@p4code/cli 0.6.48 → 0.6.49

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.
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$a as i,Ia as a,Jr as o,Ku as s,Qa as c,Tn as l,Ua as u,Ur as d,Wa as ee,Xa as te,Ya as f,Za as p,_l as m,bn as ne,cu as h,ei as g,g as _,gl as re,hl as v,kt as y,ml as ie,nu as b,pu as x,ut as S,vt as C,x as w,xt as T,yt as E,yu as D,za as O,zl as ae}from"./previewAssetResource-Cp_rWZ2h.js";import{a as k,c as oe,i as A,n as j,o as M,r as N,s as se,t as ce}from"./toggle-group-CWqFUkb4.js";import{F as P,Lr as le,M as ue,N as de,P as fe,Q as pe,Rr as me,Sr as he,Ur as ge,Vr as _e,Wr as ve,Z as ye,_r as be,b as xe,cr as Se,dr as Ce,dt as we,fi as Te,fr as Ee,ft as De,hr as Oe,ht as ke,lr as Ae,lt as je,mt as Me,or as Ne,pi as Pe,pr as Fe,pt as Ie,sr as Le,ur as Re,ut as ze,v as Be,zr as Ve}from"./index-BuDjBLW6.js";import{a as He,n as Ue}from"./fileCommentAnnotations-DxX6PWkZ.js";var We=m(`pilcrow`,[[`path`,{d:`M13 4v16`,key:`8vvj80`}],[`path`,{d:`M17 4v16`,key:`7dpous`}],[`path`,{d:`M19 4H9.5a4.5 4.5 0 0 0 0 9H13`,key:`sh4n9v`}]]),F=e(n(),1);function Ge({threadRef:e,filePath:t,activeCwd:n,openInEditor:r,openFileSurface:i}){if(e){if(i){i(t);return}S.getState().openFile(e,t);return}r(n?_(t,n):t)}var I=r();function Ke(e,t){let n=(0,I.c)(4),r=Oe(e,t),i;return n[0]!==r.data||n[1]!==r.error||n[2]!==r.isPending?(i={data:r.data,error:r.error,isPending:r.isPending},n[0]=r.data,n[1]=r.error,n[2]=r.isPending,n[3]=i):i=n[3],i}var L=t(),qe=[];function Je(e){return(e.endSide??e.side)===`deletions`?`deletions`:`additions`}function R(e,t,n){let r=Je(t),i=e.findIndex(e=>e.side===r&&e.lineNumber===t.end);return i<0?[...e,{side:r,lineNumber:t.end,metadata:{entries:[n]}}]:e.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,n]}}:e)}function Ye(e){let t=(0,I.c)(50),{files:n,sectionId:r,sectionTitle:i,composerDraftTarget:a,options:s,viewerRef:c,className:l,renderHeaderPrefix:u}=e,ee=d(Qe),te=d(B),f;t[0]===a?f=t[1]:(f=e=>e.getComposerDraft(a)?.reviewComments??qe,t[0]=a,t[1]=f);let p=d(f),[m,ne]=(0,F.useState)(null),[h,_]=(0,F.useState)(null),re;t[2]===n?re=t[3]:(re=new Map(n.map(Ze)),t[2]=n,t[3]=re);let v=re,y;if(t[4]!==h||t[5]!==n||t[6]!==p||t[7]!==r){let e;t[9]!==h||t[10]!==p||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=p.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=g(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),s=h?.fileKey===i?[...o,h.annotation]:o;return{id:i,type:`diff`,fileDiff:t,annotations:s,collapsed:a,version:ze(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=h,t[10]=p,t[11]=r,t[12]=e):e=t[12],y=n.map(e),t[4]=h,t[5]=n,t[6]=p,t[7]=r,t[8]=y}else y=t[8];let ie=y,b;t[13]!==a||t[14]!==h?.annotation||t[15]!==te?(b=e=>{ne(null),h?.annotation.metadata.entries.some(t=>t.id===e)?_(null):te(a,e)},t[13]=a,t[14]=h?.annotation,t[15]=te,t[16]=b):b=t[16];let x=b,S;t[17]!==ee||t[18]!==a||t[19]!==h||t[20]!==v||t[21]!==r||t[22]!==i?(S=(e,t)=>{let n=h?.annotation.metadata.entries.find(t=>t.id===e),s=h?v.get(h.fileKey):void 0;if(!n||!s)return;let c=o({id:n.id,sectionId:r,sectionTitle:i,filePath:s.filePath,fileDiff:s.fileDiff,range:n.range,text:t});c&&ee(a,c),ne(null),_(null)},t[17]=ee,t[18]=a,t[19]=h,t[20]=v,t[21]=r,t[22]=i,t[23]=S):S=t[23];let C=S,w;t[24]!==v||t[25]!==r||t[26]!==i?(w=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=v.get(n.id);if(!a)return;let s=Ue(),c=o({id:s,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});c&&_({fileKey:n.id,annotation:{side:Je(e),lineNumber:e.end,metadata:{entries:[{id:s,kind:`draft`,range:e,rangeLabel:c.rangeLabel,text:``}]}}})},t[24]=v,t[25]=r,t[26]=i,t[27]=w):w=t[27];let T=w,E=h!==null,D;t[28]===c?D=t[29]:(D=c?{ref:c}:{},t[28]=c,t[29]=D);let O;t[30]===l?O=t[31]:(O=l?{className:l}:{},t[30]=l,t[31]=O);let ae=!E,oe=!E,A;t[32]!==T||t[33]!==s||t[34]!==oe||t[35]!==ae?(A={...s,enableGutterUtility:ae,enableLineSelection:oe,onLineSelectionEnd:T},t[32]=T,t[33]=s,t[34]=oe,t[35]=ae,t[36]=A):A=t[36];let j;t[37]===u?j=t[38]:(j=e=>e.type===`diff`?u(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=u,t[38]=j);let M;t[39]!==x||t[40]!==C?(M=e=>(0,L.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,L.jsx)(He,{kind:e.kind,rangeLabel:e.rangeLabel,text:e.text,onCancel:()=>x(e.id),onComment:t=>C(e.id,t),onDelete:()=>x(e.id)},e.id))}),t[39]=x,t[40]=C,t[41]=M):M=t[41];let N;return t[42]!==ie||t[43]!==m||t[44]!==A||t[45]!==j||t[46]!==M||t[47]!==D||t[48]!==O?(N=(0,L.jsx)(k,{...D,...O,items:ie,selectedLines:m,onSelectedLinesChange:ne,options:A,renderHeaderPrefix:j,renderAnnotation:M}),t[42]=ie,t[43]=m,t[44]=A,t[45]=j,t[46]=M,t[47]=D,t[48]=O,t[49]=N):N=t[49],N}function z(e){return e.metadata.entries.map(Xe)}function Xe(e){return`${e.id}:${e.rangeLabel}:${e.text}`}function Ze(e){return[e.fileKey,e]}function B(e){return e.removeReviewComment}function Qe(e){return e.addReviewComment}function $e(e){return{diffPreview:b(e,{label:`environment-data:review:diff-preview`,tag:s.reviewGetDiffPreview,staleTimeMs:5e3})}}var et=$e(l);function V(e){return e.remoteName&&e.name.startsWith(`${e.remoteName}/`)?e.name.slice(e.remoteName.length+1):e.name}function tt(e,t){let n=new Set(t),r=e.map(e=>{let r=t.filter(t=>n.has(t)&&V(t)===e.name),i=r.find(e=>e.remoteName===`origin`)??r[0]??null;return i&&n.delete(i),{id:`local:${e.name}`,label:e.name,local:e,remote:i}}),i=t.filter(e=>n.has(e)).map(e=>({id:`remote:${e.name}`,label:e.name,local:null,remote:e}));return[...r,...i]}function nt(e,t){let n=t.trim().toLocaleLowerCase();return n.length===0?e:e.filter(e=>e.label.toLocaleLowerCase().includes(n)||e.local?.name.toLocaleLowerCase().includes(n)===!0||e.remote?.name.toLocaleLowerCase().includes(n)===!0)}var H=`__automatic_base_ref__`,rt=new Set,it=`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$a as i,Ia as a,Jr as o,Ku as s,Qa as c,Tn as l,Ua as u,Ur as d,Wa as ee,Xa as te,Ya as f,Za as p,_l as m,bn as ne,cu as h,ei as g,g as _,gl as re,hl as v,kt as y,ml as ie,nu as b,pu as x,ut as S,vt as C,x as w,xt as T,yt as E,yu as D,za as O,zl as ae}from"./previewAssetResource-BMf_t-Oa.js";import{a as k,c as oe,i as A,n as j,o as M,r as N,s as se,t as ce}from"./toggle-group-D7q15ngh.js";import{F as P,Lr as le,M as ue,N as de,P as fe,Q as pe,Rr as me,Sr as he,Ur as ge,Vr as _e,Wr as ve,Z as ye,_r as be,b as xe,cr as Se,dr as Ce,dt as we,fi as Te,fr as Ee,ft as De,hr as Oe,ht as ke,lr as Ae,lt as je,mt as Me,or as Ne,pi as Pe,pr as Fe,pt as Ie,sr as Le,ur as Re,ut as ze,v as Be,zr as Ve}from"./index-BSuuYg8z.js";import{a as He,n as Ue}from"./fileCommentAnnotations-ByKdy50L.js";var We=m(`pilcrow`,[[`path`,{d:`M13 4v16`,key:`8vvj80`}],[`path`,{d:`M17 4v16`,key:`7dpous`}],[`path`,{d:`M19 4H9.5a4.5 4.5 0 0 0 0 9H13`,key:`sh4n9v`}]]),F=e(n(),1);function Ge({threadRef:e,filePath:t,activeCwd:n,openInEditor:r,openFileSurface:i}){if(e){if(i){i(t);return}S.getState().openFile(e,t);return}r(n?_(t,n):t)}var I=r();function Ke(e,t){let n=(0,I.c)(4),r=Oe(e,t),i;return n[0]!==r.data||n[1]!==r.error||n[2]!==r.isPending?(i={data:r.data,error:r.error,isPending:r.isPending},n[0]=r.data,n[1]=r.error,n[2]=r.isPending,n[3]=i):i=n[3],i}var L=t(),qe=[];function Je(e){return(e.endSide??e.side)===`deletions`?`deletions`:`additions`}function R(e,t,n){let r=Je(t),i=e.findIndex(e=>e.side===r&&e.lineNumber===t.end);return i<0?[...e,{side:r,lineNumber:t.end,metadata:{entries:[n]}}]:e.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,n]}}:e)}function Ye(e){let t=(0,I.c)(50),{files:n,sectionId:r,sectionTitle:i,composerDraftTarget:a,options:s,viewerRef:c,className:l,renderHeaderPrefix:u}=e,ee=d(Qe),te=d(B),f;t[0]===a?f=t[1]:(f=e=>e.getComposerDraft(a)?.reviewComments??qe,t[0]=a,t[1]=f);let p=d(f),[m,ne]=(0,F.useState)(null),[h,_]=(0,F.useState)(null),re;t[2]===n?re=t[3]:(re=new Map(n.map(Ze)),t[2]=n,t[3]=re);let v=re,y;if(t[4]!==h||t[5]!==n||t[6]!==p||t[7]!==r){let e;t[9]!==h||t[10]!==p||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=p.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=g(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),s=h?.fileKey===i?[...o,h.annotation]:o;return{id:i,type:`diff`,fileDiff:t,annotations:s,collapsed:a,version:ze(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=h,t[10]=p,t[11]=r,t[12]=e):e=t[12],y=n.map(e),t[4]=h,t[5]=n,t[6]=p,t[7]=r,t[8]=y}else y=t[8];let ie=y,b;t[13]!==a||t[14]!==h?.annotation||t[15]!==te?(b=e=>{ne(null),h?.annotation.metadata.entries.some(t=>t.id===e)?_(null):te(a,e)},t[13]=a,t[14]=h?.annotation,t[15]=te,t[16]=b):b=t[16];let x=b,S;t[17]!==ee||t[18]!==a||t[19]!==h||t[20]!==v||t[21]!==r||t[22]!==i?(S=(e,t)=>{let n=h?.annotation.metadata.entries.find(t=>t.id===e),s=h?v.get(h.fileKey):void 0;if(!n||!s)return;let c=o({id:n.id,sectionId:r,sectionTitle:i,filePath:s.filePath,fileDiff:s.fileDiff,range:n.range,text:t});c&&ee(a,c),ne(null),_(null)},t[17]=ee,t[18]=a,t[19]=h,t[20]=v,t[21]=r,t[22]=i,t[23]=S):S=t[23];let C=S,w;t[24]!==v||t[25]!==r||t[26]!==i?(w=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=v.get(n.id);if(!a)return;let s=Ue(),c=o({id:s,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});c&&_({fileKey:n.id,annotation:{side:Je(e),lineNumber:e.end,metadata:{entries:[{id:s,kind:`draft`,range:e,rangeLabel:c.rangeLabel,text:``}]}}})},t[24]=v,t[25]=r,t[26]=i,t[27]=w):w=t[27];let T=w,E=h!==null,D;t[28]===c?D=t[29]:(D=c?{ref:c}:{},t[28]=c,t[29]=D);let O;t[30]===l?O=t[31]:(O=l?{className:l}:{},t[30]=l,t[31]=O);let ae=!E,oe=!E,A;t[32]!==T||t[33]!==s||t[34]!==oe||t[35]!==ae?(A={...s,enableGutterUtility:ae,enableLineSelection:oe,onLineSelectionEnd:T},t[32]=T,t[33]=s,t[34]=oe,t[35]=ae,t[36]=A):A=t[36];let j;t[37]===u?j=t[38]:(j=e=>e.type===`diff`?u(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=u,t[38]=j);let M;t[39]!==x||t[40]!==C?(M=e=>(0,L.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,L.jsx)(He,{kind:e.kind,rangeLabel:e.rangeLabel,text:e.text,onCancel:()=>x(e.id),onComment:t=>C(e.id,t),onDelete:()=>x(e.id)},e.id))}),t[39]=x,t[40]=C,t[41]=M):M=t[41];let N;return t[42]!==ie||t[43]!==m||t[44]!==A||t[45]!==j||t[46]!==M||t[47]!==D||t[48]!==O?(N=(0,L.jsx)(k,{...D,...O,items:ie,selectedLines:m,onSelectedLinesChange:ne,options:A,renderHeaderPrefix:j,renderAnnotation:M}),t[42]=ie,t[43]=m,t[44]=A,t[45]=j,t[46]=M,t[47]=D,t[48]=O,t[49]=N):N=t[49],N}function z(e){return e.metadata.entries.map(Xe)}function Xe(e){return`${e.id}:${e.rangeLabel}:${e.text}`}function Ze(e){return[e.fileKey,e]}function B(e){return e.removeReviewComment}function Qe(e){return e.addReviewComment}function $e(e){return{diffPreview:b(e,{label:`environment-data:review:diff-preview`,tag:s.reviewGetDiffPreview,staleTimeMs:5e3})}}var et=$e(l);function V(e){return e.remoteName&&e.name.startsWith(`${e.remoteName}/`)?e.name.slice(e.remoteName.length+1):e.name}function tt(e,t){let n=new Set(t),r=e.map(e=>{let r=t.filter(t=>n.has(t)&&V(t)===e.name),i=r.find(e=>e.remoteName===`origin`)??r[0]??null;return i&&n.delete(i),{id:`local:${e.name}`,label:e.name,local:e,remote:i}}),i=t.filter(e=>n.has(e)).map(e=>({id:`remote:${e.name}`,label:e.name,local:null,remote:e}));return[...r,...i]}function nt(e,t){let n=t.trim().toLocaleLowerCase();return n.length===0?e:e.filter(e=>e.label.toLocaleLowerCase().includes(n)||e.local?.name.toLocaleLowerCase().includes(n)===!0||e.remote?.name.toLocaleLowerCase().includes(n)===!0)}var H=`__automatic_base_ref__`,rt=new Set,it=`
2
2
  [data-diffs-header],
3
3
  [data-diff],
4
4
  [data-file],
@@ -95,4 +95,4 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}f
95
95
  text-decoration-color: currentColor;
96
96
  }
97
97
  `;function U({mode:e=`inline`,composerDraftTarget:t,initialGitScope:n,threadRef:r}){let{resolvedTheme:o}=w(),s=_e(),[l]=(0,F.useState)(n),[d,m]=(0,F.useState)(`stacked`),[g,_]=(0,F.useState)(s.wordWrap),[b,S]=(0,F.useState)(s.diffIgnoreWhitespace),[k,xe]=(0,F.useState)(``),[Oe,ze]=(0,F.useState)(()=>({scopeKey:null,fileKeys:rt})),He=(0,F.useRef)(null),Ue=r.threadId,I=Ve(r),qe=I?.projectId??null,Je=me(I&&qe?{environmentId:I.environmentId,projectId:qe}:null),R=I?.worktreePath??Je?.workspaceRoot,z=ae(ne.configValueAtom(I?.environmentId??null)),Xe=be(I?.environmentId??null,z?.availableEditors??[]),Ze=y(I!=null&&R!=null?le.status({environmentId:I.environmentId,input:{cwd:R}}):null),B=P(e=>fe(e.byThreadKey,r,l===`unstaged`)),Qe=Ze.data?.isRepo??!0,{turnDiffSummaries:$e,inferredCheckpointTurnCountByTurnId:V}=de(I),U=(0,F.useMemo)(()=>[...$e].toSorted((e,t)=>{let n=e.checkpointTurnCount??V[e.turnId]??0,r=t.checkpointTurnCount??V[t.turnId]??0;return n===r?t.completedAt.localeCompare(e.completedAt):r-n}),[V,$e]);(0,F.useEffect)(()=>{B.kind===`turn`&&P.getState().reconcileTurnSelection(r,U.map(e=>e.turnId))},[B,U,r]);let W=B.kind===`turn`?B.turnId:null,G=B.kind===`unstaged`?`unstaged`:`branch`,K=B.kind===`branch`?B.baseRef:null,at=B.kind===`turn`?B.filePath:null,ot=B.kind===`turn`?B.revealRequestId:0,q=W===null?void 0:U.find(e=>e.turnId===W)??U[0],J=q&&(q.checkpointTurnCount??V[q.turnId]),st=U[0],ct=W===null?G===`unstaged`?`Working tree`:`Branch changes`:q?.turnId===st?.turnId?`Latest turn`:`Turn ${J??`?`}`,lt=q?`turn:${q.turnId}`:G,Y=`${r.environmentId}:${r.threadId}:${lt}`,ut=Oe.scopeKey===Y?Oe.fileKeys:rt,dt=q?`Turn ${J??`?`}`:G===`unstaged`?`Working tree`:`Branch changes`,ft=(0,F.useMemo)(()=>typeof J==`number`?{fromTurnCount:Math.max(0,J-1),toTurnCount:J}:null,[J]),pt=Ke({environmentId:I?.environmentId??null,threadId:Ue,fromTurnCount:ft?.fromTurnCount??null,toTurnCount:ft?.toTurnCount??null,ignoreWhitespace:b,cacheScope:q?`turn:${q.turnId}`:null},{enabled:Qe&&q!==void 0}),mt=y(W===null&&I&&R?et.diffPreview({environmentId:I.environmentId,input:{cwd:R,...K?{baseRef:K}:{},ignoreWhitespace:b}}):null),ht=W===null&&mt.error?.includes(`configured workspace root`)===!0&&z?.cwd!==void 0&&z.cwd!==R,gt=y(ht&&I&&z?et.diffPreview({environmentId:I.environmentId,input:{cwd:z.cwd,...K?{baseRef:K}:{},ignoreWhitespace:b}}):null),X=ht?gt:mt,Z=X.data?.sources.find(e=>e.kind===(G===`unstaged`?`working-tree`:`branch-range`)),_t=y(W===null&&G===`branch`&&I&&X.data?.cwd?le.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`local`,...k.trim().length>0?{query:k.trim()}:{},limit:100}}):null),vt=y(W===null&&G===`branch`&&I&&X.data?.cwd?le.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`remote`,...k.trim().length>0?{query:k.trim()}:{},limit:100}}):null),yt=tt(_t.data?.refs.filter(e=>e.name!==Z?.headRef)??[],vt.data?.refs??[]),bt=nt(yt,k),xt=e=>K&&K===e.remote?.name?K:e.local?.name??e.remote?.name??e.id,St=[H,...yt.map(xt)],Ct=[...k.trim().length===0?[H]:[],...bt.map(xt)],wt=Z?.diff,Tt=q?pt.data?.diff:wt,Et=!q&&Z?.truncated===!0,Dt=q?pt.isPending:X.isPending,Ot=q?pt.error:X.error,kt=typeof Tt==`string`&&Tt.trim().length===0,Q=(0,F.useMemo)(()=>Ie(Tt,`diff-panel:${o}`,{compactPartialHunkOffsets:W===null}),[o,Tt,W]),At=(0,F.useMemo)(()=>!Q||Q.kind!==`files`?[]:Q.files.toSorted((e,t)=>ke(e).localeCompare(ke(t),void 0,{numeric:!0,sensitivity:`base`})),[Q]),$=(0,F.useMemo)(()=>At.map(e=>{let t=je(e);return{fileDiff:e,filePath:ke(e),fileKey:t,collapsed:ut.has(t)}}),[ut,At]),jt=(0,F.useMemo)(()=>$.map(e=>e.fileKey),[$]),Mt=N(jt,ut),Nt=(0,F.useMemo)(()=>De(At),[At]);(0,F.useEffect)(()=>{if(!at)return;let e=$.find(e=>e.filePath===at);e&&He.current?.scrollTo({type:`item`,id:e.fileKey,align:`start`})},[$,at,ot]);let Pt=ue({threadRef:r,workspaceRoot:R??null}),Ft=(0,F.useCallback)(e=>{Ge({threadRef:r,filePath:e,activeCwd:R,openFileSurface:Pt,openInEditor:e=>{(async()=>{let t=await Xe(e);t._tag===`Failure`&&!h(t)&&console.warn(`Failed to open diff file in editor.`,{operation:`open-diff-file`,environmentId:r.environmentId,threadId:r.threadId,...D(x(t))})})()}})},[R,Pt,Xe,r]),It=(0,F.useCallback)(e=>{ze(t=>{let n=new Set(t.scopeKey===Y?t.fileKeys:[]);return n.has(e)?n.delete(e):n.add(e),{scopeKey:Y,fileKeys:n}})},[Y]),Lt=(0,F.useCallback)(()=>{ze(e=>{let t=e.scopeKey===Y?e.fileKeys:rt;return{scopeKey:Y,fileKeys:A(jt,t)}})},[Y,jt]),Rt=e=>{P.getState().selectTurn(r,e)},zt=e=>{P.getState().selectGitScope(r,e)},Bt=e=>{P.getState().selectBranchBaseRef(r,e)};return(0,L.jsx)(pe,{mode:e,header:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3 [-webkit-app-region:no-drag]`,children:[(0,L.jsxs)(O,{children:[(0,L.jsxs)(c,{className:`inline-flex h-6 max-w-full items-center gap-1 rounded-md bg-muted/70 px-2 text-xs font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Diff scope: ${ct}`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:ct}),(0,L.jsx)(v,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,L.jsxs)(ee,{align:`start`,className:`w-60`,children:[(0,L.jsx)(u,{className:W===null&&G===`unstaged`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`unstaged`),children:(0,L.jsx)(`span`,{children:`Working tree`})}),(0,L.jsx)(u,{className:W===null&&G===`branch`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`branch`),children:(0,L.jsx)(`span`,{children:`Branch changes`})}),(0,L.jsx)(u,{className:W!==null&&q?.turnId===st?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>{st&&Rt(st.turnId)},children:(0,L.jsx)(`span`,{children:`Latest turn`})}),(0,L.jsxs)(f,{children:[(0,L.jsx)(p,{children:`Turn`}),(0,L.jsx)(te,{className:`w-64`,children:U.map(e=>{let t=e.checkpointTurnCount??V[e.turnId]??`?`;return(0,L.jsxs)(u,{className:e.turnId===q?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>Rt(e.turnId),children:[(0,L.jsxs)(`span`,{children:[`Turn `,t]}),(0,L.jsx)(`span`,{className:`ml-auto text-xs tabular-nums text-muted-foreground`,children:he(e.completedAt,s.timestampFormat)})]},e.turnId)})})]})]})]}),W===null&&G===`branch`&&Z?.baseRef&&(0,L.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-2 overflow-hidden text-xs text-muted-foreground`,title:`${Z.headRef??`HEAD`} → ${Z.baseRef}`,"aria-label":`Comparing ${Z.headRef??`HEAD`} against ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 max-w-48 truncate`,children:Z.headRef??`HEAD`}),(0,L.jsx)(Pe,{className:`size-3.5 shrink-0 opacity-70`}),(0,L.jsxs)(Ne,{items:St,filteredItems:Ct,value:K??H,onOpenChange:e=>{e||xe(``)},onValueChange:e=>{e&&Bt(e===H?null:e)},children:[(0,L.jsxs)(Ee,{className:`inline-flex min-w-0 max-w-48 items-center gap-1 overflow-hidden rounded-md px-1.5 py-1 outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Change comparison target. Currently ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:Z.baseRef}),(0,L.jsx)(v,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,L.jsxs)(Ce,{align:`start`,className:`w-72 min-w-0 max-w-[calc(100vw-1rem)] overflow-hidden [&>[data-slot=combobox-popup]]:min-w-0 [&>[data-slot=combobox-popup]]:overflow-hidden`,children:[(0,L.jsx)(`div`,{className:`min-w-0 shrink-0 px-3 pt-2.5`,children:(0,L.jsxs)(`div`,{className:`relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring`,children:[(0,L.jsx)(ve,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55`}),(0,L.jsx)(Se,{className:`[&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5`,inputClassName:`rounded-none bg-transparent text-sm`,placeholder:`Search refs...`,showTrigger:!1,size:`sm`,unstyled:!0,value:k,onChange:e=>xe(e.target.value)})]})}),(0,L.jsxs)(`div`,{className:`grid shrink-0 grid-cols-[1rem_minmax(0,1fr)] items-center gap-2 border-b border-border/70 ps-3 pe-6.5 pt-2 pb-1.5 font-medium text-[10px] text-muted-foreground uppercase tracking-wide`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center`,children:[(0,L.jsx)(`span`,{children:`Branch`}),(0,L.jsx)(`span`,{className:`text-right`,children:`Remote`})]})]}),(0,L.jsx)(Le,{children:`No matching refs.`}),(0,L.jsxs)(Re,{className:`max-h-64 min-w-0 overflow-x-hidden`,children:[(0,L.jsx)(Ae,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:H,children:(0,L.jsx)(`span`,{className:`block min-w-0 truncate`,children:`Automatic`})}),yt.map(e=>{let t=xt(e),n=e.local!==null&&e.remote!==null,r=e.remote?.name===t;return(0,L.jsx)(Ae,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:t,children:(0,L.jsxs)(`div`,{className:`grid w-full min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center overflow-hidden`,children:[(0,L.jsx)(`span`,{className:`block min-w-0 truncate pe-2`,children:e.label}),n?(0,L.jsx)(`div`,{className:`flex justify-end`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,L.jsx)(Fe,{"aria-label":`Use remote version of ${e.label}`,checked:r,className:`[--thumb-size:--spacing(3)]`,onCheckedChange:t=>{let n=t?e.remote?.name:e.local?.name;n&&Bt(n)}})}):e.remote?(0,L.jsx)(`span`,{className:`flex justify-end text-muted-foreground`,title:`Remote only`,children:(0,L.jsx)(re,{"aria-hidden":`true`,className:`size-3`})}):null]})},e.id)})]})]})]})]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[$.length>0&&(0,L.jsx)(Be,{additions:Nt.additions,deletions:Nt.deletions,className:`mr-1 text-[11px]`,layout:`inline`}),$.length>0&&(0,L.jsxs)(C,{children:[(0,L.jsx)(T,{render:(0,L.jsx)(a,{type:`button`,size:`icon-xs`,variant:`outline`,"aria-label":Mt?`Expand all files`:`Collapse all files`,onClick:Lt}),children:Mt?(0,L.jsx)(Te,{className:`size-3`}):(0,L.jsx)(oe,{className:`size-3`})}),(0,L.jsx)(E,{side:`top`,children:Mt?`Expand all files`:`Collapse all files`})]}),(0,L.jsxs)(j,{className:`shrink-0`,variant:`outline`,size:`xs`,value:[d],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&m(t)},children:[(0,L.jsx)(ce,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,L.jsx)(M,{className:`size-3`})}),(0,L.jsx)(ce,{"aria-label":`Split diff view`,value:`split`,children:(0,L.jsx)(se,{className:`size-3`})})]}),(0,L.jsxs)(C,{children:[(0,L.jsx)(T,{render:(0,L.jsx)(ce,{"aria-label":g?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`outline`,size:`xs`,pressed:g,onPressedChange:e=>{_(!!e)}}),children:(0,L.jsx)(ge,{className:`size-3`})}),(0,L.jsx)(E,{side:`top`,children:g?`Disable line wrapping`:`Enable line wrapping`})]}),(0,L.jsxs)(C,{children:[(0,L.jsx)(T,{render:(0,L.jsx)(ce,{"aria-label":b?`Show whitespace changes`:`Hide whitespace changes`,variant:`outline`,size:`xs`,pressed:b,onPressedChange:e=>{S(!!e)}}),children:(0,L.jsx)(We,{className:`size-3`})}),(0,L.jsx)(E,{side:`top`,children:b?`Show whitespace changes`:`Hide whitespace changes`})]})]})]}),children:I?Qe?W!==null&&U.length===0?(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No completed turns yet.`}):(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(`div`,{className:`diff-panel-viewport flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[Et&&(0,L.jsx)(`p`,{className:`shrink-0 border-b border-border/70 bg-muted/40 px-3 py-1.5 text-[11px] text-muted-foreground`,children:`This diff was truncated because it exceeded the preview limit. The changes shown are incomplete.`}),Ot&&!Q&&(0,L.jsx)(`div`,{className:`px-3`,children:(0,L.jsx)(`p`,{className:`mb-2 text-[11px] text-red-500/80`,children:Ot})}),Q?Q.kind===`files`?(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,onClickCapture:e=>{let t=(e.nativeEvent.composedPath?.()??[]).find(e=>e instanceof HTMLElement&&e.hasAttribute(`data-title`))?.textContent?.trim();t&&Ft(t)},children:(0,L.jsx)(Ye,{viewerRef:He,className:`diff-render-surface h-full min-h-0 overflow-auto`,files:$,sectionId:lt,sectionTitle:dt,composerDraftTarget:t,renderHeaderPrefix:(e,t,n)=>{let r=ke(e);return(0,L.jsxs)(C,{children:[(0,L.jsx)(T,{render:(0,L.jsx)(`button`,{type:`button`,className:i(`inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm border-0 bg-transparent p-0 transition-colors hover:bg-foreground/10 focus-visible:outline-hidden`,we(e)),"aria-label":n?`Expand ${r}`:`Collapse ${r}`,"aria-expanded":!n,onClick:e=>{e.stopPropagation(),It(t)}}),children:n?(0,L.jsx)(ie,{className:`size-4`}):(0,L.jsx)(v,{className:`size-4`})}),(0,L.jsx)(E,{side:`top`,children:n?`Expand diff`:`Collapse diff`})]})},options:{diffStyle:d===`split`?`split`:`unified`,lineDiffType:`none`,overflow:g?`wrap`:`scroll`,theme:Me(o),themeType:o,unsafeCSS:it,stickyHeaders:!0,itemMetrics:{diffHeaderHeight:33},layout:{paddingTop:0,paddingBottom:8,gap:8}}},Y??lt)}):(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:Q.reason}),(0,L.jsx)(`pre`,{className:i(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,g?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:Q.text})]})}):Dt?(0,L.jsx)(ye,{label:q?`Loading checkpoint diff...`:G===`unstaged`?`Loading working tree diff...`:`Loading branch diff...`}):(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center px-3 py-2 text-xs text-muted-foreground/70`,children:(0,L.jsx)(`p`,{children:kt?`No net changes in this selection.`:`No patch available for this selection.`})})]})}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Turn diffs are unavailable because this project is not a git repository.`}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Select a thread to inspect turn diffs.`})})}export{xe as DiffWorkerPoolProvider,U as default};
98
- //# sourceMappingURL=DiffPanel-CBLL8DDt.js.map
98
+ //# sourceMappingURL=DiffPanel-QET7ky-v.js.map
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$ as i,$a as a,Cl as o,Dt as s,Ia as c,Nt as l,St as u,Ur as d,Vp as f,W as p,Yr as m,_l as h,_t as g,cl as _,cu as v,g as y,ht as b,jt as x,ml as S,mt as C,n as w,nt as T,o as E,pu as D,vt as O,wl as k,wt as A,x as ee,xt as j,yt as M}from"./previewAssetResource-Cp_rWZ2h.js";import{n as N,r as P,t as te}from"./renderFileChildren-Di43LmWA.js";import{A as ne,An as F,Br as re,C as ie,Ct as ae,D as oe,En as se,Fr as ce,Ir as le,Jn as ue,Jt as de,Kn as fe,Nr as I,O as pe,Or as me,Pr as L,Qt as he,Rn as ge,S as _e,St as ve,Vn as ye,Vr as be,Wr as xe,Yt as Se,Zt as R,_ as Ce,at as we,dn as Te,ei as Ee,en as De,er as Oe,f as ke,fn as Ae,g as je,gr as Me,h as Ne,ir as Pe,k as Fe,kn as Ie,li as Le,m as Re,mr as ze,mt as Be,nr as Ve,oi as He,ot as Ue,p as We,qn as Ge,qr as Ke,ri as qe,rr as Je,rt as Ye,si as Xe,st as Ze,tr as Qe,ui as $e,vn as et,w as tt,x as nt}from"./index-BuDjBLW6.js";import{a as rt,i as it,n as at,r as z,t as B}from"./fileCommentAnnotations-DxX6PWkZ.js";var ot=h(`file-question-mark`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),st=h(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),ct=`file-tree-container`,lt=`data-file-tree-style`,ut=`data-file-tree-unsafe-css`,dt=`data-file-tree-scrollbar-measure`,ft=`data-file-tree-scrollbar-gutter-measured`,pt=`--trees-scrollbar-gutter-measured`,mt=`header`,ht=`context-menu`,gt=`context-menu-trigger`,_t=5,vt=1<<_t,yt=vt*4;function bt(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function xt(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function St(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let t=e[r];t!=null&&n.set(t.nameId,r)}return t.childIdByNameId=n,n}function Ct(e){if(e.childPositionById!=null)return e.childPositionById;let t=new Map;for(let n=0;n<e.childIds.length;n++){let r=e.childIds[n];r!=null&&t.set(r,n)}return e.childPositionById=t,t}function wt(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function Tt(e,t){if(e.childPositionById!=null)for(let n=t;n<e.childIds.length;n++){let t=e.childIds[n];t!=null&&e.childPositionById.set(t,n)}}function Et(e,t){let n=0,r=0;for(let i of t.childIds){let t=e[i];t!=null&&(n+=t.subtreeNodeCount,r+=t.visibleSubtreeCount)}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,At(e,t)}function Dt(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=Ct(e).get(t);if(i===void 0)return;let a=i>>_t;e.childVisibleChunkSums[a]+=r}function Ot(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let i=n,a=0;for(let o of r){if(i<o){let r=jt(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=vt}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let r=0;r<t.childIds.length;r++){let a=t.childIds[r];if(a==null)continue;let o=e[a];if(o!=null){if(i<o.visibleSubtreeCount)return{childIndex:r,childVisibleIndex:n-i,localVisibleIndex:i};i-=o.visibleSubtreeCount}}throw Error(`Visible child index ${String(n)} is out of range`)}function kt(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>_t;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<_t}for(let i=a;i<n;i+=1){let n=t.childIds[i];if(n==null)continue;let a=e[n];a!=null&&(r+=a.visibleSubtreeCount)}return r}function At(e,t){if(t.childIds.length<yt){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/vt),r=new Int32Array(n);for(let n=0;n<t.childIds.length;n++){let i=t.childIds[n];if(i==null)continue;let a=e[i];a!=null&&(r[n>>_t]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function jt(e,t,n,r){let i=Math.min(t.childIds.length,n+vt),a=r;for(let r=n;r<i;r++){let n=t.childIds[r];if(n==null)continue;let i=e[n];if(i!=null){if(a<i.visibleSubtreeCount)return{childIndex:r,localVisibleIndex:a};a-=i.visibleSubtreeCount}}throw Error(`Visible child index ${String(r)} is out of range`)}var Mt=7,Nt=3,Pt=1<<Nt,Ft=4;function It(e,t,n=0){return e<<Ft|n<<Nt|t}function Lt(e){return e.depthAndFlags>>>Ft}function Rt(e){return(e.depthAndFlags&Pt)>>Nt}function V(e){return(e.depthAndFlags&Pt)!==0}function zt(e){return e.depthAndFlags&Mt}function Bt(e,t){return(zt(e)&t)!==0}function Vt(e,t){e.depthAndFlags|=t}function Ht(e,t){e.depthAndFlags=It(t,zt(e),Rt(e))}var Ut=Symbol(`benchmarkInstrumentation`);function Wt(e,t){return t==null||Object.defineProperty(e,Ut,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function Gt(e){return e==null?null:e[Ut]??null}function H(e,t,n){return e==null?n():e.measurePhase(t,n)}function Kt(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function qt(e){return e>=48&&e<=57}function Jt(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!qt(e.charCodeAt(r));)r+=1;if(r>=e.length)break;r>n&&t.push(e.slice(n,r));let i=0;for(;r<e.length&&qt(e.charCodeAt(r));)i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}return(n<e.length||t.length===0)&&t.push(e.slice(n)),t}function Yt(e){let t=e.toLowerCase();return{lowerValue:t,tokens:Jt(t)}}function Xt(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],i=t[r];if(n===i)continue;if(typeof n==`number`&&typeof i==`number`)return n<i?-1:1;let a=String(n),o=String(i);if(a!==o)return a<o?-1:1}return e.length===t.length?0:e.length<t.length?-1:1}function Zt(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==`string`&&typeof t.tokens[0]==`string`)return e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1;let n=Xt(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function Qt(e,t,n){let r=Zt(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function $t(e,t){return Qt(e,t,Yt)}function en(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function tn(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let n=e.segments[r],i=t.segments[r];if(n===i)continue;let a=en(e,r);return a===en(t,r)?$t(n,i):a===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function nn(e,t){return tn(e,t)}function rn(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=Yt(e);return n.set(e,r),r},i=Math.min(e.segments.length,t.segments.length);for(let n=0;n<i;n++){let i=e.segments[n],a=t.segments[n];if(i===a)continue;let o=en(e,n);return o===en(t,n)?Qt(i,a,r):o===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function an(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=Yt(r);return e.sortKeyById[t]=i,i}function on(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function sn(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let t=0;t<n;t++)e.charCodeAt(t)===47&&(r.push(e.slice(i,t)),i=t+1);return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function cn(e){let{hasTrailingSlash:t,segments:n}=sn(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function ln(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=sn(e);return{requiresDirectory:t,segments:n}}var un=``;function dn(){let e=new Map;return e.set(un,0),{idByValue:e,valueById:[un],sortKeyById:[Yt(un)]}}function fn(e,t){let n=e.idByValue.get(t);if(n!==void 0)return n;let r=e.valueById.length;return e.idByValue.set(t,r),e.valueById.push(t),r}function pn(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var mn=Symbol(`pathStorePreparedInputKind`);function hn(e,t){return e[mn]=t,e}function gn(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function _n(e,t,n){return n==="default"?nn(e,t):n(gn(e),gn(t))}function vn(){return{depthAndFlags:It(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function yn(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return r;return n}function bn(e){return e.isDirectory?e.segments.length:e.segments.length-1}function xn(e){return Array.isArray(e)&&e.every(e=>typeof e==`object`&&!!e&&typeof e.path==`string`&&Array.isArray(e.segments)&&typeof e.basename==`string`&&typeof e.isDirectory==`boolean`)}function Sn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Cn(e,t={}){return kn(e,t).map(e=>e.path)}function wn(e,t={}){let n=kn(e,t);return hn({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function Tn(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let t=e[r];if(t.length>0&&t.charCodeAt(t.length-1)===47){n=!0;break}}return hn({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function En(e){let t=e,n=t.preparedPaths;if(t[mn]===`prepared`&&n!=null)return n;if(!xn(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function Dn(e){let t=e;return t[mn]===`presorted`&&t.presortedPaths!=null||Sn(t.presortedPaths)?t.presortedPaths:null}function On(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function kn(e,t={}){let n=on(t),r=Gt(t);Kt(r,`workload.inputFiles`,e.length);let i=H(r,`store.preparePathEntries.parse`,()=>e.map(e=>cn(e)));return H(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>_n(e,t,n.sort))),i}var An=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[vn()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=dn();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=Gt(e),this.options=on(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let e=new Set,n=t.length;for(let r=0;r<n;r+=1){let n=t[r],i=n.length;e.add(i>0&&n.charCodeAt(i-1)===47?n.slice(0,i-1):n)}this.initialExpandedPathSet=e,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,bt())}appendPaths(e){return H(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>cn(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,H(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return H(this.instrumentation,`store.builder.appendPresortedPaths`,()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,a=this.segmentTable,o=a.idByValue,s=a.valueById,c=this.directoryStack,l=0,u=``,d=0;for(let t of e){if(n===t)throw Error(`Duplicate path: "${t}"`);let e=t.length>0&&t.charCodeAt(t.length-1)===47,a=e?t.length-1:t.length,f=0,p=0;if(n!=null)if(u.length>0&&t.length>u.length&&t.startsWith(u))f=d,p=u.length;else{let r=Math.min(a,n.length),i=!0;for(let e=0;e<r;e++){let r=t.charCodeAt(e);if(r!==n.charCodeAt(e)){i=!1;break}r===47&&(f++,p=e+1)}i&&e&&r===a&&n.length>a&&n.charCodeAt(a)===47&&(f++,p=a+1)}l=f,r=f;let m=p,h=t.indexOf(`/`,m);for(;h>=0&&h<a;){let e=c[l];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);r++;let n=t.slice(m,h),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n));let u=i.length;i.push({depthAndFlags:It(r,0,1),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(t.slice(0,h)),l++,c[l]=u,m=h+1,h=t.indexOf(`/`,m)}if(e){if(m<a){let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory parent for "${t}"`);r++;let n=t.slice(m,a),u=o.get(n);u===void 0&&(u=s.length,o.set(n,u),s.push(n));let d=i.length;i.push({depthAndFlags:It(r,0,1),nameId:u,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),l++,c[l]=d}let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory node for "${t}"`);this.promoteDirectoryToExplicit(e,t)}else{let e=c[l];if(e===void 0)throw Error(`Unable to resolve file parent for "${t}"`);let n=t.slice(m),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n)),i.push({depthAndFlags:It(r+1,0),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1})}m!==u.length&&(u=t.substring(0,m),d=r),n=t}c.length=l+1,n!=null&&(this.lastPreparedPath=cn(n)),this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,a=i.idByValue,o=i.valueById,s=this.directoryStack,c=0,l=``,u=0;for(let i of e){if(t===i)throw Error(`Duplicate path: "${i}"`);let e=i.length,d=0,f=0;if(t!=null)if(l.length>0&&i.length>l.length&&i.startsWith(l))d=u,f=l.length;else{let n=Math.min(e,t.length);for(let e=0;e<n;e++){let n=i.charCodeAt(e);if(n!==t.charCodeAt(e))break;n===47&&(d++,f=e+1)}}c=d,n=d;let p=f,m=i.indexOf(`/`,p);for(;m>=0;){let e=s[c];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);n++;let t=i.slice(p,m),l=a.get(t);l===void 0&&(l=o.length,a.set(t,l),o.push(t));let u=r.length;r.push({depthAndFlags:It(n,0,1),nameId:l,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(i.slice(0,m)),this.presortedDirectoryNodeIds.push(u),c++,s[c]=u,p=m+1,m=i.indexOf(`/`,p)}let h=s[c];if(h===void 0)throw Error(`Unable to resolve file parent for "${i}"`);let g=i.slice(p),_=a.get(g);_===void 0&&(_=o.length,a.set(g,_),o.push(g)),r.push({depthAndFlags:It(n+1,0),nameId:_,parentId:h,subtreeNodeCount:1,visibleSubtreeCount:1}),p!==l.length&&(l=i.substring(0,p),u=n),t=i}s.length=c+1,t!=null&&(this.lastPreparedPath=cn(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(H(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||H(this.instrumentation,`store.builder.computeSubtreeCounts`,()=>this.computeSubtreeCounts(0)),{directories:this.directories,nodes:this.nodes,options:this.options,rootId:0,segmentTable:this.segmentTable,presortedDirectoryNodeIds:this.presortedDirectoryNodeIds.length>0?this.presortedDirectoryNodeIds:null}}didMatchAllInitialExpandedPaths(){return this.createdDirectoriesAllExpanded&&this.initialExpandedPathSet!=null&&this.createdDirectoryCount===this.initialExpandedPathSet.size}appendPreparedPath(e,t){if(this.hasDeferredDirectoryIndexes&&=(this.buildDirectoryIndexes(),!1),this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t&&(this.options.sort==="default"?rn(this.lastPreparedPath,e,this.segmentSortKeyCache):_n(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=bn(e),i=n==null?0:bn(n),a=n==null?0:yn(n.segments,e.segments),o=Math.min(a,r,i);this.directoryStack.length=o+1;for(let n=o;n<r;n++){let r=this.directoryStack[this.directoryStack.length-1];if(r===void 0)throw Error(`Directory stack underflow while building the path store`);let i=t?this.getOrCreateDirectoryChild(r,e.segments[n]):this.createDirectoryChild(r,e.segments[n]);this.directoryStack.push(i)}if(e.isDirectory){let t=this.directoryStack[this.directoryStack.length-1];if(t===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(t,e.path),this.lastPreparedPath=e;return}let s=this.directoryStack[this.directoryStack.length-1];if(s===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);t?this.createFileChild(s,e.basename,e.path):this.createFileChildUnchecked(s,e.basename),this.lastPreparedPath=e}recordCreatedDirectoryPath(e){!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null||(this.createdDirectoryCount+=1,this.initialExpandedPathSet.has(e)||(this.createdDirectoriesAllExpanded=!1))}createFileChild(e,t,n){let r=fn(this.segmentTable,t),i=this.getDirectoryIndex(e),a=i.childIdByNameId;if(a!=null&&a.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`);let o=this.nodes[e];if(o===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let s=this.nodes.length;return this.nodes.push({depthAndFlags:It(Lt(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),wt(i,s),s}createFileChildUnchecked(e,t){let n=fn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:It(Lt(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),wt(r,a),a}getOrCreateDirectoryChild(e,t){let n=fn(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let e=r.childIdByNameId.get(n);if(e!==void 0){let n=this.nodes[e];if(n!=null&&!V(n))throw Error(`Path collides with an existing file while creating directory "${t}"`);return e}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:It(Lt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),wt(r,a),this.directories.set(a,bt()),a}createDirectoryChild(e,t){let n=fn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:It(Lt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),wt(r,a),this.directories.set(a,bt()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!V(n))throw Error(`Path is not a directory: "${t}"`);if(Bt(n,1))throw Error(`Duplicate path: "${t}"`);Vt(n,1)}getDirectoryIndex(e){let t=this.directories.get(e);if(t!==void 0)return t;throw Error(`Unknown directory child index for node ${String(e)}`)}buildPresortedFinish(e){let t=this.nodes,n=this.directories;n.set(0,xt());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(V(a)){let t=xt();n.set(e,t),r=e,i=t}let o;a.parentId===r?o=i:(o=n.get(a.parentId),r=a.parentId,i=o??null),o?.childIds.push(e)}if(!e)for(let e=t.length-1;e>=1;e--){let n=t[e];if(n==null)continue;let r=t[n.parentId];r!=null&&(r.subtreeNodeCount+=n.subtreeNodeCount,r.visibleSubtreeCount+=n.visibleSubtreeCount)}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;V(n)&&this.directories.set(t,bt());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),wt(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!V(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let e of n.childIds)r+=this.computeSubtreeCounts(e);return Et(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function jn(e,t=`closed`,n=null){let r=Nn(t);return{activeNodeCount:e.nodes.length-1,collapsedDirectoryIds:new Set,collapseNewDirectoriesByDefault:!1,defaultExpansion:r,directoriesOpenByDefault:r===`open`,hasCollapsedDirectoryOverrides:!1,directoryLoadInfoById:new Map,expandedDirectoryIds:new Set,instrumentation:n,listeners:new Map,pathCacheByNodeId:new Map([[e.rootId,{path:``,version:0}]]),pathCacheVersion:0,snapshot:e,transactionStack:[]}}function Mn(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function Nn(e){if(typeof e!=`number`)return e;if(!Number.isInteger(e)||e<0)throw Error(`initialExpansion must be "open", "closed", or a non-negative integer depth. Received: ${String(e)}`);return e}function Pn(e,t){return Bt(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion===`closed`?!1:Lt(t)<=e.defaultExpansion}function Fn(e,t,n=e.snapshot.nodes[t]){return n==null||!V(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:Pn(e,n)}function In(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!V(r))return;let i=Pn(e,r);if(n){if(i){e.collapsedDirectoryIds.delete(t),e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;return}e.expandedDirectoryIds.add(t);return}if(i){e.collapsedDirectoryIds.add(t),e.hasCollapsedDirectoryOverrides=!0;return}e.expandedDirectoryIds.delete(t)}function Ln(e,t){let n=e.directoryLoadInfoById.get(t);if(n!=null)return n;let r={activeAttemptId:null,errorMessage:null,nextAttemptId:1,state:`loaded`};return e.directoryLoadInfoById.set(t,r),r}function Rn(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function zn(e,t){let n=Ln(e,t);if(n.state===`loading`&&n.activeAttemptId!=null)return{attemptId:n.activeAttemptId,nodeId:t,reused:!0};let r=n.nextAttemptId;return n.activeAttemptId=r,n.errorMessage=null,n.nextAttemptId+=1,n.state=`loading`,{attemptId:r,nodeId:t,reused:!1}}function Bn(e,t){let n=Ln(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function Vn(e,t,n){let r=e.directoryLoadInfoById.get(t);return r==null||r.activeAttemptId!==n?!1:(r.activeAttemptId=null,r.errorMessage=null,r.state=`loaded`,!0)}function Hn(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Un(e,t,n,r){let i=e.directoryLoadInfoById.get(t);return i==null||i.activeAttemptId!==n?!1:(i.activeAttemptId=null,i.errorMessage=r??null,i.state=`error`,!0)}function Wn(e,t){e.directoryLoadInfoById.delete(t)}function Gn(e,t,n){let r=n,i=e.listeners.get(t);return i==null?e.listeners.set(t,new Set([r])):i.add(r),()=>{let n=e.listeners.get(t);n!=null&&(n.delete(r),n.size===0&&e.listeners.delete(t))}}function Kn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function qn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function Jn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function Yn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Xn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Zn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Qn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`begin-child-load`,path:e.path,projectionChanged:e.projectionChanged,reused:e.reused,visibleCountDelta:null}}function $n(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some(e=>e.canonicalChanged),childEvents:e.childEvents,operation:`apply-child-patch`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function er(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`complete-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function tr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,errorMessage:e.errorMessage,operation:`fail-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function nr(e){return{activeNodeCountAfter:e.activeNodeCountAfter,activeNodeCountBefore:e.activeNodeCountBefore,affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],cachedPathEntryCountAfter:e.cachedPathEntryCountAfter,cachedPathEntryCountBefore:e.cachedPathEntryCountBefore,canonicalChanged:!1,idsPreserved:e.idsPreserved,loadInfoEntryCountAfter:e.loadInfoEntryCountAfter,loadInfoEntryCountBefore:e.loadInfoEntryCountBefore,mode:e.mode,operation:`cleanup`,projectionChanged:e.projectionChanged,reclaimedCachedPathEntryCount:e.reclaimedCachedPathEntryCount,reclaimedLoadInfoEntryCount:e.reclaimedLoadInfoEntryCount,reclaimedNodeSlotCount:e.reclaimedNodeSlotCount,reclaimedSegmentCount:e.reclaimedSegmentCount,segmentCountAfter:e.segmentCountAfter,segmentCountBefore:e.segmentCountBefore,totalNodeSlotCountAfter:e.totalNodeSlotCountAfter,totalNodeSlotCountBefore:e.totalNodeSlotCountBefore,visibleCountDelta:null}}function rr(e,t,n){return{...n,visibleCountDelta:mr(e)-t}}function ir(e,t){let n=mr(e),r=Mn();e.transactionStack.push(r);try{t()}catch(t){throw sr(e,r,!1),t}sr(e,r,!0,mr(e)-n)}function ar(e,t){let n=e.instrumentation;if(n==null){or(e,t);return}H(n,`store.events.record`,()=>or(e,t))}function or(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){fr(e,t);return}n.events.push(t),dr(n,t)}function sr(e,t,n,r=null){if(e.transactionStack.pop()!==t)throw Error(`Transaction stack underflow`);if(!n)return;let i=e.transactionStack[e.transactionStack.length-1]??null;if(i!=null){let n=e.instrumentation;n==null?ur(i,t):H(n,`store.events.batch.merge`,()=>ur(i,t));return}let a=cr(t,r),o=e.instrumentation;if(o==null){fr(e,a);return}H(o,`store.events.batch.commit`,()=>fr(e,a))}function cr(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some(e=>e.canonicalChanged),events:[...e.events],operation:`batch`,projectionChanged:e.events.some(e=>e.projectionChanged),visibleCountDelta:t}}function lr(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function ur(e,t){for(let n of t.events)e.events.push(n);lr(e,t)}function dr(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function fr(e,t){let n=e.instrumentation;if(n==null){pr(e,t);return}H(n,`store.events.emit`,()=>pr(e,t))}function pr(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function mr(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function hr(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!V(n)||Bt(n,2))return null;let r=e.snapshot.directories.get(t);if(r==null||r.childIds.length!==1)return null;let i=r.childIds[0];if(i==null)return null;let a=e.snapshot.nodes[i];return a==null||!V(a)?null:i}function gr(e,t){let n=t;for(;;){let t=hr(e,n);if(t==null)return n;n=t}}function _r(e,t){let n=[t],r=t;for(;;){let t=hr(e,r);if(t==null)return n;n.push(t),r=t}}function vr(e,t){let n=t==null?e.snapshot.rootId:Dr(e,t);return n==null?[]:kr(e,n)}function yr(e,t){let n=cn(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Wr(e,Ur(e,r)),{createdNodeIds:a,directoryId:o}=Ar(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=G(e,o);if(Bt(n,1))throw Error(`Path already exists: "${t}"`);Vt(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=Mr(e,o,n.basename),s.add(c);wr(e,o);let l=Wr(e,o);return Kn({affectedAncestorIds:Er(e,c),affectedNodeIds:[...s],path:t,projectionChanged:Gr(i,l)})}function br(e,t,n){let r=Dr(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=G(e,r);if(Bt(i,2))throw Error(`The root node cannot be removed`);if(V(i)&&W(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=Wr(e,a),s=Vr(e,r);Fr(e,a,r,i.nameId),Hr(e,a),wr(e,a);let c=Wr(e,a);return qn({affectedAncestorIds:Er(e,a),affectedNodeIds:s,path:t,projectionChanged:Gr(o,c),recursive:n.recursive===!0})}function xr(e,t,n,r){let i=Dr(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=G(e,i);if(Bt(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=zr(e,i,n),c=Wr(e,a.parentId),l=Wr(e,s.parentId),u=pn(e.snapshot.segmentTable,a.nameId),d=fn(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(V(a)&&Yr(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=St(e.snapshot.nodes,W(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&Br(e,p,o,Rt(a))===`skip`)return null;let m=a.parentId;Fr(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),Jr(e,i),Pr(e,s.parentId,i),Hr(e,m),e.pathCacheVersion++,wr(e,m),s.parentId!==m&&wr(e,s.parentId);let h=Wr(e,m),g=Wr(e,s.parentId);return Jn({affectedAncestorIds:[...new Set([...Er(e,m),...Er(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:Kr([c,l],[h,g]),to:U(e,i)})}function Sr(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function Cr(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function U(e,t){let n=G(e,t),r=Sr(e,t);if(r!=null)return r;if(Bt(n,2))return Cr(e,t,``);let i=U(e,n.parentId),a=pn(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return Cr(e,t,V(n)?`${o}/`:o)}function wr(e,t){let n=e.instrumentation;if(n==null){Zr(e,t);return}H(n,`store.recomputeCountsUpwardFrom`,()=>Zr(e,t))}function Tr(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;for(;n.length>0;){let t=n[n.length-1],a=t[0],o=r[a];if(o==null||!V(o)){Xr(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){Xr(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function Er(e,t){let n=[],r=t;for(;r!=null;){let t=G(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function Dr(e,t){if(t.length===0)return e.snapshot.rootId;let n=ln(t);return Or(e,n.segments,n.requiresDirectory)}function Or(e,t,n){let r=e.snapshot.rootId;for(let n of t){let t=e.snapshot.segmentTable.idByValue.get(n);if(t===void 0)return null;let i=W(e,r),a=St(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=G(e,r);return n&&!V(i)?null:r}function W(e,t){let n=e.snapshot.directories.get(t);if(n===void 0)throw Error(`Unknown directory child index for node ${String(t)}`);return n}function G(e,t){let n=e.snapshot.nodes[t];if(n===void 0||Bt(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function kr(e,t){let n=e.snapshot.nodes[t];if(n===void 0||Bt(n,4))return[];if(!V(n))return[U(e,t)];if(W(e,t).childIds.length===0)return Bt(n,1)&&!Bt(n,2)?[U(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];for(;i.length>0;){let t=i[i.length-1];if(t==null)break;let n=e.snapshot.nodes[t.nodeId];if(n===void 0||Bt(n,4)){i.pop();continue}if(!V(n)){r.push(U(e,t.nodeId)),i.pop();continue}let a=W(e,t.nodeId);if(a.childIds.length===0){Bt(n,1)&&!Bt(n,2)&&r.push(U(e,t.nodeId)),i.pop();continue}let o=a.childIds[t.childIndex];if(o==null){i.pop();continue}t.childIndex++,i.push({childIndex:0,nodeId:o})}return r}function Ar(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=fn(e.snapshot.segmentTable,i),a=W(e,r),o=St(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!V(G(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=jr(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function jr(e,t,n){let r=G(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:It(Lt(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,bt()),Pr(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function Mr(e,t,n){let r=fn(e.snapshot.segmentTable,n),i=W(e,t);if(St(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${$r(e,t,n)}"`);let a=G(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:It(Lt(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),Pr(e,t,o),e.activeNodeCount++,o}function Nr(e,t,n){let r=0,i=t.childIds.length;for(;r<i;){let a=r+i>>>1,o=t.childIds[a];if(o==null){i=a;continue}Ir(e,n,o)<0?i=a:r=a+1}return r}function Pr(e,t,n){let r=W(e,t),i=G(e,n);St(e.snapshot.nodes,r).set(i.nameId,n),Dt(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=Nr(e,r,n);r.childIds.splice(a,0,n),Tt(r,a),At(e.snapshot.nodes,r)}function Fr(e,t,n,r){let i=W(e,t),a=Ct(i),o=a.get(n)??-1;St(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&Dt(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),Tt(i,o),At(e.snapshot.nodes,i))}function Ir(e,t,n){let r=e.snapshot.options.sort;return r==="default"?Lr(e,t,n):r(Rr(e,t),Rr(e,n))}function Lr(e,t,n){let r=G(e,t),i=G(e,n),a=V(r);if(a!==V(i))return a?-1:1;let o=Zt(an(e.snapshot.segmentTable,r.nameId),an(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=pn(e.snapshot.segmentTable,r.nameId),c=pn(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function Rr(e,t){let n=G(e,t),r=U(e,t),i=V(n),a=i?r.slice(0,-1):r;return{basename:pn(e.snapshot.segmentTable,n.nameId),depth:Lt(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function zr(e,t,n){let r=G(e,t),i=Dr(e,n);if(i!=null){let t=G(e,i);if(V(t))return{basename:pn(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=ln(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=ln(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:Or(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function Br(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${U(e,t)}"`);let i=G(e,t);if(Rt(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(V(i)&&W(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return Vr(e,t),Fr(e,a,t,o),Hr(e,a),wr(e,a),`handled`}function Vr(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=G(e,t.nodeId);if(t.visitedChildren||!V(i)){V(i)&&e.snapshot.directories.delete(t.nodeId),Vt(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),Wn(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=W(e,t.nodeId);for(let e=a.childIds.length-1;e>=0;e--){let t=a.childIds[e];t!=null&&r.push({nodeId:t,visitedChildren:!1})}}return n}function Hr(e,t){let n=t;for(;n!=null;){let t=G(e,n);if(!V(t)||Bt(t,2)||W(e,n).childIds.length>0)return;Vt(t,1),n=t.parentId===n?null:t.parentId}}function Ur(e,t){let n=e.snapshot.rootId;for(let r of t){let t=e.snapshot.segmentTable.idByValue.get(r);if(t==null)break;let i=St(e.snapshot.nodes,W(e,n)).get(t);if(i==null||!V(G(e,i)))break;n=i}return n}function Wr(e,t){let n=qr(e,t);if(n==null)return null;let r=gr(e,n),i=G(e,r),a=n===r?null:_r(e,n).map(t=>U(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:W(e,r).childIds.length>0,path:U(e,r),terminalKind:Rt(i)})}function Gr(e,t){return Kr([e],[t])}function Kr(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r==null||i==null||r!==i)return!0}return!1}function qr(e,t){let n=t;for(;n!=null;){let t=G(e,n);if(!V(t)||Bt(t,2))return null;if(!Fn(e,n,t))return n;n=t.parentId}return null}function Jr(e,t){let n=G(e,t);if(Ht(n,(t===e.snapshot.rootId?-1:Lt(G(e,n.parentId)))+1),!V(n))return;let r=W(e,t);for(let t of r.childIds)Jr(e,t)}function Yr(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=G(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function Xr(e,t,n=G(e,t),r=!1){let i=e.instrumentation;if(i==null){Qr(e,t,n,r);return}H(i,`store.recomputeNodeCounts`,()=>Qr(e,t,n,r))}function Zr(e,t){let n=t;for(;n!=null;){let t=G(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(Xr(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&Dt(W(e,s),n,a,o),n=s}}function Qr(e,t,n,r){if(!V(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=W(e,t);if(r){let t=e.instrumentation;t==null?Et(e.snapshot.nodes,i):H(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>Et(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,Bt(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=hr(e,t)==null?Fn(e,t,n)?1+o:1:o}function $r(e,t,n){let r=U(e,t);return r.length===0?n:`${r}${n}`}function ei(e){return e!=null&&!Bt(e,4)}function ti(e,t){let n=e.snapshot.nodes[t];return!ei(n)||!V(n)||Bt(n,2)?null:n}function ni(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&ei(e.snapshot.nodes[n])&&(t+=1);return t}function ri(e){return Math.max(0,e.valueById.length-1)}function ii(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:ni(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:ri(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function ai(e,t,n,r){return{activeNodeCountAfter:r.activeNodeCount,activeNodeCountBefore:n.activeNodeCount,cachedPathEntryCountAfter:r.cachedPathEntryCount,cachedPathEntryCountBefore:n.cachedPathEntryCount,idsPreserved:t,loadInfoEntryCountAfter:r.loadInfoEntryCount,loadInfoEntryCountBefore:n.loadInfoEntryCount,mode:e,reclaimedCachedPathEntryCount:n.cachedPathEntryCount-r.cachedPathEntryCount,reclaimedLoadInfoEntryCount:n.loadInfoEntryCount-r.loadInfoEntryCount,reclaimedNodeSlotCount:n.totalNodeSlotCount-r.totalNodeSlotCount,reclaimedSegmentCount:n.segmentCount-r.segmentCount,segmentCountAfter:r.segmentCount,segmentCountBefore:n.segmentCount,totalNodeSlotCountAfter:r.totalNodeSlotCount,totalNodeSlotCountBefore:n.totalNodeSlotCount}}function oi(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)ti(e,n)!=null&&t.push(U(e,n));for(let t of e.expandedDirectoryIds)ti(e,t)!=null&&n.push(U(e,t));return{collapsedPaths:t,expandedPaths:n}}function si(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)ti(e,n)==null||Rn(e,n)===`loaded`||t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:U(e,n)});return t}function ci(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=Dr(e,n);t!=null&&In(e,t,!0,G(e,t))}for(let n of t.collapsedPaths){let t=Dr(e,n);t!=null&&In(e,t,!1,G(e,t))}}function li(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=Dr(e,n.path);t!=null&&ti(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function ui(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function di(e){let t=e.snapshot.segmentTable,n=dn();for(let r of e.snapshot.nodes)if(ei(r)){if(Bt(r,2)){r.nameId=0;continue}r.nameId=fn(n,pn(t,r.nameId))}e.snapshot.segmentTable=n}function fi(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!ei(r)||!V(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return ei(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[G(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),Et(e.snapshot.nodes,n)}}function pi(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(ei(n))break;--t}e.snapshot.nodes.length=t+1}function mi(e){let t=oi(e),n=si(e);H(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>ui(e)),H(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>di(e)),H(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>fi(e)),H(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>pi(e)),H(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>ci(e,t)),H(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>li(e,n)),H(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>Tr(e,e.snapshot.rootId))}function hi(e){let t=oi(e),n=si(e),r=H(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>vr(e)),i=Wt({...e.snapshot.options},e.instrumentation),a=H(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new An(i);return e.appendPaths(r),e.finish()});e.snapshot=a,e.activeNodeCount=a.nodes.length-1,e.pathCacheByNodeId=new Map([[a.rootId,{path:``,version:0}]]),e.pathCacheVersion=0,H(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>ci(e,t)),H(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>li(e,n)),H(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>Tr(e,e.snapshot.rootId))}function gi(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function _i(e,t){let n=ii(e);t===`stable`?H(e.instrumentation,`store.cleanup.stable`,()=>mi(e)):H(e.instrumentation,`store.cleanup.aggressive`,()=>hi(e));let r=ii(e);return ai(t,t===`stable`,n,r)}var vi=64;function yi(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;for(;r<n;)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function bi(e){return G(e,e.snapshot.rootId).visibleSubtreeCount}function xi(e,t,n,r){let i=G(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function Si(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:Vi(e,t.cursor),setSize:t.setSize,subtreeEndIndex:xi(e,t.cursor,t.index,n)}}function Ci(e,t,n,r,i,a){let o=W(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=Ot(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return wi(e,u,l,r+c,i+1,s,o.childIds.length,a)}function wi(e,t,n,r,i,a,o,s){if(!V(G(e,t))){if(n===0)return{ancestors:s,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:a,setSize:o};throw Error(`Visible index ${String(n)} is out of range for file`)}let c=Fi(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=G(e,c.terminalNodeId);if(!V(l)||!Fn(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Ci(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function Ti(e,t){let n=bi(e);if(t<0||t>=n)return null;let r=Ci(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>U(e,t.cursor.terminalNodeId)),a=null;return{ancestorPaths:i,get ancestorRows(){if(a!=null)return a;let t=[],i=[];for(let a of r.ancestors){let r=Si(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:Vi(e,r.cursor),setSize:r.setSize,subtreeEndIndex:xi(e,r.cursor,r.index,n)}}function Ei(e,t,n){let r=e.instrumentation,i=bi(e);if(i<=0||n<t)return[];let a=Math.max(0,Math.min(t,i-1)),o=Math.max(a,Math.min(n,i-1));if(r==null){if(a===0)return Bi(e,o+1);let t=[],n=Mi(e,a);for(let r=a;r<=o&&n!=null;r++){let r=Vi(e,n);t.push(r),n=Li(e,n)}return t}let s=[],c=0,l=0,u=H(r,`store.getVisibleSlice.selectFirstRow`,()=>Mi(e,a));for(let t=a;t<=o&&u!=null;t++){let t=H(r,`store.getVisibleSlice.materializeRow`,()=>Vi(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=H(r,`store.getVisibleSlice.advanceCursor`,()=>Li(e,u))}return Kt(r,`workload.visibleRowsRead`,s.length),Kt(r,`workload.flattenedRowsRead`,c),Kt(r,`workload.flattenedSegmentsRead`,l),s}function Di(e,t=bi(e)){let n=e.instrumentation;return n==null?zi(e,t):H(n,`store.getVisibleTreeProjection`,()=>zi(e,t))}function Oi(e){return Ri(Di(e))}function ki(e,t){let n=Dr(e,t);if(n==null||n===e.snapshot.rootId||V(G(e,n))&&gr(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=G(e,i).parentId,n=W(e,t),s=Ct(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=kt(a,n,s),t!==o){let n=G(e,t),a=hr(e,t);if(!Fn(e,t,n)&&a!==i)return null;gr(e,t)===t&&(r+=1)}i=t}return r}function Ai(e,t){let n=Dr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=G(e,n);if(!V(r))throw Error(`Path is not a directory: "${t}"`);return Fn(e,n,r)?null:(In(e,n,!0,r),wr(e,n),Yn({affectedAncestorIds:Er(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function ji(e,t){let n=Dr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=G(e,n);if(!V(r))throw Error(`Path is not a directory: "${t}"`);return Fn(e,n,r)?(In(e,n,!1,r),wr(e,n),Xn({affectedAncestorIds:Er(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function Mi(e,t){return t<0||t>=bi(e)?null:Ni(e,e.snapshot.rootId,t,-1)}function Ni(e,t,n,r){let i=W(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?Ot(e.snapshot.nodes,i,n):H(a,`store.getVisibleSlice.selectChildIndex`,()=>Ot(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return Pi(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Pi(e,t,n,r){if(!V(G(e,t))){if(n===0)return{headNodeId:t,terminalNodeId:t,visibleDepth:r};throw Error(`Visible index ${String(n)} is out of range for file`)}let i=Fi(e,t,r);if(n===0)return i;let a=G(e,i.terminalNodeId);if(!V(a)||!Fn(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Ni(e,i.terminalNodeId,n-1,i.visibleDepth)}function Fi(e,t,n){return V(G(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:gr(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:H(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>gr(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function Ii(e,t){let n=G(e,t);if(!V(n))return!0;let r=n.parentId;return r===e.snapshot.rootId?!0:hr(e,r)!==t}function Li(e,t){let n=G(e,t.terminalNodeId);if(V(n)){let r=W(e,t.terminalNodeId);if(Fn(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:Pi(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=G(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=W(e,n),o=Ct(a).get(r)??-1;if(o<0)throw Error(`Child ${String(r)} was not found in its parent index`);let s=a.childIds[o+1]??null;if(s!=null)return Pi(e,s,0,i);Ii(e,r)&&i--,r=n}}function Ri(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let t=e.getParentIndex(r);n[r]={index:r,parentPath:t>=0?e.paths[t]??null:null,path:e.paths[r]??``,posInSet:e.posInSetByIndex[r]??0,setSize:e.setSizeByIndex[r]??0}}return{getParentIndex:e.getParentIndex,rows:n,get visibleIndexByPath(){return e.visibleIndexByPath}}}function zi(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(vi);o.fill(-1);let s=0,{nodes:c,directories:l,segmentTable:u}=e.snapshot,d=[[l.get(e.snapshot.rootId),0,-1,``]],f=e.snapshot.options.flattenEmptyDirectories,p=e.pathCacheByNodeId,m=e.pathCacheVersion,h=u.valueById;for(;d.length>0&&s<t;){let t=d[d.length-1],u=t[0];if(t[1]>=u.childIds.length){d.pop();continue}let g=t[1],_=u.childIds[t[1]++],v=c[_],y=t[2]+1,b=t[3];o=yi(o,y);let x,S=_;if(V(v))S=f?gr(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:U(e,S);else{let e=p.get(_);x=e!=null&&e.version===m?e.path:`${b}${h[v.nameId]}`}r[s]=o[y],n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let C=c[S];C!=null&&V(C)&&Fn(e,S,C)&&d.push([l.get(S),0,y,x])}s<t&&(n.length=s);let g=r.subarray(0,s),_=i.subarray(0,s),v=a.subarray(0,s),y=null;return{getParentIndex(e){return e<0||e>=s?-1:g[e]??-1},paths:n,posInSetByIndex:_,setSizeByIndex:v,get visibleIndexByPath(){if(y==null){y=new Map;for(let e=0;e<s;e+=1)y.set(n[e]??``,e)}return y}}}function Bi(e,t){let n=Array(t),r=0,{nodes:i,directories:a,segmentTable:o}=e.snapshot,s=[[a.get(e.snapshot.rootId),0,-1]],c=o.valueById,l=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,d=e.pathCacheVersion;for(;s.length>0&&r<t;){let t=s[s.length-1],o=t[0];if(t[1]>=o.childIds.length){s.pop();continue}let f=o.childIds[t[1]++],p=i[f],m=t[2]+1;if(!V(p)){let t=u.get(f);n[r++]={depth:m,flattenedSegments:void 0,hasChildren:!1,id:f,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:`file`,loadState:void 0,name:c[p.nameId],path:t!=null&&t.version===d?t.path:U(e,f)};continue}let h=l?gr(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=Vi(e,g);let _=i[h];_!=null&&V(_)&&Fn(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function Vi(e,t){let n=G(e,t.terminalNodeId),r=V(n)?Hi(e,t):null,i=U(e,t.terminalNodeId),a=pn(e.snapshot.segmentTable,n.nameId),o=V(n)&&W(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?_r(e,t.headNodeId).map(n=>{let r=G(e,n);return{isTerminal:n===t.terminalNodeId,name:pn(e.snapshot.segmentTable,r.nameId),nodeId:n,path:U(e,n)}}):H(c,`store.getVisibleSlice.flatten.collectSegments`,()=>_r(e,t.headNodeId).map(n=>{let r=G(e,n);return{isTerminal:n===t.terminalNodeId,name:pn(e.snapshot.segmentTable,r.nameId),nodeId:n,path:U(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:V(n)&&Fn(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:V(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function Hi(e,t){if(t.headNodeId===t.terminalNodeId)return Rn(e,t.terminalNodeId);let n=_r(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=Rn(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}function Ui(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:a}=e.snapshot,o=r.flattenEmptyDirectories===!0,s=e=>{let r=n[e];if(r==null||!V(r))return;let i=t.get(e);if(i==null)throw Error(`Unknown directory child index for node ${String(e)}`);let a=i.childIds,s=a.length,c=0,l=0;for(let e=0;e<s;e++){let t=a[e];if(t==null)continue;let r=n[t];c+=r.subtreeNodeCount,l+=r.visibleSubtreeCount}i.totalChildSubtreeNodeCount=c,i.totalChildVisibleSubtreeCount=l,s>=128&&At(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&V(e)?l:1+l}else u=1+l;r.visibleSubtreeCount=u};if(a!=null)for(let e=a.length-1;e>=0;e--)s(a[e]);else for(let e=n.length-1;e>=1;e--)s(e);let c=n[i],l=t.get(i);if(c==null||l==null)return;let u=l.childIds,d=0,f=0;for(let e=0;e<u.length;e++){let t=u[e];if(t==null)continue;let r=n[t];d+=r.subtreeNodeCount,f+=r.visibleSubtreeCount}l.totalChildSubtreeNodeCount=d,l.totalChildVisibleSubtreeCount=f,At(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Wi(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var Gi=class e{#e;constructor(e={}){let t=Gt(e),n=H(t,`store.builder.create`,()=>new An(e));if(e.preparedInput!=null){let t=Dn(e.preparedInput);t==null?n.appendPreparedPaths(En(e.preparedInput),!1):n.appendPresortedPaths(t,On(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(H(t,`store.preparePathEntries`,()=>kn(r,e)))}let r=H(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=H(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=H(t,`store.state.create`,()=>jn(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:H(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||Wi(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&H(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?H(t,`store.state.initializeOpenVisibleCounts`,()=>Ui(this.#e)):H(t,`store.state.recomputeCounts`,()=>Tr(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return Cn(e,t)}static prepareInput(e,t={}){return wn(e,t)}static preparePresortedInput(e){return Tn(e)}list(e){return H(this.#e.instrumentation,`store.list`,()=>vr(this.#e,e))}add(e){H(this.#e.instrumentation,`store.add`,()=>{let t=bi(this.#e);ar(this.#e,rr(this.#e,t,yr(this.#e,e)))})}remove(e,t={}){H(this.#e.instrumentation,`store.remove`,()=>{let n=bi(this.#e);ar(this.#e,rr(this.#e,n,br(this.#e,e,t)))})}move(e,t,n={}){H(this.#e.instrumentation,`store.move`,()=>{let r=bi(this.#e),i=xr(this.#e,e,t,n);i!=null&&ar(this.#e,rr(this.#e,r,i))})}batch(e){ir(this.#e,()=>{if(typeof e==`function`){e(this);return}for(let t of e)switch(t.type){case`add`:this.add(t.path);break;case`remove`:this.remove(t.path,{recursive:t.recursive});break;case`move`:this.move(t.from,t.to,{collision:t.collision});break}})}getVisibleCount(){return H(this.#e.instrumentation,`store.getVisibleCount`,()=>bi(this.#e))}getVisibleSlice(e,t){return H(this.#e.instrumentation,`store.getVisibleSlice`,()=>Ei(this.#e,e,t))}getVisibleRowContext(e){return H(this.#e.instrumentation,`store.getVisibleRowContext`,()=>Ti(this.#e,e))}getVisibleTreeProjection(){return Oi(this.#e)}getVisibleTreeProjectionData(e){return Di(this.#e,e)}getVisibleIndex(e){return H(this.#e.instrumentation,`store.getVisibleIndex`,()=>ki(this.#e,e))}getPathInfo(e){return H(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=Dr(this.#e,e);if(t==null)return null;let n=G(this.#e,t);return{depth:Lt(n),kind:V(n)?`directory`:`file`,path:U(this.#e,t)}})}isExpanded(e){return H(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=G(this.#e,t);return Fn(this.#e,t,n)})}expand(e){H(this.#e.instrumentation,`store.expand`,()=>{let t=bi(this.#e),n=Ai(this.#e,e);n!=null&&ar(this.#e,rr(this.#e,t,n))})}collapse(e){H(this.#e.instrumentation,`store.collapse`,()=>{let t=bi(this.#e),n=ji(this.#e,e);n!=null&&ar(this.#e,rr(this.#e,t,n))})}on(e,t){return Gn(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return Rn(this.#e,t)}markDirectoryUnloaded(e){H(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(W(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=bi(this.#e);Bn(this.#e,t),ar(this.#e,rr(this.#e,n,Zn({affectedAncestorIds:Er(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return H(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=bi(this.#e),r=zn(this.#e,t);return ar(this.#e,rr(this.#e,n,Qn({affectedAncestorIds:Er(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return H(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||Rn(this.#e,n)!==`loading`||!Hn(this.#e,n,e.attemptId))return!1;let r=U(this.#e,n);this.validateChildPatch(r,t);let i=bi(this.#e),a=[];for(let e of t.operations){Ki(r,e);let t=bi(this.#e);switch(e.type){case`add`:a.push(rr(this.#e,t,yr(this.#e,e.path)));break;case`remove`:a.push(rr(this.#e,t,br(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=xr(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(rr(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return ar(this.#e,rr(this.#e,i,$n({affectedAncestorIds:Er(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:U(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return H(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=bi(this.#e),r=Vn(this.#e,t,e.attemptId);return ar(this.#e,rr(this.#e,n,er({affectedAncestorIds:Er(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:U(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return H(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=bi(this.#e),i=Un(this.#e,n,e.attemptId,t);return ar(this.#e,rr(this.#e,r,tr({affectedAncestorIds:Er(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:U(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return H(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(gi(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=bi(this.#e),n=_i(this.#e,e.mode??`stable`);return ar(this.#e,rr(this.#e,t,nr({...n,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:n.idsPreserved===!1}))),n})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(e){if(e==null||e.length===0)return 0;let t=0,n=[],r=[],i=0,a=null,o=this.#e.snapshot.segmentTable,s=o.valueById,c=this.#e.snapshot.nodes,l=new Map;for(let u of e){a!=null&&u<a&&(a=null,i=0,n.length=0,r.length=0);let e=u.length>0&&u.charCodeAt(u.length-1)===47?u.length-1:u.length;if(e===0){a=u,i=e,n.length=0,r.length=0;continue}let d=0,f=0;if(a!=null){let t=Math.min(e,i),n=!0;for(let e=0;e<t;e+=1){let t=u.charCodeAt(e);if(t!==a.charCodeAt(e)){n=!1;break}t===47&&(d+=1,f=e+1)}n&&(t===i&&e>t&&u.charCodeAt(t)===47?(d+=1,f=t+1):t===e&&i>t&&a.charCodeAt(t)===47&&(d+=1,f=e+1)),d=Math.min(d,r.length)}let p=d===0?this.#e.snapshot.rootId:r[d-1]??this.#e.snapshot.rootId,m=d,h=!0,g=f;for(;g<=e;){let t=u.indexOf(`/`,g),i=t===-1||t>e?e:t,a=u.slice(g,i),f=W(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??Yt(a);l.set(a,b);let x=(e,t)=>{for(v=e;v<t;v+=1){let e=f[v],t=c[e],n=s[t.nameId];if(n===a)return y=e,!0;let r=Zt(an(o,t.nameId),b);if(r>0||r===0&&n>a)return!1}return!1};if(!x(_,f.length)&&_>0&&x(0,_),y===void 0){h=!1;break}if(!V(G(this.#e,y))){h=!1;break}if(n[m]=v,r[m]=y,p=y,m+=1,i===e)break;g=i+1}if(a=u,i=e,n.length=m,r.length=m,!h){a=null,i=0,n.length=0,r.length=0;continue}for(let e=d;e<m;e+=1){let n=r[e];if(n==null)continue;let i=G(this.#e,n);Fn(this.#e,n,i)||(In(this.#e,n,!0,i),t+=1)}}return t}hasAllDirectoriesExpanded(){for(let e of this.#e.snapshot.directories.keys()){if(e===this.#e.snapshot.rootId)continue;let t=G(this.#e,e);if(!Fn(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=Dr(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!V(G(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!V(G(this.#e,e)))throw Error(`Node is not a directory: ${String(e)}`);return e}catch{return null}}isDirectoryProjectionVisible(e){let t=e;for(;t!==this.#e.snapshot.rootId;){let e=G(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=G(this.#e,e),r=hr(this.#e,e);if(!Fn(this.#e,e,n)&&r!==t)return!1}t=e}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function Ki(e,t){switch(t.type){case`add`:case`remove`:if(!t.path.startsWith(e)||t.path===e)throw Error(`Child patch operation must stay within ${e}: "${t.path}"`);break;case`move`:if(!t.from.startsWith(e)||!t.to.startsWith(e)||t.from===e||t.to===e)throw Error(`Child patch move must stay within ${e}: "${t.from}" -> "${t.to}"`);break}}var qi={compact:{itemHeight:24,factor:.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function Ji(e,t){if(typeof e==`number`)return{itemHeight:t??qi.default.itemHeight,factor:e};let n=qi[e??`default`];return{itemHeight:t??n.itemHeight,factor:n.factor}}var Yi=qi.default.itemHeight,Xi=`@layer base, theme, unsafe;
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$ as i,$a as a,Cl as o,Dt as s,Ia as c,Nt as l,St as u,Ur as d,W as f,Wp as p,Yr as m,_l as h,_t as g,cl as _,cu as v,g as y,ht as b,jt as x,ml as S,mt as C,n as w,nt as T,o as E,pu as D,vt as O,wl as k,wt as A,x as ee,xt as j,yt as M}from"./previewAssetResource-BMf_t-Oa.js";import{n as N,r as P,t as te}from"./renderFileChildren-DsohA9os.js";import{A as ne,An as F,Br as re,C as ie,Ct as ae,D as oe,En as se,Fr as ce,Ir as le,Jn as ue,Jt as de,Kn as fe,Nr as I,O as pe,Or as me,Pr as L,Qt as he,Rn as ge,S as _e,St as ve,Vn as ye,Vr as be,Wr as xe,Yt as Se,Zt as R,_ as Ce,at as we,dn as Te,ei as Ee,en as De,er as Oe,f as ke,fn as Ae,g as je,gr as Me,h as Ne,ir as Pe,k as Fe,kn as Ie,li as Le,m as Re,mr as ze,mt as Be,nr as Ve,oi as He,ot as Ue,p as We,qn as Ge,qr as Ke,ri as qe,rr as Je,rt as Ye,si as Xe,st as Ze,tr as Qe,ui as $e,vn as et,w as tt,x as nt}from"./index-BSuuYg8z.js";import{a as rt,i as it,n as at,r as z,t as B}from"./fileCommentAnnotations-ByKdy50L.js";var ot=h(`file-question-mark`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),st=h(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),ct=`file-tree-container`,lt=`data-file-tree-style`,ut=`data-file-tree-unsafe-css`,dt=`data-file-tree-scrollbar-measure`,ft=`data-file-tree-scrollbar-gutter-measured`,pt=`--trees-scrollbar-gutter-measured`,mt=`header`,ht=`context-menu`,gt=`context-menu-trigger`,_t=5,vt=1<<_t,yt=vt*4;function bt(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function xt(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function St(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let t=e[r];t!=null&&n.set(t.nameId,r)}return t.childIdByNameId=n,n}function Ct(e){if(e.childPositionById!=null)return e.childPositionById;let t=new Map;for(let n=0;n<e.childIds.length;n++){let r=e.childIds[n];r!=null&&t.set(r,n)}return e.childPositionById=t,t}function wt(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function Tt(e,t){if(e.childPositionById!=null)for(let n=t;n<e.childIds.length;n++){let t=e.childIds[n];t!=null&&e.childPositionById.set(t,n)}}function Et(e,t){let n=0,r=0;for(let i of t.childIds){let t=e[i];t!=null&&(n+=t.subtreeNodeCount,r+=t.visibleSubtreeCount)}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,At(e,t)}function Dt(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=Ct(e).get(t);if(i===void 0)return;let a=i>>_t;e.childVisibleChunkSums[a]+=r}function Ot(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let i=n,a=0;for(let o of r){if(i<o){let r=jt(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=vt}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let r=0;r<t.childIds.length;r++){let a=t.childIds[r];if(a==null)continue;let o=e[a];if(o!=null){if(i<o.visibleSubtreeCount)return{childIndex:r,childVisibleIndex:n-i,localVisibleIndex:i};i-=o.visibleSubtreeCount}}throw Error(`Visible child index ${String(n)} is out of range`)}function kt(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>_t;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<_t}for(let i=a;i<n;i+=1){let n=t.childIds[i];if(n==null)continue;let a=e[n];a!=null&&(r+=a.visibleSubtreeCount)}return r}function At(e,t){if(t.childIds.length<yt){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/vt),r=new Int32Array(n);for(let n=0;n<t.childIds.length;n++){let i=t.childIds[n];if(i==null)continue;let a=e[i];a!=null&&(r[n>>_t]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function jt(e,t,n,r){let i=Math.min(t.childIds.length,n+vt),a=r;for(let r=n;r<i;r++){let n=t.childIds[r];if(n==null)continue;let i=e[n];if(i!=null){if(a<i.visibleSubtreeCount)return{childIndex:r,localVisibleIndex:a};a-=i.visibleSubtreeCount}}throw Error(`Visible child index ${String(r)} is out of range`)}var Mt=7,Nt=3,Pt=1<<Nt,Ft=4;function It(e,t,n=0){return e<<Ft|n<<Nt|t}function Lt(e){return e.depthAndFlags>>>Ft}function Rt(e){return(e.depthAndFlags&Pt)>>Nt}function V(e){return(e.depthAndFlags&Pt)!==0}function zt(e){return e.depthAndFlags&Mt}function Bt(e,t){return(zt(e)&t)!==0}function Vt(e,t){e.depthAndFlags|=t}function Ht(e,t){e.depthAndFlags=It(t,zt(e),Rt(e))}var Ut=Symbol(`benchmarkInstrumentation`);function Wt(e,t){return t==null||Object.defineProperty(e,Ut,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function Gt(e){return e==null?null:e[Ut]??null}function H(e,t,n){return e==null?n():e.measurePhase(t,n)}function Kt(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function qt(e){return e>=48&&e<=57}function Jt(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!qt(e.charCodeAt(r));)r+=1;if(r>=e.length)break;r>n&&t.push(e.slice(n,r));let i=0;for(;r<e.length&&qt(e.charCodeAt(r));)i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}return(n<e.length||t.length===0)&&t.push(e.slice(n)),t}function Yt(e){let t=e.toLowerCase();return{lowerValue:t,tokens:Jt(t)}}function Xt(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],i=t[r];if(n===i)continue;if(typeof n==`number`&&typeof i==`number`)return n<i?-1:1;let a=String(n),o=String(i);if(a!==o)return a<o?-1:1}return e.length===t.length?0:e.length<t.length?-1:1}function Zt(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==`string`&&typeof t.tokens[0]==`string`)return e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1;let n=Xt(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function Qt(e,t,n){let r=Zt(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function $t(e,t){return Qt(e,t,Yt)}function en(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function tn(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let n=e.segments[r],i=t.segments[r];if(n===i)continue;let a=en(e,r);return a===en(t,r)?$t(n,i):a===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function nn(e,t){return tn(e,t)}function rn(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=Yt(e);return n.set(e,r),r},i=Math.min(e.segments.length,t.segments.length);for(let n=0;n<i;n++){let i=e.segments[n],a=t.segments[n];if(i===a)continue;let o=en(e,n);return o===en(t,n)?Qt(i,a,r):o===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function an(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=Yt(r);return e.sortKeyById[t]=i,i}function on(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function sn(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let t=0;t<n;t++)e.charCodeAt(t)===47&&(r.push(e.slice(i,t)),i=t+1);return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function cn(e){let{hasTrailingSlash:t,segments:n}=sn(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function ln(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=sn(e);return{requiresDirectory:t,segments:n}}var un=``;function dn(){let e=new Map;return e.set(un,0),{idByValue:e,valueById:[un],sortKeyById:[Yt(un)]}}function fn(e,t){let n=e.idByValue.get(t);if(n!==void 0)return n;let r=e.valueById.length;return e.idByValue.set(t,r),e.valueById.push(t),r}function pn(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var mn=Symbol(`pathStorePreparedInputKind`);function hn(e,t){return e[mn]=t,e}function gn(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function _n(e,t,n){return n==="default"?nn(e,t):n(gn(e),gn(t))}function vn(){return{depthAndFlags:It(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function yn(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return r;return n}function bn(e){return e.isDirectory?e.segments.length:e.segments.length-1}function xn(e){return Array.isArray(e)&&e.every(e=>typeof e==`object`&&!!e&&typeof e.path==`string`&&Array.isArray(e.segments)&&typeof e.basename==`string`&&typeof e.isDirectory==`boolean`)}function Sn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Cn(e,t={}){return kn(e,t).map(e=>e.path)}function wn(e,t={}){let n=kn(e,t);return hn({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function Tn(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let t=e[r];if(t.length>0&&t.charCodeAt(t.length-1)===47){n=!0;break}}return hn({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function En(e){let t=e,n=t.preparedPaths;if(t[mn]===`prepared`&&n!=null)return n;if(!xn(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function Dn(e){let t=e;return t[mn]===`presorted`&&t.presortedPaths!=null||Sn(t.presortedPaths)?t.presortedPaths:null}function On(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function kn(e,t={}){let n=on(t),r=Gt(t);Kt(r,`workload.inputFiles`,e.length);let i=H(r,`store.preparePathEntries.parse`,()=>e.map(e=>cn(e)));return H(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>_n(e,t,n.sort))),i}var An=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[vn()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=dn();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=Gt(e),this.options=on(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let e=new Set,n=t.length;for(let r=0;r<n;r+=1){let n=t[r],i=n.length;e.add(i>0&&n.charCodeAt(i-1)===47?n.slice(0,i-1):n)}this.initialExpandedPathSet=e,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,bt())}appendPaths(e){return H(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>cn(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,H(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return H(this.instrumentation,`store.builder.appendPresortedPaths`,()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,a=this.segmentTable,o=a.idByValue,s=a.valueById,c=this.directoryStack,l=0,u=``,d=0;for(let t of e){if(n===t)throw Error(`Duplicate path: "${t}"`);let e=t.length>0&&t.charCodeAt(t.length-1)===47,a=e?t.length-1:t.length,f=0,p=0;if(n!=null)if(u.length>0&&t.length>u.length&&t.startsWith(u))f=d,p=u.length;else{let r=Math.min(a,n.length),i=!0;for(let e=0;e<r;e++){let r=t.charCodeAt(e);if(r!==n.charCodeAt(e)){i=!1;break}r===47&&(f++,p=e+1)}i&&e&&r===a&&n.length>a&&n.charCodeAt(a)===47&&(f++,p=a+1)}l=f,r=f;let m=p,h=t.indexOf(`/`,m);for(;h>=0&&h<a;){let e=c[l];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);r++;let n=t.slice(m,h),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n));let u=i.length;i.push({depthAndFlags:It(r,0,1),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(t.slice(0,h)),l++,c[l]=u,m=h+1,h=t.indexOf(`/`,m)}if(e){if(m<a){let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory parent for "${t}"`);r++;let n=t.slice(m,a),u=o.get(n);u===void 0&&(u=s.length,o.set(n,u),s.push(n));let d=i.length;i.push({depthAndFlags:It(r,0,1),nameId:u,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),l++,c[l]=d}let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory node for "${t}"`);this.promoteDirectoryToExplicit(e,t)}else{let e=c[l];if(e===void 0)throw Error(`Unable to resolve file parent for "${t}"`);let n=t.slice(m),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n)),i.push({depthAndFlags:It(r+1,0),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1})}m!==u.length&&(u=t.substring(0,m),d=r),n=t}c.length=l+1,n!=null&&(this.lastPreparedPath=cn(n)),this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,a=i.idByValue,o=i.valueById,s=this.directoryStack,c=0,l=``,u=0;for(let i of e){if(t===i)throw Error(`Duplicate path: "${i}"`);let e=i.length,d=0,f=0;if(t!=null)if(l.length>0&&i.length>l.length&&i.startsWith(l))d=u,f=l.length;else{let n=Math.min(e,t.length);for(let e=0;e<n;e++){let n=i.charCodeAt(e);if(n!==t.charCodeAt(e))break;n===47&&(d++,f=e+1)}}c=d,n=d;let p=f,m=i.indexOf(`/`,p);for(;m>=0;){let e=s[c];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);n++;let t=i.slice(p,m),l=a.get(t);l===void 0&&(l=o.length,a.set(t,l),o.push(t));let u=r.length;r.push({depthAndFlags:It(n,0,1),nameId:l,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(i.slice(0,m)),this.presortedDirectoryNodeIds.push(u),c++,s[c]=u,p=m+1,m=i.indexOf(`/`,p)}let h=s[c];if(h===void 0)throw Error(`Unable to resolve file parent for "${i}"`);let g=i.slice(p),_=a.get(g);_===void 0&&(_=o.length,a.set(g,_),o.push(g)),r.push({depthAndFlags:It(n+1,0),nameId:_,parentId:h,subtreeNodeCount:1,visibleSubtreeCount:1}),p!==l.length&&(l=i.substring(0,p),u=n),t=i}s.length=c+1,t!=null&&(this.lastPreparedPath=cn(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(H(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||H(this.instrumentation,`store.builder.computeSubtreeCounts`,()=>this.computeSubtreeCounts(0)),{directories:this.directories,nodes:this.nodes,options:this.options,rootId:0,segmentTable:this.segmentTable,presortedDirectoryNodeIds:this.presortedDirectoryNodeIds.length>0?this.presortedDirectoryNodeIds:null}}didMatchAllInitialExpandedPaths(){return this.createdDirectoriesAllExpanded&&this.initialExpandedPathSet!=null&&this.createdDirectoryCount===this.initialExpandedPathSet.size}appendPreparedPath(e,t){if(this.hasDeferredDirectoryIndexes&&=(this.buildDirectoryIndexes(),!1),this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t&&(this.options.sort==="default"?rn(this.lastPreparedPath,e,this.segmentSortKeyCache):_n(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=bn(e),i=n==null?0:bn(n),a=n==null?0:yn(n.segments,e.segments),o=Math.min(a,r,i);this.directoryStack.length=o+1;for(let n=o;n<r;n++){let r=this.directoryStack[this.directoryStack.length-1];if(r===void 0)throw Error(`Directory stack underflow while building the path store`);let i=t?this.getOrCreateDirectoryChild(r,e.segments[n]):this.createDirectoryChild(r,e.segments[n]);this.directoryStack.push(i)}if(e.isDirectory){let t=this.directoryStack[this.directoryStack.length-1];if(t===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(t,e.path),this.lastPreparedPath=e;return}let s=this.directoryStack[this.directoryStack.length-1];if(s===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);t?this.createFileChild(s,e.basename,e.path):this.createFileChildUnchecked(s,e.basename),this.lastPreparedPath=e}recordCreatedDirectoryPath(e){!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null||(this.createdDirectoryCount+=1,this.initialExpandedPathSet.has(e)||(this.createdDirectoriesAllExpanded=!1))}createFileChild(e,t,n){let r=fn(this.segmentTable,t),i=this.getDirectoryIndex(e),a=i.childIdByNameId;if(a!=null&&a.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`);let o=this.nodes[e];if(o===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let s=this.nodes.length;return this.nodes.push({depthAndFlags:It(Lt(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),wt(i,s),s}createFileChildUnchecked(e,t){let n=fn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:It(Lt(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),wt(r,a),a}getOrCreateDirectoryChild(e,t){let n=fn(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let e=r.childIdByNameId.get(n);if(e!==void 0){let n=this.nodes[e];if(n!=null&&!V(n))throw Error(`Path collides with an existing file while creating directory "${t}"`);return e}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:It(Lt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),wt(r,a),this.directories.set(a,bt()),a}createDirectoryChild(e,t){let n=fn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:It(Lt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),wt(r,a),this.directories.set(a,bt()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!V(n))throw Error(`Path is not a directory: "${t}"`);if(Bt(n,1))throw Error(`Duplicate path: "${t}"`);Vt(n,1)}getDirectoryIndex(e){let t=this.directories.get(e);if(t!==void 0)return t;throw Error(`Unknown directory child index for node ${String(e)}`)}buildPresortedFinish(e){let t=this.nodes,n=this.directories;n.set(0,xt());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(V(a)){let t=xt();n.set(e,t),r=e,i=t}let o;a.parentId===r?o=i:(o=n.get(a.parentId),r=a.parentId,i=o??null),o?.childIds.push(e)}if(!e)for(let e=t.length-1;e>=1;e--){let n=t[e];if(n==null)continue;let r=t[n.parentId];r!=null&&(r.subtreeNodeCount+=n.subtreeNodeCount,r.visibleSubtreeCount+=n.visibleSubtreeCount)}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;V(n)&&this.directories.set(t,bt());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),wt(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!V(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let e of n.childIds)r+=this.computeSubtreeCounts(e);return Et(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function jn(e,t=`closed`,n=null){let r=Nn(t);return{activeNodeCount:e.nodes.length-1,collapsedDirectoryIds:new Set,collapseNewDirectoriesByDefault:!1,defaultExpansion:r,directoriesOpenByDefault:r===`open`,hasCollapsedDirectoryOverrides:!1,directoryLoadInfoById:new Map,expandedDirectoryIds:new Set,instrumentation:n,listeners:new Map,pathCacheByNodeId:new Map([[e.rootId,{path:``,version:0}]]),pathCacheVersion:0,snapshot:e,transactionStack:[]}}function Mn(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function Nn(e){if(typeof e!=`number`)return e;if(!Number.isInteger(e)||e<0)throw Error(`initialExpansion must be "open", "closed", or a non-negative integer depth. Received: ${String(e)}`);return e}function Pn(e,t){return Bt(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion===`closed`?!1:Lt(t)<=e.defaultExpansion}function Fn(e,t,n=e.snapshot.nodes[t]){return n==null||!V(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:Pn(e,n)}function In(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!V(r))return;let i=Pn(e,r);if(n){if(i){e.collapsedDirectoryIds.delete(t),e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;return}e.expandedDirectoryIds.add(t);return}if(i){e.collapsedDirectoryIds.add(t),e.hasCollapsedDirectoryOverrides=!0;return}e.expandedDirectoryIds.delete(t)}function Ln(e,t){let n=e.directoryLoadInfoById.get(t);if(n!=null)return n;let r={activeAttemptId:null,errorMessage:null,nextAttemptId:1,state:`loaded`};return e.directoryLoadInfoById.set(t,r),r}function Rn(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function zn(e,t){let n=Ln(e,t);if(n.state===`loading`&&n.activeAttemptId!=null)return{attemptId:n.activeAttemptId,nodeId:t,reused:!0};let r=n.nextAttemptId;return n.activeAttemptId=r,n.errorMessage=null,n.nextAttemptId+=1,n.state=`loading`,{attemptId:r,nodeId:t,reused:!1}}function Bn(e,t){let n=Ln(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function Vn(e,t,n){let r=e.directoryLoadInfoById.get(t);return r==null||r.activeAttemptId!==n?!1:(r.activeAttemptId=null,r.errorMessage=null,r.state=`loaded`,!0)}function Hn(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Un(e,t,n,r){let i=e.directoryLoadInfoById.get(t);return i==null||i.activeAttemptId!==n?!1:(i.activeAttemptId=null,i.errorMessage=r??null,i.state=`error`,!0)}function Wn(e,t){e.directoryLoadInfoById.delete(t)}function Gn(e,t,n){let r=n,i=e.listeners.get(t);return i==null?e.listeners.set(t,new Set([r])):i.add(r),()=>{let n=e.listeners.get(t);n!=null&&(n.delete(r),n.size===0&&e.listeners.delete(t))}}function Kn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function qn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function Jn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function Yn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Xn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Zn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Qn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`begin-child-load`,path:e.path,projectionChanged:e.projectionChanged,reused:e.reused,visibleCountDelta:null}}function $n(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some(e=>e.canonicalChanged),childEvents:e.childEvents,operation:`apply-child-patch`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function er(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`complete-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function tr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,errorMessage:e.errorMessage,operation:`fail-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function nr(e){return{activeNodeCountAfter:e.activeNodeCountAfter,activeNodeCountBefore:e.activeNodeCountBefore,affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],cachedPathEntryCountAfter:e.cachedPathEntryCountAfter,cachedPathEntryCountBefore:e.cachedPathEntryCountBefore,canonicalChanged:!1,idsPreserved:e.idsPreserved,loadInfoEntryCountAfter:e.loadInfoEntryCountAfter,loadInfoEntryCountBefore:e.loadInfoEntryCountBefore,mode:e.mode,operation:`cleanup`,projectionChanged:e.projectionChanged,reclaimedCachedPathEntryCount:e.reclaimedCachedPathEntryCount,reclaimedLoadInfoEntryCount:e.reclaimedLoadInfoEntryCount,reclaimedNodeSlotCount:e.reclaimedNodeSlotCount,reclaimedSegmentCount:e.reclaimedSegmentCount,segmentCountAfter:e.segmentCountAfter,segmentCountBefore:e.segmentCountBefore,totalNodeSlotCountAfter:e.totalNodeSlotCountAfter,totalNodeSlotCountBefore:e.totalNodeSlotCountBefore,visibleCountDelta:null}}function rr(e,t,n){return{...n,visibleCountDelta:mr(e)-t}}function ir(e,t){let n=mr(e),r=Mn();e.transactionStack.push(r);try{t()}catch(t){throw sr(e,r,!1),t}sr(e,r,!0,mr(e)-n)}function ar(e,t){let n=e.instrumentation;if(n==null){or(e,t);return}H(n,`store.events.record`,()=>or(e,t))}function or(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){fr(e,t);return}n.events.push(t),dr(n,t)}function sr(e,t,n,r=null){if(e.transactionStack.pop()!==t)throw Error(`Transaction stack underflow`);if(!n)return;let i=e.transactionStack[e.transactionStack.length-1]??null;if(i!=null){let n=e.instrumentation;n==null?ur(i,t):H(n,`store.events.batch.merge`,()=>ur(i,t));return}let a=cr(t,r),o=e.instrumentation;if(o==null){fr(e,a);return}H(o,`store.events.batch.commit`,()=>fr(e,a))}function cr(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some(e=>e.canonicalChanged),events:[...e.events],operation:`batch`,projectionChanged:e.events.some(e=>e.projectionChanged),visibleCountDelta:t}}function lr(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function ur(e,t){for(let n of t.events)e.events.push(n);lr(e,t)}function dr(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function fr(e,t){let n=e.instrumentation;if(n==null){pr(e,t);return}H(n,`store.events.emit`,()=>pr(e,t))}function pr(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function mr(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function hr(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!V(n)||Bt(n,2))return null;let r=e.snapshot.directories.get(t);if(r==null||r.childIds.length!==1)return null;let i=r.childIds[0];if(i==null)return null;let a=e.snapshot.nodes[i];return a==null||!V(a)?null:i}function gr(e,t){let n=t;for(;;){let t=hr(e,n);if(t==null)return n;n=t}}function _r(e,t){let n=[t],r=t;for(;;){let t=hr(e,r);if(t==null)return n;n.push(t),r=t}}function vr(e,t){let n=t==null?e.snapshot.rootId:Dr(e,t);return n==null?[]:kr(e,n)}function yr(e,t){let n=cn(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Wr(e,Ur(e,r)),{createdNodeIds:a,directoryId:o}=Ar(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=G(e,o);if(Bt(n,1))throw Error(`Path already exists: "${t}"`);Vt(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=Mr(e,o,n.basename),s.add(c);wr(e,o);let l=Wr(e,o);return Kn({affectedAncestorIds:Er(e,c),affectedNodeIds:[...s],path:t,projectionChanged:Gr(i,l)})}function br(e,t,n){let r=Dr(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=G(e,r);if(Bt(i,2))throw Error(`The root node cannot be removed`);if(V(i)&&W(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=Wr(e,a),s=Vr(e,r);Fr(e,a,r,i.nameId),Hr(e,a),wr(e,a);let c=Wr(e,a);return qn({affectedAncestorIds:Er(e,a),affectedNodeIds:s,path:t,projectionChanged:Gr(o,c),recursive:n.recursive===!0})}function xr(e,t,n,r){let i=Dr(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=G(e,i);if(Bt(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=zr(e,i,n),c=Wr(e,a.parentId),l=Wr(e,s.parentId),u=pn(e.snapshot.segmentTable,a.nameId),d=fn(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(V(a)&&Yr(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=St(e.snapshot.nodes,W(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&Br(e,p,o,Rt(a))===`skip`)return null;let m=a.parentId;Fr(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),Jr(e,i),Pr(e,s.parentId,i),Hr(e,m),e.pathCacheVersion++,wr(e,m),s.parentId!==m&&wr(e,s.parentId);let h=Wr(e,m),g=Wr(e,s.parentId);return Jn({affectedAncestorIds:[...new Set([...Er(e,m),...Er(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:Kr([c,l],[h,g]),to:U(e,i)})}function Sr(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function Cr(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function U(e,t){let n=G(e,t),r=Sr(e,t);if(r!=null)return r;if(Bt(n,2))return Cr(e,t,``);let i=U(e,n.parentId),a=pn(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return Cr(e,t,V(n)?`${o}/`:o)}function wr(e,t){let n=e.instrumentation;if(n==null){Zr(e,t);return}H(n,`store.recomputeCountsUpwardFrom`,()=>Zr(e,t))}function Tr(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;for(;n.length>0;){let t=n[n.length-1],a=t[0],o=r[a];if(o==null||!V(o)){Xr(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){Xr(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function Er(e,t){let n=[],r=t;for(;r!=null;){let t=G(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function Dr(e,t){if(t.length===0)return e.snapshot.rootId;let n=ln(t);return Or(e,n.segments,n.requiresDirectory)}function Or(e,t,n){let r=e.snapshot.rootId;for(let n of t){let t=e.snapshot.segmentTable.idByValue.get(n);if(t===void 0)return null;let i=W(e,r),a=St(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=G(e,r);return n&&!V(i)?null:r}function W(e,t){let n=e.snapshot.directories.get(t);if(n===void 0)throw Error(`Unknown directory child index for node ${String(t)}`);return n}function G(e,t){let n=e.snapshot.nodes[t];if(n===void 0||Bt(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function kr(e,t){let n=e.snapshot.nodes[t];if(n===void 0||Bt(n,4))return[];if(!V(n))return[U(e,t)];if(W(e,t).childIds.length===0)return Bt(n,1)&&!Bt(n,2)?[U(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];for(;i.length>0;){let t=i[i.length-1];if(t==null)break;let n=e.snapshot.nodes[t.nodeId];if(n===void 0||Bt(n,4)){i.pop();continue}if(!V(n)){r.push(U(e,t.nodeId)),i.pop();continue}let a=W(e,t.nodeId);if(a.childIds.length===0){Bt(n,1)&&!Bt(n,2)&&r.push(U(e,t.nodeId)),i.pop();continue}let o=a.childIds[t.childIndex];if(o==null){i.pop();continue}t.childIndex++,i.push({childIndex:0,nodeId:o})}return r}function Ar(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=fn(e.snapshot.segmentTable,i),a=W(e,r),o=St(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!V(G(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=jr(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function jr(e,t,n){let r=G(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:It(Lt(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,bt()),Pr(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function Mr(e,t,n){let r=fn(e.snapshot.segmentTable,n),i=W(e,t);if(St(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${$r(e,t,n)}"`);let a=G(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:It(Lt(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),Pr(e,t,o),e.activeNodeCount++,o}function Nr(e,t,n){let r=0,i=t.childIds.length;for(;r<i;){let a=r+i>>>1,o=t.childIds[a];if(o==null){i=a;continue}Ir(e,n,o)<0?i=a:r=a+1}return r}function Pr(e,t,n){let r=W(e,t),i=G(e,n);St(e.snapshot.nodes,r).set(i.nameId,n),Dt(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=Nr(e,r,n);r.childIds.splice(a,0,n),Tt(r,a),At(e.snapshot.nodes,r)}function Fr(e,t,n,r){let i=W(e,t),a=Ct(i),o=a.get(n)??-1;St(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&Dt(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),Tt(i,o),At(e.snapshot.nodes,i))}function Ir(e,t,n){let r=e.snapshot.options.sort;return r==="default"?Lr(e,t,n):r(Rr(e,t),Rr(e,n))}function Lr(e,t,n){let r=G(e,t),i=G(e,n),a=V(r);if(a!==V(i))return a?-1:1;let o=Zt(an(e.snapshot.segmentTable,r.nameId),an(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=pn(e.snapshot.segmentTable,r.nameId),c=pn(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function Rr(e,t){let n=G(e,t),r=U(e,t),i=V(n),a=i?r.slice(0,-1):r;return{basename:pn(e.snapshot.segmentTable,n.nameId),depth:Lt(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function zr(e,t,n){let r=G(e,t),i=Dr(e,n);if(i!=null){let t=G(e,i);if(V(t))return{basename:pn(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=ln(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=ln(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:Or(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function Br(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${U(e,t)}"`);let i=G(e,t);if(Rt(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(V(i)&&W(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return Vr(e,t),Fr(e,a,t,o),Hr(e,a),wr(e,a),`handled`}function Vr(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=G(e,t.nodeId);if(t.visitedChildren||!V(i)){V(i)&&e.snapshot.directories.delete(t.nodeId),Vt(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),Wn(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=W(e,t.nodeId);for(let e=a.childIds.length-1;e>=0;e--){let t=a.childIds[e];t!=null&&r.push({nodeId:t,visitedChildren:!1})}}return n}function Hr(e,t){let n=t;for(;n!=null;){let t=G(e,n);if(!V(t)||Bt(t,2)||W(e,n).childIds.length>0)return;Vt(t,1),n=t.parentId===n?null:t.parentId}}function Ur(e,t){let n=e.snapshot.rootId;for(let r of t){let t=e.snapshot.segmentTable.idByValue.get(r);if(t==null)break;let i=St(e.snapshot.nodes,W(e,n)).get(t);if(i==null||!V(G(e,i)))break;n=i}return n}function Wr(e,t){let n=qr(e,t);if(n==null)return null;let r=gr(e,n),i=G(e,r),a=n===r?null:_r(e,n).map(t=>U(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:W(e,r).childIds.length>0,path:U(e,r),terminalKind:Rt(i)})}function Gr(e,t){return Kr([e],[t])}function Kr(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r==null||i==null||r!==i)return!0}return!1}function qr(e,t){let n=t;for(;n!=null;){let t=G(e,n);if(!V(t)||Bt(t,2))return null;if(!Fn(e,n,t))return n;n=t.parentId}return null}function Jr(e,t){let n=G(e,t);if(Ht(n,(t===e.snapshot.rootId?-1:Lt(G(e,n.parentId)))+1),!V(n))return;let r=W(e,t);for(let t of r.childIds)Jr(e,t)}function Yr(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=G(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function Xr(e,t,n=G(e,t),r=!1){let i=e.instrumentation;if(i==null){Qr(e,t,n,r);return}H(i,`store.recomputeNodeCounts`,()=>Qr(e,t,n,r))}function Zr(e,t){let n=t;for(;n!=null;){let t=G(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(Xr(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&Dt(W(e,s),n,a,o),n=s}}function Qr(e,t,n,r){if(!V(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=W(e,t);if(r){let t=e.instrumentation;t==null?Et(e.snapshot.nodes,i):H(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>Et(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,Bt(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=hr(e,t)==null?Fn(e,t,n)?1+o:1:o}function $r(e,t,n){let r=U(e,t);return r.length===0?n:`${r}${n}`}function ei(e){return e!=null&&!Bt(e,4)}function ti(e,t){let n=e.snapshot.nodes[t];return!ei(n)||!V(n)||Bt(n,2)?null:n}function ni(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&ei(e.snapshot.nodes[n])&&(t+=1);return t}function ri(e){return Math.max(0,e.valueById.length-1)}function ii(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:ni(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:ri(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function ai(e,t,n,r){return{activeNodeCountAfter:r.activeNodeCount,activeNodeCountBefore:n.activeNodeCount,cachedPathEntryCountAfter:r.cachedPathEntryCount,cachedPathEntryCountBefore:n.cachedPathEntryCount,idsPreserved:t,loadInfoEntryCountAfter:r.loadInfoEntryCount,loadInfoEntryCountBefore:n.loadInfoEntryCount,mode:e,reclaimedCachedPathEntryCount:n.cachedPathEntryCount-r.cachedPathEntryCount,reclaimedLoadInfoEntryCount:n.loadInfoEntryCount-r.loadInfoEntryCount,reclaimedNodeSlotCount:n.totalNodeSlotCount-r.totalNodeSlotCount,reclaimedSegmentCount:n.segmentCount-r.segmentCount,segmentCountAfter:r.segmentCount,segmentCountBefore:n.segmentCount,totalNodeSlotCountAfter:r.totalNodeSlotCount,totalNodeSlotCountBefore:n.totalNodeSlotCount}}function oi(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)ti(e,n)!=null&&t.push(U(e,n));for(let t of e.expandedDirectoryIds)ti(e,t)!=null&&n.push(U(e,t));return{collapsedPaths:t,expandedPaths:n}}function si(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)ti(e,n)==null||Rn(e,n)===`loaded`||t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:U(e,n)});return t}function ci(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=Dr(e,n);t!=null&&In(e,t,!0,G(e,t))}for(let n of t.collapsedPaths){let t=Dr(e,n);t!=null&&In(e,t,!1,G(e,t))}}function li(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=Dr(e,n.path);t!=null&&ti(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function ui(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function di(e){let t=e.snapshot.segmentTable,n=dn();for(let r of e.snapshot.nodes)if(ei(r)){if(Bt(r,2)){r.nameId=0;continue}r.nameId=fn(n,pn(t,r.nameId))}e.snapshot.segmentTable=n}function fi(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!ei(r)||!V(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return ei(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[G(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),Et(e.snapshot.nodes,n)}}function pi(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(ei(n))break;--t}e.snapshot.nodes.length=t+1}function mi(e){let t=oi(e),n=si(e);H(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>ui(e)),H(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>di(e)),H(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>fi(e)),H(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>pi(e)),H(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>ci(e,t)),H(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>li(e,n)),H(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>Tr(e,e.snapshot.rootId))}function hi(e){let t=oi(e),n=si(e),r=H(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>vr(e)),i=Wt({...e.snapshot.options},e.instrumentation),a=H(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new An(i);return e.appendPaths(r),e.finish()});e.snapshot=a,e.activeNodeCount=a.nodes.length-1,e.pathCacheByNodeId=new Map([[a.rootId,{path:``,version:0}]]),e.pathCacheVersion=0,H(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>ci(e,t)),H(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>li(e,n)),H(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>Tr(e,e.snapshot.rootId))}function gi(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function _i(e,t){let n=ii(e);t===`stable`?H(e.instrumentation,`store.cleanup.stable`,()=>mi(e)):H(e.instrumentation,`store.cleanup.aggressive`,()=>hi(e));let r=ii(e);return ai(t,t===`stable`,n,r)}var vi=64;function yi(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;for(;r<n;)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function bi(e){return G(e,e.snapshot.rootId).visibleSubtreeCount}function xi(e,t,n,r){let i=G(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function Si(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:Vi(e,t.cursor),setSize:t.setSize,subtreeEndIndex:xi(e,t.cursor,t.index,n)}}function Ci(e,t,n,r,i,a){let o=W(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=Ot(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return wi(e,u,l,r+c,i+1,s,o.childIds.length,a)}function wi(e,t,n,r,i,a,o,s){if(!V(G(e,t))){if(n===0)return{ancestors:s,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:a,setSize:o};throw Error(`Visible index ${String(n)} is out of range for file`)}let c=Fi(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=G(e,c.terminalNodeId);if(!V(l)||!Fn(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Ci(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function Ti(e,t){let n=bi(e);if(t<0||t>=n)return null;let r=Ci(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>U(e,t.cursor.terminalNodeId)),a=null;return{ancestorPaths:i,get ancestorRows(){if(a!=null)return a;let t=[],i=[];for(let a of r.ancestors){let r=Si(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:Vi(e,r.cursor),setSize:r.setSize,subtreeEndIndex:xi(e,r.cursor,r.index,n)}}function Ei(e,t,n){let r=e.instrumentation,i=bi(e);if(i<=0||n<t)return[];let a=Math.max(0,Math.min(t,i-1)),o=Math.max(a,Math.min(n,i-1));if(r==null){if(a===0)return Bi(e,o+1);let t=[],n=Mi(e,a);for(let r=a;r<=o&&n!=null;r++){let r=Vi(e,n);t.push(r),n=Li(e,n)}return t}let s=[],c=0,l=0,u=H(r,`store.getVisibleSlice.selectFirstRow`,()=>Mi(e,a));for(let t=a;t<=o&&u!=null;t++){let t=H(r,`store.getVisibleSlice.materializeRow`,()=>Vi(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=H(r,`store.getVisibleSlice.advanceCursor`,()=>Li(e,u))}return Kt(r,`workload.visibleRowsRead`,s.length),Kt(r,`workload.flattenedRowsRead`,c),Kt(r,`workload.flattenedSegmentsRead`,l),s}function Di(e,t=bi(e)){let n=e.instrumentation;return n==null?zi(e,t):H(n,`store.getVisibleTreeProjection`,()=>zi(e,t))}function Oi(e){return Ri(Di(e))}function ki(e,t){let n=Dr(e,t);if(n==null||n===e.snapshot.rootId||V(G(e,n))&&gr(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=G(e,i).parentId,n=W(e,t),s=Ct(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=kt(a,n,s),t!==o){let n=G(e,t),a=hr(e,t);if(!Fn(e,t,n)&&a!==i)return null;gr(e,t)===t&&(r+=1)}i=t}return r}function Ai(e,t){let n=Dr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=G(e,n);if(!V(r))throw Error(`Path is not a directory: "${t}"`);return Fn(e,n,r)?null:(In(e,n,!0,r),wr(e,n),Yn({affectedAncestorIds:Er(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function ji(e,t){let n=Dr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=G(e,n);if(!V(r))throw Error(`Path is not a directory: "${t}"`);return Fn(e,n,r)?(In(e,n,!1,r),wr(e,n),Xn({affectedAncestorIds:Er(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function Mi(e,t){return t<0||t>=bi(e)?null:Ni(e,e.snapshot.rootId,t,-1)}function Ni(e,t,n,r){let i=W(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?Ot(e.snapshot.nodes,i,n):H(a,`store.getVisibleSlice.selectChildIndex`,()=>Ot(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return Pi(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Pi(e,t,n,r){if(!V(G(e,t))){if(n===0)return{headNodeId:t,terminalNodeId:t,visibleDepth:r};throw Error(`Visible index ${String(n)} is out of range for file`)}let i=Fi(e,t,r);if(n===0)return i;let a=G(e,i.terminalNodeId);if(!V(a)||!Fn(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Ni(e,i.terminalNodeId,n-1,i.visibleDepth)}function Fi(e,t,n){return V(G(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:gr(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:H(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>gr(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function Ii(e,t){let n=G(e,t);if(!V(n))return!0;let r=n.parentId;return r===e.snapshot.rootId?!0:hr(e,r)!==t}function Li(e,t){let n=G(e,t.terminalNodeId);if(V(n)){let r=W(e,t.terminalNodeId);if(Fn(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:Pi(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=G(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=W(e,n),o=Ct(a).get(r)??-1;if(o<0)throw Error(`Child ${String(r)} was not found in its parent index`);let s=a.childIds[o+1]??null;if(s!=null)return Pi(e,s,0,i);Ii(e,r)&&i--,r=n}}function Ri(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let t=e.getParentIndex(r);n[r]={index:r,parentPath:t>=0?e.paths[t]??null:null,path:e.paths[r]??``,posInSet:e.posInSetByIndex[r]??0,setSize:e.setSizeByIndex[r]??0}}return{getParentIndex:e.getParentIndex,rows:n,get visibleIndexByPath(){return e.visibleIndexByPath}}}function zi(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(vi);o.fill(-1);let s=0,{nodes:c,directories:l,segmentTable:u}=e.snapshot,d=[[l.get(e.snapshot.rootId),0,-1,``]],f=e.snapshot.options.flattenEmptyDirectories,p=e.pathCacheByNodeId,m=e.pathCacheVersion,h=u.valueById;for(;d.length>0&&s<t;){let t=d[d.length-1],u=t[0];if(t[1]>=u.childIds.length){d.pop();continue}let g=t[1],_=u.childIds[t[1]++],v=c[_],y=t[2]+1,b=t[3];o=yi(o,y);let x,S=_;if(V(v))S=f?gr(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:U(e,S);else{let e=p.get(_);x=e!=null&&e.version===m?e.path:`${b}${h[v.nameId]}`}r[s]=o[y],n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let C=c[S];C!=null&&V(C)&&Fn(e,S,C)&&d.push([l.get(S),0,y,x])}s<t&&(n.length=s);let g=r.subarray(0,s),_=i.subarray(0,s),v=a.subarray(0,s),y=null;return{getParentIndex(e){return e<0||e>=s?-1:g[e]??-1},paths:n,posInSetByIndex:_,setSizeByIndex:v,get visibleIndexByPath(){if(y==null){y=new Map;for(let e=0;e<s;e+=1)y.set(n[e]??``,e)}return y}}}function Bi(e,t){let n=Array(t),r=0,{nodes:i,directories:a,segmentTable:o}=e.snapshot,s=[[a.get(e.snapshot.rootId),0,-1]],c=o.valueById,l=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,d=e.pathCacheVersion;for(;s.length>0&&r<t;){let t=s[s.length-1],o=t[0];if(t[1]>=o.childIds.length){s.pop();continue}let f=o.childIds[t[1]++],p=i[f],m=t[2]+1;if(!V(p)){let t=u.get(f);n[r++]={depth:m,flattenedSegments:void 0,hasChildren:!1,id:f,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:`file`,loadState:void 0,name:c[p.nameId],path:t!=null&&t.version===d?t.path:U(e,f)};continue}let h=l?gr(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=Vi(e,g);let _=i[h];_!=null&&V(_)&&Fn(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function Vi(e,t){let n=G(e,t.terminalNodeId),r=V(n)?Hi(e,t):null,i=U(e,t.terminalNodeId),a=pn(e.snapshot.segmentTable,n.nameId),o=V(n)&&W(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?_r(e,t.headNodeId).map(n=>{let r=G(e,n);return{isTerminal:n===t.terminalNodeId,name:pn(e.snapshot.segmentTable,r.nameId),nodeId:n,path:U(e,n)}}):H(c,`store.getVisibleSlice.flatten.collectSegments`,()=>_r(e,t.headNodeId).map(n=>{let r=G(e,n);return{isTerminal:n===t.terminalNodeId,name:pn(e.snapshot.segmentTable,r.nameId),nodeId:n,path:U(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:V(n)&&Fn(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:V(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function Hi(e,t){if(t.headNodeId===t.terminalNodeId)return Rn(e,t.terminalNodeId);let n=_r(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=Rn(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}function Ui(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:a}=e.snapshot,o=r.flattenEmptyDirectories===!0,s=e=>{let r=n[e];if(r==null||!V(r))return;let i=t.get(e);if(i==null)throw Error(`Unknown directory child index for node ${String(e)}`);let a=i.childIds,s=a.length,c=0,l=0;for(let e=0;e<s;e++){let t=a[e];if(t==null)continue;let r=n[t];c+=r.subtreeNodeCount,l+=r.visibleSubtreeCount}i.totalChildSubtreeNodeCount=c,i.totalChildVisibleSubtreeCount=l,s>=128&&At(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&V(e)?l:1+l}else u=1+l;r.visibleSubtreeCount=u};if(a!=null)for(let e=a.length-1;e>=0;e--)s(a[e]);else for(let e=n.length-1;e>=1;e--)s(e);let c=n[i],l=t.get(i);if(c==null||l==null)return;let u=l.childIds,d=0,f=0;for(let e=0;e<u.length;e++){let t=u[e];if(t==null)continue;let r=n[t];d+=r.subtreeNodeCount,f+=r.visibleSubtreeCount}l.totalChildSubtreeNodeCount=d,l.totalChildVisibleSubtreeCount=f,At(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Wi(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var Gi=class e{#e;constructor(e={}){let t=Gt(e),n=H(t,`store.builder.create`,()=>new An(e));if(e.preparedInput!=null){let t=Dn(e.preparedInput);t==null?n.appendPreparedPaths(En(e.preparedInput),!1):n.appendPresortedPaths(t,On(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(H(t,`store.preparePathEntries`,()=>kn(r,e)))}let r=H(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=H(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=H(t,`store.state.create`,()=>jn(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:H(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||Wi(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&H(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?H(t,`store.state.initializeOpenVisibleCounts`,()=>Ui(this.#e)):H(t,`store.state.recomputeCounts`,()=>Tr(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return Cn(e,t)}static prepareInput(e,t={}){return wn(e,t)}static preparePresortedInput(e){return Tn(e)}list(e){return H(this.#e.instrumentation,`store.list`,()=>vr(this.#e,e))}add(e){H(this.#e.instrumentation,`store.add`,()=>{let t=bi(this.#e);ar(this.#e,rr(this.#e,t,yr(this.#e,e)))})}remove(e,t={}){H(this.#e.instrumentation,`store.remove`,()=>{let n=bi(this.#e);ar(this.#e,rr(this.#e,n,br(this.#e,e,t)))})}move(e,t,n={}){H(this.#e.instrumentation,`store.move`,()=>{let r=bi(this.#e),i=xr(this.#e,e,t,n);i!=null&&ar(this.#e,rr(this.#e,r,i))})}batch(e){ir(this.#e,()=>{if(typeof e==`function`){e(this);return}for(let t of e)switch(t.type){case`add`:this.add(t.path);break;case`remove`:this.remove(t.path,{recursive:t.recursive});break;case`move`:this.move(t.from,t.to,{collision:t.collision});break}})}getVisibleCount(){return H(this.#e.instrumentation,`store.getVisibleCount`,()=>bi(this.#e))}getVisibleSlice(e,t){return H(this.#e.instrumentation,`store.getVisibleSlice`,()=>Ei(this.#e,e,t))}getVisibleRowContext(e){return H(this.#e.instrumentation,`store.getVisibleRowContext`,()=>Ti(this.#e,e))}getVisibleTreeProjection(){return Oi(this.#e)}getVisibleTreeProjectionData(e){return Di(this.#e,e)}getVisibleIndex(e){return H(this.#e.instrumentation,`store.getVisibleIndex`,()=>ki(this.#e,e))}getPathInfo(e){return H(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=Dr(this.#e,e);if(t==null)return null;let n=G(this.#e,t);return{depth:Lt(n),kind:V(n)?`directory`:`file`,path:U(this.#e,t)}})}isExpanded(e){return H(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=G(this.#e,t);return Fn(this.#e,t,n)})}expand(e){H(this.#e.instrumentation,`store.expand`,()=>{let t=bi(this.#e),n=Ai(this.#e,e);n!=null&&ar(this.#e,rr(this.#e,t,n))})}collapse(e){H(this.#e.instrumentation,`store.collapse`,()=>{let t=bi(this.#e),n=ji(this.#e,e);n!=null&&ar(this.#e,rr(this.#e,t,n))})}on(e,t){return Gn(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return Rn(this.#e,t)}markDirectoryUnloaded(e){H(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(W(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=bi(this.#e);Bn(this.#e,t),ar(this.#e,rr(this.#e,n,Zn({affectedAncestorIds:Er(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return H(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=bi(this.#e),r=zn(this.#e,t);return ar(this.#e,rr(this.#e,n,Qn({affectedAncestorIds:Er(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return H(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||Rn(this.#e,n)!==`loading`||!Hn(this.#e,n,e.attemptId))return!1;let r=U(this.#e,n);this.validateChildPatch(r,t);let i=bi(this.#e),a=[];for(let e of t.operations){Ki(r,e);let t=bi(this.#e);switch(e.type){case`add`:a.push(rr(this.#e,t,yr(this.#e,e.path)));break;case`remove`:a.push(rr(this.#e,t,br(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=xr(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(rr(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return ar(this.#e,rr(this.#e,i,$n({affectedAncestorIds:Er(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:U(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return H(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=bi(this.#e),r=Vn(this.#e,t,e.attemptId);return ar(this.#e,rr(this.#e,n,er({affectedAncestorIds:Er(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:U(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return H(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=bi(this.#e),i=Un(this.#e,n,e.attemptId,t);return ar(this.#e,rr(this.#e,r,tr({affectedAncestorIds:Er(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:U(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return H(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(gi(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=bi(this.#e),n=_i(this.#e,e.mode??`stable`);return ar(this.#e,rr(this.#e,t,nr({...n,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:n.idsPreserved===!1}))),n})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(e){if(e==null||e.length===0)return 0;let t=0,n=[],r=[],i=0,a=null,o=this.#e.snapshot.segmentTable,s=o.valueById,c=this.#e.snapshot.nodes,l=new Map;for(let u of e){a!=null&&u<a&&(a=null,i=0,n.length=0,r.length=0);let e=u.length>0&&u.charCodeAt(u.length-1)===47?u.length-1:u.length;if(e===0){a=u,i=e,n.length=0,r.length=0;continue}let d=0,f=0;if(a!=null){let t=Math.min(e,i),n=!0;for(let e=0;e<t;e+=1){let t=u.charCodeAt(e);if(t!==a.charCodeAt(e)){n=!1;break}t===47&&(d+=1,f=e+1)}n&&(t===i&&e>t&&u.charCodeAt(t)===47?(d+=1,f=t+1):t===e&&i>t&&a.charCodeAt(t)===47&&(d+=1,f=e+1)),d=Math.min(d,r.length)}let p=d===0?this.#e.snapshot.rootId:r[d-1]??this.#e.snapshot.rootId,m=d,h=!0,g=f;for(;g<=e;){let t=u.indexOf(`/`,g),i=t===-1||t>e?e:t,a=u.slice(g,i),f=W(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??Yt(a);l.set(a,b);let x=(e,t)=>{for(v=e;v<t;v+=1){let e=f[v],t=c[e],n=s[t.nameId];if(n===a)return y=e,!0;let r=Zt(an(o,t.nameId),b);if(r>0||r===0&&n>a)return!1}return!1};if(!x(_,f.length)&&_>0&&x(0,_),y===void 0){h=!1;break}if(!V(G(this.#e,y))){h=!1;break}if(n[m]=v,r[m]=y,p=y,m+=1,i===e)break;g=i+1}if(a=u,i=e,n.length=m,r.length=m,!h){a=null,i=0,n.length=0,r.length=0;continue}for(let e=d;e<m;e+=1){let n=r[e];if(n==null)continue;let i=G(this.#e,n);Fn(this.#e,n,i)||(In(this.#e,n,!0,i),t+=1)}}return t}hasAllDirectoriesExpanded(){for(let e of this.#e.snapshot.directories.keys()){if(e===this.#e.snapshot.rootId)continue;let t=G(this.#e,e);if(!Fn(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=Dr(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!V(G(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!V(G(this.#e,e)))throw Error(`Node is not a directory: ${String(e)}`);return e}catch{return null}}isDirectoryProjectionVisible(e){let t=e;for(;t!==this.#e.snapshot.rootId;){let e=G(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=G(this.#e,e),r=hr(this.#e,e);if(!Fn(this.#e,e,n)&&r!==t)return!1}t=e}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function Ki(e,t){switch(t.type){case`add`:case`remove`:if(!t.path.startsWith(e)||t.path===e)throw Error(`Child patch operation must stay within ${e}: "${t.path}"`);break;case`move`:if(!t.from.startsWith(e)||!t.to.startsWith(e)||t.from===e||t.to===e)throw Error(`Child patch move must stay within ${e}: "${t.from}" -> "${t.to}"`);break}}var qi={compact:{itemHeight:24,factor:.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function Ji(e,t){if(typeof e==`number`)return{itemHeight:t??qi.default.itemHeight,factor:e};let n=qi[e??`default`];return{itemHeight:t??n.itemHeight,factor:n.factor}}var Yi=qi.default.itemHeight,Xi=`@layer base, theme, unsafe;
2
2
 
3
3
  @layer base {
4
4
  :host {
@@ -2226,5 +2226,5 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}f
2226
2226
  ) !important;
2227
2227
  color: var(--diffs-selection-number-fg) !important;
2228
2228
  }
2229
- `;function Sm(e){let t=(0,Yp.c)(5),n=ce(e.environmentId,e.resource),[r,i]=(0,Y.useState)(null);if(n._tag===`Failure`||n._tag===`Success`&&r===n.url){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load image.`}),t[0]=e):e=t[0],e}let a;return t[1]!==n._tag||t[2]!==n.url||t[3]!==e.alt?(a=n._tag===`Success`?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,X.jsx)(`img`,{className:`max-h-full max-w-full object-contain`,src:n.url,alt:e.alt,onError:()=>i(n.url)})}):(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,X.jsx)(_,{className:`size-5 animate-spin`})}),t[1]=n._tag,t[2]=n.url,t[3]=e.alt,t[4]=a):a=t[4],a}function Cm(e,t){let n=1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);r===10?n+=1:r===13&&(n+=1,e.charCodeAt(t+1)===10&&(t+=1))}return Math.min(Math.max(1,t),n)}function wm(e,t){let n=e.shadowRoot??e;for(let e of n.querySelectorAll(`[${bm}]`))e.removeAttribute(bm);t!==null&&(n.querySelector(`[data-line="${t}"]`)?.setAttribute(bm,``),n.querySelector(`[data-column-number="${t}"]`)?.setAttribute(bm,``))}function Tm(e,t,n){let r=(0,Yp.c)(7),[i]=(0,Y.useState)(Om),[a]=(0,Y.useState)(Dm),[o]=(0,Y.useState)(Em),s;return r[0]!==i||r[1]!==a||r[2]!==o||r[3]!==e||r[4]!==t||r[5]!==n?(s=(r,s,c)=>{if(e===null)return;let l=()=>{let t=o.get(e);t!==void 0&&(cancelAnimationFrame(t),o.delete(e))};if(c===`unmount`){l();return}let u=t===null?null:Cm(s.file?.contents??``,t);if(wm(r,u),!(s instanceof N))return;if(a.get(e)!==n&&(l(),a.set(e,n)),u===null){r.style.minHeight=``;return}let d=r.closest(`.file-preview-virtualizer`);!d||(r.style.minHeight=`${Math.ceil(Math.max(s.height,d.clientHeight))}px`,i.get(e)===n||o.has(e))||o.set(e,requestAnimationFrame(()=>{if(o.delete(e),a.get(e)!==n||!r.isConnected)return;let t=s.getLinePosition(u);if(!t)return;let c=d.scrollTop+r.getBoundingClientRect().top-d.getBoundingClientRect().top,l=Math.max(0,c+t.top-Math.max(0,(d.clientHeight-t.height)/2)),f=Math.max(0,d.scrollHeight-d.clientHeight);d.scrollTop=Math.min(l,f),i.set(e,n)}))},r[0]=i,r[1]=a,r[2]=o,r[3]=e,r[4]=t,r[5]=n,r[6]=s):s=r[6],s}function Em(){return new Map}function Dm(){return new Map}function Om(){return new Map}function km(e){let t=(0,Yp.c)(19),{environmentId:n,cwd:r,relativePath:i,onPendingChange:a}=e,o=u(re.writeFile),s;t[0]!==a||t[1]!==i?(s=e=>a(i,e),t[0]=a,t[1]=i,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n||t[5]!==i||t[6]!==o?(c=e=>o({environmentId:n,input:{cwd:r,relativePath:i,contents:e}}),t[3]=r,t[4]=n,t[5]=i,t[6]=o,t[7]=c):c=t[7];let l;t[8]!==r||t[9]!==n||t[10]!==i?(l=e=>{ke(n,r,i,e)},t[8]=r,t[9]=n,t[10]=i,t[11]=l):l=t[11];let d;t[12]!==s||t[13]!==c||t[14]!==l?(d=new _m({debounceMs:ym,onPendingChange:s,persist:c,onConfirmed:l}),t[12]=s,t[13]=c,t[14]=l,t[15]=d):d=t[15];let f=d,p,m;return t[16]===f?(p=t[17],m=t[18]):(p=()=>()=>f.dispose(),m=[f],t[16]=f,t[17]=p,t[18]=m),(0,Y.useEffect)(p,m),f}function Am(e){let t=(0,Yp.c)(73),{environmentId:n,cwd:r,relativePath:i,composerDraftTarget:a,contents:o,resolvedTheme:s,revealRequestId:c,wordWrap:l,onPostRender:u,onPendingChange:f}=e,p=d(Lm),h=d(Im),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],t[0]=g):g=t[0];let[_,v]=(0,Y.useState)(g),[y,b]=(0,Y.useState)(null),x=y?.revealRequestId===c?y.range:null,S;t[1]===c?S=t[2]:(S=e=>{b({revealRequestId:c,range:e})},t[1]=c,t[2]=S);let C=S,w=(0,Y.useRef)(null),T=(0,Y.useRef)(null),E;t[3]!==r||t[4]!==n||t[5]!==f||t[6]!==i?(E={environmentId:n,cwd:r,relativePath:i,onPendingChange:f},t[3]=r,t[4]=n,t[5]=f,t[6]=i,t[7]=E):E=t[7];let D=km(E),O=(0,Y.useRef)(null),k;t[8]!==p||t[9]!==a||t[10]!==r||t[11]!==n||t[12]!==i||t[13]!==D?(k=(e,t)=>{if(Re(n,r,i,e.contents),D.change(e.contents),t){let n=it(t);v(n);for(let t of n)for(let n of t.metadata.entries)n.kind===`comment`&&p(a,m({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:n.text,contents:e.contents}))}},t[8]=p,t[9]=a,t[10]=r,t[11]=n,t[12]=i,t[13]=D,t[14]=k):k=t[14];let A=k,ee;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(ee=e=>{let t=new Vp(e);return O.current=t,t},t[15]=ee):ee=t[15];let j=ee,M,N;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>()=>{O.current?.cleanUp(),O.current=null},N=[],t[16]=M,t[17]=N):(M=t[16],N=t[17]),(0,Y.useEffect)(M,N);let P;t[18]!==a||t[19]!==h||t[20]!==C?(P=e=>{C(null),h(a,e),v(t=>t.flatMap(t=>{let n=t.metadata.entries.filter(t=>t.id!==e);return n.length>0?[{...t,metadata:{entries:n}}]:[]}))},t[18]=a,t[19]=h,t[20]=C,t[21]=P):P=t[21];let te=P,ne;t[22]!==p||t[23]!==a||t[24]!==o||t[25]!==_||t[26]!==i||t[27]!==C?(ne=(e,t)=>{C(null);let n=_.flatMap(Fm).find(t=>t.id===e);n&&p(a,m({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:t,contents:o})),v(n=>n.map(n=>({...n,metadata:{entries:n.metadata.entries.map(n=>n.id===e?{...n,kind:`comment`,text:t}:n)}})))},t[22]=p,t[23]=a,t[24]=o,t[25]=_,t[26]=i,t[27]=C,t[28]=ne):ne=t[28];let F=ne,re;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>{let{startLine:t,endLine:n}=z(e),r={id:at(),kind:`draft`,startLine:t,endLine:n,text:``};v(e=>{let t=e.flatMap(Nm),i=t.findIndex(e=>e.lineNumber===n);return i<0?[...t,{lineNumber:n,metadata:{entries:[r]}}]:t.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,r]}}:e)})},t[29]=re):re=t[29];let ie=re,ae;t[30]===_?ae=t[31]:(ae=_.some(jm),t[30]=_,t[31]=ae);let oe=ae,se,ce;t[32]!==oe||t[33]!==C?(se=()=>{let e=w.current;if(e)return dm({root:e,resolveEditor:()=>O.current,isBlocked:()=>oe,onDismiss:()=>C(null)})},ce=[oe,C],t[32]=oe,t[33]=C,t[34]=se,t[35]=ce):(se=t[34],ce=t[35]),(0,Y.useEffect)(se,ce);let le;t[36]===C?le=t[37]:(le=e=>{C(e),e&&ie(e)},t[36]=C,t[37]=le);let ue=le,de;t[38]!==u||t[39]!==x?(de=(e,t,n)=>{u(e,t,n),T.current!==null&&(cancelAnimationFrame(T.current),T.current=null),n!==`unmount`&&(T.current=requestAnimationFrame(()=>{T.current=null,e.isConnected&&t.setSelectedLines(x,{notify:!1})}))},t[38]=u,t[39]=x,t[40]=de):de=t[40];let fe=de,I;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(I={overscrollSize:600,intersectionObserverMargin:1200},t[41]=I):I=t[41];let me;t[42]!==o||t[43]!==r||t[44]!==i?(me=pm(r,i,o),t[42]=o,t[43]=r,t[44]=i,t[45]=me):me=t[45];let L;t[46]!==o||t[47]!==i||t[48]!==me?(L={name:i,contents:o,cacheKey:me},t[46]=o,t[47]=i,t[48]=me,t[49]=L):L=t[49];let he=!oe,ge=!oe,_e=l?`wrap`:`scroll`,ve;t[50]===s?ve=t[51]:(ve=Be(s),t[50]=s,t[51]=ve);let ye;t[52]!==ue||t[53]!==fe||t[54]!==s||t[55]!==C||t[56]!==he||t[57]!==ge||t[58]!==_e||t[59]!==ve?(ye={disableFileHeader:!0,enableGutterUtility:he,enableLineSelection:ge,onGutterUtilityClick:C,onLineSelectionChange:C,onLineSelectionEnd:ue,overflow:_e,theme:ve,themeType:s,unsafeCSS:xm,onPostRender:fe},t[52]=ue,t[53]=fe,t[54]=s,t[55]=C,t[56]=he,t[57]=ge,t[58]=_e,t[59]=ve,t[60]=ye):ye=t[60];let be;t[61]!==te||t[62]!==F?(be=e=>(0,X.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,X.jsx)(rt,{kind:e.kind,rangeLabel:B(e.startLine,e.endLine),text:e.text,onCancel:()=>te(e.id),onComment:t=>F(e.id,t),onDelete:()=>te(e.id)},e.id))}),t[61]=te,t[62]=F,t[63]=be):be=t[63];let xe;t[64]===A?xe=t[65]:(xe={onChange:A},t[64]=A,t[65]=xe);let Se;return t[66]!==_||t[67]!==x||t[68]!==L||t[69]!==ye||t[70]!==be||t[71]!==xe?(Se=(0,X.jsx)(pe,{createEditor:j,children:(0,X.jsx)(`div`,{ref:w,className:`flex min-h-0 flex-1`,children:(0,X.jsx)(nt,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:I,children:(0,X.jsx)(ql,{file:L,options:ye,selectedLines:x,lineAnnotations:_,renderAnnotation:be,className:`min-h-full`,edit:!0,editorOptions:xe})})})}),t[66]=_,t[67]=x,t[68]=L,t[69]=ye,t[70]=be,t[71]=xe,t[72]=Se):Se=t[72],Se}function jm(e){return e.metadata.entries.some(Mm)}function Mm(e){return e.kind===`draft`}function Nm(e){let t=e.metadata.entries.filter(Pm);return t.length>0?[{...e,metadata:{entries:t}}]:[]}function Pm(e){return e.kind!==`draft`}function Fm(e){return e.metadata.entries}function Im(e){return e.removeReviewComment}function Lm(e){return e.addReviewComment}function Rm(e){let t=(0,Yp.c)(17),{environmentId:n,cwd:r,relativePath:i,contents:a,threadRef:o,readOnly:s,onPendingChange:c}=e,l;t[0]!==r||t[1]!==n||t[2]!==c||t[3]!==i?(l={environmentId:n,cwd:r,relativePath:i,onPendingChange:c},t[0]=r,t[1]=n,t[2]=c,t[3]=i,t[4]=l):l=t[4];let u=km(l),d;t[5]!==a||t[6]!==r||t[7]!==n||t[8]!==s||t[9]!==i||t[10]!==u?(d=s?{}:{onTaskListChange:e=>{let{markerOffset:t,checked:o}=e,s=We(n,r,i)?.contents??a,c=gm(s,t,o);c!==s&&(Re(n,r,i,c),u.change(c))}},t[5]=a,t[6]=r,t[7]=n,t[8]=s,t[9]=i,t[10]=u,t[11]=d):d=t[11];let f;return t[12]!==a||t[13]!==r||t[14]!==d||t[15]!==o?(f=(0,X.jsx)(T,{className:`min-h-0 flex-1`,children:(0,X.jsx)(we,{text:a,cwd:r,threadRef:o,className:`mx-auto max-w-4xl px-6 py-5`,...d})}),t[12]=a,t[13]=r,t[14]=d,t[15]=o,t[16]=f):f=t[16],f}function zm(){try{return o(vm,f)??!0}catch(e){return console.error(e),!0}}function Bm(e){let t=(0,Yp.c)(101),{environmentId:n,cwd:r,projectName:o,workspaceRoot:c,relativePath:l,absolutePath:d,isOutsideWorkspace:f,threadRef:m,composerDraftTarget:h,keybindings:g,availableEditors:k,revealLine:N,revealRequestId:P,onOpenFile:te,onPendingChange:ne}=e,{resolvedTheme:F}=ee(),re=be(Hm),ie=s(),ae=A(n),oe;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(oe={reportFailure:!1},t[0]=oe):oe=t[0];let se=Me(le.createUrl,oe),ce;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(ce={reportFailure:!1},t[1]=ce):ce=t[1];let ue=u(i.open,ce),de;t[2]===l?de=t[3]:(de=l!==null&&E(l),t[2]=l,t[3]=de);let fe=de,I=je(n,r,l,!fe,d),[pe,me]=(0,Y.useState)(zm),[L,he]=(0,Y.useState)(!1),ge;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(ge={path:null,revealRequestId:null},t[4]=ge):ge=t[4];let[_e,ve]=(0,Y.useState)(ge),ye=(0,Y.useRef)(null),xe;t[5]===l?xe=t[6]:(xe=l?hm(l):!1,t[5]=l,t[6]=xe);let Se=xe,R=Se&&_e.path===l&&(N===null||_e.revealRequestId===P),we;t[7]===l?we=t[8]:(we=l!==null&&p()&&Ue(l),t[7]=l,t[8]=we);let Te=we,De;t[9]!==r||t[10]!==d||t[11]!==l?(De=d??(l?y(l,r):null),t[9]=r,t[10]=d,t[11]=l,t[12]=De):De=t[12];let Oe=De,ke;t[13]!==Oe||t[14]!==m.threadId||t[15]!==c?(ke=Oe===null?null:w({filePath:Oe,threadId:m.threadId,workspaceRoot:c,allowLocalFiles:!0}),t[13]=Oe,t[14]=m.threadId,t[15]=c,t[16]=ke):ke=t[16];let Ae=ke,Ne;t[17]!==r||t[18]!==f||t[19]!==o||t[20]!==l?(Ne=l?mm(f?r:o,l):[],t[17]=r,t[18]=f,t[19]=o,t[20]=l,t[21]=Ne):Ne=t[21];let Pe=Ne,Fe=Tm(l,N,P),Ie;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=()=>{(ye.current?.querySelector(`[data-current-file-crumb='true']`))?.scrollIntoView({block:`nearest`,inline:`end`})},t[22]=Ie):Ie=t[22];let Re;t[23]===l?Re=t[24]:(Re=[l],t[23]=l,t[24]=Re),(0,Y.useEffect)(Ie,Re);let ze;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ze=()=>{me(Vm)},t[25]=ze):ze=t[25];let Ve=ze,He;t[26]!==Oe||t[27]!==se||t[28]!==ae||t[29]!==ue||t[30]!==F||t[31]!==m||t[32]!==c?(He=()=>{!Oe||!ae||(async()=>{let e=await Ze({threadRef:m,filePath:Oe,httpBaseUrl:ae,workspaceRoot:c,allowLocalFiles:!0,theme:F,createAssetUrl:se,openPreview:ue});if(e._tag===`Success`||v(e))return;let t=D(e);C.add(b({type:`error`,title:`Unable to open file in browser`,description:t instanceof Error?t.message:`An error occurred.`}))})()},t[26]=Oe,t[27]=se,t[28]=ae,t[29]=ue,t[30]=F,t[31]=m,t[32]=c,t[33]=He):He=t[33];let We=He,Ge;t[34]!==Oe||t[35]!==k||t[36]!==h||t[37]!==r||t[38]!==n||t[39]!==I||t[40]!==Ae||t[41]!==fe||t[42]!==Se||t[43]!==f||t[44]!==g||t[45]!==Fe||t[46]!==ne||t[47]!==ie||t[48]!==l||t[49]!==R||t[50]!==F||t[51]!==P||t[52]!==m||t[53]!==re?(Ge=l&&fe&&Ae?(0,X.jsx)(Sm,{environmentId:n,resource:Ae,alt:l},Oe??l):l&&I.error&&I.data===null?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:I.error}):l&&I.data===null?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,X.jsx)(_,{className:`size-5 animate-spin`})}):l&&I.data?I.data.binary&&Oe?(0,X.jsx)(om,{environmentId:n,keybindings:g,availableEditors:k,absolutePath:Oe,name:l.slice(l.lastIndexOf(`/`)+1),byteLength:I.data.byteLength,canRevealInFileManager:n===ie&&x()}):Se&&R?(0,X.jsx)(Rm,{environmentId:n,cwd:r,relativePath:l,threadRef:m,contents:I.data.contents,readOnly:f,onPendingChange:ne}):I.data.truncated||f?(0,X.jsx)(nt,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:{overscrollSize:600,intersectionObserverMargin:1200},children:(0,X.jsx)(ql,{file:{name:l,contents:I.data.contents,cacheKey:pm(r,l,I.data.contents)},options:{disableFileHeader:!0,overflow:re?`wrap`:`scroll`,theme:Be(F),themeType:F,unsafeCSS:xm,onPostRender:Fe},className:`min-h-full`})},`${l}:${F}:${I.data.byteLength}`):(0,X.jsx)(Am,{environmentId:n,cwd:r,relativePath:l,composerDraftTarget:h,contents:I.data.contents,resolvedTheme:F,revealRequestId:P,wordWrap:re,onPostRender:Fe,onPendingChange:ne},`${l}:${F}`):null,t[34]=Oe,t[35]=k,t[36]=h,t[37]=r,t[38]=n,t[39]=I,t[40]=Ae,t[41]=fe,t[42]=Se,t[43]=f,t[44]=g,t[45]=Fe,t[46]=ne,t[47]=ie,t[48]=l,t[49]=R,t[50]=F,t[51]=P,t[52]=m,t[53]=re,t[54]=Ge):Ge=t[54];let Ke=Ge,Je;t[55]!==Oe||t[56]!==k||t[57]!==Pe||t[58]!==Te||t[59]!==n||t[60]!==L||t[61]!==pe||t[62]!==We||t[63]!==Se||t[64]!==g||t[65]!==ie||t[66]!==o||t[67]!==l||t[68]!==R||t[69]!==P?(Je=l?(0,X.jsxs)(`div`,{className:`surface-subheader gap-2 px-3`,"data-surface-subheader":!0,children:[(0,X.jsx)(T,{ref:ye,hideScrollbars:!0,scrollFade:!0,className:`min-w-0 flex-1 rounded-none`,"data-file-breadcrumbs":!0,children:(0,X.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center text-xs`,children:Pe.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center`,"data-current-file-crumb":e.kind===`file`,children:[t>0?(0,X.jsx)(S,{className:`mx-1 size-3.5 shrink-0 text-muted-foreground/60`}):null,(0,X.jsx)(`span`,{className:a(`max-w-40 truncate`,e.kind===`file`?`font-medium text-foreground`:`text-muted-foreground`),title:e.path||o,children:e.label})]},e.path||`project`))})}),Oe&&n===ie?(0,X.jsx)(Ce,{environmentId:n,keybindings:g,availableEditors:k,openInCwd:Oe,compact:!0,enableShortcut:!1}):null,Se?(0,X.jsxs)(O,{children:[(0,X.jsx)(j,{render:(0,X.jsx)(Ye,{className:`shrink-0`,pressed:R,onPressedChange:e=>{ve({path:e?l:null,revealRequestId:e?P:null})},"aria-label":R?`Show markdown source`:`Show rendered markdown`,variant:`ghost`,size:`sm`,children:R?(0,X.jsx)($e,{className:`size-3.5`}):(0,X.jsx)(Xe,{className:`size-3.5`})})}),(0,X.jsx)(M,{children:R?`Show markdown source`:`Show rendered markdown`})]}):null,Te?(0,X.jsxs)(O,{children:[(0,X.jsx)(j,{render:(0,X.jsx)(Ye,{className:`shrink-0`,pressed:!1,onPressedChange:We,"aria-label":`Open file in preview browser`,variant:`ghost`,size:`sm`,children:(0,X.jsx)(Le,{className:`size-3.5`})})}),(0,X.jsx)(M,{children:`Open file in preview browser`})]}):null,(0,X.jsxs)(O,{children:[(0,X.jsx)(j,{render:(0,X.jsx)(Ye,{className:`shrink-0`,pressed:L,onPressedChange:he,"aria-label":L?`Collapse file preview`:`Expand file preview`,variant:`ghost`,size:`sm`,children:L?(0,X.jsx)(Ee,{className:`size-3.5`}):(0,X.jsx)(qe,{className:`size-3.5`})})}),(0,X.jsx)(M,{children:L?`Collapse file preview`:`Expand file preview`})]}),(0,X.jsxs)(O,{children:[(0,X.jsx)(j,{render:(0,X.jsx)(Ye,{className:`shrink-0`,pressed:pe,onPressedChange:Ve,"aria-label":pe?`Hide file explorer`:`Show file explorer`,variant:`ghost`,size:`sm`,children:(0,X.jsx)(st,{className:`size-3.5`})})}),(0,X.jsx)(M,{children:pe?`Hide file explorer`:`Show file explorer`})]})]}):null,t[55]=Oe,t[56]=k,t[57]=Pe,t[58]=Te,t[59]=n,t[60]=L,t[61]=pe,t[62]=We,t[63]=Se,t[64]=g,t[65]=ie,t[66]=o,t[67]=l,t[68]=R,t[69]=P,t[70]=Je):Je=t[70];let Qe;t[71]!==I||t[72]!==l?(Qe=l&&I.data?.truncated?(0,X.jsxs)(`div`,{className:`shrink-0 border-b border-amber-500/20 bg-amber-500/8 px-3 py-1.5 text-[11px] text-amber-700 dark:text-amber-300`,children:[`Preview limited to the first 1 MB of a `,I.data.byteLength.toLocaleString(),` byte file.`]}):null,t[71]=I,t[72]=l,t[73]=Qe):Qe=t[73];let et=l?`flex`:`hidden`,tt;t[74]===et?tt=t[75]:(tt=a(`min-w-0 flex-1 flex-col overflow-hidden`,et),t[74]=et,t[75]=tt);let rt;t[76]!==L||t[77]!==Ke?(rt=L?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs text-muted-foreground`,children:`Shown in the expanded view.`}):Ke,t[76]=L,t[77]=Ke,t[78]=rt):rt=t[78];let it;t[79]!==tt||t[80]!==rt?(it=(0,X.jsx)(`div`,{className:tt,children:rt}),t[79]=tt,t[80]=rt,t[81]=it):it=t[81];let at;t[82]!==r||t[83]!==n||t[84]!==pe||t[85]!==te||t[86]!==o||t[87]!==l?(at=pe||l===null?(0,X.jsx)(`aside`,{className:a(`flex min-h-0 shrink-0 bg-background`,l?`w-[min(22rem,46%)] min-w-64 border-l border-border/60`:`min-w-0 flex-1`),children:(0,X.jsx)(em,{environmentId:n,cwd:r,projectName:o,onOpenFile:te},`${n}:${r}`)}):null,t[82]=r,t[83]=n,t[84]=pe,t[85]=te,t[86]=o,t[87]=l,t[88]=at):at=t[88];let z;t[89]!==it||t[90]!==at?(z=(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[it,at]}),t[89]=it,t[90]=at,t[91]=z):z=t[91];let B=L&&l!==null,ot=l??``,ct;t[92]!==Ke||t[93]!==B||t[94]!==ot?(ct=(0,X.jsx)(tm,{open:B,title:ot,onOpenChange:he,children:Ke}),t[92]=Ke,t[93]=B,t[94]=ot,t[95]=ct):ct=t[95];let lt;return t[96]!==Je||t[97]!==Qe||t[98]!==z||t[99]!==ct?(lt=(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[Je,Qe,z,ct]}),t[96]=Je,t[97]=Qe,t[98]=z,t[99]=ct,t[100]=lt):lt=t[100],lt}function Vm(e){let t=!e;try{k(vm,t,f)}catch(e){console.error(e)}return t}function Hm(e){return e.wordWrap}export{Bm as default};
2230
- //# sourceMappingURL=FilePreviewPanel-DJeGSXHG.js.map
2229
+ `;function Sm(e){let t=(0,Yp.c)(5),n=ce(e.environmentId,e.resource),[r,i]=(0,Y.useState)(null);if(n._tag===`Failure`||n._tag===`Success`&&r===n.url){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load image.`}),t[0]=e):e=t[0],e}let a;return t[1]!==n._tag||t[2]!==n.url||t[3]!==e.alt?(a=n._tag===`Success`?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,X.jsx)(`img`,{className:`max-h-full max-w-full object-contain`,src:n.url,alt:e.alt,onError:()=>i(n.url)})}):(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,X.jsx)(_,{className:`size-5 animate-spin`})}),t[1]=n._tag,t[2]=n.url,t[3]=e.alt,t[4]=a):a=t[4],a}function Cm(e,t){let n=1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);r===10?n+=1:r===13&&(n+=1,e.charCodeAt(t+1)===10&&(t+=1))}return Math.min(Math.max(1,t),n)}function wm(e,t){let n=e.shadowRoot??e;for(let e of n.querySelectorAll(`[${bm}]`))e.removeAttribute(bm);t!==null&&(n.querySelector(`[data-line="${t}"]`)?.setAttribute(bm,``),n.querySelector(`[data-column-number="${t}"]`)?.setAttribute(bm,``))}function Tm(e,t,n){let r=(0,Yp.c)(7),[i]=(0,Y.useState)(Om),[a]=(0,Y.useState)(Dm),[o]=(0,Y.useState)(Em),s;return r[0]!==i||r[1]!==a||r[2]!==o||r[3]!==e||r[4]!==t||r[5]!==n?(s=(r,s,c)=>{if(e===null)return;let l=()=>{let t=o.get(e);t!==void 0&&(cancelAnimationFrame(t),o.delete(e))};if(c===`unmount`){l();return}let u=t===null?null:Cm(s.file?.contents??``,t);if(wm(r,u),!(s instanceof N))return;if(a.get(e)!==n&&(l(),a.set(e,n)),u===null){r.style.minHeight=``;return}let d=r.closest(`.file-preview-virtualizer`);!d||(r.style.minHeight=`${Math.ceil(Math.max(s.height,d.clientHeight))}px`,i.get(e)===n||o.has(e))||o.set(e,requestAnimationFrame(()=>{if(o.delete(e),a.get(e)!==n||!r.isConnected)return;let t=s.getLinePosition(u);if(!t)return;let c=d.scrollTop+r.getBoundingClientRect().top-d.getBoundingClientRect().top,l=Math.max(0,c+t.top-Math.max(0,(d.clientHeight-t.height)/2)),f=Math.max(0,d.scrollHeight-d.clientHeight);d.scrollTop=Math.min(l,f),i.set(e,n)}))},r[0]=i,r[1]=a,r[2]=o,r[3]=e,r[4]=t,r[5]=n,r[6]=s):s=r[6],s}function Em(){return new Map}function Dm(){return new Map}function Om(){return new Map}function km(e){let t=(0,Yp.c)(19),{environmentId:n,cwd:r,relativePath:i,onPendingChange:a}=e,o=u(re.writeFile),s;t[0]!==a||t[1]!==i?(s=e=>a(i,e),t[0]=a,t[1]=i,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n||t[5]!==i||t[6]!==o?(c=e=>o({environmentId:n,input:{cwd:r,relativePath:i,contents:e}}),t[3]=r,t[4]=n,t[5]=i,t[6]=o,t[7]=c):c=t[7];let l;t[8]!==r||t[9]!==n||t[10]!==i?(l=e=>{ke(n,r,i,e)},t[8]=r,t[9]=n,t[10]=i,t[11]=l):l=t[11];let d;t[12]!==s||t[13]!==c||t[14]!==l?(d=new _m({debounceMs:ym,onPendingChange:s,persist:c,onConfirmed:l}),t[12]=s,t[13]=c,t[14]=l,t[15]=d):d=t[15];let f=d,p,m;return t[16]===f?(p=t[17],m=t[18]):(p=()=>()=>f.dispose(),m=[f],t[16]=f,t[17]=p,t[18]=m),(0,Y.useEffect)(p,m),f}function Am(e){let t=(0,Yp.c)(73),{environmentId:n,cwd:r,relativePath:i,composerDraftTarget:a,contents:o,resolvedTheme:s,revealRequestId:c,wordWrap:l,onPostRender:u,onPendingChange:f}=e,p=d(Lm),h=d(Im),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],t[0]=g):g=t[0];let[_,v]=(0,Y.useState)(g),[y,b]=(0,Y.useState)(null),x=y?.revealRequestId===c?y.range:null,S;t[1]===c?S=t[2]:(S=e=>{b({revealRequestId:c,range:e})},t[1]=c,t[2]=S);let C=S,w=(0,Y.useRef)(null),T=(0,Y.useRef)(null),E;t[3]!==r||t[4]!==n||t[5]!==f||t[6]!==i?(E={environmentId:n,cwd:r,relativePath:i,onPendingChange:f},t[3]=r,t[4]=n,t[5]=f,t[6]=i,t[7]=E):E=t[7];let D=km(E),O=(0,Y.useRef)(null),k;t[8]!==p||t[9]!==a||t[10]!==r||t[11]!==n||t[12]!==i||t[13]!==D?(k=(e,t)=>{if(Re(n,r,i,e.contents),D.change(e.contents),t){let n=it(t);v(n);for(let t of n)for(let n of t.metadata.entries)n.kind===`comment`&&p(a,m({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:n.text,contents:e.contents}))}},t[8]=p,t[9]=a,t[10]=r,t[11]=n,t[12]=i,t[13]=D,t[14]=k):k=t[14];let A=k,ee;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(ee=e=>{let t=new Vp(e);return O.current=t,t},t[15]=ee):ee=t[15];let j=ee,M,N;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>()=>{O.current?.cleanUp(),O.current=null},N=[],t[16]=M,t[17]=N):(M=t[16],N=t[17]),(0,Y.useEffect)(M,N);let P;t[18]!==a||t[19]!==h||t[20]!==C?(P=e=>{C(null),h(a,e),v(t=>t.flatMap(t=>{let n=t.metadata.entries.filter(t=>t.id!==e);return n.length>0?[{...t,metadata:{entries:n}}]:[]}))},t[18]=a,t[19]=h,t[20]=C,t[21]=P):P=t[21];let te=P,ne;t[22]!==p||t[23]!==a||t[24]!==o||t[25]!==_||t[26]!==i||t[27]!==C?(ne=(e,t)=>{C(null);let n=_.flatMap(Fm).find(t=>t.id===e);n&&p(a,m({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:t,contents:o})),v(n=>n.map(n=>({...n,metadata:{entries:n.metadata.entries.map(n=>n.id===e?{...n,kind:`comment`,text:t}:n)}})))},t[22]=p,t[23]=a,t[24]=o,t[25]=_,t[26]=i,t[27]=C,t[28]=ne):ne=t[28];let F=ne,re;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>{let{startLine:t,endLine:n}=z(e),r={id:at(),kind:`draft`,startLine:t,endLine:n,text:``};v(e=>{let t=e.flatMap(Nm),i=t.findIndex(e=>e.lineNumber===n);return i<0?[...t,{lineNumber:n,metadata:{entries:[r]}}]:t.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,r]}}:e)})},t[29]=re):re=t[29];let ie=re,ae;t[30]===_?ae=t[31]:(ae=_.some(jm),t[30]=_,t[31]=ae);let oe=ae,se,ce;t[32]!==oe||t[33]!==C?(se=()=>{let e=w.current;if(e)return dm({root:e,resolveEditor:()=>O.current,isBlocked:()=>oe,onDismiss:()=>C(null)})},ce=[oe,C],t[32]=oe,t[33]=C,t[34]=se,t[35]=ce):(se=t[34],ce=t[35]),(0,Y.useEffect)(se,ce);let le;t[36]===C?le=t[37]:(le=e=>{C(e),e&&ie(e)},t[36]=C,t[37]=le);let ue=le,de;t[38]!==u||t[39]!==x?(de=(e,t,n)=>{u(e,t,n),T.current!==null&&(cancelAnimationFrame(T.current),T.current=null),n!==`unmount`&&(T.current=requestAnimationFrame(()=>{T.current=null,e.isConnected&&t.setSelectedLines(x,{notify:!1})}))},t[38]=u,t[39]=x,t[40]=de):de=t[40];let fe=de,I;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(I={overscrollSize:600,intersectionObserverMargin:1200},t[41]=I):I=t[41];let me;t[42]!==o||t[43]!==r||t[44]!==i?(me=pm(r,i,o),t[42]=o,t[43]=r,t[44]=i,t[45]=me):me=t[45];let L;t[46]!==o||t[47]!==i||t[48]!==me?(L={name:i,contents:o,cacheKey:me},t[46]=o,t[47]=i,t[48]=me,t[49]=L):L=t[49];let he=!oe,ge=!oe,_e=l?`wrap`:`scroll`,ve;t[50]===s?ve=t[51]:(ve=Be(s),t[50]=s,t[51]=ve);let ye;t[52]!==ue||t[53]!==fe||t[54]!==s||t[55]!==C||t[56]!==he||t[57]!==ge||t[58]!==_e||t[59]!==ve?(ye={disableFileHeader:!0,enableGutterUtility:he,enableLineSelection:ge,onGutterUtilityClick:C,onLineSelectionChange:C,onLineSelectionEnd:ue,overflow:_e,theme:ve,themeType:s,unsafeCSS:xm,onPostRender:fe},t[52]=ue,t[53]=fe,t[54]=s,t[55]=C,t[56]=he,t[57]=ge,t[58]=_e,t[59]=ve,t[60]=ye):ye=t[60];let be;t[61]!==te||t[62]!==F?(be=e=>(0,X.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,X.jsx)(rt,{kind:e.kind,rangeLabel:B(e.startLine,e.endLine),text:e.text,onCancel:()=>te(e.id),onComment:t=>F(e.id,t),onDelete:()=>te(e.id)},e.id))}),t[61]=te,t[62]=F,t[63]=be):be=t[63];let xe;t[64]===A?xe=t[65]:(xe={onChange:A},t[64]=A,t[65]=xe);let Se;return t[66]!==_||t[67]!==x||t[68]!==L||t[69]!==ye||t[70]!==be||t[71]!==xe?(Se=(0,X.jsx)(pe,{createEditor:j,children:(0,X.jsx)(`div`,{ref:w,className:`flex min-h-0 flex-1`,children:(0,X.jsx)(nt,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:I,children:(0,X.jsx)(ql,{file:L,options:ye,selectedLines:x,lineAnnotations:_,renderAnnotation:be,className:`min-h-full`,edit:!0,editorOptions:xe})})})}),t[66]=_,t[67]=x,t[68]=L,t[69]=ye,t[70]=be,t[71]=xe,t[72]=Se):Se=t[72],Se}function jm(e){return e.metadata.entries.some(Mm)}function Mm(e){return e.kind===`draft`}function Nm(e){let t=e.metadata.entries.filter(Pm);return t.length>0?[{...e,metadata:{entries:t}}]:[]}function Pm(e){return e.kind!==`draft`}function Fm(e){return e.metadata.entries}function Im(e){return e.removeReviewComment}function Lm(e){return e.addReviewComment}function Rm(e){let t=(0,Yp.c)(17),{environmentId:n,cwd:r,relativePath:i,contents:a,threadRef:o,readOnly:s,onPendingChange:c}=e,l;t[0]!==r||t[1]!==n||t[2]!==c||t[3]!==i?(l={environmentId:n,cwd:r,relativePath:i,onPendingChange:c},t[0]=r,t[1]=n,t[2]=c,t[3]=i,t[4]=l):l=t[4];let u=km(l),d;t[5]!==a||t[6]!==r||t[7]!==n||t[8]!==s||t[9]!==i||t[10]!==u?(d=s?{}:{onTaskListChange:e=>{let{markerOffset:t,checked:o}=e,s=We(n,r,i)?.contents??a,c=gm(s,t,o);c!==s&&(Re(n,r,i,c),u.change(c))}},t[5]=a,t[6]=r,t[7]=n,t[8]=s,t[9]=i,t[10]=u,t[11]=d):d=t[11];let f;return t[12]!==a||t[13]!==r||t[14]!==d||t[15]!==o?(f=(0,X.jsx)(T,{className:`min-h-0 flex-1`,children:(0,X.jsx)(we,{text:a,cwd:r,threadRef:o,className:`mx-auto max-w-4xl px-6 py-5`,...d})}),t[12]=a,t[13]=r,t[14]=d,t[15]=o,t[16]=f):f=t[16],f}function zm(){try{return o(vm,p)??!0}catch(e){return console.error(e),!0}}function Bm(e){let t=(0,Yp.c)(101),{environmentId:n,cwd:r,projectName:o,workspaceRoot:c,relativePath:l,absolutePath:d,isOutsideWorkspace:p,threadRef:m,composerDraftTarget:h,keybindings:g,availableEditors:k,revealLine:N,revealRequestId:P,onOpenFile:te,onPendingChange:ne}=e,{resolvedTheme:F}=ee(),re=be(Hm),ie=s(),ae=A(n),oe;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(oe={reportFailure:!1},t[0]=oe):oe=t[0];let se=Me(le.createUrl,oe),ce;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(ce={reportFailure:!1},t[1]=ce):ce=t[1];let ue=u(i.open,ce),de;t[2]===l?de=t[3]:(de=l!==null&&E(l),t[2]=l,t[3]=de);let fe=de,I=je(n,r,l,!fe,d),[pe,me]=(0,Y.useState)(zm),[L,he]=(0,Y.useState)(!1),ge;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(ge={path:null,revealRequestId:null},t[4]=ge):ge=t[4];let[_e,ve]=(0,Y.useState)(ge),ye=(0,Y.useRef)(null),xe;t[5]===l?xe=t[6]:(xe=l?hm(l):!1,t[5]=l,t[6]=xe);let Se=xe,R=Se&&_e.path===l&&(N===null||_e.revealRequestId===P),we;t[7]===l?we=t[8]:(we=l!==null&&f()&&Ue(l),t[7]=l,t[8]=we);let Te=we,De;t[9]!==r||t[10]!==d||t[11]!==l?(De=d??(l?y(l,r):null),t[9]=r,t[10]=d,t[11]=l,t[12]=De):De=t[12];let Oe=De,ke;t[13]!==Oe||t[14]!==m.threadId||t[15]!==c?(ke=Oe===null?null:w({filePath:Oe,threadId:m.threadId,workspaceRoot:c,allowLocalFiles:!0}),t[13]=Oe,t[14]=m.threadId,t[15]=c,t[16]=ke):ke=t[16];let Ae=ke,Ne;t[17]!==r||t[18]!==p||t[19]!==o||t[20]!==l?(Ne=l?mm(p?r:o,l):[],t[17]=r,t[18]=p,t[19]=o,t[20]=l,t[21]=Ne):Ne=t[21];let Pe=Ne,Fe=Tm(l,N,P),Ie;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=()=>{(ye.current?.querySelector(`[data-current-file-crumb='true']`))?.scrollIntoView({block:`nearest`,inline:`end`})},t[22]=Ie):Ie=t[22];let Re;t[23]===l?Re=t[24]:(Re=[l],t[23]=l,t[24]=Re),(0,Y.useEffect)(Ie,Re);let ze;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ze=()=>{me(Vm)},t[25]=ze):ze=t[25];let Ve=ze,He;t[26]!==Oe||t[27]!==se||t[28]!==ae||t[29]!==ue||t[30]!==F||t[31]!==m||t[32]!==c?(He=()=>{!Oe||!ae||(async()=>{let e=await Ze({threadRef:m,filePath:Oe,httpBaseUrl:ae,workspaceRoot:c,allowLocalFiles:!0,theme:F,createAssetUrl:se,openPreview:ue});if(e._tag===`Success`||v(e))return;let t=D(e);C.add(b({type:`error`,title:`Unable to open file in browser`,description:t instanceof Error?t.message:`An error occurred.`}))})()},t[26]=Oe,t[27]=se,t[28]=ae,t[29]=ue,t[30]=F,t[31]=m,t[32]=c,t[33]=He):He=t[33];let We=He,Ge;t[34]!==Oe||t[35]!==k||t[36]!==h||t[37]!==r||t[38]!==n||t[39]!==I||t[40]!==Ae||t[41]!==fe||t[42]!==Se||t[43]!==p||t[44]!==g||t[45]!==Fe||t[46]!==ne||t[47]!==ie||t[48]!==l||t[49]!==R||t[50]!==F||t[51]!==P||t[52]!==m||t[53]!==re?(Ge=l&&fe&&Ae?(0,X.jsx)(Sm,{environmentId:n,resource:Ae,alt:l},Oe??l):l&&I.error&&I.data===null?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:I.error}):l&&I.data===null?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,X.jsx)(_,{className:`size-5 animate-spin`})}):l&&I.data?I.data.binary&&Oe?(0,X.jsx)(om,{environmentId:n,keybindings:g,availableEditors:k,absolutePath:Oe,name:l.slice(l.lastIndexOf(`/`)+1),byteLength:I.data.byteLength,canRevealInFileManager:n===ie&&x()}):Se&&R?(0,X.jsx)(Rm,{environmentId:n,cwd:r,relativePath:l,threadRef:m,contents:I.data.contents,readOnly:p,onPendingChange:ne}):I.data.truncated||p?(0,X.jsx)(nt,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:{overscrollSize:600,intersectionObserverMargin:1200},children:(0,X.jsx)(ql,{file:{name:l,contents:I.data.contents,cacheKey:pm(r,l,I.data.contents)},options:{disableFileHeader:!0,overflow:re?`wrap`:`scroll`,theme:Be(F),themeType:F,unsafeCSS:xm,onPostRender:Fe},className:`min-h-full`})},`${l}:${F}:${I.data.byteLength}`):(0,X.jsx)(Am,{environmentId:n,cwd:r,relativePath:l,composerDraftTarget:h,contents:I.data.contents,resolvedTheme:F,revealRequestId:P,wordWrap:re,onPostRender:Fe,onPendingChange:ne},`${l}:${F}`):null,t[34]=Oe,t[35]=k,t[36]=h,t[37]=r,t[38]=n,t[39]=I,t[40]=Ae,t[41]=fe,t[42]=Se,t[43]=p,t[44]=g,t[45]=Fe,t[46]=ne,t[47]=ie,t[48]=l,t[49]=R,t[50]=F,t[51]=P,t[52]=m,t[53]=re,t[54]=Ge):Ge=t[54];let Ke=Ge,Je;t[55]!==Oe||t[56]!==k||t[57]!==Pe||t[58]!==Te||t[59]!==n||t[60]!==L||t[61]!==pe||t[62]!==We||t[63]!==Se||t[64]!==g||t[65]!==ie||t[66]!==o||t[67]!==l||t[68]!==R||t[69]!==P?(Je=l?(0,X.jsxs)(`div`,{className:`surface-subheader gap-2 px-3`,"data-surface-subheader":!0,children:[(0,X.jsx)(T,{ref:ye,hideScrollbars:!0,scrollFade:!0,className:`min-w-0 flex-1 rounded-none`,"data-file-breadcrumbs":!0,children:(0,X.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center text-xs`,children:Pe.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center`,"data-current-file-crumb":e.kind===`file`,children:[t>0?(0,X.jsx)(S,{className:`mx-1 size-3.5 shrink-0 text-muted-foreground/60`}):null,(0,X.jsx)(`span`,{className:a(`max-w-40 truncate`,e.kind===`file`?`font-medium text-foreground`:`text-muted-foreground`),title:e.path||o,children:e.label})]},e.path||`project`))})}),Oe&&n===ie?(0,X.jsx)(Ce,{environmentId:n,keybindings:g,availableEditors:k,openInCwd:Oe,compact:!0,enableShortcut:!1}):null,Se?(0,X.jsxs)(O,{children:[(0,X.jsx)(j,{render:(0,X.jsx)(Ye,{className:`shrink-0`,pressed:R,onPressedChange:e=>{ve({path:e?l:null,revealRequestId:e?P:null})},"aria-label":R?`Show markdown source`:`Show rendered markdown`,variant:`ghost`,size:`sm`,children:R?(0,X.jsx)($e,{className:`size-3.5`}):(0,X.jsx)(Xe,{className:`size-3.5`})})}),(0,X.jsx)(M,{children:R?`Show markdown source`:`Show rendered markdown`})]}):null,Te?(0,X.jsxs)(O,{children:[(0,X.jsx)(j,{render:(0,X.jsx)(Ye,{className:`shrink-0`,pressed:!1,onPressedChange:We,"aria-label":`Open file in preview browser`,variant:`ghost`,size:`sm`,children:(0,X.jsx)(Le,{className:`size-3.5`})})}),(0,X.jsx)(M,{children:`Open file in preview browser`})]}):null,(0,X.jsxs)(O,{children:[(0,X.jsx)(j,{render:(0,X.jsx)(Ye,{className:`shrink-0`,pressed:L,onPressedChange:he,"aria-label":L?`Collapse file preview`:`Expand file preview`,variant:`ghost`,size:`sm`,children:L?(0,X.jsx)(Ee,{className:`size-3.5`}):(0,X.jsx)(qe,{className:`size-3.5`})})}),(0,X.jsx)(M,{children:L?`Collapse file preview`:`Expand file preview`})]}),(0,X.jsxs)(O,{children:[(0,X.jsx)(j,{render:(0,X.jsx)(Ye,{className:`shrink-0`,pressed:pe,onPressedChange:Ve,"aria-label":pe?`Hide file explorer`:`Show file explorer`,variant:`ghost`,size:`sm`,children:(0,X.jsx)(st,{className:`size-3.5`})})}),(0,X.jsx)(M,{children:pe?`Hide file explorer`:`Show file explorer`})]})]}):null,t[55]=Oe,t[56]=k,t[57]=Pe,t[58]=Te,t[59]=n,t[60]=L,t[61]=pe,t[62]=We,t[63]=Se,t[64]=g,t[65]=ie,t[66]=o,t[67]=l,t[68]=R,t[69]=P,t[70]=Je):Je=t[70];let Qe;t[71]!==I||t[72]!==l?(Qe=l&&I.data?.truncated?(0,X.jsxs)(`div`,{className:`shrink-0 border-b border-amber-500/20 bg-amber-500/8 px-3 py-1.5 text-[11px] text-amber-700 dark:text-amber-300`,children:[`Preview limited to the first 1 MB of a `,I.data.byteLength.toLocaleString(),` byte file.`]}):null,t[71]=I,t[72]=l,t[73]=Qe):Qe=t[73];let et=l?`flex`:`hidden`,tt;t[74]===et?tt=t[75]:(tt=a(`min-w-0 flex-1 flex-col overflow-hidden`,et),t[74]=et,t[75]=tt);let rt;t[76]!==L||t[77]!==Ke?(rt=L?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs text-muted-foreground`,children:`Shown in the expanded view.`}):Ke,t[76]=L,t[77]=Ke,t[78]=rt):rt=t[78];let it;t[79]!==tt||t[80]!==rt?(it=(0,X.jsx)(`div`,{className:tt,children:rt}),t[79]=tt,t[80]=rt,t[81]=it):it=t[81];let at;t[82]!==r||t[83]!==n||t[84]!==pe||t[85]!==te||t[86]!==o||t[87]!==l?(at=pe||l===null?(0,X.jsx)(`aside`,{className:a(`flex min-h-0 shrink-0 bg-background`,l?`w-[min(22rem,46%)] min-w-64 border-l border-border/60`:`min-w-0 flex-1`),children:(0,X.jsx)(em,{environmentId:n,cwd:r,projectName:o,onOpenFile:te},`${n}:${r}`)}):null,t[82]=r,t[83]=n,t[84]=pe,t[85]=te,t[86]=o,t[87]=l,t[88]=at):at=t[88];let z;t[89]!==it||t[90]!==at?(z=(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[it,at]}),t[89]=it,t[90]=at,t[91]=z):z=t[91];let B=L&&l!==null,ot=l??``,ct;t[92]!==Ke||t[93]!==B||t[94]!==ot?(ct=(0,X.jsx)(tm,{open:B,title:ot,onOpenChange:he,children:Ke}),t[92]=Ke,t[93]=B,t[94]=ot,t[95]=ct):ct=t[95];let lt;return t[96]!==Je||t[97]!==Qe||t[98]!==z||t[99]!==ct?(lt=(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[Je,Qe,z,ct]}),t[96]=Je,t[97]=Qe,t[98]=z,t[99]=ct,t[100]=lt):lt=t[100],lt}function Vm(e){let t=!e;try{k(vm,t,p)}catch(e){console.error(e)}return t}function Hm(e){return e.wordWrap}export{Bm as default};
2230
+ //# sourceMappingURL=FilePreviewPanel-XIjCoVxw.js.map
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$ as i,$a as a,Au as o,B as s,Ct as c,Du as l,G as u,Ga as d,Gu as f,Ia as p,K as m,Ka as h,Mt as g,Mu as _,Q as v,Qa as y,Qp as b,Ru as x,St as S,Ua as C,Ur as w,Vu as T,W as E,Wa as D,Xa as O,Y as k,Ya as A,Z as ee,Za as j,_d as te,_l as M,em as N,ht as ne,ku as P,mt as F,pu as I,q as re,qa as L,r as ie,ut as ae,vt as oe,wt as R,x as z,xt as B,yt as V,za as se,zl as ce}from"./previewAssetResource-BMf_t-Oa.js";import{$n as le,$r as ue,Ar as H,B as de,Cr as fe,Dr as U,Er as pe,Gr as W,H as G,I as K,Jr as me,Kr as he,L as ge,Mr as _e,Nr as ve,Or as q,Pr as J,Qn as Y,Qr as X,R as ye,Tr as be,V as xe,Xn as Se,Yn as Ce,Yr as we,Zn as Te,Zr as Ee,a as De,ai as Oe,c as ke,ci as Ae,d as je,et as Me,i as Ne,j as Pe,jr as Fe,kr as Ie,l as Le,mi as Re,n as ze,nt as Be,o as Ve,pi as He,r as Ue,s as We,t as Ge,tt as Ke,u as qe,wr as Je,y as Ye,z as Xe}from"./index-BSuuYg8z.js";var Ze=M(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),Qe=M(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),$e=M(`radio-tower`,[[`path`,{d:`M4.9 16.1C1 12.2 1 5.8 4.9 1.9`,key:`s0qx1y`}],[`path`,{d:`M7.8 4.7a6.14 6.14 0 0 0-.8 7.5`,key:`1idnkw`}],[`circle`,{cx:`12`,cy:`9`,r:`2`,key:`1092wv`}],[`path`,{d:`M16.2 4.8c2 2 2.26 5.11.8 7.47`,key:`ojru2q`}],[`path`,{d:`M19.1 1.9a9.96 9.96 0 0 1 0 14.1`,key:`rhi7fg`}],[`path`,{d:`M9.5 18h5`,key:`mfy3pd`}],[`path`,{d:`m8 22 4-11 4 11`,key:`25yftu`}]]),Z=r(),Q=e(n(),1),$=t(),et=()=>{};function tt(e){let t=(0,Z.c)(116),{url:n,displayUrl:r,loading:i,loadProgress:o,canGoBack:s,canGoForward:c,refreshDisabled:l,inputDisabled:u,focusUrlNonce:d,onBack:f,onForward:m,onRefresh:h,onSubmit:g,onOpenInBrowser:_,onCapture:v,captureDisabled:y,recording:b,onPictureInPicture:x,pictureInPicture:S,pictureInPictureDisabled:C,onPickElement:w,pickActive:T,pickDisabled:E,pickDisabledReason:D,trailingActions:O}=e,k=(0,Q.useRef)(null),[A,ee]=(0,Q.useState)(n),[j,te]=(0,Q.useState)(!1),M;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(M=[],t[0]=M):M=t[0];let[N,ne]=(0,Q.useState)(M),[P,F]=(0,Q.useState)(-1),I=(0,Q.useId)(),re;t[1]!==A||t[2]!==N||t[3]!==j||t[4]!==n?(re=j&&A!==n?qe(N,A):[],t[1]=A,t[2]=N,t[3]=j,t[4]=n,t[5]=re):re=t[5];let L=re,ie,ae;t[6]===d?(ie=t[7],ae=t[8]):(ie=()=>{if(d==null)return;let e=k.current;e&&e.focus()},ae=[d],t[6]=d,t[7]=ie,t[8]=ae),(0,Q.useEffect)(ie,ae);let R;t[9]!==P||t[10]!==A||t[11]!==g||t[12]!==L?(R=e=>{e?.preventDefault();let t=L[P]?.url??A.trim();t.length!==0&&(g(t),k.current?.blur())},t[9]=P,t[10]=A,t[11]=g,t[12]=L,t[13]=R):R=t[13];let z=R,se=s?f:et,ce=!s,le;t[14]!==se||t[15]!==ce?(le=(0,$.jsx)(p,{variant:`ghost`,size:`icon-xs`,onClick:se,disabled:ce,"aria-label":`Back`,type:`button`}),t[14]=se,t[15]=ce,t[16]=le):le=t[16];let ue;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(Re,{}),t[17]=ue):ue=t[17];let H;t[18]===le?H=t[19]:(H=(0,$.jsx)(B,{render:le,children:ue}),t[18]=le,t[19]=H);let de;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(V,{children:`Back`}),t[20]=de):de=t[20];let fe;t[21]===H?fe=t[22]:(fe=(0,$.jsxs)(oe,{children:[H,de]}),t[21]=H,t[22]=fe);let U=c?m:et,pe=!c,G;t[23]!==U||t[24]!==pe?(G=(0,$.jsx)(p,{variant:`ghost`,size:`icon-xs`,onClick:U,disabled:pe,"aria-label":`Forward`,type:`button`}),t[23]=U,t[24]=pe,t[25]=G):G=t[25];let K;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(He,{}),t[26]=K):K=t[26];let me;t[27]===G?me=t[28]:(me=(0,$.jsx)(B,{render:G,children:K}),t[27]=G,t[28]=me);let he;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(V,{children:`Forward`}),t[29]=he):he=t[29];let ge;t[30]===me?ge=t[31]:(ge=(0,$.jsxs)(oe,{children:[me,he]}),t[30]=me,t[31]=ge);let _e=l?et:h,ve=i?`Stop`:`Refresh`,q;t[32]!==l||t[33]!==_e||t[34]!==ve?(q=(0,$.jsx)(p,{variant:`ghost`,size:`icon-xs`,onClick:_e,disabled:l,"aria-label":ve,type:`button`}),t[32]=l,t[33]=_e,t[34]=ve,t[35]=q):q=t[35];let J=i&&`animate-spin`,Y;t[36]===J?Y=t[37]:(Y=a(J),t[36]=J,t[37]=Y);let X;t[38]===Y?X=t[39]:(X=(0,$.jsx)(W,{className:Y}),t[38]=Y,t[39]=X);let ye;t[40]!==q||t[41]!==X?(ye=(0,$.jsx)(B,{render:q,children:X}),t[40]=q,t[41]=X,t[42]=ye):ye=t[42];let be=i?`Loading…`:`Refresh`,xe;t[43]===be?xe=t[44]:(xe=(0,$.jsx)(V,{children:be}),t[43]=be,t[44]=xe);let Se;t[45]!==ye||t[46]!==xe?(Se=(0,$.jsxs)(oe,{children:[ye,xe]}),t[45]=ye,t[46]=xe,t[47]=Se):Se=t[47];let Ce;t[48]!==fe||t[49]!==ge||t[50]!==Se?(Ce=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[fe,ge,Se]}),t[48]=fe,t[49]=ge,t[50]=Se,t[51]=Ce):Ce=t[51];let Te=j?A:r??n,De=_&&!j&&`group-hover/address:pe-7 transition-[padding]`,Oe;t[52]===De?Oe=t[53]:(Oe=a(De),t[52]=De,t[53]=Oe);let ke;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ke=e=>{ee(e.target.value),F(-1)},t[54]=ke):ke=t[54];let je;t[55]===n?je=t[56]:(je=()=>{ee(n),ne(Le()),F(-1),te(!0),queueMicrotask(()=>k.current?.select())},t[55]=n,t[56]=je);let Ne;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=()=>{te(!1)},t[57]=Ne):Ne=t[57];let Pe;t[58]!==z||t[59]!==L.length||t[60]!==n?(Pe=e=>{if(e.key===`Enter`&&z(e),(e.key===`ArrowDown`||e.key===`ArrowUp`)&&L.length>0){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;F(e=>{let n=e+t;return n>=L.length?-1:n<-1?L.length-1:n})}e.key===`Escape`&&(e.preventDefault(),ee(n),k.current?.blur())},t[58]=z,t[59]=L.length,t[60]=n,t[61]=Pe):Pe=t[61];let Fe=L.length>0,Ie=P>=0?`${I}-${P}`:void 0,ze;t[62]!==u||t[63]!==I||t[64]!==Te||t[65]!==Oe||t[66]!==je||t[67]!==Pe||t[68]!==Fe||t[69]!==Ie?(ze=(0,$.jsx)(B,{render:(0,$.jsx)(Be,{ref:k,value:Te,className:Oe,onChange:ke,onFocus:je,onBlur:Ne,onKeyDown:Pe,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":Fe,"aria-controls":I,"aria-activedescendant":Ie,placeholder:`Search or enter URL`,spellCheck:!1,disabled:u,"data-preview-url-input":!0,size:`sm`})}),t[62]=u,t[63]=I,t[64]=Te,t[65]=Oe,t[66]=je,t[67]=Pe,t[68]=Fe,t[69]=Ie,t[70]=ze):ze=t[70];let Ve;t[71]!==r||t[72]!==j||t[73]!==n?(Ve=!j&&r?(0,$.jsx)(V,{children:n}):null,t[71]=r,t[72]=j,t[73]=n,t[74]=Ve):Ve=t[74];let Ue;t[75]!==ze||t[76]!==Ve?(Ue=(0,$.jsxs)(oe,{children:[ze,Ve]}),t[75]=ze,t[76]=Ve,t[77]=Ue):Ue=t[77];let We;t[78]!==j||t[79]!==_?(We=_&&!j?(0,$.jsx)(Ke,{align:`inline-end`,className:`pointer-events-none absolute inset-y-0 right-0 opacity-0 transition-opacity group-hover/address:pointer-events-auto group-hover/address:opacity-100`,children:(0,$.jsxs)(oe,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(p,{variant:`ghost`,size:`icon-xs`,onClick:_,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(Ae,{})}),(0,$.jsx)(V,{children:`Open in system browser`})]})}):null,t[78]=j,t[79]=_,t[80]=We):We=t[80];let Ge;t[81]!==Ue||t[82]!==We?(Ge=(0,$.jsxs)(Me,{className:`group/address h-7 flex-1 rounded-md border-transparent bg-transparent shadow-none before:shadow-none hover:bg-muted/40 focus-within:bg-background`,children:[Ue,We]}),t[81]=Ue,t[82]=We,t[83]=Ge):Ge=t[83];let Je;t[84]!==w||t[85]!==T||t[86]!==E||t[87]!==D?(Je=w?(0,$.jsxs)(oe,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(p,{variant:T?`secondary`:`ghost`,size:`icon-xs`,onClick:w,disabled:E,"aria-label":T?`Cancel annotation`:`Annotate preview`,"aria-pressed":T?`true`:`false`,type:`button`}),children:(0,$.jsx)(Ee,{className:a(T&&`text-primary`)})}),(0,$.jsx)(V,{children:E&&D?D:T?`Cancel annotation (Esc)`:`Annotate elements, regions, and drawings`})]}):null,t[84]=w,t[85]=T,t[86]=E,t[87]=D,t[88]=Je):Je=t[88];let Ye;t[89]!==y||t[90]!==v||t[91]!==b?(Ye=v?(0,$.jsxs)(oe,{children:[(0,$.jsxs)(B,{render:(0,$.jsx)(p,{variant:b?`secondary`:`ghost`,size:`icon-xs`,onClick:e=>v(e.shiftKey),"aria-label":b?`Stop recording`:`Capture screenshot`,type:`button`,className:`relative`,disabled:y}),children:[(0,$.jsx)(Ze,{className:a(b&&`text-destructive`)}),b?(0,$.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 animate-status-pulse rounded-full bg-destructive`}):null]}),(0,$.jsx)(V,{children:b?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[89]=y,t[90]=v,t[91]=b,t[92]=Ye):Ye=t[92];let Xe;t[93]!==x||t[94]!==S||t[95]!==C?(Xe=x?(0,$.jsxs)(oe,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(p,{variant:S?`secondary`:`ghost`,size:`icon-xs`,onClick:x,"aria-label":S?`Close floating preview`:`Float preview over chat`,"aria-pressed":S?`true`:`false`,type:`button`,disabled:C}),children:(0,$.jsx)(we,{className:a(S&&`text-primary`)})}),(0,$.jsx)(V,{children:S?`Close floating preview`:`Float preview over chat`})]}):null,t[93]=x,t[94]=S,t[95]=C,t[96]=Xe):Xe=t[96];let Qe;t[97]!==z||t[98]!==Ce||t[99]!==Ge||t[100]!==Je||t[101]!==Ye||t[102]!==Xe||t[103]!==O?(Qe=(0,$.jsxs)(`form`,{onSubmit:z,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[Ce,Ge,Je,Ye,Xe,O]}),t[97]=z,t[98]=Ce,t[99]=Ge,t[100]=Je,t[101]=Ye,t[102]=Xe,t[103]=O,t[104]=Qe):Qe=t[104];let $e;t[105]!==P||t[106]!==g||t[107]!==L||t[108]!==I?($e=L.length>0?(0,$.jsx)(`ul`,{id:I,role:`listbox`,"aria-label":`History suggestions`,className:`absolute inset-x-2 top-full z-50 mt-1 overflow-hidden rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-lg`,children:L.map((e,t)=>(0,$.jsxs)(`li`,{id:`${I}-${t}`,role:`option`,"aria-selected":t===P,onMouseDown:nt,onClick:()=>{g(e.url),k.current?.blur()},onMouseEnter:()=>F(t),className:`flex cursor-default flex-col rounded-md px-2 py-1 text-sm aria-selected:bg-accent aria-selected:text-accent-foreground`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.title||e.url}),e.title?(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.url}):null]},e.url))}):null,t[105]=P,t[106]=g,t[107]=L,t[108]=I,t[109]=$e):$e=t[109];let tt;t[110]===o?tt=t[111]:(tt=o>0?(0,$.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute bottom-0 left-0 z-10 h-0.5 rounded-r-full bg-primary transition-all duration-150 ease-out`,style:{width:`${o}%`,boxShadow:`0 0 6px 1px var(--color-ring)`}}):null,t[110]=o,t[111]=tt);let rt;return t[112]!==Qe||t[113]!==$e||t[114]!==tt?(rt=(0,$.jsxs)(`div`,{className:`relative`,children:[Qe,$e,tt]}),t[112]=Qe,t[113]=$e,t[114]=tt,t[115]=rt):rt=t[115],rt}function nt(e){return e.preventDefault()}function rt(e){try{let t=new URL(e.url),n=new URL(e.environmentHttpBaseUrl);if(t.origin===n.origin&&t.pathname.startsWith(`/api/assets/`)){let n=t.pathname.split(`/`).at(-1);if(!n)return null;let r=decodeURIComponent(n);return!r||r===`.`||r===`..`?null:`${e.environmentLabel} · ${r}`}return t.protocol===`http:`||t.protocol===`https:`?t.host:null}catch{return null}}function it(e){let t=(0,Z.c)(6),{className:n}=e,r;t[0]===n?r=t[1]:(r=a(`relative flex flex-col gap-0.5 overflow-hidden rounded-[5px] border border-border/60 bg-card p-1 shadow-xs/5`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-destructive/80`}),(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-warning/80`}),(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-success/80`})]}),t[2]=i):i=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(`div`,{className:`mt-[1px] flex flex-1 flex-col gap-[2px]`,children:[(0,$.jsx)(`span`,{className:`h-[2px] w-full rounded-full bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-[2px] w-3/5 rounded-full bg-muted-foreground/20`})]}),t[3]=o):o=t[3];let s;return t[4]===r?s=t[5]:(s=(0,$.jsxs)(`div`,{"aria-hidden":!0,className:r,children:[i,o]}),t[4]=r,t[5]=s),s}function at(e){let t=(0,Z.c)(17),{server:n,onOpen:r}=e,i;t[0]===n?i=t[1]:(i=ot(n),t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(it,{className:`size-7 shrink-0`}),t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:a}),t[3]=a,t[4]=s);let c;t[5]!==n.host||t[6]!==n.port?(c=(0,$.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[n.host,`:`,n.port]}),t[5]=n.host,t[6]=n.port,t[7]=c):c=t[7];let l;t[8]!==s||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[s,c]}),t[8]=s,t[9]=c,t[10]=l):l=t[10];let u;t[11]===n.listening?u=t[12]:(u=n.listening?(0,$.jsx)(st,{}):(0,$.jsx)(ct,{}),t[11]=n.listening,t[12]=u);let d;return t[13]!==r||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex w-full items-center gap-3 px-3 py-3 text-left hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[o,l,u]}),t[13]=r,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function ot(e){return e.processName?e.processName:e.listening?`Listening`:e.source===`configured`?`Configured`:`Recently seen`}function st(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`span`,{"aria-label":`Listening`,className:`relative inline-flex size-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inset-0 animate-status-ping rounded-full bg-success opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-success`})]}),e[0]=t):t=e[0],t}function ct(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`span`,{"aria-label":`Not currently listening`,className:`size-2 shrink-0 rounded-full bg-muted-foreground/40`}),e[0]=t):t=e[0],t}function lt(e){let t=(0,Z.c)(7),n=U(e.environmentId),r;if(t[0]!==e.configuredUrls||t[1]!==e.environmentId||t[2]!==e.recentlySeenUrls||t[3]!==n){let i;t[5]===e.environmentId?i=t[6]:(i=t=>({...t,url:Je(e.environmentId,t.url)}),t[5]=e.environmentId,t[6]=i),r=ut({scanner:n.map(i),configuredUrls:e.configuredUrls??[],recentlySeenUrls:e.recentlySeenUrls??[]}),t[0]=e.configuredUrls,t[1]=e.environmentId,t[2]=e.recentlySeenUrls,t[3]=n,t[4]=r}else r=t[4];return r}function ut(e){let t=new Map;for(let n of e.configuredUrls){let e=ft(n);if(!e)continue;let r=dt(e.host,e.port);t.has(r)||t.set(r,{host:e.host,port:e.port,url:e.url,processName:null,pid:null,terminal:null,source:`configured`,listening:!1})}for(let n of e.scanner){let e=dt(n.host,n.port),r=t.get(e);if(r){t.set(e,{...r,processName:n.processName??r.processName,pid:n.pid??r.pid,terminal:n.terminal??r.terminal,listening:!0});continue}t.set(e,{...n,source:`scanner`,listening:!0})}for(let n of e.recentlySeenUrls){let e=ft(n);if(!e)continue;let r=dt(e.host,e.port);t.has(r)||t.set(r,{host:e.host,port:e.port,url:e.url,processName:null,pid:null,terminal:null,source:`recent`,listening:!1})}return Array.from(t.values()).toSorted((e,t)=>{let n={configured:0,scanner:1,recent:2};return n[e.source]===n[t.source]?e.port-t.port:n[e.source]-n[t.source]})}function dt(e,t){return`${e.toLowerCase()}:${t}`}function ft(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`||!be(t.hostname))return null;let n=t.port?Number.parseInt(t.port,10):t.protocol===`http:`?80:443;return!Number.isFinite(n)||n<=0?null:{host:t.hostname,port:n,url:t.href}}catch{return null}}function pt(e){let t=(0,Z.c)(16),{environmentId:n,configuredUrls:r,recentlySeenUrls:i,onOpenUrl:a}=e,o;t[0]!==r||t[1]!==n||t[2]!==i?(o={environmentId:n,configuredUrls:r,recentlySeenUrls:i},t[0]=r,t[1]=n,t[2]=i,t[3]=o):o=t[3];let s=lt(o);if(s.length===0){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(Ce,{children:[(0,$.jsx)(Te,{variant:`icon`,children:(0,$.jsx)(Oe,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(Y,{children:`No preview yet`}),(0,$.jsx)(Se,{children:`Type a URL above, or run a dev script. Listening localhost ports will show up here automatically.`})]}),t[4]=e):e=t[4],e}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)($e,{className:`size-4 shrink-0`}),(0,$.jsx)(`h2`,{className:`font-medium`,children:`Local servers`})]}),t[5]=c):c=t[5];let l;if(t[6]!==a||t[7]!==s){let e;t[9]===a?e=t[10]:(e=e=>(0,$.jsx)(at,{server:e,onOpen:()=>a(e.url)},`${e.host}:${e.port}`),t[9]=a,t[10]=e),l=s.map(e),t[6]=a,t[7]=s,t[8]=l}else l=t[8];let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60 overflow-hidden rounded-xl border border-border/70 bg-background`,children:l}),t[11]=l,t[12]=u);let d;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:`Select a listening port to open it in this browser tab.`}),t[13]=d):d=t[13];let f;return t[14]===u?f=t[15]:(f=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 overflow-y-auto px-5 py-8`,children:(0,$.jsxs)(`div`,{className:`m-auto flex w-full max-w-xl flex-col gap-3`,children:[c,u,d]})}),t[14]=u,t[15]=f),f}var mt=e=>(e instanceof Error?e.message:``).replace(/^Error invoking remote method '[^']+':\s*/u,``).replace(/^[A-Za-z]+Error:\s*/u,``).trim()||`Chrome import failed.`;function ht(e){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!e.open||!K)return;let t=!1;return n(null),c(null),K.listChromeProfiles().then(e=>{t||(n(e),i(e[0]?.id??null))},e=>{t||(n([]),i(null),c(mt(e)))}),()=>{t=!0}},[e.open]);let l=async()=>{if(!(!K||!r)){o(!0);try{let t=await K.importFromChrome({profileId:r});ke(t.history),F.add({type:`success`,title:`Imported from Chrome`,description:`${t.importedCookies} cookies and ${t.history.length} history entries.${t.failedCookies>0?` ${t.failedCookies} cookies could not be imported.`:``}`}),e.onOpenChange(!1)}catch(e){F.add({type:`error`,title:`Could not import from Chrome`,description:mt(e)})}finally{o(!1)}}};return(0,$.jsx)(q,{open:e.open,onOpenChange:e.onOpenChange,children:(0,$.jsxs)(ve,{className:`max-w-md`,children:[(0,$.jsxs)(Fe,{children:[(0,$.jsx)(J,{children:`Import from Chrome`}),(0,$.jsx)(Ie,{children:`Copies all cookies and recent history from a Chrome profile into the built-in browser. Agents that use this browser can act with these signed-in sessions. macOS asks for Keychain access to decrypt the cookies.`})]}),(0,$.jsx)(_e,{children:s?(0,$.jsx)(`p`,{className:`text-sm text-destructive-foreground`,children:s}):t===null?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Looking for Chrome profiles…`}):t.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Chrome profiles found. Importing is available on macOS with Google Chrome installed.`}):(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":`Chrome profile`,className:`space-y-1`,children:t.map(e=>(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 rounded-md px-2 py-1.5 text-sm hover:bg-accent`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`chrome-profile`,value:e.id,checked:r===e.id,onChange:()=>i(e.id)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.name===e.id?null:(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.id})]},e.id))})}),(0,$.jsxs)(H,{children:[(0,$.jsx)(p,{variant:`outline`,onClick:()=>e.onOpenChange(!1),children:`Cancel`}),(0,$.jsx)(p,{disabled:!r||a,onClick:()=>void l(),children:a?`Importing…`:`Import`})]})]})})}var gt=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function _t(e){let t=(0,Z.c)(81),{tabId:n,hasWebContents:r,zoomFactor:i,colorScheme:a,deviceToolbarVisible:o,onToggleDeviceToolbar:s,nativePictureInPicture:c,onNativePictureInPicture:l}=e,[u,f]=(0,Q.useState)(!1);if(!K)return null;let m=!n||!r,h;t[0]===n?h=t[1]:(h=e=>()=>{n&&e(n).catch(Tt)},t[0]=n,t[1]=h);let g=h,_;t[2]===i?_=t[3]:(_=Math.round(i*100),t[2]=i,t[3]=_);let v=`${_}%`,b;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsxs)(oe,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(y,{render:(0,$.jsx)(p,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(Qe,{})}),(0,$.jsx)(V,{children:`More`})]}),t[4]=b):b=t[4];let x;t[5]===g?x=t[6]:(x=g(K.hardReload),t[5]=g,t[6]=x);let S;t[7]!==x||t[8]!==m?(S=(0,$.jsx)(C,{onClick:x,disabled:m,children:`Hard reload`}),t[7]=x,t[8]=m,t[9]=S):S=t[9];let w;t[10]===g?w=t[11]:(w=g(K.openDevTools),t[10]=g,t[11]=w);let T;t[12]!==w||t[13]!==m?(T=(0,$.jsx)(C,{onClick:w,disabled:m,children:`Open DevTools`}),t[12]=w,t[13]=m,t[14]=T):T=t[14];let E=c?`Close separate preview window`:`Open separate preview window`,k;t[15]!==l||t[16]!==E||t[17]!==m?(k=(0,$.jsx)(C,{onClick:l,disabled:m,children:E}),t[15]=l,t[16]=E,t[17]=m,t[18]=k):k=t[18];let ee=o?`Hide device toolbar`:`Show device toolbar`,te;t[19]!==s||t[20]!==ee||t[21]!==m?(te=(0,$.jsx)(C,{onClick:s,disabled:m,children:ee}),t[19]=s,t[20]=ee,t[21]=m,t[22]=te):te=t[22];let M;t[23]===m?M=t[24]:(M=(0,$.jsx)(j,{disabled:m,children:`Appearance`}),t[23]=m,t[24]=M);let N;t[25]===n?N=t[26]:(N=e=>{n&&K.setColorScheme(n,e).catch(wt)},t[25]=n,t[26]=N);let ne;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ne=gt.map(Ct),t[27]=ne):ne=t[27];let P;t[28]!==a||t[29]!==N?(P=(0,$.jsx)(O,{className:`min-w-32`,children:(0,$.jsx)(d,{value:a,onValueChange:N,children:ne})}),t[28]=a,t[29]=N,t[30]=P):P=t[30];let F;t[31]!==M||t[32]!==P?(F=(0,$.jsxs)(A,{children:[M,P]}),t[31]=M,t[32]=P,t[33]=F):F=t[33];let I;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(L,{}),t[34]=I):I=t[34];let re;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(`span`,{children:`Zoom`}),t[35]=re):re=t[35];let ie;t[36]===g?ie=t[37]:(ie=g(K.zoomOut),t[36]=g,t[37]=ie);let ae;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(ue,{}),t[38]=ae):ae=t[38];let R;t[39]!==ie||t[40]!==m?(R=(0,$.jsx)(p,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:ie,"aria-label":`Zoom out`,disabled:m,children:ae}),t[39]=ie,t[40]=m,t[41]=R):R=t[41];let z;t[42]===v?z=t[43]:(z=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:v}),t[42]=v,t[43]=z);let ce;t[44]===g?ce=t[45]:(ce=g(K.zoomIn),t[44]=g,t[45]=ce);let le;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(me,{}),t[46]=le):le=t[46];let H;t[47]!==ce||t[48]!==m?(H=(0,$.jsx)(p,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:ce,"aria-label":`Zoom in`,disabled:m,children:le}),t[47]=ce,t[48]=m,t[49]=H):H=t[49];let de;t[50]===g?de=t[51]:(de=g(K.resetZoom),t[50]=g,t[51]=de);let fe;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(he,{}),t[52]=fe):fe=t[52];let U;t[53]!==de||t[54]!==m?(U=(0,$.jsx)(p,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:de,"aria-label":`Reset zoom`,disabled:m,children:fe}),t[53]=de,t[54]=m,t[55]=U):U=t[55];let pe;t[56]!==R||t[57]!==z||t[58]!==H||t[59]!==U?(pe=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[R,z,H,U]}),t[56]=R,t[57]=z,t[58]=H,t[59]=U,t[60]=pe):pe=t[60];let W;t[61]!==pe||t[62]!==m?(W=(0,$.jsxs)(C,{closeOnClick:!1,onClick:St,className:`justify-between`,disabled:m,children:[re,pe]}),t[61]=pe,t[62]=m,t[63]=W):W=t[63];let G,ge,_e,ve;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(L,{}),ge=(0,$.jsx)(C,{onClick:bt,children:`Clear cookies`}),_e=(0,$.jsx)(C,{onClick:vt,children:`Clear cache`}),ve=(0,$.jsx)(L,{}),t[64]=G,t[65]=ge,t[66]=_e,t[67]=ve):(G=t[64],ge=t[65],_e=t[66],ve=t[67]);let q;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(C,{onClick:()=>f(!0),children:`Import from Chrome…`}),t[68]=q):q=t[68];let J;t[69]!==te||t[70]!==F||t[71]!==W||t[72]!==S||t[73]!==T||t[74]!==k?(J=(0,$.jsxs)(se,{children:[b,(0,$.jsxs)(D,{align:`end`,sideOffset:6,className:`min-w-56`,children:[S,T,k,te,F,I,W,G,ge,_e,ve,q]})]}),t[69]=te,t[70]=F,t[71]=W,t[72]=S,t[73]=T,t[74]=k,t[75]=J):J=t[75];let Y;t[76]===u?Y=t[77]:(Y=(0,$.jsx)(ht,{open:u,onOpenChange:f}),t[76]=u,t[77]=Y);let X;return t[78]!==J||t[79]!==Y?(X=(0,$.jsxs)($.Fragment,{children:[J,Y]}),t[78]=J,t[79]=Y,t[80]=X):X=t[80],X}function vt(){K.clearCache().catch(yt)}function yt(){}function bt(){K.clearCookies().catch(xt)}function xt(){}function St(e){return e.preventDefault()}function Ct(e){return(0,$.jsx)(h,{value:e.value,children:e.label},e.value)}function wt(){}function Tt(){}function Et(e){return v[e]||(e.length>0?e:`Network error`)}function Dt(e){let t=(0,Z.c)(32),{url:n,code:r,description:i,onReload:a}=e,[o,s]=(0,Q.useState)(!1),c;t[0]===n?c=t[1]:(c=At(n)??n,t[0]=n,t[1]=c);let l=c,u;t[2]===i?u=t[3]:(u=Et(i),t[2]=i,t[3]=u);let d=u,f;t[4]!==r||t[5]!==i?(f=i.length>0?i:`ERR_${Math.abs(r)||`FAILED`}`,t[4]=r,t[5]=i,t[6]=f):f=t[6];let m=f,h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(kt,{className:`mb-6 size-12 text-muted-foreground/70`}),g=(0,$.jsx)(`h1`,{className:`mb-3 text-2xl font-semibold leading-tight text-foreground`,children:`This site can’t be reached`}),t[7]=h,t[8]=g):(h=t[7],g=t[8]);let _;t[9]===l?_=t[10]:(_=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:l}),t[9]=l,t[10]=_);let v;t[11]!==d||t[12]!==_?(v=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[_,`: `,d,`.`]}),t[11]=d,t[12]=_,t[13]=v):v=t[13];let y;t[14]===o?y=t[15]:(y=o?(0,$.jsxs)(`div`,{className:`mt-6 rounded-lg border border-border bg-muted/40 p-4 text-sm`,children:[(0,$.jsx)(`p`,{className:`mb-2 font-medium text-foreground`,children:`Try:`}),(0,$.jsxs)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:[(0,$.jsx)(`li`,{children:`Checking your connection`}),(0,$.jsx)(`li`,{children:`Confirming the dev server is running`}),(0,$.jsx)(`li`,{children:`Checking the proxy and the firewall`})]})]}):null,t[14]=o,t[15]=y);let b;t[16]===m?b=t[17]:(b=(0,$.jsx)(`div`,{className:`mt-8 text-xs uppercase tracking-wide text-muted-foreground/70`,children:m}),t[16]=m,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>s(Ot),t[18]=x):x=t[18];let S=o?`Hide details`:`Details`,C;t[19]===S?C=t[20]:(C=(0,$.jsx)(p,{type:`button`,variant:`outline`,size:`sm`,onClick:x,children:S}),t[19]=S,t[20]=C);let w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`div`,{className:`flex-1`}),t[21]=w):w=t[21];let T;t[22]===a?T=t[23]:(T=(0,$.jsx)(p,{type:`button`,size:`sm`,onClick:a,children:`Reload`}),t[22]=a,t[23]=T);let E;t[24]!==C||t[25]!==T?(E=(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-8`,children:[C,w,T]}),t[24]=C,t[25]=T,t[26]=E):E=t[26];let D;return t[27]!==E||t[28]!==v||t[29]!==y||t[30]!==b?(D=(0,$.jsx)(`div`,{className:`relative flex h-full min-h-0 w-full overflow-y-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-1 flex-col px-8 py-12 sm:py-16`,children:[h,g,v,y,b,E]})}),t[27]=E,t[28]=v,t[29]=y,t[30]=b,t[31]=D):D=t[31],D}function Ot(e){return!e}function kt(e){let t=(0,Z.c)(5),{className:n}=e,r,i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`path`,{d:`M16 12 L48 12 L48 52 L16 52 Z`}),i=(0,$.jsx)(`path`,{d:`M22 22 L42 22 M22 30 L36 30 M22 38 L40 38`,strokeLinecap:`round`}),a=(0,$.jsx)(`path`,{d:`M52 8 L12 56`,strokeLinecap:`round`}),t[0]=r,t[1]=i,t[2]=a):(r=t[0],i=t[1],a=t[2]);let o;return t[3]===n?o=t[4]:(o=(0,$.jsxs)(`svg`,{viewBox:`0 0 64 64`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,className:n,children:[r,i,a]}),t[3]=n,t[4]=o),o}function At(e){try{return new URL(e).host}catch{return null}}function jt(e){let t=e.toLowerCase();return t.includes(`mac`)?`Reveal in Finder`:t.includes(`win`)?`Reveal in File Explorer`:`Reveal in Files`}var Mt=120,Nt=220,Pt=4,Ft=90,It=.08,Lt=.5;function Rt(e){let[t,n]=(0,Q.useState)(0),r=(0,Q.useRef)(0);return r.current=t,(0,Q.useEffect)(()=>{if(!e){if(r.current===0)return;n(100);let e=window.setTimeout(()=>n(0),Nt);return()=>window.clearTimeout(e)}n(e=>e>0&&e<95?e:Pt);let t=window.setInterval(()=>{let e=r.current;if(e>=Ft)return;let t=Ft-e,i=Math.max(Lt,t*It);n(Math.min(Ft,e+i))},Mt);return()=>window.clearInterval(t)},[e]),t}var zt=class extends N()(`PreviewSessionThreadKeyParseError`,{threadKey:b}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},Bt=l(e=>{let t=T(e);if(t===null)throw new zt({threadKey:e});let n=i.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=i.events({environmentId:t.environmentId,input:{}});return P(e=>{let i=!1,a=0,o=e=>{x(e)&&m(t,e.value)},c=r=>{if(!x(r)||r.value.threadId!==t.threadId)return;let i=u(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}s(t,r.value)};e.addFinalizer(()=>{i=!0});let l=e.once(r);e.subscribe(n,e=>{o(e)}),e.subscribe(r,e=>{a+=1,c(e)}),queueMicrotask(()=>{i||(e.refresh(n),a===0&&c(l))})}).pipe(o(1e3),_(`preview:session-sync:${e}`))});function Vt(e){let t=(0,Z.c)(2),n;t[0]===e?n=t[1]:(n=Bt(f(e)),t[0]=e,t[1]=n),ce(n)}var Ht=1500,Ut=.001;function Wt(e){let t=(0,Z.c)(11),{zoomFactor:n}=e,[r,i]=(0,Q.useState)(!1),o=(0,Q.useRef)(n),s=(0,Q.useRef)(null),c,l;t[0]===n?(c=t[1],l=t[2]):(c=()=>{if(!(Math.abs(o.current-n)<Ut))return o.current=n,i(!0),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{i(!1),s.current=null},Ht),()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null)}},l=[n],t[0]=n,t[1]=c,t[2]=l),(0,Q.useEffect)(c,l);let u;t[3]===n?u=t[4]:(u=Math.round(n*100),t[3]=n,t[4]=u);let d=`${u}%`,f=!r,p=r?`opacity-100 translate-y-0`:`opacity-0 -translate-y-1`,m;t[5]===p?m=t[6]:(m=a(`pointer-events-none absolute top-3 right-3 z-20 select-none rounded-full border border-border/70 bg-popover/95 px-2.5 py-1 text-xs font-medium text-foreground shadow-md/10 backdrop-blur transition-all duration-200 ease-out`,p),t[5]=p,t[6]=m);let h;return t[7]!==d||t[8]!==f||t[9]!==m?(h=(0,$.jsx)(`div`,{"aria-hidden":f,className:m,children:d}),t[7]=d,t[8]=f,t[9]=m,t[10]=h):h=t[10],h}function Gt(e,t){return e?1:t===`human`?.18:.35}var Kt=700;function qt(e){let t=(0,Z.c)(9),{tabId:n,zoomFactor:r,controller:i}=e,a;t[0]===n?a=t[1]:(a=e=>e.byTabId[n]??null,t[0]=n,t[1]=a);let o=je(a),s;t[2]===n?s=t[3]:(s=e=>e.byTabId[n]?.content??null,t[2]=n,t[3]=s);let c=xe(s);if(!o)return null;let l;return t[4]!==c||t[5]!==i||t[6]!==o||t[7]!==r?(l=(0,$.jsx)(Jt,{event:o,content:c,zoomFactor:r,controller:i},o.sequence),t[4]=c,t[5]=i,t[6]=o,t[7]=r,t[8]=l):l=t[8],l}function Jt(e){let t=(0,Z.c)(15),{event:n,content:r,zoomFactor:i,controller:a}=e,[o,s]=(0,Q.useState)(!0),c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=window.setTimeout(()=>s(!1),Kt);return()=>window.clearTimeout(e)},l=[],t[0]=c,t[1]=l):(c=t[0],l=t[1]),(0,Q.useEffect)(c,l);let u;t[2]!==o||t[3]!==a?(u=Gt(o,a),t[2]=o,t[3]=a,t[4]=u):u=t[4];let d=`translate3d(${n.x*i*(r?.scale??1)+(r?.x??0)-(r?.scrollLeft??0)}px, ${n.y*i*(r?.scale??1)+(r?.y??0)-(r?.scrollTop??0)}px, 0)`,f;t[5]!==u||t[6]!==d?(f={opacity:u,transform:d},t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;t[8]!==n.phase||t[9]!==n.sequence?(p=n.phase===`click`?(0,$.jsx)(`span`,{className:`absolute left-0.5 top-0.5 size-4 animate-status-ping rounded-full bg-primary/25 motion-reduce:animate-none`},n.sequence):null,t[8]=n.phase,t[9]=n.sequence,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(X,{className:`relative size-5 -translate-x-0.5 -translate-y-0.5 fill-background text-primary drop-shadow-sm`,strokeWidth:2}),t[11]=m):m=t[11];let h;return t[12]!==f||t[13]!==p?(h=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute left-0 top-0 z-40 transition-[transform,opacity] duration-150 ease-out motion-reduce:transition-none`,style:f,"aria-hidden":`true`,"data-agent-browser-cursor":!0,children:[p,m]}),t[12]=f,t[13]=p,t[14]=h):h=t[14],h}var Yt=typeof window>`u`?null:g();function Xt({threadRef:e,tabId:t,configuredUrls:n,visible:r}){let[a,o]=(0,Q.useState)(void 0),[s,l]=(0,Q.useState)(!1),u=Ve(),d=(0,Q.useRef)(!1),p=(0,Q.useRef)(!0),m=ee(e),h=ye(t=>ge(t.byThreadKey,e)),g=w(e=>e.addPreviewAnnotation),_=w(e=>e.addImage),v=c(e.environmentId),y=R(e.environmentId),b=S(i.open),x=S(i.resize,`preview viewport resize`),{resolvedTheme:C}=z();Vt(e),(0,Q.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]);let T=t??m.activeTabId,E=T?Xe(e,m.serverEpoch,T):null,D=T&&E?u.has(E)?E:Ue(e,T):null,O=T?m.sessions[T]??null:null,A=T?m.desktopByTabId[T]??null:null;(0,Q.useEffect)(()=>{let e=K;if(!(!e||!E||!A?.pictureInPicture))return e.pictureInPicture.setVisible(E,r),()=>{e.pictureInPicture.setVisible(E,!1)}},[A?.pictureInPicture,E,r]);let j=O?.navStatus??{_tag:`Idle`},M=j._tag===`Idle`?``:j.url,N=A?.loading??j._tag===`Loading`,P=A?.canGoBack??O?.canGoBack??!1,L=A?.canGoForward??O?.canGoForward??!1,oe=j._tag===`Idle`,B=j._tag===`LoadFailed`,V=Pe(O),se=A?.controller??`none`,ce=Rt(N),ue=M&&v&&y?rt({url:M,environmentLabel:v.label,environmentHttpBaseUrl:y})??void 0:void 0,H=O?.viewport??te,U=xe(e=>E?e.byTabId[E]?.rect??null:null),W=(0,Q.useCallback)(async t=>{E&&K?(await K.navigate(E,t),re(e,t)):await fe({openPreview:b,threadRef:e,url:t})},[b,E,e]),G=(0,Q.useCallback)(async e=>{try{await W(pe(e))}catch{}},[W]),me=(0,Q.useCallback)(async t=>{try{await W(Je(e.environmentId,t))}catch{}},[W,e.environmentId]),he=(0,Q.useCallback)(()=>{K&&E&&K.refresh(E)},[E]),_e=(0,Q.useCallback)(()=>{K&&E&&K.zoomIn(E)},[E]),ve=(0,Q.useCallback)(()=>{K&&E&&K.zoomOut(E)},[E]),q=(0,Q.useCallback)(()=>{K&&E&&K.resetZoom(E)},[E]),J=(0,Q.useCallback)(async t=>{if(!T)return;let n=await x({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:T,viewport:t}});if(n._tag===`Failure`){let e=I(n);throw F.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}k(e,n.value)},[x,T,e]),Y=()=>{if(!E)return;if(H._tag!==`fill`){Ge(E,te).catch(()=>void 0);return}let e=U?We(U,A?.zoomFactor):{width:1024,height:768};Ge(E,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Q.useEffect)(()=>{if(E)return ze(E,J)},[J,E]);let X=(0,Q.useCallback)(()=>{K&&E&&K.goBack(E)},[E]),be=(0,Q.useCallback)(()=>{K&&E&&K.goForward(E)},[E]),Se=(0,Q.useCallback)(()=>{!Yt||!M||Yt.shell.openExternal(M).catch(()=>void 0)},[M]),Ce=(0,Q.useCallback)(()=>{if(T){if(h?.tabId===T){ye.getState().close(e);return}ye.getState().open(e,T),ae.getState().close(e)}},[h?.tabId,T,e]),we=(0,Q.useCallback)(()=>{!K||!E||(A?.pictureInPicture?K.pictureInPicture.close:K.pictureInPicture.open)(E).catch(e=>{F.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[A?.pictureInPicture,E]),Te=(0,Q.useCallback)(t=>{if(!K||!E||!T)return;let n=K;if(D){De(D).then(e=>{if(!e)return;let t=!1,r,i=()=>{if(!navigator.clipboard?.writeText){F.update(r,ne({type:`error`,title:`Unable to copy recording path`,description:`Clipboard API unavailable.`,actionProps:a}));return}navigator.clipboard.writeText(e.path).then(()=>{t=!0,o(),window.setTimeout(()=>{t=!1,o()},2e3)},e=>{F.update(r,ne({type:`error`,title:`Unable to copy recording path`,description:e instanceof Error?e.message:`An error occurred.`,actionProps:a}))})},a={children:jt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},o=()=>{F.update(r,ne({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:t?`Copied!`:`Copy path`,disabled:t,onClick:i},secondaryActionVariant:`outline`}}))};r=F.add(ne({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:`Copy path`,onClick:i},secondaryActionVariant:`outline`}}))},e=>{F.add({type:`error`,title:`Unable to stop recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}if(t){Ne(E,e,T).catch(e=>{F.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}n.captureScreenshot(E).then(e=>{let t={children:jt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,n=`Screenshot saved`,o)=>{F.update(a,ne({type:e,title:n,description:o,actionProps:{children:i?`Copied!`:`Copy image`,disabled:i,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:r?`Copied!`:`Copy path`,disabled:r,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},s=()=>{if(!navigator.clipboard?.writeText){o(`error`,`Unable to copy screenshot path`,`Clipboard API unavailable.`);return}navigator.clipboard.writeText(e.path).then(()=>{r=!0,o(),window.setTimeout(()=>{r=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot path`,e instanceof Error?e.message:`An error occurred.`)})},c=()=>{n.copyArtifactToClipboard(e.path).then(()=>{i=!0,o(),window.setTimeout(()=>{i=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot`,e instanceof Error?e.message:`An error occurred.`)})};a=F.add(ne({type:`success`,title:`Screenshot saved`,actionProps:{children:`Copy image`,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:`Copy path`,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},e=>{F.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[D,E,T,e]),Ee=(0,Q.useCallback)(()=>{if(!K||!E)return;if(d.current){K.cancelPickElement(E).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;d.current=!0,l(!0),(async()=>{try{let t=await K.pickElement(E);if(!t)return;g(e,t);let n=await Ye(t);n&&t.screenshot&&_(e,{type:`image`,id:t.id,name:n.name,mimeType:n.type,sizeBytes:n.size,previewUrl:t.screenshot.dataUrl,file:n})}catch{}finally{if(d.current=!1,p.current&&l(!1),t&&t.isConnected&&typeof t.focus==`function`)try{t.focus({preventScroll:!0})}catch{}}})()},[_,g,E,e]);return(0,Q.useEffect)(()=>{let e=ie(M,C);e&&W(e).catch(()=>void 0)},[W,C,M]),(0,Q.useEffect)(()=>()=>{d.current&&(d.current=!1,K&&E&&K.cancelPickElement(E).catch(()=>void 0),p.current&&l(!1))},[E]),(0,Q.useEffect)(()=>{if(r)return le(e=>{switch(e){case`refresh`:he();return;case`focus-url`:o(e=>(e??0)+1);return;case`zoom-in`:_e();return;case`zoom-out`:ve();return;case`reset-zoom`:q();return;case`toggle-panel`:return}})},[he,q,_e,ve,r]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":f(e),children:[(0,$.jsx)(tt,{url:M,displayUrl:ue,loading:N,loadProgress:ce,canGoBack:P,canGoForward:L,refreshDisabled:oe,focusUrlNonce:a,onBack:X,onForward:be,onRefresh:he,onSubmit:e=>void G(e),onOpenInBrowser:T?Se:void 0,onCapture:K&&T?Te:void 0,captureDisabled:!A||B,recording:D!==null,onPictureInPicture:K&&T?Ce:void 0,pictureInPicture:h?.tabId===T,pictureInPictureDisabled:!A?.hasWebContents||B,onPickElement:K&&T?Ee:void 0,pickActive:s,pickDisabled:!T||B,pickDisabledReason:B?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:K?(0,$.jsx)(_t,{tabId:E,hasWebContents:A?.hasWebContents??!1,zoomFactor:A?.zoomFactor??1,colorScheme:A?.colorScheme??`system`,deviceToolbarVisible:H._tag!==`fill`,onToggleDeviceToolbar:Y,nativePictureInPicture:A?.pictureInPicture??!1,onNativePictureInPicture:we}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[E&&O&&!V?(0,$.jsx)(de,{tabId:E,visible:r&&!B,className:`absolute inset-0 h-full w-full`},E):null,V?(0,$.jsx)(pt,{environmentId:e.environmentId,configuredUrls:n,recentlySeenUrls:m.recentlySeenUrls,onOpenUrl:e=>void me(e)}):null,O&&A?(0,$.jsx)(Wt,{zoomFactor:A.zoomFactor}):null,E&&A&&!V&&!B?(0,$.jsx)(qt,{tabId:E,zoomFactor:A.zoomFactor,controller:se}):null,se===`none`?null:(0,$.jsx)(`div`,{className:`pointer-events-none absolute left-3 top-3 z-40 rounded-full border border-border/70 bg-background/90 px-2.5 py-1 text-[11px] font-medium shadow-sm backdrop-blur`,children:se===`agent`?`Agent controlling browser`:`Human control`}),j._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(Dt,{url:j.url,code:j.code,description:j.description,onReload:he})}):null]})]})}function Zt(e){let t=(0,Z.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!E()){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:(0,$.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:`Preview is only available in the P4 Code desktop app.`})}),t[0]=e):e=t[0];let r;return t[1]===n?r=t[2]:(r=(0,$.jsx)(G,{mode:n,children:e}),t[1]=n,t[2]=r),r}let s;t[3]===i?s=t[4]:(s=i===void 0?{}:{tabId:i},t[3]=i,t[4]=s);let c;t[5]!==a||t[6]!==s||t[7]!==r||t[8]!==o?(c=(0,$.jsx)(Xt,{threadRef:r,...s,configuredUrls:a,visible:o}),t[5]=a,t[6]=s,t[7]=r,t[8]=o,t[9]=c):c=t[9];let l;return t[10]!==n||t[11]!==c?(l=(0,$.jsx)(G,{mode:n,children:c}),t[10]=n,t[11]=c,t[12]=l):l=t[12],l}export{Zt as PreviewPanel};
2
+ //# sourceMappingURL=PreviewPanel-BH0iIJ9a.js.map