@fungi.computer/inkcap 0.16.9 → 0.16.11
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/InkcapFileTree-CZl7zhDc.js +1 -0
- package/dist/assets/{InkcapRepositoryApp-Bv1ed4i9.js → InkcapRepositoryApp-D-yh4xmk.js} +1 -1
- package/dist/assets/{index-BHkyIFMZ.js → index-BVLTplok.js} +2 -2
- package/dist/index.html +1 -1
- package/package.json +4 -4
- package/dist/assets/InkcapFileTree-GXbbbVKb.js +0 -1
|
@@ -0,0 +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-DB2EeXaO.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-CbV6wbMY.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-TE2s7pCp.js";import{n as Wn,r as Gn,t as Kn}from"./useFileTree-DxYXvUH4.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 +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-DB2EeXaO.js";import{Ft as p,Lt as m,_ as h,s as g}from"./changes-patch-CbV6wbMY.js";import{Wt as _}from"./dropdown-menu-DRWiivN4.js";import{n as v,r as y,t as b}from"./useFileTree-DxYXvUH4.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-BHkyIFMZ.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-DB2EeXaO.js";import{Ft as p,Lt as m,_ as h,s as g}from"./changes-patch-CbV6wbMY.js";import{Wt as _}from"./dropdown-menu-DRWiivN4.js";import{n as v,r as y,t as b}from"./useFileTree-DxYXvUH4.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-BVLTplok.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};
|