@inkeep/open-knowledge 0.22.1-beta.0 → 0.22.1-beta.1
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-DWCFve7D.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/init-DOEUZl_u.mjs +1 -0
- package/dist/{init-B3YNQ26K.mjs → init-DoXhLR9T.mjs} +3 -3
- package/dist/{loader-C2SK6e1C.mjs → loader-Db2zs1T3.mjs} +2 -2
- package/dist/loader-DmNed9Bw.mjs +1 -0
- package/dist/{preview-B14IV6Qz.mjs → preview-CIBWxFBn.mjs} +2 -2
- package/dist/preview-dg2vkZ6t.mjs +1 -0
- package/dist/public/assets/{index-Ca2Onxgo.js → index-BTQ7usHM.js} +1 -1
- package/dist/public/assets/{index-DptVQKn2.css → index-BZNCQ0oq.css} +1 -1
- package/dist/public/index.html +2 -2
- package/dist/{repair-launch-json-DPn6JtvL.mjs → repair-launch-json-C24XLrhg.mjs} +2 -2
- package/dist/{repair-mcp-configs-DX8ouv3O.mjs → repair-mcp-configs-CM0eGQp0.mjs} +2 -2
- package/dist/{src-DfdgOcos.mjs → src-DvLxEWEL.mjs} +2 -2
- package/dist/start-BVbLYjT4.mjs +1 -0
- package/dist/{start-D-pH8W6O.mjs → start-Cqtt8qo_.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-Ckm9OWu3.mjs +0 -2
- package/dist/init-DGLOMpKo.mjs +0 -1
- package/dist/loader-WBS6m0y4.mjs +0 -1
- package/dist/preview-B-5maWRK.mjs +0 -1
- package/dist/start-DJ5_KJqc.mjs +0 -1
|
@@ -26,7 +26,7 @@ Error generating stack: `+e.message+`
|
|
|
26
26
|
`).trim(),mentions:t}}function US(e){let{instruction:t,mentions:n}=HS(e);return t===``&&n.length===0}function WS(e){let t=e?.content;return!Array.isArray(t)||t.length===0?!1:t.some(e=>Array.isArray(e.content)&&e.content.length>0)}function GS(e){let t=(0,$.c)(29),{ref:n,ariaLabel:r,onEmptyChange:i,onContentChange:a,onMentionsChange:o,onSubmit:s,className:c,placeholder:l,initialDoc:u}=e,f=(0,Q.useRef)(i),p=(0,Q.useRef)(a),m=(0,Q.useRef)(o),h=(0,Q.useRef)(s),g;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==s?(g=()=>{f.current=i,p.current=a,m.current=o,h.current=s},t[0]=a,t[1]=i,t[2]=o,t[3]=s,t[4]=g):g=t[4],(0,Q.useEffect)(g);let _;t[5]===l?_=t[6]:(_=zS({placeholder:l}),t[5]=l,t[6]=_);let v=u??void 0,y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=Ti(`composer-prosemirror py-1 outline-none`),t[7]=y):y=t[7];let b;t[8]===r?b=t[9]:(b={role:`textbox`,"aria-label":r,"aria-multiline":`true`,class:y},t[8]=r,t[9]=b);let x;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(x=(e,t)=>t.key===`Escape`?jS.getState(e.state)?.active?!1:(e.dom.blur(),!0):t.key===`Enter`&&!t.shiftKey&&!t.isComposing&&!e.composing?jS.getState(e.state)?.active?!1:(h.current(),!0):!1,t[10]=x):x=t[10];let S;t[11]===b?S=t[12]:(S={attributes:b,handleKeyDown:x},t[11]=b,t[12]=S);let C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{let{editor:t}=e;f.current(US(t)),p.current?.(t.getJSON()),m.current?.(HS(t).mentions)},t[13]=C):C=t[13];let w;t[14]!==_||t[15]!==v||t[16]!==S?(w={extensions:_,content:v,immediatelyRender:!0,editorProps:S,onUpdate:C},t[14]=_,t[15]=v,t[16]=S,t[17]=w):w=t[17];let T=pe(w),E;t[18]!==T||t[19]!==u?(E=()=>{T&&(US(T)&&WS(u)&&(console.warn(`composer draft was incompatible with the current schema — clearing it`),wS()),f.current(US(T)),m.current?.(HS(T).mentions))},t[18]=T,t[19]=u,t[20]=E):E=t[20];let D;t[21]===T?D=t[22]:(D=[T],t[21]=T,t[22]=D),(0,Q.useEffect)(E,D);let O,k;t[23]===T?(O=t[24],k=t[25]):(O=()=>({focus:()=>T?.commands.focus(),blur:()=>T?.commands.blur(),clear:()=>T?.commands.clearContent(!0),setText:e=>{T&&(T.commands.setContent(e),p.current?.(T.getJSON()),m.current?.(HS(T).mentions))},getContent:()=>T?HS(T):{instruction:``,mentions:[]}}),k=[T],t[23]=T,t[24]=O,t[25]=k),(0,Q.useImperativeHandle)(n,O,k);let A;return t[26]!==c||t[27]!==T?(A=(0,Z.jsx)(d,{editor:T,className:c}),t[26]=c,t[27]=T,t[28]=A):A=t[28],A}function KS(e,t,n){return e.trim().length>0||t.length>0||n}var qS=`ok-ask-ai-agent-v2`,JS=`ok-ask-ai-default-agent-v1`,YS=`ok-preferred-agent-v1`,XS=`terminal-cli`;function ZS(e){return`${XS}:${e}`}function QS(e){return e===null?null:e===`terminal-cli`?`claude`:_i.find(t=>e===ZS(t))??null}function $S(e){if(e)return e;if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function eC(e){let t=$S(e);if(!t)return null;try{let e=t.getItem(qS);return e===null?t.getItem(JS)??t.getItem(YS):e}catch{return null}}function tC(e,t){let n=$S(t);if(n)try{n.setItem(qS,e)}catch(e){console.warn(`[ask-ai] Failed to persist default agent:`,e)}}function nC(e,t){let n=Wo.filter(t=>e[t.id]?.installed===!0);if(t){let e=n.find(e=>e.id===t);if(e)return e}return n[0]??null}var rC=new Set(Wo.map(e=>e.id));function iC(e){return typeof e==`string`&&rC.has(e)}function aC(e){try{let t=eC(e);return iC(t)?t:null}catch{return null}}function oC(e,t){tC(e,t)}function sC(e){let{lastUsed:t,states:n}=e;return t&&n[t]?.installed===!0?t:Wo.find(e=>n[e.id]?.installed===!0)?.id??null}function cC(e){let t=(0,$.c)(28),{scenario:n,className:r}=e,{_:i}=cn(),{states:a,refresh:o}=ns(),{dispatch:s}=us(),c=Ho(),l=cs(),[u,d]=(0,Q.useState)(dC),f=(0,Q.useRef)(!1),[p,m]=(0,Q.useState)(null),h=p!==null&&l!==null,g=(0,Q.useRef)(null),[_]=(0,Q.useState)(uC),[v,y]=(0,Q.useState)(!0),[b,x]=(0,Q.useState)(!1),S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S=function(e){y(e),e||x(!1)},t[0]=S):S=t[0];let C=S,w=lS(n),T;t[1]===a?T=t[2]:(T=e=>a[e.id]?.installed===!0,t[1]=a,t[2]=T);let E=Wo.filter(T),D;t[3]===a?D=t[4]:(D=Wo.every(e=>a[e.id]?.installed!=null),t[3]=a,t[4]=D);let O=D,k=O&&E.length===0,A,j;t[5]!==O||t[6]!==a?(A=()=>{if(!O||f.current)return;let e=sC({lastUsed:aC(),states:a});d(t=>e===t?t:e)},j=[O,a],t[5]=O,t[6]=a,t[7]=A,t[8]=j):(A=t[7],j=t[8]),(0,Q.useEffect)(A,j);let M=function(e){f.current=!0,m(null),d(e),oC(e)},N=function(e){f.current=!0,m(e)},P=function(){if(l===null||p===null)return;let{instruction:e,mentions:t}=g.current?.getContent()??{instruction:``,mentions:[]};if(!KS(e,t,!1)){x(!0);return}let r=Zo({workspace:c,description:e,scenario:n,mentions:t});r!==null&&(l.launchInTerminal(r,p),g.current?.clear(),wS())},F=function(e){let{instruction:t,mentions:r}=g.current?.getContent()??{instruction:``,mentions:[]};if(!KS(t,r,!1)){x(!0);return}oC(e);let i=Zo({workspace:c,description:t,scenario:n,mentions:r});i!==null&&(s(e,i),g.current?.clear(),wS())},I=function(){h?P():u!==null&&F(u)},L=function(e){g.current?.setText(e),g.current?.focus()};if(k){let e;t[9]===r?e=t[10]:(e=Ti(`flex w-full flex-wrap items-center justify-between gap-3 rounded-2xl border border-border/60 bg-card px-4 py-3`,r),t[9]=r,t[10]=e);let n;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(Ws,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),t[11]=n):n=t[11];let i;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[n,(0,Z.jsx)(`span`,{className:`text-1sm text-muted-foreground`,children:(0,Z.jsx)(X,{id:`3IseAk`})})]}),t[12]=i):i=t[12];let a;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:Wo.map(lC)}),t[13]=a):a=t[13];let o;return t[14]===e?o=t[15]:(o=(0,Z.jsxs)(`div`,{className:e,"data-testid":`create-no-agents`,children:[i,a]}),t[14]=e,t[15]=o),o}let R=E.length>0,z=l!==null,B;t[16]===r?B=t[17]:(B=Ti(`flex w-full flex-col gap-3`,r),t[16]=r,t[17]=B);let V;t[18]===i?V=t[19]:(V=i({id:`7hctf2`}),t[18]=i,t[19]=V);let H;t[20]===i?H=t[21]:(H=i({id:`0jD-Gn`}),t[20]=i,t[21]=H);let U;t[22]!==v||t[23]!==b?(U=b&&v?(0,Z.jsx)(`p`,{role:`alert`,className:`text-1sm text-destructive`,"data-testid":`create-input-required`,children:(0,Z.jsx)(X,{id:`1FLarN`})}):(0,Z.jsx)(`span`,{}),t[22]=v,t[23]=b,t[24]=U):U=t[24];let W=u===null?(0,Z.jsx)(Di,{type:`button`,variant:`outline`,disabled:!0,className:`gap-1.5`,"data-testid":`create-with-agent`,children:(0,Z.jsx)(X,{id:`hYgDIe`})}):(0,Z.jsxs)(ES,{children:[(0,Z.jsx)(Di,{type:`button`,onClick:()=>h?P():F(u),variant:`outline`,className:`gap-1.5`,"data-testid":`create-with-agent`,children:h&&p!==null?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Xo,{id:Yo(p),"aria-hidden":`true`,className:`size-3.5`}),(0,Z.jsx)(X,{id:`4rjwLG`,values:{0:Gn[p].displayName}})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Xo,{id:u,"aria-hidden":`true`,className:`size-3.5`}),(0,Z.jsx)(X,{id:`9dw5bW`,values:{0:Go(u)}})]})}),(0,Z.jsxs)(rl,{onOpenChange:e=>{e&&o()},children:[(0,Z.jsx)(qc,{asChild:!0,children:(0,Z.jsx)(Di,{type:`button`,"aria-label":i({id:`nskygk`}),size:`icon`,variant:`outline`,"data-testid":`create-with-agent-menu`,children:(0,Z.jsx)(so,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,Z.jsxs)(Zc,{align:`end`,className:`min-w-[200px]`,children:[R?(0,Z.jsxs)(Xc,{"aria-label":i({id:`BBqGS9`}),children:[(0,Z.jsx)(ol,{children:(0,Z.jsx)(X,{id:`BBqGS9`})}),E.map(e=>(0,Z.jsxs)(Yc,{onSelect:()=>M(e.id),"data-testid":`create-agent-option-${e.id}`,children:[(0,Z.jsx)(Xo,{id:e.id,"aria-hidden":`true`,className:`size-4`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:e.displayName}),!h&&e.id===u?(0,Z.jsx)($a,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},e.id))]}):null,z?(0,Z.jsxs)(Z.Fragment,{children:[R?(0,Z.jsx)(cl,{}):null,(0,Z.jsxs)(Xc,{"aria-label":i({id:`ALhMYW`}),children:[(0,Z.jsx)(ol,{children:(0,Z.jsx)(X,{id:`ALhMYW`})}),ss.map(e=>{let{displayName:t}=Gn[e];return(0,Z.jsxs)(Yc,{onSelect:()=>N(e),"data-testid":`create-with-cli-${e}`,"aria-label":i({id:`QYfQdv`,values:{displayName:t}}),children:[(0,Z.jsx)(Xo,{id:Yo(e),"aria-hidden":`true`,className:`size-4`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:t}),p===e?(0,Z.jsx)($a,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},e)})]})]}):null]})]})]}),G;return t[25]!==W||t[26]!==U?(G=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-3 pb-3`,children:[U,W]}),t[25]=W,t[26]=U,t[27]=G):G=t[27],(0,Z.jsxs)(`div`,{className:B,children:[(0,Z.jsxs)(`div`,{className:`flex w-full flex-col rounded-2xl border border-border/60 bg-card shadow-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50`,children:[(0,Z.jsx)(GS,{ref:g,ariaLabel:V,placeholder:H,onEmptyChange:C,onContentChange:CS,onSubmit:I,initialDoc:_,className:`max-h-96 overflow-y-auto px-4 py-3 text-sm leading-relaxed subtle-scrollbar [&_.ProseMirror]:min-h-16`}),G]}),n!==`existing-repo`&&w.length>0?(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:w.map(e=>{let t=e.icon;return(0,Z.jsxs)(Di,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>L(e.prompt),className:`gap-1.5 rounded-md font-normal text-muted-foreground hover:text-foreground`,"data-testid":`create-suggestion-${e.id}`,children:[(0,Z.jsx)(t,{className:`size-3.5`,"aria-hidden":`true`}),e.label]},e.id)})}):null]})}function lC(e){return(0,Z.jsxs)(Di,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void Vo(e),className:`gap-1.5`,"data-testid":`install-agent-${e.id}`,children:[(0,Z.jsx)(Xo,{id:e.id,"aria-hidden":`true`,className:`size-3.5`}),e.displayName,(0,Z.jsx)(za,{"aria-hidden":`true`,className:`size-3`})]},e.id)}function uC(){return SS().doc??void 0}function dC(){return aC()}var fC=3100,pC=3;function mC(e,t,n){let r=n?.windowMs??600,i=n?.maxLevel??pC;if(e===0||t>=r)return 1;let a=e+1;return a>i?i:a}var hC={0:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},1:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},2:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},3:{count:16,startRadius:11,baseDistance:7,distanceVariance:3,sizeMin:.45,sizeMax:1.2,maxDelay:500,durationMin:1100,durationMax:2400}},gC=[`var(--color-azure-blue)`,`var(--color-sky-blue)`,`var(--color-violet-300)`,`var(--color-orange-light)`,`var(--color-crystal-blue)`,`var(--color-white-cream)`];function _C(e,t={}){let n=t.rng??Math.random,r=t.colors??gC,i=hC[e];if(i.count===0||r.length===0)return[];let a=[],o=Math.PI*2/i.count;for(let e=0;e<i.count;e++){let t=e*o+(n()-.5)*o*.7,s=i.baseDistance+(n()-.5)*2*i.distanceVariance,c=i.sizeMin+n()*(i.sizeMax-i.sizeMin),l=n()*i.maxDelay,u=i.durationMin+n()*(i.durationMax-i.durationMin),d=Math.floor(n()*r.length),f=Math.cos(t),p=Math.sin(t);a.push({id:e,dx:f*s,dy:p*s,originDx:f*i.startRadius,originDy:p*i.startRadius,size:c,color:r[d]??`currentColor`,delay:l,duration:u})}return a}var vC=1.8,yC=90,bC=16,xC=380,SC=.025,CC=.1,wC=.18,TC=400,EC=9.2736,DC=18.1799,OC=14.5244,kC={1:{halfWidth:1.5,apexLift:2.2},2:{halfWidth:1.4,apexLift:2.6},3:{halfWidth:1.25,apexLift:3}};function AC(e,t){let{halfWidth:n,apexLift:r}=kC[t];return`M${e-n} ${OC+.3} Q${e} ${OC-r}, ${e+n} ${OC+.3}`}function jC(e){let t=1.5,n=.3;return`M${e-t} ${OC-n} Q${e} ${OC+1.4}, ${e+t} ${OC-n}`}var MC=15,NC=15;function PC(e){return{fill:e.color,"--fx-tx":`${e.dx}px`,"--fx-ty":`${e.dy}px`,"--fx-delay":`${e.delay}ms`,"--fx-duration":`${e.duration}ms`}}function FC(e){let t=(0,$.c)(71),{size:n,className:r,trackMouse:i,variant:a,celebrateSignal:o}=e,s=n===void 0?48:n,c=i===void 0?!0:i,l=a===void 0?`default`:a,u=o===void 0?0:o,d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={x:0,y:0},t[0]=m):m=t[0];let h=(0,Q.useRef)(m),[g,_]=(0,Q.useState)(0),[v,y]=(0,Q.useState)(0),b;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(b=[],t[1]=b):b=t[1];let[x,S]=(0,Q.useState)(b),C=(0,Q.useRef)(0),w=(0,Q.useRef)(void 0),T=l===`sleeping`,E;t[2]!==g||t[3]!==T?(E=function(){if(T)return;let e=typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),t=C.current===0?1/0:e-C.current;C.current=e;let n=mC(g,t);_(n),y(zC),S(_C(n)),clearTimeout(w.current),w.current=setTimeout(()=>{_(0),S([])},fC)},t[2]=g,t[3]=T,t[4]=E):E=t[4];let D=E,O,k;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>()=>clearTimeout(w.current),k=[],t[5]=O,t[6]=k):(O=t[5],k=t[6]),(0,Q.useEffect)(O,k);let A,j;t[7]!==u||t[8]!==T?(A=()=>{u===0||T||(_(3),y(RC),S(_C(3)),clearTimeout(w.current),w.current=setTimeout(()=>{_(0),S([])},fC))},j=[u,T],t[7]=u,t[8]=T,t[9]=A,t[10]=j):(A=t[9],j=t[10]),(0,Q.useEffect)(A,j);let M,N;t[11]!==T||t[12]!==c?(M=()=>{if(!c||T||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=0,t=0,n=!1,r=0,i=0,a=0,o=0,s=0,l=function(){s===0&&(s=requestAnimationFrame(m))},u=function(r){e=r.clientX,t=r.clientY,n=!0,l()};function m(){s=0;let c=f.current,u=d.current;if(!c||!u){l();return}let m=n;n=!1;let g=c.getBoundingClientRect(),_=g.left+g.width/2,v=g.top+g.height*.48,y=e-_,b=t-v,x=Math.hypot(y,b),S=Math.max(-1,Math.min(1,y/xC)),C=-Math.max(-1,Math.min(1,b/xC))*bC,w=S*bC,T=0,E=0;if(x>=1){let e=Math.min(x/yC,1)*vC;T=y/x*e,E=b/x*e}let D=Math.abs(C-r)<.01&&Math.abs(w-i)<.01&&Math.abs(T-a)<.01&&Math.abs(E-o)<.01;if(!m&&D)return;l(),r+=(C-r)*CC,i+=(w-i)*CC,u.style.transform=`perspective(${TC}px) rotateX(${r.toFixed(3)}deg) rotateY(${i.toFixed(3)}deg)`,a+=(T-a)*wC,o+=(E-o)*wC;let O=i*SC,k=-r*SC,A=a+O,j=o+k;h.current.x=A,h.current.y=j,p.current?.setAttribute(`transform`,`translate(${A.toFixed(3)} ${j.toFixed(3)})`)}return document.addEventListener(`mousemove`,u,{passive:!0}),l(),()=>{document.removeEventListener(`mousemove`,u),s!==0&&cancelAnimationFrame(s),s=0,d.current&&(d.current.style.transform=``),h.current={x:0,y:0},p.current?.removeAttribute(`transform`)}},N=[c,T],t[11]=T,t[12]=c,t[13]=M,t[14]=N):(M=t[13],N=t[14]),(0,Q.useEffect)(M,N);let P;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>{let e=p.current;if(!e)return;let{x:t,y:n}=h.current;e.setAttribute(`transform`,`translate(${t.toFixed(3)} ${n.toFixed(3)})`)},t[15]=P):P=t[15],(0,Q.useLayoutEffect)(P);let F=g>0,I=F?g:1,L=F?`ok-blob-clicked-${g}`:null,R;t[16]===r?R=t[17]:(R=Ti(`ok-blob-3d-wrapper`,r),t[16]=r,t[17]=R);let z=T?`cursor-default`:`cursor-pointer`,B=`body-${v}`,V=T&&`ok-blob-sleeping`,H;t[18]!==L||t[19]!==V?(H=Ti(`ok-blob-group`,V,L),t[18]=L,t[19]=V,t[20]=H):H=t[20];let U;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(`path`,{d:`M25.2339 6.78134C25.5199 7.35734 25.8179 8.47234 26.0179 9.07834C26.0189 9.08234 26.0209 9.08634 26.0219 9.09134C26.0229 9.09534 26.0249 9.10034 26.0259 9.10434C26.0539 9.19734 26.0949 9.29533 26.1519 9.41633C26.2919 9.71133 26.5269 10.1173 27.1299 11.1683C27.3259 11.4643 27.5209 11.7693 27.7119 12.0903C29.9739 15.1623 29.3259 20.1913 27.0469 22.9153C26.7779 23.2953 26.4869 23.6043 26.1889 23.8863C26.1519 23.9253 26.1129 23.9643 26.0729 24.0033C25.3159 24.7543 24.2949 25.4673 23.6129 25.8323C22.7469 26.2983 22.1349 26.5483 21.6299 26.7463C20.3649 27.3063 19.0609 27.7733 17.6569 28.0423C15.9649 28.3513 14.1939 28.4433 12.4569 28.1373C11.4779 27.9663 10.5119 27.6663 9.60891 27.2493C8.77491 26.8663 7.99192 26.3853 7.26992 25.8403C6.83592 25.5393 6.43893 25.2343 6.08093 24.9383C5.57893 24.5223 5.15993 24.1263 4.83493 23.7793C4.04993 22.9443 3.31593 21.8893 2.80893 21.0953C2.72593 20.9663 2.64792 20.8433 2.57592 20.7293C2.56192 20.7093 2.54793 20.6893 2.53393 20.6703C2.08593 20.0263 1.71892 19.3293 1.43792 18.5993C1.42892 18.5453 1.42093 18.4903 1.41293 18.4353C1.32093 17.7443 1.08292 16.9423 1.01092 15.6333C0.984921 15.0653 0.998928 14.4013 1.12393 13.6353C1.20693 13.1413 1.31993 12.9023 1.40893 12.7113C1.43593 12.6543 1.46193 12.6023 1.48593 12.5483C1.56793 12.3653 1.59392 12.1563 1.63592 11.9083C1.68992 11.5883 1.76992 11.1943 2.04592 10.7553C2.94392 9.37934 3.36792 8.81934 3.66592 8.33934C3.75592 8.20334 3.84292 8.08134 3.94192 7.96634C4.21592 7.64634 4.67693 7.29534 5.10293 7.05734C5.16693 7.02234 5.23093 6.98834 5.29193 6.95534C5.62993 6.77834 6.22592 6.30135 6.66992 5.92035C6.83692 5.77635 7.08193 5.60735 7.37393 5.40935C7.67393 5.20535 8.02593 4.96934 8.39193 4.70234C9.32093 4.02634 9.84091 3.69134 10.2599 3.42334C10.3799 3.34734 10.4919 3.27734 10.6049 3.20834C10.9609 2.98834 11.4149 2.73034 11.8869 2.48634C12.4519 2.19334 13.0469 1.92133 13.5089 1.72233C14.7399 1.30233 16.0539 1.01333 17.4169 1.00033C18.1169 0.991333 18.7939 1.16534 19.2389 1.43034C19.6869 1.69534 19.8689 2.00335 19.8039 2.23935C19.7379 2.47835 19.4399 2.63634 19.0109 2.74734C18.5789 2.85634 18.0469 2.92035 17.4889 2.96135C16.3639 3.04235 15.2399 3.36435 14.1499 3.80835C12.8199 4.35135 11.5379 5.07133 10.2719 5.84733C9.38691 6.39133 8.51192 6.97334 7.63592 7.56834C7.54492 7.63034 7.45492 7.69135 7.36492 7.75235C6.97392 8.06635 6.58293 8.38134 6.22293 8.66334C5.97893 8.85734 5.76793 9.04834 5.59393 9.21434C5.26893 9.52334 5.02393 9.74334 4.81893 9.93934C4.67793 10.0753 4.55793 10.2013 4.45593 10.3443C4.40093 10.4213 4.32992 10.5273 4.24792 10.6593C3.90492 11.1933 3.44493 12.1693 3.15393 13.1173C3.01893 13.5363 2.87991 14.0343 2.79391 14.5253C2.66591 15.2253 2.65594 15.9053 2.71994 16.2373C2.82794 16.8193 2.95593 17.4833 3.14093 18.0553C3.31293 18.6003 3.52991 19.0583 3.70791 19.2823C3.81591 19.4183 3.90394 19.5473 3.99594 19.6913C4.09394 19.8413 4.19191 20.0073 4.31091 20.2033C4.47891 20.4803 4.68592 20.8163 5.00192 21.2493C5.36492 21.7463 5.61793 22.1043 5.83493 22.4023C6.14493 22.8243 6.38591 23.1343 6.83691 23.5033C7.33891 23.9113 7.86593 24.3113 8.26693 24.6393C8.44893 24.7883 8.66993 24.9443 8.90493 25.0963C9.21593 25.2963 9.55192 25.4893 9.85592 25.6703C10.1059 25.8203 10.3059 25.9633 10.4869 26.0863C10.5429 26.1243 10.5979 26.1603 10.6519 26.1943C10.8699 26.2803 11.0929 26.3593 11.3159 26.4283C11.3539 26.4323 11.3949 26.4353 11.4369 26.4393C11.6509 26.4573 11.9089 26.4733 12.2209 26.5133C12.7169 26.5753 13.1399 26.6603 13.6019 26.7243C13.9589 26.7733 14.3409 26.8083 14.7729 26.7893C15.0729 26.7753 15.4069 26.7353 15.7389 26.6813C16.2349 26.6023 16.7179 26.4943 17.0569 26.4473C17.1499 26.4343 17.2359 26.4343 17.3209 26.4373C17.3489 26.4393 17.3799 26.4413 17.4109 26.4433C17.4119 26.4433 17.4119 26.4433 17.4129 26.4433C17.4199 26.4433 17.4279 26.4443 17.4349 26.4443C18.2329 26.2413 19.0259 25.9433 19.7959 25.5983C19.8609 25.5633 19.9259 25.5273 19.9899 25.4913C20.3059 25.3173 20.6049 25.1383 20.7869 24.9943C20.9829 24.8393 21.5189 24.5373 22.0579 24.1853C22.4109 23.9553 22.7649 23.7053 23.0369 23.4833C23.1949 23.3553 23.3689 23.2693 23.5479 23.1773C23.7129 23.0923 23.8809 23.0013 24.0349 22.8653C24.1109 22.7983 24.1869 22.7173 24.2639 22.6303C24.3309 22.5563 24.4039 22.4723 24.4759 22.3923C24.5459 22.3153 24.7199 22.1723 24.9139 21.9793C25.0079 21.8863 25.1059 21.7783 25.1909 21.6713C25.2199 21.6323 25.2489 21.5943 25.2769 21.5553C25.5919 21.0403 25.8779 20.5003 26.1019 19.9653C26.1299 19.8403 26.1379 19.7293 26.1279 19.6373C26.1199 19.5703 26.1029 19.5113 26.0839 19.4503C26.0599 19.3643 26.0329 19.2773 26.0239 19.1723C26.0169 19.0893 26.0309 19.0043 26.0629 18.9543C26.0779 18.9323 26.0969 18.9143 26.1129 18.8993C26.1329 18.8823 26.1499 18.8673 26.1569 18.8443C26.1609 18.8273 26.1579 18.8073 26.1529 18.7833C26.1459 18.7443 26.1369 18.6943 26.1539 18.6293C26.2189 18.3853 26.2869 18.1103 26.3319 17.8383C26.3829 17.5393 26.4049 17.2433 26.3949 17.0123C26.3849 16.7493 26.3909 16.3823 26.3469 16.0003C26.3179 15.7343 26.2659 15.4663 26.1979 15.2383C26.1319 15.0143 26.0219 14.7913 25.9039 14.5783C25.7629 14.3223 25.6119 14.0783 25.5169 13.8453C25.4969 13.7983 25.4999 13.7263 25.4999 13.6323C25.5009 13.5673 25.4999 13.4913 25.4919 13.4083C25.3239 13.1243 25.1459 12.8423 24.9589 12.5483C24.9479 12.5413 24.9369 12.5333 24.9249 12.5263C24.6689 12.3503 24.3139 12.1173 24.0769 11.5503C24.0179 11.4063 24.0069 11.2983 23.9969 11.1993C23.9859 11.1013 23.9799 11.0183 23.9289 10.9093C23.8709 10.7853 23.7759 10.6583 23.6709 10.4993C23.5849 10.3703 23.4899 10.2133 23.4199 10.0423C23.3819 9.95134 23.3509 9.85734 23.3329 9.75934C23.3299 9.74334 23.3269 9.72534 23.3229 9.70634C23.2899 9.52734 23.2439 9.26534 23.2409 8.98634C23.0209 8.24434 22.8339 7.48833 22.6519 6.77633C22.3429 5.57133 22.0519 4.54234 21.3329 3.95434C20.9839 3.65334 20.5689 3.35433 20.2459 3.05433C19.9259 2.75633 19.7449 2.47534 19.8019 2.23834C19.8639 2.00634 20.1589 1.82934 20.6659 1.80534C21.1699 1.78334 21.8699 1.93235 22.5209 2.39235C23.6159 3.14235 24.2029 4.38334 24.5599 5.35734C24.5829 5.40834 24.6049 5.46034 24.6259 5.51234C24.7849 5.89434 24.9529 6.22834 25.1199 6.55534C25.1579 6.63034 25.1969 6.70834 25.2339 6.78134Z`,className:`ok-blob-body`}),t[21]=U):U=t[21];let W=(F||T)&&`ok-blob-eye-hidden`,G;t[22]===W?G=t[23]:(G=Ti(`ok-blob-eye`,W),t[22]=W,t[23]=G);let K;t[24]===G?K=t[25]:(K=(0,Z.jsx)(`ellipse`,{cx:EC,cy:OC,rx:1.2722,ry:1.9083,className:G}),t[24]=G,t[25]=K);let q=(F||T)&&`ok-blob-eye-hidden`,J;t[26]===q?J=t[27]:(J=Ti(`ok-blob-eye ok-blob-eye-right`,q),t[26]=q,t[27]=J);let Y;t[28]===J?Y=t[29]:(Y=(0,Z.jsx)(`ellipse`,{cx:DC,cy:OC,rx:1.2722,ry:1.9083,className:J}),t[28]=J,t[29]=Y);let ee;t[30]===I?ee=t[31]:(ee=AC(EC,I),t[30]=I,t[31]=ee);let te=(!F||T)&&`ok-blob-eye-hidden`,ne;t[32]===te?ne=t[33]:(ne=Ti(`ok-blob-happy-eye`,te),t[32]=te,t[33]=ne);let re;t[34]!==ee||t[35]!==ne?(re=(0,Z.jsx)(`path`,{d:ee,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:ne}),t[34]=ee,t[35]=ne,t[36]=re):re=t[36];let ie;t[37]===I?ie=t[38]:(ie=AC(DC,I),t[37]=I,t[38]=ie);let ae=(!F||T)&&`ok-blob-eye-hidden`,oe;t[39]===ae?oe=t[40]:(oe=Ti(`ok-blob-happy-eye`,ae),t[39]=ae,t[40]=oe);let se;t[41]!==ie||t[42]!==oe?(se=(0,Z.jsx)(`path`,{d:ie,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:oe}),t[41]=ie,t[42]=oe,t[43]=se):se=t[43];let ce;t[44]===T?ce=t[45]:(ce=T?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`path`,{d:jC(EC),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`}),(0,Z.jsx)(`path`,{d:jC(DC),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`})]}):null,t[44]=T,t[45]=ce);let le;t[46]!==K||t[47]!==Y||t[48]!==re||t[49]!==se||t[50]!==ce?(le=(0,Z.jsxs)(`g`,{ref:p,children:[K,Y,re,se,ce]}),t[46]=K,t[47]=Y,t[48]=re,t[49]=se,t[50]=ce,t[51]=le):le=t[51];let ue;t[52]!==B||t[53]!==H||t[54]!==le?(ue=(0,Z.jsxs)(`g`,{className:H,children:[U,le]},B),t[52]=B,t[53]=H,t[54]=le,t[55]=ue):ue=t[55];let de;t[56]===T?de=t[57]:(de=T?(0,Z.jsxs)(`g`,{children:[(0,Z.jsx)(`text`,{x:21,y:7,className:`ok-blob-z ok-blob-z-1`,children:`z`}),(0,Z.jsx)(`text`,{x:26,y:2,className:`ok-blob-z ok-blob-z-2`,children:`z`})]}):null,t[56]=T,t[57]=de);let fe;t[58]!==v||t[59]!==x?(fe=x.length>0&&(0,Z.jsx)(`g`,{children:x.map(IC)},`firework-${v}`),t[58]=v,t[59]=x,t[60]=fe):fe=t[60];let pe;t[61]!==D||t[62]!==s||t[63]!==z||t[64]!==ue||t[65]!==de||t[66]!==fe?(pe=(0,Z.jsxs)(`svg`,{ref:f,width:s,height:s,viewBox:`0 0 30 30`,fill:`none`,overflow:`visible`,xmlns:`http://www.w3.org/2000/svg`,className:z,"aria-hidden":`true`,onClick:D,onMouseDown:LC,children:[ue,de,fe]}),t[61]=D,t[62]=s,t[63]=z,t[64]=ue,t[65]=de,t[66]=fe,t[67]=pe):pe=t[67];let me;return t[68]!==R||t[69]!==pe?(me=(0,Z.jsx)(`span`,{ref:d,className:R,children:pe}),t[68]=R,t[69]=pe,t[70]=me):me=t[70],me}function IC(e){return(0,Z.jsx)(`circle`,{cx:MC+e.originDx,cy:NC+e.originDy,r:e.size,className:`ok-blob-firework`,style:PC(e)},e.id)}function LC(e){return e.preventDefault()}function RC(e){return e+1}function zC(e){return e+1}function BC(e){let t=(0,$.c)(12),{title:n,subtitle:r,celebrateSignal:i}=e,a;t[0]===i?a=t[1]:(a=(0,Z.jsx)(FC,{size:64,celebrateSignal:i}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,Z.jsx)(`h2`,{className:`text-2xl font-light tracking-tighter text-balance`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=r?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r}):null,t[4]=r,t[5]=s);let c;t[6]!==o||t[7]!==s?(c=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;return t[9]!==a||t[10]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex items-center gap-4`,children:[a,c]}),t[9]=a,t[10]=c,t[11]=l):l=t[11],l}function VC({isOnboarding:e,isEmbedded:t}){return e?{title:{id:`6h4zVU`},subtitle:t?{id:`vGeNNQ`}:{id:`qpQwGC`}}:{title:{id:`FOGD7m`},subtitle:t?{id:`3DTatP`}:{id:`MqQoV-`}}}var HC=`open-knowledge:create-top-level-file`;function UC(e={}){window.dispatchEvent(new CustomEvent(HC,{detail:e}))}function WC(e){let t=t=>{let n=t.detail;e(n??{})};return window.addEventListener(HC,t),()=>window.removeEventListener(HC,t)}function GC(e){let t=(0,$.c)(28),{celebrateSignal:n,onAddStarterPack:r}=e,{_:i}=cn(),a=es(),{title:o,subtitle:s}=VC({isOnboarding:!1,isEmbedded:a}),c=wa(),l;t[0]!==c.data||t[1]!==c.status?(l=c.status===`ready`?c.data:[],t[0]=c.data,t[1]=c.status,t[2]=l):l=t[2];let u=l,d=c.status===`loading`||c.status===`idle`,f=c.status===`error`,p=BC,m=i(o),h=i(s),g;t[3]!==p||t[4]!==n||t[5]!==m||t[6]!==h?(g=(0,Z.jsx)(p,{title:m,subtitle:h,celebrateSignal:n}),t[3]=p,t[4]=n,t[5]=m,t[6]=h,t[7]=g):g=t[7];let _;t[8]===a?_=t[9]:(_=a?(0,Z.jsx)(uS,{scenario:`existing-repo`}):(0,Z.jsx)(cC,{scenario:`existing-repo`}),t[8]=a,t[9]=_);let v;t[10]!==u||t[11]!==f||t[12]!==d?(v=d||f||u.length>0?(0,Z.jsx)(JC,{templates:u,loading:d,error:f,onSelect:qC}):null,t[10]=u,t[11]=f,t[12]=d,t[13]=v):v=t[13];let y,b;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(xt,{"aria-hidden":`true`,className:`size-3`}),b=(0,Z.jsx)(X,{id:`IajAbS`}),t[14]=y,t[15]=b):(y=t[14],b=t[15]);let x;t[16]===r?x=t[17]:(x=(0,Z.jsxs)(Di,{onClick:r,variant:`link`,size:`xs`,className:`font-mono text-xs uppercase tracking-wider text-muted-foreground font-normal hover:text-foreground hover:no-underline`,children:[y,b]}),t[16]=r,t[17]=x);let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(Di,{variant:`link`,className:`text-muted-foreground font-normal justify-end`,size:`sm`,onClick:KC,children:(0,Z.jsx)(X,{id:`L4Cdd9`,components:{0:(0,Z.jsx)(La,{"aria-hidden":`true`,className:`size-3`})}})}),t[18]=S):S=t[18];let C;t[19]===x?C=t[20]:(C=(0,Z.jsxs)(`div`,{className:`-mt-6 flex w-full items-center justify-between gap-4`,children:[x,S]}),t[19]=x,t[20]=C);let w;t[21]!==C||t[22]!==v?(w=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-8`,children:[v,C]}),t[21]=C,t[22]=v,t[23]=w):w=t[23];let T;return t[24]!==w||t[25]!==g||t[26]!==_?(T=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-8 py-12 max-w-5xl my-auto`,children:[g,_,w]}),t[24]=w,t[25]=g,t[26]=_,t[27]=T):T=t[27],T}function KC(){return UC({initialDir:``})}function qC(e,t){return UC({template:{folder:e,name:t}})}function JC(e){let t=(0,$.c)(25),{templates:n,loading:r,error:i,onSelect:a}=e,{_:o}=cn(),s;t[0]===o?s=t[1]:(s=o({id:`_8quCH`}),t[0]=o,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`span`,{children:(0,Z.jsx)(X,{id:`_8quCH`})}),t[2]=c):c=t[2];let l;t[3]!==o||t[4]!==i||t[5]!==r||t[6]!==n?(l=r||i?null:(0,Z.jsx)(Be,{className:`text-2xs`,variant:`gray`,"aria-label":o({id:`X7u0xR`,values:{0:n.length}}),children:n.length}),t[3]=o,t[4]=i,t[5]=r,t[6]=n,t[7]=l):l=t[7];let u;t[8]===l?u=t[9]:(u=(0,Z.jsxs)(`header`,{className:`flex items-center gap-2 font-mono text-2xs uppercase tracking-wider text-muted-foreground`,children:[c,l]}),t[8]=l,t[9]=u);let d;t[10]===o?d=t[11]:(d=o({id:`irFGwu`}),t[10]=o,t[11]=d);let f;t[12]!==i||t[13]!==r||t[14]!==a||t[15]!==n?(f=r?(0,Z.jsx)(`p`,{className:`p-4 text-1sm text-muted-foreground`,children:(0,Z.jsx)(X,{id:`Hl89Qd`})}):i?(0,Z.jsx)(`p`,{role:`alert`,className:`p-4 text-1sm text-destructive`,children:(0,Z.jsx)(X,{id:`54Y6Fg`})}):n.map(e=>(0,Z.jsx)(YC,{template:e,targetLabel:e.source_folder===``?`/`:`${e.source_folder}/`,onClick:()=>a(e.source_folder,e.name)},`${e.source_folder}/${e.name}`)),t[12]=i,t[13]=r,t[14]=a,t[15]=n,t[16]=f):f=t[16];let p;t[17]!==r||t[18]!==d||t[19]!==f?(p=(0,Z.jsx)(`div`,{className:`w-full overflow-hidden rounded-xl border border-border/60 bg-card`,children:(0,Z.jsx)(`section`,{"aria-busy":r,"aria-label":d,tabIndex:0,className:`subtle-scrollbar scroll-fade-mask flex max-h-[260px] w-full flex-col overflow-y-auto overscroll-contain focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,children:f})}),t[17]=r,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;return t[21]!==s||t[22]!==u||t[23]!==p?(m=(0,Z.jsxs)(`section`,{"aria-label":s,className:`flex w-full flex-col gap-3`,children:[u,p]}),t[21]=s,t[22]=u,t[23]=p,t[24]=m):m=t[24],m}function YC(e){let t=(0,$.c)(24),{template:n,targetLabel:r,onClick:i}=e,{_:a}=cn(),o;t[0]!==n.name||t[1]!==n.title?(o=n.title?.trim()||n.name,t[0]=n.name,t[1]=n.title,t[2]=o):o=t[2];let s=o,c=`${n.name}.md`,l=n.source_folder===``,u;t[3]!==a||t[4]!==s||t[5]!==c||t[6]!==l||t[7]!==r?(u=a(l?{id:`89TtiD`,values:{displayTitle:s,fileName:c}}:{id:`0_J12R`,values:{displayTitle:s,fileName:c,targetLabel:r}}),t[3]=a,t[4]=s,t[5]=c,t[6]=l,t[7]=r,t[8]=u):u=t[8];let d=u,f;t[9]===s?f=t[10]:(f=(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium leading-tight text-foreground/80`,children:s}),t[9]=s,t[10]=f);let p;t[11]===c?p=t[12]:(p=(0,Z.jsx)(`span`,{className:`truncate font-mono text-1sm font-normal text-muted-foreground`,children:c}),t[11]=c,t[12]=p);let m;t[13]!==f||t[14]!==p?(m=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[f,p]}),t[13]=f,t[14]=p,t[15]=m):m=t[15];let h=`shrink-0 font-mono text-1sm ${l?`text-muted-foreground/70`:`text-muted-foreground`}`,g;t[16]!==h||t[17]!==r?(g=(0,Z.jsx)(`span`,{className:h,children:r}),t[16]=h,t[17]=r,t[18]=g):g=t[18];let _;return t[19]!==d||t[20]!==i||t[21]!==m||t[22]!==g?(_=(0,Z.jsxs)(Di,{type:`button`,variant:`ghost`,onClick:i,"aria-label":d,className:`group flex h-auto w-full items-center justify-between gap-4 rounded-none p-4 text-left transition-colors hover:bg-muted/50 focus-visible:bg-muted/50`,children:[m,g]}),t[19]=d,t[20]=i,t[21]=m,t[22]=g,t[23]=_):_=t[23],_}function XC(e){let t=(0,$.c)(20),{terminalVisible:n}=e,r=n===void 0?!1:n,[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(void 0),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(0),f=(0,Q.useRef)(!1),p=(0,Q.useRef)(void 0),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{let e=!1,t=async function(){try{let{ok:t,body:n}=await Po();if(e)return;let r=t?Kn.safeParse(n):null;r?.success?(l($C(r.data.documents)),f.current=!0):f.current||=(l(1),!0)}catch{!e&&!f.current&&(l(1),f.current=!0)}};t();let n=tc(e=>{e.includes(`files`)&&t()});return()=>{e=!0,n(),clearTimeout(p.current)}},h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),(0,Q.useEffect)(m,h);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=function(){clearTimeout(p.current),p.current=setTimeout(()=>d(QC),500),Po().then(e=>{let{ok:t,body:n}=e;if(!t)return;let r=Kn.safeParse(n);r.success&&l($C(r.data.documents))}).catch(ZC)},t[2]=g):g=t[2];let _=g,v=c!==null,y=c===0,b;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(b=function(e){a(e),e||s(void 0)},t[3]=b):b=t[3];let x=b;if(r){let e;t[4]!==u||t[5]!==y||t[6]!==v?(e=v?(0,Z.jsx)(ew,{isOnboarding:y,celebrateSignal:u}):null,t[4]=u,t[5]=y,t[6]=v,t[7]=e):e=t[7];let n;return t[8]===e?n=t[9]:(n=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-end px-6 sm:px-12 md:px-16 pb-8 pt-10`,children:e}),t[8]=e,t[9]=n),n}let S;t[10]!==u||t[11]!==y||t[12]!==v?(S=v?y?(0,Z.jsx)(tw,{celebrateSignal:u,onPackSelect:e=>{s(e),a(!0)}}):(0,Z.jsx)(GC,{celebrateSignal:u,onAddStarterPack:()=>{a(!0)}}):null,t[10]=u,t[11]=y,t[12]=v,t[13]=S):S=t[13];let C;t[14]!==o||t[15]!==i?(C=(0,Z.jsx)(V_,{open:i,onOpenChange:x,onSeedApplied:_,initialPackId:o}),t[14]=o,t[15]=i,t[16]=C):C=t[16];let w;return t[17]!==S||t[18]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center overflow-y-auto px-6 sm:px-12 md:px-16 subtle-scrollbar`,children:[S,C]}),t[17]=S,t[18]=C,t[19]=w):w=t[19],w}function ZC(){}function QC(e){return e+1}function $C(e){return Co(e).filter(e=>e.kind===`document`||e.kind===`folder`).length}function ew(e){let t=(0,$.c)(15),{isOnboarding:n,celebrateSignal:r}=e,{_:i}=cn(),a=es(),o,s,c,l;if(t[0]!==i||t[1]!==a||t[2]!==n){let{title:e,subtitle:r}=VC({isOnboarding:n,isEmbedded:a});l=`w-full max-w-5xl`,o=BC,s=i(e),c=i(r),t[0]=i,t[1]=a,t[2]=n,t[3]=o,t[4]=s,t[5]=c,t[6]=l}else o=t[3],s=t[4],c=t[5],l=t[6];let u;t[7]!==o||t[8]!==r||t[9]!==s||t[10]!==c?(u=(0,Z.jsx)(o,{title:s,subtitle:c,celebrateSignal:r}),t[7]=o,t[8]=r,t[9]=s,t[10]=c,t[11]=u):u=t[11];let d;return t[12]!==l||t[13]!==u?(d=(0,Z.jsx)(`div`,{className:l,children:u}),t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function tw(e){let t=(0,$.c)(28),{celebrateSignal:n,onPackSelect:r}=e,{_:i}=cn(),a=es(),o,s,c,l;if(t[0]!==i||t[1]!==a){let{title:e,subtitle:n}=VC({isOnboarding:!0,isEmbedded:a});l=`flex w-full flex-col gap-10 py-12 max-w-5xl my-auto`,o=BC,s=i(e),c=i(n),t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=c,t[5]=l}else o=t[2],s=t[3],c=t[4],l=t[5];let u;t[6]!==o||t[7]!==n||t[8]!==s||t[9]!==c?(u=(0,Z.jsx)(o,{title:s,subtitle:c,celebrateSignal:n}),t[6]=o,t[7]=n,t[8]=s,t[9]=c,t[10]=u):u=t[10];let d;t[11]===a?d=t[12]:(d=a?(0,Z.jsx)(uS,{scenario:`new-project`}):(0,Z.jsx)(cC,{scenario:`new-project`}),t[11]=a,t[12]=d);let f;t[13]!==i||t[14]!==a?(f=i(a?{id:`GubkSu`}:{id:`xeXS4P`}),t[13]=i,t[14]=a,t[15]=f):f=t[15];let p;t[16]===f?p=t[17]:(p=(0,Z.jsx)(rw,{label:f}),t[16]=f,t[17]=p);let m;t[18]===r?m=t[19]:(m=(0,Z.jsx)(P_,{onPackSelect:r,onCreateBlankFile:nw}),t[18]=r,t[19]=m);let h;t[20]!==p||t[21]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[p,m]}),t[20]=p,t[21]=m,t[22]=h):h=t[22];let g;return t[23]!==l||t[24]!==u||t[25]!==d||t[26]!==h?(g=(0,Z.jsxs)(`div`,{className:l,children:[u,d,h]}),t[23]=l,t[24]=u,t[25]=d,t[26]=h,t[27]=g):g=t[27],g}function nw(){return UC()}function rw(e){let t=(0,$.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,Z.jsx)(`span`,{className:`font-mono text-2xs uppercase tracking-wider text-muted-foreground whitespace-nowrap`,children:n})}),t[0]=n,t[1]=r),r}function iw(e){return e===``?`.ok/frontmatter.yml`:`${e}/.ok/frontmatter.yml`}function aw(e){let t=(0,$.c)(70),{folderPath:n,state:r,onChange:i}=e,{_:a}=cn(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null);if(r.status===`idle`||r.status===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`section`,{className:`rounded-lg border bg-card p-4 space-y-3`,children:[(0,Z.jsx)(sw,{}),(0,Z.jsx)(la,{className:`h-7 w-full`}),(0,Z.jsx)(la,{className:`h-7 w-full`}),(0,Z.jsx)(la,{className:`h-7 w-full`})]}),t[0]=e):e=t[0],e}if(r.status===`error`){let{message:e}=r,n;return t[1]===e?n=t[2]:(n=(0,Z.jsx)(`section`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive`,role:`alert`,children:(0,Z.jsx)(X,{id:`lzmtKp`,values:{message:e}})}),t[1]=e,t[2]=n),n}let f;t[3]===r.data.frontmatterLocal?f=t[4]:(f=r.data.frontmatterLocal??{},t[3]=r.data.frontmatterLocal,t[4]=f);let p=f,m;t[5]===r.data.folder.path?m=t[6]:(m=iw(r.data.folder.path),t[5]=r.data.folder.path,t[6]=m);let h=m,g;t[7]===p?g=t[8]:(g=Object.keys(p),t[7]=p,t[8]=g);let _=g,v;t[9]!==a||t[10]!==n||t[11]!==i?(v=async function(e,t){let r=await As(n,{[e]:t});if(!r.ok){let{error:e}=r;Js.error(a({id:`xXo8FT`,values:{error:e}}));return}i()},t[9]=a,t[10]=n,t[11]=i,t[12]=v):v=t[12];let y=v,b;t[13]!==a||t[14]!==n||t[15]!==i?(b=async function(e){let t=await As(n,{[e]:null});if(!t.ok){let{error:e}=t;Js.error(a({id:`ZU8VV_`,values:{error:e}}));return}i()},t[13]=a,t[14]=n,t[15]=i,t[16]=b):b=t[16];let x=b,S;t[17]!==y||t[18]!==p?(S=function(e,t){let n=p[e];y(e,Qa(n,t))},t[17]=y,t[18]=p,t[19]=S):S=t[19];let C=S,w;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(w=function(){l({name:``,type:`text`,value:``,error:null}),s(!1)},t[20]=w):w=t[20];let T=w,E;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(E=function(e){l(t=>{if(!t)return t;let n=e===`date`?new Date().toISOString().slice(0,10):qa[e];return{...t,type:e,value:n,error:null}})},t[21]=E):E=t[21];let D=E,O;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(O=function(e){l(t=>t&&{...t,value:e})},t[22]=O):O=t[22];let k=O,A;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(A=function(e){l(t=>t&&{...t,name:e,error:null})},t[23]=A):A=t[23];let j=A,M;t[24]!==a||t[25]!==c||t[26]!==n||t[27]!==i||t[28]!==p?(M=async function(e){if(!c)return;let t=e??c.value,r=c.name.trim();if(!r){l({...c,value:t,error:a({id:`8_brI5`})});return}if(yr(t)){l({...c,value:t,error:a({id:`hXUWyd`})});return}if(Object.hasOwn(p,r)){l({...c,value:t,error:a({id:`CTJLpz`,values:{trimmed:r}})});return}let o=await As(n,{[r]:t});if(!o.ok){l({...c,value:t,error:o.error});return}l(null),i()},t[24]=a,t[25]=c,t[26]=n,t[27]=i,t[28]=p,t[29]=M):M=t[29];let N=M,P;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(P=function(e){d({key:e,draft:e,error:null})},t[30]=P):P=t[30];let F=P,I;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(I=function(e){d(t=>t&&{...t,draft:e,error:null})},t[31]=I):I=t[31];let L=I,R;t[32]!==a||t[33]!==n||t[34]!==i||t[35]!==p||t[36]!==u?(R=async function(){if(!u)return;let e=u.draft.trim();if(!e){d({...u,error:a({id:`8_brI5`})});return}if(e===u.key){d(null);return}if(Object.hasOwn(p,e)){d({...u,error:a({id:`CTJLpz`,values:{trimmed:e}})});return}let t=p[u.key],r=await As(n,{[u.key]:null,[e]:t});if(!r.ok){d({...u,error:r.error});return}d(null),i()},t[32]=a,t[33]=n,t[34]=i,t[35]=p,t[36]=u,t[37]=R):R=t[37];let z=R,B;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(B=function(){d(null)},t[38]=B):B=t[38];let V=B,H=!o,U;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>s(!e),t[39]=U):U=t[39];let W=`size-3 transition-transform ${o?``:`rotate-90`}`,G;t[40]===W?G=t[41]:(G=(0,Z.jsx)(co,{className:W,"aria-hidden":!0}),t[40]=W,t[41]=G);let K;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Z.jsx)(`span`,{children:(0,Z.jsx)(X,{id:`vQIVHc`})}),t[42]=K):K=t[42];let q;t[43]===G?q=t[44]:(q=(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase font-mono tracking-wider text-muted-foreground`,children:[G,K]}),t[43]=G,t[44]=q);let J;t[45]===h?J=t[46]:(J=(0,Z.jsx)(`code`,{className:`text-xs text-muted-foreground font-mono cursor-text select-text`,onClick:ow,children:h}),t[45]=h,t[46]=J);let Y;t[47]!==q||t[48]!==J?(Y=(0,Z.jsxs)(Hs,{className:`flex w-full cursor-pointer items-center justify-between gap-2 px-3 py-2.5 data-[state=open]:border-b border-border`,children:[q,J]}),t[47]=q,t[48]=J,t[49]=Y):Y=t[49];let ee;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(`p`,{className:`px-1 pb-2 text-sm text-muted-foreground`,children:(0,Z.jsx)(X,{id:`hSBIG-`})}),t[50]=ee):ee=t[50];let te;t[51]!==c||t[52]!==y||t[53]!==z||t[54]!==_||t[55]!==p||t[56]!==x||t[57]!==u||t[58]!==C?(te=_.length===0&&!c?(0,Z.jsx)(`p`,{className:`px-1 py-1 text-sm text-muted-foreground`,children:(0,Z.jsx)(X,{id:`4c_a6S`})}):_.map(e=>{let t=p[e];return(0,Z.jsx)(Xa,{keyName:e,value:t,declared:Ga(t,pr(t)),rename:{state:u?.key===e?u:null,onBegin:()=>F(e),onChangeDraft:L,onCommit:z,onCancel:V},badge:null,onCommit:t=>void y(e,t),onChangeType:t=>C(e,t),onRemove:()=>void x(e)},e)}),t[51]=c,t[52]=y,t[53]=z,t[54]=_,t[55]=p,t[56]=x,t[57]=u,t[58]=C,t[59]=te):te=t[59];let ne;t[60]!==c||t[61]!==N?(ne=c?(0,Z.jsx)(Ja,{draft:c,onChangeName:j,onChangeType:D,onChangeValue:k,onCommit:e=>void N(e),onCancel:()=>l(null)}):(0,Z.jsx)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:(0,Z.jsxs)(Di,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`add-property-trigger`,onClick:()=>T(),className:`flex items-center gap-1.5 rounded px-2 py-1 font-medium text-sm hover:bg-muted/50 hover:text-foreground`,children:[(0,Z.jsx)(xt,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(X,{id:`G8t9NN`})})]})}),t[60]=c,t[61]=N,t[62]=ne):ne=t[62];let re;t[63]!==te||t[64]!==ne?(re=(0,Z.jsx)(Vs,{children:(0,Z.jsxs)(`div`,{className:`px-2 py-2`,children:[ee,te,ne]})}),t[63]=te,t[64]=ne,t[65]=re):re=t[65];let ie;return t[66]!==H||t[67]!==Y||t[68]!==re?(ie=(0,Z.jsx)(`section`,{className:`rounded-lg border bg-card`,children:(0,Z.jsxs)(Us,{open:H,onOpenChange:U,children:[Y,re]})}),t[66]=H,t[67]=Y,t[68]=re,t[69]=ie):ie=t[69],ie}function ow(e){return e.stopPropagation()}function sw(){let e=(0,$.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Xu,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase font-mono tracking-wider text-muted-foreground`,children:(0,Z.jsx)(X,{id:`vQIVHc`})})]}),e[1]=n):n=e[1],n}function cw(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);return t<60?ic._({id:`xOTzt5`}):t<3600?ic._({id:`zbymaY`,values:{0:Math.floor(t/60)}}):t<86400?ic._({id:`optX0N`,values:{0:Math.floor(t/3600)}}):t<86400*7?ic._({id:`l1l8sj`,values:{0:Math.floor(t/86400)}}):new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function lw(e){return(e.split(`/`).pop()??e).replace(/\.md$/,``)}function uw(e){let t=e.message,n=t.indexOf(`: `),r=n===-1?t:t.slice(0,n),i=n===-1?``:t.slice(n+2);switch(r){case`template-create`:return{Icon:ha,label:ic._({id:`QR5SP1`}),detail:lw(i)};case`template-edit`:return{Icon:ws,label:ic._({id:`-LHLx7`}),detail:lw(i)};case`template-delete`:return{Icon:vs,label:ic._({id:`_gkGSK`}),detail:lw(i)};case`template-rename`:case`template-move`:{let[e,t]=i.split(` -> `);return{Icon:Tu,label:ic._({id:`KPW5WC`}),detail:`${lw(e??``)} → ${lw(t??i)}`}}case`folder-frontmatter-edit`:return{Icon:Xu,label:ic._({id:`_tekeB`}),detail:``};case`folder-frontmatter-delete`:return{Icon:Xu,label:ic._({id:`ZWxfrc`}),detail:``};case`folder-create`:return{Icon:Xu,label:ic._({id:`ZQLDTl`}),detail:``};default:return{Icon:rd,label:r.replace(/-/g,` `),detail:lw(i)}}}function dw(e){return e.contributors.length>0?e.contributors[0].name:e.author===`openknowledge-service`||e.author===`server`?ic._({id:`B2DrPb`}):e.author||ic._({id:`Ef7StM`})}function fw(e){let t=(0,$.c)(15),{folderPath:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Q.useState)(r),[o,s]=(0,Q.useState)(!0),[c,l]=(0,Q.useState)(!1),u,d;if(t[1]===n?(u=t[2],d=t[3]):(u=()=>{let e=!1,t=async function(){try{let t=await fetch(`/api/history?folder=${encodeURIComponent(n)}&limit=50`);if(e)return;if(!t.ok){l(!0),s(!1);return}let r=await t.json();if(e)return;a(r.entries??[]),l(!1),s(!1)}catch(t){e||(console.warn(`[FolderTimelineCard] failed to load folder timeline:`,t),l(!0),s(!1))}};s(!0),t();let r=Qs(t);return()=>{e=!0,r()}},d=[n],t[1]=n,t[2]=u,t[3]=d),(0,Q.useEffect)(u,d),c||!o&&i.length===0)return null;let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase font-mono tracking-wider text-muted-foreground`,children:(0,Z.jsx)(X,{id:`XJOV1Y`})}),t[4]=f):f=t[4];let p;t[5]===i.length?p=t[6]:(p=i.length>0?(0,Z.jsx)(Be,{className:`text-xs`,variant:`secondary`,children:i.length}):null,t[5]=i.length,t[6]=p);let m;t[7]===p?m=t[8]:(m=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-1`,children:[f,p]}),t[7]=p,t[8]=m);let h;t[9]!==i||t[10]!==o?(h=(0,Z.jsx)(`div`,{className:`px-3 py-2.5`,children:o?(0,Z.jsxs)(`div`,{className:`space-y-2`,role:`status`,"aria-busy":`true`,children:[(0,Z.jsx)(la,{className:`h-8 w-full`}),(0,Z.jsx)(la,{className:`h-8 w-full`})]}):(0,Z.jsx)(`ul`,{className:`space-y-1`,children:i.map(pw)})}),t[9]=i,t[10]=o,t[11]=h):h=t[11];let g;return t[12]!==m||t[13]!==h?(g=(0,Z.jsxs)(`section`,{className:`rounded-lg border bg-card`,"data-testid":`folder-timeline-card`,children:[m,h]}),t[12]=m,t[13]=h,t[14]=g):g=t[14],g}function pw(e){let{Icon:t,label:n,detail:r}=uw(e);return(0,Z.jsxs)(`li`,{className:`flex items-center gap-2.5 rounded-md px-2 py-1.5 text-sm`,children:[(0,Z.jsx)(t,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,Z.jsx)(`span`,{className:`text-foreground`,children:n}),r?(0,Z.jsx)(`code`,{className:`ml-1.5 font-mono text-xs text-muted-foreground`,children:r}):null]}),(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(qd,{className:`size-3`,"aria-hidden":!0}),dw(e)]}),(0,Z.jsx)(`time`,{className:`shrink-0 text-xs text-muted-foreground/80`,dateTime:e.timestamp,title:new Date(e.timestamp).toLocaleString(),children:cw(e.timestamp)})]},e.sha)}function mw(e){let t=e.split(`/`).pop();return t?`${e}/${t}`:null}function hw(e,t){let n=t.get(`${e}/index`);if(n)return n;let r=mw(e);if(r){let e=t.get(r);if(e)return e}return e.split(`/`).pop()??e}function gw(e,t,n){let r=n.get(e);return r&&r!==e?r:t}function _w(e,t){let n=e===``?``:`${e}/`,r=[...t.folderPaths].filter(e=>e.startsWith(n)).map(e=>({path:e,rel:e.slice(n.length)})).filter(e=>e.rel.length>0&&!e.rel.includes(`/`)).map(({path:e,rel:n})=>({kind:`folder`,path:e,name:n,title:hw(e,t.pageTitles)})),i=[...t.pages].filter(e=>e.startsWith(n)).map(e=>({docName:e,rel:e.slice(n.length)})).filter(e=>e.rel.length>0&&!e.rel.includes(`/`)).map(({docName:e,rel:n})=>{let r=t.pageMeta.get(e);return{kind:`file`,path:e,name:n,title:gw(e,n,t.pageTitles),size:r?.size??0,modified:r?.modified??``}}),a=[...r,...i].sort((e,t)=>e.kind===t.kind?e.title.localeCompare(t.title)||e.name.localeCompare(t.name):e.kind===`folder`?-1:1);return{title:hw(e,t.pageTitles),children:a}}function vw(e){let t=(0,$.c)(41),{folderPath:n,state:r,onChange:i,folderConfigHandle:a}=e,[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!1);if(r.status===`idle`||r.status===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`section`,{className:`rounded-lg border bg-card px-3 py-2.5 space-y-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase font-mono tracking-wider text-muted-foreground`,children:(0,Z.jsx)(X,{id:`-QCLWk`})})}),(0,Z.jsx)(la,{className:`h-12 w-full`}),(0,Z.jsx)(la,{className:`h-12 w-full`})]}),t[0]=e):e=t[0],e}if(r.status===`error`){let{message:e}=r,n;return t[1]===e?n=t[2]:(n=(0,Z.jsx)(`section`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive`,role:`alert`,children:(0,Z.jsx)(X,{id:`iDZtvM`,values:{message:e}})}),t[1]=e,t[2]=n),n}let f;t[3]===r.data.folder.templates_available?f=t[4]:(f=r.data.folder.templates_available??[],t[3]=r.data.folder.templates_available,t[4]=f);let p=f,m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase font-mono tracking-wider text-muted-foreground`,children:(0,Z.jsx)(X,{id:`-QCLWk`})}),t[5]=m):m=t[5];let h;t[6]===p.length?h=t[7]:(h=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[m,(0,Z.jsx)(Be,{className:`text-xs`,variant:`secondary`,children:p.length})]}),t[6]=p.length,t[7]=h);let g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsxs)(Di,{variant:`ghost`,className:`font-mono uppercase`,size:`sm`,onClick:()=>d(!0),children:[(0,Z.jsx)(xt,{className:`size-3.5`,"aria-hidden":!0}),(0,Z.jsx)(X,{id:`G1Gw0v`})]}),t[8]=g):g=t[8];let _;t[9]===h?_=t[10]:(_=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-1`,children:[h,g]}),t[9]=h,t[10]=_);let y;t[11]===p?y=t[12]:(y=(0,Z.jsx)(`div`,{className:`px-3 py-2.5`,children:p.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Z.jsx)(X,{id:`MZSBsh`})}):(0,Z.jsx)(`ul`,{className:`space-y-1`,children:p.map(e=>(0,Z.jsx)(Ra,{template:e,onCreate:()=>l(e.name),onEdit:()=>Is(v(e.source_folder,e.name)),onDelete:()=>s(e),badge:e.scope===`inherited`?(0,Z.jsx)(Wa,{source:e.source_folder,target:`templates/${e.name}.md`}):void 0},e.path))})}),t[11]=p,t[12]=y);let b;t[13]!==_||t[14]!==y?(b=(0,Z.jsxs)(`section`,{className:`rounded-lg border bg-card`,children:[_,y]}),t[13]=_,t[14]=y,t[15]=b):b=t[15];let x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{e||s(null)},t[16]=x):x=t[16];let S;t[17]!==o||t[18]!==i?(S=(0,Z.jsx)(zi,{template:o,onOpenChange:x,onDeleted:i}),t[17]=o,t[18]=i,t[19]=S):S=t[19];let C;t[20]===p?C=t[21]:(C=new Set(p.map(yw)),t[20]=p,t[21]=C);let w;t[22]!==n||t[23]!==i?(w=e=>{i(),Is(v(n,e))},t[22]=n,t[23]=i,t[24]=w):w=t[24];let T;t[25]!==n||t[26]!==u||t[27]!==C||t[28]!==w?(T=(0,Z.jsx)(ta,{folderPath:n,existingNames:C,open:u,onOpenChange:d,onCreated:w}),t[25]=n,t[26]=u,t[27]=C,t[28]=w,t[29]=T):T=t[29];let E=c!==null,D;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{e||l(null)},t[30]=D):D=t[30];let O=c??void 0,k;t[31]!==a||t[32]!==n||t[33]!==E||t[34]!==O?(k=(0,Z.jsx)(__,{open:E,onOpenChange:D,kind:`file`,initialDir:n,initialTemplate:O,folderConfig:a}),t[31]=a,t[32]=n,t[33]=E,t[34]=O,t[35]=k):k=t[35];let A;return t[36]!==T||t[37]!==k||t[38]!==b||t[39]!==S?(A=(0,Z.jsxs)(Z.Fragment,{children:[b,S,T,k]}),t[36]=T,t[37]=k,t[38]=b,t[39]=S,t[40]=A):A=t[40],A}function yw(e){return e.name}function bw(e){let t=(0,$.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,containerClassName:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=Ti(`relative w-full overflow-x-auto subtle-scrollbar`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=Ti(`w-full caption-bottom text-sm`,n),t[6]=n,t[7]=o);let s;t[8]!==i||t[9]!==o?(s=(0,Z.jsx)(`table`,{"data-slot":`table`,className:o,...i}),t[8]=i,t[9]=o,t[10]=s):s=t[10];let c;return t[11]!==a||t[12]!==s?(c=(0,Z.jsx)(`div`,{"data-slot":`table-container`,className:a,children:s}),t[11]=a,t[12]=s,t[13]=c):c=t[13],c}function xw(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`[&_tr]:border-b`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`thead`,{"data-slot":`table-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Sw(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`[&_tr:last-child]:border-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`tbody`,{"data-slot":`table-body`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Cw(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,noHover:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(i===void 0?!1:i)&&`hover:bg-transparent`,o;t[4]!==n||t[5]!==a?(o=Ti(`hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors`,a,n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(`tr`,{"data-slot":`table-row`,className:o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function ww(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,scope:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`col`:i,o;t[4]===n?o=t[5]:(o=Ti(`font-mono uppercase text-xs text-muted-foreground h-10 px-4 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,Z.jsx)(`th`,{"data-slot":`table-head`,scope:a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function Tw(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`py-3 px-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`td`,{"data-slot":`table-cell`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ew(e){if(!e)return`—`;let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return ic._({id:`xOTzt5`});if(r<60)return ic._({id:`NRSLBe`,values:{diffMin:r}});let i=Math.floor(r/60);if(i<24)return ic._({id:`hDKtoF`,values:{diffHrs:i}});let a=Math.floor(i/24);return a<30?ic._({id:`QDZbvN`,values:{diffDays:a}}):t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function Dw(e,t,n){return[...e].sort((e,r)=>{if(e.kind!==r.kind)return e.kind===`folder`?-1:1;let i=0;switch(t){case`name`:i=e.title.localeCompare(r.title)||e.name.localeCompare(r.name);break;case`modified`:{let t=e.kind===`file`?e.modified:``,n=r.kind===`file`?r.modified:``;i=t.localeCompare(n);break}}return n===`asc`?i:-i})}function Ow(e){let t=(0,$.c)(10),{label:n,sortKey:r,activeKey:i,activeDir:a,onSort:o}=e,s=i===r,c;t[0]!==o||t[1]!==r?(c=()=>o(r),t[0]=o,t[1]=r,t[2]=c):c=t[2];let l;t[3]!==a||t[4]!==s?(l=s?a===`asc`?(0,Z.jsx)(R,{className:`ml-1 size-3`}):(0,Z.jsx)(B,{className:`ml-1 size-3`}):(0,Z.jsx)(Eu,{className:`ml-1 size-3 text-muted-foreground/50`}),t[3]=a,t[4]=s,t[5]=l):l=t[5];let u;return t[6]!==n||t[7]!==c||t[8]!==l?(u=(0,Z.jsxs)(Di,{variant:`ghost`,size:`sm`,className:`-ml-3 h-8 uppercase font-mono`,onClick:c,children:[n,l]}),t[6]=n,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}function kw(e){let t=(0,$.c)(96),{folderPath:n}=e,{_:r}=cn(),{folderPaths:i,loading:a,pages:o,pageTitles:s,pageMeta:c}=Oo(),l=Aa(n),{state:u,refresh:d}=l,[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(`name`),[g,_]=(0,Q.useState)(`asc`);if(a){let e;t[0]===r?e=t[1]:(e=r({id:`X9VpsP`}),t[0]=r,t[1]=e);let n;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(la,{className:`size-5 rounded`}),(0,Z.jsx)(la,{className:`h-7 w-48`})]}),(0,Z.jsx)(la,{className:`h-9 w-20 rounded-md`})]}),t[2]=n):n=t[2];let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(la,{className:`h-4 w-16`}),t[3]=i):i=t[3];let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`,children:[n,(0,Z.jsxs)(`div`,{className:`rounded-lg border`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-4 border-b px-4 py-3`,children:[i,(0,Z.jsx)(`div`,{className:`ml-auto`,children:(0,Z.jsx)(la,{className:`h-4 w-20`})})]}),[`a`,`b`,`c`,`d`].map(Mw)]})]}),t[4]=a):a=t[4];let o;return t[5]===e?o=t[6]:(o=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,role:`status`,"aria-busy":`true`,"aria-label":e,children:a}),t[5]=e,t[6]=o),o}let v,y,b,x,S,C,w,T,E,D,O;if(t[7]!==r||t[8]!==u||t[9]!==l||t[10]!==n||t[11]!==i||t[12]!==c||t[13]!==s||t[14]!==o||t[15]!==d||t[16]!==g||t[17]!==m){let e=_w(n,{pages:o,pageTitles:s,pageMeta:c,folderPaths:i}),a=Dw(e.children,m,g),f=e.title||(n===``?r({id:`3aeN7X`}):e.title),k;t[29]===m?k=t[30]:(k=function(e){e===m?_(jw):(h(e),_(`asc`))},t[29]=m,t[30]=k);let A=k;O=`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,C=`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`;let j;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(gs,{className:`size-5 text-muted-foreground`}),t[31]=j):j=t[31];let M=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[j,(0,Z.jsx)(`h1`,{className:`text-2xl font-light tracking-tight`,children:f})]}),N;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsxs)(Di,{onClick:()=>p(!0),children:[(0,Z.jsx)(xt,{className:`size-4`}),(0,Z.jsx)(X,{id:`isRobC`})]}),t[32]=N):N=t[32],t[33]===M?w=t[34]:(w=(0,Z.jsx)(`div`,{className:`flex flex-col gap-6`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[M,N]})}),t[33]=M,t[34]=w),t[35]!==u||t[36]!==n||t[37]!==d?(T=(0,Z.jsx)(aw,{folderPath:n,state:u,onChange:d}),t[35]=u,t[36]=n,t[37]=d,t[38]=T):T=t[38],t[39]!==u||t[40]!==l||t[41]!==n||t[42]!==d?(E=(0,Z.jsx)(vw,{folderPath:n,state:u,onChange:d,folderConfigHandle:l}),t[39]=u,t[40]=l,t[41]=n,t[42]=d,t[43]=E):E=t[43],t[44]===n?D=t[45]:(D=(0,Z.jsx)(fw,{folderPath:n}),t[44]=n,t[45]=D),S=`rounded-lg border`,y=bw;let P=m===`name`?g===`asc`?`ascending`:`descending`:`none`,F;t[46]===r?F=t[47]:(F=r({id:`6YtxFj`}),t[46]=r,t[47]=F);let I;t[48]!==A||t[49]!==g||t[50]!==m||t[51]!==F?(I=(0,Z.jsx)(Ow,{label:F,sortKey:`name`,activeKey:m,activeDir:g,onSort:A}),t[48]=A,t[49]=g,t[50]=m,t[51]=F,t[52]=I):I=t[52];let L;t[53]!==P||t[54]!==I?(L=(0,Z.jsx)(ww,{"aria-sort":P,children:I}),t[53]=P,t[54]=I,t[55]=L):L=t[55];let R=m===`modified`?g===`asc`?`ascending`:`descending`:`none`,z;t[56]===r?z=t[57]:(z=r({id:`tgWuMB`}),t[56]=r,t[57]=z);let B;t[58]!==A||t[59]!==g||t[60]!==m||t[61]!==z?(B=(0,Z.jsx)(Ow,{label:z,sortKey:`modified`,activeKey:m,activeDir:g,onSort:A}),t[58]=A,t[59]=g,t[60]=m,t[61]=z,t[62]=B):B=t[62];let V;t[63]!==R||t[64]!==B?(V=(0,Z.jsx)(ww,{className:`w-32`,"aria-sort":R,children:B}),t[63]=R,t[64]=B,t[65]=V):V=t[65],t[66]!==L||t[67]!==V?(x=(0,Z.jsx)(xw,{children:(0,Z.jsxs)(Cw,{children:[L,V]})}),t[66]=L,t[67]=V,t[68]=x):x=t[68],v=Sw,b=a.length?a.map(Aw):(0,Z.jsx)(Cw,{children:(0,Z.jsx)(Tw,{colSpan:2,className:`h-24 text-center text-muted-foreground`,children:(0,Z.jsx)(X,{id:`Pkw7J9`})})}),t[7]=r,t[8]=u,t[9]=l,t[10]=n,t[11]=i,t[12]=c,t[13]=s,t[14]=o,t[15]=d,t[16]=g,t[17]=m,t[18]=v,t[19]=y,t[20]=b,t[21]=x,t[22]=S,t[23]=C,t[24]=w,t[25]=T,t[26]=E,t[27]=D,t[28]=O}else v=t[18],y=t[19],b=t[20],x=t[21],S=t[22],C=t[23],w=t[24],T=t[25],E=t[26],D=t[27],O=t[28];let k;t[69]!==v||t[70]!==b?(k=(0,Z.jsx)(v,{children:b}),t[69]=v,t[70]=b,t[71]=k):k=t[71];let A;t[72]!==y||t[73]!==k||t[74]!==x?(A=(0,Z.jsxs)(y,{children:[x,k]}),t[72]=y,t[73]=k,t[74]=x,t[75]=A):A=t[75];let j;t[76]!==A||t[77]!==S?(j=(0,Z.jsx)(`div`,{className:S,children:A}),t[76]=A,t[77]=S,t[78]=j):j=t[78];let M;t[79]!==j||t[80]!==C||t[81]!==w||t[82]!==T||t[83]!==E||t[84]!==D?(M=(0,Z.jsxs)(`div`,{className:C,children:[w,T,E,D,j]}),t[79]=j,t[80]=C,t[81]=w,t[82]=T,t[83]=E,t[84]=D,t[85]=M):M=t[85];let N;t[86]!==M||t[87]!==O?(N=(0,Z.jsx)(`div`,{className:O,children:M}),t[86]=M,t[87]=O,t[88]=N):N=t[88];let P;t[89]!==f||t[90]!==l||t[91]!==n?(P=(0,Z.jsx)(__,{open:f,onOpenChange:p,kind:`file`,initialDir:n,folderConfig:l,suggestedName:`index`}),t[89]=f,t[90]=l,t[91]=n,t[92]=P):P=t[92];let F;return t[93]!==N||t[94]!==P?(F=(0,Z.jsxs)(Z.Fragment,{children:[N,P]}),t[93]=N,t[94]=P,t[95]=F):F=t[95],F}function Aw(e){return(0,Z.jsxs)(Cw,{children:[(0,Z.jsx)(Tw,{children:(0,Z.jsxs)(`a`,{href:Ao(e.path),className:`flex items-center gap-2 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[e.kind===`folder`?(0,Z.jsx)(Qu,{className:`size-4 shrink-0 text-muted-foreground`}):(0,Z.jsx)(rn,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.title})]})}),(0,Z.jsx)(Tw,{className:`text-muted-foreground`,children:e.kind===`file`?Ew(e.modified):`—`})]},e.path)}function jw(e){return e===`asc`?`desc`:`asc`}function Mw(e){return(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 last:border-b-0`,children:[(0,Z.jsx)(la,{className:`size-4 rounded`}),(0,Z.jsx)(la,{className:`h-4 w-40`}),(0,Z.jsx)(`div`,{className:`ml-auto`,children:(0,Z.jsx)(la,{className:`h-4 w-16`})})]},e)}function Nw(e){let t=(0,$.c)(24),{docName:n,size:r,limit:i,backNav:a}=e,o=a!==void 0,s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l,u;t[0]===o?(l=t[1],u=t[2]):(l=()=>{o?s.current?.focus():c.current?.focus()},u=[o],t[0]=o,t[1]=l,t[2]=u),(0,Q.useEffect)(l,u);let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(`div`,{className:`flex size-16 items-center justify-center rounded-full border bg-muted/40 text-muted-foreground`,children:(0,Z.jsx)(qu,{className:`size-9`,"aria-hidden":`true`})}),t[3]=d):d=t[3];let f=o?void 0:-1,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(X,{id:`P3hnm0`}),t[4]=p):p=t[4];let m;t[5]===f?m=t[6]:(m=(0,Z.jsx)(`h2`,{ref:c,id:`large-file-title`,tabIndex:f,className:`text-2xl font-light text-balance outline-none`,children:p}),t[5]=f,t[6]=m);let h;t[7]===r?h=t[8]:(h=Dr(r),t[7]=r,t[8]=h);let g;t[9]===i?g=t[10]:(g=Dr(i),t[9]=i,t[10]=g);let _;t[11]!==n||t[12]!==h||t[13]!==g?(_=(0,Z.jsx)(`p`,{className:`max-w-md text-sm text-muted-foreground`,children:(0,Z.jsx)(X,{id:`GJH-AT`,values:{0:h,1:g,docName:n}})}),t[11]=n,t[12]=h,t[13]=g,t[14]=_):_=t[14];let v;t[15]!==m||t[16]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[m,_]}),t[15]=m,t[16]=_,t[17]=v):v=t[17];let y;t[18]!==a||t[19]!==o?(y=o?(0,Z.jsxs)(Di,{ref:s,variant:`default`,onClick:()=>a.onNavigateBack(a.previousDocName),children:[(0,Z.jsx)(Mi,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(X,{id:`CKyk7Q`})]}):null,t[18]=a,t[19]=o,t[20]=y):y=t[20];let b;return t[21]!==v||t[22]!==y?(b=(0,Z.jsxs)(`div`,{role:`status`,"aria-labelledby":`large-file-title`,"data-slot":`large-file-editor-state`,className:`flex h-full flex-col items-center justify-center gap-8 p-8 text-center`,children:[d,v,y]}),t[21]=v,t[22]=y,t[23]=b):b=t[23],b}function Pw(e){let t=(0,$.c)(8),{docName:n}=e,[r,i]=(0,Q.useState)(Fw),a,o;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>sn(e=>{i(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})}),o=[],t[0]=a,t[1]=o):(a=t[0],o=t[1]),(0,Q.useEffect)(a,o),!r.has(n))return null;let s;t[2]===n?s=t[3]:(s=function(){A(n)?.abort(),i(e=>{if(!e.has(n))return e;let t=new Set(e);return t.delete(n),t})},t[2]=n,t[3]=s);let c=s,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`span`,{children:(0,Z.jsx)(X,{id:`A67Uwj`})}),t[4]=l):l=t[4];let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(X,{id:`dEgA5A`}),t[5]=u):u=t[5];let d;return t[6]===c?d=t[7]:(d=(0,Z.jsxs)(`div`,{className:`absolute inset-x-0 bottom-8 z-20 flex justify-center text-xs text-muted-foreground`,children:[l,(0,Z.jsx)(Di,{variant:`link`,size:`sm`,className:`h-auto px-2 py-0 text-xs`,onClick:c,children:u})]}),t[6]=c,t[7]=d),d}function Fw(){return new Set}function Iw(e){let t=(0,$.c)(24),{fileName:n,text:r}=e,i,a,o,s;if(t[0]!==r){let e=jr(r).body;s=pe,i=Ct,a=!1,o=Lt().parseWithFallback(e),t[0]=r,t[1]=i,t[2]=a,t[3]=o,t[4]=s}else i=t[1],a=t[2],o=t[3],s=t[4];let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c={attributes:{class:`pt-4 pb-4`}},t[5]=c):c=t[5];let l;t[6]!==i||t[7]!==a||t[8]!==o?(l={extensions:i,editable:a,content:o,editorProps:c},t[6]=i,t[7]=a,t[8]=o,t[9]=l):l=t[9];let u;t[10]===r?u=t[11]:(u=[r],t[10]=r,t[11]=u);let f=s(l,u),[p]=(0,Q.useState)(Lw),m=(0,Q.useRef)(null),h,g;t[12]===p?(h=t[13],g=t[14]):(h=()=>{let e=m.current;if(e)return e.appendChild(p),()=>{p.parentNode===e&&e.removeChild(p)}},g=[p],t[12]=p,t[13]=h,t[14]=g),(0,Q.useLayoutEffect)(h,g);let _;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(`div`,{className:`editor-doc-scroll min-h-0 flex-1 overflow-auto`,children:(0,Z.jsx)(`div`,{className:`tiptap-editor`,children:(0,Z.jsx)(`div`,{ref:m,style:{display:`contents`}})})}),t[15]=_):_=t[15];let v;t[16]===f?v=t[17]:(v=(0,Z.jsx)(d,{editor:f,className:`tiptap-editor-portal-content h-full`}),t[16]=f,t[17]=v);let y;t[18]!==p||t[19]!==v?(y=(0,Au.createPortal)(v,p),t[18]=p,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==n||t[22]!==y?(b=(0,Z.jsxs)(`main`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":n,"data-skill-markdown-viewer":``,"data-skill-markdown-viewer-state":`loaded`,children:[_,y]}),t[21]=n,t[22]=y,t[23]=b):b=t[23],b}function Lw(){let e=document.createElement(`div`);return e.style.display=`contents`,e}var Rw=`data-skill-markdown`;function zw(e){let t=(0,$.c)(12),{scope:n,name:r,path:i,fileName:a}=e,o;t[0]!==r||t[1]!==i||t[2]!==n?(o={loadText:e=>nl({scope:n,name:r,path:i},e)},t[0]=r,t[1]=i,t[2]=n,t[3]=o):o=t[3];let s=$x(o);if(s.status===`loading`){let e;return t[4]===a?e=t[5]:(e=(0,Z.jsx)(eS,{fileName:a,dataAttr:Rw}),t[4]=a,t[5]=e),e}if(s.status===`error`){let e;return t[6]!==s.message||t[7]!==a?(e=(0,Z.jsx)(tS,{fileName:a,dataAttr:Rw,message:s.message}),t[6]=s.message,t[7]=a,t[8]=e):e=t[8],e}let c;return t[9]!==s.content||t[10]!==a?(c=(0,Z.jsx)(Iw,{fileName:a,text:s.content}),t[9]=s.content,t[10]=a,t[11]=c):c=t[11],c}var Bw=new Set([`md`,`mdx`]);function Vw(e){let t=(0,$.c)(19),{scope:n,name:r,path:i}=e,a;t[0]===i?a=t[1]:(a=i.split(`/`).pop()??i,t[0]=i,t[1]=a);let o=a,s=o.lastIndexOf(`.`),c,l;if(t[2]!==s||t[3]!==o?(c=s>=0?o.slice(s+1).toLowerCase():``,l=Bw.has(c),t[2]=s,t[3]=o,t[4]=c,t[5]=l):(c=t[4],l=t[5]),l){let e;return t[6]!==o||t[7]!==r||t[8]!==i||t[9]!==n?(e=(0,Z.jsx)(zw,{scope:n,name:r,path:i,fileName:o}),t[6]=o,t[7]=r,t[8]=i,t[9]=n,t[10]=e):e=t[10],e}let u;t[11]!==r||t[12]!==i||t[13]!==n?(u=e=>nl({scope:n,name:r,path:i},e),t[11]=r,t[12]=i,t[13]=n,t[14]=u):u=t[14];let d;return t[15]!==c||t[16]!==o||t[17]!==u?(d=(0,Z.jsx)(iS,{fileName:o,extension:c,loadText:u}),t[15]=c,t[16]=o,t[17]=u,t[18]=d):d=t[18],d}function Hw(e){let t=null,n=()=>(t===null&&(t=e(),t.catch(()=>{})),t),r=(0,Q.lazy)(n);return r.preload=n,r}var Uw=Hw(()=>n(()=>import(`./SettingsDialogBody-zAPqVjri.js`).then(e=>({default:e.SettingsDialogBody})),__vite__mapDeps([65,1,47,2,48,49,31,50,51,52,53,54,55,56,57,20,9,10,7,11,30,3,32,6,4,15,12,13,22,14,58,16,43,59,23,60,66,8,67,21,18,19,68,33,69,62,24,45,70]),import.meta.url));function Ww(e){let t=(0,$.c)(9),{error:n}=e,{_:r}=cn(),i;t[0]!==r||t[1]!==n?(i=n instanceof Error&&/dynamically imported module|Failed to fetch/i.test(n.message)?r({id:`Y8ViJx`}):r({id:`3h5zMp`}),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`h3`,{id:`settings-body-error-title`,className:`font-heading text-base leading-none font-medium`,children:(0,Z.jsx)(X,{id:`hwFOFD`})}),t[3]=o):o=t[3];let s;t[4]===a?s=t[5]:(s=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[o,(0,Z.jsx)(`p`,{className:`max-w-xs text-sm text-muted-foreground`,children:a})]}),t[4]=a,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Di,{variant:`default`,onClick:Gw,children:(0,Z.jsx)(X,{id:`HpK_8d`})}),t[6]=c):c=t[6];let l;return t[7]===s?l=t[8]:(l=(0,Z.jsxs)(`div`,{role:`alert`,"aria-labelledby":`settings-body-error-title`,"data-slot":`settings-body-error-boundary`,className:`flex h-full flex-col items-center justify-center gap-5 p-8 text-center`,children:[s,c]}),t[7]=s,t[8]=l),l}function Gw(){return window.location.reload()}function Kw(e){let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(g,{fallbackRender:Jw,onError:qw,children:n}),t[0]=n,t[1]=r),r}function qw(e,t){console.error(`[SettingsDialogErrorBoundary] rendered fallback for Settings body`,e,t.componentStack)}function Jw(e){return(0,Z.jsx)(Ww,{...e})}function Yw(e){return`https://github.com/inkeep/open-knowledge/releases/tag/v${encodeURIComponent(e)}`}function Xw(e){let t=(0,$.c)(94),{open:n,onOpenChange:r}=e,{_:i}=cn(),{collabUrl:a}=_t(),{userBinding:o,userSynced:s,okignoreBinding:c,okignoreSynced:l}=bs(),{desktopPresent:u}=Qi(),[d,f]=(0,Q.useState)(`preferences`),p,m;t[0]===n?(p=t[1],m=t[2]):(p=()=>{n&&f(`preferences`)},m=[n],t[0]=n,t[1]=p,t[2]=m),(0,Q.useEffect)(p,m);let h=a!==null,g=typeof window<`u`&&window.okDesktop!=null,_;t[3]===i?_=t[4]:(_=i({id:`7PzzBU`}),t[3]=i,t[4]=_);let v;t[5]===i?v=t[6]:(v=i({id:`Q6hhn8`}),t[5]=i,t[6]=v);let y;t[7]===v?y=t[8]:(y={id:`preferences`,label:v},t[7]=v,t[8]=y);let b;t[9]===i?b=t[10]:(b=i({id:`4KmEoC`}),t[9]=i,t[10]=b);let x;t[11]===b?x=t[12]:(x={id:`hotkeys`,label:b},t[11]=b,t[12]=x);let S;t[13]===i?S=t[14]:(S=i({id:`AeXO77`}),t[13]=i,t[14]=S);let C;t[15]===S?C=t[16]:(C={id:`account`,label:S},t[15]=S,t[16]=C);let w;t[17]!==y||t[18]!==x||t[19]!==C?(w=[y,x,C],t[17]=y,t[18]=x,t[19]=C,t[20]=w):w=t[20];let T;t[21]!==w||t[22]!==_?(T={id:`user`,label:_,enabled:!0,items:w},t[21]=w,t[22]=_,t[23]=T):T=t[23];let E;t[24]===i?E=t[25]:(E=i({id:`ZWyHmq`}),t[24]=i,t[25]=E);let D;t[26]===i?D=t[27]:(D=i({id:`Nu4DdT`}),t[26]=i,t[27]=D);let O;t[28]===D?O=t[29]:(O={id:`sync`,label:D},t[28]=D,t[29]=O);let k;t[30]===i?k=t[31]:(k=i({id:`A1taO8`}),t[30]=i,t[31]=k);let A;t[32]===k?A=t[33]:(A={id:`search`,label:k},t[32]=k,t[33]=A);let j;t[34]===i?j=t[35]:(j=g?[{id:`terminal`,label:i({id:`ALhMYW`})}]:[],t[34]=i,t[35]=j);let M;t[36]===i?M=t[37]:(M=i({id:`iTylMl`}),t[36]=i,t[37]=M);let N;t[38]===M?N=t[39]:(N={id:`project-templates`,label:M},t[38]=M,t[39]=N);let P;t[40]===i?P=t[41]:(P=i({id:`PCSkw2`}),t[40]=i,t[41]=P);let F;t[42]===P?F=t[43]:(F={id:`skills`,label:P},t[42]=P,t[43]=F);let I;t[44]===i?I=t[45]:(I=i({id:`3zyg_A`}),t[44]=i,t[45]=I);let L;t[46]===I?L=t[47]:(L={id:`okignore`,label:I},t[46]=I,t[47]=L);let R;t[48]===i?R=t[49]:(R=i({id:`cs4mps`}),t[48]=i,t[49]=R);let z;t[50]===R?z=t[51]:(z={id:`sharing`,label:R},t[50]=R,t[51]=z);let B;t[52]!==O||t[53]!==A||t[54]!==j||t[55]!==N||t[56]!==F||t[57]!==L||t[58]!==z?(B=[O,A,...j,N,F,L,z],t[52]=O,t[53]=A,t[54]=j,t[55]=N,t[56]=F,t[57]=L,t[58]=z,t[59]=B):B=t[59];let V;t[60]!==h||t[61]!==E||t[62]!==B?(V={id:`project`,label:E,enabled:h,items:B},t[60]=h,t[61]=E,t[62]=B,t[63]=V):V=t[63];let H;t[64]===i?H=t[65]:(H=i({id:`nbfdhU`}),t[64]=i,t[65]=H);let U;t[66]!==i||t[67]!==u?(U=[],t[66]=i,t[67]=u,t[68]=U):U=t[68];let W;t[69]!==H||t[70]!==U?(W={id:`integrations`,label:H,enabled:!0,items:U},t[69]=H,t[70]=U,t[71]=W):W=t[71];let G;t[72]!==T||t[73]!==V||t[74]!==W?(G=[T,V,W],t[72]=T,t[73]=V,t[74]=W,t[75]=G):G=t[75];let K=G,q;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Z.jsx)(to,{className:`sr-only`,id:`settings-dialog-title`,children:(0,Z.jsx)(X,{id:`Tz0i8g`})}),t[76]=q):q=t[76];let J;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Z.jsx)(eo,{className:`sr-only`,children:(0,Z.jsx)(X,{id:`RDrXh4`})}),t[77]=J):J=t[77];let Y;t[78]!==d||t[79]!==K?(Y=(0,Z.jsx)(Zw,{groups:K,activeId:d,onSelect:f}),t[78]=d,t[79]=K,t[80]=Y):Y=t[80];let ee;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(eT,{}),t[81]=ee):ee=t[81];let te=s?o:null,ne;t[82]!==d||t[83]!==c||t[84]!==l||t[85]!==te?(ne=(0,Z.jsx)(`section`,{"aria-labelledby":`settings-dialog-title`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain subtle-scrollbar p-6`,tabIndex:0,children:(0,Z.jsx)(Kw,{children:(0,Z.jsx)(Q.Suspense,{fallback:ee,children:(0,Z.jsx)(Uw,{activeId:d,userBinding:te,okignoreBinding:c,okignoreSynced:l})})})}),t[82]=d,t[83]=c,t[84]=l,t[85]=te,t[86]=ne):ne=t[86];let re;t[87]!==Y||t[88]!==ne?(re=(0,Z.jsxs)(no,{className:`flex h-[700px] max-h-[calc(100dvh-4rem)] w-[900px] max-w-[calc(100%-2rem)] flex-col gap-0 overflow-hidden p-0 sm:grid sm:grid-cols-[220px_1fr] sm:max-w-[min(900px,calc(100%-2rem))]`,"data-testid":`settings-dialog`,children:[q,J,Y,ne]}),t[87]=Y,t[88]=ne,t[89]=re):re=t[89];let ie;return t[90]!==r||t[91]!==n||t[92]!==re?(ie=(0,Z.jsx)(oo,{open:n,onOpenChange:r,children:re}),t[90]=r,t[91]=n,t[92]=re,t[93]=ie):ie=t[93],ie}function Zw(e){let t=(0,$.c)(13),{groups:n,activeId:r,onSelect:i}=e,{_:a}=cn(),o;t[0]===a?o=t[1]:(o=a({id:`y1t8bQ`}),t[0]=a,t[1]=o);let s;if(t[2]!==r||t[3]!==n||t[4]!==i){let e;t[6]!==r||t[7]!==i?(e=e=>(0,Z.jsx)($w,{group:e,activeId:r,onSelect:i},e.id),t[6]=r,t[7]=i,t[8]=e):e=t[8],s=n.map(e),t[2]=r,t[3]=n,t[4]=i,t[5]=s}else s=t[5];let c;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Qw,{}),t[9]=c):c=t[9];let l;return t[10]!==o||t[11]!==s?(l=(0,Z.jsxs)(`nav`,{"aria-label":o,className:`flex shrink-0 gap-x-3 overflow-x-auto overscroll-contain subtle-scrollbar scroll-fade-mask-x-max-sm border-b bg-muted/30 px-3 py-2 max-sm:pt-10 sm:h-full sm:flex-col sm:gap-0 sm:overflow-x-visible sm:overflow-y-auto sm:border-r sm:border-b-0 sm:py-4`,children:[s,c]}),t[10]=o,t[11]=s,t[12]=l):l=t[12],l}function Qw(){let e=(0,$.c)(4),t=typeof window<`u`?window.okDesktop??null:null,n=t?.appVersion;if(!t||!n)return null;let r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Yw(n),e[0]=r):r=e[0];let i=r,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsxs)(`p`,{className:`whitespace-nowrap font-mono text-xs text-muted-foreground/70`,"data-testid":`settings-sidebar-version`,children:[`v`,n]}),e[1]=a):a=e[1];let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{t.shell.openExternal(i)},e[2]=o):o=e[2];let s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsxs)(`div`,{className:`ml-auto shrink-0 px-2 sm:ml-0 sm:mt-auto sm:pt-3`,children:[a,(0,Z.jsxs)(`button`,{type:`button`,onClick:o,"data-testid":`settings-sidebar-release-notes`,className:Ti(`mt-0.5 inline-flex items-center gap-1 whitespace-nowrap rounded text-xs text-muted-foreground transition-colors hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),children:[(0,Z.jsx)(X,{id:`_PACVa`}),(0,Z.jsx)(za,{className:`size-3`,"aria-hidden":`true`})]})]}),e[3]=s):s=e[3],s}function $w(e){let t=(0,$.c)(28),{group:n,activeId:r,onSelect:i}=e;if(n.items.length===0)return null;let a=`settings-group-${n.id}`,o=`${a}-caption`,s=n.enabled?void 0:o,c=n.enabled?`text-muted-foreground/80`:`text-muted-foreground/50`,l;t[0]===c?l=t[1]:(l=Ti(`shrink-0 whitespace-nowrap px-2 text-xs font-semibold uppercase tracking-wide font-mono sm:mb-1`,c),t[0]=c,t[1]=l);let u;t[2]!==n.label||t[3]!==a||t[4]!==s||t[5]!==l?(u=(0,Z.jsx)(`h3`,{id:a,"aria-describedby":s,className:l,children:n.label}),t[2]=n.label,t[3]=a,t[4]=s,t[5]=l,t[6]=u):u=t[6];let d;t[7]!==o||t[8]!==n.enabled?(d=n.enabled?null:(0,Z.jsx)(`p`,{id:o,className:`px-2 text-xs italic text-muted-foreground/60 sm:mb-1`,children:(0,Z.jsx)(X,{id:`JWsZlx`})}),t[7]=o,t[8]=n.enabled,t[9]=d):d=t[9];let f;if(t[10]!==r||t[11]!==o||t[12]!==n.enabled||t[13]!==n.items||t[14]!==i){let e;t[16]!==r||t[17]!==o||t[18]!==n.enabled||t[19]!==i?(e=e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`button`,{type:`button`,"aria-current":r===e.id?`page`:void 0,"aria-disabled":n.enabled?void 0:!0,"aria-describedby":n.enabled?void 0:o,tabIndex:n.enabled?0:-1,disabled:!n.enabled,onClick:()=>n.enabled&&i(e.id),"data-testid":`settings-sidebar-item-${e.id}`,className:Ti(`w-auto whitespace-nowrap rounded px-2 py-1.5 text-left text-sm transition-colors sm:w-full`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,`disabled:cursor-not-allowed disabled:opacity-50`,r===e.id&&n.enabled?`bg-accent text-accent-foreground`:`hover:bg-accent/50`),children:e.label})},e.id),t[16]=r,t[17]=o,t[18]=n.enabled,t[19]=i,t[20]=e):e=t[20],f=n.items.map(e),t[10]=r,t[11]=o,t[12]=n.enabled,t[13]=n.items,t[14]=i,t[15]=f}else f=t[15];let p;t[21]!==a||t[22]!==f?(p=(0,Z.jsx)(`ul`,{"aria-labelledby":a,className:`flex gap-1 sm:block sm:space-y-0.5`,children:f}),t[21]=a,t[22]=f,t[23]=p):p=t[23];let m;return t[24]!==u||t[25]!==d||t[26]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 sm:mb-4 sm:block`,children:[u,d,p]}),t[24]=u,t[25]=d,t[26]=p,t[27]=m):m=t[27],m}function eT(){let e=(0,$.c)(4),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(X,{id:`GsBUCk`})}),n=(0,Z.jsx)(la,{className:`h-5 w-32`}),r=(0,Z.jsx)(la,{className:`h-4 w-64`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-busy":`true`,className:`space-y-3`,"data-testid":`settings-content-skeleton`,children:[t,n,r,(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(la,{className:`h-9 w-full`}),(0,Z.jsx)(la,{className:`h-9 w-full`})]})]}),e[3]=i):i=e[3],i}function tT(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`flex h-full w-full aria-[orientation=vertical]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Vx,{"data-slot":`resizable-panel-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function nT(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(Wx,{"data-slot":`resizable-panel`,...n}),t[2]=n,t[3]=r),r}function rT(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({withHandle:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=Ti(`relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90`,n),t[4]=n,t[5]=a);let o;t[6]===i?o=t[7]:(o=i&&(0,Z.jsx)(`div`,{className:`z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border`}),t[6]=i,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,Z.jsx)(Jx,{"data-slot":`resizable-handle`,className:a,...r,children:o}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}function iT(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`input-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var aT=wi(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function oT(e){let t=(0,$.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,o;t[4]!==a||t[5]!==n?(o=Ti(aT({align:a}),n),t[4]=a,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,Z.jsx)(`div`,{"data-slot":`input-group-addon`,"data-align":a,className:o,onMouseDown:sT,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function sT(e){e.target.closest(`button`)||(e.preventDefault(),e.currentTarget.parentElement?.querySelector(`input`)?.focus())}wi(`flex items-center gap-2 text-sm shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5`,sm:``,"icon-xs":`size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function cT(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function lT(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(pl,{"data-slot":`input-group-control`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function uT(e){let t=(0,$.c)(119),{findInputRef:n,query:r,replacement:i,replaceOpen:a,caseSensitive:o,wholeWord:s,current:c,total:l,onQueryChange:u,onReplacementChange:d,onReplaceOpenChange:f,onCaseSensitiveChange:p,onWholeWordChange:m,onNext:h,onPrevious:g,onReplaceCurrent:_,onReplaceAll:v,onClose:y}=e,{_:b}=cn(),x=r.length>0,S=l>0,C;t[0]!==b||t[1]!==c||t[2]!==S||t[3]!==x||t[4]!==l?(C=x?S?`${c} / ${l}`:b({id:`Ev2r9A`}):``,t[0]=b,t[1]=c,t[2]=S,t[3]=x,t[4]=l,t[5]=C):C=t[5];let w=C,T;t[6]!==y||t[7]!==h||t[8]!==g?(T=function(e){e.key===`Enter`?(e.preventDefault(),e.shiftKey?g():h()):e.key===`Escape`&&(e.preventDefault(),y())},t[6]=y,t[7]=h,t[8]=g,t[9]=T):T=t[9];let E=T,D;t[10]!==y||t[11]!==_?(D=function(e){e.key===`Enter`?(e.preventDefault(),_()):e.key===`Escape`&&(e.preventDefault(),y())},t[10]=y,t[11]=_,t[12]=D):D=t[12];let O=D,k;t[13]===b?k=t[14]:(k=b({id:`MVxpbf`}),t[13]=b,t[14]=k);let A;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(`label`,{className:`sr-only`,htmlFor:`ok-find-input`,children:(0,Z.jsx)(X,{id:`KujtjC`})}),t[15]=A):A=t[15];let j;t[16]===u?j=t[17]:(j=e=>u(e.target.value),t[16]=u,t[17]=j);let M;t[18]===b?M=t[19]:(M=b({id:`KujtjC`}),t[18]=b,t[19]=M);let N;t[20]!==n||t[21]!==E||t[22]!==r||t[23]!==j||t[24]!==M?(N=(0,Z.jsx)(lT,{ref:n,id:`ok-find-input`,value:r,onChange:j,onKeyDown:E,placeholder:M,autoComplete:`off`,spellCheck:!1,className:`h-7 px-2 text-sm`}),t[20]=n,t[21]=E,t[22]=r,t[23]=j,t[24]=M,t[25]=N):N=t[25];let P;t[26]===b?P=t[27]:(P=b({id:`-8PP0T`}),t[26]=b,t[27]=P);let F;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(Nu,{"aria-hidden":`true`}),t[28]=F):F=t[28];let I;t[29]!==o||t[30]!==p||t[31]!==P?(I=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Va,{type:`button`,variant:`segmented`,size:`sm`,"aria-label":P,pressed:o,onPressedChange:p,className:`size-6 min-w-6 px-0`,children:F})}),t[29]=o,t[30]=p,t[31]=P,t[32]=I):I=t[32];let L;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(mc,{side:`bottom`,children:(0,Z.jsx)(X,{id:`-8PP0T`})}),t[33]=L):L=t[33];let R;t[34]===I?R=t[35]:(R=(0,Z.jsxs)(gc,{children:[I,L]}),t[34]=I,t[35]=R);let z;t[36]===b?z=t[37]:(z=b({id:`_7UQ7y`}),t[36]=b,t[37]=z);let B;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(Jd,{"aria-hidden":`true`}),t[38]=B):B=t[38];let V;t[39]!==m||t[40]!==z||t[41]!==s?(V=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Va,{type:`button`,variant:`segmented`,size:`sm`,"aria-label":z,pressed:s,onPressedChange:m,className:`size-6 min-w-6 px-0`,children:B})}),t[39]=m,t[40]=z,t[41]=s,t[42]=V):V=t[42];let H;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Z.jsx)(mc,{side:`bottom`,children:(0,Z.jsx)(X,{id:`_7UQ7y`})}),t[43]=H):H=t[43];let U;t[44]===V?U=t[45]:(U=(0,Z.jsxs)(gc,{children:[V,H]}),t[44]=V,t[45]=U);let W;t[46]!==R||t[47]!==U?(W=(0,Z.jsxs)(oT,{align:`inline-end`,className:`gap-0.5`,children:[R,U]}),t[46]=R,t[47]=U,t[48]=W):W=t[48];let G;t[49]!==W||t[50]!==N?(G=(0,Z.jsxs)(iT,{className:`h-7 w-56 rounded-[min(var(--radius-md),12px)]`,children:[N,W]}),t[49]=W,t[50]=N,t[51]=G):G=t[51];let K;t[52]===w?K=t[53]:(K=(0,Z.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`min-w-14 px-1 text-right text-muted-foreground text-xs tabular-nums shrink-0`,children:w}),t[52]=w,t[53]=K);let q;t[54]===b?q=t[55]:(q=b({id:`oqB2ez`}),t[54]=b,t[55]=q);let J=!S,Y;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,Z.jsx)(st,{"data-icon":`inline-start`,"aria-hidden":`true`}),t[56]=Y):Y=t[56];let ee;t[57]!==g||t[58]!==q||t[59]!==J?(ee=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":q,disabled:J,onClick:g,children:Y})}),t[57]=g,t[58]=q,t[59]=J,t[60]=ee):ee=t[60];let te;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(mc,{side:`bottom`,children:(0,Z.jsx)(X,{id:`oqB2ez`})}),t[61]=te):te=t[61];let ne;t[62]===ee?ne=t[63]:(ne=(0,Z.jsxs)(gc,{children:[ee,te]}),t[62]=ee,t[63]=ne);let re;t[64]===b?re=t[65]:(re=b({id:`SiUUCS`}),t[64]=b,t[65]=re);let ie=!S,ae;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(so,{"data-icon":`inline-start`,"aria-hidden":`true`}),t[66]=ae):ae=t[66];let oe;t[67]!==h||t[68]!==re||t[69]!==ie?(oe=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":re,disabled:ie,onClick:h,children:ae})}),t[67]=h,t[68]=re,t[69]=ie,t[70]=oe):oe=t[70];let se;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Z.jsx)(mc,{side:`bottom`,children:(0,Z.jsx)(X,{id:`SiUUCS`})}),t[71]=se):se=t[71];let ce;t[72]===oe?ce=t[73]:(ce=(0,Z.jsxs)(gc,{children:[oe,se]}),t[72]=oe,t[73]=ce);let le=a?`secondary`:`ghost`,ue;t[74]!==b||t[75]!==a?(ue=b(a?{id:`UkQGhd`}:{id:`1RluQD`}),t[74]=b,t[75]=a,t[76]=ue):ue=t[76];let de=a?`ok-replace-input`:void 0,fe;t[77]!==f||t[78]!==a?(fe=()=>f(!a),t[77]=f,t[78]=a,t[79]=fe):fe=t[79];let pe;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Z.jsx)(Ed,{"data-icon":`inline-start`,"aria-hidden":`true`}),t[80]=pe):pe=t[80];let me;t[81]!==a||t[82]!==le||t[83]!==ue||t[84]!==de||t[85]!==fe?(me=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{type:`button`,variant:le,size:`icon-sm`,"aria-label":ue,"aria-expanded":a,"aria-controls":de,onClick:fe,children:pe})}),t[81]=a,t[82]=le,t[83]=ue,t[84]=de,t[85]=fe,t[86]=me):me=t[86];let he;t[87]===a?he=t[88]:(he=(0,Z.jsx)(mc,{side:`bottom`,children:a?(0,Z.jsx)(X,{id:`UkQGhd`}):(0,Z.jsx)(X,{id:`1RluQD`})}),t[87]=a,t[88]=he);let ge;t[89]!==me||t[90]!==he?(ge=(0,Z.jsxs)(gc,{children:[me,he]}),t[89]=me,t[90]=he,t[91]=ge):ge=t[91];let _e;t[92]!==b||t[93]!==O||t[94]!==S||t[95]!==v||t[96]!==_||t[97]!==d||t[98]!==a||t[99]!==i?(_e=a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`label`,{className:`sr-only`,htmlFor:`ok-replace-input`,children:(0,Z.jsx)(X,{id:`fqSfXY`})}),(0,Z.jsx)(pl,{id:`ok-replace-input`,value:i,onChange:e=>d(e.target.value),onKeyDown:O,placeholder:b({id:`fqSfXY`}),autoComplete:`off`,spellCheck:!1,className:`h-7 w-48 rounded-[min(var(--radius-md),12px)] px-2 text-sm shadow-none focus-visible:ring-2`}),(0,Z.jsxs)(gc,{children:[(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":b({id:`bS_boY`}),disabled:!S,onClick:_,children:(0,Z.jsx)(Ed,{"data-icon":`inline-start`,"aria-hidden":`true`})})}),(0,Z.jsx)(mc,{side:`bottom`,children:(0,Z.jsx)(X,{id:`bS_boY`})})]}),(0,Z.jsxs)(gc,{children:[(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":b({id:`dr1vFs`}),disabled:!S,onClick:v,children:(0,Z.jsx)(Td,{"data-icon":`inline-start`,"aria-hidden":`true`})})}),(0,Z.jsx)(mc,{side:`bottom`,children:(0,Z.jsx)(X,{id:`dr1vFs`})})]})]}):null,t[92]=b,t[93]=O,t[94]=S,t[95]=v,t[96]=_,t[97]=d,t[98]=a,t[99]=i,t[100]=_e):_e=t[100];let ve;t[101]===b?ve=t[102]:(ve=b({id:`wJo9oS`}),t[101]=b,t[102]=ve);let ye;t[103]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,Z.jsx)(Ys,{"data-icon":`inline-start`,"aria-hidden":`true`}),t[103]=ye):ye=t[103];let be;t[104]!==y||t[105]!==ve?(be=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":ve,onClick:y,children:ye})}),t[104]=y,t[105]=ve,t[106]=be):be=t[106];let xe;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,Z.jsx)(mc,{side:`bottom`,children:(0,Z.jsx)(X,{id:`yz7wBu`})}),t[107]=xe):xe=t[107];let Se;t[108]===be?Se=t[109]:(Se=(0,Z.jsxs)(gc,{children:[be,xe]}),t[108]=be,t[109]=Se);let Ce;return t[110]!==G||t[111]!==K||t[112]!==ne||t[113]!==ce||t[114]!==k||t[115]!==ge||t[116]!==_e||t[117]!==Se?(Ce=(0,Z.jsxs)(`search`,{"data-testid":`find-replace-bar`,"aria-label":k,className:`pointer-events-auto flex max-w-[min(calc(100vw-1rem),720px)] touch-manipulation items-center gap-1 rounded-[calc(var(--radius)+2px)] border border-input bg-popover/95 p-1 text-popover-foreground shadow-md shadow-black/10 backdrop-blur`,children:[A,G,K,ne,ce,ge,_e,Se]}),t[110]=G,t[111]=K,t[112]=ne,t[113]=ce,t[114]=k,t[115]=ge,t[116]=_e,t[117]=Se,t[118]=Ce):Ce=t[118],Ce}var dT={current:0,total:0},fT=120,pT=100;function mT(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=()=>e?ce(e):null,t[0]=e,t[1]=n),(0,Q.useSyncExternalStore)(T,n,hT)}function hT(){return null}function gT(e){if(!e||e.isDestroyed)return null;let{from:t,to:n,empty:r}=e.state.selection;if(r)return null;let i=e.state.doc.textBetween(t,n,`
|
|
27
27
|
`,`
|
|
28
28
|
`).trim();return i.length===0||i.length>fT||i.includes(`
|
|
29
|
-
`)?null:i}function _T(e){let t=$e(e.state);return{current:t.matches.length===0?0:t.activeIndex+1,total:t.matches.length}}function vT(e,t){return e.current===t.current&&e.total===t.total}function yT(e,t,n){e&&!e.isDestroyed&&(e.commands.clearFindMatches(),e.commands.focus()),t(e=>({...e,open:!1,activeIndex:0})),n(dT)}function bT(e){!e||e.isDestroyed||typeof window>`u`||window.requestAnimationFrame(()=>{if(e.isDestroyed)return;let t=fe(e);if(!t)return;let n=t.dom.querySelector(`.ok-find-match-active`);n instanceof HTMLElement&&n.scrollIntoView({block:`center`,inline:`nearest`,behavior:`auto`})})}function xT(e){let t=(0,$.c)(81),{activeDocName:n,isSourceMode:r}=e,i=mT(n),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useRef)(n),c=(0,Q.useRef)(0),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={open:!1,replaceOpen:!1,query:``,replacement:``,caseSensitive:!1,wholeWord:!1,activeIndex:0},t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(dT),m,h;t[1]===n?(m=t[2],h=t[3]):(m=()=>{s.current!==n&&(s.current=n,d(CT))},h=[n],t[1]=n,t[2]=m,t[3]=h),(0,Q.useEffect)(m,h);let g,_;t[4]===u.activeIndex?(g=t[5],_=t[6]):(g=()=>{c.current=u.activeIndex},_=[u.activeIndex],t[4]=u.activeIndex,t[5]=g,t[6]=_),(0,Q.useEffect)(g,_);let v,y;t[7]===i?(v=t[8],y=t[9]):(v=()=>{let e=o.current;e&&e!==i&&!e.isDestroyed&&e.commands.clearFindMatches(),o.current=i},y=[i],t[7]=i,t[8]=v,t[9]=y),(0,Q.useEffect)(v,y);let b,x;t[10]===u.open?(b=t[11],x=t[12]):(b=()=>{if(!u.open||!a.current)return;let e=requestAnimationFrame(()=>{a.current?.focus(),a.current?.select()});return()=>cancelAnimationFrame(e)},x=[u.open],t[10]=u.open,t[11]=b,t[12]=x),(0,Q.useEffect)(b,x);let S,C;t[13]!==u.open||t[14]!==r?(S=()=>{!u.open||!r||d(ST)},C=[u.open,r],t[13]=u.open,t[14]=r,t[15]=S,t[16]=C):(S=t[15],C=t[16]),(0,Q.useEffect)(S,C);let w,T;t[17]!==i||t[18]!==u.caseSensitive||t[19]!==u.open||t[20]!==u.query||t[21]!==u.wholeWord||t[22]!==r?(w=()=>{if(!i||i.isDestroyed){p(dT);return}if(!u.open||r){i.commands.clearFindMatches(),p(dT);return}let e=window.setTimeout(()=>{if(i.isDestroyed)return;i.commands.setFindQuery(u.query,{options:{caseSensitive:u.caseSensitive,wholeWord:u.wholeWord},activeIndex:c.current});let e=_T(i);p(t=>vT(t,e)?t:e)},pT);return()=>window.clearTimeout(e)},T=[i,u.open,u.query,u.caseSensitive,u.wholeWord,r],t[17]=i,t[18]=u.caseSensitive,t[19]=u.open,t[20]=u.query,t[21]=u.wholeWord,t[22]=r,t[23]=w,t[24]=T):(w=t[23],T=t[24]),(0,Q.useEffect)(w,T);let E,D;t[25]!==i||t[26]!==u.open||t[27]!==r?(E=()=>{if(!i||i.isDestroyed||!u.open||r)return;let e=()=>{let e=$e(i.state),t=_T(i);p(e=>vT(e,t)?e:t),d(t=>t.activeIndex===e.activeIndex?t:{...t,activeIndex:e.activeIndex})};return i.on(`transaction`,e),()=>{i.off(`transaction`,e)}},D=[i,u.open,r],t[25]=i,t[26]=u.open,t[27]=r,t[28]=E,t[29]=D):(E=t[28],D=t[29]),(0,Q.useEffect)(E,D);let O,k;t[30]!==n||t[31]!==i||t[32]!==u.open||t[33]!==r?(O=()=>{let e=function(e){let t=gT(i);d(n=>({...n,open:!0,replaceOpen:e,query:t??n.query,activeIndex:0}))},t=function(t){if(!(!n||r||t.defaultPrevented)){if(Sl(t,`find`)){t.preventDefault(),u.open?yT(i,d,p):e(!1);return}if(Sl(t,`replace`)){t.preventDefault(),e(!0);return}if(u.open){let e=Sl(t,`find-next`),n=Sl(t,`find-previous`);if(e||n){t.preventDefault(),(n?i?.commands.selectPreviousFindMatch():i?.commands.selectNextFindMatch())&&bT(i);return}}t.key===`Escape`&&u.open&&(t.preventDefault(),yT(i,d,p))}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},k=[n,i,u.open,r],t[30]=n,t[31]=i,t[32]=u.open,t[33]=r,t[34]=O,t[35]=k):(O=t[34],k=t[35]),(0,Q.useEffect)(O,k);let A;t[36]!==i||t[37]!==u.caseSensitive||t[38]!==u.query||t[39]!==u.wholeWord?(A=function(){return!i||i.isDestroyed?!1:(i.commands.setFindQuery(u.query,{options:{caseSensitive:u.caseSensitive,wholeWord:u.wholeWord},activeIndex:c.current}),!0)},t[36]=i,t[37]=u.caseSensitive,t[38]=u.query,t[39]=u.wholeWord,t[40]=A):A=t[40];let j=A,M;t[41]===i?M=t[42]:(M=function(){if(!i||i.isDestroyed)return;let e=$e(i.state),t=_T(i);p(e=>vT(e,t)?e:t),d(t=>t.activeIndex===e.activeIndex?t:{...t,activeIndex:e.activeIndex})},t[41]=i,t[42]=M);let N=M,P;t[43]===i?P=t[44]:(P=function(){yT(i,d,p)},t[43]=i,t[44]=P);let F=P,I;t[45]!==j||t[46]!==i||t[47]!==N?(I=function(){!i||i.isDestroyed||(j(),i.commands.selectNextFindMatch()&&bT(i),N())},t[45]=j,t[46]=i,t[47]=N,t[48]=I):I=t[48];let L=I,R;t[49]!==j||t[50]!==i||t[51]!==N?(R=function(){!i||i.isDestroyed||(j(),i.commands.selectPreviousFindMatch()&&bT(i),N())},t[49]=j,t[50]=i,t[51]=N,t[52]=R):R=t[52];let z=R,B;t[53]!==j||t[54]!==i||t[55]!==u.replacement||t[56]!==N?(B=function(){!i||i.isDestroyed||(j(),i.commands.replaceCurrentFindMatch(u.replacement)&&bT(i),N())},t[53]=j,t[54]=i,t[55]=u.replacement,t[56]=N,t[57]=B):B=t[57];let V=B,H;t[58]!==j||t[59]!==i||t[60]!==u.replacement||t[61]!==N?(H=function(){!i||i.isDestroyed||(j(),i.commands.replaceAllFindMatches(u.replacement)&&bT(i),N())},t[58]=j,t[59]=i,t[60]=u.replacement,t[61]=N,t[62]=H):H=t[62];let U=H;if(!u.open||!n||r)return null;let W,G,K,q,J;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>d(t=>({...t,query:e,activeIndex:0})),G=e=>d(t=>({...t,replacement:e})),K=e=>d(t=>({...t,replaceOpen:e})),q=e=>d(t=>({...t,caseSensitive:e})),J=e=>d(t=>({...t,wholeWord:e})),t[63]=W,t[64]=G,t[65]=K,t[66]=q,t[67]=J):(W=t[63],G=t[64],K=t[65],q=t[66],J=t[67]);let Y;return t[68]!==F||t[69]!==u.caseSensitive||t[70]!==u.query||t[71]!==u.replaceOpen||t[72]!==u.replacement||t[73]!==u.wholeWord||t[74]!==f.current||t[75]!==f.total||t[76]!==U||t[77]!==V||t[78]!==L||t[79]!==z?(Y=(0,Z.jsx)(`div`,{className:`editor-content-aligned pointer-events-none absolute inset-x-0 top-2 z-30 px-2`,children:(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(uT,{findInputRef:a,query:u.query,replacement:u.replacement,replaceOpen:u.replaceOpen,caseSensitive:u.caseSensitive,wholeWord:u.wholeWord,current:f.current,total:f.total,onQueryChange:W,onReplacementChange:G,onReplaceOpenChange:K,onCaseSensitiveChange:q,onWholeWordChange:J,onNext:L,onPrevious:z,onReplaceCurrent:V,onReplaceAll:U,onClose:F})})}),t[68]=F,t[69]=u.caseSensitive,t[70]=u.query,t[71]=u.replaceOpen,t[72]=u.replacement,t[73]=u.wholeWord,t[74]=f.current,t[75]=f.total,t[76]=U,t[77]=V,t[78]=L,t[79]=z,t[80]=Y):Y=t[80],Y}function ST(e){return{...e,open:!1,activeIndex:0}}function CT(e){return{...e,activeIndex:0}}var wT=300;function TT(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(Gl),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e||!t){i(Gl);return}let n=e.document.getText(`source`),r=!1,a=null,o=function(){r||i(Yl(n.toString()))};o();let s=function(){a&&clearTimeout(a),a=setTimeout(o,wT)};return n.observe(s),()=>{r=!0,n.unobserve(s),a&&clearTimeout(a)}},o=[e,t],n[0]=t,n[1]=e,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Q.useEffect)(a,o),r}function ET(e){return e&&e.document.getMap(`lifecycle`).get(`status`)===`conflict`?`conflict`:null}function DT(e){let t=(0,$.c)(8),{poolEntries:n}=_t(),r;t[0]!==e||t[1]!==n?(r=e?n.find(t=>t.docName===e)??null:null,t[0]=e,t[1]=n,t[2]=r):r=t[2];let i=r?.provider??null,a;t[3]===i?a=t[4]:(a=()=>ET(i),t[3]=i,t[4]=a);let[o,s]=(0,Q.useState)(a),c,l;return t[5]===i?(c=t[6],l=t[7]):(c=()=>{if(!i){s(null);return}let e=i.document.getMap(`lifecycle`);s(ET(i));let t=()=>s(ET(i));return e.observe(t),()=>{e.unobserve(t)}},l=[i],t[5]=i,t[6]=c,t[7]=l),(0,Q.useEffect)(c,l),o}function OT(e,t){let n=(0,$.c)(3),r;return n[0]!==e||n[1]!==t?(r=()=>$l(e,t),n[0]=e,n[1]=t,n[2]=r):r=n[2],(0,Q.useSyncExternalStore)(eu,r)}var kT=`ok-doc-panel-width-v1`;function AT(e){return Number.isFinite(e)?e<300?300:e>600?600:Math.round(e):320}function jT(e){try{let t=(e??localStorage).getItem(kT);if(t==null)return 320;let n=Number.parseInt(t,10);return Number.isFinite(n)?AT(n):320}catch{return 320}}function MT(e,t){try{(t??localStorage).setItem(kT,String(AT(e)))}catch{}}function NT(){try{return typeof localStorage>`u`?320:jT()}catch{return 320}}var PT=1024,FT=1280,IT={left:PT,right:FT};function LT(e,t,n){return e==null?t>=IT[n]?`above`:`below`:`embedded`}function RT(e){return e===`above`?`open`:`collapsed`}var zT=`ok-sidebar-pins-v2`;function BT(e){return e===`open`||e===`collapsed`}function VT(e){return e===`above`||e===`below`||e===`embedded`}function HT(e){if(typeof e!=`object`||!e)return!1;let t=e;for(let e of Object.keys(t))if(!VT(e)||!BT(t[e]))return!1;return!0}function UT(e){let t=JSON.parse(e);if(typeof t!=`object`||!t)return{};let n=t,r={};return HT(n.left)&&(r.left=n.left),HT(n.right)&&(r.right=n.right),r}function WT(e){try{let t=(e??localStorage).getItem(zT);return t==null?{}:UT(t)}catch{return{}}}function GT(e,t){try{t.setItem(zT,JSON.stringify(e))}catch{}}function KT(e,t,n){return n[e]?.[t]??RT(t)}function qT(e,t,n,r){let i=r??localStorage,a=WT(i);return a[e]={...a[e],[t]:n},GT(a,i),a}function JT(e){let t=(0,$.c)(3),[n,r]=(0,Q.useState)(`connecting`),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e){r(`connecting`);return}let t=e.configuration.websocketProvider.status;e.isSynced?r(`synced`):r(t===`connected`?`connected`:t===`disconnected`?`disconnected`:`connecting`);let n=e=>{let{status:t}=e;r(t===`connected`?YT:t===`disconnected`?`disconnected`:`connecting`)},i=e=>{let{state:t}=e;r(t?`synced`:`connected`)},a=()=>r(`disconnected`);return e.on(`status`,n),e.on(`synced`,i),e.on(`disconnect`,a),()=>{e.off(`status`,n),e.off(`synced`,i),e.off(`disconnect`,a)}},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,Q.useEffect)(i,a),n}function YT(e){return e===`synced`?`synced`:`connected`}function XT(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function ZT(e){let t=(0,$.c)(21),{path:n,onRemove:r}=e,{_:i}=cn(),a,o;t[0]!==i||t[1]!==n?(a=XT(n),o=i({id:`hnq8fP`,values:{label:a}}),t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s=o,c=`composer-context-chip-file-${n}`,l;t[4]===r?l=t[5]:(l=e=>{(e.key===`Backspace`||e.key===`Delete`)&&(e.preventDefault(),r())},t[4]=r,t[5]=l);let u;t[6]===n?u=t[7]:(u=(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 inline-flex size-3 -translate-x-1/2 -translate-y-1/2 opacity-100 transition-opacity duration-150 ease-out group-hover/chip:opacity-0 group-focus-within/chip:opacity-0 motion-reduce:transition-none`,children:(0,Z.jsx)(ut,{path:n,className:`size-3`})}),t[6]=n,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(Ys,{className:`absolute top-1/2 left-1/2 size-3 -translate-x-1/2 -translate-y-1/2 opacity-0 transition-opacity duration-150 ease-out group-hover/chip:opacity-100 group-focus-within/chip:opacity-100 motion-reduce:transition-none`,"aria-hidden":!0}),t[8]=d):d=t[8];let f;t[9]!==r||t[10]!==s||t[11]!==l||t[12]!==u?(f=(0,Z.jsxs)(Di,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s,onClick:r,onKeyDown:l,className:`group/remove relative size-3.5 shrink-0 rounded-sm text-muted-foreground/80 hover:text-foreground`,children:[u,d]}),t[9]=r,t[10]=s,t[11]=l,t[12]=u,t[13]=f):f=t[13];let p;t[14]===a?p=t[15]:(p=(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:a}),t[14]=a,t[15]=p);let m;return t[16]!==n||t[17]!==c||t[18]!==f||t[19]!==p?(m=(0,Z.jsxs)(`span`,{"data-testid":c,title:n,className:`group/chip inline-flex max-w-[14rem] items-center gap-1 rounded-md border bg-muted/40 py-0.5 pr-1.5 pl-1 text-muted-foreground text-xs`,children:[f,p]}),t[16]=n,t[17]=c,t[18]=f,t[19]=p,t[20]=m):m=t[20],m}function QT(e){let t=(0,$.c)(11),{files:n,onRemoveFile:r,className:i,children:a}=e;if(n.length===0&&a==null)return null;let o;t[0]===i?o=t[1]:(o=Ti(`flex flex-wrap items-center gap-1`,i),t[0]=i,t[1]=o);let s;if(t[2]!==n||t[3]!==r){let e;t[5]===r?e=t[6]:(e=e=>(0,Z.jsx)(ZT,{path:e,onRemove:()=>r(e)},e),t[5]=r,t[6]=e),s=n.map(e),t[2]=n,t[3]=r,t[4]=s}else s=t[4];let c;return t[7]!==a||t[8]!==o||t[9]!==s?(c=(0,Z.jsxs)(`div`,{className:o,"data-testid":`composer-context-chips`,children:[s,a]}),t[7]=a,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function $T(e){let t=(0,$.c)(35),{primary:n,onPrimary:r,primaryDisabled:i,installedTargets:a,selectedTargetId:o,onSelectTarget:s,terminal:c,terminals:l,menuEmptyState:u,onMenuOpenChange:d,menuAlign:f,triggerAriaLabel:p,testIds:m}=e,h=i===void 0?!1:i,g=f===void 0?`end`:f,{_}=cn(),v=a.length>0,y=l&&l.length>0?l:null,b=y!=null||c!=null,x=v||b,S;t[0]===m?S=t[1]:(S=e=>typeof m.terminal==`function`?m.terminal(e):m.terminal,t[0]=m,t[1]=S);let C=S,w;t[2]!==r||t[3]!==n||t[4]!==h||t[5]!==m.primary?(w=(0,Z.jsx)(Di,{type:`button`,variant:`outline`,className:`gap-1.5`,disabled:h,onClick:r,"data-testid":m.primary,children:n}),t[2]=r,t[3]=n,t[4]=h,t[5]=m.primary,t[6]=w):w=t[6];let T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(so,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),t[7]=T):T=t[7];let E;t[8]!==m.trigger||t[9]!==p?(E=(0,Z.jsx)(qc,{asChild:!0,children:(0,Z.jsx)(Di,{type:`button`,variant:`outline`,size:`icon`,"aria-label":p,"data-testid":m.trigger,children:T})}),t[8]=m.trigger,t[9]=p,t[10]=E):E=t[10];let D;t[11]!==_||t[12]!==y||t[13]!==x||t[14]!==a||t[15]!==u||t[16]!==s||t[17]!==o||t[18]!==v||t[19]!==b||t[20]!==c||t[21]!==C||t[22]!==m?(D=x?(0,Z.jsxs)(Z.Fragment,{children:[v?(0,Z.jsxs)(Xc,{"aria-label":_({id:`BBqGS9`}),children:[(0,Z.jsx)(ol,{children:(0,Z.jsx)(X,{id:`BBqGS9`})}),a.map(e=>(0,Z.jsxs)(Yc,{onSelect:()=>s(e),"data-testid":m.option(e.id),children:[(0,Z.jsx)(Xo,{id:e.id,"aria-hidden":`true`,className:`size-4`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:e.displayName}),o===e.id?(0,Z.jsx)($a,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},e.id))]}):null,b?(0,Z.jsxs)(Z.Fragment,{children:[v?(0,Z.jsx)(cl,{}):null,(0,Z.jsxs)(Xc,{"aria-label":_({id:`ALhMYW`}),children:[(0,Z.jsx)(ol,{children:(0,Z.jsx)(X,{id:`ALhMYW`})}),y?y.map(e=>(0,Z.jsxs)(Yc,{onSelect:e.onSelect,"data-testid":C(e.cli),"aria-label":e.ariaLabel,children:[(0,Z.jsx)(Xo,{id:Yo(e.cli),className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:e.label}),e.selected?(0,Z.jsx)($a,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},e.cli)):c?(0,Z.jsxs)(Yc,{onSelect:c.onSelect,"data-testid":C(`claude`),"aria-label":_({id:`AcK_r0`}),children:[(0,Z.jsx)(Xo,{id:Yo(`claude`),className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(X,{id:`fcgvCA`})}),c.selected?(0,Z.jsx)($a,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]}):null]})]}):null]}):u,t[11]=_,t[12]=y,t[13]=x,t[14]=a,t[15]=u,t[16]=s,t[17]=o,t[18]=v,t[19]=b,t[20]=c,t[21]=C,t[22]=m,t[23]=D):D=t[23];let O;t[24]!==g||t[25]!==D||t[26]!==m.menu?(O=(0,Z.jsx)(Zc,{align:g,className:`min-w-[200px]`,"data-testid":m.menu,children:D}),t[24]=g,t[25]=D,t[26]=m.menu,t[27]=O):O=t[27];let k;t[28]!==d||t[29]!==E||t[30]!==O?(k=(0,Z.jsxs)(rl,{onOpenChange:d,children:[E,O]}),t[28]=d,t[29]=E,t[30]=O,t[31]=k):k=t[31];let A;return t[32]!==w||t[33]!==k?(A=(0,Z.jsxs)(ES,{children:[w,k]}),t[32]=w,t[33]=k,t[34]=A):A=t[34],A}var eE=5200,tE=500;function nE(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toUpperCase();return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`}function rE(){let e=(0,$.c)(2),[t,n]=(0,Q.useState)(iE),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`);n(e.matches);let t=e=>n(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i),t}function iE(){return typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function aE(e,t){let n=(0,$.c)(9),[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(!0),s,c;if(n[0]!==t||n[1]!==a?(s=()=>{if(!t)return;if(a){let e=setTimeout(()=>o(!1),eE);return()=>clearTimeout(e)}let e=setTimeout(()=>{i(oE),o(!0)},tE);return()=>clearTimeout(e)},c=[a,t],n[0]=t,n[1]=a,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,Q.useEffect)(s,c),!t){let t=e[0]??``,r;return n[4]===t?r=n[5]:(r={text:t,visible:!0},n[4]=t,n[5]=r),r}let l=e[e.length>0?r%e.length:0]??``,u;return n[6]!==l||n[7]!==a?(u={text:l,visible:a},n[6]=l,n[7]=a,n[8]=u):u=n[8],u}function oE(e){return e+1}function sE(e){let t=(0,$.c)(149),{docName:n,surface:r,folderPath:i,dismissed:a,onDismiss:o,onReopen:s}=e,c=a===void 0?!1:a,{_:l}=cn(),u=i!==void 0,d=u?null:n??null,f=r??`wysiwyg`,p=rE(),m=Ho(),{states:h}=ns(),{dispatch:g}=us(),_=cs(),[v]=(0,Q.useState)(_E),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(!0),[C,w]=(0,Q.useState)(!1),T=(0,Q.useRef)(null),E=(0,Q.useRef)(null),[D]=(0,Q.useState)(gE),O,k;t[0]!==c||t[1]!==n||t[2]!==u||t[3]!==r?(O=()=>{if(u||n==null)return;let e=document.documentElement,t=mE,i=()=>{r===`wysiwyg`&&requestAnimationFrame(()=>{let e=ce(n),t=E.current;if(!(!e||e.isDestroyed||!t))try{let n=e.view,r=n.coordsAtPos(e.state.selection.head).bottom-(t.getBoundingClientRect().top-28);if(r<=0)return;let i=n.dom.closest(`.editor-doc-scroll`);i instanceof HTMLElement&&(i.scrollTop+=r)}catch{}})},a=E.current;if(c||!a){t(),e.style.removeProperty(`--ask-composer-height`);return}let o=()=>{t(),e.style.setProperty(`--ask-composer-height`,`${a.offsetHeight+24}px`)};o(),i();let s=new ResizeObserver(o);return s.observe(a),()=>{s.disconnect(),t(),e.style.removeProperty(`--ask-composer-height`)}},k=[c,r,n,u],t[0]=c,t[1]=n,t[2]=u,t[3]=r,t[4]=O,t[5]=k):(O=t[4],k=t[5]),(0,Q.useEffect)(O,k);let A=(0,Q.useRef)(c),j=(0,Q.useRef)(s),M;t[6]!==c||t[7]!==s?(M=()=>{A.current=c,j.current=s},t[6]=c,t[7]=s,t[8]=M):M=t[8],(0,Q.useEffect)(M);let N,P;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>Xl(()=>{A.current?j.current?.():T.current?.focus()}),P=[],t[9]=N,t[10]=P):(N=t[9],P=t[10]),(0,Q.useEffect)(N,P);let F;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(F=[],t[11]=F):F=t[11],(0,Q.useEffect)(fE,F);let I=(0,Q.useRef)(!1),L,R;t[12]===c?(L=t[13],R=t[14]):(L=()=>{if(!I.current){I.current=!0;return}c||T.current?.focus()},R=[c],t[12]=c,t[13]=L,t[14]=R),(0,Q.useEffect)(L,R);let z;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(z=[],t[15]=z):z=t[15];let[B,V]=(0,Q.useState)(z),[H,U]=(0,Q.useState)(dE),W;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(W=[],t[16]=W):W=t[16];let[G,K]=(0,Q.useState)(W),q;t[17]!==n||t[18]!==u?(q=u||n==null?``:Ko(n),t[17]=n,t[18]=u,t[19]=q):q=t[19];let J=q,Y,ee;t[20]!==J||t[21]!==H||t[22]!==u||t[23]!==x?(Y=()=>{u||x||V(e=>e.includes(J)||H.has(J)?e:[...e,J])},ee=[u,x,J,H],t[20]=J,t[21]=H,t[22]=u,t[23]=x,t[24]=Y,t[25]=ee):(Y=t[24],ee=t[25]),(0,Q.useEffect)(Y,ee);let te;t[26]!==H||t[27]!==u||t[28]!==i||t[29]!==G||t[30]!==B?(te=u?i&&!H.has(i)&&!G.includes(i)?[i]:[]:B.filter(e=>!H.has(e)&&!G.includes(e)),t[26]=H,t[27]=u,t[28]=i,t[29]=G,t[30]=B,t[31]=te):te=t[31];let ne=te,re=Ya(d,f),ie=Ya(d,`frontmatter`),[ae,oe]=(0,Q.useState)(null),[se,le]=(0,Q.useState)(!1),ue,de;t[32]===re?(ue=t[33],de=t[34]):(ue=()=>{re&&oe(re)},de=[re],t[32]=re,t[33]=ue,t[34]=de),(0,Q.useEffect)(ue,de);let fe,pe;t[35]===ie?(fe=t[36],pe=t[37]):(fe=()=>{ie&&oe(ie)},pe=[ie],t[35]=ie,t[36]=fe,t[37]=pe),(0,Q.useEffect)(fe,pe);let me=y??v,he;t[38]!==me||t[39]!==_?(he=_===null?null:QS(me),t[38]=me,t[39]=_,t[40]=he):he=t[40];let ge=he,_e=ge!==null,ve;t[41]!==me||t[42]!==_e||t[43]!==h?(ve=_e?null:nC(h,me),t[41]=me,t[42]=_e,t[43]=h,t[44]=ve):ve=t[44];let ye=ve,be=!C&&(!x||ae!==null)&&(_e||ye!==null),xe;t[45]===h?xe=t[46]:(xe=Wo.filter(e=>h[e.id]?.installed===!0),t[45]=h,t[46]=xe);let Se=xe,Ce;t[47]===h?Ce=t[48]:(Ce=Wo.some(e=>h[e.id]?.installed==null),t[47]=h,t[48]=Ce);let we=Ce,Te=_===null?void 0:_i.map(e=>{let{displayName:t}=Gn[e];return{cli:e,label:t,ariaLabel:l({id:`QYfQdv`,values:{displayName:t}}),selected:ge===e,onSelect:()=>Pe(e)}}),Ee;t[49]===l?Ee=t[50]:(Ee=l({id:`KYSocE`}),t[49]=l,t[50]=Ee);let De;t[51]===l?De=t[52]:(De=l({id:`7Ongq0`}),t[51]=l,t[52]=De);let Oe;t[53]===l?Oe=t[54]:(Oe=l({id:`HPTPGr`}),t[53]=l,t[54]=Oe);let ke;t[55]===l?ke=t[56]:(ke=l({id:`qiRoLb`}),t[55]=l,t[56]=ke);let Ae;t[57]!==Ee||t[58]!==De||t[59]!==Oe||t[60]!==ke?(Ae=[Ee,De,Oe,ke],t[57]=Ee,t[58]=De,t[59]=Oe,t[60]=ke,t[61]=Ae):Ae=t[61];let je=aE(Ae,!p&&x&&!c),Me;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(Me=e=>{b(e.id),tC(e.id)},t[62]=Me):Me=t[62];let Ne=Me,Pe=e=>{let t=ZS(e);b(t),tC(t)},Fe;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=()=>{T.current?.clear(),oe(null),le(!1),V([]),U(new Set),wS()},t[63]=Fe):Fe=t[63];let Ie=Fe,Le;t[64]!==l||t[65]!==g||t[66]!==ye||t[67]!==ge||t[68]!==_?(Le=e=>{if(e===null){Js.error(l({id:`y8B54M`}));return}if(ge!==null&&_!==null){try{_.launchInTerminal(e,ge)}catch{Js.error(l({id:`jBVUXo`}));return}Ie();return}ye!==null&&(w(!0),g(ye.id,e).finally(()=>{w(!1),Ie()}))},t[64]=l,t[65]=g,t[66]=ye,t[67]=ge,t[68]=_,t[69]=Le):Le=t[69];let Re=Le,ze;t[70]!==J||t[71]!==be||t[72]!==Re||t[73]!==n||t[74]!==ne||t[75]!==u||t[76]!==i||t[77]!==ae||t[78]!==m?(ze=()=>{if(!be)return;let{instruction:e,mentions:t}=T.current?.getContent()??{instruction:``,mentions:[]};if(u){Re(Qo({docName:null,folderRelativePath:i,workspace:m,instruction:e,mentions:[...new Set([...ne,...t])].filter(e=>e!==i)}));return}let r=ae?iu(ae):void 0,a=ae?.docName??null,o=ae?a:ne.includes(J)?n??null:null,s=o===null?null:Ko(o);Re(Qo({docName:o,workspace:m,instruction:e,mentions:[...new Set([...ne,...t])].filter(e=>e!==s),selection:r}))},t[70]=J,t[71]=be,t[72]=Re,t[73]=n,t[74]=ne,t[75]=u,t[76]=i,t[77]=ae,t[78]=m,t[79]=ze):ze=t[79];let Be=ze;if(c)return null;let Ve=``,He=``;if(ae){let e;t[80]===ae?e=t[81]:(e=au(ae,Ko(ae.docName).split(`/`).pop()??``),t[80]=ae,t[81]=e),Ve=e;let n;t[82]===ae.markdown?n=t[83]:(n=ou(ae.markdown),t[82]=ae.markdown,t[83]=n),He=n}let Ue;t[84]!==l||t[85]!==u||t[86]!==o?(Ue=u?null:(0,Z.jsx)(Di,{type:`button`,variant:`outline`,"aria-label":l({id:`EWX92Z`}),onClick:()=>o?.(),"data-testid":`ask-ai-collapse`,className:`-top-2.5 -translate-x-1/2 absolute left-1/2 z-10 h-5 w-10 rounded-md p-0 text-muted-foreground opacity-0 shadow-sm transition-opacity hover:text-foreground focus-visible:opacity-100 group-focus-within:opacity-100 group-hover:opacity-100`,children:(0,Z.jsx)(so,{className:`size-3.5`,"aria-hidden":!0})}),t[84]=l,t[85]=u,t[86]=o,t[87]=Ue):Ue=t[87];let We;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(We=e=>U(t=>{let n=new Set(t);return n.add(e),n}),t[88]=We):We=t[88];let Ge;t[89]!==l||t[90]!==Ve||t[91]!==He||t[92]!==ae||t[93]!==se?(Ge=ae?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"data-testid":`composer-selection-pill`,title:Ve,className:`group/chip inline-flex max-w-[16rem] items-center gap-1 rounded-md border bg-muted/40 py-0.5 pr-1.5 pl-1 text-muted-foreground text-xs`,children:[(0,Z.jsxs)(Di,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":l({id:`irrm_E`}),onClick:()=>{oe(null),le(!1)},className:`group/remove relative size-3.5 shrink-0 rounded-sm text-muted-foreground/80 hover:text-foreground`,children:[(0,Z.jsx)(Ud,{className:`absolute top-1/2 left-1/2 size-3 -translate-x-1/2 -translate-y-1/2 opacity-100 transition-opacity duration-150 ease-out group-hover/chip:opacity-0 group-focus-within/chip:opacity-0 motion-reduce:transition-none`,"aria-hidden":!0}),(0,Z.jsx)(Ys,{className:`absolute top-1/2 left-1/2 size-3 -translate-x-1/2 -translate-y-1/2 opacity-0 transition-opacity duration-150 ease-out group-hover/chip:opacity-100 group-focus-within/chip:opacity-100 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,Z.jsx)(Di,{type:`button`,variant:`ghost`,"aria-expanded":se,"aria-label":l(se?{id:`UaDyeb`}:{id:`eTL5y9`}),onClick:()=>le(uE),"data-testid":`composer-selection-peek`,className:`h-auto min-h-0 min-w-0 shrink justify-start px-0 py-0 text-left font-normal text-muted-foreground text-xs hover:bg-transparent hover:text-foreground`,children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:Ve})})]}),se&&He!==``?(0,Z.jsx)(`p`,{className:`max-h-24 w-full basis-full overflow-y-auto whitespace-pre-wrap text-2xs text-muted-foreground/80 subtle-scrollbar`,"data-testid":`composer-selection-preview`,children:He}):null]}):null,t[89]=l,t[90]=Ve,t[91]=He,t[92]=ae,t[93]=se,t[94]=Ge):Ge=t[94];let Ke;t[95]!==ne||t[96]!==Ge?(Ke=(0,Z.jsx)(QT,{files:ne,onRemoveFile:We,children:Ge}),t[95]=ne,t[96]=Ge,t[97]=Ke):Ke=t[97];let qe;t[98]===l?qe=t[99]:(qe=l({id:`xWEvuo`}),t[98]=l,t[99]=qe);let Je;t[100]!==D||t[101]!==Be||t[102]!==qe?(Je=(0,Z.jsx)(GS,{ref:T,ariaLabel:qe,onEmptyChange:S,onContentChange:CS,onMentionsChange:K,onSubmit:Be,initialDoc:D,className:`max-h-[200px] overflow-y-auto text-base md:text-sm`}),t[100]=D,t[101]=Be,t[102]=qe,t[103]=Je):Je=t[103];let Ye;t[104]!==x||t[105]!==p||t[106]!==je?(Ye=x?(0,Z.jsx)(`div`,{"aria-hidden":!0,className:Ti(`pointer-events-none absolute inset-0 truncate px-0 py-1 text-base text-muted-foreground/60 md:text-sm`,!p&&`transition-opacity duration-500 ease-in-out`,je.visible?`opacity-100`:`opacity-0`),children:je.text}):null,t[104]=x,t[105]=p,t[106]=je,t[107]=Ye):Ye=t[107];let Xe;t[108]!==Je||t[109]!==Ye?(Xe=(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[Je,Ye]}),t[108]=Je,t[109]=Ye,t[110]=Xe):Xe=t[110];let Ze;t[111]!==ye||t[112]!==ge?(Ze=ge===null?ye?(0,Z.jsx)(Xo,{id:ye.id,className:`size-4`,"aria-hidden":!0}):null:(0,Z.jsx)(Xo,{id:Yo(ge),className:`size-4`,"aria-hidden":!0}),t[111]=ye,t[112]=ge,t[113]=Ze):Ze=t[113];let Qe;t[114]!==ye||t[115]!==ge?(Qe=(0,Z.jsx)(`span`,{children:ge===null?ye?(0,Z.jsx)(X,{id:`nUNZL4`,values:{0:ye.displayName}}):(0,Z.jsx)(X,{id:`F-vBv0`}):(0,Z.jsx)(X,{id:`ti6aF_`,values:{0:Gn[ge].displayName}})}),t[114]=ye,t[115]=ge,t[116]=Qe):Qe=t[116];let $e;t[117]===C?$e=t[118]:($e=C?(0,Z.jsx)(hs,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t[117]=C,t[118]=$e);let et;t[119]!==Ze||t[120]!==Qe||t[121]!==$e?(et=(0,Z.jsxs)(Z.Fragment,{children:[Ze,Qe,$e]}),t[119]=Ze,t[120]=Qe,t[121]=$e,t[122]=et):et=t[122];let tt=!be,nt=_e?null:ye?.id??null,rt;t[123]===we?rt=t[124]:(rt=(0,Z.jsx)(`p`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,"aria-live":`polite`,children:we?(0,Z.jsx)(X,{id:`EcR0fl`}):(0,Z.jsx)(X,{id:`l6OXqI`})}),t[123]=we,t[124]=rt);let it;t[125]===l?it=t[126]:(it=l({id:`nskygk`}),t[125]=l,t[126]=it);let at;t[127]===Symbol.for(`react.memo_cache_sentinel`)?(at={primary:`ask-ai-send`,trigger:`ask-ai-agent-trigger`,menu:`ask-ai-agent-menu`,option:lE,terminal:cE},t[127]=at):at=t[127];let ot;t[128]!==Te||t[129]!==Ne||t[130]!==Se||t[131]!==Be||t[132]!==et||t[133]!==tt||t[134]!==nt||t[135]!==rt||t[136]!==it?(ot=(0,Z.jsx)($T,{primary:et,onPrimary:Be,primaryDisabled:tt,installedTargets:Se,selectedTargetId:nt,onSelectTarget:Ne,terminals:Te,menuEmptyState:rt,triggerAriaLabel:it,testIds:at}),t[128]=Te,t[129]=Ne,t[130]=Se,t[131]=Be,t[132]=et,t[133]=tt,t[134]=nt,t[135]=rt,t[136]=it,t[137]=ot):ot=t[137];let st;t[138]!==Xe||t[139]!==ot?(st=(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[Xe,ot]}),t[138]=Xe,t[139]=ot,t[140]=st):st=t[140];let ct;t[141]!==Ue||t[142]!==Ke||t[143]!==st?(ct=(0,Z.jsxs)(`div`,{ref:E,className:`pointer-events-auto group relative flex flex-col gap-1.5 rounded-2xl border border-border/60 bg-card px-3 py-2 shadow-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50`,children:[Ue,Ke,st]}),t[141]=Ue,t[142]=Ke,t[143]=st,t[144]=ct):ct=t[144];let lt=ct;if(u){let e;return t[145]===lt?e=t[146]:(e=(0,Z.jsx)(`div`,{className:`shrink-0 pt-2 pb-3`,"data-testid":`bottom-composer`,children:(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-6`,children:lt})}),t[145]=lt,t[146]=e),e}let ut;return t[147]===lt?ut=t[148]:(ut=(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-20 editor-content-aligned bg-gradient-to-t from-background from-65% via-background to-transparent pt-10 pb-2`,"data-testid":`bottom-composer`,children:lt}),t[147]=lt,t[148]=ut),ut}function cE(e){return e===`claude`?`ask-ai-agent-option-terminal`:`ask-ai-agent-option-terminal-${e}`}function lE(e){return`ask-ai-agent-option-${e}`}function uE(e){return!e}function dE(){return new Set}function fE(){let e=pE;return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})}function pE(e){Sl(e,`open-ask-ai`)&&(nE(e.target)||(e.preventDefault(),tu()))}function mE(){let e=[...document.querySelectorAll(`.editor-doc-scroll`)].filter(hE);if(e.length===0)return;let t=!1,n=()=>{t=!0};window.addEventListener(`wheel`,n,{passive:!0}),window.addEventListener(`touchstart`,n,{passive:!0});let r=performance.now(),i=()=>{if(t||performance.now()-r>=300){window.removeEventListener(`wheel`,n),window.removeEventListener(`touchstart`,n);return}for(let t of e)t.scrollTop=t.scrollHeight-t.clientHeight;requestAnimationFrame(i)};requestAnimationFrame(i)}function hE(e){let t=e.scrollHeight-e.clientHeight;return t>0&&e.scrollTop>=t-40}function gE(){return SS().doc??void 0}function _E(){return eC()}function vE(e){return!e.terminalVisible&&!e.isEmbedded&&e.isDesktop&&e.activeDocName!==null}function yE(e){return!e.terminalVisible&&!e.isEmbedded&&e.isDesktop}function bE(e,t={}){let n=De(e.componentName);return n.name===`*`?t.unregisteredSuffix?`${e.componentName} (unregistered)`:e.componentName:n.displayName??n.name}var xE=200,SE=`Outside any block`;function CE(e){let t=(0,$.c)(5),{editor:n}=e,r=tn(n),i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(!1),s,c;t[0]!==r||t[1]!==n?(s=()=>{if(a.current!==null&&(window.clearTimeout(a.current),a.current=null),!n||!i.current)return;let e=r!==null&&r.ancestorChain.length>0,t;return t=e?wE(n,r):o.current?SE:``,a.current=window.setTimeout(()=>{i.current&&(i.current.textContent=``,i.current.textContent=t),o.current=e,a.current=null},xE),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)}},c=[n,r],t[0]=r,t[1]=n,t[2]=s,t[3]=c):(s=t[2],c=t[3]),(0,Q.useEffect)(s,c);let l;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`div`,{ref:i,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`}),t[4]=l):l=t[4],l}function wE(e,t){if(!t||t.ancestorChain.length===0)return``;let n=t.ancestorChain,r=n[n.length-1],i=bE(r,{unregisteredSuffix:!0});if(n.length===1)return`Selected: ${i}`;let a=n[n.length-2],o=bE(a);try{let t=e.state.doc.resolve(r.pos),n=t.index(t.depth),a=t.parent.childCount;return`Selected: ${i}, ${n+1} of ${a} in ${o}`}catch{return`Selected: ${i} in ${o}`}}function TE(){let[e]=(0,Q.useState)(gr);return e}function EE({principal:e,identity:t}){return e&&e.source===`git-config`?{type:`human`,name:pi(e.display_name),color:wr(e.id,Zn),coeditor:t.coeditor,tabId:t.tabId,principalId:e.id}:e&&e.source===`synthesized`?{type:`human`,name:t.name,color:wr(e.id,Zn),coeditor:t.coeditor,tabId:t.tabId}:{type:`human`,name:t.name,color:t.color,coeditor:t.coeditor,tabId:t.tabId}}function DE(e,t){return e>t}function OE(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.isChangeOrigin===!0?!0:`snapshot`in t&&`prevSnapshot`in t&&t.snapshot===null&&t.prevSnapshot===null}var kE=3,AE=6e4;function jE(e,t){let n=0;for(let r of e)t-r<AE&&(n+=1);return n<kE}var ME=new Map;function NE(e,t){for(let n of e.changed.keys()){let e=n;for(;e!=null;){if(e===t)return!0;let n=e._item;e=n==null?null:n.parent}}return!1}function PE(e){let t=y.getState(e);return t?.snapshot!=null||t?.prevSnapshot!=null}function FE(e){let{fragment:t,docName:n,onWedged:r}=e,i=0,a=0,o=!1,s=!1,c=!1,l=null,u=new WeakSet,d=e=>{let t=y.getState(e)?.binding;if(!t)return;if(typeof t._prosemirrorChanged!=`function`){Ot.count(`ok/editor/binding-guard-disarmed`,{docName:n,reason:`no-prosemirror-changed`}),console.warn(`[binding-staleness-guard] ySync binding on "${n}" exposes no _prosemirrorChanged — write-back gate disarmed (vendored y-tiptap contract change?)`);return}if(u.has(t))return;u.add(t);let r=t._prosemirrorChanged.bind(t);t._prosemirrorChanged=e=>{DE(i,a)||r(e)}},f=()=>{if(c=!1,!s||o||!DE(i,a)||l!==null&&PE(l.state))return;o=!0;let e=Date.now();for(let[t,n]of ME)n.every(t=>e-t>=AE)&&ME.delete(t);let t=(ME.get(n)??[]).filter(t=>e-t<AE);if(!jE(t,e)){ME.set(n,t),Ot.count(`ok/editor/binding-wedge-rate-capped`,{docName:n}),console.warn(`[binding-staleness-guard] wedge on "${n}" rate-capped (externalSeq=${i}, appliedSeq=${a}) — publication gate stays closed, no further recycle`);return}t.push(e),ME.set(n,t),console.warn(`[binding-staleness-guard] wedged binding on "${n}" — Y→PM apply missing (externalSeq=${i}, appliedSeq=${a})`);try{r({externalSeq:i,appliedSeq:a})}catch(e){o=!1,Ot.count(`ok/editor/binding-wedge-recovery-error`,{docName:n}),console.error(`[binding-staleness-guard] wedge recovery threw for "${n}":`,e)}},p=e=>{e.origin!==y&&NE(e,t)&&(i+=1,c||(c=!0,queueMicrotask(f)))};return new ui({state:{init:()=>null,apply:e=>(OE(e.getMeta(y))&&(a=i,o&&Ot.count(`ok/editor/binding-wedge-recovered`,{docName:n}),o=!1),null)},filterTransaction:(e,t)=>!DE(i,a)||PE(t)?!0:e.getMeta(y)!==void 0,view:e=>{let r=t.doc;return r==null?(Ot.count(`ok/editor/binding-guard-disarmed`,{docName:n,reason:`no-ydoc`}),console.error(`[binding-staleness-guard] fragment has no Y.Doc for "${n}" — staleness guard disarmed`),{}):(s=!0,l=e,d(e.state),r.off(`beforeObserverCalls`,p),r.on(`beforeObserverCalls`,p),{destroy:()=>{s=!1,l=null,r.off(`beforeObserverCalls`,p)}})}})}function IE(e,t){let n=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),a=Math.max(e.right,t.right)-i,o=r-n;return new DOMRect(i,n,a,o)}var LE=class{constructor({editor:e,element:t,view:n,pluginKey:r=`bubbleMenu`,updateDelay:i=250,resizeDelay:a=60,shouldShow:o,appendTo:s,getReferencedVirtualElement:c,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:`absolute`,placement:`top`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:a}=t,{empty:o}=a,s=!i.textBetween(n,r).length&&Bn(t.selection),c=this.element.contains(document.activeElement);return!(!(e.hasFocus()||c)||o||s||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);!n&&!r||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.show(),this.updatePosition()}},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=l?.scrollTarget??window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener(`dragstart`,this.dragstartHandler),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Dc(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Cc(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(Tc(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(wc(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(xc(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(Ec(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(vc(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(yc(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}get virtualElement(){let{selection:e}=this.editor.state,t=this.getReferencedVirtualElement?.call(this);if(t)return t;if(!this.view?.dom?.parentNode)return;let n=ci(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof Xr){let t=this.view.nodeDOM(e.from),n=t.dataset.nodeViewWrapper?t:t.querySelector(`[data-node-view-wrapper]`);n&&(t=n),t&&(r={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(e instanceof sr){let{$anchorCell:t,$headCell:n}=e,i=t?t.pos:n.pos,a=n?n.pos:t.pos,o=this.view.nodeDOM(i),s=this.view.nodeDOM(a);if(!o||!s)return;let c=o===s?o.getBoundingClientRect():IE(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&Sc(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}let i=!t?.selection.eq(e.state.selection),a=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,a,t)}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:e,from:i,to:a})||!1}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener(`dragstart`,this.dragstartHandler),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},RE=e=>new ui({key:typeof e.pluginKey==`string`?new Fr(e.pluginKey):e.pluginKey,view:t=>new LE({view:t,...e})});Si.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[RE({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var zE=class{constructor({editor:e,element:t,view:n,pluginKey:r=`floatingMenu`,updateDelay:i=250,resizeDelay:a=60,options:o,appendTo:s,shouldShow:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,a=r.depth===1,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&r.parent.childCount===0&&!this.getTextContent(r.parent);return!(!e.hasFocus()||!i||!a||!o||!this.editor.isEditable)},this.floatingUIOptions={strategy:`absolute`,placement:`right`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.updatePosition(),this.show()}},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=o?.scrollTarget??window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return rr(e,{textSerializers:Tr(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Dc(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Cc(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(Tc(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(wc(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(xc(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(Ec(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(vc(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(yc(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,view:this.view,state:t,oldState:e,from:i,to:a})}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){let{selection:e}=this.editor.state,t=ci(this.view,e.from,e.to);Sc({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);this.updateHandler(e,n,r,t)}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},BE=e=>new ui({key:typeof e.pluginKey==`string`?new Fr(e.pluginKey):e.pluginKey,view:t=>new zE({view:t,...e})});Si.create({name:`floatingMenu`,addOptions(){return{element:null,options:{},pluginKey:`floatingMenu`,updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,`updatePosition`),!0)}},addProseMirrorPlugins(){return this.options.element?[BE({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function VE(e,t){return e??new Fr(t)}var HE=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,UE=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),WE=new Set(`animationIterationCount.aspectRatio.borderImageOutset.borderImageSlice.borderImageWidth.columnCount.columns.fillOpacity.flex.flexGrow.flexShrink.fontWeight.gridArea.gridColumn.gridColumnEnd.gridColumnStart.gridRow.gridRowEnd.gridRowStart.lineClamp.lineHeight.opacity.order.orphans.scale.stopOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeOpacity.strokeWidth.tabSize.widows.zIndex.zoom`.split(`.`)),GE=new Set([`children`,`className`,`style`]),KE=new Set([`tabIndex`]),qE=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),JE={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function YE(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function XE(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function ZE(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||qE.has(e)}function QE(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function $E(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:JE[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function eD(e,t){let n=t.defaultPrevented,r=!1,i=Object.create(t);return Object.defineProperties(i,{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>void 0},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,t.preventDefault()}},stopPropagation:{value:()=>{r=!0,t.stopPropagation()}}}),i}function tD(e){return KE.has(e)}function nD(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function rD(e,t){if(t===`tabIndex`){e.removeAttribute(`tabindex`);return}let n=e[t];if(typeof n==`boolean`){e[t]=!1;return}if(typeof n==`number`){e[t]=0;return}e[t]=``}function iD(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||WE.has(e)?String(t):`${t}px`}function aD(e,t){UE.has(t)||e.style.removeProperty(QE(t))}function oD(e,t,n){UE.has(t)||e.style.setProperty(QE(t),iD(t,n))}function sD(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(GE.has(r)||!ZE(r)||YE(r,t[r])||YE(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=XE(r);if(a==null||a===!1){tD(r)&&rD(e,r),e.removeAttribute(o);return}if(a===!0){tD(r)&&nD(e,r,!0),e.setAttribute(o,``);return}if(tD(r)){nD(e,r,a);return}e.setAttribute(o,String(a))})}function cD(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function lD(e,t,n){let r=t??{},i=n??{};new Set([...Object.keys(r),...Object.keys(i)]).forEach(t=>{let n=r[t],a=i[t];if(n!==a){if(a==null){aD(e,t);return}oD(e,t,a)}})}function uD(e,t,n){t.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)});let r=[];return Object.entries(n).forEach(([t,n])=>{if(!YE(t,n))return;let{eventName:i,options:a}=$E(t),o=t=>{n(eD(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function dD(e,t){let n=(0,Q.useRef)({}),r=(0,Q.useRef)([]);HE(()=>{let i=n.current;return cD(e,i.className,t.className),lD(e,i.style,t.style),sD(e,i,t),r.current=uD(e,r.current,t),n.current=t,()=>{r.current.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),r.current=[]}},[e,t])}var fD=Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:c,...l},u)=>{let d=(0,Q.useRef)(document.createElement(`div`)),f=(0,Q.useRef)(VE(e,`bubbleMenu`)).current;dD(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=se(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,getReferencedVirtualElement:o,options:s},g=(0,Q.useRef)(h);g.current=h;let[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(!0);return(0,Q.useEffect)(()=>{if(m?.isDestroyed)return;if(!m){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=d.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=RE({...g.current,editor:m,element:e});m.registerPlugin(t);let n=g.current.pluginKey;return y.current=!0,v(!0),()=>{v(!1),m.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[m]),(0,Q.useEffect)(()=>{if(!(!_||!m||m.isDestroyed)){if(y.current){y.current=!1;return}m.view.dispatch(m.state.tr.setMeta(f,{type:`updateOptions`,options:g.current}))}},[_,m,n,r,a,s,i,o,f]),(0,Au.createPortal)(c,d.current)});Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...c},l)=>{let u=(0,Q.useRef)(document.createElement(`div`)),d=(0,Q.useRef)(VE(e,`floatingMenu`)).current;dD(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=se(),p=t||f,m={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:a,options:o},h=(0,Q.useRef)(m);h.current=m;let[g,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(!0);return(0,Q.useEffect)(()=>{if(p?.isDestroyed)return;if(!p){console.warn(`FloatingMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=u.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=BE({...h.current,editor:p,element:e});p.registerPlugin(t);let n=h.current.pluginKey;return v.current=!0,_(!0),()=>{_(!1),p.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[p]),(0,Q.useEffect)(()=>{if(!(!g||!p||p.isDestroyed)){if(v.current){v.current=!1;return}p.view.dispatch(p.state.tr.setMeta(d,{type:`updateOptions`,options:h.current}))}},[g,p,n,r,a,o,i,d]),(0,Au.createPortal)(s,u.current)});var pD=[{name:`paragraph`,label:`Text`,icon:xd,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:Je,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:Qe,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:ht,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:Ne,isActive:e=>e.isActive(`list`,{ordered:!1})&&!e.isActive(`listItem`,{checked:!0})&&!e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleBulletList().run()},{name:`orderedList`,label:`Ordered List`,icon:Wt,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:dt,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:Ee,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:Md,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock({language:`js`}).run()}];function mD(e){let t=(0,$.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:hD},t[0]=n,t[1]=r);let{current:i,activeStates:a}=w(r),o=i.icon,s;t[2]===o?s=t[3]:(s=(0,Z.jsx)(o,{className:`size-3.5`}),t[2]=o,t[3]=s);let c;t[4]===i.label?c=t[5]:(c=(0,Z.jsx)(`span`,{children:i.label}),t[4]=i.label,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(so,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,Z.jsx)(qc,{asChild:!0,children:(0,Z.jsxs)(Di,{variant:`ghost`,size:`sm`,className:`gap-1 px-2 text-sm font-medium text-accent-foreground/80`,children:[s,c,l]})}),t[7]=s,t[8]=c,t[9]=u):u=t[9];let d;t[10]!==a||t[11]!==n?(d=pD.map(e=>{let t=e.icon,r=a[e.name];return(0,Z.jsxs)(Yc,{className:r?`bg-accent text-accent-foreground`:``,onSelect:()=>{e.command(n)},children:[(0,Z.jsx)(t,{className:`size-4`}),(0,Z.jsx)(`span`,{children:e.label})]},e.name)}),t[10]=a,t[11]=n,t[12]=d):d=t[12];let f;t[13]===d?f=t[14]:(f=(0,Z.jsx)(Zc,{align:`start`,sideOffset:8,className:`w-44 max-h-(--radix-dropdown-menu-content-available-height) overflow-y-auto subtle-scrollbar`,children:d}),t[13]=d,t[14]=f);let p;return t[15]!==u||t[16]!==f?(p=(0,Z.jsxs)(rl,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function hD(e){let t=Object.fromEntries(pD.map(t=>[t.name,t.isActive(e.editor)]));return{current:pD.find(e=>t[e.name])??pD[0],activeStates:t}}function gD(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toUpperCase();return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`}function _D(e){let t=(0,$.c)(2),{shortcutEnabled:n}=e,r=n===void 0?!1:n,i=dr(),a=es();if(!i||a)return null;let o;return t[0]===r?o=t[1]:(o=(0,Z.jsx)(vD,{shortcutEnabled:r}),t[0]=r,t[1]=o),o}function vD(e){let t=(0,$.c)(5),{shortcutEnabled:n}=e,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{let e=e=>{n&&Sl(e,`edit-with-ai`)&&(gD(e.target)||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),tu()))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},i=[n],t[0]=n,t[1]=r,t[2]=i),(0,Q.useEffect)(r,i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(sa,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[3]=a):a=t[3];let o;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsxs)(Z.Fragment,{children:[a,(0,Z.jsxs)(Di,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`edit-with-ai-bubble-button`,className:`gap-1 px-2 text-sm font-medium text-accent-foreground/80`,onClick:yD,children:[(0,Z.jsx)(Ws,{className:`size-3.5`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(X,{id:`xWEvuo`})})]})]}),t[4]=o):o=t[4],o}function yD(){return tu()}function bD(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(n!==`File`&&n!==`WikiEmbedFile`)return null;let r=(t.attrs.props??{}).src;return typeof r!=`string`||r.length===0?null:r}function xD(e){let t=e.state.selection.node;if(!t)return``;let n=t.attrs.props??{},r=typeof n.alias==`string`?n.alias:``;if(r.length>0)return r;let i=typeof n.name==`string`?n.name:``;return i.length>0?i:ft(typeof n.src==`string`?n.src:``)}function SD(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),n.remove()}function CD(e){let t=(0,$.c)(13),{editor:n}=e,{_:r}=cn(),i;if(t[0]===n?i=t[1]:(i={editor:n,selector:wD},t[0]=n,t[1]=i),w(i)===null)return null;let a;t[2]===r?a=t[3]:(a=r({id:`WcWS__`}),t[2]=r,t[3]=a);let o;t[4]===n?o=t[5]:(o=e=>{e.preventDefault();let t=bD(n);t&&SD(t,xD(n))},t[4]=n,t[5]=o);let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(Pa,{className:`size-3.5`}),t[6]=s):s=t[6];let c;t[7]!==a||t[8]!==o?(c=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,"aria-label":a,className:`text-accent-foreground`,onMouseDown:o,children:s})}),t[7]=a,t[8]=o,t[9]=c):c=t[9];let l;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(mc,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(X,{id:`WcWS__`})}),t[10]=l):l=t[10];let u;return t[11]===c?u=t[12]:(u=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:(0,Z.jsxs)(gc,{children:[c,l]})}),t[11]=c,t[12]=u),u}function wD(e){return bD(e.editor)}function TD(e){return bD(e)!==null}function ED(e){let t=e.schema.nodes;return!!(t.footnoteReference&&t.footnoteDefinition)}function DD(e){let{from:t,to:n}=e.state.selection,r=!1;return e.state.doc.nodesBetween(t,n,e=>e.type.name===`footnoteReference`?(r=!0,!1):!0),r}function OD(e){let{$from:t,$to:n}=e.state.selection;return!t.sameParent(n)}function kD(e){let t=(0,$.c)(21),{editor:n}=e,{_:r}=cn(),i;t[0]===n?i=t[1]:(i={editor:n,selector:AD},t[0]=n,t[1]=i);let a=w(i),o;t[2]!==a||t[3]!==n?(o=()=>{if(a||!ED(n)||n.state.selection.empty||OD(n)||DD(n))return;let{from:e,to:t}=n.state.selection,r=n.state.doc.textBetween(e,t,` `);if(!r.trim())return;let i=li(Er(n.state.doc)),o=Vr(n.state.doc)+1-(t-e);n.chain().focus().deleteSelection().insertFootnoteReference(i).insertContentAt(o,{type:`footnoteDefinition`,attrs:{identifier:i,label:i},content:[{type:`paragraph`,content:[{type:`text`,text:r}]}]}).run()},t[2]=a,t[3]=n,t[4]=o):o=t[4];let s=o,c;t[5]===r?c=t[6]:(c=r({id:`sIGbBZ`}),t[5]=r,t[6]=c);let l;t[7]===s?l=t[8]:(l=e=>{e.preventDefault(),s()},t[7]=s,t[8]=l);let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(Mt,{className:`size-3.5`,"aria-hidden":`true`}),t[9]=u):u=t[9];let d;t[10]!==a||t[11]!==c||t[12]!==l?(d=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{type:`button`,variant:`ghost`,size:`icon-xs`,"data-testid":`footnote-bubble-button`,className:`text-accent-foreground/80`,"aria-label":c,onMouseDown:l,disabled:a,children:u})}),t[10]=a,t[11]=c,t[12]=l,t[13]=d):d=t[13];let f;t[14]===r?f=t[15]:(f=r({id:`sIGbBZ`}),t[14]=r,t[15]=f);let p;t[16]===f?p=t[17]:(p=(0,Z.jsx)(mc,{side:`bottom`,sideOffset:8,children:f}),t[16]=f,t[17]=p);let m;return t[18]!==d||t[19]!==p?(m=(0,Z.jsxs)(gc,{children:[d,p]}),t[18]=d,t[19]=p,t[20]=m):m=t[20],m}function AD(e){let t=e.editor;return!!(!ED(t)||t.state.selection.empty||OD(t)||DD(t))}var jD=`img, .ok-embed, .ok-video`,MD=220,ND=`cubic-bezier(0.23, 1, 0.32, 1)`,PD=`ok-image-align-flip`,FD=.5;function ID(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function LD(){return typeof requestAnimationFrame==`function`}function RD(e){return e?e.querySelector(jD):null}function zD(e,t){if(ID()||!LD()){t();return}let n=RD(e);if(!n){t();return}let r=n.getBoundingClientRect().left;t(),requestAnimationFrame(()=>{let t=RD(e);if(!t)return;for(let e of t.getAnimations())e.id===PD&&e.cancel();let n=r-t.getBoundingClientRect().left;if(Math.abs(n)<FD)return;let i=t.animate([{transform:`translateX(${n}px)`},{transform:`translateX(0)`}],{duration:MD,easing:ND,fill:`none`});i.id=PD})}var BD=[{value:`left`,label:`Align left`,icon:Hd},{value:`center`,label:`Align center`,icon:Bd},{value:`right`,label:`Align right`,icon:Vd}];function VD(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(!Kt.has(String(n)))return null;let r=(t.attrs.props??{}).align;return r===`left`||r===`right`||r===`center`?r:`center`}function HD(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:UD},t[0]=n,t[1]=r);let i=w(r);if(i===null)return null;let a;t[2]!==i||t[3]!==n?(a=BD.map(e=>{let{value:t,label:r,icon:a}=e,o=i===t;return(0,Z.jsxs)(gc,{children:[(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,"aria-label":r,"aria-pressed":o,className:o?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:e=>{e.preventDefault();let r=n.state.selection,i=r.node;if(!i||i.type.name!==`jsxComponent`)return;let a=String(i.attrs.componentName??``);if(!Kt.has(a)||i.attrs.kind!==`element`)return;let o=a===`CommonMarkImage`,s=r.from,c={...i.attrs.props??{},align:t},l=o?{...i.attrs,componentName:`img`,props:c,sourceDirty:!0}:{...i.attrs,props:c,sourceDirty:!0},u=n.state.tr.setNodeMarkup(s,null,l);u.setSelection(Xr.create(u.doc,s)),zD(n.view.nodeDOM(s),()=>{n.view.dispatch(u)})},children:(0,Z.jsx)(a,{className:`size-3.5`})})}),(0,Z.jsx)(mc,{side:`bottom`,sideOffset:8,children:r})]},t)}),t[2]=i,t[3]=n,t[4]=a):a=t[4];let o;return t[5]===a?o=t[6]:(o=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:a}),t[5]=a,t[6]=o),o}function UD(e){return VD(e.editor)}function WD(e){return VD(e)!==null}var GD=[{name:`bold`,icon:Ou,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcutId:`format-bold`},{name:`italic`,icon:id,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcutId:`format-italic`},{name:`underline`,icon:Gd,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcutId:`format-underline`},{name:`strikethrough`,icon:Ld,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcutId:`format-strike`},{name:`code`,icon:ie,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcutId:`format-inline-code`},{name:`highlight`,icon:nd,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcutId:`format-highlight`}];function KD(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:qD},t[0]=n,t[1]=r);let i=w(r),a;t[2]!==i||t[3]!==n?(a=GD.map(e=>{let t=e.icon,r=i[e.name];return(0,Z.jsxs)(gc,{children:[(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,"aria-label":e.name,className:r?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:t=>{t.preventDefault(),e.command(n)},children:(0,Z.jsx)(t,{className:`size-3.5`})})}),(0,Z.jsxs)(mc,{side:`bottom`,sideOffset:8,children:[(0,Z.jsx)(`span`,{className:`capitalize`,children:e.name}),(0,Z.jsx)(Dt,{"aria-label":Cl(e.shortcutId),children:xl(e.shortcutId)})]})]},e.name)}),t[2]=i,t[3]=n,t[4]=a):a=t[4];let o;return t[5]===a?o=t[6]:(o=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:a}),t[5]=a,t[6]=o),o}function qD(e){return Object.fromEntries(GD.map(t=>[t.name,t.isActive(e.editor)]))}function JD(e){let t=(0,$.c)(66),{editor:n}=e,{_:r}=cn(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),c=(0,Q.useRef)(null),{folderPaths:l,loading:u,pages:d}=Oo(),f;t[0]===n?f=t[1]:(f=n.state.selection.empty&&n.isActive(`link`),t[0]=n,t[1]=f);let p=f,m;t[2]===n?m=t[3]:(m=n.getAttributes(`link`).href??``,t[2]=n,t[3]=m);let h=m,g;t[4]===n?g=t[5]:(g=function(){return n.state.selection.empty&&n.isActive(`link`)?n.getAttributes(`link`).href??``:``},t[4]=n,t[5]=g);let _=g,v,y;t[6]===n?(v=t[7],y=t[8]):(v=()=>{let e=function(){n.state.selection.empty&&a(!1)};return n.on(`selectionUpdate`,e),()=>{n.off(`selectionUpdate`,e)}},y=[n],t[6]=n,t[7]=v,t[8]=y),(0,Q.useEffect)(v,y);let b,x;t[9]===i?(b=t[10],x=t[11]):(b=()=>{i&&requestAnimationFrame(()=>c.current?.focus())},x=[i],t[9]=i,t[10]=b,t[11]=x),(0,Q.useEffect)(b,x);let S;t[12]!==n||t[13]!==p||t[14]!==o?(S=function(){o.trim()?n.chain().focus().setLink({href:o.trim()}).run():p&&n.chain().focus().unsetLink().run(),a(!1)},t[12]=n,t[13]=p,t[14]=o,t[15]=S):S=t[15];let C=S,w;t[16]===n?w=t[17]:(w=function(){n.chain().focus().unsetLink().run(),a(!1)},t[16]=n,t[17]=w);let T=w,E;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(E=function(e){s(Y(e.path,null))},t[18]=E):E=t[18];let D=E,O;t[19]!==C||t[20]!==n?(O=function(e){e.key===`Enter`&&(e.preventDefault(),C()),e.key===`Escape`&&(e.preventDefault(),a(!1),n.chain().focus().run())},t[19]=C,t[20]=n,t[21]=O):O=t[21];let k=O;if(i){let e;t[22]===r?e=t[23]:(e=r({id:`ZsGpr_`}),t[22]=r,t[23]=e);let n;t[24]===r?n=t[25]:(n=r({id:`roAe2K`}),t[24]=r,t[25]=n);let i;t[26]!==l||t[27]!==k||t[28]!==u||t[29]!==d||t[30]!==e||t[31]!==n||t[32]!==o?(i=(0,Z.jsx)(ot,{ref:c,type:`text`,placeholder:e,value:o,pages:d,folderPaths:l,loading:u,onValueChange:s,onSuggestionSelect:D,onKeyDown:k,"aria-label":n,className:`h-5 w-44 rounded-none border-none bg-transparent px-0 py-0 text-sm placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent`}),t[26]=l,t[27]=k,t[28]=u,t[29]=d,t[30]=e,t[31]=n,t[32]=o,t[33]=i):i=t[33];let a;t[34]===r?a=t[35]:(a=r({id:`tP5DDk`}),t[34]=r,t[35]=a);let f;t[36]===C?f=t[37]:(f=()=>{C()},t[36]=C,t[37]=f);let m;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(Vu,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[38]=m):m=t[38];let g;t[39]!==a||t[40]!==f?(g=(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,"aria-label":a,onClick:f,children:m}),t[39]=a,t[40]=f,t[41]=g):g=t[41];let _;t[42]!==i||t[43]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50`,children:[i,g]}),t[42]=i,t[43]=g,t[44]=_):_=t[44];let v;t[45]!==r||t[46]!==h||t[47]!==p||t[48]!==T?(v=p&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(gc,{children:[(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,"aria-label":r({id:`2vIPtm`}),onMouseDown:e=>{e.preventDefault(),on(h)},children:(0,Z.jsx)(za,{className:`size-3.5`})})}),(0,Z.jsx)(mc,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(X,{id:`2vIPtm`})})]}),(0,Z.jsxs)(gc,{children:[(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,"aria-label":r({id:`484LKL`}),onMouseDown:e=>{e.preventDefault(),T()},children:(0,Z.jsx)(vs,{className:`size-3.5`})})}),(0,Z.jsx)(mc,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(X,{id:`484LKL`})})]})]}),t[45]=r,t[46]=h,t[47]=p,t[48]=T,t[49]=v):v=t[49];let y;return t[50]!==_||t[51]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[_,v]}),t[50]=_,t[51]=v,t[52]=y):y=t[52],y}let A;t[53]===r?A=t[54]:(A=r({id:`p0Iq25`}),t[53]=r,t[54]=A);let j=p?`bg-accent text-primary`:`text-accent-foreground`,M;t[55]===_?M=t[56]:(M=e=>{e.preventDefault(),s(_()),a(!0)},t[55]=_,t[56]=M);let N;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(od,{className:`size-3.5`}),t[57]=N):N=t[57];let P;t[58]!==A||t[59]!==j||t[60]!==M?(P=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,"aria-label":A,className:j,onMouseDown:M,children:N})}),t[58]=A,t[59]=j,t[60]=M,t[61]=P):P=t[61];let F;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(X,{id:`yzF66j`}),t[62]=F):F=t[62];let I;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsxs)(mc,{side:`bottom`,sideOffset:8,children:[F,(0,Z.jsx)(Dt,{children:xl(`command-palette`)})]}),t[63]=I):I=t[63];let L;return t[64]===P?L=t[65]:(L=(0,Z.jsxs)(gc,{children:[P,I]}),t[64]=P,t[65]=L),L}function YD({editor:e}){if($e(e.state).query||e.isActive(`codeBlock`))return!1;if(WD(e)||TD(e))return!0;if(e.state.selection.empty)return!1;let{from:t,to:n}=e.state.selection;return!!e.state.doc.textBetween(t,n,` `).trim()}function XD(e){let t=(0,$.c)(23),{editor:n,shortcutEnabled:r}=e,i=r===void 0?!0:r,a=(0,Q.useRef)(null),[o,s]=(0,Q.useState)(0),c=(0,Q.useRef)(null),l;t[0]===n?l=t[1]:(l={editor:n,selector:tO},t[0]=n,t[1]=l);let u=w(l),d;t[2]===n?d=t[3]:(d={editor:n,selector:eO},t[2]=n,t[3]=d);let f=w(d),p;t[4]!==n.state||t[5]!==n.view?(p=()=>{try{let{from:e,to:t}=n.state.selection;return ci(n.view,e,t)}catch{return new DOMRect}},t[4]=n.state,t[5]=n.view,t[6]=p):p=t[6];let m;if(t[7]!==n.view.dom||t[8]!==p){let e={getBoundingClientRect:p,contextElement:n.view.dom};m=()=>{let t=a.current;t&&(c.current?.(),c.current=_c(e,t,()=>{Sc(e,t,{placement:`top`,strategy:`fixed`,middleware:[Tc(8),Dc(),Cc({padding:8})]}).then(e=>{let{x:n,y:r}=e;t.isConnected&&(t.style.position=`fixed`,t.style.left=`${n}px`,t.style.top=`${r}px`)}).catch($D)}))},t[7]=n.view.dom,t[8]=p,t[9]=m}else m=t[9];let h=m,g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{c.current?.(),c.current=null,s(QD)},t[10]=g):g=t[10];let _=g,v;t[11]===h?v=t[12]:(v={onShow:h,onHide:_,strategy:`fixed`},t[11]=h,t[12]=v);let y;t[13]!==n||t[14]!==f||t[15]!==u||t[16]!==i||t[17]!==o?(y=u?(0,Z.jsx)(HD,{editor:n},`${o}-img-align`):f?(0,Z.jsx)(CD,{editor:n},`${o}-file`):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(mD,{editor:n}),(0,Z.jsx)(sa,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(KD,{editor:n},o),(0,Z.jsx)(sa,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(JD,{editor:n},`${o}-link`),(0,Z.jsx)(kD,{editor:n},`${o}-footnote`),(0,Z.jsx)(_D,{editor:n,shortcutEnabled:i},`${o}-edit-ai`)]}),t[13]=n,t[14]=f,t[15]=u,t[16]=i,t[17]=o,t[18]=y):y=t[18];let b;return t[19]!==n||t[20]!==v||t[21]!==y?(b=(0,Z.jsx)(fD,{ref:a,editor:n,"data-testid":`bubble-menu-bar`,appendTo:ZD,shouldShow:YD,updateDelay:250,options:v,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:y}),t[19]=n,t[20]=v,t[21]=y,t[22]=b):b=t[22],b}function ZD(){return document.body}function QD(e){return e+1}function $D(){}function eO(e){return TD(e.editor)}function tO(e){return WD(e.editor)}var nO=56,rO=`0 2px 4px rgba(0, 0, 0, 0.08)`,iO=150,aO=globalThis.ScrollTimeline;function oO(e,t,n,r,i){let a=r-i;if(a<=0)return null;let o=e+n-(t+nO);return{startOffset:o,endOffset:o+a,maxShift:a}}var sO=new WeakMap;function cO(e){let t=sO.get(e);if(t){for(let e of t.animations)e.cancel();sO.delete(e)}}function lO(e){for(let t of Array.from(e.cells))cO(t)}var uO=e=>e.cellIndex===0?`3`:`2`;function dO(e,t){return fO(e,t,e=>({transform:`translateY(${e}px)`}))}function fO(e,t,n){if(!(t>0))return[{offset:0,...n(0)},{offset:1,...n(0)}];let r=t=>Math.max(0,Math.min(t-e.startOffset,e.maxShift));return Array.from(new Set([0,e.startOffset/t,e.endOffset/t,1].map(e=>Math.max(0,Math.min(e,1))))).sort((e,t)=>e-t).map(e=>({offset:e,...n(r(e*t))}))}function pO(e,t,n,r){if(!(t>0))return[{...n,offset:0},{...n,offset:1}];let i=e.startOffset/t;if(i<=0)return[{...r,offset:0},{...r,offset:1}];if(i>=1)return[{...n,offset:0},{...n,offset:1}];let a=Math.min(i+1/t,1);return[{...n,offset:0},{...n,offset:i},{...r,offset:a},{...r,offset:1}]}function mO(e,t,n){return pO(e,t,{zIndex:`auto`,boxShadow:`none`},{zIndex:n,boxShadow:rO})}function hO(e,t){return pO(e,t,{opacity:`0`},{opacity:`1`})}function gO(e,t,n,r){let i=uO(e),a=`sd|${n.startOffset}|${n.maxShift}|${r}|${i}`,o=sO.get(e);if(o?.key===a)return;if(o)for(let e of o.animations)e.cancel();let s={timeline:t,fill:`both`,easing:`linear`},c=e.animate(dO(n,r),s),l=e.animate(mO(n,r,i),s),u=e.animate(hO(n,r),{...s,pseudoElement:`::before`});sO.set(e,{key:a,animations:[c,l,u]})}function _O(e,t){let n=uO(e),r=`in|${t}|${n}`,i=sO.get(e);if(i?.key===r)return;if(i)for(let e of i.animations)e.cancel();let a=e.animate([{transform:`translateY(${t}px)`,zIndex:n,boxShadow:rO}],{duration:0,fill:`forwards`}),o=e.animate([{opacity:`1`}],{duration:0,fill:`forwards`,pseudoElement:`::before`});sO.set(e,{key:r,animations:[a,o]})}function vO(e,t,n,r){let i=e.getBoundingClientRect().top,a=e.scrollTop,o=e.scrollHeight-e.clientHeight,s=t.querySelectorAll(`.tableWrapper`);for(let e of s){r?.(e);let t=e.querySelector(`table`);if(!t)continue;let s=t.querySelector(`tbody`)?.rows[0];if(!s||!Array.from(s.cells).some(e=>e.tagName===`TH`))continue;let c=t.getBoundingClientRect(),l=s.getBoundingClientRect(),u=oO(a,i,c.top,c.height,l.height);if(!u){lO(s);continue}if(n){if(o<=0){lO(s);continue}for(let e of Array.from(s.cells))gO(e,n,u,o);continue}let d=Math.max(0,Math.min(a-u.startOffset,u.maxShift));if(d<=0||c.bottom<=i+nO){lO(s);continue}for(let e of Array.from(s.cells))_O(e,d)}}var yO=Si.create({name:`frozenTableHeaders`,addProseMirrorPlugins(){return[new ui({key:new Fr(`frozenTableHeaders`),view(e){let t=null,n=null,r=null,i=null,a=null,o=!1,s=new Set,c=()=>{o||!t||vO(t,e.dom,n,u)},l=()=>{r??=requestAnimationFrame(()=>{r=null,c()})};function u(e){s.has(e)||(s.add(e),e.addEventListener(`contentvisibilityautostatechange`,l))}let d=()=>{if(n){i??l(),i!=null&&clearTimeout(i),i=setTimeout(()=>{i=null,c()},iO);return}l()};return requestAnimationFrame(()=>{if(!o){if(t=e.dom.closest(`[data-testid="editor-scroll-container"]`),t&&aO)try{n=new aO({source:t,axis:`block`})}catch{n=null}t?.addEventListener(`scroll`,d,{passive:!0}),t&&typeof ResizeObserver<`u`&&(a=new ResizeObserver(l),a.observe(t),a.observe(e.dom)),c()}}),{update(e,t){t.doc.eq(e.state.doc)||c()},destroy(){o=!0,t?.removeEventListener(`scroll`,d),a?.disconnect(),r!=null&&cancelAnimationFrame(r),i!=null&&clearTimeout(i);for(let e of s)e.removeEventListener(`contentvisibilityautostatechange`,l);s.clear();for(let t of e.dom.querySelectorAll(`.tableWrapper > table > tbody > tr:first-child`))lO(t)}}}})]}}),bO=`application/x-open-knowledge-sidebar-item+json`,xO={image:!0,video:!0,audio:!0,pdf:!0,text:!0};function SO(e){return JSON.stringify(e)}function CO(e){return e.kind===`folder`?{target:{kind:`folder`,target:e.folderPath,folderPath:e.folderPath},hash:lo(e.folderPath)}:e.kind===`asset`?{target:{kind:`asset`,target:e.assetPath,assetPath:e.assetPath,mediaKind:e.mediaKind},hash:yo(e.assetPath)}:{target:Fo(e.docName,e.size)??{kind:`doc`,target:e.docName,docName:e.docName},hash:Ao(e.docName)}}function wO(e){if(!e||!Array.from(e.types).includes(`application/x-open-knowledge-sidebar-item+json`))return null;let t=e.getData(bO);if(!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!TO(n)||n.v!==1||typeof n.kind!=`string`)return null;if(n.kind===`doc`){if(typeof n.docName!=`string`||n.docName.length===0)return null;let e=n.size;return e!==null&&typeof e!=`number`?null:{v:1,kind:`doc`,docName:n.docName,size:e}}if(n.kind===`folder`)return typeof n.folderPath==`string`?{v:1,kind:`folder`,folderPath:n.folderPath}:null;if(n.kind===`asset`){if(typeof n.assetPath!=`string`||n.assetPath.length===0)return null;let e=n.mediaKind;return e!==null&&!EO(e)?null:{v:1,kind:`asset`,assetPath:n.assetPath,mediaKind:e}}return null}function TO(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function EO(e){return typeof e==`string`&&Object.hasOwn(xO,e)}function DO(e,t){return(n,r)=>{let i=r,a=wO(i.dataTransfer);return a?(i.preventDefault(),t?.(a),!0):e(n,i)}}function OO(e,t){let n=CO(e);t(n.target,{tabBehavior:`append`}),vo(n.hash)}function kO(e){return[...e?[{label:`Toggle header column`,icon:zu,run:e=>e.chain().focus().toggleHeaderColumn().run()}]:[],{label:`Insert column left`,icon:Mi,run:e=>e.chain().focus().addColumnBefore().run()},{label:`Insert column right`,icon:La,run:e=>e.chain().focus().addColumnAfter().run()},{label:`Delete column`,icon:vs,separatorBefore:!0,run:e=>e.chain().focus().deleteColumn().run()},{label:`Delete table`,icon:$u,run:e=>e.chain().focus().deleteTable().run()}]}function AO(e){return[...e?[{label:`Toggle header row`,icon:Rd,run:e=>e.chain().focus().toggleHeaderRow().run()}]:[],{label:`Insert row above`,icon:R,run:e=>e.chain().focus().addRowBefore().run()},{label:`Insert row below`,icon:B,run:e=>e.chain().focus().addRowAfter().run()},{label:`Delete row`,icon:vs,separatorBefore:!0,run:e=>e.chain().focus().deleteRow().run()},{label:`Delete table`,icon:$u,run:e=>e.chain().focus().deleteTable().run()}]}function jO(e){if(!e.isEditable||$e(e.state).query)return null;let{state:t,view:n}=e,r=t.selection.$from,i=-1;for(let e=r.depth;e>0;e--){let t=r.node(e).type.spec.tableRole;if(t===`cell`||t===`header_cell`){i=r.before(e);break}}if(i<0)return null;let a=n.nodeDOM(i);if(!(a instanceof HTMLTableCellElement))return null;let o=a.closest(`table`),s=a.closest(`tr`),c=a.closest(`.ProseMirror`);if(!o||!s||!c)return null;let l=Array.prototype.indexOf.call(o.rows,s),u=a.cellIndex,d=o.rows[0]?.cells[u],f=o.rows[l]?.cells[0];return!d||!f?null:{columnAnchor:d,rowAnchor:f,isFirstColumn:u===0,isFirstRow:l===0}}function MO(e){let t=(0,$.c)(22),{editor:n,anchor:r,axis:i,items:a}=e,o=(0,Q.useRef)(null),s,c;t[0]!==r||t[1]!==i?(s=()=>{let e=o.current;if(!e)return;let t=i===`column`?`top`:`left`,n=i===`column`?-14:-6;return _c(r,e,()=>{Sc(r,e,{strategy:`absolute`,placement:t,middleware:[Tc(n)]}).then(t=>{let{x:n,y:r}=t;e.style.left=`${n}px`,e.style.top=`${r}px`,e.style.opacity=`1`}).catch(NO)})},c=[r,i],t[0]=r,t[1]=i,t[2]=s,t[3]=c):(s=t[2],c=t[3]),(0,Q.useEffect)(s,c);let l=i===`column`?Uu:oa,u=i===`column`?`h-3 w-7 rounded-full p-0 text-gray-700 dark:text-muted-foreground bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 hover:text-foreground dark:hover:bg-gray-600 dark:hover:text-gray-100 relative before:absolute before:-inset-[6px] before:content-[""]`:`h-7 w-3 rounded-full p-0 text-gray-700 dark:text-muted-foreground bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 hover:text-foreground dark:hover:bg-gray-600 dark:hover:text-gray-100 relative before:absolute before:-inset-[6px] before:content-[""]`,d=i===`column`?`Column options`:`Row options`,f;t[4]===l?f=t[5]:(f=(0,Z.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),t[4]=l,t[5]=f);let p;t[6]!==u||t[7]!==d||t[8]!==f?(p=(0,Z.jsx)(qc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`secondary`,className:u,"aria-label":d,children:f})}),t[6]=u,t[7]=d,t[8]=f,t[9]=p):p=t[9];let m=i===`column`?`center`:`start`,h=i===`column`?`bottom`:`right`,g;if(t[10]!==n||t[11]!==a){let e;t[13]===n?e=t[14]:(e=e=>(0,Z.jsxs)(Q.Fragment,{children:[e.separatorBefore&&(0,Z.jsx)(cl,{}),(0,Z.jsxs)(Yc,{onSelect:()=>e.run(n),children:[(0,Z.jsx)(e.icon,{"aria-hidden":!0}),e.label]})]},e.label),t[13]=n,t[14]=e),g=a.map(e),t[10]=n,t[11]=a,t[12]=g}else g=t[12];let _;t[15]!==m||t[16]!==h||t[17]!==g?(_=(0,Z.jsx)(Zc,{align:m,side:h,className:`w-auto min-w-44 whitespace-nowrap`,children:g}),t[15]=m,t[16]=h,t[17]=g,t[18]=_):_=t[18];let v;return t[19]!==_||t[20]!==p?(v=(0,Z.jsx)(`div`,{ref:o,"data-testid":`table-cell-handle`,className:`absolute left-0 top-0 z-10 opacity-0`,children:(0,Z.jsxs)(rl,{children:[p,_]})}),t[19]=_,t[20]=p,t[21]=v):v=t[21],v}function NO(){}function PO(e){let t=(0,$.c)(18),{editor:n}=e,[r,i]=(0,Q.useState)(null),a,o;if(t[0]===n?(a=t[1],o=t[2]):(a=()=>{let e=()=>i(e=>{let t=jO(n);return e&&t&&e.columnAnchor===t.columnAnchor&&e.rowAnchor===t.rowAnchor?e:t});return e(),n.on(`selectionUpdate`,e),n.on(`update`,e),()=>{n.off(`selectionUpdate`,e),n.off(`update`,e)}},o=[n],t[0]=n,t[1]=a,t[2]=o),(0,Q.useEffect)(a,o),!r)return null;let s=r.columnAnchor,c;t[3]===r.isFirstColumn?c=t[4]:(c=kO(r.isFirstColumn),t[3]=r.isFirstColumn,t[4]=c);let l;t[5]!==r.columnAnchor||t[6]!==n||t[7]!==c?(l=(0,Z.jsx)(MO,{editor:n,anchor:s,axis:`column`,items:c}),t[5]=r.columnAnchor,t[6]=n,t[7]=c,t[8]=l):l=t[8];let u=r.rowAnchor,d;t[9]===r.isFirstRow?d=t[10]:(d=AO(r.isFirstRow),t[9]=r.isFirstRow,t[10]=d);let f;t[11]!==r.rowAnchor||t[12]!==n||t[13]!==d?(f=(0,Z.jsx)(MO,{editor:n,anchor:u,axis:`row`,items:d}),t[11]=r.rowAnchor,t[12]=n,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==l||t[16]!==f?(p=(0,Z.jsxs)(`div`,{className:`ok-table-cell-handle-layer`,children:[l,f]}),t[15]=l,t[16]=f,t[17]=p):p=t[17],p}function FO(e){let{fragment:t,docName:n}=e,r=!1,i=!1,a=!1,o=()=>{r=!0},s=e=>{console.warn(`[walk-currency] ${e} at view init — stale pre-warm cannot be invalidated: a remote edit that landed in the construct→mount gap will not render, and the first local transaction may silently erase it from the CRDT for every peer and disk (vendored y-tiptap contract change? re-verify y-tiptap.cjs:263-268)`)},c=()=>{i&&(i=!1,t.unobserveDeep(o))},l=e=>{let t=y.getState(e.state)?.binding;if(!t){Ot.count(`ok/editor/walk-currency-disarmed`,{docName:n,reason:`no-binding`}),s(`no ySync binding on "${n}"`);return}if(typeof t._forceRerender!=`function`){Ot.count(`ok/editor/walk-currency-disarmed`,{docName:n,reason:`no-force-rerender`}),s(`ySync binding on "${n}" exposes no _forceRerender`);return}Ot.count(`ok/editor/pattern-d-stale-prewarm`,{docName:n}),t._forceRerender()};return Si.create({name:`walkCurrency`,onBeforeCreate(){t.observeDeep(o),i=!0},onDestroy(){c()},addProseMirrorPlugins(){return[new ui({view:e=>(a||(a=!0,c(),r&&l(e)),{})})]}})}var IO=new WeakMap;function LO(e){let t=document.createElement(`span`);t.classList.add(`collaboration-cursor__caret`),t.style.borderColor=e.color;let n=document.createElement(`div`);return n.classList.add(`collaboration-cursor__label`),n.style.backgroundColor=e.color,n.style.color=di(e.color),n.textContent=e.name,t.append(n),t}var RO={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null},zO=100,BO=100,VO=3,HO=250;function UO(e){return`contentComponent`in e&&`isEditorContentInitialized`in e}function WO(e,t){let n=fe(e);if(!n||t.contains(n.dom))return!1;if(!UO(e))return console.warn(`[TiptapEditor] TipTap EditorContent binding fields missing; detached editor repair skipped`),!1;let r=e;if(r.contentComponent==null)return!1;try{n.setProps({nodeViews:{}})}catch{}return r.contentComponent=null,r.isEditorContentInitialized=!1,!0}function GO(){let e=new ir({extensions:mi});return{mdManager:e,text:Vt({mdManager:e}),html:Ve({mdManager:e}),paste:rt({mdManager:e}),drop:Nt({mdManager:e})}}function KO(e,t){return t?{collaboration:it.configure({document:e.document,ySyncOptions:{mapping:t}}),guard:[FO({fragment:e.document.getXmlFragment(`default`),docName:e.configuration.name??``})]}:{collaboration:it.configure({document:e.document}),guard:[]}}function qO(e){let{provider:t,placeholder:n,prebuiltMapping:r,onWedged:i}=e,{collaboration:a,guard:o}=KO(t,r);return[...Ct.map(e=>e.name===`link`||e.name===`wikiLink`||e.name===`jsxComponent`?e.configure({docName:t.configuration.name??``}):e),DS.configure({placeholder:n??`Type '/' for commands`,showOnlyCurrent:!0}),a,Si.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[Ge]}}),Si.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=t.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[re(e,{cursorBuilder:LO})]}}),Si.create({name:`bindingStalenessGuard`,addProseMirrorPlugins(){return[FE({fragment:t.document.getXmlFragment(`default`),docName:t.configuration.name??``,onWedged:i??(()=>{})})]}}),...o,yO]}function JO(e){let{provider:t,clipboard:n,ctorStart:r}=e;return{onBeforeCreate:({editor:e})=>{IO.set(e,r)},onCreate:({editor:e})=>{n.html.setView(e.view);let r=IO.get(e);if(IO.delete(e),r==null)return;let i=performance.now();Ot(`ok/editor/create-tiptap`,{docName:t.configuration.name??`unknown`,ytextLength:t.document.getText(`source`).length},{startTime:r,duration:Math.max(0,i-r)})},editorProps:{attributes:{class:`pt-4 pb-4 h-full`},clipboardTextParser:(e,t,r,i)=>{let a=n.mdManager.parse(e);return i.state.schema.nodeFromJSON(a).content},clipboardTextSerializer:(e,t)=>n.text(e,t),clipboardSerializer:n.html.serializer,handlePaste:(e,t)=>n.paste(e,t),handleDrop:DO(n.drop,e.onSidebarDrop)},extensions:kh(qO(e))}}function YO(e){let{provider:t,placeholder:n,clipboard:r,ctorStart:i,onWedged:a,onSidebarDrop:o}=e,s=t.document.getXmlFragment(`default`),c=new Map,l=JO({provider:t,placeholder:n,clipboard:r,ctorStart:i,prebuiltMapping:c,onWedged:a,onSidebarDrop:o}),u=l.onBeforeCreate;return{...l,onBeforeCreate:e=>{u?.(e);let{editor:t}=e,{doc:n,mapping:r}=Xt(s,t.schema);r.forEach((e,t)=>{c.set(t,e)}),t.options.content=n.toJSON()},element:null}}var XO=e=>{let t=(0,$.c)(24),{provider:n,placeholder:r,isSourceMode:i,portalTarget:a}=e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(RO),c=TE(),{principal:l,activeDocName:u,recycleDocument:d,openTarget:f}=_t(),p=n.configuration.name??``,[m]=(0,Q.useState)(GO),h;t[0]!==m||t[1]!==p||t[2]!==f||t[3]!==r||t[4]!==n||t[5]!==d?(h=()=>()=>({editor:new mr(YO({provider:n,placeholder:r,clipboard:m,ctorStart:performance.now(),onWedged:e=>{let{externalSeq:t,appliedSeq:n}=e;Ot(`ok/editor/binding-wedge-recycle`,{docName:p,externalSeq:t,appliedSeq:n}),d(p)},onSidebarDrop:e=>{OO(e,f)}})),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}),t[0]=m,t[1]=p,t[2]=f,t[3]=r,t[4]=n,t[5]=d,t[6]=h):h=t[6];let[g]=(0,Q.useState)(h),_,v;if(t[7]!==g||t[8]!==p||t[9]!==n.document){let e={viewCount:0,bytes:n.document.getText(`source`).length},r=de(p)??crypto.randomUUID();_=Q.use,v=ee({docName:p,mountId:r,construct:g,sizeStats:e}),t[7]=g,t[8]=p,t[9]=n.document,t[10]=_,t[11]=v}else _=t[10],v=t[11];let y=_(v),b=y.editor,x,S;t[12]===y?(x=t[13],S=t[14]):(x=()=>()=>{z(y)},S=[y],t[12]=y,t[13]=x,t[14]=S),(0,Q.useEffect)(x,S);let C;return t[15]!==u||t[16]!==p||t[17]!==b||t[18]!==c||t[19]!==i||t[20]!==a||t[21]!==l||t[22]!==n?(C=(0,Z.jsx)(ZO,{provider:n,isSourceMode:i,docName:p,activeDocName:u,identity:c,principal:l,editor:b,wrapperRef:o,flashStateRef:s,portalTarget:a}),t[15]=u,t[16]=p,t[17]=b,t[18]=c,t[19]=i,t[20]=a,t[21]=l,t[22]=n,t[23]=C):C=t[23],C},ZO=e=>{let t=(0,$.c)(98),{provider:n,isSourceMode:r,docName:i,activeDocName:a,identity:o,principal:s,editor:c,wrapperRef:l,flashStateRef:u,portalTarget:f}=e,p=(0,Q.useRef)(null),[m,h]=(0,Q.useState)(0),g,_;t[0]===f?(g=t[1],_=t[2]):(g=()=>{let e=p.current;if(e)return e.appendChild(f),()=>{f.parentNode===e&&e.removeChild(f)}},_=[f],t[0]=f,t[1]=g,t[2]=_),(0,Q.useLayoutEffect)(g,_);let v,y;t[3]!==c||t[4]!==f?(v=()=>{WO(c,f)&&h(QO)},y=[c,f],t[3]=c,t[4]=f,t[5]=v,t[6]=y):(v=t[5],y=t[6]),(0,Q.useEffect)(v,y);let b;t[7]!==c||t[8]!==n.configuration.name?(b=()=>(gt(c,n.configuration.name??null),()=>{gt(c,null)}),t[7]=c,t[8]=n.configuration.name,t[9]=b):b=t[9];let x;t[10]!==c||t[11]!==n?(x=[c,n],t[10]=c,t[11]=n,t[12]=x):x=t[12],(0,Q.useEffect)(b,x);let S;t[13]!==c||t[14]!==n.configuration.name?(S=()=>{let e=n.configuration.name;if(e)return me(e,c),()=>F(e,c)},t[13]=c,t[14]=n.configuration.name,t[15]=S):S=t[15];let C;t[16]!==c||t[17]!==n?(C=[c,n],t[16]=c,t[17]=n,t[18]=C):C=t[18],(0,Q.useEffect)(S,C);let w;t[19]!==c||t[20]!==n.configuration.name?(w=()=>{let e=n.configuration.name;if(!e)return;let t=null,r=()=>{t=null,Jl(e,`wysiwyg`,Zl(c)),su(e,`wysiwyg`,cu(c,e))},i=()=>{t&&clearTimeout(t),t=setTimeout(r,120)};return r(),c.on(`selectionUpdate`,i),c.on(`update`,i),()=>{t&&clearTimeout(t),c.off(`selectionUpdate`,i),c.off(`update`,i),Jl(e,`wysiwyg`,null),su(e,`wysiwyg`,null)}},t[19]=c,t[20]=n.configuration.name,t[21]=w):w=t[21];let T;t[22]!==c||t[23]!==n?(T=[c,n],t[22]=c,t[23]=n,t[24]=T):T=t[24],(0,Q.useEffect)(w,T);let E;t[25]!==c||t[26]!==n.configuration.name?(E=()=>{},t[25]=c,t[26]=n.configuration.name,t[27]=E):E=t[27];let D;t[28]!==c||t[29]!==n?(D=[c,n],t[28]=c,t[29]=n,t[30]=D):D=t[30],(0,Q.useEffect)(E,D);let O,k;t[31]===c?(O=t[32],k=t[33]):(O=()=>{let e=$O,t=null,n=()=>{if(t||c.isDestroyed)return;let n=fe(c);n&&(t=n.dom,t.addEventListener(`keydown`,e),t.addEventListener(`paste`,e),t.addEventListener(`drop`,e),t.addEventListener(`cut`,e))},r=()=>{t&&=(t.removeEventListener(`keydown`,e),t.removeEventListener(`paste`,e),t.removeEventListener(`drop`,e),t.removeEventListener(`cut`,e),null)};return fe(c)?n():c.on(`create`,n),()=>{c.off(`create`,n),r()}},k=[c],t[31]=c,t[32]=O,t[33]=k),(0,Q.useEffect)(O,k);let A,j;t[34]!==i||t[35]!==c?(A=()=>{let e=!1,t=()=>{if(e||c.isDestroyed||!fe(c))return;e=!0;let t=V(i)?.selection??null;if(t)try{let e=c.state.doc.content.size;if(t.type===`text`){let n=Math.max(0,Math.min(t.anchor,e)),r=Math.max(0,Math.min(t.head,e));c.commands.setTextSelection({from:n,to:r})}else{let n=Math.max(0,Math.min(t.from,e));c.commands.setNodeSelection(n)}}catch(e){let t=e,n=t instanceof Error?t.message:String(t);console.warn(JSON.stringify({event:`ok-editor-selection-restore-failed`,docName:i,message:n})),Ot(`ok/editor/selection-restore-failed`,{docName:i,message:n})}ct(i)};if(fe(c)){t();return}return c.on(`create`,t),()=>{c.off(`create`,t)}},j=[c,i],t[34]=i,t[35]=c,t[36]=A,t[37]=j):(A=t[36],j=t[37]),(0,Q.useEffect)(A,j);let M,N;t[38]!==u||t[39]!==n.document||t[40]!==l?(M=()=>{let e=n.document.getMap(`agent-flash`),t=Date.now(),r=0,i=null,a=null,o=null,s=()=>{let t=null;for(let[,n]of e.entries()){let e=n;e.timestamp&&(!t||e.timestamp>t.timestamp)&&(t={agentId:e.agentId??`unknown`,timestamp:e.timestamp,type:e.type??`insert`,description:e.description})}return t},c=e=>{u.current=e;let t=l.current;t&&(t.setAttribute(`data-agent-flash-state`,e.state),t.setAttribute(`data-agent-flash-count`,String(e.count)),t.setAttribute(`data-agent-flash-position`,e.position),t.setAttribute(`data-agent-flash-agent-id`,e.lastAgentId??``))},d=()=>{let e=s(),t=e?.description?.toLowerCase().includes(`prepend`)?`prepend`:`append`,n={state:`editing`,count:(u.current?.count??0)+1,lastFiredAt:Date.now(),position:t,lastAgentId:e?.agentId??null};c(n),document.dispatchEvent(new CustomEvent(`agent-flash`,{detail:n})),a&&clearTimeout(a),o&&clearTimeout(o),a=window.setTimeout(()=>{let e={...n,state:`settled`};c(e),document.dispatchEvent(new CustomEvent(`agent-flash-end`,{detail:e})),o=window.setTimeout(()=>{c({...e,state:`idle`})},300)},Vn)};c(RO);let f=()=>{if(zr(e),!gi(e,t)||document.visibilityState!==`visible`)return;let n=Date.now();if(t=n,n-r<500){if(!i){let e=500-(n-r);i=window.setTimeout(()=>{i=null,r=Date.now(),d()},e)}return}r=n,d()};e.observe(f);let p=()=>{document.visibilityState===`visible`?gi(e,t)&&(t=Date.now(),r=Date.now(),d()):t=Date.now()};return document.addEventListener(`visibilitychange`,p),()=>{e.unobserve(f),document.removeEventListener(`visibilitychange`,p),i&&clearTimeout(i),a&&clearTimeout(a),o&&clearTimeout(o)}},N=[n.document,u,l],t[38]=u,t[39]=n.document,t[40]=l,t[41]=M,t[42]=N):(M=t[41],N=t[42]),(0,Q.useEffect)(M,N);let P,I;t[43]!==a||t[44]!==i||t[45]!==c||t[46]!==n?(P=()=>{let e=0,t,r=null,o=null,s=null,l=function(){if(e<zO){e+=1,t=window.setTimeout(p,BO);return}r=null,o=null,e=0},u=function(e){let t=fe(c);if(!t)return null;let n=CSS.escape(e);return t.dom.querySelector(`#${n}`)??t.dom.querySelector(`[data-mirror-source-id="${n}"]`)},d=function(e){let t=u(e);return t?(t.scrollIntoView({behavior:`smooth`,block:`start`}),!0):!1},f=function(e,n){let r=VO,o=()=>{t=void 0,!(i!==a||window.location.hash!==n)&&(d(e),--r,r>0&&(t=window.setTimeout(o,HO)))};t=window.setTimeout(o,HO)};function p(){if(!r||i!==a)return;let t=r,n=o;if(!n){l();return}d(t)?(s=n,r=null,o=null,e=0,f(t,n)):l()}let m=function(){if(i!==a)return;let n=window.location.hash;if(!r&&s===n)return;let c=uo(n);if(!c){s=n;return}r=c,o=n,e=0,t!==void 0&&(clearTimeout(t),t=void 0),p()},h=function(){if(i===a){if(r){p();return}m()}};return m(),n.on(`synced`,h),c.on(`transaction`,h),window.addEventListener(`hashchange`,m),()=>{t!==void 0&&clearTimeout(t),n.off(`synced`,h),c.off(`transaction`,h),window.removeEventListener(`hashchange`,m)}},I=[n,c,i,a],t[43]=a,t[44]=i,t[45]=c,t[46]=n,t[47]=P,t[48]=I):(P=t[47],I=t[48]),(0,Q.useEffect)(P,I);let L,R;t[49]===c?(L=t[50],R=t[51]):(L=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||c.isDestroyed)return;let n=fe(c);if(!n)return;let r=n.dom.querySelectorAll(`h1, h2, h3, h4, h5, h6`)[t.index];r&&r.scrollIntoView({behavior:`smooth`,block:`start`})};return window.addEventListener(Kl,e),()=>window.removeEventListener(Kl,e)},R=[c],t[49]=c,t[50]=L,t[51]=R),(0,Q.useEffect)(L,R);let z;t[52]!==a||t[53]!==i||t[54]!==o||t[55]!==r||t[56]!==s||t[57]!==n.awareness?(z=()=>{let e=n.awareness;if(e){if(i!==a){e.setLocalState(null);return}e.setLocalState({user:EE({principal:s,identity:o}),mode:r?`source`:`wysiwyg`})}},t[52]=a,t[53]=i,t[54]=o,t[55]=r,t[56]=s,t[57]=n.awareness,t[58]=z):z=t[58];let B;t[59]!==a||t[60]!==i||t[61]!==o||t[62]!==r||t[63]!==s||t[64]!==n?(B=[n,i,a,o,s,r],t[59]=a,t[60]=i,t[61]=o,t[62]=r,t[63]=s,t[64]=n,t[65]=B):B=t[65],(0,Q.useEffect)(z,B);let H,U;t[66]!==c||t[67]!==r?(H=()=>(Qt(c,r),()=>{Qt(c,!1)}),U=[c,r],t[66]=c,t[67]=r,t[68]=H,t[69]=U):(H=t[68],U=t[69]),(0,Q.useEffect)(H,U);let W;t[70]!==a||t[71]!==i||t[72]!==c||t[73]!==r?(W=!r&&(0,Z.jsx)(XD,{editor:c,shortcutEnabled:i===a}),t[70]=a,t[71]=i,t[72]=c,t[73]=r,t[74]=W):W=t[74];let G;t[75]!==c||t[76]!==r?(G=!r&&(0,Z.jsx)(PO,{editor:c}),t[75]=c,t[76]=r,t[77]=G):G=t[77];let K;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Z.jsx)(`div`,{ref:p,style:{display:`contents`}}),t[78]=K):K=t[78];let q;t[79]!==c||t[80]!==m?(q=(0,Z.jsx)(d,{editor:c,className:`tiptap-editor-portal-content h-full`},m),t[79]=c,t[80]=m,t[81]=q):q=t[81];let J;t[82]!==f||t[83]!==q?(J=(0,Au.createPortal)(q,f),t[82]=f,t[83]=q,t[84]=J):J=t[84];let Y;t[85]===c?Y=t[86]:(Y=(0,Z.jsx)(CE,{editor:c}),t[85]=c,t[86]=Y);let ee;t[87]===c?ee=t[88]:(ee=Gt(c),t[87]=c,t[88]=ee);let te;t[89]===ee.store?te=t[90]:(te=(0,Z.jsx)(Re,{store:ee.store}),t[89]=ee.store,t[90]=te);let ne;return t[91]!==W||t[92]!==G||t[93]!==J||t[94]!==Y||t[95]!==te||t[96]!==l?(ne=(0,Z.jsxs)(`div`,{ref:l,className:`tiptap-editor h-full`,"data-agent-flash-state":`idle`,"data-agent-flash-count":`0`,"data-agent-flash-position":`append`,"data-agent-flash-agent-id":``,children:[W,G,K,J,Y,te]}),t[91]=W,t[92]=G,t[93]=J,t[94]=Y,t[95]=te,t[96]=l,t[97]=ne):ne=t[97],ne};function QO(e){return e+1}function $O(){return C()}var ek=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(t,n=t){return new e(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}};function tk(e,t,n,r,i,a){if(e==r)return[];let o=dk(e,t,n,r,i,a),s=fk(e,t+o,n,r,i+o,a);t+=o,n-=s,i+=o,a-=s;let c=n-t,l=a-i;if(!c||!l)return[new ek(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new ek(t,t+o,i,i),new ek(t+o+l,n,a,a)]}else if(l>c){let o=r.slice(i,a).indexOf(e.slice(t,n));if(o>-1)return[new ek(t,t,i,i+o),new ek(n,n,i+o+c,a)]}if(c==1||l==1)return[new ek(t,n,i,a)];let u=mk(e,t,n,r,i,a);if(u){let[o,s,c]=u;return tk(e,t,o,r,i,s).concat(tk(e,o+c,n,r,s+c,a))}return ak(e,t,n,r,i,a)}var nk=1e9,rk=0,ik=!1;function ak(e,t,n,r,i,a){let o=n-t,s=a-i;if(nk<1e9&&Math.min(o,s)>nk*16||rk>0&&Date.now()>rk)return Math.min(o,s)>nk*64?[new ek(t,n,i,a)]:hk(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);sk.reset(c),ck.reset(c);let l=(n,a)=>e.charCodeAt(t+n)==r.charCodeAt(i+a),u=(t,i)=>e.charCodeAt(n-t-1)==r.charCodeAt(a-i-1),d=(o-s)%2==0?null:ck,f=d?null:sk;for(let p=0;p<c;p++){if(p>nk||rk>0&&!(p&63)&&Date.now()>rk)return hk(e,t,n,r,i,a);let m=sk.advance(p,o,s,c,d,!1,l)||ck.advance(p,o,s,c,f,!0,u);if(m)return lk(e,t,n,t+m[0],r,i,a,i+m[1])}return[new ek(t,n,i,a)]}var ok=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let e=0;e<this.len;e++)this.vec[e]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,r,i,a,o){for(let s=-e+this.start;s<=e-this.end;s+=2){let c=r+s,l=s==-e||s!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,u=l-s;for(;l<t&&u<n&&o(l,u);)l++,u++;if(this.vec[c]=l,l>t)this.end+=2;else if(u>n)this.start+=2;else if(i){let e=r+(t-n)-s;if(e>=0&&e<this.len&&i.vec[e]!=-1)if(a){let n=i.vec[e];if(n>=t-l)return[n,r+n-e]}else{let n=t-i.vec[e];if(l>=n)return[l,u]}}}return null}},sk=new ok,ck=new ok;function lk(e,t,n,r,i,a,o,s){let c=!1;return!Ak(e,r)&&++r==n&&(c=!0),!Ak(i,s)&&++s==o&&(c=!0),c?[new ek(t,n,a,o)]:tk(e,t,r,i,a,s).concat(tk(e,r,n,i,s,o))}function uk(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function dk(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=uk(n-t,a-i);for(let s=t,c=i;;){let i=s+o,l=c+o;if(i>n||l>a||e.slice(s,i)!=r.slice(c,l)){if(o==1)return s-t-+!Ak(e,s);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function fk(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=uk(n-t,a-i);for(let s=n,c=a;;){let a=s-o,l=c-o;if(a<t||l<i||e.slice(a,s)!=r.slice(l,c)){if(o==1)return n-s-+!Ak(e,s);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function pk(e,t,n,r,i,a,o,s){let c=r.slice(i,a),l=null;for(;;){if(l||o<s)return l;for(let s=t+o;;){Ak(e,s)||s++;let u=s+o;if(Ak(e,u)||(u+=u==s+1?1:-1),u>=n)break;let d=e.slice(s,u),f=-1;for(;(f=c.indexOf(d,f+1))!=-1;){let o=dk(e,u,n,r,i+f+d.length,a),c=fk(e,t,s,r,i,i+f),p=d.length+o+c;(!l||l[2]<p)&&(l=[s-c,i+f-c,p])}s=u}if(s<0)return l;o>>=1}}function mk(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=mk(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:pk(e,t,n,r,i,a,Math.floor(o/4),-1)}function hk(e,t,n,r,i,a){ik=!0;let o=n-t,s=a-i,c;if(o<s){let s=pk(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=pk(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new ek(t,n,i,a)];let[l,u,d]=c;return tk(e,t,l,r,i,u).concat(tk(e,l+d,n,r,u+d,a))}function gk(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];r.toA>i.fromA-t&&r.toB>i.fromB-t&&(e[n-1]=new ek(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function _k(e,t,n){for(;;){gk(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=dk(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new ek(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=fk(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new ek(a.fromA,a.toA-s,a.fromB,a.toB-s));let c=a.toA-a.fromA,l=a.toB-a.fromB;if(c&&l)continue;let u=a.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:e.length)-a.toA;if(!u||!d)continue;let f=c?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);u<=f.length&&e.slice(a.fromA-u,a.fromA)==f.slice(f.length-u)?(n[i]=new ek(a.fromA-u,a.toA-u,a.fromB-u,a.toB-u),r=!0):d<=f.length&&e.slice(a.toA,a.toA+d)==f.slice(0,d)&&(n[i]=new ek(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function vk(e,t,n){for(let r=0,i=0;i<e.length;i++){let a=e[i],o=a.toA-a.fromA,s=a.toB-a.fromB;if(o&&s||o>3||s>3){let c=i==e.length-1?t.length:e[i+1].fromA,l=a.fromA-r,u=c-a.toA,d=Tk(t,a.fromA,l),f=wk(t,a.toA,u),p=a.fromA-d,m=f-a.toA;if((!o||!s)&&p&&m){let l=Math.max(o,s),[u,h,g]=o?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];l>p&&t.slice(d,a.fromA)==u.slice(g-p,g)?(a=e[i]=new ek(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=wk(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new ek(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=Tk(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new ek(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=Dk(n,a.fromB,a.toB),r,o=t<0?-1:Ek(n,a.toB,a.fromB);t>-1&&(r=t-a.fromB)<=u&&n.slice(a.fromB,t)==n.slice(a.toB,a.toB+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toB-o)<=l&&n.slice(a.fromB-r,a.fromB)==n.slice(o,a.toB)&&(a=e[i]=a.offset(-r))}else if(!s){let n=Dk(t,a.fromA,a.toA),r,o=n<0?-1:Ek(t,a.toA,a.fromA);n>-1&&(r=n-a.fromA)<=u&&t.slice(a.fromA,n)==t.slice(a.toA,a.toA+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toA-o)<=l&&t.slice(a.fromA-r,a.fromA)==t.slice(o,a.toA)&&(a=e[i]=a.offset(-r))}}r=a.toA}return gk(e,3),e}var yk;try{yk=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function bk(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function xk(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?+!!bk(n):yk?!Ok(n)||t==e.length-1?+!!yk.test(String.fromCharCode(n)):yk.test(e.slice(t,t+2))?2:0:0}function Sk(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?+!!bk(n):yk?!kk(n)||t==1?+!!yk.test(String.fromCharCode(n)):yk.test(e.slice(t-2,t))?2:0:0}var Ck=8;function wk(e,t,n){if(t==e.length||!Sk(e,t))return t;for(let r=t,i=t+n,a=0;a<Ck;a++){let t=xk(e,r);if(!t||r+t>i)return r;r+=t}return t}function Tk(e,t,n){if(!t||!xk(e,t))return t;for(let r=t,i=t-n,a=0;a<Ck;a++){let t=Sk(e,r);if(!t||r-t<i)return r;r-=t}return t}function Ek(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function Dk(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var Ok=e=>e>=55296&&e<=56319,kk=e=>e>=56320&&e<=57343;function Ak(e,t){return!t||t==e.length||!Ok(e.charCodeAt(t-1))||!kk(e.charCodeAt(t))}function jk(e,t,n){let r=n?.override;return r?r(e,t):(nk=(n?.scanLimit??1e9)>>1,rk=n?.timeout?Date.now()+n.timeout:0,ik=!1,_k(e,t,tk(e,0,e.length,t,0,t.length)))}function Mk(){return!ik}function Nk(e,t,n){return vk(jk(e,t,n),e,t)}var Pk=Nl.define({combine:e=>e[0]}),Fk=Pl.define(),Ik=Nl.define(),Lk=Ol.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(Fk)&&(e=n.value);for(let n of t.state.facet(Ik))e=n(e,t);return e}});function Rk(e){let t=e.field(Lk,!1);if(!t)return null;let n=e.facet(Pk);return{chunks:t,side:n?n.side:null}}var zk=class e{constructor(e,t,n,r,i,a=!0){this.changes=e,this.fromA=t,this.toA=n,this.fromB=r,this.toB=i,this.precise=a}offset(t,n){return t||n?new e(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return Hk(Nk(e.toString(),t.toString(),n),e,t,0,0,Mk())}static updateA(e,t,n,r,i){return Kk(Gk(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return Kk(Gk(e,r,!1,t.length),e,t,n,i)}};function Bk(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.to==e&&a.to==t&&e<n.length&&t<r.length?[e+1,t+1]:[i.from,a.from]}function Vk(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.from==e&&a.from==t?[e,t]:[i.to+1,a.to+1]}function Hk(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=Bk(c.fromA+r,c.fromB+i,t,n),[d,f]=Vk(c.toA+r,c.toB+i,t,n),p=[c.offset(-l+r,-u+i)];for(;s<e.length-1;){let a=e[s+1],[o,c]=Bk(a.fromA+r,a.fromB+i,t,n);if(o>d+1&&c>f+1)break;p.push(a.offset(-l+r,-u+i)),[d,f]=Vk(a.toA+r,a.toB+i,t,n),s++}o.push(new zk(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var Uk=1e3;function Wk(e,t,n,r){let i=0,a=e.length;for(;;){if(i==a){let r=0,a=0;i&&({toA:r,toB:a}=e[i-1]);let o=t-(n?r:a);return[r+o,a+o]}let o=i+a>>1,s=e[o],[c,l]=n?[s.fromA,s.toA]:[s.fromB,s.toB];if(c>t)a=o;else if(l<=t)i=o+1;else return r?[s.fromA,s.fromB]:[s.toA,s.toB]}}function Gk(e,t,n,r){let i=[];return t.iterChangedRanges((a,o,s,c)=>{let l=0,u=n?t.length:r,d=0,f=n?r:t.length;a>Uk&&([l,d]=Wk(e,a-Uk,n,!0)),o<t.length-Uk&&([u,f]=Wk(e,o+Uk,n,!1));let p=c-s-(o-a),m,[h,g]=n?[p,0]:[0,p];i.length&&(m=i[i.length-1]).toA>=l?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:u,toB:f,diffA:m.diffA+h,diffB:m.diffB+g}:i.push({fromA:l,toA:u,fromB:d,toB:f,diffA:h,diffB:g})}),i}function Kk(e,t,n,r,i){if(!e.length)return t;let a=[];for(let o=0,s=0,c=0,l=0;;o++){let u=o==e.length?null:e[o],d=u?u.fromA+s:n.length,f=u?u.fromB+c:r.length;for(;l<t.length;){let e=t[l];if(u&&(e.toA+s>d||e.toB+c>f))break;a.push(e.offset(s,c)),l++}if(!u)break;let p=u.toA+s+u.diffA,m=u.toB+c+u.diffB,h=Nk(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of Hk(h,n,r,d,f,Mk()))a.push(e);for(s+=u.diffA,c+=u.diffB;l<t.length;){let e=t[l];if(e.fromA+s>p&&e.fromB+c>m)break;l++}}return a}var qk={scanLimit:500},Jk=Fl.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=iA(e))}update(e){(e.docChanged||e.viewportChanged||Xk(e.startState,e.state)||Zk(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=iA(e.view))}},{decorations:e=>e.deco}),Yk=Tl.low(zl({class:`cm-changeGutter`,markers:e=>e.plugin(Jk)?.gutter||Vl.empty}));function Xk(e,t){return e.field(Lk,!1)!=t.field(Lk,!1)}function Zk(e,t){return e.facet(Pk)!=t.facet(Pk)}var Qk=jl.line({class:`cm-changedLine`}),$k=jl.mark({class:`cm-changedText`}),eA=jl.mark({tagName:`ins`,class:`cm-insertedLine`}),tA=jl.mark({tagName:`del`,class:`cm-deletedLine`}),nA=new class extends Rl{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function rA(e,t,n,r,i,a){let o=n?e.fromA:e.fromB,s=n?e.toA:e.toB,c=0;if(o!=s){i.add(o,o,Qk),i.add(o,s,n?tA:eA),a&&a.add(o,o,nA);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,Qk),a&&a.add(u,u,nA);continue}let t=u+l.value.length;if(r)for(;c<e.changes.length;){let r=e.changes[c],a=o+(n?r.fromA:r.fromB),s=o+(n?r.toA:r.toB),l=Math.max(u,a),d=Math.min(t,s);if(l<d&&i.add(l,d,$k),s<t)c++;else break}u=t}}}function iA(e){let t=e.state.field(Lk),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(Pk),o=n==`a`,s=new Ml,c=i?new Ml:null,{from:l,to:u}=e.viewport;for(let n of t){if((o?n.fromA:n.fromB)>=u)break;(o?n.toA:n.toB)>l&&(!a||!a(e.state,n,s,c))&&rA(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var aA=class extends wl{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement(`div`);return e.className=`cm-mergeSpacer`,e.style.height=this.height+`px`,e}updateDOM(e){return e.style.height=this.height+`px`,!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},oA=Pl.define({map:(e,t)=>e.map(t)}),sA=Ol.define({create:()=>jl.none,update:(e,t)=>{for(let e of t.effects)if(e.is(oA))return e.value;return e.map(t.changes)},provide:e=>Ll.decorations.from(e)}),cA=.01;function lA(e,t){if(e.size!=t.size)return!1;let n=e.iter(),r=t.iter();for(;n.value;){if(n.from!=r.from||Math.abs(n.value.spec.widget.height-r.value.spec.widget.height)>1)return!1;n.next(),r.next()}return!0}function uA(e,t,n){let r=new Ml,i=new Ml,a=e.state.field(sA).iter(),o=t.state.field(sA).iter(),s=0,c=0,l=0,u=0,d=e.viewport,f=t.viewport;for(let p=0;;p++){let m=p<n.length?n[p]:null,h=m?m.fromA:e.state.doc.length,g=m?m.fromB:t.state.doc.length;if(s<h){let n=e.lineBlockAt(s).top+l-(t.lineBlockAt(c).top+u);n<-cA?(l-=n,r.add(s,s,jl.widget({widget:new aA(-n),block:!0,side:-1}))):n>cA&&(u+=n,i.add(c,c,jl.widget({widget:new aA(n),block:!0,side:-1})))}if(h>s+1e3&&s<d.from&&h>d.from&&c<f.from&&g>f.from){let e=Math.min(d.from-s,f.from-c);s+=e,c+=e,p--}else if(m)s=m.toA,c=m.toB;else break;for(;a.value&&a.from<s;)l-=a.value.spec.widget.height,a.next();for(;o.value&&o.from<c;)u-=o.value.spec.widget.height,o.next()}for(;a.value;)l-=a.value.spec.widget.height,a.next();for(;o.value;)u-=o.value.spec.widget.height,o.next();let p=e.contentHeight+l-(t.contentHeight+u);p<cA?r.add(e.state.doc.length,e.state.doc.length,jl.widget({widget:new aA(-p),block:!0,side:1})):p>cA&&i.add(t.state.doc.length,t.state.doc.length,jl.widget({widget:new aA(p),block:!0,side:1}));let m=r.finish(),h=i.finish();lA(m,e.state.field(sA))||e.dispatch({effects:oA.of(m)}),lA(h,t.state.field(sA))||t.dispatch({effects:oA.of(h)})}var dA=Pl.define({map:(e,t)=>t.mapPos(e)}),fA=class extends wl{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement(`div`);return t.className=`cm-collapsedLines`,t.textContent=e.state.phrase(`$ unchanged lines`,this.lines),t.addEventListener(`click`,t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:dA.of(n)});let{side:r,sibling:i}=e.state.facet(Pk);i&&i().dispatch({effects:dA.of(pA(n,e.state.field(Lk),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function pA(e,t,n){let r=0,i=0;for(let a=0;;a++){let o=a<t.length?t[a]:null;if(!o||(n?o.fromA:o.fromB)>=e)return i+(e-r);[r,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}var mA=Ol.define({create(e){return jl.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(dA)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>Ll.decorations.from(e)});function hA({margin:e=3,minSize:t=4}){return mA.init(n=>gA(n,e,t))}function gA(e,t,n){let r=new Ml,i=e.facet(Pk).side==`a`,a=e.field(Lk),o=1;for(let s=0;;s++){let c=s<a.length?a[s]:null,l=s?o+t:1,u=c?e.doc.lineAt(i?c.fromA:c.fromB).number-1-t:e.doc.lines,d=u-l+1;if(d>=n&&r.add(e.doc.line(l).from,e.doc.line(u).to,jl.replace({widget:new fA(d),block:!0})),!c)break;o=e.doc.lineAt(Math.min(e.doc.length,i?c.toA:c.toB)).number}return r.finish()}var _A=Ll.styleModule.of(new Bl({".cm-mergeView":{overflowY:`auto`},".cm-mergeViewEditors":{display:`flex`,alignItems:`stretch`},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:`hidden`},".cm-merge-revert":{width:`1.6em`,flexGrow:0,flexShrink:0,position:`relative`},".cm-merge-revert button":{position:`absolute`,display:`block`,width:`100%`,boxSizing:`border-box`,textAlign:`center`,background:`none`,border:`none`,font:`inherit`,cursor:`pointer`}})),vA=Ll.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:`auto !important`,overflowY:`visible !important`},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:`rgba(160, 128, 100, .08)`},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:`rgba(100, 160, 128, .08)`},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat`},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat`},"&light.cm-merge-b .cm-changedText":{background:`linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat`},"&dark.cm-merge-b .cm-changedText":{background:`linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat`},"&.cm-merge-b .cm-deletedText":{background:`#ff000033`},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:`none`},".cm-deletedChunk":{paddingLeft:`6px`,"& .cm-chunkButtons":{position:`absolute`,insetInlineEnd:`5px`},"& button":{border:`none`,cursor:`pointer`,color:`white`,margin:`0 2px`,borderRadius:`3px`,"&[name=accept]":{background:`#2a2`},"&[name=reject]":{background:`#d43`}}},".cm-collapsedLines":{padding:`5px 5px 5px 10px`,cursor:`pointer`,"&:before":{content:`"⦚"`,marginInlineEnd:`7px`},"&:after":{content:`"⦚"`,marginInlineStart:`7px`}},"&light .cm-collapsedLines":{color:`#444`,background:`linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)`},"&dark .cm-collapsedLines":{color:`#ddd`,background:`linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)`},".cm-changeGutter":{width:`3px`,paddingLeft:`1px`},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:`#e43`},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:`#fa9`},"&light.cm-merge-b .cm-changedLineGutter":{background:`#2b2`},"&dark.cm-merge-b .cm-changedLineGutter":{background:`#8f8`},".cm-inlineChangedLineGutter":{background:`#75d`}}),yA=new Il,bA=new Il,xA=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||qk;let t=[Tl.low(Jk),vA,_A,sA,Ll.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(oA)))&&this.measure()})],n=[Pk.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(Yk);let r=Dl.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],Ll.editorAttributes.of({class:`cm-merge-a`}),bA.of(n),t]}),i=[Pk.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(Yk);let a=Dl.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],Ll.editorAttributes.of({class:`cm-merge-b`}),bA.of(i),t]});this.chunks=zk.build(r.doc,a.doc,this.diffConf);let o=[Lk.init(()=>this.chunks),yA.of(e.collapseUnchanged?hA(e.collapseUnchanged):[])];r=r.update({effects:Pl.appendConfig.of(o)}).state,a=a.update({effects:Pl.appendConfig.of(o)}).state,this.dom=document.createElement(`div`),this.dom.className=`cm-mergeView`,this.editorDOM=this.dom.appendChild(document.createElement(`div`)),this.editorDOM.className=`cm-mergeViewEditors`;let s=e.orientation||`a-b`,c=document.createElement(`div`);c.className=`cm-mergeViewEditor`;let l=document.createElement(`div`);l.className=`cm-mergeViewEditor`,this.editorDOM.appendChild(s==`a-b`?c:l),this.editorDOM.appendChild(s==`a-b`?l:c),this.a=new Ll({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new Ll({state:a,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls==`b-to-a`,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(e=>e.docChanged)){let n=e[e.length-1],r=e.reduce((e,t)=>e.compose(t.changes),El.empty(e[0].startState.doc.length));this.chunks=t==this.a?zk.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):zk.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:Fk.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:Fk.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if(`diffConfig`in e&&(this.diffConf=e.diffConfig),`orientation`in e){let t=e.orientation!=`b-a`;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent=``)}}if(`revertControls`in e||`renderRevertControl`in e){let t=!!this.revertDOM,n=this.revertToA,r=this.renderRevert;`revertControls`in e&&(t=!!e.revertControls,n=e.revertControls==`b-to-a`),`renderRevertControl`in e&&(r=e.renderRevertControl),this.setupRevertControls(t,n,r)}let t=`highlightChanges`in e,n=`gutter`in e,r=`collapseUnchanged`in e;if(t||n||r){let i=[],a=[];if(t||n){let r=this.a.state.facet(Pk),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(bA.reconfigure([Pk.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?Yk:[]])),a.push(bA.reconfigure([Pk.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?Yk:[]]))}if(r){let t=yA.reconfigure(e.collapseUnchanged?hA(e.collapseUnchanged):[]);i.push(t),a.push(t)}this.a.dispatch({effects:i}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement(`div`),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener(`mousedown`,e=>this.revertClicked(e)),this.revertDOM.className=`cm-merge-revert`):this.revertDOM&&(this.revertDOM.textContent=``)}scheduleMeasure(){this.measuring<0&&(this.measuring=(this.dom.ownerDocument.defaultView||window).requestAnimationFrame(()=>{this.measuring=-1,this.measure()}))}measure(){uA(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,r=this.b.viewport;for(let i=0;i<this.chunks.length;i++){let a=this.chunks[i];if(a.fromA>n.to||a.fromB>r.to)break;if(a.fromA<n.from||a.fromB<r.from)continue;let o=this.a.lineBlockAt(a.fromA).top+`px`;for(;t&&+t.dataset.chunk<i;)t=SA(t);t&&t.dataset.chunk==String(i)?(t.style.top!=o&&(t.style.top=o),t=t.nextSibling):e.insertBefore(this.renderRevertButton(o,i),t)}for(;t;)t=SA(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement(`button`);let e=this.a.state.phrase(`Revert this chunk`);n.setAttribute(`aria-label`,e),n.setAttribute(`title`,e),n.textContent=this.revertToLeft?`⇜`:`⇝`}return n.style.top=e,n.setAttribute(`data-chunk`,String(t)),n}revertClicked(e){let t=e.target,n;for(;t&&t.parentNode!=this.revertDOM;)t=t.parentNode;if(t&&(n=this.chunks[t.dataset.chunk])){let[t,r,i,a,o,s]=this.revertToA?[this.b,this.a,n.fromB,n.toB,n.fromA,n.toA]:[this.a,this.b,n.fromA,n.toA,n.fromB,n.toB],c=t.state.sliceDoc(i,Math.max(i,a-1));i!=a&&s<=r.state.doc.length&&(c+=t.state.lineBreak),r.dispatch({changes:{from:o,to:Math.min(r.state.doc.length,s),insert:c},userEvent:`revert`}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}};function SA(e){let t=e.nextSibling;return e.remove(),t}var CA=new class extends Rl{constructor(){super(...arguments),this.elementClass=`cm-deletedLineGutter`}},wA=Tl.low(zl({class:`cm-changeGutter`,markers:e=>e.plugin(Jk)?.gutter||Vl.empty,widgetMarker:(e,t)=>t instanceof kA?CA:null}));function TA(e){let t=typeof e.original==`string`?Al.of(e.original.split(/\r?\n/)):e.original,n=e.diffConfig||qk;return[Tl.low(Jk),PA,vA,Ll.editorAttributes.of({class:`cm-merge-b`}),Ik.of((e,t)=>{let r=t.effects.find(e=>e.is(EA));return r&&(e=zk.updateA(e,r.value.doc,t.startState.doc,r.value.changes,n)),t.docChanged&&(e=zk.updateB(e,t.state.field(DA),t.newDoc,t.changes,n)),e}),Pk.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:e.mergeControls??!0,overrideChunk:e.allowInlineDiffs?BA:void 0,side:`b`}),DA.init(()=>t),e.gutter===!1?[]:wA,e.collapseUnchanged?hA(e.collapseUnchanged):[],Lk.init(e=>zk.build(t,e.doc,n))]}var EA=Pl.define(),DA=Ol.define({create:()=>Al.empty,update(e,t){for(let n of t.effects)n.is(EA)&&(e=n.value.doc);return e}}),OA=new WeakMap,kA=class extends wl{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||=this.buildDOM(e)}};function AA(e,t,n){let r=OA.get(t.changes);if(r)return r;let i=jl.widget({block:!0,side:-1,widget:new kA(r=>{let{highlightChanges:i,syntaxHighlightDeletions:a,syntaxHighlightDeletionsMaxLength:o,mergeControls:s}=e.facet(Pk),c=document.createElement(`div`);if(c.className=`cm-deletedChunk`,s){let t=c.appendChild(document.createElement(`div`));t.className=`cm-chunkButtons`;let n=e=>{e.preventDefault(),jA(r,r.posAtDOM(c))},i=e=>{e.preventDefault(),MA(r,r.posAtDOM(c))};if(typeof s==`function`)t.appendChild(s(`accept`,n)),t.appendChild(s(`reject`,i));else{let r=t.appendChild(document.createElement(`button`));r.name=`accept`,r.textContent=e.phrase(`Accept`),r.onmousedown=n;let a=t.appendChild(document.createElement(`button`));a.name=`reject`,a.textContent=e.phrase(`Reject`),a.onmousedown=i}}if(n||t.fromA>=t.toA)return c;let l=r.state.field(DA).sliceString(t.fromA,t.endA),u=a&&e.facet(Hl),d=h(),f=t.changes,p=0,m=!1;function h(){let e=c.appendChild(document.createElement(`div`));return e.className=`cm-deletedLine`,e.appendChild(document.createElement(`del`))}function g(e,t,n){for(let r=e;r<t;){if(l.charAt(r)==`
|
|
29
|
+
`)?null:i}function _T(e){let t=$e(e.state);return{current:t.matches.length===0?0:t.activeIndex+1,total:t.matches.length}}function vT(e,t){return e.current===t.current&&e.total===t.total}function yT(e,t,n){e&&!e.isDestroyed&&(e.commands.clearFindMatches(),e.commands.focus()),t(e=>({...e,open:!1,activeIndex:0})),n(dT)}function bT(e){!e||e.isDestroyed||typeof window>`u`||window.requestAnimationFrame(()=>{if(e.isDestroyed)return;let t=fe(e);if(!t)return;let n=t.dom.querySelector(`.ok-find-match-active`);n instanceof HTMLElement&&n.scrollIntoView({block:`center`,inline:`nearest`,behavior:`auto`})})}function xT(e){let t=(0,$.c)(81),{activeDocName:n,isSourceMode:r}=e,i=mT(n),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useRef)(n),c=(0,Q.useRef)(0),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={open:!1,replaceOpen:!1,query:``,replacement:``,caseSensitive:!1,wholeWord:!1,activeIndex:0},t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(dT),m,h;t[1]===n?(m=t[2],h=t[3]):(m=()=>{s.current!==n&&(s.current=n,d(CT))},h=[n],t[1]=n,t[2]=m,t[3]=h),(0,Q.useEffect)(m,h);let g,_;t[4]===u.activeIndex?(g=t[5],_=t[6]):(g=()=>{c.current=u.activeIndex},_=[u.activeIndex],t[4]=u.activeIndex,t[5]=g,t[6]=_),(0,Q.useEffect)(g,_);let v,y;t[7]===i?(v=t[8],y=t[9]):(v=()=>{let e=o.current;e&&e!==i&&!e.isDestroyed&&e.commands.clearFindMatches(),o.current=i},y=[i],t[7]=i,t[8]=v,t[9]=y),(0,Q.useEffect)(v,y);let b,x;t[10]===u.open?(b=t[11],x=t[12]):(b=()=>{if(!u.open||!a.current)return;let e=requestAnimationFrame(()=>{a.current?.focus(),a.current?.select()});return()=>cancelAnimationFrame(e)},x=[u.open],t[10]=u.open,t[11]=b,t[12]=x),(0,Q.useEffect)(b,x);let S,C;t[13]!==u.open||t[14]!==r?(S=()=>{!u.open||!r||d(ST)},C=[u.open,r],t[13]=u.open,t[14]=r,t[15]=S,t[16]=C):(S=t[15],C=t[16]),(0,Q.useEffect)(S,C);let w,T;t[17]!==i||t[18]!==u.caseSensitive||t[19]!==u.open||t[20]!==u.query||t[21]!==u.wholeWord||t[22]!==r?(w=()=>{if(!i||i.isDestroyed){p(dT);return}if(!u.open||r){i.commands.clearFindMatches(),p(dT);return}let e=window.setTimeout(()=>{if(i.isDestroyed)return;i.commands.setFindQuery(u.query,{options:{caseSensitive:u.caseSensitive,wholeWord:u.wholeWord},activeIndex:c.current});let e=_T(i);p(t=>vT(t,e)?t:e)},pT);return()=>window.clearTimeout(e)},T=[i,u.open,u.query,u.caseSensitive,u.wholeWord,r],t[17]=i,t[18]=u.caseSensitive,t[19]=u.open,t[20]=u.query,t[21]=u.wholeWord,t[22]=r,t[23]=w,t[24]=T):(w=t[23],T=t[24]),(0,Q.useEffect)(w,T);let E,D;t[25]!==i||t[26]!==u.open||t[27]!==r?(E=()=>{if(!i||i.isDestroyed||!u.open||r)return;let e=()=>{let e=$e(i.state),t=_T(i);p(e=>vT(e,t)?e:t),d(t=>t.activeIndex===e.activeIndex?t:{...t,activeIndex:e.activeIndex})};return i.on(`transaction`,e),()=>{i.off(`transaction`,e)}},D=[i,u.open,r],t[25]=i,t[26]=u.open,t[27]=r,t[28]=E,t[29]=D):(E=t[28],D=t[29]),(0,Q.useEffect)(E,D);let O,k;t[30]!==n||t[31]!==i||t[32]!==u.open||t[33]!==r?(O=()=>{let e=function(e){let t=gT(i);d(n=>({...n,open:!0,replaceOpen:e,query:t??n.query,activeIndex:0}))},t=function(t){if(!(!n||r||t.defaultPrevented)){if(Sl(t,`find`)){t.preventDefault(),u.open?yT(i,d,p):e(!1);return}if(Sl(t,`replace`)){t.preventDefault(),e(!0);return}if(u.open){let e=Sl(t,`find-next`),n=Sl(t,`find-previous`);if(e||n){t.preventDefault(),(n?i?.commands.selectPreviousFindMatch():i?.commands.selectNextFindMatch())&&bT(i);return}}t.key===`Escape`&&u.open&&(t.preventDefault(),yT(i,d,p))}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},k=[n,i,u.open,r],t[30]=n,t[31]=i,t[32]=u.open,t[33]=r,t[34]=O,t[35]=k):(O=t[34],k=t[35]),(0,Q.useEffect)(O,k);let A;t[36]!==i||t[37]!==u.caseSensitive||t[38]!==u.query||t[39]!==u.wholeWord?(A=function(){return!i||i.isDestroyed?!1:(i.commands.setFindQuery(u.query,{options:{caseSensitive:u.caseSensitive,wholeWord:u.wholeWord},activeIndex:c.current}),!0)},t[36]=i,t[37]=u.caseSensitive,t[38]=u.query,t[39]=u.wholeWord,t[40]=A):A=t[40];let j=A,M;t[41]===i?M=t[42]:(M=function(){if(!i||i.isDestroyed)return;let e=$e(i.state),t=_T(i);p(e=>vT(e,t)?e:t),d(t=>t.activeIndex===e.activeIndex?t:{...t,activeIndex:e.activeIndex})},t[41]=i,t[42]=M);let N=M,P;t[43]===i?P=t[44]:(P=function(){yT(i,d,p)},t[43]=i,t[44]=P);let F=P,I;t[45]!==j||t[46]!==i||t[47]!==N?(I=function(){!i||i.isDestroyed||(j(),i.commands.selectNextFindMatch()&&bT(i),N())},t[45]=j,t[46]=i,t[47]=N,t[48]=I):I=t[48];let L=I,R;t[49]!==j||t[50]!==i||t[51]!==N?(R=function(){!i||i.isDestroyed||(j(),i.commands.selectPreviousFindMatch()&&bT(i),N())},t[49]=j,t[50]=i,t[51]=N,t[52]=R):R=t[52];let z=R,B;t[53]!==j||t[54]!==i||t[55]!==u.replacement||t[56]!==N?(B=function(){!i||i.isDestroyed||(j(),i.commands.replaceCurrentFindMatch(u.replacement)&&bT(i),N())},t[53]=j,t[54]=i,t[55]=u.replacement,t[56]=N,t[57]=B):B=t[57];let V=B,H;t[58]!==j||t[59]!==i||t[60]!==u.replacement||t[61]!==N?(H=function(){!i||i.isDestroyed||(j(),i.commands.replaceAllFindMatches(u.replacement)&&bT(i),N())},t[58]=j,t[59]=i,t[60]=u.replacement,t[61]=N,t[62]=H):H=t[62];let U=H;if(!u.open||!n||r)return null;let W,G,K,q,J;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>d(t=>({...t,query:e,activeIndex:0})),G=e=>d(t=>({...t,replacement:e})),K=e=>d(t=>({...t,replaceOpen:e})),q=e=>d(t=>({...t,caseSensitive:e})),J=e=>d(t=>({...t,wholeWord:e})),t[63]=W,t[64]=G,t[65]=K,t[66]=q,t[67]=J):(W=t[63],G=t[64],K=t[65],q=t[66],J=t[67]);let Y;return t[68]!==F||t[69]!==u.caseSensitive||t[70]!==u.query||t[71]!==u.replaceOpen||t[72]!==u.replacement||t[73]!==u.wholeWord||t[74]!==f.current||t[75]!==f.total||t[76]!==U||t[77]!==V||t[78]!==L||t[79]!==z?(Y=(0,Z.jsx)(`div`,{className:`editor-content-aligned pointer-events-none absolute inset-x-0 top-2 z-30 px-2`,children:(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(uT,{findInputRef:a,query:u.query,replacement:u.replacement,replaceOpen:u.replaceOpen,caseSensitive:u.caseSensitive,wholeWord:u.wholeWord,current:f.current,total:f.total,onQueryChange:W,onReplacementChange:G,onReplaceOpenChange:K,onCaseSensitiveChange:q,onWholeWordChange:J,onNext:L,onPrevious:z,onReplaceCurrent:V,onReplaceAll:U,onClose:F})})}),t[68]=F,t[69]=u.caseSensitive,t[70]=u.query,t[71]=u.replaceOpen,t[72]=u.replacement,t[73]=u.wholeWord,t[74]=f.current,t[75]=f.total,t[76]=U,t[77]=V,t[78]=L,t[79]=z,t[80]=Y):Y=t[80],Y}function ST(e){return{...e,open:!1,activeIndex:0}}function CT(e){return{...e,activeIndex:0}}var wT=300;function TT(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(Gl),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e||!t){i(Gl);return}let n=e.document.getText(`source`),r=!1,a=null,o=function(){r||i(Yl(n.toString()))};o();let s=function(){a&&clearTimeout(a),a=setTimeout(o,wT)};return n.observe(s),()=>{r=!0,n.unobserve(s),a&&clearTimeout(a)}},o=[e,t],n[0]=t,n[1]=e,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Q.useEffect)(a,o),r}function ET(e){return e&&e.document.getMap(`lifecycle`).get(`status`)===`conflict`?`conflict`:null}function DT(e){let t=(0,$.c)(8),{poolEntries:n}=_t(),r;t[0]!==e||t[1]!==n?(r=e?n.find(t=>t.docName===e)??null:null,t[0]=e,t[1]=n,t[2]=r):r=t[2];let i=r?.provider??null,a;t[3]===i?a=t[4]:(a=()=>ET(i),t[3]=i,t[4]=a);let[o,s]=(0,Q.useState)(a),c,l;return t[5]===i?(c=t[6],l=t[7]):(c=()=>{if(!i){s(null);return}let e=i.document.getMap(`lifecycle`);s(ET(i));let t=()=>s(ET(i));return e.observe(t),()=>{e.unobserve(t)}},l=[i],t[5]=i,t[6]=c,t[7]=l),(0,Q.useEffect)(c,l),o}function OT(e,t){let n=(0,$.c)(3),r;return n[0]!==e||n[1]!==t?(r=()=>$l(e,t),n[0]=e,n[1]=t,n[2]=r):r=n[2],(0,Q.useSyncExternalStore)(eu,r)}var kT=`ok-doc-panel-width-v1`;function AT(e){return Number.isFinite(e)?e<300?300:e>600?600:Math.round(e):320}function jT(e){try{let t=(e??localStorage).getItem(kT);if(t==null)return 320;let n=Number.parseInt(t,10);return Number.isFinite(n)?AT(n):320}catch{return 320}}function MT(e,t){try{(t??localStorage).setItem(kT,String(AT(e)))}catch{}}function NT(){try{return typeof localStorage>`u`?320:jT()}catch{return 320}}var PT=1024,FT=1280,IT={left:PT,right:FT};function LT(e,t,n){return e==null?t>=IT[n]?`above`:`below`:`embedded`}function RT(e){return e===`above`?`open`:`collapsed`}var zT=`ok-sidebar-pins-v2`;function BT(e){return e===`open`||e===`collapsed`}function VT(e){return e===`above`||e===`below`||e===`embedded`}function HT(e){if(typeof e!=`object`||!e)return!1;let t=e;for(let e of Object.keys(t))if(!VT(e)||!BT(t[e]))return!1;return!0}function UT(e){let t=JSON.parse(e);if(typeof t!=`object`||!t)return{};let n=t,r={};return HT(n.left)&&(r.left=n.left),HT(n.right)&&(r.right=n.right),r}function WT(e){try{let t=(e??localStorage).getItem(zT);return t==null?{}:UT(t)}catch{return{}}}function GT(e,t){try{t.setItem(zT,JSON.stringify(e))}catch{}}function KT(e,t,n){return n[e]?.[t]??RT(t)}function qT(e,t,n,r){let i=r??localStorage,a=WT(i);return a[e]={...a[e],[t]:n},GT(a,i),a}function JT(e){let t=(0,$.c)(3),[n,r]=(0,Q.useState)(`connecting`),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e){r(`connecting`);return}let t=e.configuration.websocketProvider.status;e.isSynced?r(`synced`):r(t===`connected`?`connected`:t===`disconnected`?`disconnected`:`connecting`);let n=e=>{let{status:t}=e;r(t===`connected`?YT:t===`disconnected`?`disconnected`:`connecting`)},i=e=>{let{state:t}=e;r(t?`synced`:`connected`)},a=()=>r(`disconnected`);return e.on(`status`,n),e.on(`synced`,i),e.on(`disconnect`,a),()=>{e.off(`status`,n),e.off(`synced`,i),e.off(`disconnect`,a)}},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,Q.useEffect)(i,a),n}function YT(e){return e===`synced`?`synced`:`connected`}function XT(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function ZT(e){let t=(0,$.c)(21),{path:n,onRemove:r}=e,{_:i}=cn(),a,o;t[0]!==i||t[1]!==n?(a=XT(n),o=i({id:`hnq8fP`,values:{label:a}}),t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s=o,c=`composer-context-chip-file-${n}`,l;t[4]===r?l=t[5]:(l=e=>{(e.key===`Backspace`||e.key===`Delete`)&&(e.preventDefault(),r())},t[4]=r,t[5]=l);let u;t[6]===n?u=t[7]:(u=(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 inline-flex size-3 -translate-x-1/2 -translate-y-1/2 opacity-100 transition-opacity duration-150 ease-out group-hover/chip:opacity-0 group-focus-within/chip:opacity-0 motion-reduce:transition-none`,children:(0,Z.jsx)(ut,{path:n,className:`size-3`})}),t[6]=n,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(Ys,{className:`absolute top-1/2 left-1/2 size-3 -translate-x-1/2 -translate-y-1/2 opacity-0 transition-opacity duration-150 ease-out group-hover/chip:opacity-100 group-focus-within/chip:opacity-100 motion-reduce:transition-none`,"aria-hidden":!0}),t[8]=d):d=t[8];let f;t[9]!==r||t[10]!==s||t[11]!==l||t[12]!==u?(f=(0,Z.jsxs)(Di,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s,onClick:r,onKeyDown:l,className:`group/remove relative size-3.5 shrink-0 rounded-sm text-muted-foreground/80 hover:text-foreground`,children:[u,d]}),t[9]=r,t[10]=s,t[11]=l,t[12]=u,t[13]=f):f=t[13];let p;t[14]===a?p=t[15]:(p=(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:a}),t[14]=a,t[15]=p);let m;return t[16]!==n||t[17]!==c||t[18]!==f||t[19]!==p?(m=(0,Z.jsxs)(`span`,{"data-testid":c,title:n,className:`group/chip inline-flex max-w-[14rem] items-center gap-1 rounded-md border bg-muted/40 py-0.5 pr-1.5 pl-1 text-muted-foreground text-xs`,children:[f,p]}),t[16]=n,t[17]=c,t[18]=f,t[19]=p,t[20]=m):m=t[20],m}function QT(e){let t=(0,$.c)(11),{files:n,onRemoveFile:r,className:i,children:a}=e;if(n.length===0&&a==null)return null;let o;t[0]===i?o=t[1]:(o=Ti(`flex flex-wrap items-center gap-1`,i),t[0]=i,t[1]=o);let s;if(t[2]!==n||t[3]!==r){let e;t[5]===r?e=t[6]:(e=e=>(0,Z.jsx)(ZT,{path:e,onRemove:()=>r(e)},e),t[5]=r,t[6]=e),s=n.map(e),t[2]=n,t[3]=r,t[4]=s}else s=t[4];let c;return t[7]!==a||t[8]!==o||t[9]!==s?(c=(0,Z.jsxs)(`div`,{className:o,"data-testid":`composer-context-chips`,children:[s,a]}),t[7]=a,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function $T(e){let t=(0,$.c)(35),{primary:n,onPrimary:r,primaryDisabled:i,installedTargets:a,selectedTargetId:o,onSelectTarget:s,terminal:c,terminals:l,menuEmptyState:u,onMenuOpenChange:d,menuAlign:f,triggerAriaLabel:p,testIds:m}=e,h=i===void 0?!1:i,g=f===void 0?`end`:f,{_}=cn(),v=a.length>0,y=l&&l.length>0?l:null,b=y!=null||c!=null,x=v||b,S;t[0]===m?S=t[1]:(S=e=>typeof m.terminal==`function`?m.terminal(e):m.terminal,t[0]=m,t[1]=S);let C=S,w;t[2]!==r||t[3]!==n||t[4]!==h||t[5]!==m.primary?(w=(0,Z.jsx)(Di,{type:`button`,variant:`outline`,className:`gap-1.5`,disabled:h,onClick:r,"data-testid":m.primary,children:n}),t[2]=r,t[3]=n,t[4]=h,t[5]=m.primary,t[6]=w):w=t[6];let T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(so,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),t[7]=T):T=t[7];let E;t[8]!==m.trigger||t[9]!==p?(E=(0,Z.jsx)(qc,{asChild:!0,children:(0,Z.jsx)(Di,{type:`button`,variant:`outline`,size:`icon`,"aria-label":p,"data-testid":m.trigger,children:T})}),t[8]=m.trigger,t[9]=p,t[10]=E):E=t[10];let D;t[11]!==_||t[12]!==y||t[13]!==x||t[14]!==a||t[15]!==u||t[16]!==s||t[17]!==o||t[18]!==v||t[19]!==b||t[20]!==c||t[21]!==C||t[22]!==m?(D=x?(0,Z.jsxs)(Z.Fragment,{children:[v?(0,Z.jsxs)(Xc,{"aria-label":_({id:`BBqGS9`}),children:[(0,Z.jsx)(ol,{children:(0,Z.jsx)(X,{id:`BBqGS9`})}),a.map(e=>(0,Z.jsxs)(Yc,{onSelect:()=>s(e),"data-testid":m.option(e.id),children:[(0,Z.jsx)(Xo,{id:e.id,"aria-hidden":`true`,className:`size-4`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:e.displayName}),o===e.id?(0,Z.jsx)($a,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},e.id))]}):null,b?(0,Z.jsxs)(Z.Fragment,{children:[v?(0,Z.jsx)(cl,{}):null,(0,Z.jsxs)(Xc,{"aria-label":_({id:`ALhMYW`}),children:[(0,Z.jsx)(ol,{children:(0,Z.jsx)(X,{id:`ALhMYW`})}),y?y.map(e=>(0,Z.jsxs)(Yc,{onSelect:e.onSelect,"data-testid":C(e.cli),"aria-label":e.ariaLabel,children:[(0,Z.jsx)(Xo,{id:Yo(e.cli),className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:e.label}),e.selected?(0,Z.jsx)($a,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},e.cli)):c?(0,Z.jsxs)(Yc,{onSelect:c.onSelect,"data-testid":C(`claude`),"aria-label":_({id:`AcK_r0`}),children:[(0,Z.jsx)(Xo,{id:Yo(`claude`),className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(X,{id:`fcgvCA`})}),c.selected?(0,Z.jsx)($a,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]}):null]})]}):null]}):u,t[11]=_,t[12]=y,t[13]=x,t[14]=a,t[15]=u,t[16]=s,t[17]=o,t[18]=v,t[19]=b,t[20]=c,t[21]=C,t[22]=m,t[23]=D):D=t[23];let O;t[24]!==g||t[25]!==D||t[26]!==m.menu?(O=(0,Z.jsx)(Zc,{align:g,className:`min-w-[200px]`,"data-testid":m.menu,children:D}),t[24]=g,t[25]=D,t[26]=m.menu,t[27]=O):O=t[27];let k;t[28]!==d||t[29]!==E||t[30]!==O?(k=(0,Z.jsxs)(rl,{onOpenChange:d,children:[E,O]}),t[28]=d,t[29]=E,t[30]=O,t[31]=k):k=t[31];let A;return t[32]!==w||t[33]!==k?(A=(0,Z.jsxs)(ES,{children:[w,k]}),t[32]=w,t[33]=k,t[34]=A):A=t[34],A}var eE=5200,tE=500;function nE(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toUpperCase();return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`}function rE(){let e=(0,$.c)(2),[t,n]=(0,Q.useState)(iE),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`);n(e.matches);let t=e=>n(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i),t}function iE(){return typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function aE(e,t){let n=(0,$.c)(9),[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(!0),s,c;if(n[0]!==t||n[1]!==a?(s=()=>{if(!t)return;if(a){let e=setTimeout(()=>o(!1),eE);return()=>clearTimeout(e)}let e=setTimeout(()=>{i(oE),o(!0)},tE);return()=>clearTimeout(e)},c=[a,t],n[0]=t,n[1]=a,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,Q.useEffect)(s,c),!t){let t=e[0]??``,r;return n[4]===t?r=n[5]:(r={text:t,visible:!0},n[4]=t,n[5]=r),r}let l=e[e.length>0?r%e.length:0]??``,u;return n[6]!==l||n[7]!==a?(u={text:l,visible:a},n[6]=l,n[7]=a,n[8]=u):u=n[8],u}function oE(e){return e+1}function sE(e){let t=(0,$.c)(149),{docName:n,surface:r,folderPath:i,dismissed:a,onDismiss:o,onReopen:s}=e,c=a===void 0?!1:a,{_:l}=cn(),u=i!==void 0,d=u?null:n??null,f=r??`wysiwyg`,p=rE(),m=Ho(),{states:h}=ns(),{dispatch:g}=us(),_=cs(),[v]=(0,Q.useState)(_E),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(!0),[C,w]=(0,Q.useState)(!1),T=(0,Q.useRef)(null),E=(0,Q.useRef)(null),[D]=(0,Q.useState)(gE),O,k;t[0]!==c||t[1]!==n||t[2]!==u||t[3]!==r?(O=()=>{if(u||n==null)return;let e=document.documentElement,t=mE,i=()=>{r===`wysiwyg`&&requestAnimationFrame(()=>{let e=ce(n),t=E.current;if(!(!e||e.isDestroyed||!t))try{let n=e.view,r=n.coordsAtPos(e.state.selection.head).bottom-(t.getBoundingClientRect().top-28);if(r<=0)return;let i=n.dom.closest(`.editor-doc-scroll`);i instanceof HTMLElement&&(i.scrollTop+=r)}catch{}})},a=E.current;if(c||!a){t(),e.style.removeProperty(`--ask-composer-height`);return}let o=()=>{t(),e.style.setProperty(`--ask-composer-height`,`${a.offsetHeight+56}px`)};o(),i();let s=new ResizeObserver(o);return s.observe(a),()=>{s.disconnect(),t(),e.style.removeProperty(`--ask-composer-height`)}},k=[c,r,n,u],t[0]=c,t[1]=n,t[2]=u,t[3]=r,t[4]=O,t[5]=k):(O=t[4],k=t[5]),(0,Q.useEffect)(O,k);let A=(0,Q.useRef)(c),j=(0,Q.useRef)(s),M;t[6]!==c||t[7]!==s?(M=()=>{A.current=c,j.current=s},t[6]=c,t[7]=s,t[8]=M):M=t[8],(0,Q.useEffect)(M);let N,P;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>Xl(()=>{A.current?j.current?.():T.current?.focus()}),P=[],t[9]=N,t[10]=P):(N=t[9],P=t[10]),(0,Q.useEffect)(N,P);let F;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(F=[],t[11]=F):F=t[11],(0,Q.useEffect)(fE,F);let I=(0,Q.useRef)(!1),L,R;t[12]===c?(L=t[13],R=t[14]):(L=()=>{if(!I.current){I.current=!0;return}c||T.current?.focus()},R=[c],t[12]=c,t[13]=L,t[14]=R),(0,Q.useEffect)(L,R);let z;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(z=[],t[15]=z):z=t[15];let[B,V]=(0,Q.useState)(z),[H,U]=(0,Q.useState)(dE),W;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(W=[],t[16]=W):W=t[16];let[G,K]=(0,Q.useState)(W),q;t[17]!==n||t[18]!==u?(q=u||n==null?``:Ko(n),t[17]=n,t[18]=u,t[19]=q):q=t[19];let J=q,Y,ee;t[20]!==J||t[21]!==H||t[22]!==u||t[23]!==x?(Y=()=>{u||x||V(e=>e.includes(J)||H.has(J)?e:[...e,J])},ee=[u,x,J,H],t[20]=J,t[21]=H,t[22]=u,t[23]=x,t[24]=Y,t[25]=ee):(Y=t[24],ee=t[25]),(0,Q.useEffect)(Y,ee);let te;t[26]!==H||t[27]!==u||t[28]!==i||t[29]!==G||t[30]!==B?(te=u?i&&!H.has(i)&&!G.includes(i)?[i]:[]:B.filter(e=>!H.has(e)&&!G.includes(e)),t[26]=H,t[27]=u,t[28]=i,t[29]=G,t[30]=B,t[31]=te):te=t[31];let ne=te,re=Ya(d,f),ie=Ya(d,`frontmatter`),[ae,oe]=(0,Q.useState)(null),[se,le]=(0,Q.useState)(!1),ue,de;t[32]===re?(ue=t[33],de=t[34]):(ue=()=>{re&&oe(re)},de=[re],t[32]=re,t[33]=ue,t[34]=de),(0,Q.useEffect)(ue,de);let fe,pe;t[35]===ie?(fe=t[36],pe=t[37]):(fe=()=>{ie&&oe(ie)},pe=[ie],t[35]=ie,t[36]=fe,t[37]=pe),(0,Q.useEffect)(fe,pe);let me=y??v,he;t[38]!==me||t[39]!==_?(he=_===null?null:QS(me),t[38]=me,t[39]=_,t[40]=he):he=t[40];let ge=he,_e=ge!==null,ve;t[41]!==me||t[42]!==_e||t[43]!==h?(ve=_e?null:nC(h,me),t[41]=me,t[42]=_e,t[43]=h,t[44]=ve):ve=t[44];let ye=ve,be=!C&&(!x||ae!==null)&&(_e||ye!==null),xe;t[45]===h?xe=t[46]:(xe=Wo.filter(e=>h[e.id]?.installed===!0),t[45]=h,t[46]=xe);let Se=xe,Ce;t[47]===h?Ce=t[48]:(Ce=Wo.some(e=>h[e.id]?.installed==null),t[47]=h,t[48]=Ce);let we=Ce,Te=_===null?void 0:_i.map(e=>{let{displayName:t}=Gn[e];return{cli:e,label:t,ariaLabel:l({id:`QYfQdv`,values:{displayName:t}}),selected:ge===e,onSelect:()=>Pe(e)}}),Ee;t[49]===l?Ee=t[50]:(Ee=l({id:`KYSocE`}),t[49]=l,t[50]=Ee);let De;t[51]===l?De=t[52]:(De=l({id:`7Ongq0`}),t[51]=l,t[52]=De);let Oe;t[53]===l?Oe=t[54]:(Oe=l({id:`HPTPGr`}),t[53]=l,t[54]=Oe);let ke;t[55]===l?ke=t[56]:(ke=l({id:`qiRoLb`}),t[55]=l,t[56]=ke);let Ae;t[57]!==Ee||t[58]!==De||t[59]!==Oe||t[60]!==ke?(Ae=[Ee,De,Oe,ke],t[57]=Ee,t[58]=De,t[59]=Oe,t[60]=ke,t[61]=Ae):Ae=t[61];let je=aE(Ae,!p&&x&&!c),Me;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(Me=e=>{b(e.id),tC(e.id)},t[62]=Me):Me=t[62];let Ne=Me,Pe=e=>{let t=ZS(e);b(t),tC(t)},Fe;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=()=>{T.current?.clear(),oe(null),le(!1),V([]),U(new Set),wS()},t[63]=Fe):Fe=t[63];let Ie=Fe,Le;t[64]!==l||t[65]!==g||t[66]!==ye||t[67]!==ge||t[68]!==_?(Le=e=>{if(e===null){Js.error(l({id:`y8B54M`}));return}if(ge!==null&&_!==null){try{_.launchInTerminal(e,ge)}catch{Js.error(l({id:`jBVUXo`}));return}Ie();return}ye!==null&&(w(!0),g(ye.id,e).finally(()=>{w(!1),Ie()}))},t[64]=l,t[65]=g,t[66]=ye,t[67]=ge,t[68]=_,t[69]=Le):Le=t[69];let Re=Le,ze;t[70]!==J||t[71]!==be||t[72]!==Re||t[73]!==n||t[74]!==ne||t[75]!==u||t[76]!==i||t[77]!==ae||t[78]!==m?(ze=()=>{if(!be)return;let{instruction:e,mentions:t}=T.current?.getContent()??{instruction:``,mentions:[]};if(u){Re(Qo({docName:null,folderRelativePath:i,workspace:m,instruction:e,mentions:[...new Set([...ne,...t])].filter(e=>e!==i)}));return}let r=ae?iu(ae):void 0,a=ae?.docName??null,o=ae?a:ne.includes(J)?n??null:null,s=o===null?null:Ko(o);Re(Qo({docName:o,workspace:m,instruction:e,mentions:[...new Set([...ne,...t])].filter(e=>e!==s),selection:r}))},t[70]=J,t[71]=be,t[72]=Re,t[73]=n,t[74]=ne,t[75]=u,t[76]=i,t[77]=ae,t[78]=m,t[79]=ze):ze=t[79];let Be=ze;if(c)return null;let Ve=``,He=``;if(ae){let e;t[80]===ae?e=t[81]:(e=au(ae,Ko(ae.docName).split(`/`).pop()??``),t[80]=ae,t[81]=e),Ve=e;let n;t[82]===ae.markdown?n=t[83]:(n=ou(ae.markdown),t[82]=ae.markdown,t[83]=n),He=n}let Ue;t[84]!==l||t[85]!==u||t[86]!==o?(Ue=u?null:(0,Z.jsx)(Di,{type:`button`,variant:`outline`,"aria-label":l({id:`EWX92Z`}),onClick:()=>o?.(),"data-testid":`ask-ai-collapse`,className:`-top-2.5 -translate-x-1/2 absolute left-1/2 z-10 h-5 w-10 rounded-md p-0 text-muted-foreground opacity-0 shadow-sm transition-opacity hover:text-foreground focus-visible:opacity-100 group-focus-within:opacity-100 group-hover:opacity-100`,children:(0,Z.jsx)(so,{className:`size-3.5`,"aria-hidden":!0})}),t[84]=l,t[85]=u,t[86]=o,t[87]=Ue):Ue=t[87];let We;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(We=e=>U(t=>{let n=new Set(t);return n.add(e),n}),t[88]=We):We=t[88];let Ge;t[89]!==l||t[90]!==Ve||t[91]!==He||t[92]!==ae||t[93]!==se?(Ge=ae?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"data-testid":`composer-selection-pill`,title:Ve,className:`group/chip inline-flex max-w-[16rem] items-center gap-1 rounded-md border bg-muted/40 py-0.5 pr-1.5 pl-1 text-muted-foreground text-xs`,children:[(0,Z.jsxs)(Di,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":l({id:`irrm_E`}),onClick:()=>{oe(null),le(!1)},className:`group/remove relative size-3.5 shrink-0 rounded-sm text-muted-foreground/80 hover:text-foreground`,children:[(0,Z.jsx)(Ud,{className:`absolute top-1/2 left-1/2 size-3 -translate-x-1/2 -translate-y-1/2 opacity-100 transition-opacity duration-150 ease-out group-hover/chip:opacity-0 group-focus-within/chip:opacity-0 motion-reduce:transition-none`,"aria-hidden":!0}),(0,Z.jsx)(Ys,{className:`absolute top-1/2 left-1/2 size-3 -translate-x-1/2 -translate-y-1/2 opacity-0 transition-opacity duration-150 ease-out group-hover/chip:opacity-100 group-focus-within/chip:opacity-100 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,Z.jsx)(Di,{type:`button`,variant:`ghost`,"aria-expanded":se,"aria-label":l(se?{id:`UaDyeb`}:{id:`eTL5y9`}),onClick:()=>le(uE),"data-testid":`composer-selection-peek`,className:`h-auto min-h-0 min-w-0 shrink justify-start px-0 py-0 text-left font-normal text-muted-foreground text-xs hover:bg-transparent hover:text-foreground`,children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:Ve})})]}),se&&He!==``?(0,Z.jsx)(`p`,{className:`max-h-24 w-full basis-full overflow-y-auto whitespace-pre-wrap text-2xs text-muted-foreground/80 subtle-scrollbar`,"data-testid":`composer-selection-preview`,children:He}):null]}):null,t[89]=l,t[90]=Ve,t[91]=He,t[92]=ae,t[93]=se,t[94]=Ge):Ge=t[94];let Ke;t[95]!==ne||t[96]!==Ge?(Ke=(0,Z.jsx)(QT,{files:ne,onRemoveFile:We,children:Ge}),t[95]=ne,t[96]=Ge,t[97]=Ke):Ke=t[97];let qe;t[98]===l?qe=t[99]:(qe=l({id:`xWEvuo`}),t[98]=l,t[99]=qe);let Je;t[100]!==D||t[101]!==Be||t[102]!==qe?(Je=(0,Z.jsx)(GS,{ref:T,ariaLabel:qe,onEmptyChange:S,onContentChange:CS,onMentionsChange:K,onSubmit:Be,initialDoc:D,className:`max-h-[200px] overflow-y-auto text-base md:text-sm`}),t[100]=D,t[101]=Be,t[102]=qe,t[103]=Je):Je=t[103];let Ye;t[104]!==x||t[105]!==p||t[106]!==je?(Ye=x?(0,Z.jsx)(`div`,{"aria-hidden":!0,className:Ti(`pointer-events-none absolute inset-0 truncate px-0 py-1 text-base text-muted-foreground/60 md:text-sm`,!p&&`transition-opacity duration-500 ease-in-out`,je.visible?`opacity-100`:`opacity-0`),children:je.text}):null,t[104]=x,t[105]=p,t[106]=je,t[107]=Ye):Ye=t[107];let Xe;t[108]!==Je||t[109]!==Ye?(Xe=(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[Je,Ye]}),t[108]=Je,t[109]=Ye,t[110]=Xe):Xe=t[110];let Ze;t[111]!==ye||t[112]!==ge?(Ze=ge===null?ye?(0,Z.jsx)(Xo,{id:ye.id,className:`size-4`,"aria-hidden":!0}):null:(0,Z.jsx)(Xo,{id:Yo(ge),className:`size-4`,"aria-hidden":!0}),t[111]=ye,t[112]=ge,t[113]=Ze):Ze=t[113];let Qe;t[114]!==ye||t[115]!==ge?(Qe=(0,Z.jsx)(`span`,{children:ge===null?ye?(0,Z.jsx)(X,{id:`nUNZL4`,values:{0:ye.displayName}}):(0,Z.jsx)(X,{id:`F-vBv0`}):(0,Z.jsx)(X,{id:`ti6aF_`,values:{0:Gn[ge].displayName}})}),t[114]=ye,t[115]=ge,t[116]=Qe):Qe=t[116];let $e;t[117]===C?$e=t[118]:($e=C?(0,Z.jsx)(hs,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t[117]=C,t[118]=$e);let et;t[119]!==Ze||t[120]!==Qe||t[121]!==$e?(et=(0,Z.jsxs)(Z.Fragment,{children:[Ze,Qe,$e]}),t[119]=Ze,t[120]=Qe,t[121]=$e,t[122]=et):et=t[122];let tt=!be,nt=_e?null:ye?.id??null,rt;t[123]===we?rt=t[124]:(rt=(0,Z.jsx)(`p`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,"aria-live":`polite`,children:we?(0,Z.jsx)(X,{id:`EcR0fl`}):(0,Z.jsx)(X,{id:`l6OXqI`})}),t[123]=we,t[124]=rt);let it;t[125]===l?it=t[126]:(it=l({id:`nskygk`}),t[125]=l,t[126]=it);let at;t[127]===Symbol.for(`react.memo_cache_sentinel`)?(at={primary:`ask-ai-send`,trigger:`ask-ai-agent-trigger`,menu:`ask-ai-agent-menu`,option:lE,terminal:cE},t[127]=at):at=t[127];let ot;t[128]!==Te||t[129]!==Ne||t[130]!==Se||t[131]!==Be||t[132]!==et||t[133]!==tt||t[134]!==nt||t[135]!==rt||t[136]!==it?(ot=(0,Z.jsx)($T,{primary:et,onPrimary:Be,primaryDisabled:tt,installedTargets:Se,selectedTargetId:nt,onSelectTarget:Ne,terminals:Te,menuEmptyState:rt,triggerAriaLabel:it,testIds:at}),t[128]=Te,t[129]=Ne,t[130]=Se,t[131]=Be,t[132]=et,t[133]=tt,t[134]=nt,t[135]=rt,t[136]=it,t[137]=ot):ot=t[137];let st;t[138]!==Xe||t[139]!==ot?(st=(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[Xe,ot]}),t[138]=Xe,t[139]=ot,t[140]=st):st=t[140];let ct;t[141]!==Ue||t[142]!==Ke||t[143]!==st?(ct=(0,Z.jsxs)(`div`,{ref:E,className:`pointer-events-auto group relative flex flex-col gap-1.5 rounded-2xl border border-border/60 bg-card px-3 py-2 shadow-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50`,children:[Ue,Ke,st]}),t[141]=Ue,t[142]=Ke,t[143]=st,t[144]=ct):ct=t[144];let lt=ct;if(u){let e;return t[145]===lt?e=t[146]:(e=(0,Z.jsx)(`div`,{className:`shrink-0 pt-2 pb-3`,"data-testid":`bottom-composer`,children:(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-6`,children:lt})}),t[145]=lt,t[146]=e),e}let ut;return t[147]===lt?ut=t[148]:(ut=(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-20 editor-content-aligned bg-gradient-to-t from-background from-65% via-background to-transparent pt-10 pb-2`,"data-testid":`bottom-composer`,children:lt}),t[147]=lt,t[148]=ut),ut}function cE(e){return e===`claude`?`ask-ai-agent-option-terminal`:`ask-ai-agent-option-terminal-${e}`}function lE(e){return`ask-ai-agent-option-${e}`}function uE(e){return!e}function dE(){return new Set}function fE(){let e=pE;return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})}function pE(e){Sl(e,`open-ask-ai`)&&(nE(e.target)||(e.preventDefault(),tu()))}function mE(){let e=[...document.querySelectorAll(`.editor-doc-scroll`)].filter(hE);if(e.length===0)return;let t=!1,n=()=>{t=!0};window.addEventListener(`wheel`,n,{passive:!0}),window.addEventListener(`touchstart`,n,{passive:!0});let r=performance.now(),i=()=>{if(t||performance.now()-r>=300){window.removeEventListener(`wheel`,n),window.removeEventListener(`touchstart`,n);return}for(let t of e)t.scrollTop=t.scrollHeight-t.clientHeight;requestAnimationFrame(i)};requestAnimationFrame(i)}function hE(e){let t=e.scrollHeight-e.clientHeight;return t>0&&e.scrollTop>=t-40}function gE(){return SS().doc??void 0}function _E(){return eC()}function vE(e){return!e.terminalVisible&&!e.isEmbedded&&e.isDesktop&&e.activeDocName!==null}function yE(e){return!e.terminalVisible&&!e.isEmbedded&&e.isDesktop}function bE(e,t={}){let n=De(e.componentName);return n.name===`*`?t.unregisteredSuffix?`${e.componentName} (unregistered)`:e.componentName:n.displayName??n.name}var xE=200,SE=`Outside any block`;function CE(e){let t=(0,$.c)(5),{editor:n}=e,r=tn(n),i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(!1),s,c;t[0]!==r||t[1]!==n?(s=()=>{if(a.current!==null&&(window.clearTimeout(a.current),a.current=null),!n||!i.current)return;let e=r!==null&&r.ancestorChain.length>0,t;return t=e?wE(n,r):o.current?SE:``,a.current=window.setTimeout(()=>{i.current&&(i.current.textContent=``,i.current.textContent=t),o.current=e,a.current=null},xE),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)}},c=[n,r],t[0]=r,t[1]=n,t[2]=s,t[3]=c):(s=t[2],c=t[3]),(0,Q.useEffect)(s,c);let l;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`div`,{ref:i,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`}),t[4]=l):l=t[4],l}function wE(e,t){if(!t||t.ancestorChain.length===0)return``;let n=t.ancestorChain,r=n[n.length-1],i=bE(r,{unregisteredSuffix:!0});if(n.length===1)return`Selected: ${i}`;let a=n[n.length-2],o=bE(a);try{let t=e.state.doc.resolve(r.pos),n=t.index(t.depth),a=t.parent.childCount;return`Selected: ${i}, ${n+1} of ${a} in ${o}`}catch{return`Selected: ${i} in ${o}`}}function TE(){let[e]=(0,Q.useState)(gr);return e}function EE({principal:e,identity:t}){return e&&e.source===`git-config`?{type:`human`,name:pi(e.display_name),color:wr(e.id,Zn),coeditor:t.coeditor,tabId:t.tabId,principalId:e.id}:e&&e.source===`synthesized`?{type:`human`,name:t.name,color:wr(e.id,Zn),coeditor:t.coeditor,tabId:t.tabId}:{type:`human`,name:t.name,color:t.color,coeditor:t.coeditor,tabId:t.tabId}}function DE(e,t){return e>t}function OE(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.isChangeOrigin===!0?!0:`snapshot`in t&&`prevSnapshot`in t&&t.snapshot===null&&t.prevSnapshot===null}var kE=3,AE=6e4;function jE(e,t){let n=0;for(let r of e)t-r<AE&&(n+=1);return n<kE}var ME=new Map;function NE(e,t){for(let n of e.changed.keys()){let e=n;for(;e!=null;){if(e===t)return!0;let n=e._item;e=n==null?null:n.parent}}return!1}function PE(e){let t=y.getState(e);return t?.snapshot!=null||t?.prevSnapshot!=null}function FE(e){let{fragment:t,docName:n,onWedged:r}=e,i=0,a=0,o=!1,s=!1,c=!1,l=null,u=new WeakSet,d=e=>{let t=y.getState(e)?.binding;if(!t)return;if(typeof t._prosemirrorChanged!=`function`){Ot.count(`ok/editor/binding-guard-disarmed`,{docName:n,reason:`no-prosemirror-changed`}),console.warn(`[binding-staleness-guard] ySync binding on "${n}" exposes no _prosemirrorChanged — write-back gate disarmed (vendored y-tiptap contract change?)`);return}if(u.has(t))return;u.add(t);let r=t._prosemirrorChanged.bind(t);t._prosemirrorChanged=e=>{DE(i,a)||r(e)}},f=()=>{if(c=!1,!s||o||!DE(i,a)||l!==null&&PE(l.state))return;o=!0;let e=Date.now();for(let[t,n]of ME)n.every(t=>e-t>=AE)&&ME.delete(t);let t=(ME.get(n)??[]).filter(t=>e-t<AE);if(!jE(t,e)){ME.set(n,t),Ot.count(`ok/editor/binding-wedge-rate-capped`,{docName:n}),console.warn(`[binding-staleness-guard] wedge on "${n}" rate-capped (externalSeq=${i}, appliedSeq=${a}) — publication gate stays closed, no further recycle`);return}t.push(e),ME.set(n,t),console.warn(`[binding-staleness-guard] wedged binding on "${n}" — Y→PM apply missing (externalSeq=${i}, appliedSeq=${a})`);try{r({externalSeq:i,appliedSeq:a})}catch(e){o=!1,Ot.count(`ok/editor/binding-wedge-recovery-error`,{docName:n}),console.error(`[binding-staleness-guard] wedge recovery threw for "${n}":`,e)}},p=e=>{e.origin!==y&&NE(e,t)&&(i+=1,c||(c=!0,queueMicrotask(f)))};return new ui({state:{init:()=>null,apply:e=>(OE(e.getMeta(y))&&(a=i,o&&Ot.count(`ok/editor/binding-wedge-recovered`,{docName:n}),o=!1),null)},filterTransaction:(e,t)=>!DE(i,a)||PE(t)?!0:e.getMeta(y)!==void 0,view:e=>{let r=t.doc;return r==null?(Ot.count(`ok/editor/binding-guard-disarmed`,{docName:n,reason:`no-ydoc`}),console.error(`[binding-staleness-guard] fragment has no Y.Doc for "${n}" — staleness guard disarmed`),{}):(s=!0,l=e,d(e.state),r.off(`beforeObserverCalls`,p),r.on(`beforeObserverCalls`,p),{destroy:()=>{s=!1,l=null,r.off(`beforeObserverCalls`,p)}})}})}function IE(e,t){let n=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),a=Math.max(e.right,t.right)-i,o=r-n;return new DOMRect(i,n,a,o)}var LE=class{constructor({editor:e,element:t,view:n,pluginKey:r=`bubbleMenu`,updateDelay:i=250,resizeDelay:a=60,shouldShow:o,appendTo:s,getReferencedVirtualElement:c,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:`absolute`,placement:`top`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:a}=t,{empty:o}=a,s=!i.textBetween(n,r).length&&Bn(t.selection),c=this.element.contains(document.activeElement);return!(!(e.hasFocus()||c)||o||s||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);!n&&!r||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.show(),this.updatePosition()}},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=l?.scrollTarget??window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener(`dragstart`,this.dragstartHandler),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Dc(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Cc(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(Tc(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(wc(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(xc(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(Ec(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(vc(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(yc(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}get virtualElement(){let{selection:e}=this.editor.state,t=this.getReferencedVirtualElement?.call(this);if(t)return t;if(!this.view?.dom?.parentNode)return;let n=ci(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof Xr){let t=this.view.nodeDOM(e.from),n=t.dataset.nodeViewWrapper?t:t.querySelector(`[data-node-view-wrapper]`);n&&(t=n),t&&(r={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(e instanceof sr){let{$anchorCell:t,$headCell:n}=e,i=t?t.pos:n.pos,a=n?n.pos:t.pos,o=this.view.nodeDOM(i),s=this.view.nodeDOM(a);if(!o||!s)return;let c=o===s?o.getBoundingClientRect():IE(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&Sc(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}let i=!t?.selection.eq(e.state.selection),a=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,a,t)}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:e,from:i,to:a})||!1}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener(`dragstart`,this.dragstartHandler),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},RE=e=>new ui({key:typeof e.pluginKey==`string`?new Fr(e.pluginKey):e.pluginKey,view:t=>new LE({view:t,...e})});Si.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[RE({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var zE=class{constructor({editor:e,element:t,view:n,pluginKey:r=`floatingMenu`,updateDelay:i=250,resizeDelay:a=60,options:o,appendTo:s,shouldShow:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,a=r.depth===1,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&r.parent.childCount===0&&!this.getTextContent(r.parent);return!(!e.hasFocus()||!i||!a||!o||!this.editor.isEditable)},this.floatingUIOptions={strategy:`absolute`,placement:`right`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.updatePosition(),this.show()}},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=o?.scrollTarget??window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return rr(e,{textSerializers:Tr(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Dc(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Cc(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(Tc(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(wc(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(xc(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(Ec(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(vc(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(yc(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,view:this.view,state:t,oldState:e,from:i,to:a})}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){let{selection:e}=this.editor.state,t=ci(this.view,e.from,e.to);Sc({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);this.updateHandler(e,n,r,t)}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},BE=e=>new ui({key:typeof e.pluginKey==`string`?new Fr(e.pluginKey):e.pluginKey,view:t=>new zE({view:t,...e})});Si.create({name:`floatingMenu`,addOptions(){return{element:null,options:{},pluginKey:`floatingMenu`,updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,`updatePosition`),!0)}},addProseMirrorPlugins(){return this.options.element?[BE({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function VE(e,t){return e??new Fr(t)}var HE=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,UE=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),WE=new Set(`animationIterationCount.aspectRatio.borderImageOutset.borderImageSlice.borderImageWidth.columnCount.columns.fillOpacity.flex.flexGrow.flexShrink.fontWeight.gridArea.gridColumn.gridColumnEnd.gridColumnStart.gridRow.gridRowEnd.gridRowStart.lineClamp.lineHeight.opacity.order.orphans.scale.stopOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeOpacity.strokeWidth.tabSize.widows.zIndex.zoom`.split(`.`)),GE=new Set([`children`,`className`,`style`]),KE=new Set([`tabIndex`]),qE=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),JE={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function YE(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function XE(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function ZE(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||qE.has(e)}function QE(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function $E(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:JE[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function eD(e,t){let n=t.defaultPrevented,r=!1,i=Object.create(t);return Object.defineProperties(i,{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>void 0},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,t.preventDefault()}},stopPropagation:{value:()=>{r=!0,t.stopPropagation()}}}),i}function tD(e){return KE.has(e)}function nD(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function rD(e,t){if(t===`tabIndex`){e.removeAttribute(`tabindex`);return}let n=e[t];if(typeof n==`boolean`){e[t]=!1;return}if(typeof n==`number`){e[t]=0;return}e[t]=``}function iD(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||WE.has(e)?String(t):`${t}px`}function aD(e,t){UE.has(t)||e.style.removeProperty(QE(t))}function oD(e,t,n){UE.has(t)||e.style.setProperty(QE(t),iD(t,n))}function sD(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(GE.has(r)||!ZE(r)||YE(r,t[r])||YE(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=XE(r);if(a==null||a===!1){tD(r)&&rD(e,r),e.removeAttribute(o);return}if(a===!0){tD(r)&&nD(e,r,!0),e.setAttribute(o,``);return}if(tD(r)){nD(e,r,a);return}e.setAttribute(o,String(a))})}function cD(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function lD(e,t,n){let r=t??{},i=n??{};new Set([...Object.keys(r),...Object.keys(i)]).forEach(t=>{let n=r[t],a=i[t];if(n!==a){if(a==null){aD(e,t);return}oD(e,t,a)}})}function uD(e,t,n){t.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)});let r=[];return Object.entries(n).forEach(([t,n])=>{if(!YE(t,n))return;let{eventName:i,options:a}=$E(t),o=t=>{n(eD(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function dD(e,t){let n=(0,Q.useRef)({}),r=(0,Q.useRef)([]);HE(()=>{let i=n.current;return cD(e,i.className,t.className),lD(e,i.style,t.style),sD(e,i,t),r.current=uD(e,r.current,t),n.current=t,()=>{r.current.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),r.current=[]}},[e,t])}var fD=Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:c,...l},u)=>{let d=(0,Q.useRef)(document.createElement(`div`)),f=(0,Q.useRef)(VE(e,`bubbleMenu`)).current;dD(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=se(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,getReferencedVirtualElement:o,options:s},g=(0,Q.useRef)(h);g.current=h;let[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(!0);return(0,Q.useEffect)(()=>{if(m?.isDestroyed)return;if(!m){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=d.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=RE({...g.current,editor:m,element:e});m.registerPlugin(t);let n=g.current.pluginKey;return y.current=!0,v(!0),()=>{v(!1),m.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[m]),(0,Q.useEffect)(()=>{if(!(!_||!m||m.isDestroyed)){if(y.current){y.current=!1;return}m.view.dispatch(m.state.tr.setMeta(f,{type:`updateOptions`,options:g.current}))}},[_,m,n,r,a,s,i,o,f]),(0,Au.createPortal)(c,d.current)});Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...c},l)=>{let u=(0,Q.useRef)(document.createElement(`div`)),d=(0,Q.useRef)(VE(e,`floatingMenu`)).current;dD(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=se(),p=t||f,m={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:a,options:o},h=(0,Q.useRef)(m);h.current=m;let[g,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(!0);return(0,Q.useEffect)(()=>{if(p?.isDestroyed)return;if(!p){console.warn(`FloatingMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=u.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=BE({...h.current,editor:p,element:e});p.registerPlugin(t);let n=h.current.pluginKey;return v.current=!0,_(!0),()=>{_(!1),p.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[p]),(0,Q.useEffect)(()=>{if(!(!g||!p||p.isDestroyed)){if(v.current){v.current=!1;return}p.view.dispatch(p.state.tr.setMeta(d,{type:`updateOptions`,options:h.current}))}},[g,p,n,r,a,o,i,d]),(0,Au.createPortal)(s,u.current)});var pD=[{name:`paragraph`,label:`Text`,icon:xd,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:Je,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:Qe,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:ht,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:Ne,isActive:e=>e.isActive(`list`,{ordered:!1})&&!e.isActive(`listItem`,{checked:!0})&&!e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleBulletList().run()},{name:`orderedList`,label:`Ordered List`,icon:Wt,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:dt,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:Ee,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:Md,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock({language:`js`}).run()}];function mD(e){let t=(0,$.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:hD},t[0]=n,t[1]=r);let{current:i,activeStates:a}=w(r),o=i.icon,s;t[2]===o?s=t[3]:(s=(0,Z.jsx)(o,{className:`size-3.5`}),t[2]=o,t[3]=s);let c;t[4]===i.label?c=t[5]:(c=(0,Z.jsx)(`span`,{children:i.label}),t[4]=i.label,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(so,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,Z.jsx)(qc,{asChild:!0,children:(0,Z.jsxs)(Di,{variant:`ghost`,size:`sm`,className:`gap-1 px-2 text-sm font-medium text-accent-foreground/80`,children:[s,c,l]})}),t[7]=s,t[8]=c,t[9]=u):u=t[9];let d;t[10]!==a||t[11]!==n?(d=pD.map(e=>{let t=e.icon,r=a[e.name];return(0,Z.jsxs)(Yc,{className:r?`bg-accent text-accent-foreground`:``,onSelect:()=>{e.command(n)},children:[(0,Z.jsx)(t,{className:`size-4`}),(0,Z.jsx)(`span`,{children:e.label})]},e.name)}),t[10]=a,t[11]=n,t[12]=d):d=t[12];let f;t[13]===d?f=t[14]:(f=(0,Z.jsx)(Zc,{align:`start`,sideOffset:8,className:`w-44 max-h-(--radix-dropdown-menu-content-available-height) overflow-y-auto subtle-scrollbar`,children:d}),t[13]=d,t[14]=f);let p;return t[15]!==u||t[16]!==f?(p=(0,Z.jsxs)(rl,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function hD(e){let t=Object.fromEntries(pD.map(t=>[t.name,t.isActive(e.editor)]));return{current:pD.find(e=>t[e.name])??pD[0],activeStates:t}}function gD(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toUpperCase();return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`}function _D(e){let t=(0,$.c)(2),{shortcutEnabled:n}=e,r=n===void 0?!1:n,i=dr(),a=es();if(!i||a)return null;let o;return t[0]===r?o=t[1]:(o=(0,Z.jsx)(vD,{shortcutEnabled:r}),t[0]=r,t[1]=o),o}function vD(e){let t=(0,$.c)(5),{shortcutEnabled:n}=e,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{let e=e=>{n&&Sl(e,`edit-with-ai`)&&(gD(e.target)||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),tu()))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},i=[n],t[0]=n,t[1]=r,t[2]=i),(0,Q.useEffect)(r,i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(sa,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[3]=a):a=t[3];let o;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsxs)(Z.Fragment,{children:[a,(0,Z.jsxs)(Di,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`edit-with-ai-bubble-button`,className:`gap-1 px-2 text-sm font-medium text-accent-foreground/80`,onClick:yD,children:[(0,Z.jsx)(Ws,{className:`size-3.5`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(X,{id:`xWEvuo`})})]})]}),t[4]=o):o=t[4],o}function yD(){return tu()}function bD(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(n!==`File`&&n!==`WikiEmbedFile`)return null;let r=(t.attrs.props??{}).src;return typeof r!=`string`||r.length===0?null:r}function xD(e){let t=e.state.selection.node;if(!t)return``;let n=t.attrs.props??{},r=typeof n.alias==`string`?n.alias:``;if(r.length>0)return r;let i=typeof n.name==`string`?n.name:``;return i.length>0?i:ft(typeof n.src==`string`?n.src:``)}function SD(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),n.remove()}function CD(e){let t=(0,$.c)(13),{editor:n}=e,{_:r}=cn(),i;if(t[0]===n?i=t[1]:(i={editor:n,selector:wD},t[0]=n,t[1]=i),w(i)===null)return null;let a;t[2]===r?a=t[3]:(a=r({id:`WcWS__`}),t[2]=r,t[3]=a);let o;t[4]===n?o=t[5]:(o=e=>{e.preventDefault();let t=bD(n);t&&SD(t,xD(n))},t[4]=n,t[5]=o);let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(Pa,{className:`size-3.5`}),t[6]=s):s=t[6];let c;t[7]!==a||t[8]!==o?(c=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,"aria-label":a,className:`text-accent-foreground`,onMouseDown:o,children:s})}),t[7]=a,t[8]=o,t[9]=c):c=t[9];let l;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(mc,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(X,{id:`WcWS__`})}),t[10]=l):l=t[10];let u;return t[11]===c?u=t[12]:(u=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:(0,Z.jsxs)(gc,{children:[c,l]})}),t[11]=c,t[12]=u),u}function wD(e){return bD(e.editor)}function TD(e){return bD(e)!==null}function ED(e){let t=e.schema.nodes;return!!(t.footnoteReference&&t.footnoteDefinition)}function DD(e){let{from:t,to:n}=e.state.selection,r=!1;return e.state.doc.nodesBetween(t,n,e=>e.type.name===`footnoteReference`?(r=!0,!1):!0),r}function OD(e){let{$from:t,$to:n}=e.state.selection;return!t.sameParent(n)}function kD(e){let t=(0,$.c)(21),{editor:n}=e,{_:r}=cn(),i;t[0]===n?i=t[1]:(i={editor:n,selector:AD},t[0]=n,t[1]=i);let a=w(i),o;t[2]!==a||t[3]!==n?(o=()=>{if(a||!ED(n)||n.state.selection.empty||OD(n)||DD(n))return;let{from:e,to:t}=n.state.selection,r=n.state.doc.textBetween(e,t,` `);if(!r.trim())return;let i=li(Er(n.state.doc)),o=Vr(n.state.doc)+1-(t-e);n.chain().focus().deleteSelection().insertFootnoteReference(i).insertContentAt(o,{type:`footnoteDefinition`,attrs:{identifier:i,label:i},content:[{type:`paragraph`,content:[{type:`text`,text:r}]}]}).run()},t[2]=a,t[3]=n,t[4]=o):o=t[4];let s=o,c;t[5]===r?c=t[6]:(c=r({id:`sIGbBZ`}),t[5]=r,t[6]=c);let l;t[7]===s?l=t[8]:(l=e=>{e.preventDefault(),s()},t[7]=s,t[8]=l);let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(Mt,{className:`size-3.5`,"aria-hidden":`true`}),t[9]=u):u=t[9];let d;t[10]!==a||t[11]!==c||t[12]!==l?(d=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{type:`button`,variant:`ghost`,size:`icon-xs`,"data-testid":`footnote-bubble-button`,className:`text-accent-foreground/80`,"aria-label":c,onMouseDown:l,disabled:a,children:u})}),t[10]=a,t[11]=c,t[12]=l,t[13]=d):d=t[13];let f;t[14]===r?f=t[15]:(f=r({id:`sIGbBZ`}),t[14]=r,t[15]=f);let p;t[16]===f?p=t[17]:(p=(0,Z.jsx)(mc,{side:`bottom`,sideOffset:8,children:f}),t[16]=f,t[17]=p);let m;return t[18]!==d||t[19]!==p?(m=(0,Z.jsxs)(gc,{children:[d,p]}),t[18]=d,t[19]=p,t[20]=m):m=t[20],m}function AD(e){let t=e.editor;return!!(!ED(t)||t.state.selection.empty||OD(t)||DD(t))}var jD=`img, .ok-embed, .ok-video`,MD=220,ND=`cubic-bezier(0.23, 1, 0.32, 1)`,PD=`ok-image-align-flip`,FD=.5;function ID(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function LD(){return typeof requestAnimationFrame==`function`}function RD(e){return e?e.querySelector(jD):null}function zD(e,t){if(ID()||!LD()){t();return}let n=RD(e);if(!n){t();return}let r=n.getBoundingClientRect().left;t(),requestAnimationFrame(()=>{let t=RD(e);if(!t)return;for(let e of t.getAnimations())e.id===PD&&e.cancel();let n=r-t.getBoundingClientRect().left;if(Math.abs(n)<FD)return;let i=t.animate([{transform:`translateX(${n}px)`},{transform:`translateX(0)`}],{duration:MD,easing:ND,fill:`none`});i.id=PD})}var BD=[{value:`left`,label:`Align left`,icon:Hd},{value:`center`,label:`Align center`,icon:Bd},{value:`right`,label:`Align right`,icon:Vd}];function VD(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(!Kt.has(String(n)))return null;let r=(t.attrs.props??{}).align;return r===`left`||r===`right`||r===`center`?r:`center`}function HD(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:UD},t[0]=n,t[1]=r);let i=w(r);if(i===null)return null;let a;t[2]!==i||t[3]!==n?(a=BD.map(e=>{let{value:t,label:r,icon:a}=e,o=i===t;return(0,Z.jsxs)(gc,{children:[(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,"aria-label":r,"aria-pressed":o,className:o?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:e=>{e.preventDefault();let r=n.state.selection,i=r.node;if(!i||i.type.name!==`jsxComponent`)return;let a=String(i.attrs.componentName??``);if(!Kt.has(a)||i.attrs.kind!==`element`)return;let o=a===`CommonMarkImage`,s=r.from,c={...i.attrs.props??{},align:t},l=o?{...i.attrs,componentName:`img`,props:c,sourceDirty:!0}:{...i.attrs,props:c,sourceDirty:!0},u=n.state.tr.setNodeMarkup(s,null,l);u.setSelection(Xr.create(u.doc,s)),zD(n.view.nodeDOM(s),()=>{n.view.dispatch(u)})},children:(0,Z.jsx)(a,{className:`size-3.5`})})}),(0,Z.jsx)(mc,{side:`bottom`,sideOffset:8,children:r})]},t)}),t[2]=i,t[3]=n,t[4]=a):a=t[4];let o;return t[5]===a?o=t[6]:(o=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:a}),t[5]=a,t[6]=o),o}function UD(e){return VD(e.editor)}function WD(e){return VD(e)!==null}var GD=[{name:`bold`,icon:Ou,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcutId:`format-bold`},{name:`italic`,icon:id,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcutId:`format-italic`},{name:`underline`,icon:Gd,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcutId:`format-underline`},{name:`strikethrough`,icon:Ld,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcutId:`format-strike`},{name:`code`,icon:ie,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcutId:`format-inline-code`},{name:`highlight`,icon:nd,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcutId:`format-highlight`}];function KD(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:qD},t[0]=n,t[1]=r);let i=w(r),a;t[2]!==i||t[3]!==n?(a=GD.map(e=>{let t=e.icon,r=i[e.name];return(0,Z.jsxs)(gc,{children:[(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,"aria-label":e.name,className:r?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:t=>{t.preventDefault(),e.command(n)},children:(0,Z.jsx)(t,{className:`size-3.5`})})}),(0,Z.jsxs)(mc,{side:`bottom`,sideOffset:8,children:[(0,Z.jsx)(`span`,{className:`capitalize`,children:e.name}),(0,Z.jsx)(Dt,{"aria-label":Cl(e.shortcutId),children:xl(e.shortcutId)})]})]},e.name)}),t[2]=i,t[3]=n,t[4]=a):a=t[4];let o;return t[5]===a?o=t[6]:(o=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:a}),t[5]=a,t[6]=o),o}function qD(e){return Object.fromEntries(GD.map(t=>[t.name,t.isActive(e.editor)]))}function JD(e){let t=(0,$.c)(66),{editor:n}=e,{_:r}=cn(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),c=(0,Q.useRef)(null),{folderPaths:l,loading:u,pages:d}=Oo(),f;t[0]===n?f=t[1]:(f=n.state.selection.empty&&n.isActive(`link`),t[0]=n,t[1]=f);let p=f,m;t[2]===n?m=t[3]:(m=n.getAttributes(`link`).href??``,t[2]=n,t[3]=m);let h=m,g;t[4]===n?g=t[5]:(g=function(){return n.state.selection.empty&&n.isActive(`link`)?n.getAttributes(`link`).href??``:``},t[4]=n,t[5]=g);let _=g,v,y;t[6]===n?(v=t[7],y=t[8]):(v=()=>{let e=function(){n.state.selection.empty&&a(!1)};return n.on(`selectionUpdate`,e),()=>{n.off(`selectionUpdate`,e)}},y=[n],t[6]=n,t[7]=v,t[8]=y),(0,Q.useEffect)(v,y);let b,x;t[9]===i?(b=t[10],x=t[11]):(b=()=>{i&&requestAnimationFrame(()=>c.current?.focus())},x=[i],t[9]=i,t[10]=b,t[11]=x),(0,Q.useEffect)(b,x);let S;t[12]!==n||t[13]!==p||t[14]!==o?(S=function(){o.trim()?n.chain().focus().setLink({href:o.trim()}).run():p&&n.chain().focus().unsetLink().run(),a(!1)},t[12]=n,t[13]=p,t[14]=o,t[15]=S):S=t[15];let C=S,w;t[16]===n?w=t[17]:(w=function(){n.chain().focus().unsetLink().run(),a(!1)},t[16]=n,t[17]=w);let T=w,E;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(E=function(e){s(Y(e.path,null))},t[18]=E):E=t[18];let D=E,O;t[19]!==C||t[20]!==n?(O=function(e){e.key===`Enter`&&(e.preventDefault(),C()),e.key===`Escape`&&(e.preventDefault(),a(!1),n.chain().focus().run())},t[19]=C,t[20]=n,t[21]=O):O=t[21];let k=O;if(i){let e;t[22]===r?e=t[23]:(e=r({id:`ZsGpr_`}),t[22]=r,t[23]=e);let n;t[24]===r?n=t[25]:(n=r({id:`roAe2K`}),t[24]=r,t[25]=n);let i;t[26]!==l||t[27]!==k||t[28]!==u||t[29]!==d||t[30]!==e||t[31]!==n||t[32]!==o?(i=(0,Z.jsx)(ot,{ref:c,type:`text`,placeholder:e,value:o,pages:d,folderPaths:l,loading:u,onValueChange:s,onSuggestionSelect:D,onKeyDown:k,"aria-label":n,className:`h-5 w-44 rounded-none border-none bg-transparent px-0 py-0 text-sm placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent`}),t[26]=l,t[27]=k,t[28]=u,t[29]=d,t[30]=e,t[31]=n,t[32]=o,t[33]=i):i=t[33];let a;t[34]===r?a=t[35]:(a=r({id:`tP5DDk`}),t[34]=r,t[35]=a);let f;t[36]===C?f=t[37]:(f=()=>{C()},t[36]=C,t[37]=f);let m;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(Vu,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[38]=m):m=t[38];let g;t[39]!==a||t[40]!==f?(g=(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,"aria-label":a,onClick:f,children:m}),t[39]=a,t[40]=f,t[41]=g):g=t[41];let _;t[42]!==i||t[43]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50`,children:[i,g]}),t[42]=i,t[43]=g,t[44]=_):_=t[44];let v;t[45]!==r||t[46]!==h||t[47]!==p||t[48]!==T?(v=p&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(gc,{children:[(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,"aria-label":r({id:`2vIPtm`}),onMouseDown:e=>{e.preventDefault(),on(h)},children:(0,Z.jsx)(za,{className:`size-3.5`})})}),(0,Z.jsx)(mc,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(X,{id:`2vIPtm`})})]}),(0,Z.jsxs)(gc,{children:[(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,"aria-label":r({id:`484LKL`}),onMouseDown:e=>{e.preventDefault(),T()},children:(0,Z.jsx)(vs,{className:`size-3.5`})})}),(0,Z.jsx)(mc,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(X,{id:`484LKL`})})]})]}),t[45]=r,t[46]=h,t[47]=p,t[48]=T,t[49]=v):v=t[49];let y;return t[50]!==_||t[51]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[_,v]}),t[50]=_,t[51]=v,t[52]=y):y=t[52],y}let A;t[53]===r?A=t[54]:(A=r({id:`p0Iq25`}),t[53]=r,t[54]=A);let j=p?`bg-accent text-primary`:`text-accent-foreground`,M;t[55]===_?M=t[56]:(M=e=>{e.preventDefault(),s(_()),a(!0)},t[55]=_,t[56]=M);let N;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(od,{className:`size-3.5`}),t[57]=N):N=t[57];let P;t[58]!==A||t[59]!==j||t[60]!==M?(P=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,"aria-label":A,className:j,onMouseDown:M,children:N})}),t[58]=A,t[59]=j,t[60]=M,t[61]=P):P=t[61];let F;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(X,{id:`yzF66j`}),t[62]=F):F=t[62];let I;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsxs)(mc,{side:`bottom`,sideOffset:8,children:[F,(0,Z.jsx)(Dt,{children:xl(`command-palette`)})]}),t[63]=I):I=t[63];let L;return t[64]===P?L=t[65]:(L=(0,Z.jsxs)(gc,{children:[P,I]}),t[64]=P,t[65]=L),L}function YD({editor:e}){if($e(e.state).query||e.isActive(`codeBlock`))return!1;if(WD(e)||TD(e))return!0;if(e.state.selection.empty)return!1;let{from:t,to:n}=e.state.selection;return!!e.state.doc.textBetween(t,n,` `).trim()}function XD(e){let t=(0,$.c)(23),{editor:n,shortcutEnabled:r}=e,i=r===void 0?!0:r,a=(0,Q.useRef)(null),[o,s]=(0,Q.useState)(0),c=(0,Q.useRef)(null),l;t[0]===n?l=t[1]:(l={editor:n,selector:tO},t[0]=n,t[1]=l);let u=w(l),d;t[2]===n?d=t[3]:(d={editor:n,selector:eO},t[2]=n,t[3]=d);let f=w(d),p;t[4]!==n.state||t[5]!==n.view?(p=()=>{try{let{from:e,to:t}=n.state.selection;return ci(n.view,e,t)}catch{return new DOMRect}},t[4]=n.state,t[5]=n.view,t[6]=p):p=t[6];let m;if(t[7]!==n.view.dom||t[8]!==p){let e={getBoundingClientRect:p,contextElement:n.view.dom};m=()=>{let t=a.current;t&&(c.current?.(),c.current=_c(e,t,()=>{Sc(e,t,{placement:`top`,strategy:`fixed`,middleware:[Tc(8),Dc(),Cc({padding:8})]}).then(e=>{let{x:n,y:r}=e;t.isConnected&&(t.style.position=`fixed`,t.style.left=`${n}px`,t.style.top=`${r}px`)}).catch($D)}))},t[7]=n.view.dom,t[8]=p,t[9]=m}else m=t[9];let h=m,g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{c.current?.(),c.current=null,s(QD)},t[10]=g):g=t[10];let _=g,v;t[11]===h?v=t[12]:(v={onShow:h,onHide:_,strategy:`fixed`},t[11]=h,t[12]=v);let y;t[13]!==n||t[14]!==f||t[15]!==u||t[16]!==i||t[17]!==o?(y=u?(0,Z.jsx)(HD,{editor:n},`${o}-img-align`):f?(0,Z.jsx)(CD,{editor:n},`${o}-file`):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(mD,{editor:n}),(0,Z.jsx)(sa,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(KD,{editor:n},o),(0,Z.jsx)(sa,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(JD,{editor:n},`${o}-link`),(0,Z.jsx)(kD,{editor:n},`${o}-footnote`),(0,Z.jsx)(_D,{editor:n,shortcutEnabled:i},`${o}-edit-ai`)]}),t[13]=n,t[14]=f,t[15]=u,t[16]=i,t[17]=o,t[18]=y):y=t[18];let b;return t[19]!==n||t[20]!==v||t[21]!==y?(b=(0,Z.jsx)(fD,{ref:a,editor:n,"data-testid":`bubble-menu-bar`,appendTo:ZD,shouldShow:YD,updateDelay:250,options:v,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:y}),t[19]=n,t[20]=v,t[21]=y,t[22]=b):b=t[22],b}function ZD(){return document.body}function QD(e){return e+1}function $D(){}function eO(e){return TD(e.editor)}function tO(e){return WD(e.editor)}var nO=56,rO=`0 2px 4px rgba(0, 0, 0, 0.08)`,iO=150,aO=globalThis.ScrollTimeline;function oO(e,t,n,r,i){let a=r-i;if(a<=0)return null;let o=e+n-(t+nO);return{startOffset:o,endOffset:o+a,maxShift:a}}var sO=new WeakMap;function cO(e){let t=sO.get(e);if(t){for(let e of t.animations)e.cancel();sO.delete(e)}}function lO(e){for(let t of Array.from(e.cells))cO(t)}var uO=e=>e.cellIndex===0?`3`:`2`;function dO(e,t){return fO(e,t,e=>({transform:`translateY(${e}px)`}))}function fO(e,t,n){if(!(t>0))return[{offset:0,...n(0)},{offset:1,...n(0)}];let r=t=>Math.max(0,Math.min(t-e.startOffset,e.maxShift));return Array.from(new Set([0,e.startOffset/t,e.endOffset/t,1].map(e=>Math.max(0,Math.min(e,1))))).sort((e,t)=>e-t).map(e=>({offset:e,...n(r(e*t))}))}function pO(e,t,n,r){if(!(t>0))return[{...n,offset:0},{...n,offset:1}];let i=e.startOffset/t;if(i<=0)return[{...r,offset:0},{...r,offset:1}];if(i>=1)return[{...n,offset:0},{...n,offset:1}];let a=Math.min(i+1/t,1);return[{...n,offset:0},{...n,offset:i},{...r,offset:a},{...r,offset:1}]}function mO(e,t,n){return pO(e,t,{zIndex:`auto`,boxShadow:`none`},{zIndex:n,boxShadow:rO})}function hO(e,t){return pO(e,t,{opacity:`0`},{opacity:`1`})}function gO(e,t,n,r){let i=uO(e),a=`sd|${n.startOffset}|${n.maxShift}|${r}|${i}`,o=sO.get(e);if(o?.key===a)return;if(o)for(let e of o.animations)e.cancel();let s={timeline:t,fill:`both`,easing:`linear`},c=e.animate(dO(n,r),s),l=e.animate(mO(n,r,i),s),u=e.animate(hO(n,r),{...s,pseudoElement:`::before`});sO.set(e,{key:a,animations:[c,l,u]})}function _O(e,t){let n=uO(e),r=`in|${t}|${n}`,i=sO.get(e);if(i?.key===r)return;if(i)for(let e of i.animations)e.cancel();let a=e.animate([{transform:`translateY(${t}px)`,zIndex:n,boxShadow:rO}],{duration:0,fill:`forwards`}),o=e.animate([{opacity:`1`}],{duration:0,fill:`forwards`,pseudoElement:`::before`});sO.set(e,{key:r,animations:[a,o]})}function vO(e,t,n,r){let i=e.getBoundingClientRect().top,a=e.scrollTop,o=e.scrollHeight-e.clientHeight,s=t.querySelectorAll(`.tableWrapper`);for(let e of s){r?.(e);let t=e.querySelector(`table`);if(!t)continue;let s=t.querySelector(`tbody`)?.rows[0];if(!s||!Array.from(s.cells).some(e=>e.tagName===`TH`))continue;let c=t.getBoundingClientRect(),l=s.getBoundingClientRect(),u=oO(a,i,c.top,c.height,l.height);if(!u){lO(s);continue}if(n){if(o<=0){lO(s);continue}for(let e of Array.from(s.cells))gO(e,n,u,o);continue}let d=Math.max(0,Math.min(a-u.startOffset,u.maxShift));if(d<=0||c.bottom<=i+nO){lO(s);continue}for(let e of Array.from(s.cells))_O(e,d)}}var yO=Si.create({name:`frozenTableHeaders`,addProseMirrorPlugins(){return[new ui({key:new Fr(`frozenTableHeaders`),view(e){let t=null,n=null,r=null,i=null,a=null,o=!1,s=new Set,c=()=>{o||!t||vO(t,e.dom,n,u)},l=()=>{r??=requestAnimationFrame(()=>{r=null,c()})};function u(e){s.has(e)||(s.add(e),e.addEventListener(`contentvisibilityautostatechange`,l))}let d=()=>{if(n){i??l(),i!=null&&clearTimeout(i),i=setTimeout(()=>{i=null,c()},iO);return}l()};return requestAnimationFrame(()=>{if(!o){if(t=e.dom.closest(`[data-testid="editor-scroll-container"]`),t&&aO)try{n=new aO({source:t,axis:`block`})}catch{n=null}t?.addEventListener(`scroll`,d,{passive:!0}),t&&typeof ResizeObserver<`u`&&(a=new ResizeObserver(l),a.observe(t),a.observe(e.dom)),c()}}),{update(e,t){t.doc.eq(e.state.doc)||c()},destroy(){o=!0,t?.removeEventListener(`scroll`,d),a?.disconnect(),r!=null&&cancelAnimationFrame(r),i!=null&&clearTimeout(i);for(let e of s)e.removeEventListener(`contentvisibilityautostatechange`,l);s.clear();for(let t of e.dom.querySelectorAll(`.tableWrapper > table > tbody > tr:first-child`))lO(t)}}}})]}}),bO=`application/x-open-knowledge-sidebar-item+json`,xO={image:!0,video:!0,audio:!0,pdf:!0,text:!0};function SO(e){return JSON.stringify(e)}function CO(e){return e.kind===`folder`?{target:{kind:`folder`,target:e.folderPath,folderPath:e.folderPath},hash:lo(e.folderPath)}:e.kind===`asset`?{target:{kind:`asset`,target:e.assetPath,assetPath:e.assetPath,mediaKind:e.mediaKind},hash:yo(e.assetPath)}:{target:Fo(e.docName,e.size)??{kind:`doc`,target:e.docName,docName:e.docName},hash:Ao(e.docName)}}function wO(e){if(!e||!Array.from(e.types).includes(`application/x-open-knowledge-sidebar-item+json`))return null;let t=e.getData(bO);if(!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!TO(n)||n.v!==1||typeof n.kind!=`string`)return null;if(n.kind===`doc`){if(typeof n.docName!=`string`||n.docName.length===0)return null;let e=n.size;return e!==null&&typeof e!=`number`?null:{v:1,kind:`doc`,docName:n.docName,size:e}}if(n.kind===`folder`)return typeof n.folderPath==`string`?{v:1,kind:`folder`,folderPath:n.folderPath}:null;if(n.kind===`asset`){if(typeof n.assetPath!=`string`||n.assetPath.length===0)return null;let e=n.mediaKind;return e!==null&&!EO(e)?null:{v:1,kind:`asset`,assetPath:n.assetPath,mediaKind:e}}return null}function TO(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function EO(e){return typeof e==`string`&&Object.hasOwn(xO,e)}function DO(e,t){return(n,r)=>{let i=r,a=wO(i.dataTransfer);return a?(i.preventDefault(),t?.(a),!0):e(n,i)}}function OO(e,t){let n=CO(e);t(n.target,{tabBehavior:`append`}),vo(n.hash)}function kO(e){return[...e?[{label:`Toggle header column`,icon:zu,run:e=>e.chain().focus().toggleHeaderColumn().run()}]:[],{label:`Insert column left`,icon:Mi,run:e=>e.chain().focus().addColumnBefore().run()},{label:`Insert column right`,icon:La,run:e=>e.chain().focus().addColumnAfter().run()},{label:`Delete column`,icon:vs,separatorBefore:!0,run:e=>e.chain().focus().deleteColumn().run()},{label:`Delete table`,icon:$u,run:e=>e.chain().focus().deleteTable().run()}]}function AO(e){return[...e?[{label:`Toggle header row`,icon:Rd,run:e=>e.chain().focus().toggleHeaderRow().run()}]:[],{label:`Insert row above`,icon:R,run:e=>e.chain().focus().addRowBefore().run()},{label:`Insert row below`,icon:B,run:e=>e.chain().focus().addRowAfter().run()},{label:`Delete row`,icon:vs,separatorBefore:!0,run:e=>e.chain().focus().deleteRow().run()},{label:`Delete table`,icon:$u,run:e=>e.chain().focus().deleteTable().run()}]}function jO(e){if(!e.isEditable||$e(e.state).query)return null;let{state:t,view:n}=e,r=t.selection.$from,i=-1;for(let e=r.depth;e>0;e--){let t=r.node(e).type.spec.tableRole;if(t===`cell`||t===`header_cell`){i=r.before(e);break}}if(i<0)return null;let a=n.nodeDOM(i);if(!(a instanceof HTMLTableCellElement))return null;let o=a.closest(`table`),s=a.closest(`tr`),c=a.closest(`.ProseMirror`);if(!o||!s||!c)return null;let l=Array.prototype.indexOf.call(o.rows,s),u=a.cellIndex,d=o.rows[0]?.cells[u],f=o.rows[l]?.cells[0];return!d||!f?null:{columnAnchor:d,rowAnchor:f,isFirstColumn:u===0,isFirstRow:l===0}}function MO(e){let t=(0,$.c)(22),{editor:n,anchor:r,axis:i,items:a}=e,o=(0,Q.useRef)(null),s,c;t[0]!==r||t[1]!==i?(s=()=>{let e=o.current;if(!e)return;let t=i===`column`?`top`:`left`,n=i===`column`?-14:-6;return _c(r,e,()=>{Sc(r,e,{strategy:`absolute`,placement:t,middleware:[Tc(n)]}).then(t=>{let{x:n,y:r}=t;e.style.left=`${n}px`,e.style.top=`${r}px`,e.style.opacity=`1`}).catch(NO)})},c=[r,i],t[0]=r,t[1]=i,t[2]=s,t[3]=c):(s=t[2],c=t[3]),(0,Q.useEffect)(s,c);let l=i===`column`?Uu:oa,u=i===`column`?`h-3 w-7 rounded-full p-0 text-gray-700 dark:text-muted-foreground bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 hover:text-foreground dark:hover:bg-gray-600 dark:hover:text-gray-100 relative before:absolute before:-inset-[6px] before:content-[""]`:`h-7 w-3 rounded-full p-0 text-gray-700 dark:text-muted-foreground bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 hover:text-foreground dark:hover:bg-gray-600 dark:hover:text-gray-100 relative before:absolute before:-inset-[6px] before:content-[""]`,d=i===`column`?`Column options`:`Row options`,f;t[4]===l?f=t[5]:(f=(0,Z.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),t[4]=l,t[5]=f);let p;t[6]!==u||t[7]!==d||t[8]!==f?(p=(0,Z.jsx)(qc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`secondary`,className:u,"aria-label":d,children:f})}),t[6]=u,t[7]=d,t[8]=f,t[9]=p):p=t[9];let m=i===`column`?`center`:`start`,h=i===`column`?`bottom`:`right`,g;if(t[10]!==n||t[11]!==a){let e;t[13]===n?e=t[14]:(e=e=>(0,Z.jsxs)(Q.Fragment,{children:[e.separatorBefore&&(0,Z.jsx)(cl,{}),(0,Z.jsxs)(Yc,{onSelect:()=>e.run(n),children:[(0,Z.jsx)(e.icon,{"aria-hidden":!0}),e.label]})]},e.label),t[13]=n,t[14]=e),g=a.map(e),t[10]=n,t[11]=a,t[12]=g}else g=t[12];let _;t[15]!==m||t[16]!==h||t[17]!==g?(_=(0,Z.jsx)(Zc,{align:m,side:h,className:`w-auto min-w-44 whitespace-nowrap`,children:g}),t[15]=m,t[16]=h,t[17]=g,t[18]=_):_=t[18];let v;return t[19]!==_||t[20]!==p?(v=(0,Z.jsx)(`div`,{ref:o,"data-testid":`table-cell-handle`,className:`absolute left-0 top-0 z-10 opacity-0`,children:(0,Z.jsxs)(rl,{children:[p,_]})}),t[19]=_,t[20]=p,t[21]=v):v=t[21],v}function NO(){}function PO(e){let t=(0,$.c)(18),{editor:n}=e,[r,i]=(0,Q.useState)(null),a,o;if(t[0]===n?(a=t[1],o=t[2]):(a=()=>{let e=()=>i(e=>{let t=jO(n);return e&&t&&e.columnAnchor===t.columnAnchor&&e.rowAnchor===t.rowAnchor?e:t});return e(),n.on(`selectionUpdate`,e),n.on(`update`,e),()=>{n.off(`selectionUpdate`,e),n.off(`update`,e)}},o=[n],t[0]=n,t[1]=a,t[2]=o),(0,Q.useEffect)(a,o),!r)return null;let s=r.columnAnchor,c;t[3]===r.isFirstColumn?c=t[4]:(c=kO(r.isFirstColumn),t[3]=r.isFirstColumn,t[4]=c);let l;t[5]!==r.columnAnchor||t[6]!==n||t[7]!==c?(l=(0,Z.jsx)(MO,{editor:n,anchor:s,axis:`column`,items:c}),t[5]=r.columnAnchor,t[6]=n,t[7]=c,t[8]=l):l=t[8];let u=r.rowAnchor,d;t[9]===r.isFirstRow?d=t[10]:(d=AO(r.isFirstRow),t[9]=r.isFirstRow,t[10]=d);let f;t[11]!==r.rowAnchor||t[12]!==n||t[13]!==d?(f=(0,Z.jsx)(MO,{editor:n,anchor:u,axis:`row`,items:d}),t[11]=r.rowAnchor,t[12]=n,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==l||t[16]!==f?(p=(0,Z.jsxs)(`div`,{className:`ok-table-cell-handle-layer`,children:[l,f]}),t[15]=l,t[16]=f,t[17]=p):p=t[17],p}function FO(e){let{fragment:t,docName:n}=e,r=!1,i=!1,a=!1,o=()=>{r=!0},s=e=>{console.warn(`[walk-currency] ${e} at view init — stale pre-warm cannot be invalidated: a remote edit that landed in the construct→mount gap will not render, and the first local transaction may silently erase it from the CRDT for every peer and disk (vendored y-tiptap contract change? re-verify y-tiptap.cjs:263-268)`)},c=()=>{i&&(i=!1,t.unobserveDeep(o))},l=e=>{let t=y.getState(e.state)?.binding;if(!t){Ot.count(`ok/editor/walk-currency-disarmed`,{docName:n,reason:`no-binding`}),s(`no ySync binding on "${n}"`);return}if(typeof t._forceRerender!=`function`){Ot.count(`ok/editor/walk-currency-disarmed`,{docName:n,reason:`no-force-rerender`}),s(`ySync binding on "${n}" exposes no _forceRerender`);return}Ot.count(`ok/editor/pattern-d-stale-prewarm`,{docName:n}),t._forceRerender()};return Si.create({name:`walkCurrency`,onBeforeCreate(){t.observeDeep(o),i=!0},onDestroy(){c()},addProseMirrorPlugins(){return[new ui({view:e=>(a||(a=!0,c(),r&&l(e)),{})})]}})}var IO=new WeakMap;function LO(e){let t=document.createElement(`span`);t.classList.add(`collaboration-cursor__caret`),t.style.borderColor=e.color;let n=document.createElement(`div`);return n.classList.add(`collaboration-cursor__label`),n.style.backgroundColor=e.color,n.style.color=di(e.color),n.textContent=e.name,t.append(n),t}var RO={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null},zO=100,BO=100,VO=3,HO=250;function UO(e){return`contentComponent`in e&&`isEditorContentInitialized`in e}function WO(e,t){let n=fe(e);if(!n||t.contains(n.dom))return!1;if(!UO(e))return console.warn(`[TiptapEditor] TipTap EditorContent binding fields missing; detached editor repair skipped`),!1;let r=e;if(r.contentComponent==null)return!1;try{n.setProps({nodeViews:{}})}catch{}return r.contentComponent=null,r.isEditorContentInitialized=!1,!0}function GO(){let e=new ir({extensions:mi});return{mdManager:e,text:Vt({mdManager:e}),html:Ve({mdManager:e}),paste:rt({mdManager:e}),drop:Nt({mdManager:e})}}function KO(e,t){return t?{collaboration:it.configure({document:e.document,ySyncOptions:{mapping:t}}),guard:[FO({fragment:e.document.getXmlFragment(`default`),docName:e.configuration.name??``})]}:{collaboration:it.configure({document:e.document}),guard:[]}}function qO(e){let{provider:t,placeholder:n,prebuiltMapping:r,onWedged:i}=e,{collaboration:a,guard:o}=KO(t,r);return[...Ct.map(e=>e.name===`link`||e.name===`wikiLink`||e.name===`jsxComponent`?e.configure({docName:t.configuration.name??``}):e),DS.configure({placeholder:n??`Type '/' for commands`,showOnlyCurrent:!0}),a,Si.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[Ge]}}),Si.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=t.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[re(e,{cursorBuilder:LO})]}}),Si.create({name:`bindingStalenessGuard`,addProseMirrorPlugins(){return[FE({fragment:t.document.getXmlFragment(`default`),docName:t.configuration.name??``,onWedged:i??(()=>{})})]}}),...o,yO]}function JO(e){let{provider:t,clipboard:n,ctorStart:r}=e;return{onBeforeCreate:({editor:e})=>{IO.set(e,r)},onCreate:({editor:e})=>{n.html.setView(e.view);let r=IO.get(e);if(IO.delete(e),r==null)return;let i=performance.now();Ot(`ok/editor/create-tiptap`,{docName:t.configuration.name??`unknown`,ytextLength:t.document.getText(`source`).length},{startTime:r,duration:Math.max(0,i-r)})},editorProps:{attributes:{class:`pt-4 pb-4 h-full`},clipboardTextParser:(e,t,r,i)=>{let a=n.mdManager.parse(e);return i.state.schema.nodeFromJSON(a).content},clipboardTextSerializer:(e,t)=>n.text(e,t),clipboardSerializer:n.html.serializer,handlePaste:(e,t)=>n.paste(e,t),handleDrop:DO(n.drop,e.onSidebarDrop)},extensions:kh(qO(e))}}function YO(e){let{provider:t,placeholder:n,clipboard:r,ctorStart:i,onWedged:a,onSidebarDrop:o}=e,s=t.document.getXmlFragment(`default`),c=new Map,l=JO({provider:t,placeholder:n,clipboard:r,ctorStart:i,prebuiltMapping:c,onWedged:a,onSidebarDrop:o}),u=l.onBeforeCreate;return{...l,onBeforeCreate:e=>{u?.(e);let{editor:t}=e,{doc:n,mapping:r}=Xt(s,t.schema);r.forEach((e,t)=>{c.set(t,e)}),t.options.content=n.toJSON()},element:null}}var XO=e=>{let t=(0,$.c)(24),{provider:n,placeholder:r,isSourceMode:i,portalTarget:a}=e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(RO),c=TE(),{principal:l,activeDocName:u,recycleDocument:d,openTarget:f}=_t(),p=n.configuration.name??``,[m]=(0,Q.useState)(GO),h;t[0]!==m||t[1]!==p||t[2]!==f||t[3]!==r||t[4]!==n||t[5]!==d?(h=()=>()=>({editor:new mr(YO({provider:n,placeholder:r,clipboard:m,ctorStart:performance.now(),onWedged:e=>{let{externalSeq:t,appliedSeq:n}=e;Ot(`ok/editor/binding-wedge-recycle`,{docName:p,externalSeq:t,appliedSeq:n}),d(p)},onSidebarDrop:e=>{OO(e,f)}})),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}),t[0]=m,t[1]=p,t[2]=f,t[3]=r,t[4]=n,t[5]=d,t[6]=h):h=t[6];let[g]=(0,Q.useState)(h),_,v;if(t[7]!==g||t[8]!==p||t[9]!==n.document){let e={viewCount:0,bytes:n.document.getText(`source`).length},r=de(p)??crypto.randomUUID();_=Q.use,v=ee({docName:p,mountId:r,construct:g,sizeStats:e}),t[7]=g,t[8]=p,t[9]=n.document,t[10]=_,t[11]=v}else _=t[10],v=t[11];let y=_(v),b=y.editor,x,S;t[12]===y?(x=t[13],S=t[14]):(x=()=>()=>{z(y)},S=[y],t[12]=y,t[13]=x,t[14]=S),(0,Q.useEffect)(x,S);let C;return t[15]!==u||t[16]!==p||t[17]!==b||t[18]!==c||t[19]!==i||t[20]!==a||t[21]!==l||t[22]!==n?(C=(0,Z.jsx)(ZO,{provider:n,isSourceMode:i,docName:p,activeDocName:u,identity:c,principal:l,editor:b,wrapperRef:o,flashStateRef:s,portalTarget:a}),t[15]=u,t[16]=p,t[17]=b,t[18]=c,t[19]=i,t[20]=a,t[21]=l,t[22]=n,t[23]=C):C=t[23],C},ZO=e=>{let t=(0,$.c)(98),{provider:n,isSourceMode:r,docName:i,activeDocName:a,identity:o,principal:s,editor:c,wrapperRef:l,flashStateRef:u,portalTarget:f}=e,p=(0,Q.useRef)(null),[m,h]=(0,Q.useState)(0),g,_;t[0]===f?(g=t[1],_=t[2]):(g=()=>{let e=p.current;if(e)return e.appendChild(f),()=>{f.parentNode===e&&e.removeChild(f)}},_=[f],t[0]=f,t[1]=g,t[2]=_),(0,Q.useLayoutEffect)(g,_);let v,y;t[3]!==c||t[4]!==f?(v=()=>{WO(c,f)&&h(QO)},y=[c,f],t[3]=c,t[4]=f,t[5]=v,t[6]=y):(v=t[5],y=t[6]),(0,Q.useEffect)(v,y);let b;t[7]!==c||t[8]!==n.configuration.name?(b=()=>(gt(c,n.configuration.name??null),()=>{gt(c,null)}),t[7]=c,t[8]=n.configuration.name,t[9]=b):b=t[9];let x;t[10]!==c||t[11]!==n?(x=[c,n],t[10]=c,t[11]=n,t[12]=x):x=t[12],(0,Q.useEffect)(b,x);let S;t[13]!==c||t[14]!==n.configuration.name?(S=()=>{let e=n.configuration.name;if(e)return me(e,c),()=>F(e,c)},t[13]=c,t[14]=n.configuration.name,t[15]=S):S=t[15];let C;t[16]!==c||t[17]!==n?(C=[c,n],t[16]=c,t[17]=n,t[18]=C):C=t[18],(0,Q.useEffect)(S,C);let w;t[19]!==c||t[20]!==n.configuration.name?(w=()=>{let e=n.configuration.name;if(!e)return;let t=null,r=()=>{t=null,Jl(e,`wysiwyg`,Zl(c)),su(e,`wysiwyg`,cu(c,e))},i=()=>{t&&clearTimeout(t),t=setTimeout(r,120)};return r(),c.on(`selectionUpdate`,i),c.on(`update`,i),()=>{t&&clearTimeout(t),c.off(`selectionUpdate`,i),c.off(`update`,i),Jl(e,`wysiwyg`,null),su(e,`wysiwyg`,null)}},t[19]=c,t[20]=n.configuration.name,t[21]=w):w=t[21];let T;t[22]!==c||t[23]!==n?(T=[c,n],t[22]=c,t[23]=n,t[24]=T):T=t[24],(0,Q.useEffect)(w,T);let E;t[25]!==c||t[26]!==n.configuration.name?(E=()=>{},t[25]=c,t[26]=n.configuration.name,t[27]=E):E=t[27];let D;t[28]!==c||t[29]!==n?(D=[c,n],t[28]=c,t[29]=n,t[30]=D):D=t[30],(0,Q.useEffect)(E,D);let O,k;t[31]===c?(O=t[32],k=t[33]):(O=()=>{let e=$O,t=null,n=()=>{if(t||c.isDestroyed)return;let n=fe(c);n&&(t=n.dom,t.addEventListener(`keydown`,e),t.addEventListener(`paste`,e),t.addEventListener(`drop`,e),t.addEventListener(`cut`,e))},r=()=>{t&&=(t.removeEventListener(`keydown`,e),t.removeEventListener(`paste`,e),t.removeEventListener(`drop`,e),t.removeEventListener(`cut`,e),null)};return fe(c)?n():c.on(`create`,n),()=>{c.off(`create`,n),r()}},k=[c],t[31]=c,t[32]=O,t[33]=k),(0,Q.useEffect)(O,k);let A,j;t[34]!==i||t[35]!==c?(A=()=>{let e=!1,t=()=>{if(e||c.isDestroyed||!fe(c))return;e=!0;let t=V(i)?.selection??null;if(t)try{let e=c.state.doc.content.size;if(t.type===`text`){let n=Math.max(0,Math.min(t.anchor,e)),r=Math.max(0,Math.min(t.head,e));c.commands.setTextSelection({from:n,to:r})}else{let n=Math.max(0,Math.min(t.from,e));c.commands.setNodeSelection(n)}}catch(e){let t=e,n=t instanceof Error?t.message:String(t);console.warn(JSON.stringify({event:`ok-editor-selection-restore-failed`,docName:i,message:n})),Ot(`ok/editor/selection-restore-failed`,{docName:i,message:n})}ct(i)};if(fe(c)){t();return}return c.on(`create`,t),()=>{c.off(`create`,t)}},j=[c,i],t[34]=i,t[35]=c,t[36]=A,t[37]=j):(A=t[36],j=t[37]),(0,Q.useEffect)(A,j);let M,N;t[38]!==u||t[39]!==n.document||t[40]!==l?(M=()=>{let e=n.document.getMap(`agent-flash`),t=Date.now(),r=0,i=null,a=null,o=null,s=()=>{let t=null;for(let[,n]of e.entries()){let e=n;e.timestamp&&(!t||e.timestamp>t.timestamp)&&(t={agentId:e.agentId??`unknown`,timestamp:e.timestamp,type:e.type??`insert`,description:e.description})}return t},c=e=>{u.current=e;let t=l.current;t&&(t.setAttribute(`data-agent-flash-state`,e.state),t.setAttribute(`data-agent-flash-count`,String(e.count)),t.setAttribute(`data-agent-flash-position`,e.position),t.setAttribute(`data-agent-flash-agent-id`,e.lastAgentId??``))},d=()=>{let e=s(),t=e?.description?.toLowerCase().includes(`prepend`)?`prepend`:`append`,n={state:`editing`,count:(u.current?.count??0)+1,lastFiredAt:Date.now(),position:t,lastAgentId:e?.agentId??null};c(n),document.dispatchEvent(new CustomEvent(`agent-flash`,{detail:n})),a&&clearTimeout(a),o&&clearTimeout(o),a=window.setTimeout(()=>{let e={...n,state:`settled`};c(e),document.dispatchEvent(new CustomEvent(`agent-flash-end`,{detail:e})),o=window.setTimeout(()=>{c({...e,state:`idle`})},300)},Vn)};c(RO);let f=()=>{if(zr(e),!gi(e,t)||document.visibilityState!==`visible`)return;let n=Date.now();if(t=n,n-r<500){if(!i){let e=500-(n-r);i=window.setTimeout(()=>{i=null,r=Date.now(),d()},e)}return}r=n,d()};e.observe(f);let p=()=>{document.visibilityState===`visible`?gi(e,t)&&(t=Date.now(),r=Date.now(),d()):t=Date.now()};return document.addEventListener(`visibilitychange`,p),()=>{e.unobserve(f),document.removeEventListener(`visibilitychange`,p),i&&clearTimeout(i),a&&clearTimeout(a),o&&clearTimeout(o)}},N=[n.document,u,l],t[38]=u,t[39]=n.document,t[40]=l,t[41]=M,t[42]=N):(M=t[41],N=t[42]),(0,Q.useEffect)(M,N);let P,I;t[43]!==a||t[44]!==i||t[45]!==c||t[46]!==n?(P=()=>{let e=0,t,r=null,o=null,s=null,l=function(){if(e<zO){e+=1,t=window.setTimeout(p,BO);return}r=null,o=null,e=0},u=function(e){let t=fe(c);if(!t)return null;let n=CSS.escape(e);return t.dom.querySelector(`#${n}`)??t.dom.querySelector(`[data-mirror-source-id="${n}"]`)},d=function(e){let t=u(e);return t?(t.scrollIntoView({behavior:`smooth`,block:`start`}),!0):!1},f=function(e,n){let r=VO,o=()=>{t=void 0,!(i!==a||window.location.hash!==n)&&(d(e),--r,r>0&&(t=window.setTimeout(o,HO)))};t=window.setTimeout(o,HO)};function p(){if(!r||i!==a)return;let t=r,n=o;if(!n){l();return}d(t)?(s=n,r=null,o=null,e=0,f(t,n)):l()}let m=function(){if(i!==a)return;let n=window.location.hash;if(!r&&s===n)return;let c=uo(n);if(!c){s=n;return}r=c,o=n,e=0,t!==void 0&&(clearTimeout(t),t=void 0),p()},h=function(){if(i===a){if(r){p();return}m()}};return m(),n.on(`synced`,h),c.on(`transaction`,h),window.addEventListener(`hashchange`,m),()=>{t!==void 0&&clearTimeout(t),n.off(`synced`,h),c.off(`transaction`,h),window.removeEventListener(`hashchange`,m)}},I=[n,c,i,a],t[43]=a,t[44]=i,t[45]=c,t[46]=n,t[47]=P,t[48]=I):(P=t[47],I=t[48]),(0,Q.useEffect)(P,I);let L,R;t[49]===c?(L=t[50],R=t[51]):(L=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||c.isDestroyed)return;let n=fe(c);if(!n)return;let r=n.dom.querySelectorAll(`h1, h2, h3, h4, h5, h6`)[t.index];r&&r.scrollIntoView({behavior:`smooth`,block:`start`})};return window.addEventListener(Kl,e),()=>window.removeEventListener(Kl,e)},R=[c],t[49]=c,t[50]=L,t[51]=R),(0,Q.useEffect)(L,R);let z;t[52]!==a||t[53]!==i||t[54]!==o||t[55]!==r||t[56]!==s||t[57]!==n.awareness?(z=()=>{let e=n.awareness;if(e){if(i!==a){e.setLocalState(null);return}e.setLocalState({user:EE({principal:s,identity:o}),mode:r?`source`:`wysiwyg`})}},t[52]=a,t[53]=i,t[54]=o,t[55]=r,t[56]=s,t[57]=n.awareness,t[58]=z):z=t[58];let B;t[59]!==a||t[60]!==i||t[61]!==o||t[62]!==r||t[63]!==s||t[64]!==n?(B=[n,i,a,o,s,r],t[59]=a,t[60]=i,t[61]=o,t[62]=r,t[63]=s,t[64]=n,t[65]=B):B=t[65],(0,Q.useEffect)(z,B);let H,U;t[66]!==c||t[67]!==r?(H=()=>(Qt(c,r),()=>{Qt(c,!1)}),U=[c,r],t[66]=c,t[67]=r,t[68]=H,t[69]=U):(H=t[68],U=t[69]),(0,Q.useEffect)(H,U);let W;t[70]!==a||t[71]!==i||t[72]!==c||t[73]!==r?(W=!r&&(0,Z.jsx)(XD,{editor:c,shortcutEnabled:i===a}),t[70]=a,t[71]=i,t[72]=c,t[73]=r,t[74]=W):W=t[74];let G;t[75]!==c||t[76]!==r?(G=!r&&(0,Z.jsx)(PO,{editor:c}),t[75]=c,t[76]=r,t[77]=G):G=t[77];let K;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Z.jsx)(`div`,{ref:p,style:{display:`contents`}}),t[78]=K):K=t[78];let q;t[79]!==c||t[80]!==m?(q=(0,Z.jsx)(d,{editor:c,className:`tiptap-editor-portal-content h-full`},m),t[79]=c,t[80]=m,t[81]=q):q=t[81];let J;t[82]!==f||t[83]!==q?(J=(0,Au.createPortal)(q,f),t[82]=f,t[83]=q,t[84]=J):J=t[84];let Y;t[85]===c?Y=t[86]:(Y=(0,Z.jsx)(CE,{editor:c}),t[85]=c,t[86]=Y);let ee;t[87]===c?ee=t[88]:(ee=Gt(c),t[87]=c,t[88]=ee);let te;t[89]===ee.store?te=t[90]:(te=(0,Z.jsx)(Re,{store:ee.store}),t[89]=ee.store,t[90]=te);let ne;return t[91]!==W||t[92]!==G||t[93]!==J||t[94]!==Y||t[95]!==te||t[96]!==l?(ne=(0,Z.jsxs)(`div`,{ref:l,className:`tiptap-editor h-full`,"data-agent-flash-state":`idle`,"data-agent-flash-count":`0`,"data-agent-flash-position":`append`,"data-agent-flash-agent-id":``,children:[W,G,K,J,Y,te]}),t[91]=W,t[92]=G,t[93]=J,t[94]=Y,t[95]=te,t[96]=l,t[97]=ne):ne=t[97],ne};function QO(e){return e+1}function $O(){return C()}var ek=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(t,n=t){return new e(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}};function tk(e,t,n,r,i,a){if(e==r)return[];let o=dk(e,t,n,r,i,a),s=fk(e,t+o,n,r,i+o,a);t+=o,n-=s,i+=o,a-=s;let c=n-t,l=a-i;if(!c||!l)return[new ek(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new ek(t,t+o,i,i),new ek(t+o+l,n,a,a)]}else if(l>c){let o=r.slice(i,a).indexOf(e.slice(t,n));if(o>-1)return[new ek(t,t,i,i+o),new ek(n,n,i+o+c,a)]}if(c==1||l==1)return[new ek(t,n,i,a)];let u=mk(e,t,n,r,i,a);if(u){let[o,s,c]=u;return tk(e,t,o,r,i,s).concat(tk(e,o+c,n,r,s+c,a))}return ak(e,t,n,r,i,a)}var nk=1e9,rk=0,ik=!1;function ak(e,t,n,r,i,a){let o=n-t,s=a-i;if(nk<1e9&&Math.min(o,s)>nk*16||rk>0&&Date.now()>rk)return Math.min(o,s)>nk*64?[new ek(t,n,i,a)]:hk(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);sk.reset(c),ck.reset(c);let l=(n,a)=>e.charCodeAt(t+n)==r.charCodeAt(i+a),u=(t,i)=>e.charCodeAt(n-t-1)==r.charCodeAt(a-i-1),d=(o-s)%2==0?null:ck,f=d?null:sk;for(let p=0;p<c;p++){if(p>nk||rk>0&&!(p&63)&&Date.now()>rk)return hk(e,t,n,r,i,a);let m=sk.advance(p,o,s,c,d,!1,l)||ck.advance(p,o,s,c,f,!0,u);if(m)return lk(e,t,n,t+m[0],r,i,a,i+m[1])}return[new ek(t,n,i,a)]}var ok=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let e=0;e<this.len;e++)this.vec[e]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,r,i,a,o){for(let s=-e+this.start;s<=e-this.end;s+=2){let c=r+s,l=s==-e||s!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,u=l-s;for(;l<t&&u<n&&o(l,u);)l++,u++;if(this.vec[c]=l,l>t)this.end+=2;else if(u>n)this.start+=2;else if(i){let e=r+(t-n)-s;if(e>=0&&e<this.len&&i.vec[e]!=-1)if(a){let n=i.vec[e];if(n>=t-l)return[n,r+n-e]}else{let n=t-i.vec[e];if(l>=n)return[l,u]}}}return null}},sk=new ok,ck=new ok;function lk(e,t,n,r,i,a,o,s){let c=!1;return!Ak(e,r)&&++r==n&&(c=!0),!Ak(i,s)&&++s==o&&(c=!0),c?[new ek(t,n,a,o)]:tk(e,t,r,i,a,s).concat(tk(e,r,n,i,s,o))}function uk(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function dk(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=uk(n-t,a-i);for(let s=t,c=i;;){let i=s+o,l=c+o;if(i>n||l>a||e.slice(s,i)!=r.slice(c,l)){if(o==1)return s-t-+!Ak(e,s);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function fk(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=uk(n-t,a-i);for(let s=n,c=a;;){let a=s-o,l=c-o;if(a<t||l<i||e.slice(a,s)!=r.slice(l,c)){if(o==1)return n-s-+!Ak(e,s);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function pk(e,t,n,r,i,a,o,s){let c=r.slice(i,a),l=null;for(;;){if(l||o<s)return l;for(let s=t+o;;){Ak(e,s)||s++;let u=s+o;if(Ak(e,u)||(u+=u==s+1?1:-1),u>=n)break;let d=e.slice(s,u),f=-1;for(;(f=c.indexOf(d,f+1))!=-1;){let o=dk(e,u,n,r,i+f+d.length,a),c=fk(e,t,s,r,i,i+f),p=d.length+o+c;(!l||l[2]<p)&&(l=[s-c,i+f-c,p])}s=u}if(s<0)return l;o>>=1}}function mk(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=mk(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:pk(e,t,n,r,i,a,Math.floor(o/4),-1)}function hk(e,t,n,r,i,a){ik=!0;let o=n-t,s=a-i,c;if(o<s){let s=pk(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=pk(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new ek(t,n,i,a)];let[l,u,d]=c;return tk(e,t,l,r,i,u).concat(tk(e,l+d,n,r,u+d,a))}function gk(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];r.toA>i.fromA-t&&r.toB>i.fromB-t&&(e[n-1]=new ek(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function _k(e,t,n){for(;;){gk(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=dk(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new ek(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=fk(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new ek(a.fromA,a.toA-s,a.fromB,a.toB-s));let c=a.toA-a.fromA,l=a.toB-a.fromB;if(c&&l)continue;let u=a.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:e.length)-a.toA;if(!u||!d)continue;let f=c?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);u<=f.length&&e.slice(a.fromA-u,a.fromA)==f.slice(f.length-u)?(n[i]=new ek(a.fromA-u,a.toA-u,a.fromB-u,a.toB-u),r=!0):d<=f.length&&e.slice(a.toA,a.toA+d)==f.slice(0,d)&&(n[i]=new ek(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function vk(e,t,n){for(let r=0,i=0;i<e.length;i++){let a=e[i],o=a.toA-a.fromA,s=a.toB-a.fromB;if(o&&s||o>3||s>3){let c=i==e.length-1?t.length:e[i+1].fromA,l=a.fromA-r,u=c-a.toA,d=Tk(t,a.fromA,l),f=wk(t,a.toA,u),p=a.fromA-d,m=f-a.toA;if((!o||!s)&&p&&m){let l=Math.max(o,s),[u,h,g]=o?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];l>p&&t.slice(d,a.fromA)==u.slice(g-p,g)?(a=e[i]=new ek(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=wk(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new ek(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=Tk(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new ek(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=Dk(n,a.fromB,a.toB),r,o=t<0?-1:Ek(n,a.toB,a.fromB);t>-1&&(r=t-a.fromB)<=u&&n.slice(a.fromB,t)==n.slice(a.toB,a.toB+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toB-o)<=l&&n.slice(a.fromB-r,a.fromB)==n.slice(o,a.toB)&&(a=e[i]=a.offset(-r))}else if(!s){let n=Dk(t,a.fromA,a.toA),r,o=n<0?-1:Ek(t,a.toA,a.fromA);n>-1&&(r=n-a.fromA)<=u&&t.slice(a.fromA,n)==t.slice(a.toA,a.toA+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toA-o)<=l&&t.slice(a.fromA-r,a.fromA)==t.slice(o,a.toA)&&(a=e[i]=a.offset(-r))}}r=a.toA}return gk(e,3),e}var yk;try{yk=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function bk(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function xk(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?+!!bk(n):yk?!Ok(n)||t==e.length-1?+!!yk.test(String.fromCharCode(n)):yk.test(e.slice(t,t+2))?2:0:0}function Sk(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?+!!bk(n):yk?!kk(n)||t==1?+!!yk.test(String.fromCharCode(n)):yk.test(e.slice(t-2,t))?2:0:0}var Ck=8;function wk(e,t,n){if(t==e.length||!Sk(e,t))return t;for(let r=t,i=t+n,a=0;a<Ck;a++){let t=xk(e,r);if(!t||r+t>i)return r;r+=t}return t}function Tk(e,t,n){if(!t||!xk(e,t))return t;for(let r=t,i=t-n,a=0;a<Ck;a++){let t=Sk(e,r);if(!t||r-t<i)return r;r-=t}return t}function Ek(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function Dk(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var Ok=e=>e>=55296&&e<=56319,kk=e=>e>=56320&&e<=57343;function Ak(e,t){return!t||t==e.length||!Ok(e.charCodeAt(t-1))||!kk(e.charCodeAt(t))}function jk(e,t,n){let r=n?.override;return r?r(e,t):(nk=(n?.scanLimit??1e9)>>1,rk=n?.timeout?Date.now()+n.timeout:0,ik=!1,_k(e,t,tk(e,0,e.length,t,0,t.length)))}function Mk(){return!ik}function Nk(e,t,n){return vk(jk(e,t,n),e,t)}var Pk=Nl.define({combine:e=>e[0]}),Fk=Pl.define(),Ik=Nl.define(),Lk=Ol.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(Fk)&&(e=n.value);for(let n of t.state.facet(Ik))e=n(e,t);return e}});function Rk(e){let t=e.field(Lk,!1);if(!t)return null;let n=e.facet(Pk);return{chunks:t,side:n?n.side:null}}var zk=class e{constructor(e,t,n,r,i,a=!0){this.changes=e,this.fromA=t,this.toA=n,this.fromB=r,this.toB=i,this.precise=a}offset(t,n){return t||n?new e(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return Hk(Nk(e.toString(),t.toString(),n),e,t,0,0,Mk())}static updateA(e,t,n,r,i){return Kk(Gk(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return Kk(Gk(e,r,!1,t.length),e,t,n,i)}};function Bk(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.to==e&&a.to==t&&e<n.length&&t<r.length?[e+1,t+1]:[i.from,a.from]}function Vk(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.from==e&&a.from==t?[e,t]:[i.to+1,a.to+1]}function Hk(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=Bk(c.fromA+r,c.fromB+i,t,n),[d,f]=Vk(c.toA+r,c.toB+i,t,n),p=[c.offset(-l+r,-u+i)];for(;s<e.length-1;){let a=e[s+1],[o,c]=Bk(a.fromA+r,a.fromB+i,t,n);if(o>d+1&&c>f+1)break;p.push(a.offset(-l+r,-u+i)),[d,f]=Vk(a.toA+r,a.toB+i,t,n),s++}o.push(new zk(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var Uk=1e3;function Wk(e,t,n,r){let i=0,a=e.length;for(;;){if(i==a){let r=0,a=0;i&&({toA:r,toB:a}=e[i-1]);let o=t-(n?r:a);return[r+o,a+o]}let o=i+a>>1,s=e[o],[c,l]=n?[s.fromA,s.toA]:[s.fromB,s.toB];if(c>t)a=o;else if(l<=t)i=o+1;else return r?[s.fromA,s.fromB]:[s.toA,s.toB]}}function Gk(e,t,n,r){let i=[];return t.iterChangedRanges((a,o,s,c)=>{let l=0,u=n?t.length:r,d=0,f=n?r:t.length;a>Uk&&([l,d]=Wk(e,a-Uk,n,!0)),o<t.length-Uk&&([u,f]=Wk(e,o+Uk,n,!1));let p=c-s-(o-a),m,[h,g]=n?[p,0]:[0,p];i.length&&(m=i[i.length-1]).toA>=l?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:u,toB:f,diffA:m.diffA+h,diffB:m.diffB+g}:i.push({fromA:l,toA:u,fromB:d,toB:f,diffA:h,diffB:g})}),i}function Kk(e,t,n,r,i){if(!e.length)return t;let a=[];for(let o=0,s=0,c=0,l=0;;o++){let u=o==e.length?null:e[o],d=u?u.fromA+s:n.length,f=u?u.fromB+c:r.length;for(;l<t.length;){let e=t[l];if(u&&(e.toA+s>d||e.toB+c>f))break;a.push(e.offset(s,c)),l++}if(!u)break;let p=u.toA+s+u.diffA,m=u.toB+c+u.diffB,h=Nk(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of Hk(h,n,r,d,f,Mk()))a.push(e);for(s+=u.diffA,c+=u.diffB;l<t.length;){let e=t[l];if(e.fromA+s>p&&e.fromB+c>m)break;l++}}return a}var qk={scanLimit:500},Jk=Fl.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=iA(e))}update(e){(e.docChanged||e.viewportChanged||Xk(e.startState,e.state)||Zk(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=iA(e.view))}},{decorations:e=>e.deco}),Yk=Tl.low(zl({class:`cm-changeGutter`,markers:e=>e.plugin(Jk)?.gutter||Vl.empty}));function Xk(e,t){return e.field(Lk,!1)!=t.field(Lk,!1)}function Zk(e,t){return e.facet(Pk)!=t.facet(Pk)}var Qk=jl.line({class:`cm-changedLine`}),$k=jl.mark({class:`cm-changedText`}),eA=jl.mark({tagName:`ins`,class:`cm-insertedLine`}),tA=jl.mark({tagName:`del`,class:`cm-deletedLine`}),nA=new class extends Rl{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function rA(e,t,n,r,i,a){let o=n?e.fromA:e.fromB,s=n?e.toA:e.toB,c=0;if(o!=s){i.add(o,o,Qk),i.add(o,s,n?tA:eA),a&&a.add(o,o,nA);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,Qk),a&&a.add(u,u,nA);continue}let t=u+l.value.length;if(r)for(;c<e.changes.length;){let r=e.changes[c],a=o+(n?r.fromA:r.fromB),s=o+(n?r.toA:r.toB),l=Math.max(u,a),d=Math.min(t,s);if(l<d&&i.add(l,d,$k),s<t)c++;else break}u=t}}}function iA(e){let t=e.state.field(Lk),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(Pk),o=n==`a`,s=new Ml,c=i?new Ml:null,{from:l,to:u}=e.viewport;for(let n of t){if((o?n.fromA:n.fromB)>=u)break;(o?n.toA:n.toB)>l&&(!a||!a(e.state,n,s,c))&&rA(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var aA=class extends wl{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement(`div`);return e.className=`cm-mergeSpacer`,e.style.height=this.height+`px`,e}updateDOM(e){return e.style.height=this.height+`px`,!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},oA=Pl.define({map:(e,t)=>e.map(t)}),sA=Ol.define({create:()=>jl.none,update:(e,t)=>{for(let e of t.effects)if(e.is(oA))return e.value;return e.map(t.changes)},provide:e=>Ll.decorations.from(e)}),cA=.01;function lA(e,t){if(e.size!=t.size)return!1;let n=e.iter(),r=t.iter();for(;n.value;){if(n.from!=r.from||Math.abs(n.value.spec.widget.height-r.value.spec.widget.height)>1)return!1;n.next(),r.next()}return!0}function uA(e,t,n){let r=new Ml,i=new Ml,a=e.state.field(sA).iter(),o=t.state.field(sA).iter(),s=0,c=0,l=0,u=0,d=e.viewport,f=t.viewport;for(let p=0;;p++){let m=p<n.length?n[p]:null,h=m?m.fromA:e.state.doc.length,g=m?m.fromB:t.state.doc.length;if(s<h){let n=e.lineBlockAt(s).top+l-(t.lineBlockAt(c).top+u);n<-cA?(l-=n,r.add(s,s,jl.widget({widget:new aA(-n),block:!0,side:-1}))):n>cA&&(u+=n,i.add(c,c,jl.widget({widget:new aA(n),block:!0,side:-1})))}if(h>s+1e3&&s<d.from&&h>d.from&&c<f.from&&g>f.from){let e=Math.min(d.from-s,f.from-c);s+=e,c+=e,p--}else if(m)s=m.toA,c=m.toB;else break;for(;a.value&&a.from<s;)l-=a.value.spec.widget.height,a.next();for(;o.value&&o.from<c;)u-=o.value.spec.widget.height,o.next()}for(;a.value;)l-=a.value.spec.widget.height,a.next();for(;o.value;)u-=o.value.spec.widget.height,o.next();let p=e.contentHeight+l-(t.contentHeight+u);p<cA?r.add(e.state.doc.length,e.state.doc.length,jl.widget({widget:new aA(-p),block:!0,side:1})):p>cA&&i.add(t.state.doc.length,t.state.doc.length,jl.widget({widget:new aA(p),block:!0,side:1}));let m=r.finish(),h=i.finish();lA(m,e.state.field(sA))||e.dispatch({effects:oA.of(m)}),lA(h,t.state.field(sA))||t.dispatch({effects:oA.of(h)})}var dA=Pl.define({map:(e,t)=>t.mapPos(e)}),fA=class extends wl{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement(`div`);return t.className=`cm-collapsedLines`,t.textContent=e.state.phrase(`$ unchanged lines`,this.lines),t.addEventListener(`click`,t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:dA.of(n)});let{side:r,sibling:i}=e.state.facet(Pk);i&&i().dispatch({effects:dA.of(pA(n,e.state.field(Lk),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function pA(e,t,n){let r=0,i=0;for(let a=0;;a++){let o=a<t.length?t[a]:null;if(!o||(n?o.fromA:o.fromB)>=e)return i+(e-r);[r,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}var mA=Ol.define({create(e){return jl.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(dA)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>Ll.decorations.from(e)});function hA({margin:e=3,minSize:t=4}){return mA.init(n=>gA(n,e,t))}function gA(e,t,n){let r=new Ml,i=e.facet(Pk).side==`a`,a=e.field(Lk),o=1;for(let s=0;;s++){let c=s<a.length?a[s]:null,l=s?o+t:1,u=c?e.doc.lineAt(i?c.fromA:c.fromB).number-1-t:e.doc.lines,d=u-l+1;if(d>=n&&r.add(e.doc.line(l).from,e.doc.line(u).to,jl.replace({widget:new fA(d),block:!0})),!c)break;o=e.doc.lineAt(Math.min(e.doc.length,i?c.toA:c.toB)).number}return r.finish()}var _A=Ll.styleModule.of(new Bl({".cm-mergeView":{overflowY:`auto`},".cm-mergeViewEditors":{display:`flex`,alignItems:`stretch`},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:`hidden`},".cm-merge-revert":{width:`1.6em`,flexGrow:0,flexShrink:0,position:`relative`},".cm-merge-revert button":{position:`absolute`,display:`block`,width:`100%`,boxSizing:`border-box`,textAlign:`center`,background:`none`,border:`none`,font:`inherit`,cursor:`pointer`}})),vA=Ll.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:`auto !important`,overflowY:`visible !important`},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:`rgba(160, 128, 100, .08)`},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:`rgba(100, 160, 128, .08)`},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat`},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat`},"&light.cm-merge-b .cm-changedText":{background:`linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat`},"&dark.cm-merge-b .cm-changedText":{background:`linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat`},"&.cm-merge-b .cm-deletedText":{background:`#ff000033`},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:`none`},".cm-deletedChunk":{paddingLeft:`6px`,"& .cm-chunkButtons":{position:`absolute`,insetInlineEnd:`5px`},"& button":{border:`none`,cursor:`pointer`,color:`white`,margin:`0 2px`,borderRadius:`3px`,"&[name=accept]":{background:`#2a2`},"&[name=reject]":{background:`#d43`}}},".cm-collapsedLines":{padding:`5px 5px 5px 10px`,cursor:`pointer`,"&:before":{content:`"⦚"`,marginInlineEnd:`7px`},"&:after":{content:`"⦚"`,marginInlineStart:`7px`}},"&light .cm-collapsedLines":{color:`#444`,background:`linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)`},"&dark .cm-collapsedLines":{color:`#ddd`,background:`linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)`},".cm-changeGutter":{width:`3px`,paddingLeft:`1px`},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:`#e43`},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:`#fa9`},"&light.cm-merge-b .cm-changedLineGutter":{background:`#2b2`},"&dark.cm-merge-b .cm-changedLineGutter":{background:`#8f8`},".cm-inlineChangedLineGutter":{background:`#75d`}}),yA=new Il,bA=new Il,xA=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||qk;let t=[Tl.low(Jk),vA,_A,sA,Ll.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(oA)))&&this.measure()})],n=[Pk.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(Yk);let r=Dl.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],Ll.editorAttributes.of({class:`cm-merge-a`}),bA.of(n),t]}),i=[Pk.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(Yk);let a=Dl.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],Ll.editorAttributes.of({class:`cm-merge-b`}),bA.of(i),t]});this.chunks=zk.build(r.doc,a.doc,this.diffConf);let o=[Lk.init(()=>this.chunks),yA.of(e.collapseUnchanged?hA(e.collapseUnchanged):[])];r=r.update({effects:Pl.appendConfig.of(o)}).state,a=a.update({effects:Pl.appendConfig.of(o)}).state,this.dom=document.createElement(`div`),this.dom.className=`cm-mergeView`,this.editorDOM=this.dom.appendChild(document.createElement(`div`)),this.editorDOM.className=`cm-mergeViewEditors`;let s=e.orientation||`a-b`,c=document.createElement(`div`);c.className=`cm-mergeViewEditor`;let l=document.createElement(`div`);l.className=`cm-mergeViewEditor`,this.editorDOM.appendChild(s==`a-b`?c:l),this.editorDOM.appendChild(s==`a-b`?l:c),this.a=new Ll({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new Ll({state:a,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls==`b-to-a`,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(e=>e.docChanged)){let n=e[e.length-1],r=e.reduce((e,t)=>e.compose(t.changes),El.empty(e[0].startState.doc.length));this.chunks=t==this.a?zk.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):zk.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:Fk.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:Fk.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if(`diffConfig`in e&&(this.diffConf=e.diffConfig),`orientation`in e){let t=e.orientation!=`b-a`;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent=``)}}if(`revertControls`in e||`renderRevertControl`in e){let t=!!this.revertDOM,n=this.revertToA,r=this.renderRevert;`revertControls`in e&&(t=!!e.revertControls,n=e.revertControls==`b-to-a`),`renderRevertControl`in e&&(r=e.renderRevertControl),this.setupRevertControls(t,n,r)}let t=`highlightChanges`in e,n=`gutter`in e,r=`collapseUnchanged`in e;if(t||n||r){let i=[],a=[];if(t||n){let r=this.a.state.facet(Pk),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(bA.reconfigure([Pk.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?Yk:[]])),a.push(bA.reconfigure([Pk.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?Yk:[]]))}if(r){let t=yA.reconfigure(e.collapseUnchanged?hA(e.collapseUnchanged):[]);i.push(t),a.push(t)}this.a.dispatch({effects:i}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement(`div`),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener(`mousedown`,e=>this.revertClicked(e)),this.revertDOM.className=`cm-merge-revert`):this.revertDOM&&(this.revertDOM.textContent=``)}scheduleMeasure(){this.measuring<0&&(this.measuring=(this.dom.ownerDocument.defaultView||window).requestAnimationFrame(()=>{this.measuring=-1,this.measure()}))}measure(){uA(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,r=this.b.viewport;for(let i=0;i<this.chunks.length;i++){let a=this.chunks[i];if(a.fromA>n.to||a.fromB>r.to)break;if(a.fromA<n.from||a.fromB<r.from)continue;let o=this.a.lineBlockAt(a.fromA).top+`px`;for(;t&&+t.dataset.chunk<i;)t=SA(t);t&&t.dataset.chunk==String(i)?(t.style.top!=o&&(t.style.top=o),t=t.nextSibling):e.insertBefore(this.renderRevertButton(o,i),t)}for(;t;)t=SA(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement(`button`);let e=this.a.state.phrase(`Revert this chunk`);n.setAttribute(`aria-label`,e),n.setAttribute(`title`,e),n.textContent=this.revertToLeft?`⇜`:`⇝`}return n.style.top=e,n.setAttribute(`data-chunk`,String(t)),n}revertClicked(e){let t=e.target,n;for(;t&&t.parentNode!=this.revertDOM;)t=t.parentNode;if(t&&(n=this.chunks[t.dataset.chunk])){let[t,r,i,a,o,s]=this.revertToA?[this.b,this.a,n.fromB,n.toB,n.fromA,n.toA]:[this.a,this.b,n.fromA,n.toA,n.fromB,n.toB],c=t.state.sliceDoc(i,Math.max(i,a-1));i!=a&&s<=r.state.doc.length&&(c+=t.state.lineBreak),r.dispatch({changes:{from:o,to:Math.min(r.state.doc.length,s),insert:c},userEvent:`revert`}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}};function SA(e){let t=e.nextSibling;return e.remove(),t}var CA=new class extends Rl{constructor(){super(...arguments),this.elementClass=`cm-deletedLineGutter`}},wA=Tl.low(zl({class:`cm-changeGutter`,markers:e=>e.plugin(Jk)?.gutter||Vl.empty,widgetMarker:(e,t)=>t instanceof kA?CA:null}));function TA(e){let t=typeof e.original==`string`?Al.of(e.original.split(/\r?\n/)):e.original,n=e.diffConfig||qk;return[Tl.low(Jk),PA,vA,Ll.editorAttributes.of({class:`cm-merge-b`}),Ik.of((e,t)=>{let r=t.effects.find(e=>e.is(EA));return r&&(e=zk.updateA(e,r.value.doc,t.startState.doc,r.value.changes,n)),t.docChanged&&(e=zk.updateB(e,t.state.field(DA),t.newDoc,t.changes,n)),e}),Pk.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:e.mergeControls??!0,overrideChunk:e.allowInlineDiffs?BA:void 0,side:`b`}),DA.init(()=>t),e.gutter===!1?[]:wA,e.collapseUnchanged?hA(e.collapseUnchanged):[],Lk.init(e=>zk.build(t,e.doc,n))]}var EA=Pl.define(),DA=Ol.define({create:()=>Al.empty,update(e,t){for(let n of t.effects)n.is(EA)&&(e=n.value.doc);return e}}),OA=new WeakMap,kA=class extends wl{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||=this.buildDOM(e)}};function AA(e,t,n){let r=OA.get(t.changes);if(r)return r;let i=jl.widget({block:!0,side:-1,widget:new kA(r=>{let{highlightChanges:i,syntaxHighlightDeletions:a,syntaxHighlightDeletionsMaxLength:o,mergeControls:s}=e.facet(Pk),c=document.createElement(`div`);if(c.className=`cm-deletedChunk`,s){let t=c.appendChild(document.createElement(`div`));t.className=`cm-chunkButtons`;let n=e=>{e.preventDefault(),jA(r,r.posAtDOM(c))},i=e=>{e.preventDefault(),MA(r,r.posAtDOM(c))};if(typeof s==`function`)t.appendChild(s(`accept`,n)),t.appendChild(s(`reject`,i));else{let r=t.appendChild(document.createElement(`button`));r.name=`accept`,r.textContent=e.phrase(`Accept`),r.onmousedown=n;let a=t.appendChild(document.createElement(`button`));a.name=`reject`,a.textContent=e.phrase(`Reject`),a.onmousedown=i}}if(n||t.fromA>=t.toA)return c;let l=r.state.field(DA).sliceString(t.fromA,t.endA),u=a&&e.facet(Hl),d=h(),f=t.changes,p=0,m=!1;function h(){let e=c.appendChild(document.createElement(`div`));return e.className=`cm-deletedLine`,e.appendChild(document.createElement(`del`))}function g(e,t,n){for(let r=e;r<t;){if(l.charAt(r)==`
|
|
30
30
|
`){d.firstChild||d.appendChild(document.createElement(`br`)),d=h(),r++;continue}let e=t,a=n+(m?` cm-deletedText`:``),o=!1,s=l.indexOf(`
|
|
31
31
|
`,r);if(s>-1&&s<t&&(e=s),i&&p<f.length){let t=Math.max(0,m?f[p].toA:f[p].fromA);t<=e&&(e=t,m&&p++,o=!0)}if(e>r){let t=document.createTextNode(l.slice(r,e));if(a){let e=d.appendChild(document.createElement(`span`));e.className=a,e.appendChild(t)}else d.appendChild(t);r=e}o&&(m=!m)}}if(u&&t.toA-t.fromA<=o){let t=u.parser.parse(l),n=0;kl(t,{style:t=>Ul(e,t)},(e,t,r)=>{e>n&&g(n,e,``),g(e,t,r),n=t}),g(n,l.length,``)}else g(0,l.length,``);return d.firstChild||d.appendChild(document.createElement(`br`)),c})});return OA.set(t.changes,i),i}function jA(e,t){let{state:n}=e,r=t??n.selection.main.head,i=e.state.field(Lk).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=e.state.sliceDoc(i.fromB,Math.max(i.fromB,i.toB-1)),o=e.state.field(DA);i.fromB!=i.toB&&i.toA<=o.length&&(a+=e.state.lineBreak);let s=El.of({from:i.fromA,to:Math.min(o.length,i.toA),insert:a},o.length);return e.dispatch({effects:EA.of({doc:s.apply(o),changes:s}),userEvent:`accept`}),!0}function MA(e,t){let{state:n}=e,r=t??n.selection.main.head,i=n.field(Lk).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=n.field(DA).sliceString(i.fromA,Math.max(i.fromA,i.toA-1));return i.fromA!=i.toA&&i.toB<=n.doc.length&&(a+=n.lineBreak),e.dispatch({changes:{from:i.fromB,to:Math.min(n.doc.length,i.toB),insert:a},userEvent:`revert`}),!0}function NA(e){let t=new Ml;for(let n of e.field(Lk)){let r=e.facet(Pk).overrideChunk&&IA(e,n);t.add(n.fromB,n.fromB,AA(e,n,!!r))}return t.finish()}var PA=Ol.define({create:e=>NA(e),update(e,t){return t.state.field(Lk,!1)==t.startState.field(Lk,!1)?e:NA(t.state)},provide:e=>Ll.decorations.from(e)}),FA=new WeakMap;function IA(e,t){let n=FA.get(t);if(n!==void 0)return n;n=null;let r=e.field(DA),i=e.doc,a=r.lineAt(t.endA).number-r.lineAt(t.fromA).number+1,o=i.lineAt(t.endB).number-i.lineAt(t.fromB).number+1;abort:if(a==o&&a<10){let e=[],i=0,o=t.fromA,s=t.fromB;for(let n of t.changes){if(n.fromA<n.toA){i+=n.toA-n.fromA;let t=r.sliceString(o+n.fromA,o+n.toA);if(/\n/.test(t))break abort;e.push(jl.widget({widget:new LA(t),side:-1}).range(s+n.fromB))}n.fromB<n.toB&&e.push($k.range(s+n.fromB,s+n.toB))}i<t.endA-t.fromA-a*2&&(n=e)}return FA.set(t,n),n}var LA=class extends wl{constructor(e){super(),this.text=e}eq(e){return this.text==e.text}toDOM(e){let t=document.createElement(`del`);return t.className=`cm-deletedText`,t.textContent=this.text,t}},RA=new class extends Rl{constructor(){super(...arguments),this.elementClass=`cm-inlineChangedLineGutter`}},zA=jl.line({class:`cm-inlineChangedLine`});function BA(e,t,n,r){let i=IA(e,t),a=0;if(!i)return!1;for(let o=e.doc.lineAt(t.fromB);;){for(r&&r.add(o.from,o.from,RA),n.add(o.from,o.from,zA);a<i.length&&i[a].to<=o.to;){let e=i[a++];n.add(e.from,e.to,e.value)}if(o.to>=t.endB)break;o=e.doc.lineAt(o.to+1)}return!0}var VA=oe({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),HA=E({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),UA=Ll.theme({".cm-deletedChunk .cm-chunkButtons":{display:`flex`,gap:`0.25rem`},".cm-deletedChunk .cm-chunkButtons button[data-slot='button']":{margin:`0`,border:`1px solid transparent`,borderRadius:`min(var(--radius-md), 10px)`,color:`var(--primary-foreground)`},".cm-deletedChunk .cm-chunkButtons button[data-slot='button'][data-variant='destructive']":{color:`var(--destructive)`}});function WA({addControl:e,nextId:t,removeControl:n,root:r}){return(i,a)=>{let o=document.createElement(`span`);o.className=`inline-flex`;let s=t();return e({id:s,host:o,type:i,action:a}),queueMicrotask(()=>{r.contains(o)||n(s)}),o}}function GA(e){let t=(0,$.c)(32),{oldContent:n,newContent:r,layout:i,conflictMode:a,previewMode:o,oursOverride:s,onResolve:c,onAbort:l}=e,{_:u}=cn(),d=s??r,f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(0),{resolvedTheme:h}=xr(),g=(0,Q.useRef)(c),_=(0,Q.useRef)(l),[v,y]=(0,Q.useState)(null),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=[],t[0]=b):b=t[0];let[x,S]=(0,Q.useState)(b),C;t[1]!==l||t[2]!==c?(C=()=>{g.current=c,_.current=l},t[1]=l,t[2]=c,t[3]=C):C=t[3],(0,Q.useEffect)(C);let w,T;t[4]!==a||t[5]!==d||t[6]!==i||t[7]!==n||t[8]!==o||t[9]!==h?(w=()=>{let e=f.current;if(!e)return;S([]);let t=new Map,r=!1,s=e=>{r||!t.delete(e)||S(t=>t.filter(t=>t.id!==e))},c=new MutationObserver(()=>{for(let[n,r]of t)e.contains(r)||s(n)});c.observe(e,{childList:!0,subtree:!0});let l=h===`dark`?VA:HA,u=[Ll.editable.of(!1),Dl.readOnly.of(!0)],g=[nu,Wl(),...u,l,Ll.lineWrapping];if(p.current&&=(p.current.destroy(),null),o)p.current=new Ll({doc:d,extensions:g,parent:e}),y(null);else if(a){let i=WA({addControl:e=>{r||(t.set(e.id,e.host),S(t=>[...t,e]))},nextId:()=>(m.current+=1,m.current),removeControl:s,root:e}),a=new Ll({doc:d,extensions:[nu,Wl(),Ll.editable.of(!1),l,UA,Ll.lineWrapping,TA({original:n,highlightChanges:!0,gutter:!0,mergeControls:i,collapseUnchanged:{margin:3,minSize:4}}),Ll.updateListener.of(e=>{let t=Rk(e.state);y(t?t.chunks.length:0)})],parent:e});p.current=a;let o=Rk(a.state);y(o?o.chunks.length:0)}else i===`split`?p.current=new xA({a:{doc:n,extensions:g},b:{doc:d,extensions:g},parent:e,highlightChanges:!0,gutter:!0,collapseUnchanged:{margin:3,minSize:4}}):p.current=new Ll({doc:d,extensions:[...g,TA({original:n,highlightChanges:!0,gutter:!0,mergeControls:!1,collapseUnchanged:{margin:3,minSize:4}})],parent:e});return()=>{r=!0,c.disconnect(),p.current&&=(p.current.destroy(),null)}},T=[n,d,i,h,a,o],t[4]=a,t[5]=d,t[6]=i,t[7]=n,t[8]=o,t[9]=h,t[10]=w,t[11]=T):(w=t[10],T=t[11]),(0,Q.useEffect)(w,T);let E;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(E=function(){let e=p.current;!e||!(e instanceof Ll)||g.current?.(e.state.doc.toString())},t[12]=E):E=t[12];let D=E,O;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(O=function(){let e=p.current;!e||!(e instanceof Ll)||K(e)},t[13]=O):O=t[13];let k=O,A=v===0,j;t[14]!==u||t[15]!==v?(j=v===null?``:v===0?u({id:`lPzyrU`}):ic._({id:`8FqTCr`,values:{chunksRemaining:v}}),t[14]=u,t[15]=v,t[16]=j):j=t[16];let M=j,N;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(`div`,{ref:f,className:`diff-view min-h-0 flex-1 overflow-y-auto subtle-scrollbar`}),t[17]=N):N=t[17];let P;if(t[18]!==u||t[19]!==x){let e;t[21]===u?e=t[22]:(e=e=>(0,Au.createPortal)((0,Z.jsx)(Di,{type:`button`,variant:e.type===`accept`?`default`:`destructive`,size:`xs`,onClick:t=>{e.action(t.nativeEvent)},children:e.type===`accept`?u({id:`g3UF2V`}):u({id:`1t_NnN`})}),e.host,e.id),t[21]=u,t[22]=e),P=x.map(e),t[18]=u,t[19]=x,t[20]=P}else P=t[20];let F;t[23]!==A||t[24]!==a||t[25]!==M||t[26]!==l||t[27]!==c?(F=a&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 border-t shrink-0`,children:[(0,Z.jsx)(`span`,{className:`text-xs ${A?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`}`,children:M}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l&&(0,Z.jsx)(Di,{className:`uppercase font-mono`,variant:`ghost`,size:`sm`,onClick:l,children:(0,Z.jsx)(X,{id:`XyOUTJ`})}),(0,Z.jsx)(Di,{className:`uppercase font-mono`,variant:`outline`,size:`sm`,onClick:k,children:`Undo`}),c&&(0,Z.jsx)(Di,{variant:`default`,size:`sm`,disabled:!A,onClick:D,children:(0,Z.jsx)(X,{id:`Lcehxn`})})]})]}),t[23]=A,t[24]=a,t[25]=M,t[26]=l,t[27]=c,t[28]=F):F=t[28];let I;return t[29]!==F||t[30]!==P?(I=(0,Z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[N,P,F]}),t[29]=F,t[30]=P,t[31]=I):I=t[31],I}async function KA(e,t,n){try{let r={file:e,strategy:t};n!==void 0&&(r.content=n);let i=await fetch(`/api/sync/resolve-conflict`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(i.ok)return{ok:!0};let a;try{let e=await i.json();typeof e.detail==`string`?a=e.detail:typeof e.title==`string`&&(a=e.title)}catch{}return{ok:!1,detail:a}}catch(n){let r=n instanceof Error?n.message:String(n);return console.warn(JSON.stringify({event:`conflict-resolve-dispatch-failed`,file:e,strategy:t,detail:r})),{ok:!1,detail:r}}}async function qA(e,t){return KA(e,`content`,t)}async function JA(e){return KA(e,`mine`)}async function YA(e){return KA(e,`theirs`)}async function XA(e){return KA(e,`delete`)}async function ZA(e){try{let t=await fetch(`/api/sync/conflict-content?file=${encodeURIComponent(e)}&source=ytext`);if(!t.ok){let n;try{let e=await t.json();typeof e.detail==`string`?n=e.detail:typeof e.title==`string`&&(n=e.title)}catch{}return console.warn(JSON.stringify({event:`conflict-content-fetch-failed`,file:e,status:t.status,detail:n})),null}let n=await t.json(),r=n.kind===`delete-modify`||n.kind===`modify-delete`||n.kind===`both-modified`?n.kind:`both-modified`;return n.kind!==r&&console.warn(JSON.stringify({event:`conflict-kind-missing-fallback`,file:e,receivedKind:n.kind??null})),{base:n.base??``,ours:n.ours??``,theirs:n.theirs??``,kind:r}}catch(t){return console.warn(JSON.stringify({event:`conflict-content-fetch-failed`,file:e,status:null,detail:t instanceof Error?t.message:String(t)})),null}}function QA(e){let t=(0,$.c)(84),{docName:n}=e,{_:r}=cn(),{conflicts:i,loading:a}=qi(),o;if(t[0]!==i||t[1]!==n){let e;t[3]===n?e=t[4]:(e=e=>fo(e.file)===n,t[3]=n,t[4]=e),o=i.find(e),t[0]=i,t[1]=n,t[2]=o}else o=t[2];let s=o,c=s?.file??`${n}.md`,[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),h,g;t[5]===n?(h=t[6],g=t[7]):(h=()=>(console.warn(JSON.stringify({event:`editor-area-swap-to-diffview`,"doc.name":n})),()=>{console.warn(JSON.stringify({event:`editor-area-swap-from-diffview`,"doc.name":n}))}),g=[n],t[5]=n,t[6]=h,t[7]=g),(0,Q.useEffect)(h,g);let _=a||s===void 0,v,y;t[8]!==_||t[9]!==c?(v=()=>{if(_)return;let e=!1;return u(null),f(!1),ZA(c).then(t=>{e||(t===null?f(!0):u(t))}),()=>{e=!0}},y=[c,_],t[8]=_,t[9]=c,t[10]=v,t[11]=y):(v=t[10],y=t[11]),(0,Q.useEffect)(v,y);let b;t[12]!==r||t[13]!==c?(b=async function(e){let t=await qA(c,e);t.ok||Js.error(r({id:`K-h9cT`,values:{filePath:c}}),{description:t.detail})},t[12]=r,t[13]=c,t[14]=b):b=t[14];let x=b,S;t[15]!==r||t[16]!==c?(S=async function(e){m(!0);let t=await e(c);t.ok||(m(!1),Js.error(r({id:`jPUPvG`,values:{filePath:c}}),{description:t.detail}))},t[15]=r,t[16]=c,t[17]=S):S=t[17];let C=S;if(d){let e;return t[18]===c?e=t[19]:(e=(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:(0,Z.jsx)(X,{id:`ajz9F8`,values:{filePath:c}})}),t[18]=c,t[19]=e),e}if(l===null){let e;return t[20]===c?e=t[21]:(e=(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:(0,Z.jsx)(X,{id:`DF1MtZ`,values:{filePath:c}})}),t[20]=c,t[21]=e),e}if(l.kind===`delete-modify`){let e;t[22]===l.theirs?e=t[23]:(e=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(GA,{oldContent:``,newContent:l.theirs,layout:`unified`,previewMode:!0})}),t[22]=l.theirs,t[23]=e);let n;t[24]===c?n=t[25]:(n={filePath:c},t[24]=c,t[25]=n);let r;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,Z.jsx)(`span`,{className:`font-medium text-foreground`})},t[26]=r):r=t[26];let i;t[27]===n?i=t[28]:(i=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Z.jsx)(X,{id:`V48OUT`,values:n,components:r})}),t[27]=n,t[28]=i);let a;t[29]===C?a=t[30]:(a=()=>void C(XA),t[29]=C,t[30]=a);let o;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(X,{id:`Vlc75q`}),t[31]=o):o=t[31];let s;t[32]!==p||t[33]!==a?(s=(0,Z.jsx)(Di,{type:`button`,variant:`destructive`,disabled:p,onClick:a,children:o}),t[32]=p,t[33]=a,t[34]=s):s=t[34];let u;t[35]===C?u=t[36]:(u=()=>void C(YA),t[35]=C,t[36]=u);let d;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(X,{id:`3mFsc3`}),t[37]=d):d=t[37];let f;t[38]!==p||t[39]!==u?(f=(0,Z.jsx)(Di,{type:`button`,variant:`default`,disabled:p,onClick:u,children:d}),t[38]=p,t[39]=u,t[40]=f):f=t[40];let m;t[41]!==s||t[42]!==f?(m=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-3`,children:[s,f]}),t[41]=s,t[42]=f,t[43]=m):m=t[43];let h;t[44]!==i||t[45]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center justify-between gap-x-6 gap-y-3 border-t px-6 py-4`,children:[i,m]}),t[44]=i,t[45]=m,t[46]=h):h=t[46];let g;return t[47]!==h||t[48]!==e?(g=(0,Z.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[e,h]}),t[47]=h,t[48]=e,t[49]=g):g=t[49],g}if(l.kind===`modify-delete`){let e;t[50]===l.ours?e=t[51]:(e=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(GA,{oldContent:``,newContent:l.ours,layout:`unified`,previewMode:!0})}),t[50]=l.ours,t[51]=e);let n;t[52]===c?n=t[53]:(n={filePath:c},t[52]=c,t[53]=n);let r;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,Z.jsx)(`span`,{className:`font-medium text-foreground`})},t[54]=r):r=t[54];let i;t[55]===n?i=t[56]:(i=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Z.jsx)(X,{id:`EhDLBx`,values:n,components:r})}),t[55]=n,t[56]=i);let a;t[57]===C?a=t[58]:(a=()=>void C(JA),t[57]=C,t[58]=a);let o;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(X,{id:`0NA4b3`}),t[59]=o):o=t[59];let s;t[60]!==p||t[61]!==a?(s=(0,Z.jsx)(Di,{type:`button`,variant:`default`,disabled:p,onClick:a,children:o}),t[60]=p,t[61]=a,t[62]=s):s=t[62];let u;t[63]===C?u=t[64]:(u=()=>void C(XA),t[63]=C,t[64]=u);let d;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(X,{id:`qSxaOz`}),t[65]=d):d=t[65];let f;t[66]!==p||t[67]!==u?(f=(0,Z.jsx)(Di,{type:`button`,variant:`destructive`,disabled:p,onClick:u,children:d}),t[66]=p,t[67]=u,t[68]=f):f=t[68];let m;t[69]!==s||t[70]!==f?(m=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-3`,children:[s,f]}),t[69]=s,t[70]=f,t[71]=m):m=t[71];let h;t[72]!==i||t[73]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center justify-between gap-x-6 gap-y-3 border-t px-6 py-4`,children:[i,m]}),t[72]=i,t[73]=m,t[74]=h):h=t[74];let g;return t[75]!==h||t[76]!==e?(g=(0,Z.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[e,h]}),t[75]=h,t[76]=e,t[77]=g):g=t[77],g}let w;t[78]===x?w=t[79]:(w=e=>void x(e),t[78]=x,t[79]=w);let T;return t[80]!==l.ours||t[81]!==l.theirs||t[82]!==w?(T=(0,Z.jsx)(GA,{oldContent:l.theirs,newContent:l.ours,layout:`unified`,conflictMode:!0,onResolve:w}),t[80]=l.ours,t[81]=l.theirs,t[82]=w,t[83]=T):T=t[83],T}function $A(e){let t=(0,$.c)(2),{docName:n,provider:r,children:i}=e;(0,Q.use)(Ht(n,r));let a;return t[0]===i?a=t[1]:(a=(0,Z.jsx)(Z.Fragment,{children:i}),t[0]=i,t[1]=a),a}var ej=`__back-nav__`;function tj(e){return e instanceof je||e instanceof yt||e instanceof we||e instanceof et||e instanceof Pt||e instanceof S?e.docName:null}function nj(e){if(e instanceof je){let t=e.docName;return{title:ic._({id:`Jejur6`}),summary:ic._({id:`jSY41h`,values:{docName:t}})}}if(e instanceof yt){let t=e.docName;return{title:ic._({id:`V7QxyT`}),summary:ic._({id:`xG4tb6`,values:{docName:t}})}}if(e instanceof we){let t=e.docName;return{title:ic._({id:`1di5fu`}),summary:ic._({id:`PQCdtv`,values:{docName:t}})}}if(e instanceof et){let t=e.docName;return{title:ic._({id:`wvbc1r`}),summary:ic._({id:`IX7-sq`,values:{docName:t}})}}if(e instanceof Pt)return{title:ic._({id:`Gfr4fu`}),summary:ic._({id:`UW2Fg3`})};if(e instanceof S){let t=e.docName;return{title:ic._({id:`vv7kpg`}),summary:ic._({id:`mdKFEy`,values:{docName:t}})}}let t=e instanceof Error&&e.message?e.message:ic._({id:`W5A0Ly`});return{title:ic._({id:`29VNqC`}),summary:t}}function rj(e){let t=(0,$.c)(28),{error:n,resetErrorBoundary:r,activeDocName:i,previousDocName:a,onNavigateBack:o}=e,s;t[0]===n?s=t[1]:(s=nj(n),t[0]=n,t[1]=s);let{title:c,summary:l}=s,u=!!a&&!!o,d=(0,Q.useRef)(null),f,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{d.current?.focus()},p=[],t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,Q.useEffect)(f,p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(FC,{size:80,variant:`sleeping`}),t[4]=m):m=t[4];let h;t[5]===c?h=t[6]:(h=(0,Z.jsx)(`h2`,{id:`document-error-title`,className:`text-2xl font-light tracking-tighter text-balance`,children:c}),t[5]=c,t[6]=h);let g;t[7]===l?g=t[8]:(g=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:l}),t[7]=l,t[8]=g);let _;t[9]!==h||t[10]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[h,g]}),t[9]=h,t[10]=g,t[11]=_):_=t[11];let v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(X,{id:`KDw4GX`}),t[12]=v):v=t[12];let y;t[13]===r?y=t[14]:(y=(0,Z.jsx)(Di,{ref:d,variant:`default`,onClick:r,children:v}),t[13]=r,t[14]=y);let b;t[15]!==i||t[16]!==u||t[17]!==n||t[18]!==o||t[19]!==a||t[20]!==r?(b=u?(0,Z.jsx)(Di,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(lt(tj(n)??i),o(a),r(ej))},children:(0,Z.jsx)(X,{id:`CKyk7Q`})}):null,t[15]=i,t[16]=u,t[17]=n,t[18]=o,t[19]=a,t[20]=r,t[21]=b):b=t[21];let x;t[22]!==b||t[23]!==y?(x=(0,Z.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[y,b]}),t[22]=b,t[23]=y,t[24]=x):x=t[24];let S;return t[25]!==x||t[26]!==_?(S=(0,Z.jsxs)(`div`,{role:`alert`,"aria-labelledby":`document-error-title`,"data-slot":`document-error-boundary`,className:`flex h-full flex-col items-center justify-center gap-8 p-8 text-center`,children:[m,_,x]}),t[25]=x,t[26]=_,t[27]=S):S=t[27],S}function ij(e){let t=(0,$.c)(17),{activeDocName:n,previousDocName:r,onNavigateBack:i,onRecycle:a,children:o}=e,s;t[0]!==n||t[1]!==i||t[2]!==r?(s=e=>(0,Z.jsx)(rj,{...e,activeDocName:n,previousDocName:r,onNavigateBack:i}),t[0]=n,t[1]=i,t[2]=r,t[3]=s):s=t[3];let c;t[4]===n?c=t[5]:(c=[n],t[4]=n,t[5]=c);let l;t[6]!==n||t[7]!==a?(l=e=>{if(e.reason===`imperative-api`){if(Array.isArray(e.args)&&e.args[0]===ej){console.warn(`[DocumentErrorBoundary] back-nav reset (no recycle)`);return}a(n),console.warn(`[DocumentErrorBoundary] retry recycled ${n}`)}else console.warn(`[DocumentErrorBoundary] reset by key change (${e.prev?.[0]} → ${e.next?.[0]})`)},t[6]=n,t[7]=a,t[8]=l):l=t[8];let u;t[9]===n?u=t[10]:(u=e=>{console.error(`[DocumentErrorBoundary] rendered fallback for ${n}: ${nj(e).title}`,e)},t[9]=n,t[10]=u);let d;return t[11]!==o||t[12]!==s||t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,Z.jsx)(g,{fallbackRender:s,resetKeys:c,onReset:l,onError:u,children:o}),t[11]=o,t[12]=s,t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function aj(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=ni(t);return{map:n,keys:Br(t),parseError:r}}function oj(e){let t=(0,$.c)(21),{provider:n}=e,r;t[0]===n?r=t[1]:(r=()=>aj(n),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=()=>{let e=$n(n);a(e.current());let t=e.subscribe(e=>{a(e)});return()=>{t(),e.dispose()}},s=[n],t[2]=n,t[3]=o,t[4]=s),(0,Q.useEffect)(o,s);let c;t[5]===i.map.icon?c=t[6]:(c=Xe(i.map.icon),t[5]=i.map.icon,t[6]=c);let l=c,u;t[7]===i.map.cover?u=t[8]:(u=pt(i.map.cover),t[7]=i.map.cover,t[8]=u);let d=u,f=d.kind===`url`||d.kind===`path`,p=l.kind!==`unsupported`;if(!f&&!p)return null;let m=f?`true`:`false`,h=p?`true`:`false`,g;t[9]!==d||t[10]!==f?(g=f?(0,Z.jsx)(sj,{cover:d}):null,t[9]=d,t[10]=f,t[11]=g):g=t[11];let _;t[12]!==f||t[13]!==p||t[14]!==l?(_=p?(0,Z.jsx)(cj,{icon:l,hasCover:f}):null,t[12]=f,t[13]=p,t[14]=l,t[15]=_):_=t[15];let v;return t[16]!==m||t[17]!==h||t[18]!==g||t[19]!==_?(v=(0,Z.jsxs)(`div`,{className:`page-header editor-content-aligned`,"data-has-cover":m,"data-has-icon":h,"aria-hidden":`true`,"data-testid":`page-header`,children:[g,_]}),t[16]=m,t[17]=h,t[18]=g,t[19]=_,t[20]=v):v=t[20],v}function sj(e){let t=(0,$.c)(2),{cover:n}=e,r;return t[0]===n.value?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`page-header-cover`,"data-testid":`page-header-cover`,children:(0,Z.jsx)(`img`,{src:n.value,alt:``,draggable:!1,loading:`lazy`,referrerPolicy:`no-referrer`,className:`page-header-cover-img`})}),t[0]=n.value,t[1]=r),r}function cj(e){let t=(0,$.c)(9),{icon:n,hasCover:r}=e,i=r?`page-header-icon page-header-icon--with-cover`:`page-header-icon`;if(n.kind===`emoji`){let e;return t[0]!==n.value||t[1]!==i?(e=(0,Z.jsx)(`span`,{className:i,"data-testid":`page-header-icon`,"data-kind":`emoji`,children:n.value}),t[0]=n.value,t[1]=i,t[2]=e):e=t[2],e}let a;t[3]===n.value?a=t[4]:(a=(0,Z.jsx)(`img`,{src:n.value,alt:``,draggable:!1,referrerPolicy:`no-referrer`,className:`page-header-icon-img`}),t[3]=n.value,t[4]=a);let o;return t[5]!==n.kind||t[6]!==i||t[7]!==a?(o=(0,Z.jsx)(`span`,{className:i,"data-testid":`page-header-icon`,"data-kind":n.kind,children:a}),t[5]=n.kind,t[6]=i,t[7]=a,t[8]=o):o=t[8],o}var lj=(0,Q.lazy)(async()=>({default:(await n(async()=>{let{ManagedArtifactProperties:e}=await import(`./ManagedArtifactProperties-Bey759wf.js`);return{ManagedArtifactProperties:e}},__vite__mapDeps([71,1,47,2,48,49,31,50,51,52,53,54,55,56,57,20,9,10,7,11,30,3,32,6,4,15,12,13,22,14,58,16,43,59,23,60,66,67,21,72,8,73,74,45,24]),import.meta.url)).ManagedArtifactProperties})),uj=j(`LARGE_DOC_CHAR_THRESHOLD`,5e5);function dj(e){let t=e.threshold??uj;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function fj(e){return e.hasEmittedFirstToggle||!e.isLarge?!1:e.renderSource&&e.renderVisual}var pj=j(`ACTIVITY_MOUNT_LIMIT`,3);function mj(){return n(()=>import(`./SourceEditor-pNjek-_j.js`),__vite__mapDeps([75,1,47,2,48,49,31,50,51,52,53,54,55,56,57,20,9,10,7,11,30,3,32,6,4,15,12,13,22,14,58,16,43,59,23,60,76,34,74,70]),import.meta.url)}var hj=(0,Q.lazy)(async()=>({default:(await mj()).SourceEditor}));function gj(e,t,n){if(n<=0)return[];let r=e.filter(e=>!He(e.docName)),i=[...r].sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt).slice(0,n);if(t===null||i.some(e=>e.docName===t))return i;let a=r.find(e=>e.docName===t);return a?[...i.slice(0,n-1),a]:i}function _j(e,t){return t.kind===`idle`?null:t.kind===`failed`&&t.failedDocNames.includes(e)?{kind:`failed`,title:ic._({id:`MTs6g3`}),summary:t.reason===`clear-data-timeout`?ic._({id:`Sc1bKE`,values:{docName:e}}):ic._({id:`ovIGrT`,values:{docName:e}}),actionLabel:ic._({id:`HpK_8d`})}:t.kind===`recovering`&&t.docNames.includes(e)?{kind:`recovering`,title:ic._({id:`cF9DyA`}),summary:t.phase===`clearing-local-cache`?ic._({id:`bmC18N`,values:{docName:e}}):ic._({id:`pAgkuZ`,values:{docName:e}})}:null}function vj(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(P,{name:`activity-pool`,children:(0,Z.jsx)(yj,{...e})}),t[0]=e,t[1]=n),n}function yj(e){let t=(0,$.c)(15),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=_t(),{pages:u,loading:d}=Oo(),p=gj(c,n,pj),m=(0,Q.useRef)(``),h=p.map(bj).join(`,`),g=(0,Q.useRef)(c),_,v;t[0]===c?(_=t[1],v=t[2]):(_=()=>{g.current=c},v=[c],t[0]=c,t[1]=_,t[2]=v),(0,Q.useLayoutEffect)(_,v),(0,Q.useLayoutEffect)(()=>{if(m.current===h)return;let e=m.current?m.current.split(`,`):[],t=h?h.split(`,`):[],r=e.filter(e=>!t.includes(e)),i=t.filter(t=>!e.includes(t));for(let e of r)f(e);for(let e of i){let t=g.current.find(t=>t.docName===e)?.poolEventId;O(e,t&&t.length>0?t:crypto.randomUUID())}Ot(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:r}),m.current=h,G(t)},[h,n]);let y;t[3]!==n||t[4]!==i||t[5]!==r||t[6]!==d||t[7]!==o||t[8]!==s||t[9]!==u||t[10]!==a||t[11]!==l?(y=e=>(0,Z.jsx)(Ej,{entry:e,isActive:e.docName===n,isSourceMode:r,editorPlaceholder:i,isNewDoc:!d&&!u.has(e.docName)&&!Sr(e.docName),previousDocName:a,onNavigateBack:o,onRecycle:s,serverRestartRecovery:l},e.docName),t[3]=n,t[4]=i,t[5]=r,t[6]=d,t[7]=o,t[8]=s,t[9]=u,t[10]=a,t[11]=l,t[12]=y):y=t[12];let b=p.map(y),x;return t[13]===b?x=t[14]:(x=(0,Z.jsx)(Z.Fragment,{children:b}),t[13]=b,t[14]=x),x}function bj(e){return e.docName}function xj(e){let t=(0,$.c)(8),{isActive:n,initialScrollTop:r,children:i}=e,a=(0,Q.useRef)(null),o=(0,Q.useRef)(r??0),s,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=a.current;if(!e)return;let t=()=>{e.scrollTop>0&&(o.current=e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},c=[],t[0]=s,t[1]=c):(s=t[0],c=t[1]),(0,Q.useEffect)(s,c);let l,u;t[2]===n?(l=t[3],u=t[4]):(l=()=>{if(!n)return;let e=a.current;if(!e)return;let t=o.current;if(t===0)return;let r=performance.now(),i=!1;e.scrollTop=t,e.scrollTop===t&&e.scrollHeight>t&&Ot(`ok/scroll-restore/phase1-success`,{target:t,elapsedMs:performance.now()-r});let s=!1,c=0,l=()=>{s||(s=!0,cancelAnimationFrame(c),clearTimeout(f),e.removeEventListener(`wheel`,u),e.removeEventListener(`touchstart`,u))},u=()=>l();e.addEventListener(`wheel`,u,{passive:!0}),e.addEventListener(`touchstart`,u,{passive:!0});let d=()=>{s||(e.scrollTop!==t&&e.scrollHeight>t&&(e.scrollTop=t,e.scrollTop===t&&!i&&(Ot(`ok/scroll-restore/phase2-success`,{target:t,elapsedMs:performance.now()-r}),i=!0)),c=requestAnimationFrame(d))};c=requestAnimationFrame(d);let f=setTimeout(()=>{s||(e.scrollTop!==t&&e.scrollHeight>t&&Ot(`ok/scroll-restore/abandoned`,{target:t,elapsedMs:performance.now()-r,scrollHeight:e.scrollHeight,finalScrollTop:e.scrollTop}),l())},2e3);return l},u=[n],t[2]=n,t[3]=l,t[4]=u),(0,Q.useLayoutEffect)(l,u);let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={overflowAnchor:`auto`},t[5]=d):d=t[5];let f;return t[6]===i?f=t[7]:(f=(0,Z.jsx)(`div`,{ref:a,"data-testid":`editor-scroll-container`,className:`editor-doc-scroll subtle-scrollbar h-full overflow-y-auto pt-14 scroll-pt-14`,style:d,children:i}),t[6]=i,t[7]=f),f}function Sj(e){let t=(0,$.c)(12),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a}=e,o=r&&i,[s,c]=(0,Q.useState)(o),l,u;if(t[0]===o?(l=t[1],u=t[2]):(l=()=>{o&&c(!0)},u=[o],t[0]=o,t[1]=l,t[2]=u),(0,Q.useEffect)(l,u),!s&&!o)return null;let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(cS,{}),t[3]=d):d=t[3];let f=n.docName,p;t[4]===n.provider.document?p=t[5]:(p=n.provider.document.getText(`source`),t[4]=n.provider.document,t[5]=p);let m;return t[6]!==a||t[7]!==n.docName||t[8]!==n.provider||t[9]!==o||t[10]!==p?(m=(0,Z.jsx)(Q.Suspense,{fallback:d,children:(0,Z.jsx)(hj,{docName:f,ytext:p,provider:n.provider,placeholder:a,isSourceModeActive:o})}),t[6]=a,t[7]=n.docName,t[8]=n.provider,t[9]=o,t[10]=p,t[11]=m):m=t[11],m}function Cj(e){let t=(0,$.c)(18),{view:n}=e,r=n.kind===`failed`,i=r?`alert`:`status`,a=!r,o;t[0]===r?o=t[1]:(o=(0,Z.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-full border bg-muted text-muted-foreground`,children:r?(0,Z.jsx)(Bo,{className:`size-5`,"aria-hidden":`true`}):(0,Z.jsx)(hs,{className:`size-5 animate-spin`,"aria-hidden":`true`})}),t[0]=r,t[1]=o);let s;t[2]===n.title?s=t[3]:(s=(0,Z.jsx)(`h2`,{className:`text-lg font-medium`,children:n.title}),t[2]=n.title,t[3]=s);let c;t[4]===n.summary?c=t[5]:(c=(0,Z.jsx)(`p`,{className:`max-w-md text-sm text-muted-foreground`,children:n.summary}),t[4]=n.summary,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==n.actionLabel?(u=r?(0,Z.jsxs)(Di,{type:`button`,onClick:wj,children:[(0,Z.jsx)(Bo,{className:`size-4`,"aria-hidden":`true`}),n.actionLabel]}):null,t[9]=r,t[10]=n.actionLabel,t[11]=u):u=t[11];let d;return t[12]!==i||t[13]!==a||t[14]!==o||t[15]!==l||t[16]!==u?(d=(0,Z.jsxs)(`div`,{"data-slot":`server-restart-recovery`,role:i,"aria-busy":a,className:`flex h-full flex-col items-center justify-center gap-6 p-8 text-center`,children:[o,l,u]}),t[12]=i,t[13]=a,t[14]=o,t[15]=l,t[16]=u,t[17]=d):d=t[17],d}function wj(){return window.location.reload()}function Tj(e){let t=(0,$.c)(2),{html:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`tiptap-editor h-full pointer-events-none`,"aria-hidden":`true`,children:(0,Z.jsx)(`div`,{className:`tiptap ProseMirror tiptap-editor-portal-content`,dangerouslySetInnerHTML:{__html:n}})}),t[0]=n,t[1]=r),r}function Ej(e){let t=(0,$.c)(53),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a,isNewDoc:o,previousDocName:s,onNavigateBack:c,onRecycle:l,serverRestartRecovery:u}=e,d;t[0]!==n.docName||t[1]!==u?(d=_j(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,p=DT(n.docName)===`conflict`,m;t[3]===n.docName?m=t[4]:(m=()=>{let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-portal`,n.docName),e.style.display=`contents`,e},t[3]=n.docName,t[4]=m);let[h]=(0,Q.useState)(m),g=n.provider.document.getText(`source`).length,[_,v]=(0,Q.useState)(i),[y,b]=(0,Q.useState)(!i),x,S;t[5]!==i||t[6]!==_||t[7]!==y?(x=()=>{i&&!_?v(!0):!i&&!y&&b(!0)},S=[i,_,y],t[5]=i,t[6]=_,t[7]=y,t[8]=x,t[9]=S):(x=t[8],S=t[9]),(0,Q.useEffect)(x,S);let C=dj({ytextLength:g,isSourceMode:i,visitedSource:_,visitedVisual:y}),w=(0,Q.useRef)(``),T=`${C.isLarge}-${C.renderSource}-${C.renderVisual}`,E,D;t[10]!==n.docName||t[11]!==C.isLarge||t[12]!==C.renderSource||t[13]!==C.renderVisual||t[14]!==T||t[15]!==i||t[16]!==g?(E=()=>{w.current!==T&&(w.current=T,C.isLarge&&Ot(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:g,isSourceMode:i,renderSource:C.renderSource,renderVisual:C.renderVisual}))},D=[T,C.isLarge,C.renderSource,C.renderVisual,n.docName,g,i],t[10]=n.docName,t[11]=C.isLarge,t[12]=C.renderSource,t[13]=C.renderVisual,t[14]=T,t[15]=i,t[16]=g,t[17]=E,t[18]=D):(E=t[17],D=t[18]),(0,Q.useEffect)(E,D);let O;t[19]===n.docName?O=t[20]:(O=()=>V(n.docName),t[19]=n.docName,t[20]=O);let[k]=(0,Q.useState)(O),A=k?.html??null,[j,M]=(0,Q.useState)(!1),N,P;t[21]!==n.docName||t[22]!==C.isLarge||t[23]!==C.renderSource||t[24]!==C.renderVisual||t[25]!==j||t[26]!==i||t[27]!==g?(N=()=>{fj({isLarge:C.isLarge,renderSource:C.renderSource,renderVisual:C.renderVisual,hasEmittedFirstToggle:j})&&(Ot(`ok/cold/first-toggle`,{docName:n.docName,mountId:de(n.docName),ytextLength:g,modeEnteredFirst:i?`source`:`visual`}),M(!0))},P=[j,C.isLarge,C.renderSource,C.renderVisual,n.docName,g,i],t[21]=n.docName,t[22]=C.isLarge,t[23]=C.renderSource,t[24]=C.renderVisual,t[25]=j,t[26]=i,t[27]=g,t[28]=N,t[29]=P):(N=t[28],P=t[29]),(0,Q.useEffect)(N,P);let F=r?`visible`:`hidden`,I=`editor:${n.docName}`,L=k?.scrollTop,R;t[30]!==a||t[31]!==n||t[32]!==C.renderSource||t[33]!==C.renderVisual||t[34]!==r||t[35]!==p||t[36]!==o||t[37]!==i||t[38]!==c||t[39]!==l||t[40]!==h||t[41]!==s||t[42]!==f||t[43]!==A?(R=f?(0,Z.jsx)(Cj,{view:f}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(ij,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,Z.jsx)(Q.Suspense,{fallback:A?(0,Z.jsx)(Tj,{html:A}):(0,Z.jsx)(cS,{}),children:(0,Z.jsx)($A,{docName:n.docName,provider:n.provider,children:p?(0,Z.jsx)(QA,{docName:n.docName,provider:n.provider}):(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[!i&&(Sr(n.docName)||ae(n.docName)?(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(lj,{docName:n.docName,provider:n.provider})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(oj,{provider:n.provider}),(0,Z.jsx)(Za,{provider:n.provider})]})),(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[C.renderSource?(0,Z.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,Z.jsx)(Sj,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,C.renderVisual?(0,Z.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,Z.jsx)(XO,{provider:n.provider,placeholder:a,isSourceMode:i,portalTarget:h},`${n.docName}-${String(o)}-${n.poolEventId}`)}):null]})]})})})})}),t[30]=a,t[31]=n,t[32]=C.renderSource,t[33]=C.renderVisual,t[34]=r,t[35]=p,t[36]=o,t[37]=i,t[38]=c,t[39]=l,t[40]=h,t[41]=s,t[42]=f,t[43]=A,t[44]=R):R=t[44];let z;t[45]!==r||t[46]!==L||t[47]!==R?(z=(0,Z.jsx)(xj,{isActive:r,initialScrollTop:L,children:R}),t[45]=r,t[46]=L,t[47]=R,t[48]=z):z=t[48];let B;return t[49]!==F||t[50]!==I||t[51]!==z?(B=(0,Z.jsx)(Q.Activity,{mode:F,name:I,children:z}),t[49]=F,t[50]=I,t[51]=z,t[52]=B):B=t[52],B}function Dj(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function Oj(e){let{value:t,unit:n}=Dj(e);return n===`rem`?t*16:t}function kj(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var Aj=3600*24*7;function jj(e){let t=(0,$.c)(28),{direction:n,currentWidth:r,onResize:i,onToggle:a,isCollapsed:o,minResizeWidth:s,maxResizeWidth:c,enableToggle:l,enableAutoCollapse:u,autoCollapseThreshold:d,expandThreshold:f,enableDrag:p,setIsDraggingRail:m,widthCookieName:h,widthCookieMaxAge:g,isNested:_}=e,v=n===void 0?`right`:n,y=o===void 0?!1:o,b=s===void 0?`14rem`:s,x=c===void 0?`24rem`:c,S=l===void 0?!0:l,C=u===void 0?!0:u,w=d===void 0?1.5:d,T=f===void 0?.2:f,E=p===void 0?!0:p,D=m===void 0?Mj:m,O=g===void 0?Aj:g,k=_===void 0?!1:_,A=(0,Q.useRef)(null),j=(0,Q.useRef)(0),M=(0,Q.useRef)(0),N=(0,Q.useRef)(!1),P=(0,Q.useRef)(!1),F=(0,Q.useRef)(null),I=(0,Q.useRef)(0),L=(0,Q.useRef)(!1),R=(0,Q.useRef)(0),z=(0,Q.useRef)(0),B=(0,Q.useRef)(null),V=(0,Q.useRef)(r),H=(0,Q.useRef)(y),U,W;t[0]===r?(U=t[1],W=t[2]):(U=()=>{V.current=r},W=[r],t[0]=r,t[1]=U,t[2]=W),(0,Q.useEffect)(U,W);let G,K;t[3]===y?(G=t[4],K=t[5]):(G=()=>{H.current=y},K=[y],t[3]=y,t[4]=G,t[5]=K),(0,Q.useEffect)(G,K);let q=Oj(b),J;t[6]===x?J=t[7]:(J=Oj(x),t[6]=x,t[7]=J);let Y=J,ee;t[8]!==E||t[9]!==k?(ee=function(e){E&&(P.current=!0,j.current=H.current?0:Oj(V.current),M.current=e.clientX,I.current=e.clientX,F.current=null,L.current=!1,R.current=0,z.current=0,B.current=k&&A.current?A.current.getBoundingClientRect():null,e.preventDefault())},t[8]=E,t[9]=k,t[10]=ee):ee=t[10];let te=ee,ne,re;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==Y||t[18]!==q||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(ne=()=>{let e=function(e){h&&(document.cookie=`${h}=${e}; path=/; max-age=${O}`)},t=function(e,t){return v===`left`?e<t:e>t},n=function(e,t,n,r){if(k&&r){let r=e.clientX-t;return v===`left`?n-r:n+r}return v===`left`?window.innerWidth-e.clientX:e.clientX},r=function(r){if(!P.current)return;let o=Math.abs(r.clientX-M.current);if(!N.current&&o>5&&(N.current=!0,D(!0)),N.current){let{unit:o}=Dj(V.current),s=B.current;k&&A.current&&(s=A.current.getBoundingClientRect());let c=t(r.clientX,I.current)?`expand`:`collapse`;F.current!==c&&(F.current=c),z.current=Math.abs(r.clientX-I.current);let l=Date.now();if(L.current&&l-R.current>200&&(L.current=!1),!L.current){if(C&&a&&!H.current){let e=n(r,M.current,j.current,s),t=!1;if(w<=1)t=e<=q*w;else if(e<=q){let n=q*(w-1);t=q-e>=n}if(c===`collapse`&&t){a(),I.current=r.clientX,L.current=!0,R.current=l;return}}if(a&&H.current&&c===`expand`&&z.current>q*T){a();let t=n(r,M.current,j.current,s),c=Math.max(q,Math.min(Y,t)),u=kj(o===`rem`?c/16:c,o);i(u),e(u),I.current=r.clientX,L.current=!0,R.current=l;return}}if(H.current)return;let u=n(r,M.current,j.current,s),d=Math.max(q,Math.min(Y,u)),f=kj(o===`rem`?d/16:d,o);i(f),e(f)}},o=function(){P.current&&(!N.current&&a&&S&&a(),N.current=!1,P.current=!1,F.current=null,I.current=0,L.current=!1,R.current=0,z.current=0,B.current=null,D(!1))};return document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,o),()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,o)}},re=[i,a,D,q,Y,k,C,w,T,S,h,O,v],t[11]=w,t[12]=v,t[13]=C,t[14]=S,t[15]=T,t[16]=k,t[17]=Y,t[18]=q,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=ne,t[25]=re):(ne=t[24],re=t[25]),(0,Q.useEffect)(ne,re);let ie;return t[26]===te?ie=t[27]:(ie={dragRef:A,isDragging:N,handleMouseDown:te},t[26]=te,t[27]=ie),ie}function Mj(){}var Nj=3600*24*7,Pj=`18rem`,Fj=`3rem`,Ij=`app-file-sidebar`,Lj=`14.625rem`,Rj=`32rem`,zj=`sidebar_width`,Bj=/^\d+(?:\.\d+)?(?:rem|px)$/,Vj=Q.createContext(null);function Hj(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${zj}=`))?.split(`=`)[1];if(!t)return e;let n;try{n=decodeURIComponent(t)}catch{return e}return Bj.test(n)?n:e}function Uj(){let e=Q.use(Vj);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function Wj(e){let t=(0,$.c)(58),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({open:i,onOpenChange:o,className:r,style:s,children:n,defaultWidth:c,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c===void 0?Pj:c,[u]=Q.useState(Kj),d;t[8]===u?d=t[9]:(d=()=>LT(u,window.innerWidth,`left`),t[8]=u,t[9]=d);let[f,p]=Q.useState(d),m;t[10]===l?m=t[11]:(m=()=>Hj(l),t[10]=l,t[11]=m);let[h,g]=Q.useState(m),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),x;t[12]===u?x=t[13]:(x=()=>{let e=WT();return KT(`left`,LT(u,window.innerWidth,`left`),e)===`open`},t[12]=u,t[13]=x);let[S,C]=Q.useState(x),w=i??S,T;t[14]!==w||t[15]!==f||t[16]!==o?(T=e=>{let t=typeof e==`function`?e(w):e;o?o(t):C(t),qT(`left`,f,t?`open`:`collapsed`)},t[14]=w,t[15]=f,t[16]=o,t[17]=T):T=t[17];let E=T,D;t[18]===E?D=t[19]:(D=function(){E(Gj)},t[18]=E,t[19]=D);let O=D,k=Q.useRef(w),A;t[20]===w?A=t[21]:(A=()=>{k.current=w},t[20]=w,t[21]=A),Q.useLayoutEffect(A);let j;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(){window.innerWidth>=1024||k.current&&(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||b(!0))},t[22]=j):j=t[22];let M=j,N,P;t[23]===u?(N=t[24],P=t[25]):(P=()=>{let e=window.matchMedia(`(min-width: ${PT}px)`),t=()=>{let e=LT(u,window.innerWidth,`left`);p(e),C(KT(`left`,e,WT())===`open`)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},N=[u],t[23]=u,t[24]=N,t[25]=P),Q.useEffect(P,N);let F,I;t[26]===w?(F=t[27],I=t[28]):(F=()=>{w||document.getElementById(Ij)?.contains(document.activeElement)&&document.querySelector(`[data-sidebar="trigger"]`)?.focus()},I=[w],t[26]=w,t[27]=F,t[28]=I),Q.useLayoutEffect(F,I);let L,R;t[29]!==w||t[30]!==f||t[31]!==E?(L=()=>{if(f===`above`||!w)return;let e=e=>{e.key===`Escape`&&(document.querySelector(`[data-state="open"][role="dialog"], [data-state="open"][role="alertdialog"], [data-state="open"][role="menu"], [data-state="open"][role="listbox"], [data-radix-popper-content-wrapper] [data-state="open"]`)||E(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},R=[f,w,E],t[29]=w,t[30]=f,t[31]=E,t[32]=L,t[33]=R):(L=t[32],R=t[33]),Q.useEffect(L,R);let z,B;t[34]===O?(z=t[35],B=t[36]):(z=()=>{if(typeof window<`u`&&window.okDesktop!=null)return;let e=e=>{Sl(e,`toggle-files-sidebar`)&&(e.preventDefault(),O())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},B=[O],t[34]=O,t[35]=z,t[36]=B),Q.useEffect(z,B);let V=w?`expanded`:`collapsed`,H;t[37]!==_||t[38]!==w||t[39]!==E||t[40]!==y||t[41]!==V||t[42]!==O||t[43]!==h?(H={state:V,open:w,setOpen:E,toggleSidebar:O,width:h,setWidth:g,isDraggingRail:_,setIsDraggingRail:v,showPushPulse:y,setShowPushPulse:b,notifySidebarFileSelected:M},t[37]=_,t[38]=w,t[39]=E,t[40]=y,t[41]=V,t[42]=O,t[43]=h,t[44]=H):H=t[44];let U;t[45]!==s||t[46]!==h?(U={"--sidebar-width":h,"--sidebar-width-icon":Fj,...s},t[45]=s,t[46]=h,t[47]=U):U=t[47];let W=U,G;t[48]===r?G=t[49]:(G=Ti(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[48]=r,t[49]=G);let K;t[50]!==n||t[51]!==a||t[52]!==W||t[53]!==G?(K=(0,Z.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:W,className:G,...a,children:n}),t[50]=n,t[51]=a,t[52]=W,t[53]=G,t[54]=K):K=t[54];let q;return t[55]!==H||t[56]!==K?(q=(0,Z.jsx)(Vj.Provider,{value:H,children:K}),t[55]=H,t[56]=K,t[57]=q):q=t[57],q}function Gj(e){return!e}function Kj(){return Ir()}function qj(e){let t=(0,$.c)(39),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]):({side:a,variant:o,collapsible:s,className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a===void 0?`left`:a,l=o===void 0?`sidebar`:o,u=s===void 0?`offcanvas`:s,{_:d}=cn(),{state:f,isDraggingRail:p}=Uj();if(u===`none`){let e;t[7]===r?e=t[8]:(e=Ti(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[7]=r,t[8]=e);let a;return t[9]!==n||t[10]!==i||t[11]!==e||t[12]!==l?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":l,className:e,...i,children:n}),t[9]=n,t[10]=i,t[11]=e,t[12]=l,t[13]=a):a=t[13],a}let m=f===`collapsed`?u:``,h=l===`floating`||l===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,g;t[14]===h?g=t[15]:(g=Ti(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,h,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`),t[14]=h,t[15]=g);let _;t[16]===g?_=t[17]:(_=(0,Z.jsx)(`div`,{"data-slot":`sidebar-gap`,className:g}),t[16]=g,t[17]=_);let v;t[18]===d?v=t[19]:(v=d({id:`07q4Qk`}),t[18]=d,t[19]=v);let y=l===`floating`||l===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,b;t[20]!==r||t[21]!==y?(b=Ti(`fixed inset-y-0 z-10 flex h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear motion-reduce:transition-none motion-reduce:duration-0 data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]`,y,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`,r),t[20]=r,t[21]=y,t[22]=b):b=t[22];let x;t[23]===n?x=t[24]:(x=(0,Z.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[23]=n,t[24]=x);let S;t[25]!==i||t[26]!==c||t[27]!==b||t[28]!==x||t[29]!==v?(S=(0,Z.jsx)(`nav`,{id:Ij,"aria-label":v,"data-slot":`sidebar-container`,"data-side":c,className:b,...i,children:x}),t[25]=i,t[26]=c,t[27]=b,t[28]=x,t[29]=v,t[30]=S):S=t[30];let C;return t[31]!==p||t[32]!==c||t[33]!==f||t[34]!==S||t[35]!==m||t[36]!==_||t[37]!==l?(C=(0,Z.jsxs)(`div`,{className:`group peer text-sidebar-foreground`,"data-state":f,"data-collapsible":m,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-dragging":p,children:[_,S]}),t[31]=p,t[32]=c,t[33]=f,t[34]=S,t[35]=m,t[36]=_,t[37]=l,t[38]=C):C=t[38],C}function Jj(e){let t=(0,$.c)(34),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onClick:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{_:a}=cn(),{toggleSidebar:o,state:s}=Uj(),c,l,u,d,f,p,m,h;if(t[4]!==a||t[5]!==s){let e=Cl(`toggle-files-sidebar`);c=Di,l=`trigger`,u=`sidebar-trigger`,d=`ghost`,f=`icon-sm`,p=s===`expanded`,m=Ij,h=a(s===`expanded`?{id:`4PYsOz`,values:{sidebarShortcutLabel:e}}:{id:`jbSG8V`,values:{sidebarShortcutLabel:e}}),t[4]=a,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}else c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13];let g;t[14]===n?g=t[15]:(g=Ti(n),t[14]=n,t[15]=g);let _;t[16]!==r||t[17]!==o?(_=e=>{r?.(e),o()},t[16]=r,t[17]=o,t[18]=_):_=t[18];let v;t[19]===s?v=t[20]:(v=s===`expanded`?(0,Z.jsx)(It,{}):(0,Z.jsx)(_d,{}),t[19]=s,t[20]=v);let y;return t[21]!==c||t[22]!==i||t[23]!==l||t[24]!==v||t[25]!==u||t[26]!==d||t[27]!==f||t[28]!==p||t[29]!==m||t[30]!==h||t[31]!==g||t[32]!==_?(y=(0,Z.jsx)(c,{"data-sidebar":l,"data-slot":u,variant:d,size:f,"aria-expanded":p,"aria-controls":m,"aria-label":h,className:g,onClick:_,...i,children:v}),t[21]=c,t[22]=i,t[23]=l,t[24]=v,t[25]=u,t[26]=d,t[27]=f,t[28]=p,t[29]=m,t[30]=h,t[31]=g,t[32]=_,t[33]=y):y=t[33],y}function Yj(e){let t=(0,$.c)(32),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,enableDrag:a,enableToggle:o,onMouseDown:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?!0:a,c=o===void 0?!0:o,{_:l}=cn(),{toggleSidebar:u,setWidth:d,state:f,width:p,setIsDraggingRail:m}=Uj(),h=f===`collapsed`,g;t[6]!==s||t[7]!==c||t[8]!==m||t[9]!==d||t[10]!==h||t[11]!==u||t[12]!==p?(g={direction:`right`,enableDrag:s,enableToggle:c,onResize:d,onToggle:u,currentWidth:p,isCollapsed:h,minResizeWidth:Lj,maxResizeWidth:Rj,setIsDraggingRail:m,widthCookieName:zj,widthCookieMaxAge:Nj},t[6]=s,t[7]=c,t[8]=m,t[9]=d,t[10]=h,t[11]=u,t[12]=p,t[13]=g):g=t[13];let{dragRef:_,handleMouseDown:v}=jj(g),y;t[14]!==l||t[15]!==f?(y=l(f===`expanded`?{id:`w3vFfL`}:{id:`e8zRrb`}),t[14]=l,t[15]=f,t[16]=y):y=t[16];let b;t[17]!==v||t[18]!==r?(b=e=>{r?.(e),e.defaultPrevented||v(e)},t[17]=v,t[18]=r,t[19]=b):b=t[19];let x;t[20]!==l||t[21]!==f?(x=l(f===`expanded`?{id:`w3vFfL`}:{id:`e8zRrb`}),t[20]=l,t[21]=f,t[22]=x):x=t[22];let S;t[23]===n?S=t[24]:(S=Ti(`absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,`in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,`md:group-data-[variant=inset]:after:inset-y-5`,n),t[23]=n,t[24]=S);let C;return t[25]!==_||t[26]!==i||t[27]!==y||t[28]!==b||t[29]!==x||t[30]!==S?(C=(0,Z.jsx)(`button`,{ref:_,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":y,tabIndex:-1,onMouseDown:b,title:x,className:S,...i}),t[25]=_,t[26]=i,t[27]=y,t[28]=b,t[29]=x,t[30]=S,t[31]=C):C=t[31],C}function Xj(e){let t=(0,$.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onAnimationEnd:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{showPushPulse:a,setShowPushPulse:o}=Uj(),s;t[4]!==r||t[5]!==o?(s=e=>{r?.(e),e.animationName===`sidebar-push-pulse`&&o(!1)},t[4]=r,t[5]=o,t[6]=s):s=t[6];let c=s,l=a?``:void 0,u;t[7]===n?u=t[8]:(u=Ti(`relative flex w-full flex-1 flex-col bg-background peer-data-[variant=inset]:m-2 peer-data-[variant=inset]:ml-0 peer-data-[variant=inset]:rounded-xl peer-data-[variant=inset]:shadow-sm peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,n),t[7]=n,t[8]=u);let d;return t[9]!==c||t[10]!==i||t[11]!==l||t[12]!==u?(d=(0,Z.jsx)(`main`,{"data-slot":`sidebar-inset`,"data-push-pulse":l,onAnimationEnd:c,className:u,...i}),t[9]=c,t[10]=i,t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function Zj(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Qj(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $j(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function eM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`relative flex w-full min-w-0 flex-col p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function tM(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,asChild:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i?Ei:`div`,o;t[4]===n?o=t[5]:(o=Ti(`flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(a,{"data-slot":`sidebar-group-label`,"data-sidebar":`group-label`,className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function nM(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,asChild:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i?Ei:`button`,o;t[4]===n?o=t[5]:(o=Ti(`absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(a,{"data-slot":`sidebar-group-action`,"data-sidebar":`group-action`,className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function rM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`w-full text-sm`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function iM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`flex w-full min-w-0 flex-col gap-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function aM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var oM=wi(`peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-hover data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-hover hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-hover hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function sM(e){let t=(0,$.c)(28),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({asChild:i,isActive:a,variant:o,size:s,tooltip:c,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=i===void 0?!1:i,u=a===void 0?!1:a,d=o===void 0?`default`:o,f=s===void 0?`default`:s,p=l?Ei:`button`,{state:m}=Uj(),h;t[8]!==n||t[9]!==f||t[10]!==d?(h=Ti(oM({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=h):h=t[11];let g;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==h?(g=(0,Z.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:h,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=h,t[17]=g):g=t[17];let _=g;if(!c)return _;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let v;t[20]===_?v=t[21]:(v=(0,Z.jsx)(pc,{asChild:!0,children:_}),t[20]=_,t[21]=v);let y=m!==`collapsed`,b;t[22]!==y||t[23]!==c?(b=(0,Z.jsx)(mc,{side:`right`,align:`center`,hidden:y,...c}),t[22]=y,t[23]=c,t[24]=b):b=t[24];let x;return t[25]!==v||t[26]!==b?(x=(0,Z.jsxs)(gc,{children:[v,b]}),t[25]=v,t[26]=b,t[27]=x):x=t[27],x}function cM(e){let t=(0,$.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,asChild:i,showOnHover:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?!1:i,s=a===void 0?!1:a,c=o?Ei:`button`,l=s&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0`,u;t[5]!==n||t[6]!==l?(u=Ti(`absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,l,n),t[5]=n,t[6]=l,t[7]=u):u=t[7];let d;return t[8]!==c||t[9]!==r||t[10]!==u?(d=(0,Z.jsx)(c,{"data-slot":`sidebar-menu-action`,"data-sidebar":`menu-action`,className:u,...r}),t[8]=c,t[9]=r,t[10]=u,t[11]=d):d=t[11],d}function lM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`ul`,{"data-slot":`sidebar-menu-sub`,"data-sidebar":`menu-sub`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function uM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`group/menu-sub-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`li`,{"data-slot":`sidebar-menu-sub-item`,"data-sidebar":`menu-sub-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function dM(e){let t=(0,$.c)(14),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({asChild:i,size:a,isActive:o,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=i===void 0?!1:i,c=a===void 0?`md`:a,l=o===void 0?!1:o,u=s?Ei:`a`,d;t[6]===n?d=t[7]:(d=Ti(`flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,n),t[6]=n,t[7]=d);let f;return t[8]!==u||t[9]!==l||t[10]!==r||t[11]!==c||t[12]!==d?(f=(0,Z.jsx)(u,{"data-slot":`sidebar-menu-sub-button`,"data-sidebar":`menu-sub-button`,"data-size":c,"data-active":l,className:d,...r}),t[8]=u,t[9]=l,t[10]=r,t[11]=c,t[12]=d,t[13]=f):f=t[13],f}function fM(e){let t=null,n=!1,r=new Set;function i(e){if(e!==t){t=e;for(let e of r)e()}}e.subscribeToEvent(i);async function a(){if(!n){n=!0;try{i(await e.fetchBranch())}catch{}}}return{getSnapshot:()=>t,subscribe(e){return r.add(e),a(),()=>{r.delete(e)}}}}async function pM(){let e=await fetch(`/api/server-info`,{signal:AbortSignal.timeout(5e3)});if(!e.ok)return null;let t=await e.json(),n=Qr.safeParse(t);return n.success?n.data.currentBranch??null:null}var mM=typeof window>`u`?{getSnapshot:()=>null,subscribe:()=>()=>{}}:fM({fetchBranch:pM,subscribeToEvent:Zs}),hM=mM.subscribe,gM=mM.getSnapshot;function _M(){return(0,Q.useSyncExternalStore)(hM,gM,gM)}function vM(){let e=(0,$.c)(6),t=_M(),n=Ho(),{state:r}=Uj(),i=typeof window<`u`?window.okDesktop:void 0;if(i&&r===`expanded`)return null;let a;e[0]===n?a=e[1]:(a=i?.config.projectName??(n&&Wi(n.contentDir)||null),e[0]=n,e[1]=a);let o=a,s=i?.config.projectPath??n?.contentDir??null;if(o===null&&t===null)return null;let c;return e[2]!==t||e[3]!==o||e[4]!==s?(c={projectName:o,projectPath:s,branch:t},e[2]=t,e[3]=o,e[4]=s,e[5]=c):c=e[5],c}function yM(e){let t=(0,$.c)(27),{stats:n,selectionStats:r,showStats:i,composerBadge:a}=e,o=i===void 0?!0:i,{_:s}=cn(),c=vM();if(!o&&c===null&&a==null)return null;let l=r??n,u=r!=null,{words:d,chars:f,tokens:p}=l,m;t[0]!==s||t[1]!==u||t[2]!==o?(m=s(o?u?{id:`Bv5a9_`}:{id:`L1ZE3M`}:{id:`goO4Ll`}),t[0]=s,t[1]=u,t[2]=o,t[3]=m):m=t[3];let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-full h-2 bg-linear-to-t from-background to-transparent`}),t[4]=h):h=t[4];let g;t[5]!==s||t[6]!==a?(g=a?(0,Z.jsxs)(Di,{type:`button`,variant:`outline`,onClick:a.onReopen,"data-testid":`ask-ai-reopen-badge`,className:`-translate-x-1/2 absolute bottom-0 left-1/2 z-10 h-auto gap-1 rounded-md rounded-b-none bg-card px-2.5 py-0.5 text-2xs font-normal text-muted-foreground shadow-sm hover:text-foreground active:not-aria-[haspopup]:translate-y-0`,children:[(0,Z.jsx)(Ws,{className:`size-3`,"aria-hidden":!0}),s({id:`xWEvuo`}),(0,Z.jsx)(st,{className:`size-3`,"aria-hidden":!0})]}):null,t[5]=s,t[6]=a,t[7]=g):g=t[7];let _;t[8]===c?_=t[9]:(_=c===null?null:(0,Z.jsx)(bM,{identity:c}),t[8]=c,t[9]=_);let v;t[10]===_?v=t[11]:(v=(0,Z.jsx)(`span`,{className:`flex min-w-0 items-center gap-3`,children:_}),t[10]=_,t[11]=v);let y;t[12]!==s||t[13]!==l.chars||t[14]!==l.tokens||t[15]!==l.words||t[16]!==f||t[17]!==u||t[18]!==o||t[19]!==p||t[20]!==d?(y=o?(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[u?(0,Z.jsx)(`span`,{className:`font-medium text-foreground/70`,"data-testid":`editor-footer-selected-label`,children:s({id:`ylXj1N`})}):null,(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`tabular-nums`,children:l.words.toLocaleString()}),` `,(0,Z.jsx)(X,{id:`gljvbT`,values:{words:d}})]}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`tabular-nums`,children:l.chars.toLocaleString()}),` `,(0,Z.jsx)(X,{id:`d5rK4X`,values:{chars:f}})]}),(0,Z.jsxs)(`span`,{children:[l.tokens>0?`~`:``,(0,Z.jsx)(`span`,{className:`tabular-nums`,children:l.tokens.toLocaleString()}),` `,(0,Z.jsx)(X,{id:`uynXup`,values:{tokens:p}})]})]}):null,t[12]=s,t[13]=l.chars,t[14]=l.tokens,t[15]=l.words,t[16]=f,t[17]=u,t[18]=o,t[19]=p,t[20]=d,t[21]=y):y=t[21];let b;return t[22]!==m||t[23]!==g||t[24]!==v||t[25]!==y?(b=(0,Z.jsxs)(`section`,{"aria-label":m,className:`relative flex h-6 shrink-0 items-center justify-between gap-3 bg-background px-3 text-2xs text-muted-foreground`,children:[h,g,v,y]}),t[22]=m,t[23]=g,t[24]=v,t[25]=y,t[26]=b):b=t[26],b}function bM(e){let t=(0,$.c)(8),{identity:n}=e,{projectName:r,projectPath:i,branch:a}=n,o;t[0]!==r||t[1]!==i?(o=r===null?null:i?(0,Z.jsxs)(gc,{children:[(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(`span`,{tabIndex:0,className:`truncate`,"data-testid":`editor-footer-project-name`,children:r})}),(0,Z.jsx)(mc,{side:`top`,className:`max-w-xs break-all`,children:i})]}):(0,Z.jsx)(`span`,{className:`truncate`,"data-testid":`editor-footer-project-name`,children:r}),t[0]=r,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=a===null?null:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,"data-testid":`editor-footer-branch`,children:[(0,Z.jsx)(Jt,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:a})]}),t[3]=a,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,Z.jsxs)(Z.Fragment,{children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function xM(e){let t=(0,$.c)(11),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}=cn(),a;t[3]===i?a=t[4]:(a=i({id:`3__SjS`}),t[3]=i,t[4]=a);let o;t[5]===n?o=t[6]:(o=Ti(n),t[5]=n,t[6]=o);let s;return t[7]!==r||t[8]!==a||t[9]!==o?(s=(0,Z.jsx)(`nav`,{"aria-label":a,"data-slot":`breadcrumb`,className:o,...r}),t[7]=r,t[8]=a,t[9]=o,t[10]=s):s=t[10],s}function SM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`ol`,{"data-slot":`breadcrumb-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function CM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`inline-flex items-center gap-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`li`,{"data-slot":`breadcrumb-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function wM(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({current:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0||i?`page`:void 0,o;t[4]===n?o=t[5]:(o=Ti(`font-normal text-foreground`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,Z.jsx)(`span`,{"data-slot":`breadcrumb-page`,"aria-current":a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function TM(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({children:n,className:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=Ti(`[&>svg]:size-3.5`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=n??(0,Z.jsx)(co,{}),t[6]=n,t[7]=o);let s;return t[8]!==i||t[9]!==a||t[10]!==o?(s=(0,Z.jsx)(`li`,{"data-slot":`breadcrumb-separator`,role:`presentation`,"aria-hidden":`true`,className:a,...i,children:o}),t[8]=i,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}var EM=1,DM=2,OM=4;function kM(e){let t=(0,$.c)(18),{docName:n,className:r}=e;if(!n)return null;let i,a,o,s,c,l;if(t[0]!==r||t[1]!==n){l=Symbol.for(`react.early_return_sentinel`);bb0:{let e=ti(n),u=e?e.kind===`template`?e.folder.split(`/`).filter(Boolean):[]:Zt(n,``).prefix.replace(/\/$/,``).split(`/`).filter(Boolean);if(u.length===0){l=null;break bb0}let d=(e,t)=>({kind:`segment`,value:e,key:u.slice(0,t+1).join(`/`)}),f=u.length>OM?[...u.slice(0,EM).map((e,t)=>d(e,t)),{kind:`ellipsis`,hidden:u.slice(EM,-DM)},...u.slice(-DM).map((e,t)=>d(e,u.length-DM+t))]:u.map((e,t)=>d(e,t));a=xM,t[8]===r?c=t[9]:(c=Ti(`flex min-w-0 items-center`,r),t[8]=r,t[9]=c),i=SM,o=`min-w-0 flex-nowrap gap-1 overflow-hidden text-muted-foreground/70 text-xs`,s=f.map(AM)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u;t[10]!==i||t[11]!==o||t[12]!==s?(u=(0,Z.jsx)(i,{className:o,children:s}),t[10]=i,t[11]=o,t[12]=s,t[13]=u):u=t[13];let d;return t[14]!==a||t[15]!==c||t[16]!==u?(d=(0,Z.jsx)(a,{className:c,children:u}),t[14]=a,t[15]=c,t[16]=u,t[17]=d):d=t[17],d}function AM(e,t){let n=e.kind===`segment`?e.key:`ellipsis`;return(0,Z.jsxs)(Q.Fragment,{children:[t>0&&(0,Z.jsx)(TM,{className:`shrink-0 text-muted-foreground/70 [&>svg]:size-3`}),e.kind===`ellipsis`?(0,Z.jsxs)(CM,{className:`shrink-0`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,title:e.hidden.join(` / `),className:`flex size-4 items-center justify-center text-muted-foreground/70`,children:(0,Z.jsx)(Uu,{className:`size-3.5`})}),(0,Z.jsx)(`span`,{className:`sr-only`,children:e.hidden.join(` / `)})]}):(0,Z.jsx)(CM,{className:`min-w-0`,children:(0,Z.jsx)(wM,{current:!1,className:`min-w-0 truncate font-normal text-muted-foreground/70`,title:e.value,children:e.value})})]},n)}var jM={fill:`none`,height:24,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`,width:24,xmlns:`http://www.w3.org/2000/svg`},MM=e=>{let t=(0,$.c)(15),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({color:a,size:o,strokeWidth:s,absoluteStrokeWidth:n,className:c,children:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=a===void 0?`currentColor`:a,u=o===void 0?24:o,d=s===void 0?2:s,f=c===void 0?``:c,p=n?Number(d)*24/Number(u):d,m;return t[8]!==r||t[9]!==f||t[10]!==l||t[11]!==i||t[12]!==u||t[13]!==p?(m=(0,Z.jsx)(`svg`,{"aria-hidden":`true`,...jM,className:f,height:u,stroke:l,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:p,width:u,...i,children:r}),t[8]=r,t[9]=f,t[10]=l,t[11]=i,t[12]=u,t[13]=p,t[14]=m):m=t[14],m},NM=e=>{let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Markdown`}),r=(0,Z.jsx)(`path`,{d:`M232,48H24A16,16,0,0,0,8,64V192a16,16,0,0,0,16,16H232a16,16,0,0,0,16-16V64A16,16,0,0,0,232,48Zm0,144H24V64H232V192ZM128,104v48a8,8,0,0,1-16,0V123.31L93.66,141.66a8,8,0,0,1-11.32,0L64,123.31V152a8,8,0,0,1-16,0V104a8,8,0,0,1,13.66-5.66L88,124.69l26.34-26.35A8,8,0,0,1,128,104Zm77.66,18.34a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L168,132.69V104a8,8,0,0,1,16,0v28.69l10.34-10.35A8,8,0,0,1,205.66,122.34Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(MM,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},PM=e=>{let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Textbox`}),r=(0,Z.jsx)(`path`,{d:`M112,40a8,8,0,0,0-8,8V64H24A16,16,0,0,0,8,80v96a16,16,0,0,0,16,16h80v16a8,8,0,0,0,16,0V48A8,8,0,0,0,112,40ZM24,176V80h80v96ZM248,80v96a16,16,0,0,1-16,16H144a8,8,0,0,1,0-16h88V80H144a8,8,0,0,1,0-16h88A16,16,0,0,1,248,80ZM88,112a8,8,0,0,1-8,8H72v24a8,8,0,0,1-16,0V120H48a8,8,0,0,1,0-16H80A8,8,0,0,1,88,112Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(MM,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i};function FM(e){let t=(0,$.c)(29),{isSourceMode:n,onModeChange:r,sourceDisabled:i}=e,a=i===void 0?!1:i,{_:o}=cn(),s=n?`source`:`wysiwyg`,c;t[0]===r?c=t[1]:(c=e=>{e&&r(e)},t[0]=r,t[1]=c);let l;t[2]===o?l=t[3]:(l=o({id:`n7aopT`}),t[2]=o,t[3]=l);let u;t[4]===o?u=t[5]:(u=o({id:`ur2XSb`}),t[4]=o,t[5]=u);let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(pc,{children:(0,Z.jsx)(PM,{className:`size-4`})}),t[6]=d):d=t[6];let f;t[7]===u?f=t[8]:(f=(0,Z.jsx)(Ba,{value:`wysiwyg`,"aria-label":u,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,asChild:!0,children:d}),t[7]=u,t[8]=f);let p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(mc,{side:`bottom`,children:(0,Z.jsx)(X,{id:`Mb_20S`})}),t[9]=p):p=t[9];let m;t[10]===f?m=t[11]:(m=(0,Z.jsxs)(gc,{children:[f,p]}),t[10]=f,t[11]=m);let h;t[12]===o?h=t[13]:(h=o({id:`xbdtfY`}),t[12]=o,t[13]=h);let g;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(NM,{className:`size-4`}),t[14]=g):g=t[14];let _;t[15]!==a||t[16]!==h?(_=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(`div`,{children:(0,Z.jsx)(Ba,{value:`source`,"aria-label":h,disabled:a,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,children:g})})}),t[15]=a,t[16]=h,t[17]=_):_=t[17];let v;t[18]===a?v=t[19]:(v=(0,Z.jsx)(mc,{side:`bottom`,children:a?(0,Z.jsx)(X,{id:`G-JBA1`}):(0,Z.jsx)(X,{id:`u6Hp4N`})}),t[18]=a,t[19]=v);let y;t[20]!==_||t[21]!==v?(y=(0,Z.jsxs)(gc,{children:[_,v]}),t[20]=_,t[21]=v,t[22]=y):y=t[22];let b;return t[23]!==y||t[24]!==s||t[25]!==c||t[26]!==l||t[27]!==m?(b=(0,Z.jsxs)(Ha,{type:`single`,value:s,onValueChange:c,"aria-label":l,variant:`segmented`,size:`sm`,spacing:1,className:`shrink-0 bg-muted p-0.5 data-[size=sm]:rounded-[10px]`,children:[m,y]}),t[23]=y,t[24]=s,t[25]=c,t[26]=l,t[27]=m,t[28]=b):b=t[28],b}var IM=(0,Q.lazy)(async()=>({default:(await n(async()=>{let{SkillEditorActions:e}=await import(`./SkillEditorActions-BQYuB-4q.js`);return{SkillEditorActions:e}},__vite__mapDeps([77,1,30,3,7,31,6,10,67,20,9,11,32,12,13,21,16,58,69,18,59,62,23]),import.meta.url)).SkillEditorActions}));function LM(e){let t=(0,$.c)(79),{activeDocName:n,isSourceMode:r,sourceDisabled:i,onModeChange:a,showAddPropertyButton:o,onAddProperty:s,isPanelCollapsed:c,onTogglePanel:l}=e,{_:u}=cn(),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=xl(`toggle-document-panel`),t[0]=d):d=t[0];let f=d,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D;if(t[1]!==u||t[2]!==n||t[3]!==c||t[4]!==r||t[5]!==s||t[6]!==a||t[7]!==l||t[8]!==o||t[9]!==i){let e=Cl(`toggle-document-panel`),d;t[25]===n?d=t[26]:(d=n?ti(n):null,t[25]=n,t[26]=d);let f=d,O;t[27]===n?O=t[28]:(O=n?ae(n):null,t[27]=n,t[28]=O);let k=O,A;t[29]!==f||t[30]!==k?(A=f?.kind===`skill`?{scope:f.scope,name:f.name}:k?{scope:`project`,name:k}:null,t[29]=f,t[30]=k,t[31]=A):A=t[31];let j=A;_=`editor-toolbar`,v=`pointer-events-none absolute inset-x-0 top-0 z-10`;let M;t[32]!==n||t[33]!==j?(M=j?null:(0,Z.jsx)(kM,{docName:n}),t[32]=n,t[33]=j,t[34]=M):M=t[34];let N;t[35]===M?N=t[36]:(N=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex min-w-0 items-center`,children:M}),t[35]=M,t[36]=N);let P;t[37]!==r||t[38]!==a||t[39]!==i?(P=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex justify-center`,children:(0,Z.jsx)(FM,{isSourceMode:r,onModeChange:a,sourceDisabled:i})}),t[37]=r,t[38]=a,t[39]=i,t[40]=P):P=t[40],t[41]!==N||t[42]!==P?(y=(0,Z.jsx)(`div`,{className:`editor-content-aligned bg-background py-2`,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 items-center`,children:[N,P]})}),t[41]=N,t[42]=P,t[43]=y):y=t[43],D=`pointer-events-auto absolute top-0 right-0 flex items-center justify-end gap-1 py-2 pr-2`,t[44]===j?h=t[45]:(h=j?(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(IM,{scope:j.scope,name:j.name})}):null,t[44]=j,t[45]=h),t[46]!==u||t[47]!==s||t[48]!==o?(g=o&&(0,Z.jsxs)(gc,{children:[(0,Z.jsx)(Di,{variant:`ghost`,size:`icon`,"aria-label":u({id:`81H_23`}),onClick:s,"data-testid":`add-properties-button`,asChild:!0,children:(0,Z.jsx)(pc,{children:(0,Z.jsx)(cd,{})})}),(0,Z.jsx)(mc,{side:`bottom`,children:(0,Z.jsx)(X,{id:`81H_23`})})]}),t[46]=u,t[47]=s,t[48]=o,t[49]=g):g=t[49],m=gc,p=Di,b=``,x=`ghost`,S=`icon`,C=l,w=!c,T=`doc-panel`,E=u(c?{id:`u7H-Wn`,values:{panelShortcutLabel:e}}:{id:`2hpdRq`,values:{panelShortcutLabel:e}}),t[1]=u,t[2]=n,t[3]=c,t[4]=r,t[5]=s,t[6]=a,t[7]=l,t[8]=o,t[9]=i,t[10]=p,t[11]=m,t[12]=h,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}else p=t[10],m=t[11],h=t[12],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];let O;t[50]===c?O=t[51]:(O=(0,Z.jsx)(pc,{children:c?(0,Z.jsx)(yd,{}):(0,Z.jsx)(vd,{})}),t[50]=c,t[51]=O);let k;t[52]!==p||t[53]!==O||t[54]!==b||t[55]!==x||t[56]!==S||t[57]!==C||t[58]!==w||t[59]!==T||t[60]!==E?(k=(0,Z.jsx)(p,{"data-doc-panel-toggle":b,variant:x,size:S,onClick:C,"aria-expanded":w,"aria-controls":T,"aria-label":E,asChild:!0,children:O}),t[52]=p,t[53]=O,t[54]=b,t[55]=x,t[56]=S,t[57]=C,t[58]=w,t[59]=T,t[60]=E,t[61]=k):k=t[61];let A;t[62]===c?A=t[63]:(A=(0,Z.jsx)(mc,{side:`bottom`,children:c?(0,Z.jsx)(X,{id:`KFdXwz`,values:{panelShortcut:f}}):(0,Z.jsx)(X,{id:`MsuXaI`,values:{panelShortcut:f}})}),t[62]=c,t[63]=A);let j;t[64]!==m||t[65]!==k||t[66]!==A?(j=(0,Z.jsxs)(m,{children:[k,A]}),t[64]=m,t[65]=k,t[66]=A,t[67]=j):j=t[67];let M;t[68]!==h||t[69]!==g||t[70]!==j||t[71]!==D?(M=(0,Z.jsxs)(`div`,{className:D,children:[h,g,j]}),t[68]=h,t[69]=g,t[70]=j,t[71]=D,t[72]=M):M=t[72];let N;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none h-2 bg-linear-to-b from-background to-transparent`}),t[73]=N):N=t[73];let P;return t[74]!==_||t[75]!==v||t[76]!==y||t[77]!==M?(P=(0,Z.jsxs)(`div`,{"data-testid":_,className:v,children:[y,M,N]}),t[74]=_,t[75]=v,t[76]=y,t[77]=M,t[78]=P):P=t[78],P}function RM(e){let{activeDocName:t,deferredActiveDocName:n,mountResolved:r,syncResolved:i}=e;return t===null||t===n?!1:!(r&&i)}function zM(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`horizontal`:i,o;t[4]===n?o=t[5]:(o=Ti(`group/tabs flex gap-2 data-horizontal:flex-col`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(bp,{"data-slot":`tabs`,"data-orientation":a,className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}var BM=wi(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function VM(e){let t=(0,$.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant: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||t[5]!==a?(o=Ti(BM({variant:a}),n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==o||t[9]!==a?(s=(0,Z.jsx)(xp,{"data-slot":`tabs-list`,"data-variant":a,className:o,...r}),t[7]=r,t[8]=o,t[9]=a,t[10]=s):s=t[10],s}function HM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Sp,{"data-slot":`tabs-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function UM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`flex-1 text-sm outline-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Cp,{"data-slot":`tabs-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var WM=`ok-terminal-height-v1`,GM=1/3,KM=.5;function qM(e){return Math.max(120,Math.round((Number.isFinite(e)?e:0)*KM))}function JM(e){let t=Number.isFinite(e)?e:0;return t<=0?240:Math.round(t*GM)}function YM(e,t){let n=qM(t);return Number.isFinite(e)?e<120?120:e>n?n:Math.round(e):Math.min(JM(t),n)}function XM(){return typeof window>`u`?0:window.innerHeight}function ZM(e,t){try{let n=e??localStorage,r=t??XM(),i=n.getItem(WM);if(i==null)return YM(JM(r),r);let a=Number.parseInt(i,10);return YM(Number.isFinite(a)?a:JM(r),r)}catch{return 240}}function QM(e,t,n){try{let r=t??localStorage,i=n??XM();r.setItem(WM,String(YM(e,i)))}catch{}}function $M(){try{return typeof localStorage>`u`?240:ZM()}catch{return 240}}var eN=(0,Q.lazy)(()=>n(()=>import(`./TerminalPanel-BCJwzg1b.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([78,1,30,3,7,31,6,10,13,11,79,80]),import.meta.url));function tN(e){let t=(0,$.c)(13),{bridge:n,onClose:r,onTitleChange:i,launch:a,adoptPtyId:o}=e,s=a===void 0?null:a,c=o===void 0?null:o,{enabled:l,synced:u}=Xi(),d=Hi(),{_:f}=cn(),p=u&&l===!1,m;t[0]!==f||t[1]!==d?(m=function(){if(d===null){Js.error(f({id:`V_6bJ4`}));return}let e=d(!0);e.ok||Js.error(f({id:`jKd3AP`,values:{0:e.error}}))},t[0]=f,t[1]=d,t[2]=m):m=t[2];let h=m;if(u&&!p){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`div`,{className:`h-full w-full bg-background`,"aria-hidden":`true`}),t[3]=e):e=t[3];let a;return t[4]!==c||t[5]!==n||t[6]!==s||t[7]!==r||t[8]!==i?(a=(0,Z.jsx)(g,{fallbackRender:rN,onError:nN,children:(0,Z.jsx)(Q.Suspense,{fallback:e,children:(0,Z.jsx)(eN,{bridge:n,className:`h-full`,onClose:r,onTitleChange:i,launch:s,adoptPtyId:c})})}),t[4]=c,t[5]=n,t[6]=s,t[7]=r,t[8]=i,t[9]=a):a=t[9],a}let _;return t[10]!==h||t[11]!==p?(_=p?(0,Z.jsx)(oN,{onEnable:h}):(0,Z.jsx)(`div`,{className:`h-full w-full bg-background`,"aria-hidden":`true`}),t[10]=h,t[11]=p,t[12]=_):_=t[12],_}function nN(e,t){console.error(`[TerminalGate] rendered fallback for the terminal panel`,e,t.componentStack)}function rN(e){return(0,Z.jsx)(iN,{...e})}function iN(e){let t=(0,$.c)(15),{error:n}=e,{_:r}=cn(),i;t[0]!==r||t[1]!==n?(i=n instanceof Error&&/dynamically imported module|Failed to fetch/i.test(n.message)?r({id:`Y8ViJx`}):r({id:`fbsiBw`}),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;t[3]===r?o=t[4]:(o=r({id:`6MnZEC`}),t[3]=r,t[4]=o);let s;t[5]===a?s=t[6]:(s=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-foreground`,children:a}),t[5]=a,t[6]=s);let c;t[7]===r?c=t[8]:(c=r({id:`HpK_8d`}),t[7]=r,t[8]=c);let l;t[9]===c?l=t[10]:(l=(0,Z.jsx)(Di,{onClick:aN,children:c}),t[9]=c,t[10]=l);let u;return t[11]!==o||t[12]!==s||t[13]!==l?(u=(0,Z.jsxs)(`section`,{"aria-label":o,className:`flex h-full w-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,role:`alert`,children:[s,l]}),t[11]=o,t[12]=s,t[13]=l,t[14]=u):u=t[14],u}function aN(){return window.location.reload()}function oN(e){let t=(0,$.c)(20),{onEnable:n}=e,{_:r}=cn(),i;t[0]===r?i=t[1]:(i=r({id:`_XWY2J`}),t[0]=r,t[1]=i);let a;t[2]===r?a=t[3]:(a=r({id:`oYepHb`}),t[2]=r,t[3]=a);let o;t[4]===a?o=t[5]:(o=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-foreground`,children:a}),t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=r({id:`v2ZW0K`}),t[6]=r,t[7]=s);let c;t[8]!==n||t[9]!==s?(c=(0,Z.jsx)(Di,{onClick:n,children:s}),t[8]=n,t[9]=s,t[10]=c):c=t[10];let l;t[11]===r?l=t[12]:(l=r({id:`ICoNYz`}),t[11]=r,t[12]=l);let u;t[13]===l?u=t[14]:(u=(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l}),t[13]=l,t[14]=u);let d;return t[15]!==i||t[16]!==o||t[17]!==c||t[18]!==u?(d=(0,Z.jsxs)(`section`,{"aria-label":i,className:`flex h-full w-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,children:[o,c,u]}),t[15]=i,t[16]=o,t[17]=c,t[18]=u,t[19]=d):d=t[19],d}function sN(e){let t=(0,$.c)(36),{sessions:n,activeSessionId:r,onSelect:i,onTabActivate:a,onNew:o,onClose:s,children:c,className:l}=e,{_:u}=cn(),d;t[0]===l?d=t[1]:(d=Ti(`flex min-h-0 min-w-0 flex-1 flex-col`,l),t[0]=l,t[1]=d);let f;t[2]===u?f=t[3]:(f=u({id:`1MGRQl`}),t[2]=u,t[3]=f);let p;if(t[4]!==u||t[5]!==r||t[6]!==s||t[7]!==a||t[8]!==n){let e;t[10]!==u||t[11]!==r||t[12]!==s||t[13]!==a?(e=e=>{let t=e.id===r;return(0,Z.jsxs)(`div`,{className:Ti(`group flex shrink-0 items-center rounded-md pr-0.5 transition-colors`,t?`bg-muted`:`hover:bg-muted/50`),children:[(0,Z.jsx)(HM,{value:e.id,onClick:()=>a?.(e.id),className:`h-7 flex-none rounded-md px-2 text-xs`,children:(0,Z.jsx)(`span`,{className:`max-w-40 truncate`,children:e.label})}),(0,Z.jsx)(Di,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":u({id:`nzHlj8`,values:{0:e.label}}),tabIndex:t?0:-1,className:Ti(`text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-hover:opacity-100 group-focus-within:opacity-100`,t&&`opacity-100`),onClick:t=>{t.stopPropagation(),s(e.id)},children:(0,Z.jsx)(Ys,{"aria-hidden":`true`})})]},e.id)},t[10]=u,t[11]=r,t[12]=s,t[13]=a,t[14]=e):e=t[14],p=n.map(e),t[4]=u,t[5]=r,t[6]=s,t[7]=a,t[8]=n,t[9]=p}else p=t[9];let m;t[15]!==f||t[16]!==p?(m=(0,Z.jsx)(VM,{variant:`line`,"aria-label":f,className:`flex h-auto min-w-0 flex-1 items-center justify-start gap-0.5 overflow-x-auto bg-transparent p-0 [scrollbar-width:none] scroll-fade-mask-x`,children:p}),t[15]=f,t[16]=p,t[17]=m):m=t[17];let h;t[18]===u?h=t[19]:(h=u({id:`AB4qw9`}),t[18]=u,t[19]=h);let g;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(xt,{"aria-hidden":`true`}),t[20]=g):g=t[20];let _;t[21]!==o||t[22]!==h?(_=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":h,className:`shrink-0 text-muted-foreground hover:text-foreground`,onClick:o,children:g})}),t[21]=o,t[22]=h,t[23]=_):_=t[23];let v;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(mc,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(X,{id:`AB4qw9`})}),t[24]=v):v=t[24];let y;t[25]===_?y=t[26]:(y=(0,Z.jsxs)(gc,{children:[_,v]}),t[25]=_,t[26]=y);let b;t[27]!==m||t[28]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-1 px-1.5 py-1`,children:[m,y]}),t[27]=m,t[28]=y,t[29]=b):b=t[29];let x;return t[30]!==r||t[31]!==c||t[32]!==i||t[33]!==d||t[34]!==b?(x=(0,Z.jsxs)(zM,{value:r,onValueChange:i,className:d,children:[b,c]}),t[30]=r,t[31]=c,t[32]=i,t[33]=d,t[34]=b,t[35]=x):x=t[35],x}var cN=`terminal-dock-panel`;function lN(e){return`terminal-session-${e}`}function uN(e){e!==``&&document.querySelector(`[data-terminal-session="${e}"] .xterm-helper-textarea`)?.focus()}function dN(e){let t=(0,$.c)(85),{bridge:n,children:r,visible:i,onVisibleChange:a,launch:o}=e,s=o===void 0?null:o,{_:c}=cn(),{resolvedTheme:l}=xr(),u=Kx(),d=(0,Q.useRef)(null),[f,p]=(0,Q.useState)(!i),m=typeof n.terminal?.list==`function`,h;t[0]!==m||t[1]!==s||t[2]!==i?(h=()=>!m&&i?[{id:lN(1),launch:s,title:null,adoptPtyId:null}]:[],t[0]=m,t[1]=s,t[2]=i,t[3]=h):h=t[3];let[g,_]=(0,Q.useState)(h),v;t[4]!==m||t[5]!==i?(v=()=>!m&&i?lN(1):``,t[4]=m,t[5]=i,t[6]=v):v=t[6];let[y,b]=(0,Q.useState)(v),[x,S]=(0,Q.useState)(!m),C=(0,Q.useRef)(!1),w=(0,Q.useRef)(y),T=(0,Q.useRef)(g),E=(0,Q.useRef)(!m&&i?1:0),D=(0,Q.useRef)(i&&s?s.nonce:null),O=(0,Q.useRef)(i),k;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=function(e){E.current+=1;let t=lN(E.current);_(n=>[...n,{id:t,launch:e,title:null,adoptPtyId:null}]),b(t)},t[7]=k):k=t[7];let A=k,j;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(e,t){let n=t.trim()===``?null:t.trim();_(t=>t.some(t=>t.id===e&&t.title!==n)?t.map(t=>t.id===e?{...t,title:n}:t):t)},t[8]=j):j=t[8];let M=j,N=(0,Q.useRef)(A),P;t[9]!==y||t[10]!==a?(P=function(e){let t=T.current,n=t.findIndex(t=>t.id===e);if(n===-1)return;let r=t.filter(t=>t.id!==e);if(e===y){let e=(t[n-1]??t[n+1])?.id??``;b(e),e!==``&&queueMicrotask(()=>uN(e))}_(r),r.length===0&&(a(!1),d.current?.focus())},t[9]=y,t[10]=a,t[11]=P):P=t[11];let F=P,I=(0,Q.useRef)(hN),L;t[12]!==y||t[13]!==F||t[14]!==g?(L=()=>{N.current=A,w.current=y,T.current=g,I.current=()=>{y!==``&&F(y)}},t[12]=y,t[13]=F,t[14]=g,t[15]=L):L=t[15],(0,Q.useEffect)(L);let[R]=(0,Q.useState)(mN),z=(0,Q.useRef)(R),[B,V]=(0,Q.useState)(!1),H=(0,Q.useRef)(!1),U=(0,Q.useRef)(null),W;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(W=function(e){U.current!=null&&clearTimeout(U.current),U.current=setTimeout(()=>{QM(e),U.current=null},100)},t[16]=W):W=t[16];let G=W,K=(0,Q.useRef)(null),q,J;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(J=()=>()=>{U.current!=null&&clearTimeout(U.current),K.current!=null&&(window.removeEventListener(`pointerup`,K.current),K.current=null)},q=[],t[17]=q,t[18]=J):(q=t[17],J=t[18]),(0,Q.useEffect)(J,q);let Y,ee;t[19]!==s||t[20]!==x||t[21]!==g.length||t[22]!==i?(Y=()=>{if(!x)return;let e=O.current;if(O.current=i,s!=null&&s.nonce!==D.current){D.current=s.nonce,N.current(s);return}i&&!e&&g.length===0&&N.current(null)},ee=[i,s,g.length,x],t[19]=s,t[20]=x,t[21]=g.length,t[22]=i,t[23]=Y,t[24]=ee):(Y=t[23],ee=t[24]),(0,Q.useEffect)(Y,ee);let te;t[25]===n.terminal?te=t[26]:(te=()=>{if(typeof n.terminal?.list!=`function`||C.current)return;C.current=!0;let e=!1;return(async()=>{let t;try{t=await n.terminal.list()??[]}catch(e){console.error(`[terminal] reload session list() failed; cold-starting:`,e),t=[]}if(!e){if(t.length>0){let e=t.map(pN);E.current=e.length,_(e),b(e[0]?.id??``)}S(!0)}})(),()=>{e=!0,C.current=!1}},t[25]=n.terminal,t[26]=te);let ne;t[27]===n?ne=t[28]:(ne=[n],t[27]=n,t[28]=ne),(0,Q.useEffect)(te,ne);let re,ie;t[29]===n?(re=t[30],ie=t[31]):(re=()=>n.onMenuAction(e=>{e===`new-terminal`?N.current(null):e===`kill-terminal`&&I.current()}),ie=[n],t[29]=n,t[30]=re,t[31]=ie),(0,Q.useEffect)(re,ie);let ae,oe;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>{let e=function(e){if(!e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||!/^[1-9]$/.test(e.key)||!document.getElementById(cN)?.contains(document.activeElement))return;let t=T.current[Number(e.key)-1];t!=null&&(e.preventDefault(),e.stopPropagation(),b(t.id),queueMicrotask(()=>uN(t.id)))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},oe=[],t[32]=ae,t[33]=oe):(ae=t[32],oe=t[33]),(0,Q.useEffect)(ae,oe);let se;t[34]!==n.editor||t[35]!==g.length?(se=()=>{n.editor.notifyViewMenuStateChanged({terminalLive:g.length>0})},t[34]=n.editor,t[35]=g.length,t[36]=se):se=t[36];let ce;t[37]!==n||t[38]!==g.length?(ce=[n,g.length],t[37]=n,t[38]=g.length,t[39]=ce):ce=t[39],(0,Q.useEffect)(se,ce);let le,ue;t[40]!==u||t[41]!==i?(le=()=>{let e=u.current;e!=null&&(i?e.resize(`${z.current}px`):e.collapse())},ue=[i,u],t[40]=u,t[41]=i,t[42]=le,t[43]=ue):(le=t[42],ue=t[43]),(0,Q.useEffect)(le,ue);let de,fe;t[44]===f?(de=t[45],fe=t[46]):(de=()=>{f&&document.getElementById(cN)?.contains(document.activeElement)&&d.current?.focus()},fe=[f],t[44]=f,t[45]=de,t[46]=fe),(0,Q.useLayoutEffect)(de,fe);let pe,me;t[47]===f?(pe=t[48],me=t[49]):(pe=()=>{f||uN(w.current)},me=[f],t[47]=f,t[48]=pe,t[49]=me),(0,Q.useEffect)(pe,me);let he;if(t[50]!==c||t[51]!==g){let e;t[53]===c?e=t[54]:(e=(e,t)=>({id:e.id,label:e.title??c({id:`OVjNeX`,values:{0:t+1}})}),t[53]=c,t[54]=e),he=g.map(e),t[50]=c,t[51]=g,t[52]=he}else he=t[52];let ge=he,_e=B||void 0,ve;t[55]===r?ve=t[56]:(ve=(0,Z.jsx)(nT,{minSize:`5%`,className:`flex min-h-0 flex-col`,children:(0,Z.jsx)(`div`,{ref:d,tabIndex:-1,className:`flex h-full min-h-0 flex-col outline-none`,children:r})}),t[55]=r,t[56]=ve);let ye;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,Z.jsx)(rT,{withHandle:!0,onPointerDown:()=>{V(!0),H.current=!0;let e=()=>{V(!1),H.current=!1,window.removeEventListener(`pointerup`,e),K.current=null};K.current=e,window.addEventListener(`pointerup`,e)}}),t[57]=ye):ye=t[57];let be;t[58]===l?be=t[59]:(be=lu(l),t[58]=l,t[59]=be);let xe;t[60]===be.background?xe=t[61]:(xe={backgroundColor:be.background},t[60]=be.background,t[61]=xe);let Se=i?`${R}px`:0,Ce;t[62]!==a||t[63]!==i?(Ce=e=>{let t=e.asPercentage===0;p(t),H.current&&(t&&i?a(!1):!t&&!i&&a(!0),e.inPixels>0&&(z.current=e.inPixels,G(e.inPixels)))},t[62]=a,t[63]=i,t[64]=Ce):Ce=t[64];let we=!B&&`transition-[flex-grow] duration-150 ease-out motion-reduce:transition-none motion-reduce:duration-0`,Te;t[65]===we?Te=t[66]:(Te=Ti(`flex flex-col`,we),t[65]=we,t[66]=Te);let Ee;t[67]!==y||t[68]!==n||t[69]!==F||t[70]!==g||t[71]!==ge?(Ee=g.length>0?(0,Z.jsx)(sN,{sessions:ge,activeSessionId:y,onSelect:b,onTabActivate:fN,onNew:()=>A(null),onClose:F,className:`h-full`,children:g.map(e=>(0,Z.jsx)(UM,{value:e.id,forceMount:!0,"data-terminal-session":e.id,className:`m-0 flex min-h-0 flex-1 flex-col overflow-hidden data-[state=inactive]:hidden`,children:(0,Z.jsx)(tN,{bridge:n,launch:e.launch,adoptPtyId:e.adoptPtyId,onTitleChange:t=>M(e.id,t),onClose:()=>F(e.id)})},e.id))}):null,t[67]=y,t[68]=n,t[69]=F,t[70]=g,t[71]=ge,t[72]=Ee):Ee=t[72];let De;t[73]!==f||t[74]!==u||t[75]!==xe||t[76]!==Se||t[77]!==Ce||t[78]!==Te||t[79]!==Ee?(De=(0,Z.jsx)(nT,{id:cN,style:xe,panelRef:u,defaultSize:Se,minSize:`120px`,maxSize:`95%`,collapsible:!0,collapsedSize:0,onResize:Ce,inert:f,className:Te,children:Ee}),t[73]=f,t[74]=u,t[75]=xe,t[76]=Se,t[77]=Ce,t[78]=Te,t[79]=Ee,t[80]=De):De=t[80];let Oe;return t[81]!==_e||t[82]!==ve||t[83]!==De?(Oe=(0,Z.jsxs)(tT,{orientation:`vertical`,className:`min-h-0 flex-1`,"data-dragging":_e,children:[ve,ye,De]}),t[81]=_e,t[82]=ve,t[83]=De,t[84]=Oe):Oe=t[84],Oe}function fN(e){return queueMicrotask(()=>uN(e))}function pN(e,t){return{id:lN(t+1),launch:null,title:null,adoptPtyId:e.ptyId}}function mN(){return $M()}function hN(){}var gN=(0,Q.lazy)(async()=>({default:(await n(()=>import(`./ActivityModeContent-BLwbhKWj.js`),__vite__mapDeps([46,1,2,47,48,49,31,50,51,52,53,54,55,56,57,20,9,10,7,11,30,3,32,6,4,15,12,13,22,14,58,16,43,59,23,60,61,62]),import.meta.url)).ActivityModeContent})),_N=`300px`,vN=`600px`;function yN(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=(0,Z.jsx)(xN,{...e}),t[0]=e,t[1]=n);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(bN,{}),t[2]=r):r=t[2];let i;return t[3]===n?i=t[4]:(i=(0,Z.jsx)(P,{name:`editor-area`,children:(0,Z.jsxs)(Ka,{children:[n,r]})}),t[3]=n,t[4]=i),i}function bN(){let e=(0,$.c)(5),t=Zi(),n;e[0]===t?n=e[1]:(n=e=>{e||t.close()},e[0]=t,e[1]=n);let r;return e[2]!==t.open||e[3]!==n?(r=(0,Z.jsx)(Xw,{open:t.open,onOpenChange:n}),e[2]=t.open,e[3]=n,e[4]=r):r=e[4],r}function xN(e){let t=(0,$.c)(187),{editorMode:n,onModeChange:r,activeTab:i,onActiveTabChange:a,terminalBridge:o,terminalVisible:s,onTerminalVisibleChange:c,terminalLaunch:l}=e,u=s===void 0?!1:s,d=l===void 0?null:l,{_:f}=cn(),{activeDocName:p,activeProvider:m,activeTarget:h,recycleDocument:g,docPanelMode:_,docPanelAgentId:v,docPanelExpandSignal:y}=_t(),{openDocumentTransition:b}=At(),{requestAddProperty:x}=Ua(),S=TT(m,p),C=OT(p,n===`source`?`source`:`wysiwyg`),w=JT(m),T=w===`connected`||w===`synced`,E=DT(p)===`conflict`,[D,O]=(0,Q.useState)(!1),k,A;t[0]!==m||t[1]!==D?(k=()=>{m!=null&&!D&&O(!0)},A=[m,D],t[0]=m,t[1]=D,t[2]=k,t[3]=A):(k=t[2],A=t[3]),(0,Q.useEffect)(k,A);let j=(0,Q.useDeferredValue)(p),M=h?.kind===`missing`,N=!!p&&h?.kind!==`folder`,P;t[4]!==f||t[5]!==M?(P=M?f({id:`K-a33w`}):void 0,t[4]=f,t[5]=M,t[6]=P):P=t[6];let F=P,[I]=(0,Q.useState)(TN),R=I!==null,[z]=(0,Q.useState)(wN),B;t[7]===I?B=t[8]:(B=()=>LT(I,window.innerWidth,`right`),t[7]=I,t[8]=B);let[V,H]=(0,Q.useState)(B),U=(0,Q.useRef)(V),W,G;t[9]===V?(W=t[10],G=t[11]):(W=()=>{U.current=V},G=[V],t[9]=V,t[10]=W,t[11]=G),(0,Q.useEffect)(W,G);let K=Kx(),q;t[12]===V?q=t[13]:(q=()=>KT(`right`,V,WT())===`collapsed`,t[12]=V,t[13]=q);let[J]=(0,Q.useState)(q),[Y,ee]=(0,Q.useState)(J),te=(0,Q.useRef)(Y),ne,re;t[14]===Y?(ne=t[15],re=t[16]):(ne=()=>{te.current=Y},re=[Y],t[14]=Y,t[15]=ne,t[16]=re),(0,Q.useEffect)(ne,re);let[ie,ae]=(0,Q.useState)(!1),oe=(0,Q.useRef)(!1),[se]=(0,Q.useState)(CN),ce=(0,Q.useRef)(se),le=(0,Q.useRef)(null),ue;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(ue=function(e){le.current!=null&&clearTimeout(le.current),le.current=setTimeout(()=>{MT(e),le.current=null},100)},t[17]=ue):ue=t[17];let de=ue,fe,pe;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>()=>{le.current!=null&&clearTimeout(le.current)},pe=[],t[18]=fe,t[19]=pe):(fe=t[18],pe=t[19]),(0,Q.useEffect)(fe,pe);let[me,he]=(0,Q.useState)(null),ge;t[20]!==Y||t[21]!==K?(ge=function(){if(K.current==null)return;let e=U.current;Y?(qT(`right`,e,`open`),K.current?.expand()):(qT(`right`,e,`collapsed`),K.current?.collapse())},t[20]=Y,t[21]=K,t[22]=ge):ge=t[22];let _e=ge,ve,ye;t[23]!==I||t[24]!==K?(ve=()=>{let e=window.matchMedia(`(min-width: ${FT}px)`),t=()=>{let e=LT(I,window.innerWidth,`right`);H(e);let t=KT(`right`,e,WT())===`collapsed`;ee(t),t?K.current?.collapse():K.current?.expand()};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},ye=[I,K],t[23]=I,t[24]=K,t[25]=ve,t[26]=ye):(ve=t[25],ye=t[26]),(0,Q.useEffect)(ve,ye);let be,xe;t[27]!==me||t[28]!==R||t[29]!==K?(be=()=>{if(me==null||R)return;let e=new ResizeObserver(()=>{te.current||oe.current||K.current?.resize(`${ce.current}px`)});return e.observe(me),()=>e.disconnect()},xe=[me,R,K],t[27]=me,t[28]=R,t[29]=K,t[30]=be,t[31]=xe):(be=t[30],xe=t[31]),(0,Q.useEffect)(be,xe);let Se,Ce;t[32]!==a||t[33]!==K?(Se=()=>{let e=e=>{a(e),K.current?.expand()},t=i_();return t&&e(t),o_(t=>{i_(),e(t)})},Ce=[a,K],t[32]=a,t[33]=K,t[34]=Se,t[35]=Ce):(Se=t[34],Ce=t[35]),(0,Q.useEffect)(Se,Ce);let we,Te;t[36]!==y||t[37]!==K?(we=()=>{y!==0&&K.current?.expand()},Te=[y,K],t[36]=y,t[37]=K,t[38]=we,t[39]=Te):(we=t[38],Te=t[39]),(0,Q.useEffect)(we,Te);let Ee,De;t[40]===Y?(Ee=t[41],De=t[42]):(Ee=()=>{if(!Y||!document.getElementById(`doc-panel`)?.contains(document.activeElement))return;let e=document.querySelector(`[data-doc-panel-toggle]`);if(e){e.focus();return}document.querySelector(`[data-sidebar="trigger"]`)?.focus()},De=[Y],t[40]=Y,t[41]=Ee,t[42]=De),(0,Q.useLayoutEffect)(Ee,De);let Oe,ke;t[43]===Y?(Oe=t[44],ke=t[45]):(Oe=()=>{window.okDesktop!=null&&window.okDesktop.editor.notifyViewMenuStateChanged({docPanelVisible:!Y})},ke=[Y],t[43]=Y,t[44]=Oe,t[45]=ke),(0,Q.useEffect)(Oe,ke);let Ae,je;t[46]===_e?(Ae=t[47],je=t[48]):(Ae=()=>{if(window.okDesktop!=null)return window.okDesktop.onMenuAction(e=>{e===`toggle-doc-panel`&&_e()})},je=[_e],t[46]=_e,t[47]=Ae,t[48]=je),(0,Q.useEffect)(Ae,je);let Me,Ne;t[49]===_e?(Me=t[50],Ne=t[51]):(Me=()=>{if(window.okDesktop!=null)return;let e=e=>{Sl(e,`toggle-document-panel`)&&(e.preventDefault(),_e())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},Ne=[_e],t[49]=_e,t[50]=Me,t[51]=Ne),(0,Q.useEffect)(Me,Ne);let Pe=(0,Q.useRef)(null),[Ie,Le]=(0,Q.useState)(null),[Re,ze]=(0,Q.useState)(!1),Be=h?.kind===`large-file`?h.docName:p,Ve,He;t[52]===Be?(Ve=t[53],He=t[54]):(Ve=()=>{if(Be&&Be!==Pe.current){let e=Pe.current;Pe.current=Be,Le(e)}},He=[Be],t[52]=Be,t[53]=Ve,t[54]=He),(0,Q.useEffect)(Ve,He);let Ue;t[55]===b?Ue=t[56]:(Ue=function(e){let t=Ao(e);window.location.hash===t?b(e):window.location.hash=t},t[55]=b,t[56]=Ue);let We=Ue,Ge,Ke=null;if(h?.kind===`large-file`){let e;t[57]!==We||t[58]!==Ie?(e=Ie?{previousDocName:Ie,onNavigateBack:We}:void 0,t[57]=We,t[58]=Ie,t[59]=e):e=t[59];let n;t[60]!==h.docName||t[61]!==h.limit||t[62]!==h.size||t[63]!==e?(n=(0,Z.jsx)(Nw,{docName:h.docName,size:h.size,limit:h.limit,backNav:e}),t[60]=h.docName,t[61]=h.limit,t[62]=h.size,t[63]=e,t[64]=n):n=t[64],Ge=n}else if(h?.kind===`folder`){let e;t[65]!==z||t[66]!==R||t[67]!==u?(e=yE({terminalVisible:u,isEmbedded:R,isDesktop:z}),t[65]=z,t[66]=R,t[67]=u,t[68]=e):e=t[68];let n=e,r;t[69]===h.folderPath?r=t[70]:(r=(0,Z.jsx)(kw,{folderPath:h.folderPath}),t[69]=h.folderPath,t[70]=r);let i;t[71]!==h.folderPath||t[72]!==n?(i=n?(0,Z.jsx)(sE,{folderPath:h.folderPath}):null,t[71]=h.folderPath,t[72]=n,t[73]=i):i=t[73];let a;if(t[74]!==r||t[75]!==i?(a=(0,Z.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[r,i]}),t[74]=r,t[75]=i,t[76]=a):a=t[76],Ge=a,_===`agent`&&v!==null){let e;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(rT,{withHandle:!0}),t[77]=e):e=t[77];let n;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(Z.Fragment,{children:[e,(0,Z.jsx)(nT,{id:`agent-panel`,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,className:`flex flex-col bg-muted/20`,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:(0,Z.jsx)(X,{id:`ONPvOb`})}),children:(0,Z.jsx)(gN,{showBackButton:!1})})})]}),t[78]=n):n=t[78],Ke=n}}else if(h?.kind===`asset`){let e;t[79]!==h.assetPath||t[80]!==h.mediaKind?(e=(0,Z.jsx)(sS,{assetPath:h.assetPath,mediaKind:h.mediaKind},h.assetPath),t[79]=h.assetPath,t[80]=h.mediaKind,t[81]=e):e=t[81],Ge=e}else if(h?.kind===`skill-file`){let e=`${h.scope}/${h.name}/${h.path}`,n;t[82]!==h.name||t[83]!==h.path||t[84]!==h.scope||t[85]!==e?(n=(0,Z.jsx)(Vw,{scope:h.scope,name:h.name,path:h.path},e),t[82]=h.name,t[83]=h.path,t[84]=h.scope,t[85]=e,t[86]=n):n=t[86],Ge=n}else if(!m||!p)if((typeof window<`u`?So(window.location.hash):null)!==null)if(o!=null&&D){let e;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(cS,{}),t[87]=e):e=t[87],Ge=e;let n;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(rT,{withHandle:!0,disabled:!0}),t[88]=n):n=t[88];let r=J?0:`${se}px`,i;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`}),t[89]=i):i=t[89];let a;t[90]===r?a=t[91]:(a=(0,Z.jsxs)(Z.Fragment,{children:[n,(0,Z.jsx)(nT,{id:`doc-panel`,defaultSize:r,minSize:_N,maxSize:vN,collapsible:!0,collapsedSize:0,inert:!0,className:`flex flex-col bg-muted/20`,children:i})]}),t[90]=r,t[91]=a),Ke=a}else{let e;return t[92]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(cS,{}),t[92]=e):e=t[92],e}else{let e;t[93]===u?e=t[94]:(e=(0,Z.jsx)(XC,{terminalVisible:u}),t[93]=u,t[94]=e),Ge=e}else{let e=n===`source`,o=!T,s=Y,c;t[95]!==p||t[96]!==x?(c=function(){p&&x(p)},t[95]=p,t[96]=x,t[97]=c):c=t[97];let l=c,d;t[98]!==p||t[99]!==z||t[100]!==R||t[101]!==u?(d=vE({terminalVisible:u,isEmbedded:R,isDesktop:z,activeDocName:p}),t[98]=p,t[99]=z,t[100]=R,t[101]=u,t[102]=d):d=t[102];let f=d,m=j??p,h=Ie??void 0,v;t[103]!==F||t[104]!==e||t[105]!==We||t[106]!==g||t[107]!==m||t[108]!==h?(v=(0,Z.jsx)(vj,{activeDocName:m,isSourceMode:e,editorPlaceholder:F,previousDocName:h,onNavigateBack:We,onRecycle:g}),t[103]=F,t[104]=e,t[105]=We,t[106]=g,t[107]=m,t[108]=h,t[109]=v):v=t[109];let y;t[110]!==p||t[111]!==e?(y=(0,Z.jsx)(xT,{activeDocName:p,isSourceMode:e}),t[110]=p,t[111]=e,t[112]=y):y=t[112];let b;t[113]!==p||t[114]!==j?(b=RM({activeDocName:p,deferredActiveDocName:j,mountResolved:p!==null&&L(p),syncResolved:p!==null&&Fe(p)})?(0,Z.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:[(0,Z.jsx)(cS,{}),p===null?null:(0,Z.jsx)(Pw,{docName:p})]}):null,t[113]=p,t[114]=j,t[115]=b):b=t[115];let w;t[116]!==v||t[117]!==y||t[118]!==b?(w=(0,Z.jsxs)(`div`,{className:`relative h-full`,children:[v,y,b]}),t[116]=v,t[117]=y,t[118]=b,t[119]=w):w=t[119];let D;t[120]!==p||t[121]!==E||t[122]!==s||t[123]!==e||t[124]!==r||t[125]!==l||t[126]!==o||t[127]!==_e?(D=!E&&(0,Z.jsx)(LM,{activeDocName:p,isSourceMode:e,sourceDisabled:o,onModeChange:r,showAddPropertyButton:!e,onAddProperty:l,isPanelCollapsed:s,onTogglePanel:_e}),t[120]=p,t[121]=E,t[122]=s,t[123]=e,t[124]=r,t[125]=l,t[126]=o,t[127]=_e,t[128]=D):D=t[128];let O;t[129]!==p||t[130]!==Re||t[131]!==e||t[132]!==f?(O=f?(0,Z.jsx)(sE,{docName:p,surface:e?`source`:`wysiwyg`,dismissed:Re,onDismiss:()=>ze(!0),onReopen:()=>ze(!1)}):null,t[129]=p,t[130]=Re,t[131]=e,t[132]=f,t[133]=O):O=t[133];let k;t[134]!==w||t[135]!==D||t[136]!==O?(k=(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[w,D,O]}),t[134]=w,t[135]=D,t[136]=O,t[137]=k):k=t[137];let A;t[138]!==Re||t[139]!==f?(A=f&&Re?{onReopen:()=>ze(!1)}:null,t[138]=Re,t[139]=f,t[140]=A):A=t[140];let M;t[141]!==C||t[142]!==N||t[143]!==S||t[144]!==A?(M=(0,Z.jsx)(yM,{stats:S,selectionStats:C,showStats:N,composerBadge:A}),t[141]=C,t[142]=N,t[143]=S,t[144]=A,t[145]=M):M=t[145];let P;t[146]!==k||t[147]!==M?(P=(0,Z.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[k,M]}),t[146]=k,t[147]=M,t[148]=P):P=t[148],Ge=P;let I=R&&Y,B;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{ae(!0),oe.current=!0;let e=()=>{ae(!1),oe.current=!1,window.removeEventListener(`pointerup`,e)};window.addEventListener(`pointerup`,e)},t[149]=B):B=t[149];let V;t[150]===I?V=t[151]:(V=(0,Z.jsx)(rT,{withHandle:!0,disabled:I,onPointerDown:B}),t[150]=I,t[151]=V);let H=J?0:`${se}px`,U;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>{ee(e.asPercentage===0),e.inPixels>0&&oe.current&&(ce.current=e.inPixels,de(e.inPixels))},t[152]=U):U=t[152];let W=!ie&&`transition-[flex-grow] duration-200 ease-out motion-reduce:transition-none motion-reduce:duration-0`,G;t[153]===W?G=t[154]:(G=Ti(`flex flex-col bg-muted/20`,W),t[153]=W,t[154]=G);let q;t[155]!==p||t[156]!==i||t[157]!==_||t[158]!==e||t[159]!==a?(q=(0,Z.jsx)(Qy,{docName:p,isSourceMode:e,activeTab:i,onActiveTabChange:a,mode:_}),t[155]=p,t[156]=i,t[157]=_,t[158]=e,t[159]=a,t[160]=q):q=t[160];let te;t[161]!==Y||t[162]!==K||t[163]!==H||t[164]!==G||t[165]!==q?(te=(0,Z.jsx)(nT,{id:`doc-panel`,panelRef:K,defaultSize:H,minSize:_N,maxSize:vN,collapsible:!0,collapsedSize:0,onResize:U,inert:Y,className:G,children:q}),t[161]=Y,t[162]=K,t[163]=H,t[164]=G,t[165]=q,t[166]=te):te=t[166];let ne;t[167]!==V||t[168]!==te?(ne=(0,Z.jsxs)(Z.Fragment,{children:[V,te]}),t[167]=V,t[168]=te,t[169]=ne):ne=t[169],Ke=ne}let qe;t[170]!==c||t[171]!==o||t[172]!==d||t[173]!==u||t[174]!==Ge?(qe=o==null?Ge:(0,Z.jsx)(dN,{bridge:o,visible:u,onVisibleChange:c??SN,launch:d,children:Ge}),t[170]=c,t[171]=o,t[172]=d,t[173]=u,t[174]=Ge,t[175]=qe):qe=t[175];let Je=qe,Ye=ie||void 0,Xe;t[176]!==J||t[177]!==Ke?(Xe=Ke!=null&&!J?{}:{defaultSize:`100%`},t[176]=J,t[177]=Ke,t[178]=Xe):Xe=t[178];let Ze=ie?void 0:`transition-[flex-grow] duration-200 ease-out motion-reduce:transition-none motion-reduce:duration-0`,Qe;t[179]!==Je||t[180]!==Xe||t[181]!==Ze?(Qe=(0,Z.jsx)(nT,{minSize:`30%`,...Xe,className:Ze,children:Je}),t[179]=Je,t[180]=Xe,t[181]=Ze,t[182]=Qe):Qe=t[182];let $e;return t[183]!==Ke||t[184]!==Ye||t[185]!==Qe?($e=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1`,ref:he,children:(0,Z.jsxs)(tT,{orientation:`horizontal`,"data-dragging":Ye,children:[Qe,Ke]})}),t[183]=Ke,t[184]=Ye,t[185]=Qe,t[186]=$e):$e=t[186],$e}function SN(){}function CN(){return NT()}function wN(){return typeof window<`u`&&window.okDesktop!=null}function TN(){return Ir()}function EN(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.kind!==i.kind)return!1;if(r.kind===`human`&&i.kind===`human`){if(r.clientId!==i.clientId||r.mode!==i.mode||r.tabCount!==i.tabCount)return!1;let e=r.user,t=i.user;if(e.name!==t.name||e.color!==t.color||e.icon!==t.icon)return!1}else if(r.kind===`agent`&&i.kind===`agent`){if(r.agentId!==i.agentId)return!1;let e=r.presence,t=i.presence;if(e.displayName!==t.displayName||e.icon!==t.icon||e.color!==t.color||e.currentDoc!==t.currentDoc||e.mode!==t.mode)return!1}}return!0}function DN(e){let t=new Map;for(let n of e){let e=n.user.principalId;if(typeof e==`string`&&e.length>0){let r=t.get(e);r?r.push(n):t.set(e,[n])}}let n=new Map;for(let[e,r]of t){let t=r.reduce((e,t)=>Math.min(e,t.clientId),1/0);n.set(e,{repClientId:t,count:r.length})}let r=[];for(let t of e){let e=t.user.principalId;if(typeof e==`string`&&e.length>0){let i=n.get(e);i&&i.repClientId===t.clientId&&r.push({...t,tabCount:i.count})}else r.push({...t,tabCount:1})}return r}var ON=1e3,kN=!1;function AN(e){return!!(e.localPrincipalId&&e.entryPrincipalId===e.localPrincipalId||!e.localPrincipalId&&e.entryClientId===e.localClientId)}function jN(e,t,n){let r=(0,$.c)(9),i;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={current:[],crossDoc:[]},r[0]=i):i=r[0];let[a,o]=(0,Q.useState)(i),s;r[1]!==n||r[2]!==e?.awareness||r[3]!==t?.awareness?(s=()=>{let r=e?.awareness,i=t?.awareness,a;i==null?a=void 0:Li(i)?a=i:(a=void 0,kN||(kN=!0,console.warn(`[agent-presence] __system__ provider awareness missing getStates() — presence bar will render without agent peers`)));let s=()=>{let e=(r?.getLocalState())?.user?.principalId??null,t=r?.clientID??null,i=[];if(r)for(let[n,a]of r.getStates().entries()){let r=a;if(!r.user||typeof r.user!=`object`)continue;let o=r.user;o.type===`human`&&(AN({entryPrincipalId:o.principalId,entryClientId:n,localPrincipalId:e,localClientId:t})||i.push({kind:`human`,clientId:n,user:o,mode:r.mode??`wysiwyg`,tabCount:1}))}let s=DN(i),{current:c,crossDoc:l}=a?Ni(a,n,Date.now()):{current:[],crossDoc:[]},u=MN,d=c.map(u),f=l.map(u),p=[...s,...d],m=f;o(e=>EN(e.current,p)&&EN(e.crossDoc,m)?e:{current:p,crossDoc:m})};s();let c=()=>s(),l=()=>s();r?.on(`change`,c),t?.awareness?.on(`change`,l);let u=setInterval(s,ON);return()=>{r?.off(`change`,c),t?.awareness?.off(`change`,l),clearInterval(u)}},r[1]=n,r[2]=e?.awareness,r[3]=t?.awareness,r[4]=s):s=r[4];let c;return r[5]!==n||r[6]!==e||r[7]!==t?(c=[e,t,n],r[5]=n,r[6]=e,r[7]=t,r[8]=c):c=r[8],(0,Q.useEffect)(s,c),a}function MN(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}var NN=`sync-status`;function PN(e,t){let n=(0,$.c)(6),{_:r}=cn(),i=Bh(),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(!1),s=(0,Q.useRef)(t),c,l;n[0]!==r||n[1]!==t||n[2]!==i||n[3]!==e?(c=()=>{if(s.current!==t&&(s.current=t,a.current=!1,o.current=!1),t)if(e===`synced`&&(a.current=!0),e===`disconnected`&&a.current){if(i){Js.dismiss(NN);return}o.current=!0,Js.warning(r({id:`HGNCsl`}),{id:NN,duration:1/0})}else o.current&&e===`synced`&&(o.current=!1,Js.success(r({id:`GhjUB_`}),{id:NN,duration:3e3}))},l=[e,t,r,i],n[0]=r,n[1]=t,n[2]=i,n[3]=e,n[4]=c,n[5]=l):(c=n[4],l=n[5]),(0,Q.useEffect)(c,l)}var FN=4,IN=3,LN={Bird:Du,Cat:Pu,Dog:Hu,Fish:Ju,Mouse:wd,Rabbit:Cd,Shrimp:Ad,Snail:jd,Squirrel:Pd,Turtle:Wd};Object.freeze(Object.keys(LN));function RN(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(LN,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var zN={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function BN(e){let t=(0,$.c)(28),{user:n,mode:r,tabCount:i}=e,{_:a}=cn(),o=RN(n),s=o.kind===`animal`?LN[o.animal]:void 0,c;t[0]===n.name?c=t[1]:(c=kr(n.name),t[0]=n.name,t[1]=c);let l=c,u;t[2]===n.color?u=t[3]:(u=di(n.color),t[2]=n.color,t[3]=u);let d=u,f=n.name,p;t[4]!==a||t[5]!==i||t[6]!==f?(p=i>1?a({id:`qAhFeg`,values:{userName:f,tabCount:i}}):f,t[4]=a,t[5]=i,t[6]=f,t[7]=p):p=t[7];let m=p,h;t[8]!==a||t[9]!==i||t[10]!==f?(h=i>1?a({id:`BEkF-P`,values:{userName:f,tabCount:i}}):f,t[8]=a,t[9]=i,t[10]=f,t[11]=h):h=t[11];let g=h,_;t[12]===n.color?_=t[13]:(_={backgroundColor:n.color},t[12]=n.color,t[13]=_);let v;t[14]!==s||t[15]!==d||t[16]!==l?(v=s?(0,Z.jsx)(s,{size:18,color:d,strokeWidth:1.5}):(0,Z.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:d},children:l}),t[14]=s,t[15]=d,t[16]=l,t[17]=v):v=t[17];let y;t[18]!==g||t[19]!==r||t[20]!==_||t[21]!==v?(y=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":g,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:_,children:v})}),t[18]=g,t[19]=r,t[20]=_,t[21]=v,t[22]=y):y=t[22];let b;t[23]===m?b=t[24]:(b=(0,Z.jsx)(mc,{children:m}),t[23]=m,t[24]=b);let x;return t[25]!==y||t[26]!==b?(x=(0,Z.jsxs)(gc,{children:[y,b]}),t[25]=y,t[26]=b,t[27]=x):x=t[27],x}function VN(e){let t=zN[e.icon];return e.displayName||t||ic._({id:`iEQQyu`})}function HN(e){let t=(0,$.c)(3),[n,r]=(0,Q.useState)(e===`writing`),i=(0,Q.useRef)(null),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(e===`writing`){i.current!==null&&(clearTimeout(i.current),i.current=null),r(!0);return}return i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{i.current=null,r(!1)},600),()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)}},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Q.useEffect)(a,o),n}function UN(e){let t=(0,$.c)(33),{participant:n,crossDoc:r,scoped:i,onClickAgent:a}=e,{_:o}=cn(),{activeDocName:s}=_t(),{presence:c,agentId:l}=n,u=VN(c),d=HN(c.mode),f=!r&&d,p=c.currentDoc&&c.currentDoc!==`(connected)`?c.currentDoc:null,m=s!==null||p!==null,h=m?`cursor-pointer`:`cursor-default opacity-50`,g=i?`ring-primary ring-offset-2 ring-offset-background`:`ring-background`,_=f&&!i?`ring-primary/40 animate-pulse`:``,v;t[0]!==h||t[1]!==g||t[2]!==_?(v=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2`,h,g,_].filter(Boolean),t[0]=h,t[1]=g,t[2]=_,t[3]=v):v=t[3];let y=v.join(` `),b=r?`true`:void 0,x=i?`true`:void 0,S=m?void 0:`true`,C;t[4]!==c.mode||t[5]!==b||t[6]!==x||t[7]!==S?(C={"data-presence-badge":`agent`,"data-presence-mode":c.mode,"data-presence-crossdoc":b,"data-presence-scoped":x,"data-presence-inert":S},t[4]=c.mode,t[5]=b,t[6]=x,t[7]=S,t[8]=C):C=t[8];let w=C,T=o(r&&p?{id:`b4AQFK`,values:{tooltipName:u,realCurrentDoc:p}}:{id:`RfHNf8`,values:{tooltipName:u}}),E;t[9]!==l||t[10]!==T||t[11]!==w||t[12]!==m||t[13]!==a||t[14]!==c.color||t[15]!==c.icon||t[16]!==p||t[17]!==y||t[18]!==u?(E=m?(0,Z.jsx)(`button`,{type:`button`,...w,"aria-label":T,className:y,style:{backgroundColor:c.color},onClick:()=>a(l,p),children:(0,Z.jsx)(Fi,{icon:c.icon,width:16,height:16,className:`text-white`,"aria-hidden":!0})}):(0,Z.jsx)(`div`,{...w,role:`img`,"aria-label":u,className:y,style:{backgroundColor:c.color},children:(0,Z.jsx)(Fi,{icon:c.icon,width:16,height:16,className:`text-white`,"aria-hidden":!0})}),t[9]=l,t[10]=T,t[11]=w,t[12]=m,t[13]=a,t[14]=c.color,t[15]=c.icon,t[16]=p,t[17]=y,t[18]=u,t[19]=E):E=t[19];let D=E,O;t[20]===D?O=t[21]:(O=(0,Z.jsx)(pc,{asChild:!0,children:D}),t[20]=D,t[21]=O);let k;t[22]===u?k=t[23]:(k=(0,Z.jsx)(`span`,{className:`font-medium`,children:u}),t[22]=u,t[23]=k);let A;t[24]!==r||t[25]!==p?(A=r&&p?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Z.jsx)(X,{id:`Wh0im4`,values:{realCurrentDoc:p}})}):null,t[24]=r,t[25]=p,t[26]=A):A=t[26];let j;t[27]!==k||t[28]!==A?(j=(0,Z.jsxs)(mc,{className:`flex flex-col gap-0.5`,children:[k,A]}),t[27]=k,t[28]=A,t[29]=j):j=t[29];let M;return t[30]!==O||t[31]!==j?(M=(0,Z.jsxs)(gc,{children:[O,j]}),t[30]=O,t[31]=j,t[32]=M):M=t[32],M}function WN(e){let t=(0,$.c)(21),{count:n,remainder:r,crossDoc:i,scopedAgentId:a,onClickAgent:s}=e,c;t[0]!==n||t[1]!==i?(c=i?ic._({id:`9euN0m`,values:{count:n}}):ic._({id:`uhJEA2`,values:{count:n}}),t[0]=n,t[1]=i,t[2]=c):c=t[2];let l=c,u=i?`true`:void 0,d;t[3]!==n||t[4]!==l||t[5]!==u?(d=(0,Z.jsx)(o,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":u,className:`inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full bg-muted font-medium text-muted-foreground text-xs ring-2 ring-background hover:bg-muted/80`,"aria-label":l,children:[`+`,n]})}),t[3]=n,t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;if(t[7]!==i||t[8]!==s||t[9]!==r||t[10]!==a){let e;t[12]!==i||t[13]!==s||t[14]!==a?(e=e=>e.kind===`human`?(0,Z.jsx)(BN,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(UN,{participant:e,crossDoc:i,scoped:a===e.agentId,onClickAgent:s},e.agentId),t[12]=i,t[13]=s,t[14]=a,t[15]=e):e=t[15],f=r.map(e),t[7]=i,t[8]=s,t[9]=r,t[10]=a,t[11]=f}else f=t[11];let p;t[16]===f?p=t[17]:(p=(0,Z.jsx)(q,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:f})}),t[16]=f,t[17]=p);let m;return t[18]!==d||t[19]!==p?(m=(0,Z.jsxs)(he,{children:[d,p]}),t[18]=d,t[19]=p,t[20]=m):m=t[20],m}function GN(e,t,n,r){return e.kind===`human`?(0,Z.jsx)(BN,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(UN,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function KN(){let e=(0,$.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=_t(),{current:s,crossDoc:c}=jN(t,r,n);if(PN(JT(t),n),s.length===0&&c.length===0)return null;let l;if(e[0]!==c||e[1]!==s||e[2]!==o||e[3]!==a||e[4]!==i){let t=s.slice(0,FN),n;e[6]===s?n=e[7]:(n=s.slice(FN),e[6]=s,e[7]=n);let r=n,u=c.slice(0,IN),d;e[8]===c?d=e[9]:(d=c.slice(IN),e[8]=c,e[9]=d);let f=d,p=i,m=a===`agent`?o:null,h;e[10]!==p||e[11]!==m?(h=e=>GN(e,p,!1,m),e[10]=p,e[11]=m,e[12]=h):h=e[12];let g=t.map(h),_;e[13]!==r||e[14]!==p||e[15]!==m?(_=r.length>0?(0,Z.jsx)(WN,{count:r.length,remainder:r,crossDoc:!1,scopedAgentId:m,onClickAgent:p}):null,e[13]=r,e[14]=p,e[15]=m,e[16]=_):_=e[16];let v;e[17]!==g||e[18]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,"data-presence-section":`current`,children:[g,_]}),e[17]=g,e[18]=_,e[19]=v):v=e[19],l=(0,Z.jsxs)(`div`,{"data-slot":`presence-bar`,className:`flex items-center px-1 py-1.5`,children:[v,c.length>0?(0,Z.jsxs)(`div`,{className:`ml-1.5 flex items-center gap-1.5`,"data-presence-section":`crossdoc`,children:[u.map(e=>GN(e,p,!0,m)),f.length>0?(0,Z.jsx)(WN,{count:f.length,remainder:f,crossDoc:!0,scopedAgentId:m,onClickAgent:p}):null]}):null]}),e[0]=c,e[1]=s,e[2]=o,e[3]=a,e[4]=i,e[5]=l}else l=e[5];return l}var qN=`.md`,JN=/\.(md|mdx)$/i;function YN(e,t=qN){return`${e}${t}`}function XN(e){return wP(e).replace(JN,``)}function ZN(e){return To(e)?eP(e.path):Io(e)?e.path:YN(e.docName,e.docExt)}function QN(e){let t=wP(e).match(JN);return t?`.${t[1].toLowerCase()}`:void 0}function $N(e){return wP(e)}function eP(e){let t=wP(e.trim());return t?`${t}/`:``}function tP(e){return e.endsWith(`/`)?$N(e):XN(e)}function nP(e){return e.map(ZN)}function rP(e){return[...e].sort().join(`\0`)}function iP(e){return rP(nP(e))}function aP(e){let t=new Set;for(let n of e){let e=(To(n)||Io(n)?n.path:n.docName).split(`/`).filter(Boolean);if(e.includes(`.ok`))continue;if(To(n)){let e=eP(n.path);e&&t.add(e)}let r=To(n)?e.length:e.length-1;for(let n=1;n<=r;n++)t.add(`${e.slice(0,n).join(`/`)}/`)}return[...t].sort()}function oP(e){if(!e)return[];let t=wP(e.replace(JN,``)).split(`/`).filter(Boolean),n=[],r=e.endsWith(`/`)?t.length:t.length-1;for(let e=1;e<=r;e++)n.push(`${t.slice(0,e).join(`/`)}/`);return n}function sP(e,t,n){let r=QN(e);if(r)return r;let i=n.find(e=>zo(e)&&e.docName===t);return i?i.docExt??qN:CP(e).includes(`.`)?void 0:qN}function cP(e,t){let n=e.lastIndexOf(`/`),r=n===-1?``:e.slice(0,n+1),i=n===-1?e:e.slice(n+1),a=t.filter(e=>{if(!Io(e)||!e.path.startsWith(r))return!1;let t=e.path.slice(r.length);return!t.includes(`/`)&&t.startsWith(`${i}.`)});return a.length===1?a[0].path:null}function lP(e,t,n){if(QN(e))return null;let r=n.find(e=>Io(e)&&e.path===t);return r?r.path:CP(e).includes(`.`)?t:cP(t,n)}function uP(e,t){let n=e.kind===`directory`,r=n?$N(e.path):XN(e.path);if(n)return{kind:`folder`,name:wP(CP(e.path)).replace(JN,``),path:r,treePath:fP(e.path,!0)};let i=lP(e.path,r,t);if(i)return{kind:`asset`,name:wP(CP(i)),path:i,treePath:i};let a=sP(e.path,r,t);return{kind:`file`,name:wP(CP(e.path)).replace(JN,``),path:r,treePath:fP(e.path,!1),docExt:a}}function dP(e){return e.kind===`directory`?$N(e.path):e.path}function fP(e,t){return t?eP(e):JN.test(e)?e:`${e}${qN}`}function pP(e,t,n){let r=eP(t),i=new Set(n);for(let t=0;t<100;t++){let n=t===0?``:` ${t+1}`;if(e===`file`){let e=`${r}Untitled${n}${qN}`;if(!i.has(e))return{addPath:e,renamePath:e};continue}let a=`${r}New Folder${n}/`;if(!i.has(a))return{addPath:a,renamePath:a}}throw Error(`Could not allocate a unique tree placeholder`)}function mP(e,t){return e===`file`?fP(t,!1):`${$N(t)}/index${qN}`}function hP(e,t){return t.kind===`root`||t.directoryPath==null?CP(e):`${t.directoryPath}${CP(e)}`}function gP(e,t){if(t)return $N(eP(e));let n=XN(e),r=n.lastIndexOf(`/`);return r===-1?``:n.slice(0,r)}function _P(e,t){let n=$N(eP(e));return n?`${n}/${t}`:t}function vP(e,t,n){e.append(`parentDocName`,_P(t,n)),e.append(`placement`,`parent-dir`)}function yP(e,t){return(t.path??_P(e,t.src)).replace(/^\/+/,``)}function bP(e){let t=e.dataTransfer?.types;if(!t)return!1;let n=Array.from(t);return n.includes(`Files`)&&!n.includes(`application/x-open-knowledge-sidebar-item+json`)}function xP(e){return Array.from(e.dataTransfer?.files??[]).filter(e=>e.name.length>0||e.size>0)}function SP(e,t){let n=mt(e).toLowerCase();if(n===``)return null;let r=new Date().toISOString();if(n===`.md`||n===`.mdx`)return{kind:`document`,docName:XN(e),docExt:n,modified:r,size:t.size};let i=n.startsWith(`.`)?n.slice(1):n;return{kind:`asset`,path:e,assetExt:i,mediaKind:or(i),modified:r,size:t.size}}function CP(e){let t=wP(e),n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function wP(e){return e.endsWith(`/`)?e.slice(0,-1):e}function TP(e,t){return t.trim()}function EP(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function DP(e,t){let n=TP(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function OP(e,t,n=[],r=[],i=[]){if(t.length===0&&n.length===0&&r.length===0&&i.length===0)return e;let a=new Map(t.map(e=>[e.fromDocName,e.toDocName])),o=new Map(i.map(e=>[e.toDocName,e.docExt])),s=new Map(r.map(e=>[e.fromPath,e.toPath]));return e.map(e=>{if(zo(e)){let t=s.get(YN(e.docName,e.docExt));if(t){let n=Ro(t);return{kind:`asset`,path:t,assetExt:n,mediaKind:or(n),size:e.size,modified:e.modified,referencedBy:[]}}let n=a.get(e.docName)??e.docName;return{...e,docName:n,docExt:o.get(n)??e.docExt}}if(To(e))return{...e,path:FP(e.path,n)};if(Io(e)){let t=s.get(e.path);return t&&Ze(t)?{kind:`document`,docName:XN(t),docExt:mt(t),size:e.size,modified:e.modified}:{...e,path:t??FP(e.path,n)}}return e})}function kP(e,t,n,r=[]){if(t.length===0&&!n&&r.length===0)return e;let i=new Set(t),a=new Set(r);return e.filter(e=>zo(e)?!i.has(e.docName)&&!zP(e.docName,n):To(e)?!zP(e.path,n):Io(e)?!a.has(e.path)&&!zP(e.path,n):!0)}function AP(e,t){if(e.kind!==`asset`||t.some(t=>Io(t)&&t.path===e.path))return e;let n=cP(e.path,t);return n?{...e,path:n,name:n.split(`/`).pop()??n}:e}function jP(e,t,n,r=new Date().toISOString()){let i=!1,a=[...e],o=e=>{a.some(t=>IP(t,e))||(a.push(e),i=!0)};if(n.kind===`file`){let s=e.find(e=>zo(e)&&e.docName===t.path);return o({kind:`document`,docName:n.path,docExt:s?.docExt??t.docExt,size:s?.size??0,modified:r}),i?a:e}let s=e.find(e=>To(e)&&e.path===t.path);o({kind:`folder`,path:n.path,size:s?.size??0,modified:r});let c=new Set(n.duplicatedDocNames);for(let i of e){if(zo(i)){let e=RP(i.docName,t.path,n.path);e&&c.has(e)&&o({...i,docName:e,modified:r});continue}if(To(i)){let e=LP(i.path,t.path,n.path);e&&o({...i,path:e,modified:r})}}return i?a:e}function MP(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}function NP(e,t,n){return e.flatMap(e=>t===e.toDocName||!n(e.toDocName)?[e.fromDocName]:[e.fromDocName,e.toDocName])}function PP(e,t){let n=e.kind===`file`?YN(e.path,e.docExt):e.path;return Uo(t.contentDir,n,t.pathSeparator)}function FP(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 IP(e,t){return zo(e)&&zo(t)?e.docName===t.docName:To(e)&&To(t)||Io(e)&&Io(t)?e.path===t.path:!1}function LP(e,t,n){return e===t?n:RP(e,t,n)}function RP(e,t,n){return e.startsWith(`${t}/`)?`${n}${e.slice(t.length)}`:null}function zP(e,t){return!!t&&(e===t||e.startsWith(`${t}/`))}function BP(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(Kf,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function VP(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(qf,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function HP(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(Xf,{"data-slot":`context-menu-group`,...n}),t[2]=n,t[3]=r),r}function UP(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(np,{"data-slot":`context-menu-sub`,...n}),t[2]=n,t[3]=r),r}function WP(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-36 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 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[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Jf,{children:(0,Z.jsx)(Yf,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function GP(e){let t=(0,$.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...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]===n?s=t[6]:(s=Ti(`group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,Z.jsx)(Qf,{"data-slot":`context-menu-item`,"data-inset":r,"data-variant":o,className:s,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function KP(e){let t=(0,$.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=Ti(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(co,{className:`ml-auto`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,Z.jsxs)(rp,{"data-slot":`context-menu-sub-trigger`,"data-inset":i,className:o,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function qP(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-32 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg data-[state=closed]:overflow-hidden 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 subtle-scrollbar`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(ip,{"data-slot":`context-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function JP(e){let t=(0,$.c)(15),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:i,children:r,checked:n,inset:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===i?s=t[7]:(s=Ti(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,i),t[6]=i,t[7]=s);let c;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`span`,{className:`pointer-events-none absolute right-2`,children:(0,Z.jsx)(ep,{children:(0,Z.jsx)($a,{})})}),t[8]=c):c=t[8];let l;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==s?(l=(0,Z.jsxs)($f,{"data-slot":`context-menu-checkbox-item`,"data-inset":a,className:s,checked:n,...o,children:[c,r]}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=s,t[14]=l):l=t[14],l}function YP(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,inset:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=Ti(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,Z.jsx)(Zf,{"data-slot":`context-menu-label`,"data-inset":r,className:a,...i}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function XP(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ti(`-mx-1 my-1 h-px bg-border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(tp,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var ZP=`mr-1.5 flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm text-muted-foreground outline-none transition hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50`,QP=`border-border bg-background text-foreground hover:bg-background focus-visible:bg-background`,$P={start:[Ps.Space],cancel:[Ps.Esc],end:[Ps.Space,Ps.Enter]};function eF(e){return Ti(ZP,e?`opacity-100`:`pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100`)}function tF(e){return e?void 0:-1}function nF({className:e,isDragging:t}){return Ti(e,t&&QP)}function rF(e){return e.code===Ps.Enter&&e.target===e.currentTarget}function iF({event:e,hasKeyboardActivation:t,isDragging:n}){return e.defaultPrevented?`ignore`:!n&&t&&rF(e)?`activate-tab`:`delegate-sortable`}function aF({activeWidth:e,isDragging:t,outerStyle:n,transform:r,transition:i}){let a=t&&e?e:void 0;return{...n,transform:zs.Transform.toString(r?{...r,scaleX:1,scaleY:1}:null),transition:i,flexBasis:a??n?.flexBasis,maxWidth:a??n?.maxWidth,minWidth:a??n?.minWidth,opacity:n?.opacity,width:a??n?.width,zIndex:t?20:n?.zIndex}}function oF(e){let t=e?.querySelectorAll(`[data-editor-tab-sortable]`)??[],n=1/0,r=-1/0;for(let e of t){let t=e.getBoundingClientRect();n=Math.min(n,t.left),r=Math.max(r,t.right)}return Number.isFinite(n)&&Number.isFinite(r)?{left:n,right:r}:null}function sF(e){return({activeNodeRect:t,transform:n})=>{let r={...n,y:0};if(!e||!t)return r;let i=e.left-t.left,a=e.right-t.right;return r.x=Math.min(Math.max(r.x,i),a),r}}var cF=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(r){let e=1/0,i=-1/0,a=null,o=null;for(let r of t){let t=n.get(r.id);t&&(t.left<e&&(e=t.left,a=r),t.right>i&&(i=t.right,o=r))}if(!Number.isFinite(e)||!Number.isFinite(i))return[];let s=r.x<e?a:r.x>i?o:null;if(s)return[{id:s.id,data:{droppableContainer:s,value:0}}]}return Os(e)},lF=[`.md`,`.mdx`],uF=`group relative -mb-px flex h-10 min-w-28 max-w-64 shrink-0 cursor-pointer items-center overflow-hidden border border-transparent font-medium transition-colors`,dF=`z-10 rounded-t-lg rounded-b-none border-border border-b-0 bg-background text-foreground`,fF=Ti(dF,`bg-transparent hover:bg-muted focus-visible:bg-muted border-transparent hover:border-border focus-visible:border-border`),pF=`flex h-full min-w-0 flex-1 cursor-pointer items-center overflow-hidden px-3 text-left text-[13px]`;function mF(e){return e.replace(/[^A-Za-z0-9_-]/g,`-`)}function hF(e){let t=Ao(e);window.location.hash!==t&&(window.location.hash=t)}function gF(e){Math.abs(e.deltaX)>=Math.abs(e.deltaY)||e.currentTarget.scrollWidth<=e.currentTarget.clientWidth||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY)}function _F(e,t){let n=[t,...lF].filter((e,t,n)=>e&&n.indexOf(e)===t),r=e.toLowerCase(),i=n.find(t=>e.length>t.length&&r.endsWith(t.toLowerCase()));return i?e.slice(0,-i.length):e}function vF(e){let t=(0,$.c)(37),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]):({activateFromKeyboard:n,className:r,tabId:l,disabled:i,onKeyDown:a,ref:o,style:s,...c}=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;t[9]!==i||t[10]!==l?(u={id:l,disabled:i},t[9]=i,t[10]=l,t[11]=u):u=t[11];let{attributes:d,listeners:f,rect:p,setNodeRef:m,transform:h,transition:g,isDragging:_}=Ls(u),v=p.current?.width,y;t[12]!==_||t[13]!==s||t[14]!==v||t[15]!==h||t[16]!==g?(y=aF({activeWidth:v,isDragging:_,outerStyle:s,transform:h,transition:g}),t[12]=_,t[13]=s,t[14]=v,t[15]=h,t[16]=g,t[17]=y):y=t[17];let b=y,x;t[18]!==o||t[19]!==m?(x=function(e){m(e),typeof o==`function`?o(e):o&&`current`in o&&(o.current=e)},t[18]=o,t[19]=m,t[20]=x):x=t[20];let S=x,C=f?.onKeyDown,w;t[21]!==n||t[22]!==_||t[23]!==a||t[24]!==C?(w=function(e){a?.(e);let t=iF({event:e,hasKeyboardActivation:!!n,isDragging:_});if(t!==`ignore`){if(t===`activate-tab`&&n){e.preventDefault(),n();return}C?.(e)}},t[21]=n,t[22]=_,t[23]=a,t[24]=C,t[25]=w):w=t[25];let T=w,E;t[26]!==r||t[27]!==_?(E=nF({className:r,isDragging:_}),t[26]=r,t[27]=_,t[28]=E):E=t[28];let D;return t[29]!==d||t[30]!==S||t[31]!==T||t[32]!==f||t[33]!==c||t[34]!==b||t[35]!==E?(D=(0,Z.jsx)(`div`,{ref:S,"data-editor-tab-sortable":``,className:E,style:b,...c,...d,...f,onKeyDown:T}),t[29]=d,t[30]=S,t[31]=T,t[32]=f,t[33]=c,t[34]=b,t[35]=E,t[36]=D):D=t[36],D}function yF(e){let t=(0,$.c)(52),{children:n,closeTab:r,closeTabs:i,canPin:a,disabled:o,openTabs:s,pinTab:c,pinnedTabIds:l,tabId:u,unpinTab:d}=e,f=a===void 0?!0:a;if(o!==void 0&&o)return n;let p;t[0]!==f||t[1]!==l||t[2]!==u?(p=f&&l.includes(u),t[0]=f,t[1]=l,t[2]=u,t[3]=p):p=t[3];let m=p,h;if(t[4]!==s||t[5]!==l||t[6]!==u){let e;t[8]===u?e=t[9]:(e=e=>e!==u,t[8]=u,t[9]=e),h=an(s.filter(e),l),t[4]=s,t[5]=l,t[6]=u,t[7]=h}else h=t[7];let g=h,_;t[10]!==s||t[11]!==l?(_=an(s,l),t[10]=s,t[11]=l,t[12]=_):_=t[12];let v=_,y;t[13]===n?y=t[14]:(y=(0,Z.jsx)(VP,{asChild:!0,children:n}),t[13]=n,t[14]=y);let b;t[15]!==r||t[16]!==u?(b=()=>r(u),t[15]=r,t[16]=u,t[17]=b):b=t[17];let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(X,{id:`yz7wBu`}),t[18]=x):x=t[18];let S;t[19]!==m||t[20]!==b?(S=(0,Z.jsx)(GP,{disabled:m,onSelect:b,children:x}),t[19]=m,t[20]=b,t[21]=S):S=t[21];let C=g.length===0,w;t[22]!==i||t[23]!==g?(w=()=>{i(g)},t[22]=i,t[23]=g,t[24]=w):w=t[24];let T;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(X,{id:`omXJcU`}),t[25]=T):T=t[25];let E;t[26]!==C||t[27]!==w?(E=(0,Z.jsx)(GP,{disabled:C,onSelect:w,children:T}),t[26]=C,t[27]=w,t[28]=E):E=t[28];let D=v.length===0,O;t[29]!==v||t[30]!==i?(O=()=>{i(v)},t[29]=v,t[30]=i,t[31]=O):O=t[31];let k;t[32]===l.length?k=t[33]:(k=l.length?(0,Z.jsx)(X,{id:`U2Kx6T`}):(0,Z.jsx)(X,{id:`WyXG7w`}),t[32]=l.length,t[33]=k);let A;t[34]!==D||t[35]!==O||t[36]!==k?(A=(0,Z.jsx)(GP,{disabled:D,"data-testid":`editor-tab-context-close-all`,onSelect:O,children:k}),t[34]=D,t[35]=O,t[36]=k,t[37]=A):A=t[37];let j;t[38]!==f||t[39]!==m||t[40]!==c||t[41]!==u||t[42]!==d?(j=f&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(XP,{}),(0,Z.jsx)(GP,{"data-testid":`editor-tab-context-pin-toggle`,onSelect:()=>m?d(u):c(u),children:m?(0,Z.jsx)(X,{id:`SYfHmN`}):(0,Z.jsx)(X,{id:`3pU8e-`})})]}),t[38]=f,t[39]=m,t[40]=c,t[41]=u,t[42]=d,t[43]=j):j=t[43];let M;t[44]!==E||t[45]!==A||t[46]!==j||t[47]!==S?(M=(0,Z.jsxs)(WP,{className:`min-w-40`,children:[S,E,A,j]}),t[44]=E,t[45]=A,t[46]=j,t[47]=S,t[48]=M):M=t[48];let N;return t[49]!==M||t[50]!==y?(N=(0,Z.jsxs)(BP,{children:[y,M]}),t[49]=M,t[50]=y,t[51]=N):N=t[51],N}function bF(e){let t=(0,$.c)(26),{accessibleLabel:n,closeTab:r,isActive:i,isPinned:a,tabId:o,unpinTab:s}=e,{_:c}=cn();if(a){let e;t[0]!==c||t[1]!==n?(e=c({id:`t18QYR`,values:{accessibleLabel:n}}),t[0]=c,t[1]=n,t[2]=e):e=t[2];let r;t[3]!==o||t[4]!==s?(r=e=>{e.stopPropagation(),s(o)},t[3]=o,t[4]=s,t[5]=r):r=t[5];let i;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Sd,{"aria-hidden":`true`}),t[6]=i):i=t[6];let a;return t[7]!==e||t[8]!==r?(a=(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":e,"data-testid":`editor-tab-unpin-button`,className:`mr-1.5 text-primary! hover:bg-primary/10!`,onClick:r,children:i}),t[7]=e,t[8]=r,t[9]=a):a=t[9],a}let l;t[10]!==c||t[11]!==n?(l=c({id:`JLzQi_`,values:{accessibleLabel:n}}),t[10]=c,t[11]=n,t[12]=l):l=t[12];let u;t[13]===i?u=t[14]:(u=eF(i),t[13]=i,t[14]=u);let d;t[15]===i?d=t[16]:(d=tF(i),t[15]=i,t[16]=d);let f;t[17]!==r||t[18]!==o?(f=e=>{e.stopPropagation(),r(o)},t[17]=r,t[18]=o,t[19]=f):f=t[19];let p;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(Ys,{"aria-hidden":`true`}),t[20]=p):p=t[20];let m;return t[21]!==l||t[22]!==u||t[23]!==d||t[24]!==f?(m=(0,Z.jsx)(Di,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":l,"data-testid":`editor-tab-close-button`,className:u,tabIndex:d,onClick:f,children:p}),t[21]=l,t[22]=u,t[23]=d,t[24]=f,t[25]=m):m=t[25],m}function xF(e){let t=(0,$.c)(1),{docName:n}=e;if(DT(n)!==`conflict`)return null;let r;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(mo,{"aria-label":`Conflict`,"data-testid":`editor-tab-conflict-badge`,className:`mr-1 size-3.5 shrink-0 text-amber-500`}),t[0]=r):r=t[0],r}function SF(){let e=(0,$.c)(80),{activeDocName:t,activeTabId:n,activeNewTabId:r,activeTarget:i,activateTab:a,activateNewTab:o,closeAndClearForRename:c,closeNewTab:l,closeTab:u,closeTabs:d,getPoolActiveDocName:f,poolHas:p,isNewTabActive:m,newTabIds:g,openNewTab:_,openTabs:v,pinTab:y,pinnedTabIds:b,remapTabsForRename:x,reorderTabs:S,unpinTab:C,visibleTabIds:w}=_t(),{_:T}=cn(),{pageMeta:E}=Oo(),D=(0,Q.useRef)(null),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(``),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(!1),R=(0,Q.useRef)(null),z=(0,Q.useRef)(!1),B=(0,Q.useRef)(!1),V=(0,Q.useRef)(null),H=(0,Q.useRef)(t),U;e[0]!==n||e[1]!==t||e[2]!==i?(U=n??(i?h(i):t?Yt(t):null),e[0]=n,e[1]=t,e[2]=i,e[3]=U):U=e[3];let G=U,K;e[4]!==r||e[5]!==G||e[6]!==m||e[7]!==g||e[8]!==v?(K=m?`${r??`__new-tab__`}\u0000${v.join(`\0`)}\u0000${g.join(`\0`)}`:G?`${G}\u0000${v.join(`\0`)}`:``,e[4]=r,e[5]=G,e[6]=m,e[7]=g,e[8]=v,e[9]=K):K=e[9];let q=K,Y,ee;e[10]===t?(Y=e[11],ee=e[12]):(Y=()=>{H.current=t},ee=[t],e[10]=t,e[11]=Y,e[12]=ee),(0,Q.useEffect)(Y,ee);let te,ne;e[13]===q?(te=e[14],ne=e[15]):(te=()=>{q&&(D.current?.querySelector(`[data-active-tab="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},ne=[q],e[13]=q,e[14]=te,e[15]=ne),(0,Q.useEffect)(te,ne);let re,ie;e[16]===A?(re=e[17],ie=e[18]):(re=()=>{A&&(R.current?.focus(),R.current?.select())},ie=[A],e[16]=A,e[17]=re,e[18]=ie),(0,Q.useEffect)(re,ie);let ae,oe;e[19]!==v||e[20]!==A?(ae=()=>{!A||v.includes(A.tabId)||(B.current=!0,V.current=null,j(null),N(``),F(null),L(!1))},oe=[v,A],e[19]=v,e[20]=A,e[21]=ae,e[22]=oe):(ae=e[21],oe=e[22]),(0,Q.useEffect)(ae,oe);let se=function(e,t){let n=t.split(`/`);B.current=!1,V.current=null,j({docName:t,tabId:e}),N(n[n.length-1]),F(null)},ce=function(){B.current=!0,V.current=null,j(null),N(``),F(null),L(!1)},le=async function(){if(B.current){B.current=!1;return}if(z.current)return;let e=A?.docName;if(!e){ce();return}let t=TP(`file`,_F(M,E.get(e)?.docExt??`.md`)),n=e.split(`/`),r=n[n.length-1];if(t===r){ce();return}if(t===V.current){R.current?.focus();return}if(!EP(t)){F(T({id:`P8yDjG`})),R.current?.focus();return}let i=DP({kind:`file`,path:e,name:r},t);z.current=!0,L(!0),F(null);try{let n=await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`file`,fromPath:e,toPath:i})});if(B.current){L(!1),z.current=!1;return}let r=await J(n,`Server error (HTTP ${n.status})`);if(!r.ok){F(r.title),L(!1),z.current=!1,V.current=t,R.current?.focus();return}let a=s(Pr,r.body,`rename-path:tab`,{renamed:[],renamedAssets:[]}).renamed,o=H.current,l=MP(o,a);W(a);let u=!0;try{let e=NP(a,f(),p);await Promise.all(e.map(e=>c(e))),x(a),ec([`files`,`backlinks`,`graph`])}catch(n){let r=n;u=!1,console.warn(`[EditorTabs] post-rename reconciliation failed`,{err:r,docName:e,newDocName:i,normalized:t}),Js.error(T({id:`MUBR8r`}))}B.current=!0,j(null),N(``),F(null),L(!1),z.current=!1,V.current=null,u&&l&&l!==o&&hF(l)}catch(n){console.warn(`[EditorTabs] rename failed`,{err:n,docName:e,newDocName:i,normalized:t}),F(T({id:`HIb0vl`})),L(!1),z.current=!1,V.current=t,R.current?.focus()}},ue=typeof window<`u`&&window.okDesktop!=null,de;e[23]===g?de=e[24]:(de=new Set(g),e[23]=g,e[24]=de);let fe=de,pe;e[25]===O?pe=e[26]:(pe=sF(O),e[25]=O,e[26]=pe);let me;e[27]===pe?me=e[28]:(me=[pe],e[27]=pe,e[28]=me);let he=me,ge;e[29]!==l||e[30]!==d||e[31]!==fe?(ge=function(e){let t=[],n=[];for(let r of e)fe.has(r)?n.push(r):t.push(r);t.length>0&&d(t);for(let e of n)l(e)},e[29]=l,e[30]=d,e[31]=fe,e[32]=ge):ge=e[32];let _e=ge,ve;e[33]===Symbol.for(`react.memo_cache_sentinel`)?(ve={activationConstraint:{distance:8}},e[33]=ve):ve=e[33];let ye;e[34]===Symbol.for(`react.memo_cache_sentinel`)?(ye={coordinateGetter:js,keyboardCodes:$P},e[34]=ye):ye=e[34];let be=Rs(Ts(ks,ve),Ts(Ms,ye)),xe;e[35]===Symbol.for(`react.memo_cache_sentinel`)?(xe=function(){k(oF(D.current))},e[35]=xe):xe=e[35];let Se=xe,Ce;e[36]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=function(){k(null)},e[36]=Ce):Ce=e[36];let we=Ce,Te;e[37]!==we||e[38]!==S||e[39]!==w?(Te=function(e){we();let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let r=w.indexOf(t),i=w.indexOf(n);r<0||i<0||r===i||S(Fs([...w],r,i),t)},e[37]=we,e[38]=S,e[39]=w,e[40]=Te):Te=e[40];let Ee=Te,De=ue?``:void 0,Oe;e[41]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=Ti(`pl-2 flex h-12 min-w-0 touch-manipulation flex-1 items-end overflow-x-auto overflow-y-hidden overscroll-x-contain scroll-fade-mask-x [scrollbar-width:none]`,ue&&`[-webkit-app-region:drag]`),e[41]=Oe):Oe=e[41];let ke=gF,Ae;e[42]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=Ti(`flex items-end gap-1`,ue&&`[-webkit-app-region:no-drag]`),e[42]=Ae):Ae=e[42];let je=Ds,Me=cF,Ne;e[43]===Symbol.for(`react.memo_cache_sentinel`)?(Ne={container:typeof document<`u`?document.body:void 0},e[43]=Ne):Ne=e[43];let Pe=Ns,Fe;e[44]===w?Fe=e[45]:(Fe=[...w],e[44]=w,e[45]=Fe);let Ie=Es,Le=w.map(e=>{if(fe.has(e)){let t=e===r;return(0,Z.jsx)(yF,{tabId:e,canPin:!1,openTabs:w,closeTab:l,closeTabs:_e,pinTab:y,pinnedTabIds:b,unpinTab:C,children:(0,Z.jsxs)(vF,{tabId:e,activateFromKeyboard:()=>o(e),"aria-current":t?`page`:void 0,"data-active-tab":t?`true`:void 0,className:Ti(uF,t?dF:fF),onAuxClick:t=>{t.button===1&&(t.preventDefault(),l(e))},onClick:t=>{t.target===t.currentTarget&&o(e)},children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":T({id:`zLak8b`}),"data-testid":`editor-new-tab-placeholder-button`,className:pF,onClick:()=>o(e),tabIndex:-1,children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,Z.jsx)(X,{id:`3YvS-c`})})}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":T({id:`xCdTnb`}),"data-testid":`editor-new-tab-placeholder-close`,className:eF(t),tabIndex:tF(t),onClick:t=>{t.stopPropagation(),l(e)},children:(0,Z.jsx)(Ys,{"aria-hidden":`true`,className:`size-3.5`})})]})},e)}let t=en(e),n=e===G,i=b.includes(e);if(t.kind===`folder`){let{baseName:r,label:o,prefix:s}=Zt(t.folderPath,`/`),c=`${s}${o}`;return(0,Z.jsx)(yF,{tabId:e,openTabs:w,closeTab:u,closeTabs:_e,pinTab:y,pinnedTabIds:b,unpinTab:C,children:(0,Z.jsxs)(vF,{tabId:e,activateFromKeyboard:()=>a(e),"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:Ti(uF,n?dF:fF),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&u(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":c,title:c,className:pF,onClick:()=>{a(e)},tabIndex:-1,children:[s&&(0,Z.jsx)(`span`,{className:Ti(`min-w-0 flex-1 truncate`,n&&`text-muted-foreground`),children:s}),(0,Z.jsxs)(`span`,{className:Ti(`flex min-w-0 items-center`,s?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`/`})]})]}),(0,Z.jsx)(bF,{accessibleLabel:c,closeTab:u,isActive:n,isPinned:i,tabId:e,unpinTab:C})]})},e)}if(t.kind===`asset`||t.kind===`skill-file`){let{baseName:r,label:o,prefix:s}=Zt(t.kind===`asset`?t.assetPath:t.path,``),c=`${s}${o}`;return(0,Z.jsx)(yF,{tabId:e,openTabs:w,closeTab:u,closeTabs:_e,pinTab:y,pinnedTabIds:b,unpinTab:C,children:(0,Z.jsxs)(vF,{tabId:e,activateFromKeyboard:()=>a(e),"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:Ti(uF,n?dF:fF),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&u(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":c,className:pF,onClick:()=>{a(e)},tabIndex:-1,children:[s?(0,Z.jsx)(`span`,{className:Ti(`min-w-0 flex-1 truncate text-muted-foreground/60`,n&&`text-muted-foreground`),children:s}):null,(0,Z.jsx)(`span`,{className:Ti(`min-w-0 truncate`,s?`max-w-[70%] shrink-0`:`flex-1`),children:r})]}),(0,Z.jsx)(bF,{accessibleLabel:c,closeTab:u,isActive:n,isPinned:i,tabId:e,unpinTab:C})]})},e)}let s=t.docName,c=E.get(s)?.docExt??`.md`,{baseName:d,extension:f,label:p,prefix:m}=Zt(s,c),h=`${m}${p}`,g=c===`.md`||c===`.mdx`,_=A?.tabId===e,v=`editor-tab-rename-error-${mF(s)}`;return(0,Z.jsx)(yF,{disabled:_,tabId:e,openTabs:w,closeTab:u,closeTabs:_e,pinTab:y,pinnedTabIds:b,unpinTab:C,children:(0,Z.jsx)(vF,{tabId:e,activateFromKeyboard:()=>a(e),disabled:_,"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:Ti(uF,n?dF:fF,_&&P&&`border-destructive`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&u(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:_?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(iT,{className:`h-full min-w-0 flex-1 rounded-none border-0 bg-transparent dark:bg-transparent`,children:[(0,Z.jsx)(lT,{ref:R,value:M,disabled:I,"aria-label":T({id:`Dw1T_W`,values:{label:p}}),"data-testid":`editor-tab-rename-input`,"aria-invalid":P?!0:void 0,"aria-describedby":P?v:void 0,"aria-busy":I||void 0,title:P??s,className:`h-full min-w-0 px-2 py-0 font-medium text-foreground text-xs selection:bg-primary selection:text-primary-foreground`,onChange:e=>{N(_F(e.target.value,c)),F(null),V.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),le()):e.key===`Escape`&&(e.preventDefault(),ce())},onBlur:le}),(0,Z.jsx)(oT,{align:`inline-end`,"aria-hidden":`true`,className:`pr-2 text-xs`,children:(0,Z.jsx)(cT,{className:`text-muted-foreground/60 text-xs`,children:c})})]}),P?(0,Z.jsx)(`span`,{id:v,role:`alert`,className:`sr-only`,children:P}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":h,title:h,className:pF,onClick:()=>{a(e)},onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),se(e,s)},tabIndex:-1,children:[(0,Z.jsx)(xF,{docName:s}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:d}),!g&&(0,Z.jsx)(`span`,{className:`shrink-0`,children:f})]})]}),(0,Z.jsx)(bF,{accessibleLabel:h,closeTab:u,isActive:n,isPinned:i,tabId:e,unpinTab:C})]})})},e)}),Re;e[46]!==Pe||e[47]!==Fe||e[48]!==Ie||e[49]!==Le?(Re=(0,Z.jsx)(Pe,{items:Fe,strategy:Ie,children:Le}),e[46]=Pe,e[47]=Fe,e[48]=Ie,e[49]=Le,e[50]=Re):Re=e[50];let ze;e[51]!==je||e[52]!==we||e[53]!==Ee||e[54]!==Se||e[55]!==be||e[56]!==!1||e[57]!==Me||e[58]!==Ne||e[59]!==Re||e[60]!==he?(ze=(0,Z.jsx)(je,{sensors:be,autoScroll:!1,collisionDetection:Me,modifiers:he,onDragStart:Se,onDragEnd:Ee,onDragCancel:we,accessibility:Ne,children:Re}),e[51]=je,e[52]=we,e[53]=Ee,e[54]=Se,e[55]=be,e[56]=!1,e[57]=Me,e[58]=Ne,e[59]=Re,e[60]=he,e[61]=ze):ze=e[61];let Be;e[62]===T?Be=e[63]:(Be=T({id:`3YvS-c`}),e[62]=T,e[63]=Be);let Ve;e[64]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=(0,Z.jsx)(xt,{"aria-hidden":`true`}),e[64]=Ve):Ve=e[64];let He;e[65]!==_||e[66]!==Be?(He=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":Be,"data-testid":`editor-new-tab-button`,className:`first:mb-3 mb-1.5`,onClick:_,children:Ve})}),e[65]=_,e[66]=Be,e[67]=He):He=e[67];let Ue;e[68]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,Z.jsx)(mc,{children:(0,Z.jsx)(X,{id:`3YvS-c`})}),e[68]=Ue):Ue=e[68];let We;e[69]===He?We=e[70]:(We=(0,Z.jsxs)(gc,{children:[He,Ue]}),e[69]=He,e[70]=We);let Ge;e[71]!==Ae||e[72]!==ze||e[73]!==We?(Ge=(0,Z.jsxs)(`div`,{className:Ae,children:[ze,We]}),e[71]=Ae,e[72]=ze,e[73]=We,e[74]=Ge):Ge=e[74];let Ke;return e[75]!==De||e[76]!==Oe||e[77]!==ke||e[78]!==Ge?(Ke=(0,Z.jsx)(`div`,{ref:D,"data-electron-drag":De,className:Oe,onWheel:ke,children:Ge}),e[75]=De,e[76]=Oe,e[77]=ke,e[78]=Ge,e[79]=Ke):Ke=e[79],Ke}var CF=(e,t,n)=>{if(e&&`reportValidity`in e){let r=ea(n,t);e.setCustomValidity(r&&r.message||``),e.reportValidity()}},wF=(e,t)=>{for(let n in t.fields){let r=t.fields[n];r&&r.ref&&`reportValidity`in r.ref?CF(r.ref,n,e):r&&r.refs&&r.refs.forEach(t=>CF(t,n,e))}},TF=(e,t)=>{t.shouldUseNativeValidation&&wF(e,t);let n={};for(let r in e){let i=ea(t.fields,r),a=Object.assign(e[r]||{},{ref:i&&i.ref});if(EF(t.names||Object.keys(e),r)){let e=Object.assign({},ea(n,r));Vi(e,`root`,a),Vi(n,r,e)}else Vi(n,r,a)}return n},EF=(e,t)=>{let n=DF(t).replace(/[.*+?^${}()|\\]/g,`\\$&`);return e.some(e=>DF(e).match(`^${n}\\.\\d+`))};function DF(e){return e.replace(/[\[\]]/g,``)}function OF(){return OF=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},OF.apply(null,arguments)}function kF(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}function AF(e,t){for(var n={};e.length;){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o])if(`unionErrors`in r){var s=r.unionErrors[0].errors[0];n[o]={message:s.message,type:s.code}}else n[o]={message:a,type:i};if(`unionErrors`in r&&r.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=Fa(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()}return n}function jF(e,t){for(var n={},r=function(){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o])if(r.code===`invalid_union`&&r.errors.length>0){var s=r.errors[0][0];n[o]={message:s.message,type:s.code}}else n[o]={message:a,type:i};if(r.code===`invalid_union`&&r.errors.forEach(function(t){return t.forEach(function(t){return e.push(OF({},t,{path:[].concat(r.path,t.path)}))})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=Fa(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()};e.length;)r();return n}function MF(e,t,n){if(n===void 0&&(n={}),function(e){return`_def`in e&&typeof e._def==`object`&&`typeName`in e._def}(e))return function(r,i,a){try{return Promise.resolve(kF(function(){return Promise.resolve(e[n.mode===`sync`?`parse`:`parseAsync`](r,t)).then(function(e){return a.shouldUseNativeValidation&&wF({},a),{errors:{},values:n.raw?Object.assign({},r):e}})},function(e){if(function(e){return Array.isArray(e?.issues)}(e))return{values:{},errors:TF(AF(e.errors,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};if(function(e){return`_zod`in e&&typeof e._zod==`object`}(e))return function(r,i,a){try{return Promise.resolve(kF(function(){return Promise.resolve((n.mode===`sync`?Un:vr)(e,r,t)).then(function(e){return a.shouldUseNativeValidation&&wF({},a),{errors:{},values:n.raw?Object.assign({},r):e}})},function(e){if(function(e){return e instanceof er}(e))return{values:{},errors:TF(jF(e.issues,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};throw Error(`Invalid input: not a Zod schema`)}var NF=`https://openknowledge.ai/api/subscribe`;async function PF(e){try{let t=await fetch(NF,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({email:e}),signal:AbortSignal.timeout(15e3)});return t.ok?{ok:!0}:t.status===400?{ok:!1,reason:`invalid`}:t.status===503?{ok:!1,reason:`unavailable`}:(console.warn(`[subscribe] action=submit result=http-error status=${t.status}`),{ok:!1,reason:`error`})}catch(e){return console.warn(`[subscribe] action=submit result=network-error message=${e instanceof Error?e.message:String(e)}`),{ok:!1,reason:`error`}}}function FF(e){let t=(0,$.c)(47),{title:n,description:r,onSuccess:i,onDismiss:a,autoFocus:o,className:s}=e,{_:c}=cn(),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f,p;t[0]===l?(f=t[1],p=t[2]):(f=()=>{l&&d.current?.focus()},p=[l],t[0]=l,t[1]=f,t[2]=p),(0,Q.useEffect)(f,p);let m,h;if(t[3]!==c){let e=fr({email:nr({message:c({id:`Wq6Wcm`})})});h=Bi,m=MF(e),t[3]=c,t[4]=m,t[5]=h}else m=t[4],h=t[5];let g;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(g={email:``},t[6]=g):g=t[6];let _;t[7]===m?_=t[8]:(_={resolver:m,defaultValues:g},t[7]=m,t[8]=_);let v=h(_),{isSubmitting:y}=v.formState,b=v.formState.errors.email?.message??v.formState.errors.root?.message,x;t[9]!==c||t[10]!==v||t[11]!==i?(x=async function(e){v.clearErrors(`root`);let t=await PF(e.email);if(t.ok){u(!0),i?.();return}if(t.reason===`invalid`){v.setError(`email`,{message:c({id:`Wq6Wcm`})});return}if(t.reason===`unavailable`){v.setError(`root`,{message:c({id:`4mLBx9`})});return}v.setError(`root`,{message:c({id:`fWsBTs`})})},t[9]=c,t[10]=v,t[11]=i,t[12]=x):x=t[12];let S=x,C;t[13]===s?C=t[14]:(C=Ti(`flex flex-col gap-3`,s),t[13]=s,t[14]=C);let w=l?-1:void 0,T;t[15]!==l||t[16]!==n?(T=l?(0,Z.jsxs)(`span`,{className:`mb-1.5 inline-flex flex-row items-center gap-2`,children:[(0,Z.jsx)($a,{className:`size-4 text-primary`}),(0,Z.jsx)(X,{id:`PIMM5l`})]}):n??(0,Z.jsx)(X,{id:`GzPQ2f`}),t[15]=l,t[16]=n,t[17]=T):T=t[17];let E;t[18]!==T||t[19]!==w?(E=(0,Z.jsx)(`p`,{ref:d,tabIndex:w,className:`text-base font-medium leading-tight text-foreground focus:outline-none`,children:T}),t[18]=T,t[19]=w,t[20]=E):E=t[20];let D;t[21]!==r||t[22]!==l?(D=l?(0,Z.jsx)(X,{id:`pBROkv`}):r??(0,Z.jsx)(X,{id:`WmPbvm`}),t[21]=r,t[22]=l,t[23]=D):D=t[23];let O;t[24]===D?O=t[25]:(O=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,role:`status`,children:D}),t[24]=D,t[25]=O);let k;t[26]!==E||t[27]!==O?(k=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[E,O]}),t[26]=E,t[27]=O,t[28]=k):k=t[28];let A;t[29]!==c||t[30]!==a?(A=a?(0,Z.jsx)(Di,{type:`button`,variant:`ghost`,size:`icon`,onClick:a,"aria-label":c({id:`yz7wBu`}),className:`-mr-1.5 -mt-1 size-7 shrink-0 text-muted-foreground opacity-60`,children:(0,Z.jsx)(Ys,{className:`size-4`})}):null,t[29]=c,t[30]=a,t[31]=A):A=t[31];let j;t[32]!==k||t[33]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[k,A]}),t[32]=k,t[33]=A,t[34]=j):j=t[34];let M;t[35]!==c||t[36]!==o||t[37]!==b||t[38]!==v||t[39]!==y||t[40]!==S||t[41]!==l?(M=l?null:(0,Z.jsxs)(`form`,{onSubmit:v.handleSubmit(S),className:`flex flex-col gap-2`,noValidate:!0,children:[(0,Z.jsx)($i,{control:v.control,name:`email`,render:e=>{let{field:t,fieldState:n}=e;return(0,Z.jsxs)(iT,{className:`h-10 rounded-xl`,children:[(0,Z.jsx)(oT,{className:`pl-2.5`,children:(0,Z.jsx)(dd,{className:`size-4 text-muted-foreground opacity-60`})}),(0,Z.jsx)(lT,{...t,id:t.name,type:`email`,inputMode:`email`,autoComplete:`email`,spellCheck:!1,autoFocus:o,placeholder:c({id:`2hYmUH`}),"aria-invalid":n.invalid,"aria-label":c({id:`ATGYL1`}),"data-testid":`subscribe-email`,className:`placeholder:text-muted-foreground/60`}),(0,Z.jsx)(Di,{type:`submit`,disabled:y,className:`mr-1 ml-auto text-1sm`,"data-testid":`subscribe-submit`,children:y?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(hs,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(X,{id:`lCC_D5`})})]}):(0,Z.jsx)(X,{id:`EDl9kS`})})]})}}),b?(0,Z.jsx)(`p`,{className:`text-sm text-destructive`,role:`alert`,children:b}):null]}),t[35]=c,t[36]=o,t[37]=b,t[38]=v,t[39]=y,t[40]=S,t[41]=l,t[42]=M):M=t[42];let N;return t[43]!==j||t[44]!==M||t[45]!==C?(N=(0,Z.jsxs)(`div`,{className:C,children:[j,M]}),t[43]=j,t[44]=M,t[45]=C,t[46]=N):N=t[46],N}function IF(e){let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Discord`}),r=(0,Z.jsx)(`path`,{d:`M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9554 2.4189-2.1568 2.4189Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(`svg`,{role:`img`,fill:`currentColor`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function LF(e){let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`X (Twitter)`}),r=(0,Z.jsx)(`path`,{d:`M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(`svg`,{role:`img`,fill:`currentColor`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var RF=`https://github.com/inkeep/open-knowledge`,zF=[{key:`resources`,heading:{id:`s-MGs7`},links:[{label:{id:`TbjyhA`},href:`https://openknowledge.ai/docs`,icon:at},{label:{id:`PCNIuJ`},href:`${RF}/issues/new`,icon:Iu},{label:{id:`On0aF2`},href:`https://openknowledge.ai/`,icon:ho}]},{key:`community`,heading:{id:`chL5IG`},links:[{label:`Discord`,href:`https://discord.com/invite/YujKpFN49`,icon:IF},{label:`X (Twitter)`,href:`https://x.com/OpenKnowledgeAI`,icon:LF},{label:`GitHub`,href:RF,icon:nm}]}],BF=`${RF}/releases`,VF=`group flex items-center gap-2.5 rounded-md px-2 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`;function HF(e){if(e<1e3)return String(e);let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`}var UF=e=>{let t=(0,$.c)(12),{count:n}=e,{_:r}=cn(),i,a,o,s;t[0]!==r||t[1]!==n?(i=HF(n),a=`img`,o=`ml-auto flex items-center gap-1 text-xs tabular-nums text-muted-foreground`,s=r({id:`SVLPt5`,values:{formatted:i}}),t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s):(i=t[2],a=t[3],o=t[4],s=t[5]);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Fd,{className:`size-3 fill-current`,"aria-hidden":`true`}),t[6]=c):c=t[6];let l;return t[7]!==i||t[8]!==a||t[9]!==o||t[10]!==s?(l=(0,Z.jsxs)(`span`,{role:a,className:o,"aria-label":s,children:[c,i]}),t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=l):l=t[11],l},WF=e=>{let t=(0,$.c)(15),{link:n,trailing:r}=e,{_:i}=cn(),{label:a,href:o,icon:s}=n,c,l;t[0]===o?(c=t[1],l=t[2]):(c=e=>ac(e,o),l=e=>ac(e,o),t[0]=o,t[1]=c,t[2]=l);let u;t[3]===s?u=t[4]:(u=(0,Z.jsx)(s,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t[3]=s,t[4]=u);let d;t[5]!==i||t[6]!==a?(d=typeof a==`string`?a:i(a),t[5]=i,t[6]=a,t[7]=d):d=t[7];let f;return t[8]!==o||t[9]!==c||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==r?(f=(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`a`,{href:o,target:`_blank`,rel:`noopener noreferrer`,onClick:c,onAuxClick:l,className:VF,children:[u,d,r]})}),t[8]=o,t[9]=c,t[10]=l,t[11]=u,t[12]=d,t[13]=r,t[14]=f):f=t[14],f},GF=e=>{let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:n}),t[0]=n,t[1]=r),r},KF=()=>{let e=(0,$.c)(28),{_:t}=cn(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),l,u;e[0]!==n||e[1]!==s?(l=()=>{if(!n||s!==null)return;let e=new AbortController;return Ar({signal:e.signal}).then(e=>{e!==null&&c(e)}),()=>e.abort()},u=[n,s],e[0]=n,e[1]=s,e[2]=l,e[3]=u):(l=e[2],u=e[3]),(0,Q.useEffect)(l,u);let d;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=e=>{r(e),e||a(!1)},e[4]=d):d=e[4];let f;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(_,{className:`size-4`}),e[5]=f):f=e[5];let p;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(o,{asChild:!0,children:(0,Z.jsxs)(Di,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[f,(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(X,{id:`s-MGs7`})})]})})}),e[6]=p):p=e[6];let m;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsxs)(gc,{children:[p,(0,Z.jsx)(mc,{children:(0,Z.jsx)(X,{id:`s-MGs7`})})]}),e[7]=m):m=e[7];let h;e[8]!==t||e[9]!==s?(h=zF.map((e,n)=>(0,Z.jsxs)(`div`,{className:Ti(n>0&&`mt-3`),children:[(0,Z.jsx)(GF,{children:t(e.heading)}),(0,Z.jsx)(`nav`,{"aria-label":t(e.heading),children:(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:e.links.map(e=>(0,Z.jsx)(WF,{link:e,trailing:e.href===RF&&s!==null?(0,Z.jsx)(UF,{count:s}):void 0},e.href))})})]},e.key)),e[8]=t,e[9]=s,e[10]=h):h=e[10];let g;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(GF,{children:(0,Z.jsx)(X,{id:`arUUsK`})}),e[11]=g):g=e[11];let v;e[12]===t?v=e[13]:(v=t({id:`arUUsK`}),e[12]=t,e[13]=v);let y;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(WF,{link:{label:{id:`3ePd3I`},href:BF,icon:pd}}),e[14]=y):y=e[14];let b;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(o,{asChild:!0,children:(0,Z.jsxs)(Di,{variant:`ghost`,className:Ti(VF,`h-auto w-full justify-start font-normal`),children:[(0,Z.jsx)(dd,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,Z.jsx)(X,{id:`EDl9kS`})]})}),e[15]=b):b=e[15];let x;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(q,{side:`left`,align:`center`,sideOffset:20,className:`w-80`,children:(0,Z.jsx)(FF,{autoFocus:!0,onDismiss:()=>a(!1)})}),e[16]=x):x=e[16];let S;e[17]===i?S=e[18]:(S=(0,Z.jsxs)(`ul`,{className:`space-y-0.5`,children:[y,(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(he,{open:i,onOpenChange:a,children:[b,x]})})]}),e[17]=i,e[18]=S);let C;e[19]!==S||e[20]!==v?(C=(0,Z.jsxs)(`div`,{className:`mt-3`,children:[g,(0,Z.jsx)(`nav`,{"aria-label":v,children:S})]}),e[19]=S,e[20]=v,e[21]=C):C=e[21];let w;e[22]!==C||e[23]!==h?(w=(0,Z.jsxs)(q,{align:`end`,className:`w-56 p-3`,children:[h,C]}),e[22]=C,e[23]=h,e[24]=w):w=e[24];let T;return e[25]!==n||e[26]!==w?(T=(0,Z.jsxs)(he,{open:n,onOpenChange:d,children:[m,w]}),e[25]=n,e[26]=w,e[27]=T):T=e[27],T},qF=50,JF=()=>{let e=(0,$.c)(8),t=(0,Q.useRef)(null),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t.current===null&&(t.current=setTimeout(()=>{t.current=null,Uw.preload()},qF))},e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},e[1]=i):i=e[1];let a=i,o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>()=>{t.current!==null&&clearTimeout(t.current)},s=[],e[2]=o,e[3]=s):(o=e[2],s=e[3]),(0,Q.useEffect)(o,s);let c,l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{a(),window.location.hash!==`#settings`&&(window.location.hash=ra)},l=(0,Z.jsx)(Od,{className:`size-4`}),e[4]=c,e[5]=l):(c=e[4],l=e[5]);let u;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsxs)(Di,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,"data-testid":`header-settings-button`,onMouseEnter:r,onMouseLeave:a,onFocus:r,onBlur:a,onClick:c,children:[l,(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(X,{id:`Tz0i8g`})})]})}),e[6]=u):u=e[6];let d;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsxs)(gc,{children:[u,(0,Z.jsx)(mc,{children:(0,Z.jsx)(X,{id:`Tz0i8g`})})]}),e[7]=d):d=e[7],d},YF=`https://openknowledge.ai/docs/features/share`;function XF(e){let t=(0,$.c)(42),{input:n,onClickWhenNoRemote:r}=e,{_:i}=cn(),{status:a}=ia(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d;t[0]===c?.autoCopyFailed?d=t[1]:(d=()=>{!c?.autoCopyFailed||!u.current||(u.current.focus(),u.current.select())},t[0]=c?.autoCopyFailed,t[1]=d);let f;t[2]===c?f=t[3]:(f=[c],t[2]=c,t[3]=f),(0,Q.useEffect)(d,f);let p=a?.hasRemote===!0,m=n===null,h;t[4]!==i||t[5]!==o||t[6]!==p||t[7]!==n||t[8]!==r?(h=async function(){if(!o&&n!==null){s(!0),l(null);try{let e=await Yi({...n,hasRemote:p,onClickWhenNoRemote:r},{clipboardWrite:as,toastSuccess:iI,toastError:rI,logEvent:nI});e.kind===`copied`?l({url:e.shareUrl,autoCopyFailed:!1}):e.kind===`clipboard-failed`&&l({url:e.shareUrl,autoCopyFailed:!0})}catch{Js.error(i({id:`u3YnKw`}))}s(!1)}},t[4]=i,t[5]=o,t[6]=p,t[7]=n,t[8]=r,t[9]=h):h=t[9];let g=h,v=c!==null,y;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{e||l(null)},t[10]=y):y=t[10];let b;t[11]!==i||t[12]!==n?.kind?(b=n?.kind===`folder`?i({id:`WR0y2O`}):i({id:`F4IYWe`}),t[11]=i,t[12]=n?.kind,t[13]=b):b=t[13];let x=o||m,S,C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(kd,{className:`size-3.5`,"aria-hidden":!0}),C=(0,Z.jsx)(X,{id:`Z8lGw6`}),t[14]=S,t[15]=C):(S=t[14],C=t[15]);let w;t[16]!==g||t[17]!==b||t[18]!==x?(w=(0,Z.jsx)(ye,{asChild:!0,children:(0,Z.jsxs)(Di,{variant:`ghost`,size:`sm`,"aria-label":b,onClick:g,disabled:x,className:`gap-1.5 text-muted-foreground px-1.5`,"data-testid":`share-button`,children:[S,C]})}),t[16]=g,t[17]=b,t[18]=x,t[19]=w):w=t[19];let T;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs`,children:(0,Z.jsx)(X,{id:`Z8lGw6`})}),t[20]=T):T=t[20];let E;t[21]===c?.autoCopyFailed?E=t[22]:(E=c?.autoCopyFailed?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Z.jsx)(X,{id:`ndeI89`})}):null,t[21]=c?.autoCopyFailed,t[22]=E);let D=c?.url??``,O;t[23]===i?O=t[24]:(O=i({id:`5-FeN2`}),t[23]=i,t[24]=O);let k;t[25]!==D||t[26]!==O?(k=(0,Z.jsx)(pl,{ref:u,readOnly:!0,value:D,onFocus:tI,onClick:eI,onContextMenu:$F,className:`select-all bg-muted font-mono text-xs text-muted-foreground`,"data-testid":`share-button-url`,"aria-label":O}),t[25]=D,t[26]=O,t[27]=k):k=t[27];let A=c?.url??``,j=c?.autoCopyFailed===!1,M;t[28]!==A||t[29]!==j?(M=(0,Z.jsx)(`div`,{className:`absolute inset-y-0 right-1 flex items-center`,children:(0,Z.jsx)(`div`,{className:`rounded-md bg-background/50 backdrop-blur-sm`,children:(0,Z.jsx)(H,{copyContent:A,clipboardWrite:as,initialCopied:j})})}),t[28]=A,t[29]=j,t[30]=M):M=t[30];let N;t[31]!==k||t[32]!==M?(N=(0,Z.jsxs)(`div`,{className:`relative`,children:[k,M]}),t[31]=k,t[32]=M,t[33]=N):N=t[33];let P;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsxs)(`a`,{href:YF,target:`_blank`,rel:`noopener noreferrer`,onClick:QF,onAuxClick:ZF,className:`mt-2 flex items-center gap-1.5 self-start text-xs text-muted-foreground transition-colors hover:text-primary`,children:[(0,Z.jsx)(_,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Z.jsx)(X,{id:`aByJ8j`})]}),t[34]=P):P=t[34];let F;t[35]!==E||t[36]!==N?(F=(0,Z.jsxs)(q,{align:`end`,className:`flex w-80 flex-col gap-2`,"data-testid":`share-button-popover`,children:[T,E,N,P]}),t[35]=E,t[36]=N,t[37]=F):F=t[37];let I;return t[38]!==w||t[39]!==F||t[40]!==v?(I=(0,Z.jsxs)(he,{open:v,onOpenChange:y,children:[w,F]}),t[38]=w,t[39]=F,t[40]=v,t[41]=I):I=t[41],I}function ZF(e){return ac(e,YF)}function QF(e){return ac(e,YF)}function $F(e){return e.currentTarget.select()}function eI(e){return e.currentTarget.select()}function tI(e){return e.currentTarget.select()}function nI(e){return console.log(e)}function rI(e){e!==`Link ready but could not copy to clipboard.`&&Js.error(e)}function iI(e){return Js.success(e)}function aI(e){let t=(0,$.c)(35),{onSignIn:n,onSetIdentity:r,onOpenSearch:i}=e,{_:a}=cn(),{activeDocName:o,activeTarget:s}=_t(),c=o?ti(o):null,{state:l,isDraggingRail:u}=Uj(),d=X_(),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=xl(`toggle-files-sidebar`),t[0]=f):f=t[0];let p=f,m=xl(`command-palette`),[h,g]=(0,Q.useState)(!1),_;bb0:{if(s?.kind===`folder`){let e;t[1]===s.folderPath?e=t[2]:(e=Ji(s.folderPath),t[1]=s.folderPath,t[2]=e),_=e;break bb0}if(o&&!c){let e;t[3]===o?e=t[4]:(e=ya(o),t[3]=o,t[4]=e),_=e;break bb0}if(!s&&!o){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=Ji(``),t[5]=e):e=t[5],_=e;break bb0}_=null}let v=_,y=typeof window<`u`&&window.okDesktop!=null,b=l===`collapsed`,x=y?``:void 0,S=y&&b&&`pl-[var(--ok-titlebar-reserve-left,1rem)]`,C=y&&!u&&`motion-safe:transition-[padding] motion-safe:duration-200 motion-safe:ease-linear`,w;t[6]!==S||t[7]!==C?(w=Ti(`flex h-12 shrink-0 items-center bg-muted/35 shadow-[inset_0_-1px_0_var(--border)]`,y&&`[-webkit-app-region:drag]`,S,C),t[6]=S,t[7]=C,t[8]=w):w=t[8];let T=!d&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(gc,{children:[(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Jj,{className:Ti(`-ml-1 shrink-0 text-muted-foreground`,y&&`[-webkit-app-region:no-drag]`)})}),(0,Z.jsx)(mc,{children:l===`expanded`?(0,Z.jsx)(X,{id:`ZxXhLY`,values:{sidebarShortcut:p}}):(0,Z.jsx)(X,{id:`Zz25kq`,values:{sidebarShortcut:p}})})]}),b&&i&&(0,Z.jsxs)(gc,{children:[(0,Z.jsx)(pc,{asChild:!0,children:(0,Z.jsx)(Di,{variant:`ghost`,size:`icon-sm`,onClick:i,"aria-label":a({id:`IN4UX8`,values:{searchShortcut:m}}),"data-telemetry-event":`ok.editor_header.search.click`,className:Ti(`shrink-0 text-muted-foreground`,y&&`[-webkit-app-region:no-drag]`),children:(0,Z.jsx)(nt,{"aria-hidden":`true`})})}),(0,Z.jsx)(mc,{children:(0,Z.jsx)(X,{id:`IN4UX8`,values:{searchShortcut:m}})})]}),(0,Z.jsx)(sa,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),(0,Z.jsx)(SF,{})]}),E;t[9]===T?E=t[10]:(E=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 px-3`,children:T}),t[9]=T,t[10]=E);let D;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(D=Ti(`flex shrink-0 items-center justify-end gap-2 px-3`,y&&`[&>*]:[-webkit-app-region:no-drag]`),t[11]=D):D=t[11];let O;t[12]!==h||t[13]!==g||t[14]!==v||t[15]!==d?(O=!d&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(XF,{input:v,onClickWhenNoRemote:()=>g(!0)}),(0,Z.jsx)(Ia,{open:h,onOpenChange:g})]}),t[12]=h,t[13]=g,t[14]=v,t[15]=d,t[16]=O):O=t[16];let k;t[17]!==r||t[18]!==n?(k=(0,Z.jsx)(ma,{onSignIn:n,onSetIdentity:r}),t[17]=r,t[18]=n,t[19]=k):k=t[19];let A,j,M;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(KN,{}),j=(0,Z.jsx)(sa,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),M=(0,Z.jsx)(Ep,{}),t[20]=A,t[21]=j,t[22]=M):(A=t[20],j=t[21],M=t[22]);let N;t[23]===d?N=t[24]:(N=!d&&(0,Z.jsx)(JF,{}),t[23]=d,t[24]=N);let P;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(KF,{}),t[25]=P):P=t[25];let F;t[26]!==O||t[27]!==k||t[28]!==N?(F=(0,Z.jsxs)(`div`,{className:D,children:[O,k,A,j,M,N,P]}),t[26]=O,t[27]=k,t[28]=N,t[29]=F):F=t[29];let I;return t[30]!==F||t[31]!==x||t[32]!==w||t[33]!==E?(I=(0,Z.jsxs)(`header`,{"data-electron-drag":x,className:w,children:[E,F]}),t[30]=F,t[31]=x,t[32]=w,t[33]=E,t[34]=I):I=t[34],I}var oI=`open-knowledge:terminal-launch`;function sI(e,t,n=typeof window>`u`?new EventTarget:window){n.dispatchEvent(new CustomEvent(oI,{detail:{prompt:e,cli:t}}))}function cI(e,t=typeof window>`u`?new EventTarget:window){let n=t=>{let n=t instanceof CustomEvent?t.detail:void 0;n&&typeof n.prompt==`string`&&e(n.prompt,n.cli)};return t.addEventListener(oI,n),()=>t.removeEventListener(oI,n)}function lI(e){let t=(0,$.c)(56),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onOpenSearch:r}=n,[i,a]=Av(),[o,s]=(0,Q.useState)(i),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(`auth`),[f,p]=(0,Q.useState)(qy[0].id),[m,h]=(0,Q.useState)(!1),g=typeof window<`u`?window.okDesktop??null:null,[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),x=(0,Q.useRef)(!1),[S,C]=(0,Q.useState)(null),w=(0,Q.useRef)(0),T=Gi(),{projectConfig:E,projectLocalConfig:D,projectLocalSynced:O,projectSynced:k}=bs(),{activeDocName:A}=_t(),j=T?.hasRemote,M=T?.pushPermission?.checkStatus,N;t[2]!==m||t[3]!==E||t[4]!==D||t[5]!==O||t[6]!==k||t[7]!==j||t[8]!==M?(N=Pv({autoSyncOnboardingDismissed:m,hasRemote:j,projectLocalSynced:O,projectSynced:k,projectLocalConfig:D,projectConfig:E,pushPermissionCheckStatus:M}),t[2]=m,t[3]=E,t[4]=D,t[5]=O,t[6]=k,t[7]=j,t[8]=M,t[9]=N):N=t[9];let P=N,F,I;t[10]===A?(F=t[11],I=t[12]):(F=()=>{let e=function(e){let t=e.detail;t&&A&&ql(A,{kind:`raw-mdx`,detail:t}),s(`source`)};return window.addEventListener(Sv,e),()=>window.removeEventListener(Sv,e)},I=[A],t[10]=A,t[11]=F,t[12]=I),(0,Q.useEffect)(F,I);let L,R;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{let e=window.okDesktop;if(e!=null)return e.onMenuAction(e=>{e===`toggle-terminal`?v(fI):e===`new-terminal`&&v(!0)})},R=[],t[13]=L,t[14]=R):(L=t[13],R=t[14]),(0,Q.useEffect)(L,R);let z,B;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{if(window.okDesktop!=null)return;let e=function(e){Sl(e,`toggle-terminal-panel`)&&(e.preventDefault(),v(dI))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},z=[],t[15]=z,t[16]=B):(z=t[15],B=t[16]),(0,Q.useEffect)(B,z);let V,H;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>cI((e,t)=>{v(!0),w.current+=1,C({prompt:e,cli:t,nonce:w.current})}),H=[],t[17]=V,t[18]=H):(V=t[17],H=t[18]),(0,Q.useEffect)(V,H);let U,W;t[19]===_?(U=t[20],W=t[21]):(U=()=>{_||C(null)},W=[_],t[19]=_,t[20]=U,t[21]=W),(0,Q.useEffect)(U,W);let G,K;t[22]!==y||t[23]!==_?(G=()=>{window.okDesktop!=null&&y&&window.okDesktop.editor.notifyViewMenuStateChanged({terminalVisible:_})},K=[_,y],t[22]=y,t[23]=_,t[24]=G,t[25]=K):(G=t[24],K=t[25]),(0,Q.useEffect)(G,K);let q,J;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(q=()=>{let e=window.okDesktop;if(e==null)return;if(typeof e.terminal?.getDockState!=`function`){b(!0);return}let t=!1;return e.terminal.getDockState().then(e=>{t||!e.visible||(x.current=!0,v(!0))}).catch(uI).finally(()=>{t||b(!0)}),()=>{t=!0}},J=[],t[26]=q,t[27]=J):(q=t[26],J=t[27]),(0,Q.useEffect)(q,J);let Y,ee;t[28]===_?(Y=t[29],ee=t[30]):(Y=()=>{if(window.okDesktop!=null){if(x.current){x.current=!1;return}_&&Ea()}},ee=[_],t[28]=_,t[29]=Y,t[30]=ee),(0,Q.useEffect)(Y,ee),jv(T?.pausedReason);let te;t[31]===a?te=t[32]:(te=function(e){s(e),a(e)},t[31]=a,t[32]=te);let ne=te,re,ie;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{d(`auth`),l(!0)},ie=()=>{d(`identity`),l(!0)},t[33]=re,t[34]=ie):(re=t[33],ie=t[34]);let ae;t[35]===r?ae=t[36]:(ae=(0,Z.jsx)(aI,{onSignIn:re,onSetIdentity:ie,onOpenSearch:r}),t[35]=r,t[36]=ae);let oe;t[37]!==f||t[38]!==o||t[39]!==ne||t[40]!==S||t[41]!==_?(oe=(0,Z.jsx)(yN,{editorMode:o,onModeChange:ne,activeTab:f,onActiveTabChange:p,terminalBridge:g,terminalVisible:_,onTerminalVisibleChange:v,terminalLaunch:S}),t[37]=f,t[38]=o,t[39]=ne,t[40]=S,t[41]=_,t[42]=oe):oe=t[42];let se=u===`identity`,ce;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>{l(!1)},t[43]=ce):ce=t[43];let le;t[44]!==c||t[45]!==se?(le=(0,Z.jsx)(ua,{open:c,onOpenChange:l,identityPrompt:se,onSuccess:ce}),t[44]=c,t[45]=se,t[46]=le):le=t[46];let ue;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>h(!0),t[47]=ue):ue=t[47];let de;t[48]===P?de=t[49]:(de=(0,Z.jsx)(Mv,{open:P,onResolved:ue}),t[48]=P,t[49]=de);let fe;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,Z.jsx)(yv,{}),t[50]=fe):fe=t[50];let pe;return t[51]!==ae||t[52]!==oe||t[53]!==le||t[54]!==de?(pe=(0,Z.jsxs)(Z.Fragment,{children:[ae,oe,le,de,fe]}),t[51]=ae,t[52]=oe,t[53]=le,t[54]=de,t[55]=pe):pe=t[55],pe}function uI(e){console.error(`[terminal] dock-state restore failed; staying hidden:`,e)}function dI(e){return!e}function fI(e){return!e}function pI(e){let t=Ao(fo(e));typeof window>`u`||window.location.hash!==t&&(window.location.hash=t)}function mI(){let e=(0,$.c)(11),{conflicts:t,loading:n,error:r}=qi();if(n)return null;if(r===`server`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`section`,{"data-testid":`conflicts-section`,"aria-label":`Conflicted files`,className:`border-b border-amber-200/60 bg-amber-50/40 px-2 py-2 dark:border-amber-900/40 dark:bg-amber-950/20`,children:(0,Z.jsxs)(`p`,{"data-testid":`conflicts-section-error`,className:`px-2 py-1.5 text-[12px] text-amber-700 dark:text-amber-400`,children:[(0,Z.jsx)(mo,{"aria-hidden":`true`,className:`mr-1.5 inline size-3`}),`Couldn't load conflicts — reload to retry.`]})}),e[0]=t):t=e[0],t}if(t.length===0)return null;let i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[11px] uppercase tracking-wider text-amber-700 dark:text-amber-400`,children:[(0,Z.jsx)(mo,{"aria-hidden":`true`,className:`size-3`}),`Conflicts`]}),e[1]=i):i=e[1];let a;e[2]===t.length?a=e[3]:(a=(0,Z.jsxs)(`header`,{className:`flex items-center justify-between px-2 pb-1.5`,children:[i,(0,Z.jsx)(`span`,{"data-testid":`conflicts-section-count`,className:`rounded-full bg-amber-500 px-1.5 py-0.5 font-mono text-[10px] font-medium leading-none text-white`,children:t.length})]}),e[2]=t.length,e[3]=a);let o;e[4]===t?o=e[5]:(o=t.map(hI),e[4]=t,e[5]=o);let s;e[6]===o?s=e[7]:(s=(0,Z.jsx)(`ul`,{className:`flex flex-col gap-px`,children:o}),e[6]=o,e[7]=s);let c;return e[8]!==a||e[9]!==s?(c=(0,Z.jsxs)(`section`,{"data-testid":`conflicts-section`,"aria-label":`Conflicted files`,className:`border-b border-amber-200/60 bg-amber-50/40 px-2 py-2 dark:border-amber-900/40 dark:bg-amber-950/20`,children:[a,s]}),e[8]=a,e[9]=s,e[10]=c):c=e[10],c}function hI(e){return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(Di,{variant:`ghost`,size:`sm`,"data-testid":`conflicts-section-row`,"data-file":e.file,title:e.file,className:`h-7 w-full justify-start gap-1.5 px-2 font-normal text-[13px] text-amber-800 hover:bg-amber-100/60 hover:text-amber-900 dark:text-amber-300 dark:hover:bg-amber-900/30 dark:hover:text-amber-200`,onClick:()=>pI(e.file),children:[(0,Z.jsx)(mo,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.file})]})},e.file)}var gI=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
32
32
|
<symbol id="file-tree-icon-chevron" viewBox="0 0 16 16">
|