@p4code/cli 0.1.38 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +111 -63
- package/dist/client/assets/{DiffPanel-hYmWjoUs.js → DiffPanel-C1DzsMkw.js} +2 -2
- package/dist/client/assets/{FilePreviewPanel-sn66iG-C.js → FilePreviewPanel-BV66Pov6.js} +2 -2
- package/dist/client/assets/{PreviewPanel-BwdTNeQU.js → PreviewPanel-DeGcjg8P.js} +2 -2
- package/dist/client/assets/arrow-right-BfH3g256.js +2 -0
- package/dist/client/assets/{fileCommentAnnotations-qrdl_QDz.js → fileCommentAnnotations-DoV_7-AJ.js} +2 -2
- package/dist/client/assets/{index-DYDaZ0DX.js → index-oXAJjTce.js} +18 -6
- package/dist/client/assets/{terminal-links-B2KXT7CK.js → terminal-links-CUeLECEE.js} +2 -2
- package/dist/client/index.html +2 -2
- package/package.json +1 -1
- package/dist/client/assets/arrow-right-BnQZ60ie.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$s as i,A as a,C as o,E as s,F as c,L as l,Ls as u,N as d,Nu as f,O as p,Qr as m,Rs as h,Wt as g,i as _,ic as v,in as y,u as b,un as x,w as S,ws as C,xs as ee}from"./terminal-links-B2KXT7CK.js";import{a as w,c as T,i as E,n as te,o as D,r as O,s as k,t as A}from"./fileCommentAnnotations-qrdl_QDz.js";import{Br as j,Bt as M,C as N,Cn as P,Cr as ne,D as re,Dn as ie,Dt as ae,Er as oe,Gn as F,H as se,Hr as ce,Ir as le,Jn as I,K as ue,Kn as de,Lr as fe,On as pe,Pr as me,Q as he,S as ge,Sn as _e,Sr as ve,Tn as ye,Tt as be,U as xe,V as Se,Vt as Ce,W as we,Yn as L,Zn as Te,_r as Ee,b as De,d as Oe,dn as ke,en as R,f as Ae,gr as je,hn as Me,hr as Ne,kn as Pe,kr as Fe,kt as Ie,l as Le,m as Re,mr as ze,nr as Be,p as Ve,pr as He,qn as Ue,u as We,v as Ge,vr as Ke,w as qe,wn as Je,x as Ye,xn as Xe,y as Ze,z as Qe,zr as $e}from"./index-DYDaZ0DX.js";var et=C(`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`}]]),tt=C(`file-question-mark`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),nt=C(`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`}]]),rt=`file-tree-container`,it=`data-file-tree-style`,at=`data-file-tree-unsafe-css`,z=`data-file-tree-scrollbar-measure`,B=`data-file-tree-scrollbar-gutter-measured`,ot=`--trees-scrollbar-gutter-measured`,st=`header`,ct=`context-menu`,lt=`context-menu-trigger`,ut=5,dt=1<<ut,ft=dt*4;function pt(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function mt(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function ht(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 gt(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 _t(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function vt(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 yt(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,Ct(e,t)}function bt(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=gt(e).get(t);if(i===void 0)return;let a=i>>ut;e.childVisibleChunkSums[a]+=r}function xt(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=wt(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=dt}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 St(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>ut;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<ut}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 Ct(e,t){if(t.childIds.length<ft){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/dt),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>>ut]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function wt(e,t,n,r){let i=Math.min(t.childIds.length,n+dt),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 Tt=7,Et=3,Dt=1<<Et,Ot=4;function kt(e,t,n=0){return e<<Ot|n<<Et|t}function At(e){return e.depthAndFlags>>>Ot}function jt(e){return(e.depthAndFlags&Dt)>>Et}function V(e){return(e.depthAndFlags&Dt)!==0}function Mt(e){return e.depthAndFlags&Tt}function H(e,t){return(Mt(e)&t)!==0}function Nt(e,t){e.depthAndFlags|=t}function Pt(e,t){e.depthAndFlags=kt(t,Mt(e),jt(e))}var Ft=Symbol(`benchmarkInstrumentation`);function It(e,t){return t==null||Object.defineProperty(e,Ft,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function Lt(e){return e==null?null:e[Ft]??null}function U(e,t,n){return e==null?n():e.measurePhase(t,n)}function Rt(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function zt(e){return e>=48&&e<=57}function Bt(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!zt(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&&zt(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 Vt(e){let t=e.toLowerCase();return{lowerValue:t,tokens:Bt(t)}}function Ht(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 Ut(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=Ht(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function Wt(e,t,n){let r=Ut(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function Gt(e,t){return Wt(e,t,Vt)}function Kt(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function qt(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=Kt(e,r);return a===Kt(t,r)?Gt(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 Jt(e,t){return qt(e,t)}function Yt(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=Vt(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=Kt(e,n);return o===Kt(t,n)?Wt(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 Xt(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=Vt(r);return e.sortKeyById[t]=i,i}function Zt(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function Qt(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 $t(e){let{hasTrailingSlash:t,segments:n}=Qt(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function en(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=Qt(e);return{requiresDirectory:t,segments:n}}var tn=``;function nn(){let e=new Map;return e.set(tn,0),{idByValue:e,valueById:[tn],sortKeyById:[Vt(tn)]}}function rn(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 an(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var on=Symbol(`pathStorePreparedInputKind`);function sn(e,t){return e[on]=t,e}function cn(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function ln(e,t,n){return n==="default"?Jt(e,t):n(cn(e),cn(t))}function un(){return{depthAndFlags:kt(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function dn(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 fn(e){return e.isDirectory?e.segments.length:e.segments.length-1}function pn(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 mn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function hn(e,t={}){return xn(e,t).map(e=>e.path)}function gn(e,t={}){let n=xn(e,t);return sn({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function _n(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 sn({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function vn(e){let t=e,n=t.preparedPaths;if(t[on]===`prepared`&&n!=null)return n;if(!pn(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function yn(e){let t=e;return t[on]===`presorted`&&t.presortedPaths!=null||mn(t.presortedPaths)?t.presortedPaths:null}function bn(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function xn(e,t={}){let n=Zt(t),r=Lt(t);Rt(r,`workload.inputFiles`,e.length);let i=U(r,`store.preparePathEntries.parse`,()=>e.map(e=>$t(e)));return U(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>ln(e,t,n.sort))),i}var Sn=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[un()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=nn();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=Lt(e),this.options=Zt(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,pt())}appendPaths(e){return U(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>$t(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,U(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return U(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:kt(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:kt(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:kt(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=$t(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:kt(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:kt(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=$t(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(U(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||U(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"?Yt(this.lastPreparedPath,e,this.segmentSortKeyCache):ln(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=fn(e),i=n==null?0:fn(n),a=n==null?0:dn(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=rn(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:kt(At(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),_t(i,s),s}createFileChildUnchecked(e,t){let n=rn(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:kt(At(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),_t(r,a),a}getOrCreateDirectoryChild(e,t){let n=rn(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let e=r.childIdByNameId.get(n);if(e!==void 0){let n=this.nodes[e];if(n!=null&&!V(n))throw Error(`Path collides with an existing file while creating directory "${t}"`);return e}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:kt(At(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),_t(r,a),this.directories.set(a,pt()),a}createDirectoryChild(e,t){let n=rn(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:kt(At(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),_t(r,a),this.directories.set(a,pt()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!V(n))throw Error(`Path is not a directory: "${t}"`);if(H(n,1))throw Error(`Duplicate path: "${t}"`);Nt(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,mt());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(V(a)){let t=mt();n.set(e,t),r=e,i=t}let o;a.parentId===r?o=i:(o=n.get(a.parentId),r=a.parentId,i=o??null),o?.childIds.push(e)}if(!e)for(let e=t.length-1;e>=1;e--){let n=t[e];if(n==null)continue;let r=t[n.parentId];r!=null&&(r.subtreeNodeCount+=n.subtreeNodeCount,r.visibleSubtreeCount+=n.visibleSubtreeCount)}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;V(n)&&this.directories.set(t,pt());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),_t(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!V(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let e of n.childIds)r+=this.computeSubtreeCounts(e);return yt(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function Cn(e,t=`closed`,n=null){let r=Tn(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 wn(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function Tn(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 En(e,t){return H(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion===`closed`?!1:At(t)<=e.defaultExpansion}function Dn(e,t,n=e.snapshot.nodes[t]){return n==null||!V(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:En(e,n)}function On(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!V(r))return;let i=En(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 kn(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 An(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function jn(e,t){let n=kn(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 Mn(e,t){let n=kn(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function Nn(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 Pn(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Fn(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 In(e,t){e.directoryLoadInfoById.delete(t)}function Ln(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 Rn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function zn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function Bn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function Vn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Hn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Un(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Wn(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 Gn(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 Kn(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 qn(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 Jn(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 Yn(e,t,n){return{...n,visibleCountDelta:or(e)-t}}function Xn(e,t){let n=or(e),r=wn();e.transactionStack.push(r);try{t()}catch(t){throw $n(e,r,!1),t}$n(e,r,!0,or(e)-n)}function Zn(e,t){let n=e.instrumentation;if(n==null){Qn(e,t);return}U(n,`store.events.record`,()=>Qn(e,t))}function Qn(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){ir(e,t);return}n.events.push(t),rr(n,t)}function $n(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?nr(i,t):U(n,`store.events.batch.merge`,()=>nr(i,t));return}let a=er(t,r),o=e.instrumentation;if(o==null){ir(e,a);return}U(o,`store.events.batch.commit`,()=>ir(e,a))}function er(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 tr(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function nr(e,t){for(let n of t.events)e.events.push(n);tr(e,t)}function rr(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function ir(e,t){let n=e.instrumentation;if(n==null){ar(e,t);return}U(n,`store.events.emit`,()=>ar(e,t))}function ar(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function or(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function sr(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!V(n)||H(n,2))return null;let r=e.snapshot.directories.get(t);if(r==null||r.childIds.length!==1)return null;let i=r.childIds[0];if(i==null)return null;let a=e.snapshot.nodes[i];return a==null||!V(a)?null:i}function cr(e,t){let n=t;for(;;){let t=sr(e,n);if(t==null)return n;n=t}}function lr(e,t){let n=[t],r=t;for(;;){let t=sr(e,r);if(t==null)return n;n.push(t),r=t}}function ur(e,t){let n=t==null?e.snapshot.rootId:yr(e,t);return n==null?[]:xr(e,n)}function dr(e,t){let n=$t(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Ir(e,Fr(e,r)),{createdNodeIds:a,directoryId:o}=Sr(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=K(e,o);if(H(n,1))throw Error(`Path already exists: "${t}"`);Nt(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=wr(e,o,n.basename),s.add(c);gr(e,o);let l=Ir(e,o);return Rn({affectedAncestorIds:vr(e,c),affectedNodeIds:[...s],path:t,projectionChanged:Lr(i,l)})}function fr(e,t,n){let r=yr(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=K(e,r);if(H(i,2))throw Error(`The root node cannot be removed`);if(V(i)&&G(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=Ir(e,a),s=Nr(e,r);Dr(e,a,r,i.nameId),Pr(e,a),gr(e,a);let c=Ir(e,a);return zn({affectedAncestorIds:vr(e,a),affectedNodeIds:s,path:t,projectionChanged:Lr(o,c),recursive:n.recursive===!0})}function pr(e,t,n,r){let i=yr(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=K(e,i);if(H(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=jr(e,i,n),c=Ir(e,a.parentId),l=Ir(e,s.parentId),u=an(e.snapshot.segmentTable,a.nameId),d=rn(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(V(a)&&Vr(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=ht(e.snapshot.nodes,G(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&Mr(e,p,o,jt(a))===`skip`)return null;let m=a.parentId;Dr(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),Br(e,i),Er(e,s.parentId,i),Pr(e,m),e.pathCacheVersion++,gr(e,m),s.parentId!==m&&gr(e,s.parentId);let h=Ir(e,m),g=Ir(e,s.parentId);return Bn({affectedAncestorIds:[...new Set([...vr(e,m),...vr(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:Rr([c,l],[h,g]),to:W(e,i)})}function mr(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function hr(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function W(e,t){let n=K(e,t),r=mr(e,t);if(r!=null)return r;if(H(n,2))return hr(e,t,``);let i=W(e,n.parentId),a=an(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return hr(e,t,V(n)?`${o}/`:o)}function gr(e,t){let n=e.instrumentation;if(n==null){Ur(e,t);return}U(n,`store.recomputeCountsUpwardFrom`,()=>Ur(e,t))}function _r(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;for(;n.length>0;){let t=n[n.length-1],a=t[0],o=r[a];if(o==null||!V(o)){Hr(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){Hr(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function vr(e,t){let n=[],r=t;for(;r!=null;){let t=K(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function yr(e,t){if(t.length===0)return e.snapshot.rootId;let n=en(t);return br(e,n.segments,n.requiresDirectory)}function br(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=G(e,r),a=ht(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=K(e,r);return n&&!V(i)?null:r}function G(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 K(e,t){let n=e.snapshot.nodes[t];if(n===void 0||H(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function xr(e,t){let n=e.snapshot.nodes[t];if(n===void 0||H(n,4))return[];if(!V(n))return[W(e,t)];if(G(e,t).childIds.length===0)return H(n,1)&&!H(n,2)?[W(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||H(n,4)){i.pop();continue}if(!V(n)){r.push(W(e,t.nodeId)),i.pop();continue}let a=G(e,t.nodeId);if(a.childIds.length===0){H(n,1)&&!H(n,2)&&r.push(W(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 Sr(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=rn(e.snapshot.segmentTable,i),a=G(e,r),o=ht(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!V(K(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=Cr(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function Cr(e,t,n){let r=K(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:kt(At(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,pt()),Er(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function wr(e,t,n){let r=rn(e.snapshot.segmentTable,n),i=G(e,t);if(ht(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${Gr(e,t,n)}"`);let a=K(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:kt(At(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),Er(e,t,o),e.activeNodeCount++,o}function Tr(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}Or(e,n,o)<0?i=a:r=a+1}return r}function Er(e,t,n){let r=G(e,t),i=K(e,n);ht(e.snapshot.nodes,r).set(i.nameId,n),bt(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=Tr(e,r,n);r.childIds.splice(a,0,n),vt(r,a),Ct(e.snapshot.nodes,r)}function Dr(e,t,n,r){let i=G(e,t),a=gt(i),o=a.get(n)??-1;ht(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&bt(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),vt(i,o),Ct(e.snapshot.nodes,i))}function Or(e,t,n){let r=e.snapshot.options.sort;return r==="default"?kr(e,t,n):r(Ar(e,t),Ar(e,n))}function kr(e,t,n){let r=K(e,t),i=K(e,n),a=V(r);if(a!==V(i))return a?-1:1;let o=Ut(Xt(e.snapshot.segmentTable,r.nameId),Xt(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=an(e.snapshot.segmentTable,r.nameId),c=an(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function Ar(e,t){let n=K(e,t),r=W(e,t),i=V(n),a=i?r.slice(0,-1):r;return{basename:an(e.snapshot.segmentTable,n.nameId),depth:At(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function jr(e,t,n){let r=K(e,t),i=yr(e,n);if(i!=null){let t=K(e,i);if(V(t))return{basename:an(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=en(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=en(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:br(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function Mr(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${W(e,t)}"`);let i=K(e,t);if(jt(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(V(i)&&G(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return Nr(e,t),Dr(e,a,t,o),Pr(e,a),gr(e,a),`handled`}function Nr(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=K(e,t.nodeId);if(t.visitedChildren||!V(i)){V(i)&&e.snapshot.directories.delete(t.nodeId),Nt(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),In(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=G(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 Pr(e,t){let n=t;for(;n!=null;){let t=K(e,n);if(!V(t)||H(t,2)||G(e,n).childIds.length>0)return;Nt(t,1),n=t.parentId===n?null:t.parentId}}function Fr(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=ht(e.snapshot.nodes,G(e,n)).get(t);if(i==null||!V(K(e,i)))break;n=i}return n}function Ir(e,t){let n=zr(e,t);if(n==null)return null;let r=cr(e,n),i=K(e,r),a=n===r?null:lr(e,n).map(t=>W(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:G(e,r).childIds.length>0,path:W(e,r),terminalKind:jt(i)})}function Lr(e,t){return Rr([e],[t])}function Rr(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 zr(e,t){let n=t;for(;n!=null;){let t=K(e,n);if(!V(t)||H(t,2))return null;if(!Dn(e,n,t))return n;n=t.parentId}return null}function Br(e,t){let n=K(e,t);if(Pt(n,(t===e.snapshot.rootId?-1:At(K(e,n.parentId)))+1),!V(n))return;let r=G(e,t);for(let t of r.childIds)Br(e,t)}function Vr(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=K(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function Hr(e,t,n=K(e,t),r=!1){let i=e.instrumentation;if(i==null){Wr(e,t,n,r);return}U(i,`store.recomputeNodeCounts`,()=>Wr(e,t,n,r))}function Ur(e,t){let n=t;for(;n!=null;){let t=K(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(Hr(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&bt(G(e,s),n,a,o),n=s}}function Wr(e,t,n,r){if(!V(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=G(e,t);if(r){let t=e.instrumentation;t==null?yt(e.snapshot.nodes,i):U(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>yt(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,H(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=sr(e,t)==null?Dn(e,t,n)?1+o:1:o}function Gr(e,t,n){let r=W(e,t);return r.length===0?n:`${r}${n}`}function Kr(e){return e!=null&&!H(e,4)}function qr(e,t){let n=e.snapshot.nodes[t];return!Kr(n)||!V(n)||H(n,2)?null:n}function Jr(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&Kr(e.snapshot.nodes[n])&&(t+=1);return t}function Yr(e){return Math.max(0,e.valueById.length-1)}function Xr(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:Jr(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:Yr(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function Zr(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 Qr(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)qr(e,n)!=null&&t.push(W(e,n));for(let t of e.expandedDirectoryIds)qr(e,t)!=null&&n.push(W(e,t));return{collapsedPaths:t,expandedPaths:n}}function $r(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)qr(e,n)==null||An(e,n)===`loaded`||t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:W(e,n)});return t}function ei(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=yr(e,n);t!=null&&On(e,t,!0,K(e,t))}for(let n of t.collapsedPaths){let t=yr(e,n);t!=null&&On(e,t,!1,K(e,t))}}function ti(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=yr(e,n.path);t!=null&&qr(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function ni(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function ri(e){let t=e.snapshot.segmentTable,n=nn();for(let r of e.snapshot.nodes)if(Kr(r)){if(H(r,2)){r.nameId=0;continue}r.nameId=rn(n,an(t,r.nameId))}e.snapshot.segmentTable=n}function ii(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!Kr(r)||!V(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return Kr(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[K(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),yt(e.snapshot.nodes,n)}}function ai(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(Kr(n))break;--t}e.snapshot.nodes.length=t+1}function oi(e){let t=Qr(e),n=$r(e);U(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>ni(e)),U(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>ri(e)),U(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>ii(e)),U(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>ai(e)),U(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>ei(e,t)),U(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>ti(e,n)),U(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>_r(e,e.snapshot.rootId))}function si(e){let t=Qr(e),n=$r(e),r=U(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>ur(e)),i=It({...e.snapshot.options},e.instrumentation),a=U(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new Sn(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,U(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>ei(e,t)),U(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>ti(e,n)),U(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>_r(e,e.snapshot.rootId))}function ci(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function li(e,t){let n=Xr(e);t===`stable`?U(e.instrumentation,`store.cleanup.stable`,()=>oi(e)):U(e.instrumentation,`store.cleanup.aggressive`,()=>si(e));let r=Xr(e);return Zr(t,t===`stable`,n,r)}var ui=64;function di(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 fi(e){return K(e,e.snapshot.rootId).visibleSubtreeCount}function pi(e,t,n,r){let i=K(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function mi(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:Ni(e,t.cursor),setSize:t.setSize,subtreeEndIndex:pi(e,t.cursor,t.index,n)}}function hi(e,t,n,r,i,a){let o=G(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=xt(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return gi(e,u,l,r+c,i+1,s,o.childIds.length,a)}function gi(e,t,n,r,i,a,o,s){if(!V(K(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=Di(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=K(e,c.terminalNodeId);if(!V(l)||!Dn(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return hi(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function _i(e,t){let n=fi(e);if(t<0||t>=n)return null;let r=hi(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>W(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=mi(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:Ni(e,r.cursor),setSize:r.setSize,subtreeEndIndex:pi(e,r.cursor,r.index,n)}}function vi(e,t,n){let r=e.instrumentation,i=fi(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 Mi(e,o+1);let t=[],n=wi(e,a);for(let r=a;r<=o&&n!=null;r++){let r=Ni(e,n);t.push(r),n=ki(e,n)}return t}let s=[],c=0,l=0,u=U(r,`store.getVisibleSlice.selectFirstRow`,()=>wi(e,a));for(let t=a;t<=o&&u!=null;t++){let t=U(r,`store.getVisibleSlice.materializeRow`,()=>Ni(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=U(r,`store.getVisibleSlice.advanceCursor`,()=>ki(e,u))}return Rt(r,`workload.visibleRowsRead`,s.length),Rt(r,`workload.flattenedRowsRead`,c),Rt(r,`workload.flattenedSegmentsRead`,l),s}function yi(e,t=fi(e)){let n=e.instrumentation;return n==null?ji(e,t):U(n,`store.getVisibleTreeProjection`,()=>ji(e,t))}function bi(e){return Ai(yi(e))}function xi(e,t){let n=yr(e,t);if(n==null||n===e.snapshot.rootId||V(K(e,n))&&cr(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=K(e,i).parentId,n=G(e,t),s=gt(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=St(a,n,s),t!==o){let n=K(e,t),a=sr(e,t);if(!Dn(e,t,n)&&a!==i)return null;cr(e,t)===t&&(r+=1)}i=t}return r}function Si(e,t){let n=yr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=K(e,n);if(!V(r))throw Error(`Path is not a directory: "${t}"`);return Dn(e,n,r)?null:(On(e,n,!0,r),gr(e,n),Vn({affectedAncestorIds:vr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function Ci(e,t){let n=yr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=K(e,n);if(!V(r))throw Error(`Path is not a directory: "${t}"`);return Dn(e,n,r)?(On(e,n,!1,r),gr(e,n),Hn({affectedAncestorIds:vr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function wi(e,t){return t<0||t>=fi(e)?null:Ti(e,e.snapshot.rootId,t,-1)}function Ti(e,t,n,r){let i=G(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?xt(e.snapshot.nodes,i,n):U(a,`store.getVisibleSlice.selectChildIndex`,()=>xt(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return Ei(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Ei(e,t,n,r){if(!V(K(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=Di(e,t,r);if(n===0)return i;let a=K(e,i.terminalNodeId);if(!V(a)||!Dn(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Ti(e,i.terminalNodeId,n-1,i.visibleDepth)}function Di(e,t,n){return V(K(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:cr(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:U(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>cr(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function Oi(e,t){let n=K(e,t);if(!V(n))return!0;let r=n.parentId;return r===e.snapshot.rootId?!0:sr(e,r)!==t}function ki(e,t){let n=K(e,t.terminalNodeId);if(V(n)){let r=G(e,t.terminalNodeId);if(Dn(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:Ei(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=K(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=G(e,n),o=gt(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 Ei(e,s,0,i);Oi(e,r)&&i--,r=n}}function Ai(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 ji(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(ui);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=di(o,y);let x,S=_;if(V(v))S=f?cr(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:W(e,S);else{let e=p.get(_);x=e!=null&&e.version===m?e.path:`${b}${h[v.nameId]}`}r[s]=o[y],n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let C=c[S];C!=null&&V(C)&&Dn(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 Mi(e,t){let n=Array(t),r=0,{nodes:i,directories:a,segmentTable:o}=e.snapshot,s=[[a.get(e.snapshot.rootId),0,-1]],c=o.valueById,l=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,d=e.pathCacheVersion;for(;s.length>0&&r<t;){let t=s[s.length-1],o=t[0];if(t[1]>=o.childIds.length){s.pop();continue}let f=o.childIds[t[1]++],p=i[f],m=t[2]+1;if(!V(p)){let t=u.get(f);n[r++]={depth:m,flattenedSegments:void 0,hasChildren:!1,id:f,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:`file`,loadState:void 0,name:c[p.nameId],path:t!=null&&t.version===d?t.path:W(e,f)};continue}let h=l?cr(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=Ni(e,g);let _=i[h];_!=null&&V(_)&&Dn(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function Ni(e,t){let n=K(e,t.terminalNodeId),r=V(n)?Pi(e,t):null,i=W(e,t.terminalNodeId),a=an(e.snapshot.segmentTable,n.nameId),o=V(n)&&G(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?lr(e,t.headNodeId).map(n=>{let r=K(e,n);return{isTerminal:n===t.terminalNodeId,name:an(e.snapshot.segmentTable,r.nameId),nodeId:n,path:W(e,n)}}):U(c,`store.getVisibleSlice.flatten.collectSegments`,()=>lr(e,t.headNodeId).map(n=>{let r=K(e,n);return{isTerminal:n===t.terminalNodeId,name:an(e.snapshot.segmentTable,r.nameId),nodeId:n,path:W(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:V(n)&&Dn(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:V(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function Pi(e,t){if(t.headNodeId===t.terminalNodeId)return An(e,t.terminalNodeId);let n=lr(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=An(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}function Fi(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:a}=e.snapshot,o=r.flattenEmptyDirectories===!0,s=e=>{let r=n[e];if(r==null||!V(r))return;let i=t.get(e);if(i==null)throw Error(`Unknown directory child index for node ${String(e)}`);let a=i.childIds,s=a.length,c=0,l=0;for(let e=0;e<s;e++){let t=a[e];if(t==null)continue;let r=n[t];c+=r.subtreeNodeCount,l+=r.visibleSubtreeCount}i.totalChildSubtreeNodeCount=c,i.totalChildVisibleSubtreeCount=l,s>=128&&Ct(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&V(e)?l:1+l}else u=1+l;r.visibleSubtreeCount=u};if(a!=null)for(let e=a.length-1;e>=0;e--)s(a[e]);else for(let e=n.length-1;e>=1;e--)s(e);let c=n[i],l=t.get(i);if(c==null||l==null)return;let u=l.childIds,d=0,f=0;for(let e=0;e<u.length;e++){let t=u[e];if(t==null)continue;let r=n[t];d+=r.subtreeNodeCount,f+=r.visibleSubtreeCount}l.totalChildSubtreeNodeCount=d,l.totalChildVisibleSubtreeCount=f,Ct(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Ii(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var Li=class e{#e;constructor(e={}){let t=Lt(e),n=U(t,`store.builder.create`,()=>new Sn(e));if(e.preparedInput!=null){let t=yn(e.preparedInput);t==null?n.appendPreparedPaths(vn(e.preparedInput),!1):n.appendPresortedPaths(t,bn(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(U(t,`store.preparePathEntries`,()=>xn(r,e)))}let r=U(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=U(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=U(t,`store.state.create`,()=>Cn(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:U(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||Ii(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&U(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?U(t,`store.state.initializeOpenVisibleCounts`,()=>Fi(this.#e)):U(t,`store.state.recomputeCounts`,()=>_r(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return hn(e,t)}static prepareInput(e,t={}){return gn(e,t)}static preparePresortedInput(e){return _n(e)}list(e){return U(this.#e.instrumentation,`store.list`,()=>ur(this.#e,e))}add(e){U(this.#e.instrumentation,`store.add`,()=>{let t=fi(this.#e);Zn(this.#e,Yn(this.#e,t,dr(this.#e,e)))})}remove(e,t={}){U(this.#e.instrumentation,`store.remove`,()=>{let n=fi(this.#e);Zn(this.#e,Yn(this.#e,n,fr(this.#e,e,t)))})}move(e,t,n={}){U(this.#e.instrumentation,`store.move`,()=>{let r=fi(this.#e),i=pr(this.#e,e,t,n);i!=null&&Zn(this.#e,Yn(this.#e,r,i))})}batch(e){Xn(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 U(this.#e.instrumentation,`store.getVisibleCount`,()=>fi(this.#e))}getVisibleSlice(e,t){return U(this.#e.instrumentation,`store.getVisibleSlice`,()=>vi(this.#e,e,t))}getVisibleRowContext(e){return U(this.#e.instrumentation,`store.getVisibleRowContext`,()=>_i(this.#e,e))}getVisibleTreeProjection(){return bi(this.#e)}getVisibleTreeProjectionData(e){return yi(this.#e,e)}getVisibleIndex(e){return U(this.#e.instrumentation,`store.getVisibleIndex`,()=>xi(this.#e,e))}getPathInfo(e){return U(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=yr(this.#e,e);if(t==null)return null;let n=K(this.#e,t);return{depth:At(n),kind:V(n)?`directory`:`file`,path:W(this.#e,t)}})}isExpanded(e){return U(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=K(this.#e,t);return Dn(this.#e,t,n)})}expand(e){U(this.#e.instrumentation,`store.expand`,()=>{let t=fi(this.#e),n=Si(this.#e,e);n!=null&&Zn(this.#e,Yn(this.#e,t,n))})}collapse(e){U(this.#e.instrumentation,`store.collapse`,()=>{let t=fi(this.#e),n=Ci(this.#e,e);n!=null&&Zn(this.#e,Yn(this.#e,t,n))})}on(e,t){return Ln(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return An(this.#e,t)}markDirectoryUnloaded(e){U(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(G(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=fi(this.#e);Mn(this.#e,t),Zn(this.#e,Yn(this.#e,n,Un({affectedAncestorIds:vr(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return U(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=fi(this.#e),r=jn(this.#e,t);return Zn(this.#e,Yn(this.#e,n,Wn({affectedAncestorIds:vr(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return U(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||An(this.#e,n)!==`loading`||!Pn(this.#e,n,e.attemptId))return!1;let r=W(this.#e,n);this.validateChildPatch(r,t);let i=fi(this.#e),a=[];for(let e of t.operations){Ri(r,e);let t=fi(this.#e);switch(e.type){case`add`:a.push(Yn(this.#e,t,dr(this.#e,e.path)));break;case`remove`:a.push(Yn(this.#e,t,fr(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=pr(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(Yn(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return Zn(this.#e,Yn(this.#e,i,Gn({affectedAncestorIds:vr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:W(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return U(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=fi(this.#e),r=Nn(this.#e,t,e.attemptId);return Zn(this.#e,Yn(this.#e,n,Kn({affectedAncestorIds:vr(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:W(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return U(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=fi(this.#e),i=Fn(this.#e,n,e.attemptId,t);return Zn(this.#e,Yn(this.#e,r,qn({affectedAncestorIds:vr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:W(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return U(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(ci(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=fi(this.#e),n=li(this.#e,e.mode??`stable`);return Zn(this.#e,Yn(this.#e,t,Jn({...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=G(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??Vt(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=Ut(Xt(o,t.nameId),b);if(r>0||r===0&&n>a)return!1}return!1};if(!x(_,f.length)&&_>0&&x(0,_),y===void 0){h=!1;break}if(!V(K(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=K(this.#e,n);Dn(this.#e,n,i)||(On(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=K(this.#e,e);if(!Dn(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=yr(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!V(K(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!V(K(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=K(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=K(this.#e,e),r=sr(this.#e,e);if(!Dn(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 Ri(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 zi={compact:{itemHeight:24,factor:.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function Bi(e,t){if(typeof e==`number`)return{itemHeight:t??zi.default.itemHeight,factor:e};let n=zi[e??`default`];return{itemHeight:t??n.itemHeight,factor:n.factor}}var Vi=zi.default.itemHeight,Hi=`@layer base, theme, unsafe;
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$s as i,A as a,C as o,E as s,F as c,L as l,Ls as u,N as d,Nu as f,O as p,Qr as m,Rs as h,Wt as g,i as _,ic as v,in as y,u as b,un as x,w as S,ws as C,xs as ee}from"./terminal-links-CUeLECEE.js";import{a as w,c as T,i as E,n as te,o as D,r as O,s as k,t as A}from"./fileCommentAnnotations-DoV_7-AJ.js";import{Br as j,Bt as M,C as N,Cn as P,Cr as ne,D as re,Dn as ie,Dt as ae,Er as oe,Gn as F,H as se,Hr as ce,Ir as le,Jn as I,K as ue,Kn as de,Lr as fe,On as pe,Pr as me,Q as he,S as ge,Sn as _e,Sr as ve,Tn as ye,Tt as be,U as xe,V as Se,Vt as Ce,W as we,Yn as L,Zn as Te,_r as Ee,b as De,d as Oe,dn as ke,en as R,f as Ae,gr as je,hn as Me,hr as Ne,kn as Pe,kr as Fe,kt as Ie,l as Le,m as Re,mr as ze,nr as Be,p as Ve,pr as He,qn as Ue,u as We,v as Ge,vr as Ke,w as qe,wn as Je,x as Ye,xn as Xe,y as Ze,z as Qe,zr as $e}from"./index-oXAJjTce.js";var et=C(`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`}]]),tt=C(`file-question-mark`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),nt=C(`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`}]]),rt=`file-tree-container`,it=`data-file-tree-style`,at=`data-file-tree-unsafe-css`,z=`data-file-tree-scrollbar-measure`,B=`data-file-tree-scrollbar-gutter-measured`,ot=`--trees-scrollbar-gutter-measured`,st=`header`,ct=`context-menu`,lt=`context-menu-trigger`,ut=5,dt=1<<ut,ft=dt*4;function pt(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function mt(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function ht(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 gt(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 _t(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function vt(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 yt(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,Ct(e,t)}function bt(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=gt(e).get(t);if(i===void 0)return;let a=i>>ut;e.childVisibleChunkSums[a]+=r}function xt(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=wt(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=dt}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 St(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>ut;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<ut}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 Ct(e,t){if(t.childIds.length<ft){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/dt),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>>ut]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function wt(e,t,n,r){let i=Math.min(t.childIds.length,n+dt),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 Tt=7,Et=3,Dt=1<<Et,Ot=4;function kt(e,t,n=0){return e<<Ot|n<<Et|t}function At(e){return e.depthAndFlags>>>Ot}function jt(e){return(e.depthAndFlags&Dt)>>Et}function V(e){return(e.depthAndFlags&Dt)!==0}function Mt(e){return e.depthAndFlags&Tt}function H(e,t){return(Mt(e)&t)!==0}function Nt(e,t){e.depthAndFlags|=t}function Pt(e,t){e.depthAndFlags=kt(t,Mt(e),jt(e))}var Ft=Symbol(`benchmarkInstrumentation`);function It(e,t){return t==null||Object.defineProperty(e,Ft,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function Lt(e){return e==null?null:e[Ft]??null}function U(e,t,n){return e==null?n():e.measurePhase(t,n)}function Rt(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function zt(e){return e>=48&&e<=57}function Bt(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!zt(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&&zt(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 Vt(e){let t=e.toLowerCase();return{lowerValue:t,tokens:Bt(t)}}function Ht(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 Ut(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=Ht(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function Wt(e,t,n){let r=Ut(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function Gt(e,t){return Wt(e,t,Vt)}function Kt(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function qt(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=Kt(e,r);return a===Kt(t,r)?Gt(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 Jt(e,t){return qt(e,t)}function Yt(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=Vt(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=Kt(e,n);return o===Kt(t,n)?Wt(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 Xt(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=Vt(r);return e.sortKeyById[t]=i,i}function Zt(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function Qt(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 $t(e){let{hasTrailingSlash:t,segments:n}=Qt(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function en(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=Qt(e);return{requiresDirectory:t,segments:n}}var tn=``;function nn(){let e=new Map;return e.set(tn,0),{idByValue:e,valueById:[tn],sortKeyById:[Vt(tn)]}}function rn(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 an(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var on=Symbol(`pathStorePreparedInputKind`);function sn(e,t){return e[on]=t,e}function cn(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function ln(e,t,n){return n==="default"?Jt(e,t):n(cn(e),cn(t))}function un(){return{depthAndFlags:kt(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function dn(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 fn(e){return e.isDirectory?e.segments.length:e.segments.length-1}function pn(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 mn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function hn(e,t={}){return xn(e,t).map(e=>e.path)}function gn(e,t={}){let n=xn(e,t);return sn({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function _n(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 sn({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function vn(e){let t=e,n=t.preparedPaths;if(t[on]===`prepared`&&n!=null)return n;if(!pn(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function yn(e){let t=e;return t[on]===`presorted`&&t.presortedPaths!=null||mn(t.presortedPaths)?t.presortedPaths:null}function bn(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function xn(e,t={}){let n=Zt(t),r=Lt(t);Rt(r,`workload.inputFiles`,e.length);let i=U(r,`store.preparePathEntries.parse`,()=>e.map(e=>$t(e)));return U(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>ln(e,t,n.sort))),i}var Sn=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[un()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=nn();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=Lt(e),this.options=Zt(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,pt())}appendPaths(e){return U(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>$t(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,U(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return U(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:kt(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:kt(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:kt(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=$t(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:kt(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:kt(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=$t(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(U(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||U(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"?Yt(this.lastPreparedPath,e,this.segmentSortKeyCache):ln(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=fn(e),i=n==null?0:fn(n),a=n==null?0:dn(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=rn(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:kt(At(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),_t(i,s),s}createFileChildUnchecked(e,t){let n=rn(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:kt(At(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),_t(r,a),a}getOrCreateDirectoryChild(e,t){let n=rn(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let e=r.childIdByNameId.get(n);if(e!==void 0){let n=this.nodes[e];if(n!=null&&!V(n))throw Error(`Path collides with an existing file while creating directory "${t}"`);return e}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:kt(At(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),_t(r,a),this.directories.set(a,pt()),a}createDirectoryChild(e,t){let n=rn(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:kt(At(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),_t(r,a),this.directories.set(a,pt()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!V(n))throw Error(`Path is not a directory: "${t}"`);if(H(n,1))throw Error(`Duplicate path: "${t}"`);Nt(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,mt());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(V(a)){let t=mt();n.set(e,t),r=e,i=t}let o;a.parentId===r?o=i:(o=n.get(a.parentId),r=a.parentId,i=o??null),o?.childIds.push(e)}if(!e)for(let e=t.length-1;e>=1;e--){let n=t[e];if(n==null)continue;let r=t[n.parentId];r!=null&&(r.subtreeNodeCount+=n.subtreeNodeCount,r.visibleSubtreeCount+=n.visibleSubtreeCount)}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;V(n)&&this.directories.set(t,pt());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),_t(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!V(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let e of n.childIds)r+=this.computeSubtreeCounts(e);return yt(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function Cn(e,t=`closed`,n=null){let r=Tn(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 wn(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function Tn(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 En(e,t){return H(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion===`closed`?!1:At(t)<=e.defaultExpansion}function Dn(e,t,n=e.snapshot.nodes[t]){return n==null||!V(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:En(e,n)}function On(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!V(r))return;let i=En(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 kn(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 An(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function jn(e,t){let n=kn(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 Mn(e,t){let n=kn(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function Nn(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 Pn(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Fn(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 In(e,t){e.directoryLoadInfoById.delete(t)}function Ln(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 Rn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function zn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function Bn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function Vn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Hn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Un(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Wn(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 Gn(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 Kn(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 qn(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 Jn(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 Yn(e,t,n){return{...n,visibleCountDelta:or(e)-t}}function Xn(e,t){let n=or(e),r=wn();e.transactionStack.push(r);try{t()}catch(t){throw $n(e,r,!1),t}$n(e,r,!0,or(e)-n)}function Zn(e,t){let n=e.instrumentation;if(n==null){Qn(e,t);return}U(n,`store.events.record`,()=>Qn(e,t))}function Qn(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){ir(e,t);return}n.events.push(t),rr(n,t)}function $n(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?nr(i,t):U(n,`store.events.batch.merge`,()=>nr(i,t));return}let a=er(t,r),o=e.instrumentation;if(o==null){ir(e,a);return}U(o,`store.events.batch.commit`,()=>ir(e,a))}function er(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 tr(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function nr(e,t){for(let n of t.events)e.events.push(n);tr(e,t)}function rr(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function ir(e,t){let n=e.instrumentation;if(n==null){ar(e,t);return}U(n,`store.events.emit`,()=>ar(e,t))}function ar(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function or(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function sr(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!V(n)||H(n,2))return null;let r=e.snapshot.directories.get(t);if(r==null||r.childIds.length!==1)return null;let i=r.childIds[0];if(i==null)return null;let a=e.snapshot.nodes[i];return a==null||!V(a)?null:i}function cr(e,t){let n=t;for(;;){let t=sr(e,n);if(t==null)return n;n=t}}function lr(e,t){let n=[t],r=t;for(;;){let t=sr(e,r);if(t==null)return n;n.push(t),r=t}}function ur(e,t){let n=t==null?e.snapshot.rootId:yr(e,t);return n==null?[]:xr(e,n)}function dr(e,t){let n=$t(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Ir(e,Fr(e,r)),{createdNodeIds:a,directoryId:o}=Sr(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=K(e,o);if(H(n,1))throw Error(`Path already exists: "${t}"`);Nt(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=wr(e,o,n.basename),s.add(c);gr(e,o);let l=Ir(e,o);return Rn({affectedAncestorIds:vr(e,c),affectedNodeIds:[...s],path:t,projectionChanged:Lr(i,l)})}function fr(e,t,n){let r=yr(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=K(e,r);if(H(i,2))throw Error(`The root node cannot be removed`);if(V(i)&&G(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=Ir(e,a),s=Nr(e,r);Dr(e,a,r,i.nameId),Pr(e,a),gr(e,a);let c=Ir(e,a);return zn({affectedAncestorIds:vr(e,a),affectedNodeIds:s,path:t,projectionChanged:Lr(o,c),recursive:n.recursive===!0})}function pr(e,t,n,r){let i=yr(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=K(e,i);if(H(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=jr(e,i,n),c=Ir(e,a.parentId),l=Ir(e,s.parentId),u=an(e.snapshot.segmentTable,a.nameId),d=rn(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(V(a)&&Vr(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=ht(e.snapshot.nodes,G(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&Mr(e,p,o,jt(a))===`skip`)return null;let m=a.parentId;Dr(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),Br(e,i),Er(e,s.parentId,i),Pr(e,m),e.pathCacheVersion++,gr(e,m),s.parentId!==m&&gr(e,s.parentId);let h=Ir(e,m),g=Ir(e,s.parentId);return Bn({affectedAncestorIds:[...new Set([...vr(e,m),...vr(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:Rr([c,l],[h,g]),to:W(e,i)})}function mr(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function hr(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function W(e,t){let n=K(e,t),r=mr(e,t);if(r!=null)return r;if(H(n,2))return hr(e,t,``);let i=W(e,n.parentId),a=an(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return hr(e,t,V(n)?`${o}/`:o)}function gr(e,t){let n=e.instrumentation;if(n==null){Ur(e,t);return}U(n,`store.recomputeCountsUpwardFrom`,()=>Ur(e,t))}function _r(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;for(;n.length>0;){let t=n[n.length-1],a=t[0],o=r[a];if(o==null||!V(o)){Hr(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){Hr(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function vr(e,t){let n=[],r=t;for(;r!=null;){let t=K(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function yr(e,t){if(t.length===0)return e.snapshot.rootId;let n=en(t);return br(e,n.segments,n.requiresDirectory)}function br(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=G(e,r),a=ht(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=K(e,r);return n&&!V(i)?null:r}function G(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 K(e,t){let n=e.snapshot.nodes[t];if(n===void 0||H(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function xr(e,t){let n=e.snapshot.nodes[t];if(n===void 0||H(n,4))return[];if(!V(n))return[W(e,t)];if(G(e,t).childIds.length===0)return H(n,1)&&!H(n,2)?[W(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||H(n,4)){i.pop();continue}if(!V(n)){r.push(W(e,t.nodeId)),i.pop();continue}let a=G(e,t.nodeId);if(a.childIds.length===0){H(n,1)&&!H(n,2)&&r.push(W(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 Sr(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=rn(e.snapshot.segmentTable,i),a=G(e,r),o=ht(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!V(K(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=Cr(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function Cr(e,t,n){let r=K(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:kt(At(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,pt()),Er(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function wr(e,t,n){let r=rn(e.snapshot.segmentTable,n),i=G(e,t);if(ht(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${Gr(e,t,n)}"`);let a=K(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:kt(At(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),Er(e,t,o),e.activeNodeCount++,o}function Tr(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}Or(e,n,o)<0?i=a:r=a+1}return r}function Er(e,t,n){let r=G(e,t),i=K(e,n);ht(e.snapshot.nodes,r).set(i.nameId,n),bt(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=Tr(e,r,n);r.childIds.splice(a,0,n),vt(r,a),Ct(e.snapshot.nodes,r)}function Dr(e,t,n,r){let i=G(e,t),a=gt(i),o=a.get(n)??-1;ht(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&bt(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),vt(i,o),Ct(e.snapshot.nodes,i))}function Or(e,t,n){let r=e.snapshot.options.sort;return r==="default"?kr(e,t,n):r(Ar(e,t),Ar(e,n))}function kr(e,t,n){let r=K(e,t),i=K(e,n),a=V(r);if(a!==V(i))return a?-1:1;let o=Ut(Xt(e.snapshot.segmentTable,r.nameId),Xt(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=an(e.snapshot.segmentTable,r.nameId),c=an(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function Ar(e,t){let n=K(e,t),r=W(e,t),i=V(n),a=i?r.slice(0,-1):r;return{basename:an(e.snapshot.segmentTable,n.nameId),depth:At(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function jr(e,t,n){let r=K(e,t),i=yr(e,n);if(i!=null){let t=K(e,i);if(V(t))return{basename:an(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=en(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=en(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:br(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function Mr(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${W(e,t)}"`);let i=K(e,t);if(jt(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(V(i)&&G(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return Nr(e,t),Dr(e,a,t,o),Pr(e,a),gr(e,a),`handled`}function Nr(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=K(e,t.nodeId);if(t.visitedChildren||!V(i)){V(i)&&e.snapshot.directories.delete(t.nodeId),Nt(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),In(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=G(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 Pr(e,t){let n=t;for(;n!=null;){let t=K(e,n);if(!V(t)||H(t,2)||G(e,n).childIds.length>0)return;Nt(t,1),n=t.parentId===n?null:t.parentId}}function Fr(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=ht(e.snapshot.nodes,G(e,n)).get(t);if(i==null||!V(K(e,i)))break;n=i}return n}function Ir(e,t){let n=zr(e,t);if(n==null)return null;let r=cr(e,n),i=K(e,r),a=n===r?null:lr(e,n).map(t=>W(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:G(e,r).childIds.length>0,path:W(e,r),terminalKind:jt(i)})}function Lr(e,t){return Rr([e],[t])}function Rr(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 zr(e,t){let n=t;for(;n!=null;){let t=K(e,n);if(!V(t)||H(t,2))return null;if(!Dn(e,n,t))return n;n=t.parentId}return null}function Br(e,t){let n=K(e,t);if(Pt(n,(t===e.snapshot.rootId?-1:At(K(e,n.parentId)))+1),!V(n))return;let r=G(e,t);for(let t of r.childIds)Br(e,t)}function Vr(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=K(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function Hr(e,t,n=K(e,t),r=!1){let i=e.instrumentation;if(i==null){Wr(e,t,n,r);return}U(i,`store.recomputeNodeCounts`,()=>Wr(e,t,n,r))}function Ur(e,t){let n=t;for(;n!=null;){let t=K(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(Hr(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&bt(G(e,s),n,a,o),n=s}}function Wr(e,t,n,r){if(!V(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=G(e,t);if(r){let t=e.instrumentation;t==null?yt(e.snapshot.nodes,i):U(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>yt(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,H(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=sr(e,t)==null?Dn(e,t,n)?1+o:1:o}function Gr(e,t,n){let r=W(e,t);return r.length===0?n:`${r}${n}`}function Kr(e){return e!=null&&!H(e,4)}function qr(e,t){let n=e.snapshot.nodes[t];return!Kr(n)||!V(n)||H(n,2)?null:n}function Jr(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&Kr(e.snapshot.nodes[n])&&(t+=1);return t}function Yr(e){return Math.max(0,e.valueById.length-1)}function Xr(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:Jr(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:Yr(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function Zr(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 Qr(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)qr(e,n)!=null&&t.push(W(e,n));for(let t of e.expandedDirectoryIds)qr(e,t)!=null&&n.push(W(e,t));return{collapsedPaths:t,expandedPaths:n}}function $r(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)qr(e,n)==null||An(e,n)===`loaded`||t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:W(e,n)});return t}function ei(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=yr(e,n);t!=null&&On(e,t,!0,K(e,t))}for(let n of t.collapsedPaths){let t=yr(e,n);t!=null&&On(e,t,!1,K(e,t))}}function ti(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=yr(e,n.path);t!=null&&qr(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function ni(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function ri(e){let t=e.snapshot.segmentTable,n=nn();for(let r of e.snapshot.nodes)if(Kr(r)){if(H(r,2)){r.nameId=0;continue}r.nameId=rn(n,an(t,r.nameId))}e.snapshot.segmentTable=n}function ii(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!Kr(r)||!V(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return Kr(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[K(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),yt(e.snapshot.nodes,n)}}function ai(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(Kr(n))break;--t}e.snapshot.nodes.length=t+1}function oi(e){let t=Qr(e),n=$r(e);U(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>ni(e)),U(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>ri(e)),U(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>ii(e)),U(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>ai(e)),U(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>ei(e,t)),U(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>ti(e,n)),U(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>_r(e,e.snapshot.rootId))}function si(e){let t=Qr(e),n=$r(e),r=U(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>ur(e)),i=It({...e.snapshot.options},e.instrumentation),a=U(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new Sn(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,U(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>ei(e,t)),U(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>ti(e,n)),U(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>_r(e,e.snapshot.rootId))}function ci(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function li(e,t){let n=Xr(e);t===`stable`?U(e.instrumentation,`store.cleanup.stable`,()=>oi(e)):U(e.instrumentation,`store.cleanup.aggressive`,()=>si(e));let r=Xr(e);return Zr(t,t===`stable`,n,r)}var ui=64;function di(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 fi(e){return K(e,e.snapshot.rootId).visibleSubtreeCount}function pi(e,t,n,r){let i=K(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function mi(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:Ni(e,t.cursor),setSize:t.setSize,subtreeEndIndex:pi(e,t.cursor,t.index,n)}}function hi(e,t,n,r,i,a){let o=G(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=xt(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return gi(e,u,l,r+c,i+1,s,o.childIds.length,a)}function gi(e,t,n,r,i,a,o,s){if(!V(K(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=Di(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=K(e,c.terminalNodeId);if(!V(l)||!Dn(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return hi(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function _i(e,t){let n=fi(e);if(t<0||t>=n)return null;let r=hi(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>W(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=mi(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:Ni(e,r.cursor),setSize:r.setSize,subtreeEndIndex:pi(e,r.cursor,r.index,n)}}function vi(e,t,n){let r=e.instrumentation,i=fi(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 Mi(e,o+1);let t=[],n=wi(e,a);for(let r=a;r<=o&&n!=null;r++){let r=Ni(e,n);t.push(r),n=ki(e,n)}return t}let s=[],c=0,l=0,u=U(r,`store.getVisibleSlice.selectFirstRow`,()=>wi(e,a));for(let t=a;t<=o&&u!=null;t++){let t=U(r,`store.getVisibleSlice.materializeRow`,()=>Ni(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=U(r,`store.getVisibleSlice.advanceCursor`,()=>ki(e,u))}return Rt(r,`workload.visibleRowsRead`,s.length),Rt(r,`workload.flattenedRowsRead`,c),Rt(r,`workload.flattenedSegmentsRead`,l),s}function yi(e,t=fi(e)){let n=e.instrumentation;return n==null?ji(e,t):U(n,`store.getVisibleTreeProjection`,()=>ji(e,t))}function bi(e){return Ai(yi(e))}function xi(e,t){let n=yr(e,t);if(n==null||n===e.snapshot.rootId||V(K(e,n))&&cr(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=K(e,i).parentId,n=G(e,t),s=gt(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=St(a,n,s),t!==o){let n=K(e,t),a=sr(e,t);if(!Dn(e,t,n)&&a!==i)return null;cr(e,t)===t&&(r+=1)}i=t}return r}function Si(e,t){let n=yr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=K(e,n);if(!V(r))throw Error(`Path is not a directory: "${t}"`);return Dn(e,n,r)?null:(On(e,n,!0,r),gr(e,n),Vn({affectedAncestorIds:vr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function Ci(e,t){let n=yr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=K(e,n);if(!V(r))throw Error(`Path is not a directory: "${t}"`);return Dn(e,n,r)?(On(e,n,!1,r),gr(e,n),Hn({affectedAncestorIds:vr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function wi(e,t){return t<0||t>=fi(e)?null:Ti(e,e.snapshot.rootId,t,-1)}function Ti(e,t,n,r){let i=G(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?xt(e.snapshot.nodes,i,n):U(a,`store.getVisibleSlice.selectChildIndex`,()=>xt(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return Ei(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Ei(e,t,n,r){if(!V(K(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=Di(e,t,r);if(n===0)return i;let a=K(e,i.terminalNodeId);if(!V(a)||!Dn(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Ti(e,i.terminalNodeId,n-1,i.visibleDepth)}function Di(e,t,n){return V(K(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:cr(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:U(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>cr(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function Oi(e,t){let n=K(e,t);if(!V(n))return!0;let r=n.parentId;return r===e.snapshot.rootId?!0:sr(e,r)!==t}function ki(e,t){let n=K(e,t.terminalNodeId);if(V(n)){let r=G(e,t.terminalNodeId);if(Dn(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:Ei(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=K(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=G(e,n),o=gt(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 Ei(e,s,0,i);Oi(e,r)&&i--,r=n}}function Ai(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 ji(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(ui);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=di(o,y);let x,S=_;if(V(v))S=f?cr(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:W(e,S);else{let e=p.get(_);x=e!=null&&e.version===m?e.path:`${b}${h[v.nameId]}`}r[s]=o[y],n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let C=c[S];C!=null&&V(C)&&Dn(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 Mi(e,t){let n=Array(t),r=0,{nodes:i,directories:a,segmentTable:o}=e.snapshot,s=[[a.get(e.snapshot.rootId),0,-1]],c=o.valueById,l=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,d=e.pathCacheVersion;for(;s.length>0&&r<t;){let t=s[s.length-1],o=t[0];if(t[1]>=o.childIds.length){s.pop();continue}let f=o.childIds[t[1]++],p=i[f],m=t[2]+1;if(!V(p)){let t=u.get(f);n[r++]={depth:m,flattenedSegments:void 0,hasChildren:!1,id:f,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:`file`,loadState:void 0,name:c[p.nameId],path:t!=null&&t.version===d?t.path:W(e,f)};continue}let h=l?cr(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=Ni(e,g);let _=i[h];_!=null&&V(_)&&Dn(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function Ni(e,t){let n=K(e,t.terminalNodeId),r=V(n)?Pi(e,t):null,i=W(e,t.terminalNodeId),a=an(e.snapshot.segmentTable,n.nameId),o=V(n)&&G(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?lr(e,t.headNodeId).map(n=>{let r=K(e,n);return{isTerminal:n===t.terminalNodeId,name:an(e.snapshot.segmentTable,r.nameId),nodeId:n,path:W(e,n)}}):U(c,`store.getVisibleSlice.flatten.collectSegments`,()=>lr(e,t.headNodeId).map(n=>{let r=K(e,n);return{isTerminal:n===t.terminalNodeId,name:an(e.snapshot.segmentTable,r.nameId),nodeId:n,path:W(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:V(n)&&Dn(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:V(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function Pi(e,t){if(t.headNodeId===t.terminalNodeId)return An(e,t.terminalNodeId);let n=lr(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=An(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}function Fi(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:a}=e.snapshot,o=r.flattenEmptyDirectories===!0,s=e=>{let r=n[e];if(r==null||!V(r))return;let i=t.get(e);if(i==null)throw Error(`Unknown directory child index for node ${String(e)}`);let a=i.childIds,s=a.length,c=0,l=0;for(let e=0;e<s;e++){let t=a[e];if(t==null)continue;let r=n[t];c+=r.subtreeNodeCount,l+=r.visibleSubtreeCount}i.totalChildSubtreeNodeCount=c,i.totalChildVisibleSubtreeCount=l,s>=128&&Ct(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&V(e)?l:1+l}else u=1+l;r.visibleSubtreeCount=u};if(a!=null)for(let e=a.length-1;e>=0;e--)s(a[e]);else for(let e=n.length-1;e>=1;e--)s(e);let c=n[i],l=t.get(i);if(c==null||l==null)return;let u=l.childIds,d=0,f=0;for(let e=0;e<u.length;e++){let t=u[e];if(t==null)continue;let r=n[t];d+=r.subtreeNodeCount,f+=r.visibleSubtreeCount}l.totalChildSubtreeNodeCount=d,l.totalChildVisibleSubtreeCount=f,Ct(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Ii(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var Li=class e{#e;constructor(e={}){let t=Lt(e),n=U(t,`store.builder.create`,()=>new Sn(e));if(e.preparedInput!=null){let t=yn(e.preparedInput);t==null?n.appendPreparedPaths(vn(e.preparedInput),!1):n.appendPresortedPaths(t,bn(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(U(t,`store.preparePathEntries`,()=>xn(r,e)))}let r=U(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=U(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=U(t,`store.state.create`,()=>Cn(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:U(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||Ii(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&U(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?U(t,`store.state.initializeOpenVisibleCounts`,()=>Fi(this.#e)):U(t,`store.state.recomputeCounts`,()=>_r(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return hn(e,t)}static prepareInput(e,t={}){return gn(e,t)}static preparePresortedInput(e){return _n(e)}list(e){return U(this.#e.instrumentation,`store.list`,()=>ur(this.#e,e))}add(e){U(this.#e.instrumentation,`store.add`,()=>{let t=fi(this.#e);Zn(this.#e,Yn(this.#e,t,dr(this.#e,e)))})}remove(e,t={}){U(this.#e.instrumentation,`store.remove`,()=>{let n=fi(this.#e);Zn(this.#e,Yn(this.#e,n,fr(this.#e,e,t)))})}move(e,t,n={}){U(this.#e.instrumentation,`store.move`,()=>{let r=fi(this.#e),i=pr(this.#e,e,t,n);i!=null&&Zn(this.#e,Yn(this.#e,r,i))})}batch(e){Xn(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 U(this.#e.instrumentation,`store.getVisibleCount`,()=>fi(this.#e))}getVisibleSlice(e,t){return U(this.#e.instrumentation,`store.getVisibleSlice`,()=>vi(this.#e,e,t))}getVisibleRowContext(e){return U(this.#e.instrumentation,`store.getVisibleRowContext`,()=>_i(this.#e,e))}getVisibleTreeProjection(){return bi(this.#e)}getVisibleTreeProjectionData(e){return yi(this.#e,e)}getVisibleIndex(e){return U(this.#e.instrumentation,`store.getVisibleIndex`,()=>xi(this.#e,e))}getPathInfo(e){return U(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=yr(this.#e,e);if(t==null)return null;let n=K(this.#e,t);return{depth:At(n),kind:V(n)?`directory`:`file`,path:W(this.#e,t)}})}isExpanded(e){return U(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=K(this.#e,t);return Dn(this.#e,t,n)})}expand(e){U(this.#e.instrumentation,`store.expand`,()=>{let t=fi(this.#e),n=Si(this.#e,e);n!=null&&Zn(this.#e,Yn(this.#e,t,n))})}collapse(e){U(this.#e.instrumentation,`store.collapse`,()=>{let t=fi(this.#e),n=Ci(this.#e,e);n!=null&&Zn(this.#e,Yn(this.#e,t,n))})}on(e,t){return Ln(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return An(this.#e,t)}markDirectoryUnloaded(e){U(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(G(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=fi(this.#e);Mn(this.#e,t),Zn(this.#e,Yn(this.#e,n,Un({affectedAncestorIds:vr(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return U(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=fi(this.#e),r=jn(this.#e,t);return Zn(this.#e,Yn(this.#e,n,Wn({affectedAncestorIds:vr(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return U(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||An(this.#e,n)!==`loading`||!Pn(this.#e,n,e.attemptId))return!1;let r=W(this.#e,n);this.validateChildPatch(r,t);let i=fi(this.#e),a=[];for(let e of t.operations){Ri(r,e);let t=fi(this.#e);switch(e.type){case`add`:a.push(Yn(this.#e,t,dr(this.#e,e.path)));break;case`remove`:a.push(Yn(this.#e,t,fr(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=pr(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(Yn(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return Zn(this.#e,Yn(this.#e,i,Gn({affectedAncestorIds:vr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:W(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return U(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=fi(this.#e),r=Nn(this.#e,t,e.attemptId);return Zn(this.#e,Yn(this.#e,n,Kn({affectedAncestorIds:vr(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:W(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return U(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=fi(this.#e),i=Fn(this.#e,n,e.attemptId,t);return Zn(this.#e,Yn(this.#e,r,qn({affectedAncestorIds:vr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:W(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return U(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(ci(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=fi(this.#e),n=li(this.#e,e.mode??`stable`);return Zn(this.#e,Yn(this.#e,t,Jn({...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=G(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??Vt(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=Ut(Xt(o,t.nameId),b);if(r>0||r===0&&n>a)return!1}return!1};if(!x(_,f.length)&&_>0&&x(0,_),y===void 0){h=!1;break}if(!V(K(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=K(this.#e,n);Dn(this.#e,n,i)||(On(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=K(this.#e,e);if(!Dn(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=yr(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!V(K(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!V(K(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=K(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=K(this.#e,e),r=sr(this.#e,e);if(!Dn(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 Ri(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 zi={compact:{itemHeight:24,factor:.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function Bi(e,t){if(typeof e==`number`)return{itemHeight:t??zi.default.itemHeight,factor:e};let n=zi[e??`default`];return{itemHeight:t??n.itemHeight,factor:n.factor}}var Vi=zi.default.itemHeight,Hi=`@layer base, theme, unsafe;
|
|
2
2
|
|
|
3
3
|
@layer base {
|
|
4
4
|
:host {
|
|
@@ -1775,4 +1775,4 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}f
|
|
|
1775
1775
|
color: var(--diffs-selection-number-fg) !important;
|
|
1776
1776
|
}
|
|
1777
1777
|
`;function Mf(e){let t=(0,af.c)(5),n=Ee(e.environmentId,e.resource),[r,i]=(0,X.useState)(null);if(n._tag===`Failure`||n._tag===`Success`&&r===n.url){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,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 image.`}),t[0]=e):e=t[0],e}let a;return t[1]!==n._tag||t[2]!==n.url||t[3]!==e.alt?(a=n._tag===`Success`?(0,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:n.url,alt:e.alt,onError:()=>i(n.url)})}):(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,Z.jsx)(fe,{className:`size-5 animate-spin`})}),t[1]=n._tag,t[2]=n.url,t[3]=e.alt,t[4]=a):a=t[4],a}function Nf(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 Pf(e,t){let n=e.shadowRoot??e;for(let e of n.querySelectorAll(`[${Af}]`))e.removeAttribute(Af);t!==null&&(n.querySelector(`[data-line="${t}"]`)?.setAttribute(Af,``),n.querySelector(`[data-column-number="${t}"]`)?.setAttribute(Af,``))}function Ff(e,t,n){let r=(0,af.c)(7),[i]=(0,X.useState)(Rf),[a]=(0,X.useState)(Lf),[o]=(0,X.useState)(If),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:Nf(s.file?.contents??``,t);if(Pf(r,u),!(s instanceof k))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 If(){return new Map}function Lf(){return new Map}function Rf(){return new Map}function zf(e){let t=(0,af.c)(19),{environmentId:n,cwd:r,relativePath:i,onPendingChange:a}=e,o=p(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=>{Le(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:kf,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,m;return t[16]===d?(f=t[17],m=t[18]):(f=()=>()=>d.dispose(),m=[d],t[16]=d,t[17]=f,t[18]=m),(0,X.useEffect)(f,m),d}function Bf(e){let t=(0,af.c)(74),{environmentId:n,cwd:r,relativePath:i,composerDraftTarget:a,contents:o,resolvedTheme:s,revealRequestId:c,wordWrap:l,onPostRender:u,onPendingChange:d}=e,f=y(qf),p=y(Kf),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=[],t[0]=m):m=t[0];let[h,g]=(0,X.useState)(m),[_,v]=(0,X.useState)(null),b=_?.revealRequestId===c?_.range:null,S;t[1]===c?S=t[2]:(S=e=>{v({revealRequestId:c,range:e})},t[1]=c,t[2]=S);let C=S,ee=(0,X.useRef)(null),T=(0,X.useRef)(null),D;t[3]!==r||t[4]!==n||t[5]!==d||t[6]!==i?(D={environmentId:n,cwd:r,relativePath:i,onPendingChange:d},t[3]=r,t[4]=n,t[5]=d,t[6]=i,t[7]=D):D=t[7];let k=zf(D),j;t[8]!==f||t[9]!==a||t[10]!==r||t[11]!==n||t[12]!==i||t[13]!==k?(j=new Xd({onChange:(e,t)=>{if(Oe(n,r,i,e.contents),k.change(e.contents),t){let n=E(t);g(n);for(let t of n)for(let n of t.metadata.entries)n.kind===`comment`&&f(a,x({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:n.text,contents:e.contents}))}}}),t[8]=f,t[9]=a,t[10]=r,t[11]=n,t[12]=i,t[13]=k,t[14]=j):j=t[14];let M=j,N,P;t[15]===M?(N=t[16],P=t[17]):(N=()=>()=>{M.cleanUp()},P=[M],t[15]=M,t[16]=N,t[17]=P),(0,X.useEffect)(N,P);let ne;t[18]!==a||t[19]!==p||t[20]!==C?(ne=e=>{C(null),p(a,e),g(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]=p,t[20]=C,t[21]=ne):ne=t[21];let re=ne,ie;t[22]!==f||t[23]!==a||t[24]!==o||t[25]!==h||t[26]!==i||t[27]!==C?(ie=(e,t)=>{C(null);let n=h.flatMap(Gf).find(t=>t.id===e);n&&f(a,x({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:t,contents:o})),g(n=>n.map(n=>({...n,metadata:{entries:n.metadata.entries.map(n=>n.id===e?{...n,kind:`comment`,text:t}:n)}})))},t[22]=f,t[23]=a,t[24]=o,t[25]=h,t[26]=i,t[27]=C,t[28]=ie):ie=t[28];let ae=ie,oe;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>{let{startLine:t,endLine:n}=O(e),r={id:te(),kind:`draft`,startLine:t,endLine:n,text:``};g(e=>{let t=e.flatMap(Uf),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]=oe):oe=t[29];let F=oe,se;t[30]===h?se=t[31]:(se=h.some(Vf),t[30]=h,t[31]=se);let ce=se,le,I;t[32]!==M||t[33]!==ce||t[34]!==C?(le=()=>{let e=ee.current;if(e)return xf({root:e,editor:M,isBlocked:()=>ce,onDismiss:()=>C(null)})},I=[M,ce,C],t[32]=M,t[33]=ce,t[34]=C,t[35]=le,t[36]=I):(le=t[35],I=t[36]),(0,X.useEffect)(le,I);let ue;t[37]===C?ue=t[38]:(ue=e=>{C(e),e&&F(e)},t[37]=C,t[38]=ue);let de=ue,fe;t[39]!==u||t[40]!==b?(fe=(e,t,n)=>{u(e,t,n),T.current!==null&&(cancelAnimationFrame(T.current),T.current=null),n!==`unmount`&&(T.current=requestAnimationFrame(()=>{T.current=null,e.isConnected&&t.setSelectedLines(b,{notify:!1})}))},t[39]=u,t[40]=b,t[41]=fe):fe=t[41];let pe=fe,me;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(me={overscrollSize:600,intersectionObserverMargin:1200},t[42]=me):me=t[42];let ge;t[43]!==o||t[44]!==r||t[45]!==i?(ge=Cf(r,i,o),t[43]=o,t[44]=r,t[45]=i,t[46]=ge):ge=t[46];let _e;t[47]!==o||t[48]!==i||t[49]!==ge?(_e={name:i,contents:o,cacheKey:ge},t[47]=o,t[48]=i,t[49]=ge,t[50]=_e):_e=t[50];let ve=!ce,ye=!ce,be=l?`wrap`:`scroll`,xe;t[51]===s?xe=t[52]:(xe=he(s),t[51]=s,t[52]=xe);let Se;t[53]!==de||t[54]!==pe||t[55]!==s||t[56]!==C||t[57]!==ve||t[58]!==ye||t[59]!==be||t[60]!==xe?(Se={disableFileHeader:!0,enableGutterUtility:ve,enableLineSelection:ye,onGutterUtilityClick:C,onLineSelectionChange:C,onLineSelectionEnd:de,overflow:be,theme:xe,themeType:s,unsafeCSS:jf,onPostRender:pe},t[53]=de,t[54]=pe,t[55]=s,t[56]=C,t[57]=ve,t[58]=ye,t[59]=be,t[60]=xe,t[61]=Se):Se=t[61];let Ce;t[62]!==re||t[63]!==ae?(Ce=e=>(0,Z.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,Z.jsx)(w,{kind:e.kind,rangeLabel:A(e.startLine,e.endLine),text:e.text,onCancel:()=>re(e.id),onComment:t=>ae(e.id,t),onDelete:()=>re(e.id)},e.id))}),t[62]=re,t[63]=ae,t[64]=Ce):Ce=t[64];let we;t[65]!==h||t[66]!==b||t[67]!==_e||t[68]!==Se||t[69]!==Ce?(we=(0,Z.jsx)(`div`,{ref:ee,className:`flex min-h-0 flex-1`,children:(0,Z.jsx)(Ge,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:me,children:(0,Z.jsx)(zl,{file:_e,options:Se,selectedLines:b,lineAnnotations:h,renderAnnotation:Ce,className:`min-h-full`,contentEditable:!0})})}),t[65]=h,t[66]=b,t[67]=_e,t[68]=Se,t[69]=Ce,t[70]=we):we=t[70];let L;return t[71]!==M||t[72]!==we?(L=(0,Z.jsx)(Ye,{editor:M,children:we}),t[71]=M,t[72]=we,t[73]=L):L=t[73],L}function Vf(e){return e.metadata.entries.some(Hf)}function Hf(e){return e.kind===`draft`}function Uf(e){let t=e.metadata.entries.filter(Wf);return t.length>0?[{...e,metadata:{entries:t}}]:[]}function Wf(e){return e.kind!==`draft`}function Gf(e){return e.metadata.entries}function Kf(e){return e.removeReviewComment}function qf(e){return e.addReviewComment}function Jf(e){let t=(0,af.c)(17),{environmentId:n,cwd:r,relativePath:i,contents:a,threadRef:o,readOnly:s,onPendingChange:c}=e,l;t[0]!==r||t[1]!==n||t[2]!==c||t[3]!==i?(l={environmentId:n,cwd:r,relativePath:i,onPendingChange:c},t[0]=r,t[1]=n,t[2]=c,t[3]=i,t[4]=l):l=t[4];let u=zf(l),d;t[5]!==a||t[6]!==r||t[7]!==n||t[8]!==s||t[9]!==i||t[10]!==u?(d=s?{}:{onTaskListChange:e=>{let{markerOffset:t,checked:o}=e,s=We(n,r,i)?.contents??a,c=Ef(s,t,o);c!==s&&(Oe(n,r,i,c),u.change(c))}},t[5]=a,t[6]=r,t[7]=n,t[8]=s,t[9]=i,t[10]=u,t[11]=d):d=t[11];let f;return t[12]!==a||t[13]!==r||t[14]!==d||t[15]!==o?(f=(0,Z.jsx)(Te,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(Se,{text:a,cwd:r,threadRef:o,className:`mx-auto max-w-4xl px-6 py-5`,...d})}),t[12]=a,t[13]=r,t[14]=d,t[15]=o,t[16]=f):f=t[16],f}function Yf(){try{return u(Of,f)??!0}catch(e){return console.error(e),!0}}function Xf(e){let t=(0,af.c)(102),{environmentId:n,cwd:r,projectName:l,workspaceRoot:u,relativePath:f,isOutsideWorkspace:m,threadRef:h,composerDraftTarget:y,keybindings:x,availableEditors:C,revealLine:w,revealRequestId:T,onOpenFile:E,onPendingChange:te}=e,{resolvedTheme:D}=b(),O=ne(Qf),k=d(),A=a(n),M;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(M={reportFailure:!1},t[0]=M):M=t[0];let N=de(Ke.createUrl,M),P;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(P={reportFailure:!1},t[1]=P):P=t[1];let re=p(He.open,P),ie=n===k,ae;t[2]===f?ae=t[3]:(ae=f!==null&&ue(f),t[2]=f,t[3]=ae);let oe=ae,F=Ve(n,r,f,!oe),[I,pe]=(0,X.useState)(Yf),[ge,_e]=(0,X.useState)(!1),ve;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(ve={path:null,revealRequestId:null},t[4]=ve):ve=t[4];let[ye,be]=(0,X.useState)(ve),Se=(0,X.useRef)(null),Ce;t[5]===f?Ce=t[6]:(Ce=f?Tf(f):!1,t[5]=f,t[6]=Ce);let L=Ce,Ee=L&&ye.path===f&&(w===null||ye.revealRequestId===T),De;t[7]===f?De=t[8]:(De=f!==null&&Be()&&se(f),t[7]=f,t[8]=De);let Oe=De,ke;t[9]!==r||t[10]!==f?(ke=f?_(f,r):null,t[9]=r,t[10]=f,t[11]=ke):ke=t[11];let R=ke,Ae;t[12]!==R||t[13]!==ie||t[14]!==h.threadId||t[15]!==u?(Ae=R===null?null:we({filePath:R,threadId:h.threadId,workspaceRoot:u,allowLocalFiles:ie}),t[12]=R,t[13]=ie,t[14]=h.threadId,t[15]=u,t[16]=Ae):Ae=t[16];let je=Ae,Me;t[17]!==r||t[18]!==m||t[19]!==l||t[20]!==f?(Me=f?wf(m?r:l,f):[],t[17]=r,t[18]=m,t[19]=l,t[20]=f,t[21]=Me):Me=t[21];let Pe=Me,Fe=Ff(f,w,T),Ie;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=()=>{(Se.current?.querySelector(`[data-current-file-crumb='true']`))?.scrollIntoView({block:`nearest`,inline:`end`})},t[22]=Ie):Ie=t[22];let Le;t[23]===f?Le=t[24]:(Le=[f],t[23]=f,t[24]=Le),(0,X.useEffect)(Ie,Le);let Ue;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=()=>{pe(Zf)},t[25]=Ue):Ue=t[25];let We=Ue,qe;t[26]!==R||t[27]!==ie||t[28]!==N||t[29]!==A||t[30]!==re||t[31]!==D||t[32]!==h||t[33]!==u?(qe=()=>{!R||!A||(async()=>{let e=await xe({threadRef:h,filePath:R,httpBaseUrl:A,workspaceRoot:u,allowLocalFiles:ie,theme:D,createAssetUrl:N,openPreview:re});if(e._tag===`Success`||i(e))return;let t=v(e);ze.add(Ne({type:`error`,title:`Unable to open file in browser`,description:t instanceof Error?t.message:`An error occurred.`}))})()},t[26]=R,t[27]=ie,t[28]=N,t[29]=A,t[30]=re,t[31]=D,t[32]=h,t[33]=u,t[34]=qe):qe=t[34];let Je=qe,Ye;t[35]!==R||t[36]!==ie||t[37]!==C||t[38]!==y||t[39]!==r||t[40]!==n||t[41]!==F||t[42]!==je||t[43]!==oe||t[44]!==L||t[45]!==m||t[46]!==x||t[47]!==Fe||t[48]!==te||t[49]!==f||t[50]!==Ee||t[51]!==D||t[52]!==T||t[53]!==h||t[54]!==O?(Ye=f&&oe&&je?(0,Z.jsx)(Mf,{environmentId:n,resource:je,alt:f},R??f):f&&F.error&&F.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:F.error}):f&&F.data===null?(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,Z.jsx)(fe,{className:`size-5 animate-spin`})}):f&&F.data?F.data.binary&&R?(0,Z.jsx)(gf,{environmentId:n,keybindings:x,availableEditors:C,absolutePath:R,name:f.slice(f.lastIndexOf(`/`)+1),byteLength:F.data.byteLength,canRevealInFileManager:ie&&c()}):L&&Ee?(0,Z.jsx)(Jf,{environmentId:n,cwd:r,relativePath:f,threadRef:h,contents:F.data.contents,readOnly:m,onPendingChange:te}):F.data.truncated||m?(0,Z.jsx)(Ge,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:{overscrollSize:600,intersectionObserverMargin:1200},children:(0,Z.jsx)(zl,{file:{name:f,contents:F.data.contents,cacheKey:Cf(r,f,F.data.contents)},options:{disableFileHeader:!0,overflow:O?`wrap`:`scroll`,theme:he(D),themeType:D,unsafeCSS:jf,onPostRender:Fe},className:`min-h-full`})},`${f}:${D}:${F.data.byteLength}`):(0,Z.jsx)(Bf,{environmentId:n,cwd:r,relativePath:f,composerDraftTarget:y,contents:F.data.contents,resolvedTheme:D,revealRequestId:T,wordWrap:O,onPostRender:Fe,onPendingChange:te},`${f}:${D}`):null,t[35]=R,t[36]=ie,t[37]=C,t[38]=y,t[39]=r,t[40]=n,t[41]=F,t[42]=je,t[43]=oe,t[44]=L,t[45]=m,t[46]=x,t[47]=Fe,t[48]=te,t[49]=f,t[50]=Ee,t[51]=D,t[52]=T,t[53]=h,t[54]=O,t[55]=Ye):Ye=t[55];let Xe=Ye,Ze;t[56]!==R||t[57]!==C||t[58]!==Pe||t[59]!==Oe||t[60]!==n||t[61]!==ge||t[62]!==I||t[63]!==Je||t[64]!==L||t[65]!==x||t[66]!==k||t[67]!==l||t[68]!==f||t[69]!==Ee||t[70]!==T?(Ze=f?(0,Z.jsxs)(`div`,{className:`surface-subheader gap-2 px-3`,"data-surface-subheader":!0,children:[(0,Z.jsx)(Te,{ref:Se,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:Pe.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)(ee,{className:`mx-1 size-3.5 shrink-0 text-muted-foreground/60`}):null,(0,Z.jsx)(`span`,{className:g(`max-w-40 truncate`,e.kind===`file`?`font-medium text-foreground`:`text-muted-foreground`),title:e.path||l,children:e.label})]},e.path||`project`))})}),R&&n===k?(0,Z.jsx)(Re,{environmentId:n,keybindings:x,availableEditors:C,openInCwd:R,compact:!0,enableShortcut:!1}):null,L?(0,Z.jsxs)(o,{children:[(0,Z.jsx)(s,{render:(0,Z.jsx)(Qe,{className:`shrink-0`,pressed:Ee,onPressedChange:e=>{be({path:e?f:null,revealRequestId:e?T:null})},"aria-label":Ee?`Show markdown source`:`Show rendered markdown`,variant:`ghost`,size:`sm`,children:Ee?(0,Z.jsx)(et,{className:`size-3.5`}):(0,Z.jsx)(j,{className:`size-3.5`})})}),(0,Z.jsx)(S,{children:Ee?`Show markdown source`:`Show rendered markdown`})]}):null,Oe?(0,Z.jsxs)(o,{children:[(0,Z.jsx)(s,{render:(0,Z.jsx)(Qe,{className:`shrink-0`,pressed:!1,onPressedChange:Je,"aria-label":`Open file in preview browser`,variant:`ghost`,size:`sm`,children:(0,Z.jsx)(ce,{className:`size-3.5`})})}),(0,Z.jsx)(S,{children:`Open file in preview browser`})]}):null,(0,Z.jsxs)(o,{children:[(0,Z.jsx)(s,{render:(0,Z.jsx)(Qe,{className:`shrink-0`,pressed:ge,onPressedChange:_e,"aria-label":ge?`Collapse file preview`:`Expand file preview`,variant:`ghost`,size:`sm`,children:ge?(0,Z.jsx)(me,{className:`size-3.5`}):(0,Z.jsx)(le,{className:`size-3.5`})})}),(0,Z.jsx)(S,{children:ge?`Collapse file preview`:`Expand file preview`})]}),(0,Z.jsxs)(o,{children:[(0,Z.jsx)(s,{render:(0,Z.jsx)(Qe,{className:`shrink-0`,pressed:I,onPressedChange:We,"aria-label":I?`Hide file explorer`:`Show file explorer`,variant:`ghost`,size:`sm`,children:(0,Z.jsx)(nt,{className:`size-3.5`})})}),(0,Z.jsx)(S,{children:I?`Hide file explorer`:`Show file explorer`})]})]}):null,t[56]=R,t[57]=C,t[58]=Pe,t[59]=Oe,t[60]=n,t[61]=ge,t[62]=I,t[63]=Je,t[64]=L,t[65]=x,t[66]=k,t[67]=l,t[68]=f,t[69]=Ee,t[70]=T,t[71]=Ze):Ze=t[71];let $e;t[72]!==F||t[73]!==f?($e=f&&F.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 `,F.data.byteLength.toLocaleString(),` byte file.`]}):null,t[72]=F,t[73]=f,t[74]=$e):$e=t[74];let tt=f?`flex`:`hidden`,rt;t[75]===tt?rt=t[76]:(rt=g(`min-w-0 flex-1 flex-col overflow-hidden`,tt),t[75]=tt,t[76]=rt);let it;t[77]!==ge||t[78]!==Xe?(it=ge?(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs text-muted-foreground`,children:`Shown in the expanded view.`}):Xe,t[77]=ge,t[78]=Xe,t[79]=it):it=t[79];let at;t[80]!==rt||t[81]!==it?(at=(0,Z.jsx)(`div`,{className:rt,children:it}),t[80]=rt,t[81]=it,t[82]=at):at=t[82];let z;t[83]!==r||t[84]!==n||t[85]!==I||t[86]!==E||t[87]!==l||t[88]!==f?(z=I||f===null?(0,Z.jsx)(`aside`,{className:g(`flex min-h-0 shrink-0 bg-background`,f?`w-[min(22rem,46%)] min-w-64 border-l border-border/60`:`min-w-0 flex-1`),children:(0,Z.jsx)(uf,{environmentId:n,cwd:r,projectName:l,onOpenFile:E},`${n}:${r}`)}):null,t[83]=r,t[84]=n,t[85]=I,t[86]=E,t[87]=l,t[88]=f,t[89]=z):z=t[89];let B;t[90]!==at||t[91]!==z?(B=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[at,z]}),t[90]=at,t[91]=z,t[92]=B):B=t[92];let ot=ge&&f!==null,st=f??``,ct;t[93]!==Xe||t[94]!==ot||t[95]!==st?(ct=(0,Z.jsx)(df,{open:ot,title:st,onOpenChange:_e,children:Xe}),t[93]=Xe,t[94]=ot,t[95]=st,t[96]=ct):ct=t[96];let lt;return t[97]!==Ze||t[98]!==$e||t[99]!==B||t[100]!==ct?(lt=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[Ze,$e,B,ct]}),t[97]=Ze,t[98]=$e,t[99]=B,t[100]=ct,t[101]=lt):lt=t[101],lt}function Zf(e){let t=!e;try{h(Of,t,f)}catch(e){console.error(e)}return t}function Qf(e){return e.wordWrap}export{Xf as default};
|
|
1778
|
-
//# sourceMappingURL=FilePreviewPanel-
|
|
1778
|
+
//# sourceMappingURL=FilePreviewPanel-BV66Pov6.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{A as i,Ac as a,C as o,Cc as s,E as c,Ec as l,Hs as u,I as d,Is as f,O as p,Qr as m,Uu as h,Vu as g,Wt as _,ai as v,ci as y,di as b,dl as x,fi as S,g as C,gc as w,hc as T,ic as E,in as D,k as ee,li as O,mi as te,ni as k,oi as A,pc as j,pi as M,si as ne,u as re,vc as N,w as ie,ws as P}from"./terminal-links-B2KXT7CK.js";import{t as F}from"./arrow-right-BnQZ60ie.js";import{A as I,An as L,Ar as ae,Dr as oe,F as R,G as z,Gr as se,M as B,Mn as V,Mr as ce,N as H,Nn as U,Nr as le,O as W,Or as ue,P as G,Pn as K,Qn as q,Rr as J,Vr as de,a as fe,ar as pe,c as me,cr as he,dr as ge,er as _e,fr as ve,g as ye,hr as Y,i as be,ir as xe,j as Se,jn as Ce,jr as we,k as Te,lr as Ee,mr as X,n as De,nr as Oe,o as ke,or as Ae,pr as je,r as Me,rr as Ne,s as Pe,sr as Fe,t as Ie,tr as Le,ur as Re}from"./index-DYDaZ0DX.js";var ze=P(`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`}]]),Be=P(`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`}]]),Ve=P(`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`}]]),He=P(`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=e(n(),1),Q=r(),$=t();function Ue(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=_(`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 We=f(`[&_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 Ge(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,o;t[4]!==a||t[5]!==n?(o=_(We({align:a}),n),t[4]=a,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,$.jsx)(`div`,{className:o,"data-align":a,"data-slot":`input-group-addon`,onMouseDown:Ke,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function Ke(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 qe(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)(q,{className:n,unstyled:!0,...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}var Je=()=>{};function Ye(e){let t=(0,Q.c)(98),{url:n,displayUrl:r,loading:i,loadProgress:a,canGoBack:s,canGoForward:l,refreshDisabled:u,inputDisabled:d,focusUrlNonce:f,onBack:p,onForward:h,onRefresh:g,onSubmit:v,onOpenInBrowser:y,onCapture:b,captureDisabled:x,recording:S,onPictureInPicture:C,pictureInPicture:w,pictureInPictureDisabled:T,onPickElement:E,pickActive:D,pickDisabled:ee,pickDisabledReason:O,trailingActions:te}=e,k=(0,Z.useRef)(null),[A,j]=(0,Z.useState)(n),[M,ne]=(0,Z.useState)(!1),re,N;t[0]===f?(re=t[1],N=t[2]):(re=()=>{if(f==null)return;let e=k.current;e&&e.focus()},N=[f],t[0]=f,t[1]=re,t[2]=N),(0,Z.useEffect)(re,N);let P;t[3]!==A||t[4]!==v?(P=e=>{e?.preventDefault();let t=A.trim();t.length!==0&&(v(t),k.current?.blur())},t[3]=A,t[4]=v,t[5]=P):P=t[5];let I=P,L=s?p:Je,ae=!s,R;t[6]!==L||t[7]!==ae?(R=(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,onClick:L,disabled:ae,"aria-label":`Back`,type:`button`}),t[6]=L,t[7]=ae,t[8]=R):R=t[8];let z;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(se,{}),t[9]=z):z=t[9];let B;t[10]===R?B=t[11]:(B=(0,$.jsx)(c,{render:R,children:z}),t[10]=R,t[11]=B);let V;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(ie,{children:`Back`}),t[12]=V):V=t[12];let H;t[13]===B?H=t[14]:(H=(0,$.jsxs)(o,{children:[B,V]}),t[13]=B,t[14]=H);let U=l?h:Je,le=!l,W;t[15]!==U||t[16]!==le?(W=(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,onClick:U,disabled:le,"aria-label":`Forward`,type:`button`}),t[15]=U,t[16]=le,t[17]=W):W=t[17];let ue;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(F,{}),t[18]=ue):ue=t[18];let G;t[19]===W?G=t[20]:(G=(0,$.jsx)(c,{render:W,children:ue}),t[19]=W,t[20]=G);let K;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(ie,{children:`Forward`}),t[21]=K):K=t[21];let q;t[22]===G?q=t[23]:(q=(0,$.jsxs)(o,{children:[G,K]}),t[22]=G,t[23]=q);let J=u?Je:g,fe=i?`Stop`:`Refresh`,pe;t[24]!==u||t[25]!==J||t[26]!==fe?(pe=(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,onClick:J,disabled:u,"aria-label":fe,type:`button`}),t[24]=u,t[25]=J,t[26]=fe,t[27]=pe):pe=t[27];let me=i&&`animate-spin`,he;t[28]===me?he=t[29]:(he=_(me),t[28]=me,t[29]=he);let ge;t[30]===he?ge=t[31]:(ge=(0,$.jsx)(oe,{className:he}),t[30]=he,t[31]=ge);let _e;t[32]!==pe||t[33]!==ge?(_e=(0,$.jsx)(c,{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)(ie,{children:ve}),t[35]=ve,t[36]=ye);let Y;t[37]!==_e||t[38]!==ye?(Y=(0,$.jsxs)(o,{children:[_e,ye]}),t[37]=_e,t[38]=ye,t[39]=Y):Y=t[39];let be;t[40]!==H||t[41]!==q||t[42]!==Y?(be=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[H,q,Y]}),t[40]=H,t[41]=q,t[42]=Y,t[43]=be):be=t[43];let xe=M?A:r??n,Se=y&&!M&&`group-hover/address:pe-7 transition-[padding]`,Ce;t[44]===Se?Ce=t[45]:(Ce=_(Se),t[44]=Se,t[45]=Ce);let Te;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>j(e.target.value),t[46]=Te):Te=t[46];let Ee;t[47]===n?Ee=t[48]:(Ee=()=>{j(n),ne(!0),queueMicrotask(()=>k.current?.select())},t[47]=n,t[48]=Ee);let X;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(X=()=>{ne(!1)},t[49]=X):X=t[49];let De;t[50]!==I||t[51]!==n?(De=e=>{e.key===`Enter`&&I(e),e.key===`Escape`&&(e.preventDefault(),j(n),k.current?.blur())},t[50]=I,t[51]=n,t[52]=De):De=t[52];let Oe;t[53]!==d||t[54]!==xe||t[55]!==Ce||t[56]!==Ee||t[57]!==De?(Oe=(0,$.jsx)(c,{render:(0,$.jsx)(qe,{ref:k,value:xe,className:Ce,onChange:Te,onFocus:Ee,onBlur:X,onKeyDown:De,placeholder:`Search or enter URL`,spellCheck:!1,disabled:d,"data-preview-url-input":!0,size:`sm`})}),t[53]=d,t[54]=xe,t[55]=Ce,t[56]=Ee,t[57]=De,t[58]=Oe):Oe=t[58];let ke;t[59]!==r||t[60]!==M||t[61]!==n?(ke=!M&&r?(0,$.jsx)(ie,{children:n}):null,t[59]=r,t[60]=M,t[61]=n,t[62]=ke):ke=t[62];let Ae;t[63]!==Oe||t[64]!==ke?(Ae=(0,$.jsxs)(o,{children:[Oe,ke]}),t[63]=Oe,t[64]=ke,t[65]=Ae):Ae=t[65];let je;t[66]!==M||t[67]!==y?(je=y&&!M?(0,$.jsx)(Ge,{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)(o,{children:[(0,$.jsx)(c,{render:(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,onClick:y,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(de,{})}),(0,$.jsx)(ie,{children:`Open in system browser`})]})}):null,t[66]=M,t[67]=y,t[68]=je):je=t[68];let Me;t[69]!==Ae||t[70]!==je?(Me=(0,$.jsxs)(Ue,{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:[Ae,je]}),t[69]=Ae,t[70]=je,t[71]=Me):Me=t[71];let Ne;t[72]!==E||t[73]!==D||t[74]!==ee||t[75]!==O?(Ne=E?(0,$.jsxs)(o,{children:[(0,$.jsx)(c,{render:(0,$.jsx)(m,{variant:D?`secondary`:`ghost`,size:`icon-xs`,onClick:E,disabled:ee,"aria-label":D?`Cancel annotation`:`Annotate preview`,"aria-pressed":D?`true`:`false`,type:`button`}),children:(0,$.jsx)(ce,{className:_(D&&`text-primary`)})}),(0,$.jsx)(ie,{children:ee&&O?O:D?`Cancel annotation (Esc)`:`Annotate elements, regions, and drawings`})]}):null,t[72]=E,t[73]=D,t[74]=ee,t[75]=O,t[76]=Ne):Ne=t[76];let Pe;t[77]!==x||t[78]!==b||t[79]!==S?(Pe=b?(0,$.jsxs)(o,{children:[(0,$.jsxs)(c,{render:(0,$.jsx)(m,{variant:S?`secondary`:`ghost`,size:`icon-xs`,onClick:e=>b(e.shiftKey),"aria-label":S?`Stop recording`:`Capture screenshot`,type:`button`,className:`relative`,disabled:x}),children:[(0,$.jsx)(ze,{className:_(S&&`text-destructive`)}),S?(0,$.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 animate-status-pulse rounded-full bg-destructive`}):null]}),(0,$.jsx)(ie,{children:S?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[77]=x,t[78]=b,t[79]=S,t[80]=Pe):Pe=t[80];let Fe;t[81]!==C||t[82]!==w||t[83]!==T?(Fe=C?(0,$.jsxs)(o,{children:[(0,$.jsx)(c,{render:(0,$.jsx)(m,{variant:w?`secondary`:`ghost`,size:`icon-xs`,onClick:C,"aria-label":w?`Close floating preview`:`Float preview over chat`,"aria-pressed":w?`true`:`false`,type:`button`,disabled:T}),children:(0,$.jsx)(we,{className:_(w&&`text-primary`)})}),(0,$.jsx)(ie,{children:w?`Close floating preview`:`Float preview over chat`})]}):null,t[81]=C,t[82]=w,t[83]=T,t[84]=Fe):Fe=t[84];let Ie;t[85]!==I||t[86]!==be||t[87]!==Me||t[88]!==Ne||t[89]!==Pe||t[90]!==Fe||t[91]!==te?(Ie=(0,$.jsxs)(`form`,{onSubmit:I,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[be,Me,Ne,Pe,Fe,te]}),t[85]=I,t[86]=be,t[87]=Me,t[88]=Ne,t[89]=Pe,t[90]=Fe,t[91]=te,t[92]=Ie):Ie=t[92];let Le;t[93]===a?Le=t[94]:(Le=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]=Le);let Re;return t[95]!==Ie||t[96]!==Le?(Re=(0,$.jsxs)(`div`,{className:`relative`,children:[Ie,Le]}),t[95]=Ie,t[96]=Le,t[97]=Re):Re=t[97],Re}function Xe(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 Ze(e){let t=(0,Q.c)(6),{className:n}=e,r;t[0]===n?r=t[1]:(r=_(`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 o;return t[4]===r?o=t[5]:(o=(0,$.jsxs)(`div`,{"aria-hidden":!0,className:r,children:[i,a]}),t[4]=r,t[5]=o),o}function Qe(e){let t=(0,Q.c)(17),{server:n,onOpen:r}=e,i;t[0]===n?i=t[1]:(i=$e(n),t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Ze,{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)(et,{}):(0,$.jsx)(tt,{}),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 $e(e){return e.processName?e.processName:e.listening?`Listening`:e.source===`configured`?`Configured`:`Recently seen`}function et(){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 tt(){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 nt(e){let t=(0,Q.c)(7),n=ve(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:Ee(e.environmentId,t.url)}),t[5]=e.environmentId,t[6]=i),r=rt({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 rt(e){let t=new Map;for(let n of e.configuredUrls){let e=at(n);if(!e)continue;let r=it(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=it(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=at(n);if(!e)continue;let r=it(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 it(e,t){return`${e.toLowerCase()}:${t}`}function at(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`||!Re(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 ot(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=nt(o);if(s.length===0){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(L,{children:[(0,$.jsx)(V,{variant:`icon`,children:(0,$.jsx)(J,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(U,{children:`No preview yet`}),(0,$.jsx)(Ce,{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)(He,{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)(Qe,{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 st=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function ct(e){let t=(0,Q.c)(74),{tabId:n,hasWebContents:r,zoomFactor:i,colorScheme:a,deviceToolbarVisible:s,onToggleDeviceToolbar:l,nativePictureInPicture:u,onNativePictureInPicture:d}=e;if(!I)return null;let f=!n||!r,p;t[0]===n?p=t[1]:(p=e=>()=>{n&&e(n).catch(gt)},t[0]=n,t[1]=p);let h=p,g;t[2]===i?g=t[3]:(g=Math.round(i*100),t[2]=i,t[3]=g);let _=`${g}%`,y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsxs)(o,{children:[(0,$.jsx)(c,{render:(0,$.jsx)(te,{render:(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(Be,{})}),(0,$.jsx)(ie,{children:`More`})]}),t[4]=y):y=t[4];let x;t[5]===h?x=t[6]:(x=h(I.hardReload),t[5]=h,t[6]=x);let C;t[7]!==x||t[8]!==f?(C=(0,$.jsx)(v,{onClick:x,disabled:f,children:`Hard reload`}),t[7]=x,t[8]=f,t[9]=C):C=t[9];let w;t[10]===h?w=t[11]:(w=h(I.openDevTools),t[10]=h,t[11]=w);let T;t[12]!==w||t[13]!==f?(T=(0,$.jsx)(v,{onClick:w,disabled:f,children:`Open DevTools`}),t[12]=w,t[13]=f,t[14]=T):T=t[14];let E=u?`Close separate preview window`:`Open separate preview window`,D;t[15]!==d||t[16]!==E||t[17]!==f?(D=(0,$.jsx)(v,{onClick:d,disabled:f,children:E}),t[15]=d,t[16]=E,t[17]=f,t[18]=D):D=t[18];let ee=s?`Hide device toolbar`:`Show device toolbar`,j;t[19]!==l||t[20]!==ee||t[21]!==f?(j=(0,$.jsx)(v,{onClick:l,disabled:f,children:ee}),t[19]=l,t[20]=ee,t[21]=f,t[22]=j):j=t[22];let re;t[23]===f?re=t[24]:(re=(0,$.jsx)(M,{disabled:f,children:`Appearance`}),t[23]=f,t[24]=re);let N;t[25]===n?N=t[26]:(N=e=>{n&&I.setColorScheme(n,e).catch(ht)},t[25]=n,t[26]=N);let P;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(P=st.map(mt),t[27]=P):P=t[27];let F;t[28]!==a||t[29]!==N?(F=(0,$.jsx)(S,{className:`min-w-32`,children:(0,$.jsx)(ne,{value:a,onValueChange:N,children:P})}),t[28]=a,t[29]=N,t[30]=F):F=t[30];let L;t[31]!==re||t[32]!==F?(L=(0,$.jsxs)(b,{children:[re,F]}),t[31]=re,t[32]=F,t[33]=L):L=t[33];let oe;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(O,{}),t[34]=oe):oe=t[34];let R;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(`span`,{children:`Zoom`}),t[35]=R):R=t[35];let z;t[36]===h?z=t[37]:(z=h(I.zoomOut),t[36]=h,t[37]=z);let se;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(le,{}),t[38]=se):se=t[38];let B;t[39]!==z||t[40]!==f?(B=(0,$.jsx)(m,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:z,"aria-label":`Zoom out`,disabled:f,children:se}),t[39]=z,t[40]=f,t[41]=B):B=t[41];let V;t[42]===_?V=t[43]:(V=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:_}),t[42]=_,t[43]=V);let ce;t[44]===h?ce=t[45]:(ce=h(I.zoomIn),t[44]=h,t[45]=ce);let H;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(ae,{}),t[46]=H):H=t[46];let U;t[47]!==ce||t[48]!==f?(U=(0,$.jsx)(m,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:ce,"aria-label":`Zoom in`,disabled:f,children:H}),t[47]=ce,t[48]=f,t[49]=U):U=t[49];let W;t[50]===h?W=t[51]:(W=h(I.resetZoom),t[50]=h,t[51]=W);let G;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(ue,{}),t[52]=G):G=t[52];let K;t[53]!==W||t[54]!==f?(K=(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:W,"aria-label":`Reset zoom`,disabled:f,children:G}),t[53]=W,t[54]=f,t[55]=K):K=t[55];let q;t[56]!==B||t[57]!==V||t[58]!==U||t[59]!==K?(q=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[B,V,U,K]}),t[56]=B,t[57]=V,t[58]=U,t[59]=K,t[60]=q):q=t[60];let J;t[61]!==q||t[62]!==f?(J=(0,$.jsxs)(v,{closeOnClick:!1,onClick:pt,className:`justify-between`,disabled:f,children:[R,q]}),t[61]=q,t[62]=f,t[63]=J):J=t[63];let de,fe,pe;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(O,{}),fe=(0,$.jsx)(v,{onClick:dt,children:`Clear cookies`}),pe=(0,$.jsx)(v,{onClick:lt,children:`Clear cache`}),t[64]=de,t[65]=fe,t[66]=pe):(de=t[64],fe=t[65],pe=t[66]);let me;return t[67]!==j||t[68]!==L||t[69]!==J||t[70]!==C||t[71]!==T||t[72]!==D?(me=(0,$.jsxs)(k,{children:[y,(0,$.jsxs)(A,{align:`end`,sideOffset:6,className:`min-w-56`,children:[C,T,D,j,L,oe,J,de,fe,pe]})]}),t[67]=j,t[68]=L,t[69]=J,t[70]=C,t[71]=T,t[72]=D,t[73]=me):me=t[73],me}function lt(){I.clearCache().catch(ut)}function ut(){}function dt(){I.clearCookies().catch(ft)}function ft(){}function pt(e){return e.preventDefault()}function mt(e){return(0,$.jsx)(y,{value:e.value,children:e.label},e.value)}function ht(){}function gt(){}function _t(e){return he[e]||(e.length>0?e:`Network error`)}function vt(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=xt(n)??n,t[0]=n,t[1]=c);let l=c,u;t[2]===i?u=t[3]:(u=_t(i),t[2]=i,t[3]=u);let d=u,f;t[4]!==r||t[5]!==i?(f=i.length>0?i:`ERR_${Math.abs(r)||`FAILED`}`,t[4]=r,t[5]=i,t[6]=f):f=t[6];let p=f,h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(bt,{className:`mb-6 size-12 text-muted-foreground/70`}),g=(0,$.jsx)(`h1`,{className:`mb-3 text-2xl font-semibold leading-tight text-foreground`,children:`This site can’t be reached`}),t[7]=h,t[8]=g):(h=t[7],g=t[8]);let _;t[9]===l?_=t[10]:(_=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:l}),t[9]=l,t[10]=_);let v;t[11]!==d||t[12]!==_?(v=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[_,`: `,d,`.`]}),t[11]=d,t[12]=_,t[13]=v):v=t[13];let y;t[14]===o?y=t[15]:(y=o?(0,$.jsxs)(`div`,{className:`mt-6 rounded-lg border border-border bg-muted/40 p-4 text-sm`,children:[(0,$.jsx)(`p`,{className:`mb-2 font-medium text-foreground`,children:`Try:`}),(0,$.jsxs)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:[(0,$.jsx)(`li`,{children:`Checking your connection`}),(0,$.jsx)(`li`,{children:`Confirming the dev server is running`}),(0,$.jsx)(`li`,{children:`Checking the proxy and the firewall`})]})]}):null,t[14]=o,t[15]=y);let b;t[16]===p?b=t[17]:(b=(0,$.jsx)(`div`,{className:`mt-8 text-xs uppercase tracking-wide text-muted-foreground/70`,children:p}),t[16]=p,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>s(yt),t[18]=x):x=t[18];let S=o?`Hide details`:`Details`,C;t[19]===S?C=t[20]:(C=(0,$.jsx)(m,{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)(m,{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 yt(e){return!e}function bt(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 xt(e){try{return new URL(e).host}catch{return null}}function St(e){let t=e.toLowerCase();return t.includes(`mac`)?`Reveal in Finder`:t.includes(`win`)?`Reveal in File Explorer`:`Reveal in Files`}var Ct=120,wt=220,Tt=4,Et=90,Dt=.08,Ot=.5;function kt(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),wt);return()=>window.clearTimeout(e)}n(e=>e>0&&e<95?e:Tt);let t=window.setInterval(()=>{let e=r.current;if(e>=Et)return;let t=Et-e,i=Math.max(Ot,t*Dt);n(Math.min(Et,e+i))},Ct);return()=>window.clearInterval(t)},[e]),t}var At=class extends h()(`PreviewSessionThreadKeyParseError`,{threadKey:g}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},jt=j(e=>{let t=l(e);if(t===null)throw new At({threadKey:e});let n=je.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=je.events({environmentId:t.environmentId,input:{}});return T(e=>{let i=!1,a=0,o=e=>{s(e)&&xe(t,e.value)},c=r=>{if(!s(r)||r.value.threadId!==t.threadId)return;let i=Ne(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}Le(t,r.value)};e.addFinalizer(()=>{i=!0});let l=e.once(r);e.subscribe(n,e=>{o(e)}),e.subscribe(r,e=>{a+=1,c(e)}),queueMicrotask(()=>{i||(e.refresh(n),a===0&&c(l))})}).pipe(w(1e3),N(`preview:session-sync:${e}`))});function Mt(e){let t=(0,Q.c)(2),n;t[0]===e?n=t[1]:(n=jt(a(e)),t[0]=e,t[1]=n),u(n)}var Nt=1500,Pt=.001;function Ft(e){let t=(0,Q.c)(11),{zoomFactor:n}=e,[r,i]=(0,Z.useState)(!1),a=(0,Z.useRef)(n),o=(0,Z.useRef)(null),s,c;t[0]===n?(s=t[1],c=t[2]):(s=()=>{if(!(Math.abs(a.current-n)<Pt))return a.current=n,i(!0),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{i(!1),o.current=null},Nt),()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)}},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,Z.useEffect)(s,c);let l;t[3]===n?l=t[4]:(l=Math.round(n*100),t[3]=n,t[4]=l);let u=`${l}%`,d=!r,f=r?`opacity-100 translate-y-0`:`opacity-0 -translate-y-1`,p;t[5]===f?p=t[6]:(p=_(`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`,f),t[5]=f,t[6]=p);let m;return t[7]!==u||t[8]!==d||t[9]!==p?(m=(0,$.jsx)(`div`,{"aria-hidden":d,className:p,children:u}),t[7]=u,t[8]=d,t[9]=p,t[10]=m):m=t[10],m}function It(e,t){return e?1:t===`human`?.18:.35}var Lt=700;function Rt(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=me(a),s;t[2]===n?s=t[3]:(s=e=>e.byTabId[n]?.content??null,t[2]=n,t[3]=s);let c=R(s);if(!o)return null;let l;return t[4]!==c||t[5]!==i||t[6]!==o||t[7]!==r?(l=(0,$.jsx)(zt,{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 zt(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),Lt);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=It(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)(Ve,{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 Bt=typeof window>`u`?null:d();function Vt({threadRef:e,tabId:t,configuredUrls:n,visible:r}){let[o,s]=(0,Z.useState)(void 0),[c,l]=(0,Z.useState)(!1),u=ke(),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(!0),m=Fe(e),h=B(t=>Se(t.byThreadKey,e)),g=D(e=>e.addPreviewAnnotation),_=D(e=>e.addImage),v=ee(e.environmentId),y=i(e.environmentId),b=p(je.open),S=p(je.resize,`preview viewport resize`),{resolvedTheme:w}=re();Mt(e),(0,Z.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let T=t??m.activeTabId,O=T?H(e,m.serverEpoch,T):null,te=T&&O?u.has(O)?O:Me(e,T):null,k=T?m.sessions[T]??null:null,A=T?m.desktopByTabId[T]??null:null,j=k?.navStatus??{_tag:`Idle`},M=j._tag===`Idle`?``:j.url,ne=A?.loading??j._tag===`Loading`,N=A?.canGoBack??k?.canGoBack??!1,ie=A?.canGoForward??k?.canGoForward??!1,P=j._tag===`Idle`,F=j._tag===`LoadFailed`,L=Te(k),ae=A?.controller??`none`,oe=kt(ne),se=M&&v&&y?Xe({url:M,environmentLabel:v.label,environmentHttpBaseUrl:y})??void 0:void 0,V=k?.viewport??x,ce=R(e=>O?e.byTabId[O]?.rect??null:null),U=(0,Z.useCallback)(async t=>{O&&I?(await I.navigate(O,t),pe(e,t)):await _e({openPreview:b,threadRef:e,url:t})},[b,O,e]),le=(0,Z.useCallback)(async e=>{try{await U(ge(e))}catch{}},[U]),W=(0,Z.useCallback)(async t=>{try{await U(Ee(e.environmentId,t))}catch{}},[U,e.environmentId]),ue=(0,Z.useCallback)(()=>{I&&O&&I.refresh(O)},[O]),q=(0,Z.useCallback)(()=>{I&&O&&I.zoomIn(O)},[O]),J=(0,Z.useCallback)(()=>{I&&O&&I.zoomOut(O)},[O]),de=(0,Z.useCallback)(()=>{I&&O&&I.resetZoom(O)},[O]),me=(0,Z.useCallback)(async t=>{if(!T)return;let n=await S({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:T,viewport:t}});if(n._tag===`Failure`){let e=E(n);throw X.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}Ae(e,n.value)},[S,T,e]),he=()=>{if(!O)return;if(V._tag!==`fill`){Ie(O,x).catch(()=>void 0);return}let e=ce?Pe(ce,A?.zoomFactor):{width:1024,height:768};Ie(O,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Z.useEffect)(()=>{if(O)return De(O,me)},[me,O]);let ve=(0,Z.useCallback)(()=>{I&&O&&I.goBack(O)},[O]),xe=(0,Z.useCallback)(()=>{I&&O&&I.goForward(O)},[O]),Ce=(0,Z.useCallback)(()=>{!Bt||!M||Bt.shell.openExternal(M).catch(()=>void 0)},[M]),we=(0,Z.useCallback)(()=>{if(T){if(h?.tabId===T){B.getState().close(e);return}B.getState().open(e,T),C.getState().close(e)}},[h?.tabId,T,e]),Oe=(0,Z.useCallback)(()=>{!I||!O||(A?.pictureInPicture?I.pictureInPicture.close:I.pictureInPicture.open)(O).catch(e=>{X.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[A?.pictureInPicture,O]),Ne=(0,Z.useCallback)(t=>{if(!I||!O||!T)return;let n=I;if(te){fe(te).then(e=>{if(!e)return;let t=!1,r,i=()=>{if(!navigator.clipboard?.writeText){X.update(r,Y({type:`error`,title:`Unable to copy recording path`,description:`Clipboard API unavailable.`,actionProps:a}));return}navigator.clipboard.writeText(e.path).then(()=>{t=!0,o(),window.setTimeout(()=>{t=!1,o()},2e3)},e=>{X.update(r,Y({type:`error`,title:`Unable to copy recording path`,description:e instanceof Error?e.message:`An error occurred.`,actionProps:a}))})},a={children:St(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},o=()=>{X.update(r,Y({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:t?`Copied!`:`Copy path`,disabled:t,onClick:i},secondaryActionVariant:`outline`}}))};r=X.add(Y({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(t){be(O,e,T).catch(e=>{X.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}n.captureScreenshot(O).then(e=>{let t={children:St(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,n=`Screenshot saved`,o)=>{X.update(a,Y({type:e,title:n,description:o,actionProps:{children:i?`Copied!`:`Copy image`,disabled:i,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:r?`Copied!`:`Copy path`,disabled:r,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},s=()=>{if(!navigator.clipboard?.writeText){o(`error`,`Unable to copy screenshot path`,`Clipboard API unavailable.`);return}navigator.clipboard.writeText(e.path).then(()=>{r=!0,o(),window.setTimeout(()=>{r=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot path`,e instanceof Error?e.message:`An error occurred.`)})},c=()=>{n.copyArtifactToClipboard(e.path).then(()=>{i=!0,o(),window.setTimeout(()=>{i=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot`,e instanceof Error?e.message:`An error occurred.`)})};a=X.add(Y({type:`success`,title:`Screenshot saved`,actionProps:{children:`Copy image`,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:`Copy path`,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},e=>{X.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[te,O,T,e]),Le=(0,Z.useCallback)(()=>{if(!I||!O)return;if(d.current){I.cancelPickElement(O).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;d.current=!0,l(!0),(async()=>{try{let t=await I.pickElement(O);if(!t)return;g(e,t);let n=await ye(t);n&&t.screenshot&&_(e,{type:`image`,id:t.id,name:n.name,mimeType:n.type,sizeBytes:n.size,previewUrl:t.screenshot.dataUrl,file:n})}catch{}finally{if(d.current=!1,f.current&&l(!1),t&&t.isConnected&&typeof t.focus==`function`)try{t.focus({preventScroll:!0})}catch{}}})()},[_,g,O,e]);return(0,Z.useEffect)(()=>{let e=z(M,w);e&&U(e).catch(()=>void 0)},[U,w,M]),(0,Z.useEffect)(()=>()=>{d.current&&(d.current=!1,I&&O&&I.cancelPickElement(O).catch(()=>void 0),f.current&&l(!1))},[O]),(0,Z.useEffect)(()=>{if(r)return K(e=>{switch(e){case`refresh`:ue();return;case`focus-url`:s(e=>(e??0)+1);return;case`zoom-in`:q();return;case`zoom-out`:J();return;case`reset-zoom`:de();return;case`toggle-panel`:return}})},[ue,de,q,J,r]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":a(e),children:[(0,$.jsx)(Ye,{url:M,displayUrl:se,loading:ne,loadProgress:oe,canGoBack:N,canGoForward:ie,refreshDisabled:P,focusUrlNonce:o,onBack:ve,onForward:xe,onRefresh:ue,onSubmit:e=>void le(e),onOpenInBrowser:T?Ce:void 0,onCapture:I&&T?Ne:void 0,captureDisabled:!A||F,recording:te!==null,onPictureInPicture:I&&T?we:void 0,pictureInPicture:h?.tabId===T,pictureInPictureDisabled:!A?.hasWebContents||F,onPickElement:I&&T?Le:void 0,pickActive:c,pickDisabled:!T||F,pickDisabledReason:F?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:I?(0,$.jsx)(ct,{tabId:O,hasWebContents:A?.hasWebContents??!1,zoomFactor:A?.zoomFactor??1,colorScheme:A?.colorScheme??`system`,deviceToolbarVisible:V._tag!==`fill`,onToggleDeviceToolbar:he,nativePictureInPicture:A?.pictureInPicture??!1,onNativePictureInPicture:Oe}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[O&&k&&!L?(0,$.jsx)(G,{tabId:O,visible:r&&!F,className:`absolute inset-0 h-full w-full`},O):null,L?(0,$.jsx)(ot,{environmentId:e.environmentId,configuredUrls:n,recentlySeenUrls:m.recentlySeenUrls,onOpenUrl:e=>void W(e)}):null,k&&A?(0,$.jsx)(Ft,{zoomFactor:A.zoomFactor}):null,O&&A&&!L&&!F?(0,$.jsx)(Rt,{tabId:O,zoomFactor:A.zoomFactor,controller:ae}):null,ae===`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:ae===`agent`?`Agent controlling browser`:`Human control`}),j._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(vt,{url:j.url,code:j.code,description:j.description,onReload:ue})}):null]})]})}function Ht(e){let t=(0,Q.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!Oe()){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)(W,{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)(Vt,{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)(W,{mode:n,children:c}),t[10]=n,t[11]=c,t[12]=l):l=t[12],l}export{Ht as PreviewPanel};
|
|
2
|
-
//# sourceMappingURL=PreviewPanel-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{A as i,Ac as a,C as o,Cc as s,E as c,Ec as l,Hs as u,I as d,Is as f,O as p,Qr as m,Uu as h,Vu as g,Wt as _,ai as v,ci as y,di as b,dl as x,fi as S,g as C,gc as w,hc as T,ic as E,in as D,k as ee,li as O,mi as te,ni as k,oi as A,pc as j,pi as M,si as ne,u as re,vc as N,w as ie,ws as P}from"./terminal-links-CUeLECEE.js";import{t as F}from"./arrow-right-BfH3g256.js";import{A as I,An as L,Ar as ae,Dr as oe,F as R,G as z,Gr as se,M as B,Mn as V,Mr as ce,N as H,Nn as U,Nr as le,O as W,Or as ue,P as G,Pn as K,Qn as q,Rr as J,Vr as de,a as fe,ar as pe,c as me,cr as he,dr as ge,er as _e,fr as ve,g as ye,hr as Y,i as be,ir as xe,j as Se,jn as Ce,jr as we,k as Te,lr as Ee,mr as X,n as De,nr as Oe,o as ke,or as Ae,pr as je,r as Me,rr as Ne,s as Pe,sr as Fe,t as Ie,tr as Le,ur as Re}from"./index-oXAJjTce.js";var ze=P(`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`}]]),Be=P(`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`}]]),Ve=P(`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`}]]),He=P(`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=e(n(),1),Q=r(),$=t();function Ue(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=_(`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 We=f(`[&_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 Ge(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,o;t[4]!==a||t[5]!==n?(o=_(We({align:a}),n),t[4]=a,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,$.jsx)(`div`,{className:o,"data-align":a,"data-slot":`input-group-addon`,onMouseDown:Ke,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function Ke(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 qe(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)(q,{className:n,unstyled:!0,...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}var Je=()=>{};function Ye(e){let t=(0,Q.c)(98),{url:n,displayUrl:r,loading:i,loadProgress:a,canGoBack:s,canGoForward:l,refreshDisabled:u,inputDisabled:d,focusUrlNonce:f,onBack:p,onForward:h,onRefresh:g,onSubmit:v,onOpenInBrowser:y,onCapture:b,captureDisabled:x,recording:S,onPictureInPicture:C,pictureInPicture:w,pictureInPictureDisabled:T,onPickElement:E,pickActive:D,pickDisabled:ee,pickDisabledReason:O,trailingActions:te}=e,k=(0,Z.useRef)(null),[A,j]=(0,Z.useState)(n),[M,ne]=(0,Z.useState)(!1),re,N;t[0]===f?(re=t[1],N=t[2]):(re=()=>{if(f==null)return;let e=k.current;e&&e.focus()},N=[f],t[0]=f,t[1]=re,t[2]=N),(0,Z.useEffect)(re,N);let P;t[3]!==A||t[4]!==v?(P=e=>{e?.preventDefault();let t=A.trim();t.length!==0&&(v(t),k.current?.blur())},t[3]=A,t[4]=v,t[5]=P):P=t[5];let I=P,L=s?p:Je,ae=!s,R;t[6]!==L||t[7]!==ae?(R=(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,onClick:L,disabled:ae,"aria-label":`Back`,type:`button`}),t[6]=L,t[7]=ae,t[8]=R):R=t[8];let z;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(se,{}),t[9]=z):z=t[9];let B;t[10]===R?B=t[11]:(B=(0,$.jsx)(c,{render:R,children:z}),t[10]=R,t[11]=B);let V;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(ie,{children:`Back`}),t[12]=V):V=t[12];let H;t[13]===B?H=t[14]:(H=(0,$.jsxs)(o,{children:[B,V]}),t[13]=B,t[14]=H);let U=l?h:Je,le=!l,W;t[15]!==U||t[16]!==le?(W=(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,onClick:U,disabled:le,"aria-label":`Forward`,type:`button`}),t[15]=U,t[16]=le,t[17]=W):W=t[17];let ue;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(F,{}),t[18]=ue):ue=t[18];let G;t[19]===W?G=t[20]:(G=(0,$.jsx)(c,{render:W,children:ue}),t[19]=W,t[20]=G);let K;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(ie,{children:`Forward`}),t[21]=K):K=t[21];let q;t[22]===G?q=t[23]:(q=(0,$.jsxs)(o,{children:[G,K]}),t[22]=G,t[23]=q);let J=u?Je:g,fe=i?`Stop`:`Refresh`,pe;t[24]!==u||t[25]!==J||t[26]!==fe?(pe=(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,onClick:J,disabled:u,"aria-label":fe,type:`button`}),t[24]=u,t[25]=J,t[26]=fe,t[27]=pe):pe=t[27];let me=i&&`animate-spin`,he;t[28]===me?he=t[29]:(he=_(me),t[28]=me,t[29]=he);let ge;t[30]===he?ge=t[31]:(ge=(0,$.jsx)(oe,{className:he}),t[30]=he,t[31]=ge);let _e;t[32]!==pe||t[33]!==ge?(_e=(0,$.jsx)(c,{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)(ie,{children:ve}),t[35]=ve,t[36]=ye);let Y;t[37]!==_e||t[38]!==ye?(Y=(0,$.jsxs)(o,{children:[_e,ye]}),t[37]=_e,t[38]=ye,t[39]=Y):Y=t[39];let be;t[40]!==H||t[41]!==q||t[42]!==Y?(be=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[H,q,Y]}),t[40]=H,t[41]=q,t[42]=Y,t[43]=be):be=t[43];let xe=M?A:r??n,Se=y&&!M&&`group-hover/address:pe-7 transition-[padding]`,Ce;t[44]===Se?Ce=t[45]:(Ce=_(Se),t[44]=Se,t[45]=Ce);let Te;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>j(e.target.value),t[46]=Te):Te=t[46];let Ee;t[47]===n?Ee=t[48]:(Ee=()=>{j(n),ne(!0),queueMicrotask(()=>k.current?.select())},t[47]=n,t[48]=Ee);let X;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(X=()=>{ne(!1)},t[49]=X):X=t[49];let De;t[50]!==I||t[51]!==n?(De=e=>{e.key===`Enter`&&I(e),e.key===`Escape`&&(e.preventDefault(),j(n),k.current?.blur())},t[50]=I,t[51]=n,t[52]=De):De=t[52];let Oe;t[53]!==d||t[54]!==xe||t[55]!==Ce||t[56]!==Ee||t[57]!==De?(Oe=(0,$.jsx)(c,{render:(0,$.jsx)(qe,{ref:k,value:xe,className:Ce,onChange:Te,onFocus:Ee,onBlur:X,onKeyDown:De,placeholder:`Search or enter URL`,spellCheck:!1,disabled:d,"data-preview-url-input":!0,size:`sm`})}),t[53]=d,t[54]=xe,t[55]=Ce,t[56]=Ee,t[57]=De,t[58]=Oe):Oe=t[58];let ke;t[59]!==r||t[60]!==M||t[61]!==n?(ke=!M&&r?(0,$.jsx)(ie,{children:n}):null,t[59]=r,t[60]=M,t[61]=n,t[62]=ke):ke=t[62];let Ae;t[63]!==Oe||t[64]!==ke?(Ae=(0,$.jsxs)(o,{children:[Oe,ke]}),t[63]=Oe,t[64]=ke,t[65]=Ae):Ae=t[65];let je;t[66]!==M||t[67]!==y?(je=y&&!M?(0,$.jsx)(Ge,{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)(o,{children:[(0,$.jsx)(c,{render:(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,onClick:y,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(de,{})}),(0,$.jsx)(ie,{children:`Open in system browser`})]})}):null,t[66]=M,t[67]=y,t[68]=je):je=t[68];let Me;t[69]!==Ae||t[70]!==je?(Me=(0,$.jsxs)(Ue,{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:[Ae,je]}),t[69]=Ae,t[70]=je,t[71]=Me):Me=t[71];let Ne;t[72]!==E||t[73]!==D||t[74]!==ee||t[75]!==O?(Ne=E?(0,$.jsxs)(o,{children:[(0,$.jsx)(c,{render:(0,$.jsx)(m,{variant:D?`secondary`:`ghost`,size:`icon-xs`,onClick:E,disabled:ee,"aria-label":D?`Cancel annotation`:`Annotate preview`,"aria-pressed":D?`true`:`false`,type:`button`}),children:(0,$.jsx)(ce,{className:_(D&&`text-primary`)})}),(0,$.jsx)(ie,{children:ee&&O?O:D?`Cancel annotation (Esc)`:`Annotate elements, regions, and drawings`})]}):null,t[72]=E,t[73]=D,t[74]=ee,t[75]=O,t[76]=Ne):Ne=t[76];let Pe;t[77]!==x||t[78]!==b||t[79]!==S?(Pe=b?(0,$.jsxs)(o,{children:[(0,$.jsxs)(c,{render:(0,$.jsx)(m,{variant:S?`secondary`:`ghost`,size:`icon-xs`,onClick:e=>b(e.shiftKey),"aria-label":S?`Stop recording`:`Capture screenshot`,type:`button`,className:`relative`,disabled:x}),children:[(0,$.jsx)(ze,{className:_(S&&`text-destructive`)}),S?(0,$.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 animate-status-pulse rounded-full bg-destructive`}):null]}),(0,$.jsx)(ie,{children:S?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[77]=x,t[78]=b,t[79]=S,t[80]=Pe):Pe=t[80];let Fe;t[81]!==C||t[82]!==w||t[83]!==T?(Fe=C?(0,$.jsxs)(o,{children:[(0,$.jsx)(c,{render:(0,$.jsx)(m,{variant:w?`secondary`:`ghost`,size:`icon-xs`,onClick:C,"aria-label":w?`Close floating preview`:`Float preview over chat`,"aria-pressed":w?`true`:`false`,type:`button`,disabled:T}),children:(0,$.jsx)(we,{className:_(w&&`text-primary`)})}),(0,$.jsx)(ie,{children:w?`Close floating preview`:`Float preview over chat`})]}):null,t[81]=C,t[82]=w,t[83]=T,t[84]=Fe):Fe=t[84];let Ie;t[85]!==I||t[86]!==be||t[87]!==Me||t[88]!==Ne||t[89]!==Pe||t[90]!==Fe||t[91]!==te?(Ie=(0,$.jsxs)(`form`,{onSubmit:I,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[be,Me,Ne,Pe,Fe,te]}),t[85]=I,t[86]=be,t[87]=Me,t[88]=Ne,t[89]=Pe,t[90]=Fe,t[91]=te,t[92]=Ie):Ie=t[92];let Le;t[93]===a?Le=t[94]:(Le=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]=Le);let Re;return t[95]!==Ie||t[96]!==Le?(Re=(0,$.jsxs)(`div`,{className:`relative`,children:[Ie,Le]}),t[95]=Ie,t[96]=Le,t[97]=Re):Re=t[97],Re}function Xe(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 Ze(e){let t=(0,Q.c)(6),{className:n}=e,r;t[0]===n?r=t[1]:(r=_(`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 o;return t[4]===r?o=t[5]:(o=(0,$.jsxs)(`div`,{"aria-hidden":!0,className:r,children:[i,a]}),t[4]=r,t[5]=o),o}function Qe(e){let t=(0,Q.c)(17),{server:n,onOpen:r}=e,i;t[0]===n?i=t[1]:(i=$e(n),t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Ze,{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)(et,{}):(0,$.jsx)(tt,{}),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 $e(e){return e.processName?e.processName:e.listening?`Listening`:e.source===`configured`?`Configured`:`Recently seen`}function et(){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 tt(){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 nt(e){let t=(0,Q.c)(7),n=ve(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:Ee(e.environmentId,t.url)}),t[5]=e.environmentId,t[6]=i),r=rt({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 rt(e){let t=new Map;for(let n of e.configuredUrls){let e=at(n);if(!e)continue;let r=it(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=it(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=at(n);if(!e)continue;let r=it(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 it(e,t){return`${e.toLowerCase()}:${t}`}function at(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`||!Re(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 ot(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=nt(o);if(s.length===0){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(L,{children:[(0,$.jsx)(V,{variant:`icon`,children:(0,$.jsx)(J,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(U,{children:`No preview yet`}),(0,$.jsx)(Ce,{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)(He,{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)(Qe,{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 st=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function ct(e){let t=(0,Q.c)(74),{tabId:n,hasWebContents:r,zoomFactor:i,colorScheme:a,deviceToolbarVisible:s,onToggleDeviceToolbar:l,nativePictureInPicture:u,onNativePictureInPicture:d}=e;if(!I)return null;let f=!n||!r,p;t[0]===n?p=t[1]:(p=e=>()=>{n&&e(n).catch(gt)},t[0]=n,t[1]=p);let h=p,g;t[2]===i?g=t[3]:(g=Math.round(i*100),t[2]=i,t[3]=g);let _=`${g}%`,y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsxs)(o,{children:[(0,$.jsx)(c,{render:(0,$.jsx)(te,{render:(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(Be,{})}),(0,$.jsx)(ie,{children:`More`})]}),t[4]=y):y=t[4];let x;t[5]===h?x=t[6]:(x=h(I.hardReload),t[5]=h,t[6]=x);let C;t[7]!==x||t[8]!==f?(C=(0,$.jsx)(v,{onClick:x,disabled:f,children:`Hard reload`}),t[7]=x,t[8]=f,t[9]=C):C=t[9];let w;t[10]===h?w=t[11]:(w=h(I.openDevTools),t[10]=h,t[11]=w);let T;t[12]!==w||t[13]!==f?(T=(0,$.jsx)(v,{onClick:w,disabled:f,children:`Open DevTools`}),t[12]=w,t[13]=f,t[14]=T):T=t[14];let E=u?`Close separate preview window`:`Open separate preview window`,D;t[15]!==d||t[16]!==E||t[17]!==f?(D=(0,$.jsx)(v,{onClick:d,disabled:f,children:E}),t[15]=d,t[16]=E,t[17]=f,t[18]=D):D=t[18];let ee=s?`Hide device toolbar`:`Show device toolbar`,j;t[19]!==l||t[20]!==ee||t[21]!==f?(j=(0,$.jsx)(v,{onClick:l,disabled:f,children:ee}),t[19]=l,t[20]=ee,t[21]=f,t[22]=j):j=t[22];let re;t[23]===f?re=t[24]:(re=(0,$.jsx)(M,{disabled:f,children:`Appearance`}),t[23]=f,t[24]=re);let N;t[25]===n?N=t[26]:(N=e=>{n&&I.setColorScheme(n,e).catch(ht)},t[25]=n,t[26]=N);let P;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(P=st.map(mt),t[27]=P):P=t[27];let F;t[28]!==a||t[29]!==N?(F=(0,$.jsx)(S,{className:`min-w-32`,children:(0,$.jsx)(ne,{value:a,onValueChange:N,children:P})}),t[28]=a,t[29]=N,t[30]=F):F=t[30];let L;t[31]!==re||t[32]!==F?(L=(0,$.jsxs)(b,{children:[re,F]}),t[31]=re,t[32]=F,t[33]=L):L=t[33];let oe;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(O,{}),t[34]=oe):oe=t[34];let R;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(`span`,{children:`Zoom`}),t[35]=R):R=t[35];let z;t[36]===h?z=t[37]:(z=h(I.zoomOut),t[36]=h,t[37]=z);let se;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(le,{}),t[38]=se):se=t[38];let B;t[39]!==z||t[40]!==f?(B=(0,$.jsx)(m,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:z,"aria-label":`Zoom out`,disabled:f,children:se}),t[39]=z,t[40]=f,t[41]=B):B=t[41];let V;t[42]===_?V=t[43]:(V=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:_}),t[42]=_,t[43]=V);let ce;t[44]===h?ce=t[45]:(ce=h(I.zoomIn),t[44]=h,t[45]=ce);let H;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(ae,{}),t[46]=H):H=t[46];let U;t[47]!==ce||t[48]!==f?(U=(0,$.jsx)(m,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:ce,"aria-label":`Zoom in`,disabled:f,children:H}),t[47]=ce,t[48]=f,t[49]=U):U=t[49];let W;t[50]===h?W=t[51]:(W=h(I.resetZoom),t[50]=h,t[51]=W);let G;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(ue,{}),t[52]=G):G=t[52];let K;t[53]!==W||t[54]!==f?(K=(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:W,"aria-label":`Reset zoom`,disabled:f,children:G}),t[53]=W,t[54]=f,t[55]=K):K=t[55];let q;t[56]!==B||t[57]!==V||t[58]!==U||t[59]!==K?(q=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[B,V,U,K]}),t[56]=B,t[57]=V,t[58]=U,t[59]=K,t[60]=q):q=t[60];let J;t[61]!==q||t[62]!==f?(J=(0,$.jsxs)(v,{closeOnClick:!1,onClick:pt,className:`justify-between`,disabled:f,children:[R,q]}),t[61]=q,t[62]=f,t[63]=J):J=t[63];let de,fe,pe;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(O,{}),fe=(0,$.jsx)(v,{onClick:dt,children:`Clear cookies`}),pe=(0,$.jsx)(v,{onClick:lt,children:`Clear cache`}),t[64]=de,t[65]=fe,t[66]=pe):(de=t[64],fe=t[65],pe=t[66]);let me;return t[67]!==j||t[68]!==L||t[69]!==J||t[70]!==C||t[71]!==T||t[72]!==D?(me=(0,$.jsxs)(k,{children:[y,(0,$.jsxs)(A,{align:`end`,sideOffset:6,className:`min-w-56`,children:[C,T,D,j,L,oe,J,de,fe,pe]})]}),t[67]=j,t[68]=L,t[69]=J,t[70]=C,t[71]=T,t[72]=D,t[73]=me):me=t[73],me}function lt(){I.clearCache().catch(ut)}function ut(){}function dt(){I.clearCookies().catch(ft)}function ft(){}function pt(e){return e.preventDefault()}function mt(e){return(0,$.jsx)(y,{value:e.value,children:e.label},e.value)}function ht(){}function gt(){}function _t(e){return he[e]||(e.length>0?e:`Network error`)}function vt(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=xt(n)??n,t[0]=n,t[1]=c);let l=c,u;t[2]===i?u=t[3]:(u=_t(i),t[2]=i,t[3]=u);let d=u,f;t[4]!==r||t[5]!==i?(f=i.length>0?i:`ERR_${Math.abs(r)||`FAILED`}`,t[4]=r,t[5]=i,t[6]=f):f=t[6];let p=f,h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(bt,{className:`mb-6 size-12 text-muted-foreground/70`}),g=(0,$.jsx)(`h1`,{className:`mb-3 text-2xl font-semibold leading-tight text-foreground`,children:`This site can’t be reached`}),t[7]=h,t[8]=g):(h=t[7],g=t[8]);let _;t[9]===l?_=t[10]:(_=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:l}),t[9]=l,t[10]=_);let v;t[11]!==d||t[12]!==_?(v=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[_,`: `,d,`.`]}),t[11]=d,t[12]=_,t[13]=v):v=t[13];let y;t[14]===o?y=t[15]:(y=o?(0,$.jsxs)(`div`,{className:`mt-6 rounded-lg border border-border bg-muted/40 p-4 text-sm`,children:[(0,$.jsx)(`p`,{className:`mb-2 font-medium text-foreground`,children:`Try:`}),(0,$.jsxs)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:[(0,$.jsx)(`li`,{children:`Checking your connection`}),(0,$.jsx)(`li`,{children:`Confirming the dev server is running`}),(0,$.jsx)(`li`,{children:`Checking the proxy and the firewall`})]})]}):null,t[14]=o,t[15]=y);let b;t[16]===p?b=t[17]:(b=(0,$.jsx)(`div`,{className:`mt-8 text-xs uppercase tracking-wide text-muted-foreground/70`,children:p}),t[16]=p,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>s(yt),t[18]=x):x=t[18];let S=o?`Hide details`:`Details`,C;t[19]===S?C=t[20]:(C=(0,$.jsx)(m,{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)(m,{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 yt(e){return!e}function bt(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 xt(e){try{return new URL(e).host}catch{return null}}function St(e){let t=e.toLowerCase();return t.includes(`mac`)?`Reveal in Finder`:t.includes(`win`)?`Reveal in File Explorer`:`Reveal in Files`}var Ct=120,wt=220,Tt=4,Et=90,Dt=.08,Ot=.5;function kt(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),wt);return()=>window.clearTimeout(e)}n(e=>e>0&&e<95?e:Tt);let t=window.setInterval(()=>{let e=r.current;if(e>=Et)return;let t=Et-e,i=Math.max(Ot,t*Dt);n(Math.min(Et,e+i))},Ct);return()=>window.clearInterval(t)},[e]),t}var At=class extends h()(`PreviewSessionThreadKeyParseError`,{threadKey:g}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},jt=j(e=>{let t=l(e);if(t===null)throw new At({threadKey:e});let n=je.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=je.events({environmentId:t.environmentId,input:{}});return T(e=>{let i=!1,a=0,o=e=>{s(e)&&xe(t,e.value)},c=r=>{if(!s(r)||r.value.threadId!==t.threadId)return;let i=Ne(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}Le(t,r.value)};e.addFinalizer(()=>{i=!0});let l=e.once(r);e.subscribe(n,e=>{o(e)}),e.subscribe(r,e=>{a+=1,c(e)}),queueMicrotask(()=>{i||(e.refresh(n),a===0&&c(l))})}).pipe(w(1e3),N(`preview:session-sync:${e}`))});function Mt(e){let t=(0,Q.c)(2),n;t[0]===e?n=t[1]:(n=jt(a(e)),t[0]=e,t[1]=n),u(n)}var Nt=1500,Pt=.001;function Ft(e){let t=(0,Q.c)(11),{zoomFactor:n}=e,[r,i]=(0,Z.useState)(!1),a=(0,Z.useRef)(n),o=(0,Z.useRef)(null),s,c;t[0]===n?(s=t[1],c=t[2]):(s=()=>{if(!(Math.abs(a.current-n)<Pt))return a.current=n,i(!0),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{i(!1),o.current=null},Nt),()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)}},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,Z.useEffect)(s,c);let l;t[3]===n?l=t[4]:(l=Math.round(n*100),t[3]=n,t[4]=l);let u=`${l}%`,d=!r,f=r?`opacity-100 translate-y-0`:`opacity-0 -translate-y-1`,p;t[5]===f?p=t[6]:(p=_(`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`,f),t[5]=f,t[6]=p);let m;return t[7]!==u||t[8]!==d||t[9]!==p?(m=(0,$.jsx)(`div`,{"aria-hidden":d,className:p,children:u}),t[7]=u,t[8]=d,t[9]=p,t[10]=m):m=t[10],m}function It(e,t){return e?1:t===`human`?.18:.35}var Lt=700;function Rt(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=me(a),s;t[2]===n?s=t[3]:(s=e=>e.byTabId[n]?.content??null,t[2]=n,t[3]=s);let c=R(s);if(!o)return null;let l;return t[4]!==c||t[5]!==i||t[6]!==o||t[7]!==r?(l=(0,$.jsx)(zt,{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 zt(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),Lt);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=It(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)(Ve,{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 Bt=typeof window>`u`?null:d();function Vt({threadRef:e,tabId:t,configuredUrls:n,visible:r}){let[o,s]=(0,Z.useState)(void 0),[c,l]=(0,Z.useState)(!1),u=ke(),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(!0),m=Fe(e),h=B(t=>Se(t.byThreadKey,e)),g=D(e=>e.addPreviewAnnotation),_=D(e=>e.addImage),v=ee(e.environmentId),y=i(e.environmentId),b=p(je.open),S=p(je.resize,`preview viewport resize`),{resolvedTheme:w}=re();Mt(e),(0,Z.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let T=t??m.activeTabId,O=T?H(e,m.serverEpoch,T):null,te=T&&O?u.has(O)?O:Me(e,T):null,k=T?m.sessions[T]??null:null,A=T?m.desktopByTabId[T]??null:null,j=k?.navStatus??{_tag:`Idle`},M=j._tag===`Idle`?``:j.url,ne=A?.loading??j._tag===`Loading`,N=A?.canGoBack??k?.canGoBack??!1,ie=A?.canGoForward??k?.canGoForward??!1,P=j._tag===`Idle`,F=j._tag===`LoadFailed`,L=Te(k),ae=A?.controller??`none`,oe=kt(ne),se=M&&v&&y?Xe({url:M,environmentLabel:v.label,environmentHttpBaseUrl:y})??void 0:void 0,V=k?.viewport??x,ce=R(e=>O?e.byTabId[O]?.rect??null:null),U=(0,Z.useCallback)(async t=>{O&&I?(await I.navigate(O,t),pe(e,t)):await _e({openPreview:b,threadRef:e,url:t})},[b,O,e]),le=(0,Z.useCallback)(async e=>{try{await U(ge(e))}catch{}},[U]),W=(0,Z.useCallback)(async t=>{try{await U(Ee(e.environmentId,t))}catch{}},[U,e.environmentId]),ue=(0,Z.useCallback)(()=>{I&&O&&I.refresh(O)},[O]),q=(0,Z.useCallback)(()=>{I&&O&&I.zoomIn(O)},[O]),J=(0,Z.useCallback)(()=>{I&&O&&I.zoomOut(O)},[O]),de=(0,Z.useCallback)(()=>{I&&O&&I.resetZoom(O)},[O]),me=(0,Z.useCallback)(async t=>{if(!T)return;let n=await S({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:T,viewport:t}});if(n._tag===`Failure`){let e=E(n);throw X.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}Ae(e,n.value)},[S,T,e]),he=()=>{if(!O)return;if(V._tag!==`fill`){Ie(O,x).catch(()=>void 0);return}let e=ce?Pe(ce,A?.zoomFactor):{width:1024,height:768};Ie(O,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Z.useEffect)(()=>{if(O)return De(O,me)},[me,O]);let ve=(0,Z.useCallback)(()=>{I&&O&&I.goBack(O)},[O]),xe=(0,Z.useCallback)(()=>{I&&O&&I.goForward(O)},[O]),Ce=(0,Z.useCallback)(()=>{!Bt||!M||Bt.shell.openExternal(M).catch(()=>void 0)},[M]),we=(0,Z.useCallback)(()=>{if(T){if(h?.tabId===T){B.getState().close(e);return}B.getState().open(e,T),C.getState().close(e)}},[h?.tabId,T,e]),Oe=(0,Z.useCallback)(()=>{!I||!O||(A?.pictureInPicture?I.pictureInPicture.close:I.pictureInPicture.open)(O).catch(e=>{X.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[A?.pictureInPicture,O]),Ne=(0,Z.useCallback)(t=>{if(!I||!O||!T)return;let n=I;if(te){fe(te).then(e=>{if(!e)return;let t=!1,r,i=()=>{if(!navigator.clipboard?.writeText){X.update(r,Y({type:`error`,title:`Unable to copy recording path`,description:`Clipboard API unavailable.`,actionProps:a}));return}navigator.clipboard.writeText(e.path).then(()=>{t=!0,o(),window.setTimeout(()=>{t=!1,o()},2e3)},e=>{X.update(r,Y({type:`error`,title:`Unable to copy recording path`,description:e instanceof Error?e.message:`An error occurred.`,actionProps:a}))})},a={children:St(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},o=()=>{X.update(r,Y({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:t?`Copied!`:`Copy path`,disabled:t,onClick:i},secondaryActionVariant:`outline`}}))};r=X.add(Y({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(t){be(O,e,T).catch(e=>{X.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}n.captureScreenshot(O).then(e=>{let t={children:St(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,n=`Screenshot saved`,o)=>{X.update(a,Y({type:e,title:n,description:o,actionProps:{children:i?`Copied!`:`Copy image`,disabled:i,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:r?`Copied!`:`Copy path`,disabled:r,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},s=()=>{if(!navigator.clipboard?.writeText){o(`error`,`Unable to copy screenshot path`,`Clipboard API unavailable.`);return}navigator.clipboard.writeText(e.path).then(()=>{r=!0,o(),window.setTimeout(()=>{r=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot path`,e instanceof Error?e.message:`An error occurred.`)})},c=()=>{n.copyArtifactToClipboard(e.path).then(()=>{i=!0,o(),window.setTimeout(()=>{i=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot`,e instanceof Error?e.message:`An error occurred.`)})};a=X.add(Y({type:`success`,title:`Screenshot saved`,actionProps:{children:`Copy image`,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:`Copy path`,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},e=>{X.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[te,O,T,e]),Le=(0,Z.useCallback)(()=>{if(!I||!O)return;if(d.current){I.cancelPickElement(O).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;d.current=!0,l(!0),(async()=>{try{let t=await I.pickElement(O);if(!t)return;g(e,t);let n=await ye(t);n&&t.screenshot&&_(e,{type:`image`,id:t.id,name:n.name,mimeType:n.type,sizeBytes:n.size,previewUrl:t.screenshot.dataUrl,file:n})}catch{}finally{if(d.current=!1,f.current&&l(!1),t&&t.isConnected&&typeof t.focus==`function`)try{t.focus({preventScroll:!0})}catch{}}})()},[_,g,O,e]);return(0,Z.useEffect)(()=>{let e=z(M,w);e&&U(e).catch(()=>void 0)},[U,w,M]),(0,Z.useEffect)(()=>()=>{d.current&&(d.current=!1,I&&O&&I.cancelPickElement(O).catch(()=>void 0),f.current&&l(!1))},[O]),(0,Z.useEffect)(()=>{if(r)return K(e=>{switch(e){case`refresh`:ue();return;case`focus-url`:s(e=>(e??0)+1);return;case`zoom-in`:q();return;case`zoom-out`:J();return;case`reset-zoom`:de();return;case`toggle-panel`:return}})},[ue,de,q,J,r]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":a(e),children:[(0,$.jsx)(Ye,{url:M,displayUrl:se,loading:ne,loadProgress:oe,canGoBack:N,canGoForward:ie,refreshDisabled:P,focusUrlNonce:o,onBack:ve,onForward:xe,onRefresh:ue,onSubmit:e=>void le(e),onOpenInBrowser:T?Ce:void 0,onCapture:I&&T?Ne:void 0,captureDisabled:!A||F,recording:te!==null,onPictureInPicture:I&&T?we:void 0,pictureInPicture:h?.tabId===T,pictureInPictureDisabled:!A?.hasWebContents||F,onPickElement:I&&T?Le:void 0,pickActive:c,pickDisabled:!T||F,pickDisabledReason:F?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:I?(0,$.jsx)(ct,{tabId:O,hasWebContents:A?.hasWebContents??!1,zoomFactor:A?.zoomFactor??1,colorScheme:A?.colorScheme??`system`,deviceToolbarVisible:V._tag!==`fill`,onToggleDeviceToolbar:he,nativePictureInPicture:A?.pictureInPicture??!1,onNativePictureInPicture:Oe}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[O&&k&&!L?(0,$.jsx)(G,{tabId:O,visible:r&&!F,className:`absolute inset-0 h-full w-full`},O):null,L?(0,$.jsx)(ot,{environmentId:e.environmentId,configuredUrls:n,recentlySeenUrls:m.recentlySeenUrls,onOpenUrl:e=>void W(e)}):null,k&&A?(0,$.jsx)(Ft,{zoomFactor:A.zoomFactor}):null,O&&A&&!L&&!F?(0,$.jsx)(Rt,{tabId:O,zoomFactor:A.zoomFactor,controller:ae}):null,ae===`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:ae===`agent`?`Agent controlling browser`:`Human control`}),j._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(vt,{url:j.url,code:j.code,description:j.description,onReload:ue})}):null]})]})}function Ht(e){let t=(0,Q.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!Oe()){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)(W,{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)(Vt,{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)(W,{mode:n,children:c}),t[10]=n,t[11]=c,t[12]=l):l=t[12],l}export{Ht as PreviewPanel};
|
|
2
|
+
//# sourceMappingURL=PreviewPanel-DeGcjg8P.js.map
|