@fungi.computer/prints 0.17.3 → 0.17.5
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.
|
@@ -1264,4 +1264,4 @@ import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{$ as n,$n as r,$r as
|
|
|
1264
1264
|
}`}function Rx(e){return`${Ix}
|
|
1265
1265
|
@layer unsafe {
|
|
1266
1266
|
${e}
|
|
1267
|
-
}`}var zx=new WeakMap;function Bx(e){let t=zx.get(e);if(t!=null)return t;let n=document.createElement(`div`);n.setAttribute(ab,`true`);let r=document.createElement(`div`);r.style.position=`relative`,r.style.height=`200%`,n.appendChild(r),e.appendChild(n);let i=Math.max(n.offsetWidth-n.clientWidth,0);return n.remove(),zx.set(e,i),i}function Vx(e,t){if(!e.isConnected)return;let n=Bx(t);if(n==null)return;let r=t.querySelector(`style[${ob}]`),i=r instanceof HTMLStyleElement?r:document.createElement(`style`);r instanceof HTMLStyleElement||(i.setAttribute(ob,``),t.appendChild(i)),i.textContent=`:host { ${sb}: ${n}px; }`}var Hx;function Ux(e){if(typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`&&`adoptedStyleSheets`in e){Hx??(Hx=new CSSStyleSheet,Hx.replaceSync(Lx(Fx)));let t=!1;try{e.adoptedStyleSheets=[Hx],t=!0}catch{}if(t){e.querySelector(`style[${rb}]`)?.remove();return}}if(e.querySelector(`style[data-file-tree-style]`)==null){let t=document.createElement(`style`);t.setAttribute(rb,``),t.textContent=Lx(Fx),e.prepend(t)}}function Wx(e,t){Gx(e,t),Ux(t),Vx(e,t)}function Gx(e,t){let n=e.querySelector(`template[shadowrootmode="open"], template[data-file-tree-shadowrootmode="open"]`);n instanceof HTMLTemplateElement&&(t.childNodes.length>0||(t.appendChild(n.content.cloneNode(!0)),n.hasAttribute(`shadowrootmode`)&&n.remove()))}if(typeof HTMLElement<`u`&&customElements.get(`file-tree-container`)==null){class e extends HTMLElement{constructor(){super()}connectedCallback(){let e=this.shadowRoot??this.attachShadow({mode:`open`});Wx(this,e)}}if(customElements.define(nb,e),typeof document<`u`)for(let e of Array.from(document.querySelectorAll(nb)))e instanceof HTMLElement&&Wx(e,e.shadowRoot??e.attachShadow({mode:`open`}))}var Kx=5,qx=32,Jx=128;function Yx(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Xx(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Zx(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 Qx(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 $x(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function eS(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 tS(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,aS(e,t)}function nS(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=Qx(e).get(t);if(i===void 0)return;let a=i>>Kx;e.childVisibleChunkSums[a]+=r}function rS(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=oS(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=qx}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 iS(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>Kx;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<Kx}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 aS(e,t){if(t.childIds.length<Jx){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/qx),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>>Kx]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function oS(e,t,n,r){let i=Math.min(t.childIds.length,n+qx),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 sS=7,cS=3,lS=8,uS=4;function dS(e,t,n=0){return e<<uS|n<<cS|t}function fS(e){return e.depthAndFlags>>>uS}function pS(e){return(e.depthAndFlags&lS)>>cS}function Y(e){return(e.depthAndFlags&lS)!==0}function mS(e){return e.depthAndFlags&sS}function hS(e,t){return(mS(e)&t)!==0}function gS(e,t){e.depthAndFlags|=t}function _S(e,t){e.depthAndFlags=dS(t,mS(e),pS(e))}var vS=Symbol(`benchmarkInstrumentation`);function yS(e,t){return t==null||Object.defineProperty(e,vS,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function bS(e){return e==null?null:e[vS]??null}function X(e,t,n){return e==null?n():e.measurePhase(t,n)}function xS(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function SS(e){return e>=48&&e<=57}function CS(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!SS(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&&SS(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 wS(e){let t=e.toLowerCase();return{lowerValue:t,tokens:CS(t)}}function TS(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 ES(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=TS(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function DS(e,t,n){let r=ES(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function OS(e,t){return DS(e,t,wS)}function kS(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function AS(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=kS(e,r);return a===kS(t,r)?OS(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 jS(e,t){return AS(e,t)}function MS(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=wS(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=kS(e,n);return o===kS(t,n)?DS(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 NS(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=wS(r);return e.sortKeyById[t]=i,i}function PS(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function FS(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 IS(e){let{hasTrailingSlash:t,segments:n}=FS(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function LS(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=FS(e);return{requiresDirectory:t,segments:n}}function RS(){let e=new Map;return e.set(``,0),{idByValue:e,valueById:[``],sortKeyById:[wS(``)]}}function zS(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 BS(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var VS=Symbol(`pathStorePreparedInputKind`);function HS(e,t){return e[VS]=t,e}function US(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function WS(e,t,n){return n==="default"?jS(e,t):n(US(e),US(t))}function GS(){return{depthAndFlags:dS(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function KS(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 qS(e){return e.isDirectory?e.segments.length:e.segments.length-1}function JS(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 YS(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function XS(e,t={}){return nC(e,t).map(e=>e.path)}function ZS(e,t={}){let n=nC(e,t);return HS({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function QS(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 HS({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function $S(e){let t=e,n=t.preparedPaths;if(t[VS]===`prepared`&&n!=null)return n;if(!JS(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function eC(e){let t=e;return t[VS]===`presorted`&&t.presortedPaths!=null||YS(t.presortedPaths)?t.presortedPaths:null}function tC(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function nC(e,t={}){let n=PS(t),r=bS(t);xS(r,`workload.inputFiles`,e.length);let i=X(r,`store.preparePathEntries.parse`,()=>e.map(e=>IS(e)));return X(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>WS(e,t,n.sort))),i}var rC=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[GS()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=RS();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=bS(e),this.options=PS(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,Yx())}appendPaths(e){return X(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>IS(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,X(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return X(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:dS(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:dS(r,0,1),nameId:u,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),l++,c[l]=d,m=a+1}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:dS(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=IS(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:dS(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:dS(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=IS(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(X(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||X(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"?MS(this.lastPreparedPath,e,this.segmentSortKeyCache):WS(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=qS(e),i=n==null?0:qS(n),a=n==null?0:KS(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=zS(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:dS(fS(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),$x(i,s),s}createFileChildUnchecked(e,t){let n=zS(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:dS(fS(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),$x(r,a),a}getOrCreateDirectoryChild(e,t){let n=zS(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&&!Y(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:dS(fS(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),$x(r,a),this.directories.set(a,Yx()),a}createDirectoryChild(e,t){let n=zS(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:dS(fS(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),$x(r,a),this.directories.set(a,Yx()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!Y(n))throw Error(`Path is not a directory: "${t}"`);if(hS(n,1))throw Error(`Duplicate path: "${t}"`);gS(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,Xx());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(Y(a)){let t=Xx();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;Y(n)&&this.directories.set(t,Yx());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),$x(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!Y(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 tS(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function iC(e,t=`closed`,n=null){let r=oC(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 aC(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function oC(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 sC(e,t){return hS(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion!==`closed`&&fS(t)<=e.defaultExpansion}function cC(e,t,n=e.snapshot.nodes[t]){return n==null||!Y(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:sC(e,n)}function lC(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!Y(r))return;let i=sC(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 uC(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 dC(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function fC(e,t){let n=uC(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 pC(e,t){let n=uC(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function mC(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 hC(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function gC(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 _C(e,t){e.directoryLoadInfoById.delete(t)}function vC(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 yC(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function bC(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function xC(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function SC(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function CC(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function wC(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function TC(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 EC(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 DC(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 OC(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 kC(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 AC(e,t,n){return{...n,visibleCountDelta:VC(e)-t}}function jC(e,t){let n=VC(e),r=aC();e.transactionStack.push(r);try{t()}catch(t){throw PC(e,r,!1),t}PC(e,r,!0,VC(e)-n)}function MC(e,t){let n=e.instrumentation;if(n==null){NC(e,t);return}X(n,`store.events.record`,()=>NC(e,t))}function NC(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){zC(e,t);return}n.events.push(t),RC(n,t)}function PC(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?LC(i,t):X(n,`store.events.batch.merge`,()=>LC(i,t));return}let a=FC(t,r),o=e.instrumentation;if(o==null){zC(e,a);return}X(o,`store.events.batch.commit`,()=>zC(e,a))}function FC(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 IC(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function LC(e,t){for(let n of t.events)e.events.push(n);IC(e,t)}function RC(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function zC(e,t){let n=e.instrumentation;if(n==null){BC(e,t);return}X(n,`store.events.emit`,()=>BC(e,t))}function BC(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function VC(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function HC(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!Y(n)||hS(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||!Y(a)?null:i}function UC(e,t){let n=t;for(;;){let t=HC(e,n);if(t==null)return n;n=t}}function WC(e,t){let n=[t],r=t;for(;;){let t=HC(e,r);if(t==null)return n;n.push(t),r=t}}function GC(e,t){let n=t==null?e.snapshot.rootId:tw(e,t);return n==null?[]:iw(e,n)}function KC(e,t){let n=IS(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=yw(e,vw(e,r)),{createdNodeIds:a,directoryId:o}=aw(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=Z(e,o);if(hS(n,1))throw Error(`Path already exists: "${t}"`);gS(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=sw(e,o,n.basename),s.add(c);QC(e,o);let l=yw(e,o);return yC({affectedAncestorIds:ew(e,c),affectedNodeIds:[...s],path:t,projectionChanged:bw(i,l)})}function qC(e,t,n){let r=tw(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=Z(e,r);if(hS(i,2))throw Error(`The root node cannot be removed`);if(Y(i)&&rw(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=yw(e,a),s=gw(e,r);uw(e,a,r,i.nameId),_w(e,a),QC(e,a);let c=yw(e,a);return bC({affectedAncestorIds:ew(e,a),affectedNodeIds:s,path:t,projectionChanged:bw(o,c),recursive:n.recursive===!0})}function JC(e,t,n,r){let i=tw(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=Z(e,i);if(hS(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=mw(e,i,n),c=yw(e,a.parentId),l=yw(e,s.parentId),u=BS(e.snapshot.segmentTable,a.nameId),d=zS(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(Y(a)&&ww(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=Zx(e.snapshot.nodes,rw(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&hw(e,p,o,pS(a))===`skip`)return null;let m=a.parentId;uw(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),Cw(e,i),lw(e,s.parentId,i),_w(e,m),e.pathCacheVersion++,QC(e,m),s.parentId!==m&&QC(e,s.parentId);let h=yw(e,m),g=yw(e,s.parentId);return xC({affectedAncestorIds:[...new Set([...ew(e,m),...ew(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:xw([c,l],[h,g]),to:ZC(e,i)})}function YC(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function XC(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function ZC(e,t){let n=Z(e,t),r=YC(e,t);if(r!=null)return r;if(hS(n,2))return XC(e,t,``);let i=ZC(e,n.parentId),a=BS(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return XC(e,t,Y(n)?`${o}/`:o)}function QC(e,t){let n=e.instrumentation;if(n==null){Ew(e,t);return}X(n,`store.recomputeCountsUpwardFrom`,()=>Ew(e,t))}function $C(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||!Y(o)){Tw(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){Tw(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function ew(e,t){let n=[],r=t;for(;r!=null;){let t=Z(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function tw(e,t){if(t.length===0)return e.snapshot.rootId;let n=LS(t);return nw(e,n.segments,n.requiresDirectory)}function nw(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=rw(e,r),a=Zx(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=Z(e,r);return n&&!Y(i)?null:r}function rw(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 Z(e,t){let n=e.snapshot.nodes[t];if(n===void 0||hS(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function iw(e,t){let n=e.snapshot.nodes[t];if(n===void 0||hS(n,4))return[];if(!Y(n))return[ZC(e,t)];if(rw(e,t).childIds.length===0)return hS(n,1)&&!hS(n,2)?[ZC(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||hS(n,4)){i.pop();continue}if(!Y(n)){r.push(ZC(e,t.nodeId)),i.pop();continue}let a=rw(e,t.nodeId);if(a.childIds.length===0){hS(n,1)&&!hS(n,2)&&r.push(ZC(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 aw(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=zS(e.snapshot.segmentTable,i),a=rw(e,r),o=Zx(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!Y(Z(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=ow(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function ow(e,t,n){let r=Z(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:dS(fS(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,Yx()),lw(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function sw(e,t,n){let r=zS(e.snapshot.segmentTable,n),i=rw(e,t);if(Zx(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${Ow(e,t,n)}"`);let a=Z(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:dS(fS(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),lw(e,t,o),e.activeNodeCount++,o}function cw(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}dw(e,n,o)<0?i=a:r=a+1}return r}function lw(e,t,n){let r=rw(e,t),i=Z(e,n);Zx(e.snapshot.nodes,r).set(i.nameId,n),nS(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=cw(e,r,n);r.childIds.splice(a,0,n),eS(r,a),aS(e.snapshot.nodes,r)}function uw(e,t,n,r){let i=rw(e,t),a=Qx(i),o=a.get(n)??-1;Zx(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&nS(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),eS(i,o),aS(e.snapshot.nodes,i))}function dw(e,t,n){let r=e.snapshot.options.sort;return r==="default"?fw(e,t,n):r(pw(e,t),pw(e,n))}function fw(e,t,n){let r=Z(e,t),i=Z(e,n),a=Y(r);if(a!==Y(i))return a?-1:1;let o=ES(NS(e.snapshot.segmentTable,r.nameId),NS(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=BS(e.snapshot.segmentTable,r.nameId),c=BS(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function pw(e,t){let n=Z(e,t),r=ZC(e,t),i=Y(n),a=i?r.slice(0,-1):r;return{basename:BS(e.snapshot.segmentTable,n.nameId),depth:fS(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function mw(e,t,n){let r=Z(e,t),i=tw(e,n);if(i!=null){let t=Z(e,i);if(Y(t))return{basename:BS(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=LS(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=LS(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:nw(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function hw(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${ZC(e,t)}"`);let i=Z(e,t);if(pS(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(Y(i)&&rw(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return gw(e,t),uw(e,a,t,o),_w(e,a),QC(e,a),`handled`}function gw(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=Z(e,t.nodeId);if(t.visitedChildren||!Y(i)){Y(i)&&e.snapshot.directories.delete(t.nodeId),gS(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),_C(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=rw(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 _w(e,t){let n=t;for(;n!=null;){let t=Z(e,n);if(!Y(t)||hS(t,2)||rw(e,n).childIds.length>0)return;gS(t,1),n=t.parentId===n?null:t.parentId}}function vw(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=Zx(e.snapshot.nodes,rw(e,n)).get(t);if(i==null||!Y(Z(e,i)))break;n=i}return n}function yw(e,t){let n=Sw(e,t);if(n==null)return null;let r=UC(e,n),i=Z(e,r),a=n===r?null:WC(e,n).map(t=>ZC(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:rw(e,r).childIds.length>0,path:ZC(e,r),terminalKind:pS(i)})}function bw(e,t){return xw([e],[t])}function xw(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 Sw(e,t){let n=t;for(;n!=null;){let t=Z(e,n);if(!Y(t)||hS(t,2))return null;if(!cC(e,n,t))return n;n=t.parentId}return null}function Cw(e,t){let n=Z(e,t);if(_S(n,(t===e.snapshot.rootId?-1:fS(Z(e,n.parentId)))+1),!Y(n))return;let r=rw(e,t);for(let t of r.childIds)Cw(e,t)}function ww(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=Z(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function Tw(e,t,n=Z(e,t),r=!1){let i=e.instrumentation;if(i==null){Dw(e,t,n,r);return}X(i,`store.recomputeNodeCounts`,()=>Dw(e,t,n,r))}function Ew(e,t){let n=t;for(;n!=null;){let t=Z(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(Tw(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&nS(rw(e,s),n,a,o),n=s}}function Dw(e,t,n,r){if(!Y(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=rw(e,t);if(r){let t=e.instrumentation;t==null?tS(e.snapshot.nodes,i):X(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>tS(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,hS(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=HC(e,t)==null?cC(e,t,n)?1+o:1:o}function Ow(e,t,n){let r=ZC(e,t);return r.length===0?n:`${r}${n}`}function kw(e){return e!=null&&!hS(e,4)}function Aw(e,t){let n=e.snapshot.nodes[t];return!kw(n)||!Y(n)||hS(n,2)?null:n}function jw(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&kw(e.snapshot.nodes[n])&&(t+=1);return t}function Mw(e){return Math.max(0,e.valueById.length-1)}function Nw(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:jw(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:Mw(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function Pw(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 Fw(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)Aw(e,n)!=null&&t.push(ZC(e,n));for(let t of e.expandedDirectoryIds)Aw(e,t)!=null&&n.push(ZC(e,t));return{collapsedPaths:t,expandedPaths:n}}function Iw(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)Aw(e,n)!=null&&dC(e,n)!==`loaded`&&t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:ZC(e,n)});return t}function Lw(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=tw(e,n);t!=null&&lC(e,t,!0,Z(e,t))}for(let n of t.collapsedPaths){let t=tw(e,n);t!=null&&lC(e,t,!1,Z(e,t))}}function Rw(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=tw(e,n.path);t!=null&&Aw(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function zw(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function Bw(e){let t=e.snapshot.segmentTable,n=RS();for(let r of e.snapshot.nodes)if(kw(r)){if(hS(r,2)){r.nameId=0;continue}r.nameId=zS(n,BS(t,r.nameId))}e.snapshot.segmentTable=n}function Vw(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!kw(r)||!Y(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return kw(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[Z(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),tS(e.snapshot.nodes,n)}}function Hw(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(kw(n))break;--t}e.snapshot.nodes.length=t+1}function Uw(e){let t=Fw(e),n=Iw(e);X(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>zw(e)),X(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>Bw(e)),X(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>Vw(e)),X(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>Hw(e)),X(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>Lw(e,t)),X(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>Rw(e,n)),X(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>$C(e,e.snapshot.rootId))}function Ww(e){let t=Fw(e),n=Iw(e),r=X(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>GC(e)),i=yS({...e.snapshot.options},e.instrumentation),a=X(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new rC(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,X(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>Lw(e,t)),X(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>Rw(e,n)),X(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>$C(e,e.snapshot.rootId))}function Gw(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function Kw(e,t){let n=Nw(e);t===`stable`?X(e.instrumentation,`store.cleanup.stable`,()=>Uw(e)):X(e.instrumentation,`store.cleanup.aggressive`,()=>Ww(e));let r=Nw(e);return Pw(t,t===`stable`,n,r)}var qw=64;function Jw(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 Yw(e){return Z(e,e.snapshot.rootId).visibleSubtreeCount}function Xw(e,t,n,r){let i=Z(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function Zw(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:gT(e,t.cursor),setSize:t.setSize,subtreeEndIndex:Xw(e,t.cursor,t.index,n)}}function Qw(e,t,n,r,i,a){let o=rw(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=rS(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return $w(e,u,l,r+c,i+1,s,o.childIds.length,a)}function $w(e,t,n,r,i,a,o,s){if(!Y(Z(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=uT(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=Z(e,c.terminalNodeId);if(!Y(l)||!cC(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Qw(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function eT(e,t){let n=Yw(e);if(t<0||t>=n)return null;let r=Qw(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>ZC(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=Zw(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:gT(e,r.cursor),setSize:r.setSize,subtreeEndIndex:Xw(e,r.cursor,r.index,n)}}function tT(e,t,n){let r=e.instrumentation,i=Yw(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 hT(e,o+1);let t=[],n=sT(e,a);for(let r=a;r<=o&&n!=null;r++){let r=gT(e,n);t.push(r),n=fT(e,n)}return t}let s=[],c=0,l=0,u=X(r,`store.getVisibleSlice.selectFirstRow`,()=>sT(e,a));for(let t=a;t<=o&&u!=null;t++){let t=X(r,`store.getVisibleSlice.materializeRow`,()=>gT(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=X(r,`store.getVisibleSlice.advanceCursor`,()=>fT(e,u))}return xS(r,`workload.visibleRowsRead`,s.length),xS(r,`workload.flattenedRowsRead`,c),xS(r,`workload.flattenedSegmentsRead`,l),s}function nT(e,t=Yw(e)){let n=e.instrumentation;return n==null?mT(e,t):X(n,`store.getVisibleTreeProjection`,()=>mT(e,t))}function rT(e){return pT(nT(e))}function iT(e,t){let n=tw(e,t);if(n==null||n===e.snapshot.rootId||Y(Z(e,n))&&UC(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=Z(e,i).parentId,n=rw(e,t),s=Qx(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=iS(a,n,s),t!==o){let n=Z(e,t),a=HC(e,t);if(!cC(e,t,n)&&a!==i)return null;UC(e,t)===t&&(r+=1)}i=t}return r}function aT(e,t){let n=tw(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=Z(e,n);if(!Y(r))throw Error(`Path is not a directory: "${t}"`);return cC(e,n,r)?null:(lC(e,n,!0,r),QC(e,n),SC({affectedAncestorIds:ew(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function oT(e,t){let n=tw(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=Z(e,n);if(!Y(r))throw Error(`Path is not a directory: "${t}"`);return cC(e,n,r)?(lC(e,n,!1,r),QC(e,n),CC({affectedAncestorIds:ew(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function sT(e,t){return t<0||t>=Yw(e)?null:cT(e,e.snapshot.rootId,t,-1)}function cT(e,t,n,r){let i=rw(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?rS(e.snapshot.nodes,i,n):X(a,`store.getVisibleSlice.selectChildIndex`,()=>rS(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return lT(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function lT(e,t,n,r){if(!Y(Z(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=uT(e,t,r);if(n===0)return i;let a=Z(e,i.terminalNodeId);if(!Y(a)||!cC(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return cT(e,i.terminalNodeId,n-1,i.visibleDepth)}function uT(e,t,n){return Y(Z(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:UC(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:X(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>UC(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function dT(e,t){let n=Z(e,t);if(!Y(n))return!0;let r=n.parentId;return r===e.snapshot.rootId||HC(e,r)!==t}function fT(e,t){let n=Z(e,t.terminalNodeId);if(Y(n)){let r=rw(e,t.terminalNodeId);if(cC(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:lT(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=Z(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=rw(e,n),o=Qx(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 lT(e,s,0,i);dT(e,r)&&i--,r=n}}function pT(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 mT(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(qw);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=Jw(o,y);let x,S=_;if(Y(v))S=f?UC(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:ZC(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&&Y(C)&&cC(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 hT(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(!Y(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:ZC(e,f)};continue}let h=l?UC(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=gT(e,g);let _=i[h];_!=null&&Y(_)&&cC(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function gT(e,t){let n=Z(e,t.terminalNodeId),r=Y(n)?_T(e,t):null,i=ZC(e,t.terminalNodeId),a=BS(e.snapshot.segmentTable,n.nameId),o=Y(n)&&rw(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?WC(e,t.headNodeId).map(n=>{let r=Z(e,n);return{isTerminal:n===t.terminalNodeId,name:BS(e.snapshot.segmentTable,r.nameId),nodeId:n,path:ZC(e,n)}}):X(c,`store.getVisibleSlice.flatten.collectSegments`,()=>WC(e,t.headNodeId).map(n=>{let r=Z(e,n);return{isTerminal:n===t.terminalNodeId,name:BS(e.snapshot.segmentTable,r.nameId),nodeId:n,path:ZC(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:Y(n)&&cC(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:Y(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function _T(e,t){if(t.headNodeId===t.terminalNodeId)return dC(e,t.terminalNodeId);let n=WC(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=dC(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}var vT=8;function yT(e){let{nodes:t,directories:n,rootId:r,options:i}=e,a=t.length,o=new Int32Array(a),s=new Int32Array(a),c=new Int32Array(a),l=new Int32Array(a),u=new Int32Array(a),d=new Int32Array(a),f=new Int32Array(a);for(let e=0;e<a;e+=1){let n=t[e];n!=null&&(o[e]=n.parentId,s[e]=n.nameId,c[e]=n.depthAndFlags,l[e]=n.subtreeNodeCount,u[e]=n.visibleSubtreeCount)}let p=0;for(let e of n.values())p+=e.childIds.length;let m=new Int32Array(p),h=0;for(let[e,t]of n){let n=t.childIds;d[e]=h,f[e]=n.length;for(let e=0;e<n.length;e+=1)m[h]=n[e],h+=1}return{nodeCount:a,rootId:r,flattenEmptyDirectories:i.flattenEmptyDirectories===!0,parentId:o,nameId:s,depthAndFlags:c,subtreeNodeCount:l,visibleSubtreeCount:u,childStart:d,childCount:f,childIdsFlat:m}}function bT(e){let{nodeCount:t,rootId:n,flattenEmptyDirectories:r,depthAndFlags:i,subtreeNodeCount:a,visibleSubtreeCount:o,childStart:s,childCount:c,childIdsFlat:l}=e;for(let e=t-1;e>=1;--e){if((i[e]&vT)===0)continue;let t=s[e],n=c[e],u=0,d=0;for(let e=0;e<n;e+=1){let n=l[t+e];u+=a[n],d+=o[n]}a[e]=1+u;let f;f=r&&n===1?(i[l[t]]&vT)===0?1+d:d:1+d,o[e]=f}let u=s[n],d=c[n],f=0,p=0;for(let e=0;e<d;e+=1){let t=l[u+e];f+=a[t],p+=o[t]}a[n]=1+f,o[n]=p}function xT(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||!Y(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&&aS(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&Y(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,aS(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function ST(e){let{directories:t,nodes:n,rootId:r}=e.snapshot,i=yT(e.snapshot);bT(i);let a=i.subtreeNodeCount,o=i.visibleSubtreeCount;for(let e=0;e<n.length;e+=1){let t=n[e];t!=null&&(t.subtreeNodeCount=a[e],t.visibleSubtreeCount=o[e])}for(let[e,i]of t){let t=i.childIds,a=t.length,o=0,s=0;for(let e=0;e<a;e++){let r=t[e];if(r==null)continue;let i=n[r];o+=i.subtreeNodeCount,s+=i.visibleSubtreeCount}i.totalChildSubtreeNodeCount=o,i.totalChildVisibleSubtreeCount=s,(e===r||a>=128)&&aS(n,i)}}function CT(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var wT=class e{#e;constructor(e={}){let t=bS(e),n=X(t,`store.builder.create`,()=>new rC(e));if(e.preparedInput!=null){let t=eC(e.preparedInput);t==null?n.appendPreparedPaths($S(e.preparedInput),!1):n.appendPresortedPaths(t,tC(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(X(t,`store.preparePathEntries`,()=>nC(r,e)))}let r=X(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=X(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=X(t,`store.state.create`,()=>iC(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:X(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||CT(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&X(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?e.useSoaCountSweep===!0?X(t,`store.state.initializeOpenVisibleCountsViaSoa`,()=>ST(this.#e)):X(t,`store.state.initializeOpenVisibleCounts`,()=>xT(this.#e)):X(t,`store.state.recomputeCounts`,()=>$C(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return XS(e,t)}static prepareInput(e,t={}){return ZS(e,t)}static preparePresortedInput(e){return QS(e)}list(e){return X(this.#e.instrumentation,`store.list`,()=>GC(this.#e,e))}add(e){X(this.#e.instrumentation,`store.add`,()=>{let t=Yw(this.#e);MC(this.#e,AC(this.#e,t,KC(this.#e,e)))})}remove(e,t={}){X(this.#e.instrumentation,`store.remove`,()=>{let n=Yw(this.#e);MC(this.#e,AC(this.#e,n,qC(this.#e,e,t)))})}move(e,t,n={}){X(this.#e.instrumentation,`store.move`,()=>{let r=Yw(this.#e),i=JC(this.#e,e,t,n);i!=null&&MC(this.#e,AC(this.#e,r,i))})}batch(e){jC(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})}})}getVisibleCount(){return X(this.#e.instrumentation,`store.getVisibleCount`,()=>Yw(this.#e))}getVisibleSlice(e,t){return X(this.#e.instrumentation,`store.getVisibleSlice`,()=>tT(this.#e,e,t))}getVisibleRowContext(e){return X(this.#e.instrumentation,`store.getVisibleRowContext`,()=>eT(this.#e,e))}getVisibleTreeProjection(){return rT(this.#e)}getVisibleTreeProjectionData(e){return nT(this.#e,e)}getVisibleIndex(e){return X(this.#e.instrumentation,`store.getVisibleIndex`,()=>iT(this.#e,e))}getPathInfo(e){return X(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=tw(this.#e,e);if(t==null)return null;let n=Z(this.#e,t);return{depth:fS(n),kind:Y(n)?`directory`:`file`,path:ZC(this.#e,t)}})}isExpanded(e){return X(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=Z(this.#e,t);return cC(this.#e,t,n)})}expand(e){X(this.#e.instrumentation,`store.expand`,()=>{let t=Yw(this.#e),n=aT(this.#e,e);n!=null&&MC(this.#e,AC(this.#e,t,n))})}collapse(e){X(this.#e.instrumentation,`store.collapse`,()=>{let t=Yw(this.#e),n=oT(this.#e,e);n!=null&&MC(this.#e,AC(this.#e,t,n))})}on(e,t){return vC(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return dC(this.#e,t)}markDirectoryUnloaded(e){X(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(rw(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=Yw(this.#e);pC(this.#e,t),MC(this.#e,AC(this.#e,n,wC({affectedAncestorIds:ew(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return X(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=Yw(this.#e),r=fC(this.#e,t);return MC(this.#e,AC(this.#e,n,TC({affectedAncestorIds:ew(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return X(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||dC(this.#e,n)!==`loading`||!hC(this.#e,n,e.attemptId))return!1;let r=ZC(this.#e,n);this.validateChildPatch(r,t);let i=Yw(this.#e),a=[];for(let e of t.operations){TT(r,e);let t=Yw(this.#e);switch(e.type){case`add`:a.push(AC(this.#e,t,KC(this.#e,e.path)));break;case`remove`:a.push(AC(this.#e,t,qC(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=JC(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(AC(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return MC(this.#e,AC(this.#e,i,EC({affectedAncestorIds:ew(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:ZC(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return X(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=Yw(this.#e),r=mC(this.#e,t,e.attemptId);return MC(this.#e,AC(this.#e,n,DC({affectedAncestorIds:ew(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:ZC(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return X(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=Yw(this.#e),i=gC(this.#e,n,e.attemptId,t);return MC(this.#e,AC(this.#e,r,OC({affectedAncestorIds:ew(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:ZC(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return X(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(Gw(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=Yw(this.#e),n=Kw(this.#e,e.mode??`stable`);return MC(this.#e,AC(this.#e,t,kC({...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=rw(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??wS(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=ES(NS(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(!Y(Z(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=Z(this.#e,n);cC(this.#e,n,i)||(lC(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=Z(this.#e,e);if(!cC(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=tw(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!Y(Z(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!Y(Z(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=Z(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=Z(this.#e,e),r=HC(this.#e,e);if(!cC(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 TT(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}"`)}}var ET=e=>e.startsWith(`f::`)?e.slice(3):e;function DT(e){let t=e.lastIndexOf(`/`);return t<0?{parentPath:``,baseName:e}:{parentPath:e.slice(0,t),baseName:e.slice(t+1)}}function OT(e,t){return e===``?t:`${e}/${t}`}function kT({files:e,path:t,isFolder:n,nextBasename:r}){let i=ET(t),a=r.trim();if(a.length===0)return{error:`Name cannot be empty.`};if(a.includes(`/`))return{error:`Name cannot include "/".`};let{parentPath:o,baseName:s}=DT(i);if(a===s)return{nextFiles:e,sourcePath:i,destinationPath:i,isFolder:n};let c=OT(o,a),l=Array(e.length),u=new Set;if(!n){let t=`${c}/`,r=!1;for(let n=0;n<e.length;n++){let a=e[n];if(a!==i&&a.startsWith(t))return{error:`"${c}" already exists.`};let o=a===i?c:a;if(u.has(o))return{error:`"${c}" already exists.`};u.add(o),l[n]=o,a===i&&(r=!0)}return r?{nextFiles:l,sourcePath:i,destinationPath:c,isFolder:n}:{error:`Could not find the selected file to rename.`}}let d=`${i}/`,f=`${c}/`,p=0;for(let t=0;t<e.length;t++){let n=e[t],r=n===i||n.startsWith(d);if(!r&&(n===c||n.startsWith(f)))return{error:`"${c}" already exists.`};let a=r?`${c}${n.slice(i.length)}`:n;if(u.has(a))return{error:`"${c}" already exists.`};u.add(a),l[t]=a,r&&p++}return p===0?{error:`Could not find the selected folder to rename.`}:{nextFiles:l,sourcePath:i,destinationPath:c,isFolder:n}}function AT(e){return e.endsWith(`/`)}function jT(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.lastIndexOf(`/`),r=n<0?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function MT(e){let t=[],n=new Set;for(let r of e)n.has(r)||(n.add(r),t.push(r));let r=new Set;for(let e of t.toSorted((e,t)=>e.length===t.length?e.localeCompare(t):e.length-t.length)){let t=(e.endsWith(`/`)?e.slice(0,-1):e).split(`/`),n=!1;for(let e=0;e<t.length-1;e+=1){let i=`${t.slice(0,e+1).join(`/`)}/`;if(r.has(i)){n=!0;break}}n||r.add(e)}return t.filter(e=>r.has(e))}function NT(e,t){return t.includes(e)?MT(t):[e]}function PT(e,t){return e===t?!0:e==null||t==null?!1:e.kind===t.kind&&e.directoryPath===t.directoryPath&&e.flattenedSegmentPath===t.flattenedSegmentPath&&e.hoveredPath===t.hoveredPath}function FT(e,t){return{draggedPaths:e,target:t}}function IT(e,t){if(t.kind!==`directory`||t.directoryPath==null)return!1;for(let n of e)if(AT(n)&&(t.directoryPath===n||t.directoryPath.startsWith(n)))return!0;return!1}function LT(e,t){return t.kind===`root`||t.directoryPath==null?jT(e):t.directoryPath}function RT(e,t){let n=e.map(e=>{let n=LT(e,t);return n===e?null:{from:e,to:n,type:`move`}}).filter(e=>e!=null);return n.length===0?null:{operations:n,result:{draggedPaths:e,operation:n.length===1?`move`:`batch`,target:t}}}function zT(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function BT(e,t,n){let{paths:r,preparedInput:i}=e;if(i==null){if(r==null)throw Error(`FileTree requires paths or preparedInput`);return{paths:r,preparedInput:void 0}}let a=i.paths;if(r==null)return{paths:a,preparedInput:i};if(!zT(wT.preparePaths(r,n==null?{}:{sort:n}),a))throw Error(`FileTree ${t} received paths and preparedInput for different path lists`);return{paths:a,preparedInput:i}}function VT(e){return e.operation===`add`||e.operation===`remove`||e.operation===`move`||e.operation===`batch`}function HT(e,t,n){if(e===t)return n;let r=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(r)?`${n.endsWith(`/`)?n:`${n}/`}${e.slice(r.length)}`:e}function UT(e,t){if(e===t)return!0;let n=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(n)}function WT(e,t,n=!1){if(e==null)return null;switch(t.operation){case`add`:case`expand`:case`collapse`:case`mark-directory-unloaded`:case`begin-child-load`:case`apply-child-patch`:case`complete-child-load`:case`fail-child-load`:case`cleanup`:return e;case`remove`:return UT(e,t.path)?n?e:null:e;case`move`:return HT(e,t.from,t.to);case`batch`:{let r=e;for(let e of t.events)if(r=WT(r,e,n),r==null)return null;return r}}}function GT(e){return{canonicalChanged:e.canonicalChanged,projectionChanged:e.projectionChanged,visibleCountDelta:e.visibleCountDelta}}function KT(e){switch(e.operation){case`add`:return{...GT(e),operation:`add`,path:e.path};case`remove`:return{...GT(e),operation:`remove`,path:e.path,recursive:e.recursive};case`move`:return{...GT(e),from:e.from,operation:`move`,to:e.to}}}function qT(e){return{...GT(e),events:e.events.filter(e=>e.operation===`add`||e.operation===`remove`||e.operation===`move`).map(e=>KT(e)),operation:`batch`}}function JT(e){switch(e.operation){case`add`:case`remove`:case`move`:return KT(e);case`batch`:return qT(e);default:return null}}function YT(e,t){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}function XT(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;if(t.length===0)return[];let n=t.split(`/`);return n.slice(0,-1).map((e,t)=>`${n.slice(0,t+1).join(`/`)}/`)}function ZT(e){return XT(e).at(-1)??null}function QT(e,t){return t==null?e:e.startsWith(t)?e.slice(t.length):e}function $T(e){return e.endsWith(`/`)}var eE=e=>e.toLowerCase();function tE(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?t:t.slice(n+1)}function nE(e){return e.endsWith(`/`)?e.slice(0,-1):e}function rE(e,t){return t&&!e.endsWith(`/`)?`${e}/`:e}var iE=e=>{let t=e.trim();return t.length===0?``:(t.includes(`\\`)?t.replaceAll(`\\`,`/`):t).toLowerCase()},aE=Symbol(`FILE_TREE_RENAME_VIEW`),oE=512,sE=512;function cE(e){return e===`top`||e===`center`?e:`nearest`}function lE(e,t,n){if(e===0)return-1;if(n!=null){let e=t(n);if(e!=null)return e;let r=XT(n);for(let e=r.length-1;e>=0;--e){let n=r[e];if(n==null)continue;let i=t(n);if(i!=null)return i}}return 0}function uE(e,t,n){if(e.paths.length===0)return{focusedIndex:-1,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};if(t==null)return{focusedIndex:0,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};let r=n??(t=>e.visibleIndexByPath.get(t)??null);return{focusedIndex:lE(e.paths.length,r,t),getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex}}var dE=class e{static{Object.defineProperty(e.prototype,aE,{configurable:!0,value(){return{cancel:()=>{this.#q()},commit:()=>{this.#J()},getPath:()=>this.#T,getValue:()=>this.#E,isActive:()=>this.#T!=null,setValue:e=>{this.#Y(e)}}},writable:!0})}#e;#t=new Set;#n=new Map;#r=null;#i=null;#a=new Map;#o=new Map;#s=-1;#c=null;#l=!1;#u=e=>-1;#d=new Map;#f=null;#p=null;#m=null;#h=null;#g=null;#_;#v;#y;#b=[];#x=new Int32Array;#S=new Int32Array;#C=void 0;#w=!1;#T=null;#E=``;#D=!1;#O=new Set;#k=[];#A;#j=null;#M=null;#N=null;#P=null;#F=null;#I=null;#L=null;#R=0;#z=null;#B=new Set;#V=0;#H;#U=0;#W=!1;#G=0;#K;constructor(e){let{dragAndDrop:t,fileTreeSearchMode:n,initialSearchQuery:r,initialSelectedPaths:i,renaming:a,onSearchChange:o,paths:s,preparedInput:c,...l}=e,u=BT({paths:s,preparedInput:c},`constructor`,l.sort);this.#e=l,t!=null&&t!==!1&&(this.#r=t===!0?{}:t),this.#w=a!=null&&a!==!1,a!=null&&a!==!1&&a!==!0&&(this.#C=a.canRename,this.#v=a.onError,this.#_=a.onRename),this.#y=o,this.#A=n??`hide-non-matches`,this.#H=this.#le(u.paths,u.preparedInput);let d=i?.map(e=>this.#Ne(e)).filter(e=>e!=null)??[],f=d.at(-1)??null;d.length>0&&(this.#B=new Set(d),this.#z=f,this.#V=1),this.#je(f,!1),r!=null&&this.#Te(r,!1),this.#K=this.#Re()}destroy(){this.#K?.(),this.#K=null,this.#n.clear(),this.#t.clear(),this.#d.clear(),this.#i=null,this.#he()}focusFirstItem(){this.#be().length>0&&this.#Fe(0)}focusLastItem(){this.#G<=0||(this.#Ie(),this.#Fe(this.#G-1))}focusNextItem(){this.#Ae(1)}focusParentItem(){if(this.#c==null)return;let e=ZT(this.#c);if(e==null)return;let t=this.#Z(e);t>=0&&this.#Fe(t)}focusPath(e){let t=this.#H.getPathInfo(e)?.path??null;if(t==null)return;this.#Ie();let n=this.#Z(t);n>=0&&this.#Fe(n)}scrollToPath(e,t){let n=this.#H.getPathInfo(e)?.path??null;if(n==null)return;this.#Ie();let r=this.#xe(n);r<0||this.#Me(r)!=null&&(t?.focus!==!1&&this.#Fe(r,!1),this.#L={id:this.#R+=1,offset:cE(t?.offset),visibleIndex:r},this.#De())}focusMountedPathFromInput(e){let t=this.#H.getPathInfo(e)?.path??null;if(t==null)return;let n=this.#Z(t);n>=0&&this.#Fe(n)}focusNearestPath(e){let t=this.resolveNearestVisiblePath(e);if(t==null)return null;let n=this.#Z(t);return n>=0?(this.#Fe(n),this.#be()[n]??t):null}focusPreviousItem(){this.#Ae(-1)}getFocusedIndex(){return this.#s}getFocusedItem(){return this.#c==null?null:this.#Q(this.#c)}getFocusedPath(){return this.#c}getScrollRequest(){return this.#L}clearScrollRequest(e){this.#L?.id===e&&(this.#L=null)}resolveNearestVisiblePath(e){let t=this.#be();if(this.#G===0)return null;if(e==null)return this.#c??t[0]??null;let n=this.#H.getPathInfo(e)?.path??e,r=this.#Z(n);return r>=0?t[r]??n:this.#X(n)??this.#c??t[0]??null}getSelectedPaths(){return[...this.#B]}getSelectionVersion(){return this.#V}getVisibleCount(){return this.#G}getVisibleRows(e,t){if(t<e||this.#G===0)return[];let n=Math.max(0,e),r=Math.min(this.#G-1,t);if(r<n)return[];let i=r-n+1;if(this.#F==null&&!this.#l&&r>=this.#b.length&&i<=sE){let e=[];for(let t=n;t<=r;t+=1){let n=this.#H.getVisibleRowContext(t);if(n==null)break;e.push(this.#ee(n))}return e}if(!this.#l&&r>=this.#b.length&&this.#Ie(),this.#F!=null){let e=Array.from({length:r-n+1},(e,t)=>this.#Se(n+t)),t=new Map,i=e[0]??-1,a=i;for(let n=1;n<=e.length;n+=1){let r=e[n];if(r!=null&&r===a+1){a=r;continue}if(i>=0&&this.#H.getVisibleSlice(i,a).forEach((e,n)=>{t.set(i+n,e)}),r==null){i=-1,a=-1;continue}i=r,a=r}return Array.from({length:r-n+1},(e,r)=>{let i=n+r,a=this.#Se(i),o=t.get(a),s=this.#b[a];if(o==null||s==null)throw Error(`Missing projection row for filtered visible index ${String(i)}`);return this.#$(o,i,a,{ancestorPaths:this.#re(a),path:s})})}return this.#H.getVisibleSlice(n,r).map((e,t)=>{let r=n+t,i=this.#b[r];if(i==null)throw Error(`Missing projection path for visible index ${String(r)}`);return this.#$(e,r,r,{ancestorPaths:this.#re(r),path:i})})}getStickyRowCandidates(e,t){if(this.#F!=null)return null;if(this.#G===0||e<=0||t<=0)return[];let n=[];for(let r=0;r<this.#G;r+=1){let i=e+r*t,a=Math.min(this.#G-1,Math.floor(i/t)),o=this.#te(a,r)??(a>0?this.#te(a-1,r):void 0);if(o==null)break;n.push({row:this.#ee(o),subtreeEndIndex:o.subtreeEndIndex})}return n}getItem(e){let t=this.#H.getPathInfo(e);return t==null?null:this.#Q(t.path,t)}resolveMountedDirectoryPathFromInput(e){let t=this.#H.getPathInfo(e);return t?.kind===`directory`?t.path:null}toggleMountedDirectoryFromInput(e){let t=this.resolveMountedDirectoryPathFromInput(e);t!=null&&this.#ze(t)}selectAllVisiblePaths(){this.#Ie();let e=[...this.#be()];this.#ae(e,this.#c??this.#z)}selectOnlyPath(e){let t=this.#Ne(e);t!=null&&this.#ae([t],t)}selectOnlyMountedPathFromInput(e){this.#ae([e],e)}selectPath(e){let t=this.#Ne(e);t==null||this.#B.has(t)||this.#ae([...this.#B,t])}deselectPath(e){let t=this.#Ne(e);t==null||!this.#B.has(t)||this.#ae([...this.#B].filter(e=>e!==t))}toggleFocusedSelection(){this.#c!=null&&this.togglePathSelectionFromInput(this.#c)}togglePathSelection(e){let t=this.#Ne(e);if(t!=null){if(this.#B.has(t)){this.deselectPath(t);return}this.selectPath(t)}}togglePathSelectionFromInput(e){let t=this.#Ne(e);if(t!=null){if(this.#B.has(t)){this.#ae([...this.#B].filter(e=>e!==t),t);return}this.#ae([...this.#B,t],t)}}selectPathRange(e,t){let n=this.#Ne(e);if(n==null)return;this.#Ie();let r=this.#z,i=r==null?-1:this.#Ce(r),a=this.#Ce(n);if(i===-1||a===-1){let e=t?[...this.#B,n]:[n];this.#ae(e,n);return}let[o,s]=i<=a?[i,a]:[a,i],c=this.#be().slice(o,s+1),l=t?[...this.#B,...c]:c;this.#ae(l,r)}extendSelectionFromFocused(e){if(this.#c==null)return;let t=this.#s;if(t===-1)return;let n=Math.min(this.#G-1,Math.max(0,t+e));if(n===t)return;!this.#l&&n>=this.#b.length&&this.#Ie();let r=this.#be(),i=r[t]??null,a=r[n]??null;if(i==null||a==null)return;let o=new Set(this.#B);o.has(i)&&o.has(a)?o.delete(i):o.add(a),this.#ae([...o],this.#z??i,!1),this.#Fe(n)}getDragAndDropConfig(){return this.#r}isDragAndDropEnabled(){return this.#r!=null}getDragSession(){return this.#i==null?null:{draggedPaths:[...this.#i.draggedPaths],primaryPath:this.#i.primaryPath,target:this.#i.target==null?null:{...this.#i.target}}}startDrag(e){if(this.#r==null)return!1;let t=this.#Ne(e);if(t==null||this.#M!=null&&this.#M.length>0)return!1;let n=this.getSelectedPaths(),r=NT(t,n);return this.#r.canDrag?.(r)!==!1&&(n.includes(t)||this.#ae([t],t,!1),this.#Pe(t),this.#i={draggedPaths:r,primaryPath:t,target:null},this.#De(),!0)}setDragTarget(e){let t=this.#i;if(t==null)return;let n=e;if(n!=null){let e=FT(t.draggedPaths,n);(IT(t.draggedPaths,n)||this.#r?.canDrop?.(e)===!1)&&(n=null)}PT(t.target,n)||(this.#i={...t,target:n},this.#De())}cancelDrag(){this.#i!=null&&(this.#i=null,this.#De())}completeDrag(){let e=this.#i;if(e==null)return!1;this.#i=null;let t=e.target==null?null:{...e.target};if(t==null)return this.#De(),!1;let n=FT(e.draggedPaths,t);if(IT(e.draggedPaths,t)||this.#r?.canDrop?.(n)===!1)return this.#De(),!1;let r=RT(e.draggedPaths,t);if(r==null)return this.#De(),!1;try{if(r.operations.length===1){let e=r.operations[0];if(e==null||e.type!==`move`)throw Error(`Expected a single move operation for one-item drops`);this.#H.move(e.from,e.to,{collision:e.collision})}else this.#ce(r.operations),this.#H.batch(r.operations)}catch(e){return this.#De(),this.#r?.onDropError?.(e instanceof Error?e.message:String(e),n),!1}return this.#r?.onDropComplete?.(r.result),!0}subscribe(e){return this.#t.add(e),e(),()=>{this.#t.delete(e)}}add(e){this.#H.add(e)}remove(e,t={}){this.#H.remove(e,t)}move(e,t,n={}){this.#H.move(e,t,n)}batch(e){this.#H.batch(e)}onMutation(e,t){let n=e,r=t,i=this.#n.get(n);return i??(i=new Set,this.#n.set(n,i)),i.add(r),()=>{let e=this.#n.get(n);e?.delete(r),e?.size===0&&this.#n.delete(n)}}setSearch(e){this.#Te(e,!0)}openSearch(e=``){this.#Te(e,!0)}closeSearch(){this.#Te(null,!0)}isSearchOpen(){return this.#M!==null}getSearchValue(){return this.#M??``}getSearchMatchingPaths(){return this.#k}focusNextSearchMatch(){this.#we(1)}focusPreviousSearchMatch(){this.#we(-1)}startRenaming(e=this.#c??``,t={}){if(!this.#w)return!1;let n=this.#H.getPathInfo(e);if(n==null)return!1;let r=n.path,i=$T(r),a=nE(r);if(this.#C?.({isFolder:i,path:a})===!1)return!1;for(let e of XT(r))this.#H.isExpanded(e)||this.#H.expand(e);return this.#ae([r],r,!1),this.#M!=null&&(this.#Te(null,!1),this.#y?.(this.#M)),this.#Pe(r),this.#T=r,this.#E=tE(r),this.#D=t.removeIfCanceled??!1,this.#De(),!0}#q(){if(this.#T==null)return;let e=this.#T,t=this.#D;if(this.#T=null,this.#E=``,this.#D=!1,t){this.remove(e,$T(e)?{recursive:!0}:void 0);return}this.#Pe(e),this.#De()}#J(){let e=this.#T;if(e==null)return;if(this.#D&&this.#E.trim().length===0){this.#T=null,this.#E=``,this.#D=!1,this.remove(e,$T(e)?{recursive:!0}:void 0);return}let t=$T(e),n=kT({files:this.#H.list(),isFolder:t,nextBasename:this.#E,path:nE(e)});if(this.#T=null,this.#E=``,this.#D=!1,`error`in n){this.#Pe(e),this.#v?.(n.error),this.#De();return}if(n.sourcePath===n.destinationPath){this.#Pe(e),this.#De();return}this.#_?.({destinationPath:n.destinationPath,isFolder:n.isFolder,sourcePath:n.sourcePath}),this.move(rE(n.sourcePath,t),rE(n.destinationPath,t))}#Y(e){this.#T!=null&&this.#E!==e&&(this.#E=e,this.#De())}resetPaths(e,t={}){let n=!Array.isArray(e),r=n?void 0:e,i=n?e:t,a=this.#H.list().length,o=this.#G,s=BT({paths:r,preparedInput:i.preparedInput},`resetPaths`,this.#e.sort),c=this.#le(s.paths,s.preparedInput,i.initialExpandedPaths),l=this.#c,u=this.#T,d=this.getSelectedPaths(),f=this.#z;this.#K?.(),this.#H=c,this.#d.clear(),this.#he();let p=d.map(e=>c.getPathInfo(e)?.path??null).filter(e=>e!=null),m=!YT(this.#B,p);this.#B=new Set(p),m&&(this.#V+=1),this.#z=f==null?null:c.getPathInfo(f)?.path??null,this.#T=u==null?null:c.getPathInfo(u)?.path??null,this.#T??(this.#E=``,this.#D=!1),this.#je(l,l!=null||p.length>0||this.#z!=null),this.#K=this.#Re(),this.#De(),this.#Oe({canonicalChanged:!0,operation:`reset`,pathCountAfter:s.paths.length,pathCountBefore:a,projectionChanged:!0,usedPreparedInput:i.preparedInput!=null,visibleCountDelta:this.#G-o})}#X(e){this.#Ie();let t=ZT(e),n=QT(e,t),r=null,i=null;for(let e of this.#be()){if(ZT(e)!==t)continue;let a=QT(e,t);if(a<n){r=e;continue}if(a>n){i=e;break}}return r??i}#Z(e){let t=this.#Ce(e);if(t!==-1)return t;let n=XT(e);for(let e=n.length-1;e>=0;--e){let t=n[e];if(t==null)continue;let r=this.#Ce(t);if(r!==-1)return r}return this.#be().length>0?0:-1}#Q(e,t){let n=this.#d.get(e);if(n!=null)return n;let r=t??this.#H.getPathInfo(e);if(r==null)return null;let i=r.kind===`directory`?this.#oe(r.path):this.#se(r.path);return this.#d.set(r.path,i),i}#$(e,t,n,r){return{ancestorPaths:r.ancestorPaths,depth:e.depth,flattenedSegments:e.flattenedSegments?.map(e=>({isTerminal:e.isTerminal,name:e.name,path:e.path})),hasChildren:e.hasChildren,index:t,isExpanded:e.isExpanded,isFlattened:e.isFlattened,isFocused:r.path===this.#c,isSelected:this.#B.has(r.path),kind:e.kind,level:e.depth,name:e.name,path:r.path,posInSet:r.posInSet??this.#x[n]??0,setSize:r.setSize??this.#S[n]??0}}#ee(e){return this.#$(e.row,e.index,e.index,{ancestorPaths:e.ancestorPaths,path:e.row.path,posInSet:e.posInSet,setSize:e.setSize})}#te(e,t){let n=this.#H.getVisibleRowContext(e);return n==null?void 0:n.ancestorRows[t]??(t===n.ancestorRows.length&&n.row.kind===`directory`&&n.row.isExpanded?n:void 0)}#ne(e){let t=this.#a.get(e);if(t!=null)return t;let n=this.#u(e),r=n<0?[]:[...this.#ne(n),n];return this.#a.set(e,r),r}#re(e){let t=this.#o.get(e);if(t!=null)return t;let n=this.#ne(e).map(e=>this.#b[e]??``).filter(e=>e!==``);return this.#o.set(e,n),n}#ie(e){this.#H.collapse(e)}#ae(e,t=this.#z,n=!0){let r=[...new Set(e)],i=!YT(this.#B,r),a=this.#z!==t;!i&&!a||(this.#B=new Set(r),this.#z=t,i&&(this.#V+=1),n&&this.#De())}#oe(e){return{collapse:()=>{this.#ie(e)},deselect:()=>{this.deselectPath(e)},expand:()=>{this.#ke(e)},focus:()=>{this.focusPath(e)},getPath:()=>e,isDirectory:()=>!0,isExpanded:()=>this.#H.isExpanded(e),isFocused:()=>this.#c===e,isSelected:()=>this.#B.has(e),select:()=>{this.selectPath(e)},toggleSelect:()=>{this.togglePathSelection(e)},toggle:()=>{this.#ze(e)}}}#se(e){return{deselect:()=>{this.deselectPath(e)},focus:()=>{this.focusPath(e)},getPath:()=>e,isDirectory:()=>!1,isFocused:()=>this.#c===e,isSelected:()=>this.#B.has(e),select:()=>{this.selectPath(e)},toggleSelect:()=>{this.togglePathSelection(e)}}}#ce(e){let t=this.#H.list();this.#le(t).batch(e)}#le(e,t,n){return new wT({...this.#e,paths:e,preparedInput:t??void 0,...n===void 0?{}:{initialExpandedPaths:n}})}#ue(){return this.#h??=this.#H.list(),this.#h}#de(){if(this.#m!=null)return this.#m;let e=new Set;for(let t of this.#ue()){e.add(t);for(let n of XT(t))e.add(n)}return this.#m=[...e].sort(),this.#m}#fe(){return this.#g??=this.#ue().map(eE),this.#g}#pe(){return this.#f??=this.#de().filter(e=>e.endsWith(`/`)),this.#f}#me(){return this.#p??=this.#pe().map(eE),this.#p}#he(){this.#f=null,this.#p=null,this.#m=null,this.#h=null,this.#g=null}#ge(){return this.#pe().filter(e=>this.#H.isExpanded(e))}#_e(e){let t=new Set(this.#j??[]);if(e)for(let e of this.#B)for(let n of XT(e))t.add(n);this.#ve(t)}#ve(e){this.#W=!0;try{for(let t of this.#pe()){let n=e.has(t),r=this.#H.isExpanded(t);n&&!r?this.#H.expand(t):!n&&r&&this.#H.collapse(t)}}finally{this.#W=!1}}#ye(){if(this.#M==null||this.#M.length===0){this.#k=[],this.#F=null,this.#I=null,this.#P=null,this.#G=this.#U;return}let e=this.#b;if(this.#k=e.filter(e=>this.#O.has(e)),this.#A!==`hide-non-matches`||this.#O.size===0){this.#F=null,this.#I=null,this.#P=null,this.#G=this.#U;return}let t=[],n=[],r=new Map;for(let[i,a]of e.entries())this.#N?.has(a)===!0&&(r.set(a,n.length),t.push(i),n.push(a));this.#F=t,this.#I=n,this.#P=r,this.#G=n.length}#be(){return this.#I??this.#b}#xe(e){return this.#I==null?this.#H.getVisibleIndex(e)??-1:this.#P?.get(e)??-1}#Se(e){return this.#F?.[e]??e}#Ce(e){return this.#P?.get(e)??this.#H.getVisibleIndex(e)??-1}#we(e){let t=this.#k;if(t.length===0)return;let n=this.#c,r=n==null?-1:t.indexOf(n),i=t[r<0?e>0?0:t.length-1:Math.min(t.length-1,Math.max(0,r+e))];i!=null&&this.focusPath(i)}#Te(e,t){let n=e==null?null:iE(e),r=this.#M;if(r!==n){if(r==null&&n!=null&&(this.#j=this.#ge()),this.#M=n,n==null)this.#_e(!0),this.#j=null,this.#O.clear(),this.#N=null,this.#je(this.#c,!0);else if(n.length===0)this.#_e(!1),this.#O.clear(),this.#N=null,this.#je(this.#c,!0);else{let e=this.#Ee();this.#je(e,!0)}t&&(this.#y?.(this.#M),this.#De())}}#Ee(){if(this.#M==null||this.#M.length===0)return this.#O.clear(),this.#c;let e=this.#M,t=this.#ue(),n=this.#fe(),r=[],i=new Set,a=null;for(let o=0;o<t.length;o+=1){if(!n[o].includes(e))continue;let s=t[o];r.push(s),i.add(s),a??=s}let o=this.#pe(),s=this.#me();for(let t=0;t<o.length;t+=1){if(!s[t].includes(e))continue;let n=o[t];i.has(n)||(r.push(n),i.add(n),a??=n)}this.#O=i;let c=this.#A===`hide-non-matches`&&r.length>0?new Set:null;this.#N=c;let l=this.#A===`expand-matches`?new Set(this.#j??[]):new Set;for(let e of r){c?.add(e),e.endsWith(`/`)&&l.add(e);for(let t of XT(e))l.add(t),c?.add(t)}return this.#ve(l),a??this.#c}#De(){for(let e of this.#t)e()}#Oe(e){this.#n.get(e.operation)?.forEach(t=>{t(e)}),this.#n.get(`*`)?.forEach(t=>{t(e)})}#ke(e){for(let t of XT(e))this.#H.isExpanded(t)||this.#H.expand(t);this.#H.isExpanded(e)||this.#H.expand(e)}#Ae(e){let t=this.#G;if(t===0)return;let n=this.#s===-1?0:this.#s,r=Math.min(t-1,Math.max(0,n+e));(r!==n||this.#s===-1)&&(!this.#l&&this.#F==null&&r>=this.#b.length&&this.#Ie(),this.#Fe(r))}#je(e,t=!0){let n=this.#H.getVisibleCount();this.#U=n;let r=uE(this.#H.getVisibleTreeProjectionData(t?void 0:Math.min(n,oE)),e,t?e=>this.#H.getVisibleIndex(e):void 0);this.#a.clear(),this.#o.clear(),this.#l=r.paths.length>=n,this.#u=r.getParentIndex,this.#b=r.paths,this.#x=r.posInSetByIndex,this.#S=r.setSizeByIndex,this.#ye(),this.#s=e==null?this.#be().length>0?0:-1:this.#Z(e),this.#c=this.#s<0?null:this.#Me(this.#s)}#Me(e){return this.#be()[e]??(this.#F==null?this.#H.getVisibleRowContext(e)?.row.path??null:null)}#Ne(e){return this.#H.getPathInfo(e)?.path??null}#Pe(e){if(e==null)return;let t=this.#Z(e);t>=0&&this.#Fe(t,!1)}#Fe(e,t=!0){let n=this.#Me(e);n!=null&&(this.#s!==e||this.#c!==n)&&(this.#s=e,this.#c=n,t&&this.#De())}#Ie(){this.#l||this.#je(this.#c,!0)}#Le(e){let t=WT(this.#T,e);t==null&&this.#T!=null&&(this.#E=``),this.#T=t;let n=WT(this.#c,e,!0),r=[...this.#B].map(t=>WT(t,e)).filter(e=>e!=null).map(e=>this.#H.getPathInfo(e)?.path??null).filter(e=>e!=null),i=WT(this.#z,e),a=i==null?null:this.#H.getPathInfo(i)?.path??null,o=[...new Set(r)];return YT(this.#B,o)||(this.#B=new Set(o),this.#V+=1),this.#z=a,n}#Re(){return this.#H.on(`*`,e=>{if(this.#W)return;e.canonicalChanged&&(this.#d.clear(),this.#he()),this.#i!=null&&VT(e)&&(this.#i=null);let t=VT(e)?this.#Le(e):this.#c,n=this.#M!=null&&this.#M.length>0?this.#Ee():this.#M===``?this.#c:t,r=this.#M!=null||e.operation!==`expand`&&e.operation!==`collapse`;this.#je(n,r),this.#De();let i=JT(e);i!=null&&this.#Oe(i)})}#ze(e){if(this.#H.isExpanded(e)){this.#ie(e);return}this.#ke(e)}},fE=e=>{if(e==null||e.length===0)return`0`;let t=`${e.length}`;for(let n of e)t+=`\0${n.path}\0${n.status}`;return t};function pE(e){let t=e.endsWith(`/`),n=``,r=-1;for(let t=0;t<=e.length;t+=1){if(e[t]!==`/`&&t!==e.length){r===-1&&(r=t);continue}r!==-1&&(n!==``&&(n+=`/`),n+=e.slice(r,t),r=-1)}return n===``?null:{isDirectory:t,path:n}}function mE(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;if(t.length===0)return[];let n=[],r=0;for(;;){let e=t.indexOf(`/`,r);if(e===-1)break;n.push(t.slice(0,e+1)),r=e+1}return n}function hE(e,t){return t?`${e}/`:e}function gE(e,t=null){let n=fE(e==null?void 0:[...e]);if(n===`0`)return null;if(t?.signature===n)return t;let r=new Map,i=new Set,a=new Set,o=new Map;for(let t of e??[]){let e=vE(t);e!=null&&xE({canonicalPath:e.canonicalPath,changeCountByDirectoryPath:o,directoriesWithChanges:i,ignoredDirectoryPaths:a,isDirectory:e.isDirectory,status:t.status,statusByPath:r})}return r.size===0?null:{changeCountByDirectoryPath:o,directoriesWithChanges:i,ignoredDirectoryPaths:a,signature:n,statusByPath:r}}function _E(e,t){let n=t?.remove??[],r=t?.set??[];if(n.length===0&&r.length===0)return e;let i=new Map(e?.statusByPath),a=new Set(e?.directoriesWithChanges),o=new Set(e?.ignoredDirectoryPaths),s=new Map(e?.changeCountByDirectoryPath),c=!1;for(let e of n){let t=yE(e);t!=null&&(c=bE({canonicalPath:t.canonicalPath,changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,statusByPath:i})||c)}for(let e of r){let t=vE(e);t!=null&&(c=xE({canonicalPath:t.canonicalPath,changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,isDirectory:t.isDirectory,status:e.status,statusByPath:i})||c)}return c?i.size===0?null:{changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,signature:wE(i),statusByPath:i}:e}function vE(e){return yE(e.path)}function yE(e){let t=pE(e);if(t!=null)return{canonicalPath:hE(t.path,t.isDirectory),isDirectory:t.isDirectory}}function bE({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,statusByPath:i}){let a=i.get(e);return a!=null&&(i.delete(e),a===`ignored`&&e.endsWith(`/`)&&r.delete(e),CE(t,n,e),!0)}function xE({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,isDirectory:i,status:a,statusByPath:o}){let s=o.get(e);return s!==a&&(s??SE(t,n,e),o.set(e,a),a===`ignored`&&i?r.add(e):i&&r.delete(e),!0)}function SE(e,t,n){for(let r of mE(n))e.set(r,(e.get(r)??0)+1),t.add(r)}function CE(e,t,n){for(let r of mE(n)){let n=(e.get(r)??0)-1;n>0?e.set(r,n):(e.delete(r),t.delete(r))}}function wE(e){let t=`${e.size}`;for(let[n,r]of e)t+=`\0${n}\0${r}`;return t}var TE=e=>e.trim().toLowerCase(),EE=e=>e.split(`/`).at(-1)??e,DE=e=>{let t=e.toLowerCase().split(`.`),n=[];for(let e=1;e<t.length;e+=1)n.push(t.slice(e).join(`.`));return n};function OE(e,t){return typeof e==`string`?{name:e,remappedFrom:t}:{...e,remappedFrom:t}}function kE(e){let t=jx(e),n=t.remap,r=new Map;for(let[e,n]of Object.entries(t.byFileName??{}))r.set(e.toLowerCase(),n);let i=new Map;for(let[e,n]of Object.entries(t.byFileExtension??{}))i.set(TE(e),n);let a=Object.entries(t.byFileNameContains??{}).map(([e,t])=>[e.toLowerCase(),t]);return{resolveIcon:(e,o)=>{if(e===`file-tree-icon-file`&&o!=null){let s=EE(o),c=s.toLowerCase(),l=r.get(c);if(l!=null)return OE(l,e);for(let[t,n]of a)if(c.includes(t))return OE(n,e);let u=DE(s);for(let t of u){let n=i.get(t);if(n!=null)return OE(n,e)}let d=kx(t.set,s,u);if(d!=null&&t.set!==`none`){if(d==="default"){let t=n?.[e];if(t!=null)return OE(t,e)}return{name:Dx(d),remappedFrom:e,token:d}}}let s=n?.[e];return s==null?{name:e}:OE(s,e)}}}var AE,jE,ME,NE,PE,FE,IE,LE,RE,zE,BE={},VE=[],HE=Array.isArray,UE=VE.slice,WE=Object.assign;function GE(e){e&&e.parentNode&&e.remove()}function KE(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return arguments.length>2&&(o.children=arguments.length>3?UE.call(arguments,2):n),qE(e,o,r,i,null)}function qE(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++jE,__i:-1,__u:0};return i==null&&AE.vnode!=null&&AE.vnode(a),a}function JE(e){return e.children}function YE(e,t){this.props=e,this.context=t,this.__g=0}function XE(e,t){if(t==null)return e.__?XE(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?XE(e):null}function ZE(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=n.__e;break}return ZE(e)}}function QE(e){(8&e.__g||!(e.__g|=8)||!ME.push(e)||PE++)&&NE==AE.debounceRendering||((NE=AE.debounceRendering)||queueMicrotask)($E)}function $E(){for(var e,t,n,r,i,a,o,s,c=1;ME.length;)ME.length>c&&ME.sort(FE),e=ME.shift(),c=ME.length,8&e.__g&&(n=void 0,i=(r=(t=e).__v).__e,a=[],o=[],(s=t.__P)&&((n=WE({},r)).__v=r.__v+1,AE.vnode&&AE.vnode(n),sD(s,n,r,t.__n,s.namespaceURI,32&r.__u?[i]:null,a,i??XE(r),!!(32&r.__u),o,s.ownerDocument),n.__v=r.__v,n.__.__k[n.__i]=n,lD(a,n,o),n.__e!=i&&ZE(n)));PE=0}function eD(e,t,n,r,i,a,o,s,c,l,u,d){var f,p,m,h,g,_,v,y=r&&r.__k||VE,b=t.length;for(c=tD(n,t,y,c,b),f=0;f<b;f++)(m=n.__k[f])!=null&&(p=m.__i==-1?BE:y[m.__i]||BE,m.__i=f,_=sD(e,m,p,i,a,o,s,c,l,u,d),h=m.__e,m.ref&&p.ref!=m.ref&&(p.ref&&fD(p.ref,null,m),u.push(m.ref,m.__c||h,m)),g==null&&h!=null&&(g=h),(v=!!(4&m.__u))||p.__k===m.__k?c=nD(m,c,e,v):typeof m.type==`function`&&_!==void 0?c=_:h&&(c=h.nextSibling),m.__u&=-7);return n.__e=g,c}function tD(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(c=a+f,(o=e.__k[a]=typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?qE(null,o,null,null,null):HE(o)?qE(JE,{children:o},null,null,null):o.constructor==null&&o.__b>0?qE(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=e,o.__b=e.__b+1,s=null,(l=o.__i=rD(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=XE(s)),pD(s,s));return r}function nD(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=nD(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=XE(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function rD(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&e.key==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function iD(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n??``}function aD(e,t,n,r,i){var a;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||iD(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||iD(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(IE,`$1`)),(t=t.slice(2))[0].toLowerCase()!=t[0]&&(t=t.toLowerCase()),e.__l||={},e.__l[t+a]=n,n?r?n.l=r.l:(n.l=LE,e.addEventListener(t,a?zE:RE,a)):e.removeEventListener(t,a?zE:RE,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function oD(e){return function(t){if(this.__l){var n=this.__l[t.type+e];if(t.u==null)t.u=LE++;else if(t.u<n.l)return;return n(AE.event?AE.event(t):t)}}}function sD(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M=t.type;if(t.constructor!=null)return null;128&n.__u&&(c=!!(32&n.__u),n.__c.__z&&(s=t.__e=n.__e=(a=n.__c.__z)[0],n.__c.__z=null)),(d=AE.__b)&&d(t);n:if(typeof M==`function`)try{if(v=t.props,y=`prototype`in M&&M.prototype.render,b=(d=M.contextType)&&r[d.__c],x=d?b?b.props.value:d.__:r,n.__c?2&(f=t.__c=n.__c).__g&&(f.__g|=1,_=!0):(y?t.__c=f=new M(v,x):(t.__c=f=new YE(v,x),f.constructor=M,f.render=mD),b&&b.sub(f),f.props=v,f.state||(f.state={}),f.context=x,f.__n=r,p=!0,f.__g|=8,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&M.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=WE({},f.__s)),WE(f.__s,M.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&M.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&M.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,x),!(4&f.__g)&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,x)||t.__v==n.__v){for(t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),S=0;S<f._sb.length;S++)f.__h.push(f._sb[S]);f._sb=[],f.__h.length&&o.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,x),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=x,f.props=v,f.__P=e,f.__g&=-5,C=AE.__r,w=0,y){for(f.state=f.__s,f.__g&=-9,C&&C(t),d=f.render(f.props,f.state,f.context),T=0;T<f._sb.length;T++)f.__h.push(f._sb[T]);f._sb=[]}else do f.__g&=-9,C&&C(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(8&f.__g&&++w<25);f.state=f.__s,f.getChildContext!=null&&(r=WE({},r,f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),E=d,d!=null&&d.type===JE&&d.key==null&&(E=uD(d.props.children)),s=eD(e,HE(E)?E:[E],t,n,r,i,a,o,s,c,l,u),t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__g&=-4)}catch(e){if(t.__v=null,c||a!=null){if(e.then){for(D=0,O=!1,t.__u|=c?160:128,t.__c.__z=[],k=0;k<a.length;k++)(A=a[k])==null||O||(A.nodeType==8&&A.data==`$s`?(D>0&&t.__c.__z.push(A),D++,a[k]=null):A.nodeType==8&&A.data==`/$s`?(--D>0&&t.__c.__z.push(A),O=D===0,s=a[k],a[k]=null):D>0&&(t.__c.__z.push(A),a[k]=null));if(!O){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__c.__z=[s]}t.__e=s}else{for(j=a.length;j--;)GE(a[j]);cD(t)}}else t.__e=n.__e,t.__k=n.__k,e.then||cD(t);AE.__e(e,t,n)}else s=t.__e=dD(n.__e,t,n,r,i,a,o,c,l,u);return(d=AE.diffed)&&d(t),128&t.__u?void 0:s}function cD(e){e&&e.__c&&(e.__c.__g|=4),e&&e.__k&&e.__k.forEach(cD)}function lD(e,t,n){for(var r=0;r<n.length;r++)fD(n[r],n[++r],n[++r]);AE.__c&&AE.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){AE.__e(e,t.__v)}})}function uD(e){return typeof e!=`object`||!e||e.__b&&e.__b>0?e:HE(e)?e.map(uD):WE({},e)}function dD(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v=n.props,y=t.props,b=t.type;if(b==`svg`?i=`http://www.w3.org/2000/svg`:b==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(u=0;u<a.length;u++)if((m=a[u])&&`setAttribute`in m==!!b&&(b?m.localName==b:m.nodeType==3)){e=m,a[u]=null;break}}if(e==null){if(b==null)return l.createTextNode(y);e=l.createElementNS(i,b,y.is&&y),s&&=(AE.__m&&AE.__m(t,a),!1),a=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(a&&=UE.call(e.childNodes),v=n.props||BE,!s&&a!=null)for(v={},u=0;u<e.attributes.length;u++)v[(m=e.attributes[u]).name]=m.value;for(u in v)if(m=v[u],u!=`children`){if(u==`dangerouslySetInnerHTML`)f=m;else if(!(u in y)){if(u==`value`&&`defaultValue`in y||u==`checked`&&`defaultChecked`in y)continue;aD(e,u,null,m,i)}}for(u in _=1&n.__u,y)m=y[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||v[u]===m&&!_||aD(e,u,m,v[u],i);if(d)s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(f&&(e.innerHTML=``),eD(b==`template`?e.content:e,HE(p)?p:[p],t,n,r,b==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&XE(n,0),s,c,l),a!=null)for(u=a.length;u--;)GE(a[u]);s||(u=`value`,b==`progress`&&h==null?e.removeAttribute(`value`):h==null||h===e[u]&&(b!==`progress`||h)||aD(e,u,h,v[u],i),u=`checked`,g!=null&&g!=e[u]&&aD(e,u,g,v[u],i))}return e}function fD(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){AE.__e(e,n)}}function pD(e,t,n){var r,i;if(AE.unmount&&AE.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||fD(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){AE.__e(e,t)}r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&pD(r[i],t,n||typeof e.type!=`function`);n||GE(e.__e),e.__e&&e.__e.__l&&(e.__e.__l=null),e.__e=e.__c=e.__=null}function mD(e,t,n){return this.constructor(e,n)}function hD(e,t){var n,r,i,a;t==document&&(t=document.documentElement),AE.__&&AE.__(e,t),r=(n=!!(e&&32&e.__u))?null:t.__k,e=t.__k=KE(JE,null,[e]),i=[],a=[],sD(t,e,r||BE,BE,t.namespaceURI,r?null:t.firstChild?UE.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a,t.ownerDocument),lD(i,e,a)}function gD(e,t){e.__u|=32,hD(e,t)}AE={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=8&i.__g),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=8&i.__g),o)return void(i.__g|=2)}catch(t){e=t}}throw PE=0,e}},jE=0,YE.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=WE({},this.state);typeof e==`function`&&(e=e(WE({},n),this.props)),e&&WE(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),QE(this))},YE.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),QE(this))},YE.prototype.render=JE,ME=[],PE=0,FE=function(e,t){return e.__v.__b-t.__v.__b},IE=/(PointerCapture)$|Capture$/i,LE=0,RE=oD(!1),zE=oD(!0);var _D=0;Array.isArray;function Q(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--_D,__i:-1,__u:0,__source:i,__self:a};return AE.vnode&&AE.vnode(l),l}var vD=16,yD=16,bD={};function xD({name:e,remappedFrom:t,token:n,width:r,height:i,viewBox:a,label:o,alignCapitals:s=!1}){"use no memo";let c=`#${e.replace(/^#/,``)}`,{width:l,height:u,viewBox:d}=bD[e]??{width:vD,height:yD},f=r??l,p=i??u,m=a??d??`0 0 ${l} ${u}`;return Q(`svg`,{"data-icon-name":t??e,"data-icon-token":n,"data-align-capitals":s,...o==null?{"aria-hidden":!0}:{"aria-label":o,role:`img`},viewBox:m,width:f,height:p,children:Q(`use`,{href:c})})}var SD=e=>e!==void 0&&/\s/.test(e),CD=(e,t)=>{let n=t=>SD(e[t-1])||SD(e[t]);if(!n(t))return t;for(let r=1;r<e.length;r++){let i=t-r;if(i>0&&!n(i))return i;let a=t+r;if(a<e.length&&!n(a))return a}return t},wD=e=>CD(e,Math.ceil(e.length/2)),TD=e=>{if(e.length<2)return[e,``];let t=wD(e);return[e.slice(0,t),e.slice(t)]},ED=e=>{if(e.length<4)return[e,``];let t=e.lastIndexOf(`.`)+1,n=e.length-t>10,r=t>=1&&!n?t:wD(e);return[e.slice(0,r),e.slice(r)]},DD=e=>{if(e.length<4)return[e,``];let t=e.lastIndexOf(`/`)+1,n=e.length-t>25,r=t>=1&&!n?t:Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]},OD=(e,{splitIndex:t}={})=>{if(typeof t!=`number`){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}return[e.slice(0,t),e.slice(t)]},kD=(e,{splitOffset:t}={})=>{if(typeof t!=`number`||t<=0||t>=e.length){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}let n=e.length-t;return[e.slice(0,n),e.slice(n)]},AD=(e,{splitOffset:t}={})=>{if(typeof t!=`number`||t<=0||t>=e.length){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}let n=t;return[e.slice(0,n),e.slice(n)]};function jD({children:e,marker:t,variant:n=`default`}){"use no memo";return Q(`div`,{"aria-hidden":!0,"data-truncate-marker-cell":!0,children:Q(`div`,{"data-truncate-marker":!0,children:typeof t==`function`?t({children:e}):n===`fade`?Q(`span`,{"data-truncate-fade":!0}):t})})}function MD(e){"use no memo";let{mode:t,children:n}=e;return Q(`div`,{children:[Q(`div`,{"data-truncate-content":`visible`,children:t===`fruncate`?Q(`span`,{children:n}):n}),Q(`div`,{"data-truncate-content":`overflow`,"aria-hidden":!0,children:t===`fruncate`?Q(`span`,{children:n}):n})]})}function ND({children:e,mode:t=`truncate`,marker:n=`…`,variant:r=`default`,...i}){"use no memo";let a=Q(MD,{mode:t,children:e},`content`),o=Q(jD,{marker:n,mode:t,variant:r},`marker`),s=Q(`div`,{"data-truncate-fill":!0},`fill`);return Q(`div`,{"data-truncate-container":t,"data-truncate-variant":r,...i,children:Q(`div`,{"data-truncate-grid":!0,children:t===`truncate`?[a,o]:[o,a,s]})})}function PD({children:e,...t}){"use no memo";return Q(ND,{mode:`truncate`,...t,children:e})}function FD({children:e,...t}){"use no memo";return Q(ND,{mode:`fruncate`,...t,children:e})}function ID({children:e,contents:t,priority:n=`end`,split:r=`center`,minimumLength:i=12,className:a,style:o,...s}){"use no memo";let c=null,l=null;if(Array.isArray(t)){if(t.length!==2)return console.error(`MiddleTruncate: contents must be an array of two items`),null;c=Q(PD,{...s,children:t[0]}),l=Q(FD,{...s,children:t[1]})}else{if(typeof e!=`string`)return console.error(`MiddleTruncate: children must be a string`),null;if(e.length===0)return Q(`div`,{className:a,style:o});if(e.length<i)return Q(n===`end`?FD:PD,{...s,className:a,style:o,children:e});let t=null,u=null,d=null;if(typeof r==`string`)r===`center`?t=TD:r===`extension`?t=ED:r===`leaf-path`&&(t=DD);else if(typeof r==`number`)t=OD,u=r;else if(Array.isArray(r)){let[e,n]=r;d=n,e===`last`?t=kD:e===`first`&&(t=AD)}else typeof r==`function`&&(t=r);t??=TD;let[f,p]=t(e,{priority:n,variant:s.variant,splitIndex:typeof u==`number`?u:void 0,splitOffset:typeof d==`number`?d:void 0}),m=f.length>=p.length,h=n===`equal`&&!m,g=n===`equal`&&m,_={},v={};h&&(_.marker=``),g&&(v.marker=``),c=Q(PD,{...s,..._,children:f}),l=Q(FD,{...s,...v,children:p})}return Q(`div`,{"data-truncate-group-container":`middle`,className:a,style:o,children:[Q(`div`,{"data-truncate-segment-priority":n===`start`||n===`equal`?`1`:`2`,children:c}),Q(`div`,{"data-truncate-segment-priority":n===`end`||n===`equal`?`1`:`2`,children:l})]})}var LD={endIndex:-1,startIndex:-1};function RD(e,t,n){return Math.min(Math.max(e,t),n)}function zD(e,t){return e<0||t<e?LD:{endIndex:t,startIndex:e}}function BD(e){return e.startIndex<0||e.endIndex<e.startIndex}function VD(e,t){return BD(e)?0:(e.endIndex-e.startIndex+1)*t}function HD(e,t,n){if(t<=0)return-1;let r=t*n;return e<=0?0:e>=r?t:Math.floor(e/n)}function UD(e,t,n){return t<=0||e<=0?-1:e>=t*n?t-1:Math.ceil(e/n)-1}function WD(e){let t=new Map;return e.forEach((e,n)=>{if(e.kind!==`directory`||!e.isExpanded)return;let r=e.ancestorPaths.length,i=t.get(r);if(i==null){t.set(r,[n]);return}i.push(n)}),t}function GD(e,t){let n=0,r=e.length-1,i=-1;for(;n<=r;){let a=Math.floor((n+r)/2),o=e[a];if(o==null)break;if(o<=t){i=a,n=a+1;continue}r=a-1}return i}function KD(e){let t=new Map,n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(i==null)continue;let a=i.kind===`directory`&&i.isExpanded?[...i.ancestorPaths,i.path]:i.ancestorPaths,o=0;for(;o<n.length&&o<a.length&&n[o]===a[o];)o+=1;for(let e=n.length-1;e>=o;--e){let i=n[e];i!=null&&t.set(i,r-1)}n.length=o;for(let e=o;e<a.length;e+=1){let t=a[e];t!=null&&n.push(t)}}let r=e.length-1;for(let e of n)t.set(e,r);return t}function qD(e,t,n){if(e.length===0||t<=0)return[];let r=KD(e),i=WD(e),a=[];for(let r=0;r<e.length;r+=1){let o=i.get(r);if(o==null||o.length===0)break;let s=t+r*n,c=GD(o,Math.min(e.length-1,Math.floor(s/n))),l=null;for(;c>=0;){let t=o[c],n=t==null?null:e[t]??null;if(n!=null&&(r===0||n.ancestorPaths[r-1]===a[r-1]?.path)){l=n;break}--c}if(l==null)break;a.push(l)}return a.map((i,a)=>{let o=a*n,s=(r.get(i.path)??e.length-1)+1;if(s>=e.length)return{row:i,top:o};let c=s*n-t;return{row:i,top:Math.min(o,c-n)}}).filter(e=>e.top+n>0)}function JD(e,t){let n=t.totalRowCount??e.length,r=n*t.itemHeight,i=Math.max(0,t.viewportHeight),a=Math.max(0,Math.floor(t.overscan)),o=Math.max(0,r-i),s=RD(t.scrollTop,0,o),c=t.stickyRows??qD(e,s,t.itemHeight),l=c.reduce((e,n)=>Math.max(e,n.top+t.itemHeight),0),u=Math.min(r,s+l),d=Math.max(0,i-l),f=Math.max(0,r-u),p=HD(s,n,t.itemHeight),m=HD(u,n,t.itemHeight),h=l<=0||p<0||p>=n?-1:p,g=h===-1?-1:Math.min(n-1,m-1),_=h===-1||g<h?0:g-h+1,v=d<=0||m>=n?LD:zD(m,UD(u+d,n,t.itemHeight)),y=g+1,b=BD(v)?LD:zD(Math.max(y,v.startIndex-a),Math.min(n-1,v.endIndex+a)),x=VD(b,t.itemHeight);return{occlusion:{firstOccludedIndex:h,lastOccludedIndex:g,occludedCount:_},physical:{itemHeight:t.itemHeight,maxScrollTop:o,overscan:a,scrollTop:s,totalHeight:r,totalRowCount:n,viewportHeight:i},projected:{contentHeight:f,paneHeight:d,paneTop:u},sticky:{height:l,rows:c},visible:v,window:{endIndex:b.endIndex,height:x,offsetTop:BD(b)?0:b.startIndex*t.itemHeight,startIndex:b.startIndex}}}var YD={added:`A`,deleted:`D`,ignored:null,modified:`M`,renamed:`R`,untracked:`U`},XD={added:`Git status: added`,deleted:`Git status: deleted`,ignored:`Git status: ignored`,modified:`Git status: modified`,renamed:`Git status: renamed`,untracked:`Git status: untracked`},ZD=`Contains git status items`;function QD(e){return e.current?!0:(e.current=!0,!1)}function $D(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:i=0,viewportHeight:a}=e;if(n<0)return null;let o=Math.max(0,i),s=n*r,c=s+r;if(s<t+o){let e=Math.max(0,s-o);return e===t?null:e}if(c>t+a){let e=c-a;return e===t?null:e}return null}function eO(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,offset:i,topInset:a=0,totalHeight:o,viewportHeight:s}=e;if(i===`nearest`)return $D({currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:a,viewportHeight:s});if(n<0)return null;let c=Math.max(0,a),l=n*r,u=Math.max(0,s-c),d=i===`center`?c+Math.max(0,(u-r)/2):c,f=Math.max(0,o-s),p=Math.max(0,Math.min(l-d,f));return p===t?null:p}function tO(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,targetViewportOffset:i,totalHeight:a,viewportHeight:o}=e;if(n<0)return null;let s=Math.max(0,i),c=n*r,l=c+r,u=t+s,d=t+o;if(c>=u&&l<=d)return null;let f=Math.max(0,a-o),p=Math.max(0,Math.min(c-s,f));return p===t?null:p}function nO(e){if(e==null||!e.isConnected||e===document.body||e===document.documentElement)return!1;e.focus({preventScroll:!0});let t=e.getRootNode();return t instanceof ShadowRoot?t.activeElement===e:document.activeElement===e}function rO(e){let t=e.getRootNode();if(t instanceof ShadowRoot){let e=t.activeElement;return e instanceof HTMLElement?e:null}let n=document.activeElement;return n instanceof HTMLElement&&e.contains(n)?n:null}function iO(e,t){if(e==null)return t;let n=e.getBoundingClientRect().height;return n>0?n:e.clientHeight>0?e.clientHeight:t}function aO(e,t){return e!=null&&e>0?e:t}function oO(e){let t=e.borderBoxSize,n=Array.isArray(t)?t[0]:t;return n!=null&&Number.isFinite(n.blockSize)&&n.blockSize>0?n.blockSize:e.contentRect.height>0?e.contentRect.height:null}function sO(e,t,n,r,i=0){let a=$D({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,topInset:i,viewportHeight:r});return a!=null&&(e.scrollTop=a,!0)}function cO(e,t,n,r,i,a,o=0){let s=eO({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,offset:a,topInset:o,totalHeight:i,viewportHeight:r});return s!=null&&(e.scrollTop=s,!0)}function lO(e,t,n,r,i,a){let o=tO({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,targetViewportOffset:a,totalHeight:i,viewportHeight:r});return o!=null&&(e.scrollTop=o,!0)}function uO(e,t,n,r){return n.end<n.start?null:e<n.start?-t:e>n.end?r:null}function dO(e){let{renamingPath:t,previousRenamingPath:n,hasRenderedInput:r}=e;return t==null?`reset`:r?n===t?`ignore`:`focus-input`:`reveal-canonical`}function fO({ariaLabel:e,isFlattened:t=!1,ref:n,value:r,onBlur:i,onInput:a}){return Q(`input`,{ref:n,"data-item-rename-input":!0,...t?{"data-item-flattened-rename-input":!0}:{},"aria-label":e,value:r,onBlur:i,onInput:a,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})}function pO(e){let{row:t,mode:n,targetPath:r,ariaLabel:i,domId:a,isParked:o,itemHeight:s,features:c,state:l,extraStyle:u}=e,d=n===`sticky`,f=t.ancestorPaths.at(-1)??``,p={};return l.isFocusRinged&&(p[`data-item-focused`]=!0),t.isSelected&&(p[`data-item-selected`]=!0),l.isContextHovered&&(p[`data-item-context-hover`]=`true`),l.isDragTarget&&(p[`data-item-drag-target`]=!0),l.isDragging&&(p[`data-item-dragging`]=!0),l.effectiveGitStatus!=null&&(p[`data-item-git-status`]=l.effectiveGitStatus),l.containsGitChange&&(p[`data-item-contains-git-change`]=`true`),{"aria-expanded":!d&&t.kind===`directory`?t.isExpanded:void 0,"aria-haspopup":c.contextMenuEnabled?`menu`:void 0,"aria-label":i,"aria-level":d?void 0:t.level+1,"aria-posinset":d?void 0:t.posInSet+1,"aria-selected":d?void 0:t.isSelected?`true`:`false`,"aria-setsize":d?void 0:t.setSize,"data-file-tree-sticky-path":d?r:void 0,"data-file-tree-sticky-row":d?`true`:void 0,"data-item-context-menu-button-visibility":c.actionLaneEnabled?c.contextMenuButtonVisibility:void 0,"data-item-context-menu-trigger-mode":c.contextMenuEnabled?c.contextMenuTriggerMode:void 0,"data-item-has-context-menu-action-lane":c.actionLaneEnabled?`true`:void 0,"data-item-has-git-lane":c.gitLaneActive?`true`:void 0,"data-item-parent-path":f.length>0?f:void 0,"data-item-parked":o?`true`:void 0,"data-item-path":r,"data-item-type":t.kind===`directory`?`folder`:`file`,"data-type":`item`,id:d?void 0:a,role:d?void 0:`treeitem`,style:{minHeight:`${s}px`,...u},tabIndex:!d&&t.isFocused?0:-1,...p}}function mO(e){let{event:t,mode:n,isSearchOpen:r,isDirectory:i}=e,a=t.ctrlKey||t.metaKey,o=t.shiftKey||a,s=t.shiftKey?{additive:a,kind:`range`}:a?{kind:`toggle`}:{kind:`single`};return{closeSearch:r,revealCanonical:n===`sticky`,selection:s,toggleDirectory:!o&&i}}var hO,gO,_O,vO,yO=Object.is,bO=0,xO=[],SO=AE,CO=SO.__b,wO=SO.__r,TO=SO.diffed,EO=SO.__c,DO=SO.unmount,OO=SO.__;function kO(e,t){SO.__h&&SO.__h(gO,e,bO||t),bO=0;var n=gO.__H||(gO.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function AO(e){return bO=1,jO(HO,e)}function jO(e,t,n){var r=kO(hO++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):HO(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);yO(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=gO,!gO.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return!!e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,yO(t,e.__[0])||(o=!0)}}),a&&a.call(this,e,t,n)||o};gO.__f=!0;var a=gO.shouldComponentUpdate,o=gO.componentWillUpdate;gO.componentWillUpdate=function(e,t,n){if(4&this.__g){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},gO.shouldComponentUpdate=i}return r.__N||r.__}function MO(e,t){var n=kO(hO++,3);!SO.__s&&VO(n.__H,t)&&(n.__=e,n.u=t,gO.__H.__h.push(n))}function NO(e,t){var n=kO(hO++,4);!SO.__s&&VO(n.__H,t)&&(n.__=e,n.u=t,gO.__h.push(n))}function $(e){return bO=5,PO(function(){return{current:e}},[])}function PO(e,t){var n=kO(hO++,7);return VO(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function FO(e,t){return bO=8,PO(function(){return e},t)}function IO(){for(var e;e=xO.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(zO),e.__H.__h.forEach(BO),e.__H.__h=[]}catch(t){e.__H.__h=[],SO.__e(t,e.__v)}}SO.__b=function(e){gO=null,CO&&CO(e)},SO.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),OO&&OO(e,t)},SO.__r=function(e){wO&&wO(e),hO=0;var t=(gO=e.__c).__H;t&&(_O===gO?(t.__h=[],gO.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(zO),t.__h.forEach(BO),t.__h=[],hO=0)),_O=gO},SO.diffed=function(e){TO&&TO(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(xO.push(t)!==1&&vO===SO.requestAnimationFrame||((vO=SO.requestAnimationFrame)||RO)(IO)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),_O=gO=null},SO.__c=function(e,t){t.some(function(e){try{e.__h.forEach(zO),e.__h=e.__h.filter(function(e){return!e.__||BO(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],SO.__e(n,e.__v)}}),EO&&EO(e,t)},SO.unmount=function(e){DO&&DO(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{zO(e)}catch(e){t=e}}),n.__H=void 0,t&&SO.__e(t,n.__v))};var LO=typeof requestAnimationFrame==`function`;function RO(e){var t,n=function(){clearTimeout(r),LO&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);LO&&(t=requestAnimationFrame(n))}function zO(e){var t=gO,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),gO=t}function BO(e){var t=gO;e.__c=e.__(),gO=t}function VO(e,t){return!e||e.length!==t.length||t.some(function(t,n){return!yO(t,e[n])})}function HO(e,t){return typeof t==`function`?t(e):t}function UO(e,t=null,n=null){"use no memo";let r=e.flattenedSegments;return r==null||r.length===0?t??e.name:Q(`span`,{"data-item-flattened-subitems":!0,children:r.map((e,i)=>{let a=i===r.length-1;return Q(JE,{children:[Q(`span`,{"data-item-flattened-subitem":e.path,"data-item-flattened-subitem-drag-target":n===e.path?`true`:void 0,children:a&&t!=null?t:Q(PD,{children:e.name})}),i<r.length-1?` / `:``]},e.path)})})}function WO(e){return e.isFlattened?e.flattenedSegments?.findLast(e=>e.isTerminal)?.path??e.path:e.path}function GO(e){let t=e.flattenedSegments;return t==null||t.length===0?e.name:t.map(e=>e.name).join(` / `)}function KO(e,t,n,r){return e.map((e,i)=>{let a=i*n,o=e.subtreeEndIndex+1;if(o>=r)return{row:e.row,top:a};let s=o*n-t;return{row:e.row,top:Math.min(a,s-n)}}).filter(e=>e.top+n>0)}function qO({controller:e,itemHeight:t,overscan:n,scrollTop:r,stickyFolders:i,viewportHeight:a}){let o=e.getVisibleCount(),s=i&&o>0?e.getStickyRowCandidates(r,t):[],c=s==null&&i&&o>0?e.getVisibleRows(0,o-1):[],l=JD(c,{itemHeight:t,overscan:n,scrollTop:r,stickyRows:s==null?void 0:KO(s,r,t,o),totalRowCount:o,viewportHeight:a}),u=i&&r<=0&&o>0?e.getStickyRowCandidates(1,t):[],d=u!=null&&r<=0?KO(u,1,t,o):i&&r<=0&&c.length>0?qD(c,1,t):l.sticky.rows;return{overlayHeight:d.reduce((e,n)=>Math.max(e,n.top+t),0),overlayRows:d,snapshot:l,visibleRows:c}}var JO=400,YO=40,XO=18;function ZO(e,t,n){let r=e,i=document.elementFromPoint?.bind(document)??null,a=r.elementFromPoint?.(t,n)??i?.(t,n)??null;return e instanceof ShadowRoot&&(a==null||!e.contains(a))?QO(e,t,n):a instanceof HTMLElement?a:null}function QO(e,t,n){let r=Array.from(e.querySelectorAll(`[data-type="item"], [data-item-flattened-subitem]`));for(let e=r.length-1;e>=0;e--){let i=r[e],a=i.getBoundingClientRect();if(t>=a.left&&t<=a.right&&n>=a.top&&n<=a.bottom)return i}return null}function $O(e){let t=e?.closest?.(`[data-type="item"]`);if(!(t instanceof HTMLElement))return null;let n=t.dataset.itemPath??null;if(n==null)return null;let r=e?.closest?.(`[data-item-flattened-subitem]`),i=r instanceof HTMLElement?r.getAttribute(`data-item-flattened-subitem`)??null:null;if(i!=null&&i.endsWith(`/`))return{directoryPath:i,flattenedSegmentPath:i,hoveredPath:n,kind:`directory`};if(t.dataset.itemType===`folder`)return{directoryPath:n,flattenedSegmentPath:null,hoveredPath:n,kind:`directory`};let a=t.dataset.itemParentPath??null;return a==null||a.length===0?{directoryPath:null,flattenedSegmentPath:null,hoveredPath:n,kind:`root`}:{directoryPath:a,flattenedSegmentPath:null,hoveredPath:n,kind:`directory`}}function ek(e){let t=e.cloneNode(!0);return t.removeAttribute(`id`),t.dataset.fileTreeDragPreview=`true`,t.setAttribute(`aria-hidden`,`true`),t.tabIndex=-1,Object.assign(t.style,{boxShadow:`0 4px 12px rgba(0, 0, 0, 0.15)`,left:`0px`,margin:`0`,pointerEvents:`none`,position:`fixed`,top:`0px`,willChange:`transform`,zIndex:`10000`}),t}function tk(){return navigator.vendor!==`Apple Computer, Inc.`}function nk(e,t){let n=e-t.top;if(n<YO)return-Math.ceil((YO-Math.max(0,n))/YO*XO);let r=t.bottom-e;return r<YO?Math.ceil((YO-Math.max(0,r))/YO*XO):0}function rk(e,t){if(e!=null){let t=YD[e];return t==null?null:{text:t,title:XD[e]}}return t?{icon:{name:`file-tree-icon-dot`,width:6,height:6},title:ZD}:null}function ik(e,t,n){if(t==null||t.size===0)return null;let r=[];for(let i=e.length-1;i>=0;--i){let a=e[i],o=n.get(a);if(o!=null){for(let e of r)n.set(e,o);return o?`ignored`:null}if(t.has(a)){n.set(a,!0);for(let e of r)n.set(e,!0);return`ignored`}r.push(a)}for(let e of r)n.set(e,!1);return null}function ak(e){return e!=null&&`toggle`in e}function ok(e){return e.code===`Space`||e.key===` `||e.key===`Spacebar`}function sk(e){return e.key.length===1&&/^[\p{L}\p{N}]$/u.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function ck(e){return e==null?``:`[data-item-section="spacing-item"][data-ancestor-path="${e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}"] { opacity: 1; }`}function lk(e){return e.shiftKey&&e.key===`F10`||e.key===`ContextMenu`}function uk(e,t){return t&&lk(e)||(e.ctrlKey||e.metaKey)&&ok(e)?!0:e.key===`ArrowDown`||e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`}var dk=new Set([`ArrowDown`,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`]);function fk(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&(t.dataset.fileTreeContextMenuRoot===`true`||t.dataset.type===`context-menu-anchor`||t.dataset.type===`context-menu-trigger`||t.getAttribute(`slot`)===`context-menu`))return!0;return!1}function pk(e){return{bottom:e.bottom,height:e.height,left:e.left,right:e.right,top:e.top,width:e.width,x:e.x,y:e.y}}function mk(e,t){return{bottom:t,height:0,left:e,right:e,top:t,width:0,x:e,y:t}}function hk(e,t){if(e==null)return t.offsetTop;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.top-r.top}function gk(e,t,n){if(n==null){e.delete(t);return}e.set(t,n)}function _k(e,t,n){if(e==null)return null;let r=t.get(e)??null;if(r!=null)return r;let i=n.get(e)??null;return i?.dataset.itemParked===`true`?null:i}function vk(e){if(e==null)return[];let t=[];for(let n of e.querySelectorAll(`button[data-file-tree-sticky-row="true"]`)){if(!(n instanceof HTMLElement))continue;let e=n.dataset.fileTreeStickyPath;e!=null&&t.push(e)}return t}function yk(e,t){if(e==null||t==null)return null;for(let n of e.querySelectorAll(`button[data-item-focused="true"][data-item-parked="true"]`))if(n instanceof HTMLElement&&n.dataset.itemPath===t)return n;return null}function bk(e,t,n,r,i,a,o){let s=Math.max(0,a-i),c=t?.getBoundingClientRect()??null,l=c==null||n==null?null:n.getBoundingClientRect().top-c.top,u=yk(e,r),d=c==null||u==null?null:u.getBoundingClientRect().top-c.top;return Math.max(0,Math.min(d??Math.max(l??0,s),Math.max(0,o-i)))}function xk(e,t){return{kind:e.kind,name:GO(e),path:t}}function Sk(e){return e==null?void 0:`${e}__tree`}function Ck(e,t,n){if(e!=null)return`${e}__focused-item-${encodeURIComponent(t)}${n?`__parked`:``}`}function wk(e){return e===`file-tree-icon-chevron`||e===`file-tree-icon-dot`||e===`file-tree-icon-file`||e===`file-tree-icon-lock`}function Tk(e,t){if(e==null)return null;if(`text`in e)return e.parts==null?Q(`span`,{title:e.title,children:e.text}):Q(`span`,{title:e.title,children:e.parts.map((e,t)=>Q(`span`,{style:{color:e.color},children:e.text},t))});let n=typeof e.icon==`string`?wk(e.icon)?t(e.icon):{name:e.icon}:wk(e.icon.name)?(()=>{let n=t(e.icon.name),{name:r,...i}=e.icon;return{...n,...i}})():e.icon;return Q(`span`,{title:e.title,children:Q(xD,{...n})})}function Ek(e){e!=null&&nO(e.querySelector([`button:not([disabled])`,`[href]`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`, `))??e)}function Dk(e,t,{actionLaneEnabled:n=!1,customDecoration:r=null,decorationLaneEnabled:i=!1,dragTargetFlattenedSegmentPath:a=null,gitDecoration:o=null,gitLaneActive:s=!1,renameInput:c=null,showDecorativeActionAffordance:l=!1}={}){let u=WO(e);return Q(JE,{children:[e.depth>0?Q(`div`,{"data-item-section":`spacing`,children:Array.from({length:e.depth}).map((t,n)=>Q(`div`,{"data-item-section":`spacing-item`,"data-ancestor-path":e.ancestorPaths[n]},n))}):null,Q(`div`,{"data-item-section":`icon`,children:e.kind===`directory`?Q(xD,{...t(`file-tree-icon-chevron`)}):Q(xD,{...t(`file-tree-icon-file`,u)})}),Q(`div`,{"data-item-section":`content`,children:e.isFlattened?UO(e,c,a):c??Q(ID,{minimumLength:5,split:`extension`,children:e.name})}),i?Q(`div`,{"data-item-section":`decoration`,children:r==null?null:Tk(r,t)}):null,s?Q(`div`,{"data-item-section":`git`,children:Tk(o,t)}):null,n?Q(`div`,{"data-item-section":`action`,children:l?Q(`span`,{"aria-hidden":`true`,"data-item-action-affordance":`decorative`,children:Q(xD,{...t(`file-tree-icon-ellipsis`)})}):null}):null]})}function Ok(e,t,n,r={}){let{controller:i,renameView:a,visualFocusPath:o,contextHoverPath:s,draggedPathSet:c,dragTarget:l,dragAndDropEnabled:u,shouldSuppressContextMenu:d,handleRowDragStart:f,handleRowDragEnd:p,handleRowTouchStart:m,instanceId:h,itemHeight:g,gitStatusByPath:_,ignoredGitDirectories:v,ignoredInheritanceCache:y,directoriesWithGitChanges:b,gitLaneActive:x,contextMenuEnabled:S,contextMenuTriggerMode:C,contextMenuButtonTriggerEnabled:w,contextMenuButtonVisibility:T,contextMenuRightClickEnabled:E,registerRenameInput:D,registerButton:O,resolveIcon:k,renderDecorationForRow:A,openContextMenuForRow:j,onRowClick:M,onKeyDown:N}=e,P=WO(t),{isParked:F=!1,mode:I=`flow`,style:ee}=r,te=I===`sticky`,ne=_?.get(P)??null??ik(t.ancestorPaths,v,y),re=t.kind===`directory`&&(b?.has(P)??!1),L=A(t,P),R=rk(ne,re),ie=S&&w,ae=L!=null||x||ie,oe=ie&&T===`always`,se=a.getPath()===P,ce=se?a.getValue():``,z=te||!se?null:Q(fO,{ref:D,ariaLabel:`Rename ${GO(t)}`,isFlattened:t.isFlattened,value:ce,onBlur:()=>{a.commit()},onInput:e=>{a.setValue(e.currentTarget.value)}}),le=Dk(t,k,{actionLaneEnabled:ie,customDecoration:L,decorationLaneEnabled:ae,dragTargetFlattenedSegmentPath:l?.flattenedSegmentPath??null,gitDecoration:R,gitLaneActive:x,renameInput:z,showDecorativeActionAffordance:oe}),B={...pO({ariaLabel:GO(t),domId:t.isFocused?Ck(h,P,F):void 0,extraStyle:ee,features:{actionLaneEnabled:ie,contextMenuButtonVisibility:ie?T:null,contextMenuEnabled:S,contextMenuTriggerMode:S?C:null,gitLaneActive:x},isParked:F,itemHeight:g,mode:I,row:t,state:{containsGitChange:re,effectiveGitStatus:ne,isContextHovered:s===P,isDragTarget:l?.kind===`directory`&&l.directoryPath===P,isDragging:c?.has(P)===!0,isFocusRinged:t.isFocused&&o===P},targetPath:P}),key:n,onContextMenu:S||u?e=>{if(d()){e.preventDefault();return}S&&(e.preventDefault(),E&&(i.focusMountedPathFromInput(P),j(t,P,{anchorRect:mk(e.clientX,e.clientY),source:`right-click`})))}:void 0,onFocus:te?void 0:()=>{i.focusMountedPathFromInput(P)},onKeyDown:te?void 0:N,ref:e=>{O(P,e)}};return!te&&se?Q(`div`,{...B,children:le}):Q(`button`,{...B,type:`button`,draggable:u&&!F,onDragEnd:u&&!F?p:void 0,onDragStart:u&&!F?e=>{f(e,t,P)}:void 0,onMouseDown:e=>{if(te){e.preventDefault();return}i.isSearchOpen()&&e.preventDefault()},onTouchStart:u&&!F?e=>{m(e,t,P)}:void 0,onClick:e=>{M(e,t,P,I)},children:le})}function kk(e,t,n){return t.end<t.start?[]:e.controller.getVisibleRows(t.start,t.end).filter(e=>!n.has(WO(e))).map((n,r)=>Ok(e,n,t.start+r))}function Ak({composition:e,controller:t,gitStatusByPath:n,ignoredGitDirectories:r,directoriesWithGitChanges:i,icons:a,instanceId:o,itemHeight:s=Px,overscan:c=10,renamingEnabled:l=!1,renderRowDecoration:u,searchBlurBehavior:d=`close`,searchEnabled:f=!1,searchFakeFocus:p=!1,slotHost:m,stickyFolders:h=!1,initialViewportHeight:g=420}){"use no memo";let _=$(null),v=$(null),y=$(!1),b=$(null),x=$(null),S=$(null),C=$(null),w=$(null),T=$(new Map),E=$(new Map),D=$(()=>{}),O=$(null),k=$(0),A=$(!1),j=$(null);j.current!==t&&(A.current=!1,j.current=t);let M=$(!1),N=$(null),P=$(null),F=$(!1),I=$(null),ee=$(null),te=$(null),ne=$(null),re=$(null),L=$(null),R=$(null),ie=$(null),ae=$(!1),oe=$(null),se=$(null),ce=$(null),z=$(null),le=PO(()=>new Map,[]),[,B]=AO(0),ue=$(!1),[de,fe]=AO(null),[V,pe]=AO(null),[me,he]=AO(null),[ge,_e]=AO(null),[ve,ye]=AO(0),[be,xe]=AO(null),Se=$(be);Se.current=be;let Ce=$(null),we=$(null),Te=$(null),Ee=$(null),De=$(null),Oe=$(!1),ke=()=>{we.current=null,Te.current=null,Ee.current=null},Ae=(e,t)=>{we.current=e,Te.current=null,Ee.current=t==null?null:{path:e,scrollTop:t}},je=(e,t)=>{we.current=null,Te.current={path:e,viewportOffset:t},Ee.current=null},Me=$(d===`retain`&&t.isSearchOpen()),[Ne,Pe]=AO(p);MO(()=>{p||Pe(!1)},[p]);let Fe=$(!1),Ie=FO(()=>{Fe.current=!0,Pe(e=>e&&!1)},[]),[Le,Re]=AO(()=>qO({controller:t,itemHeight:s,overscan:c,scrollTop:0,stickyFolders:h,viewportHeight:g})),[ze,Be]=AO(!1);MO(()=>{Be(!0)},[]);let Ve=e?.contextMenu?.enabled===!0||e?.contextMenu?.render!=null||e?.contextMenu?.onOpen!=null||e?.contextMenu?.onClose!=null,He=e?.contextMenu?.triggerMode??(Ve?`right-click`:`both`),Ue=He===`both`||He===`button`,H=e?.contextMenu?.buttonVisibility??`when-needed`,U=He===`both`||He===`right-click`;NO(()=>{let e=S.current;if(e==null)return;let t=e=>{if(!(e instanceof CustomEvent))return;let t=e.detail?.path??null;De.current=t,pe(t),_e(t==null?null:`pointer`)},n=e=>{e instanceof CustomEvent&&(Oe.current=e.detail?.disabled===!0)};return e.addEventListener(`file-tree-debug-set-context-menu-trigger`,t),e.addEventListener(`file-tree-debug-set-scroll-suppression`,n),()=>{e.removeEventListener(`file-tree-debug-set-context-menu-trigger`,t),e.removeEventListener(`file-tree-debug-set-scroll-suppression`,n)}},[]);let We=FO((e,t)=>{gk(T.current,e,t)},[]),Ge=FO((e,t)=>{gk(E.current,e,t)},[]),Ke=FO(e=>{x.current=e},[]),qe=FO(e=>_k(e,E.current,T.current),[]),Je=n!=null||r!=null||i!=null,{resolveIcon:Ye}=PO(()=>kE(a),[a]),Xe=t[aE](),Ze=Xe.getPath(),Qe=Ze!=null,$e=t.isSearchOpen(),et=t.getSearchValue(),tt=t.getFocusedPath(),nt=t.getFocusedIndex(),rt=t.getScrollRequest(),it=t.isDragAndDropEnabled(),at=t.getDragSession(),ot=PO(()=>at==null?null:new Set(at.draggedPaths),[at]),st=at?.target??null,ct=at?.primaryPath??null,W=Sk(o),{overlayHeight:lt,overlayRows:ut,snapshot:dt,visibleRows:G}=Le,ft=dt.physical.viewportHeight,pt=PO(()=>({end:dt.window.endIndex,start:dt.window.startIndex}),[dt.window.endIndex,dt.window.startIndex]),mt=ut,ht=dt.sticky.rows,gt=dt.physical.totalHeight,_t=dt.sticky.height,vt=PO(()=>new Set(ht.map(e=>WO(e.row))),[ht]),yt=nt>=0&&nt>=pt.start&&nt<=pt.end,bt=FO((e,t)=>u?.({item:xk(e,t),row:e})??null,[u]),xt=FO(e=>nO(e==null?null:T.current.get(e)??null)?!0:nO(S.current),[]),St=FO(e=>{xt(t.focusNearestPath(e))},[t,xt]),Ct=$(St);Ct.current=St;let wt=$(!0),Tt=$(()=>{}),Et=FO((t=!0)=>{let n=Se.current;n!=null&&(wt.current=wt.current&&t,xe(null),e?.contextMenu?.onClose?.(),wt.current&&St(n.path))},[e?.contextMenu,St]);Tt.current=Et;let Dt=FO(e=>{let t=e==null?null:hk(S.current,e);he(e=>e===t?e:t)},[]),Ot=FO((e,n,r)=>{let i=t.getItem(n);if(i==null)return;let a=qe(n);if(a?.dataset.fileTreeStickyRow===`true`){let e=C.current;Ae(n,e?.scrollTop??null),M.current=!0,fe(e=>e===n?e:n)}i.focus(),Dt(a),wt.current=!0,xe({anchorRect:r?.anchorRect??null,item:xk(e,n),path:n,source:r?.source??`keyboard`})},[t,qe,Dt]),kt=FO(e=>{if(l){if(t.isSearchOpen()){let e=C.current,t=iO(e,ft);I.current=nt<0||e==null?null:Math.max(0,Math.min(nt*s-e.scrollTop,Math.max(0,t-s))),F.current=!0}t.startRenaming(e)!==!1&&(_e(`focus`),B(e=>e+1))}},[t,nt,s,l,ft]),At=FO((e,{restoreTreeFocus:n=!0,targetOffset:r=`live-overlay`}={})=>{let i=C.current;if(i==null)return!1;t.focusPath(e);let a=t.getFocusedIndex();if(a<0)return!1;let o=t.getVisibleRows(a,a)[0]??null;if(o==null)return!1;let l=iO(i,ft),u=t.getVisibleCount()*s,d=r===`sticky-parents`?o.ancestorPaths.length*s:qO({controller:t,itemHeight:s,overscan:c,scrollTop:i.scrollTop,stickyFolders:h,viewportHeight:l}).snapshot.sticky.height;return M.current=!0,lO(i,a,s,l,u,d),D.current(),Ce.current=n?e:null,!0},[t,s,c,ft,h]),jt=()=>y.current===!0||z.current!=null||ae.current===!0,Mt=e=>typeof window.requestAnimationFrame==`function`?window.requestAnimationFrame(()=>{e()}):window.setTimeout(e,16),Nt=e=>{if(e!=null){if(typeof window.cancelAnimationFrame==`function`){window.cancelAnimationFrame(e);return}window.clearTimeout(e)}},Pt=()=>{ne.current!=null&&(clearTimeout(ne.current),ne.current=null),te.current=null},Ft=()=>{L.current?.remove(),L.current=null},It=()=>{Nt(ee.current),ee.current=null,re.current=null},Lt=e=>{let t=S.current?.getRootNode();if(t instanceof ShadowRoot){t.append(e);return}document.body.append(e)},Rt=()=>{ie.current?.(),ie.current=null,z.current!=null&&(clearTimeout(z.current),z.current=null),ae.current=!1,oe.current=null,ce.current=null,se.current!=null&&(se.current.setAttribute(`draggable`,`true`),se.current.style.removeProperty(`touch-action`),se.current=null),Ft(),Pt(),It(),R.current=null},zt=(e,n)=>{let r=S.current?.getRootNode(),i=$O(ZO(r instanceof ShadowRoot?r:document,e,n));return t.setDragTarget(i),t.getDragSession()?.target??null},Bt=e=>{let n=t.getDragAndDropConfig()?.openOnDropDelay??800;if(e==null||e.kind!==`directory`||e.directoryPath==null||n<=0){Pt();return}let r=t.getItem(e.directoryPath),i=ak(r)?r:null;if(i==null||i.isExpanded()){Pt();return}let a=`${e.directoryPath}::${e.flattenedSegmentPath??``}`;te.current!==a&&(Pt(),te.current=a,ne.current=setTimeout(()=>{let n=t.getDragSession()?.target;n?.kind===`directory`&&n.directoryPath===e.directoryPath&&n.flattenedSegmentPath===e.flattenedSegmentPath&&i.expand()},n))},Vt=()=>{ee.current=null;let e=re.current,n=C.current;if(e==null||n==null||t.getDragSession()==null)return;let r=n.getBoundingClientRect(),i=nk(e.clientY,r);if(i===0)return;let a=Math.max(0,n.scrollHeight-n.clientHeight),o=Math.max(0,Math.min(a,n.scrollTop+i));o!==n.scrollTop&&(n.scrollTop=o,D.current()),Bt(zt(e.clientX,e.clientY)),ee.current=Mt(Vt)},Ht=(e,t)=>{re.current={clientX:e,clientY:t},ee.current??=Mt(Vt)},Ut=(e,n,r)=>{let i=e.currentTarget;if(i!=null){if(Rt(),Ft(),Pt(),It(),t.startDrag(r)===!1){e.preventDefault();return}if(R.current=n,e.dataTransfer!=null&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.dropEffect=`move`,e.dataTransfer.setData(`text/plain`,r),tk())){let t=ek(i),n=i.getBoundingClientRect();Object.assign(t.style,{height:`${n.height}px`,opacity:`0.85`,transform:`translate3d(-9999px, 0px, 0)`,width:`${n.width}px`}),Lt(t),L.current=t,e.dataTransfer.setDragImage(t,Math.max(0,e.clientX-n.left),Math.max(0,e.clientY-n.top))}}},Wt=()=>{Ft(),Pt(),It(),R.current=null,t.cancelDrag()},Gt=(e,n,r)=>{if(z.current!=null||ae.current)return;let i=e.touches[0],a=e.currentTarget;if(i==null||a==null)return;ce.current={clientX:i.clientX,clientY:i.clientY},se.current=a,a.setAttribute(`draggable`,`false`);let o=(e={})=>{let t=e.restoreNativeDraggable??!ae.current;z.current!=null&&(clearTimeout(z.current),z.current=null),document.removeEventListener(`touchmove`,s),document.removeEventListener(`touchend`,c),document.removeEventListener(`touchcancel`,c),ie.current===o&&(ie.current=null),t&&(a.setAttribute(`draggable`,`true`),se.current===a&&(se.current=null),ce.current=null)},s=e=>{let t=e.touches[0],n=ce.current;if(t==null||n==null)return;let r=t.clientX-n.clientX,i=t.clientY-n.clientY;r*r+i*i<=100||o()},c=()=>{o()};document.addEventListener(`touchmove`,s,{passive:!0}),document.addEventListener(`touchend`,c),document.addEventListener(`touchcancel`,c),ie.current=o,z.current=setTimeout(()=>{if(o({restoreNativeDraggable:!1}),t.startDrag(r)===!1){a.setAttribute(`draggable`,`true`),se.current===a&&(se.current=null),ce.current=null;return}ae.current=!0,se.current=a,a.setAttribute(`draggable`,`false`),a.style.setProperty(`touch-action`,`none`),R.current=n;let e=a.getBoundingClientRect(),s=ek(a);Object.assign(s.style,{height:`${e.height}px`,opacity:`0.85`,transform:`translate3d(${e.left}px, ${e.top}px, 0)`,width:`${e.width}px`}),Lt(s),L.current=s,oe.current={x:i.clientX-e.left,y:i.clientY-e.top};let c=e=>{let t=e.touches[0];if(t==null)return;e.preventDefault();let n=oe.current;n!=null&&L.current!=null&&(L.current.style.transform=`translate3d(${t.clientX-n.x}px, ${t.clientY-n.y}px, 0)`),Bt(zt(t.clientX,t.clientY)),Ht(t.clientX,t.clientY)},l=e=>{let n=e.changedTouches[0];n!=null&&zt(n.clientX,n.clientY),t.completeDrag(),Rt()},u=()=>{t.cancelDrag(),Rt()};ie.current=()=>{document.removeEventListener(`touchmove`,c),document.removeEventListener(`touchend`,l),document.removeEventListener(`touchcancel`,u)},document.addEventListener(`touchmove`,c,{passive:!1}),document.addEventListener(`touchend`,l),document.addEventListener(`touchcancel`,u)},JO)},Kt=e=>{if(be!=null){if(e.key===`Escape`){Et(),e.preventDefault(),e.stopPropagation();return}dk.has(e.key)&&(e.preventDefault(),e.stopPropagation());return}if(Xe.isActive()){if(e.isComposing||e.keyCode===229)return;if(e.key===`Escape`)Xe.cancel();else if(e.key===`Enter`)Xe.commit();else return;_e(`focus`),B(e=>e+1),e.preventDefault(),e.stopPropagation();return}if(l&&e.key===`F2`){kt(tt??void 0),e.preventDefault(),e.stopPropagation();return}if($e){if(e.key===`Escape`)F.current=!1,I.current=null,t.closeSearch();else if(e.key===`Enter`){let e=t.getFocusedPath();e!=null&&t.selectOnlyPath(e);let n=C.current,r=iO(n,ft);I.current=nt<0||n==null?null:Math.max(0,Math.min(nt*s-n.scrollTop,Math.max(0,r-s))),F.current=!0,t.closeSearch()}else if(e.key===`ArrowDown`)t.focusNextSearchMatch();else if(e.key===`ArrowUp`)t.focusPreviousSearchMatch();else return;_e(`focus`),B(e=>e+1),e.preventDefault(),e.stopPropagation();return}if(f&&sk(e)){t.openSearch(e.key),B(e=>e+1),e.preventDefault(),e.stopPropagation();return}let n=Ve&&lk(e),r=uk(e,Ve),i=r&&S.current!=null?rO(S.current):null,a=r?new Set(vk(S.current)):new Set,o=i?.dataset.fileTreeStickyPath??null,c=i?.dataset.fileTreeStickyRow===`true`&&o!=null;if(c&&o!==tt&&a.has(o)){let e=C.current;Ae(o,e?.scrollTop??null),t.focusPath(o)}let u=t.getFocusedPath(),d=t.getFocusedIndex(),p=t.getFocusedItem();if(p==null)return;let m=ak(p)?p:null,h=u!=null&&(vt.has(u)||c&&o===u&&a.has(u)),g=e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`ArrowRight`&&m!=null&&m.isExpanded(),_=e.key===`ArrowLeft`&&h&&m!=null&&m.isExpanded(),v=C.current,y=!0;if(e.shiftKey&&e.key===`ArrowDown`)t.extendSelectionFromFocused(1);else if(e.shiftKey&&e.key===`ArrowUp`)t.extendSelectionFromFocused(-1);else if(n&&u!=null&&d>=0){let e=t.getVisibleRows(d,d)[0]??null,n=_k(u,E.current,T.current);e==null||n==null?y=!1:Ot(e,u)}else if((e.ctrlKey||e.metaKey)&&ok(e))t.toggleFocusedSelection();else if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`a`)t.selectAllVisiblePaths();else switch(e.key){case`ArrowDown`:t.focusNextItem();break;case`ArrowUp`:t.focusPreviousItem();break;case`ArrowRight`:m==null||m.isExpanded()?t.focusNextItem():m.expand();break;case`ArrowLeft`:m!=null&&m.isExpanded()?m.collapse():t.focusParentItem();break;case`Home`:t.focusFirstItem();break;case`End`:t.focusLastItem();break;default:y=!1}if(!y)return;_e(`focus`);let b=t.getFocusedPath(),x=b!=null&&(vt.has(b)||a.has(b)),w=g&&b!==u,D=n&&c&&o===u&&b===u;if((h||D)&&b!=null&&(w&&x||D))Ae(b,v?.scrollTop??null),M.current=!0,fe(e=>e===b?e:b);else{let t=e.key===`ArrowUp`&&h&&b!==u;b!=null&&(t||_&&b===u)?(je(b,bk(S.current,v,i,u,s,_t,ft)),M.current=!0,fe(e=>e===b?e:b)):ke()}B(e=>e+1),e.preventDefault(),e.stopPropagation()};NO(()=>{if(!(!f||!$e)){if(Me.current){Me.current=!1;return}nO(w.current)}},[$e,f]),NO(()=>{let e=x.current;switch(dO({hasRenderedInput:e!=null,previousRenamingPath:P.current,renamingPath:Ze})){case`reset`:P.current=null;return;case`reveal-canonical`:Ze!=null&&At(Ze,{restoreTreeFocus:!1,targetOffset:`live-overlay`});return;case`ignore`:return;case`focus-input`:e!=null&&(Ce.current=null,P.current=Ze,nO(e),e.select());return}},[pt.end,pt.start,Ze,At,vt]),NO(()=>{let e=S.current;if(e==null)return;let t=null,n=()=>{t!=null&&(clearTimeout(t),t=null)},r=()=>{let t=rO(e)?.dataset.itemPath??null;fe(e=>e===t?e:t)},i=()=>{n(),M.current=!0,r()},a=i=>{let a=i.relatedTarget;if(a==null){n(),t=setTimeout(()=>{if(t=null,rO(e)!=null){r();return}M.current=!1,fe(null)},0);return}if(!(a instanceof Node)||!e.contains(a)){n(),M.current=!1,fe(null);return}let o=a instanceof HTMLElement?a.dataset.itemPath??null:null;fe(e=>e===o?e:o)};return e.addEventListener(`focusin`,i),e.addEventListener(`focusout`,a),()=>{n(),e.removeEventListener(`focusin`,i),e.removeEventListener(`focusout`,a)}},[]),NO(()=>{let e=S.current;e!=null&&(dt.physical.scrollTop<=0?e.dataset.scrollAtTop=`true`:delete e.dataset.scrollAtTop)},[dt.physical.scrollTop]),NO(()=>{let e=null,n=C.current,r=b.current,i=S.current;if(n==null)return;O.current=iO(n,g);let a=()=>{let e=t.getVisibleCount(),r=aO(O.current,g),i=Math.max(0,e*s-r);n.scrollTop>i&&(n.scrollTop=i),Re(qO({controller:t,itemHeight:s,overscan:c,scrollTop:Math.min(n.scrollTop,i),stickyFolders:h,viewportHeight:r}))};if(!A.current){A.current=!0;let e=t.getFocusedIndex();if(e>=0){let r=aO(O.current,g),i=t.getVisibleRows(e,e)[0]??null;sO(n,e,s,r,h&&i!=null?Math.max(0,Math.min(i.ancestorPaths.length*s,Math.max(0,r-s))):0)}}D.current=a;let o=t.subscribe(()=>{QD(ue)&&B(e=>e+1),a()}),l=()=>{Oe.current!==!0&&(r!=null&&(r.dataset.isScrolling??=``),i!=null&&(i.dataset.isScrolling??=``),y.current=!0,e!=null&&clearTimeout(e),e=setTimeout(()=>{r!=null&&delete r.dataset.isScrolling,i!=null&&delete i.dataset.isScrolling,y.current=!1,ye(e=>e+1),e=null},50))},u=null,d=()=>{i!=null&&delete i.dataset.overlayReveal,u!=null&&(clearTimeout(u),u=null)},f=()=>{i!=null&&Oe.current!==!0&&(n.scrollTop>0||(i.dataset.overlayReveal=`true`,u!=null&&clearTimeout(u),u=setTimeout(()=>{d()},200)))},p=()=>{if(a(),n.scrollTop>0&&d(),Se.current!=null&&y.current&&Tt.current(),Oe.current===!0){y.current=!1;return}pe(e=>e==null?e:null),l()},m=()=>{l(),f()},_=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`,`Home`,`End`,` `,`Spacebar`]),v=e=>{_.has(e.key)&&m()};n.addEventListener(`scroll`,p,{passive:!0}),n.addEventListener(`wheel`,m,{passive:!0}),n.addEventListener(`touchmove`,m,{passive:!0}),n.addEventListener(`keydown`,v);let x=typeof ResizeObserver<`u`?new ResizeObserver(e=>{O.current=(e[0]==null?null:oO(e[0]))??iO(n,g),a()}):null;return x?.observe(n),()=>{D.current=()=>{},o(),n.removeEventListener(`scroll`,p),n.removeEventListener(`wheel`,m),n.removeEventListener(`touchmove`,m),n.removeEventListener(`keydown`,v),e!=null&&clearTimeout(e),u!=null&&clearTimeout(u),r!=null&&delete r.dataset.isScrolling,i!=null&&(delete i.dataset.isScrolling,delete i.dataset.overlayReveal),y.current=!1,O.current=null,x?.disconnect()}},[t,g,s,c,h]),NO(()=>{Ve||be==null||Et(!1)},[Et,Ve,be]);let qt=PO(()=>be==null?null:`${be.path}::${be.source}`,[be]);NO(()=>{if(qt==null){m?.clearSlotContent(lb);return}let t=Se.current;if(t==null)return;let n=v.current??_.current;if(n==null)return;let r={anchorElement:n,anchorRect:t.anchorRect??pk(n.getBoundingClientRect()),close:e=>{Tt.current(e?.restoreFocus??!0)},restoreFocus:()=>{wt.current&&Ct.current(Se.current?.path??null)}},i=e?.contextMenu?.render?.(t.item,r)??null;return m?.setSlotContent(lb,i),e?.contextMenu?.onOpen?.(t.item,r),Ek(i),queueMicrotask(()=>{i==null||!i.isConnected||document.activeElement===i&&Ek(i)}),()=>{m?.clearSlotContent(lb)}},[qt,e?.contextMenu,m]),NO(()=>{be!=null&&t.getItem(be.path)==null&&Et()},[Et,be,t]),NO(()=>{if(be==null)return;let e=S.current?.getRootNode(),t=e instanceof ShadowRoot?e.host:S.current,n=e=>{let n=e.target;n instanceof Node&&(fk(e)||_.current?.contains(n)!==!0&&t?.contains(n)!==!0&&Et())},r=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Et())};return document.addEventListener(`mousedown`,n,!0),document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`mousedown`,n,!0),document.removeEventListener(`keydown`,r,!0)}},[Et,be]),NO(()=>{let e=C.current,n=S.current;if(e==null||n==null){N.current=tt;return}let r=tt==null?null:T.current.get(tt)??null,i=rO(n),a=i?.dataset.itemPath??null,o=Qe&&x.current===i,c=f&&w.current===i,l=F.current&&!$e,u=I.current??0,d=Ce.current,p=we.current,m=Te.current,g=Ee.current,_=i!=null,v=M.current||_,y=N.current!==tt,b=p!=null&&p===tt&&tt!=null,E=!1,O=!1;if(rt!=null&&rt.id!==k.current){k.current=rt.id;let n=rt.visibleIndex,r=t.getVisibleRows(n,n)[0]??null;if(r!=null){let t=h?Math.max(0,Math.min(r.ancestorPaths.length*s,Math.max(0,ft-s))):_t;E=!0,O=cO(e,n,s,ft,gt,rt.offset,t)}t.clearScrollRequest(rt.id)}let A=!E&&l&&lO(e,nt,s,ft,gt,u),j=!E&&d!=null&&d===tt&&lO(e,nt,s,ft,gt,_t),P=!E&&m!=null&&m.path===tt&&lO(e,nt,s,ft,gt,m.viewportOffset),ee=!E&&g!=null&&g.path===tt&&e.scrollTop!==g.scrollTop;if(ee&&(e.scrollTop=g.scrollTop),(ee||O||j||P||A||v&&y&&d!==tt&&!b&&sO(e,nt,s,ft,_t))&&D.current(),E){N.current=tt;return}if(!v){N.current=tt;return}if(o){N.current=tt;return}if(c&&!l){N.current=tt;return}if(r==null){l&&nt>=0&&(lO(e,nt,s,ft,gt,u),D.current()),N.current=tt;return}(y||l||d===tt||p===tt||m?.path===tt||g?.path===tt||a==null||a!==tt)&&(nO(r),d===tt&&(Ce.current=null),p===tt&&(we.current=null),m?.path===tt&&(Te.current=null),g?.path===tt&&(Ee.current=null),F.current=!1,I.current=null),N.current=tt},[t,nt,tt,yt,s,Qe,$e,pt,ft,f,rt,h,_t,gt,G]);let Jt=nt>=0&&nt>=dt.visible.startIndex&&nt<=dt.visible.endIndex,Yt=tt!=null&&mt.some(e=>WO(e.row)===tt),Xt=Jt||Yt,Zt=Ue&&M.current===!0&&Xt?tt:null,Qt=ge===`pointer`?V:null,$t=be?.path??De.current??Qt??Zt??V,en=be?.source===`right-click`;NO(()=>{y.current&&be==null||Dt(qe($t))},[be,qe,pt,ft,ve,mt,$t,Dt,G]);let tn=FO(e=>{if(y.current||fk(e))return;let t=e.target;if(!(t instanceof HTMLElement)||t.closest?.(`[data-type="context-menu-trigger"]`)!=null)return;let n=t.closest?.(`[data-file-tree-sticky-row="true"]`),r=t.closest?.(`[data-type="item"]`),i=n instanceof HTMLElement?n.dataset.fileTreeStickyPath??null:r instanceof HTMLElement?r.dataset.itemPath??null:null;i!=null&&_e(e=>e===`pointer`?e:`pointer`),pe(e=>e===i?e:i)},[]),K=FO(()=>{pe(null)},[]);NO(()=>{if(!it)return;let e=()=>{Rt(),t.cancelDrag()};return window.addEventListener(`dragend`,e),()=>{window.removeEventListener(`dragend`,e),Rt(),t.cancelDrag()}},[t,it]);let nn=e=>{if(!it||t.getDragSession()==null||ae.current)return;let n=$O(e.target instanceof HTMLElement?e.target:null);t.setDragTarget(n),Bt(t.getDragSession()?.target??null),Ht(e.clientX,e.clientY),e.dataTransfer!=null&&(e.dataTransfer.dropEffect=`move`),e.preventDefault()},rn=e=>{if(!it||t.getDragSession()==null||ae.current)return;let n=e.relatedTarget;n instanceof Node&&S.current?.contains(n)===!0||(Pt(),It(),t.setDragTarget(null))},an=e=>{!it||t.getDragSession()==null||ae.current||(e.preventDefault(),zt(e.clientX,e.clientY),t.completeDrag(),Ft(),Pt(),It(),R.current=null)},on=dt.window.height,sn=dt.window.offsetTop,cn=Math.min(0,ft-on),ln=Math.min(0,ft-on-_t),un=de===tt||F.current,dn=tt!=null&&un&&!yt&&nt>=0?G[nt]??t.getVisibleRows(nt,nt)[0]??null:null,fn=dn==null?null:uO(nt,s,pt,on),pn=R.current,mn=ct!=null&&pn!=null&&pn.path===ct&&pn.index>=pt.start&&pn.index<=pt.end,hn=ct!=null&&pn!=null&&pn.path===ct&&!mn&&pn.path!==dn?.path?pn:null,gn=hn==null?null:uO(hn.index,s,pt,on),_n=ck((nt>=0?G[nt]??t.getVisibleRows(nt,nt)[0]??null:null)?.ancestorPaths.at(-1)??null),vn=$e&&tt!=null?Ck(o,tt,!yt):void 0,yn=be?.path??($e?tt:de),bn=be?.path??V,xn=qe($t),Sn=Ve&&Ue&&!en&&!Qe&&xn!=null&&me!=null&&$t!=null,Cn=Ve&&(Sn||be!=null),wn=be?.anchorRect,Tn=wn==null&&xn!=null&&me!=null&&(be!=null||Sn)?me:null,En=wn==null?Tn==null?void 0:{top:`${Tn}px`}:{left:`${wn.left}px`,position:`fixed`,right:`auto`,top:`${wn.top}px`},Dn=en?{opacity:`0`}:void 0,On=FO((e,n,r,i)=>{let a=mO({event:{ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey},isDirectory:n.kind===`directory`,isSearchOpen:$e,mode:i}),o=a.toggleDirectory&&n.kind===`directory`,s=o?t.resolveMountedDirectoryPathFromInput(r):null;if(o&&s==null)return;let c=s??r;switch(a.selection.kind){case`range`:t.selectPathRange(c,a.selection.additive);break;case`toggle`:t.togglePathSelectionFromInput(c);break;case`single`:t.selectOnlyMountedPathFromInput(c)}let l=e.currentTarget instanceof HTMLElement?e.currentTarget:null,u=n.index>=dt.visible.startIndex&&n.index<=dt.visible.endIndex,d=i===`flow`&&u&&l!=null&&l.dataset.itemParked!==`true`;t.focusMountedPathFromInput(c),d&&(M.current=!0,fe(e=>e===c?e:c),_e(`focus`)),o&&t.toggleMountedDirectoryFromInput(c),a.closeSearch&&t.closeSearch(),a.revealCanonical&&At(c,{targetOffset:`sticky-parents`})},[t,$e,dt.visible.endIndex,dt.visible.startIndex,At]),kn=()=>{if(y.current||!Ue||$t==null||xn==null)return;let e=t.getItem($t);e!=null&&(Dt(xn),wt.current=!0,xe({anchorRect:null,item:{kind:e.isDirectory()?`directory`:`file`,name:xn.getAttribute(`aria-label`)??$t,path:e.getPath()},path:e.getPath(),source:`button`}))},An={contextHoverPath:bn,contextMenuButtonTriggerEnabled:Ue,contextMenuButtonVisibility:H,contextMenuEnabled:Ve,contextMenuRightClickEnabled:U,contextMenuTriggerMode:He,controller:t,directoriesWithGitChanges:i,dragAndDropEnabled:it,draggedPathSet:ot,dragTarget:st,gitLaneActive:Je,gitStatusByPath:n,handleRowDragEnd:Wt,handleRowDragStart:Ut,handleRowTouchStart:Gt,ignoredGitDirectories:r,ignoredInheritanceCache:le,instanceId:o,itemHeight:s,onKeyDown:Kt,onRowClick:On,openContextMenuForRow:Ot,registerButton:We,registerRenameInput:Ke,renameView:Xe,renderDecorationForRow:bt,resolveIcon:Ye,shouldSuppressContextMenu:jt,visualFocusPath:yn},jn={...An,registerButton:Ge};return Q(`div`,{ref:S,id:W,"data-file-tree-context-menu-button-visibility":Ve&&Ue?H:void 0,"data-file-tree-context-menu-trigger-mode":Ve?He:void 0,"data-file-tree-has-context-menu-action-lane":Ve&&Ue?`true`:void 0,"data-file-tree-has-git-lane":Je?`true`:void 0,"data-file-tree-virtualized-root":`true`,onDragLeave:it?rn:void 0,onDragOver:it?nn:void 0,onDrop:it?an:void 0,onKeyDown:Kt,onPointerLeave:Ve?K:void 0,onPointerOver:Ve?tn:void 0,role:`tree`,tabIndex:-1,style:{outline:`none`,position:`relative`},children:[Q(`style`,{"data-file-tree-guide-style":`true`,dangerouslySetInnerHTML:{__html:_n}}),Q(`slot`,{name:cb,"data-type":`header-slot`}),f?Q(`div`,{"data-file-tree-search-container":!0,"data-open":$e?`true`:`false`,children:Q(`input`,{ref:w,"aria-activedescendant":vn,"aria-controls":W,placeholder:`Search…`,"data-file-tree-search-input":!0,"data-file-tree-search-input-fake-focus":Ne?`true`:void 0,value:et,onBlur:()=>{d===`retain`&&!Fe.current||t.closeSearch()},onFocus:Ie,onPointerDown:Ie,onInput:e=>{Ie();let n=e.currentTarget;t.setSearch(n.value)}})}):null,Q(`div`,{ref:C,"data-file-tree-virtualized-scroll":`true`,children:[h&&ze&&mt.length>0?Q(`div`,{"aria-hidden":`true`,"data-file-tree-sticky-overlay":`true`,children:Q(`div`,{"data-file-tree-sticky-overlay-content":`true`,style:{height:`${lt}px`},children:mt.map((e,t)=>Ok(jn,e.row,`sticky:${WO(e.row)}`,{mode:`sticky`,style:{left:`0`,position:`absolute`,right:`0`,top:`${e.top}px`,zIndex:`${mt.length-t}`}}))})}):null,Q(`div`,{ref:b,"data-file-tree-virtualized-list":`true`,style:{height:`${gt}px`},children:[Q(`div`,{"data-file-tree-virtualized-sticky-offset":`true`,"aria-hidden":`true`,style:{height:`${sn}px`}}),Q(`div`,{"data-file-tree-virtualized-sticky":`true`,style:{height:`${on}px`,top:`${cn}px`,bottom:`${ln}px`},children:[kk(An,pt,vt),dn!=null&&fn!=null?Ok(An,dn,`parked:${dn.path}`,{isParked:!0,style:{left:`0`,opacity:`0`,pointerEvents:ct===dn.path?`none`:void 0,position:`absolute`,right:`0`,top:`${fn}px`}}):null,hn!=null&&gn!=null?Ok(An,hn,`parked-drag:${hn.path}`,{isParked:!0,style:{left:`0`,opacity:`0`,pointerEvents:`none`,position:`absolute`,right:`0`,top:`${gn}px`}}):null]})]})]}),Ve?Q(`div`,{ref:_,"data-type":`context-menu-anchor`,"data-visible":Cn?`true`:`false`,style:En,children:[Q(`button`,{ref:v,type:`button`,"data-type":ub,"aria-label":`Options`,"aria-haspopup":`menu`,"aria-expanded":be==null?`false`:`true`,"data-visible":Sn?`true`:`false`,onMouseDown:e=>{e.preventDefault()},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),be!=null){Et();return}kn()},tabIndex:-1,style:Dn,children:Q(xD,{...Ye(`file-tree-icon-ellipsis`)})}),be==null?null:Q(`slot`,{name:lb})]}):null,be==null?null:Q(`div`,{"data-type":`context-menu-wash`,"aria-hidden":`true`,onMouseDownCapture:e=>{e.preventDefault(),Et()},onTouchStartCapture:e=>{e.preventDefault(),e.stopPropagation(),Et()},onTouchMoveCapture:e=>{e.preventDefault(),e.stopPropagation()},onWheelCapture:e=>{e.preventDefault(),e.stopPropagation()}})]})}var jk={hydrateRoot:(e,t)=>{gD(KE(Ak,t),e)},renderRoot:(e,t)=>{hD(KE(Ak,t),e)},unmountRoot:e=>{hD(null,e)}};function Mk(e,t){jk.renderRoot(e,t)}function Nk(e,t){jk.hydrateRoot(e,t)}function Pk(e){jk.unmountRoot(e)}var Fk=class{#e=new Map;#t=null;clearAll(){for(let e of this.#e.values())e.remove();this.#e.clear()}clearSlotContent(e){let t=this.#n(e);t!=null&&(t.remove(),this.#e.delete(e))}setHost(e){if(this.#t=e,e!=null){this.#i(e);for(let[e,t]of this.#e)this.#r(e,t)}}setSlotContent(e,t){let n=this.#n(e);if(n===t){t!=null&&(this.#e.set(e,t),this.#r(e,t));return}if(n?.remove(),t==null){this.#e.delete(e);return}this.#e.set(e,t),this.#r(e,t)}setSlotHtml(e,t){let n=t?.trim()??``;if(n.length===0){this.setSlotContent(e,null);return}let r=this.#n(e);if(r!=null&&r.innerHTML===n){this.#e.set(e,r),this.#r(e,r);return}let i=document.createElement(`div`);i.innerHTML=n,this.setSlotContent(e,i)}#n(e){let t=this.#e.get(e)??null;if(t!=null)return t;let n=this.#t;if(n==null)return null;for(let t of Array.from(n.children))if(t instanceof HTMLElement&&t.dataset.fileTreeManagedSlot===e)return t;return null}#r(e,t){t.slot=e,t.dataset.fileTreeManagedSlot=e,this.#t!=null&&t.parentNode!==this.#t&&this.#t.appendChild(t)}#i(e){for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;let e=t.dataset.fileTreeManagedSlot;e==null||this.#e.has(e)||this.#e.set(e,t)}}};Array.isArray;var Ik=0;function Lk(e){return e!=null&&e.length>0?e:(Ik+=1,`pst_ft_${Ik}`)}function Rk({initialVisibleRowCount:e,itemHeight:t}){return e==null?420:Math.max(0,e)*(t??Px)}function zk(e){if(typeof document>`u`)return;let t=document.createElement(`div`);t.innerHTML=e;let n=t.querySelector(`svg`);return n instanceof SVGElement?n:void 0}function Bk(e){return e.querySelector(`#file-tree-icon-chevron`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-file`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-dot`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-lock`)instanceof SVGElement}function Vk(e){return Array.from(e.children).filter(e=>e instanceof SVGElement)}var Hk=class{static LoadedCustomComponent=!0;#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=new Fk;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y=null;#b;#x=!1;#S=!1;constructor(e){let{composition:t,density:n,fileTreeSearchMode:r,gitStatus:i,id:a,initialSearchQuery:o,icons:s,itemHeight:c,onSearchChange:l,onSelectionChange:u,overscan:d,renderRowDecoration:f,renaming:p,search:m,searchBlurBehavior:h,searchFakeFocus:g,stickyFolders:_,unsafeCSS:v,initialVisibleRowCount:y,...b}=e;this.#e=t,this.#n=Lk(a),this.#p=gE(i),this.#m=s,this.#h=v,this.#r=u,this.#i=f,this.#a=p!=null&&p!==!1,this.#o=h,this.#s=m===!0,this.#c=g===!0,this.#u=Nx(n,c),this.#d={itemHeight:this.#u.itemHeight,overscan:d,stickyFolders:_,initialVisibleRowCount:y},this.#t=new dE({...b,fileTreeSearchMode:r,initialSearchQuery:o,onSearchChange:l,renaming:p}),this.#v=this.#t.getSelectionVersion(),this.#y=this.#r==null?null:this.subscribe(()=>{this.#D()})}unmount(){this.#b!=null&&(Pk(this.#b),delete this.#b.dataset.fileTreeVirtualizedWrapper,this.#b=void 0),this.#l.clearAll(),this.#l.setHost(null),this.#f!=null&&(delete this.#f.dataset.fileTreeVirtualized,this.#I(this.#f),this.#f=void 0)}cleanUp(){this.unmount(),this.#y?.(),this.#y=null,this.#t.destroy()}getFileTreeContainer(){return this.#f}getItem(e){return this.#t.getItem(e)}getFocusedItem(){return this.#t.getFocusedItem()}getFocusedPath(){return this.#t.getFocusedPath()}getFocusedIndex(){return this.#t.getFocusedIndex()}getVisibleCount(){return this.#t.getVisibleCount()}getVisibleRows(e,t){return this.#t.getVisibleRows(e,t)}getSelectedPaths(){return this.#t.getSelectedPaths()}getComposition(){return this.#e}getItemHeight(){return this.#u.itemHeight}getDensityFactor(){return this.#u.factor}subscribe(e){let t=!1;return this.#t.subscribe(()=>{if(!t){t=!0;return}e()})}focusPath(e){this.#t.focusPath(e)}focusFirstItem(){this.#t.focusFirstItem()}focusLastItem(){this.#t.focusLastItem()}focusNextItem(){this.#t.focusNextItem()}focusPreviousItem(){this.#t.focusPreviousItem()}focusParentItem(){this.#t.focusParentItem()}scrollToPath(e,t){this.#t.scrollToPath(e,t)}focusNearestPath(e){return this.#t.focusNearestPath(e)}add(e){this.#t.add(e)}batch(e){this.#t.batch(e)}applyGitStatusPatch(e){let t=_E(this.#p,e);if(t===this.#p)return;this.#p=t;let n=this.#T();n!=null&&Mk(n.wrapper,this.#w())}move(e,t,n){this.#t.move(e,t,n)}onMutation(e,t){return this.#t.onMutation(e,t)}setSearch(e){this.#t.setSearch(e)}openSearch(e){this.#t.openSearch(e)}closeSearch(){this.#t.closeSearch()}isSearchOpen(){return this.#t.isSearchOpen()}getSearchValue(){return this.#t.getSearchValue()}getSearchMatchingPaths(){return this.#t.getSearchMatchingPaths()}focusNextSearchMatch(){this.#t.focusNextSearchMatch()}focusPreviousSearchMatch(){this.#t.focusPreviousSearchMatch()}startRenaming(e,t){return this.#t.startRenaming(e,t)}remove(e,t){this.#t.remove(e,t)}resetPaths(e,t){Array.isArray(e)?this.#t.resetPaths(e,t):this.#t.resetPaths(e)}setComposition(e){this.#e=e;let t=this.#T();t!=null&&(this.#O(),Mk(t.wrapper,this.#w()))}setGitStatus(e){let t=gE(e,this.#p);if(t===this.#p)return;this.#p=t;let n=this.#T();n!=null&&Mk(n.wrapper,this.#w())}setIcons(e){this.#m=e;let t=this.#T();t!=null&&(this.#E(t.host,t.wrapper),Mk(t.wrapper,this.#w()))}hydrate({fileTreeContainer:e}){let t=this.#P(e),n=this.#N(t);this.#O(),Nk(n,this.#w())}render({containerWrapper:e,fileTreeContainer:t}){let n=this.#P(t??this.#f,e),r=this.#N(n);this.#O(),Mk(r,this.#w())}#C(){return{initialViewportHeight:Rk({initialVisibleRowCount:this.#d.initialVisibleRowCount,itemHeight:this.#d.itemHeight}),itemHeight:this.#d.itemHeight,overscan:this.#d.overscan,stickyFolders:this.#d.stickyFolders}}#w(){return{composition:this.#e,controller:this.#t,gitStatusByPath:this.#p?.statusByPath,ignoredGitDirectories:this.#p?.ignoredDirectoryPaths,directoriesWithGitChanges:this.#p?.directoriesWithChanges,icons:this.#m,instanceId:this.#n,renamingEnabled:this.#a,renderRowDecoration:this.#i,searchBlurBehavior:this.#o,searchEnabled:this.#s,searchFakeFocus:this.#c,slotHost:this.#l,...this.#C()}}#T(){let e=this.#f,t=this.#b;return e==null||t==null?null:{host:e,wrapper:t}}#E(e,t){let n=e.shadowRoot;n!=null&&(this.#k(n),this.#A(n)),this.#j(t)}#D(){let e=this.#r;if(e==null)return;let t=this.#t.getSelectionVersion();t!==this.#v&&(this.#v=t,e(this.#t.getSelectedPaths()))}#O(){let e=this.#e?.header?.render;if(e!=null){this.#l.setSlotContent(cb,e());return}this.#l.setSlotHtml(cb,this.#e?.header?.html??null)}#k(e){let t=Vk(e).find(e=>Bk(e)),n=zk(Ex(jx(this.#m).set));n!=null&&(t==null||t.outerHTML!==n.outerHTML)&&(t==null?e.prepend(n):t.replaceWith(n))}#A(e){let t=Vk(e),n=t.find(e=>Bk(e)),r=t.filter(e=>e!==n),i=jx(this.#m).spriteSheet?.trim()??``;if(i.length===0){for(let e of r)e.remove();return}let a=zk(i);if(a==null){for(let e of r)e.remove();return}if(r.length!==1||r[0].outerHTML!==a.outerHTML){for(let e of r)e.remove();e.appendChild(a)}}#j(e){let t=jx(this.#m);t.colored&&Ox(t.set)?e.dataset.fileTreeColoredIcons=`true`:delete e.dataset.fileTreeColoredIcons}#M(e){let t=e.querySelector(`style[${ib}]`);if(this.#g==null&&t instanceof HTMLStyleElement&&(this.#g=t),this.#h==null||this.#h===``){this.#g?.remove(),this.#g=void 0,this.#_=void 0;return}(this.#g?.parentNode!==e||this.#_!==this.#h)&&(this.#g??=document.createElement(`style`),this.#g.setAttribute(ib,``),this.#g.parentNode!==e&&e.appendChild(this.#g),this.#g.textContent=Rx(this.#h),this.#_=this.#h)}#N(e){if(this.#b!=null)return this.#b;let t=e.shadowRoot;if(t==null)throw Error(`FileTree requires a shadow root`);let n=Array.from(t.children).filter(e=>e instanceof HTMLDivElement&&typeof e.dataset.fileTreeId==`string`&&e.dataset.fileTreeId.length>0),r=n.find(e=>e.dataset.fileTreeId===this.#n)??n[0];return r!=null&&(this.#n=r.dataset.fileTreeId??this.#n),this.#b=r??document.createElement(`div`),this.#b.dataset.fileTreeId=this.#n,this.#b.dataset.fileTreeVirtualizedWrapper=`true`,this.#E(e,this.#b),this.#b.parentNode!==t&&t.appendChild(this.#b),this.#b}#P(e,t){let n=e??this.#f??document.createElement(`file-tree-container`);t!=null&&n.parentNode!==t&&t.appendChild(n);let r=n.shadowRoot??n.attachShadow({mode:`open`});return Wx(n,r),this.#M(r),n.dataset.fileTreeVirtualized=`true`,n.style.display=`flex`,this.#F(n),this.#l.setHost(n),this.#f=n,n}#F(e){e.style.getPropertyValue(`--trees-item-height`)===``&&(e.style.setProperty(`--trees-item-height`,`${String(this.#u.itemHeight)}px`),this.#x=!0),e.style.getPropertyValue(`--trees-density-override`)===``&&(e.style.setProperty(`--trees-density-override`,String(this.#u.factor)),this.#S=!0)}#I(e){this.#x&&=(e.style.removeProperty(`--trees-item-height`),!1),this.#S&&=(e.style.removeProperty(`--trees-density-override`),!1)}};function Uk(e){let[t]=(0,q.useState)(()=>new Hk(e)),n=(0,q.useRef)({timeout:null,model:t});return(0,q.useEffect)(()=>{let{current:e}=n;return e.timeout!=null&&(clearTimeout(e.timeout),e.timeout=null),()=>{e.timeout=setTimeout(()=>e.model.cleanUp(),1)}},[]),{model:t}}function Wk(e){return e.name.startsWith(`.`)}function Gk(e,t,n=0){return mi(e,_o,Pr.of(e,`tree`,e?.capabilities.version??0,t,n),async(e,r)=>{let i=await e.list({path:t,offset:n,limit:256});return r.throwIfAborted(),{...i,entries:i.entries.filter(e=>!Wk(e))}})}function Kk(){return{known:new Set,projected:new Map}}function qk(e,t){t.known.clear(),t.projected.clear(),e.resetPaths([])}function Jk(e,t,n){t.length===0&&qk(e,n);for(let{request:r,listing:i}of t){let t=`${r?.path??i.path}:${String(r?.offset??0)}`,a=i.entries.filter(e=>e.type!==`symlink`).map(e=>Yk(i.path,e.name,e.type)),o=n.projected.get(t)??[];n.projected.set(t,a);let s=new Set([...n.projected.values()].flat());for(let t of o)if(!s.has(t)){e.getItem(t)&&e.remove(t,{recursive:!0});for(let e of n.known)(e===t||t.endsWith(`/`)&&e.startsWith(t))&&n.known.delete(e)}Xk(e,i,n.known)}}function Yk(e,t,n){return`${e.endsWith(`/`)?e:`${e}/`}${t}${n===`directory`?`/`:``}`}function Xk(e,t,n){let r=t.entries.filter(e=>e.type!==`symlink`).map(e=>Yk(t.path,e.name,e.type)),i=r.filter(t=>!n.has(t)&&!e.getItem(t));i.length>0&&e.batch(i.map(e=>({type:`add`,path:e}))),n.add(t.path);for(let e of r)n.add(e);return i}function Zk(e,t){let n=t===`/`?`/`:t.replace(/\/+$/,``);if(n!==`/`&&e!==n&&!e.startsWith(`${n}/`))return[];let r=n===`/`?e.split(`/`).filter(Boolean):e.slice(n.length).split(`/`).filter(Boolean),i=[n],a=n;for(let e of r.slice(0,-1))a=`${a===`/`?``:a}/${e}`,i.push(a);return i}function Qk({app:e,rootPath:t,activePath:n}){let r=on(),i=zf(e),a=(0,q.useCallback)(t=>e.capabilities.subscribe(t),[e]),o=(0,q.useCallback)(()=>e.capabilities.version,[e]),s=(0,q.useSyncExternalStore)(a,o,o),c=(0,q.useMemo)(()=>({app:e,rootPath:t,computerId:i,version:s}),[e,t,i,s]),[l,u]=(0,q.useState)(null),d=l?.scope===c?l:null,f=n?Zk(n,t):[],p=d?.activePath===n?d.path:f.at(-1)??t,m=new Map;for(let e of[t,...f])m.set(`${e}:0`,{path:e,offset:0});for(let e of d?.pages??[])m.set(`${e.path}:${String(e.offset)}`,e);let h=[...m.values()],g=(t,n)=>Pr.of(e,`tree`,s,t,n);return{scope:c,snapshot:Hs({queries:h.map(({path:t,offset:n})=>Gk(e,t,n)),combine:e=>({listings:e.flatMap((e,t)=>e.data?[{request:h[t],listing:e.data}]:[]),busy:e.some(e=>e.isFetching),failure:e.find(e=>e.error)?.error??null})}),focusedPath:p,requestPage:(e,t)=>{let i=e.replace(/\/+$/,``)||`/`,a=g(i,t);r.getQueryState(a)?.status===`error`&&r.invalidateQueries({queryKey:a,exact:!0}),u(e=>({scope:c,activePath:n,path:i,pages:[...e?.scope===c?e.pages.filter(e=>e.path!==i||e.offset!==t):[],{path:i,offset:t}]}))},reload:()=>{r.invalidateQueries({queryKey:Pr.of(e,`tree`,s)})}}}var $k=()=>globalThis.matchMedia(`(pointer: coarse)`).matches?44:32,eA=()=>`Library`,tA=(e,t)=>`${eA()}${t.slice(e.length)}`,nA=(e,t)=>`${e}${t.replace(/\/$/,``).slice(eA().length)}`,rA=e=>e===void 0?`${eA()}/`:`${eA()}/${e}/`;function iA(e){if(!e.endsWith(`/`))return null;let t=e.slice(0,-1);return t===eA()?{folder:void 0}:t.startsWith(`${eA()}/`)?{folder:t.slice(eA().length+1)}:null}var aA=e=>e.replace(/\/$/,``)===eA(),oA=e=>({flex:1,minHeight:0,"--trees-item-height":`${String(e)}px`,"--trees-padding-inline-override":`var(--spacing-xs)`,"--trees-item-margin-x-override":`0px`,"--trees-item-padding-x-override":`var(--spacing-xs)`,"--trees-item-row-gap-override":`var(--spacing-xs)`,"--trees-bg-override":`transparent`,"--trees-border-color-override":`var(--stipe-hairline)`,"--trees-focus-ring-color-override":`var(--color-primary)`,"--trees-fg-override":`var(--color-base-content)`,"--trees-bg-muted-override":`var(--color-base-200)`,"--trees-selected-bg-override":`var(--color-base-300)`,"--trees-border-radius-override":`var(--radius-field)`,"--trees-font-family-override":`var(--font-sans)`,"--trees-font-size-override":`13px`,"--trees-search-bg-override":`var(--color-base-200)`,"--trees-search-fg-override":`var(--color-base-content)`});function sA({app:e,root:t,activeFolder:n,active:r=!0,mode:i,onSelectFolder:a,onDrop:o,onRename:s,onNewFolder:c,onMoveRows:l,canWrite:u,version:d}){let f=rA(n),{scope:p,snapshot:m,requestPage:h,reload:g}=Qk({app:e,rootPath:t,activePath:`${dg(t,n)}/.`}),_=(0,q.useRef)(!1),v=(0,q.useRef)({quiet:!1,root:t,mode:i,onSelectFolder:a,onDrop:o,onRename:s,onNewFolder:c,onMoveRows:l,requestPage:h});v.current={quiet:v.current.quiet,root:t,mode:i,onSelectFolder:a,onDrop:o,onRename:s,onNewFolder:c,onMoveRows:l,requestPage:h};let y=i===`browse`&&u,[b]=(0,q.useState)($k),{model:x}=Uk({paths:[],itemHeight:b,initialExpansion:1,flattenEmptyDirectories:!1,search:i===`browse`,composition:{contextMenu:{enabled:i===`browse`}},onSelectionChange(e){if(v.current.quiet||_.current)return;let t=e.at(-1);if(t===void 0||e.length!==1)return;let n=iA(t);n!==null&&(v.current.requestPage(nA(v.current.root,t),0),v.current.onSelectFolder(n.folder))},dragAndDrop:y?{canDrag:e=>e.every(e=>!aA(e)),canDrop:({target:e})=>e.kind===`directory`&&e.directoryPath!==null&&iA(e.directoryPath)!==null,onDropComplete:({draggedPaths:e,target:t})=>{let n=t.directoryPath===null?null:iA(t.directoryPath);n!==null&&v.current.onDrop?.(e.map(e=>nA(v.current.root,e)),n.folder)}}:void 0,renaming:y?{canRename:e=>!aA(e.path),onRename:({sourcePath:e,destinationPath:t})=>{let n=t.replace(/\/$/,``).split(`/`).at(-1);n!==void 0&&v.current.onRename?.(nA(v.current.root,e),n)}}:void 0}),S=(0,q.useRef)(Kk());(0,q.useLayoutEffect)(()=>{qk(x,S.current)},[x,p,d]);let C=(0,q.useRef)(d);(0,q.useEffect)(()=>{C.current!==d&&(C.current=d,g())},[g,d]),(0,q.useLayoutEffect)(()=>{let e=m.listings.map(({request:e,listing:n})=>({request:e,listing:{...n,path:tA(t,n.path),entries:n.entries.filter(e=>e.type===`directory`)}}));Jk(x,e,S.current)},[x,t,m.listings]);let w=(0,q.useRef)(null);return(0,q.useLayoutEffect)(()=>{v.current.quiet=!0;try{if(!r){w.current=null;for(let e of x.getSelectedPaths())x.getItem(e)?.deselect();return}e()}finally{v.current.quiet=!1}function e(){if(w.current===f)return;let e=x.getItem(f);if(!e)return;w.current=f;for(let e of x.getSelectedPaths())e!==f&&x.getItem(e)?.deselect();e.isSelected()||e.select();let t=f.slice(0,-1).split(`/`);for(let e=1;e<t.length;e+=1){let n=x.getItem(`${t.slice(0,e).join(`/`)}/`);n&&`expand`in n&&!n.isExpanded()&&n.expand()}}},[r,f,x,m.listings]),(0,q.useEffect)(()=>{m.failure&&Wt.error(It(m.failure).message,{id:`prints-tree-error`,toasterId:`prints-generation-notices`,action:{label:`Retry`,onClick:g}})},[g,m.failure]),(0,J.jsx)(`div`,{className:`prints-tree`,"data-library-tree":i,onDragStartCapture:()=>{_.current=!0},onDragEnd:()=>{_.current=!1},onDrop:()=>{_.current=!1},children:(0,J.jsx)(gb,{model:x,className:`prints-tree-view`,style:oA(b),renderContextMenu:i===`browse`?(e,n)=>{let r=iA(e.path);return(0,J.jsxs)(`div`,{className:`flex min-w-40 flex-col gap-xs p-xs`,role:`menu`,children:[r===null?null:(0,J.jsxs)(U,{className:`w-full justify-start`,disabled:!u,role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{n.close({restoreFocus:!1}),v.current.onNewFolder?.(r.folder)},children:[(0,J.jsx)(Ch,{"aria-hidden":`true`}),` New folder`]}),(0,J.jsxs)(U,{className:`w-full justify-start`,disabled:!u||aA(e.path),role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{n.close({restoreFocus:!1}),x.startRenaming(e.path)},children:[(0,J.jsx)(Nh,{"aria-hidden":`true`}),` Rename`]}),(0,J.jsxs)(U,{className:`w-full justify-start`,disabled:!u||aA(e.path),role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{n.close({restoreFocus:!1});let r=x.getSelectedPaths(),i=r.includes(e.path)?r:[e.path];v.current.onMoveRows?.(i.map(e=>nA(t,e)))},children:[(0,J.jsx)(On,{"aria-hidden":`true`}),` Move to…`]})]})}:void 0})})}function cA({view:e,onView:t,onNewFolder:n,canWrite:r,...i}){return(0,J.jsxs)(`nav`,{className:`prints-rail`,"aria-label":`Library`,children:[(0,J.jsxs)(`div`,{className:`prints-rail-views`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`prints-rail-view`,"aria-current":e.kind===`all`?`page`:void 0,onClick:()=>{t({kind:`all`})},children:[(0,J.jsx)(Mr,{"aria-hidden":!0,size:16}),` All prints`]}),(0,J.jsxs)(`button`,{type:`button`,className:`prints-rail-view`,"aria-current":e.kind===`favorites`?`page`:void 0,onClick:()=>{t({kind:`favorites`})},children:[(0,J.jsx)(fr,{"aria-hidden":!0,size:16}),` Favorites`]})]}),(0,J.jsxs)(`div`,{className:`prints-rail-head`,children:[(0,J.jsx)(`span`,{children:`Folders`}),(0,J.jsx)(U,{size:`sm`,variant:`ghost`,"aria-label":`New folder`,title:`New folder`,disabled:!r,onClick:()=>{n(e.kind===`folder`?e.folder:void 0)},children:(0,J.jsx)(Ch,{"aria-hidden":!0,size:16})})]}),(0,J.jsx)(sA,{...i,mode:`browse`,canWrite:r,activeFolder:e.kind===`folder`?e.folder:void 0,active:e.kind===`folder`,onNewFolder:n,onSelectFolder:e=>{t({kind:`folder`,folder:e})}})]})}var lA=`prints-generation-notices`;function uA({count:e,total:t,canWrite:n,onToggleAll:r,onMove:i,onFavorite:a,onDone:o}){let s=t>0&&e===t;return(0,J.jsxs)(`div`,{className:`prints-select-bar`,role:`toolbar`,"aria-label":`Selection`,children:[(0,J.jsx)(`span`,{className:`prints-select-count`,"aria-live":`polite`,children:e===0?`Choose prints`:`${String(e)} selected`}),(0,J.jsxs)(U,{size:`sm`,variant:`ghost`,className:`prints-select-all`,disabled:t===0,onClick:r,children:[(0,J.jsx)(`span`,{className:`prints-select-wide`,children:s?`Clear selection`:`Select all in view`}),(0,J.jsx)(`span`,{className:`prints-select-narrow`,children:s?`None`:`All`})]}),(0,J.jsx)(`span`,{className:`prints-select-spacer`}),(0,J.jsxs)(U,{size:`sm`,variant:`ghost`,"aria-label":`Favorite`,disabled:e===0||!n,onClick:a,children:[(0,J.jsx)(fr,{"aria-hidden":!0,size:16}),(0,J.jsx)(`span`,{className:`prints-select-wide`,children:`Favorite`})]}),(0,J.jsxs)(U,{size:`sm`,disabled:e===0||!n,onClick:i,children:[(0,J.jsx)(On,{"aria-hidden":!0,size:16}),(0,J.jsxs)(`span`,{className:`prints-select-wide`,children:[`Move to… (`,e,`)`]}),(0,J.jsxs)(`span`,{className:`prints-select-narrow`,children:[`Move (`,e,`)`]})]}),(0,J.jsx)(pt,{className:`prints-select-done`,"aria-label":`Done selecting`,title:`Done selecting`,icon:(0,J.jsx)(Ei,{}),size:`sm`,onClick:o})]})}function dA({view:e,lastFolder:t,onOpen:n,onFolders:r,subfolders:i,onOpenSubfolder:a}){return(0,J.jsxs)(`div`,{className:`prints-library-bar`,children:[(0,J.jsx)(_t,{className:`prints-folders-button`,density:`compact`,label:null,"aria-label":`Folders`,title:`Folders`,icon:(0,J.jsx)(wh,{size:16}),onClick:r}),(0,J.jsx)(Sr,{className:`prints-view-switch`,value:e.kind,onValueChange:e=>{n(e===`all`||e===`favorites`?{kind:e}:{kind:`folder`,folder:t})},children:(0,J.jsxs)(Er,{variant:`segmented`,"aria-label":`View`,children:[(0,J.jsx)(Gn,{value:`folder`,children:`Folder`}),(0,J.jsx)(Gn,{value:`all`,children:`All`}),(0,J.jsx)(Gn,{value:`favorites`,children:`Favorites`})]})}),i.length>0?(0,J.jsx)(`div`,{className:`prints-folder-chips`,role:`list`,"aria-label":`Folders`,children:i.map(e=>(0,J.jsx)(_t,{role:`listitem`,density:`compact`,className:`prints-folder-chip`,icon:(0,J.jsx)(Th,{size:16}),label:e,onClick:()=>{a(e)}},e))}):null]})}function fA({app:e,root:t,from:n,canWrite:r,count:i,open:a,version:o,onClose:s,onMove:c}){let[l,u]=(0,q.useState)(n?.folder),[d,f]=(0,q.useState)(``);(0,q.useEffect)(()=>{a&&u(n?.folder)},[a,n?.folder]);let p=d.trim(),m=p===``||ug(p)&&!p.includes(`/`),h=p===``?l:l===void 0?p:`${l}/${p}`,g=n!==null&&p===``&&h===n.folder;return(0,J.jsx)(cm,{open:a,onOpenChange:e=>{e||(f(``),s())},children:(0,J.jsxs)(pm,{className:`prints-move-dialog`,children:[(0,J.jsx)(hm,{children:(0,J.jsxs)(gm,{children:[`Move `,String(i),` `,i===1?`item`:`items`,` to…`]})}),(0,J.jsx)(`div`,{className:`prints-move-tree`,children:(0,J.jsx)(sA,{app:e,root:t,activeFolder:l,mode:`pick`,canWrite:r,version:o,onSelectFolder:u})}),(0,J.jsxs)(`label`,{className:`prints-move-new`,htmlFor:`prints-move-new-folder`,children:[(0,J.jsxs)(`span`,{children:[`New folder inside `,l??`the library`]}),(0,J.jsx)(py,{id:`prints-move-new-folder`,value:d,placeholder:`Folder name`,"aria-invalid":!m,onChange:e=>{f(e.target.value)}})]}),(0,J.jsxs)(mm,{children:[(0,J.jsx)(_m,{render:(0,J.jsx)(U,{variant:`outline`,size:`sm`}),children:`Cancel`}),(0,J.jsx)(U,{size:`sm`,disabled:!m||!r||g,onClick:()=>{f(``),c(h,p!==``)},children:g?`Choose a folder`:`Move to ${h===void 0?`Library`:h.split(`/`).at(-1)??``}`})]})]})})}var pA={conflict:`a file or folder with that name is already there`,not_found:`it is no longer in the library`,invalid:`a folder can't move into itself`,not_granted:`Prints isn't allowed to change this Computer`,unavailable:`the Computer didn't answer`};function mA(e,t,n,r){let{moved:i,failed:a}=n;if(a.length>0){let e=a[0];Wt.error(`Couldn't move ${String(a.length)} ${a.length===1?`item`:`items`}: ${pA[e.error]}.`,{toasterId:lA,id:`prints-move-error`})}i.length!==0&&Wt(`Moved ${String(i.length)} ${i.length===1?`item`:`items`}`,{toasterId:lA,duration:8e3,action:{label:`Undo`,onClick:()=>{let n=new Map;for(let{from:e,to:r}of i){let i=fg(t,e)??``;n.set(i,[...n.get(i)??[],r])}Promise.all([...n].map(([t,n])=>Sg(e,{paths:n,folder:t===``?void 0:t}))).then(()=>{r()},e=>{tn(`prints-undo-move`,e),Wt.error(`Couldn't undo that move.`,{toasterId:lA}),r()})}}})}function hA({parent:e,open:t,onClose:n,onCreate:r}){let[i,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(!1),u=()=>{a(``),s(null),n()},d=async()=>{l(!0);let e=await r(i);l(!1),e===null?u():(s(e),Wt.error(e,{toasterId:lA,id:`prints-new-folder`}))};return(0,J.jsx)(cm,{open:t,onOpenChange:e=>{e||u()},children:(0,J.jsxs)(pm,{className:`prints-new-folder-dialog`,children:[(0,J.jsx)(hm,{children:(0,J.jsxs)(gm,{children:[`New folder in `,e??`the library`]})}),(0,J.jsxs)(`form`,{id:`prints-new-folder-form`,onSubmit:e=>{e.preventDefault(),d()},children:[(0,J.jsx)(`label`,{htmlFor:`prints-new-folder-name`,children:`Name`}),(0,J.jsx)(py,{id:`prints-new-folder-name`,autoFocus:!0,value:i,placeholder:`Characters`,"aria-invalid":o!==null,onChange:e=>{a(e.target.value),s(null)}})]}),(0,J.jsxs)(mm,{children:[(0,J.jsx)(_m,{render:(0,J.jsx)(U,{variant:`outline`,size:`sm`}),children:`Cancel`}),(0,J.jsx)(U,{size:`sm`,type:`submit`,form:`prints-new-folder-form`,disabled:c||i.trim()===``,children:`Create`})]})]})})}var gA=24,_A=`prints-generation-notices`;function vA(e,t){let[n,r]=(0,q.useState)({entries:[],index:-1}),i=(e,t)=>e.kind===t.kind&&(e.kind!==`folder`||t.kind===`folder`&&e.folder===t.folder),a=n=>{r(t=>{let r=t.entries[t.index]??e;if(i(r,n))return t;let a=t.entries.slice(0,t.index+1),o=a.length===0?[e]:a;return{entries:[...o,n],index:o.length}}),t(n)},o=e=>{let i=n.index+e;if(i<0||i>=n.entries.length)return!1;let a=n.entries[i];return r({...n,index:i}),t(a),!0};return{open:a,canGoBack:n.index>0,canGoForward:n.index>=0&&n.index<n.entries.length-1,back:()=>o(-1),forward:()=>o(1)}}function yA({app:e,destination:t,view:n,setView:r,entries:i,canWrite:a}){let o=on(),s=vA(n,r),[c,l]=(0,q.useState)(0),[u,d]=(0,q.useState)(),f=n.kind===`folder`?n.folder:void 0,p=n.kind===`folder`;(0,q.useEffect)(()=>{p&&d(f)},[p,f]);let[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(new Set),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(new Map),w=e?.capabilities.has(Ci)===!0,T=Hs({queries:(0,q.useMemo)(()=>{let e=i.map(e=>e.path),t=[];for(let n=0;n<e.length;n+=gA)t.push(e.slice(n,n+gA));return t},[i]).map(n=>({...mi(e,Ci,Og.described(e,n),async(t,r)=>{if(!e)return[];let i=await Cg(e,n);return r.throwIfAborted(),i}),enabled:w&&t!==null,retry:!1})),combine:e=>{let t=new Map;for(let n of e)for(let e of n.data??[])t.set(e.path,e);return t}}),E=(0,q.useCallback)(()=>{l(e=>e+1),_(new Set),o.invalidateQueries({queryKey:Og.listings(e)}),o.invalidateQueries({queryKey:Og.describedAll(e)})},[e,o]),D=(0,q.useCallback)(async(n,r,i={})=>{if(!(!e||t===null)){try{mA(e,t,await Sg(e,{paths:n,folder:r,createFolder:i.create??!1,name:i.name}),E)}catch(e){tn(`prints-move-files`,e),Wt.error(`Couldn't move those. Check the Computer and try again.`,{toasterId:_A,id:`prints-move-error`})}E()}},[e,t,E]),O=(0,q.useCallback)((t,r)=>{e&&(C(e=>{let n=new Map(e);for(let e of t)n.set(e,r);return n}),wg(e,t,r).then(()=>{o.invalidateQueries({queryKey:Og.describedAll(e)}),n.kind===`favorites`&&o.invalidateQueries({queryKey:Og.listings(e)})},e=>{tn(`prints-set-favorite`,e),Wt.error(`Couldn't change that favorite.`,{toasterId:_A,id:`prints-favorite-error`}),C(e=>{let n=new Map(e);for(let e of t)n.delete(e);return n})}))},[e,o,n.kind]),k=(0,q.useCallback)(async(n,r)=>{if(!e||t===null)return`Choose a library folder first.`;let i=r.trim();if(!ug(i)||i.includes(`/`))return`Use a single name, without slashes.`;let a=n===void 0?i:`${n}/${i}`;if(!ug(a))return`That folder name is too long.`;try{await e.capabilities.require(Ra).mkdir({path:dg(t,a)})}catch(e){return tn(`prints-new-folder`,e),`Couldn't create the folder. Check Computer write access.`}return E(),s.open({kind:`folder`,folder:a}),null},[e,t,s,E]),A=(0,q.useMemo)(()=>n.kind===`folder`?[{id:``,label:t?.split(`/`).at(-1)??`Library`},...pg(n.folder).map(({name:e,folder:t})=>({id:t,label:e}))].slice(-8):[{id:n.kind,label:n.kind===`all`?`All prints`:`Favorites`}],[t,n]),j=e=>S.get(e)??T.get(e)?.favorite??!1,M=e=>{if(t===null||!e.path.startsWith(`${t}/`))return e;let r=T.get(e.path),o=S.get(e.path)??r?.favorite??!1,s=i.find(t=>t.path===e.path),c={...e,badge:void 0,folderCaption:n.kind===`folder`?void 0:s?.folder,favorite:o,select:{active:m,checked:g.has(e.path),onToggle:()=>{_(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n})}}};return!e.pending&&r!==void 0&&(c.badge=r.kind===null?{label:null,seconds:null}:{label:r.modelLabel??r.model,seconds:r.durationSeconds}),w&&(c.onToggleFavorite=()=>{O([e.path],!o)}),w&&a&&(c.onMove=()=>{y([e.path])}),c},N=n.kind===`all`?`All prints`:n.kind===`favorites`?`Favorites`:n.folder?.split(`/`).at(-1)??`Library`,P=n.kind===`folder`&&n.folder!==void 0?n.folder.split(`/`).slice(0,-1).join(`/`):null;return{title:N,up:P===null?void 0:()=>{s.open({kind:`folder`,folder:P===``?void 0:P})},lastFolder:u,history:s,version:c,refresh:E,crumbs:A,selecting:m,setSelecting:e=>{h(e),e||_(new Set)},selected:g,selectAll:e=>{_(new Set(e))},moving:v,setMoving:y,newFolder:b,setNewFolder:x,move:D,toggleFavorite:O,createFolder:k,enrich:M,isFavorite:j,folderOf:fg}}function bA(e,t){return{kind:`button`,id:`folder`,text:t.checking?`Checking…`:`prints`,icon:`folder`,title:e===null?`Choose where Prints saves images`:v(`Save prints to ${e}`,1024),opens:`dialog`,expanded:t.editing}}var xA=(0,q.forwardRef)(function({className:e,label:t,...n},r){return(0,J.jsx)(_t,{...n,ref:r,className:V(`parakeet-composer-model-key`,e),label:t,readout:(0,J.jsx)(ai,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)] shrink-0`})})}),SA={unchecked:`M3.25 5.9 L5.1 7.9 L8.8 3.8`,checked:`M3.25 5.9 L5.1 7.9 L8.8 3.8`,mixed:`M3.4 6 L6 6 L8.6 6`},CA={blurStdDeviation:.22,alphaSlope:18,alphaIntercept:-8};function wA({state:e}){let t=`caps-checkbox-${(0,q.useId)().replaceAll(`:`,``)}`,n=(0,q.useRef)(null),r=(0,q.useRef)(e).current,i=(0,q.useRef)(e),a=ce();return(0,q.useLayoutEffect)(()=>{if(!n.current)return;let t=e!==`unchecked`,r=i.current!==`unchecked`,s=a||i.current===e;i.current=e;let c=Tt(n.current),l=Ur(c,{ease:`inCubic`,duration:160}),u=Po(n.current,{d:{to:SA[e],...s?ki:Ur(c,{ease:`outCubic`,duration:200})},"stroke-dashoffset":{to:+!t,...s?ki:t?Ur(c,{ease:`inOutSine`,duration:260}):l},"stroke-width":s?{to:t?2.4:0,duration:0}:t&&!r?[{to:2.2,...Ur(c,{ease:`outCubic`,duration:65})},{to:2.4,delay:o(c,120),...fi(c,{bounce:.35,duration:220})}]:{to:t?2.4:0,...l}});return()=>{u.cancel()}},[e,a]),(0,J.jsxs)(`svg`,{className:`caps-checkbox-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,J.jsxs)(`defs`,{children:[(0,J.jsx)(f,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,J.jsx)(xe,{id:`${t}-shadow`}),(0,J.jsx)(gn,{id:`${t}-inset`}),(0,J.jsx)(Qe,{id:`${t}-goo`,values:CA}),(0,J.jsxs)(`filter`,{id:`${t}-relief`,x:`-25%`,y:`-25%`,width:`150%`,height:`150%`,colorInterpolationFilters:`sRGB`,children:[(0,J.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`0.28`,result:`relief`}),(0,J.jsx)(`feSpecularLighting`,{in:`relief`,surfaceScale:`1.2`,specularConstant:`0.55`,specularExponent:`18`,lightingColor:`color-mix(in srgb, var(--color-white) calc(var(--depth) * 100%), var(--color-black))`,result:`light`,children:(0,J.jsx)(`feDistantLight`,{azimuth:`225`,elevation:`55`})}),(0,J.jsx)(`feComposite`,{in:`light`,in2:`SourceAlpha`,operator:`in`,result:`clipped-light`}),(0,J.jsx)(`feBlend`,{in:`SourceGraphic`,in2:`clipped-light`,mode:`screen`})]}),(0,J.jsx)(`mask`,{id:`${t}-contour`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`12`,height:`12`,style:{maskType:`alpha`},children:(0,J.jsx)(`path`,{ref:n,d:SA[r],fill:`none`,stroke:`var(--color-white)`,strokeWidth:r===`unchecked`?0:2.4,pathLength:`1`,strokeDasharray:`1`,strokeDashoffset:+(r===`unchecked`),strokeLinecap:`round`,strokeLinejoin:`round`,filter:e===`mixed`?void 0:`url(#${t}-goo)`})}),(0,J.jsx)(`clipPath`,{id:`${t}-well`,children:(0,J.jsx)(`rect`,{x:`1`,y:`1`,width:`10`,height:`10`,rx:`2.5`})})]}),(0,J.jsx)(`rect`,{className:`caps-checkbox-track`,x:`0.5`,y:`0.5`,width:`11`,height:`11`,rx:`3`,filter:`url(#${t}-inset)`}),(0,J.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,J.jsx)(`g`,{filter:`url(#${t}-shadow)`,children:(0,J.jsx)(`g`,{filter:`url(#${t}-relief)`,children:(0,J.jsx)(`g`,{mask:`url(#${t}-contour)`,children:(0,J.jsx)(`rect`,{x:`0`,y:`0`,width:`12`,height:`12`,fill:`url(#${t}-surface)`})})})})})]})}var TA=(0,q.forwardRef)(function({className:e,appearance:t,indicator:n,invalid:r,indeterminate:i=!1,checked:a,defaultChecked:o=!1,onChange:s,...c},l){let u=(0,q.useRef)(null),[d,f]=(0,q.useState)(o),p=a??d,m=i?`mixed`:p?`checked`:`unchecked`;return(0,q.useImperativeHandle)(l,()=>{if(!u.current)throw Error(`Checkbox input is not mounted`);return u.current},[]),(0,q.useLayoutEffect)(()=>{u.current&&(u.current.indeterminate=i)},[i]),(0,q.useEffect)(()=>{let e=u.current?.form;if(!e||a!==void 0)return;let t=e=>{queueMicrotask(()=>{!e.defaultPrevented&&u.current&&f(o)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[a,o,c.form]),(0,J.jsxs)(`span`,{className:`caps-checkbox`,"data-appearance":t===`compact`?t:void 0,"data-state":m,"data-custom-indicator":n!==void 0||void 0,children:[(0,J.jsx)(`input`,{...c,checked:p,"aria-checked":i?`mixed`:p,"aria-invalid":r?!0:c[`aria-invalid`]===!1?void 0:c[`aria-invalid`],className:V(`caps-checkbox-input`,e),onChange:e=>{a===void 0&&f(e.target.checked),s?.(e),e.currentTarget.indeterminate=i},ref:u,type:`checkbox`}),n===void 0?(0,J.jsx)(wA,{state:m}):n]})});function EA({getKey:e,isDisabled:t=()=>!1,items:n}){let r=(0,q.useMemo)(()=>{let r=n.map(e);if(r.some(e=>!e))throw Error(`Selectable items require non-empty keys`);if(new Set(r).size!==r.length)throw Error(`Selectable items require unique keys`);return n.filter(e=>!t(e))},[e,t,n]),[i,a]=(0,q.useState)(null);(0,q.useEffect)(()=>{i!==null&&!r.some(t=>e(t)===i)&&a(null)},[i,r,e]);let o=r.find(t=>e(t)===i),s=o?r.findIndex(t=>e(t)===i):-1;return{activeIndex:s,activeItem:o,activeKey:i,enabledItems:r,move:(t,n)=>{if(r.length===0)return;let i=n?n===`start`?0:r.length-1:s<0?t>0?0:r.length-1:(s+t+r.length)%r.length,o=r[i];o&&a(e(o))},setActiveKey:a}}var DA={draft:`Draft`,balanced:`Balanced`,premium:`Premium`,max:`Max`};function OA(e){if(e.kind!==`video`||e.video===null)return DA[e.tier];let t=Math.min(...e.video.prices.map(e=>e.silentMilliunitsPerSecond)),n=Number.isFinite(t)?pi(t):null;return n===null?`Video`:`Video · from ${n}/s`}var kA=[{kind:`image`,label:`Images`},{kind:`video`,label:`Video`}];function AA(e){let t=()=>{e.scrollHeight-e.scrollTop-e.clientHeight>1?e.setAttribute(`data-more`,``):e.removeAttribute(`data-more`)};t();let n=requestAnimationFrame(t);return e.addEventListener(`scroll`,t,{passive:!0}),()=>{cancelAnimationFrame(n),e.removeEventListener(`scroll`,t)}}function jA({compact:e=!1,disabled:t,emptyLabel:n,models:r,onChange:i,value:a}){let o=r.find(e=>e.id===a),[s,c]=(0,q.useState)(null);(0,q.useEffect)(()=>{if(s!==null)return AA(s)},[s]);let[l,u]=(0,q.useState)(null);return(0,J.jsx)(`span`,{className:`contents`,ref:u,children:(0,J.jsxs)(Co,{children:[(0,J.jsx)(Ia,{"aria-label":`Generation model`,"data-generation-model":a,disabled:t||r.length===0,render:(t,r)=>{let i=o===void 0?n:Rn(o);return e?(0,J.jsx)(_t,{...t,className:`parakeet-composer-model-key`,expanded:r.open,icon:(0,J.jsx)(Mi,{}),label:null,readout:(0,J.jsx)(ai,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)] shrink-0`}),title:i}):(0,J.jsx)(xA,{...t,expanded:r.open,label:i})}}),(0,J.jsx)(qa,{ref:c,"data-generation-model-menu":!0,container:qg(l),side:`top`,align:`start`,"aria-label":`Generation models`,children:kA.map((e,t)=>{let n=r.filter(t=>t.kind===e.kind);return n.length===0?null:(0,J.jsxs)(mo,{children:[t>0?(0,J.jsx)(Ya,{}):null,(0,J.jsx)(Za,{children:e.label}),n.map(e=>(0,J.jsx)(Wa,{"data-generation-model-option":e.id,checked:e.id===a,closeOnClick:!0,onSelect:()=>{i(e.id)},children:(0,J.jsxs)(`span`,{className:`prints-model-row flex items-baseline gap-lg`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1`,children:Rn(e)}),(0,J.jsx)(`span`,{className:`prints-model-detail`,children:OA(e)})]})},e.id))]},e.kind)})})]})})}var MA={kind:`folder`,folder:void 0};function NA(e){let t=zf(e),n=(0,q.useRef)(e);n.current=e;let r=on(),i=Li(In(e)),a=Ks(Ag(e,i.data?.configured?{kind:`folder`,path:i.data.path}:null)),o=`${t??``}:${i.data?.path??``}`,[s,c]=(0,q.useState)({scope:o,view:MA}),l=s.scope===o?s.view:MA,d=e=>{c({scope:o,view:e})},[f,p]=(0,q.useState)(null),m=n=>n?.app===e&&n.computerId===t,h=se({mutationKey:oi.folder(e),mutationFn:async({owner:e,id:t,path:r,create:i})=>{let a=()=>{if(n.current!==e||e.context.get().computerId!==t)throw new G(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1})};return a(),i&&await e.capabilities.require(Ra).mkdir({path:r}),a(),await fo(e.capabilities,{path:r,limit:1,offset:0}),a(),dr(e.capabilities,{operation:`select-folder`,computerId:t,path:r})},onSuccess:(e,t)=>{t.owner===n.current&&t.owner.context.get().computerId===t.id&&p(null)},onSettled:(e,t,n)=>Promise.all([r.invalidateQueries({queryKey:n.queryKey,exact:!0}),r.invalidateQueries({queryKey:Og.listing(n.owner,n.path),exact:!0})])}),g=h.variables?.owner===e&&h.variables.id===t,_=i.isFetching||g&&h.isPending,v=async(n,r)=>{if(!e||!t||_)return`Computer selection changed. Try again.`;let i=n.trim();if(!u($n)(i))return`Enter an absolute Computer folder, such as /media.`;try{return await h.mutateAsync({owner:e,id:t,path:i,create:r,queryKey:oi.folder(e)}),null}catch{return`Could not use this folder. Check its location and your Computer permissions.`}},y=i.isError||a.isError,b=y||!i.data?.configured?null:i.data.path,x=b===null?null:l.kind===`folder`?dg(b,l.folder):b,S=b===null?null:l.kind===`folder`?{kind:`folder`,path:x??b}:{kind:l.kind,path:b};return{view:l,setView:d,destination:b,landingPath:x??(y?null:i.data?.path??null),source:S,path:y?null:i.data?.path??null,computerId:t,available:e?.capabilities.has(Zr)===!0,writable:e?.capabilities.has(Ra)===!0,busy:_,error:y?`Your media folder is unavailable. Choose or create a folder.`:null,editing:m(f),setEditing:n=>{p(n?{app:e,computerId:t}:null)},choose:v,ensureCreated:async()=>i.data?i.data.configured?null:v(i.data.path,!0):`Your Prints library is still loading.`,recheck:()=>{r.invalidateQueries({queryKey:Og.listing(e,i.data?.path??null),exact:!0}),r.invalidateQueries({queryKey:oi.folder(e),exact:!0})}}}var PA=w(b),FA=w(g({message:b}));function IA(e){for(let t of e.errors){let e=dn(Ce(et(FA(t),e=>e.message),()=>PA(t)));if(e!==void 0&&e.length>0)return e}}var LA={neutral:`progress-neutral`,primary:`progress-primary`,secondary:`progress-secondary`,accent:`progress-accent`,success:`progress-success`,info:`progress-info`,warning:`progress-warning`,error:`progress-error`},RA=(0,q.forwardRef)(function({className:e,tone:t=`primary`,...n},r){return(0,J.jsx)(`progress`,{...n,"data-complete":n.value!==void 0&&Number(n.value)>=Number(n.max??1)?`true`:void 0,className:V(`progress caps-gooey-motion caps-gooey-progress w-full`,LA[t],e),ref:r})});(0,q.forwardRef)(function({label:e,value:t,max:n,tone:r=`info`,className:i,...a},o){return(0,J.jsxs)(`div`,{...a,ref:o,className:V(`caps-game-meter`,i),children:[(0,J.jsxs)(`div`,{className:`caps-game-meter-readout`,children:[(0,J.jsx)(`span`,{children:e}),(0,J.jsxs)(`span`,{className:`caps-game-meter-value`,children:[t,` / `,n]})]}),(0,J.jsx)(RA,{"aria-label":e,value:t,max:n,tone:r})]})});function zA({className:e,items:t,onCancel:n,onRemove:r,onRetry:i,rowClassName:a}){return t.length?(0,J.jsx)(`div`,{"aria-live":`polite`,className:`caps-upload-queue flex w-full min-w-0 flex-col gap-sm ${e??``}`,"data-upload-rows":!0,children:t.map(e=>(0,J.jsx)(HA,{item:e,onCancel:n,onRemove:r,onRetry:i,...a===void 0?{}:{rowClassName:a}},e.id))}):null}function BA({action:e,id:t,onAction:n,retry:r=!1}){return e?(0,J.jsx)(pt,{"aria-label":e.accessibleLabel,title:e.label,variant:`ghost`,size:`xs`,className:`motion-reduce:transition-none`,icon:r?(0,J.jsx)(Ar,{}):(0,J.jsx)(Ei,{}),onClick:()=>void n(t),type:`button`}):null}function VA({item:e}){return(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block min-w-0 truncate`,title:e.name,children:e.name}),(0,J.jsx)(`div`,{className:`caps-upload-details`,children:(0,J.jsxs)(`span`,{"aria-live":e.alert?`assertive`:void 0,className:`caps-upload-status min-w-0 break-words`,"data-upload-status":!0,role:e.alert?`alert`:void 0,children:[e.alert??e.statusLabel,` `,e.progressLabel]})})]})}function HA({item:e,onCancel:t,onRemove:n,onRetry:r,rowClassName:i}){return(0,J.jsxs)(`div`,{className:`caps-upload-row grid w-full min-w-0 max-w-full grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-sm p-sm text-xs ${i??``}`,children:[e.preview.kind===`image`?(0,J.jsx)(`img`,{alt:``,className:`caps-upload-preview mask mask-squircle size-8 shrink-0 object-cover`,src:e.preview.url}):(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`caps-upload-preview mask mask-squircle flex size-8 shrink-0 items-center justify-center bg-base-300`,children:(0,J.jsx)(Jr,{className:`size-4`})}),(0,J.jsx)(VA,{item:e}),(0,J.jsx)(UA,{actions:e.actions,id:e.id,onCancel:t,onRemove:n,onRetry:r}),(0,J.jsx)(RA,{"aria-label":`${e.name} progress`,className:`caps-upload-progress`,tone:e.alert?`error`:e.progress===100?`success`:`accent`,max:100,value:e.progress??(e.alert?0:void 0)})]})}function UA({actions:e,id:t,onCancel:n,onRemove:r,onRetry:i}){return(0,J.jsxs)(`div`,{className:`caps-upload-actions flex min-w-0 flex-wrap justify-end gap-xs`,children:[(0,J.jsx)(BA,{action:e.retry,id:t,onAction:i,retry:!0}),(0,J.jsx)(BA,{action:e.cancel,id:t,onAction:n}),(0,J.jsx)(BA,{action:e.remove,id:t,onAction:r})]})}var WA=q.createContext(void 0);function GA(e){let t=q.useContext(WA);if(t===void 0&&!e)throw Error(Oa(47));return t}var KA={...No,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!No.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&No.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>No.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},qA=class extends $i{constructor(e,t,n){let r=new ja;super(JA(e,r,t,n),YA(r),KA)}setOpen=(e,t)=>{let n=t.reason===Ea,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=go(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=Pa(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),eg.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function JA(e,t,n,r=!1){let i={...Ca(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function YA(e){return{popupRef:q.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:q.createRef(),beforeTriggerFocusGuardRef:q.createRef(),beforeContentFocusGuardRef:q.createRef(),stickIfOpenTimeout:new Eo,stickIfOpen:!0,triggerElements:e}}var XA=ka(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=QA(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),Ka(u,d),Na(u);let{forceUnmount:m}=Fa(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),q.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),q.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,ra(Oo))}),[m,u]);let h=d||f||s!=null;return(0,J.jsxs)(WA.Provider,{value:u,children:[s&&(0,J.jsx)(fa,{handle:s,store:u}),h&&(0,J.jsx)($A,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function ZA(e){return GA(!0)?(0,J.jsx)(XA,{props:e}):(0,J.jsx)(Ua,{children:(0,J.jsx)(XA,{props:e})})}function QA(e,t){let n=Xi((e,n)=>new qA(t,e,n));return q.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function $A({store:e,modal:t}){let n=e.useState(`floatingRootContext`),r=eo(n,{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),i=r.reference,a=r.floating;return Sa(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}var ej=ca(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=GA(!0),h=pa(s)??m;if(!h)throw Error(Oa(74));let g=Va(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=q.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=So(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`isPressOpenedByTrigger`,g),T=h.useState(`isTouchPressOpen`,l),E=h.useState(`hasTriggerFocusGuards`,g),D=aa(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:ba(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=Qi(()=>h.context.stickIfOpen),k=za(v,{stickIfOpen:O}),A=ro(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),j=h.useState(`triggerProps`,C),{getButtonProps:M,buttonRef:N}=ya({disabled:a,native:o}),P={open(e){return w?xa.open(e):oa.open(e)}},{handlePreFocusGuardFocus:F,handleFocusTargetFocus:I}=jo(h,x),ee=Aa(`button`,e,{state:{disabled:a,open:y},ref:[N,t,S,x],props:[k.reference,D,j,A,{[Ga]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,M],stateAttributesMapping:P}),te=(0,J.jsx)(q.Fragment,{children:ee},g);return E?(0,J.jsxs)(q.Fragment,{children:[(0,J.jsx)(ho,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:F}),te,(0,J.jsx)(ho,{ref:h.context.triggerFocusTargetRef,onFocus:I})]}):te}),tj=q.createContext(void 0);function nj(){let e=q.useContext(tj);if(e===void 0)throw Error(Oa(45));return e}var rj=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return GA().useState(`mounted`)||n?(0,J.jsx)(tj.Provider,{value:n,children:(0,J.jsx)(wo,{ref:t,...r})}):null}),ij=q.createContext(void 0);function aj(){let e=q.useContext(ij);if(!e)throw Error(Oa(46));return e}var oj=q.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=Ja,..._}=e,v=GA(),y=nj(),b=oo(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=v.useState(`adaptiveOrigin`),M=ta({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:j}),N=x.useState(`domReferenceElement`);wa({store:v,domReference:N,positionerElement:O,open:C});let P=E===!0&&w!==`trigger-hover`;Ba(C&&P,D===`touch`,O,T);let F=v.useStateSetter(`positionerElement`),I={open:C,side:M.side,align:M.align,anchorHidden:M.anchorHidden,instant:k},ee=ko(e,I,{styles:M.positionerStyles,transitionStatus:A,props:_,refs:[t,F],hidden:!S,inert:!C});return(0,J.jsxs)(ij.Provider,{value:M,children:[S&&P&&(0,J.jsx)(to,{inert:ma(!C),cutout:T}),(0,J.jsx)(bo,{id:b,children:ee})]})}),sj=q.createContext(void 0);function cj(){let[e,t]=q.useState(0),n=Qi(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:q.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var lj=q.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=GA(),l=aj(),u=ia(!0)!=null,{context:d,hasClosePart:f}=cj(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);uo({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),ua(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?da(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M={open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},N=Aa(`div`,e,{state:M,ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...sa,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&ga.has(e.key)&&e.stopPropagation()}},Ta(g),s],stateAttributesMapping:_a});return(0,J.jsx)(po,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:no(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,J.jsx)(sj.Provider,{value:d,children:N})})}),uj=(0,q.forwardRef)(function({children:e,className:t,type:n=`button`,...r},i){return(0,J.jsxs)(`button`,{...r,ref:i,type:n,className:V(`select caps-select caps-combobox-trigger w-full`,t),children:[(0,J.jsx)(`span`,{children:e}),(0,J.jsx)(ai,{className:`caps-select-chevron`,"aria-hidden":`true`})]})});function dj({defaultOpen:e,defaultValue:t,getKey:n,getSearchText:r,groupBy:i,id:a,isDisabled:o,items:s,onOpenChange:c,onCommit:l,multiple:u,controlledOpen:d,controlledKeys:f,trigger:p}){let m=`${a}-listbox`,[h,g]=(0,q.useState)(``),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(t),[x,S]=(0,q.useState)(e),C=f??(y===null?[]:[y]),w=p?d??x:!0,T=(0,q.useMemo)(()=>{let e=h.trim().toLowerCase();return e?s.filter(t=>r(t).toLowerCase().includes(e)):s},[r,s,h]),E=EA({getKey:n,isDisabled:o,items:T});(0,q.useEffect)(()=>{if(E.activeKey!==null)return;let e=E.enabledItems.find(e=>C.includes(n(e)))??E.enabledItems[0];e&&E.setActiveKey(n(e))},[E.activeKey,E.enabledItems,E.setActiveKey,n,C]);let D=e=>{v(!1),e||g(``),d===void 0&&S(e),c?.(e)},O=e=>`${m}-option-${encodeURIComponent(e)}`,k=e=>{let t=n(e);f===void 0&&b(t),l(e),p&&!u&&D(!1)},A=e=>{v(!0),g(e.target.value),E.setActiveKey(null)},j=e=>{if(zi(e))return;let t;switch(e.key){case`ArrowDown`:t=[1,void 0];break;case`ArrowUp`:t=[-1,void 0];break;case`End`:t=[1,`end`];break;case`Home`:t=[-1,`start`]}t?(v(!0),e.preventDefault(),E.move(t[0],t[1])):e.key===`Enter`&&E.activeItem&&(e.preventDefault(),k(E.activeItem))},M=(0,q.useMemo)(()=>{if(!i)return[{label:``,items:T}];let e=new Map;for(let t of T){let n=i(t),r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e].map(([e,t])=>({label:e,items:t}))},[T,i]);return{keyboardNavigation:_,onPointerMove:()=>{v(!1)},activeKey:E.activeKey,activeItem:E.activeItem,groups:M,inputValue:h,listboxId:m,onInputChange:A,onInputKeyDown:j,optionId:O,open:w,commit:k,selectedKeys:C,setOpen:D}}function fj(e){let{"aria-describedby":t,"aria-invalid":n,"aria-label":r,"aria-labelledby":i,"aria-required":a,activeTone:o=`neutral`,container:s,contentClassName:c,defaultOpen:l=!1,defaultValue:u=null,emptyMessage:d=`No matches`,getKey:f,getLabel:p,getSearchText:m=p,groupBy:h,id:g,inputProps:_,inputRef:v,isDisabled:y=()=>!1,items:b,onOpenChange:x,onValueChange:S,multiple:C,open:w,placeholder:T=`Search…`,renderItem:E,rootRef:D,trigger:O,triggerRef:k,value:A,...j}=e,M=e=>{let t=f(e);if(C){let e=A.includes(t)?A.filter(e=>e!==t):[...A,t];S?.(e,b.filter(t=>e.includes(f(t))))}else S?.(t,e)},N;C?N=A:A!==void 0&&(N=A===null?[]:[A]);let P=(0,q.useId)(),F=O?.props??_,I=g??F?.id??P,ee={id:I,"aria-describedby":[t,F?.[`aria-describedby`]].filter(Boolean).join(` `)||void 0,"aria-invalid":n??F?.[`aria-invalid`],"aria-label":F?.[`aria-label`]??r,"aria-labelledby":F?.[`aria-labelledby`]??i,"aria-required":a??F?.[`aria-required`]},{keyboardNavigation:te,onPointerMove:ne,activeItem:re,activeKey:L,commit:R,groups:ie,inputValue:ae,listboxId:oe,onInputChange:se,onInputKeyDown:ce,open:z,optionId:le,selectedKeys:B,setOpen:ue}=dj({defaultOpen:l,defaultValue:u,getKey:f,getSearchText:m,groupBy:h,id:I,isDisabled:y,items:b,onOpenChange:x,onCommit:M,multiple:C??!1,controlledOpen:w,controlledKeys:N,trigger:O});na(()=>{O&&ue(!1)});let de=va(`popover`),fe=s===void 0?de:s,pe=To(`.caps-combobox-option[data-active="true"]:not(:disabled), [data-navigation="pointer"] .caps-combobox-option:hover:not(:disabled)`),me=(0,J.jsx)(py,{..._,...O?{}:ee,"aria-activedescendant":re?le(f(re)):void 0,"aria-autocomplete":`list`,"aria-controls":oe,"aria-expanded":!0,className:V(`input-sm`,_?.className),id:O?_?.id??`${I}-input`:I,onChange:e=>{_?.onChange?.(e),se(e)},onKeyDown:e=>{_?.onKeyDown?.(e),e.defaultPrevented||ce(e)},placeholder:_?.placeholder??T,ref:v,role:`combobox`,value:ae}),he=(0,J.jsx)(`div`,{id:oe,ref:pe,className:`caps-combobox-list`,"data-navigation":te?`keyboard`:`pointer`,onPointerMove:ne,role:`listbox`,"aria-multiselectable":C??void 0,children:ie.every(e=>e.items.length===0)?(0,J.jsx)(`div`,{className:`px-md py-md text-sm text-base-content`,children:d}):ie.map(e=>(0,J.jsxs)(`div`,{"aria-label":e.label||void 0,role:e.label?`group`:void 0,children:[e.label?(0,J.jsx)(`div`,{className:`px-md pb-xs pt-sm text-xs text-base-content uppercase tracking-wider`,children:e.label}):null,e.items.map(e=>{let t=f(e),n=y(e),r=L===t,i={active:r,disabled:n,selected:B.includes(t)};return(0,J.jsxs)(`button`,{"aria-disabled":n||void 0,"aria-selected":i.selected,className:`caps-combobox-option`,"data-active":r&&te,disabled:n,id:le(t),onClick:()=>{R(e)},onMouseDown:e=>{e.preventDefault()},role:`option`,tabIndex:-1,type:`button`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`caps-combobox-check`,children:i.selected?(0,J.jsx)(Lr,{}):null}),E?.(e,r,i)??p(e)]},t)})]},e.label))});return O?(0,J.jsx)(`div`,{...j,className:V(j.className),ref:D,children:(0,J.jsxs)(ZA,{modal:!0,onOpenChange:ue,open:z,children:[(0,J.jsx)(ej,{...ee,"aria-haspopup":`dialog`,className:`btn`,ref:k,render:O}),fe===null?null:(0,J.jsx)(rj,{container:fe,children:(0,J.jsx)(oj,{align:`start`,side:`bottom`,sideOffset:4,children:(0,J.jsxs)(lj,{"data-active-tone":o,className:V(`min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none caps-combobox-panel caps-combobox-popup`,c),children:[(0,J.jsx)(`div`,{className:`caps-combobox-search`,children:me}),he]})})})]})}):(0,J.jsx)(`div`,{...j,className:V(j.className),ref:D,children:(0,J.jsxs)(`div`,{className:V(`caps-combobox-panel`,c),"data-active-tone":o,children:[(0,J.jsx)(`div`,{className:`caps-combobox-search`,children:me}),he]})})}function pj({icon:e,caption:t}){return(0,J.jsxs)(`span`,{className:`caps-icon-choice-mark`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{className:`caps-icon-choice-art`,children:e}),t?(0,J.jsx)(`span`,{className:`caps-icon-choice-caption`,children:t}):null,(0,J.jsx)(`span`,{className:`caps-icon-choice-lamp`})]})}var mj=(0,q.forwardRef)(function({label:e,icon:t,caption:n,appearance:r,className:i,...a},o){return(0,J.jsx)(`label`,{className:`caps-icon-choice`,"data-appearance":r===`compact`?r:void 0,children:(0,J.jsx)(TA,{...a,appearance:r??`default`,"aria-label":e,className:V(`caps-icon-choice-input`,i),indicator:(0,J.jsx)(pj,{icon:t,caption:n}),ref:o})})}),hj=(0,q.forwardRef)(function({label:e,icon:t,hint:n,className:r,...i},a){let o=(0,q.useId)(),s=[i[`aria-describedby`],n?o:null].filter(Boolean).join(` `)||void 0;return(0,J.jsx)(`label`,{className:`caps-check-key`,children:(0,J.jsx)(TA,{...i,"aria-label":e,"aria-describedby":s,className:V(`caps-check-key-input`,r),indicator:(0,J.jsxs)(`span`,{className:`caps-check-key-face`,"aria-hidden":`true`,children:[t?(0,J.jsx)(`span`,{className:`caps-check-key-icon`,children:t}):null,(0,J.jsxs)(`span`,{className:`caps-check-key-copy`,children:[(0,J.jsx)(`span`,{className:`caps-check-key-label`,children:e}),n?(0,J.jsx)(`span`,{className:`caps-check-key-hint`,id:o,children:n}):null]}),(0,J.jsx)(`span`,{className:`caps-check-key-lamp`})]}),ref:a})})});function gj({className:e,...t}){return(0,J.jsx)(`div`,{...t,className:V(`caps-check-keys`,e)})}function _j({checked:e}){let t=`caps-radio-${(0,q.useId)().replaceAll(`:`,``)}`,n=(0,q.useRef)(null),r=(0,q.useRef)(e).current,i=(0,q.useRef)(e),a=(0,q.useRef)(null),o=ie(a),{reduced:s}=o;return(0,q.useLayoutEffect)(()=>{if(!n.current)return;let t=s||i.current===e;i.current=e;let r=e?4:0,a=Ur(o,{ease:`outCubic`,duration:75}),c=e?fi(o,{bounce:.65,duration:300}):Ur(o,{ease:`inCubic`,duration:100}),l=Po(n.current,t?{rx:r,ry:r,cy:6,duration:0}:{rx:[{to:e?3.5:4.15,...a},{to:r,...c}],ry:[{to:e?4.5:3.85,...a},{to:r,...c}],cy:[{to:e?5.85:6.1,...a},{to:6,...c}]});return()=>{l.cancel()}},[e,s,o]),(0,J.jsxs)(`svg`,{ref:a,className:`caps-radio-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,J.jsxs)(`defs`,{children:[(0,J.jsx)(f,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,J.jsx)(xe,{id:`${t}-shadow`}),(0,J.jsx)(gn,{id:`${t}-inset`}),(0,J.jsx)(`clipPath`,{id:`${t}-well`,children:(0,J.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})})]}),(0,J.jsx)(`circle`,{className:`caps-radio-track`,cx:`6`,cy:`6`,r:`5.5`,filter:`url(#${t}-inset)`}),(0,J.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,J.jsx)(`ellipse`,{ref:n,cx:`6`,cy:`6`,rx:r?4:0,ry:r?4:0,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var vj=(0,q.createContext)(null),yj=(0,q.forwardRef)(function({children:e,className:t,defaultValue:n,disabled:r=!1,name:i,onValueChange:a,orientation:o=`vertical`,value:s,...c},l){let u=(0,q.useId)(),d=(0,q.useRef)(null);(0,q.useImperativeHandle)(l,()=>{if(!d.current)throw Error(`RadioGroup is not mounted`);return d.current},[]);let f=i??`radio-group-${u}`,[p,m]=(0,q.useState)(n),h=s??p;return(0,q.useEffect)(()=>{let e=d.current?.form;if(!e||s!==void 0)return;let t=e=>{queueMicrotask(()=>{e.defaultPrevented||m(n)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[s,n,c.form]),(0,J.jsx)(vj.Provider,{value:{disabled:r,name:f,onValueChange:e=>{s===void 0&&m(e),a?.(e)},value:h},children:(0,J.jsx)(`fieldset`,{...c,className:V(`flex gap-md`,o===`horizontal`?`flex-row flex-wrap`:`flex-col`,t),disabled:r,role:c.role??`radiogroup`,ref:d,children:e})})}),bj=(0,q.forwardRef)(function({className:e,indicator:t,onChange:n,onClick:r,value:i,...a},o){let s=(0,q.useContext)(vj);if(!s)throw Error(`RadioGroupItem must be used inside <RadioGroup>`);let c=s.value===i,l=e=>{n?.(e),e.target.checked&&s.onValueChange?.(i)};return(0,J.jsxs)(`span`,{className:`caps-radio`,"data-checked":c,"data-custom-indicator":t!==void 0||void 0,children:[(0,J.jsx)(`input`,{...a,"aria-checked":c,checked:c,className:V(`caps-radio-input`,e),disabled:s.disabled||a.disabled,name:s.name,onChange:l,onClick:r,ref:o,type:`radio`,value:i}),t===void 0?(0,J.jsx)(_j,{checked:c}):t]})}),xj=(0,q.forwardRef)(function({description:e,id:t,meta:n,title:r,...i},a){let o=(0,q.useContext)(vj),s=(0,q.useId)(),c=t??s,l=o?.value===i.value,u=o?.disabled===!0||i.disabled===!0;return(0,J.jsxs)(`label`,{className:`caps-choice-card`,"data-checked":l,"data-disabled":u||void 0,htmlFor:c,children:[(0,J.jsx)(bj,{...i,"aria-describedby":e?`${c}-description`:void 0,"aria-labelledby":`${c}-title`,id:c,ref:a}),(0,J.jsxs)(`span`,{className:`caps-choice-card-copy`,children:[(0,J.jsx)(`span`,{className:`caps-choice-card-title`,id:`${c}-title`,children:r}),e?(0,J.jsx)(`span`,{className:`caps-choice-card-description`,id:`${c}-description`,children:e}):null]}),n?(0,J.jsx)(`span`,{className:`caps-choice-card-meta`,children:n}):null]})}),Sj=(0,q.forwardRef)(function({label:e,icon:t,caption:n,art:r=`dim`,className:i,...a},o){return(0,J.jsx)(`label`,{className:`caps-icon-choice`,"data-art":r===`color`?r:void 0,children:(0,J.jsx)(bj,{...a,"aria-label":e,className:V(`caps-icon-choice-input`,i),indicator:(0,J.jsx)(pj,{icon:t,caption:n}),ref:o})})});(0,q.forwardRef)(function({label:e,color:t,className:n,...r},i){return(0,J.jsx)(`label`,{className:`caps-icon-choice`,"data-art":`color`,"data-swatch":``,title:e,children:(0,J.jsx)(bj,{...r,"aria-label":e,className:V(`caps-icon-choice-input`,n),indicator:(0,J.jsx)(pj,{icon:(0,J.jsx)(`span`,{className:`caps-swatch-dot`,style:{backgroundColor:t}})}),ref:i})})});var Cj=w(b),wj=w(mt),Tj=w(p(Ge)),Ej=w(vt(b)),Dj=vt(wn(File)),Oj=w(Dj),kj=Et([b,Ge,mt,Se,kt,vt(b),Dj]),Aj=w(kj),jj=e=>ht(Cj(e.state.value),()=>``),Mj=e=>ht(wj(e.state.value),()=>!1),Nj=e=>ht(Tj(e.state.value),()=>null),Pj=e=>ht(Ej(e.state.value),()=>[]),Fj=e=>ht(Oj(e.state.value),()=>[]),Ij=e=>ht(Aj(e.state.value),()=>null);function Lj({field:e,spec:t,locked:n,...r}){let[i,a]=(0,q.useState)(!1);return(0,J.jsxs)(hy,{children:[(0,J.jsx)(py,{...r,name:t.name,disabled:n,type:i?`text`:`password`,autoComplete:`off`,spellCheck:!1,className:`caps-field-secret`,placeholder:t.placeholder,readOnly:t.readOnly,value:jj(e),onBlur:e.handleBlur,onChange:t=>{e.handleChange(t.currentTarget.value)}}),(0,J.jsx)(U,{type:`button`,variant:`outline`,size:`icon`,"aria-label":i?`Hide`:`Show`,"aria-pressed":i,disabled:n,onClick:()=>{a(e=>!e)},children:i?(0,J.jsx)(xh,{"aria-hidden":`true`}):(0,J.jsx)(Sh,{"aria-hidden":`true`})})]})}var Rj={text:`text`,email:`email`,url:`url`,tel:`tel`};function zj({spec:e,field:t,locked:n,...r}){let i=Fj(t),a=n||e.readOnly===!0,o=(0,q.useRef)(null);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,J.jsx)(Te,{asChild:!0,children:(0,J.jsx)(`input`,{...r,ref:o,type:`file`,tabIndex:-1,required:r.required===!0&&i.length===0,name:e.name,accept:e.accept,multiple:e.multiple,disabled:a,onBlur:t.handleBlur,onChange:e=>{t.handleChange(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),(0,J.jsx)(U,{type:`button`,variant:`outline`,"aria-label":`Choose files for ${e.label}`,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],disabled:a,onBlur:t.handleBlur,onClick:()=>{o.current?.click()},children:`Choose files`}),(0,J.jsx)(zA,{items:i.map((e,t)=>({id:String(t),name:e.name,preview:{kind:`file`},progress:0,progressLabel:`${String(e.size)} bytes`,statusLabel:`Selected`,actions:a?{}:{remove:{label:`Remove`,accessibleLabel:`Remove ${e.name}`}}})),onRemove:e=>{t.handleChange(i.filter((t,n)=>String(n)!==e))},onCancel:()=>void 0,onRetry:()=>void 0})]})}function Bj({spec:e,field:t,locked:n,...r}){let i=e=>{t.handleChange(e)},a={...r,name:e.name,disabled:n,onBlur:t.handleBlur};switch(e.kind){case`text`:case`email`:case`url`:case`tel`:return(0,J.jsx)(py,{...a,type:Rj[e.kind],inputMode:e.kind===`text`?void 0:e.kind,autoComplete:e.autoComplete,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:jj(t),onChange:e=>{i(e.currentTarget.value)}});case`textarea`:return(0,J.jsx)(Gi,{...a,rows:e.rows??3,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:jj(t),onChange:e=>{i(e.currentTarget.value)}});case`secret`:return(0,J.jsx)(Lj,{...r,field:t,spec:e,locked:n});case`money`:return(0,J.jsxs)(hy,{children:[(0,J.jsx)(gy,{className:`caps-field-currency`,children:e.currency??`USD`}),(0,J.jsx)(py,{...a,inputMode:`decimal`,autoComplete:`off`,className:`caps-field-amount`,placeholder:e.placeholder??`0.00`,readOnly:e.readOnly,value:jj(t),onChange:e=>{i(e.currentTarget.value)}})]});case`date`:return(0,J.jsx)(py,{...a,type:`date`,readOnly:e.readOnly,value:jj(t),onChange:e=>{i(e.currentTarget.value)}});case`number`:return(0,J.jsx)(jy,{...a,...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max},...e.step===void 0?{}:{step:e.step},...e.unit===void 0?{}:{unit:e.unit},...e.wrap===void 0?{}:{wrap:e.wrap},disabled:n||e.readOnly===!0,decrementLabel:`Decrease ${e.label}`,incrementLabel:`Increase ${e.label}`,value:Nj(t),onValueChange:e=>{t.handleChange(e)}});case`select`:return(0,J.jsxs)(My,{...a,value:jj(t),onChange:e=>{i(e.currentTarget.value)},children:[e.placeholder===void 0?null:(0,J.jsx)(`option`,{value:``,disabled:!0,children:e.placeholder}),e.options.map(e=>(0,J.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]});case`combobox`:return(0,J.jsx)(fj,{id:r.id??e.name,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],"aria-required":r[`aria-required`],items:e.options,getKey:e=>e.value,getLabel:e=>e.label,isDisabled:t=>t.disabled||n||e.readOnly===!0,value:jj(t),...e.placeholder===void 0?{}:{placeholder:e.placeholder},trigger:(0,J.jsx)(uj,{name:e.name,disabled:n||e.readOnly===!0,onBlur:t.handleBlur,children:e.options.find(e=>e.value===jj(t))?.label??e.placeholder??`Choose…`}),inputProps:{"aria-label":`Search ${e.label}`,disabled:n||e.readOnly===!0},onValueChange:e=>{i(e??``),t.handleBlur()}});case`file`:return(0,J.jsx)(zj,{...r,spec:e,field:t,locked:n});case`checkbox`:return(0,J.jsx)(TA,{...a,disabled:n||e.readOnly===!0,checked:Mj(t),onChange:e=>{t.handleChange(e.currentTarget.checked)}});case`switch`:return(0,J.jsx)(zn,{...a,disabled:n||e.readOnly===!0,checked:Mj(t),onCheckedChange:e=>{t.handleChange(e)}});case`radio`:case`icon-radio`:case`checkboxes`:case`icon-checkboxes`:return null}}var Vj=new Set([`radio`,`icon-radio`,`checkboxes`,`icon-checkboxes`]);function Hj({spec:e,field:t,locked:n,error:r,layout:i}){let a=n||e.readOnly===!0,o=e.label;if(e.kind===`checkboxes`||e.kind===`icon-checkboxes`){let n=Pj(t),s=(e,r)=>{t.handleChange(r?[...n,e]:n.filter(t=>t!==e))};return(0,J.jsx)(wy,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:e.kind===`icon-checkboxes`?(0,J.jsx)(`div`,{className:`caps-field-icon-choices`,children:e.options.map(r=>(0,J.jsx)(mj,{name:e.name,value:r.value,label:r.label,...r.caption===void 0?{}:{caption:r.caption},icon:r.icon,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))}):(0,J.jsx)(gj,{children:e.options.map(r=>(0,J.jsx)(hj,{name:e.name,value:r.value,label:r.label,icon:r.icon,hint:r.description,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))})})}let s=e.options.some(e=>e.description!==void 0||e.meta!==void 0);return(0,J.jsx)(wy,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:(0,J.jsx)(yj,{name:e.name,"aria-label":o,value:jj(t),onValueChange:e=>{t.handleChange(e),t.handleBlur()},orientation:e.kind===`icon-radio`||s?`horizontal`:`vertical`,children:e.options.map(t=>e.kind===`icon-radio`?(0,J.jsx)(Sj,{value:t.value,label:t.label,...t.caption===void 0?{}:{caption:t.caption},icon:t.icon,disabled:t.disabled},t.value):s?(0,J.jsx)(xj,{value:t.value,title:t.label,description:t.description,meta:t.meta,disabled:t.disabled},t.value):(0,J.jsx)(Ey,{label:t.label,orientation:`inline`,children:(0,J.jsx)(bj,{value:t.value,disabled:t.disabled})},t.value))})})}function Uj({spec:e,field:t,locked:n,error:r,render:i,...a}){return i({name:e.name,label:e.label,help:e.help,value:Ij(t),onChange:e=>{t.handleChange(e)},onBlur:t.handleBlur,error:r,disabled:n,id:a.id??e.name,"aria-describedby":a[`aria-describedby`],"aria-invalid":r!==void 0})}function Wj({form:e,spec:t,locked:n,layout:r}){let i=iy({form:e,name:t.name}),a=ny(e.store,e=>e.submissionAttempts>0),o=i.state.meta.isBlurred||a?IA(i.state.meta):void 0;if(t.render===void 0&&Vj.has(t.kind))return(0,J.jsx)(Hj,{spec:t,field:i,locked:n,error:o,layout:r});let s=r===`columns`?t.kind===`switch`||t.kind===`checkbox`?`horizontal`:`vertical`:t.kind===`checkbox`?`inline`:(t.layout??(t.kind===`switch`?`row`:`stacked`))===`row`?`horizontal`:`vertical`;return(0,J.jsx)(Ey,{label:t.label,...r===`columns`?{labelTitle:t.label}:{},description:t.help,icon:t.icon,orientation:s,error:o,...t.required===void 0?{}:{required:t.required},...t.optional===void 0?{}:{optional:t.optional},children:t.render===void 0?(0,J.jsx)(Bj,{spec:t,field:i,locked:n}):(0,J.jsx)(Uj,{spec:t,field:i,locked:n,error:o,render:t.render})})}var Gj=w(Ee(b,kj));function Kj({form:e,spec:t,locked:n,layout:r}){let i=t.when;return ny(e.store,e=>i===void 0||i(ht(Gj(e.values),()=>({}))))?(0,J.jsx)(Wj,{form:e,spec:t,locked:n,layout:r}):null}function qj({form:e,section:t,locked:n,layout:r}){let i=t.fields.map(t=>(0,J.jsx)(Kj,{form:e,spec:t,locked:n,layout:r},t.name));return t.title===void 0?i:(0,J.jsx)(Cy,{title:t.title,description:t.description,layout:r,children:i})}function Jj({model:e,names:t,disabled:n=!1,layout:r}){let i=e.form;return t===void 0?e.description.sections.map(e=>(0,J.jsx)(qj,{form:i,section:e,locked:n,layout:r},e.id??``)):t.map(t=>{let a=e.description.fields.find(e=>e.name===t);return a===void 0?null:(0,J.jsx)(Kj,{form:i,spec:a,locked:n,layout:r},t)})}var Yj=class{annotation;constructor(e){this.annotation=e}},Xj=class{sections;constructor(e){this.sections=e}},Zj=`caps/form`,Qj=0;function $j(e){Qj+=1;let t={[`${Zj}:${String(Qj)}`]:new Yj(e)};return e.label!==void 0&&(t.title=e.label),e.help!==void 0&&(t.description=e.help),t}b.annotate($j({kind:`secret`})).pipe(ae(`Secret`));var eM=e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)};function tM(e){return Object.values(e??{}).reduce((e,t)=>t instanceof Yj?{...e,...t.annotation}:e,{})}function nM(e){return e.reduce((e,t)=>({...e,...tM(t)}),{})}function rM(e){let t=e?.[Zj];return t instanceof Xj?t.sections:{}}var iM=w(b);function aM(e){if(nn(e))return vn(iM(e.literal),{onNone:()=>null,onSome:e=>[e]});if(!$t(e))return null;let t=[];for(let n of e.types){if(Ht(n))continue;let e=aM(n);if(e===null)return null;t.push(...e)}return t}function oM(e){if(Xe(e))return{type:`string`,literals:[]};if(Zt(e))return{type:`number`,nullable:!1};if(lt(e))return{type:`boolean`};let t=aM(e);if(t!==null)return{type:`string`,literals:t};if(r(e)){let[t]=e.rest;if(t===void 0)return null;if(Xe(t))return{type:`strings`,literals:[]};let n=aM(t);return n===null?null:{type:`strings`,literals:n}}if($t(e)){let t=e.types.filter(e=>!Ht(e)&&!Bt(e)),n=e.types.some(e=>Bt(e)),[r]=t;if(t.length!==1||r===void 0)return null;let i=oM(r);return i?.type===`number`?{type:`number`,nullable:n}:n?null:i}return null}function sM(e){let t=e.ast;if(!Ct(t))throw Error(`A schema form needs a Schema.Struct.`);return{fields:t.propertySignatures.map(e=>{let t=String(e.name),n=st(e.type),r=nM([e.type.annotations,...(e.type.checks??[]).map(e=>e.annotations)]),i=r.kind===`file`?{type:`files`}:oM(n);if(i===null)throw Error(`Schema field "${t}" has no form control. Annotate it with field({ render }) or a kind.`);return{name:t,valueType:i,optional:e.type.context?.isOptional===!0,annotation:r,title:sn(e.type),description:Nt(e.type)}}),sections:rM(rt(t))}}function cM(e){let t=e,n=!1,r=!1;for(;;)if(t instanceof R)n=!0,t=t.unwrap();else if(t instanceof me)r=!0,t=t.unwrap();else if(t instanceof Dt)t=t.unwrap();else if(t instanceof be)t=t.in;else return{node:t,optional:n,nullable:r}}function lM(e){if(e instanceof Me){let t=e.options.map(e=>lM(e));return t.some(e=>e===null)?null:t.flatMap(e=>e??[])}let t=e instanceof oe?e.options:e instanceof le?[...e.values]:null;if(t===null)return null;let n=t.map(e=>iM(e));return n.every(xn)?n.map(e=>e.value):null}function uM(e){let{node:t,nullable:n}=cM(e);if(t instanceof Tn)return{type:`string`,literals:[]};if(t instanceof T)return{type:`number`,nullable:n};if(t instanceof s)return{type:`boolean`};let r=lM(t);if(r!==null)return{type:`string`,literals:r};if(t instanceof At){let e=cM(t.element).node;if(e instanceof Tn)return{type:`strings`,literals:[]};let n=lM(e);return n===null?null:{type:`strings`,literals:n}}return null}function dM(e){let t=[e];for(;;){let e=t[t.length-1];if(e===void 0)break;let n=e instanceof R||e instanceof me||e instanceof Dt?e.unwrap():e instanceof be?e.in:e;if(n===e)break;t.push(n)}return t.reverse().map(e=>Ye.get(e))}function fM(e){return dM(e).reduce((e,t)=>({...e,...t}),{})}function pM(e){return Object.entries(e.shape)}function mM(e){let t=cM(e).node;if(!(t instanceof N))throw Error(`A schema form needs a z.object.`);return{fields:pM(t).map(([e,t])=>{let n=nM(dM(t)),r=n.kind===`file`?{type:`files`}:uM(t);if(r===null)throw Error(`Schema field "${e}" has no form control. Annotate it with field({ render }) or a kind.`);let i=fM(t);return{name:e,valueType:r,optional:cM(t).optional,annotation:n,title:i.title,description:i.description}}),sections:rM(fM(e))}}function hM(e,t){let n=t.options??{};return(e.length>0?e:Object.keys(n)).map(e=>{let t=n[e],r=t===void 0?{}:t instanceof Object?t:{label:t};return{value:e,label:r.label??eM(e),description:r.description,meta:r.meta,icon:r.icon,caption:r.caption,disabled:r.disabled===!0}})}function gM(e,t){let n=t.some(e=>e.icon!==void 0);switch(e.type){case`boolean`:return`switch`;case`number`:return`number`;case`strings`:return n?`icon-checkboxes`:`checkboxes`;case`files`:return`file`;case`string`:return t.length===0?`text`:t.length>12?`combobox`:n?`icon-radio`:t.some(e=>e.description!==void 0||e.meta!==void 0)||t.length<=3?`radio`:`select`}}function _M(e,t){switch(e.type){case`boolean`:return!1;case`number`:return e.nullable?null:0;case`strings`:case`files`:return[];case`string`:return t[0]?.value??``}}function vM(e){let t=e instanceof d?mM(e):sM(e),n=t.fields.map((e,t)=>{let{kind:n,...r}=e.annotation,i=hM(e.valueType.type===`string`||e.valueType.type===`strings`?e.valueType.literals:[],e.annotation),a=r.help??e.description;return{...r,name:e.name,label:r.label??e.title??eM(e.name),help:a,kind:n??gM(e.valueType,i),options:i,optionalInSchema:e.optional,index:t}}),r={};t.fields.forEach((e,t)=>{let i=n[t];i&&(r[e.name]=_M(e.valueType,i.options))});let i=e=>e.order??e.index,a=e=>e.section!==void 0&&Object.hasOwn(t.sections,e.section)?e.section:null,o=e=>n.filter(t=>a(t)===e).sort((e,t)=>i(e)-i(t)),s=Object.entries(t.sections).map(([e,t])=>({id:e,title:t.title,description:t.description,fields:o(e)}));return{fields:n,sections:[{id:null,title:void 0,description:void 0,fields:o(null)},...s].filter(e=>e.fields.length>0),defaults:r}}function yM(e){let t=e instanceof d?e:ge(e);return{"~standard":{...t[`~standard`],validate:e=>{let n=t[`~standard`].validate(e);return n instanceof Promise?n.then(e=>bM(e)):bM(n)}}}}function bM(e){return e.issues===void 0?e:{issues:e.issues.map(e=>e.path===void 0?e:{...e,path:e.path.slice(0,1)})}}var xM=`onServer`;function SM(e){let t=e.querySelector(`[aria-invalid="true"]`),n=t?.matches(`input, select, textarea, button, [tabindex]`)?t:t?.querySelector(`input, select, textarea, button`);return n?.focus(),n!=null}function CM(e){if(SM(e))return()=>void 0;let t=new MutationObserver(()=>{SM(e)&&t.disconnect()});return t.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`aria-invalid`]}),()=>{t.disconnect()}}function wM(e){return e.state.meta.errorMap.onServer!==void 0}function TM(e){e.setMeta(e=>({...e,errorMap:{...e.errorMap,[xM]:void 0}}))}function EM(e,t,n){e.setFieldMeta(t,e=>({...e,isBlurred:!0,errorMap:{...e.errorMap,[xM]:n}}))}function DM(e){let[t,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(e.defaultValues),[s,c]=(0,q.useState)(null);xv(a,e.defaultValues)||(o(e.defaultValues),c(null));let{schema:l}=e,u=(0,q.useMemo)(()=>vM(l),[l]),d=(0,q.useMemo)(()=>yM(l),[l]),f=fy({defaultValues:s??a,validators:{onChange:d,onSubmit:d},listeners:{onChange:({fieldApi:e})=>{n(null),i(null),wM(e)&&TM(e)}},onSubmit:async({value:t,formApi:r})=>{n(null),i(null);let a=await yM(l)[`~standard`].validate(t);if(a.issues){n(a.issues[0]?.message??`Check the form and try again.`);return}let o;try{o=await e.onSubmit(a.value,t)??{kind:`saved`}}catch(t){console.error(`SchemaForm submit failed`,t),n(e.failure??`Couldn't save changes. Try again.`);return}if(o.kind===`refused`){n(o.error??null);let e=r;for(let[t,n]of Object.entries(o.fields??{}))n!==void 0&&n.length>0&&EM(e,t,n);return}let s=o.values??t;c(s),r.reset(s),i(o.message??`Saved`),e.onSaved?.(s)}});return{description:u,form:f,error:t,saved:r,discard:()=>{n(null),i(null),f.reset()},submit:()=>f.handleSubmit()}}function OM(e){return{dirty:ny(e.form.store,e=>!e.isDefaultValue),submitting:ny(e.form.store,e=>e.isSubmitting),canSubmit:ny(e.form.store,e=>e.canSubmit)}}function kM({model:e,submitLabel:t=`Save changes`,discardLabel:n,onCancel:r,cancelLabel:i,allowClean:a,layout:o,footer:s,children:c,disabled:l=!1,...u}){let{submitting:d}=OM(e),f=(0,q.useRef)(null),p=(0,q.useRef)(()=>void 0);return(0,q.useEffect)(()=>()=>{p.current()},[]),(0,J.jsxs)(xy,{...u,ref:f,layout:o,busy:d,noValidate:!0,onSubmit:t=>{t.preventDefault(),e.form.state.isSubmitting||e.submit().then(()=>{p.current();let t=f.current;t!==null&&!e.form.state.isValid&&(p.current=CM(t))})},children:[c??(0,J.jsx)(Jj,{model:e,disabled:l,layout:o}),s===void 0?(0,J.jsx)(MM,{model:e,label:t,discardLabel:r===void 0?n:void 0,onCancel:r,cancelLabel:i,allowClean:a??r!==void 0,divider:r===void 0}):s]})}function AM({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i,...a}){let o=DM({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i});return(0,J.jsx)(kM,{...a,model:o})}function jM(e){return`model`in e?(0,J.jsx)(kM,{...e}):(0,J.jsx)(AM,{...e})}function MM({model:e,label:t,discardLabel:n,onCancel:r,cancelLabel:i=`Cancel`,allowClean:a=!1,dirtyLabel:o=`Unsaved changes`,buttonProps:s,...c}){let{dirty:l,submitting:u}=OM(e),d=u?null:e.saved&&!l?(0,J.jsx)(bi,{tone:`success`,size:`compact`,label:e.saved}):l?(0,J.jsx)(bi,{tone:`neutral`,size:`compact`,label:o}):null;return(0,J.jsxs)(by,{...c,error:e.error,status:d,children:[r?(0,J.jsx)(U,{type:`button`,variant:`ghost`,disabled:u,onClick:r,children:i}):n&&l?(0,J.jsx)(U,{type:`button`,variant:`ghost`,disabled:u,onClick:e.discard,children:n}):null,(0,J.jsx)(U,{...s,type:`submit`,loading:u,disabled:u||!l&&!a,title:!l&&!a?`No changes to save`:void 0,children:t})]})}var NM={error:0,warning:1,info:2};function PM(e,t){let n=t.generating+t.uploading>0;if(n)return{busy:n,tone:void 0,label:[t.generating?`Creating ${String(t.generating)}`:``,t.uploading?`Uploading ${String(t.uploading)}`:``].filter(Boolean).join(` · `)};let r=[...e].sort((e,t)=>Number(t.blocking??!1)-Number(e.blocking??!1)||NM[e.tone]-NM[t.tone]).at(0);return r?{busy:n,tone:r.tone===`info`?`neutral`:r.tone,label:r.short+(e.length>1?` +${String(e.length-1)}`:``)}:null}function FM(e,t,n){let r=PM(e,t);if(!r)return null;let i={kind:`button`,id:`activity`,text:`Activity`,count:e.length+t.generating+t.uploading,busy:r.busy,title:v(`Activity: ${r.label}`,1024),opens:`dialog`,expanded:n};return r.tone===void 0?i:{...i,tone:r.tone}}var IM={Setup:(0,J.jsx)(Ih,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),Images:(0,J.jsx)(Eh,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),Uploads:(0,J.jsx)(Lh,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`})};function LM({notices:e,uploads:t,open:n,inset:r,onOpenChange:i,onDismiss:a,onDismissAll:o,onLoadMore:s}){return(0,J.jsx)(zr,{className:`prints-activity-tray`,placement:`host`,align:`start`,...r===void 0?{}:{hostInset:r},items:[{id:`activity`,label:`Activity`,title:`Activity`,content:(0,J.jsx)(RM,{notices:e,uploads:t,onDismiss:a,onDismissAll:o,onLoadMore:s})}],openId:n?`activity`:null,onOpenChange:e=>{i(e===`activity`)}})}function RM({notices:e,uploads:t,onDismiss:n,onDismissAll:r,onLoadMore:i}){let a=[`Setup`,`Images`,`Uploads`].map(t=>({group:t,items:e.filter(e=>e.group===t)})).filter(e=>e.items.length);return(0,J.jsxs)(`div`,{className:`prints-instrument`,children:[a.map(({group:e,items:t})=>(0,J.jsxs)(`section`,{"aria-label":e,className:`prints-notice-group`,children:[(0,J.jsx)(Nr,{level:3,children:e}),(0,J.jsx)(Hi,{children:t.map(e=>(0,J.jsx)(Nn,{icon:IM[e.group],primary:(0,J.jsxs)(`span`,{className:`prints-notice-copy`,children:[(0,J.jsx)(`span`,{children:e.title}),e.detail?(0,J.jsx)(`span`,{className:`prints-notice-detail`,children:e.detail}):null]}),actions:(0,J.jsxs)(`div`,{className:`prints-notice-actions`,"aria-label":`Actions for ${e.title}`,children:[e.actions?.map((e,t)=>(0,J.jsx)(U,{variant:t===0?`outline`:`ghost`,size:t===0?`sm`:`xs`,onClick:e.run,children:e.label},e.label)),e.blocking?null:(0,J.jsx)(pt,{"aria-label":`Dismiss ${e.title}`,icon:(0,J.jsx)(Ei,{"aria-hidden":`true`}),onClick:()=>{n(e.key)}})]})},e.key))})]},e)),e.length?null:(0,J.jsx)(hr,{children:`All caught up.`}),t&&t.items.length>0?(0,J.jsxs)(`section`,{"aria-label":`Upload queue`,className:`prints-upload-bank`,children:[(0,J.jsx)(Nr,{level:3,children:`Uploading`}),(0,J.jsx)(zA,{...t})]}):null,(0,J.jsxs)(`div`,{className:`prints-panel-footer`,children:[(0,J.jsx)(`span`,{className:`prints-footer-note`,children:`Clear dismisses finished items`}),(0,J.jsx)(U,{variant:`ghost`,size:`xs`,disabled:!e.some(e=>!e.blocking),onClick:r,children:`Clear`}),i?(0,J.jsx)(U,{variant:`ghost`,size:`xs`,onClick:i,children:`Load more activity`}):null]})]})}function zM({folder:e}){return(0,J.jsx)(cm,{open:e.editing,onOpenChange:e.setEditing,children:(0,J.jsxs)(pm,{children:[(0,J.jsx)(hm,{children:(0,J.jsx)(gm,{children:`Save prints to`})}),(0,J.jsx)(VM,{folder:e},e.computerId),(0,J.jsx)(mm,{children:(0,J.jsx)(_m,{render:(0,J.jsx)(U,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var BM=g({path:ue.check(F(u($n),{message:`Enter an absolute Computer folder, such as /media.`})).annotate($j({label:`Folder`,placeholder:`/media`}))});function VM({folder:e}){let t=(0,q.useRef)(!1),n=DM({schema:BM,defaultValues:{path:e.path??`/media`},onSubmit:async({path:n})=>{let r=await e.choose(n,t.current);return r?{kind:`refused`,fields:{path:r}}:{kind:`saved`}}}),r=e=>{t.current=e,n.form.setFieldMeta(`path`,e=>({...e,errorMap:{...e.errorMap,onServer:void 0}}))},i=e.busy||!e.writable;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(jM,{model:n,disabled:i,footer:(0,J.jsxs)(by,{divider:!1,children:[(0,J.jsx)(_t,{className:`[--caps-keycap-width:auto]`,label:`Use`,type:`submit`,disabled:i,onClick:()=>{r(!1)}}),(0,J.jsx)(_t,{className:`[--caps-keycap-width:auto]`,label:`Create`,type:`submit`,disabled:i,onClick:()=>{r(!0)}})]})}),e.error?(0,J.jsx)(Nn,{role:`alert`,icon:(0,J.jsx)(Th,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),primary:e.error}):(0,J.jsx)(hr,{children:e.writable?`Prints saves new images and uploads here and shows this folder as your gallery.`:`This Computer is read-only for Prints, so the folder can’t change.`})]})}var HM={image:`Image`,video:`Video`,audio:`Audio`,media:`Media`};function UM({connected:e,mediaCapability:t,modelsError:n,retryModels:r,modelsLoading:i,models:a,canGenerate:o,mediaSetupMissing:s,canWrite:c,generationErrors:l,recoveryError:u,pendingGenerations:d,activeGenerations:f,atGenerationLimit:p,gallerySlots:m,computerId:h,failed:g,uploadError:_,uploads:v,permissions:y,resume:b,discard:x,retryUpload:S}){let C=[];if(e)h===null?C.push({key:`no-computer`,group:`Setup`,tone:`info`,blocking:!0,short:`Choose a Computer`,title:`No Computer selected`,detail:`Choose a Computer for this window, or create one in Grove.`}):t?n===null?!i&&!o&&!s&&C.push({key:`approval`,group:`Setup`,tone:`warning`,blocking:!0,short:`Generation not enabled`,title:`Media generation isn’t enabled`,detail:`Turn it on in this App’s Team permissions. Images already generated can still be saved.`,actions:[{label:`Permissions`,run:()=>{y()}}]}):C.push({key:`models:${n}`,group:`Setup`,tone:`warning`,blocking:!0,short:`Models unavailable`,title:`Couldn’t load image models`,detail:n,actions:[{label:`Retry`,run:r}]}):C.push({key:`no-media`,group:`Setup`,tone:`info`,blocking:!0,short:`Image creation off`,title:`Image creation is off for this Computer`,detail:`You can still browse and upload images.`});else{let e=It(new G(`Prints disconnected`,{code:`DISCONNECTED`,retryable:!0}));C.push({key:`disconnected`,group:`Setup`,tone:`warning`,blocking:!0,short:e.title,title:e.title,detail:e.message})}e&&h!==null&&!c&&C.push({key:`read-only`,group:`Setup`,tone:`info`,blocking:!0,short:`Read-only`,title:`Read-only Computer`,detail:`Uploads and new prints are off.`});for(let e of l){let t=`${HM[e.mediaKind??`media`]} failed`;C.push({key:e.key,group:`Images`,tone:`error`,short:t,title:`${t}: ${e.message}`,detail:e.prompt,blocking:e.dismiss!==void 0,actions:[...e.billing?[{label:`Open Billing`,run:e.billing}]:e.retry?[{label:`Retry`,run:e.retry}]:[],...e.dismiss?[{label:`Dismiss`,run:e.dismiss}]:[]]})}p&&C.push({key:`generation-limit`,group:`Images`,tone:`info`,short:`At the limit`,title:`At the limit`,detail:wr,blocking:!0}),u!==null&&C.push({key:`recovery:${u}`,group:`Images`,tone:`error`,short:`Retry blocked`,title:u});for(let e of d){if(f.has(e.reference.requestId)||m.some(t=>t.computerId===e.reference.computerId&&t.path===e.input.destination.path))continue;let t=`${HM[Vn(a,e.input.settings.model)?.kind??`media`]} failed`;C.push({key:`unfinished:${e.reference.requestId}`,group:`Images`,tone:`error`,blocking:!0,short:t,title:`${t}: ${e.failure?.message??`Stopped when Prints closed. Retry to run it again.`}`,detail:e.reference.computerId===h?e.typed.prompt:`${e.typed.prompt} · select the original Computer to retry`,actions:[...e.reference.computerId===h?[{label:`Retry`,run:()=>{b(e)}}]:[],{label:`Dismiss`,run:()=>{x(e)}}]})}g.length>0&&C.push({key:`files:${g.join(`|`)}`,group:`Images`,tone:`error`,short:`Couldn’t open images`,title:`Couldn’t open some images`,detail:g.join(`, `)}),_!==null&&C.push({key:`uploads:${_}`,group:`Uploads`,tone:`error`,short:`Upload failed`,title:`Couldn’t add images`,detail:_});for(let e of v)(e.status===`error`||e.status===`cancelled`)&&C.push({key:`upload:${e.id}:${e.status}`,group:`Uploads`,tone:e.status===`error`?`error`:`info`,short:`Upload failed`,title:`${e.file.name} wasn’t saved`,detail:e.message,actions:[{label:`Retry`,run:()=>{S(e.id)}}]});return C}function WM(e,t){let n=Li(ci(e)),r=se($r({queryKey:oi.dismissals(e),mutationFn:({owner:e,id:t,keys:n})=>jr(e.capabilities,{operation:`dismiss-notices`,computerId:t,keys:n}),apply:(e,t)=>({keys:[...new Set([...e.keys,...t.keys])].slice(-200)})})),i=n=>{e&&t&&n.length>0&&r.mutate({owner:e,id:t,keys:n})};return{error:r.variables?.owner===e&&r.variables.id===t&&r.isError?`Could not dismiss activity. Please try again.`:n.isError?`Could not load dismissed activity. Notices may reappear.`:null,visible:e=>e.filter(e=>(e.blocking??!1)||!n.data?.keys.includes(e.key)),dismiss:e=>{i([e])},dismissAll:e=>{i(e.filter(e=>!e.blocking).map(e=>e.key).slice(-200))}}}var GM=0,KM=1,qM=2,JM=0,YM=1;function XM(e,t,n){let r=e.list,i;for(;r;){if(r.index===n)return!1;if(t>r.high)break;i=r,r=r.next}return i||(e.list={index:n,high:t,next:r}),i&&(i.next={index:n,high:t,next:i.next}),!0}function ZM(e,t){let n=e.list;if(n.index===t)return n.next===null?JM:(e.list=n.next,YM);let r=n;for(n=n.next;n!==null;){if(n.index===t)return r.next=n.next,YM;r=n,n=n.next}}var QM={low:0,max:0,high:0,C:qM,P:void 0,R:void 0,L:void 0,list:void 0};QM.P=QM,QM.L=QM,QM.R=QM;function $M(e){let t=e.high;e.max=e.L===QM&&e.R===QM?t:e.L===QM?Math.max(e.R.max,t):e.R===QM?Math.max(e.L.max,t):Math.max(Math.max(e.L.max,e.R.max),t)}function eN(e){let t=e;for(;t.P!==QM;)$M(t.P),t=t.P}function tN(e,t){if(t.R===QM)return;let n=t.R;t.R=n.L,n.L!==QM&&(n.L.P=t),n.P=t.P,t.P===QM?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.L=t,t.P=n,$M(t),$M(n)}function nN(e,t){if(t.L===QM)return;let n=t.L;t.L=n.R,n.R!==QM&&(n.R.P=t),n.P=t.P,t.P===QM?e.root=n:t===t.P.R?t.P.R=n:t.P.L=n,n.R=t,t.P=n,$M(t),$M(n)}function rN(e,t,n){t.P===QM?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.P=t.P}function iN(e,t){let n;for(;t!==QM&&t.C===KM;)t===t.P.L?(n=t.P.R,n.C===GM&&(n.C=KM,t.P.C=GM,tN(e,t.P),n=t.P.R),n.L.C===KM&&n.R.C===KM?(n.C=GM,t=t.P):(n.R.C===KM&&(n.L.C=KM,n.C=GM,nN(e,n),n=t.P.R),n.C=t.P.C,t.P.C=KM,n.R.C=KM,tN(e,t.P),t=e.root)):(n=t.P.L,n.C===GM&&(n.C=KM,t.P.C=GM,nN(e,t.P),n=t.P.L),n.R.C===KM&&n.L.C===KM?(n.C=GM,t=t.P):(n.L.C===KM&&(n.R.C=KM,n.C=GM,tN(e,n),n=t.P.L),n.C=t.P.C,t.P.C=KM,n.L.C=KM,nN(e,t.P),t=e.root));t.C=KM}function aN(e){for(;e.L!==QM;)e=e.L;return e}function oN(e,t){let n;for(;t.P.C===GM;)t.P===t.P.P.L?(n=t.P.P.R,n.C===GM?(t.P.C=KM,n.C=KM,t.P.P.C=GM,t=t.P.P):(t===t.P.R&&(t=t.P,tN(e,t)),t.P.C=KM,t.P.P.C=GM,nN(e,t.P.P))):(n=t.P.P.L,n.C===GM?(t.P.C=KM,n.C=KM,t.P.P.C=GM,t=t.P.P):(t===t.P.L&&(t=t.P,nN(e,t)),t.P.C=KM,t.P.P.C=GM,tN(e,t.P.P)));e.root.C=KM}function sN(){let e={root:QM,size:0},t={};return{insert(n,r,i){let a=e.root,o=QM;for(;a!==QM&&(o=a,n!==o.low);)a=n<a.low?a.L:a.R;if(n===o.low&&o!==QM){if(!XM(o,r,i))return;o.high=Math.max(o.high,r),$M(o),eN(o),t[i]=o,e.size++;return}let s={low:n,high:r,max:r,C:GM,P:o,L:QM,R:QM,list:{index:i,high:r,next:null}};o===QM?e.root=s:(s.low<o.low?o.L=s:o.R=s,eN(s)),oN(e,s),t[i]=s,e.size++},remove(n){let r=t[n];if(r===void 0)return;delete t[n];let i=ZM(r,n);if(i===void 0)return;if(i===YM){r.high=r.list.high,$M(r),eN(r),e.size--;return}let a=r,o=a.C,s;r.L===QM?(s=r.R,rN(e,r,r.R)):r.R===QM?(s=r.L,rN(e,r,r.L)):(a=aN(r.R),o=a.C,s=a.R,a.P===r?s.P=a:(rN(e,a,a.R),a.R=r.R,a.R.P=a),rN(e,r,a),a.L=r.L,a.L.P=a,a.C=r.C),$M(s),eN(s),o===KM&&iN(e,s),e.size--},search(t,n,r){let i=[e.root];for(;i.length!==0;){let e=i.pop();if(!(e===QM||t>e.max)&&(e.L!==QM&&i.push(e.L),e.R!==QM&&i.push(e.R),e.low<=n&&e.high>=t)){let n=e.list;for(;n!==null;)n.high>=t&&r(n.index,e.low),n=n.next}}},get size(){return e.size}}}var cN=e=>{let t=q.useRef(e);return q.useEffect(()=>{t.current=e}),t},lN=(e,t)=>{let n=t||uN,r,i;return function(){return r&&n(arguments,r)?i:i=e.apply(null,r=arguments)}},uN=(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3],dN=class{constructor(){this.set=void 0,this.get=void 0;let e,t;this.get=n=>n===e?t:void 0,this.set=(n,r)=>{e=n,t=r}}},fN=e=>{try{return new e}catch{let e={};return{set(t,n){e[t]=n},get(t){return e[t]}}}},pN=e=>{let t=e.length,n=fN(e[0]),r,i,a,o,s=t===1;return t<3?{g:e=>(r=n.get(e[0]))===void 0||s?r:r.get(e[1]),s:(t,a)=>(s?n.set(t[0],a):(r=n.get(t[0]))===void 0?(i=fN(e[1]),i.set(t[1],a),n.set(t[0],i)):r.set(t[1],a),a)}:{g:e=>{for(o=n,a=0;a<t;a++)if((o=o.get(e[a]))===void 0)return;return o},s:(r,s)=>{for(o=n,a=0;a<t-1;a++)(i=o.get(r[a]))===void 0?(i=fN(e[a+1]),o.set(r[a],i),o=i):o=i;return o.set(r[t-1],s),s}}},mN=(e,t)=>{let n,{g:r,s:i}=pN(e);return function(){return(n=r(arguments))===void 0?i(arguments,t.apply(null,arguments)):n}},hN=new WeakMap;function gN(){let e=q.useState(_N)[1];return q.useRef(()=>e({})).current}var _N={},vN=q.createElement;function yN(e){let{positioner:t,resizeObserver:n,items:r,as:i=`div`,id:a,className:o,style:s,role:c=`grid`,tabIndex:l=0,containerRef:u,itemAs:d=`div`,itemStyle:f,itemHeightEstimate:p=300,itemKey:m=TN,overscanBy:h=2,scrollTop:g,isScrolling:_,height:v,render:y,onRender:b}=e,x=0,S,C=gN(),w=DN(t,n),T=r.length,{columnWidth:E,columnCount:D,range:O,estimateHeight:k,size:A,shortestColumn:j}=t,M=A(),N=j(),P=[],F=c===`list`?`listitem`:c===`grid`?`gridcell`:void 0,I=cN(b);h=v*h;let ee=g+h,te=N<ee&&M<T;if(O(Math.max(0,g-h/2),ee,(e,t,n)=>{let i=r[e],a=m(i,e),o={top:n,left:t,width:E,writingMode:`horizontal-tb`,position:`absolute`};P.push(vN(d,{key:a,ref:w(e),role:F,style:typeof f==`object`&&f?Object.assign({},o,f):o},xN(y,e,i,E))),S===void 0?(x=e,S=e):(x=Math.min(x,e),S=Math.max(S,e))}),te){let e=Math.min(T-M,Math.ceil((g+h-N)/p*D)),t=M,n=EN(E);for(;t<M+e;t++){let e=r[t],i=m(e,t);P.push(vN(d,{key:i,ref:w(t),role:F,style:typeof f==`object`?Object.assign({},n,f):n},xN(y,t,e,E)))}}q.useEffect(()=>{typeof I.current==`function`&&S!==void 0&&I.current(x,S,r),bN=`1`},[x,S,r,I]),q.useEffect(()=>{te&&C()},[te,t]);let ne=SN(_,k(T,p));return vN(i,{ref:u,key:bN,id:a,role:c,className:o,tabIndex:l,style:typeof s==`object`?wN(ne,s):ne,children:P})}var bN=`0`,xN=mN([dN,{},WeakMap,dN],(e,t,n,r)=>vN(e,{index:t,data:n,width:r})),SN=lN((e,t)=>({position:`relative`,width:`100%`,maxWidth:`100%`,height:Math.ceil(t),maxHeight:Math.ceil(t),willChange:e?`contents`:void 0,pointerEvents:e?`none`:void 0})),CN=(e,t)=>e[0]===t[0]&&e[1]===t[1],wN=lN((e,t)=>Object.assign({},e,t),CN);function TN(e,t){return t}var EN=lN(e=>({width:e,zIndex:-1e3,visibility:`hidden`,position:`absolute`,writingMode:`horizontal-tb`}),(e,t)=>e[0]===t[0]),DN=lN((e,t)=>n=>r=>{r!==null&&(t&&(t.observe(r),hN.set(r,n)),e.get(n)===void 0&&e.set(n,r.offsetHeight))},CN),ON=function(e,t,n,r){n===void 0&&(n=0),r===void 0&&(r=n);let i=sN(),a=Array(e),o=[],s=Array(e);for(let t=0;t<e;t++)a[t]=0,s[t]=[];return{columnCount:e,columnWidth:t,set:function(e,c){c===void 0&&(c=0);let l=0;for(let e=1;e<a.length;e++)a[e]<a[l]&&(l=e);let u=a[l]||0;a[l]=u+c+r,s[l].push(e),o[e]={left:l*(t+n),top:u,height:c,column:l},i.insert(u,u+c,e)},get:e=>o[e],update:t=>{let n=Array(e),c=0,l=0;for(;c<t.length-1;c++){let e=t[c],r=o[e];r.height=t[++c],i.remove(e),i.insert(r.top,r.top+r.height,e),n[r.column]=n[r.column]===void 0?e:Math.min(e,n[r.column])}for(c=0;c<n.length;c++){if(n[c]===void 0)continue;let e=s[c],t=kN(e,n[c]),u=s[c][t],d=o[u];for(a[c]=d.top+d.height+r,l=t+1;l<e.length;l++){let t=e[l],n=o[t];n.top=a[c],a[c]=n.top+n.height+r,i.remove(t),i.insert(n.top,n.top+n.height,t)}}},range:(e,t,n)=>i.search(e,t,(e,t)=>n(e,o[e].left,t)),estimateHeight:(t,n)=>{let r=Math.max(0,Math.max.apply(null,a));return t===i.size?r:r+Math.ceil((t-i.size)/e)*n},shortestColumn:()=>a.length>1?Math.min.apply(null,a):a[0]||0,size(){return i.size},all(){return o}}},kN=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=n+r>>>1,a=e[i];if(a===t)return i;a<=t?n=i+1:r=i-1}return-1},AN=(0,q.createContext)(null);function jN(){let e=(0,q.useContext)(AN);if(e===null)throw Error(`An audio tile part must sit inside an AudioTileScope`);return e}function MN({url:e,children:t}){let n=c_(e,at);return(0,J.jsx)(AN.Provider,{value:n,children:t})}function NN({url:e}){let{progress:t}=jN();return(0,J.jsx)(`span`,{className:`prints-audio-tile`,children:(0,J.jsx)(l_,{progress:t,url:e})})}function PN({title:e}){let t=jN();return(0,J.jsx)(pt,{"aria-label":`${t.playing?`Pause`:`Play`} ${e}`,className:`prints-audio-tile-play`,icon:t.playing?(0,J.jsx)(Mh,{}):(0,J.jsx)(Ph,{}),iconSize:`sm`,size:`sm`,variant:`accent`,onClick:t.toggle})}var FN=8,IN=320,LN=4,RN=640,zN=656;function BN(e,t){return e<=0||!Number.isFinite(t)||t<=0?0:e===1?1:e<=LN?t<RN?1:e===2||t<zN?2:3:t>=1280?4:t>=zN?3:2}function VN({item:e}){return an(e.path)?(0,J.jsx)(NN,{url:e.url}):lo(e.path)?(0,J.jsx)(`video`,{"aria-label":e.path,className:`block h-full w-full object-cover`,"data-media-thumb":!0,loop:!0,muted:!0,playsInline:!0,src:e.url}):(0,J.jsx)(`img`,{alt:e.path,className:`block h-full w-full object-cover`,"data-media-thumb":!0,src:e.url})}var HN=(0,q.memo)(function({item:e}){let t=(0,q.useRef)(null);(0,q.useEffect)(()=>{e.onVisible?.()},[e.onVisible]);let[n,r]=(0,q.useState)(e.pending===!0&&!e.onVisible);return e.pending&&!e.onVisible&&!n&&r(!0),(0,q.useLayoutEffect)(()=>{let r=t.current;if(!r||e.pending||n)return;let i=window.matchMedia(`(prefers-reduced-motion: reduce)`);if(i.matches)return;let a=!0,o,s,c=()=>o?.();return Rr(async()=>{let{animate:e,spring:t}=await import(`./modules-C4mfDnjH.js`).then(e=>e.t);return{animate:e,spring:t}},__vite__mapDeps([3,1]),import.meta.url).then(({animate:e,spring:t})=>{if(!a)return;let n=e(r,{opacity:{from:0,to:1,duration:160,ease:`outQuad`},translateY:{from:6,to:0,ease:t({bounce:.16,duration:320})},scale:{from:.985,to:1,ease:t({bounce:.16,duration:320})}});o=()=>{n.complete()},s=()=>{n.revert()}}),i.addEventListener(`change`,c),()=>{a=!1,i.removeEventListener(`change`,c),s?.()}},[e.key,e.pending,n]),(0,J.jsxs)(`div`,{ref:t,className:`prints-gallery-tile`,"data-referenced":e.referenced?!0:void 0,children:[e.error?(0,J.jsx)(`div`,{className:`block h-full w-full overflow-hidden bg-base-200`,"data-media-failed":!0,title:e.path,children:(0,J.jsx)(bm,{status:`failed`,failure:(0,J.jsxs)(`div`,{className:`flex max-w-full flex-col items-center gap-xs`,children:[e.prompt?(0,J.jsx)(`p`,{className:`m-0 max-w-full truncate px-md text-xs text-(--stipe-fg-muted)`,children:e.prompt}):null,(0,J.jsx)(vm,{density:`tile`,message:e.error,onRetry:e.onRetry,onDismiss:e.onDismiss})]})})}):(0,J.jsx)(`button`,{className:`block h-full w-full overflow-hidden bg-base-200 p-0 text-left`,"data-media-thumb-wrap":!0,type:`button`,disabled:e.pending,"aria-pressed":e.select?.active?e.select.checked:void 0,onClick:()=>{e.select?.active?e.select.onToggle():e.onOpen(e.path)},onKeyDown:t=>{t.key.toLowerCase()===`i`&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&e.onInfo&&(t.preventDefault(),e.onInfo())},title:e.path,children:(0,J.jsx)(`div`,{className:`caps-item block! h-full w-full overflow-hidden rounded-none! border-0! bg-transparent! shadow-none! z-auto! -outline-offset-2!`,"data-selected":e.selected??!1,children:e.pending||n?(0,J.jsx)(bm,{"data-media-pending":e.pending?`true`:void 0,indicator:(0,J.jsx)(`div`,{className:`prints-pending-loader`,"data-run":e.pending&&(e.prompt||e.onStop)?``:void 0,children:(0,J.jsx)(ln,{decorative:!0,size:`fill`,tone:`accent`,variant:`bloom`})}),label:e.pendingLabel??`Preparing image…`,status:e.pending?`generating`:`done`,children:e.pending?null:(0,J.jsx)(VN,{item:e})}):(0,J.jsx)(VN,{item:e})})}),e.pending&&!e.error&&(e.prompt||e.onStop)?(0,J.jsxs)(`div`,{className:`prints-tile-run`,"data-media-run":!0,children:[e.prompt?(0,J.jsx)(`p`,{className:`prints-tile-caption`,"data-media-caption":!0,children:e.prompt}):null,e.onStop?(0,J.jsx)(pt,{"aria-label":`Stop`,title:`Stop`,size:`sm`,variant:`outline`,iconSize:`sm`,className:`prints-tile-stop`,onClick:e.onStop,icon:(0,J.jsx)(Zn,{fill:`currentColor`})}):null]}):null,!e.pending&&!e.error?(0,J.jsx)(GN,{item:e}):null,(0,J.jsxs)(`div`,{className:`prints-gallery-tools`,children:[!e.pending&&!e.error?(0,J.jsx)(KN,{item:e}):null,!e.pending&&e.onInfo?(0,J.jsx)(pt,{className:`prints-gallery-secondary`,"aria-label":`Image info: ${e.path}`,title:`Image info (I)`,"aria-keyshortcuts":`I`,onClick:e.onInfo,icon:(0,J.jsx)(Oh,{})}):null,!e.pending&&e.onToggleReference?(0,J.jsx)(pt,{className:`prints-gallery-reference prints-gallery-secondary`,"aria-label":`${e.referenced?`Remove reference`:`Add reference`}: ${e.path}`,title:e.referenced?`Remove reference`:`Add reference`,"aria-pressed":e.referenced??!1,disabled:e.referenceDisabled,onClick:e.onToggleReference,icon:e.referenced?(0,J.jsx)(Lr,{}):(0,J.jsx)(Eh,{})}):null]})]})}),UN=(0,q.memo)(function({item:e}){return an(e.path)?(0,J.jsx)(MN,{url:e.url,children:(0,J.jsx)(HN,{item:e})}):(0,J.jsx)(HN,{item:e})}),WN=e=>`${String(e)}s`;function GN({item:e}){let{select:t}=e;return(0,J.jsxs)(J.Fragment,{children:[an(e.path)&&e.url!==``?(0,J.jsx)(PN,{title:e.path}):null,(0,J.jsx)(`div`,{className:`prints-tile-mark`,"data-checked":t?.active?t.checked:void 0,"data-favorite":e.favorite?!0:void 0,children:t?.active?(0,J.jsx)(TA,{appearance:`compact`,"aria-label":`Select ${e.path}`,checked:t.checked,onChange:t.onToggle}):e.onToggleFavorite?(0,J.jsx)(pt,{"aria-label":`${e.favorite?`Unfavorite`:`Favorite`}: ${e.path}`,"aria-pressed":e.favorite??!1,className:`prints-tile-heart`,icon:(0,J.jsx)(fr,{fill:e.favorite?`currentColor`:`none`}),onClick:e.onToggleFavorite,title:e.favorite?`Remove from favorites`:`Favorite`}):null}),e.badge?(0,J.jsx)(`div`,{className:`prints-tile-badge`,"data-media-badge":!0,children:e.badge.label===null?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Lh,{"aria-hidden":!0,size:12}),(0,J.jsx)(`span`,{children:`Upload`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`prints-tile-badge-model`,children:e.badge.label}),e.badge.seconds===null?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(_i,{"aria-hidden":!0,size:12}),(0,J.jsx)(`span`,{children:WN(e.badge.seconds)})]})]})}):null,e.folderCaption?(0,J.jsx)(`div`,{className:`prints-tile-folder`,title:e.folderCaption,children:e.folderCaption}):null]})}function KN({item:e}){return!e.onMove||e.select?.active?null:(0,J.jsxs)(Co,{children:[(0,J.jsx)(Ia,{render:(0,J.jsx)(pt,{"aria-label":`More actions: ${e.path}`,title:`More actions`,icon:(0,J.jsx)(ao,{})})}),(0,J.jsxs)(qa,{children:[(0,J.jsxs)(so,{onSelect:e.onMove,children:[(0,J.jsx)(On,{"aria-hidden":!0,size:16}),` Move to…`]}),e.onToggleFavorite?(0,J.jsxs)(so,{onSelect:e.onToggleFavorite,children:[(0,J.jsx)(fr,{"aria-hidden":!0,size:16}),` `,e.favorite?`Remove from favorites`:`Favorite`]}):null,e.onInfo?(0,J.jsxs)(so,{onSelect:e.onInfo,children:[(0,J.jsx)(Oh,{"aria-hidden":!0,size:16}),` Image info`]}):null,e.onToggleReference?(0,J.jsxs)(so,{disabled:e.referenceDisabled,onSelect:e.onToggleReference,children:[e.referenced?(0,J.jsx)(Lr,{"aria-hidden":!0,size:16}):(0,J.jsx)(Eh,{"aria-hidden":!0,size:16}),` `,e.referenced?`Remove reference`:`Add reference`]}):null]})]})}var qN=(0,q.memo)(function({children:e,style:t,...n}){return(0,J.jsx)(`div`,{"data-media-grid":!0,...n,style:t,children:e})});function JN(e,t){let[n,r]=(0,q.useState)({height:0,width:0});return(0,q.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{r(e=>{let n={height:t.clientHeight,width:t.clientWidth};return n.width===e.width&&n.height===e.height?e:n})};n();let i=new ResizeObserver(n);return i.observe(t),window.addEventListener(`resize`,n),()=>{i.disconnect(),window.removeEventListener(`resize`,n)}},[e,t]),n}function YN(e){let[t,n]=(0,q.useState)(0),[r,i]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{let t=e.current;if(!t)return;let r=null,a=()=>{n(t.scrollTop),i(!0),r!==null&&clearTimeout(r),r=setTimeout(()=>{i(!1)},150)};return t.addEventListener(`scroll`,a,{passive:!0}),()=>{t.removeEventListener(`scroll`,a),r!==null&&clearTimeout(r)}},[e]),{isScrolling:r,scrollTop:t}}function XN(e,t){let n=t.height>0?t.width/t.height:1;return Math.round(e/n)}function ZN(e,t,n,r){let i=Math.floor((t-(n-1)*FN)/n),a=e.length===1?e[0]:void 0;if(!a||r<=0)return i;let o=a.height>0?a.width/a.height:1;return Math.max(1,Math.min(i,Math.floor(r*o)))}function QN(e,t,n){let r=e.some(e=>e.select!==void 0),i=Math.max(1,BN(e.length,t),r&&e.length>=2?2:1),a=t-16,o=n-16;return(0,q.useMemo)(()=>{let t=ZN(e,a,i,o),n=ON(i,t,FN);return t>0&&e.forEach((e,r)=>{n.set(r,XN(t,e))}),n},[e,a,i,o])}var $N=132,eP=(0,q.memo)(function({data:e,width:t}){let n=XN(t,e);return(0,J.jsx)(`div`,{"data-media-tile":e.key,"data-short":n<$N?``:void 0,style:{height:n,width:t},children:(0,J.jsx)(UN,{item:e})})});function tP(e,t){let n=Array.from(e.querySelectorAll(`[data-media-tile]`)).find(e=>e.dataset.mediaTile===t)?.querySelector(`[data-media-thumb-wrap]`);return!n||n.disabled?!1:(n.focus({preventScroll:!0}),!0)}function nP(e,t,n){let r=e.ownerDocument;(r.activeElement!==r.body||tP(e,t))&&n()}function rP(e,t,n){let r=n.top+t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;return(r<e.scrollTop||r+n.height>e.scrollTop+e.clientHeight)&&e.scrollTo({top:r,behavior:`instant`}),r}var iP=(0,q.memo)(function({items:e,scrollRef:t,focus:n}){let r=JN(t,e.length),i=r.width||IN,a=e.length===1&&r.height>0,o=i-16,s=r.height-16,c=QN(e,i,r.height),{isScrolling:l,scrollTop:u}=YN(t),d=(0,q.useRef)(new Set),f=(0,q.useRef)(null),p=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!n)return;let a=f.current===n.requestId;if(a&&p.current===i)return;let o=t.current,s=e.findIndex(e=>e.key===n.key),l=c.get(s);if(!o||!l||r.height===0)return;let u=o.querySelector(`[data-media-grid]`);if(!u)return;let d=rP(o,u,l);if(a){nP(o,n.key,()=>{p.current=i});return}tP(o,n.key)?(f.current=n.requestId,p.current=i,n.onFocus()):o.scrollTo({top:d,behavior:`instant`})},[n,e,r.height,t,u,c,i]),(0,q.useEffect)(()=>{let n=t.current;if(!n||r.width===0||r.height===0)return;let i=e.findIndex(e=>e.pending&&!e.onVisible&&!d.current.has(e.key));if(d.current=new Set(e.map(e=>e.key)),i<0)return;let a=c.get(i),o=n.querySelector(`[data-media-grid]`);if(!a||!o)return;let s=o.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop,l=i===0?0:s+a.top,u=l+a.height;l>=n.scrollTop&&u<=n.scrollTop+n.clientHeight||n.scrollTo({top:Math.max(0,l-FN),behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`})},[e,r.width,r.height,t,c]);let m=(0,q.useCallback)(({data:e,width:t})=>(0,J.jsx)(eP,{data:e,width:t}),[]),h=yN({as:qN,height:r.height,isScrolling:l,itemKey:e=>e.key,items:e,overscanBy:2,positioner:c,render:m,scrollTop:u});return(0,J.jsx)(`div`,{"data-media-sole":a?``:void 0,style:{boxSizing:`border-box`,padding:FN,...a?{display:`flex`,alignItems:`center`,justifyContent:`center`,minHeight:r.height}:void 0},children:(0,J.jsx)(`div`,{style:{width:a?ZN(e,o,1,s):`100%`},children:h})})});function aP({items:e,scrollRef:t,focus:n}){return(0,J.jsx)(`section`,{"data-media-mosaic":!0,children:(0,J.jsx)(iP,{items:e,scrollRef:t,focus:n})})}function oP(e,t,n){let r=new Map(e.map(e=>[e.key,e])),i=new Set(t.map(e=>e.key));return[...[...t].reverse().filter(e=>!e.resolved||r.has(e.key)).map(e=>{let t=r.get(e.key);return t&&e.resolved?t:n(e)}),...e.filter(e=>!i.has(e.key))]}function sP(e){let t=on(),n=Li(nr(e)),r=n=>({mutationFn:t=>{let r=e?.context.get().computerId;if(!e||!r)throw Error(`No Computer selected`);return n(e,r,t)},onSuccess:n=>{t.setQueryData(oi.characters(e),n)}}),i=se(r((e,t,n)=>jn(e.capabilities,t,n))),a=se(r((e,t,n)=>Jn(e.capabilities,t,n))),o=i.error??a.error??n.error;return{characters:n.data?.characters??[],error:o?It(o).message:null,busy:i.isPending||a.isPending,save:(e,t)=>{i.mutate(e,{onSuccess:t})},remove:(e,t)=>{a.mutate(e,{onSuccess:t})}}}var cP=u(Hn),lP=e=>e.split(`/`).at(-1)??e;function uP({paths:e,images:t}){return(0,J.jsx)(`span`,{className:`flex gap-xs`,children:e.map(e=>{let n=t.find(t=>t.path===e);return(0,J.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,title:e,children:n?(0,J.jsx)(`img`,{src:n.url,alt:lP(e)}):null},e)})})}function dP({characters:e,images:t,open:n,onOpenChange:r,busy:i,error:a,canUpload:o,onUpload:s,onSave:c,onDelete:l}){let[u,d]=(0,q.useState)(null),f=(0,q.useId)(),p=u?.name.trim()??``,m=p.startsWith(`@`)?p.slice(1):p,h=[];m===``?h.push(`Enter a character name.`):m.length>32?h.push(`Use 32 characters or fewer for the name.`):/^image\d+$/i.test(m)?h.push(`image1, image2 and so on name attached references; pick another name.`):cP(m)||h.push(`Use only letters, numbers, hyphens (-) and underscores (_).`),u?.references.length===0&&h.push(`Select at least one reference image.`),i&&h.push(`Wait for the current character change to finish, then save.`);let g=h.length>0,_=g?f:void 0;return(0,J.jsx)(cm,{open:n,onOpenChange:e=>{e||d(null),r(e)},children:(0,J.jsxs)(pm,{children:[(0,J.jsx)(hm,{children:(0,J.jsx)(gm,{children:`Characters`})}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[e.length===0&&u===null?(0,J.jsx)(`p`,{className:`text-sm`,children:`No characters yet. Save one, then type @name in a prompt to keep it the same in every image.`}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-sm`,"aria-label":`Saved characters`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center justify-between gap-sm`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-sm`,children:[(0,J.jsx)(uP,{paths:e.references.map(e=>e.path),images:t}),(0,J.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`@`,e.name]})]}),(0,J.jsxs)(`span`,{className:`flex gap-xs`,children:[(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{d(e)},children:`Edit`}),(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,disabled:i,onClick:()=>{l(e,()=>{u?.id===e.id&&d(null)})},children:`Delete`})]})]},e.id))}),u===null?(0,J.jsx)(U,{size:`xs`,type:`button`,onClick:()=>{d({name:``,description:``,references:[]})},children:`New character`}):(0,J.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,J.jsx)(py,{"aria-label":`Character name`,"aria-invalid":!cP(m),"aria-describedby":_,maxLength:33,placeholder:`Name, typed as @name`,value:u.name,onChange:e=>{d({...u,name:e.currentTarget.value})}}),(0,J.jsx)(Gi,{"aria-label":`Character description`,maxLength:500,rows:4,placeholder:`Short description added to the prompt, e.g. a tall girl with silver hair and a red scarf`,value:u.description,onChange:e=>{d({...u,description:e.currentTarget.value})}}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-sm`,children:[(0,J.jsxs)(`span`,{className:`text-xs`,children:[`Reference images · `,u.references.length,` selected, up to`,` `,8]}),(0,J.jsxs)(U,{size:`xs`,variant:`ghost`,type:`button`,disabled:!o,onClick:s,children:[(0,J.jsx)(Lh,{"aria-hidden":`true`,size:14}),`Upload`]})]}),t.length===0?(0,J.jsx)(`p`,{className:`text-xs`,children:`No images in the Prints folder yet. Upload one to use it as a reference.`}):(0,J.jsx)(`ul`,{className:`prints-character-picker`,"aria-label":`Reference images`,children:t.map(e=>{let t=u.references.some(t=>t.path===e.path);return(0,J.jsx)(`li`,{title:e.path,children:(0,J.jsxs)(`label`,{className:`prints-character-pick`,children:[(0,J.jsx)(`img`,{src:e.url,alt:``}),(0,J.jsx)(`span`,{className:`prints-character-check`,children:(0,J.jsx)(TA,{"aria-label":`Use ${lP(e.path)}`,checked:t,disabled:!t&&u.references.length>=8,onChange:()=>{d({...u,references:t?u.references.filter(t=>t.path!==e.path):[...u.references,{path:e.path}]})}})})]})},e.path)})}),g?(0,J.jsx)(`p`,{id:f,role:`status`,className:`text-xs`,children:h.join(` `)}):null,(0,J.jsxs)(`div`,{className:`flex gap-xs`,children:[(0,J.jsx)(U,{size:`xs`,variant:`primary`,type:`button`,disabled:g,"aria-describedby":_,onClick:()=>{c({id:u.id,name:m,description:u.description.trim(),references:u.references},()=>{d(null)})},children:`Save character`}),(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{d(null)},children:`Cancel`})]})]}),a?(0,J.jsx)(`p`,{role:`alert`,className:`text-xs`,children:a}):null]}),(0,J.jsx)(mm,{children:(0,J.jsx)(_m,{render:(0,J.jsx)(U,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var fP=g({destination:Re(p(b)),height:Re(un),model:Re(b),prompt:Re(b),references:Re(vt(g({computerId:Re(b),path:b,role:Re($e([`first-frame`,`last-frame`,`reference`]))}))),generateAudio:Re(p(mt)),steps:Re(p(un)),style:Re(p(b)),width:Re(un)}),pP=i(K(),Jt()).parse(structuredClone(Ue(fP,{onExcessProperty:`error`}).schema)),mP=(e,t,n,r)=>({id:e,title:t,category:`Image generation`,description:n,projections:{agent:{}},action:r===void 0?{presentation:{type:`action`}}:{inputSchema:r,presentation:{type:`action`}}}),hP=mP(`inspect-generation-draft`,`Inspect image draft`,`Read the current Prints image form and available models`),gP=mP(`set-generation-draft`,`Edit image draft`,`Set selected Prints image form fields; this does not generate an image`,pP),_P=mP(`submit-generation-draft`,`Generate image`,`Submit the current Prints image form using the same action as the Send button`);function vP(e,t){let n=!1,r=new Set,i=(t,i)=>{e.commands.register(t,i).then(e=>{n?e():r.add(e)},()=>void 0)};return i(hP,()=>{if(n)return;let e=t.readDraft();return{draft:{destination:e.destination??null,height:e.height,model:e.model,prompt:e.prompt,generateAudio:e.generateAudio??null,references:e.references.map(e=>{let t={path:e.path,role:e.role??null};return e.computerId===void 0?t:{...t,computerId:e.computerId}}),steps:e.steps??null,style:e.style??null,width:e.width},models:t.readModels().map(e=>({id:e.id,label:e.label,defaultHeight:e.input.defaultHeight,defaultWidth:e.input.defaultWidth,maxReferences:e.input.maxReferences}))}}),i(gP,({arguments:e})=>{if(n)return;let r=L(fP,{onExcessProperty:`error`})(e);t.setDraft(r)}),i(_P,async()=>{if(!n)return{accepted:await t.submit()}}),()=>{if(!n){n=!0;for(let e of r)e();r.clear()}}}function yP(e){return[{id:`clear-prompt`,title:`Clear prompt`,category:`Prompt`,description:`Remove the current prompt`,projections:{slash:{aliases:[`clear`],order:0},palette:{}},handler:()=>{e().clear()}},...Qr.map((t,n)=>({id:`size-${t}`,title:`Use ${t} size`,category:`Prompt`,description:`Use ${String(wi[t].width)} × ${String(wi[t].height)}`,projections:{slash:{aliases:[t],order:n+1},palette:{}},handler:()=>{e().useSize(t)}})),{id:`choose-style`,title:`Choose style`,category:`Prompt`,description:`Pick, create or edit a saved style`,projections:{slash:{aliases:[`style`],order:4},palette:{}},handler:()=>{e().openStyles()}},{id:`no-style`,title:`Use no style`,category:`Prompt`,description:`Send the prompt without a style`,projections:{slash:{aliases:[`nostyle`],order:5},palette:{}},handler:()=>{e().clearStyle()}}]}function bP(e,t){let n=(0,q.useRef)(e);n.current=e;let r=Vf(t,{sourceId:`media-prompt`,namespace:`media`},(0,q.useCallback)(()=>yP(()=>n.current),[])),i=(0,q.useSyncExternalStore)(r.subscribe,r.snapshot,r.snapshot);return{items:(0,q.useMemo)(()=>vr(i).map(e=>({id:e.commandId,command:e.command,slash:e.alias,title:e.title,description:e.description})),[i]),run:e=>{r.execute(e,{origin:`slash`})}}}function xP(e){let t=on(),n=Li(ir(e)),r=n=>({mutationFn:t=>{let r=e?.context.get().computerId;if(!e||!r)throw Error(`No Computer selected`);return n(e,r,t)},onSuccess:n=>{t.setQueryData(oi.styles(e),n)}}),i=se(r((e,t,n)=>kr(e.capabilities,t,n))),a=se(r((e,t,n)=>Qn(e.capabilities,t,n))),o=i.error??a.error??n.error;return{styles:n.data?.styles??[],error:o?It(o).message:null,busy:i.isPending||a.isPending,save:(e,t)=>{i.mutate(e,{onSuccess:n=>{t(n.styles.find(t=>t.name===e.name))}})},remove:(e,t)=>{a.mutate(e,{onSuccess:t})}}}function SP(e){let t=e.filter(e=>e.kind===`video`&&e.video!==null&&e.video.prices.length>0&&e.input.maxReferences>=1&&e.video.referenceRoles.includes(`first-frame`));return t.find(e=>e.video?.provider===`seedance`)??t.at(0)}function CP(e,t,n){let r=e.video;if(r===null)return;let i=Math.log(t/n),a=e=>Math.abs(Math.log(e.width/e.height)-i);return r.formats.filter(e=>e.resolution===r.defaultResolution).reduce((e,t)=>e===void 0||a(t)<a(e)?t:e,void 0)}function wP(e,t){let{lineage:n,printPath:r,models:i,current:a}=t,o=e===`animate`?SP(i):void 0;if(e===`animate`&&o===void 0)return{kind:`refused`,message:`No video model on this Computer takes a first frame.`};let s=Vn(i,n.model),c=s?.transform!=null;if(c&&e===`reuse`)return{kind:`refused`,message:`This print was an image edit, so there is no prompt to reuse. Remix or animate it instead.`};let l=o??(c?void 0:s)??Vn(i,a.model);if(l===void 0)return{kind:`refused`,message:`Choose a model from the granted registry.`};let u=o===void 0&&s===void 0?`This print was made with ${n.model}, which is no longer available. Loaded it with ${Rn(l)} instead.`:null,d=c?[]:n.references.slice(0,n.typed.references),f=e===`animate`?{path:r,role:`first-frame`}:{path:r},p=[f,...d.filter(e=>!Vi(e,t.printComputerId)||e.path!==r)];if(e!==`reuse`&&l.input.maxReferences===0)return{kind:`refused`,message:`${l.label} does not take reference images.`};let m=e===`reuse`?d:e===`remix`?p:[f],h=Fr(a,l),g={width:n.width??h.width,height:n.height??h.height},_=o===void 0?Un(g,l,void 0):CP(l,g.width,g.height)??h,v=o===void 0&&l.input.steps!==`fixed`&&n.steps!==null&&l.id===n.model?n.steps:h.steps,y=n.style!==null&&t.styles.includes(n.style)?n.style:void 0;return{kind:`draft`,notice:u,draft:{...h,destination:void 0,prompt:Tr(c?``:n.typed.prompt,e=>{let t=d.at(e-1),n=t===void 0?-1:m.findIndex(e=>e.path===t.path&&e.computerId===t.computerId);return n<0?void 0:n+1}),references:m,steps:v,style:y,width:_.width,height:_.height}}}function TP({id:e,styles:t,selected:n,disabled:r,onSelect:i}){let a=n===void 0||t.some(e=>e.name===n);return(0,J.jsxs)(My,{id:e,"aria-label":`Prompt style`,"data-generation-style":!0,className:`select-sm`,disabled:r,onChange:e=>{i(e.currentTarget.value||void 0)},value:n??``,children:[(0,J.jsx)(`option`,{value:``,children:`No style`}),a?null:(0,J.jsx)(`option`,{value:n,children:n}),t.map(e=>(0,J.jsx)(`option`,{value:e.name,children:e.name},e.id))]})}function EP({styles:e,selected:t,open:n,onOpenChange:r,busy:i,error:a,onSelect:o,onSave:s,onDelete:c}){let[l,u]=(0,q.useState)(null);return(0,J.jsx)(cm,{open:n,onOpenChange:r,children:(0,J.jsxs)(pm,{children:[(0,J.jsx)(hm,{children:(0,J.jsx)(gm,{children:`Styles`})}),(0,J.jsx)(`ul`,{className:`space-y-1`,"aria-label":`Saved styles`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center justify-between gap-sm`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,J.jsxs)(`span`,{className:`flex gap-xs`,children:[(0,J.jsx)(U,{size:`xs`,variant:t===e.name?`primary`:`ghost`,type:`button`,"aria-pressed":t===e.name,onClick:()=>{o(e.name),r(!1)},children:`Use`}),e.builtIn?null:(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u(e)},children:`Edit`}),(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u({name:`${e.name} copy`.slice(0,64),text:e.text})},children:`Duplicate`}),e.builtIn?null:(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,disabled:i,onClick:()=>{c(e,()=>{t===e.name&&o(void 0),l?.id===e.id&&u(null)})},children:`Delete`})]})]},e.id))}),l===null?(0,J.jsx)(U,{size:`xs`,type:`button`,onClick:()=>{u({name:``,text:``})},children:`New style`}):(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(py,{"aria-label":`Style name`,maxLength:64,value:l.name,onChange:e=>{u({...l,name:e.currentTarget.value})}}),(0,J.jsx)(Gi,{"aria-label":`Style text`,maxLength:8e3,rows:6,value:l.text,onChange:e=>{u({...l,text:e.currentTarget.value})}}),(0,J.jsxs)(`div`,{className:`flex gap-xs`,children:[(0,J.jsx)(U,{size:`xs`,variant:`primary`,type:`button`,disabled:i||l.name.trim()===``||l.text.trim()===``,onClick:()=>{let n=e.find(e=>e.id===l.id);s({id:l.id,name:l.name.trim(),text:l.text},e=>{n&&t===n.name&&e&&o(e.name),u(null)})},children:`Save style`}),(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u(null)},children:`Cancel`})]})]}),a?(0,J.jsx)(`p`,{role:`alert`,className:`text-xs`,children:a}):null,(0,J.jsx)(mm,{children:(0,J.jsx)(_m,{render:(0,J.jsx)(U,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var DP=(0,q.lazy)(async()=>({default:(await Rr(()=>import(`./print-info-drawer-QvgjDcHc.js`),__vite__mapDeps([5,1,2,3,6]),import.meta.url)).PrintInfoDrawer})),OP=[`a mushroom knight`,`moss on a keyboard`,`a tiny house made of mushrooms`];function kP(e){Wt.error(e,{id:`prints-generation-error`,toasterId:`prints-generation-notices`})}function AP(e){let t=(0,q.useRef)(!1),n=fy({defaultValues:ri(),onSubmit:async({value:n})=>{t.current=await e.current(n)}}),r=(0,q.useCallback)(async()=>(t.current=!1,await n.handleSubmit(),t.current),[n]);return Object.assign(n,{submitCurrent:r})}function jP(e){let t=[...new Set(e.map(e=>e.group))];return t.length<2?[{group:void 0,choices:e}]:t.map(t=>({group:t,choices:e.filter(e=>e.group===t)}))}function MP({form:e,selected:t,stylePicker:n,sizeChoices:r,sizeMode:i,onCustomSize:a,match:o,onEditStyles:s,onEditCharacters:c}){let l=t?.input.dimensions===`none`,u=t!==void 0&&t.sizes!==null,d=t?.video??null;return(0,J.jsxs)(`div`,{className:`prints-settings`,children:[(0,J.jsx)(Ey,{label:`Style`,orientation:`horizontal`,children:n}),(0,J.jsx)(Ey,{label:`Size`,orientation:`horizontal`,children:(0,J.jsx)(My,{"aria-label":`Generation size`,"data-generation-size":!0,className:`select-sm`,disabled:l,title:l?`This model chooses the output size.`:void 0,onChange:t=>{let n=t.currentTarget.value;o.onChange(n===`match`),a(n===`custom`);let i=r.find(e=>e.value===n);i&&(e.setFieldValue(`width`,i.width),e.setFieldValue(`height`,i.height))},value:l?`provider`:i,children:l?(0,J.jsx)(`option`,{value:`provider`,children:`Model default`}):(0,J.jsxs)(J.Fragment,{children:[o.offered?(0,J.jsx)(`option`,{value:`match`,disabled:o.size===void 0,children:o.size===void 0?`Match first reference: attach an image first`:`Match first reference · ${Yn(o.size.width,o.size.height)}`}):null,u&&i!==`match`&&!r.some(e=>e.value===i)?(0,J.jsx)(`option`,{value:i,disabled:!0,children:`Choose a supported resolution`}):null,jP(r).map(({group:e,choices:t})=>e===void 0?t.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value)):(0,J.jsx)(`optgroup`,{label:e,children:t.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value))},e)),u?null:(0,J.jsx)(`option`,{value:`custom`,children:`Custom size`})]})})}),!l&&!u&&i===`custom`?(0,J.jsxs)(`div`,{className:`prints-custom-size`,children:[(0,J.jsx)(e.Field,{name:`width`,children:e=>(0,J.jsx)(Ey,{label:`Width`,children:(0,J.jsx)(py,{"aria-label":`Generation width`,"data-generation-width":!0,max:4096,min:1,onChange:t=>{e.handleChange(Number(t.currentTarget.value)||1)},type:`number`,value:e.state.value})})}),(0,J.jsx)(e.Field,{name:`height`,children:e=>(0,J.jsx)(Ey,{label:`Height`,children:(0,J.jsx)(py,{"aria-label":`Generation height`,"data-generation-height":!0,max:4096,min:1,onChange:t=>{e.handleChange(Number(t.currentTarget.value)||1)},type:`number`,value:e.state.value})})})]}):null,d?(0,J.jsx)(e.Field,{name:`durationSeconds`,children:e=>(0,J.jsx)(Ey,{label:`Length`,orientation:`horizontal`,children:(0,J.jsx)(My,{"aria-label":`Video length in seconds`,className:`select-sm`,"data-generation-duration":!0,onChange:t=>{let n=t.currentTarget.value;e.handleChange(d.durations.find(e=>String(e)===n))},value:e.state.value===void 0?``:String(e.state.value),children:d.durations.map(e=>(0,J.jsxs)(`option`,{value:String(e),children:[e,` seconds`]},e))})})}):null,d?.supportsAudio?(0,J.jsx)(e.Field,{name:`generateAudio`,children:e=>d.defaultGenerateAudio===null?(0,J.jsx)(Ey,{label:`Sound`,orientation:`horizontal`,children:(0,J.jsxs)(My,{"aria-label":`Video sound`,className:`select-sm`,"data-generation-audio":!0,onChange:t=>{let n=t.currentTarget.value;e.handleChange(n===``?void 0:n===`on`)},value:e.state.value===void 0?``:e.state.value?`on`:`off`,children:[(0,J.jsx)(`option`,{value:``,children:`Model default`}),(0,J.jsx)(`option`,{value:`on`,children:`On`}),(0,J.jsx)(`option`,{value:`off`,children:`Off`})]})}):(0,J.jsx)(Ey,{label:`Sound`,orientation:`horizontal`,children:(0,J.jsx)(zn,{"aria-label":`Video sound`,checked:e.state.value??!0,"data-generation-audio":!0,onCheckedChange:e.handleChange})})}):null,t&&t.input.steps!==`fixed`?(0,J.jsx)(e.Field,{name:`steps`,children:e=>(0,J.jsx)(Ey,{label:`Steps`,optional:!0,orientation:`horizontal`,children:(0,J.jsx)(py,{"aria-label":`Generation steps`,className:`input-sm`,"data-generation-steps":!0,max:t.input.maxSteps??void 0,min:1,onChange:t=>{e.handleChange(t.currentTarget.value===``?void 0:Number(t.currentTarget.value))},type:`number`,value:e.state.value??``})})}):null,(0,J.jsxs)(`div`,{className:`prints-settings-library`,children:[(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{s()},children:`Edit styles…`}),(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{c()},children:`Characters…`})]})]})}function NP(e){return e.detail===void 0?e.title:e.group===`Images`?e.detail:`${e.title}. ${e.detail}`}function PP({actions:e,guidance:t,commandApp:n,form:r,models:i,modelsLoading:a,mediaCapability:o,submitting:s,generateLimitReason:c,values:l,computerId:u,mediaDirectory:d,referenceImages:f,referenceLabels:p,price:m,characters:h,characterDialog:g,onSubmit:_,styleControls:v,addedLength:y}){let b=Vn(i,l.model),x=!o||a||i.length===0,S=x&&t?.group===`Setup`&&t.blocking===!0?t:void 0,C=l.prompt.trim().length,w=b!==void 0&&C>0&&C+y>b.maxPromptLength,T=si(b),E=b?.video??null,D=Cr(l.prompt).length>0,O=rr(l.references,b,D),k=b?.input.maxReferences??0,A=l.references.length>k,j=(0,q.useRef)(null),M=(0,q.useId)(),N=eb(j),[P,F]=(0,q.useState)(!1),I=w?C+y:0,ee=b!==void 0&&w?Pi({addedLength:y,length:I,maxLength:b.maxPromptLength}):void 0,[te,ne]=(0,q.useState)(!1),[re,L]=(0,q.useState)(!1),R=l.references.find(e=>u!==null&&Vi(e,u)),ie=f.find(e=>e.path===R?.path),ae=ie===void 0?void 0:br(b,ie.width,ie.height),oe=r.setFieldValue,se=(0,q.useRef)({width:l.width,height:l.height});se.current={width:l.width,height:l.height},(0,q.useEffect)(()=>{if(re){if(ae===void 0){L(!1),Wt(`Size kept at ${String(se.current.width)} × ${String(se.current.height)}; Match first reference turned off`,{toasterId:`prints-generation-notices`});return}oe(`width`,ae.width),oe(`height`,ae.height)}},[re,ae?.width,ae?.height,oe]);let[ce,z]=(0,q.useState)(!1),le=b!==void 0&&b.sizes!==null,B=ur(b),ue=re?`match`:le?`${String(l.width)}x${String(l.height)}`:te?`custom`:B.find(e=>e.width===l.width&&e.height===l.height)?.value??`custom`,[de,fe]=(0,q.useState)(!1),V=bP({clear:()=>{r.setFieldValue(`prompt`,``)},useSize:e=>{ne(!1),L(!1),r.setFieldValue(`width`,wi[e].width),r.setFieldValue(`height`,wi[e].height),r.setFieldValue(`prompt`,``)},openStyles:()=>{r.setFieldValue(`prompt`,``),fe(!0)},clearStyle:()=>{r.setFieldValue(`style`,void 0),r.setFieldValue(`prompt`,``)}},n),[pe,me]=(0,q.useState)(!1),he=l.references.map((e,t)=>({number:p[t]??t+1,name:e.path.split(`/`).at(-1)??e.path,url:u!==null&&Vi(e,u)?f.find(t=>t.path===e.path)?.url:void 0})),ge=Xr(h,he,l.prompt),_e=di(l.prompt,h,he,f),ve=Gr(V.items,l.prompt),ye=(0,q.useId)(),be=`${ye}-commands`,xe=`${ye}-characters`,Se=er(l.prompt,h).characters,Ce=e=>{let t=ve.slashMatches.at(e);t&&(ve.resetSlash(),V.run(t.command))},we=v({open:de,onOpenChange:fe}),Te=[l.style,re?`Match · ${An(l.width,l.height)}`:ar(b,l.width,l.height),E&&l.durationSeconds!==void 0?`${String(l.durationSeconds)}s`:void 0,E?.supportsAudio&&l.generateAudio===!1?`silent`:void 0].filter(e=>e!=null),Ee=(0,J.jsx)(MP,{form:r,selected:b,stylePicker:we.picker,sizeChoices:B,sizeMode:ue,onCustomSize:ne,match:{offered:b?.kind===`image`&&b.input.dimensions===`own`,size:ae,onChange:L},onEditStyles:()=>{z(!1),fe(!0)},onEditCharacters:()=>{z(!1),me(!0)}}),De=e=>{let t=r.store.state.fieldMeta,n=Fr(l,e),i=Un(l,e,b);r.setFieldValue(`model`,e.id),(e.input.dimensions===`none`||e.sizes!==null)&&ne(!1),r.setFieldValue(`width`,i.width),r.setFieldValue(`height`,i.height),r.setFieldValue(`durationSeconds`,n.durationSeconds),r.setFieldValue(`voiceId`,n.voiceId),r.setFieldValue(`generateAudio`,n.generateAudio),e.kind===`audio`&&r.setFieldValue(`references`,[]),(e.input.steps===`fixed`||!t.steps?.isTouched)&&r.setFieldValue(`steps`,n.steps)},Oe=b?.kind===`audio`,ke=Oe?0:l.references.length,Ae=Xg(hi(i)),je=(0,q.useRef)(null);b!==void 0&&b.kind!==`audio`&&(je.current=b.id);let Me=()=>{let e=Oe?Vn(i,je.current??``)??Vn(i,`@cf/black-forest-labs/flux-2-klein-4b`)??ui(i).at(0):Vn(i,Ae.at(0)?.id??``);e&&De(e)},Ne=b===void 0?null:Zg(b),Pe=Ne===null?[]:$g(Ae,Ne),Fe=b?.audio==null||Ne===null?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(e_,{disabled:s,modes:Qg(Ae),value:Ne,onChange:e=>{let t=Vn(i,$g(Ae,e).at(0)?.id??``);t&&De(t)}}),Pe.length>1?(0,J.jsx)(n_,{disabled:s,models:Pe,value:b.id,onChange:e=>{let t=Vn(i,e);t&&De(t)}}):null,b.audio.mode===`speech`?(0,J.jsx)(r_,{disabled:s,voices:b.audio.voices,value:l.voiceId??b.audio.defaultVoiceId??``,onChange:e=>{r.setFieldValue(`voiceId`,e)}}):null,b.audio.seconds===null?null:(0,J.jsx)(o_,{disabled:s,seconds:b.audio.seconds,value:l.durationSeconds??b.audio.seconds.default,onChange:e=>{r.setFieldValue(`durationSeconds`,e)}})]});return(0,J.jsxs)(ti,{"aria-label":Oe?`Audio generation`:`Image generation`,"data-generation-form":!0,"data-composer-collapsed":N.collapsed?``:void 0,"data-composer-fullscreen":N.fullscreen?``:void 0,attachments:!Oe&&l.references.length>0?(0,J.jsx)(`div`,{className:`prints-reference-tray`,"aria-label":`Image references`,"data-over-limit":A?``:void 0,title:`${String(l.references.length)} / ${String(k)} references`,children:l.references.map((e,t)=>{let n=u!==null&&Vi(e,u)?f.find(t=>t.path===e.path):void 0,i=O[t]?.role,a=cr(T,O,t);return(0,J.jsxs)(`div`,{className:`prints-reference-tile`,"data-reference-chip":!0,title:e.computerId===void 0?e.path:`${e.computerId}:${e.path}`,children:[(0,J.jsx)(`div`,{className:`prints-reference-face mask mask-squircle`,children:n?(0,J.jsx)(`img`,{src:n.url,alt:e.path.split(`/`).at(-1)}):(0,J.jsx)(`span`,{children:Kn(p[t]??t+1)})}),(0,J.jsx)(`span`,{className:`prints-reference-label`,"data-reference-label":!0,children:Kn(p[t]??t+1)}),i===void 0?null:a===void 0?(0,J.jsx)(`span`,{className:`prints-reference-role`,"data-reference-role":i,children:qr[i]}):(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,className:`prints-reference-role`,"data-reference-role":i,"aria-label":`Reference ${String(t+1)}: ${qr[i]}. Use as ${qr[a]}`,title:`Use as ${qr[a]}`,onClick:()=>{r.setFieldValue(`references`,O.map((e,n)=>n===t?{...e,role:a}:e))},children:qr[i]}),(0,J.jsx)(pt,{icon:(0,J.jsx)(Ei,{}),className:`prints-reference-remove`,"aria-label":`Remove reference ${String(t+1)}`,onClick:()=>{r.setFieldValue(`references`,l.references.filter((e,n)=>n!==t))}})]},JSON.stringify([e.computerId??u,e.path]))})}):void 0,input:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`form`,{"aria-busy":s,onSubmit:e=>{e.preventDefault(),_()},children:(0,J.jsx)(r.Field,{name:`prompt`,children:e=>(0,J.jsxs)(`div`,{className:`prints-prompt`,"data-guidance-placeholder":S?``:void 0,id:M,ref:j,children:[ve.slashOpen?(0,J.jsx)(Hr,{index:ve.slashIndex,listId:be,matches:ve.slashMatches,onHighlight:ve.highlightSlash,onPick:Ce}):null,!ve.slashOpen&&ge.matches.length>0?(0,J.jsx)(yi,{images:f,index:ge.index,listId:xe,matches:ge.matches,onHighlight:ge.highlight,onPick:t=>{let n=ge.complete(t);n!==null&&e.handleChange(n)}}):null,(0,J.jsx)(Ir,{caretRequest:ge.caretRequest,layout:N,onOver:kP,onOverflow:F,menu:ve.slashOpen?{open:ve.slashMatches.length>0,listId:be,selected:ve.slashIndex}:{open:ge.matches.length>0,listId:xe,selected:ge.index},mentionCount:ve.slashOpen?0:ge.matches.length,onCaret:ge.setCaret,onMentionDismiss:ge.dismiss,onMentionMove:ge.move,onMentionPick:()=>{let t=ge.complete(ge.index);t!==null&&e.handleChange(t)},disabled:x||s,maxLength:b?.maxPromptLength,addedLength:y,onChange:t=>{e.handleChange(t)},onSend:_,onSlashMove:ve.moveSlash,onSlashPick:()=>{Ce(ve.slashIndex)},placeholder:S?NP(S):b?.audio?.mode===`speech`?`What should it say?`:b?.audio?.mode===`music`?`Describe the music`:`What are we making?`,slashCount:ve.slashMatches.length,value:e.state.value}),Se.length>0||_e.length>0?(0,J.jsxs)(`div`,{className:`prints-composer-notes`,children:[(0,J.jsx)(Oi,{tokens:_e}),Se.length>0?(0,J.jsx)(`span`,{className:`prints-reference-count`,"data-generation-characters":!0,children:`Characters: ${Se.map(e=>e.name).join(`, `)}`}):null]}):null]})})}),t&&!S?(0,J.jsxs)(`div`,{className:`prints-composer-guidance`,role:`status`,"data-composer-guidance":!0,children:[(0,J.jsx)(`span`,{children:NP(t)}),t.actions?.map(e=>(0,J.jsx)(U,{variant:`ghost`,size:`xs`,onClick:e.run,children:e.label},e.label))]}):null]}),row:{controls:(0,J.jsxs)(J.Fragment,{children:[N.fullscreen?null:(0,J.jsx)(_t,{"aria-controls":M,"aria-expanded":!N.collapsed,"aria-label":N.collapsed?`Expand composer`:`Collapse composer`,"data-composer-collapse":!0,icon:N.collapsed?(0,J.jsx)(Di,{}):(0,J.jsx)(ai,{}),label:null,onClick:()=>{N.setCollapsed(!N.collapsed)},onMouseDown:e=>{e.preventDefault()},title:N.collapsed?`Expand composer`:`Collapse composer`}),N.collapsed&&ke>0?(0,J.jsxs)(`span`,{"aria-label":`${String(ke)} ${ke===1?`reference`:`references`} attached`,className:`prints-composer-count`,"data-composer-count":!0,role:`img`,title:`${String(ke)} ${ke===1?`reference`:`references`} attached`,children:[(0,J.jsx)(Dh,{"aria-hidden":`true`}),ke]}):null,N.coarse&&P&&!N.collapsed?(0,J.jsx)(_t,{"aria-label":`Open full-screen editor`,"data-composer-expand":!0,icon:(0,J.jsx)(Or,{}),label:null,onClick:()=>{N.setFullscreen(!0),j.current?.querySelector(`textarea`)?.focus()},title:`Open full-screen editor`}):null,S?S.actions?.map(e=>(0,J.jsx)(U,{variant:`ghost`,size:`xs`,onClick:e.run,children:e.label},e.label)):null,Oe?null:e,Ae.length>0?(0,J.jsx)(_t,{"aria-label":`Audio`,"data-generation-audio-key":!0,icon:(0,J.jsx)(yh,{}),label:null,pressed:Oe,tone:Oe?`accent`:`neutral`,title:Oe?`Back to pictures`:`Make audio`,disabled:a||!o,onClick:Me}):null,Oe?Fe:(0,J.jsx)(r.Field,{name:`model`,children:e=>(0,J.jsx)(jA,{compact:N.coarse,models:ui(i),emptyLabel:u===null?`Choose a Computer`:a?`Loading models…`:`Models unavailable`,disabled:a||!o,onChange:e=>{let t=Vn(i,e);t&&De(t)},value:e.state.value})}),u&&d?(0,J.jsx)(`span`,{className:`sr-only`,"data-generation-computer":!0,title:`Where new prints are saved`,children:`Saved in your Prints folder`}):null]}),action:(0,J.jsxs)(`span`,{className:`prints-generate-action`,children:[m===null?null:(0,J.jsx)(`span`,{className:`prints-generate-price`,"data-generation-price":!0,title:`Estimated price`,children:m.startsWith(`<`)?m:`≈ ${m}`}),(0,J.jsx)(ii,{busy:s,draft:l.prompt,disabled:!o||a||i.length===0||s||c!==void 0,disabledReason:c??ee,label:qi(b),onGenerate:()=>{_()},promptOver:w})]}),items:Oe?[]:[{id:`settings`,accessibleLabel:`Generation settings`,title:`Settings`,label:(0,J.jsxs)(`span`,{className:`prints-settings-chip`,children:[(0,J.jsx)(Ih,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),(0,J.jsx)(`span`,{className:`prints-settings-chip-text`,children:Te.length>0?Te.join(` · `):`Settings`})]}),content:Ee}],openId:ce?`settings`:null,onOpenChange:e=>{z(e===`settings`)}},children:[(0,J.jsx)(tb,{layout:N}),(0,J.jsxs)(`div`,{className:`prints-composer-editor-bar`,"data-composer-editor-bar":!0,children:[(0,J.jsx)(`span`,{children:`Prompt`}),(0,J.jsx)(_t,{"data-composer-done":!0,label:`Done`,onClick:()=>{N.setFullscreen(!1),j.current?.querySelector(`textarea`)?.focus()}})]}),we.dialog,g({open:pe,onOpenChange:me})]})}function FP({connection:e}){let t=(0,q.useRef)(null),n=(0,q.useRef)(e);n.current=e;let r=NA(e?.app??null),i=Rf(e?.app??null)?.setup?.media===`missing`,[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),l=()=>{let t=e?.app;t&&(o(!0),c(!1),t.ui.openSetup(`media`).then(e=>{o(!1),c(e===`unavailable`)},e=>{o(!1),c(!0),tn(`open-media-setup`,e)}))},u=s?(0,J.jsxs)(J.Fragment,{children:[`Image setup couldn’t open.`,` `,(0,J.jsx)(`a`,{href:`https://github.com/fungi-computer/oyster#deploy-to-cloudflare`,target:`_blank`,rel:`noreferrer`,children:`Open the image setup guide`}),`.`]}):`Image generation isn’t set up yet.`,[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(),h=WM(e?.app??null,r.computerId),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(),S=(0,q.useRef)(0);(0,q.useEffect)(()=>{_(null),y(null),x(void 0)},[e,r.computerId,r.path]);let C=r.path,w=Vg(e,r),{gallery:T,images:E,failed:D,loading:O,gallerySlots:k,canBrowse:A,canRead:j,canWrite:M,reserveSlot:N,failSlot:P,clearSlotError:F,removeSlot:I,addComputerFile:ee,retryFile:te,uploads:ne,uploadFiles:re}=w,L=e!==null&&r.destination!==null&&A&&j,R=yA({app:e?.app??null,destination:r.destination,view:r.view,setView:r.setView,entries:T.entries,canWrite:M}),[ie,ae]=(0,q.useState)(!1),oe=R.selecting||T.entries.length>0||w.gallery.folders.length>0,se=mg({selectable:oe,atFolderRoot:r.view.kind===`folder`&&!R.up,loading:O||T.loading,failed:!!T.error});Hf(L?e.app.window.navigation:null,{canGoBack:R.history.canGoBack,canGoForward:R.history.canGoForward,crumbs:R.crumbs,primary:oe?[{id:`select`,label:`Select`,variant:`outline`}]:[],onAction:e=>{e===`select`&&R.setSelecting(!R.selecting)},onBack:R.history.back,onForward:R.history.forward,onCrumb:e=>{R.history.open(e===`all`||e===`favorites`?{kind:e}:{kind:`folder`,folder:e===``?void 0:e})}});let[ce,z]=(0,q.useState)(Date.now),le=k.some(e=>e.startedAt!==void 0&&!e.resolved&&!e.error);(0,q.useEffect)(()=>{if(!le)return;let e=setInterval(()=>{z(Date.now())},1e3);return()=>{clearInterval(e)}},[le]);let B=zp(e,(e,t,n)=>(T.refresh(),ee(e,t,n)));(0,q.useLayoutEffect)(()=>{x(void 0),B.target&&(_(null),y(null))},[B.target]),(0,q.useEffect)(()=>{B.error&&xi(`Could not open this print. It may no longer be available on this Computer.`,`prints-navigation-error`)},[B.error]);let ue=T.entries.some(e=>e.path===B.target?.path);(0,q.useEffect)(()=>{B.target&&!ue&&T.nextPageReady&&T.loadMore()},[B.target,ue,T.nextPageReady,T.loadMore]);let de=E.find(e=>e.source.kind===`computer`&&e.source.computerId===B.target?.computerId&&e.source.path===B.target.path),fe=xP(e?.app??null),V=sP(e?.app??null),[pe,me]=(0,q.useState)(new Set),he=F_({connection:e,folder:r,styles:fe.styles,characters:V.characters,effects:{reserve:e=>{me(t=>{if(!t.has(e.key))return t;let n=new Set(t);return n.delete(e.key),n}),N(e)},failed:P,release:I,notifyFailure:kP,saved:({result:e},t)=>{me(t=>new Set(t).add(`${e.destination.computerId}:${e.destination.path}`)),j?ee(e.destination.path,t,e.destination.computerId):P(`${e.destination.computerId}:${e.destination.path}`,`Image saved, but this App cannot read its preview.`)}}}),{state:ge,models:_e,modelsLoading:ve,modelsError:ye,canGenerate:be,mediaCapability:xe,pendingGenerations:Se,activeGenerations:Ce,recoveryError:we}=he,Te=(0,q.useRef)(_e),Ee=(0,q.useRef)(he);Ee.current=he;let De=(0,q.useRef)(null),Oe=(0,q.useRef)(null),ke=(0,q.useRef)(0),[Ae,je]=(0,q.useState)(null),Me=(0,q.useRef)([]),Ne=(0,q.useRef)(e=>he.submit(e,Me.current));Ne.current=async e=>{let t=await he.submit(e,Me.current);return t&&je(null),t};let Pe=AP(Ne),Fe=e=>{Pe.setFieldValue(`model`,e.model),Pe.setFieldValue(`width`,e.width),Pe.setFieldValue(`height`,e.height),Pe.setFieldValue(`steps`,e.steps),Pe.setFieldValue(`durationSeconds`,e.durationSeconds),Pe.setFieldValue(`generateAudio`,e.generateAudio),Pe.setFieldValue(`prompt`,e.prompt),Pe.setFieldValue(`references`,e.references),Pe.setFieldValue(`style`,e.style),Pe.setFieldValue(`destination`,void 0)},Ie=(0,q.useRef)(Pe);Ie.current=Pe;let Le=ny(Pe.store,e=>e.values),Re=Si(Le.references,Le.prompt,r.computerId);Me.current=Re;let ze=gi(he.session,ji({draft:Le,model:Vn(he.models,Le.model),styleText:fe.styles.find(e=>e.name===Le.style)?.text,characters:V.characters,labels:Re,computerId:r.computerId})),Be=ny(Pe.store,e=>e.isSubmitting),Ve=e?.app;(0,q.useEffect)(()=>{if(Ve)return vP(Ve,{readDraft:()=>Ie.current.store.state.values,readModels:()=>Te.current,setDraft:e=>{let t=Ie.current;if(e.model!==void 0){let n=Vn(Te.current,e.model);if(!n)throw Error(`Choose a model from the granted registry.`);let r=Fr(t.store.state.values,n),i=Vn(Te.current,t.store.state.values.model),a=Un(t.store.state.values,n,i);t.setFieldValue(`model`,r.model),t.setFieldValue(`width`,a.width),t.setFieldValue(`height`,a.height),t.setFieldValue(`steps`,r.steps),t.setFieldValue(`durationSeconds`,r.durationSeconds),t.setFieldValue(`generateAudio`,r.generateAudio)}e.generateAudio!==void 0&&t.setFieldValue(`generateAudio`,e.generateAudio??void 0),e.destination!==void 0&&t.setFieldValue(`destination`,e.destination??void 0),e.height!==void 0&&t.setFieldValue(`height`,e.height),e.prompt!==void 0&&t.setFieldValue(`prompt`,e.prompt),e.references!==void 0&&t.setFieldValue(`references`,e.references),e.steps!==void 0&&t.setFieldValue(`steps`,e.steps??void 0),e.style!==void 0&&t.setFieldValue(`style`,e.style??void 0),e.width!==void 0&&t.setFieldValue(`width`,e.width)},submit:()=>Ie.current.store.state.isSubmitting||Ee.current.atLimit?Promise.resolve(!1):Ie.current.submitCurrent()})},[Ve]),(0,q.useEffect)(()=>{Te.current=_e},[_e]),(0,q.useEffect)(()=>{if(_e.length===0||ye)return;let e=_e.find(e=>e.id===`@cf/black-forest-labs/flux-2-klein-4b`)??ui(_e).at(0)??_e[0];if(!Pe.store.state.fieldMeta.model?.isTouched){let t=Fr(Pe.store.state.values,e);Pe.setFieldValue(`model`,t.model),Pe.store.state.fieldMeta.width?.isTouched||Pe.setFieldValue(`width`,t.width),Pe.store.state.fieldMeta.height?.isTouched||Pe.setFieldValue(`height`,t.height),Pe.store.state.fieldMeta.steps?.isTouched||Pe.setFieldValue(`steps`,t.steps)}},[Pe,ye,_e]);let He=Vn(_e,Le.model),Ue=Le.references,H=He?.input.maxReferences??0,We=(0,q.useRef)({addComputerFile:ee,retryPath:he.retryPath,uploads:ne});We.current={addComputerFile:ee,retryPath:he.retryPath,uploads:ne};let Ge=de?Rg(de):null,Ke=(0,q.useMemo)(()=>E.map(e=>({key:Rg(e),selected:Rg(e)===Ge,path:e.source.kind===`computer`?e.source.path:e.file.name,referenced:Ue.some(t=>e.source.kind===`computer`&&Vi(t,e.source.computerId)&&t.path===e.source.path),referenceDisabled:Ue.length>=H&&!Ue.some(t=>e.source.kind===`computer`&&Vi(t,e.source.computerId)&&t.path===e.source.path),onToggleReference:e.source.kind===`computer`&&H>0&&!an(e.source.path)?()=>{if(e.source.kind!==`computer`)return;let t=e.source.path,n=e.source.computerId,r=Ue.some(e=>Vi(e,n)&&e.path===t);Pe.setFieldValue(`references`,r?Ue.filter(e=>!Vi(e,n)||e.path!==t):[...Ue,{path:t}])}:void 0,onInfo:()=>{_(e)},url:e.url,width:e.width,height:e.height,onOpen:()=>{_(null),y(Rg(e))}})),[E,Ue,H,Pe,Ge]),qe=(0,q.useMemo)(()=>{let e=r.computerId;if(!e)return Ke;let t=new Map(Ke.map(e=>[e.key,e])),n=[...T.entries].sort((e,t)=>t.modifiedAt-e.modifiedAt||e.name.localeCompare(t.name)).map(n=>{let r=`${e}:${n.path}`;return{...t.get(r)??{key:r,path:n.path,width:1,height:1,url:``,pending:!0,pendingLabel:`Loading print…`,onOpen:()=>void 0,onVisible:()=>{T.loadFile(n.path)},error:D.includes(n.name)?`Could not load this print.`:void 0},onRetry:()=>{te(n.path)}}}),i=new Set(n.map(e=>e.key));return[...n,...Ke.filter(e=>!i.has(e.key)&&e.key!==Ge)]},[Ke,T.entries,T.loadFile,te,D,r.computerId,Ge]),Je=L&&!(r.view.kind===`folder`&&!R.up)?r.view.kind===`all`?{title:`No prints yet`,description:`Prints in any folder of the library appear here.`}:r.view.kind===`favorites`?{title:`No favorites yet`,description:`Tap the heart on a print to keep it here for your whole Team.`}:{title:`Nothing in ${R.title} yet`,description:`New prints you make here land in it. You can also drop in images or move prints from another folder.`}:null,Ye=[...Ce].sort().join(`|`),Xe=k.filter(e=>e.error!==void 0).length,Ze=(0,q.useMemo)(()=>Se.filter(e=>e.reference.computerId===r.computerId&&!Ye.split(`|`).includes(e.reference.requestId)&&!k.some(t=>t.computerId===e.reference.computerId&&t.path===e.input.destination.path)).map(e=>({key:`${e.reference.computerId}:${e.input.destination.path}`,path:e.input.destination.path,width:1024,height:1280,url:``,pending:!0,error:e.failure?.message??`Stopped when Prints closed. Retry to run it again.`,prompt:e.typed.prompt,onOpen:()=>void 0,onRetry:()=>{Ee.current.resume(e)},onDismiss:()=>{Ee.current.discard(e)}})),[Se,r.computerId,Ye,k]),Qe=(0,q.useMemo)(()=>[...Ze,...oP(qe,k,e=>{let t=ne.items.find(t=>t.id===e.uploadId),r=e.error??(t?.status===`error`||t?.status===`cancelled`?t.message:void 0);return{key:e.key,path:e.path,width:e.width,height:r===void 0?e.height:Math.max(e.height,e.width*1.25),url:``,pending:!0,error:r,prompt:Se.find(t=>t.reference.computerId===e.computerId&&t.input.destination.path===e.path)?.typed.prompt??he.promptAt(e.path),pendingLabel:t?.status===`complete`||pe.has(e.key)?`Loading preview…`:e.uploadId?`Uploading image…`:e.startedAt===void 0?e.pendingLabel:Fn(_e.find(e=>e.kind===`video`),ce-e.startedAt,e.resumed),onOpen:()=>void 0,onStop:r===void 0&&e.uploadId===void 0?()=>{Ee.current.stopPath(e.path)}:void 0,onRetry:r&&(j||t&&t.status!==`complete`)?()=>{if(F(e.key),t&&t.status!==`complete`){We.current.uploads.retry(t.id);return}!e.uploadId&&We.current.retryPath(e.path)||n.current&&We.current.addComputerFile(e.path,n.current,e.computerId)}:void 0,onDismiss:r?()=>{I(e.key),e.uploadId&&We.current.uploads.remove(e.uploadId)}:void 0}})],[Ze,Se,Xe,he.promptAt,pe,qe,k,ne.items,j,_e,ce]),$e=!i&&xe&&be&&M&&C!==null&&ge.kind===`ready`&&!ve&&_e.length>0,et=ne.items.filter(e=>e.computerId===r.computerId),tt=()=>{e&&e.app.ui.openTeamBilling().catch(t=>{tn(`open-team-billing`,t),n.current===e&&he.reportRecoveryError(t)})},nt=[...ge.kind===`error`&&ye===null?[{key:`generation:draft`,mediaKind:ge.mediaKind,message:ge.message,billing:ge.action===`billing`?tt:void 0}]:[],...he.failures.map(e=>({key:e.key,mediaKind:e.mediaKind,message:e.message,billing:e.action===`billing`?tt:void 0,prompt:e.prompt,retry:e.retry,dismiss:()=>{for(let t of k)t.path===e.path&&I(t.key);e.dismiss()}}))],rt=UM({connected:e!==null,mediaCapability:xe,modelsError:ye,retryModels:he.retryModels,modelsLoading:ve,models:_e,canGenerate:be,mediaSetupMissing:i,canWrite:M,generationErrors:nt,recoveryError:we,pendingGenerations:Se,activeGenerations:Ce,atGenerationLimit:he.atLimit,gallerySlots:k,computerId:r.computerId,failed:D,uploadError:ne.error,uploads:et,permissions:()=>{e?.app.ui.requestAppPermissions({}).catch(e=>{he.reportRecoveryError(e)})},resume:e=>{he.resume(e)},discard:e=>{he.discard(e)},retryUpload:e=>{ne.retry(e)}});h.error&&rt.push({key:`dismissal-storage`,group:`Setup`,tone:`warning`,blocking:!0,short:`Activity not saved`,title:`Activity not saved`,detail:h.error});let it=h.visible(rt),at={generating:Ce.size,uploading:et.filter(e=>e.status===`sending`||e.status===`queued`).length},ot={items:et.filter(e=>e.status===`sending`||e.status===`queued`).map(e=>({id:e.id,name:e.file.name,preview:{kind:`image`,url:e.previewUrl},progress:null,progressLabel:``,statusLabel:e.message,actions:{cancel:{label:`Cancel`,accessibleLabel:`Cancel ${e.file.name}`}}})),onCancel:e=>{ne.cancel(e)},onRetry:e=>{ne.retry(e)},onRemove:e=>{ne.remove(e)}},st=new Set([...T.entries.map(e=>`${r.computerId??``}:${e.path}`),...E.map(e=>e.source.kind===`computer`?`${e.source.computerId}:${e.source.path}`:e.file.name)]).size,ct=FM(it,at,d);Bf(e?.app,[...r.available?[bA(r.landingPath??r.path,{checking:r.busy&&r.path===null,editing:r.editing})]:[],...ct===null?[]:[ct],...A?[{kind:`text`,id:`prints`,text:`${String(st)} ${st===1?`print`:`prints`}`}]:[]],e=>e.itemId===`activity`?(m(e.anchor?.start),f(e=>!e),!0):e.itemId!==`folder`||!r.available?!1:(r.setEditing(!0),!0),t=>{tn(`prints.status.report`,t),e?.app.ui.showToast({message:`Prints couldn't update its status bar.`,tone:`error`}).catch(e=>{tn(`prints.status.toast`,e)})});let W=E.flatMap(e=>e.source.kind===`computer`?[{path:e.source.path,url:e.url,width:e.width,height:e.height}]:[]),lt=e=>{y(null),S.current+=1,x({key:e,requestId:`viewer-close-${String(S.current)}`,onFocus:()=>void 0})},ut=(t,n,i)=>(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(DP,{image:t,app:e?.app??null,referenceImages:W,models:_e,canAnimate:SP(_e)!==void 0,operations:{session:he.session,atLimit:he.atLimit,onRun:async(e,n)=>{if(t.source.kind!==`computer`)return;let r=await he.operate({computerId:t.source.computerId,path:t.source.path,width:t.width,height:t.height},e,n);if(r!==null){kP(r);return}_(null),v!==null&<(Rg(t))}},download:i,library:L&&t.source.kind===`computer`&&r.destination!==null&&t.source.path.startsWith(`${r.destination}/`)?(()=>{let e=t.source.path,n=R.isFavorite(e);return{favorite:n,onToggleFavorite:()=>{R.toggleFavorite([e],!n)},onMove:M?()=>{R.setMoving([e])}:void 0}})():void 0,onIterate:(e,n)=>{if(t.source.kind!==`computer`)return null;let r=wP(e,{lineage:n,printComputerId:t.source.computerId,printPath:t.source.path,models:_e,styles:fe.styles.map(e=>e.name),current:Pe.store.state.values});return r.kind===`refused`?r.message:(Fe(r.draft),je(r.notice===null?null:{model:r.draft.model,message:r.notice}),_(null),v!==null&<(Rg(t)),null)},onClose:n},t.url)}),dt={label:`Upload images`,onSelect:()=>Oe.current?.click(),disabled:!M||C===null,disabledReason:`Choose a writable Computer and folder to upload images.`},G=!i&&Je===null&&r.computerId!==null&&r.available&&C===null,ft={label:`Choose folder`,onSelect:()=>{r.setEditing(!0)}},pt=(0,J.jsx)(U,{variant:`ghost`,loading:a,onClick:l,children:`Set up image generation`});return(0,J.jsxs)(`main`,{ref:t,className:`h-full w-full flex flex-col overflow-hidden`,"data-app-pane":`media`,"data-generation-state":ge.kind,"data-computer-capability":A?`connected`:`absent`,onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&M&&(e.preventDefault(),re(t.map(e=>(ke.current+=1,new File([e],`paste-${String(ke.current)}-${Pg(e.name)}`,{type:e.type,lastModified:e.lastModified})))))},children:[(0,J.jsx)(ag,{id:`prints-generation-notices`}),(0,J.jsxs)(`div`,{className:`prints-library`,"data-library":L||void 0,children:[L&&r.destination?(0,J.jsx)(cA,{app:e.app,root:r.destination,view:r.view,onView:R.history.open,canWrite:M,version:R.version,onNewFolder:e=>{R.setNewFolder({parent:e})},onDrop:(e,t)=>{R.move(e,t)},onRename:(e,t)=>{R.move([e],R.folderOf(r.destination??``,e),{name:t})},onMoveRows:R.setMoving}):null,(0,J.jsxs)(`div`,{className:`prints-library-main`,"data-selecting":R.selecting||void 0,children:[L?(0,J.jsxs)(J.Fragment,{children:[se?null:(0,J.jsx)(dA,{view:r.view,lastFolder:R.lastFolder,onOpen:R.history.open,onFolders:()=>{ae(!0)},subfolders:r.view.kind===`folder`?w.gallery.folders:[],onOpenSubfolder:e=>{R.history.open({kind:`folder`,folder:r.view.kind===`folder`&&r.view.folder?`${r.view.folder}/${e}`:e})}}),R.selecting?(0,J.jsx)(uA,{count:R.selected.size,total:T.entries.length,canWrite:M,onToggleAll:()=>{R.selectAll(R.selected.size===T.entries.length?[]:T.entries.map(e=>e.path))},onMove:()=>{R.setMoving([...R.selected])},onFavorite:()=>{R.toggleFavorite([...R.selected],!0)},onDone:()=>{R.setSelecting(!1)}}):null]}):null,(0,J.jsxs)(`div`,{className:`prints-gallery-region`,children:[(0,J.jsx)(gh,{screen:!0,ref:De,className:`prints-gallery-scroll flex-1 min-h-0`,"data-media-scroll":!0,"aria-busy":O||T.loading,onDragOver:e=>{e.preventDefault()},onDrop:e=>{e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&&M&&re(t)},children:(0,J.jsxs)(`div`,{className:`prints-gallery-content`,children:[Qe.length>0?(0,J.jsx)(aP,{items:L?Qe.map(R.enrich):Qe,scrollRef:De,focus:v===null?b??(de&&B.target?{key:`${B.target.computerId}:${B.target.path}`,requestId:B.target.requestId,onFocus:()=>{_(null),y(Rg(de))}}:void 0):void 0}):O||T.loading?(0,J.jsx)(Ry,{"data-media-loading":!0,framed:!1,message:`Loading prints…`,detail:`Your library is on its way.`,variant:`wander`}):(0,J.jsx)(Iy,{"aria-live":`polite`,"data-absence":!0,"data-media-empty":!0,role:`status`,variant:`speech`,className:`prints-invitation`,visual:`blobs`,title:i?`Make and collect images`:Je?.title??`Make your first print`,description:i?`Upload images to start your collection. Open any image to view or download it.`:Je===null?r.computerId===null?`Your images will appear here.`:G?`Choose where Prints saves, then describe something.`:`Describe something and it lands here, or drop in images from your Computer.`:Je.description,primaryAction:i?dt:G?ft:void 0,actions:G?void 0:i?(0,J.jsxs)(`div`,{className:`prints-image-setup`,children:[(0,J.jsx)(`span`,{children:u}),pt]}):(0,J.jsx)(U,{variant:`ghost`,size:`sm`,disabled:!M||C===null,onClick:()=>Oe.current?.click(),children:`Upload images`}),suggestions:i||G?void 0:OP.map(e=>({label:e,disabled:!$e,onSelect:()=>{Pe.setFieldValue(`prompt`,e),t.current?.querySelector(`[data-generation-prompt]`)?.focus()}}))}),T.hasNextPage&&(0,J.jsx)(U,{variant:`ghost`,disabled:T.loading,onClick:T.loadMore,children:T.loading?`Loading images…`:`Load more images`})]})}),g&&(g.source.kind===`local`||g.source.connection===e&&g.source.computerId===r.computerId)?ut(g,()=>{_(null)}):null]})]})]}),L&&r.destination?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(fA,{app:e.app,root:r.destination,from:r.view.kind===`folder`?{folder:r.view.folder}:null,canWrite:M,count:R.moving?.length??0,open:R.moving!==null,version:R.version,onClose:()=>{R.setMoving(null)},onMove:(e,t)=>{let n=R.moving??[];R.setMoving(null),R.setSelecting(!1),R.move(n,e,{create:t})}}),(0,J.jsx)(hA,{parent:R.newFolder?.parent,open:R.newFolder!==null,onClose:()=>{R.setNewFolder(null)},onCreate:e=>R.createFolder(R.newFolder?.parent,e)}),(0,J.jsx)(cm,{open:ie,onOpenChange:ae,children:(0,J.jsxs)(pm,{className:`prints-folders-dialog`,children:[(0,J.jsx)(hm,{children:(0,J.jsx)(gm,{children:`Folders`})}),(0,J.jsx)(cA,{app:e.app,root:r.destination,view:r.view,onView:e=>{R.history.open(e),ae(!1)},canWrite:M,version:R.version,onNewFolder:e=>{ae(!1),R.setNewFolder({parent:e})},onMoveRows:R.setMoving})]})})]}):null,(0,J.jsx)(v_,{items:Qe,images:E,viewerKey:v,app:e?.app??null,onNavigate:y,onClose:lt,renderInfo:(e,t)=>ut(e,t,null)}),i&&Qe.length>0?(0,J.jsxs)(`div`,{className:`prints-library-actions`,children:[(0,J.jsx)(U,{size:`sm`,onClick:dt.onSelect,disabled:dt.disabled,children:`Upload images`}),pt,s?(0,J.jsx)(`div`,{className:`prints-image-setup`,children:u}):null]}):null,(0,J.jsxs)(`div`,{className:`prints-composer-dock`,children:[(0,J.jsx)(`section`,{"aria-label":`Computer uploads`,className:`prints-uploads`,children:(0,J.jsx)(`input`,{ref:Oe,type:`file`,disabled:!M||C===null,accept:`image/*`,multiple:!0,hidden:!0,"aria-label":`Choose images to upload`,onChange:e=>{re(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),i?null:(0,J.jsx)(PP,{addedLength:He?.kind===`audio`?0:lr(Le.prompt,fe.styles.find(e=>e.name===Le.style)?.text,V.characters),styleControls:e=>({picker:(0,J.jsx)(TP,{styles:fe.styles,selected:Le.style,disabled:!xe||ve||Be,onSelect:e=>{Pe.setFieldValue(`style`,e)}}),dialog:(0,J.jsx)(EP,{open:e.open,onOpenChange:e.onOpenChange,styles:fe.styles,selected:Le.style,busy:fe.busy,error:fe.error,onSelect:e=>{Pe.setFieldValue(`style`,e)},onSave:fe.save,onDelete:(e,t)=>{fe.remove(e.id,t)}})}),characters:V.characters,characterDialog:e=>(0,J.jsx)(dP,{open:e.open,onOpenChange:e.onOpenChange,characters:V.characters,images:W,busy:V.busy,error:V.error,canUpload:M&&C!==null,onUpload:()=>Oe.current?.click(),onSave:V.save,onDelete:(e,t)=>{V.remove(e.id,t)}}),guidance:it.find(e=>e.blocking&&e.group===`Setup`)??(Ae!==null&&Ae.model===Le.model?{key:`iteration-model`,group:`Images`,tone:`warning`,short:`Model changed`,title:`Model changed`,detail:Ae.message,actions:[{label:`Dismiss`,run:()=>{je(null)}}]}:void 0),commandApp:Ve,actions:(0,J.jsx)(_t,{"aria-label":`Upload images`,title:M?`Upload images to Computer`:`Connect a writable Computer to upload`,icon:(0,J.jsx)(Lh,{}),label:null,className:`prints-upload-key`,disabled:!M||C===null,onClick:()=>Oe.current?.click()}),form:Pe,mediaCapability:xe&&be&&M&&C!==null,models:_e,modelsLoading:ve,onSubmit:Pe.submitCurrent,submitting:Be,generateLimitReason:he.atLimit?wr:void 0,values:Le,computerId:r.computerId,mediaDirectory:C,referenceImages:W,referenceLabels:Re,price:ze}),ct===null?null:(0,J.jsx)(LM,{notices:it,uploads:ot,open:d,inset:p,onOpenChange:f,onDismiss:h.dismiss,onDismissAll:()=>{h.dismissAll(rt)},onLoadMore:he.hasMore?he.loadMore:void 0})]}),(0,J.jsx)(zM,{folder:r})]})}var IP=document.getElementById(`media-root`);if(!IP)throw Error(`Media root is missing`);Ff(IP,{name:`Prints`,queryClient:ni()},({app:e})=>(0,q.createElement)(FP,{connection:e?{app:e}:null}));
|
|
1267
|
+
}`}var zx=new WeakMap;function Bx(e){let t=zx.get(e);if(t!=null)return t;let n=document.createElement(`div`);n.setAttribute(ab,`true`);let r=document.createElement(`div`);r.style.position=`relative`,r.style.height=`200%`,n.appendChild(r),e.appendChild(n);let i=Math.max(n.offsetWidth-n.clientWidth,0);return n.remove(),zx.set(e,i),i}function Vx(e,t){if(!e.isConnected)return;let n=Bx(t);if(n==null)return;let r=t.querySelector(`style[${ob}]`),i=r instanceof HTMLStyleElement?r:document.createElement(`style`);r instanceof HTMLStyleElement||(i.setAttribute(ob,``),t.appendChild(i)),i.textContent=`:host { ${sb}: ${n}px; }`}var Hx;function Ux(e){if(typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`&&`adoptedStyleSheets`in e){Hx??(Hx=new CSSStyleSheet,Hx.replaceSync(Lx(Fx)));let t=!1;try{e.adoptedStyleSheets=[Hx],t=!0}catch{}if(t){e.querySelector(`style[${rb}]`)?.remove();return}}if(e.querySelector(`style[data-file-tree-style]`)==null){let t=document.createElement(`style`);t.setAttribute(rb,``),t.textContent=Lx(Fx),e.prepend(t)}}function Wx(e,t){Gx(e,t),Ux(t),Vx(e,t)}function Gx(e,t){let n=e.querySelector(`template[shadowrootmode="open"], template[data-file-tree-shadowrootmode="open"]`);n instanceof HTMLTemplateElement&&(t.childNodes.length>0||(t.appendChild(n.content.cloneNode(!0)),n.hasAttribute(`shadowrootmode`)&&n.remove()))}if(typeof HTMLElement<`u`&&customElements.get(`file-tree-container`)==null){class e extends HTMLElement{constructor(){super()}connectedCallback(){let e=this.shadowRoot??this.attachShadow({mode:`open`});Wx(this,e)}}if(customElements.define(nb,e),typeof document<`u`)for(let e of Array.from(document.querySelectorAll(nb)))e instanceof HTMLElement&&Wx(e,e.shadowRoot??e.attachShadow({mode:`open`}))}var Kx=5,qx=32,Jx=128;function Yx(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Xx(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Zx(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 Qx(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 $x(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function eS(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 tS(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,aS(e,t)}function nS(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=Qx(e).get(t);if(i===void 0)return;let a=i>>Kx;e.childVisibleChunkSums[a]+=r}function rS(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=oS(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=qx}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 iS(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>Kx;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<Kx}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 aS(e,t){if(t.childIds.length<Jx){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/qx),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>>Kx]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function oS(e,t,n,r){let i=Math.min(t.childIds.length,n+qx),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 sS=7,cS=3,lS=8,uS=4;function dS(e,t,n=0){return e<<uS|n<<cS|t}function fS(e){return e.depthAndFlags>>>uS}function pS(e){return(e.depthAndFlags&lS)>>cS}function Y(e){return(e.depthAndFlags&lS)!==0}function mS(e){return e.depthAndFlags&sS}function hS(e,t){return(mS(e)&t)!==0}function gS(e,t){e.depthAndFlags|=t}function _S(e,t){e.depthAndFlags=dS(t,mS(e),pS(e))}var vS=Symbol(`benchmarkInstrumentation`);function yS(e,t){return t==null||Object.defineProperty(e,vS,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function bS(e){return e==null?null:e[vS]??null}function X(e,t,n){return e==null?n():e.measurePhase(t,n)}function xS(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function SS(e){return e>=48&&e<=57}function CS(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!SS(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&&SS(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 wS(e){let t=e.toLowerCase();return{lowerValue:t,tokens:CS(t)}}function TS(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 ES(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=TS(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function DS(e,t,n){let r=ES(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function OS(e,t){return DS(e,t,wS)}function kS(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function AS(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=kS(e,r);return a===kS(t,r)?OS(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 jS(e,t){return AS(e,t)}function MS(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=wS(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=kS(e,n);return o===kS(t,n)?DS(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 NS(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=wS(r);return e.sortKeyById[t]=i,i}function PS(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function FS(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 IS(e){let{hasTrailingSlash:t,segments:n}=FS(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function LS(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=FS(e);return{requiresDirectory:t,segments:n}}function RS(){let e=new Map;return e.set(``,0),{idByValue:e,valueById:[``],sortKeyById:[wS(``)]}}function zS(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 BS(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var VS=Symbol(`pathStorePreparedInputKind`);function HS(e,t){return e[VS]=t,e}function US(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function WS(e,t,n){return n==="default"?jS(e,t):n(US(e),US(t))}function GS(){return{depthAndFlags:dS(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function KS(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 qS(e){return e.isDirectory?e.segments.length:e.segments.length-1}function JS(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 YS(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function XS(e,t={}){return nC(e,t).map(e=>e.path)}function ZS(e,t={}){let n=nC(e,t);return HS({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function QS(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 HS({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function $S(e){let t=e,n=t.preparedPaths;if(t[VS]===`prepared`&&n!=null)return n;if(!JS(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function eC(e){let t=e;return t[VS]===`presorted`&&t.presortedPaths!=null||YS(t.presortedPaths)?t.presortedPaths:null}function tC(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function nC(e,t={}){let n=PS(t),r=bS(t);xS(r,`workload.inputFiles`,e.length);let i=X(r,`store.preparePathEntries.parse`,()=>e.map(e=>IS(e)));return X(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>WS(e,t,n.sort))),i}var rC=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[GS()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=RS();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=bS(e),this.options=PS(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,Yx())}appendPaths(e){return X(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>IS(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,X(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return X(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:dS(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:dS(r,0,1),nameId:u,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),l++,c[l]=d,m=a+1}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:dS(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=IS(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:dS(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:dS(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=IS(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(X(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||X(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"?MS(this.lastPreparedPath,e,this.segmentSortKeyCache):WS(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=qS(e),i=n==null?0:qS(n),a=n==null?0:KS(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=zS(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:dS(fS(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),$x(i,s),s}createFileChildUnchecked(e,t){let n=zS(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:dS(fS(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),$x(r,a),a}getOrCreateDirectoryChild(e,t){let n=zS(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&&!Y(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:dS(fS(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),$x(r,a),this.directories.set(a,Yx()),a}createDirectoryChild(e,t){let n=zS(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:dS(fS(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),$x(r,a),this.directories.set(a,Yx()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!Y(n))throw Error(`Path is not a directory: "${t}"`);if(hS(n,1))throw Error(`Duplicate path: "${t}"`);gS(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,Xx());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(Y(a)){let t=Xx();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;Y(n)&&this.directories.set(t,Yx());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),$x(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!Y(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 tS(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function iC(e,t=`closed`,n=null){let r=oC(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 aC(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function oC(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 sC(e,t){return hS(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion!==`closed`&&fS(t)<=e.defaultExpansion}function cC(e,t,n=e.snapshot.nodes[t]){return n==null||!Y(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:sC(e,n)}function lC(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!Y(r))return;let i=sC(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 uC(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 dC(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function fC(e,t){let n=uC(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 pC(e,t){let n=uC(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function mC(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 hC(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function gC(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 _C(e,t){e.directoryLoadInfoById.delete(t)}function vC(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 yC(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function bC(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function xC(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function SC(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function CC(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function wC(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function TC(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 EC(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 DC(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 OC(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 kC(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 AC(e,t,n){return{...n,visibleCountDelta:VC(e)-t}}function jC(e,t){let n=VC(e),r=aC();e.transactionStack.push(r);try{t()}catch(t){throw PC(e,r,!1),t}PC(e,r,!0,VC(e)-n)}function MC(e,t){let n=e.instrumentation;if(n==null){NC(e,t);return}X(n,`store.events.record`,()=>NC(e,t))}function NC(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){zC(e,t);return}n.events.push(t),RC(n,t)}function PC(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?LC(i,t):X(n,`store.events.batch.merge`,()=>LC(i,t));return}let a=FC(t,r),o=e.instrumentation;if(o==null){zC(e,a);return}X(o,`store.events.batch.commit`,()=>zC(e,a))}function FC(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 IC(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function LC(e,t){for(let n of t.events)e.events.push(n);IC(e,t)}function RC(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function zC(e,t){let n=e.instrumentation;if(n==null){BC(e,t);return}X(n,`store.events.emit`,()=>BC(e,t))}function BC(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function VC(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function HC(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!Y(n)||hS(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||!Y(a)?null:i}function UC(e,t){let n=t;for(;;){let t=HC(e,n);if(t==null)return n;n=t}}function WC(e,t){let n=[t],r=t;for(;;){let t=HC(e,r);if(t==null)return n;n.push(t),r=t}}function GC(e,t){let n=t==null?e.snapshot.rootId:tw(e,t);return n==null?[]:iw(e,n)}function KC(e,t){let n=IS(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=yw(e,vw(e,r)),{createdNodeIds:a,directoryId:o}=aw(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=Z(e,o);if(hS(n,1))throw Error(`Path already exists: "${t}"`);gS(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=sw(e,o,n.basename),s.add(c);QC(e,o);let l=yw(e,o);return yC({affectedAncestorIds:ew(e,c),affectedNodeIds:[...s],path:t,projectionChanged:bw(i,l)})}function qC(e,t,n){let r=tw(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=Z(e,r);if(hS(i,2))throw Error(`The root node cannot be removed`);if(Y(i)&&rw(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=yw(e,a),s=gw(e,r);uw(e,a,r,i.nameId),_w(e,a),QC(e,a);let c=yw(e,a);return bC({affectedAncestorIds:ew(e,a),affectedNodeIds:s,path:t,projectionChanged:bw(o,c),recursive:n.recursive===!0})}function JC(e,t,n,r){let i=tw(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=Z(e,i);if(hS(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=mw(e,i,n),c=yw(e,a.parentId),l=yw(e,s.parentId),u=BS(e.snapshot.segmentTable,a.nameId),d=zS(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(Y(a)&&ww(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=Zx(e.snapshot.nodes,rw(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&hw(e,p,o,pS(a))===`skip`)return null;let m=a.parentId;uw(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),Cw(e,i),lw(e,s.parentId,i),_w(e,m),e.pathCacheVersion++,QC(e,m),s.parentId!==m&&QC(e,s.parentId);let h=yw(e,m),g=yw(e,s.parentId);return xC({affectedAncestorIds:[...new Set([...ew(e,m),...ew(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:xw([c,l],[h,g]),to:ZC(e,i)})}function YC(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function XC(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function ZC(e,t){let n=Z(e,t),r=YC(e,t);if(r!=null)return r;if(hS(n,2))return XC(e,t,``);let i=ZC(e,n.parentId),a=BS(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return XC(e,t,Y(n)?`${o}/`:o)}function QC(e,t){let n=e.instrumentation;if(n==null){Ew(e,t);return}X(n,`store.recomputeCountsUpwardFrom`,()=>Ew(e,t))}function $C(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||!Y(o)){Tw(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){Tw(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function ew(e,t){let n=[],r=t;for(;r!=null;){let t=Z(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function tw(e,t){if(t.length===0)return e.snapshot.rootId;let n=LS(t);return nw(e,n.segments,n.requiresDirectory)}function nw(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=rw(e,r),a=Zx(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=Z(e,r);return n&&!Y(i)?null:r}function rw(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 Z(e,t){let n=e.snapshot.nodes[t];if(n===void 0||hS(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function iw(e,t){let n=e.snapshot.nodes[t];if(n===void 0||hS(n,4))return[];if(!Y(n))return[ZC(e,t)];if(rw(e,t).childIds.length===0)return hS(n,1)&&!hS(n,2)?[ZC(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||hS(n,4)){i.pop();continue}if(!Y(n)){r.push(ZC(e,t.nodeId)),i.pop();continue}let a=rw(e,t.nodeId);if(a.childIds.length===0){hS(n,1)&&!hS(n,2)&&r.push(ZC(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 aw(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=zS(e.snapshot.segmentTable,i),a=rw(e,r),o=Zx(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!Y(Z(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=ow(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function ow(e,t,n){let r=Z(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:dS(fS(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,Yx()),lw(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function sw(e,t,n){let r=zS(e.snapshot.segmentTable,n),i=rw(e,t);if(Zx(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${Ow(e,t,n)}"`);let a=Z(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:dS(fS(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),lw(e,t,o),e.activeNodeCount++,o}function cw(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}dw(e,n,o)<0?i=a:r=a+1}return r}function lw(e,t,n){let r=rw(e,t),i=Z(e,n);Zx(e.snapshot.nodes,r).set(i.nameId,n),nS(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=cw(e,r,n);r.childIds.splice(a,0,n),eS(r,a),aS(e.snapshot.nodes,r)}function uw(e,t,n,r){let i=rw(e,t),a=Qx(i),o=a.get(n)??-1;Zx(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&nS(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),eS(i,o),aS(e.snapshot.nodes,i))}function dw(e,t,n){let r=e.snapshot.options.sort;return r==="default"?fw(e,t,n):r(pw(e,t),pw(e,n))}function fw(e,t,n){let r=Z(e,t),i=Z(e,n),a=Y(r);if(a!==Y(i))return a?-1:1;let o=ES(NS(e.snapshot.segmentTable,r.nameId),NS(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=BS(e.snapshot.segmentTable,r.nameId),c=BS(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function pw(e,t){let n=Z(e,t),r=ZC(e,t),i=Y(n),a=i?r.slice(0,-1):r;return{basename:BS(e.snapshot.segmentTable,n.nameId),depth:fS(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function mw(e,t,n){let r=Z(e,t),i=tw(e,n);if(i!=null){let t=Z(e,i);if(Y(t))return{basename:BS(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=LS(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=LS(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:nw(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function hw(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${ZC(e,t)}"`);let i=Z(e,t);if(pS(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(Y(i)&&rw(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return gw(e,t),uw(e,a,t,o),_w(e,a),QC(e,a),`handled`}function gw(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=Z(e,t.nodeId);if(t.visitedChildren||!Y(i)){Y(i)&&e.snapshot.directories.delete(t.nodeId),gS(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),_C(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=rw(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 _w(e,t){let n=t;for(;n!=null;){let t=Z(e,n);if(!Y(t)||hS(t,2)||rw(e,n).childIds.length>0)return;gS(t,1),n=t.parentId===n?null:t.parentId}}function vw(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=Zx(e.snapshot.nodes,rw(e,n)).get(t);if(i==null||!Y(Z(e,i)))break;n=i}return n}function yw(e,t){let n=Sw(e,t);if(n==null)return null;let r=UC(e,n),i=Z(e,r),a=n===r?null:WC(e,n).map(t=>ZC(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:rw(e,r).childIds.length>0,path:ZC(e,r),terminalKind:pS(i)})}function bw(e,t){return xw([e],[t])}function xw(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 Sw(e,t){let n=t;for(;n!=null;){let t=Z(e,n);if(!Y(t)||hS(t,2))return null;if(!cC(e,n,t))return n;n=t.parentId}return null}function Cw(e,t){let n=Z(e,t);if(_S(n,(t===e.snapshot.rootId?-1:fS(Z(e,n.parentId)))+1),!Y(n))return;let r=rw(e,t);for(let t of r.childIds)Cw(e,t)}function ww(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=Z(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function Tw(e,t,n=Z(e,t),r=!1){let i=e.instrumentation;if(i==null){Dw(e,t,n,r);return}X(i,`store.recomputeNodeCounts`,()=>Dw(e,t,n,r))}function Ew(e,t){let n=t;for(;n!=null;){let t=Z(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(Tw(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&nS(rw(e,s),n,a,o),n=s}}function Dw(e,t,n,r){if(!Y(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=rw(e,t);if(r){let t=e.instrumentation;t==null?tS(e.snapshot.nodes,i):X(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>tS(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,hS(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=HC(e,t)==null?cC(e,t,n)?1+o:1:o}function Ow(e,t,n){let r=ZC(e,t);return r.length===0?n:`${r}${n}`}function kw(e){return e!=null&&!hS(e,4)}function Aw(e,t){let n=e.snapshot.nodes[t];return!kw(n)||!Y(n)||hS(n,2)?null:n}function jw(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&kw(e.snapshot.nodes[n])&&(t+=1);return t}function Mw(e){return Math.max(0,e.valueById.length-1)}function Nw(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:jw(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:Mw(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function Pw(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 Fw(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)Aw(e,n)!=null&&t.push(ZC(e,n));for(let t of e.expandedDirectoryIds)Aw(e,t)!=null&&n.push(ZC(e,t));return{collapsedPaths:t,expandedPaths:n}}function Iw(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)Aw(e,n)!=null&&dC(e,n)!==`loaded`&&t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:ZC(e,n)});return t}function Lw(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=tw(e,n);t!=null&&lC(e,t,!0,Z(e,t))}for(let n of t.collapsedPaths){let t=tw(e,n);t!=null&&lC(e,t,!1,Z(e,t))}}function Rw(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=tw(e,n.path);t!=null&&Aw(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function zw(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function Bw(e){let t=e.snapshot.segmentTable,n=RS();for(let r of e.snapshot.nodes)if(kw(r)){if(hS(r,2)){r.nameId=0;continue}r.nameId=zS(n,BS(t,r.nameId))}e.snapshot.segmentTable=n}function Vw(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!kw(r)||!Y(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return kw(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[Z(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),tS(e.snapshot.nodes,n)}}function Hw(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(kw(n))break;--t}e.snapshot.nodes.length=t+1}function Uw(e){let t=Fw(e),n=Iw(e);X(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>zw(e)),X(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>Bw(e)),X(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>Vw(e)),X(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>Hw(e)),X(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>Lw(e,t)),X(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>Rw(e,n)),X(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>$C(e,e.snapshot.rootId))}function Ww(e){let t=Fw(e),n=Iw(e),r=X(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>GC(e)),i=yS({...e.snapshot.options},e.instrumentation),a=X(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new rC(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,X(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>Lw(e,t)),X(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>Rw(e,n)),X(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>$C(e,e.snapshot.rootId))}function Gw(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function Kw(e,t){let n=Nw(e);t===`stable`?X(e.instrumentation,`store.cleanup.stable`,()=>Uw(e)):X(e.instrumentation,`store.cleanup.aggressive`,()=>Ww(e));let r=Nw(e);return Pw(t,t===`stable`,n,r)}var qw=64;function Jw(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 Yw(e){return Z(e,e.snapshot.rootId).visibleSubtreeCount}function Xw(e,t,n,r){let i=Z(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function Zw(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:gT(e,t.cursor),setSize:t.setSize,subtreeEndIndex:Xw(e,t.cursor,t.index,n)}}function Qw(e,t,n,r,i,a){let o=rw(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=rS(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return $w(e,u,l,r+c,i+1,s,o.childIds.length,a)}function $w(e,t,n,r,i,a,o,s){if(!Y(Z(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=uT(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=Z(e,c.terminalNodeId);if(!Y(l)||!cC(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Qw(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function eT(e,t){let n=Yw(e);if(t<0||t>=n)return null;let r=Qw(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>ZC(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=Zw(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:gT(e,r.cursor),setSize:r.setSize,subtreeEndIndex:Xw(e,r.cursor,r.index,n)}}function tT(e,t,n){let r=e.instrumentation,i=Yw(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 hT(e,o+1);let t=[],n=sT(e,a);for(let r=a;r<=o&&n!=null;r++){let r=gT(e,n);t.push(r),n=fT(e,n)}return t}let s=[],c=0,l=0,u=X(r,`store.getVisibleSlice.selectFirstRow`,()=>sT(e,a));for(let t=a;t<=o&&u!=null;t++){let t=X(r,`store.getVisibleSlice.materializeRow`,()=>gT(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=X(r,`store.getVisibleSlice.advanceCursor`,()=>fT(e,u))}return xS(r,`workload.visibleRowsRead`,s.length),xS(r,`workload.flattenedRowsRead`,c),xS(r,`workload.flattenedSegmentsRead`,l),s}function nT(e,t=Yw(e)){let n=e.instrumentation;return n==null?mT(e,t):X(n,`store.getVisibleTreeProjection`,()=>mT(e,t))}function rT(e){return pT(nT(e))}function iT(e,t){let n=tw(e,t);if(n==null||n===e.snapshot.rootId||Y(Z(e,n))&&UC(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=Z(e,i).parentId,n=rw(e,t),s=Qx(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=iS(a,n,s),t!==o){let n=Z(e,t),a=HC(e,t);if(!cC(e,t,n)&&a!==i)return null;UC(e,t)===t&&(r+=1)}i=t}return r}function aT(e,t){let n=tw(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=Z(e,n);if(!Y(r))throw Error(`Path is not a directory: "${t}"`);return cC(e,n,r)?null:(lC(e,n,!0,r),QC(e,n),SC({affectedAncestorIds:ew(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function oT(e,t){let n=tw(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=Z(e,n);if(!Y(r))throw Error(`Path is not a directory: "${t}"`);return cC(e,n,r)?(lC(e,n,!1,r),QC(e,n),CC({affectedAncestorIds:ew(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function sT(e,t){return t<0||t>=Yw(e)?null:cT(e,e.snapshot.rootId,t,-1)}function cT(e,t,n,r){let i=rw(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?rS(e.snapshot.nodes,i,n):X(a,`store.getVisibleSlice.selectChildIndex`,()=>rS(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return lT(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function lT(e,t,n,r){if(!Y(Z(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=uT(e,t,r);if(n===0)return i;let a=Z(e,i.terminalNodeId);if(!Y(a)||!cC(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return cT(e,i.terminalNodeId,n-1,i.visibleDepth)}function uT(e,t,n){return Y(Z(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:UC(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:X(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>UC(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function dT(e,t){let n=Z(e,t);if(!Y(n))return!0;let r=n.parentId;return r===e.snapshot.rootId||HC(e,r)!==t}function fT(e,t){let n=Z(e,t.terminalNodeId);if(Y(n)){let r=rw(e,t.terminalNodeId);if(cC(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:lT(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=Z(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=rw(e,n),o=Qx(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 lT(e,s,0,i);dT(e,r)&&i--,r=n}}function pT(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 mT(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(qw);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=Jw(o,y);let x,S=_;if(Y(v))S=f?UC(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:ZC(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&&Y(C)&&cC(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 hT(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(!Y(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:ZC(e,f)};continue}let h=l?UC(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=gT(e,g);let _=i[h];_!=null&&Y(_)&&cC(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function gT(e,t){let n=Z(e,t.terminalNodeId),r=Y(n)?_T(e,t):null,i=ZC(e,t.terminalNodeId),a=BS(e.snapshot.segmentTable,n.nameId),o=Y(n)&&rw(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?WC(e,t.headNodeId).map(n=>{let r=Z(e,n);return{isTerminal:n===t.terminalNodeId,name:BS(e.snapshot.segmentTable,r.nameId),nodeId:n,path:ZC(e,n)}}):X(c,`store.getVisibleSlice.flatten.collectSegments`,()=>WC(e,t.headNodeId).map(n=>{let r=Z(e,n);return{isTerminal:n===t.terminalNodeId,name:BS(e.snapshot.segmentTable,r.nameId),nodeId:n,path:ZC(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:Y(n)&&cC(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:Y(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function _T(e,t){if(t.headNodeId===t.terminalNodeId)return dC(e,t.terminalNodeId);let n=WC(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=dC(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}var vT=8;function yT(e){let{nodes:t,directories:n,rootId:r,options:i}=e,a=t.length,o=new Int32Array(a),s=new Int32Array(a),c=new Int32Array(a),l=new Int32Array(a),u=new Int32Array(a),d=new Int32Array(a),f=new Int32Array(a);for(let e=0;e<a;e+=1){let n=t[e];n!=null&&(o[e]=n.parentId,s[e]=n.nameId,c[e]=n.depthAndFlags,l[e]=n.subtreeNodeCount,u[e]=n.visibleSubtreeCount)}let p=0;for(let e of n.values())p+=e.childIds.length;let m=new Int32Array(p),h=0;for(let[e,t]of n){let n=t.childIds;d[e]=h,f[e]=n.length;for(let e=0;e<n.length;e+=1)m[h]=n[e],h+=1}return{nodeCount:a,rootId:r,flattenEmptyDirectories:i.flattenEmptyDirectories===!0,parentId:o,nameId:s,depthAndFlags:c,subtreeNodeCount:l,visibleSubtreeCount:u,childStart:d,childCount:f,childIdsFlat:m}}function bT(e){let{nodeCount:t,rootId:n,flattenEmptyDirectories:r,depthAndFlags:i,subtreeNodeCount:a,visibleSubtreeCount:o,childStart:s,childCount:c,childIdsFlat:l}=e;for(let e=t-1;e>=1;--e){if((i[e]&vT)===0)continue;let t=s[e],n=c[e],u=0,d=0;for(let e=0;e<n;e+=1){let n=l[t+e];u+=a[n],d+=o[n]}a[e]=1+u;let f;f=r&&n===1?(i[l[t]]&vT)===0?1+d:d:1+d,o[e]=f}let u=s[n],d=c[n],f=0,p=0;for(let e=0;e<d;e+=1){let t=l[u+e];f+=a[t],p+=o[t]}a[n]=1+f,o[n]=p}function xT(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||!Y(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&&aS(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&Y(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,aS(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function ST(e){let{directories:t,nodes:n,rootId:r}=e.snapshot,i=yT(e.snapshot);bT(i);let a=i.subtreeNodeCount,o=i.visibleSubtreeCount;for(let e=0;e<n.length;e+=1){let t=n[e];t!=null&&(t.subtreeNodeCount=a[e],t.visibleSubtreeCount=o[e])}for(let[e,i]of t){let t=i.childIds,a=t.length,o=0,s=0;for(let e=0;e<a;e++){let r=t[e];if(r==null)continue;let i=n[r];o+=i.subtreeNodeCount,s+=i.visibleSubtreeCount}i.totalChildSubtreeNodeCount=o,i.totalChildVisibleSubtreeCount=s,(e===r||a>=128)&&aS(n,i)}}function CT(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var wT=class e{#e;constructor(e={}){let t=bS(e),n=X(t,`store.builder.create`,()=>new rC(e));if(e.preparedInput!=null){let t=eC(e.preparedInput);t==null?n.appendPreparedPaths($S(e.preparedInput),!1):n.appendPresortedPaths(t,tC(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(X(t,`store.preparePathEntries`,()=>nC(r,e)))}let r=X(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=X(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=X(t,`store.state.create`,()=>iC(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:X(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||CT(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&X(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?e.useSoaCountSweep===!0?X(t,`store.state.initializeOpenVisibleCountsViaSoa`,()=>ST(this.#e)):X(t,`store.state.initializeOpenVisibleCounts`,()=>xT(this.#e)):X(t,`store.state.recomputeCounts`,()=>$C(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return XS(e,t)}static prepareInput(e,t={}){return ZS(e,t)}static preparePresortedInput(e){return QS(e)}list(e){return X(this.#e.instrumentation,`store.list`,()=>GC(this.#e,e))}add(e){X(this.#e.instrumentation,`store.add`,()=>{let t=Yw(this.#e);MC(this.#e,AC(this.#e,t,KC(this.#e,e)))})}remove(e,t={}){X(this.#e.instrumentation,`store.remove`,()=>{let n=Yw(this.#e);MC(this.#e,AC(this.#e,n,qC(this.#e,e,t)))})}move(e,t,n={}){X(this.#e.instrumentation,`store.move`,()=>{let r=Yw(this.#e),i=JC(this.#e,e,t,n);i!=null&&MC(this.#e,AC(this.#e,r,i))})}batch(e){jC(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})}})}getVisibleCount(){return X(this.#e.instrumentation,`store.getVisibleCount`,()=>Yw(this.#e))}getVisibleSlice(e,t){return X(this.#e.instrumentation,`store.getVisibleSlice`,()=>tT(this.#e,e,t))}getVisibleRowContext(e){return X(this.#e.instrumentation,`store.getVisibleRowContext`,()=>eT(this.#e,e))}getVisibleTreeProjection(){return rT(this.#e)}getVisibleTreeProjectionData(e){return nT(this.#e,e)}getVisibleIndex(e){return X(this.#e.instrumentation,`store.getVisibleIndex`,()=>iT(this.#e,e))}getPathInfo(e){return X(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=tw(this.#e,e);if(t==null)return null;let n=Z(this.#e,t);return{depth:fS(n),kind:Y(n)?`directory`:`file`,path:ZC(this.#e,t)}})}isExpanded(e){return X(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=Z(this.#e,t);return cC(this.#e,t,n)})}expand(e){X(this.#e.instrumentation,`store.expand`,()=>{let t=Yw(this.#e),n=aT(this.#e,e);n!=null&&MC(this.#e,AC(this.#e,t,n))})}collapse(e){X(this.#e.instrumentation,`store.collapse`,()=>{let t=Yw(this.#e),n=oT(this.#e,e);n!=null&&MC(this.#e,AC(this.#e,t,n))})}on(e,t){return vC(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return dC(this.#e,t)}markDirectoryUnloaded(e){X(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(rw(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=Yw(this.#e);pC(this.#e,t),MC(this.#e,AC(this.#e,n,wC({affectedAncestorIds:ew(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return X(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=Yw(this.#e),r=fC(this.#e,t);return MC(this.#e,AC(this.#e,n,TC({affectedAncestorIds:ew(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return X(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||dC(this.#e,n)!==`loading`||!hC(this.#e,n,e.attemptId))return!1;let r=ZC(this.#e,n);this.validateChildPatch(r,t);let i=Yw(this.#e),a=[];for(let e of t.operations){TT(r,e);let t=Yw(this.#e);switch(e.type){case`add`:a.push(AC(this.#e,t,KC(this.#e,e.path)));break;case`remove`:a.push(AC(this.#e,t,qC(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=JC(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(AC(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return MC(this.#e,AC(this.#e,i,EC({affectedAncestorIds:ew(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:ZC(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return X(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=Yw(this.#e),r=mC(this.#e,t,e.attemptId);return MC(this.#e,AC(this.#e,n,DC({affectedAncestorIds:ew(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:ZC(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return X(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=Yw(this.#e),i=gC(this.#e,n,e.attemptId,t);return MC(this.#e,AC(this.#e,r,OC({affectedAncestorIds:ew(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:ZC(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return X(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(Gw(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=Yw(this.#e),n=Kw(this.#e,e.mode??`stable`);return MC(this.#e,AC(this.#e,t,kC({...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=rw(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??wS(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=ES(NS(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(!Y(Z(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=Z(this.#e,n);cC(this.#e,n,i)||(lC(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=Z(this.#e,e);if(!cC(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=tw(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!Y(Z(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!Y(Z(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=Z(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=Z(this.#e,e),r=HC(this.#e,e);if(!cC(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 TT(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}"`)}}var ET=e=>e.startsWith(`f::`)?e.slice(3):e;function DT(e){let t=e.lastIndexOf(`/`);return t<0?{parentPath:``,baseName:e}:{parentPath:e.slice(0,t),baseName:e.slice(t+1)}}function OT(e,t){return e===``?t:`${e}/${t}`}function kT({files:e,path:t,isFolder:n,nextBasename:r}){let i=ET(t),a=r.trim();if(a.length===0)return{error:`Name cannot be empty.`};if(a.includes(`/`))return{error:`Name cannot include "/".`};let{parentPath:o,baseName:s}=DT(i);if(a===s)return{nextFiles:e,sourcePath:i,destinationPath:i,isFolder:n};let c=OT(o,a),l=Array(e.length),u=new Set;if(!n){let t=`${c}/`,r=!1;for(let n=0;n<e.length;n++){let a=e[n];if(a!==i&&a.startsWith(t))return{error:`"${c}" already exists.`};let o=a===i?c:a;if(u.has(o))return{error:`"${c}" already exists.`};u.add(o),l[n]=o,a===i&&(r=!0)}return r?{nextFiles:l,sourcePath:i,destinationPath:c,isFolder:n}:{error:`Could not find the selected file to rename.`}}let d=`${i}/`,f=`${c}/`,p=0;for(let t=0;t<e.length;t++){let n=e[t],r=n===i||n.startsWith(d);if(!r&&(n===c||n.startsWith(f)))return{error:`"${c}" already exists.`};let a=r?`${c}${n.slice(i.length)}`:n;if(u.has(a))return{error:`"${c}" already exists.`};u.add(a),l[t]=a,r&&p++}return p===0?{error:`Could not find the selected folder to rename.`}:{nextFiles:l,sourcePath:i,destinationPath:c,isFolder:n}}function AT(e){return e.endsWith(`/`)}function jT(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.lastIndexOf(`/`),r=n<0?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function MT(e){let t=[],n=new Set;for(let r of e)n.has(r)||(n.add(r),t.push(r));let r=new Set;for(let e of t.toSorted((e,t)=>e.length===t.length?e.localeCompare(t):e.length-t.length)){let t=(e.endsWith(`/`)?e.slice(0,-1):e).split(`/`),n=!1;for(let e=0;e<t.length-1;e+=1){let i=`${t.slice(0,e+1).join(`/`)}/`;if(r.has(i)){n=!0;break}}n||r.add(e)}return t.filter(e=>r.has(e))}function NT(e,t){return t.includes(e)?MT(t):[e]}function PT(e,t){return e===t?!0:e==null||t==null?!1:e.kind===t.kind&&e.directoryPath===t.directoryPath&&e.flattenedSegmentPath===t.flattenedSegmentPath&&e.hoveredPath===t.hoveredPath}function FT(e,t){return{draggedPaths:e,target:t}}function IT(e,t){if(t.kind!==`directory`||t.directoryPath==null)return!1;for(let n of e)if(AT(n)&&(t.directoryPath===n||t.directoryPath.startsWith(n)))return!0;return!1}function LT(e,t){return t.kind===`root`||t.directoryPath==null?jT(e):t.directoryPath}function RT(e,t){let n=e.map(e=>{let n=LT(e,t);return n===e?null:{from:e,to:n,type:`move`}}).filter(e=>e!=null);return n.length===0?null:{operations:n,result:{draggedPaths:e,operation:n.length===1?`move`:`batch`,target:t}}}function zT(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function BT(e,t,n){let{paths:r,preparedInput:i}=e;if(i==null){if(r==null)throw Error(`FileTree requires paths or preparedInput`);return{paths:r,preparedInput:void 0}}let a=i.paths;if(r==null)return{paths:a,preparedInput:i};if(!zT(wT.preparePaths(r,n==null?{}:{sort:n}),a))throw Error(`FileTree ${t} received paths and preparedInput for different path lists`);return{paths:a,preparedInput:i}}function VT(e){return e.operation===`add`||e.operation===`remove`||e.operation===`move`||e.operation===`batch`}function HT(e,t,n){if(e===t)return n;let r=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(r)?`${n.endsWith(`/`)?n:`${n}/`}${e.slice(r.length)}`:e}function UT(e,t){if(e===t)return!0;let n=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(n)}function WT(e,t,n=!1){if(e==null)return null;switch(t.operation){case`add`:case`expand`:case`collapse`:case`mark-directory-unloaded`:case`begin-child-load`:case`apply-child-patch`:case`complete-child-load`:case`fail-child-load`:case`cleanup`:return e;case`remove`:return UT(e,t.path)?n?e:null:e;case`move`:return HT(e,t.from,t.to);case`batch`:{let r=e;for(let e of t.events)if(r=WT(r,e,n),r==null)return null;return r}}}function GT(e){return{canonicalChanged:e.canonicalChanged,projectionChanged:e.projectionChanged,visibleCountDelta:e.visibleCountDelta}}function KT(e){switch(e.operation){case`add`:return{...GT(e),operation:`add`,path:e.path};case`remove`:return{...GT(e),operation:`remove`,path:e.path,recursive:e.recursive};case`move`:return{...GT(e),from:e.from,operation:`move`,to:e.to}}}function qT(e){return{...GT(e),events:e.events.filter(e=>e.operation===`add`||e.operation===`remove`||e.operation===`move`).map(e=>KT(e)),operation:`batch`}}function JT(e){switch(e.operation){case`add`:case`remove`:case`move`:return KT(e);case`batch`:return qT(e);default:return null}}function YT(e,t){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}function XT(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;if(t.length===0)return[];let n=t.split(`/`);return n.slice(0,-1).map((e,t)=>`${n.slice(0,t+1).join(`/`)}/`)}function ZT(e){return XT(e).at(-1)??null}function QT(e,t){return t==null?e:e.startsWith(t)?e.slice(t.length):e}function $T(e){return e.endsWith(`/`)}var eE=e=>e.toLowerCase();function tE(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?t:t.slice(n+1)}function nE(e){return e.endsWith(`/`)?e.slice(0,-1):e}function rE(e,t){return t&&!e.endsWith(`/`)?`${e}/`:e}var iE=e=>{let t=e.trim();return t.length===0?``:(t.includes(`\\`)?t.replaceAll(`\\`,`/`):t).toLowerCase()},aE=Symbol(`FILE_TREE_RENAME_VIEW`),oE=512,sE=512;function cE(e){return e===`top`||e===`center`?e:`nearest`}function lE(e,t,n){if(e===0)return-1;if(n!=null){let e=t(n);if(e!=null)return e;let r=XT(n);for(let e=r.length-1;e>=0;--e){let n=r[e];if(n==null)continue;let i=t(n);if(i!=null)return i}}return 0}function uE(e,t,n){if(e.paths.length===0)return{focusedIndex:-1,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};if(t==null)return{focusedIndex:0,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};let r=n??(t=>e.visibleIndexByPath.get(t)??null);return{focusedIndex:lE(e.paths.length,r,t),getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex}}var dE=class e{static{Object.defineProperty(e.prototype,aE,{configurable:!0,value(){return{cancel:()=>{this.#q()},commit:()=>{this.#J()},getPath:()=>this.#T,getValue:()=>this.#E,isActive:()=>this.#T!=null,setValue:e=>{this.#Y(e)}}},writable:!0})}#e;#t=new Set;#n=new Map;#r=null;#i=null;#a=new Map;#o=new Map;#s=-1;#c=null;#l=!1;#u=e=>-1;#d=new Map;#f=null;#p=null;#m=null;#h=null;#g=null;#_;#v;#y;#b=[];#x=new Int32Array;#S=new Int32Array;#C=void 0;#w=!1;#T=null;#E=``;#D=!1;#O=new Set;#k=[];#A;#j=null;#M=null;#N=null;#P=null;#F=null;#I=null;#L=null;#R=0;#z=null;#B=new Set;#V=0;#H;#U=0;#W=!1;#G=0;#K;constructor(e){let{dragAndDrop:t,fileTreeSearchMode:n,initialSearchQuery:r,initialSelectedPaths:i,renaming:a,onSearchChange:o,paths:s,preparedInput:c,...l}=e,u=BT({paths:s,preparedInput:c},`constructor`,l.sort);this.#e=l,t!=null&&t!==!1&&(this.#r=t===!0?{}:t),this.#w=a!=null&&a!==!1,a!=null&&a!==!1&&a!==!0&&(this.#C=a.canRename,this.#v=a.onError,this.#_=a.onRename),this.#y=o,this.#A=n??`hide-non-matches`,this.#H=this.#le(u.paths,u.preparedInput);let d=i?.map(e=>this.#Ne(e)).filter(e=>e!=null)??[],f=d.at(-1)??null;d.length>0&&(this.#B=new Set(d),this.#z=f,this.#V=1),this.#je(f,!1),r!=null&&this.#Te(r,!1),this.#K=this.#Re()}destroy(){this.#K?.(),this.#K=null,this.#n.clear(),this.#t.clear(),this.#d.clear(),this.#i=null,this.#he()}focusFirstItem(){this.#be().length>0&&this.#Fe(0)}focusLastItem(){this.#G<=0||(this.#Ie(),this.#Fe(this.#G-1))}focusNextItem(){this.#Ae(1)}focusParentItem(){if(this.#c==null)return;let e=ZT(this.#c);if(e==null)return;let t=this.#Z(e);t>=0&&this.#Fe(t)}focusPath(e){let t=this.#H.getPathInfo(e)?.path??null;if(t==null)return;this.#Ie();let n=this.#Z(t);n>=0&&this.#Fe(n)}scrollToPath(e,t){let n=this.#H.getPathInfo(e)?.path??null;if(n==null)return;this.#Ie();let r=this.#xe(n);r<0||this.#Me(r)!=null&&(t?.focus!==!1&&this.#Fe(r,!1),this.#L={id:this.#R+=1,offset:cE(t?.offset),visibleIndex:r},this.#De())}focusMountedPathFromInput(e){let t=this.#H.getPathInfo(e)?.path??null;if(t==null)return;let n=this.#Z(t);n>=0&&this.#Fe(n)}focusNearestPath(e){let t=this.resolveNearestVisiblePath(e);if(t==null)return null;let n=this.#Z(t);return n>=0?(this.#Fe(n),this.#be()[n]??t):null}focusPreviousItem(){this.#Ae(-1)}getFocusedIndex(){return this.#s}getFocusedItem(){return this.#c==null?null:this.#Q(this.#c)}getFocusedPath(){return this.#c}getScrollRequest(){return this.#L}clearScrollRequest(e){this.#L?.id===e&&(this.#L=null)}resolveNearestVisiblePath(e){let t=this.#be();if(this.#G===0)return null;if(e==null)return this.#c??t[0]??null;let n=this.#H.getPathInfo(e)?.path??e,r=this.#Z(n);return r>=0?t[r]??n:this.#X(n)??this.#c??t[0]??null}getSelectedPaths(){return[...this.#B]}getSelectionVersion(){return this.#V}getVisibleCount(){return this.#G}getVisibleRows(e,t){if(t<e||this.#G===0)return[];let n=Math.max(0,e),r=Math.min(this.#G-1,t);if(r<n)return[];let i=r-n+1;if(this.#F==null&&!this.#l&&r>=this.#b.length&&i<=sE){let e=[];for(let t=n;t<=r;t+=1){let n=this.#H.getVisibleRowContext(t);if(n==null)break;e.push(this.#ee(n))}return e}if(!this.#l&&r>=this.#b.length&&this.#Ie(),this.#F!=null){let e=Array.from({length:r-n+1},(e,t)=>this.#Se(n+t)),t=new Map,i=e[0]??-1,a=i;for(let n=1;n<=e.length;n+=1){let r=e[n];if(r!=null&&r===a+1){a=r;continue}if(i>=0&&this.#H.getVisibleSlice(i,a).forEach((e,n)=>{t.set(i+n,e)}),r==null){i=-1,a=-1;continue}i=r,a=r}return Array.from({length:r-n+1},(e,r)=>{let i=n+r,a=this.#Se(i),o=t.get(a),s=this.#b[a];if(o==null||s==null)throw Error(`Missing projection row for filtered visible index ${String(i)}`);return this.#$(o,i,a,{ancestorPaths:this.#re(a),path:s})})}return this.#H.getVisibleSlice(n,r).map((e,t)=>{let r=n+t,i=this.#b[r];if(i==null)throw Error(`Missing projection path for visible index ${String(r)}`);return this.#$(e,r,r,{ancestorPaths:this.#re(r),path:i})})}getStickyRowCandidates(e,t){if(this.#F!=null)return null;if(this.#G===0||e<=0||t<=0)return[];let n=[];for(let r=0;r<this.#G;r+=1){let i=e+r*t,a=Math.min(this.#G-1,Math.floor(i/t)),o=this.#te(a,r)??(a>0?this.#te(a-1,r):void 0);if(o==null)break;n.push({row:this.#ee(o),subtreeEndIndex:o.subtreeEndIndex})}return n}getItem(e){let t=this.#H.getPathInfo(e);return t==null?null:this.#Q(t.path,t)}resolveMountedDirectoryPathFromInput(e){let t=this.#H.getPathInfo(e);return t?.kind===`directory`?t.path:null}toggleMountedDirectoryFromInput(e){let t=this.resolveMountedDirectoryPathFromInput(e);t!=null&&this.#ze(t)}selectAllVisiblePaths(){this.#Ie();let e=[...this.#be()];this.#ae(e,this.#c??this.#z)}selectOnlyPath(e){let t=this.#Ne(e);t!=null&&this.#ae([t],t)}selectOnlyMountedPathFromInput(e){this.#ae([e],e)}selectPath(e){let t=this.#Ne(e);t==null||this.#B.has(t)||this.#ae([...this.#B,t])}deselectPath(e){let t=this.#Ne(e);t==null||!this.#B.has(t)||this.#ae([...this.#B].filter(e=>e!==t))}toggleFocusedSelection(){this.#c!=null&&this.togglePathSelectionFromInput(this.#c)}togglePathSelection(e){let t=this.#Ne(e);if(t!=null){if(this.#B.has(t)){this.deselectPath(t);return}this.selectPath(t)}}togglePathSelectionFromInput(e){let t=this.#Ne(e);if(t!=null){if(this.#B.has(t)){this.#ae([...this.#B].filter(e=>e!==t),t);return}this.#ae([...this.#B,t],t)}}selectPathRange(e,t){let n=this.#Ne(e);if(n==null)return;this.#Ie();let r=this.#z,i=r==null?-1:this.#Ce(r),a=this.#Ce(n);if(i===-1||a===-1){let e=t?[...this.#B,n]:[n];this.#ae(e,n);return}let[o,s]=i<=a?[i,a]:[a,i],c=this.#be().slice(o,s+1),l=t?[...this.#B,...c]:c;this.#ae(l,r)}extendSelectionFromFocused(e){if(this.#c==null)return;let t=this.#s;if(t===-1)return;let n=Math.min(this.#G-1,Math.max(0,t+e));if(n===t)return;!this.#l&&n>=this.#b.length&&this.#Ie();let r=this.#be(),i=r[t]??null,a=r[n]??null;if(i==null||a==null)return;let o=new Set(this.#B);o.has(i)&&o.has(a)?o.delete(i):o.add(a),this.#ae([...o],this.#z??i,!1),this.#Fe(n)}getDragAndDropConfig(){return this.#r}isDragAndDropEnabled(){return this.#r!=null}getDragSession(){return this.#i==null?null:{draggedPaths:[...this.#i.draggedPaths],primaryPath:this.#i.primaryPath,target:this.#i.target==null?null:{...this.#i.target}}}startDrag(e){if(this.#r==null)return!1;let t=this.#Ne(e);if(t==null||this.#M!=null&&this.#M.length>0)return!1;let n=this.getSelectedPaths(),r=NT(t,n);return this.#r.canDrag?.(r)!==!1&&(n.includes(t)||this.#ae([t],t,!1),this.#Pe(t),this.#i={draggedPaths:r,primaryPath:t,target:null},this.#De(),!0)}setDragTarget(e){let t=this.#i;if(t==null)return;let n=e;if(n!=null){let e=FT(t.draggedPaths,n);(IT(t.draggedPaths,n)||this.#r?.canDrop?.(e)===!1)&&(n=null)}PT(t.target,n)||(this.#i={...t,target:n},this.#De())}cancelDrag(){this.#i!=null&&(this.#i=null,this.#De())}completeDrag(){let e=this.#i;if(e==null)return!1;this.#i=null;let t=e.target==null?null:{...e.target};if(t==null)return this.#De(),!1;let n=FT(e.draggedPaths,t);if(IT(e.draggedPaths,t)||this.#r?.canDrop?.(n)===!1)return this.#De(),!1;let r=RT(e.draggedPaths,t);if(r==null)return this.#De(),!1;try{if(r.operations.length===1){let e=r.operations[0];if(e==null||e.type!==`move`)throw Error(`Expected a single move operation for one-item drops`);this.#H.move(e.from,e.to,{collision:e.collision})}else this.#ce(r.operations),this.#H.batch(r.operations)}catch(e){return this.#De(),this.#r?.onDropError?.(e instanceof Error?e.message:String(e),n),!1}return this.#r?.onDropComplete?.(r.result),!0}subscribe(e){return this.#t.add(e),e(),()=>{this.#t.delete(e)}}add(e){this.#H.add(e)}remove(e,t={}){this.#H.remove(e,t)}move(e,t,n={}){this.#H.move(e,t,n)}batch(e){this.#H.batch(e)}onMutation(e,t){let n=e,r=t,i=this.#n.get(n);return i??(i=new Set,this.#n.set(n,i)),i.add(r),()=>{let e=this.#n.get(n);e?.delete(r),e?.size===0&&this.#n.delete(n)}}setSearch(e){this.#Te(e,!0)}openSearch(e=``){this.#Te(e,!0)}closeSearch(){this.#Te(null,!0)}isSearchOpen(){return this.#M!==null}getSearchValue(){return this.#M??``}getSearchMatchingPaths(){return this.#k}focusNextSearchMatch(){this.#we(1)}focusPreviousSearchMatch(){this.#we(-1)}startRenaming(e=this.#c??``,t={}){if(!this.#w)return!1;let n=this.#H.getPathInfo(e);if(n==null)return!1;let r=n.path,i=$T(r),a=nE(r);if(this.#C?.({isFolder:i,path:a})===!1)return!1;for(let e of XT(r))this.#H.isExpanded(e)||this.#H.expand(e);return this.#ae([r],r,!1),this.#M!=null&&(this.#Te(null,!1),this.#y?.(this.#M)),this.#Pe(r),this.#T=r,this.#E=tE(r),this.#D=t.removeIfCanceled??!1,this.#De(),!0}#q(){if(this.#T==null)return;let e=this.#T,t=this.#D;if(this.#T=null,this.#E=``,this.#D=!1,t){this.remove(e,$T(e)?{recursive:!0}:void 0);return}this.#Pe(e),this.#De()}#J(){let e=this.#T;if(e==null)return;if(this.#D&&this.#E.trim().length===0){this.#T=null,this.#E=``,this.#D=!1,this.remove(e,$T(e)?{recursive:!0}:void 0);return}let t=$T(e),n=kT({files:this.#H.list(),isFolder:t,nextBasename:this.#E,path:nE(e)});if(this.#T=null,this.#E=``,this.#D=!1,`error`in n){this.#Pe(e),this.#v?.(n.error),this.#De();return}if(n.sourcePath===n.destinationPath){this.#Pe(e),this.#De();return}this.#_?.({destinationPath:n.destinationPath,isFolder:n.isFolder,sourcePath:n.sourcePath}),this.move(rE(n.sourcePath,t),rE(n.destinationPath,t))}#Y(e){this.#T!=null&&this.#E!==e&&(this.#E=e,this.#De())}resetPaths(e,t={}){let n=!Array.isArray(e),r=n?void 0:e,i=n?e:t,a=this.#H.list().length,o=this.#G,s=BT({paths:r,preparedInput:i.preparedInput},`resetPaths`,this.#e.sort),c=this.#le(s.paths,s.preparedInput,i.initialExpandedPaths),l=this.#c,u=this.#T,d=this.getSelectedPaths(),f=this.#z;this.#K?.(),this.#H=c,this.#d.clear(),this.#he();let p=d.map(e=>c.getPathInfo(e)?.path??null).filter(e=>e!=null),m=!YT(this.#B,p);this.#B=new Set(p),m&&(this.#V+=1),this.#z=f==null?null:c.getPathInfo(f)?.path??null,this.#T=u==null?null:c.getPathInfo(u)?.path??null,this.#T??(this.#E=``,this.#D=!1),this.#je(l,l!=null||p.length>0||this.#z!=null),this.#K=this.#Re(),this.#De(),this.#Oe({canonicalChanged:!0,operation:`reset`,pathCountAfter:s.paths.length,pathCountBefore:a,projectionChanged:!0,usedPreparedInput:i.preparedInput!=null,visibleCountDelta:this.#G-o})}#X(e){this.#Ie();let t=ZT(e),n=QT(e,t),r=null,i=null;for(let e of this.#be()){if(ZT(e)!==t)continue;let a=QT(e,t);if(a<n){r=e;continue}if(a>n){i=e;break}}return r??i}#Z(e){let t=this.#Ce(e);if(t!==-1)return t;let n=XT(e);for(let e=n.length-1;e>=0;--e){let t=n[e];if(t==null)continue;let r=this.#Ce(t);if(r!==-1)return r}return this.#be().length>0?0:-1}#Q(e,t){let n=this.#d.get(e);if(n!=null)return n;let r=t??this.#H.getPathInfo(e);if(r==null)return null;let i=r.kind===`directory`?this.#oe(r.path):this.#se(r.path);return this.#d.set(r.path,i),i}#$(e,t,n,r){return{ancestorPaths:r.ancestorPaths,depth:e.depth,flattenedSegments:e.flattenedSegments?.map(e=>({isTerminal:e.isTerminal,name:e.name,path:e.path})),hasChildren:e.hasChildren,index:t,isExpanded:e.isExpanded,isFlattened:e.isFlattened,isFocused:r.path===this.#c,isSelected:this.#B.has(r.path),kind:e.kind,level:e.depth,name:e.name,path:r.path,posInSet:r.posInSet??this.#x[n]??0,setSize:r.setSize??this.#S[n]??0}}#ee(e){return this.#$(e.row,e.index,e.index,{ancestorPaths:e.ancestorPaths,path:e.row.path,posInSet:e.posInSet,setSize:e.setSize})}#te(e,t){let n=this.#H.getVisibleRowContext(e);return n==null?void 0:n.ancestorRows[t]??(t===n.ancestorRows.length&&n.row.kind===`directory`&&n.row.isExpanded?n:void 0)}#ne(e){let t=this.#a.get(e);if(t!=null)return t;let n=this.#u(e),r=n<0?[]:[...this.#ne(n),n];return this.#a.set(e,r),r}#re(e){let t=this.#o.get(e);if(t!=null)return t;let n=this.#ne(e).map(e=>this.#b[e]??``).filter(e=>e!==``);return this.#o.set(e,n),n}#ie(e){this.#H.collapse(e)}#ae(e,t=this.#z,n=!0){let r=[...new Set(e)],i=!YT(this.#B,r),a=this.#z!==t;!i&&!a||(this.#B=new Set(r),this.#z=t,i&&(this.#V+=1),n&&this.#De())}#oe(e){return{collapse:()=>{this.#ie(e)},deselect:()=>{this.deselectPath(e)},expand:()=>{this.#ke(e)},focus:()=>{this.focusPath(e)},getPath:()=>e,isDirectory:()=>!0,isExpanded:()=>this.#H.isExpanded(e),isFocused:()=>this.#c===e,isSelected:()=>this.#B.has(e),select:()=>{this.selectPath(e)},toggleSelect:()=>{this.togglePathSelection(e)},toggle:()=>{this.#ze(e)}}}#se(e){return{deselect:()=>{this.deselectPath(e)},focus:()=>{this.focusPath(e)},getPath:()=>e,isDirectory:()=>!1,isFocused:()=>this.#c===e,isSelected:()=>this.#B.has(e),select:()=>{this.selectPath(e)},toggleSelect:()=>{this.togglePathSelection(e)}}}#ce(e){let t=this.#H.list();this.#le(t).batch(e)}#le(e,t,n){return new wT({...this.#e,paths:e,preparedInput:t??void 0,...n===void 0?{}:{initialExpandedPaths:n}})}#ue(){return this.#h??=this.#H.list(),this.#h}#de(){if(this.#m!=null)return this.#m;let e=new Set;for(let t of this.#ue()){e.add(t);for(let n of XT(t))e.add(n)}return this.#m=[...e].sort(),this.#m}#fe(){return this.#g??=this.#ue().map(eE),this.#g}#pe(){return this.#f??=this.#de().filter(e=>e.endsWith(`/`)),this.#f}#me(){return this.#p??=this.#pe().map(eE),this.#p}#he(){this.#f=null,this.#p=null,this.#m=null,this.#h=null,this.#g=null}#ge(){return this.#pe().filter(e=>this.#H.isExpanded(e))}#_e(e){let t=new Set(this.#j??[]);if(e)for(let e of this.#B)for(let n of XT(e))t.add(n);this.#ve(t)}#ve(e){this.#W=!0;try{for(let t of this.#pe()){let n=e.has(t),r=this.#H.isExpanded(t);n&&!r?this.#H.expand(t):!n&&r&&this.#H.collapse(t)}}finally{this.#W=!1}}#ye(){if(this.#M==null||this.#M.length===0){this.#k=[],this.#F=null,this.#I=null,this.#P=null,this.#G=this.#U;return}let e=this.#b;if(this.#k=e.filter(e=>this.#O.has(e)),this.#A!==`hide-non-matches`||this.#O.size===0){this.#F=null,this.#I=null,this.#P=null,this.#G=this.#U;return}let t=[],n=[],r=new Map;for(let[i,a]of e.entries())this.#N?.has(a)===!0&&(r.set(a,n.length),t.push(i),n.push(a));this.#F=t,this.#I=n,this.#P=r,this.#G=n.length}#be(){return this.#I??this.#b}#xe(e){return this.#I==null?this.#H.getVisibleIndex(e)??-1:this.#P?.get(e)??-1}#Se(e){return this.#F?.[e]??e}#Ce(e){return this.#P?.get(e)??this.#H.getVisibleIndex(e)??-1}#we(e){let t=this.#k;if(t.length===0)return;let n=this.#c,r=n==null?-1:t.indexOf(n),i=t[r<0?e>0?0:t.length-1:Math.min(t.length-1,Math.max(0,r+e))];i!=null&&this.focusPath(i)}#Te(e,t){let n=e==null?null:iE(e),r=this.#M;if(r!==n){if(r==null&&n!=null&&(this.#j=this.#ge()),this.#M=n,n==null)this.#_e(!0),this.#j=null,this.#O.clear(),this.#N=null,this.#je(this.#c,!0);else if(n.length===0)this.#_e(!1),this.#O.clear(),this.#N=null,this.#je(this.#c,!0);else{let e=this.#Ee();this.#je(e,!0)}t&&(this.#y?.(this.#M),this.#De())}}#Ee(){if(this.#M==null||this.#M.length===0)return this.#O.clear(),this.#c;let e=this.#M,t=this.#ue(),n=this.#fe(),r=[],i=new Set,a=null;for(let o=0;o<t.length;o+=1){if(!n[o].includes(e))continue;let s=t[o];r.push(s),i.add(s),a??=s}let o=this.#pe(),s=this.#me();for(let t=0;t<o.length;t+=1){if(!s[t].includes(e))continue;let n=o[t];i.has(n)||(r.push(n),i.add(n),a??=n)}this.#O=i;let c=this.#A===`hide-non-matches`&&r.length>0?new Set:null;this.#N=c;let l=this.#A===`expand-matches`?new Set(this.#j??[]):new Set;for(let e of r){c?.add(e),e.endsWith(`/`)&&l.add(e);for(let t of XT(e))l.add(t),c?.add(t)}return this.#ve(l),a??this.#c}#De(){for(let e of this.#t)e()}#Oe(e){this.#n.get(e.operation)?.forEach(t=>{t(e)}),this.#n.get(`*`)?.forEach(t=>{t(e)})}#ke(e){for(let t of XT(e))this.#H.isExpanded(t)||this.#H.expand(t);this.#H.isExpanded(e)||this.#H.expand(e)}#Ae(e){let t=this.#G;if(t===0)return;let n=this.#s===-1?0:this.#s,r=Math.min(t-1,Math.max(0,n+e));(r!==n||this.#s===-1)&&(!this.#l&&this.#F==null&&r>=this.#b.length&&this.#Ie(),this.#Fe(r))}#je(e,t=!0){let n=this.#H.getVisibleCount();this.#U=n;let r=uE(this.#H.getVisibleTreeProjectionData(t?void 0:Math.min(n,oE)),e,t?e=>this.#H.getVisibleIndex(e):void 0);this.#a.clear(),this.#o.clear(),this.#l=r.paths.length>=n,this.#u=r.getParentIndex,this.#b=r.paths,this.#x=r.posInSetByIndex,this.#S=r.setSizeByIndex,this.#ye(),this.#s=e==null?this.#be().length>0?0:-1:this.#Z(e),this.#c=this.#s<0?null:this.#Me(this.#s)}#Me(e){return this.#be()[e]??(this.#F==null?this.#H.getVisibleRowContext(e)?.row.path??null:null)}#Ne(e){return this.#H.getPathInfo(e)?.path??null}#Pe(e){if(e==null)return;let t=this.#Z(e);t>=0&&this.#Fe(t,!1)}#Fe(e,t=!0){let n=this.#Me(e);n!=null&&(this.#s!==e||this.#c!==n)&&(this.#s=e,this.#c=n,t&&this.#De())}#Ie(){this.#l||this.#je(this.#c,!0)}#Le(e){let t=WT(this.#T,e);t==null&&this.#T!=null&&(this.#E=``),this.#T=t;let n=WT(this.#c,e,!0),r=[...this.#B].map(t=>WT(t,e)).filter(e=>e!=null).map(e=>this.#H.getPathInfo(e)?.path??null).filter(e=>e!=null),i=WT(this.#z,e),a=i==null?null:this.#H.getPathInfo(i)?.path??null,o=[...new Set(r)];return YT(this.#B,o)||(this.#B=new Set(o),this.#V+=1),this.#z=a,n}#Re(){return this.#H.on(`*`,e=>{if(this.#W)return;e.canonicalChanged&&(this.#d.clear(),this.#he()),this.#i!=null&&VT(e)&&(this.#i=null);let t=VT(e)?this.#Le(e):this.#c,n=this.#M!=null&&this.#M.length>0?this.#Ee():this.#M===``?this.#c:t,r=this.#M!=null||e.operation!==`expand`&&e.operation!==`collapse`;this.#je(n,r),this.#De();let i=JT(e);i!=null&&this.#Oe(i)})}#ze(e){if(this.#H.isExpanded(e)){this.#ie(e);return}this.#ke(e)}},fE=e=>{if(e==null||e.length===0)return`0`;let t=`${e.length}`;for(let n of e)t+=`\0${n.path}\0${n.status}`;return t};function pE(e){let t=e.endsWith(`/`),n=``,r=-1;for(let t=0;t<=e.length;t+=1){if(e[t]!==`/`&&t!==e.length){r===-1&&(r=t);continue}r!==-1&&(n!==``&&(n+=`/`),n+=e.slice(r,t),r=-1)}return n===``?null:{isDirectory:t,path:n}}function mE(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;if(t.length===0)return[];let n=[],r=0;for(;;){let e=t.indexOf(`/`,r);if(e===-1)break;n.push(t.slice(0,e+1)),r=e+1}return n}function hE(e,t){return t?`${e}/`:e}function gE(e,t=null){let n=fE(e==null?void 0:[...e]);if(n===`0`)return null;if(t?.signature===n)return t;let r=new Map,i=new Set,a=new Set,o=new Map;for(let t of e??[]){let e=vE(t);e!=null&&xE({canonicalPath:e.canonicalPath,changeCountByDirectoryPath:o,directoriesWithChanges:i,ignoredDirectoryPaths:a,isDirectory:e.isDirectory,status:t.status,statusByPath:r})}return r.size===0?null:{changeCountByDirectoryPath:o,directoriesWithChanges:i,ignoredDirectoryPaths:a,signature:n,statusByPath:r}}function _E(e,t){let n=t?.remove??[],r=t?.set??[];if(n.length===0&&r.length===0)return e;let i=new Map(e?.statusByPath),a=new Set(e?.directoriesWithChanges),o=new Set(e?.ignoredDirectoryPaths),s=new Map(e?.changeCountByDirectoryPath),c=!1;for(let e of n){let t=yE(e);t!=null&&(c=bE({canonicalPath:t.canonicalPath,changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,statusByPath:i})||c)}for(let e of r){let t=vE(e);t!=null&&(c=xE({canonicalPath:t.canonicalPath,changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,isDirectory:t.isDirectory,status:e.status,statusByPath:i})||c)}return c?i.size===0?null:{changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,signature:wE(i),statusByPath:i}:e}function vE(e){return yE(e.path)}function yE(e){let t=pE(e);if(t!=null)return{canonicalPath:hE(t.path,t.isDirectory),isDirectory:t.isDirectory}}function bE({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,statusByPath:i}){let a=i.get(e);return a!=null&&(i.delete(e),a===`ignored`&&e.endsWith(`/`)&&r.delete(e),CE(t,n,e),!0)}function xE({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,isDirectory:i,status:a,statusByPath:o}){let s=o.get(e);return s!==a&&(s??SE(t,n,e),o.set(e,a),a===`ignored`&&i?r.add(e):i&&r.delete(e),!0)}function SE(e,t,n){for(let r of mE(n))e.set(r,(e.get(r)??0)+1),t.add(r)}function CE(e,t,n){for(let r of mE(n)){let n=(e.get(r)??0)-1;n>0?e.set(r,n):(e.delete(r),t.delete(r))}}function wE(e){let t=`${e.size}`;for(let[n,r]of e)t+=`\0${n}\0${r}`;return t}var TE=e=>e.trim().toLowerCase(),EE=e=>e.split(`/`).at(-1)??e,DE=e=>{let t=e.toLowerCase().split(`.`),n=[];for(let e=1;e<t.length;e+=1)n.push(t.slice(e).join(`.`));return n};function OE(e,t){return typeof e==`string`?{name:e,remappedFrom:t}:{...e,remappedFrom:t}}function kE(e){let t=jx(e),n=t.remap,r=new Map;for(let[e,n]of Object.entries(t.byFileName??{}))r.set(e.toLowerCase(),n);let i=new Map;for(let[e,n]of Object.entries(t.byFileExtension??{}))i.set(TE(e),n);let a=Object.entries(t.byFileNameContains??{}).map(([e,t])=>[e.toLowerCase(),t]);return{resolveIcon:(e,o)=>{if(e===`file-tree-icon-file`&&o!=null){let s=EE(o),c=s.toLowerCase(),l=r.get(c);if(l!=null)return OE(l,e);for(let[t,n]of a)if(c.includes(t))return OE(n,e);let u=DE(s);for(let t of u){let n=i.get(t);if(n!=null)return OE(n,e)}let d=kx(t.set,s,u);if(d!=null&&t.set!==`none`){if(d==="default"){let t=n?.[e];if(t!=null)return OE(t,e)}return{name:Dx(d),remappedFrom:e,token:d}}}let s=n?.[e];return s==null?{name:e}:OE(s,e)}}}var AE,jE,ME,NE,PE,FE,IE,LE,RE,zE,BE={},VE=[],HE=Array.isArray,UE=VE.slice,WE=Object.assign;function GE(e){e&&e.parentNode&&e.remove()}function KE(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return arguments.length>2&&(o.children=arguments.length>3?UE.call(arguments,2):n),qE(e,o,r,i,null)}function qE(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++jE,__i:-1,__u:0};return i==null&&AE.vnode!=null&&AE.vnode(a),a}function JE(e){return e.children}function YE(e,t){this.props=e,this.context=t,this.__g=0}function XE(e,t){if(t==null)return e.__?XE(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?XE(e):null}function ZE(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=n.__e;break}return ZE(e)}}function QE(e){(8&e.__g||!(e.__g|=8)||!ME.push(e)||PE++)&&NE==AE.debounceRendering||((NE=AE.debounceRendering)||queueMicrotask)($E)}function $E(){for(var e,t,n,r,i,a,o,s,c=1;ME.length;)ME.length>c&&ME.sort(FE),e=ME.shift(),c=ME.length,8&e.__g&&(n=void 0,i=(r=(t=e).__v).__e,a=[],o=[],(s=t.__P)&&((n=WE({},r)).__v=r.__v+1,AE.vnode&&AE.vnode(n),sD(s,n,r,t.__n,s.namespaceURI,32&r.__u?[i]:null,a,i??XE(r),!!(32&r.__u),o,s.ownerDocument),n.__v=r.__v,n.__.__k[n.__i]=n,lD(a,n,o),n.__e!=i&&ZE(n)));PE=0}function eD(e,t,n,r,i,a,o,s,c,l,u,d){var f,p,m,h,g,_,v,y=r&&r.__k||VE,b=t.length;for(c=tD(n,t,y,c,b),f=0;f<b;f++)(m=n.__k[f])!=null&&(p=m.__i==-1?BE:y[m.__i]||BE,m.__i=f,_=sD(e,m,p,i,a,o,s,c,l,u,d),h=m.__e,m.ref&&p.ref!=m.ref&&(p.ref&&fD(p.ref,null,m),u.push(m.ref,m.__c||h,m)),g==null&&h!=null&&(g=h),(v=!!(4&m.__u))||p.__k===m.__k?c=nD(m,c,e,v):typeof m.type==`function`&&_!==void 0?c=_:h&&(c=h.nextSibling),m.__u&=-7);return n.__e=g,c}function tD(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(c=a+f,(o=e.__k[a]=typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?qE(null,o,null,null,null):HE(o)?qE(JE,{children:o},null,null,null):o.constructor==null&&o.__b>0?qE(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=e,o.__b=e.__b+1,s=null,(l=o.__i=rD(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=XE(s)),pD(s,s));return r}function nD(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=nD(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=XE(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function rD(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&e.key==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function iD(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n??``}function aD(e,t,n,r,i){var a;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||iD(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||iD(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(IE,`$1`)),(t=t.slice(2))[0].toLowerCase()!=t[0]&&(t=t.toLowerCase()),e.__l||={},e.__l[t+a]=n,n?r?n.l=r.l:(n.l=LE,e.addEventListener(t,a?zE:RE,a)):e.removeEventListener(t,a?zE:RE,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function oD(e){return function(t){if(this.__l){var n=this.__l[t.type+e];if(t.u==null)t.u=LE++;else if(t.u<n.l)return;return n(AE.event?AE.event(t):t)}}}function sD(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M=t.type;if(t.constructor!=null)return null;128&n.__u&&(c=!!(32&n.__u),n.__c.__z&&(s=t.__e=n.__e=(a=n.__c.__z)[0],n.__c.__z=null)),(d=AE.__b)&&d(t);n:if(typeof M==`function`)try{if(v=t.props,y=`prototype`in M&&M.prototype.render,b=(d=M.contextType)&&r[d.__c],x=d?b?b.props.value:d.__:r,n.__c?2&(f=t.__c=n.__c).__g&&(f.__g|=1,_=!0):(y?t.__c=f=new M(v,x):(t.__c=f=new YE(v,x),f.constructor=M,f.render=mD),b&&b.sub(f),f.props=v,f.state||(f.state={}),f.context=x,f.__n=r,p=!0,f.__g|=8,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&M.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=WE({},f.__s)),WE(f.__s,M.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&M.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&M.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,x),!(4&f.__g)&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,x)||t.__v==n.__v){for(t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),S=0;S<f._sb.length;S++)f.__h.push(f._sb[S]);f._sb=[],f.__h.length&&o.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,x),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=x,f.props=v,f.__P=e,f.__g&=-5,C=AE.__r,w=0,y){for(f.state=f.__s,f.__g&=-9,C&&C(t),d=f.render(f.props,f.state,f.context),T=0;T<f._sb.length;T++)f.__h.push(f._sb[T]);f._sb=[]}else do f.__g&=-9,C&&C(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(8&f.__g&&++w<25);f.state=f.__s,f.getChildContext!=null&&(r=WE({},r,f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),E=d,d!=null&&d.type===JE&&d.key==null&&(E=uD(d.props.children)),s=eD(e,HE(E)?E:[E],t,n,r,i,a,o,s,c,l,u),t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__g&=-4)}catch(e){if(t.__v=null,c||a!=null){if(e.then){for(D=0,O=!1,t.__u|=c?160:128,t.__c.__z=[],k=0;k<a.length;k++)(A=a[k])==null||O||(A.nodeType==8&&A.data==`$s`?(D>0&&t.__c.__z.push(A),D++,a[k]=null):A.nodeType==8&&A.data==`/$s`?(--D>0&&t.__c.__z.push(A),O=D===0,s=a[k],a[k]=null):D>0&&(t.__c.__z.push(A),a[k]=null));if(!O){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__c.__z=[s]}t.__e=s}else{for(j=a.length;j--;)GE(a[j]);cD(t)}}else t.__e=n.__e,t.__k=n.__k,e.then||cD(t);AE.__e(e,t,n)}else s=t.__e=dD(n.__e,t,n,r,i,a,o,c,l,u);return(d=AE.diffed)&&d(t),128&t.__u?void 0:s}function cD(e){e&&e.__c&&(e.__c.__g|=4),e&&e.__k&&e.__k.forEach(cD)}function lD(e,t,n){for(var r=0;r<n.length;r++)fD(n[r],n[++r],n[++r]);AE.__c&&AE.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){AE.__e(e,t.__v)}})}function uD(e){return typeof e!=`object`||!e||e.__b&&e.__b>0?e:HE(e)?e.map(uD):WE({},e)}function dD(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v=n.props,y=t.props,b=t.type;if(b==`svg`?i=`http://www.w3.org/2000/svg`:b==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(u=0;u<a.length;u++)if((m=a[u])&&`setAttribute`in m==!!b&&(b?m.localName==b:m.nodeType==3)){e=m,a[u]=null;break}}if(e==null){if(b==null)return l.createTextNode(y);e=l.createElementNS(i,b,y.is&&y),s&&=(AE.__m&&AE.__m(t,a),!1),a=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(a&&=UE.call(e.childNodes),v=n.props||BE,!s&&a!=null)for(v={},u=0;u<e.attributes.length;u++)v[(m=e.attributes[u]).name]=m.value;for(u in v)if(m=v[u],u!=`children`){if(u==`dangerouslySetInnerHTML`)f=m;else if(!(u in y)){if(u==`value`&&`defaultValue`in y||u==`checked`&&`defaultChecked`in y)continue;aD(e,u,null,m,i)}}for(u in _=1&n.__u,y)m=y[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||v[u]===m&&!_||aD(e,u,m,v[u],i);if(d)s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(f&&(e.innerHTML=``),eD(b==`template`?e.content:e,HE(p)?p:[p],t,n,r,b==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&XE(n,0),s,c,l),a!=null)for(u=a.length;u--;)GE(a[u]);s||(u=`value`,b==`progress`&&h==null?e.removeAttribute(`value`):h==null||h===e[u]&&(b!==`progress`||h)||aD(e,u,h,v[u],i),u=`checked`,g!=null&&g!=e[u]&&aD(e,u,g,v[u],i))}return e}function fD(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){AE.__e(e,n)}}function pD(e,t,n){var r,i;if(AE.unmount&&AE.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||fD(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){AE.__e(e,t)}r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&pD(r[i],t,n||typeof e.type!=`function`);n||GE(e.__e),e.__e&&e.__e.__l&&(e.__e.__l=null),e.__e=e.__c=e.__=null}function mD(e,t,n){return this.constructor(e,n)}function hD(e,t){var n,r,i,a;t==document&&(t=document.documentElement),AE.__&&AE.__(e,t),r=(n=!!(e&&32&e.__u))?null:t.__k,e=t.__k=KE(JE,null,[e]),i=[],a=[],sD(t,e,r||BE,BE,t.namespaceURI,r?null:t.firstChild?UE.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a,t.ownerDocument),lD(i,e,a)}function gD(e,t){e.__u|=32,hD(e,t)}AE={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=8&i.__g),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=8&i.__g),o)return void(i.__g|=2)}catch(t){e=t}}throw PE=0,e}},jE=0,YE.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=WE({},this.state);typeof e==`function`&&(e=e(WE({},n),this.props)),e&&WE(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),QE(this))},YE.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),QE(this))},YE.prototype.render=JE,ME=[],PE=0,FE=function(e,t){return e.__v.__b-t.__v.__b},IE=/(PointerCapture)$|Capture$/i,LE=0,RE=oD(!1),zE=oD(!0);var _D=0;Array.isArray;function Q(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--_D,__i:-1,__u:0,__source:i,__self:a};return AE.vnode&&AE.vnode(l),l}var vD=16,yD=16,bD={};function xD({name:e,remappedFrom:t,token:n,width:r,height:i,viewBox:a,label:o,alignCapitals:s=!1}){"use no memo";let c=`#${e.replace(/^#/,``)}`,{width:l,height:u,viewBox:d}=bD[e]??{width:vD,height:yD},f=r??l,p=i??u,m=a??d??`0 0 ${l} ${u}`;return Q(`svg`,{"data-icon-name":t??e,"data-icon-token":n,"data-align-capitals":s,...o==null?{"aria-hidden":!0}:{"aria-label":o,role:`img`},viewBox:m,width:f,height:p,children:Q(`use`,{href:c})})}var SD=e=>e!==void 0&&/\s/.test(e),CD=(e,t)=>{let n=t=>SD(e[t-1])||SD(e[t]);if(!n(t))return t;for(let r=1;r<e.length;r++){let i=t-r;if(i>0&&!n(i))return i;let a=t+r;if(a<e.length&&!n(a))return a}return t},wD=e=>CD(e,Math.ceil(e.length/2)),TD=e=>{if(e.length<2)return[e,``];let t=wD(e);return[e.slice(0,t),e.slice(t)]},ED=e=>{if(e.length<4)return[e,``];let t=e.lastIndexOf(`.`)+1,n=e.length-t>10,r=t>=1&&!n?t:wD(e);return[e.slice(0,r),e.slice(r)]},DD=e=>{if(e.length<4)return[e,``];let t=e.lastIndexOf(`/`)+1,n=e.length-t>25,r=t>=1&&!n?t:Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]},OD=(e,{splitIndex:t}={})=>{if(typeof t!=`number`){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}return[e.slice(0,t),e.slice(t)]},kD=(e,{splitOffset:t}={})=>{if(typeof t!=`number`||t<=0||t>=e.length){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}let n=e.length-t;return[e.slice(0,n),e.slice(n)]},AD=(e,{splitOffset:t}={})=>{if(typeof t!=`number`||t<=0||t>=e.length){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}let n=t;return[e.slice(0,n),e.slice(n)]};function jD({children:e,marker:t,variant:n=`default`}){"use no memo";return Q(`div`,{"aria-hidden":!0,"data-truncate-marker-cell":!0,children:Q(`div`,{"data-truncate-marker":!0,children:typeof t==`function`?t({children:e}):n===`fade`?Q(`span`,{"data-truncate-fade":!0}):t})})}function MD(e){"use no memo";let{mode:t,children:n}=e;return Q(`div`,{children:[Q(`div`,{"data-truncate-content":`visible`,children:t===`fruncate`?Q(`span`,{children:n}):n}),Q(`div`,{"data-truncate-content":`overflow`,"aria-hidden":!0,children:t===`fruncate`?Q(`span`,{children:n}):n})]})}function ND({children:e,mode:t=`truncate`,marker:n=`…`,variant:r=`default`,...i}){"use no memo";let a=Q(MD,{mode:t,children:e},`content`),o=Q(jD,{marker:n,mode:t,variant:r},`marker`),s=Q(`div`,{"data-truncate-fill":!0},`fill`);return Q(`div`,{"data-truncate-container":t,"data-truncate-variant":r,...i,children:Q(`div`,{"data-truncate-grid":!0,children:t===`truncate`?[a,o]:[o,a,s]})})}function PD({children:e,...t}){"use no memo";return Q(ND,{mode:`truncate`,...t,children:e})}function FD({children:e,...t}){"use no memo";return Q(ND,{mode:`fruncate`,...t,children:e})}function ID({children:e,contents:t,priority:n=`end`,split:r=`center`,minimumLength:i=12,className:a,style:o,...s}){"use no memo";let c=null,l=null;if(Array.isArray(t)){if(t.length!==2)return console.error(`MiddleTruncate: contents must be an array of two items`),null;c=Q(PD,{...s,children:t[0]}),l=Q(FD,{...s,children:t[1]})}else{if(typeof e!=`string`)return console.error(`MiddleTruncate: children must be a string`),null;if(e.length===0)return Q(`div`,{className:a,style:o});if(e.length<i)return Q(n===`end`?FD:PD,{...s,className:a,style:o,children:e});let t=null,u=null,d=null;if(typeof r==`string`)r===`center`?t=TD:r===`extension`?t=ED:r===`leaf-path`&&(t=DD);else if(typeof r==`number`)t=OD,u=r;else if(Array.isArray(r)){let[e,n]=r;d=n,e===`last`?t=kD:e===`first`&&(t=AD)}else typeof r==`function`&&(t=r);t??=TD;let[f,p]=t(e,{priority:n,variant:s.variant,splitIndex:typeof u==`number`?u:void 0,splitOffset:typeof d==`number`?d:void 0}),m=f.length>=p.length,h=n===`equal`&&!m,g=n===`equal`&&m,_={},v={};h&&(_.marker=``),g&&(v.marker=``),c=Q(PD,{...s,..._,children:f}),l=Q(FD,{...s,...v,children:p})}return Q(`div`,{"data-truncate-group-container":`middle`,className:a,style:o,children:[Q(`div`,{"data-truncate-segment-priority":n===`start`||n===`equal`?`1`:`2`,children:c}),Q(`div`,{"data-truncate-segment-priority":n===`end`||n===`equal`?`1`:`2`,children:l})]})}var LD={endIndex:-1,startIndex:-1};function RD(e,t,n){return Math.min(Math.max(e,t),n)}function zD(e,t){return e<0||t<e?LD:{endIndex:t,startIndex:e}}function BD(e){return e.startIndex<0||e.endIndex<e.startIndex}function VD(e,t){return BD(e)?0:(e.endIndex-e.startIndex+1)*t}function HD(e,t,n){if(t<=0)return-1;let r=t*n;return e<=0?0:e>=r?t:Math.floor(e/n)}function UD(e,t,n){return t<=0||e<=0?-1:e>=t*n?t-1:Math.ceil(e/n)-1}function WD(e){let t=new Map;return e.forEach((e,n)=>{if(e.kind!==`directory`||!e.isExpanded)return;let r=e.ancestorPaths.length,i=t.get(r);if(i==null){t.set(r,[n]);return}i.push(n)}),t}function GD(e,t){let n=0,r=e.length-1,i=-1;for(;n<=r;){let a=Math.floor((n+r)/2),o=e[a];if(o==null)break;if(o<=t){i=a,n=a+1;continue}r=a-1}return i}function KD(e){let t=new Map,n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(i==null)continue;let a=i.kind===`directory`&&i.isExpanded?[...i.ancestorPaths,i.path]:i.ancestorPaths,o=0;for(;o<n.length&&o<a.length&&n[o]===a[o];)o+=1;for(let e=n.length-1;e>=o;--e){let i=n[e];i!=null&&t.set(i,r-1)}n.length=o;for(let e=o;e<a.length;e+=1){let t=a[e];t!=null&&n.push(t)}}let r=e.length-1;for(let e of n)t.set(e,r);return t}function qD(e,t,n){if(e.length===0||t<=0)return[];let r=KD(e),i=WD(e),a=[];for(let r=0;r<e.length;r+=1){let o=i.get(r);if(o==null||o.length===0)break;let s=t+r*n,c=GD(o,Math.min(e.length-1,Math.floor(s/n))),l=null;for(;c>=0;){let t=o[c],n=t==null?null:e[t]??null;if(n!=null&&(r===0||n.ancestorPaths[r-1]===a[r-1]?.path)){l=n;break}--c}if(l==null)break;a.push(l)}return a.map((i,a)=>{let o=a*n,s=(r.get(i.path)??e.length-1)+1;if(s>=e.length)return{row:i,top:o};let c=s*n-t;return{row:i,top:Math.min(o,c-n)}}).filter(e=>e.top+n>0)}function JD(e,t){let n=t.totalRowCount??e.length,r=n*t.itemHeight,i=Math.max(0,t.viewportHeight),a=Math.max(0,Math.floor(t.overscan)),o=Math.max(0,r-i),s=RD(t.scrollTop,0,o),c=t.stickyRows??qD(e,s,t.itemHeight),l=c.reduce((e,n)=>Math.max(e,n.top+t.itemHeight),0),u=Math.min(r,s+l),d=Math.max(0,i-l),f=Math.max(0,r-u),p=HD(s,n,t.itemHeight),m=HD(u,n,t.itemHeight),h=l<=0||p<0||p>=n?-1:p,g=h===-1?-1:Math.min(n-1,m-1),_=h===-1||g<h?0:g-h+1,v=d<=0||m>=n?LD:zD(m,UD(u+d,n,t.itemHeight)),y=g+1,b=BD(v)?LD:zD(Math.max(y,v.startIndex-a),Math.min(n-1,v.endIndex+a)),x=VD(b,t.itemHeight);return{occlusion:{firstOccludedIndex:h,lastOccludedIndex:g,occludedCount:_},physical:{itemHeight:t.itemHeight,maxScrollTop:o,overscan:a,scrollTop:s,totalHeight:r,totalRowCount:n,viewportHeight:i},projected:{contentHeight:f,paneHeight:d,paneTop:u},sticky:{height:l,rows:c},visible:v,window:{endIndex:b.endIndex,height:x,offsetTop:BD(b)?0:b.startIndex*t.itemHeight,startIndex:b.startIndex}}}var YD={added:`A`,deleted:`D`,ignored:null,modified:`M`,renamed:`R`,untracked:`U`},XD={added:`Git status: added`,deleted:`Git status: deleted`,ignored:`Git status: ignored`,modified:`Git status: modified`,renamed:`Git status: renamed`,untracked:`Git status: untracked`},ZD=`Contains git status items`;function QD(e){return e.current?!0:(e.current=!0,!1)}function $D(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:i=0,viewportHeight:a}=e;if(n<0)return null;let o=Math.max(0,i),s=n*r,c=s+r;if(s<t+o){let e=Math.max(0,s-o);return e===t?null:e}if(c>t+a){let e=c-a;return e===t?null:e}return null}function eO(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,offset:i,topInset:a=0,totalHeight:o,viewportHeight:s}=e;if(i===`nearest`)return $D({currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:a,viewportHeight:s});if(n<0)return null;let c=Math.max(0,a),l=n*r,u=Math.max(0,s-c),d=i===`center`?c+Math.max(0,(u-r)/2):c,f=Math.max(0,o-s),p=Math.max(0,Math.min(l-d,f));return p===t?null:p}function tO(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,targetViewportOffset:i,totalHeight:a,viewportHeight:o}=e;if(n<0)return null;let s=Math.max(0,i),c=n*r,l=c+r,u=t+s,d=t+o;if(c>=u&&l<=d)return null;let f=Math.max(0,a-o),p=Math.max(0,Math.min(c-s,f));return p===t?null:p}function nO(e){if(e==null||!e.isConnected||e===document.body||e===document.documentElement)return!1;e.focus({preventScroll:!0});let t=e.getRootNode();return t instanceof ShadowRoot?t.activeElement===e:document.activeElement===e}function rO(e){let t=e.getRootNode();if(t instanceof ShadowRoot){let e=t.activeElement;return e instanceof HTMLElement?e:null}let n=document.activeElement;return n instanceof HTMLElement&&e.contains(n)?n:null}function iO(e,t){if(e==null)return t;let n=e.getBoundingClientRect().height;return n>0?n:e.clientHeight>0?e.clientHeight:t}function aO(e,t){return e!=null&&e>0?e:t}function oO(e){let t=e.borderBoxSize,n=Array.isArray(t)?t[0]:t;return n!=null&&Number.isFinite(n.blockSize)&&n.blockSize>0?n.blockSize:e.contentRect.height>0?e.contentRect.height:null}function sO(e,t,n,r,i=0){let a=$D({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,topInset:i,viewportHeight:r});return a!=null&&(e.scrollTop=a,!0)}function cO(e,t,n,r,i,a,o=0){let s=eO({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,offset:a,topInset:o,totalHeight:i,viewportHeight:r});return s!=null&&(e.scrollTop=s,!0)}function lO(e,t,n,r,i,a){let o=tO({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,targetViewportOffset:a,totalHeight:i,viewportHeight:r});return o!=null&&(e.scrollTop=o,!0)}function uO(e,t,n,r){return n.end<n.start?null:e<n.start?-t:e>n.end?r:null}function dO(e){let{renamingPath:t,previousRenamingPath:n,hasRenderedInput:r}=e;return t==null?`reset`:r?n===t?`ignore`:`focus-input`:`reveal-canonical`}function fO({ariaLabel:e,isFlattened:t=!1,ref:n,value:r,onBlur:i,onInput:a}){return Q(`input`,{ref:n,"data-item-rename-input":!0,...t?{"data-item-flattened-rename-input":!0}:{},"aria-label":e,value:r,onBlur:i,onInput:a,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})}function pO(e){let{row:t,mode:n,targetPath:r,ariaLabel:i,domId:a,isParked:o,itemHeight:s,features:c,state:l,extraStyle:u}=e,d=n===`sticky`,f=t.ancestorPaths.at(-1)??``,p={};return l.isFocusRinged&&(p[`data-item-focused`]=!0),t.isSelected&&(p[`data-item-selected`]=!0),l.isContextHovered&&(p[`data-item-context-hover`]=`true`),l.isDragTarget&&(p[`data-item-drag-target`]=!0),l.isDragging&&(p[`data-item-dragging`]=!0),l.effectiveGitStatus!=null&&(p[`data-item-git-status`]=l.effectiveGitStatus),l.containsGitChange&&(p[`data-item-contains-git-change`]=`true`),{"aria-expanded":!d&&t.kind===`directory`?t.isExpanded:void 0,"aria-haspopup":c.contextMenuEnabled?`menu`:void 0,"aria-label":i,"aria-level":d?void 0:t.level+1,"aria-posinset":d?void 0:t.posInSet+1,"aria-selected":d?void 0:t.isSelected?`true`:`false`,"aria-setsize":d?void 0:t.setSize,"data-file-tree-sticky-path":d?r:void 0,"data-file-tree-sticky-row":d?`true`:void 0,"data-item-context-menu-button-visibility":c.actionLaneEnabled?c.contextMenuButtonVisibility:void 0,"data-item-context-menu-trigger-mode":c.contextMenuEnabled?c.contextMenuTriggerMode:void 0,"data-item-has-context-menu-action-lane":c.actionLaneEnabled?`true`:void 0,"data-item-has-git-lane":c.gitLaneActive?`true`:void 0,"data-item-parent-path":f.length>0?f:void 0,"data-item-parked":o?`true`:void 0,"data-item-path":r,"data-item-type":t.kind===`directory`?`folder`:`file`,"data-type":`item`,id:d?void 0:a,role:d?void 0:`treeitem`,style:{minHeight:`${s}px`,...u},tabIndex:!d&&t.isFocused?0:-1,...p}}function mO(e){let{event:t,mode:n,isSearchOpen:r,isDirectory:i}=e,a=t.ctrlKey||t.metaKey,o=t.shiftKey||a,s=t.shiftKey?{additive:a,kind:`range`}:a?{kind:`toggle`}:{kind:`single`};return{closeSearch:r,revealCanonical:n===`sticky`,selection:s,toggleDirectory:!o&&i}}var hO,gO,_O,vO,yO=Object.is,bO=0,xO=[],SO=AE,CO=SO.__b,wO=SO.__r,TO=SO.diffed,EO=SO.__c,DO=SO.unmount,OO=SO.__;function kO(e,t){SO.__h&&SO.__h(gO,e,bO||t),bO=0;var n=gO.__H||(gO.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function AO(e){return bO=1,jO(HO,e)}function jO(e,t,n){var r=kO(hO++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):HO(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);yO(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=gO,!gO.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return!!e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,yO(t,e.__[0])||(o=!0)}}),a&&a.call(this,e,t,n)||o};gO.__f=!0;var a=gO.shouldComponentUpdate,o=gO.componentWillUpdate;gO.componentWillUpdate=function(e,t,n){if(4&this.__g){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},gO.shouldComponentUpdate=i}return r.__N||r.__}function MO(e,t){var n=kO(hO++,3);!SO.__s&&VO(n.__H,t)&&(n.__=e,n.u=t,gO.__H.__h.push(n))}function NO(e,t){var n=kO(hO++,4);!SO.__s&&VO(n.__H,t)&&(n.__=e,n.u=t,gO.__h.push(n))}function $(e){return bO=5,PO(function(){return{current:e}},[])}function PO(e,t){var n=kO(hO++,7);return VO(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function FO(e,t){return bO=8,PO(function(){return e},t)}function IO(){for(var e;e=xO.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(zO),e.__H.__h.forEach(BO),e.__H.__h=[]}catch(t){e.__H.__h=[],SO.__e(t,e.__v)}}SO.__b=function(e){gO=null,CO&&CO(e)},SO.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),OO&&OO(e,t)},SO.__r=function(e){wO&&wO(e),hO=0;var t=(gO=e.__c).__H;t&&(_O===gO?(t.__h=[],gO.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(zO),t.__h.forEach(BO),t.__h=[],hO=0)),_O=gO},SO.diffed=function(e){TO&&TO(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(xO.push(t)!==1&&vO===SO.requestAnimationFrame||((vO=SO.requestAnimationFrame)||RO)(IO)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),_O=gO=null},SO.__c=function(e,t){t.some(function(e){try{e.__h.forEach(zO),e.__h=e.__h.filter(function(e){return!e.__||BO(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],SO.__e(n,e.__v)}}),EO&&EO(e,t)},SO.unmount=function(e){DO&&DO(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{zO(e)}catch(e){t=e}}),n.__H=void 0,t&&SO.__e(t,n.__v))};var LO=typeof requestAnimationFrame==`function`;function RO(e){var t,n=function(){clearTimeout(r),LO&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);LO&&(t=requestAnimationFrame(n))}function zO(e){var t=gO,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),gO=t}function BO(e){var t=gO;e.__c=e.__(),gO=t}function VO(e,t){return!e||e.length!==t.length||t.some(function(t,n){return!yO(t,e[n])})}function HO(e,t){return typeof t==`function`?t(e):t}function UO(e,t=null,n=null){"use no memo";let r=e.flattenedSegments;return r==null||r.length===0?t??e.name:Q(`span`,{"data-item-flattened-subitems":!0,children:r.map((e,i)=>{let a=i===r.length-1;return Q(JE,{children:[Q(`span`,{"data-item-flattened-subitem":e.path,"data-item-flattened-subitem-drag-target":n===e.path?`true`:void 0,children:a&&t!=null?t:Q(PD,{children:e.name})}),i<r.length-1?` / `:``]},e.path)})})}function WO(e){return e.isFlattened?e.flattenedSegments?.findLast(e=>e.isTerminal)?.path??e.path:e.path}function GO(e){let t=e.flattenedSegments;return t==null||t.length===0?e.name:t.map(e=>e.name).join(` / `)}function KO(e,t,n,r){return e.map((e,i)=>{let a=i*n,o=e.subtreeEndIndex+1;if(o>=r)return{row:e.row,top:a};let s=o*n-t;return{row:e.row,top:Math.min(a,s-n)}}).filter(e=>e.top+n>0)}function qO({controller:e,itemHeight:t,overscan:n,scrollTop:r,stickyFolders:i,viewportHeight:a}){let o=e.getVisibleCount(),s=i&&o>0?e.getStickyRowCandidates(r,t):[],c=s==null&&i&&o>0?e.getVisibleRows(0,o-1):[],l=JD(c,{itemHeight:t,overscan:n,scrollTop:r,stickyRows:s==null?void 0:KO(s,r,t,o),totalRowCount:o,viewportHeight:a}),u=i&&r<=0&&o>0?e.getStickyRowCandidates(1,t):[],d=u!=null&&r<=0?KO(u,1,t,o):i&&r<=0&&c.length>0?qD(c,1,t):l.sticky.rows;return{overlayHeight:d.reduce((e,n)=>Math.max(e,n.top+t),0),overlayRows:d,snapshot:l,visibleRows:c}}var JO=400,YO=40,XO=18;function ZO(e,t,n){let r=e,i=document.elementFromPoint?.bind(document)??null,a=r.elementFromPoint?.(t,n)??i?.(t,n)??null;return e instanceof ShadowRoot&&(a==null||!e.contains(a))?QO(e,t,n):a instanceof HTMLElement?a:null}function QO(e,t,n){let r=Array.from(e.querySelectorAll(`[data-type="item"], [data-item-flattened-subitem]`));for(let e=r.length-1;e>=0;e--){let i=r[e],a=i.getBoundingClientRect();if(t>=a.left&&t<=a.right&&n>=a.top&&n<=a.bottom)return i}return null}function $O(e){let t=e?.closest?.(`[data-type="item"]`);if(!(t instanceof HTMLElement))return null;let n=t.dataset.itemPath??null;if(n==null)return null;let r=e?.closest?.(`[data-item-flattened-subitem]`),i=r instanceof HTMLElement?r.getAttribute(`data-item-flattened-subitem`)??null:null;if(i!=null&&i.endsWith(`/`))return{directoryPath:i,flattenedSegmentPath:i,hoveredPath:n,kind:`directory`};if(t.dataset.itemType===`folder`)return{directoryPath:n,flattenedSegmentPath:null,hoveredPath:n,kind:`directory`};let a=t.dataset.itemParentPath??null;return a==null||a.length===0?{directoryPath:null,flattenedSegmentPath:null,hoveredPath:n,kind:`root`}:{directoryPath:a,flattenedSegmentPath:null,hoveredPath:n,kind:`directory`}}function ek(e){let t=e.cloneNode(!0);return t.removeAttribute(`id`),t.dataset.fileTreeDragPreview=`true`,t.setAttribute(`aria-hidden`,`true`),t.tabIndex=-1,Object.assign(t.style,{boxShadow:`0 4px 12px rgba(0, 0, 0, 0.15)`,left:`0px`,margin:`0`,pointerEvents:`none`,position:`fixed`,top:`0px`,willChange:`transform`,zIndex:`10000`}),t}function tk(){return navigator.vendor!==`Apple Computer, Inc.`}function nk(e,t){let n=e-t.top;if(n<YO)return-Math.ceil((YO-Math.max(0,n))/YO*XO);let r=t.bottom-e;return r<YO?Math.ceil((YO-Math.max(0,r))/YO*XO):0}function rk(e,t){if(e!=null){let t=YD[e];return t==null?null:{text:t,title:XD[e]}}return t?{icon:{name:`file-tree-icon-dot`,width:6,height:6},title:ZD}:null}function ik(e,t,n){if(t==null||t.size===0)return null;let r=[];for(let i=e.length-1;i>=0;--i){let a=e[i],o=n.get(a);if(o!=null){for(let e of r)n.set(e,o);return o?`ignored`:null}if(t.has(a)){n.set(a,!0);for(let e of r)n.set(e,!0);return`ignored`}r.push(a)}for(let e of r)n.set(e,!1);return null}function ak(e){return e!=null&&`toggle`in e}function ok(e){return e.code===`Space`||e.key===` `||e.key===`Spacebar`}function sk(e){return e.key.length===1&&/^[\p{L}\p{N}]$/u.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function ck(e){return e==null?``:`[data-item-section="spacing-item"][data-ancestor-path="${e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}"] { opacity: 1; }`}function lk(e){return e.shiftKey&&e.key===`F10`||e.key===`ContextMenu`}function uk(e,t){return t&&lk(e)||(e.ctrlKey||e.metaKey)&&ok(e)?!0:e.key===`ArrowDown`||e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`}var dk=new Set([`ArrowDown`,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`]);function fk(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&(t.dataset.fileTreeContextMenuRoot===`true`||t.dataset.type===`context-menu-anchor`||t.dataset.type===`context-menu-trigger`||t.getAttribute(`slot`)===`context-menu`))return!0;return!1}function pk(e){return{bottom:e.bottom,height:e.height,left:e.left,right:e.right,top:e.top,width:e.width,x:e.x,y:e.y}}function mk(e,t){return{bottom:t,height:0,left:e,right:e,top:t,width:0,x:e,y:t}}function hk(e,t){if(e==null)return t.offsetTop;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.top-r.top}function gk(e,t,n){if(n==null){e.delete(t);return}e.set(t,n)}function _k(e,t,n){if(e==null)return null;let r=t.get(e)??null;if(r!=null)return r;let i=n.get(e)??null;return i?.dataset.itemParked===`true`?null:i}function vk(e){if(e==null)return[];let t=[];for(let n of e.querySelectorAll(`button[data-file-tree-sticky-row="true"]`)){if(!(n instanceof HTMLElement))continue;let e=n.dataset.fileTreeStickyPath;e!=null&&t.push(e)}return t}function yk(e,t){if(e==null||t==null)return null;for(let n of e.querySelectorAll(`button[data-item-focused="true"][data-item-parked="true"]`))if(n instanceof HTMLElement&&n.dataset.itemPath===t)return n;return null}function bk(e,t,n,r,i,a,o){let s=Math.max(0,a-i),c=t?.getBoundingClientRect()??null,l=c==null||n==null?null:n.getBoundingClientRect().top-c.top,u=yk(e,r),d=c==null||u==null?null:u.getBoundingClientRect().top-c.top;return Math.max(0,Math.min(d??Math.max(l??0,s),Math.max(0,o-i)))}function xk(e,t){return{kind:e.kind,name:GO(e),path:t}}function Sk(e){return e==null?void 0:`${e}__tree`}function Ck(e,t,n){if(e!=null)return`${e}__focused-item-${encodeURIComponent(t)}${n?`__parked`:``}`}function wk(e){return e===`file-tree-icon-chevron`||e===`file-tree-icon-dot`||e===`file-tree-icon-file`||e===`file-tree-icon-lock`}function Tk(e,t){if(e==null)return null;if(`text`in e)return e.parts==null?Q(`span`,{title:e.title,children:e.text}):Q(`span`,{title:e.title,children:e.parts.map((e,t)=>Q(`span`,{style:{color:e.color},children:e.text},t))});let n=typeof e.icon==`string`?wk(e.icon)?t(e.icon):{name:e.icon}:wk(e.icon.name)?(()=>{let n=t(e.icon.name),{name:r,...i}=e.icon;return{...n,...i}})():e.icon;return Q(`span`,{title:e.title,children:Q(xD,{...n})})}function Ek(e){e!=null&&nO(e.querySelector([`button:not([disabled])`,`[href]`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`, `))??e)}function Dk(e,t,{actionLaneEnabled:n=!1,customDecoration:r=null,decorationLaneEnabled:i=!1,dragTargetFlattenedSegmentPath:a=null,gitDecoration:o=null,gitLaneActive:s=!1,renameInput:c=null,showDecorativeActionAffordance:l=!1}={}){let u=WO(e);return Q(JE,{children:[e.depth>0?Q(`div`,{"data-item-section":`spacing`,children:Array.from({length:e.depth}).map((t,n)=>Q(`div`,{"data-item-section":`spacing-item`,"data-ancestor-path":e.ancestorPaths[n]},n))}):null,Q(`div`,{"data-item-section":`icon`,children:e.kind===`directory`?Q(xD,{...t(`file-tree-icon-chevron`)}):Q(xD,{...t(`file-tree-icon-file`,u)})}),Q(`div`,{"data-item-section":`content`,children:e.isFlattened?UO(e,c,a):c??Q(ID,{minimumLength:5,split:`extension`,children:e.name})}),i?Q(`div`,{"data-item-section":`decoration`,children:r==null?null:Tk(r,t)}):null,s?Q(`div`,{"data-item-section":`git`,children:Tk(o,t)}):null,n?Q(`div`,{"data-item-section":`action`,children:l?Q(`span`,{"aria-hidden":`true`,"data-item-action-affordance":`decorative`,children:Q(xD,{...t(`file-tree-icon-ellipsis`)})}):null}):null]})}function Ok(e,t,n,r={}){let{controller:i,renameView:a,visualFocusPath:o,contextHoverPath:s,draggedPathSet:c,dragTarget:l,dragAndDropEnabled:u,shouldSuppressContextMenu:d,handleRowDragStart:f,handleRowDragEnd:p,handleRowTouchStart:m,instanceId:h,itemHeight:g,gitStatusByPath:_,ignoredGitDirectories:v,ignoredInheritanceCache:y,directoriesWithGitChanges:b,gitLaneActive:x,contextMenuEnabled:S,contextMenuTriggerMode:C,contextMenuButtonTriggerEnabled:w,contextMenuButtonVisibility:T,contextMenuRightClickEnabled:E,registerRenameInput:D,registerButton:O,resolveIcon:k,renderDecorationForRow:A,openContextMenuForRow:j,onRowClick:M,onKeyDown:N}=e,P=WO(t),{isParked:F=!1,mode:I=`flow`,style:ee}=r,te=I===`sticky`,ne=_?.get(P)??null??ik(t.ancestorPaths,v,y),re=t.kind===`directory`&&(b?.has(P)??!1),L=A(t,P),R=rk(ne,re),ie=S&&w,ae=L!=null||x||ie,oe=ie&&T===`always`,se=a.getPath()===P,ce=se?a.getValue():``,z=te||!se?null:Q(fO,{ref:D,ariaLabel:`Rename ${GO(t)}`,isFlattened:t.isFlattened,value:ce,onBlur:()=>{a.commit()},onInput:e=>{a.setValue(e.currentTarget.value)}}),le=Dk(t,k,{actionLaneEnabled:ie,customDecoration:L,decorationLaneEnabled:ae,dragTargetFlattenedSegmentPath:l?.flattenedSegmentPath??null,gitDecoration:R,gitLaneActive:x,renameInput:z,showDecorativeActionAffordance:oe}),B={...pO({ariaLabel:GO(t),domId:t.isFocused?Ck(h,P,F):void 0,extraStyle:ee,features:{actionLaneEnabled:ie,contextMenuButtonVisibility:ie?T:null,contextMenuEnabled:S,contextMenuTriggerMode:S?C:null,gitLaneActive:x},isParked:F,itemHeight:g,mode:I,row:t,state:{containsGitChange:re,effectiveGitStatus:ne,isContextHovered:s===P,isDragTarget:l?.kind===`directory`&&l.directoryPath===P,isDragging:c?.has(P)===!0,isFocusRinged:t.isFocused&&o===P},targetPath:P}),key:n,onContextMenu:S||u?e=>{if(d()){e.preventDefault();return}S&&(e.preventDefault(),E&&(i.focusMountedPathFromInput(P),j(t,P,{anchorRect:mk(e.clientX,e.clientY),source:`right-click`})))}:void 0,onFocus:te?void 0:()=>{i.focusMountedPathFromInput(P)},onKeyDown:te?void 0:N,ref:e=>{O(P,e)}};return!te&&se?Q(`div`,{...B,children:le}):Q(`button`,{...B,type:`button`,draggable:u&&!F,onDragEnd:u&&!F?p:void 0,onDragStart:u&&!F?e=>{f(e,t,P)}:void 0,onMouseDown:e=>{if(te){e.preventDefault();return}i.isSearchOpen()&&e.preventDefault()},onTouchStart:u&&!F?e=>{m(e,t,P)}:void 0,onClick:e=>{M(e,t,P,I)},children:le})}function kk(e,t,n){return t.end<t.start?[]:e.controller.getVisibleRows(t.start,t.end).filter(e=>!n.has(WO(e))).map((n,r)=>Ok(e,n,t.start+r))}function Ak({composition:e,controller:t,gitStatusByPath:n,ignoredGitDirectories:r,directoriesWithGitChanges:i,icons:a,instanceId:o,itemHeight:s=Px,overscan:c=10,renamingEnabled:l=!1,renderRowDecoration:u,searchBlurBehavior:d=`close`,searchEnabled:f=!1,searchFakeFocus:p=!1,slotHost:m,stickyFolders:h=!1,initialViewportHeight:g=420}){"use no memo";let _=$(null),v=$(null),y=$(!1),b=$(null),x=$(null),S=$(null),C=$(null),w=$(null),T=$(new Map),E=$(new Map),D=$(()=>{}),O=$(null),k=$(0),A=$(!1),j=$(null);j.current!==t&&(A.current=!1,j.current=t);let M=$(!1),N=$(null),P=$(null),F=$(!1),I=$(null),ee=$(null),te=$(null),ne=$(null),re=$(null),L=$(null),R=$(null),ie=$(null),ae=$(!1),oe=$(null),se=$(null),ce=$(null),z=$(null),le=PO(()=>new Map,[]),[,B]=AO(0),ue=$(!1),[de,fe]=AO(null),[V,pe]=AO(null),[me,he]=AO(null),[ge,_e]=AO(null),[ve,ye]=AO(0),[be,xe]=AO(null),Se=$(be);Se.current=be;let Ce=$(null),we=$(null),Te=$(null),Ee=$(null),De=$(null),Oe=$(!1),ke=()=>{we.current=null,Te.current=null,Ee.current=null},Ae=(e,t)=>{we.current=e,Te.current=null,Ee.current=t==null?null:{path:e,scrollTop:t}},je=(e,t)=>{we.current=null,Te.current={path:e,viewportOffset:t},Ee.current=null},Me=$(d===`retain`&&t.isSearchOpen()),[Ne,Pe]=AO(p);MO(()=>{p||Pe(!1)},[p]);let Fe=$(!1),Ie=FO(()=>{Fe.current=!0,Pe(e=>e&&!1)},[]),[Le,Re]=AO(()=>qO({controller:t,itemHeight:s,overscan:c,scrollTop:0,stickyFolders:h,viewportHeight:g})),[ze,Be]=AO(!1);MO(()=>{Be(!0)},[]);let Ve=e?.contextMenu?.enabled===!0||e?.contextMenu?.render!=null||e?.contextMenu?.onOpen!=null||e?.contextMenu?.onClose!=null,He=e?.contextMenu?.triggerMode??(Ve?`right-click`:`both`),Ue=He===`both`||He===`button`,H=e?.contextMenu?.buttonVisibility??`when-needed`,U=He===`both`||He===`right-click`;NO(()=>{let e=S.current;if(e==null)return;let t=e=>{if(!(e instanceof CustomEvent))return;let t=e.detail?.path??null;De.current=t,pe(t),_e(t==null?null:`pointer`)},n=e=>{e instanceof CustomEvent&&(Oe.current=e.detail?.disabled===!0)};return e.addEventListener(`file-tree-debug-set-context-menu-trigger`,t),e.addEventListener(`file-tree-debug-set-scroll-suppression`,n),()=>{e.removeEventListener(`file-tree-debug-set-context-menu-trigger`,t),e.removeEventListener(`file-tree-debug-set-scroll-suppression`,n)}},[]);let We=FO((e,t)=>{gk(T.current,e,t)},[]),Ge=FO((e,t)=>{gk(E.current,e,t)},[]),Ke=FO(e=>{x.current=e},[]),qe=FO(e=>_k(e,E.current,T.current),[]),Je=n!=null||r!=null||i!=null,{resolveIcon:Ye}=PO(()=>kE(a),[a]),Xe=t[aE](),Ze=Xe.getPath(),Qe=Ze!=null,$e=t.isSearchOpen(),et=t.getSearchValue(),tt=t.getFocusedPath(),nt=t.getFocusedIndex(),rt=t.getScrollRequest(),it=t.isDragAndDropEnabled(),at=t.getDragSession(),ot=PO(()=>at==null?null:new Set(at.draggedPaths),[at]),st=at?.target??null,ct=at?.primaryPath??null,W=Sk(o),{overlayHeight:lt,overlayRows:ut,snapshot:dt,visibleRows:G}=Le,ft=dt.physical.viewportHeight,pt=PO(()=>({end:dt.window.endIndex,start:dt.window.startIndex}),[dt.window.endIndex,dt.window.startIndex]),mt=ut,ht=dt.sticky.rows,gt=dt.physical.totalHeight,_t=dt.sticky.height,vt=PO(()=>new Set(ht.map(e=>WO(e.row))),[ht]),yt=nt>=0&&nt>=pt.start&&nt<=pt.end,bt=FO((e,t)=>u?.({item:xk(e,t),row:e})??null,[u]),xt=FO(e=>nO(e==null?null:T.current.get(e)??null)?!0:nO(S.current),[]),St=FO(e=>{xt(t.focusNearestPath(e))},[t,xt]),Ct=$(St);Ct.current=St;let wt=$(!0),Tt=$(()=>{}),Et=FO((t=!0)=>{let n=Se.current;n!=null&&(wt.current=wt.current&&t,xe(null),e?.contextMenu?.onClose?.(),wt.current&&St(n.path))},[e?.contextMenu,St]);Tt.current=Et;let Dt=FO(e=>{let t=e==null?null:hk(S.current,e);he(e=>e===t?e:t)},[]),Ot=FO((e,n,r)=>{let i=t.getItem(n);if(i==null)return;let a=qe(n);if(a?.dataset.fileTreeStickyRow===`true`){let e=C.current;Ae(n,e?.scrollTop??null),M.current=!0,fe(e=>e===n?e:n)}i.focus(),Dt(a),wt.current=!0,xe({anchorRect:r?.anchorRect??null,item:xk(e,n),path:n,source:r?.source??`keyboard`})},[t,qe,Dt]),kt=FO(e=>{if(l){if(t.isSearchOpen()){let e=C.current,t=iO(e,ft);I.current=nt<0||e==null?null:Math.max(0,Math.min(nt*s-e.scrollTop,Math.max(0,t-s))),F.current=!0}t.startRenaming(e)!==!1&&(_e(`focus`),B(e=>e+1))}},[t,nt,s,l,ft]),At=FO((e,{restoreTreeFocus:n=!0,targetOffset:r=`live-overlay`}={})=>{let i=C.current;if(i==null)return!1;t.focusPath(e);let a=t.getFocusedIndex();if(a<0)return!1;let o=t.getVisibleRows(a,a)[0]??null;if(o==null)return!1;let l=iO(i,ft),u=t.getVisibleCount()*s,d=r===`sticky-parents`?o.ancestorPaths.length*s:qO({controller:t,itemHeight:s,overscan:c,scrollTop:i.scrollTop,stickyFolders:h,viewportHeight:l}).snapshot.sticky.height;return M.current=!0,lO(i,a,s,l,u,d),D.current(),Ce.current=n?e:null,!0},[t,s,c,ft,h]),jt=()=>y.current===!0||z.current!=null||ae.current===!0,Mt=e=>typeof window.requestAnimationFrame==`function`?window.requestAnimationFrame(()=>{e()}):window.setTimeout(e,16),Nt=e=>{if(e!=null){if(typeof window.cancelAnimationFrame==`function`){window.cancelAnimationFrame(e);return}window.clearTimeout(e)}},Pt=()=>{ne.current!=null&&(clearTimeout(ne.current),ne.current=null),te.current=null},Ft=()=>{L.current?.remove(),L.current=null},It=()=>{Nt(ee.current),ee.current=null,re.current=null},Lt=e=>{let t=S.current?.getRootNode();if(t instanceof ShadowRoot){t.append(e);return}document.body.append(e)},Rt=()=>{ie.current?.(),ie.current=null,z.current!=null&&(clearTimeout(z.current),z.current=null),ae.current=!1,oe.current=null,ce.current=null,se.current!=null&&(se.current.setAttribute(`draggable`,`true`),se.current.style.removeProperty(`touch-action`),se.current=null),Ft(),Pt(),It(),R.current=null},zt=(e,n)=>{let r=S.current?.getRootNode(),i=$O(ZO(r instanceof ShadowRoot?r:document,e,n));return t.setDragTarget(i),t.getDragSession()?.target??null},Bt=e=>{let n=t.getDragAndDropConfig()?.openOnDropDelay??800;if(e==null||e.kind!==`directory`||e.directoryPath==null||n<=0){Pt();return}let r=t.getItem(e.directoryPath),i=ak(r)?r:null;if(i==null||i.isExpanded()){Pt();return}let a=`${e.directoryPath}::${e.flattenedSegmentPath??``}`;te.current!==a&&(Pt(),te.current=a,ne.current=setTimeout(()=>{let n=t.getDragSession()?.target;n?.kind===`directory`&&n.directoryPath===e.directoryPath&&n.flattenedSegmentPath===e.flattenedSegmentPath&&i.expand()},n))},Vt=()=>{ee.current=null;let e=re.current,n=C.current;if(e==null||n==null||t.getDragSession()==null)return;let r=n.getBoundingClientRect(),i=nk(e.clientY,r);if(i===0)return;let a=Math.max(0,n.scrollHeight-n.clientHeight),o=Math.max(0,Math.min(a,n.scrollTop+i));o!==n.scrollTop&&(n.scrollTop=o,D.current()),Bt(zt(e.clientX,e.clientY)),ee.current=Mt(Vt)},Ht=(e,t)=>{re.current={clientX:e,clientY:t},ee.current??=Mt(Vt)},Ut=(e,n,r)=>{let i=e.currentTarget;if(i!=null){if(Rt(),Ft(),Pt(),It(),t.startDrag(r)===!1){e.preventDefault();return}if(R.current=n,e.dataTransfer!=null&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.dropEffect=`move`,e.dataTransfer.setData(`text/plain`,r),tk())){let t=ek(i),n=i.getBoundingClientRect();Object.assign(t.style,{height:`${n.height}px`,opacity:`0.85`,transform:`translate3d(-9999px, 0px, 0)`,width:`${n.width}px`}),Lt(t),L.current=t,e.dataTransfer.setDragImage(t,Math.max(0,e.clientX-n.left),Math.max(0,e.clientY-n.top))}}},Wt=()=>{Ft(),Pt(),It(),R.current=null,t.cancelDrag()},Gt=(e,n,r)=>{if(z.current!=null||ae.current)return;let i=e.touches[0],a=e.currentTarget;if(i==null||a==null)return;ce.current={clientX:i.clientX,clientY:i.clientY},se.current=a,a.setAttribute(`draggable`,`false`);let o=(e={})=>{let t=e.restoreNativeDraggable??!ae.current;z.current!=null&&(clearTimeout(z.current),z.current=null),document.removeEventListener(`touchmove`,s),document.removeEventListener(`touchend`,c),document.removeEventListener(`touchcancel`,c),ie.current===o&&(ie.current=null),t&&(a.setAttribute(`draggable`,`true`),se.current===a&&(se.current=null),ce.current=null)},s=e=>{let t=e.touches[0],n=ce.current;if(t==null||n==null)return;let r=t.clientX-n.clientX,i=t.clientY-n.clientY;r*r+i*i<=100||o()},c=()=>{o()};document.addEventListener(`touchmove`,s,{passive:!0}),document.addEventListener(`touchend`,c),document.addEventListener(`touchcancel`,c),ie.current=o,z.current=setTimeout(()=>{if(o({restoreNativeDraggable:!1}),t.startDrag(r)===!1){a.setAttribute(`draggable`,`true`),se.current===a&&(se.current=null),ce.current=null;return}ae.current=!0,se.current=a,a.setAttribute(`draggable`,`false`),a.style.setProperty(`touch-action`,`none`),R.current=n;let e=a.getBoundingClientRect(),s=ek(a);Object.assign(s.style,{height:`${e.height}px`,opacity:`0.85`,transform:`translate3d(${e.left}px, ${e.top}px, 0)`,width:`${e.width}px`}),Lt(s),L.current=s,oe.current={x:i.clientX-e.left,y:i.clientY-e.top};let c=e=>{let t=e.touches[0];if(t==null)return;e.preventDefault();let n=oe.current;n!=null&&L.current!=null&&(L.current.style.transform=`translate3d(${t.clientX-n.x}px, ${t.clientY-n.y}px, 0)`),Bt(zt(t.clientX,t.clientY)),Ht(t.clientX,t.clientY)},l=e=>{let n=e.changedTouches[0];n!=null&&zt(n.clientX,n.clientY),t.completeDrag(),Rt()},u=()=>{t.cancelDrag(),Rt()};ie.current=()=>{document.removeEventListener(`touchmove`,c),document.removeEventListener(`touchend`,l),document.removeEventListener(`touchcancel`,u)},document.addEventListener(`touchmove`,c,{passive:!1}),document.addEventListener(`touchend`,l),document.addEventListener(`touchcancel`,u)},JO)},Kt=e=>{if(be!=null){if(e.key===`Escape`){Et(),e.preventDefault(),e.stopPropagation();return}dk.has(e.key)&&(e.preventDefault(),e.stopPropagation());return}if(Xe.isActive()){if(e.isComposing||e.keyCode===229)return;if(e.key===`Escape`)Xe.cancel();else if(e.key===`Enter`)Xe.commit();else return;_e(`focus`),B(e=>e+1),e.preventDefault(),e.stopPropagation();return}if(l&&e.key===`F2`){kt(tt??void 0),e.preventDefault(),e.stopPropagation();return}if($e){if(e.key===`Escape`)F.current=!1,I.current=null,t.closeSearch();else if(e.key===`Enter`){let e=t.getFocusedPath();e!=null&&t.selectOnlyPath(e);let n=C.current,r=iO(n,ft);I.current=nt<0||n==null?null:Math.max(0,Math.min(nt*s-n.scrollTop,Math.max(0,r-s))),F.current=!0,t.closeSearch()}else if(e.key===`ArrowDown`)t.focusNextSearchMatch();else if(e.key===`ArrowUp`)t.focusPreviousSearchMatch();else return;_e(`focus`),B(e=>e+1),e.preventDefault(),e.stopPropagation();return}if(f&&sk(e)){t.openSearch(e.key),B(e=>e+1),e.preventDefault(),e.stopPropagation();return}let n=Ve&&lk(e),r=uk(e,Ve),i=r&&S.current!=null?rO(S.current):null,a=r?new Set(vk(S.current)):new Set,o=i?.dataset.fileTreeStickyPath??null,c=i?.dataset.fileTreeStickyRow===`true`&&o!=null;if(c&&o!==tt&&a.has(o)){let e=C.current;Ae(o,e?.scrollTop??null),t.focusPath(o)}let u=t.getFocusedPath(),d=t.getFocusedIndex(),p=t.getFocusedItem();if(p==null)return;let m=ak(p)?p:null,h=u!=null&&(vt.has(u)||c&&o===u&&a.has(u)),g=e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`ArrowRight`&&m!=null&&m.isExpanded(),_=e.key===`ArrowLeft`&&h&&m!=null&&m.isExpanded(),v=C.current,y=!0;if(e.shiftKey&&e.key===`ArrowDown`)t.extendSelectionFromFocused(1);else if(e.shiftKey&&e.key===`ArrowUp`)t.extendSelectionFromFocused(-1);else if(n&&u!=null&&d>=0){let e=t.getVisibleRows(d,d)[0]??null,n=_k(u,E.current,T.current);e==null||n==null?y=!1:Ot(e,u)}else if((e.ctrlKey||e.metaKey)&&ok(e))t.toggleFocusedSelection();else if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`a`)t.selectAllVisiblePaths();else switch(e.key){case`ArrowDown`:t.focusNextItem();break;case`ArrowUp`:t.focusPreviousItem();break;case`ArrowRight`:m==null||m.isExpanded()?t.focusNextItem():m.expand();break;case`ArrowLeft`:m!=null&&m.isExpanded()?m.collapse():t.focusParentItem();break;case`Home`:t.focusFirstItem();break;case`End`:t.focusLastItem();break;default:y=!1}if(!y)return;_e(`focus`);let b=t.getFocusedPath(),x=b!=null&&(vt.has(b)||a.has(b)),w=g&&b!==u,D=n&&c&&o===u&&b===u;if((h||D)&&b!=null&&(w&&x||D))Ae(b,v?.scrollTop??null),M.current=!0,fe(e=>e===b?e:b);else{let t=e.key===`ArrowUp`&&h&&b!==u;b!=null&&(t||_&&b===u)?(je(b,bk(S.current,v,i,u,s,_t,ft)),M.current=!0,fe(e=>e===b?e:b)):ke()}B(e=>e+1),e.preventDefault(),e.stopPropagation()};NO(()=>{if(!(!f||!$e)){if(Me.current){Me.current=!1;return}nO(w.current)}},[$e,f]),NO(()=>{let e=x.current;switch(dO({hasRenderedInput:e!=null,previousRenamingPath:P.current,renamingPath:Ze})){case`reset`:P.current=null;return;case`reveal-canonical`:Ze!=null&&At(Ze,{restoreTreeFocus:!1,targetOffset:`live-overlay`});return;case`ignore`:return;case`focus-input`:e!=null&&(Ce.current=null,P.current=Ze,nO(e),e.select());return}},[pt.end,pt.start,Ze,At,vt]),NO(()=>{let e=S.current;if(e==null)return;let t=null,n=()=>{t!=null&&(clearTimeout(t),t=null)},r=()=>{let t=rO(e)?.dataset.itemPath??null;fe(e=>e===t?e:t)},i=()=>{n(),M.current=!0,r()},a=i=>{let a=i.relatedTarget;if(a==null){n(),t=setTimeout(()=>{if(t=null,rO(e)!=null){r();return}M.current=!1,fe(null)},0);return}if(!(a instanceof Node)||!e.contains(a)){n(),M.current=!1,fe(null);return}let o=a instanceof HTMLElement?a.dataset.itemPath??null:null;fe(e=>e===o?e:o)};return e.addEventListener(`focusin`,i),e.addEventListener(`focusout`,a),()=>{n(),e.removeEventListener(`focusin`,i),e.removeEventListener(`focusout`,a)}},[]),NO(()=>{let e=S.current;e!=null&&(dt.physical.scrollTop<=0?e.dataset.scrollAtTop=`true`:delete e.dataset.scrollAtTop)},[dt.physical.scrollTop]),NO(()=>{let e=null,n=C.current,r=b.current,i=S.current;if(n==null)return;O.current=iO(n,g);let a=()=>{let e=t.getVisibleCount(),r=aO(O.current,g),i=Math.max(0,e*s-r);n.scrollTop>i&&(n.scrollTop=i),Re(qO({controller:t,itemHeight:s,overscan:c,scrollTop:Math.min(n.scrollTop,i),stickyFolders:h,viewportHeight:r}))};if(!A.current){A.current=!0;let e=t.getFocusedIndex();if(e>=0){let r=aO(O.current,g),i=t.getVisibleRows(e,e)[0]??null;sO(n,e,s,r,h&&i!=null?Math.max(0,Math.min(i.ancestorPaths.length*s,Math.max(0,r-s))):0)}}D.current=a;let o=t.subscribe(()=>{QD(ue)&&B(e=>e+1),a()}),l=()=>{Oe.current!==!0&&(r!=null&&(r.dataset.isScrolling??=``),i!=null&&(i.dataset.isScrolling??=``),y.current=!0,e!=null&&clearTimeout(e),e=setTimeout(()=>{r!=null&&delete r.dataset.isScrolling,i!=null&&delete i.dataset.isScrolling,y.current=!1,ye(e=>e+1),e=null},50))},u=null,d=()=>{i!=null&&delete i.dataset.overlayReveal,u!=null&&(clearTimeout(u),u=null)},f=()=>{i!=null&&Oe.current!==!0&&(n.scrollTop>0||(i.dataset.overlayReveal=`true`,u!=null&&clearTimeout(u),u=setTimeout(()=>{d()},200)))},p=()=>{if(a(),n.scrollTop>0&&d(),Se.current!=null&&y.current&&Tt.current(),Oe.current===!0){y.current=!1;return}pe(e=>e==null?e:null),l()},m=()=>{l(),f()},_=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`,`Home`,`End`,` `,`Spacebar`]),v=e=>{_.has(e.key)&&m()};n.addEventListener(`scroll`,p,{passive:!0}),n.addEventListener(`wheel`,m,{passive:!0}),n.addEventListener(`touchmove`,m,{passive:!0}),n.addEventListener(`keydown`,v);let x=typeof ResizeObserver<`u`?new ResizeObserver(e=>{O.current=(e[0]==null?null:oO(e[0]))??iO(n,g),a()}):null;return x?.observe(n),()=>{D.current=()=>{},o(),n.removeEventListener(`scroll`,p),n.removeEventListener(`wheel`,m),n.removeEventListener(`touchmove`,m),n.removeEventListener(`keydown`,v),e!=null&&clearTimeout(e),u!=null&&clearTimeout(u),r!=null&&delete r.dataset.isScrolling,i!=null&&(delete i.dataset.isScrolling,delete i.dataset.overlayReveal),y.current=!1,O.current=null,x?.disconnect()}},[t,g,s,c,h]),NO(()=>{Ve||be==null||Et(!1)},[Et,Ve,be]);let qt=PO(()=>be==null?null:`${be.path}::${be.source}`,[be]);NO(()=>{if(qt==null){m?.clearSlotContent(lb);return}let t=Se.current;if(t==null)return;let n=v.current??_.current;if(n==null)return;let r={anchorElement:n,anchorRect:t.anchorRect??pk(n.getBoundingClientRect()),close:e=>{Tt.current(e?.restoreFocus??!0)},restoreFocus:()=>{wt.current&&Ct.current(Se.current?.path??null)}},i=e?.contextMenu?.render?.(t.item,r)??null;return m?.setSlotContent(lb,i),e?.contextMenu?.onOpen?.(t.item,r),Ek(i),queueMicrotask(()=>{i==null||!i.isConnected||document.activeElement===i&&Ek(i)}),()=>{m?.clearSlotContent(lb)}},[qt,e?.contextMenu,m]),NO(()=>{be!=null&&t.getItem(be.path)==null&&Et()},[Et,be,t]),NO(()=>{if(be==null)return;let e=S.current?.getRootNode(),t=e instanceof ShadowRoot?e.host:S.current,n=e=>{let n=e.target;n instanceof Node&&(fk(e)||_.current?.contains(n)!==!0&&t?.contains(n)!==!0&&Et())},r=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Et())};return document.addEventListener(`mousedown`,n,!0),document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`mousedown`,n,!0),document.removeEventListener(`keydown`,r,!0)}},[Et,be]),NO(()=>{let e=C.current,n=S.current;if(e==null||n==null){N.current=tt;return}let r=tt==null?null:T.current.get(tt)??null,i=rO(n),a=i?.dataset.itemPath??null,o=Qe&&x.current===i,c=f&&w.current===i,l=F.current&&!$e,u=I.current??0,d=Ce.current,p=we.current,m=Te.current,g=Ee.current,_=i!=null,v=M.current||_,y=N.current!==tt,b=p!=null&&p===tt&&tt!=null,E=!1,O=!1;if(rt!=null&&rt.id!==k.current){k.current=rt.id;let n=rt.visibleIndex,r=t.getVisibleRows(n,n)[0]??null;if(r!=null){let t=h?Math.max(0,Math.min(r.ancestorPaths.length*s,Math.max(0,ft-s))):_t;E=!0,O=cO(e,n,s,ft,gt,rt.offset,t)}t.clearScrollRequest(rt.id)}let A=!E&&l&&lO(e,nt,s,ft,gt,u),j=!E&&d!=null&&d===tt&&lO(e,nt,s,ft,gt,_t),P=!E&&m!=null&&m.path===tt&&lO(e,nt,s,ft,gt,m.viewportOffset),ee=!E&&g!=null&&g.path===tt&&e.scrollTop!==g.scrollTop;if(ee&&(e.scrollTop=g.scrollTop),(ee||O||j||P||A||v&&y&&d!==tt&&!b&&sO(e,nt,s,ft,_t))&&D.current(),E){N.current=tt;return}if(!v){N.current=tt;return}if(o){N.current=tt;return}if(c&&!l){N.current=tt;return}if(r==null){l&&nt>=0&&(lO(e,nt,s,ft,gt,u),D.current()),N.current=tt;return}(y||l||d===tt||p===tt||m?.path===tt||g?.path===tt||a==null||a!==tt)&&(nO(r),d===tt&&(Ce.current=null),p===tt&&(we.current=null),m?.path===tt&&(Te.current=null),g?.path===tt&&(Ee.current=null),F.current=!1,I.current=null),N.current=tt},[t,nt,tt,yt,s,Qe,$e,pt,ft,f,rt,h,_t,gt,G]);let Jt=nt>=0&&nt>=dt.visible.startIndex&&nt<=dt.visible.endIndex,Yt=tt!=null&&mt.some(e=>WO(e.row)===tt),Xt=Jt||Yt,Zt=Ue&&M.current===!0&&Xt?tt:null,Qt=ge===`pointer`?V:null,$t=be?.path??De.current??Qt??Zt??V,en=be?.source===`right-click`;NO(()=>{y.current&&be==null||Dt(qe($t))},[be,qe,pt,ft,ve,mt,$t,Dt,G]);let tn=FO(e=>{if(y.current||fk(e))return;let t=e.target;if(!(t instanceof HTMLElement)||t.closest?.(`[data-type="context-menu-trigger"]`)!=null)return;let n=t.closest?.(`[data-file-tree-sticky-row="true"]`),r=t.closest?.(`[data-type="item"]`),i=n instanceof HTMLElement?n.dataset.fileTreeStickyPath??null:r instanceof HTMLElement?r.dataset.itemPath??null:null;i!=null&&_e(e=>e===`pointer`?e:`pointer`),pe(e=>e===i?e:i)},[]),K=FO(()=>{pe(null)},[]);NO(()=>{if(!it)return;let e=()=>{Rt(),t.cancelDrag()};return window.addEventListener(`dragend`,e),()=>{window.removeEventListener(`dragend`,e),Rt(),t.cancelDrag()}},[t,it]);let nn=e=>{if(!it||t.getDragSession()==null||ae.current)return;let n=$O(e.target instanceof HTMLElement?e.target:null);t.setDragTarget(n),Bt(t.getDragSession()?.target??null),Ht(e.clientX,e.clientY),e.dataTransfer!=null&&(e.dataTransfer.dropEffect=`move`),e.preventDefault()},rn=e=>{if(!it||t.getDragSession()==null||ae.current)return;let n=e.relatedTarget;n instanceof Node&&S.current?.contains(n)===!0||(Pt(),It(),t.setDragTarget(null))},an=e=>{!it||t.getDragSession()==null||ae.current||(e.preventDefault(),zt(e.clientX,e.clientY),t.completeDrag(),Ft(),Pt(),It(),R.current=null)},on=dt.window.height,sn=dt.window.offsetTop,cn=Math.min(0,ft-on),ln=Math.min(0,ft-on-_t),un=de===tt||F.current,dn=tt!=null&&un&&!yt&&nt>=0?G[nt]??t.getVisibleRows(nt,nt)[0]??null:null,fn=dn==null?null:uO(nt,s,pt,on),pn=R.current,mn=ct!=null&&pn!=null&&pn.path===ct&&pn.index>=pt.start&&pn.index<=pt.end,hn=ct!=null&&pn!=null&&pn.path===ct&&!mn&&pn.path!==dn?.path?pn:null,gn=hn==null?null:uO(hn.index,s,pt,on),_n=ck((nt>=0?G[nt]??t.getVisibleRows(nt,nt)[0]??null:null)?.ancestorPaths.at(-1)??null),vn=$e&&tt!=null?Ck(o,tt,!yt):void 0,yn=be?.path??($e?tt:de),bn=be?.path??V,xn=qe($t),Sn=Ve&&Ue&&!en&&!Qe&&xn!=null&&me!=null&&$t!=null,Cn=Ve&&(Sn||be!=null),wn=be?.anchorRect,Tn=wn==null&&xn!=null&&me!=null&&(be!=null||Sn)?me:null,En=wn==null?Tn==null?void 0:{top:`${Tn}px`}:{left:`${wn.left}px`,position:`fixed`,right:`auto`,top:`${wn.top}px`},Dn=en?{opacity:`0`}:void 0,On=FO((e,n,r,i)=>{let a=mO({event:{ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey},isDirectory:n.kind===`directory`,isSearchOpen:$e,mode:i}),o=a.toggleDirectory&&n.kind===`directory`,s=o?t.resolveMountedDirectoryPathFromInput(r):null;if(o&&s==null)return;let c=s??r;switch(a.selection.kind){case`range`:t.selectPathRange(c,a.selection.additive);break;case`toggle`:t.togglePathSelectionFromInput(c);break;case`single`:t.selectOnlyMountedPathFromInput(c)}let l=e.currentTarget instanceof HTMLElement?e.currentTarget:null,u=n.index>=dt.visible.startIndex&&n.index<=dt.visible.endIndex,d=i===`flow`&&u&&l!=null&&l.dataset.itemParked!==`true`;t.focusMountedPathFromInput(c),d&&(M.current=!0,fe(e=>e===c?e:c),_e(`focus`)),o&&t.toggleMountedDirectoryFromInput(c),a.closeSearch&&t.closeSearch(),a.revealCanonical&&At(c,{targetOffset:`sticky-parents`})},[t,$e,dt.visible.endIndex,dt.visible.startIndex,At]),kn=()=>{if(y.current||!Ue||$t==null||xn==null)return;let e=t.getItem($t);e!=null&&(Dt(xn),wt.current=!0,xe({anchorRect:null,item:{kind:e.isDirectory()?`directory`:`file`,name:xn.getAttribute(`aria-label`)??$t,path:e.getPath()},path:e.getPath(),source:`button`}))},An={contextHoverPath:bn,contextMenuButtonTriggerEnabled:Ue,contextMenuButtonVisibility:H,contextMenuEnabled:Ve,contextMenuRightClickEnabled:U,contextMenuTriggerMode:He,controller:t,directoriesWithGitChanges:i,dragAndDropEnabled:it,draggedPathSet:ot,dragTarget:st,gitLaneActive:Je,gitStatusByPath:n,handleRowDragEnd:Wt,handleRowDragStart:Ut,handleRowTouchStart:Gt,ignoredGitDirectories:r,ignoredInheritanceCache:le,instanceId:o,itemHeight:s,onKeyDown:Kt,onRowClick:On,openContextMenuForRow:Ot,registerButton:We,registerRenameInput:Ke,renameView:Xe,renderDecorationForRow:bt,resolveIcon:Ye,shouldSuppressContextMenu:jt,visualFocusPath:yn},jn={...An,registerButton:Ge};return Q(`div`,{ref:S,id:W,"data-file-tree-context-menu-button-visibility":Ve&&Ue?H:void 0,"data-file-tree-context-menu-trigger-mode":Ve?He:void 0,"data-file-tree-has-context-menu-action-lane":Ve&&Ue?`true`:void 0,"data-file-tree-has-git-lane":Je?`true`:void 0,"data-file-tree-virtualized-root":`true`,onDragLeave:it?rn:void 0,onDragOver:it?nn:void 0,onDrop:it?an:void 0,onKeyDown:Kt,onPointerLeave:Ve?K:void 0,onPointerOver:Ve?tn:void 0,role:`tree`,tabIndex:-1,style:{outline:`none`,position:`relative`},children:[Q(`style`,{"data-file-tree-guide-style":`true`,dangerouslySetInnerHTML:{__html:_n}}),Q(`slot`,{name:cb,"data-type":`header-slot`}),f?Q(`div`,{"data-file-tree-search-container":!0,"data-open":$e?`true`:`false`,children:Q(`input`,{ref:w,"aria-activedescendant":vn,"aria-controls":W,placeholder:`Search…`,"data-file-tree-search-input":!0,"data-file-tree-search-input-fake-focus":Ne?`true`:void 0,value:et,onBlur:()=>{d===`retain`&&!Fe.current||t.closeSearch()},onFocus:Ie,onPointerDown:Ie,onInput:e=>{Ie();let n=e.currentTarget;t.setSearch(n.value)}})}):null,Q(`div`,{ref:C,"data-file-tree-virtualized-scroll":`true`,children:[h&&ze&&mt.length>0?Q(`div`,{"aria-hidden":`true`,"data-file-tree-sticky-overlay":`true`,children:Q(`div`,{"data-file-tree-sticky-overlay-content":`true`,style:{height:`${lt}px`},children:mt.map((e,t)=>Ok(jn,e.row,`sticky:${WO(e.row)}`,{mode:`sticky`,style:{left:`0`,position:`absolute`,right:`0`,top:`${e.top}px`,zIndex:`${mt.length-t}`}}))})}):null,Q(`div`,{ref:b,"data-file-tree-virtualized-list":`true`,style:{height:`${gt}px`},children:[Q(`div`,{"data-file-tree-virtualized-sticky-offset":`true`,"aria-hidden":`true`,style:{height:`${sn}px`}}),Q(`div`,{"data-file-tree-virtualized-sticky":`true`,style:{height:`${on}px`,top:`${cn}px`,bottom:`${ln}px`},children:[kk(An,pt,vt),dn!=null&&fn!=null?Ok(An,dn,`parked:${dn.path}`,{isParked:!0,style:{left:`0`,opacity:`0`,pointerEvents:ct===dn.path?`none`:void 0,position:`absolute`,right:`0`,top:`${fn}px`}}):null,hn!=null&&gn!=null?Ok(An,hn,`parked-drag:${hn.path}`,{isParked:!0,style:{left:`0`,opacity:`0`,pointerEvents:`none`,position:`absolute`,right:`0`,top:`${gn}px`}}):null]})]})]}),Ve?Q(`div`,{ref:_,"data-type":`context-menu-anchor`,"data-visible":Cn?`true`:`false`,style:En,children:[Q(`button`,{ref:v,type:`button`,"data-type":ub,"aria-label":`Options`,"aria-haspopup":`menu`,"aria-expanded":be==null?`false`:`true`,"data-visible":Sn?`true`:`false`,onMouseDown:e=>{e.preventDefault()},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),be!=null){Et();return}kn()},tabIndex:-1,style:Dn,children:Q(xD,{...Ye(`file-tree-icon-ellipsis`)})}),be==null?null:Q(`slot`,{name:lb})]}):null,be==null?null:Q(`div`,{"data-type":`context-menu-wash`,"aria-hidden":`true`,onMouseDownCapture:e=>{e.preventDefault(),Et()},onTouchStartCapture:e=>{e.preventDefault(),e.stopPropagation(),Et()},onTouchMoveCapture:e=>{e.preventDefault(),e.stopPropagation()},onWheelCapture:e=>{e.preventDefault(),e.stopPropagation()}})]})}var jk={hydrateRoot:(e,t)=>{gD(KE(Ak,t),e)},renderRoot:(e,t)=>{hD(KE(Ak,t),e)},unmountRoot:e=>{hD(null,e)}};function Mk(e,t){jk.renderRoot(e,t)}function Nk(e,t){jk.hydrateRoot(e,t)}function Pk(e){jk.unmountRoot(e)}var Fk=class{#e=new Map;#t=null;clearAll(){for(let e of this.#e.values())e.remove();this.#e.clear()}clearSlotContent(e){let t=this.#n(e);t!=null&&(t.remove(),this.#e.delete(e))}setHost(e){if(this.#t=e,e!=null){this.#i(e);for(let[e,t]of this.#e)this.#r(e,t)}}setSlotContent(e,t){let n=this.#n(e);if(n===t){t!=null&&(this.#e.set(e,t),this.#r(e,t));return}if(n?.remove(),t==null){this.#e.delete(e);return}this.#e.set(e,t),this.#r(e,t)}setSlotHtml(e,t){let n=t?.trim()??``;if(n.length===0){this.setSlotContent(e,null);return}let r=this.#n(e);if(r!=null&&r.innerHTML===n){this.#e.set(e,r),this.#r(e,r);return}let i=document.createElement(`div`);i.innerHTML=n,this.setSlotContent(e,i)}#n(e){let t=this.#e.get(e)??null;if(t!=null)return t;let n=this.#t;if(n==null)return null;for(let t of Array.from(n.children))if(t instanceof HTMLElement&&t.dataset.fileTreeManagedSlot===e)return t;return null}#r(e,t){t.slot=e,t.dataset.fileTreeManagedSlot=e,this.#t!=null&&t.parentNode!==this.#t&&this.#t.appendChild(t)}#i(e){for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;let e=t.dataset.fileTreeManagedSlot;e==null||this.#e.has(e)||this.#e.set(e,t)}}};Array.isArray;var Ik=0;function Lk(e){return e!=null&&e.length>0?e:(Ik+=1,`pst_ft_${Ik}`)}function Rk({initialVisibleRowCount:e,itemHeight:t}){return e==null?420:Math.max(0,e)*(t??Px)}function zk(e){if(typeof document>`u`)return;let t=document.createElement(`div`);t.innerHTML=e;let n=t.querySelector(`svg`);return n instanceof SVGElement?n:void 0}function Bk(e){return e.querySelector(`#file-tree-icon-chevron`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-file`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-dot`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-lock`)instanceof SVGElement}function Vk(e){return Array.from(e.children).filter(e=>e instanceof SVGElement)}var Hk=class{static LoadedCustomComponent=!0;#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=new Fk;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y=null;#b;#x=!1;#S=!1;constructor(e){let{composition:t,density:n,fileTreeSearchMode:r,gitStatus:i,id:a,initialSearchQuery:o,icons:s,itemHeight:c,onSearchChange:l,onSelectionChange:u,overscan:d,renderRowDecoration:f,renaming:p,search:m,searchBlurBehavior:h,searchFakeFocus:g,stickyFolders:_,unsafeCSS:v,initialVisibleRowCount:y,...b}=e;this.#e=t,this.#n=Lk(a),this.#p=gE(i),this.#m=s,this.#h=v,this.#r=u,this.#i=f,this.#a=p!=null&&p!==!1,this.#o=h,this.#s=m===!0,this.#c=g===!0,this.#u=Nx(n,c),this.#d={itemHeight:this.#u.itemHeight,overscan:d,stickyFolders:_,initialVisibleRowCount:y},this.#t=new dE({...b,fileTreeSearchMode:r,initialSearchQuery:o,onSearchChange:l,renaming:p}),this.#v=this.#t.getSelectionVersion(),this.#y=this.#r==null?null:this.subscribe(()=>{this.#D()})}unmount(){this.#b!=null&&(Pk(this.#b),delete this.#b.dataset.fileTreeVirtualizedWrapper,this.#b=void 0),this.#l.clearAll(),this.#l.setHost(null),this.#f!=null&&(delete this.#f.dataset.fileTreeVirtualized,this.#I(this.#f),this.#f=void 0)}cleanUp(){this.unmount(),this.#y?.(),this.#y=null,this.#t.destroy()}getFileTreeContainer(){return this.#f}getItem(e){return this.#t.getItem(e)}getFocusedItem(){return this.#t.getFocusedItem()}getFocusedPath(){return this.#t.getFocusedPath()}getFocusedIndex(){return this.#t.getFocusedIndex()}getVisibleCount(){return this.#t.getVisibleCount()}getVisibleRows(e,t){return this.#t.getVisibleRows(e,t)}getSelectedPaths(){return this.#t.getSelectedPaths()}getComposition(){return this.#e}getItemHeight(){return this.#u.itemHeight}getDensityFactor(){return this.#u.factor}subscribe(e){let t=!1;return this.#t.subscribe(()=>{if(!t){t=!0;return}e()})}focusPath(e){this.#t.focusPath(e)}focusFirstItem(){this.#t.focusFirstItem()}focusLastItem(){this.#t.focusLastItem()}focusNextItem(){this.#t.focusNextItem()}focusPreviousItem(){this.#t.focusPreviousItem()}focusParentItem(){this.#t.focusParentItem()}scrollToPath(e,t){this.#t.scrollToPath(e,t)}focusNearestPath(e){return this.#t.focusNearestPath(e)}add(e){this.#t.add(e)}batch(e){this.#t.batch(e)}applyGitStatusPatch(e){let t=_E(this.#p,e);if(t===this.#p)return;this.#p=t;let n=this.#T();n!=null&&Mk(n.wrapper,this.#w())}move(e,t,n){this.#t.move(e,t,n)}onMutation(e,t){return this.#t.onMutation(e,t)}setSearch(e){this.#t.setSearch(e)}openSearch(e){this.#t.openSearch(e)}closeSearch(){this.#t.closeSearch()}isSearchOpen(){return this.#t.isSearchOpen()}getSearchValue(){return this.#t.getSearchValue()}getSearchMatchingPaths(){return this.#t.getSearchMatchingPaths()}focusNextSearchMatch(){this.#t.focusNextSearchMatch()}focusPreviousSearchMatch(){this.#t.focusPreviousSearchMatch()}startRenaming(e,t){return this.#t.startRenaming(e,t)}remove(e,t){this.#t.remove(e,t)}resetPaths(e,t){Array.isArray(e)?this.#t.resetPaths(e,t):this.#t.resetPaths(e)}setComposition(e){this.#e=e;let t=this.#T();t!=null&&(this.#O(),Mk(t.wrapper,this.#w()))}setGitStatus(e){let t=gE(e,this.#p);if(t===this.#p)return;this.#p=t;let n=this.#T();n!=null&&Mk(n.wrapper,this.#w())}setIcons(e){this.#m=e;let t=this.#T();t!=null&&(this.#E(t.host,t.wrapper),Mk(t.wrapper,this.#w()))}hydrate({fileTreeContainer:e}){let t=this.#P(e),n=this.#N(t);this.#O(),Nk(n,this.#w())}render({containerWrapper:e,fileTreeContainer:t}){let n=this.#P(t??this.#f,e),r=this.#N(n);this.#O(),Mk(r,this.#w())}#C(){return{initialViewportHeight:Rk({initialVisibleRowCount:this.#d.initialVisibleRowCount,itemHeight:this.#d.itemHeight}),itemHeight:this.#d.itemHeight,overscan:this.#d.overscan,stickyFolders:this.#d.stickyFolders}}#w(){return{composition:this.#e,controller:this.#t,gitStatusByPath:this.#p?.statusByPath,ignoredGitDirectories:this.#p?.ignoredDirectoryPaths,directoriesWithGitChanges:this.#p?.directoriesWithChanges,icons:this.#m,instanceId:this.#n,renamingEnabled:this.#a,renderRowDecoration:this.#i,searchBlurBehavior:this.#o,searchEnabled:this.#s,searchFakeFocus:this.#c,slotHost:this.#l,...this.#C()}}#T(){let e=this.#f,t=this.#b;return e==null||t==null?null:{host:e,wrapper:t}}#E(e,t){let n=e.shadowRoot;n!=null&&(this.#k(n),this.#A(n)),this.#j(t)}#D(){let e=this.#r;if(e==null)return;let t=this.#t.getSelectionVersion();t!==this.#v&&(this.#v=t,e(this.#t.getSelectedPaths()))}#O(){let e=this.#e?.header?.render;if(e!=null){this.#l.setSlotContent(cb,e());return}this.#l.setSlotHtml(cb,this.#e?.header?.html??null)}#k(e){let t=Vk(e).find(e=>Bk(e)),n=zk(Ex(jx(this.#m).set));n!=null&&(t==null||t.outerHTML!==n.outerHTML)&&(t==null?e.prepend(n):t.replaceWith(n))}#A(e){let t=Vk(e),n=t.find(e=>Bk(e)),r=t.filter(e=>e!==n),i=jx(this.#m).spriteSheet?.trim()??``;if(i.length===0){for(let e of r)e.remove();return}let a=zk(i);if(a==null){for(let e of r)e.remove();return}if(r.length!==1||r[0].outerHTML!==a.outerHTML){for(let e of r)e.remove();e.appendChild(a)}}#j(e){let t=jx(this.#m);t.colored&&Ox(t.set)?e.dataset.fileTreeColoredIcons=`true`:delete e.dataset.fileTreeColoredIcons}#M(e){let t=e.querySelector(`style[${ib}]`);if(this.#g==null&&t instanceof HTMLStyleElement&&(this.#g=t),this.#h==null||this.#h===``){this.#g?.remove(),this.#g=void 0,this.#_=void 0;return}(this.#g?.parentNode!==e||this.#_!==this.#h)&&(this.#g??=document.createElement(`style`),this.#g.setAttribute(ib,``),this.#g.parentNode!==e&&e.appendChild(this.#g),this.#g.textContent=Rx(this.#h),this.#_=this.#h)}#N(e){if(this.#b!=null)return this.#b;let t=e.shadowRoot;if(t==null)throw Error(`FileTree requires a shadow root`);let n=Array.from(t.children).filter(e=>e instanceof HTMLDivElement&&typeof e.dataset.fileTreeId==`string`&&e.dataset.fileTreeId.length>0),r=n.find(e=>e.dataset.fileTreeId===this.#n)??n[0];return r!=null&&(this.#n=r.dataset.fileTreeId??this.#n),this.#b=r??document.createElement(`div`),this.#b.dataset.fileTreeId=this.#n,this.#b.dataset.fileTreeVirtualizedWrapper=`true`,this.#E(e,this.#b),this.#b.parentNode!==t&&t.appendChild(this.#b),this.#b}#P(e,t){let n=e??this.#f??document.createElement(`file-tree-container`);t!=null&&n.parentNode!==t&&t.appendChild(n);let r=n.shadowRoot??n.attachShadow({mode:`open`});return Wx(n,r),this.#M(r),n.dataset.fileTreeVirtualized=`true`,n.style.display=`flex`,this.#F(n),this.#l.setHost(n),this.#f=n,n}#F(e){e.style.getPropertyValue(`--trees-item-height`)===``&&(e.style.setProperty(`--trees-item-height`,`${String(this.#u.itemHeight)}px`),this.#x=!0),e.style.getPropertyValue(`--trees-density-override`)===``&&(e.style.setProperty(`--trees-density-override`,String(this.#u.factor)),this.#S=!0)}#I(e){this.#x&&=(e.style.removeProperty(`--trees-item-height`),!1),this.#S&&=(e.style.removeProperty(`--trees-density-override`),!1)}};function Uk(e){let[t]=(0,q.useState)(()=>new Hk(e)),n=(0,q.useRef)({timeout:null,model:t});return(0,q.useEffect)(()=>{let{current:e}=n;return e.timeout!=null&&(clearTimeout(e.timeout),e.timeout=null),()=>{e.timeout=setTimeout(()=>e.model.cleanUp(),1)}},[]),{model:t}}function Wk(e){return e.name.startsWith(`.`)}function Gk(e,t,n=0){return mi(e,_o,Pr.of(e,`tree`,e?.capabilities.version??0,t,n),async(e,r)=>{let i=await e.list({path:t,offset:n,limit:256});return r.throwIfAborted(),{...i,entries:i.entries.filter(e=>!Wk(e))}})}function Kk(){return{known:new Set,projected:new Map}}function qk(e,t){t.known.clear(),t.projected.clear(),e.resetPaths([])}function Jk(e,t,n){t.length===0&&qk(e,n);for(let{request:r,listing:i}of t){let t=`${r?.path??i.path}:${String(r?.offset??0)}`,a=i.entries.filter(e=>e.type!==`symlink`).map(e=>Yk(i.path,e.name,e.type)),o=n.projected.get(t)??[];n.projected.set(t,a);let s=new Set([...n.projected.values()].flat());for(let t of o)if(!s.has(t)){e.getItem(t)&&e.remove(t,{recursive:!0});for(let e of n.known)(e===t||t.endsWith(`/`)&&e.startsWith(t))&&n.known.delete(e)}Xk(e,i,n.known)}}function Yk(e,t,n){return`${e.endsWith(`/`)?e:`${e}/`}${t}${n===`directory`?`/`:``}`}function Xk(e,t,n){let r=t.entries.filter(e=>e.type!==`symlink`).map(e=>Yk(t.path,e.name,e.type)),i=r.filter(t=>!n.has(t)&&!e.getItem(t));i.length>0&&e.batch(i.map(e=>({type:`add`,path:e}))),n.add(t.path);for(let e of r)n.add(e);return i}function Zk(e,t){let n=t===`/`?`/`:t.replace(/\/+$/,``);if(n!==`/`&&e!==n&&!e.startsWith(`${n}/`))return[];let r=n===`/`?e.split(`/`).filter(Boolean):e.slice(n.length).split(`/`).filter(Boolean),i=[n],a=n;for(let e of r.slice(0,-1))a=`${a===`/`?``:a}/${e}`,i.push(a);return i}function Qk({app:e,rootPath:t,activePath:n}){let r=on(),i=zf(e),a=(0,q.useCallback)(t=>e.capabilities.subscribe(t),[e]),o=(0,q.useCallback)(()=>e.capabilities.version,[e]),s=(0,q.useSyncExternalStore)(a,o,o),c=(0,q.useMemo)(()=>({app:e,rootPath:t,computerId:i,version:s}),[e,t,i,s]),[l,u]=(0,q.useState)(null),d=l?.scope===c?l:null,f=n?Zk(n,t):[],p=d?.activePath===n?d.path:f.at(-1)??t,m=new Map;for(let e of[t,...f])m.set(`${e}:0`,{path:e,offset:0});for(let e of d?.pages??[])m.set(`${e.path}:${String(e.offset)}`,e);let h=[...m.values()],g=(t,n)=>Pr.of(e,`tree`,s,t,n);return{scope:c,snapshot:Hs({queries:h.map(({path:t,offset:n})=>Gk(e,t,n)),combine:e=>({listings:e.flatMap((e,t)=>e.data?[{request:h[t],listing:e.data}]:[]),busy:e.some(e=>e.isFetching),failure:e.find(e=>e.error)?.error??null})}),focusedPath:p,requestPage:(e,t)=>{let i=e.replace(/\/+$/,``)||`/`,a=g(i,t);r.getQueryState(a)?.status===`error`&&r.invalidateQueries({queryKey:a,exact:!0}),u(e=>({scope:c,activePath:n,path:i,pages:[...e?.scope===c?e.pages.filter(e=>e.path!==i||e.offset!==t):[],{path:i,offset:t}]}))},reload:()=>{r.invalidateQueries({queryKey:Pr.of(e,`tree`,s)})}}}var $k=()=>globalThis.matchMedia(`(pointer: coarse)`).matches?44:32,eA=()=>`Library`,tA=(e,t)=>`${eA()}${t.slice(e.length)}`,nA=(e,t)=>`${e}${t.replace(/\/$/,``).slice(eA().length)}`,rA=e=>e===void 0?`${eA()}/`:`${eA()}/${e}/`;function iA(e){if(!e.endsWith(`/`))return null;let t=e.slice(0,-1);return t===eA()?{folder:void 0}:t.startsWith(`${eA()}/`)?{folder:t.slice(eA().length+1)}:null}var aA=e=>e.replace(/\/$/,``)===eA(),oA=e=>({flex:1,minHeight:0,"--trees-item-height":`${String(e)}px`,"--trees-padding-inline-override":`var(--spacing-xs)`,"--trees-item-margin-x-override":`0px`,"--trees-item-padding-x-override":`var(--spacing-xs)`,"--trees-item-row-gap-override":`var(--spacing-xs)`,"--trees-bg-override":`transparent`,"--trees-border-color-override":`var(--stipe-hairline)`,"--trees-focus-ring-color-override":`var(--color-primary)`,"--trees-fg-override":`var(--color-base-content)`,"--trees-bg-muted-override":`var(--color-base-200)`,"--trees-selected-bg-override":`var(--color-base-300)`,"--trees-border-radius-override":`var(--radius-field)`,"--trees-font-family-override":`var(--font-sans)`,"--trees-font-size-override":`13px`,"--trees-search-bg-override":`var(--color-base-200)`,"--trees-search-fg-override":`var(--color-base-content)`});function sA({app:e,root:t,activeFolder:n,active:r=!0,mode:i,onSelectFolder:a,onDrop:o,onRename:s,onNewFolder:c,onMoveRows:l,canWrite:u,version:d}){let f=rA(n),{scope:p,snapshot:m,requestPage:h,reload:g}=Qk({app:e,rootPath:t,activePath:`${dg(t,n)}/.`}),_=(0,q.useRef)(!1),v=(0,q.useRef)({quiet:!1,root:t,mode:i,onSelectFolder:a,onDrop:o,onRename:s,onNewFolder:c,onMoveRows:l,requestPage:h});v.current={quiet:v.current.quiet,root:t,mode:i,onSelectFolder:a,onDrop:o,onRename:s,onNewFolder:c,onMoveRows:l,requestPage:h};let y=i===`browse`&&u,[b]=(0,q.useState)($k),{model:x}=Uk({paths:[],itemHeight:b,initialExpansion:1,flattenEmptyDirectories:!1,search:i===`browse`,composition:{contextMenu:{enabled:i===`browse`}},onSelectionChange(e){if(v.current.quiet||_.current)return;let t=e.at(-1);if(t===void 0||e.length!==1)return;let n=iA(t);n!==null&&(v.current.requestPage(nA(v.current.root,t),0),v.current.onSelectFolder(n.folder))},dragAndDrop:y?{canDrag:e=>e.every(e=>!aA(e)),canDrop:({target:e})=>e.kind===`directory`&&e.directoryPath!==null&&iA(e.directoryPath)!==null,onDropComplete:({draggedPaths:e,target:t})=>{let n=t.directoryPath===null?null:iA(t.directoryPath);n!==null&&v.current.onDrop?.(e.map(e=>nA(v.current.root,e)),n.folder)}}:void 0,renaming:y?{canRename:e=>!aA(e.path),onRename:({sourcePath:e,destinationPath:t})=>{let n=t.replace(/\/$/,``).split(`/`).at(-1);n!==void 0&&v.current.onRename?.(nA(v.current.root,e),n)}}:void 0}),S=(0,q.useRef)(Kk());(0,q.useLayoutEffect)(()=>{qk(x,S.current)},[x,p,d]);let C=(0,q.useRef)(d);(0,q.useEffect)(()=>{C.current!==d&&(C.current=d,g())},[g,d]),(0,q.useLayoutEffect)(()=>{let e=m.listings.map(({request:e,listing:n})=>({request:e,listing:{...n,path:tA(t,n.path),entries:n.entries.filter(e=>e.type===`directory`)}}));Jk(x,e,S.current)},[x,t,m.listings]);let w=(0,q.useRef)(null);return(0,q.useLayoutEffect)(()=>{v.current.quiet=!0;try{if(!r){w.current=null;for(let e of x.getSelectedPaths())x.getItem(e)?.deselect();return}e()}finally{v.current.quiet=!1}function e(){if(w.current===f)return;let e=x.getItem(f);if(!e)return;w.current=f;for(let e of x.getSelectedPaths())e!==f&&x.getItem(e)?.deselect();e.isSelected()||e.select();let t=f.slice(0,-1).split(`/`);for(let e=1;e<t.length;e+=1){let n=x.getItem(`${t.slice(0,e).join(`/`)}/`);n&&`expand`in n&&!n.isExpanded()&&n.expand()}}},[r,f,x,m.listings]),(0,q.useEffect)(()=>{m.failure&&Wt.error(It(m.failure).message,{id:`prints-tree-error`,toasterId:`prints-generation-notices`,action:{label:`Retry`,onClick:g}})},[g,m.failure]),(0,J.jsx)(`div`,{className:`prints-tree`,"data-library-tree":i,onDragStartCapture:()=>{_.current=!0},onDragEnd:()=>{_.current=!1},onDrop:()=>{_.current=!1},children:(0,J.jsx)(gb,{model:x,className:`prints-tree-view`,style:oA(b),renderContextMenu:i===`browse`?(e,n)=>{let r=iA(e.path);return(0,J.jsxs)(`div`,{className:`flex min-w-40 flex-col gap-xs p-xs`,role:`menu`,children:[r===null?null:(0,J.jsxs)(U,{className:`w-full justify-start`,disabled:!u,role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{n.close({restoreFocus:!1}),v.current.onNewFolder?.(r.folder)},children:[(0,J.jsx)(Ch,{"aria-hidden":`true`}),` New folder`]}),(0,J.jsxs)(U,{className:`w-full justify-start`,disabled:!u||aA(e.path),role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{n.close({restoreFocus:!1}),x.startRenaming(e.path)},children:[(0,J.jsx)(Nh,{"aria-hidden":`true`}),` Rename`]}),(0,J.jsxs)(U,{className:`w-full justify-start`,disabled:!u||aA(e.path),role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{n.close({restoreFocus:!1});let r=x.getSelectedPaths(),i=r.includes(e.path)?r:[e.path];v.current.onMoveRows?.(i.map(e=>nA(t,e)))},children:[(0,J.jsx)(On,{"aria-hidden":`true`}),` Move to…`]})]})}:void 0})})}function cA({view:e,onView:t,onNewFolder:n,canWrite:r,...i}){return(0,J.jsxs)(`nav`,{className:`prints-rail`,"aria-label":`Library`,children:[(0,J.jsxs)(`div`,{className:`prints-rail-views`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`prints-rail-view`,"aria-current":e.kind===`all`?`page`:void 0,onClick:()=>{t({kind:`all`})},children:[(0,J.jsx)(Mr,{"aria-hidden":!0,size:16}),` All prints`]}),(0,J.jsxs)(`button`,{type:`button`,className:`prints-rail-view`,"aria-current":e.kind===`favorites`?`page`:void 0,onClick:()=>{t({kind:`favorites`})},children:[(0,J.jsx)(fr,{"aria-hidden":!0,size:16}),` Favorites`]})]}),(0,J.jsxs)(`div`,{className:`prints-rail-head`,children:[(0,J.jsx)(`span`,{children:`Folders`}),(0,J.jsx)(U,{size:`sm`,variant:`ghost`,"aria-label":`New folder`,title:`New folder`,disabled:!r,onClick:()=>{n(e.kind===`folder`?e.folder:void 0)},children:(0,J.jsx)(Ch,{"aria-hidden":!0,size:16})})]}),(0,J.jsx)(sA,{...i,mode:`browse`,canWrite:r,activeFolder:e.kind===`folder`?e.folder:void 0,active:e.kind===`folder`,onNewFolder:n,onSelectFolder:e=>{t({kind:`folder`,folder:e})}})]})}var lA=`prints-generation-notices`;function uA({count:e,total:t,canWrite:n,onToggleAll:r,onMove:i,onFavorite:a,onDone:o}){let s=t>0&&e===t;return(0,J.jsxs)(`div`,{className:`prints-select-bar`,role:`toolbar`,"aria-label":`Selection`,children:[(0,J.jsx)(`span`,{className:`prints-select-count`,"aria-live":`polite`,children:e===0?`Choose prints`:`${String(e)} selected`}),(0,J.jsxs)(U,{size:`sm`,variant:`ghost`,className:`prints-select-all`,disabled:t===0,onClick:r,children:[(0,J.jsx)(`span`,{className:`prints-select-wide`,children:s?`Clear selection`:`Select all in view`}),(0,J.jsx)(`span`,{className:`prints-select-narrow`,children:s?`None`:`All`})]}),(0,J.jsx)(`span`,{className:`prints-select-spacer`}),(0,J.jsxs)(U,{size:`sm`,variant:`ghost`,"aria-label":`Favorite`,disabled:e===0||!n,onClick:a,children:[(0,J.jsx)(fr,{"aria-hidden":!0,size:16}),(0,J.jsx)(`span`,{className:`prints-select-wide`,children:`Favorite`})]}),(0,J.jsxs)(U,{size:`sm`,disabled:e===0||!n,onClick:i,children:[(0,J.jsx)(On,{"aria-hidden":!0,size:16}),(0,J.jsxs)(`span`,{className:`prints-select-wide`,children:[`Move to… (`,e,`)`]}),(0,J.jsxs)(`span`,{className:`prints-select-narrow`,children:[`Move (`,e,`)`]})]}),(0,J.jsx)(pt,{className:`prints-select-done`,"aria-label":`Done selecting`,title:`Done selecting`,icon:(0,J.jsx)(Ei,{}),size:`sm`,onClick:o})]})}function dA({view:e,lastFolder:t,onOpen:n,onFolders:r,subfolders:i,onOpenSubfolder:a}){return(0,J.jsxs)(`div`,{className:`prints-library-bar`,children:[(0,J.jsx)(_t,{className:`prints-folders-button`,density:`compact`,label:null,"aria-label":`Folders`,title:`Folders`,icon:(0,J.jsx)(wh,{size:16}),onClick:r}),(0,J.jsx)(Sr,{className:`prints-view-switch`,value:e.kind,onValueChange:e=>{n(e===`all`||e===`favorites`?{kind:e}:{kind:`folder`,folder:t})},children:(0,J.jsxs)(Er,{variant:`segmented`,"aria-label":`View`,children:[(0,J.jsx)(Gn,{value:`folder`,children:`Folder`}),(0,J.jsx)(Gn,{value:`all`,children:`All`}),(0,J.jsx)(Gn,{value:`favorites`,children:`Favorites`})]})}),i.length>0?(0,J.jsx)(`div`,{className:`prints-folder-chips`,role:`list`,"aria-label":`Folders`,children:i.map(e=>(0,J.jsx)(_t,{role:`listitem`,density:`compact`,className:`prints-folder-chip`,icon:(0,J.jsx)(Th,{size:16}),label:e,onClick:()=>{a(e)}},e))}):null]})}function fA({app:e,root:t,from:n,canWrite:r,count:i,open:a,version:o,onClose:s,onMove:c}){let[l,u]=(0,q.useState)(n?.folder),[d,f]=(0,q.useState)(``);(0,q.useEffect)(()=>{a&&u(n?.folder)},[a,n?.folder]);let p=d.trim(),m=p===``||ug(p)&&!p.includes(`/`),h=p===``?l:l===void 0?p:`${l}/${p}`,g=n!==null&&p===``&&h===n.folder;return(0,J.jsx)(cm,{open:a,onOpenChange:e=>{e||(f(``),s())},children:(0,J.jsxs)(pm,{className:`prints-move-dialog`,children:[(0,J.jsx)(hm,{children:(0,J.jsxs)(gm,{children:[`Move `,String(i),` `,i===1?`item`:`items`,` to…`]})}),(0,J.jsx)(`div`,{className:`prints-move-tree`,children:(0,J.jsx)(sA,{app:e,root:t,activeFolder:l,mode:`pick`,canWrite:r,version:o,onSelectFolder:u})}),(0,J.jsxs)(`label`,{className:`prints-move-new`,htmlFor:`prints-move-new-folder`,children:[(0,J.jsxs)(`span`,{children:[`New folder inside `,l??`the library`]}),(0,J.jsx)(py,{id:`prints-move-new-folder`,value:d,placeholder:`Folder name`,"aria-invalid":!m,onChange:e=>{f(e.target.value)}})]}),(0,J.jsxs)(mm,{children:[(0,J.jsx)(_m,{render:(0,J.jsx)(U,{variant:`outline`,size:`sm`}),children:`Cancel`}),(0,J.jsx)(U,{size:`sm`,disabled:!m||!r||g,onClick:()=>{f(``),c(h,p!==``)},children:g?`Choose a folder`:`Move to ${h===void 0?`Library`:h.split(`/`).at(-1)??``}`})]})]})})}var pA={conflict:`a file or folder with that name is already there`,not_found:`it is no longer in the library`,invalid:`a folder can't move into itself`,not_granted:`Prints isn't allowed to change this Computer`,unavailable:`the Computer didn't answer`};function mA(e,t,n,r){let{moved:i,failed:a}=n;if(a.length>0){let e=a[0];Wt.error(`Couldn't move ${String(a.length)} ${a.length===1?`item`:`items`}: ${pA[e.error]}.`,{toasterId:lA,id:`prints-move-error`})}i.length!==0&&Wt(`Moved ${String(i.length)} ${i.length===1?`item`:`items`}`,{toasterId:lA,duration:8e3,action:{label:`Undo`,onClick:()=>{let n=new Map;for(let{from:e,to:r}of i){let i=fg(t,e)??``;n.set(i,[...n.get(i)??[],r])}Promise.all([...n].map(([t,n])=>Sg(e,{paths:n,folder:t===``?void 0:t}))).then(()=>{r()},e=>{tn(`prints-undo-move`,e),Wt.error(`Couldn't undo that move.`,{toasterId:lA}),r()})}}})}function hA({parent:e,open:t,onClose:n,onCreate:r}){let[i,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(!1),u=()=>{a(``),s(null),n()},d=async()=>{l(!0);let e=await r(i);l(!1),e===null?u():(s(e),Wt.error(e,{toasterId:lA,id:`prints-new-folder`}))};return(0,J.jsx)(cm,{open:t,onOpenChange:e=>{e||u()},children:(0,J.jsxs)(pm,{className:`prints-new-folder-dialog`,children:[(0,J.jsx)(hm,{children:(0,J.jsxs)(gm,{children:[`New folder in `,e??`the library`]})}),(0,J.jsxs)(`form`,{id:`prints-new-folder-form`,onSubmit:e=>{e.preventDefault(),d()},children:[(0,J.jsx)(`label`,{htmlFor:`prints-new-folder-name`,children:`Name`}),(0,J.jsx)(py,{id:`prints-new-folder-name`,autoFocus:!0,value:i,placeholder:`Characters`,"aria-invalid":o!==null,onChange:e=>{a(e.target.value),s(null)}})]}),(0,J.jsxs)(mm,{children:[(0,J.jsx)(_m,{render:(0,J.jsx)(U,{variant:`outline`,size:`sm`}),children:`Cancel`}),(0,J.jsx)(U,{size:`sm`,type:`submit`,form:`prints-new-folder-form`,disabled:c||i.trim()===``,children:`Create`})]})]})})}var gA=24,_A=`prints-generation-notices`;function vA(e,t){let[n,r]=(0,q.useState)({entries:[],index:-1}),i=(e,t)=>e.kind===t.kind&&(e.kind!==`folder`||t.kind===`folder`&&e.folder===t.folder),a=n=>{r(t=>{let r=t.entries[t.index]??e;if(i(r,n))return t;let a=t.entries.slice(0,t.index+1),o=a.length===0?[e]:a;return{entries:[...o,n],index:o.length}}),t(n)},o=e=>{let i=n.index+e;if(i<0||i>=n.entries.length)return!1;let a=n.entries[i];return r({...n,index:i}),t(a),!0};return{open:a,canGoBack:n.index>0,canGoForward:n.index>=0&&n.index<n.entries.length-1,back:()=>o(-1),forward:()=>o(1)}}function yA({app:e,destination:t,view:n,setView:r,entries:i,canWrite:a}){let o=on(),s=vA(n,r),[c,l]=(0,q.useState)(0),[u,d]=(0,q.useState)(),f=n.kind===`folder`?n.folder:void 0,p=n.kind===`folder`;(0,q.useEffect)(()=>{p&&d(f)},[p,f]);let[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(new Set),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(new Map),w=e?.capabilities.has(Ci)===!0,T=Hs({queries:(0,q.useMemo)(()=>{let e=i.map(e=>e.path),t=[];for(let n=0;n<e.length;n+=gA)t.push(e.slice(n,n+gA));return t},[i]).map(n=>({...mi(e,Ci,Og.described(e,n),async(t,r)=>{if(!e)return[];let i=await Cg(e,n);return r.throwIfAborted(),i}),enabled:w&&t!==null,retry:!1})),combine:e=>{let t=new Map;for(let n of e)for(let e of n.data??[])t.set(e.path,e);return t}}),E=(0,q.useCallback)(()=>{l(e=>e+1),_(new Set),o.invalidateQueries({queryKey:Og.listings(e)}),o.invalidateQueries({queryKey:Og.describedAll(e)})},[e,o]),D=(0,q.useCallback)(async(n,r,i={})=>{if(!(!e||t===null)){try{mA(e,t,await Sg(e,{paths:n,folder:r,createFolder:i.create??!1,name:i.name}),E)}catch(e){tn(`prints-move-files`,e),Wt.error(`Couldn't move those. Check the Computer and try again.`,{toasterId:_A,id:`prints-move-error`})}E()}},[e,t,E]),O=(0,q.useCallback)((t,r)=>{e&&(C(e=>{let n=new Map(e);for(let e of t)n.set(e,r);return n}),wg(e,t,r).then(()=>{o.invalidateQueries({queryKey:Og.describedAll(e)}),n.kind===`favorites`&&o.invalidateQueries({queryKey:Og.listings(e)})},e=>{tn(`prints-set-favorite`,e),Wt.error(`Couldn't change that favorite.`,{toasterId:_A,id:`prints-favorite-error`}),C(e=>{let n=new Map(e);for(let e of t)n.delete(e);return n})}))},[e,o,n.kind]),k=(0,q.useCallback)(async(n,r)=>{if(!e||t===null)return`Choose a library folder first.`;let i=r.trim();if(!ug(i)||i.includes(`/`))return`Use a single name, without slashes.`;let a=n===void 0?i:`${n}/${i}`;if(!ug(a))return`That folder name is too long.`;try{await e.capabilities.require(Ra).mkdir({path:dg(t,a)})}catch(e){return tn(`prints-new-folder`,e),`Couldn't create the folder. Check Computer write access.`}return E(),s.open({kind:`folder`,folder:a}),null},[e,t,s,E]),A=(0,q.useMemo)(()=>n.kind===`folder`?[{id:``,label:t?.split(`/`).at(-1)??`Library`},...pg(n.folder).map(({name:e,folder:t})=>({id:t,label:e}))].slice(-8):[{id:n.kind,label:n.kind===`all`?`All prints`:`Favorites`}],[t,n]),j=e=>S.get(e)??T.get(e)?.favorite??!1,M=e=>{if(t===null||!e.path.startsWith(`${t}/`))return e;let r=T.get(e.path),o=S.get(e.path)??r?.favorite??!1,s=i.find(t=>t.path===e.path),c={...e,badge:void 0,folderCaption:n.kind===`folder`?void 0:s?.folder,favorite:o,select:{active:m,checked:g.has(e.path),onToggle:()=>{_(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n})}}};return!e.pending&&r!==void 0&&(c.badge=r.kind===null?{label:null,seconds:null}:{label:r.modelLabel??r.model,seconds:r.durationSeconds}),w&&(c.onToggleFavorite=()=>{O([e.path],!o)}),w&&a&&(c.onMove=()=>{y([e.path])}),c},N=n.kind===`all`?`All prints`:n.kind===`favorites`?`Favorites`:n.folder?.split(`/`).at(-1)??`Library`,P=n.kind===`folder`&&n.folder!==void 0?n.folder.split(`/`).slice(0,-1).join(`/`):null;return{title:N,up:P===null?void 0:()=>{s.open({kind:`folder`,folder:P===``?void 0:P})},lastFolder:u,history:s,version:c,refresh:E,crumbs:A,selecting:m,setSelecting:e=>{h(e),e||_(new Set)},selected:g,selectAll:e=>{_(new Set(e))},moving:v,setMoving:y,newFolder:b,setNewFolder:x,move:D,toggleFavorite:O,createFolder:k,enrich:M,isFavorite:j,folderOf:fg}}function bA(e,t){return{kind:`button`,id:`folder`,text:t.checking?`Checking…`:`prints`,icon:`folder`,title:e===null?`Choose where Prints saves images`:v(`Save prints to ${e}`,1024),opens:`dialog`,expanded:t.editing}}var xA=(0,q.forwardRef)(function({className:e,label:t,...n},r){return(0,J.jsx)(_t,{...n,ref:r,className:V(`parakeet-composer-model-key`,e),label:t,readout:(0,J.jsx)(ai,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)] shrink-0`})})}),SA={unchecked:`M3.25 5.9 L5.1 7.9 L8.8 3.8`,checked:`M3.25 5.9 L5.1 7.9 L8.8 3.8`,mixed:`M3.4 6 L6 6 L8.6 6`},CA={blurStdDeviation:.22,alphaSlope:18,alphaIntercept:-8};function wA({state:e}){let t=`caps-checkbox-${(0,q.useId)().replaceAll(`:`,``)}`,n=(0,q.useRef)(null),r=(0,q.useRef)(e).current,i=(0,q.useRef)(e),a=ce();return(0,q.useLayoutEffect)(()=>{if(!n.current)return;let t=e!==`unchecked`,r=i.current!==`unchecked`,s=a||i.current===e;i.current=e;let c=Tt(n.current),l=Ur(c,{ease:`inCubic`,duration:160}),u=Po(n.current,{d:{to:SA[e],...s?ki:Ur(c,{ease:`outCubic`,duration:200})},"stroke-dashoffset":{to:+!t,...s?ki:t?Ur(c,{ease:`inOutSine`,duration:260}):l},"stroke-width":s?{to:t?2.4:0,duration:0}:t&&!r?[{to:2.2,...Ur(c,{ease:`outCubic`,duration:65})},{to:2.4,delay:o(c,120),...fi(c,{bounce:.35,duration:220})}]:{to:t?2.4:0,...l}});return()=>{u.cancel()}},[e,a]),(0,J.jsxs)(`svg`,{className:`caps-checkbox-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,J.jsxs)(`defs`,{children:[(0,J.jsx)(f,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,J.jsx)(xe,{id:`${t}-shadow`}),(0,J.jsx)(gn,{id:`${t}-inset`}),(0,J.jsx)(Qe,{id:`${t}-goo`,values:CA}),(0,J.jsxs)(`filter`,{id:`${t}-relief`,x:`-25%`,y:`-25%`,width:`150%`,height:`150%`,colorInterpolationFilters:`sRGB`,children:[(0,J.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`0.28`,result:`relief`}),(0,J.jsx)(`feSpecularLighting`,{in:`relief`,surfaceScale:`1.2`,specularConstant:`0.55`,specularExponent:`18`,lightingColor:`color-mix(in srgb, var(--color-white) calc(var(--depth) * 100%), var(--color-black))`,result:`light`,children:(0,J.jsx)(`feDistantLight`,{azimuth:`225`,elevation:`55`})}),(0,J.jsx)(`feComposite`,{in:`light`,in2:`SourceAlpha`,operator:`in`,result:`clipped-light`}),(0,J.jsx)(`feBlend`,{in:`SourceGraphic`,in2:`clipped-light`,mode:`screen`})]}),(0,J.jsx)(`mask`,{id:`${t}-contour`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`12`,height:`12`,style:{maskType:`alpha`},children:(0,J.jsx)(`path`,{ref:n,d:SA[r],fill:`none`,stroke:`var(--color-white)`,strokeWidth:r===`unchecked`?0:2.4,pathLength:`1`,strokeDasharray:`1`,strokeDashoffset:+(r===`unchecked`),strokeLinecap:`round`,strokeLinejoin:`round`,filter:e===`mixed`?void 0:`url(#${t}-goo)`})}),(0,J.jsx)(`clipPath`,{id:`${t}-well`,children:(0,J.jsx)(`rect`,{x:`1`,y:`1`,width:`10`,height:`10`,rx:`2.5`})})]}),(0,J.jsx)(`rect`,{className:`caps-checkbox-track`,x:`0.5`,y:`0.5`,width:`11`,height:`11`,rx:`3`,filter:`url(#${t}-inset)`}),(0,J.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,J.jsx)(`g`,{filter:`url(#${t}-shadow)`,children:(0,J.jsx)(`g`,{filter:`url(#${t}-relief)`,children:(0,J.jsx)(`g`,{mask:`url(#${t}-contour)`,children:(0,J.jsx)(`rect`,{x:`0`,y:`0`,width:`12`,height:`12`,fill:`url(#${t}-surface)`})})})})})]})}var TA=(0,q.forwardRef)(function({className:e,appearance:t,indicator:n,invalid:r,indeterminate:i=!1,checked:a,defaultChecked:o=!1,onChange:s,...c},l){let u=(0,q.useRef)(null),[d,f]=(0,q.useState)(o),p=a??d,m=i?`mixed`:p?`checked`:`unchecked`;return(0,q.useImperativeHandle)(l,()=>{if(!u.current)throw Error(`Checkbox input is not mounted`);return u.current},[]),(0,q.useLayoutEffect)(()=>{u.current&&(u.current.indeterminate=i)},[i]),(0,q.useEffect)(()=>{let e=u.current?.form;if(!e||a!==void 0)return;let t=e=>{queueMicrotask(()=>{!e.defaultPrevented&&u.current&&f(o)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[a,o,c.form]),(0,J.jsxs)(`span`,{className:`caps-checkbox`,"data-appearance":t===`compact`?t:void 0,"data-state":m,"data-custom-indicator":n!==void 0||void 0,children:[(0,J.jsx)(`input`,{...c,checked:p,"aria-checked":i?`mixed`:p,"aria-invalid":r?!0:c[`aria-invalid`]===!1?void 0:c[`aria-invalid`],className:V(`caps-checkbox-input`,e),onChange:e=>{a===void 0&&f(e.target.checked),s?.(e),e.currentTarget.indeterminate=i},ref:u,type:`checkbox`}),n===void 0?(0,J.jsx)(wA,{state:m}):n]})});function EA({getKey:e,isDisabled:t=()=>!1,items:n}){let r=(0,q.useMemo)(()=>{let r=n.map(e);if(r.some(e=>!e))throw Error(`Selectable items require non-empty keys`);if(new Set(r).size!==r.length)throw Error(`Selectable items require unique keys`);return n.filter(e=>!t(e))},[e,t,n]),[i,a]=(0,q.useState)(null);(0,q.useEffect)(()=>{i!==null&&!r.some(t=>e(t)===i)&&a(null)},[i,r,e]);let o=r.find(t=>e(t)===i),s=o?r.findIndex(t=>e(t)===i):-1;return{activeIndex:s,activeItem:o,activeKey:i,enabledItems:r,move:(t,n)=>{if(r.length===0)return;let i=n?n===`start`?0:r.length-1:s<0?t>0?0:r.length-1:(s+t+r.length)%r.length,o=r[i];o&&a(e(o))},setActiveKey:a}}var DA={draft:`Draft`,balanced:`Balanced`,premium:`Premium`,max:`Max`};function OA(e){if(e.kind!==`video`||e.video===null)return DA[e.tier];let t=Math.min(...e.video.prices.map(e=>e.silentMilliunitsPerSecond)),n=Number.isFinite(t)?pi(t):null;return n===null?`Video`:`Video · from ${n}/s`}var kA=[{kind:`image`,label:`Images`},{kind:`video`,label:`Video`}];function AA(e){let t=()=>{e.scrollHeight-e.scrollTop-e.clientHeight>1?e.setAttribute(`data-more`,``):e.removeAttribute(`data-more`)};t();let n=requestAnimationFrame(t);return e.addEventListener(`scroll`,t,{passive:!0}),()=>{cancelAnimationFrame(n),e.removeEventListener(`scroll`,t)}}function jA({compact:e=!1,disabled:t,emptyLabel:n,models:r,onChange:i,value:a}){let o=r.find(e=>e.id===a),[s,c]=(0,q.useState)(null);(0,q.useEffect)(()=>{if(s!==null)return AA(s)},[s]);let[l,u]=(0,q.useState)(null);return(0,J.jsx)(`span`,{className:`contents`,ref:u,children:(0,J.jsxs)(Co,{children:[(0,J.jsx)(Ia,{"aria-label":`Generation model`,"data-generation-model":a,disabled:t||r.length===0,render:(t,r)=>{let i=o===void 0?n:Rn(o);return e?(0,J.jsx)(_t,{...t,className:`parakeet-composer-model-key`,expanded:r.open,icon:(0,J.jsx)(Mi,{}),label:null,readout:(0,J.jsx)(ai,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)] shrink-0`}),title:i}):(0,J.jsx)(xA,{...t,expanded:r.open,label:i})}}),(0,J.jsx)(qa,{ref:c,"data-generation-model-menu":!0,container:qg(l),side:`top`,align:`start`,"aria-label":`Generation models`,children:kA.map((e,t)=>{let n=r.filter(t=>t.kind===e.kind);return n.length===0?null:(0,J.jsxs)(mo,{children:[t>0?(0,J.jsx)(Ya,{}):null,(0,J.jsx)(Za,{children:e.label}),n.map(e=>(0,J.jsx)(Wa,{"data-generation-model-option":e.id,checked:e.id===a,closeOnClick:!0,onSelect:()=>{i(e.id)},children:(0,J.jsxs)(`span`,{className:`prints-model-row flex items-baseline gap-lg`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1`,children:Rn(e)}),(0,J.jsx)(`span`,{className:`prints-model-detail`,children:OA(e)})]})},e.id))]},e.kind)})})]})})}var MA={kind:`folder`,folder:void 0};function NA(e){let t=zf(e),n=(0,q.useRef)(e);n.current=e;let r=on(),i=Li(In(e)),a=Ks(Ag(e,i.data?.configured?{kind:`folder`,path:i.data.path}:null)),o=`${t??``}:${i.data?.path??``}`,[s,c]=(0,q.useState)({scope:o,view:MA}),l=s.scope===o?s.view:MA,d=e=>{c({scope:o,view:e})},[f,p]=(0,q.useState)(null),m=n=>n?.app===e&&n.computerId===t,h=se({mutationKey:oi.folder(e),mutationFn:async({owner:e,id:t,path:r,create:i})=>{let a=()=>{if(n.current!==e||e.context.get().computerId!==t)throw new G(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1})};return a(),i&&await e.capabilities.require(Ra).mkdir({path:r}),a(),await fo(e.capabilities,{path:r,limit:1,offset:0}),a(),dr(e.capabilities,{operation:`select-folder`,computerId:t,path:r})},onSuccess:(e,t)=>{t.owner===n.current&&t.owner.context.get().computerId===t.id&&p(null)},onSettled:(e,t,n)=>Promise.all([r.invalidateQueries({queryKey:n.queryKey,exact:!0}),r.invalidateQueries({queryKey:Og.listing(n.owner,n.path),exact:!0})])}),g=h.variables?.owner===e&&h.variables.id===t,_=i.isFetching||g&&h.isPending,v=async(n,r)=>{if(!e||!t||_)return`Computer selection changed. Try again.`;let i=n.trim();if(!u($n)(i))return`Enter an absolute Computer folder, such as /media.`;try{return await h.mutateAsync({owner:e,id:t,path:i,create:r,queryKey:oi.folder(e)}),null}catch{return`Could not use this folder. Check its location and your Computer permissions.`}},y=i.isError||a.isError,b=y||!i.data?.configured?null:i.data.path,x=b===null?null:l.kind===`folder`?dg(b,l.folder):b,S=b===null?null:l.kind===`folder`?{kind:`folder`,path:x??b}:{kind:l.kind,path:b};return{view:l,setView:d,destination:b,landingPath:x??(y?null:i.data?.path??null),source:S,path:y?null:i.data?.path??null,computerId:t,available:e?.capabilities.has(Zr)===!0,writable:e?.capabilities.has(Ra)===!0,busy:_,error:y?`Your media folder is unavailable. Choose or create a folder.`:null,editing:m(f),setEditing:n=>{p(n?{app:e,computerId:t}:null)},choose:v,ensureCreated:async()=>i.data?i.data.configured?null:v(i.data.path,!0):`Your Prints library is still loading.`,recheck:()=>{r.invalidateQueries({queryKey:Og.listing(e,i.data?.path??null),exact:!0}),r.invalidateQueries({queryKey:oi.folder(e),exact:!0})}}}var PA=w(b),FA=w(g({message:b}));function IA(e){for(let t of e.errors){let e=dn(Ce(et(FA(t),e=>e.message),()=>PA(t)));if(e!==void 0&&e.length>0)return e}}var LA={neutral:`progress-neutral`,primary:`progress-primary`,secondary:`progress-secondary`,accent:`progress-accent`,success:`progress-success`,info:`progress-info`,warning:`progress-warning`,error:`progress-error`},RA=(0,q.forwardRef)(function({className:e,tone:t=`primary`,...n},r){return(0,J.jsx)(`progress`,{...n,"data-complete":n.value!==void 0&&Number(n.value)>=Number(n.max??1)?`true`:void 0,className:V(`progress caps-gooey-motion caps-gooey-progress w-full`,LA[t],e),ref:r})});(0,q.forwardRef)(function({label:e,value:t,max:n,tone:r=`info`,className:i,...a},o){return(0,J.jsxs)(`div`,{...a,ref:o,className:V(`caps-game-meter`,i),children:[(0,J.jsxs)(`div`,{className:`caps-game-meter-readout`,children:[(0,J.jsx)(`span`,{children:e}),(0,J.jsxs)(`span`,{className:`caps-game-meter-value`,children:[t,` / `,n]})]}),(0,J.jsx)(RA,{"aria-label":e,value:t,max:n,tone:r})]})});function zA({className:e,items:t,onCancel:n,onRemove:r,onRetry:i,rowClassName:a}){return t.length?(0,J.jsx)(`div`,{"aria-live":`polite`,className:`caps-upload-queue flex w-full min-w-0 flex-col gap-sm ${e??``}`,"data-upload-rows":!0,children:t.map(e=>(0,J.jsx)(HA,{item:e,onCancel:n,onRemove:r,onRetry:i,...a===void 0?{}:{rowClassName:a}},e.id))}):null}function BA({action:e,id:t,onAction:n,retry:r=!1}){return e?(0,J.jsx)(pt,{"aria-label":e.accessibleLabel,title:e.label,variant:`ghost`,size:`xs`,className:`motion-reduce:transition-none`,icon:r?(0,J.jsx)(Ar,{}):(0,J.jsx)(Ei,{}),onClick:()=>void n(t),type:`button`}):null}function VA({item:e}){return(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block min-w-0 truncate`,title:e.name,children:e.name}),(0,J.jsx)(`div`,{className:`caps-upload-details`,children:(0,J.jsxs)(`span`,{"aria-live":e.alert?`assertive`:void 0,className:`caps-upload-status min-w-0 break-words`,"data-upload-status":!0,role:e.alert?`alert`:void 0,children:[e.alert??e.statusLabel,` `,e.progressLabel]})})]})}function HA({item:e,onCancel:t,onRemove:n,onRetry:r,rowClassName:i}){return(0,J.jsxs)(`div`,{className:`caps-upload-row grid w-full min-w-0 max-w-full grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-sm p-sm text-xs ${i??``}`,children:[e.preview.kind===`image`?(0,J.jsx)(`img`,{alt:``,className:`caps-upload-preview mask mask-squircle size-8 shrink-0 object-cover`,src:e.preview.url}):(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`caps-upload-preview mask mask-squircle flex size-8 shrink-0 items-center justify-center bg-base-300`,children:(0,J.jsx)(Jr,{className:`size-4`})}),(0,J.jsx)(VA,{item:e}),(0,J.jsx)(UA,{actions:e.actions,id:e.id,onCancel:t,onRemove:n,onRetry:r}),(0,J.jsx)(RA,{"aria-label":`${e.name} progress`,className:`caps-upload-progress`,tone:e.alert?`error`:e.progress===100?`success`:`accent`,max:100,value:e.progress??(e.alert?0:void 0)})]})}function UA({actions:e,id:t,onCancel:n,onRemove:r,onRetry:i}){return(0,J.jsxs)(`div`,{className:`caps-upload-actions flex min-w-0 flex-wrap justify-end gap-xs`,children:[(0,J.jsx)(BA,{action:e.retry,id:t,onAction:i,retry:!0}),(0,J.jsx)(BA,{action:e.cancel,id:t,onAction:n}),(0,J.jsx)(BA,{action:e.remove,id:t,onAction:r})]})}var WA=q.createContext(void 0);function GA(e){let t=q.useContext(WA);if(t===void 0&&!e)throw Error(Oa(47));return t}var KA={...No,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!No.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&No.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>No.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},qA=class extends $i{constructor(e,t,n){let r=new ja;super(JA(e,r,t,n),YA(r),KA)}setOpen=(e,t)=>{let n=t.reason===Ea,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=go(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=Pa(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),eg.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function JA(e,t,n,r=!1){let i={...Ca(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function YA(e){return{popupRef:q.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:q.createRef(),beforeTriggerFocusGuardRef:q.createRef(),beforeContentFocusGuardRef:q.createRef(),stickIfOpenTimeout:new Eo,stickIfOpen:!0,triggerElements:e}}var XA=ka(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=QA(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),Ka(u,d),Na(u);let{forceUnmount:m}=Fa(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),q.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),q.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,ra(Oo))}),[m,u]);let h=d||f||s!=null;return(0,J.jsxs)(WA.Provider,{value:u,children:[s&&(0,J.jsx)(fa,{handle:s,store:u}),h&&(0,J.jsx)($A,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function ZA(e){return GA(!0)?(0,J.jsx)(XA,{props:e}):(0,J.jsx)(Ua,{children:(0,J.jsx)(XA,{props:e})})}function QA(e,t){let n=Xi((e,n)=>new qA(t,e,n));return q.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function $A({store:e,modal:t}){let n=e.useState(`floatingRootContext`),r=eo(n,{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),i=r.reference,a=r.floating;return Sa(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}var ej=ca(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=GA(!0),h=pa(s)??m;if(!h)throw Error(Oa(74));let g=Va(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=q.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=So(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`isPressOpenedByTrigger`,g),T=h.useState(`isTouchPressOpen`,l),E=h.useState(`hasTriggerFocusGuards`,g),D=aa(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:ba(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=Qi(()=>h.context.stickIfOpen),k=za(v,{stickIfOpen:O}),A=ro(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),j=h.useState(`triggerProps`,C),{getButtonProps:M,buttonRef:N}=ya({disabled:a,native:o}),P={open(e){return w?xa.open(e):oa.open(e)}},{handlePreFocusGuardFocus:F,handleFocusTargetFocus:I}=jo(h,x),ee=Aa(`button`,e,{state:{disabled:a,open:y},ref:[N,t,S,x],props:[k.reference,D,j,A,{[Ga]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,M],stateAttributesMapping:P}),te=(0,J.jsx)(q.Fragment,{children:ee},g);return E?(0,J.jsxs)(q.Fragment,{children:[(0,J.jsx)(ho,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:F}),te,(0,J.jsx)(ho,{ref:h.context.triggerFocusTargetRef,onFocus:I})]}):te}),tj=q.createContext(void 0);function nj(){let e=q.useContext(tj);if(e===void 0)throw Error(Oa(45));return e}var rj=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return GA().useState(`mounted`)||n?(0,J.jsx)(tj.Provider,{value:n,children:(0,J.jsx)(wo,{ref:t,...r})}):null}),ij=q.createContext(void 0);function aj(){let e=q.useContext(ij);if(!e)throw Error(Oa(46));return e}var oj=q.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=Ja,..._}=e,v=GA(),y=nj(),b=oo(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=v.useState(`adaptiveOrigin`),M=ta({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:j}),N=x.useState(`domReferenceElement`);wa({store:v,domReference:N,positionerElement:O,open:C});let P=E===!0&&w!==`trigger-hover`;Ba(C&&P,D===`touch`,O,T);let F=v.useStateSetter(`positionerElement`),I={open:C,side:M.side,align:M.align,anchorHidden:M.anchorHidden,instant:k},ee=ko(e,I,{styles:M.positionerStyles,transitionStatus:A,props:_,refs:[t,F],hidden:!S,inert:!C});return(0,J.jsxs)(ij.Provider,{value:M,children:[S&&P&&(0,J.jsx)(to,{inert:ma(!C),cutout:T}),(0,J.jsx)(bo,{id:b,children:ee})]})}),sj=q.createContext(void 0);function cj(){let[e,t]=q.useState(0),n=Qi(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:q.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var lj=q.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=GA(),l=aj(),u=ia(!0)!=null,{context:d,hasClosePart:f}=cj(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);uo({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),ua(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?da(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M={open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},N=Aa(`div`,e,{state:M,ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...sa,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&ga.has(e.key)&&e.stopPropagation()}},Ta(g),s],stateAttributesMapping:_a});return(0,J.jsx)(po,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:no(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,J.jsx)(sj.Provider,{value:d,children:N})})}),uj=(0,q.forwardRef)(function({children:e,className:t,type:n=`button`,...r},i){return(0,J.jsxs)(`button`,{...r,ref:i,type:n,className:V(`select caps-select caps-combobox-trigger w-full`,t),children:[(0,J.jsx)(`span`,{children:e}),(0,J.jsx)(ai,{className:`caps-select-chevron`,"aria-hidden":`true`})]})});function dj({defaultOpen:e,defaultValue:t,getKey:n,getSearchText:r,groupBy:i,id:a,isDisabled:o,items:s,onOpenChange:c,onCommit:l,multiple:u,controlledOpen:d,controlledKeys:f,trigger:p}){let m=`${a}-listbox`,[h,g]=(0,q.useState)(``),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(t),[x,S]=(0,q.useState)(e),C=f??(y===null?[]:[y]),w=p?d??x:!0,T=(0,q.useMemo)(()=>{let e=h.trim().toLowerCase();return e?s.filter(t=>r(t).toLowerCase().includes(e)):s},[r,s,h]),E=EA({getKey:n,isDisabled:o,items:T});(0,q.useEffect)(()=>{if(E.activeKey!==null)return;let e=E.enabledItems.find(e=>C.includes(n(e)))??E.enabledItems[0];e&&E.setActiveKey(n(e))},[E.activeKey,E.enabledItems,E.setActiveKey,n,C]);let D=e=>{v(!1),e||g(``),d===void 0&&S(e),c?.(e)},O=e=>`${m}-option-${encodeURIComponent(e)}`,k=e=>{let t=n(e);f===void 0&&b(t),l(e),p&&!u&&D(!1)},A=e=>{v(!0),g(e.target.value),E.setActiveKey(null)},j=e=>{if(zi(e))return;let t;switch(e.key){case`ArrowDown`:t=[1,void 0];break;case`ArrowUp`:t=[-1,void 0];break;case`End`:t=[1,`end`];break;case`Home`:t=[-1,`start`]}t?(v(!0),e.preventDefault(),E.move(t[0],t[1])):e.key===`Enter`&&E.activeItem&&(e.preventDefault(),k(E.activeItem))},M=(0,q.useMemo)(()=>{if(!i)return[{label:``,items:T}];let e=new Map;for(let t of T){let n=i(t),r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e].map(([e,t])=>({label:e,items:t}))},[T,i]);return{keyboardNavigation:_,onPointerMove:()=>{v(!1)},activeKey:E.activeKey,activeItem:E.activeItem,groups:M,inputValue:h,listboxId:m,onInputChange:A,onInputKeyDown:j,optionId:O,open:w,commit:k,selectedKeys:C,setOpen:D}}function fj(e){let{"aria-describedby":t,"aria-invalid":n,"aria-label":r,"aria-labelledby":i,"aria-required":a,activeTone:o=`neutral`,container:s,contentClassName:c,defaultOpen:l=!1,defaultValue:u=null,emptyMessage:d=`No matches`,getKey:f,getLabel:p,getSearchText:m=p,groupBy:h,id:g,inputProps:_,inputRef:v,isDisabled:y=()=>!1,items:b,onOpenChange:x,onValueChange:S,multiple:C,open:w,placeholder:T=`Search…`,renderItem:E,rootRef:D,trigger:O,triggerRef:k,value:A,...j}=e,M=e=>{let t=f(e);if(C){let e=A.includes(t)?A.filter(e=>e!==t):[...A,t];S?.(e,b.filter(t=>e.includes(f(t))))}else S?.(t,e)},N;C?N=A:A!==void 0&&(N=A===null?[]:[A]);let P=(0,q.useId)(),F=O?.props??_,I=g??F?.id??P,ee={id:I,"aria-describedby":[t,F?.[`aria-describedby`]].filter(Boolean).join(` `)||void 0,"aria-invalid":n??F?.[`aria-invalid`],"aria-label":F?.[`aria-label`]??r,"aria-labelledby":F?.[`aria-labelledby`]??i,"aria-required":a??F?.[`aria-required`]},{keyboardNavigation:te,onPointerMove:ne,activeItem:re,activeKey:L,commit:R,groups:ie,inputValue:ae,listboxId:oe,onInputChange:se,onInputKeyDown:ce,open:z,optionId:le,selectedKeys:B,setOpen:ue}=dj({defaultOpen:l,defaultValue:u,getKey:f,getSearchText:m,groupBy:h,id:I,isDisabled:y,items:b,onOpenChange:x,onCommit:M,multiple:C??!1,controlledOpen:w,controlledKeys:N,trigger:O});na(()=>{O&&ue(!1)});let de=va(`popover`),fe=s===void 0?de:s,pe=To(`.caps-combobox-option[data-active="true"]:not(:disabled), [data-navigation="pointer"] .caps-combobox-option:hover:not(:disabled)`),me=(0,J.jsx)(py,{..._,...O?{}:ee,"aria-activedescendant":re?le(f(re)):void 0,"aria-autocomplete":`list`,"aria-controls":oe,"aria-expanded":!0,className:V(`input-sm`,_?.className),id:O?_?.id??`${I}-input`:I,onChange:e=>{_?.onChange?.(e),se(e)},onKeyDown:e=>{_?.onKeyDown?.(e),e.defaultPrevented||ce(e)},placeholder:_?.placeholder??T,ref:v,role:`combobox`,value:ae}),he=(0,J.jsx)(`div`,{id:oe,ref:pe,className:`caps-combobox-list`,"data-navigation":te?`keyboard`:`pointer`,onPointerMove:ne,role:`listbox`,"aria-multiselectable":C??void 0,children:ie.every(e=>e.items.length===0)?(0,J.jsx)(`div`,{className:`px-md py-md text-sm text-base-content`,children:d}):ie.map(e=>(0,J.jsxs)(`div`,{"aria-label":e.label||void 0,role:e.label?`group`:void 0,children:[e.label?(0,J.jsx)(`div`,{className:`px-md pb-xs pt-sm text-xs text-base-content uppercase tracking-wider`,children:e.label}):null,e.items.map(e=>{let t=f(e),n=y(e),r=L===t,i={active:r,disabled:n,selected:B.includes(t)};return(0,J.jsxs)(`button`,{"aria-disabled":n||void 0,"aria-selected":i.selected,className:`caps-combobox-option`,"data-active":r&&te,disabled:n,id:le(t),onClick:()=>{R(e)},onMouseDown:e=>{e.preventDefault()},role:`option`,tabIndex:-1,type:`button`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`caps-combobox-check`,children:i.selected?(0,J.jsx)(Lr,{}):null}),E?.(e,r,i)??p(e)]},t)})]},e.label))});return O?(0,J.jsx)(`div`,{...j,className:V(j.className),ref:D,children:(0,J.jsxs)(ZA,{modal:!0,onOpenChange:ue,open:z,children:[(0,J.jsx)(ej,{...ee,"aria-haspopup":`dialog`,className:`btn`,ref:k,render:O}),fe===null?null:(0,J.jsx)(rj,{container:fe,children:(0,J.jsx)(oj,{align:`start`,side:`bottom`,sideOffset:4,children:(0,J.jsxs)(lj,{"data-active-tone":o,className:V(`min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none caps-combobox-panel caps-combobox-popup`,c),children:[(0,J.jsx)(`div`,{className:`caps-combobox-search`,children:me}),he]})})})]})}):(0,J.jsx)(`div`,{...j,className:V(j.className),ref:D,children:(0,J.jsxs)(`div`,{className:V(`caps-combobox-panel`,c),"data-active-tone":o,children:[(0,J.jsx)(`div`,{className:`caps-combobox-search`,children:me}),he]})})}function pj({icon:e,caption:t}){return(0,J.jsxs)(`span`,{className:`caps-icon-choice-mark`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{className:`caps-icon-choice-art`,children:e}),t?(0,J.jsx)(`span`,{className:`caps-icon-choice-caption`,children:t}):null,(0,J.jsx)(`span`,{className:`caps-icon-choice-lamp`})]})}var mj=(0,q.forwardRef)(function({label:e,icon:t,caption:n,appearance:r,className:i,...a},o){return(0,J.jsx)(`label`,{className:`caps-icon-choice`,"data-appearance":r===`compact`?r:void 0,children:(0,J.jsx)(TA,{...a,appearance:r??`default`,"aria-label":e,className:V(`caps-icon-choice-input`,i),indicator:(0,J.jsx)(pj,{icon:t,caption:n}),ref:o})})}),hj=(0,q.forwardRef)(function({label:e,icon:t,hint:n,className:r,...i},a){let o=(0,q.useId)(),s=[i[`aria-describedby`],n?o:null].filter(Boolean).join(` `)||void 0;return(0,J.jsx)(`label`,{className:`caps-check-key`,children:(0,J.jsx)(TA,{...i,"aria-label":e,"aria-describedby":s,className:V(`caps-check-key-input`,r),indicator:(0,J.jsxs)(`span`,{className:`caps-check-key-face`,"aria-hidden":`true`,children:[t?(0,J.jsx)(`span`,{className:`caps-check-key-icon`,children:t}):null,(0,J.jsxs)(`span`,{className:`caps-check-key-copy`,children:[(0,J.jsx)(`span`,{className:`caps-check-key-label`,children:e}),n?(0,J.jsx)(`span`,{className:`caps-check-key-hint`,id:o,children:n}):null]}),(0,J.jsx)(`span`,{className:`caps-check-key-lamp`})]}),ref:a})})});function gj({className:e,...t}){return(0,J.jsx)(`div`,{...t,className:V(`caps-check-keys`,e)})}function _j({checked:e}){let t=`caps-radio-${(0,q.useId)().replaceAll(`:`,``)}`,n=(0,q.useRef)(null),r=(0,q.useRef)(e).current,i=(0,q.useRef)(e),a=(0,q.useRef)(null),o=ie(a),{reduced:s}=o;return(0,q.useLayoutEffect)(()=>{if(!n.current)return;let t=s||i.current===e;i.current=e;let r=e?4:0,a=Ur(o,{ease:`outCubic`,duration:75}),c=e?fi(o,{bounce:.65,duration:300}):Ur(o,{ease:`inCubic`,duration:100}),l=Po(n.current,t?{rx:r,ry:r,cy:6,duration:0}:{rx:[{to:e?3.5:4.15,...a},{to:r,...c}],ry:[{to:e?4.5:3.85,...a},{to:r,...c}],cy:[{to:e?5.85:6.1,...a},{to:6,...c}]});return()=>{l.cancel()}},[e,s,o]),(0,J.jsxs)(`svg`,{ref:a,className:`caps-radio-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,J.jsxs)(`defs`,{children:[(0,J.jsx)(f,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,J.jsx)(xe,{id:`${t}-shadow`}),(0,J.jsx)(gn,{id:`${t}-inset`}),(0,J.jsx)(`clipPath`,{id:`${t}-well`,children:(0,J.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})})]}),(0,J.jsx)(`circle`,{className:`caps-radio-track`,cx:`6`,cy:`6`,r:`5.5`,filter:`url(#${t}-inset)`}),(0,J.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,J.jsx)(`ellipse`,{ref:n,cx:`6`,cy:`6`,rx:r?4:0,ry:r?4:0,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var vj=(0,q.createContext)(null),yj=(0,q.forwardRef)(function({children:e,className:t,defaultValue:n,disabled:r=!1,name:i,onValueChange:a,orientation:o=`vertical`,value:s,...c},l){let u=(0,q.useId)(),d=(0,q.useRef)(null);(0,q.useImperativeHandle)(l,()=>{if(!d.current)throw Error(`RadioGroup is not mounted`);return d.current},[]);let f=i??`radio-group-${u}`,[p,m]=(0,q.useState)(n),h=s??p;return(0,q.useEffect)(()=>{let e=d.current?.form;if(!e||s!==void 0)return;let t=e=>{queueMicrotask(()=>{e.defaultPrevented||m(n)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[s,n,c.form]),(0,J.jsx)(vj.Provider,{value:{disabled:r,name:f,onValueChange:e=>{s===void 0&&m(e),a?.(e)},value:h},children:(0,J.jsx)(`fieldset`,{...c,className:V(`flex gap-md`,o===`horizontal`?`flex-row flex-wrap`:`flex-col`,t),disabled:r,role:c.role??`radiogroup`,ref:d,children:e})})}),bj=(0,q.forwardRef)(function({className:e,indicator:t,onChange:n,onClick:r,value:i,...a},o){let s=(0,q.useContext)(vj);if(!s)throw Error(`RadioGroupItem must be used inside <RadioGroup>`);let c=s.value===i,l=e=>{n?.(e),e.target.checked&&s.onValueChange?.(i)};return(0,J.jsxs)(`span`,{className:`caps-radio`,"data-checked":c,"data-custom-indicator":t!==void 0||void 0,children:[(0,J.jsx)(`input`,{...a,"aria-checked":c,checked:c,className:V(`caps-radio-input`,e),disabled:s.disabled||a.disabled,name:s.name,onChange:l,onClick:r,ref:o,type:`radio`,value:i}),t===void 0?(0,J.jsx)(_j,{checked:c}):t]})}),xj=(0,q.forwardRef)(function({description:e,id:t,meta:n,title:r,...i},a){let o=(0,q.useContext)(vj),s=(0,q.useId)(),c=t??s,l=o?.value===i.value,u=o?.disabled===!0||i.disabled===!0;return(0,J.jsxs)(`label`,{className:`caps-choice-card`,"data-checked":l,"data-disabled":u||void 0,htmlFor:c,children:[(0,J.jsx)(bj,{...i,"aria-describedby":e?`${c}-description`:void 0,"aria-labelledby":`${c}-title`,id:c,ref:a}),(0,J.jsxs)(`span`,{className:`caps-choice-card-copy`,children:[(0,J.jsx)(`span`,{className:`caps-choice-card-title`,id:`${c}-title`,children:r}),e?(0,J.jsx)(`span`,{className:`caps-choice-card-description`,id:`${c}-description`,children:e}):null]}),n?(0,J.jsx)(`span`,{className:`caps-choice-card-meta`,children:n}):null]})}),Sj=(0,q.forwardRef)(function({label:e,icon:t,caption:n,art:r=`dim`,className:i,...a},o){return(0,J.jsx)(`label`,{className:`caps-icon-choice`,"data-art":r===`color`?r:void 0,children:(0,J.jsx)(bj,{...a,"aria-label":e,className:V(`caps-icon-choice-input`,i),indicator:(0,J.jsx)(pj,{icon:t,caption:n}),ref:o})})});(0,q.forwardRef)(function({label:e,color:t,className:n,...r},i){return(0,J.jsx)(`label`,{className:`caps-icon-choice`,"data-art":`color`,"data-swatch":``,title:e,children:(0,J.jsx)(bj,{...r,"aria-label":e,className:V(`caps-icon-choice-input`,n),indicator:(0,J.jsx)(pj,{icon:(0,J.jsx)(`span`,{className:`caps-swatch-dot`,style:{backgroundColor:t}})}),ref:i})})});var Cj=w(b),wj=w(mt),Tj=w(p(Ge)),Ej=w(vt(b)),Dj=vt(wn(File)),Oj=w(Dj),kj=Et([b,Ge,mt,Se,kt,vt(b),Dj]),Aj=w(kj),jj=e=>ht(Cj(e.state.value),()=>``),Mj=e=>ht(wj(e.state.value),()=>!1),Nj=e=>ht(Tj(e.state.value),()=>null),Pj=e=>ht(Ej(e.state.value),()=>[]),Fj=e=>ht(Oj(e.state.value),()=>[]),Ij=e=>ht(Aj(e.state.value),()=>null);function Lj({field:e,spec:t,locked:n,...r}){let[i,a]=(0,q.useState)(!1);return(0,J.jsxs)(hy,{children:[(0,J.jsx)(py,{...r,name:t.name,disabled:n,type:i?`text`:`password`,autoComplete:`off`,spellCheck:!1,className:`caps-field-secret`,placeholder:t.placeholder,readOnly:t.readOnly,value:jj(e),onBlur:e.handleBlur,onChange:t=>{e.handleChange(t.currentTarget.value)}}),(0,J.jsx)(U,{type:`button`,variant:`outline`,size:`icon`,"aria-label":i?`Hide`:`Show`,"aria-pressed":i,disabled:n,onClick:()=>{a(e=>!e)},children:i?(0,J.jsx)(xh,{"aria-hidden":`true`}):(0,J.jsx)(Sh,{"aria-hidden":`true`})})]})}var Rj={text:`text`,email:`email`,url:`url`,tel:`tel`};function zj({spec:e,field:t,locked:n,...r}){let i=Fj(t),a=n||e.readOnly===!0,o=(0,q.useRef)(null);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,J.jsx)(Te,{asChild:!0,children:(0,J.jsx)(`input`,{...r,ref:o,type:`file`,tabIndex:-1,required:r.required===!0&&i.length===0,name:e.name,accept:e.accept,multiple:e.multiple,disabled:a,onBlur:t.handleBlur,onChange:e=>{t.handleChange(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),(0,J.jsx)(U,{type:`button`,variant:`outline`,"aria-label":`Choose files for ${e.label}`,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],disabled:a,onBlur:t.handleBlur,onClick:()=>{o.current?.click()},children:`Choose files`}),(0,J.jsx)(zA,{items:i.map((e,t)=>({id:String(t),name:e.name,preview:{kind:`file`},progress:0,progressLabel:`${String(e.size)} bytes`,statusLabel:`Selected`,actions:a?{}:{remove:{label:`Remove`,accessibleLabel:`Remove ${e.name}`}}})),onRemove:e=>{t.handleChange(i.filter((t,n)=>String(n)!==e))},onCancel:()=>void 0,onRetry:()=>void 0})]})}function Bj({spec:e,field:t,locked:n,...r}){let i=e=>{t.handleChange(e)},a={...r,name:e.name,disabled:n,onBlur:t.handleBlur};switch(e.kind){case`text`:case`email`:case`url`:case`tel`:return(0,J.jsx)(py,{...a,type:Rj[e.kind],inputMode:e.kind===`text`?void 0:e.kind,autoComplete:e.autoComplete,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:jj(t),onChange:e=>{i(e.currentTarget.value)}});case`textarea`:return(0,J.jsx)(Gi,{...a,rows:e.rows??3,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:jj(t),onChange:e=>{i(e.currentTarget.value)}});case`secret`:return(0,J.jsx)(Lj,{...r,field:t,spec:e,locked:n});case`money`:return(0,J.jsxs)(hy,{children:[(0,J.jsx)(gy,{className:`caps-field-currency`,children:e.currency??`USD`}),(0,J.jsx)(py,{...a,inputMode:`decimal`,autoComplete:`off`,className:`caps-field-amount`,placeholder:e.placeholder??`0.00`,readOnly:e.readOnly,value:jj(t),onChange:e=>{i(e.currentTarget.value)}})]});case`date`:return(0,J.jsx)(py,{...a,type:`date`,readOnly:e.readOnly,value:jj(t),onChange:e=>{i(e.currentTarget.value)}});case`number`:return(0,J.jsx)(jy,{...a,...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max},...e.step===void 0?{}:{step:e.step},...e.unit===void 0?{}:{unit:e.unit},...e.wrap===void 0?{}:{wrap:e.wrap},disabled:n||e.readOnly===!0,decrementLabel:`Decrease ${e.label}`,incrementLabel:`Increase ${e.label}`,value:Nj(t),onValueChange:e=>{t.handleChange(e)}});case`select`:return(0,J.jsxs)(My,{...a,value:jj(t),onChange:e=>{i(e.currentTarget.value)},children:[e.placeholder===void 0?null:(0,J.jsx)(`option`,{value:``,disabled:!0,children:e.placeholder}),e.options.map(e=>(0,J.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]});case`combobox`:return(0,J.jsx)(fj,{id:r.id??e.name,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],"aria-required":r[`aria-required`],items:e.options,getKey:e=>e.value,getLabel:e=>e.label,isDisabled:t=>t.disabled||n||e.readOnly===!0,value:jj(t),...e.placeholder===void 0?{}:{placeholder:e.placeholder},trigger:(0,J.jsx)(uj,{name:e.name,disabled:n||e.readOnly===!0,onBlur:t.handleBlur,children:e.options.find(e=>e.value===jj(t))?.label??e.placeholder??`Choose…`}),inputProps:{"aria-label":`Search ${e.label}`,disabled:n||e.readOnly===!0},onValueChange:e=>{i(e??``),t.handleBlur()}});case`file`:return(0,J.jsx)(zj,{...r,spec:e,field:t,locked:n});case`checkbox`:return(0,J.jsx)(TA,{...a,disabled:n||e.readOnly===!0,checked:Mj(t),onChange:e=>{t.handleChange(e.currentTarget.checked)}});case`switch`:return(0,J.jsx)(zn,{...a,disabled:n||e.readOnly===!0,checked:Mj(t),onCheckedChange:e=>{t.handleChange(e)}});case`radio`:case`icon-radio`:case`checkboxes`:case`icon-checkboxes`:return null}}var Vj=new Set([`radio`,`icon-radio`,`checkboxes`,`icon-checkboxes`]);function Hj({spec:e,field:t,locked:n,error:r,layout:i}){let a=n||e.readOnly===!0,o=e.label;if(e.kind===`checkboxes`||e.kind===`icon-checkboxes`){let n=Pj(t),s=(e,r)=>{t.handleChange(r?[...n,e]:n.filter(t=>t!==e))};return(0,J.jsx)(wy,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:e.kind===`icon-checkboxes`?(0,J.jsx)(`div`,{className:`caps-field-icon-choices`,children:e.options.map(r=>(0,J.jsx)(mj,{name:e.name,value:r.value,label:r.label,...r.caption===void 0?{}:{caption:r.caption},icon:r.icon,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))}):(0,J.jsx)(gj,{children:e.options.map(r=>(0,J.jsx)(hj,{name:e.name,value:r.value,label:r.label,icon:r.icon,hint:r.description,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))})})}let s=e.options.some(e=>e.description!==void 0||e.meta!==void 0);return(0,J.jsx)(wy,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:(0,J.jsx)(yj,{name:e.name,"aria-label":o,value:jj(t),onValueChange:e=>{t.handleChange(e),t.handleBlur()},orientation:e.kind===`icon-radio`||s?`horizontal`:`vertical`,children:e.options.map(t=>e.kind===`icon-radio`?(0,J.jsx)(Sj,{value:t.value,label:t.label,...t.caption===void 0?{}:{caption:t.caption},icon:t.icon,disabled:t.disabled},t.value):s?(0,J.jsx)(xj,{value:t.value,title:t.label,description:t.description,meta:t.meta,disabled:t.disabled},t.value):(0,J.jsx)(Ey,{label:t.label,orientation:`inline`,children:(0,J.jsx)(bj,{value:t.value,disabled:t.disabled})},t.value))})})}function Uj({spec:e,field:t,locked:n,error:r,render:i,...a}){return i({name:e.name,label:e.label,help:e.help,value:Ij(t),onChange:e=>{t.handleChange(e)},onBlur:t.handleBlur,error:r,disabled:n,id:a.id??e.name,"aria-describedby":a[`aria-describedby`],"aria-invalid":r!==void 0})}function Wj({form:e,spec:t,locked:n,layout:r}){let i=iy({form:e,name:t.name}),a=ny(e.store,e=>e.submissionAttempts>0),o=i.state.meta.isBlurred||a?IA(i.state.meta):void 0;if(t.render===void 0&&Vj.has(t.kind))return(0,J.jsx)(Hj,{spec:t,field:i,locked:n,error:o,layout:r});let s=r===`columns`?t.kind===`switch`||t.kind===`checkbox`?`horizontal`:`vertical`:t.kind===`checkbox`?`inline`:(t.layout??(t.kind===`switch`?`row`:`stacked`))===`row`?`horizontal`:`vertical`;return(0,J.jsx)(Ey,{label:t.label,...r===`columns`?{labelTitle:t.label}:{},description:t.help,icon:t.icon,orientation:s,error:o,...t.required===void 0?{}:{required:t.required},...t.optional===void 0?{}:{optional:t.optional},children:t.render===void 0?(0,J.jsx)(Bj,{spec:t,field:i,locked:n}):(0,J.jsx)(Uj,{spec:t,field:i,locked:n,error:o,render:t.render})})}var Gj=w(Ee(b,kj));function Kj({form:e,spec:t,locked:n,layout:r}){let i=t.when;return ny(e.store,e=>i===void 0||i(ht(Gj(e.values),()=>({}))))?(0,J.jsx)(Wj,{form:e,spec:t,locked:n,layout:r}):null}function qj({form:e,section:t,locked:n,layout:r}){let i=t.fields.map(t=>(0,J.jsx)(Kj,{form:e,spec:t,locked:n,layout:r},t.name));return t.title===void 0?i:(0,J.jsx)(Cy,{title:t.title,description:t.description,layout:r,children:i})}function Jj({model:e,names:t,disabled:n=!1,layout:r}){let i=e.form;return t===void 0?e.description.sections.map(e=>(0,J.jsx)(qj,{form:i,section:e,locked:n,layout:r},e.id??``)):t.map(t=>{let a=e.description.fields.find(e=>e.name===t);return a===void 0?null:(0,J.jsx)(Kj,{form:i,spec:a,locked:n,layout:r},t)})}var Yj=class{annotation;constructor(e){this.annotation=e}},Xj=class{sections;constructor(e){this.sections=e}},Zj=`caps/form`,Qj=0;function $j(e){Qj+=1;let t={[`${Zj}:${String(Qj)}`]:new Yj(e)};return e.label!==void 0&&(t.title=e.label),e.help!==void 0&&(t.description=e.help),t}b.annotate($j({kind:`secret`})).pipe(ae(`Secret`));var eM=e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)};function tM(e){return Object.values(e??{}).reduce((e,t)=>t instanceof Yj?{...e,...t.annotation}:e,{})}function nM(e){return e.reduce((e,t)=>({...e,...tM(t)}),{})}function rM(e){let t=e?.[Zj];return t instanceof Xj?t.sections:{}}var iM=w(b);function aM(e){if(nn(e))return vn(iM(e.literal),{onNone:()=>null,onSome:e=>[e]});if(!$t(e))return null;let t=[];for(let n of e.types){if(Ht(n))continue;let e=aM(n);if(e===null)return null;t.push(...e)}return t}function oM(e){if(Xe(e))return{type:`string`,literals:[]};if(Zt(e))return{type:`number`,nullable:!1};if(lt(e))return{type:`boolean`};let t=aM(e);if(t!==null)return{type:`string`,literals:t};if(r(e)){let[t]=e.rest;if(t===void 0)return null;if(Xe(t))return{type:`strings`,literals:[]};let n=aM(t);return n===null?null:{type:`strings`,literals:n}}if($t(e)){let t=e.types.filter(e=>!Ht(e)&&!Bt(e)),n=e.types.some(e=>Bt(e)),[r]=t;if(t.length!==1||r===void 0)return null;let i=oM(r);return i?.type===`number`?{type:`number`,nullable:n}:n?null:i}return null}function sM(e){let t=e.ast;if(!Ct(t))throw Error(`A schema form needs a Schema.Struct.`);return{fields:t.propertySignatures.map(e=>{let t=String(e.name),n=st(e.type),r=nM([e.type.annotations,...(e.type.checks??[]).map(e=>e.annotations)]),i=r.kind===`file`?{type:`files`}:oM(n);if(i===null)throw Error(`Schema field "${t}" has no form control. Annotate it with field({ render }) or a kind.`);return{name:t,valueType:i,optional:e.type.context?.isOptional===!0,annotation:r,title:sn(e.type),description:Nt(e.type)}}),sections:rM(rt(t))}}function cM(e){let t=e,n=!1,r=!1;for(;;)if(t instanceof R)n=!0,t=t.unwrap();else if(t instanceof me)r=!0,t=t.unwrap();else if(t instanceof Dt)t=t.unwrap();else if(t instanceof be)t=t.in;else return{node:t,optional:n,nullable:r}}function lM(e){if(e instanceof Me){let t=e.options.map(e=>lM(e));return t.some(e=>e===null)?null:t.flatMap(e=>e??[])}let t=e instanceof oe?e.options:e instanceof le?[...e.values]:null;if(t===null)return null;let n=t.map(e=>iM(e));return n.every(xn)?n.map(e=>e.value):null}function uM(e){let{node:t,nullable:n}=cM(e);if(t instanceof Tn)return{type:`string`,literals:[]};if(t instanceof T)return{type:`number`,nullable:n};if(t instanceof s)return{type:`boolean`};let r=lM(t);if(r!==null)return{type:`string`,literals:r};if(t instanceof At){let e=cM(t.element).node;if(e instanceof Tn)return{type:`strings`,literals:[]};let n=lM(e);return n===null?null:{type:`strings`,literals:n}}return null}function dM(e){let t=[e];for(;;){let e=t[t.length-1];if(e===void 0)break;let n=e instanceof R||e instanceof me||e instanceof Dt?e.unwrap():e instanceof be?e.in:e;if(n===e)break;t.push(n)}return t.reverse().map(e=>Ye.get(e))}function fM(e){return dM(e).reduce((e,t)=>({...e,...t}),{})}function pM(e){return Object.entries(e.shape)}function mM(e){let t=cM(e).node;if(!(t instanceof N))throw Error(`A schema form needs a z.object.`);return{fields:pM(t).map(([e,t])=>{let n=nM(dM(t)),r=n.kind===`file`?{type:`files`}:uM(t);if(r===null)throw Error(`Schema field "${e}" has no form control. Annotate it with field({ render }) or a kind.`);let i=fM(t);return{name:e,valueType:r,optional:cM(t).optional,annotation:n,title:i.title,description:i.description}}),sections:rM(fM(e))}}function hM(e,t){let n=t.options??{};return(e.length>0?e:Object.keys(n)).map(e=>{let t=n[e],r=t===void 0?{}:t instanceof Object?t:{label:t};return{value:e,label:r.label??eM(e),description:r.description,meta:r.meta,icon:r.icon,caption:r.caption,disabled:r.disabled===!0}})}function gM(e,t){let n=t.some(e=>e.icon!==void 0);switch(e.type){case`boolean`:return`switch`;case`number`:return`number`;case`strings`:return n?`icon-checkboxes`:`checkboxes`;case`files`:return`file`;case`string`:return t.length===0?`text`:t.length>12?`combobox`:n?`icon-radio`:t.some(e=>e.description!==void 0||e.meta!==void 0)||t.length<=3?`radio`:`select`}}function _M(e,t){switch(e.type){case`boolean`:return!1;case`number`:return e.nullable?null:0;case`strings`:case`files`:return[];case`string`:return t[0]?.value??``}}function vM(e){let t=e instanceof d?mM(e):sM(e),n=t.fields.map((e,t)=>{let{kind:n,...r}=e.annotation,i=hM(e.valueType.type===`string`||e.valueType.type===`strings`?e.valueType.literals:[],e.annotation),a=r.help??e.description;return{...r,name:e.name,label:r.label??e.title??eM(e.name),help:a,kind:n??gM(e.valueType,i),options:i,optionalInSchema:e.optional,index:t}}),r={};t.fields.forEach((e,t)=>{let i=n[t];i&&(r[e.name]=_M(e.valueType,i.options))});let i=e=>e.order??e.index,a=e=>e.section!==void 0&&Object.hasOwn(t.sections,e.section)?e.section:null,o=e=>n.filter(t=>a(t)===e).sort((e,t)=>i(e)-i(t)),s=Object.entries(t.sections).map(([e,t])=>({id:e,title:t.title,description:t.description,fields:o(e)}));return{fields:n,sections:[{id:null,title:void 0,description:void 0,fields:o(null)},...s].filter(e=>e.fields.length>0),defaults:r}}function yM(e){let t=e instanceof d?e:ge(e);return{"~standard":{...t[`~standard`],validate:e=>{let n=t[`~standard`].validate(e);return n instanceof Promise?n.then(e=>bM(e)):bM(n)}}}}function bM(e){return e.issues===void 0?e:{issues:e.issues.map(e=>e.path===void 0?e:{...e,path:e.path.slice(0,1)})}}var xM=`onServer`;function SM(e){let t=e.querySelector(`[aria-invalid="true"]`),n=t?.matches(`input, select, textarea, button, [tabindex]`)?t:t?.querySelector(`input, select, textarea, button`);return n?.focus(),n!=null}function CM(e){if(SM(e))return()=>void 0;let t=new MutationObserver(()=>{SM(e)&&t.disconnect()});return t.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`aria-invalid`]}),()=>{t.disconnect()}}function wM(e){return e.state.meta.errorMap.onServer!==void 0}function TM(e){e.setMeta(e=>({...e,errorMap:{...e.errorMap,[xM]:void 0}}))}function EM(e,t,n){e.setFieldMeta(t,e=>({...e,isBlurred:!0,errorMap:{...e.errorMap,[xM]:n}}))}function DM(e){let[t,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(e.defaultValues),[s,c]=(0,q.useState)(null);xv(a,e.defaultValues)||(o(e.defaultValues),c(null));let{schema:l}=e,u=(0,q.useMemo)(()=>vM(l),[l]),d=(0,q.useMemo)(()=>yM(l),[l]),f=fy({defaultValues:s??a,validators:{onChange:d,onSubmit:d},listeners:{onChange:({fieldApi:e})=>{n(null),i(null),wM(e)&&TM(e)}},onSubmit:async({value:t,formApi:r})=>{n(null),i(null);let a=await yM(l)[`~standard`].validate(t);if(a.issues){n(a.issues[0]?.message??`Check the form and try again.`);return}let o;try{o=await e.onSubmit(a.value,t)??{kind:`saved`}}catch(t){console.error(`SchemaForm submit failed`,t),n(e.failure??`Couldn't save changes. Try again.`);return}if(o.kind===`refused`){n(o.error??null);let e=r;for(let[t,n]of Object.entries(o.fields??{}))n!==void 0&&n.length>0&&EM(e,t,n);return}let s=o.values??t;c(s),r.reset(s),i(o.message??`Saved`),e.onSaved?.(s)}});return{description:u,form:f,error:t,saved:r,discard:()=>{n(null),i(null),f.reset()},submit:()=>f.handleSubmit()}}function OM(e){return{dirty:ny(e.form.store,e=>!e.isDefaultValue),submitting:ny(e.form.store,e=>e.isSubmitting),canSubmit:ny(e.form.store,e=>e.canSubmit)}}function kM({model:e,submitLabel:t=`Save changes`,discardLabel:n,onCancel:r,cancelLabel:i,allowClean:a,layout:o,footer:s,children:c,disabled:l=!1,...u}){let{submitting:d}=OM(e),f=(0,q.useRef)(null),p=(0,q.useRef)(()=>void 0);return(0,q.useEffect)(()=>()=>{p.current()},[]),(0,J.jsxs)(xy,{...u,ref:f,layout:o,busy:d,noValidate:!0,onSubmit:t=>{t.preventDefault(),e.form.state.isSubmitting||e.submit().then(()=>{p.current();let t=f.current;t!==null&&!e.form.state.isValid&&(p.current=CM(t))})},children:[c??(0,J.jsx)(Jj,{model:e,disabled:l,layout:o}),s===void 0?(0,J.jsx)(MM,{model:e,label:t,discardLabel:r===void 0?n:void 0,onCancel:r,cancelLabel:i,allowClean:a??r!==void 0,divider:r===void 0}):s]})}function AM({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i,...a}){let o=DM({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i});return(0,J.jsx)(kM,{...a,model:o})}function jM(e){return`model`in e?(0,J.jsx)(kM,{...e}):(0,J.jsx)(AM,{...e})}function MM({model:e,label:t,discardLabel:n,onCancel:r,cancelLabel:i=`Cancel`,allowClean:a=!1,dirtyLabel:o=`Unsaved changes`,buttonProps:s,...c}){let{dirty:l,submitting:u}=OM(e),d=u?null:e.saved&&!l?(0,J.jsx)(bi,{tone:`success`,size:`compact`,label:e.saved}):l?(0,J.jsx)(bi,{tone:`neutral`,size:`compact`,label:o}):null;return(0,J.jsxs)(by,{...c,error:e.error,status:d,children:[r?(0,J.jsx)(U,{type:`button`,variant:`ghost`,disabled:u,onClick:r,children:i}):n&&l?(0,J.jsx)(U,{type:`button`,variant:`ghost`,disabled:u,onClick:e.discard,children:n}):null,(0,J.jsx)(U,{...s,type:`submit`,loading:u,disabled:u||!l&&!a,title:!l&&!a?`No changes to save`:void 0,children:t})]})}var NM={error:0,warning:1,info:2};function PM(e,t){let n=t.generating+t.uploading>0;if(n)return{busy:n,tone:void 0,label:[t.generating?`Creating ${String(t.generating)}`:``,t.uploading?`Uploading ${String(t.uploading)}`:``].filter(Boolean).join(` · `)};let r=[...e].sort((e,t)=>Number(t.blocking??!1)-Number(e.blocking??!1)||NM[e.tone]-NM[t.tone]).at(0);return r?{busy:n,tone:r.tone===`info`?`neutral`:r.tone,label:r.short+(e.length>1?` +${String(e.length-1)}`:``)}:null}function FM(e,t,n){let r=PM(e,t);if(!r)return null;let i={kind:`button`,id:`activity`,text:`Activity`,count:e.length+t.generating+t.uploading,busy:r.busy,title:v(`Activity: ${r.label}`,1024),opens:`dialog`,expanded:n};return r.tone===void 0?i:{...i,tone:r.tone}}var IM={Setup:(0,J.jsx)(Ih,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),Images:(0,J.jsx)(Eh,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),Uploads:(0,J.jsx)(Lh,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`})};function LM({notices:e,uploads:t,open:n,inset:r,onOpenChange:i,onDismiss:a,onDismissAll:o,onLoadMore:s}){return(0,J.jsx)(zr,{className:`prints-activity-tray`,placement:`host`,align:`start`,...r===void 0?{}:{hostInset:r},items:[{id:`activity`,label:`Activity`,title:`Activity`,content:(0,J.jsx)(RM,{notices:e,uploads:t,onDismiss:a,onDismissAll:o,onLoadMore:s})}],openId:n?`activity`:null,onOpenChange:e=>{i(e===`activity`)}})}function RM({notices:e,uploads:t,onDismiss:n,onDismissAll:r,onLoadMore:i}){let a=[`Setup`,`Images`,`Uploads`].map(t=>({group:t,items:e.filter(e=>e.group===t)})).filter(e=>e.items.length);return(0,J.jsxs)(`div`,{className:`prints-instrument`,children:[a.map(({group:e,items:t})=>(0,J.jsxs)(`section`,{"aria-label":e,className:`prints-notice-group`,children:[(0,J.jsx)(Nr,{level:3,children:e}),(0,J.jsx)(Hi,{children:t.map(e=>(0,J.jsx)(Nn,{icon:IM[e.group],primary:(0,J.jsxs)(`span`,{className:`prints-notice-copy`,children:[(0,J.jsx)(`span`,{children:e.title}),e.detail?(0,J.jsx)(`span`,{className:`prints-notice-detail`,children:e.detail}):null]}),actions:(0,J.jsxs)(`div`,{className:`prints-notice-actions`,"aria-label":`Actions for ${e.title}`,children:[e.actions?.map((e,t)=>(0,J.jsx)(U,{variant:t===0?`outline`:`ghost`,size:t===0?`sm`:`xs`,onClick:e.run,children:e.label},e.label)),e.blocking?null:(0,J.jsx)(pt,{"aria-label":`Dismiss ${e.title}`,icon:(0,J.jsx)(Ei,{"aria-hidden":`true`}),onClick:()=>{n(e.key)}})]})},e.key))})]},e)),e.length?null:(0,J.jsx)(hr,{children:`All caught up.`}),t&&t.items.length>0?(0,J.jsxs)(`section`,{"aria-label":`Upload queue`,className:`prints-upload-bank`,children:[(0,J.jsx)(Nr,{level:3,children:`Uploading`}),(0,J.jsx)(zA,{...t})]}):null,(0,J.jsxs)(`div`,{className:`prints-panel-footer`,children:[(0,J.jsx)(`span`,{className:`prints-footer-note`,children:`Clear dismisses finished items`}),(0,J.jsx)(U,{variant:`ghost`,size:`xs`,disabled:!e.some(e=>!e.blocking),onClick:r,children:`Clear`}),i?(0,J.jsx)(U,{variant:`ghost`,size:`xs`,onClick:i,children:`Load more activity`}):null]})]})}function zM({folder:e}){return(0,J.jsx)(cm,{open:e.editing,onOpenChange:e.setEditing,children:(0,J.jsxs)(pm,{children:[(0,J.jsx)(hm,{children:(0,J.jsx)(gm,{children:`Save prints to`})}),(0,J.jsx)(VM,{folder:e},e.computerId),(0,J.jsx)(mm,{children:(0,J.jsx)(_m,{render:(0,J.jsx)(U,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var BM=g({path:ue.check(F(u($n),{message:`Enter an absolute Computer folder, such as /media.`})).annotate($j({label:`Folder`,placeholder:`/media`}))});function VM({folder:e}){let t=(0,q.useRef)(!1),n=DM({schema:BM,defaultValues:{path:e.path??`/media`},onSubmit:async({path:n})=>{let r=await e.choose(n,t.current);return r?{kind:`refused`,fields:{path:r}}:{kind:`saved`}}}),r=e=>{t.current=e,n.form.setFieldMeta(`path`,e=>({...e,errorMap:{...e.errorMap,onServer:void 0}}))},i=e.busy||!e.writable;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(jM,{model:n,disabled:i,footer:(0,J.jsxs)(by,{divider:!1,children:[(0,J.jsx)(_t,{className:`[--caps-keycap-width:auto]`,label:`Use`,type:`submit`,disabled:i,onClick:()=>{r(!1)}}),(0,J.jsx)(_t,{className:`[--caps-keycap-width:auto]`,label:`Create`,type:`submit`,disabled:i,onClick:()=>{r(!0)}})]})}),e.error?(0,J.jsx)(Nn,{role:`alert`,icon:(0,J.jsx)(Th,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),primary:e.error}):(0,J.jsx)(hr,{children:e.writable?`Prints saves new images and uploads here and shows this folder as your gallery.`:`This Computer is read-only for Prints, so the folder can’t change.`})]})}var HM={image:`Image`,video:`Video`,audio:`Audio`,media:`Media`};function UM({connected:e,mediaCapability:t,modelsError:n,retryModels:r,modelsLoading:i,models:a,canGenerate:o,mediaSetupMissing:s,canWrite:c,generationErrors:l,recoveryError:u,pendingGenerations:d,activeGenerations:f,atGenerationLimit:p,gallerySlots:m,computerId:h,failed:g,uploadError:_,uploads:v,permissions:y,resume:b,discard:x,retryUpload:S}){let C=[];if(e)h===null?C.push({key:`no-computer`,group:`Setup`,tone:`info`,blocking:!0,short:`Choose a Computer`,title:`No Computer selected`,detail:`Choose a Computer for this window, or create one in Grove.`}):t?n===null?!i&&!o&&!s&&C.push({key:`approval`,group:`Setup`,tone:`warning`,blocking:!0,short:`Generation not enabled`,title:`Media generation isn’t enabled`,detail:`Turn it on in this App’s Team permissions. Images already generated can still be saved.`,actions:[{label:`Permissions`,run:()=>{y()}}]}):C.push({key:`models:${n}`,group:`Setup`,tone:`warning`,blocking:!0,short:`Models unavailable`,title:`Couldn’t load image models`,detail:n,actions:[{label:`Retry`,run:r}]}):C.push({key:`no-media`,group:`Setup`,tone:`info`,blocking:!0,short:`Image creation off`,title:`Image creation is off for this Computer`,detail:`You can still browse and upload images.`});else{let e=It(new G(`Prints disconnected`,{code:`DISCONNECTED`,retryable:!0}));C.push({key:`disconnected`,group:`Setup`,tone:`warning`,blocking:!0,short:e.title,title:e.title,detail:e.message})}e&&h!==null&&!c&&C.push({key:`read-only`,group:`Setup`,tone:`info`,blocking:!0,short:`Read-only`,title:`Read-only Computer`,detail:`Uploads and new prints are off.`});for(let e of l){let t=`${HM[e.mediaKind??`media`]} failed`;C.push({key:e.key,group:`Images`,tone:`error`,short:t,title:`${t}: ${e.message}`,detail:e.prompt,blocking:e.dismiss!==void 0,actions:[...e.billing?[{label:`Open Billing`,run:e.billing}]:e.retry?[{label:`Retry`,run:e.retry}]:[],...e.dismiss?[{label:`Dismiss`,run:e.dismiss}]:[]]})}p&&C.push({key:`generation-limit`,group:`Images`,tone:`info`,short:`At the limit`,title:`At the limit`,detail:wr,blocking:!0}),u!==null&&C.push({key:`recovery:${u}`,group:`Images`,tone:`error`,short:`Retry blocked`,title:u});for(let e of d){if(f.has(e.reference.requestId)||m.some(t=>t.computerId===e.reference.computerId&&t.path===e.input.destination.path))continue;let t=`${HM[Vn(a,e.input.settings.model)?.kind??`media`]} failed`;C.push({key:`unfinished:${e.reference.requestId}`,group:`Images`,tone:`error`,blocking:!0,short:t,title:`${t}: ${e.failure?.message??`Stopped when Prints closed. Retry to run it again.`}`,detail:e.reference.computerId===h?e.typed.prompt:`${e.typed.prompt} · select the original Computer to retry`,actions:[...e.reference.computerId===h?[{label:`Retry`,run:()=>{b(e)}}]:[],{label:`Dismiss`,run:()=>{x(e)}}]})}g.length>0&&C.push({key:`files:${g.join(`|`)}`,group:`Images`,tone:`error`,short:`Couldn’t open images`,title:`Couldn’t open some images`,detail:g.join(`, `)}),_!==null&&C.push({key:`uploads:${_}`,group:`Uploads`,tone:`error`,short:`Upload failed`,title:`Couldn’t add images`,detail:_});for(let e of v)(e.status===`error`||e.status===`cancelled`)&&C.push({key:`upload:${e.id}:${e.status}`,group:`Uploads`,tone:e.status===`error`?`error`:`info`,short:`Upload failed`,title:`${e.file.name} wasn’t saved`,detail:e.message,actions:[{label:`Retry`,run:()=>{S(e.id)}}]});return C}function WM(e,t){let n=Li(ci(e)),r=se($r({queryKey:oi.dismissals(e),mutationFn:({owner:e,id:t,keys:n})=>jr(e.capabilities,{operation:`dismiss-notices`,computerId:t,keys:n}),apply:(e,t)=>({keys:[...new Set([...e.keys,...t.keys])].slice(-200)})})),i=n=>{e&&t&&n.length>0&&r.mutate({owner:e,id:t,keys:n})};return{error:r.variables?.owner===e&&r.variables.id===t&&r.isError?`Could not dismiss activity. Please try again.`:n.isError?`Could not load dismissed activity. Notices may reappear.`:null,visible:e=>e.filter(e=>(e.blocking??!1)||!n.data?.keys.includes(e.key)),dismiss:e=>{i([e])},dismissAll:e=>{i(e.filter(e=>!e.blocking).map(e=>e.key).slice(-200))}}}var GM=0,KM=1,qM=2,JM=0,YM=1;function XM(e,t,n){let r=e.list,i;for(;r;){if(r.index===n)return!1;if(t>r.high)break;i=r,r=r.next}return i||(e.list={index:n,high:t,next:r}),i&&(i.next={index:n,high:t,next:i.next}),!0}function ZM(e,t){let n=e.list;if(n.index===t)return n.next===null?JM:(e.list=n.next,YM);let r=n;for(n=n.next;n!==null;){if(n.index===t)return r.next=n.next,YM;r=n,n=n.next}}var QM={low:0,max:0,high:0,C:qM,P:void 0,R:void 0,L:void 0,list:void 0};QM.P=QM,QM.L=QM,QM.R=QM;function $M(e){let t=e.high;e.max=e.L===QM&&e.R===QM?t:e.L===QM?Math.max(e.R.max,t):e.R===QM?Math.max(e.L.max,t):Math.max(Math.max(e.L.max,e.R.max),t)}function eN(e){let t=e;for(;t.P!==QM;)$M(t.P),t=t.P}function tN(e,t){if(t.R===QM)return;let n=t.R;t.R=n.L,n.L!==QM&&(n.L.P=t),n.P=t.P,t.P===QM?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.L=t,t.P=n,$M(t),$M(n)}function nN(e,t){if(t.L===QM)return;let n=t.L;t.L=n.R,n.R!==QM&&(n.R.P=t),n.P=t.P,t.P===QM?e.root=n:t===t.P.R?t.P.R=n:t.P.L=n,n.R=t,t.P=n,$M(t),$M(n)}function rN(e,t,n){t.P===QM?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.P=t.P}function iN(e,t){let n;for(;t!==QM&&t.C===KM;)t===t.P.L?(n=t.P.R,n.C===GM&&(n.C=KM,t.P.C=GM,tN(e,t.P),n=t.P.R),n.L.C===KM&&n.R.C===KM?(n.C=GM,t=t.P):(n.R.C===KM&&(n.L.C=KM,n.C=GM,nN(e,n),n=t.P.R),n.C=t.P.C,t.P.C=KM,n.R.C=KM,tN(e,t.P),t=e.root)):(n=t.P.L,n.C===GM&&(n.C=KM,t.P.C=GM,nN(e,t.P),n=t.P.L),n.R.C===KM&&n.L.C===KM?(n.C=GM,t=t.P):(n.L.C===KM&&(n.R.C=KM,n.C=GM,tN(e,n),n=t.P.L),n.C=t.P.C,t.P.C=KM,n.L.C=KM,nN(e,t.P),t=e.root));t.C=KM}function aN(e){for(;e.L!==QM;)e=e.L;return e}function oN(e,t){let n;for(;t.P.C===GM;)t.P===t.P.P.L?(n=t.P.P.R,n.C===GM?(t.P.C=KM,n.C=KM,t.P.P.C=GM,t=t.P.P):(t===t.P.R&&(t=t.P,tN(e,t)),t.P.C=KM,t.P.P.C=GM,nN(e,t.P.P))):(n=t.P.P.L,n.C===GM?(t.P.C=KM,n.C=KM,t.P.P.C=GM,t=t.P.P):(t===t.P.L&&(t=t.P,nN(e,t)),t.P.C=KM,t.P.P.C=GM,tN(e,t.P.P)));e.root.C=KM}function sN(){let e={root:QM,size:0},t={};return{insert(n,r,i){let a=e.root,o=QM;for(;a!==QM&&(o=a,n!==o.low);)a=n<a.low?a.L:a.R;if(n===o.low&&o!==QM){if(!XM(o,r,i))return;o.high=Math.max(o.high,r),$M(o),eN(o),t[i]=o,e.size++;return}let s={low:n,high:r,max:r,C:GM,P:o,L:QM,R:QM,list:{index:i,high:r,next:null}};o===QM?e.root=s:(s.low<o.low?o.L=s:o.R=s,eN(s)),oN(e,s),t[i]=s,e.size++},remove(n){let r=t[n];if(r===void 0)return;delete t[n];let i=ZM(r,n);if(i===void 0)return;if(i===YM){r.high=r.list.high,$M(r),eN(r),e.size--;return}let a=r,o=a.C,s;r.L===QM?(s=r.R,rN(e,r,r.R)):r.R===QM?(s=r.L,rN(e,r,r.L)):(a=aN(r.R),o=a.C,s=a.R,a.P===r?s.P=a:(rN(e,a,a.R),a.R=r.R,a.R.P=a),rN(e,r,a),a.L=r.L,a.L.P=a,a.C=r.C),$M(s),eN(s),o===KM&&iN(e,s),e.size--},search(t,n,r){let i=[e.root];for(;i.length!==0;){let e=i.pop();if(!(e===QM||t>e.max)&&(e.L!==QM&&i.push(e.L),e.R!==QM&&i.push(e.R),e.low<=n&&e.high>=t)){let n=e.list;for(;n!==null;)n.high>=t&&r(n.index,e.low),n=n.next}}},get size(){return e.size}}}var cN=e=>{let t=q.useRef(e);return q.useEffect(()=>{t.current=e}),t},lN=(e,t)=>{let n=t||uN,r,i;return function(){return r&&n(arguments,r)?i:i=e.apply(null,r=arguments)}},uN=(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3],dN=class{constructor(){this.set=void 0,this.get=void 0;let e,t;this.get=n=>n===e?t:void 0,this.set=(n,r)=>{e=n,t=r}}},fN=e=>{try{return new e}catch{let e={};return{set(t,n){e[t]=n},get(t){return e[t]}}}},pN=e=>{let t=e.length,n=fN(e[0]),r,i,a,o,s=t===1;return t<3?{g:e=>(r=n.get(e[0]))===void 0||s?r:r.get(e[1]),s:(t,a)=>(s?n.set(t[0],a):(r=n.get(t[0]))===void 0?(i=fN(e[1]),i.set(t[1],a),n.set(t[0],i)):r.set(t[1],a),a)}:{g:e=>{for(o=n,a=0;a<t;a++)if((o=o.get(e[a]))===void 0)return;return o},s:(r,s)=>{for(o=n,a=0;a<t-1;a++)(i=o.get(r[a]))===void 0?(i=fN(e[a+1]),o.set(r[a],i),o=i):o=i;return o.set(r[t-1],s),s}}},mN=(e,t)=>{let n,{g:r,s:i}=pN(e);return function(){return(n=r(arguments))===void 0?i(arguments,t.apply(null,arguments)):n}},hN=new WeakMap;function gN(){let e=q.useState(_N)[1];return q.useRef(()=>e({})).current}var _N={},vN=q.createElement;function yN(e){let{positioner:t,resizeObserver:n,items:r,as:i=`div`,id:a,className:o,style:s,role:c=`grid`,tabIndex:l=0,containerRef:u,itemAs:d=`div`,itemStyle:f,itemHeightEstimate:p=300,itemKey:m=TN,overscanBy:h=2,scrollTop:g,isScrolling:_,height:v,render:y,onRender:b}=e,x=0,S,C=gN(),w=DN(t,n),T=r.length,{columnWidth:E,columnCount:D,range:O,estimateHeight:k,size:A,shortestColumn:j}=t,M=A(),N=j(),P=[],F=c===`list`?`listitem`:c===`grid`?`gridcell`:void 0,I=cN(b);h=v*h;let ee=g+h,te=N<ee&&M<T;if(O(Math.max(0,g-h/2),ee,(e,t,n)=>{let i=r[e],a=m(i,e),o={top:n,left:t,width:E,writingMode:`horizontal-tb`,position:`absolute`};P.push(vN(d,{key:a,ref:w(e),role:F,style:typeof f==`object`&&f?Object.assign({},o,f):o},xN(y,e,i,E))),S===void 0?(x=e,S=e):(x=Math.min(x,e),S=Math.max(S,e))}),te){let e=Math.min(T-M,Math.ceil((g+h-N)/p*D)),t=M,n=EN(E);for(;t<M+e;t++){let e=r[t],i=m(e,t);P.push(vN(d,{key:i,ref:w(t),role:F,style:typeof f==`object`?Object.assign({},n,f):n},xN(y,t,e,E)))}}q.useEffect(()=>{typeof I.current==`function`&&S!==void 0&&I.current(x,S,r),bN=`1`},[x,S,r,I]),q.useEffect(()=>{te&&C()},[te,t]);let ne=SN(_,k(T,p));return vN(i,{ref:u,key:bN,id:a,role:c,className:o,tabIndex:l,style:typeof s==`object`?wN(ne,s):ne,children:P})}var bN=`0`,xN=mN([dN,{},WeakMap,dN],(e,t,n,r)=>vN(e,{index:t,data:n,width:r})),SN=lN((e,t)=>({position:`relative`,width:`100%`,maxWidth:`100%`,height:Math.ceil(t),maxHeight:Math.ceil(t),willChange:e?`contents`:void 0,pointerEvents:e?`none`:void 0})),CN=(e,t)=>e[0]===t[0]&&e[1]===t[1],wN=lN((e,t)=>Object.assign({},e,t),CN);function TN(e,t){return t}var EN=lN(e=>({width:e,zIndex:-1e3,visibility:`hidden`,position:`absolute`,writingMode:`horizontal-tb`}),(e,t)=>e[0]===t[0]),DN=lN((e,t)=>n=>r=>{r!==null&&(t&&(t.observe(r),hN.set(r,n)),e.get(n)===void 0&&e.set(n,r.offsetHeight))},CN),ON=function(e,t,n,r){n===void 0&&(n=0),r===void 0&&(r=n);let i=sN(),a=Array(e),o=[],s=Array(e);for(let t=0;t<e;t++)a[t]=0,s[t]=[];return{columnCount:e,columnWidth:t,set:function(e,c){c===void 0&&(c=0);let l=0;for(let e=1;e<a.length;e++)a[e]<a[l]&&(l=e);let u=a[l]||0;a[l]=u+c+r,s[l].push(e),o[e]={left:l*(t+n),top:u,height:c,column:l},i.insert(u,u+c,e)},get:e=>o[e],update:t=>{let n=Array(e),c=0,l=0;for(;c<t.length-1;c++){let e=t[c],r=o[e];r.height=t[++c],i.remove(e),i.insert(r.top,r.top+r.height,e),n[r.column]=n[r.column]===void 0?e:Math.min(e,n[r.column])}for(c=0;c<n.length;c++){if(n[c]===void 0)continue;let e=s[c],t=kN(e,n[c]),u=s[c][t],d=o[u];for(a[c]=d.top+d.height+r,l=t+1;l<e.length;l++){let t=e[l],n=o[t];n.top=a[c],a[c]=n.top+n.height+r,i.remove(t),i.insert(n.top,n.top+n.height,t)}}},range:(e,t,n)=>i.search(e,t,(e,t)=>n(e,o[e].left,t)),estimateHeight:(t,n)=>{let r=Math.max(0,Math.max.apply(null,a));return t===i.size?r:r+Math.ceil((t-i.size)/e)*n},shortestColumn:()=>a.length>1?Math.min.apply(null,a):a[0]||0,size(){return i.size},all(){return o}}},kN=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=n+r>>>1,a=e[i];if(a===t)return i;a<=t?n=i+1:r=i-1}return-1},AN=(0,q.createContext)(null);function jN(){let e=(0,q.useContext)(AN);if(e===null)throw Error(`An audio tile part must sit inside an AudioTileScope`);return e}function MN({url:e,children:t}){let n=c_(e,at);return(0,J.jsx)(AN.Provider,{value:n,children:t})}function NN({url:e}){let{progress:t}=jN();return(0,J.jsx)(`span`,{className:`prints-audio-tile`,children:(0,J.jsx)(l_,{progress:t,url:e})})}function PN({title:e}){let t=jN();return(0,J.jsx)(pt,{"aria-label":`${t.playing?`Pause`:`Play`} ${e}`,className:`prints-audio-tile-play`,icon:t.playing?(0,J.jsx)(Mh,{}):(0,J.jsx)(Ph,{}),iconSize:`sm`,size:`sm`,variant:`accent`,onClick:t.toggle})}var FN=8,IN=320,LN=4,RN=640,zN=656;function BN(e,t){return e<=0||!Number.isFinite(t)||t<=0?0:e===1?1:e<=LN?t<RN?1:e===2||t<zN?2:3:t>=1280?4:t>=zN?3:2}function VN({item:e}){return an(e.path)?(0,J.jsx)(NN,{url:e.url}):lo(e.path)?(0,J.jsx)(`video`,{"aria-label":e.path,className:`block h-full w-full object-cover`,"data-media-thumb":!0,loop:!0,muted:!0,playsInline:!0,src:e.url}):(0,J.jsx)(`img`,{alt:e.path,className:`block h-full w-full object-cover`,"data-media-thumb":!0,src:e.url})}var HN=(0,q.memo)(function({item:e}){let t=(0,q.useRef)(null);(0,q.useEffect)(()=>{e.onVisible?.()},[e.onVisible]);let[n,r]=(0,q.useState)(e.pending===!0&&!e.onVisible);return e.pending&&!e.onVisible&&!n&&r(!0),(0,q.useLayoutEffect)(()=>{let r=t.current;if(!r||e.pending||n)return;let i=window.matchMedia(`(prefers-reduced-motion: reduce)`);if(i.matches)return;let a=!0,o,s,c=()=>o?.();return Rr(async()=>{let{animate:e,spring:t}=await import(`./modules-C4mfDnjH.js`).then(e=>e.t);return{animate:e,spring:t}},__vite__mapDeps([3,1]),import.meta.url).then(({animate:e,spring:t})=>{if(!a)return;let n=e(r,{opacity:{from:0,to:1,duration:160,ease:`outQuad`},translateY:{from:6,to:0,ease:t({bounce:.16,duration:320})},scale:{from:.985,to:1,ease:t({bounce:.16,duration:320})}});o=()=>{n.complete()},s=()=>{n.revert()}}),i.addEventListener(`change`,c),()=>{a=!1,i.removeEventListener(`change`,c),s?.()}},[e.key,e.pending,n]),(0,J.jsxs)(`div`,{ref:t,className:`prints-gallery-tile`,"data-referenced":e.referenced?!0:void 0,children:[e.error?(0,J.jsx)(`div`,{className:`block h-full w-full overflow-hidden bg-base-200`,"data-media-failed":!0,title:e.path,children:(0,J.jsx)(bm,{status:`failed`,failure:(0,J.jsxs)(`div`,{className:`flex max-w-full flex-col items-center gap-xs`,children:[e.prompt?(0,J.jsx)(`p`,{className:`m-0 max-w-full truncate px-md text-xs text-(--stipe-fg-muted)`,children:e.prompt}):null,(0,J.jsx)(vm,{density:`tile`,message:e.error,onRetry:e.onRetry,onDismiss:e.onDismiss})]})})}):(0,J.jsx)(`button`,{className:`block h-full w-full overflow-hidden bg-base-200 p-0 text-left`,"data-media-thumb-wrap":!0,type:`button`,disabled:e.pending,"aria-pressed":e.select?.active?e.select.checked:void 0,onClick:()=>{e.select?.active?e.select.onToggle():e.onOpen(e.path)},onKeyDown:t=>{t.key.toLowerCase()===`i`&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&e.onInfo&&(t.preventDefault(),e.onInfo())},title:e.path,children:(0,J.jsx)(`div`,{className:`caps-item block! h-full w-full overflow-hidden rounded-none! border-0! bg-transparent! shadow-none! z-auto! -outline-offset-2!`,"data-selected":e.selected??!1,children:e.pending||n?(0,J.jsx)(bm,{"data-media-pending":e.pending?`true`:void 0,indicator:(0,J.jsx)(`div`,{className:`prints-pending-loader`,"data-run":e.pending&&(e.prompt||e.onStop)?``:void 0,children:(0,J.jsx)(ln,{decorative:!0,size:`fill`,tone:`accent`,variant:`bloom`})}),label:e.pendingLabel??`Preparing image…`,status:e.pending?`generating`:`done`,children:e.pending?null:(0,J.jsx)(VN,{item:e})}):(0,J.jsx)(VN,{item:e})})}),e.pending&&!e.error&&(e.prompt||e.onStop)?(0,J.jsxs)(`div`,{className:`prints-tile-run`,"data-media-run":!0,children:[e.prompt?(0,J.jsx)(`p`,{className:`prints-tile-caption`,"data-media-caption":!0,children:e.prompt}):null,e.onStop?(0,J.jsx)(pt,{"aria-label":`Stop`,title:`Stop`,size:`sm`,variant:`outline`,iconSize:`sm`,className:`prints-tile-stop`,onClick:e.onStop,icon:(0,J.jsx)(Zn,{fill:`currentColor`})}):null]}):null,!e.pending&&!e.error?(0,J.jsx)(GN,{item:e}):null,(0,J.jsxs)(`div`,{className:`prints-gallery-tools`,children:[!e.pending&&!e.error?(0,J.jsx)(KN,{item:e}):null,!e.pending&&e.onInfo?(0,J.jsx)(pt,{className:`prints-gallery-secondary`,"aria-label":`Image info: ${e.path}`,title:`Image info (I)`,"aria-keyshortcuts":`I`,onClick:e.onInfo,icon:(0,J.jsx)(Oh,{})}):null,!e.pending&&e.onToggleReference?(0,J.jsx)(pt,{className:`prints-gallery-reference prints-gallery-secondary`,"aria-label":`${e.referenced?`Remove reference`:`Add reference`}: ${e.path}`,title:e.referenced?`Remove reference`:`Add reference`,"aria-pressed":e.referenced??!1,disabled:e.referenceDisabled,onClick:e.onToggleReference,icon:e.referenced?(0,J.jsx)(Lr,{}):(0,J.jsx)(Eh,{})}):null]})]})}),UN=(0,q.memo)(function({item:e}){return an(e.path)?(0,J.jsx)(MN,{url:e.url,children:(0,J.jsx)(HN,{item:e})}):(0,J.jsx)(HN,{item:e})}),WN=e=>`${String(e)}s`;function GN({item:e}){let{select:t}=e;return(0,J.jsxs)(J.Fragment,{children:[an(e.path)&&e.url!==``?(0,J.jsx)(PN,{title:e.path}):null,(0,J.jsx)(`div`,{className:`prints-tile-mark`,"data-checked":t?.active?t.checked:void 0,"data-favorite":e.favorite?!0:void 0,children:t?.active?(0,J.jsx)(TA,{appearance:`compact`,"aria-label":`Select ${e.path}`,checked:t.checked,onChange:t.onToggle}):e.onToggleFavorite?(0,J.jsx)(pt,{"aria-label":`${e.favorite?`Unfavorite`:`Favorite`}: ${e.path}`,"aria-pressed":e.favorite??!1,className:`prints-tile-heart`,icon:(0,J.jsx)(fr,{fill:e.favorite?`currentColor`:`none`}),onClick:e.onToggleFavorite,title:e.favorite?`Remove from favorites`:`Favorite`}):null}),e.badge?(0,J.jsx)(`div`,{className:`prints-tile-badge`,"data-media-badge":!0,children:e.badge.label===null?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Lh,{"aria-hidden":!0,size:12}),(0,J.jsx)(`span`,{children:`Upload`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`prints-tile-badge-model`,children:e.badge.label}),e.badge.seconds===null?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(_i,{"aria-hidden":!0,size:12}),(0,J.jsx)(`span`,{children:WN(e.badge.seconds)})]})]})}):null,e.folderCaption?(0,J.jsx)(`div`,{className:`prints-tile-folder`,title:e.folderCaption,children:e.folderCaption}):null]})}function KN({item:e}){return!e.onMove||e.select?.active?null:(0,J.jsxs)(Co,{children:[(0,J.jsx)(Ia,{render:(0,J.jsx)(pt,{"aria-label":`More actions: ${e.path}`,title:`More actions`,icon:(0,J.jsx)(ao,{})})}),(0,J.jsxs)(qa,{children:[(0,J.jsxs)(so,{onSelect:e.onMove,children:[(0,J.jsx)(On,{"aria-hidden":!0,size:16}),` Move to…`]}),e.onToggleFavorite?(0,J.jsxs)(so,{onSelect:e.onToggleFavorite,children:[(0,J.jsx)(fr,{"aria-hidden":!0,size:16}),` `,e.favorite?`Remove from favorites`:`Favorite`]}):null,e.onInfo?(0,J.jsxs)(so,{onSelect:e.onInfo,children:[(0,J.jsx)(Oh,{"aria-hidden":!0,size:16}),` Image info`]}):null,e.onToggleReference?(0,J.jsxs)(so,{disabled:e.referenceDisabled,onSelect:e.onToggleReference,children:[e.referenced?(0,J.jsx)(Lr,{"aria-hidden":!0,size:16}):(0,J.jsx)(Eh,{"aria-hidden":!0,size:16}),` `,e.referenced?`Remove reference`:`Add reference`]}):null]})]})}var qN=(0,q.memo)(function({children:e,style:t,...n}){return(0,J.jsx)(`div`,{"data-media-grid":!0,...n,style:t,children:e})});function JN(e,t){let[n,r]=(0,q.useState)({height:0,width:0});return(0,q.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{r(e=>{let n={height:t.clientHeight,width:t.clientWidth};return n.width===e.width&&n.height===e.height?e:n})};n();let i=new ResizeObserver(n);return i.observe(t),window.addEventListener(`resize`,n),()=>{i.disconnect(),window.removeEventListener(`resize`,n)}},[e,t]),n}function YN(e){let[t,n]=(0,q.useState)(0),[r,i]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{let t=e.current;if(!t)return;let r=null,a=()=>{n(t.scrollTop),i(!0),r!==null&&clearTimeout(r),r=setTimeout(()=>{i(!1)},150)};return t.addEventListener(`scroll`,a,{passive:!0}),()=>{t.removeEventListener(`scroll`,a),r!==null&&clearTimeout(r)}},[e]),{isScrolling:r,scrollTop:t}}function XN(e,t){let n=t.height>0?t.width/t.height:1;return Math.round(e/n)}function ZN(e,t,n,r){let i=Math.floor((t-(n-1)*FN)/n),a=e.length===1?e[0]:void 0;if(!a||r<=0)return i;let o=a.height>0?a.width/a.height:1;return Math.max(1,Math.min(i,Math.floor(r*o)))}function QN(e,t,n){let r=e.some(e=>e.select!==void 0),i=Math.max(1,BN(e.length,t),r&&e.length>=2?2:1),a=t-16,o=n-16;return(0,q.useMemo)(()=>{let t=ZN(e,a,i,o),n=ON(i,t,FN);return t>0&&e.forEach((e,r)=>{n.set(r,XN(t,e))}),n},[e,a,i,o])}var $N=132,eP=(0,q.memo)(function({data:e,width:t}){let n=XN(t,e);return(0,J.jsx)(`div`,{"data-media-tile":e.key,"data-short":n<$N?``:void 0,style:{height:n,width:t},children:(0,J.jsx)(UN,{item:e})})});function tP(e,t){let n=Array.from(e.querySelectorAll(`[data-media-tile]`)).find(e=>e.dataset.mediaTile===t)?.querySelector(`[data-media-thumb-wrap]`);return!n||n.disabled?!1:(n.focus({preventScroll:!0}),!0)}function nP(e,t,n){let r=e.ownerDocument;(r.activeElement!==r.body||tP(e,t))&&n()}function rP(e,t,n){let r=n.top+t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;return(r<e.scrollTop||r+n.height>e.scrollTop+e.clientHeight)&&e.scrollTo({top:r,behavior:`instant`}),r}var iP=(0,q.memo)(function({items:e,scrollRef:t,focus:n}){let r=JN(t,e.length),i=r.width||IN,a=e.length===1&&r.height>0,o=i-16,s=r.height-16,c=QN(e,i,r.height),{isScrolling:l,scrollTop:u}=YN(t),d=(0,q.useRef)(new Set),f=(0,q.useRef)(null),p=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!n)return;let a=f.current===n.requestId;if(a&&p.current===i)return;let o=t.current,s=e.findIndex(e=>e.key===n.key),l=c.get(s);if(!o||!l||r.height===0)return;let u=o.querySelector(`[data-media-grid]`);if(!u)return;let d=rP(o,u,l);if(a){nP(o,n.key,()=>{p.current=i});return}tP(o,n.key)?(f.current=n.requestId,p.current=i,n.onFocus()):o.scrollTo({top:d,behavior:`instant`})},[n,e,r.height,t,u,c,i]),(0,q.useEffect)(()=>{let n=t.current;if(!n||r.width===0||r.height===0)return;let i=e.findIndex(e=>e.pending&&!e.onVisible&&!d.current.has(e.key));if(d.current=new Set(e.map(e=>e.key)),i<0)return;let a=c.get(i),o=n.querySelector(`[data-media-grid]`);if(!a||!o)return;let s=o.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop,l=i===0?0:s+a.top,u=l+a.height;l>=n.scrollTop&&u<=n.scrollTop+n.clientHeight||n.scrollTo({top:Math.max(0,l-FN),behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`})},[e,r.width,r.height,t,c]);let m=(0,q.useCallback)(({data:e,width:t})=>(0,J.jsx)(eP,{data:e,width:t}),[]),h=yN({as:qN,height:r.height,isScrolling:l,itemKey:e=>e.key,items:e,overscanBy:2,positioner:c,render:m,scrollTop:u});return(0,J.jsx)(`div`,{"data-media-sole":a?``:void 0,style:{boxSizing:`border-box`,padding:FN,...a?{display:`flex`,alignItems:`center`,justifyContent:`center`,minHeight:r.height}:void 0},children:(0,J.jsx)(`div`,{style:{width:a?ZN(e,o,1,s):`100%`},children:h})})});function aP({items:e,scrollRef:t,focus:n}){return(0,J.jsx)(`section`,{"data-media-mosaic":!0,children:(0,J.jsx)(iP,{items:e,scrollRef:t,focus:n})})}function oP(e,t,n){let r=new Map(e.map(e=>[e.key,e])),i=new Set(t.map(e=>e.key));return[...[...t].reverse().filter(e=>!e.resolved||r.has(e.key)).map(e=>{let t=r.get(e.key);return t&&e.resolved?t:n(e)}),...e.filter(e=>!i.has(e.key))]}function sP(e){let t=on(),n=Li(nr(e)),r=n=>({mutationFn:t=>{let r=e?.context.get().computerId;if(!e||!r)throw Error(`No Computer selected`);return n(e,r,t)},onSuccess:n=>{t.setQueryData(oi.characters(e),n)}}),i=se(r((e,t,n)=>jn(e.capabilities,t,n))),a=se(r((e,t,n)=>Jn(e.capabilities,t,n)));return{characters:n.data?.characters??[],error:n.error?It(n.error).message:null,busy:i.isPending||a.isPending,save:(e,t)=>{i.mutate(e,{onError:()=>{xi(`The character could not be saved. Try again.`,`prints-character-save`)},onSuccess:t})},remove:(e,t)=>{a.mutate(e,{onSuccess:t,onError:()=>{xi(`The character could not be deleted. Try again.`,`prints-character-delete`)}})}}}var cP=u(Hn),lP=e=>e.split(`/`).at(-1)??e;function uP({paths:e,images:t}){return(0,J.jsx)(`span`,{className:`flex gap-xs`,children:e.map(e=>{let n=t.find(t=>t.path===e);return(0,J.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,title:e,children:n?(0,J.jsx)(`img`,{src:n.url,alt:lP(e)}):null},e)})})}function dP({characters:e,images:t,open:n,onOpenChange:r,busy:i,error:a,canUpload:o,onUpload:s,onSave:c,onDelete:l}){let[u,d]=(0,q.useState)(null),f=(0,q.useId)(),p=u?.name.trim()??``,m=p.startsWith(`@`)?p.slice(1):p,h=[];m===``?h.push(`Enter a character name.`):m.length>32?h.push(`Use 32 characters or fewer for the name.`):/^image\d+$/i.test(m)?h.push(`image1, image2 and so on name attached references; pick another name.`):cP(m)||h.push(`Use only letters, numbers, hyphens (-) and underscores (_).`),u?.references.length===0&&h.push(`Select at least one reference image.`),i&&h.push(`Wait for the current character change to finish, then save.`);let g=h.length>0,_=g?f:void 0;return(0,J.jsx)(cm,{open:n,onOpenChange:e=>{e||d(null),r(e)},children:(0,J.jsxs)(pm,{children:[(0,J.jsx)(hm,{children:(0,J.jsx)(gm,{children:`Characters`})}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[e.length===0&&u===null?(0,J.jsx)(`p`,{className:`text-sm`,children:`No characters yet. Save one, then type @name in a prompt to keep it the same in every image.`}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-sm`,"aria-label":`Saved characters`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center justify-between gap-sm`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-sm`,children:[(0,J.jsx)(uP,{paths:e.references.map(e=>e.path),images:t}),(0,J.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`@`,e.name]})]}),(0,J.jsxs)(`span`,{className:`flex gap-xs`,children:[(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{d(e)},children:`Edit`}),(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,disabled:i,onClick:()=>{l(e,()=>{u?.id===e.id&&d(null)})},children:`Delete`})]})]},e.id))}),u===null?(0,J.jsx)(U,{size:`xs`,type:`button`,onClick:()=>{d({name:``,description:``,references:[]})},children:`New character`}):(0,J.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,J.jsx)(py,{"aria-label":`Character name`,"aria-invalid":!cP(m),"aria-describedby":_,maxLength:33,placeholder:`Name, typed as @name`,value:u.name,onChange:e=>{d({...u,name:e.currentTarget.value})}}),(0,J.jsx)(Gi,{"aria-label":`Character description`,maxLength:500,rows:4,placeholder:`Short description added to the prompt, e.g. a tall girl with silver hair and a red scarf`,value:u.description,onChange:e=>{d({...u,description:e.currentTarget.value})}}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-sm`,children:[(0,J.jsxs)(`span`,{className:`text-xs`,children:[`Reference images · `,u.references.length,` selected, up to`,` `,8]}),(0,J.jsxs)(U,{size:`xs`,variant:`ghost`,type:`button`,disabled:!o,onClick:s,children:[(0,J.jsx)(Lh,{"aria-hidden":`true`,size:14}),`Upload`]})]}),t.length===0?(0,J.jsx)(`p`,{className:`text-xs`,children:`No images in the Prints folder yet. Upload one to use it as a reference.`}):(0,J.jsx)(`ul`,{className:`prints-character-picker`,"aria-label":`Reference images`,children:t.map(e=>{let t=u.references.some(t=>t.path===e.path);return(0,J.jsx)(`li`,{title:e.path,children:(0,J.jsxs)(`label`,{className:`prints-character-pick`,children:[(0,J.jsx)(`img`,{src:e.url,alt:``}),(0,J.jsx)(`span`,{className:`prints-character-check`,children:(0,J.jsx)(TA,{"aria-label":`Use ${lP(e.path)}`,checked:t,disabled:!t&&u.references.length>=8,onChange:()=>{d({...u,references:t?u.references.filter(t=>t.path!==e.path):[...u.references,{path:e.path}]})}})})]})},e.path)})}),g?(0,J.jsx)(`p`,{id:f,role:`status`,className:`text-xs`,children:h.join(` `)}):null,(0,J.jsxs)(`div`,{className:`flex gap-xs`,children:[(0,J.jsx)(U,{size:`xs`,variant:`primary`,type:`button`,disabled:g,"aria-describedby":_,onClick:()=>{c({id:u.id,name:m,description:u.description.trim(),references:u.references},()=>{d(null)})},children:`Save character`}),(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{d(null)},children:`Cancel`})]})]}),a?(0,J.jsx)(`p`,{role:`alert`,className:`text-xs`,children:a}):null]}),(0,J.jsx)(mm,{children:(0,J.jsx)(_m,{render:(0,J.jsx)(U,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var fP=g({destination:Re(p(b)),height:Re(un),model:Re(b),prompt:Re(b),references:Re(vt(g({computerId:Re(b),path:b,role:Re($e([`first-frame`,`last-frame`,`reference`]))}))),generateAudio:Re(p(mt)),steps:Re(p(un)),style:Re(p(b)),width:Re(un)}),pP=i(K(),Jt()).parse(structuredClone(Ue(fP,{onExcessProperty:`error`}).schema)),mP=(e,t,n,r)=>({id:e,title:t,category:`Image generation`,description:n,projections:{agent:{}},action:r===void 0?{presentation:{type:`action`}}:{inputSchema:r,presentation:{type:`action`}}}),hP=mP(`inspect-generation-draft`,`Inspect image draft`,`Read the current Prints image form and available models`),gP=mP(`set-generation-draft`,`Edit image draft`,`Set selected Prints image form fields; this does not generate an image`,pP),_P=mP(`submit-generation-draft`,`Generate image`,`Submit the current Prints image form using the same action as the Send button`);function vP(e,t){let n=!1,r=new Set,i=(t,i)=>{e.commands.register(t,i).then(e=>{n?e():r.add(e)},()=>void 0)};return i(hP,()=>{if(n)return;let e=t.readDraft();return{draft:{destination:e.destination??null,height:e.height,model:e.model,prompt:e.prompt,generateAudio:e.generateAudio??null,references:e.references.map(e=>{let t={path:e.path,role:e.role??null};return e.computerId===void 0?t:{...t,computerId:e.computerId}}),steps:e.steps??null,style:e.style??null,width:e.width},models:t.readModels().map(e=>({id:e.id,label:e.label,defaultHeight:e.input.defaultHeight,defaultWidth:e.input.defaultWidth,maxReferences:e.input.maxReferences}))}}),i(gP,({arguments:e})=>{if(n)return;let r=L(fP,{onExcessProperty:`error`})(e);t.setDraft(r)}),i(_P,async()=>{if(!n)return{accepted:await t.submit()}}),()=>{if(!n){n=!0;for(let e of r)e();r.clear()}}}function yP(e){return[{id:`clear-prompt`,title:`Clear prompt`,category:`Prompt`,description:`Remove the current prompt`,projections:{slash:{aliases:[`clear`],order:0},palette:{}},handler:()=>{e().clear()}},...Qr.map((t,n)=>({id:`size-${t}`,title:`Use ${t} size`,category:`Prompt`,description:`Use ${String(wi[t].width)} × ${String(wi[t].height)}`,projections:{slash:{aliases:[t],order:n+1},palette:{}},handler:()=>{e().useSize(t)}})),{id:`choose-style`,title:`Choose style`,category:`Prompt`,description:`Pick, create or edit a saved style`,projections:{slash:{aliases:[`style`],order:4},palette:{}},handler:()=>{e().openStyles()}},{id:`no-style`,title:`Use no style`,category:`Prompt`,description:`Send the prompt without a style`,projections:{slash:{aliases:[`nostyle`],order:5},palette:{}},handler:()=>{e().clearStyle()}}]}function bP(e,t){let n=(0,q.useRef)(e);n.current=e;let r=Vf(t,{sourceId:`media-prompt`,namespace:`media`},(0,q.useCallback)(()=>yP(()=>n.current),[])),i=(0,q.useSyncExternalStore)(r.subscribe,r.snapshot,r.snapshot);return{items:(0,q.useMemo)(()=>vr(i).map(e=>({id:e.commandId,command:e.command,slash:e.alias,title:e.title,description:e.description})),[i]),run:e=>{r.execute(e,{origin:`slash`})}}}function xP(e){let t=on(),n=Li(ir(e)),r=n=>({mutationFn:t=>{let r=e?.context.get().computerId;if(!e||!r)throw Error(`No Computer selected`);return n(e,r,t)},onSuccess:n=>{t.setQueryData(oi.styles(e),n)}}),i=se(r((e,t,n)=>kr(e.capabilities,t,n))),a=se(r((e,t,n)=>Qn(e.capabilities,t,n)));return{styles:n.data?.styles??[],error:n.error?It(n.error).message:null,busy:i.isPending||a.isPending,save:(e,t)=>{i.mutate(e,{onError:()=>{xi(`The style could not be saved. Try again.`,`prints-style-save`)},onSuccess:n=>{t(n.styles.find(t=>t.name===e.name))}})},remove:(e,t)=>{a.mutate(e,{onSuccess:t,onError:()=>{xi(`The style could not be deleted. Try again.`,`prints-style-delete`)}})}}}function SP(e){let t=e.filter(e=>e.kind===`video`&&e.video!==null&&e.video.prices.length>0&&e.input.maxReferences>=1&&e.video.referenceRoles.includes(`first-frame`));return t.find(e=>e.video?.provider===`seedance`)??t.at(0)}function CP(e,t,n){let r=e.video;if(r===null)return;let i=Math.log(t/n),a=e=>Math.abs(Math.log(e.width/e.height)-i);return r.formats.filter(e=>e.resolution===r.defaultResolution).reduce((e,t)=>e===void 0||a(t)<a(e)?t:e,void 0)}function wP(e,t){let{lineage:n,printPath:r,models:i,current:a}=t,o=e===`animate`?SP(i):void 0;if(e===`animate`&&o===void 0)return{kind:`refused`,message:`No video model on this Computer takes a first frame.`};let s=Vn(i,n.model),c=s?.transform!=null;if(c&&e===`reuse`)return{kind:`refused`,message:`This print was an image edit, so there is no prompt to reuse. Remix or animate it instead.`};let l=o??(c?void 0:s)??Vn(i,a.model);if(l===void 0)return{kind:`refused`,message:`Choose a model from the granted registry.`};let u=o===void 0&&s===void 0?`This print was made with ${n.model}, which is no longer available. Loaded it with ${Rn(l)} instead.`:null,d=c?[]:n.references.slice(0,n.typed.references),f=e===`animate`?{path:r,role:`first-frame`}:{path:r},p=[f,...d.filter(e=>!Vi(e,t.printComputerId)||e.path!==r)];if(e!==`reuse`&&l.input.maxReferences===0)return{kind:`refused`,message:`${l.label} does not take reference images.`};let m=e===`reuse`?d:e===`remix`?p:[f],h=Fr(a,l),g={width:n.width??h.width,height:n.height??h.height},_=o===void 0?Un(g,l,void 0):CP(l,g.width,g.height)??h,v=o===void 0&&l.input.steps!==`fixed`&&n.steps!==null&&l.id===n.model?n.steps:h.steps,y=n.style!==null&&t.styles.includes(n.style)?n.style:void 0;return{kind:`draft`,notice:u,draft:{...h,destination:void 0,prompt:Tr(c?``:n.typed.prompt,e=>{let t=d.at(e-1),n=t===void 0?-1:m.findIndex(e=>e.path===t.path&&e.computerId===t.computerId);return n<0?void 0:n+1}),references:m,steps:v,style:y,width:_.width,height:_.height}}}function TP({id:e,styles:t,selected:n,disabled:r,onSelect:i}){let a=n===void 0||t.some(e=>e.name===n);return(0,J.jsxs)(My,{id:e,"aria-label":`Prompt style`,"data-generation-style":!0,className:`select-sm`,disabled:r,onChange:e=>{i(e.currentTarget.value||void 0)},value:n??``,children:[(0,J.jsx)(`option`,{value:``,children:`No style`}),a?null:(0,J.jsx)(`option`,{value:n,children:n}),t.map(e=>(0,J.jsx)(`option`,{value:e.name,children:e.name},e.id))]})}function EP({styles:e,selected:t,open:n,onOpenChange:r,busy:i,error:a,onSelect:o,onSave:s,onDelete:c}){let[l,u]=(0,q.useState)(null);return(0,J.jsx)(cm,{open:n,onOpenChange:r,children:(0,J.jsxs)(pm,{children:[(0,J.jsx)(hm,{children:(0,J.jsx)(gm,{children:`Styles`})}),(0,J.jsx)(`ul`,{className:`space-y-1`,"aria-label":`Saved styles`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center justify-between gap-sm`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,J.jsxs)(`span`,{className:`flex gap-xs`,children:[(0,J.jsx)(U,{size:`xs`,variant:t===e.name?`primary`:`ghost`,type:`button`,"aria-pressed":t===e.name,onClick:()=>{o(e.name),r(!1)},children:`Use`}),e.builtIn?null:(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u(e)},children:`Edit`}),(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u({name:`${e.name} copy`.slice(0,64),text:e.text})},children:`Duplicate`}),e.builtIn?null:(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,disabled:i,onClick:()=>{c(e,()=>{t===e.name&&o(void 0),l?.id===e.id&&u(null)})},children:`Delete`})]})]},e.id))}),l===null?(0,J.jsx)(U,{size:`xs`,type:`button`,onClick:()=>{u({name:``,text:``})},children:`New style`}):(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(py,{"aria-label":`Style name`,maxLength:64,value:l.name,onChange:e=>{u({...l,name:e.currentTarget.value})}}),(0,J.jsx)(Gi,{"aria-label":`Style text`,maxLength:8e3,rows:6,value:l.text,onChange:e=>{u({...l,text:e.currentTarget.value})}}),(0,J.jsxs)(`div`,{className:`flex gap-xs`,children:[(0,J.jsx)(U,{size:`xs`,variant:`primary`,type:`button`,disabled:i||l.name.trim()===``||l.text.trim()===``,onClick:()=>{let n=e.find(e=>e.id===l.id);s({id:l.id,name:l.name.trim(),text:l.text},e=>{n&&t===n.name&&e&&o(e.name),u(null)})},children:`Save style`}),(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u(null)},children:`Cancel`})]})]}),a?(0,J.jsx)(`p`,{role:`alert`,className:`text-xs`,children:a}):null,(0,J.jsx)(mm,{children:(0,J.jsx)(_m,{render:(0,J.jsx)(U,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var DP=(0,q.lazy)(async()=>({default:(await Rr(()=>import(`./print-info-drawer-QvgjDcHc.js`),__vite__mapDeps([5,1,2,3,6]),import.meta.url)).PrintInfoDrawer})),OP=[`a mushroom knight`,`moss on a keyboard`,`a tiny house made of mushrooms`];function kP(e){Wt.error(e,{id:`prints-generation-error`,toasterId:`prints-generation-notices`})}function AP(e){let t=(0,q.useRef)(!1),n=fy({defaultValues:ri(),onSubmit:async({value:n})=>{t.current=await e.current(n)}}),r=(0,q.useCallback)(async()=>(t.current=!1,await n.handleSubmit(),t.current),[n]);return Object.assign(n,{submitCurrent:r})}function jP(e){let t=[...new Set(e.map(e=>e.group))];return t.length<2?[{group:void 0,choices:e}]:t.map(t=>({group:t,choices:e.filter(e=>e.group===t)}))}function MP({form:e,selected:t,stylePicker:n,sizeChoices:r,sizeMode:i,onCustomSize:a,match:o,onEditStyles:s,onEditCharacters:c}){let l=t?.input.dimensions===`none`,u=t!==void 0&&t.sizes!==null,d=t?.video??null;return(0,J.jsxs)(`div`,{className:`prints-settings`,children:[(0,J.jsx)(Ey,{label:`Style`,orientation:`horizontal`,children:n}),(0,J.jsx)(Ey,{label:`Size`,orientation:`horizontal`,children:(0,J.jsx)(My,{"aria-label":`Generation size`,"data-generation-size":!0,className:`select-sm`,disabled:l,title:l?`This model chooses the output size.`:void 0,onChange:t=>{let n=t.currentTarget.value;o.onChange(n===`match`),a(n===`custom`);let i=r.find(e=>e.value===n);i&&(e.setFieldValue(`width`,i.width),e.setFieldValue(`height`,i.height))},value:l?`provider`:i,children:l?(0,J.jsx)(`option`,{value:`provider`,children:`Model default`}):(0,J.jsxs)(J.Fragment,{children:[o.offered?(0,J.jsx)(`option`,{value:`match`,disabled:o.size===void 0,children:o.size===void 0?`Match first reference: attach an image first`:`Match first reference · ${Yn(o.size.width,o.size.height)}`}):null,u&&i!==`match`&&!r.some(e=>e.value===i)?(0,J.jsx)(`option`,{value:i,disabled:!0,children:`Choose a supported resolution`}):null,jP(r).map(({group:e,choices:t})=>e===void 0?t.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value)):(0,J.jsx)(`optgroup`,{label:e,children:t.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value))},e)),u?null:(0,J.jsx)(`option`,{value:`custom`,children:`Custom size`})]})})}),!l&&!u&&i===`custom`?(0,J.jsxs)(`div`,{className:`prints-custom-size`,children:[(0,J.jsx)(e.Field,{name:`width`,children:e=>(0,J.jsx)(Ey,{label:`Width`,children:(0,J.jsx)(py,{"aria-label":`Generation width`,"data-generation-width":!0,max:4096,min:1,onChange:t=>{e.handleChange(Number(t.currentTarget.value)||1)},type:`number`,value:e.state.value})})}),(0,J.jsx)(e.Field,{name:`height`,children:e=>(0,J.jsx)(Ey,{label:`Height`,children:(0,J.jsx)(py,{"aria-label":`Generation height`,"data-generation-height":!0,max:4096,min:1,onChange:t=>{e.handleChange(Number(t.currentTarget.value)||1)},type:`number`,value:e.state.value})})})]}):null,d?(0,J.jsx)(e.Field,{name:`durationSeconds`,children:e=>(0,J.jsx)(Ey,{label:`Length`,orientation:`horizontal`,children:(0,J.jsx)(My,{"aria-label":`Video length in seconds`,className:`select-sm`,"data-generation-duration":!0,onChange:t=>{let n=t.currentTarget.value;e.handleChange(d.durations.find(e=>String(e)===n))},value:e.state.value===void 0?``:String(e.state.value),children:d.durations.map(e=>(0,J.jsxs)(`option`,{value:String(e),children:[e,` seconds`]},e))})})}):null,d?.supportsAudio?(0,J.jsx)(e.Field,{name:`generateAudio`,children:e=>d.defaultGenerateAudio===null?(0,J.jsx)(Ey,{label:`Sound`,orientation:`horizontal`,children:(0,J.jsxs)(My,{"aria-label":`Video sound`,className:`select-sm`,"data-generation-audio":!0,onChange:t=>{let n=t.currentTarget.value;e.handleChange(n===``?void 0:n===`on`)},value:e.state.value===void 0?``:e.state.value?`on`:`off`,children:[(0,J.jsx)(`option`,{value:``,children:`Model default`}),(0,J.jsx)(`option`,{value:`on`,children:`On`}),(0,J.jsx)(`option`,{value:`off`,children:`Off`})]})}):(0,J.jsx)(Ey,{label:`Sound`,orientation:`horizontal`,children:(0,J.jsx)(zn,{"aria-label":`Video sound`,checked:e.state.value??!0,"data-generation-audio":!0,onCheckedChange:e.handleChange})})}):null,t&&t.input.steps!==`fixed`?(0,J.jsx)(e.Field,{name:`steps`,children:e=>(0,J.jsx)(Ey,{label:`Steps`,optional:!0,orientation:`horizontal`,children:(0,J.jsx)(py,{"aria-label":`Generation steps`,className:`input-sm`,"data-generation-steps":!0,max:t.input.maxSteps??void 0,min:1,onChange:t=>{e.handleChange(t.currentTarget.value===``?void 0:Number(t.currentTarget.value))},type:`number`,value:e.state.value??``})})}):null,(0,J.jsxs)(`div`,{className:`prints-settings-library`,children:[(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{s()},children:`Edit styles…`}),(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{c()},children:`Characters…`})]})]})}function NP(e){return e.detail===void 0?e.title:e.group===`Images`?e.detail:`${e.title}. ${e.detail}`}function PP({actions:e,guidance:t,commandApp:n,form:r,models:i,modelsLoading:a,mediaCapability:o,submitting:s,generateLimitReason:c,values:l,computerId:u,mediaDirectory:d,referenceImages:f,referenceLabels:p,price:m,characters:h,characterDialog:g,onSubmit:_,styleControls:v,addedLength:y}){let b=Vn(i,l.model),x=!o||a||i.length===0,S=x&&t?.group===`Setup`&&t.blocking===!0?t:void 0,C=l.prompt.trim().length,w=b!==void 0&&C>0&&C+y>b.maxPromptLength,T=si(b),E=b?.video??null,D=Cr(l.prompt).length>0,O=rr(l.references,b,D),k=b?.input.maxReferences??0,A=l.references.length>k,j=(0,q.useRef)(null),M=(0,q.useId)(),N=eb(j),[P,F]=(0,q.useState)(!1),I=w?C+y:0,ee=b!==void 0&&w?Pi({addedLength:y,length:I,maxLength:b.maxPromptLength}):void 0,[te,ne]=(0,q.useState)(!1),[re,L]=(0,q.useState)(!1),R=l.references.find(e=>u!==null&&Vi(e,u)),ie=f.find(e=>e.path===R?.path),ae=ie===void 0?void 0:br(b,ie.width,ie.height),oe=r.setFieldValue,se=(0,q.useRef)({width:l.width,height:l.height});se.current={width:l.width,height:l.height},(0,q.useEffect)(()=>{if(re){if(ae===void 0){L(!1),Wt(`Size kept at ${String(se.current.width)} × ${String(se.current.height)}; Match first reference turned off`,{toasterId:`prints-generation-notices`});return}oe(`width`,ae.width),oe(`height`,ae.height)}},[re,ae?.width,ae?.height,oe]);let[ce,z]=(0,q.useState)(!1),le=b!==void 0&&b.sizes!==null,B=ur(b),ue=re?`match`:le?`${String(l.width)}x${String(l.height)}`:te?`custom`:B.find(e=>e.width===l.width&&e.height===l.height)?.value??`custom`,[de,fe]=(0,q.useState)(!1),V=bP({clear:()=>{r.setFieldValue(`prompt`,``)},useSize:e=>{ne(!1),L(!1),r.setFieldValue(`width`,wi[e].width),r.setFieldValue(`height`,wi[e].height),r.setFieldValue(`prompt`,``)},openStyles:()=>{r.setFieldValue(`prompt`,``),fe(!0)},clearStyle:()=>{r.setFieldValue(`style`,void 0),r.setFieldValue(`prompt`,``)}},n),[pe,me]=(0,q.useState)(!1),he=l.references.map((e,t)=>({number:p[t]??t+1,name:e.path.split(`/`).at(-1)??e.path,url:u!==null&&Vi(e,u)?f.find(t=>t.path===e.path)?.url:void 0})),ge=Xr(h,he,l.prompt),_e=di(l.prompt,h,he,f),ve=Gr(V.items,l.prompt),ye=(0,q.useId)(),be=`${ye}-commands`,xe=`${ye}-characters`,Se=er(l.prompt,h).characters,Ce=e=>{let t=ve.slashMatches.at(e);t&&(ve.resetSlash(),V.run(t.command))},we=v({open:de,onOpenChange:fe}),Te=[l.style,re?`Match · ${An(l.width,l.height)}`:ar(b,l.width,l.height),E&&l.durationSeconds!==void 0?`${String(l.durationSeconds)}s`:void 0,E?.supportsAudio&&l.generateAudio===!1?`silent`:void 0].filter(e=>e!=null),Ee=(0,J.jsx)(MP,{form:r,selected:b,stylePicker:we.picker,sizeChoices:B,sizeMode:ue,onCustomSize:ne,match:{offered:b?.kind===`image`&&b.input.dimensions===`own`,size:ae,onChange:L},onEditStyles:()=>{z(!1),fe(!0)},onEditCharacters:()=>{z(!1),me(!0)}}),De=e=>{let t=r.store.state.fieldMeta,n=Fr(l,e),i=Un(l,e,b);r.setFieldValue(`model`,e.id),(e.input.dimensions===`none`||e.sizes!==null)&&ne(!1),r.setFieldValue(`width`,i.width),r.setFieldValue(`height`,i.height),r.setFieldValue(`durationSeconds`,n.durationSeconds),r.setFieldValue(`voiceId`,n.voiceId),r.setFieldValue(`generateAudio`,n.generateAudio),e.kind===`audio`&&r.setFieldValue(`references`,[]),(e.input.steps===`fixed`||!t.steps?.isTouched)&&r.setFieldValue(`steps`,n.steps)},Oe=b?.kind===`audio`,ke=Oe?0:l.references.length,Ae=Xg(hi(i)),je=(0,q.useRef)(null);b!==void 0&&b.kind!==`audio`&&(je.current=b.id);let Me=()=>{let e=Oe?Vn(i,je.current??``)??Vn(i,`@cf/black-forest-labs/flux-2-klein-4b`)??ui(i).at(0):Vn(i,Ae.at(0)?.id??``);e&&De(e)},Ne=b===void 0?null:Zg(b),Pe=Ne===null?[]:$g(Ae,Ne),Fe=b?.audio==null||Ne===null?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(e_,{disabled:s,modes:Qg(Ae),value:Ne,onChange:e=>{let t=Vn(i,$g(Ae,e).at(0)?.id??``);t&&De(t)}}),Pe.length>1?(0,J.jsx)(n_,{disabled:s,models:Pe,value:b.id,onChange:e=>{let t=Vn(i,e);t&&De(t)}}):null,b.audio.mode===`speech`?(0,J.jsx)(r_,{disabled:s,voices:b.audio.voices,value:l.voiceId??b.audio.defaultVoiceId??``,onChange:e=>{r.setFieldValue(`voiceId`,e)}}):null,b.audio.seconds===null?null:(0,J.jsx)(o_,{disabled:s,seconds:b.audio.seconds,value:l.durationSeconds??b.audio.seconds.default,onChange:e=>{r.setFieldValue(`durationSeconds`,e)}})]});return(0,J.jsxs)(ti,{"aria-label":Oe?`Audio generation`:`Image generation`,"data-generation-form":!0,"data-composer-collapsed":N.collapsed?``:void 0,"data-composer-fullscreen":N.fullscreen?``:void 0,attachments:!Oe&&l.references.length>0?(0,J.jsx)(`div`,{className:`prints-reference-tray`,"aria-label":`Image references`,"data-over-limit":A?``:void 0,title:`${String(l.references.length)} / ${String(k)} references`,children:l.references.map((e,t)=>{let n=u!==null&&Vi(e,u)?f.find(t=>t.path===e.path):void 0,i=O[t]?.role,a=cr(T,O,t);return(0,J.jsxs)(`div`,{className:`prints-reference-tile`,"data-reference-chip":!0,title:e.computerId===void 0?e.path:`${e.computerId}:${e.path}`,children:[(0,J.jsx)(`div`,{className:`prints-reference-face mask mask-squircle`,children:n?(0,J.jsx)(`img`,{src:n.url,alt:e.path.split(`/`).at(-1)}):(0,J.jsx)(`span`,{children:Kn(p[t]??t+1)})}),(0,J.jsx)(`span`,{className:`prints-reference-label`,"data-reference-label":!0,children:Kn(p[t]??t+1)}),i===void 0?null:a===void 0?(0,J.jsx)(`span`,{className:`prints-reference-role`,"data-reference-role":i,children:qr[i]}):(0,J.jsx)(U,{size:`xs`,variant:`ghost`,type:`button`,className:`prints-reference-role`,"data-reference-role":i,"aria-label":`Reference ${String(t+1)}: ${qr[i]}. Use as ${qr[a]}`,title:`Use as ${qr[a]}`,onClick:()=>{r.setFieldValue(`references`,O.map((e,n)=>n===t?{...e,role:a}:e))},children:qr[i]}),(0,J.jsx)(pt,{icon:(0,J.jsx)(Ei,{}),className:`prints-reference-remove`,"aria-label":`Remove reference ${String(t+1)}`,onClick:()=>{r.setFieldValue(`references`,l.references.filter((e,n)=>n!==t))}})]},JSON.stringify([e.computerId??u,e.path]))})}):void 0,input:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`form`,{"aria-busy":s,onSubmit:e=>{e.preventDefault(),_()},children:(0,J.jsx)(r.Field,{name:`prompt`,children:e=>(0,J.jsxs)(`div`,{className:`prints-prompt`,"data-guidance-placeholder":S?``:void 0,id:M,ref:j,children:[ve.slashOpen?(0,J.jsx)(Hr,{index:ve.slashIndex,listId:be,matches:ve.slashMatches,onHighlight:ve.highlightSlash,onPick:Ce}):null,!ve.slashOpen&&ge.matches.length>0?(0,J.jsx)(yi,{images:f,index:ge.index,listId:xe,matches:ge.matches,onHighlight:ge.highlight,onPick:t=>{let n=ge.complete(t);n!==null&&e.handleChange(n)}}):null,(0,J.jsx)(Ir,{caretRequest:ge.caretRequest,layout:N,onOver:kP,onOverflow:F,menu:ve.slashOpen?{open:ve.slashMatches.length>0,listId:be,selected:ve.slashIndex}:{open:ge.matches.length>0,listId:xe,selected:ge.index},mentionCount:ve.slashOpen?0:ge.matches.length,onCaret:ge.setCaret,onMentionDismiss:ge.dismiss,onMentionMove:ge.move,onMentionPick:()=>{let t=ge.complete(ge.index);t!==null&&e.handleChange(t)},disabled:x||s,maxLength:b?.maxPromptLength,addedLength:y,onChange:t=>{e.handleChange(t)},onSend:_,onSlashMove:ve.moveSlash,onSlashPick:()=>{Ce(ve.slashIndex)},placeholder:S?NP(S):b?.audio?.mode===`speech`?`What should it say?`:b?.audio?.mode===`music`?`Describe the music`:`What are we making?`,slashCount:ve.slashMatches.length,value:e.state.value}),Se.length>0||_e.length>0?(0,J.jsxs)(`div`,{className:`prints-composer-notes`,children:[(0,J.jsx)(Oi,{tokens:_e}),Se.length>0?(0,J.jsx)(`span`,{className:`prints-reference-count`,"data-generation-characters":!0,children:`Characters: ${Se.map(e=>e.name).join(`, `)}`}):null]}):null]})})}),t&&!S?(0,J.jsxs)(`div`,{className:`prints-composer-guidance`,role:`status`,"data-composer-guidance":!0,children:[(0,J.jsx)(`span`,{children:NP(t)}),t.actions?.map(e=>(0,J.jsx)(U,{variant:`ghost`,size:`xs`,onClick:e.run,children:e.label},e.label))]}):null]}),row:{controls:(0,J.jsxs)(J.Fragment,{children:[N.fullscreen?null:(0,J.jsx)(_t,{"aria-controls":M,"aria-expanded":!N.collapsed,"aria-label":N.collapsed?`Expand composer`:`Collapse composer`,"data-composer-collapse":!0,icon:N.collapsed?(0,J.jsx)(Di,{}):(0,J.jsx)(ai,{}),label:null,onClick:()=>{N.setCollapsed(!N.collapsed)},onMouseDown:e=>{e.preventDefault()},title:N.collapsed?`Expand composer`:`Collapse composer`}),N.collapsed&&ke>0?(0,J.jsxs)(`span`,{"aria-label":`${String(ke)} ${ke===1?`reference`:`references`} attached`,className:`prints-composer-count`,"data-composer-count":!0,role:`img`,title:`${String(ke)} ${ke===1?`reference`:`references`} attached`,children:[(0,J.jsx)(Dh,{"aria-hidden":`true`}),ke]}):null,N.coarse&&P&&!N.collapsed?(0,J.jsx)(_t,{"aria-label":`Open full-screen editor`,"data-composer-expand":!0,icon:(0,J.jsx)(Or,{}),label:null,onClick:()=>{N.setFullscreen(!0),j.current?.querySelector(`textarea`)?.focus()},title:`Open full-screen editor`}):null,S?S.actions?.map(e=>(0,J.jsx)(U,{variant:`ghost`,size:`xs`,onClick:e.run,children:e.label},e.label)):null,Oe?null:e,Ae.length>0?(0,J.jsx)(_t,{"aria-label":`Audio`,"data-generation-audio-key":!0,icon:(0,J.jsx)(yh,{}),label:null,pressed:Oe,tone:Oe?`accent`:`neutral`,title:Oe?`Back to pictures`:`Make audio`,disabled:a||!o,onClick:Me}):null,Oe?Fe:(0,J.jsx)(r.Field,{name:`model`,children:e=>(0,J.jsx)(jA,{compact:N.coarse,models:ui(i),emptyLabel:u===null?`Choose a Computer`:a?`Loading models…`:`Models unavailable`,disabled:a||!o,onChange:e=>{let t=Vn(i,e);t&&De(t)},value:e.state.value})}),u&&d?(0,J.jsx)(`span`,{className:`sr-only`,"data-generation-computer":!0,title:`Where new prints are saved`,children:`Saved in your Prints folder`}):null]}),action:(0,J.jsxs)(`span`,{className:`prints-generate-action`,children:[m===null?null:(0,J.jsx)(`span`,{className:`prints-generate-price`,"data-generation-price":!0,title:`Estimated price`,children:m.startsWith(`<`)?m:`≈ ${m}`}),(0,J.jsx)(ii,{busy:s,draft:l.prompt,disabled:!o||a||i.length===0||s||c!==void 0,disabledReason:c??ee,label:qi(b),onGenerate:()=>{_()},promptOver:w})]}),items:Oe?[]:[{id:`settings`,accessibleLabel:`Generation settings`,title:`Settings`,label:(0,J.jsxs)(`span`,{className:`prints-settings-chip`,children:[(0,J.jsx)(Ih,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),(0,J.jsx)(`span`,{className:`prints-settings-chip-text`,children:Te.length>0?Te.join(` · `):`Settings`})]}),content:Ee}],openId:ce?`settings`:null,onOpenChange:e=>{z(e===`settings`)}},children:[(0,J.jsx)(tb,{layout:N}),(0,J.jsxs)(`div`,{className:`prints-composer-editor-bar`,"data-composer-editor-bar":!0,children:[(0,J.jsx)(`span`,{children:`Prompt`}),(0,J.jsx)(_t,{"data-composer-done":!0,label:`Done`,onClick:()=>{N.setFullscreen(!1),j.current?.querySelector(`textarea`)?.focus()}})]}),we.dialog,g({open:pe,onOpenChange:me})]})}function FP({connection:e}){let t=(0,q.useRef)(null),n=(0,q.useRef)(e);n.current=e;let r=NA(e?.app??null),i=Rf(e?.app??null)?.setup?.media===`missing`,[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),l=()=>{let t=e?.app;t&&(o(!0),c(!1),t.ui.openSetup(`media`).then(e=>{o(!1),c(e===`unavailable`)},e=>{o(!1),c(!0),tn(`open-media-setup`,e)}))},u=s?(0,J.jsxs)(J.Fragment,{children:[`Image setup couldn’t open.`,` `,(0,J.jsx)(`a`,{href:`https://github.com/fungi-computer/oyster#deploy-to-cloudflare`,target:`_blank`,rel:`noreferrer`,children:`Open the image setup guide`}),`.`]}):`Image generation isn’t set up yet.`,[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(),h=WM(e?.app??null,r.computerId),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(),S=(0,q.useRef)(0);(0,q.useEffect)(()=>{_(null),y(null),x(void 0)},[e,r.computerId,r.path]);let C=r.path,w=Vg(e,r),{gallery:T,images:E,failed:D,loading:O,gallerySlots:k,canBrowse:A,canRead:j,canWrite:M,reserveSlot:N,failSlot:P,clearSlotError:F,removeSlot:I,addComputerFile:ee,retryFile:te,uploads:ne,uploadFiles:re}=w,L=e!==null&&r.destination!==null&&A&&j,R=yA({app:e?.app??null,destination:r.destination,view:r.view,setView:r.setView,entries:T.entries,canWrite:M}),[ie,ae]=(0,q.useState)(!1),oe=R.selecting||T.entries.length>0||w.gallery.folders.length>0,se=mg({selectable:oe,atFolderRoot:r.view.kind===`folder`&&!R.up,loading:O||T.loading,failed:!!T.error});Hf(L?e.app.window.navigation:null,{canGoBack:R.history.canGoBack,canGoForward:R.history.canGoForward,crumbs:R.crumbs,primary:oe?[{id:`select`,label:`Select`,variant:`outline`}]:[],onAction:e=>{e===`select`&&R.setSelecting(!R.selecting)},onBack:R.history.back,onForward:R.history.forward,onCrumb:e=>{R.history.open(e===`all`||e===`favorites`?{kind:e}:{kind:`folder`,folder:e===``?void 0:e})}});let[ce,z]=(0,q.useState)(Date.now),le=k.some(e=>e.startedAt!==void 0&&!e.resolved&&!e.error);(0,q.useEffect)(()=>{if(!le)return;let e=setInterval(()=>{z(Date.now())},1e3);return()=>{clearInterval(e)}},[le]);let B=zp(e,(e,t,n)=>(T.refresh(),ee(e,t,n)));(0,q.useLayoutEffect)(()=>{x(void 0),B.target&&(_(null),y(null))},[B.target]),(0,q.useEffect)(()=>{B.error&&xi(`Could not open this print. It may no longer be available on this Computer.`,`prints-navigation-error`)},[B.error]);let ue=T.entries.some(e=>e.path===B.target?.path);(0,q.useEffect)(()=>{B.target&&!ue&&T.nextPageReady&&T.loadMore()},[B.target,ue,T.nextPageReady,T.loadMore]);let de=E.find(e=>e.source.kind===`computer`&&e.source.computerId===B.target?.computerId&&e.source.path===B.target.path),fe=xP(e?.app??null),V=sP(e?.app??null),[pe,me]=(0,q.useState)(new Set),he=F_({connection:e,folder:r,styles:fe.styles,characters:V.characters,effects:{reserve:e=>{me(t=>{if(!t.has(e.key))return t;let n=new Set(t);return n.delete(e.key),n}),N(e)},failed:P,release:I,notifyFailure:kP,saved:({result:e},t)=>{me(t=>new Set(t).add(`${e.destination.computerId}:${e.destination.path}`)),j?ee(e.destination.path,t,e.destination.computerId):P(`${e.destination.computerId}:${e.destination.path}`,`Image saved, but this App cannot read its preview.`)}}}),{state:ge,models:_e,modelsLoading:ve,modelsError:ye,canGenerate:be,mediaCapability:xe,pendingGenerations:Se,activeGenerations:Ce,recoveryError:we}=he,Te=(0,q.useRef)(_e),Ee=(0,q.useRef)(he);Ee.current=he;let De=(0,q.useRef)(null),Oe=(0,q.useRef)(null),ke=(0,q.useRef)(0),[Ae,je]=(0,q.useState)(null),Me=(0,q.useRef)([]),Ne=(0,q.useRef)(e=>he.submit(e,Me.current));Ne.current=async e=>{let t=await he.submit(e,Me.current);return t&&je(null),t};let Pe=AP(Ne),Fe=e=>{Pe.setFieldValue(`model`,e.model),Pe.setFieldValue(`width`,e.width),Pe.setFieldValue(`height`,e.height),Pe.setFieldValue(`steps`,e.steps),Pe.setFieldValue(`durationSeconds`,e.durationSeconds),Pe.setFieldValue(`generateAudio`,e.generateAudio),Pe.setFieldValue(`prompt`,e.prompt),Pe.setFieldValue(`references`,e.references),Pe.setFieldValue(`style`,e.style),Pe.setFieldValue(`destination`,void 0)},Ie=(0,q.useRef)(Pe);Ie.current=Pe;let Le=ny(Pe.store,e=>e.values),Re=Si(Le.references,Le.prompt,r.computerId);Me.current=Re;let ze=gi(he.session,ji({draft:Le,model:Vn(he.models,Le.model),styleText:fe.styles.find(e=>e.name===Le.style)?.text,characters:V.characters,labels:Re,computerId:r.computerId})),Be=ny(Pe.store,e=>e.isSubmitting),Ve=e?.app;(0,q.useEffect)(()=>{if(Ve)return vP(Ve,{readDraft:()=>Ie.current.store.state.values,readModels:()=>Te.current,setDraft:e=>{let t=Ie.current;if(e.model!==void 0){let n=Vn(Te.current,e.model);if(!n)throw Error(`Choose a model from the granted registry.`);let r=Fr(t.store.state.values,n),i=Vn(Te.current,t.store.state.values.model),a=Un(t.store.state.values,n,i);t.setFieldValue(`model`,r.model),t.setFieldValue(`width`,a.width),t.setFieldValue(`height`,a.height),t.setFieldValue(`steps`,r.steps),t.setFieldValue(`durationSeconds`,r.durationSeconds),t.setFieldValue(`generateAudio`,r.generateAudio)}e.generateAudio!==void 0&&t.setFieldValue(`generateAudio`,e.generateAudio??void 0),e.destination!==void 0&&t.setFieldValue(`destination`,e.destination??void 0),e.height!==void 0&&t.setFieldValue(`height`,e.height),e.prompt!==void 0&&t.setFieldValue(`prompt`,e.prompt),e.references!==void 0&&t.setFieldValue(`references`,e.references),e.steps!==void 0&&t.setFieldValue(`steps`,e.steps??void 0),e.style!==void 0&&t.setFieldValue(`style`,e.style??void 0),e.width!==void 0&&t.setFieldValue(`width`,e.width)},submit:()=>Ie.current.store.state.isSubmitting||Ee.current.atLimit?Promise.resolve(!1):Ie.current.submitCurrent()})},[Ve]),(0,q.useEffect)(()=>{Te.current=_e},[_e]),(0,q.useEffect)(()=>{if(_e.length===0||ye)return;let e=_e.find(e=>e.id===`@cf/black-forest-labs/flux-2-klein-4b`)??ui(_e).at(0)??_e[0];if(!Pe.store.state.fieldMeta.model?.isTouched){let t=Fr(Pe.store.state.values,e);Pe.setFieldValue(`model`,t.model),Pe.store.state.fieldMeta.width?.isTouched||Pe.setFieldValue(`width`,t.width),Pe.store.state.fieldMeta.height?.isTouched||Pe.setFieldValue(`height`,t.height),Pe.store.state.fieldMeta.steps?.isTouched||Pe.setFieldValue(`steps`,t.steps)}},[Pe,ye,_e]);let He=Vn(_e,Le.model),Ue=Le.references,H=He?.input.maxReferences??0,We=(0,q.useRef)({addComputerFile:ee,retryPath:he.retryPath,uploads:ne});We.current={addComputerFile:ee,retryPath:he.retryPath,uploads:ne};let Ge=de?Rg(de):null,Ke=(0,q.useMemo)(()=>E.map(e=>({key:Rg(e),selected:Rg(e)===Ge,path:e.source.kind===`computer`?e.source.path:e.file.name,referenced:Ue.some(t=>e.source.kind===`computer`&&Vi(t,e.source.computerId)&&t.path===e.source.path),referenceDisabled:Ue.length>=H&&!Ue.some(t=>e.source.kind===`computer`&&Vi(t,e.source.computerId)&&t.path===e.source.path),onToggleReference:e.source.kind===`computer`&&H>0&&!an(e.source.path)?()=>{if(e.source.kind!==`computer`)return;let t=e.source.path,n=e.source.computerId,r=Ue.some(e=>Vi(e,n)&&e.path===t);Pe.setFieldValue(`references`,r?Ue.filter(e=>!Vi(e,n)||e.path!==t):[...Ue,{path:t}])}:void 0,onInfo:()=>{_(e)},url:e.url,width:e.width,height:e.height,onOpen:()=>{_(null),y(Rg(e))}})),[E,Ue,H,Pe,Ge]),qe=(0,q.useMemo)(()=>{let e=r.computerId;if(!e)return Ke;let t=new Map(Ke.map(e=>[e.key,e])),n=[...T.entries].sort((e,t)=>t.modifiedAt-e.modifiedAt||e.name.localeCompare(t.name)).map(n=>{let r=`${e}:${n.path}`;return{...t.get(r)??{key:r,path:n.path,width:1,height:1,url:``,pending:!0,pendingLabel:`Loading print…`,onOpen:()=>void 0,onVisible:()=>{T.loadFile(n.path)},error:D.includes(n.name)?`Could not load this print.`:void 0},onRetry:()=>{te(n.path)}}}),i=new Set(n.map(e=>e.key));return[...n,...Ke.filter(e=>!i.has(e.key)&&e.key!==Ge)]},[Ke,T.entries,T.loadFile,te,D,r.computerId,Ge]),Je=L&&!(r.view.kind===`folder`&&!R.up)?r.view.kind===`all`?{title:`No prints yet`,description:`Prints in any folder of the library appear here.`}:r.view.kind===`favorites`?{title:`No favorites yet`,description:`Tap the heart on a print to keep it here for your whole Team.`}:{title:`Nothing in ${R.title} yet`,description:`New prints you make here land in it. You can also drop in images or move prints from another folder.`}:null,Ye=[...Ce].sort().join(`|`),Xe=k.filter(e=>e.error!==void 0).length,Ze=(0,q.useMemo)(()=>Se.filter(e=>e.reference.computerId===r.computerId&&!Ye.split(`|`).includes(e.reference.requestId)&&!k.some(t=>t.computerId===e.reference.computerId&&t.path===e.input.destination.path)).map(e=>({key:`${e.reference.computerId}:${e.input.destination.path}`,path:e.input.destination.path,width:1024,height:1280,url:``,pending:!0,error:e.failure?.message??`Stopped when Prints closed. Retry to run it again.`,prompt:e.typed.prompt,onOpen:()=>void 0,onRetry:()=>{Ee.current.resume(e)},onDismiss:()=>{Ee.current.discard(e)}})),[Se,r.computerId,Ye,k]),Qe=(0,q.useMemo)(()=>[...Ze,...oP(qe,k,e=>{let t=ne.items.find(t=>t.id===e.uploadId),r=e.error??(t?.status===`error`||t?.status===`cancelled`?t.message:void 0);return{key:e.key,path:e.path,width:e.width,height:r===void 0?e.height:Math.max(e.height,e.width*1.25),url:``,pending:!0,error:r,prompt:Se.find(t=>t.reference.computerId===e.computerId&&t.input.destination.path===e.path)?.typed.prompt??he.promptAt(e.path),pendingLabel:t?.status===`complete`||pe.has(e.key)?`Loading preview…`:e.uploadId?`Uploading image…`:e.startedAt===void 0?e.pendingLabel:Fn(_e.find(e=>e.kind===`video`),ce-e.startedAt,e.resumed),onOpen:()=>void 0,onStop:r===void 0&&e.uploadId===void 0?()=>{Ee.current.stopPath(e.path)}:void 0,onRetry:r&&(j||t&&t.status!==`complete`)?()=>{if(F(e.key),t&&t.status!==`complete`){We.current.uploads.retry(t.id);return}!e.uploadId&&We.current.retryPath(e.path)||n.current&&We.current.addComputerFile(e.path,n.current,e.computerId)}:void 0,onDismiss:r?()=>{I(e.key),e.uploadId&&We.current.uploads.remove(e.uploadId)}:void 0}})],[Ze,Se,Xe,he.promptAt,pe,qe,k,ne.items,j,_e,ce]),$e=!i&&xe&&be&&M&&C!==null&&ge.kind===`ready`&&!ve&&_e.length>0,et=ne.items.filter(e=>e.computerId===r.computerId),tt=()=>{e&&e.app.ui.openTeamBilling().catch(t=>{tn(`open-team-billing`,t),n.current===e&&he.reportRecoveryError(t)})},nt=[...ge.kind===`error`&&ye===null?[{key:`generation:draft`,mediaKind:ge.mediaKind,message:ge.message,billing:ge.action===`billing`?tt:void 0}]:[],...he.failures.map(e=>({key:e.key,mediaKind:e.mediaKind,message:e.message,billing:e.action===`billing`?tt:void 0,prompt:e.prompt,retry:e.retry,dismiss:()=>{for(let t of k)t.path===e.path&&I(t.key);e.dismiss()}}))],rt=UM({connected:e!==null,mediaCapability:xe,modelsError:ye,retryModels:he.retryModels,modelsLoading:ve,models:_e,canGenerate:be,mediaSetupMissing:i,canWrite:M,generationErrors:nt,recoveryError:we,pendingGenerations:Se,activeGenerations:Ce,atGenerationLimit:he.atLimit,gallerySlots:k,computerId:r.computerId,failed:D,uploadError:ne.error,uploads:et,permissions:()=>{e?.app.ui.requestAppPermissions({}).catch(e=>{he.reportRecoveryError(e)})},resume:e=>{he.resume(e)},discard:e=>{he.discard(e)},retryUpload:e=>{ne.retry(e)}});h.error&&rt.push({key:`dismissal-storage`,group:`Setup`,tone:`warning`,blocking:!0,short:`Activity not saved`,title:`Activity not saved`,detail:h.error});let it=h.visible(rt),at={generating:Ce.size,uploading:et.filter(e=>e.status===`sending`||e.status===`queued`).length},ot={items:et.filter(e=>e.status===`sending`||e.status===`queued`).map(e=>({id:e.id,name:e.file.name,preview:{kind:`image`,url:e.previewUrl},progress:null,progressLabel:``,statusLabel:e.message,actions:{cancel:{label:`Cancel`,accessibleLabel:`Cancel ${e.file.name}`}}})),onCancel:e=>{ne.cancel(e)},onRetry:e=>{ne.retry(e)},onRemove:e=>{ne.remove(e)}},st=new Set([...T.entries.map(e=>`${r.computerId??``}:${e.path}`),...E.map(e=>e.source.kind===`computer`?`${e.source.computerId}:${e.source.path}`:e.file.name)]).size,ct=FM(it,at,d);Bf(e?.app,[...r.available?[bA(r.landingPath??r.path,{checking:r.busy&&r.path===null,editing:r.editing})]:[],...ct===null?[]:[ct],...A?[{kind:`text`,id:`prints`,text:`${String(st)} ${st===1?`print`:`prints`}`}]:[]],e=>e.itemId===`activity`?(m(e.anchor?.start),f(e=>!e),!0):e.itemId!==`folder`||!r.available?!1:(r.setEditing(!0),!0),t=>{tn(`prints.status.report`,t),e?.app.ui.showToast({message:`Prints couldn't update its status bar.`,tone:`error`}).catch(e=>{tn(`prints.status.toast`,e)})});let W=E.flatMap(e=>e.source.kind===`computer`?[{path:e.source.path,url:e.url,width:e.width,height:e.height}]:[]),lt=e=>{y(null),S.current+=1,x({key:e,requestId:`viewer-close-${String(S.current)}`,onFocus:()=>void 0})},ut=(t,n,i)=>(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(DP,{image:t,app:e?.app??null,referenceImages:W,models:_e,canAnimate:SP(_e)!==void 0,operations:{session:he.session,atLimit:he.atLimit,onRun:async(e,n)=>{if(t.source.kind!==`computer`)return;let r=await he.operate({computerId:t.source.computerId,path:t.source.path,width:t.width,height:t.height},e,n);if(r!==null){kP(r);return}_(null),v!==null&<(Rg(t))}},download:i,library:L&&t.source.kind===`computer`&&r.destination!==null&&t.source.path.startsWith(`${r.destination}/`)?(()=>{let e=t.source.path,n=R.isFavorite(e);return{favorite:n,onToggleFavorite:()=>{R.toggleFavorite([e],!n)},onMove:M?()=>{R.setMoving([e])}:void 0}})():void 0,onIterate:(e,n)=>{if(t.source.kind!==`computer`)return null;let r=wP(e,{lineage:n,printComputerId:t.source.computerId,printPath:t.source.path,models:_e,styles:fe.styles.map(e=>e.name),current:Pe.store.state.values});return r.kind===`refused`?r.message:(Fe(r.draft),je(r.notice===null?null:{model:r.draft.model,message:r.notice}),_(null),v!==null&<(Rg(t)),null)},onClose:n},t.url)}),dt={label:`Upload images`,onSelect:()=>Oe.current?.click(),disabled:!M||C===null,disabledReason:`Choose a writable Computer and folder to upload images.`},G=!i&&Je===null&&r.computerId!==null&&r.available&&C===null,ft={label:`Choose folder`,onSelect:()=>{r.setEditing(!0)}},pt=(0,J.jsx)(U,{variant:`ghost`,loading:a,onClick:l,children:`Set up image generation`});return(0,J.jsxs)(`main`,{ref:t,className:`h-full w-full flex flex-col overflow-hidden`,"data-app-pane":`media`,"data-generation-state":ge.kind,"data-computer-capability":A?`connected`:`absent`,onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&M&&(e.preventDefault(),re(t.map(e=>(ke.current+=1,new File([e],`paste-${String(ke.current)}-${Pg(e.name)}`,{type:e.type,lastModified:e.lastModified})))))},children:[(0,J.jsx)(ag,{id:`prints-generation-notices`}),(0,J.jsxs)(`div`,{className:`prints-library`,"data-library":L||void 0,children:[L&&r.destination?(0,J.jsx)(cA,{app:e.app,root:r.destination,view:r.view,onView:R.history.open,canWrite:M,version:R.version,onNewFolder:e=>{R.setNewFolder({parent:e})},onDrop:(e,t)=>{R.move(e,t)},onRename:(e,t)=>{R.move([e],R.folderOf(r.destination??``,e),{name:t})},onMoveRows:R.setMoving}):null,(0,J.jsxs)(`div`,{className:`prints-library-main`,"data-selecting":R.selecting||void 0,children:[L?(0,J.jsxs)(J.Fragment,{children:[se?null:(0,J.jsx)(dA,{view:r.view,lastFolder:R.lastFolder,onOpen:R.history.open,onFolders:()=>{ae(!0)},subfolders:r.view.kind===`folder`?w.gallery.folders:[],onOpenSubfolder:e=>{R.history.open({kind:`folder`,folder:r.view.kind===`folder`&&r.view.folder?`${r.view.folder}/${e}`:e})}}),R.selecting?(0,J.jsx)(uA,{count:R.selected.size,total:T.entries.length,canWrite:M,onToggleAll:()=>{R.selectAll(R.selected.size===T.entries.length?[]:T.entries.map(e=>e.path))},onMove:()=>{R.setMoving([...R.selected])},onFavorite:()=>{R.toggleFavorite([...R.selected],!0)},onDone:()=>{R.setSelecting(!1)}}):null]}):null,(0,J.jsxs)(`div`,{className:`prints-gallery-region`,children:[(0,J.jsx)(gh,{screen:!0,ref:De,className:`prints-gallery-scroll flex-1 min-h-0`,"data-media-scroll":!0,"aria-busy":O||T.loading,onDragOver:e=>{e.preventDefault()},onDrop:e=>{e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&&M&&re(t)},children:(0,J.jsxs)(`div`,{className:`prints-gallery-content`,children:[Qe.length>0?(0,J.jsx)(aP,{items:L?Qe.map(R.enrich):Qe,scrollRef:De,focus:v===null?b??(de&&B.target?{key:`${B.target.computerId}:${B.target.path}`,requestId:B.target.requestId,onFocus:()=>{_(null),y(Rg(de))}}:void 0):void 0}):O||T.loading?(0,J.jsx)(Ry,{"data-media-loading":!0,framed:!1,message:`Loading prints…`,detail:`Your library is on its way.`,variant:`wander`}):(0,J.jsx)(Iy,{"aria-live":`polite`,"data-absence":!0,"data-media-empty":!0,role:`status`,variant:`speech`,className:`prints-invitation`,visual:`blobs`,title:i?`Make and collect images`:Je?.title??`Make your first print`,description:i?`Upload images to start your collection. Open any image to view or download it.`:Je===null?r.computerId===null?`Your images will appear here.`:G?`Choose where Prints saves, then describe something.`:`Describe something and it lands here, or drop in images from your Computer.`:Je.description,primaryAction:i?dt:G?ft:void 0,actions:G?void 0:i?(0,J.jsxs)(`div`,{className:`prints-image-setup`,children:[(0,J.jsx)(`span`,{children:u}),pt]}):(0,J.jsx)(U,{variant:`ghost`,size:`sm`,disabled:!M||C===null,onClick:()=>Oe.current?.click(),children:`Upload images`}),suggestions:i||G?void 0:OP.map(e=>({label:e,disabled:!$e,onSelect:()=>{Pe.setFieldValue(`prompt`,e),t.current?.querySelector(`[data-generation-prompt]`)?.focus()}}))}),T.hasNextPage&&(0,J.jsx)(U,{variant:`ghost`,disabled:T.loading,onClick:T.loadMore,children:T.loading?`Loading images…`:`Load more images`})]})}),g&&(g.source.kind===`local`||g.source.connection===e&&g.source.computerId===r.computerId)?ut(g,()=>{_(null)}):null]})]})]}),L&&r.destination?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(fA,{app:e.app,root:r.destination,from:r.view.kind===`folder`?{folder:r.view.folder}:null,canWrite:M,count:R.moving?.length??0,open:R.moving!==null,version:R.version,onClose:()=>{R.setMoving(null)},onMove:(e,t)=>{let n=R.moving??[];R.setMoving(null),R.setSelecting(!1),R.move(n,e,{create:t})}}),(0,J.jsx)(hA,{parent:R.newFolder?.parent,open:R.newFolder!==null,onClose:()=>{R.setNewFolder(null)},onCreate:e=>R.createFolder(R.newFolder?.parent,e)}),(0,J.jsx)(cm,{open:ie,onOpenChange:ae,children:(0,J.jsxs)(pm,{className:`prints-folders-dialog`,children:[(0,J.jsx)(hm,{children:(0,J.jsx)(gm,{children:`Folders`})}),(0,J.jsx)(cA,{app:e.app,root:r.destination,view:r.view,onView:e=>{R.history.open(e),ae(!1)},canWrite:M,version:R.version,onNewFolder:e=>{ae(!1),R.setNewFolder({parent:e})},onMoveRows:R.setMoving})]})})]}):null,(0,J.jsx)(v_,{items:Qe,images:E,viewerKey:v,app:e?.app??null,onNavigate:y,onClose:lt,renderInfo:(e,t)=>ut(e,t,null)}),i&&Qe.length>0?(0,J.jsxs)(`div`,{className:`prints-library-actions`,children:[(0,J.jsx)(U,{size:`sm`,onClick:dt.onSelect,disabled:dt.disabled,children:`Upload images`}),pt,s?(0,J.jsx)(`div`,{className:`prints-image-setup`,children:u}):null]}):null,(0,J.jsxs)(`div`,{className:`prints-composer-dock`,children:[(0,J.jsx)(`section`,{"aria-label":`Computer uploads`,className:`prints-uploads`,children:(0,J.jsx)(`input`,{ref:Oe,type:`file`,disabled:!M||C===null,accept:`image/*`,multiple:!0,hidden:!0,"aria-label":`Choose images to upload`,onChange:e=>{re(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),i?null:(0,J.jsx)(PP,{addedLength:He?.kind===`audio`?0:lr(Le.prompt,fe.styles.find(e=>e.name===Le.style)?.text,V.characters),styleControls:e=>({picker:(0,J.jsx)(TP,{styles:fe.styles,selected:Le.style,disabled:!xe||ve||Be,onSelect:e=>{Pe.setFieldValue(`style`,e)}}),dialog:(0,J.jsx)(EP,{open:e.open,onOpenChange:e.onOpenChange,styles:fe.styles,selected:Le.style,busy:fe.busy,error:fe.error,onSelect:e=>{Pe.setFieldValue(`style`,e)},onSave:fe.save,onDelete:(e,t)=>{fe.remove(e.id,t)}})}),characters:V.characters,characterDialog:e=>(0,J.jsx)(dP,{open:e.open,onOpenChange:e.onOpenChange,characters:V.characters,images:W,busy:V.busy,error:V.error,canUpload:M&&C!==null,onUpload:()=>Oe.current?.click(),onSave:V.save,onDelete:(e,t)=>{V.remove(e.id,t)}}),guidance:it.find(e=>e.blocking&&e.group===`Setup`)??(Ae!==null&&Ae.model===Le.model?{key:`iteration-model`,group:`Images`,tone:`warning`,short:`Model changed`,title:`Model changed`,detail:Ae.message,actions:[{label:`Dismiss`,run:()=>{je(null)}}]}:void 0),commandApp:Ve,actions:(0,J.jsx)(_t,{"aria-label":`Upload images`,title:M?`Upload images to Computer`:`Connect a writable Computer to upload`,icon:(0,J.jsx)(Lh,{}),label:null,className:`prints-upload-key`,disabled:!M||C===null,onClick:()=>Oe.current?.click()}),form:Pe,mediaCapability:xe&&be&&M&&C!==null,models:_e,modelsLoading:ve,onSubmit:Pe.submitCurrent,submitting:Be,generateLimitReason:he.atLimit?wr:void 0,values:Le,computerId:r.computerId,mediaDirectory:C,referenceImages:W,referenceLabels:Re,price:ze}),ct===null?null:(0,J.jsx)(LM,{notices:it,uploads:ot,open:d,inset:p,onOpenChange:f,onDismiss:h.dismiss,onDismissAll:()=>{h.dismissAll(rt)},onLoadMore:he.hasMore?he.loadMore:void 0})]}),(0,J.jsx)(zM,{folder:r})]})}var IP=document.getElementById(`media-root`);if(!IP)throw Error(`Media root is missing`);Ff(IP,{name:`Prints`,queryClient:ni()},({app:e})=>(0,q.createElement)(FP,{connection:e?{app:e}:null}));
|