@fungi.computer/inkcap 0.16.15 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{FileTab-CCBFpeI7.js → FileTab-Dh_MXYyL.js} +1 -1
- package/dist/assets/{InkcapFileTree-DxXq4PlT.js → InkcapFileTree-BOkmSC0u.js} +1 -1
- package/dist/assets/{InkcapRepositoryApp-DzQTFgl8.js → InkcapRepositoryApp-D0pW-5wq.js} +1 -1
- package/dist/assets/{changes-patch-BR_5GLNZ.js → changes-patch-CrPexAyH.js} +1 -1
- package/dist/assets/{dropdown-menu-BX51yjwf.js → dropdown-menu-D1-KaUEJ.js} +2 -2
- package/dist/assets/index-BsHPJca6.css +2 -0
- package/dist/assets/index-DqkwqNVw.js +2 -0
- package/dist/assets/{tree-path-CnRRWDW0.js → tree-path-AxEg-Kjh.js} +2 -2
- package/dist/assets/{useFileTree-D36ddtur.js → useFileTree-C86PCVGL.js} +1 -1
- package/dist/assets/{useForm-5V_Bjs-x.js → useForm-BDtDFyLf.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +3 -3
- package/dist/assets/index-BKLzsvfo.js +0 -2
- package/dist/assets/index-CqQimK4E.css +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bn as t,Ji as n,Jn as r,Kn as i,Kr as a,Xr as o,Yi as s,Yn as c,Yr as l,Zn as u,a as d,ar as f,c as p,d as m,dr as h,er as g,ir as _,l as v,lr as y,o as b,r as x,rr as S,s as C,tr as w,u as T,ur as E}from"./tree-path-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bn as t,Ji as n,Jn as r,Kn as i,Kr as a,Xr as o,Yi as s,Yn as c,Yr as l,Zn as u,a as d,ar as f,c as p,d as m,dr as h,er as g,ir as _,l as v,lr as y,o as b,r as x,rr as S,s as C,tr as w,u as T,ur as E}from"./tree-path-AxEg-Kjh.js";import{$ as ee,A as D,At as O,B as k,Bt as A,C as j,Ct as M,D as N,Dt as P,E as te,Et as F,F as ne,G as I,H as re,I as ie,It as ae,J as oe,K as L,Kt as se,L as R,M as ce,Mt as le,N as ue,Nt as de,O as fe,Ot as pe,P as me,Pt as he,Q as ge,R as _e,S as ve,St as ye,T as be,Tt as xe,U as Se,V as Ce,Vt as we,W as Te,Wt as Ee,X as De,Y as Oe,Z as ke,_ as Ae,_t as z,a as je,at as Me,b as Ne,bt as Pe,c as Fe,ct as Ie,d as Le,dt as Re,et as ze,f as Be,ft as Ve,g as He,gt as Ue,h as We,ht as Ge,i as Ke,it as qe,j as Je,jt as Ye,k as Xe,kt as Ze,l as Qe,lt as $e,m as et,mt as tt,n as nt,nt as rt,o as it,ot as at,p as ot,pt as st,q as ct,qt as lt,r as ut,rt as dt,s as ft,st as pt,t as mt,tt as ht,u as gt,ut as _t,v as vt,vt as yt,w as bt,x as xt,xt as St,y as Ct,yt as wt,z as Tt}from"./dropdown-menu-D1-KaUEJ.js";import{a as Et,p as Dt,r as Ot,t as kt}from"./useForm-BDtDFyLf.js";var At=E(`Ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),B=n();function jt({file:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:a,renderAnnotation:o,lineAnnotations:s,renderGutterUtility:c,getHoveredLine:l}){let u=t?.(e),d=n?.(e),f=r?.(e),p=a?.(e);return(0,B.jsxs)(B.Fragment,{children:[u==null?(0,B.jsxs)(B.Fragment,{children:[d!=null&&(0,B.jsx)(`div`,{slot:`header-prefix`,children:d}),f!=null&&(0,B.jsx)(`div`,{slot:`header-filename-suffix`,children:f}),p!=null&&(0,B.jsx)(`div`,{slot:`header-metadata`,children:p})]}):(0,B.jsx)(`div`,{slot:i,children:u}),o!=null&&s?.map((e,t)=>(0,B.jsx)(`div`,{slot:Ze(e),children:o(e)},t)),c!=null&&(0,B.jsx)(`div`,{slot:`gutter-utility-slot`,style:O,children:c(l)})]})}function Mt(e){return xe.hasResolvedThemes(e)}function Nt(e,t){return P(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}function Pt(e){return(e.lang??z(e.name))===`text`}var Ft=10,It=13,Lt=4,Rt=40;function zt(e){let t=[0],n=e.indexOf(`\r`),r=e.indexOf(`
|
|
2
2
|
`),i=0,a=0;for(;n!==-1||r!==-1;){let o;if(n!==-1&&(r===-1||n<r)?r===n+1?(o=r+1,n=e.indexOf(`\r`,o),r=e.indexOf(`
|
|
3
3
|
`,o)):(o=n+1,n=e.indexOf(`\r`,o)):(o=r+1,r=e.indexOf(`
|
|
4
4
|
`,o)),t.push(o),++a===Lt){if(o-i<=Rt){for(let n=o;n<e.length;n++){let r=e.charCodeAt(n);(r===Ft||r===It)&&(r===It&&n+1<e.length&&e.charCodeAt(n+1)===Ft&&n++,t.push(n+1))}return t}i=o,a=0}}return t}function Bt(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);(r===Ft||r===It)&&(r===It&&n+1<e.length&&e.charCodeAt(n+1)===Ft&&n++,t++)}return t}function Vt(e){let t=zt(e);return Array.from({length:t.length},(n,r)=>{let i=t[r],a=t[r+1]??e.length;return e.slice(i,a)})}var Ht={compositeOverBg:rt,contrastRatio:dt,deriveMutedFg:qe,hoverWouldEraseText:Me,isDarkSurface:at,isFullyTransparent:pt,pickReadableForeground:Ie,relativeLuminance:$e,surfacesMatch:_t},Ut={forcePlainText:!1};function Wt(e,t,{theme:n=c,tokenizeMaxLineLength:r,useTokenTransformer:i},{forcePlainText:a,startingLine:o,totalLines:s,lines:l}=Ut){a?(o??=0,s??=1/0):(o=0,s=1/0);let u=o>0||s<1/0,{state:d,transformers:f}=Ve(i),p=a?`text`:e.lang??z(e.name),m=typeof n==`string`?t.getTheme(n).type:void 0,h=ht({theme:n,highlighter:t});d.lineInfo=e=>({type:`context`,lineIndex:e-1+o,lineNumber:e+o});let g=typeof n==`string`?{lang:p,theme:n,transformers:f,defaultColor:!1,cssVariablePrefix:Re(`token`),tokenizeMaxLineLength:r,tokenizeTimeLimit:0}:{lang:p,themes:n,transformers:f,defaultColor:!1,cssVariablePrefix:Re(`token`),tokenizeMaxLineLength:r,tokenizeTimeLimit:0},_=ze(t.codeToHast(u?Gt(l??Vt(e.contents),o,s):e.contents,g)),v=u?Array(o):_;return u&&v.push(..._),{code:v,themeStyles:h,baseThemeType:m}}function Gt(e,t,n){if(e.length===0)return``;let r=Math.min(t+n,e.length);return e.slice(t,r).join(``)}function Kt(e,t){return t.cacheKey==null?e.file===t&&e.sourceContents===t.contents:e.cacheKey===t.cacheKey}var qt=-1,Jt=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++qt}`;highlighter;renderCache;computedLang=`text`;lineAnnotations={};lineCache;pendingStructuralRows;textDocumentCache=new WeakMap;editSessionActive=!1;constructor(e={theme:c},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=ue(e.theme??c)?wt():void 0)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}setLineAnnotations(e){this.lineAnnotations={};for(let t of e){let e=this.lineAnnotations[t.lineNumber]??[];this.lineAnnotations[t.lineNumber]=e,e.push(t)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}beginEditSession(){this.editSessionActive=!0}endEditSession(){this.editSessionActive=!1}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0,this.endEditSession(),this.textDocumentCache=new WeakMap}syncEditedContentsToFile(){let{renderCache:e,lineCache:t}=this;e?.isDirty!==!0||t==null||!Kt(t,e.file)||(e.file.contents=t.lines.join(``))}hasUnkeyedFileContentsChanged(e){let{lineCache:t}=this;return e.cacheKey==null&&t!=null&&t.file===e&&t.sourceContents!==e.contents}invalidateChangedUnkeyedFile(e){this.hasUnkeyedFileContentsChanged(e)&&(this.workerManager?.cleanUpTasks(this),this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap)}clearRenderCache(){this.syncEditedContentsToFile(),this.pendingStructuralRows=void 0;let e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(e.file.cacheKey)}hydrate(e){let{options:t}=this.getRenderOptions(e),n=Yt(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength()),r=this.workerManager?.getFileResultCache(e);r!=null&&!Nt(t,r.options)&&(r=void 0),this.renderCache??={file:e,options:t,highlighted:!n&&!Pt(e),result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightFileAST(this,e):this.highlighter??(this.computedLang=e.lang??z(e.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??c}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getFileRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let e=this.workerManager.getFileRenderOptions();return this.editSessionActive&&e.useTokenTransformer!==!0?{...e,useTokenTransformer:!0}:e}let{tokenizeMaxLineLength:e=1e3}=this.options;return{theme:this.getLocalHighlightTheme(),useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:e}})(),{renderCache:n}=this;return n?.result==null||!F(e,n.file)||!Nt(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}getOrCreateLineCache(e){this.invalidateChangedUnkeyedFile(e);let{lineCache:t}=this;return(t==null||!Kt(t,e))&&(t={cacheKey:e.cacheKey,file:e,sourceContents:e.contents,lines:Vt(e.contents)}),this.lineCache=t,t.lines}getLineCount(e){let t=this.getOrCreateLineCache(e);return this.textDocumentCache.get(e)?.lineCount??t.length}updateRenderCache(e,t,n=!1){if(this.pendingStructuralRows=void 0,this.renderCache==null)return;let{file:r,result:i}=this.renderCache;if(i==null)return;let a=n?new Map:void 0;this.pendingStructuralRows=a;let o=this.lineCache!=null&&Kt(this.lineCache,r)?this.lineCache:void 0;for(let[t,n]of e){if(a===void 0&&o!=null&&t<o.lines.length){let e=n.map(e=>e[2]).join(``);o.lines[t]=ce(o.lines[t]??``,e)}let e={type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})};a===void 0?i.code[t]=e:a.set(t,e)}i.baseThemeType=t,this.renderCache.isDirty=!0}applyDocumentChange(e){let t=this.pendingStructuralRows;if(this.pendingStructuralRows=void 0,this.renderCache==null)return;let{file:n,result:r}=this.renderCache;if(r==null)return;let i=this.lineCache!=null&&Kt(this.lineCache,n)?this.lineCache.lines:Vt(n.contents),a=Vt(e.getText());if(i.length!==a.length){let n=Math.min(i.length,a.length),o=0;for(;o<n&&i[o]===a[o];)o++;let s=0;for(;s<n-o&&i[i.length-1-s]===a[a.length-1-s];)s++;let c=r.code;r.code=Array(a.length);for(let e=0;e<o;e++)r.code[e]=c[e];for(let e=0;e<s;e++)r.code[a.length-1-e]=c[i.length-1-e];if(t!==void 0)for(let[e,n]of t)e<a.length&&(r.code[e]=n);for(let t=o;t<a.length-s;t++)r.code[t]??={type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:e.getLineText(t)}]}]};for(let e=0;e<r.code.length;e++){let t=r.code[e];t?.type===`element`&&(t.properties[`data-line`]=e+1,t.properties[`data-line-index`]=e)}this.renderCache.isDirty=!0}this.lineCache={cacheKey:n.cacheKey,file:n,sourceContents:n.contents,lines:a},this.textDocumentCache.set(n,e)}renderFile(e=this.renderCache?.file,t=r){if(e==null)return;this.invalidateChangedUnkeyedFile(e),this.renderCache?.isDirty===!0&&!F(e,this.renderCache.file)&&(this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap);let{options:n,forceHighlight:i}=this.getRenderOptions(e);this.renderCache?.isDirty===!0&&!Nt(n,this.renderCache.options)&&this.clearRenderCache();let a=this.getMatchingWorkerResultCache(e,n);a!=null&&!this.hasHighlightedRenderCache(e,n)&&(this.renderCache={file:e,highlighted:!0,renderRange:void 0,...a},i=!1),this.renderCache??={file:e,highlighted:!1,options:n,result:void 0,renderRange:void 0};let o=this.getOrCreateLineCache(e),s=e.contents.length>0,c=!s||Pt(e)||Yt(o.length,this.getTokenizeMaxLength()),l=!F(e,this.renderCache.file),u=!ne(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0)(c||this.renderCache.result==null||!this.renderCache.highlighted&&(l||u))&&(this.renderCache.file=e,this.renderCache.options=n,this.renderCache.highlighted=!1,(this.renderCache.result==null||l||u||i)&&(this.renderCache.result=this.workerManager.getPlainFileAST(e,t.startingLine,t.totalLines,o)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||i)&&this.workerManager.highlightFileAST(this,e);else{this.computedLang=e.lang??z(e.name);let t=this.highlighter!=null&&ue(n.theme),r=this.highlighter!=null&&me(this.computedLang),a=!c&&r;if(this.highlighter!=null&&t&&(i||c||!this.renderCache.highlighted&&a||this.renderCache.result==null)){let{result:t,options:n}=this.renderFileWithHighlighter(e,this.highlighter,c||!r);this.renderCache={file:e,options:n,highlighted:a,result:t,renderRange:void 0}}(!t||!c&&!r)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.applyHighlightResult(e,t,n,!c)})}return this.renderCache.result==null?void 0:this.processFileResult(this.renderCache.file,t,this.renderCache.result)}async asyncRender(e,t=r){let{result:n}=await this.asyncHighlight(e);return this.processFileResult(e,t,n)}async asyncHighlight(e){let t=Yt(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength());this.computedLang=t?`text`:e.lang??z(e.name);let n=this.highlighter!=null&&Mt(yt(this.getLocalHighlightTheme())),r=t||this.highlighter!=null&&me(this.computedLang);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(e,this.highlighter,t)}renderFileWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e);return{result:Wt(e,t,r,{forcePlainText:n}),options:r}}processFileResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let a=this.getLineCount(e),{disableFileHeader:o=!1}=this.options,s=[],c=Ge(),l=Math.min(t.startingLine+t.totalLines,a),u=0,d=Se(t)?Ce(this.lineAnnotations):void 0;d!=null&&(c.children.push(st(`context`,`annotation`,1)),s.push(Je({type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:d.map(e=>Ze(e))})),u++);for(let r=t.startingLine;r<l;r++){let t=r+1,i=n[r];if(i==null){let n=`FileRenderer.processFileResult: Line doesnt exist`;throw console.error(n,{name:e.name,lineIndex:r,lineNumber:t}),Error(n)}c.children.push(tt(`context`,t,`${r}`)),s.push(i),u++;let a=this.lineAnnotations[t];a!=null&&(c.children.push(st(`context`,`annotation`,1)),s.push(Je({type:`annotation`,hunkIndex:0,lineIndex:t,annotations:a.map(e=>Ze(e))})),u++)}return c.properties.style=`grid-row: span ${u}`,{gutterAST:c.children??[],contentAST:s,preAST:this.createPreElement(a),headerAST:o?void 0:this.renderHeader(e),totalLines:a,rowCount:u,themeStyles:r,baseThemeType:i,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderHeader(e){let{headerRenderMode:t=`default`,stickyHeader:n=!1}=this.options;return Xe({fileOrDiff:e,mode:t,stickyHeader:n})}renderFullHTML(e){return St(this.renderFullAST(e))}renderFullAST(e,t=[]){return t.push(Ue({tagName:`code`,children:this.renderCodeAST(e),properties:{"data-code":``}})),{...e.preAST,children:t}}renderCodeAST(e){let t=Ge();return t.children=e.gutterAST,t.properties.style=`grid-row: span ${e.rowCount}`,[t,D(e.contentAST,e.rowCount)]}renderPartialHTML(e,t=!1){return St(t?Ue({tagName:`code`,children:e,properties:{"data-code":``}}):e)}async initializeHighlighter(){return this.highlighter=await Pe(N(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}onHighlightSuccess(e,t,n,r=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){if(this.renderCache==null)return;let i=!F(e,this.renderCache.file)||!this.renderCache.highlighted||!Nt(n,this.renderCache.options);this.renderCache={file:e,options:n,highlighted:r,result:t,renderRange:void 0},i&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getFileResultCache(e);if(!(n==null||!Nt(t,n.options)))return n}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&F(e,n.file)&&Nt(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(e){let{disableLineNumbers:t=!1,overflow:n=`scroll`}=this.options;return fe({type:`file`,diffIndicators:`none`,disableBackground:!0,disableLineNumbers:t,overflow:n,split:!1,totalLines:e})}};function Yt(e,t){return e>t}function Xt(e,t){return e.lineNumber===t.lineNumber&&e.metadata===t.metadata}function Zt(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,themeType:e?.themeType,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:Ae(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,unsafeCSS:e?.unsafeCSS,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}var Qt=[``],$t=-1,en=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++$t}`;type=`file`;fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:c},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new Jt(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new ie,this.interactionManager=new R(`file`,_e(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}__getCurrentFile(){return this.file}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(_e(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType!==t&&(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!P(this.appliedThemeCSS.theme,this.options.theme??c)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??`additions`})}getCodeScrollLeft(){return this.code?.scrollLeft??0}setCodeScrollLeft(e){this.code!=null&&(this.code.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.fileRenderer.getEffectiveCodeOptions()}}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{overflow:e=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e===`wrap`,columnVariables:this.shouldApplyColumnVariables(e)?`apply`:`measure`}),this.managersDirty=!1}shouldApplyColumnVariables(e){return e===`scroll`&&this.lineAnnotations.length>0}cleanUp(e=!1){this.emitPostRender(!0),this.editor?.cleanUp(e),this.editor=void 0,this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.pre=void 0,this.code=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:i,lineAnnotations:a}=e;if(!this.enabled)throw Error(`File.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`File.hydrate: hydrate can only be called before the instance has rendered or hydrated`);this.hydrateElements(t,n),tn(this.pre,i,this.options.collapsed)||nn(this.headerElement,i,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:i,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Le(e,t);for(let t of Array.from(e.shadowRoot?.children??[])){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t,this.appliedPreAttributes=void 0;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}if(`diffsHeader`in t.dataset){this.headerElement=t,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(Zt(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e==null?Qt:this.fileRenderer.getOrCreateLineCache(e)}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){let e=this.editor,t=this.fileContainer,n=this.file,r=this.lineAnnotations,i=this.renderRange;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(a=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.file!==n||e.__syncRenderView(a,t,n,r,i)})}attachEditor(e){this.editor?.cleanUp(),this.editor=e,this.fileRenderer.beginEditSession();let t=this.file==null?void 0:e.__prepareFile?.(this.file);return t!==void 0&&t!==this.file?this.renderPreparedFile({file:t,forceRender:!0,preventEmit:!0,renderRange:this.renderRange}):this.fileRenderer.editorRenderReady()?this.syncRenderViewToEditor():this.rerender(),()=>{this.editor=void 0,this.fileRenderer.endEditSession()}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t,n){this.fileRenderer.updateRenderCache(e,t,n?.lineCountChangeInFlight)}render(e){if(!this.enabled)throw Error(`File.render: attempting to call render after cleaned up`);let t=this.editor?.__prepareFile?.(e.file)??e.file;return this.renderPreparedFile(t===e.file?e:{...e,file:t})}renderPreparedFile({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:i,deferManagers:a=!1,lineAnnotations:o,renderRange:s}){this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:c=!1,themeType:l=`system`}=this.options,u=c?void 0:s,d=this.renderRange,f=this.hasThemeChanged(),p=o!=null&&(o.length>0||this.lineAnnotations.length>0)&&o!==this.lineAnnotations,m=!F(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e);if(!c&&!n&&ne(u,this.renderRange)&&!m&&!p&&!f)return this.applyCachedThemeState(l);this.renderRange=u,m&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(Zt(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:h=!1,disableFileHeader:g=!1}=this.options;if(g&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,i),this.applyCachedThemeState(l),c){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let n=this.fileRenderer.renderFile(e,w);n!=null&&this.applyThemeState(t,n.themeStyles,l,n.baseThemeType),n?.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.injectUnsafeCSS()}catch(e){if(h)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}try{let r=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,p,m||f)||!this.applyPartialRender(d,u)){let n=this.fileRenderer.renderFile(e,u);if(n==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,n.themeStyles,l,n.baseThemeType),n.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.applyFullRender(n,r)}this.applyBuffers(r,u),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,a||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(h)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}async primeHighlightCache(e=this.file){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||Pt(e))return;let n=this.options.tokenizeMaxLength??1e5;this.fileRenderer.getOrCreateLineCache(e).length>n||await t.primeFileHighlightCache(e).catch(e=>{console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(let[n,r]of this.lineAnnotations.entries()){let i=`${n}-${Ze(r)}`,a=this.annotationCache.get(i);if(a==null||!Xt(r,a.annotation)){a?.element.remove();let e=t(r);if(e==null)continue;a={element:bt(Ze(r)),annotation:r},a.element.appendChild(e),this.fileContainer.appendChild(a.element),this.annotationCache.set(i,a)}e.delete(i)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=j();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=ve(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Ne(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.options.theme??c,s=typeof o==`string`?o:{...o},l=xt(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===l){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:l};return}this.themeCSSStyle=et({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:Ct(t,a,l)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:l}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e!=null&&this.themeCSSStyle!=null&&(this.themeCSSStyle.textContent=vt(this.themeCSSStyle.textContent??``,xt(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&ot()}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e);let n=this.code=He({code:this.code}),r=this.fileRenderer.renderCodeAST(e);this.editor?.__captureFocusForDOMReplacement();let i=()=>{if(n.childElementCount>=2)for(let e=0;e<2;e++){let t=n.children[e],i=r[e];t.innerHTML=St(i.children),t.style.cssText=i.properties.style}else n.innerHTML=St(r);t.contains(n)||t.replaceChildren(n)};this.shouldGuardRebuildScroll()?We(t,i):i(),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;let{file:n,code:r}=this,i=r==null?void 0:this.getColumns(r);if(n==null||r==null||i==null)return!1;let a=e.startingLine,o=t.startingLine,s=e.totalLines===1/0?1/0:a+e.totalLines,c=t.totalLines===1/0?1/0:o+t.totalLines,l=Math.max(a,o),u=Math.min(s,c);if(u<=l)return!1;if(!this.trimDOMToOverlap(i.gutter,l,u)||!this.trimDOMToOverlap(i.content,l,u))throw Error(`File.applyPartialRender: failed to trim to overlap`);let{length:d}=i.content.children,f=(e,t)=>{if(!(t<=0))return this.fileRenderer.renderFile(n,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},p=o<l?f(o,l-o):void 0;if(p===void 0&&o<l)return!1;let m=c===1/0?1/0:Math.max(0,c-u),h=c>u?f(u,m):void 0;return h===void 0&&c>u?!1:(this.cleanupErrorWrapper(),p!=null&&(i.gutter.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.gutterAST)),i.content.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.contentAST)),d+=p.rowCount),h!=null&&(i.gutter.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.gutterAST)),i.content.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.contentAST)),d+=h.rowCount),this.lastRowCount!==d&&(i.gutter.style.setProperty(`grid-row`,`span ${d}`),i.content.style.setProperty(`grid-row`,`span ${d}`),this.lastRowCount=d),!0)}getColumns(e){let t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){let r=this.getDOMBoundaryIndices(e,[t,n]),i=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(i>a)return!1;for(let t=e.children.length-1;t>=a;--t)e.children[t]?.remove();for(let t=i-1;t>=0;--t)e.children[t]?.remove();return!0}getDOMBoundaryIndices(e,t){let n=[...new Set(t)].sort((e,t)=>e-t),r=new Map;if(n.length===0)return r;let i=0,a=n[i],{children:o}=e;a===0&&(r.set(0,0),i+=1,a=n[i]);for(let e=0;e<o.length;e+=1){let t=o[e];if(!(t instanceof HTMLElement))continue;let s=this.getLineIndexFromDOMNode(t);if(s!=null){for(;a!=null&&s>=a;)r.set(a,e),i+=1,a=n[i];if(i>=n.length)break}}for(let e of n)r.has(e)||r.set(e,o.length);return r}getLineIndexFromDOMNode(e){let t=e.dataset.lineIndex;if(t==null)return;let n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){let{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let r=this.cachedHeaderHTML??St(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=r;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;let{renderHeaderPrefix:a,renderHeaderFilenameSuffix:o,renderCustomHeader:s,renderHeaderMetadata:c}=this.options;if(s!=null){let e=s(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,i,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{let e=a?.(n)??void 0,r=o?.(n)??void 0,i=c?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,f,e),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,S,r),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,_,i),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}getOrCreateFileContainerNode(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:Te(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):Te(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=te;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute(`data-code`)){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){let{overflow:n=`scroll`,disableLineNumbers:r=!1}=this.options,i={type:`file`,split:!1,overflow:n,disableLineNumbers:r,diffIndicators:`none`,disableBackground:!0,totalLines:t};be(i,this.appliedPreAttributes)||(gt(e,i),this.appliedPreAttributes=i)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function tn(e,t,n=!1){return!n&&e==null&&t!=null}function nn(e,t,n=!1){return e==null&&t!=null&&!n}var rn=5e3,an=-1;function on(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS}var sn=class extends en{virtualizer;metrics;__id=`virtualized-file:${++an}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n=u,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=n}setMetrics(e,t=!1){let n=ke(e);!t&&Oe(this.metrics,n)||(this.metrics=n,this.resetLayoutCache())}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache()}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}hasLineAnnotations(){return this.lineAnnotations.some(e=>e.lineNumber>0)}getLineHeight(e,t=!1){let n=this.cache.heights.get(e);if(n!=null)return n;let r=t?2:1;return this.metrics.lineHeight*r}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!oe(t,e),r=on(t,e);super.setOptions(e),r&&this.resetLayoutCache(!0),n&&(this.forceRenderOverride=!0),n&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache(e=!1,t=!0){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&t&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let e=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(e=!0),this.height=0,e;let{overflow:t=`scroll`}=this.options;if(this.top=this.getVirtualizedTop(),t===`scroll`&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return e;let n=this.code.children[1];if(!(n instanceof HTMLElement))return e;let r=re(this.lineAnnotations);if(this.renderRange!=null&&r&&Se(this.renderRange)){let t=cn(n)??0;t!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=t,e=!0)}else!r&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,e=!0);for(let t of n.children){if(!(t instanceof HTMLElement))continue;let n=t.dataset.lineIndex;if(n==null)continue;let r=Number(n),i=t.getBoundingClientRect().height,a=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(a=!0),i+=t.nextElementSibling.getBoundingClientRect().height);let o=this.getLineHeight(r,a);i!==o&&(e=!0,i===this.metrics.lineHeight*(a?2:1)?this.cache.heights.delete(r):this.cache.heights.set(r,i))}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null||this.file==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(e,t,n,r){let i=this.syncLineAnnotations(r),a=!F(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e),o=n?.resetFileLayoutCache===!0||a||i;n?.metrics!=null&&(this.metrics=n.metrics,o=!0);let{collapsed:s=!1}=this.options;return this.currentCollapsed!==s&&(this.currentCollapsed=s,o=!0),o&&this.resetLayoutCache(),this.file!==e&&(this.layoutDirty=!0),this.file=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e){if(this.file==null||e<1)return;let{disableFileHeader:t=!1,collapsed:n=!1}=this.options,r=this.fileRenderer.getLineCount(this.file)-1,i=ge(this.metrics,t);if(n||r<0)return{top:i,height:0};let a=Math.min(Math.max(e-1,0),r),{overflow:o=`scroll`}=this.options,{lineHeight:s}=this.metrics;if(i+=this.cache.fileAnnotationHeight,o===`scroll`&&!this.hasLineAnnotations())return{top:i+a*s,height:s};let c=this.getLayoutCheckpointBeforeLineIndex(a);i=c?.top??i;for(let e=c?.lineIndex??0;e<a;e++)i+=this.getLineHeight(e,!1);return{top:i,height:this.getLineHeight(a,!1)}}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){if(this.file==null||this.renderRange==null)return;let{disableFileHeader:t=!1,collapsed:n=!1,overflow:r=`scroll`}=this.options;if(n||this.renderRange.totalLines<=0)return;let i=this.fileRenderer.getLineCount(this.file)-1;if(i<0)return;let a=ge(this.metrics,t),o=Math.min(this.renderRange.startingLine,i),s=Math.min(o+this.renderRange.totalLines-1,i);if(s<o)return;let{fileAnnotationHeight:c}=this.cache;if(r===`scroll`&&!this.hasLineAnnotations()){let{lineHeight:t}=this.metrics,n=a+(o===0?c:this.renderRange.bufferBefore),r=o+Math.max(Math.ceil((e-n)/t),0);return r>s?void 0:{lineNumber:r+1,top:a+c+r*t}}let l=a+(o===0?c:this.renderRange.bufferBefore);for(let t=o;t<=s;t++){if(l>=e)return{lineNumber:t+1,top:l};l+=this.getLineHeight(t)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let t=e==null?this.renderRange:this.computeRenderRangeFromWindow(this.file,this.top,e);if(t==null)return;let{bufferBefore:n,bufferAfter:r,totalLines:i}=t,a=0;if(i===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(a=r)}return{topOffset:this.top+n+a,height:this.height-(n+r)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(e)}computeApproximateSize(e=!1,t=this.file){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],t==null){this.layoutDirty=!1;return}let{disableFileHeader:i=!1,collapsed:a=!1,overflow:o=`scroll`}=this.options,{lineHeight:s}=this.metrics,c=this.fileRenderer.getLineCount(t),l=ge(this.metrics,i),u=ee(this.metrics);if(this.height+=l,a){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,o===`scroll`&&!this.hasLineAnnotations())this.height+=c*s;else for(let e=0;e<c;e++)this.addLayoutCheckpoint(e,this.height),this.height+=this.getLineHeight(e,!1);if(c>0&&(this.height+=u),this.fileContainer!=null&&n&&!r){let e=this.fileContainer.getBoundingClientRect();e.height===this.height?console.log(`VirtualizedFile.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFile.computeApproximateSize: computed height doesnt match`,{name:t.name,elementHeight:e.height,computedHeight:this.height})}this.layoutDirty=!1}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;if(this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1),!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!==void 0&&this.file!==void 0){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(this.file,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}renderPreparedFile({fileContainer:e,file:t,forceRender:n=!1,lineAnnotations:r,...i}){let a=this.file==null||!F(this.file,t)||this.fileRenderer.hasUnkeyedFileContentsChanged(t),{forceRenderOverride:o,isSetup:s}=this;this.forceRenderOverride=void 0;let c=this.syncLineAnnotations(r);if(c&&this.resetLayoutCache(),e=this.getOrCreateFileContainerNode(e),t==null)return console.error(`VirtualizedFile.render: attempting to virtually render when we dont have file`),!1;if(s)this.top??=this.getVirtualizedTop(),a&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!1),this.computeApproximateSize(!1,t));else{this.computeApproximateSize(!1,t);let n=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(n==null)throw Error(`VirtualizedFile.render: simple virtualizer is not available`);n.connect(e,this),this.isVisible=n.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!a||!s))return this.file=t,a&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);let l=this.virtualizer.getWindowSpecs(),u=this.top??0,d=this.computeRenderRangeFromWindow(t,u,l),f=super.renderPreparedFile({file:t,fileContainer:e,renderRange:d,lineAnnotations:r,forceRender:(o??n)||c||a,...i});return this.isSimpleMode()&&f&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),f}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}addLayoutCheckpoint(e,t){e%rn===0&&this.cache.checkpoints.push({lineIndex:e,top:t})}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFile: invalid checkpoint index`);if(n.lineIndex%t===0)return n}}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type===`advanced`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,overflow:a=`scroll`}=this.options,{hunkLineCount:o,lineHeight:s}=this.metrics,c=this.fileRenderer.getLineCount(e),l=this.height,u=ge(this.metrics,i),d=c>0?ee(this.metrics):0,{fileAnnotationHeight:f}=this.cache,p=u+f,m=Math.max(0,l-u-f-d),h=re(this.lineAnnotations),g=t+u,_=f>0&&h&&g<r&&g+f>n;if(t<n-l||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};if(c<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};let v=Math.ceil(Math.max(r-n,0)/s),y=Math.ceil(v/o)*o+o,b=y/o,x=(n+r)/2;if(a===`scroll`&&!this.hasLineAnnotations()){let e=t+p,i=e+m;if(!_&&!(e<r&&i>n))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};let a=Math.floor(_&&x<t+p?0:(x-(t+p))/s),h=Math.floor(a/o)-Math.floor(b/2),g=Math.ceil(c/o),v=Math.max(0,Math.min(h,g))*o,S=h<0?y+h*o:y,C=v===0?0:f+v*s,w=Math.min(S,c-v);return{startingLine:v,totalLines:S,bufferBefore:C,bufferAfter:Math.max(0,(c-v-w)*s)}}let S=b,C=[],w=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-y*s*2),o),T=t+(w?.top??p),E=w?.lineIndex??0,D,O,k,A=w?.lineIndex??0;for(let e=A;e<c;e++){let i=E%o===0,a=Math.floor(E/o);if(i&&(C[a]=T-(t+p),k!=null)){if(k<=0)break;k--}let s=this.getLineHeight(e,!1);T>n-s&&T<r&&(D??=a),T+s>x&&(O??=a),k==null&&T>=r&&i&&(k=S),E++,T+=s}if(D==null){if(_)D=0,O=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d}}O??=D;let j=Math.round(O-b/2),M=Math.max(0,Math.ceil(c/o)-b),N=Math.max(0,Math.min(j,M)),P=N*o,te=j<0?y+j*o:y,F=C[N]??0,ne=P===0?0:f+F,I=N+te/o,ie=I<C.length?m-C[I]:m-(T-t-p);return{startingLine:P,totalLines:te,bufferBefore:ne,bufferAfter:Math.max(0,ie)}}};function cn(e){let t;for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===k&&(t=Math.max(t??0,n.getBoundingClientRect().height));return t}var V=e(s(),1),ln=typeof window>`u`?V.useEffect:V.useLayoutEffect;function un({file:e,options:t,editorOptions:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:a,metrics:o,hasGutterRenderUtility:s,hasCustomHeader:c,disableWorkerPool:l,edit:u}){let d=Fe(),f=i!==void 0,p=(0,V.useContext)(De),m=de(),h=(0,V.useRef)(null),g=he(n=>{if(n!=null){if(h.current!=null)throw Error(`File: An instance should not already exist when a node is created`);d==null?h.current=new en(dn({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),l?void 0:p,!0):h.current=new sn(dn({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),d,o,l?void 0:p,!0),h.current.hydrate({file:e,fileContainer:n,lineAnnotations:r,prerenderedHTML:a})}else{if(h.current==null)throw Error(`File: A File instance should exist when unmounting`);h.current.cleanUp(),h.current=null}});return ln(()=>{if(h.current==null)return;let n=dn({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),a=n!==void 0&&!oe(h.current.options,n);h.current.setOptions(n),h.current.render({file:e,lineAnnotations:r,forceRender:a}),i!==void 0&&h.current.setSelectedLines(i)}),ln(()=>{if(u&&h.current!=null){if(m===void 0)throw Error(`File: EditContext is not attached`);let e=m(n??{});if(e==null)throw Error(`File: EditProvider.createEditor must return an editor instance`);try{return e.edit(h.current)}catch(t){throw e.cleanUp(),t}}},[u]),{ref:g,getHoveredLine:(0,V.useCallback)(()=>h.current?.getHoveredLine(),[])}}function dn({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return t||r||n?{...e,controlledSelection:t,renderCustomHeader:n?Ye:e?.renderCustomHeader,renderGutterUtility:r?Ye:e?.renderGutterUtility}:e}function fn({file:e,lineAnnotations:t,selectedLines:n,options:r,editorOptions:i,metrics:a,className:o,style:s,renderAnnotation:c,renderCustomHeader:l,renderHeaderPrefix:u,renderHeaderFilenameSuffix:d,renderHeaderMetadata:f,prerenderedHTML:p,renderGutterUtility:m,disableWorkerPool:h=!1,edit:_=!1}){let{ref:v,getHoveredLine:y}=un({file:e,options:r,editorOptions:i,metrics:a,lineAnnotations:t,selectedLines:n,prerenderedHTML:p,hasGutterRenderUtility:m!=null,hasCustomHeader:l!=null,disableWorkerPool:h,edit:_});return(0,B.jsx)(g,{ref:v,className:o,style:s,children:Qe(jt({file:e,renderAnnotation:c,renderCustomHeader:l,renderHeaderPrefix:u,renderHeaderFilenameSuffix:d,renderHeaderMetadata:f,renderGutterUtility:m,lineAnnotations:t,getHoveredLine:y}),p)})}function pn({oldFile:e,newFile:t,options:n,editorOptions:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:u,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderGutterUtility:h,disableWorkerPool:_=!1,edit:v=!1}){let y=(0,V.useMemo)(()=>I(e,t,n?.parseDiffOptions),[e,t,n?.parseDiffOptions]),{ref:b,getHoveredLine:x}=ft({fileDiff:y,options:n,editorOptions:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:h!=null,hasCustomHeader:d!=null,disableWorkerPool:_,edit:v});return(0,B.jsx)(g,{ref:b,className:s,style:c,children:Qe(pe({fileDiff:y,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderAnnotation:u,lineAnnotations:a,renderGutterUtility:h,getHoveredLine:x}),l)})}function mn(e){if(e.local){if(e.closed)return{status:`unavailable`,reason:`This draft is closed.`}}else if(e.closed||!e.savable)return{status:`unavailable`,reason:`No focused savable document.`};return e.saving?{status:`unavailable`,reason:`A save is already running.`}:!e.local&&!e.dirty?{status:`unavailable`,reason:`No unsaved changes.`}:{status:`available`}}var hn=100,gn=1,_n=2,vn=3,yn=class{#e=[];#t=[];#n;#r=!1;constructor(e){this.#n=Math.max(1,e?.maxEntries??hn)}get canUndo(){return this.#e.length>0}get canRedo(){return this.#t.length>0}clear(){this.#e.length=0,this.#t.length=0,this.#r=!1}clearRedo(){this.#t.length=0}push(e){this.#e.push(e),this.clearRedo(),this.#r=!0,this.#e.length>this.#n&&this.#e.shift()}setLastUndoSelectionsAfter(e){let t=this.#e[this.#e.length-1];t!==void 0&&(t.selectionsAfter=e.map(e=>({...e})))}setLastUndoLineAnnotations(e,t){let n=this.#e[this.#e.length-1];n!==void 0&&(n.lineAnnotationsBefore=e.slice(),n.lineAnnotationsAfter=t.slice())}peekUndo(){return this.#e[this.#e.length-1]}peekUndoForCoalescing(){return this.#r?this.peekUndo():void 0}replaceLastUndo(e){if(this.#e.length===0){this.push(e);return}this.#e[this.#e.length-1]=e,this.clearRedo(),this.#r=!0}popUndoToRedo(){let e=this.#e.pop();if(e!==void 0)return this.#t.push(e),this.#r=!1,e}popRedoToUndo(){let e=this.#t.pop();if(e!==void 0)return this.#e.push(e),this.#r=!1,e}};function bn(e,t,n,r,i,a,o,s){let c=[...t].sort((e,t)=>e.start-t.start),l=[],u;if(i?.length===c.length){let t=[];for(let n of i){if(n.start.line!==n.end.line||n.start.character!==n.end.character)break;t.push(e.offsetAt(n.start))}if(t.length===c.length){t.sort((e,t)=>e-t);let e=!0,n=!0;for(let r=0;r<c.length;r++){let i=c[r];if(i.text.length>0||i.start===i.end){e=!1,n=!1;break}e&&=t[r]===i.end,n&&=t[r]===i.start}u=e?_n:n?vn:void 0}}for(let t=0,n=0;t<c.length;t++){let r=c[t],i=e.getTextSlice(r.start,r.end),a=r.start+n;l.push({start:a,end:a+r.text.length,text:i}),n+=r.text.length-(r.end-r.start)}return{forwardEdits:c.map(e=>({...e})),inverseEdits:l,versionBefore:n,versionAfter:r,selectionsBefore:i?.map(e=>({...e})),selectionsAfter:a?.map(e=>({...e})),lineAnnotationsBefore:o?.slice(),lineAnnotationsAfter:s?.slice(),coalescingMode:u}}function xn(e,t){if(e===void 0||e.undoBoundary===!0||t.undoBoundary===!0||e.forwardEdits.length===0||e.forwardEdits.length!==e.inverseEdits.length||e.forwardEdits.length!==t.forwardEdits.length||t.forwardEdits.length!==t.inverseEdits.length)return!1;let n;for(let r=0;r<e.forwardEdits.length;r++){let i=e.forwardEdits[r],a=e.inverseEdits[r],o=t.forwardEdits[r],s=t.inverseEdits[r],c=wn(o.start,e.forwardEdits),l=i.start<=i.end&&i.text.length>0&&!i.text.includes(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,$a as n,A as r,B as i,Ba as a,Bi as o,Bn as s,Bt as c,C as l,Cn as u,D as d,Dn as f,E as p,En as m,F as h,Fa as g,Fi as _,G as v,Ga as y,Gi as b,Gr as x,Gt as S,H as C,Ha as w,Hi as T,Hr as E,Ht as D,I as O,Ia as k,Ii as A,J as j,Ja as M,Ji as N,Jr as P,K as F,Ki as I,Kr as L,L as R,La as ee,Li as te,Ln as ne,Lr as re,M as ie,Ma as ae,N as oe,Na as se,Nn as ce,O as le,Oa as ue,P as z,Pa as de,Q as fe,Qa as pe,Qi as me,Qr as B,Ra as he,Ri as ge,Rt as _e,S as ve,Sn as ye,St as be,T as xe,Tn as Se,U as Ce,Ua as we,Ui as Te,Ur as Ee,Ut as V,V as De,Va as Oe,Vi as ke,Vt as Ae,W as je,Wa as Me,Wi as Ne,Wr as Pe,X as Fe,Xa as Ie,Xi as Le,Y as Re,Ya as ze,Yi as Be,Yr as Ve,Za as He,Zi as Ue,Zt as We,_n as Ge,_r as Ke,a as qe,aa as Je,ai as Ye,b as Xe,ba as Ze,bt as Qe,c as $e,ca as et,ci as tt,cn as nt,ct as rt,d as it,da as at,di as ot,dr as H,ei as st,et as ct,fi as lt,g as ut,ga as U,gr as dt,h as ft,hr as pt,i as mt,ii as ht,in as gt,j as _t,jn as W,k as vt,kn as yt,li as bt,lr as xt,m as St,mr as Ct,n as wt,na as Tt,ni as Et,nn as G,nt as Dt,oa as K,oi as Ot,on as kt,p as At,pa as jt,pn as Mt,q as Nt,qt as Pt,ra as Ft,ri as It,rt as Lt,s as Rt,sa as zt,si as Bt,st as Vt,ti as Ht,tn as Ut,tt as Wt,u as Gt,ua as Kt,ui as qt,ur as q,ut as Jt,v as Yt,wn as Xt,x as Zt,y as Qt,yr as $t,yt as en,z as tn,za as nn,zi as rn,zn as an}from"./tree-path-CnRRWDW0.js";import{C as on,D as sn,Ft as cn,O as ln,Rt as un,_ as dn,a as fn,b as J,c as pn,f as mn,g as hn,h as gn,i as _n,l as vn,m as yn,n as bn,o as xn,p as Sn,r as Cn,s as wn,t as Tn,u as En,v as Dn,w as On,x as kn,y as An}from"./changes-patch-BR_5GLNZ.js";import{a as jn,c as Mn,d as Nn,f as Pn,i as Fn,l as In,n as Ln,o as Rn,p as zn,r as Bn,s as Vn,t as Hn,u as Un}from"./useForm-5V_Bjs-x.js";import{n as Wn,r as Gn,t as Kn}from"./useFileTree-D36ddtur.js";var qn=I(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);ge.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>rn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ke(e,t,n),e.parseAsync=async(t,n)=>o(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>T(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0}),e.with=e.check,e.clone=(t,n)=>Te(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),Jn=I(`ZodMiniObject`,(e,t)=>{te.init(e,t),qn.init(e,t),Ne(e,`shape`,()=>t.shape)});function Yn(e,t){return new Jn({type:`object`,shape:e??{},...b(t)})}var Xn=I(`ZodMiniLiteral`,(e,t)=>{A.init(e,t),qn.init(e,t)});function Zn(e,t){return new Xn({type:`literal`,values:Array.isArray(e)?e:[e],...b(t)})}var Qn=q(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),$n=q(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),er=q(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),tr=q(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),nr=q(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),rr=q(`FolderPlus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ir=q(`RotateCcw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Y=e(Be(),1);function ar(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=nt({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=D(a,!0,!0),d=Pt(),[f,p]=Y.useState(),m=f===null?void 0:f??d,h=G(e=>{let t=!a,n=S(u,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return Y.useMemo(()=>({defaultPanelId:d,disabled:i,handleTrigger:h,mounted:s,open:a,panelId:m,setMounted:c,setOpen:o,setPanelIdState:p,transitionStatus:l}),[d,i,h,s,a,m,c,o,p,l])}var or=Y.createContext(void 0);function sr(){let e=Y.useContext(or);if(e===void 0)throw Error(an(15));return e}var cr=`data-open`,lr=`data-closed`,ur=yt,dr=`data-panel-open`,fr={[cr]:``},pr={[lr]:``},mr={open(e){return e?{[dr]:``}:null}},hr={open(e){return e?fr:pr},...f},X=N(),gr=Y.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=G(o),d=ar({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=Y.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=Y.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=W(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:hr});return(0,X.jsx)(or.Provider,{value:p,children:m})}),_r={...mr,...f},vr=Y.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=sr(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=We({disabled:c,native:u});return W(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:_r})}),Z={height:void 0,width:void 0};function yr(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:l,setOpen:u,transitionStatus:d}=e,f=Y.useRef(null),p=Y.useRef(null),[m,h]=Y.useState(Z),g=Y.useRef(Z),_=Y.useRef(!1),v=Y.useRef(s),y=Y.useRef(!1),[b,x]=Y.useState(!1),C=Y.useRef(null),w=ne(t,f),T=Qe(s),E=Ae(f),D=!s&&!a,O=b?`idle`:d,k=s&&(v.current||y.current),A=!s&&a&&p.current===`css-animation`&&m.height===void 0&&m.width===void 0?g.current:m,j=n&&D&&p.current!==`css-animation`,M=G((e,t=!0)=>{t&&(g.current=e),h(e)}),N=G(()=>{C.current?.(),C.current=null}),P=G(e=>{N(),C.current=()=>{C.current=null,e()}}),F=G(()=>{s&&a&&p.current===`css-animation`&&(y.current=!0)});Ut(()=>{!b||d===`starting`||x(!1)},[b,d]),Y.useEffect(()=>()=>{F(),N()},[F,N]),Ut(()=>{s||(v.current=!1,y.current=!1);let e=f.current;if(!e)return;!s&&C.current&&N();let t=br(e,k);if(p.current=t,s&&d===`idle`&&v.current&&t===`css-animation`){g.current=Q(e);return}if(s&&d===`starting`){let n=_.current;if(_.current=!1,t===`none`){M(Q(e)),x(!0);return}if(t===`css-transition`){let t=Cr(e);if(M(Q(e)),!n)return t;let r=Sr(e,`transition-duration`,`0s`);return P(r),x(!0),t}M(Q(e));let r=Sr(e,`animation-name`,`none`);if(!n){r();return}let i=Sr(e,`animation-duration`,`0s`);r(),P(i),x(!0);return}if(!s&&a&&(d===`idle`||d===`starting`)){if(t===`none`){M(Z,!1),l(!1);return}M(Q(e));return}if(d!==`ending`)return;if(t===`none`){l(!1);return}let n=Q(e);if(!(n.height>0||n.width>0)){l(!1);return}M(n),t===`css-animation`&&Sr(e,`animation-name`,`none`)()},[a,s,N,M,l,P,k,d]),c({enabled:s&&a&&O===`idle`,open:!0,ref:f,onComplete(){s&&M(Z,!1)}}),Y.useEffect(()=>{if(s||!a||O!==`ending`)return;if(!f.current){l(!1),M(Z,!1);return}let e=new AbortController,t=-1;function n(){T.current||(l(!1),M(Z,!1))}return t=V.request(()=>{E(n,e.signal)}),()=>{V.cancel(t),e.abort()}},[T,a,s,O,E,M,l]),Ut(()=>{let e=f.current;!e||!n||!D||e.setAttribute(`hidden`,`until-found`)},[D,n]),Y.useEffect(function(){let e=f.current;if(!e)return;let t=_e.create(),n=-1,r=(r,i)=>{t.start(0,()=>{T.current||(n=V.request(()=>{T.current||(r&&(_.current=!1),i&&e.setAttribute(ur,``),e.setAttribute(`hidden`,`until-found`))}))})},i=be(e,`beforematch`,t=>{let n=S(Ge,t);if(o(!0,n),n.isCanceled){r(!1,!1);return}_.current=!0;let i=e.hasAttribute(ur);e.removeAttribute(ur),u(!0),r(!0,i)});return()=>{t.clear(),V.cancel(n),i()}},[T,o,u]);let I=i||n||a||s;return{height:A.height,props:{...j?{[ur]:``}:void 0,hidden:D,id:r},ref:w,shouldPreventOpenAnimation:k,shouldRender:I,transitionStatus:O,width:A.width}}function Q(e){return{height:e.scrollHeight,width:e.scrollWidth}}function br(e,t){let n=gt(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&xr(n.animationDuration),i=xr(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function xr(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function Sr(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function Cr(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=V.request(n);return()=>{V.cancel(r),n()}}var wr=`--collapsible-panel-height`,Tr=`--collapsible-panel-width`,Er=Y.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=sr(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;Ut(()=>(m(e=>b??(e===null?void 0:e)),()=>{m(e=>e===b?null:e)}),[b,m]);let{height:S,props:C,ref:w,shouldPreventOpenAnimation:T,shouldRender:E,transitionStatus:D,width:O}=yr({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),k={...g,transitionStatus:D},A=ce(s,k),j=W(`div`,{...e,style:void 0},{state:k,ref:w,props:[C,{style:{[wr]:S===void 0?`auto`:`${S}px`,[Tr]:O===void 0?`auto`:`${O}px`}},c,A?{style:A}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:hr});return E?j:null}),Dr=P(`caps-disclosure`,{variants:{tone:{neutral:``,error:`caps-disclosure-error`},size:{group:`caps-disclosure-group`,row:`caps-disclosure-row`}},defaultVariants:{tone:`neutral`,size:`group`}});function Or({open:e,onOpenChange:t,summary:n,leading:r,trailing:i,children:a,tone:o,size:s,className:c}){return(0,X.jsxs)(gr,{className:L(Dr({tone:o,size:s}),c),onOpenChange:t,open:e,children:[(0,X.jsxs)(vr,{className:`caps-disclosure-trigger`,children:[r===void 0?null:(0,X.jsx)(`span`,{className:`caps-disclosure-leading`,children:r}),(0,X.jsx)(`span`,{className:`caps-disclosure-summary`,children:n}),i===void 0?null:(0,X.jsx)(`span`,{className:`caps-disclosure-trailing`,children:i}),(0,X.jsx)($n,{"aria-hidden":`true`,className:`caps-disclosure-chevron`,size:12})]}),(0,X.jsx)(Er,{className:`caps-disclosure-panel`,children:a})]})}function kr({app:e,rootPath:t,rootLabel:n=`Computer`,activePath:r,onOpenFile:i,onSelectPath:a,rowHeight:o=32}){let{scope:s,snapshot:c,focusedPath:l,requestPage:u,reload:d}=hn({app:e,rootPath:t,activePath:r}),f=(0,Y.useRef)({activePath:r,onOpenFile:i,onSelectPath:a,rootLabel:n});f.current={activePath:r,onOpenFile:i,onSelectPath:a,rootLabel:n};let p=(0,Y.useRef)(u);p.current=u;let{model:m}=Kn({paths:[],itemHeight:o,initialExpansion:2,flattenEmptyDirectories:!1,composition:{contextMenu:{enabled:!0}},renderRowDecoration:({row:e})=>e.path===`/`?{text:f.current.rootLabel}:null,unsafeCSS:`[data-item-section="content"] { display: flex; align-items: center; }[data-item-path="/"] [data-item-section="decoration"] { justify-content: flex-start; color: inherit; }`,onSelectionChange(e){let t=e[0];t&&(f.current.onSelectPath?.(t),t.endsWith(`/`)?p.current(t,0):t!==f.current.activePath&&f.current.onOpenFile(t))}}),h=(0,Y.useRef)(En()),g=(0,Y.useRef)(null);(0,Y.useLayoutEffect)(()=>{Sn(m,h.current),g.current=null},[m,s]),(0,Y.useLayoutEffect)(()=>{g.current=null;for(let e of m.getSelectedPaths())!e.endsWith(`/`)&&e!==r&&m.getItem(e)?.deselect()},[r,m]),(0,Y.useLayoutEffect)(()=>{if(c.listings.length===0&&(g.current=null),gn(m,c.listings,h.current),!r||g.current===r)return;let e=yn(r,t);if(!e.every(e=>h.current.known.has(e)))return;for(let t of e){let e=m.getItem(t);e&&`expand`in e&&e.expand()}let n=m.getItem(r);n&&(g.current=r,n.select(),m.scrollToPath(r,{focus:!1}))},[r,m,t,s,c.listings]),(0,Y.useEffect)(()=>{c.failure&&console.error(`Inkcap directory listing failed`,un(c.failure))},[c.failure]);let _=c.listings.filter(({request:e})=>e.path===l).sort((e,t)=>e.request.offset-t.request.offset).at(-1)?.listing,v={path:_?.path??l,next:_?.nextOffset??null},y=c.listings.some(({request:e,listing:n})=>e.path===t&&e.offset===0&&n.entries.length===0&&n.nextOffset===null),b=d;return{model:m,page:v,error:c.failure?`${B(c.failure).message} Your open files remain available.`:``,busy:c.busy,rootEmpty:y,reloadRoot:b,noteCreated:e=>{let t=e.split(`/`).filter(Boolean).at(-1)??``;!mn({name:t,type:``})&&!m.getItem(e)&&m.batch([{type:`add`,path:e}]),b()},loadNext:()=>{v.next!==null&&u(v.path,v.next)}}}var Ar=U(K),jr=U(zt({message:K}));function Mr(e){for(let t of e.errors){let e=ze(n(He(jr(t),e=>e.message),()=>Ar(t)));if(e!==void 0&&e.length>0)return e}}var Nr={neutral:`progress-neutral`,primary:`progress-primary`,secondary:`progress-secondary`,accent:`progress-accent`,success:`progress-success`,info:`progress-info`,warning:`progress-warning`,error:`progress-error`},Pr=(0,Y.forwardRef)(function({className:e,tone:t=`primary`,...n},r){return(0,X.jsx)(`progress`,{...n,"data-complete":n.value!==void 0&&Number(n.value)>=Number(n.max??1)?`true`:void 0,className:L(`progress caps-gooey-motion caps-gooey-progress w-full`,Nr[t],e),ref:r})});(0,Y.forwardRef)(function({label:e,value:t,max:n,tone:r=`info`,className:i,...a},o){return(0,X.jsxs)(`div`,{...a,ref:o,className:L(`caps-game-meter`,i),children:[(0,X.jsxs)(`div`,{className:`caps-game-meter-readout`,children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsxs)(`span`,{className:`caps-game-meter-value`,children:[t,` / `,n]})]}),(0,X.jsx)(Pr,{"aria-label":e,value:t,max:n,tone:r})]})});function Fr({className:e,items:t,onCancel:n,onRemove:r,onRetry:i,rowClassName:a}){return t.length?(0,X.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,X.jsx)(Rr,{item:e,onCancel:n,onRemove:r,onRetry:i,...a===void 0?{}:{rowClassName:a}},e.id))}):null}function Ir({action:e,id:t,onAction:n,retry:r=!1}){return e?(0,X.jsx)(s,{"aria-label":e.accessibleLabel,title:e.label,variant:`ghost`,size:`xs`,className:`motion-reduce:transition-none`,icon:r?(0,X.jsx)(ir,{}):(0,X.jsx)(xt,{}),onClick:()=>void n(t),type:`button`}):null}function Lr({item:e}){return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{className:`block min-w-0 truncate`,title:e.name,children:e.name}),(0,X.jsx)(`div`,{className:`caps-upload-details`,children:(0,X.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 Rr({item:e,onCancel:t,onRemove:n,onRetry:r,rowClassName:i}){return(0,X.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,X.jsx)(`img`,{alt:``,className:`caps-upload-preview mask mask-squircle size-8 shrink-0 object-cover`,src:e.preview.url}):(0,X.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,X.jsx)(nr,{className:`size-4`})}),(0,X.jsx)(Lr,{item:e}),(0,X.jsx)(zr,{actions:e.actions,id:e.id,onCancel:t,onRemove:n,onRetry:r}),(0,X.jsx)(Pr,{"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 zr({actions:e,id:t,onCancel:n,onRemove:r,onRetry:i}){return(0,X.jsxs)(`div`,{className:`caps-upload-actions flex min-w-0 flex-wrap justify-end gap-xs`,children:[(0,X.jsx)(Ir,{action:e.retry,id:t,onAction:i,retry:!0}),(0,X.jsx)(Ir,{action:e.cancel,id:t,onAction:n}),(0,X.jsx)(Ir,{action:e.remove,id:t,onAction:r})]})}var Br={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`},Vr={blurStdDeviation:.22,alphaSlope:18,alphaIntercept:-8};function Hr({state:e}){let t=`caps-checkbox-${(0,Y.useId)().replaceAll(`:`,``)}`,n=(0,Y.useRef)(null),r=(0,Y.useRef)(e).current,i=(0,Y.useRef)(e),a=x();return(0,Y.useLayoutEffect)(()=>{if(!n.current)return;let t=e!==`unchecked`,r=i.current!==`unchecked`,o=a||i.current===e;i.current=e;let s=Ee(n.current),c=J(s,{ease:`inCubic`,duration:160}),l=$t(n.current,{d:{to:Br[e],...o?An:J(s,{ease:`outCubic`,duration:200})},"stroke-dashoffset":{to:+!t,...o?An:t?J(s,{ease:`inOutSine`,duration:260}):c},"stroke-width":o?{to:t?2.4:0,duration:0}:t&&!r?[{to:2.2,...J(s,{ease:`outCubic`,duration:65})},{to:2.4,delay:E(s,120),...kn(s,{bounce:.35,duration:220})}]:{to:t?2.4:0,...c}});return()=>{l.cancel()}},[e,a]),(0,X.jsxs)(`svg`,{className:`caps-checkbox-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(Ke,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(dt,{id:`${t}-shadow`}),(0,X.jsx)(pt,{id:`${t}-inset`}),(0,X.jsx)(Ct,{id:`${t}-goo`,values:Vr}),(0,X.jsxs)(`filter`,{id:`${t}-relief`,x:`-25%`,y:`-25%`,width:`150%`,height:`150%`,colorInterpolationFilters:`sRGB`,children:[(0,X.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`0.28`,result:`relief`}),(0,X.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,X.jsx)(`feDistantLight`,{azimuth:`225`,elevation:`55`})}),(0,X.jsx)(`feComposite`,{in:`light`,in2:`SourceAlpha`,operator:`in`,result:`clipped-light`}),(0,X.jsx)(`feBlend`,{in:`SourceGraphic`,in2:`clipped-light`,mode:`screen`})]}),(0,X.jsx)(`mask`,{id:`${t}-contour`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`12`,height:`12`,style:{maskType:`alpha`},children:(0,X.jsx)(`path`,{ref:n,d:Br[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,X.jsx)(`clipPath`,{id:`${t}-well`,children:(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`10`,height:`10`,rx:`2.5`})})]}),(0,X.jsx)(`rect`,{className:`caps-checkbox-track`,x:`0.5`,y:`0.5`,width:`11`,height:`11`,rx:`3`,filter:`url(#${t}-inset)`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,X.jsx)(`g`,{filter:`url(#${t}-shadow)`,children:(0,X.jsx)(`g`,{filter:`url(#${t}-relief)`,children:(0,X.jsx)(`g`,{mask:`url(#${t}-contour)`,children:(0,X.jsx)(`rect`,{x:`0`,y:`0`,width:`12`,height:`12`,fill:`url(#${t}-surface)`})})})})})]})}var Ur=(0,Y.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,Y.useRef)(null),[d,f]=(0,Y.useState)(o),p=a??d,m=i?`mixed`:p?`checked`:`unchecked`;return(0,Y.useImperativeHandle)(l,()=>{if(!u.current)throw Error(`Checkbox input is not mounted`);return u.current},[]),(0,Y.useLayoutEffect)(()=>{u.current&&(u.current.indeterminate=i)},[i]),(0,Y.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,X.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,X.jsx)(`input`,{...c,checked:p,"aria-checked":i?`mixed`:p,"aria-invalid":r?!0:c[`aria-invalid`]===!1?void 0:c[`aria-invalid`],className:L(`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,X.jsx)(Hr,{state:m}):n]})}),Wr=Yn({keyCode:Zn(229)});function Gr(e){return e.nativeEvent.isComposing||ke(Wr,e.nativeEvent).success}var Kr=Y.createContext(void 0);function qr(e){let t=Y.useContext(Kr);if(t===void 0&&!e)throw Error(an(47));return t}var Jr=e(Ve(),1),Yr={...z,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!z.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&z.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>z.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},Xr=class extends h{constructor(e,t,n){let r=new tn;super(Zr(e,r,t,n),Qr(r),Yr)}setOpen=(e,t)=>{let n=t.reason===ye,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=C(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=je(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}),Jr.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function Zr(e,t,n,r=!1){let i={...oe(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 Qr(e){return{popupRef:Y.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:Y.createRef(),beforeTriggerFocusGuardRef:Y.createRef(),beforeContentFocusGuardRef:Y.createRef(),stickIfOpenTimeout:new _e,stickIfOpen:!0,triggerElements:e}}var $r=O(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=ti(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),Re(u,d),v(u);let{forceUnmount:m}=F(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),Y.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),Y.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,S(Mt))}),[m,u]);let h=d||f||s!=null;return(0,X.jsxs)(Kr.Provider,{value:u,children:[s&&(0,X.jsx)(De,{handle:s,store:u}),h&&(0,X.jsx)(ni,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function ei(e){return qr(!0)?(0,X.jsx)($r,{props:e}):(0,X.jsx)(Dt,{children:(0,X.jsx)($r,{props:e})})}function ti(e,t){let n=j((e,n)=>new Xr(t,e,n));return Y.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function ni({store:e,modal:t}){let n=e.useState(`floatingRootContext`),r=fe(n,{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),i=r.reference,a=r.floating;return Nt(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}var ri=R(function(e,n){let{render:i,className:a,style:o,disabled:s=!1,nativeButton:c=!0,handle:l,payload:u,openOnHover:d=!1,delay:f=300,closeDelay:p=0,id:h,...g}=e,_=qr(!0),v=ie(l)??_;if(!v)throw Error(an(74));let y=Pt(h),b=v.useState(`isTriggerActive`,y),x=v.useState(`floatingRootContext`),S=v.useState(`isOpenedByTrigger`,y),C=v.useState(`triggerPopupId`,y),w=Y.useRef(null),{registerTrigger:T,isMountedByThisTrigger:E}=Fe(y,w,v,{payload:u,disabled:s,openOnHover:d,closeDelay:p}),D=v.useState(`isPressOpenedByTrigger`,y),O=v.useState(`isTouchPressOpen`,d),k=v.useState(`hasTriggerFocusGuards`,y),A=r(x,{enabled:!s&&d&&!O,mouseOnly:!0,move:!1,handleClose:vt(),restMs:f,delay:{close:p},triggerElementRef:w,isActiveTrigger:b,isClosing:()=>v.select(`transitionStatus`)===`ending`}),j=G(()=>v.context.stickIfOpen),M=t(x,{stickIfOpen:j}),N=Yt(()=>v.select(`open`),e=>{v.set(`openMethod`,e)}),P=v.useState(`triggerProps`,E),{getButtonProps:F,buttonRef:I}=We({disabled:s,native:c}),L={open(e){return D?Se.open(e):m.open(e)}},{handlePreFocusGuardFocus:R,handleFocusTargetFocus:ee}=ut(v,w),te=W(`button`,e,{state:{disabled:s,open:S},ref:[I,n,T,w],props:[M.reference,A,P,N,{[rt]:``,id:y,"aria-haspopup":`dialog`,"aria-expanded":S,"aria-controls":C},g,F],stateAttributesMapping:L}),ne=(0,X.jsx)(Y.Fragment,{children:te},y);return k?(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsx)(en,{ref:v.context.beforeTriggerFocusGuardRef,onFocus:R}),ne,(0,X.jsx)(en,{ref:v.context.triggerFocusTargetRef,onFocus:ee})]}):ne}),ii=Y.createContext(void 0);function ai(){let e=Y.useContext(ii);if(e===void 0)throw Error(an(45));return e}var oi=Y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return qr().useState(`mounted`)||n?(0,X.jsx)(ii.Provider,{value:n,children:(0,X.jsx)(Vt,{ref:t,...r})}):null}),si=Y.createContext(void 0);function ci(){let e=Y.useContext(si);if(!e)throw Error(an(46));return e}var li=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:u,alignOffset:d,collisionBoundary:f=`clipping-ancestors`,collisionPadding:p,arrowPadding:m,sticky:h,disableAnchorTracking:g=!1,collisionAvoidance:_=Jt,...v}=e,y=qr(),b=ai(),x=Lt(),S=y.useState(`floatingRootContext`),C=y.useState(`mounted`),w=y.useState(`open`),T=y.useState(`openChangeReason`),E=y.useState(`activeTriggerElement`),D=y.useState(`modal`),O=y.useState(`openMethod`),k=y.useState(`positionerElement`),A=y.useState(`instantType`),j=y.useState(`transitionStatus`),M=y.useState(`adaptiveOrigin`),N=l({anchor:a,floatingRootContext:S,positionMethod:o,mounted:C,side:s,sideOffset:u,align:c,alignOffset:d,arrowPadding:m,collisionBoundary:f,collisionPadding:p,sticky:h,disableAnchorTracking:g,keepMounted:b,nodeId:x,collisionAvoidance:_,adaptiveOrigin:M}),P=S.useState(`domReferenceElement`);Zt({store:y,domReference:P,positionerElement:k,open:w});let F=D===!0&&T!==`trigger-hover`;Qt(w&&F,O===`touch`,k,E);let I=y.useStateSetter(`positionerElement`),L={open:w,side:N.side,align:N.align,anchorHidden:N.anchorHidden,instant:A},R=Xe(e,L,{styles:N.positionerStyles,transitionStatus:j,props:v,refs:[t,I],hidden:!C,inert:!w});return(0,X.jsxs)(si.Provider,{value:N,children:[C&&F&&(0,X.jsx)(ve,{inert:xe(!w),cutout:E}),(0,X.jsx)(Wt,{id:x,children:R})]})}),ui=Y.createContext(void 0);function di(){let[e,t]=Y.useState(0),n=G(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:Y.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var fi=Y.forwardRef(function(e,t){let{render:n,className:r,style:a,initialFocus:o,finalFocus:s,...l}=e,u=qr(),f=ci(),m=le(!0)!=null,{context:h,hasClosePart:g}=di(),_=u.useState(`open`),v=u.useState(`openMethod`),y=u.useState(`instantType`),b=u.useState(`transitionStatus`),x=u.useState(`popupProps`),S=u.useState(`titleElementId`),C=u.useState(`descriptionElementId`),w=u.useState(`modal`),T=u.useState(`mounted`),E=u.useState(`openChangeReason`),D=u.useState(`activeTriggerElement`),O=u.useState(`floatingRootContext`),k=O.useState(`floatingId`),A=u.useState(`disabled`),j=u.useState(`openOnHover`),M=u.useState(`closeDelay`);c({open:_,ref:u.context.popupRef,onComplete(){_&&u.context.onOpenChangeComplete?.(!0)}}),_t(O,{enabled:j&&!A,closeDelay:M});let N=o===void 0?Ce(u.context.popupRef):o,P=w!==!1&&g;u.useSyncedValue(`focusManagerModal`,P);let F=u.useStateSetter(`popupElement`),I={open:_,side:f.side,align:f.align,instant:y,transitionStatus:b},L=W(`div`,e,{state:I,ref:[t,u.context.popupRef,F],props:[x,{id:k,role:`dialog`,...i,"aria-labelledby":S,"aria-describedby":C,onKeyDown(e){m&&d.has(e.key)&&e.stopPropagation()}},p(b),l],stateAttributesMapping:Xt});return(0,X.jsx)(ct,{context:O,openInteractionType:v,modal:P,disabled:!T||E===`trigger-hover`,initialFocus:N,returnFocus:s,restoreFocus:`popup`,getInsideElements:()=>[u.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:kt(D)?D:void 0,nextFocusableElement:u.context.triggerFocusTargetRef,beforeContentFocusGuardRef:u.context.beforeContentFocusGuardRef,children:(0,X.jsx)(ui.Provider,{value:h,children:L})})});function pi({getKey:e,isDisabled:t=()=>!1,items:n,getFallbackKey:r}){let i=(0,Y.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]),[a,o]=(0,Y.useState)(null),s=r?.(i)??null,c=a!==null&&i.some(t=>e(t)===a)?a:s!==null&&i.some(t=>e(t)===s)?s:null;(0,Y.useEffect)(()=>{a!==null&&!i.some(t=>e(t)===a)&&o(null)},[a,i,e]);let l=i.find(t=>e(t)===c),u=l?i.findIndex(t=>e(t)===c):-1;return{activeIndex:u,activeItem:l,activeKey:c,enabledItems:i,move:(t,n)=>{if(i.length===0)return;let r=n?n===`start`?0:i.length-1:u<0?t>0?0:i.length-1:(u+t+i.length)%i.length,a=i[r];a&&o(e(a))},setActiveKey:o}}var mi=(0,Y.forwardRef)(function({children:e,className:t,type:n=`button`,...r},i){return(0,X.jsxs)(`button`,{...r,ref:i,type:n,className:L(`select caps-select caps-combobox-trigger w-full`,t),children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(vn,{className:`caps-select-chevron`,"aria-hidden":`true`})]})});function hi({defaultInputValue:e,defaultOpen:t,defaultValue:n,getKey:r,getSearchText:i,groupBy:a,id:o,isDisabled:s,items:c,onOpenChange:l,onCommit:u,multiple:d,controlledOpen:f,controlledKeys:p,trigger:m}){let h=`${o}-listbox`,[g,_]=(0,Y.useState)(e),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(n),[S,C]=(0,Y.useState)(t),w=p??(b===null?[]:[b]),T=m?f??S:!0,E=(0,Y.useMemo)(()=>{let e=g.trim().toLowerCase();return e?c.filter(t=>i(t).toLowerCase().includes(e)):c},[i,c,g]),D=pi({getKey:r,isDisabled:s,items:E});(0,Y.useEffect)(()=>{if(D.activeKey!==null)return;let e=D.enabledItems.find(e=>w.includes(r(e)))??D.enabledItems[0];e&&D.setActiveKey(r(e))},[D.activeKey,D.enabledItems,D.setActiveKey,r,w]);let O=e=>{y(!1),e||_(``),f===void 0&&C(e),l?.(e)},k=e=>`${h}-option-${encodeURIComponent(e)}`,A=e=>{let t=r(e);p===void 0&&x(t),u(e),m&&!d&&O(!1)},j=e=>{y(!0),_(e.target.value),D.setActiveKey(null)},M=e=>{if(Gr(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?(y(!0),e.preventDefault(),D.move(t[0],t[1])):e.key===`Enter`&&D.activeItem&&(e.preventDefault(),A(D.activeItem))},N=(0,Y.useMemo)(()=>{if(!a)return[{label:``,items:E}];let e=new Map;for(let t of E){let n=a(t),r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e].map(([e,t])=>({label:e,items:t}))},[E,a]);return{keyboardNavigation:v,onPointerMove:()=>{y(!1)},activeKey:D.activeKey,activeItem:D.activeItem,groups:N,inputValue:g,listboxId:h,onInputChange:j,onInputKeyDown:M,optionId:k,open:T,commit:A,selectedKeys:w,setOpen:O}}function gi(e){let{"aria-describedby":t,"aria-invalid":n,"aria-label":r,"aria-labelledby":i,"aria-required":a,activeTone:o=`neutral`,container:s,contentClassName:c,defaultInputValue:l=``,defaultOpen:u=!1,defaultValue:d=null,emptyMessage:f=`No matches`,getKey:p,getLabel:m,getSearchText:h=m,groupBy:g,id:_,inputProps:v,inputRef:y,isDisabled:b=()=>!1,items:x,onOpenChange:S,onValueChange:C,multiple:w,open:T,placeholder:E=`Search…`,renderItem:D,rootRef:O,trigger:k,triggerRef:A,value:j,...M}=e,N=e=>{let t=p(e);if(w){let e=j.includes(t)?j.filter(e=>e!==t):[...j,t];C?.(e,x.filter(t=>e.includes(p(t))))}else C?.(t,e)},P;w?P=j:j!==void 0&&(P=j===null?[]:[j]);let F=(0,Y.useId)(),I=k?.props??v,R=_??I?.id??F,ee={id:R,"aria-describedby":[t,I?.[`aria-describedby`]].filter(Boolean).join(` `)||void 0,"aria-invalid":n??I?.[`aria-invalid`],"aria-label":I?.[`aria-label`]??r,"aria-labelledby":I?.[`aria-labelledby`]??i,"aria-required":a??I?.[`aria-required`]},{keyboardNavigation:te,onPointerMove:ne,activeItem:re,activeKey:ie,commit:ae,groups:oe,inputValue:se,listboxId:ce,onInputChange:le,onInputKeyDown:ue,open:z,optionId:de,selectedKeys:fe,setOpen:pe}=hi({defaultInputValue:l,defaultOpen:u,defaultValue:d,getKey:p,getSearchText:h,groupBy:g,id:R,isDisabled:b,items:x,onOpenChange:S,onCommit:N,multiple:w??!1,controlledOpen:T,controlledKeys:P,trigger:k});At(()=>{k&&pe(!1)});let me=St(`popover`),B=s===void 0?me:s,he=ft(`.caps-combobox-option[data-active="true"]:not(:disabled), [data-navigation="pointer"] .caps-combobox-option:hover:not(:disabled)`),ge=(0,X.jsx)(zn,{...v,...k?{}:ee,"aria-activedescendant":re?de(p(re)):void 0,"aria-autocomplete":`list`,"aria-controls":ce,"aria-expanded":!0,className:L(`input-sm`,v?.className),id:k?v?.id??`${R}-input`:R,onChange:e=>{v?.onChange?.(e),le(e)},onKeyDown:e=>{v?.onKeyDown?.(e),e.defaultPrevented||ue(e)},placeholder:v?.placeholder??E,ref:y,role:`combobox`,value:se}),_e=(0,X.jsx)(`div`,{id:ce,ref:he,className:`caps-combobox-list`,"data-navigation":te?`keyboard`:`pointer`,onPointerMove:ne,role:`listbox`,"aria-multiselectable":w??void 0,children:oe.every(e=>e.items.length===0)?(0,X.jsx)(`div`,{className:`px-md py-md text-sm text-base-content`,children:f}):oe.map(e=>(0,X.jsxs)(`div`,{"aria-label":e.label||void 0,role:e.label?`group`:void 0,children:[e.label?(0,X.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=p(e),n=b(e),r=ie===t,i={active:r,disabled:n,selected:fe.includes(t)};return(0,X.jsxs)(`button`,{"aria-disabled":n||void 0,"aria-selected":i.selected,className:`caps-combobox-option`,"data-active":r&&te,disabled:n,id:de(t),onClick:()=>{ae(e)},onMouseDown:e=>{e.preventDefault()},role:`option`,tabIndex:-1,type:`button`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`caps-combobox-check`,children:i.selected?(0,X.jsx)(Qn,{}):null}),D?.(e,r,i)??m(e)]},t)})]},e.label))});return k?(0,X.jsx)(`div`,{...M,className:L(M.className),ref:O,children:(0,X.jsxs)(ei,{modal:!0,onOpenChange:pe,open:z,children:[(0,X.jsx)(ri,{...ee,"aria-haspopup":`dialog`,className:`btn`,ref:A,render:k}),B===null?null:(0,X.jsx)(oi,{container:B,children:(0,X.jsx)(li,{align:`start`,side:`bottom`,sideOffset:4,children:(0,X.jsxs)(fi,{"data-active-tone":o,className:L(`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,X.jsx)(`div`,{className:`caps-combobox-search`,children:ge}),_e]})})})]})}):(0,X.jsx)(`div`,{...M,className:L(M.className),ref:O,children:(0,X.jsxs)(`div`,{className:L(`caps-combobox-panel`,c),"data-active-tone":o,children:[(0,X.jsx)(`div`,{className:`caps-combobox-search`,children:ge}),_e]})})}function _i({icon:e,caption:t}){return(0,X.jsxs)(`span`,{className:`caps-icon-choice-mark`,"aria-hidden":`true`,children:[(0,X.jsx)(`span`,{className:`caps-icon-choice-art`,children:e}),t?(0,X.jsx)(`span`,{className:`caps-icon-choice-caption`,children:t}):null,(0,X.jsx)(`span`,{className:`caps-icon-choice-lamp`})]})}var vi=(0,Y.forwardRef)(function({label:e,icon:t,caption:n,appearance:r,className:i,...a},o){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,"data-appearance":r===`compact`?r:void 0,children:(0,X.jsx)(Ur,{...a,appearance:r??`default`,"aria-label":e,className:L(`caps-icon-choice-input`,i),indicator:(0,X.jsx)(_i,{icon:t,caption:n}),ref:o})})}),yi=(0,Y.forwardRef)(function({label:e,icon:t,hint:n,className:r,...i},a){let o=(0,Y.useId)(),s=[i[`aria-describedby`],n?o:null].filter(Boolean).join(` `)||void 0;return(0,X.jsx)(`label`,{className:`caps-check-key`,children:(0,X.jsx)(Ur,{...i,"aria-label":e,"aria-describedby":s,className:L(`caps-check-key-input`,r),indicator:(0,X.jsxs)(`span`,{className:`caps-check-key-face`,"aria-hidden":`true`,children:[t?(0,X.jsx)(`span`,{className:`caps-check-key-icon`,children:t}):null,(0,X.jsxs)(`span`,{className:`caps-check-key-copy`,children:[(0,X.jsx)(`span`,{className:`caps-check-key-label`,children:e}),n?(0,X.jsx)(`span`,{className:`caps-check-key-hint`,id:o,children:n}):null]}),(0,X.jsx)(`span`,{className:`caps-check-key-lamp`})]}),ref:a})})});function bi({className:e,...t}){return(0,X.jsx)(`div`,{...t,className:L(`caps-check-keys`,e)})}function xi({checked:e}){let t=`caps-radio-${(0,Y.useId)().replaceAll(`:`,``)}`,n=(0,Y.useRef)(null),r=(0,Y.useRef)(e).current,i=(0,Y.useRef)(e),a=(0,Y.useRef)(null),o=Pe(a),{reduced:s}=o;return(0,Y.useLayoutEffect)(()=>{if(!n.current)return;let t=s||i.current===e;i.current=e;let r=e?4:0,a=J(o,{ease:`outCubic`,duration:75}),c=e?kn(o,{bounce:.65,duration:300}):J(o,{ease:`inCubic`,duration:100}),l=$t(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,X.jsxs)(`svg`,{ref:a,className:`caps-radio-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(Ke,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(dt,{id:`${t}-shadow`}),(0,X.jsx)(pt,{id:`${t}-inset`}),(0,X.jsx)(`clipPath`,{id:`${t}-well`,children:(0,X.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})})]}),(0,X.jsx)(`circle`,{className:`caps-radio-track`,cx:`6`,cy:`6`,r:`5.5`,filter:`url(#${t}-inset)`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,X.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 Si=(0,Y.createContext)(null),Ci=(0,Y.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,Y.useId)(),d=(0,Y.useRef)(null);(0,Y.useImperativeHandle)(l,()=>{if(!d.current)throw Error(`RadioGroup is not mounted`);return d.current},[]);let f=i??`radio-group-${u}`,[p,m]=(0,Y.useState)(n),h=s??p;return(0,Y.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,X.jsx)(Si.Provider,{value:{disabled:r,name:f,onValueChange:e=>{s===void 0&&m(e),a?.(e)},value:h},children:(0,X.jsx)(`fieldset`,{...c,className:L(`flex gap-md`,o===`horizontal`?`flex-row flex-wrap`:`flex-col`,t),disabled:r,role:c.role??`radiogroup`,ref:d,children:e})})}),wi=(0,Y.forwardRef)(function({className:e,indicator:t,onChange:n,onClick:r,value:i,...a},o){let s=(0,Y.useContext)(Si);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,X.jsxs)(`span`,{className:`caps-radio`,"data-checked":c,"data-custom-indicator":t!==void 0||void 0,children:[(0,X.jsx)(`input`,{...a,"aria-checked":c,checked:c,className:L(`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,X.jsx)(xi,{checked:c}):t]})}),Ti=(0,Y.forwardRef)(function({description:e,id:t,meta:n,title:r,...i},a){let o=(0,Y.useContext)(Si),s=(0,Y.useId)(),c=t??s,l=o?.value===i.value,u=o?.disabled===!0||i.disabled===!0;return(0,X.jsxs)(`label`,{className:`caps-choice-card`,"data-checked":l,"data-disabled":u||void 0,htmlFor:c,children:[(0,X.jsx)(wi,{...i,"aria-describedby":e?`${c}-description`:void 0,"aria-labelledby":`${c}-title`,id:c,ref:a}),(0,X.jsxs)(`span`,{className:`caps-choice-card-copy`,children:[(0,X.jsx)(`span`,{className:`caps-choice-card-title`,id:`${c}-title`,children:r}),e?(0,X.jsx)(`span`,{className:`caps-choice-card-description`,id:`${c}-description`,children:e}):null]}),n?(0,X.jsx)(`span`,{className:`caps-choice-card-meta`,children:n}):null]})}),Ei=(0,Y.forwardRef)(function({label:e,icon:t,caption:n,art:r=`dim`,className:i,...a},o){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,"data-art":r===`color`?r:void 0,children:(0,X.jsx)(wi,{...a,"aria-label":e,className:L(`caps-icon-choice-input`,i),indicator:(0,X.jsx)(_i,{icon:t,caption:n}),ref:o})})});(0,Y.forwardRef)(function({label:e,color:t,className:n,...r},i){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,"data-art":`color`,"data-swatch":``,title:e,children:(0,X.jsx)(wi,{...r,"aria-label":e,className:L(`caps-icon-choice-input`,n),indicator:(0,X.jsx)(_i,{icon:(0,X.jsx)(`span`,{className:`caps-swatch-dot`,style:{backgroundColor:t}})}),ref:i})})});var Di=(0,Y.forwardRef)(function({className:e,invalid:t,...n},r){return(0,X.jsxs)(`span`,{className:`caps-select-shell`,children:[(0,X.jsx)(`select`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:L(`select select-bordered caps-select w-full`,t&&`select-error`,e),ref:r}),!n.multiple&&(!n.size||n.size<=1)?(0,X.jsx)(vn,{className:`caps-select-chevron`,"aria-hidden":`true`}):null]})});function Oi({checked:e}){let t=`caps-switch-${(0,Y.useId)().replaceAll(`:`,``)}`,n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.useRef)(e).current,a=(0,Y.useRef)(e),o=x();return(0,Y.useLayoutEffect)(()=>{if(!n.current||!r.current)return;let t=o||a.current===e;a.current=e;let i=e?16:8,s=Ee(n.current),c=kn(s,{bounce:.25,duration:440}),l=J(s,{ease:`inOutSine`,duration:100}),u=$t(n.current,t?{x:2,y:2,width:i,height:8,duration:0}:{x:[{to:e?2.5:1.5,...l},{to:2,...c}],y:[{to:1.5,...l},{to:2,...c}],height:[{to:9,...l},{to:8,...c}],width:[{to:e?7:16.5,...l},{to:i,...c}]}),d=$t(r.current,{gradientTransform:e?`matrix(2 0 0 1 10 6)`:`matrix(1 0 0 1 6 6)`,...t?{duration:0}:{delay:l.duration,...c}});return()=>{u.cancel(),d.cancel()}},[e,o]),(0,X.jsxs)(`svg`,{className:`caps-switch-visual`,width:`40`,height:`24`,viewBox:`0 0 20 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(Ke,{ref:r,id:`${t}-surface`,transform:i?`matrix(2 0 0 1 10 6)`:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(dt,{id:`${t}-shadow`}),(0,X.jsx)(pt,{id:`${t}-inset`}),(0,X.jsx)(`clipPath`,{id:`${t}-track`,children:(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`18`,height:`10`,rx:`5`})})]}),(0,X.jsx)(`rect`,{className:`caps-switch-track`,filter:`url(#${t}-inset)`,x:`0.5`,y:`0.5`,width:`19`,height:`11`,rx:`5.5`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-track)`,children:(0,X.jsx)(`rect`,{ref:n,x:`2`,y:`2`,width:i?16:8,height:`8`,rx:`4`,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var ki=(0,Y.forwardRef)(function({className:e,checked:t,defaultChecked:n=!1,onChange:r,onCheckedChange:i,...a},o){let s=(0,Y.useRef)(null),[c,l]=(0,Y.useState)(n),u=t??c;return(0,Y.useImperativeHandle)(o,()=>{if(!s.current)throw Error(`Switch input is not mounted`);return s.current},[]),(0,Y.useEffect)(()=>{let e=s.current?.form;if(!e||t!==void 0)return;let r=e=>{queueMicrotask(()=>{!e.defaultPrevented&&s.current&&l(n)})};return e.addEventListener(`reset`,r),()=>{e.removeEventListener(`reset`,r)}},[t,n,a.form]),(0,X.jsxs)(`span`,{className:`caps-switch`,"data-checked":u,children:[(0,X.jsx)(`input`,{...a,checked:u,className:L(`caps-switch-input`,e),onChange:e=>{t===void 0&&l(e.target.checked),r?.(e),i?.(e.target.checked)},ref:s,role:`switch`,type:`checkbox`}),(0,X.jsx)(Oi,{checked:u})]})}),Ai=(0,Y.forwardRef)(function({className:e,invalid:t,...n},r){return(0,X.jsx)(`textarea`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:L(`textarea textarea-bordered w-full`,t&&`textarea-error`,e),ref:r})}),ji=U(K),Mi=U(Ue),Ni=U(Ft(me)),Pi=U(Le(K)),Fi=Le(Ze(File)),Ii=U(Fi),Li=at([K,me,Ue,Tt,Kt,Le(K),Fi]),Ri=U(Li),$=e=>M(ji(e.state.value),()=>``),zi=e=>M(Mi(e.state.value),()=>!1),Bi=e=>M(Ni(e.state.value),()=>null),Vi=e=>M(Pi(e.state.value),()=>[]),Hi=e=>M(Ii(e.state.value),()=>[]),Ui=e=>M(Ri(e.state.value),()=>null);function Wi({field:e,spec:t,locked:n,...r}){let[i,a]=(0,Y.useState)(!1);return(0,X.jsxs)(Nn,{children:[(0,X.jsx)(zn,{...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:$(e),onBlur:e.handleBlur,onChange:t=>{e.handleChange(t.currentTarget.value)}}),(0,X.jsx)(H,{type:`button`,variant:`outline`,size:`icon`,"aria-label":i?`Hide`:`Show`,"aria-pressed":i,disabled:n,onClick:()=>{a(e=>!e)},children:i?(0,X.jsx)(er,{"aria-hidden":`true`}):(0,X.jsx)(tr,{"aria-hidden":`true`})})]})}var Gi={text:`text`,email:`email`,url:`url`,tel:`tel`};function Ki({spec:e,field:t,locked:n,...r}){let i=Hi(t),a=n||e.readOnly===!0,o=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,X.jsx)(re,{asChild:!0,children:(0,X.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,X.jsx)(H,{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,X.jsx)(Fr,{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 qi({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,X.jsx)(zn,{...a,type:Gi[e.kind],inputMode:e.kind===`text`?void 0:e.kind,autoComplete:e.autoComplete,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:$(t),onChange:e=>{i(e.currentTarget.value)}});case`textarea`:return(0,X.jsx)(Ai,{...a,rows:e.rows??3,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:$(t),onChange:e=>{i(e.currentTarget.value)}});case`secret`:return(0,X.jsx)(Wi,{...r,field:t,spec:e,locked:n});case`money`:return(0,X.jsxs)(Nn,{children:[(0,X.jsx)(Pn,{className:`caps-field-currency`,children:e.currency??`USD`}),(0,X.jsx)(zn,{...a,inputMode:`decimal`,autoComplete:`off`,className:`caps-field-amount`,placeholder:e.placeholder??`0.00`,readOnly:e.readOnly,value:$(t),onChange:e=>{i(e.currentTarget.value)}})]});case`date`:return(0,X.jsx)(zn,{...a,type:`date`,readOnly:e.readOnly,value:$(t),onChange:e=>{i(e.currentTarget.value)}});case`number`:return(0,X.jsx)(Un,{...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:Bi(t),onValueChange:e=>{t.handleChange(e)}});case`select`:return(0,X.jsxs)(Di,{...a,value:$(t),onChange:e=>{i(e.currentTarget.value)},children:[e.placeholder===void 0?null:(0,X.jsx)(`option`,{value:``,disabled:!0,children:e.placeholder}),e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]});case`combobox`:return(0,X.jsx)(gi,{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:$(t),...e.placeholder===void 0?{}:{placeholder:e.placeholder},trigger:(0,X.jsx)(mi,{name:e.name,disabled:n||e.readOnly===!0,onBlur:t.handleBlur,children:e.options.find(e=>e.value===$(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,X.jsx)(Ki,{...r,spec:e,field:t,locked:n});case`checkbox`:return(0,X.jsx)(Ur,{...a,disabled:n||e.readOnly===!0,checked:zi(t),onChange:e=>{t.handleChange(e.currentTarget.checked)}});case`switch`:return(0,X.jsx)(ki,{...a,disabled:n||e.readOnly===!0,checked:zi(t),onCheckedChange:e=>{t.handleChange(e)}});case`radio`:case`icon-radio`:case`checkboxes`:case`icon-checkboxes`:return null}}var Ji=new Set([`radio`,`icon-radio`,`checkboxes`,`icon-checkboxes`]);function Yi({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=Vi(t),s=(e,r)=>{t.handleChange(r?[...n,e]:n.filter(t=>t!==e))};return(0,X.jsx)(Rn,{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,X.jsx)(`div`,{className:`caps-field-icon-choices`,children:e.options.map(r=>(0,X.jsx)(vi,{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,X.jsx)(bi,{children:e.options.map(r=>(0,X.jsx)(yi,{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,X.jsx)(Rn,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:(0,X.jsx)(Ci,{name:e.name,"aria-label":o,value:$(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,X.jsx)(Ei,{value:t.value,label:t.label,...t.caption===void 0?{}:{caption:t.caption},icon:t.icon,disabled:t.disabled},t.value):s?(0,X.jsx)(Ti,{value:t.value,title:t.label,description:t.description,meta:t.meta,disabled:t.disabled},t.value):(0,X.jsx)(jn,{label:t.label,orientation:`inline`,children:(0,X.jsx)(wi,{value:t.value,disabled:t.disabled})},t.value))})})}function Xi({spec:e,field:t,locked:n,error:r,render:i,...a}){return i({name:e.name,label:e.label,help:e.help,value:Ui(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 Zi({form:e,spec:t,locked:n,layout:r}){let i=Ln({form:e,name:t.name}),a=Bn(e.store,e=>e.submissionAttempts>0),o=i.state.meta.isBlurred||a?Mr(i.state.meta):void 0;if(t.render===void 0&&Ji.has(t.kind))return(0,X.jsx)(Yi,{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,X.jsx)(jn,{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,X.jsx)(qi,{spec:t,field:i,locked:n}):(0,X.jsx)(Xi,{spec:t,field:i,locked:n,error:o,render:t.render})})}var Qi=U(Je(K,Li));function $i({form:e,spec:t,locked:n,layout:r}){let i=t.when;return Bn(e.store,e=>i===void 0||i(M(Qi(e.values),()=>({}))))?(0,X.jsx)(Zi,{form:e,spec:t,locked:n,layout:r}):null}function ea({form:e,section:t,locked:n,layout:r}){let i=t.fields.map(t=>(0,X.jsx)($i,{form:e,spec:t,locked:n,layout:r},t.name));return t.title===void 0?i:(0,X.jsx)(In,{title:t.title,description:t.description,layout:r,children:i})}function ta({model:e,names:t,disabled:n=!1,layout:r}){let i=e.form;return t===void 0?e.description.sections.map(e=>(0,X.jsx)(ea,{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,X.jsx)($i,{form:i,spec:a,locked:n,layout:r},t)})}var na=class{annotation;constructor(e){this.annotation=e}},ra=class{sections;constructor(e){this.sections=e}},ia=`caps/form`,aa=0;function oa(e){aa+=1;let t={[`${ia}:${String(aa)}`]:new na(e)};return e.label!==void 0&&(t.title=e.label),e.help!==void 0&&(t.description=e.help),t}K.annotate(oa({kind:`secret`})).pipe(jt(`Secret`));var sa=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 ca(e){return Object.values(e??{}).reduce((e,t)=>t instanceof na?{...e,...t.annotation}:e,{})}function la(e){return e.reduce((e,t)=>({...e,...ca(t)}),{})}function ua(e){let t=e?.[ia];return t instanceof ra?t.sections:{}}var da=U(K);function fa(e){if(g(e))return pe(da(e.literal),{onNone:()=>null,onSome:e=>[e]});if(!Oe(e))return null;let t=[];for(let n of e.types){if(a(n))continue;let e=fa(n);if(e===null)return null;t.push(...e)}return t}function pa(e){if(nn(e))return{type:`string`,literals:[]};if(ee(e))return{type:`number`,nullable:!1};if(de(e))return{type:`boolean`};let t=fa(e);if(t!==null)return{type:`string`,literals:t};if(se(e)){let[t]=e.rest;if(t===void 0)return null;if(nn(t))return{type:`strings`,literals:[]};let n=fa(t);return n===null?null:{type:`strings`,literals:n}}if(Oe(e)){let t=e.types.filter(e=>!a(e)&&!k(e)),n=e.types.some(e=>k(e)),[r]=t;if(t.length!==1||r===void 0)return null;let i=pa(r);return i?.type===`number`?{type:`number`,nullable:n}:n?null:i}return null}function ma(e){let t=e.ast;if(!he(t))throw Error(`A schema form needs a Schema.Struct.`);return{fields:t.propertySignatures.map(e=>{let t=String(e.name),n=y(e.type),r=la([e.type.annotations,...(e.type.checks??[]).map(e=>e.annotations)]),i=r.kind===`file`?{type:`files`}:pa(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:Me(e.type),description:we(e.type)}}),sections:ua(w(t))}}function ha(e){let t=e,n=!1,r=!1;for(;;)if(t instanceof tt)n=!0,t=t.unwrap();else if(t instanceof Ye)r=!0,t=t.unwrap();else if(t instanceof Et)t=t.unwrap();else if(t instanceof bt)t=t.in;else return{node:t,optional:n,nullable:r}}function ga(e){if(e instanceof lt){let t=e.options.map(e=>ga(e));return t.some(e=>e===null)?null:t.flatMap(e=>e??[])}let t=e instanceof It?e.options:e instanceof ht?[...e.values]:null;if(t===null)return null;let n=t.map(e=>da(e));return n.every(Ie)?n.map(e=>e.value):null}function _a(e){let{node:t,nullable:n}=ha(e);if(t instanceof qt)return{type:`string`,literals:[]};if(t instanceof Ot)return{type:`number`,nullable:n};if(t instanceof Ht)return{type:`boolean`};let r=ga(t);if(r!==null)return{type:`string`,literals:r};if(t instanceof st){let e=ha(t.element).node;if(e instanceof qt)return{type:`strings`,literals:[]};let n=ga(e);return n===null?null:{type:`strings`,literals:n}}return null}function va(e){let t=[e];for(;;){let e=t[t.length-1];if(e===void 0)break;let n=e instanceof tt||e instanceof Ye||e instanceof Et?e.unwrap():e instanceof bt?e.in:e;if(n===e)break;t.push(n)}return t.reverse().map(e=>_.get(e))}function ya(e){return va(e).reduce((e,t)=>({...e,...t}),{})}function ba(e){return Object.entries(e.shape)}function xa(e){let t=ha(e).node;if(!(t instanceof Bt))throw Error(`A schema form needs a z.object.`);return{fields:ba(t).map(([e,t])=>{let n=la(va(t)),r=n.kind===`file`?{type:`files`}:_a(t);if(r===null)throw Error(`Schema field "${e}" has no form control. Annotate it with field({ render }) or a kind.`);let i=ya(t);return{name:e,valueType:r,optional:ha(t).optional,annotation:n,title:i.title,description:i.description}}),sections:ua(ya(e))}}function Sa(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??sa(e),description:r.description,meta:r.meta,icon:r.icon,caption:r.caption,disabled:r.disabled===!0}})}function Ca(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 wa(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 Ta(e){let t=e instanceof ot?xa(e):ma(e),n=t.fields.map((e,t)=>{let{kind:n,...r}=e.annotation,i=Sa(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??sa(e.name),help:a,kind:n??Ca(e.valueType,i),options:i,optionalInSchema:e.optional,index:t}}),r={};t.fields.forEach((e,t)=>{let i=n[t];i&&(r[e.name]=wa(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 Ea(e){let t=e instanceof ot?e:ae(e);return{"~standard":{...t[`~standard`],validate:e=>{let n=t[`~standard`].validate(e);return n instanceof Promise?n.then(e=>Da(e)):Da(n)}}}}function Da(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 Oa=`onServer`;function ka(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 Aa(e){if(ka(e))return()=>void 0;let t=new MutationObserver(()=>{ka(e)&&t.disconnect()});return t.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`aria-invalid`]}),()=>{t.disconnect()}}function ja(e){return e.state.meta.errorMap.onServer!==void 0}function Ma(e){e.setMeta(e=>({...e,errorMap:{...e.errorMap,[Oa]:void 0}}))}function Na(e,t,n){e.setFieldMeta(t,e=>({...e,isBlurred:!0,errorMap:{...e.errorMap,[Oa]:n}}))}function Pa(e){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(e.defaultValues),[s,c]=(0,Y.useState)(null);Fn(a,e.defaultValues)||(o(e.defaultValues),c(null));let{schema:l}=e,u=(0,Y.useMemo)(()=>Ta(l),[l]),d=(0,Y.useMemo)(()=>Ea(l),[l]),f=Hn({defaultValues:s??a,validators:{onChange:d,onSubmit:d},listeners:{onChange:({fieldApi:e})=>{n(null),i(null),ja(e)&&Ma(e)}},onSubmit:async({value:t,formApi:r})=>{n(null),i(null);let a=await Ea(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&&Na(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 Fa(e){return{dirty:Bn(e.form.store,e=>!e.isDefaultValue),submitting:Bn(e.form.store,e=>e.isSubmitting),canSubmit:Bn(e.form.store,e=>e.canSubmit)}}function Ia({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}=Fa(e),f=(0,Y.useRef)(null),p=(0,Y.useRef)(()=>void 0);return(0,Y.useEffect)(()=>()=>{p.current()},[]),(0,X.jsxs)(Vn,{...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=Aa(t))})},children:[c??(0,X.jsx)(ta,{model:e,disabled:l,layout:o}),s===void 0?(0,X.jsx)(za,{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 La({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i,...a}){let o=Pa({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i});return(0,X.jsx)(Ia,{...a,model:o})}function Ra(e){return`model`in e?(0,X.jsx)(Ia,{...e}):(0,X.jsx)(La,{...e})}function za({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}=Fa(e),d=u?null:e.saved&&!l?(0,X.jsx)(Dn,{tone:`success`,size:`compact`,label:e.saved}):l?(0,X.jsx)(Dn,{tone:`neutral`,size:`compact`,label:o}):null;return(0,X.jsxs)(Mn,{...c,error:e.error,status:d,children:[r?(0,X.jsx)(H,{type:`button`,variant:`ghost`,disabled:u,onClick:r,children:i}):n&&l?(0,X.jsx)(H,{type:`button`,variant:`ghost`,disabled:u,onClick:e.discard,children:n}):null,(0,X.jsx)(H,{...s,type:`submit`,loading:u,disabled:u||!l&&!a,title:!l&&!a?`No changes to save`:void 0,children:t})]})}var Ba=et.check(ue(/^(?!\.{1,2}$)[^/]+$/u,{message:`Enter a single file or folder name.`})),Va={file:zt({name:Ba.annotate(oa({label:`File name`}))}),folder:zt({name:Ba.annotate(oa({label:`Folder name`}))})};function Ha(e){return(0,X.jsx)(Ua,{...e},e.creation?`${e.creation.kind}:${e.creation.directory}:${e.creation.name??``}`:`closed`)}function Ua({creation:e,rootPath:t,onCreate:n,onClose:r}){let i=Pa({schema:Va[e?.kind??`file`],defaultValues:{name:e?.name??``},onSubmit:async t=>{if(!e)return;let i=await n(e,t.name);if(i)return i===`That name already exists in this directory.`?{kind:`refused`,fields:{name:i}}:{kind:`refused`,error:i};r()}}),{submitting:a}=Fa(i);return(0,X.jsx)(qe,{open:e!==null,onOpenChange:e=>{!e&&!i.form.state.isSubmitting&&r()},children:(0,X.jsxs)(Rt,{children:[(0,X.jsxs)(Gt,{className:`mb-4`,children:[(0,X.jsxs)(it,{children:[`New `,e?.kind===`folder`?`folder`:`file`]}),(0,X.jsxs)($e,{children:[`Create in `,e?.directory??t,` on this Computer.`]})]}),(0,X.jsx)(Ra,{model:i,onSubmitCapture:()=>{i.form.state.isSubmitting||i.form.setFieldValue(`name`,e=>e)},footer:(0,X.jsxs)(Mn,{divider:!1,error:i.error,children:[(0,X.jsx)(H,{variant:`ghost`,type:`button`,disabled:a,onClick:r,children:`Cancel`}),(0,X.jsx)(H,{type:`submit`,disabled:a,loading:a,children:a?`Creating…`:`Create`})]})})]})})}function Wa({files:e,patch:t,truncated:n,activeDiff:r,rowHeight:i,onOpenDiff:a}){let o=(0,Y.useMemo)(()=>Tn(t),[t]);return e.length===0?(0,X.jsx)(fn,{className:`inkcap-changes-empty`,variant:`quiet`,title:`No changes yet`,description:`Files the Agent edits show up here.`}):(0,X.jsxs)(`div`,{className:`inkcap-changes-list`,children:[n?(0,X.jsx)(`p`,{className:`inkcap-tree-note`,children:`Showing the first part of a large change. Review the rest in a terminal.`}):null,(0,X.jsx)(`ul`,{children:e.map(e=>{let t=o.get(e.path);return(0,X.jsx)(`li`,{children:(0,X.jsxs)(H,{className:`inkcap-change-file`,style:{minHeight:i},size:`sm`,variant:`ghost`,"aria-current":r===e.path?`true`:void 0,title:`Review changes to ${e.path}`,onClick:()=>{a(e.path)},children:[(0,X.jsx)(`span`,{className:`inkcap-change-mark`,"data-status":e.status,role:`img`,"aria-label":bn[e.status],children:Cn[e.status]}),(0,X.jsx)(`span`,{className:`inkcap-change-path`,children:e.path}),t?(0,X.jsxs)(`span`,{className:`inkcap-change-counts`,children:[t.additions>0?(0,X.jsxs)(`span`,{className:`inkcap-change-added`,children:[`+`,t.additions]}):null,t.deletions>0?(0,X.jsxs)(`span`,{className:`inkcap-change-removed`,children:[`−`,t.deletions]}):null]}):null]})},`${e.status}:${e.path}`)})})]})}var Ga=`That name already exists in this directory.`;function Ka({app:e,onOpenFile:t,onOpenDiff:n,activeDiff:r=null,activePath:i,rootPath:a=`/`,rootLabel:o=`Computer`,onSelectPath:c,creationRequest:l=null,onCreationRequestHandled:u,rowHeight:d=32}){let[f,p]=(0,Y.useState)(null),m=kr({app:e,rootPath:a,rootLabel:o,rowHeight:d,activePath:i,onOpenFile:t,onSelectPath:e=>{p(e),c?.(e)}}),[h,g]=(0,Y.useState)(null),_=e.capabilities.has(on),[v,y]=(0,Y.useState)(!1),b=e.capabilities.has(ln),x=cn(_n(b?e:null,a)),S=x.data?.kind===`changes`?x.data:null;function C(){m.reloadRoot(),b&&x.refetch()}(0,Y.useEffect)(()=>{x.isError&&e.ui.showToast({message:B(x.error).message,tone:`error`}).catch(e=>{console.error(`Inkcap changes toast failed`,e)})},[e,x.isError,x.error]);function w(e,t){g({kind:e,directory:wt(t,a)})}(0,Y.useEffect)(()=>{if(!l)return;let e={kind:l.kind,directory:wt(f??`${a}/`,a)};l.name!==void 0&&(e.name=l.name),l.immediate===!0&&l.name!==void 0?T(e,l.name):g(e),u?.()},[l,u,a,f]);async function T(e,n){let r=await E(e,n);r===Ga?t(mt(n,e.directory)):r!==void 0&&g(e)}async function E(n,r){let i=mt(r,n.directory);try{let a=0;for(;a!==null;){let t=a,i=await On(e.capabilities,{path:n.directory,limit:256,offset:t});if(i.entries.some(e=>e.name===r))return Ga;if(i.nextOffset!==null&&i.nextOffset<=t)return`Could not verify that name is available.`;a=i.nextOffset}n.kind===`folder`?(await e.capabilities.require(on).mkdir({path:i}),m.noteCreated(`${i}/`)):(await sn(e.capabilities,{path:i,content:new Blob([])},{}),m.noteCreated(i),t(i));return}catch(e){return e instanceof Error?B(e).message:`Couldn't create ${n.kind}. Check Computer write access.`}}let D={flex:`1`,"--trees-item-height":`${String(d)}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":`var(--color-base-100)`,"--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":`12px`};return(0,X.jsxs)(`aside`,{className:`inkcap-tree`,"aria-label":`File tree`,children:[(0,X.jsxs)(`div`,{className:`inkcap-tree-toolbar`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(wn,{"aria-hidden":`true`}),` `,(0,X.jsx)(`span`,{className:`inkcap-tree-title`,children:`Explorer`})]}),(0,X.jsxs)(`span`,{className:`inkcap-tree-actions`,children:[(0,X.jsx)(s,{icon:(0,X.jsx)(pn,{}),"aria-label":`New file`,title:`New file`,variant:`ghost`,size:`responsive`,disabled:!_,onClick:()=>{w(`file`,f??`${a}/`)}}),(0,X.jsx)(s,{icon:(0,X.jsx)(rr,{}),"aria-label":`New folder`,title:`New folder`,variant:`ghost`,size:`responsive`,disabled:!_,onClick:()=>{w(`folder`,f??`${a}/`)}}),(0,X.jsx)(s,{icon:(0,X.jsx)(Gn,{}),"aria-label":`Refresh files`,title:`Refresh files`,variant:`ghost`,size:`responsive`,disabled:m.busy||x.isFetching,onClick:C})]})]}),S===null?x.isError?(0,X.jsx)(H,{className:`inkcap-changes-retry`,size:`sm`,variant:`ghost`,onClick:()=>void x.refetch(),children:`Changes unavailable. Retry`}):null:(0,X.jsx)(Or,{className:`inkcap-changes`,size:`row`,open:v,onOpenChange:y,summary:`Changes`,trailing:(0,X.jsx)(xn,{count:S.files.length}),children:(0,X.jsx)(Wa,{files:S.files,patch:S.patch,truncated:S.truncated,activeDiff:r,rowHeight:d,onOpenDiff:e=>{n?.(e)}})}),m.error&&(0,X.jsx)(dn,{message:m.error,onRetry:m.reloadRoot}),m.rootEmpty?(0,X.jsx)(`p`,{className:`inkcap-tree-note`,children:`Empty folder`}):null,(0,X.jsxs)(`div`,{className:`inkcap-tree-files`,children:[(0,X.jsx)(Wn,{model:m.model,style:D,renderContextMenu:(e,t)=>(0,X.jsxs)(`div`,{className:`flex min-w-36 flex-col gap-xs p-xs`,role:`menu`,children:[(0,X.jsxs)(H,{className:`w-full justify-start`,disabled:!_,role:`menuitem`,title:_?void 0:`Computer write access is not granted.`,size:`sm`,variant:`ghost`,onClick:()=>{t.close({restoreFocus:!1}),w(`file`,e.path)},children:[(0,X.jsx)(pn,{"aria-hidden":`true`}),` New file`]}),(0,X.jsxs)(H,{className:`w-full justify-start`,disabled:!_,role:`menuitem`,title:_?void 0:`Computer write access is not granted.`,size:`sm`,variant:`ghost`,onClick:()=>{t.close({restoreFocus:!1}),w(`folder`,e.path)},children:[(0,X.jsx)(rr,{"aria-hidden":`true`}),` New folder`]})]})}),m.page.next!==null&&(0,X.jsxs)(H,{disabled:m.busy,onClick:m.loadNext,children:[`More in `,m.page.path]})]}),(0,X.jsx)(Ha,{creation:h,rootPath:a,onCreate:E,onClose:()=>{g(null)}})]})}export{Ka as InkcapFileTree};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,$a as n,A as r,B as i,Ba as a,Bi as o,Bn as s,Bt as c,C as l,Cn as u,D as d,Dn as f,E as p,En as m,F as h,Fa as g,Fi as _,G as v,Ga as y,Gi as b,Gr as x,Gt as S,H as C,Ha as w,Hi as T,Hr as E,Ht as D,I as O,Ia as k,Ii as A,J as j,Ja as M,Ji as N,Jr as P,K as F,Ki as I,Kr as L,L as R,La as ee,Li as te,Ln as ne,Lr as re,M as ie,Ma as ae,N as oe,Na as se,Nn as ce,O as le,Oa as ue,P as z,Pa as de,Q as fe,Qa as pe,Qi as me,Qr as B,Ra as he,Ri as ge,Rt as _e,S as ve,Sn as ye,St as be,T as xe,Tn as Se,U as Ce,Ua as we,Ui as Te,Ur as Ee,Ut as V,V as De,Va as Oe,Vi as ke,Vt as Ae,W as je,Wa as Me,Wi as Ne,Wr as Pe,X as Fe,Xa as Ie,Xi as Le,Y as Re,Ya as ze,Yi as Be,Yr as Ve,Za as He,Zi as Ue,Zt as We,_n as Ge,_r as Ke,a as qe,aa as Je,ai as Ye,b as Xe,ba as Ze,bt as Qe,c as $e,ca as et,ci as tt,cn as nt,ct as rt,d as it,da as at,di as ot,dr as H,ei as st,et as ct,fi as lt,g as ut,ga as U,gr as dt,h as ft,hr as pt,i as mt,ii as ht,in as gt,j as _t,jn as W,k as vt,kn as yt,li as bt,lr as xt,m as St,mr as Ct,n as wt,na as Tt,ni as Et,nn as G,nt as Dt,oa as K,oi as Ot,on as kt,p as At,pa as jt,pn as Mt,q as Nt,qt as Pt,ra as Ft,ri as It,rt as Lt,s as Rt,sa as zt,si as Bt,st as Vt,ti as Ht,tn as Ut,tt as Wt,u as Gt,ua as Kt,ui as qt,ur as q,ut as Jt,v as Yt,wn as Xt,x as Zt,y as Qt,yr as $t,yt as en,z as tn,za as nn,zi as rn,zn as an}from"./tree-path-AxEg-Kjh.js";import{C as on,D as sn,Ft as cn,O as ln,Rt as un,_ as dn,a as fn,b as J,c as pn,f as mn,g as hn,h as gn,i as _n,l as vn,m as yn,n as bn,o as xn,p as Sn,r as Cn,s as wn,t as Tn,u as En,v as Dn,w as On,x as kn,y as An}from"./changes-patch-CrPexAyH.js";import{a as jn,c as Mn,d as Nn,f as Pn,i as Fn,l as In,n as Ln,o as Rn,p as zn,r as Bn,s as Vn,t as Hn,u as Un}from"./useForm-BDtDFyLf.js";import{n as Wn,r as Gn,t as Kn}from"./useFileTree-C86PCVGL.js";var qn=I(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);ge.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>rn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ke(e,t,n),e.parseAsync=async(t,n)=>o(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>T(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0}),e.with=e.check,e.clone=(t,n)=>Te(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),Jn=I(`ZodMiniObject`,(e,t)=>{te.init(e,t),qn.init(e,t),Ne(e,`shape`,()=>t.shape)});function Yn(e,t){return new Jn({type:`object`,shape:e??{},...b(t)})}var Xn=I(`ZodMiniLiteral`,(e,t)=>{A.init(e,t),qn.init(e,t)});function Zn(e,t){return new Xn({type:`literal`,values:Array.isArray(e)?e:[e],...b(t)})}var Qn=q(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),$n=q(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),er=q(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),tr=q(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),nr=q(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),rr=q(`FolderPlus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ir=q(`RotateCcw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Y=e(Be(),1);function ar(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=nt({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=D(a,!0,!0),d=Pt(),[f,p]=Y.useState(),m=f===null?void 0:f??d,h=G(e=>{let t=!a,n=S(u,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return Y.useMemo(()=>({defaultPanelId:d,disabled:i,handleTrigger:h,mounted:s,open:a,panelId:m,setMounted:c,setOpen:o,setPanelIdState:p,transitionStatus:l}),[d,i,h,s,a,m,c,o,p,l])}var or=Y.createContext(void 0);function sr(){let e=Y.useContext(or);if(e===void 0)throw Error(an(15));return e}var cr=`data-open`,lr=`data-closed`,ur=yt,dr=`data-panel-open`,fr={[cr]:``},pr={[lr]:``},mr={open(e){return e?{[dr]:``}:null}},hr={open(e){return e?fr:pr},...f},X=N(),gr=Y.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=G(o),d=ar({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=Y.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=Y.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=W(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:hr});return(0,X.jsx)(or.Provider,{value:p,children:m})}),_r={...mr,...f},vr=Y.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=sr(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=We({disabled:c,native:u});return W(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:_r})}),Z={height:void 0,width:void 0};function yr(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:l,setOpen:u,transitionStatus:d}=e,f=Y.useRef(null),p=Y.useRef(null),[m,h]=Y.useState(Z),g=Y.useRef(Z),_=Y.useRef(!1),v=Y.useRef(s),y=Y.useRef(!1),[b,x]=Y.useState(!1),C=Y.useRef(null),w=ne(t,f),T=Qe(s),E=Ae(f),D=!s&&!a,O=b?`idle`:d,k=s&&(v.current||y.current),A=!s&&a&&p.current===`css-animation`&&m.height===void 0&&m.width===void 0?g.current:m,j=n&&D&&p.current!==`css-animation`,M=G((e,t=!0)=>{t&&(g.current=e),h(e)}),N=G(()=>{C.current?.(),C.current=null}),P=G(e=>{N(),C.current=()=>{C.current=null,e()}}),F=G(()=>{s&&a&&p.current===`css-animation`&&(y.current=!0)});Ut(()=>{!b||d===`starting`||x(!1)},[b,d]),Y.useEffect(()=>()=>{F(),N()},[F,N]),Ut(()=>{s||(v.current=!1,y.current=!1);let e=f.current;if(!e)return;!s&&C.current&&N();let t=br(e,k);if(p.current=t,s&&d===`idle`&&v.current&&t===`css-animation`){g.current=Q(e);return}if(s&&d===`starting`){let n=_.current;if(_.current=!1,t===`none`){M(Q(e)),x(!0);return}if(t===`css-transition`){let t=Cr(e);if(M(Q(e)),!n)return t;let r=Sr(e,`transition-duration`,`0s`);return P(r),x(!0),t}M(Q(e));let r=Sr(e,`animation-name`,`none`);if(!n){r();return}let i=Sr(e,`animation-duration`,`0s`);r(),P(i),x(!0);return}if(!s&&a&&(d===`idle`||d===`starting`)){if(t===`none`){M(Z,!1),l(!1);return}M(Q(e));return}if(d!==`ending`)return;if(t===`none`){l(!1);return}let n=Q(e);if(!(n.height>0||n.width>0)){l(!1);return}M(n),t===`css-animation`&&Sr(e,`animation-name`,`none`)()},[a,s,N,M,l,P,k,d]),c({enabled:s&&a&&O===`idle`,open:!0,ref:f,onComplete(){s&&M(Z,!1)}}),Y.useEffect(()=>{if(s||!a||O!==`ending`)return;if(!f.current){l(!1),M(Z,!1);return}let e=new AbortController,t=-1;function n(){T.current||(l(!1),M(Z,!1))}return t=V.request(()=>{E(n,e.signal)}),()=>{V.cancel(t),e.abort()}},[T,a,s,O,E,M,l]),Ut(()=>{let e=f.current;!e||!n||!D||e.setAttribute(`hidden`,`until-found`)},[D,n]),Y.useEffect(function(){let e=f.current;if(!e)return;let t=_e.create(),n=-1,r=(r,i)=>{t.start(0,()=>{T.current||(n=V.request(()=>{T.current||(r&&(_.current=!1),i&&e.setAttribute(ur,``),e.setAttribute(`hidden`,`until-found`))}))})},i=be(e,`beforematch`,t=>{let n=S(Ge,t);if(o(!0,n),n.isCanceled){r(!1,!1);return}_.current=!0;let i=e.hasAttribute(ur);e.removeAttribute(ur),u(!0),r(!0,i)});return()=>{t.clear(),V.cancel(n),i()}},[T,o,u]);let I=i||n||a||s;return{height:A.height,props:{...j?{[ur]:``}:void 0,hidden:D,id:r},ref:w,shouldPreventOpenAnimation:k,shouldRender:I,transitionStatus:O,width:A.width}}function Q(e){return{height:e.scrollHeight,width:e.scrollWidth}}function br(e,t){let n=gt(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&xr(n.animationDuration),i=xr(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function xr(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function Sr(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function Cr(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=V.request(n);return()=>{V.cancel(r),n()}}var wr=`--collapsible-panel-height`,Tr=`--collapsible-panel-width`,Er=Y.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=sr(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;Ut(()=>(m(e=>b??(e===null?void 0:e)),()=>{m(e=>e===b?null:e)}),[b,m]);let{height:S,props:C,ref:w,shouldPreventOpenAnimation:T,shouldRender:E,transitionStatus:D,width:O}=yr({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),k={...g,transitionStatus:D},A=ce(s,k),j=W(`div`,{...e,style:void 0},{state:k,ref:w,props:[C,{style:{[wr]:S===void 0?`auto`:`${S}px`,[Tr]:O===void 0?`auto`:`${O}px`}},c,A?{style:A}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:hr});return E?j:null}),Dr=P(`caps-disclosure`,{variants:{tone:{neutral:``,error:`caps-disclosure-error`},size:{group:`caps-disclosure-group`,row:`caps-disclosure-row`}},defaultVariants:{tone:`neutral`,size:`group`}});function Or({open:e,onOpenChange:t,summary:n,leading:r,trailing:i,children:a,tone:o,size:s,className:c}){return(0,X.jsxs)(gr,{className:L(Dr({tone:o,size:s}),c),onOpenChange:t,open:e,children:[(0,X.jsxs)(vr,{className:`caps-disclosure-trigger`,children:[r===void 0?null:(0,X.jsx)(`span`,{className:`caps-disclosure-leading`,children:r}),(0,X.jsx)(`span`,{className:`caps-disclosure-summary`,children:n}),i===void 0?null:(0,X.jsx)(`span`,{className:`caps-disclosure-trailing`,children:i}),(0,X.jsx)($n,{"aria-hidden":`true`,className:`caps-disclosure-chevron`,size:12})]}),(0,X.jsx)(Er,{className:`caps-disclosure-panel`,children:a})]})}function kr({app:e,rootPath:t,rootLabel:n=`Computer`,activePath:r,onOpenFile:i,onSelectPath:a,rowHeight:o=32}){let{scope:s,snapshot:c,focusedPath:l,requestPage:u,reload:d}=hn({app:e,rootPath:t,activePath:r}),f=(0,Y.useRef)({activePath:r,onOpenFile:i,onSelectPath:a,rootLabel:n});f.current={activePath:r,onOpenFile:i,onSelectPath:a,rootLabel:n};let p=(0,Y.useRef)(u);p.current=u;let{model:m}=Kn({paths:[],itemHeight:o,initialExpansion:2,flattenEmptyDirectories:!1,composition:{contextMenu:{enabled:!0}},renderRowDecoration:({row:e})=>e.path===`/`?{text:f.current.rootLabel}:null,unsafeCSS:`[data-item-section="content"] { display: flex; align-items: center; }[data-item-path="/"] [data-item-section="decoration"] { justify-content: flex-start; color: inherit; }`,onSelectionChange(e){let t=e[0];t&&(f.current.onSelectPath?.(t),t.endsWith(`/`)?p.current(t,0):t!==f.current.activePath&&f.current.onOpenFile(t))}}),h=(0,Y.useRef)(En()),g=(0,Y.useRef)(null);(0,Y.useLayoutEffect)(()=>{Sn(m,h.current),g.current=null},[m,s]),(0,Y.useLayoutEffect)(()=>{g.current=null;for(let e of m.getSelectedPaths())!e.endsWith(`/`)&&e!==r&&m.getItem(e)?.deselect()},[r,m]),(0,Y.useLayoutEffect)(()=>{if(c.listings.length===0&&(g.current=null),gn(m,c.listings,h.current),!r||g.current===r)return;let e=yn(r,t);if(!e.every(e=>h.current.known.has(e)))return;for(let t of e){let e=m.getItem(t);e&&`expand`in e&&e.expand()}let n=m.getItem(r);n&&(g.current=r,n.select(),m.scrollToPath(r,{focus:!1}))},[r,m,t,s,c.listings]),(0,Y.useEffect)(()=>{c.failure&&console.error(`Inkcap directory listing failed`,un(c.failure))},[c.failure]);let _=c.listings.filter(({request:e})=>e.path===l).sort((e,t)=>e.request.offset-t.request.offset).at(-1)?.listing,v={path:_?.path??l,next:_?.nextOffset??null},y=c.listings.some(({request:e,listing:n})=>e.path===t&&e.offset===0&&n.entries.length===0&&n.nextOffset===null),b=d;return{model:m,page:v,error:c.failure?`${B(c.failure).message} Your open files remain available.`:``,busy:c.busy,rootEmpty:y,reloadRoot:b,noteCreated:e=>{let t=e.split(`/`).filter(Boolean).at(-1)??``;!mn({name:t,type:``})&&!m.getItem(e)&&m.batch([{type:`add`,path:e}]),b()},loadNext:()=>{v.next!==null&&u(v.path,v.next)}}}var Ar=U(K),jr=U(zt({message:K}));function Mr(e){for(let t of e.errors){let e=ze(n(He(jr(t),e=>e.message),()=>Ar(t)));if(e!==void 0&&e.length>0)return e}}var Nr={neutral:`progress-neutral`,primary:`progress-primary`,secondary:`progress-secondary`,accent:`progress-accent`,success:`progress-success`,info:`progress-info`,warning:`progress-warning`,error:`progress-error`},Pr=(0,Y.forwardRef)(function({className:e,tone:t=`primary`,...n},r){return(0,X.jsx)(`progress`,{...n,"data-complete":n.value!==void 0&&Number(n.value)>=Number(n.max??1)?`true`:void 0,className:L(`progress caps-gooey-motion caps-gooey-progress w-full`,Nr[t],e),ref:r})});(0,Y.forwardRef)(function({label:e,value:t,max:n,tone:r=`info`,className:i,...a},o){return(0,X.jsxs)(`div`,{...a,ref:o,className:L(`caps-game-meter`,i),children:[(0,X.jsxs)(`div`,{className:`caps-game-meter-readout`,children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsxs)(`span`,{className:`caps-game-meter-value`,children:[t,` / `,n]})]}),(0,X.jsx)(Pr,{"aria-label":e,value:t,max:n,tone:r})]})});function Fr({className:e,items:t,onCancel:n,onRemove:r,onRetry:i,rowClassName:a}){return t.length?(0,X.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,X.jsx)(Rr,{item:e,onCancel:n,onRemove:r,onRetry:i,...a===void 0?{}:{rowClassName:a}},e.id))}):null}function Ir({action:e,id:t,onAction:n,retry:r=!1}){return e?(0,X.jsx)(s,{"aria-label":e.accessibleLabel,title:e.label,variant:`ghost`,size:`xs`,className:`motion-reduce:transition-none`,icon:r?(0,X.jsx)(ir,{}):(0,X.jsx)(xt,{}),onClick:()=>void n(t),type:`button`}):null}function Lr({item:e}){return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{className:`block min-w-0 truncate`,title:e.name,children:e.name}),(0,X.jsx)(`div`,{className:`caps-upload-details`,children:(0,X.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 Rr({item:e,onCancel:t,onRemove:n,onRetry:r,rowClassName:i}){return(0,X.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,X.jsx)(`img`,{alt:``,className:`caps-upload-preview mask mask-squircle size-8 shrink-0 object-cover`,src:e.preview.url}):(0,X.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,X.jsx)(nr,{className:`size-4`})}),(0,X.jsx)(Lr,{item:e}),(0,X.jsx)(zr,{actions:e.actions,id:e.id,onCancel:t,onRemove:n,onRetry:r}),(0,X.jsx)(Pr,{"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 zr({actions:e,id:t,onCancel:n,onRemove:r,onRetry:i}){return(0,X.jsxs)(`div`,{className:`caps-upload-actions flex min-w-0 flex-wrap justify-end gap-xs`,children:[(0,X.jsx)(Ir,{action:e.retry,id:t,onAction:i,retry:!0}),(0,X.jsx)(Ir,{action:e.cancel,id:t,onAction:n}),(0,X.jsx)(Ir,{action:e.remove,id:t,onAction:r})]})}var Br={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`},Vr={blurStdDeviation:.22,alphaSlope:18,alphaIntercept:-8};function Hr({state:e}){let t=`caps-checkbox-${(0,Y.useId)().replaceAll(`:`,``)}`,n=(0,Y.useRef)(null),r=(0,Y.useRef)(e).current,i=(0,Y.useRef)(e),a=x();return(0,Y.useLayoutEffect)(()=>{if(!n.current)return;let t=e!==`unchecked`,r=i.current!==`unchecked`,o=a||i.current===e;i.current=e;let s=Ee(n.current),c=J(s,{ease:`inCubic`,duration:160}),l=$t(n.current,{d:{to:Br[e],...o?An:J(s,{ease:`outCubic`,duration:200})},"stroke-dashoffset":{to:+!t,...o?An:t?J(s,{ease:`inOutSine`,duration:260}):c},"stroke-width":o?{to:t?2.4:0,duration:0}:t&&!r?[{to:2.2,...J(s,{ease:`outCubic`,duration:65})},{to:2.4,delay:E(s,120),...kn(s,{bounce:.35,duration:220})}]:{to:t?2.4:0,...c}});return()=>{l.cancel()}},[e,a]),(0,X.jsxs)(`svg`,{className:`caps-checkbox-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(Ke,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(dt,{id:`${t}-shadow`}),(0,X.jsx)(pt,{id:`${t}-inset`}),(0,X.jsx)(Ct,{id:`${t}-goo`,values:Vr}),(0,X.jsxs)(`filter`,{id:`${t}-relief`,x:`-25%`,y:`-25%`,width:`150%`,height:`150%`,colorInterpolationFilters:`sRGB`,children:[(0,X.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`0.28`,result:`relief`}),(0,X.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,X.jsx)(`feDistantLight`,{azimuth:`225`,elevation:`55`})}),(0,X.jsx)(`feComposite`,{in:`light`,in2:`SourceAlpha`,operator:`in`,result:`clipped-light`}),(0,X.jsx)(`feBlend`,{in:`SourceGraphic`,in2:`clipped-light`,mode:`screen`})]}),(0,X.jsx)(`mask`,{id:`${t}-contour`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`12`,height:`12`,style:{maskType:`alpha`},children:(0,X.jsx)(`path`,{ref:n,d:Br[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,X.jsx)(`clipPath`,{id:`${t}-well`,children:(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`10`,height:`10`,rx:`2.5`})})]}),(0,X.jsx)(`rect`,{className:`caps-checkbox-track`,x:`0.5`,y:`0.5`,width:`11`,height:`11`,rx:`3`,filter:`url(#${t}-inset)`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,X.jsx)(`g`,{filter:`url(#${t}-shadow)`,children:(0,X.jsx)(`g`,{filter:`url(#${t}-relief)`,children:(0,X.jsx)(`g`,{mask:`url(#${t}-contour)`,children:(0,X.jsx)(`rect`,{x:`0`,y:`0`,width:`12`,height:`12`,fill:`url(#${t}-surface)`})})})})})]})}var Ur=(0,Y.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,Y.useRef)(null),[d,f]=(0,Y.useState)(o),p=a??d,m=i?`mixed`:p?`checked`:`unchecked`;return(0,Y.useImperativeHandle)(l,()=>{if(!u.current)throw Error(`Checkbox input is not mounted`);return u.current},[]),(0,Y.useLayoutEffect)(()=>{u.current&&(u.current.indeterminate=i)},[i]),(0,Y.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,X.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,X.jsx)(`input`,{...c,checked:p,"aria-checked":i?`mixed`:p,"aria-invalid":r?!0:c[`aria-invalid`]===!1?void 0:c[`aria-invalid`],className:L(`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,X.jsx)(Hr,{state:m}):n]})}),Wr=Yn({keyCode:Zn(229)});function Gr(e){return e.nativeEvent.isComposing||ke(Wr,e.nativeEvent).success}var Kr=Y.createContext(void 0);function qr(e){let t=Y.useContext(Kr);if(t===void 0&&!e)throw Error(an(47));return t}var Jr=e(Ve(),1),Yr={...z,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!z.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&z.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>z.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},Xr=class extends h{constructor(e,t,n){let r=new tn;super(Zr(e,r,t,n),Qr(r),Yr)}setOpen=(e,t)=>{let n=t.reason===ye,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=C(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=je(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}),Jr.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function Zr(e,t,n,r=!1){let i={...oe(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 Qr(e){return{popupRef:Y.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:Y.createRef(),beforeTriggerFocusGuardRef:Y.createRef(),beforeContentFocusGuardRef:Y.createRef(),stickIfOpenTimeout:new _e,stickIfOpen:!0,triggerElements:e}}var $r=O(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=ti(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),Re(u,d),v(u);let{forceUnmount:m}=F(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),Y.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),Y.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,S(Mt))}),[m,u]);let h=d||f||s!=null;return(0,X.jsxs)(Kr.Provider,{value:u,children:[s&&(0,X.jsx)(De,{handle:s,store:u}),h&&(0,X.jsx)(ni,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function ei(e){return qr(!0)?(0,X.jsx)($r,{props:e}):(0,X.jsx)(Dt,{children:(0,X.jsx)($r,{props:e})})}function ti(e,t){let n=j((e,n)=>new Xr(t,e,n));return Y.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function ni({store:e,modal:t}){let n=e.useState(`floatingRootContext`),r=fe(n,{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),i=r.reference,a=r.floating;return Nt(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}var ri=R(function(e,n){let{render:i,className:a,style:o,disabled:s=!1,nativeButton:c=!0,handle:l,payload:u,openOnHover:d=!1,delay:f=300,closeDelay:p=0,id:h,...g}=e,_=qr(!0),v=ie(l)??_;if(!v)throw Error(an(74));let y=Pt(h),b=v.useState(`isTriggerActive`,y),x=v.useState(`floatingRootContext`),S=v.useState(`isOpenedByTrigger`,y),C=v.useState(`triggerPopupId`,y),w=Y.useRef(null),{registerTrigger:T,isMountedByThisTrigger:E}=Fe(y,w,v,{payload:u,disabled:s,openOnHover:d,closeDelay:p}),D=v.useState(`isPressOpenedByTrigger`,y),O=v.useState(`isTouchPressOpen`,d),k=v.useState(`hasTriggerFocusGuards`,y),A=r(x,{enabled:!s&&d&&!O,mouseOnly:!0,move:!1,handleClose:vt(),restMs:f,delay:{close:p},triggerElementRef:w,isActiveTrigger:b,isClosing:()=>v.select(`transitionStatus`)===`ending`}),j=G(()=>v.context.stickIfOpen),M=t(x,{stickIfOpen:j}),N=Yt(()=>v.select(`open`),e=>{v.set(`openMethod`,e)}),P=v.useState(`triggerProps`,E),{getButtonProps:F,buttonRef:I}=We({disabled:s,native:c}),L={open(e){return D?Se.open(e):m.open(e)}},{handlePreFocusGuardFocus:R,handleFocusTargetFocus:ee}=ut(v,w),te=W(`button`,e,{state:{disabled:s,open:S},ref:[I,n,T,w],props:[M.reference,A,P,N,{[rt]:``,id:y,"aria-haspopup":`dialog`,"aria-expanded":S,"aria-controls":C},g,F],stateAttributesMapping:L}),ne=(0,X.jsx)(Y.Fragment,{children:te},y);return k?(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsx)(en,{ref:v.context.beforeTriggerFocusGuardRef,onFocus:R}),ne,(0,X.jsx)(en,{ref:v.context.triggerFocusTargetRef,onFocus:ee})]}):ne}),ii=Y.createContext(void 0);function ai(){let e=Y.useContext(ii);if(e===void 0)throw Error(an(45));return e}var oi=Y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return qr().useState(`mounted`)||n?(0,X.jsx)(ii.Provider,{value:n,children:(0,X.jsx)(Vt,{ref:t,...r})}):null}),si=Y.createContext(void 0);function ci(){let e=Y.useContext(si);if(!e)throw Error(an(46));return e}var li=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:u,alignOffset:d,collisionBoundary:f=`clipping-ancestors`,collisionPadding:p,arrowPadding:m,sticky:h,disableAnchorTracking:g=!1,collisionAvoidance:_=Jt,...v}=e,y=qr(),b=ai(),x=Lt(),S=y.useState(`floatingRootContext`),C=y.useState(`mounted`),w=y.useState(`open`),T=y.useState(`openChangeReason`),E=y.useState(`activeTriggerElement`),D=y.useState(`modal`),O=y.useState(`openMethod`),k=y.useState(`positionerElement`),A=y.useState(`instantType`),j=y.useState(`transitionStatus`),M=y.useState(`adaptiveOrigin`),N=l({anchor:a,floatingRootContext:S,positionMethod:o,mounted:C,side:s,sideOffset:u,align:c,alignOffset:d,arrowPadding:m,collisionBoundary:f,collisionPadding:p,sticky:h,disableAnchorTracking:g,keepMounted:b,nodeId:x,collisionAvoidance:_,adaptiveOrigin:M}),P=S.useState(`domReferenceElement`);Zt({store:y,domReference:P,positionerElement:k,open:w});let F=D===!0&&T!==`trigger-hover`;Qt(w&&F,O===`touch`,k,E);let I=y.useStateSetter(`positionerElement`),L={open:w,side:N.side,align:N.align,anchorHidden:N.anchorHidden,instant:A},R=Xe(e,L,{styles:N.positionerStyles,transitionStatus:j,props:v,refs:[t,I],hidden:!C,inert:!w});return(0,X.jsxs)(si.Provider,{value:N,children:[C&&F&&(0,X.jsx)(ve,{inert:xe(!w),cutout:E}),(0,X.jsx)(Wt,{id:x,children:R})]})}),ui=Y.createContext(void 0);function di(){let[e,t]=Y.useState(0),n=G(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:Y.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var fi=Y.forwardRef(function(e,t){let{render:n,className:r,style:a,initialFocus:o,finalFocus:s,...l}=e,u=qr(),f=ci(),m=le(!0)!=null,{context:h,hasClosePart:g}=di(),_=u.useState(`open`),v=u.useState(`openMethod`),y=u.useState(`instantType`),b=u.useState(`transitionStatus`),x=u.useState(`popupProps`),S=u.useState(`titleElementId`),C=u.useState(`descriptionElementId`),w=u.useState(`modal`),T=u.useState(`mounted`),E=u.useState(`openChangeReason`),D=u.useState(`activeTriggerElement`),O=u.useState(`floatingRootContext`),k=O.useState(`floatingId`),A=u.useState(`disabled`),j=u.useState(`openOnHover`),M=u.useState(`closeDelay`);c({open:_,ref:u.context.popupRef,onComplete(){_&&u.context.onOpenChangeComplete?.(!0)}}),_t(O,{enabled:j&&!A,closeDelay:M});let N=o===void 0?Ce(u.context.popupRef):o,P=w!==!1&&g;u.useSyncedValue(`focusManagerModal`,P);let F=u.useStateSetter(`popupElement`),I={open:_,side:f.side,align:f.align,instant:y,transitionStatus:b},L=W(`div`,e,{state:I,ref:[t,u.context.popupRef,F],props:[x,{id:k,role:`dialog`,...i,"aria-labelledby":S,"aria-describedby":C,onKeyDown(e){m&&d.has(e.key)&&e.stopPropagation()}},p(b),l],stateAttributesMapping:Xt});return(0,X.jsx)(ct,{context:O,openInteractionType:v,modal:P,disabled:!T||E===`trigger-hover`,initialFocus:N,returnFocus:s,restoreFocus:`popup`,getInsideElements:()=>[u.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:kt(D)?D:void 0,nextFocusableElement:u.context.triggerFocusTargetRef,beforeContentFocusGuardRef:u.context.beforeContentFocusGuardRef,children:(0,X.jsx)(ui.Provider,{value:h,children:L})})});function pi({getKey:e,isDisabled:t=()=>!1,items:n,getFallbackKey:r}){let i=(0,Y.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]),[a,o]=(0,Y.useState)(null),s=r?.(i)??null,c=a!==null&&i.some(t=>e(t)===a)?a:s!==null&&i.some(t=>e(t)===s)?s:null;(0,Y.useEffect)(()=>{a!==null&&!i.some(t=>e(t)===a)&&o(null)},[a,i,e]);let l=i.find(t=>e(t)===c),u=l?i.findIndex(t=>e(t)===c):-1;return{activeIndex:u,activeItem:l,activeKey:c,enabledItems:i,move:(t,n)=>{if(i.length===0)return;let r=n?n===`start`?0:i.length-1:u<0?t>0?0:i.length-1:(u+t+i.length)%i.length,a=i[r];a&&o(e(a))},setActiveKey:o}}var mi=(0,Y.forwardRef)(function({children:e,className:t,type:n=`button`,...r},i){return(0,X.jsxs)(`button`,{...r,ref:i,type:n,className:L(`select caps-select caps-combobox-trigger w-full`,t),children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(vn,{className:`caps-select-chevron`,"aria-hidden":`true`})]})});function hi({defaultInputValue:e,defaultOpen:t,defaultValue:n,getKey:r,getSearchText:i,groupBy:a,id:o,isDisabled:s,items:c,onOpenChange:l,onCommit:u,multiple:d,controlledOpen:f,controlledKeys:p,trigger:m}){let h=`${o}-listbox`,[g,_]=(0,Y.useState)(e),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(n),[S,C]=(0,Y.useState)(t),w=p??(b===null?[]:[b]),T=m?f??S:!0,E=(0,Y.useMemo)(()=>{let e=g.trim().toLowerCase();return e?c.filter(t=>i(t).toLowerCase().includes(e)):c},[i,c,g]),D=pi({getKey:r,isDisabled:s,items:E});(0,Y.useEffect)(()=>{if(D.activeKey!==null)return;let e=D.enabledItems.find(e=>w.includes(r(e)))??D.enabledItems[0];e&&D.setActiveKey(r(e))},[D.activeKey,D.enabledItems,D.setActiveKey,r,w]);let O=e=>{y(!1),e||_(``),f===void 0&&C(e),l?.(e)},k=e=>`${h}-option-${encodeURIComponent(e)}`,A=e=>{let t=r(e);p===void 0&&x(t),u(e),m&&!d&&O(!1)},j=e=>{y(!0),_(e.target.value),D.setActiveKey(null)},M=e=>{if(Gr(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?(y(!0),e.preventDefault(),D.move(t[0],t[1])):e.key===`Enter`&&D.activeItem&&(e.preventDefault(),A(D.activeItem))},N=(0,Y.useMemo)(()=>{if(!a)return[{label:``,items:E}];let e=new Map;for(let t of E){let n=a(t),r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e].map(([e,t])=>({label:e,items:t}))},[E,a]);return{keyboardNavigation:v,onPointerMove:()=>{y(!1)},activeKey:D.activeKey,activeItem:D.activeItem,groups:N,inputValue:g,listboxId:h,onInputChange:j,onInputKeyDown:M,optionId:k,open:T,commit:A,selectedKeys:w,setOpen:O}}function gi(e){let{"aria-describedby":t,"aria-invalid":n,"aria-label":r,"aria-labelledby":i,"aria-required":a,activeTone:o=`neutral`,container:s,contentClassName:c,defaultInputValue:l=``,defaultOpen:u=!1,defaultValue:d=null,emptyMessage:f=`No matches`,getKey:p,getLabel:m,getSearchText:h=m,groupBy:g,id:_,inputProps:v,inputRef:y,isDisabled:b=()=>!1,items:x,onOpenChange:S,onValueChange:C,multiple:w,open:T,placeholder:E=`Search…`,renderItem:D,rootRef:O,trigger:k,triggerRef:A,value:j,...M}=e,N=e=>{let t=p(e);if(w){let e=j.includes(t)?j.filter(e=>e!==t):[...j,t];C?.(e,x.filter(t=>e.includes(p(t))))}else C?.(t,e)},P;w?P=j:j!==void 0&&(P=j===null?[]:[j]);let F=(0,Y.useId)(),I=k?.props??v,R=_??I?.id??F,ee={id:R,"aria-describedby":[t,I?.[`aria-describedby`]].filter(Boolean).join(` `)||void 0,"aria-invalid":n??I?.[`aria-invalid`],"aria-label":I?.[`aria-label`]??r,"aria-labelledby":I?.[`aria-labelledby`]??i,"aria-required":a??I?.[`aria-required`]},{keyboardNavigation:te,onPointerMove:ne,activeItem:re,activeKey:ie,commit:ae,groups:oe,inputValue:se,listboxId:ce,onInputChange:le,onInputKeyDown:ue,open:z,optionId:de,selectedKeys:fe,setOpen:pe}=hi({defaultInputValue:l,defaultOpen:u,defaultValue:d,getKey:p,getSearchText:h,groupBy:g,id:R,isDisabled:b,items:x,onOpenChange:S,onCommit:N,multiple:w??!1,controlledOpen:T,controlledKeys:P,trigger:k});At(()=>{k&&pe(!1)});let me=St(`popover`),B=s===void 0?me:s,he=ft(`.caps-combobox-option[data-active="true"]:not(:disabled), [data-navigation="pointer"] .caps-combobox-option:hover:not(:disabled)`),ge=(0,X.jsx)(zn,{...v,...k?{}:ee,"aria-activedescendant":re?de(p(re)):void 0,"aria-autocomplete":`list`,"aria-controls":ce,"aria-expanded":!0,className:L(`input-sm`,v?.className),id:k?v?.id??`${R}-input`:R,onChange:e=>{v?.onChange?.(e),le(e)},onKeyDown:e=>{v?.onKeyDown?.(e),e.defaultPrevented||ue(e)},placeholder:v?.placeholder??E,ref:y,role:`combobox`,value:se}),_e=(0,X.jsx)(`div`,{id:ce,ref:he,className:`caps-combobox-list`,"data-navigation":te?`keyboard`:`pointer`,onPointerMove:ne,role:`listbox`,"aria-multiselectable":w??void 0,children:oe.every(e=>e.items.length===0)?(0,X.jsx)(`div`,{className:`px-md py-md text-sm text-base-content`,children:f}):oe.map(e=>(0,X.jsxs)(`div`,{"aria-label":e.label||void 0,role:e.label?`group`:void 0,children:[e.label?(0,X.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=p(e),n=b(e),r=ie===t,i={active:r,disabled:n,selected:fe.includes(t)};return(0,X.jsxs)(`button`,{"aria-disabled":n||void 0,"aria-selected":i.selected,className:`caps-combobox-option`,"data-active":r&&te,disabled:n,id:de(t),onClick:()=>{ae(e)},onMouseDown:e=>{e.preventDefault()},role:`option`,tabIndex:-1,type:`button`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`caps-combobox-check`,children:i.selected?(0,X.jsx)(Qn,{}):null}),D?.(e,r,i)??m(e)]},t)})]},e.label))});return k?(0,X.jsx)(`div`,{...M,className:L(M.className),ref:O,children:(0,X.jsxs)(ei,{modal:!0,onOpenChange:pe,open:z,children:[(0,X.jsx)(ri,{...ee,"aria-haspopup":`dialog`,className:`btn`,ref:A,render:k}),B===null?null:(0,X.jsx)(oi,{container:B,children:(0,X.jsx)(li,{align:`start`,side:`bottom`,sideOffset:4,className:`z-(--stipe-layer-popover)`,children:(0,X.jsxs)(fi,{"data-active-tone":o,className:L(`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,X.jsx)(`div`,{className:`caps-combobox-search`,children:ge}),_e]})})})]})}):(0,X.jsx)(`div`,{...M,className:L(M.className),ref:O,children:(0,X.jsxs)(`div`,{className:L(`caps-combobox-panel`,c),"data-active-tone":o,children:[(0,X.jsx)(`div`,{className:`caps-combobox-search`,children:ge}),_e]})})}function _i({icon:e,caption:t}){return(0,X.jsxs)(`span`,{className:`caps-icon-choice-mark`,"aria-hidden":`true`,children:[(0,X.jsx)(`span`,{className:`caps-icon-choice-art`,children:e}),t?(0,X.jsx)(`span`,{className:`caps-icon-choice-caption`,children:t}):null,(0,X.jsx)(`span`,{className:`caps-icon-choice-lamp`})]})}var vi=(0,Y.forwardRef)(function({label:e,icon:t,caption:n,appearance:r,className:i,...a},o){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,"data-appearance":r===`compact`?r:void 0,children:(0,X.jsx)(Ur,{...a,appearance:r??`default`,"aria-label":e,className:L(`caps-icon-choice-input`,i),indicator:(0,X.jsx)(_i,{icon:t,caption:n}),ref:o})})}),yi=(0,Y.forwardRef)(function({label:e,icon:t,hint:n,className:r,...i},a){let o=(0,Y.useId)(),s=[i[`aria-describedby`],n?o:null].filter(Boolean).join(` `)||void 0;return(0,X.jsx)(`label`,{className:`caps-check-key`,children:(0,X.jsx)(Ur,{...i,"aria-label":e,"aria-describedby":s,className:L(`caps-check-key-input`,r),indicator:(0,X.jsxs)(`span`,{className:`caps-check-key-face`,"aria-hidden":`true`,children:[t?(0,X.jsx)(`span`,{className:`caps-check-key-icon`,children:t}):null,(0,X.jsxs)(`span`,{className:`caps-check-key-copy`,children:[(0,X.jsx)(`span`,{className:`caps-check-key-label`,children:e}),n?(0,X.jsx)(`span`,{className:`caps-check-key-hint`,id:o,children:n}):null]}),(0,X.jsx)(`span`,{className:`caps-check-key-lamp`})]}),ref:a})})});function bi({className:e,...t}){return(0,X.jsx)(`div`,{...t,className:L(`caps-check-keys`,e)})}function xi({checked:e}){let t=`caps-radio-${(0,Y.useId)().replaceAll(`:`,``)}`,n=(0,Y.useRef)(null),r=(0,Y.useRef)(e).current,i=(0,Y.useRef)(e),a=(0,Y.useRef)(null),o=Pe(a),{reduced:s}=o;return(0,Y.useLayoutEffect)(()=>{if(!n.current)return;let t=s||i.current===e;i.current=e;let r=e?4:0,a=J(o,{ease:`outCubic`,duration:75}),c=e?kn(o,{bounce:.65,duration:300}):J(o,{ease:`inCubic`,duration:100}),l=$t(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,X.jsxs)(`svg`,{ref:a,className:`caps-radio-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(Ke,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(dt,{id:`${t}-shadow`}),(0,X.jsx)(pt,{id:`${t}-inset`}),(0,X.jsx)(`clipPath`,{id:`${t}-well`,children:(0,X.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})})]}),(0,X.jsx)(`circle`,{className:`caps-radio-track`,cx:`6`,cy:`6`,r:`5.5`,filter:`url(#${t}-inset)`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,X.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 Si=(0,Y.createContext)(null),Ci=(0,Y.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,Y.useId)(),d=(0,Y.useRef)(null);(0,Y.useImperativeHandle)(l,()=>{if(!d.current)throw Error(`RadioGroup is not mounted`);return d.current},[]);let f=i??`radio-group-${u}`,[p,m]=(0,Y.useState)(n),h=s??p;return(0,Y.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,X.jsx)(Si.Provider,{value:{disabled:r,name:f,onValueChange:e=>{s===void 0&&m(e),a?.(e)},value:h},children:(0,X.jsx)(`fieldset`,{...c,className:L(`flex gap-md`,o===`horizontal`?`flex-row flex-wrap`:`flex-col`,t),disabled:r,role:c.role??`radiogroup`,ref:d,children:e})})}),wi=(0,Y.forwardRef)(function({className:e,indicator:t,onChange:n,onClick:r,value:i,...a},o){let s=(0,Y.useContext)(Si);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,X.jsxs)(`span`,{className:`caps-radio`,"data-checked":c,"data-custom-indicator":t!==void 0||void 0,children:[(0,X.jsx)(`input`,{...a,"aria-checked":c,checked:c,className:L(`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,X.jsx)(xi,{checked:c}):t]})}),Ti=(0,Y.forwardRef)(function({description:e,id:t,meta:n,title:r,...i},a){let o=(0,Y.useContext)(Si),s=(0,Y.useId)(),c=t??s,l=o?.value===i.value,u=o?.disabled===!0||i.disabled===!0;return(0,X.jsxs)(`label`,{className:`caps-choice-card`,"data-checked":l,"data-disabled":u||void 0,htmlFor:c,children:[(0,X.jsx)(wi,{...i,"aria-describedby":e?`${c}-description`:void 0,"aria-labelledby":`${c}-title`,id:c,ref:a}),(0,X.jsxs)(`span`,{className:`caps-choice-card-copy`,children:[(0,X.jsx)(`span`,{className:`caps-choice-card-title`,id:`${c}-title`,children:r}),e?(0,X.jsx)(`span`,{className:`caps-choice-card-description`,id:`${c}-description`,children:e}):null]}),n?(0,X.jsx)(`span`,{className:`caps-choice-card-meta`,children:n}):null]})}),Ei=(0,Y.forwardRef)(function({label:e,icon:t,caption:n,art:r=`dim`,className:i,...a},o){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,"data-art":r===`color`?r:void 0,children:(0,X.jsx)(wi,{...a,"aria-label":e,className:L(`caps-icon-choice-input`,i),indicator:(0,X.jsx)(_i,{icon:t,caption:n}),ref:o})})});(0,Y.forwardRef)(function({label:e,color:t,className:n,...r},i){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,"data-art":`color`,"data-swatch":``,title:e,children:(0,X.jsx)(wi,{...r,"aria-label":e,className:L(`caps-icon-choice-input`,n),indicator:(0,X.jsx)(_i,{icon:(0,X.jsx)(`span`,{className:`caps-swatch-dot`,style:{backgroundColor:t}})}),ref:i})})});var Di=(0,Y.forwardRef)(function({className:e,invalid:t,...n},r){return(0,X.jsxs)(`span`,{className:`caps-select-shell`,children:[(0,X.jsx)(`select`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:L(`select select-bordered caps-select w-full`,t&&`select-error`,e),ref:r}),!n.multiple&&(!n.size||n.size<=1)?(0,X.jsx)(vn,{className:`caps-select-chevron`,"aria-hidden":`true`}):null]})});function Oi({checked:e}){let t=`caps-switch-${(0,Y.useId)().replaceAll(`:`,``)}`,n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.useRef)(e).current,a=(0,Y.useRef)(e),o=x();return(0,Y.useLayoutEffect)(()=>{if(!n.current||!r.current)return;let t=o||a.current===e;a.current=e;let i=e?16:8,s=Ee(n.current),c=kn(s,{bounce:.25,duration:440}),l=J(s,{ease:`inOutSine`,duration:100}),u=$t(n.current,t?{x:2,y:2,width:i,height:8,duration:0}:{x:[{to:e?2.5:1.5,...l},{to:2,...c}],y:[{to:1.5,...l},{to:2,...c}],height:[{to:9,...l},{to:8,...c}],width:[{to:e?7:16.5,...l},{to:i,...c}]}),d=$t(r.current,{gradientTransform:e?`matrix(2 0 0 1 10 6)`:`matrix(1 0 0 1 6 6)`,...t?{duration:0}:{delay:l.duration,...c}});return()=>{u.cancel(),d.cancel()}},[e,o]),(0,X.jsxs)(`svg`,{className:`caps-switch-visual`,width:`40`,height:`24`,viewBox:`0 0 20 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(Ke,{ref:r,id:`${t}-surface`,transform:i?`matrix(2 0 0 1 10 6)`:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(dt,{id:`${t}-shadow`}),(0,X.jsx)(pt,{id:`${t}-inset`}),(0,X.jsx)(`clipPath`,{id:`${t}-track`,children:(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`18`,height:`10`,rx:`5`})})]}),(0,X.jsx)(`rect`,{className:`caps-switch-track`,filter:`url(#${t}-inset)`,x:`0.5`,y:`0.5`,width:`19`,height:`11`,rx:`5.5`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-track)`,children:(0,X.jsx)(`rect`,{ref:n,x:`2`,y:`2`,width:i?16:8,height:`8`,rx:`4`,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var ki=(0,Y.forwardRef)(function({className:e,checked:t,defaultChecked:n=!1,onChange:r,onCheckedChange:i,...a},o){let s=(0,Y.useRef)(null),[c,l]=(0,Y.useState)(n),u=t??c;return(0,Y.useImperativeHandle)(o,()=>{if(!s.current)throw Error(`Switch input is not mounted`);return s.current},[]),(0,Y.useEffect)(()=>{let e=s.current?.form;if(!e||t!==void 0)return;let r=e=>{queueMicrotask(()=>{!e.defaultPrevented&&s.current&&l(n)})};return e.addEventListener(`reset`,r),()=>{e.removeEventListener(`reset`,r)}},[t,n,a.form]),(0,X.jsxs)(`span`,{className:`caps-switch`,"data-checked":u,children:[(0,X.jsx)(`input`,{...a,checked:u,className:L(`caps-switch-input`,e),onChange:e=>{t===void 0&&l(e.target.checked),r?.(e),i?.(e.target.checked)},ref:s,role:`switch`,type:`checkbox`}),(0,X.jsx)(Oi,{checked:u})]})}),Ai=(0,Y.forwardRef)(function({className:e,invalid:t,...n},r){return(0,X.jsx)(`textarea`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:L(`textarea textarea-bordered w-full`,t&&`textarea-error`,e),ref:r})}),ji=U(K),Mi=U(Ue),Ni=U(Ft(me)),Pi=U(Le(K)),Fi=Le(Ze(File)),Ii=U(Fi),Li=at([K,me,Ue,Tt,Kt,Le(K),Fi]),Ri=U(Li),$=e=>M(ji(e.state.value),()=>``),zi=e=>M(Mi(e.state.value),()=>!1),Bi=e=>M(Ni(e.state.value),()=>null),Vi=e=>M(Pi(e.state.value),()=>[]),Hi=e=>M(Ii(e.state.value),()=>[]),Ui=e=>M(Ri(e.state.value),()=>null);function Wi({field:e,spec:t,locked:n,...r}){let[i,a]=(0,Y.useState)(!1);return(0,X.jsxs)(Nn,{children:[(0,X.jsx)(zn,{...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:$(e),onBlur:e.handleBlur,onChange:t=>{e.handleChange(t.currentTarget.value)}}),(0,X.jsx)(H,{type:`button`,variant:`outline`,size:`icon`,"aria-label":i?`Hide`:`Show`,"aria-pressed":i,disabled:n,onClick:()=>{a(e=>!e)},children:i?(0,X.jsx)(er,{"aria-hidden":`true`}):(0,X.jsx)(tr,{"aria-hidden":`true`})})]})}var Gi={text:`text`,email:`email`,url:`url`,tel:`tel`};function Ki({spec:e,field:t,locked:n,...r}){let i=Hi(t),a=n||e.readOnly===!0,o=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,X.jsx)(re,{asChild:!0,children:(0,X.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,X.jsx)(H,{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,X.jsx)(Fr,{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 qi({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,X.jsx)(zn,{...a,type:Gi[e.kind],inputMode:e.kind===`text`?void 0:e.kind,autoComplete:e.autoComplete,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:$(t),onChange:e=>{i(e.currentTarget.value)}});case`textarea`:return(0,X.jsx)(Ai,{...a,rows:e.rows??3,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:$(t),onChange:e=>{i(e.currentTarget.value)}});case`secret`:return(0,X.jsx)(Wi,{...r,field:t,spec:e,locked:n});case`money`:return(0,X.jsxs)(Nn,{children:[(0,X.jsx)(Pn,{className:`caps-field-currency`,children:e.currency??`USD`}),(0,X.jsx)(zn,{...a,inputMode:`decimal`,autoComplete:`off`,className:`caps-field-amount`,placeholder:e.placeholder??`0.00`,readOnly:e.readOnly,value:$(t),onChange:e=>{i(e.currentTarget.value)}})]});case`date`:return(0,X.jsx)(zn,{...a,type:`date`,readOnly:e.readOnly,value:$(t),onChange:e=>{i(e.currentTarget.value)}});case`number`:return(0,X.jsx)(Un,{...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:Bi(t),onValueChange:e=>{t.handleChange(e)}});case`select`:return(0,X.jsxs)(Di,{...a,value:$(t),onChange:e=>{i(e.currentTarget.value)},children:[e.placeholder===void 0?null:(0,X.jsx)(`option`,{value:``,disabled:!0,children:e.placeholder}),e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]});case`combobox`:return(0,X.jsx)(gi,{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:$(t),...e.placeholder===void 0?{}:{placeholder:e.placeholder},trigger:(0,X.jsx)(mi,{name:e.name,disabled:n||e.readOnly===!0,onBlur:t.handleBlur,children:e.options.find(e=>e.value===$(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,X.jsx)(Ki,{...r,spec:e,field:t,locked:n});case`checkbox`:return(0,X.jsx)(Ur,{...a,disabled:n||e.readOnly===!0,checked:zi(t),onChange:e=>{t.handleChange(e.currentTarget.checked)}});case`switch`:return(0,X.jsx)(ki,{...a,disabled:n||e.readOnly===!0,checked:zi(t),onCheckedChange:e=>{t.handleChange(e)}});case`radio`:case`icon-radio`:case`checkboxes`:case`icon-checkboxes`:return null}}var Ji=new Set([`radio`,`icon-radio`,`checkboxes`,`icon-checkboxes`]);function Yi({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=Vi(t),s=(e,r)=>{t.handleChange(r?[...n,e]:n.filter(t=>t!==e))};return(0,X.jsx)(Rn,{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,X.jsx)(`div`,{className:`caps-field-icon-choices`,children:e.options.map(r=>(0,X.jsx)(vi,{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,X.jsx)(bi,{children:e.options.map(r=>(0,X.jsx)(yi,{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,X.jsx)(Rn,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:(0,X.jsx)(Ci,{name:e.name,"aria-label":o,value:$(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,X.jsx)(Ei,{value:t.value,label:t.label,...t.caption===void 0?{}:{caption:t.caption},icon:t.icon,disabled:t.disabled},t.value):s?(0,X.jsx)(Ti,{value:t.value,title:t.label,description:t.description,meta:t.meta,disabled:t.disabled},t.value):(0,X.jsx)(jn,{label:t.label,orientation:`inline`,children:(0,X.jsx)(wi,{value:t.value,disabled:t.disabled})},t.value))})})}function Xi({spec:e,field:t,locked:n,error:r,render:i,...a}){return i({name:e.name,label:e.label,help:e.help,value:Ui(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 Zi({form:e,spec:t,locked:n,layout:r}){let i=Ln({form:e,name:t.name}),a=Bn(e.store,e=>e.submissionAttempts>0),o=i.state.meta.isBlurred||a?Mr(i.state.meta):void 0;if(t.render===void 0&&Ji.has(t.kind))return(0,X.jsx)(Yi,{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,X.jsx)(jn,{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,X.jsx)(qi,{spec:t,field:i,locked:n}):(0,X.jsx)(Xi,{spec:t,field:i,locked:n,error:o,render:t.render})})}var Qi=U(Je(K,Li));function $i({form:e,spec:t,locked:n,layout:r}){let i=t.when;return Bn(e.store,e=>i===void 0||i(M(Qi(e.values),()=>({}))))?(0,X.jsx)(Zi,{form:e,spec:t,locked:n,layout:r}):null}function ea({form:e,section:t,locked:n,layout:r}){let i=t.fields.map(t=>(0,X.jsx)($i,{form:e,spec:t,locked:n,layout:r},t.name));return t.title===void 0?i:(0,X.jsx)(In,{title:t.title,description:t.description,layout:r,children:i})}function ta({model:e,names:t,disabled:n=!1,layout:r}){let i=e.form;return t===void 0?e.description.sections.map(e=>(0,X.jsx)(ea,{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,X.jsx)($i,{form:i,spec:a,locked:n,layout:r},t)})}var na=class{annotation;constructor(e){this.annotation=e}},ra=class{sections;constructor(e){this.sections=e}},ia=`caps/form`,aa=0;function oa(e){aa+=1;let t={[`${ia}:${String(aa)}`]:new na(e)};return e.label!==void 0&&(t.title=e.label),e.help!==void 0&&(t.description=e.help),t}K.annotate(oa({kind:`secret`})).pipe(jt(`Secret`));var sa=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 ca(e){return Object.values(e??{}).reduce((e,t)=>t instanceof na?{...e,...t.annotation}:e,{})}function la(e){return e.reduce((e,t)=>({...e,...ca(t)}),{})}function ua(e){let t=e?.[ia];return t instanceof ra?t.sections:{}}var da=U(K);function fa(e){if(g(e))return pe(da(e.literal),{onNone:()=>null,onSome:e=>[e]});if(!Oe(e))return null;let t=[];for(let n of e.types){if(a(n))continue;let e=fa(n);if(e===null)return null;t.push(...e)}return t}function pa(e){if(nn(e))return{type:`string`,literals:[]};if(ee(e))return{type:`number`,nullable:!1};if(de(e))return{type:`boolean`};let t=fa(e);if(t!==null)return{type:`string`,literals:t};if(se(e)){let[t]=e.rest;if(t===void 0)return null;if(nn(t))return{type:`strings`,literals:[]};let n=fa(t);return n===null?null:{type:`strings`,literals:n}}if(Oe(e)){let t=e.types.filter(e=>!a(e)&&!k(e)),n=e.types.some(e=>k(e)),[r]=t;if(t.length!==1||r===void 0)return null;let i=pa(r);return i?.type===`number`?{type:`number`,nullable:n}:n?null:i}return null}function ma(e){let t=e.ast;if(!he(t))throw Error(`A schema form needs a Schema.Struct.`);return{fields:t.propertySignatures.map(e=>{let t=String(e.name),n=y(e.type),r=la([e.type.annotations,...(e.type.checks??[]).map(e=>e.annotations)]),i=r.kind===`file`?{type:`files`}:pa(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:Me(e.type),description:we(e.type)}}),sections:ua(w(t))}}function ha(e){let t=e,n=!1,r=!1;for(;;)if(t instanceof tt)n=!0,t=t.unwrap();else if(t instanceof Ye)r=!0,t=t.unwrap();else if(t instanceof Et)t=t.unwrap();else if(t instanceof bt)t=t.in;else return{node:t,optional:n,nullable:r}}function ga(e){if(e instanceof lt){let t=e.options.map(e=>ga(e));return t.some(e=>e===null)?null:t.flatMap(e=>e??[])}let t=e instanceof It?e.options:e instanceof ht?[...e.values]:null;if(t===null)return null;let n=t.map(e=>da(e));return n.every(Ie)?n.map(e=>e.value):null}function _a(e){let{node:t,nullable:n}=ha(e);if(t instanceof qt)return{type:`string`,literals:[]};if(t instanceof Ot)return{type:`number`,nullable:n};if(t instanceof Ht)return{type:`boolean`};let r=ga(t);if(r!==null)return{type:`string`,literals:r};if(t instanceof st){let e=ha(t.element).node;if(e instanceof qt)return{type:`strings`,literals:[]};let n=ga(e);return n===null?null:{type:`strings`,literals:n}}return null}function va(e){let t=[e];for(;;){let e=t[t.length-1];if(e===void 0)break;let n=e instanceof tt||e instanceof Ye||e instanceof Et?e.unwrap():e instanceof bt?e.in:e;if(n===e)break;t.push(n)}return t.reverse().map(e=>_.get(e))}function ya(e){return va(e).reduce((e,t)=>({...e,...t}),{})}function ba(e){return Object.entries(e.shape)}function xa(e){let t=ha(e).node;if(!(t instanceof Bt))throw Error(`A schema form needs a z.object.`);return{fields:ba(t).map(([e,t])=>{let n=la(va(t)),r=n.kind===`file`?{type:`files`}:_a(t);if(r===null)throw Error(`Schema field "${e}" has no form control. Annotate it with field({ render }) or a kind.`);let i=ya(t);return{name:e,valueType:r,optional:ha(t).optional,annotation:n,title:i.title,description:i.description}}),sections:ua(ya(e))}}function Sa(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??sa(e),description:r.description,meta:r.meta,icon:r.icon,caption:r.caption,disabled:r.disabled===!0}})}function Ca(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 wa(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 Ta(e){let t=e instanceof ot?xa(e):ma(e),n=t.fields.map((e,t)=>{let{kind:n,...r}=e.annotation,i=Sa(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??sa(e.name),help:a,kind:n??Ca(e.valueType,i),options:i,optionalInSchema:e.optional,index:t}}),r={};t.fields.forEach((e,t)=>{let i=n[t];i&&(r[e.name]=wa(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 Ea(e){let t=e instanceof ot?e:ae(e);return{"~standard":{...t[`~standard`],validate:e=>{let n=t[`~standard`].validate(e);return n instanceof Promise?n.then(e=>Da(e)):Da(n)}}}}function Da(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 Oa=`onServer`;function ka(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 Aa(e){if(ka(e))return()=>void 0;let t=new MutationObserver(()=>{ka(e)&&t.disconnect()});return t.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`aria-invalid`]}),()=>{t.disconnect()}}function ja(e){return e.state.meta.errorMap.onServer!==void 0}function Ma(e){e.setMeta(e=>({...e,errorMap:{...e.errorMap,[Oa]:void 0}}))}function Na(e,t,n){e.setFieldMeta(t,e=>({...e,isBlurred:!0,errorMap:{...e.errorMap,[Oa]:n}}))}function Pa(e){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(e.defaultValues),[s,c]=(0,Y.useState)(null);Fn(a,e.defaultValues)||(o(e.defaultValues),c(null));let{schema:l}=e,u=(0,Y.useMemo)(()=>Ta(l),[l]),d=(0,Y.useMemo)(()=>Ea(l),[l]),f=Hn({defaultValues:s??a,validators:{onChange:d,onSubmit:d},listeners:{onChange:({fieldApi:e})=>{n(null),i(null),ja(e)&&Ma(e)}},onSubmit:async({value:t,formApi:r})=>{n(null),i(null);let a=await Ea(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&&Na(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 Fa(e){return{dirty:Bn(e.form.store,e=>!e.isDefaultValue),submitting:Bn(e.form.store,e=>e.isSubmitting),canSubmit:Bn(e.form.store,e=>e.canSubmit)}}function Ia({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}=Fa(e),f=(0,Y.useRef)(null),p=(0,Y.useRef)(()=>void 0);return(0,Y.useEffect)(()=>()=>{p.current()},[]),(0,X.jsxs)(Vn,{...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=Aa(t))})},children:[c??(0,X.jsx)(ta,{model:e,disabled:l,layout:o}),s===void 0?(0,X.jsx)(za,{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 La({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i,...a}){let o=Pa({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i});return(0,X.jsx)(Ia,{...a,model:o})}function Ra(e){return`model`in e?(0,X.jsx)(Ia,{...e}):(0,X.jsx)(La,{...e})}function za({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}=Fa(e),d=u?null:e.saved&&!l?(0,X.jsx)(Dn,{tone:`success`,size:`compact`,label:e.saved}):l?(0,X.jsx)(Dn,{tone:`neutral`,size:`compact`,label:o}):null;return(0,X.jsxs)(Mn,{...c,error:e.error,status:d,children:[r?(0,X.jsx)(H,{type:`button`,variant:`ghost`,disabled:u,onClick:r,children:i}):n&&l?(0,X.jsx)(H,{type:`button`,variant:`ghost`,disabled:u,onClick:e.discard,children:n}):null,(0,X.jsx)(H,{...s,type:`submit`,loading:u,disabled:u||!l&&!a,title:!l&&!a?`No changes to save`:void 0,children:t})]})}var Ba=et.check(ue(/^(?!\.{1,2}$)[^/]+$/u,{message:`Enter a single file or folder name.`})),Va={file:zt({name:Ba.annotate(oa({label:`File name`}))}),folder:zt({name:Ba.annotate(oa({label:`Folder name`}))})};function Ha(e){return(0,X.jsx)(Ua,{...e},e.creation?`${e.creation.kind}:${e.creation.directory}:${e.creation.name??``}`:`closed`)}function Ua({creation:e,rootPath:t,onCreate:n,onClose:r}){let i=Pa({schema:Va[e?.kind??`file`],defaultValues:{name:e?.name??``},onSubmit:async t=>{if(!e)return;let i=await n(e,t.name);if(i)return i===`That name already exists in this directory.`?{kind:`refused`,fields:{name:i}}:{kind:`refused`,error:i};r()}}),{submitting:a}=Fa(i);return(0,X.jsx)(qe,{open:e!==null,onOpenChange:e=>{!e&&!i.form.state.isSubmitting&&r()},children:(0,X.jsxs)(Rt,{children:[(0,X.jsxs)(Gt,{className:`mb-4`,children:[(0,X.jsxs)(it,{children:[`New `,e?.kind===`folder`?`folder`:`file`]}),(0,X.jsxs)($e,{children:[`Create in `,e?.directory??t,` on this Computer.`]})]}),(0,X.jsx)(Ra,{model:i,onSubmitCapture:()=>{i.form.state.isSubmitting||i.form.setFieldValue(`name`,e=>e)},footer:(0,X.jsxs)(Mn,{divider:!1,error:i.error,children:[(0,X.jsx)(H,{variant:`ghost`,type:`button`,disabled:a,onClick:r,children:`Cancel`}),(0,X.jsx)(H,{type:`submit`,disabled:a,loading:a,children:a?`Creating…`:`Create`})]})})]})})}function Wa({files:e,patch:t,truncated:n,activeDiff:r,rowHeight:i,onOpenDiff:a}){let o=(0,Y.useMemo)(()=>Tn(t),[t]);return e.length===0?(0,X.jsx)(fn,{className:`inkcap-changes-empty`,variant:`quiet`,title:`No changes yet`,description:`Files the Agent edits show up here.`}):(0,X.jsxs)(`div`,{className:`inkcap-changes-list`,children:[n?(0,X.jsx)(`p`,{className:`inkcap-tree-note`,children:`Showing the first part of a large change. Review the rest in a terminal.`}):null,(0,X.jsx)(`ul`,{children:e.map(e=>{let t=o.get(e.path);return(0,X.jsx)(`li`,{children:(0,X.jsxs)(H,{className:`inkcap-change-file`,style:{minHeight:i},size:`sm`,variant:`ghost`,"aria-current":r===e.path?`true`:void 0,title:`Review changes to ${e.path}`,onClick:()=>{a(e.path)},children:[(0,X.jsx)(`span`,{className:`inkcap-change-mark`,"data-status":e.status,role:`img`,"aria-label":bn[e.status],children:Cn[e.status]}),(0,X.jsx)(`span`,{className:`inkcap-change-path`,children:e.path}),t?(0,X.jsxs)(`span`,{className:`inkcap-change-counts`,children:[t.additions>0?(0,X.jsxs)(`span`,{className:`inkcap-change-added`,children:[`+`,t.additions]}):null,t.deletions>0?(0,X.jsxs)(`span`,{className:`inkcap-change-removed`,children:[`−`,t.deletions]}):null]}):null]})},`${e.status}:${e.path}`)})})]})}var Ga=`That name already exists in this directory.`;function Ka({app:e,onOpenFile:t,onOpenDiff:n,activeDiff:r=null,activePath:i,rootPath:a=`/`,rootLabel:o=`Computer`,onSelectPath:c,creationRequest:l=null,onCreationRequestHandled:u,rowHeight:d=32}){let[f,p]=(0,Y.useState)(null),m=kr({app:e,rootPath:a,rootLabel:o,rowHeight:d,activePath:i,onOpenFile:t,onSelectPath:e=>{p(e),c?.(e)}}),[h,g]=(0,Y.useState)(null),_=e.capabilities.has(on),[v,y]=(0,Y.useState)(!1),b=e.capabilities.has(ln),x=cn(_n(b?e:null,a)),S=x.data?.kind===`changes`?x.data:null;function C(){m.reloadRoot(),b&&x.refetch()}(0,Y.useEffect)(()=>{x.isError&&e.ui.showToast({message:B(x.error).message,tone:`error`}).catch(e=>{console.error(`Inkcap changes toast failed`,e)})},[e,x.isError,x.error]);function w(e,t){g({kind:e,directory:wt(t,a)})}(0,Y.useEffect)(()=>{if(!l)return;let e={kind:l.kind,directory:wt(f??`${a}/`,a)};l.name!==void 0&&(e.name=l.name),l.immediate===!0&&l.name!==void 0?T(e,l.name):g(e),u?.()},[l,u,a,f]);async function T(e,n){let r=await E(e,n);r===Ga?t(mt(n,e.directory)):r!==void 0&&g(e)}async function E(n,r){let i=mt(r,n.directory);try{let a=0;for(;a!==null;){let t=a,i=await On(e.capabilities,{path:n.directory,limit:256,offset:t});if(i.entries.some(e=>e.name===r))return Ga;if(i.nextOffset!==null&&i.nextOffset<=t)return`Could not verify that name is available.`;a=i.nextOffset}n.kind===`folder`?(await e.capabilities.require(on).mkdir({path:i}),m.noteCreated(`${i}/`)):(await sn(e.capabilities,{path:i,content:new Blob([])},{}),m.noteCreated(i),t(i));return}catch(e){return e instanceof Error?B(e).message:`Couldn't create ${n.kind}. Check Computer write access.`}}let D={flex:`1`,"--trees-item-height":`${String(d)}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":`var(--color-base-100)`,"--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":`12px`};return(0,X.jsxs)(`aside`,{className:`inkcap-tree`,"aria-label":`File tree`,children:[(0,X.jsxs)(`div`,{className:`inkcap-tree-toolbar`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(wn,{"aria-hidden":`true`}),` `,(0,X.jsx)(`span`,{className:`inkcap-tree-title`,children:`Explorer`})]}),(0,X.jsxs)(`span`,{className:`inkcap-tree-actions`,children:[(0,X.jsx)(s,{icon:(0,X.jsx)(pn,{}),"aria-label":`New file`,title:`New file`,variant:`ghost`,size:`responsive`,disabled:!_,onClick:()=>{w(`file`,f??`${a}/`)}}),(0,X.jsx)(s,{icon:(0,X.jsx)(rr,{}),"aria-label":`New folder`,title:`New folder`,variant:`ghost`,size:`responsive`,disabled:!_,onClick:()=>{w(`folder`,f??`${a}/`)}}),(0,X.jsx)(s,{icon:(0,X.jsx)(Gn,{}),"aria-label":`Refresh files`,title:`Refresh files`,variant:`ghost`,size:`responsive`,disabled:m.busy||x.isFetching,onClick:C})]})]}),S===null?x.isError?(0,X.jsx)(H,{className:`inkcap-changes-retry`,size:`sm`,variant:`ghost`,onClick:()=>void x.refetch(),children:`Changes unavailable. Retry`}):null:(0,X.jsx)(Or,{className:`inkcap-changes`,size:`row`,open:v,onOpenChange:y,summary:`Changes`,trailing:(0,X.jsx)(xn,{count:S.files.length}),children:(0,X.jsx)(Wa,{files:S.files,patch:S.patch,truncated:S.truncated,activeDiff:r,rowHeight:d,onOpenDiff:e=>{n?.(e)}})}),m.error&&(0,X.jsx)(dn,{message:m.error,onRetry:m.reloadRoot}),m.rootEmpty?(0,X.jsx)(`p`,{className:`inkcap-tree-note`,children:`Empty folder`}):null,(0,X.jsxs)(`div`,{className:`inkcap-tree-files`,children:[(0,X.jsx)(Wn,{model:m.model,style:D,renderContextMenu:(e,t)=>(0,X.jsxs)(`div`,{className:`flex min-w-36 flex-col gap-xs p-xs`,role:`menu`,children:[(0,X.jsxs)(H,{className:`w-full justify-start`,disabled:!_,role:`menuitem`,title:_?void 0:`Computer write access is not granted.`,size:`sm`,variant:`ghost`,onClick:()=>{t.close({restoreFocus:!1}),w(`file`,e.path)},children:[(0,X.jsx)(pn,{"aria-hidden":`true`}),` New file`]}),(0,X.jsxs)(H,{className:`w-full justify-start`,disabled:!_,role:`menuitem`,title:_?void 0:`Computer write access is not granted.`,size:`sm`,variant:`ghost`,onClick:()=>{t.close({restoreFocus:!1}),w(`folder`,e.path)},children:[(0,X.jsx)(rr,{"aria-hidden":`true`}),` New folder`]})]})}),m.page.next!==null&&(0,X.jsxs)(H,{disabled:m.busy,onClick:m.loadNext,children:[`More in `,m.page.path]})]}),(0,X.jsx)(Ha,{creation:h,rootPath:a,onCreate:E,onClose:()=>{g(null)}})]})}export{Ka as InkcapFileTree};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bn as t,Ji as n,Qr as r,Xr as i,Yi as a,a as o,c as s,d as c,dr as l,s as u,u as d,ur as f}from"./tree-path-CnRRWDW0.js";import{Ft as p,Lt as m,_ as h,s as g}from"./changes-patch-BR_5GLNZ.js";import{Wt as _}from"./dropdown-menu-BX51yjwf.js";import{n as v,r as y,t as b}from"./useFileTree-D36ddtur.js";import{a as x,c as S,d as C,f as w,h as T,i as E,l as D,m as O,n as k,o as A,p as j,r as M,s as N,t as P,u as F}from"./index-BKLzsvfo.js";var I=f(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),L=f(`History`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),R=e(a(),1),z=256;async function B(e,t,n,r,a){r.throwIfAborted();let o=await n(e,t);if(!j.safeParse(o).success)return o;a(!0);try{let a=null,o=!1;for(let e=0;e<z&&!o;e++){r.throwIfAborted();let e=x.parse(await n(`rebuildCopies`,{cursor:a}));o=e.done,a=e.cursor}if(!o)throw new i(`Bonsai is still preparing this repository. Try again shortly.`,{code:`TIMEOUT`,retryable:!0});r.throwIfAborted();let s=await n(e,t);if(j.safeParse(s).success)throw Error(`The repository changed while loading. Refresh to retry.`);return s}finally{a(!1)}}function V({repository:e,branch:t,request:n,onSaved:r,onSaveState:a}){let o=new Map;async function s(r,a){a.throwIfAborted();let o=A.parse(await n(`files.read`,{repo:e,ref:t,path:r}));if(a.throwIfAborted(),o.binary)throw Error(`This Bonsai file is not a text document.`);if(o.text===null&&o.blob!==null)throw new i(`This Bonsai file is too large to edit.`,{code:`FILE_TOO_LARGE`,retryable:!1});return o}async function c(s,c){c.throwIfAborted();let l=w.parse(await n(`files.sync`,{}));c.throwIfAborted();let u=l.settled.find(n=>n.repo===e&&n.branch===t&&n.path===s);if(u){if(u.result.kind===`refused`)throw new i(`Bonsai refused sync: ${u.result.reason}`,{code:`CAPABILITY_DENIED`,retryable:u.result.reason===`background-unavailable`});let e=o.get(s);if(u.result.revision!==e?.version)throw new i(`Your saved file changed. Compare before syncing.`,{code:`CONFLICT`,retryable:!0});a(s,u.result)}r()}async function l(l,u,d,f){f.throwIfAborted();let p=o.get(l);if(d===void 0){let e=await s(l,f);p={file:e,contents:e.pending?.text??e.text??``,version:e.version}}if(!p)throw Error(`Reopen this Bonsai file before saving.`);if(d!==void 0&&p.contents!==d)throw new i(`The file baseline changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});if(d!==void 0){let e=await s(l,f);if(e.version!==p.version||(e.pending?.text??e.text??``)!==p.contents)throw new i(`The file changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});e.pending===void 0&&(p.file=e)}let m=F.parse({repo:e,branch:t,path:l,baseCommit:p.file.commit,baseBlob:p.file.blob,text:u,revision:p.version}),h=C.parse(await n(`files.save`,m));if(h.kind===`refused`)throw new i(`Bonsai refused this save: ${h.reason}`,{code:`CAPABILITY_DENIED`,retryable:h.reason===`background-unavailable`});if(a(l,h),h.kind===`conflict`)throw new i(`Your saved file changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});o.set(l,{file:p.file,contents:u,version:h.revision}),r(),h.kind===`saved`&&c(l,f).catch(e=>{console.error(`Bonsai sync status could not be refreshed`,e),!(o.get(l)?.version!==h.revision||f.aborted)&&a(l,{kind:`failed`,revision:h.revision,reason:`sync_failed`})})}return{kind:`repository`,id:`${e}:${t}`,label:`${e} · ${t}`,async read(e,t,n){let r=n?.revision,i=await s(e,t);if(n?.closed)return{kind:`closed`};if(n&&n.revision!==r)return{kind:`changed`};let c=i.pending?.text??i.text??``;o.set(e,{file:i,contents:c,version:i.version});let l=i.pending;return l?.state===`pending`?a(e,{kind:`saved`,revision:l.revision,state:`pending`}):l?.state===`conflict`?a(e,{kind:`conflict`,revision:l.revision,theirs:l.theirs}):l?.state===`failed`?a(e,{kind:`failed`,revision:l.revision,reason:l.failure??`sync_failed`}):i.version!==null&&a(e,{kind:`synced`,revision:i.version,commit:i.commit}),{kind:`text`,contents:c}},replace:(e,t,n,r)=>l(e,t,n,r),write:(e,t,n)=>l(e,t,void 0,n),async exists(r,i){i.throwIfAborted();let a=D.parse(await n(`files.list`,{repo:e,ref:t}));if(i.throwIfAborted(),a.paths.includes(r))return!0;if(a.truncated)throw Error(`The repository file list is incomplete.`);return!1},retry:c,async discard(s,c){c.throwIfAborted();let l=o.get(s);if(!l)throw Error(`Reopen this saved file before discarding it.`);if(l.version===null)return;let u=N.parse({repo:e,branch:t,path:s,revision:l.version}),d=S.parse(await n(`files.discard`,u));if(c.throwIfAborted(),d.kind===`conflict`)throw new i(`Your saved file changed. Refresh before discarding.`,{code:`CONFLICT`,retryable:!0});o.delete(s),a(s,null),r()},async readCommitted(e,t){let n=await s(e,t),r=n.text??``;return o.has(e)||o.set(e,{file:n,contents:r,version:n.version}),r}}}async function H(e,t,n){let r={repo:t,ref:n},i=O.parse(await e(`files.tree`,{...r,path:``})),a=D.parse(await e(`files.list`,r)),o=E.parse(await e(`commits.list`,{...r,limit:20}));if(i.commit.hash!==a.commit.hash)throw Error(`The repository changed while loading. Refresh to retry.`);return{head:i.commit.hash,branch:n,files:a.paths.map(e=>({path:e})),history:o.commits.map(e=>e.commit),truncated:a.truncated}}var U=n();function W({files:e,rowHeight:n,dirtyPaths:r,activePath:i,busy:a,onRefresh:o,onOpenFile:s}){let c=(0,R.useRef)({files:e,onOpenFile:s});c.current={files:e,onOpenFile:s};let{model:l}=b({paths:[],initialExpansion:`open`,itemHeight:n,onSelectionChange(e){let t=e[0];t&&!t.endsWith(`/`)&&c.current.files.some(e=>e.path===t)&&c.current.onOpenFile(t)}}),u=(0,R.useMemo)(()=>{let t=new Set(r);return e.flatMap(e=>t.has(e.path)?[{path:e.path,status:`modified`}]:[])},[e,r]);(0,R.useEffect)(()=>{l.resetPaths(e.map(e=>e.path))},[l,e]),(0,R.useEffect)(()=>{l.setGitStatus(u)},[l,u]),(0,R.useEffect)(()=>{for(let e of l.getSelectedPaths())e!==i&&l.getItem(e)?.deselect();i&&l.getItem(i)?.select()},[l,i]);let d={flex:`1`,"--trees-item-height":`${String(n)}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-border-radius-override":`var(--radius-field)`,"--trees-bg-override":`var(--color-base-100)`,"--trees-fg-override":`var(--color-base-content)`,"--trees-bg-muted-override":`var(--color-base-200)`,"--trees-selected-bg-override":`var(--color-base-300)`,"--trees-font-family-override":`var(--font-sans)`,"--trees-font-size-override":`12px`};return(0,U.jsxs)(`aside`,{className:`inkcap-tree`,"aria-label":`Repository files`,children:[(0,U.jsxs)(`div`,{className:`inkcap-tree-toolbar`,children:[(0,U.jsxs)(`span`,{children:[(0,U.jsx)(g,{"aria-hidden":`true`}),` Explorer`]}),(0,U.jsx)(t,{icon:(0,U.jsx)(y,{}),"aria-label":`Refresh repository`,variant:`ghost`,size:`responsive`,disabled:a,onClick:o})]}),(0,U.jsx)(`p`,{className:`inkcap-repository-legend`,children:`Changes in latest commit · drafts marked modified`}),(0,U.jsx)(v,{model:l,style:d})]})}var G={all:(e,t)=>[`inkcap-repository`,e,t],branch:(e,t,n)=>[...G.all(e,t),n]},K={branch_missing:`The repository branch no longer exists. Your text is saved; restore the branch before retrying.`,access_changed:`Repository access changed. Your text is saved; restore Bonsai's Git access before retrying.`,sync_failed:`Git could not publish this change. Your text is saved; retry sync.`,permanent_material:`The saved change no longer matches the repository state. Save again to publish your text from the current state.`};function q({connection:e,repository:t,initialBranch:n,initialPath:i,openRequestId:a,transport:f,onReady:g}){let v=m(),[y,b]=(0,R.useState)(!1),[x,S]=(0,R.useState)(0),[C,w]=(0,R.useState)(new Map),[E,D]=(0,R.useState)(``),O=(0,R.useRef)(new AbortController);(0,R.useEffect)(()=>{let e=new AbortController;return O.current=e,()=>{e.abort()}},[]);let A=(0,R.useCallback)((t,n)=>f?f(t,n):e.app.capabilities.require(T).call(`app_bonsai`,t,JSON.stringify(n)),[e.app,f]),j=(0,R.useCallback)((e,t)=>B(e,t,A,O.current.signal,e=>{S(t=>t+(e?1:-1))}),[A]),N=(0,R.useCallback)(()=>{v.invalidateQueries({queryKey:G.all(e.app.identity.surfaceId,t)})},[v,e.app,t]),F=(0,R.useRef)(new Map),z=(0,R.useMemo)(()=>{let r=`${e.app.identity.surfaceId}:${t}:${n}`,i=F.current.get(r);if(i?.app===e.app)return i;let a=V({repository:t,branch:n,request:j,onSaved:N,onSaveState:(e,r)=>{O.current.signal.aborted||w(i=>{let a=new Map(i),o=`${t}:${n}:${e}`;return r===null?a.delete(o):a.set(o,r),a})}}),o={app:e.app,source:a};return F.current.set(r,o),o},[t,n,j,N,e.app]),q=P({connection:z}),J=p({queryKey:G.branch(e.app.identity.surfaceId,t,n),queryFn:()=>H(j,t,n),refetchInterval:15e3});(0,R.useEffect)(()=>e.app.window.onBeforeClose(q.requestWindowClose),[e.app,q.requestWindowClose]),(0,R.useEffect)(()=>{g?.({requestWindowClose:q.requestWindowClose})},[g,q.requestWindowClose]);let Y=(0,R.useRef)(),X=(0,R.useRef)(new Map),Z=(0,R.useRef)(new Set);(0,R.useEffect)(()=>{if(!J.data)return;let e=`${z.app.identity.surfaceId}:${z.source.id}:${a}`;Y.current!==e&&(Y.current=e,q.onOpenFile(i));let t=X.current.get(z.source.id),n=t!==void 0&&t!==J.data.head;X.current.set(z.source.id,J.data.head);let r=new Set(q.tabs.map(e=>e.tabKey));for(let e of Z.current)r.has(e)||Z.current.delete(e);for(let e of q.tabs)if(!(e.target.closed||e.connection!==z||!n&&!Z.current.has(e.tabKey))){if(e.target.saving){Z.current.add(e.tabKey);continue}Z.current.delete(e.tabKey),e.target.dirty||q.onReopen(e,{background:!0})}},[J.data,z,i,a,q]);let Q=q.tabs.find(e=>e.tabKey===q.active),$=Q?.connection?.source?C.get(`${Q.connection.source.id}:${Q.path}`):void 0,ee=$?.kind===`saved`?`Saved · syncing`:$?.kind===`synced`?`Synced · ${$.commit.slice(0,7)}`:$?.kind===`conflict`?`Sync conflict · Compare`:$?.kind===`failed`?`Sync failed · Retry`:void 0;async function te(){if(!Q?.connection?.source)return;let e=F.current.get(`${Q.connection.app.identity.surfaceId}:${Q.connection.source.id}`);if(e)try{D(``),await e.source.retry(Q.path,O.current.signal)}catch(e){console.error(`Bonsai sync retry failed`,e),D(`${r(e).message} Your saved text remains in Bonsai.`)}}async function ne(){if(!Q?.connection?.source)return;let e=()=>!Q.target.dirty&&!Q.target.saving&&!Q.target.closed;if(!e())return;let t=F.current.get(`${Q.connection.app.identity.surfaceId}:${Q.connection.source.id}`);if(t)try{D(``);let n=await t.source.read(Q.path,O.current.signal);if(n.kind!==`text`)throw Error(`This saved text is unavailable.`);if(!e())return;await t.source.replace(Q.path,n.contents,n.contents,O.current.signal)}catch(e){console.error(`Bonsai explicit re-save failed`,e),D(`${r(e).message} Your saved text and open edits remain available.`)}}return(0,U.jsxs)(`div`,{className:`inkcap-repository`,children:[(0,U.jsxs)(`div`,{className:`inkcap-repository-toolbar`,children:[(0,U.jsxs)(`span`,{className:`inkcap-repository-name`,children:[(0,U.jsx)(I,{"aria-hidden":`true`}),` `,t,` · `,n]}),(0,U.jsxs)(l,{size:`sm`,variant:`outline`,onClick:()=>{b(!0)},children:[(0,U.jsx)(L,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),` `,`History`]})]}),x>0&&(0,U.jsx)(M,{message:`Loading this repository…`}),J.data?.truncated&&(0,U.jsx)(_,{tone:`info`,title:`Only the indexed files are shown`}),E&&(0,U.jsx)(h,{message:E,onDismiss:()=>{D(``)}}),$?.kind===`failed`&&!E&&(0,U.jsx)(_,{tone:`warning`,title:$.reason===`permanent_material`?`Sync needs a new save`:`Sync failed`,description:K[$.reason],action:(0,U.jsx)(l,{size:`sm`,disabled:$.reason===`permanent_material`&&Q!==void 0&&(Q.target.dirty||Q.target.saving),onClick:()=>void($.reason===`permanent_material`?ne():te()),children:$.reason===`permanent_material`?`Save again`:`Retry`})}),(0,U.jsx)(k,{model:{...q,repositoryStatus:ee,repositoryStates:C,canList:!0,sourceLabel:z.source.label,onReadCurrent:async(e,t)=>{if(e.connection?.source?.kind!==`repository`)return q.onReadCurrent(e);let n=F.current.get(`${e.connection.app.identity.surfaceId}:${e.connection.source.id}`);if(!n||e.target.closed)throw Error(`This Bonsai file is no longer open.`);return t&&await n.source.discard(e.path,O.current.signal),n.source.readCommitted(e.path,O.current.signal)},error:J.error?`${r(J.error).message} Your open edits remain available.`:void 0,fileTree:(e,t)=>(0,U.jsx)(W,{rowHeight:t?44:32,files:J.data?.files??[],dirtyPaths:q.tabs.filter(e=>e.connection===z&&e.dirty).map(e=>e.path),activePath:Q?.connection===z?Q.path:null,busy:J.isFetching,onRefresh:N,onOpenFile:e},t?`phone`:`desktop`)}}),(0,U.jsx)(o,{open:y,onOpenChange:b,children:(0,U.jsxs)(u,{children:[(0,U.jsxs)(d,{children:[(0,U.jsx)(c,{children:`Commit history`}),(0,U.jsxs)(s,{children:[t,` · `,n]})]}),(0,U.jsx)(`ol`,{className:`inkcap-repository-history`,children:J.data?.history.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`code`,{children:e.hash.slice(0,7)}),` `,e.message,(0,U.jsx)(`span`,{className:`text-dim`,children:e.author.name})]},e.hash))})]})})]})}export{q as InkcapRepositoryApp};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bn as t,Ji as n,Qr as r,Xr as i,Yi as a,a as o,c as s,d as c,dr as l,s as u,u as d,ur as f}from"./tree-path-AxEg-Kjh.js";import{Ft as p,Lt as m,_ as h,s as g}from"./changes-patch-CrPexAyH.js";import{Wt as _}from"./dropdown-menu-D1-KaUEJ.js";import{n as v,r as y,t as b}from"./useFileTree-C86PCVGL.js";import{a as x,c as S,d as C,f as w,h as T,i as E,l as D,m as O,n as k,o as A,p as j,r as M,s as N,t as P,u as F}from"./index-DqkwqNVw.js";var I=f(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),L=f(`History`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),R=e(a(),1),z=256;async function B(e,t,n,r,a){r.throwIfAborted();let o=await n(e,t);if(!j.safeParse(o).success)return o;a(!0);try{let a=null,o=!1;for(let e=0;e<z&&!o;e++){r.throwIfAborted();let e=x.parse(await n(`rebuildCopies`,{cursor:a}));o=e.done,a=e.cursor}if(!o)throw new i(`Bonsai is still preparing this repository. Try again shortly.`,{code:`TIMEOUT`,retryable:!0});r.throwIfAborted();let s=await n(e,t);if(j.safeParse(s).success)throw Error(`The repository changed while loading. Refresh to retry.`);return s}finally{a(!1)}}function V({repository:e,branch:t,request:n,onSaved:r,onSaveState:a}){let o=new Map;async function s(r,a){a.throwIfAborted();let o=A.parse(await n(`files.read`,{repo:e,ref:t,path:r}));if(a.throwIfAborted(),o.binary)throw Error(`This Bonsai file is not a text document.`);if(o.text===null&&o.blob!==null)throw new i(`This Bonsai file is too large to edit.`,{code:`FILE_TOO_LARGE`,retryable:!1});return o}async function c(s,c){c.throwIfAborted();let l=w.parse(await n(`files.sync`,{}));c.throwIfAborted();let u=l.settled.find(n=>n.repo===e&&n.branch===t&&n.path===s);if(u){if(u.result.kind===`refused`)throw new i(`Bonsai refused sync: ${u.result.reason}`,{code:`CAPABILITY_DENIED`,retryable:u.result.reason===`background-unavailable`});let e=o.get(s);if(u.result.revision!==e?.version)throw new i(`Your saved file changed. Compare before syncing.`,{code:`CONFLICT`,retryable:!0});a(s,u.result)}r()}async function l(l,u,d,f){f.throwIfAborted();let p=o.get(l);if(d===void 0){let e=await s(l,f);p={file:e,contents:e.pending?.text??e.text??``,version:e.version}}if(!p)throw Error(`Reopen this Bonsai file before saving.`);if(d!==void 0&&p.contents!==d)throw new i(`The file baseline changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});if(d!==void 0){let e=await s(l,f);if(e.version!==p.version||(e.pending?.text??e.text??``)!==p.contents)throw new i(`The file changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});e.pending===void 0&&(p.file=e)}let m=F.parse({repo:e,branch:t,path:l,baseCommit:p.file.commit,baseBlob:p.file.blob,text:u,revision:p.version}),h=C.parse(await n(`files.save`,m));if(h.kind===`refused`)throw new i(`Bonsai refused this save: ${h.reason}`,{code:`CAPABILITY_DENIED`,retryable:h.reason===`background-unavailable`});if(a(l,h),h.kind===`conflict`)throw new i(`Your saved file changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});o.set(l,{file:p.file,contents:u,version:h.revision}),r(),h.kind===`saved`&&c(l,f).catch(e=>{console.error(`Bonsai sync status could not be refreshed`,e),!(o.get(l)?.version!==h.revision||f.aborted)&&a(l,{kind:`failed`,revision:h.revision,reason:`sync_failed`})})}return{kind:`repository`,id:`${e}:${t}`,label:`${e} · ${t}`,async read(e,t,n){let r=n?.revision,i=await s(e,t);if(n?.closed)return{kind:`closed`};if(n&&n.revision!==r)return{kind:`changed`};let c=i.pending?.text??i.text??``;o.set(e,{file:i,contents:c,version:i.version});let l=i.pending;return l?.state===`pending`?a(e,{kind:`saved`,revision:l.revision,state:`pending`}):l?.state===`conflict`?a(e,{kind:`conflict`,revision:l.revision,theirs:l.theirs}):l?.state===`failed`?a(e,{kind:`failed`,revision:l.revision,reason:l.failure??`sync_failed`}):i.version!==null&&a(e,{kind:`synced`,revision:i.version,commit:i.commit}),{kind:`text`,contents:c}},replace:(e,t,n,r)=>l(e,t,n,r),write:(e,t,n)=>l(e,t,void 0,n),async exists(r,i){i.throwIfAborted();let a=D.parse(await n(`files.list`,{repo:e,ref:t}));if(i.throwIfAborted(),a.paths.includes(r))return!0;if(a.truncated)throw Error(`The repository file list is incomplete.`);return!1},retry:c,async discard(s,c){c.throwIfAborted();let l=o.get(s);if(!l)throw Error(`Reopen this saved file before discarding it.`);if(l.version===null)return;let u=N.parse({repo:e,branch:t,path:s,revision:l.version}),d=S.parse(await n(`files.discard`,u));if(c.throwIfAborted(),d.kind===`conflict`)throw new i(`Your saved file changed. Refresh before discarding.`,{code:`CONFLICT`,retryable:!0});o.delete(s),a(s,null),r()},async readCommitted(e,t){let n=await s(e,t),r=n.text??``;return o.has(e)||o.set(e,{file:n,contents:r,version:n.version}),r}}}async function H(e,t,n){let r={repo:t,ref:n},i=O.parse(await e(`files.tree`,{...r,path:``})),a=D.parse(await e(`files.list`,r)),o=E.parse(await e(`commits.list`,{...r,limit:20}));if(i.commit.hash!==a.commit.hash)throw Error(`The repository changed while loading. Refresh to retry.`);return{head:i.commit.hash,branch:n,files:a.paths.map(e=>({path:e})),history:o.commits.map(e=>e.commit),truncated:a.truncated}}var U=n();function W({files:e,rowHeight:n,dirtyPaths:r,activePath:i,busy:a,onRefresh:o,onOpenFile:s}){let c=(0,R.useRef)({files:e,onOpenFile:s});c.current={files:e,onOpenFile:s};let{model:l}=b({paths:[],initialExpansion:`open`,itemHeight:n,onSelectionChange(e){let t=e[0];t&&!t.endsWith(`/`)&&c.current.files.some(e=>e.path===t)&&c.current.onOpenFile(t)}}),u=(0,R.useMemo)(()=>{let t=new Set(r);return e.flatMap(e=>t.has(e.path)?[{path:e.path,status:`modified`}]:[])},[e,r]);(0,R.useEffect)(()=>{l.resetPaths(e.map(e=>e.path))},[l,e]),(0,R.useEffect)(()=>{l.setGitStatus(u)},[l,u]),(0,R.useEffect)(()=>{for(let e of l.getSelectedPaths())e!==i&&l.getItem(e)?.deselect();i&&l.getItem(i)?.select()},[l,i]);let d={flex:`1`,"--trees-item-height":`${String(n)}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-border-radius-override":`var(--radius-field)`,"--trees-bg-override":`var(--color-base-100)`,"--trees-fg-override":`var(--color-base-content)`,"--trees-bg-muted-override":`var(--color-base-200)`,"--trees-selected-bg-override":`var(--color-base-300)`,"--trees-font-family-override":`var(--font-sans)`,"--trees-font-size-override":`12px`};return(0,U.jsxs)(`aside`,{className:`inkcap-tree`,"aria-label":`Repository files`,children:[(0,U.jsxs)(`div`,{className:`inkcap-tree-toolbar`,children:[(0,U.jsxs)(`span`,{children:[(0,U.jsx)(g,{"aria-hidden":`true`}),` Explorer`]}),(0,U.jsx)(t,{icon:(0,U.jsx)(y,{}),"aria-label":`Refresh repository`,variant:`ghost`,size:`responsive`,disabled:a,onClick:o})]}),(0,U.jsx)(`p`,{className:`inkcap-repository-legend`,children:`Changes in latest commit · drafts marked modified`}),(0,U.jsx)(v,{model:l,style:d})]})}var G={all:(e,t)=>[`inkcap-repository`,e,t],branch:(e,t,n)=>[...G.all(e,t),n]},K={branch_missing:`The repository branch no longer exists. Your text is saved; restore the branch before retrying.`,access_changed:`Repository access changed. Your text is saved; restore Bonsai's Git access before retrying.`,sync_failed:`Git could not publish this change. Your text is saved; retry sync.`,permanent_material:`The saved change no longer matches the repository state. Save again to publish your text from the current state.`};function q({connection:e,repository:t,initialBranch:n,initialPath:i,openRequestId:a,transport:f,onReady:g}){let v=m(),[y,b]=(0,R.useState)(!1),[x,S]=(0,R.useState)(0),[C,w]=(0,R.useState)(new Map),[E,D]=(0,R.useState)(``),O=(0,R.useRef)(new AbortController);(0,R.useEffect)(()=>{let e=new AbortController;return O.current=e,()=>{e.abort()}},[]);let A=(0,R.useCallback)((t,n)=>f?f(t,n):e.app.capabilities.require(T).call(`app_bonsai`,t,JSON.stringify(n)),[e.app,f]),j=(0,R.useCallback)((e,t)=>B(e,t,A,O.current.signal,e=>{S(t=>t+(e?1:-1))}),[A]),N=(0,R.useCallback)(()=>{v.invalidateQueries({queryKey:G.all(e.app.identity.surfaceId,t)})},[v,e.app,t]),F=(0,R.useRef)(new Map),z=(0,R.useMemo)(()=>{let r=`${e.app.identity.surfaceId}:${t}:${n}`,i=F.current.get(r);if(i?.app===e.app)return i;let a=V({repository:t,branch:n,request:j,onSaved:N,onSaveState:(e,r)=>{O.current.signal.aborted||w(i=>{let a=new Map(i),o=`${t}:${n}:${e}`;return r===null?a.delete(o):a.set(o,r),a})}}),o={app:e.app,source:a};return F.current.set(r,o),o},[t,n,j,N,e.app]),q=P({connection:z}),J=p({queryKey:G.branch(e.app.identity.surfaceId,t,n),queryFn:()=>H(j,t,n),refetchInterval:15e3});(0,R.useEffect)(()=>e.app.window.onBeforeClose(q.requestWindowClose),[e.app,q.requestWindowClose]),(0,R.useEffect)(()=>{g?.({requestWindowClose:q.requestWindowClose})},[g,q.requestWindowClose]);let Y=(0,R.useRef)(),X=(0,R.useRef)(new Map),Z=(0,R.useRef)(new Set);(0,R.useEffect)(()=>{if(!J.data)return;let e=`${z.app.identity.surfaceId}:${z.source.id}:${a}`;Y.current!==e&&(Y.current=e,q.onOpenFile(i));let t=X.current.get(z.source.id),n=t!==void 0&&t!==J.data.head;X.current.set(z.source.id,J.data.head);let r=new Set(q.tabs.map(e=>e.tabKey));for(let e of Z.current)r.has(e)||Z.current.delete(e);for(let e of q.tabs)if(!(e.target.closed||e.connection!==z||!n&&!Z.current.has(e.tabKey))){if(e.target.saving){Z.current.add(e.tabKey);continue}Z.current.delete(e.tabKey),e.target.dirty||q.onReopen(e,{background:!0})}},[J.data,z,i,a,q]);let Q=q.tabs.find(e=>e.tabKey===q.active),$=Q?.connection?.source?C.get(`${Q.connection.source.id}:${Q.path}`):void 0,ee=$?.kind===`saved`?`Saved · syncing`:$?.kind===`synced`?`Synced · ${$.commit.slice(0,7)}`:$?.kind===`conflict`?`Sync conflict · Compare`:$?.kind===`failed`?`Sync failed · Retry`:void 0;async function te(){if(!Q?.connection?.source)return;let e=F.current.get(`${Q.connection.app.identity.surfaceId}:${Q.connection.source.id}`);if(e)try{D(``),await e.source.retry(Q.path,O.current.signal)}catch(e){console.error(`Bonsai sync retry failed`,e),D(`${r(e).message} Your saved text remains in Bonsai.`)}}async function ne(){if(!Q?.connection?.source)return;let e=()=>!Q.target.dirty&&!Q.target.saving&&!Q.target.closed;if(!e())return;let t=F.current.get(`${Q.connection.app.identity.surfaceId}:${Q.connection.source.id}`);if(t)try{D(``);let n=await t.source.read(Q.path,O.current.signal);if(n.kind!==`text`)throw Error(`This saved text is unavailable.`);if(!e())return;await t.source.replace(Q.path,n.contents,n.contents,O.current.signal)}catch(e){console.error(`Bonsai explicit re-save failed`,e),D(`${r(e).message} Your saved text and open edits remain available.`)}}return(0,U.jsxs)(`div`,{className:`inkcap-repository`,children:[(0,U.jsxs)(`div`,{className:`inkcap-repository-toolbar`,children:[(0,U.jsxs)(`span`,{className:`inkcap-repository-name`,children:[(0,U.jsx)(I,{"aria-hidden":`true`}),` `,t,` · `,n]}),(0,U.jsxs)(l,{size:`sm`,variant:`outline`,onClick:()=>{b(!0)},children:[(0,U.jsx)(L,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),` `,`History`]})]}),x>0&&(0,U.jsx)(M,{message:`Loading this repository…`}),J.data?.truncated&&(0,U.jsx)(_,{tone:`info`,title:`Only the indexed files are shown`}),E&&(0,U.jsx)(h,{message:E,onDismiss:()=>{D(``)}}),$?.kind===`failed`&&!E&&(0,U.jsx)(_,{tone:`warning`,title:$.reason===`permanent_material`?`Sync needs a new save`:`Sync failed`,description:K[$.reason],action:(0,U.jsx)(l,{size:`sm`,disabled:$.reason===`permanent_material`&&Q!==void 0&&(Q.target.dirty||Q.target.saving),onClick:()=>void($.reason===`permanent_material`?ne():te()),children:$.reason===`permanent_material`?`Save again`:`Retry`})}),(0,U.jsx)(k,{model:{...q,repositoryStatus:ee,repositoryStates:C,canList:!0,sourceLabel:z.source.label,onReadCurrent:async(e,t)=>{if(e.connection?.source?.kind!==`repository`)return q.onReadCurrent(e);let n=F.current.get(`${e.connection.app.identity.surfaceId}:${e.connection.source.id}`);if(!n||e.target.closed)throw Error(`This Bonsai file is no longer open.`);return t&&await n.source.discard(e.path,O.current.signal),n.source.readCommitted(e.path,O.current.signal)},error:J.error?`${r(J.error).message} Your open edits remain available.`:void 0,fileTree:(e,t)=>(0,U.jsx)(W,{rowHeight:t?44:32,files:J.data?.files??[],dirtyPaths:q.tabs.filter(e=>e.connection===z&&e.dirty).map(e=>e.path),activePath:Q?.connection===z?Q.path:null,busy:J.isFetching,onRefresh:N,onOpenFile:e},t?`phone`:`desktop`)}}),(0,U.jsx)(o,{open:y,onOpenChange:b,children:(0,U.jsxs)(u,{children:[(0,U.jsxs)(d,{children:[(0,U.jsx)(c,{children:`Commit history`}),(0,U.jsxs)(s,{children:[t,` · `,n]})]}),(0,U.jsx)(`ol`,{className:`inkcap-repository-history`,children:J.data?.history.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`code`,{children:e.hash.slice(0,7)}),` `,e.message,(0,U.jsx)(`span`,{className:`text-dim`,children:e.author.name})]},e.hash))})]})})]})}export{q as InkcapRepositoryApp};
|