@inkeep/open-knowledge 0.17.0 → 0.17.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +6 -6
- package/dist/constants-w7EkF_E3.mjs +2 -0
- package/dist/{dist-Dycch3Bo.mjs → dist-DS-lr0dJ.mjs} +3 -3
- package/dist/{dist-DyAf4V0Q.mjs → dist-DfeFCiM5.mjs} +1 -1
- package/dist/{gh-detect-5m4AdE0N.mjs → gh-detect-CenJLuMO.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/init-CvDt7Sz_.mjs +1 -0
- package/dist/{init-CnuOnNM4.mjs → init-_B_rQl4n.mjs} +4 -4
- package/dist/loader--oYkNtDH.mjs +1 -0
- package/dist/{loader-BC1xQQPM.mjs → loader-Bq4XzFk4.mjs} +2 -2
- package/dist/preview-5fRkqlhw.mjs +1 -0
- package/dist/{preview-OyCPPr4x.mjs → preview-vLTscVoK.mjs} +2 -2
- package/dist/public/assets/{ActivityModeContent-Dl8kJCiz.js → ActivityModeContent-BhLDEUEu.js} +1 -1
- package/dist/public/assets/{DocumentContext-ahzUXqR1.js → DocumentContext-BX_sV_R5.js} +3 -3
- package/dist/public/assets/{GraphPanel-BqyJr7H0.js → GraphPanel-BcI5qcvU.js} +1 -1
- package/dist/public/assets/{OpenInAgentMenuRequestContext-Clw6Qq_e.js → OpenInAgentMenuRequestContext-RVOid4N9.js} +3 -3
- package/dist/public/assets/SettingsDialogBody-HMe-8_5H.js +7 -0
- package/dist/public/assets/SourceEditor-CtjBvs7y.js +2 -0
- package/dist/public/assets/{TerminalPanel-CUIIoGHN.js → TerminalPanel-CRRQI35z.js} +1 -1
- package/dist/public/assets/{config-validation-events-Bekqky0D.js → config-validation-events-D83pJzu8.js} +5 -5
- package/dist/public/assets/{dist-Cxvuqvas.js → dist-BOw5J5xw.js} +159 -158
- package/dist/public/assets/index-BCi-zfC-.js +2002 -0
- package/dist/public/assets/index-BqjKblAJ.css +1 -0
- package/dist/public/assets/{keyboard-shortcuts-DfWwnTs8.js → keyboard-shortcuts-Cup8f5Fx.js} +1 -1
- package/dist/public/assets/{prop-types-DG4ribF0.js → prop-types-Bu6HzVRz.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-CUr8kqsv.js → target-navigation-intent-Dirj8zkE.js} +1 -1
- package/dist/public/assets/{telemetry-impl-BXM3YshC.js → telemetry-impl-BBCqZg6V.js} +1 -1
- package/dist/public/index.html +9 -9
- package/dist/{repair-launch-json-BYM8CIj6.mjs → repair-launch-json-DByxKFwf.mjs} +2 -2
- package/dist/{repair-mcp-configs-BamXpBTG.mjs → repair-mcp-configs-CT_NDRrH.mjs} +2 -2
- package/dist/{repair-skills-kKWWiqBy.mjs → repair-skills-BMwoxPAJ.mjs} +2 -2
- package/dist/repair-skills-BTAEHhVs.mjs +1 -0
- package/dist/{server-lock-BpjJj3OD-DJIGZqfz.mjs → server-lock-BpjJj3OD-DWhr5fHw.mjs} +20 -19
- package/dist/server-lock-CyhBidkz-D48N1gMX.mjs +1 -0
- package/dist/{src-pqgJP0A8.mjs → src-NINdZzPM.mjs} +2 -2
- package/dist/{start-D2qkDoxq.mjs → start-B5TStCcY.mjs} +2 -2
- package/dist/start-Bqg8vl9A.mjs +1 -0
- package/dist/{write-project-skill-9crem9HB.mjs → write-project-skill-DVFdi_YZ.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-0mGfStNQ.mjs +0 -2
- package/dist/init-BGvWkJT5.mjs +0 -1
- package/dist/loader-zIR0bbiS.mjs +0 -1
- package/dist/preview-BOn8AG6T.mjs +0 -1
- package/dist/public/assets/SettingsDialogBody-BhXgXyf7.js +0 -7
- package/dist/public/assets/SourceEditor-D2O63e1-.js +0 -2
- package/dist/public/assets/index-C0_gw-ES.js +0 -2002
- package/dist/public/assets/index-vvXWe6WY.css +0 -1
- package/dist/repair-skills-Dg0iNFNA.mjs +0 -1
- package/dist/server-lock-CyhBidkz-Bn8GS6ED.mjs +0 -1
- package/dist/start-BitVoQc9.mjs +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid.core-srYvzXpO.js","./preload-helper-2ej06EnG.js","./chunk-U2HBQHQK-DThlp4DR.js","./src-DxsrUvGr.js","./chunk-CFjPhJqf.js","./src-DXWvEiD2.js","./chunk-5PVQY5BW-D2kQfsEU.js","./dist-CfsYm4uS.js","./chunk-ICPOFSXX-Dy9JRPZu.js","./_baseFor-BB4KANPr.js","./isObjectLike-BWNDxuxw.js","./isEmpty-Bq6bzoiF.js","./chunk-336JU56O-BalL_f4q.js","./chunk-5FUZZQ4R-Bp1iPpGN.js","./chunk-X2U36JSP-b_VUmOsG.js","./chunk-ZZ45TVLE-CwnCYU7J.js","./rough.esm-DlG7R-Qx.js","./chunk-ENJZ2VHE-DGOBbqgN.js","./line-BPa9YIgj.js","./path-BA4kcoAV.js","./array-BhtCvaOB.js","./chunk-BSJP7CBP-gINBJmdn.js","./chunk-426QAEUC-CYmyjEj-.js","./chunk-XPW4576I-Dc6SL782.js","./pdf-CQwfdc8y.js","./dist-Debx6b6u.js","./dist-C0jOOVYt.js","./w3c-keyname-nBRha8PK.js","./dist-B-IVhlJQ.js","./dist-pSQcUvmU.js","./dist-D1rVZYi52.js","./dist-j3LJSXW6.js","./dist-CjXb6uie.js","./stex-CGHNatva.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{$r as c,An as l,Ar as u,At as d,Br as f,Bt as p,Cn as m,Dn as h,Dr as g,Dt as _,En as v,Er as y,Et as b,F as x,Fr as S,G as C,Gn as w,Gr as T,Gt as E,Hn as D,Hr as O,Ht as k,In as A,J as j,Jn as M,Jr as N,K as P,Kn as F,Kr as I,Nt as L,On as R,Or as z,Ot as B,P as ee,Pn as V,Pr as te,Qr as H,Rn as U,Rr as ne,Rt as W,S as re,Sn as G,Sr as ie,Tn as ae,Tr as oe,Tt as K,U as se,Un as ce,Ur as q,Ut as le,V as ue,Vn as de,Vr as fe,W as pe,Wn as me,Wt as he,X as ge,Xn as _e,Xr as ve,Yn as ye,Yr as be,Z as xe,Zn as Se,Zr as Ce,_ as we,_n as Te,a as Ee,at as De,br as Oe,ci as ke,cn as Ae,d as je,dn as Me,dt as Ne,ei as Pe,er as Fe,et as Ie,f as Le,fi as Re,fn as ze,ft as Be,g as Ve,hn as He,in as Ue,ir as We,it as Ge,jn as Ke,jr as qe,jt as Je,kn as Ye,kr as Xe,l as Ze,li as Qe,ln as $e,lr as et,lt as tt,m as nt,mt as rt,ni as it,nn as at,nt as ot,or as st,p as ct,pr as lt,pt as ut,q as dt,qn as ft,qr as pt,qt as mt,rn as ht,rr as gt,rt as _t,sn as vt,sr as yt,ti as bt,tt as xt,u as St,ui as Ct,ur as wt,v as Tt,vn as Et,w as Dt,wn as Ot,wr as kt,wt as At,x as jt,xn as Mt,xr as Nt,xt as Pt,y as Ft,yn as It,yr as Lt,zn as Rt,zr as zt}from"./dist-Cxvuqvas.js";import{c as Bt,d as Vt,i as Ht,l as Ut,o as Wt,r as Gt,s as Kt,t as qt,u as J}from"./button-CmLxDlCv.js";import{_ as Jt,a as Yt,c as Xt,d as Zt,f as Qt,g as $t,h as en,i as tn,l as nn,m as rn,n as an,o as on,p as sn,r as cn,s as ln,t as un,u as dn,v as fn}from"./dialog-uOgi9SAD.js";import{a as pn,i as mn,n as hn,o as gn,r as _n,t as vn}from"./collapsible-BzkAcCLq.js";import{A as yn,B as bn,F as xn,H as Sn,I as Cn,O as wn,P as Tn,V as En,a as Dn,b as On,c as kn,f as An,i as jn,j as Mn,m as Nn,p as Pn,r as Fn,u as In,y as Ln,z as Rn}from"./prop-types-DG4ribF0.js";import{n as zn,r as Bn}from"./dist-DuNRfJxD.js";import{t as Vn}from"./trace-api-DPMyR1_m.js";import{n as Hn,t as Un}from"./propagation-api-qAYD7s-v.js";import{a as Wn,c as Gn,d as Kn,f as qn,i as Jn,l as Yn,n as Xn,o as Zn,r as Qn,s as $n,t as er}from"./dist-CSynDsuh.js";import{S as tr,_ as nr,a as rr,b as ir,c as ar,f as or,i as sr,l as cr,m as lr,n as ur,o as dr,p as fr,s as pr,t as mr,v as hr,x as gr,y as _r}from"./tooltip-DjrmDp0P.js";import{Bt as vr,C as yr,Ct as br,D as xr,Dt as Sr,E as Cr,Et as wr,F as Tr,Ft as Er,Ht as Dr,It as Or,J as kr,L as Ar,Lt as jr,Mt as Mr,N as Nr,O as Pr,Ot as Fr,P as Ir,Pt as Lr,Q as Rr,R as Y,S as zr,St as Br,Tt as Vr,V as Hr,Vt as Ur,X as Wr,Y as Gr,a as Kr,c as qr,dt as Jr,f as Yr,j as Xr,l as Zr,n as Qr,o as $r,q as ei,r as ti,t as ni,ut as ri,xt as ii}from"./dist-C0jOOVYt.js";import{n as ai,r as oi,t as si}from"./dist-B-IVhlJQ.js";import{t as ci}from"./dist-Mxq-zflt.js";import{n as li}from"./dist-Bn0QvNGs.js";import{n as ui}from"./dist-Bui1BhSw.js";import{n as di}from"./dist-Debx6b6u.js";import{i as fi,n as pi,r as mi}from"./dist-B9B58-J_.js";import{n as hi}from"./dist-pSQcUvmU.js";import{t as gi}from"./stex-CGHNatva.js";var X=a();(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 _i=J(`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`}]]),vi=J(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),yi=J(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),bi=J(`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`}]]),xi=J(`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`}]]),Si=J(`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`}]]),Ci=J(`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`}]]),wi=J(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Ti=J(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Ei=J(`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`}]]),Di=J(`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`}]]),Oi=J(`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`}]]),ki=J(`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`}]]),Ai=J(`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`}]]),ji=J(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Mi=J(`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`}]]),Ni=J(`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`}]]),Pi=J(`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`}]]),Fi=J(`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`}]]),Ii=J(`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`}]]),Li=J(`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`}]]),Ri=J(`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`}]]),zi=J(`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`}]]),Bi=J(`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`}]]),Vi=J(`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`}]]),Hi=J(`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`}]]),Ui=J(`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`}]]),Wi=J(`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`}]]),Gi=J(`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`}]]),Ki=J(`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`}]]),qi=J(`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`}]]),Ji=J(`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`}]]),Yi=J(`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`}]]),Xi=J(`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`}]]),Zi=J(`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`}]]),Qi=J(`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`}]]),$i=J(`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`}]]),ea=J(`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`}]]),ta=[[`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`}]],na=J(`link-2`,ta),ra=J(`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`}]]),ia=J(`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`}]]),aa=J(`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`}]]),oa=J(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),sa=J(`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`}]]),ca=J(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),la=J(`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`}]]),ua=J(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),da=J(`panel-top`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]),fa=J(`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`}]]),pa=J(`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`}]]),ma=J(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),ha=J(`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`}]]),ga=J(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),_a=J(`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`}]]),va=J(`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`}]]),ya=J(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),ba=J(`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`}]]),xa=J(`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`}]]),Sa=J(`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`}]]),Ca=J(`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`}]]),wa=J(`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`}]]),Ta=J(`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`}]]),Ea=J(`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`}]]),Da=J(`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`}]]),Oa=J(`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`}]]),ka=J(`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`}]]),Aa=J(`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`}]]),ja=J(`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`}]]),Ma=e(Vt(),1),Z=s(),Q=e(r(),1);function Na(e,t){let n=(0,Z.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,Q.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,Q.useEffect)(a,o)}var Pa=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})),Fa=t(((e,t)=>{t.exports=Pa()}));function Ia(e,[t,n]){return Math.min(n,Math.max(t,e))}var La=`Popover`,[Ra,za]=Kn(La,[cr]),Ba=cr(),[Va,Ha]=Ra(La),Ua=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Ba(t),c=Q.useRef(null),[l,u]=Q.useState(!1),[d,f]=$n({prop:r,defaultProp:i??!1,onChange:a,caller:La});return(0,X.jsx)(ar,{...s,children:(0,X.jsx)(Va,{scope:t,contentId:Wn(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:Q.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:Q.useCallback(()=>u(!0),[]),onCustomAnchorRemove:Q.useCallback(()=>u(!1),[]),modal:o,children:n})})};Ua.displayName=La;var Wa=`PopoverAnchor`,Ga=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Ha(Wa,n),a=Ba(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return Q.useEffect(()=>(o(),()=>s()),[o,s]),(0,X.jsx)(rr,{...a,...r,ref:t})});Ga.displayName=Wa;var Ka=`PopoverTrigger`,qa=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Ha(Ka,n),a=Ba(n),o=Kt(t,i.triggerRef),s=(0,X.jsx)(qn.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":co(i.open),...r,ref:o,onClick:Yn(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,X.jsx)(rr,{asChild:!0,...a,children:s})});qa.displayName=Ka;var Ja=`PopoverPortal`,[Ya,Xa]=Ra(Ja,{forceMount:void 0}),Za=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Ha(Ja,t);return(0,X.jsx)(Ya,{scope:t,forceMount:n,children:(0,X.jsx)(Zn,{present:n||a.open,children:(0,X.jsx)(Xn,{asChild:!0,container:i,children:r})})})};Za.displayName=Ja;var Qa=`PopoverContent`,$a=Q.forwardRef((e,t)=>{let n=Xa(Qa,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Ha(Qa,e.__scopePopover);return(0,X.jsx)(Zn,{present:r||a.open,children:a.modal?(0,X.jsx)(to,{...i,ref:t}):(0,X.jsx)(no,{...i,ref:t})})});$a.displayName=Qa;var eo=Ht(`PopoverContent.RemoveScroll`),to=Q.forwardRef((e,t)=>{let n=Ha(Qa,e.__scopePopover),r=Q.useRef(null),i=Kt(t,r),a=Q.useRef(!1);return Q.useEffect(()=>{let e=r.current;if(e)return rn(e)},[]),(0,X.jsx)(en,{as:eo,allowPinchZoom:!0,children:(0,X.jsx)(ro,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Yn(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Yn(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:Yn(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),no=Q.forwardRef((e,t)=>{let n=Ha(Qa,e.__scopePopover),r=Q.useRef(!1),i=Q.useRef(!1);return(0,X.jsx)(ro,{...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()}})}),ro=Q.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Ha(Qa,n),p=Ba(n);return $t(),(0,X.jsx)(Jt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,X.jsx)(Qn,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,X.jsx)(pr,{"data-state":co(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)`}})})})}),io=`PopoverClose`,ao=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Ha(io,n);return(0,X.jsx)(qn.button,{type:`button`,...r,ref:t,onClick:Yn(e.onClick,()=>i.onOpenChange(!1))})});ao.displayName=io;var oo=`PopoverArrow`,so=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Ba(n);return(0,X.jsx)(dr,{...i,...r,ref:t})});so.displayName=oo;function co(e){return e?`open`:`closed`}var lo=Ua,uo=Ga,fo=qa,po=Za,mo=$a,ho=[` `,`Enter`,`ArrowUp`,`ArrowDown`],go=[` `,`Enter`],_o=`Select`,[vo,yo,bo]=gr(_o),[xo,So]=Kn(_o,[bo,cr]),Co=cr(),[wo,To]=xo(_o),[Eo,Do]=xo(_o),Oo=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=Co(t),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(!1),S=ir(l),[C,w]=$n({prop:r,defaultProp:i??!1,onChange:a,caller:_o}),[T,E]=$n({prop:o,defaultProp:s,onChange:c,caller:_o}),D=Q.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=Q.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,X.jsx)(ar,{...h,children:(0,X.jsxs)(wo,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Wn(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,X.jsx)(vo.Provider,{scope:t,children:(0,X.jsx)(Eo,{scope:e.__scopeSelect,onNativeOptionAdd:Q.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:Q.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,X.jsxs)(Cs,{"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]})})};Oo.displayName=_o;var ko=`SelectTrigger`,Ao=Q.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Co(n),o=To(ko,n),s=o.disabled||r,c=Kt(t,o.onTriggerChange),l=yo(n),u=Q.useRef(`touch`),[d,f,p]=Ts(e=>{let t=l().filter(e=>!e.disabled),n=Es(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)(rr,{asChild:!0,...a,children:(0,X.jsx)(qn.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":ws(o.value)?``:void 0,...i,ref:c,onClick:Yn(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:Yn(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:Yn(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&ho.includes(e.key)&&(m(),e.preventDefault())})})})});Ao.displayName=ko;var jo=`SelectValue`,Mo=Q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=To(jo,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Kt(t,c.onValueNodeChange);return Gn(()=>{l(u)},[l,u]),(0,X.jsx)(qn.span,{...s,ref:d,style:{pointerEvents:`none`},children:ws(c.value)?(0,X.jsx)(X.Fragment,{children:o}):a})});Mo.displayName=jo;var No=`SelectIcon`,Po=Q.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,X.jsx)(qn.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});Po.displayName=No;var Fo=`SelectPortal`,Io=e=>(0,X.jsx)(Xn,{asChild:!0,...e});Io.displayName=Fo;var Lo=`SelectContent`,Ro=Q.forwardRef((e,t)=>{let n=To(Lo,e.__scopeSelect),[r,i]=Q.useState();if(Gn(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Ma.createPortal((0,X.jsx)(Bo,{scope:e.__scopeSelect,children:(0,X.jsx)(vo.Slot,{scope:e.__scopeSelect,children:(0,X.jsx)(`div`,{children:e.children})})}),t):null}return(0,X.jsx)(Wo,{...e,ref:t})});Ro.displayName=Lo;var zo=10,[Bo,Vo]=xo(Lo),Ho=`SelectContentImpl`,Uo=Ht(`SelectContent.RemoveScroll`),Wo=Q.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=To(Lo,n),[y,b]=Q.useState(null),[x,S]=Q.useState(null),C=Kt(t,e=>b(e)),[w,T]=Q.useState(null),[E,D]=Q.useState(null),O=yo(n),[k,A]=Q.useState(!1),j=Q.useRef(!1);Q.useEffect(()=>{if(y)return rn(y)},[y]),$t();let M=Q.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),N=Q.useCallback(()=>M([w,y]),[M,w,y]);Q.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;Q.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(F.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||P(!1),document.removeEventListener(`pointermove`,t),F.current=null};return F.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,P,F]),Q.useEffect(()=>{let e=()=>P(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[P]);let[I,L]=Ts(e=>{let t=O().filter(e=>!e.disabled),n=Es(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),R=Q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),z=Q.useCallback(()=>y?.focus(),[y]),B=Q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),ee=r===`popper`?Jo:Ko,V=ee===Jo?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,X.jsx)(Bo,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:R,selectedItem:w,onItemLeave:z,itemTextRefCallback:B,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:I,children:(0,X.jsx)(en,{as:Uo,allowPinchZoom:!0,children:(0,X.jsx)(Jt,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Yn(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,X.jsx)(Qn,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,X.jsx)(ee,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...V,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:Yn(_.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()}})})})})})})});Wo.displayName=Ho;var Go=`SelectItemAlignedPosition`,Ko=Q.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=To(Lo,n),o=Vo(Lo,n),[s,c]=Q.useState(null),[l,u]=Q.useState(null),d=Kt(t,e=>u(e)),f=yo(n),p=Q.useRef(!1),m=Q.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=Q.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-zo,d=Ia(a,[zo,Math.max(zo,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-zo,d=Ia(a,[zo,Math.max(zo,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-zo*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-zo,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=`${zo}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]);Gn(()=>y(),[y]);let[b,x]=Q.useState();return Gn(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,X.jsx)(Yo,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:Q.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)(qn.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Ko.displayName=Go;var qo=`SelectPopperPosition`,Jo=Q.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=zo,...a}=e,o=Co(n);return(0,X.jsx)(pr,{...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)`}})});Jo.displayName=qo;var[Yo,Xo]=xo(Lo,{}),Zo=`SelectViewport`,Qo=Q.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Vo(Zo,n),o=Xo(Zo,n),s=Kt(t,a.onViewportChange),c=Q.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)(vo.Slot,{scope:n,children:(0,X.jsx)(qn.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Yn(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-zo*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})})})]})});Qo.displayName=Zo;var $o=`SelectGroup`,[es,ts]=xo($o),ns=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Wn();return(0,X.jsx)(es,{scope:n,id:i,children:(0,X.jsx)(qn.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});ns.displayName=$o;var rs=`SelectLabel`,is=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=ts(rs,n);return(0,X.jsx)(qn.div,{id:i.id,...r,ref:t})});is.displayName=rs;var as=`SelectItem`,[os,ss]=xo(as),cs=Q.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=To(as,n),c=Vo(as,n),l=s.value===r,[u,d]=Q.useState(a??``),[f,p]=Q.useState(!1),m=Kt(t,e=>c.itemRefCallback?.(e,r,i)),h=Wn(),g=Q.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,X.jsx)(os,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:Q.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,X.jsx)(vo.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,X.jsx)(qn.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:Yn(o.onFocus,()=>p(!0)),onBlur:Yn(o.onBlur,()=>p(!1)),onClick:Yn(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:Yn(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:Yn(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:Yn(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Yn(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Yn(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(go.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});cs.displayName=as;var ls=`SelectItemText`,us=Q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=To(ls,n),s=Vo(ls,n),c=ss(ls,n),l=Do(ls,n),[u,d]=Q.useState(null),f=Kt(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=Q.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 Gn(()=>(h(m),()=>g(m)),[h,g,m]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qn.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Ma.createPortal(a.children,o.valueNode):null]})});us.displayName=ls;var ds=`SelectItemIndicator`,fs=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return ss(ds,n).isSelected?(0,X.jsx)(qn.span,{"aria-hidden":!0,...r,ref:t}):null});fs.displayName=ds;var ps=`SelectScrollUpButton`,ms=Q.forwardRef((e,t)=>{let n=Vo(ps,e.__scopeSelect),r=Xo(ps,e.__scopeSelect),[i,a]=Q.useState(!1),o=Kt(t,r.onScrollButtonChange);return Gn(()=>{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)(_s,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});ms.displayName=ps;var hs=`SelectScrollDownButton`,gs=Q.forwardRef((e,t)=>{let n=Vo(hs,e.__scopeSelect),r=Xo(hs,e.__scopeSelect),[i,a]=Q.useState(!1),o=Kt(t,r.onScrollButtonChange);return Gn(()=>{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)(_s,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});gs.displayName=hs;var _s=Q.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Vo(`SelectScrollButton`,n),o=Q.useRef(null),s=yo(n),c=Q.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return Q.useEffect(()=>()=>c(),[c]),Gn(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,X.jsx)(qn.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Yn(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Yn(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Yn(i.onPointerLeave,()=>{c()})})}),vs=`SelectSeparator`,ys=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,X.jsx)(qn.div,{"aria-hidden":!0,...r,ref:t})});ys.displayName=vs;var bs=`SelectArrow`,xs=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Co(n),a=To(bs,n),o=Vo(bs,n);return a.open&&o.position===`popper`?(0,X.jsx)(dr,{...i,...r,ref:t}):null});xs.displayName=bs;var Ss=`SelectBubbleInput`,Cs=Q.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=Q.useRef(null),a=Kt(r,i),o=nn(t);return Q.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,X.jsx)(qn.select,{...n,style:{...tr,...n.style},ref:a,defaultValue:t})});Cs.displayName=Ss;function ws(e){return e===``||e===void 0}function Ts(e){let t=Jn(e),n=Q.useRef(``),r=Q.useRef(0),i=Q.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=Q.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return Q.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function Es(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=Ds(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 Ds(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Os=Oo,ks=Ao,As=Mo,js=Po,Ms=Io,Ns=Ro,Ps=Qo,Fs=cs,Is=us,Ls=fs,Rs=ms,zs=gs,Bs=`Switch`,[Vs,Hs]=Kn(Bs),[Us,Ws]=Vs(Bs),Gs=Q.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=Q.useState(null),m=Kt(t,e=>p(e)),h=Q.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=$n({prop:i,defaultProp:a??!1,onChange:l,caller:Bs});return(0,X.jsxs)(Us,{scope:n,checked:_,disabled:s,children:[(0,X.jsx)(qn.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":Xs(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:Yn(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,X.jsx)(Ys,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Gs.displayName=Bs;var Ks=`SwitchThumb`,qs=Q.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Ws(Ks,n);return(0,X.jsx)(qn.span,{"data-state":Xs(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});qs.displayName=Ks;var Js=`SwitchBubbleInput`,Ys=Q.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=Q.useRef(null),s=Kt(o,a),c=nn(n),l=er(t);return Q.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,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}})});Ys.displayName=Js;function Xs(e){return e?`checked`:`unchecked`}var Zs=Gs,Qs=qs;function $s(e){return e.kind===`doc`?e.docPath:e.folderPath}var ec=Fa(),tc=Bt(`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 nc(e){let t=(0,Z.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?Gt:`span`,c;t[5]!==n||t[6]!==o?(c=Ut(tc({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 rc(e){let t=(0,Z.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)(lo,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function ic(e){let t=(0,Z.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)(fo,{"data-slot":`popover-trigger`,...n}),t[2]=n,t[3]=r),r}function ac(e){let t=(0,Z.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=Ut(`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)(mo,{"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 oc(e){let t=(0,Z.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)(uo,{"data-slot":`popover-anchor`,...n}),t[2]=n,t[3]=r),r}var sc={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_APP_VERSION:`0.16.1`}?.VITE_APP_VERSION??`0.0.0-unknown`;function cc(){return he({kind:`web`,runtimeVersion:sc})}function lc(){return E({kind:`web`,runtimeVersion:sc})}function uc(e,t){return t}function dc(e){let t=e.split(`/`);return t.length<2?`ok`:`${t[0]}/${t[1]}`}function fc(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 pc(e,t,n){if(typeof performance>`u`||!performance.measure)return;let r=dc(e),i=fc(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 mc(e,t){}function hc(e,t,n){pc(e,{...t,durationMs:n},{duration:n})}var $=Object.assign(pc,{count:mc,histogram:hc});function gc(e){let t=(0,Z.c)(3),{name:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,X.jsx)(Q.Profiler,{id:n,onRender:_c,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var _c=(e,t,n,r,i,a)=>{$(`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:vc,getOwnPropertySymbols:yc}=Object,{hasOwnProperty:bc}=Object.prototype;function xc(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function Sc(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 Cc(e){return e?.[Symbol.toStringTag]}function wc(e){return vc(e).concat(yc(e))}var Tc=Object.hasOwn||((e,t)=>bc.call(e,t));function Ec(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var Dc=`__v`,Oc=`__o`,kc=`_owner`,{getOwnPropertyDescriptor:Ac,keys:jc}=Object;function Mc(e,t){return e.byteLength===t.byteLength&&Gc(new Uint8Array(e),new Uint8Array(t))}function Nc(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 Pc(e,t){return e.byteLength===t.byteLength&&Gc(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function Fc(e,t){return Ec(e.getTime(),t.getTime())}function Ic(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function Lc(e,t){return e===t}function Rc(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 zc=Ec;function Bc(e,t,n){let r=jc(e),i=r.length;if(jc(t).length!==i)return!1;for(;i-- >0;)if(!qc(e,t,n,r[i]))return!1;return!0}function Vc(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],!qc(e,t,n,a)||(o=Ac(e,a),s=Ac(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function Hc(e,t){return Ec(e.valueOf(),t.valueOf())}function Uc(e,t){return e.source===t.source&&e.flags===t.flags}function Wc(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 Gc(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 Kc(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 qc(e,t,n,r){return(r===kc||r===Oc||r===Dc)&&(e.$$typeof||t.$$typeof)?!0:Tc(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var Jc=`[object ArrayBuffer]`,Yc=`[object Arguments]`,Xc=`[object Boolean]`,Zc=`[object DataView]`,Qc=`[object Date]`,$c=`[object Error]`,el=`[object Map]`,tl=`[object Number]`,nl=`[object Object]`,rl=`[object RegExp]`,il=`[object Set]`,al=`[object String]`,ol={"[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},sl=`[object URL]`,cl=Object.prototype.toString;function ll({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=cl.call(h);if(b===Qc)return r(h,g,_);if(b===rl)return u(h,g,_);if(b===el)return o(h,g,_);if(b===il)return d(h,g,_);if(b===nl)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===sl)return p(h,g,_);if(b===$c)return i(h,g,_);if(b===Yc)return c(h,g,_);if(ol[b])return f(h,g,_);if(b===Jc)return e(h,g,_);if(b===Zc)return n(h,g,_);if(b===Xc||b===tl||b===al)return l(h,g,_);if(m){let e=m[b];if(!e){let t=Cc(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function ul({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:Mc,areArraysEqual:n?Vc:Nc,areDataViewsEqual:Pc,areDatesEqual:Fc,areErrorsEqual:Ic,areFunctionsEqual:Lc,areMapsEqual:n?xc(Rc,Vc):Rc,areNumbersEqual:zc,areObjectsEqual:n?Vc:Bc,arePrimitiveWrappersEqual:Hc,areRegExpsEqual:Uc,areSetsEqual:n?xc(Wc,Vc):Wc,areTypedArraysEqual:n?xc(Gc,Vc):Gc,areUrlsEqual:Kc,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=Sc(r.areArraysEqual),t=Sc(r.areMapsEqual),n=Sc(r.areObjectsEqual),i=Sc(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function dl(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function fl({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 pl=ml();ml({strict:!0}),ml({circular:!0}),ml({circular:!0,strict:!0}),ml({createInternalComparator:()=>Ec}),ml({strict:!0,createInternalComparator:()=>Ec}),ml({circular:!0,createInternalComparator:()=>Ec}),ml({circular:!0,createInternalComparator:()=>Ec,strict:!0});function ml(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=ll(ul(e));return fl({circular:t,comparator:a,createState:r,equals:n?n(a):dl(a),strict:i})}var hl=t((e=>{var t=r(),n=Fa();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}})),gl=t(((e,t)=>{t.exports=hl()}))(),_l=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},vl=({contentComponent:e})=>{let t=(0,ec.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,X.jsx)(X.Fragment,{children:Object.values(t)})};function yl(){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]:Ma.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 bl=class extends Q.Component{constructor(e){super(e),this.editorContentRef=Q.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=yl(),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:_l(t,this.editorContentRef),...n}),e?.contentComponent&&(0,X.jsx)(vl,{contentComponent:e.contentComponent})]})}},xl=(0,Q.forwardRef)((e,t)=>{let n=Q.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return Q.createElement(bl,{key:n,innerRef:t,...e})}),Sl=Q.memo(xl),Cl=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,wl=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 Tl(e){let[t]=(0,Q.useState)(()=>new wl(e.editor)),n=(0,gl.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??pl);return Cl(()=>t.watch(e.editor),[e.editor,t]),(0,Q.useDebugValue)(n),n}typeof window>`u`||typeof window<`u`&&window.next;var El=(0,Q.createContext)({editor:null});El.Consumer;var Dl=()=>(0,Q.useContext)(El),Ol=(0,Q.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),kl=()=>(0,Q.useContext)(Ol);function Al({as:e=`div`,...t}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=kl();return(0,X.jsx)(e,{...t,ref:n,"data-node-view-content":``,style:{whiteSpace:`pre-wrap`,...t.style},children:r})}var jl=Q.forwardRef((e,t)=>{let{onDragStart:n}=kl();return(0,X.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})});function Ml(e){return!!(typeof e==`function`&&e.prototype&&e.prototype.isReactComponent)}function Nl(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.forward_ref)`||e.$$typeof.description===`react.forward_ref`))}function Pl(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.memo)`||e.$$typeof.description===`react.memo`))}function Fl(e){if(Ml(e)||Nl(e))return!0;if(Pl(e)){let t=e.type;if(t)return Ml(t)||Nl(t)}return!1}function Il(){try{if(Q.version)return parseInt(Q.version.split(`.`)[0],10)>=19}catch{}return!1}var Ll=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,Ma.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=Il(),a=Fl(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])})}};Q.createContext({markViewContentRef:()=>{}});var Rl=class extends y{constructor(e,t,n){if(super(e,t,n),this.selectionRafId=null,this.positionCheckCallback=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?`span`:`div`),this.contentDOMElement.dataset.nodeViewContentReact=``,this.contentDOMElement.dataset.nodeViewWrapper=``,this.contentDOMElement.style.whiteSpace=`inherit`;let e=this.dom.querySelector(`[data-node-view-content]`);if(!e)return;e.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,i){return r===`storage`?e.storage[t.name]??{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:(0,Q.createRef)()};if(!this.component.displayName){let e=e=>e.charAt(0).toUpperCase()+e.substring(1);this.component.displayName=e(this.extension.name)}let t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&(e.hasAttribute(`data-node-view-wrapper`)&&e.removeAttribute(`data-node-view-wrapper`),e.appendChild(this.contentDOMElement))}},n=this.component,r=(0,Q.memo)(e=>(0,X.jsx)(Ol.Provider,{value:t,children:(0,Q.createElement)(n,e)}));r.displayName=`ReactNodeView`;let i=this.node.isInline?`span`:`div`;this.options.as&&(i=this.options.as);let{className:a=``}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Ll(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())},f(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&&=(g(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=u(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function zl(e,t){return n=>n.editor.contentComponent?new Rl(e,n,t):{}}var Bl=(0,Q.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});Bl.displayName=`TiptapContext`;var Vl=()=>(0,Q.useContext)(Bl);function Hl({editor:e,instance:t,children:n}){let r=e??t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,Q.useMemo)(()=>({editor:r}),[r]),a=(0,Q.useMemo)(()=>({editor:r}),[r]);return(0,X.jsx)(El.Provider,{value:a,children:(0,X.jsx)(Bl.Provider,{value:i,children:n})})}Hl.displayName=`Tiptap`;function Ul({...e}){let{editor:t}=Vl();return(0,X.jsx)(Sl,{editor:t,...e})}Ul.displayName=`Tiptap.Content`,Object.assign(Hl,{Content:Ul});var Wl=()=>new Map,Gl=e=>{let t=Wl();return e.forEach((e,n)=>{t.set(n,e)}),t},Kl=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},ql=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Jl=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},Yl=()=>new Set,Xl=e=>e[e.length-1],Zl=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},Ql=Array.from,$l=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},eu=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},tu=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},nu=Array.isArray,ru=class{constructor(){this._observers=Wl()}on(e,t){return Kl(this._observers,e,Yl).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 Ql((this._observers.get(e)||Wl()).values()).forEach(e=>e(...t))}destroy(){this._observers=Wl()}},iu=class{constructor(){this._observers=Wl()}on(e,t){Kl(this._observers,e,Yl).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 Ql((this._observers.get(e)||Wl()).values()).forEach(e=>e(...t))}destroy(){this._observers=Wl()}},au=Math.floor,ou=Math.abs,su=(e,t)=>e<t?e:t,cu=(e,t)=>e>t?e:t;Number.isNaN;var lu=e=>e===0?1/e<0:e<0,uu=1<<17,du=1<<18,fu=1<<19,pu=1<<20,mu=1<<21,hu=1<<22,gu=1<<23,_u=1<<24,vu=1<<25,yu=1<<26,bu=1<<27,xu=1<<28,Su=1<<29;uu-1,du-1,fu-1,pu-1,mu-1,hu-1,gu-1,_u-1,vu-1,yu-1,bu-1,xu-1,Su-1;var Cu=2**53-1,wu=-(2**53-1),Tu=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&au(e)===e);Number.isNaN,Number.parseInt;var Eu=String.fromCharCode;String.fromCodePoint,Eu(65535);var Du=e=>e.toLowerCase(),Ou=/^\s*/g,ku=e=>e.replace(Ou,``),Au=/([A-Z])/g,ju=(e,t)=>ku(e.replace(Au,e=>`${t}${Du(e)}`)),Mu=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},Nu=typeof TextEncoder<`u`?new TextEncoder:null,Pu=Nu?e=>Nu.encode(e):Mu,Fu=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Fu&&Fu.decode(new Uint8Array).length===1&&(Fu=null);var Iu=(e,t)=>tu(t,()=>e).join(``),Lu=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Ru=()=>new Lu,zu=e=>{let t=Ru();return e(t),Vu(t)},Bu=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},Vu=e=>{let t=new Uint8Array(Bu(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},Hu=(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(cu(n,t)*2),e.cpos=0)},Uu=(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},Wu=Uu,Gu=(e,t)=>{for(;t>127;)Uu(e,128|127&t),t=au(t/128);Uu(e,127&t)},Ku=(e,t)=>{let n=lu(t);for(n&&(t=-t),Uu(e,(t>63?128:0)|(n?64:0)|63&t),t=au(t/64);t>0;)Uu(e,(t>127?128:0)|127&t),t=au(t/128)},qu=new Uint8Array(3e4),Ju=qu.length/3,Yu=Nu&&Nu.encodeInto?(e,t)=>{if(t.length<Ju){let n=Nu.encodeInto(t,qu).written||0;Gu(e,n);for(let t=0;t<n;t++)Uu(e,qu[t])}else Zu(e,Pu(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Gu(e,r);for(let t=0;t<r;t++)Uu(e,n.codePointAt(t))},Xu=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=su(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(cu(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Zu=(e,t)=>{Gu(e,t.byteLength),Xu(e,t)},Qu=(e,t)=>{Hu(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},$u=(e,t)=>Qu(e,4).setFloat32(0,t,!1),ed=(e,t)=>Qu(e,8).setFloat64(0,t,!1),td=(e,t)=>Qu(e,8).setBigInt64(0,t,!1),nd=new DataView(new ArrayBuffer(4)),rd=e=>(nd.setFloat32(0,e),nd.getFloat32(0)===e),id=(e,t)=>{switch(typeof t){case`string`:Uu(e,119),Yu(e,t);break;case`number`:Tu(t)&&ou(t)<=2147483647?(Uu(e,125),Ku(e,t)):rd(t)?(Uu(e,124),$u(e,t)):(Uu(e,123),ed(e,t));break;case`bigint`:Uu(e,122),td(e,t);break;case`object`:if(t===null)Uu(e,126);else if(nu(t)){Uu(e,117),Gu(e,t.length);for(let n=0;n<t.length;n++)id(e,t[n])}else if(t instanceof Uint8Array)Uu(e,116),Zu(e,t);else{Uu(e,118);let n=Object.keys(t);Gu(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];Yu(e,i),id(e,t[i])}}break;case`boolean`:Uu(e,t?120:121);break;default:Uu(e,127)}},ad=class extends Lu{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Gu(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},od=e=>{e.count>0&&(Ku(e.encoder,e.count===1?e.s:-e.s),e.count>1&&Gu(e.encoder,e.count-2))},sd=class{constructor(){this.encoder=new Lu,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),Vu(this.encoder)}},cd=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);Ku(e.encoder,t),e.count>1&&Gu(e.encoder,e.count-2)}},ld=class{constructor(){this.encoder=new Lu,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(cd(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return cd(this),Vu(this.encoder)}},ud=class{constructor(){this.sarr=[],this.s=``,this.lensE=new sd}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 Lu;return this.sarr.push(this.s),this.s=``,Yu(e,this.sarr.join(``)),Xu(e,this.lensE.toUint8Array()),Vu(e)}},dd=e=>Error(e),fd=()=>{throw dd(`Method unimplemented`)},pd=()=>{throw dd(`Unexpected case`)},md=dd(`Unexpected end of array`),hd=dd(`Integer out of Range`),gd=class{constructor(e){this.arr=e,this.pos=0}},_d=e=>new gd(e),vd=e=>e.pos!==e.arr.length,yd=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},bd=e=>yd(e,Sd(e)),xd=e=>e.arr[e.pos++],Sd=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>Cu)throw hd}throw md},Cd=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>Cu)throw hd}throw md},wd=Fu?e=>Fu.decode(bd(e)):e=>{let t=Sd(e);if(t===0)return``;{let n=String.fromCodePoint(xd(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(xd(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))}},Td=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Ed=[e=>void 0,e=>null,Cd,e=>Td(e,4).getFloat32(0,!1),e=>Td(e,8).getFloat64(0,!1),e=>Td(e,8).getBigInt64(0,!1),e=>!1,e=>!0,wd,e=>{let t=Sd(e),n={};for(let r=0;r<t;r++){let t=wd(e);n[t]=Dd(e)}return n},e=>{let t=Sd(e),n=[];for(let r=0;r<t;r++)n.push(Dd(e));return n},bd],Dd=e=>Ed[127-xd(e)](e),Od=class extends gd{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),vd(this)?this.count=Sd(this)+1:this.count=-1),this.count--,this.s}},kd=class extends gd{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Cd(this);let e=lu(this.s);this.count=1,e&&(this.s=-this.s,this.count=Sd(this)+2)}return this.count--,this.s}},Ad=class extends gd{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Cd(this),t=e&1;this.diff=au(e/2),this.count=1,t&&(this.count=Sd(this)+2)}return this.s+=this.diff,this.count--,this.s}},jd=class{constructor(e){this.decoder=new kd(e),this.str=wd(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 Md=crypto.getRandomValues.bind(crypto),Nd=Math.random,Pd=()=>Md(new Uint32Array(1))[0],Fd=e=>e[au(Nd()*e.length)],Id=`10000000-1000-4000-8000-100000000000`,Ld=()=>Id.replace(/[018]/g,e=>(e^Pd()&15>>e/4).toString(16)),Rd=Date.now,zd=e=>new Promise(e);Promise.all.bind(Promise);var Bd=e=>e===void 0?null:e,Vd=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&&(Vd=localStorage)}catch{}var Hd=Vd,Ud=Symbol(`Equality`),Wd=(e,t)=>e===t||!!e?.[Ud]?.(t)||!1,Gd=e=>typeof e==`object`,Kd=Object.assign,qd=Object.keys,Jd=(e,t)=>{for(let n in e)t(e[n],n)},Yd=e=>qd(e).length,Xd=e=>{for(let t in e)return!1;return!0},Zd=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Qd=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),$d=(e,t)=>e===t||Yd(e)===Yd(t)&&Zd(e,(e,n)=>(e!==void 0||Qd(t,n))&&Wd(t[n],e)),ef=Object.freeze,tf=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&tf(e[t])}return ef(e)},nf=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&nf(e,t,n+1)}},rf=e=>e,af=(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[Ud]!=null)return e[Ud](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)||!af(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Yd(e)!==Yd(t))return!1;for(let n in e)if(!Qd(e,n)||!af(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(!af(e[n],t[n]))return!1;break;default:return!1}return!0},of=(e,t)=>t.includes(e),sf=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,cf=typeof window<`u`&&typeof document<`u`&&!sf;typeof navigator<`u`&&/Mac/.test(navigator.platform);var lf,uf=[],df=()=>{if(lf===void 0)if(sf){lf=Wl();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&lf.set(t,``),t=r):t===null?uf.push(r):(lf.set(t,r),t=null)}t!==null&&lf.set(t,``)}else typeof location==`object`?(lf=Wl(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);lf.set(`--${ju(t,`-`)}`,n),lf.set(`-${ju(t,`-`)}`,n)}})):lf=Wl();return lf},ff=e=>df().has(e),pf=e=>Bd(sf?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Hd.getItem(e)),mf=e=>ff(`--`+e)||pf(e)!==null,hf=mf(`production`),gf=sf&&of({}.FORCE_COLOR,[`true`,`1`,`2`])||!ff(`--no-colors`)&&!mf(`no-color`)&&(!sf||process.stdout.isTTY)&&(!sf||ff(`--color`)||pf(`COLORTERM`)!==null||(pf(`TERM`)||``).includes(`color`)),_f=e=>new Uint8Array(e),vf=cf?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Eu(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),yf=e=>{let t=_f(e.byteLength);return t.set(e),t},bf=e=>zu(t=>id(t,e)),xf=class{constructor(e,t){this.left=e,this.right=t}},Sf=(e,t)=>new xf(e,t),Cf=(e,t)=>e.forEach(e=>t(e.left,e.right)),wf=e=>e.next()>=.5,Tf=(e,t,n)=>au(e.next()*(n+1-t)+t),Ef=(e,t,n)=>au(e.next()*(n+1-t)+t),Df=(e,t,n)=>Ef(e,t,n),Of=e=>Eu(Df(e,97,122)),kf=(e,t=0,n=20)=>{let r=Df(e,t,n),i=``;for(let t=0;t<r;t++)i+=Of(e);return i},Af=(e,t)=>t[Df(e,0,t.length-1)],jf=Symbol(`0schema`),Mf=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(Iu(` `,(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{$r as c,An as l,Ar as u,At as d,Br as f,Bt as p,Cn as m,Dn as h,Dr as g,Dt as _,En as v,Er as y,Et as b,F as x,Fr as S,G as C,Gn as w,Gr as T,Gt as E,Hn as D,Hr as O,Ht as k,In as A,J as j,Jn as M,Jr as N,K as P,Kn as F,Kr as I,Nt as L,On as R,Or as z,Ot as B,P as ee,Pn as V,Pr as te,Qr as H,Rn as U,Rr as ne,Rt as W,S as re,Sn as G,Sr as ie,Tn as ae,Tr as oe,Tt as K,U as se,Un as ce,Ur as q,Ut as le,V as ue,Vn as de,Vr as fe,W as pe,Wn as me,Wt as he,X as ge,Xn as _e,Xr as ve,Yn as ye,Yr as be,Z as xe,Zn as Se,Zr as Ce,_ as we,_n as Te,a as Ee,at as De,br as Oe,ci as ke,cn as Ae,d as je,dn as Me,dt as Ne,ei as Pe,er as Fe,et as Ie,f as Le,fi as Re,fn as ze,ft as Be,g as Ve,hn as He,in as Ue,ir as We,it as Ge,jn as Ke,jr as qe,jt as Je,kn as Ye,kr as Xe,l as Ze,li as Qe,ln as $e,lr as et,lt as tt,m as nt,mt as rt,ni as it,nn as at,nt as ot,or as st,p as ct,pr as lt,pt as ut,q as dt,qn as ft,qr as pt,qt as mt,rn as ht,rr as gt,rt as _t,sn as vt,sr as yt,ti as bt,tt as xt,u as St,ui as Ct,ur as wt,v as Tt,vn as Et,w as Dt,wn as Ot,wr as kt,wt as At,x as jt,xn as Mt,xr as Nt,xt as Pt,y as Ft,yn as It,yr as Lt,zn as Rt,zr as zt}from"./dist-BOw5J5xw.js";import{c as Bt,d as Vt,i as Ht,l as Ut,o as Wt,r as Gt,s as Kt,t as qt,u as J}from"./button-CmLxDlCv.js";import{_ as Jt,a as Yt,c as Xt,d as Zt,f as Qt,g as $t,h as en,i as tn,l as nn,m as rn,n as an,o as on,p as sn,r as cn,s as ln,t as un,u as dn,v as fn}from"./dialog-uOgi9SAD.js";import{a as pn,i as mn,n as hn,o as gn,r as _n,t as vn}from"./collapsible-BzkAcCLq.js";import{A as yn,B as bn,F as xn,H as Sn,I as Cn,O as wn,P as Tn,V as En,a as Dn,b as On,c as kn,f as An,i as jn,j as Mn,m as Nn,p as Pn,r as Fn,u as In,y as Ln,z as Rn}from"./prop-types-Bu6HzVRz.js";import{n as zn,r as Bn}from"./dist-DuNRfJxD.js";import{t as Vn}from"./trace-api-DPMyR1_m.js";import{n as Hn,t as Un}from"./propagation-api-qAYD7s-v.js";import{a as Wn,c as Gn,d as Kn,f as qn,i as Jn,l as Yn,n as Xn,o as Zn,r as Qn,s as $n,t as er}from"./dist-CSynDsuh.js";import{S as tr,_ as nr,a as rr,b as ir,c as ar,f as or,i as sr,l as cr,m as lr,n as ur,o as dr,p as fr,s as pr,t as mr,v as hr,x as gr,y as _r}from"./tooltip-DjrmDp0P.js";import{Bt as vr,C as yr,Ct as br,D as xr,Dt as Sr,E as Cr,Et as wr,F as Tr,Ft as Er,Ht as Dr,It as Or,J as kr,L as Ar,Lt as jr,Mt as Mr,N as Nr,O as Pr,Ot as Fr,P as Ir,Pt as Lr,Q as Rr,R as Y,S as zr,St as Br,Tt as Vr,V as Hr,Vt as Ur,X as Wr,Y as Gr,a as Kr,c as qr,dt as Jr,f as Yr,j as Xr,l as Zr,n as Qr,o as $r,q as ei,r as ti,t as ni,ut as ri,xt as ii}from"./dist-C0jOOVYt.js";import{n as ai,r as oi,t as si}from"./dist-B-IVhlJQ.js";import{t as ci}from"./dist-Mxq-zflt.js";import{n as li}from"./dist-Bn0QvNGs.js";import{n as ui}from"./dist-Bui1BhSw.js";import{n as di}from"./dist-Debx6b6u.js";import{i as fi,n as pi,r as mi}from"./dist-B9B58-J_.js";import{n as hi}from"./dist-pSQcUvmU.js";import{t as gi}from"./stex-CGHNatva.js";var X=a();(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 _i=J(`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`}]]),vi=J(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),yi=J(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),bi=J(`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`}]]),xi=J(`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`}]]),Si=J(`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`}]]),Ci=J(`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`}]]),wi=J(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Ti=J(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Ei=J(`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`}]]),Di=J(`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`}]]),Oi=J(`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`}]]),ki=J(`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`}]]),Ai=J(`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`}]]),ji=J(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Mi=J(`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`}]]),Ni=J(`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`}]]),Pi=J(`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`}]]),Fi=J(`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`}]]),Ii=J(`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`}]]),Li=J(`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`}]]),Ri=J(`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`}]]),zi=J(`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`}]]),Bi=J(`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`}]]),Vi=J(`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`}]]),Hi=J(`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`}]]),Ui=J(`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`}]]),Wi=J(`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`}]]),Gi=J(`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`}]]),Ki=J(`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`}]]),qi=J(`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`}]]),Ji=J(`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`}]]),Yi=J(`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`}]]),Xi=J(`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`}]]),Zi=J(`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`}]]),Qi=J(`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`}]]),$i=J(`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`}]]),ea=J(`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`}]]),ta=[[`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`}]],na=J(`link-2`,ta),ra=J(`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`}]]),ia=J(`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`}]]),aa=J(`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`}]]),oa=J(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),sa=J(`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`}]]),ca=J(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),la=J(`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`}]]),ua=J(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),da=J(`panel-top`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]),fa=J(`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`}]]),pa=J(`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`}]]),ma=J(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),ha=J(`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`}]]),ga=J(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),_a=J(`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`}]]),va=J(`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`}]]),ya=J(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),ba=J(`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`}]]),xa=J(`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`}]]),Sa=J(`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`}]]),Ca=J(`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`}]]),wa=J(`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`}]]),Ta=J(`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`}]]),Ea=J(`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`}]]),Da=J(`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`}]]),Oa=J(`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`}]]),ka=J(`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`}]]),Aa=J(`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`}]]),ja=J(`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`}]]),Ma=e(Vt(),1),Z=s(),Q=e(r(),1);function Na(e,t){let n=(0,Z.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,Q.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,Q.useEffect)(a,o)}var Pa=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})),Fa=t(((e,t)=>{t.exports=Pa()}));function Ia(e,[t,n]){return Math.min(n,Math.max(t,e))}var La=`Popover`,[Ra,za]=Kn(La,[cr]),Ba=cr(),[Va,Ha]=Ra(La),Ua=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Ba(t),c=Q.useRef(null),[l,u]=Q.useState(!1),[d,f]=$n({prop:r,defaultProp:i??!1,onChange:a,caller:La});return(0,X.jsx)(ar,{...s,children:(0,X.jsx)(Va,{scope:t,contentId:Wn(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:Q.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:Q.useCallback(()=>u(!0),[]),onCustomAnchorRemove:Q.useCallback(()=>u(!1),[]),modal:o,children:n})})};Ua.displayName=La;var Wa=`PopoverAnchor`,Ga=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Ha(Wa,n),a=Ba(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return Q.useEffect(()=>(o(),()=>s()),[o,s]),(0,X.jsx)(rr,{...a,...r,ref:t})});Ga.displayName=Wa;var Ka=`PopoverTrigger`,qa=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Ha(Ka,n),a=Ba(n),o=Kt(t,i.triggerRef),s=(0,X.jsx)(qn.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":co(i.open),...r,ref:o,onClick:Yn(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,X.jsx)(rr,{asChild:!0,...a,children:s})});qa.displayName=Ka;var Ja=`PopoverPortal`,[Ya,Xa]=Ra(Ja,{forceMount:void 0}),Za=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Ha(Ja,t);return(0,X.jsx)(Ya,{scope:t,forceMount:n,children:(0,X.jsx)(Zn,{present:n||a.open,children:(0,X.jsx)(Xn,{asChild:!0,container:i,children:r})})})};Za.displayName=Ja;var Qa=`PopoverContent`,$a=Q.forwardRef((e,t)=>{let n=Xa(Qa,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Ha(Qa,e.__scopePopover);return(0,X.jsx)(Zn,{present:r||a.open,children:a.modal?(0,X.jsx)(to,{...i,ref:t}):(0,X.jsx)(no,{...i,ref:t})})});$a.displayName=Qa;var eo=Ht(`PopoverContent.RemoveScroll`),to=Q.forwardRef((e,t)=>{let n=Ha(Qa,e.__scopePopover),r=Q.useRef(null),i=Kt(t,r),a=Q.useRef(!1);return Q.useEffect(()=>{let e=r.current;if(e)return rn(e)},[]),(0,X.jsx)(en,{as:eo,allowPinchZoom:!0,children:(0,X.jsx)(ro,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Yn(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Yn(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:Yn(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),no=Q.forwardRef((e,t)=>{let n=Ha(Qa,e.__scopePopover),r=Q.useRef(!1),i=Q.useRef(!1);return(0,X.jsx)(ro,{...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()}})}),ro=Q.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Ha(Qa,n),p=Ba(n);return $t(),(0,X.jsx)(Jt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,X.jsx)(Qn,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,X.jsx)(pr,{"data-state":co(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)`}})})})}),io=`PopoverClose`,ao=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Ha(io,n);return(0,X.jsx)(qn.button,{type:`button`,...r,ref:t,onClick:Yn(e.onClick,()=>i.onOpenChange(!1))})});ao.displayName=io;var oo=`PopoverArrow`,so=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Ba(n);return(0,X.jsx)(dr,{...i,...r,ref:t})});so.displayName=oo;function co(e){return e?`open`:`closed`}var lo=Ua,uo=Ga,fo=qa,po=Za,mo=$a,ho=[` `,`Enter`,`ArrowUp`,`ArrowDown`],go=[` `,`Enter`],_o=`Select`,[vo,yo,bo]=gr(_o),[xo,So]=Kn(_o,[bo,cr]),Co=cr(),[wo,To]=xo(_o),[Eo,Do]=xo(_o),Oo=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=Co(t),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(!1),S=ir(l),[C,w]=$n({prop:r,defaultProp:i??!1,onChange:a,caller:_o}),[T,E]=$n({prop:o,defaultProp:s,onChange:c,caller:_o}),D=Q.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=Q.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,X.jsx)(ar,{...h,children:(0,X.jsxs)(wo,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Wn(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,X.jsx)(vo.Provider,{scope:t,children:(0,X.jsx)(Eo,{scope:e.__scopeSelect,onNativeOptionAdd:Q.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:Q.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,X.jsxs)(Cs,{"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]})})};Oo.displayName=_o;var ko=`SelectTrigger`,Ao=Q.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Co(n),o=To(ko,n),s=o.disabled||r,c=Kt(t,o.onTriggerChange),l=yo(n),u=Q.useRef(`touch`),[d,f,p]=Ts(e=>{let t=l().filter(e=>!e.disabled),n=Es(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)(rr,{asChild:!0,...a,children:(0,X.jsx)(qn.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":ws(o.value)?``:void 0,...i,ref:c,onClick:Yn(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:Yn(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:Yn(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&ho.includes(e.key)&&(m(),e.preventDefault())})})})});Ao.displayName=ko;var jo=`SelectValue`,Mo=Q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=To(jo,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Kt(t,c.onValueNodeChange);return Gn(()=>{l(u)},[l,u]),(0,X.jsx)(qn.span,{...s,ref:d,style:{pointerEvents:`none`},children:ws(c.value)?(0,X.jsx)(X.Fragment,{children:o}):a})});Mo.displayName=jo;var No=`SelectIcon`,Po=Q.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,X.jsx)(qn.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});Po.displayName=No;var Fo=`SelectPortal`,Io=e=>(0,X.jsx)(Xn,{asChild:!0,...e});Io.displayName=Fo;var Lo=`SelectContent`,Ro=Q.forwardRef((e,t)=>{let n=To(Lo,e.__scopeSelect),[r,i]=Q.useState();if(Gn(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Ma.createPortal((0,X.jsx)(Bo,{scope:e.__scopeSelect,children:(0,X.jsx)(vo.Slot,{scope:e.__scopeSelect,children:(0,X.jsx)(`div`,{children:e.children})})}),t):null}return(0,X.jsx)(Wo,{...e,ref:t})});Ro.displayName=Lo;var zo=10,[Bo,Vo]=xo(Lo),Ho=`SelectContentImpl`,Uo=Ht(`SelectContent.RemoveScroll`),Wo=Q.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=To(Lo,n),[y,b]=Q.useState(null),[x,S]=Q.useState(null),C=Kt(t,e=>b(e)),[w,T]=Q.useState(null),[E,D]=Q.useState(null),O=yo(n),[k,A]=Q.useState(!1),j=Q.useRef(!1);Q.useEffect(()=>{if(y)return rn(y)},[y]),$t();let M=Q.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),N=Q.useCallback(()=>M([w,y]),[M,w,y]);Q.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;Q.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(F.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||P(!1),document.removeEventListener(`pointermove`,t),F.current=null};return F.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,P,F]),Q.useEffect(()=>{let e=()=>P(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[P]);let[I,L]=Ts(e=>{let t=O().filter(e=>!e.disabled),n=Es(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),R=Q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),z=Q.useCallback(()=>y?.focus(),[y]),B=Q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),ee=r===`popper`?Jo:Ko,V=ee===Jo?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,X.jsx)(Bo,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:R,selectedItem:w,onItemLeave:z,itemTextRefCallback:B,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:I,children:(0,X.jsx)(en,{as:Uo,allowPinchZoom:!0,children:(0,X.jsx)(Jt,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Yn(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,X.jsx)(Qn,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,X.jsx)(ee,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...V,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:Yn(_.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()}})})})})})})});Wo.displayName=Ho;var Go=`SelectItemAlignedPosition`,Ko=Q.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=To(Lo,n),o=Vo(Lo,n),[s,c]=Q.useState(null),[l,u]=Q.useState(null),d=Kt(t,e=>u(e)),f=yo(n),p=Q.useRef(!1),m=Q.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=Q.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-zo,d=Ia(a,[zo,Math.max(zo,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-zo,d=Ia(a,[zo,Math.max(zo,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-zo*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-zo,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=`${zo}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]);Gn(()=>y(),[y]);let[b,x]=Q.useState();return Gn(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,X.jsx)(Yo,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:Q.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)(qn.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Ko.displayName=Go;var qo=`SelectPopperPosition`,Jo=Q.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=zo,...a}=e,o=Co(n);return(0,X.jsx)(pr,{...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)`}})});Jo.displayName=qo;var[Yo,Xo]=xo(Lo,{}),Zo=`SelectViewport`,Qo=Q.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Vo(Zo,n),o=Xo(Zo,n),s=Kt(t,a.onViewportChange),c=Q.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)(vo.Slot,{scope:n,children:(0,X.jsx)(qn.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Yn(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-zo*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})})})]})});Qo.displayName=Zo;var $o=`SelectGroup`,[es,ts]=xo($o),ns=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Wn();return(0,X.jsx)(es,{scope:n,id:i,children:(0,X.jsx)(qn.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});ns.displayName=$o;var rs=`SelectLabel`,is=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=ts(rs,n);return(0,X.jsx)(qn.div,{id:i.id,...r,ref:t})});is.displayName=rs;var as=`SelectItem`,[os,ss]=xo(as),cs=Q.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=To(as,n),c=Vo(as,n),l=s.value===r,[u,d]=Q.useState(a??``),[f,p]=Q.useState(!1),m=Kt(t,e=>c.itemRefCallback?.(e,r,i)),h=Wn(),g=Q.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,X.jsx)(os,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:Q.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,X.jsx)(vo.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,X.jsx)(qn.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:Yn(o.onFocus,()=>p(!0)),onBlur:Yn(o.onBlur,()=>p(!1)),onClick:Yn(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:Yn(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:Yn(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:Yn(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Yn(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Yn(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(go.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});cs.displayName=as;var ls=`SelectItemText`,us=Q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=To(ls,n),s=Vo(ls,n),c=ss(ls,n),l=Do(ls,n),[u,d]=Q.useState(null),f=Kt(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=Q.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 Gn(()=>(h(m),()=>g(m)),[h,g,m]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qn.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Ma.createPortal(a.children,o.valueNode):null]})});us.displayName=ls;var ds=`SelectItemIndicator`,fs=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return ss(ds,n).isSelected?(0,X.jsx)(qn.span,{"aria-hidden":!0,...r,ref:t}):null});fs.displayName=ds;var ps=`SelectScrollUpButton`,ms=Q.forwardRef((e,t)=>{let n=Vo(ps,e.__scopeSelect),r=Xo(ps,e.__scopeSelect),[i,a]=Q.useState(!1),o=Kt(t,r.onScrollButtonChange);return Gn(()=>{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)(_s,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});ms.displayName=ps;var hs=`SelectScrollDownButton`,gs=Q.forwardRef((e,t)=>{let n=Vo(hs,e.__scopeSelect),r=Xo(hs,e.__scopeSelect),[i,a]=Q.useState(!1),o=Kt(t,r.onScrollButtonChange);return Gn(()=>{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)(_s,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});gs.displayName=hs;var _s=Q.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Vo(`SelectScrollButton`,n),o=Q.useRef(null),s=yo(n),c=Q.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return Q.useEffect(()=>()=>c(),[c]),Gn(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,X.jsx)(qn.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Yn(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Yn(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Yn(i.onPointerLeave,()=>{c()})})}),vs=`SelectSeparator`,ys=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,X.jsx)(qn.div,{"aria-hidden":!0,...r,ref:t})});ys.displayName=vs;var bs=`SelectArrow`,xs=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Co(n),a=To(bs,n),o=Vo(bs,n);return a.open&&o.position===`popper`?(0,X.jsx)(dr,{...i,...r,ref:t}):null});xs.displayName=bs;var Ss=`SelectBubbleInput`,Cs=Q.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=Q.useRef(null),a=Kt(r,i),o=nn(t);return Q.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,X.jsx)(qn.select,{...n,style:{...tr,...n.style},ref:a,defaultValue:t})});Cs.displayName=Ss;function ws(e){return e===``||e===void 0}function Ts(e){let t=Jn(e),n=Q.useRef(``),r=Q.useRef(0),i=Q.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=Q.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return Q.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function Es(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=Ds(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 Ds(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Os=Oo,ks=Ao,As=Mo,js=Po,Ms=Io,Ns=Ro,Ps=Qo,Fs=cs,Is=us,Ls=fs,Rs=ms,zs=gs,Bs=`Switch`,[Vs,Hs]=Kn(Bs),[Us,Ws]=Vs(Bs),Gs=Q.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=Q.useState(null),m=Kt(t,e=>p(e)),h=Q.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=$n({prop:i,defaultProp:a??!1,onChange:l,caller:Bs});return(0,X.jsxs)(Us,{scope:n,checked:_,disabled:s,children:[(0,X.jsx)(qn.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":Xs(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:Yn(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,X.jsx)(Ys,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Gs.displayName=Bs;var Ks=`SwitchThumb`,qs=Q.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Ws(Ks,n);return(0,X.jsx)(qn.span,{"data-state":Xs(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});qs.displayName=Ks;var Js=`SwitchBubbleInput`,Ys=Q.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=Q.useRef(null),s=Kt(o,a),c=nn(n),l=er(t);return Q.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,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}})});Ys.displayName=Js;function Xs(e){return e?`checked`:`unchecked`}var Zs=Gs,Qs=qs;function $s(e){return e.kind===`doc`?e.docPath:e.folderPath}var ec=Fa(),tc=Bt(`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 nc(e){let t=(0,Z.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?Gt:`span`,c;t[5]!==n||t[6]!==o?(c=Ut(tc({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 rc(e){let t=(0,Z.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)(lo,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function ic(e){let t=(0,Z.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)(fo,{"data-slot":`popover-trigger`,...n}),t[2]=n,t[3]=r),r}function ac(e){let t=(0,Z.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=Ut(`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)(mo,{"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 oc(e){let t=(0,Z.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)(uo,{"data-slot":`popover-anchor`,...n}),t[2]=n,t[3]=r),r}var sc={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_APP_VERSION:`0.17.0`}?.VITE_APP_VERSION??`0.0.0-unknown`;function cc(){return he({kind:`web`,runtimeVersion:sc})}function lc(){return E({kind:`web`,runtimeVersion:sc})}function uc(e,t){return t}function dc(e){let t=e.split(`/`);return t.length<2?`ok`:`${t[0]}/${t[1]}`}function fc(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 pc(e,t,n){if(typeof performance>`u`||!performance.measure)return;let r=dc(e),i=fc(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 mc(e,t){}function hc(e,t,n){pc(e,{...t,durationMs:n},{duration:n})}var $=Object.assign(pc,{count:mc,histogram:hc});function gc(e){let t=(0,Z.c)(3),{name:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,X.jsx)(Q.Profiler,{id:n,onRender:_c,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var _c=(e,t,n,r,i,a)=>{$(`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:vc,getOwnPropertySymbols:yc}=Object,{hasOwnProperty:bc}=Object.prototype;function xc(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function Sc(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 Cc(e){return e?.[Symbol.toStringTag]}function wc(e){return vc(e).concat(yc(e))}var Tc=Object.hasOwn||((e,t)=>bc.call(e,t));function Ec(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var Dc=`__v`,Oc=`__o`,kc=`_owner`,{getOwnPropertyDescriptor:Ac,keys:jc}=Object;function Mc(e,t){return e.byteLength===t.byteLength&&Gc(new Uint8Array(e),new Uint8Array(t))}function Nc(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 Pc(e,t){return e.byteLength===t.byteLength&&Gc(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function Fc(e,t){return Ec(e.getTime(),t.getTime())}function Ic(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function Lc(e,t){return e===t}function Rc(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 zc=Ec;function Bc(e,t,n){let r=jc(e),i=r.length;if(jc(t).length!==i)return!1;for(;i-- >0;)if(!qc(e,t,n,r[i]))return!1;return!0}function Vc(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],!qc(e,t,n,a)||(o=Ac(e,a),s=Ac(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function Hc(e,t){return Ec(e.valueOf(),t.valueOf())}function Uc(e,t){return e.source===t.source&&e.flags===t.flags}function Wc(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 Gc(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 Kc(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 qc(e,t,n,r){return(r===kc||r===Oc||r===Dc)&&(e.$$typeof||t.$$typeof)?!0:Tc(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var Jc=`[object ArrayBuffer]`,Yc=`[object Arguments]`,Xc=`[object Boolean]`,Zc=`[object DataView]`,Qc=`[object Date]`,$c=`[object Error]`,el=`[object Map]`,tl=`[object Number]`,nl=`[object Object]`,rl=`[object RegExp]`,il=`[object Set]`,al=`[object String]`,ol={"[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},sl=`[object URL]`,cl=Object.prototype.toString;function ll({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=cl.call(h);if(b===Qc)return r(h,g,_);if(b===rl)return u(h,g,_);if(b===el)return o(h,g,_);if(b===il)return d(h,g,_);if(b===nl)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===sl)return p(h,g,_);if(b===$c)return i(h,g,_);if(b===Yc)return c(h,g,_);if(ol[b])return f(h,g,_);if(b===Jc)return e(h,g,_);if(b===Zc)return n(h,g,_);if(b===Xc||b===tl||b===al)return l(h,g,_);if(m){let e=m[b];if(!e){let t=Cc(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function ul({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:Mc,areArraysEqual:n?Vc:Nc,areDataViewsEqual:Pc,areDatesEqual:Fc,areErrorsEqual:Ic,areFunctionsEqual:Lc,areMapsEqual:n?xc(Rc,Vc):Rc,areNumbersEqual:zc,areObjectsEqual:n?Vc:Bc,arePrimitiveWrappersEqual:Hc,areRegExpsEqual:Uc,areSetsEqual:n?xc(Wc,Vc):Wc,areTypedArraysEqual:n?xc(Gc,Vc):Gc,areUrlsEqual:Kc,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=Sc(r.areArraysEqual),t=Sc(r.areMapsEqual),n=Sc(r.areObjectsEqual),i=Sc(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function dl(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function fl({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 pl=ml();ml({strict:!0}),ml({circular:!0}),ml({circular:!0,strict:!0}),ml({createInternalComparator:()=>Ec}),ml({strict:!0,createInternalComparator:()=>Ec}),ml({circular:!0,createInternalComparator:()=>Ec}),ml({circular:!0,createInternalComparator:()=>Ec,strict:!0});function ml(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=ll(ul(e));return fl({circular:t,comparator:a,createState:r,equals:n?n(a):dl(a),strict:i})}var hl=t((e=>{var t=r(),n=Fa();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}})),gl=t(((e,t)=>{t.exports=hl()}))(),_l=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},vl=({contentComponent:e})=>{let t=(0,ec.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,X.jsx)(X.Fragment,{children:Object.values(t)})};function yl(){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]:Ma.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 bl=class extends Q.Component{constructor(e){super(e),this.editorContentRef=Q.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=yl(),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:_l(t,this.editorContentRef),...n}),e?.contentComponent&&(0,X.jsx)(vl,{contentComponent:e.contentComponent})]})}},xl=(0,Q.forwardRef)((e,t)=>{let n=Q.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return Q.createElement(bl,{key:n,innerRef:t,...e})}),Sl=Q.memo(xl),Cl=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,wl=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 Tl(e){let[t]=(0,Q.useState)(()=>new wl(e.editor)),n=(0,gl.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??pl);return Cl(()=>t.watch(e.editor),[e.editor,t]),(0,Q.useDebugValue)(n),n}typeof window>`u`||typeof window<`u`&&window.next;var El=(0,Q.createContext)({editor:null});El.Consumer;var Dl=()=>(0,Q.useContext)(El),Ol=(0,Q.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),kl=()=>(0,Q.useContext)(Ol);function Al({as:e=`div`,...t}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=kl();return(0,X.jsx)(e,{...t,ref:n,"data-node-view-content":``,style:{whiteSpace:`pre-wrap`,...t.style},children:r})}var jl=Q.forwardRef((e,t)=>{let{onDragStart:n}=kl();return(0,X.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})});function Ml(e){return!!(typeof e==`function`&&e.prototype&&e.prototype.isReactComponent)}function Nl(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.forward_ref)`||e.$$typeof.description===`react.forward_ref`))}function Pl(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.memo)`||e.$$typeof.description===`react.memo`))}function Fl(e){if(Ml(e)||Nl(e))return!0;if(Pl(e)){let t=e.type;if(t)return Ml(t)||Nl(t)}return!1}function Il(){try{if(Q.version)return parseInt(Q.version.split(`.`)[0],10)>=19}catch{}return!1}var Ll=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,Ma.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=Il(),a=Fl(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])})}};Q.createContext({markViewContentRef:()=>{}});var Rl=class extends y{constructor(e,t,n){if(super(e,t,n),this.selectionRafId=null,this.positionCheckCallback=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?`span`:`div`),this.contentDOMElement.dataset.nodeViewContentReact=``,this.contentDOMElement.dataset.nodeViewWrapper=``,this.contentDOMElement.style.whiteSpace=`inherit`;let e=this.dom.querySelector(`[data-node-view-content]`);if(!e)return;e.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,i){return r===`storage`?e.storage[t.name]??{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:(0,Q.createRef)()};if(!this.component.displayName){let e=e=>e.charAt(0).toUpperCase()+e.substring(1);this.component.displayName=e(this.extension.name)}let t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&(e.hasAttribute(`data-node-view-wrapper`)&&e.removeAttribute(`data-node-view-wrapper`),e.appendChild(this.contentDOMElement))}},n=this.component,r=(0,Q.memo)(e=>(0,X.jsx)(Ol.Provider,{value:t,children:(0,Q.createElement)(n,e)}));r.displayName=`ReactNodeView`;let i=this.node.isInline?`span`:`div`;this.options.as&&(i=this.options.as);let{className:a=``}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Ll(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())},f(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&&=(g(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=u(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function zl(e,t){return n=>n.editor.contentComponent?new Rl(e,n,t):{}}var Bl=(0,Q.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});Bl.displayName=`TiptapContext`;var Vl=()=>(0,Q.useContext)(Bl);function Hl({editor:e,instance:t,children:n}){let r=e??t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,Q.useMemo)(()=>({editor:r}),[r]),a=(0,Q.useMemo)(()=>({editor:r}),[r]);return(0,X.jsx)(El.Provider,{value:a,children:(0,X.jsx)(Bl.Provider,{value:i,children:n})})}Hl.displayName=`Tiptap`;function Ul({...e}){let{editor:t}=Vl();return(0,X.jsx)(Sl,{editor:t,...e})}Ul.displayName=`Tiptap.Content`,Object.assign(Hl,{Content:Ul});var Wl=()=>new Map,Gl=e=>{let t=Wl();return e.forEach((e,n)=>{t.set(n,e)}),t},Kl=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},ql=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Jl=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},Yl=()=>new Set,Xl=e=>e[e.length-1],Zl=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},Ql=Array.from,$l=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},eu=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},tu=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},nu=Array.isArray,ru=class{constructor(){this._observers=Wl()}on(e,t){return Kl(this._observers,e,Yl).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 Ql((this._observers.get(e)||Wl()).values()).forEach(e=>e(...t))}destroy(){this._observers=Wl()}},iu=class{constructor(){this._observers=Wl()}on(e,t){Kl(this._observers,e,Yl).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 Ql((this._observers.get(e)||Wl()).values()).forEach(e=>e(...t))}destroy(){this._observers=Wl()}},au=Math.floor,ou=Math.abs,su=(e,t)=>e<t?e:t,cu=(e,t)=>e>t?e:t;Number.isNaN;var lu=e=>e===0?1/e<0:e<0,uu=1<<17,du=1<<18,fu=1<<19,pu=1<<20,mu=1<<21,hu=1<<22,gu=1<<23,_u=1<<24,vu=1<<25,yu=1<<26,bu=1<<27,xu=1<<28,Su=1<<29;uu-1,du-1,fu-1,pu-1,mu-1,hu-1,gu-1,_u-1,vu-1,yu-1,bu-1,xu-1,Su-1;var Cu=2**53-1,wu=-(2**53-1),Tu=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&au(e)===e);Number.isNaN,Number.parseInt;var Eu=String.fromCharCode;String.fromCodePoint,Eu(65535);var Du=e=>e.toLowerCase(),Ou=/^\s*/g,ku=e=>e.replace(Ou,``),Au=/([A-Z])/g,ju=(e,t)=>ku(e.replace(Au,e=>`${t}${Du(e)}`)),Mu=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},Nu=typeof TextEncoder<`u`?new TextEncoder:null,Pu=Nu?e=>Nu.encode(e):Mu,Fu=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Fu&&Fu.decode(new Uint8Array).length===1&&(Fu=null);var Iu=(e,t)=>tu(t,()=>e).join(``),Lu=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Ru=()=>new Lu,zu=e=>{let t=Ru();return e(t),Vu(t)},Bu=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},Vu=e=>{let t=new Uint8Array(Bu(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},Hu=(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(cu(n,t)*2),e.cpos=0)},Uu=(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},Wu=Uu,Gu=(e,t)=>{for(;t>127;)Uu(e,128|127&t),t=au(t/128);Uu(e,127&t)},Ku=(e,t)=>{let n=lu(t);for(n&&(t=-t),Uu(e,(t>63?128:0)|(n?64:0)|63&t),t=au(t/64);t>0;)Uu(e,(t>127?128:0)|127&t),t=au(t/128)},qu=new Uint8Array(3e4),Ju=qu.length/3,Yu=Nu&&Nu.encodeInto?(e,t)=>{if(t.length<Ju){let n=Nu.encodeInto(t,qu).written||0;Gu(e,n);for(let t=0;t<n;t++)Uu(e,qu[t])}else Zu(e,Pu(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Gu(e,r);for(let t=0;t<r;t++)Uu(e,n.codePointAt(t))},Xu=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=su(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(cu(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Zu=(e,t)=>{Gu(e,t.byteLength),Xu(e,t)},Qu=(e,t)=>{Hu(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},$u=(e,t)=>Qu(e,4).setFloat32(0,t,!1),ed=(e,t)=>Qu(e,8).setFloat64(0,t,!1),td=(e,t)=>Qu(e,8).setBigInt64(0,t,!1),nd=new DataView(new ArrayBuffer(4)),rd=e=>(nd.setFloat32(0,e),nd.getFloat32(0)===e),id=(e,t)=>{switch(typeof t){case`string`:Uu(e,119),Yu(e,t);break;case`number`:Tu(t)&&ou(t)<=2147483647?(Uu(e,125),Ku(e,t)):rd(t)?(Uu(e,124),$u(e,t)):(Uu(e,123),ed(e,t));break;case`bigint`:Uu(e,122),td(e,t);break;case`object`:if(t===null)Uu(e,126);else if(nu(t)){Uu(e,117),Gu(e,t.length);for(let n=0;n<t.length;n++)id(e,t[n])}else if(t instanceof Uint8Array)Uu(e,116),Zu(e,t);else{Uu(e,118);let n=Object.keys(t);Gu(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];Yu(e,i),id(e,t[i])}}break;case`boolean`:Uu(e,t?120:121);break;default:Uu(e,127)}},ad=class extends Lu{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Gu(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},od=e=>{e.count>0&&(Ku(e.encoder,e.count===1?e.s:-e.s),e.count>1&&Gu(e.encoder,e.count-2))},sd=class{constructor(){this.encoder=new Lu,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),Vu(this.encoder)}},cd=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);Ku(e.encoder,t),e.count>1&&Gu(e.encoder,e.count-2)}},ld=class{constructor(){this.encoder=new Lu,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(cd(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return cd(this),Vu(this.encoder)}},ud=class{constructor(){this.sarr=[],this.s=``,this.lensE=new sd}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 Lu;return this.sarr.push(this.s),this.s=``,Yu(e,this.sarr.join(``)),Xu(e,this.lensE.toUint8Array()),Vu(e)}},dd=e=>Error(e),fd=()=>{throw dd(`Method unimplemented`)},pd=()=>{throw dd(`Unexpected case`)},md=dd(`Unexpected end of array`),hd=dd(`Integer out of Range`),gd=class{constructor(e){this.arr=e,this.pos=0}},_d=e=>new gd(e),vd=e=>e.pos!==e.arr.length,yd=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},bd=e=>yd(e,Sd(e)),xd=e=>e.arr[e.pos++],Sd=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>Cu)throw hd}throw md},Cd=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>Cu)throw hd}throw md},wd=Fu?e=>Fu.decode(bd(e)):e=>{let t=Sd(e);if(t===0)return``;{let n=String.fromCodePoint(xd(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(xd(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))}},Td=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Ed=[e=>void 0,e=>null,Cd,e=>Td(e,4).getFloat32(0,!1),e=>Td(e,8).getFloat64(0,!1),e=>Td(e,8).getBigInt64(0,!1),e=>!1,e=>!0,wd,e=>{let t=Sd(e),n={};for(let r=0;r<t;r++){let t=wd(e);n[t]=Dd(e)}return n},e=>{let t=Sd(e),n=[];for(let r=0;r<t;r++)n.push(Dd(e));return n},bd],Dd=e=>Ed[127-xd(e)](e),Od=class extends gd{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),vd(this)?this.count=Sd(this)+1:this.count=-1),this.count--,this.s}},kd=class extends gd{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Cd(this);let e=lu(this.s);this.count=1,e&&(this.s=-this.s,this.count=Sd(this)+2)}return this.count--,this.s}},Ad=class extends gd{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Cd(this),t=e&1;this.diff=au(e/2),this.count=1,t&&(this.count=Sd(this)+2)}return this.s+=this.diff,this.count--,this.s}},jd=class{constructor(e){this.decoder=new kd(e),this.str=wd(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 Md=crypto.getRandomValues.bind(crypto),Nd=Math.random,Pd=()=>Md(new Uint32Array(1))[0],Fd=e=>e[au(Nd()*e.length)],Id=`10000000-1000-4000-8000-100000000000`,Ld=()=>Id.replace(/[018]/g,e=>(e^Pd()&15>>e/4).toString(16)),Rd=Date.now,zd=e=>new Promise(e);Promise.all.bind(Promise);var Bd=e=>e===void 0?null:e,Vd=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&&(Vd=localStorage)}catch{}var Hd=Vd,Ud=Symbol(`Equality`),Wd=(e,t)=>e===t||!!e?.[Ud]?.(t)||!1,Gd=e=>typeof e==`object`,Kd=Object.assign,qd=Object.keys,Jd=(e,t)=>{for(let n in e)t(e[n],n)},Yd=e=>qd(e).length,Xd=e=>{for(let t in e)return!1;return!0},Zd=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Qd=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),$d=(e,t)=>e===t||Yd(e)===Yd(t)&&Zd(e,(e,n)=>(e!==void 0||Qd(t,n))&&Wd(t[n],e)),ef=Object.freeze,tf=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&tf(e[t])}return ef(e)},nf=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&nf(e,t,n+1)}},rf=e=>e,af=(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[Ud]!=null)return e[Ud](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)||!af(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Yd(e)!==Yd(t))return!1;for(let n in e)if(!Qd(e,n)||!af(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(!af(e[n],t[n]))return!1;break;default:return!1}return!0},of=(e,t)=>t.includes(e),sf=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,cf=typeof window<`u`&&typeof document<`u`&&!sf;typeof navigator<`u`&&/Mac/.test(navigator.platform);var lf,uf=[],df=()=>{if(lf===void 0)if(sf){lf=Wl();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&lf.set(t,``),t=r):t===null?uf.push(r):(lf.set(t,r),t=null)}t!==null&&lf.set(t,``)}else typeof location==`object`?(lf=Wl(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);lf.set(`--${ju(t,`-`)}`,n),lf.set(`-${ju(t,`-`)}`,n)}})):lf=Wl();return lf},ff=e=>df().has(e),pf=e=>Bd(sf?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Hd.getItem(e)),mf=e=>ff(`--`+e)||pf(e)!==null,hf=mf(`production`),gf=sf&&of({}.FORCE_COLOR,[`true`,`1`,`2`])||!ff(`--no-colors`)&&!mf(`no-color`)&&(!sf||process.stdout.isTTY)&&(!sf||ff(`--color`)||pf(`COLORTERM`)!==null||(pf(`TERM`)||``).includes(`color`)),_f=e=>new Uint8Array(e),vf=cf?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Eu(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),yf=e=>{let t=_f(e.byteLength);return t.set(e),t},bf=e=>zu(t=>id(t,e)),xf=class{constructor(e,t){this.left=e,this.right=t}},Sf=(e,t)=>new xf(e,t),Cf=(e,t)=>e.forEach(e=>t(e.left,e.right)),wf=e=>e.next()>=.5,Tf=(e,t,n)=>au(e.next()*(n+1-t)+t),Ef=(e,t,n)=>au(e.next()*(n+1-t)+t),Df=(e,t,n)=>Ef(e,t,n),Of=e=>Eu(Df(e,97,122)),kf=(e,t=0,n=20)=>{let r=Df(e,t,n),i=``;for(let t=0;t<r;t++)i+=Of(e);return i},Af=(e,t)=>t[Df(e,0,t.length-1)],jf=Symbol(`0schema`),Mf=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(Iu(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
3
3
|
`)}},Nf=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Ud]?Wd(e,t):nu(e)?$l(e,e=>eu(t,t=>Nf(e,t))):Gd(e)?Zd(e,(e,n)=>Nf(e,t[n])):!1,Pf=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Nf(t,n)}equals(e){return this.constructor===e.constructor&&af(this.shape,e.shape)}[jf](){return!0}[Ud](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){fd()}get nullable(){return pp(this,Op)}get optional(){return new Gf(this)}cast(e){return Mp(e,this),e}expect(e){return Mp(e,this),e}},Ff=class extends Pf{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}},If=(e,t=null)=>new Ff(e,t);If(Ff);var Lf=class extends Pf{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}},Rf=e=>new Lf(e);If(Lf);var zf=class extends Pf{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}},Bf=(...e)=>new zf(e),Vf=If(zf),Hf=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Uf=e=>{if(Cp.check(e))return[Hf(e)];if(Vf.check(e))return e.shape.map(e=>e+``);if(Sp.check(e))return[`[+-]?\\d+.?\\d*`];if(wp.check(e))return[`.*`];if(mp.check(e))return e.shape.map(Uf).flat(1);pd()};If(class extends Pf{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Uf).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 Wf=Symbol(`optional`),Gf=class extends Pf{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[Wf](){return!0}},Kf=If(Gf),qf=class extends Pf{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new qf,If(qf);var Jf=class e extends Pf{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):Zd(this.shape,(n,r)=>{let i=this._isPartial&&!Qd(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Yf=e=>new Jf(e),Xf=If(Jf),Zf=Rf(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Qf=class extends Pf{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Zd(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)})}},$f=(e,t)=>new Qf(e,t),ep=If(Qf),tp=class extends Pf{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Zd(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},np=(...e)=>new tp(e);If(tp);var rp=class extends Pf{constructor(e){super(),this.shape=e.length===1?e[0]:new fp(e)}check(e,t){let n=nu(e)&&$l(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},ip=(...e)=>new rp(e),ap=If(rp),op=Rf(e=>nu(e)),sp=class extends Pf{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}},cp=(e,t=null)=>new sp(e,t);If(sp);var lp=cp(Pf),up=If(class extends Pf{constructor(e){super(),this.len=e.length-1,this.args=np(...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}}),dp=Rf(e=>typeof e==`function`);If(class extends Pf{constructor(e){super(),this.shape=e}check(e,t){let n=$l(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var fp=class extends Pf{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=eu(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},pp=(...e)=>e.findIndex(e=>mp.check(e))>=0?pp(...e.map(e=>jp(e)).map(e=>mp.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new fp(e),mp=If(fp),hp=()=>!0,gp=Rf(hp),_p=If(Lf,e=>e.shape===hp),vp=Rf(e=>typeof e==`bigint`),yp=Rf(e=>e===vp),bp=Rf(e=>typeof e==`symbol`);Rf(e=>e===bp);var xp=Rf(e=>typeof e==`number`),Sp=Rf(e=>e===xp),Cp=Rf(e=>typeof e==`string`),wp=Rf(e=>e===Cp),Tp=Rf(e=>typeof e==`boolean`),Ep=Rf(e=>e===Tp),Dp=Bf(void 0);If(zf,e=>e.shape.length===1&&e.shape[0]===void 0),Bf(void 0);var Op=Bf(null),kp=If(zf,e=>e.shape.length===1&&e.shape[0]===null);If(Uint8Array),If(Ff,e=>e.shape===Uint8Array);var Ap=pp(xp,Cp,Op,Dp,vp,Tp,bp);(()=>{let e=ip(gp),t=$f(Cp,gp),n=pp(xp,Cp,Op,Tp,e,t);return e.shape=n,t.shape.values=n,n})();var jp=e=>{if(lp.check(e))return e;if(Zf.check(e)){let t={};for(let n in e)t[n]=jp(e[n]);return Yf(t)}else if(op.check(e))return pp(...e.map(jp));else if(Ap.check(e))return Bf(e);else if(dp.check(e))return If(e);pd()},Mp=hf?()=>{}:(e,t)=>{let n=new Mf;if(!t.check(e,n))throw dd(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},Np=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:jp(e),h:t}),this}else(e){return this.if(gp,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 dd(`Unhandled pattern`)}}},Pp=(e=>new Np(e))(gp).if(Sp,(e,t)=>Tf(t,wu,Cu)).if(wp,(e,t)=>kf(t)).if(Ep,(e,t)=>wf(t)).if(yp,(e,t)=>BigInt(Tf(t,wu,Cu))).if(mp,(e,t)=>Fp(t,Af(t,e.shape))).if(Xf,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Kf.check(i)){if(wf(t))continue;i=i.shape}n[r]=Pp(i,t)}return n}).if(ap,(e,t)=>{let n=[],r=Ef(t,0,42);for(let i=0;i<r;i++)n.push(Fp(t,e.shape));return n}).if(Vf,(e,t)=>Af(t,e.shape)).if(kp,(e,t)=>null).if(up,(e,t)=>{let n=Fp(t,e.res);return()=>n}).if(_p,(e,t)=>Fp(t,Af(t,[xp,Cp,Op,Dp,vp,Tp,ip(xp),$f(pp(`a`,`b`,`c`),xp)]))).if(ep,(e,t)=>{let n={},r=Tf(t,0,3);for(let i=0;i<r;i++){let r=Fp(t,e.shape.keys);n[r]=Fp(t,e.shape.values)}return n}).done(),Fp=(e,t)=>Pp(jp(t),e),Ip=typeof document<`u`?document:{},Lp=e=>Ip.createElement(e),Rp=()=>Ip.createDocumentFragment();Rf(e=>e.nodeType===Xp);var zp=e=>Ip.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var Bp=(e,t)=>(Cf(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),Vp=e=>{let t=Rp();for(let n=0;n<e.length;n++)Kp(t,e[n]);return t},Hp=(e,t)=>(Kp(e,Vp(t)),e),Up=(e,t=[],n=[])=>Hp(Bp(Lp(e),t),n);Rf(e=>e.nodeType===qp);var Wp=zp;Rf(e=>e.nodeType===Jp);var Gp=e=>ql(e,(e,t)=>`${t}:${e};`).join(``),Kp=(e,t)=>e.appendChild(t),qp=Ip.ELEMENT_NODE,Jp=Ip.TEXT_NODE;Ip.CDATA_SECTION_NODE,Ip.COMMENT_NODE;var Yp=Ip.DOCUMENT_NODE;Ip.DOCUMENT_TYPE_NODE;var Xp=Ip.DOCUMENT_FRAGMENT_NODE;Rf(e=>e.nodeType===Yp);var Zp=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),Qp=(e,t)=>new Zp(setTimeout(t,e)),$p=Symbol,em=$p(),tm=$p(),nm=$p(),rm=$p(),im=$p(),am=$p(),om=$p(),sm=$p(),cm=$p(),lm=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};Rd();var um={[em]:Sf(`font-weight`,`bold`),[tm]:Sf(`font-weight`,`normal`),[nm]:Sf(`color`,`blue`),[im]:Sf(`color`,`green`),[rm]:Sf(`color`,`grey`),[am]:Sf(`color`,`red`),[om]:Sf(`color`,`purple`),[sm]:Sf(`color`,`orange`),[cm]:Sf(`color`,`black`)},dm=gf?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=Wl(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=um[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=Gp(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}:lm,fm=(...e)=>{console.log(...dm(e)),mm.forEach(t=>t.print(e))},pm=(...e)=>{console.warn(...dm(e)),e.unshift(sm),mm.forEach(t=>t.print(e))},mm=Yl(),hm=e=>({[Symbol.iterator](){return this},next:e}),gm=(e,t)=>hm(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),_m=(e,t)=>hm(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),vm=class{constructor(e,t){this.clock=e,this.len=t}},ym=class{constructor(){this.clients=new Map}},bm=(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])zh(e,i,o.clock,o.len,n)}}),xm=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=au((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},Sm=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&xm(n,t.clock)!==null},Cm=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 vm(r.clock,cu(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},wm=e=>{let t=new ym;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++)Zl(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return Cm(t),t},Tm=(e,t,n,r)=>{Kl(e.clients,t,()=>[]).push(new vm(n,r))},Em=()=>new ym,Dm=e=>{let t=Em();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 vm(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Om=(e,t)=>{Gu(e.restEncoder,t.clients.size),Ql(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),Gu(e.restEncoder,t);let r=n.length;Gu(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},km=e=>{let t=new ym,n=Sd(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=Sd(e.restDecoder),r=Sd(e.restDecoder);if(r>0){let i=Kl(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new vm(e.readDsClock(),e.readDsLen()))}}return t},Am=(e,t,n)=>{let r=new ym,i=Sd(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=Sd(e.restDecoder),a=Sd(e.restDecoder),o=n.clients.get(i)||[],s=jh(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&Tm(r,i,s,a-s);let e=Nh(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,nv(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,nv(t,c,a-c.id.clock)),c.delete(t))}else Tm(r,i,n,a-n)}}if(r.clients.size>0){let e=new Bm;return Gu(e.restEncoder,0),Om(e,r),e.toUint8Array()}return null},jm=Pd,Mm=class e extends ru{constructor({guid:e=Ld(),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=jm(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new kh,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=zd(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>zd(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&&qh(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Ql(this.subdocs).map(e=>e.guid))}transact(e,t=null){return qh(this,e,t)}get(e,t=Cg){let n=Kl(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==Cg&&r!==t)if(r===Cg){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,Wg)}getText(e=``){return this.get(e,d_)}getMap(e=``){return this.get(e,qg)}getXmlElement(e=``){return this.get(e,g_)}getXmlFragment(e=``){return this.get(e,m_)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,Ql(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,qh(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()}},Nm=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Sd(this.restDecoder)}readDsLen(){return Sd(this.restDecoder)}},Pm=class extends Nm{readLeftID(){return dh(Sd(this.restDecoder),Sd(this.restDecoder))}readRightID(){return dh(Sd(this.restDecoder),Sd(this.restDecoder))}readClient(){return Sd(this.restDecoder)}readInfo(){return xd(this.restDecoder)}readString(){return wd(this.restDecoder)}readParentInfo(){return Sd(this.restDecoder)===1}readTypeRef(){return Sd(this.restDecoder)}readLen(){return Sd(this.restDecoder)}readAny(){return Dd(this.restDecoder)}readBuf(){return yf(bd(this.restDecoder))}readJSON(){return JSON.parse(wd(this.restDecoder))}readKey(){return wd(this.restDecoder)}},Fm=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Sd(this.restDecoder),this.dsCurrVal}readDsLen(){let e=Sd(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Im=class extends Fm{constructor(e){super(e),this.keys=[],Sd(e),this.keyClockDecoder=new Ad(bd(e)),this.clientDecoder=new kd(bd(e)),this.leftClockDecoder=new Ad(bd(e)),this.rightClockDecoder=new Ad(bd(e)),this.infoDecoder=new Od(bd(e),xd),this.stringDecoder=new jd(bd(e)),this.parentInfoDecoder=new Od(bd(e),xd),this.typeRefDecoder=new kd(bd(e)),this.lenDecoder=new kd(bd(e))}readLeftID(){return new lh(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new lh(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 Dd(this.restDecoder)}readBuf(){return bd(this.restDecoder)}readJSON(){return Dd(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}}},Lm=class{constructor(){this.restEncoder=Ru()}toUint8Array(){return Vu(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Gu(this.restEncoder,e)}writeDsLen(e){Gu(this.restEncoder,e)}},Rm=class extends Lm{writeLeftID(e){Gu(this.restEncoder,e.client),Gu(this.restEncoder,e.clock)}writeRightID(e){Gu(this.restEncoder,e.client),Gu(this.restEncoder,e.clock)}writeClient(e){Gu(this.restEncoder,e)}writeInfo(e){Wu(this.restEncoder,e)}writeString(e){Yu(this.restEncoder,e)}writeParentInfo(e){Gu(this.restEncoder,+!!e)}writeTypeRef(e){Gu(this.restEncoder,e)}writeLen(e){Gu(this.restEncoder,e)}writeAny(e){id(this.restEncoder,e)}writeBuf(e){Zu(this.restEncoder,e)}writeJSON(e){Yu(this.restEncoder,JSON.stringify(e))}writeKey(e){Yu(this.restEncoder,e)}},zm=class{constructor(){this.restEncoder=Ru(),this.dsCurrVal=0}toUint8Array(){return Vu(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,Gu(this.restEncoder,t)}writeDsLen(e){e===0&&pd(),Gu(this.restEncoder,e-1),this.dsCurrVal+=e}},Bm=class extends zm{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new ld,this.clientEncoder=new sd,this.leftClockEncoder=new ld,this.rightClockEncoder=new ld,this.infoEncoder=new ad(Wu),this.stringEncoder=new ud,this.parentInfoEncoder=new ad(Wu),this.typeRefEncoder=new sd,this.lenEncoder=new sd}toUint8Array(){let e=Ru();return Gu(e,0),Zu(e,this.keyClockEncoder.toUint8Array()),Zu(e,this.clientEncoder.toUint8Array()),Zu(e,this.leftClockEncoder.toUint8Array()),Zu(e,this.rightClockEncoder.toUint8Array()),Zu(e,Vu(this.infoEncoder)),Zu(e,this.stringEncoder.toUint8Array()),Zu(e,Vu(this.parentInfoEncoder)),Zu(e,this.typeRefEncoder.toUint8Array()),Zu(e,this.lenEncoder.toUint8Array()),Xu(e,Vu(this.restEncoder)),Vu(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){id(this.restEncoder,e)}writeBuf(e){Zu(this.restEncoder,e)}writeJSON(e){id(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)}},Vm=(e,t,n,r)=>{r=cu(r,t[0].id.clock);let i=Nh(t,r);Gu(e.restEncoder,t.length-i),e.writeClient(n),Gu(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)},Hm=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{jh(t,n)>e&&r.set(n,e)}),Ah(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),Gu(e.restEncoder,r.size),Ql(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Vm(e,t.clients.get(n),n,r)})},Um=(e,t)=>{let n=Wl(),r=Sd(e.restDecoder);for(let i=0;i<r;i++){let r=Sd(e.restDecoder),i=Array(r),a=e.readClient(),o=Sd(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 T_(dh(a,o),t),o+=t;break}case 10:{let t=Sd(e.restDecoder);i[n]=new lv(dh(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new av(dh(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},Wm=(e,t,n)=>{let r=[],i=Ql(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 kh,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!==lv){let i=Kl(d,u.id.client,()=>jh(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,jh(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 Bm;return Hm(e,s,new Map),Gu(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},Gm=(e,t)=>Hm(e,t.doc.store,t.beforeState),Km=(e,t,n,r=new Im(e))=>qh(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Wm(e,i,Um(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<jh(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=rg([o.update,a.update])}}else i.pendingStructs=a;let s=Am(r,e,i);if(i.pendingDs){let t=new Im(_d(i.pendingDs));Sd(t.restDecoder);let n=Am(t,e,i);s&&n?i.pendingDs=rg([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,qm(e.doc,t)}},n,!1),qm=(e,t,n,r=Im)=>{let i=_d(t);Km(i,e,n,new r(i))},Jm=(e,t,n)=>qm(e,t,n,Pm),Ym=(e,t,n=new Map)=>{Hm(e,t.store,n),Om(e,Dm(t.store))},Xm=(e,t=new Uint8Array([0]),n=new Bm)=>{Ym(n,e,$m(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(ig(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Rm)return tg(r.map((e,t)=>t===0?e:lg(e)));if(n.constructor===Bm)return rg(r)}return r[0]},Zm=(e,t)=>Xm(e,t,new Rm),Qm=e=>{let t=new Map,n=Sd(e.restDecoder);for(let r=0;r<n;r++){let n=Sd(e.restDecoder),r=Sd(e.restDecoder);t.set(n,r)}return t},$m=e=>Qm(new Nm(_d(e))),eh=(e,t)=>(Gu(e.restEncoder,t.size),Ql(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{Gu(e.restEncoder,t),Gu(e.restEncoder,n)}),e),th=(e,t)=>eh(e,Ah(t.store)),nh=(e,t=new zm)=>(e instanceof Map?eh(t,e):th(t,e),t.toUint8Array()),rh=e=>nh(e,new Lm),ih=class{constructor(){this.l=[]}},ah=()=>new ih,oh=(e,t)=>e.l.push(t),sh=(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.`)},ch=(e,t,n)=>nf(e.l,[t,n]),lh=class{constructor(e,t){this.client=e,this.clock=t}},uh=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,dh=(e,t)=>new lh(e,t),fh=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw pd()},ph=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},mh=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},hh=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},gh=e=>new mh(e.type==null?null:dh(e.type.client,e.type.clock),e.tname??null,e.item==null?null:dh(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),_h=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},vh=(e,t,n=0)=>new _h(e,t,n),yh=(e,t,n)=>{let r=null,i=null;return e._item===null?i=fh(e):r=dh(e._item.id.client,e._item.id.clock),new mh(r,i,t,n)},bh=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return yh(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return yh(e,dh(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return yh(e,r.lastId,n);r=r.right}return yh(e,null,n)},xh=(e,t)=>{let n=Ph(e,t);return{item:n,diff:t.clock-n.id.clock}},Sh=(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(jh(r,i.client)<=i.clock)return null;let e=n?ev(r,i):xh(r,i),t=e.item;if(!(t instanceof av))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(jh(r,a.client)<=a.clock)return null;let{item:e}=n?ev(r,a):{item:Ph(r,a)};if(e instanceof av&&e.content instanceof Q_)c=e.content.type;else return null}else throw pd();l=s>=0?c._length:0}return vh(c,l,e.assoc)},Ch=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&uh(e.item,t.item)&&uh(e.type,t.type)&&e.assoc===t.assoc,wh=class{constructor(e,t){this.ds=e,this.sv=t}},Th=(e,t)=>new wh(e,t);Th(Em(),new Map);var Eh=e=>Th(Dm(e.store),Ah(e.store)),Dh=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Sm(t.ds,e.id),Oh=(e,t)=>{let n=Kl(e.meta,Oh,Yl),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<jh(r,n)&&Ih(e,dh(n,t))}),bm(e,t.ds,e=>{}),n.add(t))},kh=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Ah=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},jh=(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},Mh=(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 pd()}n.push(t)},Nh=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=au(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=au((n+r)/2)}throw pd()},Ph=(e,t)=>{let n=e.clients.get(t.client);return n[Nh(n,t.clock)]},Fh=(e,t,n)=>{let r=Nh(t,n),i=t[r];return i.id.clock<n&&i instanceof av?(t.splice(r+1,0,nv(e,i,n-i.id.clock)),r+1):r},Ih=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Fh(e,n,t.clock)]},Lh=(e,t,n)=>{let r=t.clients.get(n.client),i=Nh(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==T_&&r.splice(i+1,0,nv(e,a,n.clock-a.id.clock+1)),a},Rh=(e,t,n)=>{let r=e.clients.get(t.id.client);r[Nh(r,t.id.clock)]=n},zh=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Fh(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&Fh(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Bh=class{constructor(e,t,n){this.doc=e,this.deleteSet=new ym,this.beforeState=Ah(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}},Vh=(e,t)=>t.deleteSet.clients.size===0&&!Jl(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(Cm(t.deleteSet),Gm(e,t),Om(e,t.deleteSet),!0),Hh=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&Kl(e.changed,t,Yl).add(n)},Uh=(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 av&&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},Wh=(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=Nh(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 av&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Gh=(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=su(r.length-1,1+Nh(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+Uh(r,e)}})},Kh=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{Cm(a),n.afterState=Ah(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(()=>{ch(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&c_(n)})}),nf(e,[])}finally{r.gc&&Wh(a,i,r.gcFilter),Gh(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=cu(Nh(e,r),1);for(let t=e.length-1;t>=n;)t-=1+Uh(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=Nh(r,n);a+1<r.length&&Uh(r,a+1)>1||a>0&&Uh(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(fm(sm,em,`[yjs] `,tm,am,`Changed the client-id because another client seems to be using it.`),r.clientID=jm()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Rm;Vh(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Bm;Vh(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])):Kh(e,t+1)}}},qh=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Bh(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&&Kh(i,0)}}return o},Jh=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Yh=(e,t,n)=>{bm(e,n.deletions,n=>{n instanceof av&&t.scope.some(t=>t===e.doc||ph(t,n))&&tv(n,!1)})},Xh=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;qh(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;bm(n,o.insertions,e=>{if(e instanceof av){if(e.redone!==null){let{item:t,diff:i}=ev(r,e.id);i>0&&(t=Ih(n,dh(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||ph(t,e))&&c.push(e)}}),bm(n,o.deletions,e=>{e instanceof av&&a.some(t=>t===n.doc||ph(t,e))&&!Sm(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=iv(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},Zh=class extends ru{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=nu(e)?e[0].doc:e instanceof Mm?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 ym;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&Tm(i,n,r,a)});let a=Rd(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=wm([t.deletions,e.deleteSet]),t.insertions=wm([t.insertions,i])}else r.push(new Jh(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),bm(e,e.deleteSet,t=>{t instanceof av&&this.scope.some(n=>n===e.doc||ph(n,t))&&tv(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=nu(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof Cg?e.doc!==this.doc:e!==this.doc)&&pm(`[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=>Yh(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Yh(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=Xh(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Xh(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*Qh(e){let t=Sd(e.restDecoder);for(let n=0;n<t;n++){let t=Sd(e.restDecoder),n=e.readClient(),r=Sd(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=Sd(e.restDecoder);yield new lv(dh(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new av(dh(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 T_(dh(n,r),t),r+=t}}}}var $h=class{constructor(e,t){this.gen=Qh(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===lv);return this.curr}},eg=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},tg=e=>rg(e,Pm,Rm),ng=(e,t)=>{if(e.constructor===T_){let{client:n,clock:r}=e.id;return new T_(dh(n,r+t),e.length-t)}else if(e.constructor===lv){let{client:n,clock:r}=e.id;return new lv(dh(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new av(dh(r,i+t),null,dh(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},rg=(e,t=Im,n=Bm)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(_d(e))),i=r.map(e=>new $h(e,!0)),a=null,o=new n,s=new eg(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===lv?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===lv)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 lv(dh(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===lv?a.struct.length-=t:n=ng(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!==lv;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),sg(s),Om(o,wm(r.map(e=>km(e)))),o.toUint8Array()},ig=(e,t,n=Im,r=Bm)=>{let i=$m(t),a=new r,o=new eg(a),s=new n(_d(e)),c=new $h(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===lv){c.next();continue}if(e.id.clock+e.length>n)for(og(o,e,cu(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 sg(o),Om(a,km(s)),a.toUint8Array()},ag=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:Vu(e.encoder.restEncoder)}),e.encoder.restEncoder=Ru(),e.written=0)},og=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&ag(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),Gu(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},sg=e=>{ag(e);let t=e.encoder.restEncoder;Gu(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];Gu(t,r.written),Xu(t,r.restEncoder)}},cg=(e,t,n,r)=>{let i=new n(_d(e)),a=new $h(i,!1),o=new r,s=new eg(o);for(let e=a.curr;e!==null;e=a.next())og(s,t(e),0);return sg(s),Om(o,km(i)),o.toUint8Array()},lg=e=>cg(e,rf,Im,Rm),ug=`You must not compute changes after the event-handler fired.`,dg=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||=fg(this.currentTarget,this.target)}deletes(e){return Sm(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw dd(ug);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=Xl(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=Xl(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=Xl(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 dd(ug);let t=this.target,n=Yl(),r=Yl(),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}},fg=(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},pg=()=>{pm(`Invalid access: Add Yjs type to a document before reading data.`)},mg=80,hg=0,gg=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=hg++}},_g=e=>{e.timestamp=hg++},vg=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=hg++},yg=(e,t,n)=>{if(e.length>=mg){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return vg(r,t,n),r}else{let r=new gg(t,n);return e.push(r),r}},bg=(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,_g(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/mg?(vg(n,r,i),n):yg(e._searchMarker,r,i)},xg=(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=cu(t,i.index+n))}},Sg=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;Kl(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;ch(r._eH,n,t)},Cg=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=ah(),this._dEH=ah(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw fd()}clone(){throw fd()}_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){sh(this._eH,e)}unobserveDeep(e){sh(this._dEH,e)}toJSON(){}},wg=(e,t,n)=>{e.doc??pg(),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},Tg=e=>{e.doc??pg();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},Eg=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Dh(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},Dg=(e,t)=>{let n=0,r=e._start;for(e.doc??pg();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}},Og=(e,t)=>{let n=[];return Dg(e,(r,i)=>{n.push(t(r,i,e))}),n},kg=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}}}},Ag=(e,t)=>{e.doc??pg();let n=bg(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}},jg=(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 av(dh(o,jh(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new B_(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 av(dh(o,jh(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new E_(new Uint8Array(n))),i.integrate(e,0);break;case Mm:i=new av(dh(o,jh(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new j_(n)),i.integrate(e,0);break;default:if(n instanceof Cg)i=new av(dh(o,jh(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Q_(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},Mg=()=>dd(`Length exceeded!`),Ng=(e,t,n,r)=>{if(n>t._length)throw Mg();if(n===0)return t._searchMarker&&xg(t._searchMarker,n,r.length),jg(e,t,null,r);let i=n,a=bg(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&&Ih(e,dh(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&xg(t._searchMarker,i,r.length),jg(e,t,o,r)},Pg=(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 jg(e,t,r,n)},Fg=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=bg(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&&Ih(e,dh(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&Ih(e,dh(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw Mg();t._searchMarker&&xg(t._searchMarker,i,-a+r)},Ig=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Lg=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new B_([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new B_([r]);break;case Uint8Array:s=new E_(r);break;case Mm:s=new j_(r);break;default:if(r instanceof Cg)s=new Q_(r);else throw Error(`Unexpected content type`)}new av(dh(o,jh(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},Rg=(e,t)=>{e.doc??pg();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},zg=e=>{let t={};return e.doc??pg(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},Bg=(e,t)=>{e.doc??pg();let n=e._map.get(t);return n!==void 0&&!n.deleted},Vg=(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&&Dh(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},Hg=e=>(e.doc??pg(),gm(e._map.entries(),e=>!e[1].deleted)),Ug=class extends dg{},Wg=class e extends Cg{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 Cg?e.clone():e)),t}get length(){return this.doc??pg(),this._length}_callObserver(e,t){super._callObserver(e,t),Sg(this,e,new Ug(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):qh(this.doc,n=>{Ng(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):qh(this.doc,t=>{Pg(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):qh(this.doc,n=>{Fg(n,this,e,t)})}get(e){return Ag(this,e)}toArray(){return Tg(this)}slice(e=0,t=this.length){return wg(this,e,t)}toJSON(){return this.map(e=>e instanceof Cg?e.toJSON():e)}map(e){return Og(this,e)}forEach(e){Dg(this,e)}[Symbol.iterator](){return kg(this)}_write(e){e.writeTypeRef(G_)}},Gg=e=>new Wg,Kg=class extends dg{constructor(e,t,n){super(e,t),this.keysChanged=n}},qg=class e extends Cg{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 Cg?e.clone():e)}),t}_callObserver(e,t){Sg(this,e,new Kg(this,e,t))}toJSON(){this.doc??pg();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof Cg?r.toJSON():r}}),e}get size(){return[...Hg(this)].length}keys(){return _m(Hg(this),e=>e[0])}values(){return _m(Hg(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return _m(Hg(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??pg(),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):qh(this.doc,t=>{Ig(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):qh(this.doc,n=>{Lg(n,this,e,t)}),t}get(e){return Rg(this,e)}has(e){return Bg(this,e)}clear(){this.doc===null?this._prelimContent.clear():qh(this.doc,e=>{this.forEach(function(t,n,r){Ig(e,r,n)})})}_write(e){e.writeTypeRef(K_)}},Jg=e=>new qg,Yg=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&$d(e,t),Xg=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&pd(),this.right.content.constructor){case F_:this.right.deleted||e_(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}},Zg=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case F_:t.right.deleted||e_(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&Ih(e,dh(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},Qg=(e,t,n,r)=>{let i=new Map,a=r?bg(t,n):null;return a?Zg(e,new Xg(a.p.left,a.p,a.index,i),n-a.index):Zg(e,new Xg(null,t._start,0,i),n)},$g=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===F_&&Yg(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 av(dh(a,jh(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new F_(o,r));l.integrate(e,0),n.right=l,n.forward()})},e_=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},t_=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===F_&&Yg(t[e.right.content.key]??null,e.right.content.value));)e.forward()},n_=(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(!Yg(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new av(dh(a,jh(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new F_(s,c)),n.right.integrate(e,0),n.forward()}}return o},r_=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;t_(n,i);let s=n_(e,t,n,i),c=r.constructor===String?new H_(r):r instanceof Cg?new Q_(r):new N_(r),{left:l,right:u,index:d}=n;t._searchMarker&&xg(t._searchMarker,n.index,c.getLength()),u=new av(dh(o,jh(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(),$g(e,t,n,s)},i_=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;t_(n,i);let s=n_(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===F_));){if(!n.right.deleted)switch(n.right.content.constructor){case F_:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Yg(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&&Ih(e,dh(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 av(dh(o,jh(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new H_(i)),n.right.integrate(e,0),n.forward()}$g(e,t,n,s)},a_=(e,t,n,r,i)=>{let a=t,o=Wl();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===F_){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 F_:{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&&e_(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===F_){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},s_=e=>{let t=0;return qh(e.doc,n=>{let r=e._start,i=e._start,a=Wl(),o=Gl(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case F_:e_(o,i.content);break;default:t+=a_(n,r,i,a,o),a=Gl(o),r=i;break}i=i.right}}),t},c_=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&&zh(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===F_&&e.constructor!==T_&&t.add(e.parent)})}qh(n,n=>{bm(e,e.deleteSet,e=>{if(e instanceof T_||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===F_?t.add(r):o_(n,e)});for(let e of t)s_(e)})},l_=(e,t,n)=>{let r=n,i=Gl(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Q_:case N_:case H_:n<t.right.length&&Ih(e,dh(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&a_(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&xg(o._searchMarker,t.index,-r+n),t},u_=class extends dg{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=[];qh(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},Xd(o)||(e.attributes=Kd({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Q_:case N_: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 H_: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 F_:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Yg(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Yg(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;Yg(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Yg(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),e_(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}},d_=class e extends Cg{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??pg(),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 u_(this,e,t);Sg(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??pg();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===H_&&(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)):qh(this.doc,n=>{let r=new Xg(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)&&r_(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&l_(n,r,a.delete):i_(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??pg();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(Dh(s,e)||t!==void 0&&Dh(s,t))switch(s.content.constructor){case H_:{let r=i.get(`ychange`);e!==void 0&&!Dh(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&&!Dh(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 Q_:case N_:{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 F_:Dh(s,e)&&(c(),e_(i,s.content));break}s=s.right}c()};return e||t?qh(a,n=>{e&&Oh(n,e),t&&Oh(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)):qh(r,r=>{let i=Qg(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),r_(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):qh(r,r=>{let i=Qg(r,this,e,!n);r_(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)):qh(n,n=>{l_(n,Qg(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)):qh(r,r=>{let i=Qg(r,this,e,!1);i.right!==null&&i_(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):qh(this.doc,t=>{Ig(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):qh(this.doc,n=>{Lg(n,this,e,t)})}getAttribute(e){return Rg(this,e)}getAttributes(){return zg(this)}_write(e){e.writeTypeRef(q_)}},f_=e=>new d_,p_=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??pg()}[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===g_||t.constructor===m_)&&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})}},m_=class e extends Cg{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 Cg?e.clone():e)),t}get length(){return this.doc??pg(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new p_(this,e)}querySelector(e){e=e.toUpperCase();let t=new p_(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),Ql(new p_(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Sg(this,e,new v_(this,t,e))}toString(){return Og(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),Dg(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):qh(this.doc,n=>{Ng(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)qh(this.doc,n=>{let r=e&&e instanceof Cg?e._item:e;jg(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 dd(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):qh(this.doc,n=>{Fg(n,this,e,t)})}toArray(){return Tg(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Ag(this,e)}slice(e=0,t=this.length){return wg(this,e,t)}forEach(e){Dg(this,e)}_write(e){e.writeTypeRef(Y_)}},h_=e=>new m_,g_=class e extends m_{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 Jd(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof Cg?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):qh(this.doc,t=>{Ig(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):qh(this.doc,n=>{Lg(n,this,e,t)})}getAttribute(e){return Rg(this,e)}hasAttribute(e){return Bg(this,e)}getAttributes(e){return e?Vg(this,e):zg(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 Dg(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(J_),e.writeKey(this.nodeName)}},__=e=>new g_(e.readKey()),v_=class extends dg{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)})}},y_=class e extends qg{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(X_),e.writeKey(this.hookName)}},b_=e=>new y_(e.readKey()),x_=class e extends d_{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(Z_)}},S_=e=>new x_,C_=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw fd()}mergeWith(e){return!1}write(e,t,n){throw fd()}integrate(e,t){throw fd()}},w_=0,T_=class extends C_{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),Mh(e.doc.store,this)}write(e,t){e.writeInfo(w_),e.writeLen(this.length-t)}getMissing(e,t){return null}},E_=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 fd()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},D_=e=>new E_(e.readBuf()),O_=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){Tm(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}},k_=e=>new O_(e.readLen()),A_=(e,t)=>new Mm({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),j_=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(A_(this.doc.guid,this.opts))}splice(e){throw fd()}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}},M_=e=>new j_(A_(e.readString(),e.readAny())),N_=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 fd()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},P_=e=>new N_(e.readJSON()),F_=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 fd()}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}},I_=e=>new F_(e.readKey(),e.readJSON()),L_=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}},R_=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 L_(n)},z_=pf(`node_env`)===`development`,B_=class e{constructor(e){this.arr=e,z_&&tf(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}},V_=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new B_(n)},H_=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}},U_=e=>new H_(e.readString()),W_=[Gg,Jg,f_,__,h_,b_,S_],G_=0,K_=1,q_=2,J_=3,Y_=4,X_=5,Z_=6,Q_=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 fd()}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}},$_=e=>new Q_(W_[e.readTypeRef()](e)),ev=(e,t)=>{let n=t,r=0,i;do r>0&&(n=dh(n.client,n.clock+r)),i=Ph(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof av);return{item:i,diff:r}},tv=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},nv=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new av(dh(r,i+n),t,dh(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=dh(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},rv=(e,t)=>eu(e,e=>Sm(e.deletions,t)),iv=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return Ih(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||iv(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=Ih(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:Ih(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:Ih(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||Sm(r,d.right.id)||rv(a.undoStack,d.right.id)||rv(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Ih(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;let m=dh(c,jh(s,c)),h=new av(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,tv(h,!0),h.integrate(e,0),h},av=class e extends C_{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>=jh(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=jh(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===lh&&this.id.client!==this.parent.client&&this.parent.clock>=jh(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Lh(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=Ih(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===T_||this.right&&this.right.constructor===T_)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===lh){let e=Ph(n,this.parent);e.constructor===T_?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Lh(e,e.doc.store,dh(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),uh(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(uh(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Ph(e.doc.store,n.origin)))r.has(Ph(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),Mh(e.doc.store,this),this.content.integrate(e,this),Hh(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new T_(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:dh(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&uh(e.origin,this.lastId)&&this.right===e&&uh(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(),Tm(e.deleteSet,this.id.client,this.id.clock,this.length),Hh(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw pd();this.content.gc(e),t?Rh(e,this,new T_(this.id,this.length)):this.content=new O_(this.length)}write(e,t){let n=t>0?dh(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=fh(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===lh?(e.writeParentInfo(!1),e.writeLeftID(t)):pd();i!==null&&e.writeString(i)}this.content.write(e,t)}},ov=(e,t)=>sv[t&31](e),sv=[()=>{pd()},k_,R_,D_,U_,P_,I_,$_,V_,M_,()=>{pd()}],cv=10,lv=class extends C_{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){pd()}write(e,t){e.writeInfo(cv),Gu(e.restEncoder,this.length-t)}getMissing(e,t){return null}},uv=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},dv=`__ $YJS$ __`;uv[dv]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),uv[dv]=!0;var fv=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},pv=/[\uD800-\uDBFF]/,mv=/[\uDC00-\uDFFF]/,hv=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&pv.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&&mv.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},gv=(e,t)=>e>>>t|e<<32-t,_v=e=>gv(e,2)^gv(e,13)^gv(e,22),vv=e=>gv(e,6)^gv(e,11)^gv(e,25),yv=e=>gv(e,7)^gv(e,18)^e>>>3,bv=e=>gv(e,17)^gv(e,19)^e>>>10,xv=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]),Sv=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Cv=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Sv),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=bv(t[e-2])+t[e-7]+yv(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+vv(o)+(o&s^~o&c)+xv[e]+t[e]>>>0,d=_v(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/Su,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}},wv=e=>new Cv().digest(e),Tv=new N(`y-sync`),Ev=new N(`y-undo`),Dv=new N(`yjs-cursor`),Ov=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},kv=e=>vf(Ov(wv(bf(e)))),Av=()=>({mapping:new Map,isOMark:new Map}),jv=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!Sm(t.ds,e.id),Mv=[{light:`#ecd44433`,dark:`#ecd444`}],Nv=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=Yl();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,Fd(t))}return e.get(n)},Pv=(e,{colors:t=Mv,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new Rv(e,a),c=new pt({props:{editable:e=>{let t=Tv.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:Tv,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(Tv);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)&&Qp(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=Ev.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)},Tv)})}},destroy:()=>{s.destroy()}})});return c},Fv=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new T(e.doc));else if(t.type===`node`){let r=py(n.doc,n.type,t.anchor,n.mapping);e.setSelection(Iv(e,r))}else{let r=py(n.doc,n.type,t.anchor,n.mapping),i=py(n.doc,n.type,t.head,n.mapping);r!==null&&i!==null&&e.setSelection(Ce.between(e.doc.resolve(r),e.doc.resolve(i)))}},Iv=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?I.create(e.doc,t):Ce.near(n)},Lv=(e,t)=>({type:t.selection.jsonID,anchor:dy(t.selection.anchor,e.type,e.mapping),head:dy(t.selection.head,e.type,e.mapping)}),Rv=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=fv(),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=Lv(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()?(cf&&this._domSelectionInView===null&&(Qp(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=Ip.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||=Th(Em(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(Tv,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>Bv(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new it(Pe.from(e),0,0));t.setMeta(Tv,{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=>Bv(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new it(Pe.from(t),0,0));if(e){let t=su(cu(e.anchor,0),n.doc.content.size),r=su(cu(e.head,0),n.doc.content.size);n.setSelection(Ce.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(Tv,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=Eh(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&pd(),r=new Mm({gc:!1}),qm(r,t),t=Eh(r),qm(r,e),e=Eh(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[Nh(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{bm(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:Nv(n.colorMapping,n.colors,r)}},s=Eg(i,new wh(t.ds,e.sv)).map(n=>!n._item.deleted||jv(n._item,e)||jv(n._item,t)?Bv(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 it(Pe.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(Tv,{isChangeOrigin:!0}))},Tv)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=Tv.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);bm(t,t.deleteSet,e=>{if(e.constructor===av){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=>zv(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new it(Pe.from(n),0,0));Fv(r,this.beforeTransactionSelection,this),r=r.setMeta(Tv,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof Zh}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{iy(this.doc,this.type,e,this),this.beforeTransactionSelection=Lv(this,this.prosemirrorView.state)},Tv)}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))}},zv=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof g_)return Bv(e,t,n,r,i,a);throw fd()}return o},Bv=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof g_){let s=zv(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof d_&&!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=Vv(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):Eg(e,new wh(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(jv(e._item,r)?jv(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}},Vv=(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,ny(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},Hv=(e,t)=>{let n=new x_,r=e.map(e=>({insert:e.text,attributes:ry(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},Uv=(e,t)=>{let n=new g_(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,qv(e).map(e=>Wv(e,t))),t.mapping.set(n,e),n},Wv=(e,t)=>e instanceof Array?Hv(e,t):Uv(e,t),Gv=e=>typeof e==`object`&&!!e,Kv=(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||Gv(o)&&Gv(s)&&Kv(o,s)}return r},qv=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},Jv=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&qd(e.attributes||{}).length===t[n].marks.length&&Zd(e.attributes,(e,r)=>{let i=ty(r),a=t[n].marks;return a.find(e=>e.type.name===i)?Kv(e,a.find(e=>e.type.name===i)?.attrs):!1}))},Yv=(e,t)=>{if(e instanceof g_&&!(t instanceof Array)&&ay(e,t)){let n=qv(t);return e._length===n.length&&Kv(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>Yv(e,n[t]))}return e instanceof x_&&t instanceof Array&&Jv(e,t)},Xv=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),Zv=(e,t,n)=>{let r=e.toArray(),i=qv(t),a=i.length,o=r.length,s=su(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(Xv(n.mapping.get(e),t))u=!0;else if(!Yv(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(Xv(n.mapping.get(e),t))u=!0;else if(!Yv(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},Qv=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof H_?t+=n.content.str:n.content instanceof F_&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},$v=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=Qv(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,ry(e.marks,n))})),{insert:o,remove:s,index:c}=hv(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})))},ey=/(.*)(--[a-zA-Z0-9+/=]{8})$/,ty=e=>ey.exec(e)?.[1]??e,ny=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(ty(r),e[r]));return n},ry=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=Kl(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${kv(e.toJSON())}`:e.type.name]=e.attrs}}),n},iy=(e,t,n,r)=>{if(t instanceof g_&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof g_){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=qv(n),a=i.length,o=t.toArray(),s=o.length,c=su(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!Xv(r.mapping.get(e),t))if(Yv(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(!Xv(r.mapping.get(e),t))if(Yv(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 x_&&c instanceof Array)Jv(n,c)||$v(n,c,r),l+=1;else{let i=n instanceof g_&&ay(n,c),a=d instanceof g_&&ay(d,f);if(i&&a){let e=Zv(n,c,r),t=Zv(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(iy(e,n,c,r),l+=1):a?(iy(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[Wv(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof x_?(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(Wv(i[t],r));t.insert(l,e)}},Tv)},ay=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,oy=null,sy=class{constructor(e,t,n){this.view=e,this.key=t,this.value=n}apply(){let e=Tv.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)}}},cy=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 sy(t,r,e))})}),new e(n)}},ly=(e=cy.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()||Qp(0,()=>ly(e,!0));return}throw r}n=!1,e.dequeueFirst()}},uy=(e,t,n)=>{oy||(oy=new Map,Qp(0,ly)),Kl(oy,e,Wl).set(t,n)},dy=(e,t,n)=>{if(e===0)return bh(t,0,-1);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof x_){if(r._length>=e)return bh(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 mh(r._item===null?null:r._item.id,r._item===null?fh(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 mh(r._item===null?null:r._item.id,r._item===null?fh(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 pd();if(e===0&&r.constructor!==x_&&r!==t)return fy(r._item.parent,r._item)}return bh(t,t._length,-1)},fy=(e,t)=>{let n=null,r=null;return e._item===null?r=fh(e):n=dh(e._item.id.client,e._item.id.clock),new mh(n,r,t.id)},py=(e,t,n,r)=>{let i=Sh(n,e);if(i===null||i.type!==t&&!ph(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===x_)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 x_?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 x_?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1},my=(e,t)=>{let n=Av(),r=e.toArray().map(e=>Bv(e,t,n)).filter(e=>e!==null);return{doc:t.topNodeType.create(null,Pe.fromArray(r)),meta:n,mapping:n.mapping}},hy=(e,t,n)=>e!==t,gy=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},_y=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),vy=/^#[0-9a-fA-F]{6}$/,yy=(e,t,n,r,i)=>{let a=Tv.getState(e);if(a==null||a.doc==null||a.binding==null)return q.create(e.doc,[]);let o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?q.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`:vy.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=py(o,a.type,gh(t.cursor.anchor),a.binding.mapping),u=py(o,a.type,gh(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=cu(e.doc.content.size-1,0);l=su(l,t),u=su(u,t),s.push(O.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=su(l,u),o=cu(l,u);s.push(O.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),q.create(e.doc,s))},by=(e,{awarenessStateFilter:t=hy,cursorBuilder:n=gy,selectionBuilder:r=_y,getSelection:i=e=>e.selection}={},a=`cursor`)=>new pt({key:Dv,state:{init(i,a){return yy(a,e,t,n,r)},apply(i,a,o,s){let c=Tv.getState(s),l=i.getMeta(Dv);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?yy(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>Dv.getState(e)},view:t=>{let n=()=>{t.docView&&uy(t,Dv,{awarenessUpdated:!0})},r=()=>{let n=Tv.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=dy(o.anchor,n.type,n.binding.mapping),c=dy(o.head,n.type,n.binding.mapping);(r.cursor==null||!Ch(gh(r.cursor.anchor),s)||!Ch(gh(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&py(n.doc,n.type,gh(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)}}}}),xy=e=>{let t=Ev.getState(e).undoManager;if(t!=null)return t.undo(),!0},Sy=e=>{let t=Ev.getState(e).undoManager;if(t!=null)return t.redo(),!0},Cy=new Set([`paragraph`]),wy=(e,t)=>!(e instanceof av)||!(e.content instanceof Q_)||!(e.content.type instanceof d_||e.content.type instanceof g_&&t.has(e.content.type.nodeName))||e.content.type._length===0,Ty=({protectedNodes:e=Cy,trackedOrigins:t=[],undoManager:n=null}={})=>new pt({key:Ev,state:{init:(r,i)=>{let a=Tv.getState(i),o=n||new Zh(a.type,{trackedOrigins:new Set([Tv].concat(t)),deleteFilter:t=>wy(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=Tv.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:Lv(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=Tv.getState(e.state),n=Ev.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,Ev.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 Ey(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=z(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 Dy(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 Oy=new N(`suggestion`);function ky({pluginKey:e=Oy,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=Ey,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}},S=(n,r)=>r?()=>{let r=e.getState(t.state)?.decorationId;return n.dom.querySelector(`[data-decoration-id="${r}"]`)?.getBoundingClientRect()||null}:x,C=({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&&!Dy(i);function w(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:S(n,a)};(i=y?.onExit)==null||i.call(y,o)}catch{}let a=n.state.tr.setMeta(r,{exit:!0});n.dispatch(a)}let T=new pt({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,C=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:C,clientRect:S(e,C)},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&&!C({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}=T.getState(t.state);if(!i)return!1;if(n.key===`Escape`||n.key===`Esc`){let i=T.getState(t.state);return(r=y?.onKeyDown)==null||r.call(y,{view:t,event:n,range:i.range}),w(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}=T.getState(e);if(!t)return null;let a=!i?.length,o=[c];return a&&o.push(u),q.create(e.doc,[O.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return T}var Ay=ky;function jy(e){return e.kind===`create`?`create:${e.value}`:`tag:${e.value}`}function My(e){if(e.kind===`create`){let t=e.value;return Rn._({id:`XPqe3B`,values:{tagValue:t}})}let t=Rn._({id:`pckX1A`,values:{0:e.count}}),n=e.value;return Rn._({id:`m2T1Xj`,values:{tagValue:n,uses:t}})}function Ny(e){let t=(0,Z.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,Q.useRef)(null),h=(0,Q.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,Q.useEffect)(_,v);let y=Py;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?My(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=jy(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 Py(e){return e.preventDefault()}var Fy=new WeakMap;function Iy(e,t){Fy.set(e,t)}function Ly(e){return Fy.get(e)??!1}function Ry(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`),fr(r,n,{placement:`bottom-start`,middleware:[nr(4),lr(),hr({padding:8}),_r({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:()=>or(r,n,o),reveal:()=>{a||(i=!0,o())}}}function zy(e){e.stopAutoUpdate?.(),e.stopAutoUpdate=null,e.popup?.remove(),e.popup=null}var By=new N(`tagSuggestion`),Vy=8,Hy=/^[a-zA-Z][\w/-]*$/;async function Uy(){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 Wy(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 Gy(e,t){let n=Wy(e,t).slice(0,Vy).map(e=>({kind:`tag`,value:e.name,count:e.count,isLeaf:e.isLeaf})),r=t.trim();return r&&Hy.test(r)&&!e.some(e=>e.name===r)&&n.push({kind:`create`,value:r}),n}function Ky(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 qy(e){let t=[],n=!1,r=null,i=null;return Ay({editor:e,pluginKey:By,char:`#`,allowedPrefixes:null,findSuggestionMatch:Ky,allow:({editor:e})=>!Ly(e),items:async({query:e})=>{if(!n){r||=Uy();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 Gy(t,e)},command:({editor:e,range:t,props:n})=>{try{let r=n.value;if(!r||!Hy.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=Ry(()=>a,`tag-suggestion`);s.popup=n.popup,c=n.doPosition,l=n.reveal,e=new Ll(Ny,{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&&Hy.test(n)?(a.command({kind:`create`,value:n}),!0):!1}return e.key,!1},onExit(){zy(s),c=null,l=null,e?.destroy(),e=null,a=null,o=0,t=[],i=null,n=!1,r=null}}}})}var Jy=1,Yy=.9,Xy=.8,Zy=.17,Qy=.1,$y=.999,eb=.9999,tb=.99,nb=/[\\\/_+.#"@\[\(\{&]/,rb=/[\\\/_+.#"@\[\(\{&]/g,ib=/[\s-]/,ab=/[\s-]/g;function ob(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Jy:tb;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*=Jy:nb.test(e.charAt(l-1))?(d*=Xy,p=e.slice(i,l-1).match(rb),p&&i>0&&(d*=$y**+p.length)):ib.test(e.charAt(l-1))?(d*=Yy,m=e.slice(i,l-1).match(ab),m&&i>0&&(d*=$y**+m.length)):(d*=Zy,i>0&&(d*=$y**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=eb)),(d<Qy&&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*Qy>d&&(d=f*Qy)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function sb(e){return e.toLowerCase().replace(ab,` `)}function cb(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,ob(e,t,sb(e),sb(t),0,0,{})}var lb=`[cmdk-group=""]`,ub=`[cmdk-group-items=""]`,db=`[cmdk-group-heading=""]`,fb=`[cmdk-item=""]`,pb=`${fb}:not([aria-disabled="true"])`,mb=`cmdk-item-select`,hb=`data-value`,gb=(e,t,n)=>cb(e,t,n),_b=Q.createContext(void 0),vb=()=>Q.useContext(_b),yb=Q.createContext(void 0),bb=()=>Q.useContext(yb),xb=Q.createContext(void 0),Sb=Q.forwardRef((e,t)=>{let n=Ib(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Ib(()=>new Set),i=Ib(()=>new Map),a=Ib(()=>new Map),o=Ib(()=>new Set),s=Pb(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Wn(),y=Wn(),b=Wn(),x=Q.useRef(null),S=zb();Fb(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Fb(()=>{S(6,k)},[]);let C=Q.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=Q.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??gb;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(ub);t?t.appendChild(e.parentElement===t?e:e.closest(`${ub} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${ub} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${lb}[${hb}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(hb);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(lb)?.querySelector(db))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${fb}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(pb)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(hb))}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(hb))}function P(e){let t=A()?.closest(lb),n;for(;t&&!n;)t=e>0?Mb(t,lb):Nb(t,lb),n=t?.querySelector(pb);n?C.setState(`value`,n.getAttribute(hb)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return Q.createElement(qn.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(mb);t.dispatchEvent(e)}}}}},Q.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Hb},c),Vb(e,e=>Q.createElement(yb.Provider,{value:C},Q.createElement(_b.Provider,{value:w},e))))}),Cb=Q.forwardRef((e,t)=>{let n=Wn(),r=Q.useRef(null),i=Q.useContext(xb),a=vb(),o=Pb(e),s=o.current?.forceMount??i?.forceMount;Fb(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Rb(n,r,[e.value,e.children,r],e.keywords),l=bb(),u=Lb(e=>e.value&&e.value===c.current),d=Lb(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);Q.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(mb,f),()=>t.removeEventListener(mb,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return Q.createElement(qn.div,{ref:Wt(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)}),wb=Q.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Wn(),s=Q.useRef(null),c=Q.useRef(null),l=Wn(),u=vb(),d=Lb(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);Fb(()=>u.group(o),[]),Rb(o,s,[e.value,e.heading,c]);let f=Q.useMemo(()=>({id:o,forceMount:i}),[i]);return Q.createElement(qn.div,{ref:Wt(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&Q.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Vb(e,e=>Q.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Q.createElement(xb.Provider,{value:f},e))))}),Tb=Q.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Q.useRef(null),a=Lb(e=>!e.search);return!n&&!a?null:Q.createElement(qn.div,{ref:Wt(i,t),...r,"cmdk-separator":``,role:`separator`})}),Eb=Q.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=bb(),o=Lb(e=>e.search),s=Lb(e=>e.selectedItemId),c=vb();return Q.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Q.createElement(qn.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)}})}),Db=Q.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Q.useRef(null),o=Q.useRef(null),s=Lb(e=>e.selectedItemId),c=vb();return Q.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Q.createElement(qn.div,{ref:Wt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Vb(e,e=>Q.createElement(`div`,{ref:Wt(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Ob=Q.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Q.createElement(sn,{open:n,onOpenChange:r},Q.createElement(Qt,{container:o},Q.createElement(Zt,{"cmdk-overlay":``,className:i}),Q.createElement(dn,{"aria-label":e.label,"cmdk-dialog":``,className:a},Q.createElement(Sb,{ref:t,...s}))))}),kb=Q.forwardRef((e,t)=>Lb(e=>e.filtered.count===0)?Q.createElement(qn.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Ab=Q.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Q.createElement(qn.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Vb(e,e=>Q.createElement(`div`,{"aria-hidden":!0},e)))}),jb=Object.assign(Sb,{List:Db,Item:Cb,Input:Eb,Group:wb,Separator:Tb,Dialog:Ob,Empty:kb,Loading:Ab});function Mb(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Nb(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Pb(e){let t=Q.useRef(e);return Fb(()=>{t.current=e}),t}var Fb=typeof window>`u`?Q.useEffect:Q.useLayoutEffect;function Ib(e){let t=Q.useRef();return t.current===void 0&&(t.current=e()),t}function Lb(e){let t=bb(),n=()=>e(t.snapshot());return Q.useSyncExternalStore(t.subscribe,n,n)}function Rb(e,t,n,r=[]){let i=Q.useRef(),a=vb();return Fb(()=>{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(hb,s),i.current=s}),i}var zb=()=>{let[e,t]=Q.useState(),n=Ib(()=>new Map);return Fb(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Bb(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Vb({asChild:e,children:t},n){return e&&Q.isValidElement(t)?Q.cloneElement(Bb(t),{ref:t.ref},n(t.props.children)):n(t)}var Hb={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Ub(e){let t=(0,Z.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=Ut(`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)(jb,{"data-slot":`command`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Wb(e){let t=(0,Z.c)(36),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({title:s,description:c,children:n,className:r,showCloseButton:l,commandProps:i,onEscapeKeyDown:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=s===void 0?`Command Palette`:s,d=c===void 0?`Search for a command to run`:c,f=l===void 0?!0:l,p;t[9]===i?p=t[10]:(p=i??{},t[9]=i,t[10]=p);let m,h;t[11]===p?(m=t[12],h=t[13]):({className:m,...h}=p,t[11]=p,t[12]=m,t[13]=h);let g;t[14]===r?g=t[15]:(g=Ut(`top-[12vh] translate-y-0 overflow-hidden p-0`,r),t[14]=r,t[15]=g);let _;t[16]===u?_=t[17]:(_=(0,X.jsx)(Xt,{className:`sr-only`,children:u}),t[16]=u,t[17]=_);let v;t[18]===d?v=t[19]:(v=(0,X.jsx)(Yt,{className:`sr-only`,children:d}),t[18]=d,t[19]=v);let y;t[20]===m?y=t[21]:(y=Ut(`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,m),t[20]=m,t[21]=y);let b;t[22]!==n||t[23]!==h||t[24]!==y?(b=(0,X.jsx)(Ub,{className:y,...h,children:n}),t[22]=n,t[23]=h,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==a||t[27]!==f||t[28]!==g||t[29]!==_||t[30]!==v||t[31]!==b?(x=(0,X.jsxs)(tn,{className:g,showCloseButton:f,onEscapeKeyDown:a,children:[_,v,b]}),t[26]=a,t[27]=f,t[28]=g,t[29]=_,t[30]=v,t[31]=b,t[32]=x):x=t[32];let S;return t[33]!==o||t[34]!==x?(S=(0,X.jsx)(un,{...o,children:x}),t[33]=o,t[34]=x,t[35]=S):S=t[35],S}function Gb(e){let t=(0,Z.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)(ga,{className:`size-4 shrink-0 opacity-50`}),t[3]=i):i=t[3];let a;t[4]===n?a=t[5]:(a=Ut(`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)(jb.Input,{"data-slot":`command-input`,className:a,...r})]}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function Kb(e){let t=(0,Z.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=Ut(`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)(jb.List,{"data-slot":`command-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function qb(e){let t=(0,Z.c)(2),n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(jb.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e}),t[0]=e,t[1]=n),n}function Jb(e){let t=(0,Z.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=Ut(`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)(jb.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Yb(e){let t=(0,Z.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=Ut(`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)(jb.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Xb(e){let t=(0,Z.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=Ut(`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 Zb(e,t){let n=null,r;try{n=await e.json()}catch(e){r=e}if(r instanceof Error&&r.name===`AbortError`)throw r;if(e.ok)return r!==void 0&&console.warn(`[parse-server-response] 2xx response with non-JSON body:`,r instanceof Error?r.message:String(r)),{ok:!0,body:r===void 0?n:null};if(r!==void 0){let t=r instanceof Error?r.message:String(r);return{ok:!1,title:`Server error (HTTP ${e.status}): ${t}`}}return{ok:!1,title:wn(n)??t}}function Qb(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 $b=new Map,ex=null;function tx(){return uc(`PREWARM_CORRELATION_WINDOW_MS`,5e3)}function nx(){if(ex!==null)return;let e=Math.max(50,Math.floor(tx()/2));ex=setTimeout(()=>{ex=null,rx(Date.now()),$b.size>0&&nx()},e)}function rx(e){let t=tx();for(let[n,r]of $b)e-r.emittedAt>=t&&($b.delete(n),$.count(`ok/sidebar/prewarm`,{hit:!1}))}function ix(e,t,n=Date.now()){$b.has(e)&&$.count(`ok/sidebar/prewarm`,{hit:!1}),$b.set(e,{poolEventId:t,emittedAt:n}),nx()}function ax(e,t,n=Date.now()){let r=$b.get(e);return!r||r.poolEventId!==t||n-r.emittedAt>=tx()?!1:($b.delete(e),$(`ok/sidebar/prewarm-clicked`,{docName:e,t:n,poolEventId:t}),$.count(`ok/sidebar/prewarm`,{hit:!0}),!0)}Qe({event:ke(`ok-branch-switched-clear-failed`),branch:Ct(),docName:Ct(),reason:Ct()});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 sx=null,cx=new Set;function lx(){return sx}function ux(e){let t=e!==null&&e.length>0?e:null;if(t!==sx){sx=t;for(let e of cx)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function dx(e){return cx.add(e),()=>{cx.delete(e)}}function fx(){return(0,Q.useSyncExternalStore)(dx,lx,lx)}function px(e){let t=!1;return()=>{t?e():t=!0}}function mx(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 hx(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=rt.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),ux(i.data.serverInstanceId),i.data.currentBranch!==void 0&&e.compareAndUpdateObservedBranch(i.data.currentBranch)&&(ox(e,i.data.currentBranch),Pn(i.data.currentBranch)),i.data.currentDiskAckSVs!==void 0){let t={};for(let[e,n]of Object.entries(i.data.currentDiskAckSVs))try{t[e]=mx(n)}catch{}e.observeDiskAckBatch(t)}}async function gx(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,singleFile:r.singleFile===!0}}}function _x(e){return Tx(e,Le)}function vx(e){return Tx(e,nt)}function yx(e){return Tx(e,Ze)}function bx(e){return Tx(e,je)}function xx(e){return Tx(e,St)}function Sx(e){let t=Tx(e,ct);if(!t)return null;try{return{docName:t.docName,sv:Cx(t.sv)}}catch{return null}}function Cx(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 wx(e,t){let n=vx(e);if(n){t.onServerInfo?.(n);return}let r=yx(e);if(r){t.onBranchSwitched?.(r);return}let i=Sx(e);if(i){t.onDiskAck?.(i);return}let a=_x(e);if(a){t.onDerivedView?.(a);return}let o=bx(e);if(o){t.onConfigValidationRejected?.(o);return}let s=xx(e);if(s){t.onConfigIgnoreNestedError?.(s);return}t.onUnknown?.(e)}function Tx(e,t){let n;try{n=JSON.parse(e)}catch{return null}let r=t.safeParse(n);return r.success?r.data:null}function Ex(){return typeof location>`u`?`ws://localhost/collab`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/collab`}function Dx(e){if(e===void 0)return null;let t=e.okDesktop;return!t||!t.config.collabUrl||t.config.collabUrl.length===0?null:t}function Ox(e){return{collabUrl:e.collabUrl,attempts:0,terminal:!1,lastError:null}}var kx=2e3,Ax=15e3;function jx(e){let t=e.terminalAfterMs??3e4,n=e.initialDelayMs??kx,r=e.maxDelayMs??Ax,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 Mx(){let e=(0,Z.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={collabUrl:null,attempts:0,terminal:!1,lastError:null},e[0]=t):t=e[0];let[n,r]=(0,Q.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={token:0},e[1]=i):i=e[1];let a=(0,Q.useRef)(i),[o,s]=(0,Q.useState)(0),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=a.current.token=a.current.token+1,t=Dx(window);if(t){r(Ox(t.config));let n=t.onProjectSwitched(t=>{e===a.current.token&&r(Ox(t))});return()=>{n()}}let n=jx({fetchConfig:gx,fallbackUrl:Ex,now:Date.now,setTimeout:Ix,clearTimeout:Fx,onStateChange:t=>{e===a.current.token&&r(t)}});return()=>{n.cancel()}},e[2]=c):c=e[2];let l;e[3]===o?l=e[4]:(l=[o],e[3]=o,e[4]=l),(0,Q.useEffect)(c,l);let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{a.current.token=a.current.token+1,r(Px),s(Nx)},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 Nx(e){return e+1}function Px(e){return{...e,terminal:!1,lastError:null}}function Fx(e){return globalThis.clearTimeout(e)}function Ix(e,t){return globalThis.setTimeout(e,t)}var Lx=new Map,Rx=new Set;function zx(){for(let e of Rx)e()}function Bx(e,t){Lx.set(e,t),zx()}function Vx(e,t){Lx.get(e)===t&&(Lx.delete(e),zx())}function Hx(e){return Lx.get(e)??null}function Ux(e){return Rx.add(e),()=>Rx.delete(e)}var Wx=new Map;function Gx(e){return Wx.get(e)}function Kx(e,t){Wx.set(e,t)}function qx(e){Wx.delete(e)}var Jx=`open-knowledge-app`,Yx=new Map,Xx=new Set,Zx=1024,Qx=1024;function $x(){return Vn.getTracer(Jx)}function eS(e,t,n){if(Xx.has(e))return null;let r=Yx.get(e);if(r)return r;if(Yx.size>=Qx){let e=Yx.keys().next().value;if(e!==void 0){let t=Yx.get(e);Yx.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:$x().startSpan(`ok.cold-mount`,{attributes:{"mount.id":e,...t},startTime:n}),startTimeMs:n};return Yx.set(e,i),i}function tS(e,t,n,r,i){try{let a=eS(e,n,r),o=a?Vn.setSpan(Hn.active(),a.span):Hn.active();$x().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 nS(e,t){try{let n=Yx.get(e);if(n&&(Yx.delete(e),n.span.end(t??Date.now())),!Xx.has(e)){if(Xx.size>=Zx){let e=Xx.values().next().value;e!==void 0&&Xx.delete(e)}Xx.add(e)}}catch(e){console.warn(`[otel-spans] finalizeColdMountSpan failed:`,e instanceof Error?e:String(e))}}var rS=class extends Error{docName;constructor(e){super(`Mount aborted for "${e}"`),this.name=`MountAbortError`,this.docName=e}};function iS(){return uc(`MOUNT_STALLED_THRESHOLD_MS`,1e4)}function aS(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;$(`ok/mount/stalled`,{docName:t,mountId:e.mountId,elapsedMs:r})}var sS=new Map,cS=new Set;function lS(e){cS.add(e);for(let[t,n]of sS)if(n.stalledMarkEmitted&&!n.settled)try{e(t,n.mountId)}catch{}return()=>{cS.delete(e)}}function uS(e,t){for(let n of cS)try{n(e,t.mountId)}catch{}}var dS=!1;function fS(){typeof document>`u`||document.visibilityState===`visible`&&hS(Date.now())}function pS(){dS||typeof document>`u`||typeof document.addEventListener==`function`&&(document.addEventListener(`visibilitychange`,fS),dS=!0)}function mS(){dS&&(typeof document>`u`||typeof document.removeEventListener==`function`&&(document.removeEventListener(`visibilitychange`,fS),dS=!1))}function hS(e){let t=iS();for(let[n,r]of sS)r.settled||r.stalledMarkEmitted||e-r.createdAt<t||(oS(r,n,e),uS(n,r))}function gS(e){let{docName:t,mountId:n,construct:r,sizeStats:i}=e,a=sS.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()),uS(t,d))},iS()),o.signal.addEventListener(`abort`,()=>{d.settled||(d.settled=!0,aS(d),d.preMountEditor&&=(bS(t,d.preMountEditor,`aborted`),null),sS.delete(t),sS.size===0&&mS(),$(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`aborted`}),l(new rS(t)),nS(d.mountId))}),sS.set(t,d),pS(),$(`ok/mount/create`,{docName:t,mountId:d.mountId}),xS({docName:t,construct:r,sizeStats:i,entry:d,resolveFn:c,rejectFn:l}).catch(e=>{if(d.preMountEditor&&=(bS(t,d.preMountEditor,`backstop`),null),d.settled){$(`ok/mount/post-settle-throw`,{docName:t,mountId:d.mountId,message:e instanceof Error?e.message:String(e)});return}d.settled=!0,aS(d);let n=e instanceof Error?e:Error(String(e));$(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`unhandled-body-throw`,message:n.message}),l(n),nS(d.mountId)}),u}function _S(e){return sS.get(e)?.resolved===!0}function vS(e){return sS.get(e)?.controller??null}function yS(e){let t=sS.get(e);t&&(t.settled=!0,aS(t),t.preMountEditor&&=(bS(e,t.preMountEditor,`aborted`),null),sS.delete(e),sS.size===0&&mS(),$(`ok/mount/invalidate`,{docName:e,mountId:t.mountId}),nS(t.mountId),t.controller.abort())}function bS(e,t,n){let r=SS(t);try{t.destroy()}catch(t){$(`ok/mount/destroy-failed`,{docName:e,stage:n,message:t instanceof Error?t.message:String(t)})}r&&(r.restore=void 0)}async function xS(e){let{docName:t,construct:n,sizeStats:r,entry:i,resolveFn:a,rejectFn:o}=e,s=document.createElement(`div`);if(nC(t)!==void 0){let e=BS({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,aS(i),a(e);return}if(await scheduler.yield(),i.controller.signal.aborted)return;let c=null;try{c=n()}catch(e){i.settled=!0,aS(i);let n=e instanceof Error?e:Error(String(e));$(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`construct-failed`,message:n.message}),o(n),nS(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){bS(t,c.editor,`mount-failed`),i.preMountEditor=null,i.settled=!0,aS(i);let n=e instanceof Error?e:Error(String(e));$(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`mount-failed`,message:n.message}),o(n),nS(i.mountId);return}let l;try{l=BS({docName:t,container:s,sizeStats:r,factory:()=>c})}catch(e){bS(t,c.editor,`v2-register-failed`),i.preMountEditor=null,i.settled=!0,aS(i);let n=e instanceof Error?e:Error(String(e));$(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`v2-register-failed`,message:n.message}),o(n),nS(i.mountId);return}i.preMountEditor=null,i.settled=!0,i.resolved=!0,aS(i);let u=Date.now()-i.createdAt;$(`ok/mount/resolve`,{docName:t,mountId:i.mountId,elapsedMs:u}),$.histogram(`ok/mount/resolve-elapsed-ms`,{docName:t,mountId:i.mountId},u),a(l);let d=Date.now();tS(i.mountId,`ok.mount-promise`,{"doc.name":t,elapsed_ms:u},i.createdAt,d),nS(i.mountId,d)}function SS(e){try{let t=e.state;return Ev.getState(t)?.undoManager??null}catch(e){return $(`ok/cache/undo-manager-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}var CS=uc(`MAX_CACHE`,10),wS=uc(`VIEW_COUNT_CACHE_THRESHOLD`,50),TS=uc(`BYTES_CACHE_THRESHOLD`,8e6);function ES(e){return!(e.viewCount>0&&e.viewCount>=wS||e.bytes>TS)}var DS=new Map,OS=new Map,kS=new Map;function AS(e,t){if(kS.size>=CS){let e=kS.keys().next().value;e!==void 0&&kS.delete(e)}kS.set(e,t),$(`ok/cache/snapshot-stored`,{toDocName:e,htmlBytes:t.html.length,hasScroll:t.scrollTop>0,hasSelection:t.selection!==null})}function jS(e){return kS.get(e)??null}function MS(e){if(!kS.has(e))return;let t=kS.get(e)??null;kS.delete(e),$(`ok/cache/snapshot-consumed`,{docName:e,hit:t!==null,hasScroll:t!==null&&t.scrollTop>0,hasSelection:t!==null&&t.selection!==null})}function NS(){try{return typeof document>`u`?0:document.querySelector(`[data-testid="editor-scroll-container"]`)?.scrollTop??0}catch(e){return $(`ok/cache/snapshot-scroll-read-failed`,{message:e instanceof Error?e.message:String(e)}),0}}function PS(e){try{let t=e.state.selection;return t instanceof Ce?{type:`text`,anchor:t.anchor,head:t.head}:t instanceof I?{type:`node`,from:t.from}:null}catch(e){return $(`ok/cache/snapshot-selection-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}function FS(e){for(let t of e)try{let e=nC(t.fromDocName);if(e&&!e.editor.isDestroyed){if(e.ytext.length===0){$(`ok/cache/snapshot-skipped-empty`,{fromDocName:t.fromDocName});continue}AS(t.toDocName,{html:e.editor.getHTML(),scrollTop:NS(),selection:PS(e.editor)})}else $(`ok/cache/snapshot-skipped`,{fromDocName:t.fromDocName})}catch(e){$(`ok/cache/snapshot-capture-failed`,{fromDocName:t.fromDocName,message:e instanceof Error?e.message:String(e)})}}var IS=[],LS=[],RS=new Set;function zS(){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 BS(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!ES(i)){let e=r(n);return $(`ok/cache/miss`,{docName:t,mountId:Gx(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=DS.get(t);if(a){if($(`ok/cache/reparent-start`,{docName:t,mountId:Gx(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),JS(a,n),a.activeMountKey=t,XS(IS,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.editor.commands.focus()}catch{}return $(`ok/cache/reparent-end`,{docName:t,mountId:Gx(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),$(`ok/cache/hit`,{docName:t,mountId:Gx(t),kind:`tiptap`}),i&&$(`ok/cold/editor-mount-stats`,{docName:t,mountId:Gx(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;DS.size>=CS;){let e=ZS(IS,t);if(!e)break;HS(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 DS.set(t,s),XS(IS,t),$(`ok/cache/miss`,{docName:t,mountId:Gx(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&$(`ok/cold/editor-mount-stats`,{docName:t,mountId:Gx(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function VS(e){let t=e.activeMountKey;if(e.__uncached){t&&yS(t);let n=SS(e.editor);try{e.editor.destroy()}catch(e){$(`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=KS(e.editor);if(n){e.hadFocus=qS(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||=zS(),e.parkingNode&&e.parkingNode.appendChild(n.dom)}e.activeMountKey=null}function HS(e){yS(e);let t=DS.get(e);if(!t)return!1;let n=SS(t.editor);try{t.editor.destroy()}catch(t){$(`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){$(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){$(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}DS.delete(e);let r=IS.indexOf(e);return r!==-1&&IS.splice(r,1),$(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function US(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!ES(i)){let e=r(n);return $(`ok/cache/miss`,{docName:t,mountId:Gx(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`,kind:`cm`}),{view:e.view,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,themeCompartment:e.themeCompartment,wordWrapCompartment:e.wordWrapCompartment,placeholderCompartment:e.placeholderCompartment,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=OS.get(t);if(a){if($(`ok/cache/reparent-start`,{docName:t,mountId:Gx(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),YS(a,n),a.activeMountKey=t,XS(LS,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.view.focus()}catch{}return $(`ok/cache/reparent-end`,{docName:t,mountId:Gx(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),$(`ok/cache/hit`,{docName:t,mountId:Gx(t),kind:`cm`}),i&&$(`ok/cold/editor-mount-stats`,{docName:t,mountId:Gx(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;OS.size>=CS;){let e=ZS(LS,t);if(!e)break;GS(e)}let o=r(n),s={view:o.view,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,themeCompartment:o.themeCompartment,wordWrapCompartment:o.wordWrapCompartment,placeholderCompartment:o.placeholderCompartment,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return OS.set(t,s),XS(LS,t),$(`ok/cache/miss`,{docName:t,mountId:Gx(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&$(`ok/cold/editor-mount-stats`,{docName:t,mountId:Gx(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function WS(e){if(e.__uncached){try{e.view.destroy()}catch(t){$(`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=qS(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t),e.parkingNode||=zS(),e.parkingNode&&e.parkingNode.appendChild(t),e.activeMountKey=null}function GS(e){let t=OS.get(e);if(!t)return!1;try{t.view.destroy()}catch(t){$(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){$(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){$(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}OS.delete(e);let n=LS.indexOf(e);return n!==-1&&LS.splice(n,1),$(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function KS(e){return e.editorView??null}function qS(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function JS(e,t){let n=KS(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 YS(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function XS(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function ZS(e,t){for(let n of e)if(n!==t&&!RS.has(n))return n;$(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:RS.size});for(let n of e)if(n!==t)return n;return null}function QS(e){let t=RS,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=eC(e);if(t)try{t.disconnect(),$(`ok/cache/disconnect`,{docName:e})}catch(t){$(`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=eC(e);if(!n)continue;let r=t=>{$(`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(()=>$(`ok/cache/connect`,{docName:e}),e=>r(e)):$(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}RS=n}var $S=null;function eC(e){let t=DS.get(e);if(t)return t.provider;let n=OS.get(e);if(n)return n.provider;if($S){let t=$S.entries.get(e);if(t)return t.provider}return null}function tC(e){$S=e;let t=e.onEvict(e=>{HS(e),GS(e)});return()=>{t(),$S===e&&($S=null)}}function nC(e){return DS.get(e)}var rC=`ok-editor-tabs-v1:`,iC=`\0folder:`,aC=`\0asset:`,oC=`\0doc-tab:`,sC=/\.(md|mdx)$/i;function cC(e){let t=e.lastIndexOf(oC);return t<0?{baseTabId:e,instanceSuffix:``}:{baseTabId:e.slice(0,t),instanceSuffix:e.slice(t)}}function lC(e){return cC(e).baseTabId}function uC(e){return sC.test(e)?e.replace(sC,``):null}function dC(e){if(typeof e!=`string`||e.length===0)return!1;let t=lC(e);return t.startsWith(iC)?t.length>8:t.startsWith(aC)?t.length>7:!0}function fC(e){return e}function pC(e,t){return`${lC(e)}${oC}${t}`}function mC(e,t){return hC(e,fC(t))}function hC(e,t){let n=SC(e,2**53-1),r=lC(t);if(!n.includes(r))return r;let i=1,a;do a=pC(r,i),i++;while(n.includes(a));return a}function gC(e){return`${iC}${e}`}function _C(e){return`${aC}${e}`}function vC(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 yC(e){switch(e.kind){case`doc`:case`folder-index`:case`large-file`:return fC(e.docName);case`folder`:return gC(e.folderPath);case`missing`:return fC(e.target);case`asset`:return _C(e.assetPath)}}function bC(e){let t=lC(e);return t.startsWith(iC)?{kind:`folder`,folderPath:t.slice(8)}:t.startsWith(aC)?{kind:`asset`,assetPath:t.slice(7)}:{kind:`doc`,docName:t}}function xC(e){let t=bC(e);return t.kind===`doc`?t.docName:null}function SC(e,t){if(!Array.isArray(e)||t<=0)return[];let n=[],r=new Set;for(let i of e)if(dC(i)&&!r.has(i)&&(r.add(i),n.push(i),n.length>=t))break;return n}function CC(e,t){let n=new Set(SC(t,2**53-1));return SC(e,2**53-1).filter(e=>n.has(e))}function wC(e,t,n){if(t<=0)return[];let r=new Set(SC(n,2**53-1)),i=SC(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 TC(e,t,n){let r=CC(e,n);return!SC(n,2**53-1).includes(t)||r.includes(t)?r:[...r,t]}function EC(e,t){return SC(e,2**53-1).filter(e=>e!==t)}function DC(e,t){let n=new Set(SC(t,2**53-1));return SC(e,2**53-1).filter(e=>!n.has(e))}function OC(e,t,n){let r=SC(e,2**53-1),i=CC(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?TC(i,n,r):EC(i,n)}function kC(e,t,n,r=[]){let i=wC(e,n,r);return!dC(t)||i.includes(t)?i:wC([...i,t],n,r)}function AC(e,t,n,r,i=[]){let a=wC(e,r,i);if(!dC(n))return a;if(!t||t===n)return kC(a,n,r,i);let o=a.filter(e=>e!==n),s=o.indexOf(t);if(s<0)return kC(o,n,r,i);let c=[...o];return c[s]=n,wC(c,r,i)}function jC(e,t,n){return MC(e,fC(t),n)}function MC(e,t,{behavior:n,currentTabId:r,limit:i,pinnedTabIds:a=[]}){let o=wC(e,i,a),s=lC(t);if(r&&o.includes(r)&&lC(r)===s)return{tabs:o,activeTabId:r};if(n!==`replace-active`)return{tabs:kC(o,s,i,a),activeTabId:s};let c=hC(o,s);return{tabs:AC(o,r,c,i,a),activeTabId:c}}function NC(e,t){return e.filter(e=>e!==t)}function PC(e,t,n){let r=SC(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 FC(e,{pages:t,folderPaths:n,assetPaths:r,keepMissingDocName:i=null,keepHashDocName:a=null}){return SC(e,2**53-1).filter(e=>{let o=bC(e);return o.kind===`folder`?n.has(o.folderPath):o.kind===`asset`?r.has(o.assetPath):t.has(o.docName)||o.docName===i||o.docName===a})}function IC(e,t,n,r=[],i=[],a=[]){if(t.length===0&&r.length===0&&a.length===0)return SC(e,n);let o=new Map(t.map(e=>[e.fromDocName,e.toDocName])),s=new Map(a.flatMap(e=>{let t=uC(e.fromPath);return t?[[t,e.toPath]]:[]})),c=new Map(a.flatMap(e=>{let t=uC(e.toPath);return t?[[e.fromPath,t]]:[]})),l=e=>zC(RC(e,r),a),u=(e,t)=>{let n=o.get(e);if(n)return n;let r=s.get(e);return r?_C(r):t},d=e=>{let t=c.get(e);return t?fC(t):_C(l(e))},f=[],p=new Set;for(let t of e){let{instanceSuffix:e}=cC(t),a=bC(t),o=`${a.kind===`doc`?u(a.docName,lC(t)):a.kind===`folder`?gC(RC(a.folderPath,r)):d(a.assetPath)}${e}`;if(!p.has(o)&&(p.add(o),f.push(o),i.length===0&&f.length>=n))break}return i.length===0?f:wC(f,n,i.map(e=>{let t=bC(e);return t.kind===`doc`?u(t.docName,e):t.kind===`folder`?gC(RC(t.folderPath,r)):d(t.assetPath)}))}function LC(e,t,n=[],r=[]){return IC(e,t,2**53-1,n,[],r)}function RC(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 zC(e,t){for(let{fromPath:n,toPath:r}of t)if(e===n)return r;return e}function BC(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 VC(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 HC(e,t){if(typeof e!=`object`||!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};let n=e,r=SC(n.openTabs,2**53-1),i=CC(n.pinnedTabIds,r),a=i.length===0?SC(n.openTabs,t):wC(r,t,i),o=CC(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?bC(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 UC(e,t,n=[],r=()=>new Date){let i=SC(e,2**53-1),a=t&&i.includes(t)?t:null,o=a?bC(a):null;return{openTabs:i,pinnedTabIds:CC(n,i),activeDocName:o?.kind===`doc`?o.docName:null,activeTabId:a,updatedAt:r().toISOString()}}function WC(e){return`${rC}${e}`}function GC(e,t,n){if(!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};try{let r=e.getItem(t);return r?HC(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 KC(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 qC=Math.floor,JC=(e,t)=>e<t?e:t,YC=(e,t)=>e>t?e:t;Number.isNaN;var XC=128,ZC=1<<17,QC=1<<18,$C=1<<19,ew=1<<20,tw=1<<21,nw=1<<22,rw=1<<23,iw=1<<24,aw=1<<25,ow=1<<26,sw=1<<27,cw=1<<28,lw=1<<29,uw=1<<30,dw=127;ZC-1,QC-1,$C-1,ew-1,tw-1,nw-1,rw-1,iw-1,aw-1,ow-1,sw-1,cw-1,lw-1,uw-1;var fw=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var pw=String.fromCharCode;String.fromCodePoint,pw(65535);var mw=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},hw=typeof TextEncoder<`u`?new TextEncoder:null,gw=hw?e=>hw.encode(e):mw,_w=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});_w&&_w.decode(new Uint8Array).length===1&&(_w=null);var vw=(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},yw=(e,t)=>{for(;t>dw;)vw(e,XC|dw&t),t=qC(t/128);vw(e,dw&t)},bw=new Uint8Array(3e4),xw=bw.length/3,Sw=hw&&hw.encodeInto?(e,t)=>{if(t.length<xw){let n=hw.encodeInto(t,bw).written||0;yw(e,n);for(let t=0;t<n;t++)vw(e,bw[t])}else ww(e,gw(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;yw(e,r);for(let t=0;t<r;t++)vw(e,n.codePointAt(t))},Cw=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=JC(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(YC(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},ww=(e,t)=>{yw(e,t.byteLength),Cw(e,t)},Tw=e=>Error(e),Ew=Tw(`Unexpected end of array`),Dw=Tw(`Integer out of Range`),Ow=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},kw=e=>Ow(e,jw(e)),Aw=e=>e.arr[e.pos++],jw=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&dw)*n,n*=128,r<XC)return t;if(t>fw)throw Dw}throw Ew},Mw=_w?e=>_w.decode(kw(e)):e=>{let t=jw(e);if(t===0)return``;{let n=String.fromCodePoint(Aw(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Aw(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))}},Nw=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),Pw=(e,t)=>{yw(e,Nw.Token),Sw(e,t)},Fw=(e,t,n,r)=>{switch(jw(e)){case Nw.Token:t();break;case Nw.PermissionDenied:n(Mw(e));break;case Nw.Authenticated:r(Mw(e));break;default:}},Iw=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),Lw=`\0`;function Rw(e,t){return e+Lw+t}function zw(e){let t=e.indexOf(Lw);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var Bw=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 Vw(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 Hw(e){return new Promise(t=>setTimeout(t,e))}function Uw(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 Ww(e,t){let n=Vw(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||Uw;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 Hw(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 Hw(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await Hw(e)}return a()}var Gw=Math.floor,Kw=(e,t)=>e<t?e:t,qw=(e,t)=>e>t?e:t;Number.isNaN;var Jw=64,Yw=128,Xw=1<<17,Zw=1<<18,Qw=1<<19,$w=1<<20,eT=1<<21,tT=1<<22,nT=1<<23,rT=1<<24,iT=1<<25,aT=1<<26,oT=1<<27,sT=1<<28,cT=1<<29,lT=1<<30,uT=63,dT=127;Xw-1,Zw-1,Qw-1,$w-1,eT-1,tT-1,nT-1,rT-1,iT-1,aT-1,oT-1,sT-1,cT-1,lT-1;var fT=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var pT=()=>new Set,mT=Array.from;Array.isArray;var hT=String.fromCharCode;String.fromCodePoint,hT(65535);var gT=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},_T=typeof TextEncoder<`u`?new TextEncoder:null,vT=_T?e=>_T.encode(e):gT,yT=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});yT&&yT.decode(new Uint8Array).length===1&&(yT=null);var bT=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},xT=()=>new bT,ST=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},CT=e=>{let t=new Uint8Array(ST(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},wT=(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},TT=(e,t)=>{for(;t>dT;)wT(e,Yw|dT&t),t=Gw(t/128);wT(e,dT&t)},ET=new Uint8Array(3e4),DT=ET.length/3,OT=_T&&_T.encodeInto?(e,t)=>{if(t.length<DT){let n=_T.encodeInto(t,ET).written||0;TT(e,n);for(let t=0;t<n;t++)wT(e,ET[t])}else AT(e,vT(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;TT(e,r);for(let t=0;t<r;t++)wT(e,n.codePointAt(t))},kT=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Kw(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(qw(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},AT=(e,t)=>{TT(e,t.byteLength),kT(e,t)},jT=e=>Error(e),MT=jT(`Unexpected end of array`),NT=jT(`Integer out of Range`),PT=class{constructor(e){this.arr=e,this.pos=0}},FT=e=>new PT(e),IT=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},LT=e=>IT(e,zT(e)),RT=e=>e.arr[e.pos++],zT=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&dT)*n,n*=128,r<Yw)return t;if(t>fT)throw NT}throw MT},BT=e=>{let t=e.arr[e.pos++],n=t&uT,r=64,i=(t&Jw)>0?-1:1;if((t&Yw)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&dT)*r,r*=128,t<Yw)return i*n;if(n>fT)throw NT}throw MT},VT=yT?e=>yT.decode(LT(e)):e=>{let t=zT(e);if(t===0)return``;{let n=String.fromCodePoint(RT(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(RT(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))}},HT=e=>{let t=e.pos,n=VT(e);return e.pos=t,n},UT=Date.now,WT=()=>new Map,GT=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},KT=class{constructor(){this._observers=WT()}on(e,t){GT(this._observers,e,pT).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 mT((this._observers.get(e)||WT()).values()).forEach(e=>e(...t))}destroy(){this._observers=WT()}},qT=Symbol(`Equality`),JT=Object.keys,YT=e=>JT(e).length,XT=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ZT=(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[qT]!=null)return e[qT](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)||!ZT(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(YT(e)!==YT(t))return!1;for(let n in e)if(!XT(e,n)||!ZT(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(!ZT(e[n],t[n]))return!1;break;default:return!1}return!0},QT=3e4,$T=class extends KT{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=UT();this.getLocalState()!==null&&QT/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&QT<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&eE(this,t,`timeout`)},Gw(QT/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:UT()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),ZT(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}},eE=(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:UT()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},tE=(e,t,n=e.states)=>{let r=t.length,i=xT();TT(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;TT(i,r),TT(i,s),OT(i,JSON.stringify(o))}return CT(i)},nE=(e,t,n)=>{let r=FT(t),i=UT(),a=[],o=[],s=[],c=[],l=zT(r);for(let t=0;t<l;t++){let t=zT(r),n=zT(r),l=JSON.parse(VT(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&&(ZT(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])},rE=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={}}},iE=class{constructor(e){this.data=e,this.encoder=xT(),this.decoder=FT(new Uint8Array(this.data))}peekVarString(){return HT(this.decoder)}readVarUint(){return zT(this.decoder)}readVarString(){return VT(this.decoder)}readVarUint8Array(){return LT(this.decoder)}writeVarUint(e){return TT(this.encoder,e)}writeVarString(e){return OT(this.encoder,e)}writeVarUint8Array(e){return AT(this.encoder,e)}length(){return ST(this.encoder)}},aE=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}({}),sE=class{constructor(){this.encoder=xT()}get(e){return e.encoder}toUint8Array(){return CT(this.encoder)}},cE=class extends sE{constructor(...e){super(...e),this.type=aE.CLOSE,this.description=`Ask the server to close the connection`}get(e){return OT(this.encoder,e.documentName),TT(this.encoder,this.type),this.encoder}},lE=class e extends rE{static{this.DEDUPLICATABLE_TYPES=new Set([aE.Awareness,aE.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(cE,{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:Ww(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=UT();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===aE.Ping){this.sendPong();return}let n=new iE(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=xT();TT(e,aE.Pong),this.send(CT(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>=UT()-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=FT(e);return{documentName:VT(t),messageType:zT(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===Bw.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()}},uE=0,dE=1,fE=2,pE=(e,t)=>{TT(e,uE),AT(e,rh(t))},mE=(e,t,n)=>{TT(e,dE),AT(e,Zm(t,n))},hE=(e,t,n)=>mE(t,n,LT(e)),gE=(e,t,n,r)=>{try{Jm(t,LT(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},_E=(e,t)=>{TT(e,fE),AT(e,t)},vE=gE,yE=(e,t,n,r,i)=>{let a=zT(e);switch(a){case uE:hE(e,t,n);break;case dE:gE(e,n,r,i);break;case fE:vE(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},bE=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case aE.Sync:this.applySyncMessage(e,t);break;case aE.Awareness:this.applyAwarenessMessage(e);break;case aE.Auth:this.applyAuthMessage(e);break;case aE.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case aE.Stateless:e.receiveStateless(VT(n.decoder));break;case aE.SyncStatus:this.applySyncStatusMessage(e,BT(n.decoder)===1);break;case aE.CLOSE:let i={code:1e3,reason:VT(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(sE,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(aE.Sync);let r=yE(n.decoder,n.encoder,e.document,e);t&&r===dE&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;nE(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;Fw(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(aE.Awareness),t.writeVarUint8Array(tE(e.awareness,Array.from(e.awareness.getStates().keys())))}},xE=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return CT(this.encoder)}send(e){e?.send(this.create())}},SE=`4.0.0-rc.1`,CE=class extends sE{constructor(...e){super(...e),this.type=aE.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return OT(this.encoder,e.documentName),TT(this.encoder,this.type),Pw(this.encoder,e.token),OT(this.encoder,SE),this.encoder}},wE=class extends sE{constructor(...e){super(...e),this.type=aE.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`);OT(this.encoder,e.documentName),TT(this.encoder,this.type);let t;return t=e.states===void 0?tE(e.awareness,e.clients):tE(e.awareness,e.clients,e.states),AT(this.encoder,t),this.encoder}},TE=class extends sE{constructor(...e){super(...e),this.type=aE.Stateless,this.description=`A stateless message`}get(e){return OT(this.encoder,e.documentName),TT(this.encoder,this.type),OT(this.encoder,e.payload??``),this.encoder}},EE=class extends sE{constructor(...e){super(...e),this.type=aE.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 OT(this.encoder,e.documentName),TT(this.encoder,this.type),pE(this.encoder,e.document),this.encoder}},DE=class extends sE{constructor(...e){super(...e),this.type=aE.Sync,this.description=`A document update`}get(e){return OT(this.encoder,e.documentName),TT(this.encoder,this.type),_E(this.encoder,e.update),this.encoder}},OE=class extends Error{constructor(...e){super(...e),this.code=1001}},kE=class extends rE{get effectiveName(){return this.configuration.sessionAwareness?Rw(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 Mm,this.configuration.awareness=e.awareness===void 0?new $T(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:Iw(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:Iw(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 lE(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(EE,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&eE(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(TE,{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(CE,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(DE,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(wE,{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(EE,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(wE,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new xE(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new iE(e.data),{documentName:n}=zw(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new iE(e.data)}),new bE(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&eE(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&&(eE(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 OE(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}};function AE(e,t,n=null,r=null){let i={...lc()};return e!==null&&(i.principalId=e.principalId,i.tabSessionId=e.tabSessionId),t!==null&&t.length>0&&(i.expectedServerInstanceId=t),n!==null&&n.length>0&&(i.expectedBranch=n),r!==null&&r.length>0&&(i.expectedDocLineageEpoch=r),JSON.stringify(i)}var jE=e=>zd((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),ME=(e,t)=>zd((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(dd(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),NE=e=>jE(indexedDB.deleteDatabase(e)),PE=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),FE=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>KE(r,e))},IE=(e,t)=>jE(e.count(t)),LE=(e,t)=>jE(e.get(t)),RE=(e,t)=>jE(e.delete(t)),zE=(e,t,n)=>jE(e.put(t,n)),BE=(e,t)=>jE(e.add(t)),VE=(e,t,n)=>jE(e.getAll(t,n)),HE=(e,t,n)=>{let r=null;return GE(e,t,e=>(r=e,!1),n).then(()=>r)},UE=(e,t=null)=>HE(e,t,`prev`),WE=(e,t)=>zd((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()}}),GE=(e,t,n,r=`next`)=>WE(e.openKeyCursor(t,r),e=>n(e.key)),KE=(e,t)=>e.objectStore(t),qE=(e,t)=>IDBKeyRange.upperBound(e,t),JE=(e,t)=>IDBKeyRange.lowerBound(e,t),YE=`custom`,XE=`updates`,ZE=(e,t=()=>{},n=()=>{})=>{let[r]=FE(e.db,[XE]);return VE(r,JE(e._dbref,!1)).then(i=>{e._destroyed||(t(r),qh(e.doc,()=>{i.forEach(t=>Jm(e.doc,t))},e,!1),n(r))}).then(()=>UE(r).then(t=>{e._dbref=t+1})).then(()=>IE(r).then(t=>{e._dbsize=t})).then(()=>r)},QE=(e,t=!0)=>ZE(e).then(n=>{(t||e._dbsize>=500)&&BE(n,Zm(e.doc)).then(()=>RE(n,qE(e._dbref,!0))).then(()=>IE(n).then(t=>{e._dbsize=t}))}),$E=class extends iu{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=ME(e,e=>PE(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=zd(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,ZE(this,async e=>{await IE(e)>0&&BE(e,Zm(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]=FE(this.db,[XE]);BE(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(()=>{QE(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(()=>{NE(this.name)})}get(e){return this._db.then(t=>{let[n]=FE(t,[YE],`readonly`);return LE(n,e)})}set(e,t){return this._db.then(n=>{let[r]=FE(n,[YE]);return zE(r,t,e)})}del(e){return this._db.then(t=>{let[n]=FE(t,[YE]);return RE(n,e)})}},eD=`updates`,tD=`custom`;function nD(){return!0}var rD=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=nD()?0:performance.now();this._idb=new $E(this._dbName,r),this.whenSynced=this._idb.whenSynced.then(()=>{if(!nD()){let e=performance.now();$(`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=nD()?0:performance.now();try{await this._idb.destroy()}finally{if(!nD()){let t=performance.now();$(`ok/pool/idb-destroy`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}async flushFullState(){this._idb.db===null&&await this.whenSynced;let e=this._idb.db;if(e===null)return;let t=this._idb;await new Promise((n,r)=>{let i=e.transaction(eD,`readwrite`),a=i.objectStore(eD),o=a.getAll();o.onerror=()=>r(o.error??Error(`flushFullState getAll failed`)),o.onsuccess=()=>{try{qh(t.doc,()=>{for(let e of o.result)Jm(t.doc,e)},t,!1);let e=a.add(Zm(t.doc));e.onerror=()=>r(e.error??Error(`flushFullState add failed`)),e.onsuccess=()=>{a.delete(IDBKeyRange.upperBound(e.result,!0))}}catch(e){r(e instanceof Error?e:Error(String(e)));try{i.abort()}catch{}}},i.oncomplete=()=>n(),i.onabort=()=>r(i.error??Error(`flushFullState transaction aborted`))})}async clearData(){let e=nD()?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(!nD()){let t=performance.now();$(`ok/pool/idb-cleardata`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}};function iD(e){return new rD(e)}async function aD(e){if(typeof indexedDB>`u`)return null;let t=`ok-ydoc:${e.branch}:${e.serverInstanceId}:${e.docName}`;if(typeof indexedDB.databases==`function`&&!(await indexedDB.databases()).some(e=>e.name===t))return null;let n=await new Promise((e,n)=>{let r=indexedDB.open(t);r.onupgradeneeded=()=>{let e=r.result;e.objectStoreNames.contains(eD)||e.createObjectStore(eD,{autoIncrement:!0}),e.objectStoreNames.contains(tD)||e.createObjectStore(tD)},r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)});try{if(!n.objectStoreNames.contains(eD))return null;let e=await new Promise((e,t)=>{let r=n.transaction(eD,`readonly`).objectStore(eD).getAll();r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)});if(e.length===0)return null;let t=new Mm;try{qh(t,()=>{for(let n of e)Jm(t,n)});let n=t.getMap(`lifecycle`).get(dt);return typeof n==`string`&&n.length>0?n:null}finally{t.destroy()}}finally{n.close()}}function oD(e){return rh(e)}function sD(e,t){return t===null?Zm(e):Zm(e,t)}function cD(e,t){if(e===null)return t;if(t===null)return e;let n=$m(e),r=$m(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 rh(i)}function lD(e){let t={};if(Un.inject(Hn.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 uD=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new pt({key:e||new N(`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))}}}),dD=kt.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[uD({key:new N(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}});function fD(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||!I.isSelectable(o))return!1;try{let t=I.create(n.doc,s);return e.view.dispatch(n.tr.setSelection(t).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return G(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L0`,reason:e.message.slice(0,500)})),!0}}function pD(e){let{state:t,view:n}=e;if(!(t.selection instanceof Ce)||!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=be.findFrom(n,-1,!0);return!r||!(r instanceof Ce)?!1:(e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return G(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2c`,reason:e.message.slice(0,500)})),!0}}function mD(e,t){let{state:n,view:r}=e;if(!(n.selection instanceof Ce)||!n.selection.empty||!r.endOfTextblock(t))return!1;let i=n.selection.$head,a=t===`down`||t===`right`,o=null,s=-1;if(a){let e=i.after();if(e>=n.doc.content.size)return!1;o=n.doc.nodeAt(e),s=e}else{let e=i.before();if(e<=0||(o=n.doc.resolve(e).nodeBefore,!o))return!1;s=e-o.nodeSize}if(!o||o.type.name!==`jsxComponent`||o.childCount===0)return!1;let c=s+o.nodeSize;try{let t=a?s+1:c-1,r=be.findFrom(n.doc.resolve(t),a?1:-1,!0);return!r||!(r instanceof Ce)||r.$head.pos<=s||r.$head.pos>=c?!1:(e.view.dispatch(n.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return G(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L2d`,reason:e.message.slice(0,500)})),!0}}var hD=kt.create({name:`keyboardNav`,priority:50,addKeyboardShortcuts(){return{Escape:({editor:e})=>{let{state:t}=e;if(t.selection instanceof I){let n=t.selection.from+t.selection.node.nodeSize,r=t.doc.resolve(Math.min(n,t.doc.content.size)),i=Ce.near(r);return e.view.dispatch(t.tr.setSelection(i)),!0}return t.selection instanceof Ce?e.commands.selectParentNode():!1},ArrowUp:({editor:e})=>{if(fD(e,`up`)||pD(e)||mD(e,`up`))return!0;let{state:t}=e;if(!(t.selection instanceof I))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=I.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 G(`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(fD(e,`down`)||mD(e,`down`))return!0;let{state:t}=e;if(!(t.selection instanceof I))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=I.create(t.doc,n);return e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return G(`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})=>fD(e,`left`)||mD(e,`left`),ArrowRight:({editor:e})=>fD(e,`right`)||mD(e,`right`),Enter:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof Ce)||!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(Ce.create(s.doc,f)),e.view.dispatch(s.scrollIntoView()),!0}}}}),gD={query:``,options:{caseSensitive:!1,wholeWord:!1},activeIndex:0,matches:[]},_D=/[A-Za-z0-9_]/;function vD(e){return e!==void 0&&_D.test(e)}function yD(e,t,n){return!vD(e[t-1])&&!vD(e[n])}function bD(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||yD(e,t,s))&&a.push({start:t,end:s,text:e.slice(t,s)}),o=s}return a}function xD(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 bD(e.text,t,n))r.push({from:i+a.start,to:i+a.end,text:a.text})}),r}var SD=new N(`findReplace`);function CD(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(Math.max(Math.trunc(e),0),t-1)}function wD(e,t,n,r){let i=xD(e.doc,t,n);return{query:t,options:n,activeIndex:CD(r,i.length),matches:i}}function TD(e,t,n){return t<=0?0:(CD(e,t)+n+t)%t}function ED(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 DD(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=xD(r.doc,t.query,t.options),a=CD(0,i.length),o=i[a];return r.setMeta(SD,{type:`setActiveIndex`,activeIndex:a}),o&&r.setSelection(Ce.create(r.doc,o.from,o.to)),r.scrollIntoView()}function OD(e,t){let n=SD.getState(e)?.matches[t];return n?e.tr.setMeta(SD,{type:`setActiveIndex`,activeIndex:t}).setSelection(Ce.create(e.doc,n.from,n.to)).scrollIntoView():null}function kD(e){return SD.getState(e)??gD}function AD(){return new pt({key:SD,state:{init:()=>gD,apply(e,t,n,r){let i=e.getMeta(SD);if(i?.type===`clear`)return gD;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:[]}:wD(r,a,o,s)}},props:{decorations(e){let t=SD.getState(e);return!t||t.matches.length===0?null:q.create(e.doc,t.matches.map((e,n)=>O.inline(e.from,e.to,{class:n===t.activeIndex?`ok-find-match ok-find-match-active`:`ok-find-match`})))}}})}var jD=kt.create({name:`findReplace`,addCommands(){return{setFindQuery:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(SD,{type:`setQuery`,query:e,options:t?.options,activeIndex:t?.activeIndex})),!0),setFindOptions:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(SD,{type:`setOptions`,options:e,activeIndex:t})),!0),setActiveFindIndex:e=>({state:t,dispatch:n})=>(n&&n(t.tr.setMeta(SD,{type:`setActiveIndex`,activeIndex:e})),!0),selectNextFindMatch:()=>({state:e,dispatch:t})=>{let n=kD(e),r=OD(e,TD(n.activeIndex,n.matches.length,1));return r?(t?.(r),!0):!1},selectPreviousFindMatch:()=>({state:e,dispatch:t})=>{let n=kD(e),r=OD(e,TD(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=xD(a.doc,r.query,r.options),s=ED(o,i.from,e.length),c=o[s];return a.setMeta(SD,{type:`setActiveIndex`,activeIndex:s}),c&&a.setSelection(Ce.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=DD(t,r,e);return i?(n(i),!0):!1},clearFindMatches:()=>({state:e,dispatch:t})=>(t&&t(e.tr.setMeta(SD,{type:`clear`})),!0)}},addProseMirrorPlugins(){return[AD()]}}),MD=new WeakMap;function ND(e,t){if(t===null){MD.delete(e);return}MD.set(e,t)}function PD(e){return MD.get(e)??null}function FD(e){return`pagesBySlug`in e}function ID(e){return FD(e)?e.pages:e}function LD(e,t){return FD(e)?e.assetPaths??new Set:t??new Set}function RD(e,t){return FD(e)?e.filePaths??new Set:t??new Set}function zD(e,t){let n=wt(e);if(n){if(FD(t))return t.pagesBySlug.get(n);for(let e of t)if(wt(e)===n)return e}}function BD(e,t){if(e.includes(`/`))return;let n=wt(e);if(!n)return;if(FD(t))return t.pagesByBasename?.get(n);let r;for(let e of t){let t=e.lastIndexOf(`/`);wt(t===-1?e:e.slice(t+1))===n&&(r===void 0||e.localeCompare(r)<0)&&(r=e)}return r}function VD(e){let t=e.trim();if(!t)return null;let n=wt(t);return n?{target:n,alias:n===t?null:t,anchor:null}:null}function HD(e){let t=e.trim();if(!t)return[];let n=wt(t);return n.length>0&&n!==t?[n]:[]}function UD(e,t){let n=e.trim();if(!n)return;let r=ID(t);if(r.has(n))return n;let i=zD(n,t);if(i)return i;for(let e of HD(n))if(r.has(e))return e;return WD(n,r)||BD(n,t)}function WD(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 GD(e){let t=((e.trim().split(`#`)[0]??``).trim().split(`?`)[0]??``).trim();return t.startsWith(`/`)?t.slice(1):t}function KD(e,t,n){let r=GD(e);if(!r)return null;let i=r.toLowerCase(),a=n?[t,n]:[t];for(let e of a){if(e.has(r))return r;for(let t of e)if(t.toLowerCase()===i)return t}if(r.includes(`/`))return null;let o=[];for(let e of a)for(let t of e){let e=t.lastIndexOf(`/`);(e===-1?t:t.slice(e+1)).toLowerCase()===i&&o.push(t)}return o.length===0?null:o.sort((e,t)=>e.localeCompare(t))[0]??null}function qD(e,t,n,r){let i=e.trim();if(!i)return!1;if(KD(i,LD(t,n),RD(t,r)))return!0;let a=ID(t);return a.has(i)||HD(i).some(e=>a.has(e))||zD(i,t)!==void 0||WD(i,a)?!0:BD(i,t)!==void 0}var JD=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}},YD=new N(`imageUpload`);function XD(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?Rn._({id:`KDuPiY`,values:{fileName:n}}):Rn._({id:`bGa3Fk`})),t}var ZD=new pt({key:YD,state:{init(){return{decorations:q.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(YD);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=O.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 YD.getState(e)?.decorations??q.empty}}});function QD(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function $D(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function eO(e){return e.split(`/`).filter(e=>e!==``)}function tO(e,t){let n=QD(e),r=QD(t),i=$D(e);if(n===r)return i;let a=eO(r),o=eO(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 nO(e){return PD(e)}function rO(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 iO(e){let t=Ae(e);return t===`md`||t===`mdx`?{kind:`wiki-link`,ext:t}:se.has(t)?{kind:`jsx-img`,ext:t}:K.has(t)?{kind:`jsx-video`,ext:t}:Ee.has(t)?{kind:`jsx-audio`,ext:t}:ee.has(t)?{kind:`jsx-file`,ext:t}:b.has(t)?{kind:`wikiembed`,ext:t}:{kind:`markdown-link`,ext:t}}async function aO(e,t,n){let r=nO(t),i=r?`${r}.md`:``;if(!i){zn.error(Rn._({id:`z5pqI8`}));return}let a=crypto.randomUUID(),o=XD(e);t.view.dispatch(t.state.tr.setMeta(YD,{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),oO(t,a);return}let l;try{l=await c.json()}catch(e){console.error(`[uploadAndInsert] Response is not JSON:`,e),oO(t,a);return}if(!c.ok){let e=De.safeParse(l);if(!e.success){let n=new JD(`Upload response did not match ProblemDetails.`,{cause:e.error,status:c.status});console.error(`[uploadAndInsert] Server error (unparseable):`,n),oO(t,a);return}console.error(`[uploadAndInsert] Server error:`,e.data),oO(t,a,e.data.title);return}let u=At.safeParse(l);if(!u.success){let e=new JD(`Upload success response did not match UploadAssetSuccess.`,{cause:u.error,status:c.status});console.error(`[uploadAndInsert] Response missing src:`,e),oO(t,a);return}let d=u.data,f=d.src,p=d.deduped===!0,m=QD(i),h=typeof d.path==`string`&&d.path.length>0?d.path:m?`${m}/${f}`:f;p&&zn.info(Rn._({id:`VbqhBI`,values:{assetContentPath:h}}));let g=iO(e.name),{state:_}=t,v=YD.getState(_)?.uploads.get(a)??n,y=_.tr.setMeta(YD,{type:`remove`,id:a}),b=tO(h,i),x=`/${h}`;if(g.kind===`jsx-file`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),oO(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:ze(e.size)}}};t.chain().command(({tr:e})=>(e.setMeta(YD,{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(I.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`),oO(t,a);return}let e=rO(g.kind,x);t.chain().command(({tr:e})=>(e.setMeta(YD,{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(I.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`),oO(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`),oO(t,a);return}let r=VD(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 oO(e,t,n){e.view.dispatch(e.state.tr.setMeta(YD,{type:`remove`,id:t})),zn.error(n??Rn._({id:`b3Thhd`}))}var sO=new Set;function cO(e){sO.add(e)}function lO(e){return sO.delete(e)}var uO=new N(`markIdentity`);function dO(){return{byId:new Map,counter:0}}function fO(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&&pO(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 pO(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&&pO(n,i)))return!1}return!0}function mO(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 hO(e){let{markTypes:t,predicate:n,onRegister:r,onDeregister:i}=e,a=new Set(t);return new pt({key:uO,state:{init(e,t){return fO(t.doc,dO(),a,n)},apply(e,t,r,i){return e.docChanged?fO(i.doc,t,a,n,e.mapping):t}},view(){let e=new Set;return{update(t){let n=uO.getState(t.state);n&&(e=mO(e,n,r,i))},destroy(){for(let t of e)i?.(t);e=new Set}}}})}var gO=300,_O=150,vO=500,yO=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 bO(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 xO(e){return e?e.closest(`[data-ok-prop-panel]`)!==null:!1}function SO(){return typeof document>`u`?!1:document.querySelector(`[data-ok-layer-spawned]`)!==null}var CO=e=>{let t=(0,Z.c)(18),{store:n}=e,r;t[0]===n?r=t[1]:(r=()=>n.getSnapshot(),t[0]=n,t[1]=r);let[i,a]=(0,Q.useState)(r),o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>(a(n.getSnapshot()),n.subscribe(()=>{a(n.getSnapshot())})),s=[n],t[2]=n,t[3]=o,t[4]=s),(0,Q.useEffect)(o,s);let{active:c}=i;if(!c)return null;let l;t[5]===n?l=t[6]:(l=()=>n.setActiveNode(null),t[5]=n,t[6]=l);let u,d,f;if(t[7]!==c.controls||t[8]!==c.nodeId||t[9]!==c.type||t[10]!==l){let e={nodeId:c.nodeId,type:c.type,deactivate:l};u=c.controls.propPanel?.(e),d=c.controls.toolbar?.(e),f=c.controls.breadcrumb?.(e),t[7]=c.controls,t[8]=c.nodeId,t[9]=c.type,t[10]=l,t[11]=u,t[12]=d,t[13]=f}else u=t[11],d=t[12],f=t[13];let p;return t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,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 wO(e){return e.editorView?.dom??null}function TO(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 EO(e){let{editor:t}=e,n=new yO,r=wO(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)},gO))},m=()=>{n.getActiveNode()!==null&&o===null&&(o=setTimeout(()=>{o=null,!SO()&&n.setActiveNode(null)},_O))},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&&TO(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??wO(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=bO(e.target,n);if(t===null)return;f(),c=setTimeout(()=>{c=null,l=t,n.setActiveNode(t)},vO);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=bO(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=bO(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=bO(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(xO(r)){d();return}let i=bO(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=bO(r,n);if(o!==null){if(a&&xO(a)){d();return}if(a&&bO(a,n)===o)return;s===o&&u(),m();return}if(xO(r)){if(a&&xO(a))return;let e=n.getActiveNode();if(e!==null&&a&&bO(a,n)===e)return;m()}},E=e=>{if(g)return;let t=e.target;if(!(t instanceof Element))return;let r=bO(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&&xO(i)||i&&bO(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=wO(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 DO=e=>{let t=(0,Z.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)(CO,{store:n})}),t[0]=n,t[1]=r),r},OO=new WeakMap;function kO(e){let t=OO.get(e);if(t)return t;let n=EO({editor:e});return OO.set(e,n),e.on(`destroy`,()=>{n.destroy(),OO.delete(e)}),n}var AO={AppWindow:_i,ChevronRight:gn,CopyPlus:Mi,FileText:zi,Film:Hi,GitBranch:Gi,Image:Xi,LayoutPanelTop:Qi,MessageSquareWarning:sa,PanelTop:da,Paperclip:fa,Sigma:ba,SquarePlay:Sa,Volume2:Da,Workflow:Oa,ZoomIn:Aa};function jO(e){return e&&Object.hasOwn(AO,e)?AO[e]:xi}var MO={Info:pn,Lightbulb:$i,MessageSquareWarning:sa,AlertTriangle:bn,AlertOctagon:la,ClipboardList:ki,BookOpen:bi,ListTodo:ia,CircleCheck:Sn,CircleHelp:Di,CircleX:Oi,Zap:ka,Bug:Si,FlaskConical:Ui,Quote:ha,ChevronRight:gn},NO=Object.entries(MO).sort(([e],[t])=>e.localeCompare(t));function PO(e){if(!e||!e.startsWith(`lucide:`))return null;let t=e.slice(7);return Object.hasOwn(MO,t)?MO[t]??null:null}function FO(e){let t=(0,Z.c)(24),n;t[0]===e.icon?n=t[1]:(n=PO(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)(gn,{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 IO(e){return e!==!1}function LO(e){let t=(0,Z.c)(12),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:et(e.src),t[0]=e.src,t[1]=n);let r=e.title,i;t[2]===e.controls?i=t[3]:(i=IO(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 RO={note:pn,tip:$i,important:sa,warning:bn,caution:la,abstract:ki,info:bi,todo:ia,success:Sn,question:Di,failure:Oi,danger:ka,bug:Si,example:Ui,quote:ha};function zO(e,t){return PO(e)??RO[t]}var BO=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]);function VO(e){return typeof e==`string`&&BO.has(e)?e:`note`}function HO(e){let t=(0,Z.c)(29),n,r;t[0]!==e.icon||t[1]!==e.type?(r=VO(e.type),n=zO(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)(wi,{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 UO=(0,Q.createContext)(null);function WO(e){let t=(0,Z.c)(3),{value:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,X.jsx)(UO.Provider,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function GO(){return(0,Q.use)(UO)}var KO=[{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 qO(e){let t=(0,Z.c)(7),{targetRef:n,onResize:r,onResizeEnd:a,bounds:o}=e,{_:s}=i(),c=(0,Q.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=KO.map(e=>{let t=e.key;return(0,X.jsx)(`button`,{type:`button`,className:Ut(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 JO=`26rem`,YO=`Embedded content`,XO=/^https?:\/\//i;function ZO(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function QO(e){return!(typeof e!=`string`||!XO.test(e)||!ZO(e))}function $O(e){let t=(0,Z.c)(24),{src:n,title:r,width:i,height:a}=e,o=(0,Q.useRef)(null),s=GO(),c=i||void 0,l=a||JO,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||JO)},p=[i,a],t[3]=a,t[4]=i,t[5]=f,t[6]=p):(f=t[5],p=t[6]),(0,Q.useEffect)(f,p),!QO(n)){let e=`Embed a URL`;typeof n==`string`&&n.length>0&&(e=XO.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;t[11]===n?g=t[12]:(g=We(n),t[11]=n,t[12]=g);let _=g,v=_===n?`no-referrer`:`strict-origin-when-cross-origin`,y=r||YO,b;t[13]!==_||t[14]!==v||t[15]!==y?(b=(0,X.jsx)(`iframe`,{title:y,src:_,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation`,referrerPolicy:v,loading:`lazy`,className:`ok-embed-frame`}),t[13]=_,t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;t[17]!==s||t[18]!==h?(x=s?(0,X.jsx)(qO,{targetRef:o,bounds:{minWidth:192,maxWidth:2e3,minHeight:128,maxHeight:Math.round(window.innerHeight*.9)},onResize:e=>{let t=o.current;t&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)},onResizeEnd:h}):null,t[17]=s,t[18]=h,t[19]=x):x=t[19];let S;return t[20]!==d||t[21]!==x||t[22]!==b?(S=(0,X.jsxs)(`div`,{className:`ok-embed`,style:d,ref:o,contentEditable:!1,children:[b,x]}),t[20]=d,t[21]=x,t[22]=b,t[23]=S):S=t[23],S}function ek(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 tk(e){let t=(0,Z.c)(18),n;t[0]!==e.name||t[1]!==e.src?(n=e.name?.trim()||ek(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?et(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)(Bi,{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:nk,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 nk(e){return e.stopPropagation()}function rk(){return Q.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-unzoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Q.createElement(`path`,{d:`M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z`}))}function ik(){return Q.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-zoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Q.createElement(`path`,{d:`M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z`}))}function ak(e){return typeof Element>`u`?!1:e instanceof Element}var ok=(e,t)=>ak(t)&&t.tagName.toUpperCase()===e,sk=e=>ok(`DIV`,e)||ok(`SPAN`,e),ck=e=>ok(`IMG`,e),lk=e=>e.complete&&e.naturalHeight!==0,uk=e=>ok(`SVG`,e),dk=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),fk=({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},pk=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:i,targetWidth:a})=>e===0||t===0?1:!n&&i!==0&&a!==0?fk({containerHeight:e,containerWidth:t,offset:r,targetHeight:i,targetWidth:a}):dk({height:e,offset:r,width:t}),mk=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,hk=e=>{if(e!==null){if(ck(e))return e.currentSrc===``?void 0:e.currentSrc;if(sk(e)){let{backgroundImage:t}=window.getComputedStyle(e);if(t!==``)return mk.exec(t)?.[1]}}},gk=e=>{if(e!==null)return ck(e)?e.alt:e.getAttribute(`aria-label`)??void 0},_k=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s})=>{let c=pk({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})`}},vk=({position:e,relativeNum:t})=>{let n=parseFloat(e);return e.endsWith(`%`)?t*n/100:n},yk=({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=vk({position:p,relativeNum:r-l*f}),g=vk({position:m,relativeNum:e-c*f}),_=pk({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=vk({position:a,relativeNum:r-l}),f=vk({position:u,relativeNum:e-c}),p=pk({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=pk({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{}},bk=({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=vk({position:p,relativeNum:a-l*f}),g=vk({position:m,relativeNum:n-c*f}),_=pk({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=vk({position:t,relativeNum:a-l}),f=vk({position:u,relativeNum:n-c}),p=pk({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=vk({position:u,relativeNum:a}),p=vk({position:d,relativeNum:n}),m=f/l,h=p/c,g=Math.min(m,h),[_=`50%`,v=`50%`]=e.split(` `),y=vk({position:_,relativeNum:a-l*g}),b=vk({position:v,relativeNum:n-c*g}),x=pk({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})`}}},xk=/\.svg$/i,Sk=({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&&xk.test(t),l=s.getBoundingClientRect(),u=window.getComputedStyle(s),d=i!=null&&sk(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=_k({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}),g=f?yk({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?bk({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},Ck=e=>{if(e==null)return{};if(uk(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}},wk=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}`)}})})},Tk=[`img`,`svg`,`[role="img"]`,`[data-zoom]`].map(e=>`${e}:not([aria-hidden="true"])`).join(`,`),Ek={overflow:``,width:``};function Dk(){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 Ok(e){e.preventDefault()}function kk(e){return Q.createElement(Ak,{...e})}var Ak=class extends Q.Component{constructor(){super(...arguments),this.state={id:``,isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:`UNLOADED`,shouldRefresh:!1,styleGhost:{}},this.refContent=Q.createRef(),this.refDialog=Q.createRef(),this.refModalContent=Q.createRef(),this.refModalImg=Q.createRef(),this.refWrap=Q.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=Ek,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(Tk),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:Ck(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver??(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:Ck(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=hk(this.imgEl);if(e==null||e===``)return;let t=new Image,{imgEl:n}=this;if(ck(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:Ck(this.imgEl)})};t.decode().then(r).catch(()=>{if(lk(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||uk(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=Ek},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(lk(n)){r();return}n.onload=r})}},this.UNSAFE_handleSvg=()=>{let{imgEl:e,refModalImg:t,styleModalImg:n}=this;if(uk(e)){let r=e.cloneNode(!0);wk(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=sk(a),j=ck(a),M=uk(a),N=gk(a),P=hk(a),F=j?a.sizes:void 0,I=j?a.srcset:void 0,L=j?a.crossOrigin:void 0,R=h?.src!==void 0&&h.src!==``,z=this.hasImage(),B=N!==void 0&&N!==``?`${s}: ${N}`:s,ee=T===`LOADING`||T===`LOADED`,V=z?`found`:`not-found`,te=T===`UNLOADED`||T===`UNLOADING`?`hidden`:`visible`,H={visibility:T===`UNLOADED`?`visible`:`hidden`};this.styleModalImg=z&&a!==null?Sk({hasZoomImg:R,imgSrc:P,isSvg:M,isZoomed:f&&ee,loadedImgEl:w,offset:g,shouldRefresh:E,targetEl:a}):{};let U=null;if(z){let t=j||A?Q.createElement(`img`,{alt:N,crossOrigin:L,sizes:F,src:P,srcSet:I,...C&&T===`LOADED`?h:{},"data-rmiz-modal-img":``,height:this.styleModalImg.height??void 0,id:k,ref:b,style:this.styleModalImg,width:this.styleModalImg.width??void 0}):M?Q.createElement(`div`,{"data-rmiz-modal-img":!0,ref:b,style:this.styleModalImg}):null,n=Q.createElement(`button`,{"aria-label":o,"data-rmiz-btn-unzoom":``,onClick:e,type:`button`},Q.createElement(u,null));U=m==null?Q.createElement(Q.Fragment,null,t,n):Q.createElement(m,{buttonUnzoom:n,modalState:T,img:t,isZoomImgLoaded:C,onUnzoom:r})}return Q.createElement(p,{"aria-owns":z?O:void 0,"data-rmiz":``,ref:x},Q.createElement(p,{"data-rmiz-content":V,ref:_,style:H},c),z&&Q.createElement(p,{"data-rmiz-ghost":``,style:D},Q.createElement(`button`,{"aria-label":B,"data-rmiz-btn-zoom":``,onClick:i,type:`button`},Q.createElement(d,null))),z&&Ma.createPortal(Q.createElement(`dialog`,{"aria-labelledby":k,"aria-modal":`true`,className:l,"data-rmiz-modal":``,id:O,onClick:t,onClose:n,onCancel:Ok,ref:v,role:`dialog`},Q.createElement(`div`,{"data-rmiz-modal-overlay":te}),Q.createElement(`div`,{"data-rmiz-modal-content":``,ref:y},U)),Dk()))}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)}};Ak.defaultProps={a11yNameButtonUnzoom:`Minimize image`,a11yNameButtonZoom:`Expand image`,canSwipeToUnzoom:!0,IconUnzoom:rk,IconZoom:ik,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:`div`,zoomMargin:0};function jk({onZoomChange:e,...t}){let[n,r]=Q.useState(!1),i=Q.useCallback((t,{event:n})=>{r(t),e?.(t,{event:n})},[e]);return Q.createElement(kk,{...t,isZoomed:n,onZoomChange:i})}function Mk(e,t){return typeof e==`number`&&typeof t==`number`&&e>0&&t>0}function Nk(e,t,n){return Mk(e,t)?{...n,width:`${e}px`,aspectRatio:`${e} / ${t}`}:n}function Pk(e){let t=(0,Z.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,Q.useRef)(null),[b,x]=(0,Q.useState)(!1),S;t[13]!==r||t[14]!==m?(S=Mk(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=Nk(m,r,u),t[16]=r,t[17]=u,t[18]=m,t[19]=w):w=t[19];let T=w,E;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{y.current?.complete?x(!0):x(!1)},t[20]=E):E=t[20];let D;t[21]===l?D=t[22]:(D=[l],t[21]=l,t[22]=D),(0,Q.useLayoutEffect)(E,D);let O=!C&&!b&&`aspect-[16/9] w-full max-w-full`,k;t[23]!==c||t[24]!==O?(k=Ut(`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=Ut(`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 Fk(e){return e??`lazy`}function Ik(e){if(typeof e!=`string`)return e;let t=Number(e);return Number.isFinite(t)&&t>0?t:e}function Lk(e){let t=(0,Z.c)(21),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:et(e.src),t[0]=e.src,t[1]=n);let r=e.alt??``,i;t[2]===e.width?i=t[3]:(i=Ik(e.width),t[2]=e.width,t[3]=i);let a;t[4]===e.height?a=t[5]:(a=Ik(e.height),t[4]=e.height,t[5]=a);let o=e.title,s;t[6]===e.loading?s=t[7]:(s=Fk(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)(Pk,{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 Rk(e){let t=(0,Z.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)(jk,{wrapElement:`span`,zoomMargin:20,zoomImg:n,children:(0,X.jsx)(Lk,{...e})}),t[1]=e,t[2]=r),r}var zk=(0,Q.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-DBuiuHex.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,Z.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 Bk(e){let t=(0,Z.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 Vk(e){let t=(0,Z.c)(6),n=e.formula??``;if(!n){let r;return t[0]!==n||t[1]!==e.id?(r=(0,X.jsx)(Bk,{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)(Q.Suspense,{fallback:(0,X.jsx)(Bk,{formula:n,id:e.id}),children:(0,X.jsx)(zk,{formula:n,id:e.id})}),t[3]=n,t[4]=e.id,t[5]=r):r=t[5],r}var Hk=null;function Uk(){return Hk||=n(()=>import(`./mermaid.core-srYvzXpO.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 Hk=null,e}),Hk}function Wk(e){let t=(0,Z.c)(24),n=e.chart??``,r=(0,Q.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,Q.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(Gk),Uk().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,Q.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)(bn,{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 Gk(e){return{...e,status:`rendering`}}var Kk=null;function qk(){return Kk||=new ge({extensions:yt}),Kk}function Jk(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=Jk(e,t);if(n)return n}return null}function Yk(e){return ce({type:`root`,children:e.children??[]})}var Xk=new Map,Zk=30,Qk=150,$k=1e4;function eA(e,t){let n=`${e}|${t}`,r=Xk.get(n);if(r)return r.refcount+=1,r;let i=new Mm,a=new kE({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()}),Xk.set(n,s),Xk.size>Zk&&console.warn(`[Mirror] provider pool exceeded ${Zk} entries (current=${Xk.size}). Many Mirrors pointing at distinct source docs — investigate if this is a runaway pattern.`),s}function tA(e,t){let n=`${e}|${t}`,r=Xk.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})}Xk.delete(n)}}function nA(e,t){let n=(0,Z.c)(8),{collabUrl:r}=Mx(),i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={kind:`loading`},n[0]=i):i=n[0];let[a,o]=(0,Q.useState)(i),s=(0,Q.useRef)(t),c=(0,Q.useRef)(null),l,u;n[1]!==r||n[2]!==e?(l=()=>{if(!e){o({kind:`empty-props`});return}if(!r){o({kind:`loading`});return}let t=eA(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=qk().parseToMdast(r)}catch(t){console.warn(`[Mirror] parseToMdast failed`,{src:e,anchor:n,err:t}),o({kind:`source-removed`});return}let a=Jk(i,n);if(!a){o({kind:`anchor-not-found`});return}let c;try{c=Yk(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()},Qk)},onSynced:()=>{i&&=(clearTimeout(i),null),n()}};t.subscribers.add(a),c.current=n;let l=setTimeout(()=>{t.synced||o({kind:`source-removed`})},$k);return n(),()=>{clearTimeout(l),i&&clearTimeout(i),t.subscribers.delete(a),c.current=null,tA(r,e)}},u=[r,e],n[1]=r,n[2]=e,n[3]=l,n[4]=u):(l=n[3],u=n[4]),(0,Q.useEffect)(l,u);let d,f;return n[5]===t?(d=n[6],f=n[7]):(d=()=>{s.current=t,c.current?.()},f=[t],n[5]=t,n[6]=d,n[7]=f),(0,Q.useEffect)(d,f),a}function rA(e){let t=(0,Z.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)(ea,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}):(0,X.jsx)(na,{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 iA(e){let t=(0,Z.c)(30),n=e.src??``,r=e.anchor??``,i=nA(n,r);if(i.kind===`empty-props`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(rA,{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)(rA,{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)(rA,{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)(rA,{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)(Ni,{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 aA(e){let t=(0,Z.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)(Mi,{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 oA=24,sA=24,cA=12,lA=.1;function uA(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(lA,(n-oA)/t.naturalWidth);case`fit-height`:return Math.max(lA,(r-sA)/t.naturalHeight);case`single`:return 1;case`two-odd`:case`two-even`:return Math.max(lA,((n-oA)/2-cA)/t.naturalWidth)}}var dA=600,fA=.5,pA=3,mA=.25,hA=null;function gA(){return hA||(hA=(async()=>{let e=await n(()=>import(`./pdf-CQwfdc8y.js`),__vite__mapDeps([24,1]),import.meta.url);if(!e.GlobalWorkerOptions.workerSrc){let t=(await n(async()=>{let{default:e}=await import(`./pdf.worker-aWVFMfr5.js`);return{default:e}},[],import.meta.url)).default;e.GlobalWorkerOptions.workerSrc=t}return e})(),hA.catch(()=>{hA=null})),hA}function _A(e){return e instanceof Error&&e.name===`RenderingCancelledException`}function vA(e){let t=(0,Z.c)(96),n,r;if(t[0]!==e.anchor||t[1]!==e.fillContainer){let{height:i,viewerFragment:a}=Se(e.anchor);n=i===null?e.fillContainer?`100%`:`${dA}px`:`${i}px`,r=wA(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,Q.useRef)(null),c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[4]=c):c=t[4];let l=(0,Q.useRef)(c),u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[5]=u):u=t[5];let d=(0,Q.useRef)(u),f=(0,Q.useRef)(null),p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[6]=p):p=t[6];let[m,h]=(0,Q.useState)(p),[g,_]=(0,Q.useState)(!0),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(a??1),[S,C]=(0,Q.useState)(String(a??1)),[w,T]=(0,Q.useState)(1),[E,D]=(0,Q.useState)(`fit-width`),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(0),[P,F]=(0,Q.useState)(0),{_:I}=i(),L=m.length,R,z;t[7]!==I||t[8]!==e.src?(R=()=>{if(!e.src){_(!1);return}let t=et(e.src),n=!1,r=null;return _(!0),y(null),(async()=>{try{let e=await(await gA()).getDocument({url:t,isEvalSupported:!1}).promise;if(n){await e.destroy();return}r=e,f.current=e;let i=[];for(let t=1;t<=e.numPages;t++){if(n)return;let r=(await e.getPage(t)).getViewport({scale:1});i.push({pageNumber:t,naturalWidth:r.width,naturalHeight:r.height})}if(n)return;h(i)}catch(e){let t=e;if(n)return;y(t instanceof Error?t.message:I({id:`jRHdCz`})),_(!1)}})(),()=>{n=!0,r&&=(r.destroy(),null),f.current=null}},z=[e.src,I],t[7]=I,t[8]=e.src,t[9]=R,t[10]=z):(R=t[9],z=t[10]),(0,Q.useEffect)(R,z);let B,ee;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{let e=s.current;if(!e)return;let t=()=>{N(e.clientWidth),F(e.clientHeight)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},ee=[],t[11]=B,t[12]=ee):(B=t[11],ee=t[12]),(0,Q.useEffect)(B,ee);let V,te;t[13]!==I||t[14]!==P||t[15]!==M||t[16]!==E||t[17]!==m||t[18]!==w?(V=()=>{let e=f.current;if(!e||m.length===0||M===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of m){if(t)return;let a=l.current[i.pageNumber-1];if(!a)continue;let o=uA(E,i,M,P)*w,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let u=a.getContext(`2d`);u&&(u.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:u,viewport:c}),await n.promise,n=null)}t||_(!1)}catch(e){let n=e;if(t||_A(n))return;console.warn(`[Pdf] page render failed:`,n),y(n instanceof Error?n.message:I({id:`_TF8ep`})),_(!1)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},te=[m,E,w,M,P,I],t[13]=I,t[14]=P,t[15]=M,t[16]=E,t[17]=m,t[18]=w,t[19]=V,t[20]=te):(V=t[19],te=t[20]),(0,Q.useEffect)(V,te);let H,U;t[21]!==m||t[22]!==O?(H=()=>{if(!O)return;let e=f.current;if(!e||m.length===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of m){if(t)return;let a=d.current[i.pageNumber-1];if(!a)continue;let o=120/i.naturalWidth,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let l=a.getContext(`2d`);l&&(l.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:l,viewport:c}),await n.promise,n=null)}}catch(e){let t=e;_A(t)||console.warn(`[Pdf] thumbnail render failed:`,t)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},U=[O,m],t[21]=m,t[22]=O,t[23]=H,t[24]=U):(H=t[23],U=t[24]),(0,Q.useEffect)(H,U);let ne,W;t[25]!==g||t[26]!==a?(ne=()=>{if(g||!a)return;let e=s.current,t=l.current[a-1];e&&t&&(e.scrollTop=t.offsetTop-e.offsetTop)},W=[g,a],t[25]=g,t[26]=a,t[27]=ne,t[28]=W):(ne=t[27],W=t[28]),(0,Q.useEffect)(ne,W);let re,G;t[29]===m?(re=t[30],G=t[31]):(re=()=>{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)}x(r),C(String(r))}))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},G=[m],t[29]=m,t[30]=re,t[31]=G),(0,Q.useEffect)(re,G);let ie,ae;t[32]===A?(ie=t[33],ae=t[34]):(ie=()=>{if(!A)return;let e=e=>{let t=e.target,n=s.current?.closest(`.ok-pdf`);if(!n||!t||!n.contains(t)){j(!1);return}let r=n.querySelector(`.ok-pdf-layout-menu`);r&&!r.contains(t)&&j(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},ae=[A],t[32]=A,t[33]=ie,t[34]=ae),(0,Q.useEffect)(ie,ae);let oe;t[35]===L?oe=t[36]:(oe=e=>{let t=Math.max(1,Math.min(L||1,e));x(t),C(String(t));let n=s.current,r=l.current[t-1];n&&r&&n.scrollTo({top:r.offsetTop-n.offsetTop,behavior:`smooth`})},t[35]=L,t[36]=oe);let K=oe,se;t[37]!==b||t[38]!==K||t[39]!==S?(se=()=>{let e=Number.parseInt(S,10);if(Number.isNaN(e)){C(String(b));return}K(e)},t[37]=b,t[38]=K,t[39]=S,t[40]=se):se=t[40];let ce=se,q;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(q=()=>T(SA),t[41]=q):q=t[41];let le=q,ue;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>T(xA),t[42]=ue):ue=t[42];let de=ue,fe;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>{D(e),j(!1),T(1)},t[43]=fe):fe=t[43];let pe=fe,me;t[44]===n?me=t[45]:(me={height:n},t[44]=n,t[45]=me);let he;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(he=()=>k(bA),t[46]=he):he=t[46];let ge;t[47]!==I||t[48]!==O?(ge=I(O?{id:`JK-Ave`}:{id:`iEYxO4`}),t[47]=I,t[48]=O,t[49]=ge):ge=t[49];let _e;t[50]===I?_e=t[51]:(_e=I({id:`zo3Dl7`}),t[50]=I,t[51]=_e);let ve;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,X.jsx)(ua,{size:14,"aria-hidden":`true`}),t[52]=ve):ve=t[52];let ye;t[53]!==O||t[54]!==ge||t[55]!==_e?(ye=(0,X.jsx)(`button`,{type:`button`,onClick:he,"aria-label":ge,"aria-pressed":O,className:`ok-pdf-btn`,title:_e,children:ve}),t[53]=O,t[54]=ge,t[55]=_e,t[56]=ye):ye=t[56];let be=e.title??`PDF`,xe;t[57]===be?xe=t[58]:(xe=(0,X.jsx)(`span`,{className:`ok-pdf-title`,children:be}),t[57]=be,t[58]=xe);let Ce;t[59]!==I||t[60]!==A||t[61]!==E||t[62]!==S||t[63]!==ce||t[64]!==L||t[65]!==w?(Ce=L>0&&(0,X.jsxs)(`div`,{className:`ok-pdf-controls`,children:[(0,X.jsx)(`form`,{className:`ok-pdf-page-form`,onSubmit:e=>{e.preventDefault(),ce()},children:(0,X.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,className:`ok-pdf-page-input`,value:S,onChange:e=>C(e.target.value.replace(/[^0-9]/g,``)),onBlur:ce,"aria-label":I({id:`xsZhu-`})})}),(0,X.jsx)(`span`,{className:`ok-pdf-page-of`,children:(0,X.jsx)(o,{id:`1GhYxC`,values:{totalPages:L}})}),(0,X.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{type:`button`,onClick:de,disabled:w<=fA,"aria-label":I({id:`FjkaiT`}),className:`ok-pdf-btn`,title:I({id:`FjkaiT`}),children:(0,X.jsx)(ja,{size:14,"aria-hidden":`true`})}),(0,X.jsxs)(`span`,{className:`ok-pdf-zoom-display`,"aria-live":`polite`,children:[Math.round(w*100),`%`]}),(0,X.jsx)(`button`,{type:`button`,onClick:le,disabled:w>=pA,"aria-label":I({id:`AWOSPo`}),className:`ok-pdf-btn`,title:I({id:`AWOSPo`}),children:(0,X.jsx)(Aa,{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:()=>j(yA),"aria-label":I({id:`GQDSBN`}),"aria-haspopup":`menu`,"aria-expanded":A,className:`ok-pdf-btn`,title:I({id:`rdU729`}),children:(0,X.jsx)(wi,{size:14,"aria-hidden":`true`})}),A&&(0,X.jsxs)(`div`,{role:`menu`,className:`ok-pdf-menu`,children:[(0,X.jsx)(CA,{label:I({id:`vIxrEk`}),active:E===`fit-width`,onSelect:()=>pe(`fit-width`)}),(0,X.jsx)(CA,{label:I({id:`YlDuro`}),active:E===`fit-height`,onSelect:()=>pe(`fit-height`)}),(0,X.jsx)(`hr`,{className:`ok-pdf-menu-divider`}),(0,X.jsx)(CA,{label:I({id:`BGHHtQ`}),active:E===`single`,onSelect:()=>pe(`single`)}),(0,X.jsx)(CA,{label:I({id:`xK291b`}),active:E===`two-odd`,onSelect:()=>pe(`two-odd`)}),(0,X.jsx)(CA,{label:I({id:`NSnIUP`}),active:E===`two-even`,onSelect:()=>pe(`two-even`)})]})]})]}),t[59]=I,t[60]=A,t[61]=E,t[62]=S,t[63]=ce,t[64]=L,t[65]=w,t[66]=Ce):Ce=t[66];let we;t[67]!==ye||t[68]!==xe||t[69]!==Ce?(we=(0,X.jsxs)(`div`,{className:`ok-pdf-toolbar`,contentEditable:!1,children:[ye,xe,Ce]}),t[67]=ye,t[68]=xe,t[69]=Ce,t[70]=we):we=t[70];let Te;t[71]!==I||t[72]!==b||t[73]!==K||t[74]!==m||t[75]!==O?(Te=O&&(0,X.jsx)(`aside`,{className:`ok-pdf-sidebar`,"aria-label":I({id:`nzaV6Q`}),children:m.map((e,t)=>{let{pageNumber:n}=e;return(0,X.jsxs)(`button`,{type:`button`,className:`ok-pdf-thumb`,"data-active":b===n||void 0,onClick:()=>K(n),"aria-label":I({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]=I,t[72]=b,t[73]=K,t[74]=m,t[75]=O,t[76]=Te):Te=t[76];let Ee;t[77]===g?Ee=t[78]:(Ee=g&&(0,X.jsx)(`div`,{className:`ok-pdf-loading`,children:(0,X.jsx)(o,{id:`T-654M`})}),t[77]=g,t[78]=Ee);let De;t[79]===v?De=t[80]:(De=v&&(0,X.jsx)(`div`,{className:`ok-pdf-error`,children:(0,X.jsx)(o,{id:`WamGNs`,values:{error:v}})}),t[79]=v,t[80]=De);let Oe;t[81]!==I||t[82]!==L?(Oe=Array.from({length:L},(e,t)=>{let n=t+1;return(0,X.jsx)(`canvas`,{ref:e=>{l.current[t]=e},className:`ok-pdf-page`,"aria-label":I({id:`XtRoxT`,values:{pageNumber:n}})},n)}),t[81]=I,t[82]=L,t[83]=Oe):Oe=t[83];let ke;t[84]!==E||t[85]!==Ee||t[86]!==De||t[87]!==Oe?(ke=(0,X.jsxs)(`div`,{className:`ok-pdf-pages`,ref:s,"data-layout":E,children:[Ee,De,Oe]}),t[84]=E,t[85]=Ee,t[86]=De,t[87]=Oe,t[88]=ke):ke=t[88];let Ae;t[89]!==Te||t[90]!==ke?(Ae=(0,X.jsxs)(`div`,{className:`ok-pdf-body`,children:[Te,ke]}),t[89]=Te,t[90]=ke,t[91]=Ae):Ae=t[91];let je;return t[92]!==me||t[93]!==we||t[94]!==Ae?(je=(0,X.jsxs)(`div`,{className:`ok-pdf`,style:me,children:[we,Ae]}),t[92]=me,t[93]=we,t[94]=Ae,t[95]=je):je=t[95],je}function yA(e){return!e}function bA(e){return!e}function xA(e){return Math.max(fA,+(e-mA).toFixed(2))}function SA(e){return Math.min(pA,+(e+mA).toFixed(2))}function CA(e){let t=(0,Z.c)(10),n=e.active||void 0,r;t[0]===e.active?r=t[1]:(r=e.active&&(0,X.jsx)(fn,{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 wA(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 TA(e){let t=(0,Z.c)(10),{label:n,id:r,children:i}=e,a=(0,Q.useId)(),o;t[0]!==r||t[1]!==a?(o=r||`tab-panel-${a.replace(/:/g,``)}`,t[0]=r,t[1]=a,t[2]=o):o=t[2];let s=o,c=`${s}-tab`,l;t[3]===n?l=t[4]:(l=n?.trim()||`Tab`,t[3]=n,t[4]=l);let u=l,d;return t[5]!==i||t[6]!==s||t[7]!==u||t[8]!==c?(d=(0,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 EA=`:scope > .component-children > [data-node-view-content-react] > .react-renderer`;function DA(e){return Array.from(e.querySelectorAll(EA)).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 OA(e,t){let n=Array.from(e.querySelectorAll(EA))[t];return n?n.querySelector(`[data-jsx-gear]`):null}function kA(e){let t=(0,Z.c)(31),{id:n,children:r}=e,[a,o]=(0,Q.useState)(0),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Q.useState)(s),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(0),p=GO(),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=DA(e);l(e=>{if(e.length!==t.length)return t;for(let n=0;n<e.length;n++)if(e[n].label!==t[n].label||e[n].panelId!==t[n].panelId)return t;return e})},t[1]=g):g=t[1],(0,Q.useLayoutEffect)(g);let _,v;t[2]===c.length?(_=t[3],v=t[4]):(_=()=>{c.length>f.current&&c.length>0&&o(c.length-1),f.current=c.length},v=[c.length],t[2]=c.length,t[3]=_,t[4]=v),(0,Q.useLayoutEffect)(_,v);let y;t[5]===n?y=t[6]:(y=()=>{let e=()=>{let e=window.location.hash.slice(1);if(!e)return;if(n&&e===n){o(0);return}let t=u.current;if(!t)return;let r=DA(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,Q.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;t[10]!==c||t[11]!==b?(w=c.map(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:jA,onClick:()=>{if(e.index!==b){o(e.index);return}let t=u.current;t&&OA(t,e.index)?.click()},children:e.label},e.index)),t[10]=c,t[11]=b,t[12]=w):w=t[12];let T;t[13]!==S||t[14]!==C||t[15]!==w?(T=(0,X.jsx)(`div`,{ref:d,role:`tablist`,"aria-label":C,className:`tabs-tablist`,onKeyDown:S,children:w}),t[13]=S,t[14]=C,t[15]=w,t[16]=T):T=t[16];let E;t[17]!==h||t[18]!==m||t[19]!==p?(E=m&&(0,X.jsx)(`button`,{type:`button`,className:`tabs-strip-add`,"aria-label":h({id:`hjO0Mq`}),title:h({id:`hjO0Mq`}),onMouseDown:AA,onClick:()=>p?.addChild?.(),"data-tabs-strip-add":``,children:`+`}),t[17]=h,t[18]=m,t[19]=p,t[20]=E):E=t[20];let D;t[21]!==E||t[22]!==T?(D=(0,X.jsxs)(`div`,{className:`tabs-strip`,contentEditable:!1,children:[T,E]}),t[21]=E,t[22]=T,t[23]=D):D=t[23];let O;t[24]!==r||t[25]!==b?(O=(0,X.jsx)(`div`,{ref:u,className:`tabs-content`,"data-active-index":b,children:r}),t[24]=r,t[25]=b,t[26]=O):O=t[26];let k;return t[27]!==n||t[28]!==D||t[29]!==O?(k=(0,X.jsxs)(`div`,{className:`tabs`,id:n,children:[D,O]}),t[27]=n,t[28]=D,t[29]=O,t[30]=k):k=t[30],k}function AA(e){return e.preventDefault()}function jA(e){return e.preventDefault()}var MA=typeof global<`u`&&{}.toString.call(global)===`[object global]`,NA=typeof Bun<`u`,PA=typeof Deno<`u`,FA=typeof WebSocketPair==`function`&&caches?.default!==void 0,IA=MA||NA||PA||FA;function LA(e,t){return e.indexOf(t.toLowerCase())===0?e:`${t.toLowerCase()}${e.substr(0,1).toUpperCase()}${e.substr(1)}`}function RA(e){return!!(e&&e.nodeType===1&&`nodeName`in e&&e.ownerDocument&&e.ownerDocument.defaultView)}function zA(e){return!isNaN(parseFloat(e))&&isFinite(e)&&Math.floor(e)==e}function BA(e){return/^(https?:)?\/\/((((player|www)\.)?vimeo\.com)|((player\.)?[a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))(?=$|\/)/.test(e)}function VA(e){return/^https:\/\/player\.((vimeo\.com)|([a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))\/video\/\d+/.test(e)}function HA(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 UA(){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(zA(r))return`https://vimeo.com/${r}`;if(BA(r))return r.replace(`http:`,`https:`);throw TypeError(t?`“${t}” is not a valid video id.`:`“${r}” is not a vimeo.com url.`)}var WA=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 GA(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 KA=Array.prototype.indexOf!==void 0,qA=typeof window<`u`&&window.postMessage!==void 0;if(!IA&&(!KA||!qA))throw Error(`Sorry, the Vimeo Player API is not available in this browser.`);var JA=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function YA(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:JA);var XA=YA(function(e){(function(t,n,r){n[t]=n[t]||r(),e.exports&&=n[t]})(`Promise`,JA,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})}),ZA=new WeakMap;function QA(e,t,n){let r=ZA.get(e.element)||{};t in r||(r[t]=[]),r[t].push(n),ZA.set(e.element,r)}function $A(e,t){return(ZA.get(e.element)||{})[t]||[]}function ej(e,t,n){let r=ZA.get(e.element)||{};if(!r[t])return!0;if(!n)return r[t]=[],ZA.set(e.element,r),!0;let i=r[t].indexOf(n);return i!==-1&&r[t].splice(i,1),ZA.set(e.element,r),r[t]&&r[t].length===0}function tj(e,t){let n=$A(e,t);if(n.length<1)return!1;let r=n.shift();return ej(e,t,r),r}function nj(e,t){let n=ZA.get(e);ZA.set(t,n),ZA.delete(e)}function rj(e){if(typeof e==`string`)try{e=JSON.parse(e)}catch(e){return console.warn(e),{}}return e}function ij(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 aj(e,t){t=rj(t);let n=[],r;if(t.event)t.event===`error`&&$A(e,t.data.method).forEach(n=>{let r=Error(t.data.message);r.name=t.data.name,n.reject(r),ej(e,t.data.method,n)}),n=$A(e,`event:${t.event}`),r=t.data;else if(t.method){let i=tj(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 oj=`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 sj(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return oj.reduce((t,n)=>{let r=e.getAttribute(`data-vimeo-${n}`);return(r||r===``)&&(t[n]=r===``?1:r),t},t)}function cj(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 lj(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(!BA(e))throw TypeError(`“${e}” is not a vimeo.com url.`);let a=`https://${HA(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){cj(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 uj(){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=sj(e);lj(UA(t),t,e).then(t=>cj(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(!BA(t.origin)||!t.data||t.data.event!==`spacechange`)return;let n=t.source?GA(t.source,e):null;if(n){let e=n.parentElement;e.style.paddingBottom=`${t.data.data[0].bottom}px`}}))}function fj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoSeoMetadataAppended||(window.VimeoSeoMetadataAppended=!0,window.addEventListener(`message`,t=>{if(!BA(t.origin))return;let n=rj(t.data);if(!n||n.event!==`ready`)return;let r=t.source?GA(t.source,e):null;r&&VA(r.src)&&new xj(r).callMethod(`appendVideoMetadata`,window.location.href)}))}function pj(){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(!BA(n.origin))return;let r=rj(n.data);if(!r||r.event!==`ready`)return;let i=n.source?GA(n.source,e):null;if(i&&VA(i.src)){let e=new xj(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 mj(){window.VimeoDRMEmbedsUpdated||(window.VimeoDRMEmbedsUpdated=!0,window.addEventListener(`message`,e=>{if(!BA(e.origin))return;let t=rj(e.data);if(!t||t.event!==`drminitfailed`)return;let n=e.source?GA(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 hj(){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 gj={role:`viewer`,autoPlayMuted:!0,allowedDrift:.3,maxAllowedDrift:1,minCheckInterval:.1,maxRateAdjustment:.2,maxTimeToCatchUp:1},_j=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,{...gj,...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=WA(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=WA(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()})}},vj=new WeakMap,yj=new WeakMap,bj={},xj=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)),!RA(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`&&!BA(e.getAttribute(`src`)||``))throw Error(`The player element passed isn’t a Vimeo embed.`);if(vj.has(e))return vj.get(e);this._window=e.ownerDocument.defaultView,this.element=e,this.origin=`*`;let n=new XA((n,r)=>{if(this._onMessage=e=>{if(!BA(e.origin)||this.element.contentWindow!==e.source)return;this.origin===`*`&&(this.origin=e.origin);let t=rj(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}aj(this,t)},this._window.addEventListener(`message`,this._onMessage),this.element.nodeName!==`IFRAME`){let n=sj(e,t);lj(UA(n),n,e).then(t=>{let n=cj(t,e);return this.element=n,this._originalElement=e,nj(e,n),vj.set(this.element,this),t}).catch(r)}});if(yj.set(this,n),vj.set(this.element,this),this.element.nodeName===`IFRAME`&&ij(this,`ping`),bj.isEnabled){let e=()=>bj.exit();this.fullscreenchangeHandler=()=>{bj.isFullscreen?QA(this,`event:exitFullscreen`,e):ej(this,`event:exitFullscreen`,e),this.ready().then(()=>{ij(this,`fullscreenchange`,bj.isFullscreen)})},bj.on(`fullscreenchange`,this.fullscreenchangeHandler)}return this}static isVimeoUrl(e){return BA(e)}callMethod(e){var t=[...arguments].slice(1);if(e==null)throw TypeError(`You must pass a method name.`);return new XA((n,r)=>this.ready().then(()=>{QA(this,e,{resolve:n,reject:r}),t.length===0?t={}:t.length===1&&(t=t[0]),ij(this,e,t)}).catch(r))}get(e){return new XA((t,n)=>(e=LA(e,`get`),this.ready().then(()=>{QA(this,e,{resolve:t,reject:n}),ij(this,e)}).catch(n)))}set(e,t){return new XA((n,r)=>{if(e=LA(e,`set`),t==null)throw TypeError(`There must be a value to set.`);return this.ready().then(()=>{QA(this,e,{resolve:n,reject:r}),ij(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.`);$A(this,`event:${e}`).length===0&&this.callMethod(`addEventListener`,e).catch(()=>{}),QA(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.`);ej(this,`event:${e}`,t)&&this.callMethod(`removeEventListener`,e).catch(e=>{})}loadVideo(e){return this.callMethod(`loadVideo`,e)}ready(){let e=yj.get(this)||new XA((e,t)=>{t(Error(`Unknown player. Probably unloaded.`))});return XA.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 bj.isEnabled?bj.request(this.element):this.callMethod(`requestFullscreen`)}exitFullscreen(){return bj.isEnabled?bj.exit():this.callMethod(`exitFullscreen`)}getFullscreen(){return bj.isEnabled?XA.resolve(bj.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 XA(e=>{if(yj.delete(this),vj.delete(this.element),this._originalElement&&(vj.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),bj.isEnabled&&bj.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 XA.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 XA((e,t)=>t(TypeError(`Argument must be an array.`)));let t=new XA(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 XA.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 _j(this,e,t);return ij(this,`notifyTimingObjectConnect`),n.addEventListener(`disconnect`,()=>ij(this,`notifyTimingObjectDisconnect`)),n}};IA||(bj=hj(),uj(),dj(),fj(),pj(),mj());function Sj(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Cj(e,t)}function Cj(e,t){return Cj=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Cj(e,t)}var wj={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`},Tj=function(e){function t(t){var n=e.call(this,t)||this;return n.refContainer=n.refContainer.bind(n),n}Sj(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 xj(this.container,this.getInitialOptions()),Object.keys(wj).forEach(function(t){var n=wj[t];e.player.on(t,function(t){var r=e.props[n];r&&r(t)})});var a=this.props,o=a.onError,s=a.onReady;this.player.ready().then(function(){s&&s(e.player)},function(e){if(o)o(e);else throw e}),typeof n==`number`&&this.player.setCurrentTime(n),typeof r==`number`&&this.updateProps([`volume`]),typeof i==`number`&&this.updateProps([`playbackRate`])},n.refContainer=function(e){this.container=e},n.render=function(){var e=this.props,t=e.id,n=e.className,r=e.style;return Q.createElement(`div`,{id:t,className:n,style:r,ref:this.refContainer})},t}(Q.Component);Tj.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 Ej={default:120,mqdefault:320,hqdefault:480,sddefault:640,maxresdefault:1280},Dj=(e,t,n,r=`maxresdefault`)=>{let[i,a]=(0,Q.useState)(``);return(0,Q.useEffect)(()=>{let i=`https://img.youtube.com/${t}/${e}/${r}.${n}`,o=`https://img.youtube.com/${t}/${e}/hqdefault.${n}`,s=Ej[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 Oj(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 kj(e,t){let[n,r]=Q.useState(!1),[i,a]=Q.useState(e.alwaysLoadIframe||!1),o=encodeURIComponent(e.id),s=typeof e.playlistCoverId==`string`?encodeURIComponent(e.playlistCoverId):null,c=e.title,l=e.poster||`hqdefault`,u=e.announce||`Watch`,d=e.alwaysLoadIframe?e.autoplay&&e.muted:!0,f=Q.useMemo(()=>{let t=new URLSearchParams({...e.muted?{mute:`1`}:{},...d?{autoplay:`1`}:{},...e.enableJsApi?{enablejsapi:`1`}:{},...e.enableJsApi&&typeof window<`u`?{origin:window.location.origin}:{},...e.playlist?{list:o}:{}});return e.params&&new URLSearchParams(e.params.startsWith(`&`)?e.params.slice(1):e.params).forEach((e,n)=>{t.append(n,e)}),t},[e.muted,d,e.enableJsApi,e.playlist,o,e.params]),p=Q.useMemo(()=>e.cookie?`https://www.youtube.com`:`https://www.youtube-nocookie.com`,[e.cookie]),m=Q.useMemo(()=>e.playlist?`${p}/embed/videoseries?${f.toString()}`:`${p}/embed/${o}?${f.toString()}`,[e.playlist,p,o,f]),h=!e.thumbnail&&!e.playlist&&l===`maxresdefault`,g=e.webp?`webp`:`jpg`,_=e.webp?`vi_webp`:`vi`,v=h?Dj(e.id,_,g,l):null,y=Q.useMemo(()=>e.thumbnail||v||`https://i.ytimg.com/${_}/${e.playlist?s:o}/${l}.${g}`,[e.thumbnail,v,_,e.playlist,s,o,l,g]),b=e.activatedClass||`lyt-activated`,x=e.adNetwork||!1,S=e.aspectHeight||9,C=e.aspectWidth||16,w=e.iframeClass||``,T=e.playerClass||`lty-playbtn`,E=e.wrapperClass||`yt-lite`,D=Q.useCallback(e.onIframeAdded||function(){},[e.onIframeAdded]),O=e.rel?`prefetch`:`preload`,k=e.containerElement||`article`,A=e.noscriptFallback!==!1,j=()=>{n||r(!0)},M=()=>{i||a(!0)};return Q.useEffect(()=>{i&&(D(),e.focusOnLoad&&typeof t==`object`&&t?.current&&t.current.focus())},[i,D,e.focusOnLoad,t]),Q.useEffect(()=>{if(!i||!e.enableJsApi||!(e.onReady||e.onStateChange||e.onError||e.onPlay||e.onPause||e.onEnd||e.onBuffering||e.onPlaybackRateChange||e.onPlaybackQualityChange))return;let n=!1,r=!1,a=r=>{if(r.origin!==`https://www.youtube.com`&&r.origin!==`https://www.youtube-nocookie.com`)return;let i;try{i=typeof r.data==`string`?JSON.parse(r.data):r.data}catch{return}switch(i.event){case`onReady`:n||(n=!0,e.onReady&&e.onReady({videoId:e.id,title:c}));break;case`infoDelivery`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate),i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break;case`onStateChange`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}break;case`onError`:if(i.info&&`errorCode`in i.info){let t=i.info.errorCode;e.onError&&e.onError(t)}break;case`onPlaybackRateChange`:i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate);break;case`onPlaybackQualityChange`:i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break}};window.addEventListener(`message`,a);let s=[],l=()=>{typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"listening","id":"`+o+`"}`,`*`)},u=()=>{r||(r=!0,l(),[100,300,600,1200,2400].forEach(e=>{s.push(setTimeout(l,e))}))};return typeof t==`object`&&t?.current?(t.current.addEventListener(`load`,u),t.current.contentDocument?.readyState===`complete`&&u()):[200,500,1e3,2e3,3e3].forEach(e=>{s.push(setTimeout(l,e))}),()=>{window.removeEventListener(`message`,a),s.forEach(clearTimeout),typeof t==`object`&&t?.current&&t.current.removeEventListener(`load`,u)}},[i,e.enableJsApi,e.onReady,e.onStateChange,e.onError,e.onPlay,e.onPause,e.onEnd,e.onBuffering,e.onPlaybackRateChange,e.onPlaybackQualityChange,e.stopOnEnd,e.id,o,c,t]),(0,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:Oj(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 Aj=Q.forwardRef(kj);function jj(e){return e!==!1}function Mj(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 Nj(e){if(e.width!==void 0)return{width:e.width}}function Pj(e){if(!(e.width===void 0||e.height===void 0))return{aspectRatio:`${e.width} / ${e.height}`}}function Fj(e){let t=(0,Z.c)(23),n=(0,Q.useRef)(null),r=e.title??`Vimeo video player`,i;t[0]===r?i=t[1]:(i=e=>{let t=e;n.current=t,t.element&&(t.element.title=r)},t[0]=r,t[1]=i);let a=i,o,s;t[2]===r?(o=t[3],s=t[4]):(o=()=>{let e=n.current;e?.element&&(e.element.title=r)},s=[r],t[2]=r,t[3]=o,t[4]=s),(0,Q.useEffect)(o,s);let c;t[5]===e?c=t[6]:(c=Nj(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)(Tj,{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 Ij(e){let t=(0,Z.c)(17),n;t[0]===e.src?n=t[1]:(n=_e(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=Nj(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 Lj(e){let t=(0,Z.c)(29);if(e.src!==void 0&&A(e.src)){let n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(Ij,{...e,src:e.src}),t[0]=e,t[1]=n),n}if(e.src!==void 0&&de(e.src)){let n;return t[2]===e?n=t[3]:(n=(0,X.jsx)(Fj,{...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:Fe(e.src);if(r!==null){let i=e.autoplay===!0&&e.muted===!0,a=e.width!==void 0&&e.height!==void 0,o=Nj(e),s;t[6]===e.poster?s=t[7]:(s=e.poster===void 0?void 0:et(e.poster),t[6]=e.poster,t[7]=s);let c=(0,X.jsx)(Aj,{id:r.id,title:e.title??`YouTube video player`,cookie:!r.noCookie,params:Mj(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:Pj(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:et(e.src),t[11]=e.src,t[12]=r);let i=e.title,a;t[13]===e.controls?a=t[14]:(a=jj(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:et(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 Rj(e){let t=(0,Z.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 zj={Callout:HO,img:Rk,video:Lj,audio:LO,Pdf:vA,File:tk,Embed:$O,Accordion:FO,Tabs:kA,Tab:TA,Math:Vk,MermaidFence:Wk,Mirror:iA,MirrorSource:aA,"*":Rj};function Bj(e){let t=new Set;for(let n of e)n.type===`reactnode`&&t.add(n.name);return t}var Vj=at(),Hj=new Map;function Uj(e){if(e.surface===`compat`){let t=zj[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:Bj(e.props)}}let t=zj[e.name];return t?{Component:t,reactNodePropNames:Bj(e.props)}:null}for(let[e,t]of Vj.entries()){let n=Uj(t);n&&Hj.set(e,n)}function Wj(e,t){return{...e,Component:t.Component,reactNodePropNames:t.reactNodePropNames}}function Gj(e){let t=Vj.getOrWildcard(e),n=Hj.get(t.name)??Hj.get(`*`);if(!n)throw Error(`No React component registered for ${t.name} (and no '*' wildcard)`);return Wj(t,n)}function Kj(){let e=[];for(let[t,n]of Vj.entries()){if(t===`*`)continue;let r=Hj.get(t);r&&e.push(Wj(n,r))}return e}var qj=``+new URL(`image-preview-BJSGEOo4.png`,import.meta.url).href,Jj=``+new URL(`video-preview-vLovc_Vy.png`,import.meta.url).href,Yj={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:qj,alt:`Sample image`}},video:{description:{id:`e1hptq`},props:{controls:!0,poster:Jj}},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)(Fi,{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)(Mi,{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 Xj(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 Zj(e){let t=Gj(e),n=Xj(t);return{type:`jsxComponent`,attrs:{componentName:t.name,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:n},content:t.hasChildren?[{type:`paragraph`}]:void 0}}var Qj=new Set;function $j(e){Qj.add(e)}function eM(e){if(typeof e==`number`)return Qj.delete(e);let t=Qj.values().next();return t.done?!1:(Qj.delete(t.value),!0)}function tM(e,t,n){n.props.some(e=>!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`)?($j(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})):n.hasChildren&&e.commands.setTextSelection(t+2)}function nM(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=Zj(e.name);if(e.name===`Tabs`){let e=Zj(`Tab`),t=Zj(`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)&&tM(t,i,e)}}var rM=new Set([`File`,`Tab`]);function iM(){return[{name:`component-File`,label:Rn._({id:`J2eKUI`}),icon:Bi,category:`media`,aliases:[`file`,`attachment`,`download`,`upload`,`document`,`doc`,`docx`,`zip`],description:"Attach a downloadable file (`.pdf` / `.docx` / `.zip` / …)",command:oM,preview:{description:Rn._({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)(Bi,{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 aM(){return[...Kj().filter(e=>e.surface===`canonical`&&!rM.has(e.name)).map(e=>{let t=Yj[e.name],n=e.Component,r=t?{description:Rn._(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:jO(e.icon),category:e.category??`content`,command:nM(e),aliases:e.searchTerms,description:e.description,preview:r}}),...iM()]}function oM(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;aO(n,e,t)}t.remove()},{once:!0}),t.addEventListener(`cancel`,()=>t.remove(),{once:!0}),document.body.appendChild(t),t.click()}function sM(e,t){let n=uO.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 cM(){return[{name:`link`,label:Rn._({id:`yzF66j`}),icon:na,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:Rn._({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=sM(e,t);n&&(cO(n),requestAnimationFrame(()=>{kO(e).setActiveNode(n)}))}},{name:`component-Tag`,label:Rn._({id:`UL8A9w`}),icon:Ki,category:`content`,aliases:[`#`,`hashtag`,`label`],description:"Inline tag (`#tagname`) for cross-doc linking",preview:{description:Rn._({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 lM(e,t){e.chain().focus().insertContent({type:`codeBlock`,attrs:{language:`html`,meta:`preview`},content:[{type:`text`,text:t}]}).run()}var uM=`<div style="padding:20px;font-family:system-ui,sans-serif;color:var(--foreground)">
|
|
6
|
+
`);return/\s/.test(n)}):!1}var Oy=new N(`suggestion`);function ky({pluginKey:e=Oy,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=Ey,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}},S=(n,r)=>r?()=>{let r=e.getState(t.state)?.decorationId;return n.dom.querySelector(`[data-decoration-id="${r}"]`)?.getBoundingClientRect()||null}:x,C=({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&&!Dy(i);function w(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:S(n,a)};(i=y?.onExit)==null||i.call(y,o)}catch{}let a=n.state.tr.setMeta(r,{exit:!0});n.dispatch(a)}let T=new pt({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,C=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:C,clientRect:S(e,C)},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&&!C({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}=T.getState(t.state);if(!i)return!1;if(n.key===`Escape`||n.key===`Esc`){let i=T.getState(t.state);return(r=y?.onKeyDown)==null||r.call(y,{view:t,event:n,range:i.range}),w(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}=T.getState(e);if(!t)return null;let a=!i?.length,o=[c];return a&&o.push(u),q.create(e.doc,[O.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return T}var Ay=ky;function jy(e){return e.kind===`create`?`create:${e.value}`:`tag:${e.value}`}function My(e){if(e.kind===`create`){let t=e.value;return Rn._({id:`XPqe3B`,values:{tagValue:t}})}let t=Rn._({id:`pckX1A`,values:{0:e.count}}),n=e.value;return Rn._({id:`m2T1Xj`,values:{tagValue:n,uses:t}})}function Ny(e){let t=(0,Z.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,Q.useRef)(null),h=(0,Q.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,Q.useEffect)(_,v);let y=Py;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?My(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=jy(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 Py(e){return e.preventDefault()}var Fy=new WeakMap;function Iy(e,t){Fy.set(e,t)}function Ly(e){return Fy.get(e)??!1}function Ry(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`),fr(r,n,{placement:`bottom-start`,middleware:[nr(4),lr(),hr({padding:8}),_r({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:()=>or(r,n,o),reveal:()=>{a||(i=!0,o())}}}function zy(e){e.stopAutoUpdate?.(),e.stopAutoUpdate=null,e.popup?.remove(),e.popup=null}var By=new N(`tagSuggestion`),Vy=8,Hy=/^[a-zA-Z][\w/-]*$/;async function Uy(){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 Wy(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 Gy(e,t){let n=Wy(e,t).slice(0,Vy).map(e=>({kind:`tag`,value:e.name,count:e.count,isLeaf:e.isLeaf})),r=t.trim();return r&&Hy.test(r)&&!e.some(e=>e.name===r)&&n.push({kind:`create`,value:r}),n}function Ky(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 qy(e){let t=[],n=!1,r=null,i=null;return Ay({editor:e,pluginKey:By,char:`#`,allowedPrefixes:null,findSuggestionMatch:Ky,allow:({editor:e})=>!Ly(e),items:async({query:e})=>{if(!n){r||=Uy();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 Gy(t,e)},command:({editor:e,range:t,props:n})=>{try{let r=n.value;if(!r||!Hy.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=Ry(()=>a,`tag-suggestion`);s.popup=n.popup,c=n.doPosition,l=n.reveal,e=new Ll(Ny,{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&&Hy.test(n)?(a.command({kind:`create`,value:n}),!0):!1}return e.key,!1},onExit(){zy(s),c=null,l=null,e?.destroy(),e=null,a=null,o=0,t=[],i=null,n=!1,r=null}}}})}var Jy=1,Yy=.9,Xy=.8,Zy=.17,Qy=.1,$y=.999,eb=.9999,tb=.99,nb=/[\\\/_+.#"@\[\(\{&]/,rb=/[\\\/_+.#"@\[\(\{&]/g,ib=/[\s-]/,ab=/[\s-]/g;function ob(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Jy:tb;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*=Jy:nb.test(e.charAt(l-1))?(d*=Xy,p=e.slice(i,l-1).match(rb),p&&i>0&&(d*=$y**+p.length)):ib.test(e.charAt(l-1))?(d*=Yy,m=e.slice(i,l-1).match(ab),m&&i>0&&(d*=$y**+m.length)):(d*=Zy,i>0&&(d*=$y**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=eb)),(d<Qy&&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*Qy>d&&(d=f*Qy)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function sb(e){return e.toLowerCase().replace(ab,` `)}function cb(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,ob(e,t,sb(e),sb(t),0,0,{})}var lb=`[cmdk-group=""]`,ub=`[cmdk-group-items=""]`,db=`[cmdk-group-heading=""]`,fb=`[cmdk-item=""]`,pb=`${fb}:not([aria-disabled="true"])`,mb=`cmdk-item-select`,hb=`data-value`,gb=(e,t,n)=>cb(e,t,n),_b=Q.createContext(void 0),vb=()=>Q.useContext(_b),yb=Q.createContext(void 0),bb=()=>Q.useContext(yb),xb=Q.createContext(void 0),Sb=Q.forwardRef((e,t)=>{let n=Ib(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Ib(()=>new Set),i=Ib(()=>new Map),a=Ib(()=>new Map),o=Ib(()=>new Set),s=Pb(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Wn(),y=Wn(),b=Wn(),x=Q.useRef(null),S=zb();Fb(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Fb(()=>{S(6,k)},[]);let C=Q.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=Q.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??gb;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(ub);t?t.appendChild(e.parentElement===t?e:e.closest(`${ub} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${ub} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${lb}[${hb}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(hb);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(lb)?.querySelector(db))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${fb}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(pb)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(hb))}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(hb))}function P(e){let t=A()?.closest(lb),n;for(;t&&!n;)t=e>0?Mb(t,lb):Nb(t,lb),n=t?.querySelector(pb);n?C.setState(`value`,n.getAttribute(hb)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return Q.createElement(qn.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(mb);t.dispatchEvent(e)}}}}},Q.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Hb},c),Vb(e,e=>Q.createElement(yb.Provider,{value:C},Q.createElement(_b.Provider,{value:w},e))))}),Cb=Q.forwardRef((e,t)=>{let n=Wn(),r=Q.useRef(null),i=Q.useContext(xb),a=vb(),o=Pb(e),s=o.current?.forceMount??i?.forceMount;Fb(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Rb(n,r,[e.value,e.children,r],e.keywords),l=bb(),u=Lb(e=>e.value&&e.value===c.current),d=Lb(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);Q.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(mb,f),()=>t.removeEventListener(mb,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return Q.createElement(qn.div,{ref:Wt(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)}),wb=Q.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Wn(),s=Q.useRef(null),c=Q.useRef(null),l=Wn(),u=vb(),d=Lb(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);Fb(()=>u.group(o),[]),Rb(o,s,[e.value,e.heading,c]);let f=Q.useMemo(()=>({id:o,forceMount:i}),[i]);return Q.createElement(qn.div,{ref:Wt(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&Q.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Vb(e,e=>Q.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Q.createElement(xb.Provider,{value:f},e))))}),Tb=Q.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Q.useRef(null),a=Lb(e=>!e.search);return!n&&!a?null:Q.createElement(qn.div,{ref:Wt(i,t),...r,"cmdk-separator":``,role:`separator`})}),Eb=Q.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=bb(),o=Lb(e=>e.search),s=Lb(e=>e.selectedItemId),c=vb();return Q.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Q.createElement(qn.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)}})}),Db=Q.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Q.useRef(null),o=Q.useRef(null),s=Lb(e=>e.selectedItemId),c=vb();return Q.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Q.createElement(qn.div,{ref:Wt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Vb(e,e=>Q.createElement(`div`,{ref:Wt(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Ob=Q.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Q.createElement(sn,{open:n,onOpenChange:r},Q.createElement(Qt,{container:o},Q.createElement(Zt,{"cmdk-overlay":``,className:i}),Q.createElement(dn,{"aria-label":e.label,"cmdk-dialog":``,className:a},Q.createElement(Sb,{ref:t,...s}))))}),kb=Q.forwardRef((e,t)=>Lb(e=>e.filtered.count===0)?Q.createElement(qn.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Ab=Q.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Q.createElement(qn.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Vb(e,e=>Q.createElement(`div`,{"aria-hidden":!0},e)))}),jb=Object.assign(Sb,{List:Db,Item:Cb,Input:Eb,Group:wb,Separator:Tb,Dialog:Ob,Empty:kb,Loading:Ab});function Mb(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Nb(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Pb(e){let t=Q.useRef(e);return Fb(()=>{t.current=e}),t}var Fb=typeof window>`u`?Q.useEffect:Q.useLayoutEffect;function Ib(e){let t=Q.useRef();return t.current===void 0&&(t.current=e()),t}function Lb(e){let t=bb(),n=()=>e(t.snapshot());return Q.useSyncExternalStore(t.subscribe,n,n)}function Rb(e,t,n,r=[]){let i=Q.useRef(),a=vb();return Fb(()=>{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(hb,s),i.current=s}),i}var zb=()=>{let[e,t]=Q.useState(),n=Ib(()=>new Map);return Fb(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Bb(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Vb({asChild:e,children:t},n){return e&&Q.isValidElement(t)?Q.cloneElement(Bb(t),{ref:t.ref},n(t.props.children)):n(t)}var Hb={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Ub(e){let t=(0,Z.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=Ut(`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)(jb,{"data-slot":`command`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Wb(e){let t=(0,Z.c)(36),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({title:s,description:c,children:n,className:r,showCloseButton:l,commandProps:i,onEscapeKeyDown:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=s===void 0?`Command Palette`:s,d=c===void 0?`Search for a command to run`:c,f=l===void 0?!0:l,p;t[9]===i?p=t[10]:(p=i??{},t[9]=i,t[10]=p);let m,h;t[11]===p?(m=t[12],h=t[13]):({className:m,...h}=p,t[11]=p,t[12]=m,t[13]=h);let g;t[14]===r?g=t[15]:(g=Ut(`top-[12vh] translate-y-0 overflow-hidden p-0`,r),t[14]=r,t[15]=g);let _;t[16]===u?_=t[17]:(_=(0,X.jsx)(Xt,{className:`sr-only`,children:u}),t[16]=u,t[17]=_);let v;t[18]===d?v=t[19]:(v=(0,X.jsx)(Yt,{className:`sr-only`,children:d}),t[18]=d,t[19]=v);let y;t[20]===m?y=t[21]:(y=Ut(`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,m),t[20]=m,t[21]=y);let b;t[22]!==n||t[23]!==h||t[24]!==y?(b=(0,X.jsx)(Ub,{className:y,...h,children:n}),t[22]=n,t[23]=h,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==a||t[27]!==f||t[28]!==g||t[29]!==_||t[30]!==v||t[31]!==b?(x=(0,X.jsxs)(tn,{className:g,showCloseButton:f,onEscapeKeyDown:a,children:[_,v,b]}),t[26]=a,t[27]=f,t[28]=g,t[29]=_,t[30]=v,t[31]=b,t[32]=x):x=t[32];let S;return t[33]!==o||t[34]!==x?(S=(0,X.jsx)(un,{...o,children:x}),t[33]=o,t[34]=x,t[35]=S):S=t[35],S}function Gb(e){let t=(0,Z.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)(ga,{className:`size-4 shrink-0 opacity-50`}),t[3]=i):i=t[3];let a;t[4]===n?a=t[5]:(a=Ut(`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)(jb.Input,{"data-slot":`command-input`,className:a,...r})]}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function Kb(e){let t=(0,Z.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=Ut(`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)(jb.List,{"data-slot":`command-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function qb(e){let t=(0,Z.c)(2),n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(jb.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e}),t[0]=e,t[1]=n),n}function Jb(e){let t=(0,Z.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=Ut(`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)(jb.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Yb(e){let t=(0,Z.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=Ut(`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)(jb.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Xb(e){let t=(0,Z.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=Ut(`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 Zb(e,t){let n=null,r;try{n=await e.json()}catch(e){r=e}if(r instanceof Error&&r.name===`AbortError`)throw r;if(e.ok)return r!==void 0&&console.warn(`[parse-server-response] 2xx response with non-JSON body:`,r instanceof Error?r.message:String(r)),{ok:!0,body:r===void 0?n:null};if(r!==void 0){let t=r instanceof Error?r.message:String(r);return{ok:!1,title:`Server error (HTTP ${e.status}): ${t}`}}return{ok:!1,title:wn(n)??t}}function Qb(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 $b=new Map,ex=null;function tx(){return uc(`PREWARM_CORRELATION_WINDOW_MS`,5e3)}function nx(){if(ex!==null)return;let e=Math.max(50,Math.floor(tx()/2));ex=setTimeout(()=>{ex=null,rx(Date.now()),$b.size>0&&nx()},e)}function rx(e){let t=tx();for(let[n,r]of $b)e-r.emittedAt>=t&&($b.delete(n),$.count(`ok/sidebar/prewarm`,{hit:!1}))}function ix(e,t,n=Date.now()){$b.has(e)&&$.count(`ok/sidebar/prewarm`,{hit:!1}),$b.set(e,{poolEventId:t,emittedAt:n}),nx()}function ax(e,t,n=Date.now()){let r=$b.get(e);return!r||r.poolEventId!==t||n-r.emittedAt>=tx()?!1:($b.delete(e),$(`ok/sidebar/prewarm-clicked`,{docName:e,t:n,poolEventId:t}),$.count(`ok/sidebar/prewarm`,{hit:!0}),!0)}Qe({event:ke(`ok-branch-switched-clear-failed`),branch:Ct(),docName:Ct(),reason:Ct()});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 sx=null,cx=new Set;function lx(){return sx}function ux(e){let t=e!==null&&e.length>0?e:null;if(t!==sx){sx=t;for(let e of cx)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function dx(e){return cx.add(e),()=>{cx.delete(e)}}function fx(){return(0,Q.useSyncExternalStore)(dx,lx,lx)}function px(e){let t=!1;return()=>{t?e():t=!0}}function mx(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 hx(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=rt.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),ux(i.data.serverInstanceId),i.data.currentBranch!==void 0&&e.compareAndUpdateObservedBranch(i.data.currentBranch)&&(ox(e,i.data.currentBranch),Pn(i.data.currentBranch)),i.data.currentDiskAckSVs!==void 0){let t={};for(let[e,n]of Object.entries(i.data.currentDiskAckSVs))try{t[e]=mx(n)}catch{}e.observeDiskAckBatch(t)}}async function gx(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,singleFile:r.singleFile===!0}}}function _x(e){return Tx(e,Le)}function vx(e){return Tx(e,nt)}function yx(e){return Tx(e,Ze)}function bx(e){return Tx(e,je)}function xx(e){return Tx(e,St)}function Sx(e){let t=Tx(e,ct);if(!t)return null;try{return{docName:t.docName,sv:Cx(t.sv)}}catch{return null}}function Cx(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 wx(e,t){let n=vx(e);if(n){t.onServerInfo?.(n);return}let r=yx(e);if(r){t.onBranchSwitched?.(r);return}let i=Sx(e);if(i){t.onDiskAck?.(i);return}let a=_x(e);if(a){t.onDerivedView?.(a);return}let o=bx(e);if(o){t.onConfigValidationRejected?.(o);return}let s=xx(e);if(s){t.onConfigIgnoreNestedError?.(s);return}t.onUnknown?.(e)}function Tx(e,t){let n;try{n=JSON.parse(e)}catch{return null}let r=t.safeParse(n);return r.success?r.data:null}function Ex(){return typeof location>`u`?`ws://localhost/collab`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/collab`}function Dx(e){if(e===void 0)return null;let t=e.okDesktop;return!t||!t.config.collabUrl||t.config.collabUrl.length===0?null:t}function Ox(e){return{collabUrl:e.collabUrl,attempts:0,terminal:!1,lastError:null}}var kx=2e3,Ax=15e3;function jx(e){let t=e.terminalAfterMs??3e4,n=e.initialDelayMs??kx,r=e.maxDelayMs??Ax,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 Mx(){let e=(0,Z.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={collabUrl:null,attempts:0,terminal:!1,lastError:null},e[0]=t):t=e[0];let[n,r]=(0,Q.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={token:0},e[1]=i):i=e[1];let a=(0,Q.useRef)(i),[o,s]=(0,Q.useState)(0),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=a.current.token=a.current.token+1,t=Dx(window);if(t){r(Ox(t.config));let n=t.onProjectSwitched(t=>{e===a.current.token&&r(Ox(t))});return()=>{n()}}let n=jx({fetchConfig:gx,fallbackUrl:Ex,now:Date.now,setTimeout:Ix,clearTimeout:Fx,onStateChange:t=>{e===a.current.token&&r(t)}});return()=>{n.cancel()}},e[2]=c):c=e[2];let l;e[3]===o?l=e[4]:(l=[o],e[3]=o,e[4]=l),(0,Q.useEffect)(c,l);let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{a.current.token=a.current.token+1,r(Px),s(Nx)},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 Nx(e){return e+1}function Px(e){return{...e,terminal:!1,lastError:null}}function Fx(e){return globalThis.clearTimeout(e)}function Ix(e,t){return globalThis.setTimeout(e,t)}var Lx=new Map,Rx=new Set;function zx(){for(let e of Rx)e()}function Bx(e,t){Lx.set(e,t),zx()}function Vx(e,t){Lx.get(e)===t&&(Lx.delete(e),zx())}function Hx(e){return Lx.get(e)??null}function Ux(e){return Rx.add(e),()=>Rx.delete(e)}var Wx=new Map;function Gx(e){return Wx.get(e)}function Kx(e,t){Wx.set(e,t)}function qx(e){Wx.delete(e)}var Jx=`open-knowledge-app`,Yx=new Map,Xx=new Set,Zx=1024,Qx=1024;function $x(){return Vn.getTracer(Jx)}function eS(e,t,n){if(Xx.has(e))return null;let r=Yx.get(e);if(r)return r;if(Yx.size>=Qx){let e=Yx.keys().next().value;if(e!==void 0){let t=Yx.get(e);Yx.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:$x().startSpan(`ok.cold-mount`,{attributes:{"mount.id":e,...t},startTime:n}),startTimeMs:n};return Yx.set(e,i),i}function tS(e,t,n,r,i){try{let a=eS(e,n,r),o=a?Vn.setSpan(Hn.active(),a.span):Hn.active();$x().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 nS(e,t){try{let n=Yx.get(e);if(n&&(Yx.delete(e),n.span.end(t??Date.now())),!Xx.has(e)){if(Xx.size>=Zx){let e=Xx.values().next().value;e!==void 0&&Xx.delete(e)}Xx.add(e)}}catch(e){console.warn(`[otel-spans] finalizeColdMountSpan failed:`,e instanceof Error?e:String(e))}}var rS=class extends Error{docName;constructor(e){super(`Mount aborted for "${e}"`),this.name=`MountAbortError`,this.docName=e}};function iS(){return uc(`MOUNT_STALLED_THRESHOLD_MS`,1e4)}function aS(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;$(`ok/mount/stalled`,{docName:t,mountId:e.mountId,elapsedMs:r})}var sS=new Map,cS=new Set;function lS(e){cS.add(e);for(let[t,n]of sS)if(n.stalledMarkEmitted&&!n.settled)try{e(t,n.mountId)}catch{}return()=>{cS.delete(e)}}function uS(e,t){for(let n of cS)try{n(e,t.mountId)}catch{}}var dS=!1;function fS(){typeof document>`u`||document.visibilityState===`visible`&&hS(Date.now())}function pS(){dS||typeof document>`u`||typeof document.addEventListener==`function`&&(document.addEventListener(`visibilitychange`,fS),dS=!0)}function mS(){dS&&(typeof document>`u`||typeof document.removeEventListener==`function`&&(document.removeEventListener(`visibilitychange`,fS),dS=!1))}function hS(e){let t=iS();for(let[n,r]of sS)r.settled||r.stalledMarkEmitted||e-r.createdAt<t||(oS(r,n,e),uS(n,r))}function gS(e){let{docName:t,mountId:n,construct:r,sizeStats:i}=e,a=sS.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()),uS(t,d))},iS()),o.signal.addEventListener(`abort`,()=>{d.settled||(d.settled=!0,aS(d),d.preMountEditor&&=(bS(t,d.preMountEditor,`aborted`),null),sS.delete(t),sS.size===0&&mS(),$(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`aborted`}),l(new rS(t)),nS(d.mountId))}),sS.set(t,d),pS(),$(`ok/mount/create`,{docName:t,mountId:d.mountId}),xS({docName:t,construct:r,sizeStats:i,entry:d,resolveFn:c,rejectFn:l}).catch(e=>{if(d.preMountEditor&&=(bS(t,d.preMountEditor,`backstop`),null),d.settled){$(`ok/mount/post-settle-throw`,{docName:t,mountId:d.mountId,message:e instanceof Error?e.message:String(e)});return}d.settled=!0,aS(d);let n=e instanceof Error?e:Error(String(e));$(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`unhandled-body-throw`,message:n.message}),l(n),nS(d.mountId)}),u}function _S(e){return sS.get(e)?.resolved===!0}function vS(e){return sS.get(e)?.controller??null}function yS(e){let t=sS.get(e);t&&(t.settled=!0,aS(t),t.preMountEditor&&=(bS(e,t.preMountEditor,`aborted`),null),sS.delete(e),sS.size===0&&mS(),$(`ok/mount/invalidate`,{docName:e,mountId:t.mountId}),nS(t.mountId),t.controller.abort())}function bS(e,t,n){let r=SS(t);try{t.destroy()}catch(t){$(`ok/mount/destroy-failed`,{docName:e,stage:n,message:t instanceof Error?t.message:String(t)})}r&&(r.restore=void 0)}async function xS(e){let{docName:t,construct:n,sizeStats:r,entry:i,resolveFn:a,rejectFn:o}=e,s=document.createElement(`div`);if(nC(t)!==void 0){let e=BS({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,aS(i),a(e);return}if(await scheduler.yield(),i.controller.signal.aborted)return;let c=null;try{c=n()}catch(e){i.settled=!0,aS(i);let n=e instanceof Error?e:Error(String(e));$(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`construct-failed`,message:n.message}),o(n),nS(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){bS(t,c.editor,`mount-failed`),i.preMountEditor=null,i.settled=!0,aS(i);let n=e instanceof Error?e:Error(String(e));$(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`mount-failed`,message:n.message}),o(n),nS(i.mountId);return}let l;try{l=BS({docName:t,container:s,sizeStats:r,factory:()=>c})}catch(e){bS(t,c.editor,`v2-register-failed`),i.preMountEditor=null,i.settled=!0,aS(i);let n=e instanceof Error?e:Error(String(e));$(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`v2-register-failed`,message:n.message}),o(n),nS(i.mountId);return}i.preMountEditor=null,i.settled=!0,i.resolved=!0,aS(i);let u=Date.now()-i.createdAt;$(`ok/mount/resolve`,{docName:t,mountId:i.mountId,elapsedMs:u}),$.histogram(`ok/mount/resolve-elapsed-ms`,{docName:t,mountId:i.mountId},u),a(l);let d=Date.now();tS(i.mountId,`ok.mount-promise`,{"doc.name":t,elapsed_ms:u},i.createdAt,d),nS(i.mountId,d)}function SS(e){try{let t=e.state;return Ev.getState(t)?.undoManager??null}catch(e){return $(`ok/cache/undo-manager-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}var CS=uc(`MAX_CACHE`,10),wS=uc(`VIEW_COUNT_CACHE_THRESHOLD`,50),TS=uc(`BYTES_CACHE_THRESHOLD`,8e6);function ES(e){return!(e.viewCount>0&&e.viewCount>=wS||e.bytes>TS)}var DS=new Map,OS=new Map,kS=new Map;function AS(e,t){if(kS.size>=CS){let e=kS.keys().next().value;e!==void 0&&kS.delete(e)}kS.set(e,t),$(`ok/cache/snapshot-stored`,{toDocName:e,htmlBytes:t.html.length,hasScroll:t.scrollTop>0,hasSelection:t.selection!==null})}function jS(e){return kS.get(e)??null}function MS(e){if(!kS.has(e))return;let t=kS.get(e)??null;kS.delete(e),$(`ok/cache/snapshot-consumed`,{docName:e,hit:t!==null,hasScroll:t!==null&&t.scrollTop>0,hasSelection:t!==null&&t.selection!==null})}function NS(){try{return typeof document>`u`?0:document.querySelector(`[data-testid="editor-scroll-container"]`)?.scrollTop??0}catch(e){return $(`ok/cache/snapshot-scroll-read-failed`,{message:e instanceof Error?e.message:String(e)}),0}}function PS(e){try{let t=e.state.selection;return t instanceof Ce?{type:`text`,anchor:t.anchor,head:t.head}:t instanceof I?{type:`node`,from:t.from}:null}catch(e){return $(`ok/cache/snapshot-selection-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}function FS(e){for(let t of e)try{let e=nC(t.fromDocName);if(e&&!e.editor.isDestroyed){if(e.ytext.length===0){$(`ok/cache/snapshot-skipped-empty`,{fromDocName:t.fromDocName});continue}AS(t.toDocName,{html:e.editor.getHTML(),scrollTop:NS(),selection:PS(e.editor)})}else $(`ok/cache/snapshot-skipped`,{fromDocName:t.fromDocName})}catch(e){$(`ok/cache/snapshot-capture-failed`,{fromDocName:t.fromDocName,message:e instanceof Error?e.message:String(e)})}}var IS=[],LS=[],RS=new Set;function zS(){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 BS(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!ES(i)){let e=r(n);return $(`ok/cache/miss`,{docName:t,mountId:Gx(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=DS.get(t);if(a){if($(`ok/cache/reparent-start`,{docName:t,mountId:Gx(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),JS(a,n),a.activeMountKey=t,XS(IS,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.editor.commands.focus()}catch{}return $(`ok/cache/reparent-end`,{docName:t,mountId:Gx(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),$(`ok/cache/hit`,{docName:t,mountId:Gx(t),kind:`tiptap`}),i&&$(`ok/cold/editor-mount-stats`,{docName:t,mountId:Gx(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;DS.size>=CS;){let e=ZS(IS,t);if(!e)break;HS(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 DS.set(t,s),XS(IS,t),$(`ok/cache/miss`,{docName:t,mountId:Gx(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&$(`ok/cold/editor-mount-stats`,{docName:t,mountId:Gx(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function VS(e){let t=e.activeMountKey;if(e.__uncached){t&&yS(t);let n=SS(e.editor);try{e.editor.destroy()}catch(e){$(`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=KS(e.editor);if(n){e.hadFocus=qS(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||=zS(),e.parkingNode&&e.parkingNode.appendChild(n.dom)}e.activeMountKey=null}function HS(e){yS(e);let t=DS.get(e);if(!t)return!1;let n=SS(t.editor);try{t.editor.destroy()}catch(t){$(`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){$(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){$(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}DS.delete(e);let r=IS.indexOf(e);return r!==-1&&IS.splice(r,1),$(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function US(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!ES(i)){let e=r(n);return $(`ok/cache/miss`,{docName:t,mountId:Gx(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`,kind:`cm`}),{view:e.view,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,themeCompartment:e.themeCompartment,wordWrapCompartment:e.wordWrapCompartment,placeholderCompartment:e.placeholderCompartment,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=OS.get(t);if(a){if($(`ok/cache/reparent-start`,{docName:t,mountId:Gx(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),YS(a,n),a.activeMountKey=t,XS(LS,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.view.focus()}catch{}return $(`ok/cache/reparent-end`,{docName:t,mountId:Gx(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),$(`ok/cache/hit`,{docName:t,mountId:Gx(t),kind:`cm`}),i&&$(`ok/cold/editor-mount-stats`,{docName:t,mountId:Gx(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;OS.size>=CS;){let e=ZS(LS,t);if(!e)break;GS(e)}let o=r(n),s={view:o.view,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,themeCompartment:o.themeCompartment,wordWrapCompartment:o.wordWrapCompartment,placeholderCompartment:o.placeholderCompartment,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return OS.set(t,s),XS(LS,t),$(`ok/cache/miss`,{docName:t,mountId:Gx(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&$(`ok/cold/editor-mount-stats`,{docName:t,mountId:Gx(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function WS(e){if(e.__uncached){try{e.view.destroy()}catch(t){$(`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=qS(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t),e.parkingNode||=zS(),e.parkingNode&&e.parkingNode.appendChild(t),e.activeMountKey=null}function GS(e){let t=OS.get(e);if(!t)return!1;try{t.view.destroy()}catch(t){$(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){$(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){$(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}OS.delete(e);let n=LS.indexOf(e);return n!==-1&&LS.splice(n,1),$(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function KS(e){return e.editorView??null}function qS(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function JS(e,t){let n=KS(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 YS(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function XS(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function ZS(e,t){for(let n of e)if(n!==t&&!RS.has(n))return n;$(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:RS.size});for(let n of e)if(n!==t)return n;return null}function QS(e){let t=RS,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=eC(e);if(t)try{t.disconnect(),$(`ok/cache/disconnect`,{docName:e})}catch(t){$(`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=eC(e);if(!n)continue;let r=t=>{$(`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(()=>$(`ok/cache/connect`,{docName:e}),e=>r(e)):$(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}RS=n}var $S=null;function eC(e){let t=DS.get(e);if(t)return t.provider;let n=OS.get(e);if(n)return n.provider;if($S){let t=$S.entries.get(e);if(t)return t.provider}return null}function tC(e){$S=e;let t=e.onEvict(e=>{HS(e),GS(e)});return()=>{t(),$S===e&&($S=null)}}function nC(e){return DS.get(e)}var rC=`ok-editor-tabs-v1:`,iC=`\0folder:`,aC=`\0asset:`,oC=`\0doc-tab:`,sC=/\.(md|mdx)$/i;function cC(e){let t=e.lastIndexOf(oC);return t<0?{baseTabId:e,instanceSuffix:``}:{baseTabId:e.slice(0,t),instanceSuffix:e.slice(t)}}function lC(e){return cC(e).baseTabId}function uC(e){return sC.test(e)?e.replace(sC,``):null}function dC(e){if(typeof e!=`string`||e.length===0)return!1;let t=lC(e);return t.startsWith(iC)?t.length>8:t.startsWith(aC)?t.length>7:!0}function fC(e){return e}function pC(e,t){return`${lC(e)}${oC}${t}`}function mC(e,t){return hC(e,fC(t))}function hC(e,t){let n=SC(e,2**53-1),r=lC(t);if(!n.includes(r))return r;let i=1,a;do a=pC(r,i),i++;while(n.includes(a));return a}function gC(e){return`${iC}${e}`}function _C(e){return`${aC}${e}`}function vC(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 yC(e){switch(e.kind){case`doc`:case`folder-index`:case`large-file`:return fC(e.docName);case`folder`:return gC(e.folderPath);case`missing`:return fC(e.target);case`asset`:return _C(e.assetPath)}}function bC(e){let t=lC(e);return t.startsWith(iC)?{kind:`folder`,folderPath:t.slice(8)}:t.startsWith(aC)?{kind:`asset`,assetPath:t.slice(7)}:{kind:`doc`,docName:t}}function xC(e){let t=bC(e);return t.kind===`doc`?t.docName:null}function SC(e,t){if(!Array.isArray(e)||t<=0)return[];let n=[],r=new Set;for(let i of e)if(dC(i)&&!r.has(i)&&(r.add(i),n.push(i),n.length>=t))break;return n}function CC(e,t){let n=new Set(SC(t,2**53-1));return SC(e,2**53-1).filter(e=>n.has(e))}function wC(e,t,n){if(t<=0)return[];let r=new Set(SC(n,2**53-1)),i=SC(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 TC(e,t,n){let r=CC(e,n);return!SC(n,2**53-1).includes(t)||r.includes(t)?r:[...r,t]}function EC(e,t){return SC(e,2**53-1).filter(e=>e!==t)}function DC(e,t){let n=new Set(SC(t,2**53-1));return SC(e,2**53-1).filter(e=>!n.has(e))}function OC(e,t,n){let r=SC(e,2**53-1),i=CC(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?TC(i,n,r):EC(i,n)}function kC(e,t,n,r=[]){let i=wC(e,n,r);return!dC(t)||i.includes(t)?i:wC([...i,t],n,r)}function AC(e,t,n,r,i=[]){let a=wC(e,r,i);if(!dC(n))return a;if(!t||t===n)return kC(a,n,r,i);let o=a.filter(e=>e!==n),s=o.indexOf(t);if(s<0)return kC(o,n,r,i);let c=[...o];return c[s]=n,wC(c,r,i)}function jC(e,t,n){return MC(e,fC(t),n)}function MC(e,t,{behavior:n,currentTabId:r,limit:i,pinnedTabIds:a=[]}){let o=wC(e,i,a),s=lC(t);if(r&&o.includes(r)&&lC(r)===s)return{tabs:o,activeTabId:r};if(n!==`replace-active`)return{tabs:kC(o,s,i,a),activeTabId:s};let c=hC(o,s);return{tabs:AC(o,r,c,i,a),activeTabId:c}}function NC(e,t){return e.filter(e=>e!==t)}function PC(e,t,n){let r=SC(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 FC(e,{pages:t,folderPaths:n,assetPaths:r,keepMissingDocName:i=null,keepHashDocName:a=null}){return SC(e,2**53-1).filter(e=>{let o=bC(e);return o.kind===`folder`?n.has(o.folderPath):o.kind===`asset`?r.has(o.assetPath):t.has(o.docName)||o.docName===i||o.docName===a})}function IC(e,t,n,r=[],i=[],a=[]){if(t.length===0&&r.length===0&&a.length===0)return SC(e,n);let o=new Map(t.map(e=>[e.fromDocName,e.toDocName])),s=new Map(a.flatMap(e=>{let t=uC(e.fromPath);return t?[[t,e.toPath]]:[]})),c=new Map(a.flatMap(e=>{let t=uC(e.toPath);return t?[[e.fromPath,t]]:[]})),l=e=>zC(RC(e,r),a),u=(e,t)=>{let n=o.get(e);if(n)return n;let r=s.get(e);return r?_C(r):t},d=e=>{let t=c.get(e);return t?fC(t):_C(l(e))},f=[],p=new Set;for(let t of e){let{instanceSuffix:e}=cC(t),a=bC(t),o=`${a.kind===`doc`?u(a.docName,lC(t)):a.kind===`folder`?gC(RC(a.folderPath,r)):d(a.assetPath)}${e}`;if(!p.has(o)&&(p.add(o),f.push(o),i.length===0&&f.length>=n))break}return i.length===0?f:wC(f,n,i.map(e=>{let t=bC(e);return t.kind===`doc`?u(t.docName,e):t.kind===`folder`?gC(RC(t.folderPath,r)):d(t.assetPath)}))}function LC(e,t,n=[],r=[]){return IC(e,t,2**53-1,n,[],r)}function RC(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 zC(e,t){for(let{fromPath:n,toPath:r}of t)if(e===n)return r;return e}function BC(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 VC(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 HC(e,t){if(typeof e!=`object`||!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};let n=e,r=SC(n.openTabs,2**53-1),i=CC(n.pinnedTabIds,r),a=i.length===0?SC(n.openTabs,t):wC(r,t,i),o=CC(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?bC(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 UC(e,t,n=[],r=()=>new Date){let i=SC(e,2**53-1),a=t&&i.includes(t)?t:null,o=a?bC(a):null;return{openTabs:i,pinnedTabIds:CC(n,i),activeDocName:o?.kind===`doc`?o.docName:null,activeTabId:a,updatedAt:r().toISOString()}}function WC(e){return`${rC}${e}`}function GC(e,t,n){if(!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};try{let r=e.getItem(t);return r?HC(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 KC(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 qC=Math.floor,JC=(e,t)=>e<t?e:t,YC=(e,t)=>e>t?e:t;Number.isNaN;var XC=128,ZC=1<<17,QC=1<<18,$C=1<<19,ew=1<<20,tw=1<<21,nw=1<<22,rw=1<<23,iw=1<<24,aw=1<<25,ow=1<<26,sw=1<<27,cw=1<<28,lw=1<<29,uw=1<<30,dw=127;ZC-1,QC-1,$C-1,ew-1,tw-1,nw-1,rw-1,iw-1,aw-1,ow-1,sw-1,cw-1,lw-1,uw-1;var fw=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var pw=String.fromCharCode;String.fromCodePoint,pw(65535);var mw=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},hw=typeof TextEncoder<`u`?new TextEncoder:null,gw=hw?e=>hw.encode(e):mw,_w=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});_w&&_w.decode(new Uint8Array).length===1&&(_w=null);var vw=(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},yw=(e,t)=>{for(;t>dw;)vw(e,XC|dw&t),t=qC(t/128);vw(e,dw&t)},bw=new Uint8Array(3e4),xw=bw.length/3,Sw=hw&&hw.encodeInto?(e,t)=>{if(t.length<xw){let n=hw.encodeInto(t,bw).written||0;yw(e,n);for(let t=0;t<n;t++)vw(e,bw[t])}else ww(e,gw(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;yw(e,r);for(let t=0;t<r;t++)vw(e,n.codePointAt(t))},Cw=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=JC(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(YC(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},ww=(e,t)=>{yw(e,t.byteLength),Cw(e,t)},Tw=e=>Error(e),Ew=Tw(`Unexpected end of array`),Dw=Tw(`Integer out of Range`),Ow=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},kw=e=>Ow(e,jw(e)),Aw=e=>e.arr[e.pos++],jw=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&dw)*n,n*=128,r<XC)return t;if(t>fw)throw Dw}throw Ew},Mw=_w?e=>_w.decode(kw(e)):e=>{let t=jw(e);if(t===0)return``;{let n=String.fromCodePoint(Aw(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Aw(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))}},Nw=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),Pw=(e,t)=>{yw(e,Nw.Token),Sw(e,t)},Fw=(e,t,n,r)=>{switch(jw(e)){case Nw.Token:t();break;case Nw.PermissionDenied:n(Mw(e));break;case Nw.Authenticated:r(Mw(e));break;default:}},Iw=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),Lw=`\0`;function Rw(e,t){return e+Lw+t}function zw(e){let t=e.indexOf(Lw);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var Bw=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 Vw(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 Hw(e){return new Promise(t=>setTimeout(t,e))}function Uw(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 Ww(e,t){let n=Vw(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||Uw;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 Hw(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 Hw(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await Hw(e)}return a()}var Gw=Math.floor,Kw=(e,t)=>e<t?e:t,qw=(e,t)=>e>t?e:t;Number.isNaN;var Jw=64,Yw=128,Xw=1<<17,Zw=1<<18,Qw=1<<19,$w=1<<20,eT=1<<21,tT=1<<22,nT=1<<23,rT=1<<24,iT=1<<25,aT=1<<26,oT=1<<27,sT=1<<28,cT=1<<29,lT=1<<30,uT=63,dT=127;Xw-1,Zw-1,Qw-1,$w-1,eT-1,tT-1,nT-1,rT-1,iT-1,aT-1,oT-1,sT-1,cT-1,lT-1;var fT=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var pT=()=>new Set,mT=Array.from;Array.isArray;var hT=String.fromCharCode;String.fromCodePoint,hT(65535);var gT=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},_T=typeof TextEncoder<`u`?new TextEncoder:null,vT=_T?e=>_T.encode(e):gT,yT=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});yT&&yT.decode(new Uint8Array).length===1&&(yT=null);var bT=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},xT=()=>new bT,ST=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},CT=e=>{let t=new Uint8Array(ST(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},wT=(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},TT=(e,t)=>{for(;t>dT;)wT(e,Yw|dT&t),t=Gw(t/128);wT(e,dT&t)},ET=new Uint8Array(3e4),DT=ET.length/3,OT=_T&&_T.encodeInto?(e,t)=>{if(t.length<DT){let n=_T.encodeInto(t,ET).written||0;TT(e,n);for(let t=0;t<n;t++)wT(e,ET[t])}else AT(e,vT(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;TT(e,r);for(let t=0;t<r;t++)wT(e,n.codePointAt(t))},kT=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Kw(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(qw(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},AT=(e,t)=>{TT(e,t.byteLength),kT(e,t)},jT=e=>Error(e),MT=jT(`Unexpected end of array`),NT=jT(`Integer out of Range`),PT=class{constructor(e){this.arr=e,this.pos=0}},FT=e=>new PT(e),IT=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},LT=e=>IT(e,zT(e)),RT=e=>e.arr[e.pos++],zT=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&dT)*n,n*=128,r<Yw)return t;if(t>fT)throw NT}throw MT},BT=e=>{let t=e.arr[e.pos++],n=t&uT,r=64,i=(t&Jw)>0?-1:1;if((t&Yw)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&dT)*r,r*=128,t<Yw)return i*n;if(n>fT)throw NT}throw MT},VT=yT?e=>yT.decode(LT(e)):e=>{let t=zT(e);if(t===0)return``;{let n=String.fromCodePoint(RT(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(RT(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))}},HT=e=>{let t=e.pos,n=VT(e);return e.pos=t,n},UT=Date.now,WT=()=>new Map,GT=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},KT=class{constructor(){this._observers=WT()}on(e,t){GT(this._observers,e,pT).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 mT((this._observers.get(e)||WT()).values()).forEach(e=>e(...t))}destroy(){this._observers=WT()}},qT=Symbol(`Equality`),JT=Object.keys,YT=e=>JT(e).length,XT=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ZT=(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[qT]!=null)return e[qT](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)||!ZT(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(YT(e)!==YT(t))return!1;for(let n in e)if(!XT(e,n)||!ZT(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(!ZT(e[n],t[n]))return!1;break;default:return!1}return!0},QT=3e4,$T=class extends KT{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=UT();this.getLocalState()!==null&&QT/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&QT<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&eE(this,t,`timeout`)},Gw(QT/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:UT()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),ZT(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}},eE=(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:UT()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},tE=(e,t,n=e.states)=>{let r=t.length,i=xT();TT(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;TT(i,r),TT(i,s),OT(i,JSON.stringify(o))}return CT(i)},nE=(e,t,n)=>{let r=FT(t),i=UT(),a=[],o=[],s=[],c=[],l=zT(r);for(let t=0;t<l;t++){let t=zT(r),n=zT(r),l=JSON.parse(VT(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&&(ZT(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])},rE=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={}}},iE=class{constructor(e){this.data=e,this.encoder=xT(),this.decoder=FT(new Uint8Array(this.data))}peekVarString(){return HT(this.decoder)}readVarUint(){return zT(this.decoder)}readVarString(){return VT(this.decoder)}readVarUint8Array(){return LT(this.decoder)}writeVarUint(e){return TT(this.encoder,e)}writeVarString(e){return OT(this.encoder,e)}writeVarUint8Array(e){return AT(this.encoder,e)}length(){return ST(this.encoder)}},aE=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}({}),sE=class{constructor(){this.encoder=xT()}get(e){return e.encoder}toUint8Array(){return CT(this.encoder)}},cE=class extends sE{constructor(...e){super(...e),this.type=aE.CLOSE,this.description=`Ask the server to close the connection`}get(e){return OT(this.encoder,e.documentName),TT(this.encoder,this.type),this.encoder}},lE=class e extends rE{static{this.DEDUPLICATABLE_TYPES=new Set([aE.Awareness,aE.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(cE,{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:Ww(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=UT();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===aE.Ping){this.sendPong();return}let n=new iE(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=xT();TT(e,aE.Pong),this.send(CT(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>=UT()-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=FT(e);return{documentName:VT(t),messageType:zT(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===Bw.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()}},uE=0,dE=1,fE=2,pE=(e,t)=>{TT(e,uE),AT(e,rh(t))},mE=(e,t,n)=>{TT(e,dE),AT(e,Zm(t,n))},hE=(e,t,n)=>mE(t,n,LT(e)),gE=(e,t,n,r)=>{try{Jm(t,LT(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},_E=(e,t)=>{TT(e,fE),AT(e,t)},vE=gE,yE=(e,t,n,r,i)=>{let a=zT(e);switch(a){case uE:hE(e,t,n);break;case dE:gE(e,n,r,i);break;case fE:vE(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},bE=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case aE.Sync:this.applySyncMessage(e,t);break;case aE.Awareness:this.applyAwarenessMessage(e);break;case aE.Auth:this.applyAuthMessage(e);break;case aE.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case aE.Stateless:e.receiveStateless(VT(n.decoder));break;case aE.SyncStatus:this.applySyncStatusMessage(e,BT(n.decoder)===1);break;case aE.CLOSE:let i={code:1e3,reason:VT(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(sE,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(aE.Sync);let r=yE(n.decoder,n.encoder,e.document,e);t&&r===dE&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;nE(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;Fw(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(aE.Awareness),t.writeVarUint8Array(tE(e.awareness,Array.from(e.awareness.getStates().keys())))}},xE=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return CT(this.encoder)}send(e){e?.send(this.create())}},SE=`4.0.0-rc.1`,CE=class extends sE{constructor(...e){super(...e),this.type=aE.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return OT(this.encoder,e.documentName),TT(this.encoder,this.type),Pw(this.encoder,e.token),OT(this.encoder,SE),this.encoder}},wE=class extends sE{constructor(...e){super(...e),this.type=aE.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`);OT(this.encoder,e.documentName),TT(this.encoder,this.type);let t;return t=e.states===void 0?tE(e.awareness,e.clients):tE(e.awareness,e.clients,e.states),AT(this.encoder,t),this.encoder}},TE=class extends sE{constructor(...e){super(...e),this.type=aE.Stateless,this.description=`A stateless message`}get(e){return OT(this.encoder,e.documentName),TT(this.encoder,this.type),OT(this.encoder,e.payload??``),this.encoder}},EE=class extends sE{constructor(...e){super(...e),this.type=aE.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 OT(this.encoder,e.documentName),TT(this.encoder,this.type),pE(this.encoder,e.document),this.encoder}},DE=class extends sE{constructor(...e){super(...e),this.type=aE.Sync,this.description=`A document update`}get(e){return OT(this.encoder,e.documentName),TT(this.encoder,this.type),_E(this.encoder,e.update),this.encoder}},OE=class extends Error{constructor(...e){super(...e),this.code=1001}},kE=class extends rE{get effectiveName(){return this.configuration.sessionAwareness?Rw(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 Mm,this.configuration.awareness=e.awareness===void 0?new $T(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:Iw(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:Iw(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 lE(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(EE,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&eE(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(TE,{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(CE,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(DE,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(wE,{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(EE,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(wE,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new xE(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new iE(e.data),{documentName:n}=zw(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new iE(e.data)}),new bE(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&eE(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&&(eE(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 OE(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}};function AE(e,t,n=null,r=null){let i={...lc()};return e!==null&&(i.principalId=e.principalId,i.tabSessionId=e.tabSessionId),t!==null&&t.length>0&&(i.expectedServerInstanceId=t),n!==null&&n.length>0&&(i.expectedBranch=n),r!==null&&r.length>0&&(i.expectedDocLineageEpoch=r),JSON.stringify(i)}var jE=e=>zd((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),ME=(e,t)=>zd((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(dd(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),NE=e=>jE(indexedDB.deleteDatabase(e)),PE=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),FE=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>KE(r,e))},IE=(e,t)=>jE(e.count(t)),LE=(e,t)=>jE(e.get(t)),RE=(e,t)=>jE(e.delete(t)),zE=(e,t,n)=>jE(e.put(t,n)),BE=(e,t)=>jE(e.add(t)),VE=(e,t,n)=>jE(e.getAll(t,n)),HE=(e,t,n)=>{let r=null;return GE(e,t,e=>(r=e,!1),n).then(()=>r)},UE=(e,t=null)=>HE(e,t,`prev`),WE=(e,t)=>zd((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()}}),GE=(e,t,n,r=`next`)=>WE(e.openKeyCursor(t,r),e=>n(e.key)),KE=(e,t)=>e.objectStore(t),qE=(e,t)=>IDBKeyRange.upperBound(e,t),JE=(e,t)=>IDBKeyRange.lowerBound(e,t),YE=`custom`,XE=`updates`,ZE=(e,t=()=>{},n=()=>{})=>{let[r]=FE(e.db,[XE]);return VE(r,JE(e._dbref,!1)).then(i=>{e._destroyed||(t(r),qh(e.doc,()=>{i.forEach(t=>Jm(e.doc,t))},e,!1),n(r))}).then(()=>UE(r).then(t=>{e._dbref=t+1})).then(()=>IE(r).then(t=>{e._dbsize=t})).then(()=>r)},QE=(e,t=!0)=>ZE(e).then(n=>{(t||e._dbsize>=500)&&BE(n,Zm(e.doc)).then(()=>RE(n,qE(e._dbref,!0))).then(()=>IE(n).then(t=>{e._dbsize=t}))}),$E=class extends iu{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=ME(e,e=>PE(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=zd(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,ZE(this,async e=>{await IE(e)>0&&BE(e,Zm(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]=FE(this.db,[XE]);BE(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(()=>{QE(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(()=>{NE(this.name)})}get(e){return this._db.then(t=>{let[n]=FE(t,[YE],`readonly`);return LE(n,e)})}set(e,t){return this._db.then(n=>{let[r]=FE(n,[YE]);return zE(r,t,e)})}del(e){return this._db.then(t=>{let[n]=FE(t,[YE]);return RE(n,e)})}},eD=`updates`,tD=`custom`;function nD(){return!0}var rD=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=nD()?0:performance.now();this._idb=new $E(this._dbName,r),this.whenSynced=this._idb.whenSynced.then(()=>{if(!nD()){let e=performance.now();$(`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=nD()?0:performance.now();try{await this._idb.destroy()}finally{if(!nD()){let t=performance.now();$(`ok/pool/idb-destroy`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}async flushFullState(){this._idb.db===null&&await this.whenSynced;let e=this._idb.db;if(e===null)return;let t=this._idb;await new Promise((n,r)=>{let i=e.transaction(eD,`readwrite`),a=i.objectStore(eD),o=a.getAll();o.onerror=()=>r(o.error??Error(`flushFullState getAll failed`)),o.onsuccess=()=>{try{qh(t.doc,()=>{for(let e of o.result)Jm(t.doc,e)},t,!1);let e=a.add(Zm(t.doc));e.onerror=()=>r(e.error??Error(`flushFullState add failed`)),e.onsuccess=()=>{a.delete(IDBKeyRange.upperBound(e.result,!0))}}catch(e){r(e instanceof Error?e:Error(String(e)));try{i.abort()}catch{}}},i.oncomplete=()=>n(),i.onabort=()=>r(i.error??Error(`flushFullState transaction aborted`))})}async clearData(){let e=nD()?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(!nD()){let t=performance.now();$(`ok/pool/idb-cleardata`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}};function iD(e){return new rD(e)}async function aD(e){if(typeof indexedDB>`u`)return null;let t=`ok-ydoc:${e.branch}:${e.serverInstanceId}:${e.docName}`;if(typeof indexedDB.databases==`function`&&!(await indexedDB.databases()).some(e=>e.name===t))return null;let n=await new Promise((e,n)=>{let r=indexedDB.open(t);r.onupgradeneeded=()=>{let e=r.result;e.objectStoreNames.contains(eD)||e.createObjectStore(eD,{autoIncrement:!0}),e.objectStoreNames.contains(tD)||e.createObjectStore(tD)},r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)});try{if(!n.objectStoreNames.contains(eD))return null;let e=await new Promise((e,t)=>{let r=n.transaction(eD,`readonly`).objectStore(eD).getAll();r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)});if(e.length===0)return null;let t=new Mm;try{qh(t,()=>{for(let n of e)Jm(t,n)});let n=t.getMap(`lifecycle`).get(dt);return typeof n==`string`&&n.length>0?n:null}finally{t.destroy()}}finally{n.close()}}function oD(e){return rh(e)}function sD(e,t){return t===null?Zm(e):Zm(e,t)}function cD(e,t){if(e===null)return t;if(t===null)return e;let n=$m(e),r=$m(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 rh(i)}function lD(e){let t={};if(Un.inject(Hn.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 uD=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new pt({key:e||new N(`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))}}}),dD=kt.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[uD({key:new N(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}});function fD(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||!I.isSelectable(o))return!1;try{let t=I.create(n.doc,s);return e.view.dispatch(n.tr.setSelection(t).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return G(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L0`,reason:e.message.slice(0,500)})),!0}}function pD(e){let{state:t,view:n}=e;if(!(t.selection instanceof Ce)||!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=be.findFrom(n,-1,!0);return!r||!(r instanceof Ce)?!1:(e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return G(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2c`,reason:e.message.slice(0,500)})),!0}}function mD(e,t){let{state:n,view:r}=e;if(!(n.selection instanceof Ce)||!n.selection.empty||!r.endOfTextblock(t))return!1;let i=n.selection.$head,a=t===`down`||t===`right`,o=null,s=-1;if(a){let e=i.after();if(e>=n.doc.content.size)return!1;o=n.doc.nodeAt(e),s=e}else{let e=i.before();if(e<=0||(o=n.doc.resolve(e).nodeBefore,!o))return!1;s=e-o.nodeSize}if(!o||o.type.name!==`jsxComponent`||o.childCount===0)return!1;let c=s+o.nodeSize;try{let t=a?s+1:c-1,r=be.findFrom(n.doc.resolve(t),a?1:-1,!0);return!r||!(r instanceof Ce)||r.$head.pos<=s||r.$head.pos>=c?!1:(e.view.dispatch(n.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return G(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L2d`,reason:e.message.slice(0,500)})),!0}}var hD=kt.create({name:`keyboardNav`,priority:50,addKeyboardShortcuts(){return{Escape:({editor:e})=>{let{state:t}=e;if(t.selection instanceof I){if(t.selection.$from.depth===0)return e.commands.blur(),!0;let n=t.selection.from+t.selection.node.nodeSize,r=t.doc.resolve(Math.min(n,t.doc.content.size)),i=Ce.near(r);return e.view.dispatch(t.tr.setSelection(i)),!0}return t.selection instanceof Ce?e.commands.selectParentNode():!1},ArrowUp:({editor:e})=>{if(fD(e,`up`)||pD(e)||mD(e,`up`))return!0;let{state:t}=e;if(!(t.selection instanceof I))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=I.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 G(`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(fD(e,`down`)||mD(e,`down`))return!0;let{state:t}=e;if(!(t.selection instanceof I))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=I.create(t.doc,n);return e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return G(`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})=>fD(e,`left`)||mD(e,`left`),ArrowRight:({editor:e})=>fD(e,`right`)||mD(e,`right`),Enter:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof Ce)||!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(Ce.create(s.doc,f)),e.view.dispatch(s.scrollIntoView()),!0}}}}),gD={query:``,options:{caseSensitive:!1,wholeWord:!1},activeIndex:0,matches:[]},_D=/[A-Za-z0-9_]/;function vD(e){return e!==void 0&&_D.test(e)}function yD(e,t,n){return!vD(e[t-1])&&!vD(e[n])}function bD(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||yD(e,t,s))&&a.push({start:t,end:s,text:e.slice(t,s)}),o=s}return a}function xD(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 bD(e.text,t,n))r.push({from:i+a.start,to:i+a.end,text:a.text})}),r}var SD=new N(`findReplace`);function CD(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(Math.max(Math.trunc(e),0),t-1)}function wD(e,t,n,r){let i=xD(e.doc,t,n);return{query:t,options:n,activeIndex:CD(r,i.length),matches:i}}function TD(e,t,n){return t<=0?0:(CD(e,t)+n+t)%t}function ED(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 DD(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=xD(r.doc,t.query,t.options),a=CD(0,i.length),o=i[a];return r.setMeta(SD,{type:`setActiveIndex`,activeIndex:a}),o&&r.setSelection(Ce.create(r.doc,o.from,o.to)),r.scrollIntoView()}function OD(e,t){let n=SD.getState(e)?.matches[t];return n?e.tr.setMeta(SD,{type:`setActiveIndex`,activeIndex:t}).setSelection(Ce.create(e.doc,n.from,n.to)).scrollIntoView():null}function kD(e){return SD.getState(e)??gD}function AD(){return new pt({key:SD,state:{init:()=>gD,apply(e,t,n,r){let i=e.getMeta(SD);if(i?.type===`clear`)return gD;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:[]}:wD(r,a,o,s)}},props:{decorations(e){let t=SD.getState(e);return!t||t.matches.length===0?null:q.create(e.doc,t.matches.map((e,n)=>O.inline(e.from,e.to,{class:n===t.activeIndex?`ok-find-match ok-find-match-active`:`ok-find-match`})))}}})}var jD=kt.create({name:`findReplace`,addCommands(){return{setFindQuery:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(SD,{type:`setQuery`,query:e,options:t?.options,activeIndex:t?.activeIndex})),!0),setFindOptions:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(SD,{type:`setOptions`,options:e,activeIndex:t})),!0),setActiveFindIndex:e=>({state:t,dispatch:n})=>(n&&n(t.tr.setMeta(SD,{type:`setActiveIndex`,activeIndex:e})),!0),selectNextFindMatch:()=>({state:e,dispatch:t})=>{let n=kD(e),r=OD(e,TD(n.activeIndex,n.matches.length,1));return r?(t?.(r),!0):!1},selectPreviousFindMatch:()=>({state:e,dispatch:t})=>{let n=kD(e),r=OD(e,TD(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=xD(a.doc,r.query,r.options),s=ED(o,i.from,e.length),c=o[s];return a.setMeta(SD,{type:`setActiveIndex`,activeIndex:s}),c&&a.setSelection(Ce.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=DD(t,r,e);return i?(n(i),!0):!1},clearFindMatches:()=>({state:e,dispatch:t})=>(t&&t(e.tr.setMeta(SD,{type:`clear`})),!0)}},addProseMirrorPlugins(){return[AD()]}}),MD=new WeakMap;function ND(e,t){if(t===null){MD.delete(e);return}MD.set(e,t)}function PD(e){return MD.get(e)??null}function FD(e){return`pagesBySlug`in e}function ID(e){return FD(e)?e.pages:e}function LD(e,t){return FD(e)?e.assetPaths??new Set:t??new Set}function RD(e,t){return FD(e)?e.filePaths??new Set:t??new Set}function zD(e,t){let n=wt(e);if(n){if(FD(t))return t.pagesBySlug.get(n);for(let e of t)if(wt(e)===n)return e}}function BD(e,t){if(e.includes(`/`))return;let n=wt(e);if(!n)return;if(FD(t))return t.pagesByBasename?.get(n);let r;for(let e of t){let t=e.lastIndexOf(`/`);wt(t===-1?e:e.slice(t+1))===n&&(r===void 0||e.localeCompare(r)<0)&&(r=e)}return r}function VD(e){let t=e.trim();if(!t)return null;let n=wt(t);return n?{target:n,alias:n===t?null:t,anchor:null}:null}function HD(e){let t=e.trim();if(!t)return[];let n=wt(t);return n.length>0&&n!==t?[n]:[]}function UD(e,t){let n=e.trim();if(!n)return;let r=ID(t);if(r.has(n))return n;let i=zD(n,t);if(i)return i;for(let e of HD(n))if(r.has(e))return e;return WD(n,r)||BD(n,t)}function WD(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 GD(e){let t=((e.trim().split(`#`)[0]??``).trim().split(`?`)[0]??``).trim();return t.startsWith(`/`)?t.slice(1):t}function KD(e,t,n){let r=GD(e);if(!r)return null;let i=r.toLowerCase(),a=n?[t,n]:[t];for(let e of a){if(e.has(r))return r;for(let t of e)if(t.toLowerCase()===i)return t}if(r.includes(`/`))return null;let o=[];for(let e of a)for(let t of e){let e=t.lastIndexOf(`/`);(e===-1?t:t.slice(e+1)).toLowerCase()===i&&o.push(t)}return o.length===0?null:o.sort((e,t)=>e.localeCompare(t))[0]??null}function qD(e,t,n,r){let i=e.trim();if(!i)return!1;if(KD(i,LD(t,n),RD(t,r)))return!0;let a=ID(t);return a.has(i)||HD(i).some(e=>a.has(e))||zD(i,t)!==void 0||WD(i,a)?!0:BD(i,t)!==void 0}var JD=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}},YD=new N(`imageUpload`);function XD(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?Rn._({id:`KDuPiY`,values:{fileName:n}}):Rn._({id:`bGa3Fk`})),t}var ZD=new pt({key:YD,state:{init(){return{decorations:q.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(YD);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=O.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 YD.getState(e)?.decorations??q.empty}}});function QD(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function $D(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function eO(e){return e.split(`/`).filter(e=>e!==``)}function tO(e,t){let n=QD(e),r=QD(t),i=$D(e);if(n===r)return i;let a=eO(r),o=eO(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 nO(e){return PD(e)}function rO(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 iO(e){let t=Ae(e);return t===`md`||t===`mdx`?{kind:`wiki-link`,ext:t}:se.has(t)?{kind:`jsx-img`,ext:t}:K.has(t)?{kind:`jsx-video`,ext:t}:Ee.has(t)?{kind:`jsx-audio`,ext:t}:ee.has(t)?{kind:`jsx-file`,ext:t}:b.has(t)?{kind:`wikiembed`,ext:t}:{kind:`markdown-link`,ext:t}}async function aO(e,t,n){let r=nO(t),i=r?`${r}.md`:``;if(!i){zn.error(Rn._({id:`z5pqI8`}));return}let a=crypto.randomUUID(),o=XD(e);t.view.dispatch(t.state.tr.setMeta(YD,{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),oO(t,a);return}let l;try{l=await c.json()}catch(e){console.error(`[uploadAndInsert] Response is not JSON:`,e),oO(t,a);return}if(!c.ok){let e=De.safeParse(l);if(!e.success){let n=new JD(`Upload response did not match ProblemDetails.`,{cause:e.error,status:c.status});console.error(`[uploadAndInsert] Server error (unparseable):`,n),oO(t,a);return}console.error(`[uploadAndInsert] Server error:`,e.data),oO(t,a,e.data.title);return}let u=At.safeParse(l);if(!u.success){let e=new JD(`Upload success response did not match UploadAssetSuccess.`,{cause:u.error,status:c.status});console.error(`[uploadAndInsert] Response missing src:`,e),oO(t,a);return}let d=u.data,f=d.src,p=d.deduped===!0,m=QD(i),h=typeof d.path==`string`&&d.path.length>0?d.path:m?`${m}/${f}`:f;p&&zn.info(Rn._({id:`VbqhBI`,values:{assetContentPath:h}}));let g=iO(e.name),{state:_}=t,v=YD.getState(_)?.uploads.get(a)??n,y=_.tr.setMeta(YD,{type:`remove`,id:a}),b=tO(h,i),x=`/${h}`;if(g.kind===`jsx-file`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),oO(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:ze(e.size)}}};t.chain().command(({tr:e})=>(e.setMeta(YD,{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(I.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`),oO(t,a);return}let e=rO(g.kind,x);t.chain().command(({tr:e})=>(e.setMeta(YD,{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(I.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`),oO(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`),oO(t,a);return}let r=VD(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 oO(e,t,n){e.view.dispatch(e.state.tr.setMeta(YD,{type:`remove`,id:t})),zn.error(n??Rn._({id:`b3Thhd`}))}var sO=new Set;function cO(e){sO.add(e)}function lO(e){return sO.delete(e)}var uO=new N(`markIdentity`);function dO(){return{byId:new Map,counter:0}}function fO(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&&pO(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 pO(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&&pO(n,i)))return!1}return!0}function mO(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 hO(e){let{markTypes:t,predicate:n,onRegister:r,onDeregister:i}=e,a=new Set(t);return new pt({key:uO,state:{init(e,t){return fO(t.doc,dO(),a,n)},apply(e,t,r,i){return e.docChanged?fO(i.doc,t,a,n,e.mapping):t}},view(){let e=new Set;return{update(t){let n=uO.getState(t.state);n&&(e=mO(e,n,r,i))},destroy(){for(let t of e)i?.(t);e=new Set}}}})}var gO=300,_O=150,vO=500,yO=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 bO(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 xO(e){return e?e.closest(`[data-ok-prop-panel]`)!==null:!1}function SO(){return typeof document>`u`?!1:document.querySelector(`[data-ok-layer-spawned]`)!==null}var CO=e=>{let t=(0,Z.c)(18),{store:n}=e,r;t[0]===n?r=t[1]:(r=()=>n.getSnapshot(),t[0]=n,t[1]=r);let[i,a]=(0,Q.useState)(r),o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>(a(n.getSnapshot()),n.subscribe(()=>{a(n.getSnapshot())})),s=[n],t[2]=n,t[3]=o,t[4]=s),(0,Q.useEffect)(o,s);let{active:c}=i;if(!c)return null;let l;t[5]===n?l=t[6]:(l=()=>n.setActiveNode(null),t[5]=n,t[6]=l);let u,d,f;if(t[7]!==c.controls||t[8]!==c.nodeId||t[9]!==c.type||t[10]!==l){let e={nodeId:c.nodeId,type:c.type,deactivate:l};u=c.controls.propPanel?.(e),d=c.controls.toolbar?.(e),f=c.controls.breadcrumb?.(e),t[7]=c.controls,t[8]=c.nodeId,t[9]=c.type,t[10]=l,t[11]=u,t[12]=d,t[13]=f}else u=t[11],d=t[12],f=t[13];let p;return t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,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 wO(e){return e.editorView?.dom??null}function TO(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 EO(e){let{editor:t}=e,n=new yO,r=wO(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)},gO))},m=()=>{n.getActiveNode()!==null&&o===null&&(o=setTimeout(()=>{o=null,!SO()&&n.setActiveNode(null)},_O))},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&&TO(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??wO(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=bO(e.target,n);if(t===null)return;f(),c=setTimeout(()=>{c=null,l=t,n.setActiveNode(t)},vO);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=bO(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=bO(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=bO(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(xO(r)){d();return}let i=bO(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=bO(r,n);if(o!==null){if(a&&xO(a)){d();return}if(a&&bO(a,n)===o)return;s===o&&u(),m();return}if(xO(r)){if(a&&xO(a))return;let e=n.getActiveNode();if(e!==null&&a&&bO(a,n)===e)return;m()}},E=e=>{if(g)return;let t=e.target;if(!(t instanceof Element))return;let r=bO(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&&xO(i)||i&&bO(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=wO(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 DO=e=>{let t=(0,Z.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)(CO,{store:n})}),t[0]=n,t[1]=r),r},OO=new WeakMap;function kO(e){let t=OO.get(e);if(t)return t;let n=EO({editor:e});return OO.set(e,n),e.on(`destroy`,()=>{n.destroy(),OO.delete(e)}),n}var AO={AppWindow:_i,ChevronRight:gn,CopyPlus:Mi,FileText:zi,Film:Hi,GitBranch:Gi,Image:Xi,LayoutPanelTop:Qi,MessageSquareWarning:sa,PanelTop:da,Paperclip:fa,Sigma:ba,SquarePlay:Sa,Volume2:Da,Workflow:Oa,ZoomIn:Aa};function jO(e){return e&&Object.hasOwn(AO,e)?AO[e]:xi}var MO={Info:pn,Lightbulb:$i,MessageSquareWarning:sa,AlertTriangle:bn,AlertOctagon:la,ClipboardList:ki,BookOpen:bi,ListTodo:ia,CircleCheck:Sn,CircleHelp:Di,CircleX:Oi,Zap:ka,Bug:Si,FlaskConical:Ui,Quote:ha,ChevronRight:gn},NO=Object.entries(MO).sort(([e],[t])=>e.localeCompare(t));function PO(e){if(!e||!e.startsWith(`lucide:`))return null;let t=e.slice(7);return Object.hasOwn(MO,t)?MO[t]??null:null}function FO(e){let t=(0,Z.c)(24),n;t[0]===e.icon?n=t[1]:(n=PO(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)(gn,{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 IO(e){return e!==!1}function LO(e){let t=(0,Z.c)(12),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:et(e.src),t[0]=e.src,t[1]=n);let r=e.title,i;t[2]===e.controls?i=t[3]:(i=IO(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 RO={note:pn,tip:$i,important:sa,warning:bn,caution:la,abstract:ki,info:bi,todo:ia,success:Sn,question:Di,failure:Oi,danger:ka,bug:Si,example:Ui,quote:ha};function zO(e,t){return PO(e)??RO[t]}var BO=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]);function VO(e){return typeof e==`string`&&BO.has(e)?e:`note`}function HO(e){let t=(0,Z.c)(29),n,r;t[0]!==e.icon||t[1]!==e.type?(r=VO(e.type),n=zO(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)(wi,{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 UO=(0,Q.createContext)(null);function WO(e){let t=(0,Z.c)(3),{value:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,X.jsx)(UO.Provider,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function GO(){return(0,Q.use)(UO)}var KO=[{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 qO(e){let t=(0,Z.c)(7),{targetRef:n,onResize:r,onResizeEnd:a,bounds:o}=e,{_:s}=i(),c=(0,Q.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=KO.map(e=>{let t=e.key;return(0,X.jsx)(`button`,{type:`button`,className:Ut(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 JO=`26rem`,YO=`Embedded content`,XO=/^https?:\/\//i;function ZO(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function QO(e){return!(typeof e!=`string`||!XO.test(e)||!ZO(e))}function $O(e){let t=(0,Z.c)(24),{src:n,title:r,width:i,height:a}=e,o=(0,Q.useRef)(null),s=GO(),c=i||void 0,l=a||JO,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||JO)},p=[i,a],t[3]=a,t[4]=i,t[5]=f,t[6]=p):(f=t[5],p=t[6]),(0,Q.useEffect)(f,p),!QO(n)){let e=`Embed a URL`;typeof n==`string`&&n.length>0&&(e=XO.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;t[11]===n?g=t[12]:(g=We(n),t[11]=n,t[12]=g);let _=g,v=_===n?`no-referrer`:`strict-origin-when-cross-origin`,y=r||YO,b;t[13]!==_||t[14]!==v||t[15]!==y?(b=(0,X.jsx)(`iframe`,{title:y,src:_,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation`,referrerPolicy:v,loading:`lazy`,className:`ok-embed-frame`}),t[13]=_,t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;t[17]!==s||t[18]!==h?(x=s?(0,X.jsx)(qO,{targetRef:o,bounds:{minWidth:192,maxWidth:2e3,minHeight:128,maxHeight:Math.round(window.innerHeight*.9)},onResize:e=>{let t=o.current;t&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)},onResizeEnd:h}):null,t[17]=s,t[18]=h,t[19]=x):x=t[19];let S;return t[20]!==d||t[21]!==x||t[22]!==b?(S=(0,X.jsxs)(`div`,{className:`ok-embed`,style:d,ref:o,contentEditable:!1,children:[b,x]}),t[20]=d,t[21]=x,t[22]=b,t[23]=S):S=t[23],S}function ek(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 tk(e){let t=(0,Z.c)(18),n;t[0]!==e.name||t[1]!==e.src?(n=e.name?.trim()||ek(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?et(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)(Bi,{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:nk,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 nk(e){return e.stopPropagation()}function rk(){return Q.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-unzoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Q.createElement(`path`,{d:`M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z`}))}function ik(){return Q.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-zoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Q.createElement(`path`,{d:`M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z`}))}function ak(e){return typeof Element>`u`?!1:e instanceof Element}var ok=(e,t)=>ak(t)&&t.tagName.toUpperCase()===e,sk=e=>ok(`DIV`,e)||ok(`SPAN`,e),ck=e=>ok(`IMG`,e),lk=e=>e.complete&&e.naturalHeight!==0,uk=e=>ok(`SVG`,e),dk=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),fk=({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},pk=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:i,targetWidth:a})=>e===0||t===0?1:!n&&i!==0&&a!==0?fk({containerHeight:e,containerWidth:t,offset:r,targetHeight:i,targetWidth:a}):dk({height:e,offset:r,width:t}),mk=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,hk=e=>{if(e!==null){if(ck(e))return e.currentSrc===``?void 0:e.currentSrc;if(sk(e)){let{backgroundImage:t}=window.getComputedStyle(e);if(t!==``)return mk.exec(t)?.[1]}}},gk=e=>{if(e!==null)return ck(e)?e.alt:e.getAttribute(`aria-label`)??void 0},_k=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s})=>{let c=pk({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})`}},vk=({position:e,relativeNum:t})=>{let n=parseFloat(e);return e.endsWith(`%`)?t*n/100:n},yk=({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=vk({position:p,relativeNum:r-l*f}),g=vk({position:m,relativeNum:e-c*f}),_=pk({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=vk({position:a,relativeNum:r-l}),f=vk({position:u,relativeNum:e-c}),p=pk({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=pk({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{}},bk=({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=vk({position:p,relativeNum:a-l*f}),g=vk({position:m,relativeNum:n-c*f}),_=pk({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=vk({position:t,relativeNum:a-l}),f=vk({position:u,relativeNum:n-c}),p=pk({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=vk({position:u,relativeNum:a}),p=vk({position:d,relativeNum:n}),m=f/l,h=p/c,g=Math.min(m,h),[_=`50%`,v=`50%`]=e.split(` `),y=vk({position:_,relativeNum:a-l*g}),b=vk({position:v,relativeNum:n-c*g}),x=pk({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})`}}},xk=/\.svg$/i,Sk=({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&&xk.test(t),l=s.getBoundingClientRect(),u=window.getComputedStyle(s),d=i!=null&&sk(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=_k({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}),g=f?yk({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?bk({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},Ck=e=>{if(e==null)return{};if(uk(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}},wk=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}`)}})})},Tk=[`img`,`svg`,`[role="img"]`,`[data-zoom]`].map(e=>`${e}:not([aria-hidden="true"])`).join(`,`),Ek={overflow:``,width:``};function Dk(){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 Ok(e){e.preventDefault()}function kk(e){return Q.createElement(Ak,{...e})}var Ak=class extends Q.Component{constructor(){super(...arguments),this.state={id:``,isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:`UNLOADED`,shouldRefresh:!1,styleGhost:{}},this.refContent=Q.createRef(),this.refDialog=Q.createRef(),this.refModalContent=Q.createRef(),this.refModalImg=Q.createRef(),this.refWrap=Q.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=Ek,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(Tk),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:Ck(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver??(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:Ck(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=hk(this.imgEl);if(e==null||e===``)return;let t=new Image,{imgEl:n}=this;if(ck(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:Ck(this.imgEl)})};t.decode().then(r).catch(()=>{if(lk(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||uk(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=Ek},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(lk(n)){r();return}n.onload=r})}},this.UNSAFE_handleSvg=()=>{let{imgEl:e,refModalImg:t,styleModalImg:n}=this;if(uk(e)){let r=e.cloneNode(!0);wk(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=sk(a),j=ck(a),M=uk(a),N=gk(a),P=hk(a),F=j?a.sizes:void 0,I=j?a.srcset:void 0,L=j?a.crossOrigin:void 0,R=h?.src!==void 0&&h.src!==``,z=this.hasImage(),B=N!==void 0&&N!==``?`${s}: ${N}`:s,ee=T===`LOADING`||T===`LOADED`,V=z?`found`:`not-found`,te=T===`UNLOADED`||T===`UNLOADING`?`hidden`:`visible`,H={visibility:T===`UNLOADED`?`visible`:`hidden`};this.styleModalImg=z&&a!==null?Sk({hasZoomImg:R,imgSrc:P,isSvg:M,isZoomed:f&&ee,loadedImgEl:w,offset:g,shouldRefresh:E,targetEl:a}):{};let U=null;if(z){let t=j||A?Q.createElement(`img`,{alt:N,crossOrigin:L,sizes:F,src:P,srcSet:I,...C&&T===`LOADED`?h:{},"data-rmiz-modal-img":``,height:this.styleModalImg.height??void 0,id:k,ref:b,style:this.styleModalImg,width:this.styleModalImg.width??void 0}):M?Q.createElement(`div`,{"data-rmiz-modal-img":!0,ref:b,style:this.styleModalImg}):null,n=Q.createElement(`button`,{"aria-label":o,"data-rmiz-btn-unzoom":``,onClick:e,type:`button`},Q.createElement(u,null));U=m==null?Q.createElement(Q.Fragment,null,t,n):Q.createElement(m,{buttonUnzoom:n,modalState:T,img:t,isZoomImgLoaded:C,onUnzoom:r})}return Q.createElement(p,{"aria-owns":z?O:void 0,"data-rmiz":``,ref:x},Q.createElement(p,{"data-rmiz-content":V,ref:_,style:H},c),z&&Q.createElement(p,{"data-rmiz-ghost":``,style:D},Q.createElement(`button`,{"aria-label":B,"data-rmiz-btn-zoom":``,onClick:i,type:`button`},Q.createElement(d,null))),z&&Ma.createPortal(Q.createElement(`dialog`,{"aria-labelledby":k,"aria-modal":`true`,className:l,"data-rmiz-modal":``,id:O,onClick:t,onClose:n,onCancel:Ok,ref:v,role:`dialog`},Q.createElement(`div`,{"data-rmiz-modal-overlay":te}),Q.createElement(`div`,{"data-rmiz-modal-content":``,ref:y},U)),Dk()))}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)}};Ak.defaultProps={a11yNameButtonUnzoom:`Minimize image`,a11yNameButtonZoom:`Expand image`,canSwipeToUnzoom:!0,IconUnzoom:rk,IconZoom:ik,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:`div`,zoomMargin:0};function jk({onZoomChange:e,...t}){let[n,r]=Q.useState(!1),i=Q.useCallback((t,{event:n})=>{r(t),e?.(t,{event:n})},[e]);return Q.createElement(kk,{...t,isZoomed:n,onZoomChange:i})}function Mk(e,t){return typeof e==`number`&&typeof t==`number`&&e>0&&t>0}function Nk(e,t,n){return Mk(e,t)?{...n,width:`${e}px`,aspectRatio:`${e} / ${t}`}:n}function Pk(e){let t=(0,Z.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,Q.useRef)(null),[b,x]=(0,Q.useState)(!1),S;t[13]!==r||t[14]!==m?(S=Mk(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=Nk(m,r,u),t[16]=r,t[17]=u,t[18]=m,t[19]=w):w=t[19];let T=w,E;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{y.current?.complete?x(!0):x(!1)},t[20]=E):E=t[20];let D;t[21]===l?D=t[22]:(D=[l],t[21]=l,t[22]=D),(0,Q.useLayoutEffect)(E,D);let O=!C&&!b&&`aspect-[16/9] w-full max-w-full`,k;t[23]!==c||t[24]!==O?(k=Ut(`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=Ut(`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 Fk(e){return e??`lazy`}function Ik(e){if(typeof e!=`string`)return e;let t=Number(e);return Number.isFinite(t)&&t>0?t:e}function Lk(e){let t=(0,Z.c)(21),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:et(e.src),t[0]=e.src,t[1]=n);let r=e.alt??``,i;t[2]===e.width?i=t[3]:(i=Ik(e.width),t[2]=e.width,t[3]=i);let a;t[4]===e.height?a=t[5]:(a=Ik(e.height),t[4]=e.height,t[5]=a);let o=e.title,s;t[6]===e.loading?s=t[7]:(s=Fk(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)(Pk,{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 Rk(e){let t=(0,Z.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)(jk,{wrapElement:`span`,zoomMargin:20,zoomImg:n,children:(0,X.jsx)(Lk,{...e})}),t[1]=e,t[2]=r),r}var zk=(0,Q.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-DBuiuHex.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,Z.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 Bk(e){let t=(0,Z.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 Vk(e){let t=(0,Z.c)(6),n=e.formula??``;if(!n){let r;return t[0]!==n||t[1]!==e.id?(r=(0,X.jsx)(Bk,{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)(Q.Suspense,{fallback:(0,X.jsx)(Bk,{formula:n,id:e.id}),children:(0,X.jsx)(zk,{formula:n,id:e.id})}),t[3]=n,t[4]=e.id,t[5]=r):r=t[5],r}var Hk=null;function Uk(){return Hk||=n(()=>import(`./mermaid.core-srYvzXpO.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 Hk=null,e}),Hk}function Wk(e){let t=(0,Z.c)(24),n=e.chart??``,r=(0,Q.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,Q.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(Gk),Uk().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,Q.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)(bn,{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 Gk(e){return{...e,status:`rendering`}}var Kk=null;function qk(){return Kk||=new ge({extensions:yt}),Kk}function Jk(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=Jk(e,t);if(n)return n}return null}function Yk(e){return ce({type:`root`,children:e.children??[]})}var Xk=new Map,Zk=30,Qk=150,$k=1e4;function eA(e,t){let n=`${e}|${t}`,r=Xk.get(n);if(r)return r.refcount+=1,r;let i=new Mm,a=new kE({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()}),Xk.set(n,s),Xk.size>Zk&&console.warn(`[Mirror] provider pool exceeded ${Zk} entries (current=${Xk.size}). Many Mirrors pointing at distinct source docs — investigate if this is a runaway pattern.`),s}function tA(e,t){let n=`${e}|${t}`,r=Xk.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})}Xk.delete(n)}}function nA(e,t){let n=(0,Z.c)(8),{collabUrl:r}=Mx(),i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={kind:`loading`},n[0]=i):i=n[0];let[a,o]=(0,Q.useState)(i),s=(0,Q.useRef)(t),c=(0,Q.useRef)(null),l,u;n[1]!==r||n[2]!==e?(l=()=>{if(!e){o({kind:`empty-props`});return}if(!r){o({kind:`loading`});return}let t=eA(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=qk().parseToMdast(r)}catch(t){console.warn(`[Mirror] parseToMdast failed`,{src:e,anchor:n,err:t}),o({kind:`source-removed`});return}let a=Jk(i,n);if(!a){o({kind:`anchor-not-found`});return}let c;try{c=Yk(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()},Qk)},onSynced:()=>{i&&=(clearTimeout(i),null),n()}};t.subscribers.add(a),c.current=n;let l=setTimeout(()=>{t.synced||o({kind:`source-removed`})},$k);return n(),()=>{clearTimeout(l),i&&clearTimeout(i),t.subscribers.delete(a),c.current=null,tA(r,e)}},u=[r,e],n[1]=r,n[2]=e,n[3]=l,n[4]=u):(l=n[3],u=n[4]),(0,Q.useEffect)(l,u);let d,f;return n[5]===t?(d=n[6],f=n[7]):(d=()=>{s.current=t,c.current?.()},f=[t],n[5]=t,n[6]=d,n[7]=f),(0,Q.useEffect)(d,f),a}function rA(e){let t=(0,Z.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)(ea,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}):(0,X.jsx)(na,{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 iA(e){let t=(0,Z.c)(30),n=e.src??``,r=e.anchor??``,i=nA(n,r);if(i.kind===`empty-props`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(rA,{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)(rA,{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)(rA,{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)(rA,{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)(Ni,{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 aA(e){let t=(0,Z.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)(Mi,{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 oA=24,sA=24,cA=12,lA=.1;function uA(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(lA,(n-oA)/t.naturalWidth);case`fit-height`:return Math.max(lA,(r-sA)/t.naturalHeight);case`single`:return 1;case`two-odd`:case`two-even`:return Math.max(lA,((n-oA)/2-cA)/t.naturalWidth)}}var dA=600,fA=.5,pA=3,mA=.25,hA=null;function gA(){return hA||(hA=(async()=>{let e=await n(()=>import(`./pdf-CQwfdc8y.js`),__vite__mapDeps([24,1]),import.meta.url);if(!e.GlobalWorkerOptions.workerSrc){let t=(await n(async()=>{let{default:e}=await import(`./pdf.worker-aWVFMfr5.js`);return{default:e}},[],import.meta.url)).default;e.GlobalWorkerOptions.workerSrc=t}return e})(),hA.catch(()=>{hA=null})),hA}function _A(e){return e instanceof Error&&e.name===`RenderingCancelledException`}function vA(e){let t=(0,Z.c)(96),n,r;if(t[0]!==e.anchor||t[1]!==e.fillContainer){let{height:i,viewerFragment:a}=Se(e.anchor);n=i===null?e.fillContainer?`100%`:`${dA}px`:`${i}px`,r=wA(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,Q.useRef)(null),c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[4]=c):c=t[4];let l=(0,Q.useRef)(c),u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[5]=u):u=t[5];let d=(0,Q.useRef)(u),f=(0,Q.useRef)(null),p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[6]=p):p=t[6];let[m,h]=(0,Q.useState)(p),[g,_]=(0,Q.useState)(!0),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(a??1),[S,C]=(0,Q.useState)(String(a??1)),[w,T]=(0,Q.useState)(1),[E,D]=(0,Q.useState)(`fit-width`),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(0),[P,F]=(0,Q.useState)(0),{_:I}=i(),L=m.length,R,z;t[7]!==I||t[8]!==e.src?(R=()=>{if(!e.src){_(!1);return}let t=et(e.src),n=!1,r=null;return _(!0),y(null),(async()=>{try{let e=await(await gA()).getDocument({url:t,isEvalSupported:!1}).promise;if(n){await e.destroy();return}r=e,f.current=e;let i=[];for(let t=1;t<=e.numPages;t++){if(n)return;let r=(await e.getPage(t)).getViewport({scale:1});i.push({pageNumber:t,naturalWidth:r.width,naturalHeight:r.height})}if(n)return;h(i)}catch(e){let t=e;if(n)return;y(t instanceof Error?t.message:I({id:`jRHdCz`})),_(!1)}})(),()=>{n=!0,r&&=(r.destroy(),null),f.current=null}},z=[e.src,I],t[7]=I,t[8]=e.src,t[9]=R,t[10]=z):(R=t[9],z=t[10]),(0,Q.useEffect)(R,z);let B,ee;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{let e=s.current;if(!e)return;let t=()=>{N(e.clientWidth),F(e.clientHeight)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},ee=[],t[11]=B,t[12]=ee):(B=t[11],ee=t[12]),(0,Q.useEffect)(B,ee);let V,te;t[13]!==I||t[14]!==P||t[15]!==M||t[16]!==E||t[17]!==m||t[18]!==w?(V=()=>{let e=f.current;if(!e||m.length===0||M===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of m){if(t)return;let a=l.current[i.pageNumber-1];if(!a)continue;let o=uA(E,i,M,P)*w,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let u=a.getContext(`2d`);u&&(u.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:u,viewport:c}),await n.promise,n=null)}t||_(!1)}catch(e){let n=e;if(t||_A(n))return;console.warn(`[Pdf] page render failed:`,n),y(n instanceof Error?n.message:I({id:`_TF8ep`})),_(!1)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},te=[m,E,w,M,P,I],t[13]=I,t[14]=P,t[15]=M,t[16]=E,t[17]=m,t[18]=w,t[19]=V,t[20]=te):(V=t[19],te=t[20]),(0,Q.useEffect)(V,te);let H,U;t[21]!==m||t[22]!==O?(H=()=>{if(!O)return;let e=f.current;if(!e||m.length===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of m){if(t)return;let a=d.current[i.pageNumber-1];if(!a)continue;let o=120/i.naturalWidth,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let l=a.getContext(`2d`);l&&(l.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:l,viewport:c}),await n.promise,n=null)}}catch(e){let t=e;_A(t)||console.warn(`[Pdf] thumbnail render failed:`,t)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},U=[O,m],t[21]=m,t[22]=O,t[23]=H,t[24]=U):(H=t[23],U=t[24]),(0,Q.useEffect)(H,U);let ne,W;t[25]!==g||t[26]!==a?(ne=()=>{if(g||!a)return;let e=s.current,t=l.current[a-1];e&&t&&(e.scrollTop=t.offsetTop-e.offsetTop)},W=[g,a],t[25]=g,t[26]=a,t[27]=ne,t[28]=W):(ne=t[27],W=t[28]),(0,Q.useEffect)(ne,W);let re,G;t[29]===m?(re=t[30],G=t[31]):(re=()=>{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)}x(r),C(String(r))}))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},G=[m],t[29]=m,t[30]=re,t[31]=G),(0,Q.useEffect)(re,G);let ie,ae;t[32]===A?(ie=t[33],ae=t[34]):(ie=()=>{if(!A)return;let e=e=>{let t=e.target,n=s.current?.closest(`.ok-pdf`);if(!n||!t||!n.contains(t)){j(!1);return}let r=n.querySelector(`.ok-pdf-layout-menu`);r&&!r.contains(t)&&j(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},ae=[A],t[32]=A,t[33]=ie,t[34]=ae),(0,Q.useEffect)(ie,ae);let oe;t[35]===L?oe=t[36]:(oe=e=>{let t=Math.max(1,Math.min(L||1,e));x(t),C(String(t));let n=s.current,r=l.current[t-1];n&&r&&n.scrollTo({top:r.offsetTop-n.offsetTop,behavior:`smooth`})},t[35]=L,t[36]=oe);let K=oe,se;t[37]!==b||t[38]!==K||t[39]!==S?(se=()=>{let e=Number.parseInt(S,10);if(Number.isNaN(e)){C(String(b));return}K(e)},t[37]=b,t[38]=K,t[39]=S,t[40]=se):se=t[40];let ce=se,q;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(q=()=>T(SA),t[41]=q):q=t[41];let le=q,ue;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>T(xA),t[42]=ue):ue=t[42];let de=ue,fe;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>{D(e),j(!1),T(1)},t[43]=fe):fe=t[43];let pe=fe,me;t[44]===n?me=t[45]:(me={height:n},t[44]=n,t[45]=me);let he;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(he=()=>k(bA),t[46]=he):he=t[46];let ge;t[47]!==I||t[48]!==O?(ge=I(O?{id:`JK-Ave`}:{id:`iEYxO4`}),t[47]=I,t[48]=O,t[49]=ge):ge=t[49];let _e;t[50]===I?_e=t[51]:(_e=I({id:`zo3Dl7`}),t[50]=I,t[51]=_e);let ve;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,X.jsx)(ua,{size:14,"aria-hidden":`true`}),t[52]=ve):ve=t[52];let ye;t[53]!==O||t[54]!==ge||t[55]!==_e?(ye=(0,X.jsx)(`button`,{type:`button`,onClick:he,"aria-label":ge,"aria-pressed":O,className:`ok-pdf-btn`,title:_e,children:ve}),t[53]=O,t[54]=ge,t[55]=_e,t[56]=ye):ye=t[56];let be=e.title??`PDF`,xe;t[57]===be?xe=t[58]:(xe=(0,X.jsx)(`span`,{className:`ok-pdf-title`,children:be}),t[57]=be,t[58]=xe);let Ce;t[59]!==I||t[60]!==A||t[61]!==E||t[62]!==S||t[63]!==ce||t[64]!==L||t[65]!==w?(Ce=L>0&&(0,X.jsxs)(`div`,{className:`ok-pdf-controls`,children:[(0,X.jsx)(`form`,{className:`ok-pdf-page-form`,onSubmit:e=>{e.preventDefault(),ce()},children:(0,X.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,className:`ok-pdf-page-input`,value:S,onChange:e=>C(e.target.value.replace(/[^0-9]/g,``)),onBlur:ce,"aria-label":I({id:`xsZhu-`})})}),(0,X.jsx)(`span`,{className:`ok-pdf-page-of`,children:(0,X.jsx)(o,{id:`1GhYxC`,values:{totalPages:L}})}),(0,X.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{type:`button`,onClick:de,disabled:w<=fA,"aria-label":I({id:`FjkaiT`}),className:`ok-pdf-btn`,title:I({id:`FjkaiT`}),children:(0,X.jsx)(ja,{size:14,"aria-hidden":`true`})}),(0,X.jsxs)(`span`,{className:`ok-pdf-zoom-display`,"aria-live":`polite`,children:[Math.round(w*100),`%`]}),(0,X.jsx)(`button`,{type:`button`,onClick:le,disabled:w>=pA,"aria-label":I({id:`AWOSPo`}),className:`ok-pdf-btn`,title:I({id:`AWOSPo`}),children:(0,X.jsx)(Aa,{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:()=>j(yA),"aria-label":I({id:`GQDSBN`}),"aria-haspopup":`menu`,"aria-expanded":A,className:`ok-pdf-btn`,title:I({id:`rdU729`}),children:(0,X.jsx)(wi,{size:14,"aria-hidden":`true`})}),A&&(0,X.jsxs)(`div`,{role:`menu`,className:`ok-pdf-menu`,children:[(0,X.jsx)(CA,{label:I({id:`vIxrEk`}),active:E===`fit-width`,onSelect:()=>pe(`fit-width`)}),(0,X.jsx)(CA,{label:I({id:`YlDuro`}),active:E===`fit-height`,onSelect:()=>pe(`fit-height`)}),(0,X.jsx)(`hr`,{className:`ok-pdf-menu-divider`}),(0,X.jsx)(CA,{label:I({id:`BGHHtQ`}),active:E===`single`,onSelect:()=>pe(`single`)}),(0,X.jsx)(CA,{label:I({id:`xK291b`}),active:E===`two-odd`,onSelect:()=>pe(`two-odd`)}),(0,X.jsx)(CA,{label:I({id:`NSnIUP`}),active:E===`two-even`,onSelect:()=>pe(`two-even`)})]})]})]}),t[59]=I,t[60]=A,t[61]=E,t[62]=S,t[63]=ce,t[64]=L,t[65]=w,t[66]=Ce):Ce=t[66];let we;t[67]!==ye||t[68]!==xe||t[69]!==Ce?(we=(0,X.jsxs)(`div`,{className:`ok-pdf-toolbar`,contentEditable:!1,children:[ye,xe,Ce]}),t[67]=ye,t[68]=xe,t[69]=Ce,t[70]=we):we=t[70];let Te;t[71]!==I||t[72]!==b||t[73]!==K||t[74]!==m||t[75]!==O?(Te=O&&(0,X.jsx)(`aside`,{className:`ok-pdf-sidebar`,"aria-label":I({id:`nzaV6Q`}),children:m.map((e,t)=>{let{pageNumber:n}=e;return(0,X.jsxs)(`button`,{type:`button`,className:`ok-pdf-thumb`,"data-active":b===n||void 0,onClick:()=>K(n),"aria-label":I({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]=I,t[72]=b,t[73]=K,t[74]=m,t[75]=O,t[76]=Te):Te=t[76];let Ee;t[77]===g?Ee=t[78]:(Ee=g&&(0,X.jsx)(`div`,{className:`ok-pdf-loading`,children:(0,X.jsx)(o,{id:`T-654M`})}),t[77]=g,t[78]=Ee);let De;t[79]===v?De=t[80]:(De=v&&(0,X.jsx)(`div`,{className:`ok-pdf-error`,children:(0,X.jsx)(o,{id:`WamGNs`,values:{error:v}})}),t[79]=v,t[80]=De);let Oe;t[81]!==I||t[82]!==L?(Oe=Array.from({length:L},(e,t)=>{let n=t+1;return(0,X.jsx)(`canvas`,{ref:e=>{l.current[t]=e},className:`ok-pdf-page`,"aria-label":I({id:`XtRoxT`,values:{pageNumber:n}})},n)}),t[81]=I,t[82]=L,t[83]=Oe):Oe=t[83];let ke;t[84]!==E||t[85]!==Ee||t[86]!==De||t[87]!==Oe?(ke=(0,X.jsxs)(`div`,{className:`ok-pdf-pages`,ref:s,"data-layout":E,children:[Ee,De,Oe]}),t[84]=E,t[85]=Ee,t[86]=De,t[87]=Oe,t[88]=ke):ke=t[88];let Ae;t[89]!==Te||t[90]!==ke?(Ae=(0,X.jsxs)(`div`,{className:`ok-pdf-body`,children:[Te,ke]}),t[89]=Te,t[90]=ke,t[91]=Ae):Ae=t[91];let je;return t[92]!==me||t[93]!==we||t[94]!==Ae?(je=(0,X.jsxs)(`div`,{className:`ok-pdf`,style:me,children:[we,Ae]}),t[92]=me,t[93]=we,t[94]=Ae,t[95]=je):je=t[95],je}function yA(e){return!e}function bA(e){return!e}function xA(e){return Math.max(fA,+(e-mA).toFixed(2))}function SA(e){return Math.min(pA,+(e+mA).toFixed(2))}function CA(e){let t=(0,Z.c)(10),n=e.active||void 0,r;t[0]===e.active?r=t[1]:(r=e.active&&(0,X.jsx)(fn,{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 wA(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 TA(e){let t=(0,Z.c)(10),{label:n,id:r,children:i}=e,a=(0,Q.useId)(),o;t[0]!==r||t[1]!==a?(o=r||`tab-panel-${a.replace(/:/g,``)}`,t[0]=r,t[1]=a,t[2]=o):o=t[2];let s=o,c=`${s}-tab`,l;t[3]===n?l=t[4]:(l=n?.trim()||`Tab`,t[3]=n,t[4]=l);let u=l,d;return t[5]!==i||t[6]!==s||t[7]!==u||t[8]!==c?(d=(0,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 EA=`:scope > .component-children > [data-node-view-content-react] > .react-renderer`;function DA(e){return Array.from(e.querySelectorAll(EA)).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 OA(e,t){let n=Array.from(e.querySelectorAll(EA))[t];return n?n.querySelector(`[data-jsx-gear]`):null}function kA(e){let t=(0,Z.c)(31),{id:n,children:r}=e,[a,o]=(0,Q.useState)(0),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Q.useState)(s),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(0),p=GO(),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=DA(e);l(e=>{if(e.length!==t.length)return t;for(let n=0;n<e.length;n++)if(e[n].label!==t[n].label||e[n].panelId!==t[n].panelId)return t;return e})},t[1]=g):g=t[1],(0,Q.useLayoutEffect)(g);let _,v;t[2]===c.length?(_=t[3],v=t[4]):(_=()=>{c.length>f.current&&c.length>0&&o(c.length-1),f.current=c.length},v=[c.length],t[2]=c.length,t[3]=_,t[4]=v),(0,Q.useLayoutEffect)(_,v);let y;t[5]===n?y=t[6]:(y=()=>{let e=()=>{let e=window.location.hash.slice(1);if(!e)return;if(n&&e===n){o(0);return}let t=u.current;if(!t)return;let r=DA(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,Q.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;t[10]!==c||t[11]!==b?(w=c.map(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:jA,onClick:()=>{if(e.index!==b){o(e.index);return}let t=u.current;t&&OA(t,e.index)?.click()},children:e.label},e.index)),t[10]=c,t[11]=b,t[12]=w):w=t[12];let T;t[13]!==S||t[14]!==C||t[15]!==w?(T=(0,X.jsx)(`div`,{ref:d,role:`tablist`,"aria-label":C,className:`tabs-tablist`,onKeyDown:S,children:w}),t[13]=S,t[14]=C,t[15]=w,t[16]=T):T=t[16];let E;t[17]!==h||t[18]!==m||t[19]!==p?(E=m&&(0,X.jsx)(`button`,{type:`button`,className:`tabs-strip-add`,"aria-label":h({id:`hjO0Mq`}),title:h({id:`hjO0Mq`}),onMouseDown:AA,onClick:()=>p?.addChild?.(),"data-tabs-strip-add":``,children:`+`}),t[17]=h,t[18]=m,t[19]=p,t[20]=E):E=t[20];let D;t[21]!==E||t[22]!==T?(D=(0,X.jsxs)(`div`,{className:`tabs-strip`,contentEditable:!1,children:[T,E]}),t[21]=E,t[22]=T,t[23]=D):D=t[23];let O;t[24]!==r||t[25]!==b?(O=(0,X.jsx)(`div`,{ref:u,className:`tabs-content`,"data-active-index":b,children:r}),t[24]=r,t[25]=b,t[26]=O):O=t[26];let k;return t[27]!==n||t[28]!==D||t[29]!==O?(k=(0,X.jsxs)(`div`,{className:`tabs`,id:n,children:[D,O]}),t[27]=n,t[28]=D,t[29]=O,t[30]=k):k=t[30],k}function AA(e){return e.preventDefault()}function jA(e){return e.preventDefault()}var MA=typeof global<`u`&&{}.toString.call(global)===`[object global]`,NA=typeof Bun<`u`,PA=typeof Deno<`u`,FA=typeof WebSocketPair==`function`&&caches?.default!==void 0,IA=MA||NA||PA||FA;function LA(e,t){return e.indexOf(t.toLowerCase())===0?e:`${t.toLowerCase()}${e.substr(0,1).toUpperCase()}${e.substr(1)}`}function RA(e){return!!(e&&e.nodeType===1&&`nodeName`in e&&e.ownerDocument&&e.ownerDocument.defaultView)}function zA(e){return!isNaN(parseFloat(e))&&isFinite(e)&&Math.floor(e)==e}function BA(e){return/^(https?:)?\/\/((((player|www)\.)?vimeo\.com)|((player\.)?[a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))(?=$|\/)/.test(e)}function VA(e){return/^https:\/\/player\.((vimeo\.com)|([a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))\/video\/\d+/.test(e)}function HA(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 UA(){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(zA(r))return`https://vimeo.com/${r}`;if(BA(r))return r.replace(`http:`,`https:`);throw TypeError(t?`“${t}” is not a valid video id.`:`“${r}” is not a vimeo.com url.`)}var WA=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 GA(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 KA=Array.prototype.indexOf!==void 0,qA=typeof window<`u`&&window.postMessage!==void 0;if(!IA&&(!KA||!qA))throw Error(`Sorry, the Vimeo Player API is not available in this browser.`);var JA=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function YA(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:JA);var XA=YA(function(e){(function(t,n,r){n[t]=n[t]||r(),e.exports&&=n[t]})(`Promise`,JA,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})}),ZA=new WeakMap;function QA(e,t,n){let r=ZA.get(e.element)||{};t in r||(r[t]=[]),r[t].push(n),ZA.set(e.element,r)}function $A(e,t){return(ZA.get(e.element)||{})[t]||[]}function ej(e,t,n){let r=ZA.get(e.element)||{};if(!r[t])return!0;if(!n)return r[t]=[],ZA.set(e.element,r),!0;let i=r[t].indexOf(n);return i!==-1&&r[t].splice(i,1),ZA.set(e.element,r),r[t]&&r[t].length===0}function tj(e,t){let n=$A(e,t);if(n.length<1)return!1;let r=n.shift();return ej(e,t,r),r}function nj(e,t){let n=ZA.get(e);ZA.set(t,n),ZA.delete(e)}function rj(e){if(typeof e==`string`)try{e=JSON.parse(e)}catch(e){return console.warn(e),{}}return e}function ij(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 aj(e,t){t=rj(t);let n=[],r;if(t.event)t.event===`error`&&$A(e,t.data.method).forEach(n=>{let r=Error(t.data.message);r.name=t.data.name,n.reject(r),ej(e,t.data.method,n)}),n=$A(e,`event:${t.event}`),r=t.data;else if(t.method){let i=tj(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 oj=`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 sj(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return oj.reduce((t,n)=>{let r=e.getAttribute(`data-vimeo-${n}`);return(r||r===``)&&(t[n]=r===``?1:r),t},t)}function cj(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 lj(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(!BA(e))throw TypeError(`“${e}” is not a vimeo.com url.`);let a=`https://${HA(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){cj(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 uj(){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=sj(e);lj(UA(t),t,e).then(t=>cj(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(!BA(t.origin)||!t.data||t.data.event!==`spacechange`)return;let n=t.source?GA(t.source,e):null;if(n){let e=n.parentElement;e.style.paddingBottom=`${t.data.data[0].bottom}px`}}))}function fj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoSeoMetadataAppended||(window.VimeoSeoMetadataAppended=!0,window.addEventListener(`message`,t=>{if(!BA(t.origin))return;let n=rj(t.data);if(!n||n.event!==`ready`)return;let r=t.source?GA(t.source,e):null;r&&VA(r.src)&&new xj(r).callMethod(`appendVideoMetadata`,window.location.href)}))}function pj(){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(!BA(n.origin))return;let r=rj(n.data);if(!r||r.event!==`ready`)return;let i=n.source?GA(n.source,e):null;if(i&&VA(i.src)){let e=new xj(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 mj(){window.VimeoDRMEmbedsUpdated||(window.VimeoDRMEmbedsUpdated=!0,window.addEventListener(`message`,e=>{if(!BA(e.origin))return;let t=rj(e.data);if(!t||t.event!==`drminitfailed`)return;let n=e.source?GA(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 hj(){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 gj={role:`viewer`,autoPlayMuted:!0,allowedDrift:.3,maxAllowedDrift:1,minCheckInterval:.1,maxRateAdjustment:.2,maxTimeToCatchUp:1},_j=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,{...gj,...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=WA(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=WA(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()})}},vj=new WeakMap,yj=new WeakMap,bj={},xj=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)),!RA(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`&&!BA(e.getAttribute(`src`)||``))throw Error(`The player element passed isn’t a Vimeo embed.`);if(vj.has(e))return vj.get(e);this._window=e.ownerDocument.defaultView,this.element=e,this.origin=`*`;let n=new XA((n,r)=>{if(this._onMessage=e=>{if(!BA(e.origin)||this.element.contentWindow!==e.source)return;this.origin===`*`&&(this.origin=e.origin);let t=rj(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}aj(this,t)},this._window.addEventListener(`message`,this._onMessage),this.element.nodeName!==`IFRAME`){let n=sj(e,t);lj(UA(n),n,e).then(t=>{let n=cj(t,e);return this.element=n,this._originalElement=e,nj(e,n),vj.set(this.element,this),t}).catch(r)}});if(yj.set(this,n),vj.set(this.element,this),this.element.nodeName===`IFRAME`&&ij(this,`ping`),bj.isEnabled){let e=()=>bj.exit();this.fullscreenchangeHandler=()=>{bj.isFullscreen?QA(this,`event:exitFullscreen`,e):ej(this,`event:exitFullscreen`,e),this.ready().then(()=>{ij(this,`fullscreenchange`,bj.isFullscreen)})},bj.on(`fullscreenchange`,this.fullscreenchangeHandler)}return this}static isVimeoUrl(e){return BA(e)}callMethod(e){var t=[...arguments].slice(1);if(e==null)throw TypeError(`You must pass a method name.`);return new XA((n,r)=>this.ready().then(()=>{QA(this,e,{resolve:n,reject:r}),t.length===0?t={}:t.length===1&&(t=t[0]),ij(this,e,t)}).catch(r))}get(e){return new XA((t,n)=>(e=LA(e,`get`),this.ready().then(()=>{QA(this,e,{resolve:t,reject:n}),ij(this,e)}).catch(n)))}set(e,t){return new XA((n,r)=>{if(e=LA(e,`set`),t==null)throw TypeError(`There must be a value to set.`);return this.ready().then(()=>{QA(this,e,{resolve:n,reject:r}),ij(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.`);$A(this,`event:${e}`).length===0&&this.callMethod(`addEventListener`,e).catch(()=>{}),QA(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.`);ej(this,`event:${e}`,t)&&this.callMethod(`removeEventListener`,e).catch(e=>{})}loadVideo(e){return this.callMethod(`loadVideo`,e)}ready(){let e=yj.get(this)||new XA((e,t)=>{t(Error(`Unknown player. Probably unloaded.`))});return XA.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 bj.isEnabled?bj.request(this.element):this.callMethod(`requestFullscreen`)}exitFullscreen(){return bj.isEnabled?bj.exit():this.callMethod(`exitFullscreen`)}getFullscreen(){return bj.isEnabled?XA.resolve(bj.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 XA(e=>{if(yj.delete(this),vj.delete(this.element),this._originalElement&&(vj.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),bj.isEnabled&&bj.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 XA.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 XA((e,t)=>t(TypeError(`Argument must be an array.`)));let t=new XA(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 XA.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 _j(this,e,t);return ij(this,`notifyTimingObjectConnect`),n.addEventListener(`disconnect`,()=>ij(this,`notifyTimingObjectDisconnect`)),n}};IA||(bj=hj(),uj(),dj(),fj(),pj(),mj());function Sj(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Cj(e,t)}function Cj(e,t){return Cj=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Cj(e,t)}var wj={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`},Tj=function(e){function t(t){var n=e.call(this,t)||this;return n.refContainer=n.refContainer.bind(n),n}Sj(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 xj(this.container,this.getInitialOptions()),Object.keys(wj).forEach(function(t){var n=wj[t];e.player.on(t,function(t){var r=e.props[n];r&&r(t)})});var a=this.props,o=a.onError,s=a.onReady;this.player.ready().then(function(){s&&s(e.player)},function(e){if(o)o(e);else throw e}),typeof n==`number`&&this.player.setCurrentTime(n),typeof r==`number`&&this.updateProps([`volume`]),typeof i==`number`&&this.updateProps([`playbackRate`])},n.refContainer=function(e){this.container=e},n.render=function(){var e=this.props,t=e.id,n=e.className,r=e.style;return Q.createElement(`div`,{id:t,className:n,style:r,ref:this.refContainer})},t}(Q.Component);Tj.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 Ej={default:120,mqdefault:320,hqdefault:480,sddefault:640,maxresdefault:1280},Dj=(e,t,n,r=`maxresdefault`)=>{let[i,a]=(0,Q.useState)(``);return(0,Q.useEffect)(()=>{let i=`https://img.youtube.com/${t}/${e}/${r}.${n}`,o=`https://img.youtube.com/${t}/${e}/hqdefault.${n}`,s=Ej[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 Oj(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 kj(e,t){let[n,r]=Q.useState(!1),[i,a]=Q.useState(e.alwaysLoadIframe||!1),o=encodeURIComponent(e.id),s=typeof e.playlistCoverId==`string`?encodeURIComponent(e.playlistCoverId):null,c=e.title,l=e.poster||`hqdefault`,u=e.announce||`Watch`,d=e.alwaysLoadIframe?e.autoplay&&e.muted:!0,f=Q.useMemo(()=>{let t=new URLSearchParams({...e.muted?{mute:`1`}:{},...d?{autoplay:`1`}:{},...e.enableJsApi?{enablejsapi:`1`}:{},...e.enableJsApi&&typeof window<`u`?{origin:window.location.origin}:{},...e.playlist?{list:o}:{}});return e.params&&new URLSearchParams(e.params.startsWith(`&`)?e.params.slice(1):e.params).forEach((e,n)=>{t.append(n,e)}),t},[e.muted,d,e.enableJsApi,e.playlist,o,e.params]),p=Q.useMemo(()=>e.cookie?`https://www.youtube.com`:`https://www.youtube-nocookie.com`,[e.cookie]),m=Q.useMemo(()=>e.playlist?`${p}/embed/videoseries?${f.toString()}`:`${p}/embed/${o}?${f.toString()}`,[e.playlist,p,o,f]),h=!e.thumbnail&&!e.playlist&&l===`maxresdefault`,g=e.webp?`webp`:`jpg`,_=e.webp?`vi_webp`:`vi`,v=h?Dj(e.id,_,g,l):null,y=Q.useMemo(()=>e.thumbnail||v||`https://i.ytimg.com/${_}/${e.playlist?s:o}/${l}.${g}`,[e.thumbnail,v,_,e.playlist,s,o,l,g]),b=e.activatedClass||`lyt-activated`,x=e.adNetwork||!1,S=e.aspectHeight||9,C=e.aspectWidth||16,w=e.iframeClass||``,T=e.playerClass||`lty-playbtn`,E=e.wrapperClass||`yt-lite`,D=Q.useCallback(e.onIframeAdded||function(){},[e.onIframeAdded]),O=e.rel?`prefetch`:`preload`,k=e.containerElement||`article`,A=e.noscriptFallback!==!1,j=()=>{n||r(!0)},M=()=>{i||a(!0)};return Q.useEffect(()=>{i&&(D(),e.focusOnLoad&&typeof t==`object`&&t?.current&&t.current.focus())},[i,D,e.focusOnLoad,t]),Q.useEffect(()=>{if(!i||!e.enableJsApi||!(e.onReady||e.onStateChange||e.onError||e.onPlay||e.onPause||e.onEnd||e.onBuffering||e.onPlaybackRateChange||e.onPlaybackQualityChange))return;let n=!1,r=!1,a=r=>{if(r.origin!==`https://www.youtube.com`&&r.origin!==`https://www.youtube-nocookie.com`)return;let i;try{i=typeof r.data==`string`?JSON.parse(r.data):r.data}catch{return}switch(i.event){case`onReady`:n||(n=!0,e.onReady&&e.onReady({videoId:e.id,title:c}));break;case`infoDelivery`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate),i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break;case`onStateChange`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}break;case`onError`:if(i.info&&`errorCode`in i.info){let t=i.info.errorCode;e.onError&&e.onError(t)}break;case`onPlaybackRateChange`:i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate);break;case`onPlaybackQualityChange`:i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break}};window.addEventListener(`message`,a);let s=[],l=()=>{typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"listening","id":"`+o+`"}`,`*`)},u=()=>{r||(r=!0,l(),[100,300,600,1200,2400].forEach(e=>{s.push(setTimeout(l,e))}))};return typeof t==`object`&&t?.current?(t.current.addEventListener(`load`,u),t.current.contentDocument?.readyState===`complete`&&u()):[200,500,1e3,2e3,3e3].forEach(e=>{s.push(setTimeout(l,e))}),()=>{window.removeEventListener(`message`,a),s.forEach(clearTimeout),typeof t==`object`&&t?.current&&t.current.removeEventListener(`load`,u)}},[i,e.enableJsApi,e.onReady,e.onStateChange,e.onError,e.onPlay,e.onPause,e.onEnd,e.onBuffering,e.onPlaybackRateChange,e.onPlaybackQualityChange,e.stopOnEnd,e.id,o,c,t]),(0,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:Oj(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 Aj=Q.forwardRef(kj);function jj(e){return e!==!1}function Mj(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 Nj(e){if(e.width!==void 0)return{width:e.width}}function Pj(e){if(!(e.width===void 0||e.height===void 0))return{aspectRatio:`${e.width} / ${e.height}`}}function Fj(e){let t=(0,Z.c)(23),n=(0,Q.useRef)(null),r=e.title??`Vimeo video player`,i;t[0]===r?i=t[1]:(i=e=>{let t=e;n.current=t,t.element&&(t.element.title=r)},t[0]=r,t[1]=i);let a=i,o,s;t[2]===r?(o=t[3],s=t[4]):(o=()=>{let e=n.current;e?.element&&(e.element.title=r)},s=[r],t[2]=r,t[3]=o,t[4]=s),(0,Q.useEffect)(o,s);let c;t[5]===e?c=t[6]:(c=Nj(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)(Tj,{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 Ij(e){let t=(0,Z.c)(17),n;t[0]===e.src?n=t[1]:(n=_e(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=Nj(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 Lj(e){let t=(0,Z.c)(29);if(e.src!==void 0&&A(e.src)){let n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(Ij,{...e,src:e.src}),t[0]=e,t[1]=n),n}if(e.src!==void 0&&de(e.src)){let n;return t[2]===e?n=t[3]:(n=(0,X.jsx)(Fj,{...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:Fe(e.src);if(r!==null){let i=e.autoplay===!0&&e.muted===!0,a=e.width!==void 0&&e.height!==void 0,o=Nj(e),s;t[6]===e.poster?s=t[7]:(s=e.poster===void 0?void 0:et(e.poster),t[6]=e.poster,t[7]=s);let c=(0,X.jsx)(Aj,{id:r.id,title:e.title??`YouTube video player`,cookie:!r.noCookie,params:Mj(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:Pj(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:et(e.src),t[11]=e.src,t[12]=r);let i=e.title,a;t[13]===e.controls?a=t[14]:(a=jj(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:et(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 Rj(e){let t=(0,Z.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 zj={Callout:HO,img:Rk,video:Lj,audio:LO,Pdf:vA,File:tk,Embed:$O,Accordion:FO,Tabs:kA,Tab:TA,Math:Vk,MermaidFence:Wk,Mirror:iA,MirrorSource:aA,"*":Rj};function Bj(e){let t=new Set;for(let n of e)n.type===`reactnode`&&t.add(n.name);return t}var Vj=at(),Hj=new Map;function Uj(e){if(e.surface===`compat`){let t=zj[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:Bj(e.props)}}let t=zj[e.name];return t?{Component:t,reactNodePropNames:Bj(e.props)}:null}for(let[e,t]of Vj.entries()){let n=Uj(t);n&&Hj.set(e,n)}function Wj(e,t){return{...e,Component:t.Component,reactNodePropNames:t.reactNodePropNames}}function Gj(e){let t=Vj.getOrWildcard(e),n=Hj.get(t.name)??Hj.get(`*`);if(!n)throw Error(`No React component registered for ${t.name} (and no '*' wildcard)`);return Wj(t,n)}function Kj(){let e=[];for(let[t,n]of Vj.entries()){if(t===`*`)continue;let r=Hj.get(t);r&&e.push(Wj(n,r))}return e}var qj=``+new URL(`image-preview-BJSGEOo4.png`,import.meta.url).href,Jj=``+new URL(`video-preview-vLovc_Vy.png`,import.meta.url).href,Yj={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:qj,alt:`Sample image`}},video:{description:{id:`e1hptq`},props:{controls:!0,poster:Jj}},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)(Fi,{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)(Mi,{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 Xj(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 Zj(e){let t=Gj(e),n=Xj(t);return{type:`jsxComponent`,attrs:{componentName:t.name,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:n},content:t.hasChildren?[{type:`paragraph`}]:void 0}}var Qj=new Set;function $j(e){Qj.add(e)}function eM(e){if(typeof e==`number`)return Qj.delete(e);let t=Qj.values().next();return t.done?!1:(Qj.delete(t.value),!0)}function tM(e,t,n){n.props.some(e=>!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`)?($j(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})):n.hasChildren&&e.commands.setTextSelection(t+2)}function nM(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=Zj(e.name);if(e.name===`Tabs`){let e=Zj(`Tab`),t=Zj(`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)&&tM(t,i,e)}}var rM=new Set([`File`,`Tab`]);function iM(){return[{name:`component-File`,label:Rn._({id:`J2eKUI`}),icon:Bi,category:`media`,aliases:[`file`,`attachment`,`download`,`upload`,`document`,`doc`,`docx`,`zip`],description:"Attach a downloadable file (`.pdf` / `.docx` / `.zip` / …)",command:oM,preview:{description:Rn._({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)(Bi,{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 aM(){return[...Kj().filter(e=>e.surface===`canonical`&&!rM.has(e.name)).map(e=>{let t=Yj[e.name],n=e.Component,r=t?{description:Rn._(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:jO(e.icon),category:e.category??`content`,command:nM(e),aliases:e.searchTerms,description:e.description,preview:r}}),...iM()]}function oM(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;aO(n,e,t)}t.remove()},{once:!0}),t.addEventListener(`cancel`,()=>t.remove(),{once:!0}),document.body.appendChild(t),t.click()}function sM(e,t){let n=uO.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 cM(){return[{name:`link`,label:Rn._({id:`yzF66j`}),icon:na,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:Rn._({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=sM(e,t);n&&(cO(n),requestAnimationFrame(()=>{kO(e).setActiveNode(n)}))}},{name:`component-Tag`,label:Rn._({id:`UL8A9w`}),icon:Ki,category:`content`,aliases:[`#`,`hashtag`,`label`],description:"Inline tag (`#tagname`) for cross-doc linking",preview:{description:Rn._({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 lM(e,t){e.chain().focus().insertContent({type:`codeBlock`,attrs:{language:`html`,meta:`preview`},content:[{type:`text`,text:t}]}).run()}var uM=`<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:Ci,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:Zi,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:va,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:xa,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 fM(){return{name:`embed-starter-html`,label:Rn._({id:`FBknns`}),icon:ji,category:`embed`,aliases:[`html`,`embed`,`preview`,`iframe`,`sandbox`,`web`,`snippet`],description:Rn._({id:`4niEzY`}),command:e=>lM(e,uM),preview:{description:Rn._({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 pM(){let e=Ie.map(e=>{let t=dM[e.id];return{name:`embed-starter-${e.id}`,label:e.title,icon:t.icon,category:`embed`,command:t=>lM(t,e.html),aliases:t.aliases,description:e.description,preview:{description:e.description,render:t.render}}});return[fM(),...e]}function mM(){return[{name:`heading1`,label:Rn._({id:`lXKZGw`}),icon:qi,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:1}).run(),aliases:[`h1`],preview:{description:Rn._({id:`3J7d2N`}),render:()=>(0,X.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:(0,X.jsx)(o,{id:`lXKZGw`})})}},{name:`heading2`,label:Rn._({id:`El7NbA`}),icon:Ji,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:2}).run(),aliases:[`h2`],preview:{description:Rn._({id:`LXdWeS`}),render:()=>(0,X.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:(0,X.jsx)(o,{id:`El7NbA`})})}},{name:`heading3`,label:Rn._({id:`SFN6dN`}),icon:Yi,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:3}).run(),aliases:[`h3`],preview:{description:Rn._({id:`g4XBm0`}),render:()=>(0,X.jsx)(`h3`,{className:`text-base font-semibold tracking-tight`,children:(0,X.jsx)(o,{id:`SFN6dN`})})}},{name:`bulletList`,label:Rn._({id:`s1c0ja`}),icon:aa,category:`basic`,command:e=>e.chain().focus().toggleBulletList().run(),aliases:[`ul`,`unordered`],preview:{description:Rn._({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:Rn._({id:`Uci-Ph`}),icon:ra,category:`basic`,command:e=>e.chain().focus().toggleOrderedList().run(),aliases:[`ol`,`numbered`],preview:{description:Rn._({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:Rn._({id:`G_686w`}),icon:ia,category:`basic`,command:e=>e.chain().focus().toggleTaskList().run(),aliases:[`todo`,`checklist`,`checkbox`],preview:{description:Rn._({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:Rn._({id:`ZhhOwV`}),icon:ha,category:`basic`,command:e=>e.chain().focus().toggleBlockquote().run(),aliases:[`quote`],preview:{description:Rn._({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:Rn._({id:`N2eHWq`}),icon:Ai,category:`basic`,command:e=>e.chain().focus().toggleCodeBlock({language:`js`}).run(),aliases:[`code`,`fence`],preview:{description:Rn._({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";
|
|
@@ -31,4 +31,4 @@ body{background:var(--background);color:var(--foreground)}
|
|
|
31
31
|
</style>`}function JG(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.${zG};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({${VG}:Math.ceil(r.bottom+mb)},'*');}function schedule(){if(raf){cancelAnimationFrame(raf);}raf=requestAnimationFrame(report);}function init(){schedule();addEventListener('load',schedule);if(window.ResizeObserver){try{new ResizeObserver(schedule).observe(document.body);}catch(_e){}}}if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',init);}else{init();}var cspSeen=new Set();var cspList=[];var cspTrunc=false;var cspTimer;function cspFlush(){parent.postMessage({${UG}:{blocked:cspList.slice(),truncated:cspTrunc}},'*');}addEventListener('securitypolicyviolation',function(e){if(cspTrunc)return;var dir=(e&&(e.effectiveDirective||e.violatedDirective))||'';var uri=(e&&e.blockedURI)||'';var k=dir+' '+uri;if(cspSeen.has(k))return;cspSeen.add(k);if(cspList.length<20){cspList.push({directive:dir,uri:uri});}else{cspTrunc=true;}if(cspTimer){clearTimeout(cspTimer);}cspTimer=setTimeout(cspFlush,250);});})();<\/script>`}var YG=`default-src 'none'; script-src 'unsafe-inline' https:; style-src 'unsafe-inline' https: data:; img-src https: data: blob:; font-src https: data:; connect-src https: wss: data: blob:; media-src https: data: blob:; frame-src https:; child-src https:; form-action 'none'; base-uri 'none';`;function XG(e){return`<meta http-equiv="Content-Security-Policy" content="${YG}">
|
|
32
32
|
${qG()}
|
|
33
33
|
${GG}
|
|
34
|
-
${JG(e)}`}var ZG=`plaintext`;function QG(){return typeof document<`u`&&document.documentElement.classList.contains(`dark`)?`dark`:`light`}function $G(e,t){let n=(0,Z.c)(4),[r,i]=(0,Q.useState)(!1),a,o;return n[0]!==e||n[1]!==t?(a=()=>{let n=()=>{let n=typeof t==`function`?t():void 0;if(typeof n!=`number`)return;let r=e.state.doc.nodeAt(n);if(!r)return;let{from:a,to:o}=e.state.selection,s=n,c=a<n+r.nodeSize&&o>s;i(e=>e===c?e:c)};return n(),e.on(`selectionUpdate`,n),()=>{e.isDestroyed||e.off(`selectionUpdate`,n)}},o=[e,t],n[0]=e,n[1]=t,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Q.useEffect)(a,o),r}function eK(e){let t=(0,Z.c)(174),{node:n,updateAttributes:r,editor:a,getPos:s,selected:c}=e,{_:l}=i(),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),m=(0,Q.useRef)(null),h=(0,Q.useRef)(null),g=(0,Q.useRef)(null),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(null),{resolvedTheme:x}=Re(),S;t[0]===x?S=t[1]:(S=x===`dark`||x===`light`?x:QG(),t[0]=x,t[1]=S);let C=S,[w]=(0,Q.useState)(QG),T=n.attrs.language??null,E=n.attrs.meta??null,D;t[2]===E?D=t[3]:(D=IG(E),t[2]=E,t[3]=D);let O=D,[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),N=(0,Q.useId)(),P=`${N}-title-input`,F=`${N}-title-help`,I=(0,Q.useRef)(E),L,R;t[4]===E?(L=t[5],R=t[6]):(L=()=>{I.current=E},R=[E],t[4]=E,t[5]=L,t[6]=R),(0,Q.useEffect)(L,R);let z,B,ee,V,te;if(t[7]!==l||t[8]!==T||t[9]!==E){B=yG(T),z=T?_G.find(e=>e.value===B)?.label??T:l({id:`LpB85N`});let e;t[15]===E?e=t[16]:(e=CG(E,`preview`),t[15]=E,t[16]=e),V=e,ee=B?EG.has(B):!1,te=DG(B,E),t[7]=l,t[8]=T,t[9]=E,t[10]=z,t[11]=B,t[12]=ee,t[13]=V,t[14]=te}else z=t[10],B=t[11],ee=t[12],V=t[13],te=t[14];let H=te,U;t[17]!==H||t[18]!==E?(U=H?MG(E):null,t[17]=H,t[18]=E,t[19]=U):U=t[19];let ne=U,W;t[20]!==H||t[21]!==E?(W=H?NG(E):null,t[20]=H,t[21]=E,t[22]=W):W=t[22];let re=W,G=ne??(_===null?void 0:`${_}px`),ie=!H,ae,oe;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>()=>{m.current!==null&&window.clearTimeout(m.current)},oe=[],t[23]=ae,t[24]=oe):(ae=t[23],oe=t[24]),(0,Q.useEffect)(ae,oe);let K=a.isEditable,se=$G(a,s),ce,q;t[25]===C?(ce=t[26],q=t[27]):(ce=()=>{g.current?.contentWindow?.postMessage(BG(C),`*`)},q=[C],t[25]=C,t[26]=ce,t[27]=q),(0,Q.useEffect)(ce,q);let le,ue;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>{let e=function(e){if(e.source!==g.current?.contentWindow)return;let t=HG(e.data);if(t!==null){v(e=>e!==null&&Math.abs(e-t)<=2?e:t);return}let n=WG(e.data);n!==null&&b(n)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},ue=[],t[28]=le,t[29]=ue):(le=t[28],ue=t[29]),(0,Q.useEffect)(le,ue);let de;t[30]===n.textContent?de=t[31]:(de=()=>{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,iK)}catch{}},t[30]=n.textContent,t[31]=de);let fe=de,pe;t[32]!==a||t[33]!==s?(pe=()=>{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]=pe):pe=t[34];let me=pe,he;t[35]!==V||t[36]!==E||t[37]!==r?(he=()=>{r({meta:V?TG(E,`preview`):wG(E,`preview`)})},t[35]=V,t[36]=E,t[37]=r,t[38]=he):he=t[38];let ge=he,_e;t[39]!==E||t[40]!==r?(_e=e=>{let t=LG(E,e.length>0?e:null);t!==E&&r({meta:t})},t[39]=E,t[40]=r,t[41]=_e):_e=t[41];let ve=_e,ye;t[42]!==a.state||t[43]!==a.view||t[44]!==s||t[45]!==n.attrs||t[46]!==n.nodeSize||t[47]!==n.type?(ye=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]=ye):ye=t[48];let be=ye,xe;t[49]===r?xe=t[50]:(xe=e=>{let t=`${Math.round(e.width)}px`,n=`${Math.round(e.height)}px`;r({meta:jG(jG(I.current,`h`,n),`w`,t)})},t[49]=r,t[50]=xe);let Se=xe,Ce=T??void 0,we=se?`true`:void 0,Te=c?`true`:void 0,Ee=H?`true`:void 0,De=ie?`true`:`false`,Oe;t[51]!==l||t[52]!==C||t[53]!==w||t[54]!==ie||t[55]!==G||t[56]!==Se||t[57]!==n.textContent||t[58]!==H||t[59]!==re?(Oe=H?(0,X.jsxs)(`div`,{ref:h,className:Ut(`ok-codeblock-preview`,ie?`ok-codeblock-preview--with-code`:`ok-codeblock-preview--solo`),contentEditable:!1,style:{...G?{height:G}:{},...re?{width:re}:{}},onMouseDown:rK,children:[(0,X.jsx)(`iframe`,{title:l({id:`G7cMuO`}),ref:g,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,srcDoc:XG(w)+n.textContent,className:`ok-codeblock-preview-frame`,onLoad:()=>{b(null),g.current?.contentWindow?.postMessage(BG(C),`*`)}}),(0,X.jsx)(qO,{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:Se})]}):null,t[51]=l,t[52]=C,t[53]=w,t[54]=ie,t[55]=G,t[56]=Se,t[57]=n.textContent,t[58]=H,t[59]=re,t[60]=Oe):Oe=t[60];let ke;t[61]!==y||t[62]!==H?(ke=H&&y?(0,X.jsx)(gG,{blocked:y.blocked,truncated:y.truncated,onDismiss:()=>b(null)}):null,t[61]=y,t[62]=H,t[63]=ke):ke=t[63];let Ae;t[64]===O?Ae=t[65]:(Ae=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[64]=O,t[65]=Ae);let je=H&&ie?`rounded-b-lg`:null,Me=H?null:`rounded-lg`,Ne;t[66]!==je||t[67]!==Me?(Ne=Ut(`ok-codeblock-pre m-0 overflow-x-auto px-5 py-4 font-mono text-sm leading-relaxed`,je,Me),t[66]=je,t[67]=Me,t[68]=Ne):Ne=t[68];let Pe=!ie||void 0,Fe=T?`language-${T}`:void 0,Ie;t[69]===Fe?Ie=t[70]:(Ie=Ut(`hljs block whitespace-pre bg-transparent p-0`,Fe),t[69]=Fe,t[70]=Ie);let Le;t[71]===Ie?Le=t[72]:(Le=(0,X.jsx)(Al,{as:`code`,className:Ie}),t[71]=Ie,t[72]=Le);let ze;t[73]!==Ne||t[74]!==Pe||t[75]!==Le?(ze=(0,X.jsx)(`pre`,{className:Ne,"aria-hidden":Pe,children:Le}),t[73]=Ne,t[74]=Pe,t[75]=Le,t[76]=ze):ze=t[76];let Be;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(Be={[JP]:`true`},t[77]=Be):Be=t[77];let Ve=!K,He;t[78]!==l||t[79]!==z?(He=l({id:`c5f7sm`,values:{currentLabel:z}}),t[78]=l,t[79]=z,t[80]=He):He=t[80];let Ue;t[81]===z?Ue=t[82]:(Ue=(0,X.jsx)(`span`,{children:z}),t[81]=z,t[82]=Ue);let We;t[83]===K?We=t[84]:(We=K?(0,X.jsx)(wi,{className:`size-3 opacity-60`,"aria-hidden":`true`}):null,t[83]=K,t[84]=We);let Ge;t[85]!==Ve||t[86]!==He||t[87]!==Ue||t[88]!==We?(Ge=(0,X.jsx)(ic,{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[85]=Ve,t[86]=He,t[87]=Ue,t[88]=We,t[89]=Ge):Ge=t[89];let Ke;t[90]===l?Ke=t[91]:(Ke=l({id:`G_mWXb`}),t[90]=l,t[91]=Ke);let qe;t[92]===Ke?qe=t[93]:(qe=(0,X.jsx)(Gb,{placeholder:Ke}),t[92]=Ke,t[93]=qe);let Je;t[94]===l?Je=t[95]:(Je=l({id:`ETyvvg`}),t[94]=l,t[95]=Je);let Ye;t[96]===Je?Ye=t[97]:(Ye=(0,X.jsx)(qb,{children:Je}),t[96]=Je,t[97]=Ye);let Xe;t[98]!==a.commands||t[99]!==B||t[100]!==T||t[101]!==r?(Xe=_G.map(e=>{let t=e.value===ZG?!T||B===ZG:B===e.value;return(0,X.jsxs)(Yb,{value:`${e.label} ${e.value} ${e.aliases?.join(` `)??``}`,onSelect:()=>{r({language:e.value===ZG?null:e.value}),d(!1),a.commands.focus()},children:[(0,X.jsx)(`span`,{className:`flex-1`,children:e.label}),t?(0,X.jsx)(fn,{className:`size-3.5`,"aria-hidden":`true`}):null]},e.value)}),t[98]=a.commands,t[99]=B,t[100]=T,t[101]=r,t[102]=Xe):Xe=t[102];let Ze;t[103]===Xe?Ze=t[104]:(Ze=(0,X.jsx)(Jb,{children:Xe}),t[103]=Xe,t[104]=Ze);let Qe;t[105]!==Ye||t[106]!==Ze?(Qe=(0,X.jsxs)(Kb,{children:[Ye,Ze]}),t[105]=Ye,t[106]=Ze,t[107]=Qe):Qe=t[107];let $e;t[108]!==qe||t[109]!==Qe?($e=(0,X.jsx)(ac,{align:`end`,sideOffset:6,className:`w-56 p-0`,children:(0,X.jsxs)(Ub,{filter:tK,children:[qe,Qe]})}),t[108]=qe,t[109]=Qe,t[110]=$e):$e=t[110];let et;t[111]!==u||t[112]!==Ge||t[113]!==$e?(et=(0,X.jsxs)(rc,{open:u,onOpenChange:d,children:[Ge,$e]}),t[111]=u,t[112]=Ge,t[113]=$e,t[114]=et):et=t[114];let tt;t[115]!==l||t[116]!==K||t[117]!==H?(tt=K&&H?(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)(pa,{className:`size-3.5`,"aria-hidden":`true`})}):null,t[115]=l,t[116]=K,t[117]=H,t[118]=tt):tt=t[118];let nt;t[119]!==l||t[120]!==K||t[121]!==ge||t[122]!==ee||t[123]!==V?(nt=K&&ee?(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"data-active":V?`true`:void 0,"aria-pressed":V,"aria-label":l(V?{id:`xHGM4U`}:{id:`7OwvEL`}),onClick:ge,children:V?(0,X.jsx)(Ii,{className:`size-3.5`}):(0,X.jsx)(Li,{className:`size-3.5`})}):null,t[119]=l,t[120]=K,t[121]=ge,t[122]=ee,t[123]=V,t[124]=nt):nt=t[124];let rt;t[125]!==l||t[126]!==K||t[127]!==ve||t[128]!==k||t[129]!==O||t[130]!==F||t[131]!==P?(rt=K?(0,X.jsxs)(rc,{open:k,onOpenChange:A,children:[(0,X.jsx)(ic,{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)(_a,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,X.jsx)(ac,{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)(mn,{id:P,type:`text`,value:O??``,placeholder:l({id:`mk2poV`}),"data-testid":`ok-codeblock-title-input`,"aria-describedby":F,onChange:e=>ve(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[125]=l,t[126]=K,t[127]=ve,t[128]=k,t[129]=O,t[130]=F,t[131]=P,t[132]=rt):rt=t[132];let it;t[133]!==l||t[134]!==f?(it=l(f?{id:`6V3Ea3`}:{id:`NmPNJJ`}),t[133]=l,t[134]=f,t[135]=it):it=t[135];let at;t[136]===f?at=t[137]:(at=f?(0,X.jsx)(fn,{className:`size-3.5`,"aria-hidden":`true`}):(0,X.jsx)(Ni,{className:`size-3.5`,"aria-hidden":`true`}),t[136]=f,t[137]=at);let ot;t[138]!==fe||t[139]!==it||t[140]!==at?(ot=(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"aria-label":it,onClick:fe,children:at}),t[138]=fe,t[139]=it,t[140]=at,t[141]=ot):ot=t[141];let st;t[142]!==l||t[143]!==K||t[144]!==me?(st=K?(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn ok-codeblock-chrome-btn--delete`,"aria-label":l({id:`oBXkm2`}),onClick:me,children:(0,X.jsx)(Ta,{className:`size-3.5`,"aria-hidden":`true`})}):null,t[142]=l,t[143]=K,t[144]=me,t[145]=st):st=t[145];let ct;t[146]!==et||t[147]!==tt||t[148]!==nt||t[149]!==rt||t[150]!==ot||t[151]!==st?(ct=(0,X.jsxs)(`div`,{className:`ok-codeblock-chrome`,contentEditable:!1,onMouseDown:nK,...Be,children:[et,tt,nt,rt,ot,st]}),t[146]=et,t[147]=tt,t[148]=nt,t[149]=rt,t[150]=ot,t[151]=st,t[152]=ct):ct=t[152];let lt;t[153]!==l||t[154]!==w||t[155]!==j||t[156]!==K||t[157]!==be||t[158]!==n.textContent||t[159]!==B||t[160]!==H?(lt=K&&H?(0,X.jsx)(mG,{open:j,onOpenChange:M,initialValue:n.textContent,language:B===`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:XG(w)+e}),onSave:be}):null,t[153]=l,t[154]=w,t[155]=j,t[156]=K,t[157]=be,t[158]=n.textContent,t[159]=B,t[160]=H,t[161]=lt):lt=t[161];let ut;return t[162]!==Ce||t[163]!==we||t[164]!==Te||t[165]!==Ee||t[166]!==De||t[167]!==Oe||t[168]!==ke||t[169]!==Ae||t[170]!==ze||t[171]!==ct||t[172]!==lt?(ut=(0,X.jsxs)(jl,{className:`ok-codeblock relative my-3`,"data-language":Ce,"data-cursor-inside":we,"data-selected":Te,"data-preview":Ee,"data-code-visible":De,children:[Oe,ke,Ae,ze,ct,lt]}),t[162]=Ce,t[163]=we,t[164]=Te,t[165]=Ee,t[166]=De,t[167]=Oe,t[168]=ke,t[169]=Ae,t[170]=ze,t[171]=ct,t[172]=lt,t[173]=ut):ut=t[173],ut}function tK(e,t){return t?+!!e.toLowerCase().includes(t.toLowerCase()):1}function nK(e){return e.stopPropagation()}function rK(e){return e.stopPropagation()}function iK(){}function aK(e,t=[]){return e.flatMap(e=>{if(e.type===`text`)return[{text:e.value,classes:t}];let n=[...t,...e.properties?.className??[]];return aK(e.children,n)})}function oK(e){let{doc:t,name:n,lowlight:r,defaultLanguage:i}=e,a=[],o=r.listLanguages();return Xe(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 aK(c)){let n=t+e.text.length;e.classes.length>0&&a.push(O.inline(t,n,{class:e.classes.join(` `)})),t=n}}),q.create(t,a)}function sK(e){let{name:t,lowlight:n,defaultLanguage:r}=e,i=new pt({key:new N(`codeBlockLowlight`),state:{init:(e,{doc:i})=>oK({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=Xe(a.doc,e=>e.type.name===t),u=Xe(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)})?oK({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 cK=zP(FP),lK=re.extend({addNodeView(){return zl(eK)},addProseMirrorPlugins(){return[...this.parent?.()??[],sK({name:this.name,lowlight:cK,defaultLanguage:null})]},addInputRules(){return[...this.parent?.()??[],fe({find:/^```$/,type:this.type,getAttributes:()=>({language:`js`})})]}});function uK(e){return!!e.getMeta(Tv)}function dK(e,t){let n=Tv.getState(e);return py(n.doc,n.type,t,n.binding.mapping)||0}function fK(e,t){let n=Tv.getState(e);return dy(t,n.type,n.binding.mapping)}var pK=class e extends oe{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 mK(e,t){return new pK(e,fK(t,e))}function hK(e,t,n){let r=e instanceof pK?e.yRelativePosition:null;if(uK(t)&&r)return{position:new pK(dK(n,r),r),mapResult:null};let i=te(e,t),a=i.position.position;return{position:new pK(a,r??fK(n,a)),mapResult:i.mapResult}}var gK=kt.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)=>hK(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>mK(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Ev.getState(t).undoManager.undoStack.length===0?!1:n?xy(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Ev.getState(t).undoManager.redoStack.length===0?!1:n?Sy(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=Ty(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{let{undoManager:t}=Ev.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()}}},[Pv(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,this.editor.options.enableContentCheck&&new pt({key:new N(`filterInvalidContent`),filterTransaction:t=>{if(!uK(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 _K(e){if(!e.length)return q.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(O.node(n,n+r.nodeSize,{class:`ProseMirror-selectednoderange`}))}),q.create(n,t)}function vK(e,t,n){let r=n.isText||n.isAtom?0:1;return{start:e+r,end:e+t-r}}function yK(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 bt(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=vK(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 ve(a.resolve(l),a.resolve(u));i.push(p)}),i}var bK=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 xK(e.resolve(this.anchor),e.resolve(this.head))}},xK=class e extends be{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=yK(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 bK(this.anchor,this.head)}};xK.prototype.visible=!1;function SK(e){return e instanceof xK}kt.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(!SK(a)){let e=xK.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(!SK(a)){let e=xK.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=xK.create(i,0,i.content.size,t);return a.setSelection(o),n.dispatch(a),!0}}},onSelectionUpdate(){let{selection:e}=this.editor.state;SK(e)&&this.editor.view.dom.classList.add(`ProseMirror-noderangeselection`)},addProseMirrorPlugins(){let e=!1,t=!1;return[new pt({key:new N(`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=xK.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=SK(r);if(e=!1,!t)return i?(e=!0,_K(r.ranges)):null;let{$from:a,$to:o}=r;if(!i&&a.sameParent(o))return null;let s=yK(a,o,this.options.depth);return s.length?(e=!0,_K(s)):null}}})]}});function CK(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 wK(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=CK(e)}),t}var TK=[{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}],EK={edges:[`left`,`top`],threshold:12,strength:500};function DK(e){return e===void 0||e===`left`?{...EK}: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}:{...EK,...e}}function OK(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 kK(e,t,n,r){return!t||n.edges.length===0?0:OK(e,t,n)?n.strength*r:0}var AK=1e3;function jK(e,t,n,r){let i=AK,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-=kK(r,o,n,e.depth),i<=0?-1:i}function MK(e,t,n){return Array.from({length:t},(e,n)=>t-1-n).some(t=>n.includes(e.node(t).type.name))}function NK(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(...TK),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&&!MK(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=jK({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=MK(a,l,n.allowedContainers)),p){let r=jK({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 PK(e,t){let n=e;for(;n?.parentElement&&n.parentElement!==t.dom;)n=n.parentElement;return n?.parentElement===t.dom?n:void 0}function FK(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 IK(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(!FK(s)||!FK(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 LK=e=>{let{x:t,y:n,editor:r,nestedOptions:i}=e,{view:a,state:o}=r,s=IK(a,t,n,5);if(!s)return{resultElement:null,resultNode:null,pos:null};let{x:c,y:l}=s;if(i?.enabled){let e=NK(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=PK(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 RK(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 zK(e){var t;(t=e.parentNode)==null||t.removeChild(e)}function BK(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=LK({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 yK(i.resolve(a.pos),i.resolve(a.pos+a.resultNode.nodeSize+o),0,{extendOnBoundaryOverlap:!1})}function VK(e,t,n,r){let{view:i}=t;if(!e.dataTransfer)return;let{empty:a,$from:o,$to:s}=i.state.selection,c=BK(e,t,n,r),l=yK(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`,RK(i,m));let g=n?.enabled&&r?.node,_,v;g?(_=i.state.doc.slice(m,h),v=I.create(i.state.doc,m)):(v=xK.create(i.state.doc,m,h),_=v.content()),d.forEach(e=>{let t=wK(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,zK(p),document.removeEventListener(`drop`,T),document.removeEventListener(`dragend`,T))},E=v instanceof I?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 HK=(e,t)=>{let n=e.resolve(t),{depth:r}=n;return r===0?t:n.pos-n.parentOffset-1},UK=(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},WK=(e,t)=>{let n=Tv.getState(e);return n?dy(t,n.type,n.binding.mapping):null},GK=(e,t)=>{let n=Tv.getState(e);return n?py(n.doc,n.type,t,n.binding.mapping)||0:-1},KK=(e,t)=>{let n=t;for(;n?.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n},qK=new N(`dragHandle`),JK=({pluginKey:e=qK,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){fr(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),VK(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(S()){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 pt({key:typeof e==`string`?new N(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(uK(e)){let e=GK(o,p);e!==f&&(f=e)}else{let t=e.mapping.map(f);t!==f&&(f=t,p=WK(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=KK(e,o),o===e.dom||o?.nodeType!==1)return;let s=e.posAtDOM(o,0),c=UK(n.state.doc,s),l=HK(n.state.doc,s);d=c,f=l,p=WK(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&&zK(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=LK({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=KK(e,o),o===e.dom||o?.nodeType!==1)return;let t=e.posAtDOM(o,0);s=UK(n.state.doc,t),l=HK(n.state.doc,t)}s!==d&&(d=s,f=l??-1,p=WK(e.state,f),a?.({editor:n,node:d,pos:f}),v(o),_())})),!1}}}})}};function YK(e){return e===!1||e===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:DK(`none`)}:e===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:DK(`left`)}:{enabled:!0,rules:e.rules??[],defaultRules:e.defaultRules??!0,allowedContainers:e.allowedContainers,edgeDetection:DK(e.edgeDetection)}}var XK={placement:`left-start`,strategy:`absolute`};kt.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=YK(this.options.nested);return[JK({computePositionConfig:{...XK,...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 ZK=20,QK=44,$K=28;function eq(e){if(!e)return`Select block`;if(e.type.name===`jsxComponent`){let t=e.attrs.componentName??``;if(t){let e=Gj(t),n=e.name===`*`?t:e.displayName??e.name;if(n)return`Select ${n}`}}return`Select ${e.type.name}`}function tq(){let e=document.createElement(`div`);e.className=`ok-block-controls`,e.setAttribute(JP,`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 nq(e,t,n){let{state:r,view:i}=e;if(n.type.name===`jsxComponent`){let i=n.attrs.componentName??``;if(i){let a=Gj(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,Zj(o)).run(),tM(e,i,Gj(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=Ce.near(o.doc.resolve(a+1));o.setSelection(c).scrollIntoView(),i.dispatch(o),i.focus(),e.commands.insertContent(`/`)}var rq=kt.create({name:`blockDragHandle`,addProseMirrorPlugins(){let e=this.editor,t=null,n=-1,{container:r,addBtn:i,grip:a}=tq();return i.addEventListener(`click`,()=>{t&&n>=0&&nq(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()||(Mt(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;Mt(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)}))}}),[JK({element:r,editor:e,onNodeChange({node:e,pos:r}){t=e,n=r??-1,a.setAttribute(`aria-label`,eq(e))},computePositionConfig:{placement:`left-start`,strategy:`absolute`,middleware:[nr(({rects:e})=>({mainAxis:10,crossAxis:((e.reference.height<=QK?e.reference.height:$K)-ZK)/2}))]},nestedOptions:YK(!1)}).plugin]}}),iq=/^#fn(?:ref)?-/,aq=kt.create({name:`footnoteAnchorScroll`,addProseMirrorPlugins(){return[new pt({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(!iq.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}}}})]}}),oq=kt.create({name:`formattingShortcuts`,addKeyboardShortcuts(){return{"Mod-Shift-x":()=>this.editor.commands.toggleStrike()}}}),sq=kt.create({name:`headingAnchors`,addProseMirrorPlugins(){return[new pt({props:{decorations(e){let t=[],n=new Map;return e.doc.descendants((e,r)=>{if(e.type.name===`heading`){let i=He(e.textContent,n);if(!i)return;t.push(O.node(r,r+e.nodeSize,{id:i}))}}),q.create(e.doc,t)}}})]}});function cq(e){let t=(0,Z.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?PD(r)??void 0:void 0;s=typeof i==`string`?et(M(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)(jl,{as:`span`,"data-image-inline-zoom":!0,"data-clipboard-inline-leaf":`image`,children:(0,X.jsx)(jk,{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 lq=C.extend({addNodeView(){return zl(cq)}});function uq(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=gt(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=k(n.getAttribute(`href`)??``,t);if(e?.kind===`asset`){let n=gt(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=k(e,t);if(n?.kind===`asset`){let e=gt(n.url,t);return e?{kind:`image`,relPath:e,title:e.split(`/`).pop()??n.url}:null}}}n=n.parentElement}return null}var dq=new N(`asset-context-menu`);function fq(e){return new pt({key:dq,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=uq(t.target,e.sourceDocName);r&&(t.preventDefault(),n(r))};return t.dom.addEventListener(`contextmenu`,r),{destroy(){t.dom.removeEventListener(`contextmenu`,r)}}}})}var pq=e=>{let t=(0,Z.c)(18),{kind:n,ariaLabel:r,onDeactivate:i,children:a,triggerReference:o,layout:s,className:c,"data-slot":l}=e,u=s===void 0?`standard`:s,d=(0,Q.useRef)(null),f,p;t[0]===o?(f=t[1],p=t[2]):(f=()=>{let e=d.current;if(e)return or(o,e,()=>{let t=o.getBoundingClientRect();e.isConnected&&(e.style.left=`${t.left}px`,e.style.top=`${t.top}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`)})},p=[o],t[0]=o,t[1]=f,t[2]=p),(0,Q.useLayoutEffect)(f,p);let m;t[3]===i?m=t[4]:(m=e=>{e||i()},t[3]=i,t[4]=m);let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.jsx)(oc,{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?(_=Ut(`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)(ac,{side:`bottom`,align:`start`,sideOffset:8,collisionPadding:8,"aria-label":r,"data-ok-prop-panel":n,"data-slot":l,onOpenAutoFocus:mq,onCloseAutoFocus:hq,onPointerDownOutside:gq,onFocusOutside:_q,onInteractOutside:vq,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)(rc,{open:!0,onOpenChange:m,children:[h,v]}),t[15]=m,t[16]=v,t[17]=y):y=t[17],y};function mq(e){return e.preventDefault()}function hq(e){return e.preventDefault()}function gq(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function _q(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function vq(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function yq(e){let t=e.trim();return/\.(md|mdx)$/i.test(t)?t:`${t}.md`}function bq(e){let t=e.initialDir.trim().replace(/^\/+|\/+$/g,``),n=yq(e.suggestedName);return t?`${t}/${n}`:n}async function xq(e){let t=await Zb(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:Qb(Dt,t.body,`create-page`,{docName:n}).docName}}async function Sq(e){return xq(bq(e))}async function Cq(e,t){let{docName:n}=await Sq(e);return t.addPage(n),Nn([`files`,`backlinks`,`graph`]),t.onCreated?.(n),{docName:n}}var wq=8;function Tq(e){return e.trim().replace(/^\/+/,``).replace(/\.mdx?$/i,``).replace(/\/+$/g,``)}function Eq(e){return Dq(e)?Tq(e.slice(1)).toLowerCase():null}function Dq(e){return e.startsWith(`/`)&&!e.startsWith(`//`)}function Oq(e){return e.split(`/`).at(-1)??e}function kq(e,t){if(!t)return 0;let n=e.toLowerCase(),r=Oq(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 Aq(e){switch(e){case`page`:return 0;case`folder`:return 1;case`asset`:return 2}}function jq(e){let t=[],n=new Set;function r(e,r){let i=Tq(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 Mq(e){let t=Eq(e.value);if(t===null)return[];let n=[];for(let r of jq(e)){let e=kq(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=Aq(e.suggestion.kind)-Aq(t.suggestion.kind);return n===0?e.suggestion.path.localeCompare(t.suggestion.path):n}),n.slice(0,e.limit??wq).map(e=>e.suggestion)}var Nq=`[data-ok-link-path-suggestion-panel]`;function Pq(e){return e instanceof Element&&e.closest(Nq)!==null}function Fq(e){Pq(e.target)&&e.preventDefault()}function Iq(e){switch(e){case`page`:return(0,X.jsx)(zi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`});case`folder`:return(0,X.jsx)(Wi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`});case`asset`:return(0,X.jsx)(fa,{className:`size-3.5 shrink-0`,"aria-hidden":`true`})}}function Lq(e,t){if(e){if(typeof e==`function`){e(t);return}e.current=t}}function Rq(e){let t=(0,Z.c)(54),n,r,a,o,s,c,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],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14]):({value:g,pages:f,folderPaths:a,assetPaths:n,includeAssets:m,loading:h,onValueChange:d,onKeyDown:l,onSuggestionSelect:u,onFocus:c,onBlur:s,className:r,ref:p,...o}=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,t[13]=h,t[14]=g);let _=m===void 0?!1:m,v=h===void 0?!1:h,{_:y}=i(),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(0),E=(0,Q.useRef)(null),D=(0,Q.useRef)(null),O=(0,Q.useId)(),k;t[15]===g?k=t[16]:(k=g.trim(),t[15]=g,t[16]=k);let A=k===``,j=Mq({value:A?`/`:g,pages:f,folderPaths:a,assetPaths:n,includeAssets:_}),M=j.map(Uq).join(`\0`),N;t[17]===g?N=t[18]:(N=Dq(g),t[17]=g,t[18]=N);let P=A||N,F=j.length>0,I=b&&!S&&P&&(F||v)||b&&!S&&P&&!v&&!F,L=Math.min(w,Math.max(j.length-1,0)),R=F?`${O}-option-${L}`:void 0,z;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>{T(0)},t[19]=z):z=t[19],(0,Q.useEffect)(z,[M]);let B,ee;t[20]!==R||t[21]!==I?(B=()=>{!I||!R||document.getElementById(R)?.scrollIntoView?.({block:`nearest`})},ee=[R,I],t[20]=R,t[21]=I,t[22]=B,t[23]=ee):(B=t[22],ee=t[23]),(0,Q.useEffect)(B,ee);let V,te;t[24]===I?(V=t[25],te=t[26]):(V=()=>{if(!I)return;let e=E.current,t=D.current;if(!e||!t)return;let n=e,r=t,i=function(){fr(n,r,{placement:`bottom-start`,strategy:`fixed`,middleware:[nr(4),lr({padding:8}),hr({padding:8}),_r({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=or(n,r,i);return i(),a},te=[I],t[24]=I,t[25]=V,t[26]=te),(0,Q.useLayoutEffect)(V,te);let H;t[27]===p?H=t[28]:(H=function(e){E.current=e,Lq(p,e)},t[27]=p,t[28]=H);let U=H,ne=function(e){u?u(e):d(e.path),C(!0),requestAnimationFrame(()=>E.current?.focus())},W=function(e){if(F){if(e.key===`ArrowDown`){e.preventDefault(),T(e=>Math.min(e+1,j.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),T(Hq);return}if(e.key===`Enter`){e.preventDefault();let t=j[L];t&&ne(t);return}if(e.key===`Escape`){e.preventDefault(),C(!0);return}}if(I&&e.key===`Escape`){e.preventDefault(),C(!0);return}l?.(e)},re;t[29]===y?re=t[30]:(re=function(e){switch(e){case`page`:return y({id:`6WdDG7`});case`folder`:return y({id:`kNqMMd`});case`asset`:return y({id:`bUUVED`})}},t[29]=y,t[30]=re);let G=re,ie=I?(0,X.jsx)(`div`,{ref:D,id:O,role:`listbox`,"aria-label":y({id:`mBltnd`}),"data-ok-layer-spawned":``,"data-ok-link-path-suggestion-panel":``,className:`fixed z-70 max-h-52 overflow-y-auto overscroll-y-contain rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md subtle-scrollbar pointer-events-auto`,onWheel:Vq,onTouchMove:Bq,children:F?j.map((e,t)=>{let n=t===L,r=G(e.kind);return(0,X.jsxs)(qt,{id:`${O}-option-${t}`,type:`button`,role:`option`,"aria-label":`/${e.path} ${r}`,"aria-selected":n,variant:`ghost`,className:Ut(`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:zq,onClick:()=>ne(e),children:[Iq(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:y(v?{id:`sxTdZI`}:{id:`_QwkMu`})})}):null,ae;t[31]===d?ae=t[32]:(ae=e=>{C(!1),d(e.target.value)},t[31]=d,t[32]=ae);let oe;t[33]===c?oe=t[34]:(oe=e=>{x(!0),c?.(e)},t[33]=c,t[34]=oe);let K;t[35]===s?K=t[36]:(K=e=>{x(!1),s?.(e)},t[35]=s,t[36]=K);let se=I?O:void 0,ce;t[37]!==R||t[38]!==r||t[39]!==W||t[40]!==o||t[41]!==U||t[42]!==I||t[43]!==ae||t[44]!==oe||t[45]!==K||t[46]!==se||t[47]!==g?(ce=(0,X.jsx)(mn,{...o,ref:U,value:g,onChange:ae,onFocus:oe,onBlur:K,onKeyDown:W,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":I,"aria-controls":se,"aria-activedescendant":R,autoComplete:`off`,className:r}),t[37]=R,t[38]=r,t[39]=W,t[40]=o,t[41]=U,t[42]=I,t[43]=ae,t[44]=oe,t[45]=K,t[46]=se,t[47]=g,t[48]=ce):ce=t[48];let q;t[49]===ie?q=t[50]:(q=ie&&(0,Ma.createPortal)(ie,document.body),t[49]=ie,t[50]=q);let le;return t[51]!==ce||t[52]!==q?(le=(0,X.jsxs)(`div`,{className:`relative`,children:[ce,q]}),t[51]=ce,t[52]=q,t[53]=le):le=t[53],le}function zq(e){return e.preventDefault()}function Bq(e){e.stopPropagation()}function Vq(e){e.stopPropagation()}function Hq(e){return Math.max(e-1,0)}function Uq(e){return`${e.kind}:${e.path}`}var Wq=1500;function Gq(e){let t=(0,Z.c)(15),{copyContent:n}=e,[r,i]=(0,Q.useState)(!1),a=(0,Q.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,Q.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),Wq)},Kq)}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)(fn,{className:`size-3.5`,"aria-hidden":`true`}):(0,X.jsx)(Ni,{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)(sr,{asChild:!0,children:(0,X.jsx)(qt,{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)(ur,{children:p}),t[10]=p,t[11]=m);let h;return t[12]!==f||t[13]!==m?(h=(0,X.jsxs)(mr,{children:[f,m]}),t[12]=f,t[13]=m,t[14]=h):h=t[14],h}function Kq(){}function qq(e,t){return uO.getState(e)?.byId.get(t)??null}function Jq(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 Yq(e){let{editor:t,layer:n,markTypes:r,predicate:i,renderPropPanel:a,handlePrimary:o}=e,s=Jq({editor:t,layer:n,renderPropPanel:a,handlePrimary:o});return hO({markTypes:[...r],predicate:i,onRegister:s.onRegister,onDeregister:s.onDeregister})}function Xq(e){let t=kO(e.editor);return Yq({...e,layer:t})}function Zq(e,t){let n=(0,Z.c)(4),[r,i]=(0,Q.useState)(null),a,o;return n[0]!==e||n[1]!==t?(a=()=>{if(!t||!e){i(null);return}let n=!1;return i(null),AW(e).then(e=>{n||i(e)}).catch(()=>{n||i([])}),()=>{n=!0}},o=[e,t],n[0]=e,n[1]=t,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Q.useEffect)(a,o),r}function Qq(e,t){let n=e.trim();return n?n.startsWith(`#`)?`anchor`:V(n)?`external`:`doc`:t}function $q(e){return e?.kind===`doc`?`doc`:e?.kind===`anchor`?`anchor`:`external`}function eJ(e){let t=(0,Z.c)(84),{open:n,href:r,text:a,pages:s,folderPaths:c,loading:l,onOpenChange:u,onSave:d}=e,[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(`doc`),b=(0,Q.useId)(),x=(0,Q.useId)(),S=(0,Q.useId)(),C=(0,Q.useId)(),{_:w}=i(),T=(0,Q.useRef)(!1),E=(0,Q.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=HU(r);if(y($q(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,Q.useEffect)(D,O);let k,A,j;t[5]!==v||t[6]!==f||t[7]!==s?(k=An(f),A=v===`doc`,j=A&&qD(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=Zq(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?$U(k,m.trim()||null):e,g,g.trim()!==E.current.trim()),u(!1))},t[11]=k,t[12]=A,t[13]=m,t[14]=g,t[15]=f,t[16]=u,t[17]=d,t[18]=P):P=t[18];let F=P,I;t[19]===F?I=t[20]:(I=function(e){e.key===`Enter`&&(e.preventDefault(),F())},t[19]=F,t[20]=I);let L=I,R;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(R=function(e){p(e.path),y(`doc`),h(``)},t[21]=R):R=t[21];let z=R,B;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,X.jsx)(Xt,{children:(0,X.jsx)(o,{id:`B11p-O`})}),t[22]=B):B=t[22];let ee;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,X.jsxs)(ln,{children:[B,(0,X.jsx)(Yt,{children:(0,X.jsx)(o,{id:`RobAKV`})})]}),t[23]=ee):ee=t[23];let V;t[24]===A?V=t[25]:(V=A?(0,X.jsx)(o,{id:`6WdDG7`}):(0,X.jsx)(o,{id:`6vEr3W`}),t[24]=A,t[25]=V);let te;t[26]!==V||t[27]!==b?(te=(0,X.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:b,children:V}),t[26]=V,t[27]=b,t[28]=te):te=t[28];let H;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>{p(e),y(t=>Qq(e,t))},t[29]=H):H=t[29];let U;t[30]===w?U=t[31]:(U=w({id:`Xl-UUg`}),t[30]=w,t[31]=U);let ne;t[32]!==f||t[33]!==c||t[34]!==L||t[35]!==l||t[36]!==s||t[37]!==U||t[38]!==b?(ne=(0,X.jsx)(Rq,{id:b,value:f,pages:s,folderPaths:c,loading:l,onValueChange:H,onSuggestionSelect:z,placeholder:U,autoFocus:!0,onKeyDown:L}),t[32]=f,t[33]=c,t[34]=L,t[35]=l,t[36]=s,t[37]=U,t[38]=b,t[39]=ne):ne=t[39];let W;t[40]!==te||t[41]!==ne?(W=(0,X.jsxs)(`div`,{children:[te,ne]}),t[40]=te,t[41]=ne,t[42]=W):W=t[42];let re;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,X.jsx)(o,{id:`QqBQu1`,components:{0:(0,X.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[43]=re):re=t[43];let G;t[44]===S?G=t[45]:(G=(0,X.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:S,children:re}),t[44]=S,t[45]=G);let ie;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>_(e.target.value),t[46]=ie):ie=t[46];let ae;t[47]===w?ae=t[48]:(ae=w({id:`yYR6za`}),t[47]=w,t[48]=ae);let oe;t[49]!==g||t[50]!==L||t[51]!==S||t[52]!==ae?(oe=(0,X.jsx)(mn,{id:S,value:g,onChange:ie,placeholder:ae,onKeyDown:L}),t[49]=g,t[50]=L,t[51]=S,t[52]=ae,t[53]=oe):oe=t[53];let K;t[54]!==G||t[55]!==oe?(K=(0,X.jsxs)(`div`,{children:[G,oe]}),t[54]=G,t[55]=oe,t[56]=K):K=t[56];let se;t[57]!==w||t[58]!==x||t[59]!==A||t[60]!==m||t[61]!==L||t[62]!==C||t[63]!==M||t[64]!==N?(se=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)(mn,{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:Ut(`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]=se):se=t[65];let ce;t[66]!==W||t[67]!==K||t[68]!==se?(ce=(0,X.jsxs)(an,{className:`space-y-6 pb-1`,children:[W,K,se]}),t[66]=W,t[67]=K,t[68]=se,t[69]=ce):ce=t[69];let q;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,X.jsx)(cn,{asChild:!0,children:(0,X.jsx)(qt,{variant:`outline`,children:(0,X.jsx)(o,{id:`dEgA5A`})})}),t[70]=q):q=t[70];let le;t[71]===f?le=t[72]:(le=f.trim(),t[71]=f,t[72]=le);let ue=!le,de;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,X.jsx)(o,{id:`tfDRzk`}),t[73]=de):de=t[73];let fe;t[74]!==F||t[75]!==ue?(fe=(0,X.jsxs)(on,{children:[q,(0,X.jsx)(qt,{onClick:F,disabled:ue,children:de})]}),t[74]=F,t[75]=ue,t[76]=fe):fe=t[76];let pe;t[77]!==ce||t[78]!==fe?(pe=(0,X.jsxs)(tn,{className:`sm:max-w-xl`,"data-ok-layer-spawned":``,onPointerDownOutside:Fq,onFocusOutside:Fq,onInteractOutside:Fq,children:[ee,ce,fe]}),t[77]=ce,t[78]=fe,t[79]=pe):pe=t[79];let me;return t[80]!==u||t[81]!==n||t[82]!==pe?(me=(0,X.jsx)(un,{open:n,onOpenChange:u,children:pe}),t[80]=u,t[81]=n,t[82]=pe,t[83]=me):me=t[83],me}function tJ(e){let t=(0,Z.c)(99),{editor:n,nodeId:r,sourceDocName:a,onClose:s,onNavigate:c}=e,l=qq(n.state,r),u=l?.attrs?.href??``,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),h;t[0]!==r||t[1]!==f?(h=()=>{lO(r)&&f(!0)},t[0]=r,t[1]=f,t[2]=h):h=t[2];let g;t[3]===r?g=t[4]:(g=[r],t[3]=r,t[4]=g),(0,Q.useEffect)(h,g);let{addPage:_,folderPaths:v,pages:y,loading:b}=jn(),{_:x}=i();if(!l)return null;let S=n.state.doc.textBetween(l.from,l.to),C=u?k(u,a):null,w;t[5]!==n||t[6]!==r?(w=function(e,t,i){let a=qq(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=qq(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=qq(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 A=(0,X.jsx)(eJ,{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:A});let j=C?.kind===`doc`?`${C.docName}${C.anchor?`#${C.anchor}`:``}`:C?.kind===`anchor`?`#${C.anchor}`:C?.kind===`external`?C.url:u,M=function(e){let t=qq(n.state,r);t&&n.chain().setTextSelection({from:t.from,to:t.to}).extendMarkRange(`link`).updateAttributes(`link`,{href:$U(e,C?.kind===`doc`?C.anchor??null:null)}).run()},N,P=!1,F=!1,I=null;if(b){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(oa,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),t[17]=e):e=t[17],N={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)(Vi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[18]=e):e=t[18],N={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)(En,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[19]=e):e=t[19],N={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)(Vi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[20]=e):e=t[20],N={icon:e,text:x({id:`dprWmL`}),className:`text-muted-foreground`}}else if(C?.kind===`doc`){let e=AU(C.docName,{pages:y,folderPaths:v});if(F=e.kind===`navigate`&&e.displayState===`folder`,P=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)(Wi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[21]=e):e=t[21],N={icon:e,text:x({id:`kNqMMd`}),className:`text-muted-foreground`}}else if(P){let e;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ei,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[22]=e):e=t[22],N={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)(Vi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[23]=e):e=t[23],N={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)(Ei,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[24]=e):e=t[24],N={icon:e,text:x({id:`-g6KIS`}),className:`text-muted-foreground/80`}}let L=C?.kind===`external`,R=C?.kind===`doc`?UU({docName:C.docName,anchor:C.anchor}):C?.kind===`anchor`?UU({docName:a,anchor:C.anchor}):C?.kind===`external`&&BU(C.url)?C.url:null,z=!b&&R!==null&&(C?.kind===`anchor`||C?.kind===`external`||C?.kind===`doc`&&!P&&!F),B;t[25]!==n.state||t[26]!==n.view||t[27]!==r?(B=()=>{let e=qq(n.state,r);if(!e)return new DOMRect;try{return zt(n.view,e.from,e.to)}catch{return new DOMRect}},t[25]=n.state,t[26]=n.view,t[27]=r,t[28]=B):B=t[28];let ee;t[29]!==n.view.dom||t[30]!==B?(ee={getBoundingClientRect:B,contextElement:n.view.dom},t[29]=n.view.dom,t[30]=B,t[31]=ee):ee=t[31];let V=ee,te;t[32]!==x||t[33]!==_||t[34]!==p||t[35]!==I||t[36]!==s||t[37]!==M?(te=async function(){if(!(!I||p)){m(!0);try{await Cq(I,{addPage:_,onCreated(e){M(e),window.location.hash=`#/${e}`,s()}}),m(!1)}catch(e){let t=e;zn.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]=M,t[38]=te):te=t[38];let H=te,U=Ut(`flex shrink-0`,N.className),ne;t[39]!==N.icon||t[40]!==U?(ne=(0,X.jsx)(`span`,{className:U,children:N.icon}),t[39]=N.icon,t[40]=U,t[41]=ne):ne=t[41];let W=ne,re;t[42]!==W||t[43]!==P||t[44]!==N.text?(re=P?(0,X.jsxs)(mr,{children:[(0,X.jsx)(sr,{asChild:!0,children:(0,X.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`internal-link-prop-panel-icon-trigger`,children:W})}),(0,X.jsx)(ur,{children:N.text})]}):W,t[42]=W,t[43]=P,t[44]=N.text,t[45]=re):re=t[45];let G=re,ie=`${N.text}: ${j}`,ae;t[46]!==j||t[47]!==L||t[48]!==P||t[49]!==R||t[50]!==z||t[51]!==s||t[52]!==c?(ae=(0,X.jsx)(sr,{asChild:!0,children:z?(0,X.jsx)(`a`,{href:R??void 0,...L?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>XU(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:j}):(0,X.jsx)(`span`,{"data-slot":`internal-link-prop-panel-text`,className:Ut(`block truncate text-sm font-medium`,P?`text-muted-foreground`:`text-foreground`),children:j})}),t[46]=j,t[47]=L,t[48]=P,t[49]=R,t[50]=z,t[51]=s,t[52]=c,t[53]=ae):ae=t[53];let oe;t[54]===j?oe=t[55]:(oe=(0,X.jsx)(ur,{className:`max-w-80 break-all`,children:j}),t[54]=j,t[55]=oe);let K;t[56]!==ae||t[57]!==oe?(K=(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(mr,{children:[ae,oe]})}),t[56]=ae,t[57]=oe,t[58]=K):K=t[58];let se;t[59]!==H||t[60]!==p||t[61]!==P?(se=P?(0,X.jsxs)(qt,{type:`button`,size:`sm`,variant:`link`,disabled:p,onClick:()=>void H(),"data-slot":`internal-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,X.jsx)(ma,{className:`size-3.5`,"aria-hidden":`true`}),p?(0,X.jsx)(o,{id:`HM56Bx`}):(0,X.jsx)(o,{id:`XRuL0i`})]}):null,t[59]=H,t[60]=p,t[61]=P,t[62]=se):se=t[62];let ce;t[63]===x?ce=t[64]:(ce=x({id:`ePK91l`}),t[63]=x,t[64]=ce);let q;t[65]===f?q=t[66]:(q=()=>f(!0),t[65]=f,t[66]=q);let le;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,X.jsx)(pa,{className:`size-3.5`,"aria-hidden":`true`}),t[67]=le):le=t[67];let ue;t[68]!==ce||t[69]!==q?(ue=(0,X.jsx)(sr,{asChild:!0,children:(0,X.jsx)(qt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":ce,onClick:q,"data-slot":`internal-link-prop-panel-edit`,children:le})}),t[68]=ce,t[69]=q,t[70]=ue):ue=t[70];let de;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,X.jsx)(ur,{children:(0,X.jsx)(o,{id:`ePK91l`})}),t[71]=de):de=t[71];let fe;t[72]===ue?fe=t[73]:(fe=(0,X.jsxs)(mr,{children:[ue,de]}),t[72]=ue,t[73]=fe);let pe;t[74]===u?pe=t[75]:(pe=(0,X.jsx)(Gq,{copyContent:u}),t[74]=u,t[75]=pe);let me;t[76]===x?me=t[77]:(me=x({id:`t_YqKh`}),t[76]=x,t[77]=me);let he;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,X.jsx)(Ta,{className:`size-3.5`,"aria-hidden":`true`}),t[78]=he):he=t[78];let ge;t[79]!==D||t[80]!==me?(ge=(0,X.jsx)(sr,{asChild:!0,children:(0,X.jsx)(qt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":me,onClick:D,"data-slot":`internal-link-prop-panel-remove`,children:he})}),t[79]=D,t[80]=me,t[81]=ge):ge=t[81];let _e;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,X.jsx)(ur,{children:(0,X.jsx)(o,{id:`t_YqKh`})}),t[82]=_e):_e=t[82];let ve;t[83]===ge?ve=t[84]:(ve=(0,X.jsxs)(mr,{children:[ge,_e]}),t[83]=ge,t[84]=ve);let ye;t[85]!==se||t[86]!==fe||t[87]!==pe||t[88]!==ve?(ye=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[se,fe,pe,ve]}),t[85]=se,t[86]=fe,t[87]=pe,t[88]=ve,t[89]=ye):ye=t[89];let be;t[90]!==G||t[91]!==K||t[92]!==ye?(be=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[G,K,ye]}),t[90]=G,t[91]=K,t[92]=ye,t[93]=be):be=t[93];let xe;return t[94]!==s||t[95]!==ie||t[96]!==be||t[97]!==V?(xe=(0,X.jsx)(pq,{kind:`internal-link`,ariaLabel:ie,onDeactivate:s,triggerReference:V,className:`w-96`,children:be}),t[94]=s,t[95]=ie,t[96]=be,t[97]=V,t[98]=xe):xe=t[98],(0,X.jsxs)(X.Fragment,{children:[A,xe]})}new N(`markIdentityDecoration`);var nJ=`data-mark-id`,rJ=new N(`linkResolutionDecoration`);function iJ(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={[nJ]:e.id};t!==null&&Object.assign(o,t),a.push(O.inline(e.from,e.to,o))}return a.length===0?null:q.create(e,a)}function aJ(e){let t=new Set(e.markTypes),{computeAttrs:n}=e;return new pt({key:rJ,state:{init:()=>({version:0}),apply(e,t){let n=e.getMeta(rJ);return n&&typeof n==`object`&&n.refresh?{version:t.version+1}:t}},props:{decorations(e){let r=uO.getState(e);if(!r)return null;let i=Ln();return iJ(e.doc,r.byId,t,n,i)}},view(e){$(`ok/render/decoration-merge`,{markTypes:Array.from(t).join(`,`)},{startTime:performance.now(),duration:0});let n=On(()=>{e.dispatch(e.state.tr.setMeta(rJ,{refresh:!0}))});return{destroy(){n()}}}})}var oJ=j.extend({addOptions(){return{...this.parent?.(),docName:``}},renderHTML({HTMLAttributes:e}){let t=typeof e.href==`string`?e.href:``;return[`span`,ne(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=qq(t.state,n),a=i?.attrs?.href;if(typeof a!=`string`||!a)return!1;let o=i?.attrs?.sourceForm,s=k(a,e),c=$e(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=gt(t,e);if(!i)return!1;let o=Ln();return o===null||(o.assetPaths!==void 0||o.filePaths!==void 0)&&!MU(t,e,o.assetPaths,o.filePaths)?!1:(JU({url:t,projectRelPath:i,ext:n,title:i.split(`/`).pop()??t,newTab:r}),!0)}if(!s)return!1;switch(s.kind){case`doc`:{let e=Ln(),t=AU(s.docName,{pages:e?.pages??new Set,folderPaths:e?.folderPaths??new Set});return t.kind===`create`||t.kind===`navigate`&&t.displayState===`folder`?!1:(r?KU({docName:s.docName,anchor:s.anchor}):window.location.assign(UU({docName:s.docName,anchor:s.anchor})),!0)}case`anchor`:return r?KU({docName:e,anchor:s.anchor}):window.location.assign(UU({docName:e,anchor:s.anchor})),!0;case`external`:return BU(s.url)?(WU(s.url),!0):!1;default:return d(s)}};return[Xq({editor:this.editor,markTypes:[`link`],renderPropPanel:({editor:n,nodeId:r,deactivate:i})=>(0,Q.createElement)(tJ,{editor:n,nodeId:r,sourceDocName:e,onClose:i,onNavigate:e=>t({editor:n,nodeId:r,newTab:e})}),handlePrimary:t}),aJ({markTypes:[`link`],computeAttrs:FU(e)}),fq({sourceDocName:e})]}}),sJ=(0,Q.createContext)(null),cJ={didCatch:!1,error:null},lJ=class extends Q.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=cJ}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(cJ))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&uJ(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState(cJ))}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:a}=this.state,o=e;if(i){let e={error:a,resetErrorBoundary:this.resetErrorBoundary};if(typeof t==`function`)o=t(e);else if(n)o=(0,Q.createElement)(n,e);else if(r!==void 0)o=r;else throw a}return(0,Q.createElement)(sJ.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function uJ(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}function dJ(e){let t=(0,Z.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=Ut(`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:fJ,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 fJ(e){e.preventDefault(),e.stopPropagation()}function pJ(e){let t=(0,Z.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)(Os,{"data-slot":`select`,...n}),t[2]=n,t[3]=r),r}function mJ(e){let t=(0,Z.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)(As,{"data-slot":`select-value`,...n}),t[2]=n,t[3]=r),r}function hJ(e){let t=(0,Z.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=Ut(`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)(js,{asChild:!0,children:(0,X.jsx)(wi,{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)(ks,{"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 gJ(e){let t=(0,Z.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=Ut(`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)(vJ,{}),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=Ut(`p-1`,u),t[9]=u,t[10]=d);let f;t[11]!==n||t[12]!==d?(f=(0,X.jsx)(Ps,{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)(yJ,{}),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)(Ms,{children:(0,X.jsxs)(Ns,{"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 _J(e){let t=(0,Z.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=Ut(`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)(Ls,{children:(0,X.jsx)(fn,{className:`size-4`})})}),t[6]=o):o=t[6];let s;t[7]===n?s=t[8]:(s=(0,X.jsx)(Is,{children:n}),t[7]=n,t[8]=s);let c;return t[9]!==i||t[10]!==a||t[11]!==s?(c=(0,X.jsxs)(Fs,{"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 vJ(e){let t=(0,Z.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=Ut(`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)(Ti,{className:`size-4`}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,X.jsx)(Rs,{"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 yJ(e){let t=(0,Z.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=Ut(`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)(wi,{className:`size-4`}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,X.jsx)(zs,{"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 bJ(e){let t=(0,Z.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=Ut(`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)(Qs,{"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)(Zs,{"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 xJ(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 SJ(e){let t=(0,Z.c)(36),{id:n,value:r,onChange:i,autoFocus:a}=e,o=(0,Q.useRef)(null),s;t[0]===i?s=t[1]:(s=e=>i(e.target.value),t[0]=i,t[1]=s);let c=a?``:void 0,l=r?`pl-7`:void 0,u;t[2]===l?u=t[3]:(u=Ut(`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)(mn,{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)(qt,{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]:(_=xJ(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)(qt,{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)(Pi,{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 CJ(e){let t=(0,Z.c)(43),{id:n,value:r,onChange:i,autoFocus:a}=e,[o,s]=(0,Q.useState)(!1),c;t[0]===r?c=t[1]:(c=PO(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=Ut(`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)(mn,{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)(wi,{className:`size-3`,"aria-hidden":`true`}),t[20]=y):y=t[20];let b;t[21]===o?b=t[22]:(b=(0,X.jsx)(ic,{asChild:!0,children:(0,X.jsx)(qt,{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)(Gb,{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)(qb,{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)(Jb,{children:(0,X.jsxs)(Yb,{value:`__clear__`,onSelect:()=>{i(``),s(!1)},className:`gap-2 text-muted-foreground`,"data-icon-picker-clear":``,children:[(0,X.jsx)(Bn,{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=NO.map(e=>{let[t,n]=e,r=t===d;return(0,X.jsx)(Yb,{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:Ut(`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)(Jb,{heading:`Lucide`,children:(0,X.jsx)(jb.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)(ac,{align:`end`,className:`z-70 w-72 p-0`,onOpenAutoFocus:wJ,children:(0,X.jsxs)(Ub,{label:`Icon picker`,children:[x,(0,X.jsxs)(Kb,{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)(rc,{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 wJ(e){return e.preventDefault()}function TJ(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 EJ(e){if(e.length===1&&e[0]===`*/*`)return`all`;let t=new Set;for(let n of e){if(n===`*/*`)return`all`;let e=TJ(n);e&&t.add(e)}return t}function DJ(e){let t=e.lastIndexOf(`.`);return t<0||t<e.lastIndexOf(`/`)?``:e.slice(t+1).toLowerCase()}function OJ(e,t){let n=EJ(t),r=[];for(let t of e){if(n===`all`){r.push(t);continue}let e=w(DJ(t));e&&n.has(e)&&r.push(t)}return r}var kJ=8,AJ=new Set,jJ=null;function MJ(e){return{path:e,basename:e.split(`/`).pop()??e}}function NJ(e){let t=e.map(e=>e.path).join(``);return jJ?.fingerprint===t||(jJ={fingerprint:t,byPath:new Map(e.map(e=>[e.path,e])),itemsInOrder:e,corpus:ht(e.map(e=>Ue({kind:`page`,path:e.path,title:e.basename})))}),jJ}function PJ(e){let t=e.trim();return t.startsWith(`/`)?t.slice(1):t}function FJ(e,t){let n=PJ(t);return n?st(e.corpus,n,{intent:`autocomplete`,limit:kJ}).map(t=>e.byPath.get(t.document.path)).filter(e=>!!e):e.itemsInOrder.slice(0,kJ)}function IJ(e){let t=(0,Z.c)(52),{value:n,onChange:r,accept:i,id:a,placeholder:o,autoFocus:s,ariaInvalid:c,ariaDescribedBy:l,dataPropAutofocus:u,className:d,onSubmit:f}=e,p=Fn()?.assetPaths??AJ,m;t[0]!==i||t[1]!==p||t[2]!==n?(m=FJ(NJ(OJ(p,i).map(MJ)),n),t[0]=i,t[1]=p,t[2]=n,t[3]=m):m=t[3];let h=m,[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(0),b,x;t[4]!==v||t[5]!==h.length?(b=()=>{v>=h.length&&y(0)},x=[v,h.length],t[4]=v,t[5]=h.length,t[6]=b,t[7]=x):(b=t[6],x=t[7]),(0,Q.useEffect)(b,x);let S=(0,Q.useId)(),C=(0,Q.useRef)(null),w=g&&h.length>0,T;t[8]===r?T=t[9]:(T=e=>{r(`/${e.path}`),_(!1),y(0),C.current?.focus()},t[8]=r,t[9]=T);let E=T,D;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>_(e),t[10]=D):D=t[10];let O=w?S:void 0,k=w&&h[v]?`${S}-opt-${v}`:void 0,A;t[11]===r?A=t[12]:(A=e=>{r(e.target.value),_(!0),y(0)},t[11]=r,t[12]=A);let j,M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{_(!0)},j=()=>{_(!0)},t[13]=j,t[14]=M):(j=t[13],M=t[14]);let N;t[15]!==v||t[16]!==f||t[17]!==E||t[18]!==h||t[19]!==w?(N=e=>{if(e.key===`ArrowDown`){if(h.length===0)return;e.preventDefault(),_(!0),y(e=>(e+1)%h.length);return}if(e.key===`ArrowUp`){if(h.length===0)return;e.preventDefault(),_(!0),y(e=>(e-1+h.length)%h.length);return}if(e.key===`Enter`){if(w){let t=h[v];if(t){e.preventDefault(),E(t);return}}f&&(e.preventDefault(),f());return}if(e.key===`Escape`){if(!w)return;e.preventDefault(),e.stopPropagation(),_(!1);return}e.key===`Tab`&&_(!1)},t[15]=v,t[16]=f,t[17]=E,t[18]=h,t[19]=w,t[20]=N):N=t[20];let P;t[21]!==l||t[22]!==c||t[23]!==s||t[24]!==d||t[25]!==u||t[26]!==a||t[27]!==o||t[28]!==N||t[29]!==O||t[30]!==k||t[31]!==A||t[32]!==n||t[33]!==w?(P=(0,X.jsx)(oc,{asChild:!0,children:(0,X.jsx)(mn,{ref:C,id:a,type:`text`,value:n,placeholder:o,autoFocus:s,"data-prop-autofocus":u,"aria-invalid":c,"aria-describedby":l,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":w,"aria-controls":O,"aria-activedescendant":k,className:d,onChange:A,onFocus:M,onClick:j,onKeyDown:N})}),t[21]=l,t[22]=c,t[23]=s,t[24]=d,t[25]=u,t[26]=a,t[27]=o,t[28]=N,t[29]=O,t[30]=k,t[31]=A,t[32]=n,t[33]=w,t[34]=P):P=t[34];let F;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{let t=e.target;t instanceof Node&&C.current?.contains(t)&&e.preventDefault()},t[35]=F):F=t[35];let I;if(t[36]!==v||t[37]!==S||t[38]!==E||t[39]!==h){let e;t[41]!==v||t[42]!==S||t[43]!==E?(e=(e,t)=>{let n=`${S}-opt-${t}`,r=t===v;return(0,X.jsxs)(`button`,{id:n,type:`button`,role:`option`,"aria-selected":r,"data-testid":`src-autocomplete-option`,"data-highlighted":r?``:void 0,className:Ut(`flex w-full flex-col items-start gap-0.5 rounded-sm px-2 py-1 text-left text-xs`,`transition-colors`,r?`bg-accent text-accent-foreground`:`hover:bg-accent/50`),onMouseEnter:()=>y(t),onMouseDown:t=>{t.preventDefault(),E(e)},children:[(0,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[41]=v,t[42]=S,t[43]=E,t[44]=e):e=t[44],I=h.map(e),t[36]=v,t[37]=S,t[38]=E,t[39]=h,t[40]=I}else I=t[40];let L;t[45]!==S||t[46]!==I?(L=(0,X.jsx)(ac,{align:`start`,sideOffset:4,className:`z-70 w-(--radix-popover-trigger-width) p-1`,onOpenAutoFocus:RJ,onCloseAutoFocus:LJ,onInteractOutside:F,children:(0,X.jsx)(`div`,{id:S,role:`listbox`,"aria-label":`Asset suggestions`,className:`flex flex-col gap-px`,children:I})}),t[45]=S,t[46]=I,t[47]=L):L=t[47];let R;return t[48]!==P||t[49]!==L||t[50]!==w?(R=(0,X.jsxs)(rc,{open:w,onOpenChange:D,children:[P,L]}),t[48]=P,t[49]=L,t[50]=w,t[51]=R):R=t[51],R}function LJ(e){e.preventDefault()}function RJ(e){e.preventDefault()}function zJ(){if(typeof window>`u`)return null;let e=window.location.hash.match(/^#\/([^?#]+)/);return e?decodeURIComponent(e[1]):null}var BJ=`/api/upload`;async function VJ(e,t,n={}){let r=n.fetch??globalThis.fetch,i=n.docName===void 0?zJ():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(BJ,{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 JD(`Upload response is not JSON.`,{cause:e,status:o.status})}if(!o.ok){let e=De.safeParse(s);throw e.success?Error(e.data.title):new JD(`Upload error response did not match ProblemDetails.`,{cause:e.error,status:o.status})}let c=At.safeParse(s);if(!c.success)throw new JD(`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 HJ=new Intl.PluralRules(`en-US`);function UJ(e,t,n){return n<=0?`${e} (empty)`:`${e} with ${n} ${HJ.select(n)===`one`?`item`:`items`}`}function WJ(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 GJ(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 KJ=new Set([`auto`,`inherit`,`initial`,`unset`]),qJ=new Set([`px`,`%`,`rem`,`em`,`vh`,`vw`,`ch`,`ex`,`fr`]),JJ=/^(-?\d+(?:\.\d+)?)([a-z%]*)$/i;function YJ(e){let t=e.trim();if(!t)return{valid:!1,reason:`empty`};if(KJ.has(t.toLowerCase()))return{valid:!0};let n=t.match(JJ);if(!n)return{valid:!1,reason:`malformed-syntax`};let r=(n[2]??``).toLowerCase();return r===``||qJ.has(r)?{valid:!0}:{valid:!1,reason:`unknown-unit`}}function XJ(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 ZJ={video:K,audio:Ee,image:se},QJ={youtube:[`youtube.com`,`youtu.be`,`youtube-nocookie.com`],vimeo:[`vimeo.com`],loom:[`loom.com`]};function $J(e){let t=e.toLowerCase();for(let e of Object.keys(QJ)){let n=QJ[e];for(let r of n)if(t===r||t.endsWith(`.${r}`))return e}return null}function eY(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 tY=`https://placeholder.invalid`;function nY(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,tY),i=!1}catch{return{valid:!1,reason:`invalid-url`}}}if(t===`video`&&Fe(n)!==null||t===`video`&&de(n)||t===`video`&&A(n))return{valid:!0};let a=i?$J(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=eY(r.pathname),s=ZJ[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 rY(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 iY(e){return`Direct ${e} file URL — ${Array.from(ZJ[e]).map(e=>`.${e}`).join(`, `)}`}var aY={youtube:`YouTube`,vimeo:`Vimeo`,loom:`Loom`};function oY(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=aY[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(ZJ[t]).map(e=>`.${e}`).join(`, `);return e.extension===``?`Missing file extension. Accepts: ${n}.`:`Unsupported extension .${e.extension}. Accepts: ${n}.`}function sY(e){return`ok.propPanel.advanced.${e}`}function cY(e){try{return typeof localStorage>`u`?!1:localStorage.getItem(sY(e))===`true`}catch{return!1}}function lY(e,t){try{if(typeof localStorage>`u`)return;localStorage.setItem(sY(e),t?`true`:`false`)}catch{}}function uY(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 dY(e,t,n){try{let{url:r}=await VJ(e,t);n(r)}catch(e){let t=e instanceof Error?e.message:String(e);zn.error(Rn._({id:`02P3hL`,values:{message:t}}))}}function fY(e){let t=(0,Z.c)(14),{descriptor:n,values:r,onChange:i,onDismiss:a}=e,s;t[0]===r?s=t[1]:(s=e=>!(`hidden`in e&&e.hidden)&&e.hideWhen?.(r)!==!0&&e.type!==`reactnode`,t[0]=r,t[1]=s);let c=n.props.filter(s),l=c.filter(mY),u=c.filter(pY),d=uY(u,r),f;t[2]===n.props?f=t[3]:(f=WJ(n.props),t[2]=n.props,t[3]=f);let p=f,m;t[4]===n.name?m=t[5]:(m=()=>cY(n.name),t[4]=n.name,t[5]=m);let[h,g]=(0,Q.useState)(m);if(c.length===0)return null;let _;t[6]!==p||t[7]!==i||t[8]!==a||t[9]!==r?(_=e=>(0,X.jsx)(gY,{propDef:e,value:r[e.name],onChange:t=>i(e.name,t),onDismiss:a,isAutoFocused:e.name===p},e.name),t[6]=p,t[7]=i,t[8]=a,t[9]=r,t[10]=_):_=t[10];let v=l.map(_),y=u.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,X.jsxs)(vn,{open:h,onOpenChange:e=>{g(e),lY(n.name,e)},children:[(0,X.jsxs)(_n,{"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)(wi,{className:`size-3 transition-transform group-data-[state=closed]:-rotate-90`}),(0,X.jsx)(o,{id:`sxkWRg`})]}),d>0&&(0,X.jsx)(nc,{variant:`secondary`,"data-prop-panel-advanced-count":``,children:d})]}),(0,X.jsx)(hn,{className:`flex flex-col gap-4 pt-2`,children:u.map(e=>(0,X.jsx)(gY,{propDef:e,value:r[e.name],onChange:t=>i(e.name,t),onDismiss:a,isAutoFocused:e.name===p},e.name))})]})]}),b;return t[11]!==v||t[12]!==y?(b=(0,X.jsxs)(`div`,{"data-prop-panel":``,className:`flex flex-col gap-4 py-2 text-sm`,children:[v,y]}),t[11]=v,t[12]=y,t[13]=b):b=t[13],b}function pY(e){return`advanced`in e&&e.advanced}function mY(e){return!(`advanced`in e&&e.advanced)}function hY(e){throw Error(`PropPanel: unhandled PropDef type ${JSON.stringify(e)}`)}function gY(e){let t=(0,Z.c)(165),{propDef:n,value:r,onChange:i,onDismiss:a,isAutoFocused:o}=e,s;t[0]===a?s=t[1]:(s=a?e=>{e.key===`Enter`&&(e.preventDefault(),a())}:void 0,t[0]=a,t[1]=s);let c=s;switch(n.type){case`reactnode`:return null;case`string`:{let e=`prop-${n.name}`,s=n.accept,l=s!==void 0&&s.length>0,u=!n.required&&n.defaultValue===void 0;if(n.language){let a=`${e}-label`,s;t[2]===n.name?s=t[3]:(s=GJ(n.name),t[2]=n.name,t[3]=s);let c;t[4]!==a||t[5]!==e||t[6]!==s?(c=(0,X.jsx)(`label`,{id:a,htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[4]=a,t[5]=e,t[6]=s,t[7]=c):c=t[7];let l=r??``,d;t[8]!==i||t[9]!==u?(d=e=>{if(e===``&&u){i(void 0);return}i(e)},t[8]=i,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==o||t[12]!==a||t[13]!==n.language||t[14]!==e||t[15]!==l||t[16]!==d?(f=(0,X.jsx)(fG,{id:e,ariaLabelledBy:a,value:l,language:n.language,onChange:d,autoFocus:o}),t[11]=o,t[12]=a,t[13]=n.language,t[14]=e,t[15]=l,t[16]=d,t[17]=f):f=t[17];let p;return t[18]!==c||t[19]!==f?(p=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,f]}),t[18]=c,t[19]=f,t[20]=p):p=t[20],p}if(n.iconPicker){let a=r??``,s;t[21]===n.name?s=t[22]:(s=GJ(n.name),t[21]=n.name,t[22]=s);let c;t[23]!==e||t[24]!==s?(c=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[23]=e,t[24]=s,t[25]=c):c=t[25];let l;t[26]!==i||t[27]!==u?(l=e=>{if(e===``&&u){i(void 0);return}i(e)},t[26]=i,t[27]=u,t[28]=l):l=t[28];let d;t[29]!==a||t[30]!==o||t[31]!==e||t[32]!==l?(d=(0,X.jsx)(CJ,{id:e,value:a,onChange:l,autoFocus:o}),t[29]=a,t[30]=o,t[31]=e,t[32]=l,t[33]=d):d=t[33];let f;return t[34]!==c||t[35]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,d]}),t[34]=c,t[35]=d,t[36]=f):f=t[36],f}if(n.colorPicker){let a=r??``,s;t[37]===n.name?s=t[38]:(s=GJ(n.name),t[37]=n.name,t[38]=s);let c;t[39]!==e||t[40]!==s?(c=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[39]=e,t[40]=s,t[41]=c):c=t[41];let l;t[42]!==i||t[43]!==u?(l=e=>{if(e===``&&u){i(void 0);return}i(e)},t[42]=i,t[43]=u,t[44]=l):l=t[44];let d;t[45]!==a||t[46]!==o||t[47]!==e||t[48]!==l?(d=(0,X.jsx)(SJ,{id:e,value:a,onChange:l,autoFocus:o}),t[45]=a,t[46]=o,t[47]=e,t[48]=l,t[49]=d):d=t[49];let f;return t[50]!==c||t[51]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,d]}),t[50]=c,t[51]=d,t[52]=f):f=t[52],f}if(n.cssLengthInput){let a=r??``,s;if(t[53]!==a){let e=YJ(a);s=e.valid?null:XJ(e),t[53]=a,t[54]=s}else s=t[54];let l=s,d;t[55]===n.name?d=t[56]:(d=GJ(n.name),t[55]=n.name,t[56]=d);let f;t[57]!==e||t[58]!==d?(f=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:d}),t[57]=e,t[58]=d,t[59]=f):f=t[59];let p;t[60]!==i||t[61]!==u?(p=e=>{let t=e.target.value;if(t===``&&u){i(void 0);return}i(t)},t[60]=i,t[61]=u,t[62]=p):p=t[62];let m=o?``:void 0,h=l===null?void 0:!0,g=l===null?void 0:`${e}-error`,_;t[63]!==a||t[64]!==c||t[65]!==o||t[66]!==e||t[67]!==p||t[68]!==m||t[69]!==h||t[70]!==g?(_=(0,X.jsx)(mn,{id:e,type:`text`,value:a,placeholder:`100px, 50%, 26rem, auto`,onChange:p,onKeyDown:c,autoFocus:o,"data-prop-autofocus":m,"aria-invalid":h,"aria-describedby":g,className:`h-7 text-sm`,"data-prop-css-length-input":``}),t[63]=a,t[64]=c,t[65]=o,t[66]=e,t[67]=p,t[68]=m,t[69]=h,t[70]=g,t[71]=_):_=t[71];let v;t[72]!==l||t[73]!==e?(v=l!==null&&(0,X.jsx)(`p`,{id:`${e}-error`,"data-prop-css-length-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:l}),t[72]=l,t[73]=e,t[74]=v):v=t[74];let y;return t[75]!==v||t[76]!==f||t[77]!==_?(y=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[f,_,v]}),t[75]=v,t[76]=f,t[77]=_,t[78]=y):y=t[78],y}let d,f,p;if(t[79]!==s||t[80]!==r){let e=s===void 0?void 0:rY(s);d=r??``;let n=e===void 0?null:nY(d,e);f=n!==null&&!n.valid&&e!==void 0&&d.trim().length>0?oY(n,e):null,p=e===void 0?void 0:iY(e),t[79]=s,t[80]=r,t[81]=d,t[82]=f,t[83]=p}else d=t[81],f=t[82],p=t[83];let m=p,h;t[84]===n.name?h=t[85]:(h=GJ(n.name),t[84]=n.name,t[85]=h);let g;t[86]!==e||t[87]!==h?(g=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:h}),t[86]=e,t[87]=h,t[88]=g):g=t[88];let _;t[89]!==s||t[90]!==d||t[91]!==c||t[92]!==o||t[93]!==f||t[94]!==m||t[95]!==i||t[96]!==a||t[97]!==e||t[98]!==u?(_=s===void 0?(0,X.jsx)(mn,{id:e,type:`text`,value:d,placeholder:m,onChange:e=>{let t=e.target.value;if(t===``&&u){i(void 0);return}i(t)},onKeyDown:c,autoFocus:o,"data-prop-autofocus":o?``:void 0,"aria-invalid":f===null?void 0:!0,"aria-describedby":f===null?void 0:`${e}-error`,className:`h-7 text-sm`}):(0,X.jsx)(IJ,{id:e,value:d,onChange:e=>{if(e===``&&u){i(void 0);return}i(e)},onSubmit:a,accept:s,placeholder:m,autoFocus:o,dataPropAutofocus:o?``:void 0,ariaInvalid:f===null?void 0:!0,ariaDescribedBy:f===null?void 0:`${e}-error`,className:`h-7 text-sm`}),t[89]=s,t[90]=d,t[91]=c,t[92]=o,t[93]=f,t[94]=m,t[95]=i,t[96]=a,t[97]=e,t[98]=u,t[99]=_):_=t[99];let v;t[100]!==s||t[101]!==i||t[102]!==l?(v=l&&(0,X.jsx)(vY,{accept:s,onUploaded:e=>i(e)}),t[100]=s,t[101]=i,t[102]=l,t[103]=v):v=t[103];let y;t[104]!==_||t[105]!==v?(y=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[_,v]}),t[104]=_,t[105]=v,t[106]=y):y=t[106];let b;t[107]!==f||t[108]!==e?(b=f!==null&&(0,X.jsx)(`p`,{id:`${e}-error`,"data-prop-media-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:f}),t[107]=f,t[108]=e,t[109]=b):b=t[109];let x;return t[110]!==g||t[111]!==y||t[112]!==b?(x=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[g,y,b]}),t[110]=g,t[111]=y,t[112]=b,t[113]=x):x=t[113],x}case`boolean`:{let e=`prop-${n.name}`,a;t[114]===n.name?a=t[115]:(a=GJ(n.name),t[114]=n.name,t[115]=a);let o=a,s;t[116]!==e||t[117]!==o?(s=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[116]=e,t[117]=o,t[118]=s):s=t[118];let c=!!r,l;t[119]===i?l=t[120]:(l=e=>i(e),t[119]=i,t[120]=l);let u;t[121]!==e||t[122]!==c||t[123]!==l?(u=(0,X.jsx)(bJ,{id:e,checked:c,onCheckedChange:l}),t[121]=e,t[122]=c,t[123]=l,t[124]=u):u=t[124];let d;return t[125]!==s||t[126]!==u?(d=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[s,u]}),t[125]=s,t[126]=u,t[127]=d):d=t[127],d}case`enum`:{let e=`prop-${n.name}`,a=r??n.enumValues[0]??``,o;t[128]===n.name?o=t[129]:(o=GJ(n.name),t[128]=n.name,t[129]=o);let s;t[130]!==e||t[131]!==o?(s=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[130]=e,t[131]=o,t[132]=s):s=t[132];let c;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(mJ,{}),t[133]=c):c=t[133];let l;t[134]===e?l=t[135]:(l=(0,X.jsx)(hJ,{id:e,size:`sm`,children:c}),t[134]=e,t[135]=l);let u;t[136]===n.enumValues?u=t[137]:(u=n.enumValues.map(_Y),t[136]=n.enumValues,t[137]=u);let d;t[138]===u?d=t[139]:(d=(0,X.jsx)(gJ,{className:`z-70`,children:u}),t[138]=u,t[139]=d);let f;t[140]!==a||t[141]!==i||t[142]!==l||t[143]!==d?(f=(0,X.jsxs)(pJ,{value:a,onValueChange:i,children:[l,d]}),t[140]=a,t[141]=i,t[142]=l,t[143]=d,t[144]=f):f=t[144];let p;return t[145]!==s||t[146]!==f?(p=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s,f]}),t[145]=s,t[146]=f,t[147]=p):p=t[147],p}case`number`:{let e=`prop-${n.name}`,a;t[148]===n.name?a=t[149]:(a=GJ(n.name),t[148]=n.name,t[149]=a);let o;t[150]!==e||t[151]!==a?(o=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:a}),t[150]=e,t[151]=a,t[152]=o):o=t[152];let s=r==null?``:String(r),l;t[153]===i?l=t[154]:(l=e=>{let t=e.target.value;if(t===``){i(void 0);return}if(t===`-`)return;let n=Number(t);Number.isNaN(n)||i(n)},t[153]=i,t[154]=l);let u;t[155]!==c||t[156]!==e||t[157]!==s||t[158]!==l?(u=(0,X.jsx)(mn,{id:e,type:`number`,inputMode:`numeric`,value:s,onChange:l,onKeyDown:c,className:`h-7 text-sm`}),t[155]=c,t[156]=e,t[157]=s,t[158]=l,t[159]=u):u=t[159];let d;return t[160]!==o||t[161]!==u?(d=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[o,u]}),t[160]=o,t[161]=u,t[162]=d):d=t[162],d}default:{let e;return t[163]===n?e=t[164]:(e=hY(n),t[163]=n,t[164]=e),e}}}function _Y(e){return(0,X.jsx)(_J,{value:e,children:e},e)}function vY(e){let t=(0,Z.c)(17),{accept:n,onUploaded:r}=e,[i,a]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c;t[0]===n?c=t[1]:(c=n.join(`,`),t[0]=n,t[1]=c);let l;t[2]!==n||t[3]!==r?(l=async e=>{let t=e.target.files?.[0];if(t){a(!0);try{await dY(t,n,r)}catch{}a(!1),s.current&&(s.current.value=``)}},t[2]=n,t[3]=r,t[4]=l):l=t[4];let u;t[5]!==c||t[6]!==l?(u=(0,X.jsx)(`input`,{ref:s,type:`file`,accept:c,className:`hidden`,"data-prop-upload-input":``,onChange:l}),t[5]=c,t[6]=l,t[7]=u):u=t[7];let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>s.current?.click(),t[8]=d):d=t[8];let f;t[9]===i?f=t[10]:(f=i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oa,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),(0,X.jsx)(o,{id:`_eguJc`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ea,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(o,{id:`eJitUk`})]}),t[9]=i,t[10]=f);let p;t[11]!==f||t[12]!==i?(p=(0,X.jsx)(qt,{type:`button`,variant:`outline`,size:`sm`,disabled:i,"data-prop-upload-trigger":``,className:`h-7 w-full justify-center gap-1.5 px-2 text-xs`,onClick:d,children:f}),t[11]=f,t[12]=i,t[13]=p):p=t[13];let m;return t[14]!==u||t[15]!==p?(m=(0,X.jsxs)(X.Fragment,{children:[u,p]}),t[14]=u,t[15]=p,t[16]=m):m=t[16],m}var yY=new Set([`img`,`CommonMarkImage`,`video`,`audio`,`Pdf`,`File`]);function bY(e,t,n){if(!yY.has(e)||!n)return t;let r=t.src;if(typeof r!=`string`)return t;let i=M(r,n);return i===r?t:{...t,src:i}}var xY=`selectionStatePlugin/origin`,SY=`selectionStatePlugin/refresh`,CY=new N(`selectionState`),wY=new Set,TY={selectedBlockId:null,ancestorChain:[],selectionOrigin:`programmatic`,isDragging:!1,rangeEncompassedBlockIds:wY};function EY(e){return CY.getState(e.state)??TY}function DY(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(OY(e,i,a))}if(t instanceof I){let r=t.node;r.type.name===`jsxComponent`&&n.push(OY(e,r,t.from))}return n}function OY(e,t,n){let r=t.attrs.componentName??`unknown`;return{bridgeId:kY(e,n),componentName:r,pos:n}}function kY(e,t){return bM.getState(e)?.posToId.get(t)??`pos-${t}`}function AY(e,t){if(t instanceof I)return wY;let{from:n,to:r}=t;if(n>=r)return wY;let i=bM.getState(e)?.posToId;if(!i)return wY;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??wY}function jY(e,t,n={}){let r=DY(e,e.selection),i=r[r.length-1],a=AY(e,e.selection),o={selectedBlockId:i?.bridgeId??null,ancestorChain:r,selectionOrigin:n.origin??t.selectionOrigin,isDragging:n.isDragging??t.isDragging,rangeEncompassedBlockIds:a};return MY(t,o)?t:o}function MY(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 NY=new WeakMap;function PY(e,t,n,r){let i=r?.isDragging??t.isDragging,a=!!e.getMeta(SY),o=e.selectionSet&&!a,s=e.getMeta(xY),c=o?r?.pendingOrigin??null:null,l=s??c??t.selectionOrigin;return o&&r&&(r.pendingOrigin=null),jY(n,t,{origin:l,isDragging:i})}var FY=kt.create({name:`selectionStatePlugin`,addProseMirrorPlugins(){let e=this.editor,t=new pt({key:CY,state:{init(e,t){return jY(t,TY)},apply(e,n,r,i){return PY(e,n,i,NY.get(t))}},props:{handleDOMEvents:{mousedown:()=>{let e=NY.get(t);return e&&(e.pendingOrigin=`pointer`),!1},pointerdown:()=>{let e=NY.get(t);return e&&(e.pendingOrigin=`pointer`),!1}},handleKeyDown:(e,n)=>{if(IY(n.key)){let e=NY.get(t);e&&(e.pendingOrigin=`keyboard`)}return!1}},view(n){NY.set(t,{pendingOrigin:null,isDragging:!1});let r=n.dom.parentElement??n.dom,i=()=>{let n=NY.get(t);n&&(n.isDragging=!0,LY(e))},a=()=>{let n=NY.get(t);n&&(n.isDragging=!1,LY(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),NY.delete(t)}}}});return[t]}});function IY(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 LY(e){queueMicrotask(()=>{if(!e.isDestroyed)try{let t=e.state.tr.setMeta(SY,!0);e.view.dispatch(t)}catch{}})}function RY(e){let t=(0,Z.c)(5),n;t[0]===e?n=t[1]:(n=()=>e?EY(e):null,t[0]=e,t[1]=n);let[r,i]=(0,Q.useState)(n),a,o;return t[2]===e?(a=t[3],o=t[4]):(a=()=>{if(!e){i(null);return}i(EY(e));let t=()=>{i(EY(e))};return e.on(`transaction`,t),e.on(`selectionUpdate`,t),()=>{e.off(`transaction`,t),e.off(`selectionUpdate`,t)}},o=[e],t[2]=e,t[3]=a,t[4]=o),(0,Q.useEffect)(a,o),r}function zY(e,t){if(e.hasChildren)return!1;let n=WJ(e.props);return n===null?!1:t[n]===``}function BY(e){let t=e.placeholder?.label,n=`Add ${(e.displayName??e.name).toLowerCase()}`;return{label:t??n,Icon:jO(e.placeholder?.icon??e.icon)}}var VY=new Set([`img`,`CommonMarkImage`,`Embed`,`video`]);function HY(e){if(!e.attrs.sourceDirty&&e.attrs.sourceRaw)return e.attrs.sourceRaw;let t=qk(),n=e.type.schema.node(`doc`,null,[e]);return t.serialize(n.toJSON()).trim()}var UY=new Set(Ne.map(e=>`${e}:`)),WY=6e4,GY=10,KY=new Map;function qY(e,t){let n=t.toLowerCase();R(n);let r=Date.now(),i=KY.get(n);if(!i||r-i.windowStart>=WY)KY.set(n,{windowStart:r,count:1});else if(i.count+=1,i.count>GY)return;typeof console<`u`&&typeof console.warn==`function`&&console.warn(JSON.stringify({event:`jsx-prop-dropped`,reason:e,prop:t}))}var JY=new Set([`href`,`src`,`action`,`formaction`,`poster`,`cite`,`data`,`manifest`,`background`,`ping`,`xlinkhref`,`xlinkactuate`,`xlinkrole`,`xlinkarcrole`,`xlinkshow`,`url`,`link`]),YY=new Set([`dangerouslysetinnerhtml`,`ref`,`key`,`defaultvalue`,`defaultchecked`,`__proto__`,`constructor`,`prototype`]),XY=1e4;function ZY(e){let t=e.toLowerCase();return!!(YY.has(t)||t.length>=3&&t.startsWith(`on`))}function QY(e){return JY.has(e.toLowerCase())}function $Y(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t||t.startsWith(`#`)||t.startsWith(`//`)||U(t))return e;let n=t.indexOf(`:`),r=t.slice(0,n+1).toLowerCase();return UY.has(r)?e:`#`}function eX(e){if(e.length>XY)return``;let t=e.toLowerCase();return/url\s*\(\s*['"]?\s*(?:javascript|vbscript|data)\s*:/.test(t)||/\bexpression\s*\(/.test(t)?``:e}function tX(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=tX(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(ZY(e)){qY(`dangerous-prop-name-nested`,e),r=!0;continue}if(QY(e)&&typeof t==`string`){let n=$Y(t);n!==t&&(r=!0),i[e]=n}else{let n=tX(t);n!==t&&(r=!0),i[e]=n}}return r?i:e}function nX(e){let t=!1,n={};for(let[r,i]of Object.entries(e)){if(ZY(r)){qY(`dangerous-prop-name`,r),t=!0;continue}if(QY(r)){let e=$Y(i);e!==i&&(t=!0),n[r]=e;continue}if(r===`style`){if(typeof i==`string`){let e=eX(i);e!==i&&(t=!0),n[r]=e}else t=!0;continue}let e=tX(i);e!==i&&(t=!0),n[r]=e}return t?n:e}function rX(e){let t=(0,Z.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 iX(e){let t=(0,Z.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})),Ye(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)(rX,{...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)(lJ,{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 aX(e){if(typeof e!=`object`||!e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(aX).join(`,`)}]`;let t=Object.entries(e);return t.sort(([e],[t])=>e<t?-1:+(e>t)),`{${t.map(([e,t])=>`${JSON.stringify(e)}:${aX(t)}`).join(`,`)}}`}function oX(e,t){let n=e.props??{},r={};for(let[e,i]of Object.entries(n))t.has(e)||(r[e]=i);return nX(r)}function sX(e){return e.kind===`element`?e:null}var cX=3;function lX(e){let t=(0,Z.c)(162),{node:n,editor:r,extension:a,getPos:s,selected:c}=e,{_:u}=i(),d=Gj(n.attrs.componentName),[f,p]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),y=(0,Q.useRef)(!1),b=typeof s==`function`?s():void 0,x=!1,S=0,C=1;try{if(b!==void 0){let e=r.state.doc.resolve(b);e.depth>0&&e.parent.type.name===`jsxComponent`&&(x=!0,S=e.index(e.depth),C=e.parent.childCount)}}catch(e){let t=e;if(!(t instanceof RangeError))throw t}let w=x&&S>0,T=x&&S<C-1,E=RY(r),D=typeof b==`number`?kY(r.state,b):null,O=D!==null&&(E?.rangeEncompassedBlockIds.has(D)??!1),k;t[0]===E?.ancestorChain?k=t[1]:(k=E?.ancestorChain.at(-1)?.bridgeId??null,t[0]=E?.ancestorChain,t[1]=k);let A=D!==null&&k===D,j=c&&!O&&A,M=D!==null&&!A&&(E?.ancestorChain.some(e=>e.bridgeId===D)??!1),N=j&&E?E.selectionOrigin:void 0,P=j&&(E?.isDragging??!1),F=d.props.some(hX),I=n.attrs.props??{},L=F&&d.props.some(e=>e.type!==`string`||!e.required||`hidden`in e&&e.hidden?!1:!Object.hasOwn(I,e.name)),R=zY(d,I),z=R?BY(d):null,B=!d.hasChildren||!!d.isSelfClosing,ee=VY.has(d.name),V=d.name===`MermaidFence`?{propName:`chart`,language:`mermaid`}:d.name===`Math`||d.name===`DollarMath`||d.name===`MathFence`?{propName:`formula`,language:`latex`}:null,[te,H]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{c&&!y.current&&F&&eM(b)&&_(!0),y.current=c},[c,F,b]);let U=oX(n.attrs,d.reactNodePropNames),ne=d.surface===`compat`?d.translateProps(U):U,W=a.options.docName,re=typeof W==`string`&&W?W:PD(r),G=bY(d.name,ne,re),ie=`${d.name}::${aX(U)}`,oe;t[2]!==s||t[3]!==n.content.size?(oe=()=>(typeof s==`function`?s()??0:0)+1+n.content.size,t[2]=s,t[3]=n.content.size,t[4]=oe):oe=t[4];let K=oe,se=d.name===`*`||f!==null,ce=(0,Q.useRef)(!1),q=(0,Q.useRef)(0),[le,ue]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{if(!se||ce.current||le)return;let e=typeof s==`function`?s():void 0;if(typeof e!=`number`)return;let t=HY(n),i=d.name===`*`?`Unregistered component: ${n.attrs.componentName}`:`Render error in <${d.displayName??d.name}>: ${f?.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)),ce.current=!0,Ot(d.name===`*`?`wildcard`:d.name)}catch(e){let t=e,r=d.name===`*`?`wildcard`:d.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:q.current})),m(r),q.current+=1,q.current<cX){let e=50*(2**q.current-1);c=setTimeout(()=>{o||l()},e)}else o||ue(!0)}},u=requestAnimationFrame(l);return()=>{o=!0,cancelAnimationFrame(u),c!==void 0&&clearTimeout(c)}},[se,n,r,s,d,f,le]),le){let e=n.attrs.componentName,i=d.displayName??d.name,a=d.name===`*`?u({id:`Kh1n4a`,values:{componentName:e}}):u({id:`g58Kwy`,values:{descriptorLabel:i}}),o=()=>{try{let e=HY(n);typeof navigator<`u`&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(e)}catch(e){let t=e;l(d.name),console.warn(JSON.stringify({event:`jsx-component-stuck-copy-failed`,component:d.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;Ke(d.name),console.warn(JSON.stringify({event:`jsx-component-stuck-delete-failed`,component:d.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f={[JP]:`true`},t[5]=f):f=t[5];let p;t[6]===a?p=t[7]:(p=(0,X.jsx)(`span`,{className:`flex-1`,children:a}),t[6]=a,t[7]=p);let m;t[8]===u?m=t[9]:(m=u({id:`E2Mv-X`}),t[8]=u,t[9]=m);let h;t[10]!==o||t[11]!==m?(h=(0,X.jsx)(`button`,{type:`button`,className:`text-xs underline hover:no-underline`,onClick:o,children:m}),t[10]=o,t[11]=m,t[12]=h):h=t[12];let g;t[13]===u?g=t[14]:(g=u({id:`cnGeoo`}),t[13]=u,t[14]=g);let _;t[15]!==c||t[16]!==g?(_=(0,X.jsx)(`button`,{type:`button`,className:`text-xs underline hover:no-underline`,onClick:c,children:g}),t[15]=c,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==h||t[19]!==_||t[20]!==p?(v=(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,...f,children:[p,h,_]}),t[18]=h,t[19]=_,t[20]=p,t[21]=v):v=t[21];let y;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,X.jsx)(Al,{className:`component-children`}),t[22]=y):y=t[22];let b;return t[23]===v?b=t[24]:(b=(0,X.jsxs)(jl,{className:`jsx-component-wrapper my-2`,children:[v,y]}),t[23]=v,t[24]=b),b}if(se){let e=n.attrs.componentName,r=d.displayName??d.name,i=d.name===`*`?u({id:`oJl7eO`,values:{componentName:e}}):u({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)(Al,{className:`component-children`}),t[27]=o):o=t[27];let s;return t[28]===a?s=t[29]:(s=(0,X.jsxs)(jl,{className:`jsx-component-wrapper my-2`,children:[a,o]}),t[28]=a,t[29]=s),s}let de=d.Component,fe=d.displayName??d.name,pe=d.displayName??d.name,me=d.displayName??d.name,he=e=>{if(R||!B)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 b!=`number`)return;let n=r.state.doc.nodeAt(b);if(!n)return;let i=b+n.nodeSize,a=r.state.selection.from;a<b||a>=i||r.chain().focus().setNodeSelection(b).run()},ge;t[30]!==r||t[31]!==s||t[32]!==_?(ge=()=>{let e=typeof s==`function`?s():void 0;typeof e==`number`&&(r.chain().focus().setNodeSelection(e).run(),_(!0))},t[30]=r,t[31]=s,t[32]=_,t[33]=ge):ge=t[33];let _e=ge,ve=d.displayName??d.name,ye=!!d.emptyChildName,be=ye?UJ(ve,d.emptyChildName,n.childCount):void 0,xe=e=>{let t=e.target;if(e.key===`Backspace`||e.key===`Delete`){if(!j||!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()||(ae(d.name),console.warn(JSON.stringify({event:`jsx-component-keyboard-delete-failed`,component:d.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;ae(d.name),console.warn(JSON.stringify({event:`jsx-component-keyboard-delete-failed`,component:d.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}return}e.key!==`Enter`&&e.key!==` `||c&&F&&(t.closest(`.jsx-component-chrome`)||t.closest(`input, textarea, select, button`)||(e.preventDefault(),_(!0)))},Se=e=>{_(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(B){let e=r.state.doc.resolve(Math.min(n,r.state.doc.content.size)),t=Ce.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;h(d.name),console.warn(JSON.stringify({event:`jsx-component-popover-close-restore-failed`,component:d.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}})},we=rc,Te=jl,Ee;t[34]===d.name?Ee=t[35]:(Ee=d.name.toLowerCase(),t[34]=d.name,t[35]=Ee);let De;bb0:{let e=I.align;if(e===`left`||e===`right`||e===`center`){De=e;break bb0}if(ee){De=`center`;break bb0}De=void 0}let Oe=j?`true`:void 0,ke=M?`true`:void 0,Ae=O?`true`:void 0,je=P?`true`:void 0,Me=L?`true`:void 0,Ne=ye?`group`:void 0,Pe=j?0:-1,Fe;t[36]===x?Fe=t[37]:(Fe=x?{draggable:`false`,onDragStart:mX}:{"data-drag-handle":``,draggable:`true`},t[36]=x,t[37]=Fe);let Ie=d.name,Le=pX,Re;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(Re={[JP]:`true`},t[38]=Re):Re=t[38];let ze=d.name===`Embed`&&typeof U.src==`string`&&/^https?:\/\//i.test(U.src)&&(0,X.jsx)(`a`,{href:U.src,target:`_blank`,rel:`noopener noreferrer`,className:`jsx-chrome-btn`,"aria-label":u({id:`iOHg1t`}),onMouseDown:fX,children:(0,X.jsx)(Fi,{size:12,"aria-hidden":`true`})}),Be=d.name===`Mirror`&&typeof U.src==`string`&&U.src.length>0&&(()=>{let e=U.src;return(0,X.jsx)(`a`,{href:xn(e,typeof U.anchor==`string`&&U.anchor.length>0?U.anchor:null),className:`jsx-chrome-btn`,"aria-label":u({id:`3a_Bd7`,values:{mirrorSrc:e}}),title:u({id:`0kTAXe`,values:{mirrorSrc:e}}),onMouseDown:dX,children:(0,X.jsx)(Fi,{size:12,"aria-hidden":`true`})})})(),Ve;t[39]!==u||t[40]!==w||t[41]!==d.name||t[42]!==r||t[43]!==n.attrs.componentName||t[44]!==n.nodeSize||t[45]!==b?(Ve=w&&(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":u({id:`QyioBP`}),onClick:()=>{try{if(typeof b!=`number`)return;let e=r.state.doc.resolve(b),t=e.index(e.depth);if(t===0)return;let i=b-e.node(e.depth).child(t-1).nodeSize,a=b+n.nodeSize,o=r.state.tr,s=r.state.doc.slice(b,b+n.nodeSize),c=r.state.doc.slice(i,b);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;v(`up`),console.warn(JSON.stringify({event:`jsx-component-move-failed`,direction:`up`,component:d.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},children:(0,X.jsx)(yi,{size:12,"aria-hidden":`true`})}),t[39]=u,t[40]=w,t[41]=d.name,t[42]=r,t[43]=n.attrs.componentName,t[44]=n.nodeSize,t[45]=b,t[46]=Ve):Ve=t[46];let He;t[47]!==u||t[48]!==T||t[49]!==d.name||t[50]!==r||t[51]!==n.attrs.componentName||t[52]!==n.nodeSize||t[53]!==b?(He=T&&(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":u({id:`3Ib6FN`}),onClick:()=>{try{if(typeof b!=`number`)return;let e=r.state.doc.resolve(b),t=e.index(e.depth),i=e.node(e.depth);if(t>=i.childCount-1)return;let a=i.child(t+1),o=b,s=b+n.nodeSize+a.nodeSize,c=r.state.tr,l=r.state.doc.slice(b,b+n.nodeSize),u=r.state.doc.slice(b+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;v(`down`),console.warn(JSON.stringify({event:`jsx-component-move-failed`,direction:`down`,component:d.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},children:(0,X.jsx)(vi,{size:12,"aria-hidden":`true`})}),t[47]=u,t[48]=T,t[49]=d.name,t[50]=r,t[51]=n.attrs.componentName,t[52]=n.nodeSize,t[53]=b,t[54]=He):He=t[54];let Ue;t[55]!==u||t[56]!==d.displayName||t[57]!==d.name||t[58]!==V||t[59]!==b||t[60]!==H?(Ue=V&&typeof b==`number`?(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":u({id:`ky9Tuc`,values:{0:d.displayName??d.name}}),"data-testid":`jsx-component-edit-btn`,onClick:()=>H(!0),children:(0,X.jsx)(pa,{size:12,"aria-hidden":`true`})}):null,t[55]=u,t[56]=d.displayName,t[57]=d.name,t[58]=V,t[59]=b,t[60]=H,t[61]=Ue):Ue=t[61];let We;t[62]!==u||t[63]!==fe?(We=u({id:`MCjC9A`,values:{deleteDescriptorLabel:fe}}),t[62]=u,t[63]=fe,t[64]=We):We=t[64];let Ge;t[65]!==d.name||t[66]!==r||t[67]!==n.attrs.componentName||t[68]!==b?(Ge=()=>{if(typeof b==`number`)try{r.chain().focus().setNodeSelection(b).deleteSelection().run()||(ae(d.name),console.warn(JSON.stringify({event:`jsx-component-chrome-delete-failed`,component:d.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;ae(d.name),console.warn(JSON.stringify({event:`jsx-component-chrome-delete-failed`,component:d.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},t[65]=d.name,t[66]=r,t[67]=n.attrs.componentName,t[68]=b,t[69]=Ge):Ge=t[69];let qe;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,X.jsx)(Ta,{size:12,"aria-hidden":`true`}),t[70]=qe):qe=t[70];let Je;t[71]!==We||t[72]!==Ge?(Je=(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn jsx-chrome-btn--delete`,"aria-label":We,onClick:Ge,children:qe}),t[71]=We,t[72]=Ge,t[73]=Je):Je=t[73];let Ye;t[74]!==u||t[75]!==F||t[76]!==pe?(Ye=F&&(0,X.jsx)(ic,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"data-jsx-gear":``,"aria-label":u({id:`XPJ0sN`,values:{settingsDescriptorLabel:pe}}),children:(0,X.jsx)(_a,{size:12,"aria-hidden":`true`})})}),t[74]=u,t[75]=F,t[76]=pe,t[77]=Ye):Ye=t[77];let Xe;t[78]!==Le||t[79]!==Re||t[80]!==ze||t[81]!==Be||t[82]!==Ve||t[83]!==He||t[84]!==Ue||t[85]!==Je||t[86]!==Ye?(Xe=(0,X.jsxs)(`div`,{className:`jsx-component-chrome`,contentEditable:!1,onMouseDown:Le,...Re,children:[ze,Be,Ve,He,Ue,Je,Ye]}),t[78]=Le,t[79]=Re,t[80]=ze,t[81]=Be,t[82]=Ve,t[83]=He,t[84]=Ue,t[85]=Je,t[86]=Ye,t[87]=Xe):Xe=t[87];let Ze;t[88]!==de||t[89]!==d.emptyChildName||t[90]!==d.hasChildren||t[91]!==d.isSelfClosing||t[92]!==d.name||t[93]!==r||t[94]!==s||t[95]!==K||t[96]!==j||t[97]!==n.attrs.componentName||t[98]!==n.childCount||t[99]!==_e||t[100]!==G||t[101]!==ie||t[102]!==z||t[103]!==p||t[104]!==R?(Ze=R&&z?(0,X.jsx)(oc,{asChild:!0,children:(0,X.jsx)(dJ,{label:z.label,Icon:z.Icon,onClick:_e,selected:j})}):(0,X.jsx)(iX,{resetKey:ie,onError:p,descriptorName:d.name===`*`?`wildcard`:d.name,rawComponentName:n.attrs.componentName??``,children:(0,X.jsx)(WO,{value:typeof s==`function`?{editor:r,getPos:()=>{let e=s();return typeof e==`number`?e:void 0},addChild:d.emptyChildName?()=>{let e=d.emptyChildName,t=Zj(e),n=K();r.chain().focus().insertContentAt(n,t).run(),tM(r,n,Gj(e))}:null}:null,children:(0,X.jsx)(de,{...G,children:(0,X.jsx)(Al,{className:`component-children ${!d.hasChildren&&n.childCount===0?`min-h-0 m-0 p-0`:``}`,...!d.hasChildren||d.isSelfClosing?{contentEditable:!1}:{}})})})}),t[88]=de,t[89]=d.emptyChildName,t[90]=d.hasChildren,t[91]=d.isSelfClosing,t[92]=d.name,t[93]=r,t[94]=s,t[95]=K,t[96]=j,t[97]=n.attrs.componentName,t[98]=n.childCount,t[99]=_e,t[100]=G,t[101]=ie,t[102]=z,t[103]=p,t[104]=R,t[105]=Ze):Ze=t[105];let Qe;t[106]!==d.emptyChildName||t[107]!==d.name||t[108]!==r||t[109]!==K||t[110]!==n.childCount?(Qe=d.emptyChildName&&!(d.name===`Tabs`&&n.childCount>0)&&(()=>{let e=d.emptyChildName;return(0,X.jsx)(`button`,{type:`button`,contentEditable:!1,className:n.childCount===0?`jsx-empty-child-placeholder`:`jsx-add-child-pill`,onMouseDown:uX,onClick:()=>{let e=d.emptyChildName,t=Zj(e),n=K();r.chain().focus().insertContentAt(n,t).run(),tM(r,n,Gj(e))},"data-clipboard-omit":`true`,children:(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`7Fkcej`,values:{addChildName:e}})})})})(),t[106]=d.emptyChildName,t[107]=d.name,t[108]=r,t[109]=K,t[110]=n.childCount,t[111]=Qe):Qe=t[111];let $e;t[112]!==Te||t[113]!==d.name||t[114]!==be||t[115]!==he||t[116]!==xe||t[117]!==N||t[118]!==Ee||t[119]!==De||t[120]!==Oe||t[121]!==ke||t[122]!==Ae||t[123]!==je||t[124]!==Me||t[125]!==Ne||t[126]!==Pe||t[127]!==Fe||t[128]!==Xe||t[129]!==Ze||t[130]!==Qe?($e=(0,X.jsxs)(Te,{className:`jsx-component-wrapper my-2`,"data-jsx-component":``,"data-component-type":Ee,"data-align":De,"data-selected":Oe,"data-has-child-selected":ke,"data-range-selected":Ae,"data-selection-origin":N,"data-dragging":je,"data-needs-config":Me,role:Ne,"aria-label":be,tabIndex:Pe,...Fe,"data-component-name":Ie,onClick:he,onKeyDown:xe,children:[Xe,Ze,Qe]}),t[112]=Te,t[113]=d.name,t[114]=be,t[115]=he,t[116]=xe,t[117]=N,t[118]=Ee,t[119]=De,t[120]=Oe,t[121]=ke,t[122]=Ae,t[123]=je,t[124]=Me,t[125]=Ne,t[126]=Pe,t[127]=Fe,t[128]=Xe,t[129]=Ze,t[130]=Qe,t[131]=$e):$e=t[131];let et;t[132]!==u||t[133]!==I||t[134]!==d.Component||t[135]!==d.displayName||t[136]!==d.name||t[137]!==te||t[138]!==V||t[139]!==r||t[140]!==s||t[141]!==b||t[142]!==G||t[143]!==H?(et=V&&typeof b==`number`?(0,X.jsx)(mG,{open:te,onOpenChange:H,initialValue:typeof I[V.propName]==`string`?I[V.propName]:``,language:V.language,title:u({id:`ky9Tuc`,values:{0:d.displayName??d.name}}),renderPreview:e=>{let t=d.Component;return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center p-4`,children:(0,X.jsx)(t,{...G,[V.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)return;let i=sX(n.attrs);if(i)try{let n={...i.props,[V.propName]:e},a={...i,props:n,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]=u,t[133]=I,t[134]=d.Component,t[135]=d.displayName,t[136]=d.name,t[137]=te,t[138]=V,t[139]=r,t[140]=s,t[141]=b,t[142]=G,t[143]=H,t[144]=et):et=t[144];let tt;t[145]!==d||t[146]!==r||t[147]!==s||t[148]!==F||t[149]!==B||t[150]!==U||t[151]!==me||t[152]!==_||t[153]!==R?(tt=F&&(0,X.jsxs)(ac,{side:R?`bottom`:`right`,align:R?`center`:`start`,sideOffset:R?-4:8,className:`w-64 p-3 z-[60] overflow-y-auto subtle-scrollbar max-h-[var(--radix-popper-available-height)] overscroll-contain`,onCloseAutoFocus:B?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)(fY,{descriptor:d,values:U,onDismiss:()=>_(!1),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)return;let a=sX(i.attrs);if(!a)return;let o={...a.props},c=Array.isArray(i.attrs.attributes)?i.attrs.attributes:[],l=c;t===void 0?(delete o[e],l=c.filter(t=>!(typeof t==`object`&&t&&t.type===`mdxJsxAttribute`&&t.name===e))):o[e]=t,r.view.dispatch(r.state.tr.setNodeMarkup(n,null,{...a,attributes:l,props:o,sourceDirty:!0}))}}),(0,X.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-border pt-2`,children:(0,X.jsx)(qt,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>_(!1),className:`h-7 px-3 text-xs`,children:(0,X.jsx)(o,{id:`DPfwMq`})})})]}),t[145]=d,t[146]=r,t[147]=s,t[148]=F,t[149]=B,t[150]=U,t[151]=me,t[152]=_,t[153]=R,t[154]=tt):tt=t[154];let nt;return t[155]!==we||t[156]!==Se||t[157]!==g||t[158]!==$e||t[159]!==et||t[160]!==tt?(nt=(0,X.jsxs)(we,{open:g,onOpenChange:Se,children:[$e,et,tt]}),t[155]=we,t[156]=Se,t[157]=g,t[158]=$e,t[159]=et,t[160]=tt,t[161]=nt):nt=t[161],nt}function uX(e){return e.stopPropagation()}function dX(e){return e.stopPropagation()}function fX(e){return e.stopPropagation()}function pX(e){return e.stopPropagation()}function mX(e){return e.preventDefault()}function hX(e){return!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`}var gX=P.extend({addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return zl(lX)}}),_X={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`}]},vX=(0,Q.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-DBuiuHex.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,Z.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 yX(){let e=(0,Z.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 bX(e){let t=(0,Z.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 xX(e){let t=(0,Z.c)(38),{node:n,selected:r,getPos:i,editor:a}=e,s=typeof n.attrs.formula==`string`?n.attrs.formula:``,c=typeof n.attrs.id==`string`?n.attrs.id:void 0,[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(!1),f;t[0]!==a.state||t[1]!==i||t[2]!==r?(f=()=>{let e=r&&a.state.selection instanceof I;e&&!d.current?(eM(typeof i==`function`?i()??0:0),u(!0)):!e&&d.current&&u(!1),d.current=e},t[0]=a.state,t[1]=i,t[2]=r,t[3]=f):f=t[3];let p;t[4]!==a||t[5]!==i||t[6]!==r?(p=[r,i,a],t[4]=a,t[5]=i,t[6]=r,t[7]=p):p=t[7],(0,Q.useEffect)(f,p);let m=r?`math-inline-selected`:void 0,h;t[8]===c?h=t[9]:(h=c?{id:c}:{},t[8]=c,t[9]=h);let g;t[10]===s?g=t[11]:(g=s?(0,X.jsx)(lJ,{resetKeys:[s],onError:CX,fallbackRender:()=>(0,X.jsx)(`span`,{className:`math math-inline math-error`,children:s}),children:(0,X.jsx)(Q.Suspense,{fallback:(0,X.jsx)(bX,{formula:s}),children:(0,X.jsx)(vX,{formula:s})})}):(0,X.jsx)(yX,{}),t[10]=s,t[11]=g);let _;t[12]!==s||t[13]!==h||t[14]!==g?(_=(0,X.jsx)(ic,{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(I.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)(fY,{descriptor:_X,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)(ac,{className:`z-[60] w-72 p-0`,side:`bottom`,align:`start`,onOpenAutoFocus:SX,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)(rc,{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)(jl,{as:`span`,className:m,children:w}),t[35]=w,t[36]=m,t[37]=T):T=t[37],T}function SX(e){e.preventDefault()}function CX(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})),Ye(`mathInline`)}var wX=xe.extend({addNodeView(){return zl(xX)}});function TX(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=be.near(e.doc.resolve(i),n);return a.$head?.parent.type.name===`rawMdxFallback`?a:null}function EX(e,t){let{state:n,view:r}=e;if(!r.endOfTextblock(t))return!1;let i=TX(n,t);return i?(r.dispatch(n.tr.setSelection(i)),!0):!1}var DX=tt.extend({addKeyboardShortcuts(){return{ArrowLeft:({editor:e})=>EX(e,`left`),ArrowRight:({editor:e})=>EX(e,`right`),ArrowUp:({editor:e})=>EX(e,`up`),ArrowDown:({editor:e})=>EX(e,`down`)}},addNodeView(){return zl(sG,{stopEvent:()=>!0,ignoreMutation:()=>!0})}});function OX(e){let t=(0,Z.c)(51),{items:n,selectedIndex:r,categoryLabels:a,onSelect:s,onHoverIndex:c}=e,l=(0,Q.useRef)(null),u=(0,Q.useId)(),{_:d}=i(),f=r>=0&&r<n.length?`${u}-option-${r}`:void 0,p=AX,m,h;if(t[0]===r?(m=t[1],h=t[2]):(m=()=>{let e=l.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(r);t&&t.scrollIntoView({block:`nearest`})},h=[r],t[0]=r,t[1]=m,t[2]=h),(0,Q.useEffect)(m,h),n.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[3]=e):e=t[3];let n;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,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(kX),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 kX(e){return e.preview}function AX(e){return e.preventDefault()}var jX=new N(`slashCommand`),MX=kt.create({name:`slashCommand`,addOptions(){return{itemsSources:[mM],categoryLabels:{basic:`Basic blocks`,insert:`Insert`}}},addProseMirrorPlugins(){let e=this;return[Ay({editor:this.editor,pluginKey:jX,char:`/`,startOfLine:!1,allow:({editor:e})=>!Ly(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 hM(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=Ry(()=>n,`slash-command`);i.popup=c.popup,a=c.doPosition,t=new Ll(OX,{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(){zy(i),a=null,t?.destroy(),t=null,n=null,r=0}}}})]}}),NX=new N(`sourceDirty`),PX=kt.create({name:`sourceDirtyObserver`,addProseMirrorPlugins(){return[new pt({key:NX,appendTransaction(e,t,n){if(!e.some(e=>!e.getMeta(Tv))||!e.some(e=>e.docChanged))return null;let r=new H;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=!FX(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 FX(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(!FX(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(!FX(e[r],t[r]))return!1;return!0}function IX(e,t){let n=e.doc.nodeAt(t);if(!n||n.type.name!==`table`)return null;let r=Lt.get(n);return{map:r,tableStart:t+1,table:n,left:0,top:0,right:r.width,bottom:r.height}}function LX(e,t){let n=IX(e,t);return n?Oe(e.tr,n,n.map.width):null}function RX(e,t){let n=IX(e,t);return n?Nt(e.tr,n,n.map.height):null}function zX(e,t){if(!e.dom.contains(t))return null;let n;try{n=e.posAtDOM(t,0)}catch{return null}return n<0?null:ie(e.state.doc.resolve(n))?.pos??null}var BX=`<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 VX(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(JP,`true`),n.innerHTML=BX,n.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation()}),n}var HX=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(JP,`true`);let n=VX(`column`,`Add column`),r=VX(`row`,`Add row`);n.addEventListener(`click`,()=>this.insert(e,LX)),r.addEventListener(`click`,()=>this.insert(e,RX)),t.append(n,r),this.mount.appendChild(t);let i=or(e,t,()=>{let{width:t,height:i}=e.getBoundingClientRect();fr(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(()=>{}),fr(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=zX(this.view,n);if(r===null)return;let i=t(this.view.state,r);i&&(this.view.dispatch(i),this.view.focus())}},UX=kt.create({name:`tableInsertControls`,addProseMirrorPlugins(){let e=this.editor;return[new pt({key:new N(`tableInsertControls`),view:t=>new HX(t,e)})]}}),WX=`ok:tag-click`;function GX(e){if(typeof document>`u`)return;let t={value:e};document.dispatchEvent(new CustomEvent(WX,{detail:t}))}function KX(e){return e instanceof Element?e.closest(`a[data-tag]`):null}var qX=kt.create({name:`tagClick`,addProseMirrorPlugins(){return[new pt({props:{handleDOMEvents:{click(e,t){let n=KX(t.target);if(!n)return!1;let r=n.getAttribute(`data-tag`);return r?(t.preventDefault(),t.stopPropagation(),GX(r),!0):!1}}}})]}});function JX(e,t,n){if(typeof t!=`number`||!n||!pe.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(Ce.create(o.doc,s+1)),i.dispatch(o),i.focus(),!0}function YX(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 XX(e){let t=(0,Z.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 ZX(e){let t=(0,Z.c)(20),{initialDraft:n,onCommit:r,onCancel:a}=e,{_:o}=i(),s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(n),u=(0,Q.useRef)(!1),d,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=requestAnimationFrame(()=>{s.current?.focus()});return()=>cancelAnimationFrame(e)},f=[],t[0]=d,t[1]=f):(d=t[0],f=t[1]),(0,Q.useEffect)(d,f);let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,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===``||pe.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}pe.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 QX(e){let t=(0,Z.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)(jl,{as:`span`,children:(0,X.jsx)(ZX,{initialDraft:``,onCommit:e=>JX(i,typeof r==`function`?r():void 0,e),onCancel:()=>YX(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)(jl,{as:`span`,children:(0,X.jsx)(XX,{value:a})}),t[3]=a,t[4]=o),o}var $X=Pt.extend({priority:200,addNodeView(){return zl(QX)},addKeyboardShortcuts(){return{Backspace:()=>{if(By.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(By.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[qy(this.editor)]}}),eZ=2048,tZ=24;function nZ(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim();if(t===``||t.length>eZ)return{kind:`unsupported`,value:``};if(aZ(t))return{kind:`emoji`,value:t};let n=oZ(t);return n===`url`?{kind:`url`,value:t}:n===`path`?{kind:`path`,value:et(`/api/asset?path=${encodeURIComponent(iZ(t))}`)}:{kind:`unsupported`,value:``}}function rZ(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim();if(t===``||t.length>eZ)return{kind:`unsupported`,value:``};let n=oZ(t);return n===`url`?{kind:`url`,value:t}:n===`path`?{kind:`path`,value:et(`/api/asset?path=${encodeURIComponent(iZ(t))}`)}:{kind:`unsupported`,value:``}}function iZ(e){return e.startsWith(`/`)?e.slice(1):e}function aZ(e){if(/\p{L}/u.test(e)||e.includes(`/`))return!1;let t=0;for(let n of e)t++;if(t>tZ)return!1;let n=e.lastIndexOf(`.`);if(n>-1){let t=e.slice(n+1).toLowerCase();if(se.has(t))return!1}return!0}function oZ(e){let t=sZ(e);if(!t||!se.has(t))return`unsupported`;let n=e.indexOf(`:`),r=e.indexOf(`/`);return n>-1&&(r===-1||n<r)?Rt(e)?`url`:`unsupported`:e.startsWith(`//`)||e.includes(`?`)||e.includes(`#`)||e.startsWith(`../`)||e.includes(`/../`)?`unsupported`:`path`}function sZ(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 cZ(e){let t=(0,Z.c)(133),{open:n,target:r,alias:a,anchor:s,pages:c,assetPaths:l,filePaths:u,loading:d,onOpenChange:f,onSave:p}=e,[m,h]=(0,Q.useState)(r),[g,_]=(0,Q.useState)(a??``),[v,y]=(0,Q.useState)(s??``),b=(0,Q.useId)(),x=(0,Q.useId)(),S=(0,Q.useId)(),C=(0,Q.useId)(),{_:w}=i(),T;t[0]!==l||t[1]!==m||t[2]!==u?(T=KD(m,l,u),t[0]=l,t[1]=m,t[2]=u,t[3]=T):T=t[3];let E=T,D;t[4]!==l||t[5]!==m||t[6]!==u||t[7]!==c?(D=qD(m,c,l,u),t[4]=l,t[5]=m,t[6]=u,t[7]=c,t[8]=D):D=t[8];let O=Zq(m,D&&!E&&n),k=(0,Q.useRef)(!1),A,j;t[9]!==a||t[10]!==s||t[11]!==n||t[12]!==r?(A=()=>{if(!n){k.current=!1;return}k.current||(k.current=!0,h(r),_(a??``),y(s??``))},j=[n,r,a,s],t[9]=a,t[10]=s,t[11]=n,t[12]=r,t[13]=A,t[14]=j):(A=t[13],j=t[14]),(0,Q.useEffect)(A,j);let M;t[15]!==g||t[16]!==v||t[17]!==m||t[18]!==f||t[19]!==p?(M=function(){let e=m.trim();e&&(p(e,g.trim()||null,v.trim()||null),f(!1))},t[15]=g,t[16]=v,t[17]=m,t[18]=f,t[19]=p,t[20]=M):M=t[20];let N=M,P;t[21]===N?P=t[22]:(P=function(e){e.key===`Enter`&&(e.preventDefault(),N())},t[21]=N,t[22]=P);let F=P,I;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(I=function(e){h(e.path),y(``)},t[23]=I):I=t[23];let L=I,R,z,B,ee,V,te,H,U,ne,W,re,G,ie,ae,oe,K,se;if(t[24]!==w||t[25]!==S||t[26]!==x||t[27]!==l||t[28]!==g||t[29]!==v||t[30]!==m||t[31]!==F||t[32]!==C||t[33]!==O||t[34]!==d||t[35]!==f||t[36]!==n||t[37]!==c||t[38]!==b){let e=new Map,r=O?.map(t=>{let n=e.get(t.slug)??0;e.set(t.slug,n+1);let r=n===0?t.slug:`${t.slug}-${n}`;return{...t,reactKey:r}}),i=!!r?.length;B=un,ae=n,oe=f,z=tn,U=`sm:max-w-xl`,ne=``,W=Fq,re=Fq,G=Fq;let a;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Xt,{children:(0,X.jsx)(o,{id:`xzktOa`})}),t[56]=a):a=t[56],t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,X.jsxs)(ln,{children:[a,(0,X.jsx)(Yt,{children:(0,X.jsx)(o,{id:`Jhj_lh`})})]}),t[57]=ie):ie=t[57],R=an,V=`space-y-6`;let s;t[58]===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[58]=s):s=t[58];let u;t[59]===b?u=t[60]:(u=(0,X.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:b,children:s}),t[59]=b,t[60]=u);let p;t[61]===w?p=t[62]:(p=w({id:`aM23Wr`}),t[61]=w,t[62]=p);let T;t[63]!==l||t[64]!==m||t[65]!==F||t[66]!==d||t[67]!==c||t[68]!==p||t[69]!==b?(T=(0,X.jsx)(Rq,{id:b,value:m,pages:c,assetPaths:l,includeAssets:!0,loading:d,onValueChange:h,onSuggestionSelect:L,placeholder:p,autoFocus:!0,"aria-required":`true`,onKeyDown:F}),t[63]=l,t[64]=m,t[65]=F,t[66]=d,t[67]=c,t[68]=p,t[69]=b,t[70]=T):T=t[70],t[71]!==u||t[72]!==T?(te=(0,X.jsxs)(`div`,{children:[u,T]}),t[71]=u,t[72]=T,t[73]=te):te=t[73];let E;t[74]===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[74]=E):E=t[74];let D;t[75]===S?D=t[76]:(D=(0,X.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:S,children:E}),t[75]=S,t[76]=D);let k;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>_(e.target.value),t[77]=k):k=t[77];let A;t[78]===w?A=t[79]:(A=w({id:`BH56dn`}),t[78]=w,t[79]=A);let j;t[80]!==S||t[81]!==g||t[82]!==F||t[83]!==A?(j=(0,X.jsx)(mn,{id:S,value:g,onChange:k,placeholder:A,onKeyDown:F}),t[80]=S,t[81]=g,t[82]=F,t[83]=A,t[84]=j):j=t[84],t[85]!==D||t[86]!==j?(H=(0,X.jsxs)(`div`,{children:[D,j]}),t[85]=D,t[86]=j,t[87]=H):H=t[87];let M;t[88]===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[88]=M):M=t[88],t[89]===x?K=t[90]:(K=(0,X.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:x,children:M}),t[89]=x,t[90]=K);let N;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>y(e.target.value),t[91]=N):N=t[91];let P;t[92]===w?P=t[93]:(P=w({id:`W-ntoW`}),t[92]=w,t[93]=P),t[94]!==x||t[95]!==v||t[96]!==F||t[97]!==P?(se=(0,X.jsx)(mn,{id:x,value:v,onChange:N,placeholder:P,onKeyDown:F}),t[94]=x,t[95]=v,t[96]=F,t[97]=P,t[98]=se):se=t[98],ee=i&&(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:r.map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":v===e.slug,className:Ut(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,v===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>y(v===e.slug?``:e.slug),children:[(0,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[24]=w,t[25]=S,t[26]=x,t[27]=l,t[28]=g,t[29]=v,t[30]=m,t[31]=F,t[32]=C,t[33]=O,t[34]=d,t[35]=f,t[36]=n,t[37]=c,t[38]=b,t[39]=R,t[40]=z,t[41]=B,t[42]=ee,t[43]=V,t[44]=te,t[45]=H,t[46]=U,t[47]=ne,t[48]=W,t[49]=re,t[50]=G,t[51]=ie,t[52]=ae,t[53]=oe,t[54]=K,t[55]=se}else R=t[39],z=t[40],B=t[41],ee=t[42],V=t[43],te=t[44],H=t[45],U=t[46],ne=t[47],W=t[48],re=t[49],G=t[50],ie=t[51],ae=t[52],oe=t[53],K=t[54],se=t[55];let ce;t[99]!==ee||t[100]!==K||t[101]!==se?(ce=(0,X.jsxs)(`div`,{children:[K,se,ee]}),t[99]=ee,t[100]=K,t[101]=se,t[102]=ce):ce=t[102];let q;t[103]!==V||t[104]!==te||t[105]!==H||t[106]!==ce?(q=(0,X.jsxs)(`div`,{className:V,children:[te,H,ce]}),t[103]=V,t[104]=te,t[105]=H,t[106]=ce,t[107]=q):q=t[107];let le;t[108]!==R||t[109]!==q?(le=(0,X.jsx)(R,{children:q}),t[108]=R,t[109]=q,t[110]=le):le=t[110];let ue;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,X.jsx)(cn,{asChild:!0,children:(0,X.jsx)(qt,{variant:`outline`,children:(0,X.jsx)(o,{id:`dEgA5A`})})}),t[111]=ue):ue=t[111];let de;t[112]===m?de=t[113]:(de=m.trim(),t[112]=m,t[113]=de);let fe=!de,pe;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,X.jsx)(o,{id:`tfDRzk`}),t[114]=pe):pe=t[114];let me;t[115]!==N||t[116]!==fe?(me=(0,X.jsxs)(on,{children:[ue,(0,X.jsx)(qt,{onClick:N,disabled:fe,children:pe})]}),t[115]=N,t[116]=fe,t[117]=me):me=t[117];let he;t[118]!==z||t[119]!==U||t[120]!==ne||t[121]!==W||t[122]!==re||t[123]!==G||t[124]!==ie||t[125]!==le||t[126]!==me?(he=(0,X.jsxs)(z,{className:U,"data-ok-layer-spawned":ne,onPointerDownOutside:W,onFocusOutside:re,onInteractOutside:G,children:[ie,le,me]}),t[118]=z,t[119]=U,t[120]=ne,t[121]=W,t[122]=re,t[123]=G,t[124]=ie,t[125]=le,t[126]=me,t[127]=he):he=t[127];let ge;return t[128]!==B||t[129]!==ae||t[130]!==oe||t[131]!==he?(ge=(0,X.jsx)(B,{open:ae,onOpenChange:oe,children:he}),t[128]=B,t[129]=ae,t[130]=oe,t[131]=he,t[132]=ge):ge=t[132],ge}function lZ(e){let t=(0,Z.c)(116),{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=ye(l?.attrs.alias),f=ye(l?.attrs.anchor),p=Te({target:u,alias:d,anchor:f}),{addPage:m,assetPaths:h,filePaths:g,folderPaths:_,pages:v,pagesBySlug:y,pagesByBasename:b,loading:x}=jn(),S=le(u,f),C=S?.kind===`external`?S:null,w=S?.kind===`asset`?KD(S.url,h,g)??S.url.replace(/^\//,``):null,T=w?null:AU(u,{pages:v,folderPaths:_,pagesBySlug:y,pagesByBasename:b,fallbackTargets:HD(u)}),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.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 P=N,F=function(e){if(e!==u){let t=r();if(t==null)return;n.view.dispatch(n.state.tr.setNodeMarkup(t,void 0,{...n.state.doc.nodeAt(t)?.attrs,target:e,alias:d??p}))}},I=function(){return T?.kind===`create`?{initialDir:T.initialDir,suggestedName:T.suggestedName}:null},L=async function(){let e=I();if(!(!e||O)){k(!0);try{await Cq(e,{addPage:m,onCreated(e){F(e),window.location.hash=`#/${e}`,a()}}),k(!1)}catch(e){let t=e;zn.error(t instanceof Error?t.message:A({id:`tfi40B`})),k(!1)}}},R=!C&&!x&&w!==null,z=!C&&!x&&T?.kind===`navigate`&&T.displayState===`resolved`,B=!C&&!x&&T?.kind===`navigate`&&T.displayState===`folder`,ee=!C&&!x&&!w&&T?.kind===`create`,V=!!C,te=C?BU(C.url)?C.url:null:R&&w?Tn(w):z&&T?.kind===`navigate`?UU({docName:T.hashDocName,anchor:f}):null,H=!x&&te!==null&&(V||R||z),U,ne,W,re,G;if(t[9]!==A||t[10]!==d||t[11]!==f||t[12]!==w||t[13]!==n.state||t[14]!==n.view||t[15]!==C||t[16]!==r||t[17]!==R||t[18]!==B||t[19]!==z||t[20]!==ee||t[21]!==x||t[22]!==u){if(x){let e;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(oa,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),t[28]=e):e=t[28],W={icon:e,text:A({id:`yQE2r9`}),className:`text-muted-foreground/80`}}else if(C){let e;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(En,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[29]=e):e=t[29],W={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)(Ri,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[30]=e):e=t[30],W={icon:e,text:A({id:`bUUVED`}),className:`text-muted-foreground`}}else if(B){let e;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Wi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[31]=e):e=t[31],W={icon:e,text:A({id:`kNqMMd`}),className:`text-muted-foreground`}}else if(ee){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ei,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[32]=e):e=t[32],W={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)(Vi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[33]=e):e=t[33],W={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)(Ei,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[34]=e):e=t[34],W={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 zt(n.view,e,e+t.nodeSize)}catch{return new DOMRect}},t[35]=n.state,t[36]=n.view,t[37]=r,t[38]=e):e=t[38];let i;t[39]!==n.view.dom||t[40]!==e?(i={getBoundingClientRect:e,contextElement:n.view.dom},t[39]=n.view.dom,t[40]=e,t[41]=i):i=t[41],G=i,ne=w??(C?C.url:`${u}${f?`#${f}`:``}`);let a=f?`${u}#${f}`:u;U=d?`[[${a}|${d}]]`:`[[${a}]]`,re=Ut(`flex shrink-0`,W.className),t[9]=A,t[10]=d,t[11]=f,t[12]=w,t[13]=n.state,t[14]=n.view,t[15]=C,t[16]=r,t[17]=R,t[18]=B,t[19]=z,t[20]=ee,t[21]=x,t[22]=u,t[23]=U,t[24]=ne,t[25]=W,t[26]=re,t[27]=G}else U=t[23],ne=t[24],W=t[25],re=t[26],G=t[27];let ie;t[42]!==W.icon||t[43]!==re?(ie=(0,X.jsx)(`span`,{className:re,children:W.icon}),t[42]=W.icon,t[43]=re,t[44]=ie):ie=t[44];let ae=ie,oe;t[45]!==ae||t[46]!==ee||t[47]!==W.text?(oe=ee?(0,X.jsxs)(mr,{children:[(0,X.jsx)(sr,{asChild:!0,children:(0,X.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`wiki-link-prop-panel-icon-trigger`,children:ae})}),(0,X.jsx)(ur,{children:W.text})]}):ae,t[45]=ae,t[46]=ee,t[47]=W.text,t[48]=oe):oe=t[48];let K=oe,se=`${W.text}: ${ne}`,ce;t[49]!==ne||t[50]!==V||t[51]!==ee||t[52]!==te||t[53]!==H||t[54]!==a||t[55]!==s?(ce=(0,X.jsx)(sr,{asChild:!0,children:H?(0,X.jsx)(`a`,{href:te??void 0,...V?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>XU(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:ne}):(0,X.jsx)(`span`,{"data-slot":`wiki-link-prop-panel-text`,className:Ut(`block truncate text-sm font-medium`,ee?`text-muted-foreground`:`text-foreground`),children:ne})}),t[49]=ne,t[50]=V,t[51]=ee,t[52]=te,t[53]=H,t[54]=a,t[55]=s,t[56]=ce):ce=t[56];let q;t[57]===ne?q=t[58]:(q=(0,X.jsx)(ur,{className:`max-w-80 break-all`,children:ne}),t[57]=ne,t[58]=q);let ue;t[59]!==ce||t[60]!==q?(ue=(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(mr,{children:[ce,q]})}),t[59]=ce,t[60]=q,t[61]=ue):ue=t[61];let de;t[62]!==L||t[63]!==O||t[64]!==ee?(de=ee?(0,X.jsxs)(qt,{type:`button`,size:`sm`,variant:`link`,disabled:O,onClick:()=>void L(),"data-slot":`wiki-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,X.jsx)(ma,{className:`size-3.5`,"aria-hidden":`true`}),O?(0,X.jsx)(o,{id:`HM56Bx`}):(0,X.jsx)(o,{id:`XRuL0i`})]}):null,t[62]=L,t[63]=O,t[64]=ee,t[65]=de):de=t[65];let fe;t[66]===A?fe=t[67]:(fe=A({id:`ePK91l`}),t[66]=A,t[67]=fe);let pe;t[68]===D?pe=t[69]:(pe=()=>D(!0),t[68]=D,t[69]=pe);let me;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,X.jsx)(pa,{className:`size-3.5`,"aria-hidden":`true`}),t[70]=me):me=t[70];let he;t[71]!==fe||t[72]!==pe?(he=(0,X.jsx)(sr,{asChild:!0,children:(0,X.jsx)(qt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":fe,onClick:pe,"data-slot":`wiki-link-prop-panel-edit`,children:me})}),t[71]=fe,t[72]=pe,t[73]=he):he=t[73];let ge;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,X.jsx)(ur,{children:(0,X.jsx)(o,{id:`ePK91l`})}),t[74]=ge):ge=t[74];let _e;t[75]===he?_e=t[76]:(_e=(0,X.jsxs)(mr,{children:[he,ge]}),t[75]=he,t[76]=_e);let ve;t[77]===U?ve=t[78]:(ve=(0,X.jsx)(Gq,{copyContent:U}),t[77]=U,t[78]=ve);let be;t[79]===A?be=t[80]:(be=A({id:`t_YqKh`}),t[79]=A,t[80]=be);let xe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,X.jsx)(Ta,{className:`size-3.5`,"aria-hidden":`true`}),t[81]=xe):xe=t[81];let Se;t[82]!==P||t[83]!==be?(Se=(0,X.jsx)(sr,{asChild:!0,children:(0,X.jsx)(qt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":be,onClick:P,"data-slot":`wiki-link-prop-panel-remove`,children:xe})}),t[82]=P,t[83]=be,t[84]=Se):Se=t[84];let Ce;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,X.jsx)(ur,{children:(0,X.jsx)(o,{id:`t_YqKh`})}),t[85]=Ce):Ce=t[85];let we;t[86]===Se?we=t[87]:(we=(0,X.jsxs)(mr,{children:[Se,Ce]}),t[86]=Se,t[87]=we);let Ee;t[88]!==de||t[89]!==_e||t[90]!==ve||t[91]!==we?(Ee=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[de,_e,ve,we]}),t[88]=de,t[89]=_e,t[90]=ve,t[91]=we,t[92]=Ee):Ee=t[92];let De;t[93]!==K||t[94]!==ue||t[95]!==Ee?(De=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[K,ue,Ee]}),t[93]=K,t[94]=ue,t[95]=Ee,t[96]=De):De=t[96];let Oe;t[97]!==a||t[98]!==De||t[99]!==se||t[100]!==G?(Oe=(0,X.jsx)(pq,{kind:`wiki-link`,ariaLabel:se,onDeactivate:a,triggerReference:G,className:`w-96`,children:De}),t[97]=a,t[98]=De,t[99]=se,t[100]=G,t[101]=Oe):Oe=t[101];let ke;t[102]!==d||t[103]!==f||t[104]!==h||t[105]!==E||t[106]!==g||t[107]!==M||t[108]!==x||t[109]!==v||t[110]!==D||t[111]!==u?(ke=(0,X.jsx)(cZ,{open:E,target:u,alias:d,anchor:f,pages:v,assetPaths:h,filePaths:g,loading:x,onOpenChange:D,onSave:M}),t[102]=d,t[103]=f,t[104]=h,t[105]=E,t[106]=g,t[107]=M,t[108]=x,t[109]=v,t[110]=D,t[111]=u,t[112]=ke):ke=t[112];let Ae;return t[113]!==Oe||t[114]!==ke?(Ae=(0,X.jsxs)(X.Fragment,{children:[Oe,ke]}),t[113]=Oe,t[114]=ke,t[115]=Ae):Ae=t[115],Ae}var uZ=0;function dZ(){return`wiki-link-${++uZ}`}function fZ(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 pZ(e,t){if(!t||!e)return null;let n=UD(e,t);if(!n)return null;let r=t.pageIcons?.get(n);if(!r)return null;let i=nZ(r);return i.kind===`unsupported`?null:i}function mZ(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 hZ=_.extend({priority:200,addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=dZ(),{dom:i,iconSpan:a}=fZ({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=()=>{mZ(a,pZ(String(o.attrs.target??``),Ln()))};s();let c=On(s),l=()=>{let e=n();return typeof e==`number`?e:void 0},u=kO(e),d=({newTab:e})=>{let t=o.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=le(n,typeof t.anchor==`string`?t.anchor:null);if(!r)return!1;if(r.kind===`doc`){let t=Ln(),i=AU(n,{pages:t?.pages??new Set,folderPaths:t?.folderPaths??new Set,pagesBySlug:t?.pagesBySlug,pagesByBasename:t?.pagesByBasename,fallbackTargets:HD(n)});if(i.kind===`create`||i.kind===`navigate`&&i.displayState===`folder`)return!1;let a=i.kind===`navigate`?i.hashDocName:r.docName;return e?KU({docName:a,anchor:r.anchor}):window.location.assign(UU({docName:a,anchor:r.anchor})),!0}if(r.kind===`asset`){let t=Ln(),n=KD(r.url,t?.assetPaths??new Set,t?.filePaths)??r.url.replace(/^\//,``);return e?WU(Tn(n)):window.location.hash=Tn(n),!0}return BU(r.url)?(WU(r.url),!0):!1};return u.register({type:`wikiLink`,nodeId:r,getPos:l,controls:{propPanel:t=>(0,Q.createElement)(lZ,{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(gW.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(gW.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[jW(this.editor)]}}),gZ=0;function _Z(){return`wiki-link-embed-${++gZ}`}function vZ(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 yZ(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`,et(e.src)),t.setAttribute(`alt`,e.alias??e.target),{dom:t}}function bZ(e){let t=$e(e);return t!==null&&se.has(t)}var xZ=B.extend({addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=_Z(),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(bZ(a)){let{dom:e}=yZ({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(!bZ(n))return!1;let o=a??n;return e.setAttribute(`data-target`,n),e.setAttribute(`data-alias`,r??``),e.setAttribute(`src`,et(o)),e.setAttribute(`alt`,r??n),!0}}}let{dom:l}=vZ({nodeId:r,target:a,alias:o,anchor:s,href:c??a});l.addEventListener(`click`,e=>{e.preventDefault()});let u=()=>{let e=n();return typeof e==`number`?e:void 0},d=kO(e);return d.register({type:`wikiLinkEmbed`,nodeId:r,getPos:u,controls:{},handlePrimary:({newTab:e})=>{let t=i.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=(typeof t.resolvedSrc==`string`&&t.resolvedSrc.length>0?t.resolvedSrc:null)??n,a=$e(n);if(a===null)return!1;let o=gt(r,``)??n;return JU({url:r,projectRelPath:o,ext:a,title:o.split(`/`).pop()??r,newTab:e}),!0}}),{dom:l,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLinkEmbed`)return!1;i=e;let t=String(e.attrs.target??``);if(bZ(t))return!1;let n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor),a=(e.attrs.resolvedSrc==null?null:String(e.attrs.resolvedSrc))??t;return l.setAttribute(`data-target`,t),l.setAttribute(`data-alias`,n??``),l.setAttribute(`data-anchor`,r??``),l.setAttribute(`href`,a),l.setAttribute(`aria-label`,`Embed: ${t}${r?`#${r}`:``}`),l.textContent=n??`${t}${r?`#${r}`:``}`,!0},destroy:()=>{d.deregister(r)}}}}}),SZ=[...yt.map(e=>{if(e.name===`jsxComponent`)return gX;if(e.name===`image`){let t=e.options??{};return lq.configure({...t,inline:!0})}return e.name===`rawMdxFallback`?DX:e.name===`wikiLink`?hZ:e.name===`wikiLinkEmbed`?xZ:e.name===`link`?oJ:e.name===`mathInline`?wX:e.name===`tag`?$X:e.name===`codeBlock`?lK:e}),MX.configure({itemsSources:[mM,aM,pM,cM],categoryLabels:{content:`Components`,layout:`Layout`,media:`Media`,data:`Data`,embed:`Embeds`}}),oq,dD.configure({onDrop(e,t,n){for(let r of t)aO(r,e,n)},onPaste(e,t,n){for(let n of t)aO(n,e,e.state.selection.from)}}),sq,jD,qX,aq,rq,yM,UX,PX,hD,wM,FY,kt.create({name:`chunkWrapperDecoration`,addProseMirrorPlugins(){return[AM()]}})];function CZ(e){return e===ut}function wZ(){return uc(`SYNC_TIMEOUT_MS`,3e4)}var TZ=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}},EZ=class extends Error{docName;constructor(e){super(`Provider disconnected before sync for "${e}"`),this.name=`PreSyncDisconnectError`,this.docName=e}},DZ=class extends Error{docName;constructor(e){super(`Document not found: "${e}"`),this.name=`DocumentNotFoundError`,this.docName=e}},OZ=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}},kZ=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}},AZ=new Map,jZ=!1;function MZ(){for(let e of AZ.values())if(!e.settled)return!0;return!1}function NZ(){typeof document>`u`||document.visibilityState===`visible`&&PZ(Date.now())}function PZ(e){let t=[];for(let[n,r]of AZ){if(r.settled)continue;let i=e-r.createdAt;if(i<wZ())continue;r.settled=!0;let a=new TZ(n,i);RZ(r),r.reject(a);let o=Gx(n);o!==void 0&&nS(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 MZ()||IZ(),t.length}function FZ(){jZ||typeof document>`u`||(document.addEventListener(`visibilitychange`,NZ),jZ=!0)}function IZ(){jZ&&(typeof document>`u`||(document.removeEventListener(`visibilitychange`,NZ),jZ=!1))}var LZ=new Map;function RZ(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 zZ(e,t){let n=AZ.get(e);if(n)return n.promise;let r=LZ.get(e);if(r!==void 0){LZ.delete(e);let n=r===`timeout`?new TZ(e,0):new EZ(e);console.warn(`[syncPromise] ${e} rejected on creation (test hook, armed ${r}): ${n.message}`),$(`ok/sync/create`,{docName:e,mountId:Gx(e),warm:!1,armed:r}),$(`ok/sync/reject`,{docName:e,mountId:Gx(e),reason:`armed-${r}`});let i=VZ(n);return AZ.set(e,HZ(i,t)),i}if(t.synced){console.log(`[syncPromise] ${e} resolved synchronously (warm provider)`);let n=Gx(e);$(`ok/sync/create`,{docName:e,mountId:n,warm:!0}),$(`ok/sync/resolve`,{docName:e,mountId:n,elapsedMs:0,warm:!0}),$.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 AZ.set(e,BZ(r,t)),r}let i=Date.now(),a=()=>{},o=()=>{},s=new Promise((e,t)=>{a=e,o=t}),c=()=>{let t=AZ.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=Gx(e);if($(`ok/sync/resolve`,{docName:e,mountId:r,elapsedMs:n,warm:!1}),$.histogram(`ok/sync/resolve-elapsed-ms`,r===void 0?{docName:e}:{docName:e,mountId:r},n),RZ(t),MZ()||IZ(),t.resolve(),r!==void 0){let i=Date.now();tS(r,`ok.sync-promise`,{"doc.name":e,elapsed_ms:n},t.createdAt,i),nS(r,i)}},l=t=>{let n=AZ.get(e);if(!n||n.settled)return;n.settled=!0;let r=new EZ(e);console.warn(`[syncPromise] ${e} rejected: ${r.message}`);let i=Gx(e);$(`ok/sync/reject`,{docName:e,mountId:i,reason:`pre-sync-disconnect`}),RZ(n),MZ()||IZ(),n.reject(r),i!==void 0&&nS(i)},u=setTimeout(()=>{let t=AZ.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt,r=new TZ(e,n);console.warn(`[syncPromise] ${e} rejected: ${r.message}`);let i=Gx(e);$(`ok/sync/reject`,{docName:e,mountId:i,reason:`timeout`,elapsedMs:n}),RZ(t),MZ()||IZ(),t.reject(r),i!==void 0&&nS(i)},wZ()),d={promise:s,resolve:a,reject:o,createdAt:i,timeoutHandle:u,provider:t,onSynced:c,onClose:l,settled:!1,resolved:!1,detached:!1};return AZ.set(e,d),t.on(`synced`,c),t.on(`close`,l),FZ(),$(`ok/sync/create`,{docName:e,mountId:Gx(e),warm:!1}),s}function BZ(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!0,detached:!0}}function VZ(e){let t=Promise.reject(e);t.catch(()=>{});let n=t;return n.status=`rejected`,n.reason=e,n}function HZ(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!1,detached:!0}}function UZ(e){return AZ.get(e)?.resolved===!0}function WZ(e){let t=AZ.get(e);t&&(t.settled=!0,RZ(t),AZ.delete(e),MZ()||IZ())}function GZ(e,t){let n=AZ.get(e);if(!n||n.settled)return!1;n.settled=!0,console.warn(`[syncPromise] ${e} rejected: ${t.message}`),RZ(n),MZ()||IZ(),n.reject(t);let r=Gx(e);return r!==void 0&&nS(r),!0}var KZ=Object.freeze({kind:`tab-replay`}),qZ=Object.freeze({kind:`idle`});function JZ(e,t){return()=>{}}var YZ=null;function XZ(){return YZ??=qe(SZ),YZ}var ZZ=4e3,QZ=1e4,$Z=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`}},eQ=class extends Error{constructor(e,t){super(`stored-state epoch peek timed out for ${e} after ${t}ms`),this.docName=e,this.timeoutMs=t,this.name=`StoredEpochPeekTimeoutError`}},tQ=`ok-last-observed-branch`,nQ=`ok-doc-lineage-epochs`,rQ=5e3,iQ=uc(`MAX_BUFFER_BYTES`,1*1024*1024),aQ=uc(`MAX_POOL`,10),oQ=class{_entries=new Map;get entries(){return this._entries}lruOrder=[];activeDocName=null;maxSize;wsUrl;recycleDebounceMs;clearDataTimeoutMs;onChange=null;tabIdentity=null;serverRestartRecoveryState=qZ;cachedServerInstanceId=null;pendingServerInstanceKnown=null;recoveryMismatchStaleClaim;bufferedUpdates=new Map;pendingClears=new Map;clearFailures=new Set;persistenceFactory;peekStoredEpoch;storage;constructor(e,t,n){this.maxSize=e,this.wsUrl=t,this.recycleDebounceMs=n?.recycleDebounceMs??ZZ,this.clearDataTimeoutMs=n?.clearDataTimeoutMs??QZ,this.persistenceFactory=n?.persistenceFactory??iD,this.peekStoredEpoch=n?.peekStoredLineageEpoch??aD,n?.storage===void 0?this.storage=globalThis.localStorage===void 0?null:globalThis.localStorage:this.storage=n.storage}setTabIdentity(e){this.tabIdentity=e}setExpectedServerInstanceId(e){if(this.cachedServerInstanceId=e,!(e===null||e.length===0)){if(this.pendingServerInstanceKnown!==null){let t=this.pendingServerInstanceKnown;this.pendingServerInstanceKnown=null,t.resolve(e)}this.attachDeferredPersistence(e)}}whenServerInstanceKnown(){if(this.cachedServerInstanceId!==null&&this.cachedServerInstanceId.length>0)return Promise.resolve(this.cachedServerInstanceId);if(this.pendingServerInstanceKnown!==null)return this.pendingServerInstanceKnown.promise;let e,t=new Promise(t=>{e=t});return this.pendingServerInstanceKnown={promise:t,resolve:e},t}buildPersistence(e,t,n){return this.persistenceFactory({branch:this.normalizedObservedBranch(),serverInstanceId:e,docName:t,doc:n})}async validateStoredStateThenAttach(e,t){if(e.persistenceAttachOwned)return;e.persistenceAttachOwned=!0;let n=e.docName,r=()=>this._entries.get(n)===e&&e.kind===`active`&&e.persistence===null&&!this.pendingClears.has(n);if(!r())return;let i;try{i=await new Promise((e,r)=>{let i=setTimeout(()=>{r(new eQ(n,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);this.peekStoredEpoch({branch:this.normalizedObservedBranch(),serverInstanceId:t,docName:n}).then(t=>{clearTimeout(i),e(t)},e=>{clearTimeout(i),r(e)})})}catch(e){this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`peek`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)});return}if(!r())return;if(i===null){this.attachValidatedPersistence(e,t);return}if(!e.hasSynced&&(await this.awaitFirstSyncOrDestroy(e),!r()||!e.hasSynced))return;let a=e.provider.document.getMap(`lifecycle`).get(dt),o=typeof a==`string`&&a.length>0?a:null;if(o===i){this.attachValidatedPersistence(e,t);return}this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(n),via:`stored-state-validation`,staleEpoch:i,liveEpoch:o??`<absent>`});let s=this.activeDocName===n;this.runCloseAndClearPersistence(n),this.open(n)!==null&&s&&this.setActive(n)}attachValidatedPersistence(e,t){let n=e.docName;try{let r=this.buildPersistence(t,n,e.provider.document);e.persistence=r,this.notify(),this.backfillCacheAfterFirstSync(e,r).catch(e=>{this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`backfill`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)})})}catch(e){this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`attach`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)})}}async backfillCacheAfterFirstSync(e,t){await t.whenSynced,e.hasSynced||await this.awaitFirstSyncOrDestroy(e),!(this._entries.get(e.docName)!==e||e.kind!==`active`||e.persistence!==t||!e.hasSynced)&&await t.flushFullState()}async awaitFirstSyncOrDestroy(e){e.hasSynced||await new Promise(t=>{let n=()=>{e.provider.off(`synced`,n),e.provider.off(`destroy`,n),t()};e.provider.on(`synced`,n),e.provider.on(`destroy`,n)})}attachDeferredPersistence(e){for(let t of Array.from(this._entries.values()))if(t.kind===`active`&&t.persistence===null&&this._entries.get(t.docName)===t){if(t.hasSynced&&t.lineageEpochRecordAtOpen!==null){let e=t.provider.document.getMap(`lifecycle`).get(dt);if(typeof e==`string`&&e.length>0&&e!==t.lineageEpochRecordAtOpen){let n=t.docName;this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(n),via:`deferred-attach`,staleEpoch:t.lineageEpochRecordAtOpen,liveEpoch:e});let r=this.activeDocName===n;this.runCloseAndClearPersistence(n),this.open(n)!==null&&r&&this.setActive(n);continue}}this.validateStoredStateThenAttach(t,e)}}getServerRestartRecoveryState(){return this.serverRestartRecoveryState}observeDiskAck(e,t){let n=this.entries.get(e);!n||n.kind!==`active`||(n.lastDiskAckedSV=cD(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(tQ)??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(tQ):this.storage?.setItem(tQ,e)}catch{}}docLineageEpochs=new Map;docLineageEpochsEnvelopeConsumed=!1;normalizedObservedBranch(){return this.getOrInitObservedBranch()??`_unknown_`}consumeLineageEpochEnvelopeIfValid(){if(this.docLineageEpochsEnvelopeConsumed)return;let e=this.cachedServerInstanceId;if(!(e===null||e.length===0)){this.docLineageEpochsEnvelopeConsumed=!0;try{let t=this.storage?.getItem(nQ)??null;if(t===null)return;let n=JSON.parse(t);if(typeof n!=`object`||!n)return;let r=n;if(r.branch!==this.normalizedObservedBranch()||r.serverInstanceId!==e||typeof r.epochs!=`object`||r.epochs===null)return;for(let[e,t]of Object.entries(r.epochs))typeof t==`string`&&t.length>0&&!this.docLineageEpochs.has(e)&&this.docLineageEpochs.set(e,t)}catch(e){e instanceof DOMException||console.warn(JSON.stringify({event:`ok-lineage-epoch-envelope-read-error`,errorName:e instanceof Error?e.name:typeof e,message:e instanceof Error?e.message:String(e)}))}}}getRecordedLineageEpoch(e){let t=this.docLineageEpochs.get(e);return t===void 0?(this.consumeLineageEpochEnvelopeIfValid(),this.docLineageEpochs.get(e)??null):t}persistLineageEpochEnvelope(){let e=this.cachedServerInstanceId;if(!(e===null||e.length===0))try{this.storage?.setItem(nQ,JSON.stringify({branch:this.normalizedObservedBranch(),serverInstanceId:e,epochs:Object.fromEntries(this.docLineageEpochs)}))}catch{}}recordLineageEpoch(e,t){this.docLineageEpochs.get(e)!==t&&(this.docLineageEpochs.set(e,t),this.persistLineageEpochEnvelope())}deleteLineageEpochRecord(e){this.docLineageEpochs.delete(e)&&this.persistLineageEpochEnvelope()}withClearDataTimeout(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>{r(new $Z(e,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);t.then(()=>{clearTimeout(i),n()},e=>{clearTimeout(i),r(e)})})}recoveryTelemetryBase(e,t){let n={docName:e,branch:this.normalizedObservedBranch()},r=t===void 0?this.recoveryMismatchStaleClaim:t;return r!==void 0&&r.length>0&&(n.serverInstanceId=r),n}emitStructuredClientRecoveryEvent(e){console.warn(JSON.stringify(e))}clearRecoveryMismatchStaleClaimIfTerminal(){let e=this.serverRestartRecoveryState.kind;(e===`idle`||e===`failed`)&&(this.recoveryMismatchStaleClaim=void 0)}beginServerRestartRecovery(e,t){this.serverRestartRecoveryState={kind:`recovering`,phase:`clearing-local-cache`,docNames:e,failedDocNames:[],startedAt:t};for(let t of e)WZ(t);this.notify()}enterServerRestartReconnect(e,t,n,r){if(e.length===0){this.serverRestartRecoveryState=t.length===0?qZ:{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=qZ,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(CZ(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(),$(`ok/pool/open`,{docName:e,hit:!0,lastAccessedAt:n,poolEventId:t.poolEventId}),$.count(`ok/pool/open`,{hit:!0}),t}let n=Date.now();this.entries.size>=this.maxSize&&this.evictLru();let r=this.cachedServerInstanceId,i=this.getRecordedLineageEpoch(e),a=AE(this.tabIdentity,r,this.getOrInitObservedBranch(),r!==null&&r.length>0?i:null),o=new kE({url:lD(this.wsUrl),name:e,forceSyncInterval:rQ,token:a}),s=this.cachedServerInstanceId;this.clearFailures.has(e)&&this.runCloseAndClearPersistence(e);let c=this.pendingClears.get(e),l=s!==null&&s.length>0&&c===void 0&&i!==null?this.buildPersistence(s,e,o.document):null,u=crypto.randomUUID(),d={kind:`active`,provider:o,persistence:l,lastServerSyncedSV:null,lastDiskAckedSV:null,observerCleanup:null,observerFireCounterCleanup:JZ(o.document,e),syncState:`connecting`,docName:e,lastAccessedAt:Date.now(),poolEventId:u,hasSynced:!1,pendingRecycleTimer:null,bridgeSetupFailed:!1,serverDrivenCloseReauthInFlight:!1,persistenceAttachOwned:!1,lineageEpochRecordAtOpen:i};if($(`ok/pool/open`,{docName:e,hit:!1,poolEventId:u}),$.count(`ok/pool/open`,{hit:!1}),o.on(`status`,({status:t})=>{d.kind!==`active`||this.entries.get(e)!==d||t===`disconnected`&&(d.syncState=`disconnected`,this.notify())}),o.on(`synced`,()=>{if(d.kind!==`active`||this.entries.get(e)!==d)return;d.syncState=`synced`,d.hasSynced=!0,d.lastServerSyncedSV=oD(o.document);let t=o.document.getMap(`lifecycle`).get(dt);if(typeof t==`string`&&t.length>0&&this.recordLineageEpoch(e,t),d.pendingRecycleTimer&&=(clearTimeout(d.pendingRecycleTimer),null),this.markServerRestartRecoverySynced(e),this.notify(),!d.observerCleanup)try{let t=o.document,n=new ge({extensions:SZ});d.observerCleanup=dU({doc:t,xmlFragment:t.getXmlFragment(`default`),ytext:t.getText(`source`),mdManager:n,schema:XZ(),onSyncError:(t,n)=>{console.warn(`[Sync] ${t} failed for ${e}:`,n.message)}})}catch(t){console.error(`[ProviderPool] setupObservers init failed for ${e}:`,t),d.bridgeSetupFailed=!0,GZ(e,new OZ(e,t))}}),o.on(`disconnect`,()=>{d.kind!==`active`||this.entries.get(e)!==d||(d.syncState=`disconnected`,this.notify(),d.hasSynced&&o.unsyncedChanges===0&&!d.pendingRecycleTimer&&(d.pendingRecycleTimer=setTimeout(()=>{d.kind===`active`&&(d.pendingRecycleTimer=null,this.entries.get(e)===d&&this.recycleDisconnectedEntry(e))},this.recycleDebounceMs)))}),o.on(`authenticationFailed`,({reason:t})=>{let n=[`server-instance-mismatch`,`branch-mismatch`,`rename-redirect`,`doc-deleted`,`doc-lineage-mismatch`],i=t.indexOf(`:`),a=i===-1?t:t.slice(0,i);if(!n.includes(a)){console.warn(JSON.stringify({event:`ok-auth-failed-unknown-reason`,reason:t}));return}let o=i===-1?``:t.slice(i+1),s=o.length>0?o:void 0,c=a;if(c===`server-instance-mismatch`){if(r===null||this.cachedServerInstanceId!==r)return;let e=r;this.cachedServerInstanceId=null,this.handleServerInstanceMismatch(e);return}if(c===`branch-mismatch`){this.onBranchMismatch?.();return}if(c===`rename-redirect`){if(s===void 0||s.length===0){console.warn(JSON.stringify({event:`rename-redirect-missing-payload`,fromDocName:e}));return}let t=e,n=s;this.deleteLineageEpochRecord(t);let r=this.entries.get(t),i=r!==void 0&&r.kind===`active`;this.onRenameRedirect?.({fromDocName:t,toDocName:n,hadOpenProvider:i});return}if(c===`doc-deleted`){this.deleteLineageEpochRecord(e);let t=this.entries.get(e),n=t!==void 0&&t.kind===`active`;this.onDocDeleted?.({docName:e,hadOpenProvider:n});return}if(c===`doc-lineage-mismatch`){if(d.kind!==`active`||this.entries.get(e)!==d)return;this.deleteLineageEpochRecord(e),this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(e),via:`auth-rejection`,staleEpoch:d.lineageEpochRecordAtOpen??``});let t=this.activeDocName===e;this.runCloseAndClearPersistence(e),this.open(e)!==null&&t&&this.setActive(e);return}}),o.on(`close`,({event:t})=>{if(d.kind!==`active`||this.entries.get(e)!==d||d.serverDrivenCloseReauthInFlight)return;d.serverDrivenCloseReauthInFlight=!0,o.sendToken().catch(t=>{console.warn(JSON.stringify({event:`ok-provider-server-driven-close-reauth-failed`,docName:e,message:t instanceof Error?t.message:String(t)}))}).finally(()=>{d.kind===`active`&&this.entries.get(e)===d&&(d.serverDrivenCloseReauthInFlight=!1)});let n=t?.reason??`<unknown>`;console.info(JSON.stringify({event:`ok-provider-server-driven-close-reauth`,docName:e,reason:n}))}),this.bufferedUpdates.get(e)!==void 0){let t=this.recoveryMismatchStaleClaim,n=()=>{if(o.off(`synced`,n),d.kind!==`active`||this.entries.get(e)!==d)return;let r=this.bufferedUpdates.get(e);if(r!==void 0){this.bufferedUpdates.delete(e);try{Jm(o.document,r,KZ)}catch(n){let i=n instanceof Error?n.name:`non-error-throw`;this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-failed`,...this.recoveryTelemetryBase(e,t),replayByteLength:r.byteLength,errorName:i,errorMessage:n instanceof Error?n.message:String(n)})}}};o.on(`synced`,n)}if(this._entries.set(e,d),this.touch(e),this.notify(),l===null&&s!==null&&s.length>0&&c===void 0&&this.validateStoredStateThenAttach(d,s),c!==void 0&&s!==null&&s.length>0){let t=s;c.then(()=>{this.attachDeferredPersistenceForEntry(d,t)},t=>{console.warn(JSON.stringify({event:`ok-pool-deferred-persistence-attach-skipped`,docName:e,reason:`pending-clear-failed`,message:t instanceof Error?t.message:String(t)}))})}let f=Gx(e);return f!==void 0&&tS(f,`ok.provider-pool.open`,{"doc.name":e},n,Date.now()),d}attachDeferredPersistenceForEntry(e,t){let n=this._entries.get(e.docName);n!==e||n.kind!==`active`||n.persistence!==null||this.validateStoredStateThenAttach(n,t)}handleServerInstanceMismatch(e){this.recoveryMismatchStaleClaim=e.length>0?e:void 0;let t=Array.from(this.entries.entries()),n=Date.now(),r=this.activeDocName,i=r!==null&&t.some(([e,t])=>e===r&&t.kind===`active`)?[r]:[],a=r??t.find(([,e])=>e.kind===`active`)?.[0]??``;a.length>0&&this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-epoch-mismatch`,...this.recoveryTelemetryBase(a)}),this.beginServerRestartRecovery(i,n);for(let[e,n]of t)n.kind===`active`&&!i.includes(e)&&WZ(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=sD(n.provider.document,t);if(r.byteLength>iQ){$(`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 $Z;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(CZ(e))return null;let t=this.entries.get(e);if(t)return t;let n=this.open(e);if(!n)return null;let r=this.lruOrder.indexOf(e);return r!==-1&&(this.lruOrder.splice(r,1),this.lruOrder.unshift(e)),n}close(e){let t=this.entries.get(e);t&&(this.destroyEntry(t),this._entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),this.bufferedUpdates.delete(e),this.activeDocName===e&&(this.activeDocName=null),this.notify())}async closeAndClearPersistence(e){try{await this.runCloseAndClearPersistence(e)}catch{}}runCloseAndClearPersistence(e){let t=this.pendingClears.get(e);if(t!==void 0)return t;let n=()=>{},r=()=>{},i=new Promise((e,t)=>{n=e,r=t});this.pendingClears.set(e,i);let a=()=>{this.pendingClears.get(e)===i&&this.pendingClears.delete(e)};return i.then(a,a),this.executeCloseAndClearPersistence(e).then(n,r),i}async executeCloseAndClearPersistence(e){this.clearFailures.delete(e);let t=this.entries.get(e);if(t?.kind===`active`&&t.persistence!==null){let n=t.persistence;try{this.close(e)}catch(t){console.warn(`[ProviderPool] close before clearData threw for ${e}:`,t)}try{await this.withClearDataTimeout(e,n.clearData())}catch(t){throw console.warn(`[ProviderPool] clearData on rename failed for ${e}:`,t),this.clearFailures.add(e),t}return}if(t)try{this.close(e)}catch(t){console.warn(`[ProviderPool] close before IDB-by-name delete threw for ${e}:`,t)}let n=this.normalizedObservedBranch(),r=this.cachedServerInstanceId;if(r===null)return;let i=`ok-ydoc:${n}:${r}:${e}`;try{await this.withClearDataTimeout(e,new Promise((e,t)=>{let n=indexedDB.deleteDatabase(i);n.onsuccess=()=>e(),n.onerror=()=>t(n.error),n.onblocked=()=>{console.warn(`[ProviderPool] IDB delete blocked for ${i}`)}}))}catch(t){throw console.warn(`[ProviderPool] IDB delete on rename failed for ${i}:`,t),this.clearFailures.add(e),t}}clearBufferedUpdates(){this.bufferedUpdates.clear()}__test_seedBufferedUpdate(e,t){this.bufferedUpdates.set(e,t)}__test_bufferedUpdatesSize(){return this.bufferedUpdates.size}__test_hasBufferedUpdate(e){return this.bufferedUpdates.has(e)}__test_getBufferedUpdate(e){return this.bufferedUpdates.get(e)}setActive(e){let t=this.entries.get(e);if(!t)throw Error(`[ProviderPool] Cannot setActive — "${e}" is not open`);t.lastAccessedAt=Date.now(),this.touch(e),this.activeDocName=e,this.notify()}clearActive(){this.activeDocName!==null&&(this.activeDocName=null,this.notify())}getActive(){return this.activeDocName?this.entries.get(this.activeDocName)??null:null}getActiveDocName(){return this.activeDocName}has(e){return this.entries.has(e)}peek(e){return this.entries.get(e)??null}recycle(e){this.recycleDisconnectedEntry(e)}dispose(){for(let e of this._entries.values())this.destroyEntry(e);this._entries.clear(),this.lruOrder=[],this.activeDocName=null,this.onChange=null,this.bufferedUpdates.clear(),this.pendingClears.clear(),this.clearFailures.clear(),this.docLineageEpochs.clear(),this.docLineageEpochsEnvelopeConsumed=!1,this.onBranchMismatch=null,this.branchMismatchInFlight=null,this.onRenameRedirect=null,this.onDocDeleted=null,this.evictListeners.clear(),this.serverRestartRecoveryState=qZ,this.cachedServerInstanceId=null,this.pendingServerInstanceKnown=null,this.tabIdentity=null,this.recoveryMismatchStaleClaim=void 0}evictLru(){for(let e of this.lruOrder)if(e!==this.activeDocName){$(`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),WZ(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($(`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()}},sQ=crypto.randomUUID(),cQ=!1;function lQ(e){cQ||(cQ=!0,console.warn(`[principal-fetch] failed to resolve principal — falling back to random identity.`,e))}var uQ=(0,Q.createContext)(null),dQ=null;function fQ(e){return dQ||(dQ=new oQ(aQ,e),tC(dQ)),dQ}var pQ={activeDocName:null,activeProvider:null,syncState:`connecting`,serverRestartRecovery:{kind:`idle`},poolEntries:[]};function mQ(){if(typeof window>`u`)return null;let e=window.okDesktop;return e?.config.mode===`editor`?e:null}function hQ(){return typeof window>`u`||window.okDesktop?.config.mode===`editor`?null:WC(window.location.origin)}function gQ(){if(typeof window>`u`)return HC(null,aQ);let e=hQ();return e?GC(window.localStorage===void 0?null:window.localStorage,e,aQ):HC(null,aQ)}function _Q(){return gQ().openTabs}function vQ(){return gQ().pinnedTabIds}function yQ(){if(typeof window>`u`||window.location.hash.length>0)return null;let e=gQ();return e.activeTabId??(e.activeDocName?fC(e.activeDocName):null)??e.openTabs[0]??null}function bQ(e){let t=bC(e);switch(t.kind){case`doc`:return xn(t.docName);case`folder`:return Cn(t.folderPath);case`asset`:return Tn(t.assetPath)}}function xQ(e){let t=yn(e);if(t)return _C(t);let n=Mn(e);if(!n)return null;let r=n.trim();if(/\/+$/.test(r)){let e=r.replace(/\/+$/g,``);return e?gC(e):null}return fC(n)}function SQ(e){return{kind:`asset`,target:e,assetPath:e,mediaKind:w(e.split(`.`).pop()??``)}}function CQ(e,t){return e?yC(e):t?fC(t):null}function wQ(e,t,n){return e.some(e=>!n.has(e)&&xC(e)===t)}function TQ(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function EQ(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 DQ(e,t){return e===t?!0:!e||!t?!1:EQ(e)===EQ(t)}function OQ(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 kQ(e){let t=(0,Z.c)(175),{children:n}=e,[r,i]=(0,Q.useState)(pQ),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(yQ),[l,u]=(0,Q.useState)(_Q),[d,f]=(0,Q.useState)(vQ),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[0]=p):p=t[0];let[m,h]=(0,Q.useState)(p),[g,_]=(0,Q.useState)(l),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),S=(0,Q.useRef)(s),C=(0,Q.useRef)(l),w=(0,Q.useRef)(d),T=(0,Q.useRef)(v),E=(0,Q.useRef)(m),D=(0,Q.useRef)(g),O=(0,Q.useRef)(1),k=(0,Q.useRef)(!1),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(`doc`),[R,z]=(0,Q.useState)(null),[B,ee]=(0,Q.useState)(0),{collabUrl:V,terminal:te,lastError:H,retry:U}=Mx(),ne;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(ne=function(e){S.current=e,c(e)},t[1]=ne):ne=t[1];let W=ne,re;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(re=function(e){T.current=e,y(e)},t[2]=re):re=t[2];let G=re,ie;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(ie=function(e){D.current=e,_(t=>TQ(t,e)?t:e)},t[3]=ie):ie=t[3];let ae=ie,oe;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(oe=function(e){w.current=e,f(t=>TQ(t,e)?t:e)},t[4]=oe):oe=t[4];let K=oe,se;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(se=function(e,t){let n=CC(t,e);C.current=e,w.current=n,u(t=>TQ(t,e)?t:e),f(e=>TQ(e,n)?e:n),ae(PC(D.current,e,E.current))},t[5]=se):se=t[5];let ce=se,q;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(q=function(e){ce(e,w.current)},t[6]=q):q=t[6];let le=q,ue;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(ue=function(e){le(e(C.current))},t[7]=ue):ue=t[7];let de=ue,fe;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(fe=function(e){E.current=e,h(t=>TQ(t,e)?t:e),ae(PC(D.current,C.current,e))},t[8]=fe):fe=t[8];let pe=fe,me;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(me=function(e){let t=T.current;if(!t)return;let n=E.current.filter(e=>e!==t);E.current=n,h(e=>TQ(e,n)?e:n),G(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))}ae(PC(r,C.current,n))},t[9]=me):me=t[9];let he=me,ge,_e;t[10]===s?(ge=t[11],_e=t[12]):(ge=()=>{S.current=s},_e=[s],t[10]=s,t[11]=ge,t[12]=_e),(0,Q.useEffect)(ge,_e);let ve,ye;t[13]===l?(ve=t[14],ye=t[15]):(ve=()=>{C.current=l},ye=[l],t[13]=l,t[14]=ve,t[15]=ye),(0,Q.useEffect)(ve,ye);let be,xe;t[16]===d?(be=t[17],xe=t[18]):(be=()=>{w.current=d},xe=[d],t[16]=d,t[17]=be,t[18]=xe),(0,Q.useEffect)(be,xe);let Se,Ce;t[19]===v?(Se=t[20],Ce=t[21]):(Se=()=>{T.current=v},Ce=[v],t[19]=v,t[20]=Se,t[21]=Ce),(0,Q.useEffect)(Se,Ce);let we,Te;t[22]===m?(we=t[23],Te=t[24]):(we=()=>{E.current=m},Te=[m],t[22]=m,t[23]=we,t[24]=Te),(0,Q.useEffect)(we,Te);let Ee,De;t[25]===g?(Ee=t[26],De=t[27]):(Ee=()=>{D.current=g},De=[g],t[25]=g,t[26]=Ee,t[27]=De),(0,Q.useEffect)(Ee,De);let Oe=v!==null,ke,Ae;t[28]!==V||t[29]!==A||t[30]!==b?(ke=()=>{if(V===null||b||!A)return;let e=!1,t=mQ(),n=hQ(),r=typeof localStorage<`u`?localStorage:null;return(t?t.project.getSessionState():Promise.resolve(n?GC(r,n,aQ):{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null})).then(t=>{if(e)return;let n=HC(t,aQ);if(k.current)return;let r=fQ(V);for(let e of n.openTabs){let t=xC(e);t&&r.open(t)}let i=[...n.pinnedTabIds,...w.current],a=n.openTabs;for(let e of C.current)a=kC(a,e,aQ,i);let o=CC(i,a);C.current=a,w.current=o,u(e=>TQ(e,a)?e:a),f(e=>TQ(e,o)?e:o);let s=PC(D.current,a,E.current);D.current=s,_(e=>TQ(e,s)?e:s);let l=Mn(window.location.hash),d=n.activeTabId??(n.activeDocName?fC(n.activeDocName):null)??n.openTabs[0]??null,p=d?bQ(d):null;if((l===null&&window.location.hash.length===0||p!==null&&p===window.location.hash)&&d){S.current=d,c(d);let e=bQ(d);window.location.hash!==e&&(window.location.hash=e)}}).catch(zQ).finally(()=>{e||x(!0)}),()=>{e=!0}},Ae=[V,A,b],t[28]=V,t[29]=A,t[30]=b,t[31]=ke,t[32]=Ae):(ke=t[31],Ae=t[32]),(0,Q.useEffect)(ke,Ae);let je,Me;t[33]!==s||t[34]!==a||t[35]!==l||t[36]!==d||t[37]!==r.activeDocName||t[38]!==b?(je=()=>{if(!b)return;let e=UC(l,s??CQ(a,r.activeDocName),d),t=mQ();if(t){t.project.setSessionState(e).catch(RQ);return}let n=hQ();n&&KC(typeof localStorage<`u`?localStorage:null,n,e)},Me=[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]=je,t[40]=Me):(je=t[39],Me=t[40]),(0,Q.useEffect)(je,Me);let Ne;t[41]===b?Ne=t[42]:(Ne=function(){b||(k.current=!0)},t[41]=b,t[42]=Ne);let Pe=Ne,Fe,Ie;t[43]===V?(Fe=t[44],Ie=t[45]):(Fe=()=>{if(V===null)return;let e=!1;j(!1);let t=fQ(V);i(OQ(t));let n=function(e,t){let n=CC(t,e);C.current=e,w.current=n,u(t=>TQ(t,e)?t:e),f(e=>TQ(e,n)?e:n);let r=PC(D.current,e,E.current);D.current=r,_(e=>TQ(e,r)?e:r)};return t.setOnBranchMismatch(()=>hx(t)),t.setOnRenameRedirect(e=>{let{fromDocName:r,toDocName:i,hadOpenProvider:a}=e;(async()=>{let e,s=t.getActiveDocName()===r;FS([{fromDocName:r,toDocName:i}]);try{await Promise.all([t.closeAndClearPersistence(r),t.closeAndClearPersistence(i)]),s&&(t.open(i),t.setActive(i));let e=IC(C.current,[{fromDocName:r,toDocName:i}],aQ,[],w.current),a=CC(IC(w.current,[{fromDocName:r,toDocName:i}],2**53-1),e);D.current=LC(D.current,[{fromDocName:r,toDocName:i}]),n(e,a),o(e=>e&&(Dn(e)===r?{kind:`doc`,target:i,docName:i}:e)),s&&(window.location.hash=xn(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(NC(C.current,r),w.current),o(e=>e&&(Dn(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(OQ(t))),fetch(`/api/principal`).then(LQ).then(n=>{if(e)return;let r=Ge.safeParse(n);r.success?(t.setTabIdentity({principalId:r.data.id,tabSessionId:sQ}),N(r.data)):lQ(r.error)}).catch(t=>{e||lQ(t)}).finally(()=>{e||j(!0)}),hx(t),()=>{e=!0,t.setOnChange(null),t.setOnRenameRedirect(null),t.setOnDocDeleted(null)}},Ie=[V],t[43]=V,t[44]=Fe,t[45]=Ie),(0,Q.useEffect)(Fe,Ie);let Le;t[46]===V?Le=t[47]:(Le=e=>{if($(`ok/nav/open-document`,{docName:e,transition:!1}),V===null)return;let t=fQ(V),n=t.open(e);if(!n)return;ax(e,n.poolEventId);let r=fC(e);de(e=>kC(e,r,aQ,w.current)),he(r),W(r),t.setActive(e),o({kind:`doc`,target:e,docName:e})},t[46]=V,t[47]=Le);let Re=Le,ze;t[48]===Re?ze=t[49]:(ze=e=>{$(`ok/nav/open-document`,{docName:e,transition:!1}),Re(e)},t[48]=Re,t[49]=ze);let Be=ze,Ve;t[50]!==a||t[51]!==V||t[52]!==Pe||t[53]!==r.activeDocName?(Ve=(e,t)=>{let n=t===void 0?{}:t;if(V===null)return;n.tabBehavior===`replace-active`&&Pe();let i=fQ(V),s=Dn(e),c=T.current,l=c!==null&&n.tabBehavior===`replace-active`,u=c?null:S.current??CQ(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;ax(s,e.poolEventId);let t=l?mC(C.current,s):null,n=l?{activeTabId:t??fC(s),tabs:kC(C.current,t??fC(s),aQ,w.current)}:jC(C.current,s,{behavior:p,currentTabId:u,limit:aQ,pinnedTabIds:w.current});le(n.tabs),he(n.activeTabId),W(n.activeTabId),i.setActive(s)}else{i.clearActive();let t=yC(e);if(t){let e=MC(C.current,t,{behavior:p,currentTabId:u,limit:aQ,pinnedTabIds:w.current});le(e.tabs),W(e.activeTabId),he(e.activeTabId)}else he(t)}o(t=>DQ(t,e)?t:e)},t[50]=a,t[51]=V,t[52]=Pe,t[53]=r.activeDocName,t[54]=Ve):Ve=t[54];let He=Ve,Ue;t[55]===He?Ue=t[56]:(Ue=(e,t)=>{He(e,t===void 0?{}:t)},t[55]=He,t[56]=Ue);let We=Ue,Ke;t[57]===He?Ke=t[58]:(Ke=(e,t)=>{let n=t===void 0?{}:t;$(`ok/nav/open-target`,{docName:Dn(e),kind:e.kind,transition:!1}),He(e,n)},t[57]=He,t[58]=Ke);let qe=Ke,Je;t[59]!==s||t[60]!==a||t[61]!==V||t[62]!==Pe||t[63]!==r.activeDocName?(Je=e=>{if(w.current.includes(e))return;Pe();let t=null,n=xC(e);if(V!==null){let t=fQ(V);n&&!wQ(C.current,n,new Set([e]))&&t.close(n)}let i=s??CQ(a,r.activeDocName);if(de(n=>(t=BC(n,i,e),NC(n,e))),i===e){if(t){W(t),window.location.hash=bQ(t);return}V!==null&&fQ(V).clearActive(),o(null),W(null),window.location.hash=``}},t[59]=s,t[60]=a,t[61]=V,t[62]=Pe,t[63]=r.activeDocName,t[64]=Je):Je=t[64];let Ye=Je,Xe;t[65]!==V||t[66]!==Pe?(Xe=e=>{Pe();let t=E.current;if(!t.includes(e))return;let n=t.filter(t=>t!==e);if(pe(n),T.current!==e)return;let r=t.indexOf(e),i=n[r]??n[r-1]??null;if(i){G(i),V!==null&&fQ(V).clearActive(),o(null),W(null),window.location.hash!==``&&(window.location.hash=``);return}G(null);let a=C.current[C.current.length-1]??null;if(a){W(a),window.location.hash=bQ(a);return}V!==null&&fQ(V).clearActive(),o(null),W(null),window.location.hash=``},t[65]=V,t[66]=Pe,t[67]=Xe):Xe=t[67];let Ze=Xe,Qe;t[68]!==Ze||t[69]!==Ye?(Qe=()=>{let e=T.current;if(e)return Ze(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 Ye(r),!0;let i=new Set(E.current),a=D.current.find(e=>i.has(e));return a?(Ze(a),!0):!1},t[68]=Ze,t[69]=Ye,t[70]=Qe):Qe=t[70];let $e=Qe,et,tt;t[71]===$e?(et=t[72],tt=t[73]):(et=()=>{let e=mQ();if(e)return e.onMenuAction(e=>{e===`close-active-tab-or-window`&&($e()||window.close())})},tt=[$e],t[71]=$e,t[72]=et,t[73]=tt),(0,Q.useEffect)(et,tt);let nt;t[74]===V?nt=t[75]:(nt=()=>{if(V===null){o(IQ),S.current=null,c(FQ);return}let e=fQ(V);e.getActiveDocName()!==null&&e.clearActive(),o(PQ),S.current=null,c(NQ)},t[74]=V,t[75]=nt);let rt;t[76]!==V||t[77]!==Pe?(rt=e=>{V!==null&&(Pe(),fQ(V).close(e),de(t=>NC(t,fC(e))),c(t=>{let n=t&&xC(t)===e?null:t;return S.current=n,n}),o(t=>t&&(Dn(t)===e?null:t)))},t[76]=V,t[77]=Pe,t[78]=rt):rt=t[78];let it;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(it=e=>{let t=TC(w.current,e,C.current);TQ(w.current,t)||K(t)},t[79]=it):it=t[79];let at;t[80]===Pe?at=t[81]:(at=e=>{let t=EC(w.current,e);TQ(w.current,t)||(Pe(),K(t))},t[80]=Pe,t[81]=at);let ot;t[82]===V?ot=t[83]:(ot=e=>{let t=bC(e);if(G(null),W(e),t.kind===`doc`){if(V!==null){let e=fQ(V);if(!e.open(t.docName))return;e.setActive(t.docName)}o({kind:`doc`,target:t.docName,docName:t.docName});let e=xn(t.docName);window.location.hash!==e&&(window.location.hash=e);return}if(V!==null&&fQ(V).clearActive(),t.kind===`asset`){o(SQ(t.assetPath));let e=Tn(t.assetPath);window.location.hash!==e&&(window.location.hash=e);return}o({kind:`folder`,target:t.folderPath,folderPath:t.folderPath});let n=Cn(t.folderPath);window.location.hash!==n&&(window.location.hash=n)},t[82]=V,t[83]=ot);let st;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(st=(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=TQ(C.current,a),l=TQ(E.current,o),u=TQ(D.current,s);c&&l&&u||(D.current=s,l||(E.current=o,h(e=>TQ(e,o)?e:o)),ce(a,OC(a,w.current,t)))},t[84]=st):st=t[84];let ct,lt;t[85]===V?(ct=t[86],lt=t[87]):(ct=()=>{let e=`new-tab:${O.current}`;O.current+=1,pe([...E.current,e]),G(e),V!==null&&fQ(V).clearActive(),o(null),W(null),window.location.hash!==``&&(window.location.hash=``)},lt=e=>{E.current.includes(e)&&(V!==null&&fQ(V).clearActive(),o(null),W(null),G(e),window.location.hash!==``&&(window.location.hash=``))},t[85]=V,t[86]=ct,t[87]=lt);let ut;t[88]!==s||t[89]!==a||t[90]!==V||t[91]!==Pe||t[92]!==r.activeDocName?(ut=(e,t)=>{let n=t===void 0?{}:t,i=e.filter(MQ),c=new Set(n.force?i:DC(i,w.current));if(c.size===0)return;if(Pe(),V!==null){let e=fQ(V),t=new Map;for(let e of c){let n=xC(e);if(!n)continue;let r=t.get(n)??new Set;r.add(e),t.set(n,r)}for(let[n,r]of t)wQ(C.current,n,r)||e.close(n)}let l=null,u=s??CQ(a,r.activeDocName);if(de(e=>(l=VC(e,u,c),e.filter(e=>!c.has(e)))),!u||!c.has(u)){u||o(e=>{if(!e)return e;let t=yC(e);return t&&c.has(t)?null:e});return}if(l){W(l),window.location.hash=bQ(l);return}V!==null&&fQ(V).clearActive(),o(null),W(null),window.location.hash=``},t[88]=s,t[89]=a,t[90]=V,t[91]=Pe,t[92]=r.activeDocName,t[93]=ut):ut=t[93];let dt;t[94]!==s||t[95]!==a||t[96]!==V||t[97]!==Pe||t[98]!==l||t[99]!==r.activeDocName?(dt=e=>{let{pages:t,folderPaths:n,assetPaths:i}=e,c=FC(l,{pages:t,folderPaths:n,assetPaths:i,keepMissingDocName:a?.kind===`missing`?a.target:null,keepHashDocName:typeof window<`u`?Mn(window.location.hash):null});if(c.length===l.length)return;let u=new Set(c),d=l.filter(e=>!u.has(e)),f=new Set(d);if(Pe(),V!==null){let e=fQ(V);for(let t of d){let n=xC(t);n&&e.close(n)}}le(c);let p=typeof window<`u`?xQ(window.location.hash):null,m=s??CQ(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=yC(e);return t&&f.has(t)?null:e});return}let g=VC(l,h,d);if(g){W(g),window.location.hash=bQ(g);return}V!==null&&fQ(V).clearActive(),o(null),W(null),window.location.hash=``},t[94]=s,t[95]=a,t[96]=V,t[97]=Pe,t[98]=l,t[99]=r.activeDocName,t[100]=dt):dt=t[100];let ft;t[101]!==V||t[102]!==Pe?(ft=(e,t,n)=>{let r=t===void 0?[]:t,i=n===void 0?[]:n;Pe();let a=IC(C.current,e,aQ,r,w.current,i),o=CC(IC(w.current,e,2**53-1,r,[],i),a);if(V!==null){let e=fQ(V);for(let t of a){let n=xC(t);n&&e.open(n)}}D.current=LC(D.current,e,r,i),ce(a,o);let s=S.current;if(s){let t=IC([s],e,1,r,[],i)[0];t&&a.includes(t)&&W(t)}},t[101]=V,t[102]=Pe,t[103]=ft):ft=t[103];let pt,mt,ht,gt,_t;t[104]===V?(pt=t[105],mt=t[106],ht=t[107],gt=t[108],_t=t[109]):(pt=async e=>{V!==null&&(await fQ(V).closeAndClearPersistence(e),o(t=>t&&(Dn(t)===e?null:t)))},mt=()=>V===null?null:fQ(V).getActiveDocName(),ht=e=>V===null?!1:fQ(V).has(e),gt=e=>{V!==null&&fQ(V).recycle(e)},_t=e=>V===null?null:fQ(V).prewarm(e)?.poolEventId??null,t[104]=V,t[105]=pt,t[106]=mt,t[107]=ht,t[108]=gt,t[109]=_t);let vt,yt,bt,xt,St;t[110]===V?(vt=t[111],yt=t[112],bt=t[113],xt=t[114],St=t[115]):(vt=e=>{V!==null&&fQ(V).setExpectedServerInstanceId(e)},yt=async e=>{if(V===null)return;let t=fQ(V);t.setObservedBranch(e),await ox(t,e),Nn([`files`,`backlinks`,`graph`]),Pn(e)},bt=async e=>{if(V===null)return;let t=fQ(V);t.compareAndUpdateObservedBranch(e)&&(await ox(t,e),Nn([`files`,`backlinks`,`graph`]),Pn(e))},xt=(e,t)=>{V!==null&&fQ(V).observeDiskAck(e,t)},St=async()=>{V!==null&&await hx(fQ(V))},t[110]=V,t[111]=vt,t[112]=yt,t[113]=bt,t[114]=xt,t[115]=St);let Ct;t[116]!==R||t[117]!==I||t[118]!==r.activeDocName?(Ct=(e,t)=>{if(!r.activeDocName&&t){window.location.hash=xn(t),z(e),L(`agent`),ee(jQ);return}if(I===`agent`&&R===e){L(`doc`);return}z(e),L(`agent`),ee(AQ)},t[116]=R,t[117]=I,t[118]=r.activeDocName,t[119]=Ct):Ct=t[119];let wt;t[120]===Symbol.for(`react.memo_cache_sentinel`)?(wt=()=>{L(`doc`),z(null)},t[120]=wt):wt=t[120];let Tt;t[121]!==v||t[122]!==s||t[123]!==a||t[124]!==$e||t[125]!==Ze||t[126]!==Ye||t[127]!==H||t[128]!==te||t[129]!==V||t[130]!==R||t[131]!==B||t[132]!==I||t[133]!==Oe||t[134]!==m||t[135]!==Re||t[136]!==Be||t[137]!==l||t[138]!==We||t[139]!==qe||t[140]!==d||t[141]!==M||t[142]!==U||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]!==nt||t[150]!==rt||t[151]!==at||t[152]!==ot||t[153]!==ct||t[154]!==lt||t[155]!==ut||t[156]!==dt||t[157]!==ft||t[158]!==pt||t[159]!==mt||t[160]!==ht||t[161]!==gt||t[162]!==_t||t[163]!==vt||t[164]!==yt||t[165]!==bt||t[166]!==xt||t[167]!==St||t[168]!==Ct||t[169]!==b||t[170]!==g?(Tt={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:Re,openDocumentTransition:Be,openTarget:We,openTargetTransition:qe,clearTarget:nt,closeDocument:rt,closeActiveTabOrWindow:$e,closeTab:Ye,pinTab:it,unpinTab:at,activateTab:ot,reorderTabs:st,newTabIds:m,activeNewTabId:v,isNewTabActive:Oe,openNewTab:ct,activateNewTab:lt,closeNewTab:Ze,closeTabs:ut,syncOpenTabsWithKnownTargets:dt,remapTabsForRename:ft,closeAndClearForRename:pt,getPoolActiveDocName:mt,poolHas:ht,recycleDocument:gt,prewarm:_t,systemProvider:P,setSystemProvider:F,updateServerInstanceId:vt,onBranchSwitched:yt,observeBranch:bt,observeDiskAck:xt,refreshServerInfo:St,collabUrl:V,collabTerminal:te,collabLastError:H,retryCollab:U,docPanelMode:I,docPanelAgentId:R,docPanelExpandSignal:B,openActivityPanel:Ct,closeActivityPanel:wt},t[121]=v,t[122]=s,t[123]=a,t[124]=$e,t[125]=Ze,t[126]=Ye,t[127]=H,t[128]=te,t[129]=V,t[130]=R,t[131]=B,t[132]=I,t[133]=Oe,t[134]=m,t[135]=Re,t[136]=Be,t[137]=l,t[138]=We,t[139]=qe,t[140]=d,t[141]=M,t[142]=U,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]=nt,t[150]=rt,t[151]=at,t[152]=ot,t[153]=ct,t[154]=lt,t[155]=ut,t[156]=dt,t[157]=ft,t[158]=pt,t[159]=mt,t[160]=ht,t[161]=gt,t[162]=_t,t[163]=vt,t[164]=yt,t[165]=bt,t[166]=xt,t[167]=St,t[168]=Ct,t[169]=b,t[170]=g,t[171]=Tt):Tt=t[171];let Et=Tt,Dt;return t[172]!==n||t[173]!==Et?(Dt=(0,X.jsx)(uQ,{value:Et,children:n}),t[172]=n,t[173]=Et,t[174]=Dt):Dt=t[174],Dt}function AQ(e){return e+1}function jQ(e){return e+1}function MQ(e){return e.length>0}function NQ(e){return e===null?e:null}function PQ(e){return e===null?e:null}function FQ(e){return e===null?e:null}function IQ(e){return e===null?e:null}function LQ(e){return e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))}function RQ(e){console.warn(`[editor-tabs] failed to persist tab session:`,e)}function zQ(e){console.warn(`[editor-tabs] failed to restore tab session:`,e)}function BQ(){let e=(0,Q.use)(uQ);if(!e)throw Error(`useDocumentContext must be used within <DocumentProvider />`);return e}function VQ(){let e=(0,Z.c)(3),{openDocumentTransition:t,openTargetTransition:n}=BQ(),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{qk as $,Vi as $n,Iy as $t,WU as A,$s as An,qx as At,Jz as B,oa as Bn,ix as Bt,Rq as C,uc as Cn,jS as Ct,QW as D,ac as Dn,_S as Dt,eG as E,oc as En,vS as Et,fU as F,ga as Fn,Ux as Ft,_L as G,ta as Gn,qb as Gt,oR as H,ia as Hn,Qb as Ht,uU as I,ha as In,Vx as It,hL as J,Ji as Jn,Yb as Jt,uL as K,Zi as Kn,Jb as Kt,lU as L,ma as Ln,wx as Lt,AU as M,Ea as Mn,Kx as Mt,CU as N,Ta as Nn,Hx as Nt,$W as O,ic as On,gS as Ot,bU as P,Ca as Pn,Bx as Pt,vA as Q,Wi as Qn,Wy as Qt,iU as R,pa as Rn,gx as Rt,lJ as S,$ as Sn,VS as St,gK as T,rc as Tn,rS as Tt,Yz as U,ra as Un,Ub as Ut,VL as V,aa as Vn,Zb as Vt,UL as W,na as Wn,Wb as Wt,lI as X,Ki as Xn,Xb as Xt,uI as Y,qi as Yn,Kb as Yt,Gj as Z,Gi as Zn,Uy as Zt,GX as _,Sl as _n,vC as _t,DZ as a,Mm as an,Mi as ar,JD as at,VJ as b,Tl as bn,US as bt,TZ as c,Sh as cn,Di as cr,kD as ct,UZ as d,hh as dn,wi as dr,fC as dt,Rv as en,zi as er,Pk as et,CZ as f,Up as fn,xi as fr,DC as ft,WX as g,su as gn,yC as gt,nZ as h,cu as hn,vi as hr,RC as ht,OZ as i,fv as in,Ni as ir,ZD as it,RU as j,Na as jn,Gx as jt,$U as k,nc as kn,lS as kt,WZ as l,gh as ln,Ei as lr,kE as lt,rZ as m,Sf as mn,yi as mr,bC as mt,BQ as n,by as nn,Ii as nr,kO as nt,EZ as o,Zh as on,ji as or,PD as ot,SZ as p,Wp as pn,bi as pr,gC as pt,cL as q,Yi as qn,Gb as qt,VQ as r,Tv as rn,Fi as rr,DO as rt,kZ as s,Ch as sn,Oi as sr,ND as st,kQ as t,my as tn,Li as tr,ek as tt,zZ as u,bh as un,Ti as ur,_C as ut,VY as v,bl as vn,FS as vt,Cq as w,cc as wn,QS as wt,bJ as x,gc as xn,WS as xt,RY as y,Dl as yn,MS as yt,nU as z,ua as zn,px as zt};
|
|
34
|
+
${JG(e)}`}var ZG=`plaintext`;function QG(){return typeof document<`u`&&document.documentElement.classList.contains(`dark`)?`dark`:`light`}function $G(e,t){let n=(0,Z.c)(4),[r,i]=(0,Q.useState)(!1),a,o;return n[0]!==e||n[1]!==t?(a=()=>{let n=()=>{let n=typeof t==`function`?t():void 0;if(typeof n!=`number`)return;let r=e.state.doc.nodeAt(n);if(!r)return;let{from:a,to:o}=e.state.selection,s=n,c=a<n+r.nodeSize&&o>s;i(e=>e===c?e:c)};return n(),e.on(`selectionUpdate`,n),()=>{e.isDestroyed||e.off(`selectionUpdate`,n)}},o=[e,t],n[0]=e,n[1]=t,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Q.useEffect)(a,o),r}function eK(e){let t=(0,Z.c)(174),{node:n,updateAttributes:r,editor:a,getPos:s,selected:c}=e,{_:l}=i(),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),m=(0,Q.useRef)(null),h=(0,Q.useRef)(null),g=(0,Q.useRef)(null),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(null),{resolvedTheme:x}=Re(),S;t[0]===x?S=t[1]:(S=x===`dark`||x===`light`?x:QG(),t[0]=x,t[1]=S);let C=S,[w]=(0,Q.useState)(QG),T=n.attrs.language??null,E=n.attrs.meta??null,D;t[2]===E?D=t[3]:(D=IG(E),t[2]=E,t[3]=D);let O=D,[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),N=(0,Q.useId)(),P=`${N}-title-input`,F=`${N}-title-help`,I=(0,Q.useRef)(E),L,R;t[4]===E?(L=t[5],R=t[6]):(L=()=>{I.current=E},R=[E],t[4]=E,t[5]=L,t[6]=R),(0,Q.useEffect)(L,R);let z,B,ee,V,te;if(t[7]!==l||t[8]!==T||t[9]!==E){B=yG(T),z=T?_G.find(e=>e.value===B)?.label??T:l({id:`LpB85N`});let e;t[15]===E?e=t[16]:(e=CG(E,`preview`),t[15]=E,t[16]=e),V=e,ee=B?EG.has(B):!1,te=DG(B,E),t[7]=l,t[8]=T,t[9]=E,t[10]=z,t[11]=B,t[12]=ee,t[13]=V,t[14]=te}else z=t[10],B=t[11],ee=t[12],V=t[13],te=t[14];let H=te,U;t[17]!==H||t[18]!==E?(U=H?MG(E):null,t[17]=H,t[18]=E,t[19]=U):U=t[19];let ne=U,W;t[20]!==H||t[21]!==E?(W=H?NG(E):null,t[20]=H,t[21]=E,t[22]=W):W=t[22];let re=W,G=ne??(_===null?void 0:`${_}px`),ie=!H,ae,oe;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>()=>{m.current!==null&&window.clearTimeout(m.current)},oe=[],t[23]=ae,t[24]=oe):(ae=t[23],oe=t[24]),(0,Q.useEffect)(ae,oe);let K=a.isEditable,se=$G(a,s),ce,q;t[25]===C?(ce=t[26],q=t[27]):(ce=()=>{g.current?.contentWindow?.postMessage(BG(C),`*`)},q=[C],t[25]=C,t[26]=ce,t[27]=q),(0,Q.useEffect)(ce,q);let le,ue;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>{let e=function(e){if(e.source!==g.current?.contentWindow)return;let t=HG(e.data);if(t!==null){v(e=>e!==null&&Math.abs(e-t)<=2?e:t);return}let n=WG(e.data);n!==null&&b(n)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},ue=[],t[28]=le,t[29]=ue):(le=t[28],ue=t[29]),(0,Q.useEffect)(le,ue);let de;t[30]===n.textContent?de=t[31]:(de=()=>{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,iK)}catch{}},t[30]=n.textContent,t[31]=de);let fe=de,pe;t[32]!==a||t[33]!==s?(pe=()=>{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]=pe):pe=t[34];let me=pe,he;t[35]!==V||t[36]!==E||t[37]!==r?(he=()=>{r({meta:V?TG(E,`preview`):wG(E,`preview`)})},t[35]=V,t[36]=E,t[37]=r,t[38]=he):he=t[38];let ge=he,_e;t[39]!==E||t[40]!==r?(_e=e=>{let t=LG(E,e.length>0?e:null);t!==E&&r({meta:t})},t[39]=E,t[40]=r,t[41]=_e):_e=t[41];let ve=_e,ye;t[42]!==a.state||t[43]!==a.view||t[44]!==s||t[45]!==n.attrs||t[46]!==n.nodeSize||t[47]!==n.type?(ye=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]=ye):ye=t[48];let be=ye,xe;t[49]===r?xe=t[50]:(xe=e=>{let t=`${Math.round(e.width)}px`,n=`${Math.round(e.height)}px`;r({meta:jG(jG(I.current,`h`,n),`w`,t)})},t[49]=r,t[50]=xe);let Se=xe,Ce=T??void 0,we=se?`true`:void 0,Te=c?`true`:void 0,Ee=H?`true`:void 0,De=ie?`true`:`false`,Oe;t[51]!==l||t[52]!==C||t[53]!==w||t[54]!==ie||t[55]!==G||t[56]!==Se||t[57]!==n.textContent||t[58]!==H||t[59]!==re?(Oe=H?(0,X.jsxs)(`div`,{ref:h,className:Ut(`ok-codeblock-preview`,ie?`ok-codeblock-preview--with-code`:`ok-codeblock-preview--solo`),contentEditable:!1,style:{...G?{height:G}:{},...re?{width:re}:{}},onMouseDown:rK,children:[(0,X.jsx)(`iframe`,{title:l({id:`G7cMuO`}),ref:g,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,srcDoc:XG(w)+n.textContent,className:`ok-codeblock-preview-frame`,onLoad:()=>{b(null),g.current?.contentWindow?.postMessage(BG(C),`*`)}}),(0,X.jsx)(qO,{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:Se})]}):null,t[51]=l,t[52]=C,t[53]=w,t[54]=ie,t[55]=G,t[56]=Se,t[57]=n.textContent,t[58]=H,t[59]=re,t[60]=Oe):Oe=t[60];let ke;t[61]!==y||t[62]!==H?(ke=H&&y?(0,X.jsx)(gG,{blocked:y.blocked,truncated:y.truncated,onDismiss:()=>b(null)}):null,t[61]=y,t[62]=H,t[63]=ke):ke=t[63];let Ae;t[64]===O?Ae=t[65]:(Ae=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[64]=O,t[65]=Ae);let je=H&&ie?`rounded-b-lg`:null,Me=H?null:`rounded-lg`,Ne;t[66]!==je||t[67]!==Me?(Ne=Ut(`ok-codeblock-pre m-0 overflow-x-auto px-5 py-4 font-mono text-sm leading-relaxed`,je,Me),t[66]=je,t[67]=Me,t[68]=Ne):Ne=t[68];let Pe=!ie||void 0,Fe=T?`language-${T}`:void 0,Ie;t[69]===Fe?Ie=t[70]:(Ie=Ut(`hljs block whitespace-pre bg-transparent p-0`,Fe),t[69]=Fe,t[70]=Ie);let Le;t[71]===Ie?Le=t[72]:(Le=(0,X.jsx)(Al,{as:`code`,className:Ie}),t[71]=Ie,t[72]=Le);let ze;t[73]!==Ne||t[74]!==Pe||t[75]!==Le?(ze=(0,X.jsx)(`pre`,{className:Ne,"aria-hidden":Pe,children:Le}),t[73]=Ne,t[74]=Pe,t[75]=Le,t[76]=ze):ze=t[76];let Be;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(Be={[JP]:`true`},t[77]=Be):Be=t[77];let Ve=!K,He;t[78]!==l||t[79]!==z?(He=l({id:`c5f7sm`,values:{currentLabel:z}}),t[78]=l,t[79]=z,t[80]=He):He=t[80];let Ue;t[81]===z?Ue=t[82]:(Ue=(0,X.jsx)(`span`,{children:z}),t[81]=z,t[82]=Ue);let We;t[83]===K?We=t[84]:(We=K?(0,X.jsx)(wi,{className:`size-3 opacity-60`,"aria-hidden":`true`}):null,t[83]=K,t[84]=We);let Ge;t[85]!==Ve||t[86]!==He||t[87]!==Ue||t[88]!==We?(Ge=(0,X.jsx)(ic,{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[85]=Ve,t[86]=He,t[87]=Ue,t[88]=We,t[89]=Ge):Ge=t[89];let Ke;t[90]===l?Ke=t[91]:(Ke=l({id:`G_mWXb`}),t[90]=l,t[91]=Ke);let qe;t[92]===Ke?qe=t[93]:(qe=(0,X.jsx)(Gb,{placeholder:Ke}),t[92]=Ke,t[93]=qe);let Je;t[94]===l?Je=t[95]:(Je=l({id:`ETyvvg`}),t[94]=l,t[95]=Je);let Ye;t[96]===Je?Ye=t[97]:(Ye=(0,X.jsx)(qb,{children:Je}),t[96]=Je,t[97]=Ye);let Xe;t[98]!==a.commands||t[99]!==B||t[100]!==T||t[101]!==r?(Xe=_G.map(e=>{let t=e.value===ZG?!T||B===ZG:B===e.value;return(0,X.jsxs)(Yb,{value:`${e.label} ${e.value} ${e.aliases?.join(` `)??``}`,onSelect:()=>{r({language:e.value===ZG?null:e.value}),d(!1),a.commands.focus()},children:[(0,X.jsx)(`span`,{className:`flex-1`,children:e.label}),t?(0,X.jsx)(fn,{className:`size-3.5`,"aria-hidden":`true`}):null]},e.value)}),t[98]=a.commands,t[99]=B,t[100]=T,t[101]=r,t[102]=Xe):Xe=t[102];let Ze;t[103]===Xe?Ze=t[104]:(Ze=(0,X.jsx)(Jb,{children:Xe}),t[103]=Xe,t[104]=Ze);let Qe;t[105]!==Ye||t[106]!==Ze?(Qe=(0,X.jsxs)(Kb,{children:[Ye,Ze]}),t[105]=Ye,t[106]=Ze,t[107]=Qe):Qe=t[107];let $e;t[108]!==qe||t[109]!==Qe?($e=(0,X.jsx)(ac,{align:`end`,sideOffset:6,className:`w-56 p-0`,children:(0,X.jsxs)(Ub,{filter:tK,children:[qe,Qe]})}),t[108]=qe,t[109]=Qe,t[110]=$e):$e=t[110];let et;t[111]!==u||t[112]!==Ge||t[113]!==$e?(et=(0,X.jsxs)(rc,{open:u,onOpenChange:d,children:[Ge,$e]}),t[111]=u,t[112]=Ge,t[113]=$e,t[114]=et):et=t[114];let tt;t[115]!==l||t[116]!==K||t[117]!==H?(tt=K&&H?(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)(pa,{className:`size-3.5`,"aria-hidden":`true`})}):null,t[115]=l,t[116]=K,t[117]=H,t[118]=tt):tt=t[118];let nt;t[119]!==l||t[120]!==K||t[121]!==ge||t[122]!==ee||t[123]!==V?(nt=K&&ee?(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"data-active":V?`true`:void 0,"aria-pressed":V,"aria-label":l(V?{id:`xHGM4U`}:{id:`7OwvEL`}),onClick:ge,children:V?(0,X.jsx)(Ii,{className:`size-3.5`}):(0,X.jsx)(Li,{className:`size-3.5`})}):null,t[119]=l,t[120]=K,t[121]=ge,t[122]=ee,t[123]=V,t[124]=nt):nt=t[124];let rt;t[125]!==l||t[126]!==K||t[127]!==ve||t[128]!==k||t[129]!==O||t[130]!==F||t[131]!==P?(rt=K?(0,X.jsxs)(rc,{open:k,onOpenChange:A,children:[(0,X.jsx)(ic,{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)(_a,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,X.jsx)(ac,{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)(mn,{id:P,type:`text`,value:O??``,placeholder:l({id:`mk2poV`}),"data-testid":`ok-codeblock-title-input`,"aria-describedby":F,onChange:e=>ve(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[125]=l,t[126]=K,t[127]=ve,t[128]=k,t[129]=O,t[130]=F,t[131]=P,t[132]=rt):rt=t[132];let it;t[133]!==l||t[134]!==f?(it=l(f?{id:`6V3Ea3`}:{id:`NmPNJJ`}),t[133]=l,t[134]=f,t[135]=it):it=t[135];let at;t[136]===f?at=t[137]:(at=f?(0,X.jsx)(fn,{className:`size-3.5`,"aria-hidden":`true`}):(0,X.jsx)(Ni,{className:`size-3.5`,"aria-hidden":`true`}),t[136]=f,t[137]=at);let ot;t[138]!==fe||t[139]!==it||t[140]!==at?(ot=(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"aria-label":it,onClick:fe,children:at}),t[138]=fe,t[139]=it,t[140]=at,t[141]=ot):ot=t[141];let st;t[142]!==l||t[143]!==K||t[144]!==me?(st=K?(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn ok-codeblock-chrome-btn--delete`,"aria-label":l({id:`oBXkm2`}),onClick:me,children:(0,X.jsx)(Ta,{className:`size-3.5`,"aria-hidden":`true`})}):null,t[142]=l,t[143]=K,t[144]=me,t[145]=st):st=t[145];let ct;t[146]!==et||t[147]!==tt||t[148]!==nt||t[149]!==rt||t[150]!==ot||t[151]!==st?(ct=(0,X.jsxs)(`div`,{className:`ok-codeblock-chrome`,contentEditable:!1,onMouseDown:nK,...Be,children:[et,tt,nt,rt,ot,st]}),t[146]=et,t[147]=tt,t[148]=nt,t[149]=rt,t[150]=ot,t[151]=st,t[152]=ct):ct=t[152];let lt;t[153]!==l||t[154]!==w||t[155]!==j||t[156]!==K||t[157]!==be||t[158]!==n.textContent||t[159]!==B||t[160]!==H?(lt=K&&H?(0,X.jsx)(mG,{open:j,onOpenChange:M,initialValue:n.textContent,language:B===`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:XG(w)+e}),onSave:be}):null,t[153]=l,t[154]=w,t[155]=j,t[156]=K,t[157]=be,t[158]=n.textContent,t[159]=B,t[160]=H,t[161]=lt):lt=t[161];let ut;return t[162]!==Ce||t[163]!==we||t[164]!==Te||t[165]!==Ee||t[166]!==De||t[167]!==Oe||t[168]!==ke||t[169]!==Ae||t[170]!==ze||t[171]!==ct||t[172]!==lt?(ut=(0,X.jsxs)(jl,{className:`ok-codeblock relative my-3`,"data-language":Ce,"data-cursor-inside":we,"data-selected":Te,"data-preview":Ee,"data-code-visible":De,children:[Oe,ke,Ae,ze,ct,lt]}),t[162]=Ce,t[163]=we,t[164]=Te,t[165]=Ee,t[166]=De,t[167]=Oe,t[168]=ke,t[169]=Ae,t[170]=ze,t[171]=ct,t[172]=lt,t[173]=ut):ut=t[173],ut}function tK(e,t){return t?+!!e.toLowerCase().includes(t.toLowerCase()):1}function nK(e){return e.stopPropagation()}function rK(e){return e.stopPropagation()}function iK(){}function aK(e,t=[]){return e.flatMap(e=>{if(e.type===`text`)return[{text:e.value,classes:t}];let n=[...t,...e.properties?.className??[]];return aK(e.children,n)})}function oK(e){let{doc:t,name:n,lowlight:r,defaultLanguage:i}=e,a=[],o=r.listLanguages();return Xe(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 aK(c)){let n=t+e.text.length;e.classes.length>0&&a.push(O.inline(t,n,{class:e.classes.join(` `)})),t=n}}),q.create(t,a)}function sK(e){let{name:t,lowlight:n,defaultLanguage:r}=e,i=new pt({key:new N(`codeBlockLowlight`),state:{init:(e,{doc:i})=>oK({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=Xe(a.doc,e=>e.type.name===t),u=Xe(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)})?oK({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 cK=zP(FP),lK=re.extend({addNodeView(){return zl(eK)},addProseMirrorPlugins(){return[...this.parent?.()??[],sK({name:this.name,lowlight:cK,defaultLanguage:null})]},addInputRules(){return[...this.parent?.()??[],fe({find:/^```$/,type:this.type,getAttributes:()=>({language:`js`})})]}});function uK(e){return!!e.getMeta(Tv)}function dK(e,t){let n=Tv.getState(e);return py(n.doc,n.type,t,n.binding.mapping)||0}function fK(e,t){let n=Tv.getState(e);return dy(t,n.type,n.binding.mapping)}var pK=class e extends oe{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 mK(e,t){return new pK(e,fK(t,e))}function hK(e,t,n){let r=e instanceof pK?e.yRelativePosition:null;if(uK(t)&&r)return{position:new pK(dK(n,r),r),mapResult:null};let i=te(e,t),a=i.position.position;return{position:new pK(a,r??fK(n,a)),mapResult:i.mapResult}}var gK=kt.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)=>hK(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>mK(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Ev.getState(t).undoManager.undoStack.length===0?!1:n?xy(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Ev.getState(t).undoManager.redoStack.length===0?!1:n?Sy(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=Ty(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{let{undoManager:t}=Ev.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()}}},[Pv(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,this.editor.options.enableContentCheck&&new pt({key:new N(`filterInvalidContent`),filterTransaction:t=>{if(!uK(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 _K(e){if(!e.length)return q.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(O.node(n,n+r.nodeSize,{class:`ProseMirror-selectednoderange`}))}),q.create(n,t)}function vK(e,t,n){let r=n.isText||n.isAtom?0:1;return{start:e+r,end:e+t-r}}function yK(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 bt(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=vK(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 ve(a.resolve(l),a.resolve(u));i.push(p)}),i}var bK=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 xK(e.resolve(this.anchor),e.resolve(this.head))}},xK=class e extends be{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=yK(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 bK(this.anchor,this.head)}};xK.prototype.visible=!1;function SK(e){return e instanceof xK}kt.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(!SK(a)){let e=xK.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(!SK(a)){let e=xK.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=xK.create(i,0,i.content.size,t);return a.setSelection(o),n.dispatch(a),!0}}},onSelectionUpdate(){let{selection:e}=this.editor.state;SK(e)&&this.editor.view.dom.classList.add(`ProseMirror-noderangeselection`)},addProseMirrorPlugins(){let e=!1,t=!1;return[new pt({key:new N(`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=xK.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=SK(r);if(e=!1,!t)return i?(e=!0,_K(r.ranges)):null;let{$from:a,$to:o}=r;if(!i&&a.sameParent(o))return null;let s=yK(a,o,this.options.depth);return s.length?(e=!0,_K(s)):null}}})]}});function CK(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 wK(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=CK(e)}),t}var TK=[{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}],EK={edges:[`left`,`top`],threshold:12,strength:500};function DK(e){return e===void 0||e===`left`?{...EK}: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}:{...EK,...e}}function OK(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 kK(e,t,n,r){return!t||n.edges.length===0?0:OK(e,t,n)?n.strength*r:0}var AK=1e3;function jK(e,t,n,r){let i=AK,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-=kK(r,o,n,e.depth),i<=0?-1:i}function MK(e,t,n){return Array.from({length:t},(e,n)=>t-1-n).some(t=>n.includes(e.node(t).type.name))}function NK(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(...TK),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&&!MK(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=jK({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=MK(a,l,n.allowedContainers)),p){let r=jK({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 PK(e,t){let n=e;for(;n?.parentElement&&n.parentElement!==t.dom;)n=n.parentElement;return n?.parentElement===t.dom?n:void 0}function FK(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 IK(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(!FK(s)||!FK(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 LK=e=>{let{x:t,y:n,editor:r,nestedOptions:i}=e,{view:a,state:o}=r,s=IK(a,t,n,5);if(!s)return{resultElement:null,resultNode:null,pos:null};let{x:c,y:l}=s;if(i?.enabled){let e=NK(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=PK(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 RK(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 zK(e){var t;(t=e.parentNode)==null||t.removeChild(e)}function BK(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=LK({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 yK(i.resolve(a.pos),i.resolve(a.pos+a.resultNode.nodeSize+o),0,{extendOnBoundaryOverlap:!1})}function VK(e,t,n,r){let{view:i}=t;if(!e.dataTransfer)return;let{empty:a,$from:o,$to:s}=i.state.selection,c=BK(e,t,n,r),l=yK(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`,RK(i,m));let g=n?.enabled&&r?.node,_,v;g?(_=i.state.doc.slice(m,h),v=I.create(i.state.doc,m)):(v=xK.create(i.state.doc,m,h),_=v.content()),d.forEach(e=>{let t=wK(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,zK(p),document.removeEventListener(`drop`,T),document.removeEventListener(`dragend`,T))},E=v instanceof I?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 HK=(e,t)=>{let n=e.resolve(t),{depth:r}=n;return r===0?t:n.pos-n.parentOffset-1},UK=(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},WK=(e,t)=>{let n=Tv.getState(e);return n?dy(t,n.type,n.binding.mapping):null},GK=(e,t)=>{let n=Tv.getState(e);return n?py(n.doc,n.type,t,n.binding.mapping)||0:-1},KK=(e,t)=>{let n=t;for(;n?.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n},qK=new N(`dragHandle`),JK=({pluginKey:e=qK,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){fr(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),VK(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(S()){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 pt({key:typeof e==`string`?new N(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(uK(e)){let e=GK(o,p);e!==f&&(f=e)}else{let t=e.mapping.map(f);t!==f&&(f=t,p=WK(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=KK(e,o),o===e.dom||o?.nodeType!==1)return;let s=e.posAtDOM(o,0),c=UK(n.state.doc,s),l=HK(n.state.doc,s);d=c,f=l,p=WK(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&&zK(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=LK({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=KK(e,o),o===e.dom||o?.nodeType!==1)return;let t=e.posAtDOM(o,0);s=UK(n.state.doc,t),l=HK(n.state.doc,t)}s!==d&&(d=s,f=l??-1,p=WK(e.state,f),a?.({editor:n,node:d,pos:f}),v(o),_())})),!1}}}})}};function YK(e){return e===!1||e===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:DK(`none`)}:e===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:DK(`left`)}:{enabled:!0,rules:e.rules??[],defaultRules:e.defaultRules??!0,allowedContainers:e.allowedContainers,edgeDetection:DK(e.edgeDetection)}}var XK={placement:`left-start`,strategy:`absolute`};kt.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=YK(this.options.nested);return[JK({computePositionConfig:{...XK,...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 ZK=20,QK=44,$K=28;function eq(e){if(!e)return`Select block`;if(e.type.name===`jsxComponent`){let t=e.attrs.componentName??``;if(t){let e=Gj(t),n=e.name===`*`?t:e.displayName??e.name;if(n)return`Select ${n}`}}return`Select ${e.type.name}`}function tq(){let e=document.createElement(`div`);e.className=`ok-block-controls`,e.setAttribute(JP,`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 nq(e,t,n){let{state:r,view:i}=e;if(n.type.name===`jsxComponent`){let i=n.attrs.componentName??``;if(i){let a=Gj(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,Zj(o)).run(),tM(e,i,Gj(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=Ce.near(o.doc.resolve(a+1));o.setSelection(c).scrollIntoView(),i.dispatch(o),i.focus(),e.commands.insertContent(`/`)}var rq=kt.create({name:`blockDragHandle`,addProseMirrorPlugins(){let e=this.editor,t=null,n=-1,{container:r,addBtn:i,grip:a}=tq();return i.addEventListener(`click`,()=>{t&&n>=0&&nq(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()||(Mt(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;Mt(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)}))}}),[JK({element:r,editor:e,onNodeChange({node:e,pos:r}){t=e,n=r??-1,a.setAttribute(`aria-label`,eq(e))},computePositionConfig:{placement:`left-start`,strategy:`absolute`,middleware:[nr(({rects:e})=>({mainAxis:10,crossAxis:((e.reference.height<=QK?e.reference.height:$K)-ZK)/2}))]},nestedOptions:YK(!1)}).plugin]}}),iq=/^#fn(?:ref)?-/,aq=kt.create({name:`footnoteAnchorScroll`,addProseMirrorPlugins(){return[new pt({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(!iq.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}}}})]}}),oq=kt.create({name:`formattingShortcuts`,addKeyboardShortcuts(){return{"Mod-Shift-x":()=>this.editor.commands.toggleStrike()}}}),sq=kt.create({name:`headingAnchors`,addProseMirrorPlugins(){return[new pt({props:{decorations(e){let t=[],n=new Map;return e.doc.descendants((e,r)=>{if(e.type.name===`heading`){let i=He(e.textContent,n);if(!i)return;t.push(O.node(r,r+e.nodeSize,{id:i}))}}),q.create(e.doc,t)}}})]}});function cq(e){let t=(0,Z.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?PD(r)??void 0:void 0;s=typeof i==`string`?et(M(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)(jl,{as:`span`,"data-image-inline-zoom":!0,"data-clipboard-inline-leaf":`image`,children:(0,X.jsx)(jk,{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 lq=C.extend({addNodeView(){return zl(cq)}});function uq(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=gt(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=k(n.getAttribute(`href`)??``,t);if(e?.kind===`asset`){let n=gt(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=k(e,t);if(n?.kind===`asset`){let e=gt(n.url,t);return e?{kind:`image`,relPath:e,title:e.split(`/`).pop()??n.url}:null}}}n=n.parentElement}return null}var dq=new N(`asset-context-menu`);function fq(e){return new pt({key:dq,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=uq(t.target,e.sourceDocName);r&&(t.preventDefault(),n(r))};return t.dom.addEventListener(`contextmenu`,r),{destroy(){t.dom.removeEventListener(`contextmenu`,r)}}}})}var pq=e=>{let t=(0,Z.c)(18),{kind:n,ariaLabel:r,onDeactivate:i,children:a,triggerReference:o,layout:s,className:c,"data-slot":l}=e,u=s===void 0?`standard`:s,d=(0,Q.useRef)(null),f,p;t[0]===o?(f=t[1],p=t[2]):(f=()=>{let e=d.current;if(e)return or(o,e,()=>{let t=o.getBoundingClientRect();e.isConnected&&(e.style.left=`${t.left}px`,e.style.top=`${t.top}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`)})},p=[o],t[0]=o,t[1]=f,t[2]=p),(0,Q.useLayoutEffect)(f,p);let m;t[3]===i?m=t[4]:(m=e=>{e||i()},t[3]=i,t[4]=m);let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.jsx)(oc,{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?(_=Ut(`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)(ac,{side:`bottom`,align:`start`,sideOffset:8,collisionPadding:8,"aria-label":r,"data-ok-prop-panel":n,"data-slot":l,onOpenAutoFocus:mq,onCloseAutoFocus:hq,onPointerDownOutside:gq,onFocusOutside:_q,onInteractOutside:vq,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)(rc,{open:!0,onOpenChange:m,children:[h,v]}),t[15]=m,t[16]=v,t[17]=y):y=t[17],y};function mq(e){return e.preventDefault()}function hq(e){return e.preventDefault()}function gq(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function _q(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function vq(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function yq(e){let t=e.trim();return/\.(md|mdx)$/i.test(t)?t:`${t}.md`}function bq(e){let t=e.initialDir.trim().replace(/^\/+|\/+$/g,``),n=yq(e.suggestedName);return t?`${t}/${n}`:n}async function xq(e){let t=await Zb(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:Qb(Dt,t.body,`create-page`,{docName:n}).docName}}async function Sq(e){return xq(bq(e))}async function Cq(e,t){let{docName:n}=await Sq(e);return t.addPage(n),Nn([`files`,`backlinks`,`graph`]),t.onCreated?.(n),{docName:n}}var wq=8;function Tq(e){return e.trim().replace(/^\/+/,``).replace(/\.mdx?$/i,``).replace(/\/+$/g,``)}function Eq(e){return Dq(e)?Tq(e.slice(1)).toLowerCase():null}function Dq(e){return e.startsWith(`/`)&&!e.startsWith(`//`)}function Oq(e){return e.split(`/`).at(-1)??e}function kq(e,t){if(!t)return 0;let n=e.toLowerCase(),r=Oq(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 Aq(e){switch(e){case`page`:return 0;case`folder`:return 1;case`asset`:return 2}}function jq(e){let t=[],n=new Set;function r(e,r){let i=Tq(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 Mq(e){let t=Eq(e.value);if(t===null)return[];let n=[];for(let r of jq(e)){let e=kq(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=Aq(e.suggestion.kind)-Aq(t.suggestion.kind);return n===0?e.suggestion.path.localeCompare(t.suggestion.path):n}),n.slice(0,e.limit??wq).map(e=>e.suggestion)}var Nq=`[data-ok-link-path-suggestion-panel]`;function Pq(e){return e instanceof Element&&e.closest(Nq)!==null}function Fq(e){Pq(e.target)&&e.preventDefault()}function Iq(e){switch(e){case`page`:return(0,X.jsx)(zi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`});case`folder`:return(0,X.jsx)(Wi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`});case`asset`:return(0,X.jsx)(fa,{className:`size-3.5 shrink-0`,"aria-hidden":`true`})}}function Lq(e,t){if(e){if(typeof e==`function`){e(t);return}e.current=t}}function Rq(e){let t=(0,Z.c)(54),n,r,a,o,s,c,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],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14]):({value:g,pages:f,folderPaths:a,assetPaths:n,includeAssets:m,loading:h,onValueChange:d,onKeyDown:l,onSuggestionSelect:u,onFocus:c,onBlur:s,className:r,ref:p,...o}=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,t[13]=h,t[14]=g);let _=m===void 0?!1:m,v=h===void 0?!1:h,{_:y}=i(),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(0),E=(0,Q.useRef)(null),D=(0,Q.useRef)(null),O=(0,Q.useId)(),k;t[15]===g?k=t[16]:(k=g.trim(),t[15]=g,t[16]=k);let A=k===``,j=Mq({value:A?`/`:g,pages:f,folderPaths:a,assetPaths:n,includeAssets:_}),M=j.map(Uq).join(`\0`),N;t[17]===g?N=t[18]:(N=Dq(g),t[17]=g,t[18]=N);let P=A||N,F=j.length>0,I=b&&!S&&P&&(F||v)||b&&!S&&P&&!v&&!F,L=Math.min(w,Math.max(j.length-1,0)),R=F?`${O}-option-${L}`:void 0,z;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>{T(0)},t[19]=z):z=t[19],(0,Q.useEffect)(z,[M]);let B,ee;t[20]!==R||t[21]!==I?(B=()=>{!I||!R||document.getElementById(R)?.scrollIntoView?.({block:`nearest`})},ee=[R,I],t[20]=R,t[21]=I,t[22]=B,t[23]=ee):(B=t[22],ee=t[23]),(0,Q.useEffect)(B,ee);let V,te;t[24]===I?(V=t[25],te=t[26]):(V=()=>{if(!I)return;let e=E.current,t=D.current;if(!e||!t)return;let n=e,r=t,i=function(){fr(n,r,{placement:`bottom-start`,strategy:`fixed`,middleware:[nr(4),lr({padding:8}),hr({padding:8}),_r({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=or(n,r,i);return i(),a},te=[I],t[24]=I,t[25]=V,t[26]=te),(0,Q.useLayoutEffect)(V,te);let H;t[27]===p?H=t[28]:(H=function(e){E.current=e,Lq(p,e)},t[27]=p,t[28]=H);let U=H,ne=function(e){u?u(e):d(e.path),C(!0),requestAnimationFrame(()=>E.current?.focus())},W=function(e){if(F){if(e.key===`ArrowDown`){e.preventDefault(),T(e=>Math.min(e+1,j.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),T(Hq);return}if(e.key===`Enter`){e.preventDefault();let t=j[L];t&&ne(t);return}if(e.key===`Escape`){e.preventDefault(),C(!0);return}}if(I&&e.key===`Escape`){e.preventDefault(),C(!0);return}l?.(e)},re;t[29]===y?re=t[30]:(re=function(e){switch(e){case`page`:return y({id:`6WdDG7`});case`folder`:return y({id:`kNqMMd`});case`asset`:return y({id:`bUUVED`})}},t[29]=y,t[30]=re);let G=re,ie=I?(0,X.jsx)(`div`,{ref:D,id:O,role:`listbox`,"aria-label":y({id:`mBltnd`}),"data-ok-layer-spawned":``,"data-ok-link-path-suggestion-panel":``,className:`fixed z-70 max-h-52 overflow-y-auto overscroll-y-contain rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md subtle-scrollbar pointer-events-auto`,onWheel:Vq,onTouchMove:Bq,children:F?j.map((e,t)=>{let n=t===L,r=G(e.kind);return(0,X.jsxs)(qt,{id:`${O}-option-${t}`,type:`button`,role:`option`,"aria-label":`/${e.path} ${r}`,"aria-selected":n,variant:`ghost`,className:Ut(`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:zq,onClick:()=>ne(e),children:[Iq(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:y(v?{id:`sxTdZI`}:{id:`_QwkMu`})})}):null,ae;t[31]===d?ae=t[32]:(ae=e=>{C(!1),d(e.target.value)},t[31]=d,t[32]=ae);let oe;t[33]===c?oe=t[34]:(oe=e=>{x(!0),c?.(e)},t[33]=c,t[34]=oe);let K;t[35]===s?K=t[36]:(K=e=>{x(!1),s?.(e)},t[35]=s,t[36]=K);let se=I?O:void 0,ce;t[37]!==R||t[38]!==r||t[39]!==W||t[40]!==o||t[41]!==U||t[42]!==I||t[43]!==ae||t[44]!==oe||t[45]!==K||t[46]!==se||t[47]!==g?(ce=(0,X.jsx)(mn,{...o,ref:U,value:g,onChange:ae,onFocus:oe,onBlur:K,onKeyDown:W,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":I,"aria-controls":se,"aria-activedescendant":R,autoComplete:`off`,className:r}),t[37]=R,t[38]=r,t[39]=W,t[40]=o,t[41]=U,t[42]=I,t[43]=ae,t[44]=oe,t[45]=K,t[46]=se,t[47]=g,t[48]=ce):ce=t[48];let q;t[49]===ie?q=t[50]:(q=ie&&(0,Ma.createPortal)(ie,document.body),t[49]=ie,t[50]=q);let le;return t[51]!==ce||t[52]!==q?(le=(0,X.jsxs)(`div`,{className:`relative`,children:[ce,q]}),t[51]=ce,t[52]=q,t[53]=le):le=t[53],le}function zq(e){return e.preventDefault()}function Bq(e){e.stopPropagation()}function Vq(e){e.stopPropagation()}function Hq(e){return Math.max(e-1,0)}function Uq(e){return`${e.kind}:${e.path}`}var Wq=1500;async function Gq(e){if(typeof navigator>`u`||!navigator.clipboard?.writeText)throw Error(`clipboard unavailable`);await navigator.clipboard.writeText(e)}function Kq(e){let t=(0,Z.c)(20),{copyContent:n,clipboardWrite:r,initialCopied:a}=e,o=r===void 0?Gq:r,s=a===void 0?!1:a,{_:c}=i(),[l,u]=(0,Q.useState)(+!!s),d=l>0,f,p;t[0]===l?(f=t[1],p=t[2]):(f=()=>{if(l===0)return;let e=setTimeout(()=>u(0),Wq);return()=>clearTimeout(e)},p=[l],t[0]=l,t[1]=f,t[2]=p),(0,Q.useEffect)(f,p);let m;t[3]!==o||t[4]!==n?(m=()=>{Promise.resolve().then(()=>o(n)).then(()=>u(Jq),qq)},t[3]=o,t[4]=n,t[5]=m):m=t[5];let h=m,g;t[6]!==c||t[7]!==d?(g=c(d?{id:`PiH3UR`}:{id:`he3ygx`}),t[6]=c,t[7]=d,t[8]=g):g=t[8];let _=g,v;t[9]===d?v=t[10]:(v=d?(0,X.jsx)(fn,{className:`size-3.5`,"aria-hidden":`true`}):(0,X.jsx)(Ni,{className:`size-3.5`,"aria-hidden":`true`}),t[9]=d,t[10]=v);let y;t[11]!==h||t[12]!==_||t[13]!==v?(y=(0,X.jsx)(sr,{asChild:!0,children:(0,X.jsx)(qt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":_,onClick:h,children:v})}),t[11]=h,t[12]=_,t[13]=v,t[14]=y):y=t[14];let b;t[15]===_?b=t[16]:(b=(0,X.jsx)(ur,{children:_}),t[15]=_,t[16]=b);let x;return t[17]!==y||t[18]!==b?(x=(0,X.jsxs)(mr,{children:[y,b]}),t[17]=y,t[18]=b,t[19]=x):x=t[19],x}function qq(){}function Jq(e){return e+1}function Yq(e,t){return uO.getState(e)?.byId.get(t)??null}function Xq(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 Zq(e){let{editor:t,layer:n,markTypes:r,predicate:i,renderPropPanel:a,handlePrimary:o}=e,s=Xq({editor:t,layer:n,renderPropPanel:a,handlePrimary:o});return hO({markTypes:[...r],predicate:i,onRegister:s.onRegister,onDeregister:s.onDeregister})}function Qq(e){let t=kO(e.editor);return Zq({...e,layer:t})}function $q(e,t){let n=(0,Z.c)(4),[r,i]=(0,Q.useState)(null),a,o;return n[0]!==e||n[1]!==t?(a=()=>{if(!t||!e){i(null);return}let n=!1;return i(null),AW(e).then(e=>{n||i(e)}).catch(()=>{n||i([])}),()=>{n=!0}},o=[e,t],n[0]=e,n[1]=t,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Q.useEffect)(a,o),r}function eJ(e,t){let n=e.trim();return n?n.startsWith(`#`)?`anchor`:V(n)?`external`:`doc`:t}function tJ(e){return e?.kind===`doc`?`doc`:e?.kind===`anchor`?`anchor`:`external`}function nJ(e){let t=(0,Z.c)(84),{open:n,href:r,text:a,pages:s,folderPaths:c,loading:l,onOpenChange:u,onSave:d}=e,[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(`doc`),b=(0,Q.useId)(),x=(0,Q.useId)(),S=(0,Q.useId)(),C=(0,Q.useId)(),{_:w}=i(),T=(0,Q.useRef)(!1),E=(0,Q.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=HU(r);if(y(tJ(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,Q.useEffect)(D,O);let k,A,j;t[5]!==v||t[6]!==f||t[7]!==s?(k=An(f),A=v===`doc`,j=A&&qD(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=$q(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?$U(k,m.trim()||null):e,g,g.trim()!==E.current.trim()),u(!1))},t[11]=k,t[12]=A,t[13]=m,t[14]=g,t[15]=f,t[16]=u,t[17]=d,t[18]=P):P=t[18];let F=P,I;t[19]===F?I=t[20]:(I=function(e){e.key===`Enter`&&(e.preventDefault(),F())},t[19]=F,t[20]=I);let L=I,R;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(R=function(e){p(e.path),y(`doc`),h(``)},t[21]=R):R=t[21];let z=R,B;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,X.jsx)(Xt,{children:(0,X.jsx)(o,{id:`B11p-O`})}),t[22]=B):B=t[22];let ee;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,X.jsxs)(ln,{children:[B,(0,X.jsx)(Yt,{children:(0,X.jsx)(o,{id:`RobAKV`})})]}),t[23]=ee):ee=t[23];let V;t[24]===A?V=t[25]:(V=A?(0,X.jsx)(o,{id:`6WdDG7`}):(0,X.jsx)(o,{id:`6vEr3W`}),t[24]=A,t[25]=V);let te;t[26]!==V||t[27]!==b?(te=(0,X.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:b,children:V}),t[26]=V,t[27]=b,t[28]=te):te=t[28];let H;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>{p(e),y(t=>eJ(e,t))},t[29]=H):H=t[29];let U;t[30]===w?U=t[31]:(U=w({id:`Xl-UUg`}),t[30]=w,t[31]=U);let ne;t[32]!==f||t[33]!==c||t[34]!==L||t[35]!==l||t[36]!==s||t[37]!==U||t[38]!==b?(ne=(0,X.jsx)(Rq,{id:b,value:f,pages:s,folderPaths:c,loading:l,onValueChange:H,onSuggestionSelect:z,placeholder:U,autoFocus:!0,onKeyDown:L}),t[32]=f,t[33]=c,t[34]=L,t[35]=l,t[36]=s,t[37]=U,t[38]=b,t[39]=ne):ne=t[39];let W;t[40]!==te||t[41]!==ne?(W=(0,X.jsxs)(`div`,{children:[te,ne]}),t[40]=te,t[41]=ne,t[42]=W):W=t[42];let re;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,X.jsx)(o,{id:`QqBQu1`,components:{0:(0,X.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[43]=re):re=t[43];let G;t[44]===S?G=t[45]:(G=(0,X.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:S,children:re}),t[44]=S,t[45]=G);let ie;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>_(e.target.value),t[46]=ie):ie=t[46];let ae;t[47]===w?ae=t[48]:(ae=w({id:`yYR6za`}),t[47]=w,t[48]=ae);let oe;t[49]!==g||t[50]!==L||t[51]!==S||t[52]!==ae?(oe=(0,X.jsx)(mn,{id:S,value:g,onChange:ie,placeholder:ae,onKeyDown:L}),t[49]=g,t[50]=L,t[51]=S,t[52]=ae,t[53]=oe):oe=t[53];let K;t[54]!==G||t[55]!==oe?(K=(0,X.jsxs)(`div`,{children:[G,oe]}),t[54]=G,t[55]=oe,t[56]=K):K=t[56];let se;t[57]!==w||t[58]!==x||t[59]!==A||t[60]!==m||t[61]!==L||t[62]!==C||t[63]!==M||t[64]!==N?(se=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)(mn,{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:Ut(`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]=se):se=t[65];let ce;t[66]!==W||t[67]!==K||t[68]!==se?(ce=(0,X.jsxs)(an,{className:`space-y-6 pb-1`,children:[W,K,se]}),t[66]=W,t[67]=K,t[68]=se,t[69]=ce):ce=t[69];let q;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,X.jsx)(cn,{asChild:!0,children:(0,X.jsx)(qt,{variant:`outline`,children:(0,X.jsx)(o,{id:`dEgA5A`})})}),t[70]=q):q=t[70];let le;t[71]===f?le=t[72]:(le=f.trim(),t[71]=f,t[72]=le);let ue=!le,de;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,X.jsx)(o,{id:`tfDRzk`}),t[73]=de):de=t[73];let fe;t[74]!==F||t[75]!==ue?(fe=(0,X.jsxs)(on,{children:[q,(0,X.jsx)(qt,{onClick:F,disabled:ue,children:de})]}),t[74]=F,t[75]=ue,t[76]=fe):fe=t[76];let pe;t[77]!==ce||t[78]!==fe?(pe=(0,X.jsxs)(tn,{className:`sm:max-w-xl`,"data-ok-layer-spawned":``,onPointerDownOutside:Fq,onFocusOutside:Fq,onInteractOutside:Fq,children:[ee,ce,fe]}),t[77]=ce,t[78]=fe,t[79]=pe):pe=t[79];let me;return t[80]!==u||t[81]!==n||t[82]!==pe?(me=(0,X.jsx)(un,{open:n,onOpenChange:u,children:pe}),t[80]=u,t[81]=n,t[82]=pe,t[83]=me):me=t[83],me}function rJ(e){let t=(0,Z.c)(99),{editor:n,nodeId:r,sourceDocName:a,onClose:s,onNavigate:c}=e,l=Yq(n.state,r),u=l?.attrs?.href??``,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),h;t[0]!==r||t[1]!==f?(h=()=>{lO(r)&&f(!0)},t[0]=r,t[1]=f,t[2]=h):h=t[2];let g;t[3]===r?g=t[4]:(g=[r],t[3]=r,t[4]=g),(0,Q.useEffect)(h,g);let{addPage:_,folderPaths:v,pages:y,loading:b}=jn(),{_:x}=i();if(!l)return null;let S=n.state.doc.textBetween(l.from,l.to),C=u?k(u,a):null,w;t[5]!==n||t[6]!==r?(w=function(e,t,i){let a=Yq(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=Yq(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=Yq(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 A=(0,X.jsx)(nJ,{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:A});let j=C?.kind===`doc`?`${C.docName}${C.anchor?`#${C.anchor}`:``}`:C?.kind===`anchor`?`#${C.anchor}`:C?.kind===`external`?C.url:u,M=function(e){let t=Yq(n.state,r);t&&n.chain().setTextSelection({from:t.from,to:t.to}).extendMarkRange(`link`).updateAttributes(`link`,{href:$U(e,C?.kind===`doc`?C.anchor??null:null)}).run()},N,P=!1,F=!1,I=null;if(b){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(oa,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),t[17]=e):e=t[17],N={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)(Vi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[18]=e):e=t[18],N={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)(En,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[19]=e):e=t[19],N={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)(Vi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[20]=e):e=t[20],N={icon:e,text:x({id:`dprWmL`}),className:`text-muted-foreground`}}else if(C?.kind===`doc`){let e=AU(C.docName,{pages:y,folderPaths:v});if(F=e.kind===`navigate`&&e.displayState===`folder`,P=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)(Wi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[21]=e):e=t[21],N={icon:e,text:x({id:`kNqMMd`}),className:`text-muted-foreground`}}else if(P){let e;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ei,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[22]=e):e=t[22],N={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)(Vi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[23]=e):e=t[23],N={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)(Ei,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[24]=e):e=t[24],N={icon:e,text:x({id:`-g6KIS`}),className:`text-muted-foreground/80`}}let L=C?.kind===`external`,R=C?.kind===`doc`?UU({docName:C.docName,anchor:C.anchor}):C?.kind===`anchor`?UU({docName:a,anchor:C.anchor}):C?.kind===`external`&&BU(C.url)?C.url:null,z=!b&&R!==null&&(C?.kind===`anchor`||C?.kind===`external`||C?.kind===`doc`&&!P&&!F),B;t[25]!==n.state||t[26]!==n.view||t[27]!==r?(B=()=>{let e=Yq(n.state,r);if(!e)return new DOMRect;try{return zt(n.view,e.from,e.to)}catch{return new DOMRect}},t[25]=n.state,t[26]=n.view,t[27]=r,t[28]=B):B=t[28];let ee;t[29]!==n.view.dom||t[30]!==B?(ee={getBoundingClientRect:B,contextElement:n.view.dom},t[29]=n.view.dom,t[30]=B,t[31]=ee):ee=t[31];let V=ee,te;t[32]!==x||t[33]!==_||t[34]!==p||t[35]!==I||t[36]!==s||t[37]!==M?(te=async function(){if(!(!I||p)){m(!0);try{await Cq(I,{addPage:_,onCreated(e){M(e),window.location.hash=`#/${e}`,s()}}),m(!1)}catch(e){let t=e;zn.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]=M,t[38]=te):te=t[38];let H=te,U=Ut(`flex shrink-0`,N.className),ne;t[39]!==N.icon||t[40]!==U?(ne=(0,X.jsx)(`span`,{className:U,children:N.icon}),t[39]=N.icon,t[40]=U,t[41]=ne):ne=t[41];let W=ne,re;t[42]!==W||t[43]!==P||t[44]!==N.text?(re=P?(0,X.jsxs)(mr,{children:[(0,X.jsx)(sr,{asChild:!0,children:(0,X.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`internal-link-prop-panel-icon-trigger`,children:W})}),(0,X.jsx)(ur,{children:N.text})]}):W,t[42]=W,t[43]=P,t[44]=N.text,t[45]=re):re=t[45];let G=re,ie=`${N.text}: ${j}`,ae;t[46]!==j||t[47]!==L||t[48]!==P||t[49]!==R||t[50]!==z||t[51]!==s||t[52]!==c?(ae=(0,X.jsx)(sr,{asChild:!0,children:z?(0,X.jsx)(`a`,{href:R??void 0,...L?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>XU(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:j}):(0,X.jsx)(`span`,{"data-slot":`internal-link-prop-panel-text`,className:Ut(`block truncate text-sm font-medium`,P?`text-muted-foreground`:`text-foreground`),children:j})}),t[46]=j,t[47]=L,t[48]=P,t[49]=R,t[50]=z,t[51]=s,t[52]=c,t[53]=ae):ae=t[53];let oe;t[54]===j?oe=t[55]:(oe=(0,X.jsx)(ur,{className:`max-w-80 break-all`,children:j}),t[54]=j,t[55]=oe);let K;t[56]!==ae||t[57]!==oe?(K=(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(mr,{children:[ae,oe]})}),t[56]=ae,t[57]=oe,t[58]=K):K=t[58];let se;t[59]!==H||t[60]!==p||t[61]!==P?(se=P?(0,X.jsxs)(qt,{type:`button`,size:`sm`,variant:`link`,disabled:p,onClick:()=>void H(),"data-slot":`internal-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,X.jsx)(ma,{className:`size-3.5`,"aria-hidden":`true`}),p?(0,X.jsx)(o,{id:`HM56Bx`}):(0,X.jsx)(o,{id:`XRuL0i`})]}):null,t[59]=H,t[60]=p,t[61]=P,t[62]=se):se=t[62];let ce;t[63]===x?ce=t[64]:(ce=x({id:`ePK91l`}),t[63]=x,t[64]=ce);let q;t[65]===f?q=t[66]:(q=()=>f(!0),t[65]=f,t[66]=q);let le;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,X.jsx)(pa,{className:`size-3.5`,"aria-hidden":`true`}),t[67]=le):le=t[67];let ue;t[68]!==ce||t[69]!==q?(ue=(0,X.jsx)(sr,{asChild:!0,children:(0,X.jsx)(qt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":ce,onClick:q,"data-slot":`internal-link-prop-panel-edit`,children:le})}),t[68]=ce,t[69]=q,t[70]=ue):ue=t[70];let de;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,X.jsx)(ur,{children:(0,X.jsx)(o,{id:`ePK91l`})}),t[71]=de):de=t[71];let fe;t[72]===ue?fe=t[73]:(fe=(0,X.jsxs)(mr,{children:[ue,de]}),t[72]=ue,t[73]=fe);let pe;t[74]===u?pe=t[75]:(pe=(0,X.jsx)(Kq,{copyContent:u}),t[74]=u,t[75]=pe);let me;t[76]===x?me=t[77]:(me=x({id:`t_YqKh`}),t[76]=x,t[77]=me);let he;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,X.jsx)(Ta,{className:`size-3.5`,"aria-hidden":`true`}),t[78]=he):he=t[78];let ge;t[79]!==D||t[80]!==me?(ge=(0,X.jsx)(sr,{asChild:!0,children:(0,X.jsx)(qt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":me,onClick:D,"data-slot":`internal-link-prop-panel-remove`,children:he})}),t[79]=D,t[80]=me,t[81]=ge):ge=t[81];let _e;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,X.jsx)(ur,{children:(0,X.jsx)(o,{id:`t_YqKh`})}),t[82]=_e):_e=t[82];let ve;t[83]===ge?ve=t[84]:(ve=(0,X.jsxs)(mr,{children:[ge,_e]}),t[83]=ge,t[84]=ve);let ye;t[85]!==se||t[86]!==fe||t[87]!==pe||t[88]!==ve?(ye=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[se,fe,pe,ve]}),t[85]=se,t[86]=fe,t[87]=pe,t[88]=ve,t[89]=ye):ye=t[89];let be;t[90]!==G||t[91]!==K||t[92]!==ye?(be=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[G,K,ye]}),t[90]=G,t[91]=K,t[92]=ye,t[93]=be):be=t[93];let xe;return t[94]!==s||t[95]!==ie||t[96]!==be||t[97]!==V?(xe=(0,X.jsx)(pq,{kind:`internal-link`,ariaLabel:ie,onDeactivate:s,triggerReference:V,className:`w-96`,children:be}),t[94]=s,t[95]=ie,t[96]=be,t[97]=V,t[98]=xe):xe=t[98],(0,X.jsxs)(X.Fragment,{children:[A,xe]})}new N(`markIdentityDecoration`);var iJ=`data-mark-id`,aJ=new N(`linkResolutionDecoration`);function oJ(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={[iJ]:e.id};t!==null&&Object.assign(o,t),a.push(O.inline(e.from,e.to,o))}return a.length===0?null:q.create(e,a)}function sJ(e){let t=new Set(e.markTypes),{computeAttrs:n}=e;return new pt({key:aJ,state:{init:()=>({version:0}),apply(e,t){let n=e.getMeta(aJ);return n&&typeof n==`object`&&n.refresh?{version:t.version+1}:t}},props:{decorations(e){let r=uO.getState(e);if(!r)return null;let i=Ln();return oJ(e.doc,r.byId,t,n,i)}},view(e){$(`ok/render/decoration-merge`,{markTypes:Array.from(t).join(`,`)},{startTime:performance.now(),duration:0});let n=On(()=>{e.dispatch(e.state.tr.setMeta(aJ,{refresh:!0}))});return{destroy(){n()}}}})}var cJ=j.extend({addOptions(){return{...this.parent?.(),docName:``}},renderHTML({HTMLAttributes:e}){let t=typeof e.href==`string`?e.href:``;return[`span`,ne(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=Yq(t.state,n),a=i?.attrs?.href;if(typeof a!=`string`||!a)return!1;let o=i?.attrs?.sourceForm,s=k(a,e),c=$e(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=gt(t,e);if(!i)return!1;let o=Ln();return o===null||(o.assetPaths!==void 0||o.filePaths!==void 0)&&!MU(t,e,o.assetPaths,o.filePaths)?!1:(JU({url:t,projectRelPath:i,ext:n,title:i.split(`/`).pop()??t,newTab:r}),!0)}if(!s)return!1;switch(s.kind){case`doc`:{let e=Ln(),t=AU(s.docName,{pages:e?.pages??new Set,folderPaths:e?.folderPaths??new Set});return t.kind===`create`||t.kind===`navigate`&&t.displayState===`folder`?!1:(r?KU({docName:s.docName,anchor:s.anchor}):window.location.assign(UU({docName:s.docName,anchor:s.anchor})),!0)}case`anchor`:return r?KU({docName:e,anchor:s.anchor}):window.location.assign(UU({docName:e,anchor:s.anchor})),!0;case`external`:return BU(s.url)?(WU(s.url),!0):!1;default:return d(s)}};return[Qq({editor:this.editor,markTypes:[`link`],renderPropPanel:({editor:n,nodeId:r,deactivate:i})=>(0,Q.createElement)(rJ,{editor:n,nodeId:r,sourceDocName:e,onClose:i,onNavigate:e=>t({editor:n,nodeId:r,newTab:e})}),handlePrimary:t}),sJ({markTypes:[`link`],computeAttrs:FU(e)}),fq({sourceDocName:e})]}}),lJ=(0,Q.createContext)(null),uJ={didCatch:!1,error:null},dJ=class extends Q.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=uJ}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(uJ))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&fJ(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState(uJ))}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:a}=this.state,o=e;if(i){let e={error:a,resetErrorBoundary:this.resetErrorBoundary};if(typeof t==`function`)o=t(e);else if(n)o=(0,Q.createElement)(n,e);else if(r!==void 0)o=r;else throw a}return(0,Q.createElement)(lJ.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function fJ(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}function pJ(e){let t=(0,Z.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=Ut(`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:mJ,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 mJ(e){e.preventDefault(),e.stopPropagation()}function hJ(e){let t=(0,Z.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)(Os,{"data-slot":`select`,...n}),t[2]=n,t[3]=r),r}function gJ(e){let t=(0,Z.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)(As,{"data-slot":`select-value`,...n}),t[2]=n,t[3]=r),r}function _J(e){let t=(0,Z.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=Ut(`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)(js,{asChild:!0,children:(0,X.jsx)(wi,{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)(ks,{"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 vJ(e){let t=(0,Z.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=Ut(`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)(bJ,{}),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=Ut(`p-1`,u),t[9]=u,t[10]=d);let f;t[11]!==n||t[12]!==d?(f=(0,X.jsx)(Ps,{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)(xJ,{}),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)(Ms,{children:(0,X.jsxs)(Ns,{"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 yJ(e){let t=(0,Z.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=Ut(`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)(Ls,{children:(0,X.jsx)(fn,{className:`size-4`})})}),t[6]=o):o=t[6];let s;t[7]===n?s=t[8]:(s=(0,X.jsx)(Is,{children:n}),t[7]=n,t[8]=s);let c;return t[9]!==i||t[10]!==a||t[11]!==s?(c=(0,X.jsxs)(Fs,{"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 bJ(e){let t=(0,Z.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=Ut(`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)(Ti,{className:`size-4`}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,X.jsx)(Rs,{"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 xJ(e){let t=(0,Z.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=Ut(`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)(wi,{className:`size-4`}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,X.jsx)(zs,{"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 SJ(e){let t=(0,Z.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=Ut(`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)(Qs,{"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)(Zs,{"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 CJ(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 wJ(e){let t=(0,Z.c)(36),{id:n,value:r,onChange:i,autoFocus:a}=e,o=(0,Q.useRef)(null),s;t[0]===i?s=t[1]:(s=e=>i(e.target.value),t[0]=i,t[1]=s);let c=a?``:void 0,l=r?`pl-7`:void 0,u;t[2]===l?u=t[3]:(u=Ut(`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)(mn,{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)(qt,{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]:(_=CJ(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)(qt,{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)(Pi,{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 TJ(e){let t=(0,Z.c)(43),{id:n,value:r,onChange:i,autoFocus:a}=e,[o,s]=(0,Q.useState)(!1),c;t[0]===r?c=t[1]:(c=PO(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=Ut(`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)(mn,{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)(wi,{className:`size-3`,"aria-hidden":`true`}),t[20]=y):y=t[20];let b;t[21]===o?b=t[22]:(b=(0,X.jsx)(ic,{asChild:!0,children:(0,X.jsx)(qt,{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)(Gb,{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)(qb,{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)(Jb,{children:(0,X.jsxs)(Yb,{value:`__clear__`,onSelect:()=>{i(``),s(!1)},className:`gap-2 text-muted-foreground`,"data-icon-picker-clear":``,children:[(0,X.jsx)(Bn,{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=NO.map(e=>{let[t,n]=e,r=t===d;return(0,X.jsx)(Yb,{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:Ut(`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)(Jb,{heading:`Lucide`,children:(0,X.jsx)(jb.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)(ac,{align:`end`,className:`z-70 w-72 p-0`,onOpenAutoFocus:EJ,children:(0,X.jsxs)(Ub,{label:`Icon picker`,children:[x,(0,X.jsxs)(Kb,{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)(rc,{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 EJ(e){return e.preventDefault()}function DJ(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 OJ(e){if(e.length===1&&e[0]===`*/*`)return`all`;let t=new Set;for(let n of e){if(n===`*/*`)return`all`;let e=DJ(n);e&&t.add(e)}return t}function kJ(e){let t=e.lastIndexOf(`.`);return t<0||t<e.lastIndexOf(`/`)?``:e.slice(t+1).toLowerCase()}function AJ(e,t){let n=OJ(t),r=[];for(let t of e){if(n===`all`){r.push(t);continue}let e=w(kJ(t));e&&n.has(e)&&r.push(t)}return r}var jJ=8,MJ=new Set,NJ=null;function PJ(e){return{path:e,basename:e.split(`/`).pop()??e}}function FJ(e){let t=e.map(e=>e.path).join(``);return NJ?.fingerprint===t||(NJ={fingerprint:t,byPath:new Map(e.map(e=>[e.path,e])),itemsInOrder:e,corpus:ht(e.map(e=>Ue({kind:`page`,path:e.path,title:e.basename})))}),NJ}function IJ(e){let t=e.trim();return t.startsWith(`/`)?t.slice(1):t}function LJ(e,t){let n=IJ(t);return n?st(e.corpus,n,{intent:`autocomplete`,limit:jJ}).map(t=>e.byPath.get(t.document.path)).filter(e=>!!e):e.itemsInOrder.slice(0,jJ)}function RJ(e){let t=(0,Z.c)(52),{value:n,onChange:r,accept:i,id:a,placeholder:o,autoFocus:s,ariaInvalid:c,ariaDescribedBy:l,dataPropAutofocus:u,className:d,onSubmit:f}=e,p=Fn()?.assetPaths??MJ,m;t[0]!==i||t[1]!==p||t[2]!==n?(m=LJ(FJ(AJ(p,i).map(PJ)),n),t[0]=i,t[1]=p,t[2]=n,t[3]=m):m=t[3];let h=m,[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(0),b,x;t[4]!==v||t[5]!==h.length?(b=()=>{v>=h.length&&y(0)},x=[v,h.length],t[4]=v,t[5]=h.length,t[6]=b,t[7]=x):(b=t[6],x=t[7]),(0,Q.useEffect)(b,x);let S=(0,Q.useId)(),C=(0,Q.useRef)(null),w=g&&h.length>0,T;t[8]===r?T=t[9]:(T=e=>{r(`/${e.path}`),_(!1),y(0),C.current?.focus()},t[8]=r,t[9]=T);let E=T,D;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>_(e),t[10]=D):D=t[10];let O=w?S:void 0,k=w&&h[v]?`${S}-opt-${v}`:void 0,A;t[11]===r?A=t[12]:(A=e=>{r(e.target.value),_(!0),y(0)},t[11]=r,t[12]=A);let j,M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{_(!0)},j=()=>{_(!0)},t[13]=j,t[14]=M):(j=t[13],M=t[14]);let N;t[15]!==v||t[16]!==f||t[17]!==E||t[18]!==h||t[19]!==w?(N=e=>{if(e.key===`ArrowDown`){if(h.length===0)return;e.preventDefault(),_(!0),y(e=>(e+1)%h.length);return}if(e.key===`ArrowUp`){if(h.length===0)return;e.preventDefault(),_(!0),y(e=>(e-1+h.length)%h.length);return}if(e.key===`Enter`){if(w){let t=h[v];if(t){e.preventDefault(),E(t);return}}f&&(e.preventDefault(),f());return}if(e.key===`Escape`){if(!w)return;e.preventDefault(),e.stopPropagation(),_(!1);return}e.key===`Tab`&&_(!1)},t[15]=v,t[16]=f,t[17]=E,t[18]=h,t[19]=w,t[20]=N):N=t[20];let P;t[21]!==l||t[22]!==c||t[23]!==s||t[24]!==d||t[25]!==u||t[26]!==a||t[27]!==o||t[28]!==N||t[29]!==O||t[30]!==k||t[31]!==A||t[32]!==n||t[33]!==w?(P=(0,X.jsx)(oc,{asChild:!0,children:(0,X.jsx)(mn,{ref:C,id:a,type:`text`,value:n,placeholder:o,autoFocus:s,"data-prop-autofocus":u,"aria-invalid":c,"aria-describedby":l,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":w,"aria-controls":O,"aria-activedescendant":k,className:d,onChange:A,onFocus:M,onClick:j,onKeyDown:N})}),t[21]=l,t[22]=c,t[23]=s,t[24]=d,t[25]=u,t[26]=a,t[27]=o,t[28]=N,t[29]=O,t[30]=k,t[31]=A,t[32]=n,t[33]=w,t[34]=P):P=t[34];let F;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{let t=e.target;t instanceof Node&&C.current?.contains(t)&&e.preventDefault()},t[35]=F):F=t[35];let I;if(t[36]!==v||t[37]!==S||t[38]!==E||t[39]!==h){let e;t[41]!==v||t[42]!==S||t[43]!==E?(e=(e,t)=>{let n=`${S}-opt-${t}`,r=t===v;return(0,X.jsxs)(`button`,{id:n,type:`button`,role:`option`,"aria-selected":r,"data-testid":`src-autocomplete-option`,"data-highlighted":r?``:void 0,className:Ut(`flex w-full flex-col items-start gap-0.5 rounded-sm px-2 py-1 text-left text-xs`,`transition-colors`,r?`bg-accent text-accent-foreground`:`hover:bg-accent/50`),onMouseEnter:()=>y(t),onMouseDown:t=>{t.preventDefault(),E(e)},children:[(0,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[41]=v,t[42]=S,t[43]=E,t[44]=e):e=t[44],I=h.map(e),t[36]=v,t[37]=S,t[38]=E,t[39]=h,t[40]=I}else I=t[40];let L;t[45]!==S||t[46]!==I?(L=(0,X.jsx)(ac,{align:`start`,sideOffset:4,className:`z-70 w-(--radix-popover-trigger-width) p-1`,onOpenAutoFocus:BJ,onCloseAutoFocus:zJ,onInteractOutside:F,children:(0,X.jsx)(`div`,{id:S,role:`listbox`,"aria-label":`Asset suggestions`,className:`flex flex-col gap-px`,children:I})}),t[45]=S,t[46]=I,t[47]=L):L=t[47];let R;return t[48]!==P||t[49]!==L||t[50]!==w?(R=(0,X.jsxs)(rc,{open:w,onOpenChange:D,children:[P,L]}),t[48]=P,t[49]=L,t[50]=w,t[51]=R):R=t[51],R}function zJ(e){e.preventDefault()}function BJ(e){e.preventDefault()}function VJ(){if(typeof window>`u`)return null;let e=window.location.hash.match(/^#\/([^?#]+)/);return e?decodeURIComponent(e[1]):null}var HJ=`/api/upload`;async function UJ(e,t,n={}){let r=n.fetch??globalThis.fetch,i=n.docName===void 0?VJ():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(HJ,{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 JD(`Upload response is not JSON.`,{cause:e,status:o.status})}if(!o.ok){let e=De.safeParse(s);throw e.success?Error(e.data.title):new JD(`Upload error response did not match ProblemDetails.`,{cause:e.error,status:o.status})}let c=At.safeParse(s);if(!c.success)throw new JD(`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 WJ=new Intl.PluralRules(`en-US`);function GJ(e,t,n){return n<=0?`${e} (empty)`:`${e} with ${n} ${WJ.select(n)===`one`?`item`:`items`}`}function KJ(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 qJ(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 JJ=new Set([`auto`,`inherit`,`initial`,`unset`]),YJ=new Set([`px`,`%`,`rem`,`em`,`vh`,`vw`,`ch`,`ex`,`fr`]),XJ=/^(-?\d+(?:\.\d+)?)([a-z%]*)$/i;function ZJ(e){let t=e.trim();if(!t)return{valid:!1,reason:`empty`};if(JJ.has(t.toLowerCase()))return{valid:!0};let n=t.match(XJ);if(!n)return{valid:!1,reason:`malformed-syntax`};let r=(n[2]??``).toLowerCase();return r===``||YJ.has(r)?{valid:!0}:{valid:!1,reason:`unknown-unit`}}function QJ(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 $J={video:K,audio:Ee,image:se},eY={youtube:[`youtube.com`,`youtu.be`,`youtube-nocookie.com`],vimeo:[`vimeo.com`],loom:[`loom.com`]};function tY(e){let t=e.toLowerCase();for(let e of Object.keys(eY)){let n=eY[e];for(let r of n)if(t===r||t.endsWith(`.${r}`))return e}return null}function nY(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 rY=`https://placeholder.invalid`;function iY(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,rY),i=!1}catch{return{valid:!1,reason:`invalid-url`}}}if(t===`video`&&Fe(n)!==null||t===`video`&&de(n)||t===`video`&&A(n))return{valid:!0};let a=i?tY(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=nY(r.pathname),s=$J[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 aY(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 oY(e){return`Direct ${e} file URL — ${Array.from($J[e]).map(e=>`.${e}`).join(`, `)}`}var sY={youtube:`YouTube`,vimeo:`Vimeo`,loom:`Loom`};function cY(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=sY[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($J[t]).map(e=>`.${e}`).join(`, `);return e.extension===``?`Missing file extension. Accepts: ${n}.`:`Unsupported extension .${e.extension}. Accepts: ${n}.`}function lY(e){return`ok.propPanel.advanced.${e}`}function uY(e){try{return typeof localStorage>`u`?!1:localStorage.getItem(lY(e))===`true`}catch{return!1}}function dY(e,t){try{if(typeof localStorage>`u`)return;localStorage.setItem(lY(e),t?`true`:`false`)}catch{}}function fY(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 pY(e,t,n){try{let{url:r}=await UJ(e,t);n(r)}catch(e){let t=e instanceof Error?e.message:String(e);zn.error(Rn._({id:`02P3hL`,values:{message:t}}))}}function mY(e){let t=(0,Z.c)(14),{descriptor:n,values:r,onChange:i,onDismiss:a}=e,s;t[0]===r?s=t[1]:(s=e=>!(`hidden`in e&&e.hidden)&&e.hideWhen?.(r)!==!0&&e.type!==`reactnode`,t[0]=r,t[1]=s);let c=n.props.filter(s),l=c.filter(gY),u=c.filter(hY),d=fY(u,r),f;t[2]===n.props?f=t[3]:(f=KJ(n.props),t[2]=n.props,t[3]=f);let p=f,m;t[4]===n.name?m=t[5]:(m=()=>uY(n.name),t[4]=n.name,t[5]=m);let[h,g]=(0,Q.useState)(m);if(c.length===0)return null;let _;t[6]!==p||t[7]!==i||t[8]!==a||t[9]!==r?(_=e=>(0,X.jsx)(vY,{propDef:e,value:r[e.name],onChange:t=>i(e.name,t),onDismiss:a,isAutoFocused:e.name===p},e.name),t[6]=p,t[7]=i,t[8]=a,t[9]=r,t[10]=_):_=t[10];let v=l.map(_),y=u.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,X.jsxs)(vn,{open:h,onOpenChange:e=>{g(e),dY(n.name,e)},children:[(0,X.jsxs)(_n,{"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)(wi,{className:`size-3 transition-transform group-data-[state=closed]:-rotate-90`}),(0,X.jsx)(o,{id:`sxkWRg`})]}),d>0&&(0,X.jsx)(nc,{variant:`secondary`,"data-prop-panel-advanced-count":``,children:d})]}),(0,X.jsx)(hn,{className:`flex flex-col gap-4 pt-2`,children:u.map(e=>(0,X.jsx)(vY,{propDef:e,value:r[e.name],onChange:t=>i(e.name,t),onDismiss:a,isAutoFocused:e.name===p},e.name))})]})]}),b;return t[11]!==v||t[12]!==y?(b=(0,X.jsxs)(`div`,{"data-prop-panel":``,className:`flex flex-col gap-4 py-2 text-sm`,children:[v,y]}),t[11]=v,t[12]=y,t[13]=b):b=t[13],b}function hY(e){return`advanced`in e&&e.advanced}function gY(e){return!(`advanced`in e&&e.advanced)}function _Y(e){throw Error(`PropPanel: unhandled PropDef type ${JSON.stringify(e)}`)}function vY(e){let t=(0,Z.c)(165),{propDef:n,value:r,onChange:i,onDismiss:a,isAutoFocused:o}=e,s;t[0]===a?s=t[1]:(s=a?e=>{e.key===`Enter`&&(e.preventDefault(),a())}:void 0,t[0]=a,t[1]=s);let c=s;switch(n.type){case`reactnode`:return null;case`string`:{let e=`prop-${n.name}`,s=n.accept,l=s!==void 0&&s.length>0,u=!n.required&&n.defaultValue===void 0;if(n.language){let a=`${e}-label`,s;t[2]===n.name?s=t[3]:(s=qJ(n.name),t[2]=n.name,t[3]=s);let c;t[4]!==a||t[5]!==e||t[6]!==s?(c=(0,X.jsx)(`label`,{id:a,htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[4]=a,t[5]=e,t[6]=s,t[7]=c):c=t[7];let l=r??``,d;t[8]!==i||t[9]!==u?(d=e=>{if(e===``&&u){i(void 0);return}i(e)},t[8]=i,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==o||t[12]!==a||t[13]!==n.language||t[14]!==e||t[15]!==l||t[16]!==d?(f=(0,X.jsx)(fG,{id:e,ariaLabelledBy:a,value:l,language:n.language,onChange:d,autoFocus:o}),t[11]=o,t[12]=a,t[13]=n.language,t[14]=e,t[15]=l,t[16]=d,t[17]=f):f=t[17];let p;return t[18]!==c||t[19]!==f?(p=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,f]}),t[18]=c,t[19]=f,t[20]=p):p=t[20],p}if(n.iconPicker){let a=r??``,s;t[21]===n.name?s=t[22]:(s=qJ(n.name),t[21]=n.name,t[22]=s);let c;t[23]!==e||t[24]!==s?(c=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[23]=e,t[24]=s,t[25]=c):c=t[25];let l;t[26]!==i||t[27]!==u?(l=e=>{if(e===``&&u){i(void 0);return}i(e)},t[26]=i,t[27]=u,t[28]=l):l=t[28];let d;t[29]!==a||t[30]!==o||t[31]!==e||t[32]!==l?(d=(0,X.jsx)(TJ,{id:e,value:a,onChange:l,autoFocus:o}),t[29]=a,t[30]=o,t[31]=e,t[32]=l,t[33]=d):d=t[33];let f;return t[34]!==c||t[35]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,d]}),t[34]=c,t[35]=d,t[36]=f):f=t[36],f}if(n.colorPicker){let a=r??``,s;t[37]===n.name?s=t[38]:(s=qJ(n.name),t[37]=n.name,t[38]=s);let c;t[39]!==e||t[40]!==s?(c=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[39]=e,t[40]=s,t[41]=c):c=t[41];let l;t[42]!==i||t[43]!==u?(l=e=>{if(e===``&&u){i(void 0);return}i(e)},t[42]=i,t[43]=u,t[44]=l):l=t[44];let d;t[45]!==a||t[46]!==o||t[47]!==e||t[48]!==l?(d=(0,X.jsx)(wJ,{id:e,value:a,onChange:l,autoFocus:o}),t[45]=a,t[46]=o,t[47]=e,t[48]=l,t[49]=d):d=t[49];let f;return t[50]!==c||t[51]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,d]}),t[50]=c,t[51]=d,t[52]=f):f=t[52],f}if(n.cssLengthInput){let a=r??``,s;if(t[53]!==a){let e=ZJ(a);s=e.valid?null:QJ(e),t[53]=a,t[54]=s}else s=t[54];let l=s,d;t[55]===n.name?d=t[56]:(d=qJ(n.name),t[55]=n.name,t[56]=d);let f;t[57]!==e||t[58]!==d?(f=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:d}),t[57]=e,t[58]=d,t[59]=f):f=t[59];let p;t[60]!==i||t[61]!==u?(p=e=>{let t=e.target.value;if(t===``&&u){i(void 0);return}i(t)},t[60]=i,t[61]=u,t[62]=p):p=t[62];let m=o?``:void 0,h=l===null?void 0:!0,g=l===null?void 0:`${e}-error`,_;t[63]!==a||t[64]!==c||t[65]!==o||t[66]!==e||t[67]!==p||t[68]!==m||t[69]!==h||t[70]!==g?(_=(0,X.jsx)(mn,{id:e,type:`text`,value:a,placeholder:`100px, 50%, 26rem, auto`,onChange:p,onKeyDown:c,autoFocus:o,"data-prop-autofocus":m,"aria-invalid":h,"aria-describedby":g,className:`h-7 text-sm`,"data-prop-css-length-input":``}),t[63]=a,t[64]=c,t[65]=o,t[66]=e,t[67]=p,t[68]=m,t[69]=h,t[70]=g,t[71]=_):_=t[71];let v;t[72]!==l||t[73]!==e?(v=l!==null&&(0,X.jsx)(`p`,{id:`${e}-error`,"data-prop-css-length-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:l}),t[72]=l,t[73]=e,t[74]=v):v=t[74];let y;return t[75]!==v||t[76]!==f||t[77]!==_?(y=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[f,_,v]}),t[75]=v,t[76]=f,t[77]=_,t[78]=y):y=t[78],y}let d,f,p;if(t[79]!==s||t[80]!==r){let e=s===void 0?void 0:aY(s);d=r??``;let n=e===void 0?null:iY(d,e);f=n!==null&&!n.valid&&e!==void 0&&d.trim().length>0?cY(n,e):null,p=e===void 0?void 0:oY(e),t[79]=s,t[80]=r,t[81]=d,t[82]=f,t[83]=p}else d=t[81],f=t[82],p=t[83];let m=p,h;t[84]===n.name?h=t[85]:(h=qJ(n.name),t[84]=n.name,t[85]=h);let g;t[86]!==e||t[87]!==h?(g=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:h}),t[86]=e,t[87]=h,t[88]=g):g=t[88];let _;t[89]!==s||t[90]!==d||t[91]!==c||t[92]!==o||t[93]!==f||t[94]!==m||t[95]!==i||t[96]!==a||t[97]!==e||t[98]!==u?(_=s===void 0?(0,X.jsx)(mn,{id:e,type:`text`,value:d,placeholder:m,onChange:e=>{let t=e.target.value;if(t===``&&u){i(void 0);return}i(t)},onKeyDown:c,autoFocus:o,"data-prop-autofocus":o?``:void 0,"aria-invalid":f===null?void 0:!0,"aria-describedby":f===null?void 0:`${e}-error`,className:`h-7 text-sm`}):(0,X.jsx)(RJ,{id:e,value:d,onChange:e=>{if(e===``&&u){i(void 0);return}i(e)},onSubmit:a,accept:s,placeholder:m,autoFocus:o,dataPropAutofocus:o?``:void 0,ariaInvalid:f===null?void 0:!0,ariaDescribedBy:f===null?void 0:`${e}-error`,className:`h-7 text-sm`}),t[89]=s,t[90]=d,t[91]=c,t[92]=o,t[93]=f,t[94]=m,t[95]=i,t[96]=a,t[97]=e,t[98]=u,t[99]=_):_=t[99];let v;t[100]!==s||t[101]!==i||t[102]!==l?(v=l&&(0,X.jsx)(bY,{accept:s,onUploaded:e=>i(e)}),t[100]=s,t[101]=i,t[102]=l,t[103]=v):v=t[103];let y;t[104]!==_||t[105]!==v?(y=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[_,v]}),t[104]=_,t[105]=v,t[106]=y):y=t[106];let b;t[107]!==f||t[108]!==e?(b=f!==null&&(0,X.jsx)(`p`,{id:`${e}-error`,"data-prop-media-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:f}),t[107]=f,t[108]=e,t[109]=b):b=t[109];let x;return t[110]!==g||t[111]!==y||t[112]!==b?(x=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[g,y,b]}),t[110]=g,t[111]=y,t[112]=b,t[113]=x):x=t[113],x}case`boolean`:{let e=`prop-${n.name}`,a;t[114]===n.name?a=t[115]:(a=qJ(n.name),t[114]=n.name,t[115]=a);let o=a,s;t[116]!==e||t[117]!==o?(s=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[116]=e,t[117]=o,t[118]=s):s=t[118];let c=!!r,l;t[119]===i?l=t[120]:(l=e=>i(e),t[119]=i,t[120]=l);let u;t[121]!==e||t[122]!==c||t[123]!==l?(u=(0,X.jsx)(SJ,{id:e,checked:c,onCheckedChange:l}),t[121]=e,t[122]=c,t[123]=l,t[124]=u):u=t[124];let d;return t[125]!==s||t[126]!==u?(d=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[s,u]}),t[125]=s,t[126]=u,t[127]=d):d=t[127],d}case`enum`:{let e=`prop-${n.name}`,a=r??n.enumValues[0]??``,o;t[128]===n.name?o=t[129]:(o=qJ(n.name),t[128]=n.name,t[129]=o);let s;t[130]!==e||t[131]!==o?(s=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[130]=e,t[131]=o,t[132]=s):s=t[132];let c;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(gJ,{}),t[133]=c):c=t[133];let l;t[134]===e?l=t[135]:(l=(0,X.jsx)(_J,{id:e,size:`sm`,children:c}),t[134]=e,t[135]=l);let u;t[136]===n.enumValues?u=t[137]:(u=n.enumValues.map(yY),t[136]=n.enumValues,t[137]=u);let d;t[138]===u?d=t[139]:(d=(0,X.jsx)(vJ,{className:`z-70`,children:u}),t[138]=u,t[139]=d);let f;t[140]!==a||t[141]!==i||t[142]!==l||t[143]!==d?(f=(0,X.jsxs)(hJ,{value:a,onValueChange:i,children:[l,d]}),t[140]=a,t[141]=i,t[142]=l,t[143]=d,t[144]=f):f=t[144];let p;return t[145]!==s||t[146]!==f?(p=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s,f]}),t[145]=s,t[146]=f,t[147]=p):p=t[147],p}case`number`:{let e=`prop-${n.name}`,a;t[148]===n.name?a=t[149]:(a=qJ(n.name),t[148]=n.name,t[149]=a);let o;t[150]!==e||t[151]!==a?(o=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:a}),t[150]=e,t[151]=a,t[152]=o):o=t[152];let s=r==null?``:String(r),l;t[153]===i?l=t[154]:(l=e=>{let t=e.target.value;if(t===``){i(void 0);return}if(t===`-`)return;let n=Number(t);Number.isNaN(n)||i(n)},t[153]=i,t[154]=l);let u;t[155]!==c||t[156]!==e||t[157]!==s||t[158]!==l?(u=(0,X.jsx)(mn,{id:e,type:`number`,inputMode:`numeric`,value:s,onChange:l,onKeyDown:c,className:`h-7 text-sm`}),t[155]=c,t[156]=e,t[157]=s,t[158]=l,t[159]=u):u=t[159];let d;return t[160]!==o||t[161]!==u?(d=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[o,u]}),t[160]=o,t[161]=u,t[162]=d):d=t[162],d}default:{let e;return t[163]===n?e=t[164]:(e=_Y(n),t[163]=n,t[164]=e),e}}}function yY(e){return(0,X.jsx)(yJ,{value:e,children:e},e)}function bY(e){let t=(0,Z.c)(17),{accept:n,onUploaded:r}=e,[i,a]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c;t[0]===n?c=t[1]:(c=n.join(`,`),t[0]=n,t[1]=c);let l;t[2]!==n||t[3]!==r?(l=async e=>{let t=e.target.files?.[0];if(t){a(!0);try{await pY(t,n,r)}catch{}a(!1),s.current&&(s.current.value=``)}},t[2]=n,t[3]=r,t[4]=l):l=t[4];let u;t[5]!==c||t[6]!==l?(u=(0,X.jsx)(`input`,{ref:s,type:`file`,accept:c,className:`hidden`,"data-prop-upload-input":``,onChange:l}),t[5]=c,t[6]=l,t[7]=u):u=t[7];let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>s.current?.click(),t[8]=d):d=t[8];let f;t[9]===i?f=t[10]:(f=i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oa,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),(0,X.jsx)(o,{id:`_eguJc`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ea,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(o,{id:`eJitUk`})]}),t[9]=i,t[10]=f);let p;t[11]!==f||t[12]!==i?(p=(0,X.jsx)(qt,{type:`button`,variant:`outline`,size:`sm`,disabled:i,"data-prop-upload-trigger":``,className:`h-7 w-full justify-center gap-1.5 px-2 text-xs`,onClick:d,children:f}),t[11]=f,t[12]=i,t[13]=p):p=t[13];let m;return t[14]!==u||t[15]!==p?(m=(0,X.jsxs)(X.Fragment,{children:[u,p]}),t[14]=u,t[15]=p,t[16]=m):m=t[16],m}var xY=new Set([`img`,`CommonMarkImage`,`video`,`audio`,`Pdf`,`File`]);function SY(e,t,n){if(!xY.has(e)||!n)return t;let r=t.src;if(typeof r!=`string`)return t;let i=M(r,n);return i===r?t:{...t,src:i}}var CY=`selectionStatePlugin/origin`,wY=`selectionStatePlugin/refresh`,TY=new N(`selectionState`),EY=new Set,DY={selectedBlockId:null,ancestorChain:[],selectionOrigin:`programmatic`,isDragging:!1,rangeEncompassedBlockIds:EY};function OY(e){return TY.getState(e.state)??DY}function kY(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(AY(e,i,a))}if(t instanceof I){let r=t.node;r.type.name===`jsxComponent`&&n.push(AY(e,r,t.from))}return n}function AY(e,t,n){let r=t.attrs.componentName??`unknown`;return{bridgeId:jY(e,n),componentName:r,pos:n}}function jY(e,t){return bM.getState(e)?.posToId.get(t)??`pos-${t}`}function MY(e,t){if(t instanceof I)return EY;let{from:n,to:r}=t;if(n>=r)return EY;let i=bM.getState(e)?.posToId;if(!i)return EY;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??EY}function NY(e,t,n={}){let r=kY(e,e.selection),i=r[r.length-1],a=MY(e,e.selection),o={selectedBlockId:i?.bridgeId??null,ancestorChain:r,selectionOrigin:n.origin??t.selectionOrigin,isDragging:n.isDragging??t.isDragging,rangeEncompassedBlockIds:a};return PY(t,o)?t:o}function PY(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 FY=new WeakMap;function IY(e,t,n,r){let i=r?.isDragging??t.isDragging,a=!!e.getMeta(wY),o=e.selectionSet&&!a,s=e.getMeta(CY),c=o?r?.pendingOrigin??null:null,l=s??c??t.selectionOrigin;return o&&r&&(r.pendingOrigin=null),NY(n,t,{origin:l,isDragging:i})}var LY=kt.create({name:`selectionStatePlugin`,addProseMirrorPlugins(){let e=this.editor,t=new pt({key:TY,state:{init(e,t){return NY(t,DY)},apply(e,n,r,i){return IY(e,n,i,FY.get(t))}},props:{handleDOMEvents:{mousedown:()=>{let e=FY.get(t);return e&&(e.pendingOrigin=`pointer`),!1},pointerdown:()=>{let e=FY.get(t);return e&&(e.pendingOrigin=`pointer`),!1}},handleKeyDown:(e,n)=>{if(RY(n.key)){let e=FY.get(t);e&&(e.pendingOrigin=`keyboard`)}return!1}},view(n){FY.set(t,{pendingOrigin:null,isDragging:!1});let r=n.dom.parentElement??n.dom,i=()=>{let n=FY.get(t);n&&(n.isDragging=!0,zY(e))},a=()=>{let n=FY.get(t);n&&(n.isDragging=!1,zY(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),FY.delete(t)}}}});return[t]}});function RY(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 zY(e){queueMicrotask(()=>{if(!e.isDestroyed)try{let t=e.state.tr.setMeta(wY,!0);e.view.dispatch(t)}catch{}})}function BY(e){let t=(0,Z.c)(5),n;t[0]===e?n=t[1]:(n=()=>e?OY(e):null,t[0]=e,t[1]=n);let[r,i]=(0,Q.useState)(n),a,o;return t[2]===e?(a=t[3],o=t[4]):(a=()=>{if(!e){i(null);return}i(OY(e));let t=()=>{i(OY(e))};return e.on(`transaction`,t),e.on(`selectionUpdate`,t),()=>{e.off(`transaction`,t),e.off(`selectionUpdate`,t)}},o=[e],t[2]=e,t[3]=a,t[4]=o),(0,Q.useEffect)(a,o),r}function VY(e,t){if(e.hasChildren)return!1;let n=KJ(e.props);return n===null?!1:t[n]===``}function HY(e){let t=e.placeholder?.label,n=`Add ${(e.displayName??e.name).toLowerCase()}`;return{label:t??n,Icon:jO(e.placeholder?.icon??e.icon)}}var UY=new Set([`img`,`CommonMarkImage`,`Embed`,`video`]);function WY(e){if(!e.attrs.sourceDirty&&e.attrs.sourceRaw)return e.attrs.sourceRaw;let t=qk(),n=e.type.schema.node(`doc`,null,[e]);return t.serialize(n.toJSON()).trim()}var GY=new Set(Ne.map(e=>`${e}:`)),KY=6e4,qY=10,JY=new Map;function YY(e,t){let n=t.toLowerCase();R(n);let r=Date.now(),i=JY.get(n);if(!i||r-i.windowStart>=KY)JY.set(n,{windowStart:r,count:1});else if(i.count+=1,i.count>qY)return;typeof console<`u`&&typeof console.warn==`function`&&console.warn(JSON.stringify({event:`jsx-prop-dropped`,reason:e,prop:t}))}var XY=new Set([`href`,`src`,`action`,`formaction`,`poster`,`cite`,`data`,`manifest`,`background`,`ping`,`xlinkhref`,`xlinkactuate`,`xlinkrole`,`xlinkarcrole`,`xlinkshow`,`url`,`link`]),ZY=new Set([`dangerouslysetinnerhtml`,`ref`,`key`,`defaultvalue`,`defaultchecked`,`__proto__`,`constructor`,`prototype`]),QY=1e4;function $Y(e){let t=e.toLowerCase();return!!(ZY.has(t)||t.length>=3&&t.startsWith(`on`))}function eX(e){return XY.has(e.toLowerCase())}function tX(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t||t.startsWith(`#`)||t.startsWith(`//`)||U(t))return e;let n=t.indexOf(`:`),r=t.slice(0,n+1).toLowerCase();return GY.has(r)?e:`#`}function nX(e){if(e.length>QY)return``;let t=e.toLowerCase();return/url\s*\(\s*['"]?\s*(?:javascript|vbscript|data)\s*:/.test(t)||/\bexpression\s*\(/.test(t)?``:e}function rX(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=rX(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($Y(e)){YY(`dangerous-prop-name-nested`,e),r=!0;continue}if(eX(e)&&typeof t==`string`){let n=tX(t);n!==t&&(r=!0),i[e]=n}else{let n=rX(t);n!==t&&(r=!0),i[e]=n}}return r?i:e}function iX(e){let t=!1,n={};for(let[r,i]of Object.entries(e)){if($Y(r)){YY(`dangerous-prop-name`,r),t=!0;continue}if(eX(r)){let e=tX(i);e!==i&&(t=!0),n[r]=e;continue}if(r===`style`){if(typeof i==`string`){let e=nX(i);e!==i&&(t=!0),n[r]=e}else t=!0;continue}let e=rX(i);e!==i&&(t=!0),n[r]=e}return t?n:e}function aX(e){let t=(0,Z.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 oX(e){let t=(0,Z.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})),Ye(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)(aX,{...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)(dJ,{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 sX(e){if(typeof e!=`object`||!e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(sX).join(`,`)}]`;let t=Object.entries(e);return t.sort(([e],[t])=>e<t?-1:+(e>t)),`{${t.map(([e,t])=>`${JSON.stringify(e)}:${sX(t)}`).join(`,`)}}`}function cX(e,t){let n=e.props??{},r={};for(let[e,i]of Object.entries(n))t.has(e)||(r[e]=i);return iX(r)}function lX(e){return e.kind===`element`?e:null}var uX=3;function dX(e){let t=(0,Z.c)(162),{node:n,editor:r,extension:a,getPos:s,selected:c}=e,{_:u}=i(),d=Gj(n.attrs.componentName),[f,p]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),y=(0,Q.useRef)(!1),b=typeof s==`function`?s():void 0,x=!1,S=0,C=1;try{if(b!==void 0){let e=r.state.doc.resolve(b);e.depth>0&&e.parent.type.name===`jsxComponent`&&(x=!0,S=e.index(e.depth),C=e.parent.childCount)}}catch(e){let t=e;if(!(t instanceof RangeError))throw t}let w=x&&S>0,T=x&&S<C-1,E=BY(r),D=typeof b==`number`?jY(r.state,b):null,O=D!==null&&(E?.rangeEncompassedBlockIds.has(D)??!1),k;t[0]===E?.ancestorChain?k=t[1]:(k=E?.ancestorChain.at(-1)?.bridgeId??null,t[0]=E?.ancestorChain,t[1]=k);let A=D!==null&&k===D,j=c&&!O&&A,M=D!==null&&!A&&(E?.ancestorChain.some(e=>e.bridgeId===D)??!1),N=j&&E?E.selectionOrigin:void 0,P=j&&(E?.isDragging??!1),F=d.props.some(_X),I=n.attrs.props??{},L=F&&d.props.some(e=>e.type!==`string`||!e.required||`hidden`in e&&e.hidden?!1:!Object.hasOwn(I,e.name)),R=VY(d,I),z=R?HY(d):null,B=!d.hasChildren||!!d.isSelfClosing,ee=UY.has(d.name),V=d.name===`MermaidFence`?{propName:`chart`,language:`mermaid`}:d.name===`Math`||d.name===`DollarMath`||d.name===`MathFence`?{propName:`formula`,language:`latex`}:null,[te,H]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{c&&!y.current&&F&&eM(b)&&_(!0),y.current=c},[c,F,b]);let U=cX(n.attrs,d.reactNodePropNames),ne=d.surface===`compat`?d.translateProps(U):U,W=a.options.docName,re=typeof W==`string`&&W?W:PD(r),G=SY(d.name,ne,re),ie=`${d.name}::${sX(U)}`,oe;t[2]!==s||t[3]!==n.content.size?(oe=()=>(typeof s==`function`?s()??0:0)+1+n.content.size,t[2]=s,t[3]=n.content.size,t[4]=oe):oe=t[4];let K=oe,se=d.name===`*`||f!==null,ce=(0,Q.useRef)(!1),q=(0,Q.useRef)(0),[le,ue]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{if(!se||ce.current||le)return;let e=typeof s==`function`?s():void 0;if(typeof e!=`number`)return;let t=WY(n),i=d.name===`*`?`Unregistered component: ${n.attrs.componentName}`:`Render error in <${d.displayName??d.name}>: ${f?.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)),ce.current=!0,Ot(d.name===`*`?`wildcard`:d.name)}catch(e){let t=e,r=d.name===`*`?`wildcard`:d.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:q.current})),m(r),q.current+=1,q.current<uX){let e=50*(2**q.current-1);c=setTimeout(()=>{o||l()},e)}else o||ue(!0)}},u=requestAnimationFrame(l);return()=>{o=!0,cancelAnimationFrame(u),c!==void 0&&clearTimeout(c)}},[se,n,r,s,d,f,le]),le){let e=n.attrs.componentName,i=d.displayName??d.name,a=d.name===`*`?u({id:`Kh1n4a`,values:{componentName:e}}):u({id:`g58Kwy`,values:{descriptorLabel:i}}),o=()=>{try{let e=WY(n);typeof navigator<`u`&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(e)}catch(e){let t=e;l(d.name),console.warn(JSON.stringify({event:`jsx-component-stuck-copy-failed`,component:d.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;Ke(d.name),console.warn(JSON.stringify({event:`jsx-component-stuck-delete-failed`,component:d.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f={[JP]:`true`},t[5]=f):f=t[5];let p;t[6]===a?p=t[7]:(p=(0,X.jsx)(`span`,{className:`flex-1`,children:a}),t[6]=a,t[7]=p);let m;t[8]===u?m=t[9]:(m=u({id:`E2Mv-X`}),t[8]=u,t[9]=m);let h;t[10]!==o||t[11]!==m?(h=(0,X.jsx)(`button`,{type:`button`,className:`text-xs underline hover:no-underline`,onClick:o,children:m}),t[10]=o,t[11]=m,t[12]=h):h=t[12];let g;t[13]===u?g=t[14]:(g=u({id:`cnGeoo`}),t[13]=u,t[14]=g);let _;t[15]!==c||t[16]!==g?(_=(0,X.jsx)(`button`,{type:`button`,className:`text-xs underline hover:no-underline`,onClick:c,children:g}),t[15]=c,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==h||t[19]!==_||t[20]!==p?(v=(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,...f,children:[p,h,_]}),t[18]=h,t[19]=_,t[20]=p,t[21]=v):v=t[21];let y;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,X.jsx)(Al,{className:`component-children`}),t[22]=y):y=t[22];let b;return t[23]===v?b=t[24]:(b=(0,X.jsxs)(jl,{className:`jsx-component-wrapper my-2`,children:[v,y]}),t[23]=v,t[24]=b),b}if(se){let e=n.attrs.componentName,r=d.displayName??d.name,i=d.name===`*`?u({id:`oJl7eO`,values:{componentName:e}}):u({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)(Al,{className:`component-children`}),t[27]=o):o=t[27];let s;return t[28]===a?s=t[29]:(s=(0,X.jsxs)(jl,{className:`jsx-component-wrapper my-2`,children:[a,o]}),t[28]=a,t[29]=s),s}let de=d.Component,fe=d.displayName??d.name,pe=d.displayName??d.name,me=d.displayName??d.name,he=e=>{if(R||!B)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 b!=`number`)return;let n=r.state.doc.nodeAt(b);if(!n)return;let i=b+n.nodeSize,a=r.state.selection.from;a<b||a>=i||r.chain().focus().setNodeSelection(b).run()},ge;t[30]!==r||t[31]!==s||t[32]!==_?(ge=()=>{let e=typeof s==`function`?s():void 0;typeof e==`number`&&(r.chain().focus().setNodeSelection(e).run(),_(!0))},t[30]=r,t[31]=s,t[32]=_,t[33]=ge):ge=t[33];let _e=ge,ve=d.displayName??d.name,ye=!!d.emptyChildName,be=ye?GJ(ve,d.emptyChildName,n.childCount):void 0,xe=e=>{let t=e.target;if(e.key===`Backspace`||e.key===`Delete`){if(!j||!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()||(ae(d.name),console.warn(JSON.stringify({event:`jsx-component-keyboard-delete-failed`,component:d.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;ae(d.name),console.warn(JSON.stringify({event:`jsx-component-keyboard-delete-failed`,component:d.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}return}e.key!==`Enter`&&e.key!==` `||c&&F&&(t.closest(`.jsx-component-chrome`)||t.closest(`input, textarea, select, button`)||(e.preventDefault(),_(!0)))},Se=e=>{_(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(B){let e=r.state.doc.resolve(Math.min(n,r.state.doc.content.size)),t=Ce.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;h(d.name),console.warn(JSON.stringify({event:`jsx-component-popover-close-restore-failed`,component:d.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}})},we=rc,Te=jl,Ee;t[34]===d.name?Ee=t[35]:(Ee=d.name.toLowerCase(),t[34]=d.name,t[35]=Ee);let De;bb0:{let e=I.align;if(e===`left`||e===`right`||e===`center`){De=e;break bb0}if(ee){De=`center`;break bb0}De=void 0}let Oe=j?`true`:void 0,ke=M?`true`:void 0,Ae=O?`true`:void 0,je=P?`true`:void 0,Me=L?`true`:void 0,Ne=ye?`group`:void 0,Pe=j?0:-1,Fe;t[36]===x?Fe=t[37]:(Fe=x?{draggable:`false`,onDragStart:gX}:{"data-drag-handle":``,draggable:`true`},t[36]=x,t[37]=Fe);let Ie=d.name,Le=hX,Re;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(Re={[JP]:`true`},t[38]=Re):Re=t[38];let ze=d.name===`Embed`&&typeof U.src==`string`&&/^https?:\/\//i.test(U.src)&&(0,X.jsx)(`a`,{href:U.src,target:`_blank`,rel:`noopener noreferrer`,className:`jsx-chrome-btn`,"aria-label":u({id:`iOHg1t`}),onMouseDown:mX,children:(0,X.jsx)(Fi,{size:12,"aria-hidden":`true`})}),Be=d.name===`Mirror`&&typeof U.src==`string`&&U.src.length>0&&(()=>{let e=U.src;return(0,X.jsx)(`a`,{href:xn(e,typeof U.anchor==`string`&&U.anchor.length>0?U.anchor:null),className:`jsx-chrome-btn`,"aria-label":u({id:`3a_Bd7`,values:{mirrorSrc:e}}),title:u({id:`0kTAXe`,values:{mirrorSrc:e}}),onMouseDown:pX,children:(0,X.jsx)(Fi,{size:12,"aria-hidden":`true`})})})(),Ve;t[39]!==u||t[40]!==w||t[41]!==d.name||t[42]!==r||t[43]!==n.attrs.componentName||t[44]!==n.nodeSize||t[45]!==b?(Ve=w&&(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":u({id:`QyioBP`}),onClick:()=>{try{if(typeof b!=`number`)return;let e=r.state.doc.resolve(b),t=e.index(e.depth);if(t===0)return;let i=b-e.node(e.depth).child(t-1).nodeSize,a=b+n.nodeSize,o=r.state.tr,s=r.state.doc.slice(b,b+n.nodeSize),c=r.state.doc.slice(i,b);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;v(`up`),console.warn(JSON.stringify({event:`jsx-component-move-failed`,direction:`up`,component:d.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},children:(0,X.jsx)(yi,{size:12,"aria-hidden":`true`})}),t[39]=u,t[40]=w,t[41]=d.name,t[42]=r,t[43]=n.attrs.componentName,t[44]=n.nodeSize,t[45]=b,t[46]=Ve):Ve=t[46];let He;t[47]!==u||t[48]!==T||t[49]!==d.name||t[50]!==r||t[51]!==n.attrs.componentName||t[52]!==n.nodeSize||t[53]!==b?(He=T&&(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":u({id:`3Ib6FN`}),onClick:()=>{try{if(typeof b!=`number`)return;let e=r.state.doc.resolve(b),t=e.index(e.depth),i=e.node(e.depth);if(t>=i.childCount-1)return;let a=i.child(t+1),o=b,s=b+n.nodeSize+a.nodeSize,c=r.state.tr,l=r.state.doc.slice(b,b+n.nodeSize),u=r.state.doc.slice(b+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;v(`down`),console.warn(JSON.stringify({event:`jsx-component-move-failed`,direction:`down`,component:d.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},children:(0,X.jsx)(vi,{size:12,"aria-hidden":`true`})}),t[47]=u,t[48]=T,t[49]=d.name,t[50]=r,t[51]=n.attrs.componentName,t[52]=n.nodeSize,t[53]=b,t[54]=He):He=t[54];let Ue;t[55]!==u||t[56]!==d.displayName||t[57]!==d.name||t[58]!==V||t[59]!==b||t[60]!==H?(Ue=V&&typeof b==`number`?(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":u({id:`ky9Tuc`,values:{0:d.displayName??d.name}}),"data-testid":`jsx-component-edit-btn`,onClick:()=>H(!0),children:(0,X.jsx)(pa,{size:12,"aria-hidden":`true`})}):null,t[55]=u,t[56]=d.displayName,t[57]=d.name,t[58]=V,t[59]=b,t[60]=H,t[61]=Ue):Ue=t[61];let We;t[62]!==u||t[63]!==fe?(We=u({id:`MCjC9A`,values:{deleteDescriptorLabel:fe}}),t[62]=u,t[63]=fe,t[64]=We):We=t[64];let Ge;t[65]!==d.name||t[66]!==r||t[67]!==n.attrs.componentName||t[68]!==b?(Ge=()=>{if(typeof b==`number`)try{r.chain().focus().setNodeSelection(b).deleteSelection().run()||(ae(d.name),console.warn(JSON.stringify({event:`jsx-component-chrome-delete-failed`,component:d.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;ae(d.name),console.warn(JSON.stringify({event:`jsx-component-chrome-delete-failed`,component:d.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},t[65]=d.name,t[66]=r,t[67]=n.attrs.componentName,t[68]=b,t[69]=Ge):Ge=t[69];let qe;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,X.jsx)(Ta,{size:12,"aria-hidden":`true`}),t[70]=qe):qe=t[70];let Je;t[71]!==We||t[72]!==Ge?(Je=(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn jsx-chrome-btn--delete`,"aria-label":We,onClick:Ge,children:qe}),t[71]=We,t[72]=Ge,t[73]=Je):Je=t[73];let Ye;t[74]!==u||t[75]!==F||t[76]!==pe?(Ye=F&&(0,X.jsx)(ic,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"data-jsx-gear":``,"aria-label":u({id:`XPJ0sN`,values:{settingsDescriptorLabel:pe}}),children:(0,X.jsx)(_a,{size:12,"aria-hidden":`true`})})}),t[74]=u,t[75]=F,t[76]=pe,t[77]=Ye):Ye=t[77];let Xe;t[78]!==Le||t[79]!==Re||t[80]!==ze||t[81]!==Be||t[82]!==Ve||t[83]!==He||t[84]!==Ue||t[85]!==Je||t[86]!==Ye?(Xe=(0,X.jsxs)(`div`,{className:`jsx-component-chrome`,contentEditable:!1,onMouseDown:Le,...Re,children:[ze,Be,Ve,He,Ue,Je,Ye]}),t[78]=Le,t[79]=Re,t[80]=ze,t[81]=Be,t[82]=Ve,t[83]=He,t[84]=Ue,t[85]=Je,t[86]=Ye,t[87]=Xe):Xe=t[87];let Ze;t[88]!==de||t[89]!==d.emptyChildName||t[90]!==d.hasChildren||t[91]!==d.isSelfClosing||t[92]!==d.name||t[93]!==r||t[94]!==s||t[95]!==K||t[96]!==j||t[97]!==n.attrs.componentName||t[98]!==n.childCount||t[99]!==_e||t[100]!==G||t[101]!==ie||t[102]!==z||t[103]!==p||t[104]!==R?(Ze=R&&z?(0,X.jsx)(oc,{asChild:!0,children:(0,X.jsx)(pJ,{label:z.label,Icon:z.Icon,onClick:_e,selected:j})}):(0,X.jsx)(oX,{resetKey:ie,onError:p,descriptorName:d.name===`*`?`wildcard`:d.name,rawComponentName:n.attrs.componentName??``,children:(0,X.jsx)(WO,{value:typeof s==`function`?{editor:r,getPos:()=>{let e=s();return typeof e==`number`?e:void 0},addChild:d.emptyChildName?()=>{let e=d.emptyChildName,t=Zj(e),n=K();r.chain().focus().insertContentAt(n,t).run(),tM(r,n,Gj(e))}:null}:null,children:(0,X.jsx)(de,{...G,children:(0,X.jsx)(Al,{className:`component-children ${!d.hasChildren&&n.childCount===0?`min-h-0 m-0 p-0`:``}`,...!d.hasChildren||d.isSelfClosing?{contentEditable:!1}:{}})})})}),t[88]=de,t[89]=d.emptyChildName,t[90]=d.hasChildren,t[91]=d.isSelfClosing,t[92]=d.name,t[93]=r,t[94]=s,t[95]=K,t[96]=j,t[97]=n.attrs.componentName,t[98]=n.childCount,t[99]=_e,t[100]=G,t[101]=ie,t[102]=z,t[103]=p,t[104]=R,t[105]=Ze):Ze=t[105];let Qe;t[106]!==d.emptyChildName||t[107]!==d.name||t[108]!==r||t[109]!==K||t[110]!==n.childCount?(Qe=d.emptyChildName&&!(d.name===`Tabs`&&n.childCount>0)&&(()=>{let e=d.emptyChildName;return(0,X.jsx)(`button`,{type:`button`,contentEditable:!1,className:n.childCount===0?`jsx-empty-child-placeholder`:`jsx-add-child-pill`,onMouseDown:fX,onClick:()=>{let e=d.emptyChildName,t=Zj(e),n=K();r.chain().focus().insertContentAt(n,t).run(),tM(r,n,Gj(e))},"data-clipboard-omit":`true`,children:(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`7Fkcej`,values:{addChildName:e}})})})})(),t[106]=d.emptyChildName,t[107]=d.name,t[108]=r,t[109]=K,t[110]=n.childCount,t[111]=Qe):Qe=t[111];let $e;t[112]!==Te||t[113]!==d.name||t[114]!==be||t[115]!==he||t[116]!==xe||t[117]!==N||t[118]!==Ee||t[119]!==De||t[120]!==Oe||t[121]!==ke||t[122]!==Ae||t[123]!==je||t[124]!==Me||t[125]!==Ne||t[126]!==Pe||t[127]!==Fe||t[128]!==Xe||t[129]!==Ze||t[130]!==Qe?($e=(0,X.jsxs)(Te,{className:`jsx-component-wrapper my-2`,"data-jsx-component":``,"data-component-type":Ee,"data-align":De,"data-selected":Oe,"data-has-child-selected":ke,"data-range-selected":Ae,"data-selection-origin":N,"data-dragging":je,"data-needs-config":Me,role:Ne,"aria-label":be,tabIndex:Pe,...Fe,"data-component-name":Ie,onClick:he,onKeyDown:xe,children:[Xe,Ze,Qe]}),t[112]=Te,t[113]=d.name,t[114]=be,t[115]=he,t[116]=xe,t[117]=N,t[118]=Ee,t[119]=De,t[120]=Oe,t[121]=ke,t[122]=Ae,t[123]=je,t[124]=Me,t[125]=Ne,t[126]=Pe,t[127]=Fe,t[128]=Xe,t[129]=Ze,t[130]=Qe,t[131]=$e):$e=t[131];let et;t[132]!==u||t[133]!==I||t[134]!==d.Component||t[135]!==d.displayName||t[136]!==d.name||t[137]!==te||t[138]!==V||t[139]!==r||t[140]!==s||t[141]!==b||t[142]!==G||t[143]!==H?(et=V&&typeof b==`number`?(0,X.jsx)(mG,{open:te,onOpenChange:H,initialValue:typeof I[V.propName]==`string`?I[V.propName]:``,language:V.language,title:u({id:`ky9Tuc`,values:{0:d.displayName??d.name}}),renderPreview:e=>{let t=d.Component;return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center p-4`,children:(0,X.jsx)(t,{...G,[V.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)return;let i=lX(n.attrs);if(i)try{let n={...i.props,[V.propName]:e},a={...i,props:n,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]=u,t[133]=I,t[134]=d.Component,t[135]=d.displayName,t[136]=d.name,t[137]=te,t[138]=V,t[139]=r,t[140]=s,t[141]=b,t[142]=G,t[143]=H,t[144]=et):et=t[144];let tt;t[145]!==d||t[146]!==r||t[147]!==s||t[148]!==F||t[149]!==B||t[150]!==U||t[151]!==me||t[152]!==_||t[153]!==R?(tt=F&&(0,X.jsxs)(ac,{side:R?`bottom`:`right`,align:R?`center`:`start`,sideOffset:R?-4:8,className:`w-64 p-3 z-[60] overflow-y-auto subtle-scrollbar max-h-[var(--radix-popper-available-height)] overscroll-contain`,onCloseAutoFocus:B?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)(mY,{descriptor:d,values:U,onDismiss:()=>_(!1),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)return;let a=lX(i.attrs);if(!a)return;let o={...a.props},c=Array.isArray(i.attrs.attributes)?i.attrs.attributes:[],l=c;t===void 0?(delete o[e],l=c.filter(t=>!(typeof t==`object`&&t&&t.type===`mdxJsxAttribute`&&t.name===e))):o[e]=t,r.view.dispatch(r.state.tr.setNodeMarkup(n,null,{...a,attributes:l,props:o,sourceDirty:!0}))}}),(0,X.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-border pt-2`,children:(0,X.jsx)(qt,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>_(!1),className:`h-7 px-3 text-xs`,children:(0,X.jsx)(o,{id:`DPfwMq`})})})]}),t[145]=d,t[146]=r,t[147]=s,t[148]=F,t[149]=B,t[150]=U,t[151]=me,t[152]=_,t[153]=R,t[154]=tt):tt=t[154];let nt;return t[155]!==we||t[156]!==Se||t[157]!==g||t[158]!==$e||t[159]!==et||t[160]!==tt?(nt=(0,X.jsxs)(we,{open:g,onOpenChange:Se,children:[$e,et,tt]}),t[155]=we,t[156]=Se,t[157]=g,t[158]=$e,t[159]=et,t[160]=tt,t[161]=nt):nt=t[161],nt}function fX(e){return e.stopPropagation()}function pX(e){return e.stopPropagation()}function mX(e){return e.stopPropagation()}function hX(e){return e.stopPropagation()}function gX(e){return e.preventDefault()}function _X(e){return!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`}var vX=P.extend({addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return zl(dX)}}),yX={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`}]},bX=(0,Q.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-DBuiuHex.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,Z.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 xX(){let e=(0,Z.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 SX(e){let t=(0,Z.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 CX(e){let t=(0,Z.c)(38),{node:n,selected:r,getPos:i,editor:a}=e,s=typeof n.attrs.formula==`string`?n.attrs.formula:``,c=typeof n.attrs.id==`string`?n.attrs.id:void 0,[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(!1),f;t[0]!==a.state||t[1]!==i||t[2]!==r?(f=()=>{let e=r&&a.state.selection instanceof I;e&&!d.current?(eM(typeof i==`function`?i()??0:0),u(!0)):!e&&d.current&&u(!1),d.current=e},t[0]=a.state,t[1]=i,t[2]=r,t[3]=f):f=t[3];let p;t[4]!==a||t[5]!==i||t[6]!==r?(p=[r,i,a],t[4]=a,t[5]=i,t[6]=r,t[7]=p):p=t[7],(0,Q.useEffect)(f,p);let m=r?`math-inline-selected`:void 0,h;t[8]===c?h=t[9]:(h=c?{id:c}:{},t[8]=c,t[9]=h);let g;t[10]===s?g=t[11]:(g=s?(0,X.jsx)(dJ,{resetKeys:[s],onError:TX,fallbackRender:()=>(0,X.jsx)(`span`,{className:`math math-inline math-error`,children:s}),children:(0,X.jsx)(Q.Suspense,{fallback:(0,X.jsx)(SX,{formula:s}),children:(0,X.jsx)(bX,{formula:s})})}):(0,X.jsx)(xX,{}),t[10]=s,t[11]=g);let _;t[12]!==s||t[13]!==h||t[14]!==g?(_=(0,X.jsx)(ic,{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(I.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)(mY,{descriptor:yX,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)(ac,{className:`z-[60] w-72 p-0`,side:`bottom`,align:`start`,onOpenAutoFocus:wX,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)(rc,{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)(jl,{as:`span`,className:m,children:w}),t[35]=w,t[36]=m,t[37]=T):T=t[37],T}function wX(e){e.preventDefault()}function TX(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})),Ye(`mathInline`)}var EX=xe.extend({addNodeView(){return zl(CX)}});function DX(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=be.near(e.doc.resolve(i),n);return a.$head?.parent.type.name===`rawMdxFallback`?a:null}function OX(e,t){let{state:n,view:r}=e;if(!r.endOfTextblock(t))return!1;let i=DX(n,t);return i?(r.dispatch(n.tr.setSelection(i)),!0):!1}var kX=tt.extend({addKeyboardShortcuts(){return{ArrowLeft:({editor:e})=>OX(e,`left`),ArrowRight:({editor:e})=>OX(e,`right`),ArrowUp:({editor:e})=>OX(e,`up`),ArrowDown:({editor:e})=>OX(e,`down`)}},addNodeView(){return zl(sG,{stopEvent:()=>!0,ignoreMutation:()=>!0})}});function AX(e){let t=(0,Z.c)(51),{items:n,selectedIndex:r,categoryLabels:a,onSelect:s,onHoverIndex:c}=e,l=(0,Q.useRef)(null),u=(0,Q.useId)(),{_:d}=i(),f=r>=0&&r<n.length?`${u}-option-${r}`:void 0,p=MX,m,h;if(t[0]===r?(m=t[1],h=t[2]):(m=()=>{let e=l.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(r);t&&t.scrollIntoView({block:`nearest`})},h=[r],t[0]=r,t[1]=m,t[2]=h),(0,Q.useEffect)(m,h),n.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[3]=e):e=t[3];let n;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,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(jX),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 jX(e){return e.preview}function MX(e){return e.preventDefault()}var NX=new N(`slashCommand`),PX=kt.create({name:`slashCommand`,addOptions(){return{itemsSources:[mM],categoryLabels:{basic:`Basic blocks`,insert:`Insert`}}},addProseMirrorPlugins(){let e=this;return[Ay({editor:this.editor,pluginKey:NX,char:`/`,startOfLine:!1,allow:({editor:e})=>!Ly(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 hM(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=Ry(()=>n,`slash-command`);i.popup=c.popup,a=c.doPosition,t=new Ll(AX,{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(){zy(i),a=null,t?.destroy(),t=null,n=null,r=0}}}})]}}),FX=new N(`sourceDirty`),IX=kt.create({name:`sourceDirtyObserver`,addProseMirrorPlugins(){return[new pt({key:FX,appendTransaction(e,t,n){if(!e.some(e=>!e.getMeta(Tv))||!e.some(e=>e.docChanged))return null;let r=new H;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=!LX(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 LX(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(!LX(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(!LX(e[r],t[r]))return!1;return!0}var RX=kt.create({name:`tabFocusTrap`,priority:1,addKeyboardShortcuts(){return{Tab:()=>!0,"Shift-Tab":()=>!0}}});function zX(e,t){let n=e.doc.nodeAt(t);if(!n||n.type.name!==`table`)return null;let r=Lt.get(n);return{map:r,tableStart:t+1,table:n,left:0,top:0,right:r.width,bottom:r.height}}function BX(e,t){let n=zX(e,t);return n?Oe(e.tr,n,n.map.width):null}function VX(e,t){let n=zX(e,t);return n?Nt(e.tr,n,n.map.height):null}function HX(e,t){if(!e.dom.contains(t))return null;let n;try{n=e.posAtDOM(t,0)}catch{return null}return n<0?null:ie(e.state.doc.resolve(n))?.pos??null}var UX=`<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 WX(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(JP,`true`),n.innerHTML=UX,n.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation()}),n}var GX=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(JP,`true`);let n=WX(`column`,`Add column`),r=WX(`row`,`Add row`);n.addEventListener(`click`,()=>this.insert(e,BX)),r.addEventListener(`click`,()=>this.insert(e,VX)),t.append(n,r),this.mount.appendChild(t);let i=or(e,t,()=>{let{width:t,height:i}=e.getBoundingClientRect();fr(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(()=>{}),fr(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=HX(this.view,n);if(r===null)return;let i=t(this.view.state,r);i&&(this.view.dispatch(i),this.view.focus())}},KX=kt.create({name:`tableInsertControls`,addProseMirrorPlugins(){let e=this.editor;return[new pt({key:new N(`tableInsertControls`),view:t=>new GX(t,e)})]}}),qX=`ok:tag-click`;function JX(e){if(typeof document>`u`)return;let t={value:e};document.dispatchEvent(new CustomEvent(qX,{detail:t}))}function YX(e){return e instanceof Element?e.closest(`a[data-tag]`):null}var XX=kt.create({name:`tagClick`,addProseMirrorPlugins(){return[new pt({props:{handleDOMEvents:{click(e,t){let n=YX(t.target);if(!n)return!1;let r=n.getAttribute(`data-tag`);return r?(t.preventDefault(),t.stopPropagation(),JX(r),!0):!1}}}})]}});function ZX(e,t,n){if(typeof t!=`number`||!n||!pe.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(Ce.create(o.doc,s+1)),i.dispatch(o),i.focus(),!0}function QX(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 $X(e){let t=(0,Z.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 eZ(e){let t=(0,Z.c)(20),{initialDraft:n,onCommit:r,onCancel:a}=e,{_:o}=i(),s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(n),u=(0,Q.useRef)(!1),d,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=requestAnimationFrame(()=>{s.current?.focus()});return()=>cancelAnimationFrame(e)},f=[],t[0]=d,t[1]=f):(d=t[0],f=t[1]),(0,Q.useEffect)(d,f);let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,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===``||pe.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}pe.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 tZ(e){let t=(0,Z.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)(jl,{as:`span`,children:(0,X.jsx)(eZ,{initialDraft:``,onCommit:e=>ZX(i,typeof r==`function`?r():void 0,e),onCancel:()=>QX(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)(jl,{as:`span`,children:(0,X.jsx)($X,{value:a})}),t[3]=a,t[4]=o),o}var nZ=Pt.extend({priority:200,addNodeView(){return zl(tZ)},addKeyboardShortcuts(){return{Backspace:()=>{if(By.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(By.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[qy(this.editor)]}}),rZ=2048,iZ=24;function aZ(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim();if(t===``||t.length>rZ)return{kind:`unsupported`,value:``};if(cZ(t))return{kind:`emoji`,value:t};let n=lZ(t);return n===`url`?{kind:`url`,value:t}:n===`path`?{kind:`path`,value:et(`/api/asset?path=${encodeURIComponent(sZ(t))}`)}:{kind:`unsupported`,value:``}}function oZ(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim();if(t===``||t.length>rZ)return{kind:`unsupported`,value:``};let n=lZ(t);return n===`url`?{kind:`url`,value:t}:n===`path`?{kind:`path`,value:et(`/api/asset?path=${encodeURIComponent(sZ(t))}`)}:{kind:`unsupported`,value:``}}function sZ(e){return e.startsWith(`/`)?e.slice(1):e}function cZ(e){if(/\p{L}/u.test(e)||e.includes(`/`))return!1;let t=0;for(let n of e)t++;if(t>iZ)return!1;let n=e.lastIndexOf(`.`);if(n>-1){let t=e.slice(n+1).toLowerCase();if(se.has(t))return!1}return!0}function lZ(e){let t=uZ(e);if(!t||!se.has(t))return`unsupported`;let n=e.indexOf(`:`),r=e.indexOf(`/`);return n>-1&&(r===-1||n<r)?Rt(e)?`url`:`unsupported`:e.startsWith(`//`)||e.includes(`?`)||e.includes(`#`)||e.startsWith(`../`)||e.includes(`/../`)?`unsupported`:`path`}function uZ(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 dZ(e){let t=(0,Z.c)(133),{open:n,target:r,alias:a,anchor:s,pages:c,assetPaths:l,filePaths:u,loading:d,onOpenChange:f,onSave:p}=e,[m,h]=(0,Q.useState)(r),[g,_]=(0,Q.useState)(a??``),[v,y]=(0,Q.useState)(s??``),b=(0,Q.useId)(),x=(0,Q.useId)(),S=(0,Q.useId)(),C=(0,Q.useId)(),{_:w}=i(),T;t[0]!==l||t[1]!==m||t[2]!==u?(T=KD(m,l,u),t[0]=l,t[1]=m,t[2]=u,t[3]=T):T=t[3];let E=T,D;t[4]!==l||t[5]!==m||t[6]!==u||t[7]!==c?(D=qD(m,c,l,u),t[4]=l,t[5]=m,t[6]=u,t[7]=c,t[8]=D):D=t[8];let O=$q(m,D&&!E&&n),k=(0,Q.useRef)(!1),A,j;t[9]!==a||t[10]!==s||t[11]!==n||t[12]!==r?(A=()=>{if(!n){k.current=!1;return}k.current||(k.current=!0,h(r),_(a??``),y(s??``))},j=[n,r,a,s],t[9]=a,t[10]=s,t[11]=n,t[12]=r,t[13]=A,t[14]=j):(A=t[13],j=t[14]),(0,Q.useEffect)(A,j);let M;t[15]!==g||t[16]!==v||t[17]!==m||t[18]!==f||t[19]!==p?(M=function(){let e=m.trim();e&&(p(e,g.trim()||null,v.trim()||null),f(!1))},t[15]=g,t[16]=v,t[17]=m,t[18]=f,t[19]=p,t[20]=M):M=t[20];let N=M,P;t[21]===N?P=t[22]:(P=function(e){e.key===`Enter`&&(e.preventDefault(),N())},t[21]=N,t[22]=P);let F=P,I;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(I=function(e){h(e.path),y(``)},t[23]=I):I=t[23];let L=I,R,z,B,ee,V,te,H,U,ne,W,re,G,ie,ae,oe,K,se;if(t[24]!==w||t[25]!==S||t[26]!==x||t[27]!==l||t[28]!==g||t[29]!==v||t[30]!==m||t[31]!==F||t[32]!==C||t[33]!==O||t[34]!==d||t[35]!==f||t[36]!==n||t[37]!==c||t[38]!==b){let e=new Map,r=O?.map(t=>{let n=e.get(t.slug)??0;e.set(t.slug,n+1);let r=n===0?t.slug:`${t.slug}-${n}`;return{...t,reactKey:r}}),i=!!r?.length;B=un,ae=n,oe=f,z=tn,U=`sm:max-w-xl`,ne=``,W=Fq,re=Fq,G=Fq;let a;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Xt,{children:(0,X.jsx)(o,{id:`xzktOa`})}),t[56]=a):a=t[56],t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,X.jsxs)(ln,{children:[a,(0,X.jsx)(Yt,{children:(0,X.jsx)(o,{id:`Jhj_lh`})})]}),t[57]=ie):ie=t[57],R=an,V=`space-y-6`;let s;t[58]===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[58]=s):s=t[58];let u;t[59]===b?u=t[60]:(u=(0,X.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:b,children:s}),t[59]=b,t[60]=u);let p;t[61]===w?p=t[62]:(p=w({id:`aM23Wr`}),t[61]=w,t[62]=p);let T;t[63]!==l||t[64]!==m||t[65]!==F||t[66]!==d||t[67]!==c||t[68]!==p||t[69]!==b?(T=(0,X.jsx)(Rq,{id:b,value:m,pages:c,assetPaths:l,includeAssets:!0,loading:d,onValueChange:h,onSuggestionSelect:L,placeholder:p,autoFocus:!0,"aria-required":`true`,onKeyDown:F}),t[63]=l,t[64]=m,t[65]=F,t[66]=d,t[67]=c,t[68]=p,t[69]=b,t[70]=T):T=t[70],t[71]!==u||t[72]!==T?(te=(0,X.jsxs)(`div`,{children:[u,T]}),t[71]=u,t[72]=T,t[73]=te):te=t[73];let E;t[74]===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[74]=E):E=t[74];let D;t[75]===S?D=t[76]:(D=(0,X.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:S,children:E}),t[75]=S,t[76]=D);let k;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>_(e.target.value),t[77]=k):k=t[77];let A;t[78]===w?A=t[79]:(A=w({id:`BH56dn`}),t[78]=w,t[79]=A);let j;t[80]!==S||t[81]!==g||t[82]!==F||t[83]!==A?(j=(0,X.jsx)(mn,{id:S,value:g,onChange:k,placeholder:A,onKeyDown:F}),t[80]=S,t[81]=g,t[82]=F,t[83]=A,t[84]=j):j=t[84],t[85]!==D||t[86]!==j?(H=(0,X.jsxs)(`div`,{children:[D,j]}),t[85]=D,t[86]=j,t[87]=H):H=t[87];let M;t[88]===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[88]=M):M=t[88],t[89]===x?K=t[90]:(K=(0,X.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:x,children:M}),t[89]=x,t[90]=K);let N;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>y(e.target.value),t[91]=N):N=t[91];let P;t[92]===w?P=t[93]:(P=w({id:`W-ntoW`}),t[92]=w,t[93]=P),t[94]!==x||t[95]!==v||t[96]!==F||t[97]!==P?(se=(0,X.jsx)(mn,{id:x,value:v,onChange:N,placeholder:P,onKeyDown:F}),t[94]=x,t[95]=v,t[96]=F,t[97]=P,t[98]=se):se=t[98],ee=i&&(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:r.map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":v===e.slug,className:Ut(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,v===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>y(v===e.slug?``:e.slug),children:[(0,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[24]=w,t[25]=S,t[26]=x,t[27]=l,t[28]=g,t[29]=v,t[30]=m,t[31]=F,t[32]=C,t[33]=O,t[34]=d,t[35]=f,t[36]=n,t[37]=c,t[38]=b,t[39]=R,t[40]=z,t[41]=B,t[42]=ee,t[43]=V,t[44]=te,t[45]=H,t[46]=U,t[47]=ne,t[48]=W,t[49]=re,t[50]=G,t[51]=ie,t[52]=ae,t[53]=oe,t[54]=K,t[55]=se}else R=t[39],z=t[40],B=t[41],ee=t[42],V=t[43],te=t[44],H=t[45],U=t[46],ne=t[47],W=t[48],re=t[49],G=t[50],ie=t[51],ae=t[52],oe=t[53],K=t[54],se=t[55];let ce;t[99]!==ee||t[100]!==K||t[101]!==se?(ce=(0,X.jsxs)(`div`,{children:[K,se,ee]}),t[99]=ee,t[100]=K,t[101]=se,t[102]=ce):ce=t[102];let q;t[103]!==V||t[104]!==te||t[105]!==H||t[106]!==ce?(q=(0,X.jsxs)(`div`,{className:V,children:[te,H,ce]}),t[103]=V,t[104]=te,t[105]=H,t[106]=ce,t[107]=q):q=t[107];let le;t[108]!==R||t[109]!==q?(le=(0,X.jsx)(R,{children:q}),t[108]=R,t[109]=q,t[110]=le):le=t[110];let ue;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,X.jsx)(cn,{asChild:!0,children:(0,X.jsx)(qt,{variant:`outline`,children:(0,X.jsx)(o,{id:`dEgA5A`})})}),t[111]=ue):ue=t[111];let de;t[112]===m?de=t[113]:(de=m.trim(),t[112]=m,t[113]=de);let fe=!de,pe;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,X.jsx)(o,{id:`tfDRzk`}),t[114]=pe):pe=t[114];let me;t[115]!==N||t[116]!==fe?(me=(0,X.jsxs)(on,{children:[ue,(0,X.jsx)(qt,{onClick:N,disabled:fe,children:pe})]}),t[115]=N,t[116]=fe,t[117]=me):me=t[117];let he;t[118]!==z||t[119]!==U||t[120]!==ne||t[121]!==W||t[122]!==re||t[123]!==G||t[124]!==ie||t[125]!==le||t[126]!==me?(he=(0,X.jsxs)(z,{className:U,"data-ok-layer-spawned":ne,onPointerDownOutside:W,onFocusOutside:re,onInteractOutside:G,children:[ie,le,me]}),t[118]=z,t[119]=U,t[120]=ne,t[121]=W,t[122]=re,t[123]=G,t[124]=ie,t[125]=le,t[126]=me,t[127]=he):he=t[127];let ge;return t[128]!==B||t[129]!==ae||t[130]!==oe||t[131]!==he?(ge=(0,X.jsx)(B,{open:ae,onOpenChange:oe,children:he}),t[128]=B,t[129]=ae,t[130]=oe,t[131]=he,t[132]=ge):ge=t[132],ge}function fZ(e){let t=(0,Z.c)(116),{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=ye(l?.attrs.alias),f=ye(l?.attrs.anchor),p=Te({target:u,alias:d,anchor:f}),{addPage:m,assetPaths:h,filePaths:g,folderPaths:_,pages:v,pagesBySlug:y,pagesByBasename:b,loading:x}=jn(),S=le(u,f),C=S?.kind===`external`?S:null,w=S?.kind===`asset`?KD(S.url,h,g)??S.url.replace(/^\//,``):null,T=w?null:AU(u,{pages:v,folderPaths:_,pagesBySlug:y,pagesByBasename:b,fallbackTargets:HD(u)}),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.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 P=N,F=function(e){if(e!==u){let t=r();if(t==null)return;n.view.dispatch(n.state.tr.setNodeMarkup(t,void 0,{...n.state.doc.nodeAt(t)?.attrs,target:e,alias:d??p}))}},I=function(){return T?.kind===`create`?{initialDir:T.initialDir,suggestedName:T.suggestedName}:null},L=async function(){let e=I();if(!(!e||O)){k(!0);try{await Cq(e,{addPage:m,onCreated(e){F(e),window.location.hash=`#/${e}`,a()}}),k(!1)}catch(e){let t=e;zn.error(t instanceof Error?t.message:A({id:`tfi40B`})),k(!1)}}},R=!C&&!x&&w!==null,z=!C&&!x&&T?.kind===`navigate`&&T.displayState===`resolved`,B=!C&&!x&&T?.kind===`navigate`&&T.displayState===`folder`,ee=!C&&!x&&!w&&T?.kind===`create`,V=!!C,te=C?BU(C.url)?C.url:null:R&&w?Tn(w):z&&T?.kind===`navigate`?UU({docName:T.hashDocName,anchor:f}):null,H=!x&&te!==null&&(V||R||z),U,ne,W,re,G;if(t[9]!==A||t[10]!==d||t[11]!==f||t[12]!==w||t[13]!==n.state||t[14]!==n.view||t[15]!==C||t[16]!==r||t[17]!==R||t[18]!==B||t[19]!==z||t[20]!==ee||t[21]!==x||t[22]!==u){if(x){let e;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(oa,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),t[28]=e):e=t[28],W={icon:e,text:A({id:`yQE2r9`}),className:`text-muted-foreground/80`}}else if(C){let e;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(En,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[29]=e):e=t[29],W={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)(Ri,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[30]=e):e=t[30],W={icon:e,text:A({id:`bUUVED`}),className:`text-muted-foreground`}}else if(B){let e;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Wi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[31]=e):e=t[31],W={icon:e,text:A({id:`kNqMMd`}),className:`text-muted-foreground`}}else if(ee){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ei,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[32]=e):e=t[32],W={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)(Vi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[33]=e):e=t[33],W={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)(Ei,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[34]=e):e=t[34],W={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 zt(n.view,e,e+t.nodeSize)}catch{return new DOMRect}},t[35]=n.state,t[36]=n.view,t[37]=r,t[38]=e):e=t[38];let i;t[39]!==n.view.dom||t[40]!==e?(i={getBoundingClientRect:e,contextElement:n.view.dom},t[39]=n.view.dom,t[40]=e,t[41]=i):i=t[41],G=i,ne=w??(C?C.url:`${u}${f?`#${f}`:``}`);let a=f?`${u}#${f}`:u;U=d?`[[${a}|${d}]]`:`[[${a}]]`,re=Ut(`flex shrink-0`,W.className),t[9]=A,t[10]=d,t[11]=f,t[12]=w,t[13]=n.state,t[14]=n.view,t[15]=C,t[16]=r,t[17]=R,t[18]=B,t[19]=z,t[20]=ee,t[21]=x,t[22]=u,t[23]=U,t[24]=ne,t[25]=W,t[26]=re,t[27]=G}else U=t[23],ne=t[24],W=t[25],re=t[26],G=t[27];let ie;t[42]!==W.icon||t[43]!==re?(ie=(0,X.jsx)(`span`,{className:re,children:W.icon}),t[42]=W.icon,t[43]=re,t[44]=ie):ie=t[44];let ae=ie,oe;t[45]!==ae||t[46]!==ee||t[47]!==W.text?(oe=ee?(0,X.jsxs)(mr,{children:[(0,X.jsx)(sr,{asChild:!0,children:(0,X.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`wiki-link-prop-panel-icon-trigger`,children:ae})}),(0,X.jsx)(ur,{children:W.text})]}):ae,t[45]=ae,t[46]=ee,t[47]=W.text,t[48]=oe):oe=t[48];let K=oe,se=`${W.text}: ${ne}`,ce;t[49]!==ne||t[50]!==V||t[51]!==ee||t[52]!==te||t[53]!==H||t[54]!==a||t[55]!==s?(ce=(0,X.jsx)(sr,{asChild:!0,children:H?(0,X.jsx)(`a`,{href:te??void 0,...V?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>XU(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:ne}):(0,X.jsx)(`span`,{"data-slot":`wiki-link-prop-panel-text`,className:Ut(`block truncate text-sm font-medium`,ee?`text-muted-foreground`:`text-foreground`),children:ne})}),t[49]=ne,t[50]=V,t[51]=ee,t[52]=te,t[53]=H,t[54]=a,t[55]=s,t[56]=ce):ce=t[56];let q;t[57]===ne?q=t[58]:(q=(0,X.jsx)(ur,{className:`max-w-80 break-all`,children:ne}),t[57]=ne,t[58]=q);let ue;t[59]!==ce||t[60]!==q?(ue=(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(mr,{children:[ce,q]})}),t[59]=ce,t[60]=q,t[61]=ue):ue=t[61];let de;t[62]!==L||t[63]!==O||t[64]!==ee?(de=ee?(0,X.jsxs)(qt,{type:`button`,size:`sm`,variant:`link`,disabled:O,onClick:()=>void L(),"data-slot":`wiki-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,X.jsx)(ma,{className:`size-3.5`,"aria-hidden":`true`}),O?(0,X.jsx)(o,{id:`HM56Bx`}):(0,X.jsx)(o,{id:`XRuL0i`})]}):null,t[62]=L,t[63]=O,t[64]=ee,t[65]=de):de=t[65];let fe;t[66]===A?fe=t[67]:(fe=A({id:`ePK91l`}),t[66]=A,t[67]=fe);let pe;t[68]===D?pe=t[69]:(pe=()=>D(!0),t[68]=D,t[69]=pe);let me;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,X.jsx)(pa,{className:`size-3.5`,"aria-hidden":`true`}),t[70]=me):me=t[70];let he;t[71]!==fe||t[72]!==pe?(he=(0,X.jsx)(sr,{asChild:!0,children:(0,X.jsx)(qt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":fe,onClick:pe,"data-slot":`wiki-link-prop-panel-edit`,children:me})}),t[71]=fe,t[72]=pe,t[73]=he):he=t[73];let ge;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,X.jsx)(ur,{children:(0,X.jsx)(o,{id:`ePK91l`})}),t[74]=ge):ge=t[74];let _e;t[75]===he?_e=t[76]:(_e=(0,X.jsxs)(mr,{children:[he,ge]}),t[75]=he,t[76]=_e);let ve;t[77]===U?ve=t[78]:(ve=(0,X.jsx)(Kq,{copyContent:U}),t[77]=U,t[78]=ve);let be;t[79]===A?be=t[80]:(be=A({id:`t_YqKh`}),t[79]=A,t[80]=be);let xe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,X.jsx)(Ta,{className:`size-3.5`,"aria-hidden":`true`}),t[81]=xe):xe=t[81];let Se;t[82]!==P||t[83]!==be?(Se=(0,X.jsx)(sr,{asChild:!0,children:(0,X.jsx)(qt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":be,onClick:P,"data-slot":`wiki-link-prop-panel-remove`,children:xe})}),t[82]=P,t[83]=be,t[84]=Se):Se=t[84];let Ce;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,X.jsx)(ur,{children:(0,X.jsx)(o,{id:`t_YqKh`})}),t[85]=Ce):Ce=t[85];let we;t[86]===Se?we=t[87]:(we=(0,X.jsxs)(mr,{children:[Se,Ce]}),t[86]=Se,t[87]=we);let Ee;t[88]!==de||t[89]!==_e||t[90]!==ve||t[91]!==we?(Ee=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[de,_e,ve,we]}),t[88]=de,t[89]=_e,t[90]=ve,t[91]=we,t[92]=Ee):Ee=t[92];let De;t[93]!==K||t[94]!==ue||t[95]!==Ee?(De=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[K,ue,Ee]}),t[93]=K,t[94]=ue,t[95]=Ee,t[96]=De):De=t[96];let Oe;t[97]!==a||t[98]!==De||t[99]!==se||t[100]!==G?(Oe=(0,X.jsx)(pq,{kind:`wiki-link`,ariaLabel:se,onDeactivate:a,triggerReference:G,className:`w-96`,children:De}),t[97]=a,t[98]=De,t[99]=se,t[100]=G,t[101]=Oe):Oe=t[101];let ke;t[102]!==d||t[103]!==f||t[104]!==h||t[105]!==E||t[106]!==g||t[107]!==M||t[108]!==x||t[109]!==v||t[110]!==D||t[111]!==u?(ke=(0,X.jsx)(dZ,{open:E,target:u,alias:d,anchor:f,pages:v,assetPaths:h,filePaths:g,loading:x,onOpenChange:D,onSave:M}),t[102]=d,t[103]=f,t[104]=h,t[105]=E,t[106]=g,t[107]=M,t[108]=x,t[109]=v,t[110]=D,t[111]=u,t[112]=ke):ke=t[112];let Ae;return t[113]!==Oe||t[114]!==ke?(Ae=(0,X.jsxs)(X.Fragment,{children:[Oe,ke]}),t[113]=Oe,t[114]=ke,t[115]=Ae):Ae=t[115],Ae}var pZ=0;function mZ(){return`wiki-link-${++pZ}`}function hZ(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 gZ(e,t){if(!t||!e)return null;let n=UD(e,t);if(!n)return null;let r=t.pageIcons?.get(n);if(!r)return null;let i=aZ(r);return i.kind===`unsupported`?null:i}function _Z(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 vZ=_.extend({priority:200,addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=mZ(),{dom:i,iconSpan:a}=hZ({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=()=>{_Z(a,gZ(String(o.attrs.target??``),Ln()))};s();let c=On(s),l=()=>{let e=n();return typeof e==`number`?e:void 0},u=kO(e),d=({newTab:e})=>{let t=o.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=le(n,typeof t.anchor==`string`?t.anchor:null);if(!r)return!1;if(r.kind===`doc`){let t=Ln(),i=AU(n,{pages:t?.pages??new Set,folderPaths:t?.folderPaths??new Set,pagesBySlug:t?.pagesBySlug,pagesByBasename:t?.pagesByBasename,fallbackTargets:HD(n)});if(i.kind===`create`||i.kind===`navigate`&&i.displayState===`folder`)return!1;let a=i.kind===`navigate`?i.hashDocName:r.docName;return e?KU({docName:a,anchor:r.anchor}):window.location.assign(UU({docName:a,anchor:r.anchor})),!0}if(r.kind===`asset`){let t=Ln(),n=KD(r.url,t?.assetPaths??new Set,t?.filePaths)??r.url.replace(/^\//,``);return e?WU(Tn(n)):window.location.hash=Tn(n),!0}return BU(r.url)?(WU(r.url),!0):!1};return u.register({type:`wikiLink`,nodeId:r,getPos:l,controls:{propPanel:t=>(0,Q.createElement)(fZ,{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(gW.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(gW.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[jW(this.editor)]}}),yZ=0;function bZ(){return`wiki-link-embed-${++yZ}`}function xZ(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 SZ(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`,et(e.src)),t.setAttribute(`alt`,e.alias??e.target),{dom:t}}function CZ(e){let t=$e(e);return t!==null&&se.has(t)}var wZ=B.extend({addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=bZ(),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(CZ(a)){let{dom:e}=SZ({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(!CZ(n))return!1;let o=a??n;return e.setAttribute(`data-target`,n),e.setAttribute(`data-alias`,r??``),e.setAttribute(`src`,et(o)),e.setAttribute(`alt`,r??n),!0}}}let{dom:l}=xZ({nodeId:r,target:a,alias:o,anchor:s,href:c??a});l.addEventListener(`click`,e=>{e.preventDefault()});let u=()=>{let e=n();return typeof e==`number`?e:void 0},d=kO(e);return d.register({type:`wikiLinkEmbed`,nodeId:r,getPos:u,controls:{},handlePrimary:({newTab:e})=>{let t=i.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=(typeof t.resolvedSrc==`string`&&t.resolvedSrc.length>0?t.resolvedSrc:null)??n,a=$e(n);if(a===null)return!1;let o=gt(r,``)??n;return JU({url:r,projectRelPath:o,ext:a,title:o.split(`/`).pop()??r,newTab:e}),!0}}),{dom:l,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLinkEmbed`)return!1;i=e;let t=String(e.attrs.target??``);if(CZ(t))return!1;let n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor),a=(e.attrs.resolvedSrc==null?null:String(e.attrs.resolvedSrc))??t;return l.setAttribute(`data-target`,t),l.setAttribute(`data-alias`,n??``),l.setAttribute(`data-anchor`,r??``),l.setAttribute(`href`,a),l.setAttribute(`aria-label`,`Embed: ${t}${r?`#${r}`:``}`),l.textContent=n??`${t}${r?`#${r}`:``}`,!0},destroy:()=>{d.deregister(r)}}}}}),TZ=[...yt.map(e=>{if(e.name===`jsxComponent`)return vX;if(e.name===`image`){let t=e.options??{};return lq.configure({...t,inline:!0})}return e.name===`rawMdxFallback`?kX:e.name===`wikiLink`?vZ:e.name===`wikiLinkEmbed`?wZ:e.name===`link`?cJ:e.name===`mathInline`?EX:e.name===`tag`?nZ:e.name===`codeBlock`?lK:e}),PX.configure({itemsSources:[mM,aM,pM,cM],categoryLabels:{content:`Components`,layout:`Layout`,media:`Media`,data:`Data`,embed:`Embeds`}}),oq,RX,dD.configure({onDrop(e,t,n){for(let r of t)aO(r,e,n)},onPaste(e,t,n){for(let n of t)aO(n,e,e.state.selection.from)}}),sq,jD,XX,aq,rq,yM,KX,IX,hD,wM,LY,kt.create({name:`chunkWrapperDecoration`,addProseMirrorPlugins(){return[AM()]}})];function EZ(e){return e===ut}function DZ(){return uc(`SYNC_TIMEOUT_MS`,3e4)}var OZ=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}},kZ=class extends Error{docName;constructor(e){super(`Provider disconnected before sync for "${e}"`),this.name=`PreSyncDisconnectError`,this.docName=e}},AZ=class extends Error{docName;constructor(e){super(`Document not found: "${e}"`),this.name=`DocumentNotFoundError`,this.docName=e}},jZ=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}},MZ=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}},NZ=new Map,PZ=!1;function FZ(){for(let e of NZ.values())if(!e.settled)return!0;return!1}function IZ(){typeof document>`u`||document.visibilityState===`visible`&&LZ(Date.now())}function LZ(e){let t=[];for(let[n,r]of NZ){if(r.settled)continue;let i=e-r.createdAt;if(i<DZ())continue;r.settled=!0;let a=new OZ(n,i);VZ(r),r.reject(a);let o=Gx(n);o!==void 0&&nS(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 FZ()||zZ(),t.length}function RZ(){PZ||typeof document>`u`||(document.addEventListener(`visibilitychange`,IZ),PZ=!0)}function zZ(){PZ&&(typeof document>`u`||(document.removeEventListener(`visibilitychange`,IZ),PZ=!1))}var BZ=new Map;function VZ(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 HZ(e,t){let n=NZ.get(e);if(n)return n.promise;let r=BZ.get(e);if(r!==void 0){BZ.delete(e);let n=r===`timeout`?new OZ(e,0):new kZ(e);console.warn(`[syncPromise] ${e} rejected on creation (test hook, armed ${r}): ${n.message}`),$(`ok/sync/create`,{docName:e,mountId:Gx(e),warm:!1,armed:r}),$(`ok/sync/reject`,{docName:e,mountId:Gx(e),reason:`armed-${r}`});let i=WZ(n);return NZ.set(e,GZ(i,t)),i}if(t.synced){console.log(`[syncPromise] ${e} resolved synchronously (warm provider)`);let n=Gx(e);$(`ok/sync/create`,{docName:e,mountId:n,warm:!0}),$(`ok/sync/resolve`,{docName:e,mountId:n,elapsedMs:0,warm:!0}),$.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 NZ.set(e,UZ(r,t)),r}let i=Date.now(),a=()=>{},o=()=>{},s=new Promise((e,t)=>{a=e,o=t}),c=()=>{let t=NZ.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=Gx(e);if($(`ok/sync/resolve`,{docName:e,mountId:r,elapsedMs:n,warm:!1}),$.histogram(`ok/sync/resolve-elapsed-ms`,r===void 0?{docName:e}:{docName:e,mountId:r},n),VZ(t),FZ()||zZ(),t.resolve(),r!==void 0){let i=Date.now();tS(r,`ok.sync-promise`,{"doc.name":e,elapsed_ms:n},t.createdAt,i),nS(r,i)}},l=t=>{let n=NZ.get(e);if(!n||n.settled)return;n.settled=!0;let r=new kZ(e);console.warn(`[syncPromise] ${e} rejected: ${r.message}`);let i=Gx(e);$(`ok/sync/reject`,{docName:e,mountId:i,reason:`pre-sync-disconnect`}),VZ(n),FZ()||zZ(),n.reject(r),i!==void 0&&nS(i)},u=setTimeout(()=>{let t=NZ.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt,r=new OZ(e,n);console.warn(`[syncPromise] ${e} rejected: ${r.message}`);let i=Gx(e);$(`ok/sync/reject`,{docName:e,mountId:i,reason:`timeout`,elapsedMs:n}),VZ(t),FZ()||zZ(),t.reject(r),i!==void 0&&nS(i)},DZ()),d={promise:s,resolve:a,reject:o,createdAt:i,timeoutHandle:u,provider:t,onSynced:c,onClose:l,settled:!1,resolved:!1,detached:!1};return NZ.set(e,d),t.on(`synced`,c),t.on(`close`,l),RZ(),$(`ok/sync/create`,{docName:e,mountId:Gx(e),warm:!1}),s}function UZ(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!0,detached:!0}}function WZ(e){let t=Promise.reject(e);t.catch(()=>{});let n=t;return n.status=`rejected`,n.reason=e,n}function GZ(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!1,detached:!0}}function KZ(e){return NZ.get(e)?.resolved===!0}function qZ(e){let t=NZ.get(e);t&&(t.settled=!0,VZ(t),NZ.delete(e),FZ()||zZ())}function JZ(e,t){let n=NZ.get(e);if(!n||n.settled)return!1;n.settled=!0,console.warn(`[syncPromise] ${e} rejected: ${t.message}`),VZ(n),FZ()||zZ(),n.reject(t);let r=Gx(e);return r!==void 0&&nS(r),!0}var YZ=Object.freeze({kind:`tab-replay`}),XZ=Object.freeze({kind:`idle`});function ZZ(e,t){return()=>{}}var QZ=null;function $Z(){return QZ??=qe(TZ),QZ}var eQ=4e3,tQ=1e4,nQ=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`}},rQ=class extends Error{constructor(e,t){super(`stored-state epoch peek timed out for ${e} after ${t}ms`),this.docName=e,this.timeoutMs=t,this.name=`StoredEpochPeekTimeoutError`}},iQ=`ok-last-observed-branch`,aQ=`ok-doc-lineage-epochs`,oQ=5e3,sQ=uc(`MAX_BUFFER_BYTES`,1*1024*1024),cQ=uc(`MAX_POOL`,10),lQ=class{_entries=new Map;get entries(){return this._entries}lruOrder=[];activeDocName=null;maxSize;wsUrl;recycleDebounceMs;clearDataTimeoutMs;onChange=null;tabIdentity=null;serverRestartRecoveryState=XZ;cachedServerInstanceId=null;pendingServerInstanceKnown=null;recoveryMismatchStaleClaim;bufferedUpdates=new Map;pendingClears=new Map;clearFailures=new Set;persistenceFactory;peekStoredEpoch;storage;constructor(e,t,n){this.maxSize=e,this.wsUrl=t,this.recycleDebounceMs=n?.recycleDebounceMs??eQ,this.clearDataTimeoutMs=n?.clearDataTimeoutMs??tQ,this.persistenceFactory=n?.persistenceFactory??iD,this.peekStoredEpoch=n?.peekStoredLineageEpoch??aD,n?.storage===void 0?this.storage=globalThis.localStorage===void 0?null:globalThis.localStorage:this.storage=n.storage}setTabIdentity(e){this.tabIdentity=e}setExpectedServerInstanceId(e){if(this.cachedServerInstanceId=e,!(e===null||e.length===0)){if(this.pendingServerInstanceKnown!==null){let t=this.pendingServerInstanceKnown;this.pendingServerInstanceKnown=null,t.resolve(e)}this.attachDeferredPersistence(e)}}whenServerInstanceKnown(){if(this.cachedServerInstanceId!==null&&this.cachedServerInstanceId.length>0)return Promise.resolve(this.cachedServerInstanceId);if(this.pendingServerInstanceKnown!==null)return this.pendingServerInstanceKnown.promise;let e,t=new Promise(t=>{e=t});return this.pendingServerInstanceKnown={promise:t,resolve:e},t}buildPersistence(e,t,n){return this.persistenceFactory({branch:this.normalizedObservedBranch(),serverInstanceId:e,docName:t,doc:n})}async validateStoredStateThenAttach(e,t){if(e.persistenceAttachOwned)return;e.persistenceAttachOwned=!0;let n=e.docName,r=()=>this._entries.get(n)===e&&e.kind===`active`&&e.persistence===null&&!this.pendingClears.has(n);if(!r())return;let i;try{i=await new Promise((e,r)=>{let i=setTimeout(()=>{r(new rQ(n,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);this.peekStoredEpoch({branch:this.normalizedObservedBranch(),serverInstanceId:t,docName:n}).then(t=>{clearTimeout(i),e(t)},e=>{clearTimeout(i),r(e)})})}catch(e){this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`peek`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)});return}if(!r())return;if(i===null){this.attachValidatedPersistence(e,t);return}if(!e.hasSynced&&(await this.awaitFirstSyncOrDestroy(e),!r()||!e.hasSynced))return;let a=e.provider.document.getMap(`lifecycle`).get(dt),o=typeof a==`string`&&a.length>0?a:null;if(o===i){this.attachValidatedPersistence(e,t);return}this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(n),via:`stored-state-validation`,staleEpoch:i,liveEpoch:o??`<absent>`});let s=this.activeDocName===n;this.runCloseAndClearPersistence(n),this.open(n)!==null&&s&&this.setActive(n)}attachValidatedPersistence(e,t){let n=e.docName;try{let r=this.buildPersistence(t,n,e.provider.document);e.persistence=r,this.notify(),this.backfillCacheAfterFirstSync(e,r).catch(e=>{this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`backfill`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)})})}catch(e){this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`attach`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)})}}async backfillCacheAfterFirstSync(e,t){await t.whenSynced,e.hasSynced||await this.awaitFirstSyncOrDestroy(e),!(this._entries.get(e.docName)!==e||e.kind!==`active`||e.persistence!==t||!e.hasSynced)&&await t.flushFullState()}async awaitFirstSyncOrDestroy(e){e.hasSynced||await new Promise(t=>{let n=()=>{e.provider.off(`synced`,n),e.provider.off(`destroy`,n),t()};e.provider.on(`synced`,n),e.provider.on(`destroy`,n)})}attachDeferredPersistence(e){for(let t of Array.from(this._entries.values()))if(t.kind===`active`&&t.persistence===null&&this._entries.get(t.docName)===t){if(t.hasSynced&&t.lineageEpochRecordAtOpen!==null){let e=t.provider.document.getMap(`lifecycle`).get(dt);if(typeof e==`string`&&e.length>0&&e!==t.lineageEpochRecordAtOpen){let n=t.docName;this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(n),via:`deferred-attach`,staleEpoch:t.lineageEpochRecordAtOpen,liveEpoch:e});let r=this.activeDocName===n;this.runCloseAndClearPersistence(n),this.open(n)!==null&&r&&this.setActive(n);continue}}this.validateStoredStateThenAttach(t,e)}}getServerRestartRecoveryState(){return this.serverRestartRecoveryState}observeDiskAck(e,t){let n=this.entries.get(e);!n||n.kind!==`active`||(n.lastDiskAckedSV=cD(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(iQ)??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(iQ):this.storage?.setItem(iQ,e)}catch{}}docLineageEpochs=new Map;docLineageEpochsEnvelopeConsumed=!1;normalizedObservedBranch(){return this.getOrInitObservedBranch()??`_unknown_`}consumeLineageEpochEnvelopeIfValid(){if(this.docLineageEpochsEnvelopeConsumed)return;let e=this.cachedServerInstanceId;if(!(e===null||e.length===0)){this.docLineageEpochsEnvelopeConsumed=!0;try{let t=this.storage?.getItem(aQ)??null;if(t===null)return;let n=JSON.parse(t);if(typeof n!=`object`||!n)return;let r=n;if(r.branch!==this.normalizedObservedBranch()||r.serverInstanceId!==e||typeof r.epochs!=`object`||r.epochs===null)return;for(let[e,t]of Object.entries(r.epochs))typeof t==`string`&&t.length>0&&!this.docLineageEpochs.has(e)&&this.docLineageEpochs.set(e,t)}catch(e){e instanceof DOMException||console.warn(JSON.stringify({event:`ok-lineage-epoch-envelope-read-error`,errorName:e instanceof Error?e.name:typeof e,message:e instanceof Error?e.message:String(e)}))}}}getRecordedLineageEpoch(e){let t=this.docLineageEpochs.get(e);return t===void 0?(this.consumeLineageEpochEnvelopeIfValid(),this.docLineageEpochs.get(e)??null):t}persistLineageEpochEnvelope(){let e=this.cachedServerInstanceId;if(!(e===null||e.length===0))try{this.storage?.setItem(aQ,JSON.stringify({branch:this.normalizedObservedBranch(),serverInstanceId:e,epochs:Object.fromEntries(this.docLineageEpochs)}))}catch{}}recordLineageEpoch(e,t){this.docLineageEpochs.get(e)!==t&&(this.docLineageEpochs.set(e,t),this.persistLineageEpochEnvelope())}deleteLineageEpochRecord(e){this.docLineageEpochs.delete(e)&&this.persistLineageEpochEnvelope()}withClearDataTimeout(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>{r(new nQ(e,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);t.then(()=>{clearTimeout(i),n()},e=>{clearTimeout(i),r(e)})})}recoveryTelemetryBase(e,t){let n={docName:e,branch:this.normalizedObservedBranch()},r=t===void 0?this.recoveryMismatchStaleClaim:t;return r!==void 0&&r.length>0&&(n.serverInstanceId=r),n}emitStructuredClientRecoveryEvent(e){console.warn(JSON.stringify(e))}clearRecoveryMismatchStaleClaimIfTerminal(){let e=this.serverRestartRecoveryState.kind;(e===`idle`||e===`failed`)&&(this.recoveryMismatchStaleClaim=void 0)}beginServerRestartRecovery(e,t){this.serverRestartRecoveryState={kind:`recovering`,phase:`clearing-local-cache`,docNames:e,failedDocNames:[],startedAt:t};for(let t of e)qZ(t);this.notify()}enterServerRestartReconnect(e,t,n,r){if(e.length===0){this.serverRestartRecoveryState=t.length===0?XZ:{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=XZ,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(EZ(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(),$(`ok/pool/open`,{docName:e,hit:!0,lastAccessedAt:n,poolEventId:t.poolEventId}),$.count(`ok/pool/open`,{hit:!0}),t}let n=Date.now();this.entries.size>=this.maxSize&&this.evictLru();let r=this.cachedServerInstanceId,i=this.getRecordedLineageEpoch(e),a=AE(this.tabIdentity,r,this.getOrInitObservedBranch(),r!==null&&r.length>0?i:null),o=new kE({url:lD(this.wsUrl),name:e,forceSyncInterval:oQ,token:a}),s=this.cachedServerInstanceId;this.clearFailures.has(e)&&this.runCloseAndClearPersistence(e);let c=this.pendingClears.get(e),l=s!==null&&s.length>0&&c===void 0&&i!==null?this.buildPersistence(s,e,o.document):null,u=crypto.randomUUID(),d={kind:`active`,provider:o,persistence:l,lastServerSyncedSV:null,lastDiskAckedSV:null,observerCleanup:null,observerFireCounterCleanup:ZZ(o.document,e),syncState:`connecting`,docName:e,lastAccessedAt:Date.now(),poolEventId:u,hasSynced:!1,pendingRecycleTimer:null,bridgeSetupFailed:!1,serverDrivenCloseReauthInFlight:!1,persistenceAttachOwned:!1,lineageEpochRecordAtOpen:i};if($(`ok/pool/open`,{docName:e,hit:!1,poolEventId:u}),$.count(`ok/pool/open`,{hit:!1}),o.on(`status`,({status:t})=>{d.kind!==`active`||this.entries.get(e)!==d||t===`disconnected`&&(d.syncState=`disconnected`,this.notify())}),o.on(`synced`,()=>{if(d.kind!==`active`||this.entries.get(e)!==d)return;d.syncState=`synced`,d.hasSynced=!0,d.lastServerSyncedSV=oD(o.document);let t=o.document.getMap(`lifecycle`).get(dt);if(typeof t==`string`&&t.length>0&&this.recordLineageEpoch(e,t),d.pendingRecycleTimer&&=(clearTimeout(d.pendingRecycleTimer),null),this.markServerRestartRecoverySynced(e),this.notify(),!d.observerCleanup)try{let t=o.document,n=new ge({extensions:TZ});d.observerCleanup=dU({doc:t,xmlFragment:t.getXmlFragment(`default`),ytext:t.getText(`source`),mdManager:n,schema:$Z(),onSyncError:(t,n)=>{console.warn(`[Sync] ${t} failed for ${e}:`,n.message)}})}catch(t){console.error(`[ProviderPool] setupObservers init failed for ${e}:`,t),d.bridgeSetupFailed=!0,JZ(e,new jZ(e,t))}}),o.on(`disconnect`,()=>{d.kind!==`active`||this.entries.get(e)!==d||(d.syncState=`disconnected`,this.notify(),d.hasSynced&&o.unsyncedChanges===0&&!d.pendingRecycleTimer&&(d.pendingRecycleTimer=setTimeout(()=>{d.kind===`active`&&(d.pendingRecycleTimer=null,this.entries.get(e)===d&&this.recycleDisconnectedEntry(e))},this.recycleDebounceMs)))}),o.on(`authenticationFailed`,({reason:t})=>{let n=[`server-instance-mismatch`,`branch-mismatch`,`rename-redirect`,`doc-deleted`,`doc-lineage-mismatch`],i=t.indexOf(`:`),a=i===-1?t:t.slice(0,i);if(!n.includes(a)){console.warn(JSON.stringify({event:`ok-auth-failed-unknown-reason`,reason:t}));return}let o=i===-1?``:t.slice(i+1),s=o.length>0?o:void 0,c=a;if(c===`server-instance-mismatch`){if(r===null||this.cachedServerInstanceId!==r)return;let e=r;this.cachedServerInstanceId=null,this.handleServerInstanceMismatch(e);return}if(c===`branch-mismatch`){this.onBranchMismatch?.();return}if(c===`rename-redirect`){if(s===void 0||s.length===0){console.warn(JSON.stringify({event:`rename-redirect-missing-payload`,fromDocName:e}));return}let t=e,n=s;this.deleteLineageEpochRecord(t);let r=this.entries.get(t),i=r!==void 0&&r.kind===`active`;this.onRenameRedirect?.({fromDocName:t,toDocName:n,hadOpenProvider:i});return}if(c===`doc-deleted`){this.deleteLineageEpochRecord(e);let t=this.entries.get(e),n=t!==void 0&&t.kind===`active`;this.onDocDeleted?.({docName:e,hadOpenProvider:n});return}if(c===`doc-lineage-mismatch`){if(d.kind!==`active`||this.entries.get(e)!==d)return;this.deleteLineageEpochRecord(e),this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(e),via:`auth-rejection`,staleEpoch:d.lineageEpochRecordAtOpen??``});let t=this.activeDocName===e;this.runCloseAndClearPersistence(e),this.open(e)!==null&&t&&this.setActive(e);return}}),o.on(`close`,({event:t})=>{if(d.kind!==`active`||this.entries.get(e)!==d||d.serverDrivenCloseReauthInFlight)return;d.serverDrivenCloseReauthInFlight=!0,o.sendToken().catch(t=>{console.warn(JSON.stringify({event:`ok-provider-server-driven-close-reauth-failed`,docName:e,message:t instanceof Error?t.message:String(t)}))}).finally(()=>{d.kind===`active`&&this.entries.get(e)===d&&(d.serverDrivenCloseReauthInFlight=!1)});let n=t?.reason??`<unknown>`;console.info(JSON.stringify({event:`ok-provider-server-driven-close-reauth`,docName:e,reason:n}))}),this.bufferedUpdates.get(e)!==void 0){let t=this.recoveryMismatchStaleClaim,n=()=>{if(o.off(`synced`,n),d.kind!==`active`||this.entries.get(e)!==d)return;let r=this.bufferedUpdates.get(e);if(r!==void 0){this.bufferedUpdates.delete(e);try{Jm(o.document,r,YZ)}catch(n){let i=n instanceof Error?n.name:`non-error-throw`;this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-failed`,...this.recoveryTelemetryBase(e,t),replayByteLength:r.byteLength,errorName:i,errorMessage:n instanceof Error?n.message:String(n)})}}};o.on(`synced`,n)}if(this._entries.set(e,d),this.touch(e),this.notify(),l===null&&s!==null&&s.length>0&&c===void 0&&this.validateStoredStateThenAttach(d,s),c!==void 0&&s!==null&&s.length>0){let t=s;c.then(()=>{this.attachDeferredPersistenceForEntry(d,t)},t=>{console.warn(JSON.stringify({event:`ok-pool-deferred-persistence-attach-skipped`,docName:e,reason:`pending-clear-failed`,message:t instanceof Error?t.message:String(t)}))})}let f=Gx(e);return f!==void 0&&tS(f,`ok.provider-pool.open`,{"doc.name":e},n,Date.now()),d}attachDeferredPersistenceForEntry(e,t){let n=this._entries.get(e.docName);n!==e||n.kind!==`active`||n.persistence!==null||this.validateStoredStateThenAttach(n,t)}handleServerInstanceMismatch(e){this.recoveryMismatchStaleClaim=e.length>0?e:void 0;let t=Array.from(this.entries.entries()),n=Date.now(),r=this.activeDocName,i=r!==null&&t.some(([e,t])=>e===r&&t.kind===`active`)?[r]:[],a=r??t.find(([,e])=>e.kind===`active`)?.[0]??``;a.length>0&&this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-epoch-mismatch`,...this.recoveryTelemetryBase(a)}),this.beginServerRestartRecovery(i,n);for(let[e,n]of t)n.kind===`active`&&!i.includes(e)&&qZ(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=sD(n.provider.document,t);if(r.byteLength>sQ){$(`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 nQ;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(EZ(e))return null;let t=this.entries.get(e);if(t)return t;let n=this.open(e);if(!n)return null;let r=this.lruOrder.indexOf(e);return r!==-1&&(this.lruOrder.splice(r,1),this.lruOrder.unshift(e)),n}close(e){let t=this.entries.get(e);t&&(this.destroyEntry(t),this._entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),this.bufferedUpdates.delete(e),this.activeDocName===e&&(this.activeDocName=null),this.notify())}async closeAndClearPersistence(e){try{await this.runCloseAndClearPersistence(e)}catch{}}runCloseAndClearPersistence(e){let t=this.pendingClears.get(e);if(t!==void 0)return t;let n=()=>{},r=()=>{},i=new Promise((e,t)=>{n=e,r=t});this.pendingClears.set(e,i);let a=()=>{this.pendingClears.get(e)===i&&this.pendingClears.delete(e)};return i.then(a,a),this.executeCloseAndClearPersistence(e).then(n,r),i}async executeCloseAndClearPersistence(e){this.clearFailures.delete(e);let t=this.entries.get(e);if(t?.kind===`active`&&t.persistence!==null){let n=t.persistence;try{this.close(e)}catch(t){console.warn(`[ProviderPool] close before clearData threw for ${e}:`,t)}try{await this.withClearDataTimeout(e,n.clearData())}catch(t){throw console.warn(`[ProviderPool] clearData on rename failed for ${e}:`,t),this.clearFailures.add(e),t}return}if(t)try{this.close(e)}catch(t){console.warn(`[ProviderPool] close before IDB-by-name delete threw for ${e}:`,t)}let n=this.normalizedObservedBranch(),r=this.cachedServerInstanceId;if(r===null)return;let i=`ok-ydoc:${n}:${r}:${e}`;try{await this.withClearDataTimeout(e,new Promise((e,t)=>{let n=indexedDB.deleteDatabase(i);n.onsuccess=()=>e(),n.onerror=()=>t(n.error),n.onblocked=()=>{console.warn(`[ProviderPool] IDB delete blocked for ${i}`)}}))}catch(t){throw console.warn(`[ProviderPool] IDB delete on rename failed for ${i}:`,t),this.clearFailures.add(e),t}}clearBufferedUpdates(){this.bufferedUpdates.clear()}__test_seedBufferedUpdate(e,t){this.bufferedUpdates.set(e,t)}__test_bufferedUpdatesSize(){return this.bufferedUpdates.size}__test_hasBufferedUpdate(e){return this.bufferedUpdates.has(e)}__test_getBufferedUpdate(e){return this.bufferedUpdates.get(e)}setActive(e){let t=this.entries.get(e);if(!t)throw Error(`[ProviderPool] Cannot setActive — "${e}" is not open`);t.lastAccessedAt=Date.now(),this.touch(e),this.activeDocName=e,this.notify()}clearActive(){this.activeDocName!==null&&(this.activeDocName=null,this.notify())}getActive(){return this.activeDocName?this.entries.get(this.activeDocName)??null:null}getActiveDocName(){return this.activeDocName}has(e){return this.entries.has(e)}peek(e){return this.entries.get(e)??null}recycle(e){this.recycleDisconnectedEntry(e)}dispose(){for(let e of this._entries.values())this.destroyEntry(e);this._entries.clear(),this.lruOrder=[],this.activeDocName=null,this.onChange=null,this.bufferedUpdates.clear(),this.pendingClears.clear(),this.clearFailures.clear(),this.docLineageEpochs.clear(),this.docLineageEpochsEnvelopeConsumed=!1,this.onBranchMismatch=null,this.branchMismatchInFlight=null,this.onRenameRedirect=null,this.onDocDeleted=null,this.evictListeners.clear(),this.serverRestartRecoveryState=XZ,this.cachedServerInstanceId=null,this.pendingServerInstanceKnown=null,this.tabIdentity=null,this.recoveryMismatchStaleClaim=void 0}evictLru(){for(let e of this.lruOrder)if(e!==this.activeDocName){$(`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),qZ(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($(`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()}},uQ=crypto.randomUUID(),dQ=!1;function fQ(e){dQ||(dQ=!0,console.warn(`[principal-fetch] failed to resolve principal — falling back to random identity.`,e))}var pQ=(0,Q.createContext)(null),mQ=null;function hQ(e){return mQ||(mQ=new lQ(cQ,e),tC(mQ)),mQ}var gQ={activeDocName:null,activeProvider:null,syncState:`connecting`,serverRestartRecovery:{kind:`idle`},poolEntries:[]};function _Q(){if(typeof window>`u`)return null;let e=window.okDesktop;return e?.config.mode===`editor`?e:null}function vQ(){return typeof window>`u`||window.okDesktop?.config.mode===`editor`?null:WC(window.location.origin)}function yQ(){if(typeof window>`u`)return HC(null,cQ);let e=vQ();return e?GC(window.localStorage===void 0?null:window.localStorage,e,cQ):HC(null,cQ)}function bQ(){return yQ().openTabs}function xQ(){return yQ().pinnedTabIds}function SQ(){if(typeof window>`u`||window.location.hash.length>0)return null;let e=yQ();return e.activeTabId??(e.activeDocName?fC(e.activeDocName):null)??e.openTabs[0]??null}function CQ(e){let t=bC(e);switch(t.kind){case`doc`:return xn(t.docName);case`folder`:return Cn(t.folderPath);case`asset`:return Tn(t.assetPath)}}function wQ(e){let t=yn(e);if(t)return _C(t);let n=Mn(e);if(!n)return null;let r=n.trim();if(/\/+$/.test(r)){let e=r.replace(/\/+$/g,``);return e?gC(e):null}return fC(n)}function TQ(e){return{kind:`asset`,target:e,assetPath:e,mediaKind:w(e.split(`.`).pop()??``)}}function EQ(e,t){return e?yC(e):t?fC(t):null}function DQ(e,t,n){return e.some(e=>!n.has(e)&&xC(e)===t)}function OQ(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function kQ(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 AQ(e,t){return e===t?!0:!e||!t?!1:kQ(e)===kQ(t)}function jQ(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 MQ(e){let t=(0,Z.c)(175),{children:n}=e,[r,i]=(0,Q.useState)(gQ),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(SQ),[l,u]=(0,Q.useState)(bQ),[d,f]=(0,Q.useState)(xQ),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[0]=p):p=t[0];let[m,h]=(0,Q.useState)(p),[g,_]=(0,Q.useState)(l),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),S=(0,Q.useRef)(s),C=(0,Q.useRef)(l),w=(0,Q.useRef)(d),T=(0,Q.useRef)(v),E=(0,Q.useRef)(m),D=(0,Q.useRef)(g),O=(0,Q.useRef)(1),k=(0,Q.useRef)(!1),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(`doc`),[R,z]=(0,Q.useState)(null),[B,ee]=(0,Q.useState)(0),{collabUrl:V,terminal:te,lastError:H,retry:U}=Mx(),ne;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(ne=function(e){S.current=e,c(e)},t[1]=ne):ne=t[1];let W=ne,re;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(re=function(e){T.current=e,y(e)},t[2]=re):re=t[2];let G=re,ie;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(ie=function(e){D.current=e,_(t=>OQ(t,e)?t:e)},t[3]=ie):ie=t[3];let ae=ie,oe;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(oe=function(e){w.current=e,f(t=>OQ(t,e)?t:e)},t[4]=oe):oe=t[4];let K=oe,se;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(se=function(e,t){let n=CC(t,e);C.current=e,w.current=n,u(t=>OQ(t,e)?t:e),f(e=>OQ(e,n)?e:n),ae(PC(D.current,e,E.current))},t[5]=se):se=t[5];let ce=se,q;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(q=function(e){ce(e,w.current)},t[6]=q):q=t[6];let le=q,ue;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(ue=function(e){le(e(C.current))},t[7]=ue):ue=t[7];let de=ue,fe;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(fe=function(e){E.current=e,h(t=>OQ(t,e)?t:e),ae(PC(D.current,C.current,e))},t[8]=fe):fe=t[8];let pe=fe,me;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(me=function(e){let t=T.current;if(!t)return;let n=E.current.filter(e=>e!==t);E.current=n,h(e=>OQ(e,n)?e:n),G(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))}ae(PC(r,C.current,n))},t[9]=me):me=t[9];let he=me,ge,_e;t[10]===s?(ge=t[11],_e=t[12]):(ge=()=>{S.current=s},_e=[s],t[10]=s,t[11]=ge,t[12]=_e),(0,Q.useEffect)(ge,_e);let ve,ye;t[13]===l?(ve=t[14],ye=t[15]):(ve=()=>{C.current=l},ye=[l],t[13]=l,t[14]=ve,t[15]=ye),(0,Q.useEffect)(ve,ye);let be,xe;t[16]===d?(be=t[17],xe=t[18]):(be=()=>{w.current=d},xe=[d],t[16]=d,t[17]=be,t[18]=xe),(0,Q.useEffect)(be,xe);let Se,Ce;t[19]===v?(Se=t[20],Ce=t[21]):(Se=()=>{T.current=v},Ce=[v],t[19]=v,t[20]=Se,t[21]=Ce),(0,Q.useEffect)(Se,Ce);let we,Te;t[22]===m?(we=t[23],Te=t[24]):(we=()=>{E.current=m},Te=[m],t[22]=m,t[23]=we,t[24]=Te),(0,Q.useEffect)(we,Te);let Ee,De;t[25]===g?(Ee=t[26],De=t[27]):(Ee=()=>{D.current=g},De=[g],t[25]=g,t[26]=Ee,t[27]=De),(0,Q.useEffect)(Ee,De);let Oe=v!==null,ke,Ae;t[28]!==V||t[29]!==A||t[30]!==b?(ke=()=>{if(V===null||b||!A)return;let e=!1,t=_Q(),n=vQ(),r=typeof localStorage<`u`?localStorage:null;return(t?t.project.getSessionState():Promise.resolve(n?GC(r,n,cQ):{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null})).then(t=>{if(e)return;let n=HC(t,cQ);if(k.current)return;let r=hQ(V);for(let e of n.openTabs){let t=xC(e);t&&r.open(t)}let i=[...n.pinnedTabIds,...w.current],a=n.openTabs;for(let e of C.current)a=kC(a,e,cQ,i);let o=CC(i,a);C.current=a,w.current=o,u(e=>OQ(e,a)?e:a),f(e=>OQ(e,o)?e:o);let s=PC(D.current,a,E.current);D.current=s,_(e=>OQ(e,s)?e:s);let l=Mn(window.location.hash),d=n.activeTabId??(n.activeDocName?fC(n.activeDocName):null)??n.openTabs[0]??null,p=d?CQ(d):null;if((l===null&&window.location.hash.length===0||p!==null&&p===window.location.hash)&&d){S.current=d,c(d);let e=CQ(d);window.location.hash!==e&&(window.location.hash=e)}}).catch(HQ).finally(()=>{e||x(!0)}),()=>{e=!0}},Ae=[V,A,b],t[28]=V,t[29]=A,t[30]=b,t[31]=ke,t[32]=Ae):(ke=t[31],Ae=t[32]),(0,Q.useEffect)(ke,Ae);let je,Me;t[33]!==s||t[34]!==a||t[35]!==l||t[36]!==d||t[37]!==r.activeDocName||t[38]!==b?(je=()=>{if(!b)return;let e=UC(l,s??EQ(a,r.activeDocName),d),t=_Q();if(t){t.project.setSessionState(e).catch(VQ);return}let n=vQ();n&&KC(typeof localStorage<`u`?localStorage:null,n,e)},Me=[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]=je,t[40]=Me):(je=t[39],Me=t[40]),(0,Q.useEffect)(je,Me);let Ne;t[41]===b?Ne=t[42]:(Ne=function(){b||(k.current=!0)},t[41]=b,t[42]=Ne);let Pe=Ne,Fe,Ie;t[43]===V?(Fe=t[44],Ie=t[45]):(Fe=()=>{if(V===null)return;let e=!1;j(!1);let t=hQ(V);i(jQ(t));let n=function(e,t){let n=CC(t,e);C.current=e,w.current=n,u(t=>OQ(t,e)?t:e),f(e=>OQ(e,n)?e:n);let r=PC(D.current,e,E.current);D.current=r,_(e=>OQ(e,r)?e:r)};return t.setOnBranchMismatch(()=>hx(t)),t.setOnRenameRedirect(e=>{let{fromDocName:r,toDocName:i,hadOpenProvider:a}=e;(async()=>{let e,s=t.getActiveDocName()===r;FS([{fromDocName:r,toDocName:i}]);try{await Promise.all([t.closeAndClearPersistence(r),t.closeAndClearPersistence(i)]),s&&(t.open(i),t.setActive(i));let e=IC(C.current,[{fromDocName:r,toDocName:i}],cQ,[],w.current),a=CC(IC(w.current,[{fromDocName:r,toDocName:i}],2**53-1),e);D.current=LC(D.current,[{fromDocName:r,toDocName:i}]),n(e,a),o(e=>e&&(Dn(e)===r?{kind:`doc`,target:i,docName:i}:e)),s&&(window.location.hash=xn(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(NC(C.current,r),w.current),o(e=>e&&(Dn(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(jQ(t))),fetch(`/api/principal`).then(BQ).then(n=>{if(e)return;let r=Ge.safeParse(n);r.success?(t.setTabIdentity({principalId:r.data.id,tabSessionId:uQ}),N(r.data)):fQ(r.error)}).catch(t=>{e||fQ(t)}).finally(()=>{e||j(!0)}),hx(t),()=>{e=!0,t.setOnChange(null),t.setOnRenameRedirect(null),t.setOnDocDeleted(null)}},Ie=[V],t[43]=V,t[44]=Fe,t[45]=Ie),(0,Q.useEffect)(Fe,Ie);let Le;t[46]===V?Le=t[47]:(Le=e=>{if($(`ok/nav/open-document`,{docName:e,transition:!1}),V===null)return;let t=hQ(V),n=t.open(e);if(!n)return;ax(e,n.poolEventId);let r=fC(e);de(e=>kC(e,r,cQ,w.current)),he(r),W(r),t.setActive(e),o({kind:`doc`,target:e,docName:e})},t[46]=V,t[47]=Le);let Re=Le,ze;t[48]===Re?ze=t[49]:(ze=e=>{$(`ok/nav/open-document`,{docName:e,transition:!1}),Re(e)},t[48]=Re,t[49]=ze);let Be=ze,Ve;t[50]!==a||t[51]!==V||t[52]!==Pe||t[53]!==r.activeDocName?(Ve=(e,t)=>{let n=t===void 0?{}:t;if(V===null)return;n.tabBehavior===`replace-active`&&Pe();let i=hQ(V),s=Dn(e),c=T.current,l=c!==null&&n.tabBehavior===`replace-active`,u=c?null:S.current??EQ(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;ax(s,e.poolEventId);let t=l?mC(C.current,s):null,n=l?{activeTabId:t??fC(s),tabs:kC(C.current,t??fC(s),cQ,w.current)}:jC(C.current,s,{behavior:p,currentTabId:u,limit:cQ,pinnedTabIds:w.current});le(n.tabs),he(n.activeTabId),W(n.activeTabId),i.setActive(s)}else{i.clearActive();let t=yC(e);if(t){let e=MC(C.current,t,{behavior:p,currentTabId:u,limit:cQ,pinnedTabIds:w.current});le(e.tabs),W(e.activeTabId),he(e.activeTabId)}else he(t)}o(t=>AQ(t,e)?t:e)},t[50]=a,t[51]=V,t[52]=Pe,t[53]=r.activeDocName,t[54]=Ve):Ve=t[54];let He=Ve,Ue;t[55]===He?Ue=t[56]:(Ue=(e,t)=>{He(e,t===void 0?{}:t)},t[55]=He,t[56]=Ue);let We=Ue,Ke;t[57]===He?Ke=t[58]:(Ke=(e,t)=>{let n=t===void 0?{}:t;$(`ok/nav/open-target`,{docName:Dn(e),kind:e.kind,transition:!1}),He(e,n)},t[57]=He,t[58]=Ke);let qe=Ke,Je;t[59]!==s||t[60]!==a||t[61]!==V||t[62]!==Pe||t[63]!==r.activeDocName?(Je=e=>{if(w.current.includes(e))return;Pe();let t=null,n=xC(e);if(V!==null){let t=hQ(V);n&&!DQ(C.current,n,new Set([e]))&&t.close(n)}let i=s??EQ(a,r.activeDocName);if(de(n=>(t=BC(n,i,e),NC(n,e))),i===e){if(t){W(t),window.location.hash=CQ(t);return}V!==null&&hQ(V).clearActive(),o(null),W(null),window.location.hash=``}},t[59]=s,t[60]=a,t[61]=V,t[62]=Pe,t[63]=r.activeDocName,t[64]=Je):Je=t[64];let Ye=Je,Xe;t[65]!==V||t[66]!==Pe?(Xe=e=>{Pe();let t=E.current;if(!t.includes(e))return;let n=t.filter(t=>t!==e);if(pe(n),T.current!==e)return;let r=t.indexOf(e),i=n[r]??n[r-1]??null;if(i){G(i),V!==null&&hQ(V).clearActive(),o(null),W(null),window.location.hash!==``&&(window.location.hash=``);return}G(null);let a=C.current[C.current.length-1]??null;if(a){W(a),window.location.hash=CQ(a);return}V!==null&&hQ(V).clearActive(),o(null),W(null),window.location.hash=``},t[65]=V,t[66]=Pe,t[67]=Xe):Xe=t[67];let Ze=Xe,Qe;t[68]!==Ze||t[69]!==Ye?(Qe=()=>{let e=T.current;if(e)return Ze(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 Ye(r),!0;let i=new Set(E.current),a=D.current.find(e=>i.has(e));return a?(Ze(a),!0):!1},t[68]=Ze,t[69]=Ye,t[70]=Qe):Qe=t[70];let $e=Qe,et,tt;t[71]===$e?(et=t[72],tt=t[73]):(et=()=>{let e=_Q();if(e)return e.onMenuAction(e=>{e===`close-active-tab-or-window`&&($e()||window.close())})},tt=[$e],t[71]=$e,t[72]=et,t[73]=tt),(0,Q.useEffect)(et,tt);let nt;t[74]===V?nt=t[75]:(nt=()=>{if(V===null){o(zQ),S.current=null,c(RQ);return}let e=hQ(V);e.getActiveDocName()!==null&&e.clearActive(),o(LQ),S.current=null,c(IQ)},t[74]=V,t[75]=nt);let rt;t[76]!==V||t[77]!==Pe?(rt=e=>{V!==null&&(Pe(),hQ(V).close(e),de(t=>NC(t,fC(e))),c(t=>{let n=t&&xC(t)===e?null:t;return S.current=n,n}),o(t=>t&&(Dn(t)===e?null:t)))},t[76]=V,t[77]=Pe,t[78]=rt):rt=t[78];let it;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(it=e=>{let t=TC(w.current,e,C.current);OQ(w.current,t)||K(t)},t[79]=it):it=t[79];let at;t[80]===Pe?at=t[81]:(at=e=>{let t=EC(w.current,e);OQ(w.current,t)||(Pe(),K(t))},t[80]=Pe,t[81]=at);let ot;t[82]===V?ot=t[83]:(ot=e=>{let t=bC(e);if(G(null),W(e),t.kind===`doc`){if(V!==null){let e=hQ(V);if(!e.open(t.docName))return;e.setActive(t.docName)}o({kind:`doc`,target:t.docName,docName:t.docName});let e=xn(t.docName);window.location.hash!==e&&(window.location.hash=e);return}if(V!==null&&hQ(V).clearActive(),t.kind===`asset`){o(TQ(t.assetPath));let e=Tn(t.assetPath);window.location.hash!==e&&(window.location.hash=e);return}o({kind:`folder`,target:t.folderPath,folderPath:t.folderPath});let n=Cn(t.folderPath);window.location.hash!==n&&(window.location.hash=n)},t[82]=V,t[83]=ot);let st;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(st=(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=OQ(C.current,a),l=OQ(E.current,o),u=OQ(D.current,s);c&&l&&u||(D.current=s,l||(E.current=o,h(e=>OQ(e,o)?e:o)),ce(a,OC(a,w.current,t)))},t[84]=st):st=t[84];let ct,lt;t[85]===V?(ct=t[86],lt=t[87]):(ct=()=>{let e=`new-tab:${O.current}`;O.current+=1,pe([...E.current,e]),G(e),V!==null&&hQ(V).clearActive(),o(null),W(null),window.location.hash!==``&&(window.location.hash=``)},lt=e=>{E.current.includes(e)&&(V!==null&&hQ(V).clearActive(),o(null),W(null),G(e),window.location.hash!==``&&(window.location.hash=``))},t[85]=V,t[86]=ct,t[87]=lt);let ut;t[88]!==s||t[89]!==a||t[90]!==V||t[91]!==Pe||t[92]!==r.activeDocName?(ut=(e,t)=>{let n=t===void 0?{}:t,i=e.filter(FQ),c=new Set(n.force?i:DC(i,w.current));if(c.size===0)return;if(Pe(),V!==null){let e=hQ(V),t=new Map;for(let e of c){let n=xC(e);if(!n)continue;let r=t.get(n)??new Set;r.add(e),t.set(n,r)}for(let[n,r]of t)DQ(C.current,n,r)||e.close(n)}let l=null,u=s??EQ(a,r.activeDocName);if(de(e=>(l=VC(e,u,c),e.filter(e=>!c.has(e)))),!u||!c.has(u)){u||o(e=>{if(!e)return e;let t=yC(e);return t&&c.has(t)?null:e});return}if(l){W(l),window.location.hash=CQ(l);return}V!==null&&hQ(V).clearActive(),o(null),W(null),window.location.hash=``},t[88]=s,t[89]=a,t[90]=V,t[91]=Pe,t[92]=r.activeDocName,t[93]=ut):ut=t[93];let dt;t[94]!==s||t[95]!==a||t[96]!==V||t[97]!==Pe||t[98]!==l||t[99]!==r.activeDocName?(dt=e=>{let{pages:t,folderPaths:n,assetPaths:i}=e,c=FC(l,{pages:t,folderPaths:n,assetPaths:i,keepMissingDocName:a?.kind===`missing`?a.target:null,keepHashDocName:typeof window<`u`?Mn(window.location.hash):null});if(c.length===l.length)return;let u=new Set(c),d=l.filter(e=>!u.has(e)),f=new Set(d);if(Pe(),V!==null){let e=hQ(V);for(let t of d){let n=xC(t);n&&e.close(n)}}le(c);let p=typeof window<`u`?wQ(window.location.hash):null,m=s??EQ(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=yC(e);return t&&f.has(t)?null:e});return}let g=VC(l,h,d);if(g){W(g),window.location.hash=CQ(g);return}V!==null&&hQ(V).clearActive(),o(null),W(null),window.location.hash=``},t[94]=s,t[95]=a,t[96]=V,t[97]=Pe,t[98]=l,t[99]=r.activeDocName,t[100]=dt):dt=t[100];let ft;t[101]!==V||t[102]!==Pe?(ft=(e,t,n)=>{let r=t===void 0?[]:t,i=n===void 0?[]:n;Pe();let a=IC(C.current,e,cQ,r,w.current,i),o=CC(IC(w.current,e,2**53-1,r,[],i),a);if(V!==null){let e=hQ(V);for(let t of a){let n=xC(t);n&&e.open(n)}}D.current=LC(D.current,e,r,i),ce(a,o);let s=S.current;if(s){let t=IC([s],e,1,r,[],i)[0];t&&a.includes(t)&&W(t)}},t[101]=V,t[102]=Pe,t[103]=ft):ft=t[103];let pt,mt,ht,gt,_t;t[104]===V?(pt=t[105],mt=t[106],ht=t[107],gt=t[108],_t=t[109]):(pt=async e=>{V!==null&&(await hQ(V).closeAndClearPersistence(e),o(t=>t&&(Dn(t)===e?null:t)))},mt=()=>V===null?null:hQ(V).getActiveDocName(),ht=e=>V===null?!1:hQ(V).has(e),gt=e=>{V!==null&&hQ(V).recycle(e)},_t=e=>V===null?null:hQ(V).prewarm(e)?.poolEventId??null,t[104]=V,t[105]=pt,t[106]=mt,t[107]=ht,t[108]=gt,t[109]=_t);let vt,yt,bt,xt,St;t[110]===V?(vt=t[111],yt=t[112],bt=t[113],xt=t[114],St=t[115]):(vt=e=>{V!==null&&hQ(V).setExpectedServerInstanceId(e)},yt=async e=>{if(V===null)return;let t=hQ(V);t.setObservedBranch(e),await ox(t,e),Nn([`files`,`backlinks`,`graph`]),Pn(e)},bt=async e=>{if(V===null)return;let t=hQ(V);t.compareAndUpdateObservedBranch(e)&&(await ox(t,e),Nn([`files`,`backlinks`,`graph`]),Pn(e))},xt=(e,t)=>{V!==null&&hQ(V).observeDiskAck(e,t)},St=async()=>{V!==null&&await hx(hQ(V))},t[110]=V,t[111]=vt,t[112]=yt,t[113]=bt,t[114]=xt,t[115]=St);let Ct;t[116]!==R||t[117]!==I||t[118]!==r.activeDocName?(Ct=(e,t)=>{if(!r.activeDocName&&t){window.location.hash=xn(t),z(e),L(`agent`),ee(PQ);return}if(I===`agent`&&R===e){L(`doc`);return}z(e),L(`agent`),ee(NQ)},t[116]=R,t[117]=I,t[118]=r.activeDocName,t[119]=Ct):Ct=t[119];let wt;t[120]===Symbol.for(`react.memo_cache_sentinel`)?(wt=()=>{L(`doc`),z(null)},t[120]=wt):wt=t[120];let Tt;t[121]!==v||t[122]!==s||t[123]!==a||t[124]!==$e||t[125]!==Ze||t[126]!==Ye||t[127]!==H||t[128]!==te||t[129]!==V||t[130]!==R||t[131]!==B||t[132]!==I||t[133]!==Oe||t[134]!==m||t[135]!==Re||t[136]!==Be||t[137]!==l||t[138]!==We||t[139]!==qe||t[140]!==d||t[141]!==M||t[142]!==U||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]!==nt||t[150]!==rt||t[151]!==at||t[152]!==ot||t[153]!==ct||t[154]!==lt||t[155]!==ut||t[156]!==dt||t[157]!==ft||t[158]!==pt||t[159]!==mt||t[160]!==ht||t[161]!==gt||t[162]!==_t||t[163]!==vt||t[164]!==yt||t[165]!==bt||t[166]!==xt||t[167]!==St||t[168]!==Ct||t[169]!==b||t[170]!==g?(Tt={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:Re,openDocumentTransition:Be,openTarget:We,openTargetTransition:qe,clearTarget:nt,closeDocument:rt,closeActiveTabOrWindow:$e,closeTab:Ye,pinTab:it,unpinTab:at,activateTab:ot,reorderTabs:st,newTabIds:m,activeNewTabId:v,isNewTabActive:Oe,openNewTab:ct,activateNewTab:lt,closeNewTab:Ze,closeTabs:ut,syncOpenTabsWithKnownTargets:dt,remapTabsForRename:ft,closeAndClearForRename:pt,getPoolActiveDocName:mt,poolHas:ht,recycleDocument:gt,prewarm:_t,systemProvider:P,setSystemProvider:F,updateServerInstanceId:vt,onBranchSwitched:yt,observeBranch:bt,observeDiskAck:xt,refreshServerInfo:St,collabUrl:V,collabTerminal:te,collabLastError:H,retryCollab:U,docPanelMode:I,docPanelAgentId:R,docPanelExpandSignal:B,openActivityPanel:Ct,closeActivityPanel:wt},t[121]=v,t[122]=s,t[123]=a,t[124]=$e,t[125]=Ze,t[126]=Ye,t[127]=H,t[128]=te,t[129]=V,t[130]=R,t[131]=B,t[132]=I,t[133]=Oe,t[134]=m,t[135]=Re,t[136]=Be,t[137]=l,t[138]=We,t[139]=qe,t[140]=d,t[141]=M,t[142]=U,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]=nt,t[150]=rt,t[151]=at,t[152]=ot,t[153]=ct,t[154]=lt,t[155]=ut,t[156]=dt,t[157]=ft,t[158]=pt,t[159]=mt,t[160]=ht,t[161]=gt,t[162]=_t,t[163]=vt,t[164]=yt,t[165]=bt,t[166]=xt,t[167]=St,t[168]=Ct,t[169]=b,t[170]=g,t[171]=Tt):Tt=t[171];let Et=Tt,Dt;return t[172]!==n||t[173]!==Et?(Dt=(0,X.jsx)(pQ,{value:Et,children:n}),t[172]=n,t[173]=Et,t[174]=Dt):Dt=t[174],Dt}function NQ(e){return e+1}function PQ(e){return e+1}function FQ(e){return e.length>0}function IQ(e){return e===null?e:null}function LQ(e){return e===null?e:null}function RQ(e){return e===null?e:null}function zQ(e){return e===null?e:null}function BQ(e){return e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))}function VQ(e){console.warn(`[editor-tabs] failed to persist tab session:`,e)}function HQ(e){console.warn(`[editor-tabs] failed to restore tab session:`,e)}function UQ(){let e=(0,Q.use)(pQ);if(!e)throw Error(`useDocumentContext must be used within <DocumentProvider />`);return e}function WQ(){let e=(0,Z.c)(3),{openDocumentTransition:t,openTargetTransition:n}=UQ(),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{vA as $,Wi as $n,Wy as $t,$U as A,nc as An,lS as At,nU as B,ua as Bn,px as Bt,Kq as C,$ as Cn,VS as Ct,eG as D,oc as Dn,vS as Dt,gK as E,rc as En,rS as Et,bU as F,Ca as Fn,Bx as Ft,UL as G,na as Gn,Wb as Gt,VL as H,aa as Hn,Zb as Ht,fU as I,ga as In,Ux as It,cL as J,Yi as Jn,Gb as Jt,_L as K,ta as Kn,qb as Kt,uU as L,ha as Ln,Vx as Lt,RU as M,Na as Mn,Gx as Mt,AU as N,Ea as Nn,Kx as Nt,QW as O,ac as On,_S as Ot,CU as P,Ta as Pn,Hx as Pt,Gj as Q,Gi as Qn,Uy as Qt,lU as R,ma as Rn,wx as Rt,dJ as S,gc as Sn,WS as St,Cq as T,cc as Tn,QS as Tt,oR as U,ia as Un,Qb as Ut,Jz as V,oa as Vn,ix as Vt,Yz as W,ra as Wn,Ub as Wt,uI as X,qi as Xn,Kb as Xt,hL as Y,Ji as Yn,Yb as Yt,lI as Z,Ki as Zn,Xb as Zt,JX as _,su as _n,yC as _t,AZ as a,fv as an,Ni as ar,ZD as at,UJ as b,Dl as bn,MS as bt,OZ as c,Ch as cn,Oi as cr,ND as ct,KZ as d,bh as dn,Ti as dr,_C as dt,Iy as en,Vi as er,qk as et,EZ as f,hh as fn,wi as fr,fC as ft,qX as g,cu as gn,vi as gr,RC as gt,aZ as h,Sf as hn,yi as hr,bC as ht,jZ as i,Tv as in,Fi as ir,DO as it,WU as j,$s as jn,qx as jt,$W as k,ic as kn,gS as kt,qZ as l,Sh as ln,Di as lr,kD as lt,oZ as m,Wp as mn,bi as mr,gC as mt,UQ as n,my as nn,Li as nr,ek as nt,kZ as o,Mm as on,Mi as or,JD as ot,TZ as p,Up as pn,xi as pr,DC as pt,uL as q,Zi as qn,Jb as qt,WQ as r,by as rn,Ii as rr,kO as rt,MZ as s,Zh as sn,ji as sr,PD as st,MQ as t,Rv as tn,zi as tr,Pk as tt,HZ as u,gh as un,Ei as ur,kE as ut,UY as v,Sl as vn,vC as vt,Rq as w,uc as wn,jS as wt,SJ as x,Tl as xn,US as xt,BY as y,bl as yn,FS as yt,iU as z,pa as zn,gx as zt};
|