rebase-git 0.0.2-nightly.20260929.133 → 0.0.2

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/runtime.js CHANGED
@@ -8928,7 +8928,7 @@ function resolveBrowserAssetsRoot() {
8928
8928
  return fileURLToPath2(root);
8929
8929
  }
8930
8930
  function productVersion() {
8931
- return "0.0.2-nightly.20260929.133";
8931
+ return "0.0.2";
8932
8932
  }
8933
8933
  function versionOutput() {
8934
8934
  return [
@@ -12,4 +12,4 @@ Error generating stack: `+e.message+`
12
12
  `).length-1,a=s.find(({start:e,length:t})=>r>=e&&r<e+t);a!==void 0&&i(a.regionId)}})]})]})})}function qC(e,t){let n=[],r=[];for(let i of e.segments){let e=n.length,a=Co(i,t);if(n.push(...a),i.kind===`text`)continue;let{region:o}=i;r.push({regionId:o.id,ordinal:r.length+1,start:e,length:a.length,edges:ts(i,t)?null:i.typed===null?JC($o(t,o.id),e):[{colour:GC,line:e,length:a.length}]})}return{lines:n,blocks:r}}function JC(e,t){let n=[];return e.forEach(({side:e},r)=>{let i=Bo[e].edge,a=n.at(-1);a?.colour===i?n[n.length-1]={...a,length:a.length+1}:n.push({colour:i,line:t+r,length:1})}),n}function YC({block:e,onUndo:t}){return e.edges===null?(0,q.jsx)(`div`,{"data-region":e.regionId,"aria-hidden":`true`,className:`absolute left-0 w-[3px] bg-foreground/15`,style:XC(e)}):(0,q.jsxs)(q.Fragment,{children:[e.length===0?(0,q.jsx)(`div`,{"aria-hidden":`true`,className:r(`absolute left-0 h-0.5 w-full`,GC),style:{top:e.start*WC-1}}):e.edges.map(e=>(0,q.jsx)(`div`,{"aria-hidden":`true`,className:r(`absolute left-0 w-[3px]`,e.colour),style:{top:e.line*WC,height:e.length*WC}},e.line)),(0,q.jsx)(T,{"data-region":e.regionId,variant:`ghost`,size:`xs`,"aria-label":`Undo region ${e.ordinal}`,className:`absolute right-1 h-5 px-1 text-[11px] text-muted-foreground sm:h-5`,style:{top:Math.max(e.start*WC-(e.length===0?10:0),0)},onClick:()=>t(e.regionId),children:`Undo`})]})}function XC(e){return{top:e.start*WC,height:Math.max(e.length,1)*WC}}var ZC={current:`Alt+1`,incoming:`Alt+2`},QC=(0,K.memo)(function({loaded:e,sides:t,leftSide:n,scrollRef:r,...i}){let a=(0,K.useMemo)(()=>$C(e,n),[e,n]),o={...i,side:n,rows:a.left},s={...i,side:`incoming`,rows:a.right};return(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,q.jsxs)(`div`,{className:`flex shrink-0 border-border border-b`,children:[(0,q.jsx)(tw,{side:n,sides:t,className:`pl-9`}),(0,q.jsx)(tw,{side:`incoming`,sides:t,className:`pr-9`})]}),(0,q.jsx)(`div`,{ref:r,className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`flex font-mono text-xs leading-5`,children:[(0,q.jsx)(nw,{...o}),(0,q.jsx)(Jo,{...o}),(0,q.jsx)(Jo,{...s}),(0,q.jsx)(nw,{...s})]})})]})});function $C(e,t){let n=[],r=[],i=0;for(let a of e.segments){if(a.kind===`text`){for(let e of a.lines){let t=`line-${n.length}`;n.push({kind:`context`,key:t,text:e}),r.push({kind:`context`,key:t,text:e})}continue}i+=1;let{region:e}=a,o=Math.max(e[t].length,e.incoming.length,1);for(let a=0;a<o;a+=1){let s={region:e,ordinal:i,first:a===0,last:a===o-1};n.push(ew(s,t,a)),r.push(ew(s,`incoming`,a))}}return{left:n,right:r}}function ew(e,t,n){let r=e.region[t][n],i=`${e.region.id}-${n}`;return r===void 0?{kind:`padding`,key:i,band:e}:{kind:`line`,key:i,band:e,side:t,index:n,text:r}}function tw({side:e,sides:t,className:n}){let{ref:i,commit:a,subject:o}=t[e];return(0,q.jsxs)(`div`,{className:r(`flex h-8 min-w-0 flex-1 items-center gap-2 px-2 text-xs`,n),children:[(0,q.jsx)(`strong`,{className:`shrink-0 font-semibold`,children:zo[e]}),(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:a===null?i:a.slice(0,7)}),(0,q.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:o})]})}function nw({rows:e,side:t,picks:n,activeRegion:i,lines:a}){return(0,q.jsx)(`div`,{className:`w-7 shrink-0 bg-muted/40 select-none`,children:e.map(e=>(0,q.jsx)(`div`,{"data-region":e.kind!==`context`&&e.band.first?e.band.region.id:void 0,className:r(`flex h-5 items-center justify-center`,e.kind!==`context`&&Go(e.band,i)),children:e.kind!==`context`&&e.band.first&&e.band.region[t].length>0&&(0,q.jsx)(rw,{band:e.band,side:t,taken:So($o(n,e.band.region.id),e.band.region,t),active:e.band.region.id===i,lines:a})},e.key))})}function rw({band:e,side:t,taken:n,active:i,lines:a}){return(0,q.jsx)(T,{variant:`ghost`,size:`icon-xs`,"aria-label":`Take ${zo[t].toLowerCase()}, region ${e.ordinal}`,"aria-pressed":n,"aria-keyshortcuts":i?ZC[t]:void 0,className:r(`size-5 border-border bg-background text-muted-foreground sm:size-5`,n&&[`border-transparent text-background`,Bo[t].edge]),onClick:()=>a.take(e.region,t),children:(0,q.jsx)(gh,{"aria-hidden":`true`,className:`size-3.5`})})}function iw(e,t){return e.segments.flatMap(e=>Co(e,t))}function aw(e,t,n,r){let i=iw(e,t),a=n.split(`
13
13
  `),o=n.slice(0,r).split(`
14
14
  `).length-1,s=0,c=Math.min(i.length,a.length,o);for(;s<c&&i[s]===a[s];)s+=1;let l=0,u=Math.min(i.length-s,a.length-o-1);for(;l<u&&i[i.length-1-l]===a[a.length-1-l];)l+=1;let d=s,f=i.length-l,p=a.length-l;return d===f&&d>0?--d:d===f&&f<i.length&&(f+=1,p+=1),ow(e,t,d,f,a.slice(d,p))}function ow(e,t,n,r,i){let a=sw(e,t),o=a.filter(({start:e,end:t})=>t>e?e<r&&t>n:e>n&&e<r),s=o[0],c=o.at(-1);if(s===void 0||c===void 0)return{...e,segments:[...e.segments,{kind:`text`,lines:i}]};let l=[...Co(s.segment,t).slice(0,n-s.start),...i,...Co(c.segment,t).slice(r-c.start)];return{...e,segments:a.flatMap(({segment:e})=>e===s.segment?[cw(e,l,t)]:o.some(t=>t.segment===e)?e.kind===`text`?[]:[cw(e,[],t)]:[e])}}function sw(e,t){let n=0;return e.segments.map(e=>{let r=n+Co(e,t).length,i={segment:e,start:n,end:r};return n=r,i})}function cw(e,t,n){if(e.kind===`text`)return{kind:`text`,lines:t};let r=Co(e,n);return r.length===t.length&&r.every((e,n)=>e===t[n])?e:{...e,typed:t}}var lw=bo.write,uw=new Map;function dw(e){let{path:t}=e,n=Wo(e),r=Zo(e),{run:i}=Xr(lw,{target:e,answers:(e,{repositoryId:t,worktreePath:n,path:r})=>[Ri(bo.document,{repositoryId:t,worktreePath:n,path:r},e)]}),a=(0,K.useRef)({revision:null,sent:null,pending:null,running:!1,waiters:[]}),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(uw),[f,p]=(0,K.useState)(null),m=(0,K.useCallback)(e=>{a.current.revision=e.file.revision,a.current.sent=e.content;let t=Io(e);s(t),l(t),d(uw)},[]),h=n.refetch,g=(0,K.useCallback)(async()=>{let{data:e}=await h();e!==void 0&&m(e)},[m,h]),_=(0,K.useCallback)(async e=>{let n=a.current;n.running=!0,n.sent=e;let r=await i({path:t,revision:n.revision??``,content:e});n.running=!1,r._tag===`Ok`?n.revision=r.value.file.revision:(n.sent=null,n.pending=null,qo(r)===`Stale`?(p(`${t.split(`/`).at(-1)??t} changed on disk. Reloaded.`),g()):p(Cr(r)));let o=n.pending;if(n.pending=null,o!==null)return void _(o);for(let e of n.waiters.splice(0))e()},[i,t,g]),v=n.data;return(0,K.useEffect)(()=>{let e=a.current;v===void 0||e.running||e.pending!==null||v.file.revision===e.revision||m(v)},[v,m]),(0,K.useEffect)(()=>{if(c===null)return;let e=Qo(c,u),t=a.current;e!==(t.pending??t.sent)&&(t.running?t.pending=e:_(e))},[c,u,_]),{document:n,list:r,loaded:o,model:c,picks:u,notice:f,choose:(0,K.useCallback)((e,t)=>{p(null),d(n=>new Map(n).set(e,t($o(n,e)))),l(t=>t&&yo(t,e,null))},[]),revision:()=>a.current.revision,settled:()=>{let e=a.current;return!e.running&&e.pending===null?Promise.resolve():new Promise(t=>e.waiters.push(t))},edit:(e,t)=>{p(null),l(n=>n&&aw(n,u,e,t))},undo:e=>{p(null),d(t=>{let n=new Map(t);return n.delete(e),n}),l(t=>t&&yo(t,e,null))}}}function fw(e,t,n){let[r,i]=(0,K.useState)(null),a=(0,K.useRef)(null),o=(0,K.useRef)(null),s=e===null?[]:No(e),c=s.find(({region:e})=>e.id===r)??s.find(e=>ts(e,t))??s[0],l=c===void 0?-1:s.indexOf(c),u=pw(n,i,(0,K.useCallback)(e=>{i(e),mw(o.current,e)},[])),d=e=>{let t=s[l+e];t!==void 0&&(i(t.region.id),mw(a.current,t.region.id),mw(o.current,t.region.id))};return{lines:u,sidesRef:a,resultRef:o,activeRegion:c?.region.id??null,hasPrevious:l>0,hasNext:l!==-1&&l<s.length-1,previous:()=>d(-1),next:()=>d(1),takeActive:e=>{c!==void 0&&u.take(c.region,e)},focusFromResult:e=>{i(e),mw(a.current,e)}}}function pw(e,t,n){let r=(0,K.useRef)(null);return(0,K.useMemo)(()=>{let i=(n,r)=>{t(n),e(n,r)};return{press:(e,t)=>{let n=Mo(t,e);r.current={target:e,mode:n},i(e.regionId,t=>Po(t,e,n))},enter:(t,n)=>{let i=r.current;if(i===null||!(n&1)){r.current=null;return}let a=i.target;if(a.regionId!==t.regionId||a.side!==t.side||a.index===t.index)return;r.current={...i,target:t};let o=t.index>a.index?1:-1;e(t.regionId,e=>xo(e,t.side,a.index+o,t.index,i.mode))},toggle:e=>i(e.regionId,t=>Uo(t,e)),extend:(e,t)=>i(e.regionId,n=>Po(Po(n,e,`add`),{side:e.side,index:t},`add`)),take:(e,t)=>i(e.id,n=>ko(n,e,t)),focusRegion:n}},[e,n,t])}function mw(e,t){let n=e?.querySelector(`[data-region="${CSS.escape(t)}"]`);if(e==null||n==null)return;let r=n.getBoundingClientRect().top-e.getBoundingClientRect().top;e.scrollTop=Math.max(e.scrollTop+r-40,0)}function hw({path:e,...t}){let n=La();return n===void 0?null:(0,q.jsx)(gw,{input:{repositoryId:n.repositoryId,worktreePath:n.worktreePath,path:e},...t},JSON.stringify([n.repositoryId,n.worktreePath,e]))}function gw({input:e,onOpen:t,onClose:n,toolbarActions:r}){let i=dw(e),[a,o]=(0,K.useState)(!1),s=a?`base`:`current`,c=fw(i.model,i.picks,i.choose),l=i.list.data?.files.find(({path:t})=>t===e.path),u=Lo(e,{revision:()=>i.revision()??l?.revision,onResolved:r=>{let i=r.files.find(({path:t,openRegions:n})=>t!==e.path&&n>0);i===void 0?n():t(i.path)}}),{loaded:d,model:f,picks:p}=i,m=i.document.data,h=i.document.error,g=Ro(h),_=!g&&d!==null&&f!==null&&m!==void 0,v=u.confirming===e.path,y=i.notice??u.problem??(h!==null&&!g?Cr(h):null),b=async t=>{await i.settled(),await u.resolve(e.path,t)};return(0,q.jsxs)(`section`,{"aria-label":`Merge view`,className:`flex h-full min-h-0 flex-col bg-repository`,onKeyDown:e=>{let t=_w(e);if(!(t===null||!e.currentTarget.contains(e.target))){if(e.preventDefault(),t===`close`)return v?u.cancel():n();if(t===`previous`)return c.previous();if(t===`next`)return c.next();c.takeActive(t)}},children:[(0,q.jsxs)(`div`,{className:`flex min-h-12 shrink-0 flex-wrap items-center gap-2 border-border/60 border-b px-3 py-1`,children:[(0,q.jsxs)(T,{variant:`ghost`,size:`xs`,onClick:n,children:[(0,q.jsx)(_h,{"aria-hidden":`true`,className:`size-3.5`}),`History`]}),(0,q.jsx)(`h1`,{className:`min-w-0 truncate text-[.85rem] font-semibold`,children:e.path}),_&&(0,q.jsxs)(`span`,{className:`shrink-0 text-xs whitespace-nowrap text-muted-foreground`,children:[es(f,p),` of `,No(f).length,` open`]}),(0,q.jsx)(`span`,{className:`flex-1`}),_&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(T,{variant:`outline`,size:`xs`,"aria-pressed":a,className:`aria-pressed:bg-muted aria-pressed:text-foreground`,onClick:()=>o(e=>!e),children:`Base`}),(0,q.jsx)(T,{variant:`ghost`,size:`icon-xs`,"aria-label":`Previous region`,"aria-keyshortcuts":`Alt+ArrowUp`,disabled:!c.hasPrevious,onClick:c.previous,children:(0,q.jsx)(zs,{"aria-hidden":`true`,className:`size-3.5`})}),(0,q.jsx)(T,{variant:`ghost`,size:`icon-xs`,"aria-label":`Next region`,"aria-keyshortcuts":`Alt+ArrowDown`,disabled:!c.hasNext,onClick:c.next,children:(0,q.jsx)(Bs,{"aria-hidden":`true`,className:`size-3.5`})})]}),(0,q.jsx)(Xo,{choices:m?.file.choices??l?.choices??[],disabled:u.busy,onChoose:async t=>{await i.settled(),await u.choose(e.path,t)}}),_&&(v?(0,q.jsx)(Ga,{title:`Conflict markers remain`,action:`Mark resolved anyway`,busy:u.busy,onCancel:u.cancel,onConfirm:()=>void b(!0),className:`flex-nowrap`}):(0,q.jsx)(T,{size:`xs`,disabled:u.busy,onClick:()=>void b(!1),children:`Mark resolved`})),r]}),y!==null&&(0,q.jsx)(`p`,{role:`status`,className:`shrink-0 border-border border-b px-3 py-1.5 text-xs text-muted-foreground`,children:y}),_&&i.list.data&&(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,q.jsx)(QC,{loaded:d,sides:i.list.data.sides,leftSide:s,picks:p,activeRegion:c.activeRegion,lines:c.lines,scrollRef:c.sidesRef}),(0,q.jsx)(KC,{model:f,picks:p,onEdit:i.edit,onUndo:i.undo,onRegionClick:c.focusFromResult,scrollRef:c.resultRef})]})]})}function _w(e){return e.key===`Escape`?`close`:!e.altKey||e.ctrlKey||e.metaKey?null:e.key===`ArrowUp`?`previous`:e.key===`ArrowDown`?`next`:e.code===`Digit1`?`current`:e.code===`Digit2`?`incoming`:null}function vw({state:e,repositoryName:t,writable:n,execute:r,review:i,refresh:a,dismiss:o}){let[s,c]=(0,K.useState)(!1),l=e.operation;if(l?.kind===`idle`&&e.completed===null&&e.error===null||l===null&&e.error===null)return null;let u=l!==null&&l.kind!==`idle`,d=l?.unresolvedPaths.length??0,f=l?.actions.find(e=>e.action===`continue`),p=()=>{c(!0),i()};return(0,q.jsxs)(`section`,{"aria-label":`Git operation`,className:`max-h-[calc(100dvh-5rem)] overflow-y-auto`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,q.jsx)(Xs,{"aria-hidden":`true`,className:`size-2 shrink-0 ${e.completed?`text-status-available`:`text-status-connecting`}`}),(0,q.jsx)(`h2`,{className:`min-w-0 flex-1 text-xs font-semibold`,"aria-live":`polite`,"aria-atomic":`true`,children:uc(e)}),e.completed?(0,q.jsx)(T,{size:`xs`,variant:`ghost`,onClick:o,children:`Dismiss`}):(0,q.jsx)(T,{size:`icon-xs`,variant:`ghost`,"aria-label":s?`Expand operation`:`Collapse operation`,"aria-expanded":!s,onClick:()=>c(!s),children:s?(0,q.jsx)(Us,{}):(0,q.jsx)(Ws,{})})]}),!s&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`px-3 pb-2 break-all font-mono text-[10px] text-muted-foreground`,children:[t,l?.branch?` · ${l.branch}`:``]}),!e.connected&&(0,q.jsx)(`p`,{className:`px-3 pb-3 text-xs text-muted-foreground`,children:`Waiting to reconnect. Git state will be checked before another action.`}),!e.completed&&(0,q.jsxs)(q.Fragment,{children:[l?.phase===`edit`&&(0,q.jsx)(`p`,{className:`px-3 pb-3 text-xs text-muted-foreground`,children:`Amend this commit in Diffs, or continue unchanged.`}),f?.reason&&(0,q.jsx)(`p`,{className:`px-3 pb-3 text-xs text-muted-foreground`,children:f.reason}),l?.kind===`unknown`&&(0,q.jsx)(`p`,{className:`px-3 pb-3 text-xs text-muted-foreground`,children:`Git metadata could not be recognized. Recovery actions are unavailable.`}),!n&&u&&e.connected&&(0,q.jsx)(`p`,{className:`px-3 pb-3 text-xs text-muted-foreground`,children:`Repository write access is required to recover this operation.`}),(0,q.jsxs)(dc,{state:e,writable:n,execute:r,refresh:a,className:`border-t border-border px-3 py-2`,children:[d>0?(0,q.jsx)(T,{size:`xs`,disabled:!e.connected||e.busy,onClick:p,children:`Review conflicts`}):null,l?.phase===`edit`&&(0,q.jsx)(T,{size:`xs`,variant:`ghost`,onClick:p,children:`Review commit`}),(0,q.jsx)(`span`,{className:`flex-1`})]})]})]})]})}function yw({repositoryName:e}){let t=La(),n=ac(t,{polling:!0}),r=Ag();return t===void 0||r.state.open&&(r.state.active===`changes`||r.state.active===`rebase`)&&lc(n.state)?null:(0,q.jsx)(Ns,{children:(0,q.jsx)(vw,{...n,repositoryName:e,review:()=>r.execute({type:`open`,kind:`changes`})})})}function bw({className:e,...t}){return(0,q.jsx)(T,{className:r(`h-7 gap-1.5 text-[.85rem] sm:text-[.85rem]`,e),size:`sm`,variant:`ghost`,...t})}function xw(e,t){if(e===void 0||t===void 0)return;let n=(e.remoteProviders??[]).map(({remote:e})=>e);if(n.length===0)return;let r=e.branches.find(e=>e.name===t)?.upstream,i=r===void 0?void 0:ww(r.name,n);if(r===void 0||i===void 0)return{branch:t,remotes:n};let a=e.remoteBranches.find(e=>`${e.remote}/${e.name}`===r.name)?.target;return{branch:t,remotes:n,upstream:{destination:i,ahead:r.ahead,behind:r.behind,gone:r.gone,...a===void 0?{}:{remoteOid:a}}}}function Sw(e){return e.includes(`origin`)?`origin`:e[0]}function Cw({remote:e,branch:t}){return`${e}/${t}`}function ww(e,t){let n=t.filter(t=>e.startsWith(`${t}/`)).sort((e,t)=>t.length-e.length)[0];return n===void 0?void 0:{remote:n,branch:e.slice(n.length+1)}}function Tw(e){let t=e.upstream;if(!(t?.remoteOid===void 0||t.gone))return{branch:e.branch,destination:t.destination,expectedOid:t.remoteOid,removed:t.behind}}function Ew(e){let t=e.upstream,n=Sw(e.remotes),r=t?.destination??(n===void 0?void 0:{remote:n,branch:e.branch});if(r!==void 0)return{branch:e.branch,destination:r,setUpstream:t===void 0,mode:{_tag:`FastForward`}}}function Dw(e){return{branch:e.branch,destination:e.destination,setUpstream:!1,mode:{_tag:`ForceWithLease`,expectedOid:e.expectedOid}}}function Ow({destination:e,mode:t}){return`${t._tag===`ForceWithLease`?`Force pushing`:`Pushing`} to ${Cw(e)}`}function kw(e,t){return Cr(e,{PushRejected:e=>Aw(e,t)})}function Aw({reason:e,detail:t},n){let r=Cw(n);switch(e){case`NonFastForward`:return`Rejected: ${r} has commits you don't have. Fetch first.`;case`LeaseRejected`:return`Rejected: ${r} moved since your last fetch. Fetch and review.`;case`HookDeclined`:return`Rejected by hook: ${t}`;case`Authentication`:return`${n.remote} rejected the credentials.`;case`Network`:return`Can't reach ${n.remote}.`;case`RemoteMissing`:return`Remote ${n.remote} not found.`;default:return t||`Push failed.`}}function jw(){let e=Xr(wp.push),[t,n]=(0,K.useState)(null),r=La()?.worktreePath,{cancel:i,reset:a}=e;(0,K.useEffect)(()=>{if(r!==void 0)return()=>{i(),a(),n(null)}},[r,i,a]);let o=e.running&&e.input!==void 0?Ow(e.input):null,s=e.failure!==void 0&&e.input!==void 0?kw(e.failure,e.input.destination):null,c=t=>{!e.canRun||e.running||(n(null),e.run(t))},l=t=>{let r=Tw(t);r===void 0||e.running||(e.reset(),n(r))};return{canRun:e.canRun,running:o,review:t,notice:s,push:e=>{let t=e.upstream;if(t!==void 0&&!t.gone&&t.behind>0){l(e);return}let n=Ew(e);n!==void 0&&c(n)},requestForcePush:l,confirm:()=>{t!==null&&c(Dw(t))},cancel:()=>{e.running?e.cancel():n(null)}}}function Mw({push:e,target:t,operationBusy:n}){let r=t.upstream,i=r!==void 0&&!r.gone,a=!e.canRun||n||e.running!==null,o=!i||r.ahead>0,s=i&&r.remoteOid!==void 0;return(0,q.jsxs)(`div`,{className:`flex h-7 items-center rounded-md border border-border`,children:[(0,q.jsxs)(bw,{"aria-label":Nw(t),className:`h-full rounded-r-none border-0`,disabled:a||!o,onClick:()=>e.push(t),children:[(0,q.jsx)(zs,{"aria-hidden":`true`,className:`size-3.5`}),e.running===null?`Push`:`Pushing`,i&&r.ahead>0?(0,q.jsx)(`span`,{className:`text-status-available tabular-nums`,children:r.ahead}):null,i&&r.behind>0?(0,q.jsxs)(`span`,{className:`inline-flex items-center text-status-unavailable tabular-nums`,children:[(0,q.jsx)(Bs,{"aria-hidden":`true`,className:`size-3`}),r.behind]}):null]}),(0,q.jsxs)(la,{children:[(0,q.jsx)(gc,{"aria-label":`More push actions`,disabled:a,render:(0,q.jsx)(T,{className:`h-full rounded-l-none border-0 border-border border-l px-1.5`,size:`sm`,variant:`ghost`}),children:(0,q.jsx)(Us,{"aria-hidden":`true`,className:`size-3.5`})}),(0,q.jsxs)(Yo,{children:[(0,q.jsx)(Vo,{disabled:!o,onClick:()=>e.push(t),children:`Push`}),(0,q.jsx)(Vo,{disabled:!s,onClick:()=>e.requestForcePush(t),children:`Force push…`})]})]})]})}function Nw({branch:e,upstream:t}){if(t===void 0||t.gone)return`Push ${e}`;let n=Cw(t.destination);return t.ahead===0?`Push ${e} to ${n}`:t.behind>0?`Force push ${e} to ${n}, ${t.ahead} ahead and ${t.behind} behind`:`Push ${t.ahead} commits to ${n}`}function Pw({push:e}){return e.running===null?e.review===null?e.notice===null?null:(0,q.jsx)(Ls,{message:e.notice}):(0,q.jsx)(Ns,{children:(0,q.jsx)(Fw,{review:e.review,disabled:!e.canRun,cancel:e.cancel,confirm:e.confirm})}):(0,q.jsx)(Iw,{title:e.running,cancel:e.cancel})}function Fw({review:e,disabled:t,cancel:n,confirm:r}){return(0,q.jsxs)(Ga,{title:`Force push to ${Cw(e.destination)}?`,action:`Force push`,disabled:t,onCancel:n,onConfirm:r,className:`px-3 py-2`,children:[`Overwrites`,` `,(0,q.jsx)(`span`,{className:`font-mono text-foreground`,children:e.expectedOid.slice(0,8)}),e.removed>0?(0,q.jsxs)(`span`,{className:`text-destructive`,children:[` `,`· drops `,e.removed,` remote`,` `,e.removed===1?`commit`:`commits`]}):null]})}function Iw({title:e,cancel:t}){return(0,q.jsx)(Ns,{children:(0,q.jsxs)(`section`,{"aria-label":`Push progress`,className:`flex items-center gap-2 px-3 py-2 outline-none`,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),t())},children:[(0,q.jsx)(Xs,{"aria-hidden":`true`,className:`size-2 shrink-0 text-status-connecting`}),(0,q.jsx)(`h2`,{"aria-live":`polite`,className:`min-w-0 flex-1 wrap-anywhere text-xs font-semibold`,children:e}),(0,q.jsx)(T,{size:`xs`,variant:`ghost`,onClick:t,children:`Cancel`})]})})}function Lw({children:e}){let t=kb(),n=jw();return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Pw,{push:n}),t.error===void 0?null:(0,q.jsx)(Ls,{message:t.error}),e((0,q.jsx)(Rw,{pull:t,push:n}))]})}function Rw({pull:e,push:t}){let n=Ob(),r=La(),{refs:i}=Ds(),a=Qs()===`busy`,o=i===void 0||r===void 0?void 0:_s(i,r.worktreePath)?.branch,s=i?.branches.find(({name:e})=>e===o)?.upstream?.behind??0,c=xw(i,o),l=e.canRun&&e.ready&&!a&&!e.pulling;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(bw,{disabled:!l||n.fetching,onClick:()=>void n.execute(),children:[(0,q.jsx)(Bs,{"aria-hidden":`true`,className:`size-3.5`}),n.fetching?`Fetching`:`Fetch`]}),e.available?(0,q.jsxs)(bw,{"aria-label":Bw(e.pulling,s),disabled:!l||o===void 0,onClick:()=>{o!==void 0&&e.pull(o)},children:[(0,q.jsx)(gh,{"aria-hidden":`true`,className:`size-3.5`}),e.pulling?`Pulling`:`Pull`,e.pulling||s===0?null:(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`rounded-full bg-primary/15 px-1.5 text-[.75rem] leading-[1.15rem] text-primary tabular-nums`,children:s})]}):null,r===void 0||c===void 0?null:(0,q.jsx)(Mw,{push:t,target:c,operationBusy:a}),(0,q.jsx)(zw,{connected:r?.connected!==!1,failed:n.failed,fetching:n.fetching})]})}function zw({connected:e,fetching:t,failed:n}){return t?null:e?n?(0,q.jsx)(Ls,{message:`Fetch failed`}):null:(0,q.jsx)(Ls,{message:`You're offline`})}function Bw(e,t){return e?`Pulling`:t===0?`Pull`:`Pull ${t} incoming ${t===1?`commit`:`commits`}`}var Vw=K.createContext(void 0);function Hw(){let e=K.useContext(Vw);if(e===void 0)throw Error(s(64));return e}var Uw={tabActivationDirection:e=>({"data-activation-direction":e})},Ww=K.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,style:c,...l}=e,d=e.defaultValue!==void 0,f=K.useRef([]),[p,m]=K.useState(()=>new Map),[g,_]=mc({controlled:s,default:r,name:`Tabs`,state:`value`}),v=s!==void 0,[y,b]=K.useState(()=>new Map),x=K.useRef(void 0),S=K.useCallback(e=>Gw(y,e),[y]),[C,T]=K.useState(()=>({previousValue:g,tabActivationDirection:`none`})),{previousValue:E,tabActivationDirection:D}=C,O=D,k=!1;E!==g&&(O=Kw(E,g,a,y),k=E!=null&&g!=null&&S(g)==null);let A=k?E:g,j=E!==A||D!==O;w(()=>{j&&T({previousValue:A,tabActivationDirection:O})},[A,j,O]);let M=h((e,t)=>{t.activationDirection=Kw(g,e,a,y),i?.(e,t),!t.isCanceled&&_(e)}),N=h((e,t)=>{i?.(e,za(t,void 0,void 0,{activationDirection:`none`}))}),P=h((e,t)=>(m(n=>{let r=new Map(n);return r.set(e,t),r}),()=>{m(n=>{if(n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})})),F=K.useCallback(e=>p.get(e),[p]),I=K.useCallback(e=>{for(let t of y.values())if(e===t.value)return t.id},[y]),L=K.useMemo(()=>({getTabElementBySelectedValue:S,getTabIdByPanelValue:I,getTabPanelIdByValue:F,onValueChange:M,orientation:a,registerMountedTabPanel:P,setTabMap:b,tabActivationDirection:O,value:g}),[S,I,F,M,a,P,b,O,g]),R=K.useMemo(()=>{for(let e of y.values())if(e.value===g)return e},[y,g]),z=K.useMemo(()=>{for(let e of y.values())if(!e.disabled)return e.value},[y]),B=K.useRef(!d),V=K.useRef(r),ee=K.useRef(d),te=K.useRef(!1);w(()=>{if(v)return;function e(e,t){_(e),T({previousValue:e,tabActivationDirection:`none`}),N(e,t),B.current=!1}if(y.size===0){te.current&&g!==null&&!x.current?.isConnected&&e(null,Oi);return}te.current=!0,x.current=y.keys().next().value;let t=R?.disabled,n=R==null&&g!==null;if(!t&&g===V.current&&(ee.current=!1),ee.current&&t&&g===V.current)return;let r=B.current;if(t||n){let n=z??null;if(g===n){B.current=!1;return}let i=Oi;r?i=Ki:t&&(i=co),e(n,i);return}r&&R!=null&&(N(g,Ki),B.current=!1)},[z,v,N,R,_,y,g]);let ne=u(`div`,e,{state:{orientation:a,tabActivationDirection:O},ref:t,props:l,stateAttributesMapping:Uw});return(0,q.jsx)(Vw.Provider,{value:L,children:(0,q.jsx)(sa,{elementsRef:f,children:ne})})});function Gw(e,t){for(let[n,r]of e.entries())if(t===r.value)return n;return null}function Kw(e,t,n,r){if(e==null||t==null)return`none`;let[i,a,o]=n===`horizontal`?[`left`,`left`,`right`]:[`top`,`up`,`down`],s=Gw(r,e),c=Gw(r,t);if(s==null||c==null)return s!==c&&(typeof e==`number`||typeof e==`string`)&&typeof e==typeof t?t>e?o:a:`none`;let l=s.getBoundingClientRect()[i],u=c.getBoundingClientRect()[i];return u<l?a:u>l?o:`none`}var qw=`data-composite-item-active`,Jw=K.createContext(void 0);function Yw(){let e=K.useContext(Jw);if(e===void 0)throw Error(s(65));return e}var Xw=K.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,style:c,...l}=e,{value:d,getTabPanelIdByValue:f,onValueChange:p,orientation:m,tabActivationDirection:g}=Hw(),{activateOnFocus:_,registerTabResizeObserverElement:v,tabsListElement:y}=Yw(),{highlightedIndex:b,onHighlightedIndexChange:x}=S(),T=ha(o),E=K.useMemo(()=>({disabled:r,id:T,value:a}),[r,T,a]),{compositeProps:D,compositeRef:O,index:k}=hc({metadata:E}),A=a===d,j=K.useRef(!1),M=K.useRef(null),N=h(e=>{M.current?.(),M.current=e?v(e):null});w(()=>{if(j.current){j.current=!1;return}if(!(A&&k>-1&&b!==k))return;let e=y;if(e!=null){let t=Ci(io(e));if(t&&Wa(e,t))return}r||x(k)},[A,k,b,x,r,y]);let{getButtonProps:P,buttonRef:F}=C({disabled:r,native:s,focusableWhenDisabled:!0}),I=f(a),L=K.useRef(!1),R=K.useRef(!1);function z(e){p(a,za(ji,e.nativeEvent,void 0,{activationDirection:`none`}))}function B(e){A||r||z(e)}function V(e){A||r||_&&(!L.current||R.current)&&z(e)}function ee(e){if(A||r)return;L.current=!0,R.current=e.button===0;let t=io(e.currentTarget);function n(){L.current=!1,R.current=!1,t.removeEventListener(`pointerup`,n),t.removeEventListener(`pointercancel`,n)}t.addEventListener(`pointerup`,n),t.addEventListener(`pointercancel`,n)}return u(`button`,e,{state:{disabled:r,active:A,orientation:m,tabActivationDirection:g},ref:[t,F,O,N],props:[D,{role:`tab`,"aria-controls":I,"aria-selected":A,id:T,onClick:B,onFocus:V,onPointerDown:ee,[qw]:A?``:void 0,onKeyDownCapture(){j.current=!0}},l,P],stateAttributesMapping:Uw})}),Zw=K.createContext(void 0),Qw={disableStyleElements:!1};function $w(){return K.useContext(Zw)??Qw}var eT={...Uw,...pi},tT=K.forwardRef(function(e,t){let{className:n,value:r,render:i,keepMounted:a=!1,style:o,...s}=e,{value:c,getTabIdByPanelValue:l,orientation:d,tabActivationDirection:f,registerMountedTabPanel:p}=Hw(),m=ha(),{ref:h,index:g}=ja(),_=r===c,{mounted:v,transitionStatus:y,setMounted:b}=Ia(_),x=!v,S=l(r),C={hidden:x,orientation:d,tabActivationDirection:f,transitionStatus:y},T=K.useRef(null),E=u(`div`,e,{state:C,ref:[t,h,T],props:[{"aria-labelledby":S,hidden:x,id:m,role:`tabpanel`,tabIndex:_?0:-1,inert:da(!_),"data-index":g},s],stateAttributesMapping:eT});return va({open:_,ref:T,onComplete(){_||b(!1)}}),w(()=>{if(!(m==null||x&&!a))return p(r,m)},[x,a,r,m,p]),a||v?E:null}),nT=[];function rT(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:a,direction:o,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:l,enableHomeAndEndKeys:u=!1,stopEventPropagation:d,disabledIndices:f,modifierKeys:p=nT}=e,[m,g]=K.useState(0),_=r!=null,v=K.useRef(null),y=i(v,l),b=K.useRef([]),x=K.useRef(!1),S=s??m,C=h((e,t=!1)=>{if((c??g)(e),t){let t=b.current[e];Di(v.current,t,o,n)}}),T=h(e=>{if(e.size===0||x.current)return;x.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)C(i);else if(Ii(t,S,f)){let e=ka(t,{disabledIndices:f});Mi(t,e)||C(e)}Di(v.current,r,o,n)});w(()=>{if(f==null||s!=null||!x.current)return;let e=b.current;if(Ii(e,S,f)){let t=ka(e,{disabledIndices:f});Mi(e,t)||C(t)}},[f,s,S,b,C]);let E=h((e,t,n)=>a?a(e,t,n,b):n),D=h(e=>{let i=e.key===`Home`||e.key===`End`;if(!Ni.has(e.key)||!u&&i||iT(e,p)||!v.current)return;let s=o===`rtl`,c=s?Gi:si,l=s?si:Gi,m=n===`vertical`?oo:c,h=n===`vertical`?ai:l,g=xi(e.nativeEvent);if(g!=null&&Ea(g)&&!Pg(g)){let t=g.selectionStart,n=g.selectionEnd,r=g.value;if(t==null||e.shiftKey||t!==n||e.key!==h&&t<r.length||e.key!==m&&t>0)return}let y=S,x=ki(b,f),w=Da(b,f);r!=null&&(y=r({disabledIndices:f,elementsRef:b,event:e,highlightedIndex:S,loopFocus:t,maxIndex:w,minIndex:x,onLoop:E,orientation:n,rtl:s}));let T=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,D=n!==`vertical`&&e.key===l||n!==`horizontal`&&e.key===`ArrowUp`;u&&(e.key===`Home`?y=x:e.key===`End`&&(y=w)),y===S&&(T||D)&&(t&&y===w&&T?(y=x,a&&(y=a(e,S,y,b))):t&&y===x&&D?(y=w,a&&(y=a(e,S,y,b))):y=ka(b.current,{startingIndex:y,decrement:D,disabledIndices:f})),y!==S&&!Mi(b.current,y)&&(d&&e.stopPropagation(),(_||i||T||D)&&e.preventDefault(),C(y,!0),queueMicrotask(()=>{b.current[y]?.focus()}))});return{props:{ref:y,onFocus(e){let t=v.current,n=xi(e.nativeEvent);!t||n==null||!Ea(n)||n.setSelectionRange(0,n.value.length)},onKeyDown:D},highlightedIndex:S,onHighlightedIndexChange:C,elementsRef:b,onMapChange:T,relayKeyboardEvent:D}}function iT(e,t){for(let n of Zr)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function aT(e){let{render:t,className:n,style:r,refs:i=v,props:a=v,state:o=c,stateAttributesMapping:s,highlightedIndex:l,onHighlightedIndexChange:d,orientation:f,grid:m,loopFocus:h,onLoop:g,enableHomeAndEndKeys:_,onMapChange:y,stopEventPropagation:b=!0,rootRef:x,disabledIndices:S,modifierKeys:C,highlightItemOnHover:w=!1,tag:T=`div`,...E}=e,{props:D,highlightedIndex:O,onHighlightedIndexChange:k,elementsRef:A,onMapChange:j,relayKeyboardEvent:M}=rT({grid:m,loopFocus:h,onLoop:g,orientation:f,highlightedIndex:l,onHighlightedIndexChange:d,rootRef:x,stopEventPropagation:b,enableHomeAndEndKeys:_,direction:uo(),disabledIndices:S,modifierKeys:C}),N=u(T,e,{state:o,ref:i,props:[D,...a,E],stateAttributesMapping:s}),P=K.useMemo(()=>({highlightedIndex:O,onHighlightedIndexChange:k,highlightItemOnHover:w,relayKeyboardEvent:M}),[O,k,w,M]);return(0,q.jsx)(p.Provider,{value:P,children:(0,q.jsx)(sa,{elementsRef:A,onMapChange:e=>{y?.(e),j(e)},children:N})})}var oT=K.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,style:o,...s}=e,{orientation:c,setTabMap:l,tabActivationDirection:u}=Hw(),[d,f]=K.useState(0),[p,m]=K.useState(null),g=K.useRef(new Set),_=K.useRef(new Set),y=K.useRef(null);w(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{g.current.forEach(e=>{e()})});return y.current=e,p&&e.observe(p),_.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),y.current=null}},[p]);let b=h(e=>(g.current.add(e),()=>{g.current.delete(e)})),x=h(e=>(_.current.add(e),y.current?.observe(e),()=>{_.current.delete(e),y.current?.unobserve(e)})),S={orientation:c,tabActivationDirection:u},C={"aria-orientation":c===`vertical`?`vertical`:void 0,role:`tablist`},T=K.useMemo(()=>({activateOnFocus:n,registerIndicatorUpdateListener:b,registerTabResizeObserverElement:x,tabsListElement:p}),[n,b,x,p]);return(0,q.jsx)(Jw.Provider,{value:T,children:(0,q.jsx)(aT,{render:a,className:r,style:o,state:S,refs:[t,m],props:[C,s],stateAttributesMapping:Uw,highlightedIndex:d,enableHomeAndEndKeys:!0,loopFocus:i,orientation:c,onHighlightedIndexChange:f,onMapChange:l,disabledIndices:v})})});function sT({className:e,...t}){return(0,q.jsx)(Ww,{"data-slot":`tabs`,className:r(`flex min-h-0 flex-col`,e),...t})}function cT({className:e,...t}){return(0,q.jsx)(oT,{"data-slot":`tabs-list`,className:r(`flex min-w-0 items-center`,e),...t})}function lT({className:e,...t}){return(0,q.jsx)(Xw,{"data-slot":`tabs-trigger`,className:r(`inline-flex items-center justify-center gap-2 whitespace-nowrap text-xs text-muted-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring/50 data-active:text-foreground`,e),...t})}function uT({className:e,...t}){return(0,q.jsx)(tT,{"data-slot":`tabs-content`,className:r(`min-h-0 flex-1 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/50`,e),...t})}function dT(){let e=Ag(),t=(0,K.useRef)(!1);return(0,q.jsxs)(Ko,{open:e.launcherOpen,onOpenChange:e.setLauncherOpen,children:[(0,q.jsx)(Fo,{render:(0,q.jsx)(T,{ref:e.launcherRef,"aria-label":`Open tab`,variant:`ghost`,size:`icon-xs`,className:`size-6 text-muted-foreground`}),children:(0,q.jsx)(Hh,{"aria-hidden":`true`,className:`size-3.5`})}),(0,q.jsxs)(Yo,{align:`start`,finalFocus:()=>t.current?(t.current=!1,e.launcherRef.current?.closest(`[data-workspace-panel-tabs]`)?.querySelector(`[aria-selected="true"]`)??e.launcherRef.current):e.launcherRef.current,children:[(0,q.jsx)(`div`,{className:`flex items-center justify-between gap-3 px-2 py-2 text-[10px] text-muted-foreground`,children:(0,q.jsx)(`span`,{children:`Coming soon`})}),$h.filter(e=>Qh[e].launchable).map(n=>{let r=Qh[n];return(0,q.jsxs)(Vo,{disabled:!Qh[n].available,onClick:()=>{t.current=!0,e.setLauncherOpen(!1),e.execute({type:`open`,kind:n})},children:[(0,q.jsx)(r.icon,{"aria-hidden":`true`}),r.label]},n)})]})]})}function fT({contents:e}){let t=Ag(),n=(0,K.useRef)(null),r=(0,K.useRef)(0),{active:i,tabs:a}=t.state;return(0,K.useLayoutEffect)(()=>{if(t.focusRequest===r.current||t.launcherOpen)return;r.current=t.focusRequest;let e=n.current?.querySelector(`[aria-selected="true"]`);(e??t.emptyStateRef.current)?.focus(),e?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t.focusRequest,t.launcherOpen,t.emptyStateRef]),(0,q.jsxs)(sT,{"data-workspace-panel-tabs":!0,value:i,onValueChange:e=>{tg(e)&&t.execute({type:`open`,kind:e})},className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[(0,q.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-1 border-border border-b px-2`,children:[(0,q.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto py-1`,children:a.length>0?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(cT,{ref:n,"aria-label":`Side panel tabs`,activateOnFocus:!0,className:`shrink-0 gap-1`,children:a.map(e=>(0,q.jsx)(pT,{kind:e},e))}),(0,q.jsx)(dT,{})]}):null}),(0,q.jsx)(T,{size:`icon-xs`,variant:`ghost`,"aria-label":t.state.expanded?`Restore side panel`:`Expand side panel`,"aria-pressed":t.state.expanded===!0,onClick:()=>t.execute({type:`expand`,expanded:!t.state.expanded}),children:t.state.expanded?(0,q.jsx)(yh,{}):(0,q.jsx)(vh,{})})]}),a.map(n=>(0,q.jsx)(uT,{value:n,keepMounted:!0,className:`min-h-0 flex-1 overflow-hidden data-[hidden]:hidden`,children:(0,q.jsx)(wg,{session:t.session,kind:n,children:e?.[n]})},n)),i===null?(0,q.jsx)(mT,{}):null]})}function pT({kind:e}){let t=Ag(),n=Qh[e],i=t.state.active===e;return(0,q.jsxs)(`div`,{className:r(`group/tab flex h-6 max-w-36 shrink-0 items-center gap-1 rounded-md pl-1.5 text-xs`,i?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/60 hover:text-foreground`),children:[(0,q.jsxs)(T,{"aria-label":`Close ${n.label} tab`,size:`icon-xs`,variant:`ghost`,className:`size-4 text-inherit hover:bg-muted sm:size-4`,onClick:()=>t.execute({type:`close`,kind:e}),children:[(0,q.jsx)(n.icon,{"aria-hidden":`true`,className:`size-3 group-hover/tab:hidden group-focus-within/tab:hidden`}),(0,q.jsx)(Gh,{"aria-hidden":`true`,className:`hidden size-3 group-hover/tab:block group-focus-within/tab:block`})]}),(0,q.jsx)(lT,{value:e,className:`h-full min-w-0 rounded-sm pr-2 text-inherit`,onKeyDown:n=>{n.key===`Delete`&&(n.preventDefault(),t.execute({type:`close`,kind:e}))},children:(0,q.jsx)(`span`,{className:`truncate`,children:n.label})})]})}function mT(){let e=Ag();return(0,q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-6 py-8`,children:(0,q.jsxs)(`div`,{className:`my-auto w-full max-w-100 self-center`,children:[(0,q.jsx)(`h2`,{ref:e.emptyStateRef,tabIndex:-1,className:`mb-4 text-center text-sm font-medium outline-none`,children:`Open a tab`}),(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:$h.filter(e=>Qh[e].launchable).map(t=>{let n=Qh[t];return(0,q.jsxs)(T,{disabled:!Qh[t].available,variant:`ghost`,className:`h-auto min-h-20 min-w-0 flex-col items-start justify-center gap-2.5 whitespace-normal border-border bg-card px-3 py-3 text-left hover:border-foreground/20 sm:h-auto`,onClick:()=>e.execute({type:`open`,kind:t}),children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-2 text-xs font-normal`,children:[(0,q.jsx)(n.icon,{"aria-hidden":`true`,className:`size-3.5`}),n.label]}),(0,q.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:n.description})]},t)})})]})})}function hT({children:e}){let{store:t,panelId:n,state:r}=Ag(),i=ns(),a=(0,K.useRef)(!1),o=(0,K.useRef)(!1),s=r.open&&r.expanded===!0;return(0,K.useEffect)(()=>{if(a.current===s)return;a.current=s,o.current=!0;let e=i.current;if(!e)return;let t=e.getLayout().branches??20,c=0,l=requestAnimationFrame(()=>{e.setLayout({branches:t,workspace:s?0:100-t-(r.open?r.width:0),...r.open?{[n]:s?100-t:r.width}:{}}),c=requestAnimationFrame(()=>{o.current=!1})});return()=>{cancelAnimationFrame(l),cancelAnimationFrame(c),o.current=!1}},[s,i,n,r.open,r.width]),(0,q.jsx)(jo,{className:`h-full min-h-0`,groupRef:i,orientation:`horizontal`,onLayoutChanged:e=>{let r=e[n];!s&&a.current===s&&!o.current&&r!==void 0&&t.dispatch({type:`resize`,width:r})},children:e})}function gT(){let e=Ag();return(0,q.jsx)(T,{"aria-label":e.state.open?`Hide side panel`:`Show side panel`,"aria-expanded":e.state.open,variant:`ghost`,size:`icon-sm`,className:`border-0 bg-transparent shadow-none aria-expanded:bg-transparent`,onClick:()=>e.execute({type:`visibility`,open:!e.state.open}),children:e.state.open?(0,q.jsx)(Lh,{"aria-hidden":`true`}):(0,q.jsx)(Rh,{"aria-hidden":`true`})})}function _T({children:e}){let{state:t}=Ag(),n=!(t.open&&t.expanded);return(0,q.jsx)(Eo,{id:`workspace`,minSize:`30%`,collapsible:!0,collapsedSize:0,children:(0,q.jsx)(`div`,{className:`h-full min-w-0 overflow-hidden`,inert:!n,"aria-hidden":!n,children:e(n)})})}function vT({contents:e}){let{state:t,panelId:n}=Ag();return t.open?(0,q.jsxs)(q.Fragment,{children:[t.expanded?null:(0,q.jsx)(To,{"aria-label":`Resize side panel`,className:`z-10 bg-transparent after:w-2 focus-visible:ring-primary/40`}),(0,q.jsx)(Eo,{id:n,defaultSize:`${t.width}%`,minSize:`18rem`,maxSize:t.expanded?`100%`:`65%`,children:(0,q.jsx)(`aside`,{"aria-label":`Side panel`,className:`h-full min-h-0 border-border border-l`,children:(0,q.jsx)(fT,{contents:e})})})]}):null}var yT={Sessions:hg,Provider:Og,Group:hT,Toggle:gT,Pane:vT,Main:_T},bT=new Set;function xT(){let e=La(),{environmentId:t}=Vn();return e===void 0||t===void 0?null:(0,q.jsx)(ST,{environmentId:t,scope:e},JSON.stringify([t,e.repositoryId,e.logicalRepositoryId]))}function ST({environmentId:e,scope:t}){let{repositoryId:n,logicalRepositoryId:r,worktreePath:i}=t,a=(0,K.useMemo)(()=>({environmentId:e,repositoryId:n,logicalRepositoryId:r,worktreePath:i}),[e,n,r,i]);return(0,q.jsx)(yT.Provider,{scope:a,scopeKey:JSON.stringify([e,r,i]),children:(0,q.jsx)(CT,{environmentId:e,scope:t})})}function CT({environmentId:e,scope:t}){let{worktreePath:n}=t,[r,i]=(0,K.useState)(null),a=r?.worktreePath===n?r.path:null,o=(0,K.useCallback)(e=>i({worktreePath:n,path:e}),[n]),s=(0,K.useMemo)(()=>({changes:(0,q.jsx)(K.Suspense,{fallback:null,children:(0,q.jsx)(Jh.Content,{openMergeView:o})})}),[o]),c=cC({environmentId:e,repositoryId:t.repositoryId,logicalRepositoryId:t.logicalRepositoryId}),l=VC(c),u=Ag(),d=(0,K.useCallback)(e=>{u.execute({type:`input`,kind:`rebase`,input:e}),u.execute({type:`open`,kind:`rebase`})},[u.execute]),f=vc(c,d),p=Ib(c),m=lh(t.repositoryId)?.name??`Repository`,h=Ds(),{refs:g}=h,_=MC(e,t,h),v=(0,K.useCallback)(e=>{u.execute({type:`input`,kind:`reflog`,input:{_tag:`LocalBranch`,name:e}}),u.execute({type:`open`,kind:`reflog`})},[u.execute]),y=(0,K.useCallback)(()=>u.execute({type:`close`,kind:`rebase`}),[u.execute]),b=_.resolvedScope;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(yw,{repositoryName:m},n),(0,q.jsx)(Lw,{children:n=>(0,q.jsx)(jg,{connected:t.connected,children:r=>(0,q.jsxs)(yT.Group,{children:[(0,q.jsx)(Eo,{defaultSize:`16.5rem`,groupResizeBehavior:`preserve-pixel-size`,id:`branches`,maxSize:`26rem`,minSize:`12rem`,children:(0,q.jsx)(Pb,{merge:l,rebase:f,onBranchRenamed:_.renameBranch,onShowReflog:v,onToggleHistoryRef:_.toggleRef,selectedHistoryRefKeys:b?.selectedRefKeys??bT})}),(0,q.jsx)(To,{"aria-label":`Resize branches sidebar`,className:`z-10 bg-transparent after:w-2 focus-visible:ring-primary/40`}),(0,q.jsx)(yT.Main,{children:()=>a===null?(0,q.jsx)(`main`,{"aria-label":`Repository workspace`,className:`h-full rounded-none bg-repository`,children:(0,q.jsx)(TC,{merge:l,rebase:f,cherryPick:p,ref:r.graphRef,onOpenDetails:r.open,onActiveCommitChange:r.select,toolbarActions:(0,q.jsxs)(q.Fragment,{children:[n,(0,q.jsx)(yT.Toggle,{})]}),githubRepository:g?.githubRepository,remoteProviders:g?.remoteProviders,historyIdentity:{environmentId:e,repositoryId:t.logicalRepositoryId},onRemoveHistoryRef:_.toggleRef,onRevealHistoryRef:_.toggleRef,onAddHistoryRef:()=>Ps({_tag:`FocusRefs`}),onResetHistoryScope:_.reset,history:c,repositoryName:m,roots:b?.roots,scope:b?.scope??P_,selections:b?.selections??[]})}):(0,q.jsx)(hw,{path:a,onOpen:o,onClose:()=>i(null),toolbarActions:(0,q.jsx)(yT.Toggle,{})})}),(0,q.jsx)(yT.Pane,{contents:{...s,reflog:(0,q.jsx)(K.Suspense,{fallback:null,children:(0,q.jsx)(Yh.Content,{onOpenDetails:r.open,onShowInGraph:async e=>{await r.graphRef.current?.navigateToOid(e)}})}),rebase:(0,q.jsx)(K.Suspense,{fallback:null,children:(0,q.jsx)(Xh.Content,{history:c,onClose:y})})}})]})})})]})}var wT=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});function TT(e,t){let n=t.trim().toLocaleLowerCase();return e.map(e=>{let t=e.name.toLocaleLowerCase().includes(n),r=jT(e.repositories).filter(e=>n.length===0||t||e.name.toLocaleLowerCase().includes(n)||e.path.toLocaleLowerCase().includes(n));return{...e,repositories:r}})}function ET(e){return e.flatMap(e=>e.repositories.map(t=>({disabled:e.availability!==`available`,environment:e,key:`recent:${e.id}:${t.id}`,repository:t}))).filter(e=>e.repository.lastOpenedAt!==void 0).sort(MT).slice(0,4)}function DT(e,t){return e.flatMap(e=>t.has(e.id)?jT(e.repositories).map(t=>({disabled:e.availability!==`available`,environment:e,key:`catalog:${e.id}:${t.id}`,repository:t})):[])}function OT(e,t){return[...e,...t].filter(e=>!e.disabled)}function kT(e){return e.split(/[-_\s]+/).map(e=>e[0]).filter(e=>e!==void 0).join(``).slice(0,2).toUpperCase()}function AT(e,t=new Date){let n=new Date(e),r=Math.max(0,t.getTime()-n.getTime()),i=Math.floor(r/36e5);if(i<1)return`${Math.max(1,Math.floor(r/6e4))}m`;if(i<24&&NT(n,t))return`${i}h`;let a=new Date(t);return a.setDate(a.getDate()-1),NT(n,a)?`Yesterday`:new Intl.DateTimeFormat(void 0,{day:`numeric`,month:`short`,year:n.getFullYear()===t.getFullYear()?void 0:`numeric`}).format(n)}function jT(e){return e.toSorted((e,t)=>wT.compare(e.name,t.name))}function MT(e,t){return new Date(t.repository.lastOpenedAt??0).getTime()-new Date(e.repository.lastOpenedAt??0).getTime()||wT.compare(e.repository.name,t.repository.name)}function NT(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function PT({activeDescendant:e,browseAvailable:t,inputRef:n,onBrowse:r,onChange:i,onKeyDown:a,query:o}){return(0,q.jsxs)(`div`,{className:`sticky top-0 z-10 grid grid-cols-[minmax(0,1fr)_auto] gap-2.5 bg-repository pt-1 pb-3 max-[650px]:grid-cols-1`,children:[(0,q.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,q.jsx)(Uh,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,q.jsx)(oc,{"aria-activedescendant":e,"aria-controls":`open-project-results`,"aria-label":`Search repositories`,autoComplete:`off`,autoFocus:!0,className:`h-8 bg-white/[.04] pl-9 sm:h-8`,onChange:e=>i(e.target.value),onKeyDown:a,placeholder:`Search repositories`,ref:n,type:`search`,value:o})]}),(0,q.jsxs)(T,{className:`h-8 gap-[.45rem] px-3 text-[.8rem] font-medium sm:h-8 max-[650px]:w-full`,disabled:!t,onClick:r,type:`button`,children:[(0,q.jsx)(Ks,{"aria-hidden":`true`}),`Browse files`]})]})}function FT({name:e,onOpen:t}){return(0,q.jsx)(`button`,{"aria-label":`Repository settings for ${e}`,className:`grid size-7.5 shrink-0 place-items-center border-0 bg-transparent text-muted-foreground opacity-0 outline-none hover:text-sidebar-accent-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring/40 group-hover:opacity-100 group-focus-within:opacity-100 [@media(hover:none)]:opacity-100`,onClick:t,type:`button`,children:(0,q.jsx)(Ho,{"aria-hidden":`true`,className:`size-4`})})}function IT({active:e,available:t,itemKey:n,onActivate:r,onOpen:i,onOpenSettings:a,repository:o}){return(0,q.jsxs)(`div`,{className:`group ml-8 grid h-11 min-w-0 grid-cols-[minmax(0,1fr)_1.75rem] items-center rounded-md px-2.5 hover:bg-accent has-[[aria-expanded=true]]:bg-accent data-[active=true]:bg-accent data-[available=false]:opacity-42`,"data-active":e,"data-available":t,children:[(0,q.jsxs)(`button`,{"aria-selected":e,className:`grid h-full min-w-0 grid-cols-[1.875rem_minmax(0,1fr)] items-center gap-[.7rem] text-left outline-none disabled:pointer-events-none`,disabled:!t,id:LT(n),onClick:()=>i(o),onFocus:()=>r(n),role:`option`,tabIndex:-1,type:`button`,children:[(0,q.jsx)(`span`,{className:`grid size-7.5 place-items-center rounded-[.45rem] bg-secondary text-[.67rem] font-semibold text-secondary-foreground`,children:kT(o.name)}),(0,q.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-[.65rem] max-[650px]:block`,children:[(0,q.jsx)(`strong`,{className:`shrink-0 truncate text-[.8rem] font-medium text-foreground`,children:o.name}),(0,q.jsx)(`span`,{className:`block min-w-0 truncate font-mono text-[.69rem] leading-[1.45] text-muted-foreground`,children:o.path})]})]}),(0,q.jsx)(FT,{name:o.name,onOpen:()=>a(o)})]})}function LT(e){return`open-project-item-${e.replaceAll(/[^a-zA-Z0-9_-]/g,`-`)}`}function RT({activeKey:e,items:t,onActivate:n,onOpen:r,onOpenSettings:i}){return t.length===0?null:(0,q.jsxs)(`section`,{"aria-labelledby":`open-project-recent-heading`,children:[(0,q.jsx)(`h2`,{className:`mt-[1.85rem] mb-[.55rem] text-xs font-medium text-muted-foreground`,id:`open-project-recent-heading`,children:`Recent`}),(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-x-8 gap-y-1 max-[650px]:grid-cols-1`,children:t.map(t=>(0,q.jsxs)(`div`,{className:`group flex min-w-0 items-center rounded-md pr-1 hover:bg-accent`,children:[(0,q.jsxs)(`button`,{"aria-selected":e===t.key,className:`grid h-16 min-w-0 flex-1 grid-cols-[2.5rem_minmax(0,1fr)_auto] items-center gap-3 rounded-md px-2.5 text-left text-foreground outline-none hover:bg-accent disabled:opacity-42 data-[active=true]:bg-accent data-[active=true]:shadow-[inset_0_0_0_1px_rgb(124_140_255/48%)]`,"data-active":e===t.key,disabled:t.disabled,id:LT(t.key),onClick:()=>r(t.repository),onFocus:()=>n(t.key),role:`option`,tabIndex:-1,type:`button`,children:[(0,q.jsx)(zT,{name:t.repository.name}),(0,q.jsxs)(`span`,{className:`min-w-0`,children:[(0,q.jsx)(`strong`,{className:`mb-[.12rem] block truncate text-[.86rem] font-semibold`,children:t.repository.name}),(0,q.jsx)(`span`,{className:`block truncate font-mono text-[.69rem] leading-[1.45] text-muted-foreground`,children:t.repository.path})]}),(0,q.jsxs)(`span`,{className:`text-right text-[.68rem] text-muted-foreground`,children:[(0,q.jsx)(`span`,{className:`mb-[.18rem] block text-foreground/60`,children:t.environment.name}),(0,q.jsx)(`span`,{className:`block`,children:AT(t.repository.lastOpenedAt??``)})]})]}),(0,q.jsx)(FT,{name:t.repository.name,onOpen:()=>i(t.repository)})]},t.key))})]})}function zT({name:e}){return(0,q.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-[.45rem] bg-secondary text-xs font-semibold text-secondary-foreground`,children:kT(e)})}function BT(e){let{open:t,defaultOpen:n,onOpenChange:r,disabled:i}=e,[a,o]=mc({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=Ia(a,!0,!0),u=ha(),[d,f]=K.useState(),p=d===null?void 0:d??u,m=h(e=>{let t=!a,n=za(Vi,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return K.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:m,mounted:s,open:a,panelId:p,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,m,s,a,p,c,o,f,l])}var VT=K.createContext(void 0);function HT(){let e=K.useContext(VT);if(e===void 0)throw Error(s(15));return e}var UT=function(e){return e.open=`data-open`,e.closed=`data-closed`,e[e.startingStyle=$i.startingStyle]=`startingStyle`,e[e.endingStyle=$i.endingStyle]=`endingStyle`,e}({}),WT=function(e){return e.panelOpen=`data-panel-open`,e}({}),GT={[UT.open]:``},KT={[UT.closed]:``},qT={open(e){return e?{[WT.panelOpen]:``}:null}},JT={open(e){return e?GT:KT},...pi},YT=K.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,d=h(o),f=BT({open:s,defaultOpen:i,onOpenChange:d,disabled:a}),p=K.useMemo(()=>({open:f.open,disabled:f.disabled,transitionStatus:f.transitionStatus}),[f.open,f.disabled,f.transitionStatus]),m=K.useMemo(()=>({...f,onOpenChange:d,state:p}),[f,d,p]),g=u(`div`,e,{state:p,ref:t,props:l,stateAttributesMapping:JT});return(0,q.jsx)(VT.Provider,{value:m,children:g})}),XT={...qT,...pi},ZT=K.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=HT(),{className:s,disabled:c=o,render:l,nativeButton:d=!0,style:f,...p}=e,{getButtonProps:m,buttonRef:h}=C({disabled:c,focusableWhenDisabled:!0,native:d});return u(`button`,e,{state:a,ref:[t,h],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},p,m],stateAttributesMapping:XT})}),QT={height:void 0,width:void 0};function $T(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:a,mounted:o,onOpenChange:s,open:c,setMounted:l,setOpen:u,transitionStatus:d}=e,f=K.useRef(null),p=K.useRef(null),[m,g]=K.useState(QT),_=K.useRef(QT),v=K.useRef(!1),y=K.useRef(c),b=K.useRef(!1),[x,S]=K.useState(!1),C=K.useRef(null),T=i(t,f),E=go(c),D=Qa(f),O=!c&&!o,k=x?`idle`:d,A=c&&(y.current||b.current),j=!c&&o&&p.current===`css-animation`&&m.height===void 0&&m.width===void 0?_.current:m,M=n&&O&&p.current!==`css-animation`,N=h((e,t=!0)=>{t&&(_.current=e),g(e)}),P=h(()=>{C.current?.(),C.current=null}),F=h(e=>{P(),C.current=()=>{C.current=null,e()}}),I=h(()=>{c&&o&&p.current===`css-animation`&&(b.current=!0)});w(()=>{!x||d===`starting`||S(!1)},[x,d]),K.useEffect(()=>()=>{I(),P()},[I,P]),w(()=>{let e=f.current;if(!e)return;!c&&C.current&&P();let t=tE(e,A);if(p.current=t,c&&d===`idle`&&y.current&&t===`css-animation`){_.current=eE(e);return}if(c&&d===`starting`){let n=v.current;if(v.current=!1,t===`none`){N(eE(e)),S(!0);return}if(t===`css-transition`){let t=iE(e);if(N(eE(e)),!n)return t;let r=rE(e,`transition-duration`,`0s`);return F(r),S(!0),t}N(eE(e));let r=rE(e,`animation-name`,`none`);if(!n){r();return}let i=rE(e,`animation-duration`,`0s`);r(),F(i),S(!0);return}if(!c&&o&&(d===`idle`||d===`starting`)){if(y.current=!1,b.current=!1,t===`none`){N(QT,!1),l(!1);return}N(eE(e));return}if(d!==`ending`)return;if(t===`none`){l(!1);return}let n=eE(e);if(!(n.height>0||n.width>0)){l(!1);return}N(n),t===`css-animation`&&rE(e,`animation-name`,`none`)()},[o,c,P,N,l,F,A,d]),va({enabled:c&&o&&k===`idle`,open:!0,ref:f,onComplete(){c&&N(QT,!1)}}),K.useEffect(()=>{if(c||!o||k!==`ending`||!f.current)return;let e=new AbortController,t=-1;function n(){E.current||(l(!1),N(QT,!1))}return t=Ka.request(()=>{D(n,e.signal)}),()=>{Ka.cancel(t),e.abort()}},[E,o,c,k,D,N,l]),w(()=>{let e=f.current;!e||!n||!O||e.setAttribute(`hidden`,`until-found`)},[O,n]),K.useEffect(function(){let e=f.current;if(!e)return;function t(e){let t=za(ji,e);s(!0,t),!t.isCanceled&&(v.current=!0,u(!0))}return Zi(e,`beforematch`,t)},[s,u]);let L=a||n||o||c;return{height:j.height,props:{...M?{[UT.startingStyle]:``}:void 0,hidden:O,id:r},ref:T,shouldPreventOpenAnimation:A,shouldRender:L,transitionStatus:k,width:j.width}}function eE(e){return{height:e.scrollHeight,width:e.scrollWidth}}function tE(e,t){let n=f(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&nE(n.animationDuration),i=nE(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function nE(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function rE(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 iE(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=Ka.request(n);return()=>{Ka.cancel(r),n()}}var aE=function(e){return e.collapsiblePanelHeight=`--collapsible-panel-height`,e.collapsiblePanelWidth=`--collapsible-panel-width`,e}({}),oE=K.forwardRef(function(e,t){let{className:r,hiddenUntilFound:i,keepMounted:a,render:o,id:s,style:c,...l}=e,{defaultPanelId:d,mounted:f,onOpenChange:p,open:m,setMounted:h,setPanelIdState:g,setOpen:_,state:v,transitionStatus:y}=HT(),b=i??!1,x=a??!1,S=s||void 0,C=S??d;w(()=>(g(e=>S??(e===null?void 0:e)),()=>{g(e=>e===S?null:e)}),[S,g]);let{height:T,props:E,ref:D,shouldPreventOpenAnimation:O,shouldRender:k,transitionStatus:A,width:j}=$T({externalRef:t,hiddenUntilFound:b,id:C,keepMounted:x,mounted:f,onOpenChange:p,open:m,setMounted:h,setOpen:_,transitionStatus:y}),M={...v,transitionStatus:A},N=n(c,M),P=u(`div`,{...e,style:void 0},{state:M,ref:D,props:[E,{style:{[aE.collapsiblePanelHeight]:T===void 0?`auto`:`${T}px`,[aE.collapsiblePanelWidth]:j===void 0?`auto`:`${j}px`}},l,N?{style:N}:void 0,O?{style:{animationName:`none`}}:void 0],stateAttributesMapping:JT});return k?P:null});function sE({...e}){return(0,q.jsx)(YT,{"data-slot":`collapsible`,...e})}function cE({...e}){return(0,q.jsx)(ZT,{"data-slot":`collapsible-trigger`,...e})}function lE({...e}){return(0,q.jsx)(oE,{"data-slot":`collapsible-content`,...e})}function uE({activeKey:e,environment:t,onActivate:n,onOpenChange:r,onOpenRepository:i,onOpenSettings:a,open:o}){let s=t.icon;return(0,q.jsxs)(sE,{onOpenChange:r,open:o,children:[(0,q.jsxs)(`div`,{className:`grid h-9 min-w-0 grid-cols-[1.75rem_1.125rem_minmax(0,1fr)_auto] items-center gap-[.45rem] px-1 text-muted-foreground`,children:[(0,q.jsx)(cE,{"aria-label":`${o?`Collapse`:`Expand`} ${t.name}`,className:`grid size-7 place-items-center rounded-[.4rem] outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/30`,children:(0,q.jsx)(Us,{"aria-hidden":`true`,className:`size-4 transition-transform ${o?``:`-rotate-90`}`})}),(0,q.jsx)(s,{"aria-hidden":`true`,className:`size-4.5 shrink-0`,style:{color:t.iconColor}}),(0,q.jsx)(`strong`,{className:`truncate text-[.83rem] font-medium text-foreground`,children:t.name}),t.availability===`unavailable`?(0,q.jsx)(`span`,{className:`truncate text-xs text-status-unavailable`,role:`status`,children:t.status}):null]}),(0,q.jsx)(lE,{children:t.repositories.map(r=>{let o=`catalog:${t.id}:${r.id}`;return(0,q.jsx)(IT,{active:e===o,available:t.availability===`available`,itemKey:o,onActivate:n,onOpen:i,onOpenSettings:a,repository:r},r.id)})})]})}var dE=K.createContext(void 0);function fE(e){let t=K.useContext(dE);if(!e&&t===void 0)throw Error(s(27));return t}var pE=K.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=fE(),c=s.useState(`open`),l=s.useState(`nested`),d=s.useState(`mounted`),f={open:c,transitionStatus:s.useState(`transitionStatus`)};return u(`div`,e,{state:f,ref:[s.context.backdropRef,t],stateAttributesMapping:Xi,props:[{role:`presentation`,hidden:!d,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),mE=K.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=fE(),l=c.useState(`open`),{getButtonProps:d,buttonRef:f}=C({disabled:a,native:o}),p={disabled:a};function m(e){l&&c.setOpen(!1,za(fa,e.nativeEvent))}return u(`button`,e,{state:p,ref:[t,f],props:[{onClick:m},s,d]})}),hE=K.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=fE(),c=ha(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),u(`p`,e,{ref:t,props:[{id:c},o]})}),gE=K.createContext(void 0);function _E(){let e=K.useContext(gE);if(e===void 0)throw Error(s(26));return e}var vE={...ti,...pi,nestedDialogOpen(e){return e?{"data-nested-dialog-open":``}:null}},yE=K.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=fE(),l=c.useState(`descriptionElementId`),d=c.useState(`disablePointerDismissal`),f=c.useState(`floatingRootContext`),p=c.useState(`popupProps`),m=c.useState(`modal`),h=c.useState(`mounted`),g=c.useState(`nested`),_=c.useState(`nestedOpenDialogCount`),v=c.useState(`open`),y=c.useState(`openMethod`),b=c.useState(`titleElementId`),x=c.useState(`transitionStatus`),S=c.useState(`role`),C=f.useState(`floatingId`);_E(),va({open:v,ref:c.context.popupRef,onComplete(){v&&c.context.onOpenChangeComplete?.(!0)}});let w=o===void 0?Si(c.context.popupRef):o,T=_>0,E=c.useStateSetter(`popupElement`),D=u(`div`,e,{state:{open:v,nested:g,transitionStatus:x,nestedDialogOpen:T},props:[p,{id:C,"aria-labelledby":b,"aria-describedby":l,role:S,...qi,hidden:!h,onKeyDown(e){Ni.has(e.key)&&e.stopPropagation()},style:{"--nested-dialogs":_}},s],ref:[t,c.context.popupRef,E],stateAttributesMapping:vE});return(0,q.jsx)(no,{context:f,openInteractionType:y,disabled:!h,closeOnFocusOut:!d,initialFocus:w,returnFocus:a,modal:m!==!1,restoreFocus:`popup`,children:D})}),bE=K.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=fE(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,q.jsx)(gE.Provider,{value:n,children:(0,q.jsxs)(ca,{ref:t,...r,children:[a&&o===!0&&(0,q.jsx)(xa,{ref:i.context.internalBackdropRef,inert:da(!s)}),e.children]})}):null});function xE({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`disablePointerDismissal`),a=e.useState(`modal`),o=e.useState(`popupElement`),s=e.useState(`floatingRootContext`),[c,l]=K.useState(0),[u,d]=K.useState(0),f=c===0,p=ga(s,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:a===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=xi(t);if(f&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Wa(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:f});return Na(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{l(e),d(t)}),w(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(c+1,u+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,c,u,t]),ea(e,{activeTriggerProps:p.reference,inactiveTriggerProps:p.trigger,popupProps:p.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:u}),null}var SE={...Yi,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},CE=class extends Ra{constructor(e,t,n){let r=new hi,i=wE(e,r,t,n);super(i,TE(r),SE)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let n={open:e};Ua(n,e,t.trigger),this.update(n)}};function wE(e,t,n,r=!1){let i={...mo(),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e};return i.floatingRootContext=ei(t,n,r),i}function TE(e){return{popupRef:K.createRef(),backdropRef:K.createRef(),internalBackdropRef:K.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function EE(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=fE(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=ia((e,t)=>new CE({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...y},e,t),!0);b.useControlledProp(`openProp`,r),b.useControlledProp(`triggerIdProp`,d),b.useSyncedValues(y),b.useContextCallback(`onOpenChange`,a),b.useContextCallback(`onOpenChangeComplete`,o);let x=b.useState(`open`),S=b.useState(`mounted`),C=b.useState(`payload`);Li(b,x),bi(b);let{forceUnmount:w}=na(x,b);K.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,za(so))}),[w,b]);let T=x||S;return(0,q.jsxs)(dE.Provider,{value:b,children:[u&&(0,q.jsx)(Qi,{handle:u,store:b}),T&&(0,q.jsx)(xE,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}function DE(e){return EE(`dialog`,e)}var OE=K.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=_E(),c=fE(),l=c.useState(`open`),d=c.useState(`nested`),f=c.useState(`transitionStatus`),p=c.useState(`nestedOpenDialogCount`),m=c.useState(`mounted`),h=c.useStateSetter(`viewportElement`);return u(`div`,e,{enabled:s||m,state:{open:l,nested:d,transitionStatus:f,nestedDialogOpen:p>0},ref:[t,h],stateAttributesMapping:vE,props:[{role:`presentation`,hidden:!m,style:{pointerEvents:l?void 0:`none`},children:a},o]})}),kE=K.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=fE(),c=ha(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),u(`h2`,e,{ref:t,props:[{id:c},o]})});function AE(e){return(0,q.jsx)(DE,{"data-slot":`dialog`,...e})}function jE(e){return(0,q.jsx)(mE,{"data-slot":`dialog-close`,...e})}function ME(e){return(0,q.jsx)(kE,{"data-slot":`dialog-title`,...e})}function NE(e){return(0,q.jsx)(hE,{"data-slot":`dialog-description`,...e})}function PE({className:e,...t}){return(0,q.jsxs)(bE,{children:[(0,q.jsx)(pE,{className:`fixed inset-0 z-50 bg-black/70`}),(0,q.jsx)(OE,{className:`fixed inset-0 z-50 grid place-items-center overflow-y-auto p-4`,children:(0,q.jsx)(yE,{className:r(`relative w-full rounded-[.625rem] border border-border bg-popover text-popover-foreground shadow-[0_1.5rem_4rem_rgb(0_0_0/65%)] outline-none`,e),"data-slot":`dialog-content`,...t})})]})}function FE(e,t){let n=t.trim().toLocaleLowerCase();return n.length===0?e:e.filter(e=>e.name.toLocaleLowerCase().includes(n))}function IE(e,t=new Date){if(e===void 0)return`—`;let n=new Date(e);if(n.toDateString()===t.toDateString())return`Today`;let r=new Date(t);return r.setDate(t.getDate()-1),n.toDateString()===r.toDateString()?`Yesterday`:new Intl.DateTimeFormat(void 0,{day:`numeric`,month:`short`}).format(n)}var LE={NotRepository:`This folder is not a Git repository.`,NotFound:`This folder no longer exists.`,NotDirectory:`The selected path is not a folder.`,InspectionFailed:`Rebase could not inspect this folder.`,MalformedPath:`The selected folder path is invalid.`},RE={NotFound:`This folder no longer exists.`,NotDirectory:`This path is not a folder.`,PermissionDenied:`Rebase does not have permission to open this folder.`,MalformedPath:`This folder path is invalid.`,InspectionFailed:`Rebase could not read this folder.`};function zE(e){return Cr(e,{RepositoryPathRejected:({reason:e})=>LE[e]})}function BE(e){return Cr(e,{EnvironmentDirectoryRejected:({reason:e})=>RE[e]})}var VE={_tag:`None`};function HE(e,t){let[n,r]=(0,K.useState)(),[i,a]=(0,K.useState)(VE),o=UE(n,e.available),s=Xr(Jf.remember,{answers:oh}),c=o.isError?void 0:o.data,l=c===void 0?void 0:i._tag===`Folder`?i.path:i._tag===`Current`?c.path:void 0;return{directory:c,selectedPath:l,loading:e.available&&o.isLoading,opening:s.running,directoryError:e.available?o.isError?BE(o.error):void 0:e.status,selectionError:s.failure===void 0?void 0:zE(s.failure),navigate:e=>{s.reset(),r(e),a({_tag:`Current`})},select:e=>{s.reset(),a({_tag:`Folder`,path:e})},openRepository:async()=>{if(l===void 0||s.running)return;let e=await s.run({path:l});e._tag===`Ok`&&t(e.value)}}}function UE(e,t){return In(zf.listDirectory,e===void 0?{}:{path:e},{enabled:t,changes:`none`,staleTime:0,refetchOnWindowFocus:!1})}function WE({entries:e,error:t,loading:n,onEnter:r,onParent:i,onSelect:a,selectedPath:o,truncated:s}){let c=e.filter(e=>e.type===`directory`),l=e=>{if(c.length===0)return;let t=c.findIndex(e=>e.path===o),n=t<0?e>0?0:c.length-1:(t+e+c.length)%c.length,r=c[n];r!==void 0&&(a(r.path),requestAnimationFrame(()=>document.getElementById(GE(n))?.focus()))};return(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,q.jsxs)(`div`,{className:`grid h-[1.85rem] shrink-0 grid-cols-[minmax(0,1fr)_6.5rem_5rem] items-center gap-3 px-4 text-[.66rem] text-muted-foreground uppercase max-[600px]:grid-cols-[minmax(0,1fr)_5rem] max-[600px]:[&>*:last-child]:hidden`,children:[(0,q.jsx)(`span`,{children:`Name`}),(0,q.jsx)(`span`,{children:`Kind`}),(0,q.jsx)(`span`,{children:`Modified`})]}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[.45rem] py-[.15rem]`,children:[n?(0,q.jsx)(JE,{children:`Loading directory…`}):t===void 0?e.length===0?(0,q.jsx)(JE,{children:`This folder is empty.`}):e.map(e=>e.type===`directory`?(0,q.jsxs)(`button`,{"aria-pressed":o===e.path,className:YE(o===e.path),id:GE(c.findIndex(t=>t.path===e.path)),onClick:()=>a(e.path),onDoubleClick:()=>r(e.path),onKeyDown:t=>{if(t.key===`ArrowDown`||t.key===`ArrowUp`){t.preventDefault(),l(t.key===`ArrowDown`?1:-1);return}if(t.key===`ArrowLeft`){t.preventDefault(),i();return}(t.key===`ArrowRight`||t.key===`Enter`&&!t.ctrlKey&&!t.metaKey)&&(t.preventDefault(),r(e.path))},type:`button`,children:[(0,q.jsx)(KE,{entry:e}),(0,q.jsx)(qE,{children:e.kind}),(0,q.jsx)(qE,{className:`max-[600px]:hidden`,children:IE(e.modifiedAt)})]},e.path):(0,q.jsxs)(`div`,{className:YE(!1),children:[(0,q.jsx)(KE,{entry:e}),(0,q.jsx)(qE,{children:e.kind}),(0,q.jsx)(qE,{className:`max-[600px]:hidden`,children:IE(e.modifiedAt)})]},e.path)):(0,q.jsx)(JE,{children:t}),s&&!n&&t===void 0?(0,q.jsx)(`p`,{className:`px-3 py-2 text-[.68rem] text-muted-foreground`,children:`Only part of this directory is shown.`}):null]})]})}function GE(e){return`repository-directory-option-${e}`}function KE({entry:e}){let t=e.type===`directory`?Ks:Do;return(0,q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[.65rem]`,children:[(0,q.jsx)(t,{"aria-hidden":`true`,className:r(`size-4 shrink-0 text-muted-foreground`,e.type===`directory`&&`text-foreground/65`)}),(0,q.jsx)(`span`,{className:`truncate`,children:e.name})]})}function qE({children:e,className:t}){return(0,q.jsx)(`span`,{className:r(`text-[.69rem] text-muted-foreground`,t),children:e})}function JE({children:e}){return(0,q.jsx)(`div`,{className:`grid h-full min-h-32 place-items-center px-4 text-center text-xs text-muted-foreground`,children:e})}function YE(e){return r(`grid h-11 w-full grid-cols-[minmax(0,1fr)_6.5rem_5rem] items-center gap-3 rounded-lg px-3 text-left text-[.8rem] text-foreground/80 outline-none max-[600px]:grid-cols-[minmax(0,1fr)_5rem]`,`hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/30`,e&&`bg-accent shadow-[inset_0_0_0_1px_rgb(124_140_255/48%)]`)}function XE({environments:e,onSelect:t,selected:n}){let r=n.icon;return(0,q.jsxs)(Ko,{children:[(0,q.jsxs)(Fo,{"aria-label":`Select Environment`,className:`flex h-8 max-w-64 items-center gap-2 rounded-md border border-border bg-white/[.03] px-2.5 text-xs font-medium text-foreground/85 outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/30`,children:[(0,q.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`,style:{color:n.iconColor}}),(0,q.jsx)(`span`,{className:`truncate`,children:n.name}),(0,q.jsx)(Us,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,q.jsx)(Yo,{align:`end`,className:`w-64`,children:e.map(e=>{let r=e.icon,i=e.availability!==`available`;return(0,q.jsxs)(Vo,{className:`h-auto min-h-9`,onClick:()=>t(e.id),children:[(0,q.jsx)(r,{"aria-hidden":`true`,style:{color:e.iconColor}}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`block truncate`,children:e.name}),i?(0,q.jsx)(`span`,{className:`mt-0.5 block truncate text-[.66rem] text-muted-foreground`,children:e.status}):null]}),e.id===n.id?(0,q.jsx)(Hs,{"aria-hidden":`true`,className:`text-primary`}):null]},e.id)})})]})}function ZE({environment:e,environments:t,chooseEnvironment:n,onRepositoryOpened:r}){let i=HE({available:e.availability===`available`,status:e.status},r),{directory:a,loading:o}=i,[s,c]=(0,K.useState)(!1),[l,u]=(0,K.useState)(``),d=(0,K.useRef)(null);(0,K.useEffect)(()=>{s&&d.current?.focus()},[s]);let f=e=>{u(``),i.navigate(e)},p=()=>{a?.parentPath!==void 0&&f(a.parentPath)};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`header`,{className:`flex min-h-14 shrink-0 items-center gap-3 border-b border-border pr-3 pl-[1.1rem]`,children:[(0,q.jsx)(ME,{className:`min-w-0 flex-1 text-base font-semibold`,children:`Choose repository`}),(0,q.jsx)(NE,{className:`sr-only`,children:`Browse folders on an Environment and select a Git repository.`}),(0,q.jsx)(XE,{environments:t,onSelect:n,selected:e}),(0,q.jsx)(jE,{"aria-label":`Close`,className:`grid size-8 place-items-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/30`,children:(0,q.jsx)(Gh,{"aria-hidden":`true`,className:`size-4`})})]}),(0,q.jsxs)(`div`,{className:`grid min-h-[3.25rem] shrink-0 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 border-b border-border px-3 py-2`,children:[(0,q.jsx)(T,{"aria-label":`Parent directory`,disabled:a?.parentPath===void 0||o,onClick:p,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,q.jsx)(zs,{"aria-hidden":`true`})}),s?(0,q.jsx)(oc,{"aria-label":`Filter current directory`,className:`h-8 bg-white/[.03] sm:h-8`,onChange:e=>u(e.target.value),placeholder:`Filter current directory`,ref:d,value:l}):(0,q.jsx)(`nav`,{"aria-label":`Current directory`,className:`flex min-w-0 items-center gap-1 overflow-x-auto text-xs whitespace-nowrap text-muted-foreground`,children:a?.breadcrumbs.map((e,t)=>(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0?(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`text-foreground/25`,children:`/`}):null,(0,q.jsx)(`button`,{className:`rounded-sm px-1.5 py-1 outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/30 disabled:bg-accent disabled:text-foreground`,disabled:e.path===a.path||o,onClick:()=>f(e.path),type:`button`,children:e.name})]},e.path))}),(0,q.jsx)(T,{"aria-label":s?`Close directory filter`:`Filter current directory`,onClick:()=>{c(e=>!e),s&&u(``)},size:`icon-sm`,type:`button`,variant:`ghost`,children:s?(0,q.jsx)(Gh,{"aria-hidden":`true`}):(0,q.jsx)(Uh,{"aria-hidden":`true`})})]}),(0,q.jsx)(WE,{entries:FE(a?.entries??[],l),error:i.directoryError,loading:o,onEnter:f,onParent:p,onSelect:i.select,selectedPath:i.selectedPath,truncated:a?.truncated??!1}),(0,q.jsxs)(`footer`,{className:`grid min-h-[3.75rem] shrink-0 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 border-t border-border px-3 py-2 max-[540px]:grid-cols-[minmax(0,1fr)_auto]`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`p`,{className:`truncate font-mono text-[.69rem] text-muted-foreground`,children:i.selectedPath??`Select a folder`}),i.selectionError===void 0?null:(0,q.jsx)(`p`,{"aria-live":`polite`,className:`truncate text-[.68rem] text-destructive`,children:i.selectionError})]}),(0,q.jsx)(jE,{className:`inline-flex h-8 items-center justify-center rounded-md border border-border bg-white/[.03] px-3 text-xs font-medium text-foreground/80 outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/30 max-[540px]:hidden`,children:`Cancel`}),(0,q.jsx)(T,{className:`h-8 px-3 text-xs sm:h-8`,disabled:i.selectedPath===void 0||i.opening||o,onClick:i.openRepository,type:`button`,children:i.opening?`Opening…`:`Open repository`})]})]})}function QE({environments:e,onOpenChange:t,onRepositoryOpened:n,open:r}){let[i,a]=(0,K.useState)(),o=e.find(({id:e})=>e===i)??e.find(({availability:e})=>e===`available`)??e[0];return o===void 0?null:(0,q.jsx)(AE,{onOpenChange:t,open:r,children:(0,q.jsx)(PE,{className:`flex h-[min(32rem,calc(100svh-2rem))] max-w-[46rem] flex-col overflow-hidden`,children:(0,q.jsx)(ZE,{environment:o,environments:e,chooseEnvironment:a,onRepositoryOpened:e=>{n(o.id,e),t(!1)}},o.id)})})}function $E({onOpenRepository:e,onOpenSettings:t,onRepositoryRemembered:n}){let r=rD(),i=Vn().status.availability===`available`,[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(()=>new Set([Lm.id])),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(),p=(0,K.useRef)(null),m=(0,K.useMemo)(()=>TT(r,l),[r,l]),h=(0,K.useMemo)(()=>ET(m),[m]),g=(0,K.useMemo)(()=>DT(m,s),[s,m]),_=(0,K.useMemo)(()=>OT(h,g),[g,h]),v=r.some(e=>e.repositories.length>0),y=m.some(e=>e.repositories.length>0);(0,K.useEffect)(()=>{p.current?.focus()},[]),(0,K.useEffect)(()=>{d!==void 0&&!_.some(e=>e.key===d)&&f(void 0)},[d,_]),(0,K.useEffect)(()=>{d!==void 0&&document.getElementById(LT(d))?.scrollIntoView({block:`nearest`})},[d]);let b=(0,K.useCallback)(t=>e(t),[e]),x=(0,K.useCallback)(e=>t(e.id),[t]),S=()=>{i&&o(!0)},C=(e,t)=>c(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r});return(0,q.jsxs)(`main`,{"aria-label":`Open project`,className:`h-full overflow-x-hidden overflow-y-auto bg-repository`,children:[(0,q.jsxs)(`div`,{className:`mx-auto w-[min(56rem,calc(100%-3rem))] pt-16 pb-20 max-[900px]:w-[calc(100%-2rem)] max-[650px]:pt-10`,children:[(0,q.jsx)(`h1`,{className:`mb-6 text-xl leading-tight font-semibold tracking-[-.018em]`,children:`Open project`}),(0,q.jsx)(PT,{activeDescendant:d===void 0?void 0:LT(d),browseAvailable:i,inputRef:p,onBrowse:S,onChange:e=>{u(e),f(void 0)},onKeyDown:e=>{if(e.key===`Escape`&&l.length>0){e.preventDefault(),u(``),f(void 0);return}if(e.key===`Enter`){let t=_.find(e=>e.key===d);if(t===void 0)return;e.preventDefault(),b(t.repository);return}let t=nD(e.key);if(t===0||_.length===0)return;e.preventDefault();let n=_.findIndex(e=>e.key===d),r=n<0?t>0?0:_.length-1:(n+t+_.length)%_.length;f(_[r]?.key)},query:l}),v?y?(0,q.jsxs)(`div`,{"aria-label":`Repositories`,id:`open-project-results`,role:`listbox`,children:[(0,q.jsx)(RT,{activeKey:d,items:h,onActivate:f,onOpen:b,onOpenSettings:x}),(0,q.jsx)(`div`,{className:`mt-[2.4rem] space-y-[1.2rem]`,children:m.filter(e=>e.repositories.length>0).map(e=>(0,q.jsx)(uE,{activeKey:d,environment:e,onActivate:f,onOpenChange:t=>C(e.id,t),onOpenRepository:b,onOpenSettings:x,open:s.has(e.id)},e.id))})]}):(0,q.jsx)(tD,{}):(0,q.jsx)(eD,{browseAvailable:i,onBrowse:S})]}),(0,q.jsx)(QE,{environments:r,onOpenChange:o,onRepositoryOpened:(e,t)=>n(t),open:a})]})}function eD({browseAvailable:e,onBrowse:t}){return(0,q.jsxs)(`button`,{className:`mt-[1.35rem] grid min-h-16 w-full grid-cols-[2.25rem_minmax(0,1fr)_auto] items-center gap-3 rounded-md px-2.5 text-left outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:opacity-45`,disabled:!e,onClick:t,type:`button`,children:[(0,q.jsx)(`span`,{className:`grid size-9 place-items-center rounded-[.45rem] bg-secondary text-secondary-foreground`,children:(0,q.jsx)(Ah,{"aria-hidden":`true`,className:`size-4`})}),(0,q.jsxs)(`span`,{className:`min-w-0`,children:[(0,q.jsx)(`strong`,{className:`block truncate text-[.82rem] font-semibold`,children:`Open a repository from your file system`}),(0,q.jsx)(`span`,{className:`block truncate text-[.72rem] text-muted-foreground`,children:`Choose a folder containing a Git repository`})]}),(0,q.jsx)(vr,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`})]})}function tD(){return(0,q.jsxs)(`div`,{className:`flex min-h-42 flex-col items-center justify-center text-center`,children:[(0,q.jsx)(Uh,{"aria-hidden":`true`,className:`mb-3 size-8 text-muted-foreground`,stroke:1.25}),(0,q.jsx)(`strong`,{className:`text-[.82rem] font-semibold`,children:`No repositories found`}),(0,q.jsx)(`p`,{className:`mt-1 max-w-72 text-[.72rem] text-muted-foreground`,children:`Browse your file system to open a repository that Rebase does not know yet.`})]})}function nD(e){return e===`ArrowDown`||e===`ArrowRight`?1:e===`ArrowUp`||e===`ArrowLeft`?-1:0}function rD(){let{repositories:e}=ah(),{availability:t,connectionState:n,status:r}=Vn().status;return(0,K.useMemo)(()=>n===`PairingRequired`?[]:[{availability:t,icon:Eh,iconColor:`var(--primary)`,id:Lm.id,name:Lm.name,repositories:e.map(e=>({environmentId:Lm.id,id:e.id,lastOpenedAt:e.lastOpenedAt,name:e.name,path:e.path})),status:r}],[t,n,e,r])}function iD({closeRepository:e,collapse:t,expand:n,navigation:r,openProject:i,openSettings:a,openRepositorySettings:o,selectRepository:s,toggleEnvironment:c}){let[l,u]=(0,K.useState)(``),{status:d}=Vn();return(0,q.jsx)(`nav`,{"aria-label":`Projects`,className:`flex h-full min-h-0 flex-col overflow-hidden border-sidebar-border/50 border-r bg-sidebar text-sidebar-foreground`,children:r.sidebarCollapsed?(0,q.jsx)(oD,{environmentStatus:d,expand:n,filterQuery:l,navigation:r,openProject:i,openSettings:a,selectRepository:s,toggleEnvironment:c}):(0,q.jsx)(aD,{closeRepository:e,collapse:t,environmentStatus:d,filterQuery:l,navigation:r,openProject:i,openSettings:a,openRepositorySettings:o,selectRepository:s,setFilterQuery:u,toggleEnvironment:c})})}function aD({closeRepository:e,collapse:t,environmentStatus:n,filterQuery:r,navigation:i,openProject:a,openSettings:o,openRepositorySettings:s,selectRepository:c,setFilterQuery:l,toggleEnvironment:u}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center px-4 text-sidebar-accent-foreground`,children:[(0,q.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-base font-semibold`,children:`Projects`}),(0,q.jsx)(T,{"aria-label":`Collapse Projects sidebar`,onClick:t,size:`icon`,variant:`ghost`,children:(0,q.jsx)(Fh,{"aria-hidden":`true`})})]}),(0,q.jsxs)(`div`,{className:`mx-3 mt-3 mb-1.5 flex items-center gap-2`,children:[(0,q.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,q.jsx)(Uh,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,q.jsx)(oc,{"aria-label":`Filter open projects`,className:`pl-9`,onChange:e=>l(e.target.value),placeholder:`Filter open projects`,value:r})]}),(0,q.jsx)(T,{"aria-current":i.workspaceView===`open-project`?`page`:void 0,"aria-label":`Open project`,className:`!size-7.5 shrink-0 border-0 ${i.workspaceView===`open-project`?`bg-sidebar-accent text-sidebar-accent-foreground`:``}`,onClick:a,size:`icon`,variant:`ghost`,children:(0,q.jsx)(Ah,{"aria-hidden":`true`})})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto`,children:(0,q.jsxs)(`div`,{"aria-label":`Open projects`,className:`px-2 py-1.5`,role:`tree`,children:[i.environments.length===0?(0,q.jsx)(`span`,{className:`sr-only`,role:`status`,children:n.status}):null,i.environments.map(t=>(0,q.jsxs)(sE,{onOpenChange:()=>u(t.id),open:t.expanded,children:[(0,q.jsxs)(`div`,{className:`flex h-9 min-w-0 items-center gap-1.5 px-1`,children:[(0,q.jsx)(cE,{"aria-label":`${t.expanded?`Collapse`:`Expand`} ${t.name}`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring/40`,children:(0,q.jsx)(Us,{"aria-hidden":`true`,className:`size-4 transition-transform ${t.expanded?``:`-rotate-90`}`})}),(0,q.jsx)(Eh,{"aria-hidden":`true`,className:`size-4.5 shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-sidebar-foreground`,children:t.name}),(0,q.jsx)(`span`,{className:n.availability===`available`?`sr-only`:`shrink-0 truncate text-sm ${n.availability===`unavailable`?`text-status-unavailable`:`text-muted-foreground`}`,role:`status`,children:n.status})]}),(0,q.jsx)(lE,{children:zm(t,r).map(n=>(0,q.jsxs)(`div`,{className:`group grid h-11 w-full min-w-0 grid-cols-[minmax(0,1fr)_1.875rem_1.875rem] items-center rounded-lg pr-1.5 pl-2.5 text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground ${i.selectedRepositoryId===n.id?`bg-sidebar-accent text-sidebar-accent-foreground`:``}`,children:[(0,q.jsxs)(`button`,{"aria-current":i.workspaceView===`repository`&&i.selectedRepositoryId===n.id?`page`:void 0,"aria-label":`Open ${n.name}`,className:`grid h-full min-w-0 grid-cols-[1.875rem_minmax(0,1fr)] items-center gap-2.5 text-left text-base outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring/40 disabled:pointer-events-none disabled:opacity-45`,disabled:n.disabled,onClick:()=>c(t.id,n),type:`button`,children:[(0,q.jsx)(`span`,{className:`grid size-7.5 shrink-0 place-items-center rounded-md bg-secondary text-sm font-semibold`,children:cD(n.name)}),(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:n.name})]}),(0,q.jsx)(FT,{name:n.name,onOpen:()=>s(t.id,n)}),(0,q.jsx)(`button`,{"aria-label":`Close ${n.name}`,className:`grid size-7.5 place-items-center rounded-md text-muted-foreground outline-none hover:bg-sidebar-accent-foreground/10 hover:text-sidebar-accent-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring/40`,onClick:()=>e(t.id,n),type:`button`,children:(0,q.jsx)(Gh,{"aria-hidden":`true`,className:`size-4`})})]},n.id))})]},t.id))]})}),(0,q.jsx)(sD,{openSettings:o})]})}function oD({environmentStatus:e,expand:t,filterQuery:n,navigation:r,openProject:i,openSettings:a,selectRepository:o,toggleEnvironment:s}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":`Expand Projects sidebar`,className:`mx-auto mt-1 grid size-10 shrink-0 place-items-center rounded-md text-muted-foreground outline-none hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring/40`,onClick:t,children:(0,q.jsx)(Ih,{"aria-hidden":`true`,className:`size-5`})}),(0,q.jsx)(`button`,{type:`button`,"aria-current":r.workspaceView===`open-project`?`page`:void 0,"aria-label":`Open project`,className:`mx-auto mt-2 grid size-10 shrink-0 place-items-center rounded-md text-sidebar-foreground outline-none hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-sidebar-ring/40 ${r.workspaceView===`open-project`?`bg-sidebar-accent text-sidebar-accent-foreground`:``}`,onClick:i,children:(0,q.jsx)(Ah,{"aria-hidden":`true`,className:`size-5`})}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center gap-1.5 pt-3`,children:[r.environments.length===0?(0,q.jsx)(`span`,{className:`sr-only`,role:`status`,children:e.status}):null,r.environments.map(t=>{let i=`${t.expanded?`Collapse`:`Expand`} ${t.name}, ${e.status}`;return(0,q.jsxs)(`div`,{className:`grid justify-items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,"aria-expanded":t.expanded,"aria-label":i,className:`grid size-10 place-items-center rounded-md outline-none hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-sidebar-ring/40 ${e.availability===`unavailable`?`text-status-unavailable`:`text-muted-foreground`}`,onClick:()=>s(t.id),children:(0,q.jsx)(Eh,{"aria-hidden":`true`,className:`size-5`})}),t.expanded?zm(t,n).map(e=>(0,q.jsx)(`button`,{"aria-current":r.workspaceView===`repository`&&r.selectedRepositoryId===e.id?`page`:void 0,"aria-label":e.name,className:`grid size-10 place-items-center rounded-md bg-secondary text-sm font-semibold text-sidebar-foreground outline-none hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-sidebar-ring/40 disabled:pointer-events-none disabled:opacity-45 ${r.selectedRepositoryId===e.id?`bg-sidebar-accent`:``}`,disabled:e.disabled,onClick:()=>o(t.id,e),type:`button`,children:cD(e.name)},e.id)):null]},t.id)})]}),(0,q.jsx)(sD,{collapsed:!0,openSettings:a})]})}function sD({collapsed:e=!1,openSettings:t}){return e?(0,q.jsx)(`button`,{type:`button`,"aria-label":`Settings`,className:`mx-auto mb-3 grid size-10 shrink-0 place-items-center rounded-md text-muted-foreground outline-none hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring/40`,onClick:t,children:(0,q.jsx)(Ho,{"aria-hidden":`true`,className:`size-5`})}):(0,q.jsxs)(T,{className:`mx-3 mb-2 h-10 justify-between px-2 text-muted-foreground`,onClick:t,variant:`ghost`,children:[`Settings`,(0,q.jsx)(Ho,{"aria-hidden":`true`,"data-icon":`inline-end`})]})}function cD(e){return e.split(/[-_\s]+/).map(e=>e[0]).filter(e=>e!==void 0).join(``).slice(0,2).toUpperCase()}function lD({title:e,children:t}){return(0,q.jsxs)(`section`,{"aria-label":e,className:`mt-8`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),(0,q.jsx)(`div`,{className:`mt-2 space-y-1`,children:t})]})}function uD({title:e,description:t,descriptionId:n,liveDescription:r=!1,children:i}){return(0,q.jsxs)(`div`,{className:`flex min-h-20 flex-col items-start justify-between gap-3 rounded-xl px-3 py-4 sm:px-4 md:flex-row md:items-center md:gap-8`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium`,children:e}),t===void 0?null:(0,q.jsx)(`div`,{id:n,"aria-live":r?`polite`:void 0,"aria-atomic":r||void 0,className:`mt-1 text-[13px] leading-5 text-muted-foreground`,children:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:i})]})}var dD={_tag:`Inherit`};function fD({repositoryId:e,canConfigure:t}){let n=(0,K.useId)(),r=In(hp.fetchStatus,{repositoryId:e},{changes:`refs`}),i=Xr(hp.configureFetch),a=r.data?.setting??dD,o=r.data?.defaultIntervalSeconds??300,s=!i.canRun||!t||r.data===void 0,c=i.canRun?r.error===null?t?`Loading fetch settings.`:`Connect with repository write access to change fetch settings.`:Cr(r.error):`Reconnect to the server and try again.`,[l,u]=(0,K.useState)(),d=l?.mode??a._tag,f=l?.seconds??String(a._tag===`Interval`?a.seconds:o),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)();return(0,q.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),s||p)return;let n=Number(f);if(d===`Interval`&&(!Number.isInteger(n)||n<1||n>86400)){g(`Enter a whole number from 1 to 86400 seconds.`);return}let r=d===`Interval`?{_tag:`Interval`,seconds:n}:{_tag:d};m(!0),g(void 0),i.run({repositoryId:e,setting:r}).then(e=>{e._tag===`Ok`?u(void 0):g(Cr(e))}).finally(()=>m(!1))},children:[(0,q.jsxs)(`fieldset`,{className:`m-0 border-0 p-0`,disabled:s||p,children:[(0,q.jsx)(uD,{title:`Automatic fetch`,description:`Shared by clients connected to this repository.`,descriptionId:`${n}-scope`,children:(0,q.jsxs)(`select`,{"aria-label":`Automatic fetch`,"aria-describedby":`${n}-scope`,className:`h-8 rounded-md border border-input bg-background px-3 text-sm`,value:d,onChange:e=>{let t=e.currentTarget.value;(t===`Inherit`||t===`Disabled`||t===`Interval`)&&u({mode:t,seconds:f})},children:[(0,q.jsxs)(`option`,{value:`Inherit`,children:[`Server default · `,pD(o)]}),(0,q.jsx)(`option`,{value:`Disabled`,children:`Off`}),(0,q.jsx)(`option`,{value:`Interval`,children:`Custom interval`})]})}),d===`Interval`?(0,q.jsx)(uD,{title:`Custom interval`,description:`Fetch every 1 to 86,400 seconds.`,descriptionId:`${n}-interval`,children:(0,q.jsx)(oc,{"aria-label":`Interval in seconds`,"aria-describedby":h===void 0?`${n}-interval`:`${n}-interval ${n}-error`,"aria-invalid":h!==void 0,className:`w-32`,max:86400,min:1,onChange:e=>u({mode:d,seconds:e.target.value}),required:!0,step:1,type:`number`,value:f})}):null]}),h===void 0?null:(0,q.jsx)(`p`,{className:`mt-3 mb-0 text-xs text-destructive`,id:`${n}-error`,role:`alert`,children:h}),s?(0,q.jsx)(`p`,{className:`mt-3 mb-0 text-xs text-muted-foreground`,children:c??`Fetch settings are unavailable.`}):null,(0,q.jsx)(`div`,{className:`mt-2 flex justify-end px-4`,children:(0,q.jsx)(T,{disabled:s||p,size:`sm`,type:`submit`,variant:`outline`,children:p?`Saving`:`Save`})})]})}function pD(e){if(e%60==0){let t=e/60;return`${t} ${t===1?`minute`:`minutes`}`}return`${e} ${e===1?`second`:`seconds`}`}function mD(e){return EE(`alert-dialog`,e)}function hD(e){return(0,q.jsx)(mD,{"data-slot":`alert-dialog`,...e})}function gD({children:e,className:t,...n}){return(0,q.jsxs)(bE,{children:[(0,q.jsx)(pE,{className:`fixed inset-0 z-50 bg-black/65`}),(0,q.jsx)(OE,{className:`fixed inset-0 z-50 grid place-items-center overflow-y-auto p-4`,children:(0,q.jsx)(yE,{className:r(`w-full max-w-md rounded-lg border border-border bg-popover p-5 text-popover-foreground shadow-2xl outline-none`,t),"data-slot":`alert-dialog-content`,...n,children:e})})]})}function _D({className:e,...t}){return(0,q.jsx)(kE,{className:r(`text-base font-semibold`,e),"data-slot":`alert-dialog-title`,...t})}function vD({className:e,...t}){return(0,q.jsx)(hE,{className:r(`mt-2 text-sm text-muted-foreground`,e),"data-slot":`alert-dialog-description`,...t})}function yD({className:e,...t}){return(0,q.jsx)(`div`,{className:r(`mt-5 flex justify-end gap-2`,e),"data-slot":`alert-dialog-footer`,...t})}function bD({className:e,...t}){return(0,q.jsx)(mE,{className:r(x({variant:`outline`}),e),"data-slot":`alert-dialog-cancel`,...t})}function xD({className:e,...t}){return(0,q.jsx)(mE,{className:r(x({variant:`destructive`}),e),"data-slot":`alert-dialog-action`,...t})}function SD(e){return e===void 0?`Unavailable`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function CD({history:e,identity:t,onCacheChanged:n}){let r=fg(e),[i,a]=(0,K.useState)(),[o,s]=(0,K.useState)(),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(),[m,h]=(0,K.useState)(),g=(0,K.useCallback)(async()=>{p(void 0);try{a(await e.ask({_tag:`Storage`,action:`inspect`}))}catch{p(`Unable to read history storage. Try refreshing.`)}},[e]);(0,K.useEffect)(()=>{g()},[g]);let _=r.synchronization===`complete`;(0,K.useEffect)(()=>{_&&g()},[g,_]);async function v(r){s(void 0),l(!0),p(void 0),h(void 0);try{await e.ask({_tag:`Storage`,action:r}),r===`remove`&&(d(!0),a(e=>e&&{...e,caches:e.caches.filter(e=>e.environmentId!==t.environmentId||e.repositoryId!==t.repositoryId)})),h(wD[r].result),r!==`remove`&&await g();try{await n(r,r===`clear-all`?void 0:t)}catch{p(`The cache changed, but the repository view could not refresh. Reopen the repository to update it.`)}}catch{p(`The cache action could not finish. Refresh storage details and try again.`)}finally{l(!1)}}return{snapshot:r,diagnostics:i,confirmation:o,setConfirmation:s,pending:c,removed:u,error:f,message:m,refresh:g,manage:v,exhausted:i?.usageBytes!==void 0&&i.quotaBytes!==void 0&&i.usageBytes>=i.quotaBytes,storageUnavailable:r.failure?._tag===`StorageUnavailable`}}var wD={clear:{label:`Clear cache`,description:`Clear this repository’s cached history and pause synchronization. Rebuild or reopen the repository to load history.`,result:`Cache cleared. Rebuild or reopen the repository to load history.`},rebuild:{label:`Rebuild cache`,description:`Clear this repository’s cached history and download it again. The environment must be connected.`,result:`Cache rebuild requested.`},remove:{label:`Remove cache`,description:`Remove this repository’s cached history and close its history readers. Reopen the repository to download history again.`,result:`Cache removed. Reopen the repository to load history.`},"clear-all":{label:`Clear all caches`,description:`Clear cached history for every repository, including open repositories. Rebuild or reopen a repository to load its history.`,result:`All history caches cleared. Rebuild or reopen a repository to load history.`}};function TD(e){let t=CD(e),n=t.diagnostics?.caches.find(({environmentId:t,repositoryId:n})=>t===e.identity.environmentId&&n===e.identity.repositoryId),r=t.removed||t.pending;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(uD,{title:`Cached history`,description:`Stored in this client.`,children:(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:n===void 0?t.diagnostics===void 0?`Reading storage…`:`No cached history`:`${SD(n.estimatedBytes)} · ${n.commitCount.toLocaleString()} commits`})}),(0,q.jsxs)(uD,{title:`Repair or clear history`,description:`Repository files stay on disk.`,children:[(0,q.jsx)(T,{size:`sm`,variant:`outline`,"aria-label":`Rebuild cache`,disabled:r||!e.connected,onClick:()=>t.setConfirmation(`rebuild`),children:`Rebuild`}),(0,q.jsx)(T,{size:`sm`,variant:`outline`,disabled:r,onClick:()=>t.setConfirmation(`clear`),children:`Clear cache`})]}),t.exhausted||t.storageUnavailable?(0,q.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[t.exhausted?`Browser storage is full.`:`Browser storage is unavailable.`,` `,`Clear unused history, then rebuild this cache.`]}):null,t.snapshot.failure!==void 0&&!t.storageUnavailable&&!t.removed?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:t.snapshot.failure._tag===`Offline`?`Reconnect to finish history synchronization.`:`History synchronization failed. Rebuild the cache to retry.`}):null,t.pending?(0,q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Updating history storage…`}):null,t.snapshot.synchronization===`syncing`&&!t.removed?(0,q.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[`Synchronizing history · `,t.snapshot.commitCount.toLocaleString(),` `,`commits stored`]}):null,t.message===void 0?null:(0,q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:t.message}),t.error===void 0?null:(0,q.jsxs)(`div`,{role:`alert`,className:`text-sm text-destructive`,children:[t.error,(0,q.jsx)(T,{size:`sm`,variant:`ghost`,disabled:t.pending,onClick:()=>void t.refresh(),children:`Retry`})]}),(0,q.jsxs)(`details`,{className:`px-4 text-sm text-muted-foreground`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:`Storage details`}),(0,q.jsxs)(`div`,{className:`space-y-3 py-3`,children:[(0,q.jsx)(`p`,{children:`Cache sizes are estimates. Open repositories are protected from automatic eviction.`}),n===void 0?null:(0,q.jsxs)(`p`,{children:[`History: `,n.state]}),(0,q.jsx)(T,{size:`sm`,variant:`outline`,disabled:r,onClick:()=>t.setConfirmation(`remove`),children:`Remove cache`})]})]}),(0,q.jsx)(hD,{open:t.confirmation!==void 0,onOpenChange:e=>{e||t.setConfirmation(void 0)},children:(0,q.jsxs)(gD,{children:[(0,q.jsxs)(_D,{children:[t.confirmation===void 0?`Manage cache`:wD[t.confirmation].label,`?`]}),(0,q.jsx)(vD,{children:t.confirmation===void 0?``:wD[t.confirmation].description}),(0,q.jsxs)(yD,{children:[(0,q.jsx)(bD,{children:`Cancel`}),(0,q.jsx)(xD,{onClick:()=>{t.confirmation!==void 0&&t.manage(t.confirmation)},children:t.confirmation===void 0?`Confirm`:wD[t.confirmation].label})]})]})})]})}function ED({name:e,path:t,connected:n,canRemove:r,copyPath:i,reveal:a,remove:o}){let[s,c]=(0,K.useState)(!1),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(),[p,m]=(0,K.useState)(),h=async(e,t)=>{u(!0),f(void 0),m(void 0);try{await e(),m(t)}catch(e){f(e instanceof Error?e.message:`The repository action failed. Try again.`)}finally{u(!1)}};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(uD,{title:`Checkout path`,description:(0,q.jsx)(`span`,{className:`break-all font-mono text-xs`,children:t}),children:[(0,q.jsx)(T,{size:`sm`,variant:`outline`,disabled:l,onClick:()=>void h(i,`Path copied.`),children:`Copy path`}),a===void 0?null:(0,q.jsx)(T,{size:`sm`,variant:`outline`,disabled:l||!n,onClick:()=>void h(a),children:`Reveal`})]}),(0,q.jsx)(uD,{title:`Remove from Rebase`,description:r?`Keeps the repository and its files on disk.`:`Connect with repository catalog access to remove this repository.`,children:(0,q.jsx)(T,{size:`sm`,variant:`outline`,className:`text-destructive`,disabled:l||!r,onClick:()=>c(!0),children:`Remove repository`})}),p===void 0?null:(0,q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:p}),d===void 0?null:(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:d}),(0,q.jsx)(hD,{open:s,onOpenChange:c,children:(0,q.jsxs)(gD,{children:[(0,q.jsx)(_D,{children:`Remove repository?`}),(0,q.jsxs)(vD,{children:[`Remove `,e,` from Rebase? The repository and its files will stay on disk.`]}),(0,q.jsxs)(yD,{children:[(0,q.jsx)(bD,{children:`Cancel`}),(0,q.jsx)(xD,{onClick:()=>void h(o),children:`Remove repository`})]})]})})]})}function DD({repositoryId:e,history:t,reveal:n,onRemoved:r}){let i=lh(e),{environmentId:a,connected:o,writable:s}=Vn(),c=Xr(Jf.remove,{answers:sh}),l=i?.logicalRepositoryId??e,u=(0,K.useRef)(null),d=(0,K.useMemo)(()=>a===void 0?void 0:{environmentId:a,repositoryId:l},[a,l]);if((0,K.useEffect)(()=>{u.current?.focus()},[]),i===void 0)return null;let f=i.path;return(0,q.jsxs)(`main`,{"aria-label":`Repository settings`,className:`h-full overflow-y-auto bg-repository`,children:[(0,q.jsx)(`header`,{className:`flex h-12 items-center border-b border-border/60 px-6 text-xs`,children:(0,q.jsxs)(`span`,{children:[i.name,(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:` / Settings`})]})}),(0,q.jsxs)(`div`,{className:`mx-auto max-w-4xl px-4 pt-8 pb-16 sm:px-8`,children:[(0,q.jsx)(`h1`,{ref:u,tabIndex:-1,className:`text-xl font-semibold tracking-tight outline-none`,children:`Repository settings`}),(0,q.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[i.name,` · `,Lm.name]}),(0,q.jsx)(lD,{title:`History`,children:d===void 0?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Connect to the environment to load repository preferences.`}):(0,q.jsx)(kD,{identity:d})}),t===void 0||d===void 0?(0,q.jsx)(`p`,{role:`status`,className:`mt-8 text-sm text-muted-foreground`,children:a===void 0?`Reconnect to load repository settings.`:`Loading repository settings…`}):(0,q.jsx)(OD,{history:t,repositoryId:e,identity:d,connected:o,canConfigure:s}),(0,q.jsx)(lD,{title:`Repository`,children:(0,q.jsx)(ED,{name:i.name,path:f,connected:o,canRemove:c.canRun,copyPath:()=>bc(f),reveal:n===void 0?void 0:()=>n(f),remove:async()=>{let t=await c.run({repositoryId:e});if(t._tag!==`Ok`)throw Error(Cr(t));r()}})})]})]})}function OD({history:e,repositoryId:t,identity:n,connected:r,canConfigure:i}){let a=yn();return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(lD,{title:`Fetch`,children:(0,q.jsx)(fD,{repositoryId:t,canConfigure:i})}),(0,q.jsx)(lD,{title:`History storage`,children:(0,q.jsx)(TD,{history:e,identity:n,connected:r,onCacheChanged:()=>ps(a,n.environmentId,n.repositoryId)})})]})}function kD({identity:e}){let t=(0,K.useId)(),n=ZS(e.environmentId,e.repositoryId),[r,i]=(0,K.useState)(!1);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(uD,{title:`History ordering`,description:`Saved for this repository in this client.`,descriptionId:t,children:(0,q.jsxs)(`select`,{"aria-label":`History ordering`,"aria-describedby":t,className:`h-8 rounded-md border border-input bg-background px-3 text-sm`,value:n,onChange:t=>{try{YS(e,t.currentTarget.value===`chronological`?`chronological`:`topological`),i(!1)}catch{i(!0)}},children:[(0,q.jsx)(`option`,{value:`topological`,children:`Topological`}),(0,q.jsx)(`option`,{value:`chronological`,children:`Chronological`})]})}),r?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:`Could not save history ordering. Check this client's storage and try again.`}):null]})}var AD=K.createContext(null);function jD(){let e=K.useContext(AD);if(e===null)throw Error(s(60));return e}var $={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:Fv(t,r)!==``},hasNullItemLabel:(e,t)=>t?Nv(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>Ev(t,e,n)):Ev(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function MD(e,t){return Math.max(0,e-t)}function ND(e,t){if(t<=0)return 0;let n=ib(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function PD(e){let{id:t,value:n,defaultValue:r=null,onValueChange:a,open:s,defaultOpen:l=!1,onOpenChange:u,name:d,form:f,autoComplete:p,disabled:m=!1,readOnly:g=!1,required:_=!1,modal:b=!0,actionsRef:x,inputRef:S,onOpenChangeComplete:C,items:T,multiple:E=!1,itemToStringLabel:D,itemToStringValue:O,isItemEqualToValue:k=Tv,highlightItemOnHover:A=!0,children:j}=e,{clearErrors:M}=cc(),{setDirty:N,setTouched:P,setFocused:F,validityData:I,setFilled:L,name:R,disabled:z,validation:B,validationMode:V}=rc(),ee=tc({id:t}),te=z||m,ne=R??d,[H,re]=mc({controlled:n,default:E?r??v:r,name:`Select`,state:`value`}),[ie,ae]=mc({controlled:s,default:l,name:`Select`,state:`open`}),oe=K.useRef([]),se=K.useRef([]),ce=K.useRef(null),le=K.useRef(null),ue=K.useRef(0),de=K.useRef(null),fe=K.useRef([]),pe=K.useRef(!1),U=K.useRef(null),me=K.useRef(null),he=K.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ge=K.useRef(!1),{mounted:_e,setMounted:ve,transitionStatus:ye}=Ia(ie),{openMethod:be,triggerProps:xe}=ma(ie),Se=o(()=>new Ra({id:ee,labelId:void 0,modal:b,multiple:E,itemToStringLabel:D,itemToStringValue:O,isItemEqualToValue:k,value:H,open:ie,mounted:_e,transitionStatus:ye,items:T,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,Ce=G(Se,$.activeIndex),we=G(Se,$.selectedIndex),Te=G(Se,$.triggerElement),Ee=G(Se,$.positionerElement),De=Ng(be),Oe=be??De,ke=K.useMemo(()=>E?``:Fv(H,O),[E,H,O]),Ae=K.useMemo(()=>E&&Array.isArray(H)?H.map(e=>Fv(e,O)):Fv(H,O),[E,H,O]),je=go(Te),Me=h(()=>Ae);fc(je,ee,H,Me,!te,d);let Ne=K.useRef(H),Pe=E?Array.isArray(H)&&H.length>0:H!=null&&ke!==``;w(()=>{L(Pe)},[Pe,L]),w(function(){let e=H,t=!1;if(E){let n=Array.isArray(H)?H:[];t=n.length===0,e=n[n.length-1]}let n=t?-1:Ov(fe.current,e,k),r=n===-1?null:n;r===null&&(me.current=null),!ie&&Se.set(`selectedIndex`,r)},[E,ie,H,k,Se]);function Fe(e){let t=I.initialValue;return Array.isArray(e)&&Array.isArray(t)?!Gv(e,t,(e,t)=>Ev(e,t,k)):e!==t}to(H,()=>{M(ne),N(Fe(H)),B.change(H)});let Ie=h((e,t)=>{u?.(e,t),!t.isCanceled&&(ae(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(P(!0),F(!1),V===`onBlur`&&B.commit(H)))}),Le=h(()=>{ve(!1),Se.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),C?.(!1)});va({enabled:!x,open:ie,ref:ce,onComplete(){ie||Le()}}),K.useImperativeHandle(x,()=>({unmount:Le}),[Le]);let Re=h((e,t)=>{a?.(e,t),!t.isCanceled&&re(e)}),ze=h(e=>{let t=MD(e.scrollHeight,e.clientHeight),n=ND(e.scrollTop,t),r=n>0,i=n<t;Se.set(`scrollUpArrowVisible`,r),Se.set(`scrollDownArrowVisible`,i)}),Be=Mg({open:ie,onOpenChange:Ie,elements:{reference:Te,floating:Ee}}),Ve=Ma(Be,{enabled:!g&&!te,event:`mousedown`}),He=ga(Be),Ue=vi(Be,{enabled:!g&&!te,listRef:oe,activeIndex:Ce,selectedIndex:we,disabledIndices:v,onNavigate(e){e===null&&!ie||Se.set(`activeIndex`,e)},focusItemOnHover:A}),We=li(Be,{enabled:!g&&!te&&(ie||!E),listRef:se,activeIndex:Ce,selectedIndex:we,disabledIndices:e=>Pg(oe.current[e]),onMatch(e){ie?Se.set(`activeIndex`,e):Re(fe.current[e],za(ji))},onTyping(e){pe.current=e}}),Ge=K.useMemo(()=>y(We.reference,Ue.reference,He.reference,Ve.reference,xe),[Ve.reference,We.reference,Ue.reference,He.reference,xe]),Ke=K.useMemo(()=>y(qi,We.floating,Ue.floating,He.floating),[We.floating,Ue.floating,He.floating]),qe=Ue.item??c;pv(()=>{Se.update({popupProps:Ke,triggerProps:Ge})}),Se.useSyncedValues({id:ee,modal:b,multiple:E,value:H,open:ie,mounted:_e,transitionStatus:ye,popupProps:Ke,triggerProps:Ge,items:T,itemToStringLabel:D,itemToStringValue:O,isItemEqualToValue:k,openMethod:Oe});let Je=K.useMemo(()=>({store:Se,floatingContext:Be,required:_,disabled:te,readOnly:g,multiple:E,highlightItemOnHover:A,setValue:Re,setOpen:Ie,listRef:oe,popupRef:ce,scrollHandlerRef:le,handleScrollArrowVisibility:ze,scrollArrowsMountedCountRef:ue,itemProps:qe,valueRef:de,valuesRef:fe,labelsRef:se,typingRef:pe,selectionRef:he,firstItemTextRef:U,selectedItemTextRef:me,validation:B,onOpenChangeComplete:C,alignItemWithTriggerActiveRef:ge,initialValueRef:Ne}),[Se,Be,_,te,g,E,A,Re,Ie,qe,B,C,ze]),Ye=i(S,B.inputRef),Xe=E?void 0:ne,Ze=K.useMemo(()=>!E||!Array.isArray(H)||!ne?null:H.map(e=>{let t=Fv(e,O);return(0,q.jsx)(`input`,{type:`hidden`,form:f,name:ne,value:t,disabled:te},t)}),[E,H,f,ne,O,te]);return(0,q.jsxs)(AD.Provider,{value:Je,children:[j,(0,q.jsx)(`input`,{...B.getValidationProps(te,{onFocus(){Se.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||te||g)return;let t=e.currentTarget.value,n=za(ji,e.nativeEvent);function r(){if(E)return;let e=t.toLowerCase(),r=fe.current.findIndex(t=>Fv(t,O).toLowerCase()===e||Pv(t,D).toLowerCase()===e);r===-1&&(r=fe.current.findIndex((t,n)=>{let r=se.current[n];return r!=null&&r.toLowerCase()===e}));let i=fe.current[r];i!=null&&Re(i,n)}Se.set(`forceMount`,!0),queueMicrotask(r)}}),id:ee&&Xe==null?`${ee}-hidden-input`:void 0,form:f,name:Xe,autoComplete:p,value:ke,disabled:te,required:_&&!(E&&Pe),readOnly:g,ref:Ye,style:ne?Hi:Ei,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Ze]})}var FD=400,ID={...gi,...pc,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},LD=K.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,setFocused:d,validationMode:f,state:p,disabled:m}=rc(),{labelId:h}=nc(),{store:g,setOpen:_,selectionRef:v,validation:b,readOnly:x,required:S,alignItemWithTriggerActiveRef:w,disabled:T}=jD(),E=m||T||a,D=G(g,$.open),O=G(g,$.mounted),k=G(g,$.value),A=G(g,$.triggerProps),j=G(g,$.positionerElement),M=G(g,$.listElement),N=G(g,$.popupSide),P=G(g,$.id),F=G(g,$.labelId),I=G(g,$.hasSelectedValue),L=O&&j?N:null,R=i??P,z=Xv(h,F);tc({id:R});let B=go(j),V=K.useRef(null),{getButtonProps:ee,buttonRef:te}=C({disabled:E,native:o}),ne=g.useStateSetter(`triggerElement`),H=zi(),re=zi(),ie=zi();K.useEffect(()=>{if(D)return ie.start(FD,()=>{v.current.allowUnselectedMouseUp=!0,v.current.allowSelectedMouseUp=!0}),()=>{ie.clear()};v.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},re.clear()},[D,v,re,ie]);let ae=y(A,{id:R,role:`combobox`,"aria-expanded":D,"aria-haspopup":`listbox`,"aria-controls":D?M?.id??_i(j)?.id:void 0,"aria-labelledby":z,"aria-readonly":x||void 0,"aria-required":S||void 0,tabIndex:E?-1:0,onFocus(e){d(!0),D&&w.current&&_(!1,za(ji,e.nativeEvent)),H.start(0,()=>{g.set(`forceMount`,!0)})},onBlur(e){Wa(j,e.relatedTarget)||(l(!0),d(!1),f===`onBlur`&&b.commit(k))},onMouseDown(e){if(D)return;let t=io(e.currentTarget);function n(e){if(!V.current)return;let t=e.target;Wa(V.current,t)||Wa(B.current,t)||Ys(e,V.current)||_(!1,za(fo,e))}re.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,ee),oe=b.getValidationProps(E,ae);oe.role=`combobox`;let se={...p,open:D,disabled:E,value:k,readOnly:x,popupSide:L,placeholder:!I};return u(`button`,e,{ref:[t,V,te,ne],state:se,stateAttributesMapping:ID,props:oe})}),RD={value:()=>null},zD=K.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,{store:c,valueRef:l}=jD(),d=G(c,$.value),f=G(c,$.items),p=G(c,$.itemToStringLabel),m=G(c,$.hasSelectedValue),h=!m&&a!=null&&i==null,g=G(c,$.hasNullItemLabel,h),_={value:d,placeholder:!m},v=null;return v=typeof i==`function`?i(d):i??(h&&!g?a:Array.isArray(d)?Lv(d,f,p):Iv(d,f,p)),u(`span`,e,{state:_,ref:[t,l],props:[{children:v},s],stateAttributesMapping:RD})}),BD=K.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{store:o}=jD(),s={open:G(o,$.open)};return u(`span`,e,{state:s,ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:Ji})}),VD=K.forwardRef(function(e,t){let{store:n}=jD(),r=G(n,$.mounted),i=G(n,$.forceMount);return r||i?(0,q.jsx)(ca,{ref:t,...e}):null}),HD=K.createContext(void 0);function UD(){let e=K.useContext(HD);if(!e)throw Error(s(59));return e}function WD(e,t){e&&Object.assign(e.style,t)}var GD={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},KD={position:`fixed`},qD=K.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:g=!0,collisionAvoidance:_=lo,style:v,...y}=e,{store:b,listRef:x,labelsRef:S,alignItemWithTriggerActiveRef:C,selectedItemTextRef:T,valuesRef:E,initialValueRef:D,popupRef:O,setValue:k,floatingContext:A}=jD(),j=G(b,$.open),M=G(b,$.mounted),N=G(b,$.modal),P=G(b,$.value),F=G(b,$.openMethod),I=G(b,$.positionerElement),L=G(b,$.triggerElement),R=G(b,$.isItemEqualToValue),z=G(b,$.transitionStatus),B=K.useRef(null),V=K.useRef(null),[ee,te]=K.useState(g),ne=M&&ee&&F!==`touch`;!M&&ee!==g&&te(g),K.useImperativeHandle(C,()=>ne),Ba((ne||N)&&j,F===`touch`,I,L);let H=ro({anchor:n,floatingRootContext:A,positionMethod:a,mounted:M,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??ne,collisionAvoidance:_,keepMounted:!0}),re=ne?`none`:H.side,ie=ne?KD:H.positionerStyles,ae={open:j,side:re,align:H.align,anchorHidden:H.anchorHidden};w(()=>{b.set(`popupSide`,H.side)},[b,H.side]);let oe=b.useStateSetter(`positionerElement`),se=Ca(e,ae,{styles:ie,transitionStatus:z,props:y,refs:[t,oe],hidden:!M,inert:!j}),ce=K.useRef(0),le=h(e=>{if(E.current.length===0)return;let t=ce.current;if(ce.current=e.size,e.size===t)return;let n=za(ji);if(t!==0&&!b.state.multiple&&P!==null&&Ov(E.current,P,R)===-1){let e=D.current,t=e!=null&&Ov(E.current,e,R)!==-1?e:null;k(t,n),t===null&&(b.set(`selectedIndex`,null),T.current=null)}if(t!==0&&b.state.multiple&&Array.isArray(P)){let e=P.filter(e=>Ov(E.current,e,R)!==-1);e.length!==P.length&&(k(e,n),e.length===0&&(b.set(`selectedIndex`,null),T.current=null))}if(j&&ne){b.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};WD(I,e),WD(O.current,e)}}),ue=K.useMemo(()=>({...H,side:re,alignItemWithTriggerActive:ne,setControlledAlignItemWithTrigger:te,scrollUpArrowRef:B,scrollDownArrowRef:V}),[H,re,ne,te]);return(0,q.jsx)(sa,{elementsRef:x,labelsRef:S,onMapChange:le,children:(0,q.jsxs)(HD.Provider,{value:ue,children:[M&&N&&(0,q.jsx)(xa,{inert:da(!j),cutout:L}),se]})})}),JD=`base-ui-disable-scrollbar`,YD={className:JD,getElement(e){return(0,q.jsx)(`style`,{nonce:e,href:JD,precedence:`base-ui:low`,children:`.${JD}{scrollbar-width:none}.${JD}::-webkit-scrollbar{display:none}`})}},XD={...ti,...pi},ZD=K.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s,popupRef:c,onOpenChangeComplete:l,setOpen:d,valueRef:p,firstItemTextRef:m,selectedItemTextRef:g,multiple:_,handleScrollArrowVisibility:v,scrollHandlerRef:y,listRef:b,highlightItemOnHover:x,floatingContext:S}=jD(),{side:C,align:T,alignItemWithTriggerActive:E,isPositioned:D,setControlledAlignItemWithTrigger:O}=UD(),k=Ai(!0)!=null,A=uo(),{nonce:j,disableStyleElements:M}=$w(),N=G(s,$.id),P=G(s,$.open),F=G(s,$.openMethod),I=G(s,$.mounted),L=G(s,$.popupProps),R=G(s,$.transitionStatus),z=G(s,$.triggerElement),B=G(s,$.positionerElement),V=G(s,$.listElement),ee=K.useRef(!1),te=K.useRef(!1),ne=K.useRef({}),H=Ta(),re=h(e=>{if(!B||!c.current||!te.current)return;let t=B.style.top===`0px`,n=B.style.bottom===`0px`;if(ee.current||!E||!t&&!n){v(e);return}let r=eO(B),i=tO(B.getBoundingClientRect().height,`y`,r),a=io(B),o=f(B),s=o.getComputedStyle(B),l=parseFloat(s.marginTop),u=parseFloat(s.marginBottom),d=QD(o.getComputedStyle(c.current)),p=Math.min(a.documentElement.clientHeight-l-u,d),m=e.scrollTop,h=$D(e),g=null,_=e=>{B.style.height=`${e}px`},y=t?h-m:m,b=Math.min(i+y,p);if(y<=1){let n=ib(y,0,p-i);n>0&&_(i+n),e.scrollTop=t?h:0,p-(i+n)<=1&&(ee.current=!0),v(e);return}p-b>1?g=t?1/0:0:n&&m<h&&(g=m-(y-(i+y-p)));let x=Math.ceil(b);if(x!==0&&_(x),g!=null){let t=ib(g,0,$D(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}x>=p-1&&(ee.current=!0),v(e)});K.useImperativeHandle(y,()=>re,[re]),va({open:P,ref:c,onComplete(){P&&l?.(!0)}});let ie={open:P,transitionStatus:R,side:C,align:T};w(()=>{!B||!c.current||Object.keys(ne.current).length||(ne.current={top:B.style.top||`0`,left:B.style.left||`0`,right:B.style.right,height:B.style.height,bottom:B.style.bottom,minHeight:B.style.minHeight,maxHeight:B.style.maxHeight,marginTop:B.style.marginTop,marginBottom:B.style.marginBottom})},[c,B]),w(()=>{P||E||(te.current=!1,ee.current=!1,WD(B,ne.current))},[P,E,B,c]),w(()=>{let e=c.current;if(!P||!z||!B||!e||E&&!D||s.state.transitionStatus===`ending`)return;if(te.current=!0,e.style.removeProperty(`--transform-origin`),!E){H.request(()=>v(V||e));return}let t=iO(e);try{let t=g.current;t?.isConnected||(t=!$.hasSelectedValue(s.state)&&m.current?.isConnected?m.current:null);let n=p.current,r=f(B),i=r.getComputedStyle(B),a=r.getComputedStyle(e),o=io(z),c=eO(z),l=nO(z.getBoundingClientRect(),c),u=nO(B.getBoundingClientRect(),c),d=l.height,h=V||e,_=h.scrollHeight,y=parseFloat(a.borderBottomWidth),S=parseFloat(i.marginTop)||10,C=parseFloat(i.marginBottom)||10,w=parseFloat(i.minHeight)||100,T=QD(a),E=o.documentElement.clientHeight-S-C,D=o.documentElement.clientWidth,k=E-l.bottom+d,j,M=A===`rtl`?l.right-u.width:l.left,N=0;if(t&&n){let e=nO(n.getBoundingClientRect(),c);j=nO(t.getBoundingClientRect(),c),M=u.left+(A===`rtl`?e.right-j.right:e.left-j.left);let r=e.top-l.top+e.height/2;N=j.top-u.top+j.height/2-r}let P=k+N+C+y,F=Math.min(E,P),I=E-S-C,L=P-F,R=D-5;B.style.left=`${ib(M,5,R-u.width)}px`,B.style.height=`${F}px`,B.style.maxHeight=`none`,B.style.marginTop=`${S}px`,B.style.marginBottom=`${C}px`,e.style.height=`100%`;let te=$D(h),H=L>=te-1;H&&(F=Math.min(E,u.height)-(L-te));let re=l.top<20||l.bottom>E-20||Math.ceil(F)+1<Math.min(_,w),ie=(r.visualViewport?.scale??1)!==1&&Pa;if(re||ie){WD(B,ne.current),O(!1);return}let ae=Math.max(w,F);if(H){let e=Math.max(0,E-P);B.style.top=u.height>=I?`0`:`${e}px`,B.style.height=`${F}px`,h.scrollTop=$D(h)}else B.style.bottom=`0`,h.scrollTop=L;if(j){let t=u.top,n=u.height,r=j.top+j.height/2,i=ib(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(`--transform-origin`,`50% ${i}%`)}(ae===E||F>=T)&&(ee.current=!0),v(h),x&&s.state.selectedIndex===null&&s.state.activeIndex===null&&b.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,P,B,z,p,m,g,c,v,E,O,H,V,b,x,A,D]),K.useEffect(()=>{if(!E||!B||!P)return;let e=f(B);function t(e){d(!1,za(ho,e))}return Zi(e,`resize`,t)},[d,E,B,P]);let ae={...V?{role:`presentation`,"aria-orientation":void 0}:{role:`listbox`,"aria-multiselectable":_||void 0,id:`${N}-list`},onKeyDown(e){k&&Ni.has(e.key)&&e.stopPropagation()},onScroll(e){V||re(e.currentTarget)},...E&&{style:V?{height:`100%`}:GD},className:!V&&E?YD.className:void 0},oe=u(`div`,e,{ref:[t,c],state:ie,stateAttributesMapping:XD,props:[L,ae,ri(R),o]});return(0,q.jsxs)(K.Fragment,{children:[!M&&YD.getElement(j),(0,q.jsx)(no,{context:S,modal:!1,disabled:!I,openInteractionType:F,returnFocus:a,restoreFocus:!0,children:oe})]})});function QD(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function $D(e){return MD(e.scrollHeight,e.clientHeight)}function eO(e){return Xa.getScale(e)}function tO(e,t,n){return e/n[t]}function nO(e,t){return di({x:tO(e.x,`x`,t),y:tO(e.y,`y`,t),width:tO(e.width,`x`,t),height:tO(e.height,`y`,t)})}var rO=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function iO(e){let{style:t}=e,n={};for(let[e,r]of rO)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of rO){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var aO=K.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{store:o,scrollHandlerRef:s,multiple:c}=jD(),{alignItemWithTriggerActive:l}=UD(),d=G(o,$.hasScrollArrows),f=G(o,$.openMethod),p={id:`${G(o,$.id)}-list`,role:`listbox`,"aria-multiselectable":c||void 0,onScroll(e){s.current?.(e.currentTarget)},...l&&{style:GD},className:d&&f!==`touch`?YD.className:void 0},m=o.useStateSetter(`listElement`);return u(`div`,e,{ref:[t,m],props:[p,a]})}),oO=K.createContext(void 0);function sO(){let e=K.useContext(oO);if(!e)throw Error(s(57));return e}var cO=K.memo(K.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,d=K.useRef(null),f=ja({guess:!0,label:o,textRef:d}),{store:p,itemProps:m,setOpen:h,setValue:g,selectionRef:_,typingRef:v,valuesRef:y,multiple:b,selectedItemTextRef:x,disabled:S,readOnly:T}=jD(),E=S||s,D=G(p,$.isActive,f.index),O=G(p,$.open),k=G(p,$.isSelected,a),A=G(p,$.isSelectedByFocus,f.index),j=G(p,$.isItemEqualToValue),M=f.index,N=K.useRef(null);w(()=>{let e=y.current;return e[M]=a,()=>{delete e[M]}},[M,a,y]),w(()=>{let e=p.state.value,t=e;b&&Array.isArray(e)&&(t=e.length>0?e[e.length-1]:void 0),t!==void 0&&Ev(a,t,j)&&(p.set(`selectedIndex`,M),d.current&&(x.current=d.current))},[M,b,j,p,a,x]);let P=K.useRef(`mouse`),F=K.useRef(!1),{getButtonProps:I,buttonRef:L}=C({disabled:E,focusableWhenDisabled:!0,native:c,composite:!0}),R={disabled:E,selected:k,highlighted:D};function z(e){if(S||T)return;let t=p.state.value;if(b){let n=Array.isArray(t)?t:[],r=k?Av(n,a,j):[...n,a];g(r,za(Oa,e))}else g(a,za(Oa,e)),h(!1,za(Oa,e))}function B(){_.current.dragY=0}let V={role:`option`,"aria-selected":k,tabIndex:O&&D?0:-1,onKeyDown(e){p.set(`activeIndex`,M),e.key===` `&&v.current&&e.preventDefault()},onClick(e){let t=P.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&ra(e.nativeEvent)&&(n!==void 0||D),i=t&&!r&&!F.current;F.current=!1,!(E||i)&&z(e.nativeEvent)},onPointerEnter(e){P.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=_.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){P.current=e.pointerType,F.current=!0,B()},onMouseUp(){if(B(),E||P.current===`touch`||F.current)return;let e=!_.current.allowSelectedMouseUp&&k,t=!_.current.allowUnselectedMouseUp&&!k;e||t||(F.current=!0,N.current?.click(),F.current=!1)}},ee=u(`div`,e,{ref:[L,t,f.ref,N],state:R,props:[m,V,l,I]}),te=K.useMemo(()=>({selected:k,index:M,textRef:d,selectedByFocus:A}),[k,M,d,A]);return(0,q.jsx)(oO.Provider,{value:te,children:ee})})),lO=K.memo(K.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=sO(),{firstItemTextRef:a,selectedItemTextRef:o}=jD(),{render:s,className:c,style:l,...d}=e,f=K.useCallback(e=>{e&&(n===0&&(a.current=e),i&&(o.current=e))},[a,o,n,i]);return u(`div`,e,{ref:[f,t,r],props:d})})),uO=K.createContext(void 0);function dO(){let e=K.useContext(uO);if(e===void 0)throw Error(s(63));return e}var fO={...pc,checked(e){return e?{"data-checked":``}:{"data-unchecked":``}}},pO=K.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:a,"aria-labelledby":o,form:s,id:l,inputRef:d,name:f,nativeButton:p=!1,onCheckedChange:m,readOnly:h=!1,required:g=!1,disabled:v=!1,render:y,uncheckedValue:b,value:x,style:S,...T}=e,{clearErrors:E}=cc(),{state:D,setTouched:O,setDirty:k,validityData:A,setFilled:j,setFocused:M,validationMode:N,disabled:P,name:F,validation:I}=rc(),{labelId:L}=nc(),R=P||v,z=F??f,B=K.useRef(null),V=i(B,d,I.inputRef),ee=K.useRef(null),te=ha(),ne=tc({id:l,implicit:!1,controlRef:ee}),H=p?void 0:ne,[re,ie]=mc({controlled:n,default:!!a,name:`Switch`,state:`checked`});fc(ee,te,re,void 0,!R,f),w(()=>{B.current&&j(B.current.checked)},[j]),to(re,()=>{E(z),k(re!==A.initialValue),j(re),I.change(re)});let{getButtonProps:ae,buttonRef:oe}=C({disabled:R,native:p}),se=Fg(o,L,B,!p,H),ce={id:p?ne:te,role:`switch`,"aria-checked":re,"aria-readonly":h||void 0,"aria-required":g||void 0,"aria-labelledby":se,onFocus(){R||M(!0)},onBlur(){let e=B.current;!e||R||(O(!0),M(!1),N===`onBlur`&&I.commit(e.checked))},onClick(e){if(h||R)return;e.preventDefault();let t=B.current;t&&_(t,e)}},le={...I.getValidationProps(R),checked:re,disabled:R,form:s,id:H,name:z,required:g,style:z?Hi:Ei,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:V,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(h){e.preventDefault();return}let t=e.currentTarget.checked,n=za(ji,e.nativeEvent);m?.(t,n),!n.isCanceled&&ie(t)},onClick(e){e.stopPropagation()},onFocus(){ee.current?.focus()},...x===void 0?c:{value:x}},ue=K.useMemo(()=>({...D,checked:re,disabled:R,readOnly:h,required:g}),[D,re,R,h,g]),de=u(`span`,e,{state:ue,ref:[t,ee,oe],props:[ce,T,ae,e=>I.getValidationProps(R,e)],stateAttributesMapping:fO});return(0,q.jsxs)(uO.Provider,{value:ue,children:[de,!re&&z&&b!==void 0&&(0,q.jsx)(`input`,{type:`hidden`,form:s,name:z,value:b,disabled:R}),(0,q.jsx)(`input`,{...le,suppressHydrationWarning:!0})]})}),mO=K.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=dO();return u(`span`,e,{state:o,ref:t,stateAttributesMapping:fO,props:a})});function hO({className:e,...t}){return(0,q.jsx)(pO,{className:r(`inline-flex h-5 w-9 shrink-0 items-center rounded-full bg-input p-0.5 outline-none transition-colors data-checked:bg-primary data-disabled:cursor-not-allowed data-disabled:opacity-45 focus-visible:ring-2 focus-visible:ring-ring/40`,e),...t,children:(0,q.jsx)(mO,{className:`block size-4 rounded-full bg-white transition-transform data-checked:translate-x-4`})})}var gO={nightly:`Nightly`,stable:`Stable`},_O=yl.map(e=>({label:gO[e],value:e})),vO={settings:{checkAutomatically:!1,releaseChannel:`stable`},status:{_tag:`Unavailable`}};function yO({desktopUpdates:e,productVersion:t,updateLoadError:n,updateSnapshot:r}){let i=r??vO,[a,o]=(0,K.useState)(),[s,c]=(0,K.useState)(!1),l=e!==void 0,u=l&&r!==void 0&&n===void 0,d=i.status._tag===`Checking`||i.status._tag===`Downloading`||i.status._tag===`Ready`,f=u&&!s&&(i.status._tag===`Idle`||i.status._tag===`UpToDate`||i.status._tag===`Error`),p=u&&!s&&i.status._tag===`Ready`,m=async e=>{o(void 0),c(!0);try{await e()}catch(e){o(SO(e))}finally{c(!1)}},h=async e=>{o(void 0);try{await e()}catch(e){o(SO(e))}};return(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-4xl px-4 pt-10 pb-16 sm:px-8 sm:pt-12`,children:[(0,q.jsxs)(`header`,{children:[(0,q.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`General`}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Application details.`})]}),(0,q.jsxs)(`section`,{"aria-labelledby":`about-settings`,className:`mt-10`,children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold`,id:`about-settings`,children:`About`}),(0,q.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,q.jsx)(uD,{description:`The version currently running.`,descriptionId:`version-description`,title:`Version`,children:(0,q.jsx)(`span`,{className:`shrink-0 text-sm text-muted-foreground`,children:t})}),(0,q.jsx)(uD,{description:u?`Stable follows full releases. Nightly follows nightly builds.`:l?`Loading release channel settings.`:`Release channels are available in the Electron app.`,descriptionId:`release-channel-description`,title:`Release channel`,children:(0,q.jsxs)(PD,{disabled:!u||s||d,items:_O,onValueChange:t=>{t!==null&&e!==void 0&&m(()=>e.selectReleaseChannel(t))},value:i.settings.releaseChannel,children:[(0,q.jsxs)(LD,{"aria-describedby":`release-channel-description`,"aria-label":`Release channel`,className:`flex h-8 w-40 shrink-0 items-center justify-between rounded-md border border-input bg-input/30 px-3 text-sm text-foreground outline-none hover:bg-accent data-disabled:cursor-not-allowed data-disabled:opacity-45 data-pressed:bg-accent focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30`,children:[(0,q.jsx)(zD,{}),(0,q.jsx)(BD,{children:(0,q.jsx)(Us,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`})})]}),(0,q.jsx)(VD,{children:(0,q.jsx)(qD,{align:`end`,alignItemWithTrigger:!1,className:`z-50 outline-none`,sideOffset:4,children:(0,q.jsx)(ZD,{className:`w-[var(--anchor-width)] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg outline-none`,children:(0,q.jsx)(aO,{children:_O.map(e=>(0,q.jsx)(cO,{className:`flex h-8 cursor-default items-center rounded-sm px-2 text-sm outline-none select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground`,value:e.value,children:(0,q.jsx)(lO,{children:e.label})},e.value))})})})})]})}),(0,q.jsx)(uD,{description:u?`Check the selected channel when Rebase starts.`:l?`Loading automatic update settings.`:`Automatic checks are available in the Electron app.`,descriptionId:`automatic-update-description`,title:`Check automatically`,children:(0,q.jsx)(hO,{"aria-describedby":`automatic-update-description`,"aria-label":`Check automatically`,checked:i.settings.checkAutomatically,disabled:!u||s,onCheckedChange:t=>{e!==void 0&&m(()=>e.setCheckAutomatically(t))}})}),(0,q.jsx)(uD,{description:xO(i,l,u,a??n),descriptionId:`updates-description`,liveDescription:!0,title:`Updates`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 md:shrink-0`,children:[(0,q.jsx)(T,{"aria-describedby":`updates-description`,disabled:!f,onClick:()=>{e!==void 0&&h(()=>e.checkForUpdates())},size:`sm`,variant:`outline`,children:bO(i)}),(0,q.jsx)(T,{"aria-describedby":`updates-description`,disabled:!p,onClick:()=>{e!==void 0&&h(()=>e.installUpdate())},size:`sm`,children:`Update now`})]})})]})]})]})}function bO(e){return e.status._tag===`Checking`?`Checking...`:e.status._tag===`Downloading`?`Downloading ${e.status.percent}%`:e.status._tag===`Ready`||e.status._tag===`UpToDate`||e.status._tag===`Error`?`Check again`:`Check for updates`}function xO(e,t,n,r){if(r!==void 0)return r;if(!t)return`Update checks are available in the Electron app.`;if(!n)return`Loading update settings.`;switch(e.status._tag){case`Checking`:return`Checking the selected release channel.`;case`Downloading`:return`Downloading version ${e.status.version}.`;case`Ready`:return`Version ${e.status.version} is ready to install.`;case`UpToDate`:return`This is the latest version on the selected channel.`;case`Error`:return`The update check failed. ${e.status.message}`;case`Unavailable`:return`Updates are unavailable for this installation.`;case`Idle`:return`Check the selected channel for a newer version.`}}function SO(e){return e instanceof Error?e.message:`The update action failed.`}function CO({diagnostics:e}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Browser storage`}),(0,q.jsx)(`dd`,{children:e.persistent?`Persistent`:`Best effort`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Origin usage / quota`}),(0,q.jsxs)(`dd`,{children:[SD(e.usageBytes),` /`,` `,SD(e.quotaBytes)]})]})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Cache sizes are estimates. Origin usage includes other app data. Open repositories are protected from automatic eviction.`}),(0,q.jsxs)(`div`,{className:`max-h-64 overflow-auto rounded-md border border-border`,children:[(0,q.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,q.jsx)(`caption`,{className:`sr-only`,children:`Repository history caches`}),(0,q.jsx)(`thead`,{className:`sticky top-0 bg-popover text-muted-foreground`,children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Repository`}),(0,q.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`History`}),(0,q.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Size`})]})}),(0,q.jsx)(`tbody`,{children:e.caches.map(e=>(0,q.jsxs)(`tr`,{className:`border-t border-border align-top`,children:[(0,q.jsxs)(`td`,{className:`max-w-64 px-3 py-2`,children:[(0,q.jsx)(`div`,{className:`break-all font-medium`,children:e.repositoryId}),(0,q.jsxs)(`div`,{className:`mt-1 break-all text-muted-foreground`,children:[`Environment: `,e.environmentId]}),(0,q.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:`Last opened ${new Date(e.lastOpenedAt).toLocaleString()}`}),e.open&&(0,q.jsx)(`div`,{className:`mt-1`,children:`Open · Protected`})]}),(0,q.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,q.jsx)(`div`,{className:`capitalize`,children:e.state}),(0,q.jsxs)(`div`,{className:`mt-1 whitespace-nowrap text-muted-foreground`,children:[e.commitCount.toLocaleString(),` commits`]})]}),(0,q.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right tabular-nums`,children:SD(e.estimatedBytes)})]},`${e.environmentId}/${e.repositoryId}`))})]}),e.caches.length===0&&(0,q.jsx)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:`No history caches.`})]})]})}function wO(){let[e,t]=(0,K.useState)(),[n,r]=(0,K.useState)(),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(),u=(0,K.useRef)(void 0),d=yn(),f=(0,K.useCallback)(async e=>{u.current?.abort();let n=new AbortController;u.current=n,a(!0),r(void 0),l(void 0);try{t(await TO(e,n.signal)),e===`clear`&&(ms(d),l(`All history caches cleared. Rebuild or reopen a repository to load history.`))}catch{if(n.signal.aborted)return;r(`History storage could not be updated. Try again.`)}a(!1)},[d]);return(0,K.useEffect)(()=>(f(`inspect`),()=>u.current?.abort()),[f]),(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-4xl px-4 pt-10 pb-16 sm:px-8 sm:pt-12`,children:[(0,q.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`History storage`}),(0,q.jsxs)(`div`,{className:`mt-8 space-y-4`,"aria-busy":i,children:[e===void 0?null:(0,q.jsx)(CO,{diagnostics:e}),i?(0,q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Updating history storage…`}):null,n===void 0?null:(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:n}),c===void 0?null:(0,q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:c}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(T,{size:`sm`,variant:`destructive`,disabled:i||e===void 0||e.caches.length===0,onClick:()=>s(!0),children:`Clear all caches`}),(0,q.jsx)(T,{size:`sm`,variant:`outline`,disabled:i,onClick:()=>void f(`inspect`),children:`Refresh`})]})]}),(0,q.jsx)(hD,{open:o,onOpenChange:s,children:(0,q.jsxs)(gD,{children:[(0,q.jsx)(_D,{children:`Clear all caches?`}),(0,q.jsx)(vD,{children:`Clear cached history for every repository in this client, including open repositories. Git files stay on disk. Rebuild or reopen repositories to load history.`}),(0,q.jsxs)(yD,{children:[(0,q.jsx)(bD,{children:`Cancel`}),(0,q.jsx)(xD,{onClick:()=>void f(`clear`),children:`Clear all caches`})]})]})})]})}async function TO(e,t){let n=sC();try{return await n.ask({_tag:`Storage`,action:e===`clear`?`clear-all`:`inspect`},t)}finally{n.close()}}var EO=[{id:`general`,label:`General`,icon:Ho,Content:yO},{id:`history-storage`,label:`History storage`,icon:Oo,Content:wO}];function DO({closeSettings:e,section:t,selectSection:n}){let[r,i]=(0,K.useState)(``),a=EO.filter(({label:e})=>e.toLocaleLowerCase().includes(r.trim().toLocaleLowerCase()));return(0,q.jsxs)(`nav`,{"aria-label":`Settings`,className:`flex h-full w-48 shrink-0 flex-col overflow-hidden border-sidebar-border/50 border-r bg-sidebar text-sidebar-foreground md:w-64`,children:[(0,q.jsx)(`div`,{className:`flex h-11 shrink-0 items-center px-4`,children:(0,q.jsx)(`h1`,{className:`text-base font-semibold text-sidebar-accent-foreground`,children:`Settings`})}),(0,q.jsxs)(`div`,{className:`relative mx-3 mt-3`,children:[(0,q.jsx)(Uh,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,q.jsx)(oc,{"aria-label":`Search settings`,className:`pl-9`,onChange:e=>i(e.target.value),placeholder:`Search settings...`,value:r})]}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pt-3`,children:[a.map(e=>{let r=e.icon,i=e.id===t;return(0,q.jsxs)(`button`,{"aria-current":i?`page`:void 0,className:`flex h-10 w-full items-center gap-3 rounded-lg px-3 text-left text-sm text-muted-foreground outline-none hover:bg-sidebar-accent hover:text-sidebar-accent-foreground aria-current-page:bg-sidebar-accent aria-current-page:text-sidebar-accent-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring/40`,onClick:()=>n(e.id),type:`button`,children:[(0,q.jsx)(r,{"aria-hidden":`true`,className:`size-4.5`}),e.label]},e.id)}),a.length===0?(0,q.jsx)(`p`,{className:`px-3 py-2 text-sm text-muted-foreground`,children:`No settings found`}):null]}),(0,q.jsx)(`div`,{className:`shrink-0 px-3 pb-2`,children:(0,q.jsxs)(T,{className:`h-10 w-full justify-start px-2 text-muted-foreground`,onClick:e,variant:`ghost`,children:[(0,q.jsx)(_h,{"aria-hidden":`true`,"data-icon":`inline-start`}),`Back`]})})]})}function OO({closeSettings:e,desktopUpdates:t,productVersion:n}){let[r,i]=(0,K.useState)(`general`),a=EO.find(({id:e})=>e===r)?.Content??EO[0].Content,[o,s]=(0,K.useState)(),[c,l]=(0,K.useState)();return(0,K.useEffect)(()=>{if(t===void 0){s(void 0),l(void 0);return}let e=!0,n=!1;l(void 0);let r=t.subscribe(t=>{e&&(n=!0,l(void 0),s(t))});return t.getSnapshot().then(t=>{e&&!n&&(l(void 0),s(t))}).catch(t=>{e&&!n&&l(t instanceof Error?t.message:`Update settings could not be loaded.`)}),()=>{e=!1,r()}},[t]),(0,q.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,q.jsx)(DO,{closeSettings:e,section:r,selectSection:i}),(0,q.jsx)(`main`,{"aria-label":`Settings content`,className:`min-w-0 flex-1 overflow-y-auto rounded-none bg-repository`,children:(0,q.jsx)(a,{desktopUpdates:t,productVersion:n,updateLoadError:c,updateSnapshot:o})})]})}function kO({session:e,...t}){return(0,q.jsx)(PO,{session:e,children:(0,q.jsx)(AO,{...t})})}function AO({desktopUpdates:e,productVersion:t,repositoryFilesystem:n}){let{navigation:r,navigate:i}=Jm(),{openRepository:a,showRepository:o}=jO(i),s=Xm(r.projects,Vn().status),c=lh(r.repositorySettingsId)?.id;return(0,q.jsx)(uh,{navigation:r,navigate:i,children:(0,q.jsx)(NO,{navigation:r,visible:!r.settingsOpen&&c===void 0,children:(0,q.jsx)(Pm,{onSidebarCollapsedChange:e=>i({type:`collapse-sidebar`,collapsed:e}),sidebar:e=>(0,q.jsx)(iD,{closeRepository:(e,{id:t})=>i({type:`close-repository`,repositoryId:t}),collapse:e.collapse,expand:e.expand,navigation:s,openProject:()=>i({type:`show-open-project`}),openSettings:()=>i({type:`show-settings`,open:!0}),openRepositorySettings:(e,{id:t})=>i({type:`show-repository-settings`,repositoryId:t}),selectRepository:(e,t)=>a(t),toggleEnvironment:e=>i({type:`toggle-environment`,environmentId:e})}),repositorySettings:c===void 0?void 0:(0,q.jsx)(MO,{repositoryId:c,reveal:n===void 0?void 0:e=>n.revealRepository(e),onRemoved:()=>i({type:`close-repository`,repositoryId:c})}),settings:r.settingsOpen?(0,q.jsx)(OO,{closeSettings:()=>i({type:`show-settings`,open:!1}),desktopUpdates:e,productVersion:t}):void 0,children:s.workspaceView===`open-project`?(0,q.jsx)($E,{onOpenRepository:a,onRepositoryRemembered:o,onOpenSettings:e=>i({type:`show-repository-settings`,repositoryId:e})},r.openProjectRequest):(0,q.jsx)(xT,{})})})})}function jO(e){let{status:t}=Vn(),{run:n}=Xr(Jf.recordOpened,{answers:oh}),r=t.availability===`available`,i=(0,K.useCallback)(t=>e({type:`open-repository`,repository:t}),[e]);return{openRepository:(0,K.useCallback)(e=>{r&&(i(e),n({repositoryId:e.id}))},[r,n,i]),showRepository:i}}function MO({repositoryId:e,reveal:t,onRemoved:n}){let{environmentId:r}=Vn(),i=lh(e),a=cC(r===void 0||i===void 0?void 0:{environmentId:r,repositoryId:i.id,logicalRepositoryId:i.logicalRepositoryId??i.id});return(0,q.jsx)(DD,{repositoryId:e,history:a,reveal:t,onRemoved:n},JSON.stringify([r,e]))}function NO({navigation:e,visible:t,children:n}){let{environmentId:r,connected:i,writable:a}=Vn(),o=(0,K.useMemo)(()=>({environmentId:r,connected:i,writable:a,visible:t}),[r,i,a,t]),{environments:s}=e.projects,c=(0,K.useMemo)(()=>s.flatMap(({repositories:e})=>e.map(({id:e})=>e)),[s]);return(0,q.jsx)(yT.Sessions,{environment:o,repositoryIds:c,children:n})}function PO({session:e,children:t}){let n=fg(e),r=FO(n),i=n._tag===`Connected`,a=i?n.requests:mm,o=i,s=i,c=(0,K.useMemo)(()=>Fm(n),[n]),l=(0,K.useMemo)(()=>({environmentId:r,requests:a,connected:i,readable:o,writable:s,status:c}),[r,a,i,o,s,c]);return(0,q.jsx)(tr,{environment:l,children:t})}function FO(e){let t=(0,K.useRef)(void 0);return e._tag===`Connected`&&(t.current=e.environmentId),e._tag===`Reconnecting`?e.environmentId??t.current:t.current}function IO({children:e}){let[t,n]=(0,K.useState)(null);return(0,q.jsx)($y,{timeout:0,limit:3,children:(0,q.jsxs)(Fs.Provider,{value:t,children:[e,(0,q.jsx)(LO,{persistentOutlet:n})]})})}function LO({persistentOutlet:e}){let{toasts:t}=Cs();return(0,q.jsx)(Sb,{children:(0,q.jsxs)(tb,{className:`pointer-events-none fixed top-14 right-4 z-100 flex w-[calc(100%-2rem)] max-w-90 flex-col gap-2 outline-none`,children:[(0,q.jsx)(`div`,{ref:e,className:`empty:hidden`}),t.map(e=>(0,q.jsx)(pb,{toast:e,className:`pointer-events-auto shrink-0 rounded-lg border border-border bg-popover text-popover-foreground shadow-lg outline-none data-ending-style:hidden data-limited:hidden`,children:(0,q.jsxs)(mb,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,q.jsx)(hh,{"aria-hidden":`true`,className:`size-4 shrink-0 text-status-connecting`}),(0,q.jsx)(yb,{className:`min-w-0 flex-1 wrap-anywhere text-sm font-medium`}),(0,q.jsx)(bb,{"aria-hidden":!1,"aria-label":`Dismiss notification`,render:(0,q.jsx)(T,{size:`icon-xs`,variant:`ghost`}),children:(0,q.jsx)(Gh,{"aria-hidden":`true`})})]})},e.id))]})})}function RO(){}function zO(e,{interval:t=1e3,onError:n=RO}={}){if(typeof e!=`function`)throw Error(`argument is not function.`);let r=0,i=null,a=!1,o=!1;return async(...s)=>{if(i=s,!o){for(o=!0;a;)await new Promise(e=>oe.setTimeout(e,t));for(;Date.now()<r;)await new Promise(e=>oe.setTimeout(e,r-Date.now()));o=!1,a=!0;try{await e(...i)}catch(e){try{n(e)}catch{}}r=Date.now()+t,a=!1}}}var BO=({storage:e,key:t=`REACT_QUERY_OFFLINE_CACHE`,throttleTime:n=1e3,serialize:r=JSON.stringify,deserialize:i=JSON.parse,retry:a})=>{if(e){let o=async n=>{try{let i=await r(n);await e.setItem(t,i);return}catch(e){return e}};return{persistClient:zO(async e=>{let t=e,n=await o(t),r=0;for(;n&&t;)r++,t=await a?.({persistedClient:t,error:n,errorCount:r}),t&&(n=await o(t))},{interval:n}),restoreClient:async()=>{let n=await e.getItem(t);if(n)return await i(n)},removeClient:()=>e.removeItem(t)}}return{persistClient:RO,restoreClient:()=>Promise.resolve(void 0),removeClient:RO}};function VO(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function HO(e,t){let n,r=()=>{if(n)return n;let r=indexedDB.open(e);return r.onupgradeneeded=()=>r.result.createObjectStore(t),n=VO(r),n.then(e=>{e.onclose=()=>n=void 0},()=>{n=void 0}),n};return(e,n)=>r().then(r=>n(r.transaction(t,e).objectStore(t)))}var UO;function WO(){return UO||=HO(`keyval-store`,`keyval`),UO}function GO(e,t=WO()){return t(`readonly`,t=>VO(t.get(e)))}function KO(e,t,n=WO()){return n(`readwrite`,n=>(n.put(t,e),VO(n.transaction)))}function qO(e,t=WO()){return t(`readwrite`,t=>(t.delete(e),VO(t.transaction)))}function JO(){let e=HO(`rebase-environment-queries`,`clients`);return{persister:ZO(BO({key:`environment-queries`,storage:{getItem:t=>GO(t,e),setItem:(t,n)=>KO(t,n,e),removeItem:t=>qO(t,e)},deserialize:e=>XO(JSON.parse(e))})),buster:`protocol-5`,maxAge:1/0,dehydrateOptions:{shouldDehydrateQuery:YO},hydrateOptions:{defaultOptions:{queries:{gcTime:1/0}}}}}function YO(e){return e.meta?.persist===!0&&e.state.data!==void 0}function XO(e){return{...e,clientState:{...e.clientState,queries:e.clientState.queries.map(e=>({...e,state:{...e.state,status:`success`,dataUpdatedAt:0,error:null,fetchFailureCount:0,fetchFailureReason:null,dataUpdateCount:0,errorUpdateCount:0,isInvalidated:!0}}))}}}function ZO(e){let t;return{persistClient:n=>{let r=ek(n);if(r!==t)return t=r,e.persistClient(n)},restoreClient:e.restoreClient,removeClient:()=>(t=void 0,e.removeClient())}}var QO=new WeakMap,$O=0;function ek(e){return e.clientState.queries.map(({queryHash:e,state:t})=>`${e}@${tk(t.data)}`).join(`
15
- `)}function tk(e){if(typeof e!=`object`||!e)return JSON.stringify(e);let t=QO.get(e);return t===void 0?($O+=1,QO.set(e,$O),$O):t}var nk=document.getElementById(`root`);if(!(nk instanceof HTMLElement))throw Error(`The web application requires an element with id "root".`);var rk=`0.0.2-nightly.20260929.133`,ik=jm(),ak=Cn(),ok=Em(ik,{onConnect:oC,invalidation:ya(ak)});ok.start();var sk=JO();(0,vl.createRoot)(nk).render((0,q.jsx)(K.StrictMode,{children:(0,q.jsx)(Fc,{client:ak,persistOptions:sk,children:(0,q.jsx)(IO,{children:(0,q.jsx)(kO,{desktopUpdates:ik?.updates,productVersion:rk,repositoryFilesystem:ik,session:ok})})})}));
15
+ `)}function tk(e){if(typeof e!=`object`||!e)return JSON.stringify(e);let t=QO.get(e);return t===void 0?($O+=1,QO.set(e,$O),$O):t}var nk=document.getElementById(`root`);if(!(nk instanceof HTMLElement))throw Error(`The web application requires an element with id "root".`);var rk=`0.0.2`,ik=jm(),ak=Cn(),ok=Em(ik,{onConnect:oC,invalidation:ya(ak)});ok.start();var sk=JO();(0,vl.createRoot)(nk).render((0,q.jsx)(K.StrictMode,{children:(0,q.jsx)(Fc,{client:ak,persistOptions:sk,children:(0,q.jsx)(IO,{children:(0,q.jsx)(kO,{desktopUpdates:ik?.updates,productVersion:rk,repositoryFilesystem:ik,session:ok})})})}));
@@ -6,7 +6,7 @@
6
6
  <meta name="theme-color" content="#050506" />
7
7
  <title>Rebase</title>
8
8
  <link rel="icon" type="image/svg+xml" href="./favicon.svg" />
9
- <script type="module" crossorigin src="./assets/index-2Thy_En8.js"></script>
9
+ <script type="module" crossorigin src="./assets/index-DMxGcYbd.js"></script>
10
10
  <link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-hePW80VL.js">
11
11
  <link rel="modulepreload" crossorigin href="./assets/button-ClFEJHGI.js">
12
12
  <link rel="modulepreload" crossorigin href="./assets/IconChevronRight-Ct8_bzuc.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rebase-git",
3
- "version": "0.0.2-nightly.20260929.133",
3
+ "version": "0.0.2",
4
4
  "description": "A fast local Git client for the browser and desktop.",
5
5
  "author": "Alexandru Ion <ionalexandru99@users.noreply.github.com>",
6
6
  "license": "Apache-2.0",