@p4code/cli 0.0.37 → 0.0.38

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{C as e,Ds as t,E as n,Ff as r,It as i,Ss as a,Wf as o,Wo as s,Xt as c,b as l,g as u,m as d,os as f,p,ql as m,qo as h,sp as g,ss as _,tn as v,up as y,v as b}from"./textarea-DXib_Xm1.js";import{a as x,c as S,i as C,n as ee,o as w,r as te,s as T,t as ne}from"./fileCommentAnnotations-BKadMjLJ.js";import{Bt as E,C as D,En as O,F as k,Fr as A,Gn as j,Gt as M,Hn as re,I as ie,L as ae,Mt as N,N as oe,Nr as se,P as ce,Qn as le,Qt as ue,S as de,Sr as P,Tr as fe,Ut as pe,Wn as me,_ as he,b as ge,d as _e,dn as ve,dr as ye,f as be,fn as xe,fr as Se,g as Ce,j as we,jr as Te,kt as Ee,l as F,ln as De,lr as Oe,m as ke,mn as Ae,mr as je,nn as Me,p as Ne,pn as Pe,pr as Fe,qn as Ie,u as Le,un as Re,ur as ze,v as Be,vr as Ve,x as He,xt as Ue,yr as We,yt as Ge,zt as Ke}from"./index-qr_OWE66.js";var qe=h(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Je=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`}]]),Ye=`file-tree-container`,Xe=`data-file-tree-style`,Ze=`data-file-tree-unsafe-css`,Qe=`data-file-tree-scrollbar-measure`,$e=`data-file-tree-scrollbar-gutter-measured`,et=`--trees-scrollbar-gutter-measured`,tt=`header`,nt=`context-menu`,rt=`context-menu-trigger`,it=5,at=1<<it,ot=at*4;function st(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function ct(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function lt(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 ut(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 dt(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function I(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 L(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,ht(e,t)}function ft(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=ut(e).get(t);if(i===void 0)return;let a=i>>it;e.childVisibleChunkSums[a]+=r}function pt(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=gt(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=at}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 mt(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>it;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<it}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 ht(e,t){if(t.childIds.length<ot){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/at),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>>it]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function gt(e,t,n,r){let i=Math.min(t.childIds.length,n+at),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 _t=7,vt=3,yt=1<<vt,bt=4;function R(e,t,n=0){return e<<bt|n<<vt|t}function xt(e){return e.depthAndFlags>>>bt}function z(e){return(e.depthAndFlags&yt)>>vt}function B(e){return(e.depthAndFlags&yt)!==0}function St(e){return e.depthAndFlags&_t}function V(e,t){return(St(e)&t)!==0}function Ct(e,t){e.depthAndFlags|=t}function wt(e,t){e.depthAndFlags=R(t,St(e),z(e))}var Tt=Symbol(`benchmarkInstrumentation`);function Et(e,t){return t==null||Object.defineProperty(e,Tt,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function Dt(e){return e==null?null:e[Tt]??null}function H(e,t,n){return e==null?n():e.measurePhase(t,n)}function Ot(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function kt(e){return e>=48&&e<=57}function At(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!kt(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&&kt(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 jt(e){let t=e.toLowerCase();return{lowerValue:t,tokens:At(t)}}function Mt(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 Nt(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=Mt(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function Pt(e,t,n){let r=Nt(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function Ft(e,t){return Pt(e,t,jt)}function It(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function Lt(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=It(e,r);return a===It(t,r)?Ft(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 Rt(e,t){return Lt(e,t)}function zt(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=jt(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=It(e,n);return o===It(t,n)?Pt(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 Bt(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=jt(r);return e.sortKeyById[t]=i,i}function Vt(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function Ht(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 Ut(e){let{hasTrailingSlash:t,segments:n}=Ht(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function Wt(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=Ht(e);return{requiresDirectory:t,segments:n}}var Gt=``;function Kt(){let e=new Map;return e.set(Gt,0),{idByValue:e,valueById:[Gt],sortKeyById:[jt(Gt)]}}function qt(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 Jt(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var Yt=Symbol(`pathStorePreparedInputKind`);function Xt(e,t){return e[Yt]=t,e}function Zt(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function Qt(e,t,n){return n==="default"?Rt(e,t):n(Zt(e),Zt(t))}function $t(){return{depthAndFlags:R(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function en(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 tn(e){return e.isDirectory?e.segments.length:e.segments.length-1}function nn(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 rn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function an(e,t={}){return dn(e,t).map(e=>e.path)}function on(e,t={}){let n=dn(e,t);return Xt({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function sn(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 Xt({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function cn(e){let t=e,n=t.preparedPaths;if(t[Yt]===`prepared`&&n!=null)return n;if(!nn(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function ln(e){let t=e;return t[Yt]===`presorted`&&t.presortedPaths!=null||rn(t.presortedPaths)?t.presortedPaths:null}function un(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function dn(e,t={}){let n=Vt(t),r=Dt(t);Ot(r,`workload.inputFiles`,e.length);let i=H(r,`store.preparePathEntries.parse`,()=>e.map(e=>Ut(e)));return H(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>Qt(e,t,n.sort))),i}var fn=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[$t()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=Kt();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=Dt(e),this.options=Vt(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,st())}appendPaths(e){return H(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>Ut(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:R(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:R(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:R(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=Ut(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:R(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:R(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=Ut(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"?zt(this.lastPreparedPath,e,this.segmentSortKeyCache):Qt(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=tn(e),i=n==null?0:tn(n),a=n==null?0:en(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=qt(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:R(xt(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),dt(i,s),s}createFileChildUnchecked(e,t){let n=qt(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:R(xt(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),dt(r,a),a}getOrCreateDirectoryChild(e,t){let n=qt(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&&!B(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:R(xt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),dt(r,a),this.directories.set(a,st()),a}createDirectoryChild(e,t){let n=qt(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:R(xt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),dt(r,a),this.directories.set(a,st()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!B(n))throw Error(`Path is not a directory: "${t}"`);if(V(n,1))throw Error(`Duplicate path: "${t}"`);Ct(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,ct());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(B(a)){let t=ct();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;B(n)&&this.directories.set(t,st());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),dt(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!B(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 L(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function pn(e,t=`closed`,n=null){let r=hn(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 hn(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 gn(e,t){return V(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion===`closed`?!1:xt(t)<=e.defaultExpansion}function _n(e,t,n=e.snapshot.nodes[t]){return n==null||!B(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:gn(e,n)}function vn(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!B(r))return;let i=gn(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 yn(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 bn(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function xn(e,t){let n=yn(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 Sn(e,t){let n=yn(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function Cn(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 wn(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Tn(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 En(e,t){e.directoryLoadInfoById.delete(t)}function Dn(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 On(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function kn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function An(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function jn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Mn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Nn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Pn(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 Fn(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 In(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 Ln(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 Rn(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 zn(e,t,n){return{...n,visibleCountDelta:Xn(e)-t}}function Bn(e,t){let n=Xn(e),r=mn();e.transactionStack.push(r);try{t()}catch(t){throw Un(e,r,!1),t}Un(e,r,!0,Xn(e)-n)}function Vn(e,t){let n=e.instrumentation;if(n==null){Hn(e,t);return}H(n,`store.events.record`,()=>Hn(e,t))}function Hn(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){Jn(e,t);return}n.events.push(t),qn(n,t)}function Un(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?Kn(i,t):H(n,`store.events.batch.merge`,()=>Kn(i,t));return}let a=Wn(t,r),o=e.instrumentation;if(o==null){Jn(e,a);return}H(o,`store.events.batch.commit`,()=>Jn(e,a))}function Wn(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 Gn(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function Kn(e,t){for(let n of t.events)e.events.push(n);Gn(e,t)}function qn(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function Jn(e,t){let n=e.instrumentation;if(n==null){Yn(e,t);return}H(n,`store.events.emit`,()=>Yn(e,t))}function Yn(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function Xn(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function Zn(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!B(n)||V(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||!B(a)?null:i}function Qn(e,t){let n=t;for(;;){let t=Zn(e,n);if(t==null)return n;n=t}}function $n(e,t){let n=[t],r=t;for(;;){let t=Zn(e,r);if(t==null)return n;n.push(t),r=t}}function er(e,t){let n=t==null?e.snapshot.rootId:lr(e,t);return n==null?[]:dr(e,n)}function tr(e,t){let n=Ut(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Er(e,Tr(e,r)),{createdNodeIds:a,directoryId:o}=fr(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=G(e,o);if(V(n,1))throw Error(`Path already exists: "${t}"`);Ct(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=mr(e,o,n.basename),s.add(c);or(e,o);let l=Er(e,o);return On({affectedAncestorIds:cr(e,c),affectedNodeIds:[...s],path:t,projectionChanged:Dr(i,l)})}function nr(e,t,n){let r=lr(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=G(e,r);if(V(i,2))throw Error(`The root node cannot be removed`);if(B(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=Er(e,a),s=Cr(e,r);_r(e,a,r,i.nameId),wr(e,a),or(e,a);let c=Er(e,a);return kn({affectedAncestorIds:cr(e,a),affectedNodeIds:s,path:t,projectionChanged:Dr(o,c),recursive:n.recursive===!0})}function rr(e,t,n,r){let i=lr(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=G(e,i);if(V(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=xr(e,i,n),c=Er(e,a.parentId),l=Er(e,s.parentId),u=Jt(e.snapshot.segmentTable,a.nameId),d=qt(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(B(a)&&jr(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=lt(e.snapshot.nodes,W(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&Sr(e,p,o,z(a))===`skip`)return null;let m=a.parentId;_r(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),Ar(e,i),gr(e,s.parentId,i),wr(e,m),e.pathCacheVersion++,or(e,m),s.parentId!==m&&or(e,s.parentId);let h=Er(e,m),g=Er(e,s.parentId);return An({affectedAncestorIds:[...new Set([...cr(e,m),...cr(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:Or([c,l],[h,g]),to:U(e,i)})}function ir(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function ar(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function U(e,t){let n=G(e,t),r=ir(e,t);if(r!=null)return r;if(V(n,2))return ar(e,t,``);let i=U(e,n.parentId),a=Jt(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return ar(e,t,B(n)?`${o}/`:o)}function or(e,t){let n=e.instrumentation;if(n==null){Nr(e,t);return}H(n,`store.recomputeCountsUpwardFrom`,()=>Nr(e,t))}function sr(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||!B(o)){Mr(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){Mr(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function cr(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 lr(e,t){if(t.length===0)return e.snapshot.rootId;let n=Wt(t);return ur(e,n.segments,n.requiresDirectory)}function ur(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=lt(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=G(e,r);return n&&!B(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||V(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function dr(e,t){let n=e.snapshot.nodes[t];if(n===void 0||V(n,4))return[];if(!B(n))return[U(e,t)];if(W(e,t).childIds.length===0)return V(n,1)&&!V(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||V(n,4)){i.pop();continue}if(!B(n)){r.push(U(e,t.nodeId)),i.pop();continue}let a=W(e,t.nodeId);if(a.childIds.length===0){V(n,1)&&!V(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 fr(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=qt(e.snapshot.segmentTable,i),a=W(e,r),o=lt(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!B(G(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=pr(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function pr(e,t,n){let r=G(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:R(xt(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,st()),gr(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function mr(e,t,n){let r=qt(e.snapshot.segmentTable,n),i=W(e,t);if(lt(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${Fr(e,t,n)}"`);let a=G(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:R(xt(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),gr(e,t,o),e.activeNodeCount++,o}function hr(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}vr(e,n,o)<0?i=a:r=a+1}return r}function gr(e,t,n){let r=W(e,t),i=G(e,n);lt(e.snapshot.nodes,r).set(i.nameId,n),ft(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=hr(e,r,n);r.childIds.splice(a,0,n),I(r,a),ht(e.snapshot.nodes,r)}function _r(e,t,n,r){let i=W(e,t),a=ut(i),o=a.get(n)??-1;lt(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&ft(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),I(i,o),ht(e.snapshot.nodes,i))}function vr(e,t,n){let r=e.snapshot.options.sort;return r==="default"?yr(e,t,n):r(br(e,t),br(e,n))}function yr(e,t,n){let r=G(e,t),i=G(e,n),a=B(r);if(a!==B(i))return a?-1:1;let o=Nt(Bt(e.snapshot.segmentTable,r.nameId),Bt(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=Jt(e.snapshot.segmentTable,r.nameId),c=Jt(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function br(e,t){let n=G(e,t),r=U(e,t),i=B(n),a=i?r.slice(0,-1):r;return{basename:Jt(e.snapshot.segmentTable,n.nameId),depth:xt(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function xr(e,t,n){let r=G(e,t),i=lr(e,n);if(i!=null){let t=G(e,i);if(B(t))return{basename:Jt(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=Wt(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=Wt(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:ur(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function Sr(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(z(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(B(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 Cr(e,t),_r(e,a,t,o),wr(e,a),or(e,a),`handled`}function Cr(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||!B(i)){B(i)&&e.snapshot.directories.delete(t.nodeId),Ct(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),En(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 wr(e,t){let n=t;for(;n!=null;){let t=G(e,n);if(!B(t)||V(t,2)||W(e,n).childIds.length>0)return;Ct(t,1),n=t.parentId===n?null:t.parentId}}function Tr(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=lt(e.snapshot.nodes,W(e,n)).get(t);if(i==null||!B(G(e,i)))break;n=i}return n}function Er(e,t){let n=kr(e,t);if(n==null)return null;let r=Qn(e,n),i=G(e,r),a=n===r?null:$n(e,n).map(t=>U(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:W(e,r).childIds.length>0,path:U(e,r),terminalKind:z(i)})}function Dr(e,t){return Or([e],[t])}function Or(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 kr(e,t){let n=t;for(;n!=null;){let t=G(e,n);if(!B(t)||V(t,2))return null;if(!_n(e,n,t))return n;n=t.parentId}return null}function Ar(e,t){let n=G(e,t);if(wt(n,(t===e.snapshot.rootId?-1:xt(G(e,n.parentId)))+1),!B(n))return;let r=W(e,t);for(let t of r.childIds)Ar(e,t)}function jr(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 Mr(e,t,n=G(e,t),r=!1){let i=e.instrumentation;if(i==null){Pr(e,t,n,r);return}H(i,`store.recomputeNodeCounts`,()=>Pr(e,t,n,r))}function Nr(e,t){let n=t;for(;n!=null;){let t=G(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(Mr(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&ft(W(e,s),n,a,o),n=s}}function Pr(e,t,n,r){if(!B(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=W(e,t);if(r){let t=e.instrumentation;t==null?L(e.snapshot.nodes,i):H(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>L(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,V(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=Zn(e,t)==null?_n(e,t,n)?1+o:1:o}function Fr(e,t,n){let r=U(e,t);return r.length===0?n:`${r}${n}`}function Ir(e){return e!=null&&!V(e,4)}function Lr(e,t){let n=e.snapshot.nodes[t];return!Ir(n)||!B(n)||V(n,2)?null:n}function Rr(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&Ir(e.snapshot.nodes[n])&&(t+=1);return t}function zr(e){return Math.max(0,e.valueById.length-1)}function Br(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:Rr(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:zr(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function Vr(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 Hr(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)Lr(e,n)!=null&&t.push(U(e,n));for(let t of e.expandedDirectoryIds)Lr(e,t)!=null&&n.push(U(e,t));return{collapsedPaths:t,expandedPaths:n}}function Ur(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)Lr(e,n)==null||bn(e,n)===`loaded`||t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:U(e,n)});return t}function Wr(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=lr(e,n);t!=null&&vn(e,t,!0,G(e,t))}for(let n of t.collapsedPaths){let t=lr(e,n);t!=null&&vn(e,t,!1,G(e,t))}}function Gr(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=lr(e,n.path);t!=null&&Lr(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function Kr(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function qr(e){let t=e.snapshot.segmentTable,n=Kt();for(let r of e.snapshot.nodes)if(Ir(r)){if(V(r,2)){r.nameId=0;continue}r.nameId=qt(n,Jt(t,r.nameId))}e.snapshot.segmentTable=n}function Jr(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!Ir(r)||!B(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return Ir(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])),L(e.snapshot.nodes,n)}}function Yr(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(Ir(n))break;--t}e.snapshot.nodes.length=t+1}function Xr(e){let t=Hr(e),n=Ur(e);H(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>Kr(e)),H(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>qr(e)),H(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>Jr(e)),H(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>Yr(e)),H(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>Wr(e,t)),H(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>Gr(e,n)),H(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>sr(e,e.snapshot.rootId))}function Zr(e){let t=Hr(e),n=Ur(e),r=H(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>er(e)),i=Et({...e.snapshot.options},e.instrumentation),a=H(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new fn(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`,()=>Wr(e,t)),H(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>Gr(e,n)),H(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>sr(e,e.snapshot.rootId))}function Qr(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function $r(e,t){let n=Br(e);t===`stable`?H(e.instrumentation,`store.cleanup.stable`,()=>Xr(e)):H(e.instrumentation,`store.cleanup.aggressive`,()=>Zr(e));let r=Br(e);return Vr(t,t===`stable`,n,r)}var ei=64;function ti(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 ni(e){return G(e,e.snapshot.rootId).visibleSubtreeCount}function ri(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 ii(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:Ci(e,t.cursor),setSize:t.setSize,subtreeEndIndex:ri(e,t.cursor,t.index,n)}}function ai(e,t,n,r,i,a){let o=W(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=pt(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return oi(e,u,l,r+c,i+1,s,o.childIds.length,a)}function oi(e,t,n,r,i,a,o,s){if(!B(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=_i(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=G(e,c.terminalNodeId);if(!B(l)||!_n(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return ai(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function si(e,t){let n=ni(e);if(t<0||t>=n)return null;let r=ai(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=ii(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:Ci(e,r.cursor),setSize:r.setSize,subtreeEndIndex:ri(e,r.cursor,r.index,n)}}function ci(e,t,n){let r=e.instrumentation,i=ni(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 Si(e,o+1);let t=[],n=mi(e,a);for(let r=a;r<=o&&n!=null;r++){let r=Ci(e,n);t.push(r),n=yi(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`,()=>Ci(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=H(r,`store.getVisibleSlice.advanceCursor`,()=>yi(e,u))}return Ot(r,`workload.visibleRowsRead`,s.length),Ot(r,`workload.flattenedRowsRead`,c),Ot(r,`workload.flattenedSegmentsRead`,l),s}function li(e,t=ni(e)){let n=e.instrumentation;return n==null?xi(e,t):H(n,`store.getVisibleTreeProjection`,()=>xi(e,t))}function ui(e){return bi(li(e))}function di(e,t){let n=lr(e,t);if(n==null||n===e.snapshot.rootId||B(G(e,n))&&Qn(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=ut(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=mt(a,n,s),t!==o){let n=G(e,t),a=Zn(e,t);if(!_n(e,t,n)&&a!==i)return null;Qn(e,t)===t&&(r+=1)}i=t}return r}function fi(e,t){let n=lr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=G(e,n);if(!B(r))throw Error(`Path is not a directory: "${t}"`);return _n(e,n,r)?null:(vn(e,n,!0,r),or(e,n),jn({affectedAncestorIds:cr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function pi(e,t){let n=lr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=G(e,n);if(!B(r))throw Error(`Path is not a directory: "${t}"`);return _n(e,n,r)?(vn(e,n,!1,r),or(e,n),Mn({affectedAncestorIds:cr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function mi(e,t){return t<0||t>=ni(e)?null:hi(e,e.snapshot.rootId,t,-1)}function hi(e,t,n,r){let i=W(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?pt(e.snapshot.nodes,i,n):H(a,`store.getVisibleSlice.selectChildIndex`,()=>pt(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return gi(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function gi(e,t,n,r){if(!B(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=_i(e,t,r);if(n===0)return i;let a=G(e,i.terminalNodeId);if(!B(a)||!_n(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return hi(e,i.terminalNodeId,n-1,i.visibleDepth)}function _i(e,t,n){return B(G(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:Qn(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:H(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>Qn(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function vi(e,t){let n=G(e,t);if(!B(n))return!0;let r=n.parentId;return r===e.snapshot.rootId?!0:Zn(e,r)!==t}function yi(e,t){let n=G(e,t.terminalNodeId);if(B(n)){let r=W(e,t.terminalNodeId);if(_n(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:gi(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=ut(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 gi(e,s,0,i);vi(e,r)&&i--,r=n}}function bi(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 xi(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(ei);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=ti(o,y);let x,S=_;if(B(v))S=f?Qn(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&&B(C)&&_n(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 Si(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(!B(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?Qn(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=Ci(e,g);let _=i[h];_!=null&&B(_)&&_n(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function Ci(e,t){let n=G(e,t.terminalNodeId),r=B(n)?wi(e,t):null,i=U(e,t.terminalNodeId),a=Jt(e.snapshot.segmentTable,n.nameId),o=B(n)&&W(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?$n(e,t.headNodeId).map(n=>{let r=G(e,n);return{isTerminal:n===t.terminalNodeId,name:Jt(e.snapshot.segmentTable,r.nameId),nodeId:n,path:U(e,n)}}):H(c,`store.getVisibleSlice.flatten.collectSegments`,()=>$n(e,t.headNodeId).map(n=>{let r=G(e,n);return{isTerminal:n===t.terminalNodeId,name:Jt(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:B(n)&&_n(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:B(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function wi(e,t){if(t.headNodeId===t.terminalNodeId)return bn(e,t.terminalNodeId);let n=$n(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=bn(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}function Ti(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||!B(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&&ht(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&B(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,ht(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Ei(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var Di=class e{#e;constructor(e={}){let t=Dt(e),n=H(t,`store.builder.create`,()=>new fn(e));if(e.preparedInput!=null){let t=ln(e.preparedInput);t==null?n.appendPreparedPaths(cn(e.preparedInput),!1):n.appendPresortedPaths(t,un(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(H(t,`store.preparePathEntries`,()=>dn(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`,()=>pn(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||Ei(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`,()=>Ti(this.#e)):H(t,`store.state.recomputeCounts`,()=>sr(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return an(e,t)}static prepareInput(e,t={}){return on(e,t)}static preparePresortedInput(e){return sn(e)}list(e){return H(this.#e.instrumentation,`store.list`,()=>er(this.#e,e))}add(e){H(this.#e.instrumentation,`store.add`,()=>{let t=ni(this.#e);Vn(this.#e,zn(this.#e,t,tr(this.#e,e)))})}remove(e,t={}){H(this.#e.instrumentation,`store.remove`,()=>{let n=ni(this.#e);Vn(this.#e,zn(this.#e,n,nr(this.#e,e,t)))})}move(e,t,n={}){H(this.#e.instrumentation,`store.move`,()=>{let r=ni(this.#e),i=rr(this.#e,e,t,n);i!=null&&Vn(this.#e,zn(this.#e,r,i))})}batch(e){Bn(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`,()=>ni(this.#e))}getVisibleSlice(e,t){return H(this.#e.instrumentation,`store.getVisibleSlice`,()=>ci(this.#e,e,t))}getVisibleRowContext(e){return H(this.#e.instrumentation,`store.getVisibleRowContext`,()=>si(this.#e,e))}getVisibleTreeProjection(){return ui(this.#e)}getVisibleTreeProjectionData(e){return li(this.#e,e)}getVisibleIndex(e){return H(this.#e.instrumentation,`store.getVisibleIndex`,()=>di(this.#e,e))}getPathInfo(e){return H(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=lr(this.#e,e);if(t==null)return null;let n=G(this.#e,t);return{depth:xt(n),kind:B(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 _n(this.#e,t,n)})}expand(e){H(this.#e.instrumentation,`store.expand`,()=>{let t=ni(this.#e),n=fi(this.#e,e);n!=null&&Vn(this.#e,zn(this.#e,t,n))})}collapse(e){H(this.#e.instrumentation,`store.collapse`,()=>{let t=ni(this.#e),n=pi(this.#e,e);n!=null&&Vn(this.#e,zn(this.#e,t,n))})}on(e,t){return Dn(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return bn(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=ni(this.#e);Sn(this.#e,t),Vn(this.#e,zn(this.#e,n,Nn({affectedAncestorIds:cr(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=ni(this.#e),r=xn(this.#e,t);return Vn(this.#e,zn(this.#e,n,Pn({affectedAncestorIds:cr(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||bn(this.#e,n)!==`loading`||!wn(this.#e,n,e.attemptId))return!1;let r=U(this.#e,n);this.validateChildPatch(r,t);let i=ni(this.#e),a=[];for(let e of t.operations){Oi(r,e);let t=ni(this.#e);switch(e.type){case`add`:a.push(zn(this.#e,t,tr(this.#e,e.path)));break;case`remove`:a.push(zn(this.#e,t,nr(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=rr(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(zn(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return Vn(this.#e,zn(this.#e,i,Fn({affectedAncestorIds:cr(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=ni(this.#e),r=Cn(this.#e,t,e.attemptId);return Vn(this.#e,zn(this.#e,n,In({affectedAncestorIds:cr(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=ni(this.#e),i=Tn(this.#e,n,e.attemptId,t);return Vn(this.#e,zn(this.#e,r,Ln({affectedAncestorIds:cr(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(Qr(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=ni(this.#e),n=$r(this.#e,e.mode??`stable`);return Vn(this.#e,zn(this.#e,t,Rn({...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)??jt(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=Nt(Bt(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(!B(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);_n(this.#e,n,i)||(vn(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(!_n(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=lr(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!B(G(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!B(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=Zn(this.#e,e);if(!_n(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 Oi(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 ki={compact:{itemHeight:24,factor:.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function Ai(e,t){if(typeof e==`number`)return{itemHeight:t??ki.default.itemHeight,factor:e};let n=ki[e??`default`];return{itemHeight:t??n.itemHeight,factor:n.factor}}var ji=ki.default.itemHeight,Mi=`@layer base, theme, unsafe;
1
+ import{C as e,Ds as t,E as n,Ff as r,It as i,Ss as a,Wf as o,Wo as s,Xt as c,b as l,g as u,m as d,os as f,p,ql as m,qo as h,sp as g,ss as _,tn as v,up as y,v as b}from"./textarea-DXib_Xm1.js";import{a as x,c as S,i as C,n as ee,o as w,r as te,s as T,t as ne}from"./fileCommentAnnotations-BNNcqDCJ.js";import{Bt as E,C as D,En as O,F as k,Fr as A,Gn as j,Gt as M,Hn as re,I as ie,L as ae,Mt as N,N as oe,Nr as se,P as ce,Qn as le,Qt as ue,S as de,Sr as P,Tr as fe,Ut as pe,Wn as me,_ as he,b as ge,d as _e,dn as ve,dr as ye,f as be,fn as xe,fr as Se,g as Ce,j as we,jr as Te,kt as Ee,l as F,ln as De,lr as Oe,m as ke,mn as Ae,mr as je,nn as Me,p as Ne,pn as Pe,pr as Fe,qn as Ie,u as Le,un as Re,ur as ze,v as Be,vr as Ve,x as He,xt as Ue,yr as We,yt as Ge,zt as Ke}from"./index-CmXGS7F0.js";var qe=h(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Je=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`}]]),Ye=`file-tree-container`,Xe=`data-file-tree-style`,Ze=`data-file-tree-unsafe-css`,Qe=`data-file-tree-scrollbar-measure`,$e=`data-file-tree-scrollbar-gutter-measured`,et=`--trees-scrollbar-gutter-measured`,tt=`header`,nt=`context-menu`,rt=`context-menu-trigger`,it=5,at=1<<it,ot=at*4;function st(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function ct(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function lt(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 ut(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 dt(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function I(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 L(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,ht(e,t)}function ft(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=ut(e).get(t);if(i===void 0)return;let a=i>>it;e.childVisibleChunkSums[a]+=r}function pt(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=gt(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=at}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 mt(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>it;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<it}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 ht(e,t){if(t.childIds.length<ot){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/at),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>>it]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function gt(e,t,n,r){let i=Math.min(t.childIds.length,n+at),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 _t=7,vt=3,yt=1<<vt,bt=4;function R(e,t,n=0){return e<<bt|n<<vt|t}function xt(e){return e.depthAndFlags>>>bt}function z(e){return(e.depthAndFlags&yt)>>vt}function B(e){return(e.depthAndFlags&yt)!==0}function St(e){return e.depthAndFlags&_t}function V(e,t){return(St(e)&t)!==0}function Ct(e,t){e.depthAndFlags|=t}function wt(e,t){e.depthAndFlags=R(t,St(e),z(e))}var Tt=Symbol(`benchmarkInstrumentation`);function Et(e,t){return t==null||Object.defineProperty(e,Tt,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function Dt(e){return e==null?null:e[Tt]??null}function H(e,t,n){return e==null?n():e.measurePhase(t,n)}function Ot(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function kt(e){return e>=48&&e<=57}function At(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!kt(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&&kt(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 jt(e){let t=e.toLowerCase();return{lowerValue:t,tokens:At(t)}}function Mt(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 Nt(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=Mt(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function Pt(e,t,n){let r=Nt(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function Ft(e,t){return Pt(e,t,jt)}function It(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function Lt(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=It(e,r);return a===It(t,r)?Ft(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 Rt(e,t){return Lt(e,t)}function zt(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=jt(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=It(e,n);return o===It(t,n)?Pt(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 Bt(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=jt(r);return e.sortKeyById[t]=i,i}function Vt(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function Ht(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 Ut(e){let{hasTrailingSlash:t,segments:n}=Ht(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function Wt(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=Ht(e);return{requiresDirectory:t,segments:n}}var Gt=``;function Kt(){let e=new Map;return e.set(Gt,0),{idByValue:e,valueById:[Gt],sortKeyById:[jt(Gt)]}}function qt(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 Jt(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var Yt=Symbol(`pathStorePreparedInputKind`);function Xt(e,t){return e[Yt]=t,e}function Zt(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function Qt(e,t,n){return n==="default"?Rt(e,t):n(Zt(e),Zt(t))}function $t(){return{depthAndFlags:R(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function en(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 tn(e){return e.isDirectory?e.segments.length:e.segments.length-1}function nn(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 rn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function an(e,t={}){return dn(e,t).map(e=>e.path)}function on(e,t={}){let n=dn(e,t);return Xt({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function sn(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 Xt({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function cn(e){let t=e,n=t.preparedPaths;if(t[Yt]===`prepared`&&n!=null)return n;if(!nn(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function ln(e){let t=e;return t[Yt]===`presorted`&&t.presortedPaths!=null||rn(t.presortedPaths)?t.presortedPaths:null}function un(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function dn(e,t={}){let n=Vt(t),r=Dt(t);Ot(r,`workload.inputFiles`,e.length);let i=H(r,`store.preparePathEntries.parse`,()=>e.map(e=>Ut(e)));return H(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>Qt(e,t,n.sort))),i}var fn=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[$t()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=Kt();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=Dt(e),this.options=Vt(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,st())}appendPaths(e){return H(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>Ut(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:R(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:R(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:R(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=Ut(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:R(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:R(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=Ut(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"?zt(this.lastPreparedPath,e,this.segmentSortKeyCache):Qt(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=tn(e),i=n==null?0:tn(n),a=n==null?0:en(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=qt(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:R(xt(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),dt(i,s),s}createFileChildUnchecked(e,t){let n=qt(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:R(xt(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),dt(r,a),a}getOrCreateDirectoryChild(e,t){let n=qt(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&&!B(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:R(xt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),dt(r,a),this.directories.set(a,st()),a}createDirectoryChild(e,t){let n=qt(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:R(xt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),dt(r,a),this.directories.set(a,st()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!B(n))throw Error(`Path is not a directory: "${t}"`);if(V(n,1))throw Error(`Duplicate path: "${t}"`);Ct(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,ct());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(B(a)){let t=ct();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;B(n)&&this.directories.set(t,st());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),dt(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!B(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 L(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function pn(e,t=`closed`,n=null){let r=hn(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 hn(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 gn(e,t){return V(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion===`closed`?!1:xt(t)<=e.defaultExpansion}function _n(e,t,n=e.snapshot.nodes[t]){return n==null||!B(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:gn(e,n)}function vn(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!B(r))return;let i=gn(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 yn(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 bn(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function xn(e,t){let n=yn(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 Sn(e,t){let n=yn(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function Cn(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 wn(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Tn(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 En(e,t){e.directoryLoadInfoById.delete(t)}function Dn(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 On(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function kn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function An(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function jn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Mn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Nn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Pn(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 Fn(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 In(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 Ln(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 Rn(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 zn(e,t,n){return{...n,visibleCountDelta:Xn(e)-t}}function Bn(e,t){let n=Xn(e),r=mn();e.transactionStack.push(r);try{t()}catch(t){throw Un(e,r,!1),t}Un(e,r,!0,Xn(e)-n)}function Vn(e,t){let n=e.instrumentation;if(n==null){Hn(e,t);return}H(n,`store.events.record`,()=>Hn(e,t))}function Hn(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){Jn(e,t);return}n.events.push(t),qn(n,t)}function Un(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?Kn(i,t):H(n,`store.events.batch.merge`,()=>Kn(i,t));return}let a=Wn(t,r),o=e.instrumentation;if(o==null){Jn(e,a);return}H(o,`store.events.batch.commit`,()=>Jn(e,a))}function Wn(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 Gn(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function Kn(e,t){for(let n of t.events)e.events.push(n);Gn(e,t)}function qn(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function Jn(e,t){let n=e.instrumentation;if(n==null){Yn(e,t);return}H(n,`store.events.emit`,()=>Yn(e,t))}function Yn(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function Xn(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function Zn(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!B(n)||V(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||!B(a)?null:i}function Qn(e,t){let n=t;for(;;){let t=Zn(e,n);if(t==null)return n;n=t}}function $n(e,t){let n=[t],r=t;for(;;){let t=Zn(e,r);if(t==null)return n;n.push(t),r=t}}function er(e,t){let n=t==null?e.snapshot.rootId:lr(e,t);return n==null?[]:dr(e,n)}function tr(e,t){let n=Ut(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Er(e,Tr(e,r)),{createdNodeIds:a,directoryId:o}=fr(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=G(e,o);if(V(n,1))throw Error(`Path already exists: "${t}"`);Ct(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=mr(e,o,n.basename),s.add(c);or(e,o);let l=Er(e,o);return On({affectedAncestorIds:cr(e,c),affectedNodeIds:[...s],path:t,projectionChanged:Dr(i,l)})}function nr(e,t,n){let r=lr(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=G(e,r);if(V(i,2))throw Error(`The root node cannot be removed`);if(B(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=Er(e,a),s=Cr(e,r);_r(e,a,r,i.nameId),wr(e,a),or(e,a);let c=Er(e,a);return kn({affectedAncestorIds:cr(e,a),affectedNodeIds:s,path:t,projectionChanged:Dr(o,c),recursive:n.recursive===!0})}function rr(e,t,n,r){let i=lr(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=G(e,i);if(V(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=xr(e,i,n),c=Er(e,a.parentId),l=Er(e,s.parentId),u=Jt(e.snapshot.segmentTable,a.nameId),d=qt(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(B(a)&&jr(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=lt(e.snapshot.nodes,W(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&Sr(e,p,o,z(a))===`skip`)return null;let m=a.parentId;_r(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),Ar(e,i),gr(e,s.parentId,i),wr(e,m),e.pathCacheVersion++,or(e,m),s.parentId!==m&&or(e,s.parentId);let h=Er(e,m),g=Er(e,s.parentId);return An({affectedAncestorIds:[...new Set([...cr(e,m),...cr(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:Or([c,l],[h,g]),to:U(e,i)})}function ir(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function ar(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function U(e,t){let n=G(e,t),r=ir(e,t);if(r!=null)return r;if(V(n,2))return ar(e,t,``);let i=U(e,n.parentId),a=Jt(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return ar(e,t,B(n)?`${o}/`:o)}function or(e,t){let n=e.instrumentation;if(n==null){Nr(e,t);return}H(n,`store.recomputeCountsUpwardFrom`,()=>Nr(e,t))}function sr(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||!B(o)){Mr(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){Mr(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function cr(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 lr(e,t){if(t.length===0)return e.snapshot.rootId;let n=Wt(t);return ur(e,n.segments,n.requiresDirectory)}function ur(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=lt(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=G(e,r);return n&&!B(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||V(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function dr(e,t){let n=e.snapshot.nodes[t];if(n===void 0||V(n,4))return[];if(!B(n))return[U(e,t)];if(W(e,t).childIds.length===0)return V(n,1)&&!V(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||V(n,4)){i.pop();continue}if(!B(n)){r.push(U(e,t.nodeId)),i.pop();continue}let a=W(e,t.nodeId);if(a.childIds.length===0){V(n,1)&&!V(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 fr(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=qt(e.snapshot.segmentTable,i),a=W(e,r),o=lt(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!B(G(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=pr(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function pr(e,t,n){let r=G(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:R(xt(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,st()),gr(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function mr(e,t,n){let r=qt(e.snapshot.segmentTable,n),i=W(e,t);if(lt(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${Fr(e,t,n)}"`);let a=G(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:R(xt(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),gr(e,t,o),e.activeNodeCount++,o}function hr(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}vr(e,n,o)<0?i=a:r=a+1}return r}function gr(e,t,n){let r=W(e,t),i=G(e,n);lt(e.snapshot.nodes,r).set(i.nameId,n),ft(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=hr(e,r,n);r.childIds.splice(a,0,n),I(r,a),ht(e.snapshot.nodes,r)}function _r(e,t,n,r){let i=W(e,t),a=ut(i),o=a.get(n)??-1;lt(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&ft(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),I(i,o),ht(e.snapshot.nodes,i))}function vr(e,t,n){let r=e.snapshot.options.sort;return r==="default"?yr(e,t,n):r(br(e,t),br(e,n))}function yr(e,t,n){let r=G(e,t),i=G(e,n),a=B(r);if(a!==B(i))return a?-1:1;let o=Nt(Bt(e.snapshot.segmentTable,r.nameId),Bt(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=Jt(e.snapshot.segmentTable,r.nameId),c=Jt(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function br(e,t){let n=G(e,t),r=U(e,t),i=B(n),a=i?r.slice(0,-1):r;return{basename:Jt(e.snapshot.segmentTable,n.nameId),depth:xt(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function xr(e,t,n){let r=G(e,t),i=lr(e,n);if(i!=null){let t=G(e,i);if(B(t))return{basename:Jt(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=Wt(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=Wt(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:ur(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function Sr(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(z(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(B(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 Cr(e,t),_r(e,a,t,o),wr(e,a),or(e,a),`handled`}function Cr(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||!B(i)){B(i)&&e.snapshot.directories.delete(t.nodeId),Ct(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),En(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 wr(e,t){let n=t;for(;n!=null;){let t=G(e,n);if(!B(t)||V(t,2)||W(e,n).childIds.length>0)return;Ct(t,1),n=t.parentId===n?null:t.parentId}}function Tr(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=lt(e.snapshot.nodes,W(e,n)).get(t);if(i==null||!B(G(e,i)))break;n=i}return n}function Er(e,t){let n=kr(e,t);if(n==null)return null;let r=Qn(e,n),i=G(e,r),a=n===r?null:$n(e,n).map(t=>U(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:W(e,r).childIds.length>0,path:U(e,r),terminalKind:z(i)})}function Dr(e,t){return Or([e],[t])}function Or(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 kr(e,t){let n=t;for(;n!=null;){let t=G(e,n);if(!B(t)||V(t,2))return null;if(!_n(e,n,t))return n;n=t.parentId}return null}function Ar(e,t){let n=G(e,t);if(wt(n,(t===e.snapshot.rootId?-1:xt(G(e,n.parentId)))+1),!B(n))return;let r=W(e,t);for(let t of r.childIds)Ar(e,t)}function jr(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 Mr(e,t,n=G(e,t),r=!1){let i=e.instrumentation;if(i==null){Pr(e,t,n,r);return}H(i,`store.recomputeNodeCounts`,()=>Pr(e,t,n,r))}function Nr(e,t){let n=t;for(;n!=null;){let t=G(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(Mr(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&ft(W(e,s),n,a,o),n=s}}function Pr(e,t,n,r){if(!B(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=W(e,t);if(r){let t=e.instrumentation;t==null?L(e.snapshot.nodes,i):H(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>L(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,V(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=Zn(e,t)==null?_n(e,t,n)?1+o:1:o}function Fr(e,t,n){let r=U(e,t);return r.length===0?n:`${r}${n}`}function Ir(e){return e!=null&&!V(e,4)}function Lr(e,t){let n=e.snapshot.nodes[t];return!Ir(n)||!B(n)||V(n,2)?null:n}function Rr(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&Ir(e.snapshot.nodes[n])&&(t+=1);return t}function zr(e){return Math.max(0,e.valueById.length-1)}function Br(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:Rr(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:zr(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function Vr(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 Hr(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)Lr(e,n)!=null&&t.push(U(e,n));for(let t of e.expandedDirectoryIds)Lr(e,t)!=null&&n.push(U(e,t));return{collapsedPaths:t,expandedPaths:n}}function Ur(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)Lr(e,n)==null||bn(e,n)===`loaded`||t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:U(e,n)});return t}function Wr(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=lr(e,n);t!=null&&vn(e,t,!0,G(e,t))}for(let n of t.collapsedPaths){let t=lr(e,n);t!=null&&vn(e,t,!1,G(e,t))}}function Gr(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=lr(e,n.path);t!=null&&Lr(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function Kr(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function qr(e){let t=e.snapshot.segmentTable,n=Kt();for(let r of e.snapshot.nodes)if(Ir(r)){if(V(r,2)){r.nameId=0;continue}r.nameId=qt(n,Jt(t,r.nameId))}e.snapshot.segmentTable=n}function Jr(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!Ir(r)||!B(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return Ir(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])),L(e.snapshot.nodes,n)}}function Yr(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(Ir(n))break;--t}e.snapshot.nodes.length=t+1}function Xr(e){let t=Hr(e),n=Ur(e);H(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>Kr(e)),H(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>qr(e)),H(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>Jr(e)),H(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>Yr(e)),H(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>Wr(e,t)),H(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>Gr(e,n)),H(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>sr(e,e.snapshot.rootId))}function Zr(e){let t=Hr(e),n=Ur(e),r=H(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>er(e)),i=Et({...e.snapshot.options},e.instrumentation),a=H(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new fn(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`,()=>Wr(e,t)),H(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>Gr(e,n)),H(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>sr(e,e.snapshot.rootId))}function Qr(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function $r(e,t){let n=Br(e);t===`stable`?H(e.instrumentation,`store.cleanup.stable`,()=>Xr(e)):H(e.instrumentation,`store.cleanup.aggressive`,()=>Zr(e));let r=Br(e);return Vr(t,t===`stable`,n,r)}var ei=64;function ti(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 ni(e){return G(e,e.snapshot.rootId).visibleSubtreeCount}function ri(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 ii(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:Ci(e,t.cursor),setSize:t.setSize,subtreeEndIndex:ri(e,t.cursor,t.index,n)}}function ai(e,t,n,r,i,a){let o=W(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=pt(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return oi(e,u,l,r+c,i+1,s,o.childIds.length,a)}function oi(e,t,n,r,i,a,o,s){if(!B(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=_i(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=G(e,c.terminalNodeId);if(!B(l)||!_n(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return ai(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function si(e,t){let n=ni(e);if(t<0||t>=n)return null;let r=ai(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=ii(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:Ci(e,r.cursor),setSize:r.setSize,subtreeEndIndex:ri(e,r.cursor,r.index,n)}}function ci(e,t,n){let r=e.instrumentation,i=ni(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 Si(e,o+1);let t=[],n=mi(e,a);for(let r=a;r<=o&&n!=null;r++){let r=Ci(e,n);t.push(r),n=yi(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`,()=>Ci(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=H(r,`store.getVisibleSlice.advanceCursor`,()=>yi(e,u))}return Ot(r,`workload.visibleRowsRead`,s.length),Ot(r,`workload.flattenedRowsRead`,c),Ot(r,`workload.flattenedSegmentsRead`,l),s}function li(e,t=ni(e)){let n=e.instrumentation;return n==null?xi(e,t):H(n,`store.getVisibleTreeProjection`,()=>xi(e,t))}function ui(e){return bi(li(e))}function di(e,t){let n=lr(e,t);if(n==null||n===e.snapshot.rootId||B(G(e,n))&&Qn(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=ut(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=mt(a,n,s),t!==o){let n=G(e,t),a=Zn(e,t);if(!_n(e,t,n)&&a!==i)return null;Qn(e,t)===t&&(r+=1)}i=t}return r}function fi(e,t){let n=lr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=G(e,n);if(!B(r))throw Error(`Path is not a directory: "${t}"`);return _n(e,n,r)?null:(vn(e,n,!0,r),or(e,n),jn({affectedAncestorIds:cr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function pi(e,t){let n=lr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=G(e,n);if(!B(r))throw Error(`Path is not a directory: "${t}"`);return _n(e,n,r)?(vn(e,n,!1,r),or(e,n),Mn({affectedAncestorIds:cr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function mi(e,t){return t<0||t>=ni(e)?null:hi(e,e.snapshot.rootId,t,-1)}function hi(e,t,n,r){let i=W(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?pt(e.snapshot.nodes,i,n):H(a,`store.getVisibleSlice.selectChildIndex`,()=>pt(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return gi(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function gi(e,t,n,r){if(!B(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=_i(e,t,r);if(n===0)return i;let a=G(e,i.terminalNodeId);if(!B(a)||!_n(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return hi(e,i.terminalNodeId,n-1,i.visibleDepth)}function _i(e,t,n){return B(G(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:Qn(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:H(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>Qn(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function vi(e,t){let n=G(e,t);if(!B(n))return!0;let r=n.parentId;return r===e.snapshot.rootId?!0:Zn(e,r)!==t}function yi(e,t){let n=G(e,t.terminalNodeId);if(B(n)){let r=W(e,t.terminalNodeId);if(_n(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:gi(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=ut(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 gi(e,s,0,i);vi(e,r)&&i--,r=n}}function bi(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 xi(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(ei);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=ti(o,y);let x,S=_;if(B(v))S=f?Qn(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&&B(C)&&_n(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 Si(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(!B(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?Qn(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=Ci(e,g);let _=i[h];_!=null&&B(_)&&_n(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function Ci(e,t){let n=G(e,t.terminalNodeId),r=B(n)?wi(e,t):null,i=U(e,t.terminalNodeId),a=Jt(e.snapshot.segmentTable,n.nameId),o=B(n)&&W(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?$n(e,t.headNodeId).map(n=>{let r=G(e,n);return{isTerminal:n===t.terminalNodeId,name:Jt(e.snapshot.segmentTable,r.nameId),nodeId:n,path:U(e,n)}}):H(c,`store.getVisibleSlice.flatten.collectSegments`,()=>$n(e,t.headNodeId).map(n=>{let r=G(e,n);return{isTerminal:n===t.terminalNodeId,name:Jt(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:B(n)&&_n(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:B(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function wi(e,t){if(t.headNodeId===t.terminalNodeId)return bn(e,t.terminalNodeId);let n=$n(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=bn(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}function Ti(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||!B(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&&ht(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&B(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,ht(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Ei(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var Di=class e{#e;constructor(e={}){let t=Dt(e),n=H(t,`store.builder.create`,()=>new fn(e));if(e.preparedInput!=null){let t=ln(e.preparedInput);t==null?n.appendPreparedPaths(cn(e.preparedInput),!1):n.appendPresortedPaths(t,un(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(H(t,`store.preparePathEntries`,()=>dn(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`,()=>pn(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||Ei(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`,()=>Ti(this.#e)):H(t,`store.state.recomputeCounts`,()=>sr(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return an(e,t)}static prepareInput(e,t={}){return on(e,t)}static preparePresortedInput(e){return sn(e)}list(e){return H(this.#e.instrumentation,`store.list`,()=>er(this.#e,e))}add(e){H(this.#e.instrumentation,`store.add`,()=>{let t=ni(this.#e);Vn(this.#e,zn(this.#e,t,tr(this.#e,e)))})}remove(e,t={}){H(this.#e.instrumentation,`store.remove`,()=>{let n=ni(this.#e);Vn(this.#e,zn(this.#e,n,nr(this.#e,e,t)))})}move(e,t,n={}){H(this.#e.instrumentation,`store.move`,()=>{let r=ni(this.#e),i=rr(this.#e,e,t,n);i!=null&&Vn(this.#e,zn(this.#e,r,i))})}batch(e){Bn(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`,()=>ni(this.#e))}getVisibleSlice(e,t){return H(this.#e.instrumentation,`store.getVisibleSlice`,()=>ci(this.#e,e,t))}getVisibleRowContext(e){return H(this.#e.instrumentation,`store.getVisibleRowContext`,()=>si(this.#e,e))}getVisibleTreeProjection(){return ui(this.#e)}getVisibleTreeProjectionData(e){return li(this.#e,e)}getVisibleIndex(e){return H(this.#e.instrumentation,`store.getVisibleIndex`,()=>di(this.#e,e))}getPathInfo(e){return H(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=lr(this.#e,e);if(t==null)return null;let n=G(this.#e,t);return{depth:xt(n),kind:B(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 _n(this.#e,t,n)})}expand(e){H(this.#e.instrumentation,`store.expand`,()=>{let t=ni(this.#e),n=fi(this.#e,e);n!=null&&Vn(this.#e,zn(this.#e,t,n))})}collapse(e){H(this.#e.instrumentation,`store.collapse`,()=>{let t=ni(this.#e),n=pi(this.#e,e);n!=null&&Vn(this.#e,zn(this.#e,t,n))})}on(e,t){return Dn(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return bn(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=ni(this.#e);Sn(this.#e,t),Vn(this.#e,zn(this.#e,n,Nn({affectedAncestorIds:cr(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=ni(this.#e),r=xn(this.#e,t);return Vn(this.#e,zn(this.#e,n,Pn({affectedAncestorIds:cr(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||bn(this.#e,n)!==`loading`||!wn(this.#e,n,e.attemptId))return!1;let r=U(this.#e,n);this.validateChildPatch(r,t);let i=ni(this.#e),a=[];for(let e of t.operations){Oi(r,e);let t=ni(this.#e);switch(e.type){case`add`:a.push(zn(this.#e,t,tr(this.#e,e.path)));break;case`remove`:a.push(zn(this.#e,t,nr(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=rr(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(zn(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return Vn(this.#e,zn(this.#e,i,Fn({affectedAncestorIds:cr(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=ni(this.#e),r=Cn(this.#e,t,e.attemptId);return Vn(this.#e,zn(this.#e,n,In({affectedAncestorIds:cr(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=ni(this.#e),i=Tn(this.#e,n,e.attemptId,t);return Vn(this.#e,zn(this.#e,r,Ln({affectedAncestorIds:cr(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(Qr(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=ni(this.#e),n=$r(this.#e,e.mode??`stable`);return Vn(this.#e,zn(this.#e,t,Rn({...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)??jt(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=Nt(Bt(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(!B(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);_n(this.#e,n,i)||(vn(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(!_n(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=lr(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!B(G(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!B(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=Zn(this.#e,e);if(!_n(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 Oi(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 ki={compact:{itemHeight:24,factor:.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function Ai(e,t){if(typeof e==`number`)return{itemHeight:t??ki.default.itemHeight,factor:e};let n=ki[e??`default`];return{itemHeight:t??n.itemHeight,factor:n.factor}}var ji=ki.default.itemHeight,Mi=`@layer base, theme, unsafe;
2
2
 
3
3
  @layer base {
4
4
  :host {
@@ -1775,4 +1775,4 @@ import{C as e,Ds as t,E as n,Ff as r,It as i,Ss as a,Wf as o,Wo as s,Xt as c,b a
1775
1775
  color: var(--diffs-selection-number-fg) !important;
1776
1776
  }
1777
1777
  `;function gf(e){let t=(0,kl.c)(8),n;t[0]!==e.absolutePath||t[1]!==e.threadRef.threadId?(n={_tag:`workspace-file`,threadId:e.threadRef.threadId,path:e.absolutePath},t[0]=e.absolutePath,t[1]=e.threadRef.threadId,t[2]=n):n=t[2];let r=Fe(e.environmentId,n),[i,a]=(0,X.useState)(null);if(r._tag===`Failure`||r._tag===`Success`&&i===r.url){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.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 workspace image.`}),t[3]=e):e=t[3],e}let o;return t[4]!==r._tag||t[5]!==r.url||t[6]!==e.alt?(o=r._tag===`Success`?(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,Z.jsx)(`img`,{className:`max-h-full max-w-full object-contain`,src:r.url,alt:e.alt,onError:()=>a(r.url)})}):(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,Z.jsx)(Te,{className:`size-5 animate-spin`})}),t[4]=r._tag,t[5]=r.url,t[6]=e.alt,t[7]=o):o=t[7],o}function _f(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 vf(e,t){let n=e.shadowRoot??e;for(let e of n.querySelectorAll(`[${mf}]`))e.removeAttribute(mf);t!==null&&(n.querySelector(`[data-line="${t}"]`)?.setAttribute(mf,``),n.querySelector(`[data-column-number="${t}"]`)?.setAttribute(mf,``))}function yf(e,t,n){let r=(0,kl.c)(7),[i]=(0,X.useState)(Sf),[a]=(0,X.useState)(xf),[o]=(0,X.useState)(bf),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:_f(s.file?.contents??``,t);if(vf(r,u),!(s instanceof w))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 bf(){return new Map}function xf(){return new Map}function Sf(){return new Map}function Cf(e){let t=(0,kl.c)(19),{environmentId:n,cwd:r,relativePath:i,onPendingChange:a}=e,o=b(Ve.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=>{F(n,r,i,e)},t[8]=r,t[9]=n,t[10]=i,t[11]=l):l=t[11];let u;t[12]!==s||t[13]!==c||t[14]!==l?(u=new df({debounceMs:pf,onPendingChange:s,persist:c,onConfirmed:l}),t[12]=s,t[13]=c,t[14]=l,t[15]=u):u=t[15];let d=u,f,p;return t[16]===d?(f=t[17],p=t[18]):(f=()=>()=>d.dispose(),p=[d],t[16]=d,t[17]=f,t[18]=p),(0,X.useEffect)(f,p),d}function wf(e){let t=(0,kl.c)(74),{environmentId:n,cwd:r,relativePath:i,composerDraftTarget:a,contents:o,resolvedTheme:s,revealRequestId:l,wordWrap:u,onPostRender:d,onPendingChange:f}=e,p=c(jf),m=c(Af),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[0]=h):h=t[0];let[g,_]=(0,X.useState)(h),[y,b]=(0,X.useState)(null),S=y?.revealRequestId===l?y.range:null,w;t[1]===l?w=t[2]:(w=e=>{b({revealRequestId:l,range:e})},t[1]=l,t[2]=w);let T=w,E=(0,X.useRef)(null),D=(0,X.useRef)(null),O;t[3]!==r||t[4]!==n||t[5]!==f||t[6]!==i?(O={environmentId:n,cwd:r,relativePath:i,onPendingChange:f},t[3]=r,t[4]=n,t[5]=f,t[6]=i,t[7]=O):O=t[7];let k=Cf(O),A;t[8]!==p||t[9]!==a||t[10]!==r||t[11]!==n||t[12]!==i||t[13]!==k?(A=new Ud({onChange:(e,t)=>{if(_e(n,r,i,e.contents),k.change(e.contents),t){let n=C(t);_(n);for(let t of n)for(let n of t.metadata.entries)n.kind===`comment`&&p(a,v({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]=k,t[14]=A):A=t[14];let j=A,M,re;t[15]===j?(M=t[16],re=t[17]):(M=()=>()=>{j.cleanUp()},re=[j],t[15]=j,t[16]=M,t[17]=re),(0,X.useEffect)(M,re);let ae;t[18]!==a||t[19]!==m||t[20]!==T?(ae=e=>{T(null),m(a,e),_(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]=m,t[20]=T,t[21]=ae):ae=t[21];let N=ae,se;t[22]!==p||t[23]!==a||t[24]!==o||t[25]!==g||t[26]!==i||t[27]!==T?(se=(e,t)=>{T(null);let n=g.flatMap(kf).find(t=>t.id===e);n&&p(a,v({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:t,contents:o})),_(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]=g,t[26]=i,t[27]=T,t[28]=se):se=t[28];let ce=se,le;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(le=e=>{let{startLine:t,endLine:n}=te(e),r={id:ee(),kind:`draft`,startLine:t,endLine:n,text:``};_(e=>{let t=e.flatMap(Df),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]=le):le=t[29];let ue=le,de;t[30]===g?de=t[31]:(de=g.some(Tf),t[30]=g,t[31]=de);let P=de,fe,pe;t[32]!==j||t[33]!==P||t[34]!==T?(fe=()=>{let e=E.current;if(e)return af({root:e,editor:j,isBlocked:()=>P,onDismiss:()=>T(null)})},pe=[j,P,T],t[32]=j,t[33]=P,t[34]=T,t[35]=fe,t[36]=pe):(fe=t[35],pe=t[36]),(0,X.useEffect)(fe,pe);let me;t[37]===T?me=t[38]:(me=e=>{T(e),e&&ue(e)},t[37]=T,t[38]=me);let he=me,ge;t[39]!==d||t[40]!==S?(ge=(e,t,n)=>{d(e,t,n),D.current!==null&&(cancelAnimationFrame(D.current),D.current=null),n!==`unmount`&&(D.current=requestAnimationFrame(()=>{D.current=null,e.isConnected&&t.setSelectedLines(S,{notify:!1})}))},t[39]=d,t[40]=S,t[41]=ge):ge=t[41];let ve=ge,ye;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(ye={overscrollSize:600,intersectionObserverMargin:1200},t[42]=ye):ye=t[42];let be;t[43]!==o||t[44]!==r||t[45]!==i?(be=sf(r,i,o),t[43]=o,t[44]=r,t[45]=i,t[46]=be):be=t[46];let xe;t[47]!==o||t[48]!==i||t[49]!==be?(xe={name:i,contents:o,cacheKey:be},t[47]=o,t[48]=i,t[49]=be,t[50]=xe):xe=t[50];let Se=!P,Ce=!P,Te=u?`wrap`:`scroll`,Ee;t[51]===s?Ee=t[52]:(Ee=we(s),t[51]=s,t[52]=Ee);let F;t[53]!==he||t[54]!==ve||t[55]!==s||t[56]!==T||t[57]!==Se||t[58]!==Ce||t[59]!==Te||t[60]!==Ee?(F={disableFileHeader:!0,enableGutterUtility:Se,enableLineSelection:Ce,onGutterUtilityClick:T,onLineSelectionChange:T,onLineSelectionEnd:he,overflow:Te,theme:Ee,themeType:s,unsafeCSS:hf,onPostRender:ve},t[53]=he,t[54]=ve,t[55]=s,t[56]=T,t[57]=Se,t[58]=Ce,t[59]=Te,t[60]=Ee,t[61]=F):F=t[61];let De;t[62]!==N||t[63]!==ce?(De=e=>(0,Z.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,Z.jsx)(x,{kind:e.kind,rangeLabel:ne(e.startLine,e.endLine),text:e.text,onCancel:()=>N(e.id),onComment:t=>ce(e.id,t),onDelete:()=>N(e.id)},e.id))}),t[62]=N,t[63]=ce,t[64]=De):De=t[64];let Oe;t[65]!==g||t[66]!==S||t[67]!==xe||t[68]!==F||t[69]!==De?(Oe=(0,Z.jsx)(`div`,{ref:E,className:`flex min-h-0 flex-1`,children:(0,Z.jsx)(oe,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:ye,children:(0,Z.jsx)(Ol,{file:xe,options:F,selectedLines:S,lineAnnotations:g,renderAnnotation:De,className:`min-h-full`,contentEditable:!0})})}),t[65]=g,t[66]=S,t[67]=xe,t[68]=F,t[69]=De,t[70]=Oe):Oe=t[70];let ke;return t[71]!==j||t[72]!==Oe?(ke=(0,Z.jsx)(ie,{editor:j,children:Oe}),t[71]=j,t[72]=Oe,t[73]=ke):ke=t[73],ke}function Tf(e){return e.metadata.entries.some(Ef)}function Ef(e){return e.kind===`draft`}function Df(e){let t=e.metadata.entries.filter(Of);return t.length>0?[{...e,metadata:{entries:t}}]:[]}function Of(e){return e.kind!==`draft`}function kf(e){return e.metadata.entries}function Af(e){return e.removeReviewComment}function jf(e){return e.addReviewComment}function Mf(e){let t=(0,kl.c)(16),{environmentId:n,cwd:r,relativePath:i,contents:a,threadRef:o,onPendingChange:s}=e,c;t[0]!==r||t[1]!==n||t[2]!==s||t[3]!==i?(c={environmentId:n,cwd:r,relativePath:i,onPendingChange:s},t[0]=r,t[1]=n,t[2]=s,t[3]=i,t[4]=c):c=t[4];let l=Cf(c),u;t[5]!==a||t[6]!==r||t[7]!==n||t[8]!==i||t[9]!==l?(u=e=>{let{markerOffset:t,checked:o}=e,s=Le(n,r,i)?.contents??a,c=uf(s,t,o);c!==s&&(_e(n,r,i,c),l.change(c))},t[5]=a,t[6]=r,t[7]=n,t[8]=i,t[9]=l,t[10]=u):u=t[10];let d;return t[11]!==a||t[12]!==r||t[13]!==u||t[14]!==o?(d=(0,Z.jsx)(Ie,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(ge,{text:a,cwd:r,threadRef:o,className:`mx-auto max-w-4xl px-6 py-5`,onTaskListChange:u})}),t[11]=a,t[12]=r,t[13]=u,t[14]=o,t[15]=d):d=t[15],d}function Nf(){try{return f(ff,m)??!0}catch(e){return console.error(e),!0}}function Pf(n){let r=(0,kl.c)(78),{environmentId:o,cwd:c,projectName:f,relativePath:m,threadRef:h,composerDraftTarget:g,keybindings:_,availableEditors:v,revealLine:y,revealRequestId:x,onOpenFile:S,onPendingChange:C}=n,{resolvedTheme:ee}=re(),w=We(If),te=e(),T=l(o),ne;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(ne={reportFailure:!1},r[0]=ne):ne=r[0];let E=j(je.createUrl,ne),k;r[1]===Symbol.for(`react.memo_cache_sentinel`)?(k={reportFailure:!1},r[1]=k):k=r[1];let M=b(Oe.open,k),ie;r[2]===m?ie=r[3]:(ie=m!==null&&Ml(m),r[2]=m,r[3]=ie);let ae=ie,N=Ne(o,c,m,!ae),[ce,ue]=(0,X.useState)(Nf),P;r[4]===Symbol.for(`react.memo_cache_sentinel`)?(P={path:null,revealRequestId:null},r[4]=P):P=r[4];let[fe,pe]=(0,X.useState)(P),me=(0,X.useRef)(null),he;r[5]===m?he=r[6]:(he=m?lf(m):!1,r[5]=m,r[6]=he);let ge=he,_e=ge&&fe.path===m&&(y===null||fe.revealRequestId===x),ve;r[7]===m?ve=r[8]:(ve=m!==null&&le()&&He(m),r[7]=m,r[8]=ve);let be=ve,xe;r[9]!==c||r[10]!==m?(xe=m?D(m,c):null,r[9]=c,r[10]=m,r[11]=xe):xe=r[11];let Se=xe,Ce;r[12]!==f||r[13]!==m?(Ce=m?cf(f,m):[],r[12]=f,r[13]=m,r[14]=Ce):Ce=r[14];let Ee=Ce,F=yf(m,y,x),De;r[15]===Symbol.for(`react.memo_cache_sentinel`)?(De=()=>{(me.current?.querySelector(`[data-current-file-crumb='true']`))?.scrollIntoView({block:`nearest`,inline:`end`})},r[15]=De):De=r[15];let Ae;r[16]===m?Ae=r[17]:(Ae=[m],r[16]=m,r[17]=Ae),(0,X.useEffect)(De,Ae);let Me;r[18]===Symbol.for(`react.memo_cache_sentinel`)?(Me=()=>{ue(Ff)},r[18]=Me):Me=r[18];let Pe=Me,Fe;r[19]!==Se||r[20]!==E||r[21]!==T||r[22]!==M||r[23]!==h?(Fe=()=>{!Se||!T||(async()=>{let e=await de({threadRef:h,filePath:Se,httpBaseUrl:T,createAssetUrl:E,openPreview:M});if(e._tag===`Success`||a(e))return;let n=t(e);ze.add(ye({type:`error`,title:`Unable to open file in browser`,description:n instanceof Error?n.message:`An error occurred.`}))})()},r[19]=Se,r[20]=E,r[21]=T,r[22]=M,r[23]=h,r[24]=Fe):Fe=r[24];let Le=Fe,Re;r[25]!==Se||r[26]!==v||r[27]!==Ee||r[28]!==be||r[29]!==o||r[30]!==ce||r[31]!==Le||r[32]!==ge||r[33]!==_||r[34]!==te||r[35]!==f||r[36]!==m||r[37]!==_e||r[38]!==x?(Re=m?(0,Z.jsxs)(`div`,{className:`surface-subheader gap-2 px-3`,"data-surface-subheader":!0,children:[(0,Z.jsx)(Ie,{ref:me,hideScrollbars:!0,scrollFade:!0,className:`min-w-0 flex-1 rounded-none`,"data-file-breadcrumbs":!0,children:(0,Z.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center text-xs`,children:Ee.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center`,"data-current-file-crumb":e.kind===`file`,children:[t>0?(0,Z.jsx)(s,{className:`mx-1 size-3.5 shrink-0 text-muted-foreground/60`}):null,(0,Z.jsx)(`span`,{className:i(`max-w-40 truncate`,e.kind===`file`?`font-medium text-foreground`:`text-muted-foreground`),title:e.path||f,children:e.label})]},e.path||`project`))})}),Se&&o===te?(0,Z.jsx)(ke,{environmentId:o,keybindings:_,availableEditors:v,openInCwd:Se,compact:!0,enableShortcut:!1}):null,ge?(0,Z.jsxs)(p,{children:[(0,Z.jsx)(u,{render:(0,Z.jsx)(O,{className:`shrink-0`,pressed:_e,onPressedChange:e=>{pe({path:e?m:null,revealRequestId:e?x:null})},"aria-label":_e?`Show markdown source`:`Show rendered markdown`,variant:`ghost`,size:`sm`,children:_e?(0,Z.jsx)(qe,{className:`size-3.5`}):(0,Z.jsx)(se,{className:`size-3.5`})})}),(0,Z.jsx)(d,{children:_e?`Show markdown source`:`Show rendered markdown`})]}):null,be?(0,Z.jsxs)(p,{children:[(0,Z.jsx)(u,{render:(0,Z.jsx)(O,{className:`shrink-0`,pressed:!1,onPressedChange:Le,"aria-label":`Open file in preview browser`,variant:`ghost`,size:`sm`,children:(0,Z.jsx)(A,{className:`size-3.5`})})}),(0,Z.jsx)(d,{children:`Open file in preview browser`})]}):null,(0,Z.jsxs)(p,{children:[(0,Z.jsx)(u,{render:(0,Z.jsx)(O,{className:`shrink-0`,pressed:ce,onPressedChange:Pe,"aria-label":ce?`Hide file explorer`:`Show file explorer`,variant:`ghost`,size:`sm`,children:(0,Z.jsx)(Je,{className:`size-3.5`})})}),(0,Z.jsx)(d,{children:ce?`Hide file explorer`:`Show file explorer`})]})]}):null,r[25]=Se,r[26]=v,r[27]=Ee,r[28]=be,r[29]=o,r[30]=ce,r[31]=Le,r[32]=ge,r[33]=_,r[34]=te,r[35]=f,r[36]=m,r[37]=_e,r[38]=x,r[39]=Re):Re=r[39];let Be;r[40]!==N||r[41]!==m?(Be=m&&N.data?.truncated?(0,Z.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 `,N.data.byteLength.toLocaleString(),` byte file.`]}):null,r[40]=N,r[41]=m,r[42]=Be):Be=r[42];let Ve=m?`flex`:`hidden`,Ue;r[43]===Ve?Ue=r[44]:(Ue=i(`min-w-0 flex-1 flex-col overflow-hidden`,Ve),r[43]=Ve,r[44]=Ue);let Ge;r[45]!==Se||r[46]!==g||r[47]!==c||r[48]!==o||r[49]!==N||r[50]!==ae||r[51]!==ge||r[52]!==F||r[53]!==C||r[54]!==m||r[55]!==_e||r[56]!==ee||r[57]!==x||r[58]!==h||r[59]!==w?(Ge=m&&ae&&Se?(0,Z.jsx)(gf,{environmentId:o,threadRef:h,absolutePath:Se,alt:m},Se):m&&N.error&&N.data===null?(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:N.error}):m&&N.data===null?(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,Z.jsx)(Te,{className:`size-5 animate-spin`})}):m&&N.data?ge&&_e?(0,Z.jsx)(Mf,{environmentId:o,cwd:c,relativePath:m,threadRef:h,contents:N.data.contents,onPendingChange:C}):N.data.truncated?(0,Z.jsx)(oe,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:{overscrollSize:600,intersectionObserverMargin:1200},children:(0,Z.jsx)(Ol,{file:{name:m,contents:N.data.contents,cacheKey:sf(c,m,N.data.contents)},options:{disableFileHeader:!0,overflow:w?`wrap`:`scroll`,theme:we(ee),themeType:ee,unsafeCSS:hf,onPostRender:F},className:`min-h-full`})},`${m}:${ee}:${N.data.byteLength}`):(0,Z.jsx)(wf,{environmentId:o,cwd:c,relativePath:m,composerDraftTarget:g,contents:N.data.contents,resolvedTheme:ee,revealRequestId:x,wordWrap:w,onPostRender:F,onPendingChange:C},`${m}:${ee}`):null,r[45]=Se,r[46]=g,r[47]=c,r[48]=o,r[49]=N,r[50]=ae,r[51]=ge,r[52]=F,r[53]=C,r[54]=m,r[55]=_e,r[56]=ee,r[57]=x,r[58]=h,r[59]=w,r[60]=Ge):Ge=r[60];let Ke;r[61]!==Ue||r[62]!==Ge?(Ke=(0,Z.jsx)(`div`,{className:Ue,children:Ge}),r[61]=Ue,r[62]=Ge,r[63]=Ke):Ke=r[63];let Ye;r[64]!==c||r[65]!==o||r[66]!==ce||r[67]!==S||r[68]!==f||r[69]!==m?(Ye=ce||m===null?(0,Z.jsx)(`aside`,{className:i(`flex min-h-0 shrink-0 bg-background`,m?`w-[min(22rem,46%)] min-w-64 border-l border-border/60`:`min-w-0 flex-1`),children:(0,Z.jsx)(tf,{environmentId:o,cwd:c,projectName:f,onOpenFile:S},`${o}:${c}`)}):null,r[64]=c,r[65]=o,r[66]=ce,r[67]=S,r[68]=f,r[69]=m,r[70]=Ye):Ye=r[70];let Xe;r[71]!==Ke||r[72]!==Ye?(Xe=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[Ke,Ye]}),r[71]=Ke,r[72]=Ye,r[73]=Xe):Xe=r[73];let Ze;return r[74]!==Re||r[75]!==Be||r[76]!==Xe?(Ze=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[Re,Be,Xe]}),r[74]=Re,r[75]=Be,r[76]=Xe,r[77]=Ze):Ze=r[77],Ze}function Ff(e){let t=!e;try{_(ff,t,m)}catch(e){console.error(e)}return t}function If(e){return e.wordWrap}export{Pf as default};
1778
- //# sourceMappingURL=FilePreviewPanel-CmJUrNYJ.js.map
1778
+ //# sourceMappingURL=FilePreviewPanel-BUGKMTB4.js.map
@@ -1,2 +1,2 @@
1
- import{$s as e,Ds as t,Ff as n,Gr as r,Hr as i,Is as a,It as o,Jr as s,Ks as c,Oc as l,Pr as u,Rr as d,Rs as f,T as p,Ur as m,Vr as h,Vs as g,Wf as _,Wr as v,Xr as y,Xt as b,Yr as x,Ys as S,as as C,b as w,ds as T,g as E,m as D,o as O,p as k,qo as A,qr as ee,ru as j,sp as te,tu as M,up as N,v as ne,y as P,zs as F}from"./textarea-DXib_Xm1.js";import{t as re}from"./arrow-right-AJ0Jl2nt.js";import{$n as I,An as L,Cr as ie,Dr as ae,Er as oe,Jn as R,Mn as z,Mr as B,On as V,Or as H,Pr as se,Qn as U,Rr as ce,Sn as W,Xn as le,Zn as G,_n as K,a as q,ar as J,bn as ue,c as Y,cr as de,dr as fe,er as pe,gn as me,hn as he,i as ge,ir as _e,jn as ve,kn as ye,kr as be,lr as xe,n as Se,nr as Ce,o as we,or as Te,r as Ee,rr as De,s as Oe,sr as ke,t as Ae,tr as je,ur as X,vn as Me,wr as Ne,xn as Pe,y as Fe,yn as Ie}from"./index-qr_OWE66.js";var Le=A(`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`}]]),Re=A(`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`}]]),ze=A(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),Be=A(`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=N(te(),1),Q=n(),$=_();function Ve(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`relative inline-flex w-full min-w-0 items-center rounded-lg border border-input bg-background not-dark:bg-clip-padding text-base text-foreground shadow-xs/5 ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_1px_--theme(--color-black/4%)] has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/64 has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/16 has-[textarea]:h-auto has-data-[align=block-end]:h-auto has-data-[align=block-start]:h-auto has-data-[align=block-end]:flex-col has-data-[align=block-start]:flex-col has-[input:focus-visible,textarea:focus-visible]:border-ring has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/36 has-autofill:bg-foreground/4 has-[input:disabled,textarea:disabled]:opacity-64 has-[input:disabled,textarea:disabled,input:focus-visible,textarea:focus-visible,input[aria-invalid],textarea[aria-invalid]]:shadow-none has-[input:focus-visible,textarea:focus-visible]:ring-[3px] sm:text-sm dark:bg-input/32 dark:has-autofill:bg-foreground/8 dark:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/24 dark:not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_-1px_--theme(--color-white/6%)] has-data-[align=inline-start]:**:[[data-size=sm]_input]:ps-1.5 has-data-[align=inline-end]:**:[[data-size=sm]_input]:pe-1.5 *:[[data-slot=input-control],[data-slot=textarea-control]]:contents *:[[data-slot=input-control],[data-slot=textarea-control]]:before:hidden has-[[data-align=block-start],[data-align=block-end]]:**:[input]:h-auto has-data-[align=inline-start]:**:[input]:ps-2 has-data-[align=inline-end]:**:[input]:pe-2 has-data-[align=block-end]:**:[input]:pt-1.5 has-data-[align=block-start]:**:[input]:pb-1.5 **:[textarea]:min-h-20.5 **:[textarea]:resize-none **:[textarea]:py-[calc(--spacing(3)-1px)] **:[textarea]:max-sm:min-h-23.5 **:[textarea_button]:rounded-[calc(var(--radius-md)-1px)]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{className:i,"data-slot":`input-group`,role:`group`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var He=C(`[&_svg]:-mx-0.5 flex h-auto cursor-text select-none items-center justify-center gap-2 leading-none [&>kbd]:rounded-[calc(var(--radius)-5px)] in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4.5 sm:in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4 not-has-[button]:**:[svg:not([class*='opacity-'])]:opacity-80`,{defaultVariants:{align:`inline-start`},variants:{align:{"block-end":`order-last w-full justify-start px-[calc(--spacing(3)-1px)] pb-[calc(--spacing(3)-1px)] [.border-t]:pt-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]`,"block-start":`order-first w-full justify-start px-[calc(--spacing(3)-1px)] pt-[calc(--spacing(3)-1px)] [.border-b]:pb-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]`,"inline-end":`has-[>:last-child[data-slot=badge]]:-me-1.5 has-[>button]:-me-2 order-last pe-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:me-[-0.35rem] [[data-size=sm]+&]:pe-[calc(--spacing(2.5)-1px)]`,"inline-start":`has-[>:last-child[data-slot=badge]]:-ms-1.5 has-[>button]:-ms-2 order-first ps-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:ms-[-0.35rem] [[data-size=sm]+&]:ps-[calc(--spacing(2.5)-1px)]`}}});function Ue(e){let t=(0,Q.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,s;t[4]!==a||t[5]!==n?(s=o(He({align:a}),n),t[4]=a,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==r||t[9]!==s?(c=(0,$.jsx)(`div`,{className:s,"data-align":a,"data-slot":`input-group-addon`,onMouseDown:We,...r}),t[7]=a,t[8]=r,t[9]=s,t[10]=c):c=t[10],c}function We(e){if(e.target.closest(`button, a, input, select, textarea, [role='button'], [role='combobox'], [role='listbox'], [data-slot='select-trigger']`))return;e.preventDefault();let t=e.currentTarget.parentElement,n=t?.querySelector(`input, textarea`);n&&!t?.querySelector(`input:focus, textarea:focus`)&&n.focus()}function Ge(e){let t=(0,Q.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,$.jsx)(R,{className:n,unstyled:!0,...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}var Ke=()=>{};function qe(e){let t=(0,Q.c)(98),{url:n,displayUrl:r,loading:i,loadProgress:a,canGoBack:s,canGoForward:c,refreshDisabled:l,inputDisabled:d,focusUrlNonce:f,onBack:p,onForward:m,onRefresh:h,onSubmit:g,onOpenInBrowser:_,onCapture:v,captureDisabled:y,recording:b,onPictureInPicture:x,pictureInPicture:S,pictureInPictureDisabled:C,onPickElement:w,pickActive:T,pickDisabled:O,pickDisabledReason:A,trailingActions:ee}=e,j=(0,Z.useRef)(null),[te,M]=(0,Z.useState)(n),[N,ne]=(0,Z.useState)(!1),P,F;t[0]===f?(P=t[1],F=t[2]):(P=()=>{if(f==null)return;let e=j.current;e&&e.focus()},F=[f],t[0]=f,t[1]=P,t[2]=F),(0,Z.useEffect)(P,F);let I;t[3]!==te||t[4]!==g?(I=e=>{e?.preventDefault();let t=te.trim();t.length!==0&&(g(t),j.current?.blur())},t[3]=te,t[4]=g,t[5]=I):I=t[5];let L=I,oe=s?p:Ke,R=!s,z;t[6]!==oe||t[7]!==R?(z=(0,$.jsx)(u,{variant:`ghost`,size:`icon-xs`,onClick:oe,disabled:R,"aria-label":`Back`,type:`button`}),t[6]=oe,t[7]=R,t[8]=z):z=t[8];let B;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(ce,{}),t[9]=B):B=t[9];let V;t[10]===z?V=t[11]:(V=(0,$.jsx)(E,{render:z,children:B}),t[10]=z,t[11]=V);let U;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(D,{children:`Back`}),t[12]=U):U=t[12];let W;t[13]===V?W=t[14]:(W=(0,$.jsxs)(k,{children:[V,U]}),t[13]=V,t[14]=W);let le=c?m:Ke,G=!c,K;t[15]!==le||t[16]!==G?(K=(0,$.jsx)(u,{variant:`ghost`,size:`icon-xs`,onClick:le,disabled:G,"aria-label":`Forward`,type:`button`}),t[15]=le,t[16]=G,t[17]=K):K=t[17];let q;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(re,{}),t[18]=q):q=t[18];let J;t[19]===K?J=t[20]:(J=(0,$.jsx)(E,{render:K,children:q}),t[19]=K,t[20]=J);let ue;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(D,{children:`Forward`}),t[21]=ue):ue=t[21];let Y;t[22]===J?Y=t[23]:(Y=(0,$.jsxs)(k,{children:[J,ue]}),t[22]=J,t[23]=Y);let de=l?Ke:h,fe=i?`Stop`:`Refresh`,pe;t[24]!==l||t[25]!==de||t[26]!==fe?(pe=(0,$.jsx)(u,{variant:`ghost`,size:`icon-xs`,onClick:de,disabled:l,"aria-label":fe,type:`button`}),t[24]=l,t[25]=de,t[26]=fe,t[27]=pe):pe=t[27];let me=i&&`animate-spin`,he;t[28]===me?he=t[29]:(he=o(me),t[28]=me,t[29]=he);let ge;t[30]===he?ge=t[31]:(ge=(0,$.jsx)(ie,{className:he}),t[30]=he,t[31]=ge);let _e;t[32]!==pe||t[33]!==ge?(_e=(0,$.jsx)(E,{render:pe,children:ge}),t[32]=pe,t[33]=ge,t[34]=_e):_e=t[34];let ve=i?`Loading…`:`Refresh`,ye;t[35]===ve?ye=t[36]:(ye=(0,$.jsx)(D,{children:ve}),t[35]=ve,t[36]=ye);let be;t[37]!==_e||t[38]!==ye?(be=(0,$.jsxs)(k,{children:[_e,ye]}),t[37]=_e,t[38]=ye,t[39]=be):be=t[39];let xe;t[40]!==W||t[41]!==Y||t[42]!==be?(xe=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[W,Y,be]}),t[40]=W,t[41]=Y,t[42]=be,t[43]=xe):xe=t[43];let Se=N?te:r??n,Ce=_&&!N&&`group-hover/address:pe-7 transition-[padding]`,we;t[44]===Ce?we=t[45]:(we=o(Ce),t[44]=Ce,t[45]=we);let Te;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>M(e.target.value),t[46]=Te):Te=t[46];let Ee;t[47]===n?Ee=t[48]:(Ee=()=>{M(n),ne(!0),queueMicrotask(()=>j.current?.select())},t[47]=n,t[48]=Ee);let De;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(De=()=>{ne(!1)},t[49]=De):De=t[49];let Oe;t[50]!==L||t[51]!==n?(Oe=e=>{e.key===`Enter`&&L(e),e.key===`Escape`&&(e.preventDefault(),M(n),j.current?.blur())},t[50]=L,t[51]=n,t[52]=Oe):Oe=t[52];let ke;t[53]!==d||t[54]!==Se||t[55]!==we||t[56]!==Ee||t[57]!==Oe?(ke=(0,$.jsx)(E,{render:(0,$.jsx)(Ge,{ref:j,value:Se,className:we,onChange:Te,onFocus:Ee,onBlur:De,onKeyDown:Oe,placeholder:`Search or enter URL`,spellCheck:!1,disabled:d,"data-preview-url-input":!0,size:`sm`})}),t[53]=d,t[54]=Se,t[55]=we,t[56]=Ee,t[57]=Oe,t[58]=ke):ke=t[58];let Ae;t[59]!==r||t[60]!==N||t[61]!==n?(Ae=!N&&r?(0,$.jsx)(D,{children:n}):null,t[59]=r,t[60]=N,t[61]=n,t[62]=Ae):Ae=t[62];let je;t[63]!==ke||t[64]!==Ae?(je=(0,$.jsxs)(k,{children:[ke,Ae]}),t[63]=ke,t[64]=Ae,t[65]=je):je=t[65];let X;t[66]!==N||t[67]!==_?(X=_&&!N?(0,$.jsx)(Ue,{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)(k,{children:[(0,$.jsx)(E,{render:(0,$.jsx)(u,{variant:`ghost`,size:`icon-xs`,onClick:_,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(se,{})}),(0,$.jsx)(D,{children:`Open in system browser`})]})}):null,t[66]=N,t[67]=_,t[68]=X):X=t[68];let Me;t[69]!==je||t[70]!==X?(Me=(0,$.jsxs)(Ve,{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:[je,X]}),t[69]=je,t[70]=X,t[71]=Me):Me=t[71];let Ne;t[72]!==w||t[73]!==T||t[74]!==O||t[75]!==A?(Ne=w?(0,$.jsxs)(k,{children:[(0,$.jsx)(E,{render:(0,$.jsx)(u,{variant:T?`secondary`:`ghost`,size:`icon-xs`,onClick:w,disabled:O,"aria-label":T?`Cancel annotation`:`Annotate preview`,"aria-pressed":T?`true`:`false`,type:`button`}),children:(0,$.jsx)(H,{className:o(T&&`text-primary`)})}),(0,$.jsx)(D,{children:O&&A?A:T?`Cancel annotation (Esc)`:`Annotate elements, regions, and drawings`})]}):null,t[72]=w,t[73]=T,t[74]=O,t[75]=A,t[76]=Ne):Ne=t[76];let Pe;t[77]!==y||t[78]!==v||t[79]!==b?(Pe=v?(0,$.jsxs)(k,{children:[(0,$.jsxs)(E,{render:(0,$.jsx)(u,{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)(Le,{className:o(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)(D,{children:b?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[77]=y,t[78]=v,t[79]=b,t[80]=Pe):Pe=t[80];let Fe;t[81]!==x||t[82]!==S||t[83]!==C?(Fe=x?(0,$.jsxs)(k,{children:[(0,$.jsx)(E,{render:(0,$.jsx)(u,{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)(ae,{className:o(S&&`text-primary`)})}),(0,$.jsx)(D,{children:S?`Close floating preview`:`Float preview over chat`})]}):null,t[81]=x,t[82]=S,t[83]=C,t[84]=Fe):Fe=t[84];let Ie;t[85]!==L||t[86]!==xe||t[87]!==Me||t[88]!==Ne||t[89]!==Pe||t[90]!==Fe||t[91]!==ee?(Ie=(0,$.jsxs)(`form`,{onSubmit:L,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[xe,Me,Ne,Pe,Fe,ee]}),t[85]=L,t[86]=xe,t[87]=Me,t[88]=Ne,t[89]=Pe,t[90]=Fe,t[91]=ee,t[92]=Ie):Ie=t[92];let Re;t[93]===a?Re=t[94]:(Re=a>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:`${a}%`,boxShadow:`0 0 6px 1px var(--color-ring)`}}):null,t[93]=a,t[94]=Re);let ze;return t[95]!==Ie||t[96]!==Re?(ze=(0,$.jsxs)(`div`,{className:`relative`,children:[Ie,Re]}),t[95]=Ie,t[96]=Re,t[97]=ze):ze=t[97],ze}function Je(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 Ye(e){let t=(0,Q.c)(6),{className:n}=e,r;t[0]===n?r=t[1]:(r=o(`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 a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(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]=a):a=t[3];let s;return t[4]===r?s=t[5]:(s=(0,$.jsxs)(`div`,{"aria-hidden":!0,className:r,children:[i,a]}),t[4]=r,t[5]=s),s}function Xe(e){let t=(0,Q.c)(17),{server:n,onOpen:r}=e,i;t[0]===n?i=t[1]:(i=Ze(n),t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Ye,{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)(Qe,{}):(0,$.jsx)($e,{}),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 Ze(e){return e.processName?e.processName:e.listening?`Listening`:e.source===`configured`?`Configured`:`Recently seen`}function Qe(){let e=(0,Q.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 $e(){let e=(0,Q.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 et(e){let t=(0,Q.c)(7),n=de(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:J(e.environmentId,t.url)}),t[5]=e.environmentId,t[6]=i),r=tt({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 tt(e){let t=new Map;for(let n of e.configuredUrls){let e=rt(n);if(!e)continue;let r=nt(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=nt(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=rt(n);if(!e)continue;let r=nt(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 nt(e,t){return`${e.toLowerCase()}:${t}`}function rt(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`||!Te(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 it(e){let t=(0,Q.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=et(o);if(s.length===0){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(V,{children:[(0,$.jsx)(L,{variant:`icon`,children:(0,$.jsx)(B,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(ve,{children:`No preview yet`}),(0,$.jsx)(ye,{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)(Be,{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)(Xe,{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 at=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function ot(e){let t=(0,Q.c)(74),{tabId:n,hasWebContents:a,zoomFactor:o,colorScheme:c,deviceToolbarVisible:l,onToggleDeviceToolbar:f,nativePictureInPicture:p,onNativePictureInPicture:g}=e;if(!K)return null;let _=!n||!a,v;t[0]===n?v=t[1]:(v=e=>()=>{n&&e(n).catch(mt)},t[0]=n,t[1]=v);let b=v,S;t[2]===o?S=t[3]:(S=Math.round(o*100),t[2]=o,t[3]=S);let C=`${S}%`,w;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsxs)(k,{children:[(0,$.jsx)(E,{render:(0,$.jsx)(y,{render:(0,$.jsx)(u,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(Re,{})}),(0,$.jsx)(D,{children:`More`})]}),t[4]=w):w=t[4];let T;t[5]===b?T=t[6]:(T=b(K.hardReload),t[5]=b,t[6]=T);let O;t[7]!==T||t[8]!==_?(O=(0,$.jsx)(h,{onClick:T,disabled:_,children:`Hard reload`}),t[7]=T,t[8]=_,t[9]=O):O=t[9];let A;t[10]===b?A=t[11]:(A=b(K.openDevTools),t[10]=b,t[11]=A);let j;t[12]!==A||t[13]!==_?(j=(0,$.jsx)(h,{onClick:A,disabled:_,children:`Open DevTools`}),t[12]=A,t[13]=_,t[14]=j):j=t[14];let te=p?`Close separate preview window`:`Open separate preview window`,M;t[15]!==g||t[16]!==te||t[17]!==_?(M=(0,$.jsx)(h,{onClick:g,disabled:_,children:te}),t[15]=g,t[16]=te,t[17]=_,t[18]=M):M=t[18];let N=l?`Hide device toolbar`:`Show device toolbar`,ne;t[19]!==f||t[20]!==N||t[21]!==_?(ne=(0,$.jsx)(h,{onClick:f,disabled:_,children:N}),t[19]=f,t[20]=N,t[21]=_,t[22]=ne):ne=t[22];let P;t[23]===_?P=t[24]:(P=(0,$.jsx)(x,{disabled:_,children:`Appearance`}),t[23]=_,t[24]=P);let F;t[25]===n?F=t[26]:(F=e=>{n&&K.setColorScheme(n,e).catch(pt)},t[25]=n,t[26]=F);let re;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(re=at.map(ft),t[27]=re):re=t[27];let I;t[28]!==c||t[29]!==F?(I=(0,$.jsx)(s,{className:`min-w-32`,children:(0,$.jsx)(m,{value:c,onValueChange:F,children:re})}),t[28]=c,t[29]=F,t[30]=I):I=t[30];let L;t[31]!==P||t[32]!==I?(L=(0,$.jsxs)(ee,{children:[P,I]}),t[31]=P,t[32]=I,t[33]=L):L=t[33];let ie;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(r,{}),t[34]=ie):ie=t[34];let ae;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(`span`,{children:`Zoom`}),t[35]=ae):ae=t[35];let R;t[36]===b?R=t[37]:(R=b(K.zoomOut),t[36]=b,t[37]=R);let z;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(be,{}),t[38]=z):z=t[38];let B;t[39]!==R||t[40]!==_?(B=(0,$.jsx)(u,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:R,"aria-label":`Zoom out`,disabled:_,children:z}),t[39]=R,t[40]=_,t[41]=B):B=t[41];let V;t[42]===C?V=t[43]:(V=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:C}),t[42]=C,t[43]=V);let H;t[44]===b?H=t[45]:(H=b(K.zoomIn),t[44]=b,t[45]=H);let se;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(oe,{}),t[46]=se):se=t[46];let U;t[47]!==H||t[48]!==_?(U=(0,$.jsx)(u,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:H,"aria-label":`Zoom in`,disabled:_,children:se}),t[47]=H,t[48]=_,t[49]=U):U=t[49];let ce;t[50]===b?ce=t[51]:(ce=b(K.resetZoom),t[50]=b,t[51]=ce);let W;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(Ne,{}),t[52]=W):W=t[52];let le;t[53]!==ce||t[54]!==_?(le=(0,$.jsx)(u,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:ce,"aria-label":`Reset zoom`,disabled:_,children:W}),t[53]=ce,t[54]=_,t[55]=le):le=t[55];let G;t[56]!==B||t[57]!==V||t[58]!==U||t[59]!==le?(G=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[B,V,U,le]}),t[56]=B,t[57]=V,t[58]=U,t[59]=le,t[60]=G):G=t[60];let q;t[61]!==G||t[62]!==_?(q=(0,$.jsxs)(h,{closeOnClick:!1,onClick:dt,className:`justify-between`,disabled:_,children:[ae,G]}),t[61]=G,t[62]=_,t[63]=q):q=t[63];let J,ue,Y;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,$.jsx)(r,{}),ue=(0,$.jsx)(h,{onClick:lt,children:`Clear cookies`}),Y=(0,$.jsx)(h,{onClick:st,children:`Clear cache`}),t[64]=J,t[65]=ue,t[66]=Y):(J=t[64],ue=t[65],Y=t[66]);let de;return t[67]!==ne||t[68]!==L||t[69]!==q||t[70]!==O||t[71]!==j||t[72]!==M?(de=(0,$.jsxs)(d,{children:[w,(0,$.jsxs)(i,{align:`end`,sideOffset:6,className:`min-w-56`,children:[O,j,M,ne,L,ie,q,J,ue,Y]})]}),t[67]=ne,t[68]=L,t[69]=q,t[70]=O,t[71]=j,t[72]=M,t[73]=de):de=t[73],de}function st(){K.clearCache().catch(ct)}function ct(){}function lt(){K.clearCookies().catch(ut)}function ut(){}function dt(e){return e.preventDefault()}function ft(e){return(0,$.jsx)(v,{value:e.value,children:e.label},e.value)}function pt(){}function mt(){}function ht(e){return _e[e]||(e.length>0?e:`Network error`)}function gt(e){let t=(0,Q.c)(32),{url:n,code:r,description:i,onReload:a}=e,[o,s]=(0,Z.useState)(!1),c;t[0]===n?c=t[1]:(c=yt(n)??n,t[0]=n,t[1]=c);let l=c,d;t[2]===i?d=t[3]:(d=ht(i),t[2]=i,t[3]=d);let f=d,p;t[4]!==r||t[5]!==i?(p=i.length>0?i:`ERR_${Math.abs(r)||`FAILED`}`,t[4]=r,t[5]=i,t[6]=p):p=t[6];let m=p,h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(vt,{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]!==f||t[12]!==_?(v=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[_,`: `,f,`.`]}),t[11]=f,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(_t),t[18]=x):x=t[18];let S=o?`Hide details`:`Details`,C;t[19]===S?C=t[20]:(C=(0,$.jsx)(u,{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)(u,{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 _t(e){return!e}function vt(e){let t=(0,Q.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 yt(e){try{return new URL(e).host}catch{return null}}function bt(e){let t=e.toLowerCase();return t.includes(`mac`)?`Reveal in Finder`:t.includes(`win`)?`Reveal in File Explorer`:`Reveal in Files`}var xt=120,St=220,Ct=4,wt=90,Tt=.08,Et=.5;function Dt(e){let[t,n]=(0,Z.useState)(0),r=(0,Z.useRef)(0);return r.current=t,(0,Z.useEffect)(()=>{if(!e){if(r.current===0)return;n(100);let e=window.setTimeout(()=>n(0),St);return()=>window.clearTimeout(e)}n(e=>e>0&&e<95?e:Ct);let t=window.setInterval(()=>{let e=r.current;if(e>=wt)return;let t=wt-e,i=Math.max(Et,t*Tt);n(Math.min(wt,e+i))},xt);return()=>window.clearInterval(t)},[e]),t}var Ot=class extends j()(`PreviewSessionThreadKeyParseError`,{threadKey:M}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},kt=a(e=>{let t=S(e);if(t===null)throw new Ot({threadKey:e});let n=xe.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=xe.events({environmentId:t.environmentId,input:{}});return f(e=>{let i=!1,a=0,o=e=>{c(e)&&pe(t,e.value)},s=r=>{if(!c(r)||r.value.threadId!==t.threadId)return;let i=I(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}G(t,r.value)};e.addFinalizer(()=>{i=!0});let l=e.once(r);e.subscribe(n,e=>{o(e)}),e.subscribe(r,e=>{a+=1,s(e)}),queueMicrotask(()=>{i||(e.refresh(n),a===0&&s(l))})}).pipe(F(1e3),g(`preview:session-sync:${e}`))});function At(t){let n=(0,Q.c)(2),r;n[0]===t?r=n[1]:(r=kt(e(t)),n[0]=t,n[1]=r),T(r)}var jt=1500,Mt=.001;function Nt(e){let t=(0,Q.c)(11),{zoomFactor:n}=e,[r,i]=(0,Z.useState)(!1),a=(0,Z.useRef)(n),s=(0,Z.useRef)(null),c,l;t[0]===n?(c=t[1],l=t[2]):(c=()=>{if(!(Math.abs(a.current-n)<Mt))return a.current=n,i(!0),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{i(!1),s.current=null},jt),()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null)}},l=[n],t[0]=n,t[1]=c,t[2]=l),(0,Z.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=o(`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 Pt(e,t){return e?1:t===`human`?.18:.35}var Ft=700;function It(e){let t=(0,Q.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=Y(a),s;t[2]===n?s=t[3]:(s=e=>e.byTabId[n]?.content??null,t[2]=n,t[3]=s);let c=W(s);if(!o)return null;let l;return t[4]!==c||t[5]!==i||t[6]!==o||t[7]!==r?(l=(0,$.jsx)(Lt,{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 Lt(e){let t=(0,Q.c)(15),{event:n,content:r,zoomFactor:i,controller:a}=e,[o,s]=(0,Z.useState)(!0),c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=window.setTimeout(()=>s(!1),Ft);return()=>window.clearTimeout(e)},l=[],t[0]=c,t[1]=l):(c=t[0],l=t[1]),(0,Z.useEffect)(c,l);let u;t[2]!==o||t[3]!==a?(u=Pt(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)(ze,{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 Rt=typeof window>`u`?null:p();function zt({threadRef:n,tabId:r,configuredUrls:i,visible:a}){let[o,s]=(0,Z.useState)(void 0),[c,u]=(0,Z.useState)(!1),d=we(),f=(0,Z.useRef)(!1),p=(0,Z.useRef)(!0),m=De(n),h=Ie(e=>Me(e.byThreadKey,n)),g=b(e=>e.addPreviewAnnotation),_=b(e=>e.addImage),v=P(n.environmentId),y=w(n.environmentId),x=ne(xe.open),S=ne(xe.resize,`preview viewport resize`);At(n),(0,Z.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]);let C=r??m.activeTabId,T=C?ue(n,m.serverEpoch,C):null,E=C&&T?d.has(T)?T:Ee(n,C):null,D=C?m.sessions[C]??null:null,k=C?m.desktopByTabId[C]??null:null,A=D?.navStatus??{_tag:`Idle`},ee=A._tag===`Idle`?``:A.url,j=k?.loading??A._tag===`Loading`,te=k?.canGoBack??D?.canGoBack??!1,M=k?.canGoForward??D?.canGoForward??!1,N=A._tag===`Idle`,F=A._tag===`LoadFailed`,re=me(D),I=k?.controller??`none`,L=Dt(j),ie=ee&&v&&y?Je({url:ee,environmentLabel:v.label,environmentHttpBaseUrl:y})??void 0:void 0,ae=D?.viewport??l,oe=W(e=>T?e.byTabId[T]?.rect??null:null),R=(0,Z.useCallback)(async e=>{T&&K?(await K.navigate(T,e),je(n,e)):await le({openPreview:x,threadRef:n,url:e})},[x,T,n]),B=(0,Z.useCallback)(async e=>{try{await R(ke(e))}catch{}},[R]),V=(0,Z.useCallback)(async e=>{try{await R(J(n.environmentId,e))}catch{}},[R,n.environmentId]),H=(0,Z.useCallback)(()=>{K&&T&&K.refresh(T)},[T]),se=(0,Z.useCallback)(()=>{K&&T&&K.zoomIn(T)},[T]),U=(0,Z.useCallback)(()=>{K&&T&&K.zoomOut(T)},[T]),ce=(0,Z.useCallback)(()=>{K&&T&&K.resetZoom(T)},[T]),G=(0,Z.useCallback)(async e=>{if(!C)return;let r=await S({environmentId:n.environmentId,input:{threadId:n.threadId,tabId:C,viewport:e}});if(r._tag===`Failure`){let e=t(r);throw X.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}Ce(n,r.value)},[S,C,n]),Y=()=>{if(!T)return;if(ae._tag!==`fill`){Ae(T,l).catch(()=>void 0);return}let e=oe?Oe(oe,k?.zoomFactor):{width:1024,height:768};Ae(T,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Z.useEffect)(()=>{if(T)return Se(T,G)},[G,T]);let de=(0,Z.useCallback)(()=>{K&&T&&K.goBack(T)},[T]),pe=(0,Z.useCallback)(()=>{K&&T&&K.goForward(T)},[T]),he=(0,Z.useCallback)(()=>{!Rt||!ee||Rt.shell.openExternal(ee).catch(()=>void 0)},[ee]),_e=(0,Z.useCallback)(()=>{if(C){if(h?.tabId===C){Ie.getState().close(n);return}Ie.getState().open(n,C),O.getState().close(n)}},[h?.tabId,C,n]),ve=(0,Z.useCallback)(()=>{!K||!T||(k?.pictureInPicture?K.pictureInPicture.close:K.pictureInPicture.open)(T).catch(e=>{X.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[k?.pictureInPicture,T]),ye=(0,Z.useCallback)(e=>{if(!K||!T||!C)return;let t=K;if(E){q(E).then(e=>{if(!e)return;let n=!1,r,i=()=>{if(!navigator.clipboard?.writeText){X.update(r,fe({type:`error`,title:`Unable to copy recording path`,description:`Clipboard API unavailable.`,actionProps:a}));return}navigator.clipboard.writeText(e.path).then(()=>{n=!0,o(),window.setTimeout(()=>{n=!1,o()},2e3)},e=>{X.update(r,fe({type:`error`,title:`Unable to copy recording path`,description:e instanceof Error?e.message:`An error occurred.`,actionProps:a}))})},a={children:bt(navigator.platform),onClick:()=>void t.revealArtifact(e.path)},o=()=>{X.update(r,fe({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:n?`Copied!`:`Copy path`,disabled:n,onClick:i},secondaryActionVariant:`outline`}}))};r=X.add(fe({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:`Copy path`,onClick:i},secondaryActionVariant:`outline`}}))},e=>{X.add({type:`error`,title:`Unable to stop recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}if(e){ge(T,n,C).catch(e=>{X.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}t.captureScreenshot(T).then(e=>{let n={children:bt(navigator.platform),onClick:()=>void t.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,t=`Screenshot saved`,o)=>{X.update(a,fe({type:e,title:t,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:{...n},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=()=>{t.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=X.add(fe({type:`success`,title:`Screenshot saved`,actionProps:{children:`Copy image`,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:`Copy path`,onClick:s}}],secondaryActionProps:{...n},secondaryActionVariant:`outline`}}))},e=>{X.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[E,T,C,n]),be=(0,Z.useCallback)(()=>{if(!K||!T)return;if(f.current){K.cancelPickElement(T).catch(()=>void 0);return}let e=typeof document<`u`?document.activeElement:null;f.current=!0,u(!0),(async()=>{try{let e=await K.pickElement(T);if(!e)return;g(n,e);let t=await Fe(e);t&&e.screenshot&&_(n,{type:`image`,id:e.id,name:t.name,mimeType:t.type,sizeBytes:t.size,previewUrl:e.screenshot.dataUrl,file:t})}catch{}finally{if(f.current=!1,p.current&&u(!1),e&&e.isConnected&&typeof e.focus==`function`)try{e.focus({preventScroll:!0})}catch{}}})()},[_,g,T,n]);return(0,Z.useEffect)(()=>()=>{f.current&&(f.current=!1,K&&T&&K.cancelPickElement(T).catch(()=>void 0),p.current&&u(!1))},[T]),(0,Z.useEffect)(()=>{if(a)return z(e=>{switch(e){case`refresh`:H();return;case`focus-url`:s(e=>(e??0)+1);return;case`zoom-in`:se();return;case`zoom-out`:U();return;case`reset-zoom`:ce();return;case`toggle-panel`:return}})},[H,ce,se,U,a]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":e(n),children:[(0,$.jsx)(qe,{url:ee,displayUrl:ie,loading:j,loadProgress:L,canGoBack:te,canGoForward:M,refreshDisabled:N,focusUrlNonce:o,onBack:de,onForward:pe,onRefresh:H,onSubmit:e=>void B(e),onOpenInBrowser:C?he:void 0,onCapture:K&&C?ye:void 0,captureDisabled:!k||F,recording:E!==null,onPictureInPicture:K&&C?_e:void 0,pictureInPicture:h?.tabId===C,pictureInPictureDisabled:!k?.hasWebContents||F,onPickElement:K&&C?be:void 0,pickActive:c,pickDisabled:!C||F,pickDisabledReason:F?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:K?(0,$.jsx)(ot,{tabId:T,hasWebContents:k?.hasWebContents??!1,zoomFactor:k?.zoomFactor??1,colorScheme:k?.colorScheme??`system`,deviceToolbarVisible:ae._tag!==`fill`,onToggleDeviceToolbar:Y,nativePictureInPicture:k?.pictureInPicture??!1,onNativePictureInPicture:ve}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[T&&D&&!re?(0,$.jsx)(Pe,{tabId:T,visible:a&&!F,className:`absolute inset-0 h-full w-full`},T):null,re?(0,$.jsx)(it,{environmentId:n.environmentId,configuredUrls:i,recentlySeenUrls:m.recentlySeenUrls,onOpenUrl:e=>void V(e)}):null,D&&k?(0,$.jsx)(Nt,{zoomFactor:k.zoomFactor}):null,T&&k&&!re&&!F?(0,$.jsx)(It,{tabId:T,zoomFactor:k.zoomFactor,controller:I}):null,I===`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:I===`agent`?`Agent controlling browser`:`Human control`}),A._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(gt,{url:A.url,code:A.code,description:A.description,onReload:H})}):null]})]})}function Bt(e){let t=(0,Q.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!U()){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 P4Code desktop app.`})}),t[0]=e):e=t[0];let r;return t[1]===n?r=t[2]:(r=(0,$.jsx)(he,{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)(zt,{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)(he,{mode:n,children:c}),t[10]=n,t[11]=c,t[12]=l):l=t[12],l}export{Bt as PreviewPanel};
2
- //# sourceMappingURL=PreviewPanel-B5dlT-n2.js.map
1
+ import{$s as e,Ds as t,Ff as n,Gr as r,Hr as i,Is as a,It as o,Jr as s,Ks as c,Oc as l,Pr as u,Rr as d,Rs as f,T as p,Ur as m,Vr as h,Vs as g,Wf as _,Wr as v,Xr as y,Xt as b,Yr as x,Ys as S,as as C,b as w,ds as T,g as E,m as D,o as O,p as k,qo as A,qr as ee,ru as j,sp as te,tu as M,up as N,v as ne,y as P,zs as F}from"./textarea-DXib_Xm1.js";import{t as re}from"./arrow-right-AJ0Jl2nt.js";import{$n as I,An as L,Cr as ie,Dr as ae,Er as oe,Jn as R,Mn as z,Mr as B,On as V,Or as H,Pr as se,Qn as U,Rr as ce,Sn as W,Xn as le,Zn as G,_n as K,a as q,ar as J,bn as ue,c as Y,cr as de,dr as fe,er as pe,gn as me,hn as he,i as ge,ir as _e,jn as ve,kn as ye,kr as be,lr as xe,n as Se,nr as Ce,o as we,or as Te,r as Ee,rr as De,s as Oe,sr as ke,t as Ae,tr as je,ur as X,vn as Me,wr as Ne,xn as Pe,y as Fe,yn as Ie}from"./index-CmXGS7F0.js";var Le=A(`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`}]]),Re=A(`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`}]]),ze=A(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),Be=A(`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=N(te(),1),Q=n(),$=_();function Ve(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`relative inline-flex w-full min-w-0 items-center rounded-lg border border-input bg-background not-dark:bg-clip-padding text-base text-foreground shadow-xs/5 ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_1px_--theme(--color-black/4%)] has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/64 has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/16 has-[textarea]:h-auto has-data-[align=block-end]:h-auto has-data-[align=block-start]:h-auto has-data-[align=block-end]:flex-col has-data-[align=block-start]:flex-col has-[input:focus-visible,textarea:focus-visible]:border-ring has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/36 has-autofill:bg-foreground/4 has-[input:disabled,textarea:disabled]:opacity-64 has-[input:disabled,textarea:disabled,input:focus-visible,textarea:focus-visible,input[aria-invalid],textarea[aria-invalid]]:shadow-none has-[input:focus-visible,textarea:focus-visible]:ring-[3px] sm:text-sm dark:bg-input/32 dark:has-autofill:bg-foreground/8 dark:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/24 dark:not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_-1px_--theme(--color-white/6%)] has-data-[align=inline-start]:**:[[data-size=sm]_input]:ps-1.5 has-data-[align=inline-end]:**:[[data-size=sm]_input]:pe-1.5 *:[[data-slot=input-control],[data-slot=textarea-control]]:contents *:[[data-slot=input-control],[data-slot=textarea-control]]:before:hidden has-[[data-align=block-start],[data-align=block-end]]:**:[input]:h-auto has-data-[align=inline-start]:**:[input]:ps-2 has-data-[align=inline-end]:**:[input]:pe-2 has-data-[align=block-end]:**:[input]:pt-1.5 has-data-[align=block-start]:**:[input]:pb-1.5 **:[textarea]:min-h-20.5 **:[textarea]:resize-none **:[textarea]:py-[calc(--spacing(3)-1px)] **:[textarea]:max-sm:min-h-23.5 **:[textarea_button]:rounded-[calc(var(--radius-md)-1px)]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{className:i,"data-slot":`input-group`,role:`group`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var He=C(`[&_svg]:-mx-0.5 flex h-auto cursor-text select-none items-center justify-center gap-2 leading-none [&>kbd]:rounded-[calc(var(--radius)-5px)] in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4.5 sm:in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4 not-has-[button]:**:[svg:not([class*='opacity-'])]:opacity-80`,{defaultVariants:{align:`inline-start`},variants:{align:{"block-end":`order-last w-full justify-start px-[calc(--spacing(3)-1px)] pb-[calc(--spacing(3)-1px)] [.border-t]:pt-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]`,"block-start":`order-first w-full justify-start px-[calc(--spacing(3)-1px)] pt-[calc(--spacing(3)-1px)] [.border-b]:pb-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]`,"inline-end":`has-[>:last-child[data-slot=badge]]:-me-1.5 has-[>button]:-me-2 order-last pe-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:me-[-0.35rem] [[data-size=sm]+&]:pe-[calc(--spacing(2.5)-1px)]`,"inline-start":`has-[>:last-child[data-slot=badge]]:-ms-1.5 has-[>button]:-ms-2 order-first ps-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:ms-[-0.35rem] [[data-size=sm]+&]:ps-[calc(--spacing(2.5)-1px)]`}}});function Ue(e){let t=(0,Q.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,s;t[4]!==a||t[5]!==n?(s=o(He({align:a}),n),t[4]=a,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==r||t[9]!==s?(c=(0,$.jsx)(`div`,{className:s,"data-align":a,"data-slot":`input-group-addon`,onMouseDown:We,...r}),t[7]=a,t[8]=r,t[9]=s,t[10]=c):c=t[10],c}function We(e){if(e.target.closest(`button, a, input, select, textarea, [role='button'], [role='combobox'], [role='listbox'], [data-slot='select-trigger']`))return;e.preventDefault();let t=e.currentTarget.parentElement,n=t?.querySelector(`input, textarea`);n&&!t?.querySelector(`input:focus, textarea:focus`)&&n.focus()}function Ge(e){let t=(0,Q.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,$.jsx)(R,{className:n,unstyled:!0,...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}var Ke=()=>{};function qe(e){let t=(0,Q.c)(98),{url:n,displayUrl:r,loading:i,loadProgress:a,canGoBack:s,canGoForward:c,refreshDisabled:l,inputDisabled:d,focusUrlNonce:f,onBack:p,onForward:m,onRefresh:h,onSubmit:g,onOpenInBrowser:_,onCapture:v,captureDisabled:y,recording:b,onPictureInPicture:x,pictureInPicture:S,pictureInPictureDisabled:C,onPickElement:w,pickActive:T,pickDisabled:O,pickDisabledReason:A,trailingActions:ee}=e,j=(0,Z.useRef)(null),[te,M]=(0,Z.useState)(n),[N,ne]=(0,Z.useState)(!1),P,F;t[0]===f?(P=t[1],F=t[2]):(P=()=>{if(f==null)return;let e=j.current;e&&e.focus()},F=[f],t[0]=f,t[1]=P,t[2]=F),(0,Z.useEffect)(P,F);let I;t[3]!==te||t[4]!==g?(I=e=>{e?.preventDefault();let t=te.trim();t.length!==0&&(g(t),j.current?.blur())},t[3]=te,t[4]=g,t[5]=I):I=t[5];let L=I,oe=s?p:Ke,R=!s,z;t[6]!==oe||t[7]!==R?(z=(0,$.jsx)(u,{variant:`ghost`,size:`icon-xs`,onClick:oe,disabled:R,"aria-label":`Back`,type:`button`}),t[6]=oe,t[7]=R,t[8]=z):z=t[8];let B;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(ce,{}),t[9]=B):B=t[9];let V;t[10]===z?V=t[11]:(V=(0,$.jsx)(E,{render:z,children:B}),t[10]=z,t[11]=V);let U;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(D,{children:`Back`}),t[12]=U):U=t[12];let W;t[13]===V?W=t[14]:(W=(0,$.jsxs)(k,{children:[V,U]}),t[13]=V,t[14]=W);let le=c?m:Ke,G=!c,K;t[15]!==le||t[16]!==G?(K=(0,$.jsx)(u,{variant:`ghost`,size:`icon-xs`,onClick:le,disabled:G,"aria-label":`Forward`,type:`button`}),t[15]=le,t[16]=G,t[17]=K):K=t[17];let q;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(re,{}),t[18]=q):q=t[18];let J;t[19]===K?J=t[20]:(J=(0,$.jsx)(E,{render:K,children:q}),t[19]=K,t[20]=J);let ue;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(D,{children:`Forward`}),t[21]=ue):ue=t[21];let Y;t[22]===J?Y=t[23]:(Y=(0,$.jsxs)(k,{children:[J,ue]}),t[22]=J,t[23]=Y);let de=l?Ke:h,fe=i?`Stop`:`Refresh`,pe;t[24]!==l||t[25]!==de||t[26]!==fe?(pe=(0,$.jsx)(u,{variant:`ghost`,size:`icon-xs`,onClick:de,disabled:l,"aria-label":fe,type:`button`}),t[24]=l,t[25]=de,t[26]=fe,t[27]=pe):pe=t[27];let me=i&&`animate-spin`,he;t[28]===me?he=t[29]:(he=o(me),t[28]=me,t[29]=he);let ge;t[30]===he?ge=t[31]:(ge=(0,$.jsx)(ie,{className:he}),t[30]=he,t[31]=ge);let _e;t[32]!==pe||t[33]!==ge?(_e=(0,$.jsx)(E,{render:pe,children:ge}),t[32]=pe,t[33]=ge,t[34]=_e):_e=t[34];let ve=i?`Loading…`:`Refresh`,ye;t[35]===ve?ye=t[36]:(ye=(0,$.jsx)(D,{children:ve}),t[35]=ve,t[36]=ye);let be;t[37]!==_e||t[38]!==ye?(be=(0,$.jsxs)(k,{children:[_e,ye]}),t[37]=_e,t[38]=ye,t[39]=be):be=t[39];let xe;t[40]!==W||t[41]!==Y||t[42]!==be?(xe=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[W,Y,be]}),t[40]=W,t[41]=Y,t[42]=be,t[43]=xe):xe=t[43];let Se=N?te:r??n,Ce=_&&!N&&`group-hover/address:pe-7 transition-[padding]`,we;t[44]===Ce?we=t[45]:(we=o(Ce),t[44]=Ce,t[45]=we);let Te;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>M(e.target.value),t[46]=Te):Te=t[46];let Ee;t[47]===n?Ee=t[48]:(Ee=()=>{M(n),ne(!0),queueMicrotask(()=>j.current?.select())},t[47]=n,t[48]=Ee);let De;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(De=()=>{ne(!1)},t[49]=De):De=t[49];let Oe;t[50]!==L||t[51]!==n?(Oe=e=>{e.key===`Enter`&&L(e),e.key===`Escape`&&(e.preventDefault(),M(n),j.current?.blur())},t[50]=L,t[51]=n,t[52]=Oe):Oe=t[52];let ke;t[53]!==d||t[54]!==Se||t[55]!==we||t[56]!==Ee||t[57]!==Oe?(ke=(0,$.jsx)(E,{render:(0,$.jsx)(Ge,{ref:j,value:Se,className:we,onChange:Te,onFocus:Ee,onBlur:De,onKeyDown:Oe,placeholder:`Search or enter URL`,spellCheck:!1,disabled:d,"data-preview-url-input":!0,size:`sm`})}),t[53]=d,t[54]=Se,t[55]=we,t[56]=Ee,t[57]=Oe,t[58]=ke):ke=t[58];let Ae;t[59]!==r||t[60]!==N||t[61]!==n?(Ae=!N&&r?(0,$.jsx)(D,{children:n}):null,t[59]=r,t[60]=N,t[61]=n,t[62]=Ae):Ae=t[62];let je;t[63]!==ke||t[64]!==Ae?(je=(0,$.jsxs)(k,{children:[ke,Ae]}),t[63]=ke,t[64]=Ae,t[65]=je):je=t[65];let X;t[66]!==N||t[67]!==_?(X=_&&!N?(0,$.jsx)(Ue,{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)(k,{children:[(0,$.jsx)(E,{render:(0,$.jsx)(u,{variant:`ghost`,size:`icon-xs`,onClick:_,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(se,{})}),(0,$.jsx)(D,{children:`Open in system browser`})]})}):null,t[66]=N,t[67]=_,t[68]=X):X=t[68];let Me;t[69]!==je||t[70]!==X?(Me=(0,$.jsxs)(Ve,{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:[je,X]}),t[69]=je,t[70]=X,t[71]=Me):Me=t[71];let Ne;t[72]!==w||t[73]!==T||t[74]!==O||t[75]!==A?(Ne=w?(0,$.jsxs)(k,{children:[(0,$.jsx)(E,{render:(0,$.jsx)(u,{variant:T?`secondary`:`ghost`,size:`icon-xs`,onClick:w,disabled:O,"aria-label":T?`Cancel annotation`:`Annotate preview`,"aria-pressed":T?`true`:`false`,type:`button`}),children:(0,$.jsx)(H,{className:o(T&&`text-primary`)})}),(0,$.jsx)(D,{children:O&&A?A:T?`Cancel annotation (Esc)`:`Annotate elements, regions, and drawings`})]}):null,t[72]=w,t[73]=T,t[74]=O,t[75]=A,t[76]=Ne):Ne=t[76];let Pe;t[77]!==y||t[78]!==v||t[79]!==b?(Pe=v?(0,$.jsxs)(k,{children:[(0,$.jsxs)(E,{render:(0,$.jsx)(u,{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)(Le,{className:o(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)(D,{children:b?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[77]=y,t[78]=v,t[79]=b,t[80]=Pe):Pe=t[80];let Fe;t[81]!==x||t[82]!==S||t[83]!==C?(Fe=x?(0,$.jsxs)(k,{children:[(0,$.jsx)(E,{render:(0,$.jsx)(u,{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)(ae,{className:o(S&&`text-primary`)})}),(0,$.jsx)(D,{children:S?`Close floating preview`:`Float preview over chat`})]}):null,t[81]=x,t[82]=S,t[83]=C,t[84]=Fe):Fe=t[84];let Ie;t[85]!==L||t[86]!==xe||t[87]!==Me||t[88]!==Ne||t[89]!==Pe||t[90]!==Fe||t[91]!==ee?(Ie=(0,$.jsxs)(`form`,{onSubmit:L,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[xe,Me,Ne,Pe,Fe,ee]}),t[85]=L,t[86]=xe,t[87]=Me,t[88]=Ne,t[89]=Pe,t[90]=Fe,t[91]=ee,t[92]=Ie):Ie=t[92];let Re;t[93]===a?Re=t[94]:(Re=a>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:`${a}%`,boxShadow:`0 0 6px 1px var(--color-ring)`}}):null,t[93]=a,t[94]=Re);let ze;return t[95]!==Ie||t[96]!==Re?(ze=(0,$.jsxs)(`div`,{className:`relative`,children:[Ie,Re]}),t[95]=Ie,t[96]=Re,t[97]=ze):ze=t[97],ze}function Je(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 Ye(e){let t=(0,Q.c)(6),{className:n}=e,r;t[0]===n?r=t[1]:(r=o(`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 a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(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]=a):a=t[3];let s;return t[4]===r?s=t[5]:(s=(0,$.jsxs)(`div`,{"aria-hidden":!0,className:r,children:[i,a]}),t[4]=r,t[5]=s),s}function Xe(e){let t=(0,Q.c)(17),{server:n,onOpen:r}=e,i;t[0]===n?i=t[1]:(i=Ze(n),t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Ye,{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)(Qe,{}):(0,$.jsx)($e,{}),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 Ze(e){return e.processName?e.processName:e.listening?`Listening`:e.source===`configured`?`Configured`:`Recently seen`}function Qe(){let e=(0,Q.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 $e(){let e=(0,Q.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 et(e){let t=(0,Q.c)(7),n=de(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:J(e.environmentId,t.url)}),t[5]=e.environmentId,t[6]=i),r=tt({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 tt(e){let t=new Map;for(let n of e.configuredUrls){let e=rt(n);if(!e)continue;let r=nt(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=nt(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=rt(n);if(!e)continue;let r=nt(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 nt(e,t){return`${e.toLowerCase()}:${t}`}function rt(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`||!Te(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 it(e){let t=(0,Q.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=et(o);if(s.length===0){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(V,{children:[(0,$.jsx)(L,{variant:`icon`,children:(0,$.jsx)(B,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(ve,{children:`No preview yet`}),(0,$.jsx)(ye,{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)(Be,{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)(Xe,{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 at=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function ot(e){let t=(0,Q.c)(74),{tabId:n,hasWebContents:a,zoomFactor:o,colorScheme:c,deviceToolbarVisible:l,onToggleDeviceToolbar:f,nativePictureInPicture:p,onNativePictureInPicture:g}=e;if(!K)return null;let _=!n||!a,v;t[0]===n?v=t[1]:(v=e=>()=>{n&&e(n).catch(mt)},t[0]=n,t[1]=v);let b=v,S;t[2]===o?S=t[3]:(S=Math.round(o*100),t[2]=o,t[3]=S);let C=`${S}%`,w;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsxs)(k,{children:[(0,$.jsx)(E,{render:(0,$.jsx)(y,{render:(0,$.jsx)(u,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(Re,{})}),(0,$.jsx)(D,{children:`More`})]}),t[4]=w):w=t[4];let T;t[5]===b?T=t[6]:(T=b(K.hardReload),t[5]=b,t[6]=T);let O;t[7]!==T||t[8]!==_?(O=(0,$.jsx)(h,{onClick:T,disabled:_,children:`Hard reload`}),t[7]=T,t[8]=_,t[9]=O):O=t[9];let A;t[10]===b?A=t[11]:(A=b(K.openDevTools),t[10]=b,t[11]=A);let j;t[12]!==A||t[13]!==_?(j=(0,$.jsx)(h,{onClick:A,disabled:_,children:`Open DevTools`}),t[12]=A,t[13]=_,t[14]=j):j=t[14];let te=p?`Close separate preview window`:`Open separate preview window`,M;t[15]!==g||t[16]!==te||t[17]!==_?(M=(0,$.jsx)(h,{onClick:g,disabled:_,children:te}),t[15]=g,t[16]=te,t[17]=_,t[18]=M):M=t[18];let N=l?`Hide device toolbar`:`Show device toolbar`,ne;t[19]!==f||t[20]!==N||t[21]!==_?(ne=(0,$.jsx)(h,{onClick:f,disabled:_,children:N}),t[19]=f,t[20]=N,t[21]=_,t[22]=ne):ne=t[22];let P;t[23]===_?P=t[24]:(P=(0,$.jsx)(x,{disabled:_,children:`Appearance`}),t[23]=_,t[24]=P);let F;t[25]===n?F=t[26]:(F=e=>{n&&K.setColorScheme(n,e).catch(pt)},t[25]=n,t[26]=F);let re;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(re=at.map(ft),t[27]=re):re=t[27];let I;t[28]!==c||t[29]!==F?(I=(0,$.jsx)(s,{className:`min-w-32`,children:(0,$.jsx)(m,{value:c,onValueChange:F,children:re})}),t[28]=c,t[29]=F,t[30]=I):I=t[30];let L;t[31]!==P||t[32]!==I?(L=(0,$.jsxs)(ee,{children:[P,I]}),t[31]=P,t[32]=I,t[33]=L):L=t[33];let ie;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(r,{}),t[34]=ie):ie=t[34];let ae;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(`span`,{children:`Zoom`}),t[35]=ae):ae=t[35];let R;t[36]===b?R=t[37]:(R=b(K.zoomOut),t[36]=b,t[37]=R);let z;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(be,{}),t[38]=z):z=t[38];let B;t[39]!==R||t[40]!==_?(B=(0,$.jsx)(u,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:R,"aria-label":`Zoom out`,disabled:_,children:z}),t[39]=R,t[40]=_,t[41]=B):B=t[41];let V;t[42]===C?V=t[43]:(V=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:C}),t[42]=C,t[43]=V);let H;t[44]===b?H=t[45]:(H=b(K.zoomIn),t[44]=b,t[45]=H);let se;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(oe,{}),t[46]=se):se=t[46];let U;t[47]!==H||t[48]!==_?(U=(0,$.jsx)(u,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:H,"aria-label":`Zoom in`,disabled:_,children:se}),t[47]=H,t[48]=_,t[49]=U):U=t[49];let ce;t[50]===b?ce=t[51]:(ce=b(K.resetZoom),t[50]=b,t[51]=ce);let W;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(Ne,{}),t[52]=W):W=t[52];let le;t[53]!==ce||t[54]!==_?(le=(0,$.jsx)(u,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:ce,"aria-label":`Reset zoom`,disabled:_,children:W}),t[53]=ce,t[54]=_,t[55]=le):le=t[55];let G;t[56]!==B||t[57]!==V||t[58]!==U||t[59]!==le?(G=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[B,V,U,le]}),t[56]=B,t[57]=V,t[58]=U,t[59]=le,t[60]=G):G=t[60];let q;t[61]!==G||t[62]!==_?(q=(0,$.jsxs)(h,{closeOnClick:!1,onClick:dt,className:`justify-between`,disabled:_,children:[ae,G]}),t[61]=G,t[62]=_,t[63]=q):q=t[63];let J,ue,Y;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,$.jsx)(r,{}),ue=(0,$.jsx)(h,{onClick:lt,children:`Clear cookies`}),Y=(0,$.jsx)(h,{onClick:st,children:`Clear cache`}),t[64]=J,t[65]=ue,t[66]=Y):(J=t[64],ue=t[65],Y=t[66]);let de;return t[67]!==ne||t[68]!==L||t[69]!==q||t[70]!==O||t[71]!==j||t[72]!==M?(de=(0,$.jsxs)(d,{children:[w,(0,$.jsxs)(i,{align:`end`,sideOffset:6,className:`min-w-56`,children:[O,j,M,ne,L,ie,q,J,ue,Y]})]}),t[67]=ne,t[68]=L,t[69]=q,t[70]=O,t[71]=j,t[72]=M,t[73]=de):de=t[73],de}function st(){K.clearCache().catch(ct)}function ct(){}function lt(){K.clearCookies().catch(ut)}function ut(){}function dt(e){return e.preventDefault()}function ft(e){return(0,$.jsx)(v,{value:e.value,children:e.label},e.value)}function pt(){}function mt(){}function ht(e){return _e[e]||(e.length>0?e:`Network error`)}function gt(e){let t=(0,Q.c)(32),{url:n,code:r,description:i,onReload:a}=e,[o,s]=(0,Z.useState)(!1),c;t[0]===n?c=t[1]:(c=yt(n)??n,t[0]=n,t[1]=c);let l=c,d;t[2]===i?d=t[3]:(d=ht(i),t[2]=i,t[3]=d);let f=d,p;t[4]!==r||t[5]!==i?(p=i.length>0?i:`ERR_${Math.abs(r)||`FAILED`}`,t[4]=r,t[5]=i,t[6]=p):p=t[6];let m=p,h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(vt,{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]!==f||t[12]!==_?(v=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[_,`: `,f,`.`]}),t[11]=f,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(_t),t[18]=x):x=t[18];let S=o?`Hide details`:`Details`,C;t[19]===S?C=t[20]:(C=(0,$.jsx)(u,{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)(u,{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 _t(e){return!e}function vt(e){let t=(0,Q.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 yt(e){try{return new URL(e).host}catch{return null}}function bt(e){let t=e.toLowerCase();return t.includes(`mac`)?`Reveal in Finder`:t.includes(`win`)?`Reveal in File Explorer`:`Reveal in Files`}var xt=120,St=220,Ct=4,wt=90,Tt=.08,Et=.5;function Dt(e){let[t,n]=(0,Z.useState)(0),r=(0,Z.useRef)(0);return r.current=t,(0,Z.useEffect)(()=>{if(!e){if(r.current===0)return;n(100);let e=window.setTimeout(()=>n(0),St);return()=>window.clearTimeout(e)}n(e=>e>0&&e<95?e:Ct);let t=window.setInterval(()=>{let e=r.current;if(e>=wt)return;let t=wt-e,i=Math.max(Et,t*Tt);n(Math.min(wt,e+i))},xt);return()=>window.clearInterval(t)},[e]),t}var Ot=class extends j()(`PreviewSessionThreadKeyParseError`,{threadKey:M}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},kt=a(e=>{let t=S(e);if(t===null)throw new Ot({threadKey:e});let n=xe.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=xe.events({environmentId:t.environmentId,input:{}});return f(e=>{let i=!1,a=0,o=e=>{c(e)&&pe(t,e.value)},s=r=>{if(!c(r)||r.value.threadId!==t.threadId)return;let i=I(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}G(t,r.value)};e.addFinalizer(()=>{i=!0});let l=e.once(r);e.subscribe(n,e=>{o(e)}),e.subscribe(r,e=>{a+=1,s(e)}),queueMicrotask(()=>{i||(e.refresh(n),a===0&&s(l))})}).pipe(F(1e3),g(`preview:session-sync:${e}`))});function At(t){let n=(0,Q.c)(2),r;n[0]===t?r=n[1]:(r=kt(e(t)),n[0]=t,n[1]=r),T(r)}var jt=1500,Mt=.001;function Nt(e){let t=(0,Q.c)(11),{zoomFactor:n}=e,[r,i]=(0,Z.useState)(!1),a=(0,Z.useRef)(n),s=(0,Z.useRef)(null),c,l;t[0]===n?(c=t[1],l=t[2]):(c=()=>{if(!(Math.abs(a.current-n)<Mt))return a.current=n,i(!0),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{i(!1),s.current=null},jt),()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null)}},l=[n],t[0]=n,t[1]=c,t[2]=l),(0,Z.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=o(`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 Pt(e,t){return e?1:t===`human`?.18:.35}var Ft=700;function It(e){let t=(0,Q.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=Y(a),s;t[2]===n?s=t[3]:(s=e=>e.byTabId[n]?.content??null,t[2]=n,t[3]=s);let c=W(s);if(!o)return null;let l;return t[4]!==c||t[5]!==i||t[6]!==o||t[7]!==r?(l=(0,$.jsx)(Lt,{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 Lt(e){let t=(0,Q.c)(15),{event:n,content:r,zoomFactor:i,controller:a}=e,[o,s]=(0,Z.useState)(!0),c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=window.setTimeout(()=>s(!1),Ft);return()=>window.clearTimeout(e)},l=[],t[0]=c,t[1]=l):(c=t[0],l=t[1]),(0,Z.useEffect)(c,l);let u;t[2]!==o||t[3]!==a?(u=Pt(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)(ze,{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 Rt=typeof window>`u`?null:p();function zt({threadRef:n,tabId:r,configuredUrls:i,visible:a}){let[o,s]=(0,Z.useState)(void 0),[c,u]=(0,Z.useState)(!1),d=we(),f=(0,Z.useRef)(!1),p=(0,Z.useRef)(!0),m=De(n),h=Ie(e=>Me(e.byThreadKey,n)),g=b(e=>e.addPreviewAnnotation),_=b(e=>e.addImage),v=P(n.environmentId),y=w(n.environmentId),x=ne(xe.open),S=ne(xe.resize,`preview viewport resize`);At(n),(0,Z.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]);let C=r??m.activeTabId,T=C?ue(n,m.serverEpoch,C):null,E=C&&T?d.has(T)?T:Ee(n,C):null,D=C?m.sessions[C]??null:null,k=C?m.desktopByTabId[C]??null:null,A=D?.navStatus??{_tag:`Idle`},ee=A._tag===`Idle`?``:A.url,j=k?.loading??A._tag===`Loading`,te=k?.canGoBack??D?.canGoBack??!1,M=k?.canGoForward??D?.canGoForward??!1,N=A._tag===`Idle`,F=A._tag===`LoadFailed`,re=me(D),I=k?.controller??`none`,L=Dt(j),ie=ee&&v&&y?Je({url:ee,environmentLabel:v.label,environmentHttpBaseUrl:y})??void 0:void 0,ae=D?.viewport??l,oe=W(e=>T?e.byTabId[T]?.rect??null:null),R=(0,Z.useCallback)(async e=>{T&&K?(await K.navigate(T,e),je(n,e)):await le({openPreview:x,threadRef:n,url:e})},[x,T,n]),B=(0,Z.useCallback)(async e=>{try{await R(ke(e))}catch{}},[R]),V=(0,Z.useCallback)(async e=>{try{await R(J(n.environmentId,e))}catch{}},[R,n.environmentId]),H=(0,Z.useCallback)(()=>{K&&T&&K.refresh(T)},[T]),se=(0,Z.useCallback)(()=>{K&&T&&K.zoomIn(T)},[T]),U=(0,Z.useCallback)(()=>{K&&T&&K.zoomOut(T)},[T]),ce=(0,Z.useCallback)(()=>{K&&T&&K.resetZoom(T)},[T]),G=(0,Z.useCallback)(async e=>{if(!C)return;let r=await S({environmentId:n.environmentId,input:{threadId:n.threadId,tabId:C,viewport:e}});if(r._tag===`Failure`){let e=t(r);throw X.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}Ce(n,r.value)},[S,C,n]),Y=()=>{if(!T)return;if(ae._tag!==`fill`){Ae(T,l).catch(()=>void 0);return}let e=oe?Oe(oe,k?.zoomFactor):{width:1024,height:768};Ae(T,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Z.useEffect)(()=>{if(T)return Se(T,G)},[G,T]);let de=(0,Z.useCallback)(()=>{K&&T&&K.goBack(T)},[T]),pe=(0,Z.useCallback)(()=>{K&&T&&K.goForward(T)},[T]),he=(0,Z.useCallback)(()=>{!Rt||!ee||Rt.shell.openExternal(ee).catch(()=>void 0)},[ee]),_e=(0,Z.useCallback)(()=>{if(C){if(h?.tabId===C){Ie.getState().close(n);return}Ie.getState().open(n,C),O.getState().close(n)}},[h?.tabId,C,n]),ve=(0,Z.useCallback)(()=>{!K||!T||(k?.pictureInPicture?K.pictureInPicture.close:K.pictureInPicture.open)(T).catch(e=>{X.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[k?.pictureInPicture,T]),ye=(0,Z.useCallback)(e=>{if(!K||!T||!C)return;let t=K;if(E){q(E).then(e=>{if(!e)return;let n=!1,r,i=()=>{if(!navigator.clipboard?.writeText){X.update(r,fe({type:`error`,title:`Unable to copy recording path`,description:`Clipboard API unavailable.`,actionProps:a}));return}navigator.clipboard.writeText(e.path).then(()=>{n=!0,o(),window.setTimeout(()=>{n=!1,o()},2e3)},e=>{X.update(r,fe({type:`error`,title:`Unable to copy recording path`,description:e instanceof Error?e.message:`An error occurred.`,actionProps:a}))})},a={children:bt(navigator.platform),onClick:()=>void t.revealArtifact(e.path)},o=()=>{X.update(r,fe({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:n?`Copied!`:`Copy path`,disabled:n,onClick:i},secondaryActionVariant:`outline`}}))};r=X.add(fe({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:`Copy path`,onClick:i},secondaryActionVariant:`outline`}}))},e=>{X.add({type:`error`,title:`Unable to stop recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}if(e){ge(T,n,C).catch(e=>{X.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}t.captureScreenshot(T).then(e=>{let n={children:bt(navigator.platform),onClick:()=>void t.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,t=`Screenshot saved`,o)=>{X.update(a,fe({type:e,title:t,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:{...n},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=()=>{t.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=X.add(fe({type:`success`,title:`Screenshot saved`,actionProps:{children:`Copy image`,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:`Copy path`,onClick:s}}],secondaryActionProps:{...n},secondaryActionVariant:`outline`}}))},e=>{X.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[E,T,C,n]),be=(0,Z.useCallback)(()=>{if(!K||!T)return;if(f.current){K.cancelPickElement(T).catch(()=>void 0);return}let e=typeof document<`u`?document.activeElement:null;f.current=!0,u(!0),(async()=>{try{let e=await K.pickElement(T);if(!e)return;g(n,e);let t=await Fe(e);t&&e.screenshot&&_(n,{type:`image`,id:e.id,name:t.name,mimeType:t.type,sizeBytes:t.size,previewUrl:e.screenshot.dataUrl,file:t})}catch{}finally{if(f.current=!1,p.current&&u(!1),e&&e.isConnected&&typeof e.focus==`function`)try{e.focus({preventScroll:!0})}catch{}}})()},[_,g,T,n]);return(0,Z.useEffect)(()=>()=>{f.current&&(f.current=!1,K&&T&&K.cancelPickElement(T).catch(()=>void 0),p.current&&u(!1))},[T]),(0,Z.useEffect)(()=>{if(a)return z(e=>{switch(e){case`refresh`:H();return;case`focus-url`:s(e=>(e??0)+1);return;case`zoom-in`:se();return;case`zoom-out`:U();return;case`reset-zoom`:ce();return;case`toggle-panel`:return}})},[H,ce,se,U,a]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":e(n),children:[(0,$.jsx)(qe,{url:ee,displayUrl:ie,loading:j,loadProgress:L,canGoBack:te,canGoForward:M,refreshDisabled:N,focusUrlNonce:o,onBack:de,onForward:pe,onRefresh:H,onSubmit:e=>void B(e),onOpenInBrowser:C?he:void 0,onCapture:K&&C?ye:void 0,captureDisabled:!k||F,recording:E!==null,onPictureInPicture:K&&C?_e:void 0,pictureInPicture:h?.tabId===C,pictureInPictureDisabled:!k?.hasWebContents||F,onPickElement:K&&C?be:void 0,pickActive:c,pickDisabled:!C||F,pickDisabledReason:F?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:K?(0,$.jsx)(ot,{tabId:T,hasWebContents:k?.hasWebContents??!1,zoomFactor:k?.zoomFactor??1,colorScheme:k?.colorScheme??`system`,deviceToolbarVisible:ae._tag!==`fill`,onToggleDeviceToolbar:Y,nativePictureInPicture:k?.pictureInPicture??!1,onNativePictureInPicture:ve}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[T&&D&&!re?(0,$.jsx)(Pe,{tabId:T,visible:a&&!F,className:`absolute inset-0 h-full w-full`},T):null,re?(0,$.jsx)(it,{environmentId:n.environmentId,configuredUrls:i,recentlySeenUrls:m.recentlySeenUrls,onOpenUrl:e=>void V(e)}):null,D&&k?(0,$.jsx)(Nt,{zoomFactor:k.zoomFactor}):null,T&&k&&!re&&!F?(0,$.jsx)(It,{tabId:T,zoomFactor:k.zoomFactor,controller:I}):null,I===`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:I===`agent`?`Agent controlling browser`:`Human control`}),A._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(gt,{url:A.url,code:A.code,description:A.description,onReload:H})}):null]})]})}function Bt(e){let t=(0,Q.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!U()){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 P4Code desktop app.`})}),t[0]=e):e=t[0];let r;return t[1]===n?r=t[2]:(r=(0,$.jsx)(he,{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)(zt,{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)(he,{mode:n,children:c}),t[10]=n,t[11]=c,t[12]=l):l=t[12],l}export{Bt as PreviewPanel};
2
+ //# sourceMappingURL=PreviewPanel-Lk9ar7c8.js.map