@treeport/treeport 0.2.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bin/treeport.mjs +3 -1
- package/dist/{loopback-4XVZbAD1.js → loopback-D7k_J_Wl.js} +16 -11
- package/dist/node/cli/index.js +1257 -104
- package/dist/node/server/core/launcher.js +19 -2
- package/dist/node/server/index.js +469 -377
- package/dist/{shell-integration-7aBNr-p0.js → shell-integration-Be_c91lw.js} +17 -15
- package/dist/web/assets/{index-CUy0IkGL.js → index-DCtptjcH.js} +5 -5
- package/dist/web/assets/index-Wj0w0nWP.css +2 -0
- package/dist/web/index.html +2 -2
- package/dist/web/manifest.webmanifest +2 -2
- package/package.json +4 -4
- package/skills/treeport/SKILL.md +20 -20
- package/dist/web/assets/index-0q5frbNy.css +0 -2
|
@@ -46,7 +46,7 @@ Error generating stack: `+e.message+`
|
|
|
46
46
|
`},Lm=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Rm=function(){R.useEffect(function(){return document.body.setAttribute(Fm,(Lm()+1).toString()),function(){var e=Lm()-1;e<=0?document.body.removeAttribute(Fm):document.body.setAttribute(Fm,e.toString())}},[])},zm=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Rm();var a=R.useMemo(function(){return Nm(i)},[i]);return R.createElement(Pm,{styles:Im(a,!t,i,n?``:`!important`)})},Bm=!1;if(typeof window<`u`)try{var Vm=Object.defineProperty({},"passive",{get:function(){return Bm=!0,!0}});window.addEventListener(`test`,Vm,Vm),window.removeEventListener(`test`,Vm,Vm)}catch{Bm=!1}var Hm=Bm?{passive:!1}:!1,Um=function(e){return e.tagName===`TEXTAREA`},Wm=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Um(e)&&n[t]===`visible`)},Gm=function(e){return Wm(e,`overflowY`)},Km=function(e){return Wm(e,`overflowX`)},qm=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Xm(e,r)){var i=Zm(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Jm=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Ym=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Xm=function(e,t){return e===`v`?Gm(t):Km(t)},Zm=function(e,t){return e===`v`?Jm(t):Ym(t)},Qm=function(e,t){return e===`h`&&t===`rtl`?-1:1},$m=function(e,t,n,r,i){var a=Qm(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Zm(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Xm(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},eh=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},th=function(e){return[e.deltaX,e.deltaY]},nh=function(e){return e&&`current`in e?e.current:e},rh=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ih=function(e){return`
|
|
47
47
|
.block-interactivity-${e} {pointer-events: none;}
|
|
48
48
|
.allow-interactivity-${e} {pointer-events: all;}
|
|
49
|
-
`},ah=0,oh=[];function sh(e){var t=R.useRef([]),n=R.useRef([0,0]),r=R.useRef(),i=R.useState(ah++)[0],a=R.useState(km)[0],o=R.useRef(e);R.useEffect(function(){o.current=e},[e]),R.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=im([e.lockRef.current],(e.shards||[]).map(nh),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=R.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=eh(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=qm(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=qm(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return $m(h,t,e,h===`h`?s:c,!0)},[]),c=R.useCallback(function(e){var n=e;if(!(!oh.length||oh[oh.length-1]!==a)){var r=`deltaY`in n?th(n):eh(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&rh(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(nh).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=R.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ch(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=R.useCallback(function(e){n.current=eh(e),r.current=void 0},[]),d=R.useCallback(function(t){l(t.type,th(t),t.target,s(t,e.lockRef.current))},[]),f=R.useCallback(function(t){l(t.type,eh(t),t.target,s(t,e.lockRef.current))},[]);R.useEffect(function(){return oh.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Hm),document.addEventListener(`touchmove`,c,Hm),document.addEventListener(`touchstart`,u,Hm),function(){oh=oh.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Hm),document.removeEventListener(`touchmove`,c,Hm),document.removeEventListener(`touchstart`,u,Hm)}},[]);var p=e.removeScrollBar,m=e.inert;return R.createElement(R.Fragment,null,m?R.createElement(a,{styles:ih(i)}):null,p?R.createElement(zm,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ch(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var lh=vm(ym,sh),uh=R.forwardRef(function(e,t){return R.createElement(xm,nm({},e,{ref:t,sideCar:lh}))});uh.classNames=xm.classNames;var dh=`Popover`,[fh,ph]=oo(dh,[al]),mh=al(),[hh,gh]=fh(dh),_h=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=mh(t),c=R.useRef(null),[l,u]=R.useState(!1),[d,f]=Fl({prop:r,defaultProp:i??!1,onChange:a,caller:dh});return(0,z.jsx)(xl,{...s,children:(0,z.jsx)(hh,{scope:t,contentId:Vo(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:R.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:R.useCallback(()=>u(!0),[]),onCustomAnchorRemove:R.useCallback(()=>u(!1),[]),modal:o,children:n})})};_h.displayName=dh;var vh=`PopoverAnchor`,yh=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=gh(vh,n),a=mh(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return R.useEffect(()=>(o(),()=>s()),[o,s]),(0,z.jsx)(Sl,{...a,...r,ref:t})});yh.displayName=vh;var bh=`PopoverTrigger`,xh=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=gh(bh,n),a=mh(n),o=ao(t,i.triggerRef),s=(0,z.jsx)(xo.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Ih(i.open),...r,ref:o,onClick:no(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,z.jsx)(Sl,{asChild:!0,...a,children:s})});xh.displayName=bh;var Sh=`PopoverPortal`,[Ch,wh]=fh(Sh,{forceMount:void 0}),Th=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=gh(Sh,t);return(0,z.jsx)(Ch,{scope:t,forceMount:n,children:(0,z.jsx)(Ol,{present:n||a.open,children:(0,z.jsx)(El,{asChild:!0,container:i,children:r})})})};Th.displayName=Sh;var Eh=`PopoverContent`,Dh=R.forwardRef((e,t)=>{let n=wh(Eh,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=gh(Eh,e.__scopePopover);return(0,z.jsx)(Ol,{present:r||a.open,children:a.modal?(0,z.jsx)(kh,{...i,ref:t}):(0,z.jsx)(Ah,{...i,ref:t})})});Dh.displayName=Eh;var Oh=co(`PopoverContent.RemoveScroll`),kh=R.forwardRef((e,t)=>{let n=gh(Eh,e.__scopePopover),r=R.useRef(null),i=ao(t,r),a=R.useRef(!1);return R.useEffect(()=>{let e=r.current;if(e)return tm(e)},[]),(0,z.jsx)(uh,{as:Oh,allowPinchZoom:!0,children:(0,z.jsx)(jh,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:no(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:no(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:no(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),Ah=R.forwardRef((e,t)=>{let n=gh(Eh,e.__scopePopover),r=R.useRef(!1),i=R.useRef(!1);return(0,z.jsx)(jh,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),jh=R.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=gh(Eh,n),p=mh(n);return kp(),(0,z.jsx)(Fp,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,z.jsx)(Ao,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,z.jsx)(Cl,{"data-state":Ih(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),Mh=`PopoverClose`,Nh=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=gh(Mh,n);return(0,z.jsx)(xo.button,{type:`button`,...r,ref:t,onClick:no(e.onClick,()=>i.onOpenChange(!1))})});Nh.displayName=Mh;var Ph=`PopoverArrow`,Fh=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=mh(n);return(0,z.jsx)(wl,{...i,...r,ref:t})});Fh.displayName=Ph;function Ih(e){return e?`open`:`closed`}var Lh=_h,Rh=xh,zh=Th,Bh=Dh;function Vh(e){return(0,z.jsx)(Lh,{...e})}function Hh(e){return(0,z.jsx)(Rh,{...e})}function Uh({className:e,align:t=`start`,sideOffset:n=6,portalled:r=!0,...i}){let a=(0,z.jsx)(Bh,{align:t,sideOffset:n,className:W(`z-100 w-52 rounded-lg bg-zinc-900 p-3 text-zinc-200 shadow-xl ring-1 ring-white/10 outline-none`,e),...i});return r?(0,z.jsx)(zh,{children:a}):a}var Wh=(0,R.createRef)();function Gh(e){if(!Wh.current)throw Error(`ForceSpecificCursor is not mounted`);Wh.current.style.cursor=e,Wh.current.style.pointerEvents=`auto`}function Kh(){if(!Wh.current)throw Error(`ForceSpecificCursor is not mounted`);Wh.current.style.cursor=``,Wh.current.style.pointerEvents=`none`}function qh(){return(0,z.jsx)(`div`,{ref:Wh,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0`,style:{zIndex:2147483647}})}var Jh=3,Yh=450,Xh=550,Zh=10;function Qh(e){let t=e.value===null?``:`, ${e.value}% complete`;return e.state===`error`?`progress error${t}`:e.state===`paused`?`progress paused${t}`:e.value===null?`working`:`${e.value}% complete`}function $h(e,t=!1){if(e.type!==`keydown`||e.isComposing||e.ctrlKey)return null;if(e.key===`Enter`&&e.shiftKey&&!e.altKey&&!e.metaKey)return`\x1B[13;2u`;if(e.altKey&&!e.metaKey&&!e.shiftKey){if(eg()){if(e.key===`ArrowLeft`)return`\x1Bb`;if(e.key===`ArrowRight`)return`\x1Bf`}else{let t={ArrowUp:`A`,ArrowDown:`B`,ArrowRight:`C`,ArrowLeft:`D`}[e.key];if(t)return`\u001b[1;5${t}`}return null}if(!e.metaKey||e.altKey||e.shiftKey)return null;let n=t?`\x1BO`:`\x1B[`;return e.key===`ArrowLeft`?`${n}H`:e.key===`ArrowRight`?`${n}F`:null}function eg(){return typeof navigator<`u`&&/Mac|iPhone|iPad|iPod/.test(navigator.platform)}function tg(e,t){if(eg()?!e.metaKey:!e.ctrlKey)return;let n;try{n=new URL(t)}catch{return}if(n.protocol===`file:`){window.treeportDesktop?.openFileUrl(t).catch(()=>void 0);return}(n.protocol===`http:`||n.protocol===`https:`)&&window.open(t,`_blank`,`noopener,noreferrer`)}function ng(e,t){!t.element?.classList.contains(`enable-mouse-events`)||e.button!==0||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||Object.defineProperty(e,eg()?`altKey`:`shiftKey`,{configurable:!0,value:!0})}var rg=50,ig=3;function ag(e,t,n){let r=null,i=null,a=null,o,s=(e,n)=>{let r=(t.element?.querySelector(`.xterm-screen`))?.getBoundingClientRect();return!r?.width||!r.height?null:{column:Math.max(1,Math.min(t.cols,Math.floor((e-r.left)/r.width*t.cols)+1)),row:Math.max(1,Math.min(t.rows,Math.floor((n-r.top)/r.height*t.rows)+1)),bounds:r}},c=()=>{a!==null&&(window.clearInterval(a),a=null)};function l(){if(!i)return;let u=s(i.clientX,i.clientY);if(!u)return;let f=i.clientY<u.bounds.top||i.clientY>u.bounds.bottom,p=i.clientX<u.bounds.left||i.clientX>u.bounds.right,m=f&&!p;if(m||c(),i.tmux)n.canInput()&&n.sendInput(`\u001b[<32;${u.column};${u.row}M`);else{if(Math.hypot(i.clientX-i.startClientX,i.clientY-i.startClientY)<ig||!n.canInput())return;n.sendInput(`${n.selectionStartSequence}\u001b[<0;${i.startColumn};${i.startRow}M\u001b[<32;${i.startColumn};${i.startRow}M\u001b[<32;${u.column};${u.row}M`),t.clearSelection(),r!==null&&e.setPointerCapture(r),i.tmux=!0,o??=window.treeportDesktop?.onTerminalSelectionRelease(d),window.treeportDesktop?.setTerminalSelectionActive(!0),n.onTmuxSelectionStart()}m&&a===null&&(a=window.setInterval(l,rg))}let u=()=>{let t=r;r=null,t!==null&&e.hasPointerCapture(t)&&e.releasePointerCapture(t)},d=()=>{if(!i){u();return}let e=i.tmux;if(e&&n.canInput()){let e=s(i.clientX,i.clientY);if(e){let r=e.row===1?Math.min(2,t.rows):e.row===t.rows?Math.max(1,t.rows-1):e.row;n.onTmuxSelectionFinish(),n.sendInput(`${n.selectionStopSequence}\u001b[<32;${e.column};${r}M\u001b[<0;${e.column};${r}m`)}}c(),i=null,Kh(),e&&window.treeportDesktop?.setTerminalSelectionActive(!1),u(),document.removeEventListener(`mousemove`,f,!0),document.removeEventListener(`mouseup`,p,!0),window.removeEventListener(`blur`,_)},f=e=>{if(i){if(!(e.buttons&1)){d();return}i.clientX=e.clientX,i.clientY=e.clientY,l()}},p=()=>d(),m=e=>{e.isPrimary&&e.button===0&&(d(),r=e.pointerId)},h=()=>d(),g=()=>d(),_=()=>d();return e.addEventListener(`pointerdown`,m,!0),e.addEventListener(`pointerup`,h,!0),e.addEventListener(`pointercancel`,h,!0),e.addEventListener(`lostpointercapture`,g,!0),e.addEventListener(`mousedown`,e=>{n.requestControl(),ng(e,t);let r=s(e.clientX,e.clientY);e.button!==0||e.ctrlKey||e.metaKey||!r||e.clientX<r.bounds.left||e.clientX>r.bounds.right||e.clientY<r.bounds.top||e.clientY>r.bounds.bottom||(n.onSelectionStart(),Gh(`text`),i={startColumn:r.column,startRow:r.row,startClientX:e.clientX,startClientY:e.clientY,clientX:e.clientX,clientY:e.clientY,tmux:!1},document.addEventListener(`mousemove`,f,!0),document.addEventListener(`mouseup`,p,!0),window.addEventListener(`blur`,_))},!0),()=>{i?.tmux&&n.canInput()&&n.onTmuxSelectionCancel(),i?.tmux&&window.treeportDesktop?.setTerminalSelectionActive(!1),o?.(),c(),i&&=(Kh(),null),u(),e.removeEventListener(`pointerdown`,m,!0),e.removeEventListener(`pointerup`,h,!0),e.removeEventListener(`pointercancel`,h,!0),e.removeEventListener(`lostpointercapture`,g,!0),document.removeEventListener(`mousemove`,f,!0),document.removeEventListener(`mouseup`,p,!0),window.removeEventListener(`blur`,_)}}function og(e,t,n,r,i){let a=null,o=0,s=null,c=null,l=null,u=null,d=[],f=(e,n)=>{let r=t.element;if(!r)return null;let i=r.getBoundingClientRect();return{column:Math.min(t.cols-1,Math.max(0,Math.floor((e-i.left)/i.width*t.cols))),row:t.buffer.active.viewportY+Math.min(t.rows-1,Math.max(0,Math.floor((n-i.top)/i.height*t.rows)))}},p=()=>{c!==null&&(window.clearTimeout(c),c=null)},m=()=>{u!==null&&(window.clearTimeout(u),u=null),d=[]};e.addEventListener(`wheel`,n,{capture:!0,passive:!0}),e.addEventListener(`touchstart`,e=>{if(e.touches.length===2){p(),m(),a=null,o=0,s=null,l=null,d=Array.from(e.touches,e=>({identifier:e.identifier,x:e.clientX,y:e.clientY})),u=window.setTimeout(()=>{u=null,d=[],navigator.vibrate?.(10),i()},Xh);return}if(e.touches.length!==1){p(),m(),a=null,o=0,s=null,l=null;return}m();let n=e.touches[0];a=n.clientY,o=0,s={x:n.clientX,y:n.clientY},l=null,p(),c=window.setTimeout(()=>{c=null,s&&(l=f(s.x,s.y),l&&(t.select(l.column,l.row,1),navigator.vibrate?.(10)))},Yh)},{capture:!0,passive:!0}),e.addEventListener(`touchmove`,e=>{if(e.touches.length===2&&d.length===2){d.some(t=>{let n=Array.from(e.touches).find(e=>e.identifier===t.identifier);return!n||Math.hypot(n.clientX-t.x,n.clientY-t.y)>Zh})?m():e.preventDefault();return}if(e.touches.length!==1||a===null){p(),m(),a=null,o=0,s=null,l=null;return}let n=t.element;if(!n)return;let r=e.touches[0];if(l){e.preventDefault();let n=f(r.clientX,r.clientY);if(!n)return;let i=l.row*t.cols+l.column,a=n.row*t.cols+n.column,o=Math.min(i,a);t.select(o%t.cols,Math.floor(o/t.cols),Math.abs(a-i)+1);return}s&&Math.hypot(r.clientX-s.x,r.clientY-s.y)>Zh&&(p(),s=null),o+=a-r.clientY,a=r.clientY,e.preventDefault();let i=n.getBoundingClientRect(),c=(i.height/t.rows||16)*(n.classList.contains(`enable-mouse-events`)?Jh:1),u=Math.trunc(o/c);if(u===0)return;o-=u*c;let h=Math.min(Math.max(r.clientX,i.left),i.right-1),g=Math.min(Math.max(r.clientY,i.top),i.bottom-1);for(let e=0;e<Math.abs(u);e+=1)n.dispatchEvent(new WheelEvent(`wheel`,{bubbles:!0,cancelable:!0,composed:!0,clientX:h,clientY:g,deltaMode:WheelEvent.DOM_DELTA_LINE,deltaY:Math.sign(u)}))},{capture:!0,passive:!1});let h=e=>{l&&e.preventDefault(),p(),m(),a=null,o=0,s=null,l=null};e.addEventListener(`touchend`,h,{capture:!0,passive:!1}),e.addEventListener(`touchcancel`,h,{capture:!0,passive:!1}),e.addEventListener(`paste`,r,!0)}function sg(){return{cursorBlink:!0,convertEol:!1,fontFamily:`"SFMono-Regular", "Cascadia Code", "Liberation Mono", monospace`,fontSize:14,lineHeight:1.15,scrollback:0,allowProposedApi:!1,macOptionClickForcesSelection:!0,linkHandler:{activate:tg,allowNonHttpProtocols:!0},theme:{background:`#09090b`,foreground:`#e4e4e7`,cursor:`#67e8f9`,selectionBackground:`#3f3f4666`,scrollbarSliderBackground:`#3f3f46`,scrollbarSliderHoverBackground:`#52525b`,scrollbarSliderActiveBackground:`#71717a`,black:`#18181b`,red:`#fb7185`,green:`#86efac`,yellow:`#fde047`,blue:`#7dd3fc`,magenta:`#d8b4fe`,cyan:`#67e8f9`,white:`#f4f4f5`}}}var cg=2,lg=1,ug=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(cg,Math.floor(u/e.css.cell.width)),rows:Math.max(lg,Math.floor(l/e.css.cell.height))}}},dg=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=pg.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function fg(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var pg=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!fg(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),!(!n.isWrapped||o.indexOf(` `)!==-1)););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},mg=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function hg(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var gg=class{constructor(e=hg,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||mg;this._linkProvider=this._terminal.registerLinkProvider(new dg(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},_g=Object.defineProperty,vg=Object.getOwnPropertyDescriptor,yg=(e,t)=>{for(var n in t)_g(e,n,{get:t[n],enumerable:!0})},bg=(e,t,n,r)=>{for(var i=r>1?void 0:r?vg(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&_g(t,n,i),i},K=(e,t)=>(n,r)=>t(n,r,e),xg=`Terminal input`,Sg={get:()=>xg,set:e=>xg=e},Cg=`Too much output to announce, navigate to rows manually to read`,wg={get:()=>Cg,set:e=>Cg=e};function Tg(e){return e.replace(/\r?\n/g,`\r`)}function Eg(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function Dg(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function Og(e,t,n,r){e.stopPropagation(),e.clipboardData&&kg(e.clipboardData.getData(`text/plain`),t,n,r)}function kg(e,t,n,r){e=Tg(e),e=Eg(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Ag(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function jg(e,t,n,r,i){Ag(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Mg(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Ng(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var Pg=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},Fg=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},Ig=``,Lg=` `,Rg=class e{constructor(){this.fg=0,this.bg=0,this.extended=new zg}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},zg=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Bg=class e extends Rg{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new zg,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Mg(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Vg=`di$target`,Hg=`di$dependencies`,Ug=new Map;function Wg(e){return e[Hg]||[]}function Gg(e){if(Ug.has(e))return Ug.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Kg(t,e,r)};return t._id=e,Ug.set(e,t),t}function Kg(e,t,n){t[Vg]===t?t[Hg].push({id:e,index:n}):(t[Hg]=[{id:e,index:n}],t[Vg]=t)}var qg=Gg(`BufferService`),Jg=Gg(`CoreMouseService`),Yg=Gg(`CoreService`),Xg=Gg(`CharsetService`),Zg=Gg(`InstantiationService`),Qg=Gg(`LogService`),$g=Gg(`OptionsService`),e_=Gg(`OscLinkService`),t_=Gg(`UnicodeService`),n_=Gg(`DecorationService`),r_=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Bg,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):i_(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};r_=bg([K(0,qg),K(1,$g),K(2,e_)],r_);function i_(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
49
|
+
`},ah=0,oh=[];function sh(e){var t=R.useRef([]),n=R.useRef([0,0]),r=R.useRef(),i=R.useState(ah++)[0],a=R.useState(km)[0],o=R.useRef(e);R.useEffect(function(){o.current=e},[e]),R.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=im([e.lockRef.current],(e.shards||[]).map(nh),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=R.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=eh(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=qm(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=qm(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return $m(h,t,e,h===`h`?s:c,!0)},[]),c=R.useCallback(function(e){var n=e;if(!(!oh.length||oh[oh.length-1]!==a)){var r=`deltaY`in n?th(n):eh(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&rh(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(nh).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=R.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ch(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=R.useCallback(function(e){n.current=eh(e),r.current=void 0},[]),d=R.useCallback(function(t){l(t.type,th(t),t.target,s(t,e.lockRef.current))},[]),f=R.useCallback(function(t){l(t.type,eh(t),t.target,s(t,e.lockRef.current))},[]);R.useEffect(function(){return oh.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Hm),document.addEventListener(`touchmove`,c,Hm),document.addEventListener(`touchstart`,u,Hm),function(){oh=oh.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Hm),document.removeEventListener(`touchmove`,c,Hm),document.removeEventListener(`touchstart`,u,Hm)}},[]);var p=e.removeScrollBar,m=e.inert;return R.createElement(R.Fragment,null,m?R.createElement(a,{styles:ih(i)}):null,p?R.createElement(zm,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ch(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var lh=vm(ym,sh),uh=R.forwardRef(function(e,t){return R.createElement(xm,nm({},e,{ref:t,sideCar:lh}))});uh.classNames=xm.classNames;var dh=`Popover`,[fh,ph]=oo(dh,[al]),mh=al(),[hh,gh]=fh(dh),_h=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=mh(t),c=R.useRef(null),[l,u]=R.useState(!1),[d,f]=Fl({prop:r,defaultProp:i??!1,onChange:a,caller:dh});return(0,z.jsx)(xl,{...s,children:(0,z.jsx)(hh,{scope:t,contentId:Vo(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:R.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:R.useCallback(()=>u(!0),[]),onCustomAnchorRemove:R.useCallback(()=>u(!1),[]),modal:o,children:n})})};_h.displayName=dh;var vh=`PopoverAnchor`,yh=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=gh(vh,n),a=mh(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return R.useEffect(()=>(o(),()=>s()),[o,s]),(0,z.jsx)(Sl,{...a,...r,ref:t})});yh.displayName=vh;var bh=`PopoverTrigger`,xh=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=gh(bh,n),a=mh(n),o=ao(t,i.triggerRef),s=(0,z.jsx)(xo.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Ih(i.open),...r,ref:o,onClick:no(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,z.jsx)(Sl,{asChild:!0,...a,children:s})});xh.displayName=bh;var Sh=`PopoverPortal`,[Ch,wh]=fh(Sh,{forceMount:void 0}),Th=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=gh(Sh,t);return(0,z.jsx)(Ch,{scope:t,forceMount:n,children:(0,z.jsx)(Ol,{present:n||a.open,children:(0,z.jsx)(El,{asChild:!0,container:i,children:r})})})};Th.displayName=Sh;var Eh=`PopoverContent`,Dh=R.forwardRef((e,t)=>{let n=wh(Eh,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=gh(Eh,e.__scopePopover);return(0,z.jsx)(Ol,{present:r||a.open,children:a.modal?(0,z.jsx)(kh,{...i,ref:t}):(0,z.jsx)(Ah,{...i,ref:t})})});Dh.displayName=Eh;var Oh=co(`PopoverContent.RemoveScroll`),kh=R.forwardRef((e,t)=>{let n=gh(Eh,e.__scopePopover),r=R.useRef(null),i=ao(t,r),a=R.useRef(!1);return R.useEffect(()=>{let e=r.current;if(e)return tm(e)},[]),(0,z.jsx)(uh,{as:Oh,allowPinchZoom:!0,children:(0,z.jsx)(jh,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:no(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:no(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:no(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),Ah=R.forwardRef((e,t)=>{let n=gh(Eh,e.__scopePopover),r=R.useRef(!1),i=R.useRef(!1);return(0,z.jsx)(jh,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),jh=R.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=gh(Eh,n),p=mh(n);return kp(),(0,z.jsx)(Fp,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,z.jsx)(Ao,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,z.jsx)(Cl,{"data-state":Ih(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),Mh=`PopoverClose`,Nh=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=gh(Mh,n);return(0,z.jsx)(xo.button,{type:`button`,...r,ref:t,onClick:no(e.onClick,()=>i.onOpenChange(!1))})});Nh.displayName=Mh;var Ph=`PopoverArrow`,Fh=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=mh(n);return(0,z.jsx)(wl,{...i,...r,ref:t})});Fh.displayName=Ph;function Ih(e){return e?`open`:`closed`}var Lh=_h,Rh=xh,zh=Th,Bh=Dh;function Vh(e){return(0,z.jsx)(Lh,{...e})}function Hh(e){return(0,z.jsx)(Rh,{...e})}function Uh({className:e,align:t=`start`,sideOffset:n=6,portalled:r=!0,...i}){let a=(0,z.jsx)(Bh,{align:t,sideOffset:n,className:W(`z-100 w-52 rounded-lg bg-zinc-900 p-3 text-zinc-200 shadow-xl ring-1 ring-white/10 outline-none`,e),...i});return r?(0,z.jsx)(zh,{children:a}):a}var Wh=(0,R.createRef)();function Gh(e){if(!Wh.current)throw Error(`ForceSpecificCursor is not mounted`);Wh.current.style.cursor=e,Wh.current.style.pointerEvents=`auto`}function Kh(){if(!Wh.current)throw Error(`ForceSpecificCursor is not mounted`);Wh.current.style.cursor=``,Wh.current.style.pointerEvents=`none`}function qh(){return(0,z.jsx)(`div`,{ref:Wh,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0`,style:{zIndex:2147483647}})}var Jh=1,Yh=450,Xh=550,Zh=10;function Qh(e){let t=e.value===null?``:`, ${e.value}% complete`;return e.state===`error`?`progress error${t}`:e.state===`paused`?`progress paused${t}`:e.value===null?`working`:`${e.value}% complete`}function $h(e,t=!1){if(e.type!==`keydown`||e.isComposing||e.ctrlKey)return null;if(e.key===`Enter`&&e.shiftKey&&!e.altKey&&!e.metaKey)return`\x1B[13;2u`;if(e.altKey&&!e.metaKey&&!e.shiftKey){if(eg()){if(e.key===`ArrowLeft`)return`\x1Bb`;if(e.key===`ArrowRight`)return`\x1Bf`}else{let t={ArrowUp:`A`,ArrowDown:`B`,ArrowRight:`C`,ArrowLeft:`D`}[e.key];if(t)return`\u001b[1;5${t}`}return null}if(!e.metaKey||e.altKey||e.shiftKey)return null;let n=t?`\x1BO`:`\x1B[`;return e.key===`ArrowLeft`?`${n}H`:e.key===`ArrowRight`?`${n}F`:null}function eg(){return/Mac|iPhone|iPad|iPod/.test(globalThis.navigator?.platform??``)}function tg(e,t){if(eg()?!e.metaKey:!e.ctrlKey)return;let n;try{n=new URL(t)}catch{return}if(n.protocol===`file:`){window.treeportDesktop?.openFileUrl(t).catch(()=>void 0);return}(n.protocol===`http:`||n.protocol===`https:`)&&window.open(t,`_blank`,`noopener,noreferrer`)}function ng(e,t){!t.element?.classList.contains(`enable-mouse-events`)||e.button!==0||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||Object.defineProperty(e,eg()?`altKey`:`shiftKey`,{configurable:!0,value:!0})}var rg=50,ig=3;function ag(e,t,n){let r=null,i=null,a=null,o,s=(e,n)=>{let r=(t.element?.querySelector(`.xterm-screen`))?.getBoundingClientRect();if(!r?.width||!r.height)return null;let i=Math.ceil((e-r.left)/r.width*t.cols+.5);return{column:Math.max(1,Math.min(t.cols,i)),endOfLine:i>t.cols,row:Math.max(1,Math.min(t.rows,Math.floor((n-r.top)/r.height*t.rows)+1)),bounds:r}},c=()=>{a!==null&&(window.clearInterval(a),a=null)};function l(){if(!i)return;let u=s(i.clientX,i.clientY);if(!u)return;let f=i.clientY<u.bounds.top||i.clientY>u.bounds.bottom,p=i.clientX<u.bounds.left||i.clientX>u.bounds.right,m=f&&!p;m||c();let h=u.endOfLine?`\x1B[F`:``;if(i.tmux)n.canInput()&&n.sendInput(`\u001b[<32;${u.column};${u.row}M${h}`);else{if(Math.hypot(i.clientX-i.startClientX,i.clientY-i.startClientY)<ig||!n.canInput())return;n.sendInput(`${n.selectionStartSequence}\u001b[<0;${i.startColumn};${i.startRow}M\u001b[<32;${i.startColumn};${i.startRow}M\u001b[<32;${u.column};${u.row}M${h}`),t.clearSelection(),r!==null&&e.setPointerCapture(r),i.tmux=!0,o??=window.treeportDesktop?.onTerminalSelectionRelease(d),window.treeportDesktop?.setTerminalSelectionActive(!0),n.onTmuxSelectionStart()}m&&a===null&&(a=window.setInterval(l,rg))}let u=()=>{let t=r;r=null,t!==null&&e.hasPointerCapture(t)&&e.releasePointerCapture(t)},d=()=>{if(!i){u();return}let e=i.tmux;if(e&&n.canInput()){let e=s(i.clientX,i.clientY);if(e){let r=e.row===1?Math.min(2,t.rows):e.row===t.rows?Math.max(1,t.rows-1):e.row;n.onTmuxSelectionFinish(),n.sendInput(`${n.selectionStopSequence}\u001b[<32;${e.column};${r}M\u001b[<0;${e.column};${r}m`)}}c(),i=null,Kh(),e&&window.treeportDesktop?.setTerminalSelectionActive(!1),u(),document.removeEventListener(`mousemove`,f,!0),document.removeEventListener(`mouseup`,p,!0),window.removeEventListener(`blur`,_)},f=e=>{if(i){if(!(e.buttons&1)){d();return}i.clientX=e.clientX,i.clientY=e.clientY,l()}},p=()=>d(),m=e=>{e.isPrimary&&e.button===0&&(d(),r=e.pointerId)},h=()=>d(),g=()=>d(),_=()=>d();return e.addEventListener(`pointerdown`,m,!0),e.addEventListener(`pointerup`,h,!0),e.addEventListener(`pointercancel`,h,!0),e.addEventListener(`lostpointercapture`,g,!0),e.addEventListener(`mousedown`,e=>{n.requestControl(),ng(e,t);let r=s(e.clientX,e.clientY);e.button!==0||e.ctrlKey||e.metaKey||!r||e.clientX<r.bounds.left||e.clientX>r.bounds.right||e.clientY<r.bounds.top||e.clientY>r.bounds.bottom||(n.onSelectionStart(),Gh(`text`),i={startColumn:r.column,startRow:r.row,startClientX:e.clientX,startClientY:e.clientY,clientX:e.clientX,clientY:e.clientY,tmux:!1},document.addEventListener(`mousemove`,f,!0),document.addEventListener(`mouseup`,p,!0),window.addEventListener(`blur`,_))},!0),()=>{i?.tmux&&n.canInput()&&n.onTmuxSelectionCancel(),i?.tmux&&window.treeportDesktop?.setTerminalSelectionActive(!1),o?.(),c(),i&&=(Kh(),null),u(),e.removeEventListener(`pointerdown`,m,!0),e.removeEventListener(`pointerup`,h,!0),e.removeEventListener(`pointercancel`,h,!0),e.removeEventListener(`lostpointercapture`,g,!0),document.removeEventListener(`mousemove`,f,!0),document.removeEventListener(`mouseup`,p,!0),window.removeEventListener(`blur`,_)}}function og(e,t,n,r,i){let a=null,o=0,s=0,c=[],l=new WeakSet,u=null,d=null,f=null,p=null,m=[],h=(e,n)=>{let r=t.element;if(!r)return null;let i=r.getBoundingClientRect();return{column:Math.min(t.cols-1,Math.max(0,Math.floor((e-i.left)/i.width*t.cols))),row:t.buffer.active.viewportY+Math.min(t.rows-1,Math.max(0,Math.floor((n-i.top)/i.height*t.rows)))}},g=()=>{d!==null&&(window.clearTimeout(d),d=null)},_=()=>{p!==null&&(window.clearTimeout(p),p=null),m=[]};t.attachCustomWheelEventHandler(e=>{let n=t.element;if(!n?.classList.contains(`enable-mouse-events`)||l.has(e)||e.deltaY===0)return!0;let r=n.getBoundingClientRect().height/t.rows||16,i=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/r:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*t.rows:e.deltaY;s+=i;let a=Math.trunc(s);if(s-=a,a===0)return!1;let o=new WheelEvent(`wheel`,{bubbles:!0,cancelable:!0,composed:!0,clientX:e.clientX,clientY:e.clientY,deltaMode:WheelEvent.DOM_DELTA_LINE,deltaY:Math.sign(a),altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey});return l.add(o),c.push(Math.abs(a)),queueMicrotask(()=>n.dispatchEvent(o)),!1}),e.addEventListener(`wheel`,n,{capture:!0,passive:!0}),e.addEventListener(`touchstart`,e=>{if(e.touches.length===2){g(),_(),a=null,o=0,u=null,f=null,m=Array.from(e.touches,e=>({identifier:e.identifier,x:e.clientX,y:e.clientY})),p=window.setTimeout(()=>{p=null,m=[],navigator.vibrate?.(10),i()},Xh);return}if(e.touches.length!==1){g(),_(),a=null,o=0,u=null,f=null;return}_();let n=e.touches[0];a=n.clientY,o=0,u={x:n.clientX,y:n.clientY},f=null,g(),d=window.setTimeout(()=>{d=null,u&&(f=h(u.x,u.y),f&&(t.select(f.column,f.row,1),navigator.vibrate?.(10)))},Yh)},{capture:!0,passive:!0}),e.addEventListener(`touchmove`,e=>{if(e.touches.length===2&&m.length===2){m.some(t=>{let n=Array.from(e.touches).find(e=>e.identifier===t.identifier);return!n||Math.hypot(n.clientX-t.x,n.clientY-t.y)>Zh})?_():e.preventDefault();return}if(e.touches.length!==1||a===null){g(),_(),a=null,o=0,u=null,f=null;return}let n=t.element;if(!n)return;let r=e.touches[0];if(f){e.preventDefault();let n=h(r.clientX,r.clientY);if(!n)return;let i=f.row*t.cols+f.column,a=n.row*t.cols+n.column,o=Math.min(i,a);t.select(o%t.cols,Math.floor(o/t.cols),Math.abs(a-i)+1);return}u&&Math.hypot(r.clientX-u.x,r.clientY-u.y)>Zh&&(g(),u=null),o+=a-r.clientY,a=r.clientY,e.preventDefault();let i=n.getBoundingClientRect(),s=(i.height/t.rows||16)*(n.classList.contains(`enable-mouse-events`)?Jh:1),c=Math.trunc(o/s);if(c===0)return;o-=c*s;let l=Math.min(Math.max(r.clientX,i.left),i.right-1),d=Math.min(Math.max(r.clientY,i.top),i.bottom-1);for(let e=0;e<Math.abs(c);e+=1)n.dispatchEvent(new WheelEvent(`wheel`,{bubbles:!0,cancelable:!0,composed:!0,clientX:l,clientY:d,deltaMode:WheelEvent.DOM_DELTA_LINE,deltaY:Math.sign(c)}))},{capture:!0,passive:!1});let v=e=>{f&&e.preventDefault(),g(),_(),a=null,o=0,u=null,f=null};return e.addEventListener(`touchend`,v,{capture:!0,passive:!1}),e.addEventListener(`touchcancel`,v,{capture:!0,passive:!1}),e.addEventListener(`paste`,r,!0),e=>{let t=c.shift()??1;return t===1?e:e.repeat(t)}}function sg(){return{cursorBlink:!0,convertEol:!1,fontFamily:`"SFMono-Regular", "Cascadia Code", "Liberation Mono", monospace`,fontSize:14,lineHeight:1.15,scrollback:0,allowProposedApi:!1,macOptionClickForcesSelection:!0,linkHandler:{activate:tg,allowNonHttpProtocols:!0},theme:{background:`#09090b`,foreground:`#e4e4e7`,cursor:`#67e8f9`,selectionBackground:`#3f3f4666`,scrollbarSliderBackground:`#3f3f46`,scrollbarSliderHoverBackground:`#52525b`,scrollbarSliderActiveBackground:`#71717a`,black:`#18181b`,red:`#fb7185`,green:`#86efac`,yellow:`#fde047`,blue:`#7dd3fc`,magenta:`#d8b4fe`,cyan:`#67e8f9`,white:`#f4f4f5`}}}var cg=2,lg=1,ug=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(cg,Math.floor(u/e.css.cell.width)),rows:Math.max(lg,Math.floor(l/e.css.cell.height))}}},dg=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=pg.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function fg(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var pg=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!fg(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),!(!n.isWrapped||o.indexOf(` `)!==-1)););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},mg=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function hg(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var gg=class{constructor(e=hg,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||mg;this._linkProvider=this._terminal.registerLinkProvider(new dg(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},_g=Object.defineProperty,vg=Object.getOwnPropertyDescriptor,yg=(e,t)=>{for(var n in t)_g(e,n,{get:t[n],enumerable:!0})},bg=(e,t,n,r)=>{for(var i=r>1?void 0:r?vg(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&_g(t,n,i),i},K=(e,t)=>(n,r)=>t(n,r,e),xg=`Terminal input`,Sg={get:()=>xg,set:e=>xg=e},Cg=`Too much output to announce, navigate to rows manually to read`,wg={get:()=>Cg,set:e=>Cg=e};function Tg(e){return e.replace(/\r?\n/g,`\r`)}function Eg(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function Dg(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function Og(e,t,n,r){e.stopPropagation(),e.clipboardData&&kg(e.clipboardData.getData(`text/plain`),t,n,r)}function kg(e,t,n,r){e=Tg(e),e=Eg(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Ag(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function jg(e,t,n,r,i){Ag(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Mg(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Ng(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var Pg=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},Fg=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},Ig=``,Lg=` `,Rg=class e{constructor(){this.fg=0,this.bg=0,this.extended=new zg}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},zg=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Bg=class e extends Rg{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new zg,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Mg(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Vg=`di$target`,Hg=`di$dependencies`,Ug=new Map;function Wg(e){return e[Hg]||[]}function Gg(e){if(Ug.has(e))return Ug.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Kg(t,e,r)};return t._id=e,Ug.set(e,t),t}function Kg(e,t,n){t[Vg]===t?t[Hg].push({id:e,index:n}):(t[Hg]=[{id:e,index:n}],t[Vg]=t)}var qg=Gg(`BufferService`),Jg=Gg(`CoreMouseService`),Yg=Gg(`CoreService`),Xg=Gg(`CharsetService`),Zg=Gg(`InstantiationService`),Qg=Gg(`LogService`),$g=Gg(`OptionsService`),e_=Gg(`OscLinkService`),t_=Gg(`UnicodeService`),n_=Gg(`DecorationService`),r_=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Bg,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):i_(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};r_=bg([K(0,qg),K(1,$g),K(2,e_)],r_);function i_(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
50
50
|
|
|
51
51
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var a_=Gg(`CharSizeService`),o_=Gg(`CoreBrowserService`),s_=Gg(`MouseService`),c_=Gg(`RenderService`),l_=Gg(`SelectionService`),u_=Gg(`CharacterJoinerService`),d_=Gg(`ThemeService`),f_=Gg(`LinkProviderService`),p_=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?y_.isErrorNoTelemetry(e)?new y_(e.message+`
|
|
52
52
|
|
|
@@ -80,9 +80,9 @@ ${s.join(`
|
|
|
80
80
|
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),Gx&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=mS(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=kx(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-hS),hS),t/=hS,t/Math.abs(t)+Math.round(t*(gS-1)))}shouldForceSelection(e){return Vx?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),_S)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Vx&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<vS&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=eS(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(!(!t&&o.slice(s,c).trim()===``)){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=mS(n,this._bufferService.cols)}};bS=bg([K(3,qg),K(4,Yg),K(5,s_),K(6,$g),K(7,c_),K(8,o_)],bS);var xS=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},SS=class{constructor(){this._color=new xS,this._css=new xS}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},CS=Object.freeze((()=>{let e=[Zb.toColor(`#2e3436`),Zb.toColor(`#cc0000`),Zb.toColor(`#4e9a06`),Zb.toColor(`#c4a000`),Zb.toColor(`#3465a4`),Zb.toColor(`#75507b`),Zb.toColor(`#06989a`),Zb.toColor(`#d3d7cf`),Zb.toColor(`#555753`),Zb.toColor(`#ef2929`),Zb.toColor(`#8ae234`),Zb.toColor(`#fce94f`),Zb.toColor(`#729fcf`),Zb.toColor(`#ad7fa8`),Zb.toColor(`#34e2e2`),Zb.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:Yb.toCss(r,i,a),rgba:Yb.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:Yb.toCss(n,n,n),rgba:Yb.toRgba(n,n,n)})}return e})()),wS=Zb.toColor(`#ffffff`),TS=Zb.toColor(`#000000`),ES=Zb.toColor(`#ffffff`),DS=TS,OS={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},kS=wS,AS=class extends U_{constructor(e){super(),this._optionsService=e,this._contrastCache=new SS,this._halfContrastCache=new SS,this._onChangeColors=this._register(new q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:wS,background:TS,cursor:ES,cursorAccent:DS,selectionForeground:void 0,selectionBackgroundTransparent:OS,selectionBackgroundOpaque:Xb.blend(TS,OS),selectionInactiveBackgroundTransparent:OS,selectionInactiveBackgroundOpaque:Xb.blend(TS,OS),scrollbarSliderBackground:Xb.opacity(wS,.2),scrollbarSliderHoverBackground:Xb.opacity(wS,.4),scrollbarSliderActiveBackground:Xb.opacity(wS,.5),overviewRulerBorder:wS,ansi:CS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=jS(e.foreground,wS),t.background=jS(e.background,TS),t.cursor=Xb.blend(t.background,jS(e.cursor,ES)),t.cursorAccent=Xb.blend(t.background,jS(e.cursorAccent,DS)),t.selectionBackgroundTransparent=jS(e.selectionBackground,OS),t.selectionBackgroundOpaque=Xb.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=jS(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Xb.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?jS(e.selectionForeground,Jb):void 0,t.selectionForeground===Jb&&(t.selectionForeground=void 0),Xb.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Xb.opacity(t.selectionBackgroundTransparent,.3)),Xb.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Xb.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=jS(e.scrollbarSliderBackground,Xb.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=jS(e.scrollbarSliderHoverBackground,Xb.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=jS(e.scrollbarSliderActiveBackground,Xb.opacity(t.foreground,.5)),t.overviewRulerBorder=jS(e.overviewRulerBorder,kS),t.ansi=CS.slice(),t.ansi[0]=jS(e.black,CS[0]),t.ansi[1]=jS(e.red,CS[1]),t.ansi[2]=jS(e.green,CS[2]),t.ansi[3]=jS(e.yellow,CS[3]),t.ansi[4]=jS(e.blue,CS[4]),t.ansi[5]=jS(e.magenta,CS[5]),t.ansi[6]=jS(e.cyan,CS[6]),t.ansi[7]=jS(e.white,CS[7]),t.ansi[8]=jS(e.brightBlack,CS[8]),t.ansi[9]=jS(e.brightRed,CS[9]),t.ansi[10]=jS(e.brightGreen,CS[10]),t.ansi[11]=jS(e.brightYellow,CS[11]),t.ansi[12]=jS(e.brightBlue,CS[12]),t.ansi[13]=jS(e.brightMagenta,CS[13]),t.ansi[14]=jS(e.brightCyan,CS[14]),t.ansi[15]=jS(e.brightWhite,CS[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=jS(e.extendedAnsi[r],CS[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};AS=bg([K(0,$g)],AS);function jS(e,t){if(e!==void 0)try{return Zb.toColor(e)}catch{}return t}var MS=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},NS=class{constructor(){this._services=new MS,this._services.set(Zg,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=Wg(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},PS={trace:0,debug:1,info:2,warn:3,error:4,off:5},FS=`xterm.js: `,IS=class extends U_{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),LS=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=PS[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:FS)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};IS=bg([K(0,$g)],IS);var LS,RS=class extends U_{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new q),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},zS=3,BS=Object.freeze(new Rg),VS=0,HS=2,US=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*zS);let r=t||Bg.fromCharData([0,Ig,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*zS+0],n=t&2097151;return[this._data[e*zS+1],t&2097152?this._combined[e]:n?Mg(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*zS+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*zS+0]=e|2097152|t[2]<<22):this._data[e*zS+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*zS+0]>>22}hasWidth(e){return this._data[e*zS+0]&12582912}getFg(e){return this._data[e*zS+1]}getBg(e){return this._data[e*zS+2]}hasContent(e){return this._data[e*zS+0]&4194303}getCodePoint(e){let t=this._data[e*zS+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*zS+0]&2097152}getString(e){let t=this._data[e*zS+0];return t&2097152?this._combined[e]:t&2097151?Mg(t&2097151):``}isProtected(e){return this._data[e*zS+2]&536870912}loadCell(e,t){return VS=e*zS,t.content=this._data[VS+0],t.fg=this._data[VS+1],t.bg=this._data[VS+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*zS+0]=t.content,this._data[e*zS+1]=t.fg,this._data[e*zS+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*zS+0]=t|n<<22,this._data[e*zS+1]=r.fg,this._data[e*zS+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*zS+0];r&2097152?this._combined[e]+=Mg(t):r&2097151?(this._combined[e]=Mg(r&2097151)+Mg(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*zS+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new Bg;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new Bg;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*HS<this._data.buffer.byteLength;let n=e*zS;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*HS<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*HS<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*zS+0]&4194303)return e+(this._data[e*zS+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*zS+0]&4194303||this._data[e*zS+2]&50331648)return e+(this._data[e*zS+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<zS;e++)this._data[(n+i)*zS+e]=a[(t+i)*zS+e];a[(t+i)*zS+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<zS;e++)this._data[(n+i)*zS+e]=a[(t+i)*zS+e];a[(t+i)*zS+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*zS+0],n=e&2097151,a=e&2097152?this._combined[t]:n?Mg(n):Lg;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function WS(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=JS(u,d,t),p=1,m=0;for(;p<u.length;){let e=JS(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function GS(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function KS(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function qS(e,t,n){let r=[],i=e.map((n,r)=>JS(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=JS(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function JS(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var YS=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),R_(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};YS._nextId=1;var XS=YS,ZS={},QS=ZS.B;ZS[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:``,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},ZS.A={"#":`£`},ZS.B=void 0,ZS[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},ZS.C=ZS[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},ZS.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},ZS.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},ZS.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},ZS.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},ZS.E=ZS[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},ZS.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},ZS.H=ZS[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},ZS[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var $S=4294967295,eC=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=BS.clone(),this.savedCharset=QS,this.markers=[],this._nullCell=Bg.fromCharData([0,Ig,1,0]),this._whitespaceCell=Bg.fromCharData([0,Lg,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Xx,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new RS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new zg),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new zg),this._whitespaceCell}getBlankLine(e,t){return new US(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>$S?$S:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=BS);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new RS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(BS),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new US(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new US(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=WS(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(BS),n);if(r.length>0){let n=GS(this.lines,r);KS(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(BS),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new US(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(BS),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=qS(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(BS,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=JS(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new XS(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},tC=class extends U_{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new q),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new eC(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new eC(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},nC=2,rC=1,iC=class extends U_{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new q),this.onResize=this._onResize.event,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,nC),this.rows=Math.max(e.rawOptions.rows||0,rC),this.buffers=this._register(new tC(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};iC=bg([K(0,$g)],iC);var aC={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Vx,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},oC=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],sC=class extends U_{constructor(e){super(),this._onOptionChange=this._register(new q),this.onOptionChange=this._onOptionChange.event;let t={...aC};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(B_(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in aC))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in aC))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=aC[e],!cC(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=aC[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=oC.includes(t)?t:aC[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={};break}return t}};function cC(e){return e===`block`||e===`underline`||e===`bar`}function lC(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&lC(e[r],t-1);return n}var uC=Object.freeze({insertMode:!1}),dC=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),fC=class extends U_{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new q),this.onData=this._onData.event,this._onUserInput=this._register(new q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=lC(uC),this.decPrivateModes=lC(dC)}reset(){this.modes=lC(uC),this.decPrivateModes=lC(dC)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};fC=bg([K(0,qg),K(1,Qg),K(2,$g)],fC);var pC={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function mC(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var hC=String.fromCharCode,gC={DEFAULT:e=>{let t=[mC(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${hC(t[0])}${hC(t[1])}${hC(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${mC(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${mC(e,!0)};${e.x};${e.y}${t}`}},_C=class extends U_{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new q),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(pC))this.addProtocol(e,pC[e]);for(let e of Object.keys(gC))this.addEncoding(e,gC[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};_C=bg([K(0,qg),K(1,Yg),K(2,$g)],_C);var vC=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],yC=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],bC;function xC(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var SC=class{constructor(){if(this.version=`6`,!bC){bC=new Uint8Array(65536),bC.fill(1),bC[0]=0,bC.fill(0,1,32),bC.fill(0,127,160),bC.fill(2,4352,4448),bC[9001]=2,bC[9002]=2,bC.fill(2,11904,42192),bC[12351]=1,bC.fill(2,44032,55204),bC.fill(2,63744,64256),bC.fill(2,65040,65050),bC.fill(2,65072,65136),bC.fill(2,65280,65377),bC.fill(2,65504,65511);for(let e=0;e<vC.length;++e)bC.fill(0,vC[e][0],vC[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?bC[e]:xC(e,yC)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=CC.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return CC.createPropertyValue(0,n,r)}},CC=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new q,this.onChange=this._onChange.event;let e=new SC;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},wC=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function TC(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var EC=2147483647,DC=256,OC=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>DC)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>EC?EC:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>EC?EC:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,EC):e}},kC=[],AC=class{constructor(){this._state=0,this._active=kC,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=kC}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=kC,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||kC,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,Ng(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=kC,this._id=-1,this._state=0}}},jC=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Ng(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},MC=[],NC=class{constructor(){this._handlers=Object.create(null),this._active=MC,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=MC}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=MC,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||MC,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,Ng(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=MC,this._ident=0}},PC=new OC;PC.addParam(0);var FC=class{constructor(e){this._handler=e,this._data=``,this._params=PC,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():PC,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Ng(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=PC,this._data=``,this._hitLimit=!1,e));return this._params=PC,this._data=``,this._hitLimit=!1,t}},IC=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},LC=160,RC=function(){let e=new IC(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(LC,0,2,0),e.add(LC,8,5,8),e.add(LC,6,0,6),e.add(LC,11,0,11),e.add(LC,13,13,13),e}(),zC=class extends U_{constructor(e=RC){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new OC,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(B_(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new AC),this._dcsParser=this._register(new NC),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:LC)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<LC){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<LC){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<LC){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<LC){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<LC){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<LC){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},BC=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,VC=/^[\da-f]+$/;function HC(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=BC.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),VC.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function UC(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function WC(e,t=16){let[n,r,i]=e;return`rgb:${UC(n,t)}/${UC(r,t)}/${UC(i,t)}`}var GC={"(":0,")":1,"*":2,"+":3,"-":1,".":2},KC=131072,qC=10;function JC(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var YC=5e3,XC=0,ZC=class extends U_{constructor(e,t,n,r,i,a,o,s,c=new zC){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Pg,this._utf8Decoder=new Fg,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=BS.clone(),this._eraseAttrDataInternal=BS.clone(),this._onRequestBell=this._register(new q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new q),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new QC(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(Y.BEL,()=>this.bell()),this._parser.setExecuteHandler(Y.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Y.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Y.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Y.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Y.BS,()=>this.backspace()),this._parser.setExecuteHandler(Y.HT,()=>this.tab()),this._parser.setExecuteHandler(Y.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Y.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Vb.IND,()=>this.index()),this._parser.setExecuteHandler(Vb.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Vb.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new jC(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new jC(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new jC(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new jC(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new jC(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new jC(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new jC(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new jC(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new jC(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new jC(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new jC(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new jC(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in ZS)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new FC((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),YC))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${YC} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>KC&&(a=this._parseStack.position+KC)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<KC&&(this._parseBuffer=new Uint32Array(Math.min(e.length,KC))),o||this._dirtyRowTracker.clearRange(),e.length>KC)for(let t=a;t<e.length;t+=KC){let a=t+KC<e.length?t+KC:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=CC.extractWidth(t);let n=CC.extractShouldJoin(t),m=n?CC.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(Mg(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof US&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!JC(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new FC(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new jC(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(BS));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=CC.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent(Y.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(Y.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(Y.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(Y.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(Y.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,QS),this._charsetService.setgCharset(1,QS),this._charsetService.setgCharset(2,QS),this._charsetService.setgCharset(3,QS);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${Y.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=Rg.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=BS.fg,e.bg=BS.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=BS.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=BS.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=BS.fg&16777215,r.bg&=-67108864,r.bg|=BS.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Y.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Y.ESC}[${e};${t}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Y.ESC}[?${e};${t}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=BS.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`;break}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!JC(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${Y.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>qC&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>qC&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if($C(n))if(r===`?`)t.push({type:0,index:n});else{let e=HC(r);e&&t.push({type:1,index:n,color:e})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=HC(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);$C(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,QS),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(GC[e[0]],ZS[e[1]]||QS),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=BS.clone(),this._eraseAttrDataInternal=BS.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Bg;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${Y.ESC}${e}${Y.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},QC=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(XC=e,e=t,t=XC),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};QC=bg([K(0,qg)],QC);function $C(e){return 0<=e&&e<256}var ew=5e7,tw=12,nw=50,rw=class extends U_{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new q),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>ew)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=tw?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=tw)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>nw&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},iw=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};iw=bg([K(0,qg)],iw);var aw=!1,ow=class extends U_{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new W_),this._onBinary=this._register(new q),this.onBinary=this._onBinary.event,this._onData=this._register(new q),this.onData=this._onData.event,this._onLineFeed=this._register(new q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new q),this._instantiationService=new NS,this.optionsService=this._register(new sC(e)),this._instantiationService.setService($g,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(iC)),this._instantiationService.setService(qg,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(IS)),this._instantiationService.setService(Qg,this._logService),this.coreService=this._register(this._instantiationService.createInstance(fC)),this._instantiationService.setService(Yg,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(_C)),this._instantiationService.setService(Jg,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(CC)),this._instantiationService.setService(t_,this.unicodeService),this._charsetService=this._instantiationService.createInstance(wC),this._instantiationService.setService(Xg,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(iw),this._instantiationService.setService(e_,this._oscLinkService),this._inputHandler=this._register(new ZC(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Z_.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Z_.forward(this._bufferService.onResize,this._onResize)),this._register(Z_.forward(this.coreService.onData,this._onData)),this._register(Z_.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new rw((e,t)=>this._inputHandler.parse(e,t))),this._register(Z_.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new q),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!aw&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),aw=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,nC),t=Math.max(t,rC),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(TC.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(TC(this._bufferService),!1))),this._windowsWrappingHeuristics.value=B_(()=>{for(let t of e)t.dispose()})}}},sw={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function cw(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?t?i.key=Y.ESC+`OA`:i.key=Y.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?t?i.key=Y.ESC+`OD`:i.key=Y.ESC+`[D`:e.key===`UIKeyInputRightArrow`?t?i.key=Y.ESC+`OC`:i.key=Y.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(t?i.key=Y.ESC+`OB`:i.key=Y.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:Y.DEL,e.altKey&&(i.key=Y.ESC+i.key);break;case 9:if(e.shiftKey){i.key=Y.ESC+`[Z`;break}i.key=Y.HT,i.cancel=!0;break;case 13:i.key=e.altKey?Y.ESC+Y.CR:Y.CR,i.cancel=!0;break;case 27:i.key=Y.ESC,e.altKey&&(i.key=Y.ESC+Y.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;a?i.key=Y.ESC+`[1;`+(a+1)+`D`:t?i.key=Y.ESC+`OD`:i.key=Y.ESC+`[D`;break;case 39:if(e.metaKey)break;a?i.key=Y.ESC+`[1;`+(a+1)+`C`:t?i.key=Y.ESC+`OC`:i.key=Y.ESC+`[C`;break;case 38:if(e.metaKey)break;a?i.key=Y.ESC+`[1;`+(a+1)+`A`:t?i.key=Y.ESC+`OA`:i.key=Y.ESC+`[A`;break;case 40:if(e.metaKey)break;a?i.key=Y.ESC+`[1;`+(a+1)+`B`:t?i.key=Y.ESC+`OB`:i.key=Y.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=Y.ESC+`[2~`);break;case 46:a?i.key=Y.ESC+`[3;`+(a+1)+`~`:i.key=Y.ESC+`[3~`;break;case 36:a?i.key=Y.ESC+`[1;`+(a+1)+`H`:t?i.key=Y.ESC+`OH`:i.key=Y.ESC+`[H`;break;case 35:a?i.key=Y.ESC+`[1;`+(a+1)+`F`:t?i.key=Y.ESC+`OF`:i.key=Y.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=Y.ESC+`[5;`+(a+1)+`~`:i.key=Y.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=Y.ESC+`[6;`+(a+1)+`~`:i.key=Y.ESC+`[6~`;break;case 112:a?i.key=Y.ESC+`[1;`+(a+1)+`P`:i.key=Y.ESC+`OP`;break;case 113:a?i.key=Y.ESC+`[1;`+(a+1)+`Q`:i.key=Y.ESC+`OQ`;break;case 114:a?i.key=Y.ESC+`[1;`+(a+1)+`R`:i.key=Y.ESC+`OR`;break;case 115:a?i.key=Y.ESC+`[1;`+(a+1)+`S`:i.key=Y.ESC+`OS`;break;case 116:a?i.key=Y.ESC+`[15;`+(a+1)+`~`:i.key=Y.ESC+`[15~`;break;case 117:a?i.key=Y.ESC+`[17;`+(a+1)+`~`:i.key=Y.ESC+`[17~`;break;case 118:a?i.key=Y.ESC+`[18;`+(a+1)+`~`:i.key=Y.ESC+`[18~`;break;case 119:a?i.key=Y.ESC+`[19;`+(a+1)+`~`:i.key=Y.ESC+`[19~`;break;case 120:a?i.key=Y.ESC+`[20;`+(a+1)+`~`:i.key=Y.ESC+`[20~`;break;case 121:a?i.key=Y.ESC+`[21;`+(a+1)+`~`:i.key=Y.ESC+`[21~`;break;case 122:a?i.key=Y.ESC+`[23;`+(a+1)+`~`:i.key=Y.ESC+`[23~`;break;case 123:a?i.key=Y.ESC+`[24;`+(a+1)+`~`:i.key=Y.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=Y.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=Y.DEL:e.keyCode===219?i.key=Y.ESC:e.keyCode===220?i.key=Y.FS:e.keyCode===221&&(i.key=Y.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=sw[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=Y.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=Y.ESC+n}else if(e.keyCode===32)i.key=Y.ESC+(e.ctrlKey?Y.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=Y.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=Y.US),e.key===`@`&&(i.key=Y.NUL));break}return i}var lw=0,uw=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Xx,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Xx,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(lw=this._search(t),lw===-1)||this._getKey(this._array[lw])!==t)return!1;do if(this._array[lw]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(lw),!0;while(++lw<this._array.length&&this._getKey(this._array[lw])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(lw=this._search(e),!(lw<0||lw>=this._array.length)&&this._getKey(this._array[lw])===e))do yield this._array[lw];while(++lw<this._array.length&&this._getKey(this._array[lw])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(lw=this._search(e),!(lw<0||lw>=this._array.length)&&this._getKey(this._array[lw])===e))do t(this._array[lw]);while(++lw<this._array.length&&this._getKey(this._array[lw])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},dw=0,fw=0,pw=class extends U_{constructor(){super(),this._decorations=new uw(e=>e?.marker.line),this._onDecorationRegistered=this._register(new q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(B_(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new mw(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{dw=t.options.x??0,fw=dw+(t.options.width??1),e>=dw&&e<fw&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},mw=class extends H_{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new q),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Zb.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Zb.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},hw=1e3,gw=class{constructor(e,t=hw){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},_w=20,vw=class extends U_{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new gw(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
81
81
|
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(J(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(B_(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<_w+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
82
82
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===_w+1&&(this._liveRegion.textContent+=wg.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};vw=bg([K(1,Zg),K(2,o_),K(3,c_)],vw);var yw=class extends U_{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(B_(()=>{R_(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(J(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(J(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(J(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(J(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&bw(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,R_(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};yw=bg([K(1,s_),K(2,c_),K(3,qg),K(4,f_)],yw);function bw(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var xw=class extends ow{constructor(e={}){super(e),this._linkifier=this._register(new W_),this.browser=Nx,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new W_),this._onCursorMove=this._register(new q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new q),this.onKey=this._onKey.event,this._onRender=this._register(new q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new q),this.onBell=this._onBell.event,this._onFocus=this._register(new q),this._onBlur=this._register(new q),this._onA11yCharEmitter=this._register(new q),this._onA11yTabEmitter=this._register(new q),this._onWillOpen=this._register(new q),this._setup(),this._decorationService=this._instantiationService.createInstance(pw),this._instantiationService.setService(n_,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Ox),this._instantiationService.setService(f_,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(r_)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(Z_.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Z_.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Z_.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Z_.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(B_(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=Xb.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${Y.ESC}]${n};${WC(r)}${Hb.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=Yb.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=Yb.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(vw,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Y.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Y.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(J(this.element,`copy`,e=>{this.hasSelection()&&Dg(e,this._selectionService)}));let e=e=>Og(e,this.textarea,this.coreService,this.optionsService);this._register(J(this.textarea,`paste`,e)),this._register(J(this.element,`paste`,e)),Lx?this._register(J(this.element,`mousedown`,e=>{e.button===2&&jg(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(J(this.element,`contextmenu`,e=>{jg(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Gx&&this._register(J(this.element,`auxclick`,e=>{e.button===1&&Ag(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(J(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(J(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(J(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(J(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(J(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(J(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(J(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(J(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,Sg.get()),Kx||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Ex,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(o_,this._coreBrowserService),this._register(J(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(J(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Sx,this._document,this._helperContainer),this._instantiationService.setService(a_,this._charSizeService),this._themeService=this._instantiationService.createInstance(AS),this._instantiationService.setService(d_,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(rx),this._instantiationService.setService(u_,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Qx,this.rows,this.screenElement)),this._instantiationService.setService(c_,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(Ub,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(jx),this._instantiationService.setService(s_,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(yw,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Pb,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(bS,this.element,this.screenElement,r)),this._instantiationService.setService(l_,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(Z_.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Fb,this.screenElement)),this._register(J(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(vw,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Bb,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Bb,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(xx,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(J(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(J(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=Y.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){kg(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=cw(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===Y.ETX||n.key===Y.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Sw(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(BS));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent(Y.ESC+`[I`):this.coreService.triggerDataEvent(Y.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Y.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Y.ESC}[6;${r};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Sw(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Cw=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},ww=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Bg)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Tw=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new ww(t)}getNullCell(){return new Bg}},Ew=class extends U_{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new q),this.onBufferChange=this._onBufferChange.event,this._normal=new Tw(this._core.buffers.normal,`normal`),this._alternate=new Tw(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},Dw=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},Ow=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},kw=[`cols`,`rows`],Aw=0,jw=class extends U_{constructor(e){super(),this._core=this._register(new xw(e)),this._addonManager=this._register(new Cw),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(kw.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new Dw(this._core),this._parser}get unicode(){return this._checkProposedApi(),new Ow(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new Ew(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`;break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
83
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Sg.get()},set promptLabel(e){Sg.set(e)},get tooMuchOutput(){return wg.get()},set tooMuchOutput(e){wg.set(e)}}}_verifyIntegers(...e){for(Aw of e)if(Aw===1/0||isNaN(Aw)||Aw%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(Aw of e)if(Aw&&(Aw===1/0||isNaN(Aw)||Aw%1!=0||Aw<0))throw Error(`This API only accepts positive integers`)}},Mw=Object.create(null);Mw.open=`0`,Mw.close=`1`,Mw.ping=`2`,Mw.pong=`3`,Mw.message=`4`,Mw.upgrade=`5`,Mw.noop=`6`;var Nw=Object.create(null);Object.keys(Mw).forEach(e=>{Nw[Mw[e]]=e});var Pw={type:`error`,data:`parser error`},Fw=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,Iw=typeof ArrayBuffer==`function`,Lw=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Rw=({type:e,data:t},n,r)=>Fw&&t instanceof Blob?n?r(t):zw(t,r):Iw&&(t instanceof ArrayBuffer||Lw(t))?n?r(t):zw(new Blob([t]),r):r(Mw[e]+(t||``)),zw=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function Bw(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var Vw;function Hw(e,t){if(Fw&&e.data instanceof Blob)return e.data.arrayBuffer().then(Bw).then(t);if(Iw&&(e.data instanceof ArrayBuffer||Lw(e.data)))return t(Bw(e.data));Rw(e,!1,e=>{Vw||=new TextEncoder,t(Vw.encode(e))})}var Uw=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Ww=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)Ww[Uw.charCodeAt(e)]=e;var Gw=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=Ww[e.charCodeAt(r)],o=Ww[e.charCodeAt(r+1)],s=Ww[e.charCodeAt(r+2)],c=Ww[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},Kw=typeof ArrayBuffer==`function`,qw=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:Yw(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:Jw(e.substring(1),t)}:Nw[n]?e.length>1?{type:Nw[n],data:e.substring(1)}:{type:Nw[n]}:Pw},Jw=(e,t)=>Kw?Yw(Gw(e),t):{base64:!0,data:e},Yw=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},Xw=``,Zw=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{Rw(e,!1,e=>{r[a]=e,++i===n&&t(r.join(Xw))})})},Qw=(e,t)=>{let n=e.split(Xw),r=[];for(let e=0;e<n.length;e++){let i=qw(n[e],t);if(r.push(i),i.type===`error`)break}return r};function $w(){return new TransformStream({transform(e,t){Hw(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var eT;function tT(e){return e.reduce((e,t)=>e+t.length,0)}function nT(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function rT(e,t){eT||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(tT(n)<1)break;let e=nT(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(tT(n)<2)break;let e=nT(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(tT(n)<8)break;let e=nT(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(Pw);break}i=a*2**32+t.getUint32(4),r=3}else{if(tT(n)<i)break;let e=nT(n,i);s.enqueue(qw(a?e:eT.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(Pw);break}}}})}function iT(e){if(e)return aT(e)}function aT(e){for(var t in iT.prototype)e[t]=iT.prototype[t];return e}iT.prototype.on=iT.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},iT.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},iT.prototype.off=iT.prototype.removeListener=iT.prototype.removeAllListeners=iT.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},iT.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},iT.prototype.emitReserved=iT.prototype.emit,iT.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},iT.prototype.hasListeners=function(e){return!!this.listeners(e).length};var oT=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),sT=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),cT=`arraybuffer`;function lT(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var uT=sT.setTimeout,dT=sT.clearTimeout;function fT(e,t){t.useNativeTimers?(e.setTimeoutFn=uT.bind(sT),e.clearTimeoutFn=dT.bind(sT)):(e.setTimeoutFn=sT.setTimeout.bind(sT),e.clearTimeoutFn=sT.clearTimeout.bind(sT))}var pT=1.33;function mT(e){return typeof e==`string`?hT(e):Math.ceil((e.byteLength||e.size)*pT)}function hT(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function gT(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function _T(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function vT(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var yT=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},bT=class extends iT{constructor(e){super(),this.writable=!1,fT(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new yT(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=qw(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=_T(e);return t.length?`?`+t:``}},xT=class extends bT{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){Qw(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,Zw(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=gT()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},ST=!1;try{ST=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var CT=ST;function wT(){}var TT=class extends xT{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},ET=class e extends iT{constructor(e,t,n){super(),this.createRequest=e,fT(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=lT(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=wT,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(ET.requestsCount=0,ET.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,DT);else if(typeof addEventListener==`function`){let e=`onpagehide`in sT?`pagehide`:`unload`;addEventListener(e,DT,!1)}}function DT(){for(let e in ET.requests)ET.requests.hasOwnProperty(e)&&ET.requests[e].abort()}var OT=(function(){let e=AT({xdomain:!1});return e&&e.responseType!==null})(),kT=class extends TT{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=OT&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new ET(AT,this.uri(),e)}};function AT(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||CT))return new XMLHttpRequest}catch{}if(!t)try{return new sT[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var jT=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,MT=class extends bT{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=jT?{}:lT(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;Rw(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&oT(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=gT()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},NT=sT.WebSocket||sT.MozWebSocket,PT={websocket:class extends MT{createSocket(e,t,n){return jT?new NT(e,t,n):t?new NT(e,t):new NT(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends bT{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=rT(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=$w();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&oT(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:kT},FT=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,IT=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function LT(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=FT.exec(e||``),a={},o=14;for(;o--;)a[IT[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=RT(a,a.path),a.queryKey=zT(a,a.query),a}function RT(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function zT(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var BT=typeof addEventListener==`function`&&typeof removeEventListener==`function`,VT=[];BT&&addEventListener(`offline`,()=>{VT.forEach(e=>e())},!1);var HT=class e extends iT{constructor(e,t){if(super(),this.binaryType=cT,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=LT(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=LT(t.host).host);fT(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=vT(this.opts.query)),BT&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},VT.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=mT(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,oT(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),BT&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=VT.indexOf(this._offlineEventListener);e!==-1&&VT.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};HT.protocol=4;var UT=class extends HT{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;HT.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;HT.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},WT=class extends UT{constructor(e,t={}){let n=typeof e==`object`,r=n?{...e}:{...t};(!r.transports||r.transports&&typeof r.transports[0]==`string`)&&(r.transports=(r.transports||[`polling`,`websocket`,`webtransport`]).map(e=>PT[e]).filter(e=>!!e)),super(n?r:e,r)}};WT.protocol;function GT(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=LT(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var KT=typeof ArrayBuffer==`function`,qT=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,JT=Object.prototype.toString,YT=typeof Blob==`function`||typeof Blob<`u`&&JT.call(Blob)===`[object BlobConstructor]`,XT=typeof File==`function`||typeof File<`u`&&JT.call(File)===`[object FileConstructor]`;function ZT(e){return KT&&(e instanceof ArrayBuffer||qT(e))||YT&&e instanceof Blob||XT&&e instanceof File}function QT(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(QT(e[t]))return!0;return!1}if(ZT(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return QT(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&QT(e[t]))return!0;return!1}function $T(e){let t=[],n=e.data,r=e;return r.data=eE(n,t),r.attachments=t.length,{packet:r,buffers:t}}function eE(e,t,n){if(!e)return e;if(ZT(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=eE(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){if(e.toJSON&&typeof e.toJSON==`function`&&!n)return eE(e.toJSON(),t,!0);let r={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=eE(e[n],t));return r}return e}function tE(e,t){return e.data=nE(e.data,t),delete e.attachments,e}function nE(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=nE(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=nE(e[n],t));return e}var rE=s({Decoder:()=>sE,Encoder:()=>oE,PacketType:()=>aE,isPacketValid:()=>mE,protocol:()=>5}),iE=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],aE;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(aE||={});var oE=class{constructor(e){this.replacer=e}encode(e){return(e.type===aE.EVENT||e.type===aE.ACK)&&QT(e)?this.encodeAsBinary({type:e.type===aE.EVENT?aE.BINARY_EVENT:aE.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===aE.BINARY_EVENT||e.type===aE.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=$T(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},sE=class e extends iT{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===aE.BINARY_EVENT;n||t.type===aE.BINARY_ACK?(t.type=n?aE.EVENT:aE.ACK,this.reconstructor=new cE(t)):super.emitReserved(`decoded`,t)}else if(ZT(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(aE[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===aE.BINARY_EVENT||r.type===aE.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!uE(a)||a<1)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case aE.CONNECT:return fE(t);case aE.DISCONNECT:return t===void 0;case aE.CONNECT_ERROR:return typeof t==`string`||fE(t);case aE.EVENT:case aE.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&iE.indexOf(t[0])===-1);case aE.ACK:case aE.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},cE=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=tE(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function lE(e){return typeof e==`string`}var uE=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function dE(e){return e===void 0||uE(e)}function fE(e){return Object.prototype.toString.call(e)===`[object Object]`}function pE(e,t){switch(e){case aE.CONNECT:return t===void 0||fE(t);case aE.DISCONNECT:return t===void 0;case aE.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&iE.indexOf(t[0])===-1);case aE.ACK:return Array.isArray(t);case aE.CONNECT_ERROR:return typeof t==`string`||fE(t);default:return!1}}function mE(e){return lE(e.nsp)&&dE(e.id)&&pE(e.type,e.data)}function hE(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var gE=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),_E=class extends iT{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[hE(e,`open`,this.onopen.bind(this)),hE(e,`packet`,this.onpacket.bind(this)),hE(e,`error`,this.onerror.bind(this)),hE(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(gE.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:aE.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:aE.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case aE.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case aE.EVENT:case aE.BINARY_EVENT:this.onevent(e);break;case aE.ACK:case aE.BINARY_ACK:this.onack(e);break;case aE.DISCONNECT:this.ondisconnect();break;case aE.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:aE.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:aE.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function vE(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}vE.prototype.duration=function(){var e=this.ms*this.factor**+this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},vE.prototype.reset=function(){this.attempts=0},vE.prototype.setMin=function(e){this.ms=e},vE.prototype.setMax=function(e){this.max=e},vE.prototype.setJitter=function(e){this.jitter=e};var yE=class extends iT{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,fT(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new vE({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||rE;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new WT(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=hE(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=hE(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(hE(e,`ping`,this.onping.bind(this)),hE(e,`data`,this.ondata.bind(this)),hE(e,`error`,this.onerror.bind(this)),hE(e,`close`,this.onclose.bind(this)),hE(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){oT(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new _E(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},bE={};function xE(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=GT(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=bE[i]&&a in bE[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new yE(r,t):(bE[i]||(bE[i]=new yE(r,t)),c=bE[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(xE,{Manager:yE,Socket:_E,io:xE,connect:xE});var SE=class extends Error{method;path;constructor(e,t,n){super(`Treeport could not be reached`,{cause:n}),this.method=e,this.path=t,this.name=`RpcNetworkError`}},CE=Of(`/`,{fetch:async(e,t)=>{try{return await fetch(e,t)}catch(n){if(n instanceof Error&&n.name===`AbortError`)throw n;let r=e instanceof Request?e:null,i=new URL(r?.url??String(e),globalThis.location?.href??`http://localhost`);throw new SE(String(t?.method??r?.method??`GET`).toUpperCase().slice(0,16),i.pathname.slice(0,2048),n)}}}),wE=500,TE=80,EE=128;function DE(e,t){if(typeof e!=`string`)return null;let n=``;for(let t of e){let e=t.charCodeAt(0);n+=e<32||e===127?` `:t}let r=n.replace(/\s+/g,` `).trim();return r?r.length<=t?r:`${r.slice(0,t-1)}…`:null}function OE(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.requestId;return typeof t==`string`&&t.length<=EE&&/^[A-Za-z0-9_=-]+$/.test(t)?t:null}function kE(e){if(e instanceof SE)return{message:`Treeport could not be reached.`,code:null,details:null,status:null,statusText:null,requestId:null,method:e.method,path:e.path,networkFailure:!0,recoveryHint:`Check that it is running and reachable, then retry.`};if(e instanceof hf){let t=e.detail,n=t?.data,r=n&&typeof n==`object`&&!Array.isArray(n)?n.error:null,i=r&&typeof r==`object`&&!Array.isArray(r)?r:null,a=DE(i?.message,wE),o=DE(i?.code,100),s=i?.details??null,c=typeof e.statusCode==`number`&&e.statusCode>=100&&e.statusCode<=599?e.statusCode:null,l=DE(t?.statusText,TE),u=OE(s);if(a)return{message:a,code:o,details:s,status:c,statusText:l,requestId:u,method:null,path:null,networkFailure:!1,recoveryHint:o===`INTERNAL_ERROR`?`Retry. If the problem continues, use the reference when checking Treeport logs.`:null};let d=c?`${c}${l?` ${l}`:``}`:DE(e.message,TE);return{message:c&&[502,503,504].includes(c)?`The server or proxy returned ${d}.`:d?`The Treeport server returned ${d}.`:`The Treeport server returned an unexpected response.`,code:o,details:s,status:c,statusText:l,requestId:u,method:null,path:null,networkFailure:!1,recoveryHint:c&&[502,503,504].includes(c)?`Check that Treeport is running, then retry.`:null}}return{message:DE(e instanceof Error?e.message:String(e),wE)??`Unexpected error.`,code:null,details:null,status:null,statusText:null,requestId:null,method:null,path:null,networkFailure:!1,recoveryHint:null}}function AE(e){return kE(e).message}var jE;function X(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var ME=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},NE=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(jE=globalThis).__zod_globalConfig??(jE.__zod_globalConfig={});var PE=globalThis.__zod_globalConfig;function FE(e){return e&&Object.assign(PE,e),PE}function IE(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function LE(e,t){return typeof t==`bigint`?t.toString():t}function RE(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function zE(e){return e==null}function BE(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function VE(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var HE=Symbol(`evaluating`);function UE(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==HE)return r===void 0&&(r=HE,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function WE(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function GE(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function KE(e){return JSON.stringify(e)}function qE(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var JE=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function YE(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var XE=RE(()=>{if(PE.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function ZE(e){if(YE(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(YE(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function QE(e){return ZE(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var $E=new Set([`string`,`number`,`symbol`]);function eD(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function tD(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Z(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function nD(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var rD={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function iD(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return tD(e,GE(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return WE(this,`shape`,e),e},checks:[]}))}function aD(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return tD(e,GE(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return WE(this,`shape`,r),r},checks:[]}))}function oD(e,t){if(!ZE(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return tD(e,GE(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return WE(this,`shape`,n),n}}))}function sD(e,t){if(!ZE(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return tD(e,GE(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return WE(this,`shape`,n),n}}))}function cD(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return tD(e,GE(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return WE(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function lD(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return tD(t,GE(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return WE(this,`shape`,i),i},checks:[]}))}function uD(e,t,n){return tD(t,GE(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return WE(this,`shape`,i),i}}))}function dD(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function fD(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function pD(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function mD(e){return typeof e==`string`?e:e?.message}function hD(e,t,n){let r=e.message?e.message:mD(e.inst?._zod.def?.error?.(e))??mD(t?.error?.(e))??mD(n.customError?.(e))??mD(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function gD(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function _D(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var vD=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,LE,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},yD=X(`$ZodError`,vD),bD=X(`$ZodError`,vD,{Parent:Error});function xD(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function SD(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var CD=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new ME;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>hD(e,a,FE())));throw JE(t,i?.callee),t}return o.value},wD=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>hD(e,a,FE())));throw JE(t,i?.callee),t}return o.value},TD=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new ME;return a.issues.length?{success:!1,error:new(e??yD)(a.issues.map(e=>hD(e,i,FE())))}:{success:!0,data:a.value}},ED=TD(bD),DD=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>hD(e,i,FE())))}:{success:!0,data:a.value}},OD=DD(bD),kD=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return CD(e)(t,n,i)},AD=e=>(t,n,r)=>CD(e)(t,n,r),jD=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return wD(e)(t,n,i)},MD=e=>async(t,n,r)=>wD(e)(t,n,r),ND=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return TD(e)(t,n,i)},PD=e=>(t,n,r)=>TD(e)(t,n,r),FD=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return DD(e)(t,n,i)},ID=e=>async(t,n,r)=>DD(e)(t,n,r),LD=/^[cC][0-9a-z]{6,}$/,RD=/^[0-9a-z]+$/,zD=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,BD=/^[0-9a-vA-V]{20}$/,VD=/^[A-Za-z0-9]{27}$/,HD=/^[a-zA-Z0-9_-]{21}$/,UD=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,WD=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,GD=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,KD=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,qD=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function JD(){return new RegExp(qD,`u`)}var YD=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,XD=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ZD=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,QD=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,$D=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,eO=/^[A-Za-z0-9_-]*$/,tO=/^https?$/,nO=/^\+[1-9]\d{6,14}$/,rO=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,iO=RegExp(`^${rO}$`);function aO(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function oO(e){return RegExp(`^${aO(e)}$`)}function sO(e){let t=aO({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${rO}T(?:${r})$`)}var cO=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},lO=/^-?\d+$/,uO=/^-?\d+(?:\.\d+)?$/,dO=/^(?:true|false)$/i,fO=/^null$/i,pO=/^[^A-Z]*$/,mO=/^[^a-z]*$/,hO=X(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),gO={number:`number`,bigint:`bigint`,object:`date`},_O=X(`$ZodCheckLessThan`,(e,t)=>{hO.init(e,t);let n=gO[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),vO=X(`$ZodCheckGreaterThan`,(e,t)=>{hO.init(e,t);let n=gO[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),yO=X(`$ZodCheckMultipleOf`,(e,t)=>{hO.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):VE(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),bO=X(`$ZodCheckNumberFormat`,(e,t)=>{hO.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=rD[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=lO)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),xO=X(`$ZodCheckMaxLength`,(e,t)=>{var n;hO.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!zE(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=gD(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),SO=X(`$ZodCheckMinLength`,(e,t)=>{var n;hO.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!zE(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=gD(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),CO=X(`$ZodCheckLengthEquals`,(e,t)=>{var n;hO.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!zE(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=gD(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),wO=X(`$ZodCheckStringFormat`,(e,t)=>{var n,r;hO.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),TO=X(`$ZodCheckRegex`,(e,t)=>{wO.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),EO=X(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=pO,wO.init(e,t)}),DO=X(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=mO,wO.init(e,t)}),OO=X(`$ZodCheckIncludes`,(e,t)=>{hO.init(e,t);let n=eD(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),kO=X(`$ZodCheckStartsWith`,(e,t)=>{hO.init(e,t);let n=RegExp(`^${eD(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),AO=X(`$ZodCheckEndsWith`,(e,t)=>{hO.init(e,t);let n=RegExp(`.*${eD(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),jO=X(`$ZodCheckOverwrite`,(e,t)=>{hO.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),MO=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
83
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Sg.get()},set promptLabel(e){Sg.set(e)},get tooMuchOutput(){return wg.get()},set tooMuchOutput(e){wg.set(e)}}}_verifyIntegers(...e){for(Aw of e)if(Aw===1/0||isNaN(Aw)||Aw%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(Aw of e)if(Aw&&(Aw===1/0||isNaN(Aw)||Aw%1!=0||Aw<0))throw Error(`This API only accepts positive integers`)}},Mw=Object.create(null);Mw.open=`0`,Mw.close=`1`,Mw.ping=`2`,Mw.pong=`3`,Mw.message=`4`,Mw.upgrade=`5`,Mw.noop=`6`;var Nw=Object.create(null);Object.keys(Mw).forEach(e=>{Nw[Mw[e]]=e});var Pw={type:`error`,data:`parser error`},Fw=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,Iw=typeof ArrayBuffer==`function`,Lw=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Rw=({type:e,data:t},n,r)=>Fw&&t instanceof Blob?n?r(t):zw(t,r):Iw&&(t instanceof ArrayBuffer||Lw(t))?n?r(t):zw(new Blob([t]),r):r(Mw[e]+(t||``)),zw=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function Bw(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var Vw;function Hw(e,t){if(Fw&&e.data instanceof Blob)return e.data.arrayBuffer().then(Bw).then(t);if(Iw&&(e.data instanceof ArrayBuffer||Lw(e.data)))return t(Bw(e.data));Rw(e,!1,e=>{Vw||=new TextEncoder,t(Vw.encode(e))})}var Uw=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Ww=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)Ww[Uw.charCodeAt(e)]=e;var Gw=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=Ww[e.charCodeAt(r)],o=Ww[e.charCodeAt(r+1)],s=Ww[e.charCodeAt(r+2)],c=Ww[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},Kw=typeof ArrayBuffer==`function`,qw=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:Yw(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:Jw(e.substring(1),t)}:Nw[n]?e.length>1?{type:Nw[n],data:e.substring(1)}:{type:Nw[n]}:Pw},Jw=(e,t)=>Kw?Yw(Gw(e),t):{base64:!0,data:e},Yw=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},Xw=``,Zw=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{Rw(e,!1,e=>{r[a]=e,++i===n&&t(r.join(Xw))})})},Qw=(e,t)=>{let n=e.split(Xw),r=[];for(let e=0;e<n.length;e++){let i=qw(n[e],t);if(r.push(i),i.type===`error`)break}return r};function $w(){return new TransformStream({transform(e,t){Hw(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var eT;function tT(e){return e.reduce((e,t)=>e+t.length,0)}function nT(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function rT(e,t){eT||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(tT(n)<1)break;let e=nT(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(tT(n)<2)break;let e=nT(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(tT(n)<8)break;let e=nT(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(Pw);break}i=a*2**32+t.getUint32(4),r=3}else{if(tT(n)<i)break;let e=nT(n,i);s.enqueue(qw(a?e:eT.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(Pw);break}}}})}function iT(e){if(e)return aT(e)}function aT(e){for(var t in iT.prototype)e[t]=iT.prototype[t];return e}iT.prototype.on=iT.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},iT.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},iT.prototype.off=iT.prototype.removeListener=iT.prototype.removeAllListeners=iT.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},iT.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},iT.prototype.emitReserved=iT.prototype.emit,iT.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},iT.prototype.hasListeners=function(e){return!!this.listeners(e).length};var oT=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),sT=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),cT=`arraybuffer`;function lT(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var uT=sT.setTimeout,dT=sT.clearTimeout;function fT(e,t){t.useNativeTimers?(e.setTimeoutFn=uT.bind(sT),e.clearTimeoutFn=dT.bind(sT)):(e.setTimeoutFn=sT.setTimeout.bind(sT),e.clearTimeoutFn=sT.clearTimeout.bind(sT))}var pT=1.33;function mT(e){return typeof e==`string`?hT(e):Math.ceil((e.byteLength||e.size)*pT)}function hT(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function gT(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function _T(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function vT(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var yT=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},bT=class extends iT{constructor(e){super(),this.writable=!1,fT(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new yT(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=qw(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=_T(e);return t.length?`?`+t:``}},xT=class extends bT{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){Qw(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,Zw(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=gT()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},ST=!1;try{ST=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var CT=ST;function wT(){}var TT=class extends xT{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},ET=class e extends iT{constructor(e,t,n){super(),this.createRequest=e,fT(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=lT(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=wT,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(ET.requestsCount=0,ET.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,DT);else if(typeof addEventListener==`function`){let e=`onpagehide`in sT?`pagehide`:`unload`;addEventListener(e,DT,!1)}}function DT(){for(let e in ET.requests)ET.requests.hasOwnProperty(e)&&ET.requests[e].abort()}var OT=(function(){let e=AT({xdomain:!1});return e&&e.responseType!==null})(),kT=class extends TT{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=OT&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new ET(AT,this.uri(),e)}};function AT(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||CT))return new XMLHttpRequest}catch{}if(!t)try{return new sT[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var jT=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,MT=class extends bT{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=jT?{}:lT(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;Rw(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&oT(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=gT()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},NT=sT.WebSocket||sT.MozWebSocket,PT={websocket:class extends MT{createSocket(e,t,n){return jT?new NT(e,t,n):t?new NT(e,t):new NT(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends bT{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=rT(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=$w();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&oT(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:kT},FT=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,IT=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function LT(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=FT.exec(e||``),a={},o=14;for(;o--;)a[IT[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=RT(a,a.path),a.queryKey=zT(a,a.query),a}function RT(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function zT(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var BT=typeof addEventListener==`function`&&typeof removeEventListener==`function`,VT=[];BT&&addEventListener(`offline`,()=>{VT.forEach(e=>e())},!1);var HT=class e extends iT{constructor(e,t){if(super(),this.binaryType=cT,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=LT(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=LT(t.host).host);fT(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=vT(this.opts.query)),BT&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},VT.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=mT(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,oT(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),BT&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=VT.indexOf(this._offlineEventListener);e!==-1&&VT.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};HT.protocol=4;var UT=class extends HT{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;HT.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;HT.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},WT=class extends UT{constructor(e,t={}){let n=typeof e==`object`,r=n?{...e}:{...t};(!r.transports||r.transports&&typeof r.transports[0]==`string`)&&(r.transports=(r.transports||[`polling`,`websocket`,`webtransport`]).map(e=>PT[e]).filter(e=>!!e)),super(n?r:e,r)}};WT.protocol;function GT(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=LT(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var KT=typeof ArrayBuffer==`function`,qT=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,JT=Object.prototype.toString,YT=typeof Blob==`function`||typeof Blob<`u`&&JT.call(Blob)===`[object BlobConstructor]`,XT=typeof File==`function`||typeof File<`u`&&JT.call(File)===`[object FileConstructor]`;function ZT(e){return KT&&(e instanceof ArrayBuffer||qT(e))||YT&&e instanceof Blob||XT&&e instanceof File}function QT(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(QT(e[t]))return!0;return!1}if(ZT(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return QT(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&QT(e[t]))return!0;return!1}function $T(e){let t=[],n=e.data,r=e;return r.data=eE(n,t),r.attachments=t.length,{packet:r,buffers:t}}function eE(e,t,n){if(!e)return e;if(ZT(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=eE(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){if(e.toJSON&&typeof e.toJSON==`function`&&!n)return eE(e.toJSON(),t,!0);let r={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=eE(e[n],t));return r}return e}function tE(e,t){return e.data=nE(e.data,t),delete e.attachments,e}function nE(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=nE(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=nE(e[n],t));return e}var rE=s({Decoder:()=>sE,Encoder:()=>oE,PacketType:()=>aE,isPacketValid:()=>mE,protocol:()=>5}),iE=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],aE;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(aE||={});var oE=class{constructor(e){this.replacer=e}encode(e){return(e.type===aE.EVENT||e.type===aE.ACK)&&QT(e)?this.encodeAsBinary({type:e.type===aE.EVENT?aE.BINARY_EVENT:aE.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===aE.BINARY_EVENT||e.type===aE.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=$T(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},sE=class e extends iT{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===aE.BINARY_EVENT;n||t.type===aE.BINARY_ACK?(t.type=n?aE.EVENT:aE.ACK,this.reconstructor=new cE(t)):super.emitReserved(`decoded`,t)}else if(ZT(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(aE[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===aE.BINARY_EVENT||r.type===aE.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!uE(a)||a<1)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case aE.CONNECT:return fE(t);case aE.DISCONNECT:return t===void 0;case aE.CONNECT_ERROR:return typeof t==`string`||fE(t);case aE.EVENT:case aE.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&iE.indexOf(t[0])===-1);case aE.ACK:case aE.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},cE=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=tE(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function lE(e){return typeof e==`string`}var uE=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function dE(e){return e===void 0||uE(e)}function fE(e){return Object.prototype.toString.call(e)===`[object Object]`}function pE(e,t){switch(e){case aE.CONNECT:return t===void 0||fE(t);case aE.DISCONNECT:return t===void 0;case aE.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&iE.indexOf(t[0])===-1);case aE.ACK:return Array.isArray(t);case aE.CONNECT_ERROR:return typeof t==`string`||fE(t);default:return!1}}function mE(e){return lE(e.nsp)&&dE(e.id)&&pE(e.type,e.data)}function hE(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var gE=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),_E=class extends iT{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[hE(e,`open`,this.onopen.bind(this)),hE(e,`packet`,this.onpacket.bind(this)),hE(e,`error`,this.onerror.bind(this)),hE(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(gE.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:aE.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:aE.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case aE.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case aE.EVENT:case aE.BINARY_EVENT:this.onevent(e);break;case aE.ACK:case aE.BINARY_ACK:this.onack(e);break;case aE.DISCONNECT:this.ondisconnect();break;case aE.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:aE.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:aE.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function vE(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}vE.prototype.duration=function(){var e=this.ms*this.factor**+this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},vE.prototype.reset=function(){this.attempts=0},vE.prototype.setMin=function(e){this.ms=e},vE.prototype.setMax=function(e){this.max=e},vE.prototype.setJitter=function(e){this.jitter=e};var yE=class extends iT{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,fT(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new vE({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||rE;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new WT(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=hE(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=hE(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(hE(e,`ping`,this.onping.bind(this)),hE(e,`data`,this.ondata.bind(this)),hE(e,`error`,this.onerror.bind(this)),hE(e,`close`,this.onclose.bind(this)),hE(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){oT(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new _E(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},bE={};function xE(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=GT(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=bE[i]&&a in bE[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new yE(r,t):(bE[i]||(bE[i]=new yE(r,t)),c=bE[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(xE,{Manager:yE,Socket:_E,io:xE,connect:xE});var SE;function X(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var CE=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},wE=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(SE=globalThis).__zod_globalConfig??(SE.__zod_globalConfig={});var TE=globalThis.__zod_globalConfig;function EE(e){return e&&Object.assign(TE,e),TE}function DE(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function OE(e,t){return typeof t==`bigint`?t.toString():t}function kE(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function AE(e){return e==null}function jE(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ME(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var NE=Symbol(`evaluating`);function PE(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==NE)return r===void 0&&(r=NE,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function FE(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function IE(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function LE(e){return JSON.stringify(e)}function RE(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var zE=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function BE(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var VE=kE(()=>{if(TE.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function HE(e){if(BE(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(BE(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function UE(e){return HE(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var WE=new Set([`string`,`number`,`symbol`]);function GE(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function KE(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Z(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function qE(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var JE={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function YE(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return KE(e,IE(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return FE(this,`shape`,e),e},checks:[]}))}function XE(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return KE(e,IE(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return FE(this,`shape`,r),r},checks:[]}))}function ZE(e,t){if(!HE(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return KE(e,IE(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return FE(this,`shape`,n),n}}))}function QE(e,t){if(!HE(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return KE(e,IE(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return FE(this,`shape`,n),n}}))}function $E(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return KE(e,IE(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return FE(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function eD(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return KE(t,IE(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return FE(this,`shape`,i),i},checks:[]}))}function tD(e,t,n){return KE(t,IE(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return FE(this,`shape`,i),i}}))}function nD(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function rD(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function iD(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function aD(e){return typeof e==`string`?e:e?.message}function oD(e,t,n){let r=e.message?e.message:aD(e.inst?._zod.def?.error?.(e))??aD(t?.error?.(e))??aD(n.customError?.(e))??aD(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function sD(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function cD(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var lD=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,OE,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},uD=X(`$ZodError`,lD),dD=X(`$ZodError`,lD,{Parent:Error});function fD(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function pD(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var mD=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new CE;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>oD(e,a,EE())));throw zE(t,i?.callee),t}return o.value},hD=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>oD(e,a,EE())));throw zE(t,i?.callee),t}return o.value},gD=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new CE;return a.issues.length?{success:!1,error:new(e??uD)(a.issues.map(e=>oD(e,i,EE())))}:{success:!0,data:a.value}},_D=gD(dD),vD=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>oD(e,i,EE())))}:{success:!0,data:a.value}},yD=vD(dD),bD=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return mD(e)(t,n,i)},xD=e=>(t,n,r)=>mD(e)(t,n,r),SD=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return hD(e)(t,n,i)},CD=e=>async(t,n,r)=>hD(e)(t,n,r),wD=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return gD(e)(t,n,i)},TD=e=>(t,n,r)=>gD(e)(t,n,r),ED=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return vD(e)(t,n,i)},DD=e=>async(t,n,r)=>vD(e)(t,n,r),OD=/^[cC][0-9a-z]{6,}$/,kD=/^[0-9a-z]+$/,AD=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,jD=/^[0-9a-vA-V]{20}$/,MD=/^[A-Za-z0-9]{27}$/,ND=/^[a-zA-Z0-9_-]{21}$/,PD=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,FD=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ID=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,LD=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,RD=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function zD(){return new RegExp(RD,`u`)}var BD=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,VD=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,HD=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,UD=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,WD=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,GD=/^[A-Za-z0-9_-]*$/,KD=/^https?$/,qD=/^\+[1-9]\d{6,14}$/,JD=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,YD=RegExp(`^${JD}$`);function XD(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ZD(e){return RegExp(`^${XD(e)}$`)}function QD(e){let t=XD({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${JD}T(?:${r})$`)}var $D=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},eO=/^-?\d+$/,tO=/^-?\d+(?:\.\d+)?$/,nO=/^(?:true|false)$/i,rO=/^null$/i,iO=/^[^A-Z]*$/,aO=/^[^a-z]*$/,oO=X(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),sO={number:`number`,bigint:`bigint`,object:`date`},cO=X(`$ZodCheckLessThan`,(e,t)=>{oO.init(e,t);let n=sO[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),lO=X(`$ZodCheckGreaterThan`,(e,t)=>{oO.init(e,t);let n=sO[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),uO=X(`$ZodCheckMultipleOf`,(e,t)=>{oO.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):ME(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),dO=X(`$ZodCheckNumberFormat`,(e,t)=>{oO.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=JE[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=eO)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),fO=X(`$ZodCheckMaxLength`,(e,t)=>{var n;oO.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!AE(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=sD(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),pO=X(`$ZodCheckMinLength`,(e,t)=>{var n;oO.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!AE(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=sD(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),mO=X(`$ZodCheckLengthEquals`,(e,t)=>{var n;oO.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!AE(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=sD(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),hO=X(`$ZodCheckStringFormat`,(e,t)=>{var n,r;oO.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),gO=X(`$ZodCheckRegex`,(e,t)=>{hO.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),_O=X(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=iO,hO.init(e,t)}),vO=X(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=aO,hO.init(e,t)}),yO=X(`$ZodCheckIncludes`,(e,t)=>{oO.init(e,t);let n=GE(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),bO=X(`$ZodCheckStartsWith`,(e,t)=>{oO.init(e,t);let n=RegExp(`^${GE(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),xO=X(`$ZodCheckEndsWith`,(e,t)=>{oO.init(e,t);let n=RegExp(`.*${GE(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),SO=X(`$ZodCheckOverwrite`,(e,t)=>{oO.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),CO=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
84
84
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
85
|
-
`))}},
|
|
85
|
+
`))}},wO={major:4,minor:4,patch:3},TO=X(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=wO;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=nD(e),i;for(let a of t){if(a._zod.def.when){if(rD(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new CE;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=nD(e,t))});else{if(e.issues.length===t)continue;r||=nD(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(nD(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new CE;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new CE;return o.then(e=>t(e,r,a))}return t(o,r,a)}}PE(e,`~standard`,()=>({validate:t=>{try{let n=_D(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return yD(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),EO=X(`$ZodString`,(e,t)=>{TO.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??$D(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),DO=X(`$ZodStringFormat`,(e,t)=>{hO.init(e,t),EO.init(e,t)}),OO=X(`$ZodGUID`,(e,t)=>{t.pattern??=FD,DO.init(e,t)}),kO=X(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=ID(e)}else t.pattern??=ID();DO.init(e,t)}),AO=X(`$ZodEmail`,(e,t)=>{t.pattern??=LD,DO.init(e,t)}),jO=X(`$ZodURL`,(e,t)=>{DO.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===KD.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),MO=X(`$ZodEmoji`,(e,t)=>{t.pattern??=zD(),DO.init(e,t)}),NO=X(`$ZodNanoID`,(e,t)=>{t.pattern??=ND,DO.init(e,t)}),PO=X(`$ZodCUID`,(e,t)=>{t.pattern??=OD,DO.init(e,t)}),FO=X(`$ZodCUID2`,(e,t)=>{t.pattern??=kD,DO.init(e,t)}),IO=X(`$ZodULID`,(e,t)=>{t.pattern??=AD,DO.init(e,t)}),LO=X(`$ZodXID`,(e,t)=>{t.pattern??=jD,DO.init(e,t)}),RO=X(`$ZodKSUID`,(e,t)=>{t.pattern??=MD,DO.init(e,t)}),zO=X(`$ZodISODateTime`,(e,t)=>{t.pattern??=QD(t),DO.init(e,t)}),BO=X(`$ZodISODate`,(e,t)=>{t.pattern??=YD,DO.init(e,t)}),VO=X(`$ZodISOTime`,(e,t)=>{t.pattern??=ZD(t),DO.init(e,t)}),HO=X(`$ZodISODuration`,(e,t)=>{t.pattern??=PD,DO.init(e,t)}),UO=X(`$ZodIPv4`,(e,t)=>{t.pattern??=BD,DO.init(e,t),e._zod.bag.format=`ipv4`}),WO=X(`$ZodIPv6`,(e,t)=>{t.pattern??=VD,DO.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),GO=X(`$ZodCIDRv4`,(e,t)=>{t.pattern??=HD,DO.init(e,t)}),KO=X(`$ZodCIDRv6`,(e,t)=>{t.pattern??=UD,DO.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function qO(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var JO=X(`$ZodBase64`,(e,t)=>{t.pattern??=WD,DO.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{qO(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function YO(e){if(!GD.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return qO(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var XO=X(`$ZodBase64URL`,(e,t)=>{t.pattern??=GD,DO.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{YO(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ZO=X(`$ZodE164`,(e,t)=>{t.pattern??=qD,DO.init(e,t)});function QO(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var $O=X(`$ZodJWT`,(e,t)=>{DO.init(e,t),e._zod.check=n=>{QO(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ek=X(`$ZodNumber`,(e,t)=>{TO.init(e,t),e._zod.pattern=e._zod.bag.pattern??tO,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),tk=X(`$ZodNumberFormat`,(e,t)=>{dO.init(e,t),ek.init(e,t)}),nk=X(`$ZodBoolean`,(e,t)=>{TO.init(e,t),e._zod.pattern=nO,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),rk=X(`$ZodNull`,(e,t)=>{TO.init(e,t),e._zod.pattern=rO,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),ik=X(`$ZodUnknown`,(e,t)=>{TO.init(e,t),e._zod.parse=e=>e}),ak=X(`$ZodNever`,(e,t)=>{TO.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function ok(e,t,n){e.issues.length&&t.issues.push(...iD(n,e.issues)),t.value[n]=e.value}var sk=X(`$ZodArray`,(e,t)=>{TO.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>ok(t,n,e))):ok(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function ck(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...iD(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function lk(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=qE(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function uk(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ck(e,n,i,t,u,d))):ck(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var dk=X(`$ZodObject`,(e,t)=>{if(TO.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=kE(()=>lk(t));PE(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=BE,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>ck(n,t,e,s,r,i))):ck(a,t,e,s,r,i)}return i?uk(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),fk=X(`$ZodObjectJIT`,(e,t)=>{dk.init(e,t);let n=e._zod.parse,r=kE(()=>lk(t)),i=e=>{let t=new CO([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=LE(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=LE(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
86
86
|
if (${n}.issues.length) {
|
|
87
87
|
if (${o} in input) {
|
|
88
88
|
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
@@ -141,6 +141,6 @@ ${s.join(`
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=YE,s=!PE.jitless,c=s&&XE.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?yk([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Sk(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!dD(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>hD(e,r,FE())))}),t)}var Ck=X(`$ZodUnion`,(e,t)=>{PO.init(e,t),UE(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),UE(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),UE(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),UE(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>BE(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Sk(t,r,e,i)):Sk(o,r,e,i)}}),wk=X(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Ck.init(e,t);let n=e._zod.parse;UE(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=RE(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!YE(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),Tk=X(`$ZodIntersection`,(e,t)=>{PO.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Dk(e,t,n)):Dk(e,i,a)}});function Ek(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ZE(e)&&ZE(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Ek(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ek(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Dk(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),dD(e))return e;let o=Ek(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Ok=X(`$ZodRecord`,(e,t)=>{PO.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!ZE(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>hD(e,r,FE())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...pD(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...pD(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&uO.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>hD(e,r,FE())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...pD(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...pD(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),kk=X(`$ZodEnum`,(e,t)=>{PO.init(e,t);let n=IE(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>$E.has(typeof e)).map(e=>typeof e==`string`?eD(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Ak=X(`$ZodLiteral`,(e,t)=>{if(PO.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?eD(e):e?eD(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),jk=X(`$ZodTransform`,(e,t)=>{PO.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new NE(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new ME;return n.value=i,n.fallback=!0,n}});function Mk(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Nk=X(`$ZodOptional`,(e,t)=>{PO.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,UE(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),UE(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${BE(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Mk(e,r)):Mk(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Pk=X(`$ZodExactOptional`,(e,t)=>{Nk.init(e,t),UE(e._zod,`values`,()=>t.innerType._zod.values),UE(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Fk=X(`$ZodNullable`,(e,t)=>{PO.init(e,t),UE(e._zod,`optin`,()=>t.innerType._zod.optin),UE(e._zod,`optout`,()=>t.innerType._zod.optout),UE(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${BE(e.source)}|null)$`):void 0}),UE(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ik=X(`$ZodDefault`,(e,t)=>{PO.init(e,t),e._zod.optin=`optional`,UE(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Lk(e,t)):Lk(r,t)}});function Lk(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Rk=X(`$ZodPrefault`,(e,t)=>{PO.init(e,t),e._zod.optin=`optional`,UE(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),zk=X(`$ZodNonOptional`,(e,t)=>{PO.init(e,t),UE(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Bk(t,e)):Bk(i,e)}});function Bk(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Vk=X(`$ZodCatch`,(e,t)=>{PO.init(e,t),e._zod.optin=`optional`,UE(e._zod,`optout`,()=>t.innerType._zod.optout),UE(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>hD(e,n,FE()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>hD(e,n,FE()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Hk=X(`$ZodPipe`,(e,t)=>{PO.init(e,t),UE(e._zod,`values`,()=>t.in._zod.values),UE(e._zod,`optin`,()=>t.in._zod.optin),UE(e._zod,`optout`,()=>t.out._zod.optout),UE(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Uk(e,t.in,n)):Uk(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Uk(e,t.out,n)):Uk(r,t.out,n)}});function Uk(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Wk=X(`$ZodReadonly`,(e,t)=>{PO.init(e,t),UE(e._zod,`propValues`,()=>t.innerType._zod.propValues),UE(e._zod,`values`,()=>t.innerType._zod.values),UE(e._zod,`optin`,()=>t.innerType?._zod?.optin),UE(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Gk):Gk(r)}});function Gk(e){return e.value=Object.freeze(e.value),e}var Kk=X(`$ZodLazy`,(e,t)=>{PO.init(e,t),UE(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),UE(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),UE(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),UE(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),UE(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),qk=X(`$ZodCustom`,(e,t)=>{hO.init(e,t),PO.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Jk(t,n,r,e));Jk(i,n,r,e)}});function Jk(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(_D(e))}}var Yk,Xk=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Zk(){return new Xk}(Yk=globalThis).__zod_globalRegistry??(Yk.__zod_globalRegistry=Zk());var Qk=globalThis.__zod_globalRegistry;function $k(e,t){return new e({type:`string`,...Z(t)})}function eA(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Z(t)})}function tA(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Z(t)})}function nA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Z(t)})}function rA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Z(t)})}function iA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Z(t)})}function aA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Z(t)})}function oA(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Z(t)})}function sA(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Z(t)})}function cA(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Z(t)})}function lA(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Z(t)})}function uA(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Z(t)})}function dA(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Z(t)})}function fA(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Z(t)})}function pA(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Z(t)})}function mA(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Z(t)})}function hA(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Z(t)})}function gA(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Z(t)})}function _A(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Z(t)})}function vA(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Z(t)})}function yA(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Z(t)})}function bA(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Z(t)})}function xA(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Z(t)})}function SA(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Z(t)})}function CA(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Z(t)})}function wA(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Z(t)})}function TA(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Z(t)})}function EA(e,t){return new e({type:`number`,checks:[],...Z(t)})}function DA(e,t){return new e({type:`number`,coerce:!0,checks:[],...Z(t)})}function OA(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...Z(t)})}function kA(e,t){return new e({type:`boolean`,...Z(t)})}function AA(e,t){return new e({type:`null`,...Z(t)})}function jA(e){return new e({type:`unknown`})}function MA(e,t){return new e({type:`never`,...Z(t)})}function NA(e,t){return new _O({check:`less_than`,...Z(t),value:e,inclusive:!1})}function PA(e,t){return new _O({check:`less_than`,...Z(t),value:e,inclusive:!0})}function FA(e,t){return new vO({check:`greater_than`,...Z(t),value:e,inclusive:!1})}function IA(e,t){return new vO({check:`greater_than`,...Z(t),value:e,inclusive:!0})}function LA(e,t){return new yO({check:`multiple_of`,...Z(t),value:e})}function RA(e,t){return new xO({check:`max_length`,...Z(t),maximum:e})}function zA(e,t){return new SO({check:`min_length`,...Z(t),minimum:e})}function BA(e,t){return new CO({check:`length_equals`,...Z(t),length:e})}function VA(e,t){return new TO({check:`string_format`,format:`regex`,...Z(t),pattern:e})}function HA(e){return new EO({check:`string_format`,format:`lowercase`,...Z(e)})}function UA(e){return new DO({check:`string_format`,format:`uppercase`,...Z(e)})}function WA(e,t){return new OO({check:`string_format`,format:`includes`,...Z(t),includes:e})}function GA(e,t){return new kO({check:`string_format`,format:`starts_with`,...Z(t),prefix:e})}function KA(e,t){return new AO({check:`string_format`,format:`ends_with`,...Z(t),suffix:e})}function qA(e){return new jO({check:`overwrite`,tx:e})}function JA(e){return qA(t=>t.normalize(e))}function YA(){return qA(e=>e.trim())}function XA(){return qA(e=>e.toLowerCase())}function ZA(){return qA(e=>e.toUpperCase())}function QA(){return qA(e=>qE(e))}function $A(e,t,n){return new e({type:`array`,element:t,...Z(n)})}function ej(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Z(n)})}function tj(e,t){let n=nj(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(_D(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(_D(r))}},e(t.value,t)),t);return n}function nj(e,t){let n=new hO({check:`custom`,...Z(t)});return n._zod.check=e,n}function rj(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Qk,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function ij(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,ij(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&sj(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function aj(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
144
|
+
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=BE,s=!TE.jitless,c=s&&VE.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?uk([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function pk(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!nD(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>oD(e,r,EE())))}),t)}var mk=X(`$ZodUnion`,(e,t)=>{TO.init(e,t),PE(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),PE(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),PE(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),PE(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>jE(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>pk(t,r,e,i)):pk(o,r,e,i)}}),hk=X(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,mk.init(e,t);let n=e._zod.parse;PE(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=kE(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!BE(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),gk=X(`$ZodIntersection`,(e,t)=>{TO.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>vk(e,t,n)):vk(e,i,a)}});function _k(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(HE(e)&&HE(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=_k(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=_k(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function vk(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),nD(e))return e;let o=_k(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var yk=X(`$ZodRecord`,(e,t)=>{TO.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!HE(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>oD(e,r,EE())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...iD(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...iD(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&tO.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>oD(e,r,EE())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...iD(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...iD(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),bk=X(`$ZodEnum`,(e,t)=>{TO.init(e,t);let n=DE(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>WE.has(typeof e)).map(e=>typeof e==`string`?GE(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),xk=X(`$ZodLiteral`,(e,t)=>{if(TO.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?GE(e):e?GE(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Sk=X(`$ZodTransform`,(e,t)=>{TO.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new wE(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new CE;return n.value=i,n.fallback=!0,n}});function Ck(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var wk=X(`$ZodOptional`,(e,t)=>{TO.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,PE(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),PE(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${jE(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Ck(e,r)):Ck(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Tk=X(`$ZodExactOptional`,(e,t)=>{wk.init(e,t),PE(e._zod,`values`,()=>t.innerType._zod.values),PE(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ek=X(`$ZodNullable`,(e,t)=>{TO.init(e,t),PE(e._zod,`optin`,()=>t.innerType._zod.optin),PE(e._zod,`optout`,()=>t.innerType._zod.optout),PE(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${jE(e.source)}|null)$`):void 0}),PE(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Dk=X(`$ZodDefault`,(e,t)=>{TO.init(e,t),e._zod.optin=`optional`,PE(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ok(e,t)):Ok(r,t)}});function Ok(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var kk=X(`$ZodPrefault`,(e,t)=>{TO.init(e,t),e._zod.optin=`optional`,PE(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ak=X(`$ZodNonOptional`,(e,t)=>{TO.init(e,t),PE(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>jk(t,e)):jk(i,e)}});function jk(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Mk=X(`$ZodCatch`,(e,t)=>{TO.init(e,t),e._zod.optin=`optional`,PE(e._zod,`optout`,()=>t.innerType._zod.optout),PE(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>oD(e,n,EE()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>oD(e,n,EE()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Nk=X(`$ZodPipe`,(e,t)=>{TO.init(e,t),PE(e._zod,`values`,()=>t.in._zod.values),PE(e._zod,`optin`,()=>t.in._zod.optin),PE(e._zod,`optout`,()=>t.out._zod.optout),PE(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Pk(e,t.in,n)):Pk(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Pk(e,t.out,n)):Pk(r,t.out,n)}});function Pk(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Fk=X(`$ZodReadonly`,(e,t)=>{TO.init(e,t),PE(e._zod,`propValues`,()=>t.innerType._zod.propValues),PE(e._zod,`values`,()=>t.innerType._zod.values),PE(e._zod,`optin`,()=>t.innerType?._zod?.optin),PE(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ik):Ik(r)}});function Ik(e){return e.value=Object.freeze(e.value),e}var Lk=X(`$ZodLazy`,(e,t)=>{TO.init(e,t),PE(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),PE(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),PE(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),PE(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),PE(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Rk=X(`$ZodCustom`,(e,t)=>{oO.init(e,t),TO.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>zk(t,n,r,e));zk(i,n,r,e)}});function zk(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(cD(e))}}var Bk,Vk=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Hk(){return new Vk}(Bk=globalThis).__zod_globalRegistry??(Bk.__zod_globalRegistry=Hk());var Uk=globalThis.__zod_globalRegistry;function Wk(e,t){return new e({type:`string`,...Z(t)})}function Gk(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Z(t)})}function Kk(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Z(t)})}function qk(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Z(t)})}function Jk(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Z(t)})}function Yk(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Z(t)})}function Xk(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Z(t)})}function Zk(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Z(t)})}function Qk(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Z(t)})}function $k(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Z(t)})}function eA(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Z(t)})}function tA(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Z(t)})}function nA(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Z(t)})}function rA(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Z(t)})}function iA(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Z(t)})}function aA(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Z(t)})}function oA(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Z(t)})}function sA(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Z(t)})}function cA(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Z(t)})}function lA(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Z(t)})}function uA(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Z(t)})}function dA(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Z(t)})}function fA(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Z(t)})}function pA(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Z(t)})}function mA(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Z(t)})}function hA(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Z(t)})}function gA(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Z(t)})}function _A(e,t){return new e({type:`number`,checks:[],...Z(t)})}function vA(e,t){return new e({type:`number`,coerce:!0,checks:[],...Z(t)})}function yA(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...Z(t)})}function bA(e,t){return new e({type:`boolean`,...Z(t)})}function xA(e,t){return new e({type:`null`,...Z(t)})}function SA(e){return new e({type:`unknown`})}function CA(e,t){return new e({type:`never`,...Z(t)})}function wA(e,t){return new cO({check:`less_than`,...Z(t),value:e,inclusive:!1})}function TA(e,t){return new cO({check:`less_than`,...Z(t),value:e,inclusive:!0})}function EA(e,t){return new lO({check:`greater_than`,...Z(t),value:e,inclusive:!1})}function DA(e,t){return new lO({check:`greater_than`,...Z(t),value:e,inclusive:!0})}function OA(e,t){return new uO({check:`multiple_of`,...Z(t),value:e})}function kA(e,t){return new fO({check:`max_length`,...Z(t),maximum:e})}function AA(e,t){return new pO({check:`min_length`,...Z(t),minimum:e})}function jA(e,t){return new mO({check:`length_equals`,...Z(t),length:e})}function MA(e,t){return new gO({check:`string_format`,format:`regex`,...Z(t),pattern:e})}function NA(e){return new _O({check:`string_format`,format:`lowercase`,...Z(e)})}function PA(e){return new vO({check:`string_format`,format:`uppercase`,...Z(e)})}function FA(e,t){return new yO({check:`string_format`,format:`includes`,...Z(t),includes:e})}function IA(e,t){return new bO({check:`string_format`,format:`starts_with`,...Z(t),prefix:e})}function LA(e,t){return new xO({check:`string_format`,format:`ends_with`,...Z(t),suffix:e})}function RA(e){return new SO({check:`overwrite`,tx:e})}function zA(e){return RA(t=>t.normalize(e))}function BA(){return RA(e=>e.trim())}function VA(){return RA(e=>e.toLowerCase())}function HA(){return RA(e=>e.toUpperCase())}function UA(){return RA(e=>RE(e))}function WA(e,t,n){return new e({type:`array`,element:t,...Z(n)})}function GA(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Z(n)})}function KA(e,t){let n=qA(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(cD(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(cD(r))}},e(t.value,t)),t);return n}function qA(e,t){let n=new oO({check:`custom`,...Z(t)});return n._zod.check=e,n}function JA(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Uk,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function YA(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,YA(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&QA(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function XA(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
145
145
|
|
|
146
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function oj(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:lj(t,`input`,e.processors),output:lj(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function sj(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return sj(r.element,n);if(r.type===`set`)return sj(r.valueType,n);if(r.type===`lazy`)return sj(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return sj(r.innerType,n);if(r.type===`intersection`)return sj(r.left,n)||sj(r.right,n);if(r.type===`record`||r.type===`map`)return sj(r.keyType,n)||sj(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:sj(r.in,n)||sj(r.out,n);if(r.type===`object`){for(let e in r.shape)if(sj(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(sj(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(sj(e,n))return!0;return!!(r.rest&&sj(r.rest,n))}return!1}var cj=(e,t={})=>n=>{let r=rj({...n,processors:t});return ij(e,r),aj(r,e),oj(r,e)},lj=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=rj({...i??{},target:a,io:t,processors:n});return ij(e,o),aj(o,e),oj(o,e)},uj={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},dj=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=uj[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},fj=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},pj=(e,t,n,r)=>{n.type=`boolean`},mj=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},hj=(e,t,n,r)=>{n.not={}},gj=(e,t,n,r)=>{let i=e._zod.def,a=IE(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},_j=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},vj=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},yj=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},bj=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=ij(a.element,t,{...r,path:[...r.path,`items`]})},xj=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=ij(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=ij(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Sj=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>ij(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Cj=(e,t,n,r)=>{let i=e._zod.def,a=ij(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=ij(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},wj=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=ij(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=ij(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=ij(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Tj=(e,t,n,r)=>{let i=e._zod.def,a=ij(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ej=(e,t,n,r)=>{let i=e._zod.def;ij(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Dj=(e,t,n,r)=>{let i=e._zod.def;ij(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Oj=(e,t,n,r)=>{let i=e._zod.def;ij(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},kj=(e,t,n,r)=>{let i=e._zod.def;ij(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Aj=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;ij(o,t,r);let s=t.seen.get(e);s.ref=o},jj=(e,t,n,r)=>{let i=e._zod.def;ij(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Mj=(e,t,n,r)=>{let i=e._zod.def;ij(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Nj=(e,t,n,r)=>{let i=e._zod.innerType;ij(i,t,r);let a=t.seen.get(e);a.ref=i},Pj=X(`ZodISODateTime`,(e,t)=>{JO.init(e,t),oM.init(e,t)});function Fj(e){return SA(Pj,e)}var Ij=X(`ZodISODate`,(e,t)=>{YO.init(e,t),oM.init(e,t)});function Lj(e){return CA(Ij,e)}var Rj=X(`ZodISOTime`,(e,t)=>{XO.init(e,t),oM.init(e,t)});function zj(e){return wA(Rj,e)}var Bj=X(`ZodISODuration`,(e,t)=>{ZO.init(e,t),oM.init(e,t)});function Vj(e){return TA(Bj,e)}var Hj=X(`ZodError`,(e,t)=>{yD.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>SD(e,t)},flatten:{value:t=>xD(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,LE,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,LE,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Uj=CD(Hj),Wj=wD(Hj),Gj=TD(Hj),Kj=DD(Hj),qj=kD(Hj),Jj=AD(Hj),Yj=jD(Hj),Xj=MD(Hj),Zj=ND(Hj),Qj=PD(Hj),$j=FD(Hj),eM=ID(Hj),tM=new WeakMap;function nM(e,t,n){let r=Object.getPrototypeOf(e),i=tM.get(r);if(i||(i=new Set,tM.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var rM=X(`ZodType`,(e,t)=>(PO.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:lj(e,`input`),output:lj(e,`output`)}}),e.toJSONSchema=cj(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Uj(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Gj(e,t,n),e.parseAsync=async(t,n)=>Wj(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Kj(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>qj(e,t,n),e.decode=(t,n)=>Jj(e,t,n),e.encodeAsync=async(t,n)=>Yj(e,t,n),e.decodeAsync=async(t,n)=>Xj(e,t,n),e.safeEncode=(t,n)=>Zj(e,t,n),e.safeDecode=(t,n)=>Qj(e,t,n),e.safeEncodeAsync=async(t,n)=>$j(e,t,n),e.safeDecodeAsync=async(t,n)=>eM(e,t,n),nM(e,`ZodType`,{check(...e){let t=this.def;return this.clone(GE(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return tD(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(CN(e,t))},superRefine(e,t){return this.check(wN(e,t))},overwrite(e){return this.check(qA(e))},optional(){return rN(this)},exactOptional(){return aN(this)},nullable(){return sN(this)},nullish(){return rN(sN(this))},nonoptional(e){return pN(this,e)},array(){return zM(this)},or(e){return UM([this,e])},and(e){return qM(this,e)},transform(e){return _N(this,tN(e))},default(e){return lN(this,e)},prefault(e){return dN(this,e)},catch(e){return hN(this,e)},pipe(e){return _N(this,e)},readonly(){return yN(this)},describe(e){let t=this.clone();return Qk.add(t,{description:e}),t},meta(...e){if(e.length===0)return Qk.get(this);let t=this.clone();return Qk.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Qk.get(e)?.description},configurable:!0}),e)),iM=X(`_ZodString`,(e,t)=>{FO.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dj(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,nM(e,`_ZodString`,{regex(...e){return this.check(VA(...e))},includes(...e){return this.check(WA(...e))},startsWith(...e){return this.check(GA(...e))},endsWith(...e){return this.check(KA(...e))},min(...e){return this.check(zA(...e))},max(...e){return this.check(RA(...e))},length(...e){return this.check(BA(...e))},nonempty(...e){return this.check(zA(1,...e))},lowercase(e){return this.check(HA(e))},uppercase(e){return this.check(UA(e))},trim(){return this.check(YA())},normalize(...e){return this.check(JA(...e))},toLowerCase(){return this.check(XA())},toUpperCase(){return this.check(ZA())},slugify(){return this.check(QA())}})}),aM=X(`ZodString`,(e,t)=>{FO.init(e,t),iM.init(e,t),e.email=t=>e.check(eA(sM,t)),e.url=t=>e.check(oA(uM,t)),e.jwt=t=>e.check(xA(TM,t)),e.emoji=t=>e.check(sA(dM,t)),e.guid=t=>e.check(tA(cM,t)),e.uuid=t=>e.check(nA(lM,t)),e.uuidv4=t=>e.check(rA(lM,t)),e.uuidv6=t=>e.check(iA(lM,t)),e.uuidv7=t=>e.check(aA(lM,t)),e.nanoid=t=>e.check(cA(fM,t)),e.guid=t=>e.check(tA(cM,t)),e.cuid=t=>e.check(lA(pM,t)),e.cuid2=t=>e.check(uA(mM,t)),e.ulid=t=>e.check(dA(hM,t)),e.base64=t=>e.check(vA(SM,t)),e.base64url=t=>e.check(yA(CM,t)),e.xid=t=>e.check(fA(gM,t)),e.ksuid=t=>e.check(pA(_M,t)),e.ipv4=t=>e.check(mA(vM,t)),e.ipv6=t=>e.check(hA(yM,t)),e.cidrv4=t=>e.check(gA(bM,t)),e.cidrv6=t=>e.check(_A(xM,t)),e.e164=t=>e.check(bA(wM,t)),e.datetime=t=>e.check(Fj(t)),e.date=t=>e.check(Lj(t)),e.time=t=>e.check(zj(t)),e.duration=t=>e.check(Vj(t))});function Q(e){return $k(aM,e)}var oM=X(`ZodStringFormat`,(e,t)=>{IO.init(e,t),iM.init(e,t)}),sM=X(`ZodEmail`,(e,t)=>{zO.init(e,t),oM.init(e,t)}),cM=X(`ZodGUID`,(e,t)=>{LO.init(e,t),oM.init(e,t)}),lM=X(`ZodUUID`,(e,t)=>{RO.init(e,t),oM.init(e,t)}),uM=X(`ZodURL`,(e,t)=>{BO.init(e,t),oM.init(e,t)}),dM=X(`ZodEmoji`,(e,t)=>{VO.init(e,t),oM.init(e,t)}),fM=X(`ZodNanoID`,(e,t)=>{HO.init(e,t),oM.init(e,t)}),pM=X(`ZodCUID`,(e,t)=>{UO.init(e,t),oM.init(e,t)}),mM=X(`ZodCUID2`,(e,t)=>{WO.init(e,t),oM.init(e,t)}),hM=X(`ZodULID`,(e,t)=>{GO.init(e,t),oM.init(e,t)}),gM=X(`ZodXID`,(e,t)=>{KO.init(e,t),oM.init(e,t)}),_M=X(`ZodKSUID`,(e,t)=>{qO.init(e,t),oM.init(e,t)}),vM=X(`ZodIPv4`,(e,t)=>{QO.init(e,t),oM.init(e,t)}),yM=X(`ZodIPv6`,(e,t)=>{$O.init(e,t),oM.init(e,t)}),bM=X(`ZodCIDRv4`,(e,t)=>{ek.init(e,t),oM.init(e,t)}),xM=X(`ZodCIDRv6`,(e,t)=>{tk.init(e,t),oM.init(e,t)}),SM=X(`ZodBase64`,(e,t)=>{rk.init(e,t),oM.init(e,t)}),CM=X(`ZodBase64URL`,(e,t)=>{ak.init(e,t),oM.init(e,t)}),wM=X(`ZodE164`,(e,t)=>{ok.init(e,t),oM.init(e,t)}),TM=X(`ZodJWT`,(e,t)=>{ck.init(e,t),oM.init(e,t)}),EM=X(`ZodNumber`,(e,t)=>{lk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fj(e,t,n,r),nM(e,`ZodNumber`,{gt(e,t){return this.check(FA(e,t))},gte(e,t){return this.check(IA(e,t))},min(e,t){return this.check(IA(e,t))},lt(e,t){return this.check(NA(e,t))},lte(e,t){return this.check(PA(e,t))},max(e,t){return this.check(PA(e,t))},int(e){return this.check(kM(e))},safe(e){return this.check(kM(e))},positive(e){return this.check(FA(0,e))},nonnegative(e){return this.check(IA(0,e))},negative(e){return this.check(NA(0,e))},nonpositive(e){return this.check(PA(0,e))},multipleOf(e,t){return this.check(LA(e,t))},step(e,t){return this.check(LA(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function DM(e){return EA(EM,e)}var OM=X(`ZodNumberFormat`,(e,t)=>{uk.init(e,t),EM.init(e,t)});function kM(e){return OA(OM,e)}var AM=X(`ZodBoolean`,(e,t)=>{dk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pj(e,t,n,r)});function jM(e){return kA(AM,e)}var MM=X(`ZodNull`,(e,t)=>{fk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mj(e,t,n,r)});function NM(e){return AA(MM,e)}var PM=X(`ZodUnknown`,(e,t)=>{pk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function FM(){return jA(PM)}var IM=X(`ZodNever`,(e,t)=>{mk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hj(e,t,n,r)});function LM(e){return MA(IM,e)}var RM=X(`ZodArray`,(e,t)=>{gk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bj(e,t,n,r),e.element=t.element,nM(e,`ZodArray`,{min(e,t){return this.check(zA(e,t))},nonempty(e){return this.check(zA(1,e))},max(e,t){return this.check(RA(e,t))},length(e,t){return this.check(BA(e,t))},unwrap(){return this.element}})});function zM(e,t){return $A(RM,e,t)}var BM=X(`ZodObject`,(e,t)=>{xk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xj(e,t,n,r),UE(e,`shape`,()=>t.shape),nM(e,`ZodObject`,{keyof(){return ZM(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:FM()})},loose(){return this.clone({...this._zod.def,catchall:FM()})},strict(){return this.clone({...this._zod.def,catchall:LM()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return oD(this,e)},safeExtend(e){return sD(this,e)},merge(e){return cD(this,e)},pick(e){return iD(this,e)},omit(e){return aD(this,e)},partial(...e){return lD(nN,this,e[0])},required(...e){return uD(fN,this,e[0])}})});function VM(e,t){return new BM({type:`object`,shape:e??{},...Z(t)})}function $(e,t){return new BM({type:`object`,shape:e,catchall:LM(),...Z(t)})}var HM=X(`ZodUnion`,(e,t)=>{Ck.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sj(e,t,n,r),e.options=t.options});function UM(e,t){return new HM({type:`union`,options:e,...Z(t)})}var WM=X(`ZodDiscriminatedUnion`,(e,t)=>{HM.init(e,t),wk.init(e,t)});function GM(e,t,n){return new WM({type:`union`,options:t,discriminator:e,...Z(n)})}var KM=X(`ZodIntersection`,(e,t)=>{Tk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cj(e,t,n,r)});function qM(e,t){return new KM({type:`intersection`,left:e,right:t})}var JM=X(`ZodRecord`,(e,t)=>{Ok.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wj(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function YM(e,t,n){return!t||!t._zod?new JM({type:`record`,keyType:Q(),valueType:e,...Z(t)}):new JM({type:`record`,keyType:e,valueType:t,...Z(n)})}var XM=X(`ZodEnum`,(e,t)=>{kk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gj(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new XM({...t,checks:[],...Z(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new XM({...t,checks:[],...Z(r),entries:i})}});function ZM(e,t){return new XM({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Z(t)})}var QM=X(`ZodLiteral`,(e,t)=>{Ak.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_j(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $M(e,t){return new QM({type:`literal`,values:Array.isArray(e)?e:[e],...Z(t)})}var eN=X(`ZodTransform`,(e,t)=>{jk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yj(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new NE(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(_D(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(_D(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function tN(e){return new eN({type:`transform`,transform:e})}var nN=X(`ZodOptional`,(e,t)=>{Nk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rN(e){return new nN({type:`optional`,innerType:e})}var iN=X(`ZodExactOptional`,(e,t)=>{Pk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function aN(e){return new iN({type:`optional`,innerType:e})}var oN=X(`ZodNullable`,(e,t)=>{Fk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function sN(e){return new oN({type:`nullable`,innerType:e})}var cN=X(`ZodDefault`,(e,t)=>{Ik.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function lN(e,t){return new cN({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():QE(t)}})}var uN=X(`ZodPrefault`,(e,t)=>{Rk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dN(e,t){return new uN({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():QE(t)}})}var fN=X(`ZodNonOptional`,(e,t)=>{zk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ej(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function pN(e,t){return new fN({type:`nonoptional`,innerType:e,...Z(t)})}var mN=X(`ZodCatch`,(e,t)=>{Vk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function hN(e,t){return new mN({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var gN=X(`ZodPipe`,(e,t)=>{Hk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Aj(e,t,n,r),e.in=t.in,e.out=t.out});function _N(e,t){return new gN({type:`pipe`,in:e,out:t})}var vN=X(`ZodReadonly`,(e,t)=>{Wk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function yN(e){return new vN({type:`readonly`,innerType:e})}var bN=X(`ZodLazy`,(e,t)=>{Kk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nj(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function xN(e){return new bN({type:`lazy`,getter:e})}var SN=X(`ZodCustom`,(e,t)=>{qk.init(e,t),rM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vj(e,t,n,r)});function CN(e,t={}){return ej(SN,e,t)}function wN(e,t){return tj(e,t)}function TN(e){let t=xN(()=>UM([Q(e),DM(),jM(),NM(),zM(t),YM(Q(),t)]));return t}function EN(e){return DA(EM,e)}var DN=`/api/socket.io/`,ON=64*1024,kN=`\x1B[9000~`,AN=`\x1B[9001~`,jN=`\x1B[9002~`,MN=`\x1B[9003~`,NN=`\x1B[9004~`,PN=Q().min(1).max(128),FN=Q().min(1).max(128),IN=Q().min(1).max(128),LN=DM().int().nonnegative(),RN={cols:DM().int().min(2).max(1e3),rows:DM().int().min(2).max(500)},zN=$(RN),BN=$({state:ZM([`normal`,`error`,`indeterminate`,`paused`]),value:DM().int().min(0).max(100).nullable()}),VN=ZM([`pi`,`claude`,`codex`]),HN=$({terminalId:Q().min(1),title:Q().max(256).nullable(),program:VN.nullable().default(null),hasForegroundProcess:jM().nullable().optional(),progress:BN.nullable(),progressStartedAt:Q().datetime().nullable().default(null),progressClearedAt:Q().datetime().nullable().default(null),bell:$({sequence:DM().int().positive(),at:Q().datetime(),unread:jM()}).nullable().default(null)});$({sequence:DM().int().positive()}),$({terminalId:PN,clientId:FN,...RN}),$({generation:LN,data:Q().max(ON)}),$({generation:LN,data:Q().max(ON)}),$({generation:LN,...RN}),$({generation:LN,...RN}),$({generation:LN}),$({streamId:IN,sequence:DM().int().nonnegative()});var UN={connectionId:Q().min(1).max(128),streamId:IN,generation:LN,controller:jM(),reset:$M(`full`)},WN=UM([$(UN),$({...UN,...RN,revision:DM().int().positive()})]),GN=$({...RN,revision:DM().int().positive()}),KN=$({streamId:IN,sequence:DM().int().positive(),data:Q()}),qN=$({title:Q().max(256)}),JN=$({progress:BN.nullable()}),YN=$({viewing:jM()}),XN=$({generation:LN,controller:jM()}),ZN=$({exitCode:DM().int().nullable()}),QN=$({code:Q().min(1).max(80),message:Q().min(1).max(1e3),retryable:jM()});function $N(e,t){let n={ready:WN,dimensions:GN,output:KN,title:qN,progress:JN,history:YN,control:XN,exit:ZN,terminal_error:QN}[e].safeParse(t);return n.success?n.data:null}var eP=Q().min(1).max(128),tP=(e,t)=>$({id:eP,type:$M(e),at:Q().datetime(),data:t}),nP=$({projectId:eP,worktreeId:NM()}),rP=$({worktreeId:eP}),iP=$({projectId:eP,worktreeId:eP}),aP=$({operationId:eP,worktreeId:eP}),oP=GM(`type`,[tP(`project.created`,nP),tP(`project.updated`,nP),tP(`project.removed`,nP),tP(`worktree.created`,iP),tP(`worktree.updated`,rP),tP(`worktree.removed`,iP),tP(`create.started`,$({projectId:eP,operationId:eP,worktreeId:NM()})),tP(`create.completed`,$({projectId:eP,operationId:eP,worktreeId:eP})),tP(`create.failed`,$({projectId:eP,operationId:eP,worktreeId:NM()})),tP(`terminal.created`,$({projectId:eP.optional(),worktreeId:eP,terminalId:eP})),tP(`terminal.updated`,$({worktreeId:eP,terminalId:eP})),tP(`terminal.removed`,$({worktreeId:eP,terminalId:eP})),tP(`terminal.metadata`,HN.extend({worktreeId:NM()})),tP(`terminal.controller_changed`,$({terminalId:eP,controlled:jM(),worktreeId:NM()})),tP(`panel.created`,$({worktreeId:eP,panelId:eP})),tP(`panel.updated`,$({worktreeId:eP,panelId:eP})),tP(`panel.open_requested`,$({worktreeId:eP,panelId:eP,sourceTerminalId:eP.nullable()})),tP(`panel.removed`,$({worktreeId:eP,panelId:eP})),tP(`remove.started`,aP.extend({kind:$M(`remove`)})),tP(`remove.completed`,aP),tP(`remove.failed`,aP.extend({error:Q()}))]),sP=$({id:Q().min(1),kind:$M(`web`),worktreeId:Q().min(1),definitionId:Q().min(1),title:Q().min(1),launch:$({input:YM(Q(),TN()).nullable(),cwd:Q().nullable()}),sandbox:$({allowSameOrigin:jM()}),createdAt:Q(),updatedAt:Q()}),cP=$({at:Q().datetime(),terminalMetadata:zM(HN),webPanels:zM(sP)});function lP(e){let t=cP.safeParse(e);return t.success?t.data:null}function uP(e){let t=oP.safeParse(e);return t.success?t.data:null}var dP=4096,fP=4096;VM({input:Q().trim().min(1).max(4096),hidden:ZM([`true`,`false`]).optional().default(`false`).transform(e=>e===`true`)}),VM({lines:EN().int().min(1).max(5e3).optional().default(200)}),VM({path:Q().trim().min(1),name:Q().trim().min(1).max(120).optional()}),VM({color:ZM([`rose`,`orange`,`amber`,`emerald`,`cyan`,`blue`,`violet`,`pink`]).nullable()});var pP=Q().trim().min(1).max(120),mP=zM(Q()).min(1).max(128),hP=Q().max(fP),gP={name:pP,executable:Q().min(1).max(dP).refine(e=>e.trim().length>0,{message:`Executable cannot be blank`}),args:zM(hP).max(127),closeOnSuccess:jM().default(!1)};$(gP);var _P=Q().regex(/^[a-z0-9][a-z0-9._-]{0,119}$/,{message:`Preset IDs must contain only lowercase letters, numbers, dots, underscores, and hyphens`});$({version:$M(1),presets:YM(_P,FM())});var vP=Q().min(1).max(64),yP=VM({name:pP,argv:mP.optional(),returnToShell:jM().optional(),initialSize:zN.optional()});VM({name:Q().trim().min(1).max(120),base:ZM([`default`,`current`]).default(`default`),sourceWorktreeId:Q().min(1).optional(),initialTerminal:yP.optional()}).superRefine((e,t)=>{e.base===`current`&&!e.sourceWorktreeId&&t.addIssue({code:`custom`,path:[`sourceWorktreeId`],message:`A source worktree is required when starting from current`})});var bP=Q().min(1).max(4096).refine(e=>e.trim().length>0&&!e.includes(`\0`),{message:`Working directory cannot be blank or contain NUL`}),xP=YM(Q().min(1).max(256).refine(e=>!e.includes(`=`)&&!e.includes(`\0`),{message:`Environment keys cannot contain equals or NUL`}),Q().max(fP).refine(e=>!e.includes(`\0`),{message:`Environment values cannot contain NUL`})).refine(e=>Object.keys(e).length<=128,{message:`Environment cannot contain more than 128 variables`});VM({name:pP,argv:mP.optional(),cwd:bP.optional(),env:xP.optional(),returnToShell:jM().optional(),closeOnSuccess:jM().optional(),initialSize:zN.optional()}).refine(e=>!(e.returnToShell&&e.closeOnSuccess),{message:`A terminal cannot return to a shell and close on success`}),VM({name:pP});var SP=YM(Q(),TN());VM({definitionId:Q().min(1).max(256),input:SP.nullable().optional(),launchCwd:Q().max(4096).nullable().optional()}).extend({newInstance:jM().optional(),sourceTerminalId:Q().min(1).max(128).nullable().optional()});var CP=Q().min(1).max(128);VM({key:CP}),VM({key:CP,value:TN()}),VM({key:CP}),VM(gP),VM({...gP,closeOnSuccess:jM().optional(),expectedUpdatedAt:vP}),VM({expectedUpdatedAt:vP}),VM({path:Q().trim().min(1).max(4096)}),VM({source:Q().trim().min(1).max(4096),projectId:Q().min(1).optional()}),VM({source:Q().trim().min(1).max(4096),projectId:Q().min(1).optional()}),VM({source:Q().trim().min(1).max(4096).optional()}),VM({projectId:Q().min(1).optional()}),VM({confirmationToken:Q().length(64),confirmDestructive:jM()}),VM({project:Q().min(1),worktreeName:Q().trim().min(1).max(120),name:pP,argv:mP.optional(),base:ZM([`default`,`current`]).default(`default`),sourceWorktreeId:Q().min(1).optional()}).superRefine((e,t)=>{e.base===`current`&&!e.sourceWorktreeId&&t.addIssue({code:`custom`,path:[`sourceWorktreeId`],message:`A source worktree is required when starting from current`})});var wP=8,TP=8*1024*1024,EP=4,DP=2,OP=1e3,kP=2,AP=500,jP=150,MP=24,NP=44;function PP(e,t={cols:100,rows:30}){return{cols:Number.isFinite(e.cols)?Math.min(OP,Math.max(DP,Math.trunc(e.cols))):t.cols,rows:Number.isFinite(e.rows)?Math.min(AP,Math.max(kP,Math.trunc(e.rows))):t.rows}}var FP={phase:`closed`,degraded:!1,controller:!1,controlPending:!1,title:null,bellActive:!1,bellSerial:0,exitSerial:0,fileTransfer:null,hasSelection:!1,selecting:!1,viewingHistory:!1,pasteRequestSerial:0,error:null},IP=null;function LP(){if(IP)return IP;try{let e=sessionStorage.getItem(`treeport-terminal-client-id`);if(e)return sessionStorage.setItem(`treeport-terminal-client-id`,e),IP=e}catch{}let e=new Uint8Array(16);if(typeof globalThis.crypto?.getRandomValues==`function`)globalThis.crypto.getRandomValues(e);else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)),n=`${t.slice(0,4).join(``)}-${t.slice(4,6).join(``)}-${t.slice(6,8).join(``)}-${t.slice(8,10).join(``)}-${t.slice(10).join(``)}`;try{sessionStorage.setItem(`treeport-terminal-client-id`,n)}catch{}return IP=n}var RP=class{terminalId;listeners=new Set;snapshotValue=FP;terminal=null;fitAddon=null;wrapper=null;host=null;resizeObserver=null;keyboardViewportCleanup=null;socket=null;degradedTimer=null;bellTimer=null;fileTransferTimer=null;fileTransferQueue=Promise.resolve();resizeFrame=null;resizeSettleTimer=null;disposed=!1;opened=!1;ready=!1;reconnectAllowed=!0;streamId=null;controllerGeneration=0;controlRequestGeneration=null;canonicalCols=100;canonicalRows=30;canonicalRevision=0;appliedRevision=0;proposedDimensions=null;resizePending=!1;serverProtocolVersion=2;resizeIntentDirty=!1;resizeQuietElapsed=!1;resizeIntentGeneration=0;renderEpoch=0;renderQueue=Promise.resolve();renderFailed=!1;pendingTerminalWrites=0;expectedSequence=1;lastParsedSequence=0;parsedSequences=new Set;scrollExitPending=!1;resumeOnNextInput=!1;historyExitRequested=!1;selectionClearRequested=!1;selectionDragCancel=null;tmuxSelectionPending=!1;tmuxSelectionText=null;pendingPaste=``;inputModifiers=null;lastBellAt=0;wakeListenersAttached=!1;reconnectWhenOnline=()=>this.reconnectImmediately();reconnectWhenVisible=()=>{document.visibilityState===`visible`&&this.reconnectImmediately()};constructor(e){this.terminalId=e}getSnapshot=()=>this.snapshotValue;getInitialSize(){return!this.host||!this.terminal?null:PP(this.proposedDimensions??{cols:this.terminal.cols,rows:this.terminal.rows})}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));mount(e){if(this.disposed)return;this.host=e,this.wrapper||(this.wrapper=document.createElement(`div`),this.wrapper.className=`terminal-session-host h-full min-h-0 min-w-0`),e.appendChild(this.wrapper),this.opened||this.openTerminal(),this.keyboardViewportCleanup?.(),this.keyboardViewportCleanup=null;let t=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,n=window.visualViewport;if(t&&n){let e=null,t=null,r=()=>{t!==null&&window.cancelAnimationFrame(t),t=window.requestAnimationFrame(()=>{t=null;let r=this.wrapper?.querySelector(`.xterm-helper-textarea`);if(!(document.activeElement===r&&n.height<document.documentElement.clientHeight-100)){e?.remove(),e=null,document.querySelector(`.app-frame`)?.scrollIntoView({block:`start`,inline:`nearest`});return}let i=document.querySelector(`.accessory-row`);if(!i)return;e??=document.createElement(`div`),e.className=`ios-keyboard-viewport-spacer`,e.setAttribute(`aria-hidden`,`true`);let a=window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone?0:NP;e.style.height=`${i.getBoundingClientRect().height+MP+a}px`,document.body.appendChild(e),e.scrollIntoView({block:`end`,inline:`nearest`})})};n.addEventListener(`resize`,r),r(),this.keyboardViewportCleanup=()=>{n.removeEventListener(`resize`,r),t!==null&&window.cancelAnimationFrame(t),e?.remove()}}this.resizeObserver?.disconnect(),this.resizeObserver=new ResizeObserver(()=>this.scheduleFit()),this.resizeObserver.observe(e),this.wakeListenersAttached||=(window.addEventListener(`online`,this.reconnectWhenOnline),document.addEventListener(`visibilitychange`,this.reconnectWhenVisible),!0),this.scheduleFit(),!this.socket&&this.opened?this.connect():this.reconnectImmediately()}unmount(e){this.host===e&&(this.resizeObserver?.disconnect(),this.resizeObserver=null,this.wakeListenersAttached&&=(window.removeEventListener(`online`,this.reconnectWhenOnline),document.removeEventListener(`visibilitychange`,this.reconnectWhenVisible),!1),this.keyboardViewportCleanup?.(),this.keyboardViewportCleanup=null,this.cancelControllerResizeIntent(!1),this.selectionDragCancel?.(),this.wrapper?.remove(),this.host=null)}focus(e={}){e.requestControl&&this.requestControl(),this.terminal?.focus()}requestControl(){if(!this.ready||!this.socket?.connected||this.snapshotValue.controller||this.controlRequestGeneration===this.controllerGeneration)return;let e=PP(this.proposedDimensions??{cols:this.canonicalCols,rows:this.canonicalRows});this.controlRequestGeneration=this.controllerGeneration,this.update({controlPending:!0}),this.send(`take_control`,this.serverProtocolVersion===2?{generation:this.controllerGeneration,...e}:{generation:this.controllerGeneration})}retry(){if(!(this.disposed||this.ready)){if(this.renderFailed){window.location.reload();return}this.reconnectAllowed=!0,this.update({error:null,phase:`connecting`,degraded:!1}),this.socket?this.socket.connect():this.connect()}}setInputModifiers(e,t,n){this.inputModifiers=e||t?{ctrl:e,alt:t,onConsumed:n}:null}sendText(e){this.requestControl(),this.clearSelection(),this.prepareScrollExit(),this.canInput()&&this.send(`input`,{generation:this.controllerGeneration,data:this.withScrollExit(e)}),this.focus()}pasteText(e){e&&(this.requestControl(),this.clearSelection(),this.prepareScrollExit(),this.canInput()?this.terminal?.paste(e):this.pendingPaste+=e,this.focus())}sendArrow(e,t=!1){let n={up:`A`,down:`B`,right:`C`,left:`D`}[e],r=this.terminal?.modes.applicationCursorKeysMode?`\x1BO`:`\x1B[`;this.sendText(`${t?`\x1B`:``}${r}${n}`)}jumpToLatest(){this.ready&&(this.historyExitRequested=!0,this.requestControl(),this.canInput()&&this.sendHistoryExit(),this.focus())}copySelection(){let e=this.tmuxSelectionText??this.terminal?.getSelection()??``;if(!e)return;let t=document.createElement(`textarea`);t.value=e,t.readOnly=!0,t.style.position=`fixed`,t.style.left=`-9999px`,t.style.opacity=`0`,document.body.appendChild(t),t.focus({preventScroll:!0}),t.select(),t.setSelectionRange(0,e.length);let n=document.execCommand(`copy`);t.remove(),!n&&navigator.clipboard&&navigator.clipboard.writeText(e),this.focus()}clearSelectionAndJumpToLatest(){this.ready&&(this.historyExitRequested=!0,this.selectionClearRequested=!0,this.requestControl(),this.canInput()&&(this.send(`input`,{generation:this.controllerGeneration,data:`${kN}${MN}`}),this.historyExitRequested=!1,this.selectionClearRequested=!1,this.setViewingHistory(!1)),this.tmuxSelectionPending=!1,this.tmuxSelectionText=null,this.wrapper?.classList.remove(`terminal-tmux-selection`),this.terminal?.clearSelection(),this.update({selecting:!1,hasSelection:!1}),this.focus())}clearSelection(){let e=this.tmuxSelectionPending||this.tmuxSelectionText!==null;!e&&!this.terminal?.hasSelection?.()||(e&&(this.selectionClearRequested=!0,this.sendSelectionClear()),this.tmuxSelectionPending=!1,this.tmuxSelectionText=null,this.update({selecting:!1}),this.wrapper?.classList.remove(`terminal-tmux-selection`),this.terminal?.clearSelection(),this.updateSelectionState())}dispose(){this.disposed||(this.disposed=!0,this.reconnectAllowed=!1,this.clearTimers(),this.selectionDragCancel?.(),this.selectionDragCancel=null,this.resizeObserver?.disconnect(),this.wakeListenersAttached&&=(window.removeEventListener(`online`,this.reconnectWhenOnline),document.removeEventListener(`visibilitychange`,this.reconnectWhenVisible),!1),this.keyboardViewportCleanup?.(),this.keyboardViewportCleanup=null,this.socket?.disconnect(),this.socket=null,this.wrapper?.remove(),this.terminal?.dispose(),this.terminal=null,this.fitAddon=null,this.wrapper=null,this.listeners.clear())}openTerminal(){if(!this.wrapper||this.opened)return;let e=new jw(sg()),t=new ug;e.loadAddon(t),e.loadAddon(new gg(tg)),e.open(this.wrapper),e.onSelectionChange(()=>this.updateSelectionState()),this.selectionDragCancel=ag(this.wrapper,e,{canInput:()=>this.canInput(),sendInput:e=>{this.send(`input`,{generation:this.controllerGeneration,data:e})},requestControl:()=>this.requestControl(),onSelectionStart:()=>this.clearSelection(),onTmuxSelectionStart:()=>{this.scrollExitPending=!0,this.update({selecting:!0}),this.wrapper?.classList.add(`terminal-scrolling`,`terminal-tmux-selection`)},onTmuxSelectionFinish:()=>{this.tmuxSelectionPending=!0,this.update({selecting:!1,hasSelection:!0})},onTmuxSelectionCancel:()=>{this.update({selecting:!1}),this.sendHistoryExit()},selectionStartSequence:AN,selectionStopSequence:jN}),this.wrapper.addEventListener(`copy`,e=>{this.tmuxSelectionText===null||!e.clipboardData||(e.preventDefault(),e.stopImmediatePropagation(),e.clipboardData.setData(`text/plain`,this.tmuxSelectionText))},!0),this.wrapper.addEventListener(`click`,()=>this.requestControl(),!0),this.wrapper.addEventListener(`keydown`,t=>{let n=t.key.toLowerCase(),r=[`alt`,`altgraph`,`control`,`meta`,`shift`].includes(n),i=$h(t,e.modes.applicationCursorKeysMode),a=t.metaKey&&i===null,o=t.ctrlKey&&t.shiftKey&&(n===`c`||n===`v`);!r&&!a&&!o&&(this.clearSelection(),this.requestControl())},!0),og(this.wrapper,e,e=>{e.deltaY<0&&this.canInput()&&(!this.snapshotValue.viewingHistory&&this.tmuxSelectionText!==null&&this.send(`input`,{generation:this.controllerGeneration,data:NN}),this.scrollExitPending=!0)},()=>{this.requestControl(),this.clearSelection(),this.prepareScrollExit()},()=>{this.requestControl(),this.update({pasteRequestSerial:this.snapshotValue.pasteRequestSerial+1})});let n=this.wrapper,r=e=>!!(e&&(Array.from(e.types).includes(`Files`)||Array.from(e.items).some(e=>e.kind===`file`))),i=e=>{let t=Array.from(e?.files??[]);return t.length?t:Array.from(e?.items??[]).flatMap(e=>{let t=e.kind===`file`?e.getAsFile():null;return t?[t]:[]})};n.addEventListener(`dragover`,e=>{r(e.dataTransfer)&&(this.requestControl(),e.preventDefault(),e.dataTransfer.dropEffect=`copy`,n.classList.add(`terminal-file-drag`))}),n.addEventListener(`dragleave`,e=>{(!(e.relatedTarget instanceof Node)||!n.contains(e.relatedTarget))&&n.classList.remove(`terminal-file-drag`)}),n.addEventListener(`drop`,e=>{r(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),n.classList.remove(`terminal-file-drag`),this.requestControl(),this.queueFileUpload(i(e.dataTransfer)))}),n.addEventListener(`paste`,e=>{let t=i(e.clipboardData);t.length&&(e.preventDefault(),e.stopPropagation(),this.requestControl(),this.queueFileUpload(t))},!0),this.terminal=e,this.fitAddon=t,this.opened=!0,e.parser.registerOscHandler(52,e=>{if(!this.tmuxSelectionPending)return!1;this.tmuxSelectionPending=!1;let t=e.indexOf(`;`),n=t===-1?``:e.slice(t+1),r=n.replace(/=+$/,``);if(!n||n===`?`||n.length>TP||e.indexOf(`;`,t+1)!==-1||!/^[A-Za-z0-9+/]*={0,2}$/.test(n)||r.length%4==1)return this.updateSelectionState(),!0;let i=r.padEnd(Math.ceil(r.length/4)*4,`=`),a=atob(i);return this.tmuxSelectionText=new TextDecoder().decode(Uint8Array.from(a,e=>e.charCodeAt(0))),this.update({selecting:!1}),this.updateSelectionState(),!0}),e.attachCustomKeyEventHandler(t=>{let n=$h(t,e.modes.applicationCursorKeysMode);return n===null?!0:(t.preventDefault(),t.stopPropagation(),this.prepareScrollExit(),e.input(n,!0),!1)}),e.onKey(()=>this.prepareScrollExit()),e.onData(e=>{if(this.canInput()){let t=this.inputModifiers;t&&(this.inputModifiers=null,t.ctrl&&e.length===1&&(e=String.fromCharCode(e.toUpperCase().charCodeAt(0)&31)),t.alt&&(e=`\u001b${e}`),t.onConsumed()),this.send(`input`,{generation:this.controllerGeneration,data:this.withScrollExit(e)})}}),e.onBinary(e=>{this.canInput()&&this.send(`binary`,{generation:this.controllerGeneration,data:this.withScrollExit(e)})}),e.onTitleChange(e=>this.update({title:e.trim().slice(0,256)})),e.onBell(()=>this.handleBell())}queueFileUpload(e){this.fileTransferQueue=this.fileTransferQueue.catch(()=>void 0).then(()=>this.uploadFiles(e))}async uploadFiles(e){if(!(!e.length||this.disposed)){if(e.length>wP){this.showFileTransferError(`Choose no more than ${wP} files at a time`);return}if(!this.ready||!this.snapshotValue.controller){this.showFileTransferError(this.snapshotValue.controlPending?`taking control; try again in a moment`:`interact with the terminal to take control first`);return}if(!this.canInput()){this.showFileTransferError(`Wait for the terminal resize to finish`);return}this.fileTransferTimer!==null&&(window.clearTimeout(this.fileTransferTimer),this.fileTransferTimer=null),this.update({fileTransfer:{state:`uploading`,message:`Uploading ${e.length===1?`file`:`${e.length} files`}…`}});try{let t=[];for(let n of e){let e=/\.([a-z0-9]{1,16})$/i.exec(n.name)?.[1],r=await Tf(CE.api.terminals[`:terminalId`].files.$post({param:{terminalId:this.terminalId}},{init:{body:n,headers:{"content-type":n.type||`application/octet-stream`,...e?{"x-treeport-file-extension":e.toLowerCase()}:{}}}}));t.push(r.file.path)}if(this.disposed)return;if(!this.ready||!this.snapshotValue.controller){this.showFileTransferError(`Terminal control was lost during the upload`);return}if(!this.canInput()){this.showFileTransferError(`Wait for the terminal resize to finish`);return}let n=t.join(` `);if(new TextEncoder().encode(n).byteLength>65504){this.showFileTransferError(`The uploaded file paths are too long`);return}this.clearSelection(),this.prepareScrollExit(),this.terminal?.paste(n),this.focus(),this.update({fileTransfer:null})}catch(e){this.disposed||this.showFileTransferError(AE(e))}}}showFileTransferError(e){this.fileTransferTimer!==null&&window.clearTimeout(this.fileTransferTimer),this.update({fileTransfer:{state:`error`,message:`Couldn’t paste file: ${e}`}}),this.fileTransferTimer=window.setTimeout(()=>{this.fileTransferTimer=null,this.update({fileTransfer:null})},6e3)}prepareScrollExit(){(this.scrollExitPending||this.snapshotValue.viewingHistory)&&(this.resumeOnNextInput=!0)}withScrollExit(e){return this.resumeOnNextInput?(this.setViewingHistory(!1),`${kN}${e}`):e}sendHistoryExit(){this.canInput()&&(this.send(`input`,{generation:this.controllerGeneration,data:kN}),this.historyExitRequested=!1,this.setViewingHistory(!1))}sendSelectionClear(){this.canInput()&&(this.send(`input`,{generation:this.controllerGeneration,data:MN}),this.selectionClearRequested=!1)}setViewingHistory(e){e?(this.scrollExitPending=!0,this.wrapper?.classList.add(`terminal-scrolling`),this.tmuxSelectionText!==null&&this.wrapper?.classList.add(`terminal-tmux-selection`)):(this.scrollExitPending=!1,this.resumeOnNextInput=!1,this.historyExitRequested=!1,this.wrapper?.classList.remove(`terminal-scrolling`,`terminal-tmux-selection`)),e!==this.snapshotValue.viewingHistory&&this.update({viewingHistory:e})}reconnectImmediately(){if(!this.host||this.disposed||!this.reconnectAllowed||this.ready||this.socket?.connected)return;let e=this.socket;e&&(e.disconnect(),this.socket===e&&(this.socket=null)),this.opened&&this.connect()}connect(){if(this.disposed||!this.reconnectAllowed||this.socket)return;this.ready=!1,this.controlRequestGeneration=null,this.update({phase:`connecting`,controller:!1,controlPending:!1,error:null}),this.startDegradedTimer();let e=xE(`/terminals`,{path:DN,transports:[`websocket`],forceNew:!0,multiplex:!1,autoConnect:!1,reconnection:!0,reconnectionDelay:100,reconnectionDelayMax:1e3,randomizationFactor:.2,retries:0,query:{terminalProtocol:`2`},auth:e=>{let t=PP(this.proposedDimensions??{cols:this.terminal?.cols??100,rows:this.terminal?.rows??30});e({terminalId:this.terminalId,clientId:LP(),...t})}});this.socket=e,e.on(`connect`,()=>{this.socket===e&&this.fit()}),e.on(`ready`,e=>this.handleServerEvent(`ready`,e)),e.on(`dimensions`,e=>this.handleServerEvent(`dimensions`,e)),e.on(`output`,e=>this.handleServerEvent(`output`,e)),e.on(`title`,e=>this.handleServerEvent(`title`,e)),e.on(`progress`,e=>this.handleServerEvent(`progress`,e)),e.on(`history`,e=>this.handleServerEvent(`history`,e)),e.on(`control`,e=>this.handleServerEvent(`control`,e)),e.on(`exit`,e=>this.handleServerEvent(`exit`,e)),e.on(`terminal_error`,e=>this.handleServerEvent(`terminal_error`,e)),e.on(`connect_error`,t=>{this.socket!==e||!this.reconnectAllowed||(this.controlRequestGeneration=null,this.update({phase:`reconnecting`,controller:!1,controlPending:!1,error:`Terminal connection failed: ${t.message}`}))}),e.on(`disconnect`,t=>{if(this.socket!==e)return;let n=this.ready;this.ready=!1,this.streamId=null,this.selectionDragCancel?.(),this.tmuxSelectionPending=!1,this.tmuxSelectionText=null,this.setViewingHistory(!1),this.controllerGeneration=0,this.controlRequestGeneration=null,this.cancelControllerResizeIntent(),this.reconnectAllowed||this.clearDegraded(),this.update({phase:this.reconnectAllowed&&!this.disposed?`reconnecting`:`closed`,controller:!1,controlPending:!1,hasSelection:!1,selecting:!1,viewingHistory:!1,degraded:this.reconnectAllowed?this.snapshotValue.degraded:!1,error:!n&&!this.snapshotValue.error?`Terminal connection closed: ${t}`:this.snapshotValue.error})}),e.io.on(`reconnect_attempt`,()=>{this.socket===e&&this.reconnectAllowed&&(this.controlRequestGeneration=null,this.startDegradedTimer(),this.update({phase:`reconnecting`,controller:!1,controlPending:!1}))}),e.connect()}handleServerEvent(e,t){if(e===`ready`){let e=$N(`ready`,t);if(!e){this.failProtocol(`The terminal server sent an invalid ready event`);return}this.cancelControllerResizeIntent(),this.controlRequestGeneration=null;let n=`revision`in e;this.serverProtocolVersion=n?2:1;let r=n?{cols:e.cols,rows:e.rows}:PP(this.proposedDimensions??{cols:this.terminal?.cols??100,rows:this.terminal?.rows??30}),i=n?e.revision:1;this.streamId=e.streamId,this.controllerGeneration=e.generation,this.canonicalCols=r.cols,this.canonicalRows=r.rows,this.canonicalRevision=i,this.appliedRevision=n?0:i,this.expectedSequence=1,this.lastParsedSequence=0,this.parsedSequences.clear(),this.selectionDragCancel?.(),this.tmuxSelectionPending=!1,this.tmuxSelectionText=null,this.setViewingHistory(!1),this.ready=!0,this.renderEpoch+=1;let a=this.renderEpoch;this.enqueueRender(a,async()=>{await this.drainTerminalWrites(),!(this.disposed||a!==this.renderEpoch)&&(this.terminal?.reset(),n?this.applyCanonicalDimensions(r.cols,r.rows,i,!0):this.fit(!0))}),this.clearDegraded(),this.update({phase:`ready`,controller:e.controller,controlPending:!1,hasSelection:!1,selecting:!1,viewingHistory:!1,error:null});return}if(e===`dimensions`){if(this.serverProtocolVersion!==2){this.failProtocol(`The legacy terminal server sent dimensions`);return}let e=$N(`dimensions`,t);if(!e){this.failProtocol(`The terminal server sent invalid dimensions`);return}if(e.revision<=this.canonicalRevision)return;this.canonicalCols=e.cols,this.canonicalRows=e.rows,this.canonicalRevision=e.revision,this.resizePending=!1;let n=this.renderEpoch;this.enqueueRender(n,async()=>{await this.drainTerminalWrites(),!(this.disposed||n!==this.renderEpoch)&&(this.applyCanonicalDimensions(e.cols,e.rows,e.revision),this.flushControllerResize())});return}if(e===`output`){let e=$N(`output`,t);if(!e){this.failProtocol(`The terminal server sent invalid output`);return}this.handleOutput(e.streamId,e.sequence,e.data);return}if(e===`title`){let e=$N(`title`,t);if(!e){this.failProtocol(`The terminal server sent an invalid title`);return}this.update({title:e.title.trim().slice(0,256)});return}if(e===`progress`){$N(`progress`,t)||this.failProtocol(`The terminal server sent invalid progress`);return}if(e===`history`){let e=$N(`history`,t);if(!e){this.failProtocol(`The terminal server sent invalid history state`);return}this.setViewingHistory(e.viewing);return}if(e===`control`){let e=$N(`control`,t);if(!e){this.failProtocol(`The terminal server sent invalid controller state`);return}let n=e.controller!==this.snapshotValue.controller||e.generation!==this.controllerGeneration;if(n&&this.cancelControllerResizeIntent(),this.controllerGeneration=e.generation,this.controlRequestGeneration=null,this.update({controller:e.controller,controlPending:!1}),n&&!e.controller&&(this.selectionDragCancel?.(),this.tmuxSelectionPending=!1),e.controller&&this.selectionClearRequested&&this.sendSelectionClear(),e.controller&&this.historyExitRequested&&this.sendHistoryExit(),e.controller&&this.pendingPaste){let e=this.pendingPaste;this.pendingPaste=``,this.terminal?.paste(e)}n&&this.scheduleFit();return}if(e===`exit`){if(!$N(`exit`,t)){this.failProtocol(`The terminal server sent an invalid exit event`);return}this.update({exitSerial:this.snapshotValue.exitSerial+1});return}let n=$N(`terminal_error`,t);if(!n){this.failProtocol(`The terminal server sent an invalid error event`);return}this.reconnectAllowed=n.retryable,this.terminal?.writeln(`\r\n\x1b[31m${n.message}\x1b[0m`),n.retryable?(this.controlRequestGeneration=null,this.update({controlPending:!1,error:n.message})):(this.stopWithError(n.message),this.socket?.disconnect())}handleOutput(e,t,n){if(!this.ready||e!==this.streamId||t!==this.expectedSequence){this.failProtocol(`Terminal output arrived out of order`);return}this.expectedSequence+=1;let r=this.renderEpoch;this.enqueueRender(r,()=>{let i=this.terminal;i&&(this.pendingTerminalWrites+=1,i.write(n,()=>{if(this.pendingTerminalWrites=Math.max(0,this.pendingTerminalWrites-1),this.ready&&r===this.renderEpoch&&e===this.streamId){for(this.parsedSequences.add(t);this.parsedSequences.delete(this.lastParsedSequence+1);)this.lastParsedSequence+=1;this.send(`output_ack`,{streamId:e,sequence:this.lastParsedSequence})}}))})}async drainTerminalWrites(){let e=this.terminal;!e||this.pendingTerminalWrites===0||await new Promise(t=>e.write(``,t))}enqueueRender(e,t){let n=this.renderQueue.then(async()=>{this.disposed||this.renderFailed||e!==this.renderEpoch||await t()});this.renderQueue=n,n.catch(e=>this.failRendering(e))}applyCanonicalDimensions(e,t,n,r=!1){!this.terminal||n<=this.appliedRevision||(this.terminal.resize(e,t),this.appliedRevision=n,this.wrapper&&(this.wrapper.dataset.terminalCols=String(e),this.wrapper.dataset.terminalRows=String(t),this.wrapper.dataset.terminalRevision=String(n)),n===this.canonicalRevision&&this.fit(r))}canInput(){return this.ready&&this.snapshotValue.controller&&!this.resizePending&&this.appliedRevision===this.canonicalRevision}send(e,t){if(!(!this.socket?.connected||!this.ready)){if(e===`output_ack`||e===`resize`||e===`take_control`){this.socket.emit(e,t);return}this.socket.volatile.emit(e,t)}}scheduleFit(){this.resizeFrame!==null&&cancelAnimationFrame(this.resizeFrame),this.resizeFrame=requestAnimationFrame(()=>{this.resizeFrame=null,this.fit(!0)})}queueControllerResizeIntent(){this.resizeSettleTimer!==null&&window.clearTimeout(this.resizeSettleTimer),this.resizeIntentDirty=!0,this.resizeQuietElapsed=!1,this.resizeIntentGeneration=this.controllerGeneration,this.resizeSettleTimer=window.setTimeout(()=>{this.resizeSettleTimer=null,this.resizeQuietElapsed=!0,this.flushControllerResize()},jP)}flushControllerResize(){let e=this.proposedDimensions;if(!(!this.resizeIntentDirty||!this.resizeQuietElapsed||!e||!this.host||!this.ready||!this.socket?.connected||!this.snapshotValue.controller||this.resizeIntentGeneration!==this.controllerGeneration||this.appliedRevision!==this.canonicalRevision||this.resizePending)){if(e.cols===this.canonicalCols&&e.rows===this.canonicalRows){this.resizeIntentDirty=!1,this.resizeQuietElapsed=!1;return}this.resizeIntentDirty=!1,this.resizeQuietElapsed=!1,this.serverProtocolVersion===2?this.resizePending=!0:(this.canonicalCols=e.cols,this.canonicalRows=e.rows,this.appliedRevision=this.canonicalRevision),this.send(`resize`,{generation:this.controllerGeneration,cols:e.cols,rows:e.rows})}}cancelControllerResizeIntent(e=!0){this.resizeSettleTimer!==null&&window.clearTimeout(this.resizeSettleTimer),this.resizeSettleTimer=null,e&&(this.resizePending=!1),this.resizeIntentDirty=!1,this.resizeQuietElapsed=!1,this.resizeIntentGeneration=0,this.proposedDimensions=null}fit(e=!1){if(!(!this.host||!this.fitAddon||!this.terminal))try{if(!this.ready){this.terminal.options.fontSize=14,this.fitAddon.fit(),this.terminal.cols>=DP&&this.terminal.rows>=kP&&(this.proposedDimensions=PP({cols:this.terminal.cols,rows:this.terminal.rows}));return}if(this.serverProtocolVersion===1){if(this.terminal.options.fontSize=14,this.fitAddon.fit(),this.terminal.cols<DP||this.terminal.rows<kP){this.cancelControllerResizeIntent(!1);return}let t=PP({cols:this.terminal.cols,rows:this.terminal.rows});this.proposedDimensions=t,this.snapshotValue.controller&&e&&this.queueControllerResizeIntent();return}if(this.appliedRevision!==this.canonicalRevision)return;this.terminal.options.fontSize=14;let t=this.fitAddon.proposeDimensions();if(!t||!Number.isFinite(t.cols)||!Number.isFinite(t.rows)||t.cols<DP||t.rows<kP){this.snapshotValue.controller&&this.cancelControllerResizeIntent(!1);return}let n=PP(t);if(this.proposedDimensions=n,this.snapshotValue.controller){if(!e)return;if(!this.resizePending&&n.cols===this.canonicalCols&&n.rows===this.canonicalRows){this.resizeSettleTimer!==null&&window.clearTimeout(this.resizeSettleTimer),this.resizeSettleTimer=null,this.resizeIntentDirty=!1,this.resizeQuietElapsed=!1;return}this.queueControllerResizeIntent();return}let r=Math.min(1,n.cols/this.canonicalCols,n.rows/this.canonicalRows);this.terminal.options.fontSize=Math.max(EP,Math.floor(14*r*100)/100),(this.terminal.cols!==this.canonicalCols||this.terminal.rows!==this.canonicalRows)&&this.terminal.resize(this.canonicalCols,this.canonicalRows)}catch(e){this.failRendering(e)}}startDegradedTimer(){this.degradedTimer===null&&(this.degradedTimer=window.setTimeout(()=>{this.degradedTimer=null,this.ready||this.update({degraded:!0})},500))}clearDegraded(){this.degradedTimer!==null&&window.clearTimeout(this.degradedTimer),this.degradedTimer=null,this.update({degraded:!1})}handleBell(){let e=Date.now();e-this.lastBellAt<1e3||(this.lastBellAt=e,this.bellTimer!==null&&window.clearTimeout(this.bellTimer),this.update({bellActive:!0,bellSerial:this.snapshotValue.bellSerial+1}),this.bellTimer=window.setTimeout(()=>{this.bellTimer=null,this.update({bellActive:!1})},180))}failRendering(e){if(this.renderFailed||this.disposed)return;this.renderFailed=!0;let t=(e instanceof Error?e.message:String(e)).trim();this.reconnectAllowed=!1,this.stopWithError(t?`Terminal rendering failed: ${t.slice(0,500)}`:`Terminal rendering failed`),this.socket?.disconnect()}failProtocol(e){this.reconnectAllowed=!1,this.stopWithError(e),this.socket?.disconnect()}stopWithError(e){this.ready=!1,this.clearDegraded(),this.controlRequestGeneration=null,this.update({error:e,phase:`closed`,degraded:!1,controller:!1,controlPending:!1})}updateSelectionState(){this.update({hasSelection:this.tmuxSelectionPending||this.tmuxSelectionText!==null||!!this.terminal?.hasSelection()})}update(e){this.snapshotValue={...this.snapshotValue,...e},this.listeners.forEach(e=>e())}clearTimers(){this.degradedTimer!==null&&window.clearTimeout(this.degradedTimer),this.bellTimer!==null&&window.clearTimeout(this.bellTimer),this.fileTransferTimer!==null&&window.clearTimeout(this.fileTransferTimer),this.resizeFrame!==null&&cancelAnimationFrame(this.resizeFrame),this.resizeSettleTimer!==null&&window.clearTimeout(this.resizeSettleTimer),this.degradedTimer=null,this.bellTimer=null,this.fileTransferTimer=null,this.resizeFrame=null,this.resizeSettleTimer=null,this.resizePending=!1,this.resizeIntentDirty=!1,this.resizeQuietElapsed=!1,this.resizeIntentGeneration=0,this.proposedDimensions=null}},zP=class{maxSessions;idleMs;createSession;onTitleChange;entries=new Map;constructor(e=8,t=5*6e4,n=e=>new RP(e),r=()=>void 0){this.maxSessions=e,this.idleMs=t,this.createSession=n,this.onTitleChange=r}getInitialSize(e){return this.entries.get(e)?.session.getInitialSize()??null}acquire(e){let t=this.entries.get(e);if(!t){let n=this.createSession(e);t={session:n,references:0,lastUsed:Date.now(),idleTimer:null,lastTitle:n.getSnapshot().title,unsubscribe:()=>void 0};let r=t;t.unsubscribe=n.subscribe(()=>{let t=n.getSnapshot();t.title!==r.lastTitle&&(r.lastTitle=t.title,this.onTitleChange(e,t.title))}),this.entries.set(e,t),t.lastTitle&&this.onTitleChange(e,t.lastTitle)}return t.references+=1,t.lastUsed=Date.now(),t.idleTimer!==null&&window.clearTimeout(t.idleTimer),t.idleTimer=null,this.evictOverCapacity(e),t.session}release(e){let t=this.entries.get(e);t&&(t.references=Math.max(0,t.references-1),t.lastUsed=Date.now(),t.references===0&&t.idleTimer===null&&(t.idleTimer=window.setTimeout(()=>this.disposeEntry(e),this.idleMs)))}forget(e){this.disposeEntry(e)}reconcile(e){let t=new Set(e);for(let e of this.entries.keys())t.has(e)||this.disposeEntry(e)}disposeEntry(e){let t=this.entries.get(e);t&&(t.idleTimer!==null&&window.clearTimeout(t.idleTimer),t.unsubscribe(),t.session.dispose(),this.entries.delete(e))}evictOverCapacity(e){for(;this.entries.size>this.maxSessions;){let t=[...this.entries.entries()].filter(([t,n])=>t!==e&&n.references===0).sort((e,t)=>e[1].lastUsed-t[1].lastUsed)[0];if(!t)return;this.disposeEntry(t[0])}}},BP=class{sendBellAcknowledgement;listeners=new Set;bellEventListeners=new Set;attentionSnapshot=new Set;titleSnapshot=new Map;programSnapshot=new Map;foregroundProcessSnapshot=new Set;progressSnapshot=new Map;bellMetadata=new Map;bellAcknowledgementTargets=new Map;bellAcknowledgementQueues=new Map;bellAcknowledgementEpoch=0;notificationBatchDepth=0;notificationPending=!1;constructor(e=(e,t)=>Tf(CE.api.terminals[`:terminalId`].bell.acknowledge.$post({param:{terminalId:e},json:{sequence:t}}))){this.sendBellAcknowledgement=e}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));subscribeBellEvents=e=>(this.bellEventListeners.add(e),()=>this.bellEventListeners.delete(e));getAttentionSnapshot=()=>this.attentionSnapshot;getBellSnapshot=()=>this.bellMetadata;getTitleSnapshot=()=>this.titleSnapshot;getProgramSnapshot=()=>this.programSnapshot;getForegroundProcessSnapshot=()=>this.foregroundProcessSnapshot;getProgressSnapshot=()=>this.progressSnapshot;applyRuntimeMetadata(e){this.notificationBatchDepth+=1;let t=this.bellMetadata.get(e.terminalId),n=e.bell,r=n!==null&&(!t||n.sequence>t.sequence||n.sequence===t.sequence&&(t.unread||!n.unread)),i=r&&(t?.sequence!==n.sequence||t?.at!==n.at||t?.unread!==n.unread),a=r&&n.unread&&(!t||n.sequence>t.sequence)?{terminalId:e.terminalId,sequence:n.sequence,at:n.at}:null;if(r){if(i){let t=new Map(this.bellMetadata);t.set(e.terminalId,{sequence:n.sequence,at:n.at,unread:n.unread}),this.bellMetadata=t,this.emit()}this.setAttention(e.terminalId,n.unread)}else!t&&n===null&&this.setAttention(e.terminalId,!1);this.setRuntimeTitle(e.terminalId,e.title),this.setProgram(e.terminalId,e.program??null),this.setForegroundProcess(e.terminalId,e.hasForegroundProcess===!0),this.setProgress(e.terminalId,e.progress),--this.notificationBatchDepth,this.notificationBatchDepth===0&&this.notificationPending&&(this.notificationPending=!1,this.listeners.forEach(e=>e())),a&&this.bellEventListeners.forEach(e=>e(a))}replaceRuntimeMetadata(e){let t=new Map,n=new Map,r=new Set,i=new Map,a=new Map,o=new Set;for(let s of e){let e=s.title?.trim().slice(0,256);if(e&&t.set(s.terminalId,e),s.program&&n.set(s.terminalId,s.program),s.hasForegroundProcess&&r.add(s.terminalId),s.progress){let e=this.progressSnapshot.get(s.terminalId);i.set(s.terminalId,e?.state===s.progress.state&&e.value===s.progress.value?e:s.progress)}s.bell&&(a.set(s.terminalId,{sequence:s.bell.sequence,at:s.bell.at,unread:s.bell.unread}),s.bell.unread&&o.add(s.terminalId))}let s=t.size!==this.titleSnapshot.size||[...t].some(([e,t])=>this.titleSnapshot.get(e)!==t),c=n.size!==this.programSnapshot.size||[...n].some(([e,t])=>this.programSnapshot.get(e)!==t),l=r.size!==this.foregroundProcessSnapshot.size||[...r].some(e=>!this.foregroundProcessSnapshot.has(e)),u=i.size!==this.progressSnapshot.size||[...i].some(([e,t])=>{let n=this.progressSnapshot.get(e);return n?.state!==t.state||n.value!==t.value}),d=o.size!==this.attentionSnapshot.size||[...o].some(e=>!this.attentionSnapshot.has(e)),f=a.size!==this.bellMetadata.size||[...a].some(([e,t])=>{let n=this.bellMetadata.get(e);return n?.sequence!==t.sequence||n?.at!==t.at||n?.unread!==t.unread});f&&(this.bellMetadata=a),this.bellAcknowledgementEpoch+=1,this.bellAcknowledgementTargets.clear(),s&&(this.titleSnapshot=t),c&&(this.programSnapshot=n),l&&(this.foregroundProcessSnapshot=r),u&&(this.progressSnapshot=i),d&&(this.attentionSnapshot=o),(s||c||l||u||d||f)&&this.emit()}setRuntimeTitle(e,t){let n=t?.trim().slice(0,256)||null;if(n===null){this.clearRuntimeTitle(e);return}this.titleSnapshot.get(e)!==n&&(this.titleSnapshot=new Map(this.titleSnapshot).set(e,n),this.emit())}forget(e){if(this.bellMetadata.has(e)){let t=new Map(this.bellMetadata);t.delete(e),this.bellMetadata=t,this.emit()}this.bellAcknowledgementTargets.delete(e),this.bellAcknowledgementQueues.delete(e),this.clearAttention(e),this.clearRuntimeTitle(e),this.setProgram(e,null),this.setForegroundProcess(e,!1),this.setProgress(e,null)}reconcile(e){let t=new Set(e),n=!1,r=new Set(this.attentionSnapshot),i=new Map(this.titleSnapshot),a=new Map(this.programSnapshot),o=new Set(this.foregroundProcessSnapshot),s=new Map(this.progressSnapshot);for(let e of r)t.has(e)||(r.delete(e),n=!0);for(let e of i.keys())t.has(e)||(i.delete(e),n=!0);for(let e of a.keys())t.has(e)||(a.delete(e),n=!0);for(let e of o)t.has(e)||(o.delete(e),n=!0);for(let e of s.keys())t.has(e)||(s.delete(e),n=!0);let c=new Map(this.bellMetadata);for(let e of c.keys())t.has(e)||(c.delete(e),this.bellAcknowledgementTargets.delete(e),this.bellAcknowledgementQueues.delete(e),n=!0);n&&(this.attentionSnapshot=r,this.titleSnapshot=i,this.programSnapshot=a,this.foregroundProcessSnapshot=o,this.progressSnapshot=s,this.bellMetadata=c,this.emit())}acknowledgeBell(e,t){let n=this.bellMetadata.get(e);if(!n?.unread||n.sequence!==t)return Promise.resolve();let r=this.bellAcknowledgementTargets.get(e)??0,i=this.bellAcknowledgementQueues.get(e);if(t<=r)return i??Promise.resolve();let a=this.bellAcknowledgementEpoch;this.bellAcknowledgementTargets.set(e,t);let o=(i??Promise.resolve()).catch(()=>void 0).then(async()=>{let n=this.bellMetadata.get(e);if(this.bellAcknowledgementEpoch!==a||n?.sequence!==t||!n.unread){this.bellAcknowledgementTargets.get(e)===t&&this.bellAcknowledgementTargets.delete(e);return}await this.sendBellAcknowledgement(e,t)}).catch(n=>{throw this.bellAcknowledgementTargets.get(e)===t&&this.bellAcknowledgementTargets.delete(e),n}).finally(()=>{this.bellAcknowledgementQueues.get(e)===o&&this.bellAcknowledgementQueues.delete(e)});return this.bellAcknowledgementQueues.set(e,o),o}clearAttention(e){if(!this.attentionSnapshot.has(e))return;let t=new Set(this.attentionSnapshot);t.delete(e),this.attentionSnapshot=t,this.emit()}clearRuntimeTitle(e){if(!this.titleSnapshot.has(e))return;let t=new Map(this.titleSnapshot);t.delete(e),this.titleSnapshot=t,this.emit()}setProgram(e,t){if(this.programSnapshot.get(e)===t)return;let n=new Map(this.programSnapshot);t?n.set(e,t):n.delete(e),this.programSnapshot=n,this.emit()}setForegroundProcess(e,t){if(this.foregroundProcessSnapshot.has(e)===t)return;let n=new Set(this.foregroundProcessSnapshot);t?n.add(e):n.delete(e),this.foregroundProcessSnapshot=n,this.emit()}setAttention(e,t){if(t||this.bellAcknowledgementTargets.delete(e),this.attentionSnapshot.has(e)===t)return;let n=new Set(this.attentionSnapshot);t?n.add(e):n.delete(e),this.attentionSnapshot=n,this.emit()}setProgress(e,t){let n=this.progressSnapshot.get(e);if(t&&n?.state===t.state&&n.value===t.value||!t&&!n)return;let r=new Map(this.progressSnapshot);t?r.set(e,t):r.delete(e),this.progressSnapshot=r,this.emit()}emit(){if(this.notificationBatchDepth>0){this.notificationPending=!0;return}this.listeners.forEach(e=>e())}},VP=new class{pool;runtimeMetadata;constructor(e=8,t=5*6e4,n=e=>new RP(e),r){this.runtimeMetadata=new BP(r),this.pool=new zP(e,t,n,(e,t)=>this.runtimeMetadata.setRuntimeTitle(e,t))}subscribe=e=>this.runtimeMetadata.subscribe(e);subscribeBellEvents=e=>this.runtimeMetadata.subscribeBellEvents(e);getAttentionSnapshot=()=>this.runtimeMetadata.getAttentionSnapshot();getBellSnapshot=()=>this.runtimeMetadata.getBellSnapshot();getTitleSnapshot=()=>this.runtimeMetadata.getTitleSnapshot();getProgramSnapshot=()=>this.runtimeMetadata.getProgramSnapshot();getForegroundProcessSnapshot=()=>this.runtimeMetadata.getForegroundProcessSnapshot();getProgressSnapshot=()=>this.runtimeMetadata.getProgressSnapshot();getInitialSize(e){return this.pool.getInitialSize(e)}applyRuntimeMetadata(e){this.runtimeMetadata.applyRuntimeMetadata(e)}replaceRuntimeMetadata(e){this.runtimeMetadata.replaceRuntimeMetadata(e)}acquire(e){return this.pool.acquire(e)}release(e){this.pool.release(e)}forget(e){this.pool.forget(e),this.runtimeMetadata.forget(e)}reconcile(e){let t=[...e].map(e=>e.id);this.pool.reconcile(t),this.runtimeMetadata.reconcile(t)}acknowledgeBell(e,t){return this.runtimeMetadata.acknowledgeBell(e,t)}},HP=new Set,UP=new Map,WP=new Map,GP=new Map,KP=new Map,qP={attention:HP,titles:UP,programs:WP,progress:GP},JP={bells:KP,titles:UP},YP=qP,XP=JP;function ZP(){let e=VP.getAttentionSnapshot(),t=VP.getTitleSnapshot(),n=VP.getProgramSnapshot(),r=VP.getProgressSnapshot();return(YP.attention!==e||YP.titles!==t||YP.programs!==n||YP.progress!==r)&&(YP={attention:e,titles:t,programs:n,progress:r}),YP}function QP(){let e=VP.getBellSnapshot(),t=VP.getTitleSnapshot();return(XP.bells!==e||XP.titles!==t)&&(XP={bells:e,titles:t}),XP}function $P(){return(0,R.useSyncExternalStore)(VP.subscribe,ZP,()=>qP)}function eF(){return(0,R.useSyncExternalStore)(VP.subscribe,QP,()=>JP)}var tF=`treeport-last-workspace-route`,nF=`treeport-last-project-terminal:`;function rF(e,t){return e!==null&&e===t}function iF(e){return encodeURIComponent(e)}function aF(e){return{kind:`project`,pathname:`/projects/${iF(e)}`,projectId:e}}function oF(e,t){return{kind:`worktree`,pathname:`/projects/${iF(e)}/worktrees/${iF(t)}`,projectId:e,worktreeId:t}}function sF(e,t,n){return{kind:`terminal`,pathname:`/projects/${iF(e)}/worktrees/${iF(t)}/terminals/${iF(n)}`,projectId:e,worktreeId:t,terminalId:n}}function cF(e,t,n){return{kind:`panel`,pathname:`/projects/${iF(e)}/worktrees/${iF(t)}/panels/${iF(n)}`,projectId:e,worktreeId:t,panelId:n}}function lF(e){let t=e.worktrees[0];if(!t)return aF(e.id);let n=t.terminals[0];return n?sF(e.id,t.id,n.id):oF(e.id,t.id)}function uF(e,t){if(t)for(let n of e.worktrees){let r=n.terminals.find(e=>e.id===t);if(r)return sF(e.id,n.id,r.id)}return lF(e)}function dF(e,t){let n=t.terminals[0];return n?sF(e.id,t.id,n.id):oF(e.id,t.id)}function fF(e,t){for(let n of e){let e=n.worktrees.find(e=>e.id===t.worktreeId);if(e?.panels.some(e=>e.kind===`web`&&e.id===t.id))return cF(n.id,e.id,t.id)}return null}function pF(e,t){for(let n of e){let e=n.worktrees.find(e=>e.id===t.worktreeId);if(e?.terminals.some(e=>e.id===t.id))return sF(n.id,e.id,t.id)}return null}function mF(e,t,n){let r=e.find(e=>e.id===t.projectId&&e.worktrees.some(e=>e.id===t.id));if(!r)return null;let i=t.terminals.find(e=>e.id===n)??t.terminals[0];return i?sF(r.id,t.id,i.id):oF(r.id,t.id)}function hF(e,t){if(t.kind===`root`)return{project:null,worktree:null,terminal:null,panel:null};let n=e.find(e=>e.id===t.projectId)??null;if(!n||t.kind===`project`)return{project:n,worktree:null,terminal:null,panel:null};let r=n.worktrees.find(e=>e.id===t.worktreeId)??null;return!r||t.kind===`worktree`?{project:n,worktree:r,terminal:null,panel:null}:t.kind===`panel`?{project:n,worktree:r,terminal:null,panel:r.panels.find(e=>e.kind===`web`&&e.id===t.panelId)??null}:{project:n,worktree:r,terminal:r.terminals.find(e=>e.id===t.terminalId)??null,panel:null}}function gF(e){try{return decodeURIComponent(e)}catch{return null}}function _F(e){if(e===`/`)return{kind:`root`,pathname:`/`};let t=e.split(`/`).filter(Boolean);if(t[0]!==`projects`)return null;let n=t[1]?gF(t[1]):null;if(!n)return null;if(t.length===2)return aF(n);if(t[2]!==`worktrees`)return null;let r=t[3]?gF(t[3]):null;if(!r)return null;if(t.length===4)return oF(n,r);let i=t[5]?gF(t[5]):null;return!i||t.length!==6?null:t[4]===`terminals`?sF(n,r,i):t[4]===`panels`?cF(n,r,i):null}function vF(e){return e[0]?lF(e[0]):{kind:`root`,pathname:`/`}}function yF(e,t){if(!t||t.kind===`root`)return vF(e);let n=e.find(e=>e.id===t.projectId);if(!n)return vF(e);if(t.kind===`project`)return n.worktrees.length?lF(n):aF(n.id);let r=n.worktrees.find(e=>e.id===t.worktreeId);if(!r)return n.worktrees[0]?dF(n,n.worktrees[0]):aF(n.id);if(t.kind===`worktree`)return dF(n,r);if(t.kind===`panel`){let e=r.panels.find(e=>e.kind===`web`&&e.id===t.panelId);return e?cF(n.id,r.id,e.id):dF(n,r)}let i=r.terminals.find(e=>e.id===t.terminalId);return i?sF(n.id,r.id,i.id):dF(n,r)}function bF(e,t,n){let r=_F(t),i;if(r?.kind===`root`&&e.length&&n){let t=_F(n);i=t?.kind!==`root`&&e.some(e=>e.id===t?.projectId)?yF(e,t):vF(e)}else i=yF(e,r);return{target:i,selection:hF(e,i),canonical:i.pathname===t}}function xF(e,{operation:t}){let n=kE(e),r=[n.message,n.recoveryHint,n.requestId?`Reference: ${n.requestId}.`:null].filter(e=>!!e).join(` `);za.error(`Couldn’t ${t}`,{description:r})}function SF(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=new Date,r=t.toDateString()===n.toDateString();return new Intl.DateTimeFormat(void 0,r?{hour:`numeric`,minute:`2-digit`}:{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(t)}function CF({projects:e,navigateToWorkspace:t,open:n,onOpenChange:r}){let{bells:i,titles:a}=eF(),[o,s]=(0,R.useState)(()=>new Set),c=(0,R.useMemo)(()=>e.flatMap(t=>t.worktrees.flatMap(n=>n.terminals.flatMap(r=>{let o=i.get(r.id),s=pF(e,r);return o?.unread&&s?[{terminalId:r.id,sequence:o.sequence,occurredAt:o.at,title:a.get(r.id)??r.name,context:`${t.name} · ${n.name}`,target:s}]:[]}))).sort((e,t)=>t.occurredAt.localeCompare(e.occurredAt)||e.terminalId.localeCompare(t.terminalId)),[i,e,a]),l=c.length,u=l===0?`Notifications, no unread notifications`:`Notifications, ${l} unread`,d=async(e,t,n)=>{s(t=>new Set(t).add(e)),await VP.acknowledgeBell(e,t).catch(e=>{xF(e,{operation:`mark notification for terminal “${n}” as read`})}),s(t=>{let n=new Set(t);return n.delete(e),n})};return(0,z.jsxs)(Vh,{modal:!0,open:n,onOpenChange:r,children:[(0,z.jsx)(Hh,{asChild:!0,children:(0,z.jsxs)(G,{type:`button`,size:`icon`,variant:`ghost`,className:`icon-button text-zinc-400 hover:bg-white/5 hover:text-zinc-100`,"aria-label":u,children:[(0,z.jsx)(Gf,{}),l>0?(0,z.jsx)(Sp,{size:`counter`,className:`pointer-events-none absolute -top-0.5 -right-0.5`,"aria-hidden":!0,children:l>99?`99+`:l}):null]})}),(0,z.jsxs)(Uh,{align:`end`,className:`flex max-h-[min(26rem,calc(100dvh-1rem))] w-[min(22rem,calc(100vw-1rem))] touch-manipulation flex-col overflow-hidden p-0 select-none`,"aria-label":`Notifications`,children:[(0,z.jsx)(`div`,{className:`shrink-0 px-3 pt-3 pb-2`,children:(0,z.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Notifications`})}),c.length===0?(0,z.jsxs)(wp,{className:`min-h-28 p-4`,children:[(0,z.jsx)(Tp,{children:`All caught up`}),(0,z.jsx)(Ep,{children:`No unread notifications.`})]}):(0,z.jsx)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain px-1.5 pb-1.5`,children:(0,z.jsx)(`ul`,{role:`list`,className:`flex flex-col gap-0.5`,children:c.map(e=>(0,z.jsx)(`li`,{className:`min-w-0`,children:(0,z.jsxs)(`button`,{type:`button`,className:`w-full min-w-0 cursor-default rounded-md px-2 py-2 text-left outline-none hover:bg-white/5 focus-visible:bg-white/5 focus-visible:outline-2 focus-visible:outline-cyan-400 disabled:opacity-45`,disabled:o.has(e.terminalId),"aria-label":`Open ${e.title}`,onClick:()=>{r(!1),d(e.terminalId,e.sequence,e.title).then(()=>t(e.target))},children:[(0,z.jsx)(`h3`,{className:`truncate text-sm font-medium text-zinc-100`,children:e.title}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-1.5 text-xs text-zinc-500`,children:[(0,z.jsx)(`p`,{className:`min-w-0 truncate`,children:e.context}),(0,z.jsx)(`span`,{className:`shrink-0`,"aria-hidden":!0,children:`·`}),(0,z.jsx)(`time`,{dateTime:e.occurredAt,className:`shrink-0 tabular-nums`,children:SF(e.occurredAt)})]})]})},e.terminalId))})})]})]})}function wF(e,t,n){for(let r of e)for(let e of r.worktrees){let r=e.terminals.find(e=>e.id===n);if(r)return t.get(n)??r.name}return null}function TF({projects:e,selectedTerminalId:t}){let{bells:n,titles:r}=eF(),i=(0,R.useRef)({projects:e,selectedTerminalId:t,titles:r,presence:{focused:document.hasFocus(),visible:document.visibilityState===`visible`}});i.current.projects=e,i.current.selectedTerminalId=t,i.current.titles=r;let a=()=>{let e=i.current,t=e.selectedTerminalId;if(!t||!e.presence.focused||!e.presence.visible)return;let n=VP.getBellSnapshot().get(t);if(!n?.unread)return;let r=wF(e.projects,e.titles,t);VP.acknowledgeBell(t,n.sequence).catch(e=>{xF(e,{operation:r?`acknowledge notification for terminal “${r}”`:`acknowledge terminal notification`})})};return(0,R.useEffect)(()=>{let e=()=>{i.current.presence={focused:document.hasFocus(),visible:document.visibilityState===`visible`},a()};return document.addEventListener(`visibilitychange`,e),window.addEventListener(`focus`,e),window.addEventListener(`blur`,e),()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`focus`,e),window.removeEventListener(`blur`,e)}},[]),(0,R.useEffect)(()=>{a()},[n,t]),(0,R.useEffect)(()=>VP.subscribeBellEvents(e=>{let t=i.current;if(t.selectedTerminalId===e.terminalId&&t.presence.focused&&t.presence.visible){let n=wF(t.projects,VP.getTitleSnapshot(),e.terminalId);VP.acknowledgeBell(e.terminalId,e.sequence).catch(e=>{xF(e,{operation:n?`acknowledge notification for terminal “${n}”`:`acknowledge terminal notification`})});return}window.treeportDesktop?.requestAttention()}),[]),null}var EF=Object.defineProperty,DF=(e,t)=>EF(e,`name`,{value:t,configurable:!0});function OF(e,t){let n=R.createContext(t);n.displayName=e+`Context`;let r=DF(e=>{let{children:t,...r}=e,i=R.useMemo(()=>r,Object.values(r));return(0,z.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=R.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return DF(i,`useContext`),[r,i]}DF(OF,`createContext`);function kF(e,t=[]){let n=[];function r(t,r){let i=R.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=DF(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=R.useMemo(()=>o,Object.values(o));return(0,z.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=R.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return DF(s,`useContext`),[o,s]}DF(r,`createContext`);let i=DF(()=>{let t=n.map(e=>R.createContext(e));return DF(function(n){let r=n?.[e]||t;return R.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,AF(i,...t)]}DF(kF,`createContextScope`);function AF(...e){let t=e[0];if(e.length===1)return t;let n=DF(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return DF(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return R.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}DF(AF,`composeContextScopes`);var jF=Object.defineProperty,MF=(e,t)=>jF(e,`name`,{value:t,configurable:!0}),NF=!!(typeof window<`u`&&window.document&&window.document.createElement);function PF(e,t,{checkForDefaultPrevented:n=!0}={}){return MF(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}MF(PF,`composeEventHandlers`);function FF(e){if(!NF)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}MF(FF,`getOwnerWindow`);function IF(e){if(!NF)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}MF(IF,`getOwnerDocument`);function LF(e,t=!1){let{activeElement:n}=IF(e);if(!n?.nodeName)return null;if(RF(n)&&n.contentDocument)return LF(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=IF(n).getElementById(e);if(t)return t}}return n}MF(LF,`getActiveElement`);function RF(e){return e.tagName===`IFRAME`}MF(RF,`isFrame`);var zF=globalThis?.document?R.useLayoutEffect:()=>{},BF=Object.defineProperty,VF=(e,t)=>BF(e,`name`,{value:t,configurable:!0}),HF=R.useId||(()=>void 0),UF=0;function WF(e){let[t,n]=R.useState(HF());return zF(()=>{e||n(e=>e??String(UF++))},[e]),e||(t?`radix-${t}`:``)}VF(WF,`useId`);var GF=Object.defineProperty,KF=(e,t)=>GF(e,`name`,{value:t,configurable:!0}),qF=R.useEffectEvent,JF=R.useInsertionEffect;function YF(e){if(typeof qF==`function`)return qF(e);let t=R.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof JF==`function`?JF(()=>{t.current=e}):zF(()=>{t.current=e}),R.useMemo(()=>((...e)=>t.current?.(...e)),[])}KF(YF,`useEffectEvent`);var XF=Object.defineProperty,ZF=(e,t)=>XF(e,`name`,{value:t,configurable:!0}),QF=R.useInsertionEffect||zF;function $F({prop:e,defaultProp:t,onChange:n=ZF(()=>{},`onChange`),caller:r}){let[i,a,o]=eI({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,R.useCallback(t=>{if(s){let n=tI(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}ZF($F,`useControllableState`);function eI({defaultProp:e,onChange:t}){let[n,r]=R.useState(e),i=R.useRef(n),a=R.useRef(t);return QF(()=>{a.current=t},[t]),R.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}ZF(eI,`useUncontrolledState`);function tI(e){return typeof e==`function`}ZF(tI,`isFunction`);var nI=Symbol(`RADIX:SYNC_STATE`);function rI(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=YF(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=R.useReducer((t,n)=>{if(n.type===nI)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=R.useRef(p);R.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=R.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return R.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:nI,state:i})},[i,d.state,c]),[h,f]}ZF(rI,`useControllableStateReducer`);var iI=Object.defineProperty,aI=(e,t)=>iI(e,`name`,{value:t,configurable:!0}),oI=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=ip(`Primitive.${t}`),r=R.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,z.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function sI(e,t){e&&Bi.flushSync(()=>e.dispatchEvent(t))}aI(sI,`dispatchDiscreteCustomEvent`);var cI=Object.defineProperty,lI=(e,t)=>cI(e,`name`,{value:t,configurable:!0});function uI(e){let t=R.useRef(e);return R.useEffect(()=>{t.current=e}),R.useMemo(()=>((...e)=>t.current?.(...e)),[])}lI(uI,`useCallbackRef`);var dI=Object.defineProperty,fI=(e,t)=>dI(e,`name`,{value:t,configurable:!0}),pI=`dismissableLayer.update`,mI=`dismissableLayer.pointerDownOutside`,hI=`dismissableLayer.focusOutside`,gI,_I=R.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),vI=R.forwardRef(fI(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=R.useContext(_I),[d,f]=R.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=R.useState({}),h=tp(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=_?g.indexOf(_):-1,y=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,S=R.useRef(!1),C=xI(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:R.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return x&&!t},[u.branches,x])}),w=SI(e=>{if(r&&S.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),T=d?y===g.length-1:!1,E=uI(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return R.useEffect(()=>{if(T)return p.addEventListener(`keydown`,E,{capture:!0}),()=>p.removeEventListener(`keydown`,E,{capture:!0})},[p,T,E]),R.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(gI=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),CI(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=gI))}},[d,p,n,u]),R.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),CI())},[d,u]),R.useEffect(()=>{let e=fI(()=>m({}),`handleUpdate`);return document.addEventListener(pI,e),()=>document.removeEventListener(pI,e)},[]),(0,z.jsx)(oI.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:PF(e.onFocusCapture,w.onFocusCapture),onBlurCapture:PF(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:PF(e.onPointerDownCapture,C.onPointerDownCapture)})},`DismissableLayer`));function yI(){let e=R.useContext(_I),[t,n]=R.useState(null);return R.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}fI(yI,`useDismissableLayerSurface`);var bI=fI(()=>!0,`IS_TRUE`);function xI(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=bI}=t,s=uI(e),c=R.useRef(!1),l=R.useRef(!1),u=R.useRef(new Map),d=R.useRef(()=>{});return R.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}fI(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}fI(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}fI(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}fI(p,`handleInteractionBubble`);let m=fI(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||wI(mI,s,p,{discrete:!0})};if(fI(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:fI(()=>c.current=!0,`onPointerDownCapture`)}}fI(xI,`usePointerDownOutside`);function SI(e,t=globalThis?.document){let n=uI(e),r=R.useRef(!1);return R.useEffect(()=>{let e=fI(e=>{e.target&&!r.current&&wI(hI,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:fI(()=>r.current=!0,`onFocusCapture`),onBlurCapture:fI(()=>r.current=!1,`onBlurCapture`)}}fI(SI,`useFocusOutside`);function CI(){let e=new CustomEvent(pI);document.dispatchEvent(e)}fI(CI,`dispatchUpdate`);function wI(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?sI(i,a):i.dispatchEvent(a)}fI(wI,`handleAndDispatchCustomEvent`);var TI=Object.defineProperty,EI=(e,t)=>TI(e,`name`,{value:t,configurable:!0}),DI=`focusScope.autoFocusOnMount`,OI=`focusScope.autoFocusOnUnmount`,kI={bubbles:!1,cancelable:!0},AI=R.forwardRef(EI(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=R.useState(null),l=uI(i),u=uI(a),d=R.useRef(null),f=tp(t,c),p=R.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;R.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:LI(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||LI(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&LI(s)};EI(e,`handleFocusIn`),EI(t,`handleFocusOut`),EI(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),R.useEffect(()=>{if(s){RI.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(DI,kI);s.addEventListener(DI,l),s.dispatchEvent(t),t.defaultPrevented||(jI(VI(NI(s)),{select:!0}),document.activeElement===e&&LI(s))}return()=>{s.removeEventListener(DI,l),setTimeout(()=>{let t=new CustomEvent(OI,kI);s.addEventListener(OI,u),s.dispatchEvent(t),t.defaultPrevented||LI(e??document.body,{select:!0}),s.removeEventListener(OI,u),RI.remove(p)},0)}}},[s,l,u,p]);let m=R.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=MI(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&LI(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&LI(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,z.jsx)(oI.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})},`FocusScope`));function jI(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(LI(r,{select:t}),document.activeElement!==n)return}EI(jI,`focusFirst`);function MI(e){let t=NI(e);return[PI(t,e),PI(t.reverse(),e)]}EI(MI,`getTabbableEdges`);function NI(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:EI(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}EI(NI,`getTabbableCandidates`);function PI(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):FI(r,{upTo:t})))return r}EI(PI,`findVisible`);function FI(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}EI(FI,`isHidden`);function II(e){return e instanceof HTMLInputElement&&`select`in e}EI(II,`isSelectableInput`);function LI(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&II(e)&&t&&e.select()}}EI(LI,`focus`);var RI=zI();function zI(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=BI(e,t),e.unshift(t)},remove(t){e=BI(e,t),e[0]?.resume()}}}EI(zI,`createFocusScopesStack`);function BI(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}EI(BI,`arrayRemove`);function VI(e){return e.filter(e=>e.tagName!==`A`)}EI(VI,`removeLinks`);var HI=Object.defineProperty,UI=R.forwardRef(((e,t)=>HI(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=R.useState(!1);zF(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Bi.createPortal((0,z.jsx)(oI.div,{...r,ref:t}),o):null},`Portal`)),WI=Object.defineProperty,GI=(e,t)=>WI(e,`name`,{value:t,configurable:!0});function KI(e,t){return R.useReducer((e,n)=>t[e][n]??e,e)}GI(KI,`useStateMachine`);var qI=GI(e=>{let{present:t,children:n}=e,r=JI(t),i=typeof n==`function`?n({present:r.isPresent}):R.Children.only(n),a=XI(r.ref,QI(i));return typeof n==`function`||r.isPresent?R.cloneElement(i,{ref:a}):null},`Presence`);function JI(e){let[t,n]=R.useState(),r=R.useRef(null),i=R.useRef(e),a=R.useRef(`none`),o=R.useRef(void 0),[s,c]=KI(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return R.useEffect(()=>{s===`mounted`?(a.current=o.current??ZI(r.current),o.current=void 0):a.current=`none`},[s]),zF(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=ZI(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),zF(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=GI(a=>{let o=ZI(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=GI(e=>{e.target===t&&(a.current=ZI(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:R.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=ZI(t)}else r.current=null;n(e)},[])}}GI(JI,`usePresence`);function YI(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}GI(YI,`setRef`);function XI(...e){let t=R.useRef(e);return t.current=e,R.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=YI(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():YI(n[e],null)}}},[])}GI(XI,`useStableComposedRefs`);function ZI(e){return e?.animationName||`none`}GI(ZI,`getAnimationName`);function QI(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}GI(QI,`getElementRef`);var $I=Object.defineProperty,eL=(e,t)=>$I(e,`name`,{value:t,configurable:!0}),tL=0,nL=null;function rL(e){return iL(),e.children}eL(rL,`FocusGuards`);function iL(){R.useEffect(()=>{nL||={start:aL(),end:aL()};let{start:e,end:t}=nL;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),tL++,()=>{tL===1&&(nL?.start.remove(),nL?.end.remove(),nL=null),tL=Math.max(0,tL-1)}},[])}eL(iL,`useFocusGuards`);function aL(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}eL(aL,`createFocusGuard`);var oL=Object.defineProperty,sL=(e,t)=>oL(e,`name`,{value:t,configurable:!0}),cL=`Dialog`,[lL,uL]=kF(cL),[dL,fL]=lL(cL),pL=sL(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=R.useRef(null),c=R.useRef(null),[l,u]=$F({prop:r,defaultProp:i??!1,onChange:a,caller:cL}),[d,f]=R.useState(0),[p,m]=R.useState(0);return(0,z.jsx)(dL,{scope:t,triggerRef:s,contentRef:c,contentId:WF(),titleId:WF(),descriptionId:WF(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:R.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),mL=`DialogTrigger`,hL=R.forwardRef(sL(function(e,t){let{__scopeDialog:n,...r}=e,i=fL(mL,n),a=tp(t,i.triggerRef);return(0,z.jsx)(oI.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":FL(i.open),...r,ref:a,onClick:PF(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),gL=`DialogPortal`,[_L,vL]=lL(gL,{forceMount:void 0}),yL=sL(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=fL(gL,t);return(0,z.jsx)(_L,{scope:t,forceMount:n,children:R.Children.map(r,e=>(0,z.jsx)(qI,{present:n||a.open,children:(0,z.jsx)(UI,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),bL=`DialogOverlay`,xL=R.forwardRef(sL(function(e,t){let n=vL(bL,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=fL(bL,e.__scopeDialog);return a.modal?(0,z.jsx)(qI,{present:r||a.open,children:(0,z.jsx)(CL,{...i,ref:t})}):null},`DialogOverlay`)),SL=ip(`DialogOverlay.RemoveScroll`),CL=R.forwardRef(sL(function(e,t){let{__scopeDialog:n,...r}=e,i=fL(bL,n),a=tp(t,yI());return(0,z.jsx)(uh,{as:SL,allowPinchZoom:!0,shards:[i.contentRef],children:(0,z.jsx)(oI.div,{"data-state":FL(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),wL=`DialogContent`,TL=R.forwardRef(sL(function(e,t){let n=vL(wL,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=fL(wL,e.__scopeDialog);return(0,z.jsx)(qI,{present:r||a.open,children:a.modal?(0,z.jsx)(EL,{...i,ref:t}):(0,z.jsx)(DL,{...i,ref:t})})},`DialogContent`)),EL=R.forwardRef(sL(function(e,t){let n=fL(wL,e.__scopeDialog),r=R.useRef(null),i=tp(t,n.contentRef,r);return R.useEffect(()=>{let e=r.current;if(e)return tm(e)},[]),(0,z.jsx)(OL,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:PF(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:PF(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:PF(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),DL=R.forwardRef(sL(function(e,t){let n=fL(wL,e.__scopeDialog),r=R.useRef(!1),i=R.useRef(!1);return(0,z.jsx)(OL,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),OL=R.forwardRef(sL(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=fL(wL,n);return iL(),(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(AI,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,z.jsx)(vI,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":FL(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),kL=`DialogTitle`,AL=R.forwardRef(sL(function(e,t){let{__scopeDialog:n,...r}=e,i=fL(kL,n),{setTitleCount:a}=i;return zF(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,z.jsx)(oI.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),jL=`DialogDescription`,ML=R.forwardRef(sL(function(e,t){let{__scopeDialog:n,...r}=e,i=fL(jL,n),{setDescriptionCount:a}=i;return zF(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,z.jsx)(oI.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),NL=`DialogClose`,PL=R.forwardRef(sL(function(e,t){let{__scopeDialog:n,...r}=e,i=fL(NL,n);return(0,z.jsx)(oI.button,{type:`button`,...r,ref:t,onClick:PF(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function FL(e){return e?`open`:`closed`}sL(FL,`getState`);var IL=Object.defineProperty,LL=(e,t)=>IL(e,`name`,{value:t,configurable:!0}),[RL,zL]=kF(`AlertDialog`,[uL]),BL=uL(),VL=LL(e=>{let{__scopeAlertDialog:t,...n}=e,r=BL(t);return(0,z.jsx)(pL,{...r,...n,modal:!0})},`AlertDialog`);R.forwardRef(LL(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=BL(n);return(0,z.jsx)(hL,{...i,...r,ref:t})},`AlertDialogTrigger`));var HL=LL(e=>{let{__scopeAlertDialog:t,...n}=e,r=BL(t);return(0,z.jsx)(yL,{...r,...n})},`AlertDialogPortal`),UL=R.forwardRef(LL(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=BL(n);return(0,z.jsx)(xL,{...i,...r,ref:t})},`AlertDialogOverlay`)),[WL,GL]=RL(`AlertDialogContent`),KL=R.forwardRef(LL(function(e,t){let{__scopeAlertDialog:n,children:r,...i}=e,a=BL(n),o=tp(t,R.useRef(null)),s=R.useRef(null);return(0,z.jsx)(WL,{scope:n,cancelRef:s,children:(0,z.jsx)(TL,{role:`alertdialog`,...a,...i,ref:o,onOpenAutoFocus:PF(i.onOpenAutoFocus,e=>{e.preventDefault(),s.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:r})})},`AlertDialogContent`)),qL=R.forwardRef(LL(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=BL(n);return(0,z.jsx)(AL,{...i,...r,ref:t})},`AlertDialogTitle`)),JL=R.forwardRef(LL(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=BL(n);return(0,z.jsx)(ML,{...i,...r,ref:t})},`AlertDialogDescription`)),YL=R.forwardRef(LL(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=BL(n);return(0,z.jsx)(PL,{...i,...r,ref:t})},`AlertDialogAction`)),XL=`AlertDialogCancel`,ZL=R.forwardRef(LL(function(e,t){let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=GL(XL,n),a=BL(n),o=tp(t,i);return(0,z.jsx)(PL,{...a,...r,ref:o})},`AlertDialogCancel`)),QL=VL,$L=HL,eR=UL,tR=KL,nR=YL,rR=ZL,iR=qL,aR=JL,oR=QL,sR=$L,cR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(eR,{ref:n,className:W(`fixed inset-0 z-50 bg-black/70 backdrop-blur-sm`,e),...t}));cR.displayName=eR.displayName;var lR=R.forwardRef(({className:e,restoreFocusTo:t,onCloseAutoFocus:n,...r},i)=>(0,z.jsxs)(sR,{children:[(0,z.jsx)(cR,{}),(0,z.jsx)(tR,{ref:i,className:W(`fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 overflow-y-auto rounded-xl bg-zinc-900 p-6 text-zinc-200 shadow-2xl ring-1 ring-white/10 outline-none max-[700px]:top-auto max-[700px]:bottom-0 max-[700px]:left-0 max-[700px]:max-h-[90dvh] max-[700px]:w-full max-[700px]:max-w-none max-[700px]:translate-x-0 max-[700px]:translate-y-0 max-[700px]:rounded-b-none max-[700px]:p-5 max-[700px]:pb-[calc(1.25rem+env(safe-area-inset-bottom))]`,e),onCloseAutoFocus:e=>{n?.(e),!e.defaultPrevented&&t?.isConnected&&(e.preventDefault(),t.focus())},...r})]}));lR.displayName=tR.displayName;function uR({className:e,...t}){return(0,z.jsx)(`div`,{className:W(`flex flex-col gap-1.5 text-left`,e),...t})}function dR({className:e,...t}){return(0,z.jsx)(`div`,{className:W(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}var fR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(iR,{ref:n,className:W(`text-balance text-xl font-semibold tracking-tight text-zinc-50 sm:text-2xl`,e),...t}));fR.displayName=iR.displayName;var pR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(aR,{ref:n,className:W(`text-base text-pretty text-zinc-400 sm:text-sm`,e),...t}));pR.displayName=aR.displayName;var mR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(nR,{ref:n,className:W(Cp(),e),...t}));mR.displayName=nR.displayName;var hR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(rR,{ref:n,className:W(Cp({variant:`outline`}),e),...t}));hR.displayName=rR.displayName;function gR({panel:e,busy:t,restoreFocusTo:n,onOpenChange:r,onConfirm:i}){return(0,z.jsx)(oR,{open:e!==null,onOpenChange:r,children:e?(0,z.jsxs)(lR,{restoreFocusTo:n,children:[(0,z.jsxs)(uR,{children:[(0,z.jsxs)(fR,{children:[`Close `,e.title,`?`]}),(0,z.jsx)(pR,{children:`This panel has saved data. Closing it permanently deletes that data, including any comments or drafts.`})]}),(0,z.jsxs)(dR,{children:[(0,z.jsx)(hR,{children:`Cancel`}),(0,z.jsx)(mR,{asChild:!0,children:(0,z.jsx)(G,{type:`button`,variant:`destructive`,disabled:t,onClick:t=>{t.preventDefault(),i(e)},children:t?`Closing…`:`Close and delete data`})})]})]}):null})}function _R({panel:e,active:t,title:n,reloadRevision:r,autoFocusBlocked:i,onTitleChange:a,onSelectWorkspace:o}){let s=(0,R.useRef)(null),c=(0,R.useRef)(null),l=`${e.id}:${r}`,[u,d]=(0,R.useState)(null);return(0,R.useEffect)(()=>{a(e.id,null)},[a,e.id,l]),(0,R.useEffect)(()=>{if(!t||i||u!==l)return;let e=window.requestAnimationFrame(()=>s.current?.focus());return()=>window.cancelAnimationFrame(e)},[t,i,u,l]),(0,R.useEffect)(()=>{if(!t)return;let e=e=>{e.key.toLowerCase()!==`f`||!e.metaKey&&!e.ctrlKey||e.altKey||document.querySelector(`[role="dialog"]`)||(e.preventDefault(),(s.current?.contentWindow??c.current)?.postMessage({source:`treeport-host-v1`,method:`shortcut`,shortcut:`find`},`*`))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[t]),(0,R.useEffect)(()=>{let t=t=>{let n=s.current?.contentWindow??c.current;if(t.source!==n||t.data?.source!==`treeport-panel-v1`)return;let r=t.data.method;if(r===`panel.title.set`){t.data.title===null?a(e.id,null):typeof t.data.title==`string`&&a(e.id,t.data.title.trim().slice(0,256)||null);return}if(r===`workspace.select`&&Number.isInteger(t.data.index)&&t.data.index>=0&&t.data.index<=8){o(t.data.index);return}if(typeof t.data.id!=`string`)return;let i;i=r===`context`?Tf(CE.api.panels[`:panelId`].context.$get({param:{panelId:e.id}})).then(e=>e.context):r===`diff`?Tf(CE.api.panels[`:panelId`].diff.$get({param:{panelId:e.id}})).then(e=>e.diff):r===`network.listeners`?Tf(CE.api.panels[`:panelId`].network.listeners.$get({param:{panelId:e.id}})).then(e=>e.discovery):r===`storage.get`&&typeof t.data.key==`string`?Tf(CE.api.panels[`:panelId`].storage.get.$post({param:{panelId:e.id},json:{key:t.data.key}})).then(e=>e.value):r===`storage.set`&&typeof t.data.key==`string`?Tf(CE.api.panels[`:panelId`].storage.$put({param:{panelId:e.id},json:{key:t.data.key,value:t.data.value}})).then(()=>void 0):r===`storage.delete`&&typeof t.data.key==`string`?Tf(CE.api.panels[`:panelId`].storage.$delete({param:{panelId:e.id},json:{key:t.data.key}})).then(()=>void 0):Promise.reject(Error(`Unsupported Treeport SDK method`)),i.then(e=>n?.postMessage({source:`treeport-host-v1`,id:t.data.id,ok:!0,value:e},`*`),e=>n?.postMessage({source:`treeport-host-v1`,id:t.data.id,ok:!1,error:AE(e)},`*`))};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[o,a,e.id]),(0,z.jsx)(R.Activity,{mode:t?`visible`:`hidden`,children:(0,z.jsx)(`main`,{className:`min-h-0 min-w-0 bg-zinc-950`,"aria-label":`${n} web panel`,children:(0,z.jsx)(`iframe`,{ref:s,title:n,src:`/api/web-panels/${encodeURIComponent(e.id)}/assets/`,sandbox:`allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads${e.sandbox.allowSameOrigin?` allow-same-origin`:``}`,allow:`clipboard-read; clipboard-write; fullscreen`,className:W(`h-full w-full border-0 bg-zinc-950`,u===l?`opacity-100`:`opacity-0`),onLoad:()=>{c.current=s.current?.contentWindow??null,d(l)}},l)})})}var vR=pL,yR=yL;function bR(e){let t=window.visualViewport;return t?(t.addEventListener(`resize`,e),t.addEventListener(`scroll`,e),()=>{t.removeEventListener(`resize`,e),t.removeEventListener(`scroll`,e)}):()=>void 0}function xR(){let e=window.visualViewport;return e?`${e.offsetTop}:${e.height}`:null}var SR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(xL,{ref:n,className:W(`fixed inset-0 z-50 bg-black/70 backdrop-blur-sm`,e),...t}));SR.displayName=xL.displayName;var CR=R.forwardRef(({className:e,children:t,restoreFocusTo:n,mobilePresentation:r=`sheet`,overlayClassName:i,onCloseAutoFocus:a,style:o,...s},c)=>{let[l,u]=R.useSyncExternalStore(bR,xR,()=>null)?.split(`:`).map(Number)??[null,null];return(0,z.jsxs)(yR,{children:[(0,z.jsx)(SR,{className:i}),(0,z.jsxs)(TL,{ref:c,className:W(`fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 overflow-y-auto rounded-xl bg-zinc-900 p-6 text-zinc-200 shadow-2xl ring-1 ring-white/10 outline-none max-[700px]:top-auto max-[700px]:bottom-0 max-[700px]:left-0 max-[700px]:max-h-[90dvh] max-[700px]:w-full max-[700px]:max-w-none max-[700px]:translate-x-0 max-[700px]:translate-y-0 max-[700px]:rounded-b-none max-[700px]:p-5 max-[700px]:pb-[calc(1.25rem+env(safe-area-inset-bottom))]`,r===`dialog`&&`keyboard-safe-dialog`,e),style:{...o,"--dialog-visual-viewport-top":r===`dialog`&&l!==null?`${l}px`:void 0,"--dialog-visual-viewport-height":r===`dialog`&&u!==null?`${u}px`:void 0},onCloseAutoFocus:e=>{a?.(e),!e.defaultPrevented&&n?.isConnected&&(e.preventDefault(),n.focus())},...s,children:[t,(0,z.jsxs)(PL,{className:`absolute top-3 right-3 inline-flex size-9 items-center justify-center rounded-md text-zinc-500 outline-none hover:bg-white/5 hover:text-zinc-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-cyan-400 disabled:pointer-events-none [&_svg]:size-4`,children:[(0,z.jsx)(Xf,{}),(0,z.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})});CR.displayName=TL.displayName;function wR({className:e,...t}){return(0,z.jsx)(`div`,{className:W(`flex flex-col gap-1.5 pr-12 text-left`,e),...t})}var TR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(AL,{ref:n,className:W(`text-balance text-xl font-semibold tracking-tight text-zinc-50 sm:text-2xl`,e),...t}));TR.displayName=AL.displayName;var ER=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(ML,{ref:n,className:W(`text-base text-pretty text-zinc-400 sm:text-sm`,e),...t}));ER.displayName=ML.displayName;function DR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M13.836 2.477a.75.75 0 0 1 .75.75v3.182a.75.75 0 0 1-.75.75h-3.182a.75.75 0 0 1 0-1.5h1.37l-.84-.841a4.5 4.5 0 0 0-7.08.932.75.75 0 0 1-1.3-.75 6 6 0 0 1 9.44-1.242l.842.84V3.227a.75.75 0 0 1 .75-.75Zm-.911 7.5A.75.75 0 0 1 13.199 11a6 6 0 0 1-9.44 1.241l-.84-.84v1.371a.75.75 0 0 1-1.5 0V9.591a.75.75 0 0 1 .75-.75H5.35a.75.75 0 0 1 0 1.5H3.98l.841.841a4.5 4.5 0 0 0 7.08-.932.75.75 0 0 1 1.025-.273Z`,clipRule:`evenodd`}))}var OR=R.forwardRef(DR);function kR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M8 14a.75.75 0 0 1-.75-.75V4.56L4.03 7.78a.75.75 0 0 1-1.06-1.06l4.5-4.5a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.75 4.56v8.69A.75.75 0 0 1 8 14Z`,clipRule:`evenodd`}))}var AR=R.forwardRef(kR);function jR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M2 3.75A.75.75 0 0 1 2.75 3h10.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 3.75ZM2 8a.75.75 0 0 1 .75-.75h10.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 8Zm0 4.25a.75.75 0 0 1 .75-.75h10.5a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1-.75-.75Z`,clipRule:`evenodd`}))}var MR=R.forwardRef(jR);function NR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{d:`M7.25 3.688a8.035 8.035 0 0 0-4.872-.523A.48.48 0 0 0 2 3.64v7.994c0 .345.342.588.679.512a6.02 6.02 0 0 1 4.571.81V3.688ZM8.75 12.956a6.02 6.02 0 0 1 4.571-.81c.337.075.679-.167.679-.512V3.64a.48.48 0 0 0-.378-.475 8.034 8.034 0 0 0-4.872.523v9.268Z`}))}var PR=R.forwardRef(NR);function FR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M12.416 3.376a.75.75 0 0 1 .208 1.04l-5 7.5a.75.75 0 0 1-1.154.114l-3-3a.75.75 0 0 1 1.06-1.06l2.353 2.353 4.493-6.74a.75.75 0 0 1 1.04-.207Z`,clipRule:`evenodd`}))}var IR=R.forwardRef(FR);function LR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06Z`,clipRule:`evenodd`}))}var RR=R.forwardRef(LR);function zR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M6.22 4.22a.75.75 0 0 1 1.06 0l3.25 3.25a.75.75 0 0 1 0 1.06l-3.25 3.25a.75.75 0 0 1-1.06-1.06L8.94 8 6.22 5.28a.75.75 0 0 1 0-1.06Z`,clipRule:`evenodd`}))}var BR=R.forwardRef(zR);function VR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M5.22 10.22a.75.75 0 0 1 1.06 0L8 11.94l1.72-1.72a.75.75 0 1 1 1.06 1.06l-2.25 2.25a.75.75 0 0 1-1.06 0l-2.25-2.25a.75.75 0 0 1 0-1.06ZM10.78 5.78a.75.75 0 0 1-1.06 0L8 4.06 6.28 5.78a.75.75 0 0 1-1.06-1.06l2.25-2.25a.75.75 0 0 1 1.06 0l2.25 2.25a.75.75 0 0 1 0 1.06Z`,clipRule:`evenodd`}))}var HR=R.forwardRef(VR);function UR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M6.455 1.45A.5.5 0 0 1 6.952 1h2.096a.5.5 0 0 1 .497.45l.186 1.858a4.996 4.996 0 0 1 1.466.848l1.703-.769a.5.5 0 0 1 .639.206l1.047 1.814a.5.5 0 0 1-.14.656l-1.517 1.09a5.026 5.026 0 0 1 0 1.694l1.516 1.09a.5.5 0 0 1 .141.656l-1.047 1.814a.5.5 0 0 1-.639.206l-1.703-.768c-.433.36-.928.649-1.466.847l-.186 1.858a.5.5 0 0 1-.497.45H6.952a.5.5 0 0 1-.497-.45l-.186-1.858a4.993 4.993 0 0 1-1.466-.848l-1.703.769a.5.5 0 0 1-.639-.206l-1.047-1.814a.5.5 0 0 1 .14-.656l1.517-1.09a5.033 5.033 0 0 1 0-1.694l-1.516-1.09a.5.5 0 0 1-.141-.656L2.46 3.593a.5.5 0 0 1 .639-.206l1.703.769c.433-.36.928-.65 1.466-.848l.186-1.858Zm-.177 7.567-.022-.037a2 2 0 0 1 3.466-1.997l.022.037a2 2 0 0 1-3.466 1.997Z`,clipRule:`evenodd`}))}var WR=R.forwardRef(UR);function GR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M2 4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4Zm2.22 1.97a.75.75 0 0 0 0 1.06l.97.97-.97.97a.75.75 0 1 0 1.06 1.06l1.5-1.5a.75.75 0 0 0 0-1.06l-1.5-1.5a.75.75 0 0 0-1.06 0ZM8.75 8.5a.75.75 0 0 0 0 1.5h2.5a.75.75 0 0 0 0-1.5h-2.5Z`,clipRule:`evenodd`}))}var KR=R.forwardRef(GR);function qR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{d:`M2 3.5A1.5 1.5 0 0 1 3.5 2h2.879a1.5 1.5 0 0 1 1.06.44l1.122 1.12A1.5 1.5 0 0 0 9.62 4H12.5A1.5 1.5 0 0 1 14 5.5v1.401a2.986 2.986 0 0 0-1.5-.401h-9c-.546 0-1.059.146-1.5.401V3.5ZM2 9.5v3A1.5 1.5 0 0 0 3.5 14h9a1.5 1.5 0 0 0 1.5-1.5v-3A1.5 1.5 0 0 0 12.5 8h-9A1.5 1.5 0 0 0 2 9.5Z`}))}var JR=R.forwardRef(qR);function YR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{d:`M8.543 2.232a.75.75 0 0 0-1.085 0l-5.25 5.5A.75.75 0 0 0 2.75 9H4v4a1 1 0 0 0 1 1h1a1 1 0 0 0 1-1v-1a1 1 0 1 1 2 0v1a1 1 0 0 0 1 1h1a1 1 0 0 0 1-1V9h1.25a.75.75 0 0 0 .543-1.268l-5.25-5.5Z`}))}var XR=R.forwardRef(YR);function ZR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M9.965 11.026a5 5 0 1 1 1.06-1.06l2.755 2.754a.75.75 0 1 1-1.06 1.06l-2.755-2.754ZM10.5 7a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0Z`,clipRule:`evenodd`}))}var QR=R.forwardRef(ZR);function $R({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{d:`M8.75 3.75a.75.75 0 0 0-1.5 0v3.5h-3.5a.75.75 0 0 0 0 1.5h3.5v3.5a.75.75 0 0 0 1.5 0v-3.5h3.5a.75.75 0 0 0 0-1.5h-3.5v-3.5Z`}))}var ez=R.forwardRef($R);function tz({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M5 3.25V4H2.75a.75.75 0 0 0 0 1.5h.3l.815 8.15A1.5 1.5 0 0 0 5.357 15h5.285a1.5 1.5 0 0 0 1.493-1.35l.815-8.15h.3a.75.75 0 0 0 0-1.5H11v-.75A2.25 2.25 0 0 0 8.75 1h-1.5A2.25 2.25 0 0 0 5 3.25Zm2.25-.75a.75.75 0 0 0-.75.75V4h3v-.75a.75.75 0 0 0-.75-.75h-1.5ZM6.05 6a.75.75 0 0 1 .787.713l.275 5.5a.75.75 0 0 1-1.498.075l-.275-5.5A.75.75 0 0 1 6.05 6Zm3.9 0a.75.75 0 0 1 .712.787l-.275 5.5a.75.75 0 0 1-1.498-.075l.275-5.5a.75.75 0 0 1 .786-.711Z`,clipRule:`evenodd`}))}var nz=R.forwardRef(tz);function rz({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M2 12V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2Zm1.5-5.5V12a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5V6.5A.5.5 0 0 0 12 6H4a.5.5 0 0 0-.5.5Zm.75-1.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM7 4a.75.75 0 1 1-1.5 0A.75.75 0 0 1 7 4Zm1.25.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Z`,clipRule:`evenodd`}))}var iz=R.forwardRef(rz);function az({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{d:`M5.28 4.22a.75.75 0 0 0-1.06 1.06L6.94 8l-2.72 2.72a.75.75 0 1 0 1.06 1.06L8 9.06l2.72 2.72a.75.75 0 1 0 1.06-1.06L9.06 8l2.72-2.72a.75.75 0 0 0-1.06-1.06L8 6.94 5.28 4.22Z`}))}var oz=R.forwardRef(az);function sz({children:e}){return(0,z.jsx)(`div`,{className:`grid gap-2`,children:e})}function cz({className:e,type:t,...n}){return(0,z.jsx)(`input`,{type:t,"data-slot":`input`,className:W(`h-11 w-full rounded-md bg-zinc-950/70 px-3 py-2 text-base text-zinc-100 ring-1 ring-white/12 outline-none transition-shadow placeholder:text-zinc-600 focus-visible:ring-2 focus-visible:ring-cyan-400 disabled:cursor-not-allowed disabled:opacity-50 sm:h-9 sm:text-sm`,e),...n})}function lz({className:e,...t}){return(0,z.jsx)(`label`,{"data-slot":`label`,className:W(`flex text-base font-medium text-zinc-300 sm:text-sm`,e),...t})}function uz({onOpened:e}){let t=(0,R.useRef)(null),[n,r]=(0,R.useState)(`~`),[i,a]=(0,R.useState)(`~`),[o,s]=(0,R.useState)(!1);(0,R.useEffect)(()=>{let e=window.setTimeout(()=>a(n.trim()),250);return()=>window.clearTimeout(e)},[n]);let c=dt({queryKey:[`filesystem-directories`,i,o],queryFn:()=>Tf(CE.api.filesystem.directories.$get({query:{input:i,...o?{hidden:`true`}:{}}})),enabled:!!i,retry:!1}),l=pt({mutationFn:async e=>(await Tf(CE.api.projects.$post({json:{path:e}}))).project,onSuccess:e,onError:(e,t)=>{xF(e,{operation:`open project at “${t}”`})}}),u=n.trim()===i,d=u&&!c.isError&&c.data?.input===i?c.data:void 0,f=u&&c.isSuccess&&!c.isFetching&&d?.exact&&d.repository.state===`valid`?d.repository:null,p=l.isPending,m=e=>{r(e),a(e),window.requestAnimationFrame(()=>t.current?.focus())};return(0,z.jsxs)(`form`,{className:`flex flex-col gap-3 max-[700px]:gap-4`,onSubmit:e=>{e.preventDefault(),!(!f||p)&&l.mutate(f.repositoryPath)},children:[(0,z.jsxs)(sz,{children:[(0,z.jsx)(lz,{htmlFor:`repository-path`,children:`Server folder`}),(0,z.jsx)(cz,{ref:t,id:`repository-path`,name:`repository-path`,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`Enter`&&!f){e.preventDefault(),a(n.trim());return}if(e.key===`ArrowDown`){let t=document.querySelector(`#project-directory-list button`);t&&(e.preventDefault(),t.focus());return}e.key===`Escape`&&d&&n.trim()!==d.directory.path&&(e.preventDefault(),e.stopPropagation(),m(d.directory.path))}},placeholder:`/Users/you/Projects/example`,"aria-label":`Server folder path`,"aria-describedby":`repository-path-status`,"aria-invalid":c.isError,autoFocus:!0,disabled:p})]}),(0,z.jsx)(`div`,{className:`flex min-h-8 flex-wrap items-center gap-2 min-[701px]:min-h-7`,children:d&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(G,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(d.directory.homePath),disabled:p,children:[(0,z.jsx)(XR,{"data-icon":`inline-start`}),`Home`]}),(0,z.jsx)(G,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(d.directory.rootPath),disabled:p,children:`Root`}),(0,z.jsxs)(`label`,{className:`ml-auto flex cursor-pointer items-center gap-2 text-base text-zinc-400 min-[701px]:text-sm`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),disabled:p}),`Show hidden folders`]})]})}),(0,z.jsxs)(`div`,{className:`overflow-hidden rounded-lg bg-zinc-950/50 ring-1 ring-white/10`,children:[(0,z.jsx)(`div`,{className:`flex min-h-10 items-center gap-1 overflow-x-auto border-b border-white/8 px-2 py-1.5 min-[701px]:min-h-8 min-[701px]:p-1`,children:d&&(0,z.jsxs)(z.Fragment,{children:[d.directory.parentPath&&(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Parent folder`,onClick:()=>m(d.directory.parentPath),disabled:p,children:(0,z.jsx)(AR,{})}),d.directory.breadcrumbs.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t>0&&(0,z.jsx)(BR,{className:`size-3.5 shrink-0 fill-zinc-600`}),(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`max-w-48`,title:e.path,onClick:()=>m(e.path),disabled:p,children:(0,z.jsx)(`span`,{className:`truncate`,children:e.name})})]},e.path))]})}),(0,z.jsxs)(`div`,{id:`project-directory-list`,className:`grid h-64 content-start gap-0.5 overflow-y-auto p-1.5 min-[701px]:h-56 min-[701px]:p-1 [scrollbar-color:var(--color-zinc-700)_transparent]`,"aria-label":`Folders`,children:[c.isFetching&&(0,z.jsx)(`p`,{className:`form-note p-3`,role:`status`,children:`Looking for folders…`}),c.isError&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 p-3`,children:[(0,z.jsx)(`p`,{className:`text-base text-rose-300 min-[701px]:text-sm`,role:`alert`,children:AE(c.error)}),(0,z.jsx)(G,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>c.refetch(),children:`Retry`})]}),!c.isFetching&&d?.directory.entries.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-2 rounded-md px-2.5 py-2 text-left text-base text-zinc-200 outline-none hover:bg-white/6 focus-visible:bg-white/6 focus-visible:outline-2 focus-visible:outline-cyan-400 min-[701px]:px-2 min-[701px]:py-1.5 min-[701px]:text-sm`,title:e.path,onClick:()=>m(e.path),onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),t.current?.focus();return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let n=[...document.querySelectorAll(`#project-directory-list button`)],r=n.indexOf(e.currentTarget),i=e.key===`ArrowDown`?Math.min(r+1,n.length-1):r-1;i>=0?n[i]?.focus():t.current?.focus()},disabled:p,children:[(0,z.jsx)(JR,{className:`size-4 shrink-0 fill-cyan-500/80`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),!c.isFetching&&d&&d.directory.entries.length===0&&(0,z.jsx)(`p`,{className:`form-note p-3`,role:`status`,children:d.exact?`This folder has no subfolders.`:`No matching folders.`}),d?.directory.truncated&&(0,z.jsx)(`p`,{className:`form-note p-3`,role:`status`,children:`More folders are available. Type more of the path to narrow the list.`})]})]}),(0,z.jsx)(`p`,{id:`repository-path-status`,className:W(`form-note min-h-5 truncate`,d?.repository.state===`valid`?`text-emerald-300`:c.isError||d?.repository.state===`not-repository`?`text-rose-300`:void 0),title:d?.repository.state===`valid`?d.repository.repositoryPath:void 0,"aria-live":`polite`,children:i?c.isFetching||!u?`Checking folder…`:c.isError?AE(c.error):d?.repository.state===`valid`?`Will open repository: ${d.repository.repositoryPath}`:d?.repository.message:`Enter a folder path on the Treeport server.`}),(0,z.jsx)(G,{type:`submit`,className:`self-end`,disabled:!f||p,children:p?`Opening…`:`Open project`})]})}function dz({open:e,onOpenChange:t,restoreFocusTo:n,onOpened:r}){return(0,z.jsx)(vR,{open:e,onOpenChange:t,children:(0,z.jsxs)(CR,{className:`max-w-xl gap-3 p-4 max-[700px]:gap-4`,restoreFocusTo:n,children:[(0,z.jsxs)(wR,{children:[(0,z.jsx)(TR,{className:`text-lg tracking-normal sm:text-lg`,children:`Open project`}),(0,z.jsx)(ER,{children:`Browse folders on the Treeport server.`})]}),(0,z.jsx)(uz,{onOpened:r})]})})}var fz=[`projects`],pz=[`recent-projects`],mz=[`terminal-presets`],hz=ft({queryKey:fz,queryFn:async()=>(await Tf(CE.api.projects.$get())).projects,staleTime:kf,refetchInterval:5e3,refetchOnReconnect:!0,refetchOnWindowFocus:!0}),gz=ft({queryKey:pz,queryFn:async()=>(await Tf(CE.api.projects.recent.$get())).projects}),_z=ft({queryKey:mz,queryFn:async()=>(await Tf(CE.api[`terminal-presets`].$get())).presets,staleTime:0,refetchInterval:5e3,refetchOnReconnect:!0,refetchOnWindowFocus:!0}),vz=e=>ft({queryKey:[`terminal-preset-definitions`,e?.worktreeId??e?.projectId??`global`],queryFn:async()=>await Tf(CE.api[`terminal-preset-definitions`].$get({query:{...e?.projectId?{projectId:e.projectId}:{},...e?.worktreeId?{worktreeId:e.worktreeId}:{}}})),staleTime:0,refetchInterval:5e3,refetchOnReconnect:!0,refetchOnWindowFocus:!0});function yz(){let e=Ri(),t=cf();return(0,R.useCallback)((n,r=!1,i=!0)=>{switch(n.kind===`terminal`&&t(n.terminalId,i),n.kind){case`root`:return e({to:`/`,replace:r});case`project`:return e({to:`/projects/$projectId`,params:{projectId:n.projectId},replace:r});case`worktree`:return e({to:`/projects/$projectId/worktrees/$worktreeId`,params:{projectId:n.projectId,worktreeId:n.worktreeId},replace:r});case`terminal`:return e({to:`/projects/$projectId/worktrees/$worktreeId/terminals/$terminalId`,params:{projectId:n.projectId,worktreeId:n.worktreeId,terminalId:n.terminalId},replace:r});case`panel`:return e({to:`/projects/$projectId/worktrees/$worktreeId/panels/$panelId`,params:{projectId:n.projectId,worktreeId:n.worktreeId,panelId:n.panelId},replace:r})}},[e,t])}function bz({projects:e,selectedProject:t,targetForProject:n,projectSwitcherTriggerRef:r,closeProjectUi:i,openedProjectUi:a}){let o=Ye(),s=Ca(),c=yz(),l=pt({mutationFn:e=>Tf(CE.api.projects[`:projectId`].close.$post({param:{projectId:e.id}})),onSuccess:async(a,s)=>{let l=o.getQueryData(fz)??e,u=l.filter(e=>e.id!==s.id),d=l.findIndex(e=>e.id===s.id),f=u[Math.min(Math.max(d,0),u.length-1)]??null,p=t?.id===s.id;p&&(await c(f?n(f):{kind:`root`,pathname:`/`},!0),i()),o.setQueryData(fz,u);for(let e of s.worktrees.flatMap(e=>e.terminals))VP.forget(e.id);await Promise.all([o.invalidateQueries({queryKey:fz}),o.invalidateQueries({queryKey:pz})]),(p||!u.length)&&window.requestAnimationFrame(()=>r.current?.focus())},onError:(e,t)=>{xF(e,{operation:`close project “${t.name}”`}),kE(e).code===`PROJECT_CLOSE_FAILED`&&o.invalidateQueries({queryKey:fz})}});return{closingProjectId:l.isPending?l.variables?.id??null:null,requestProjectClose:e=>{let t=e.worktrees.reduce((e,t)=>e+t.terminals.length,0);t>0&&!window.confirm(`Close “${e.name}”? This will terminate ${t} Treeport terminal ${t===1?`session and its process`:`sessions and their processes`}. Git worktrees and files will remain on disk, and you can reopen the project from Recent projects.`)||l.mutate(e)},projectOpened:async(t,r=!0)=>{let i=e.length===0&&s.pathname===`/`;o.setQueryData(fz,e=>[...(e??[]).filter(e=>e.id!==t.id),t]),o.setQueryData(pz,e=>e?.filter(e=>e.id!==t.id)),await c(n(t),i,r),await Promise.all([o.invalidateQueries({queryKey:fz}),o.invalidateQueries({queryKey:pz})]),a()}}}function xz({program:e,progress:t,attention:n,exited:r,className:i,title:a}){let o=t!==null&&!n&&t.state!==`paused`&&t.state!==`error`,s=n?`text-amber-300`:t?.state===`error`?`text-rose-300`:t?.state===`paused`?`text-amber-300`:r&&!t?`text-rose-300`:o?`text-cyan-400`:`text-zinc-500`;return(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,className:W(`shrink-0 overflow-visible`,i),"aria-hidden":!a||void 0,children:[a?(0,z.jsx)(`title`,{children:a}):null,(0,z.jsx)(`g`,{className:W(`origin-center transition-[color,transform] duration-500`,s,o&&`scale-[0.62]`),children:e===`pi`?(0,z.jsxs)(`svg`,{viewBox:`0 0 800 800`,width:`24`,height:`24`,children:[(0,z.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M165.29 165.29H517.36V400H400V517.36H282.65V634.72H165.29ZM282.65 282.65V400H400V282.65Z`}),(0,z.jsx)(`path`,{fill:`currentColor`,d:`M517.36 400H634.72V634.72H517.36Z`})]}):e===`claude`?(0,z.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`,d:`M20.998 10.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6 10.949h1.488V8.102H6v2.847zm10.51 0H18V8.102h-1.49v2.847z`}):e===`codex`?(0,z.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`,d:`M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z`}):(0,z.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`polyline`,{points:`4 17 10 11 4 5`}),(0,z.jsx)(`line`,{x1:`12`,y1:`19`,x2:`20`,y2:`19`})]})}),(0,z.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,className:`text-cyan-400`,children:[(0,z.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`5`,className:W(`opacity-0 transition-opacity duration-500`,o&&`opacity-25`)}),(0,z.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`5`,pathLength:`100`,strokeDasharray:`30 70`,className:W(`opacity-0 transition-opacity duration-500`,o&&`animate-comet opacity-100 motion-reduce:animate-none`)})]})]})}var Sz=Object.defineProperty,Cz=(e,t)=>Sz(e,`name`,{value:t,configurable:!0}),wz=`horizontal`,Tz=[`horizontal`,`vertical`],Ez=R.forwardRef(Cz(function(e,t){let{decorative:n,orientation:r=wz,...i}=e,a=Dz(r)?r:wz,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,z.jsx)(oI.div,{"data-orientation":a,...o,...i,ref:t})},`Separator`));function Dz(e){return Tz.includes(e)}Cz(Dz,`isValidOrientation`);var Oz=Ez,kz=R.forwardRef(({className:e,orientation:t=`horizontal`,decorative:n=!0,...r},i)=>(0,z.jsx)(Oz,{ref:i,decorative:n,orientation:t,className:W(`shrink-0 bg-border`,t===`horizontal`?`h-[1px] w-full`:`h-full w-[1px]`,e),...r}));kz.displayName=Oz.displayName;var Az=`(max-width: 700px)`;function jz(e){let t=window.matchMedia(Az);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function Mz(){return window.matchMedia(Az).matches}function Nz(){return(0,R.useSyncExternalStore)(jz,Mz,()=>!1)}var Pz=pL,Fz=yL,Iz=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(xL,{className:W(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t,ref:n}));Iz.displayName=xL.displayName;var Lz=bp(`fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out`,{variants:{side:{top:`inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,bottom:`inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,left:`inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm`,right:`inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm`}},defaultVariants:{side:`right`}}),Rz=R.forwardRef(({side:e=`right`,className:t,children:n,showCloseButton:r=!0,...i},a)=>(0,z.jsxs)(Fz,{children:[(0,z.jsx)(Iz,{}),(0,z.jsxs)(TL,{ref:a,className:W(Lz({side:e}),t),...i,children:[r?(0,z.jsxs)(PL,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,z.jsx)(Xf,{className:`size-4`}),(0,z.jsx)(`span`,{className:`sr-only`,children:`Close`})]}):null,n]})]}));Rz.displayName=TL.displayName;var zz=({className:e,...t})=>(0,z.jsx)(`div`,{className:W(`flex flex-col gap-2 text-center sm:text-left`,e),...t});zz.displayName=`SheetHeader`;var Bz=({className:e,...t})=>(0,z.jsx)(`div`,{className:W(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t});Bz.displayName=`SheetFooter`;var Vz=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(AL,{ref:n,className:W(`text-lg font-semibold text-foreground`,e),...t}));Vz.displayName=AL.displayName;var Hz=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(ML,{ref:n,className:W(`text-sm text-muted-foreground`,e),...t}));Hz.displayName=ML.displayName;function Uz({className:e,...t}){return(0,z.jsx)(`div`,{className:W(`animate-pulse rounded-md bg-primary/10`,e),...t})}var Wz=`16rem`,Gz=`min(88vw, 21rem)`,Kz=`3rem`,qz=R.createContext(null);function Jz(){let e=R.useContext(qz);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}var Yz=R.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o},s)=>{let c=Nz(),[l,u]=R.useState(!1),d=R.useRef(null),f=R.useRef(!1),p=R.useCallback(e=>{u(t=>{let n=typeof e==`function`?e(t):e;return!t&&n&&(d.current=document.activeElement instanceof HTMLElement?document.activeElement:null),n})},[]),m=R.useCallback(()=>{f.current=!0,u(!1)},[]),[h,g]=R.useState(e),_=t??h,v=R.useCallback(e=>{let t=typeof e==`function`?e(_):e;n?n(t):g(t)},[n,_]),y=R.useCallback(()=>{c&&p(e=>!e)},[c,p]),b=_?`expanded`:`collapsed`,x=R.useMemo(()=>({state:b,open:_,setOpen:v,isMobile:c,openMobile:l,setOpenMobile:p,mobileRestoreFocusRef:d,skipMobileFocusRestoreRef:f,closeMobileWithoutFocusRestore:m,toggleSidebar:y}),[b,_,v,c,l,p,y]);return(0,z.jsx)(qz.Provider,{value:x,children:(0,z.jsx)(ef,{delayDuration:0,children:(0,z.jsx)(`div`,{style:{"--sidebar-width":Wz,"--sidebar-width-icon":Kz,...i},className:W(`group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar`,r),ref:s,...o,children:a})})})});Yz.displayName=`SidebarProvider`;var Xz=R.forwardRef(({side:e=`left`,variant:t=`sidebar`,collapsible:n=`offcanvas`,className:r,children:i,mobileTitle:a=`Sidebar`,mobileDescription:o=`Displays the mobile sidebar.`,...s},c)=>{let{isMobile:l,state:u,openMobile:d,setOpenMobile:f,mobileRestoreFocusRef:p,skipMobileFocusRestoreRef:m}=Jz();return l?(0,z.jsx)(Pz,{open:d,onOpenChange:f,children:(0,z.jsxs)(Rz,{"data-sidebar":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width-mobile) bg-zinc-900/95 p-0 text-zinc-100 backdrop-blur-xl`,style:{"--sidebar-width-mobile":Gz},side:e,showCloseButton:!1,onCloseAutoFocus:e=>{e.preventDefault(),m.current?m.current=!1:p.current?.isConnected&&p.current.focus()},children:[(0,z.jsxs)(zz,{className:`sr-only`,children:[(0,z.jsx)(Vz,{children:a}),(0,z.jsx)(Hz,{children:o})]}),(0,z.jsx)(`div`,{ref:c,className:W(`flex h-full w-full flex-col`,r),...s,children:i})]})}):n===`none`?(0,z.jsx)(`div`,{className:W(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),ref:c,...s,children:i}):(0,z.jsxs)(`div`,{ref:c,className:`group peer hidden text-sidebar-foreground min-[701px]:block`,"data-state":u,"data-collapsible":u===`collapsed`?n:``,"data-variant":t,"data-side":e,children:[(0,z.jsx)(`div`,{className:W(`relative w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,t===`floating`||t===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]`:`group-data-[collapsible=icon]:w-[--sidebar-width-icon]`)}),(0,z.jsx)(`div`,{className:W(`fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear min-[701px]:flex`,e===`left`?`left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]`:`right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]`,t===`floating`||t===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]`:`group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l`,r),...s,children:(0,z.jsx)(`div`,{"data-sidebar":`sidebar`,className:`flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow`,children:i})})]})});Xz.displayName=`Sidebar`;var Zz=R.forwardRef(({className:e,onClick:t,children:n,...r},i)=>{let{toggleSidebar:a}=Jz();return(0,z.jsxs)(G,{ref:i,"data-sidebar":`trigger`,variant:`ghost`,size:`icon`,className:W(`size-7`,e),onClick:e=>{t?.(e),a()},...r,children:[n??(0,z.jsx)(Yf,{}),r[`aria-label`]?null:(0,z.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`})]})});Zz.displayName=`SidebarTrigger`;var Qz=R.forwardRef(({className:e,...t},n)=>{let{toggleSidebar:r}=Jz();return(0,z.jsx)(`button`,{ref:n,"data-sidebar":`rail`,"aria-label":`Toggle Sidebar`,tabIndex:-1,onClick:r,title:`Toggle Sidebar`,className:W(`absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 min-[701px]:flex`,`[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,e),...t})});Qz.displayName=`SidebarRail`;var $z=R.forwardRef(({className:e,asChild:t=!1,...n},r)=>(0,z.jsx)(t?ap:`main`,{ref:r,className:W(`relative flex w-full flex-1 flex-col bg-background`,`min-[701px]:peer-data-[variant=inset]:m-2 min-[701px]:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 min-[701px]:peer-data-[variant=inset]:ml-0 min-[701px]:peer-data-[variant=inset]:rounded-xl min-[701px]:peer-data-[variant=inset]:shadow`,e),...n}));$z.displayName=`SidebarInset`;var eB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(cz,{ref:n,"data-sidebar":`input`,className:W(`h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring`,e),...t}));eB.displayName=`SidebarInput`;var tB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`div`,{ref:n,"data-sidebar":`header`,className:W(`flex flex-col gap-2 p-2`,e),...t}));tB.displayName=`SidebarHeader`;var nB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`div`,{ref:n,"data-sidebar":`footer`,className:W(`flex flex-col gap-2 p-2`,e),...t}));nB.displayName=`SidebarFooter`;var rB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(kz,{ref:n,"data-sidebar":`separator`,className:W(`mx-2 w-auto bg-sidebar-border`,e),...t}));rB.displayName=`SidebarSeparator`;var iB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`div`,{ref:n,"data-sidebar":`content`,className:W(`flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,e),...t}));iB.displayName=`SidebarContent`;var aB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`div`,{ref:n,"data-sidebar":`group`,className:W(`relative flex w-full min-w-0 flex-col p-2`,e),...t}));aB.displayName=`SidebarGroup`;var oB=R.forwardRef(({className:e,asChild:t=!1,...n},r)=>(0,z.jsx)(t?ap:`div`,{ref:r,"data-sidebar":`group-label`,className:W(`flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,`group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0`,e),...n}));oB.displayName=`SidebarGroupLabel`;var sB=R.forwardRef(({className:e,asChild:t=!1,...n},r)=>(0,z.jsx)(t?ap:`button`,{ref:r,"data-sidebar":`group-action`,className:W(`absolute right-3 top-3.5 flex size-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,`after:absolute after:-inset-2 after:min-[701px]:hidden`,`group-data-[collapsible=icon]:hidden`,e),...n}));sB.displayName=`SidebarGroupAction`;var cB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`div`,{ref:n,"data-sidebar":`group-content`,className:W(`w-full text-sm`,e),...t}));cB.displayName=`SidebarGroupContent`;var lB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`ul`,{ref:n,"data-sidebar":`menu`,className:W(`flex w-full min-w-0 flex-col gap-1`,e),...t}));lB.displayName=`SidebarMenu`;var uB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`li`,{ref:n,"data-sidebar":`menu-item`,className:W(`group/menu-item relative`,e),...t}));uB.displayName=`SidebarMenuItem`;var dB=bp(`peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0`,{variants:{variant:{default:`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:!p-0`}},defaultVariants:{variant:`default`,size:`default`}}),fB=R.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n=`default`,size:r=`default`,tooltip:i,className:a,...o},s)=>{let c=e?ap:`button`,{isMobile:l,state:u}=Jz(),d=(0,z.jsx)(c,{ref:s,"data-sidebar":`menu-button`,"data-size":r,"data-active":t,className:W(dB({variant:n,size:r}),a),...o});return i?(typeof i==`string`&&(i={children:i}),(0,z.jsxs)(tf,{children:[(0,z.jsx)(nf,{asChild:!0,children:d}),(0,z.jsx)(rf,{side:`right`,align:`center`,hidden:u!==`collapsed`||l,...i})]})):d});fB.displayName=`SidebarMenuButton`;var pB=R.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>(0,z.jsx)(t?ap:`button`,{ref:i,"data-sidebar":`menu-action`,className:W(`absolute right-1 top-1.5 flex size-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0`,`after:absolute after:-inset-2 after:min-[701px]:hidden`,`peer-data-[size=sm]/menu-button:top-1`,`peer-data-[size=default]/menu-button:top-1.5`,`peer-data-[size=lg]/menu-button:top-2.5`,`group-data-[collapsible=icon]:hidden`,n&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground min-[701px]:opacity-0`,e),...r}));pB.displayName=`SidebarMenuAction`;var mB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`div`,{ref:n,"data-sidebar":`menu-badge`,className:W(`pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground`,`peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground`,`peer-data-[size=sm]/menu-button:top-1`,`peer-data-[size=default]/menu-button:top-1.5`,`peer-data-[size=lg]/menu-button:top-2.5`,`group-data-[collapsible=icon]:hidden`,e),...t}));mB.displayName=`SidebarMenuBadge`;var hB=R.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{let i=R.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return(0,z.jsxs)(`div`,{ref:r,"data-sidebar":`menu-skeleton`,className:W(`flex h-8 items-center gap-2 rounded-md px-2`,e),...n,children:[t&&(0,z.jsx)(Uz,{className:`size-4 rounded-md`,"data-sidebar":`menu-skeleton-icon`}),(0,z.jsx)(Uz,{className:`h-4 max-w-[--skeleton-width] flex-1`,"data-sidebar":`menu-skeleton-text`,style:{"--skeleton-width":i}})]})});hB.displayName=`SidebarMenuSkeleton`;var gB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`ul`,{ref:n,"data-sidebar":`menu-sub`,className:W(`mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5`,`group-data-[collapsible=icon]:hidden`,e),...t}));gB.displayName=`SidebarMenuSub`;var _B=R.forwardRef(({...e},t)=>(0,z.jsx)(`li`,{ref:t,...e}));_B.displayName=`SidebarMenuSubItem`;var vB=R.forwardRef(({asChild:e=!1,size:t=`md`,isActive:n,className:r,...i},a)=>(0,z.jsx)(e?ap:`a`,{ref:a,"data-sidebar":`menu-sub-button`,"data-size":t,"data-active":n,className:W(`flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,`data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground`,t===`sm`&&`text-xs`,t===`md`&&`text-sm`,`group-data-[collapsible=icon]:hidden`,r),...i}));vB.displayName=`SidebarMenuSubButton`;function yB({label:e,tooltip:t=e,className:n,disabled:r,keyShortcuts:i,onClick:a,children:o}){return(0,z.jsxs)(tf,{children:[(0,z.jsx)(nf,{asChild:!0,children:(0,z.jsxs)(G,{type:`button`,variant:`ghost`,size:`icon-sm`,className:n,"aria-label":e,"aria-keyshortcuts":i,disabled:r,onClick:e=>a(e.currentTarget),children:[o,(0,z.jsx)(`span`,{className:`touch-target`,"aria-hidden":`true`})]})}),(0,z.jsx)(rf,{side:`top`,children:t})]})}var bB=240,xB=420,SB=272,CB=`treeport-sidebar-width`,wB=(0,R.createContext)(null),TB=(0,R.createContext)(null);function EB(e){return Math.min(xB,Math.max(bB,e))}function DB(){let e=(0,R.useContext)(wB);if(!e)throw Error(`useProjectSwitcher must be used within WorkspaceShell.`);return e}function OB({children:e}){let[t,n]=(0,R.useState)(!1),r=(0,R.useRef)(null),i=(0,R.useRef)(!1),[a,o]=(0,R.useState)(()=>{let e=Number.parseInt(localStorage.getItem(CB)??``,10);return Number.isFinite(e)?EB(e):SB}),[s,c]=(0,R.useState)(!1);return(0,z.jsx)(wB.Provider,{value:{open:t,setOpen:n,triggerRef:r,dismissedIntoTerminalRef:i},children:(0,z.jsx)(TB.Provider,{value:{width:a,resizing:s,setWidth:e=>{let t=EB(e);o(t),localStorage.setItem(CB,String(t))},setResizing:c},children:(0,z.jsx)(Yz,{className:W(`app-frame isolate grid h-dvh min-h-0 grid-cols-[var(--sidebar-width)_minmax(0,1fr)] bg-zinc-950 max-[700px]:grid-cols-1 max-[700px]:grid-rows-[3.25rem_minmax(0,1fr)]`,s&&`select-none`),style:{"--sidebar-width":`${a}px`,"--sidebar-width-mobile":`min(88vw, 21rem)`},children:e})})})}function kB({children:e}){let{isMobile:t,openMobile:n}=Jz(),r=DB();return(0,z.jsx)($z,{asChild:!0,children:(0,z.jsx)(`div`,{className:`grid min-h-0 min-w-0 grid-rows-[minmax(0,1fr)] overflow-hidden bg-zinc-950`,inert:t&&n?!0:void 0,"aria-hidden":t&&n?!0:void 0,onPointerDownCapture:()=>{r.open&&(r.dismissedIntoTerminalRef.current=!0,r.setOpen(!1))},children:e})})}function AB(){let e=(0,R.useContext)(TB),t=(0,R.useRef)(null);if(!e)throw Error(`ResizableSidebarRail must be used within WorkspaceShell.`);let n=n=>{n.button===0&&(t.current={pointerX:n.clientX,width:e.width},n.currentTarget.setPointerCapture(n.pointerId),e.setResizing(!0))},r=n=>{t.current&&e.setWidth(t.current.width+n.clientX-t.current.pointerX)},i=n=>{t.current=null,n.currentTarget.hasPointerCapture(n.pointerId)&&n.currentTarget.releasePointerCapture(n.pointerId),e.setResizing(!1)};return(0,z.jsx)(`div`,{className:W(`absolute inset-y-0 right-0 z-20 hidden w-3 translate-x-1/2 touch-none cursor-col-resize outline-none before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-white/8 after:absolute after:top-1/2 after:left-1/2 after:h-8 after:w-1 after:-translate-1/2 after:rounded-full after:bg-zinc-700 hover:before:w-0.5 hover:before:bg-cyan-400/60 hover:after:bg-cyan-400 focus-visible:before:w-0.5 focus-visible:before:bg-cyan-400 focus-visible:after:bg-cyan-400 min-[701px]:block`,e.resizing&&`before:w-0.5 before:bg-cyan-400`),role:`separator`,"aria-label":`Resize sidebar`,"aria-orientation":`vertical`,"aria-controls":`worktree-sidebar`,"aria-valuemin":bB,"aria-valuemax":xB,"aria-valuenow":e.width,"aria-valuetext":`${e.width} pixels`,title:`Drag to resize; double-click to reset`,tabIndex:0,onPointerDown:n,onPointerMove:r,onPointerUp:i,onPointerCancel:i,onKeyDown:t=>{let n=e.width;if(t.key===`ArrowLeft`)n-=t.shiftKey?32:16;else if(t.key===`ArrowRight`)n+=t.shiftKey?32:16;else if(t.key===`Home`)n=bB;else if(t.key===`End`)n=xB;else return;t.preventDefault(),e.setWidth(n)},onDoubleClick:()=>e.setWidth(SB)})}function jB({blocked:e}){let t=/Mac|iPhone|iPad|iPod/.test(navigator.platform),{isMobile:n,setOpenMobile:r}=Jz(),i=DB();return(0,R.useEffect)(()=>{let a=a=>{let o=t?a.metaKey&&!a.ctrlKey:a.ctrlKey&&!a.metaKey;a.isComposing||a.key.toLocaleLowerCase()!==`p`||!a.shiftKey||a.altKey||!o||e||(a.preventDefault(),a.stopPropagation(),n?(r(!0),window.requestAnimationFrame(()=>i.setOpen(!0))):i.setOpen(!0))};return document.addEventListener(`keydown`,a,!0),()=>document.removeEventListener(`keydown`,a,!0)},[e,n,i.setOpen,r]),null}function MB({projects:e,activeProject:t,closingProjectId:n,onSelectProject:r,onProjectOpened:i,onRequestProjectClose:a,onOpenProjectDialog:o}){let s=/Mac|iPhone|iPad|iPod/.test(navigator.platform),{isMobile:c}=Jz(),l=DB(),{attention:u,progress:d}=$P(),[f,p]=(0,R.useState)(``),[m,h]=(0,R.useState)(null),g=dt({...gz,enabled:l.open}),_=pt({mutationFn:async e=>(await Tf(CE.api.projects[`:projectId`].open.$post({param:{projectId:e.id}}))).project,onSuccess:i,onError:(e,t)=>{xF(e,{operation:`reopen project “${t.name}”`})}}),v=e=>{r(e),p(``),h(null)},y=e=>{_.mutate(e),p(``),h(null)},b=f.trim().toLocaleLowerCase(),x=e.filter(e=>!b||e.name.toLocaleLowerCase().includes(b)||e.repositoryPath.toLocaleLowerCase().includes(b)),S=new Set(e.map(e=>e.id)),C=(g.data??[]).filter(e=>!S.has(e.id)),w=C.filter(e=>!b||e.name.toLocaleLowerCase().includes(b)||e.repositoryPath.toLocaleLowerCase().includes(b)),T=[...x.map(e=>({kind:`open`,project:e})),...w.map(e=>({kind:`recent`,project:e}))],E=T.find(e=>e.project.id===m)??T[0]??null;return(0,z.jsxs)(Vh,{open:l.open,onOpenChange:e=>{l.setOpen(e),h(null),p(``)},children:[(0,z.jsx)(Hh,{asChild:!0,children:(0,z.jsxs)(G,{ref:l.triggerRef,type:`button`,variant:`ghost`,className:`h-11 min-w-0 flex-1 justify-start gap-2 px-2 text-base text-zinc-100 hover:bg-white/5 min-[701px]:h-8 min-[701px]:text-sm`,"aria-label":t?`Switch project, current project ${t.name}`:`Open project`,"aria-keyshortcuts":s?`Meta+Shift+P`:`Control+Shift+P`,title:`${t?.repositoryPath??`Open project`} — ${s?`⌘⇧P`:`Ctrl+Shift+P`}`,children:[(0,z.jsx)(`span`,{className:`truncate font-medium`,children:t?.name??`Open project`}),(0,z.jsx)(HR,{className:`ml-auto shrink-0 fill-zinc-600`,"data-icon":`inline-end`})]})}),(0,z.jsxs)(Uh,{align:`start`,portalled:!c,className:`grid w-[min(17rem,calc(100vw-1rem))] gap-1 p-1 min-[701px]:w-60`,onOpenAutoFocus:e=>{c&&e.preventDefault()},onCloseAutoFocus:e=>{l.dismissedIntoTerminalRef.current&&(e.preventDefault(),l.dismissedIntoTerminalRef.current=!1)},children:[(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(QR,{className:`pointer-events-none absolute top-1/2 left-2 size-4 -translate-y-1/2 fill-zinc-600`}),(0,z.jsx)(cz,{name:`project-search`,value:f,onChange:e=>{p(e.target.value),h(null)},onKeyDown:e=>{if(e.nativeEvent.isComposing||!T.length)return;if(e.key===`Enter`){e.preventDefault(),E?.kind===`open`?v(E.project):E?.kind===`recent`&&!_.isPending&&y(E.project);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=Math.max(0,T.findIndex(e=>e.project.id===E?.project.id)),n=e.key===`ArrowDown`?Math.min(t+1,T.length-1):Math.max(t-1,0),r=T[n];h(r.project.id),window.requestAnimationFrame(()=>document.getElementById(`project-switcher-option-${r.project.id}`)?.scrollIntoView({block:`nearest`}))},className:`h-11! bg-zinc-950/50 pr-2 pl-8 text-base! ring-white/8 focus-visible:ring-1! focus-visible:ring-white/20! min-[701px]:h-7! min-[701px]:py-1 min-[701px]:pr-2 min-[701px]:pl-7 min-[701px]:text-sm! min-[701px]:placeholder:text-sm`,placeholder:`Search projects…`,"aria-label":`Search projects`,"aria-activedescendant":E?`project-switcher-option-${E.project.id}`:void 0,autoFocus:!c})]}),(0,z.jsxs)(`div`,{className:`grid max-h-[min(28rem,70vh)] gap-1 overflow-y-auto p-0.5 min-[701px]:max-h-[min(22rem,70vh)] min-[701px]:gap-0.5 min-[701px]:p-0 [scrollbar-color:var(--color-zinc-700)_transparent]`,children:[x.length?(0,z.jsx)(`ul`,{role:`list`,className:`grid gap-1 min-[701px]:gap-0.5`,children:x.map(e=>{let r=e.worktrees.flatMap(e=>e.terminals),i=r.some(e=>u.has(e.id)),o=r.map(e=>d.get(e.id)).find(e=>e!==void 0);return(0,z.jsxs)(`li`,{className:W(`group/project-option relative flex h-11 min-w-0 items-center gap-0.5 rounded-md pr-1 has-[button:hover]:bg-white/5 focus-within:bg-white/5 min-[701px]:h-7`,E?.project.id===e.id&&`bg-white/8`),onMouseEnter:()=>h(e.id),children:[(0,z.jsxs)(G,{id:`project-switcher-option-${e.id}`,type:`button`,variant:`ghost`,className:`h-11 min-w-0 flex-1 justify-start px-2 text-left text-base hover:bg-transparent min-[701px]:h-7 min-[701px]:px-1.5 min-[701px]:text-sm max-[700px]:pr-8`,"data-highlighted":E?.project.id===e.id||void 0,onClick:()=>v(e),children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,z.jsx)(`span`,{className:`truncate font-medium text-zinc-100`,children:e.name}),t?.id===e.id?(0,z.jsx)(IR,{className:`shrink-0 fill-zinc-400`}):null]}),o||i?(0,z.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5 min-[701px]:group-hover/project-option:opacity-0 min-[701px]:group-focus-within/project-option:opacity-0`,children:[o?(0,z.jsx)(xz,{program:null,progress:o,attention:!1,exited:!1,className:`size-4`,title:Qh(o)}):null,i?(0,z.jsx)(xz,{program:null,progress:null,attention:!0,exited:!1,className:`size-4`,title:`Terminal needs attention`}):null]}):null]}),(0,z.jsx)(yB,{label:`Close project ${e.name}`,tooltip:`Close project`,disabled:n===e.id,className:`absolute right-1 shrink-0 fill-zinc-500 opacity-0 hover:bg-white/5 hover:fill-rose-300 group-hover/project-option:opacity-100 group-focus-within/project-option:opacity-100 max-[700px]:opacity-100`,onClick:()=>a(e),children:n===e.id?(0,z.jsx)(OR,{className:`animate-spin`}):(0,z.jsx)(oz,{})})]},e.id)})}):(0,z.jsx)(`p`,{className:`px-2 py-1.5 text-base text-pretty text-zinc-500 min-[701px]:px-1.5 min-[701px]:py-1 min-[701px]:text-sm`,children:`No open projects found.`}),!g.isSuccess||C.length?(0,z.jsxs)(`section`,{className:`grid gap-1 min-[701px]:gap-0.5`,"aria-labelledby":`recent-projects-switcher-title`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 py-1.5 min-[701px]:px-1.5 min-[701px]:py-1`,children:[(0,z.jsx)(`h3`,{id:`recent-projects-switcher-title`,className:`text-sm font-medium text-balance text-zinc-500 min-[701px]:text-xs`,children:`Recent projects`}),g.isFetching?(0,z.jsx)(OR,{className:`size-4 shrink-0 animate-spin fill-zinc-600`,"aria-label":`Refreshing recent projects`}):null]}),g.isError?(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 py-1.5 min-[701px]:px-1.5 min-[701px]:py-1`,children:[(0,z.jsx)(`p`,{className:`text-base text-pretty text-zinc-500 min-[701px]:text-sm`,children:`Recent projects unavailable.`}),(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`h-9 text-base min-[701px]:h-7 min-[701px]:text-sm`,onClick:()=>void g.refetch(),children:`Retry`})]}):null,g.isSuccess&&w.length?(0,z.jsx)(`ul`,{role:`list`,className:`grid gap-1 min-[701px]:gap-0.5`,children:w.map(e=>(0,z.jsx)(`li`,{onMouseEnter:()=>h(e.id),children:(0,z.jsx)(G,{id:`project-switcher-option-${e.id}`,type:`button`,variant:`ghost`,className:W(`h-11 w-full min-w-0 justify-start px-2 text-left text-base min-[701px]:h-7 min-[701px]:px-1.5 min-[701px]:text-sm`,E?.project.id===e.id&&`bg-white/8`),"data-highlighted":E?.project.id===e.id||void 0,disabled:_.isPending,onClick:()=>y(e),children:(0,z.jsx)(`span`,{className:`truncate font-medium text-zinc-200`,children:e.name})})},e.id))}):null,g.isSuccess&&!w.length?(0,z.jsx)(`p`,{className:`px-2 py-1.5 text-base text-pretty text-zinc-500 min-[701px]:px-1.5 min-[701px]:py-1 min-[701px]:text-sm`,children:`No recent projects found.`}):null]}):null]}),(0,z.jsx)(kz,{className:`bg-white/8`}),(0,z.jsxs)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`h-11 w-full justify-start text-base font-normal text-zinc-500 hover:text-zinc-100 min-[701px]:h-7 min-[701px]:text-sm`,onClick:e=>{l.setOpen(!1),o(l.triggerRef.current??e.currentTarget)},children:[(0,z.jsx)(ez,{"data-icon":`inline-start`}),` Open project…`]})]})]})}function NB({className:e,children:t,...n}){return(0,z.jsxs)(`span`,{className:`grid grid-cols-[1fr_--spacing(8)]`,children:[(0,z.jsx)(`select`,{"data-slot":`native-select`,className:W(`col-span-full row-start-1 h-11 w-full appearance-none rounded-md bg-zinc-950/70 py-2 pr-8 pl-3 text-base text-zinc-100 ring-1 ring-white/12 outline-none focus-visible:ring-2 focus-visible:ring-cyan-400 sm:h-9 sm:text-sm`,e),...n,children:t}),(0,z.jsx)(RR,{className:`pointer-events-none col-start-2 row-start-1 size-4 place-self-center text-zinc-500`})]})}function PB({projectSwitcher:e,notificationCenter:t,children:n}){return(0,z.jsxs)(Xz,{id:`worktree-sidebar`,collapsible:`none`,mobileTitle:`Projects and worktrees`,mobileDescription:`Navigate projects, worktrees, and terminals.`,className:`sidebar relative min-h-0 border-r border-white/8 bg-zinc-900/80 text-zinc-200 backdrop-blur-xl`,children:[(0,z.jsxs)(tB,{className:`gap-0 border-b border-white/8 p-0`,children:[(0,z.jsx)(`div`,{className:`hidden justify-end p-2 max-[700px]:flex`,children:(0,z.jsxs)(Zz,{type:`button`,size:`icon-sm`,className:`icon-button mobile-close text-zinc-400 hover:bg-white/5 hover:text-zinc-100`,"aria-label":`Close drawer`,children:[(0,z.jsx)(oz,{}),(0,z.jsx)(`span`,{className:`touch-target`,"aria-hidden":`true`})]})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 p-2 max-[700px]:pt-0`,children:[(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),(0,z.jsx)(`div`,{className:`max-[700px]:hidden`,children:t})]})]}),(0,z.jsx)(iB,{className:`gap-0 overflow-hidden`,children:n}),(0,z.jsx)(AB,{})]})}function FB({selectedTerminalId:e,terminals:t,onSelectTerminal:n,notificationCenter:r}){let{isMobile:i,openMobile:a}=Jz(),{titles:o}=$P();return(0,z.jsxs)(`header`,{className:`mobile-bar hidden min-w-0 grid-cols-[2.75rem_minmax(0,1fr)_2.75rem] items-center gap-2 border-b border-white/8 bg-zinc-900/95 px-2 backdrop-blur max-[700px]:grid`,inert:i&&a?!0:void 0,children:[(0,z.jsxs)(Zz,{type:`button`,size:`icon`,className:`icon-button text-zinc-400 hover:bg-white/5 hover:text-zinc-100`,"aria-label":`Open worktree drawer`,children:[(0,z.jsx)(MR,{}),(0,z.jsx)(`span`,{className:`touch-target`,"aria-hidden":`true`})]}),(0,z.jsxs)(NB,{className:`h-9 border-0 bg-zinc-800/80 text-base ring-0`,name:`terminal-selector`,"aria-label":`Terminal selector`,value:e??``,onChange:e=>{let r=t.find(t=>t.id===e.target.value);r&&n(r)},children:[(0,z.jsx)(`option`,{value:``,children:`Select terminal`}),t.map(e=>(0,z.jsx)(`option`,{value:e.id,children:o.get(e.id)||e.name},e.id))]}),r]})}var IB=Object.defineProperty,LB=(e,t)=>IB(e,`name`,{value:t,configurable:!0});function RB(e){let t=e+`CollectionProvider`,[n,r]=kF(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=LB(e=>{let{scope:t,children:n}=e,r=R.useRef(null),a=R.useRef(new Map).current;return(0,z.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=ip(s),l=R.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=tp(t,a(s,n).collectionRef);return(0,z.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=ip(u),p=R.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=R.useRef(null),s=tp(t,o),c=a(u,n);return R.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,z.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return R.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return LB(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}LB(RB,`createCollection`);var zB=new WeakMap,BB=class e extends Map{static{LB(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],zB.set(this,!0)}set(e,t){return zB.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=UB(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=VB(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=VB(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return VB(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function VB(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=HB(e,t);return n===-1?void 0:e[n]}LB(VB,`at`);function HB(e,t){let n=e.length,r=UB(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}LB(HB,`toSafeIndex`);function UB(e){return e!==e||e===0?0:Math.trunc(e)}LB(UB,`toSafeInteger`);function WB(e){let t=e+`CollectionProvider`,[n,r]=kF(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new BB,setItemMap:LB(()=>void 0,`setItemMap`)}),o=LB(({state:e,...t})=>e?(0,z.jsx)(c,{...t,state:e}):(0,z.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=LB(e=>{let t=h();return(0,z.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=LB(e=>{let{scope:t,children:n,state:r}=e,a=R.useRef(null),[o,s]=R.useState(null),c=tp(a,s),[l,u]=r;return R.useEffect(()=>{if(!o)return;let e=JB(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,z.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=ip(l),d=R.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=tp(t,a(l,n).collectionRef);return(0,z.jsx)(u,{ref:i,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=ip(f),m=R.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=R.useRef(null),[s,c]=R.useState(null),l=tp(t,o,c),{setItemMap:u}=a(f,n),d=R.useRef(i);GB(d.current,i)||(d.current=i);let m=d.current;return R.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(qB):(t.set(s,{...e,element:s}),t.toSorted(qB)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new BB(e)))}},[s,m,u]),(0,z.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return R.useState(new BB)}LB(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return LB(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}LB(WB,`createCollection`);function GB(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}LB(GB,`shallowEqual`);function KB(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}LB(KB,`isElementPreceding`);function qB(e,t){return!e[1].element||!t[1].element?0:KB(e[1].element,t[1].element)?-1:1}LB(qB,`sortByDocumentPosition`);function JB(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}LB(JB,`getChildListObserver`);var YB=Object.defineProperty,XB=(e,t)=>YB(e,`name`,{value:t,configurable:!0}),ZB=R.createContext(void 0);function QB(e){let t=R.useContext(ZB);return e||t||`ltr`}XB(QB,`useDirection`);var $B=Object.defineProperty,eV=(e,t)=>$B(e,`name`,{value:t,configurable:!0});function tV(e){let[t,n]=R.useState(void 0);return zF(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}eV(tV,`useSize`);var nV=Object.defineProperty,rV=(e,t)=>nV(e,`name`,{value:t,configurable:!0}),iV=`Popper`,[aV,oV]=kF(iV),[sV,cV]=aV(iV),lV=rV(e=>{let{__scopePopper:t,children:n}=e,[r,i]=R.useState(null),[a,o]=R.useState(void 0);return(0,z.jsx)(sV,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),uV=`PopperAnchor`,dV=R.forwardRef(rV(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=cV(uV,n),o=R.useRef(null),s=a.onAnchorChange,c=tp(t,R.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=R.useRef(null);R.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&vV(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,z.jsx)(oI.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),fV=`PopperContent`,[pV,mV]=aV(fV),hV=R.forwardRef(rV(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=cV(fV,n),[_,v]=R.useState(null),y=tp(t,v),[b,x]=R.useState(null),S=tV(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(gV),altBoundary:O},{refs:ee,floatingStyles:te,placement:A,isPositioned:j,middlewareData:M}=Wc({strategy:`fixed`,placement:T,whileElementsMounted:rV((...e)=>Ac(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[Kc({mainAxis:i+w,alignmentAxis:o}),c&&qc({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Jc():void 0,...k}),c&&Yc({...k}),Xc({...k,apply:rV(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),b&&Qc({element:b,padding:s}),_V({arrowWidth:C,arrowHeight:w}),f&&Zc({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ne=g.setPlacementState;zF(()=>(ne(A),()=>{ne(void 0)}),[A,ne]);let[N,P]=vV(A),re=uI(m);zF(()=>{j&&re?.()},[j,re]);let ie=M.arrow?.x,ae=M.arrow?.y,F=M.arrow?.centerOffset!==0,[I,L]=R.useState();return zF(()=>{_&&L(window.getComputedStyle(_).zIndex)},[_]),(0,z.jsx)(`div`,{ref:ee.setFloating,"data-radix-popper-content-wrapper":``,style:{...te,transform:j?te.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:I,"--radix-popper-transform-origin":[M.transformOrigin?.x,M.transformOrigin?.y].join(` `),...M.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,z.jsx)(pV,{scope:n,placedSide:N,placedAlign:P,onArrowChange:x,arrowX:ie,arrowY:ae,shouldHideArrow:F,children:(0,z.jsx)(oI.div,{"data-side":N,"data-align":P,...h,ref:y,style:{...h.style,animation:j?h.style?.animation:`none`}})})})},`PopperContent`));function gV(e){return e!==null}rV(gV,`isNotNull`);var _V=rV(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=vV(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function vV(e){let[t,n=`center`]=e.split(`-`);return[t,n]}rV(vV,`getSideAndAlignFromPlacement`);var yV=lV,bV=dV,xV=hV,SV=Object.defineProperty,CV=(e,t)=>SV(e,`name`,{value:t,configurable:!0}),wV=!1;function TV(){let[e,t]=R.useState(wV);return R.useEffect(()=>{wV||(wV=!0,t(!0))},[]),e}CV(TV,`useIsHydrated`);var EV=R.useSyncExternalStore;function DV(){return()=>{}}CV(DV,`subscribe`);function OV(){return EV(DV,()=>!0,()=>!1)}CV(OV,`useIsHydratedModern`);var kV=typeof EV==`function`?OV:TV,AV=Object.defineProperty,jV=(e,t)=>AV(e,`name`,{value:t,configurable:!0}),MV=`rovingFocusGroup.onEntryFocus`,NV={bubbles:!1,cancelable:!0},PV=`RovingFocusGroup`,[FV,IV,LV]=RB(PV),[RV,zV]=kF(PV,[LV]),[BV,VV]=RV(PV),HV=R.forwardRef(jV(function(e,t){return(0,z.jsx)(FV.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,z.jsx)(FV.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,z.jsx)(UV,{...e,ref:t})})})},`RovingFocusGroup`)),UV=R.forwardRef(jV(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=R.useRef(null),p=tp(t,f),m=QB(a),[h,g]=$F({prop:o,defaultProp:s??null,onChange:c,caller:PV}),[_,v]=R.useState(!1),y=uI(l),b=IV(n),x=R.useRef(!1),[S,C]=R.useState(0);return R.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(MV,y),()=>e.removeEventListener(MV,y)},[y]),(0,z.jsx)(BV,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:R.useCallback(e=>g(e),[g]),onItemShiftTab:R.useCallback(()=>v(!0),[]),onFocusableItemAdd:R.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:R.useCallback(()=>C(e=>e-1),[]),children:(0,z.jsx)(oI.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:PF(e.onMouseDown,()=>{x.current=!0}),onFocus:PF(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(MV,NV);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);YV([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:PF(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),WV=`RovingFocusGroupItem`,GV=R.forwardRef(jV(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=WF(),l=a||c,u=VV(WV,n),d=u.currentTabStopId===l,f=IV(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=kV();return zF(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),R.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,z.jsx)(FV.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,z.jsx)(oI.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:PF(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:PF(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:PF(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=JV(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?XV(n,r+1):n.slice(r+1)}setTimeout(()=>YV(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),KV={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function qV(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}jV(qV,`getDirectionAwareKey`);function JV(e,t,n){let r=qV(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return KV[r]}jV(JV,`getFocusIntent`);function YV(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}jV(YV,`focusFirst`);function XV(e,t){return e.map((n,r)=>e[(t+r)%e.length])}jV(XV,`wrapArray`);var ZV=HV,QV=GV,$V=Object.defineProperty,eH=(e,t)=>$V(e,`name`,{value:t,configurable:!0}),tH=[`Enter`,` `],nH=[`ArrowDown`,`PageUp`,`Home`],rH=[`ArrowUp`,`PageDown`,`End`],iH=[...nH,...rH];[...tH],[...tH];var aH=`Menu`,[oH,sH,cH]=RB(aH),[lH,uH]=kF(aH,[cH,oV,zV]),dH=oV(),fH=zV(),[pH,mH]=lH(aH),[hH,gH]=lH(aH),_H=eH(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=dH(t),[c,l]=R.useState(null),u=R.useRef(!1),d=uI(a),f=QB(i);return R.useEffect(()=>{let e=eH(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=eH(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),R.useEffect(()=>{if(!n)return;let e=eH(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,z.jsx)(yV,{...s,children:(0,z.jsx)(pH,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,z.jsx)(hH,{scope:t,onClose:R.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),vH=R.forwardRef(eH(function(e,t){let{__scopeMenu:n,...r}=e,i=dH(n);return(0,z.jsx)(bV,{...i,...r,ref:t})},`MenuAnchor`)),yH=`MenuPortal`,[bH,xH]=lH(yH,{forceMount:void 0}),SH=eH(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=mH(yH,t);return(0,z.jsx)(bH,{scope:t,forceMount:n,children:(0,z.jsx)(qI,{present:n||a.open,children:(0,z.jsx)(UI,{asChild:!0,container:i,children:r})})})},`MenuPortal`),CH=`MenuContent`,[wH,TH]=lH(CH),EH=R.forwardRef(eH(function(e,t){let n=xH(CH,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=mH(CH,e.__scopeMenu),o=gH(CH,e.__scopeMenu);return(0,z.jsx)(oH.Provider,{scope:e.__scopeMenu,children:(0,z.jsx)(qI,{present:r||a.open,children:(0,z.jsx)(oH.Slot,{scope:e.__scopeMenu,children:o.modal?(0,z.jsx)(DH,{...i,ref:t}):(0,z.jsx)(OH,{...i,ref:t})})})})},`MenuContent`)),DH=R.forwardRef(eH(function(e,t){let n=mH(CH,e.__scopeMenu),r=R.useRef(null),i=tp(t,r);return R.useEffect(()=>{let e=r.current;if(e)return tm(e)},[]),(0,z.jsx)(AH,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:PF(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),OH=R.forwardRef(eH(function(e,t){let n=mH(CH,e.__scopeMenu);return(0,z.jsx)(AH,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),kH=ip(`MenuContent.ScrollLock`),AH=R.forwardRef(eH(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=mH(CH,n),_=gH(CH,n),v=dH(n),y=fH(n),b=sH(n),[x,S]=R.useState(null),C=R.useRef(null),w=tp(t,C,g.onContentChange),T=R.useRef(0),E=R.useRef(``),D=R.useRef(0),O=R.useRef(null),k=R.useRef(`right`),ee=R.useRef(0),te=m?uh:R.Fragment,A=m?{as:kH,allowPinchZoom:!0}:void 0,j=eH(e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=qH(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;eH((function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);R.useEffect(()=>()=>window.clearTimeout(T.current),[]),iL();let M=R.useCallback(e=>k.current===O.current?.side&&YH(e,O.current?.area),[]);return(0,z.jsx)(wH,{scope:n,searchRef:E,onItemEnter:R.useCallback(e=>{M(e)&&e.preventDefault()},[M]),onItemLeave:R.useCallback(e=>{M(e)||(C.current?.focus(),S(null))},[M]),onTriggerLeave:R.useCallback(e=>{M(e)&&e.preventDefault()},[M]),pointerGraceTimerRef:D,onPointerGraceIntentChange:R.useCallback(e=>{O.current=e},[]),children:(0,z.jsx)(te,{...A,children:(0,z.jsx)(AI,{asChild:!0,trapped:i,onMountAutoFocus:PF(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,z.jsx)(vI,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,z.jsx)(ZV,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:PF(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,z.jsx)(xV,{role:`menu`,"aria-orientation":`vertical`,"data-state":HH(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:PF(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&j(e.key));let i=C.current;if(e.target!==i||!iH.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);rH.includes(e.key)&&a.reverse(),GH(a)}),onBlur:PF(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:PF(e.onPointerMove,XH(e=>{let t=e.target,n=ee.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>ee.current?`right`:`left`;k.current=t,ee.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),jH=R.forwardRef(eH(function(e,t){let{__scopeMenu:n,...r}=e;return(0,z.jsx)(oI.div,{role:`group`,...r,ref:t})},`MenuGroup`)),MH=`MenuItem`,NH=`menu.itemSelect`,PH=R.forwardRef(eH(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=R.useRef(null),o=gH(MH,e.__scopeMenu),s=TH(MH,e.__scopeMenu),c=tp(t,a),l=R.useRef(!1),u=eH(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(NH,{bubbles:!0,cancelable:!0});e.addEventListener(NH,e=>r?.(e),{once:!0}),sI(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,z.jsx)(FH,{...i,ref:c,disabled:n,onClick:PF(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:PF(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:PF(e.onKeyDown,e=>{n||e.target!==e.currentTarget||s.searchRef.current!==``&&e.key===` `||tH.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),FH=R.forwardRef(eH(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=TH(MH,n),s=fH(n),c=R.useRef(null),l=tp(t,c),[u,d]=R.useState(!1),[f,p]=R.useState(``);return R.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,z.jsx)(oH.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,z.jsx)(QV,{asChild:!0,...s,focusable:!r,children:(0,z.jsx)(oI.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:PF(e.onPointerMove,XH(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:PF(e.onPointerLeave,XH(e=>o.onItemLeave(e))),onFocus:PF(e.onFocus,()=>d(!0)),onBlur:PF(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[IH,LH]=lH(`MenuRadioGroup`,{value:void 0,onValueChange:eH(()=>{},`onValueChange`)}),[RH,zH]=lH(`MenuItemIndicator`,{checked:!1}),[BH,VH]=lH(`MenuSub`);function HH(e){return e?`open`:`closed`}eH(HH,`getOpenState`);function UH(e){return e===`indeterminate`}eH(UH,`isIndeterminate`);function WH(e){return UH(e)?`indeterminate`:e?`checked`:`unchecked`}eH(WH,`getCheckedState`);function GH(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}eH(GH,`focusFirst`);function KH(e,t){return e.map((n,r)=>e[(t+r)%e.length])}eH(KH,`wrapArray`);function qH(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=KH(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}eH(qH,`getNextMatch`);function JH(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}eH(JH,`isPointInPolygon`);function YH(e,t){return t?JH({x:e.clientX,y:e.clientY},t):!1}eH(YH,`isPointerInGraceArea`);function XH(e){return t=>t.pointerType===`mouse`?e(t):void 0}eH(XH,`whenMouse`);var ZH=_H,QH=vH,$H=SH,eU=EH,tU=jH,nU=PH,rU=Object.defineProperty,iU=(e,t)=>rU(e,`name`,{value:t,configurable:!0}),aU=`ContextMenu`,[oU,sU]=kF(aU,[uH]),cU=uH(),[lU,uU]=oU(aU),dU=iU(e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,dir:a,modal:o=!0}=e,s=R.useRef(!1),[c,l]=$F({prop:i,defaultProp:!1,onChange:r,caller:aU}),u=cU(t);return(0,z.jsx)(lU,{scope:t,open:c,onOpenChange:l,modal:o,hasInteractedRef:s,children:(0,z.jsx)(ZH,{...u,dir:a,open:c,onOpenChange:l,modal:o,children:n})})},`ContextMenu`),fU=`ContextMenuTrigger`,pU=R.forwardRef(iU(function(e,t){let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=uU(fU,n),o=cU(n),[s,c]=R.useState({x:0,y:0}),l=R.useMemo(()=>({current:{getBoundingClientRect:iU(()=>DOMRect.fromRect({width:0,height:0,...s}),`getBoundingClientRect`)}}),[s]),u=R.useRef(0),d=R.useCallback(()=>window.clearTimeout(u.current),[]),f=iU(e=>{a.hasInteractedRef.current=!0,c({x:e.clientX,y:e.clientY}),a.onOpenChange(!0)},`handleOpen`);return R.useEffect(()=>d,[d]),R.useEffect(()=>void(r&&d()),[r,d]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(QH,{...o,virtualRef:l}),(0,z.jsx)(oI.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:PF(e.onContextMenu,e=>{d(),f(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:PF(e.onPointerDown,yU(e=>{d(),a.open&&a.onOpenChange(!1),u.current=window.setTimeout(()=>f(e),700)})),onPointerMove:r?e.onPointerMove:PF(e.onPointerMove,yU(d)),onPointerCancel:r?e.onPointerCancel:PF(e.onPointerCancel,yU(d)),onPointerUp:r?e.onPointerUp:PF(e.onPointerUp,yU(d))})]})},`ContextMenuTrigger`)),mU=iU(e=>{let{__scopeContextMenu:t,...n}=e,r=cU(t);return(0,z.jsx)($H,{...r,...n})},`ContextMenuPortal`),hU=`ContextMenuContent`,gU=R.forwardRef(iU(function(e,t){let{__scopeContextMenu:n,...r}=e,i=uU(hU,n),a=cU(n),o=R.useRef(!1);return(0,z.jsx)(eU,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`ContextMenuContent`)),_U=R.forwardRef(iU(function(e,t){let{__scopeContextMenu:n,...r}=e,i=cU(n);return(0,z.jsx)(tU,{...i,...r,ref:t})},`ContextMenuGroup`)),vU=R.forwardRef(iU(function(e,t){let{__scopeContextMenu:n,...r}=e,i=cU(n);return(0,z.jsx)(nU,{...i,...r,ref:t})},`ContextMenuItem`));function yU(e){return t=>t.pointerType===`mouse`?void 0:e(t)}iU(yU,`whenTouchOrPen`);var bU=dU,xU=pU,SU=mU,CU=gU,wU=_U,TU=vU;function EU(e){return(0,z.jsx)(bU,{...e})}function DU(e){return(0,z.jsx)(xU,{...e})}function OU({className:e,...t}){return(0,z.jsx)(SU,{children:(0,z.jsx)(CU,{className:W(`z-100 min-w-44 max-w-[calc(100vw-1rem)] rounded-md bg-zinc-900 p-1 text-zinc-200 shadow-xl ring-1 ring-white/10 outline-none`,e),...t})})}function kU(e){return(0,z.jsx)(wU,{...e})}function AU({className:e,variant:t=`default`,...n}){return(0,z.jsx)(TU,{"data-variant":t,className:W(`relative flex min-h-8 cursor-default items-center gap-1.5 rounded-sm px-2 py-1.5 text-sm outline-none select-none [&_svg]:size-3.5 [&_svg]:shrink-0 data-[disabled]:pointer-events-none data-[disabled]:opacity-45 data-[highlighted]:bg-white/7 data-[highlighted]:text-zinc-50 data-[variant=destructive]:text-rose-300`,e),...n})}function jU({name:e,title:t,icon:n,status:r,selected:i=!1,pending:a=!1,busy:o=!1,id:s,className:c,ariaLabel:l,onClick:u}){let d=W(`worktree-row flex h-auto min-h-11 w-full min-w-0 items-center justify-start gap-1.5 rounded-md px-2 py-1.5 text-left text-base/5 font-medium min-[701px]:min-h-8 min-[701px]:py-0.5 min-[701px]:text-sm/5`,a?`text-zinc-300`:i?`selected text-zinc-50 min-[701px]:bg-white/8!`:`text-zinc-300 hover:bg-white/5 hover:text-zinc-50`,`max-[700px]:flex-1 max-[700px]:hover:bg-transparent`,(a||o)&&`motion-safe:animate-pulse`,a&&`pointer-events-none`,c),f=(0,z.jsxs)(z.Fragment,{children:[n,(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:e}),r]})]});return(0,z.jsx)(fB,{asChild:!0,isActive:i,children:(0,z.jsx)(G,{id:s,variant:`ghost`,type:`button`,className:d,onClick:a?void 0:u,title:t,role:a?`status`:void 0,"aria-label":a?`Creating worktree ${e}`:l,"aria-live":a||l?`polite`:void 0,"aria-disabled":a||void 0,tabIndex:a?-1:void 0,children:f})})}function MU({projects:e,projectsPending:t,projectsError:n,projectsLoaded:r,activeProject:i,selectedWorktree:a,selectedTerminalId:o,selectedPendingTerminalId:s,selectedWebPanelId:c,webPanelRuntimeTitles:l,pendingTerminals:u,pendingWorktrees:d,pendingRemovals:f,onRetryProjects:p,onSelectTerminal:m,onSelectPendingTerminal:h,onCloseTerminal:g,onSelectWebPanel:_,onCloseWebPanel:v,onSelectWorktree:y,onPrepareRemoval:b,onOpenPanelDialog:x,onOpenWorktreeDialog:S}){let{attention:C,titles:w,programs:T,progress:E}=$P(),D=window.treeportDesktop,O=D?D.platform===`darwin`?`⌘N`:`Ctrl+N`:null,k=D?D.platform===`darwin`?`⌘⇧T`:`Ctrl+Shift+T`:null;return(0,z.jsxs)(`nav`,{className:`tree min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-2 pt-3 pb-5 min-[701px]:px-1.5 min-[701px]:pt-2 min-[701px]:pb-4 [scrollbar-color:var(--color-zinc-700)_transparent]`,"aria-label":`Projects and worktrees`,children:[t?(0,z.jsx)(`p`,{className:`sidebar-note px-2 py-3 text-base text-zinc-500 min-[701px]:text-sm`,children:`Loading repositories…`}):null,n&&!r?(0,z.jsxs)(`div`,{className:`flex flex-col items-start gap-2 px-2 py-3`,children:[(0,z.jsx)(`p`,{className:`sidebar-note text-base text-rose-300 min-[701px]:text-sm`,children:`Projects could not be loaded.`}),(0,z.jsx)(G,{type:`button`,variant:`secondary`,size:`sm`,onClick:p,children:`Retry`})]}):null,!t&&!n&&!e.length?(0,z.jsx)(`p`,{className:`sidebar-note px-2 py-3 text-base text-pretty text-zinc-500 min-[701px]:text-sm`,children:`Open a Git repository to begin.`}):null,(0,z.jsx)(`div`,{className:`grid gap-4`,children:e.filter(e=>e.id===i?.id).map(e=>(0,z.jsxs)(`div`,{className:`project-tree min-w-0`,children:[e.availability.state===`unavailable`?(0,z.jsx)(`p`,{className:`mx-1 mb-2 rounded-md bg-amber-400/8 px-2 py-1.5 text-sm text-amber-200`,role:`status`,children:e.availability.message||`Git repository unavailable`}):null,(0,z.jsxs)(lB,{className:`gap-2 min-[701px]:gap-1`,children:[e.worktrees.map(t=>(0,z.jsxs)(uB,{className:`group/worktree min-w-0`,children:[(0,z.jsxs)(EU,{children:[(0,z.jsx)(DU,{asChild:!0,disabled:t.kind!==`linked`,children:(0,z.jsxs)(`div`,{className:W(`relative min-w-0 max-[700px]:flex max-[700px]:items-center max-[700px]:gap-0.5 max-[700px]:rounded-md max-[700px]:has-[button:hover]:bg-white/5`,a?.id===t.id&&`max-[700px]:bg-white/8`),children:[(0,z.jsx)(jU,{id:`worktree-${t.id}`,name:t.name,title:`${t.path}${t.branch?` · ${t.branch}`:` · detached at ${t.head.slice(0,8)}`}`,selected:a?.id===t.id,className:W(a?.id===t.id&&`min-[701px]:pr-6`),busy:!!f[t.id],ariaLabel:f[t.id]===`checking`?`${t.name}, preparing removal`:f[t.id]?`${t.name}, removing`:void 0,onClick:()=>y(t),icon:f[t.id]?(0,z.jsx)(Jf,{className:`worktree-progress-icon worktree-removing-icon size-4 shrink-0 stroke-rose-400 stroke-[1.5] min-[701px]:size-3.5!`,"aria-hidden":`true`}):t.kind===`main`?(0,z.jsx)(qf,{className:`size-4 shrink-0 stroke-zinc-600 stroke-[1.5] min-[701px]:size-3.5!`,"aria-hidden":`true`}):(0,z.jsx)(Jf,{className:`shrink-0 stroke-zinc-600 stroke-[1.5] min-[701px]:size-3.5!`,"aria-hidden":`true`})}),a?.id===t.id?(0,z.jsx)(`div`,{className:`worktree-actions absolute inset-y-0 right-0 z-10 flex items-center max-[700px]:static max-[700px]:shrink-0`,children:(0,z.jsx)(yB,{label:`New panel in ${t.name}`,tooltip:`New panel in ${t.name}${k?` — ${k}`:``}`,...k?{keyShortcuts:D?.platform===`darwin`?`Meta+Shift+T`:`Control+Shift+T`}:{},className:`text-zinc-500 hover:bg-transparent hover:text-zinc-100 min-[701px]:size-6`,onClick:n=>x(e,t,n),children:(0,z.jsx)(ez,{})})}):null]})}),t.kind===`linked`?(0,z.jsx)(OU,{children:(0,z.jsx)(kU,{children:(0,z.jsxs)(AU,{variant:`destructive`,disabled:e.availability.state===`unavailable`||!!f[t.id],onSelect:()=>void b(t,document.getElementById(`worktree-${t.id}`)),children:[(0,z.jsx)(nz,{}),e.availability.state===`unavailable`?`Git repository unavailable`:f[t.id]?`Removal in progress`:`Remove worktree…`]})})}):null]}),(0,z.jsxs)(gB,{className:`terminal-list mr-0 ml-4 gap-px border-white/6 pr-0 pl-2 min-[701px]:ml-2.5 min-[701px]:pl-1.5`,"aria-label":`${t.name} terminals`,children:[t.terminals.map((e,n)=>{let r=w.get(e.id)||e.name,i=C.has(e.id),s=E.get(e.id),c=!!s&&!i&&s.state!==`paused`&&s.state!==`error`,l=[s?Qh(s):e.status,i?`bell`:null].filter(Boolean).join(`, `),u=a?.id===t.id&&n<9?n+1:null;return(0,z.jsxs)(_B,{className:`group/terminal relative min-w-0`,children:[(0,z.jsx)(vB,{asChild:!0,isActive:o===e.id,children:(0,z.jsxs)(G,{variant:`ghost`,type:`button`,className:W(`terminal-row grid h-auto min-h-11 w-full min-w-0 grid-cols-[1.25rem_minmax(0,1fr)_2rem] gap-1.5 rounded-md px-2 py-1.5 text-left text-base/5 font-normal min-[701px]:min-h-7 min-[701px]:grid-cols-[1rem_minmax(0,1fr)_1.75rem] min-[701px]:gap-1 min-[701px]:py-0 min-[701px]:text-xs/4`,o===e.id?`selected bg-cyan-400/8! text-cyan-50`:`text-zinc-300 hover:bg-white/5 hover:text-zinc-100`),onClick:()=>m(e),onMouseDown:e=>{e.button===1&&e.preventDefault()},onAuxClick:t=>{t.button===1&&(t.preventDefault(),g(e))},"aria-label":`${r}, ${l}`,"aria-keyshortcuts":u?`Meta+${u}`:void 0,children:[(0,z.jsx)(xz,{program:T.get(e.id)??null,progress:s??null,attention:i,exited:e.status===`exited`,className:`size-4! min-[701px]:size-3.5!`}),(0,z.jsx)(`span`,{className:W(`truncate`,c&&`text-cyan-300`,i&&`text-amber-200`),"aria-hidden":`true`,children:r}),u?(0,z.jsxs)(`kbd`,{className:`justify-self-end font-sans text-[0.6875rem] font-normal text-zinc-500 tabular-nums group-hover/terminal:opacity-0 group-focus-within/terminal:opacity-0 max-[700px]:opacity-0`,"aria-hidden":`true`,children:[`⌘`,u]}):(0,z.jsx)(`span`,{"aria-hidden":`true`})]})}),(0,z.jsx)(`div`,{className:`absolute inset-y-0 right-0 z-10 flex items-center opacity-0 group-hover/terminal:opacity-100 group-focus-within/terminal:opacity-100 max-[700px]:opacity-100`,children:(0,z.jsx)(yB,{label:`Close ${r}`,tooltip:t.terminals.length===1?`Every worktree keeps at least one terminal`:`Close terminal`,disabled:t.terminals.length===1,className:`text-zinc-500 hover:bg-transparent hover:text-zinc-200`,onClick:()=>g(e),children:(0,z.jsx)(oz,{})})})]},e.id)}),t.panels.filter(e=>e.kind===`web`).map((e,n)=>{let r=l[e.id]??e.title,i=a?.id===t.id&&t.terminals.length+n<9?t.terminals.length+n+1:null;return(0,z.jsxs)(_B,{className:`group/terminal relative min-w-0`,children:[(0,z.jsx)(vB,{asChild:!0,isActive:c===e.id,children:(0,z.jsxs)(G,{variant:`ghost`,type:`button`,className:W(`terminal-row grid h-auto min-h-11 w-full min-w-0 grid-cols-[1.25rem_minmax(0,1fr)_2rem] gap-1.5 rounded-md px-2 py-1.5 text-left text-base/5 font-normal min-[701px]:min-h-7 min-[701px]:grid-cols-[1rem_minmax(0,1fr)_1.75rem] min-[701px]:gap-1 min-[701px]:py-0 min-[701px]:text-xs/4`,c===e.id?`selected bg-cyan-400/8! text-cyan-50`:`text-zinc-300 hover:bg-white/5 hover:text-zinc-100`),onClick:()=>_(e),onMouseDown:e=>{e.button===1&&e.preventDefault()},onAuxClick:t=>{t.button===1&&(t.preventDefault(),v(e,t.currentTarget))},"aria-label":`${r}, web panel`,"aria-keyshortcuts":i?`Meta+${i}`:void 0,children:[(0,z.jsx)(iz,{className:`size-4! shrink-0 fill-zinc-500 min-[701px]:size-3.5!`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`truncate`,"aria-hidden":`true`,children:r}),i?(0,z.jsxs)(`kbd`,{className:`justify-self-end font-sans text-[0.6875rem] font-normal text-zinc-500 tabular-nums group-hover/terminal:opacity-0 group-focus-within/terminal:opacity-0 max-[700px]:opacity-0`,"aria-hidden":`true`,children:[`⌘`,i]}):(0,z.jsx)(`span`,{"aria-hidden":`true`})]})}),(0,z.jsx)(`div`,{className:`absolute inset-y-0 right-0 z-10 flex items-center opacity-0 group-hover/terminal:opacity-100 group-focus-within/terminal:opacity-100 max-[700px]:opacity-100`,children:(0,z.jsx)(yB,{label:`Close ${r}`,tooltip:`Close web panel`,className:`text-zinc-500 hover:bg-transparent hover:text-zinc-200`,onClick:t=>v(e,t),children:(0,z.jsx)(oz,{})})})]},e.id)}),u.filter(e=>e.worktreeId===t.id).map((e,n)=>{let r=t.panels.filter(e=>e.kind===`web`).length,i=t.terminals.length+r+n;return(0,z.jsx)(_B,{className:`min-w-0`,children:(0,z.jsx)(vB,{asChild:!0,isActive:s===e.id,children:(0,z.jsxs)(G,{variant:`ghost`,type:`button`,className:W(`terminal-row grid h-auto min-h-11 w-full min-w-0 grid-cols-[1.25rem_minmax(0,1fr)_auto] gap-1.5 rounded-md px-2 py-1.5 text-left text-base/5 font-normal min-[701px]:min-h-7 min-[701px]:grid-cols-[1rem_minmax(0,1fr)_auto] min-[701px]:gap-1 min-[701px]:py-0 min-[701px]:text-xs/4`,s===e.id?`selected bg-cyan-400/8! text-cyan-50`:`text-zinc-300 hover:bg-white/5 hover:text-zinc-100`),onClick:()=>h(e.id),"aria-label":`${e.name}, starting`,"aria-keyshortcuts":a?.id===t.id&&i<9?`Meta+${i+1}`:void 0,children:[(0,z.jsx)(OR,{className:`animate-spin fill-zinc-500`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`truncate`,"aria-hidden":`true`,children:e.name}),(0,z.jsx)(`span`,{className:`text-[0.6875rem] text-zinc-500`,"aria-hidden":`true`,children:`Starting…`})]})})},e.id)})]})]},t.id)),a?null:(0,z.jsx)(uB,{className:`min-w-0`,children:(0,z.jsx)(fB,{asChild:!0,children:(0,z.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-auto min-h-11 w-full justify-start gap-1.5 px-2 py-1.5 text-base/5 font-normal text-zinc-500 hover:bg-white/5 hover:text-zinc-100 min-[701px]:min-h-8 min-[701px]:py-0.5 min-[701px]:text-sm/5`,"aria-label":`New panel`,onClick:t=>x(e,null,t.currentTarget),children:[(0,z.jsx)(ez,{className:`min-[701px]:size-3.5!`}),(0,z.jsx)(`span`,{children:`New panel`})]})})}),d.filter(t=>t.projectId===e.id).map(e=>(0,z.jsx)(uB,{className:`min-w-0`,children:(0,z.jsx)(jU,{id:`pending-worktree-${e.id}`,name:e.typedName,title:`Creating ${e.typedName}`,pending:!0,icon:(0,z.jsx)(Jf,{className:`worktree-progress-icon size-4 shrink-0 stroke-cyan-400 stroke-[1.5] min-[701px]:size-3.5!`,"aria-hidden":`true`})})},e.id)),(0,z.jsx)(uB,{className:`min-w-0`,children:(0,z.jsx)(fB,{asChild:!0,children:(0,z.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-auto min-h-11 w-full justify-start gap-1.5 px-2 py-1.5 text-base/5 font-normal text-zinc-500 hover:bg-white/5 hover:text-zinc-100 min-[701px]:min-h-8 min-[701px]:py-0.5 min-[701px]:text-sm/5`,disabled:e.availability.state===`unavailable`,"aria-keyshortcuts":O?D?.platform===`darwin`?`Meta+N`:`Control+N`:void 0,title:O?`New worktree — ${O}`:void 0,onClick:t=>S(e,t.currentTarget),children:[(0,z.jsx)(ez,{className:`min-[701px]:size-3.5!`}),(0,z.jsx)(`span`,{children:`New worktree`}),O?(0,z.jsx)(`kbd`,{className:`ml-auto font-sans text-[0.6875rem] text-zinc-500`,"aria-hidden":`true`,children:O}):null]})})})]})]},e.id))})]})}function NU(e){let t=[],n=``,r=null,i=!1;for(let a=0;a<e.length;a+=1){let o=e[a];if(r===`single`){o===`'`?r=null:n+=o;continue}if(r===`double`){if(o===`"`)r=null;else if(o===`\\`){if(a+=1,a>=e.length)return{argv:null,error:`The command ends with an incomplete escape.`};n+=e[a]}else n+=o;continue}if(/\s/.test(o)){i&&=(t.push(n),n=``,!1);continue}if(i=!0,o===`'`)r=`single`;else if(o===`"`)r=`double`;else if(o===`\\`){if(a+=1,a>=e.length)return{argv:null,error:`The command ends with an incomplete escape.`};n+=e[a]}else n+=o}return r?{argv:null,error:`The command has an unclosed quote.`}:(i&&t.push(n),t.length===0?{argv:null,error:`Enter a command.`}:{argv:t,error:null})}function PU(e){return e.map(e=>e===``?`""`:/[\s"'\\]/.test(e)?`"${e.replace(/["\\]/g,`\\$&`)}"`:e).join(` `)}var FU=Object.defineProperty,IU=(e,t)=>FU(e,`name`,{value:t,configurable:!0}),LU=`Checkbox`,[RU,zU]=kF(LU),[BU,VU]=RU(LU);function HU(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=$F({prop:n,defaultProp:i??!1,onChange:c,caller:LU}),[m,h]=R.useState(null),[g,_]=R.useState(null),v=R.useRef(!1),[y,b]=R.useReducer(e=>e+1,0),x=!m||!!o||!!m.closest(`form`),S={checked:f,disabled:a,setChecked:p,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,userInteractionCount:y,onUserInteraction:b,required:l,defaultChecked:!ZU(i)&&i,isFormControl:x,bubbleInput:g,setBubbleInput:_};return(0,z.jsx)(BU,{scope:t,...S,children:XU(d)?d(S):r})}IU(HU,`CheckboxProvider`);var UU=`CheckboxTrigger`,WU=R.forwardRef(IU(function({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i){let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:m,bubbleInput:h}=VU(UU,e),g=tp(i,u),_=R.useRef(c);return R.useEffect(()=>{let e=a?.form;if(e){let t=IU(()=>d(_.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,z.jsx)(oI.button,{type:`button`,role:`checkbox`,"aria-checked":ZU(c)?`mixed`:c,"aria-required":l,"data-state":QU(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:g,onKeyDown:PF(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:PF(n,e=>{p(),d(e=>ZU(e)?!0:!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),GU=R.forwardRef(IU(function(e,t){let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,z.jsx)(HU,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(WU,{...d,ref:t,__scopeCheckbox:n}),e&&(0,z.jsx)(YU,{__scopeCheckbox:n})]})})},`Checkbox`)),KU=`CheckboxIndicator`,qU=R.forwardRef(IU(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=VU(KU,n);return(0,z.jsx)(qI,{present:r||ZU(a.checked)||a.checked===!0,children:(0,z.jsx)(oI.span,{"data-state":QU(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),JU=`CheckboxBubbleInput`,YU=R.forwardRef(IU(function({__scopeCheckbox:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:m,setBubbleInput:h}=VU(JU,e),g=tp(r,h),_=tV(i),v=R.useRef(!1),y=R.useRef(s),b=R.useRef(o);R.useEffect(()=>{let e=m;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==b.current;b.current=o;let i=y.current!==s;y.current=s;let c=!(r&&a.current);if(i&&n){v.current=!r;let t=new Event(`click`,{bubbles:c});e.indeterminate=ZU(s),n.call(e,!ZU(s)&&s),e.dispatchEvent(t),v.current=!1}},[m,s,a,o]);let x=R.useRef(!ZU(s)&&s);return(0,z.jsx)(oI.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:g,onClick:PF(t,e=>{v.current&&e.stopPropagation()}),style:{...n.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function XU(e){return typeof e==`function`}IU(XU,`isFunction`);function ZU(e){return e===`indeterminate`}IU(ZU,`isIndeterminate`);function QU(e){return ZU(e)?`indeterminate`:e?`checked`:`unchecked`}IU(QU,`getState`);var $U=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(GU,{ref:n,className:W(`peer grid size-4 shrink-0 place-content-center rounded-sm border border-white/20 bg-zinc-950 text-zinc-950 outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-cyan-400 data-[state=checked]:bg-cyan-400 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-cyan-400`,e),...t,children:(0,z.jsx)(qU,{className:`grid place-content-center text-current`,children:(0,z.jsx)(Kf,{className:`size-3.5`})})}));$U.displayName=GU.displayName;function eW({presets:e,loading:t,loadError:n,onRetry:r}){let i=Ye(),[a,o]=(0,R.useState)({editingId:null,loadedUpdatedAt:null,name:``,command:``,closeOnSuccess:!1,commandError:null,notice:null}),{editingId:s,loadedUpdatedAt:c,name:l,command:u,closeOnSuccess:d,commandError:f,notice:p}=a,m=()=>{o({editingId:null,loadedUpdatedAt:null,name:``,command:``,closeOnSuccess:!1,commandError:null,notice:null})};if(s){let t=e.find(e=>e.id===s);t?t.updatedAt!==c&&o({editingId:t.id,loadedUpdatedAt:t.updatedAt,name:t.name,command:PU([t.executable,...t.args]),closeOnSuccess:t.closeOnSuccess,commandError:null,notice:c?`This preset changed, so the latest saved values were loaded.`:p}):o({editingId:null,loadedUpdatedAt:null,name:``,command:``,closeOnSuccess:!1,commandError:null,notice:`That preset was deleted. You can create a new one.`})}let h=pt({mutationFn:({presetId:e,input:t,expectedUpdatedAt:n})=>e?Tf(CE.api[`terminal-presets`][`:presetId`].$patch({param:{presetId:e},json:{...t,expectedUpdatedAt:n}})).then(e=>e.preset):Tf(CE.api[`terminal-presets`].$post({json:t})).then(e=>e.preset),onSuccess:(e,t)=>{i.setQueryData(mz,n=>t.presetId?n?.map(t=>t.id===e.id?e:t):[...n??[],e]),o({editingId:e.id,loadedUpdatedAt:e.updatedAt,name:e.name,command:PU([e.executable,...e.args]),closeOnSuccess:e.closeOnSuccess,commandError:null,notice:`Preset saved.`})},onError:(e,{presetId:t,input:n})=>{i.invalidateQueries({queryKey:mz}),xF(e,{operation:`${t?`update`:`create`} terminal preset “${n.name}”`})},onSettled:async()=>{await Promise.all([i.invalidateQueries({queryKey:mz}),i.invalidateQueries({queryKey:[`terminal-preset-definitions`]})])}}),g=pt({mutationFn:e=>Tf(CE.api[`terminal-presets`][`:presetId`].$delete({param:{presetId:e.id},json:{expectedUpdatedAt:e.updatedAt}})),onSuccess:(e,t)=>{i.setQueryData(mz,e=>e?.filter(e=>e.id!==t.id)),s===t.id&&o({editingId:null,loadedUpdatedAt:null,name:``,command:``,closeOnSuccess:!1,commandError:null,notice:`Preset deleted.`})},onError:(e,t)=>{i.invalidateQueries({queryKey:mz}),xF(e,{operation:`delete terminal preset “${t.name}”`})},onSettled:async()=>{await Promise.all([i.invalidateQueries({queryKey:mz}),i.invalidateQueries({queryKey:[`terminal-preset-definitions`]})])}}),_=h.isPending||g.isPending;return(0,z.jsx)(z.Fragment,{children:(0,z.jsxs)(`div`,{className:`grid min-h-0 gap-5 border-t border-white/8 pt-4 md:grid-cols-[minmax(12rem,0.8fr)_minmax(0,1.35fr)]`,children:[(0,z.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-2`,"aria-labelledby":`saved-presets-title`,children:[(0,z.jsxs)(`div`,{className:`flex min-h-8 items-center justify-between gap-3`,children:[(0,z.jsx)(`h3`,{id:`saved-presets-title`,className:`text-sm font-medium text-zinc-200`,children:`Presets`}),(0,z.jsxs)(G,{type:`button`,variant:`secondary`,size:`sm`,disabled:_,onClick:m,children:[(0,z.jsx)(ez,{}),` New`]})]}),(0,z.jsxs)(`div`,{className:`max-h-72 overflow-y-auto rounded-lg bg-white/3 p-1 ring-1 ring-white/8 [scrollbar-color:var(--color-zinc-700)_transparent]`,children:[(0,z.jsxs)(`div`,{className:`grid min-h-14 min-w-0 content-center gap-0.5 rounded-md px-3 py-2`,children:[(0,z.jsx)(`span`,{className:`truncate text-sm font-medium text-zinc-100`,children:`Shell`}),(0,z.jsx)(`span`,{className:`truncate text-xs text-zinc-500`,children:`Built in · login shell`})]}),e.map(e=>(0,z.jsxs)(`div`,{className:W(`group/preset flex min-h-14 items-center rounded-md px-1 transition-colors hover:bg-white/5`,s===e.id&&`bg-white/7 hover:bg-white/7`),children:[(0,z.jsxs)(`button`,{type:`button`,className:`grid min-w-0 flex-1 cursor-pointer gap-0.5 rounded-sm px-2 py-2 text-left outline-none focus-visible:outline-2 focus-visible:outline-cyan-400`,"aria-current":s===e.id?`true`:void 0,disabled:_,onClick:()=>{o({editingId:e.id,loadedUpdatedAt:e.updatedAt,name:e.name,command:PU([e.executable,...e.args]),closeOnSuccess:e.closeOnSuccess,commandError:null,notice:null})},children:[(0,z.jsx)(`span`,{className:`truncate text-sm font-medium text-zinc-100`,children:e.name}),(0,z.jsx)(`span`,{className:`truncate text-xs text-zinc-500`,children:PU([e.executable,...e.args])})]}),(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`mr-1 size-11 shrink-0 hover:text-rose-300 min-[701px]:size-8 min-[701px]:opacity-0 min-[701px]:group-hover/preset:opacity-100 min-[701px]:focus-visible:opacity-100`,"aria-label":`Delete ${e.name}`,disabled:_,onClick:()=>{window.confirm(`Delete terminal preset “${e.name}”?`)&&g.mutate(e)},children:(0,z.jsx)(nz,{})})]},e.id)),t&&(0,z.jsx)(`p`,{className:`px-2.5 py-3 text-sm text-zinc-500`,role:`status`,children:`Loading presets…`}),n&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2.5 py-3`,children:[(0,z.jsx)(`p`,{className:`text-sm text-zinc-400`,children:`Could not load presets.`}),(0,z.jsx)(G,{type:`button`,variant:`secondary`,size:`sm`,onClick:r,children:`Retry`})]})]})]}),(0,z.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:e=>{e.preventDefault();let t=NU(u);if(t.argv===null){o(e=>({...e,commandError:t.error}));return}let[n,...r]=t.argv;h.mutate({presetId:s,input:{name:l,executable:n,args:r,closeOnSuccess:d},expectedUpdatedAt:c})},children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-medium text-zinc-200`,children:`Preset details`}),p&&(0,z.jsx)(`span`,{className:`text-xs text-zinc-400`,role:`status`,children:p})]}),(0,z.jsxs)(sz,{children:[(0,z.jsx)(lz,{htmlFor:`preset-name`,children:`Name`}),(0,z.jsx)(cz,{id:`preset-name`,name:`preset-name`,value:l,maxLength:120,disabled:_,autoFocus:!0,required:!0,onChange:e=>{o(t=>({...t,name:e.target.value,notice:null}))},placeholder:`Code review`})]}),(0,z.jsxs)(sz,{children:[(0,z.jsx)(lz,{htmlFor:`preset-command`,children:`Command`}),(0,z.jsx)(cz,{id:`preset-command`,name:`preset-command`,value:u,disabled:_,required:!0,"aria-invalid":f?!0:void 0,"aria-describedby":f?`preset-command-error`:void 0,onChange:e=>{o(t=>({...t,command:e.target.value,commandError:null,notice:null}))},placeholder:`diff main --mode split`}),f&&(0,z.jsx)(`p`,{id:`preset-command-error`,className:`text-xs text-rose-300`,role:`alert`,children:f})]}),(0,z.jsx)(sz,{children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,z.jsx)($U,{id:`preset-close-on-success`,checked:d,disabled:_,onCheckedChange:e=>{o(t=>({...t,closeOnSuccess:e===!0,notice:null}))}}),(0,z.jsxs)(`div`,{className:`grid gap-1`,children:[(0,z.jsx)(lz,{htmlFor:`preset-close-on-success`,children:`Close on success`}),(0,z.jsx)(`p`,{className:`form-note`,children:`Use for one-off commands such as opening an editor. Failed commands remain open for inspection.`})]})]})}),(0,z.jsx)(G,{type:`submit`,className:`self-end`,disabled:_||!l.trim()||!u.trim()||s!==null&&c===null,children:h.isPending?`Saving…`:s?`Save changes`:`Create preset`})]})]})})}function tW({open:e,onOpenChange:t,restoreFocusTo:n,presets:r,loading:i,loadError:a,onRetry:o}){return(0,z.jsx)(vR,{open:e,onOpenChange:t,children:(0,z.jsxs)(CR,{className:`max-w-3xl`,restoreFocusTo:n,children:[(0,z.jsxs)(wR,{children:[(0,z.jsx)(TR,{children:`Global terminal presets`}),(0,z.jsx)(ER,{children:`Create commands available in every repository. Arguments are passed exactly as entered.`})]}),(0,z.jsx)(eW,{presets:r,loading:i,loadError:a,onRetry:o})]})})}function nW(e){return e.source.type===`repository`?e.source.format===`zed`?`Repository · Zed`:`Repository`:e.source.type===`user`?`Global`:`${e.source.scope===`project`?`Repository`:`Global`} · ${e.source.packageId}`}function rW({open:e,onOpenChange:t,restoreFocusTo:n,worktreeName:r,presets:i,presetDiagnostics:a,presetsLoading:o,presetsError:s,webPanelDefinitions:c,webPanelDefinitionsLoading:l,webPanelDefinitionsError:u,launchDisabled:d,onCreateTerminal:f,onCreateWebPanel:p,onManagePresets:m}){let[h,g]=(0,R.useState)(``),[_,v]=(0,R.useState)(0),y=h.trim().toLocaleLowerCase(),b=`shell`.includes(y),x=i.filter(e=>[e.name,e.executable,nW(e),PU([e.executable,...e.args])].some(e=>e.toLocaleLowerCase().includes(y))),S=c.filter(e=>[e.title,e.id].some(e=>e.toLocaleLowerCase().includes(y))),C=x.length+ +!!b,w=C===0&&S.length===0;return(0,z.jsx)(vR,{open:e,onOpenChange:e=>{e||(g(``),v(0)),t(e)},children:(0,z.jsxs)(CR,{className:`max-w-xl gap-0 overflow-hidden rounded-xl bg-zinc-800/95 p-0 shadow-2xl ring-white/15 backdrop-blur-2xl max-[700px]:p-0 max-[700px]:pb-0 [&>button.absolute]:hidden`,mobilePresentation:`dialog`,overlayClassName:`bg-transparent backdrop-blur-[1px]`,restoreFocusTo:n,children:[(0,z.jsx)(TR,{className:`sr-only`,children:`New panel`}),(0,z.jsxs)(ER,{className:`sr-only`,children:[`Search for a terminal or web panel to start`,r?` in ${r}`:``,`.`]}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 border-b border-white/8 px-4`,children:[(0,z.jsx)(QR,{className:`size-4 shrink-0 fill-zinc-400`,"aria-hidden":`true`}),(0,z.jsx)(`input`,{type:`search`,name:`panel-launcher-search`,className:`h-14 min-w-0 flex-1 bg-transparent text-base text-zinc-50 outline-none placeholder:text-zinc-500 sm:h-12 sm:text-sm`,value:h,autoComplete:`off`,autoFocus:!0,"aria-label":`Search panels`,placeholder:r?`New panel in ${r}`:`New panel`,onChange:e=>{g(e.target.value),v(0)},onKeyDown:e=>{let t=Array.from(e.currentTarget.closest(`[role="dialog"]`)?.querySelectorAll(`[data-panel-launch]:not(:disabled)`)??[]);if(t.length===0)return;if(e.key===`Enter`){e.preventDefault(),t[_]?.click();return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let n=e.key===`ArrowDown`?1:-1;v((_+n+t.length)%t.length)}}),(0,z.jsx)(`kbd`,{className:`hidden shrink-0 rounded bg-white/6 px-1.5 py-0.5 font-sans text-[0.6875rem] text-zinc-500 ring-1 ring-white/8 sm:inline`,children:`esc`})]}),(0,z.jsxs)(`div`,{className:`max-h-[min(22rem,55dvh)] overflow-y-auto p-1.5 [scrollbar-color:var(--color-zinc-600)_transparent] [&_[data-selected]]:bg-white/8`,onKeyDown:e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=Array.from(e.currentTarget.querySelectorAll(`[data-panel-launch]:not(:disabled)`)),n=t.indexOf(e.target);n<0||t.length<2||(e.preventDefault(),t[(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus())},children:[(0,z.jsxs)(`div`,{role:`group`,"aria-label":`Terminals`,children:[C>0||o||s||a.length>0?(0,z.jsx)(`p`,{className:`px-2 py-1 text-xs font-medium text-zinc-500`,children:`Terminals`}):null,b?(0,z.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-12 w-full justify-start gap-3 rounded-lg py-2 pr-3 pl-2 text-base font-normal text-zinc-100 hover:bg-white/8 focus-visible:bg-white/8 sm:h-9 sm:text-sm`,"aria-label":`Shell`,"data-panel-launch":!0,"data-selected":_===0?``:void 0,disabled:d,onFocus:()=>v(0),onMouseMove:()=>v(0),onClick:()=>{g(``),v(0),f({name:`Shell`})},children:[(0,z.jsx)(KR,{className:`size-4 shrink-0 fill-zinc-400`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:`Shell`}),(0,z.jsx)(`span`,{className:`shrink-0 text-zinc-500`,children:`Login shell`})]}):null,x.map((e,t)=>{let n=t+ +!!b,r=nW(e),i=PU([e.executable,...e.args]);return(0,z.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-12 w-full justify-start gap-3 rounded-lg py-2 pr-3 pl-2 text-base font-normal text-zinc-100 hover:bg-white/8 focus-visible:bg-white/8 sm:h-9 sm:text-sm`,"aria-label":`${e.name}, ${r}, ${i}`,"data-panel-launch":!0,"data-selected":_===n?``:void 0,disabled:d,onFocus:()=>v(n),onMouseMove:()=>v(n),onClick:()=>{g(``),v(0),f({name:e.name,argv:[e.executable,...e.args],...e.cwd?{cwd:e.cwd}:{},...Object.keys(e.env).length?{env:{...e.env}}:{},...e.closeOnSuccess?{closeOnSuccess:!0}:{returnToShell:!0}})},children:[(0,z.jsx)(KR,{className:`size-4 shrink-0 fill-zinc-400`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.name}),(0,z.jsxs)(`span`,{className:`min-w-0 max-w-1/2 truncate text-zinc-500`,children:[r,` · `,i]})]},e.id)}),o?(0,z.jsx)(`p`,{className:`px-3 py-2 text-base text-zinc-500 sm:text-sm`,role:`status`,children:`Loading presets…`}):null,s?(0,z.jsx)(`p`,{className:`px-3 py-2 text-base text-zinc-500 sm:text-sm`,role:`status`,children:`Presets unavailable`}):null,a.map(e=>(0,z.jsx)(`p`,{className:`px-3 py-2 text-base text-amber-300 sm:text-sm`,role:`status`,children:e.message},`${e.path}:${e.itemId??`file`}:${e.message}`))]}),(0,z.jsxs)(`div`,{role:`group`,"aria-label":`Web panels`,children:[S.length>0||l||u?(0,z.jsx)(`p`,{className:`mt-1 px-2 py-1 text-xs font-medium text-zinc-500`,children:`Web panels`}):null,S.map((e,t)=>{let n=C+t;return(0,z.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-12 w-full justify-start gap-3 rounded-lg py-2 pr-3 pl-2 text-base font-normal text-zinc-100 hover:bg-white/8 focus-visible:bg-white/8 sm:h-9 sm:text-sm`,"aria-label":`${e.title}, web panel`,"data-panel-launch":!0,"data-selected":_===n?``:void 0,disabled:d,onFocus:()=>v(n),onMouseMove:()=>v(n),onClick:()=>{g(``),v(0),p(e)},children:[(0,z.jsx)(iz,{className:`size-4 shrink-0 fill-zinc-400`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.title}),(0,z.jsx)(`span`,{className:`min-w-0 max-w-1/2 truncate text-zinc-500`,children:e.source.type===`project`?`Project`:`${e.source.scope===`project`?`Project`:`Global`} · ${e.source.packageId}`})]},e.id)}),l?(0,z.jsx)(`p`,{className:`px-3 py-2 text-base text-zinc-500 sm:text-sm`,role:`status`,children:`Loading web panels…`}):null,u?(0,z.jsx)(`p`,{className:`px-3 py-2 text-base text-zinc-500 sm:text-sm`,role:`status`,children:`Web panels unavailable`}):null]}),w&&!o&&!l?(0,z.jsx)(`p`,{className:`px-3 py-8 text-center text-base text-zinc-500 sm:text-sm`,children:`No matching panels.`}):null]}),(0,z.jsxs)(`div`,{className:`border-t border-white/8 p-1.5`,children:[(0,z.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-12 w-full justify-start gap-3 rounded-lg py-2 pr-3 pl-2 text-base font-normal text-zinc-400 hover:bg-white/8 hover:text-zinc-100 sm:h-9 sm:text-sm`,onClick:()=>{g(``),v(0),m()},children:[(0,z.jsx)(WR,{className:`size-4 shrink-0 fill-zinc-500`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:`Manage global presets`})]}),(0,z.jsx)(G,{asChild:!0,variant:`ghost`,className:`h-12 w-full justify-start gap-3 rounded-lg py-2 pr-3 pl-2 text-base font-normal text-zinc-400 hover:bg-white/8 hover:text-zinc-100 sm:h-9 sm:text-sm`,children:(0,z.jsxs)(`a`,{href:`https://treeport.app/features/terminal-presets/#repository-presets`,target:`_blank`,rel:`noreferrer`,children:[(0,z.jsx)(PR,{className:`size-4 shrink-0 fill-zinc-500`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:`Configure repository presets`})]})})]})]})})}var iW={phase:`closed`,degraded:!1,controller:!1,controlPending:!1,title:null,bellActive:!1,bellSerial:0,exitSerial:0,fileTransfer:null,hasSelection:!1,selecting:!1,viewingHistory:!1,pasteRequestSerial:0,error:null};function aW({worktree:e,terminal:t,pendingTerminals:n,selectedPendingTerminalId:r,loading:i,autoFocusBlocked:a,onStatusChange:o}){let s=(0,R.useRef)(null),c=(0,R.useRef)(null),l=(0,R.useRef)(null),[u,d]=(0,R.useState)(null),[f,p]=(0,R.useState)(!1),[m,h]=(0,R.useState)(!1),[g,_]=(0,R.useState)({terminalId:null,open:!1,value:``}),v=(0,R.useRef)(o);v.current=o;let y=Nz();(0,R.useLayoutEffect)(()=>{if(!t){d(null);return}let e=VP.acquire(t.id);return d(e),()=>VP.release(t.id)},[t?.id]);let b=u?.terminalId===t?.id?u:null,x=(0,R.useSyncExternalStore)((0,R.useCallback)(e=>{if(!b)return()=>void 0;let t=b.getSnapshot();return b.subscribe(()=>{let n=b.getSnapshot();n.pasteRequestSerial>t.pasteRequestSerial&&_(e=>({terminalId:b.terminalId,open:!0,value:e.terminalId===b.terminalId?e.value:``})),n.exitSerial>t.exitSerial&&v.current(),t=n,e()})},[b]),b?.getSnapshot??(()=>iW),()=>iW),S=g.terminalId===t?.id&&g.open,C=g.terminalId===t?.id?g.value:``,{titles:w}=$P();(0,R.useLayoutEffect)(()=>{let e=c.current;if(!(!e||!b))return b.mount(e),()=>b.unmount(e)},[b]),lf({terminalId:t?.id??null,session:b,blocked:a}),(0,R.useEffect)(()=>{if(b)return b.setInputModifiers(f,m,()=>{p(!1),h(!1)}),()=>b.setInputModifiers(!1,!1,()=>void 0)},[b,m,f]);let T=e=>{let t=e;f&&e.length===1&&(t=String.fromCharCode(e.toUpperCase().charCodeAt(0)&31)),m&&(t=`\u001b${t}`),b?.sendText(t),p(!1),h(!1)},E=e=>{b?.sendArrow(e,m),p(!1),h(!1)},D=e=>{e&&(b?.pasteText(e),_({terminalId:t?.id??null,open:!1,value:``}))},O=()=>{b?.requestControl(),_(e=>({terminalId:t?.id??null,open:!0,value:e.terminalId===t?.id?e.value:``})),navigator.clipboard&&navigator.clipboard.readText().then(e=>D(e),()=>void 0)},k=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`label`,{htmlFor:`terminal-paste-input`,className:`text-xs font-medium text-zinc-200`,children:`Paste text here`}),(0,z.jsx)(`textarea`,{id:`terminal-paste-input`,autoFocus:!0,rows:2,value:C,placeholder:`Touch and hold here, then choose Paste`,className:`min-h-16 resize-none rounded-md border border-white/10 bg-zinc-950 px-3 py-2 text-base text-zinc-100 outline-none focus:border-cyan-500`,onChange:e=>_({terminalId:t?.id??null,open:!0,value:e.target.value}),onPaste:e=>{let t=e.clipboardData.getData(`text`);t&&(e.preventDefault(),D(t))}}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>_({terminalId:t?.id??null,open:!1,value:``}),children:`Cancel`}),(0,z.jsx)(G,{type:`button`,size:`sm`,disabled:!C,onClick:()=>D(C),children:`Send`})]})]}),ee=n.find(e=>e.id===r),te=t?w.get(t.id)||t.name:ee?.name??``;return(0,z.jsxs)(`main`,{ref:s,className:W(`terminal-shell grid min-h-0 min-w-0 grid-rows-[minmax(0,1fr)] bg-zinc-950 max-[700px]:grid-rows-[minmax(0,1fr)_3.25rem]`,x.bellActive&&`terminal-bell`),"aria-label":ee?`Starting ${ee.name} terminal`:t?`${te} terminal`:`Terminal panel`,children:[ee?(0,z.jsx)(`div`,{className:`grid min-h-0 place-items-center bg-[radial-gradient(circle_at_center,var(--color-zinc-900)_0,var(--color-zinc-950)_55%)] p-8`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-zinc-300`,role:`status`,children:[(0,z.jsx)(OR,{className:`size-4 animate-spin fill-zinc-500`,"aria-hidden":`true`}),`Starting `,ee.name,`…`]})}):t?(0,z.jsxs)(`div`,{className:`relative min-h-0 min-w-0 overflow-hidden`,children:[(0,z.jsx)(`div`,{className:`xterm-host absolute inset-0 min-h-0 min-w-0 overflow-hidden p-2.5 outline-none max-[700px]:p-1.5`,ref:c,onMouseDown:()=>b?.focus({requestControl:!0})},t.id),x.viewingHistory&&!S?(0,z.jsxs)(`div`,{className:`absolute top-3 left-1/2 z-20 flex -translate-x-1/2 items-center gap-2 rounded-full bg-zinc-900/95 py-1 pr-1 pl-3 text-xs text-zinc-300 shadow-lg ring-1 ring-amber-400/20 backdrop-blur`,children:[(0,z.jsxs)(`span`,{role:`status`,className:`whitespace-nowrap leading-tight`,children:[(0,z.jsx)(`strong`,{className:`block font-medium text-zinc-100`,children:x.hasSelection||x.selecting?`Selection is active`:`Scrolled back in tmux`}),(0,z.jsx)(`span`,{className:`block text-[0.6875rem] text-zinc-400`,children:`New output is continuing off-screen`})]}),(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 rounded-full px-2.5 text-xs text-cyan-200 hover:bg-white/8 hover:text-cyan-100`,onClick:()=>{x.hasSelection||x.selecting?b?.clearSelectionAndJumpToLatest():b?.jumpToLatest()},children:x.hasSelection||x.selecting?`Clear`:`Follow latest`})]}):null,x.phase===`ready`&&!x.controller?(0,z.jsxs)(`span`,{className:`absolute top-3 right-3 z-10 inline-flex shrink-0 items-center gap-1.5 rounded-full bg-zinc-900/90 px-2 py-1 text-[0.6875rem] font-medium text-zinc-400 shadow ring-1 ring-white/8 backdrop-blur`,title:`Interact with the terminal to control it`,children:[(0,z.jsx)(`span`,{className:W(`size-1.5 rounded-full bg-zinc-500`,x.controlPending&&`animate-pulse bg-cyan-400`),"aria-hidden":`true`}),x.controlPending?`Taking control…`:`Viewing`]}):null,S&&(y?(0,z.jsx)(vR,{open:!0,onOpenChange:e=>{e||_({terminalId:t.id,open:!1,value:``})},children:(0,z.jsxs)(CR,{className:`max-w-sm gap-3 p-4`,mobilePresentation:`dialog`,restoreFocusTo:l.current,children:[(0,z.jsxs)(wR,{children:[(0,z.jsx)(TR,{className:`text-lg sm:text-lg`,children:`Paste into terminal`}),(0,z.jsx)(ER,{className:`sr-only`,children:`Paste text and send it to the active terminal.`})]}),k]})}):(0,z.jsx)(`div`,{className:`absolute inset-x-3 bottom-3 z-20 grid gap-2 rounded-lg bg-zinc-900 p-3 shadow-xl ring-1 ring-white/15`,role:`dialog`,"aria-label":`Paste into terminal`,children:k})),x.hasSelection&&!S&&(0,z.jsxs)(`div`,{className:`terminal-selection-actions absolute right-3 bottom-3 z-10 overflow-hidden rounded-md bg-zinc-800 shadow-lg ring-1 ring-white/15 max-[700px]:bottom-2`,"aria-label":`Terminal text selection`,children:[(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`rounded-none border-r border-white/10 px-3 text-zinc-100`,onClick:()=>b?.copySelection(),children:`Copy`}),(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`rounded-none px-3 text-zinc-300`,onClick:()=>b?.clearSelection(),children:`Clear`})]}),(x.degraded||x.fileTransfer)&&(0,z.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-0 top-3 z-10 flex flex-col items-center gap-2`,children:[x.degraded&&(0,z.jsx)(`span`,{className:`max-w-[calc(100%-1.5rem)] rounded-full bg-zinc-900/90 px-3 py-1 text-center text-xs text-amber-200 shadow ring-1 ring-amber-400/20 backdrop-blur`,children:x.error?`${x.error} Retrying…`:`Reconnecting…`}),x.fileTransfer&&(0,z.jsx)(`span`,{className:W(`rounded-full bg-zinc-900/90 px-3 py-1 text-xs shadow ring-1 backdrop-blur`,x.fileTransfer.state===`error`?`text-rose-100 ring-rose-400/30`:`text-cyan-100 ring-cyan-400/20`),role:x.fileTransfer.state===`error`?`alert`:`status`,children:x.fileTransfer.message})]}),x.phase===`closed`&&x.error&&(0,z.jsx)(`div`,{className:`absolute inset-x-0 top-3 z-10 flex justify-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-full bg-rose-950/95 px-3 py-1 text-xs text-rose-100 shadow ring-1 ring-rose-400/30 backdrop-blur`,children:[(0,z.jsx)(`span`,{children:x.error}),(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs text-rose-100 hover:bg-rose-900`,onClick:()=>b?.retry(),children:`Retry`})]})}),(0,z.jsxs)(`span`,{className:`sr-only`,"aria-live":`polite`,children:[x.phase===`ready`?x.controller?`Controlling terminal`:x.controlPending?`Taking control of terminal`:`Viewing terminal`:``,x.bellActive?` Bell from ${te}`:``]})]}):i?(0,z.jsx)(`div`,{className:`grid min-h-0 place-items-center bg-[radial-gradient(circle_at_center,var(--color-zinc-900)_0,var(--color-zinc-950)_55%)] p-8`,children:(0,z.jsx)(`div`,{role:`status`,"aria-label":`Loading workspace`,children:(0,z.jsx)(OR,{className:`size-6 animate-spin fill-zinc-500`,"aria-hidden":`true`})})}):(0,z.jsx)(`div`,{className:`empty-state grid min-h-0 place-items-center bg-[radial-gradient(circle_at_center,var(--color-zinc-900)_0,var(--color-zinc-950)_55%)] p-8`,children:(0,z.jsxs)(`div`,{className:`grid max-w-lg gap-3`,children:[(0,z.jsx)(`p`,{className:`eyebrow`,children:`No terminal open`}),(0,z.jsx)(`h1`,{className:`text-balance text-2xl font-semibold tracking-tight text-zinc-50 sm:text-3xl`,children:e?`Start a terminal for this worktree.`:`Choose a worktree.`}),(0,z.jsx)(`p`,{className:`max-w-[52ch] text-base text-pretty text-zinc-400 sm:text-sm`,children:e?`Use New panel in the sidebar to start a login shell, preset, or web panel.`:`Select a worktree from the sidebar to view its terminals.`})]})}),t&&(0,z.jsxs)(`div`,{className:`accessory-row hidden min-w-0 touch-pan-x overflow-x-auto overflow-y-hidden border-t border-white/8 bg-zinc-900 pt-1 pr-[env(safe-area-inset-right)] pb-[calc(0.25rem+env(safe-area-inset-bottom))] pl-[env(safe-area-inset-left)] max-[700px]:flex [&_button]:h-11 [&_button]:min-w-11 [&_button]:grow [&_button]:rounded-none [&_button]:border-r [&_button]:border-white/8 [&_button]:text-sm [&_button:last-child]:border-r-0`,"aria-label":`Terminal accessory keys`,onPointerDownCapture:()=>b?.requestControl(),children:[(0,z.jsx)(G,{variant:`ghost`,type:`button`,onClick:()=>T(`\x1B`),children:`Esc`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,className:f?`latched bg-cyan-950 text-cyan-100`:``,"aria-pressed":f,onClick:()=>{p(e=>!e),b?.focus()},children:`Ctrl`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,className:m?`latched bg-cyan-950 text-cyan-100`:``,"aria-pressed":m,onClick:()=>{h(e=>!e),b?.focus()},children:`Alt`}),(0,z.jsx)(G,{ref:l,variant:`ghost`,type:`button`,onClick:O,children:`Paste`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,onClick:()=>T(` `),children:`Tab`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,onClick:()=>{b?.sendText(`\x1B[Z`),p(!1),h(!1)},children:`Shift+Tab`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,onClick:()=>T(`\r`),children:`Enter`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,"aria-label":`Arrow left`,onClick:()=>E(`left`),children:`←`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,"aria-label":`Arrow up`,onClick:()=>E(`up`),children:`↑`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,"aria-label":`Arrow down`,onClick:()=>E(`down`),children:`↓`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,"aria-label":`Arrow right`,onClick:()=>E(`right`),children:`→`})]})]})}function oW({projects:e,selectedWorktree:t,selectedTerminal:n}){let r=Ye(),{closeMobileWithoutFocusRestore:i}=Jz(),a=Ca(),o=yz(),s=(0,R.useRef)(new Set),c=(0,R.useRef)(0),l=(0,R.useRef)(null),u=(0,R.useRef)(a.pathname),[d,f]=(0,R.useState)([]),[p,m]=(0,R.useState)(null);u.current=a.pathname;let h=d.find(e=>e.id===p&&e.worktreeId===t?.id),g=n?.id??null,_=pt({mutationFn:({worktreeId:e,name:t,argv:n,cwd:r,env:i,returnToShell:a,closeOnSuccess:o,initialSize:s})=>Tf(CE.api.worktrees[`:worktreeId`].terminals.$post({param:{worktreeId:e},json:{name:t,...n?{argv:n}:{},...r?{cwd:r}:{},...i?{env:i}:{},...a?{returnToShell:!0}:{},...o?{closeOnSuccess:!0}:{},...s?{initialSize:s}:{}}})).then(e=>e.terminal),onSuccess:async(t,{pendingTerminal:n})=>{let i=l.current===n.id,a=i&&u.current===n.originPath;f(e=>e.filter(e=>e.id!==n.id)),i&&(l.current=null,m(null));let s=e.find(e=>e.id===n.projectId),c=s?.worktrees.find(e=>e.id===n.worktreeId);if(!s||!c){await r.invalidateQueries({queryKey:fz});return}let d=n.originPath===oF(s.id,c.id).pathname;r.setQueryData(fz,e=>e?.map(e=>({...e,worktrees:e.worktrees.map(e=>e.id===c.id?{...e,terminals:[...e.terminals.filter(e=>e.id!==t.id),t]}:e)}))),a&&await o(sF(s.id,c.id,t.id),d),await r.invalidateQueries({queryKey:fz})},onError:async(e,{pendingTerminal:t})=>{f(e=>e.filter(e=>e.id!==t.id)),l.current===t.id&&(l.current=null,m(null)),xF(e,{operation:`create terminal “${t.name}”`}),await r.invalidateQueries({queryKey:fz})}}),v=pt({mutationFn:({terminal:e})=>Tf(CE.api.terminals[`:terminalId`].$delete({param:{terminalId:e.id}})),onSuccess:async()=>{await r.invalidateQueries({queryKey:fz})},onError:(e,t)=>{r.setQueryData(fz,e=>e?.map(e=>({...e,worktrees:e.worktrees.map(e=>{if(e.id!==t.terminal.worktreeId||e.terminals.some(e=>e.id===t.terminal.id))return e;let n=[...e.terminals];return n.splice(t.index,0,t.terminal),{...e,terminals:n}})}))),xF(e,{operation:`close terminal “${t.terminal.name}”`})},onSettled:(e,t,n)=>{s.current.delete(n.terminal.id)}});return{pendingTerminals:d,selectedPendingTerminal:h,createTerminalInWorktree:(t,r,o)=>{let s=e.find(e=>e.id===t.id),u=s?.worktrees.find(e=>e.id===r.id);if(!s||!u||s.availability.state===`unavailable`||u.prunable)return;let d=n?.worktreeId===u.id?VP.getInitialSize(n.id):null,p={id:`pending-terminal-${++c.current}`,projectId:s.id,worktreeId:u.id,name:o.name,originPath:a.pathname};l.current=p.id,f(e=>[...e,p]),m(p.id),i(),_.mutate({worktreeId:u.id,name:o.name,...o.argv?{argv:[...o.argv]}:{},...o.cwd?{cwd:o.cwd}:{},...o.env?{env:{...o.env}}:{},...o.returnToShell?{returnToShell:!0}:{},...o.closeOnSuccess?{closeOnSuccess:!0}:{},...d?{initialSize:d}:{},pendingTerminal:p})},requestCloseTerminal:(t,n)=>{let i=e.find(e=>e.worktrees.some(e=>e.id===t.worktreeId)),a=i?.worktrees.find(e=>e.id===t.worktreeId),c=a?.terminals.filter(e=>e.id!==t.id&&!s.current.has(e.id));if(!i||!a||s.current.has(t.id)||!c?.length)return;let l=n?.title??VP.getTitleSnapshot().get(t.id)??t.name;if((n?.hasForegroundProcess??VP.getForegroundProcessSnapshot().has(t.id))&&!window.confirm(`Close terminal “${l}”? Its foreground process will be terminated.`))return;let u=a.terminals.findIndex(e=>e.id===t.id);if(s.current.add(t.id),r.cancelQueries({queryKey:fz}),g===t.id){let e=a.terminals.slice(u+1).find(e=>!s.current.has(e.id))??a.terminals.slice(0,u).reverse().find(e=>!s.current.has(e.id));e&&o(sF(i.id,a.id,e.id),!0)}VP.forget(t.id),r.setQueryData(fz,e=>e?.map(e=>({...e,worktrees:e.worktrees.map(e=>e.id===a.id?{...e,terminals:e.terminals.filter(e=>e.id!==t.id)}:e)}))),v.mutate({terminal:t,index:u})},clearPendingTerminalSelection:()=>{l.current=null,m(null)},selectPendingTerminal:e=>{d.some(t=>t.id===e)&&(l.current=e,m(e),i())}}}function sW({selectedWorktree:e,selectedTerminal:t,selectedPendingTerminal:n,pendingTerminals:r,loading:i,dialogOpen:a}){let o=Ye(),{isMobile:s,openMobile:c}=Jz(),{open:l}=DB();return(0,z.jsx)(aW,{worktree:e,terminal:n?null:t,pendingTerminals:r.filter(t=>t.worktreeId===e?.id),selectedPendingTerminalId:n?.id??null,loading:i,autoFocusBlocked:a||l||s&&c,onStatusChange:()=>void o.invalidateQueries({queryKey:fz})})}var cW=`treeport-initial-terminal-preset`;function lW({project:e,presets:t,presetDiagnostics:n,presetsLoading:r,presetsError:i,onRetryPresets:a,busy:o,onSubmit:s}){let[c,l]=(0,R.useState)(``),[u,d]=(0,R.useState)(`default`),[f,p]=(0,R.useState)(()=>localStorage.getItem(cW)??`shell`),m=t.filter(e=>!e.closeOnSuccess),h=m.some(e=>e.id===f),g=f!==`shell`&&!h,_=g&&r,v=g&&!r&&!i,y=g&&!r?`shell`:f,b=u==="default"?`default`:`current`;return(0,z.jsxs)(`form`,{className:`flex flex-col gap-5`,autoComplete:`off`,onSubmit:e=>{e.preventDefault();let t=c.trim();if(o||!t)return;let n=m.find(e=>e.id===y);v&&localStorage.setItem(cW,`shell`),s(t,b,n?{name:n.name,argv:[n.executable,...n.args],returnToShell:!0}:{name:`Shell`},b===`current`?u:void 0)},children:[(0,z.jsxs)(sz,{children:[(0,z.jsx)(lz,{htmlFor:`worktree-name`,children:`Name`}),(0,z.jsx)(cz,{id:`worktree-name`,name:`worktree-name`,value:c,onChange:e=>l(e.target.value),placeholder:`feature-name`,"aria-label":`Worktree name`,autoCapitalize:`none`,spellCheck:!1,required:!0,autoFocus:!0,disabled:o})]}),(0,z.jsxs)(sz,{children:[(0,z.jsx)(lz,{htmlFor:`worktree-base`,children:`Start from`}),(0,z.jsxs)(NB,{id:`worktree-base`,name:`worktree-base`,value:u,onChange:e=>d(e.target.value),disabled:o,children:[(0,z.jsxs)(`option`,{value:`default`,children:[e.defaultBranch,` · latest from origin`]}),e.worktrees.map(e=>(0,z.jsxs)(`option`,{value:e.id,children:[e.name,` · current commit`]},e.id))]})]}),(0,z.jsxs)(sz,{children:[(0,z.jsx)(lz,{htmlFor:`initial-terminal-preset`,children:`Initial terminal`}),(0,z.jsxs)(NB,{id:`initial-terminal-preset`,name:`initial-terminal-preset`,value:y,onChange:e=>{p(e.target.value),localStorage.setItem(cW,e.target.value)},disabled:o,children:[_&&(0,z.jsx)(`option`,{value:f,children:`Loading saved preset…`}),(0,z.jsx)(`option`,{value:`shell`,children:`Shell`}),m.map(e=>(0,z.jsxs)(`option`,{value:e.id,children:[e.name,` — `,nW(e),` —`,` `,PU([e.executable,...e.args])]},e.id))]}),v&&(0,z.jsx)(`p`,{className:`form-note`,role:`status`,children:`The selected preset cannot be used as an initial terminal. Initial terminal changed to Shell.`}),r&&(0,z.jsx)(`p`,{className:`form-note`,role:`status`,children:`Loading terminal presets…`}),i&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`p`,{className:`form-note`,children:`Presets could not be loaded. Shell is still available.`}),(0,z.jsx)(G,{type:`button`,variant:`secondary`,size:`sm`,onClick:a,children:`Retry`})]}),n.map(e=>(0,z.jsx)(`p`,{className:`form-note`,role:`status`,children:e.message},`${e.path}:${e.itemId??`file`}:${e.message}`))]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 pt-1`,children:[(0,z.jsx)(`p`,{className:`hidden text-xs text-zinc-600 sm:block`,children:`Press Enter to create`}),(0,z.jsx)(G,{type:`submit`,className:`ml-auto`,disabled:o||_||!c.trim(),children:o?`Creating…`:`Create worktree`})]})]})}function uW({project:e,onOpenChange:t,restoreFocusTo:n,presets:r,presetDiagnostics:i,presetsLoading:a,presetsError:o,onRetryPresets:s,onSubmit:c}){let l=(0,R.useRef)(!1);return(0,z.jsx)(vR,{open:e!==null,onOpenChange:t,children:e?(0,z.jsxs)(CR,{className:`max-w-md`,mobilePresentation:`dialog`,restoreFocusTo:n,onCloseAutoFocus:e=>{l.current&&(l.current=!1,e.preventDefault())},children:[(0,z.jsxs)(wR,{children:[(0,z.jsx)(`p`,{className:`eyebrow`,children:e.name}),(0,z.jsx)(TR,{children:`Create worktree`}),(0,z.jsx)(ER,{className:`sr-only`,children:`Create a linked worktree and choose its starting point and initial terminal.`})]}),(0,z.jsx)(lW,{project:e,presets:r,presetDiagnostics:i,presetsLoading:a,presetsError:o,onRetryPresets:s,busy:!1,onSubmit:(t,n,r,i)=>{l.current=!0,c(e,t,n,r,i)}})]}):null})}function dW({worktree:e,preview:t,busy:n,onOpenChange:r,restoreFocusTo:i,onConfirm:a}){let o=!!t?.warnings.length,s=t?.name??e?.name,c=t?.branch??e?.branch,l=t?.detached??e?.detached,u=t?.head??e?.head,d=t?.path??e?.path;return(0,z.jsx)(oR,{open:e!==null,onOpenChange:r,children:e&&t?(0,z.jsxs)(lR,{restoreFocusTo:i,children:[(0,z.jsxs)(uR,{children:[(0,z.jsx)(`p`,{className:`eyebrow`,children:o?`Destructive removal`:`Worktree`}),(0,z.jsx)(fR,{children:`Remove worktree`}),(0,z.jsx)(pR,{children:`Review what will be removed before continuing.`})]}),(0,z.jsxs)(`dl`,{className:`facts`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Name`}),(0,z.jsx)(`dd`,{children:s})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Git state`}),(0,z.jsx)(`dd`,{children:!l&&c?`Branch ${c} (preserved)`:`Detached at ${u?.slice(0,8)}`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Path`}),(0,z.jsx)(`dd`,{children:d})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Uncommitted`}),(0,z.jsx)(`dd`,{children:`${t.dirty.total} (${t.dirty.staged} staged, ${t.dirty.unstaged} unstaged, ${t.dirty.untracked} untracked, ${t.dirty.conflicts} conflicted)`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Terminals stopped`}),(0,z.jsx)(`dd`,{children:t.terminals.map(e=>e.name).join(`, `)||`none`})]})]}),t.reasons.length>0?(0,z.jsxs)(`div`,{className:`warning`,children:[(0,z.jsx)(`strong`,{children:`Removal refused`}),(0,z.jsx)(`ul`,{role:`list`,children:t.reasons.map(e=>(0,z.jsx)(`li`,{children:e},e))})]}):null,t.warnings.length>0?(0,z.jsxs)(`div`,{className:`warning danger`,children:[(0,z.jsx)(`strong`,{children:`Local work may be lost.`}),(0,z.jsx)(`ul`,{role:`list`,children:t.warnings.map(e=>(0,z.jsx)(`li`,{children:e},e))})]}):null,(0,z.jsxs)(dR,{children:[(0,z.jsx)(hR,{children:`Cancel`}),(0,z.jsx)(mR,{asChild:!0,children:(0,z.jsx)(G,{type:`button`,variant:`destructive`,disabled:n||!t.eligible,onClick:n=>{n.preventDefault(),a(e,t)},children:n?`Removing…`:o?`Remove anyway`:`Remove worktree`})})]})]}):null})}function fW({projects:e,setDrawerOpen:t,onWorktreeSubmitted:n,onRemovalNeedsConfirmation:r,onRemovalCompleted:i,selectedTerminalId:a}){let o=Ye(),s=Ca(),c=yz(),l=dt({queryKey:[`worktree-creations`],queryFn:async()=>(await Tf(CE.api.operations.$get({query:{kind:`create`}}))).operations,refetchInterval:2e3,refetchOnReconnect:!0,refetchOnWindowFocus:!0}),u=dt({queryKey:[`worktree-removals`],queryFn:async()=>(await Tf(CE.api.operations.$get({query:{kind:`remove`}}))).operations,refetchInterval:2e3,refetchOnReconnect:!0,refetchOnWindowFocus:!0}),[d,f]=(0,R.useState)([]),p=(l.data??[]).flatMap(e=>{if(e.kind!==`create`)return[];let t=e.request.name;return e.projectId&&typeof t==`string`?[{id:e.id,projectId:e.projectId,typedName:t}]:[]}),m=(0,R.useRef)(new Set),h=(0,R.useRef)(new Set),g=lt({queries:d.map(e=>({queryKey:[`operation`,e.id],queryFn:async()=>(await Tf(CE.api.operations[`:operationId`].$get({param:{operationId:e.id}}))).operation,refetchInterval:500}))}),_=new Set(g.flatMap(t=>{let n=t.data;if(n?.status!==`completed`||n.kind!==`create`)return[];let r=n.result?.worktreeId,i=typeof r==`string`?r:n.worktreeId;return i&&e.some(e=>e.worktrees.some(e=>e.id===i))?[n.id]:[]})),v=p.filter(e=>!_.has(e.id)),y=new Set(v.map(e=>e.id)),b=[...v,...d.filter(e=>!y.has(e.id)&&!_.has(e.id)).map(({id:e,projectId:t,typedName:n})=>({id:e,projectId:t,typedName:n}))],[x,S]=(0,R.useState)({}),C=(u.data??[]).reduce((e,t)=>(t.kind===`remove`&&t.request.preview&&(e[t.request.preview.worktreeId]=`removing`),e),{...x}),w=(0,R.useRef)(new Set),T=pt({mutationFn:e=>Tf(CE.api.projects[`:projectId`][`worktree-operations`].$post({param:{projectId:e.projectId},json:{name:e.typedName,base:e.base,initialTerminal:e.initialTerminal,...e.sourceWorktreeId?{sourceWorktreeId:e.sourceWorktreeId}:{}}})).then(e=>e.operation),onSuccess:(e,t)=>{let n=e.kind===`create`?e.request.name:t.typedName;f(r=>[...r,{id:e.id,projectId:t.projectId,typedName:n,replacesEmptyProject:s.pathname===aF(t.projectId).pathname}]),o.invalidateQueries({queryKey:[`worktree-creations`]})},onError:(e,n)=>{t(!1),xF(e,{operation:`create worktree “${n.typedName}”`})}});(0,R.useEffect)(()=>{for(let e of b)d.some(t=>t.id===e.id)&&!h.current.has(e.id)&&(h.current.add(e.id),window.requestAnimationFrame(()=>{document.getElementById(`pending-worktree-${e.id}`)?.focus()}))},[d,b]),(0,R.useEffect)(()=>{g.forEach((e,n)=>{let r=e.data,i=d[n];!r||r.kind!==`create`||!i||r.status!==`completed`&&r.status!==`failed`||m.current.has(r.id)||(m.current.add(r.id),(async()=>{if(await o.invalidateQueries({queryKey:[`worktree-creations`]}),r.status===`failed`)xF(r.error??`Worktree creation failed`,{operation:`create worktree “${i.typedName}”`});else{await o.invalidateQueries({queryKey:fz});let e=(await Tf(CE.api.projects.$get())).projects;o.setQueryData(fz,e);let n=r.result,a=typeof n?.worktreeId==`string`?n.worktreeId:r.worktreeId,s=typeof n?.terminalId==`string`?n.terminalId:null,l=e.find(e=>e.id===i.projectId)?.worktrees.find(e=>e.id===a);if(l){let e=s?sF(i.projectId,l.id,s):oF(i.projectId,l.id);await c(e,i.replacesEmptyProject)}t(!1),typeof n?.setupError==`string`?xF(n.setupError,{operation:`start setup for newly created worktree “${i.typedName}”`}):typeof n?.terminalError==`string`&&xF(n.terminalError,{operation:`start a terminal for newly created worktree “${i.typedName}”`})}f(e=>e.filter(e=>e.id!==r.id))})())})},[c,g,d,o,t]);let E=(e,t,r,i,o)=>{let s=a?VP.getInitialSize(a):null,c={projectId:e.id,typedName:t,base:r,initialTerminal:{name:i.name,...i.argv?{argv:[...i.argv]}:{},...i.returnToShell?{returnToShell:!0}:{},...s?{initialSize:s}:{}},...o?{sourceWorktreeId:o}:{}};n(),T.mutate(c)},D=(e,t)=>S(n=>({...n,[e]:t})),O=e=>{w.current.delete(e),S(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})},k=async(e,t,n,a)=>{D(e.id,`removing`);try{await Tf(CE.api.worktrees[`:worktreeId`].remove.$post({param:{worktreeId:e.id},json:{confirmationToken:t.confirmationToken,confirmDestructive:n}})),await o.invalidateQueries({queryKey:[`worktree-removals`]}),O(e.id),i(e.id),o.invalidateQueries({queryKey:fz},{cancelRefetch:!1})}catch(t){if(kE(t).code===`REMOVE_PREVIEW_STALE`&&a>0){D(e.id,`checking`);try{let t=(await Tf(CE.api.worktrees[`:worktreeId`][`remove-preview`].$get({param:{worktreeId:e.id}}))).preview;if(t.eligible&&t.warnings.length===0){await k(e,t,!1,a-1);return}O(e.id),r(e,t);return}catch(t){O(e.id),xF(t,{operation:`refresh removal details for worktree “${e.name}”`});return}}O(e.id),xF(t,{operation:`remove worktree “${e.name}”`})}};return{pendingWorktrees:b,pendingRemovals:C,submitWorktreeCreation:E,prepareRemoval:async(e,t)=>{if(!(w.current.has(e.id)||C[e.id])){w.current.add(e.id),D(e.id,`checking`);try{let n=(await Tf(CE.api.worktrees[`:worktreeId`][`remove-preview`].$get({param:{worktreeId:e.id}}))).preview;if(n.eligible&&n.warnings.length===0){await k(e,n,!1,1);return}O(e.id),r(e,n,t)}catch(t){O(e.id),xF(t,{operation:`check whether worktree “${e.name}” can be removed`})}}},confirmRemoval:(e,t)=>{w.current.has(e.id)||(w.current.add(e.id),k(e,t,t.warnings.length>0,1))}}}function pW(e,t){let n=Ye(),r=(0,R.useRef)(t);r.current=t;let[i,a]=(0,R.useState)(!1);return(0,R.useEffect)(()=>{let e=xE(`/events`,{path:DN,transports:[`websocket`],autoConnect:!1,retries:0}),t=Pf(()=>n.invalidateQueries({queryKey:fz},{cancelRefetch:!1})),i=Pf(()=>Promise.all([n.invalidateQueries({queryKey:fz},{cancelRefetch:!1}),n.invalidateQueries({queryKey:pz},{cancelRefetch:!1}),n.invalidateQueries({queryKey:[`terminal-preset-definitions`]},{cancelRefetch:!1}),n.invalidateQueries({queryKey:[`web-panel-definitions`]},{cancelRefetch:!1})])),o=()=>{t.schedule(),Promise.all([n.invalidateQueries({queryKey:[`worktree-creations`]}),n.invalidateQueries({queryKey:[`worktree-removals`]})])},s=()=>i.schedule(),c=e=>{let t=lP(e);if(!t){a(!0);return}VP.replaceRuntimeMetadata(t.terminalMetadata),a(!1),o()},l=e=>{let t=uP(e);if(t){if(t.type===`terminal.metadata`){VP.applyRuntimeMetadata({terminalId:t.data.terminalId,title:t.data.title,program:t.data.program,hasForegroundProcess:t.data.hasForegroundProcess,progress:t.data.progress,progressStartedAt:t.data.progressStartedAt,progressClearedAt:t.data.progressClearedAt,bell:t.data.bell});return}if(t.type===`panel.open_requested`){o(),r.current?.(t.data);return}if(t.type===`project.updated`){s();return}if(t.type===`project.removed`){s();return}t.type!==`terminal.controller_changed`&&o()}},u=()=>a(!0);return e.on(`snapshot`,c),e.on(`product_event`,l),e.on(`disconnect`,u),e.on(`connect_error`,u),e.connect(),()=>{t.dispose(),i.dispose(),e.disconnect()}},[n]),(0,R.useEffect)(()=>{e&&VP.reconcile(e.flatMap(e=>e.worktrees.flatMap(e=>e.terminals)))},[e]),i}function mW(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(OB,{children:(0,z.jsx)(hW,{})}),(0,z.jsx)(qh,{})]})}function hW(){let e=window.treeportDesktop,t=yz(),n=Ye(),r=Ca(),i=dt(hz),a=i.data??[],o=dt(_z),s=o.data??[],c=localStorage.getItem(tF),l=i.data?bF(a,r.pathname,c):null,u=l?.selection.project??null,d=l?.selection.worktree??null,f=l?.selection.terminal??null,p=f?.id??null,m=l?.selection.panel??null,h=m?.id??null,g=u,{isMobile:_,openMobile:v,setOpenMobile:y,closeMobileWithoutFocusRestore:b}=Jz(),x=DB(),S=x.open,[C,w]=(0,R.useState)(null),[T,E]=(0,R.useState)(!1),[D,O]=(0,R.useState)(!1),[k,ee]=(0,R.useState)(()=>new Set),[te,A]=(0,R.useState)({}),[j,M]=(0,R.useState)({}),ne=(0,R.useCallback)((e,t)=>{M(n=>{if(t===null){if(n[e]===void 0)return n;let t={...n};return delete t[e],t}return n[e]===t?n:{...n,[e]:t}})},[]);(0,R.useEffect)(()=>{let e=new Set(a.flatMap(e=>e.worktrees.flatMap(e=>e.panels.filter(e=>e.kind===`web`).map(e=>e.id))));M(t=>{let n=Object.keys(t).filter(t=>!e.has(t));if(n.length===0)return t;let r={...t};return n.forEach(e=>delete r[e]),r})},[a]);let N=C?.type===`panel`?a.find(e=>e.id===C.projectId)??null:null,P=C?.type===`panel`&&C.worktreeId?N?.worktrees.find(e=>e.id===C.worktreeId)??null:null,re=dt(vz(C?.type===`worktree`?{projectId:C.project.id}:P?{worktreeId:P.id}:d?{worktreeId:d.id}:u?{projectId:u.id}:void 0)),ie=re.data?.definitions??[],ae=re.data?.diagnostics??[],F=dt({queryKey:[`web-panel-definitions`,P?.id],queryFn:async()=>(await Tf(CE.api.worktrees[`:worktreeId`][`web-panel-definitions`].$get({param:{worktreeId:P.id}}))).definitions,enabled:!!P}),I=pt({mutationFn:({worktree:e,definition:t,input:n})=>Tf(CE.api.worktrees[`:worktreeId`].panels.$post({param:{worktreeId:e.id},json:{definitionId:t.id,input:n,launchCwd:null}})).then(e=>e.panel),onSuccess:async e=>{w(null),await n.invalidateQueries({queryKey:hz.queryKey});let r=fF(n.getQueryData(hz.queryKey)??a,e);r&&await t(r)},onError:(e,{worktree:t,definition:n})=>{xF(e,{operation:`create web panel “${n.title}” in worktree “${t.name}”`})}}),L=pt({mutationFn:({panel:e,discardStoredData:t=!1})=>Tf(CE.api.panels[`:panelId`].$delete({param:{panelId:e.id},query:{...t?{discardStoredData:`true`}:{}}})),onSuccess:async(e,{panel:r})=>{if(ne(r.id,null),w(e=>e?.type===`close-web-panel`&&e.panel.id===r.id?null:e),m?.id===r.id){let e=a.flatMap(e=>e.worktrees).find(e=>e.id===r.worktreeId),n=e?mF(a,e):null;n&&await t(n,!0)}await n.invalidateQueries({queryKey:hz.queryKey})},onError:(e,{panel:t})=>{xF(e,{operation:`close web panel “${t.title}”`})}}),oe=(e,t)=>{Tf(CE.api.panels[`:panelId`].storage.$get({param:{panelId:e.id}})).then(({hasData:n})=>{n?fe({type:`close-web-panel`,panel:e},t):L.mutate({panel:e})},t=>{xF(t,{operation:`check stored data for web panel “${e.title}”`})})},se=(0,R.useCallback)(e=>{A(t=>({...t,[e.panelId]:(t[e.panelId]??0)+1})),rF(e.sourceTerminalId,p)&&n.invalidateQueries({queryKey:hz.queryKey}).then(async()=>{let r=n.getQueryData(hz.queryKey)??[],i=r.flatMap(e=>e.worktrees).find(t=>t.id===e.worktreeId)?.panels.find(t=>t.kind===`web`&&t.id===e.panelId),a=i?fF(r,i):null;a&&await t(a)}).catch(e=>{xF(e,{operation:`open web panel`})})},[t,n,p]),ce=pW(i.data,se),[le,ue]=(0,R.useState)(!1),de=(0,R.useRef)(null),fe=(e,t)=>{de.current=t??document.activeElement,w(e)};(0,R.useEffect)(()=>{h&&ee(e=>{if(e.has(h))return e;let t=new Set(e);return t.add(h),t})},[h]),(0,R.useEffect)(()=>{!l||l.canonical||t(l.target,!0)},[t,l?.canonical,l?.target.pathname]),(0,R.useEffect)(()=>{l?.canonical&&(l.target.kind===`root`?localStorage.removeItem(tF):localStorage.setItem(tF,l.target.pathname),l.target.kind===`terminal`&&localStorage.setItem(`${nF}${l.target.projectId}`,l.target.terminalId))},[l?.canonical,l?.target.pathname]),(0,R.useEffect)(()=>{if(!(i.data!==void 0&&(ce||i.isRefetchError))){ue(!1);return}let e=window.setTimeout(()=>ue(!0),jf);return()=>window.clearTimeout(e)},[ce,i.data,i.isRefetchError]);let pe=(0,R.useMemo)(()=>g?.worktrees.flatMap(e=>e.terminals)??[],[g]),me=(0,R.useMemo)(()=>a.flatMap(e=>e.worktrees).flatMap(e=>e.panels).filter(e=>e.kind===`web`&&(k.has(e.id)||e.id===h)),[a,k,h]),he=(0,R.useCallback)(e=>{let n=pF(a,e);n&&t(n),b()},[b,t,a]),ge=e=>{let n=mF(a,e,p);n&&t(n),b()},_e=e=>uF(e,localStorage.getItem(`${nF}${e.id}`)),ve=e=>{let n=_e(e);x.dismissedIntoTerminalRef.current=!_&&n.kind===`terminal`,t(n,!1,!_),x.setOpen(!1),b()},{closingProjectId:ye,requestProjectClose:be,projectOpened:xe}=bz({projects:a,selectedProject:u,targetForProject:_e,projectSwitcherTriggerRef:x.triggerRef,closeProjectUi:()=>x.setOpen(!1),openedProjectUi:()=>{x.setOpen(!1),b(),w(null)}}),Se=e=>{let t=_e(e);return x.dismissedIntoTerminalRef.current=!_&&t.kind===`terminal`,xe(e,!_)},{pendingWorktrees:Ce,pendingRemovals:we,submitWorktreeCreation:Te,prepareRemoval:Ee,confirmRemoval:De}=fW({projects:a,setDrawerOpen:e=>{e?y(!0):b()},onWorktreeSubmitted:()=>w(null),onRemovalNeedsConfirmation:(e,t,n)=>fe({type:`remove`,worktree:e,preview:t},n),onRemovalCompleted:e=>w(t=>t?.type===`remove`&&t.worktree.id===e?null:t),selectedTerminalId:p}),Oe=oW({projects:a,selectedWorktree:d,selectedTerminal:f}),ke=(0,R.useCallback)(e=>{E(!1),O(!1),Oe.clearPendingTerminalSelection(),he(e)},[he,Oe.clearPendingTerminalSelection]),Ae=(0,R.useCallback)(e=>{Oe.clearPendingTerminalSelection();let n=fF(a,e);n&&t(n),b()},[b,t,a,Oe.clearPendingTerminalSelection]),je=(0,R.useCallback)(e=>{if(C||S||_&&v||!d)return!1;let t=d.terminals[e];if(t)return ke(t),!0;let n=d.panels.filter(e=>e.kind===`web`),r=n[e-d.terminals.length];if(r)return Ae(r),!0;let i=Oe.pendingTerminals.filter(e=>e.worktreeId===d.id)[e-d.terminals.length-n.length];return i?(Oe.selectPendingTerminal(i.id),!0):!1},[C,v,_,S,d,ke,Ae,Oe.pendingTerminals,Oe.selectPendingTerminal]);(0,R.useEffect)(()=>{let e=e=>{if(!e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return;let t=Number(e.key)-1;!Number.isInteger(t)||t<0||t>8||je(t)&&(e.preventDefault(),e.stopPropagation())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[je]);let Me=!N||!P||N.availability.state===`unavailable`||!!P.prunable||!!we[P.id];return(0,R.useEffect)(()=>{if(e)return e.onCommand(e=>{if(!(C||S||_&&v)){if(e===`new-worktree`){g&&g.availability.state!==`unavailable`&&fe({type:`worktree`,project:g});return}!u||!d||(e===`new-terminal`?Oe.createTerminalInWorktree(u,d,{name:`Shell`}):e===`new-panel`?fe({type:`panel`,projectId:u.id,worktreeId:d.id}):e===`close-panel`&&(m?oe(m):!Oe.selectedPendingTerminal&&f&&Oe.requestCloseTerminal(f)))}})},[g,C,v,_,S,u,f,m,d,Oe.selectedPendingTerminal]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(TF,{projects:a,selectedTerminalId:p}),(0,z.jsx)(jB,{blocked:C!==null}),(0,z.jsx)(FB,{selectedTerminalId:Oe.selectedPendingTerminal||m?null:p,terminals:pe,onSelectTerminal:ke,notificationCenter:(0,z.jsx)(CF,{projects:a,navigateToWorkspace:t,open:D,onOpenChange:O})}),(0,z.jsx)(PB,{notificationCenter:(0,z.jsx)(CF,{projects:a,navigateToWorkspace:t,open:T,onOpenChange:E}),projectSwitcher:(0,z.jsx)(MB,{projects:a,activeProject:g,closingProjectId:ye,onSelectProject:ve,onProjectOpened:Se,onRequestProjectClose:be,onOpenProjectDialog:e=>fe({type:`project`},e)}),children:(0,z.jsx)(MU,{projects:a,projectsPending:i.isPending,projectsError:i.isError,projectsLoaded:i.data!==void 0,activeProject:g,selectedWorktree:d,selectedTerminalId:Oe.selectedPendingTerminal||m?null:p,selectedWebPanelId:Oe.selectedPendingTerminal?null:m?.id??null,webPanelRuntimeTitles:j,selectedPendingTerminalId:Oe.selectedPendingTerminal?.id??null,pendingTerminals:Oe.pendingTerminals,pendingWorktrees:Ce,pendingRemovals:we,onRetryProjects:()=>void i.refetch(),onSelectTerminal:ke,onSelectPendingTerminal:Oe.selectPendingTerminal,onCloseTerminal:Oe.requestCloseTerminal,onSelectWebPanel:Ae,onCloseWebPanel:oe,onSelectWorktree:ge,onPrepareRemoval:Ee,onOpenPanelDialog:(e,t,n)=>fe({type:`panel`,projectId:e.id,worktreeId:t?.id??null},n),onOpenWorktreeDialog:(e,t)=>fe({type:`worktree`,project:e},t)})}),(0,z.jsxs)(kB,{children:[me.map(e=>(0,z.jsx)(_R,{panel:e,active:e.id===h&&!Oe.selectedPendingTerminal,title:j[e.id]??e.title,reloadRevision:te[e.id]??0,autoFocusBlocked:C!==null||S||_&&v,onTitleChange:ne,onSelectWorkspace:je},e.id)),(!m||Oe.selectedPendingTerminal)&&(0,z.jsx)(sW,{selectedWorktree:d,selectedTerminal:f,selectedPendingTerminal:Oe.selectedPendingTerminal,pendingTerminals:Oe.pendingTerminals,loading:i.isPending,dialogOpen:C!==null})]}),le?(0,z.jsx)(`div`,{className:`fixed right-4 bottom-4 z-70 flex max-w-[min(30rem,calc(100vw-2rem))] items-center gap-3 rounded-lg bg-zinc-800 p-3 text-sm text-zinc-300 shadow-2xl ring-1 ring-white/10`,role:`status`,inert:_&&v?!0:void 0,"aria-hidden":_&&v?!0:void 0,children:(0,z.jsx)(`span`,{children:`Updates paused; showing the last known project state.`})}):null,(0,z.jsx)(dz,{open:C?.type===`project`,onOpenChange:e=>!e&&w(null),restoreFocusTo:de.current,onOpened:xe}),(0,z.jsx)(uW,{project:C?.type===`worktree`?C.project:null,onOpenChange:e=>!e&&w(null),restoreFocusTo:de.current,presets:ie,presetDiagnostics:ae,presetsLoading:re.isPending,presetsError:re.isError,onRetryPresets:()=>void re.refetch(),onSubmit:Te}),(0,z.jsx)(rW,{open:C?.type===`panel`,onOpenChange:e=>!e&&w(null),restoreFocusTo:de.current,worktreeName:P?.name??null,presets:ie,presetDiagnostics:ae,presetsLoading:re.isPending,presetsError:re.isError,webPanelDefinitions:F.data??[],webPanelDefinitionsLoading:!!P&&F.isPending,webPanelDefinitionsError:F.isError,launchDisabled:Me||I.isPending,onCreateTerminal:e=>{!N||!P||(w(null),Oe.createTerminalInWorktree(N,P,e))},onCreateWebPanel:e=>{P&&I.mutate({worktree:P,definition:e,input:null})},onManagePresets:()=>w({type:`presets`})}),(0,z.jsx)(tW,{open:C?.type===`presets`,onOpenChange:e=>!e&&w(null),restoreFocusTo:de.current,presets:s,loading:o.isPending,loadError:o.isError,onRetry:()=>void o.refetch()}),(0,z.jsx)(gR,{panel:C?.type===`close-web-panel`?C.panel:null,busy:L.isPending,onOpenChange:e=>!e&&w(null),restoreFocusTo:de.current,onConfirm:e=>L.mutate({panel:e,discardStoredData:!0})}),(0,z.jsx)(dW,{worktree:C?.type===`remove`?C.worktree:null,preview:C?.type===`remove`?C.preview:null,busy:C?.type===`remove`&&we[C.worktree.id]!==void 0,onOpenChange:e=>!e&&w(null),restoreFocusTo:de.current,onConfirm:De})]})}function gW({reset:e}){return(0,z.jsx)(`main`,{className:`grid min-h-dvh place-items-center bg-zinc-950 p-6 text-zinc-100`,"aria-labelledby":`app-error-title`,children:(0,z.jsxs)(`section`,{className:`w-full max-w-lg rounded-xl bg-zinc-900 p-6 shadow-2xl ring-1 ring-white/10`,role:`alert`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-rose-300`,children:`Unexpected error`}),(0,z.jsx)(`h1`,{id:`app-error-title`,className:`mt-2 text-xl font-semibold`,children:`Treeport couldn’t display this workspace`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm text-zinc-400`,children:`Try recovering the interface. If the problem continues, reload Treeport; your persistent terminal sessions will keep running.`}),(0,z.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-3`,children:[(0,z.jsx)(G,{type:`button`,onClick:e,children:`Try again`}),(0,z.jsx)(G,{type:`button`,variant:`secondary`,onClick:()=>window.location.reload(),children:`Reload Treeport`})]})]})})}var _W=ra({component:mW,errorComponent:gW,onCatch:e=>console.error(`Unexpected application crash`,e)}),vW=ta({getParentRoute:()=>_W,path:`/`}),yW=ta({getParentRoute:()=>_W,path:`projects/$projectId`}),bW=ta({getParentRoute:()=>yW,path:`worktrees/$worktreeId`}),xW=ta({getParentRoute:()=>bW,path:`terminals/$terminalId`}),SW=ta({getParentRoute:()=>bW,path:`panels/$panelId`}),CW=ya({routeTree:_W.addChildren([vW,yW.addChildren([bW.addChildren([xW,SW])])]),defaultPreload:!1,scrollRestoration:!1}),wW=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,TW=document.querySelector(`meta[name="viewport"]`);wW&&TW&&!TW.content.includes(`maximum-scale`)&&(TW.content=`${TW.content}, maximum-scale=1`);var EW=new Ge({defaultOptions:{queries:{retry:Mf,retryDelay:Nf,refetchOnReconnect:!0},mutations:{retry:!1}}});(0,wa.createRoot)(document.getElementById(`root`)).render((0,z.jsx)(R.StrictMode,{children:(0,z.jsx)(Xe,{client:EW,children:(0,z.jsx)(ef,{children:(0,z.jsxs)(sf,{children:[(0,z.jsx)(Sa,{router:CW}),(0,z.jsx)(to,{})]})})})}));
|
|
146
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function ZA(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:ej(t,`input`,e.processors),output:ej(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function QA(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return QA(r.element,n);if(r.type===`set`)return QA(r.valueType,n);if(r.type===`lazy`)return QA(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return QA(r.innerType,n);if(r.type===`intersection`)return QA(r.left,n)||QA(r.right,n);if(r.type===`record`||r.type===`map`)return QA(r.keyType,n)||QA(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:QA(r.in,n)||QA(r.out,n);if(r.type===`object`){for(let e in r.shape)if(QA(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(QA(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(QA(e,n))return!0;return!!(r.rest&&QA(r.rest,n))}return!1}var $A=(e,t={})=>n=>{let r=JA({...n,processors:t});return YA(e,r),XA(r,e),ZA(r,e)},ej=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=JA({...i??{},target:a,io:t,processors:n});return YA(e,o),XA(o,e),ZA(o,e)},tj={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},nj=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=tj[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},rj=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},ij=(e,t,n,r)=>{n.type=`boolean`},aj=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},oj=(e,t,n,r)=>{n.not={}},sj=(e,t,n,r)=>{let i=e._zod.def,a=DE(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},cj=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},lj=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},uj=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},dj=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=YA(a.element,t,{...r,path:[...r.path,`items`]})},fj=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=YA(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=YA(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},pj=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>YA(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},mj=(e,t,n,r)=>{let i=e._zod.def,a=YA(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=YA(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},hj=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=YA(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=YA(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=YA(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},gj=(e,t,n,r)=>{let i=e._zod.def,a=YA(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},_j=(e,t,n,r)=>{let i=e._zod.def;YA(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},vj=(e,t,n,r)=>{let i=e._zod.def;YA(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},yj=(e,t,n,r)=>{let i=e._zod.def;YA(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},bj=(e,t,n,r)=>{let i=e._zod.def;YA(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},xj=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;YA(o,t,r);let s=t.seen.get(e);s.ref=o},Sj=(e,t,n,r)=>{let i=e._zod.def;YA(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Cj=(e,t,n,r)=>{let i=e._zod.def;YA(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},wj=(e,t,n,r)=>{let i=e._zod.innerType;YA(i,t,r);let a=t.seen.get(e);a.ref=i},Tj=X(`ZodISODateTime`,(e,t)=>{zO.init(e,t),Zj.init(e,t)});function Ej(e){return pA(Tj,e)}var Dj=X(`ZodISODate`,(e,t)=>{BO.init(e,t),Zj.init(e,t)});function Oj(e){return mA(Dj,e)}var kj=X(`ZodISOTime`,(e,t)=>{VO.init(e,t),Zj.init(e,t)});function Aj(e){return hA(kj,e)}var jj=X(`ZodISODuration`,(e,t)=>{HO.init(e,t),Zj.init(e,t)});function Mj(e){return gA(jj,e)}var Nj=X(`ZodError`,(e,t)=>{uD.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>pD(e,t)},flatten:{value:t=>fD(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,OE,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,OE,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Pj=mD(Nj),Fj=hD(Nj),Ij=gD(Nj),Lj=vD(Nj),Rj=bD(Nj),zj=xD(Nj),Bj=SD(Nj),Vj=CD(Nj),Hj=wD(Nj),Uj=TD(Nj),Wj=ED(Nj),Gj=DD(Nj),Kj=new WeakMap;function qj(e,t,n){let r=Object.getPrototypeOf(e),i=Kj.get(r);if(i||(i=new Set,Kj.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Jj=X(`ZodType`,(e,t)=>(TO.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ej(e,`input`),output:ej(e,`output`)}}),e.toJSONSchema=$A(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Pj(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ij(e,t,n),e.parseAsync=async(t,n)=>Fj(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Lj(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Rj(e,t,n),e.decode=(t,n)=>zj(e,t,n),e.encodeAsync=async(t,n)=>Bj(e,t,n),e.decodeAsync=async(t,n)=>Vj(e,t,n),e.safeEncode=(t,n)=>Hj(e,t,n),e.safeDecode=(t,n)=>Uj(e,t,n),e.safeEncodeAsync=async(t,n)=>Wj(e,t,n),e.safeDecodeAsync=async(t,n)=>Gj(e,t,n),qj(e,`ZodType`,{check(...e){let t=this.def;return this.clone(IE(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return KE(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(mN(e,t))},superRefine(e,t){return this.check(hN(e,t))},overwrite(e){return this.check(RA(e))},optional(){return JM(this)},exactOptional(){return XM(this)},nullable(){return QM(this)},nullish(){return JM(QM(this))},nonoptional(e){return iN(this,e)},array(){return AM(this)},or(e){return PM([this,e])},and(e){return RM(this,e)},transform(e){return cN(this,KM(e))},default(e){return eN(this,e)},prefault(e){return nN(this,e)},catch(e){return oN(this,e)},pipe(e){return cN(this,e)},readonly(){return uN(this)},describe(e){let t=this.clone();return Uk.add(t,{description:e}),t},meta(...e){if(e.length===0)return Uk.get(this);let t=this.clone();return Uk.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Uk.get(e)?.description},configurable:!0}),e)),Yj=X(`_ZodString`,(e,t)=>{EO.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nj(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,qj(e,`_ZodString`,{regex(...e){return this.check(MA(...e))},includes(...e){return this.check(FA(...e))},startsWith(...e){return this.check(IA(...e))},endsWith(...e){return this.check(LA(...e))},min(...e){return this.check(AA(...e))},max(...e){return this.check(kA(...e))},length(...e){return this.check(jA(...e))},nonempty(...e){return this.check(AA(1,...e))},lowercase(e){return this.check(NA(e))},uppercase(e){return this.check(PA(e))},trim(){return this.check(BA())},normalize(...e){return this.check(zA(...e))},toLowerCase(){return this.check(VA())},toUpperCase(){return this.check(HA())},slugify(){return this.check(UA())}})}),Xj=X(`ZodString`,(e,t)=>{EO.init(e,t),Yj.init(e,t),e.email=t=>e.check(Gk(Qj,t)),e.url=t=>e.check(Zk(tM,t)),e.jwt=t=>e.check(fA(gM,t)),e.emoji=t=>e.check(Qk(nM,t)),e.guid=t=>e.check(Kk($j,t)),e.uuid=t=>e.check(qk(eM,t)),e.uuidv4=t=>e.check(Jk(eM,t)),e.uuidv6=t=>e.check(Yk(eM,t)),e.uuidv7=t=>e.check(Xk(eM,t)),e.nanoid=t=>e.check($k(rM,t)),e.guid=t=>e.check(Kk($j,t)),e.cuid=t=>e.check(eA(iM,t)),e.cuid2=t=>e.check(tA(aM,t)),e.ulid=t=>e.check(nA(oM,t)),e.base64=t=>e.check(lA(pM,t)),e.base64url=t=>e.check(uA(mM,t)),e.xid=t=>e.check(rA(sM,t)),e.ksuid=t=>e.check(iA(cM,t)),e.ipv4=t=>e.check(aA(lM,t)),e.ipv6=t=>e.check(oA(uM,t)),e.cidrv4=t=>e.check(sA(dM,t)),e.cidrv6=t=>e.check(cA(fM,t)),e.e164=t=>e.check(dA(hM,t)),e.datetime=t=>e.check(Ej(t)),e.date=t=>e.check(Oj(t)),e.time=t=>e.check(Aj(t)),e.duration=t=>e.check(Mj(t))});function Q(e){return Wk(Xj,e)}var Zj=X(`ZodStringFormat`,(e,t)=>{DO.init(e,t),Yj.init(e,t)}),Qj=X(`ZodEmail`,(e,t)=>{AO.init(e,t),Zj.init(e,t)}),$j=X(`ZodGUID`,(e,t)=>{OO.init(e,t),Zj.init(e,t)}),eM=X(`ZodUUID`,(e,t)=>{kO.init(e,t),Zj.init(e,t)}),tM=X(`ZodURL`,(e,t)=>{jO.init(e,t),Zj.init(e,t)}),nM=X(`ZodEmoji`,(e,t)=>{MO.init(e,t),Zj.init(e,t)}),rM=X(`ZodNanoID`,(e,t)=>{NO.init(e,t),Zj.init(e,t)}),iM=X(`ZodCUID`,(e,t)=>{PO.init(e,t),Zj.init(e,t)}),aM=X(`ZodCUID2`,(e,t)=>{FO.init(e,t),Zj.init(e,t)}),oM=X(`ZodULID`,(e,t)=>{IO.init(e,t),Zj.init(e,t)}),sM=X(`ZodXID`,(e,t)=>{LO.init(e,t),Zj.init(e,t)}),cM=X(`ZodKSUID`,(e,t)=>{RO.init(e,t),Zj.init(e,t)}),lM=X(`ZodIPv4`,(e,t)=>{UO.init(e,t),Zj.init(e,t)}),uM=X(`ZodIPv6`,(e,t)=>{WO.init(e,t),Zj.init(e,t)}),dM=X(`ZodCIDRv4`,(e,t)=>{GO.init(e,t),Zj.init(e,t)}),fM=X(`ZodCIDRv6`,(e,t)=>{KO.init(e,t),Zj.init(e,t)}),pM=X(`ZodBase64`,(e,t)=>{JO.init(e,t),Zj.init(e,t)}),mM=X(`ZodBase64URL`,(e,t)=>{XO.init(e,t),Zj.init(e,t)}),hM=X(`ZodE164`,(e,t)=>{ZO.init(e,t),Zj.init(e,t)}),gM=X(`ZodJWT`,(e,t)=>{$O.init(e,t),Zj.init(e,t)}),_M=X(`ZodNumber`,(e,t)=>{ek.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rj(e,t,n,r),qj(e,`ZodNumber`,{gt(e,t){return this.check(EA(e,t))},gte(e,t){return this.check(DA(e,t))},min(e,t){return this.check(DA(e,t))},lt(e,t){return this.check(wA(e,t))},lte(e,t){return this.check(TA(e,t))},max(e,t){return this.check(TA(e,t))},int(e){return this.check(bM(e))},safe(e){return this.check(bM(e))},positive(e){return this.check(EA(0,e))},nonnegative(e){return this.check(DA(0,e))},negative(e){return this.check(wA(0,e))},nonpositive(e){return this.check(TA(0,e))},multipleOf(e,t){return this.check(OA(e,t))},step(e,t){return this.check(OA(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function vM(e){return _A(_M,e)}var yM=X(`ZodNumberFormat`,(e,t)=>{tk.init(e,t),_M.init(e,t)});function bM(e){return yA(yM,e)}var xM=X(`ZodBoolean`,(e,t)=>{nk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ij(e,t,n,r)});function SM(e){return bA(xM,e)}var CM=X(`ZodNull`,(e,t)=>{rk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aj(e,t,n,r)});function wM(e){return xA(CM,e)}var TM=X(`ZodUnknown`,(e,t)=>{ik.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function EM(){return SA(TM)}var DM=X(`ZodNever`,(e,t)=>{ak.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oj(e,t,n,r)});function OM(e){return CA(DM,e)}var kM=X(`ZodArray`,(e,t)=>{sk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dj(e,t,n,r),e.element=t.element,qj(e,`ZodArray`,{min(e,t){return this.check(AA(e,t))},nonempty(e){return this.check(AA(1,e))},max(e,t){return this.check(kA(e,t))},length(e,t){return this.check(jA(e,t))},unwrap(){return this.element}})});function AM(e,t){return WA(kM,e,t)}var jM=X(`ZodObject`,(e,t)=>{fk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fj(e,t,n,r),PE(e,`shape`,()=>t.shape),qj(e,`ZodObject`,{keyof(){return HM(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:EM()})},loose(){return this.clone({...this._zod.def,catchall:EM()})},strict(){return this.clone({...this._zod.def,catchall:OM()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return ZE(this,e)},safeExtend(e){return QE(this,e)},merge(e){return $E(this,e)},pick(e){return YE(this,e)},omit(e){return XE(this,e)},partial(...e){return eD(qM,this,e[0])},required(...e){return tD(rN,this,e[0])}})});function MM(e,t){return new jM({type:`object`,shape:e??{},...Z(t)})}function $(e,t){return new jM({type:`object`,shape:e,catchall:OM(),...Z(t)})}var NM=X(`ZodUnion`,(e,t)=>{mk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pj(e,t,n,r),e.options=t.options});function PM(e,t){return new NM({type:`union`,options:e,...Z(t)})}var FM=X(`ZodDiscriminatedUnion`,(e,t)=>{NM.init(e,t),hk.init(e,t)});function IM(e,t,n){return new FM({type:`union`,options:t,discriminator:e,...Z(n)})}var LM=X(`ZodIntersection`,(e,t)=>{gk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mj(e,t,n,r)});function RM(e,t){return new LM({type:`intersection`,left:e,right:t})}var zM=X(`ZodRecord`,(e,t)=>{yk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hj(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function BM(e,t,n){return!t||!t._zod?new zM({type:`record`,keyType:Q(),valueType:e,...Z(t)}):new zM({type:`record`,keyType:e,valueType:t,...Z(n)})}var VM=X(`ZodEnum`,(e,t)=>{bk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sj(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new VM({...t,checks:[],...Z(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new VM({...t,checks:[],...Z(r),entries:i})}});function HM(e,t){return new VM({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Z(t)})}var UM=X(`ZodLiteral`,(e,t)=>{xk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cj(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function WM(e,t){return new UM({type:`literal`,values:Array.isArray(e)?e:[e],...Z(t)})}var GM=X(`ZodTransform`,(e,t)=>{Sk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uj(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new wE(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(cD(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(cD(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function KM(e){return new GM({type:`transform`,transform:e})}var qM=X(`ZodOptional`,(e,t)=>{wk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function JM(e){return new qM({type:`optional`,innerType:e})}var YM=X(`ZodExactOptional`,(e,t)=>{Tk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function XM(e){return new YM({type:`optional`,innerType:e})}var ZM=X(`ZodNullable`,(e,t)=>{Ek.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function QM(e){return new ZM({type:`nullable`,innerType:e})}var $M=X(`ZodDefault`,(e,t)=>{Dk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function eN(e,t){return new $M({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():UE(t)}})}var tN=X(`ZodPrefault`,(e,t)=>{kk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nN(e,t){return new tN({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():UE(t)}})}var rN=X(`ZodNonOptional`,(e,t)=>{Ak.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_j(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function iN(e,t){return new rN({type:`nonoptional`,innerType:e,...Z(t)})}var aN=X(`ZodCatch`,(e,t)=>{Mk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function oN(e,t){return new aN({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var sN=X(`ZodPipe`,(e,t)=>{Nk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xj(e,t,n,r),e.in=t.in,e.out=t.out});function cN(e,t){return new sN({type:`pipe`,in:e,out:t})}var lN=X(`ZodReadonly`,(e,t)=>{Fk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function uN(e){return new lN({type:`readonly`,innerType:e})}var dN=X(`ZodLazy`,(e,t)=>{Lk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wj(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function fN(e){return new dN({type:`lazy`,getter:e})}var pN=X(`ZodCustom`,(e,t)=>{Rk.init(e,t),Jj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lj(e,t,n,r)});function mN(e,t={}){return GA(pN,e,t)}function hN(e,t){return KA(e,t)}function gN(e){let t=fN(()=>PM([Q(e),vM(),SM(),wM(),AM(t),BM(Q(),t)]));return t}function _N(e){return vA(_M,e)}var vN=class extends Error{method;path;constructor(e,t,n){super(`Treeport could not be reached`,{cause:n}),this.method=e,this.path=t,this.name=`RpcNetworkError`}},yN=Of(`/`,{fetch:async(e,t)=>{try{return await fetch(e,t)}catch(n){if(n instanceof Error&&n.name===`AbortError`)throw n;let r=e instanceof Request?e:null,i=new URL(r?.url??String(e),globalThis.location?.href??`http://localhost`);throw new vN(String(t?.method??r?.method??`GET`).toUpperCase().slice(0,16),i.pathname.slice(0,2048),n)}}}),bN=500,xN=80,SN=128,CN=MM({error:MM({code:EM().optional(),message:EM().optional(),details:EM().optional()}).optional()}),wN=MM({data:EM().optional(),statusText:EM().optional()}),TN=e=>EM().transform(t=>{let n=Q().safeParse(t);if(!n.success)return null;let r=``;for(let e of n.data){let t=e.charCodeAt(0);r+=t<32||t===127?` `:e}let i=r.replace(/\s+/g,` `).trim();return i?i.length<=e?i:`${i.slice(0,e-1)}…`:null}).parse,EN=EM().transform(e=>{let t=MM({requestId:Q()}).safeParse(e);if(!t.success)return null;let n=t.data.requestId;return n.length<=SN&&/^[A-Za-z0-9_=-]+$/.test(n)?n:null}).parse;function DN(e){if(e instanceof vN)return{message:`Treeport could not be reached.`,code:null,details:null,status:null,statusText:null,requestId:null,method:e.method,path:e.path,networkFailure:!0,recoveryHint:`Check that it is running and reachable, then retry.`};if(e instanceof hf){let t=wN.safeParse(e.detail),n=t.success?t.data:null,r=CN.safeParse(n?.data),i=r.success?r.data.error:null,a=TN(bN)(i?.message),o=TN(100)(i?.code),s=i?.details??null,c=vM().int().min(100).max(599).safeParse(e.statusCode),l=c.success?c.data:null,u=TN(xN)(n?.statusText),d=EN(s);if(a)return{message:a,code:o,details:s,status:l,statusText:u,requestId:d,method:null,path:null,networkFailure:!1,recoveryHint:o===`INTERNAL_ERROR`?`Retry. If the problem continues, use the reference when checking Treeport logs.`:null};let f=l?`${l}${u?` ${u}`:``}`:TN(xN)(e.message);return{message:l&&[502,503,504].includes(l)?`The server or proxy returned ${f}.`:f?`The Treeport server returned ${f}.`:`The Treeport server returned an unexpected response.`,code:o,details:s,status:l,statusText:u,requestId:d,method:null,path:null,networkFailure:!1,recoveryHint:l&&[502,503,504].includes(l)?`Check that Treeport is running, then retry.`:null}}return{message:TN(bN)(e instanceof Error?e.message:String(e))??`Unexpected error.`,code:null,details:null,status:null,statusText:null,requestId:null,method:null,path:null,networkFailure:!1,recoveryHint:null}}function ON(e){return DN(e).message}var kN=`/api/socket.io/`,AN=64*1024,jN=`\x1B[9000~`,MN=`\x1B[9001~`,NN=`\x1B[9002~`,PN=`\x1B[9003~`,FN=`\x1B[9004~`,IN=Q().min(1).max(128),LN=Q().min(1).max(128),RN=Q().min(1).max(128),zN=vM().int().nonnegative(),BN={cols:vM().int().min(2).max(1e3),rows:vM().int().min(2).max(500)},VN=$(BN),HN=$({state:HM([`normal`,`error`,`indeterminate`,`paused`]),value:vM().int().min(0).max(100).nullable()}),UN=HM([`pi`,`claude`,`codex`]),WN=$({terminalId:Q().min(1),title:Q().max(256).nullable(),program:UN.nullable().default(null),hasForegroundProcess:SM().nullable().optional(),progress:HN.nullable(),progressStartedAt:Q().datetime().nullable().default(null),progressClearedAt:Q().datetime().nullable().default(null),bell:$({sequence:vM().int().positive(),at:Q().datetime(),unread:SM()}).nullable().default(null)});$({sequence:vM().int().positive()}),$({terminalId:IN,clientId:LN,...BN}),$({generation:zN,data:Q().max(AN)}),$({generation:zN,data:Q().max(AN)}),$({generation:zN,...BN}),$({generation:zN,...BN}),$({generation:zN}),$({streamId:RN,sequence:vM().int().nonnegative()});var GN={connectionId:Q().min(1).max(128),streamId:RN,generation:zN,controller:SM(),reset:WM(`full`)},KN=PM([$(GN),$({...GN,...BN,revision:vM().int().positive()})]),qN=$({...BN,revision:vM().int().positive()}),JN=$({streamId:RN,sequence:vM().int().positive(),data:Q()}),YN=$({title:Q().max(256)}),XN=$({progress:HN.nullable()}),ZN=$({viewing:SM()}),QN=$({generation:zN,controller:SM()}),$N=$({exitCode:vM().int().nullable()}),eP=$({code:Q().min(1).max(80),message:Q().min(1).max(1e3),retryable:SM()});function tP(e,t){let n={ready:KN,dimensions:qN,output:JN,title:YN,progress:XN,history:ZN,control:QN,exit:$N,terminal_error:eP}[e].safeParse(t);return n.success?n.data:null}var nP=Q().min(1).max(128),rP=(e,t)=>$({id:nP,type:WM(e),at:Q().datetime(),data:t}),iP=$({projectId:nP,worktreeId:wM()}),aP=$({worktreeId:nP}),oP=$({projectId:nP,worktreeId:nP}),sP=$({operationId:nP,worktreeId:nP}),cP=IM(`type`,[rP(`project.created`,iP),rP(`project.updated`,iP),rP(`project.removed`,iP),rP(`worktree.created`,oP),rP(`worktree.updated`,aP),rP(`worktree.removed`,oP),rP(`create.started`,$({projectId:nP,operationId:nP,worktreeId:wM()})),rP(`create.completed`,$({projectId:nP,operationId:nP,worktreeId:nP})),rP(`create.failed`,$({projectId:nP,operationId:nP,worktreeId:wM()})),rP(`terminal.created`,$({projectId:nP.optional(),worktreeId:nP,terminalId:nP})),rP(`terminal.updated`,$({worktreeId:nP,terminalId:nP})),rP(`terminal.removed`,$({worktreeId:nP,terminalId:nP})),rP(`terminal.metadata`,WN.extend({worktreeId:wM()})),rP(`terminal.controller_changed`,$({terminalId:nP,controlled:SM(),worktreeId:wM()})),rP(`panel.created`,$({worktreeId:nP,panelId:nP})),rP(`panel.updated`,$({worktreeId:nP,panelId:nP})),rP(`panel.open_requested`,$({worktreeId:nP,panelId:nP,sourceTerminalId:nP.nullable()})),rP(`panel.removed`,$({worktreeId:nP,panelId:nP})),rP(`remove.started`,sP.extend({kind:WM(`remove`)})),rP(`remove.completed`,sP),rP(`remove.failed`,sP.extend({error:Q()}))]),lP=$({id:Q().min(1),kind:WM(`web`),worktreeId:Q().min(1),definitionId:Q().min(1),title:Q().min(1),launch:$({input:BM(Q(),gN()).nullable(),cwd:Q().nullable()}),sandbox:$({allowSameOrigin:SM()}),createdAt:Q(),updatedAt:Q()}),uP=$({at:Q().datetime(),terminalMetadata:AM(WN),webPanels:AM(lP)});function dP(e){let t=uP.safeParse(e);return t.success?t.data:null}function fP(e){let t=cP.safeParse(e);return t.success?t.data:null}var pP=50*1024*1024,mP=4096,hP=4096;MM({input:Q().trim().min(1).max(4096),hidden:HM([`true`,`false`]).optional().default(`false`).transform(e=>e===`true`)}),MM({lines:_N().int().min(1).max(5e3).optional().default(200)}),MM({path:Q().trim().min(1),name:Q().trim().min(1).max(120).optional()}),MM({color:HM([`rose`,`orange`,`amber`,`emerald`,`cyan`,`blue`,`violet`,`pink`]).nullable()});var gP=Q().trim().min(1).max(120),_P=AM(Q()).min(1).max(128),vP=Q().max(hP),yP={name:gP,executable:Q().min(1).max(mP).refine(e=>e.trim().length>0,{message:`Executable cannot be blank`}),args:AM(vP).max(127),closeOnSuccess:SM().default(!1)};$(yP);var bP=Q().regex(/^[a-z0-9][a-z0-9._-]{0,119}$/,{message:`Preset IDs must contain only lowercase letters, numbers, dots, underscores, and hyphens`});$({version:WM(1),presets:BM(bP,EM())});var xP=Q().min(1).max(64),SP=MM({name:gP,argv:_P.optional(),returnToShell:SM().optional(),initialSize:VN.optional()});MM({name:Q().trim().min(1).max(120),base:HM([`default`,`current`]).default(`default`),sourceWorktreeId:Q().min(1).optional(),initialTerminal:SP.optional()}).superRefine((e,t)=>{e.base===`current`&&!e.sourceWorktreeId&&t.addIssue({code:`custom`,path:[`sourceWorktreeId`],message:`A source tree is required when starting from current`})});var CP=Q().min(1).max(4096).refine(e=>e.trim().length>0&&!e.includes(`\0`),{message:`Working directory cannot be blank or contain NUL`}),wP=BM(Q().min(1).max(256).refine(e=>!e.includes(`=`)&&!e.includes(`\0`),{message:`Environment keys cannot contain equals or NUL`}),Q().max(hP).refine(e=>!e.includes(`\0`),{message:`Environment values cannot contain NUL`})).refine(e=>Object.keys(e).length<=128,{message:`Environment cannot contain more than 128 variables`});MM({name:gP,argv:_P.optional(),cwd:CP.optional(),env:wP.optional(),returnToShell:SM().optional(),closeOnSuccess:SM().optional(),initialSize:VN.optional()}).refine(e=>!(e.returnToShell&&e.closeOnSuccess),{message:`A terminal cannot return to a shell and close on success`}),MM({name:gP});var TP=BM(Q(),gN());MM({definitionId:Q().min(1).max(256),input:TP.nullable().optional(),launchCwd:Q().max(4096).nullable().optional()}).extend({newInstance:SM().optional(),sourceTerminalId:Q().min(1).max(128).nullable().optional()});var EP=Q().min(1).max(128);MM({key:EP}),MM({key:EP,value:gN()}),MM({key:EP}),MM(yP),MM({...yP,closeOnSuccess:SM().optional(),expectedUpdatedAt:xP}),MM({expectedUpdatedAt:xP}),MM({path:Q().trim().min(1).max(4096)}),MM({source:Q().trim().min(1).max(4096),projectId:Q().min(1).optional()}),MM({source:Q().trim().min(1).max(4096),projectId:Q().min(1).optional()}),MM({source:Q().trim().min(1).max(4096).optional()}),MM({projectId:Q().min(1).optional()}),MM({confirmationToken:Q().length(64),confirmDestructive:SM()}),MM({project:Q().min(1),worktreeName:Q().trim().min(1).max(120),name:gP,argv:_P.optional(),base:HM([`default`,`current`]).default(`default`),sourceWorktreeId:Q().min(1).optional()}).superRefine((e,t)=>{e.base===`current`&&!e.sourceWorktreeId&&t.addIssue({code:`custom`,path:[`sourceWorktreeId`],message:`A source tree is required when starting from current`})});var DP=8,OP=Q().max(16384).startsWith(`/`).refine(e=>Array.from(e).every(e=>{let t=e.codePointAt(0);return t>31&&t!==127})),kP=new Set([`127.0.0.1`,`localhost`,`[::1]`]),AP=8*1024*1024,jP=4,MP=2,NP=1e3,PP=2,FP=500,IP=150,LP=44;function RP(e,t={cols:100,rows:30}){return{cols:Number.isFinite(e.cols)?Math.min(NP,Math.max(MP,Math.trunc(e.cols))):t.cols,rows:Number.isFinite(e.rows)?Math.min(FP,Math.max(PP,Math.trunc(e.rows))):t.rows}}var zP={phase:`closed`,degraded:!1,controller:!1,controlPending:!1,title:null,bellActive:!1,bellSerial:0,exitSerial:0,fileTransfer:null,hasSelection:!1,selecting:!1,viewingHistory:!1,pasteRequestSerial:0,error:null},BP=null;function VP(){if(BP)return BP;try{let e=sessionStorage.getItem(`treeport-terminal-client-id`);if(e)return sessionStorage.setItem(`treeport-terminal-client-id`,e),BP=e}catch{}let e=new Uint8Array(16);if(globalThis.crypto?.getRandomValues)globalThis.crypto.getRandomValues(e);else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)),n=`${t.slice(0,4).join(``)}-${t.slice(4,6).join(``)}-${t.slice(6,8).join(``)}-${t.slice(8,10).join(``)}-${t.slice(10).join(``)}`;try{sessionStorage.setItem(`treeport-terminal-client-id`,n)}catch{}return BP=n}var HP=50,UP=250,WP=class{createSocket;terminalId;listeners=new Set;snapshotValue=zP;terminal=null;fitAddon=null;wrapper=null;host=null;resizeObserver=null;keyboardViewportCleanup=null;socket=null;degradedTimer=null;bellTimer=null;fileTransferTimer=null;cursorRestoreTimer=null;cursorRestoreStartedAt=null;fileTransferQueue=Promise.resolve();resizeFrame=null;resizeSettleTimer=null;disposed=!1;opened=!1;ready=!1;reconnectAllowed=!0;streamId=null;controllerGeneration=0;controlRequestGeneration=null;canonicalCols=100;canonicalRows=30;canonicalRevision=0;appliedRevision=0;proposedDimensions=null;resizePending=!1;serverProtocolVersion=2;resizeIntentDirty=!1;resizeQuietElapsed=!1;resizeIntentGeneration=0;renderEpoch=0;renderQueue=Promise.resolve();renderFailed=!1;pendingTerminalWrites=0;expectedSequence=1;lastParsedSequence=0;parsedSequences=new Set;scrollExitPending=!1;resumeOnNextInput=!1;historyExitRequested=!1;selectionClearRequested=!1;selectionDragCancel=null;tmuxSelectionPending=!1;tmuxSelectionText=null;pendingPaste=``;inputModifiers=null;lastBellAt=0;wakeListenersAttached=!1;reconnectWhenOnline=()=>this.reconnectImmediately();reconnectWhenVisible=()=>{document.visibilityState===`visible`&&this.reconnectImmediately()};constructor(e,t=xE){this.createSocket=t,this.terminalId=e}getSnapshot=()=>this.snapshotValue;getInitialSize(){return!this.host||!this.terminal?null:RP(this.proposedDimensions??{cols:this.terminal.cols,rows:this.terminal.rows})}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));mount(e){if(this.disposed)return;this.host=e,this.wrapper||(this.wrapper=document.createElement(`div`),this.wrapper.className=`terminal-session-host h-full min-h-0 min-w-0`),e.appendChild(this.wrapper),this.opened||this.openTerminal(),this.keyboardViewportCleanup?.(),this.keyboardViewportCleanup=null;let t=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,n=window.visualViewport,r=document.querySelector(`.app-frame`);if(t&&n&&r){let e=null,t=()=>{e!==null&&window.cancelAnimationFrame(e),e=window.requestAnimationFrame(()=>{e=null;let t=this.wrapper?.querySelector(`.xterm-helper-textarea`);if(!(document.activeElement===t&&n.height<document.documentElement.clientHeight-100)){r.style.removeProperty(`--app-visual-viewport-height`),r.style.removeProperty(`--app-visual-viewport-offset-top`);return}let i=window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone?0:LP;r.style.setProperty(`--app-visual-viewport-height`,`${Math.max(0,n.height-i)}px`),r.style.setProperty(`--app-visual-viewport-offset-top`,`${n.offsetTop}px`)})};n.addEventListener(`resize`,t),n.addEventListener(`scroll`,t),t(),this.keyboardViewportCleanup=()=>{n.removeEventListener(`resize`,t),n.removeEventListener(`scroll`,t),e!==null&&window.cancelAnimationFrame(e),r.style.removeProperty(`--app-visual-viewport-height`),r.style.removeProperty(`--app-visual-viewport-offset-top`)}}this.resizeObserver?.disconnect(),this.resizeObserver=new ResizeObserver(()=>this.scheduleFit()),this.resizeObserver.observe(e),this.wakeListenersAttached||=(window.addEventListener(`online`,this.reconnectWhenOnline),document.addEventListener(`visibilitychange`,this.reconnectWhenVisible),!0),this.scheduleFit(),!this.socket&&this.opened?this.connect():this.reconnectImmediately()}unmount(e){this.host===e&&(this.resizeObserver?.disconnect(),this.resizeObserver=null,this.wakeListenersAttached&&=(window.removeEventListener(`online`,this.reconnectWhenOnline),document.removeEventListener(`visibilitychange`,this.reconnectWhenVisible),!1),this.keyboardViewportCleanup?.(),this.keyboardViewportCleanup=null,this.cancelControllerResizeIntent(!1),this.selectionDragCancel?.(),this.wrapper?.remove(),this.host=null)}focus(e={}){e.requestControl&&this.requestControl(),this.terminal?.focus()}requestControl(){if(!this.ready||!this.socket?.connected||this.snapshotValue.controller||this.controlRequestGeneration===this.controllerGeneration)return;let e=RP(this.proposedDimensions??{cols:this.canonicalCols,rows:this.canonicalRows});this.controlRequestGeneration=this.controllerGeneration,this.update({controlPending:!0}),this.send(`take_control`,this.serverProtocolVersion===2?{generation:this.controllerGeneration,...e}:{generation:this.controllerGeneration})}retry(){if(!(this.disposed||this.ready)){if(this.renderFailed){window.location.reload();return}this.reconnectAllowed=!0,this.update({error:null,phase:`connecting`,degraded:!1}),this.socket?this.socket.connect():this.connect()}}setInputModifiers(e,t,n){this.inputModifiers=e||t?{ctrl:e,alt:t,onConsumed:n}:null}sendText(e,t={}){this.requestControl(),this.clearSelection(),this.prepareScrollExit(),this.canInput()&&this.send(`input`,{generation:this.controllerGeneration,data:this.withScrollExit(e)}),t.focus!==!1&&this.focus()}pasteText(e){e&&(this.requestControl(),this.clearSelection(),this.prepareScrollExit(),this.canInput()?this.terminal?.paste(e):this.pendingPaste+=e,this.focus())}sendArrow(e,t=!1,n={}){let r={up:`A`,down:`B`,right:`C`,left:`D`}[e],i=this.terminal?.modes.applicationCursorKeysMode?`\x1BO`:`\x1B[`;this.sendText(`${t?`\x1B`:``}${i}${r}`,n)}jumpToLatest(){this.ready&&(this.historyExitRequested=!0,this.requestControl(),this.canInput()&&this.sendHistoryExit(),this.focus())}copySelection(){let e=this.tmuxSelectionText??this.terminal?.getSelection()??``;if(!e)return;let t=document.createElement(`textarea`);t.value=e,t.readOnly=!0,t.style.position=`fixed`,t.style.left=`-9999px`,t.style.opacity=`0`,document.body.appendChild(t),t.focus({preventScroll:!0}),t.select(),t.setSelectionRange(0,e.length);let n=document.execCommand(`copy`);t.remove(),!n&&navigator.clipboard&&navigator.clipboard.writeText(e),this.focus()}clearSelectionAndJumpToLatest(){this.ready&&(this.historyExitRequested=!0,this.selectionClearRequested=!0,this.requestControl(),this.canInput()&&(this.send(`input`,{generation:this.controllerGeneration,data:`${jN}${PN}`}),this.historyExitRequested=!1,this.selectionClearRequested=!1,this.setViewingHistory(!1)),this.tmuxSelectionPending=!1,this.tmuxSelectionText=null,this.terminal?.clearSelection(),this.update({selecting:!1,hasSelection:!1}),this.focus())}clearSelection(){let e=this.tmuxSelectionPending||this.tmuxSelectionText!==null;!e&&!this.terminal?.hasSelection?.()||(e&&(this.selectionClearRequested=!0,this.sendSelectionClear()),this.tmuxSelectionPending=!1,this.tmuxSelectionText=null,this.update({selecting:!1}),this.terminal?.clearSelection(),this.updateSelectionState())}dispose(){this.disposed||(this.disposed=!0,this.reconnectAllowed=!1,this.clearTimers(),this.selectionDragCancel?.(),this.selectionDragCancel=null,this.resizeObserver?.disconnect(),this.wakeListenersAttached&&=(window.removeEventListener(`online`,this.reconnectWhenOnline),document.removeEventListener(`visibilitychange`,this.reconnectWhenVisible),!1),this.keyboardViewportCleanup?.(),this.keyboardViewportCleanup=null,this.socket?.disconnect(),this.socket=null,this.wrapper?.remove(),this.terminal?.dispose(),this.terminal=null,this.fitAddon=null,this.wrapper=null,this.listeners.clear())}openTerminal(){if(!this.wrapper||this.opened)return;let e=new jw(sg()),t=new ug;e.loadAddon(t),e.loadAddon(new gg(tg)),e.open(this.wrapper),e.onSelectionChange(()=>this.updateSelectionState()),e.onRender(()=>{this.wrapper?.classList.contains(`terminal-scrolling`)&&this.hideTerminalCursor()}),e.onWriteParsed(()=>{this.cursorRestoreTimer!==null&&this.scheduleTerminalCursorRestore()}),this.selectionDragCancel=ag(this.wrapper,e,{canInput:()=>this.canInput(),sendInput:e=>{this.send(`input`,{generation:this.controllerGeneration,data:e})},requestControl:()=>this.requestControl(),onSelectionStart:()=>this.clearSelection(),onTmuxSelectionStart:()=>{this.scrollExitPending=!0,this.update({selecting:!0}),this.setTerminalScrolling(!0)},onTmuxSelectionFinish:()=>{this.tmuxSelectionPending=!0,this.update({selecting:!1,hasSelection:!0})},onTmuxSelectionCancel:()=>{this.update({selecting:!1}),this.sendHistoryExit()},selectionStartSequence:MN,selectionStopSequence:NN}),this.wrapper.addEventListener(`copy`,e=>{this.tmuxSelectionText===null||!e.clipboardData||(e.preventDefault(),e.stopImmediatePropagation(),e.clipboardData.setData(`text/plain`,this.tmuxSelectionText))},!0),this.wrapper.addEventListener(`click`,()=>this.requestControl(),!0),this.wrapper.addEventListener(`keydown`,t=>{let n=t.key.toLowerCase(),r=[`alt`,`altgraph`,`control`,`meta`,`shift`].includes(n),i=$h(t,e.modes.applicationCursorKeysMode),a=t.metaKey&&i===null,o=t.ctrlKey&&t.shiftKey&&(n===`c`||n===`v`);!r&&!a&&!o&&(this.clearSelection(),this.requestControl())},!0);let n=og(this.wrapper,e,e=>{e.deltaY<0&&this.canInput()&&(!this.snapshotValue.viewingHistory&&this.tmuxSelectionText!==null&&this.send(`input`,{generation:this.controllerGeneration,data:FN}),this.scrollExitPending=!0)},()=>{this.requestControl(),this.clearSelection(),this.prepareScrollExit()},()=>{this.requestControl(),this.update({pasteRequestSerial:this.snapshotValue.pasteRequestSerial+1})}),r=this.wrapper,i=e=>!!(e&&(Array.from(e.types).includes(`Files`)||Array.from(e.items).some(e=>e.kind===`file`))),a=e=>{let t=Array.from(e?.files??[]);return t.length?t:Array.from(e?.items??[]).flatMap(e=>{let t=e.kind===`file`?e.getAsFile():null;return t?[t]:[]})};r.addEventListener(`dragover`,e=>{i(e.dataTransfer)&&(this.requestControl(),e.preventDefault(),e.dataTransfer.dropEffect=`copy`,r.classList.add(`terminal-file-drag`))}),r.addEventListener(`dragleave`,e=>{(!(e.relatedTarget instanceof Node)||!r.contains(e.relatedTarget))&&r.classList.remove(`terminal-file-drag`)}),r.addEventListener(`drop`,e=>{i(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),r.classList.remove(`terminal-file-drag`),this.requestControl(),this.queueFileTransfer(a(e.dataTransfer)))}),r.addEventListener(`paste`,e=>{let t=a(e.clipboardData);t.length&&(e.preventDefault(),e.stopPropagation(),this.requestControl(),this.queueFileTransfer(t))},!0),this.terminal=e,this.fitAddon=t,this.opened=!0,e.parser.registerOscHandler(52,e=>{if(!this.tmuxSelectionPending)return!1;this.tmuxSelectionPending=!1;let t=e.indexOf(`;`),n=t===-1?``:e.slice(t+1),r=n.replace(/=+$/,``);if(!n||n===`?`||n.length>AP||e.indexOf(`;`,t+1)!==-1||!/^[A-Za-z0-9+/]*={0,2}$/.test(n)||r.length%4==1)return this.updateSelectionState(),!0;let i=r.padEnd(Math.ceil(r.length/4)*4,`=`),a=atob(i);return this.tmuxSelectionText=new TextDecoder().decode(Uint8Array.from(a,e=>e.charCodeAt(0))),this.update({selecting:!1}),this.updateSelectionState(),!0}),e.attachCustomKeyEventHandler(t=>{let n=$h(t,e.modes.applicationCursorKeysMode);return n===null?!0:(t.preventDefault(),t.stopPropagation(),this.prepareScrollExit(),e.input(n,!0),!1)}),e.onKey(()=>this.prepareScrollExit()),e.onData(e=>{if(this.canInput()){e=n(e);let t=this.inputModifiers;t&&(this.inputModifiers=null,t.ctrl&&e.length===1&&(e=String.fromCharCode(e.toUpperCase().charCodeAt(0)&31)),t.alt&&(e=`\u001b${e}`),t.onConsumed()),this.send(`input`,{generation:this.controllerGeneration,data:this.withScrollExit(e)})}}),e.onBinary(e=>{this.canInput()&&this.send(`binary`,{generation:this.controllerGeneration,data:this.withScrollExit(e)})}),e.onTitleChange(e=>this.update({title:e.trim().slice(0,256)})),e.onBell(()=>this.handleBell())}queueFileTransfer(e){this.fileTransferQueue=this.fileTransferQueue.catch(()=>void 0).then(()=>this.transferFiles(e))}async transferFiles(e){if(!(!e.length||this.disposed)){if(e.length>DP){this.showFileTransferError(`Choose no more than ${DP} files at a time`);return}if(e.some(e=>e.size>52428800)){this.showFileTransferError(`Files are limited to ${pP} bytes`);return}if(!this.ready||!this.snapshotValue.controller){this.showFileTransferError(this.snapshotValue.controlPending?`taking control; try again in a moment`:`interact with the terminal to take control first`);return}if(!this.canInput()){this.showFileTransferError(`Wait for the terminal resize to finish`);return}this.fileTransferTimer!==null&&(window.clearTimeout(this.fileTransferTimer),this.fileTransferTimer=null);try{let t=window.treeportDesktop,n;n=t?.getPathForFile?await Promise.all(e.map(e=>Promise.resolve().then(()=>t.getPathForFile?.(e)??null).catch(()=>null))):kP.has(window.location.hostname)?e.map(e=>{let t=e,n=OP.safeParse(t.path);return n.success?n.data:null}):e.map(()=>null);let r=n.filter(e=>!e).length;r>0&&this.update({fileTransfer:{state:`uploading`,message:`Uploading ${r===1?`file`:`${r} files`}…`}});let i=[];for(let[t,r]of e.entries()){let e=n[t];if(e){i.push(e);continue}let a=/\.([a-z0-9]{1,16})$/i.exec(r.name)?.[1],o=new Headers({"content-type":r.type||`application/octet-stream`});a&&o.set(`x-treeport-file-extension`,a.toLowerCase());let s=await Tf(yN.api.terminals[`:terminalId`].files.$post({param:{terminalId:this.terminalId}},{init:{body:r,headers:o}}));i.push(s.file.path)}if(this.disposed)return;if(!this.ready||!this.snapshotValue.controller){this.showFileTransferError(`Terminal control was lost during the upload`);return}if(!this.canInput()){this.showFileTransferError(`Wait for the terminal resize to finish`);return}let a=i.map(e=>/^[A-Za-z0-9_+,./:@%=-]+$/u.test(e)?e:`'${e.replaceAll(`'`,`'\\''`)}'`).join(` `);if(new TextEncoder().encode(a).byteLength>65504){this.showFileTransferError(`The file paths are too long`);return}this.clearSelection(),this.prepareScrollExit(),this.terminal?.paste(a),this.focus(),this.update({fileTransfer:null})}catch(e){this.disposed||this.showFileTransferError(ON(e))}}}showFileTransferError(e){this.fileTransferTimer!==null&&window.clearTimeout(this.fileTransferTimer),this.update({fileTransfer:{state:`error`,message:`Couldn’t paste file: ${e}`}}),this.fileTransferTimer=window.setTimeout(()=>{this.fileTransferTimer=null,this.update({fileTransfer:null})},6e3)}prepareScrollExit(){(this.scrollExitPending||this.snapshotValue.viewingHistory)&&(this.resumeOnNextInput=!0)}withScrollExit(e){return this.resumeOnNextInput?(this.setViewingHistory(!1),`${jN}${e}`):e}sendHistoryExit(){this.canInput()&&(this.send(`input`,{generation:this.controllerGeneration,data:jN}),this.historyExitRequested=!1,this.setViewingHistory(!1))}sendSelectionClear(){this.canInput()&&(this.send(`input`,{generation:this.controllerGeneration,data:PN}),this.selectionClearRequested=!1)}hideTerminalCursor(){this.terminal?.element?.querySelector(`.xterm-cursor`)?.classList.remove(`xterm-cursor`)}scheduleTerminalCursorRestore(){this.cursorRestoreTimer!==null&&window.clearTimeout(this.cursorRestoreTimer),this.cursorRestoreStartedAt??=Date.now();let e=Math.max(0,UP-(Date.now()-this.cursorRestoreStartedAt));this.cursorRestoreTimer=window.setTimeout(()=>{this.cursorRestoreTimer=null,this.cursorRestoreStartedAt=null,!(!this.wrapper||this.scrollExitPending||this.snapshotValue.viewingHistory)&&(this.wrapper.classList.remove(`terminal-scrolling`),this.terminal?.refresh(0,this.terminal.rows-1))},Math.min(HP,e))}setTerminalScrolling(e){if(this.wrapper){if(e){this.cursorRestoreTimer!==null&&(window.clearTimeout(this.cursorRestoreTimer),this.cursorRestoreTimer=null),this.cursorRestoreStartedAt=null,this.wrapper.classList.add(`terminal-scrolling`),this.hideTerminalCursor();return}this.wrapper.classList.contains(`terminal-scrolling`)&&this.scheduleTerminalCursorRestore()}}setViewingHistory(e){e?this.scrollExitPending=!0:(this.scrollExitPending=!1,this.resumeOnNextInput=!1,this.historyExitRequested=!1),this.setTerminalScrolling(e),e!==this.snapshotValue.viewingHistory&&this.update({viewingHistory:e})}reconnectImmediately(){if(!this.host||this.disposed||!this.reconnectAllowed||this.ready||this.socket?.connected)return;let e=this.socket;e&&(e.disconnect(),this.socket===e&&(this.socket=null)),this.opened&&this.connect()}connect(){if(this.disposed||!this.reconnectAllowed||this.socket)return;this.ready=!1,this.controlRequestGeneration=null,this.update({phase:`connecting`,controller:!1,controlPending:!1,error:null}),this.startDegradedTimer();let e=this.createSocket(`/terminals`,{path:kN,transports:[`websocket`],forceNew:!0,multiplex:!1,autoConnect:!1,reconnection:!0,reconnectionDelay:100,reconnectionDelayMax:1e3,randomizationFactor:.2,retries:0,query:{terminalProtocol:`2`},auth:e=>{let t=RP(this.proposedDimensions??{cols:this.terminal?.cols??100,rows:this.terminal?.rows??30});e({terminalId:this.terminalId,clientId:VP(),...t})}});this.socket=e,e.on(`connect`,()=>{this.socket===e&&this.fit()}),e.on(`ready`,e=>this.handleServerEvent(`ready`,e)),e.on(`dimensions`,e=>this.handleServerEvent(`dimensions`,e)),e.on(`output`,e=>this.handleServerEvent(`output`,e)),e.on(`title`,e=>this.handleServerEvent(`title`,e)),e.on(`progress`,e=>this.handleServerEvent(`progress`,e)),e.on(`history`,e=>this.handleServerEvent(`history`,e)),e.on(`control`,e=>this.handleServerEvent(`control`,e)),e.on(`exit`,e=>this.handleServerEvent(`exit`,e)),e.on(`terminal_error`,e=>this.handleServerEvent(`terminal_error`,e)),e.on(`connect_error`,t=>{this.socket!==e||!this.reconnectAllowed||(this.controlRequestGeneration=null,this.update({phase:`reconnecting`,controller:!1,controlPending:!1,error:`Terminal connection failed: ${t.message}`}))}),e.on(`disconnect`,t=>{if(this.socket!==e)return;let n=this.ready;this.ready=!1,this.streamId=null,this.selectionDragCancel?.(),this.tmuxSelectionPending=!1,this.tmuxSelectionText=null,this.setViewingHistory(!1),this.controllerGeneration=0,this.controlRequestGeneration=null,this.cancelControllerResizeIntent(),this.reconnectAllowed||this.clearDegraded(),this.update({phase:this.reconnectAllowed&&!this.disposed?`reconnecting`:`closed`,controller:!1,controlPending:!1,hasSelection:!1,selecting:!1,viewingHistory:!1,degraded:this.reconnectAllowed?this.snapshotValue.degraded:!1,error:!n&&!this.snapshotValue.error?`Terminal connection closed: ${t}`:this.snapshotValue.error})}),e.io.on(`reconnect_attempt`,()=>{this.socket===e&&this.reconnectAllowed&&(this.controlRequestGeneration=null,this.startDegradedTimer(),this.update({phase:`reconnecting`,controller:!1,controlPending:!1}))}),e.connect()}handleServerEvent(e,t){if(e===`ready`){let e=tP(`ready`,t);if(!e){this.failProtocol(`The terminal server sent an invalid ready event`);return}this.cancelControllerResizeIntent(),this.controlRequestGeneration=null;let n=`revision`in e;this.serverProtocolVersion=n?2:1;let r=n?{cols:e.cols,rows:e.rows}:RP(this.proposedDimensions??{cols:this.terminal?.cols??100,rows:this.terminal?.rows??30}),i=n?e.revision:1;this.streamId=e.streamId,this.controllerGeneration=e.generation,this.canonicalCols=r.cols,this.canonicalRows=r.rows,this.canonicalRevision=i,this.appliedRevision=n?0:i,this.expectedSequence=1,this.lastParsedSequence=0,this.parsedSequences.clear(),this.selectionDragCancel?.(),this.tmuxSelectionPending=!1,this.tmuxSelectionText=null,this.setViewingHistory(!1),this.ready=!0,this.renderEpoch+=1;let a=this.renderEpoch;this.enqueueRender(a,async()=>{await this.drainTerminalWrites(),!(this.disposed||a!==this.renderEpoch)&&(this.terminal?.reset(),n?this.applyCanonicalDimensions(r.cols,r.rows,i,!0):this.fit(!0))}),this.clearDegraded(),this.update({phase:`ready`,controller:e.controller,controlPending:!1,hasSelection:!1,selecting:!1,viewingHistory:!1,error:null});return}if(e===`dimensions`){if(this.serverProtocolVersion!==2){this.failProtocol(`The legacy terminal server sent dimensions`);return}let e=tP(`dimensions`,t);if(!e){this.failProtocol(`The terminal server sent invalid dimensions`);return}if(e.revision<=this.canonicalRevision)return;this.canonicalCols=e.cols,this.canonicalRows=e.rows,this.canonicalRevision=e.revision,this.resizePending=!1;let n=this.renderEpoch;this.enqueueRender(n,async()=>{await this.drainTerminalWrites(),!(this.disposed||n!==this.renderEpoch)&&(this.applyCanonicalDimensions(e.cols,e.rows,e.revision),this.flushControllerResize())});return}if(e===`output`){let e=tP(`output`,t);if(!e){this.failProtocol(`The terminal server sent invalid output`);return}this.handleOutput(e.streamId,e.sequence,e.data);return}if(e===`title`){let e=tP(`title`,t);if(!e){this.failProtocol(`The terminal server sent an invalid title`);return}this.update({title:e.title.trim().slice(0,256)});return}if(e===`progress`){tP(`progress`,t)||this.failProtocol(`The terminal server sent invalid progress`);return}if(e===`history`){let e=tP(`history`,t);if(!e){this.failProtocol(`The terminal server sent invalid history state`);return}this.setViewingHistory(e.viewing);return}if(e===`control`){let e=tP(`control`,t);if(!e){this.failProtocol(`The terminal server sent invalid controller state`);return}let n=e.controller!==this.snapshotValue.controller||e.generation!==this.controllerGeneration;if(n&&this.cancelControllerResizeIntent(),this.controllerGeneration=e.generation,this.controlRequestGeneration=null,this.update({controller:e.controller,controlPending:!1}),n&&!e.controller&&(this.selectionDragCancel?.(),this.tmuxSelectionPending=!1),e.controller&&this.selectionClearRequested&&this.sendSelectionClear(),e.controller&&this.historyExitRequested&&this.sendHistoryExit(),e.controller&&this.pendingPaste){let e=this.pendingPaste;this.pendingPaste=``,this.terminal?.paste(e)}n&&this.scheduleFit();return}if(e===`exit`){if(!tP(`exit`,t)){this.failProtocol(`The terminal server sent an invalid exit event`);return}this.update({exitSerial:this.snapshotValue.exitSerial+1});return}let n=tP(`terminal_error`,t);if(!n){this.failProtocol(`The terminal server sent an invalid error event`);return}this.reconnectAllowed=n.retryable,this.terminal?.writeln(`\r\n\x1b[31m${n.message}\x1b[0m`),n.retryable?(this.controlRequestGeneration=null,this.update({controlPending:!1,error:n.message})):(this.stopWithError(n.message),this.socket?.disconnect())}handleOutput(e,t,n){if(!this.ready||e!==this.streamId||t!==this.expectedSequence){this.failProtocol(`Terminal output arrived out of order`);return}this.expectedSequence+=1;let r=this.renderEpoch;this.enqueueRender(r,()=>{let i=this.terminal;i&&(this.pendingTerminalWrites+=1,i.write(n,()=>{if(this.pendingTerminalWrites=Math.max(0,this.pendingTerminalWrites-1),this.ready&&r===this.renderEpoch&&e===this.streamId){for(this.parsedSequences.add(t);this.parsedSequences.delete(this.lastParsedSequence+1);)this.lastParsedSequence+=1;this.send(`output_ack`,{streamId:e,sequence:this.lastParsedSequence})}}))})}async drainTerminalWrites(){let e=this.terminal;!e||this.pendingTerminalWrites===0||await new Promise(t=>e.write(``,t))}enqueueRender(e,t){let n=this.renderQueue.then(async()=>{this.disposed||this.renderFailed||e!==this.renderEpoch||await t()});this.renderQueue=n,n.catch(e=>this.failRendering(e))}applyCanonicalDimensions(e,t,n,r=!1){!this.terminal||n<=this.appliedRevision||(this.terminal.resize(e,t),this.appliedRevision=n,this.wrapper&&(this.wrapper.dataset.terminalCols=String(e),this.wrapper.dataset.terminalRows=String(t),this.wrapper.dataset.terminalRevision=String(n)),n===this.canonicalRevision&&this.fit(r))}canInput(){return this.ready&&this.snapshotValue.controller&&!this.resizePending&&this.appliedRevision===this.canonicalRevision}send(e,t){if(!(!this.socket?.connected||!this.ready)){if(e===`output_ack`||e===`resize`||e===`take_control`){this.socket.emit.bind(this.socket)(e,t);return}this.socket.volatile.emit.bind(this.socket.volatile)(e,t)}}scheduleFit(){this.resizeFrame!==null&&cancelAnimationFrame(this.resizeFrame),this.resizeFrame=requestAnimationFrame(()=>{this.resizeFrame=null,this.fit(!0)})}queueControllerResizeIntent(){this.resizeSettleTimer!==null&&window.clearTimeout(this.resizeSettleTimer),this.resizeIntentDirty=!0,this.resizeQuietElapsed=!1,this.resizeIntentGeneration=this.controllerGeneration,this.resizeSettleTimer=window.setTimeout(()=>{this.resizeSettleTimer=null,this.resizeQuietElapsed=!0,this.flushControllerResize()},IP)}flushControllerResize(){let e=this.proposedDimensions;if(!(!this.resizeIntentDirty||!this.resizeQuietElapsed||!e||!this.host||!this.ready||!this.socket?.connected||!this.snapshotValue.controller||this.resizeIntentGeneration!==this.controllerGeneration||this.appliedRevision!==this.canonicalRevision||this.resizePending)){if(e.cols===this.canonicalCols&&e.rows===this.canonicalRows){this.resizeIntentDirty=!1,this.resizeQuietElapsed=!1;return}this.resizeIntentDirty=!1,this.resizeQuietElapsed=!1,this.serverProtocolVersion===2?this.resizePending=!0:(this.canonicalCols=e.cols,this.canonicalRows=e.rows,this.appliedRevision=this.canonicalRevision),this.send(`resize`,{generation:this.controllerGeneration,cols:e.cols,rows:e.rows})}}cancelControllerResizeIntent(e=!0){this.resizeSettleTimer!==null&&window.clearTimeout(this.resizeSettleTimer),this.resizeSettleTimer=null,e&&(this.resizePending=!1),this.resizeIntentDirty=!1,this.resizeQuietElapsed=!1,this.resizeIntentGeneration=0,this.proposedDimensions=null}fit(e=!1){if(!(!this.host||!this.fitAddon||!this.terminal))try{if(!this.ready){this.terminal.options.fontSize=14,this.fitAddon.fit(),this.terminal.cols>=MP&&this.terminal.rows>=PP&&(this.proposedDimensions=RP({cols:this.terminal.cols,rows:this.terminal.rows}));return}if(this.serverProtocolVersion===1){if(this.terminal.options.fontSize=14,this.fitAddon.fit(),this.terminal.cols<MP||this.terminal.rows<PP){this.cancelControllerResizeIntent(!1);return}let t=RP({cols:this.terminal.cols,rows:this.terminal.rows});this.proposedDimensions=t,this.snapshotValue.controller&&e&&this.queueControllerResizeIntent();return}if(this.appliedRevision!==this.canonicalRevision)return;this.terminal.options.fontSize=14;let t=this.fitAddon.proposeDimensions();if(!t||!Number.isFinite(t.cols)||!Number.isFinite(t.rows)||t.cols<MP||t.rows<PP){this.snapshotValue.controller&&this.cancelControllerResizeIntent(!1);return}let n=RP(t);if(this.proposedDimensions=n,this.snapshotValue.controller){if(!e)return;if(!this.resizePending&&n.cols===this.canonicalCols&&n.rows===this.canonicalRows){this.resizeSettleTimer!==null&&window.clearTimeout(this.resizeSettleTimer),this.resizeSettleTimer=null,this.resizeIntentDirty=!1,this.resizeQuietElapsed=!1;return}this.queueControllerResizeIntent();return}let r=Math.min(1,n.cols/this.canonicalCols,n.rows/this.canonicalRows);this.terminal.options.fontSize=Math.max(jP,Math.floor(14*r*100)/100),(this.terminal.cols!==this.canonicalCols||this.terminal.rows!==this.canonicalRows)&&this.terminal.resize(this.canonicalCols,this.canonicalRows)}catch(e){this.failRendering(e)}}startDegradedTimer(){this.degradedTimer===null&&(this.degradedTimer=window.setTimeout(()=>{this.degradedTimer=null,this.ready||this.update({degraded:!0})},500))}clearDegraded(){this.degradedTimer!==null&&window.clearTimeout(this.degradedTimer),this.degradedTimer=null,this.update({degraded:!1})}handleBell(){let e=Date.now();e-this.lastBellAt<1e3||(this.lastBellAt=e,this.bellTimer!==null&&window.clearTimeout(this.bellTimer),this.update({bellActive:!0,bellSerial:this.snapshotValue.bellSerial+1}),this.bellTimer=window.setTimeout(()=>{this.bellTimer=null,this.update({bellActive:!1})},180))}failRendering(e){if(this.renderFailed||this.disposed)return;this.renderFailed=!0;let t=(e instanceof Error?e.message:String(e)).trim();this.reconnectAllowed=!1,this.stopWithError(t?`Terminal rendering failed: ${t.slice(0,500)}`:`Terminal rendering failed`),this.socket?.disconnect()}failProtocol(e){this.reconnectAllowed=!1,this.stopWithError(e),this.socket?.disconnect()}stopWithError(e){this.ready=!1,this.clearDegraded(),this.controlRequestGeneration=null,this.update({error:e,phase:`closed`,degraded:!1,controller:!1,controlPending:!1})}updateSelectionState(){this.update({hasSelection:this.tmuxSelectionPending||this.tmuxSelectionText!==null||!!this.terminal?.hasSelection()})}update(e){this.snapshotValue={...this.snapshotValue,...e},this.listeners.forEach(e=>e())}clearTimers(){this.degradedTimer!==null&&window.clearTimeout(this.degradedTimer),this.bellTimer!==null&&window.clearTimeout(this.bellTimer),this.fileTransferTimer!==null&&window.clearTimeout(this.fileTransferTimer),this.cursorRestoreTimer!==null&&window.clearTimeout(this.cursorRestoreTimer),this.resizeFrame!==null&&cancelAnimationFrame(this.resizeFrame),this.resizeSettleTimer!==null&&window.clearTimeout(this.resizeSettleTimer),this.degradedTimer=null,this.bellTimer=null,this.fileTransferTimer=null,this.cursorRestoreTimer=null,this.cursorRestoreStartedAt=null,this.resizeFrame=null,this.resizeSettleTimer=null,this.resizePending=!1,this.resizeIntentDirty=!1,this.resizeQuietElapsed=!1,this.resizeIntentGeneration=0,this.proposedDimensions=null}},GP=class{maxSessions;idleMs;createSession;onTitleChange;entries=new Map;constructor(e=8,t=5*6e4,n=e=>new WP(e),r=()=>void 0){this.maxSessions=e,this.idleMs=t,this.createSession=n,this.onTitleChange=r}getInitialSize(e){return this.entries.get(e)?.session.getInitialSize()??null}acquire(e){let t=this.entries.get(e);if(!t){let n=this.createSession(e);t={session:n,references:0,lastUsed:Date.now(),idleTimer:null,lastTitle:n.getSnapshot().title,unsubscribe:()=>void 0};let r=t;t.unsubscribe=n.subscribe(()=>{let t=n.getSnapshot();t.title!==r.lastTitle&&(r.lastTitle=t.title,this.onTitleChange(e,t.title))}),this.entries.set(e,t),t.lastTitle&&this.onTitleChange(e,t.lastTitle)}return t.references+=1,t.lastUsed=Date.now(),t.idleTimer!==null&&window.clearTimeout(t.idleTimer),t.idleTimer=null,this.evictOverCapacity(e),t.session}release(e){let t=this.entries.get(e);t&&(t.references=Math.max(0,t.references-1),t.lastUsed=Date.now(),t.references===0&&t.idleTimer===null&&(t.idleTimer=window.setTimeout(()=>this.disposeEntry(e),this.idleMs)))}forget(e){this.disposeEntry(e)}reconcile(e){let t=new Set(e);for(let e of this.entries.keys())t.has(e)||this.disposeEntry(e)}disposeEntry(e){let t=this.entries.get(e);t&&(t.idleTimer!==null&&window.clearTimeout(t.idleTimer),t.unsubscribe(),t.session.dispose(),this.entries.delete(e))}evictOverCapacity(e){for(;this.entries.size>this.maxSessions;){let t=[...this.entries.entries()].filter(([t,n])=>t!==e&&n.references===0).sort((e,t)=>e[1].lastUsed-t[1].lastUsed)[0];if(!t)return;this.disposeEntry(t[0])}}},KP=class{sendBellAcknowledgement;listeners=new Set;bellEventListeners=new Set;attentionSnapshot=new Set;titleSnapshot=new Map;programSnapshot=new Map;foregroundProcessSnapshot=new Set;progressSnapshot=new Map;bellMetadata=new Map;bellAcknowledgementTargets=new Map;bellAcknowledgementQueues=new Map;bellAcknowledgementEpoch=0;notificationBatchDepth=0;notificationPending=!1;constructor(e=async(e,t)=>{await Tf(yN.api.terminals[`:terminalId`].bell.acknowledge.$post({param:{terminalId:e},json:{sequence:t}}))}){this.sendBellAcknowledgement=e}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));subscribeBellEvents=e=>(this.bellEventListeners.add(e),()=>this.bellEventListeners.delete(e));getAttentionSnapshot=()=>this.attentionSnapshot;getBellSnapshot=()=>this.bellMetadata;getTitleSnapshot=()=>this.titleSnapshot;getProgramSnapshot=()=>this.programSnapshot;getForegroundProcessSnapshot=()=>this.foregroundProcessSnapshot;getProgressSnapshot=()=>this.progressSnapshot;applyRuntimeMetadata(e){this.notificationBatchDepth+=1;let t=this.bellMetadata.get(e.terminalId),n=e.bell,r=n!==null&&(!t||n.sequence>t.sequence||n.sequence===t.sequence&&(t.unread||!n.unread)),i=r&&(t?.sequence!==n.sequence||t?.at!==n.at||t?.unread!==n.unread),a=r&&n.unread&&(!t||n.sequence>t.sequence)?{terminalId:e.terminalId,sequence:n.sequence,at:n.at}:null;if(r){if(i){let t=new Map(this.bellMetadata);t.set(e.terminalId,{sequence:n.sequence,at:n.at,unread:n.unread}),this.bellMetadata=t,this.emit()}this.setAttention(e.terminalId,n.unread)}else!t&&n===null&&this.setAttention(e.terminalId,!1);this.setRuntimeTitle(e.terminalId,e.title),this.setProgram(e.terminalId,e.program??null),this.setForegroundProcess(e.terminalId,e.hasForegroundProcess===!0),this.setProgress(e.terminalId,e.progress),--this.notificationBatchDepth,this.notificationBatchDepth===0&&this.notificationPending&&(this.notificationPending=!1,this.listeners.forEach(e=>e())),a&&this.bellEventListeners.forEach(e=>e(a))}replaceRuntimeMetadata(e){let t=new Map,n=new Map,r=new Set,i=new Map,a=new Map,o=new Set;for(let s of e){let e=s.title?.trim().slice(0,256);if(e&&t.set(s.terminalId,e),s.program&&n.set(s.terminalId,s.program),s.hasForegroundProcess&&r.add(s.terminalId),s.progress){let e=this.progressSnapshot.get(s.terminalId);i.set(s.terminalId,e?.state===s.progress.state&&e.value===s.progress.value?e:s.progress)}s.bell&&(a.set(s.terminalId,{sequence:s.bell.sequence,at:s.bell.at,unread:s.bell.unread}),s.bell.unread&&o.add(s.terminalId))}let s=t.size!==this.titleSnapshot.size||[...t].some(([e,t])=>this.titleSnapshot.get(e)!==t),c=n.size!==this.programSnapshot.size||[...n].some(([e,t])=>this.programSnapshot.get(e)!==t),l=r.size!==this.foregroundProcessSnapshot.size||[...r].some(e=>!this.foregroundProcessSnapshot.has(e)),u=i.size!==this.progressSnapshot.size||[...i].some(([e,t])=>{let n=this.progressSnapshot.get(e);return n?.state!==t.state||n.value!==t.value}),d=o.size!==this.attentionSnapshot.size||[...o].some(e=>!this.attentionSnapshot.has(e)),f=a.size!==this.bellMetadata.size||[...a].some(([e,t])=>{let n=this.bellMetadata.get(e);return n?.sequence!==t.sequence||n?.at!==t.at||n?.unread!==t.unread});f&&(this.bellMetadata=a),this.bellAcknowledgementEpoch+=1,this.bellAcknowledgementTargets.clear(),s&&(this.titleSnapshot=t),c&&(this.programSnapshot=n),l&&(this.foregroundProcessSnapshot=r),u&&(this.progressSnapshot=i),d&&(this.attentionSnapshot=o),(s||c||l||u||d||f)&&this.emit()}setRuntimeTitle(e,t){let n=t?.trim().slice(0,256)||null;if(n===null){this.clearRuntimeTitle(e);return}this.titleSnapshot.get(e)!==n&&(this.titleSnapshot=new Map(this.titleSnapshot).set(e,n),this.emit())}forget(e){if(this.bellMetadata.has(e)){let t=new Map(this.bellMetadata);t.delete(e),this.bellMetadata=t,this.emit()}this.bellAcknowledgementTargets.delete(e),this.bellAcknowledgementQueues.delete(e),this.clearAttention(e),this.clearRuntimeTitle(e),this.setProgram(e,null),this.setForegroundProcess(e,!1),this.setProgress(e,null)}reconcile(e){let t=new Set(e),n=!1,r=new Set(this.attentionSnapshot),i=new Map(this.titleSnapshot),a=new Map(this.programSnapshot),o=new Set(this.foregroundProcessSnapshot),s=new Map(this.progressSnapshot);for(let e of r)t.has(e)||(r.delete(e),n=!0);for(let e of i.keys())t.has(e)||(i.delete(e),n=!0);for(let e of a.keys())t.has(e)||(a.delete(e),n=!0);for(let e of o)t.has(e)||(o.delete(e),n=!0);for(let e of s.keys())t.has(e)||(s.delete(e),n=!0);let c=new Map(this.bellMetadata);for(let e of c.keys())t.has(e)||(c.delete(e),this.bellAcknowledgementTargets.delete(e),this.bellAcknowledgementQueues.delete(e),n=!0);n&&(this.attentionSnapshot=r,this.titleSnapshot=i,this.programSnapshot=a,this.foregroundProcessSnapshot=o,this.progressSnapshot=s,this.bellMetadata=c,this.emit())}acknowledgeBell(e,t){let n=this.bellMetadata.get(e);if(!n?.unread||n.sequence!==t)return Promise.resolve();let r=this.bellAcknowledgementTargets.get(e)??0,i=this.bellAcknowledgementQueues.get(e);if(t<=r)return i??Promise.resolve();let a=this.bellAcknowledgementEpoch;this.bellAcknowledgementTargets.set(e,t);let o=(i??Promise.resolve()).catch(()=>void 0).then(async()=>{let n=this.bellMetadata.get(e);if(this.bellAcknowledgementEpoch!==a||n?.sequence!==t||!n.unread){this.bellAcknowledgementTargets.get(e)===t&&this.bellAcknowledgementTargets.delete(e);return}await this.sendBellAcknowledgement(e,t)}).catch(n=>{throw this.bellAcknowledgementTargets.get(e)===t&&this.bellAcknowledgementTargets.delete(e),n}).finally(()=>{this.bellAcknowledgementQueues.get(e)===o&&this.bellAcknowledgementQueues.delete(e)});return this.bellAcknowledgementQueues.set(e,o),o}clearAttention(e){if(!this.attentionSnapshot.has(e))return;let t=new Set(this.attentionSnapshot);t.delete(e),this.attentionSnapshot=t,this.emit()}clearRuntimeTitle(e){if(!this.titleSnapshot.has(e))return;let t=new Map(this.titleSnapshot);t.delete(e),this.titleSnapshot=t,this.emit()}setProgram(e,t){if(this.programSnapshot.get(e)===t)return;let n=new Map(this.programSnapshot);t?n.set(e,t):n.delete(e),this.programSnapshot=n,this.emit()}setForegroundProcess(e,t){if(this.foregroundProcessSnapshot.has(e)===t)return;let n=new Set(this.foregroundProcessSnapshot);t?n.add(e):n.delete(e),this.foregroundProcessSnapshot=n,this.emit()}setAttention(e,t){if(t||this.bellAcknowledgementTargets.delete(e),this.attentionSnapshot.has(e)===t)return;let n=new Set(this.attentionSnapshot);t?n.add(e):n.delete(e),this.attentionSnapshot=n,this.emit()}setProgress(e,t){let n=this.progressSnapshot.get(e);if(t&&n?.state===t.state&&n.value===t.value||!t&&!n)return;let r=new Map(this.progressSnapshot);t?r.set(e,t):r.delete(e),this.progressSnapshot=r,this.emit()}emit(){if(this.notificationBatchDepth>0){this.notificationPending=!0;return}this.listeners.forEach(e=>e())}},qP=new class{pool;runtimeMetadata;constructor(e=8,t=5*6e4,n=e=>new WP(e),r){this.runtimeMetadata=new KP(r),this.pool=new GP(e,t,n,(e,t)=>this.runtimeMetadata.setRuntimeTitle(e,t))}subscribe=e=>this.runtimeMetadata.subscribe(e);subscribeBellEvents=e=>this.runtimeMetadata.subscribeBellEvents(e);getAttentionSnapshot=()=>this.runtimeMetadata.getAttentionSnapshot();getBellSnapshot=()=>this.runtimeMetadata.getBellSnapshot();getTitleSnapshot=()=>this.runtimeMetadata.getTitleSnapshot();getProgramSnapshot=()=>this.runtimeMetadata.getProgramSnapshot();getForegroundProcessSnapshot=()=>this.runtimeMetadata.getForegroundProcessSnapshot();getProgressSnapshot=()=>this.runtimeMetadata.getProgressSnapshot();getInitialSize(e){return this.pool.getInitialSize(e)}applyRuntimeMetadata(e){this.runtimeMetadata.applyRuntimeMetadata(e)}replaceRuntimeMetadata(e){this.runtimeMetadata.replaceRuntimeMetadata(e)}acquire(e){return this.pool.acquire(e)}release(e){this.pool.release(e)}forget(e){this.pool.forget(e),this.runtimeMetadata.forget(e)}reconcile(e){let t=[...e].map(e=>e.id);this.pool.reconcile(t),this.runtimeMetadata.reconcile(t)}acknowledgeBell(e,t){return this.runtimeMetadata.acknowledgeBell(e,t)}},JP=new Set,YP=new Map,XP=new Map,ZP=new Map,QP=new Map,$P={attention:JP,titles:YP,programs:XP,progress:ZP},eF={bells:QP,titles:YP},tF=$P,nF=eF;function rF(){let e=qP.getAttentionSnapshot(),t=qP.getTitleSnapshot(),n=qP.getProgramSnapshot(),r=qP.getProgressSnapshot();return(tF.attention!==e||tF.titles!==t||tF.programs!==n||tF.progress!==r)&&(tF={attention:e,titles:t,programs:n,progress:r}),tF}function iF(){let e=qP.getBellSnapshot(),t=qP.getTitleSnapshot();return(nF.bells!==e||nF.titles!==t)&&(nF={bells:e,titles:t}),nF}function aF(){return(0,R.useSyncExternalStore)(qP.subscribe,rF,()=>$P)}function oF(){return(0,R.useSyncExternalStore)(qP.subscribe,iF,()=>eF)}var sF=`treeport-last-workspace-route`,cF=`treeport-last-project-terminal:`;function lF(e,t){return e!==null&&e===t}function uF(e){return encodeURIComponent(e)}function dF(e){return{kind:`project`,pathname:`/projects/${uF(e)}`,projectId:e}}function fF(e,t){return{kind:`worktree`,pathname:`/projects/${uF(e)}/worktrees/${uF(t)}`,projectId:e,worktreeId:t}}function pF(e,t,n){return{kind:`terminal`,pathname:`/projects/${uF(e)}/worktrees/${uF(t)}/terminals/${uF(n)}`,projectId:e,worktreeId:t,terminalId:n}}function mF(e,t,n){return{kind:`panel`,pathname:`/projects/${uF(e)}/worktrees/${uF(t)}/panels/${uF(n)}`,projectId:e,worktreeId:t,panelId:n}}function hF(e){let t=e.worktrees[0];if(!t)return dF(e.id);let n=t.terminals[0];return n?pF(e.id,t.id,n.id):fF(e.id,t.id)}function gF(e,t){if(t)for(let n of e.worktrees){let r=n.terminals.find(e=>e.id===t);if(r)return pF(e.id,n.id,r.id)}return hF(e)}function _F(e,t){let n=t.terminals[0];return n?pF(e.id,t.id,n.id):fF(e.id,t.id)}function vF(e,t){for(let n of e){let e=n.worktrees.find(e=>e.id===t.worktreeId);if(e?.panels.some(e=>e.kind===`web`&&e.id===t.id))return mF(n.id,e.id,t.id)}return null}function yF(e,t){for(let n of e){let e=n.worktrees.find(e=>e.id===t.worktreeId);if(e?.terminals.some(e=>e.id===t.id))return pF(n.id,e.id,t.id)}return null}function bF(e,t,n){let r=e.find(e=>e.id===t.projectId&&e.worktrees.some(e=>e.id===t.id));if(!r)return null;let i=t.terminals.find(e=>e.id===n)??t.terminals[0];return i?pF(r.id,t.id,i.id):fF(r.id,t.id)}function xF(e,t){if(t.kind===`root`)return{project:null,worktree:null,terminal:null,panel:null};let n=e.find(e=>e.id===t.projectId)??null;if(!n||t.kind===`project`)return{project:n,worktree:null,terminal:null,panel:null};let r=n.worktrees.find(e=>e.id===t.worktreeId)??null;return!r||t.kind===`worktree`?{project:n,worktree:r,terminal:null,panel:null}:t.kind===`panel`?{project:n,worktree:r,terminal:null,panel:r.panels.find(e=>e.kind===`web`&&e.id===t.panelId)??null}:{project:n,worktree:r,terminal:r.terminals.find(e=>e.id===t.terminalId)??null,panel:null}}function SF(e){try{return decodeURIComponent(e)}catch{return null}}function CF(e){if(e===`/`)return{kind:`root`,pathname:`/`};let t=e.split(`/`).filter(Boolean);if(t[0]!==`projects`)return null;let n=t[1]?SF(t[1]):null;if(!n)return null;if(t.length===2)return dF(n);if(t[2]!==`worktrees`)return null;let r=t[3]?SF(t[3]):null;if(!r)return null;if(t.length===4)return fF(n,r);let i=t[5]?SF(t[5]):null;return!i||t.length!==6?null:t[4]===`terminals`?pF(n,r,i):t[4]===`panels`?mF(n,r,i):null}function wF(e){return e[0]?hF(e[0]):{kind:`root`,pathname:`/`}}function TF(e,t){if(!t||t.kind===`root`)return wF(e);let n=e.find(e=>e.id===t.projectId);if(!n)return wF(e);if(t.kind===`project`)return n.worktrees.length?hF(n):dF(n.id);let r=n.worktrees.find(e=>e.id===t.worktreeId);if(!r)return n.worktrees[0]?_F(n,n.worktrees[0]):dF(n.id);if(t.kind===`worktree`)return _F(n,r);if(t.kind===`panel`){let e=r.panels.find(e=>e.kind===`web`&&e.id===t.panelId);return e?mF(n.id,r.id,e.id):_F(n,r)}let i=r.terminals.find(e=>e.id===t.terminalId);return i?pF(n.id,r.id,i.id):_F(n,r)}function EF(e,t,n){let r=CF(t),i;if(r?.kind===`root`&&e.length&&n){let t=CF(n);i=t?.kind!==`root`&&e.some(e=>e.id===t?.projectId)?TF(e,t):wF(e)}else i=TF(e,r);return{target:i,selection:xF(e,i),canonical:i.pathname===t}}function DF(e,{operation:t}){let n=DN(e),r=[n.message,n.recoveryHint,n.requestId?`Reference: ${n.requestId}.`:null].filter(e=>!!e).join(` `);za.error(`Couldn’t ${t}`,{description:r})}function OF(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=new Date,r=t.toDateString()===n.toDateString();return new Intl.DateTimeFormat(void 0,r?{hour:`numeric`,minute:`2-digit`}:{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(t)}function kF({projects:e,navigateToWorkspace:t,open:n,onOpenChange:r}){let{bells:i,titles:a}=oF(),[o,s]=(0,R.useState)(()=>new Set),c=(0,R.useMemo)(()=>e.flatMap(t=>t.worktrees.flatMap(n=>n.terminals.flatMap(r=>{let o=i.get(r.id),s=yF(e,r);return o?.unread&&s?[{terminalId:r.id,sequence:o.sequence,occurredAt:o.at,title:a.get(r.id)??r.name,context:`${t.name} · ${n.name}`,target:s}]:[]}))).sort((e,t)=>t.occurredAt.localeCompare(e.occurredAt)||e.terminalId.localeCompare(t.terminalId)),[i,e,a]),l=c.length,u=l===0?`Notifications, no unread notifications`:`Notifications, ${l} unread`,d=async(e,t,n)=>{s(t=>new Set(t).add(e)),await qP.acknowledgeBell(e,t).catch(e=>{DF(e,{operation:`mark notification for terminal “${n}” as read`})}),s(t=>{let n=new Set(t);return n.delete(e),n})};return(0,z.jsxs)(Vh,{modal:!0,open:n,onOpenChange:r,children:[(0,z.jsx)(Hh,{asChild:!0,children:(0,z.jsxs)(G,{type:`button`,size:`icon`,variant:`ghost`,className:`icon-button text-zinc-400 hover:bg-white/5 hover:text-zinc-100`,"aria-label":u,children:[(0,z.jsx)(Gf,{}),l>0?(0,z.jsx)(Sp,{size:`counter`,className:`pointer-events-none absolute -top-0.5 -right-0.5`,"aria-hidden":!0,children:l>99?`99+`:l}):null]})}),(0,z.jsxs)(Uh,{align:`end`,className:`flex max-h-[min(26rem,calc(100dvh-1rem))] w-[min(22rem,calc(100vw-1rem))] touch-manipulation flex-col overflow-hidden p-0 select-none`,"aria-label":`Notifications`,children:[(0,z.jsx)(`div`,{className:`shrink-0 px-3 pt-3 pb-2`,children:(0,z.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Notifications`})}),c.length===0?(0,z.jsxs)(wp,{className:`min-h-28 p-4`,children:[(0,z.jsx)(Tp,{children:`All caught up`}),(0,z.jsx)(Ep,{children:`No unread notifications.`})]}):(0,z.jsx)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain px-1.5 pb-1.5`,children:(0,z.jsx)(`ul`,{role:`list`,className:`flex flex-col gap-0.5`,children:c.map(e=>(0,z.jsx)(`li`,{className:`min-w-0`,children:(0,z.jsxs)(`button`,{type:`button`,className:`w-full min-w-0 cursor-default rounded-md px-2 py-2 text-left outline-none hover:bg-white/5 focus-visible:bg-white/5 focus-visible:outline-2 focus-visible:outline-cyan-400 disabled:opacity-45`,disabled:o.has(e.terminalId),"aria-label":`Open ${e.title}`,onClick:()=>{r(!1),d(e.terminalId,e.sequence,e.title).then(()=>t(e.target))},children:[(0,z.jsx)(`h3`,{className:`truncate text-sm font-medium text-zinc-100`,children:e.title}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-1.5 text-xs text-zinc-500`,children:[(0,z.jsx)(`p`,{className:`min-w-0 truncate`,children:e.context}),(0,z.jsx)(`span`,{className:`shrink-0`,"aria-hidden":!0,children:`·`}),(0,z.jsx)(`time`,{dateTime:e.occurredAt,className:`shrink-0 tabular-nums`,children:OF(e.occurredAt)})]})]})},e.terminalId))})})]})]})}function AF(e,t,n){for(let r of e)for(let e of r.worktrees){let r=e.terminals.find(e=>e.id===n);if(r)return t.get(n)??r.name}return null}function jF({projects:e,selectedTerminalId:t}){let{bells:n,titles:r}=oF(),i=(0,R.useRef)({projects:e,selectedTerminalId:t,titles:r,presence:{focused:document.hasFocus(),visible:document.visibilityState===`visible`}});i.current.projects=e,i.current.selectedTerminalId=t,i.current.titles=r;let a=()=>{let e=i.current,t=e.selectedTerminalId;if(!t||!e.presence.focused||!e.presence.visible)return;let n=qP.getBellSnapshot().get(t);if(!n?.unread)return;let r=AF(e.projects,e.titles,t);qP.acknowledgeBell(t,n.sequence).catch(e=>{DF(e,{operation:r?`acknowledge notification for terminal “${r}”`:`acknowledge terminal notification`})})};return(0,R.useEffect)(()=>{let e=()=>{i.current.presence={focused:document.hasFocus(),visible:document.visibilityState===`visible`},a()};return document.addEventListener(`visibilitychange`,e),window.addEventListener(`focus`,e),window.addEventListener(`blur`,e),()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`focus`,e),window.removeEventListener(`blur`,e)}},[]),(0,R.useEffect)(()=>{a()},[n,t]),(0,R.useEffect)(()=>qP.subscribeBellEvents(e=>{let t=i.current;if(t.selectedTerminalId===e.terminalId&&t.presence.focused&&t.presence.visible){let n=AF(t.projects,qP.getTitleSnapshot(),e.terminalId);qP.acknowledgeBell(e.terminalId,e.sequence).catch(e=>{DF(e,{operation:n?`acknowledge notification for terminal “${n}”`:`acknowledge terminal notification`})});return}window.treeportDesktop?.requestAttention()}),[]),null}var MF=Object.defineProperty,NF=(e,t)=>MF(e,`name`,{value:t,configurable:!0});function PF(e,t){let n=R.createContext(t);n.displayName=e+`Context`;let r=NF(e=>{let{children:t,...r}=e,i=R.useMemo(()=>r,Object.values(r));return(0,z.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=R.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return NF(i,`useContext`),[r,i]}NF(PF,`createContext`);function FF(e,t=[]){let n=[];function r(t,r){let i=R.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=NF(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=R.useMemo(()=>o,Object.values(o));return(0,z.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=R.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return NF(s,`useContext`),[o,s]}NF(r,`createContext`);let i=NF(()=>{let t=n.map(e=>R.createContext(e));return NF(function(n){let r=n?.[e]||t;return R.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,IF(i,...t)]}NF(FF,`createContextScope`);function IF(...e){let t=e[0];if(e.length===1)return t;let n=NF(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return NF(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return R.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}NF(IF,`composeContextScopes`);var LF=Object.defineProperty,RF=(e,t)=>LF(e,`name`,{value:t,configurable:!0}),zF=!!(typeof window<`u`&&window.document&&window.document.createElement);function BF(e,t,{checkForDefaultPrevented:n=!0}={}){return RF(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}RF(BF,`composeEventHandlers`);function VF(e){if(!zF)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}RF(VF,`getOwnerWindow`);function HF(e){if(!zF)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}RF(HF,`getOwnerDocument`);function UF(e,t=!1){let{activeElement:n}=HF(e);if(!n?.nodeName)return null;if(WF(n)&&n.contentDocument)return UF(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=HF(n).getElementById(e);if(t)return t}}return n}RF(UF,`getActiveElement`);function WF(e){return e.tagName===`IFRAME`}RF(WF,`isFrame`);var GF=globalThis?.document?R.useLayoutEffect:()=>{},KF=Object.defineProperty,qF=(e,t)=>KF(e,`name`,{value:t,configurable:!0}),JF=R.useId||(()=>void 0),YF=0;function XF(e){let[t,n]=R.useState(JF());return GF(()=>{e||n(e=>e??String(YF++))},[e]),e||(t?`radix-${t}`:``)}qF(XF,`useId`);var ZF=Object.defineProperty,QF=(e,t)=>ZF(e,`name`,{value:t,configurable:!0}),$F=R.useEffectEvent,eI=R.useInsertionEffect;function tI(e){if(typeof $F==`function`)return $F(e);let t=R.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof eI==`function`?eI(()=>{t.current=e}):GF(()=>{t.current=e}),R.useMemo(()=>((...e)=>t.current?.(...e)),[])}QF(tI,`useEffectEvent`);var nI=Object.defineProperty,rI=(e,t)=>nI(e,`name`,{value:t,configurable:!0}),iI=R.useInsertionEffect||GF;function aI({prop:e,defaultProp:t,onChange:n=rI(()=>{},`onChange`),caller:r}){let[i,a,o]=oI({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,R.useCallback(t=>{if(s){let n=sI(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}rI(aI,`useControllableState`);function oI({defaultProp:e,onChange:t}){let[n,r]=R.useState(e),i=R.useRef(n),a=R.useRef(t);return iI(()=>{a.current=t},[t]),R.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}rI(oI,`useUncontrolledState`);function sI(e){return typeof e==`function`}rI(sI,`isFunction`);var cI=Symbol(`RADIX:SYNC_STATE`);function lI(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=tI(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=R.useReducer((t,n)=>{if(n.type===cI)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=R.useRef(p);R.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=R.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return R.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:cI,state:i})},[i,d.state,c]),[h,f]}rI(lI,`useControllableStateReducer`);var uI=Object.defineProperty,dI=(e,t)=>uI(e,`name`,{value:t,configurable:!0}),fI=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=ip(`Primitive.${t}`),r=R.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,z.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function pI(e,t){e&&Bi.flushSync(()=>e.dispatchEvent(t))}dI(pI,`dispatchDiscreteCustomEvent`);var mI=Object.defineProperty,hI=(e,t)=>mI(e,`name`,{value:t,configurable:!0});function gI(e){let t=R.useRef(e);return R.useEffect(()=>{t.current=e}),R.useMemo(()=>((...e)=>t.current?.(...e)),[])}hI(gI,`useCallbackRef`);var _I=Object.defineProperty,vI=(e,t)=>_I(e,`name`,{value:t,configurable:!0}),yI=`dismissableLayer.update`,bI=`dismissableLayer.pointerDownOutside`,xI=`dismissableLayer.focusOutside`,SI,CI=R.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),wI=R.forwardRef(vI(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=R.useContext(CI),[d,f]=R.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=R.useState({}),h=tp(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=_?g.indexOf(_):-1,y=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,S=R.useRef(!1),C=DI(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:R.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return x&&!t},[u.branches,x])}),w=OI(e=>{if(r&&S.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),T=d?y===g.length-1:!1,E=gI(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return R.useEffect(()=>{if(T)return p.addEventListener(`keydown`,E,{capture:!0}),()=>p.removeEventListener(`keydown`,E,{capture:!0})},[p,T,E]),R.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(SI=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),kI(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=SI))}},[d,p,n,u]),R.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),kI())},[d,u]),R.useEffect(()=>{let e=vI(()=>m({}),`handleUpdate`);return document.addEventListener(yI,e),()=>document.removeEventListener(yI,e)},[]),(0,z.jsx)(fI.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:BF(e.onFocusCapture,w.onFocusCapture),onBlurCapture:BF(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:BF(e.onPointerDownCapture,C.onPointerDownCapture)})},`DismissableLayer`));function TI(){let e=R.useContext(CI),[t,n]=R.useState(null);return R.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}vI(TI,`useDismissableLayerSurface`);var EI=vI(()=>!0,`IS_TRUE`);function DI(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=EI}=t,s=gI(e),c=R.useRef(!1),l=R.useRef(!1),u=R.useRef(new Map),d=R.useRef(()=>{});return R.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}vI(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}vI(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}vI(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}vI(p,`handleInteractionBubble`);let m=vI(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||AI(bI,s,p,{discrete:!0})};if(vI(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:vI(()=>c.current=!0,`onPointerDownCapture`)}}vI(DI,`usePointerDownOutside`);function OI(e,t=globalThis?.document){let n=gI(e),r=R.useRef(!1);return R.useEffect(()=>{let e=vI(e=>{e.target&&!r.current&&AI(xI,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:vI(()=>r.current=!0,`onFocusCapture`),onBlurCapture:vI(()=>r.current=!1,`onBlurCapture`)}}vI(OI,`useFocusOutside`);function kI(){let e=new CustomEvent(yI);document.dispatchEvent(e)}vI(kI,`dispatchUpdate`);function AI(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?pI(i,a):i.dispatchEvent(a)}vI(AI,`handleAndDispatchCustomEvent`);var jI=Object.defineProperty,MI=(e,t)=>jI(e,`name`,{value:t,configurable:!0}),NI=`focusScope.autoFocusOnMount`,PI=`focusScope.autoFocusOnUnmount`,FI={bubbles:!1,cancelable:!0},II=R.forwardRef(MI(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=R.useState(null),l=gI(i),u=gI(a),d=R.useRef(null),f=tp(t,c),p=R.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;R.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:UI(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||UI(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&UI(s)};MI(e,`handleFocusIn`),MI(t,`handleFocusOut`),MI(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),R.useEffect(()=>{if(s){WI.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(NI,FI);s.addEventListener(NI,l),s.dispatchEvent(t),t.defaultPrevented||(LI(qI(zI(s)),{select:!0}),document.activeElement===e&&UI(s))}return()=>{s.removeEventListener(NI,l),setTimeout(()=>{let t=new CustomEvent(PI,FI);s.addEventListener(PI,u),s.dispatchEvent(t),t.defaultPrevented||UI(e??document.body,{select:!0}),s.removeEventListener(PI,u),WI.remove(p)},0)}}},[s,l,u,p]);let m=R.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=RI(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&UI(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&UI(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,z.jsx)(fI.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})},`FocusScope`));function LI(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(UI(r,{select:t}),document.activeElement!==n)return}MI(LI,`focusFirst`);function RI(e){let t=zI(e);return[BI(t,e),BI(t.reverse(),e)]}MI(RI,`getTabbableEdges`);function zI(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:MI(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}MI(zI,`getTabbableCandidates`);function BI(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):VI(r,{upTo:t})))return r}MI(BI,`findVisible`);function VI(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}MI(VI,`isHidden`);function HI(e){return e instanceof HTMLInputElement&&`select`in e}MI(HI,`isSelectableInput`);function UI(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&HI(e)&&t&&e.select()}}MI(UI,`focus`);var WI=GI();function GI(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=KI(e,t),e.unshift(t)},remove(t){e=KI(e,t),e[0]?.resume()}}}MI(GI,`createFocusScopesStack`);function KI(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}MI(KI,`arrayRemove`);function qI(e){return e.filter(e=>e.tagName!==`A`)}MI(qI,`removeLinks`);var JI=Object.defineProperty,YI=R.forwardRef(((e,t)=>JI(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=R.useState(!1);GF(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Bi.createPortal((0,z.jsx)(fI.div,{...r,ref:t}),o):null},`Portal`)),XI=Object.defineProperty,ZI=(e,t)=>XI(e,`name`,{value:t,configurable:!0});function QI(e,t){return R.useReducer((e,n)=>t[e][n]??e,e)}ZI(QI,`useStateMachine`);var $I=ZI(e=>{let{present:t,children:n}=e,r=eL(t),i=typeof n==`function`?n({present:r.isPresent}):R.Children.only(n),a=nL(r.ref,iL(i));return typeof n==`function`||r.isPresent?R.cloneElement(i,{ref:a}):null},`Presence`);function eL(e){let[t,n]=R.useState(),r=R.useRef(null),i=R.useRef(e),a=R.useRef(`none`),o=R.useRef(void 0),[s,c]=QI(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return R.useEffect(()=>{s===`mounted`?(a.current=o.current??rL(r.current),o.current=void 0):a.current=`none`},[s]),GF(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=rL(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),GF(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=ZI(a=>{let o=rL(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=ZI(e=>{e.target===t&&(a.current=rL(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:R.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=rL(t)}else r.current=null;n(e)},[])}}ZI(eL,`usePresence`);function tL(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}ZI(tL,`setRef`);function nL(...e){let t=R.useRef(e);return t.current=e,R.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=tL(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():tL(n[e],null)}}},[])}ZI(nL,`useStableComposedRefs`);function rL(e){return e?.animationName||`none`}ZI(rL,`getAnimationName`);function iL(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}ZI(iL,`getElementRef`);var aL=Object.defineProperty,oL=(e,t)=>aL(e,`name`,{value:t,configurable:!0}),sL=0,cL=null;function lL(e){return uL(),e.children}oL(lL,`FocusGuards`);function uL(){R.useEffect(()=>{cL||={start:dL(),end:dL()};let{start:e,end:t}=cL;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),sL++,()=>{sL===1&&(cL?.start.remove(),cL?.end.remove(),cL=null),sL=Math.max(0,sL-1)}},[])}oL(uL,`useFocusGuards`);function dL(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}oL(dL,`createFocusGuard`);var fL=Object.defineProperty,pL=(e,t)=>fL(e,`name`,{value:t,configurable:!0}),mL=`Dialog`,[hL,gL]=FF(mL),[_L,vL]=hL(mL),yL=pL(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=R.useRef(null),c=R.useRef(null),[l,u]=aI({prop:r,defaultProp:i??!1,onChange:a,caller:mL}),[d,f]=R.useState(0),[p,m]=R.useState(0);return(0,z.jsx)(_L,{scope:t,triggerRef:s,contentRef:c,contentId:XF(),titleId:XF(),descriptionId:XF(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:R.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),bL=`DialogTrigger`,xL=R.forwardRef(pL(function(e,t){let{__scopeDialog:n,...r}=e,i=vL(bL,n),a=tp(t,i.triggerRef);return(0,z.jsx)(fI.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":VL(i.open),...r,ref:a,onClick:BF(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),SL=`DialogPortal`,[CL,wL]=hL(SL,{forceMount:void 0}),TL=pL(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=vL(SL,t);return(0,z.jsx)(CL,{scope:t,forceMount:n,children:R.Children.map(r,e=>(0,z.jsx)($I,{present:n||a.open,children:(0,z.jsx)(YI,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),EL=`DialogOverlay`,DL=R.forwardRef(pL(function(e,t){let n=wL(EL,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=vL(EL,e.__scopeDialog);return a.modal?(0,z.jsx)($I,{present:r||a.open,children:(0,z.jsx)(kL,{...i,ref:t})}):null},`DialogOverlay`)),OL=ip(`DialogOverlay.RemoveScroll`),kL=R.forwardRef(pL(function(e,t){let{__scopeDialog:n,...r}=e,i=vL(EL,n),a=tp(t,TI());return(0,z.jsx)(uh,{as:OL,allowPinchZoom:!0,shards:[i.contentRef],children:(0,z.jsx)(fI.div,{"data-state":VL(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),AL=`DialogContent`,jL=R.forwardRef(pL(function(e,t){let n=wL(AL,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=vL(AL,e.__scopeDialog);return(0,z.jsx)($I,{present:r||a.open,children:a.modal?(0,z.jsx)(ML,{...i,ref:t}):(0,z.jsx)(NL,{...i,ref:t})})},`DialogContent`)),ML=R.forwardRef(pL(function(e,t){let n=vL(AL,e.__scopeDialog),r=R.useRef(null),i=tp(t,n.contentRef,r);return R.useEffect(()=>{let e=r.current;if(e)return tm(e)},[]),(0,z.jsx)(PL,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:BF(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:BF(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:BF(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),NL=R.forwardRef(pL(function(e,t){let n=vL(AL,e.__scopeDialog),r=R.useRef(!1),i=R.useRef(!1);return(0,z.jsx)(PL,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),PL=R.forwardRef(pL(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=vL(AL,n);return uL(),(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(II,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,z.jsx)(wI,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":VL(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),FL=`DialogTitle`,IL=R.forwardRef(pL(function(e,t){let{__scopeDialog:n,...r}=e,i=vL(FL,n),{setTitleCount:a}=i;return GF(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,z.jsx)(fI.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),LL=`DialogDescription`,RL=R.forwardRef(pL(function(e,t){let{__scopeDialog:n,...r}=e,i=vL(LL,n),{setDescriptionCount:a}=i;return GF(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,z.jsx)(fI.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),zL=`DialogClose`,BL=R.forwardRef(pL(function(e,t){let{__scopeDialog:n,...r}=e,i=vL(zL,n);return(0,z.jsx)(fI.button,{type:`button`,...r,ref:t,onClick:BF(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function VL(e){return e?`open`:`closed`}pL(VL,`getState`);var HL=Object.defineProperty,UL=(e,t)=>HL(e,`name`,{value:t,configurable:!0}),[WL,GL]=FF(`AlertDialog`,[gL]),KL=gL(),qL=UL(e=>{let{__scopeAlertDialog:t,...n}=e,r=KL(t);return(0,z.jsx)(yL,{...r,...n,modal:!0})},`AlertDialog`);R.forwardRef(UL(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=KL(n);return(0,z.jsx)(xL,{...i,...r,ref:t})},`AlertDialogTrigger`));var JL=UL(e=>{let{__scopeAlertDialog:t,...n}=e,r=KL(t);return(0,z.jsx)(TL,{...r,...n})},`AlertDialogPortal`),YL=R.forwardRef(UL(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=KL(n);return(0,z.jsx)(DL,{...i,...r,ref:t})},`AlertDialogOverlay`)),[XL,ZL]=WL(`AlertDialogContent`),QL=R.forwardRef(UL(function(e,t){let{__scopeAlertDialog:n,children:r,...i}=e,a=KL(n),o=tp(t,R.useRef(null)),s=R.useRef(null);return(0,z.jsx)(XL,{scope:n,cancelRef:s,children:(0,z.jsx)(jL,{role:`alertdialog`,...a,...i,ref:o,onOpenAutoFocus:BF(i.onOpenAutoFocus,e=>{e.preventDefault(),s.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:r})})},`AlertDialogContent`)),$L=R.forwardRef(UL(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=KL(n);return(0,z.jsx)(IL,{...i,...r,ref:t})},`AlertDialogTitle`)),eR=R.forwardRef(UL(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=KL(n);return(0,z.jsx)(RL,{...i,...r,ref:t})},`AlertDialogDescription`)),tR=R.forwardRef(UL(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=KL(n);return(0,z.jsx)(BL,{...i,...r,ref:t})},`AlertDialogAction`)),nR=`AlertDialogCancel`,rR=R.forwardRef(UL(function(e,t){let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=ZL(nR,n),a=KL(n),o=tp(t,i);return(0,z.jsx)(BL,{...a,...r,ref:o})},`AlertDialogCancel`)),iR=qL,aR=JL,oR=YL,sR=QL,cR=tR,lR=rR,uR=$L,dR=eR,fR=iR,pR=aR,mR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(oR,{ref:n,className:W(`fixed inset-0 z-50 bg-black/70 backdrop-blur-sm`,e),...t}));mR.displayName=oR.displayName;var hR=R.forwardRef(({className:e,restoreFocusTo:t,onCloseAutoFocus:n,...r},i)=>(0,z.jsxs)(pR,{children:[(0,z.jsx)(mR,{}),(0,z.jsx)(sR,{ref:i,className:W(`fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 overflow-y-auto rounded-xl bg-zinc-900 p-6 text-zinc-200 shadow-2xl ring-1 ring-white/10 outline-none max-[700px]:top-auto max-[700px]:bottom-0 max-[700px]:left-0 max-[700px]:max-h-[90dvh] max-[700px]:w-full max-[700px]:max-w-none max-[700px]:translate-x-0 max-[700px]:translate-y-0 max-[700px]:rounded-b-none max-[700px]:p-5 max-[700px]:pb-[calc(1.25rem+env(safe-area-inset-bottom))]`,e),onCloseAutoFocus:e=>{n?.(e),!e.defaultPrevented&&t?.isConnected&&(e.preventDefault(),t.focus())},...r})]}));hR.displayName=sR.displayName;function gR({className:e,...t}){return(0,z.jsx)(`div`,{className:W(`flex flex-col gap-1.5 text-left`,e),...t})}function _R({className:e,...t}){return(0,z.jsx)(`div`,{className:W(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}var vR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(uR,{ref:n,className:W(`text-balance text-xl font-semibold tracking-tight text-zinc-50 sm:text-2xl`,e),...t}));vR.displayName=uR.displayName;var yR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(dR,{ref:n,className:W(`text-base text-pretty text-zinc-400 sm:text-sm`,e),...t}));yR.displayName=dR.displayName;var bR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(cR,{ref:n,className:W(Cp(),e),...t}));bR.displayName=cR.displayName;var xR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(lR,{ref:n,className:W(Cp({variant:`outline`}),e),...t}));xR.displayName=lR.displayName;function SR({panel:e,busy:t,restoreFocusTo:n,onOpenChange:r,onConfirm:i}){return(0,z.jsx)(fR,{open:e!==null,onOpenChange:r,children:e?(0,z.jsxs)(hR,{restoreFocusTo:n,children:[(0,z.jsxs)(gR,{children:[(0,z.jsxs)(vR,{children:[`Close `,e.title,`?`]}),(0,z.jsx)(yR,{children:`This panel has saved data. Closing it permanently deletes that data, including any comments or drafts.`})]}),(0,z.jsxs)(_R,{children:[(0,z.jsx)(xR,{children:`Cancel`}),(0,z.jsx)(bR,{asChild:!0,children:(0,z.jsx)(G,{type:`button`,variant:`destructive`,disabled:t,onClick:t=>{t.preventDefault(),i(e)},children:t?`Closing…`:`Close and delete data`})})]})]}):null})}var CR=MM({source:WM(`treeport-panel-v1`),method:WM(`panel.title.set`),title:Q().nullable()}),wR=MM({source:WM(`treeport-panel-v1`),method:WM(`workspace.select`),index:vM().int().min(0).max(8)}),TR=MM({source:WM(`treeport-panel-v1`),id:Q(),method:HM([`context`,`diff`,`network.listeners`,`storage.get`,`storage.set`,`storage.delete`]),key:Q().optional(),value:gN().optional()});function ER({panel:e,active:t,title:n,reloadRevision:r,autoFocusBlocked:i,onTitleChange:a,onSelectWorkspace:o}){let s=(0,R.useRef)(null),c=(0,R.useRef)(null),l=`${e.id}:${r}`,[u,d]=(0,R.useState)(null);return(0,R.useEffect)(()=>{a(e.id,null)},[a,e.id,l]),(0,R.useEffect)(()=>{if(!t||i||u!==l)return;let e=window.requestAnimationFrame(()=>s.current?.focus());return()=>window.cancelAnimationFrame(e)},[t,i,u,l]),(0,R.useEffect)(()=>{if(!t)return;let e=e=>{e.key.toLowerCase()!==`f`||!e.metaKey&&!e.ctrlKey||e.altKey||document.querySelector(`[role="dialog"]`)||(e.preventDefault(),(s.current?.contentWindow??c.current)?.postMessage({source:`treeport-host-v1`,method:`shortcut`,shortcut:`find`},`*`))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[t]),(0,R.useEffect)(()=>{let t=t=>{let n=s.current?.contentWindow??c.current;if(t.source!==n)return;let r=CR.safeParse(t.data);if(r.success){a(e.id,r.data.title?.trim().slice(0,256)||null);return}let i=wR.safeParse(t.data);if(i.success){o(i.data.index);return}let l=TR.safeParse(t.data);if(!l.success)return;let u=l.data,{method:d}=u,f;f=d===`context`?Tf(yN.api.panels[`:panelId`].context.$get({param:{panelId:e.id}})).then(e=>e.context):d===`diff`?Tf(yN.api.panels[`:panelId`].diff.$get({param:{panelId:e.id}})).then(e=>e.diff):d===`network.listeners`?Tf(yN.api.panels[`:panelId`].network.listeners.$get({param:{panelId:e.id}})).then(e=>e.discovery):d===`storage.get`&&u.key?Tf(yN.api.panels[`:panelId`].storage.get.$post({param:{panelId:e.id},json:{key:u.key}})).then(e=>e.value):d===`storage.set`&&u.key&&u.value!==void 0?Tf(yN.api.panels[`:panelId`].storage.$put({param:{panelId:e.id},json:{key:u.key,value:u.value}})).then(()=>void 0):d===`storage.delete`&&u.key?Tf(yN.api.panels[`:panelId`].storage.$delete({param:{panelId:e.id},json:{key:u.key}})).then(()=>void 0):Promise.reject(Error(`Unsupported Treeport SDK method`)),f.then(e=>n?.postMessage({source:`treeport-host-v1`,id:u.id,ok:!0,value:e},`*`),e=>n?.postMessage({source:`treeport-host-v1`,id:u.id,ok:!1,error:ON(e)},`*`))};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[o,a,e.id]),(0,z.jsx)(R.Activity,{mode:t?`visible`:`hidden`,children:(0,z.jsx)(`main`,{className:`min-h-0 min-w-0 bg-zinc-950`,"aria-label":`${n} web panel`,children:(0,z.jsx)(`iframe`,{ref:s,title:n,src:`/api/web-panels/${encodeURIComponent(e.id)}/assets/`,sandbox:`allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads${e.sandbox.allowSameOrigin?` allow-same-origin`:``}`,allow:`clipboard-read; clipboard-write; fullscreen`,className:W(`h-full w-full border-0 bg-zinc-950`,u===l?`opacity-100`:`opacity-0`),onLoad:()=>{c.current=s.current?.contentWindow??null,d(l)}},l)})})}var DR=yL,OR=TL;function kR(e){let t=window.visualViewport;return t?(t.addEventListener(`resize`,e),t.addEventListener(`scroll`,e),()=>{t.removeEventListener(`resize`,e),t.removeEventListener(`scroll`,e)}):()=>void 0}function AR(){let e=window.visualViewport;return e?`${e.offsetTop}:${e.height}`:null}var jR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(DL,{ref:n,className:W(`fixed inset-0 z-50 bg-black/70 backdrop-blur-sm`,e),...t}));jR.displayName=DL.displayName;var MR=R.forwardRef(({className:e,children:t,restoreFocusTo:n,mobilePresentation:r=`sheet`,overlayClassName:i,onCloseAutoFocus:a,style:o,...s},c)=>{let[l,u]=R.useSyncExternalStore(kR,AR,()=>null)?.split(`:`).map(Number)??[null,null];return(0,z.jsxs)(OR,{children:[(0,z.jsx)(jR,{className:i}),(0,z.jsxs)(jL,{ref:c,className:W(`fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 overflow-y-auto rounded-xl bg-zinc-900 p-6 text-zinc-200 shadow-2xl ring-1 ring-white/10 outline-none max-[700px]:top-auto max-[700px]:bottom-0 max-[700px]:left-0 max-[700px]:max-h-[90dvh] max-[700px]:w-full max-[700px]:max-w-none max-[700px]:translate-x-0 max-[700px]:translate-y-0 max-[700px]:rounded-b-none max-[700px]:p-5 max-[700px]:pb-[calc(1.25rem+env(safe-area-inset-bottom))]`,r===`dialog`&&`keyboard-safe-dialog`,e),style:{...o,"--dialog-visual-viewport-top":r===`dialog`&&l!==null?`${l}px`:void 0,"--dialog-visual-viewport-height":r===`dialog`&&u!==null?`${u}px`:void 0},onCloseAutoFocus:e=>{a?.(e),!e.defaultPrevented&&n?.isConnected&&(e.preventDefault(),n.focus())},...s,children:[t,(0,z.jsxs)(BL,{className:`absolute top-3 right-3 inline-flex size-9 items-center justify-center rounded-md text-zinc-500 outline-none hover:bg-white/5 hover:text-zinc-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-cyan-400 disabled:pointer-events-none [&_svg]:size-4`,children:[(0,z.jsx)(Xf,{}),(0,z.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})});MR.displayName=jL.displayName;function NR({className:e,...t}){return(0,z.jsx)(`div`,{className:W(`flex flex-col gap-1.5 pr-12 text-left`,e),...t})}var PR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(IL,{ref:n,className:W(`text-balance text-xl font-semibold tracking-tight text-zinc-50 sm:text-2xl`,e),...t}));PR.displayName=IL.displayName;var FR=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(RL,{ref:n,className:W(`text-base text-pretty text-zinc-400 sm:text-sm`,e),...t}));FR.displayName=RL.displayName;function IR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M13.836 2.477a.75.75 0 0 1 .75.75v3.182a.75.75 0 0 1-.75.75h-3.182a.75.75 0 0 1 0-1.5h1.37l-.84-.841a4.5 4.5 0 0 0-7.08.932.75.75 0 0 1-1.3-.75 6 6 0 0 1 9.44-1.242l.842.84V3.227a.75.75 0 0 1 .75-.75Zm-.911 7.5A.75.75 0 0 1 13.199 11a6 6 0 0 1-9.44 1.241l-.84-.84v1.371a.75.75 0 0 1-1.5 0V9.591a.75.75 0 0 1 .75-.75H5.35a.75.75 0 0 1 0 1.5H3.98l.841.841a4.5 4.5 0 0 0 7.08-.932.75.75 0 0 1 1.025-.273Z`,clipRule:`evenodd`}))}var LR=R.forwardRef(IR);function RR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M8 14a.75.75 0 0 1-.75-.75V4.56L4.03 7.78a.75.75 0 0 1-1.06-1.06l4.5-4.5a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.75 4.56v8.69A.75.75 0 0 1 8 14Z`,clipRule:`evenodd`}))}var zR=R.forwardRef(RR);function BR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M2 3.75A.75.75 0 0 1 2.75 3h10.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 3.75ZM2 8a.75.75 0 0 1 .75-.75h10.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 8Zm0 4.25a.75.75 0 0 1 .75-.75h10.5a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1-.75-.75Z`,clipRule:`evenodd`}))}var VR=R.forwardRef(BR);function HR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{d:`M7.25 3.688a8.035 8.035 0 0 0-4.872-.523A.48.48 0 0 0 2 3.64v7.994c0 .345.342.588.679.512a6.02 6.02 0 0 1 4.571.81V3.688ZM8.75 12.956a6.02 6.02 0 0 1 4.571-.81c.337.075.679-.167.679-.512V3.64a.48.48 0 0 0-.378-.475 8.034 8.034 0 0 0-4.872.523v9.268Z`}))}var UR=R.forwardRef(HR);function WR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M12.416 3.376a.75.75 0 0 1 .208 1.04l-5 7.5a.75.75 0 0 1-1.154.114l-3-3a.75.75 0 0 1 1.06-1.06l2.353 2.353 4.493-6.74a.75.75 0 0 1 1.04-.207Z`,clipRule:`evenodd`}))}var GR=R.forwardRef(WR);function KR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06Z`,clipRule:`evenodd`}))}var qR=R.forwardRef(KR);function JR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M6.22 4.22a.75.75 0 0 1 1.06 0l3.25 3.25a.75.75 0 0 1 0 1.06l-3.25 3.25a.75.75 0 0 1-1.06-1.06L8.94 8 6.22 5.28a.75.75 0 0 1 0-1.06Z`,clipRule:`evenodd`}))}var YR=R.forwardRef(JR);function XR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M5.22 10.22a.75.75 0 0 1 1.06 0L8 11.94l1.72-1.72a.75.75 0 1 1 1.06 1.06l-2.25 2.25a.75.75 0 0 1-1.06 0l-2.25-2.25a.75.75 0 0 1 0-1.06ZM10.78 5.78a.75.75 0 0 1-1.06 0L8 4.06 6.28 5.78a.75.75 0 0 1-1.06-1.06l2.25-2.25a.75.75 0 0 1 1.06 0l2.25 2.25a.75.75 0 0 1 0 1.06Z`,clipRule:`evenodd`}))}var ZR=R.forwardRef(XR);function QR({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M6.455 1.45A.5.5 0 0 1 6.952 1h2.096a.5.5 0 0 1 .497.45l.186 1.858a4.996 4.996 0 0 1 1.466.848l1.703-.769a.5.5 0 0 1 .639.206l1.047 1.814a.5.5 0 0 1-.14.656l-1.517 1.09a5.026 5.026 0 0 1 0 1.694l1.516 1.09a.5.5 0 0 1 .141.656l-1.047 1.814a.5.5 0 0 1-.639.206l-1.703-.768c-.433.36-.928.649-1.466.847l-.186 1.858a.5.5 0 0 1-.497.45H6.952a.5.5 0 0 1-.497-.45l-.186-1.858a4.993 4.993 0 0 1-1.466-.848l-1.703.769a.5.5 0 0 1-.639-.206l-1.047-1.814a.5.5 0 0 1 .14-.656l1.517-1.09a5.033 5.033 0 0 1 0-1.694l-1.516-1.09a.5.5 0 0 1-.141-.656L2.46 3.593a.5.5 0 0 1 .639-.206l1.703.769c.433-.36.928-.65 1.466-.848l.186-1.858Zm-.177 7.567-.022-.037a2 2 0 0 1 3.466-1.997l.022.037a2 2 0 0 1-3.466 1.997Z`,clipRule:`evenodd`}))}var $R=R.forwardRef(QR);function ez({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M2 4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4Zm2.22 1.97a.75.75 0 0 0 0 1.06l.97.97-.97.97a.75.75 0 1 0 1.06 1.06l1.5-1.5a.75.75 0 0 0 0-1.06l-1.5-1.5a.75.75 0 0 0-1.06 0ZM8.75 8.5a.75.75 0 0 0 0 1.5h2.5a.75.75 0 0 0 0-1.5h-2.5Z`,clipRule:`evenodd`}))}var tz=R.forwardRef(ez);function nz({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{d:`M2 3.5A1.5 1.5 0 0 1 3.5 2h2.879a1.5 1.5 0 0 1 1.06.44l1.122 1.12A1.5 1.5 0 0 0 9.62 4H12.5A1.5 1.5 0 0 1 14 5.5v1.401a2.986 2.986 0 0 0-1.5-.401h-9c-.546 0-1.059.146-1.5.401V3.5ZM2 9.5v3A1.5 1.5 0 0 0 3.5 14h9a1.5 1.5 0 0 0 1.5-1.5v-3A1.5 1.5 0 0 0 12.5 8h-9A1.5 1.5 0 0 0 2 9.5Z`}))}var rz=R.forwardRef(nz);function iz({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{d:`M8.543 2.232a.75.75 0 0 0-1.085 0l-5.25 5.5A.75.75 0 0 0 2.75 9H4v4a1 1 0 0 0 1 1h1a1 1 0 0 0 1-1v-1a1 1 0 1 1 2 0v1a1 1 0 0 0 1 1h1a1 1 0 0 0 1-1V9h1.25a.75.75 0 0 0 .543-1.268l-5.25-5.5Z`}))}var az=R.forwardRef(iz);function oz({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M9.965 11.026a5 5 0 1 1 1.06-1.06l2.755 2.754a.75.75 0 1 1-1.06 1.06l-2.755-2.754ZM10.5 7a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0Z`,clipRule:`evenodd`}))}var sz=R.forwardRef(oz);function cz({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{d:`M8.75 3.75a.75.75 0 0 0-1.5 0v3.5h-3.5a.75.75 0 0 0 0 1.5h3.5v3.5a.75.75 0 0 0 1.5 0v-3.5h3.5a.75.75 0 0 0 0-1.5h-3.5v-3.5Z`}))}var lz=R.forwardRef(cz);function uz({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M5 3.25V4H2.75a.75.75 0 0 0 0 1.5h.3l.815 8.15A1.5 1.5 0 0 0 5.357 15h5.285a1.5 1.5 0 0 0 1.493-1.35l.815-8.15h.3a.75.75 0 0 0 0-1.5H11v-.75A2.25 2.25 0 0 0 8.75 1h-1.5A2.25 2.25 0 0 0 5 3.25Zm2.25-.75a.75.75 0 0 0-.75.75V4h3v-.75a.75.75 0 0 0-.75-.75h-1.5ZM6.05 6a.75.75 0 0 1 .787.713l.275 5.5a.75.75 0 0 1-1.498.075l-.275-5.5A.75.75 0 0 1 6.05 6Zm3.9 0a.75.75 0 0 1 .712.787l-.275 5.5a.75.75 0 0 1-1.498-.075l.275-5.5a.75.75 0 0 1 .786-.711Z`,clipRule:`evenodd`}))}var dz=R.forwardRef(uz);function fz({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{fillRule:`evenodd`,d:`M2 12V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2Zm1.5-5.5V12a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5V6.5A.5.5 0 0 0 12 6H4a.5.5 0 0 0-.5.5Zm.75-1.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM7 4a.75.75 0 1 1-1.5 0A.75.75 0 0 1 7 4Zm1.25.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Z`,clipRule:`evenodd`}))}var pz=R.forwardRef(fz);function mz({title:e,titleId:t,...n},r){return R.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?R.createElement(`title`,{id:t},e):null,R.createElement(`path`,{d:`M5.28 4.22a.75.75 0 0 0-1.06 1.06L6.94 8l-2.72 2.72a.75.75 0 1 0 1.06 1.06L8 9.06l2.72 2.72a.75.75 0 1 0 1.06-1.06L9.06 8l2.72-2.72a.75.75 0 0 0-1.06-1.06L8 6.94 5.28 4.22Z`}))}var hz=R.forwardRef(mz);function gz({children:e}){return(0,z.jsx)(`div`,{className:`grid gap-2`,children:e})}function _z({className:e,type:t,...n}){return(0,z.jsx)(`input`,{type:t,"data-slot":`input`,className:W(`h-11 w-full rounded-md bg-zinc-950/70 px-3 py-2 text-base text-zinc-100 ring-1 ring-white/12 outline-none transition-shadow placeholder:text-zinc-600 focus-visible:ring-2 focus-visible:ring-cyan-400 disabled:cursor-not-allowed disabled:opacity-50 sm:h-9 sm:text-sm`,e),...n})}function vz({className:e,...t}){return(0,z.jsx)(`label`,{"data-slot":`label`,className:W(`flex text-base font-medium text-zinc-300 sm:text-sm`,e),...t})}function yz({onOpened:e}){let t=(0,R.useRef)(null),[n,r]=(0,R.useState)(`~`),[i,a]=(0,R.useState)(`~`),[o,s]=(0,R.useState)(!1);(0,R.useEffect)(()=>{let e=window.setTimeout(()=>a(n.trim()),250);return()=>window.clearTimeout(e)},[n]);let c=dt({queryKey:[`filesystem-directories`,i,o],queryFn:()=>{let e={input:i};return o&&(e.hidden=`true`),Tf(yN.api.filesystem.directories.$get({query:e}))},enabled:!!i,retry:!1}),l=pt({mutationFn:async e=>(await Tf(yN.api.projects.$post({json:{path:e}}))).project,onSuccess:e,onError:(e,t)=>{DF(e,{operation:`open project at “${t}”`})}}),u=n.trim()===i,d=u&&!c.isError&&c.data?.input===i?c.data:void 0,f=u&&c.isSuccess&&!c.isFetching&&d?.exact&&d.repository.state===`valid`?d.repository:null,p=l.isPending,m=e=>{r(e),a(e),window.requestAnimationFrame(()=>t.current?.focus())};return(0,z.jsxs)(`form`,{className:`flex flex-col gap-3 max-[700px]:gap-4`,onSubmit:e=>{e.preventDefault(),!(!f||p)&&l.mutate(f.repositoryPath)},children:[(0,z.jsxs)(gz,{children:[(0,z.jsx)(vz,{htmlFor:`repository-path`,children:`Server folder`}),(0,z.jsx)(_z,{ref:t,id:`repository-path`,name:`repository-path`,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`Enter`&&!f){e.preventDefault(),a(n.trim());return}if(e.key===`ArrowDown`){let t=document.querySelector(`#project-directory-list button`);t&&(e.preventDefault(),t.focus());return}e.key===`Escape`&&d&&n.trim()!==d.directory.path&&(e.preventDefault(),e.stopPropagation(),m(d.directory.path))}},placeholder:`/Users/you/Projects/example`,"aria-label":`Server folder path`,"aria-describedby":`repository-path-status`,"aria-invalid":c.isError,autoFocus:!0,disabled:p})]}),(0,z.jsx)(`div`,{className:`flex min-h-8 flex-wrap items-center gap-2 min-[701px]:min-h-7`,children:d&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(G,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(d.directory.homePath),disabled:p,children:[(0,z.jsx)(az,{"data-icon":`inline-start`}),`Home`]}),(0,z.jsx)(G,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(d.directory.rootPath),disabled:p,children:`Root`}),(0,z.jsxs)(`label`,{className:`ml-auto flex cursor-pointer items-center gap-2 text-base text-zinc-400 min-[701px]:text-sm`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),disabled:p}),`Show hidden folders`]})]})}),(0,z.jsxs)(`div`,{className:`overflow-hidden rounded-lg bg-zinc-950/50 ring-1 ring-white/10`,children:[(0,z.jsx)(`div`,{className:`flex min-h-10 items-center gap-1 overflow-x-auto border-b border-white/8 px-2 py-1.5 min-[701px]:min-h-8 min-[701px]:p-1`,children:d&&(0,z.jsxs)(z.Fragment,{children:[d.directory.parentPath&&(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Parent folder`,onClick:()=>m(d.directory.parentPath),disabled:p,children:(0,z.jsx)(zR,{})}),d.directory.breadcrumbs.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t>0&&(0,z.jsx)(YR,{className:`size-3.5 shrink-0 fill-zinc-600`}),(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`max-w-48`,title:e.path,onClick:()=>m(e.path),disabled:p,children:(0,z.jsx)(`span`,{className:`truncate`,children:e.name})})]},e.path))]})}),(0,z.jsxs)(`div`,{id:`project-directory-list`,className:`grid h-64 content-start gap-0.5 overflow-y-auto p-1.5 min-[701px]:h-56 min-[701px]:p-1 [scrollbar-color:var(--color-zinc-700)_transparent]`,"aria-label":`Folders`,children:[c.isFetching&&(0,z.jsx)(`p`,{className:`form-note p-3`,role:`status`,children:`Looking for folders…`}),c.isError&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 p-3`,children:[(0,z.jsx)(`p`,{className:`text-base text-rose-300 min-[701px]:text-sm`,role:`alert`,children:ON(c.error)}),(0,z.jsx)(G,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>c.refetch(),children:`Retry`})]}),!c.isFetching&&d?.directory.entries.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-2 rounded-md px-2.5 py-2 text-left text-base text-zinc-200 outline-none hover:bg-white/6 focus-visible:bg-white/6 focus-visible:outline-2 focus-visible:outline-cyan-400 min-[701px]:px-2 min-[701px]:py-1.5 min-[701px]:text-sm`,title:e.path,onClick:()=>m(e.path),onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),t.current?.focus();return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let n=[...document.querySelectorAll(`#project-directory-list button`)],r=n.indexOf(e.currentTarget),i=e.key===`ArrowDown`?Math.min(r+1,n.length-1):r-1;i>=0?n[i]?.focus():t.current?.focus()},disabled:p,children:[(0,z.jsx)(rz,{className:`size-4 shrink-0 fill-cyan-500/80`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),!c.isFetching&&d&&d.directory.entries.length===0&&(0,z.jsx)(`p`,{className:`form-note p-3`,role:`status`,children:d.exact?`This folder has no subfolders.`:`No matching folders.`}),d?.directory.truncated&&(0,z.jsx)(`p`,{className:`form-note p-3`,role:`status`,children:`More folders are available. Type more of the path to narrow the list.`})]})]}),(0,z.jsx)(`p`,{id:`repository-path-status`,className:W(`form-note min-h-5 truncate`,d?.repository.state===`valid`?`text-emerald-300`:c.isError||d?.repository.state===`not-repository`?`text-rose-300`:void 0),title:d?.repository.state===`valid`?d.repository.repositoryPath:void 0,"aria-live":`polite`,children:i?c.isFetching||!u?`Checking folder…`:c.isError?ON(c.error):d?.repository.state===`valid`?`Will open repository: ${d.repository.repositoryPath}`:d?.repository.message:`Enter a folder path on the Treeport server.`}),(0,z.jsx)(G,{type:`submit`,className:`self-end`,disabled:!f||p,children:p?`Opening…`:`Open project`})]})}function bz({open:e,onOpenChange:t,restoreFocusTo:n,onOpened:r}){return(0,z.jsx)(DR,{open:e,onOpenChange:t,children:(0,z.jsxs)(MR,{className:`max-w-xl gap-3 p-4 max-[700px]:gap-4`,restoreFocusTo:n,children:[(0,z.jsxs)(NR,{children:[(0,z.jsx)(PR,{className:`text-lg tracking-normal sm:text-lg`,children:`Open project`}),(0,z.jsx)(FR,{children:`Browse folders on the Treeport server.`})]}),(0,z.jsx)(yz,{onOpened:r})]})})}var xz=[`projects`],Sz=[`recent-projects`],Cz=[`terminal-presets`],wz=ft({queryKey:xz,queryFn:async()=>(await Tf(yN.api.projects.$get())).projects,staleTime:kf,refetchInterval:5e3,refetchOnReconnect:!0,refetchOnWindowFocus:!0}),Tz=ft({queryKey:Sz,queryFn:async()=>(await Tf(yN.api.projects.recent.$get())).projects}),Ez=ft({queryKey:Cz,queryFn:async()=>(await Tf(yN.api[`terminal-presets`].$get())).presets,staleTime:0,refetchInterval:5e3,refetchOnReconnect:!0,refetchOnWindowFocus:!0}),Dz=e=>ft({queryKey:[`terminal-preset-definitions`,e?.worktreeId??e?.projectId??`global`],queryFn:async()=>{let t={};return e?.projectId&&(t.projectId=e.projectId),e?.worktreeId&&(t.worktreeId=e.worktreeId),await Tf(yN.api[`terminal-preset-definitions`].$get({query:t}))},staleTime:0,refetchInterval:5e3,refetchOnReconnect:!0,refetchOnWindowFocus:!0});function Oz(){let e=Ri(),t=cf();return(0,R.useCallback)((n,r=!1,i=!0)=>{switch(n.kind===`terminal`&&t(n.terminalId,i),n.kind){case`root`:return e({to:`/`,replace:r});case`project`:return e({to:`/projects/$projectId`,params:{projectId:n.projectId},replace:r});case`worktree`:return e({to:`/projects/$projectId/worktrees/$worktreeId`,params:{projectId:n.projectId,worktreeId:n.worktreeId},replace:r});case`terminal`:return e({to:`/projects/$projectId/worktrees/$worktreeId/terminals/$terminalId`,params:{projectId:n.projectId,worktreeId:n.worktreeId,terminalId:n.terminalId},replace:r});case`panel`:return e({to:`/projects/$projectId/worktrees/$worktreeId/panels/$panelId`,params:{projectId:n.projectId,worktreeId:n.worktreeId,panelId:n.panelId},replace:r})}},[e,t])}function kz({projects:e,selectedProject:t,targetForProject:n,projectSwitcherTriggerRef:r,closeProjectUi:i,openedProjectUi:a}){let o=Ye(),s=Ca(),c=Oz(),l=pt({mutationFn:e=>Tf(yN.api.projects[`:projectId`].close.$post({param:{projectId:e.id}})),onSuccess:async(a,s)=>{let l=o.getQueryData(xz)??e,u=l.filter(e=>e.id!==s.id),d=l.findIndex(e=>e.id===s.id),f=u[Math.min(Math.max(d,0),u.length-1)]??null,p=t?.id===s.id;p&&(await c(f?n(f):{kind:`root`,pathname:`/`},!0),i()),o.setQueryData(xz,u);for(let e of s.worktrees.flatMap(e=>e.terminals))qP.forget(e.id);await Promise.all([o.invalidateQueries({queryKey:xz}),o.invalidateQueries({queryKey:Sz})]),(p||!u.length)&&window.requestAnimationFrame(()=>r.current?.focus())},onError:(e,t)=>{DF(e,{operation:`close project “${t.name}”`}),DN(e).code===`PROJECT_CLOSE_FAILED`&&o.invalidateQueries({queryKey:xz})}});return{closingProjectId:l.isPending?l.variables?.id??null:null,requestProjectClose:e=>{let t=e.worktrees.reduce((e,t)=>e+t.terminals.length,0);t>0&&!window.confirm(`Close “${e.name}”? This will terminate ${t} Treeport terminal ${t===1?`session and its process`:`sessions and their processes`}. Git worktrees and files will remain on disk, and you can reopen the project from Recent projects.`)||l.mutate(e)},projectOpened:async(t,r=!0)=>{let i=e.length===0&&s.pathname===`/`;o.setQueryData(xz,e=>[...(e??[]).filter(e=>e.id!==t.id),t]),o.setQueryData(Sz,e=>e?.filter(e=>e.id!==t.id)),await c(n(t),i,r),await Promise.all([o.invalidateQueries({queryKey:xz}),o.invalidateQueries({queryKey:Sz})]),a()}}}function Az({program:e,progress:t,attention:n,exited:r,className:i,title:a}){let o=t!==null&&!n&&t.state!==`paused`&&t.state!==`error`,s=n?`text-amber-300`:t?.state===`error`?`text-rose-300`:t?.state===`paused`?`text-amber-300`:r&&!t?`text-rose-300`:o?`text-cyan-400`:`text-zinc-500`;return(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,className:W(`shrink-0 overflow-visible`,i),"aria-hidden":!a||void 0,children:[a?(0,z.jsx)(`title`,{children:a}):null,(0,z.jsx)(`g`,{className:W(`origin-center transition-[color,transform] duration-500`,s,o&&`scale-[0.62]`),children:e===`pi`?(0,z.jsxs)(`svg`,{viewBox:`0 0 800 800`,width:`24`,height:`24`,children:[(0,z.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M165.29 165.29H517.36V400H400V517.36H282.65V634.72H165.29ZM282.65 282.65V400H400V282.65Z`}),(0,z.jsx)(`path`,{fill:`currentColor`,d:`M517.36 400H634.72V634.72H517.36Z`})]}):e===`claude`?(0,z.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`,d:`M20.998 10.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6 10.949h1.488V8.102H6v2.847zm10.51 0H18V8.102h-1.49v2.847z`}):e===`codex`?(0,z.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`,d:`M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z`}):(0,z.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`polyline`,{points:`4 17 10 11 4 5`}),(0,z.jsx)(`line`,{x1:`12`,y1:`19`,x2:`20`,y2:`19`})]})}),(0,z.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,className:`text-cyan-400`,children:[(0,z.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`5`,className:W(`opacity-0 transition-opacity duration-500`,o&&`opacity-25`)}),(0,z.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`5`,pathLength:`100`,strokeDasharray:`30 70`,className:W(`opacity-0 transition-opacity duration-500`,o&&`animate-comet opacity-100 motion-reduce:animate-none`)})]})]})}var jz=Object.defineProperty,Mz=(e,t)=>jz(e,`name`,{value:t,configurable:!0}),Nz=`horizontal`,Pz=[`horizontal`,`vertical`],Fz=R.forwardRef(Mz(function(e,t){let{decorative:n,orientation:r=Nz,...i}=e,a=Iz(r)?r:Nz,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,z.jsx)(fI.div,{"data-orientation":a,...o,...i,ref:t})},`Separator`));function Iz(e){return Pz.includes(e)}Mz(Iz,`isValidOrientation`);var Lz=Fz,Rz=R.forwardRef(({className:e,orientation:t=`horizontal`,decorative:n=!0,...r},i)=>(0,z.jsx)(Lz,{ref:i,decorative:n,orientation:t,className:W(`shrink-0 bg-border`,t===`horizontal`?`h-[1px] w-full`:`h-full w-[1px]`,e),...r}));Rz.displayName=Lz.displayName;var zz=`(max-width: 700px)`;function Bz(e){let t=window.matchMedia(zz);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function Vz(){return window.matchMedia(zz).matches}function Hz(){return(0,R.useSyncExternalStore)(Bz,Vz,()=>!1)}var Uz=yL,Wz=TL,Gz=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(DL,{className:W(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t,ref:n}));Gz.displayName=DL.displayName;var Kz=bp(`fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out`,{variants:{side:{top:`inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,bottom:`inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,left:`inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm`,right:`inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm`}},defaultVariants:{side:`right`}}),qz=R.forwardRef(({side:e=`right`,className:t,children:n,showCloseButton:r=!0,...i},a)=>(0,z.jsxs)(Wz,{children:[(0,z.jsx)(Gz,{}),(0,z.jsxs)(jL,{ref:a,className:W(Kz({side:e}),t),...i,children:[r?(0,z.jsxs)(BL,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,z.jsx)(Xf,{className:`size-4`}),(0,z.jsx)(`span`,{className:`sr-only`,children:`Close`})]}):null,n]})]}));qz.displayName=jL.displayName;var Jz=({className:e,...t})=>(0,z.jsx)(`div`,{className:W(`flex flex-col gap-2 text-center sm:text-left`,e),...t});Jz.displayName=`SheetHeader`;var Yz=({className:e,...t})=>(0,z.jsx)(`div`,{className:W(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t});Yz.displayName=`SheetFooter`;var Xz=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(IL,{ref:n,className:W(`text-lg font-semibold text-foreground`,e),...t}));Xz.displayName=IL.displayName;var Zz=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(RL,{ref:n,className:W(`text-sm text-muted-foreground`,e),...t}));Zz.displayName=RL.displayName;function Qz({className:e,...t}){return(0,z.jsx)(`div`,{className:W(`animate-pulse rounded-md bg-primary/10`,e),...t})}var $z=`16rem`,eB=`min(88vw, 21rem)`,tB=`3rem`,nB=R.createContext(null);function rB(){let e=R.useContext(nB);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}var iB=R.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o},s)=>{let c=Hz(),[l,u]=R.useState(!1),d=R.useRef(null),f=R.useRef(!1),p=R.useCallback(e=>{u(t=>{let n=e instanceof Function?e(t):e;return!t&&n&&(d.current=document.activeElement instanceof HTMLElement?document.activeElement:null),n})},[]),m=R.useCallback(()=>{f.current=!0,u(!1)},[]),[h,g]=R.useState(e),_=t??h,v=R.useCallback(e=>{let t=e instanceof Function?e(_):e;n?n(t):g(t)},[n,_]),y=R.useCallback(()=>{c&&p(e=>!e)},[c,p]),b=_?`expanded`:`collapsed`,x=R.useMemo(()=>({state:b,open:_,setOpen:v,isMobile:c,openMobile:l,setOpenMobile:p,mobileRestoreFocusRef:d,skipMobileFocusRestoreRef:f,closeMobileWithoutFocusRestore:m,toggleSidebar:y}),[b,_,v,c,l,p,y]);return(0,z.jsx)(nB.Provider,{value:x,children:(0,z.jsx)(ef,{delayDuration:0,children:(0,z.jsx)(`div`,{style:{"--sidebar-width":$z,"--sidebar-width-icon":tB,...i},className:W(`group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar`,r),ref:s,...o,children:a})})})});iB.displayName=`SidebarProvider`;var aB=R.forwardRef(({side:e=`left`,variant:t=`sidebar`,collapsible:n=`offcanvas`,className:r,children:i,mobileTitle:a=`Sidebar`,mobileDescription:o=`Displays the mobile sidebar.`,...s},c)=>{let{isMobile:l,state:u,openMobile:d,setOpenMobile:f,mobileRestoreFocusRef:p,skipMobileFocusRestoreRef:m}=rB();return l?(0,z.jsx)(Uz,{open:d,onOpenChange:f,children:(0,z.jsxs)(qz,{"data-sidebar":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width-mobile) bg-zinc-900/95 p-0 text-zinc-100 backdrop-blur-xl`,style:{"--sidebar-width-mobile":eB},side:e,showCloseButton:!1,onCloseAutoFocus:e=>{e.preventDefault(),m.current?m.current=!1:p.current?.isConnected&&p.current.focus()},children:[(0,z.jsxs)(Jz,{className:`sr-only`,children:[(0,z.jsx)(Xz,{children:a}),(0,z.jsx)(Zz,{children:o})]}),(0,z.jsx)(`div`,{ref:c,className:W(`flex h-full w-full flex-col`,r),...s,children:i})]})}):n===`none`?(0,z.jsx)(`div`,{className:W(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),ref:c,...s,children:i}):(0,z.jsxs)(`div`,{ref:c,className:`group peer hidden text-sidebar-foreground min-[701px]:block`,"data-state":u,"data-collapsible":u===`collapsed`?n:``,"data-variant":t,"data-side":e,children:[(0,z.jsx)(`div`,{className:W(`relative w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,t===`floating`||t===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]`:`group-data-[collapsible=icon]:w-[--sidebar-width-icon]`)}),(0,z.jsx)(`div`,{className:W(`fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear min-[701px]:flex`,e===`left`?`left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]`:`right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]`,t===`floating`||t===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]`:`group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l`,r),...s,children:(0,z.jsx)(`div`,{"data-sidebar":`sidebar`,className:`flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow`,children:i})})]})});aB.displayName=`Sidebar`;var oB=R.forwardRef(({className:e,onClick:t,children:n,...r},i)=>{let{toggleSidebar:a}=rB();return(0,z.jsxs)(G,{ref:i,"data-sidebar":`trigger`,variant:`ghost`,size:`icon`,className:W(`size-7`,e),onClick:e=>{t?.(e),a()},...r,children:[n??(0,z.jsx)(Yf,{}),r[`aria-label`]?null:(0,z.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`})]})});oB.displayName=`SidebarTrigger`;var sB=R.forwardRef(({className:e,...t},n)=>{let{toggleSidebar:r}=rB();return(0,z.jsx)(`button`,{ref:n,"data-sidebar":`rail`,"aria-label":`Toggle Sidebar`,tabIndex:-1,onClick:r,title:`Toggle Sidebar`,className:W(`absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 min-[701px]:flex`,`[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,e),...t})});sB.displayName=`SidebarRail`;var cB=R.forwardRef(({className:e,asChild:t=!1,...n},r)=>(0,z.jsx)(t?ap:`main`,{ref:r,className:W(`relative flex w-full flex-1 flex-col bg-background`,`min-[701px]:peer-data-[variant=inset]:m-2 min-[701px]:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 min-[701px]:peer-data-[variant=inset]:ml-0 min-[701px]:peer-data-[variant=inset]:rounded-xl min-[701px]:peer-data-[variant=inset]:shadow`,e),...n}));cB.displayName=`SidebarInset`;var lB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(_z,{ref:n,"data-sidebar":`input`,className:W(`h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring`,e),...t}));lB.displayName=`SidebarInput`;var uB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`div`,{ref:n,"data-sidebar":`header`,className:W(`flex flex-col gap-2 p-2`,e),...t}));uB.displayName=`SidebarHeader`;var dB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`div`,{ref:n,"data-sidebar":`footer`,className:W(`flex flex-col gap-2 p-2`,e),...t}));dB.displayName=`SidebarFooter`;var fB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(Rz,{ref:n,"data-sidebar":`separator`,className:W(`mx-2 w-auto bg-sidebar-border`,e),...t}));fB.displayName=`SidebarSeparator`;var pB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`div`,{ref:n,"data-sidebar":`content`,className:W(`flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,e),...t}));pB.displayName=`SidebarContent`;var mB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`div`,{ref:n,"data-sidebar":`group`,className:W(`relative flex w-full min-w-0 flex-col p-2`,e),...t}));mB.displayName=`SidebarGroup`;var hB=R.forwardRef(({className:e,asChild:t=!1,...n},r)=>(0,z.jsx)(t?ap:`div`,{ref:r,"data-sidebar":`group-label`,className:W(`flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,`group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0`,e),...n}));hB.displayName=`SidebarGroupLabel`;var gB=R.forwardRef(({className:e,asChild:t=!1,...n},r)=>(0,z.jsx)(t?ap:`button`,{ref:r,"data-sidebar":`group-action`,className:W(`absolute right-3 top-3.5 flex size-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,`after:absolute after:-inset-2 after:min-[701px]:hidden`,`group-data-[collapsible=icon]:hidden`,e),...n}));gB.displayName=`SidebarGroupAction`;var _B=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`div`,{ref:n,"data-sidebar":`group-content`,className:W(`w-full text-sm`,e),...t}));_B.displayName=`SidebarGroupContent`;var vB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`ul`,{ref:n,"data-sidebar":`menu`,className:W(`flex w-full min-w-0 flex-col gap-1`,e),...t}));vB.displayName=`SidebarMenu`;var yB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`li`,{ref:n,"data-sidebar":`menu-item`,className:W(`group/menu-item relative`,e),...t}));yB.displayName=`SidebarMenuItem`;var bB=bp(`peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0`,{variants:{variant:{default:`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:!p-0`}},defaultVariants:{variant:`default`,size:`default`}}),xB=R.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n=`default`,size:r=`default`,tooltip:i,className:a,...o},s)=>{let c=e?ap:`button`,{isMobile:l,state:u}=rB(),d=(0,z.jsx)(c,{ref:s,"data-sidebar":`menu-button`,"data-size":r,"data-active":t,className:W(bB({variant:n,size:r}),a),...o});if(!i)return d;let f=Q().safeParse(i),p;return p=f.success?{children:f.data}:i,(0,z.jsxs)(tf,{children:[(0,z.jsx)(nf,{asChild:!0,children:d}),(0,z.jsx)(rf,{side:`right`,align:`center`,hidden:u!==`collapsed`||l,...p})]})});xB.displayName=`SidebarMenuButton`;var SB=R.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>(0,z.jsx)(t?ap:`button`,{ref:i,"data-sidebar":`menu-action`,className:W(`absolute right-1 top-1.5 flex size-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0`,`after:absolute after:-inset-2 after:min-[701px]:hidden`,`peer-data-[size=sm]/menu-button:top-1`,`peer-data-[size=default]/menu-button:top-1.5`,`peer-data-[size=lg]/menu-button:top-2.5`,`group-data-[collapsible=icon]:hidden`,n&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground min-[701px]:opacity-0`,e),...r}));SB.displayName=`SidebarMenuAction`;var CB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`div`,{ref:n,"data-sidebar":`menu-badge`,className:W(`pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground`,`peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground`,`peer-data-[size=sm]/menu-button:top-1`,`peer-data-[size=default]/menu-button:top-1.5`,`peer-data-[size=lg]/menu-button:top-2.5`,`group-data-[collapsible=icon]:hidden`,e),...t}));CB.displayName=`SidebarMenuBadge`;var wB=R.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{let i=R.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return(0,z.jsxs)(`div`,{ref:r,"data-sidebar":`menu-skeleton`,className:W(`flex h-8 items-center gap-2 rounded-md px-2`,e),...n,children:[t&&(0,z.jsx)(Qz,{className:`size-4 rounded-md`,"data-sidebar":`menu-skeleton-icon`}),(0,z.jsx)(Qz,{className:`h-4 max-w-[--skeleton-width] flex-1`,"data-sidebar":`menu-skeleton-text`,style:{"--skeleton-width":i}})]})});wB.displayName=`SidebarMenuSkeleton`;var TB=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(`ul`,{ref:n,"data-sidebar":`menu-sub`,className:W(`mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5`,`group-data-[collapsible=icon]:hidden`,e),...t}));TB.displayName=`SidebarMenuSub`;var EB=R.forwardRef(({...e},t)=>(0,z.jsx)(`li`,{ref:t,...e}));EB.displayName=`SidebarMenuSubItem`;var DB=R.forwardRef(({asChild:e=!1,size:t=`md`,isActive:n,className:r,...i},a)=>(0,z.jsx)(e?ap:`a`,{ref:a,"data-sidebar":`menu-sub-button`,"data-size":t,"data-active":n,className:W(`flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,`data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground`,t===`sm`&&`text-xs`,t===`md`&&`text-sm`,`group-data-[collapsible=icon]:hidden`,r),...i}));DB.displayName=`SidebarMenuSubButton`;function OB({label:e,tooltip:t=e,className:n,disabled:r,keyShortcuts:i,onClick:a,children:o}){return(0,z.jsxs)(tf,{children:[(0,z.jsx)(nf,{asChild:!0,children:(0,z.jsxs)(G,{type:`button`,variant:`ghost`,size:`icon-sm`,className:n,"aria-label":e,"aria-keyshortcuts":i,disabled:r,onClick:e=>a(e.currentTarget),children:[o,(0,z.jsx)(`span`,{className:`touch-target`,"aria-hidden":`true`})]})}),(0,z.jsx)(rf,{side:`top`,children:t})]})}var kB=240,AB=420,jB=272,MB=`treeport-sidebar-width`,NB=(0,R.createContext)(null),PB=(0,R.createContext)(null);function FB(e){return Math.min(AB,Math.max(kB,e))}function IB(){let e=(0,R.useContext)(NB);if(!e)throw Error(`useProjectSwitcher must be used within WorkspaceShell.`);return e}function LB({children:e}){let[t,n]=(0,R.useState)(!1),r=(0,R.useRef)(null),i=(0,R.useRef)(!1),[a,o]=(0,R.useState)(()=>{let e=Number.parseInt(localStorage.getItem(MB)??``,10);return Number.isFinite(e)?FB(e):jB}),[s,c]=(0,R.useState)(!1);return(0,z.jsx)(NB.Provider,{value:{open:t,setOpen:n,triggerRef:r,dismissedIntoTerminalRef:i},children:(0,z.jsx)(PB.Provider,{value:{width:a,resizing:s,setWidth:e=>{let t=FB(e);o(t),localStorage.setItem(MB,String(t))},setResizing:c},children:(0,z.jsx)(iB,{className:W(`app-frame isolate grid min-h-0 grid-cols-[var(--sidebar-width)_minmax(0,1fr)] bg-zinc-950 max-[700px]:grid-cols-1 max-[700px]:grid-rows-[3.25rem_minmax(0,1fr)]`,s&&`select-none`),style:{"--sidebar-width":`${a}px`,"--sidebar-width-mobile":`min(88vw, 21rem)`},children:e})})})}function RB({children:e}){let{isMobile:t,openMobile:n}=rB(),r=IB();return(0,z.jsx)(cB,{asChild:!0,children:(0,z.jsx)(`div`,{className:`grid min-h-0 min-w-0 grid-rows-[minmax(0,1fr)] overflow-hidden bg-zinc-950`,inert:t&&n?!0:void 0,"aria-hidden":t&&n?!0:void 0,onPointerDownCapture:()=>{r.open&&(r.dismissedIntoTerminalRef.current=!0,r.setOpen(!1))},children:e})})}function zB(){let e=(0,R.useContext)(PB),t=(0,R.useRef)(null);if(!e)throw Error(`ResizableSidebarRail must be used within WorkspaceShell.`);let n=n=>{n.button===0&&(t.current={pointerX:n.clientX,width:e.width},n.currentTarget.setPointerCapture(n.pointerId),e.setResizing(!0))},r=n=>{t.current&&e.setWidth(t.current.width+n.clientX-t.current.pointerX)},i=n=>{t.current=null,n.currentTarget.hasPointerCapture(n.pointerId)&&n.currentTarget.releasePointerCapture(n.pointerId),e.setResizing(!1)};return(0,z.jsx)(`div`,{className:W(`absolute inset-y-0 right-0 z-20 hidden w-3 translate-x-1/2 touch-none cursor-col-resize outline-none before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-white/8 after:absolute after:top-1/2 after:left-1/2 after:h-8 after:w-1 after:-translate-1/2 after:rounded-full after:bg-zinc-700 hover:before:w-0.5 hover:before:bg-cyan-400/60 hover:after:bg-cyan-400 focus-visible:before:w-0.5 focus-visible:before:bg-cyan-400 focus-visible:after:bg-cyan-400 min-[701px]:block`,e.resizing&&`before:w-0.5 before:bg-cyan-400`),role:`separator`,"aria-label":`Resize sidebar`,"aria-orientation":`vertical`,"aria-controls":`worktree-sidebar`,"aria-valuemin":kB,"aria-valuemax":AB,"aria-valuenow":e.width,"aria-valuetext":`${e.width} pixels`,title:`Drag to resize; double-click to reset`,tabIndex:0,onPointerDown:n,onPointerMove:r,onPointerUp:i,onPointerCancel:i,onKeyDown:t=>{let n=e.width;if(t.key===`ArrowLeft`)n-=t.shiftKey?32:16;else if(t.key===`ArrowRight`)n+=t.shiftKey?32:16;else if(t.key===`Home`)n=kB;else if(t.key===`End`)n=AB;else return;t.preventDefault(),e.setWidth(n)},onDoubleClick:()=>e.setWidth(jB)})}function BB({blocked:e}){let t=/Mac|iPhone|iPad|iPod/.test(navigator.platform),{isMobile:n,setOpenMobile:r}=rB(),i=IB();return(0,R.useEffect)(()=>{let a=a=>{let o=t?a.metaKey&&!a.ctrlKey:a.ctrlKey&&!a.metaKey;a.isComposing||a.key.toLocaleLowerCase()!==`p`||!a.shiftKey||a.altKey||!o||e||(a.preventDefault(),a.stopPropagation(),n?(r(!0),window.requestAnimationFrame(()=>i.setOpen(!0))):i.setOpen(!0))};return document.addEventListener(`keydown`,a,!0),()=>document.removeEventListener(`keydown`,a,!0)},[e,n,i.setOpen,r]),null}function VB({projects:e,activeProject:t,closingProjectId:n,onSelectProject:r,onProjectOpened:i,onRequestProjectClose:a,onOpenProjectDialog:o}){let s=/Mac|iPhone|iPad|iPod/.test(navigator.platform),{isMobile:c}=rB(),l=IB(),{attention:u,progress:d}=aF(),[f,p]=(0,R.useState)(``),[m,h]=(0,R.useState)(null),g=dt({...Tz,enabled:l.open}),_=pt({mutationFn:async e=>(await Tf(yN.api.projects[`:projectId`].open.$post({param:{projectId:e.id}}))).project,onSuccess:i,onError:(e,t)=>{DF(e,{operation:`reopen project “${t.name}”`})}}),v=e=>{r(e),p(``),h(null)},y=e=>{_.mutate(e),p(``),h(null)},b=f.trim().toLocaleLowerCase(),x=e.filter(e=>!b||e.name.toLocaleLowerCase().includes(b)||e.repositoryPath.toLocaleLowerCase().includes(b)),S=new Set(e.map(e=>e.id)),C=(g.data??[]).filter(e=>!S.has(e.id)),w=C.filter(e=>!b||e.name.toLocaleLowerCase().includes(b)||e.repositoryPath.toLocaleLowerCase().includes(b)),T=[...x.map(e=>({kind:`open`,project:e})),...w.map(e=>({kind:`recent`,project:e}))],E=T.find(e=>e.project.id===m)??T[0]??null;return(0,z.jsxs)(Vh,{open:l.open,onOpenChange:e=>{l.setOpen(e),h(null),p(``)},children:[(0,z.jsx)(Hh,{asChild:!0,children:(0,z.jsxs)(G,{ref:l.triggerRef,type:`button`,variant:`ghost`,className:`h-11 min-w-0 flex-1 justify-start gap-2 px-2 text-base text-zinc-100 hover:bg-white/5 min-[701px]:h-8 min-[701px]:text-sm`,"aria-label":t?`Switch project, current project ${t.name}`:`Open project`,"aria-keyshortcuts":s?`Meta+Shift+P`:`Control+Shift+P`,title:`${t?.repositoryPath??`Open project`} — ${s?`⌘⇧P`:`Ctrl+Shift+P`}`,children:[(0,z.jsx)(`span`,{className:`truncate font-medium`,children:t?.name??`Open project`}),(0,z.jsx)(ZR,{className:`ml-auto shrink-0 fill-zinc-600`,"data-icon":`inline-end`})]})}),(0,z.jsxs)(Uh,{align:`start`,portalled:!c,className:`grid w-[min(17rem,calc(100vw-1rem))] gap-1 p-1 min-[701px]:w-60`,onOpenAutoFocus:e=>{c&&e.preventDefault()},onCloseAutoFocus:e=>{l.dismissedIntoTerminalRef.current&&(e.preventDefault(),l.dismissedIntoTerminalRef.current=!1)},children:[(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(sz,{className:`pointer-events-none absolute top-1/2 left-2 size-4 -translate-y-1/2 fill-zinc-600`}),(0,z.jsx)(_z,{name:`project-search`,value:f,onChange:e=>{p(e.target.value),h(null)},onKeyDown:e=>{if(e.nativeEvent.isComposing||!T.length)return;if(e.key===`Enter`){e.preventDefault(),E?.kind===`open`?v(E.project):E?.kind===`recent`&&!_.isPending&&y(E.project);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=Math.max(0,T.findIndex(e=>e.project.id===E?.project.id)),n=e.key===`ArrowDown`?Math.min(t+1,T.length-1):Math.max(t-1,0),r=T[n];h(r.project.id),window.requestAnimationFrame(()=>document.getElementById(`project-switcher-option-${r.project.id}`)?.scrollIntoView({block:`nearest`}))},className:`h-11! bg-zinc-950/50 pr-2 pl-8 text-base! ring-white/8 focus-visible:ring-1! focus-visible:ring-white/20! min-[701px]:h-7! min-[701px]:py-1 min-[701px]:pr-2 min-[701px]:pl-7 min-[701px]:text-sm! min-[701px]:placeholder:text-sm`,placeholder:`Search projects…`,"aria-label":`Search projects`,"aria-activedescendant":E?`project-switcher-option-${E.project.id}`:void 0,autoFocus:!c})]}),(0,z.jsxs)(`div`,{className:`grid max-h-[min(28rem,70vh)] gap-1 overflow-y-auto p-0.5 min-[701px]:max-h-[min(22rem,70vh)] min-[701px]:gap-0.5 min-[701px]:p-0 [scrollbar-color:var(--color-zinc-700)_transparent]`,children:[x.length?(0,z.jsx)(`ul`,{role:`list`,className:`grid gap-1 min-[701px]:gap-0.5`,children:x.map(e=>{let r=e.worktrees.flatMap(e=>e.terminals),i=r.some(e=>u.has(e.id)),o=r.map(e=>d.get(e.id)).find(e=>e!==void 0);return(0,z.jsxs)(`li`,{className:W(`group/project-option relative flex h-11 min-w-0 items-center gap-0.5 rounded-md pr-1 has-[button:hover]:bg-white/5 focus-within:bg-white/5 min-[701px]:h-7`,E?.project.id===e.id&&`bg-white/8`),onMouseEnter:()=>h(e.id),children:[(0,z.jsxs)(G,{id:`project-switcher-option-${e.id}`,type:`button`,variant:`ghost`,className:`h-11 min-w-0 flex-1 justify-start px-2 text-left text-base hover:bg-transparent min-[701px]:h-7 min-[701px]:px-1.5 min-[701px]:text-sm max-[700px]:pr-8`,"data-highlighted":E?.project.id===e.id||void 0,onClick:()=>v(e),children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,z.jsx)(`span`,{className:`truncate font-medium text-zinc-100`,children:e.name}),t?.id===e.id?(0,z.jsx)(GR,{className:`shrink-0 fill-zinc-400`}):null]}),o||i?(0,z.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5 min-[701px]:group-hover/project-option:opacity-0 min-[701px]:group-focus-within/project-option:opacity-0`,children:[o?(0,z.jsx)(Az,{program:null,progress:o,attention:!1,exited:!1,className:`size-4`,title:Qh(o)}):null,i?(0,z.jsx)(Az,{program:null,progress:null,attention:!0,exited:!1,className:`size-4`,title:`Terminal needs attention`}):null]}):null]}),(0,z.jsx)(OB,{label:`Close project ${e.name}`,tooltip:`Close project`,disabled:n===e.id,className:`absolute right-1 shrink-0 fill-zinc-500 opacity-0 hover:bg-white/5 hover:fill-rose-300 group-hover/project-option:opacity-100 group-focus-within/project-option:opacity-100 max-[700px]:opacity-100`,onClick:()=>a(e),children:n===e.id?(0,z.jsx)(LR,{className:`animate-spin`}):(0,z.jsx)(hz,{})})]},e.id)})}):(0,z.jsx)(`p`,{className:`px-2 py-1.5 text-base text-pretty text-zinc-500 min-[701px]:px-1.5 min-[701px]:py-1 min-[701px]:text-sm`,children:`No open projects found.`}),!g.isSuccess||C.length?(0,z.jsxs)(`section`,{className:`grid gap-1 min-[701px]:gap-0.5`,"aria-labelledby":`recent-projects-switcher-title`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 py-1.5 min-[701px]:px-1.5 min-[701px]:py-1`,children:[(0,z.jsx)(`h3`,{id:`recent-projects-switcher-title`,className:`text-sm font-medium text-balance text-zinc-500 min-[701px]:text-xs`,children:`Recent projects`}),g.isFetching?(0,z.jsx)(LR,{className:`size-4 shrink-0 animate-spin fill-zinc-600`,"aria-label":`Refreshing recent projects`}):null]}),g.isError?(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 py-1.5 min-[701px]:px-1.5 min-[701px]:py-1`,children:[(0,z.jsx)(`p`,{className:`text-base text-pretty text-zinc-500 min-[701px]:text-sm`,children:`Recent projects unavailable.`}),(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`h-9 text-base min-[701px]:h-7 min-[701px]:text-sm`,onClick:()=>void g.refetch(),children:`Retry`})]}):null,g.isSuccess&&w.length?(0,z.jsx)(`ul`,{role:`list`,className:`grid gap-1 min-[701px]:gap-0.5`,children:w.map(e=>(0,z.jsx)(`li`,{onMouseEnter:()=>h(e.id),children:(0,z.jsx)(G,{id:`project-switcher-option-${e.id}`,type:`button`,variant:`ghost`,className:W(`h-11 w-full min-w-0 justify-start px-2 text-left text-base min-[701px]:h-7 min-[701px]:px-1.5 min-[701px]:text-sm`,E?.project.id===e.id&&`bg-white/8`),"data-highlighted":E?.project.id===e.id||void 0,disabled:_.isPending,onClick:()=>y(e),children:(0,z.jsx)(`span`,{className:`truncate font-medium text-zinc-200`,children:e.name})})},e.id))}):null,g.isSuccess&&!w.length?(0,z.jsx)(`p`,{className:`px-2 py-1.5 text-base text-pretty text-zinc-500 min-[701px]:px-1.5 min-[701px]:py-1 min-[701px]:text-sm`,children:`No recent projects found.`}):null]}):null]}),(0,z.jsx)(Rz,{className:`bg-white/8`}),(0,z.jsxs)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`h-11 w-full justify-start text-base font-normal text-zinc-500 hover:text-zinc-100 min-[701px]:h-7 min-[701px]:text-sm`,onClick:e=>{l.setOpen(!1),o(l.triggerRef.current??e.currentTarget)},children:[(0,z.jsx)(lz,{"data-icon":`inline-start`}),` Open project…`]})]})]})}function HB({className:e,children:t,...n}){return(0,z.jsxs)(`span`,{className:`grid grid-cols-[1fr_--spacing(8)]`,children:[(0,z.jsx)(`select`,{"data-slot":`native-select`,className:W(`col-span-full row-start-1 h-11 w-full appearance-none rounded-md bg-zinc-950/70 py-2 pr-8 pl-3 text-base text-zinc-100 ring-1 ring-white/12 outline-none focus-visible:ring-2 focus-visible:ring-cyan-400 sm:h-9 sm:text-sm`,e),...n,children:t}),(0,z.jsx)(qR,{className:`pointer-events-none col-start-2 row-start-1 size-4 place-self-center text-zinc-500`})]})}function UB({projectSwitcher:e,notificationCenter:t,children:n}){return(0,z.jsxs)(aB,{id:`worktree-sidebar`,collapsible:`none`,mobileTitle:`Projects and trees`,mobileDescription:`Navigate projects, trees, and terminals.`,className:`sidebar relative min-h-0 border-r border-white/8 bg-zinc-900/80 text-zinc-200 backdrop-blur-xl`,children:[(0,z.jsxs)(uB,{className:`gap-0 border-b border-white/8 p-0`,children:[(0,z.jsx)(`div`,{className:`hidden justify-end p-2 max-[700px]:flex`,children:(0,z.jsxs)(oB,{type:`button`,size:`icon-sm`,className:`icon-button mobile-close text-zinc-400 hover:bg-white/5 hover:text-zinc-100`,"aria-label":`Close drawer`,children:[(0,z.jsx)(hz,{}),(0,z.jsx)(`span`,{className:`touch-target`,"aria-hidden":`true`})]})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 p-2 max-[700px]:pt-0`,children:[(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),(0,z.jsx)(`div`,{className:`max-[700px]:hidden`,children:t})]})]}),(0,z.jsx)(pB,{className:`gap-0 overflow-hidden`,children:n}),(0,z.jsx)(zB,{})]})}function WB({selectedTerminalId:e,terminals:t,onSelectTerminal:n,notificationCenter:r}){let{isMobile:i,openMobile:a}=rB(),{titles:o}=aF();return(0,z.jsxs)(`header`,{className:`mobile-bar hidden min-w-0 grid-cols-[2.75rem_minmax(0,1fr)_2.75rem] items-center gap-2 border-b border-white/8 bg-zinc-900/95 px-2 backdrop-blur max-[700px]:grid`,inert:i&&a?!0:void 0,children:[(0,z.jsxs)(oB,{type:`button`,size:`icon`,className:`icon-button text-zinc-400 hover:bg-white/5 hover:text-zinc-100`,"aria-label":`Open tree drawer`,children:[(0,z.jsx)(VR,{}),(0,z.jsx)(`span`,{className:`touch-target`,"aria-hidden":`true`})]}),(0,z.jsxs)(HB,{className:`h-9 border-0 bg-zinc-800/80 text-base ring-0`,name:`terminal-selector`,"aria-label":`Terminal selector`,value:e??``,onChange:e=>{let r=t.find(t=>t.id===e.target.value);r&&n(r)},children:[(0,z.jsx)(`option`,{value:``,children:`Select terminal`}),t.map(e=>(0,z.jsx)(`option`,{value:e.id,children:o.get(e.id)||e.name},e.id))]}),r]})}var GB=Object.defineProperty,KB=(e,t)=>GB(e,`name`,{value:t,configurable:!0});function qB(e){let t=e+`CollectionProvider`,[n,r]=FF(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=KB(e=>{let{scope:t,children:n}=e,r=R.useRef(null),a=R.useRef(new Map).current;return(0,z.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=ip(s),l=R.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=tp(t,a(s,n).collectionRef);return(0,z.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=ip(u),p=R.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=R.useRef(null),s=tp(t,o),c=a(u,n);return R.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,z.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return R.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return KB(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}KB(qB,`createCollection`);var JB=new WeakMap,YB=class e extends Map{static{KB(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],JB.set(this,!0)}set(e,t){return JB.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=QB(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=XB(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=XB(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return XB(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function XB(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=ZB(e,t);return n===-1?void 0:e[n]}KB(XB,`at`);function ZB(e,t){let n=e.length,r=QB(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}KB(ZB,`toSafeIndex`);function QB(e){return e!==e||e===0?0:Math.trunc(e)}KB(QB,`toSafeInteger`);function $B(e){let t=e+`CollectionProvider`,[n,r]=FF(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new YB,setItemMap:KB(()=>void 0,`setItemMap`)}),o=KB(({state:e,...t})=>e?(0,z.jsx)(c,{...t,state:e}):(0,z.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=KB(e=>{let t=h();return(0,z.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=KB(e=>{let{scope:t,children:n,state:r}=e,a=R.useRef(null),[o,s]=R.useState(null),c=tp(a,s),[l,u]=r;return R.useEffect(()=>{if(!o)return;let e=rV(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,z.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=ip(l),d=R.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=tp(t,a(l,n).collectionRef);return(0,z.jsx)(u,{ref:i,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=ip(f),m=R.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=R.useRef(null),[s,c]=R.useState(null),l=tp(t,o,c),{setItemMap:u}=a(f,n),d=R.useRef(i);eV(d.current,i)||(d.current=i);let m=d.current;return R.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(nV):(t.set(s,{...e,element:s}),t.toSorted(nV)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new YB(e)))}},[s,m,u]),(0,z.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return R.useState(new YB)}KB(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return KB(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}KB($B,`createCollection`);function eV(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}KB(eV,`shallowEqual`);function tV(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}KB(tV,`isElementPreceding`);function nV(e,t){return!e[1].element||!t[1].element?0:tV(e[1].element,t[1].element)?-1:1}KB(nV,`sortByDocumentPosition`);function rV(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}KB(rV,`getChildListObserver`);var iV=Object.defineProperty,aV=(e,t)=>iV(e,`name`,{value:t,configurable:!0}),oV=R.createContext(void 0);function sV(e){let t=R.useContext(oV);return e||t||`ltr`}aV(sV,`useDirection`);var cV=Object.defineProperty,lV=(e,t)=>cV(e,`name`,{value:t,configurable:!0});function uV(e){let[t,n]=R.useState(void 0);return GF(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}lV(uV,`useSize`);var dV=Object.defineProperty,fV=(e,t)=>dV(e,`name`,{value:t,configurable:!0}),pV=`Popper`,[mV,hV]=FF(pV),[gV,_V]=mV(pV),vV=fV(e=>{let{__scopePopper:t,children:n}=e,[r,i]=R.useState(null),[a,o]=R.useState(void 0);return(0,z.jsx)(gV,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),yV=`PopperAnchor`,bV=R.forwardRef(fV(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=_V(yV,n),o=R.useRef(null),s=a.onAnchorChange,c=tp(t,R.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=R.useRef(null);R.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&DV(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,z.jsx)(fI.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),xV=`PopperContent`,[SV,CV]=mV(xV),wV=R.forwardRef(fV(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=_V(xV,n),[_,v]=R.useState(null),y=tp(t,v),[b,x]=R.useState(null),S=uV(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(TV),altBoundary:O},{refs:ee,floatingStyles:te,placement:A,isPositioned:j,middlewareData:M}=Wc({strategy:`fixed`,placement:T,whileElementsMounted:fV((...e)=>Ac(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[Kc({mainAxis:i+w,alignmentAxis:o}),c&&qc({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Jc():void 0,...k}),c&&Yc({...k}),Xc({...k,apply:fV(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),b&&Qc({element:b,padding:s}),EV({arrowWidth:C,arrowHeight:w}),f&&Zc({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ne=g.setPlacementState;GF(()=>(ne(A),()=>{ne(void 0)}),[A,ne]);let[N,P]=DV(A),re=gI(m);GF(()=>{j&&re?.()},[j,re]);let ie=M.arrow?.x,ae=M.arrow?.y,F=M.arrow?.centerOffset!==0,[I,L]=R.useState();return GF(()=>{_&&L(window.getComputedStyle(_).zIndex)},[_]),(0,z.jsx)(`div`,{ref:ee.setFloating,"data-radix-popper-content-wrapper":``,style:{...te,transform:j?te.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:I,"--radix-popper-transform-origin":[M.transformOrigin?.x,M.transformOrigin?.y].join(` `),...M.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,z.jsx)(SV,{scope:n,placedSide:N,placedAlign:P,onArrowChange:x,arrowX:ie,arrowY:ae,shouldHideArrow:F,children:(0,z.jsx)(fI.div,{"data-side":N,"data-align":P,...h,ref:y,style:{...h.style,animation:j?h.style?.animation:`none`}})})})},`PopperContent`));function TV(e){return e!==null}fV(TV,`isNotNull`);var EV=fV(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=DV(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function DV(e){let[t,n=`center`]=e.split(`-`);return[t,n]}fV(DV,`getSideAndAlignFromPlacement`);var OV=vV,kV=bV,AV=wV,jV=Object.defineProperty,MV=(e,t)=>jV(e,`name`,{value:t,configurable:!0}),NV=!1;function PV(){let[e,t]=R.useState(NV);return R.useEffect(()=>{NV||(NV=!0,t(!0))},[]),e}MV(PV,`useIsHydrated`);var FV=R.useSyncExternalStore;function IV(){return()=>{}}MV(IV,`subscribe`);function LV(){return FV(IV,()=>!0,()=>!1)}MV(LV,`useIsHydratedModern`);var RV=typeof FV==`function`?LV:PV,zV=Object.defineProperty,BV=(e,t)=>zV(e,`name`,{value:t,configurable:!0}),VV=`rovingFocusGroup.onEntryFocus`,HV={bubbles:!1,cancelable:!0},UV=`RovingFocusGroup`,[WV,GV,KV]=qB(UV),[qV,JV]=FF(UV,[KV]),[YV,XV]=qV(UV),ZV=R.forwardRef(BV(function(e,t){return(0,z.jsx)(WV.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,z.jsx)(WV.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,z.jsx)(QV,{...e,ref:t})})})},`RovingFocusGroup`)),QV=R.forwardRef(BV(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=R.useRef(null),p=tp(t,f),m=sV(a),[h,g]=aI({prop:o,defaultProp:s??null,onChange:c,caller:UV}),[_,v]=R.useState(!1),y=gI(l),b=GV(n),x=R.useRef(!1),[S,C]=R.useState(0);return R.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(VV,y),()=>e.removeEventListener(VV,y)},[y]),(0,z.jsx)(YV,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:R.useCallback(e=>g(e),[g]),onItemShiftTab:R.useCallback(()=>v(!0),[]),onFocusableItemAdd:R.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:R.useCallback(()=>C(e=>e-1),[]),children:(0,z.jsx)(fI.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:BF(e.onMouseDown,()=>{x.current=!0}),onFocus:BF(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(VV,HV);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);iH([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:BF(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),$V=`RovingFocusGroupItem`,eH=R.forwardRef(BV(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=XF(),l=a||c,u=XV($V,n),d=u.currentTabStopId===l,f=GV(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=RV();return GF(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),R.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,z.jsx)(WV.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,z.jsx)(fI.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:BF(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:BF(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:BF(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=rH(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?aH(n,r+1):n.slice(r+1)}setTimeout(()=>iH(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),tH={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function nH(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}BV(nH,`getDirectionAwareKey`);function rH(e,t,n){let r=nH(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return tH[r]}BV(rH,`getFocusIntent`);function iH(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}BV(iH,`focusFirst`);function aH(e,t){return e.map((n,r)=>e[(t+r)%e.length])}BV(aH,`wrapArray`);var oH=ZV,sH=eH,cH=Object.defineProperty,lH=(e,t)=>cH(e,`name`,{value:t,configurable:!0}),uH=[`Enter`,` `],dH=[`ArrowDown`,`PageUp`,`Home`],fH=[`ArrowUp`,`PageDown`,`End`],pH=[...dH,...fH];[...uH],[...uH];var mH=`Menu`,[hH,gH,_H]=qB(mH),[vH,yH]=FF(mH,[_H,hV,JV]),bH=hV(),xH=JV(),[SH,CH]=vH(mH),[wH,TH]=vH(mH),EH=lH(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=bH(t),[c,l]=R.useState(null),u=R.useRef(!1),d=gI(a),f=sV(i);return R.useEffect(()=>{let e=lH(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=lH(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),R.useEffect(()=>{if(!n)return;let e=lH(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,z.jsx)(OV,{...s,children:(0,z.jsx)(SH,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,z.jsx)(wH,{scope:t,onClose:R.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),DH=R.forwardRef(lH(function(e,t){let{__scopeMenu:n,...r}=e,i=bH(n);return(0,z.jsx)(kV,{...i,...r,ref:t})},`MenuAnchor`)),OH=`MenuPortal`,[kH,AH]=vH(OH,{forceMount:void 0}),jH=lH(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=CH(OH,t);return(0,z.jsx)(kH,{scope:t,forceMount:n,children:(0,z.jsx)($I,{present:n||a.open,children:(0,z.jsx)(YI,{asChild:!0,container:i,children:r})})})},`MenuPortal`),MH=`MenuContent`,[NH,PH]=vH(MH),FH=R.forwardRef(lH(function(e,t){let n=AH(MH,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=CH(MH,e.__scopeMenu),o=TH(MH,e.__scopeMenu);return(0,z.jsx)(hH.Provider,{scope:e.__scopeMenu,children:(0,z.jsx)($I,{present:r||a.open,children:(0,z.jsx)(hH.Slot,{scope:e.__scopeMenu,children:o.modal?(0,z.jsx)(IH,{...i,ref:t}):(0,z.jsx)(LH,{...i,ref:t})})})})},`MenuContent`)),IH=R.forwardRef(lH(function(e,t){let n=CH(MH,e.__scopeMenu),r=R.useRef(null),i=tp(t,r);return R.useEffect(()=>{let e=r.current;if(e)return tm(e)},[]),(0,z.jsx)(zH,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:BF(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),LH=R.forwardRef(lH(function(e,t){let n=CH(MH,e.__scopeMenu);return(0,z.jsx)(zH,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),RH=ip(`MenuContent.ScrollLock`),zH=R.forwardRef(lH(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=CH(MH,n),_=TH(MH,n),v=bH(n),y=xH(n),b=gH(n),[x,S]=R.useState(null),C=R.useRef(null),w=tp(t,C,g.onContentChange),T=R.useRef(0),E=R.useRef(``),D=R.useRef(0),O=R.useRef(null),k=R.useRef(`right`),ee=R.useRef(0),te=m?uh:R.Fragment,A=m?{as:RH,allowPinchZoom:!0}:void 0,j=lH(e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=nU(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;lH((function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);R.useEffect(()=>()=>window.clearTimeout(T.current),[]),uL();let M=R.useCallback(e=>k.current===O.current?.side&&iU(e,O.current?.area),[]);return(0,z.jsx)(NH,{scope:n,searchRef:E,onItemEnter:R.useCallback(e=>{M(e)&&e.preventDefault()},[M]),onItemLeave:R.useCallback(e=>{M(e)||(C.current?.focus(),S(null))},[M]),onTriggerLeave:R.useCallback(e=>{M(e)&&e.preventDefault()},[M]),pointerGraceTimerRef:D,onPointerGraceIntentChange:R.useCallback(e=>{O.current=e},[]),children:(0,z.jsx)(te,{...A,children:(0,z.jsx)(II,{asChild:!0,trapped:i,onMountAutoFocus:BF(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,z.jsx)(wI,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,z.jsx)(oH,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:BF(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,z.jsx)(AV,{role:`menu`,"aria-orientation":`vertical`,"data-state":ZH(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:BF(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&j(e.key));let i=C.current;if(e.target!==i||!pH.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);fH.includes(e.key)&&a.reverse(),eU(a)}),onBlur:BF(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:BF(e.onPointerMove,aU(e=>{let t=e.target,n=ee.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>ee.current?`right`:`left`;k.current=t,ee.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),BH=R.forwardRef(lH(function(e,t){let{__scopeMenu:n,...r}=e;return(0,z.jsx)(fI.div,{role:`group`,...r,ref:t})},`MenuGroup`)),VH=`MenuItem`,HH=`menu.itemSelect`,UH=R.forwardRef(lH(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=R.useRef(null),o=TH(VH,e.__scopeMenu),s=PH(VH,e.__scopeMenu),c=tp(t,a),l=R.useRef(!1),u=lH(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(HH,{bubbles:!0,cancelable:!0});e.addEventListener(HH,e=>r?.(e),{once:!0}),pI(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,z.jsx)(WH,{...i,ref:c,disabled:n,onClick:BF(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:BF(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:BF(e.onKeyDown,e=>{n||e.target!==e.currentTarget||s.searchRef.current!==``&&e.key===` `||uH.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),WH=R.forwardRef(lH(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=PH(VH,n),s=xH(n),c=R.useRef(null),l=tp(t,c),[u,d]=R.useState(!1),[f,p]=R.useState(``);return R.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,z.jsx)(hH.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,z.jsx)(sH,{asChild:!0,...s,focusable:!r,children:(0,z.jsx)(fI.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:BF(e.onPointerMove,aU(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:BF(e.onPointerLeave,aU(e=>o.onItemLeave(e))),onFocus:BF(e.onFocus,()=>d(!0)),onBlur:BF(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[GH,KH]=vH(`MenuRadioGroup`,{value:void 0,onValueChange:lH(()=>{},`onValueChange`)}),[qH,JH]=vH(`MenuItemIndicator`,{checked:!1}),[YH,XH]=vH(`MenuSub`);function ZH(e){return e?`open`:`closed`}lH(ZH,`getOpenState`);function QH(e){return e===`indeterminate`}lH(QH,`isIndeterminate`);function $H(e){return QH(e)?`indeterminate`:e?`checked`:`unchecked`}lH($H,`getCheckedState`);function eU(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}lH(eU,`focusFirst`);function tU(e,t){return e.map((n,r)=>e[(t+r)%e.length])}lH(tU,`wrapArray`);function nU(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=tU(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}lH(nU,`getNextMatch`);function rU(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}lH(rU,`isPointInPolygon`);function iU(e,t){return t?rU({x:e.clientX,y:e.clientY},t):!1}lH(iU,`isPointerInGraceArea`);function aU(e){return t=>t.pointerType===`mouse`?e(t):void 0}lH(aU,`whenMouse`);var oU=EH,sU=DH,cU=jH,lU=FH,uU=BH,dU=UH,fU=Object.defineProperty,pU=(e,t)=>fU(e,`name`,{value:t,configurable:!0}),mU=`ContextMenu`,[hU,gU]=FF(mU,[yH]),_U=yH(),[vU,yU]=hU(mU),bU=pU(e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,dir:a,modal:o=!0}=e,s=R.useRef(!1),[c,l]=aI({prop:i,defaultProp:!1,onChange:r,caller:mU}),u=_U(t);return(0,z.jsx)(vU,{scope:t,open:c,onOpenChange:l,modal:o,hasInteractedRef:s,children:(0,z.jsx)(oU,{...u,dir:a,open:c,onOpenChange:l,modal:o,children:n})})},`ContextMenu`),xU=`ContextMenuTrigger`,SU=R.forwardRef(pU(function(e,t){let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=yU(xU,n),o=_U(n),[s,c]=R.useState({x:0,y:0}),l=R.useMemo(()=>({current:{getBoundingClientRect:pU(()=>DOMRect.fromRect({width:0,height:0,...s}),`getBoundingClientRect`)}}),[s]),u=R.useRef(0),d=R.useCallback(()=>window.clearTimeout(u.current),[]),f=pU(e=>{a.hasInteractedRef.current=!0,c({x:e.clientX,y:e.clientY}),a.onOpenChange(!0)},`handleOpen`);return R.useEffect(()=>d,[d]),R.useEffect(()=>void(r&&d()),[r,d]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(sU,{...o,virtualRef:l}),(0,z.jsx)(fI.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:BF(e.onContextMenu,e=>{d(),f(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:BF(e.onPointerDown,OU(e=>{d(),a.open&&a.onOpenChange(!1),u.current=window.setTimeout(()=>f(e),700)})),onPointerMove:r?e.onPointerMove:BF(e.onPointerMove,OU(d)),onPointerCancel:r?e.onPointerCancel:BF(e.onPointerCancel,OU(d)),onPointerUp:r?e.onPointerUp:BF(e.onPointerUp,OU(d))})]})},`ContextMenuTrigger`)),CU=pU(e=>{let{__scopeContextMenu:t,...n}=e,r=_U(t);return(0,z.jsx)(cU,{...r,...n})},`ContextMenuPortal`),wU=`ContextMenuContent`,TU=R.forwardRef(pU(function(e,t){let{__scopeContextMenu:n,...r}=e,i=yU(wU,n),a=_U(n),o=R.useRef(!1);return(0,z.jsx)(lU,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`ContextMenuContent`)),EU=R.forwardRef(pU(function(e,t){let{__scopeContextMenu:n,...r}=e,i=_U(n);return(0,z.jsx)(uU,{...i,...r,ref:t})},`ContextMenuGroup`)),DU=R.forwardRef(pU(function(e,t){let{__scopeContextMenu:n,...r}=e,i=_U(n);return(0,z.jsx)(dU,{...i,...r,ref:t})},`ContextMenuItem`));function OU(e){return t=>t.pointerType===`mouse`?void 0:e(t)}pU(OU,`whenTouchOrPen`);var kU=bU,AU=SU,jU=CU,MU=TU,NU=EU,PU=DU;function FU(e){return(0,z.jsx)(kU,{...e})}function IU(e){return(0,z.jsx)(AU,{...e})}function LU({className:e,...t}){return(0,z.jsx)(jU,{children:(0,z.jsx)(MU,{className:W(`z-100 min-w-44 max-w-[calc(100vw-1rem)] rounded-md bg-zinc-900 p-1 text-zinc-200 shadow-xl ring-1 ring-white/10 outline-none`,e),...t})})}function RU(e){return(0,z.jsx)(NU,{...e})}function zU({className:e,variant:t=`default`,...n}){return(0,z.jsx)(PU,{"data-variant":t,className:W(`relative flex min-h-8 cursor-default items-center gap-1.5 rounded-sm px-2 py-1.5 text-sm outline-none select-none [&_svg]:size-3.5 [&_svg]:shrink-0 data-[disabled]:pointer-events-none data-[disabled]:opacity-45 data-[highlighted]:bg-white/7 data-[highlighted]:text-zinc-50 data-[variant=destructive]:text-rose-300`,e),...n})}function BU({name:e,title:t,icon:n,status:r,selected:i=!1,pending:a=!1,busy:o=!1,id:s,className:c,ariaLabel:l,onClick:u}){let d=W(`worktree-row flex h-auto min-h-11 w-full min-w-0 items-center justify-start gap-1.5 rounded-md px-2 py-1.5 text-left text-base/5 font-medium min-[701px]:min-h-8 min-[701px]:py-0.5 min-[701px]:text-sm/5`,a?`text-zinc-300`:i?`selected text-zinc-50 min-[701px]:bg-white/8!`:`text-zinc-300 hover:bg-white/5 hover:text-zinc-50`,`max-[700px]:flex-1 max-[700px]:hover:bg-transparent`,(a||o)&&`motion-safe:animate-pulse`,a&&`pointer-events-none`,c),f=(0,z.jsxs)(z.Fragment,{children:[n,(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:e}),r]})]});return(0,z.jsx)(xB,{asChild:!0,isActive:i,children:(0,z.jsx)(G,{id:s,variant:`ghost`,type:`button`,className:d,onClick:a?void 0:u,title:t,role:a?`status`:void 0,"aria-label":a?`Creating tree ${e}`:l,"aria-live":a||l?`polite`:void 0,"aria-disabled":a||void 0,tabIndex:a?-1:void 0,children:f})})}function VU({projects:e,projectsPending:t,projectsError:n,projectsLoaded:r,activeProject:i,selectedWorktree:a,selectedTerminalId:o,selectedPendingTerminalId:s,selectedWebPanelId:c,webPanelRuntimeTitles:l,pendingTerminals:u,pendingWorktrees:d,pendingRemovals:f,onRetryProjects:p,onSelectTerminal:m,onSelectPendingTerminal:h,onCloseTerminal:g,onSelectWebPanel:_,onCloseWebPanel:v,onSelectWorktree:y,onPrepareRemoval:b,onOpenPanelDialog:x,onOpenWorktreeDialog:S}){let{attention:C,titles:w,programs:T,progress:E}=aF(),D=window.treeportDesktop,O=D?D.platform===`darwin`?`⌘N`:`Ctrl+N`:null,k=D?D.platform===`darwin`?`⌘⇧T`:`Ctrl+Shift+T`:null;return(0,z.jsxs)(`nav`,{className:`tree min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-2 pt-3 pb-5 min-[701px]:px-1.5 min-[701px]:pt-2 min-[701px]:pb-4 [scrollbar-color:var(--color-zinc-700)_transparent]`,"aria-label":`Projects and trees`,children:[t?(0,z.jsx)(`p`,{className:`sidebar-note px-2 py-3 text-base text-zinc-500 min-[701px]:text-sm`,children:`Loading repositories…`}):null,n&&!r?(0,z.jsxs)(`div`,{className:`flex flex-col items-start gap-2 px-2 py-3`,children:[(0,z.jsx)(`p`,{className:`sidebar-note text-base text-rose-300 min-[701px]:text-sm`,children:`Projects could not be loaded.`}),(0,z.jsx)(G,{type:`button`,variant:`secondary`,size:`sm`,onClick:p,children:`Retry`})]}):null,!t&&!n&&!e.length?(0,z.jsx)(`p`,{className:`sidebar-note px-2 py-3 text-base text-pretty text-zinc-500 min-[701px]:text-sm`,children:`Open a Git repository to begin.`}):null,(0,z.jsx)(`div`,{className:`grid gap-4`,children:e.filter(e=>e.id===i?.id).map(e=>(0,z.jsxs)(`div`,{className:`project-tree min-w-0`,children:[e.availability.state===`unavailable`?(0,z.jsx)(`p`,{className:`mx-1 mb-2 rounded-md bg-amber-400/8 px-2 py-1.5 text-sm text-amber-200`,role:`status`,children:e.availability.message||`Git repository unavailable`}):null,(0,z.jsxs)(vB,{className:`gap-2 min-[701px]:gap-1`,children:[e.worktrees.map(t=>(0,z.jsxs)(yB,{className:`group/worktree min-w-0`,children:[(0,z.jsxs)(FU,{children:[(0,z.jsx)(IU,{asChild:!0,disabled:t.kind!==`linked`,children:(0,z.jsxs)(`div`,{className:W(`relative min-w-0 max-[700px]:flex max-[700px]:items-center max-[700px]:gap-0.5 max-[700px]:rounded-md max-[700px]:has-[button:hover]:bg-white/5`,a?.id===t.id&&`max-[700px]:bg-white/8`),children:[(0,z.jsx)(BU,{id:`worktree-${t.id}`,name:t.name,title:`${t.path}${t.branch?` · ${t.branch}`:` · detached at ${t.head.slice(0,8)}`}`,selected:a?.id===t.id,className:W(a?.id===t.id&&`min-[701px]:pr-6`),busy:!!f[t.id],ariaLabel:f[t.id]===`checking`?`${t.name}, preparing removal`:f[t.id]?`${t.name}, removing`:void 0,onClick:()=>y(t),icon:f[t.id]?(0,z.jsx)(Jf,{className:`worktree-progress-icon worktree-removing-icon size-4 shrink-0 stroke-rose-400 stroke-[1.5] min-[701px]:size-3.5!`,"aria-hidden":`true`}):t.kind===`main`?(0,z.jsx)(qf,{className:`size-4 shrink-0 stroke-zinc-600 stroke-[1.5] min-[701px]:size-3.5!`,"aria-hidden":`true`}):(0,z.jsx)(Jf,{className:`shrink-0 stroke-zinc-600 stroke-[1.5] min-[701px]:size-3.5!`,"aria-hidden":`true`})}),a?.id===t.id?(0,z.jsx)(`div`,{className:`worktree-actions absolute inset-y-0 right-0 z-10 flex items-center max-[700px]:static max-[700px]:shrink-0`,children:(0,z.jsx)(OB,{label:`New panel in ${t.name}`,tooltip:`New panel in ${t.name}${k?` — ${k}`:``}`,...k?{keyShortcuts:D?.platform===`darwin`?`Meta+Shift+T`:`Control+Shift+T`}:{},className:`text-zinc-500 hover:bg-transparent hover:text-zinc-100 min-[701px]:size-6`,onClick:n=>x(e,t,n),children:(0,z.jsx)(lz,{})})}):null]})}),t.kind===`linked`?(0,z.jsx)(LU,{children:(0,z.jsx)(RU,{children:(0,z.jsxs)(zU,{variant:`destructive`,disabled:e.availability.state===`unavailable`||!!f[t.id],onSelect:()=>void b(t,document.getElementById(`worktree-${t.id}`)),children:[(0,z.jsx)(dz,{}),e.availability.state===`unavailable`?`Git repository unavailable`:f[t.id]?`Removal in progress`:`Remove tree…`]})})}):null]}),(0,z.jsxs)(TB,{className:`terminal-list mr-0 ml-4 gap-px border-white/6 pr-0 pl-2 min-[701px]:ml-2.5 min-[701px]:pl-1.5`,"aria-label":`${t.name} terminals`,children:[t.terminals.map((e,n)=>{let r=w.get(e.id)||e.name,i=C.has(e.id),s=E.get(e.id),c=!!s&&!i&&s.state!==`paused`&&s.state!==`error`,l=[s?Qh(s):e.status,i?`bell`:null].filter(Boolean).join(`, `),u=a?.id===t.id&&n<9?n+1:null;return(0,z.jsxs)(EB,{className:`group/terminal relative min-w-0`,children:[(0,z.jsx)(DB,{asChild:!0,isActive:o===e.id,children:(0,z.jsxs)(G,{variant:`ghost`,type:`button`,className:W(`terminal-row grid h-auto min-h-11 w-full min-w-0 grid-cols-[1.25rem_minmax(0,1fr)_2rem] gap-1.5 rounded-md px-2 py-1.5 text-left text-base/5 font-normal min-[701px]:min-h-7 min-[701px]:grid-cols-[1rem_minmax(0,1fr)_1.75rem] min-[701px]:gap-1 min-[701px]:py-0 min-[701px]:text-xs/4`,o===e.id?`selected bg-cyan-400/8! text-cyan-50`:`text-zinc-300 hover:bg-white/5 hover:text-zinc-100`),onClick:()=>m(e),onMouseDown:e=>{e.button===1&&e.preventDefault()},onAuxClick:t=>{t.button===1&&(t.preventDefault(),g(e))},"aria-label":`${r}, ${l}`,"aria-keyshortcuts":u?`Meta+${u}`:void 0,children:[(0,z.jsx)(Az,{program:T.get(e.id)??null,progress:s??null,attention:i,exited:e.status===`exited`,className:`size-4! min-[701px]:size-3.5!`}),(0,z.jsx)(`span`,{className:W(`truncate`,c&&`text-cyan-300`,i&&`text-amber-200`),"aria-hidden":`true`,children:r}),u?(0,z.jsxs)(`kbd`,{className:`justify-self-end font-sans text-[0.6875rem] font-normal text-zinc-500 tabular-nums group-hover/terminal:opacity-0 group-focus-within/terminal:opacity-0 max-[700px]:opacity-0`,"aria-hidden":`true`,children:[`⌘`,u]}):(0,z.jsx)(`span`,{"aria-hidden":`true`})]})}),(0,z.jsx)(`div`,{className:`absolute inset-y-0 right-0 z-10 flex items-center opacity-0 group-hover/terminal:opacity-100 group-focus-within/terminal:opacity-100 max-[700px]:opacity-100`,children:(0,z.jsx)(OB,{label:`Close ${r}`,tooltip:t.terminals.length===1?`Every tree keeps at least one terminal`:`Close terminal`,disabled:t.terminals.length===1,className:`text-zinc-500 hover:bg-transparent hover:text-zinc-200`,onClick:()=>g(e),children:(0,z.jsx)(hz,{})})})]},e.id)}),t.panels.filter(e=>e.kind===`web`).map((e,n)=>{let r=l[e.id]??e.title,i=a?.id===t.id&&t.terminals.length+n<9?t.terminals.length+n+1:null;return(0,z.jsxs)(EB,{className:`group/terminal relative min-w-0`,children:[(0,z.jsx)(DB,{asChild:!0,isActive:c===e.id,children:(0,z.jsxs)(G,{variant:`ghost`,type:`button`,className:W(`terminal-row grid h-auto min-h-11 w-full min-w-0 grid-cols-[1.25rem_minmax(0,1fr)_2rem] gap-1.5 rounded-md px-2 py-1.5 text-left text-base/5 font-normal min-[701px]:min-h-7 min-[701px]:grid-cols-[1rem_minmax(0,1fr)_1.75rem] min-[701px]:gap-1 min-[701px]:py-0 min-[701px]:text-xs/4`,c===e.id?`selected bg-cyan-400/8! text-cyan-50`:`text-zinc-300 hover:bg-white/5 hover:text-zinc-100`),onClick:()=>_(e),onMouseDown:e=>{e.button===1&&e.preventDefault()},onAuxClick:t=>{t.button===1&&(t.preventDefault(),v(e,t.currentTarget))},"aria-label":`${r}, web panel`,"aria-keyshortcuts":i?`Meta+${i}`:void 0,children:[(0,z.jsx)(pz,{className:`size-4! shrink-0 fill-zinc-500 min-[701px]:size-3.5!`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`truncate`,"aria-hidden":`true`,children:r}),i?(0,z.jsxs)(`kbd`,{className:`justify-self-end font-sans text-[0.6875rem] font-normal text-zinc-500 tabular-nums group-hover/terminal:opacity-0 group-focus-within/terminal:opacity-0 max-[700px]:opacity-0`,"aria-hidden":`true`,children:[`⌘`,i]}):(0,z.jsx)(`span`,{"aria-hidden":`true`})]})}),(0,z.jsx)(`div`,{className:`absolute inset-y-0 right-0 z-10 flex items-center opacity-0 group-hover/terminal:opacity-100 group-focus-within/terminal:opacity-100 max-[700px]:opacity-100`,children:(0,z.jsx)(OB,{label:`Close ${r}`,tooltip:`Close web panel`,className:`text-zinc-500 hover:bg-transparent hover:text-zinc-200`,onClick:t=>v(e,t),children:(0,z.jsx)(hz,{})})})]},e.id)}),u.filter(e=>e.worktreeId===t.id).map((e,n)=>{let r=t.panels.filter(e=>e.kind===`web`).length,i=t.terminals.length+r+n;return(0,z.jsx)(EB,{className:`min-w-0`,children:(0,z.jsx)(DB,{asChild:!0,isActive:s===e.id,children:(0,z.jsxs)(G,{variant:`ghost`,type:`button`,className:W(`terminal-row grid h-auto min-h-11 w-full min-w-0 grid-cols-[1.25rem_minmax(0,1fr)_auto] gap-1.5 rounded-md px-2 py-1.5 text-left text-base/5 font-normal min-[701px]:min-h-7 min-[701px]:grid-cols-[1rem_minmax(0,1fr)_auto] min-[701px]:gap-1 min-[701px]:py-0 min-[701px]:text-xs/4`,s===e.id?`selected bg-cyan-400/8! text-cyan-50`:`text-zinc-300 hover:bg-white/5 hover:text-zinc-100`),onClick:()=>h(e.id),"aria-label":`${e.name}, starting`,"aria-keyshortcuts":a?.id===t.id&&i<9?`Meta+${i+1}`:void 0,children:[(0,z.jsx)(LR,{className:`animate-spin fill-zinc-500`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`truncate`,"aria-hidden":`true`,children:e.name}),(0,z.jsx)(`span`,{className:`text-[0.6875rem] text-zinc-500`,"aria-hidden":`true`,children:`Starting…`})]})})},e.id)})]})]},t.id)),a?null:(0,z.jsx)(yB,{className:`min-w-0`,children:(0,z.jsx)(xB,{asChild:!0,children:(0,z.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-auto min-h-11 w-full justify-start gap-1.5 px-2 py-1.5 text-base/5 font-normal text-zinc-500 hover:bg-white/5 hover:text-zinc-100 min-[701px]:min-h-8 min-[701px]:py-0.5 min-[701px]:text-sm/5`,"aria-label":`New panel`,onClick:t=>x(e,null,t.currentTarget),children:[(0,z.jsx)(lz,{className:`min-[701px]:size-3.5!`}),(0,z.jsx)(`span`,{children:`New panel`})]})})}),d.filter(t=>t.projectId===e.id).map(e=>(0,z.jsx)(yB,{className:`min-w-0`,children:(0,z.jsx)(BU,{id:`pending-worktree-${e.id}`,name:e.typedName,title:`Creating ${e.typedName}`,pending:!0,icon:(0,z.jsx)(Jf,{className:`worktree-progress-icon size-4 shrink-0 stroke-cyan-400 stroke-[1.5] min-[701px]:size-3.5!`,"aria-hidden":`true`})})},e.id)),(0,z.jsx)(yB,{className:`min-w-0`,children:(0,z.jsx)(xB,{asChild:!0,children:(0,z.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-auto min-h-11 w-full justify-start gap-1.5 px-2 py-1.5 text-base/5 font-normal text-zinc-500 hover:bg-white/5 hover:text-zinc-100 min-[701px]:min-h-8 min-[701px]:py-0.5 min-[701px]:text-sm/5`,disabled:e.availability.state===`unavailable`,"aria-keyshortcuts":O?D?.platform===`darwin`?`Meta+N`:`Control+N`:void 0,title:O?`New tree — ${O}`:void 0,onClick:t=>S(e,t.currentTarget),children:[(0,z.jsx)(lz,{className:`min-[701px]:size-3.5!`}),(0,z.jsx)(`span`,{children:`New tree`}),O?(0,z.jsx)(`kbd`,{className:`ml-auto font-sans text-[0.6875rem] text-zinc-500`,"aria-hidden":`true`,children:O}):null]})})})]})]},e.id))})]})}function HU(e){let t=[],n=``,r=null,i=!1;for(let a=0;a<e.length;a+=1){let o=e[a];if(r===`single`){o===`'`?r=null:n+=o;continue}if(r===`double`){if(o===`"`)r=null;else if(o===`\\`){if(a+=1,a>=e.length)return{argv:null,error:`The command ends with an incomplete escape.`};n+=e[a]}else n+=o;continue}if(/\s/.test(o)){i&&=(t.push(n),n=``,!1);continue}if(i=!0,o===`'`)r=`single`;else if(o===`"`)r=`double`;else if(o===`\\`){if(a+=1,a>=e.length)return{argv:null,error:`The command ends with an incomplete escape.`};n+=e[a]}else n+=o}return r?{argv:null,error:`The command has an unclosed quote.`}:(i&&t.push(n),t.length===0?{argv:null,error:`Enter a command.`}:{argv:t,error:null})}function UU(e){return e.map(e=>e===``?`""`:/[\s"'\\]/.test(e)?`"${e.replace(/["\\]/g,`\\$&`)}"`:e).join(` `)}var WU=Object.defineProperty,GU=(e,t)=>WU(e,`name`,{value:t,configurable:!0}),KU=`Checkbox`,[qU,JU]=FF(KU),[YU,XU]=qU(KU);function ZU(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=aI({prop:n,defaultProp:i??!1,onChange:c,caller:KU}),[m,h]=R.useState(null),[g,_]=R.useState(null),v=R.useRef(!1),[y,b]=R.useReducer(e=>e+1,0),x=!m||!!o||!!m.closest(`form`),S={checked:f,disabled:a,setChecked:p,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,userInteractionCount:y,onUserInteraction:b,required:l,defaultChecked:!oW(i)&&i,isFormControl:x,bubbleInput:g,setBubbleInput:_};return(0,z.jsx)(YU,{scope:t,...S,children:aW(d)?d(S):r})}GU(ZU,`CheckboxProvider`);var QU=`CheckboxTrigger`,$U=R.forwardRef(GU(function({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i){let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:m,bubbleInput:h}=XU(QU,e),g=tp(i,u),_=R.useRef(c);return R.useEffect(()=>{let e=a?.form;if(e){let t=GU(()=>d(_.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,z.jsx)(fI.button,{type:`button`,role:`checkbox`,"aria-checked":oW(c)?`mixed`:c,"aria-required":l,"data-state":sW(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:g,onKeyDown:BF(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:BF(n,e=>{p(),d(e=>oW(e)?!0:!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),eW=R.forwardRef(GU(function(e,t){let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,z.jsx)(ZU,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)($U,{...d,ref:t,__scopeCheckbox:n}),e&&(0,z.jsx)(iW,{__scopeCheckbox:n})]})})},`Checkbox`)),tW=`CheckboxIndicator`,nW=R.forwardRef(GU(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=XU(tW,n);return(0,z.jsx)($I,{present:r||oW(a.checked)||a.checked===!0,children:(0,z.jsx)(fI.span,{"data-state":sW(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),rW=`CheckboxBubbleInput`,iW=R.forwardRef(GU(function({__scopeCheckbox:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:m,setBubbleInput:h}=XU(rW,e),g=tp(r,h),_=uV(i),v=R.useRef(!1),y=R.useRef(s),b=R.useRef(o);R.useEffect(()=>{let e=m;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==b.current;b.current=o;let i=y.current!==s;y.current=s;let c=!(r&&a.current);if(i&&n){v.current=!r;let t=new Event(`click`,{bubbles:c});e.indeterminate=oW(s),n.call(e,!oW(s)&&s),e.dispatchEvent(t),v.current=!1}},[m,s,a,o]);let x=R.useRef(!oW(s)&&s);return(0,z.jsx)(fI.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:g,onClick:BF(t,e=>{v.current&&e.stopPropagation()}),style:{...n.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function aW(e){return typeof e==`function`}GU(aW,`isFunction`);function oW(e){return e===`indeterminate`}GU(oW,`isIndeterminate`);function sW(e){return oW(e)?`indeterminate`:e?`checked`:`unchecked`}GU(sW,`getState`);var cW=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(eW,{ref:n,className:W(`peer grid size-4 shrink-0 place-content-center rounded-sm border border-white/20 bg-zinc-950 text-zinc-950 outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-cyan-400 data-[state=checked]:bg-cyan-400 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-cyan-400`,e),...t,children:(0,z.jsx)(nW,{className:`grid place-content-center text-current`,children:(0,z.jsx)(Kf,{className:`size-3.5`})})}));cW.displayName=eW.displayName;function lW({presets:e,loading:t,loadError:n,onRetry:r}){let i=Ye(),[a,o]=(0,R.useState)({editingId:null,loadedUpdatedAt:null,name:``,command:``,closeOnSuccess:!1,commandError:null,notice:null}),{editingId:s,loadedUpdatedAt:c,name:l,command:u,closeOnSuccess:d,commandError:f,notice:p}=a,m=()=>{o({editingId:null,loadedUpdatedAt:null,name:``,command:``,closeOnSuccess:!1,commandError:null,notice:null})};if(s){let t=e.find(e=>e.id===s);t?t.updatedAt!==c&&o({editingId:t.id,loadedUpdatedAt:t.updatedAt,name:t.name,command:UU([t.executable,...t.args]),closeOnSuccess:t.closeOnSuccess,commandError:null,notice:c?`This preset changed, so the latest saved values were loaded.`:p}):o({editingId:null,loadedUpdatedAt:null,name:``,command:``,closeOnSuccess:!1,commandError:null,notice:`That preset was deleted. You can create a new one.`})}let h=pt({mutationFn:({presetId:e,input:t,expectedUpdatedAt:n})=>e?Tf(yN.api[`terminal-presets`][`:presetId`].$patch({param:{presetId:e},json:{...t,expectedUpdatedAt:n}})).then(e=>e.preset):Tf(yN.api[`terminal-presets`].$post({json:t})).then(e=>e.preset),onSuccess:(e,t)=>{i.setQueryData(Cz,n=>t.presetId?n?.map(t=>t.id===e.id?e:t):[...n??[],e]),o({editingId:e.id,loadedUpdatedAt:e.updatedAt,name:e.name,command:UU([e.executable,...e.args]),closeOnSuccess:e.closeOnSuccess,commandError:null,notice:`Preset saved.`})},onError:(e,{presetId:t,input:n})=>{i.invalidateQueries({queryKey:Cz}),DF(e,{operation:`${t?`update`:`create`} terminal preset “${n.name}”`})},onSettled:async()=>{await Promise.all([i.invalidateQueries({queryKey:Cz}),i.invalidateQueries({queryKey:[`terminal-preset-definitions`]})])}}),g=pt({mutationFn:e=>Tf(yN.api[`terminal-presets`][`:presetId`].$delete({param:{presetId:e.id},json:{expectedUpdatedAt:e.updatedAt}})),onSuccess:(e,t)=>{i.setQueryData(Cz,e=>e?.filter(e=>e.id!==t.id)),s===t.id&&o({editingId:null,loadedUpdatedAt:null,name:``,command:``,closeOnSuccess:!1,commandError:null,notice:`Preset deleted.`})},onError:(e,t)=>{i.invalidateQueries({queryKey:Cz}),DF(e,{operation:`delete terminal preset “${t.name}”`})},onSettled:async()=>{await Promise.all([i.invalidateQueries({queryKey:Cz}),i.invalidateQueries({queryKey:[`terminal-preset-definitions`]})])}}),_=h.isPending||g.isPending;return(0,z.jsx)(z.Fragment,{children:(0,z.jsxs)(`div`,{className:`grid min-h-0 gap-5 border-t border-white/8 pt-4 md:grid-cols-[minmax(12rem,0.8fr)_minmax(0,1.35fr)]`,children:[(0,z.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-2`,"aria-labelledby":`saved-presets-title`,children:[(0,z.jsxs)(`div`,{className:`flex min-h-8 items-center justify-between gap-3`,children:[(0,z.jsx)(`h3`,{id:`saved-presets-title`,className:`text-sm font-medium text-zinc-200`,children:`Presets`}),(0,z.jsxs)(G,{type:`button`,variant:`secondary`,size:`sm`,disabled:_,onClick:m,children:[(0,z.jsx)(lz,{}),` New`]})]}),(0,z.jsxs)(`div`,{className:`max-h-72 overflow-y-auto rounded-lg bg-white/3 p-1 ring-1 ring-white/8 [scrollbar-color:var(--color-zinc-700)_transparent]`,children:[(0,z.jsxs)(`div`,{className:`grid min-h-14 min-w-0 content-center gap-0.5 rounded-md px-3 py-2`,children:[(0,z.jsx)(`span`,{className:`truncate text-sm font-medium text-zinc-100`,children:`Shell`}),(0,z.jsx)(`span`,{className:`truncate text-xs text-zinc-500`,children:`Built in · login shell`})]}),e.map(e=>(0,z.jsxs)(`div`,{className:W(`group/preset flex min-h-14 items-center rounded-md px-1 transition-colors hover:bg-white/5`,s===e.id&&`bg-white/7 hover:bg-white/7`),children:[(0,z.jsxs)(`button`,{type:`button`,className:`grid min-w-0 flex-1 cursor-pointer gap-0.5 rounded-sm px-2 py-2 text-left outline-none focus-visible:outline-2 focus-visible:outline-cyan-400`,"aria-current":s===e.id?`true`:void 0,disabled:_,onClick:()=>{o({editingId:e.id,loadedUpdatedAt:e.updatedAt,name:e.name,command:UU([e.executable,...e.args]),closeOnSuccess:e.closeOnSuccess,commandError:null,notice:null})},children:[(0,z.jsx)(`span`,{className:`truncate text-sm font-medium text-zinc-100`,children:e.name}),(0,z.jsx)(`span`,{className:`truncate text-xs text-zinc-500`,children:UU([e.executable,...e.args])})]}),(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`mr-1 size-11 shrink-0 hover:text-rose-300 min-[701px]:size-8 min-[701px]:opacity-0 min-[701px]:group-hover/preset:opacity-100 min-[701px]:focus-visible:opacity-100`,"aria-label":`Delete ${e.name}`,disabled:_,onClick:()=>{window.confirm(`Delete terminal preset “${e.name}”?`)&&g.mutate(e)},children:(0,z.jsx)(dz,{})})]},e.id)),t&&(0,z.jsx)(`p`,{className:`px-2.5 py-3 text-sm text-zinc-500`,role:`status`,children:`Loading presets…`}),n&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2.5 py-3`,children:[(0,z.jsx)(`p`,{className:`text-sm text-zinc-400`,children:`Could not load presets.`}),(0,z.jsx)(G,{type:`button`,variant:`secondary`,size:`sm`,onClick:r,children:`Retry`})]})]})]}),(0,z.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:e=>{e.preventDefault();let t=HU(u);if(t.argv===null){o(e=>({...e,commandError:t.error}));return}let[n,...r]=t.argv;h.mutate({presetId:s,input:{name:l,executable:n,args:r,closeOnSuccess:d},expectedUpdatedAt:c})},children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-medium text-zinc-200`,children:`Preset details`}),p&&(0,z.jsx)(`span`,{className:`text-xs text-zinc-400`,role:`status`,children:p})]}),(0,z.jsxs)(gz,{children:[(0,z.jsx)(vz,{htmlFor:`preset-name`,children:`Name`}),(0,z.jsx)(_z,{id:`preset-name`,name:`preset-name`,value:l,maxLength:120,disabled:_,autoFocus:!0,required:!0,onChange:e=>{o(t=>({...t,name:e.target.value,notice:null}))},placeholder:`Code review`})]}),(0,z.jsxs)(gz,{children:[(0,z.jsx)(vz,{htmlFor:`preset-command`,children:`Command`}),(0,z.jsx)(_z,{id:`preset-command`,name:`preset-command`,value:u,disabled:_,required:!0,"aria-invalid":f?!0:void 0,"aria-describedby":f?`preset-command-error`:void 0,onChange:e=>{o(t=>({...t,command:e.target.value,commandError:null,notice:null}))},placeholder:`diff main --mode split`}),f&&(0,z.jsx)(`p`,{id:`preset-command-error`,className:`text-xs text-rose-300`,role:`alert`,children:f})]}),(0,z.jsx)(gz,{children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,z.jsx)(cW,{id:`preset-close-on-success`,checked:d,disabled:_,onCheckedChange:e=>{o(t=>({...t,closeOnSuccess:e===!0,notice:null}))}}),(0,z.jsxs)(`div`,{className:`grid gap-1`,children:[(0,z.jsx)(vz,{htmlFor:`preset-close-on-success`,children:`Close on success`}),(0,z.jsx)(`p`,{className:`form-note`,children:`Use for one-off commands such as opening an editor. Failed commands remain open for inspection.`})]})]})}),(0,z.jsx)(G,{type:`submit`,className:`self-end`,disabled:_||!l.trim()||!u.trim()||s!==null&&c===null,children:h.isPending?`Saving…`:s?`Save changes`:`Create preset`})]})]})})}function uW({open:e,onOpenChange:t,restoreFocusTo:n,presets:r,loading:i,loadError:a,onRetry:o}){return(0,z.jsx)(DR,{open:e,onOpenChange:t,children:(0,z.jsxs)(MR,{className:`max-w-3xl`,restoreFocusTo:n,children:[(0,z.jsxs)(NR,{children:[(0,z.jsx)(PR,{children:`Global terminal presets`}),(0,z.jsx)(FR,{children:`Create commands available in every repository. Arguments are passed exactly as entered.`})]}),(0,z.jsx)(lW,{presets:r,loading:i,loadError:a,onRetry:o})]})})}function dW(e){return e.source.type===`repository`?e.source.format===`zed`?`Repository · Zed`:`Repository`:e.source.type===`user`?`Global`:`${e.source.scope===`project`?`Repository`:`Global`} · ${e.source.packageId}`}function fW({open:e,onOpenChange:t,restoreFocusTo:n,worktreeName:r,presets:i,presetDiagnostics:a,presetsLoading:o,presetsError:s,webPanelDefinitions:c,webPanelDefinitionsLoading:l,webPanelDefinitionsError:u,launchDisabled:d,onCreateTerminal:f,onCreateWebPanel:p,onManagePresets:m}){let[h,g]=(0,R.useState)(``),[_,v]=(0,R.useState)(0),y=h.trim().toLocaleLowerCase(),b=`shell`.includes(y),x=i.filter(e=>[e.name,e.executable,dW(e),UU([e.executable,...e.args])].some(e=>e.toLocaleLowerCase().includes(y))),S=c.filter(e=>[e.title,e.id].some(e=>e.toLocaleLowerCase().includes(y))),C=x.length+ +!!b,w=C===0&&S.length===0;return(0,z.jsx)(DR,{open:e,onOpenChange:e=>{e||(g(``),v(0)),t(e)},children:(0,z.jsxs)(MR,{className:`max-w-xl gap-0 overflow-hidden rounded-xl bg-zinc-800/95 p-0 shadow-2xl ring-white/15 backdrop-blur-2xl max-[700px]:p-0 max-[700px]:pb-0 [&>button.absolute]:hidden`,mobilePresentation:`dialog`,overlayClassName:`bg-transparent backdrop-blur-[1px]`,restoreFocusTo:n,children:[(0,z.jsx)(PR,{className:`sr-only`,children:`New panel`}),(0,z.jsxs)(FR,{className:`sr-only`,children:[`Search for a terminal or web panel to start`,r?` in ${r}`:``,`.`]}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 border-b border-white/8 px-4`,children:[(0,z.jsx)(sz,{className:`size-4 shrink-0 fill-zinc-400`,"aria-hidden":`true`}),(0,z.jsx)(`input`,{type:`search`,name:`panel-launcher-search`,className:`h-14 min-w-0 flex-1 bg-transparent text-base text-zinc-50 outline-none placeholder:text-zinc-500 sm:h-12 sm:text-sm`,value:h,autoComplete:`off`,autoFocus:!0,"aria-label":`Search panels`,placeholder:r?`New panel in ${r}`:`New panel`,onChange:e=>{g(e.target.value),v(0)},onKeyDown:e=>{let t=Array.from(e.currentTarget.closest(`[role="dialog"]`)?.querySelectorAll(`[data-panel-launch]:not(:disabled)`)??[]);if(t.length===0)return;if(e.key===`Enter`){e.preventDefault(),t[_]?.click();return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let n=e.key===`ArrowDown`?1:-1;v((_+n+t.length)%t.length)}}),(0,z.jsx)(`kbd`,{className:`hidden shrink-0 rounded bg-white/6 px-1.5 py-0.5 font-sans text-[0.6875rem] text-zinc-500 ring-1 ring-white/8 sm:inline`,children:`esc`})]}),(0,z.jsxs)(`div`,{className:`max-h-[min(22rem,55dvh)] overflow-y-auto p-1.5 [scrollbar-color:var(--color-zinc-600)_transparent] [&_[data-selected]]:bg-white/8`,onKeyDown:e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=Array.from(e.currentTarget.querySelectorAll(`[data-panel-launch]:not(:disabled)`)),n=t.indexOf(e.target);n<0||t.length<2||(e.preventDefault(),t[(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus())},children:[(0,z.jsxs)(`div`,{role:`group`,"aria-label":`Terminals`,children:[C>0||o||s||a.length>0?(0,z.jsx)(`p`,{className:`px-2 py-1 text-xs font-medium text-zinc-500`,children:`Terminals`}):null,b?(0,z.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-12 w-full justify-start gap-3 rounded-lg py-2 pr-3 pl-2 text-base font-normal text-zinc-100 hover:bg-white/8 focus-visible:bg-white/8 sm:h-9 sm:text-sm`,"aria-label":`Shell`,"data-panel-launch":!0,"data-selected":_===0?``:void 0,disabled:d,onFocus:()=>v(0),onMouseMove:()=>v(0),onClick:()=>{g(``),v(0),f({name:`Shell`})},children:[(0,z.jsx)(tz,{className:`size-4 shrink-0 fill-zinc-400`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:`Shell`}),(0,z.jsx)(`span`,{className:`shrink-0 text-zinc-500`,children:`Login shell`})]}):null,x.map((e,t)=>{let n=t+ +!!b,r=dW(e),i=UU([e.executable,...e.args]);return(0,z.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-12 w-full justify-start gap-3 rounded-lg py-2 pr-3 pl-2 text-base font-normal text-zinc-100 hover:bg-white/8 focus-visible:bg-white/8 sm:h-9 sm:text-sm`,"aria-label":`${e.name}, ${r}, ${i}`,"data-panel-launch":!0,"data-selected":_===n?``:void 0,disabled:d,onFocus:()=>v(n),onMouseMove:()=>v(n),onClick:()=>{g(``),v(0);let t={name:e.name,argv:[e.executable,...e.args]};e.cwd&&(t.cwd=e.cwd),Object.keys(e.env).length&&(t.env={...e.env}),e.closeOnSuccess?t.closeOnSuccess=!0:t.returnToShell=!0,f(t)},children:[(0,z.jsx)(tz,{className:`size-4 shrink-0 fill-zinc-400`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.name}),(0,z.jsxs)(`span`,{className:`min-w-0 max-w-1/2 truncate text-zinc-500`,children:[r,` · `,i]})]},e.id)}),o?(0,z.jsx)(`p`,{className:`px-3 py-2 text-base text-zinc-500 sm:text-sm`,role:`status`,children:`Loading presets…`}):null,s?(0,z.jsx)(`p`,{className:`px-3 py-2 text-base text-zinc-500 sm:text-sm`,role:`status`,children:`Presets unavailable`}):null,a.map(e=>(0,z.jsx)(`p`,{className:`px-3 py-2 text-base text-amber-300 sm:text-sm`,role:`status`,children:e.message},`${e.path}:${e.itemId??`file`}:${e.message}`))]}),(0,z.jsxs)(`div`,{role:`group`,"aria-label":`Web panels`,children:[S.length>0||l||u?(0,z.jsx)(`p`,{className:`mt-1 px-2 py-1 text-xs font-medium text-zinc-500`,children:`Web panels`}):null,S.map((e,t)=>{let n=C+t;return(0,z.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-12 w-full justify-start gap-3 rounded-lg py-2 pr-3 pl-2 text-base font-normal text-zinc-100 hover:bg-white/8 focus-visible:bg-white/8 sm:h-9 sm:text-sm`,"aria-label":`${e.title}, web panel`,"data-panel-launch":!0,"data-selected":_===n?``:void 0,disabled:d,onFocus:()=>v(n),onMouseMove:()=>v(n),onClick:()=>{g(``),v(0),p(e)},children:[(0,z.jsx)(pz,{className:`size-4 shrink-0 fill-zinc-400`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.title}),(0,z.jsx)(`span`,{className:`min-w-0 max-w-1/2 truncate text-zinc-500`,children:e.source.type===`project`?`Project`:`${e.source.scope===`project`?`Project`:`Global`} · ${e.source.packageId}`})]},e.id)}),l?(0,z.jsx)(`p`,{className:`px-3 py-2 text-base text-zinc-500 sm:text-sm`,role:`status`,children:`Loading web panels…`}):null,u?(0,z.jsx)(`p`,{className:`px-3 py-2 text-base text-zinc-500 sm:text-sm`,role:`status`,children:`Web panels unavailable`}):null]}),w&&!o&&!l?(0,z.jsx)(`p`,{className:`px-3 py-8 text-center text-base text-zinc-500 sm:text-sm`,children:`No matching panels.`}):null]}),(0,z.jsxs)(`div`,{className:`border-t border-white/8 p-1.5`,children:[(0,z.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-12 w-full justify-start gap-3 rounded-lg py-2 pr-3 pl-2 text-base font-normal text-zinc-400 hover:bg-white/8 hover:text-zinc-100 sm:h-9 sm:text-sm`,onClick:()=>{g(``),v(0),m()},children:[(0,z.jsx)($R,{className:`size-4 shrink-0 fill-zinc-500`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:`Manage global presets`})]}),(0,z.jsx)(G,{asChild:!0,variant:`ghost`,className:`h-12 w-full justify-start gap-3 rounded-lg py-2 pr-3 pl-2 text-base font-normal text-zinc-400 hover:bg-white/8 hover:text-zinc-100 sm:h-9 sm:text-sm`,children:(0,z.jsxs)(`a`,{href:`https://treeport.app/features/terminal-presets/#repository-presets`,target:`_blank`,rel:`noreferrer`,children:[(0,z.jsx)(UR,{className:`size-4 shrink-0 fill-zinc-500`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:`Configure repository presets`})]})})]})]})})}var pW={phase:`closed`,degraded:!1,controller:!1,controlPending:!1,title:null,bellActive:!1,bellSerial:0,exitSerial:0,fileTransfer:null,hasSelection:!1,selecting:!1,viewingHistory:!1,pasteRequestSerial:0,error:null};function mW({worktree:e,terminal:t,pendingTerminals:n,selectedPendingTerminalId:r,loading:i,autoFocusBlocked:a,onStatusChange:o}){let s=(0,R.useRef)(null),c=(0,R.useRef)(null),l=(0,R.useRef)(null),[u,d]=(0,R.useState)(null),[f,p]=(0,R.useState)(!1),[m,h]=(0,R.useState)(!1),[g,_]=(0,R.useState)({terminalId:null,open:!1,value:``}),v=(0,R.useRef)(o);v.current=o;let y=Hz();(0,R.useLayoutEffect)(()=>{if(!t){d(null);return}let e=qP.acquire(t.id);return d(e),()=>qP.release(t.id)},[t?.id]);let b=u?.terminalId===t?.id?u:null,x=(0,R.useSyncExternalStore)((0,R.useCallback)(e=>{if(!b)return()=>void 0;let t=b.getSnapshot();return b.subscribe(()=>{let n=b.getSnapshot();n.pasteRequestSerial>t.pasteRequestSerial&&_(e=>({terminalId:b.terminalId,open:!0,value:e.terminalId===b.terminalId?e.value:``})),n.exitSerial>t.exitSerial&&v.current(),t=n,e()})},[b]),b?.getSnapshot??(()=>pW),()=>pW),S=g.terminalId===t?.id&&g.open,C=g.terminalId===t?.id?g.value:``,{titles:w}=aF();(0,R.useLayoutEffect)(()=>{let e=c.current;if(!(!e||!b))return b.mount(e),()=>b.unmount(e)},[b]),lf({terminalId:t?.id??null,session:b,blocked:a}),(0,R.useEffect)(()=>{if(b)return b.setInputModifiers(f,m,()=>{p(!1),h(!1)}),()=>b.setInputModifiers(!1,!1,()=>void 0)},[b,m,f]);let T=e=>{let t=e;f&&e.length===1&&(t=String.fromCharCode(e.toUpperCase().charCodeAt(0)&31)),m&&(t=`\u001b${t}`),b?.sendText(t,{focus:!1}),p(!1),h(!1)},E=e=>{b?.sendArrow(e,m,{focus:!1}),p(!1),h(!1)},D=e=>{e&&(b?.pasteText(e),_({terminalId:t?.id??null,open:!1,value:``}))},O=()=>{b?.requestControl(),_(e=>({terminalId:t?.id??null,open:!0,value:e.terminalId===t?.id?e.value:``})),navigator.clipboard&&navigator.clipboard.readText().then(e=>D(e),()=>void 0)},k=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`label`,{htmlFor:`terminal-paste-input`,className:`text-xs font-medium text-zinc-200`,children:`Paste text here`}),(0,z.jsx)(`textarea`,{id:`terminal-paste-input`,autoFocus:!0,rows:2,value:C,placeholder:`Touch and hold here, then choose Paste`,className:`min-h-16 resize-none rounded-md border border-white/10 bg-zinc-950 px-3 py-2 text-base text-zinc-100 outline-none focus:border-cyan-500`,onChange:e=>_({terminalId:t?.id??null,open:!0,value:e.target.value}),onPaste:e=>{let t=e.clipboardData.getData(`text`);t&&(e.preventDefault(),D(t))}}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>_({terminalId:t?.id??null,open:!1,value:``}),children:`Cancel`}),(0,z.jsx)(G,{type:`button`,size:`sm`,disabled:!C,onClick:()=>D(C),children:`Send`})]})]}),ee=n.find(e=>e.id===r),te=t?w.get(t.id)||t.name:ee?.name??``;return(0,z.jsxs)(`main`,{ref:s,className:W(`terminal-shell grid min-h-0 min-w-0 grid-rows-[minmax(0,1fr)] bg-zinc-950 max-[700px]:grid-rows-[minmax(0,1fr)_3.25rem]`,x.bellActive&&`terminal-bell`),"aria-label":ee?`Starting ${ee.name} terminal`:t?`${te} terminal`:`Terminal panel`,children:[ee?(0,z.jsx)(`div`,{className:`grid min-h-0 place-items-center bg-[radial-gradient(circle_at_center,var(--color-zinc-900)_0,var(--color-zinc-950)_55%)] p-8`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-zinc-300`,role:`status`,children:[(0,z.jsx)(LR,{className:`size-4 animate-spin fill-zinc-500`,"aria-hidden":`true`}),`Starting `,ee.name,`…`]})}):t?(0,z.jsxs)(`div`,{className:`relative min-h-0 min-w-0 overflow-hidden`,children:[(0,z.jsx)(`div`,{className:`xterm-host absolute inset-0 min-h-0 min-w-0 overflow-hidden p-2.5 outline-none max-[700px]:p-1.5`,ref:c,onMouseDown:()=>b?.focus({requestControl:!0})},t.id),x.viewingHistory&&!S?(0,z.jsxs)(`div`,{className:`absolute top-3 left-1/2 z-20 flex -translate-x-1/2 items-center gap-2 rounded-full bg-zinc-900/95 py-1 pr-1 pl-3 text-xs text-zinc-300 shadow-lg ring-1 ring-amber-400/20 backdrop-blur`,children:[(0,z.jsxs)(`span`,{role:`status`,className:`whitespace-nowrap leading-tight`,children:[(0,z.jsx)(`strong`,{className:`block font-medium text-zinc-100`,children:x.hasSelection||x.selecting?`Selection is active`:`Scrolled back in tmux`}),(0,z.jsx)(`span`,{className:`block text-[0.6875rem] text-zinc-400`,children:`New output is continuing off-screen`})]}),(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 rounded-full px-2.5 text-xs text-cyan-200 hover:bg-white/8 hover:text-cyan-100`,onClick:()=>{x.hasSelection||x.selecting?b?.clearSelectionAndJumpToLatest():b?.jumpToLatest()},children:x.hasSelection||x.selecting?`Clear`:`Follow latest`})]}):null,x.phase===`ready`&&!x.controller?(0,z.jsxs)(`span`,{className:`absolute top-3 right-3 z-10 inline-flex shrink-0 items-center gap-1.5 rounded-full bg-zinc-900/90 px-2 py-1 text-[0.6875rem] font-medium text-zinc-400 shadow ring-1 ring-white/8 backdrop-blur`,title:`Interact with the terminal to control it`,children:[(0,z.jsx)(`span`,{className:W(`size-1.5 rounded-full bg-zinc-500`,x.controlPending&&`animate-pulse bg-cyan-400`),"aria-hidden":`true`}),x.controlPending?`Taking control…`:`Viewing`]}):null,S&&(y?(0,z.jsx)(DR,{open:!0,onOpenChange:e=>{e||_({terminalId:t.id,open:!1,value:``})},children:(0,z.jsxs)(MR,{className:`max-w-sm gap-3 p-4`,mobilePresentation:`dialog`,restoreFocusTo:l.current,children:[(0,z.jsxs)(NR,{children:[(0,z.jsx)(PR,{className:`text-lg sm:text-lg`,children:`Paste into terminal`}),(0,z.jsx)(FR,{className:`sr-only`,children:`Paste text and send it to the active terminal.`})]}),k]})}):(0,z.jsx)(`div`,{className:`absolute inset-x-3 bottom-3 z-20 grid gap-2 rounded-lg bg-zinc-900 p-3 shadow-xl ring-1 ring-white/15`,role:`dialog`,"aria-label":`Paste into terminal`,children:k})),x.hasSelection&&!S&&(0,z.jsxs)(`div`,{className:`terminal-selection-actions absolute right-3 bottom-3 z-10 overflow-hidden rounded-md bg-zinc-800 shadow-lg ring-1 ring-white/15 max-[700px]:bottom-2`,"aria-label":`Terminal text selection`,children:[(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`rounded-none border-r border-white/10 px-3 text-zinc-100`,onClick:()=>b?.copySelection(),children:`Copy`}),(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`rounded-none px-3 text-zinc-300`,onClick:()=>b?.clearSelection(),children:`Clear`})]}),(x.degraded||x.fileTransfer)&&(0,z.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-0 top-3 z-10 flex flex-col items-center gap-2`,children:[x.degraded&&(0,z.jsx)(`span`,{className:`max-w-[calc(100%-1.5rem)] rounded-full bg-zinc-900/90 px-3 py-1 text-center text-xs text-amber-200 shadow ring-1 ring-amber-400/20 backdrop-blur`,children:x.error?`${x.error} Retrying…`:`Reconnecting…`}),x.fileTransfer&&(0,z.jsx)(`span`,{className:W(`rounded-full bg-zinc-900/90 px-3 py-1 text-xs shadow ring-1 backdrop-blur`,x.fileTransfer.state===`error`?`text-rose-100 ring-rose-400/30`:`text-cyan-100 ring-cyan-400/20`),role:x.fileTransfer.state===`error`?`alert`:`status`,children:x.fileTransfer.message})]}),x.phase===`closed`&&x.error&&(0,z.jsx)(`div`,{className:`absolute inset-x-0 top-3 z-10 flex justify-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-full bg-rose-950/95 px-3 py-1 text-xs text-rose-100 shadow ring-1 ring-rose-400/30 backdrop-blur`,children:[(0,z.jsx)(`span`,{children:x.error}),(0,z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs text-rose-100 hover:bg-rose-900`,onClick:()=>b?.retry(),children:`Retry`})]})}),(0,z.jsxs)(`span`,{className:`sr-only`,"aria-live":`polite`,children:[x.phase===`ready`?x.controller?`Controlling terminal`:x.controlPending?`Taking control of terminal`:`Viewing terminal`:``,x.bellActive?` Bell from ${te}`:``]})]}):i?(0,z.jsx)(`div`,{className:`grid min-h-0 place-items-center bg-[radial-gradient(circle_at_center,var(--color-zinc-900)_0,var(--color-zinc-950)_55%)] p-8`,children:(0,z.jsx)(`div`,{role:`status`,"aria-label":`Loading workspace`,children:(0,z.jsx)(LR,{className:`size-6 animate-spin fill-zinc-500`,"aria-hidden":`true`})})}):(0,z.jsx)(`div`,{className:`empty-state grid min-h-0 place-items-center bg-[radial-gradient(circle_at_center,var(--color-zinc-900)_0,var(--color-zinc-950)_55%)] p-8`,children:(0,z.jsxs)(`div`,{className:`grid max-w-lg gap-3`,children:[(0,z.jsx)(`p`,{className:`eyebrow`,children:`No terminal open`}),(0,z.jsx)(`h1`,{className:`text-balance text-2xl font-semibold tracking-tight text-zinc-50 sm:text-3xl`,children:e?`Start a terminal for this tree.`:`Choose a tree.`}),(0,z.jsx)(`p`,{className:`max-w-[52ch] text-base text-pretty text-zinc-400 sm:text-sm`,children:e?`Use New panel in the sidebar to start a login shell, preset, or web panel.`:`Select a tree from the sidebar to view its terminals.`})]})}),t&&(0,z.jsxs)(`div`,{className:`accessory-row hidden min-w-0 touch-pan-x overflow-x-auto overflow-y-hidden border-t border-white/8 bg-zinc-900 pt-1 pr-[env(safe-area-inset-right)] pb-[calc(0.25rem+env(safe-area-inset-bottom))] pl-[env(safe-area-inset-left)] max-[700px]:flex [&_button]:h-11 [&_button]:min-w-11 [&_button]:grow [&_button]:rounded-none [&_button]:border-r [&_button]:border-white/8 [&_button]:text-sm [&_button:last-child]:border-r-0`,"aria-label":`Terminal accessory keys`,onPointerDownCapture:()=>b?.requestControl(),onMouseDownCapture:e=>e.preventDefault(),children:[(0,z.jsx)(G,{variant:`ghost`,type:`button`,onClick:()=>T(`\x1B`),children:`Esc`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,className:f?`latched bg-cyan-950 text-cyan-100`:``,"aria-pressed":f,onClick:()=>p(e=>!e),children:`Ctrl`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,className:m?`latched bg-cyan-950 text-cyan-100`:``,"aria-pressed":m,onClick:()=>h(e=>!e),children:`Alt`}),(0,z.jsx)(G,{ref:l,variant:`ghost`,type:`button`,onClick:O,children:`Paste`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,onClick:()=>T(` `),children:`Tab`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,onClick:()=>{b?.sendText(`\x1B[Z`,{focus:!1}),p(!1),h(!1)},children:`Shift+Tab`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,onClick:()=>T(`\r`),children:`Enter`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,"aria-label":`Arrow left`,onClick:()=>E(`left`),children:`←`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,"aria-label":`Arrow up`,onClick:()=>E(`up`),children:`↑`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,"aria-label":`Arrow down`,onClick:()=>E(`down`),children:`↓`}),(0,z.jsx)(G,{variant:`ghost`,type:`button`,"aria-label":`Arrow right`,onClick:()=>E(`right`),children:`→`})]})]})}function hW({projects:e,selectedWorktree:t,selectedTerminal:n}){let r=Ye(),{closeMobileWithoutFocusRestore:i}=rB(),a=Ca(),o=Oz(),s=(0,R.useRef)(new Set),c=(0,R.useRef)(0),l=(0,R.useRef)(null),u=(0,R.useRef)(a.pathname),[d,f]=(0,R.useState)([]),[p,m]=(0,R.useState)(null);u.current=a.pathname;let h=d.find(e=>e.id===p&&e.worktreeId===t?.id),g=n?.id??null,_=pt({mutationFn:async({worktreeId:e,name:t,argv:n,cwd:r,env:i,returnToShell:a,closeOnSuccess:o,initialSize:s})=>{let c={name:t};return n&&(c.argv=n),r&&(c.cwd=r),i&&(c.env=i),a&&(c.returnToShell=!0),o&&(c.closeOnSuccess=!0),s&&(c.initialSize=s),(await Tf(yN.api.worktrees[`:worktreeId`].terminals.$post({param:{worktreeId:e},json:c}))).terminal},onSuccess:async(t,{pendingTerminal:n})=>{let i=l.current===n.id,a=i&&u.current===n.originPath;f(e=>e.filter(e=>e.id!==n.id)),i&&(l.current=null,m(null));let s=e.find(e=>e.id===n.projectId),c=s?.worktrees.find(e=>e.id===n.worktreeId);if(!s||!c){await r.invalidateQueries({queryKey:xz});return}let d=n.originPath===fF(s.id,c.id).pathname;r.setQueryData(xz,e=>e?.map(e=>({...e,worktrees:e.worktrees.map(e=>e.id===c.id?{...e,terminals:[...e.terminals.filter(e=>e.id!==t.id),t]}:e)}))),a&&await o(pF(s.id,c.id,t.id),d),await r.invalidateQueries({queryKey:xz})},onError:async(e,{pendingTerminal:t})=>{f(e=>e.filter(e=>e.id!==t.id)),l.current===t.id&&(l.current=null,m(null)),DF(e,{operation:`create terminal “${t.name}”`}),await r.invalidateQueries({queryKey:xz})}}),v=pt({mutationFn:({terminal:e})=>Tf(yN.api.terminals[`:terminalId`].$delete({param:{terminalId:e.id}})),onSuccess:async()=>{await r.invalidateQueries({queryKey:xz})},onError:(e,t)=>{r.setQueryData(xz,e=>e?.map(e=>({...e,worktrees:e.worktrees.map(e=>{if(e.id!==t.terminal.worktreeId||e.terminals.some(e=>e.id===t.terminal.id))return e;let n=[...e.terminals];return n.splice(t.index,0,t.terminal),{...e,terminals:n}})}))),DF(e,{operation:`close terminal “${t.terminal.name}”`})},onSettled:(e,t,n)=>{s.current.delete(n.terminal.id)}});return{pendingTerminals:d,selectedPendingTerminal:h,createTerminalInWorktree:(t,r,o)=>{let s=e.find(e=>e.id===t.id),u=s?.worktrees.find(e=>e.id===r.id);if(!s||!u||s.availability.state===`unavailable`||u.prunable)return;let d=n?.worktreeId===u.id?qP.getInitialSize(n.id):null,p={id:`pending-terminal-${++c.current}`,projectId:s.id,worktreeId:u.id,name:o.name,originPath:a.pathname};l.current=p.id,f(e=>[...e,p]),m(p.id),i();let h={worktreeId:u.id,name:o.name,pendingTerminal:p};o.argv&&(h.argv=[...o.argv]),o.cwd&&(h.cwd=o.cwd),o.env&&(h.env={...o.env}),o.returnToShell&&(h.returnToShell=!0),o.closeOnSuccess&&(h.closeOnSuccess=!0),d&&(h.initialSize=d),_.mutate(h)},requestCloseTerminal:(t,n)=>{let i=e.find(e=>e.worktrees.some(e=>e.id===t.worktreeId)),a=i?.worktrees.find(e=>e.id===t.worktreeId),c=a?.terminals.filter(e=>e.id!==t.id&&!s.current.has(e.id));if(!i||!a||s.current.has(t.id)||!c?.length)return;let l=n?.title??qP.getTitleSnapshot().get(t.id)??t.name;if((n?.hasForegroundProcess??qP.getForegroundProcessSnapshot().has(t.id))&&!window.confirm(`Close terminal “${l}”? Its foreground process will be terminated.`))return;let u=a.terminals.findIndex(e=>e.id===t.id);if(s.current.add(t.id),r.cancelQueries({queryKey:xz}),g===t.id){let e=a.terminals.slice(u+1).find(e=>!s.current.has(e.id))??a.terminals.slice(0,u).reverse().find(e=>!s.current.has(e.id));e&&o(pF(i.id,a.id,e.id),!0)}qP.forget(t.id),r.setQueryData(xz,e=>e?.map(e=>({...e,worktrees:e.worktrees.map(e=>e.id===a.id?{...e,terminals:e.terminals.filter(e=>e.id!==t.id)}:e)}))),v.mutate({terminal:t,index:u})},clearPendingTerminalSelection:()=>{l.current=null,m(null)},selectPendingTerminal:e=>{d.some(t=>t.id===e)&&(l.current=e,m(e),i())}}}function gW({selectedWorktree:e,selectedTerminal:t,selectedPendingTerminal:n,pendingTerminals:r,loading:i,dialogOpen:a}){let o=Ye(),{isMobile:s,openMobile:c}=rB(),{open:l}=IB();return(0,z.jsx)(mW,{worktree:e,terminal:n?null:t,pendingTerminals:r.filter(t=>t.worktreeId===e?.id),selectedPendingTerminalId:n?.id??null,loading:i,autoFocusBlocked:a||l||s&&c,onStatusChange:()=>void o.invalidateQueries({queryKey:xz})})}var _W=`treeport-initial-terminal-preset`;function vW({project:e,presets:t,presetDiagnostics:n,presetsLoading:r,presetsError:i,onRetryPresets:a,busy:o,onSubmit:s}){let[c,l]=(0,R.useState)(``),[u,d]=(0,R.useState)(`default`),[f,p]=(0,R.useState)(()=>localStorage.getItem(_W)??`shell`),m=t.filter(e=>!e.closeOnSuccess),h=m.some(e=>e.id===f),g=f!==`shell`&&!h,_=g&&r,v=g&&!r&&!i,y=g&&!r?`shell`:f,b=u==="default"?`default`:`current`;return(0,z.jsxs)(`form`,{className:`flex flex-col gap-5`,autoComplete:`off`,onSubmit:e=>{e.preventDefault();let t=c.trim();if(o||!t)return;let n=m.find(e=>e.id===y);v&&localStorage.setItem(_W,`shell`),s(t,b,n?{name:n.name,argv:[n.executable,...n.args],returnToShell:!0}:{name:`Shell`},b===`current`?u:void 0)},children:[(0,z.jsxs)(gz,{children:[(0,z.jsx)(vz,{htmlFor:`worktree-name`,children:`Name`}),(0,z.jsx)(_z,{id:`worktree-name`,name:`worktree-name`,value:c,onChange:e=>l(e.target.value),placeholder:`feature-name`,"aria-label":`Tree name`,autoCapitalize:`none`,spellCheck:!1,required:!0,autoFocus:!0,disabled:o})]}),(0,z.jsxs)(gz,{children:[(0,z.jsx)(vz,{htmlFor:`worktree-base`,children:`Start from`}),(0,z.jsxs)(HB,{id:`worktree-base`,name:`worktree-base`,value:u,onChange:e=>d(e.target.value),disabled:o,children:[(0,z.jsxs)(`option`,{value:`default`,children:[e.defaultBranch,` · latest from origin`]}),e.worktrees.map(e=>(0,z.jsxs)(`option`,{value:e.id,children:[e.name,` · current commit`]},e.id))]})]}),(0,z.jsxs)(gz,{children:[(0,z.jsx)(vz,{htmlFor:`initial-terminal-preset`,children:`Initial terminal`}),(0,z.jsxs)(HB,{id:`initial-terminal-preset`,name:`initial-terminal-preset`,value:y,onChange:e=>{p(e.target.value),localStorage.setItem(_W,e.target.value)},disabled:o,children:[_&&(0,z.jsx)(`option`,{value:f,children:`Loading saved preset…`}),(0,z.jsx)(`option`,{value:`shell`,children:`Shell`}),m.map(e=>(0,z.jsxs)(`option`,{value:e.id,children:[e.name,` — `,dW(e),` —`,` `,UU([e.executable,...e.args])]},e.id))]}),v&&(0,z.jsx)(`p`,{className:`form-note`,role:`status`,children:`The selected preset cannot be used as an initial terminal. Initial terminal changed to Shell.`}),r&&(0,z.jsx)(`p`,{className:`form-note`,role:`status`,children:`Loading terminal presets…`}),i&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`p`,{className:`form-note`,children:`Presets could not be loaded. Shell is still available.`}),(0,z.jsx)(G,{type:`button`,variant:`secondary`,size:`sm`,onClick:a,children:`Retry`})]}),n.map(e=>(0,z.jsx)(`p`,{className:`form-note`,role:`status`,children:e.message},`${e.path}:${e.itemId??`file`}:${e.message}`))]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 pt-1`,children:[(0,z.jsx)(`p`,{className:`hidden text-xs text-zinc-600 sm:block`,children:`Press Enter to create`}),(0,z.jsx)(G,{type:`submit`,className:`ml-auto`,disabled:o||_||!c.trim(),children:o?`Creating…`:`Create tree`})]})]})}function yW({project:e,onOpenChange:t,restoreFocusTo:n,presets:r,presetDiagnostics:i,presetsLoading:a,presetsError:o,onRetryPresets:s,onSubmit:c}){let l=(0,R.useRef)(!1);return(0,z.jsx)(DR,{open:e!==null,onOpenChange:t,children:e?(0,z.jsxs)(MR,{className:`max-w-md`,mobilePresentation:`dialog`,restoreFocusTo:n,onCloseAutoFocus:e=>{l.current&&(l.current=!1,e.preventDefault())},children:[(0,z.jsxs)(NR,{children:[(0,z.jsx)(`p`,{className:`eyebrow`,children:e.name}),(0,z.jsx)(PR,{children:`Create tree`}),(0,z.jsx)(FR,{className:`sr-only`,children:`Create a linked tree and choose its starting point and initial terminal.`})]}),(0,z.jsx)(vW,{project:e,presets:r,presetDiagnostics:i,presetsLoading:a,presetsError:o,onRetryPresets:s,busy:!1,onSubmit:(t,n,r,i)=>{l.current=!0,c(e,t,n,r,i)}})]}):null})}function bW({worktree:e,preview:t,busy:n,onOpenChange:r,restoreFocusTo:i,onConfirm:a}){let o=!!t?.warnings.length,s=t?.name??e?.name,c=t?.branch??e?.branch,l=t?.detached??e?.detached,u=t?.head??e?.head,d=t?.path??e?.path;return(0,z.jsx)(fR,{open:e!==null,onOpenChange:r,children:e&&t?(0,z.jsxs)(hR,{restoreFocusTo:i,children:[(0,z.jsxs)(gR,{children:[(0,z.jsx)(`p`,{className:`eyebrow`,children:o?`Destructive removal`:`Tree`}),(0,z.jsx)(vR,{children:`Remove tree`}),(0,z.jsx)(yR,{children:`Review what will be removed before continuing.`})]}),(0,z.jsxs)(`dl`,{className:`facts`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Name`}),(0,z.jsx)(`dd`,{children:s})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Git state`}),(0,z.jsx)(`dd`,{children:!l&&c?`Branch ${c} (preserved)`:`Detached at ${u?.slice(0,8)}`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Path`}),(0,z.jsx)(`dd`,{children:d})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Uncommitted`}),(0,z.jsx)(`dd`,{children:`${t.dirty.total} (${t.dirty.staged} staged, ${t.dirty.unstaged} unstaged, ${t.dirty.untracked} untracked, ${t.dirty.conflicts} conflicted)`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Terminals stopped`}),(0,z.jsx)(`dd`,{children:t.terminals.map(e=>e.name).join(`, `)||`none`})]})]}),t.reasons.length>0?(0,z.jsxs)(`div`,{className:`warning`,children:[(0,z.jsx)(`strong`,{children:`Removal refused`}),(0,z.jsx)(`ul`,{role:`list`,children:t.reasons.map(e=>(0,z.jsx)(`li`,{children:e},e))})]}):null,t.warnings.length>0?(0,z.jsxs)(`div`,{className:`warning danger`,children:[(0,z.jsx)(`strong`,{children:`Local work may be lost.`}),(0,z.jsx)(`ul`,{role:`list`,children:t.warnings.map(e=>(0,z.jsx)(`li`,{children:e},e))})]}):null,(0,z.jsxs)(_R,{children:[(0,z.jsx)(xR,{children:`Cancel`}),(0,z.jsx)(bR,{asChild:!0,children:(0,z.jsx)(G,{type:`button`,variant:`destructive`,disabled:n||!t.eligible,onClick:n=>{n.preventDefault(),a(e,t)},children:n?`Removing…`:o?`Remove anyway`:`Remove tree`})})]})]}):null})}function xW({projects:e,setDrawerOpen:t,onWorktreeSubmitted:n,onRemovalNeedsConfirmation:r,onRemovalCompleted:i,selectedTerminalId:a}){let o=Ye(),s=Ca(),c=Oz(),l=dt({queryKey:[`worktree-creations`],queryFn:async()=>(await Tf(yN.api.operations.$get({query:{kind:`create`}}))).operations,refetchInterval:2e3,refetchOnReconnect:!0,refetchOnWindowFocus:!0}),u=dt({queryKey:[`worktree-removals`],queryFn:async()=>(await Tf(yN.api.operations.$get({query:{kind:`remove`}}))).operations,refetchInterval:2e3,refetchOnReconnect:!0,refetchOnWindowFocus:!0}),[d,f]=(0,R.useState)([]),p=(l.data??[]).flatMap(e=>{if(e.kind!==`create`)return[];let t=e.request.name;return e.projectId?[{id:e.id,projectId:e.projectId,typedName:t}]:[]}),m=(0,R.useRef)(new Set),h=(0,R.useRef)(new Set),g=lt({queries:d.map(e=>({queryKey:[`operation`,e.id],queryFn:async()=>(await Tf(yN.api.operations[`:operationId`].$get({param:{operationId:e.id}}))).operation,refetchInterval:500}))}),_=new Set(g.flatMap(t=>{let n=t.data;if(n?.status!==`completed`||n.kind!==`create`)return[];let r=n.result?.worktreeId??n.worktreeId;return r&&e.some(e=>e.worktrees.some(e=>e.id===r))?[n.id]:[]})),v=p.filter(e=>!_.has(e.id)),y=new Set(v.map(e=>e.id)),b=[...v,...d.filter(e=>!y.has(e.id)&&!_.has(e.id)).map(({id:e,projectId:t,typedName:n})=>({id:e,projectId:t,typedName:n}))],[x,S]=(0,R.useState)({}),C=(u.data??[]).reduce((e,t)=>(t.kind===`remove`&&t.request.preview&&(e[t.request.preview.worktreeId]=`removing`),e),{...x}),w=(0,R.useRef)(new Set),T=pt({mutationFn:e=>{let t={name:e.typedName,base:e.base,initialTerminal:e.initialTerminal};return e.sourceWorktreeId&&Object.assign(t,{sourceWorktreeId:e.sourceWorktreeId}),Tf(yN.api.projects[`:projectId`][`worktree-operations`].$post({param:{projectId:e.projectId},json:t})).then(e=>e.operation)},onSuccess:(e,t)=>{let n=e.kind===`create`?e.request.name:t.typedName;f(r=>[...r,{id:e.id,projectId:t.projectId,typedName:n,replacesEmptyProject:s.pathname===dF(t.projectId).pathname}]),o.invalidateQueries({queryKey:[`worktree-creations`]})},onError:(e,n)=>{t(!1),DF(e,{operation:`create tree “${n.typedName}”`})}});(0,R.useEffect)(()=>{for(let e of b)d.some(t=>t.id===e.id)&&!h.current.has(e.id)&&(h.current.add(e.id),window.requestAnimationFrame(()=>{document.getElementById(`pending-worktree-${e.id}`)?.focus()}))},[d,b]),(0,R.useEffect)(()=>{g.forEach((e,n)=>{let r=e.data,i=d[n];!r||r.kind!==`create`||!i||r.status!==`completed`&&r.status!==`failed`||m.current.has(r.id)||(m.current.add(r.id),(async()=>{if(await o.invalidateQueries({queryKey:[`worktree-creations`]}),r.status===`failed`)DF(r.error??`Tree creation failed`,{operation:`create tree “${i.typedName}”`});else{await o.invalidateQueries({queryKey:xz});let e=(await Tf(yN.api.projects.$get())).projects;o.setQueryData(xz,e);let n=r.result,a=n?.worktreeId??r.worktreeId,s=n?.terminalId??null,l=e.find(e=>e.id===i.projectId)?.worktrees.find(e=>e.id===a);if(l){let e=s?pF(i.projectId,l.id,s):fF(i.projectId,l.id);await c(e,i.replacesEmptyProject)}t(!1),n?.setupError?DF(n.setupError,{operation:`start setup for newly created tree “${i.typedName}”`}):n?.terminalError&&DF(n.terminalError,{operation:`start a terminal for newly created tree “${i.typedName}”`})}f(e=>e.filter(e=>e.id!==r.id))})())})},[c,g,d,o,t]);let E=(e,t,r,i,o)=>{let s=a?qP.getInitialSize(a):null,c={name:i.name};i.argv&&(c.argv=[...i.argv]),i.returnToShell&&(c.returnToShell=!0),s&&(c.initialSize=s);let l={projectId:e.id,typedName:t,base:r,initialTerminal:c};o&&(l.sourceWorktreeId=o),n(),T.mutate(l)},D=(e,t)=>S(n=>({...n,[e]:t})),O=e=>{w.current.delete(e),S(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})},k=async(e,t,n,a)=>{D(e.id,`removing`);try{await Tf(yN.api.worktrees[`:worktreeId`].remove.$post({param:{worktreeId:e.id},json:{confirmationToken:t.confirmationToken,confirmDestructive:n}})),await o.invalidateQueries({queryKey:[`worktree-removals`]}),O(e.id),i(e.id),o.invalidateQueries({queryKey:xz},{cancelRefetch:!1})}catch(t){if(DN(t).code===`REMOVE_PREVIEW_STALE`&&a>0){D(e.id,`checking`);try{let t=(await Tf(yN.api.worktrees[`:worktreeId`][`remove-preview`].$get({param:{worktreeId:e.id}}))).preview;if(t.eligible&&t.warnings.length===0){await k(e,t,!1,a-1);return}O(e.id),r(e,t);return}catch(t){O(e.id),DF(t,{operation:`refresh removal details for tree “${e.name}”`});return}}O(e.id),DF(t,{operation:`remove tree “${e.name}”`})}};return{pendingWorktrees:b,pendingRemovals:C,submitWorktreeCreation:E,prepareRemoval:async(e,t)=>{if(!(w.current.has(e.id)||C[e.id])){w.current.add(e.id),D(e.id,`checking`);try{let n=(await Tf(yN.api.worktrees[`:worktreeId`][`remove-preview`].$get({param:{worktreeId:e.id}}))).preview;if(n.eligible&&n.warnings.length===0){await k(e,n,!1,1);return}O(e.id),r(e,n,t)}catch(t){O(e.id),DF(t,{operation:`check whether tree “${e.name}” can be removed`})}}},confirmRemoval:(e,t)=>{w.current.has(e.id)||(w.current.add(e.id),k(e,t,t.warnings.length>0,1))}}}function SW(e,t){let n=Ye(),r=(0,R.useRef)(t);r.current=t;let[i,a]=(0,R.useState)(!1);return(0,R.useEffect)(()=>{let e=xE(`/events`,{path:kN,transports:[`websocket`],autoConnect:!1,retries:0}),t=Pf(()=>n.invalidateQueries({queryKey:xz},{cancelRefetch:!1})),i=Pf(()=>Promise.all([n.invalidateQueries({queryKey:xz},{cancelRefetch:!1}),n.invalidateQueries({queryKey:Sz},{cancelRefetch:!1}),n.invalidateQueries({queryKey:[`terminal-preset-definitions`]},{cancelRefetch:!1}),n.invalidateQueries({queryKey:[`web-panel-definitions`]},{cancelRefetch:!1})]).then(()=>void 0)),o=()=>{t.schedule(),Promise.all([n.invalidateQueries({queryKey:[`worktree-creations`]}),n.invalidateQueries({queryKey:[`worktree-removals`]})])},s=()=>i.schedule(),c=e=>{let t=dP(e);if(!t){a(!0);return}qP.replaceRuntimeMetadata(t.terminalMetadata),a(!1),o()},l=e=>{let t=fP(e);if(t){if(t.type===`terminal.metadata`){qP.applyRuntimeMetadata({terminalId:t.data.terminalId,title:t.data.title,program:t.data.program,hasForegroundProcess:t.data.hasForegroundProcess,progress:t.data.progress,progressStartedAt:t.data.progressStartedAt,progressClearedAt:t.data.progressClearedAt,bell:t.data.bell});return}if(t.type===`panel.open_requested`){o(),r.current?.(t.data);return}if(t.type===`project.updated`){s();return}if(t.type===`project.removed`){s();return}t.type!==`terminal.controller_changed`&&o()}},u=()=>a(!0);return e.on(`snapshot`,c),e.on(`product_event`,l),e.on(`disconnect`,u),e.on(`connect_error`,u),e.connect(),()=>{t.dispose(),i.dispose(),e.disconnect()}},[n]),(0,R.useEffect)(()=>{e&&qP.reconcile(e.flatMap(e=>e.worktrees.flatMap(e=>e.terminals)))},[e]),i}function CW(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(LB,{children:(0,z.jsx)(wW,{})}),(0,z.jsx)(qh,{})]})}function wW(){let e=window.treeportDesktop,t=Oz(),n=Ye(),r=Ca(),i=dt(wz),a=i.data??[],o=dt(Ez),s=o.data??[],c=localStorage.getItem(sF),l=i.data?EF(a,r.pathname,c):null,u=l?.selection.project??null,d=l?.selection.worktree??null,f=l?.selection.terminal??null,p=f?.id??null,m=l?.selection.panel??null,h=m?.id??null,g=u,{isMobile:_,openMobile:v,setOpenMobile:y,closeMobileWithoutFocusRestore:b}=rB(),x=IB(),S=x.open,[C,w]=(0,R.useState)(null),[T,E]=(0,R.useState)(!1),[D,O]=(0,R.useState)(!1),[k,ee]=(0,R.useState)(()=>new Set),[te,A]=(0,R.useState)({}),[j,M]=(0,R.useState)({}),ne=(0,R.useCallback)((e,t)=>{M(n=>{if(t===null){if(n[e]===void 0)return n;let t={...n};return delete t[e],t}return n[e]===t?n:{...n,[e]:t}})},[]);(0,R.useEffect)(()=>{let e=new Set(a.flatMap(e=>e.worktrees.flatMap(e=>e.panels.filter(e=>e.kind===`web`).map(e=>e.id))));M(t=>{let n=Object.keys(t).filter(t=>!e.has(t));if(n.length===0)return t;let r={...t};return n.forEach(e=>delete r[e]),r})},[a]);let N=C?.type===`panel`?a.find(e=>e.id===C.projectId)??null:null,P=C?.type===`panel`&&C.worktreeId?N?.worktrees.find(e=>e.id===C.worktreeId)??null:null,re=dt(Dz(C?.type===`worktree`?{projectId:C.project.id}:P?{worktreeId:P.id}:d?{worktreeId:d.id}:u?{projectId:u.id}:void 0)),ie=re.data?.definitions??[],ae=re.data?.diagnostics??[],F=dt({queryKey:[`web-panel-definitions`,P?.id],queryFn:async()=>(await Tf(yN.api.worktrees[`:worktreeId`][`web-panel-definitions`].$get({param:{worktreeId:P.id}}))).definitions,enabled:!!P}),I=pt({mutationFn:({worktree:e,definition:t,input:n})=>Tf(yN.api.worktrees[`:worktreeId`].panels.$post({param:{worktreeId:e.id},json:{definitionId:t.id,input:n,launchCwd:null}})).then(e=>e.panel),onSuccess:async e=>{w(null),await n.invalidateQueries({queryKey:wz.queryKey});let r=vF(n.getQueryData(wz.queryKey)??a,e);r&&await t(r)},onError:(e,{worktree:t,definition:n})=>{DF(e,{operation:`create web panel “${n.title}” in tree “${t.name}”`})}}),L=pt({mutationFn:({panel:e,discardStoredData:t=!1})=>{let n={};return t&&(n.discardStoredData=`true`),Tf(yN.api.panels[`:panelId`].$delete({param:{panelId:e.id},query:n}))},onSuccess:async(e,{panel:r})=>{if(ne(r.id,null),w(e=>e?.type===`close-web-panel`&&e.panel.id===r.id?null:e),m?.id===r.id){let e=a.flatMap(e=>e.worktrees).find(e=>e.id===r.worktreeId),n=e?bF(a,e):null;n&&await t(n,!0)}await n.invalidateQueries({queryKey:wz.queryKey})},onError:(e,{panel:t})=>{DF(e,{operation:`close web panel “${t.title}”`})}}),oe=(e,t)=>{Tf(yN.api.panels[`:panelId`].storage.$get({param:{panelId:e.id}})).then(({hasData:n})=>{n?fe({type:`close-web-panel`,panel:e},t):L.mutate({panel:e})},t=>{DF(t,{operation:`check stored data for web panel “${e.title}”`})})},se=(0,R.useCallback)(e=>{A(t=>({...t,[e.panelId]:(t[e.panelId]??0)+1})),lF(e.sourceTerminalId,p)&&n.invalidateQueries({queryKey:wz.queryKey}).then(async()=>{let r=n.getQueryData(wz.queryKey)??[],i=r.flatMap(e=>e.worktrees).find(t=>t.id===e.worktreeId)?.panels.find(t=>t.kind===`web`&&t.id===e.panelId),a=i?vF(r,i):null;a&&await t(a)}).catch(e=>{DF(e,{operation:`open web panel`})})},[t,n,p]),ce=SW(i.data,se),[le,ue]=(0,R.useState)(!1),de=(0,R.useRef)(null),fe=(e,t)=>{de.current=t??document.activeElement,w(e)};(0,R.useEffect)(()=>{h&&ee(e=>{if(e.has(h))return e;let t=new Set(e);return t.add(h),t})},[h]),(0,R.useEffect)(()=>{!l||l.canonical||t(l.target,!0)},[t,l?.canonical,l?.target.pathname]),(0,R.useEffect)(()=>{l?.canonical&&(l.target.kind===`root`?localStorage.removeItem(sF):localStorage.setItem(sF,l.target.pathname),l.target.kind===`terminal`&&localStorage.setItem(`${cF}${l.target.projectId}`,l.target.terminalId))},[l?.canonical,l?.target.pathname]),(0,R.useEffect)(()=>{if(!(i.data!==void 0&&(ce||i.isRefetchError))){ue(!1);return}let e=window.setTimeout(()=>ue(!0),jf);return()=>window.clearTimeout(e)},[ce,i.data,i.isRefetchError]);let pe=(0,R.useMemo)(()=>g?.worktrees.flatMap(e=>e.terminals)??[],[g]),me=(0,R.useMemo)(()=>a.flatMap(e=>e.worktrees).flatMap(e=>e.panels).filter(e=>e.kind===`web`&&(k.has(e.id)||e.id===h)),[a,k,h]),he=(0,R.useCallback)(e=>{let n=yF(a,e);n&&t(n),b()},[b,t,a]),ge=e=>{let n=bF(a,e,p);n&&t(n),b()},_e=e=>gF(e,localStorage.getItem(`${cF}${e.id}`)),ve=e=>{let n=_e(e);x.dismissedIntoTerminalRef.current=!_&&n.kind===`terminal`,t(n,!1,!_),x.setOpen(!1),b()},{closingProjectId:ye,requestProjectClose:be,projectOpened:xe}=kz({projects:a,selectedProject:u,targetForProject:_e,projectSwitcherTriggerRef:x.triggerRef,closeProjectUi:()=>x.setOpen(!1),openedProjectUi:()=>{x.setOpen(!1),b(),w(null)}}),Se=e=>{let t=_e(e);return x.dismissedIntoTerminalRef.current=!_&&t.kind===`terminal`,xe(e,!_)},{pendingWorktrees:Ce,pendingRemovals:we,submitWorktreeCreation:Te,prepareRemoval:Ee,confirmRemoval:De}=xW({projects:a,setDrawerOpen:e=>{e?y(!0):b()},onWorktreeSubmitted:()=>w(null),onRemovalNeedsConfirmation:(e,t,n)=>fe({type:`remove`,worktree:e,preview:t},n),onRemovalCompleted:e=>w(t=>t?.type===`remove`&&t.worktree.id===e?null:t),selectedTerminalId:p}),Oe=hW({projects:a,selectedWorktree:d,selectedTerminal:f}),ke=(0,R.useCallback)(e=>{E(!1),O(!1),Oe.clearPendingTerminalSelection(),he(e)},[he,Oe.clearPendingTerminalSelection]),Ae=(0,R.useCallback)(e=>{Oe.clearPendingTerminalSelection();let n=vF(a,e);n&&t(n),b()},[b,t,a,Oe.clearPendingTerminalSelection]),je=(0,R.useCallback)(e=>{if(C||S||_&&v||!d)return!1;let t=d.terminals[e];if(t)return ke(t),!0;let n=d.panels.filter(e=>e.kind===`web`),r=n[e-d.terminals.length];if(r)return Ae(r),!0;let i=Oe.pendingTerminals.filter(e=>e.worktreeId===d.id)[e-d.terminals.length-n.length];return i?(Oe.selectPendingTerminal(i.id),!0):!1},[C,v,_,S,d,ke,Ae,Oe.pendingTerminals,Oe.selectPendingTerminal]);(0,R.useEffect)(()=>{let e=e=>{if(!e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return;let t=Number(e.key)-1;!Number.isInteger(t)||t<0||t>8||je(t)&&(e.preventDefault(),e.stopPropagation())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[je]);let Me=!N||!P||N.availability.state===`unavailable`||!!P.prunable||!!we[P.id];return(0,R.useEffect)(()=>{if(e)return e.onCommand(e=>{if(!(C||S||_&&v)){if(e===`new-worktree`){g&&g.availability.state!==`unavailable`&&fe({type:`worktree`,project:g});return}!u||!d||(e===`new-terminal`?Oe.createTerminalInWorktree(u,d,{name:`Shell`}):e===`new-panel`?fe({type:`panel`,projectId:u.id,worktreeId:d.id}):e===`close-panel`&&(m?oe(m):!Oe.selectedPendingTerminal&&f&&Oe.requestCloseTerminal(f)))}})},[g,C,v,_,S,u,f,m,d,Oe.selectedPendingTerminal]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(jF,{projects:a,selectedTerminalId:p}),(0,z.jsx)(BB,{blocked:C!==null}),(0,z.jsx)(WB,{selectedTerminalId:Oe.selectedPendingTerminal||m?null:p,terminals:pe,onSelectTerminal:ke,notificationCenter:(0,z.jsx)(kF,{projects:a,navigateToWorkspace:t,open:D,onOpenChange:O})}),(0,z.jsx)(UB,{notificationCenter:(0,z.jsx)(kF,{projects:a,navigateToWorkspace:t,open:T,onOpenChange:E}),projectSwitcher:(0,z.jsx)(VB,{projects:a,activeProject:g,closingProjectId:ye,onSelectProject:ve,onProjectOpened:Se,onRequestProjectClose:be,onOpenProjectDialog:e=>fe({type:`project`},e)}),children:(0,z.jsx)(VU,{projects:a,projectsPending:i.isPending,projectsError:i.isError,projectsLoaded:i.data!==void 0,activeProject:g,selectedWorktree:d,selectedTerminalId:Oe.selectedPendingTerminal||m?null:p,selectedWebPanelId:Oe.selectedPendingTerminal?null:m?.id??null,webPanelRuntimeTitles:j,selectedPendingTerminalId:Oe.selectedPendingTerminal?.id??null,pendingTerminals:Oe.pendingTerminals,pendingWorktrees:Ce,pendingRemovals:we,onRetryProjects:()=>void i.refetch(),onSelectTerminal:ke,onSelectPendingTerminal:Oe.selectPendingTerminal,onCloseTerminal:Oe.requestCloseTerminal,onSelectWebPanel:Ae,onCloseWebPanel:oe,onSelectWorktree:ge,onPrepareRemoval:Ee,onOpenPanelDialog:(e,t,n)=>fe({type:`panel`,projectId:e.id,worktreeId:t?.id??null},n),onOpenWorktreeDialog:(e,t)=>fe({type:`worktree`,project:e},t)})}),(0,z.jsxs)(RB,{children:[me.map(e=>(0,z.jsx)(ER,{panel:e,active:e.id===h&&!Oe.selectedPendingTerminal,title:j[e.id]??e.title,reloadRevision:te[e.id]??0,autoFocusBlocked:C!==null||S||_&&v,onTitleChange:ne,onSelectWorkspace:je},e.id)),(!m||Oe.selectedPendingTerminal)&&(0,z.jsx)(gW,{selectedWorktree:d,selectedTerminal:f,selectedPendingTerminal:Oe.selectedPendingTerminal,pendingTerminals:Oe.pendingTerminals,loading:i.isPending,dialogOpen:C!==null})]}),le?(0,z.jsx)(`div`,{className:`fixed right-4 bottom-4 z-70 flex max-w-[min(30rem,calc(100vw-2rem))] items-center gap-3 rounded-lg bg-zinc-800 p-3 text-sm text-zinc-300 shadow-2xl ring-1 ring-white/10`,role:`status`,inert:_&&v?!0:void 0,"aria-hidden":_&&v?!0:void 0,children:(0,z.jsx)(`span`,{children:`Updates paused; showing the last known project state.`})}):null,(0,z.jsx)(bz,{open:C?.type===`project`,onOpenChange:e=>!e&&w(null),restoreFocusTo:de.current,onOpened:xe}),(0,z.jsx)(yW,{project:C?.type===`worktree`?C.project:null,onOpenChange:e=>!e&&w(null),restoreFocusTo:de.current,presets:ie,presetDiagnostics:ae,presetsLoading:re.isPending,presetsError:re.isError,onRetryPresets:()=>void re.refetch(),onSubmit:Te}),(0,z.jsx)(fW,{open:C?.type===`panel`,onOpenChange:e=>!e&&w(null),restoreFocusTo:de.current,worktreeName:P?.name??null,presets:ie,presetDiagnostics:ae,presetsLoading:re.isPending,presetsError:re.isError,webPanelDefinitions:F.data??[],webPanelDefinitionsLoading:!!P&&F.isPending,webPanelDefinitionsError:F.isError,launchDisabled:Me||I.isPending,onCreateTerminal:e=>{!N||!P||(w(null),Oe.createTerminalInWorktree(N,P,e))},onCreateWebPanel:e=>{P&&I.mutate({worktree:P,definition:e,input:null})},onManagePresets:()=>w({type:`presets`})}),(0,z.jsx)(uW,{open:C?.type===`presets`,onOpenChange:e=>!e&&w(null),restoreFocusTo:de.current,presets:s,loading:o.isPending,loadError:o.isError,onRetry:()=>void o.refetch()}),(0,z.jsx)(SR,{panel:C?.type===`close-web-panel`?C.panel:null,busy:L.isPending,onOpenChange:e=>!e&&w(null),restoreFocusTo:de.current,onConfirm:e=>L.mutate({panel:e,discardStoredData:!0})}),(0,z.jsx)(bW,{worktree:C?.type===`remove`?C.worktree:null,preview:C?.type===`remove`?C.preview:null,busy:C?.type===`remove`&&we[C.worktree.id]!==void 0,onOpenChange:e=>!e&&w(null),restoreFocusTo:de.current,onConfirm:De})]})}function TW({reset:e}){return(0,z.jsx)(`main`,{className:`grid min-h-dvh place-items-center bg-zinc-950 p-6 text-zinc-100`,"aria-labelledby":`app-error-title`,children:(0,z.jsxs)(`section`,{className:`w-full max-w-lg rounded-xl bg-zinc-900 p-6 shadow-2xl ring-1 ring-white/10`,role:`alert`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-rose-300`,children:`Unexpected error`}),(0,z.jsx)(`h1`,{id:`app-error-title`,className:`mt-2 text-xl font-semibold`,children:`Treeport couldn’t display this workspace`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm text-zinc-400`,children:`Try recovering the interface. If the problem continues, reload Treeport; your persistent terminal sessions will keep running.`}),(0,z.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-3`,children:[(0,z.jsx)(G,{type:`button`,onClick:e,children:`Try again`}),(0,z.jsx)(G,{type:`button`,variant:`secondary`,onClick:()=>window.location.reload(),children:`Reload Treeport`})]})]})})}var EW=ra({component:CW,errorComponent:TW,onCatch:e=>console.error(`Unexpected application crash`,e)}),DW=ta({getParentRoute:()=>EW,path:`/`}),OW=ta({getParentRoute:()=>EW,path:`projects/$projectId`}),kW=ta({getParentRoute:()=>OW,path:`worktrees/$worktreeId`}),AW=ta({getParentRoute:()=>kW,path:`terminals/$terminalId`}),jW=ta({getParentRoute:()=>kW,path:`panels/$panelId`}),MW=ya({routeTree:EW.addChildren([DW,OW.addChildren([kW.addChildren([AW,jW])])]),defaultPreload:!1,scrollRestoration:!1}),NW=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,PW=document.querySelector(`meta[name="viewport"]`);NW&&PW&&!PW.content.includes(`maximum-scale`)&&(PW.content=`${PW.content}, maximum-scale=1`);var FW=new Ge({defaultOptions:{queries:{retry:Mf,retryDelay:Nf,refetchOnReconnect:!0},mutations:{retry:!1}}});(0,wa.createRoot)(document.getElementById(`root`)).render((0,z.jsx)(R.StrictMode,{children:(0,z.jsx)(Xe,{client:FW,children:(0,z.jsx)(ef,{children:(0,z.jsxs)(sf,{children:[(0,z.jsx)(Sa,{router:MW}),(0,z.jsx)(to,{})]})})})}));
|