@vibedeckx/ui-dist 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/ui/404/index.html +2 -2
- package/ui/404.html +2 -2
- package/ui/__next.__PAGE__.txt +2 -2
- package/ui/__next._full.txt +6 -6
- package/ui/__next._head.txt +1 -1
- package/ui/__next._index.txt +5 -5
- package/ui/__next._tree.txt +2 -2
- package/ui/_next/static/chunks/168c1c7cc189ae44.css +1 -0
- package/ui/_next/static/chunks/{9aeb8562e641b193.js → 72099a99d6861369.js} +3 -3
- package/ui/_next/static/chunks/bd765d8ebd40270d.js +35 -0
- package/ui/_not-found/__next._full.txt +5 -5
- package/ui/_not-found/__next._head.txt +1 -1
- package/ui/_not-found/__next._index.txt +5 -5
- package/ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
- package/ui/_not-found/__next._not-found.txt +1 -1
- package/ui/_not-found/__next._tree.txt +2 -2
- package/ui/_not-found/index.html +2 -2
- package/ui/_not-found/index.txt +5 -5
- package/ui/index.html +2 -2
- package/ui/index.txt +6 -6
- package/ui/_next/static/chunks/4c477a2a8f0165b2.js +0 -35
- package/ui/_next/static/chunks/71194462cde9e568.css +0 -1
- /package/ui/_next/static/{xvgisBurv3A3Iti1-C9JK → 8E-6CIYeI2VIFxpqmjIiK}/_buildManifest.js +0 -0
- /package/ui/_next/static/{xvgisBurv3A3Iti1-C9JK → 8E-6CIYeI2VIFxpqmjIiK}/_clientMiddlewareManifest.json +0 -0
- /package/ui/_next/static/{xvgisBurv3A3Iti1-C9JK → 8E-6CIYeI2VIFxpqmjIiK}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,837031,e=>{"use strict";let r,s,i,n,a,o,l,c,d,u,h,f,p,m,g,x,v;var _,y,b,w,S,C,j,k,N,E,D,R,A,M,F,T,P,B,L,I,O,z=e.i(813443),$=e.i(629109),W=e.i(331053),H=e.i(322387),H=H,U=e.i(538422);function K(e,r=[]){let s=[],i=()=>{let r=s.map(e=>$.createContext(e));return function(s){let i=s?.[e]||r;return $.useMemo(()=>({[`__scope${e}`]:{...s,[e]:i}}),[s,i])}};return i.scopeName=e,[function(r,i){let n=$.createContext(i),a=s.length;s=[...s,i];let o=r=>{let{scope:s,children:i,...o}=r,l=s?.[e]?.[a]||n,c=$.useMemo(()=>o,Object.values(o));return(0,z.jsx)(l.Provider,{value:c,children:i})};return o.displayName=r+"Provider",[o,function(s,o){let l=o?.[e]?.[a]||n,c=$.useContext(l);if(c)return c;if(void 0!==i)return i;throw Error(`\`${s}\` must be used within \`${r}\``)}]},function(...e){let r=e[0];if(1===e.length)return r;let s=()=>{let s=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let i=s.reduce((r,{useScope:s,scopeName:i})=>{let n=s(e)[`__scope${i}`];return{...r,...n}},{});return $.useMemo(()=>({[`__scope${r.scopeName}`]:i}),[i])}};return s.scopeName=r.scopeName,s}(i,...r)]}function q(e,r,{checkForDefaultPrevented:s=!0}={}){return function(i){if(e?.(i),!1===s||!i.defaultPrevented)return r?.(i)}}"undefined"!=typeof window&&window.document&&window.document.createElement;var V=globalThis?.document?$.useLayoutEffect:()=>{};$[" useEffectEvent ".trim().toString()],$[" useInsertionEffect ".trim().toString()];var Y=$[" useInsertionEffect ".trim().toString()]||V;function G({prop:e,defaultProp:r,onChange:s=()=>{},caller:i}){let[n,a,o]=function({defaultProp:e,onChange:r}){let[s,i]=$.useState(e),n=$.useRef(s),a=$.useRef(r);return Y(()=>{a.current=r},[r]),$.useEffect(()=>{n.current!==s&&(a.current?.(s),n.current=s)},[s,n]),[s,i,a]}({defaultProp:r,onChange:s}),l=void 0!==e,c=l?e:n;{let r=$.useRef(void 0!==e);$.useEffect(()=>{let e=r.current;if(e!==l){let r=l?"controlled":"uncontrolled";console.warn(`${i} is changing from ${e?"controlled":"uncontrolled"} to ${r}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}r.current=l},[l,i])}return[c,$.useCallback(r=>{if(l){let s="function"==typeof r?r(e):r;s!==e&&o.current?.(s)}else a(r)},[l,e,a,o])]}function X(e){let r=$.useRef({value:e,previous:e});return $.useMemo(()=>(r.current.value!==e&&(r.current.previous=r.current.value,r.current.value=e),r.current.previous),[e])}function J(e){let[r,s]=$.useState(void 0);return V(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});let r=new ResizeObserver(r=>{let i,n;if(!Array.isArray(r)||!r.length)return;let a=r[0];if("borderBoxSize"in a){let e=a.borderBoxSize,r=Array.isArray(e)?e[0]:e;i=r.inlineSize,n=r.blockSize}else i=e.offsetWidth,n=e.offsetHeight;s({width:i,height:n})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}s(void 0)},[e]),r}Symbol("RADIX:SYNC_STATE");var Z=e=>{var r;let s,i,{present:n,children:a}=e,o=function(e){var r,s;let[i,n]=$.useState(),a=$.useRef(null),o=$.useRef(e),l=$.useRef("none"),[c,d]=(r=e?"mounted":"unmounted",s={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},$.useReducer((e,r)=>s[e][r]??e,r));return $.useEffect(()=>{let e=Q(a.current);l.current="mounted"===c?e:"none"},[c]),V(()=>{let r=a.current,s=o.current;if(s!==e){let i=l.current,n=Q(r);e?d("MOUNT"):"none"===n||r?.display==="none"?d("UNMOUNT"):s&&i!==n?d("ANIMATION_OUT"):d("UNMOUNT"),o.current=e}},[e,d]),V(()=>{if(i){let e,r=i.ownerDocument.defaultView??window,s=s=>{let n=Q(a.current).includes(CSS.escape(s.animationName));if(s.target===i&&n&&(d("ANIMATION_END"),!o.current)){let s=i.style.animationFillMode;i.style.animationFillMode="forwards",e=r.setTimeout(()=>{"forwards"===i.style.animationFillMode&&(i.style.animationFillMode=s)})}},n=e=>{e.target===i&&(l.current=Q(a.current))};return i.addEventListener("animationstart",n),i.addEventListener("animationcancel",s),i.addEventListener("animationend",s),()=>{r.clearTimeout(e),i.removeEventListener("animationstart",n),i.removeEventListener("animationcancel",s),i.removeEventListener("animationend",s)}}d("ANIMATION_END")},[i,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:$.useCallback(e=>{a.current=e?getComputedStyle(e):null,n(e)},[])}}(n),l="function"==typeof a?a({present:o.isPresent}):$.Children.only(a),c=(0,U.useComposedRefs)(o.ref,(r=l,(i=(s=Object.getOwnPropertyDescriptor(r.props,"ref")?.get)&&"isReactWarning"in s&&s.isReactWarning)?r.ref:(i=(s=Object.getOwnPropertyDescriptor(r,"ref")?.get)&&"isReactWarning"in s&&s.isReactWarning)?r.props.ref:r.props.ref||r.ref));return"function"==typeof a||o.isPresent?$.cloneElement(l,{ref:c}):null};function Q(e){return e?.animationName||"none"}Z.displayName="Presence";var ee=e.i(492521),et=e.i(475299),er=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,r)=>{let s=(0,et.createSlot)(`Primitive.${r}`),i=$.forwardRef((e,i)=>{let{asChild:n,...a}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,z.jsx)(n?s:r,{...a,ref:i})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{});function es(e,r){e&&ee.flushSync(()=>e.dispatchEvent(r))}var ei="Checkbox",[en,ea]=K(ei),[eo,el]=en(ei);function ec(e){let{__scopeCheckbox:r,checked:s,children:i,defaultChecked:n,disabled:a,form:o,name:l,onCheckedChange:c,required:d,value:u="on",internal_do_not_use_render:h}=e,[f,p]=G({prop:s,defaultProp:n??!1,onChange:c,caller:ei}),[m,g]=$.useState(null),[x,v]=$.useState(null),_=$.useRef(!1),y=!m||!!o||!!m.closest("form"),b={checked:f,disabled:a,setChecked:p,control:m,setControl:g,name:l,form:o,value:u,hasConsumerStoppedPropagationRef:_,required:d,defaultChecked:!ex(n)&&n,isFormControl:y,bubbleInput:x,setBubbleInput:v};return(0,z.jsx)(eo,{scope:r,...b,children:"function"==typeof h?h(b):i})}var ed="CheckboxTrigger",eu=$.forwardRef(({__scopeCheckbox:e,onKeyDown:r,onClick:s,...i},n)=>{let{control:a,value:o,disabled:l,checked:c,required:d,setControl:u,setChecked:h,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:m}=el(ed,e),g=(0,U.useComposedRefs)(n,u),x=$.useRef(c);return $.useEffect(()=>{let e=a?.form;if(e){let r=()=>h(x.current);return e.addEventListener("reset",r),()=>e.removeEventListener("reset",r)}},[a,h]),(0,z.jsx)(er.button,{type:"button",role:"checkbox","aria-checked":ex(c)?"mixed":c,"aria-required":d,"data-state":ev(c),"data-disabled":l?"":void 0,disabled:l,value:o,...i,ref:g,onKeyDown:q(r,e=>{"Enter"===e.key&&e.preventDefault()}),onClick:q(s,e=>{h(e=>!!ex(e)||!e),m&&p&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})});eu.displayName=ed;var eh=$.forwardRef((e,r)=>{let{__scopeCheckbox:s,name:i,checked:n,defaultChecked:a,required:o,disabled:l,value:c,onCheckedChange:d,form:u,...h}=e;return(0,z.jsx)(ec,{__scopeCheckbox:s,checked:n,defaultChecked:a,disabled:l,required:o,onCheckedChange:d,name:i,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(eu,{...h,ref:r,__scopeCheckbox:s}),e&&(0,z.jsx)(eg,{__scopeCheckbox:s})]})})});eh.displayName=ei;var ef="CheckboxIndicator",ep=$.forwardRef((e,r)=>{let{__scopeCheckbox:s,forceMount:i,...n}=e,a=el(ef,s);return(0,z.jsx)(Z,{present:i||ex(a.checked)||!0===a.checked,children:(0,z.jsx)(er.span,{"data-state":ev(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:r,style:{pointerEvents:"none",...e.style}})})});ep.displayName=ef;var em="CheckboxBubbleInput",eg=$.forwardRef(({__scopeCheckbox:e,...r},s)=>{let{control:i,hasConsumerStoppedPropagationRef:n,checked:a,defaultChecked:o,required:l,disabled:c,name:d,value:u,form:h,bubbleInput:f,setBubbleInput:p}=el(em,e),m=(0,U.useComposedRefs)(s,p),g=X(a),x=J(i);$.useEffect(()=>{if(!f)return;let e=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set,r=!n.current;if(g!==a&&e){let s=new Event("click",{bubbles:r});f.indeterminate=ex(a),e.call(f,!ex(a)&&a),f.dispatchEvent(s)}},[f,g,a,n]);let v=$.useRef(!ex(a)&&a);return(0,z.jsx)(er.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??v.current,required:l,disabled:c,name:d,value:u,form:h,...r,tabIndex:-1,ref:m,style:{...r.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});function ex(e){return"indeterminate"===e}function ev(e){return ex(e)?"indeterminate":e?"checked":"unchecked"}eg.displayName=em,e.s(["Checkbox",()=>eh,"CheckboxIndicator",()=>ep,"Indicator",()=>ep,"Root",()=>eh,"createCheckboxScope",()=>ea,"unstable_BubbleInput",()=>eg,"unstable_CheckboxBubbleInput",()=>eg,"unstable_CheckboxProvider",()=>ec,"unstable_CheckboxTrigger",()=>eu,"unstable_Provider",()=>ec,"unstable_Trigger",()=>eu],85402);var e_=e.i(85402),e_=e_,ey=e.i(803545);function eb({className:e,...r}){return(0,z.jsx)(e_.Root,{"data-slot":"checkbox",className:(0,ey.cn)("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...r,children:(0,z.jsx)(e_.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:(0,z.jsx)(H.default,{className:"size-3.5"})})})}var ew=e.i(198631);let eS=(0,ew.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);var eC=$[" useId ".trim().toString()]||(()=>void 0),ej=0;function ek(e){let[r,s]=$.useState(eC());return V(()=>{e||s(e=>e??String(ej++))},[e]),e||(r?`radix-${r}`:"")}function eN(e){let r=$.useRef(e);return $.useEffect(()=>{r.current=e}),$.useMemo(()=>(...e)=>r.current?.(...e),[])}var eE="dismissableLayer.update",eD=$.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),eR=$.forwardRef((e,r)=>{let{disableOutsidePointerEvents:s=!1,onEscapeKeyDown:i,onPointerDownOutside:n,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...c}=e,d=$.useContext(eD),[u,h]=$.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=$.useState({}),m=(0,U.useComposedRefs)(r,e=>h(e)),g=Array.from(d.layers),[x]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),v=g.indexOf(x),_=u?g.indexOf(u):-1,y=d.layersWithOutsidePointerEventsDisabled.size>0,b=_>=v,w=function(e,r=globalThis?.document){let s=eN(e),i=$.useRef(!1),n=$.useRef(()=>{});return $.useEffect(()=>{let e=e=>{if(e.target&&!i.current){let i=function(){eM("dismissableLayer.pointerDownOutside",s,a,{discrete:!0})},a={originalEvent:e};"touch"===e.pointerType?(r.removeEventListener("click",n.current),n.current=i,r.addEventListener("click",n.current,{once:!0})):i()}else r.removeEventListener("click",n.current);i.current=!1},a=window.setTimeout(()=>{r.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(a),r.removeEventListener("pointerdown",e),r.removeEventListener("click",n.current)}},[r,s]),{onPointerDownCapture:()=>i.current=!0}}(e=>{let r=e.target,s=[...d.branches].some(e=>e.contains(r));b&&!s&&(n?.(e),o?.(e),e.defaultPrevented||l?.())},f),S=function(e,r=globalThis?.document){let s=eN(e),i=$.useRef(!1);return $.useEffect(()=>{let e=e=>{e.target&&!i.current&&eM("dismissableLayer.focusOutside",s,{originalEvent:e},{discrete:!1})};return r.addEventListener("focusin",e),()=>r.removeEventListener("focusin",e)},[r,s]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}(e=>{let r=e.target;![...d.branches].some(e=>e.contains(r))&&(a?.(e),o?.(e),e.defaultPrevented||l?.())},f);return!function(e,r=globalThis?.document){let s=eN(e);$.useEffect(()=>{let e=e=>{"Escape"===e.key&&s(e)};return r.addEventListener("keydown",e,{capture:!0}),()=>r.removeEventListener("keydown",e,{capture:!0})},[s,r])}(e=>{_===d.layers.size-1&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),$.useEffect(()=>{if(u)return s&&(0===d.layersWithOutsidePointerEventsDisabled.size&&(hW=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(u)),d.layers.add(u),eA(),()=>{s&&1===d.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=hW)}},[u,f,s,d]),$.useEffect(()=>()=>{u&&(d.layers.delete(u),d.layersWithOutsidePointerEventsDisabled.delete(u),eA())},[u,d]),$.useEffect(()=>{let e=()=>p({});return document.addEventListener(eE,e),()=>document.removeEventListener(eE,e)},[]),(0,z.jsx)(er.div,{...c,ref:m,style:{pointerEvents:y?b?"auto":"none":void 0,...e.style},onFocusCapture:q(e.onFocusCapture,S.onFocusCapture),onBlurCapture:q(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:q(e.onPointerDownCapture,w.onPointerDownCapture)})});function eA(){let e=new CustomEvent(eE);document.dispatchEvent(e)}function eM(e,r,s,{discrete:i}){let n=s.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});r&&n.addEventListener(e,r,{once:!0}),i?es(n,a):n.dispatchEvent(a)}eR.displayName="DismissableLayer",$.forwardRef((e,r)=>{let s=$.useContext(eD),i=$.useRef(null),n=(0,U.useComposedRefs)(r,i);return $.useEffect(()=>{let e=i.current;if(e)return s.branches.add(e),()=>{s.branches.delete(e)}},[s.branches]),(0,z.jsx)(er.div,{...e,ref:n})}).displayName="DismissableLayerBranch";var eF="focusScope.autoFocusOnMount",eT="focusScope.autoFocusOnUnmount",eP={bubbles:!1,cancelable:!0},eB=$.forwardRef((e,r)=>{let{loop:s=!1,trapped:i=!1,onMountAutoFocus:n,onUnmountAutoFocus:a,...o}=e,[l,c]=$.useState(null),d=eN(n),u=eN(a),h=$.useRef(null),f=(0,U.useComposedRefs)(r,e=>c(e)),p=$.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;$.useEffect(()=>{if(i){let e=function(e){if(p.paused||!l)return;let r=e.target;l.contains(r)?h.current=r:eO(h.current,{select:!0})},r=function(e){if(p.paused||!l)return;let r=e.relatedTarget;null!==r&&(l.contains(r)||eO(h.current,{select:!0}))};document.addEventListener("focusin",e),document.addEventListener("focusout",r);let s=new MutationObserver(function(e){if(document.activeElement===document.body)for(let r of e)r.removedNodes.length>0&&eO(l)});return l&&s.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",r),s.disconnect()}}},[i,l,p.paused]),$.useEffect(()=>{if(l){ez.add(p);let e=document.activeElement;if(!l.contains(e)){let r=new CustomEvent(eF,eP);l.addEventListener(eF,d),l.dispatchEvent(r),r.defaultPrevented||(function(e,{select:r=!1}={}){let s=document.activeElement;for(let i of e)if(eO(i,{select:r}),document.activeElement!==s)return}(eL(l).filter(e=>"A"!==e.tagName),{select:!0}),document.activeElement===e&&eO(l))}return()=>{l.removeEventListener(eF,d),setTimeout(()=>{let r=new CustomEvent(eT,eP);l.addEventListener(eT,u),l.dispatchEvent(r),r.defaultPrevented||eO(e??document.body,{select:!0}),l.removeEventListener(eT,u),ez.remove(p)},0)}}},[l,d,u,p]);let m=$.useCallback(e=>{if(!s&&!i||p.paused)return;let r="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(r&&n){var a;let r,i=e.currentTarget,[o,l]=[eI(r=eL(a=i),a),eI(r.reverse(),a)];o&&l?e.shiftKey||n!==l?e.shiftKey&&n===o&&(e.preventDefault(),s&&eO(l,{select:!0})):(e.preventDefault(),s&&eO(o,{select:!0})):n===i&&e.preventDefault()}},[s,i,p.paused]);return(0,z.jsx)(er.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});function eL(e){let r=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let r="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||r?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)r.push(s.currentNode);return r}function eI(e,r){for(let s of e)if(!function(e,{upTo:r}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e&&(void 0===r||e!==r);){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(s,{upTo:r}))return s}function eO(e,{select:r=!1}={}){if(e&&e.focus){var s;let i=document.activeElement;e.focus({preventScroll:!0}),e!==i&&(s=e)instanceof HTMLInputElement&&"select"in s&&r&&e.select()}}eB.displayName="FocusScope";var ez=(v=[],{add(e){let r=v[0];e!==r&&r?.pause(),(v=e$(v,e)).unshift(e)},remove(e){v=e$(v,e),v[0]?.resume()}});function e$(e,r){let s=[...e],i=s.indexOf(r);return -1!==i&&s.splice(i,1),s}var eW=$.forwardRef((e,r)=>{let{container:s,...i}=e,[n,a]=$.useState(!1);V(()=>a(!0),[]);let o=s||n&&globalThis?.document?.body;return o?ee.default.createPortal((0,z.jsx)(er.div,{...i,ref:r}),o):null});eW.displayName="Portal";var eH=0;function eU(){$.useEffect(()=>{let e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??eK()),document.body.insertAdjacentElement("beforeend",e[1]??eK()),eH++,()=>{1===eH&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),eH--}},[])}function eK(){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}var eq=function(){return(eq=Object.assign||function(e){for(var r,s=1,i=arguments.length;s<i;s++)for(var n in r=arguments[s])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e}).apply(this,arguments)};function eV(e,r){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>r.indexOf(i)&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)0>r.indexOf(i[n])&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(s[i[n]]=e[i[n]]);return s}var eY=("function"==typeof SuppressedError&&SuppressedError,"right-scroll-bar-position"),eG="width-before-scroll-bar";function eX(e,r){return"function"==typeof e?e(r):e&&(e.current=r),e}var eJ="undefined"!=typeof window?$.useLayoutEffect:$.useEffect,eZ=new WeakMap,eQ=(void 0===hT&&(hT={}),(void 0===hP&&(hP=function(e){return e}),hB=[],hL=!1,hI={read:function(){if(hL)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return hB.length?hB[hB.length-1]:null},useMedium:function(e){var r=hP(e,hL);return hB.push(r),function(){hB=hB.filter(function(e){return e!==r})}},assignSyncMedium:function(e){for(hL=!0;hB.length;){var r=hB;hB=[],r.forEach(e)}hB={push:function(r){return e(r)},filter:function(){return hB}}},assignMedium:function(e){hL=!0;var r=[];if(hB.length){var s=hB;hB=[],s.forEach(e),r=hB}var i=function(){var s=r;r=[],s.forEach(e)},n=function(){return Promise.resolve().then(i)};n(),hB={push:function(e){r.push(e),n()},filter:function(e){return r=r.filter(e),hB}}}}).options=eq({async:!0,ssr:!1},hT),hI),e0=function(){},e1=$.forwardRef(function(e,r){var s,i,n,a,o=$.useRef(null),l=$.useState({onScrollCapture:e0,onWheelCapture:e0,onTouchMoveCapture:e0}),c=l[0],d=l[1],u=e.forwardProps,h=e.children,f=e.className,p=e.removeScrollBar,m=e.enabled,g=e.shards,x=e.sideCar,v=e.noRelative,_=e.noIsolation,y=e.inert,b=e.allowPinchZoom,w=e.as,S=e.gapMode,C=eV(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=(s=[o,r],i=function(e){return s.forEach(function(r){return eX(r,e)})},(n=(0,$.useState)(function(){return{value:null,callback:i,facade:{get current(){return n.value},set current(value){var e=n.value;e!==value&&(n.value=value,n.callback(value,e))}}}})[0]).callback=i,a=n.facade,eJ(function(){var e=eZ.get(a);if(e){var r=new Set(e),i=new Set(s),n=a.current;r.forEach(function(e){i.has(e)||eX(e,null)}),i.forEach(function(e){r.has(e)||eX(e,n)})}eZ.set(a,s)},[s]),a),k=eq(eq({},C),c);return $.createElement($.Fragment,null,m&&$.createElement(x,{sideCar:eQ,removeScrollBar:p,shards:g,noRelative:v,noIsolation:_,inert:y,setCallbacks:d,allowPinchZoom:!!b,lockRef:o,gapMode:S}),u?$.cloneElement($.Children.only(h),eq(eq({},k),{ref:j})):$.createElement(void 0===w?"div":w,eq({},k,{className:f,ref:j}),h))});e1.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},e1.classNames={fullWidth:eG,zeroRight:eY};var e2=function(e){var r=e.sideCar,s=eV(e,["sideCar"]);if(!r)throw Error("Sidecar: please provide `sideCar` property to import the right car");var i=r.read();if(!i)throw Error("Sidecar medium not found");return $.createElement(i,eq({},s))};e2.isSideCarExport=!0;var e5=function(){var e=0,r=null;return{add:function(s){if(0==e&&(r=function(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var r=hH||("undefined"!=typeof __webpack_nonce__?__webpack_nonce__:void 0);return r&&e.setAttribute("nonce",r),e}())){var i,n;(i=r).styleSheet?i.styleSheet.cssText=s:i.appendChild(document.createTextNode(s)),n=r,(document.head||document.getElementsByTagName("head")[0]).appendChild(n)}e++},remove:function(){--e||!r||(r.parentNode&&r.parentNode.removeChild(r),r=null)}}},e3=function(){var e=e5();return function(r,s){$.useEffect(function(){return e.add(r),function(){e.remove()}},[r&&s])}},e4=function(){var e=e3();return function(r){return e(r.styles,r.dynamic),null}},e6={left:0,top:0,right:0,gap:0},e8=function(e){return parseInt(e||"",10)||0},e7=function(e){var r=window.getComputedStyle(document.body),s=r["padding"===e?"paddingLeft":"marginLeft"],i=r["padding"===e?"paddingTop":"marginTop"],n=r["padding"===e?"paddingRight":"marginRight"];return[e8(s),e8(i),e8(n)]},e9=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return e6;var r=e7(e),s=document.documentElement.clientWidth,i=window.innerWidth;return{left:r[0],top:r[1],right:r[2],gap:Math.max(0,i-s+r[2]-r[0])}},te=e4(),tt="data-scroll-locked",tr=function(e,r,s,i){var n=e.left,a=e.top,o=e.right,l=e.gap;return void 0===s&&(s="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(i,";\n padding-right: ").concat(l,"px ").concat(i,";\n }\n body[").concat(tt,"] {\n overflow: hidden ").concat(i,";\n overscroll-behavior: contain;\n ").concat([r&&"position: relative ".concat(i,";"),"margin"===s&&"\n padding-left: ".concat(n,"px;\n padding-top: ").concat(a,"px;\n padding-right: ").concat(o,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(l,"px ").concat(i,";\n "),"padding"===s&&"padding-right: ".concat(l,"px ").concat(i,";")].filter(Boolean).join(""),"\n }\n \n .").concat(eY," {\n right: ").concat(l,"px ").concat(i,";\n }\n \n .").concat(eG," {\n margin-right: ").concat(l,"px ").concat(i,";\n }\n \n .").concat(eY," .").concat(eY," {\n right: 0 ").concat(i,";\n }\n \n .").concat(eG," .").concat(eG," {\n margin-right: 0 ").concat(i,";\n }\n \n body[").concat(tt,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(l,"px;\n }\n")},ts=function(){var e=parseInt(document.body.getAttribute(tt)||"0",10);return isFinite(e)?e:0},ti=function(){$.useEffect(function(){return document.body.setAttribute(tt,(ts()+1).toString()),function(){var e=ts()-1;e<=0?document.body.removeAttribute(tt):document.body.setAttribute(tt,e.toString())}},[])},tn=function(e){var r=e.noRelative,s=e.noImportant,i=e.gapMode,n=void 0===i?"margin":i;ti();var a=$.useMemo(function(){return e9(n)},[n]);return $.createElement(te,{styles:tr(a,!r,n,s?"":"!important")})},ta=!1;if("undefined"!=typeof window)try{var to=Object.defineProperty({},"passive",{get:function(){return ta=!0,!0}});window.addEventListener("test",to,to),window.removeEventListener("test",to,to)}catch(e){ta=!1}var tl=!!ta&&{passive:!1},tc=function(e,r){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return"hidden"!==s[r]&&(s.overflowY!==s.overflowX||"TEXTAREA"===e.tagName||"visible"!==s[r])},td=function(e,r){var s=r.ownerDocument,i=r;do{if("undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot&&(i=i.host),tu(e,i)){var n=th(e,i);if(n[1]>n[2])return!0}i=i.parentNode}while(i&&i!==s.body)return!1},tu=function(e,r){return"v"===e?tc(r,"overflowY"):tc(r,"overflowX")},th=function(e,r){return"v"===e?[r.scrollTop,r.scrollHeight,r.clientHeight]:[r.scrollLeft,r.scrollWidth,r.clientWidth]},tf=function(e,r,s,i,n){var a,o=(a=window.getComputedStyle(r).direction,"h"===e&&"rtl"===a?-1:1),l=o*i,c=s.target,d=r.contains(c),u=!1,h=l>0,f=0,p=0;do{if(!c)break;var m=th(e,c),g=m[0],x=m[1]-m[2]-o*g;(g||x)&&tu(e,c)&&(f+=x,p+=g);var v=c.parentNode;c=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!d&&c!==document.body||d&&(r.contains(c)||r===c))return h&&(n&&1>Math.abs(f)||!n&&l>f)?u=!0:!h&&(n&&1>Math.abs(p)||!n&&-l>p)&&(u=!0),u},tp=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},tm=function(e){return[e.deltaX,e.deltaY]},tg=function(e){return e&&"current"in e?e.current:e},tx=0,tv=[];let t_=(hO=function(e){var r=$.useRef([]),s=$.useRef([0,0]),i=$.useRef(),n=$.useState(tx++)[0],a=$.useState(e4)[0],o=$.useRef(e);$.useEffect(function(){o.current=e},[e]),$.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(n));var r=(function(e,r,s){if(s||2==arguments.length)for(var i,n=0,a=r.length;n<a;n++)!i&&n in r||(i||(i=Array.prototype.slice.call(r,0,n)),i[n]=r[n]);return e.concat(i||Array.prototype.slice.call(r))})([e.lockRef.current],(e.shards||[]).map(tg),!0).filter(Boolean);return r.forEach(function(e){return e.classList.add("allow-interactivity-".concat(n))}),function(){document.body.classList.remove("block-interactivity-".concat(n)),r.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(n))})}}},[e.inert,e.lockRef.current,e.shards]);var l=$.useCallback(function(e,r){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!o.current.allowPinchZoom;var n,a=tp(e),l=s.current,c="deltaX"in e?e.deltaX:l[0]-a[0],d="deltaY"in e?e.deltaY:l[1]-a[1],u=e.target,h=Math.abs(c)>Math.abs(d)?"h":"v";if("touches"in e&&"h"===h&&"range"===u.type)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=td(h,u);if(!m)return!0;if(m?n=h:(n="v"===h?"h":"v",m=td(h,u)),!m)return!1;if(!i.current&&"changedTouches"in e&&(c||d)&&(i.current=n),!n)return!0;var g=i.current||n;return tf(g,r,e,"h"===g?c:d,!0)},[]),c=$.useCallback(function(e){if(tv.length&&tv[tv.length-1]===a){var s="deltaY"in e?tm(e):tp(e),i=r.current.filter(function(r){var i;return r.name===e.type&&(r.target===e.target||e.target===r.shadowParent)&&(i=r.delta,i[0]===s[0]&&i[1]===s[1])})[0];if(i&&i.should){e.cancelable&&e.preventDefault();return}if(!i){var n=(o.current.shards||[]).map(tg).filter(Boolean).filter(function(r){return r.contains(e.target)});(n.length>0?l(e,n[0]):!o.current.noIsolation)&&e.cancelable&&e.preventDefault()}}},[]),d=$.useCallback(function(e,s,i,n){var a={name:e,delta:s,target:i,should:n,shadowParent:function(e){for(var r=null;null!==e;)e instanceof ShadowRoot&&(r=e.host,e=e.host),e=e.parentNode;return r}(i)};r.current.push(a),setTimeout(function(){r.current=r.current.filter(function(e){return e!==a})},1)},[]),u=$.useCallback(function(e){s.current=tp(e),i.current=void 0},[]),h=$.useCallback(function(r){d(r.type,tm(r),r.target,l(r,e.lockRef.current))},[]),f=$.useCallback(function(r){d(r.type,tp(r),r.target,l(r,e.lockRef.current))},[]);$.useEffect(function(){return tv.push(a),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",c,tl),document.addEventListener("touchmove",c,tl),document.addEventListener("touchstart",u,tl),function(){tv=tv.filter(function(e){return e!==a}),document.removeEventListener("wheel",c,tl),document.removeEventListener("touchmove",c,tl),document.removeEventListener("touchstart",u,tl)}},[]);var p=e.removeScrollBar,m=e.inert;return $.createElement($.Fragment,null,m?$.createElement(a,{styles:"\n .block-interactivity-".concat(n," {pointer-events: none;}\n .allow-interactivity-").concat(n," {pointer-events: all;}\n")}):null,p?$.createElement(tn,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},eQ.useMedium(hO),e2);var ty=$.forwardRef(function(e,r){return $.createElement(e1,eq({},e,{ref:r,sideCar:t_}))});ty.classNames=e1.classNames;var tb=new WeakMap,tw=new WeakMap,tS={},tC=0,tj=function(e){return e&&(e.host||tj(e.parentNode))},tk=function(e,r,s,i){var n=(Array.isArray(e)?e:[e]).map(function(e){if(r.contains(e))return e;var s=tj(e);return s&&r.contains(s)?s:(console.error("aria-hidden",e,"in not contained inside",r,". Doing nothing"),null)}).filter(function(e){return!!e});tS[s]||(tS[s]=new WeakMap);var a=tS[s],o=[],l=new Set,c=new Set(n),d=function(e){!e||l.has(e)||(l.add(e),d(e.parentNode))};n.forEach(d);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(l.has(e))u(e);else try{var r=e.getAttribute(i),n=null!==r&&"false"!==r,c=(tb.get(e)||0)+1,d=(a.get(e)||0)+1;tb.set(e,c),a.set(e,d),o.push(e),1===c&&n&&tw.set(e,!0),1===d&&e.setAttribute(s,"true"),n||e.setAttribute(i,"true")}catch(r){console.error("aria-hidden: cannot operate on ",e,r)}})};return u(r),l.clear(),tC++,function(){o.forEach(function(e){var r=tb.get(e)-1,n=a.get(e)-1;tb.set(e,r),a.set(e,n),r||(tw.has(e)||e.removeAttribute(i),tw.delete(e)),n||e.removeAttribute(s)}),--tC||(tb=new WeakMap,tb=new WeakMap,tw=new WeakMap,tS={})}},tN=function(e,r,s){void 0===s&&(s="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),n=r||("undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body);return n?(i.push.apply(i,Array.from(n.querySelectorAll("[aria-live], script"))),tk(i,n,s,"aria-hidden")):function(){return null}},tE="Dialog",[tD,tR]=K(tE),[tA,tM]=tD(tE),tF=e=>{let{__scopeDialog:r,children:s,open:i,defaultOpen:n,onOpenChange:a,modal:o=!0}=e,l=$.useRef(null),c=$.useRef(null),[d,u]=G({prop:i,defaultProp:n??!1,onChange:a,caller:tE});return(0,z.jsx)(tA,{scope:r,triggerRef:l,contentRef:c,contentId:ek(),titleId:ek(),descriptionId:ek(),open:d,onOpenChange:u,onOpenToggle:$.useCallback(()=>u(e=>!e),[u]),modal:o,children:s})};tF.displayName=tE;var tT="DialogTrigger",tP=$.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=tM(tT,s),a=(0,U.useComposedRefs)(r,n.triggerRef);return(0,z.jsx)(er.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":t1(n.open),...i,ref:a,onClick:q(e.onClick,n.onOpenToggle)})});tP.displayName=tT;var tB="DialogPortal",[tL,tI]=tD(tB,{forceMount:void 0}),tO=e=>{let{__scopeDialog:r,forceMount:s,children:i,container:n}=e,a=tM(tB,r);return(0,z.jsx)(tL,{scope:r,forceMount:s,children:$.Children.map(i,e=>(0,z.jsx)(Z,{present:s||a.open,children:(0,z.jsx)(eW,{asChild:!0,container:n,children:e})}))})};tO.displayName=tB;var tz="DialogOverlay",t$=$.forwardRef((e,r)=>{let s=tI(tz,e.__scopeDialog),{forceMount:i=s.forceMount,...n}=e,a=tM(tz,e.__scopeDialog);return a.modal?(0,z.jsx)(Z,{present:i||a.open,children:(0,z.jsx)(tH,{...n,ref:r})}):null});t$.displayName=tz;var tW=(0,et.createSlot)("DialogOverlay.RemoveScroll"),tH=$.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=tM(tz,s);return(0,z.jsx)(ty,{as:tW,allowPinchZoom:!0,shards:[n.contentRef],children:(0,z.jsx)(er.div,{"data-state":t1(n.open),...i,ref:r,style:{pointerEvents:"auto",...i.style}})})}),tU="DialogContent",tK=$.forwardRef((e,r)=>{let s=tI(tU,e.__scopeDialog),{forceMount:i=s.forceMount,...n}=e,a=tM(tU,e.__scopeDialog);return(0,z.jsx)(Z,{present:i||a.open,children:a.modal?(0,z.jsx)(tq,{...n,ref:r}):(0,z.jsx)(tV,{...n,ref:r})})});tK.displayName=tU;var tq=$.forwardRef((e,r)=>{let s=tM(tU,e.__scopeDialog),i=$.useRef(null),n=(0,U.useComposedRefs)(r,s.contentRef,i);return $.useEffect(()=>{let e=i.current;if(e)return tN(e)},[]),(0,z.jsx)(tY,{...e,ref:n,trapFocus:s.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:q(e.onCloseAutoFocus,e=>{e.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:q(e.onPointerDownOutside,e=>{let r=e.detail.originalEvent,s=0===r.button&&!0===r.ctrlKey;(2===r.button||s)&&e.preventDefault()}),onFocusOutside:q(e.onFocusOutside,e=>e.preventDefault())})}),tV=$.forwardRef((e,r)=>{let s=tM(tU,e.__scopeDialog),i=$.useRef(!1),n=$.useRef(!1);return(0,z.jsx)(tY,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{e.onCloseAutoFocus?.(r),r.defaultPrevented||(i.current||s.triggerRef.current?.focus(),r.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:r=>{e.onInteractOutside?.(r),r.defaultPrevented||(i.current=!0,"pointerdown"===r.detail.originalEvent.type&&(n.current=!0));let a=r.target;s.triggerRef.current?.contains(a)&&r.preventDefault(),"focusin"===r.detail.originalEvent.type&&n.current&&r.preventDefault()}})}),tY=$.forwardRef((e,r)=>{let{__scopeDialog:s,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:a,...o}=e,l=tM(tU,s),c=$.useRef(null),d=(0,U.useComposedRefs)(r,c);return eU(),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(eB,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:a,children:(0,z.jsx)(eR,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":t1(l.open),...o,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(t4,{titleId:l.titleId}),(0,z.jsx)(t6,{contentRef:c,descriptionId:l.descriptionId})]})]})}),tG="DialogTitle",tX=$.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=tM(tG,s);return(0,z.jsx)(er.h2,{id:n.titleId,...i,ref:r})});tX.displayName=tG;var tJ="DialogDescription",tZ=$.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=tM(tJ,s);return(0,z.jsx)(er.p,{id:n.descriptionId,...i,ref:r})});tZ.displayName=tJ;var tQ="DialogClose",t0=$.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=tM(tQ,s);return(0,z.jsx)(er.button,{type:"button",...i,ref:r,onClick:q(e.onClick,()=>n.onOpenChange(!1))})});function t1(e){return e?"open":"closed"}t0.displayName=tQ;var t2="DialogTitleWarning",[t5,t3]=(hz={contentName:tU,titleName:tG,docsSlug:"dialog"},s=$.createContext(hz),(i=e=>{let{children:r,...i}=e,n=$.useMemo(()=>i,Object.values(i));return(0,z.jsx)(s.Provider,{value:n,children:r})}).displayName=t2+"Provider",[i,function(e){let r=$.useContext(s);if(r)return r;if(void 0!==hz)return hz;throw Error(`\`${e}\` must be used within \`${t2}\``)}]),t4=({titleId:e})=>{let r=t3(t2),s=`\`${r.contentName}\` requires a \`${r.titleName}\` for the component to be accessible for screen reader users.
|
|
2
|
+
|
|
3
|
+
If you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
4
|
+
|
|
5
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return $.useEffect(()=>{e&&(document.getElementById(e)||console.error(s))},[s,e]),null},t6=({contentRef:e,descriptionId:r})=>{let s=t3("DialogDescriptionWarning"),i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${s.contentName}}.`;return $.useEffect(()=>{let s=e.current?.getAttribute("aria-describedby");r&&s&&(document.getElementById(r)||console.warn(i))},[i,e,r]),null};let t8=(0,ew.default)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function t7({...e}){return(0,z.jsx)(tF,{"data-slot":"dialog",...e})}function t9({...e}){return(0,z.jsx)(tP,{"data-slot":"dialog-trigger",...e})}function re({...e}){return(0,z.jsx)(tO,{"data-slot":"dialog-portal",...e})}function rt({className:e,...r}){return(0,z.jsx)(t$,{"data-slot":"dialog-overlay",className:(0,ey.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...r})}function rr({className:e,children:r,showCloseButton:s=!0,...i}){return(0,z.jsxs)(re,{"data-slot":"dialog-portal",children:[(0,z.jsx)(rt,{}),(0,z.jsxs)(tK,{"data-slot":"dialog-content",className:(0,ey.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",e),...i,children:[r,s&&(0,z.jsxs)(t0,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,z.jsx)(t8,{}),(0,z.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function rs({className:e,...r}){return(0,z.jsx)("div",{"data-slot":"dialog-header",className:(0,ey.cn)("flex flex-col gap-2 text-center sm:text-left",e),...r})}function ri({className:e,...r}){return(0,z.jsx)("div",{"data-slot":"dialog-footer",className:(0,ey.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r})}function rn({className:e,...r}){return(0,z.jsx)(tX,{"data-slot":"dialog-title",className:(0,ey.cn)("text-lg leading-none font-semibold",e),...r})}function ra({className:e,...r}){return(0,z.jsx)(tZ,{"data-slot":"dialog-description",className:(0,ey.cn)("text-muted-foreground text-sm",e),...r})}function ro({className:e,type:r,...s}){return(0,z.jsx)("input",{type:r,"data-slot":"input",className:(0,ey.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...s})}function rl({className:e,...r}){return(0,z.jsx)("textarea",{"data-slot":"textarea",className:(0,ey.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...r})}let rc=(0,ew.default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);function rd({open:e,onOpenChange:r,rule:s,onSave:i,onDelete:n}){let[a,o]=(0,$.useState)(""),[l,c]=(0,$.useState)(""),[d,u]=(0,$.useState)(!0);(0,$.useEffect)(()=>{e&&(o(s?.name??""),c(s?.content??""),u(!s||1===s.enabled))},[e,s]);let h=!!s;return(0,z.jsx)(t7,{open:e,onOpenChange:r,children:(0,z.jsxs)(rr,{className:"sm:max-w-md",children:[(0,z.jsx)(rs,{children:(0,z.jsx)(rn,{children:h?"Edit Rule":"Add Rule"})}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,z.jsx)(ro,{value:a,onChange:e=>o(e.target.value),placeholder:"e.g. Auto-commit on finish"})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Rule"}),(0,z.jsx)(rl,{value:l,onChange:e=>c(e.target.value),placeholder:"e.g. When the coding agent finishes, run git commit executor",rows:3})]}),(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(eb,{id:"rule-enabled",checked:d,onCheckedChange:e=>u(!0===e)}),(0,z.jsx)("label",{htmlFor:"rule-enabled",className:"text-sm",children:"Enabled"})]})]}),(0,z.jsxs)(ri,{className:"flex justify-between",children:[(0,z.jsx)("div",{children:h&&n&&(0,z.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{n(s.id),r(!1)},children:[(0,z.jsx)(rc,{className:"h-4 w-4 mr-1"}),"Delete"]})}),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsx)(W.Button,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),(0,z.jsx)(W.Button,{onClick:()=>{a.trim()&&l.trim()&&(i({name:a.trim(),content:l.trim(),enabled:d}),r(!1))},disabled:!a.trim()||!l.trim(),children:"Save"})]})]})]})})}let ru=(0,$.forwardRef)(function({rules:e,hideHeader:r,onCreateRule:s,onUpdateRule:i,onDeleteRule:n},a){let[o,l]=(0,$.useState)(!1),[c,d]=(0,$.useState)(null);(0,$.useImperativeHandle)(a,()=>({openAdd:()=>{d(null),l(!0)}}));let u=()=>{d(null),l(!0)},h=async e=>{c?await i(c.id,e):await s(e)},f=async(e,r)=>{await i(e.id,{enabled:r})};return(0,z.jsxs)("div",{className:r?void 0:"space-y-1",children:[!r&&(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsx)("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Rules"}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6",onClick:u,title:"Add rule",children:(0,z.jsx)(eS,{className:"h-3.5 w-3.5"})})]}),0===e.length?(0,z.jsx)("button",{onClick:u,className:"w-full text-center py-3 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:"No rules yet. Click to add one."}):(0,z.jsx)("div",{className:"space-y-0.5 max-h-48 overflow-y-auto",children:e.map(e=>(0,z.jsxs)("div",{className:"flex items-center gap-2 px-1.5 py-1 rounded-md hover:bg-muted/50 group cursor-pointer",onClick:()=>{d(e),l(!0)},children:[(0,z.jsx)("div",{onClick:e=>e.stopPropagation(),className:"shrink-0",children:(0,z.jsx)(eb,{checked:1===e.enabled,onCheckedChange:r=>f(e,!0===r)})}),(0,z.jsx)("span",{className:`text-sm truncate flex-1 ${1===e.enabled?"text-foreground":"text-muted-foreground line-through"}`,title:e.content,children:e.name})]},e.id))}),(0,z.jsx)(rd,{open:o,onOpenChange:l,rule:c,onSave:h,onDelete:async e=>{await n(e)}})]})}),rh=(0,ew.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);var rf=e.i(454267);function rp({open:e,onOpenChange:r,command:s,onSave:i,onDelete:n}){let[a,o]=(0,$.useState)(""),[l,c]=(0,$.useState)("");(0,$.useEffect)(()=>{e&&(o(s?.name??""),c(s?.content??""))},[e,s]);let d=!!s;return(0,z.jsx)(t7,{open:e,onOpenChange:r,children:(0,z.jsxs)(rr,{className:"sm:max-w-md",children:[(0,z.jsx)(rs,{children:(0,z.jsx)(rn,{children:d?"Edit Command":"Add Command"})}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,z.jsx)(ro,{value:a,onChange:e=>o(e.target.value),placeholder:"e.g. Run tests"})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Command"}),(0,z.jsx)(rl,{value:l,onChange:e=>c(e.target.value),placeholder:"e.g. Run all unit tests and report any failures",rows:3})]})]}),(0,z.jsxs)(ri,{className:"flex justify-between",children:[(0,z.jsx)("div",{children:d&&n&&(0,z.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{n(s.id),r(!1)},children:[(0,z.jsx)(rc,{className:"h-4 w-4 mr-1"}),"Delete"]})}),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsx)(W.Button,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),(0,z.jsx)(W.Button,{onClick:()=>{a.trim()&&l.trim()&&(i({name:a.trim(),content:l.trim()}),r(!1))},disabled:!a.trim()||!l.trim(),children:"Save"})]})]})]})})}let rm=(0,$.forwardRef)(function({commands:e,hideHeader:r,onCreateCommand:s,onUpdateCommand:i,onDeleteCommand:n,onExecuteCommand:a},o){let[l,c]=(0,$.useState)(!1),[d,u]=(0,$.useState)(null),[h,f]=(0,$.useState)(null),p=(0,$.useRef)(null);(0,$.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]),(0,$.useImperativeHandle)(o,()=>({openAdd:()=>{u(null),c(!0)}}));let m=()=>{u(null),c(!0)},g=async e=>{d?await i(d.id,e):await s(e)};return(0,z.jsxs)("div",{className:r?void 0:"space-y-1",children:[!r&&(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsx)("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Commands"}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6",onClick:m,title:"Add command",children:(0,z.jsx)(eS,{className:"h-3.5 w-3.5"})})]}),0===e.length?(0,z.jsx)("button",{onClick:m,className:"w-full text-center py-3 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:"No commands yet. Click to add one."}):(0,z.jsx)("div",{className:"space-y-0.5 max-h-48 overflow-y-auto",children:e.map(e=>(0,z.jsxs)("div",{className:"flex items-center gap-2 px-1.5 py-1 rounded-md hover:bg-muted/50 group",children:[(0,z.jsx)("span",{className:"text-sm truncate flex-1 cursor-pointer text-foreground",title:e.content,onClick:()=>{u(e),c(!0)},children:e.name}),(0,z.jsxs)(W.Button,{variant:"ghost",size:"icon-sm",className:(0,ey.cn)("relative h-6 w-6 shrink-0 transition-all duration-150 active:scale-90 hover:bg-transparent dark:hover:bg-transparent",h===e.id?"opacity-100":"opacity-0 group-hover:opacity-100 hover:text-primary"),onClick:()=>{a(e.content),f(e.id),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>f(null),1200)},title:h===e.id?"Sent to chat":"Execute command",children:[(0,z.jsx)(rh,{className:(0,ey.cn)("absolute h-3 w-3 transition-opacity duration-150",h===e.id?"opacity-0":"opacity-0 group-hover:opacity-100")}),(0,z.jsx)(rf.Check,{className:(0,ey.cn)("absolute h-3 w-3 text-emerald-600 dark:text-emerald-400 transition-opacity duration-150",h===e.id?"opacity-100":"opacity-0")})]})]},e.id))}),(0,z.jsx)(rp,{open:l,onOpenChange:c,command:d,onSave:g,onDelete:async e=>{await n(e)}})]})}),rg=(0,ew.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);function rx({assignedTask:e,rules:r,commands:s,onCreateRule:i,onUpdateRule:n,onDeleteRule:a,onCreateCommand:o,onUpdateCommand:l,onDeleteCommand:c,onExecuteCommand:d,onUpdateTaskTitle:u,onCompleteTask:h}){let[f,p]=(0,$.useState)("task"),m=(0,$.useRef)(null),g=(0,$.useRef)(null),[x,v]=(0,$.useState)(!1),[_,y]=(0,$.useState)(""),b=(0,$.useRef)(null);(0,$.useEffect)(()=>{e&&y(e.title),v(!1)},[e?.id,e?.title]);let w=()=>{v(!1);let r=_.trim();r&&e&&r!==e.title?u?.(e.id,r):e&&y(e.title)};return(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsxs)("div",{className:"flex items-center gap-4",children:[(0,z.jsx)("button",{onClick:()=>p("task"),className:`text-xs font-medium pb-1 border-b-2 transition-colors ${"task"===f?"text-foreground border-primary":"text-muted-foreground border-transparent hover:text-foreground/70"}`,children:"Task"}),(0,z.jsx)("button",{onClick:()=>p("rules"),className:`text-xs font-medium pb-1 border-b-2 transition-colors ${"rules"===f?"text-foreground border-primary":"text-muted-foreground border-transparent hover:text-foreground/70"}`,children:"Rules"}),(0,z.jsx)("button",{onClick:()=>p("commands"),className:`text-xs font-medium pb-1 border-b-2 transition-colors ${"commands"===f?"text-foreground border-primary":"text-muted-foreground border-transparent hover:text-foreground/70"}`,children:"Commands"}),(0,z.jsx)("div",{className:"flex items-center gap-1 ml-auto",children:"task"===f&&e?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(W.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6",onClick:()=>{e&&(y(e.title),v(!0),setTimeout(()=>{b.current?.focus(),b.current?.select()},0))},title:"Edit task title",children:(0,z.jsx)(rg,{className:"h-3.5 w-3.5"})}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6",onClick:()=>h?.(e.id),title:"Complete task",children:(0,z.jsx)(rf.Check,{className:"h-3.5 w-3.5"})})]}):"rules"===f?(0,z.jsx)(W.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6",onClick:()=>m.current?.openAdd(),title:"Add rule",children:(0,z.jsx)(eS,{className:"h-3.5 w-3.5"})}):"commands"===f?(0,z.jsx)(W.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6",onClick:()=>g.current?.openAdd(),title:"Add command",children:(0,z.jsx)(eS,{className:"h-3.5 w-3.5"})}):(0,z.jsx)(W.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 invisible",children:(0,z.jsx)(eS,{className:"h-3.5 w-3.5"})})})]}),(0,z.jsxs)("div",{className:"grid [&>*]:col-start-1 [&>*]:row-start-1",children:[(0,z.jsx)("div",{className:"task"!==f?"invisible":void 0,children:e?x?(0,z.jsx)("input",{ref:b,className:"w-full bg-transparent border-b border-primary outline-none text-sm py-0.5",value:_,onChange:e=>y(e.target.value),onBlur:w,onKeyDown:r=>{"Enter"===r.key&&w(),"Escape"===r.key&&(y(e.title),v(!1))}}):(0,z.jsx)("p",{className:"text-sm text-foreground truncate",title:e.title,children:e.title}):(0,z.jsx)("p",{className:"text-xs text-muted-foreground py-3 text-center",children:"No task assigned to this workspace."})}),(0,z.jsx)("div",{className:"rules"!==f?"invisible":void 0,children:(0,z.jsx)(ru,{ref:m,hideHeader:!0,rules:r,onCreateRule:i,onUpdateRule:n,onDeleteRule:a})}),(0,z.jsx)("div",{className:"commands"!==f?"invisible":void 0,children:(0,z.jsx)(rm,{ref:g,hideHeader:!0,commands:s,onCreateCommand:o,onUpdateCommand:l,onDeleteCommand:c,onExecuteCommand:d})})]})]})}var rv=e.i(165512);let r_=(0,ew.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),ry=(0,ew.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),rb=(0,ew.default)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]),rw=(0,ew.default)("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),rS=(0,ew.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),rC=(0,ew.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),rj=(0,ew.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),rk=(0,ew.default)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);function rN({className:e,...r}){return(0,z.jsx)("div",{"data-slot":"card",className:(0,ey.cn)("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...r})}function rE({className:e,...r}){return(0,z.jsx)("div",{"data-slot":"card-header",className:(0,ey.cn)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...r})}function rD({className:e,...r}){return(0,z.jsx)("div",{"data-slot":"card-title",className:(0,ey.cn)("leading-none font-semibold",e),...r})}function rR({className:e,...r}){return(0,z.jsx)("div",{"data-slot":"card-content",className:(0,ey.cn)("px-6",e),...r})}function rA(e){let r=e+"CollectionProvider",[s,i]=K(r),[n,a]=s(r,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:r,children:s}=e,i=$.default.useRef(null),a=$.default.useRef(new Map).current;return(0,z.jsx)(n,{scope:r,itemMap:a,collectionRef:i,children:s})};o.displayName=r;let l=e+"CollectionSlot",c=(0,et.createSlot)(l),d=$.default.forwardRef((e,r)=>{let{scope:s,children:i}=e,n=a(l,s),o=(0,U.useComposedRefs)(r,n.collectionRef);return(0,z.jsx)(c,{ref:o,children:i})});d.displayName=l;let u=e+"CollectionItemSlot",h="data-radix-collection-item",f=(0,et.createSlot)(u),p=$.default.forwardRef((e,r)=>{let{scope:s,children:i,...n}=e,o=$.default.useRef(null),l=(0,U.useComposedRefs)(r,o),c=a(u,s);return $.default.useEffect(()=>(c.itemMap.set(o,{ref:o,...n}),()=>void c.itemMap.delete(o))),(0,z.jsx)(f,{...{[h]:""},ref:l,children:i})});return p.displayName=u,[{Provider:o,Slot:d,ItemSlot:p},function(r){let s=a(e+"CollectionConsumer",r);return $.default.useCallback(()=>{let e=s.collectionRef.current;if(!e)return[];let r=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(s.itemMap.values()).sort((e,s)=>r.indexOf(e.ref.current)-r.indexOf(s.ref.current))},[s.collectionRef,s.itemMap])},i]}var rM=new WeakMap;function rF(e,r){var s,i;let n,a,o;if("at"in Array.prototype)return Array.prototype.at.call(e,r);let l=(s=e,i=r,n=s.length,(o=(a=rT(i))>=0?a:n+a)<0||o>=n?-1:o);return -1===l?void 0:e[l]}function rT(e){return e!=e||0===e?0:Math.trunc(e)}(class e extends Map{#e;constructor(e){super(e),this.#e=[...super.keys()],rM.set(this,!0)}set(e,r){return rM.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,r),this}insert(e,r,s){let i,n=this.has(r),a=this.#e.length,o=rT(e),l=o>=0?o:a+o,c=l<0||l>=a?-1:l;if(c===this.size||n&&c===this.size-1||-1===c)return this.set(r,s),this;let d=this.size+ +!n;o<0&&l++;let u=[...this.#e],h=!1;for(let e=l;e<d;e++)if(l===e){let a=u[e];u[e]===r&&(a=u[e+1]),n&&this.delete(r),i=this.get(a),this.set(r,s)}else{h||u[e-1]!==r||(h=!0);let s=u[h?e:e-1],n=i;i=this.get(s),this.delete(s),this.set(s,n)}return this}with(r,s,i){let n=new e(this);return n.insert(r,s,i),n}before(e){let r=this.#e.indexOf(e)-1;if(!(r<0))return this.entryAt(r)}setBefore(e,r,s){let i=this.#e.indexOf(e);return -1===i?this:this.insert(i,r,s)}after(e){let r=this.#e.indexOf(e);if(-1!==(r=-1===r||r===this.size-1?-1:r+1))return this.entryAt(r)}setAfter(e,r,s){let i=this.#e.indexOf(e);return -1===i?this:this.insert(i+1,r,s)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let r=super.delete(e);return r&&this.#e.splice(this.#e.indexOf(e),1),r}deleteAt(e){let r=this.keyAt(e);return void 0!==r&&this.delete(r)}at(e){let r=rF(this.#e,e);if(void 0!==r)return this.get(r)}entryAt(e){let r=rF(this.#e,e);if(void 0!==r)return[r,this.get(r)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return rF(this.#e,e)}from(e,r){let s=this.indexOf(e);if(-1===s)return;let i=s+r;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.at(i)}keyFrom(e,r){let s=this.indexOf(e);if(-1===s)return;let i=s+r;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.keyAt(i)}find(e,r){let s=0;for(let i of this){if(Reflect.apply(e,r,[i,s,this]))return i;s++}}findIndex(e,r){let s=0;for(let i of this){if(Reflect.apply(e,r,[i,s,this]))return s;s++}return -1}filter(r,s){let i=[],n=0;for(let e of this)Reflect.apply(r,s,[e,n,this])&&i.push(e),n++;return new e(i)}map(r,s){let i=[],n=0;for(let e of this)i.push([e[0],Reflect.apply(r,s,[e,n,this])]),n++;return new e(i)}reduce(...e){let[r,s]=e,i=0,n=s??this.at(0);for(let s of this)n=0===i&&1===e.length?s:Reflect.apply(r,this,[n,s,i,this]),i++;return n}reduceRight(...e){let[r,s]=e,i=s??this.at(-1);for(let s=this.size-1;s>=0;s--){let n=this.at(s);i=s===this.size-1&&1===e.length?n:Reflect.apply(r,this,[i,n,s,this])}return i}toSorted(r){return new e([...this.entries()].sort(r))}toReversed(){let r=new e;for(let e=this.size-1;e>=0;e--){let s=this.keyAt(e),i=this.get(s);r.set(s,i)}return r}toSpliced(...r){let s=[...this.entries()];return s.splice(...r),new e(s)}slice(r,s){let i=new e,n=this.size-1;if(void 0===r)return i;r<0&&(r+=this.size),void 0!==s&&s>0&&(n=s-1);for(let e=r;e<=n;e++){let r=this.keyAt(e),s=this.get(r);i.set(r,s)}return i}every(e,r){let s=0;for(let i of this){if(!Reflect.apply(e,r,[i,s,this]))return!1;s++}return!0}some(e,r){let s=0;for(let i of this){if(Reflect.apply(e,r,[i,s,this]))return!0;s++}return!1}});var rP=$.createContext(void 0);function rB(e){let r=$.useContext(rP);return e||r||"ltr"}var rL="rovingFocusGroup.onEntryFocus",rI={bubbles:!1,cancelable:!0},rO="RovingFocusGroup",[rz,r$,rW]=rA(rO),[rH,rU]=K(rO,[rW]),[rK,rq]=rH(rO),rV=$.forwardRef((e,r)=>(0,z.jsx)(rz.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,z.jsx)(rz.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,z.jsx)(rY,{...e,ref:r})})}));rV.displayName=rO;var rY=$.forwardRef((e,r)=>{let{__scopeRovingFocusGroup:s,orientation:i,loop:n=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:u=!1,...h}=e,f=$.useRef(null),p=(0,U.useComposedRefs)(r,f),m=rB(a),[g,x]=G({prop:o,defaultProp:l??null,onChange:c,caller:rO}),[v,_]=$.useState(!1),y=eN(d),b=r$(s),w=$.useRef(!1),[S,C]=$.useState(0);return $.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(rL,y),()=>e.removeEventListener(rL,y)},[y]),(0,z.jsx)(rK,{scope:s,orientation:i,dir:m,loop:n,currentTabStopId:g,onItemFocus:$.useCallback(e=>x(e),[x]),onItemShiftTab:$.useCallback(()=>_(!0),[]),onFocusableItemAdd:$.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:$.useCallback(()=>C(e=>e-1),[]),children:(0,z.jsx)(er.div,{tabIndex:v||0===S?-1:0,"data-orientation":i,...h,ref:p,style:{outline:"none",...e.style},onMouseDown:q(e.onMouseDown,()=>{w.current=!0}),onFocus:q(e.onFocus,e=>{let r=!w.current;if(e.target===e.currentTarget&&r&&!v){let r=new CustomEvent(rL,rI);if(e.currentTarget.dispatchEvent(r),!r.defaultPrevented){let e=b().filter(e=>e.focusable);rZ([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),u)}}w.current=!1}),onBlur:q(e.onBlur,()=>_(!1))})})}),rG="RovingFocusGroupItem",rX=$.forwardRef((e,r)=>{let{__scopeRovingFocusGroup:s,focusable:i=!0,active:n=!1,tabStopId:a,children:o,...l}=e,c=ek(),d=a||c,u=rq(rG,s),h=u.currentTabStopId===d,f=r$(s),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:g}=u;return $.useEffect(()=>{if(i)return p(),()=>m()},[i,p,m]),(0,z.jsx)(rz.ItemSlot,{scope:s,id:d,focusable:i,active:n,children:(0,z.jsx)(er.span,{tabIndex:h?0:-1,"data-orientation":u.orientation,...l,ref:r,onMouseDown:q(e.onMouseDown,e=>{i?u.onItemFocus(d):e.preventDefault()}),onFocus:q(e.onFocus,()=>u.onItemFocus(d)),onKeyDown:q(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void u.onItemShiftTab();if(e.target!==e.currentTarget)return;let r=function(e,r,s){var i;let n=(i=e.key,"rtl"!==s?i:"ArrowLeft"===i?"ArrowRight":"ArrowRight"===i?"ArrowLeft":i);if(!("vertical"===r&&["ArrowLeft","ArrowRight"].includes(n))&&!("horizontal"===r&&["ArrowUp","ArrowDown"].includes(n)))return rJ[n]}(e,u.orientation,u.dir);if(void 0!==r){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("last"===r)n.reverse();else if("prev"===r||"next"===r){var s,i;"prev"===r&&n.reverse();let a=n.indexOf(e.currentTarget);n=u.loop?(s=n,i=a+1,s.map((e,r)=>s[(i+r)%s.length])):n.slice(a+1)}setTimeout(()=>rZ(n))}}),children:"function"==typeof o?o({isCurrentTabStop:h,hasTabStop:null!=g}):o})})});rX.displayName=rG;var rJ={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function rZ(e,r=!1){let s=document.activeElement;for(let i of e)if(i===s||(i.focus({preventScroll:r}),document.activeElement!==s))return}var rQ="Tabs",[r0,r1]=K(rQ,[rU]),r2=rU(),[r5,r3]=r0(rQ),r4=$.forwardRef((e,r)=>{let{__scopeTabs:s,value:i,onValueChange:n,defaultValue:a,orientation:o="horizontal",dir:l,activationMode:c="automatic",...d}=e,u=rB(l),[h,f]=G({prop:i,onChange:n,defaultProp:a??"",caller:rQ});return(0,z.jsx)(r5,{scope:s,baseId:ek(),value:h,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,z.jsx)(er.div,{dir:u,"data-orientation":o,...d,ref:r})})});r4.displayName=rQ;var r6="TabsList",r8=$.forwardRef((e,r)=>{let{__scopeTabs:s,loop:i=!0,...n}=e,a=r3(r6,s),o=r2(s);return(0,z.jsx)(rV,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:i,children:(0,z.jsx)(er.div,{role:"tablist","aria-orientation":a.orientation,...n,ref:r})})});r8.displayName=r6;var r7="TabsTrigger",r9=$.forwardRef((e,r)=>{let{__scopeTabs:s,value:i,disabled:n=!1,...a}=e,o=r3(r7,s),l=r2(s),c=sr(o.baseId,i),d=ss(o.baseId,i),u=i===o.value;return(0,z.jsx)(rX,{asChild:!0,...l,focusable:!n,active:u,children:(0,z.jsx)(er.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":d,"data-state":u?"active":"inactive","data-disabled":n?"":void 0,disabled:n,id:c,...a,ref:r,onMouseDown:q(e.onMouseDown,e=>{n||0!==e.button||!1!==e.ctrlKey?e.preventDefault():o.onValueChange(i)}),onKeyDown:q(e.onKeyDown,e=>{[" ","Enter"].includes(e.key)&&o.onValueChange(i)}),onFocus:q(e.onFocus,()=>{let e="manual"!==o.activationMode;u||n||!e||o.onValueChange(i)})})})});r9.displayName=r7;var se="TabsContent",st=$.forwardRef((e,r)=>{let{__scopeTabs:s,value:i,forceMount:n,children:a,...o}=e,l=r3(se,s),c=sr(l.baseId,i),d=ss(l.baseId,i),u=i===l.value,h=$.useRef(u);return $.useEffect(()=>{let e=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,z.jsx)(Z,{present:n||u,children:({present:s})=>(0,z.jsx)(er.div,{"data-state":u?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!s,id:d,tabIndex:0,...o,ref:r,style:{...e.style,animationDuration:h.current?"0s":void 0},children:s&&a})})});function sr(e,r){return`${e}-trigger-${r}`}function ss(e,r){return`${e}-content-${r}`}st.displayName=se;let si=$.forwardRef(({className:e,...r},s)=>(0,z.jsx)(r8,{ref:s,className:(0,ey.cn)("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...r}));si.displayName=r8.displayName;let sn=$.forwardRef(({className:e,...r},s)=>(0,z.jsx)(r9,{ref:s,className:(0,ey.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...r}));sn.displayName=r9.displayName;let sa=$.forwardRef(({className:e,...r},s)=>(0,z.jsx)(st,{ref:s,className:(0,ey.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...r}));sa.displayName=st.displayName;let so=(0,ew.default)("cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]),sl=(0,ew.default)("cloud-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);function sc(e,r){let s=r?.withStatus??!1,[i,n]=(0,$.useState)([]),[a,o]=(0,$.useState)(!1),l=(0,$.useCallback)(async()=>{if(!e)return void n([]);o(!0);try{let r=await rv.api.getProjectRemotes(e);if(s){let e=await rv.api.getRemoteServers(),s=new Map(e.map(e=>[e.id,e]));n(r.map(e=>{let r=s.get(e.remote_server_id);return r?{...e,status:r.status,connection_mode:r.connection_mode}:e}))}else n(r)}catch(e){console.error("Failed to fetch project remotes:",e)}finally{o(!1)}},[e,s]);return(0,$.useEffect)(()=>{l()},[l]),(0,$.useEffect)(()=>{if(!s||!e)return;let r=setInterval(l,15e3),i=()=>l();return window.addEventListener("focus",i),()=>{clearInterval(r),window.removeEventListener("focus",i)}},[s,e,l]),{remotes:i,loading:a,refresh:l}}function sd(e){return"inbound"===e.connection_mode&&"online"!==e.status?sl:so}function su(e){return null===e?"":e}var sh=Symbol.for("react.lazy"),sf=$[" use ".trim().toString()];function sp(e){var r;return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===sh&&"_payload"in e&&"object"==typeof(r=e._payload)&&null!==r&&"then"in r}function sm(e){var r;let s,i=(r=e,(s=$.forwardRef((e,r)=>{let{children:s,...i}=e;if(sp(s)&&"function"==typeof sf&&(s=sf(s._payload)),$.isValidElement(s)){var n;let e,a,o=(n=s,(a=(e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?n.ref:(a=(e=Object.getOwnPropertyDescriptor(n,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?n.props.ref:n.props.ref||n.ref),l=function(e,r){let s={...r};for(let i in r){let n=e[i],a=r[i];/^on[A-Z]/.test(i)?n&&a?s[i]=(...e)=>{let r=a(...e);return n(...e),r}:n&&(s[i]=n):"style"===i?s[i]={...n,...a}:"className"===i&&(s[i]=[n,a].filter(Boolean).join(" "))}return{...e,...s}}(i,s.props);return s.type!==$.Fragment&&(l.ref=r?(0,U.composeRefs)(r,o):o),$.cloneElement(s,l)}return $.Children.count(s)>1?$.Children.only(null):null})).displayName=`${r}.SlotClone`,s),n=$.forwardRef((e,r)=>{let{children:s,...n}=e;sp(s)&&"function"==typeof sf&&(s=sf(s._payload));let a=$.Children.toArray(s),o=a.find(sv);if(o){let e=o.props.children,s=a.map(r=>r!==o?r:$.Children.count(e)>1?$.Children.only(null):$.isValidElement(e)?e.props.children:null);return(0,z.jsx)(i,{...n,ref:r,children:$.isValidElement(e)?$.cloneElement(e,void 0,s):null})}return(0,z.jsx)(i,{...n,ref:r,children:s})});return n.displayName=`${e}.Slot`,n}var sg=sm("Slot"),sx=Symbol("radix.slottable");function sv(e){return $.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===sx}var s_=e.i(294237);let sy=(0,s_.cva)("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function sb({className:e,variant:r,asChild:s=!1,...i}){return(0,z.jsx)(s?sg:"span",{"data-slot":"badge",className:(0,ey.cn)(sy({variant:r}),e),...i})}let sw=(0,ew.default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),sS=["top","right","bottom","left"],sC=Math.min,sj=Math.max,sk=Math.round,sN=Math.floor,sE=e=>({x:e,y:e}),sD={left:"right",right:"left",bottom:"top",top:"bottom"},sR={start:"end",end:"start"};function sA(e,r){return"function"==typeof e?e(r):e}function sM(e){return e.split("-")[0]}function sF(e){return e.split("-")[1]}function sT(e){return"x"===e?"y":"x"}function sP(e){return"y"===e?"height":"width"}let sB=new Set(["top","bottom"]);function sL(e){return sB.has(sM(e))?"y":"x"}function sI(e){return e.replace(/start|end/g,e=>sR[e])}let sO=["left","right"],sz=["right","left"],s$=["top","bottom"],sW=["bottom","top"];function sH(e){return e.replace(/left|right|bottom|top/g,e=>sD[e])}function sU(e){return"number"!=typeof e?{top:0,right:0,bottom:0,left:0,...e}:{top:e,right:e,bottom:e,left:e}}function sK(e){let{x:r,y:s,width:i,height:n}=e;return{width:i,height:n,top:s,left:r,right:r+i,bottom:s+n,x:r,y:s}}function sq(e,r,s){let i,{reference:n,floating:a}=e,o=sL(r),l=sT(sL(r)),c=sP(l),d=sM(r),u="y"===o,h=n.x+n.width/2-a.width/2,f=n.y+n.height/2-a.height/2,p=n[c]/2-a[c]/2;switch(d){case"top":i={x:h,y:n.y-a.height};break;case"bottom":i={x:h,y:n.y+n.height};break;case"right":i={x:n.x+n.width,y:f};break;case"left":i={x:n.x-a.width,y:f};break;default:i={x:n.x,y:n.y}}switch(sF(r)){case"start":i[l]-=p*(s&&u?-1:1);break;case"end":i[l]+=p*(s&&u?-1:1)}return i}async function sV(e,r){var s;void 0===r&&(r={});let{x:i,y:n,platform:a,rects:o,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:f=!1,padding:p=0}=sA(r,e),m=sU(p),g=l[f?"floating"===h?"reference":"floating":h],x=sK(await a.getClippingRect({element:null==(s=await (null==a.isElement?void 0:a.isElement(g)))||s?g:g.contextElement||await (null==a.getDocumentElement?void 0:a.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),v="floating"===h?{x:i,y:n,width:o.floating.width,height:o.floating.height}:o.reference,_=await (null==a.getOffsetParent?void 0:a.getOffsetParent(l.floating)),y=await (null==a.isElement?void 0:a.isElement(_))&&await (null==a.getScale?void 0:a.getScale(_))||{x:1,y:1},b=sK(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:_,strategy:c}):v);return{top:(x.top-b.top+m.top)/y.y,bottom:(b.bottom-x.bottom+m.bottom)/y.y,left:(x.left-b.left+m.left)/y.x,right:(b.right-x.right+m.right)/y.x}}let sY=async(e,r,s)=>{let{placement:i="bottom",strategy:n="absolute",middleware:a=[],platform:o}=s,l=a.filter(Boolean),c=await (null==o.isRTL?void 0:o.isRTL(r)),d=await o.getElementRects({reference:e,floating:r,strategy:n}),{x:u,y:h}=sq(d,i,c),f=i,p={},m=0;for(let s=0;s<l.length;s++){var g;let{name:a,fn:x}=l[s],{x:v,y:_,data:y,reset:b}=await x({x:u,y:h,initialPlacement:i,placement:f,strategy:n,middlewareData:p,rects:d,platform:{...o,detectOverflow:null!=(g=o.detectOverflow)?g:sV},elements:{reference:e,floating:r}});u=null!=v?v:u,h=null!=_?_:h,p={...p,[a]:{...p[a],...y}},b&&m<=50&&(m++,"object"==typeof b&&(b.placement&&(f=b.placement),b.rects&&(d=!0===b.rects?await o.getElementRects({reference:e,floating:r,strategy:n}):b.rects),{x:u,y:h}=sq(d,f,c)),s=-1)}return{x:u,y:h,placement:f,strategy:n,middlewareData:p}};function sG(e,r){return{top:e.top-r.height,right:e.right-r.width,bottom:e.bottom-r.height,left:e.left-r.width}}function sX(e){return sS.some(r=>e[r]>=0)}let sJ=new Set(["left","top"]);async function sZ(e,r){let{placement:s,platform:i,elements:n}=e,a=await (null==i.isRTL?void 0:i.isRTL(n.floating)),o=sM(s),l=sF(s),c="y"===sL(s),d=sJ.has(o)?-1:1,u=a&&c?-1:1,h=sA(r,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}="number"==typeof h?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&"number"==typeof m&&(p="end"===l?-1*m:m),c?{x:p*u,y:f*d}:{x:f*d,y:p*u}}function sQ(){return"undefined"!=typeof window}function s0(e){return s5(e)?(e.nodeName||"").toLowerCase():"#document"}function s1(e){var r;return(null==e||null==(r=e.ownerDocument)?void 0:r.defaultView)||window}function s2(e){var r;return null==(r=(s5(e)?e.ownerDocument:e.document)||window.document)?void 0:r.documentElement}function s5(e){return!!sQ()&&(e instanceof Node||e instanceof s1(e).Node)}function s3(e){return!!sQ()&&(e instanceof Element||e instanceof s1(e).Element)}function s4(e){return!!sQ()&&(e instanceof HTMLElement||e instanceof s1(e).HTMLElement)}function s6(e){return!!sQ()&&"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof s1(e).ShadowRoot)}let s8=new Set(["inline","contents"]);function s7(e){let{overflow:r,overflowX:s,overflowY:i,display:n}=id(e);return/auto|scroll|overlay|hidden|clip/.test(r+i+s)&&!s8.has(n)}let s9=new Set(["table","td","th"]),ie=[":popover-open",":modal"];function it(e){return ie.some(r=>{try{return e.matches(r)}catch(e){return!1}})}let ir=["transform","translate","scale","rotate","perspective"],is=["transform","translate","scale","rotate","perspective","filter"],ii=["paint","layout","strict","content"];function ia(e){let r=io(),s=s3(e)?id(e):e;return ir.some(e=>!!s[e]&&"none"!==s[e])||!!s.containerType&&"normal"!==s.containerType||!r&&!!s.backdropFilter&&"none"!==s.backdropFilter||!r&&!!s.filter&&"none"!==s.filter||is.some(e=>(s.willChange||"").includes(e))||ii.some(e=>(s.contain||"").includes(e))}function io(){return"undefined"!=typeof CSS&&!!CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")}let il=new Set(["html","body","#document"]);function ic(e){return il.has(s0(e))}function id(e){return s1(e).getComputedStyle(e)}function iu(e){return s3(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ih(e){if("html"===s0(e))return e;let r=e.assignedSlot||e.parentNode||s6(e)&&e.host||s2(e);return s6(r)?r.host:r}function ip(e,r,s){var i;void 0===r&&(r=[]),void 0===s&&(s=!0);let n=function e(r){let s=ih(r);return ic(s)?r.ownerDocument?r.ownerDocument.body:r.body:s4(s)&&s7(s)?s:e(s)}(e),a=n===(null==(i=e.ownerDocument)?void 0:i.body),o=s1(n);if(a){let e=im(o);return r.concat(o,o.visualViewport||[],s7(n)?n:[],e&&s?ip(e):[])}return r.concat(n,ip(n,[],s))}function im(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ig(e){let r=id(e),s=parseFloat(r.width)||0,i=parseFloat(r.height)||0,n=s4(e),a=n?e.offsetWidth:s,o=n?e.offsetHeight:i,l=sk(s)!==a||sk(i)!==o;return l&&(s=a,i=o),{width:s,height:i,$:l}}function ix(e){return s3(e)?e:e.contextElement}function iv(e){let r=ix(e);if(!s4(r))return sE(1);let s=r.getBoundingClientRect(),{width:i,height:n,$:a}=ig(r),o=(a?sk(s.width):s.width)/i,l=(a?sk(s.height):s.height)/n;return o&&Number.isFinite(o)||(o=1),l&&Number.isFinite(l)||(l=1),{x:o,y:l}}let i_=sE(0);function iy(e){let r=s1(e);return io()&&r.visualViewport?{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}:i_}function ib(e,r,s,i){var n;void 0===r&&(r=!1),void 0===s&&(s=!1);let a=e.getBoundingClientRect(),o=ix(e),l=sE(1);r&&(i?s3(i)&&(l=iv(i)):l=iv(e));let c=(void 0===(n=s)&&(n=!1),i&&(!n||i===s1(o))&&n)?iy(o):sE(0),d=(a.left+c.x)/l.x,u=(a.top+c.y)/l.y,h=a.width/l.x,f=a.height/l.y;if(o){let e=s1(o),r=i&&s3(i)?s1(i):i,s=e,n=im(s);for(;n&&i&&r!==s;){let e=iv(n),r=n.getBoundingClientRect(),i=id(n),a=r.left+(n.clientLeft+parseFloat(i.paddingLeft))*e.x,o=r.top+(n.clientTop+parseFloat(i.paddingTop))*e.y;d*=e.x,u*=e.y,h*=e.x,f*=e.y,d+=a,u+=o,n=im(s=s1(n))}}return sK({width:h,height:f,x:d,y:u})}function iw(e,r){let s=iu(e).scrollLeft;return r?r.left+s:ib(s2(e)).left+s}function iS(e,r){let s=e.getBoundingClientRect();return{x:s.left+r.scrollLeft-iw(e,s),y:s.top+r.scrollTop}}let iC=new Set(["absolute","fixed"]);function ij(e,r,s){var i;let n;if("viewport"===r)n=function(e,r){let s=s1(e),i=s2(e),n=s.visualViewport,a=i.clientWidth,o=i.clientHeight,l=0,c=0;if(n){a=n.width,o=n.height;let e=io();(!e||e&&"fixed"===r)&&(l=n.offsetLeft,c=n.offsetTop)}let d=iw(i);if(d<=0){let e=i.ownerDocument,r=e.body,s=getComputedStyle(r),n="CSS1Compat"===e.compatMode&&parseFloat(s.marginLeft)+parseFloat(s.marginRight)||0,o=Math.abs(i.clientWidth-r.clientWidth-n);o<=25&&(a-=o)}else d<=25&&(a+=d);return{width:a,height:o,x:l,y:c}}(e,s);else if("document"===r){let r,s,a,o,l,c,d;i=s2(e),r=s2(i),s=iu(i),a=i.ownerDocument.body,o=sj(r.scrollWidth,r.clientWidth,a.scrollWidth,a.clientWidth),l=sj(r.scrollHeight,r.clientHeight,a.scrollHeight,a.clientHeight),c=-s.scrollLeft+iw(i),d=-s.scrollTop,"rtl"===id(a).direction&&(c+=sj(r.clientWidth,a.clientWidth)-o),n={width:o,height:l,x:c,y:d}}else if(s3(r)){let e,i,a,o,l,c;i=(e=ib(r,!0,"fixed"===s)).top+r.clientTop,a=e.left+r.clientLeft,o=s4(r)?iv(r):sE(1),l=r.clientWidth*o.x,c=r.clientHeight*o.y,n={width:l,height:c,x:a*o.x,y:i*o.y}}else{let s=iy(e);n={x:r.x-s.x,y:r.y-s.y,width:r.width,height:r.height}}return sK(n)}function ik(e){return"static"===id(e).position}function iN(e,r){if(!s4(e)||"fixed"===id(e).position)return null;if(r)return r(e);let s=e.offsetParent;return s2(e)===s&&(s=s.ownerDocument.body),s}function iE(e,r){var s;let i=s1(e);if(it(e))return i;if(!s4(e)){let r=ih(e);for(;r&&!ic(r);){if(s3(r)&&!ik(r))return r;r=ih(r)}return i}let n=iN(e,r);for(;n&&(s=n,s9.has(s0(s)))&&ik(n);)n=iN(n,r);return n&&ic(n)&&ik(n)&&!ia(n)?i:n||function(e){let r=ih(e);for(;s4(r)&&!ic(r);){if(ia(r))return r;if(it(r))break;r=ih(r)}return null}(e)||i}let iD=async function(e){let r=this.getOffsetParent||iE,s=this.getDimensions,i=await s(e.floating);return{reference:function(e,r,s){let i=s4(r),n=s2(r),a="fixed"===s,o=ib(e,!0,a,r),l={scrollLeft:0,scrollTop:0},c=sE(0);if(i||!i&&!a)if(("body"!==s0(r)||s7(n))&&(l=iu(r)),i){let e=ib(r,!0,a,r);c.x=e.x+r.clientLeft,c.y=e.y+r.clientTop}else n&&(c.x=iw(n));a&&!i&&n&&(c.x=iw(n));let d=!n||i||a?sE(0):iS(n,l);return{x:o.left+l.scrollLeft-c.x-d.x,y:o.top+l.scrollTop-c.y-d.y,width:o.width,height:o.height}}(e.reference,await r(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},iR={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:r,rect:s,offsetParent:i,strategy:n}=e,a="fixed"===n,o=s2(i),l=!!r&&it(r.floating);if(i===o||l&&a)return s;let c={scrollLeft:0,scrollTop:0},d=sE(1),u=sE(0),h=s4(i);if((h||!h&&!a)&&(("body"!==s0(i)||s7(o))&&(c=iu(i)),s4(i))){let e=ib(i);d=iv(i),u.x=e.x+i.clientLeft,u.y=e.y+i.clientTop}let f=!o||h||a?sE(0):iS(o,c);return{width:s.width*d.x,height:s.height*d.y,x:s.x*d.x-c.scrollLeft*d.x+u.x+f.x,y:s.y*d.y-c.scrollTop*d.y+u.y+f.y}},getDocumentElement:s2,getClippingRect:function(e){let{element:r,boundary:s,rootBoundary:i,strategy:n}=e,a=[..."clippingAncestors"===s?it(r)?[]:function(e,r){let s=r.get(e);if(s)return s;let i=ip(e,[],!1).filter(e=>s3(e)&&"body"!==s0(e)),n=null,a="fixed"===id(e).position,o=a?ih(e):e;for(;s3(o)&&!ic(o);){let r=id(o),s=ia(o);s||"fixed"!==r.position||(n=null),(a?!s&&!n:!s&&"static"===r.position&&!!n&&iC.has(n.position)||s7(o)&&!s&&function e(r,s){let i=ih(r);return!(i===s||!s3(i)||ic(i))&&("fixed"===id(i).position||e(i,s))}(e,o))?i=i.filter(e=>e!==o):n=r,o=ih(o)}return r.set(e,i),i}(r,this._c):[].concat(s),i],o=a[0],l=a.reduce((e,s)=>{let i=ij(r,s,n);return e.top=sj(i.top,e.top),e.right=sC(i.right,e.right),e.bottom=sC(i.bottom,e.bottom),e.left=sj(i.left,e.left),e},ij(r,o,n));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}},getOffsetParent:iE,getElementRects:iD,getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){let{width:r,height:s}=ig(e);return{width:r,height:s}},getScale:iv,isElement:s3,isRTL:function(e){return"rtl"===id(e).direction}};function iA(e,r){return e.x===r.x&&e.y===r.y&&e.width===r.width&&e.height===r.height}let iM=e=>({name:"arrow",options:e,async fn(r){let{x:s,y:i,placement:n,rects:a,platform:o,elements:l,middlewareData:c}=r,{element:d,padding:u=0}=sA(e,r)||{};if(null==d)return{};let h=sU(u),f={x:s,y:i},p=sT(sL(n)),m=sP(p),g=await o.getDimensions(d),x="y"===p,v=x?"clientHeight":"clientWidth",_=a.reference[m]+a.reference[p]-f[p]-a.floating[m],y=f[p]-a.reference[p],b=await (null==o.getOffsetParent?void 0:o.getOffsetParent(d)),w=b?b[v]:0;w&&await (null==o.isElement?void 0:o.isElement(b))||(w=l.floating[v]||a.floating[m]);let S=w/2-g[m]/2-1,C=sC(h[x?"top":"left"],S),j=sC(h[x?"bottom":"right"],S),k=w-g[m]-j,N=w/2-g[m]/2+(_/2-y/2),E=sj(C,sC(N,k)),D=!c.arrow&&null!=sF(n)&&N!==E&&a.reference[m]/2-(N<C?C:j)-g[m]/2<0,R=D?N<C?N-C:N-k:0;return{[p]:f[p]+R,data:{[p]:E,centerOffset:N-E-R,...D&&{alignmentOffset:R}},reset:D}}});var iF="undefined"!=typeof document?$.useLayoutEffect:function(){};function iT(e,r){let s,i,n;if(e===r)return!0;if(typeof e!=typeof r)return!1;if("function"==typeof e&&e.toString()===r.toString())return!0;if(e&&r&&"object"==typeof e){if(Array.isArray(e)){if((s=e.length)!==r.length)return!1;for(i=s;0!=i--;)if(!iT(e[i],r[i]))return!1;return!0}if((s=(n=Object.keys(e)).length)!==Object.keys(r).length)return!1;for(i=s;0!=i--;)if(!({}).hasOwnProperty.call(r,n[i]))return!1;for(i=s;0!=i--;){let s=n[i];if(("_owner"!==s||!e.$$typeof)&&!iT(e[s],r[s]))return!1}return!0}return e!=e&&r!=r}function iP(e){return"undefined"==typeof window?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function iB(e,r){let s=iP(e);return Math.round(r*s)/s}function iL(e){let r=$.useRef(e);return iF(()=>{r.current=e}),r}var iI=$.forwardRef((e,r)=>{let{children:s,width:i=10,height:n=5,...a}=e;return(0,z.jsx)(er.svg,{...a,ref:r,width:i,height:n,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?s:(0,z.jsx)("polygon",{points:"0,0 30,0 15,10"})})});iI.displayName="Arrow";var iO="Popper",[iz,i$]=K(iO),[iW,iH]=iz(iO),iU=e=>{let{__scopePopper:r,children:s}=e,[i,n]=$.useState(null);return(0,z.jsx)(iW,{scope:r,anchor:i,onAnchorChange:n,children:s})};iU.displayName=iO;var iK="PopperAnchor",iq=$.forwardRef((e,r)=>{let{__scopePopper:s,virtualRef:i,...n}=e,a=iH(iK,s),o=$.useRef(null),l=(0,U.useComposedRefs)(r,o),c=$.useRef(null);return $.useEffect(()=>{let e=c.current;c.current=i?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),i?null:(0,z.jsx)(er.div,{...n,ref:l})});iq.displayName=iK;var iV="PopperContent",[iY,iG]=iz(iV),iX=$.forwardRef((e,r)=>{var s,i,n,a,o,l,c,d,u,h,f,p,m,g,x,v,_,y,b,w,S;let{__scopePopper:C,side:j="bottom",sideOffset:k=0,align:N="center",alignOffset:E=0,arrowPadding:D=0,avoidCollisions:R=!0,collisionBoundary:A=[],collisionPadding:M=0,sticky:F="partial",hideWhenDetached:T=!1,updatePositionStrategy:P="optimized",onPlaced:B,...L}=e,I=iH(iV,C),[O,W]=$.useState(null),H=(0,U.useComposedRefs)(r,e=>W(e)),[K,q]=$.useState(null),Y=J(K),G=Y?.width??0,X=Y?.height??0,Z="number"==typeof M?M:{top:0,right:0,bottom:0,left:0,...M},Q=Array.isArray(A)?A:[A],et=Q.length>0,es={padding:Z,boundary:Q.filter(i0),altBoundary:et},{refs:ei,floatingStyles:en,placement:ea,isPositioned:eo,middlewareData:el}=function(e){void 0===e&&(e={});let{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:n,elements:{reference:a,floating:o}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[u,h]=$.useState({x:0,y:0,strategy:s,placement:r,middlewareData:{},isPositioned:!1}),[f,p]=$.useState(i);iT(f,i)||p(i);let[m,g]=$.useState(null),[x,v]=$.useState(null),_=$.useCallback(e=>{e!==S.current&&(S.current=e,g(e))},[]),y=$.useCallback(e=>{e!==C.current&&(C.current=e,v(e))},[]),b=a||m,w=o||x,S=$.useRef(null),C=$.useRef(null),j=$.useRef(u),k=null!=c,N=iL(c),E=iL(n),D=iL(d),R=$.useCallback(()=>{var e,i;let n,a,o;if(!S.current||!C.current)return;let l={placement:r,strategy:s,middleware:f};E.current&&(l.platform=E.current),(e=S.current,i=C.current,n=new Map,o={...(a={platform:iR,...l}).platform,_c:n},sY(e,i,{...a,platform:o})).then(e=>{let r={...e,isPositioned:!1!==D.current};A.current&&!iT(j.current,r)&&(j.current=r,ee.flushSync(()=>{h(r)}))})},[f,r,s,E,D]);iF(()=>{!1===d&&j.current.isPositioned&&(j.current.isPositioned=!1,h(e=>({...e,isPositioned:!1})))},[d]);let A=$.useRef(!1);iF(()=>(A.current=!0,()=>{A.current=!1}),[]),iF(()=>{if(b&&(S.current=b),w&&(C.current=w),b&&w){if(N.current)return N.current(b,w,R);R()}},[b,w,R,N,k]);let M=$.useMemo(()=>({reference:S,floating:C,setReference:_,setFloating:y}),[_,y]),F=$.useMemo(()=>({reference:b,floating:w}),[b,w]),T=$.useMemo(()=>{let e={position:s,left:0,top:0};if(!F.floating)return e;let r=iB(F.floating,u.x),i=iB(F.floating,u.y);return l?{...e,transform:"translate("+r+"px, "+i+"px)",...iP(F.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:r,top:i}},[s,l,F.floating,u.x,u.y]);return $.useMemo(()=>({...u,update:R,refs:M,elements:F,floatingStyles:T}),[u,R,M,F,T])}({strategy:"fixed",placement:j+("center"!==N?"-"+N:""),whileElementsMounted:(...e)=>(function(e,r,s,i){let n;void 0===i&&(i={});let{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:l="function"==typeof ResizeObserver,layoutShift:c="function"==typeof IntersectionObserver,animationFrame:d=!1}=i,u=ix(e),h=a||o?[...u?ip(u):[],...ip(r)]:[];h.forEach(e=>{a&&e.addEventListener("scroll",s,{passive:!0}),o&&e.addEventListener("resize",s)});let f=u&&c?function(e,r){let s,i=null,n=s2(e);function a(){var e;clearTimeout(s),null==(e=i)||e.disconnect(),i=null}return!function o(l,c){void 0===l&&(l=!1),void 0===c&&(c=1),a();let d=e.getBoundingClientRect(),{left:u,top:h,width:f,height:p}=d;if(l||r(),!f||!p)return;let m={rootMargin:-sN(h)+"px "+-sN(n.clientWidth-(u+f))+"px "+-sN(n.clientHeight-(h+p))+"px "+-sN(u)+"px",threshold:sj(0,sC(1,c))||1},g=!0;function x(r){let i=r[0].intersectionRatio;if(i!==c){if(!g)return o();i?o(!1,i):s=setTimeout(()=>{o(!1,1e-7)},1e3)}1!==i||iA(d,e.getBoundingClientRect())||o(),g=!1}try{i=new IntersectionObserver(x,{...m,root:n.ownerDocument})}catch(e){i=new IntersectionObserver(x,m)}i.observe(e)}(!0),a}(u,s):null,p=-1,m=null;l&&(m=new ResizeObserver(e=>{let[i]=e;i&&i.target===u&&m&&(m.unobserve(r),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;null==(e=m)||e.observe(r)})),s()}),u&&!d&&m.observe(u),m.observe(r));let g=d?ib(e):null;return d&&function r(){let i=ib(e);g&&!iA(g,i)&&s(),g=i,n=requestAnimationFrame(r)}(),s(),()=>{var e;h.forEach(e=>{a&&e.removeEventListener("scroll",s),o&&e.removeEventListener("resize",s)}),null==f||f(),null==(e=m)||e.disconnect(),m=null,d&&cancelAnimationFrame(n)}})(...e,{animationFrame:"always"===P}),elements:{reference:I.anchor},middleware:[{...{name:"offset",options:n=s={mainAxis:k+X,alignmentAxis:E},async fn(e){var r,s;let{x:i,y:a,placement:o,middlewareData:l}=e,c=await sZ(e,n);return o===(null==(r=l.offset)?void 0:r.placement)&&null!=(s=l.arrow)&&s.alignmentOffset?{}:{x:i+c.x,y:a+c.y,data:{...c,placement:o}}}},options:[s,i]},R&&{...{name:"shift",options:u=c={mainAxis:!0,crossAxis:!1,limiter:"partial"===F?{...(void 0===(l=a)&&(l={}),{options:l,fn(e){let{x:r,y:s,placement:i,rects:n,middlewareData:a}=e,{offset:o=0,mainAxis:c=!0,crossAxis:d=!0}=sA(l,e),u={x:r,y:s},h=sL(i),f=sT(h),p=u[f],m=u[h],g=sA(o,e),x="number"==typeof g?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){let e="y"===f?"height":"width",r=n.reference[f]-n.floating[e]+x.mainAxis,s=n.reference[f]+n.reference[e]-x.mainAxis;p<r?p=r:p>s&&(p=s)}if(d){var v,_;let e="y"===f?"width":"height",r=sJ.has(sM(i)),s=n.reference[h]-n.floating[e]+(r&&(null==(v=a.offset)?void 0:v[h])||0)+(r?0:x.crossAxis),o=n.reference[h]+n.reference[e]+(r?0:(null==(_=a.offset)?void 0:_[h])||0)-(r?x.crossAxis:0);m<s?m=s:m>o&&(m=o)}return{[f]:p,[h]:m}}}),options:[a,o]}:void 0,...es},async fn(e){let{x:r,y:s,placement:i,platform:n}=e,{mainAxis:a=!0,crossAxis:o=!1,limiter:l={fn:e=>{let{x:r,y:s}=e;return{x:r,y:s}}},...c}=sA(u,e),d={x:r,y:s},h=await n.detectOverflow(e,c),f=sL(sM(i)),p=sT(f),m=d[p],g=d[f];if(a){let e="y"===p?"top":"left",r="y"===p?"bottom":"right",s=m+h[e],i=m-h[r];m=sj(s,sC(m,i))}if(o){let e="y"===f?"top":"left",r="y"===f?"bottom":"right",s=g+h[e],i=g-h[r];g=sj(s,sC(g,i))}let x=l.fn({...e,[p]:m,[f]:g});return{...x,data:{x:x.x-r,y:x.y-s,enabled:{[p]:a,[f]:o}}}}},options:[c,d]},R&&{...{name:"flip",options:p=h={...es},async fn(e){var r,s,i,n,a,o,l,c;let d,u,h,{placement:f,middlewareData:m,rects:g,initialPlacement:x,platform:v,elements:_}=e,{mainAxis:y=!0,crossAxis:b=!0,fallbackPlacements:w,fallbackStrategy:S="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:j=!0,...k}=sA(p,e);if(null!=(r=m.arrow)&&r.alignmentOffset)return{};let N=sM(f),E=sL(x),D=sM(x)===x,R=await (null==v.isRTL?void 0:v.isRTL(_.floating)),A=w||(D||!j?[sH(x)]:(d=sH(x),[sI(x),d,sI(d)])),M="none"!==C;!w&&M&&A.push(...(u=sF(x),h=function(e,r,s){switch(e){case"top":case"bottom":if(s)return r?sz:sO;return r?sO:sz;case"left":case"right":return r?s$:sW;default:return[]}}(sM(x),"start"===C,R),u&&(h=h.map(e=>e+"-"+u),j&&(h=h.concat(h.map(sI)))),h));let F=[x,...A],T=await v.detectOverflow(e,k),P=[],B=(null==(s=m.flip)?void 0:s.overflows)||[];if(y&&P.push(T[N]),b){let e,r,s,i,n=(o=f,l=g,void 0===(c=R)&&(c=!1),e=sF(o),s=sP(r=sT(sL(o))),i="x"===r?e===(c?"end":"start")?"right":"left":"start"===e?"bottom":"top",l.reference[s]>l.floating[s]&&(i=sH(i)),[i,sH(i)]);P.push(T[n[0]],T[n[1]])}if(B=[...B,{placement:f,overflows:P}],!P.every(e=>e<=0)){let e=((null==(i=m.flip)?void 0:i.index)||0)+1,r=F[e];if(r&&("alignment"!==b||E===sL(r)||B.every(e=>sL(e.placement)!==E||e.overflows[0]>0)))return{data:{index:e,overflows:B},reset:{placement:r}};let s=null==(n=B.filter(e=>e.overflows[0]<=0).sort((e,r)=>e.overflows[1]-r.overflows[1])[0])?void 0:n.placement;if(!s)switch(S){case"bestFit":{let e=null==(a=B.filter(e=>{if(M){let r=sL(e.placement);return r===E||"y"===r}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,r)=>e+r,0)]).sort((e,r)=>e[1]-r[1])[0])?void 0:a[0];e&&(s=e);break}case"initialPlacement":s=x}if(f!==s)return{reset:{placement:s}}}return{}}},options:[h,f]},{...{name:"size",options:x=m={...es,apply:({elements:e,rects:r,availableWidth:s,availableHeight:i})=>{let{width:n,height:a}=r.reference,o=e.floating.style;o.setProperty("--radix-popper-available-width",`${s}px`),o.setProperty("--radix-popper-available-height",`${i}px`),o.setProperty("--radix-popper-anchor-width",`${n}px`),o.setProperty("--radix-popper-anchor-height",`${a}px`)}},async fn(e){var r,s;let i,n,{placement:a,rects:o,platform:l,elements:c}=e,{apply:d=()=>{},...u}=sA(x,e),h=await l.detectOverflow(e,u),f=sM(a),p=sF(a),m="y"===sL(a),{width:g,height:v}=o.floating;"top"===f||"bottom"===f?(i=f,n=p===(await (null==l.isRTL?void 0:l.isRTL(c.floating))?"start":"end")?"left":"right"):(n=f,i="end"===p?"top":"bottom");let _=v-h.top-h.bottom,y=g-h.left-h.right,b=sC(v-h[i],_),w=sC(g-h[n],y),S=!e.middlewareData.shift,C=b,j=w;if(null!=(r=e.middlewareData.shift)&&r.enabled.x&&(j=y),null!=(s=e.middlewareData.shift)&&s.enabled.y&&(C=_),S&&!p){let e=sj(h.left,0),r=sj(h.right,0),s=sj(h.top,0),i=sj(h.bottom,0);m?j=g-2*(0!==e||0!==r?e+r:sj(h.left,h.right)):C=v-2*(0!==s||0!==i?s+i:sj(h.top,h.bottom))}await d({...e,availableWidth:j,availableHeight:C});let k=await l.getDimensions(c.floating);return g!==k.width||v!==k.height?{reset:{rects:!0}}:{}}},options:[m,g]},K&&{...{name:"arrow",options:y=v={element:K,padding:D},fn(e){let{element:r,padding:s}="function"==typeof y?y(e):y;return r&&({}).hasOwnProperty.call(r,"current")?null!=r.current?iM({element:r.current,padding:s}).fn(e):{}:r?iM({element:r,padding:s}).fn(e):{}}},options:[v,_]},i1({arrowWidth:G,arrowHeight:X}),T&&{...{name:"hide",options:S=b={strategy:"referenceHidden",...es},async fn(e){let{rects:r,platform:s}=e,{strategy:i="referenceHidden",...n}=sA(S,e);switch(i){case"referenceHidden":{let i=sG(await s.detectOverflow(e,{...n,elementContext:"reference"}),r.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:sX(i)}}}case"escaped":{let i=sG(await s.detectOverflow(e,{...n,altBoundary:!0}),r.floating);return{data:{escapedOffsets:i,escaped:sX(i)}}}default:return{}}}},options:[b,w]}]}),[ec,ed]=i2(ea),eu=eN(B);V(()=>{eo&&eu?.()},[eo,eu]);let eh=el.arrow?.x,ef=el.arrow?.y,ep=el.arrow?.centerOffset!==0,[em,eg]=$.useState();return V(()=>{O&&eg(window.getComputedStyle(O).zIndex)},[O]),(0,z.jsx)("div",{ref:ei.setFloating,"data-radix-popper-content-wrapper":"",style:{...en,transform:eo?en.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:em,"--radix-popper-transform-origin":[el.transformOrigin?.x,el.transformOrigin?.y].join(" "),...el.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:(0,z.jsx)(iY,{scope:C,placedSide:ec,onArrowChange:q,arrowX:eh,arrowY:ef,shouldHideArrow:ep,children:(0,z.jsx)(er.div,{"data-side":ec,"data-align":ed,...L,ref:H,style:{...L.style,animation:eo?void 0:"none"}})})})});iX.displayName=iV;var iJ="PopperArrow",iZ={top:"bottom",right:"left",bottom:"top",left:"right"},iQ=$.forwardRef(function(e,r){let{__scopePopper:s,...i}=e,n=iG(iJ,s),a=iZ[n.placedSide];return(0,z.jsx)("span",{ref:n.onArrowChange,style:{position:"absolute",left:n.arrowX,top:n.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[n.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[n.placedSide],visibility:n.shouldHideArrow?"hidden":void 0},children:(0,z.jsx)(iI,{...i,ref:r,style:{...i.style,display:"block"}})})});function i0(e){return null!==e}iQ.displayName=iJ;var i1=e=>({name:"transformOrigin",options:e,fn(r){let{placement:s,rects:i,middlewareData:n}=r,a=n.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,l=a?0:e.arrowHeight,[c,d]=i2(s),u={start:"0%",center:"50%",end:"100%"}[d],h=(n.arrow?.x??0)+o/2,f=(n.arrow?.y??0)+l/2,p="",m="";return"bottom"===c?(p=a?u:`${h}px`,m=`${-l}px`):"top"===c?(p=a?u:`${h}px`,m=`${i.floating.height+l}px`):"right"===c?(p=`${-l}px`,m=a?u:`${f}px`):"left"===c&&(p=`${i.floating.width+l}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function i2(e){let[r,s="center"]=e.split("-");return[r,s]}var i5=["Enter"," "],i3=["ArrowUp","PageDown","End"],i4=["ArrowDown","PageUp","Home",...i3],i6={ltr:[...i5,"ArrowRight"],rtl:[...i5,"ArrowLeft"]},i8={ltr:["ArrowLeft"],rtl:["ArrowRight"]},i7="Menu",[i9,ne,nt]=rA(i7),[nr,ns]=K(i7,[nt,i$,rU]),ni=i$(),nn=rU(),[na,no]=nr(i7),[nl,nc]=nr(i7),nd=e=>{let{__scopeMenu:r,open:s=!1,children:i,dir:n,onOpenChange:a,modal:o=!0}=e,l=ni(r),[c,d]=$.useState(null),u=$.useRef(!1),h=eN(a),f=rB(n);return $.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener("pointerdown",r,{capture:!0,once:!0}),document.addEventListener("pointermove",r,{capture:!0,once:!0})},r=()=>u.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",r,{capture:!0}),document.removeEventListener("pointermove",r,{capture:!0})}},[]),(0,z.jsx)(iU,{...l,children:(0,z.jsx)(na,{scope:r,open:s,onOpenChange:h,content:c,onContentChange:d,children:(0,z.jsx)(nl,{scope:r,onClose:$.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:u,dir:f,modal:o,children:i})})})};nd.displayName=i7;var nu=$.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e,n=ni(s);return(0,z.jsx)(iq,{...n,...i,ref:r})});nu.displayName="MenuAnchor";var nh="MenuPortal",[nf,np]=nr(nh,{forceMount:void 0}),nm=e=>{let{__scopeMenu:r,forceMount:s,children:i,container:n}=e,a=no(nh,r);return(0,z.jsx)(nf,{scope:r,forceMount:s,children:(0,z.jsx)(Z,{present:s||a.open,children:(0,z.jsx)(eW,{asChild:!0,container:n,children:i})})})};nm.displayName=nh;var ng="MenuContent",[nx,nv]=nr(ng),n_=$.forwardRef((e,r)=>{let s=np(ng,e.__scopeMenu),{forceMount:i=s.forceMount,...n}=e,a=no(ng,e.__scopeMenu),o=nc(ng,e.__scopeMenu);return(0,z.jsx)(i9.Provider,{scope:e.__scopeMenu,children:(0,z.jsx)(Z,{present:i||a.open,children:(0,z.jsx)(i9.Slot,{scope:e.__scopeMenu,children:o.modal?(0,z.jsx)(ny,{...n,ref:r}):(0,z.jsx)(nb,{...n,ref:r})})})})}),ny=$.forwardRef((e,r)=>{let s=no(ng,e.__scopeMenu),i=$.useRef(null),n=(0,U.useComposedRefs)(r,i);return $.useEffect(()=>{let e=i.current;if(e)return tN(e)},[]),(0,z.jsx)(nS,{...e,ref:n,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:q(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})}),nb=$.forwardRef((e,r)=>{let s=no(ng,e.__scopeMenu);return(0,z.jsx)(nS,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})}),nw=(0,et.createSlot)("MenuContent.ScrollLock"),nS=$.forwardRef((e,r)=>{let{__scopeMenu:s,loop:i=!1,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:h,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...g}=e,x=no(ng,s),v=nc(ng,s),_=ni(s),y=nn(s),b=ne(s),[w,S]=$.useState(null),C=$.useRef(null),j=(0,U.useComposedRefs)(r,C,x.onContentChange),k=$.useRef(0),N=$.useRef(""),E=$.useRef(0),D=$.useRef(null),R=$.useRef("right"),A=$.useRef(0),M=m?ty:$.Fragment;$.useEffect(()=>()=>window.clearTimeout(k.current),[]),eU();let F=$.useCallback(e=>{var r,s;return R.current===D.current?.side&&(r=e,!!(s=D.current?.area)&&function(e,r){let{x:s,y:i}=e,n=!1;for(let e=0,a=r.length-1;e<r.length;a=e++){let o=r[e],l=r[a],c=o.x,d=o.y,u=l.x,h=l.y;d>i!=h>i&&s<(u-c)*(i-d)/(h-d)+c&&(n=!n)}return n}({x:r.clientX,y:r.clientY},s))},[]);return(0,z.jsx)(nx,{scope:s,searchRef:N,onItemEnter:$.useCallback(e=>{F(e)&&e.preventDefault()},[F]),onItemLeave:$.useCallback(e=>{F(e)||(C.current?.focus(),S(null))},[F]),onTriggerLeave:$.useCallback(e=>{F(e)&&e.preventDefault()},[F]),pointerGraceTimerRef:E,onPointerGraceIntentChange:$.useCallback(e=>{D.current=e},[]),children:(0,z.jsx)(M,{...m?{as:nw,allowPinchZoom:!0}:void 0,children:(0,z.jsx)(eB,{asChild:!0,trapped:n,onMountAutoFocus:q(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,z.jsx)(eR,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:h,onInteractOutside:f,onDismiss:p,children:(0,z.jsx)(rV,{asChild:!0,...y,dir:v.dir,orientation:"vertical",loop:i,currentTabStopId:w,onCurrentTabStopIdChange:S,onEntryFocus:q(c,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,z.jsx)(iX,{role:"menu","aria-orientation":"vertical","data-state":nJ(x.open),"data-radix-menu-content":"",dir:v.dir,..._,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:q(g.onKeyDown,e=>{let r=e.target.closest("[data-radix-menu-content]")===e.currentTarget,s=e.ctrlKey||e.altKey||e.metaKey,i=1===e.key.length;if(r){var n;let r,a,o,l,c,d;"Tab"===e.key&&e.preventDefault(),!s&&i&&(n=e.key,r=N.current+n,a=b().filter(e=>!e.disabled),o=document.activeElement,l=a.find(e=>e.ref.current===o)?.textValue,c=function(e,r,s){var i;let n=r.length>1&&Array.from(r).every(e=>e===r[0])?r[0]:r,a=s?e.indexOf(s):-1,o=(i=Math.max(a,0),e.map((r,s)=>e[(i+s)%e.length]));1===n.length&&(o=o.filter(e=>e!==s));let l=o.find(e=>e.toLowerCase().startsWith(n.toLowerCase()));return l!==s?l:void 0}(a.map(e=>e.textValue),r,l),d=a.find(e=>e.textValue===c)?.ref.current,function e(r){N.current=r,window.clearTimeout(k.current),""!==r&&(k.current=window.setTimeout(()=>e(""),1e3))}(r),d&&setTimeout(()=>d.focus()))}let a=C.current;if(e.target!==a||!i4.includes(e.key))return;e.preventDefault();let o=b().filter(e=>!e.disabled).map(e=>e.ref.current);i3.includes(e.key)&&o.reverse(),function(e){let r=document.activeElement;for(let s of e)if(s===r||(s.focus(),document.activeElement!==r))return}(o)}),onBlur:q(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(k.current),N.current="")}),onPointerMove:q(e.onPointerMove,n0(e=>{let r=e.target,s=A.current!==e.clientX;e.currentTarget.contains(r)&&s&&(R.current=e.clientX>A.current?"right":"left",A.current=e.clientX)}))})})})})})})});n_.displayName=ng;var nC=$.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e;return(0,z.jsx)(er.div,{role:"group",...i,ref:r})});nC.displayName="MenuGroup";var nj=$.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e;return(0,z.jsx)(er.div,{...i,ref:r})});nj.displayName="MenuLabel";var nk="MenuItem",nN="menu.itemSelect",nE=$.forwardRef((e,r)=>{let{disabled:s=!1,onSelect:i,...n}=e,a=$.useRef(null),o=nc(nk,e.__scopeMenu),l=nv(nk,e.__scopeMenu),c=(0,U.useComposedRefs)(r,a),d=$.useRef(!1);return(0,z.jsx)(nD,{...n,ref:c,disabled:s,onClick:q(e.onClick,()=>{let e=a.current;if(!s&&e){let r=new CustomEvent(nN,{bubbles:!0,cancelable:!0});e.addEventListener(nN,e=>i?.(e),{once:!0}),es(e,r),r.defaultPrevented?d.current=!1:o.onClose()}}),onPointerDown:r=>{e.onPointerDown?.(r),d.current=!0},onPointerUp:q(e.onPointerUp,e=>{d.current||e.currentTarget?.click()}),onKeyDown:q(e.onKeyDown,e=>{let r=""!==l.searchRef.current;s||r&&" "===e.key||i5.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});nE.displayName=nk;var nD=$.forwardRef((e,r)=>{let{__scopeMenu:s,disabled:i=!1,textValue:n,...a}=e,o=nv(nk,s),l=nn(s),c=$.useRef(null),d=(0,U.useComposedRefs)(r,c),[u,h]=$.useState(!1),[f,p]=$.useState("");return $.useEffect(()=>{let e=c.current;e&&p((e.textContent??"").trim())},[a.children]),(0,z.jsx)(i9.ItemSlot,{scope:s,disabled:i,textValue:n??f,children:(0,z.jsx)(rX,{asChild:!0,...l,focusable:!i,children:(0,z.jsx)(er.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...a,ref:d,onPointerMove:q(e.onPointerMove,n0(e=>{i?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:q(e.onPointerLeave,n0(e=>o.onItemLeave(e))),onFocus:q(e.onFocus,()=>h(!0)),onBlur:q(e.onBlur,()=>h(!1))})})})}),nR=$.forwardRef((e,r)=>{let{checked:s=!1,onCheckedChange:i,...n}=e;return(0,z.jsx)(nI,{scope:e.__scopeMenu,checked:s,children:(0,z.jsx)(nE,{role:"menuitemcheckbox","aria-checked":nZ(s)?"mixed":s,...n,ref:r,"data-state":nQ(s),onSelect:q(n.onSelect,()=>i?.(!!nZ(s)||!s),{checkForDefaultPrevented:!1})})})});nR.displayName="MenuCheckboxItem";var nA="MenuRadioGroup",[nM,nF]=nr(nA,{value:void 0,onValueChange:()=>{}}),nT=$.forwardRef((e,r)=>{let{value:s,onValueChange:i,...n}=e,a=eN(i);return(0,z.jsx)(nM,{scope:e.__scopeMenu,value:s,onValueChange:a,children:(0,z.jsx)(nC,{...n,ref:r})})});nT.displayName=nA;var nP="MenuRadioItem",nB=$.forwardRef((e,r)=>{let{value:s,...i}=e,n=nF(nP,e.__scopeMenu),a=s===n.value;return(0,z.jsx)(nI,{scope:e.__scopeMenu,checked:a,children:(0,z.jsx)(nE,{role:"menuitemradio","aria-checked":a,...i,ref:r,"data-state":nQ(a),onSelect:q(i.onSelect,()=>n.onValueChange?.(s),{checkForDefaultPrevented:!1})})})});nB.displayName=nP;var nL="MenuItemIndicator",[nI,nO]=nr(nL,{checked:!1}),nz=$.forwardRef((e,r)=>{let{__scopeMenu:s,forceMount:i,...n}=e,a=nO(nL,s);return(0,z.jsx)(Z,{present:i||nZ(a.checked)||!0===a.checked,children:(0,z.jsx)(er.span,{...n,ref:r,"data-state":nQ(a.checked)})})});nz.displayName=nL;var n$=$.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e;return(0,z.jsx)(er.div,{role:"separator","aria-orientation":"horizontal",...i,ref:r})});n$.displayName="MenuSeparator";var nW=$.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e,n=ni(s);return(0,z.jsx)(iQ,{...n,...i,ref:r})});nW.displayName="MenuArrow";var nH="MenuSub",[nU,nK]=nr(nH),nq=e=>{let{__scopeMenu:r,children:s,open:i=!1,onOpenChange:n}=e,a=no(nH,r),o=ni(r),[l,c]=$.useState(null),[d,u]=$.useState(null),h=eN(n);return $.useEffect(()=>(!1===a.open&&h(!1),()=>h(!1)),[a.open,h]),(0,z.jsx)(iU,{...o,children:(0,z.jsx)(na,{scope:r,open:i,onOpenChange:h,content:d,onContentChange:u,children:(0,z.jsx)(nU,{scope:r,contentId:ek(),triggerId:ek(),trigger:l,onTriggerChange:c,children:s})})})};nq.displayName=nH;var nV="MenuSubTrigger",nY=$.forwardRef((e,r)=>{let s=no(nV,e.__scopeMenu),i=nc(nV,e.__scopeMenu),n=nK(nV,e.__scopeMenu),a=nv(nV,e.__scopeMenu),o=$.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=a,d={__scopeMenu:e.__scopeMenu},u=$.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return $.useEffect(()=>u,[u]),$.useEffect(()=>{let e=l.current;return()=>{window.clearTimeout(e),c(null)}},[l,c]),(0,z.jsx)(nu,{asChild:!0,...d,children:(0,z.jsx)(nD,{id:n.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":n.contentId,"data-state":nJ(s.open),...e,ref:(0,U.composeRefs)(r,n.onTriggerChange),onClick:r=>{e.onClick?.(r),e.disabled||r.defaultPrevented||(r.currentTarget.focus(),s.open||s.onOpenChange(!0))},onPointerMove:q(e.onPointerMove,n0(r=>{a.onItemEnter(r),!r.defaultPrevented&&(e.disabled||s.open||o.current||(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{s.onOpenChange(!0),u()},100)))})),onPointerLeave:q(e.onPointerLeave,n0(e=>{u();let r=s.content?.getBoundingClientRect();if(r){let i=s.content?.dataset.side,n="right"===i,o=r[n?"left":"right"],c=r[n?"right":"left"];a.onPointerGraceIntentChange({area:[{x:e.clientX+(n?-5:5),y:e.clientY},{x:o,y:r.top},{x:c,y:r.top},{x:c,y:r.bottom},{x:o,y:r.bottom}],side:i}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:q(e.onKeyDown,r=>{let n=""!==a.searchRef.current;e.disabled||n&&" "===r.key||i6[i.dir].includes(r.key)&&(s.onOpenChange(!0),s.content?.focus(),r.preventDefault())})})})});nY.displayName=nV;var nG="MenuSubContent",nX=$.forwardRef((e,r)=>{let s=np(ng,e.__scopeMenu),{forceMount:i=s.forceMount,...n}=e,a=no(ng,e.__scopeMenu),o=nc(ng,e.__scopeMenu),l=nK(nG,e.__scopeMenu),c=$.useRef(null),d=(0,U.useComposedRefs)(r,c);return(0,z.jsx)(i9.Provider,{scope:e.__scopeMenu,children:(0,z.jsx)(Z,{present:i||a.open,children:(0,z.jsx)(i9.Slot,{scope:e.__scopeMenu,children:(0,z.jsx)(nS,{id:l.contentId,"aria-labelledby":l.triggerId,...n,ref:d,align:"start",side:"rtl"===o.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:q(e.onFocusOutside,e=>{e.target!==l.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:q(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:q(e.onKeyDown,e=>{let r=e.currentTarget.contains(e.target),s=i8[o.dir].includes(e.key);r&&s&&(a.onOpenChange(!1),l.trigger?.focus(),e.preventDefault())})})})})})});function nJ(e){return e?"open":"closed"}function nZ(e){return"indeterminate"===e}function nQ(e){return nZ(e)?"indeterminate":e?"checked":"unchecked"}function n0(e){return r=>"mouse"===r.pointerType?e(r):void 0}nX.displayName=nG;var n1="DropdownMenu",[n2,n5]=K(n1,[ns]),n3=ns(),[n4,n6]=n2(n1),n8=e=>{let{__scopeDropdownMenu:r,children:s,dir:i,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=e,c=n3(r),d=$.useRef(null),[u,h]=G({prop:n,defaultProp:a??!1,onChange:o,caller:n1});return(0,z.jsx)(n4,{scope:r,triggerId:ek(),triggerRef:d,contentId:ek(),open:u,onOpenChange:h,onOpenToggle:$.useCallback(()=>h(e=>!e),[h]),modal:l,children:(0,z.jsx)(nd,{...c,open:u,onOpenChange:h,dir:i,modal:l,children:s})})};n8.displayName=n1;var n7="DropdownMenuTrigger",n9=$.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,disabled:i=!1,...n}=e,a=n6(n7,s),o=n3(s);return(0,z.jsx)(nu,{asChild:!0,...o,children:(0,z.jsx)(er.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...n,ref:(0,U.composeRefs)(r,a.triggerRef),onPointerDown:q(e.onPointerDown,e=>{!i&&0===e.button&&!1===e.ctrlKey&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:q(e.onKeyDown,e=>{!i&&(["Enter"," "].includes(e.key)&&a.onOpenToggle(),"ArrowDown"===e.key&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});n9.displayName=n7;var ae=e=>{let{__scopeDropdownMenu:r,...s}=e,i=n3(r);return(0,z.jsx)(nm,{...i,...s})};ae.displayName="DropdownMenuPortal";var at="DropdownMenuContent",ar=$.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=n6(at,s),a=n3(s),o=$.useRef(!1);return(0,z.jsx)(n_,{id:n.contentId,"aria-labelledby":n.triggerId,...a,...i,ref:r,onCloseAutoFocus:q(e.onCloseAutoFocus,e=>{o.current||n.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:q(e.onInteractOutside,e=>{let r=e.detail.originalEvent,s=0===r.button&&!0===r.ctrlKey,i=2===r.button||s;(!n.modal||i)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ar.displayName=at,$.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=n3(s);return(0,z.jsx)(nC,{...n,...i,ref:r})}).displayName="DropdownMenuGroup";var as=$.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=n3(s);return(0,z.jsx)(nj,{...n,...i,ref:r})});as.displayName="DropdownMenuLabel";var ai=$.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=n3(s);return(0,z.jsx)(nE,{...n,...i,ref:r})});ai.displayName="DropdownMenuItem";var an=$.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=n3(s);return(0,z.jsx)(nR,{...n,...i,ref:r})});an.displayName="DropdownMenuCheckboxItem";var aa=$.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=n3(s);return(0,z.jsx)(nT,{...n,...i,ref:r})});aa.displayName="DropdownMenuRadioGroup";var ao=$.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=n3(s);return(0,z.jsx)(nB,{...n,...i,ref:r})});ao.displayName="DropdownMenuRadioItem";var al=$.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=n3(s);return(0,z.jsx)(nz,{...n,...i,ref:r})});al.displayName="DropdownMenuItemIndicator";var ac=$.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=n3(s);return(0,z.jsx)(n$,{...n,...i,ref:r})});ac.displayName="DropdownMenuSeparator",$.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=n3(s);return(0,z.jsx)(nW,{...n,...i,ref:r})}).displayName="DropdownMenuArrow";var ad=$.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=n3(s);return(0,z.jsx)(nY,{...n,...i,ref:r})});ad.displayName="DropdownMenuSubTrigger";var au=$.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=n3(s);return(0,z.jsx)(nX,{...n,...i,ref:r,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});au.displayName="DropdownMenuSubContent";var ah=e=>{let{__scopeDropdownMenu:r,children:s,open:i,onOpenChange:n,defaultOpen:a}=e,o=n3(r),[l,c]=G({prop:i,defaultProp:a??!1,onChange:n,caller:"DropdownMenuSub"});return(0,z.jsx)(nq,{...o,open:l,onOpenChange:c,children:s})},H=H;let af=(0,ew.default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);function ap({...e}){return(0,z.jsx)(n8,{"data-slot":"dropdown-menu",...e})}function am({...e}){return(0,z.jsx)(n9,{"data-slot":"dropdown-menu-trigger",...e})}function ag({className:e,sideOffset:r=4,...s}){return(0,z.jsx)(ae,{children:(0,z.jsx)(ar,{"data-slot":"dropdown-menu-content",sideOffset:r,className:(0,ey.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...s})})}function ax({className:e,inset:r,variant:s="default",...i}){return(0,z.jsx)(ai,{"data-slot":"dropdown-menu-item","data-inset":r,"data-variant":s,className:(0,ey.cn)("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...i})}function av({className:e,children:r,checked:s,...i}){return(0,z.jsxs)(an,{"data-slot":"dropdown-menu-checkbox-item",className:(0,ey.cn)("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:s,...i,children:[(0,z.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:(0,z.jsx)(al,{children:(0,z.jsx)(H.default,{className:"size-4"})})}),r]})}function a_({...e}){return(0,z.jsx)(aa,{"data-slot":"dropdown-menu-radio-group",...e})}function ay({className:e,children:r,...s}){return(0,z.jsxs)(ao,{"data-slot":"dropdown-menu-radio-item",className:(0,ey.cn)("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...s,children:[(0,z.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:(0,z.jsx)(al,{children:(0,z.jsx)(rS,{className:"size-2 fill-current"})})}),r]})}function ab({className:e,inset:r,...s}){return(0,z.jsx)(as,{"data-slot":"dropdown-menu-label","data-inset":r,className:(0,ey.cn)("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...s})}function aw({className:e,...r}){return(0,z.jsx)(ac,{"data-slot":"dropdown-menu-separator",className:(0,ey.cn)("bg-border -mx-1 my-1 h-px",e),...r})}function aS({...e}){return(0,z.jsx)(ah,{"data-slot":"dropdown-menu-sub",...e})}function aC({className:e,inset:r,children:s,...i}){return(0,z.jsxs)(ad,{"data-slot":"dropdown-menu-sub-trigger","data-inset":r,className:(0,ey.cn)("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...i,children:[s,(0,z.jsx)(af,{className:"ml-auto size-4"})]})}function aj({className:e,...r}){return(0,z.jsx)(au,{"data-slot":"dropdown-menu-sub-content",className:(0,ey.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",e),...r})}function ak({targets:e,activeTarget:r,onTargetChange:s,onAddRemote:i,disabled:n}){if(e.length<=2)return(0,z.jsx)("div",{className:"inline-flex items-center rounded-md border bg-muted/50 px-0.5 text-xs",children:e.map(e=>{let i=e.icon;return(0,z.jsxs)("button",{onClick:()=>s(e.id),disabled:n,className:(0,ey.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors",r===e.id?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground",n&&"opacity-50 cursor-not-allowed"),children:[i&&(0,z.jsx)(i,{className:"h-3 w-3"}),e.label]},e.id)})});let a=e.find(e=>e.id===r)??e[0],o=a?.icon;return(0,z.jsxs)(ap,{children:[(0,z.jsx)(am,{asChild:!0,children:(0,z.jsxs)("button",{disabled:n,className:(0,ey.cn)("inline-flex items-center gap-1 rounded-md border bg-muted/50 px-2 py-0.5 text-xs font-medium transition-colors hover:bg-muted",n&&"opacity-50 cursor-not-allowed"),children:[o&&(0,z.jsx)(o,{className:"h-3 w-3"}),a?.label??"Local",(0,z.jsx)(sw,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,z.jsxs)(ag,{align:"start",children:[(0,z.jsx)(a_,{value:r,onValueChange:s,children:e.map(e=>{let r=e.icon;return(0,z.jsxs)(ay,{value:e.id,className:"text-xs",children:[r&&(0,z.jsx)(r,{className:"h-3 w-3"}),e.label]},e.id)})}),i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(aw,{}),(0,z.jsxs)(ax,{onClick:i,className:"text-xs",children:[(0,z.jsx)(eS,{className:"h-3 w-3"}),"Add Remote"]})]})]})]})}let aN=(0,ew.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),aE=(0,ew.default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),aD=(0,ew.default)("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]),aR=(0,ew.default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]),aA=(0,ew.default)("crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);function aM(e,[r,s]){return Math.min(s,Math.max(r,e))}var aF="ScrollArea",[aT,aP]=K(aF),[aB,aL]=aT(aF),aI=$.forwardRef((e,r)=>{let{__scopeScrollArea:s,type:i="hover",dir:n,scrollHideDelay:a=600,...o}=e,[l,c]=$.useState(null),[d,u]=$.useState(null),[h,f]=$.useState(null),[p,m]=$.useState(null),[g,x]=$.useState(null),[v,_]=$.useState(0),[y,b]=$.useState(0),[w,S]=$.useState(!1),[C,j]=$.useState(!1),k=(0,U.useComposedRefs)(r,e=>c(e)),N=rB(n);return(0,z.jsx)(aB,{scope:s,type:i,dir:N,scrollHideDelay:a,scrollArea:l,viewport:d,onViewportChange:u,content:h,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:w,onScrollbarXEnabledChange:S,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:C,onScrollbarYEnabledChange:j,onCornerWidthChange:_,onCornerHeightChange:b,children:(0,z.jsx)(er.div,{dir:N,...o,ref:k,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});aI.displayName=aF;var aO="ScrollAreaViewport",az=$.forwardRef((e,r)=>{let{__scopeScrollArea:s,children:i,nonce:n,...a}=e,o=aL(aO,s),l=$.useRef(null),c=(0,U.useComposedRefs)(r,l,o.onViewportChange);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),(0,z.jsx)(er.div,{"data-radix-scroll-area-viewport":"",...a,ref:c,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,z.jsx)("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})});az.displayName=aO;var a$="ScrollAreaScrollbar",aW=$.forwardRef((e,r)=>{let{forceMount:s,...i}=e,n=aL(a$,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=n,l="horizontal"===e.orientation;return $.useEffect(()=>(l?a(!0):o(!0),()=>{l?a(!1):o(!1)}),[l,a,o]),"hover"===n.type?(0,z.jsx)(aH,{...i,ref:r,forceMount:s}):"scroll"===n.type?(0,z.jsx)(aU,{...i,ref:r,forceMount:s}):"auto"===n.type?(0,z.jsx)(aK,{...i,ref:r,forceMount:s}):"always"===n.type?(0,z.jsx)(aq,{...i,ref:r}):null});aW.displayName=a$;var aH=$.forwardRef((e,r)=>{let{forceMount:s,...i}=e,n=aL(a$,e.__scopeScrollArea),[a,o]=$.useState(!1);return $.useEffect(()=>{let e=n.scrollArea,r=0;if(e){let s=()=>{window.clearTimeout(r),o(!0)},i=()=>{r=window.setTimeout(()=>o(!1),n.scrollHideDelay)};return e.addEventListener("pointerenter",s),e.addEventListener("pointerleave",i),()=>{window.clearTimeout(r),e.removeEventListener("pointerenter",s),e.removeEventListener("pointerleave",i)}}},[n.scrollArea,n.scrollHideDelay]),(0,z.jsx)(Z,{present:s||a,children:(0,z.jsx)(aK,{"data-state":a?"visible":"hidden",...i,ref:r})})}),aU=$.forwardRef((e,r)=>{var s;let{forceMount:i,...n}=e,a=aL(a$,e.__scopeScrollArea),o="horizontal"===e.orientation,l=oe(()=>d("SCROLL_END"),100),[c,d]=(s={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},$.useReducer((e,r)=>s[e][r]??e,"hidden"));return $.useEffect(()=>{if("idle"===c){let e=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(e)}},[c,a.scrollHideDelay,d]),$.useEffect(()=>{let e=a.viewport,r=o?"scrollLeft":"scrollTop";if(e){let s=e[r],i=()=>{let i=e[r];s!==i&&(d("SCROLL"),l()),s=i};return e.addEventListener("scroll",i),()=>e.removeEventListener("scroll",i)}},[a.viewport,o,d,l]),(0,z.jsx)(Z,{present:i||"hidden"!==c,children:(0,z.jsx)(aq,{"data-state":"hidden"===c?"hidden":"visible",...n,ref:r,onPointerEnter:q(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:q(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),aK=$.forwardRef((e,r)=>{let s=aL(a$,e.__scopeScrollArea),{forceMount:i,...n}=e,[a,o]=$.useState(!1),l="horizontal"===e.orientation,c=oe(()=>{if(s.viewport){let e=s.viewport.offsetWidth<s.viewport.scrollWidth,r=s.viewport.offsetHeight<s.viewport.scrollHeight;o(l?e:r)}},10);return ot(s.viewport,c),ot(s.content,c),(0,z.jsx)(Z,{present:i||a,children:(0,z.jsx)(aq,{"data-state":a?"visible":"hidden",...n,ref:r})})}),aq=$.forwardRef((e,r)=>{let{orientation:s="vertical",...i}=e,n=aL(a$,e.__scopeScrollArea),a=$.useRef(null),o=$.useRef(0),[l,c]=$.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=a4(l.viewport,l.content),u={...i,sizes:l,onSizesChange:c,hasThumb:!!(d>0&&d<1),onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function h(e,r){return function(e,r,s,i="ltr"){let n=a6(s),a=r||n/2,o=s.scrollbar.paddingStart+a,l=s.scrollbar.size-s.scrollbar.paddingEnd-(n-a),c=s.content-s.viewport;return a7([o,l],"ltr"===i?[0,c]:[-1*c,0])(e)}(e,o.current,l,r)}return"horizontal"===s?(0,z.jsx)(aV,{...u,ref:r,onThumbPositionChange:()=>{if(n.viewport&&a.current){let e=a8(n.viewport.scrollLeft,l,n.dir);a.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{n.viewport&&(n.viewport.scrollLeft=e)},onDragScroll:e=>{n.viewport&&(n.viewport.scrollLeft=h(e,n.dir))}}):"vertical"===s?(0,z.jsx)(aY,{...u,ref:r,onThumbPositionChange:()=>{if(n.viewport&&a.current){let e=a8(n.viewport.scrollTop,l);a.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{n.viewport&&(n.viewport.scrollTop=e)},onDragScroll:e=>{n.viewport&&(n.viewport.scrollTop=h(e))}}):null}),aV=$.forwardRef((e,r)=>{let{sizes:s,onSizesChange:i,...n}=e,a=aL(a$,e.__scopeScrollArea),[o,l]=$.useState(),c=$.useRef(null),d=(0,U.useComposedRefs)(r,c,a.onScrollbarXChange);return $.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,z.jsx)(aJ,{"data-orientation":"horizontal",...n,ref:d,sizes:s,style:{bottom:0,left:"rtl"===a.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===a.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":a6(s)+"px",...e.style},onThumbPointerDown:r=>e.onThumbPointerDown(r.x),onDragScroll:r=>e.onDragScroll(r.x),onWheelScroll:(r,s)=>{if(a.viewport){var i,n;let o=a.viewport.scrollLeft+r.deltaX;e.onWheelScroll(o),i=o,n=s,i>0&&i<n&&r.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&i({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:a3(o.paddingLeft),paddingEnd:a3(o.paddingRight)}})}})}),aY=$.forwardRef((e,r)=>{let{sizes:s,onSizesChange:i,...n}=e,a=aL(a$,e.__scopeScrollArea),[o,l]=$.useState(),c=$.useRef(null),d=(0,U.useComposedRefs)(r,c,a.onScrollbarYChange);return $.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,z.jsx)(aJ,{"data-orientation":"vertical",...n,ref:d,sizes:s,style:{top:0,right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":a6(s)+"px",...e.style},onThumbPointerDown:r=>e.onThumbPointerDown(r.y),onDragScroll:r=>e.onDragScroll(r.y),onWheelScroll:(r,s)=>{if(a.viewport){var i,n;let o=a.viewport.scrollTop+r.deltaY;e.onWheelScroll(o),i=o,n=s,i>0&&i<n&&r.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&i({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:a3(o.paddingTop),paddingEnd:a3(o.paddingBottom)}})}})}),[aG,aX]=aT(a$),aJ=$.forwardRef((e,r)=>{let{__scopeScrollArea:s,sizes:i,hasThumb:n,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:u,onResize:h,...f}=e,p=aL(a$,s),[m,g]=$.useState(null),x=(0,U.useComposedRefs)(r,e=>g(e)),v=$.useRef(null),_=$.useRef(""),y=p.viewport,b=i.content-i.viewport,w=eN(u),S=eN(c),C=oe(h,10);function j(e){v.current&&d({x:e.clientX-v.current.left,y:e.clientY-v.current.top})}return $.useEffect(()=>{let e=e=>{let r=e.target;m?.contains(r)&&w(e,b)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[y,m,b,w]),$.useEffect(S,[i,S]),ot(m,C),ot(p.content,C),(0,z.jsx)(aG,{scope:s,scrollbar:m,hasThumb:n,onThumbChange:eN(a),onThumbPointerUp:eN(o),onThumbPositionChange:S,onThumbPointerDown:eN(l),children:(0,z.jsx)(er.div,{...f,ref:x,style:{position:"absolute",...f.style},onPointerDown:q(e.onPointerDown,e=>{0===e.button&&(e.target.setPointerCapture(e.pointerId),v.current=m.getBoundingClientRect(),_.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),j(e))}),onPointerMove:q(e.onPointerMove,j),onPointerUp:q(e.onPointerUp,e=>{let r=e.target;r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=_.current,p.viewport&&(p.viewport.style.scrollBehavior=""),v.current=null})})})}),aZ="ScrollAreaThumb",aQ=$.forwardRef((e,r)=>{let{forceMount:s,...i}=e,n=aX(aZ,e.__scopeScrollArea);return(0,z.jsx)(Z,{present:s||n.hasThumb,children:(0,z.jsx)(a0,{ref:r,...i})})}),a0=$.forwardRef((e,r)=>{let{__scopeScrollArea:s,style:i,...n}=e,a=aL(aZ,s),o=aX(aZ,s),{onThumbPositionChange:l}=o,c=(0,U.useComposedRefs)(r,e=>o.onThumbChange(e)),d=$.useRef(void 0),u=oe(()=>{d.current&&(d.current(),d.current=void 0)},100);return $.useEffect(()=>{let e=a.viewport;if(e){let r=()=>{u(),d.current||(d.current=a9(e,l),l())};return l(),e.addEventListener("scroll",r),()=>e.removeEventListener("scroll",r)}},[a.viewport,u,l]),(0,z.jsx)(er.div,{"data-state":o.hasThumb?"visible":"hidden",...n,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:q(e.onPointerDownCapture,e=>{let r=e.target.getBoundingClientRect(),s=e.clientX-r.left,i=e.clientY-r.top;o.onThumbPointerDown({x:s,y:i})}),onPointerUp:q(e.onPointerUp,o.onThumbPointerUp)})});aQ.displayName=aZ;var a1="ScrollAreaCorner",a2=$.forwardRef((e,r)=>{let s=aL(a1,e.__scopeScrollArea),i=!!(s.scrollbarX&&s.scrollbarY);return"scroll"!==s.type&&i?(0,z.jsx)(a5,{...e,ref:r}):null});a2.displayName=a1;var a5=$.forwardRef((e,r)=>{let{__scopeScrollArea:s,...i}=e,n=aL(a1,s),[a,o]=$.useState(0),[l,c]=$.useState(0),d=!!(a&&l);return ot(n.scrollbarX,()=>{let e=n.scrollbarX?.offsetHeight||0;n.onCornerHeightChange(e),c(e)}),ot(n.scrollbarY,()=>{let e=n.scrollbarY?.offsetWidth||0;n.onCornerWidthChange(e),o(e)}),d?(0,z.jsx)(er.div,{...i,ref:r,style:{width:a,height:l,position:"absolute",right:"ltr"===n.dir?0:void 0,left:"rtl"===n.dir?0:void 0,bottom:0,...e.style}}):null});function a3(e){return e?parseInt(e,10):0}function a4(e,r){let s=e/r;return isNaN(s)?0:s}function a6(e){let r=a4(e.viewport,e.content),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd;return Math.max((e.scrollbar.size-s)*r,18)}function a8(e,r,s="ltr"){let i=a6(r),n=r.scrollbar.paddingStart+r.scrollbar.paddingEnd,a=r.scrollbar.size-n,o=r.content-r.viewport,l=aM(e,"ltr"===s?[0,o]:[-1*o,0]);return a7([0,o],[0,a-i])(l)}function a7(e,r){return s=>{if(e[0]===e[1]||r[0]===r[1])return r[0];let i=(r[1]-r[0])/(e[1]-e[0]);return r[0]+i*(s-e[0])}}var a9=(e,r=()=>{})=>{let s={left:e.scrollLeft,top:e.scrollTop},i=0;return!function n(){let a={left:e.scrollLeft,top:e.scrollTop},o=s.left!==a.left,l=s.top!==a.top;(o||l)&&r(),s=a,i=window.requestAnimationFrame(n)}(),()=>window.cancelAnimationFrame(i)};function oe(e,r){let s=eN(e),i=$.useRef(0);return $.useEffect(()=>()=>window.clearTimeout(i.current),[]),$.useCallback(()=>{window.clearTimeout(i.current),i.current=window.setTimeout(s,r)},[s,r])}function ot(e,r){let s=eN(r);V(()=>{let r=0;if(e){let i=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(s)});return i.observe(e),()=>{window.cancelAnimationFrame(r),i.unobserve(e)}}},[e,s])}function or({className:e,children:r,...s}){return(0,z.jsxs)(aI,{"data-slot":"scroll-area",className:(0,ey.cn)("relative",e),...s,children:[(0,z.jsx)(az,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:r}),(0,z.jsx)(os,{}),(0,z.jsx)(a2,{})]})}function os({className:e,orientation:r="vertical",...s}){return(0,z.jsx)(aW,{"data-slot":"scroll-area-scrollbar",orientation:r,className:(0,ey.cn)("flex touch-none p-px transition-colors select-none","vertical"===r&&"h-full w-2.5 border-l border-l-transparent","horizontal"===r&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:(0,z.jsx)(aQ,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}let oi=(0,ew.default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),on=(0,ew.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),oa=(0,ew.default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);function oo({serverId:e,onSelect:r,selectedPath:s}){let[i,n]=(0,$.useState)("/"),[a,o]=(0,$.useState)([]),[l,c]=(0,$.useState)(!1),[d,u]=(0,$.useState)(""),[h,f]=(0,$.useState)(!1),[p,m]=(0,$.useState)(""),[g,x]=(0,$.useState)(""),[v,_]=(0,$.useState)(!1),y=(0,$.useRef)(null),b=(0,$.useRef)(!1),w=(0,$.useCallback)(async()=>{if(!e)return void o([]);c(!0),u("");try{let r=await rv.api.browseRemoteServerDirectory(e,i);o(r.items??[])}catch(e){u(e instanceof Error?e.message:"Failed to load directory"),o([])}finally{c(!1)}},[e,i]);(0,$.useEffect)(()=>{w(),f(!1),m(""),x("")},[w]),(0,$.useEffect)(()=>{h&&(y.current?.focus(),y.current?.select())},[h]);let S=()=>{f(!1),m(""),x("")},C=async()=>{if(b.current)return;let s=p.trim();if(!s)return void S();b.current=!0,_(!0),x("");try{let n=await rv.api.createRemoteServerDirectory(e,i,s);f(!1),m(""),await w(),r(n.path)}catch(e){x(e instanceof Error?e.message:"Failed to create folder")}finally{b.current=!1,_(!1)}};return e?(0,z.jsxs)("div",{className:"border rounded-md",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2 p-2 border-b bg-muted/50",children:[(0,z.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:()=>{n(i.split("/").slice(0,-1).join("/")||"/")},disabled:"/"===i||l,children:(0,z.jsx)(oa,{className:"h-4 w-4"})}),(0,z.jsx)("span",{className:"text-sm font-mono truncate flex-1",children:i}),(0,z.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:()=>{x(""),m("New Folder"),f(!0)},disabled:l||h,title:"New folder",children:(0,z.jsx)(on,{className:"h-4 w-4"})})]}),l?(0,z.jsx)("div",{className:"flex items-center justify-center h-[200px]",children:(0,z.jsx)(rk,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):d?(0,z.jsx)("div",{className:"p-4 text-sm text-red-500 h-[200px] overflow-y-auto",children:d}):(0,z.jsx)(or,{className:"h-[200px]",children:(0,z.jsxs)("div",{className:"p-1",children:[h&&(0,z.jsxs)("div",{className:"flex flex-col gap-1 p-2",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(oi,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,z.jsx)("input",{ref:y,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),C()):"Escape"===e.key&&(e.preventDefault(),S())},onBlur:()=>{v||C()},disabled:v,className:"flex-1 bg-background border rounded px-1.5 py-0.5 text-sm outline-none focus:ring-1 focus:ring-ring"}),v&&(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin text-muted-foreground shrink-0"})]}),g&&(0,z.jsx)("span",{className:"text-xs text-red-500 pl-6",children:g})]}),0!==a.length||h?a.map(e=>(0,z.jsxs)("div",{className:`flex items-center gap-2 p-2 rounded-md cursor-pointer hover:bg-muted ${s===e.path?"bg-muted":""}`,children:[(0,z.jsxs)("button",{className:"flex items-center gap-2 flex-1 text-left",onClick:()=>{r(e.path)},children:[(0,z.jsx)(oi,{className:"h-4 w-4 text-muted-foreground"}),(0,z.jsx)("span",{className:"text-sm truncate",children:e.name})]}),(0,z.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:()=>{n(e.path)},title:"Open folder",children:(0,z.jsx)(af,{className:"h-4 w-4"})})]},e.path)):(0,z.jsx)("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"No directories found"})]})})]}):(0,z.jsx)("div",{className:"text-sm text-muted-foreground p-4 text-center border rounded-md",children:"Select a remote server to browse directories"})}let ol={actionType:"command",executionMode:"local",content:""};function oc(e){return e?{actionType:e.actionType,executionMode:e.executionMode,content:e.content}:{...ol}}function od(e){return{actionType:e.actionType,executionMode:e.executionMode,content:e.content}}function ou({actionType:e,onActionTypeChange:r}){return(0,z.jsxs)("div",{className:"inline-flex items-center rounded-md border bg-muted/50 p-0.5 text-xs",children:[(0,z.jsxs)("button",{onClick:()=>r("command"),className:(0,ey.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors","command"===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[(0,z.jsx)(aN,{className:"h-3 w-3"}),"Command"]}),(0,z.jsxs)("button",{onClick:()=>r("prompt"),className:(0,ey.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors","prompt"===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[(0,z.jsx)(aE,{className:"h-3 w-3"}),"Prompt"]})]})}function oh({config:e,onChange:r,label:s,targets:i}){return(0,z.jsxs)("div",{className:"space-y-4 py-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:s}),i.length>0&&(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-xs text-muted-foreground",children:"Execution Environment"}),(0,z.jsx)("div",{children:(0,z.jsx)(ak,{targets:i,activeTarget:e.executionMode,onTargetChange:s=>r({...e,executionMode:s})})})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-xs text-muted-foreground",children:"Action Type"}),(0,z.jsx)("div",{children:(0,z.jsx)(ou,{actionType:e.actionType,onActionTypeChange:s=>r({...e,actionType:s})})})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-xs text-muted-foreground",children:"command"===e.actionType?"Shell Command":"Agent Prompt"}),(0,z.jsx)(rl,{value:e.content,onChange:s=>r({...e,content:s.target.value}),placeholder:"command"===e.actionType?"git push origin HEAD":"Please pull the latest changes and rebase...",rows:3})]})]})}function of({project:e,onSave:r,onCancel:s}){let{remotes:i,refresh:n}=sc(e.id),a=[];for(let r of(e.path&&a.push({id:"local",label:"Local",icon:aD}),i))a.push({id:r.remote_server_id,label:r.server_name,icon:so});let[o,l]=(0,$.useState)(e.name),[c,d]=(0,$.useState)(e.path??""),[u,h]=(0,$.useState)(!1),[f,p]=(0,$.useState)(""),[m,g]=(0,$.useState)(null),[x,v]=(0,$.useState)(oc(e.sync_up_config)),[_,y]=(0,$.useState)(oc(e.sync_down_config)),[b,w]=(0,$.useState)("closed"),[S,C]=(0,$.useState)([]),[j,k]=(0,$.useState)(null),[N,E]=(0,$.useState)(""),[D,R]=(0,$.useState)(""),[A,M]=(0,$.useState)(""),[F,T]=(0,$.useState)(""),[P,B]=(0,$.useState)("idle"),[L,I]=(0,$.useState)(""),O=()=>{w("closed"),k(null),E(""),R(""),M(""),T(""),B("idle"),I("")};(0,$.useEffect)(()=>{l(e.name),d(e.path??""),p(""),v(oc(e.sync_up_config)),y(oc(e.sync_down_config)),O()},[e.id]);let H=async()=>{let e=await rv.api.selectFolder();e.path&&d(e.path)},U=async()=>{w("pick-server");try{let e=await rv.api.getRemoteServers();C(e)}catch{C([])}},K=async()=>{if(!A||!F)return void I("URL and API key are required");B("testing"),I("");try{await rv.api.testRemoteConnection(A,F),B("success")}catch(e){B("error"),I(e instanceof Error?e.message:"Connection failed")}},q=async()=>{if(D.trim()&&A.trim())try{let e=await rv.api.createRemoteServer({name:D.trim(),url:A.trim(),apiKey:F.trim()||void 0});k(e),E(""),w("pick-path")}catch(e){I(e instanceof Error?e.message:"Failed to create server")}},V=async()=>{if(j&&N)try{await rv.api.addProjectRemote(e.id,{remoteServerId:j.id,remotePath:N}),await n(),O()}catch(e){p(e instanceof Error?e.message:"Failed to add remote")}},Y=async r=>{try{await rv.api.removeProjectRemote(e.id,r),await n()}catch(e){p(e instanceof Error?e.message:"Failed to remove remote")}},G=async r=>{p(""),g(r);try{await rv.api.setProjectRemotePrimary(e.id,r),await n()}catch(e){p(e instanceof Error?e.message:"Failed to set primary remote")}finally{g(null)}},X=c.trim().length>0,J=async()=>{if(!o.trim())return void p("Project name is required");if(!X&&0===i.length)return void p("Project must have at least a local folder or remote server");h(!0),p("");try{let s={};o.trim()!==e.name&&(s.name=o.trim());let i=X?c.trim():null;i!==(e.path??null)&&(s.path=i);let n=od(x),a=e.sync_up_config;JSON.stringify(n)!==JSON.stringify(a)&&(s.syncUpConfig=n);let l=od(_),d=e.sync_down_config;JSON.stringify(l)!==JSON.stringify(d)&&(s.syncDownConfig=l),await r(e.id,s)}catch(e){p(e instanceof Error?e.message:"Failed to update project")}finally{h(!1)}};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(r4,{defaultValue:"settings",children:[(0,z.jsxs)(si,{className:"w-full",children:[(0,z.jsx)(sn,{value:"settings",className:"flex-1",children:"Project Settings"}),(0,z.jsx)(sn,{value:"sync-up",className:"flex-1",children:"Sync Up"}),(0,z.jsx)(sn,{value:"sync-down",className:"flex-1",children:"Sync Down"})]}),(0,z.jsx)(sa,{value:"settings",children:(0,z.jsxs)("div",{className:"space-y-5 py-2",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Project Name"}),(0,z.jsx)(ro,{value:o,onChange:e=>l(e.target.value),placeholder:"My Project"})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Local Folder"}),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsx)(ro,{value:c,onChange:e=>d(e.target.value),placeholder:"/path/to/project (optional)",className:"flex-1"}),(0,z.jsx)(W.Button,{variant:"outline",onClick:H,children:(0,z.jsx)(r_,{className:"h-4 w-4"})})]})]}),(0,z.jsxs)("div",{className:"space-y-3",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Remote Servers"}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:"The primary remote is used for remote-only projects and default remote operations. When a local checkout exists, merge status is computed locally."}),i.length>0&&(0,z.jsx)("div",{className:"space-y-2",children:i.map((e,r)=>(0,z.jsxs)("div",{className:"flex items-center gap-2 rounded-md border p-2 text-sm",children:[(0,z.jsx)(ry,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,z.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)("p",{className:"font-medium truncate",children:e.server_name}),0===r&&(0,z.jsxs)(sb,{variant:"secondary",className:"shrink-0 gap-1",children:[(0,z.jsx)(aA,{className:"h-3 w-3"}),"Primary"]})]}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:e.remote_path})]}),0!==r&&(0,z.jsxs)(W.Button,{variant:"outline",size:"sm",className:"h-7 shrink-0",disabled:null!==m,onClick:()=>G(e.id),children:[m===e.id&&(0,z.jsx)(rk,{className:"h-3.5 w-3.5 animate-spin"}),"Set as Primary"]}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon-sm",className:"h-7 w-7 shrink-0",onClick:()=>Y(e.id),children:(0,z.jsx)(rc,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},e.id))}),"closed"===b&&(0,z.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:U,className:"w-full",children:[(0,z.jsx)(eS,{className:"h-4 w-4 mr-1"}),"Add Remote"]}),"pick-server"===b&&(0,z.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsx)("label",{className:"text-xs font-medium",children:"Select a Remote Server"}),(0,z.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:O,children:(0,z.jsx)(t8,{className:"h-3.5 w-3.5"})})]}),S.length>0&&(0,z.jsx)("div",{className:"space-y-1",children:S.map(e=>(0,z.jsxs)("button",{className:"flex items-center gap-2 w-full rounded-md p-2 text-sm text-left hover:bg-muted",onClick:()=>{k(e),E(""),w("pick-path")},children:[(0,z.jsx)(aR,{className:"h-4 w-4 text-muted-foreground"}),(0,z.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,z.jsx)("p",{className:"truncate",children:e.name}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.url})]})]},e.id))}),(0,z.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:()=>{w("new-server"),R(""),M(""),T(""),B("idle"),I("")},className:"w-full",children:[(0,z.jsx)(eS,{className:"h-4 w-4 mr-1"}),"New Server"]})]}),"new-server"===b&&(0,z.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsx)("label",{className:"text-xs font-medium",children:"Create New Server"}),(0,z.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:O,children:(0,z.jsx)(t8,{className:"h-3.5 w-3.5"})})]}),(0,z.jsx)(ro,{value:D,onChange:e=>R(e.target.value),placeholder:"Server name"}),(0,z.jsx)(ro,{value:A,onChange:e=>{M(e.target.value),B("idle")},placeholder:"http://remote-server:5173"}),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsx)(ro,{type:"password",value:F,onChange:e=>{T(e.target.value),B("idle")},placeholder:"API key",className:"flex-1"}),(0,z.jsx)(W.Button,{variant:"outline",size:"sm",onClick:K,disabled:"testing"===P||!A||!F,children:"testing"===P?(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin"}):"success"===P?(0,z.jsx)(rf.Check,{className:"h-4 w-4 text-green-500"}):"error"===P?(0,z.jsx)(t8,{className:"h-4 w-4 text-red-500"}):"Test"})]}),L&&(0,z.jsx)("p",{className:"text-xs text-red-500",children:L}),"success"===P&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("p",{className:"text-xs text-green-500",children:"Connection successful"}),(0,z.jsx)(W.Button,{size:"sm",onClick:q,disabled:!D.trim(),children:"Create & Continue"})]})]}),"pick-path"===b&&j&&(0,z.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("label",{className:"text-xs font-medium",children:["Select Directory on ",j.name]}),(0,z.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:O,children:(0,z.jsx)(t8,{className:"h-3.5 w-3.5"})})]}),(0,z.jsx)(oo,{serverId:j.id,onSelect:e=>{E(e)},selectedPath:N}),N&&(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Selected:"," ",(0,z.jsx)("span",{className:"font-mono",children:N})]}),(0,z.jsx)(W.Button,{size:"sm",onClick:V,children:"Add"})]})]})]})]})}),(0,z.jsx)(sa,{value:"sync-up",children:(0,z.jsx)(oh,{config:x,onChange:v,label:"Sync Up Button",targets:a})}),(0,z.jsx)(sa,{value:"sync-down",children:(0,z.jsx)(oh,{config:_,onChange:y,label:"Sync Down Button",targets:a})})]}),f&&(0,z.jsx)("p",{className:"text-sm text-red-500",children:f}),(0,z.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[s&&(0,z.jsx)(W.Button,{variant:"outline",onClick:s,children:"Cancel"}),(0,z.jsx)(W.Button,{onClick:J,disabled:u,children:u?"Saving...":"Save Changes"})]})]})}let op={todo:{label:"To Do",color:"bg-muted text-muted-foreground"},in_progress:{label:"In Progress",color:"bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300"},done:{label:"Done",color:"bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300"},cancelled:{label:"Cancelled",color:"bg-neutral-100 text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400 line-through"}},om={low:{label:"Low",color:"bg-muted text-muted-foreground"},medium:{label:"Medium",color:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/40 dark:text-yellow-300"},high:{label:"High",color:"bg-orange-100 text-orange-800 dark:bg-orange-900/40 dark:text-orange-300"},urgent:{label:"Urgent",color:"bg-red-100 text-red-800 dark:bg-red-900/40 dark:text-red-300"}},og=["todo","in_progress","done","cancelled"],ox=["low","medium","high","urgent"];function ov({task:e,open:r,onOpenChange:s}){return e?(0,z.jsx)(t7,{open:r,onOpenChange:s,children:(0,z.jsxs)(rr,{className:"sm:max-w-lg",children:[(0,z.jsx)(rs,{children:(0,z.jsx)(rn,{className:"text-base leading-snug",children:e.title})}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(sb,{variant:"outline",className:`text-xs ${op[e.status].color}`,children:op[e.status].label}),(0,z.jsx)(sb,{variant:"outline",className:`text-xs ${om[e.priority].color}`,children:om[e.priority].label})]}),e.description&&(0,z.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:e.description}),(0,z.jsxs)("div",{className:"flex gap-4 text-xs text-muted-foreground pt-2 border-t",children:[(0,z.jsxs)("span",{children:["Created: ",new Date(e.created_at).toLocaleString()]}),(0,z.jsxs)("span",{children:["Updated: ",new Date(e.updated_at).toLocaleString()]})]})]})]})}):null}function o_({project:e}){let r=!!e.path,s=e.is_remote||!!e.remote_path;return r&&s?(0,z.jsx)("span",{className:"inline-flex items-center rounded-full bg-purple-500/10 px-2.5 py-0.5 text-xs font-medium text-purple-600",children:"Local + Remote"}):s?(0,z.jsx)("span",{className:"inline-flex items-center rounded-full bg-blue-500/10 px-2.5 py-0.5 text-xs font-medium text-blue-600",children:"Remote"}):(0,z.jsx)("span",{className:"inline-flex items-center rounded-full bg-muted px-2.5 py-0.5 text-xs font-medium text-muted-foreground",children:"Local"})}function oy({status:e}){switch(e){case"done":return(0,z.jsx)(rC,{className:"h-3.5 w-3.5 shrink-0 text-green-600"});case"in_progress":return(0,z.jsx)(rk,{className:"h-3.5 w-3.5 shrink-0 text-blue-600"});case"cancelled":return(0,z.jsx)(rj,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/60"});default:return(0,z.jsx)(rS,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})}}function ob({priority:e}){return"urgent"===e?(0,z.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-red-500 shrink-0"}):"high"===e?(0,z.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-orange-500 shrink-0"}):null}function ow({status:e}){return(0,z.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${"working"===e?"bg-blue-500":"completed"===e?"bg-green-500":"stopped"===e?"bg-amber-500":"bg-muted-foreground/40"}`})}let oS={in_progress:0,todo:1,done:2,cancelled:3},oC={urgent:0,high:1,medium:2,low:3};function oj({project:e,tasks:r,worktrees:s,selectedBranch:i,workspaceStatuses:n,onSelectBranch:a,onProjectUpdated:o}){let{remotes:l}=sc(e.id),[c,d]=(0,$.useState)(null),[u,h]=(0,$.useState)(!1),f=(0,$.useMemo)(()=>r.filter(e=>null===e.archived_at),[r]),p=(0,$.useMemo)(()=>[...f].sort((e,r)=>{let s=oS[e.status]-oS[r.status];if(0!==s)return s;let i=oC[e.priority]-oC[r.priority];return 0!==i?i:r.updated_at.localeCompare(e.updated_at)}),[f]).slice(0,5);return(0,z.jsxs)("div",{className:"h-full flex flex-col p-6 overflow-hidden",children:[(0,z.jsxs)(r4,{defaultValue:"home",className:"w-full max-w-4xl mx-auto flex flex-col flex-1 min-h-0",children:[(0,z.jsxs)(si,{children:[(0,z.jsx)(sn,{value:"home",children:"Home"}),(0,z.jsx)(sn,{value:"settings",children:"Settings"})]}),(0,z.jsxs)(sa,{value:"home",className:"flex-1 overflow-auto mt-4 space-y-4",children:[(0,z.jsxs)(rN,{children:[(0,z.jsx)(rE,{children:(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsx)(rD,{className:"text-lg",children:e.name}),(0,z.jsx)(o_,{project:e})]})}),(0,z.jsxs)(rR,{className:"space-y-3",children:[e.path&&(0,z.jsxs)("div",{className:"flex items-start gap-3 text-sm",children:[(0,z.jsx)(r_,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),(0,z.jsx)("span",{className:"text-muted-foreground break-all",children:e.path})]}),l.map(e=>(0,z.jsxs)("div",{className:"flex items-start gap-3 text-sm",children:[(0,z.jsx)(ry,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),(0,z.jsxs)("div",{className:"min-w-0",children:[(0,z.jsx)("span",{className:"text-muted-foreground break-all",children:e.server_name}),e.server_url&&(0,z.jsx)("span",{className:"block text-xs text-muted-foreground/70 break-all",children:e.server_url})]})]},e.id)),(0,z.jsxs)("div",{className:"flex items-center gap-3 text-sm",children:[(0,z.jsx)(rb,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,z.jsxs)("span",{className:"text-muted-foreground",children:["Created ",new Date(e.created_at).toLocaleDateString()]})]})]})]}),(0,z.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,z.jsxs)(rN,{children:[(0,z.jsx)(rE,{children:(0,z.jsxs)(rD,{className:"text-sm flex items-center justify-between",children:[(0,z.jsx)("span",{children:"Tasks"}),(0,z.jsx)("span",{className:"text-xs font-normal text-muted-foreground",children:f.length})]})}),(0,z.jsxs)(rR,{children:[0===p.length?(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"No tasks yet"}):(0,z.jsx)("ul",{className:"space-y-2",children:p.map(e=>{let r="done"===e.status||"cancelled"===e.status;return(0,z.jsx)("li",{children:(0,z.jsxs)("button",{type:"button",onClick:()=>{d(e),h(!0)},className:"flex w-full items-center gap-2 text-sm rounded-md px-2 py-1 -mx-2 hover:bg-muted/60 transition-colors text-left",children:[(0,z.jsx)(oy,{status:e.status}),(0,z.jsx)("span",{className:`flex-1 truncate ${r?"text-muted-foreground line-through":""}`,children:e.title}),(0,z.jsx)(ob,{priority:e.priority})]})},e.id)})}),f.length>p.length&&(0,z.jsxs)("p",{className:"text-xs text-muted-foreground mt-3",children:["+",f.length-p.length," more"]})]})]}),(0,z.jsxs)(rN,{children:[(0,z.jsx)(rE,{children:(0,z.jsxs)(rD,{className:"text-sm flex items-center justify-between",children:[(0,z.jsx)("span",{children:"Workspaces"}),(0,z.jsx)("span",{className:"text-xs font-normal text-muted-foreground",children:s.length})]})}),(0,z.jsx)(rR,{children:0===s.length?(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"No workspaces"}):(0,z.jsx)("ul",{className:"space-y-2",children:s.map(e=>{let r=su(e.branch),s=i===e.branch;return(0,z.jsx)("li",{children:(0,z.jsxs)("button",{type:"button",onClick:()=>a(e.branch),className:"flex w-full items-center gap-2 text-sm rounded-md px-2 py-1 -mx-2 hover:bg-muted/60 transition-colors text-left",children:[(0,z.jsx)(ow,{status:n.get(r)}),(0,z.jsx)(rw,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,z.jsx)("span",{className:`flex-1 truncate ${s?"font-medium text-foreground":"text-muted-foreground"}`,children:e.branch??"(main)"})]})},r)})})})]})]})]}),(0,z.jsx)(sa,{value:"settings",className:"flex-1 overflow-auto",children:(0,z.jsx)(of,{project:e,onSave:o})})]}),(0,z.jsx)(ov,{task:c,open:u,onOpenChange:h})]})}var ok=e.i(112683);function oN(e){return e?"target-not-found"===e.error?e.requestedTarget:e.target:null}function oE(e){let r=[],s=`vibedeckx:mergeTarget:${e}:`;try{for(let e=0;e<localStorage.length;e+=1){let i=localStorage.key(e);if(!i?.startsWith(s))continue;let n=localStorage.getItem(i);n&&r.push({key:i,branch:i.slice(s.length),target:n})}}catch{}return r}let oD=new Map,oR=new Set(["working","main-running"]),oA=(0,ew.default)("calendar-clock",[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);var oM=e.i(94265),oF=oM;let oT=(0,ew.default)("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),oP=(0,ew.default)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),oB=(0,ew.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var oL=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),oI=$.forwardRef((e,r)=>(0,z.jsx)(er.span,{...e,ref:r,style:{...oL,...e.style}}));oI.displayName="VisuallyHidden";var[oO,oz]=K("Tooltip",[i$]),o$=i$(),oW="TooltipProvider",oH="tooltip.open",[oU,oK]=oO(oW),oq=e=>{let{__scopeTooltip:r,delayDuration:s=700,skipDelayDuration:i=300,disableHoverableContent:n=!1,children:a}=e,o=$.useRef(!0),l=$.useRef(!1),c=$.useRef(0);return $.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,z.jsx)(oU,{scope:r,isOpenDelayedRef:o,delayDuration:s,onOpen:$.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:$.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,i)},[i]),isPointerInTransitRef:l,onPointerInTransitChange:$.useCallback(e=>{l.current=e},[]),disableHoverableContent:n,children:a})};oq.displayName=oW;var oV="Tooltip",[oY,oG]=oO(oV),oX=e=>{let{__scopeTooltip:r,children:s,open:i,defaultOpen:n,onOpenChange:a,disableHoverableContent:o,delayDuration:l}=e,c=oK(oV,e.__scopeTooltip),d=o$(r),[u,h]=$.useState(null),f=ek(),p=$.useRef(0),m=o??c.disableHoverableContent,g=l??c.delayDuration,x=$.useRef(!1),[v,_]=G({prop:i,defaultProp:n??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(oH))):c.onClose(),a?.(e)},caller:oV}),y=$.useMemo(()=>v?x.current?"delayed-open":"instant-open":"closed",[v]),b=$.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,_(!0)},[_]),w=$.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),S=$.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,_(!0),p.current=0},g)},[g,_]);return $.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),(0,z.jsx)(iU,{...d,children:(0,z.jsx)(oY,{scope:r,contentId:f,open:v,stateAttribute:y,trigger:u,onTriggerChange:h,onTriggerEnter:$.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:$.useCallback(()=>{m?w():(window.clearTimeout(p.current),p.current=0)},[w,m]),onOpen:b,onClose:w,disableHoverableContent:m,children:s})})};oX.displayName=oV;var oJ="TooltipTrigger",oZ=$.forwardRef((e,r)=>{let{__scopeTooltip:s,...i}=e,n=oG(oJ,s),a=oK(oJ,s),o=o$(s),l=$.useRef(null),c=(0,U.useComposedRefs)(r,l,n.onTriggerChange),d=$.useRef(!1),u=$.useRef(!1),h=$.useCallback(()=>d.current=!1,[]);return $.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),(0,z.jsx)(iq,{asChild:!0,...o,children:(0,z.jsx)(er.button,{"aria-describedby":n.open?n.contentId:void 0,"data-state":n.stateAttribute,...i,ref:c,onPointerMove:q(e.onPointerMove,e=>{"touch"!==e.pointerType&&(u.current||a.isPointerInTransitRef.current||(n.onTriggerEnter(),u.current=!0))}),onPointerLeave:q(e.onPointerLeave,()=>{n.onTriggerLeave(),u.current=!1}),onPointerDown:q(e.onPointerDown,()=>{n.open&&n.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:q(e.onFocus,()=>{d.current||n.onOpen()}),onBlur:q(e.onBlur,n.onClose),onClick:q(e.onClick,n.onClose)})})});oZ.displayName=oJ;var oQ="TooltipPortal",[o0,o1]=oO(oQ,{forceMount:void 0}),o2=e=>{let{__scopeTooltip:r,forceMount:s,children:i,container:n}=e,a=oG(oQ,r);return(0,z.jsx)(o0,{scope:r,forceMount:s,children:(0,z.jsx)(Z,{present:s||a.open,children:(0,z.jsx)(eW,{asChild:!0,container:n,children:i})})})};o2.displayName=oQ;var o5="TooltipContent",o3=$.forwardRef((e,r)=>{let s=o1(o5,e.__scopeTooltip),{forceMount:i=s.forceMount,side:n="top",...a}=e,o=oG(o5,e.__scopeTooltip);return(0,z.jsx)(Z,{present:i||o.open,children:o.disableHoverableContent?(0,z.jsx)(o9,{side:n,...a,ref:r}):(0,z.jsx)(o4,{side:n,...a,ref:r})})}),o4=$.forwardRef((e,r)=>{let s=oG(o5,e.__scopeTooltip),i=oK(o5,e.__scopeTooltip),n=$.useRef(null),a=(0,U.useComposedRefs)(r,n),[o,l]=$.useState(null),{trigger:c,onClose:d}=s,u=n.current,{onPointerInTransitChange:h}=i,f=$.useCallback(()=>{l(null),h(!1)},[h]),p=$.useCallback((e,r)=>{let s,i=e.currentTarget,n={x:e.clientX,y:e.clientY},a=function(e,r){let s=Math.abs(r.top-e.y),i=Math.abs(r.bottom-e.y),n=Math.abs(r.right-e.x),a=Math.abs(r.left-e.x);switch(Math.min(s,i,n,a)){case a:return"left";case n:return"right";case s:return"top";case i:return"bottom";default:throw Error("unreachable")}}(n,i.getBoundingClientRect());l(((s=[...function(e,r,s=5){let i=[];switch(r){case"top":i.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":i.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":i.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":i.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s})}return i}(n,a),...function(e){let{top:r,right:s,bottom:i,left:n}=e;return[{x:n,y:r},{x:s,y:r},{x:s,y:i},{x:n,y:i}]}(r.getBoundingClientRect())].slice()).sort((e,r)=>e.x<r.x?-1:e.x>r.x?1:e.y<r.y?-1:1*!!(e.y>r.y)),function(e){if(e.length<=1)return e.slice();let r=[];for(let s=0;s<e.length;s++){let i=e[s];for(;r.length>=2;){let e=r[r.length-1],s=r[r.length-2];if((e.x-s.x)*(i.y-s.y)>=(e.y-s.y)*(i.x-s.x))r.pop();else break}r.push(i)}r.pop();let s=[];for(let r=e.length-1;r>=0;r--){let i=e[r];for(;s.length>=2;){let e=s[s.length-1],r=s[s.length-2];if((e.x-r.x)*(i.y-r.y)>=(e.y-r.y)*(i.x-r.x))s.pop();else break}s.push(i)}return(s.pop(),1===r.length&&1===s.length&&r[0].x===s[0].x&&r[0].y===s[0].y)?r:r.concat(s)}(s))),h(!0)},[h]);return $.useEffect(()=>()=>f(),[f]),$.useEffect(()=>{if(c&&u){let e=e=>p(e,u),r=e=>p(e,c);return c.addEventListener("pointerleave",e),u.addEventListener("pointerleave",r),()=>{c.removeEventListener("pointerleave",e),u.removeEventListener("pointerleave",r)}}},[c,u,p,f]),$.useEffect(()=>{if(o){let e=e=>{let r=e.target,s={x:e.clientX,y:e.clientY},i=c?.contains(r)||u?.contains(r),n=!function(e,r){let{x:s,y:i}=e,n=!1;for(let e=0,a=r.length-1;e<r.length;a=e++){let o=r[e],l=r[a],c=o.x,d=o.y,u=l.x,h=l.y;d>i!=h>i&&s<(u-c)*(i-d)/(h-d)+c&&(n=!n)}return n}(s,o);i?f():n&&(f(),d())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[c,u,o,d,f]),(0,z.jsx)(o9,{...e,ref:a})}),[o6,o8]=oO(oV,{isInside:!1}),o7=(0,et.createSlottable)("TooltipContent"),o9=$.forwardRef((e,r)=>{let{__scopeTooltip:s,children:i,"aria-label":n,onEscapeKeyDown:a,onPointerDownOutside:o,...l}=e,c=oG(o5,s),d=o$(s),{onClose:u}=c;return $.useEffect(()=>(document.addEventListener(oH,u),()=>document.removeEventListener(oH,u)),[u]),$.useEffect(()=>{if(c.trigger){let e=e=>{let r=e.target;r?.contains(c.trigger)&&u()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[c.trigger,u]),(0,z.jsx)(eR,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,z.jsxs)(iX,{"data-state":c.stateAttribute,...d,...l,ref:r,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[(0,z.jsx)(o7,{children:i}),(0,z.jsx)(o6,{scope:s,isInside:!0,children:(0,z.jsx)(oI,{id:c.contentId,role:"tooltip",children:n||i})})]})})});o3.displayName=o5;var le="TooltipArrow",lt=$.forwardRef((e,r)=>{let{__scopeTooltip:s,...i}=e,n=o$(s);return o8(le,s).isInside?null:(0,z.jsx)(iQ,{...n,...i,ref:r})});lt.displayName=le,e.s(["Arrow",()=>lt,"Content",()=>o3,"Portal",()=>o2,"Provider",()=>oq,"Root",()=>oX,"Tooltip",()=>oX,"TooltipArrow",()=>lt,"TooltipContent",()=>o3,"TooltipPortal",()=>o2,"TooltipProvider",()=>oq,"TooltipTrigger",()=>oZ,"Trigger",()=>oZ,"createTooltipScope",()=>oz],517964);var lr=e.i(517964),lr=lr;function ls({delayDuration:e=0,...r}){return(0,z.jsx)(lr.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function li({...e}){return(0,z.jsx)(lr.Root,{"data-slot":"tooltip",...e})}function ln({...e}){return(0,z.jsx)(lr.Trigger,{"data-slot":"tooltip-trigger",...e})}function la({className:e,sideOffset:r=0,children:s,...i}){return(0,z.jsx)(lr.Portal,{children:(0,z.jsxs)(lr.Content,{"data-slot":"tooltip-content",sideOffset:r,className:(0,ey.cn)("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...i,children:[s,(0,z.jsx)(lr.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}let lo=(0,ew.default)("check-check",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]),ll=(0,ew.default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);function lc({info:e,repositoryLabel:r,onClick:s}){let i=function(e,r){if("target-not-found"===e.error){let s=`Target branch '${e.requestedTarget}' not found — pick a new target or reset to default`;return r?`${s} \xb7 ${r}`:s}let s=["merged"===e.status?`Merged into ${e.target}`:"no-unique-commits"===e.status?`In sync with ${e.target}`:`${e.unmergedCount} commit${1!==e.unmergedCount?"s":""} not in ${e.target}`];return e.dirty&&s.push("uncommitted changes"),r&&s.push(r),s.join(" · ")}(e,r);return(0,z.jsxs)(li,{children:[(0,z.jsx)(ln,{asChild:!0,children:(0,z.jsxs)("button",{onClick:e=>{e.stopPropagation(),s()},"aria-label":i,className:"relative shrink-0 flex items-center justify-center h-4 min-w-4 px-0.5 rounded hover:bg-muted",children:["target-not-found"===e.error?(0,z.jsx)(ll,{className:"h-3 w-3 text-amber-500"}):"merged"===e.status?(0,z.jsx)(rf.Check,{className:"h-3 w-3 text-muted-foreground/70"}):"no-unique-commits"===e.status?(0,z.jsx)(lo,{className:"h-3 w-3 text-emerald-500"}):(0,z.jsx)("span",{className:"text-[10px] font-mono leading-none text-amber-500",children:e.unmergedCount}),!e.error&&e.dirty&&(0,z.jsx)("span",{className:"absolute -top-0.5 -right-0.5 h-1.5 w-1.5 rounded-full bg-orange-400"})]})}),(0,z.jsx)(la,{side:"right",children:i})]})}let ld=(0,ew.default)("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]),lu=(0,ew.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);function lh({projectId:e,branch:r,currentTarget:s,onTargetChange:i,onTargetReset:n,onDelete:a}){let[o,l]=(0,$.useState)(null),c=async()=>{null!==o||l((await rv.api.getProjectBranches(e)).filter(e=>e!==r))};return(0,z.jsxs)(ap,{children:[(0,z.jsx)(am,{asChild:!0,children:(0,z.jsx)("button",{onClick:e=>e.stopPropagation(),className:"shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 hover:bg-muted transition-all",title:"Workspace menu",children:(0,z.jsx)(lu,{className:"h-3 w-3"})})}),(0,z.jsxs)(ag,{side:"right",align:"start",children:[(0,z.jsxs)(aS,{children:[(0,z.jsxs)(aC,{onPointerEnter:c,onFocus:c,children:[(0,z.jsx)(ld,{className:"h-3.5 w-3.5 mr-1.5"}),"Compare against"]}),(0,z.jsxs)(aj,{children:[null===o?(0,z.jsx)(ax,{disabled:!0,children:"Loading…"}):0===o.length?(0,z.jsx)(ax,{disabled:!0,children:"No other branches"}):o.map(e=>(0,z.jsx)(av,{checked:e===s,onCheckedChange:()=>i(e),children:(0,z.jsx)("span",{className:"font-mono text-xs",children:e})},e)),(0,z.jsx)(aw,{}),(0,z.jsx)(ax,{onClick:n,children:(0,z.jsx)("span",{className:"text-xs",children:"Default branch (auto)"})})]})]}),(0,z.jsxs)(ax,{onClick:a,className:"text-destructive focus:text-destructive",children:[(0,z.jsx)(rc,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete worktree"]})]})]})}function lf({status:e}){let r="relative h-[7px] w-[7px] rounded-full shrink-0";return e&&"idle"!==e?"working"===e?(0,z.jsx)("span",{className:(0,ey.cn)(r,"bg-blue-500"),children:(0,z.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-blue-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})}):"main-running"===e?(0,z.jsx)("span",{className:(0,ey.cn)(r,"bg-violet-500"),children:(0,z.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-violet-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})}):"main-completed"===e?(0,z.jsx)("span",{className:(0,ey.cn)(r,"bg-emerald-500")}):"stopped"===e?(0,z.jsx)("span",{className:(0,ey.cn)(r,"bg-amber-500")}):(0,z.jsx)("span",{className:(0,ey.cn)(r,"bg-lime-400")}):(0,z.jsx)("span",{className:(0,ey.cn)(r,"bg-muted-foreground/40")})}function lp({status:e}){let r="relative h-[7px] w-[7px] rounded-full shrink-0";return"running"===e?(0,z.jsx)("span",{className:(0,ey.cn)(r,"bg-blue-500"),children:(0,z.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-blue-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})}):"error"===e?(0,z.jsx)("span",{className:(0,ey.cn)(r,"bg-red-500")}):(0,z.jsx)("span",{className:(0,ey.cn)(r,"bg-lime-400")})}function lm({schedule:e}){let r="relative h-[7px] w-[7px] rounded-full shrink-0";if(e.running)return(0,z.jsx)("span",{className:(0,ey.cn)(r,"bg-blue-500"),children:(0,z.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-blue-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})});let s=e.last_run;return s&&"skipped"!==s.status?"completed"===s.status?(0,z.jsx)("span",{className:(0,ey.cn)(r,"bg-emerald-500")}):"failed"===s.status||"timeout"===s.status||"killed"===s.status?(0,z.jsx)("span",{className:(0,ey.cn)(r,"bg-red-500")}):(0,z.jsx)("span",{className:(0,ey.cn)(r,"bg-blue-500")}):(0,z.jsx)("span",{className:(0,ey.cn)(r,"bg-muted-foreground/40")})}function lg({project:e}){let r=!!e.path,s=e.is_remote||!!e.remote_path,i="h-[7px] w-[7px] rounded-full shrink-0";return r&&s?(0,z.jsx)("span",{className:(0,ey.cn)(i,"bg-purple-500")}):s?(0,z.jsx)("span",{className:(0,ey.cn)(i,"bg-blue-500")}):(0,z.jsx)("span",{className:(0,ey.cn)(i,"bg-muted-foreground/40")})}function lx({children:e,className:r}){return(0,z.jsx)("div",{className:(0,ey.cn)("px-2 pt-2.5 pb-1.5 border-t border-border/50 first:border-t-0",r),children:e})}function lv({children:e,action:r}){return(0,z.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.06em] text-muted-foreground/80",children:[(0,z.jsx)("span",{children:e}),r]})}function l_({icon:e,label:r,active:s,disabled:i,onClick:n}){return(0,z.jsxs)("button",{onClick:n,disabled:i,className:(0,ey.cn)("relative w-full flex items-center gap-[9px] rounded-md px-2 py-[5px] text-[12.5px] font-normal transition-colors",i&&"text-muted-foreground/40 cursor-not-allowed",!i&&!s&&"text-foreground/75 hover:bg-muted hover:text-foreground",s&&"bg-card text-foreground font-medium shadow-sm"),children:[s&&(0,z.jsx)("span",{className:"absolute -left-2 top-1.5 bottom-1.5 w-[2px] rounded-full bg-primary"}),(0,z.jsx)("span",{className:(0,ey.cn)("shrink-0 flex items-center justify-center",s?"text-foreground":"text-muted-foreground"),children:e}),(0,z.jsx)("span",{className:"truncate text-left",children:r})]})}function ly({activeView:e,onViewChange:r,worktrees:s,selectedBranch:i,onBranchChange:n,currentProject:a,onCreateWorktreeOpen:o,onDeleteWorktree:l,mergeStatuses:c,mergeDefaultTarget:d,mergeRepositoryLabel:u,onMergeTargetChange:h,onMergeBadgeClick:f,workspaceStatuses:p,residentSessions:m,selectedSessionId:g,onResidentSessionSelect:x,hasProject:v=!0,projects:_,onSelectProject:y,onCreateProjectOpen:b,schedules:w,selectedScheduleId:S,onScheduleSelect:C,onCreateScheduleOpen:j}){let k=(0,$.useRef)(null);return(0,$.useEffect)(()=>{k.current?.scrollIntoView({block:"nearest"})},[a?.id,_]),(0,z.jsxs)("nav",{className:"w-[220px] border-r border-border bg-sidebar flex flex-col overflow-hidden",children:[(0,z.jsxs)(lx,{children:[(0,z.jsx)(lv,{action:(0,z.jsx)("button",{onClick:b,className:"p-0.5 rounded hover:bg-muted hover:text-foreground transition-colors text-muted-foreground",title:"Create new project",children:(0,z.jsx)(eS,{className:"h-3 w-3"})}),children:"Projects"}),_&&_.length>0?(0,z.jsx)(ls,{delayDuration:300,children:(0,z.jsx)("div",{className:"flex flex-col gap-0.5 max-h-40 overflow-y-auto mt-0.5",children:_.map(s=>{let i=a?.id===s.id,n=i&&"project-info"===e;return(0,z.jsxs)(li,{children:[(0,z.jsx)(ln,{asChild:!0,children:(0,z.jsxs)("button",{ref:i?k:void 0,onClick:()=>{y?.(s),r("project-info")},className:(0,ey.cn)("relative w-full flex items-center gap-[9px] rounded-md px-2 py-[5px] text-[12.5px] transition-colors min-w-0","hover:bg-muted hover:text-foreground",i?"text-foreground font-medium":"text-foreground/75"),children:[n&&(0,z.jsx)("span",{className:"absolute -left-2 top-1.5 bottom-1.5 w-[2px] rounded-full bg-primary"}),(0,z.jsx)(lg,{project:s}),(0,z.jsx)("span",{className:"truncate flex-1 text-left",children:s.name}),i&&(0,z.jsx)(r_,{className:"h-3 w-3 shrink-0 text-muted-foreground ml-auto"})]})}),(0,z.jsx)(la,{side:"right",children:s.name})]},s.id)})})}):(0,z.jsx)("span",{className:"block px-2 mt-1 text-[11.5px] text-muted-foreground/60",children:"No projects yet"})]}),(0,z.jsxs)(lx,{children:[(0,z.jsx)(lv,{children:"Navigation"}),(0,z.jsx)("div",{className:"flex flex-col gap-0.5 mt-0.5",children:(0,z.jsx)(l_,{icon:(0,z.jsx)(oP,{className:"h-3.5 w-3.5"}),label:"Tasks",active:"tasks"===e&&v,disabled:!v,onClick:()=>{v&&(n?.(null),r("tasks"))}})})]}),(0,z.jsxs)(lx,{children:[(0,z.jsx)(lv,{action:a?(0,z.jsx)("button",{onClick:j,className:"p-0.5 rounded hover:bg-muted hover:text-foreground transition-colors text-muted-foreground",title:"Create scheduled task",children:(0,z.jsx)(eS,{className:"h-3 w-3"})}):void 0,children:"Schedule"}),a&&w&&w.length>0&&(0,z.jsx)("div",{className:"flex flex-col gap-px",children:w.map(r=>{let s="schedules"===e&&S===r.id;return(0,z.jsxs)("button",{onClick:()=>C?.(r.id),className:(0,ey.cn)("w-full min-w-0 flex items-center gap-2 rounded-[5px] px-2 py-1 text-[11.5px] transition-colors overflow-hidden",!s&&"text-foreground/80 hover:bg-muted",s&&"bg-accent text-accent-foreground font-medium",!r.enabled&&"opacity-50"),children:[(0,z.jsx)(lm,{schedule:r}),(0,z.jsx)("span",{className:"truncate text-left flex-1",children:r.name}),"local"!==r.target&&(0,z.jsx)(ry,{className:"h-2.5 w-2.5 shrink-0 text-violet-500","aria-label":"remote"})]},r.id)})}),a&&w&&0===w.length&&(0,z.jsx)("span",{className:"block px-2 mt-1 text-[11.5px] text-muted-foreground/60",children:"No scheduled tasks"})]}),(0,z.jsxs)(lx,{className:"flex-1 overflow-y-auto",children:[(0,z.jsx)(lv,{action:a?(0,z.jsx)("button",{onClick:o,className:"p-0.5 rounded hover:bg-muted hover:text-foreground transition-colors text-muted-foreground",title:"Create new worktree",children:(0,z.jsx)(eS,{className:"h-3 w-3"})}):void 0,children:"Workspace"}),a&&s&&s.length>0&&(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(ls,{delayDuration:300,children:(0,z.jsx)("div",{className:"flex flex-col gap-px",children:s.map(s=>{var o;let v="workspace"===e&&i===s.branch,_=null===s.branch?"":s.branch,y=m?.get(_)??[],b=(o=p?.get(_),y.length>0&&"main-running"!==o&&"main-completed"!==o?"idle":o);return(0,z.jsxs)("div",{className:(0,ey.cn)("min-w-0 rounded-[3px]",v&&"bg-accent"),children:[(0,z.jsxs)("div",{className:"group relative flex items-center min-w-0 gap-0.5 pr-1",children:[(0,z.jsxs)(li,{children:[(0,z.jsx)(ln,{asChild:!0,children:(0,z.jsxs)("button",{onClick:()=>{n?.(s.branch),r("workspace")},className:(0,ey.cn)("flex-1 min-w-0 flex items-center gap-2 rounded-[3px] pl-2 pr-1 py-1 font-mono text-[11.5px] transition-colors overflow-hidden",!v&&"text-foreground/80 hover:bg-muted",v&&"text-accent-foreground font-medium"),children:[(0,z.jsx)(lf,{status:b}),(0,z.jsx)("span",{className:"truncate text-left",children:s.branch??"main"})]})}),(0,z.jsx)(la,{side:"right",children:s.branch??"main"})]}),null!==s.branch&&c?.get(s.branch)&&(0,z.jsx)(lc,{info:c.get(s.branch),repositoryLabel:u,onClick:()=>f?.(s.branch)}),null!==s.branch&&a&&(0,z.jsx)(lh,{projectId:a.id,branch:s.branch,currentTarget:oN(c?.get(s.branch))??d??null,onTargetChange:e=>h?.(s.branch,e),onTargetReset:()=>h?.(s.branch,null),onDelete:()=>l?.(s)})]}),y.length>0&&(0,z.jsx)("div",{className:"ml-4 mt-px flex flex-col gap-px",children:y.map(r=>{let s="workspace"===e&&g===r.id;return(0,z.jsxs)(li,{children:[(0,z.jsx)(ln,{asChild:!0,children:(0,z.jsxs)("button",{onClick:()=>x?.(r),className:(0,ey.cn)("min-w-0 flex items-center gap-1.5 rounded-[3px] py-0.5 pl-1.5 pr-2 font-mono text-[11px] transition-colors",!s&&"text-foreground/70 hover:text-foreground",s&&"text-accent-foreground font-medium"),children:[(0,z.jsx)("span",{className:"shrink-0 text-muted-foreground/70",children:"└"}),(0,z.jsx)(lp,{status:r.status}),(0,z.jsx)("span",{className:"truncate text-left",children:r.title})]})}),(0,z.jsx)(la,{side:"right",children:r.title})]},r.id)})})]},s.branch??"__main__")})})})}),(!s||0===s.length)&&(0,z.jsx)("div",{className:"mt-0.5",children:(0,z.jsx)(l_,{icon:(0,z.jsx)(oT,{className:"h-3.5 w-3.5"}),label:"Workspace",active:"workspace"===e,onClick:()=>r("workspace")})})]}),(0,z.jsx)(lx,{children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)(l_,{icon:(0,z.jsx)(ry,{className:"h-3.5 w-3.5"}),label:"Remote Servers",active:"remote-servers"===e,onClick:()=>r("remote-servers")}),(0,z.jsx)(l_,{icon:(0,z.jsx)(oB,{className:"h-3.5 w-3.5"}),label:"Settings",active:"settings"===e,onClick:()=>r("settings")})]})})]})}function lb({title:e,count:r,description:s,actions:i,className:n}){return(0,z.jsxs)("div",{className:(0,ey.cn)("flex items-center justify-between gap-4 px-5 pt-[14px] pb-3 border-b border-border bg-background flex-shrink-0",n),children:[(0,z.jsxs)("div",{className:"min-w-0",children:[(0,z.jsxs)("h1",{className:"flex items-baseline gap-2.5 m-0 text-[17px] font-semibold tracking-[-0.018em] text-foreground",children:[(0,z.jsx)("span",{className:"truncate",children:e}),void 0!==r&&(0,z.jsx)("span",{className:"font-mono text-[11.5px] font-medium text-muted-foreground/80 tracking-normal",children:r})]}),s&&(0,z.jsx)("p",{className:"text-[11.5px] text-muted-foreground mt-0.5",children:s})]}),i&&(0,z.jsx)("div",{className:"flex items-center gap-2",children:i})]})}function lw({children:e,className:r}){return(0,z.jsx)("div",{className:(0,ey.cn)("flex items-center gap-1.5 px-5 py-2 border-b border-border bg-background flex-shrink-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",r),children:e})}function lS({active:e,count:r,onClick:s,children:i}){return(0,z.jsxs)("button",{onClick:s,className:(0,ey.cn)("inline-flex items-center gap-1.5 px-2.5 py-[3px] rounded-full text-[11.5px] font-normal transition-colors whitespace-nowrap flex-shrink-0 border",e?"bg-card text-foreground font-medium border-border shadow-sm":"bg-transparent text-muted-foreground border-transparent hover:bg-muted hover:text-foreground"),children:[i,void 0!==r&&(0,z.jsx)("span",{className:(0,ey.cn)("font-mono text-[10.5px] pl-0.5",e?"text-muted-foreground":"text-muted-foreground/70"),children:r})]})}var lC="AlertDialog",[lj,lk]=K(lC,[tR]),lN=tR(),lE=e=>{let{__scopeAlertDialog:r,...s}=e,i=lN(r);return(0,z.jsx)(tF,{...i,...s,modal:!0})};lE.displayName=lC,$.forwardRef((e,r)=>{let{__scopeAlertDialog:s,...i}=e,n=lN(s);return(0,z.jsx)(tP,{...n,...i,ref:r})}).displayName="AlertDialogTrigger";var lD=e=>{let{__scopeAlertDialog:r,...s}=e,i=lN(r);return(0,z.jsx)(tO,{...i,...s})};lD.displayName="AlertDialogPortal";var lR=$.forwardRef((e,r)=>{let{__scopeAlertDialog:s,...i}=e,n=lN(s);return(0,z.jsx)(t$,{...n,...i,ref:r})});lR.displayName="AlertDialogOverlay";var lA="AlertDialogContent",[lM,lF]=lj(lA),lT=(0,et.createSlottable)("AlertDialogContent"),lP=$.forwardRef((e,r)=>{let{__scopeAlertDialog:s,children:i,...n}=e,a=lN(s),o=$.useRef(null),l=(0,U.useComposedRefs)(r,o),c=$.useRef(null);return(0,z.jsx)(t5,{contentName:lA,titleName:lB,docsSlug:"alert-dialog",children:(0,z.jsx)(lM,{scope:s,cancelRef:c,children:(0,z.jsxs)(tK,{role:"alertdialog",...a,...n,ref:l,onOpenAutoFocus:q(n.onOpenAutoFocus,e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,z.jsx)(lT,{children:i}),(0,z.jsx)(lH,{contentRef:o})]})})})});lP.displayName=lA;var lB="AlertDialogTitle",lL=$.forwardRef((e,r)=>{let{__scopeAlertDialog:s,...i}=e,n=lN(s);return(0,z.jsx)(tX,{...n,...i,ref:r})});lL.displayName=lB;var lI="AlertDialogDescription",lO=$.forwardRef((e,r)=>{let{__scopeAlertDialog:s,...i}=e,n=lN(s);return(0,z.jsx)(tZ,{...n,...i,ref:r})});lO.displayName=lI;var lz=$.forwardRef((e,r)=>{let{__scopeAlertDialog:s,...i}=e,n=lN(s);return(0,z.jsx)(t0,{...n,...i,ref:r})});lz.displayName="AlertDialogAction";var l$="AlertDialogCancel",lW=$.forwardRef((e,r)=>{let{__scopeAlertDialog:s,...i}=e,{cancelRef:n}=lF(l$,s),a=lN(s),o=(0,U.useComposedRefs)(r,n);return(0,z.jsx)(t0,{...a,...i,ref:o})});lW.displayName=l$;var lH=({contentRef:e})=>{let r=`\`${lA}\` requires a description for the component to be accessible for screen reader users.
|
|
6
|
+
|
|
7
|
+
You can add a description to the \`${lA}\` by passing a \`${lI}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
8
|
+
|
|
9
|
+
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${lA}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
10
|
+
|
|
11
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return $.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(r)},[r,e]),null};function lU({...e}){return(0,z.jsx)(lE,{"data-slot":"alert-dialog",...e})}function lK({...e}){return(0,z.jsx)(lD,{"data-slot":"alert-dialog-portal",...e})}function lq({className:e,...r}){return(0,z.jsx)(lR,{"data-slot":"alert-dialog-overlay",className:(0,ey.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...r})}function lV({className:e,...r}){return(0,z.jsxs)(lK,{children:[(0,z.jsx)(lq,{}),(0,z.jsx)(lP,{"data-slot":"alert-dialog-content",className:(0,ey.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r})]})}function lY({className:e,...r}){return(0,z.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,ey.cn)("flex flex-col gap-2 text-center sm:text-left",e),...r})}function lG({className:e,...r}){return(0,z.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,ey.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r})}function lX({className:e,...r}){return(0,z.jsx)(lL,{"data-slot":"alert-dialog-title",className:(0,ey.cn)("text-lg font-semibold",e),...r})}function lJ({className:e,...r}){return(0,z.jsx)(lO,{"data-slot":"alert-dialog-description",className:(0,ey.cn)("text-muted-foreground text-sm",e),...r})}function lZ({className:e,...r}){return(0,z.jsx)(lz,{className:(0,ey.cn)((0,W.buttonVariants)(),e),...r})}function lQ({className:e,...r}){return(0,z.jsx)(lW,{className:(0,ey.cn)((0,W.buttonVariants)({variant:"outline"}),e),...r})}function l0({className:e,...r}){return(0,z.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,z.jsx)("table",{"data-slot":"table",className:(0,ey.cn)("w-full caption-bottom text-sm",e),...r})})}function l1({className:e,...r}){return(0,z.jsx)("thead",{"data-slot":"table-header",className:(0,ey.cn)("[&_tr]:border-b",e),...r})}function l2({className:e,...r}){return(0,z.jsx)("tbody",{"data-slot":"table-body",className:(0,ey.cn)("[&_tr:last-child]:border-0",e),...r})}function l5({className:e,...r}){return(0,z.jsx)("tr",{"data-slot":"table-row",className:(0,ey.cn)("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...r})}function l3({className:e,...r}){return(0,z.jsx)("th",{"data-slot":"table-head",className:(0,ey.cn)("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}function l4({className:e,...r}){return(0,z.jsx)("td",{"data-slot":"table-cell",className:(0,ey.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}var l6=[" ","Enter","ArrowUp","ArrowDown"],l8=[" ","Enter"],l7="Select",[l9,ce,ct]=rA(l7),[cr,cs]=K(l7,[ct,i$]),ci=i$(),[cn,ca]=cr(l7),[co,cl]=cr(l7),cc=e=>{let{__scopeSelect:r,children:s,open:i,defaultOpen:n,onOpenChange:a,value:o,defaultValue:l,onValueChange:c,dir:d,name:u,autoComplete:h,disabled:f,required:p,form:m}=e,g=ci(r),[x,v]=$.useState(null),[_,y]=$.useState(null),[b,w]=$.useState(!1),S=rB(d),[C,j]=G({prop:i,defaultProp:n??!1,onChange:a,caller:l7}),[k,N]=G({prop:o,defaultProp:l,onChange:c,caller:l7}),E=$.useRef(null),D=!x||m||!!x.closest("form"),[R,A]=$.useState(new Set),M=Array.from(R).map(e=>e.props.value).join(";");return(0,z.jsx)(iU,{...g,children:(0,z.jsxs)(cn,{required:p,scope:r,trigger:x,onTriggerChange:v,valueNode:_,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:w,contentId:ek(),value:k,onValueChange:N,open:C,onOpenChange:j,dir:S,triggerPointerDownPosRef:E,disabled:f,children:[(0,z.jsx)(l9.Provider,{scope:r,children:(0,z.jsx)(co,{scope:e.__scopeSelect,onNativeOptionAdd:$.useCallback(e=>{A(r=>new Set(r).add(e))},[]),onNativeOptionRemove:$.useCallback(e=>{A(r=>{let s=new Set(r);return s.delete(e),s})},[]),children:s})}),D?(0,z.jsxs)(cq,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:h,value:k,onChange:e=>N(e.target.value),disabled:f,form:m,children:[void 0===k?(0,z.jsx)("option",{value:""}):null,Array.from(R)]},M):null]})})};cc.displayName=l7;var cd="SelectTrigger",cu=$.forwardRef((e,r)=>{let{__scopeSelect:s,disabled:i=!1,...n}=e,a=ci(s),o=ca(cd,s),l=o.disabled||i,c=(0,U.useComposedRefs)(r,o.onTriggerChange),d=ce(s),u=$.useRef("touch"),[h,f,p]=cY(e=>{let r=d().filter(e=>!e.disabled),s=r.find(e=>e.value===o.value),i=cG(r,e,s);void 0!==i&&o.onValueChange(i.value)}),m=e=>{l||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,z.jsx)(iq,{asChild:!0,...a,children:(0,z.jsx)(er.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":cV(o.value)?"":void 0,...n,ref:c,onClick:q(n.onClick,e=>{e.currentTarget.focus(),"mouse"!==u.current&&m(e)}),onPointerDown:q(n.onPointerDown,e=>{u.current=e.pointerType;let r=e.target;r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(m(e),e.preventDefault())}),onKeyDown:q(n.onKeyDown,e=>{let r=""!==h.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||f(e.key),(!r||" "!==e.key)&&l6.includes(e.key)&&(m(),e.preventDefault())})})})});cu.displayName=cd;var ch="SelectValue",cf=$.forwardRef((e,r)=>{let{__scopeSelect:s,className:i,style:n,children:a,placeholder:o="",...l}=e,c=ca(ch,s),{onValueNodeHasChildrenChange:d}=c,u=void 0!==a,h=(0,U.useComposedRefs)(r,c.onValueNodeChange);return V(()=>{d(u)},[d,u]),(0,z.jsx)(er.span,{...l,ref:h,style:{pointerEvents:"none"},children:cV(c.value)?(0,z.jsx)(z.Fragment,{children:o}):a})});cf.displayName=ch;var cp=$.forwardRef((e,r)=>{let{__scopeSelect:s,children:i,...n}=e;return(0,z.jsx)(er.span,{"aria-hidden":!0,...n,ref:r,children:i||"▼"})});cp.displayName="SelectIcon";var cm=e=>(0,z.jsx)(eW,{asChild:!0,...e});cm.displayName="SelectPortal";var cg="SelectContent",cx=$.forwardRef((e,r)=>{let s=ca(cg,e.__scopeSelect),[i,n]=$.useState();return(V(()=>{n(new DocumentFragment)},[]),s.open)?(0,z.jsx)(cb,{...e,ref:r}):i?ee.createPortal((0,z.jsx)(cv,{scope:e.__scopeSelect,children:(0,z.jsx)(l9.Slot,{scope:e.__scopeSelect,children:(0,z.jsx)("div",{children:e.children})})}),i):null});cx.displayName=cg;var[cv,c_]=cr(cg),cy=(0,et.createSlot)("SelectContent.RemoveScroll"),cb=$.forwardRef((e,r)=>{let{__scopeSelect:s,position:i="item-aligned",onCloseAutoFocus:n,onEscapeKeyDown:a,onPointerDownOutside:o,side:l,sideOffset:c,align:d,alignOffset:u,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:x,...v}=e,_=ca(cg,s),[y,b]=$.useState(null),[w,S]=$.useState(null),C=(0,U.useComposedRefs)(r,e=>b(e)),[j,k]=$.useState(null),[N,E]=$.useState(null),D=ce(s),[R,A]=$.useState(!1),M=$.useRef(!1);$.useEffect(()=>{if(y)return tN(y)},[y]),eU();let F=$.useCallback(e=>{let[r,...s]=D().map(e=>e.ref.current),[i]=s.slice(-1),n=document.activeElement;for(let s of e)if(s===n||(s?.scrollIntoView({block:"nearest"}),s===r&&w&&(w.scrollTop=0),s===i&&w&&(w.scrollTop=w.scrollHeight),s?.focus(),document.activeElement!==n))return},[D,w]),T=$.useCallback(()=>F([j,y]),[F,j,y]);$.useEffect(()=>{R&&T()},[R,T]);let{onOpenChange:P,triggerPointerDownPosRef:B}=_;$.useEffect(()=>{if(y){let e={x:0,y:0},r=r=>{e={x:Math.abs(Math.round(r.pageX)-(B.current?.x??0)),y:Math.abs(Math.round(r.pageY)-(B.current?.y??0))}},s=s=>{e.x<=10&&e.y<=10?s.preventDefault():y.contains(s.target)||P(!1),document.removeEventListener("pointermove",r),B.current=null};return null!==B.current&&(document.addEventListener("pointermove",r),document.addEventListener("pointerup",s,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",s,{capture:!0})}}},[y,P,B]),$.useEffect(()=>{let e=()=>P(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[P]);let[L,I]=cY(e=>{let r=D().filter(e=>!e.disabled),s=r.find(e=>e.ref.current===document.activeElement),i=cG(r,e,s);i&&setTimeout(()=>i.ref.current.focus())}),O=$.useCallback((e,r,s)=>{let i=!M.current&&!s;(void 0!==_.value&&_.value===r||i)&&(k(e),i&&(M.current=!0))},[_.value]),W=$.useCallback(()=>y?.focus(),[y]),H=$.useCallback((e,r,s)=>{let i=!M.current&&!s;(void 0!==_.value&&_.value===r||i)&&E(e)},[_.value]),K="popper"===i?cS:cw,V=K===cS?{side:l,sideOffset:c,align:d,alignOffset:u,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:x}:{};return(0,z.jsx)(cv,{scope:s,content:y,viewport:w,onViewportChange:S,itemRefCallback:O,selectedItem:j,onItemLeave:W,itemTextRefCallback:H,focusSelectedItem:T,selectedItemText:N,position:i,isPositioned:R,searchRef:L,children:(0,z.jsx)(ty,{as:cy,allowPinchZoom:!0,children:(0,z.jsx)(eB,{asChild:!0,trapped:_.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:q(n,e=>{_.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,z.jsx)(eR,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>_.onOpenChange(!1),children:(0,z.jsx)(K,{role:"listbox",id:_.contentId,"data-state":_.open?"open":"closed",dir:_.dir,onContextMenu:e=>e.preventDefault(),...v,...V,onPlaced:()=>A(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:q(v.onKeyDown,e=>{let r=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),r||1!==e.key.length||I(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let r=D().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(r=r.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){let s=e.target,i=r.indexOf(s);r=r.slice(i+1)}setTimeout(()=>F(r)),e.preventDefault()}})})})})})})});cb.displayName="SelectContentImpl";var cw=$.forwardRef((e,r)=>{let{__scopeSelect:s,onPlaced:i,...n}=e,a=ca(cg,s),o=c_(cg,s),[l,c]=$.useState(null),[d,u]=$.useState(null),h=(0,U.useComposedRefs)(r,e=>u(e)),f=ce(s),p=$.useRef(!1),m=$.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:v,focusSelectedItem:_}=o,y=$.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&d&&g&&x&&v){let e=a.trigger.getBoundingClientRect(),r=d.getBoundingClientRect(),s=a.valueNode.getBoundingClientRect(),n=v.getBoundingClientRect();if("rtl"!==a.dir){let i=n.left-r.left,a=s.left-i,o=e.left-a,c=e.width+o,d=Math.max(c,r.width),u=aM(a,[10,Math.max(10,window.innerWidth-10-d)]);l.style.minWidth=c+"px",l.style.left=u+"px"}else{let i=r.right-n.right,a=window.innerWidth-s.right-i,o=window.innerWidth-e.right-a,c=e.width+o,d=Math.max(c,r.width),u=aM(a,[10,Math.max(10,window.innerWidth-10-d)]);l.style.minWidth=c+"px",l.style.right=u+"px"}let o=f(),c=window.innerHeight-20,u=g.scrollHeight,h=window.getComputedStyle(d),m=parseInt(h.borderTopWidth,10),_=parseInt(h.paddingTop,10),y=parseInt(h.borderBottomWidth,10),b=m+_+u+parseInt(h.paddingBottom,10)+y,w=Math.min(5*x.offsetHeight,b),S=window.getComputedStyle(g),C=parseInt(S.paddingTop,10),j=parseInt(S.paddingBottom,10),k=e.top+e.height/2-10,N=x.offsetHeight/2,E=m+_+(x.offsetTop+N);if(E<=k){let e=o.length>0&&x===o[o.length-1].ref.current;l.style.bottom="0px";let r=Math.max(c-k,N+(e?j:0)+(d.clientHeight-g.offsetTop-g.offsetHeight)+y);l.style.height=E+r+"px"}else{let e=o.length>0&&x===o[0].ref.current;l.style.top="0px";let r=Math.max(k,m+g.offsetTop+(e?C:0)+N);l.style.height=r+(b-E)+"px",g.scrollTop=E-k+g.offsetTop}l.style.margin="10px 0",l.style.minHeight=w+"px",l.style.maxHeight=c+"px",i?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,l,d,g,x,v,a.dir,i]);V(()=>y(),[y]);let[b,w]=$.useState();V(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]);let S=$.useCallback(e=>{e&&!0===m.current&&(y(),_?.(),m.current=!1)},[y,_]);return(0,z.jsx)(cC,{scope:s,contentWrapper:l,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:(0,z.jsx)("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:b},children:(0,z.jsx)(er.div,{...n,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...n.style}})})})});cw.displayName="SelectItemAlignedPosition";var cS=$.forwardRef((e,r)=>{let{__scopeSelect:s,align:i="start",collisionPadding:n=10,...a}=e,o=ci(s);return(0,z.jsx)(iX,{...o,...a,ref:r,align:i,collisionPadding:n,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});cS.displayName="SelectPopperPosition";var[cC,cj]=cr(cg,{}),ck="SelectViewport",cN=$.forwardRef((e,r)=>{let{__scopeSelect:s,nonce:i,...n}=e,a=c_(ck,s),o=cj(ck,s),l=(0,U.useComposedRefs)(r,a.onViewportChange),c=$.useRef(0);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),(0,z.jsx)(l9.Slot,{scope:s,children:(0,z.jsx)(er.div,{"data-radix-select-viewport":"",role:"presentation",...n,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...n.style},onScroll:q(n.onScroll,e=>{let r=e.currentTarget,{contentWrapper:s,shouldExpandOnScrollRef:i}=o;if(i?.current&&s){let e=Math.abs(c.current-r.scrollTop);if(e>0){let i=window.innerHeight-20,n=Math.max(parseFloat(s.style.minHeight),parseFloat(s.style.height));if(n<i){let a=n+e,o=Math.min(i,a),l=a-o;s.style.height=o+"px","0px"===s.style.bottom&&(r.scrollTop=l>0?l:0,s.style.justifyContent="flex-end")}}}c.current=r.scrollTop})})})]})});cN.displayName=ck;var cE="SelectGroup",[cD,cR]=cr(cE);$.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e,n=ek();return(0,z.jsx)(cD,{scope:s,id:n,children:(0,z.jsx)(er.div,{role:"group","aria-labelledby":n,...i,ref:r})})}).displayName=cE;var cA="SelectLabel";$.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e,n=cR(cA,s);return(0,z.jsx)(er.div,{id:n.id,...i,ref:r})}).displayName=cA;var cM="SelectItem",[cF,cT]=cr(cM),cP=$.forwardRef((e,r)=>{let{__scopeSelect:s,value:i,disabled:n=!1,textValue:a,...o}=e,l=ca(cM,s),c=c_(cM,s),d=l.value===i,[u,h]=$.useState(a??""),[f,p]=$.useState(!1),m=(0,U.useComposedRefs)(r,e=>c.itemRefCallback?.(e,i,n)),g=ek(),x=$.useRef("touch"),v=()=>{n||(l.onValueChange(i),l.onOpenChange(!1))};if(""===i)throw Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return(0,z.jsx)(cF,{scope:s,value:i,disabled:n,textId:g,isSelected:d,onItemTextChange:$.useCallback(e=>{h(r=>r||(e?.textContent??"").trim())},[]),children:(0,z.jsx)(l9.ItemSlot,{scope:s,value:i,disabled:n,textValue:u,children:(0,z.jsx)(er.div,{role:"option","aria-labelledby":g,"data-highlighted":f?"":void 0,"aria-selected":d&&f,"data-state":d?"checked":"unchecked","aria-disabled":n||void 0,"data-disabled":n?"":void 0,tabIndex:n?void 0:-1,...o,ref:m,onFocus:q(o.onFocus,()=>p(!0)),onBlur:q(o.onBlur,()=>p(!1)),onClick:q(o.onClick,()=>{"mouse"!==x.current&&v()}),onPointerUp:q(o.onPointerUp,()=>{"mouse"===x.current&&v()}),onPointerDown:q(o.onPointerDown,e=>{x.current=e.pointerType}),onPointerMove:q(o.onPointerMove,e=>{x.current=e.pointerType,n?c.onItemLeave?.():"mouse"===x.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:q(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:q(o.onKeyDown,e=>{(c.searchRef?.current===""||" "!==e.key)&&(l8.includes(e.key)&&v()," "===e.key&&e.preventDefault())})})})})});cP.displayName=cM;var cB="SelectItemText",cL=$.forwardRef((e,r)=>{let{__scopeSelect:s,className:i,style:n,...a}=e,o=ca(cB,s),l=c_(cB,s),c=cT(cB,s),d=cl(cB,s),[u,h]=$.useState(null),f=(0,U.useComposedRefs)(r,e=>h(e),c.onItemTextChange,e=>l.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=$.useMemo(()=>(0,z.jsx)("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=d;return V(()=>(g(m),()=>x(m)),[g,x,m]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(er.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?ee.createPortal(a.children,o.valueNode):null]})});cL.displayName=cB;var cI="SelectItemIndicator",cO=$.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e;return cT(cI,s).isSelected?(0,z.jsx)(er.span,{"aria-hidden":!0,...i,ref:r}):null});cO.displayName=cI;var cz="SelectScrollUpButton",c$=$.forwardRef((e,r)=>{let s=c_(cz,e.__scopeSelect),i=cj(cz,e.__scopeSelect),[n,a]=$.useState(!1),o=(0,U.useComposedRefs)(r,i.onScrollButtonChange);return V(()=>{if(s.viewport&&s.isPositioned){let e=function(){a(r.scrollTop>0)},r=s.viewport;return e(),r.addEventListener("scroll",e),()=>r.removeEventListener("scroll",e)}},[s.viewport,s.isPositioned]),n?(0,z.jsx)(cU,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:r}=s;e&&r&&(e.scrollTop=e.scrollTop-r.offsetHeight)}}):null});c$.displayName=cz;var cW="SelectScrollDownButton",cH=$.forwardRef((e,r)=>{let s=c_(cW,e.__scopeSelect),i=cj(cW,e.__scopeSelect),[n,a]=$.useState(!1),o=(0,U.useComposedRefs)(r,i.onScrollButtonChange);return V(()=>{if(s.viewport&&s.isPositioned){let e=function(){let e=r.scrollHeight-r.clientHeight;a(Math.ceil(r.scrollTop)<e)},r=s.viewport;return e(),r.addEventListener("scroll",e),()=>r.removeEventListener("scroll",e)}},[s.viewport,s.isPositioned]),n?(0,z.jsx)(cU,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:r}=s;e&&r&&(e.scrollTop=e.scrollTop+r.offsetHeight)}}):null});cH.displayName=cW;var cU=$.forwardRef((e,r)=>{let{__scopeSelect:s,onAutoScroll:i,...n}=e,a=c_("SelectScrollButton",s),o=$.useRef(null),l=ce(s),c=$.useCallback(()=>{null!==o.current&&(window.clearInterval(o.current),o.current=null)},[]);return $.useEffect(()=>()=>c(),[c]),V(()=>{let e=l().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[l]),(0,z.jsx)(er.div,{"aria-hidden":!0,...n,ref:r,style:{flexShrink:0,...n.style},onPointerDown:q(n.onPointerDown,()=>{null===o.current&&(o.current=window.setInterval(i,50))}),onPointerMove:q(n.onPointerMove,()=>{a.onItemLeave?.(),null===o.current&&(o.current=window.setInterval(i,50))}),onPointerLeave:q(n.onPointerLeave,()=>{c()})})});$.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e;return(0,z.jsx)(er.div,{"aria-hidden":!0,...i,ref:r})}).displayName="SelectSeparator";var cK="SelectArrow";$.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e,n=ci(s),a=ca(cK,s),o=c_(cK,s);return a.open&&"popper"===o.position?(0,z.jsx)(iQ,{...n,...i,ref:r}):null}).displayName=cK;var cq=$.forwardRef(({__scopeSelect:e,value:r,...s},i)=>{let n=$.useRef(null),a=(0,U.useComposedRefs)(i,n),o=X(r);return $.useEffect(()=>{let e=n.current;if(!e)return;let s=Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype,"value").set;if(o!==r&&s){let i=new Event("change",{bubbles:!0});s.call(e,r),e.dispatchEvent(i)}},[o,r]),(0,z.jsx)(er.select,{...s,style:{...oL,...s.style},ref:a,defaultValue:r})});function cV(e){return""===e||void 0===e}function cY(e){let r=eN(e),s=$.useRef(""),i=$.useRef(0),n=$.useCallback(e=>{let n=s.current+e;r(n),function e(r){s.current=r,window.clearTimeout(i.current),""!==r&&(i.current=window.setTimeout(()=>e(""),1e3))}(n)},[r]),a=$.useCallback(()=>{s.current="",window.clearTimeout(i.current)},[]);return $.useEffect(()=>()=>window.clearTimeout(i.current),[]),[s,n,a]}function cG(e,r,s){var i,n;let a=r.length>1&&Array.from(r).every(e=>e===r[0])?r[0]:r,o=s?e.indexOf(s):-1,l=(i=e,n=Math.max(o,0),i.map((e,r)=>i[(n+r)%i.length]));1===a.length&&(l=l.filter(e=>e!==s));let c=l.find(e=>e.textValue.toLowerCase().startsWith(a.toLowerCase()));return c!==s?c:void 0}cq.displayName="SelectBubbleInput";var H=H;function cX({...e}){return(0,z.jsx)(cc,{"data-slot":"select",...e})}function cJ({...e}){return(0,z.jsx)(cf,{"data-slot":"select-value",...e})}function cZ({className:e,size:r="default",children:s,...i}){return(0,z.jsxs)(cu,{"data-slot":"select-trigger","data-size":r,className:(0,ey.cn)("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...i,children:[s,(0,z.jsx)(cp,{asChild:!0,children:(0,z.jsx)(sw,{className:"size-4 opacity-50"})})]})}function cQ({className:e,children:r,position:s="item-aligned",align:i="center",...n}){return(0,z.jsx)(cm,{children:(0,z.jsxs)(cx,{"data-slot":"select-content",className:(0,ey.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,align:i,...n,children:[(0,z.jsx)(c1,{}),(0,z.jsx)(cN,{className:(0,ey.cn)("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),(0,z.jsx)(c2,{})]})})}function c0({className:e,children:r,...s}){return(0,z.jsxs)(cP,{"data-slot":"select-item",className:(0,ey.cn)("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...s,children:[(0,z.jsx)("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,z.jsx)(cO,{children:(0,z.jsx)(H.default,{className:"size-4"})})}),(0,z.jsx)(cL,{children:r})]})}function c1({className:e,...r}){return(0,z.jsx)(c$,{"data-slot":"select-scroll-up-button",className:(0,ey.cn)("flex cursor-default items-center justify-center py-1",e),...r,children:(0,z.jsx)(oa,{className:"size-4"})})}function c2({className:e,...r}){return(0,z.jsx)(cH,{"data-slot":"select-scroll-down-button",className:(0,ey.cn)("flex cursor-default items-center justify-center py-1",e),...r,children:(0,z.jsx)(sw,{className:"size-4"})})}let c5="__main__";function c3({open:e,onOpenChange:r,onSubmit:s,initial:i,worktrees:n,projectId:a}){let[o,l]=(0,$.useState)(""),[c,d]=(0,$.useState)("0 9 * * *"),[u,h]=(0,$.useState)(""),[f,p]=(0,$.useState)("local"),[m,g]=(0,$.useState)([]),[x,v]=(0,$.useState)("command"),[_,y]=(0,$.useState)("claude"),[b,w]=(0,$.useState)(""),[S,C]=(0,$.useState)("branch"),[j,k]=(0,$.useState)(c5),[N,E]=(0,$.useState)(n),[D,R]=(0,$.useState)(""),[A,M]=(0,$.useState)("30"),[F,T]=(0,$.useState)(!1),[P,B]=(0,$.useState)(null);(0,$.useEffect)(()=>{e&&(B(null),l(i?.name??""),d(i?.cron_expr??"0 9 * * *"),h(i?.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone),p(i?.target??"local"),v(i?.run_type??"command"),y(i?.prompt_provider??"claude"),w(i?.content??""),C(i?.cwd_mode??"branch"),k(i?.branch??c5),R(i?.directory??""),M(String(Math.round((i?.timeout_seconds??1800)/60))))},[e,i]),(0,$.useEffect)(()=>{"local"===f&&E(n)},[f,n]),(0,$.useEffect)(()=>{let r=!1;return e&&a&&rv.api.getProjectRemotes(a).then(e=>{r||g(e)}).catch(e=>console.error("Failed to load project remotes:",e)),()=>{r=!0}},[e,a]),(0,$.useEffect)(()=>{let r=!1;if(e&&a&&"local"!==f)return rv.api.getProjectWorktrees(a,f).then(e=>{r||E(e)}).catch(e=>{console.error("Failed to load target worktrees:",e),r||E([{branch:null}])}),()=>{r=!0}},[e,a,f]);let L=async()=>{if(!o.trim()||!b.trim())return void B("Name and content are required");let e=parseInt(A,10);if(!Number.isInteger(e)||e<=0)return void B("Timeout must be a positive number of minutes");if("directory"===S&&!D.trim())return void B("Directory is required");T(!0),B(null);try{await s({name:o.trim(),cron_expr:c.trim(),timezone:u.trim()||"UTC",target:f,run_type:x,prompt_provider:"prompt"===x?_:null,content:b,cwd_mode:S,branch:"branch"===S?j===c5?null:j:null,directory:"directory"===S?D.trim():null,timeout_seconds:60*e}),r(!1)}catch(e){B(e instanceof Error?e.message:"Failed to save schedule")}finally{T(!1)}};return(0,z.jsx)(t7,{open:e,onOpenChange:r,children:(0,z.jsxs)(rr,{className:"max-w-lg",children:[(0,z.jsxs)(rs,{children:[(0,z.jsx)(rn,{children:i?"Edit Scheduled Task":"New Scheduled Task"}),(0,z.jsx)(ra,{children:"Run a command or a Claude prompt on a cron schedule"})]}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,z.jsx)(ro,{value:o,onChange:e=>l(e.target.value),placeholder:"Daily log analysis",disabled:F})]}),(0,z.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Cron"}),(0,z.jsx)(ro,{value:c,onChange:e=>d(e.target.value),placeholder:"0 9 * * *",className:"font-mono",disabled:F}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:"5-field cron — “0 9 * * *” = every day at 09:00"})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Timezone"}),(0,z.jsx)(ro,{value:u,onChange:e=>h(e.target.value),placeholder:"Asia/Shanghai",disabled:F})]})]}),(0,z.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Type"}),(0,z.jsxs)(cX,{value:x,onValueChange:e=>v(e),disabled:F,children:[(0,z.jsx)(cZ,{size:"sm",children:(0,z.jsx)(cJ,{})}),(0,z.jsxs)(cQ,{children:[(0,z.jsx)(c0,{value:"command",children:"Command (shell)"}),(0,z.jsx)(c0,{value:"prompt",children:"Prompt"})]})]})]}),"prompt"===x&&(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Agent"}),(0,z.jsxs)(cX,{value:_,onValueChange:e=>y(e),disabled:F,children:[(0,z.jsx)(cZ,{size:"sm",children:(0,z.jsx)(cJ,{})}),(0,z.jsxs)(cQ,{children:[(0,z.jsx)(c0,{value:"claude",children:"Claude"}),(0,z.jsx)(c0,{value:"codex",children:"Codex"})]})]})]})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"command"===x?"Command":"Prompt"}),(0,z.jsx)(rl,{value:b,onChange:e=>w(e.target.value),placeholder:"command"===x?"./scripts/scan.sh --daily":"Analyze today's server logs under ./logs and summarize anomalies",className:"font-mono text-sm min-h-[80px]",disabled:F})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Target"}),(0,z.jsxs)(cX,{value:f,onValueChange:e=>{p(e),k(c5)},disabled:F,children:[(0,z.jsx)(cZ,{size:"sm",children:(0,z.jsx)(cJ,{placeholder:"Local"})}),(0,z.jsxs)(cQ,{children:[(0,z.jsx)(c0,{value:"local",children:"Local"}),m.map(e=>(0,z.jsx)(c0,{value:e.remote_server_id,children:e.server_name??e.server_url??e.remote_server_id},e.remote_server_id))]})]})]}),(0,z.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Runs in"}),(0,z.jsxs)(cX,{value:S,onValueChange:e=>C(e),disabled:F,children:[(0,z.jsx)(cZ,{size:"sm",children:(0,z.jsx)(cJ,{})}),(0,z.jsxs)(cQ,{children:[(0,z.jsx)(c0,{value:"branch",children:"Workspace (branch)"}),(0,z.jsx)(c0,{value:"directory",children:"Directory"})]})]})]}),(0,z.jsx)("div",{className:"space-y-2",children:"branch"===S?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Workspace"}),(0,z.jsxs)(cX,{value:j,onValueChange:k,disabled:F,children:[(0,z.jsx)(cZ,{size:"sm",children:(0,z.jsx)(cJ,{placeholder:"Select workspace"})}),(0,z.jsx)(cQ,{children:N.map(e=>(0,z.jsx)(c0,{value:e.branch??c5,children:e.branch??"main"},e.branch??c5))})]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Directory"}),(0,z.jsx)(ro,{value:D,onChange:e=>R(e.target.value),placeholder:"/var/log/myapp",className:"font-mono",disabled:F})]})})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Timeout (minutes)"}),(0,z.jsx)(ro,{value:A,onChange:e=>M(e.target.value),className:"w-24",disabled:F})]}),P&&(0,z.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:P})]}),(0,z.jsxs)(ri,{children:[(0,z.jsx)(W.Button,{variant:"outline",onClick:()=>r(!1),disabled:F,children:"Cancel"}),(0,z.jsx)(W.Button,{onClick:L,disabled:F||!o.trim()||!b.trim(),children:F?"Saving...":i?"Save":"Create"})]})]})})}let c4={running:"bg-blue-500/15 text-blue-600",completed:"bg-emerald-500/15 text-emerald-600",failed:"bg-red-500/15 text-red-600",timeout:"bg-amber-500/15 text-amber-600",killed:"bg-amber-500/15 text-amber-600",skipped:"bg-muted text-muted-foreground"},c6=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;function c8(e){return e.replace(c6,"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")}function c7(e){return new Date(e.includes("T")?e:e.replace(" ","T")+"Z")}function c9(e){return e?c7(e).toLocaleString():"—"}function de({projectId:e,schedules:r,loading:s,selectedId:i,onSelect:n,worktrees:a,onCreate:o,onUpdate:l,onDelete:c,onRunNow:d,createOpen:u,onCreateOpenChange:h}){let f=r.find(e=>e.id===i)??r[0]??null,[p,m]=(0,$.useState)([]),[g,x]=(0,$.useState)(!1),[v,_]=(0,$.useState)(null),[y,b]=(0,$.useState)(null),[w,S]=(0,$.useState)(null),C=(0,$.useCallback)(async e=>{try{return await rv.api.getScheduleRuns(e)}catch(e){return console.error("Failed to fetch schedule runs:",e),null}},[]);(0,$.useEffect)(()=>{let e=f?.id,r=!1;return(e?C(e):Promise.resolve([])).then(e=>{r||m(e??[])}),()=>{r=!0}},[f?.id,r,C]);let j=async()=>{if(f){b(null);try{await d(f.id)}catch(e){b(e instanceof Error?e.message:"Failed to start run")}}},k=async e=>{if("skipped"!==e.status)try{_(await rv.api.getScheduleRun(e.id))}catch(e){console.error("Failed to fetch run output:",e)}};return s||0!==r.length?(0,z.jsxs)("div",{className:"flex flex-col h-full",children:[f&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(lb,{title:f.name,description:`${f.cron_expr} \xb7 ${f.timezone} \xb7 next: ${c9(f.next_run_at)}`,actions:(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsxs)(W.Button,{size:"sm",onClick:j,disabled:!!f.running,children:[(0,z.jsx)(rh,{className:"h-3.5 w-3.5 mr-1.5"}),f.running?"Running…":"Run now"]}),(0,z.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,z.jsx)("input",{type:"checkbox",checked:f.enabled,onChange:e=>void l(f.id,{enabled:e.target.checked}),className:"h-4 w-4 rounded border-input accent-primary"}),(0,z.jsx)("span",{children:"Enabled"})]}),(0,z.jsx)(W.Button,{size:"sm",variant:"outline",onClick:()=>x(!0),children:(0,z.jsx)(rg,{className:"h-3.5 w-3.5"})}),(0,z.jsx)(W.Button,{size:"sm",variant:"outline",onClick:()=>{f&&S(f)},className:"hover:bg-destructive/15 hover:text-destructive",children:(0,z.jsx)(rc,{className:"h-3.5 w-3.5"})})]})}),(0,z.jsxs)("div",{className:"px-5 py-3 grid grid-cols-2 gap-x-8 gap-y-1 text-sm border-b border-border/50",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("span",{className:"text-muted-foreground",children:"Type: "}),"command"===f.run_type?"Command":`Prompt (${"codex"===f.prompt_provider?"Codex":"Claude"})`]}),(0,z.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,z.jsx)("span",{className:"text-muted-foreground",children:"Runs in: "}),"branch"===f.cwd_mode?`workspace ${f.branch??"main"}`:f.directory,"local"!==f.target&&(0,z.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-violet-500/15 text-violet-600",children:"remote"})]}),(0,z.jsx)("div",{className:"col-span-2 font-mono text-xs text-muted-foreground truncate",title:f.content,children:f.content}),(0,z.jsxs)("div",{children:[(0,z.jsx)("span",{className:"text-muted-foreground",children:"Timeout: "}),Math.round(f.timeout_seconds/60),"m"]})]}),y&&(0,z.jsx)("div",{className:"mx-5 mt-3 text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:y}),(0,z.jsx)("div",{className:"flex-1 overflow-auto px-5 py-3",children:(0,z.jsxs)(l0,{children:[(0,z.jsx)(l1,{children:(0,z.jsxs)(l5,{children:[(0,z.jsx)(l3,{children:"Started"}),(0,z.jsx)(l3,{children:"Duration"}),(0,z.jsx)(l3,{children:"Status"}),(0,z.jsx)(l3,{children:"Exit code"})]})}),(0,z.jsxs)(l2,{children:[p.map(e=>(0,z.jsxs)(l5,{onClick:()=>void k(e),className:(0,ey.cn)("skipped"!==e.status&&"cursor-pointer"),children:[(0,z.jsx)(l4,{children:c9(e.started_at)}),(0,z.jsx)(l4,{children:"skipped"===e.status?"—":function(e){if(!e.finished_at)return"…";let r=Math.max(0,Math.round((c7(e.finished_at).getTime()-c7(e.started_at).getTime())/1e3));return r<60?`${r}s`:`${Math.floor(r/60)}m ${r%60}s`}(e)}),(0,z.jsx)(l4,{children:(0,z.jsx)("span",{className:(0,ey.cn)("px-1.5 py-0.5 rounded text-[11px] font-medium",c4[e.status]),children:e.status})}),(0,z.jsx)(l4,{children:e.exit_code??"—"})]},e.id)),0===p.length&&(0,z.jsx)(l5,{children:(0,z.jsx)(l4,{colSpan:4,className:"text-center text-muted-foreground",children:"No runs yet — click “Run now” to try it"})})]})]})}),(0,z.jsx)(c3,{open:g,onOpenChange:x,initial:f,onSubmit:async e=>{await l(f.id,e)},worktrees:a,projectId:e})]}),(0,z.jsx)(c3,{open:u,onOpenChange:h,onSubmit:async e=>{n((await o(e)).id)},worktrees:a,projectId:e}),(0,z.jsx)(lU,{open:null!==w,onOpenChange:e=>{e||S(null)},children:(0,z.jsxs)(lV,{children:[(0,z.jsxs)(lY,{children:[(0,z.jsx)(lX,{children:"Delete scheduled task?"}),(0,z.jsx)(lJ,{children:w?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("span",{className:"font-medium text-foreground",children:w.name})," ","and its run history will be permanently deleted. This cannot be undone."]}):null})]}),(0,z.jsxs)(lG,{children:[(0,z.jsx)(lQ,{children:"Cancel"}),(0,z.jsx)(lZ,{className:(0,ey.cn)((0,W.buttonVariants)({variant:"destructive"}),"border-transparent"),onClick:()=>{S(null),w&&(b(null),c(w.id).catch(e=>{b(e instanceof Error?e.message:"Failed to delete")}))},children:"Delete"})]})]})}),(0,z.jsx)(t7,{open:null!==v,onOpenChange:e=>!e&&_(null),children:(0,z.jsxs)(rr,{className:"max-w-3xl",children:[(0,z.jsx)(rs,{children:(0,z.jsxs)(rn,{children:[v?.report?"Run report":"Run output"," — ",v?c9(v.started_at):""," ",v&&(0,z.jsx)("span",{className:(0,ey.cn)("ml-2 px-1.5 py-0.5 rounded text-[11px] font-medium",c4[v.status]),children:v.status})]})}),v?.report?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("div",{className:"max-h-[50vh] overflow-auto rounded-md border border-border/50 p-3 text-sm",children:(0,z.jsx)(oF.i,{className:"[&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:v.report})}),(0,z.jsxs)("details",{children:[(0,z.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer select-none",children:"Raw output"}),(0,z.jsx)("pre",{className:"mt-2 max-h-[30vh] overflow-auto rounded-md bg-muted/50 p-3 font-mono text-xs whitespace-pre-wrap",children:v.output?c8(v.output):"(no output captured)"})]})]}):(0,z.jsx)("pre",{className:"max-h-[60vh] overflow-auto rounded-md bg-muted/50 p-3 font-mono text-xs whitespace-pre-wrap",children:v?.output?c8(v.output):"(no output captured)"})]})})]}):(0,z.jsxs)("div",{className:"flex flex-col h-full items-center justify-center gap-3 text-center",children:[(0,z.jsx)(oA,{className:"h-8 w-8 text-muted-foreground/50"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"No scheduled tasks yet"}),(0,z.jsx)(W.Button,{size:"sm",onClick:()=>h(!0),children:"New Scheduled Task"}),(0,z.jsx)(c3,{open:u,onOpenChange:h,onSubmit:async e=>{await o(e)},worktrees:a,projectId:e})]})}let dt=(0,ew.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);var dr=e.i(423917);function ds({open:e,onOpenChange:r,onProjectCreated:s}){let{config:i}=(0,dr.useAppConfig)(),n=i?.localProjectsEnabled!==!1,[a,o]=(0,$.useState)(""),[l,c]=(0,$.useState)(""),[d,u]=(0,$.useState)([]),[h,f]=(0,$.useState)("closed"),[p,m]=(0,$.useState)([]),[g,x]=(0,$.useState)(null),[v,_]=(0,$.useState)(""),[y,b]=(0,$.useState)(""),[w,S]=(0,$.useState)(""),[C,j]=(0,$.useState)(""),[k,N]=(0,$.useState)("idle"),[E,D]=(0,$.useState)(""),[R,A]=(0,$.useState)(!1),[M,F]=(0,$.useState)(""),T=()=>{o(""),c(""),u([]),P(),F("")},P=()=>{f("closed"),x(null),_(""),b(""),S(""),j(""),N("idle"),D("")},B=e=>{e||T(),r(e)},L=async()=>{let e=await rv.api.selectFolder();e.path&&(c(e.path),a||o(e.path.split("/").pop()||""))},I=async()=>{f("pick-server");try{let e=await rv.api.getRemoteServers();m(e)}catch{m([])}},O=async()=>{if(!w||!C)return void D("URL and API key are required");N("testing"),D("");try{await rv.api.testRemoteConnection(w,C),N("success")}catch(e){N("error"),D(e instanceof Error?e.message:"Connection failed")}},H=async()=>{if(y.trim()&&w.trim())try{let e=await rv.api.createRemoteServer({name:y.trim(),url:w.trim(),apiKey:C.trim()||void 0});x(e),_(""),f("pick-path")}catch(e){D(e instanceof Error?e.message:"Failed to create server")}},U=l.trim().length>0,K=d.length>0,q=async()=>{if(!a.trim())return void F("Project name is required");if(!U&&!K)return void F(n?"Please provide a local folder, remote server, or both":"Please add a remote server");A(!0),F("");try{let e=await rv.api.createProject({name:a.trim(),...U?{path:l.trim()}:{},...K&&!U?{agentMode:d[0].serverId}:{}});for(let r of d)await rv.api.addProjectRemote(e.id,{remoteServerId:r.serverId,remotePath:r.remotePath});s(e),T(),r(!1)}catch(e){F(e instanceof Error?e.message:"Failed to create project")}finally{A(!1)}};return(0,z.jsx)(t7,{open:e,onOpenChange:B,children:(0,z.jsxs)(rr,{className:"max-w-lg h-[620px] max-h-[calc(100vh-4rem)] grid-rows-[auto_minmax(0,1fr)_auto]",children:[(0,z.jsx)(rs,{children:(0,z.jsx)(rn,{children:"Create New Project"})}),(0,z.jsx)("div",{className:"overflow-y-auto -mx-1 px-1",children:(0,z.jsxs)("div",{className:"space-y-5 py-2",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Project Name"}),(0,z.jsx)(ro,{value:a,onChange:e=>o(e.target.value),placeholder:"My Project"})]}),n&&(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Local Folder"}),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsx)(ro,{value:l,onChange:e=>c(e.target.value),placeholder:"/path/to/project (optional)",className:"flex-1"}),(0,z.jsx)(W.Button,{variant:"outline",onClick:L,children:(0,z.jsx)(r_,{className:"h-4 w-4"})})]})]}),(0,z.jsxs)("div",{className:"space-y-3",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Remote Servers"}),d.length>0&&(0,z.jsx)("div",{className:"space-y-2",children:d.map((e,r)=>(0,z.jsxs)("div",{className:"flex items-center gap-2 rounded-md border p-2 text-sm",children:[(0,z.jsx)(ry,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,z.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,z.jsx)("p",{className:"font-medium truncate",children:e.serverName}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:e.remotePath})]}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon-sm",className:"h-7 w-7 shrink-0",onClick:()=>{u(e=>e.filter((e,s)=>s!==r))},children:(0,z.jsx)(rc,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},`${e.serverId}-${e.remotePath}`))}),"closed"===h&&(0,z.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:I,className:"w-full",children:[(0,z.jsx)(eS,{className:"h-4 w-4 mr-1"}),"Add Remote"]}),"pick-server"===h&&(0,z.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsx)("label",{className:"text-xs font-medium",children:"Select a Remote Server"}),(0,z.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:P,children:(0,z.jsx)(t8,{className:"h-3.5 w-3.5"})})]}),p.length>0&&(0,z.jsx)("div",{className:"space-y-1",children:p.map(e=>(0,z.jsxs)("button",{className:"flex items-center gap-2 w-full rounded-md p-2 text-sm text-left hover:bg-muted",onClick:()=>{x(e),_(""),f("pick-path")},children:[(0,z.jsx)(aR,{className:"h-4 w-4 text-muted-foreground"}),(0,z.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,z.jsx)("p",{className:"truncate",children:e.name}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.url})]})]},e.id))}),(0,z.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:()=>{f("new-server"),b(""),S(""),j(""),N("idle"),D("")},className:"w-full",children:[(0,z.jsx)(eS,{className:"h-4 w-4 mr-1"}),"New Server"]})]}),"new-server"===h&&(0,z.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsx)("label",{className:"text-xs font-medium",children:"Create New Server"}),(0,z.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:P,children:(0,z.jsx)(t8,{className:"h-3.5 w-3.5"})})]}),(0,z.jsx)(ro,{value:y,onChange:e=>b(e.target.value),placeholder:"Server name"}),(0,z.jsx)(ro,{value:w,onChange:e=>{S(e.target.value),N("idle")},placeholder:"http://remote-server:5173"}),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsx)(ro,{type:"password",value:C,onChange:e=>{j(e.target.value),N("idle")},placeholder:"API key",className:"flex-1"}),(0,z.jsx)(W.Button,{variant:"outline",size:"sm",onClick:O,disabled:"testing"===k||!w||!C,children:"testing"===k?(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin"}):"success"===k?(0,z.jsx)(rf.Check,{className:"h-4 w-4 text-green-500"}):"error"===k?(0,z.jsx)(t8,{className:"h-4 w-4 text-red-500"}):"Test"})]}),E&&(0,z.jsx)("p",{className:"text-xs text-red-500",children:E}),"success"===k&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("p",{className:"text-xs text-green-500",children:"Connection successful"}),(0,z.jsx)(W.Button,{size:"sm",onClick:H,disabled:!y.trim(),children:"Create & Continue"})]})]}),"pick-path"===h&&g&&(0,z.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("label",{className:"text-xs font-medium",children:["Select Directory on ",g.name]}),(0,z.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:P,children:(0,z.jsx)(t8,{className:"h-3.5 w-3.5"})})]}),(0,z.jsx)(oo,{serverId:g.id,onSelect:e=>{_(e)},selectedPath:v}),v&&(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Selected: ",(0,z.jsx)("span",{className:"font-mono",children:v})]}),(0,z.jsx)(W.Button,{size:"sm",onClick:()=>{g&&v&&(d.some(e=>e.serverId===g.id&&e.remotePath===v)||(u(e=>[...e,{serverId:g.id,serverName:g.name,serverUrl:g.url,remotePath:v}]),a||o(v.split("/").pop()||"")),P())},children:"Add"})]})]})]}),M&&(0,z.jsx)("p",{className:"text-sm text-red-500 pt-3",children:M})]})}),(0,z.jsxs)(ri,{children:[(0,z.jsx)(W.Button,{variant:"outline",onClick:()=>B(!1),children:"Cancel"}),(0,z.jsx)(W.Button,{onClick:q,disabled:R,children:R?"Creating...":"Create Project"})]})]})})}let di=(0,ew.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),dn=(0,ew.default)("palette",[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]),da=(0,ew.default)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]),dl=(0,ew.default)("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]),dc=(0,ew.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),dd=(0,ew.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);var du=e.i(371263),dh=e.i(909596),df=["PageUp","PageDown"],dp=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],dm={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},dg="Slider",[dx,dv,d_]=rA(dg),[dy,db]=K(dg,[d_]),[dw,dS]=dy(dg),dC=$.forwardRef((e,r)=>{let{name:s,min:i=0,max:n=100,step:a=1,orientation:o="horizontal",disabled:l=!1,minStepsBetweenThumbs:c=0,defaultValue:d=[i],value:u,onValueChange:h=()=>{},onValueCommit:f=()=>{},inverted:p=!1,form:m,...g}=e,x=$.useRef(new Set),v=$.useRef(0),_="horizontal"===o,[y=[],b]=G({prop:u,defaultProp:d,onChange:e=>{let r=[...x.current];r[v.current]?.focus(),h(e)}}),w=$.useRef(y);function S(e,r,{commit:s}={commit:!1}){let o,l=(String(a).split(".")[1]||"").length,d=aM(Math.round((Math.round((e-i)/a)*a+i)*(o=Math.pow(10,l)))/o,[i,n]);b((e=[])=>{let i=function(e=[],r,s){let i=[...e];return i[s]=r,i.sort((e,r)=>e-r)}(e,d,r);if(!function(e,r){if(r>0)return Math.min(...e.slice(0,-1).map((r,s)=>e[s+1]-r))>=r;return!0}(i,c*a))return e;{v.current=i.indexOf(d);let r=String(i)!==String(e);return r&&s&&f(i),r?i:e}})}return(0,z.jsx)(dw,{scope:e.__scopeSlider,name:s,disabled:l,min:i,max:n,valueIndexToChangeRef:v,thumbs:x.current,values:y,orientation:o,form:m,children:(0,z.jsx)(dx.Provider,{scope:e.__scopeSlider,children:(0,z.jsx)(dx.Slot,{scope:e.__scopeSlider,children:(0,z.jsx)(_?dN:dE,{"aria-disabled":l,"data-disabled":l?"":void 0,...g,ref:r,onPointerDown:q(g.onPointerDown,()=>{l||(w.current=y)}),min:i,max:n,inverted:p,onSlideStart:l?void 0:function(e){let r=function(e,r){if(1===e.length)return 0;let s=e.map(e=>Math.abs(e-r)),i=Math.min(...s);return s.indexOf(i)}(y,e);S(e,r)},onSlideMove:l?void 0:function(e){S(e,v.current)},onSlideEnd:l?void 0:function(){let e=w.current[v.current];y[v.current]!==e&&f(y)},onHomeKeyDown:()=>!l&&S(i,0,{commit:!0}),onEndKeyDown:()=>!l&&S(n,y.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:r})=>{if(!l){let s=df.includes(e.key)||e.shiftKey&&dp.includes(e.key),i=v.current;S(y[i]+a*(s?10:1)*r,i,{commit:!0})}}})})})})});dC.displayName=dg;var[dj,dk]=dy(dg,{startEdge:"left",endEdge:"right",size:"width",direction:1}),dN=$.forwardRef((e,r)=>{let{min:s,max:i,dir:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:c,onStepKeyDown:d,...u}=e,[h,f]=$.useState(null),p=(0,U.useComposedRefs)(r,e=>f(e)),m=$.useRef(void 0),g=rB(n),x="ltr"===g,v=x&&!a||!x&&a;function _(e){let r=m.current||h.getBoundingClientRect(),n=dO([0,r.width],v?[s,i]:[i,s]);return m.current=r,n(e-r.left)}return(0,z.jsx)(dj,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:(0,z.jsx)(dD,{dir:g,"data-orientation":"horizontal",...u,ref:p,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{let r=_(e.clientX);o?.(r)},onSlideMove:e=>{let r=_(e.clientX);l?.(r)},onSlideEnd:()=>{m.current=void 0,c?.()},onStepKeyDown:e=>{let r=dm[v?"from-left":"from-right"].includes(e.key);d?.({event:e,direction:r?-1:1})}})})}),dE=$.forwardRef((e,r)=>{let{min:s,max:i,inverted:n,onSlideStart:a,onSlideMove:o,onSlideEnd:l,onStepKeyDown:c,...d}=e,u=$.useRef(null),h=(0,U.useComposedRefs)(r,u),f=$.useRef(void 0),p=!n;function m(e){let r=f.current||u.current.getBoundingClientRect(),n=dO([0,r.height],p?[i,s]:[s,i]);return f.current=r,n(e-r.top)}return(0,z.jsx)(dj,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:(0,z.jsx)(dD,{"data-orientation":"vertical",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{let r=m(e.clientY);a?.(r)},onSlideMove:e=>{let r=m(e.clientY);o?.(r)},onSlideEnd:()=>{f.current=void 0,l?.()},onStepKeyDown:e=>{let r=dm[p?"from-bottom":"from-top"].includes(e.key);c?.({event:e,direction:r?-1:1})}})})}),dD=$.forwardRef((e,r)=>{let{__scopeSlider:s,onSlideStart:i,onSlideMove:n,onSlideEnd:a,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:c,...d}=e,u=dS(dg,s);return(0,z.jsx)(er.span,{...d,ref:r,onKeyDown:q(e.onKeyDown,e=>{"Home"===e.key?(o(e),e.preventDefault()):"End"===e.key?(l(e),e.preventDefault()):df.concat(dp).includes(e.key)&&(c(e),e.preventDefault())}),onPointerDown:q(e.onPointerDown,e=>{let r=e.target;r.setPointerCapture(e.pointerId),e.preventDefault(),u.thumbs.has(r)?r.focus():i(e)}),onPointerMove:q(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&n(e)}),onPointerUp:q(e.onPointerUp,e=>{let r=e.target;r.hasPointerCapture(e.pointerId)&&(r.releasePointerCapture(e.pointerId),a(e))})})}),dR="SliderTrack",dA=$.forwardRef((e,r)=>{let{__scopeSlider:s,...i}=e,n=dS(dR,s);return(0,z.jsx)(er.span,{"data-disabled":n.disabled?"":void 0,"data-orientation":n.orientation,...i,ref:r})});dA.displayName=dR;var dM="SliderRange",dF=$.forwardRef((e,r)=>{let{__scopeSlider:s,...i}=e,n=dS(dM,s),a=dk(dM,s),o=$.useRef(null),l=(0,U.useComposedRefs)(r,o),c=n.values.length,d=n.values.map(e=>dI(e,n.min,n.max)),u=c>1?Math.min(...d):0,h=100-Math.max(...d);return(0,z.jsx)(er.span,{"data-orientation":n.orientation,"data-disabled":n.disabled?"":void 0,...i,ref:l,style:{...e.style,[a.startEdge]:u+"%",[a.endEdge]:h+"%"}})});dF.displayName=dM;var dT="SliderThumb",dP=$.forwardRef((e,r)=>{let s=dv(e.__scopeSlider),[i,n]=$.useState(null),a=(0,U.useComposedRefs)(r,e=>n(e)),o=$.useMemo(()=>i?s().findIndex(e=>e.ref.current===i):-1,[s,i]);return(0,z.jsx)(dB,{...e,ref:a,index:o})}),dB=$.forwardRef((e,r)=>{var s,i,n,a,o;let l,c,{__scopeSlider:d,index:u,name:h,...f}=e,p=dS(dT,d),m=dk(dT,d),[g,x]=$.useState(null),v=(0,U.useComposedRefs)(r,e=>x(e)),_=!g||p.form||!!g.closest("form"),y=J(g),b=p.values[u],w=void 0===b?0:dI(b,p.min,p.max),S=(s=u,(i=p.values.length)>2?`Value ${s+1} of ${i}`:2===i?["Minimum","Maximum"][s]:void 0),C=y?.[m.size],j=C?(n=C,a=w,o=m.direction,c=dO([0,50],[0,l=n/2]),(l-c(a)*o)*o):0;return $.useEffect(()=>{if(g)return p.thumbs.add(g),()=>{p.thumbs.delete(g)}},[g,p.thumbs]),(0,z.jsxs)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[m.startEdge]:`calc(${w}% + ${j}px)`},children:[(0,z.jsx)(dx.ItemSlot,{scope:e.__scopeSlider,children:(0,z.jsx)(er.span,{role:"slider","aria-label":e["aria-label"]||S,"aria-valuemin":p.min,"aria-valuenow":b,"aria-valuemax":p.max,"aria-orientation":p.orientation,"data-orientation":p.orientation,"data-disabled":p.disabled?"":void 0,tabIndex:p.disabled?void 0:0,...f,ref:v,style:void 0===b?{display:"none"}:e.style,onFocus:q(e.onFocus,()=>{p.valueIndexToChangeRef.current=u})})}),_&&(0,z.jsx)(dL,{name:h??(p.name?p.name+(p.values.length>1?"[]":""):void 0),form:p.form,value:b},u)]})});dP.displayName=dT;var dL=$.forwardRef(({__scopeSlider:e,value:r,...s},i)=>{let n=$.useRef(null),a=(0,U.useComposedRefs)(n,i),o=X(r);return $.useEffect(()=>{let e=n.current;if(!e)return;let s=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;if(o!==r&&s){let i=new Event("input",{bubbles:!0});s.call(e,r),e.dispatchEvent(i)}},[o,r]),(0,z.jsx)(er.input,{style:{display:"none"},...s,ref:a,defaultValue:r})});function dI(e,r,s){return aM(100/(s-r)*(e-r),[0,100])}function dO(e,r){return s=>{if(e[0]===e[1]||r[0]===r[1])return r[0];let i=(r[1]-r[0])/(e[1]-e[0]);return r[0]+i*(s-e[0])}}dL.displayName="RadioBubbleInput";let dz=$.forwardRef(({className:e,...r},s)=>(0,z.jsxs)(dC,{ref:s,className:(0,ey.cn)("relative flex w-full touch-none select-none items-center","data-[disabled]:opacity-50",e),...r,children:[(0,z.jsx)(dA,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-muted",children:(0,z.jsx)(dF,{className:"absolute h-full bg-primary"})}),(0,z.jsx)(dP,{className:(0,ey.cn)("block h-4 w-4 rounded-full border border-primary/60 bg-card shadow-[var(--shadow-sm-app)]","transition-colors hover:border-primary","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-offset-1 focus-visible:ring-offset-background"),"aria-label":"Value"})]}));function d$({id:e,label:r,description:s,rightSlot:i,children:n}){return(0,z.jsxs)("section",{id:e,className:"scroll-mt-6 rounded-[10px] border border-border bg-card p-5 shadow-[var(--shadow-sm-app)]",children:[(0,z.jsxs)("header",{className:"flex items-end justify-between gap-3 pb-3 mb-4 border-b border-border/70",children:[(0,z.jsxs)("div",{className:"min-w-0",children:[(0,z.jsx)("h2",{className:"text-[10.5px] font-semibold uppercase tracking-[0.08em] text-muted-foreground/80 leading-none",children:r}),s&&(0,z.jsx)("p",{className:"mt-2 text-[12px] text-muted-foreground/90 leading-snug",children:s})]}),i&&(0,z.jsx)("div",{className:"shrink-0",children:i})]}),(0,z.jsx)("div",{className:"space-y-4",children:n})]})}function dW({label:e,hint:r,htmlFor:s,mono:i,children:n}){return(0,z.jsxs)("div",{children:[(0,z.jsx)("label",{htmlFor:s,className:(0,ey.cn)("block text-[12px] font-medium text-foreground/90 mb-1.5",i&&"font-mono tracking-tight"),children:e}),n,r&&(0,z.jsx)("p",{className:"mt-1.5 text-[11px] text-muted-foreground/85 leading-relaxed",children:r})]})}function dH({name:e,value:r,options:s,onChange:i,columns:n=1}){return(0,z.jsx)("div",{className:(0,ey.cn)("grid gap-2",1===n&&"grid-cols-1",2===n&&"grid-cols-1 sm:grid-cols-2",3===n&&"grid-cols-1 sm:grid-cols-3"),role:"radiogroup",children:s.map(s=>{let n=r===s.value,a=s.Icon;return(0,z.jsxs)("label",{className:(0,ey.cn)("group relative flex items-start gap-3 px-3 py-2.5 rounded-[8px] border cursor-pointer","transition-[border-color,background-color,box-shadow] duration-150","focus-within:ring-2 focus-within:ring-ring/40 focus-within:ring-offset-1 focus-within:ring-offset-background",n?"border-primary/40 bg-[color-mix(in_oklch,var(--primary)_8%,var(--card))] shadow-[var(--shadow-sm-app)]":"border-border/70 bg-card hover:border-border hover:bg-muted/40"),children:[(0,z.jsx)("input",{type:"radio",name:e,value:s.value,checked:n,onChange:()=>i(s.value),className:"sr-only"}),(0,z.jsx)("span",{"aria-hidden":!0,className:(0,ey.cn)("mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",n?"border-primary bg-primary":"border-border bg-card group-hover:border-foreground/40"),children:n&&(0,z.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-primary-foreground"})}),a&&(0,z.jsx)(a,{className:(0,ey.cn)("h-4 w-4 mt-0.5 shrink-0 transition-colors",n?"text-primary":"text-muted-foreground")}),(0,z.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,z.jsx)("span",{className:(0,ey.cn)("block text-[12.5px] font-medium leading-tight",n?"text-foreground":"text-foreground/90"),children:s.label}),s.description&&(0,z.jsx)("span",{className:"mt-0.5 block text-[11.5px] text-muted-foreground leading-snug",children:s.description})]}),s.meta&&(0,z.jsx)("span",{className:"ml-2 mt-0.5 shrink-0 font-mono text-[10.5px] text-muted-foreground/80",children:s.meta})]},s.value)})})}function dU({variant:e="default",icon:r,children:s}){return(0,z.jsxs)("div",{className:(0,ey.cn)("flex items-center gap-2 rounded-[6px] px-2.5 py-1.5 text-[12px]","default"===e&&"text-muted-foreground bg-muted/40","success"===e&&"text-[color:var(--chart-2)] bg-[color-mix(in_oklch,var(--chart-2)_10%,var(--card))] border border-[color-mix(in_oklch,var(--chart-2)_25%,transparent)]","error"===e&&"text-destructive bg-[color-mix(in_oklch,var(--destructive)_8%,var(--card))] border border-[color-mix(in_oklch,var(--destructive)_25%,transparent)]"),children:[r&&(0,z.jsx)("span",{className:"shrink-0",children:r}),(0,z.jsx)("span",{className:"truncate",children:s})]})}function dK({children:e}){return(0,z.jsx)("div",{className:"flex items-center justify-end gap-2 pt-1",children:e})}function dq({nav:e,children:r}){let[s,i]=(0,$.useState)(e[0]?.id??""),n=(0,$.useRef)(null);return(0,$.useEffect)(()=>{let r=n.current;if(!r)return;let s=()=>{let s=r.getBoundingClientRect(),n=s.top+.25*s.height,a=e[0]?.id??"";for(let s of e){let e=r.querySelector(`#${CSS.escape(s.id)}`);e&&e.getBoundingClientRect().top<=n&&(a=s.id)}i(a)};return s(),r.addEventListener("scroll",s,{passive:!0}),()=>r.removeEventListener("scroll",s)},[e]),(0,z.jsxs)("div",{className:"flex-1 min-h-0 grid grid-cols-[200px_minmax(0,1fr)] overflow-hidden",children:[(0,z.jsx)("aside",{className:"border-r border-border bg-[color:var(--sidebar)] overflow-y-auto",children:(0,z.jsx)("nav",{className:"p-3 flex flex-col gap-0.5",children:e.map(e=>{let r=e.Icon,a=s===e.id;return(0,z.jsxs)("button",{type:"button",onClick:()=>(e=>{let r=n.current;if(!r)return;let s=r.querySelector(`#${CSS.escape(e)}`);if(!s)return;let a=s.offsetTop-12;r.scrollTo({top:a,behavior:"smooth"}),i(e)})(e.id),className:(0,ey.cn)("group relative flex items-center gap-2.5 w-full px-2.5 py-1.5 rounded-[6px] text-[12.5px] text-left","transition-colors duration-100",a?"bg-card text-foreground font-medium shadow-[var(--shadow-sm-app)]":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[a&&(0,z.jsx)("span",{"aria-hidden":!0,className:"absolute -left-3 top-1.5 bottom-1.5 w-[2px] rounded-full bg-primary"}),r&&(0,z.jsx)(r,{className:(0,ey.cn)("h-3.5 w-3.5 shrink-0",a?"text-foreground":"text-muted-foreground/80")}),(0,z.jsx)("span",{className:"truncate",children:e.label}),e.badge&&(0,z.jsx)("span",{className:"ml-auto font-mono text-[10px] text-muted-foreground/80",children:e.badge})]},e.id)})})}),(0,z.jsx)("div",{ref:n,className:"overflow-y-auto",children:(0,z.jsx)("div",{className:"mx-auto max-w-2xl px-8 py-7 space-y-6",children:r})})]})}dz.displayName="Slider";let dV=[{value:"light",label:"Light",description:"Bright surface, true-white cards",Icon:dd},{value:"dark",label:"Dark",description:"Low-light surfaces with deep neutrals",Icon:dc},{value:"system",label:"System",description:"Match your OS preference",Icon:aD}],{fontSizeMin:dY,fontSizeMax:dG}=rv.CONVERSATION_SETTINGS_LIMITS;function dX(){let{theme:e,setTheme:r}=(0,du.useTheme)(),{settings:s,setAgentFontSize:i,setChatFontSize:n,setFilesTreeFontSize:a,setFilesContentFontSize:o}=(0,dh.useConversationSettings)();return(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsx)(dW,{label:"Theme",hint:"Sets the surface palette across the app. Switching is instant.",children:(0,z.jsx)(dH,{name:"theme",value:e,options:dV,onChange:r,columns:3})}),(0,z.jsx)(dW,{label:"Conversation font size",hint:"Independent typography for agent and chat views. Affects message body and tool output; chrome elements stay fixed.",children:(0,z.jsxs)("div",{className:"space-y-5",children:[(0,z.jsx)(dJ,{label:"Agent conversation",value:s.agentFontSize,onChange:i}),(0,z.jsx)(dJ,{label:"Chat session",value:s.chatFontSize,onChange:n})]})}),(0,z.jsx)(dW,{label:"Files font size",hint:"Independent typography for the Files tab. File tree controls the file list and search results; file content controls the preview and code.",children:(0,z.jsxs)("div",{className:"space-y-5",children:[(0,z.jsx)(dJ,{label:"File tree, File search",value:s.filesTreeFontSize,onChange:a}),(0,z.jsx)(dJ,{label:"File content",value:s.filesContentFontSize,onChange:o})]})}),(0,z.jsx)(dK,{children:(0,z.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:()=>{i(rv.DEFAULT_CONVERSATION_SETTINGS.agentFontSize),n(rv.DEFAULT_CONVERSATION_SETTINGS.chatFontSize),a(rv.DEFAULT_CONVERSATION_SETTINGS.filesTreeFontSize),o(rv.DEFAULT_CONVERSATION_SETTINGS.filesContentFontSize)},children:"Reset"})})]})}function dJ({label:e,value:r,onChange:s}){return(0,z.jsxs)("div",{children:[(0,z.jsxs)("div",{className:"flex items-baseline justify-between mb-1.5",children:[(0,z.jsx)("span",{className:"text-[12px] font-medium text-foreground/90",children:e}),(0,z.jsxs)("span",{className:"font-mono text-[11.5px] text-foreground/80 tabular-nums",children:[r," px"]})]}),(0,z.jsx)(dz,{min:dY,max:dG,step:1,value:[r],onValueChange:e=>s(e[0])}),(0,z.jsxs)("div",{className:"flex justify-between mt-1 text-[10.5px] text-muted-foreground/80 font-mono",children:[(0,z.jsx)("span",{children:dY}),(0,z.jsx)("span",{children:dG})]})]})}let dZ=(0,ew.default)("waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]]),dQ={deepseek:da,openrouter:dZ},d0=rv.PROVIDER_IDS.map(e=>({value:e,label:rv.PROVIDERS[e].label,description:"deepseek"===e?"Direct API access — lowest latency":"Aggregator routing — many models available",Icon:dQ[e]}));function d1({name:e,value:r,onChange:s}){let i=rv.PROVIDERS[r.provider];return(0,z.jsxs)("div",{className:"space-y-3",children:[(0,z.jsx)(dH,{name:e,value:r.provider,options:d0,onChange:e=>s((0,rv.defaultModelChoice)(e)),columns:2}),i.models?(0,z.jsxs)(cX,{value:r.model,onValueChange:e=>s({...r,model:e}),children:[(0,z.jsx)(cZ,{className:"w-full font-mono text-[12.5px]",children:(0,z.jsx)(cJ,{})}),(0,z.jsx)(cQ,{children:i.models.map(e=>(0,z.jsx)(c0,{value:e,className:"font-mono text-[12.5px]",children:i.modelLabels?.[e]??e},e))})]}):(0,z.jsx)(ro,{className:"font-mono text-[12.5px]",placeholder:i.placeholder,value:r.model,onChange:e=>s({...r,model:e.target.value})})]})}function d2(){let[e,r]=(0,$.useState)(()=>(0,rv.defaultChatProviderConfig)().apiKeys),[s,i]=(0,$.useState)(()=>({deepseek:!1,openrouter:!1})),[n,a]=(0,$.useState)(()=>(0,rv.defaultModelChoice)()),[o,l]=(0,$.useState)(()=>(0,rv.defaultModelChoice)()),[c,d]=(0,$.useState)(!0),[u,h]=(0,$.useState)(!1),[f,p]=(0,$.useState)(null);(0,$.useEffect)(()=>{d(!0),rv.api.getChatProviderSettings().then(e=>{r(e.apiKeys),a(e.main),l(e.fast),i({deepseek:!1,openrouter:!1})}).finally(()=>d(!1))},[]);let m=async()=>{h(!0),p(null);try{let c={};for(let r of rv.PROVIDER_IDS)s[r]&&(c[r]=e[r]);let d={main:n,fast:o};Object.keys(c).length>0&&(d.apiKeys=c);let u=await rv.api.updateChatProviderSettings(d);r(u.apiKeys),a(u.main),l(u.fast),i({deepseek:!1,openrouter:!1}),p("Settings saved"),setTimeout(()=>p(null),2e3)}catch(e){p(e instanceof Error?e.message:"Failed to save")}finally{h(!1)}};return c?(0,z.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsx)("p",{className:"text-[12px] font-medium text-foreground/70",children:"API keys"}),rv.PROVIDER_IDS.map(n=>{let a=rv.PROVIDERS[n],o=s[n],l=e[n];return(0,z.jsx)(dW,{label:`${a.label} API key`,mono:!0,hint:(0,z.jsxs)(z.Fragment,{children:["Leave empty to fall back to the"," ",(0,z.jsx)("code",{className:"font-mono text-[10.5px] bg-muted/60 border border-border/60 rounded px-1 py-px",children:a.envKey})," ","environment variable."]}),children:(0,z.jsx)(ro,{type:"password",className:"font-mono text-[12px]",placeholder:l&&!o?l:"sk-...",value:o?l:"",onChange:e=>{var s;return s=e.target.value,void(r(e=>({...e,[n]:s})),i(e=>({...e,[n]:!0})),p(null))}})},n)})]}),(0,z.jsx)(dW,{label:"Main model",hint:"Powers the chat session.",children:(0,z.jsx)(d1,{name:"main-provider",value:n,onChange:e=>{a(e),p(null)}})}),(0,z.jsx)(dW,{label:"Fast model",hint:"Powers translate and agent session titles. Can use a different provider than the main model.",children:(0,z.jsx)(d1,{name:"fast-provider",value:o,onChange:e=>{l(e),p(null)}})}),f&&(0,z.jsx)(dU,{variant:"Settings saved"===f?"success":"error",icon:"Settings saved"===f?(0,z.jsx)(rC,{className:"h-3.5 w-3.5"}):(0,z.jsx)(rj,{className:"h-3.5 w-3.5"}),children:f}),(0,z.jsx)(dK,{children:(0,z.jsxs)(W.Button,{size:"sm",onClick:m,disabled:u,children:[u&&(0,z.jsx)(rk,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})})]})}let d5=[{value:"none",label:"Direct",description:"No proxy — connect directly to the internet",Icon:(0,ew.default)("shield-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]])},{value:"http",label:"HTTP / HTTPS",description:"Route through an HTTP CONNECT proxy",Icon:di},{value:"socks5",label:"SOCKS5",description:"Route through a SOCKS5 proxy server",Icon:dZ}];function d3(){let[e,r]=(0,$.useState)("none"),[s,i]=(0,$.useState)(""),[n,a]=(0,$.useState)(""),[o,l]=(0,$.useState)(!0),[c,d]=(0,$.useState)(!1),[u,h]=(0,$.useState)(!1),[f,p]=(0,$.useState)(null),[m,g]=(0,$.useState)(null);(0,$.useEffect)(()=>{l(!0),p(null),g(null),rv.api.getProxySettings().then(e=>{r(e.type),i(e.host),a(e.port?String(e.port):"")}).finally(()=>l(!1))},[]);let x=()=>({type:e,host:"none"===e?"":s.trim(),port:"none"===e?0:parseInt(n,10)||0}),v=async()=>{h(!0),p(null);try{p(await rv.api.testProxyConnection(x()))}catch(e){p({success:!1,message:e instanceof Error?e.message:"Test failed"})}finally{h(!1)}},_=async()=>{d(!0),g(null);try{await rv.api.updateProxySettings(x()),g("Settings saved"),setTimeout(()=>g(null),2e3)}catch(e){g(e instanceof Error?e.message:"Failed to save")}finally{d(!1)}},y="none"!==e;return o?(0,z.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsx)(dW,{label:"Connection mode",children:(0,z.jsx)(dH,{name:"proxyType",value:e,options:d5,onChange:e=>{r(e),p(null),g(null)}})}),y&&(0,z.jsxs)("div",{className:"grid grid-cols-[1fr_120px] gap-3",children:[(0,z.jsx)(dW,{label:"Host",mono:!0,children:(0,z.jsx)(ro,{placeholder:"127.0.0.1",value:s,className:"font-mono text-[12.5px]",onChange:e=>{i(e.target.value),p(null),g(null)}})}),(0,z.jsx)(dW,{label:"Port",mono:!0,children:(0,z.jsx)(ro,{type:"number",placeholder:"1080",value:n,className:"font-mono text-[12.5px]",onChange:e=>{a(e.target.value),p(null),g(null)},min:1,max:65535})})]}),f&&(0,z.jsx)(dU,{variant:f.success?"success":"error",icon:f.success?(0,z.jsx)(rC,{className:"h-3.5 w-3.5"}):(0,z.jsx)(rj,{className:"h-3.5 w-3.5"}),children:f.message??(f.success?"Connection succeeded":"Connection failed")}),m&&!f&&(0,z.jsx)(dU,{variant:"Settings saved"===m?"success":"error",icon:"Settings saved"===m?(0,z.jsx)(rC,{className:"h-3.5 w-3.5"}):(0,z.jsx)(rj,{className:"h-3.5 w-3.5"}),children:m}),(0,z.jsxs)(dK,{children:[y&&(0,z.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:v,disabled:u||!s.trim()||!n,children:[u&&(0,z.jsx)(rk,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Test connection"]}),(0,z.jsxs)(W.Button,{size:"sm",onClick:_,disabled:c,children:[c&&(0,z.jsx)(rk,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})]})]})}var d4=e.i(276949);let{scrollbackMin:d6,scrollbackMax:d8,fontSizeMin:d7,fontSizeMax:d9}=rv.TERMINAL_SETTINGS_LIMITS;function ue(){let{settings:e,loaded:r,refresh:s}=(0,d4.useTerminalSettings)(),[i,n]=(0,$.useState)(String(rv.DEFAULT_TERMINAL_SETTINGS.scrollback)),[a,o]=(0,$.useState)(String(rv.DEFAULT_TERMINAL_SETTINGS.fontSize)),[l,c]=(0,$.useState)(rv.DEFAULT_TERMINAL_SETTINGS.fontFamily),[d,u]=(0,$.useState)(!1),[h,f]=(0,$.useState)(null);(0,$.useEffect)(()=>{r&&(n(String(e.scrollback)),o(String(e.fontSize)),c(e.fontFamily))},[r,e.scrollback,e.fontSize,e.fontFamily]);let p=parseInt(i,10),m=parseInt(a,10),g=Number.isFinite(p)&&p>=d6&&p<=d8,x=Number.isFinite(m)&&m>=d7&&m<=d9,v=""!==l.trim(),_=g&&x&&v,y=async()=>{if(_){u(!0),f(null);try{let e={scrollback:p,fontSize:m,fontFamily:l.trim()};await rv.api.updateTerminalSettings(e),await s(),f("Settings saved"),setTimeout(()=>f(null),2e3)}catch(e){f(e instanceof Error?e.message:"Failed to save")}finally{u(!1)}}};return r?(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,z.jsx)(dW,{label:"Scrollback",mono:!0,hint:(0,z.jsxs)("span",{children:["Lines kept in buffer."," ",(0,z.jsxs)("span",{className:"font-mono text-foreground/70",children:[d6,"–",d8]})," · default ",(0,z.jsx)("span",{className:"font-mono text-foreground/70",children:rv.DEFAULT_TERMINAL_SETTINGS.scrollback})]}),children:(0,z.jsx)(ro,{type:"number",min:d6,max:d8,value:i,className:"font-mono text-[12.5px]",onChange:e=>{n(e.target.value),f(null)}})}),(0,z.jsx)(dW,{label:"Font size",mono:!0,hint:(0,z.jsxs)("span",{children:["Pixels."," ",(0,z.jsxs)("span",{className:"font-mono text-foreground/70",children:[d7,"–",d9]})," · default ",(0,z.jsx)("span",{className:"font-mono text-foreground/70",children:rv.DEFAULT_TERMINAL_SETTINGS.fontSize})]}),children:(0,z.jsx)(ro,{type:"number",min:d7,max:d9,value:a,className:"font-mono text-[12.5px]",onChange:e=>{o(e.target.value),f(null)}})})]}),(0,z.jsx)(dW,{label:"Font family",mono:!0,hint:"CSS font-family list. Use monospace fonts for column alignment.",children:(0,z.jsx)(ro,{value:l,className:"font-mono text-[12px]",onChange:e=>{c(e.target.value),f(null)},placeholder:rv.DEFAULT_TERMINAL_SETTINGS.fontFamily})}),h&&(0,z.jsx)(dU,{variant:"Settings saved"===h?"success":"error",icon:"Settings saved"===h?(0,z.jsx)(rC,{className:"h-3.5 w-3.5"}):(0,z.jsx)(rj,{className:"h-3.5 w-3.5"}),children:h}),(0,z.jsxs)(dK,{children:[(0,z.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>{n(String(rv.DEFAULT_TERMINAL_SETTINGS.scrollback)),o(String(rv.DEFAULT_TERMINAL_SETTINGS.fontSize)),c(rv.DEFAULT_TERMINAL_SETTINGS.fontFamily),f(null)},disabled:d,children:"Reset"}),(0,z.jsxs)(W.Button,{size:"sm",onClick:y,disabled:d||!_,children:[d&&(0,z.jsx)(rk,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})]})]}):(0,z.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin text-muted-foreground"})})}let{min:ut,max:ur}=rv.AGENT_PROCESS_SETTINGS_LIMITS;function us(){let[e,r]=(0,$.useState)(String(rv.DEFAULT_AGENT_PROCESS_SETTINGS.maxResidentAgentProcesses)),[s,i]=(0,$.useState)(!1),[n,a]=(0,$.useState)(!1),[o,l]=(0,$.useState)(null);(0,$.useEffect)(()=>{let e=!1;return(0,rv.getAgentProcessSettings)().then(s=>{e||(r(String(s.maxResidentAgentProcesses)),i(!0))}).catch(r=>{e||(l(r instanceof Error?r.message:"Failed to load settings"),i(!0))}),()=>{e=!0}},[]);let c=parseInt(e,10),d=Number.isInteger(c)&&c>=ut&&c<=ur,u=async()=>{if(d){a(!0),l(null);try{let e=await (0,rv.updateAgentProcessSettings)({maxResidentAgentProcesses:c});r(String(e.maxResidentAgentProcesses)),l("Settings saved"),setTimeout(()=>l(null),2e3)}catch(e){l(e instanceof Error?e.message:"Failed to save")}finally{a(!1)}}};return s?(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsx)(dW,{label:"Resident agent processes",mono:!0,hint:(0,z.jsxs)("span",{children:["Live local or remote agent processes per server."," ",(0,z.jsxs)("span",{className:"font-mono text-foreground/70",children:[ut,"–",ur]})," · default ",(0,z.jsx)("span",{className:"font-mono text-foreground/70",children:rv.DEFAULT_AGENT_PROCESS_SETTINGS.maxResidentAgentProcesses})]}),children:(0,z.jsxs)("div",{className:"flex items-center gap-2 max-w-[220px]",children:[(0,z.jsx)(aE,{className:"h-4 w-4 text-muted-foreground"}),(0,z.jsx)(ro,{type:"number",min:ut,max:ur,value:e,className:"font-mono text-[12.5px]",onChange:e=>{r(e.target.value),l(null)}})]})}),o&&(0,z.jsx)(dU,{variant:"Settings saved"===o?"success":"error",icon:"Settings saved"===o?(0,z.jsx)(rC,{className:"h-3.5 w-3.5"}):(0,z.jsx)(rj,{className:"h-3.5 w-3.5"}),children:o}),(0,z.jsxs)(dK,{children:[(0,z.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>{r(String(rv.DEFAULT_AGENT_PROCESS_SETTINGS.maxResidentAgentProcesses)),l(null)},disabled:n,children:"Reset"}),(0,z.jsxs)(W.Button,{size:"sm",onClick:u,disabled:n||!d,children:[n&&(0,z.jsx)(rk,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})]})]}):(0,z.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin text-muted-foreground"})})}let ui=[{id:"appearance",label:"Appearance",Icon:dn},{id:"ai-chat",label:"AI Chat",Icon:da},{id:"agents",label:"Agents",Icon:aE},{id:"terminal",label:"Terminal",Icon:dl},{id:"proxy",label:"Proxy",Icon:di}];function un(){return(0,z.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,z.jsx)(lb,{title:"Settings",description:"Theme, intelligence, terminal, and network preferences."}),(0,z.jsxs)(dq,{nav:ui,children:[(0,z.jsx)(d$,{id:"appearance",label:"Appearance",description:"Visual surface for the workspace. Affects every view.",children:(0,z.jsx)(dX,{})}),(0,z.jsx)(d$,{id:"ai-chat",label:"AI Chat",description:"Provider, credentials, and default model used for the orchestrator chat.",children:(0,z.jsx)(d2,{})}),(0,z.jsx)(d$,{id:"agents",label:"Agents",description:"Resident coding-agent process limits per workspace branch.",children:(0,z.jsx)(us,{})}),(0,z.jsx)(d$,{id:"terminal",label:"Terminal",description:"Buffer size and typography for the executor terminal.",children:(0,z.jsx)(ue,{})}),(0,z.jsx)(d$,{id:"proxy",label:"Proxy",description:"Outbound network routing for AI providers and remote servers.",children:(0,z.jsx)(d3,{})})]})]})}let ua=(0,ew.default)("plug-zap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]),uo=(0,ew.default)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);var ul=e.i(710307);let uc={name:"",url:"",apiKey:"",connectionMode:"outbound"};function ud(){let[e,r]=(0,$.useState)([]),[s,i]=(0,$.useState)(!0),[n,a]=(0,$.useState)(""),[o,l]=(0,$.useState)(!1),[c,d]=(0,$.useState)(null),[u,h]=(0,$.useState)(uc),[f,p]=(0,$.useState)(""),[m,g]=(0,$.useState)(!1),[x,v]=(0,$.useState)(null),[_,y]=(0,$.useState)(!1),[b,w]=(0,$.useState)({}),[S,C]=(0,$.useState)({}),[j,k]=(0,$.useState)(null),[N,E]=(0,$.useState)(null),[D,R]=(0,$.useState)(null),[A,M]=(0,$.useState)(!1),[F,T]=(0,$.useState)(!1),P=(0,$.useCallback)(async()=>{try{let e=await rv.api.getRemoteServers();r(e),a("")}catch(e){a(e instanceof Error?e.message:"Failed to load servers")}finally{i(!1)}},[]);(0,$.useEffect)(()=>{P()},[P]),(0,$.useEffect)(()=>{let e=setInterval(P,15e3),r=()=>P();return window.addEventListener("focus",r),()=>{clearInterval(e),window.removeEventListener("focus",r)}},[P]);let B=async()=>{if(!u.name.trim())return void p("Name is required");if("outbound"===u.connectionMode&&!u.url.trim())return void p("URL is required for outbound servers");g(!0),p("");try{if(c){let e={};u.name.trim()!==c.name&&(e.name=u.name.trim()),u.url.trim()!==(c.url||"")&&(e.url=u.url.trim()),u.apiKey.trim()&&(e.apiKey=u.apiKey.trim()),await rv.api.updateRemoteServer(c.id,e)}else await rv.api.createRemoteServer({name:u.name.trim(),url:u.url.trim(),...u.apiKey.trim()?{apiKey:u.apiKey.trim()}:{},connectionMode:u.connectionMode});l(!1),await P()}catch(e){p(e instanceof Error?e.message:"Failed to save server")}finally{g(!1)}},L=async()=>{if(x){y(!0);try{await rv.api.deleteRemoteServer(x.id),v(null),await P()}catch(e){p(e instanceof Error?e.message:"Failed to delete server")}finally{y(!1)}}},I=async e=>{w(r=>({...r,[e.id]:"testing"})),C(r=>{let s={...r};return delete s[e.id],s});try{let r=await rv.api.testRemoteServer(e.id);w(s=>({...s,[e.id]:r.success?"success":"error"})),r.success||C(r=>({...r,[e.id]:"Connection failed"}))}catch(r){w(r=>({...r,[e.id]:"error"})),C(s=>({...s,[e.id]:r instanceof Error?r.message:"Test failed"}))}},O=async e=>{k(e),E(null),R(null),T(!1),M(!0);try{let r=await rv.api.generateRemoteServerToken(e.id);E(r.token),R(r.connectCommand)}catch(e){p(e instanceof Error?e.message:"Failed to generate token"),k(null)}finally{M(!1)}},H=async e=>{try{await rv.api.revokeRemoteServerToken(e.id),await P()}catch(e){a(e instanceof Error?e.message:"Failed to revoke token")}},U=async(e,s)=>{try{let i=await rv.api.updateRemoteServer(e.id,{crossRemoteAccess:s});r(e=>e.map(e=>e.id===i.id?i:e))}catch(e){a(e instanceof Error?e.message:"Failed to update access")}};return s?(0,z.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,z.jsx)(rk,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h3",{className:"text-sm font-medium",children:"Remote Servers"}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:"Manage globally available remote servers"})]}),(0,z.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:()=>{d(null),h(uc),p(""),l(!0)},children:[(0,z.jsx)(eS,{className:"h-4 w-4 mr-1.5"}),"Add Server"]})]}),n&&(0,z.jsx)("p",{className:"text-sm text-red-500",children:n}),0===e.length?(0,z.jsxs)("div",{className:"text-center py-8 text-sm text-muted-foreground border rounded-md",children:[(0,z.jsx)(ry,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),"No remote servers configured"]}):(0,z.jsxs)(l0,{children:[(0,z.jsx)(l1,{children:(0,z.jsxs)(l5,{children:[(0,z.jsx)(l3,{children:"Name"}),(0,z.jsx)(l3,{children:"Mode"}),(0,z.jsx)(l3,{children:"URL / Status"}),(0,z.jsx)(l3,{children:"Cross-remote access"}),(0,z.jsx)(l3,{className:"w-[180px] text-right",children:"Actions"})]})}),(0,z.jsx)(l2,{children:e.map(e=>{let r;return(0,z.jsxs)(l5,{children:[(0,z.jsx)(l4,{className:"font-medium",children:(0,z.jsxs)("div",{className:"flex items-center",children:[(e=>{if("inbound"!==e.connection_mode)return null;let r="online"===e.status;return(0,z.jsx)("span",{className:`inline-block h-2.5 w-2.5 rounded-full mr-2 ${r?"bg-green-500":"bg-gray-400"}`,title:r?"Online":"Offline"})})(e),e.name]})}),(0,z.jsx)(l4,{children:(0,z.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${"inbound"===e.connection_mode?"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400":"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-400"}`,children:"inbound"===e.connection_mode?"Inbound":"Outbound"})}),(0,z.jsx)(l4,{className:"font-mono text-xs text-muted-foreground",children:"inbound"===e.connection_mode?"online"===e.status?"Connected":"Waiting for connection...":e.url}),(0,z.jsx)(l4,{children:(0,z.jsxs)(cX,{value:e.cross_remote_access,onValueChange:r=>U(e,r),children:[(0,z.jsx)(cZ,{className:"w-[190px] text-[12.5px]",children:(0,z.jsx)(cJ,{})}),(0,z.jsxs)(cQ,{children:[(0,z.jsx)(c0,{value:"off",className:"text-[12.5px]",children:"Off"}),(0,z.jsx)(c0,{value:"read",className:"text-[12.5px]",children:"Diagnostic read"}),(0,z.jsx)(c0,{value:"exec",className:"text-[12.5px]",children:"Command execution"})]})]})}),(0,z.jsxs)(l4,{className:"text-right",children:[(0,z.jsxs)("div",{className:"flex items-center justify-end gap-1",children:["inbound"===e.connection_mode&&(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>O(e),title:"Generate connect token",className:"h-8 w-8",children:(0,z.jsx)(uo,{className:"h-4 w-4"})}),(r=b[e.id]||"idle",(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>I(e),disabled:"testing"===r,title:"Test connection",className:"h-8 w-8",children:"testing"===r?(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin"}):"success"===r?(0,z.jsx)(rf.Check,{className:"h-4 w-4 text-green-500"}):"error"===r?(0,z.jsx)(t8,{className:"h-4 w-4 text-red-500"}):(0,z.jsx)(ua,{className:"h-4 w-4"})})),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>{d(e),h({name:e.name,url:e.url||"",apiKey:"",connectionMode:e.connection_mode}),p(""),l(!0)},title:"Edit server",className:"h-8 w-8",children:(0,z.jsx)(rg,{className:"h-4 w-4"})}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>v(e),title:"Delete server",className:"h-8 w-8 text-destructive hover:text-destructive",children:(0,z.jsx)(rc,{className:"h-4 w-4"})})]}),S[e.id]&&(0,z.jsx)("p",{className:"text-xs text-red-500 mt-1 text-right",children:S[e.id]})]})]},e.id)})})]}),(0,z.jsxs)("p",{className:"text-xs text-muted-foreground",children:["When enabled, agents running on your other machines can reach this one.",(0,z.jsx)("strong",{children:" Diagnostic read"})," exposes files, directories and the process list — including any secrets in logs and config files.",(0,z.jsx)("strong",{children:" Command execution"})," additionally allows arbitrary shell commands. Off by default."]}),(0,z.jsx)(t7,{open:o,onOpenChange:l,children:(0,z.jsxs)(rr,{className:"sm:max-w-md",children:[(0,z.jsxs)(rs,{children:[(0,z.jsx)(rn,{children:c?"Edit Server":"Add Remote Server"}),(0,z.jsx)(ra,{children:c?"Update the server connection details.":"Add a new remote server to the global registry."})]}),(0,z.jsxs)("div",{className:"space-y-4",children:[!c&&(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Connection Mode"}),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsx)(W.Button,{type:"button",variant:"outbound"===u.connectionMode?"default":"outline",size:"sm",onClick:()=>h(e=>({...e,connectionMode:"outbound"})),children:"Outbound"}),(0,z.jsx)(W.Button,{type:"button",variant:"inbound"===u.connectionMode?"default":"outline",size:"sm",onClick:()=>h(e=>({...e,connectionMode:"inbound"})),children:"Inbound"})]}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:"outbound"===u.connectionMode?"Server connects outbound to the remote node (remote must have a public URL).":"Remote node connects inbound to this server (no public URL needed on remote)."})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,z.jsx)(ro,{value:u.name,onChange:e=>{h(r=>({...r,name:e.target.value})),p("")},placeholder:"My Remote Server"})]}),("outbound"===u.connectionMode||c)&&(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsxs)("label",{className:"text-sm font-medium",children:["URL","inbound"!==u.connectionMode||c?"":" (optional)"]}),(0,z.jsx)(ro,{value:u.url,onChange:e=>{h(r=>({...r,url:e.target.value})),p("")},placeholder:"http://remote-server:5173"})]}),"outbound"===u.connectionMode&&(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"API Key"}),(0,z.jsx)(ro,{type:"password",value:u.apiKey,onChange:e=>{h(r=>({...r,apiKey:e.target.value})),p("")},placeholder:c?"(unchanged)":"Optional"})]}),f&&(0,z.jsx)("p",{className:"text-sm text-red-500",children:f})]}),(0,z.jsxs)(ri,{children:[(0,z.jsx)(W.Button,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),(0,z.jsxs)(W.Button,{onClick:B,disabled:m,children:[m&&(0,z.jsx)(rk,{className:"h-4 w-4 mr-1.5 animate-spin"}),c?"Save Changes":"Add Server"]})]})]})}),(0,z.jsx)(t7,{open:null!==j,onOpenChange:e=>{e||(k(null),E(null),R(null))},children:(0,z.jsxs)(rr,{className:"sm:max-w-lg",children:[(0,z.jsxs)(rs,{children:[(0,z.jsx)(rn,{children:"Connect Token"}),(0,z.jsxs)(ra,{children:["Use this token to connect a remote node to"," ",(0,z.jsx)("span",{className:"font-semibold",children:j?.name}),". The token is shown only once."]})]}),A?(0,z.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,z.jsx)(rk,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):N?(0,z.jsx)("div",{className:"space-y-4",children:(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Connect Command"}),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsx)(ro,{readOnly:!0,value:D||"",className:"font-mono text-xs"}),(0,z.jsx)(W.Button,{variant:"outline",size:"icon",className:"shrink-0",onClick:()=>{var e;return e=D||"",void(navigator.clipboard.writeText(e),T(!0),setTimeout(()=>T(!1),2e3))},title:"Copy command",children:F?(0,z.jsx)(rf.Check,{className:"h-4 w-4 text-green-500"}):(0,z.jsx)(ul.Copy,{className:"h-4 w-4"})})]}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:"Run this command on the remote machine to establish the reverse connection."})]})}):null,(0,z.jsxs)(ri,{children:[N&&j&&(0,z.jsx)(W.Button,{variant:"outline",className:"mr-auto text-destructive hover:text-destructive",onClick:()=>{H(j),k(null),E(null)},children:"Revoke Token"}),(0,z.jsx)(W.Button,{variant:"outline",onClick:()=>{k(null),E(null),R(null)},children:"Close"})]})]})}),(0,z.jsx)(t7,{open:null!==x,onOpenChange:e=>{e||v(null)},children:(0,z.jsxs)(rr,{className:"sm:max-w-sm",children:[(0,z.jsxs)(rs,{children:[(0,z.jsx)(rn,{children:"Delete Server"}),(0,z.jsxs)(ra,{children:["Are you sure you want to delete"," ",(0,z.jsx)("span",{className:"font-semibold",children:x?.name}),"? This will also remove it from any projects that reference it."]})]}),(0,z.jsxs)(ri,{children:[(0,z.jsx)(W.Button,{variant:"outline",onClick:()=>v(null),children:"Cancel"}),(0,z.jsxs)(W.Button,{variant:"destructive",onClick:L,disabled:_,children:[_&&(0,z.jsx)(rk,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Delete"]})]})]})})]})}function uu({projectId:e,project:r,open:s,onOpenChange:i,onWorktreeCreated:n}){let[a,o]=(0,$.useState)(""),[l,c]=(0,$.useState)(!1),[d,u]=(0,$.useState)(null),[h,f]=(0,$.useState)(null),[p,m]=(0,$.useState)(!0),[g,x]=(0,$.useState)(!0),[v,_]=(0,$.useState)([]),[y,b]=(0,$.useState)([]),[w,S]=(0,$.useState)("main"),[C,j]=(0,$.useState)("main"),[k,N]=(0,$.useState)(!1),E=!!(r.path&&r.remote_path);(0,$.useEffect)(()=>{s&&(N(!0),E?Promise.all([rv.api.getProjectBranches(e,"local"),rv.api.getProjectBranches(e,"remote")]).then(([e,r])=>{_(e),b(r),S(e.includes("main")?"main":e[0]||"main"),j(r.includes("main")?"main":r[0]||"main"),N(!1)}):rv.api.getProjectBranches(e).then(e=>{_(e),S(e.includes("main")?"main":e[0]||"main"),N(!1)}))},[s,e,E]);let D=async()=>{if(a.trim()){c(!0),u(null),f(null);try{let r;E&&(r=[],p&&r.push("local"),g&&r.push("remote"));let s=await rv.api.createWorktree(e,a.trim(),r,w,E?C:void 0);if(s.partialSuccess){let e,r=s.results?.remote?.success===!1?"remote":"local",i=s.results?.[r],n=i?.error||"Unknown error",a=i?.errorCode,o=i?.requestId;switch(a){case"timeout":e="Connection to remote server timed out. The remote server may be slow or unreachable.";break;case"network_error":e="Cannot connect to remote server. Check that the server is running and the URL is correct.";break;case"auth_error":e="Authentication failed with remote server. Check the API key in project settings.";break;case"server_error":e=`Remote server returned an error: ${n}`;break;default:e=`Worktree created locally, but ${r} creation failed: ${n}`}o&&(e+=` (Request ID: ${o})`),f(e)}n(s.worktree.branch),s.partialSuccess||(i(!1),o(""))}catch(e){u(e instanceof Error?e.message:"Failed to create worktree")}finally{c(!1)}}},R=e=>{e||(o(""),u(null),f(null),m(!0),x(!0),_([]),b([]),S("main"),j("main")),i(e)},A=(e,r,s,i)=>(0,z.jsxs)(cX,{value:r,onValueChange:s,disabled:i||k,children:[(0,z.jsx)(cZ,{size:"sm",children:(0,z.jsx)(cJ,{placeholder:k?"Loading...":"Select branch"})}),(0,z.jsx)(cQ,{children:e.map(e=>(0,z.jsx)(c0,{value:e,children:e},e))})]});return(0,z.jsx)(t7,{open:s,onOpenChange:R,children:(0,z.jsxs)(rr,{children:[(0,z.jsxs)(rs,{children:[(0,z.jsx)(rn,{children:"Create New Worktree"}),(0,z.jsx)(ra,{children:"Create a new branch based on an existing branch"})]}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{htmlFor:"branch-name",className:"text-sm font-medium",children:"Branch Name"}),(0,z.jsx)(ro,{id:"branch-name",placeholder:"feature/my-feature",value:a,onChange:e=>o(e.target.value),disabled:l,onKeyDown:e=>{"Enter"===e.key&&a.trim()&&(!E||p||g)&&D()}})]}),E?(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Create On"}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,z.jsx)("input",{type:"checkbox",checked:p,onChange:e=>{(e.target.checked||g)&&m(e.target.checked)},disabled:l,className:"h-4 w-4 rounded border-input accent-primary"}),(0,z.jsx)("span",{children:"Local"}),(0,z.jsx)("span",{className:"text-muted-foreground truncate text-xs",children:r.path})]}),p&&v.length>0&&(0,z.jsxs)("div",{className:"ml-6",children:[(0,z.jsx)("label",{className:"text-xs text-muted-foreground",children:"Base Branch"}),A(v,w,S,l)]}),(0,z.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,z.jsx)("input",{type:"checkbox",checked:g,onChange:e=>{(e.target.checked||p)&&x(e.target.checked)},disabled:l,className:"h-4 w-4 rounded border-input accent-primary"}),(0,z.jsx)("span",{children:"Remote"}),(0,z.jsx)("span",{className:"text-muted-foreground truncate text-xs",children:r.remote_path})]}),g&&y.length>0&&(0,z.jsxs)("div",{className:"ml-6",children:[(0,z.jsx)("label",{className:"text-xs text-muted-foreground",children:"Base Branch"}),A(y,C,j,l)]})]})]}):v.length>0&&(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Base Branch"}),A(v,w,S,l)]}),h&&(0,z.jsx)("div",{className:"text-sm text-yellow-600 dark:text-yellow-500 bg-yellow-500/10 px-3 py-2 rounded-md",children:h}),d&&(0,z.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:d})]}),(0,z.jsxs)(ri,{children:[(0,z.jsx)(W.Button,{variant:"outline",onClick:()=>R(!1),disabled:l,children:"Cancel"}),(0,z.jsx)(W.Button,{onClick:D,disabled:!a.trim()||l||E&&!p&&!g,children:l?"Creating...":"Create"})]})]})})}function uh({projectId:e,worktree:r,open:s,onOpenChange:i,onWorktreeDeleted:n}){let[a,o]=(0,$.useState)(!1),[l,c]=(0,$.useState)(null),[d,u]=(0,$.useState)(null),h=async()=>{if(r){o(!0),c(null),u(null);try{let s=await rv.api.deleteWorktree(e,r.branch);if(s.partialSuccess){let e=s.results?.remote?.error||"Unknown error";u(`Local worktree deleted, but remote deletion failed: ${e}`)}n(),s.partialSuccess||i(!1)}catch(e){c(e instanceof Error?e.message:"Failed to delete worktree")}finally{o(!1)}}},f=e=>{e||(c(null),u(null)),i(e)};return(0,z.jsx)(t7,{open:s,onOpenChange:f,children:(0,z.jsxs)(rr,{children:[(0,z.jsxs)(rs,{children:[(0,z.jsx)(rn,{children:"Delete Worktree"}),(0,z.jsx)(ra,{children:"Are you sure you want to delete this worktree?"})]}),r&&(0,z.jsx)("div",{className:"space-y-2",children:(0,z.jsxs)("div",{className:"text-sm",children:[(0,z.jsx)("span",{className:"font-medium",children:"Branch:"})," ",(0,z.jsx)("span",{className:"text-muted-foreground",children:r.branch})]})}),d&&(0,z.jsx)("div",{className:"text-sm text-yellow-600 dark:text-yellow-500 bg-yellow-500/10 px-3 py-2 rounded-md",children:d}),l&&(0,z.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:l}),(0,z.jsxs)(ri,{children:[(0,z.jsx)(W.Button,{variant:"outline",onClick:()=>f(!1),disabled:a,children:"Cancel"}),(0,z.jsx)(W.Button,{variant:"destructive",onClick:h,disabled:a,children:a?"Deleting...":"Delete"})]})]})})}e.i(247755);var uf=e.i(642098);function up(){let{config:e}=(0,dr.useAppConfig)();return e?.authEnabled?(0,z.jsx)("div",{className:"flex items-center",children:(0,z.jsx)(uf.UserButton,{appearance:{elements:{avatarBox:"h-7 w-7 ring-1 ring-border/60"}}})}):null}var um=e.i(183663),ug="Collapsible",[ux,uv]=K(ug),[u_,uy]=ux(ug),ub=$.forwardRef((e,r)=>{let{__scopeCollapsible:s,open:i,defaultOpen:n,disabled:a,onOpenChange:o,...l}=e,[c,d]=G({prop:i,defaultProp:n??!1,onChange:o,caller:ug});return(0,z.jsx)(u_,{scope:s,disabled:a,contentId:ek(),open:c,onOpenToggle:$.useCallback(()=>d(e=>!e),[d]),children:(0,z.jsx)(er.div,{"data-state":uN(c),"data-disabled":a?"":void 0,...l,ref:r})})});ub.displayName=ug;var uw="CollapsibleTrigger",uS=$.forwardRef((e,r)=>{let{__scopeCollapsible:s,...i}=e,n=uy(uw,s);return(0,z.jsx)(er.button,{type:"button","aria-controls":n.contentId,"aria-expanded":n.open||!1,"data-state":uN(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...i,ref:r,onClick:q(e.onClick,n.onOpenToggle)})});uS.displayName=uw;var uC="CollapsibleContent",uj=$.forwardRef((e,r)=>{let{forceMount:s,...i}=e,n=uy(uC,e.__scopeCollapsible);return(0,z.jsx)(Z,{present:s||n.open,children:({present:e})=>(0,z.jsx)(uk,{...i,ref:r,present:e})})});uj.displayName=uC;var uk=$.forwardRef((e,r)=>{let{__scopeCollapsible:s,present:i,children:n,...a}=e,o=uy(uC,s),[l,c]=$.useState(i),d=$.useRef(null),u=(0,U.useComposedRefs)(r,d),h=$.useRef(0),f=h.current,p=$.useRef(0),m=p.current,g=o.open||l,x=$.useRef(g),v=$.useRef(void 0);return $.useEffect(()=>{let e=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(e)},[]),V(()=>{let e=d.current;if(e){v.current=v.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let r=e.getBoundingClientRect();h.current=r.height,p.current=r.width,x.current||(e.style.transitionDuration=v.current.transitionDuration,e.style.animationName=v.current.animationName),c(i)}},[o.open,i]),(0,z.jsx)(er.div,{"data-state":uN(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!g,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:g&&n})});function uN(e){return e?"open":"closed"}function uE({...e}){return(0,z.jsx)(ub,{"data-slot":"collapsible",...e})}function uD({...e}){return(0,z.jsx)(uS,{"data-slot":"collapsible-trigger",...e})}function uR({...e}){return(0,z.jsx)(uj,{"data-slot":"collapsible-content",...e})}let uA=(0,ew.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),uM=(0,ew.default)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),uF=(0,ew.default)("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),uT=(0,ew.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var uP=e.i(885101),uB=Object.defineProperty,uL=Object.getOwnPropertyDescriptor,uI=(e,r,s,i)=>{for(var n,a=i>1?void 0:i?uL(r,s):r,o=e.length-1;o>=0;o--)(n=e[o])&&(a=(i?n(r,s,a):n(a))||a);return i&&a&&uB(r,s,a),a},uO=(e,r)=>(s,i)=>r(s,i,e),uz="Terminal input",u$="Too much output to announce, navigate to rows manually to read";function uW(e,r,s,i){var n;n=e=e.replace(/\r?\n/g,"\r"),e=s.decPrivateModes.bracketedPasteMode&&!0!==i.rawOptions.ignoreBracketedPasteMode?"\x1b[200~"+n+"\x1b[201~":n,s.triggerDataEvent(e,!0),r.value=""}function uH(e,r,s){let i=s.getBoundingClientRect(),n=e.clientX-i.left-10,a=e.clientY-i.top-10;r.style.width="20px",r.style.height="20px",r.style.left=`${n}px`,r.style.top=`${a}px`,r.style.zIndex="1000",r.focus()}function uU(e,r,s,i,n){uH(e,r,s),n&&i.rightClickSelect(e),r.value=i.selectionText,r.select()}function uK(e){return e>65535?String.fromCharCode(((e-=65536)>>10)+55296)+String.fromCharCode(e%1024+56320):String.fromCharCode(e)}function uq(e,r=0,s=e.length){let i="";for(let n=r;n<s;++n){let r=e[n];r>65535?(r-=65536,i+=String.fromCharCode((r>>10)+55296)+String.fromCharCode(r%1024+56320)):i+=String.fromCharCode(r)}return i}var uV=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,r){let s=e.length;if(!s)return 0;let i=0,n=0;if(this._interim){let s=e.charCodeAt(n++);56320<=s&&s<=57343?r[i++]=(this._interim-55296)*1024+s-56320+65536:(r[i++]=this._interim,r[i++]=s),this._interim=0}for(let a=n;a<s;++a){let n=e.charCodeAt(a);if(55296<=n&&n<=56319){if(++a>=s)return this._interim=n,i;let o=e.charCodeAt(a);56320<=o&&o<=57343?r[i++]=(n-55296)*1024+o-56320+65536:(r[i++]=n,r[i++]=o);continue}65279!==n&&(r[i++]=n)}return i}},uY=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,r){let s=e.length;if(!s)return 0;let i=0,n,a,o,l,c=0,d=0;if(this.interim[0]){let n=!1,a=this.interim[0];a&=(224&a)==192?31:(240&a)==224?15:7;let o=0,l;for(;(l=63&this.interim[++o])&&o<4;)a<<=6,a|=l;let c=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,u=c-o;for(;d<u;){if(d>=s)return 0;if((192&(l=e[d++]))!=128){d--,n=!0;break}this.interim[o++]=l,a<<=6,a|=63&l}n||(2===c?a<128?d--:r[i++]=a:3===c?a<2048||a>=55296&&a<=57343||65279===a||(r[i++]=a):a<65536||a>1114111||(r[i++]=a)),this.interim.fill(0)}let u=s-4,h=d;for(;h<s;){for(;h<u&&!(128&(n=e[h]))&&!(128&(a=e[h+1]))&&!(128&(o=e[h+2]))&&!(128&(l=e[h+3]));)r[i++]=n,r[i++]=a,r[i++]=o,r[i++]=l,h+=4;if((n=e[h++])<128)r[i++]=n;else if((224&n)==192){if(h>=s)return this.interim[0]=n,i;if((192&(a=e[h++]))!=128||(c=(31&n)<<6|63&a)<128){h--;continue}r[i++]=c}else if((240&n)==224){if(h>=s)return this.interim[0]=n,i;if((192&(a=e[h++]))!=128){h--;continue}if(h>=s)return this.interim[0]=n,this.interim[1]=a,i;if((192&(o=e[h++]))!=128){h--;continue}if((c=(15&n)<<12|(63&a)<<6|63&o)<2048||c>=55296&&c<=57343||65279===c)continue;r[i++]=c}else if((248&n)==240){if(h>=s)return this.interim[0]=n,i;if((192&(a=e[h++]))!=128){h--;continue}if(h>=s)return this.interim[0]=n,this.interim[1]=a,i;if((192&(o=e[h++]))!=128){h--;continue}if(h>=s)return this.interim[0]=n,this.interim[1]=a,this.interim[2]=o,i;if((192&(l=e[h++]))!=128){h--;continue}if((c=(7&n)<<18|(63&a)<<12|(63&o)<<6|63&l)<65536||c>1114111)continue;r[i++]=c}}return i}},uG=class e{constructor(){this.fg=0,this.bg=0,this.extended=new uX}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let r=new e;return r.fg=this.fg,r.bg=this.bg,r.extended=this.extended.clone(),r}isInverse(){return 0x4000000&this.fg}isBold(){return 0x8000000&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:0x10000000&this.fg}isBlink(){return 0x20000000&this.fg}isInvisible(){return 0x40000000&this.fg}isItalic(){return 0x4000000&this.bg}isDim(){return 0x8000000&this.bg}isStrikethrough(){return 0x80000000&this.fg}isProtected(){return 0x20000000&this.bg}isOverline(){return 0x40000000&this.bg}getFgColorMode(){return 0x3000000&this.fg}getBgColorMode(){return 0x3000000&this.bg}isFgRGB(){return(0x3000000&this.fg)==0x3000000}isBgRGB(){return(0x3000000&this.bg)==0x3000000}isFgPalette(){return(0x3000000&this.fg)==0x1000000||(0x3000000&this.fg)==0x2000000}isBgPalette(){return(0x3000000&this.bg)==0x1000000||(0x3000000&this.bg)==0x2000000}isFgDefault(){return(0x3000000&this.fg)==0}isBgDefault(){return(0x3000000&this.bg)==0}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(0x3000000&this.fg){case 0x1000000:case 0x2000000:return 255&this.fg;case 0x3000000:return 0xffffff&this.fg;default:return -1}}getBgColor(){switch(0x3000000&this.bg){case 0x1000000:case 0x2000000:return 255&this.bg;case 0x3000000:return 0xffffff&this.bg;default:return -1}}hasExtendedAttrs(){return 0x10000000&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-0x10000001:this.bg|=0x10000000}getUnderlineColor(){if(0x10000000&this.bg&&~this.extended.underlineColor)switch(0x3000000&this.extended.underlineColor){case 0x1000000:case 0x2000000:return 255&this.extended.underlineColor;case 0x3000000:return 0xffffff&this.extended.underlineColor}return this.getFgColor()}getUnderlineColorMode(){return 0x10000000&this.bg&&~this.extended.underlineColor?0x3000000&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x3000000:this.isFgRGB()}isUnderlineColorPalette(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x1000000||(0x3000000&this.extended.underlineColor)==0x2000000:this.isFgPalette()}isUnderlineColorDefault(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 0x10000000&this.fg?0x10000000&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},uX=class e{constructor(e=0,r=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=r}get ext(){return this._urlId?-0x1c000001&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(0x1c000000&this._ext)>>26}set underlineStyle(e){this._ext&=-0x1c000001,this._ext|=e<<26&0x1c000000}get underlineColor(){return 0x3ffffff&this._ext}set underlineColor(e){this._ext&=-0x4000000,this._ext|=0x3ffffff&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(0xe0000000&this._ext)>>29;return e<0?0xfffffff8^e:e}set underlineVariantOffset(e){this._ext&=0x1fffffff,this._ext|=e<<29&0xe0000000}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},uJ=class e extends uG{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new uX,this.combinedData=""}static fromCharData(r){let s=new e;return s.setFromCharData(r),s}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?uK(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let r=!1;if(e[1].length>2)r=!0;else if(2===e[1].length){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let i=e[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(s-55296)*1024+i-56320+65536|e[2]<<22:r=!0}else r=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;r&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},uZ="di$target",uQ="di$dependencies",u0=new Map;function u1(e){if(u0.has(e))return u0.get(e);let r=function(e,s,i){var n,a,o;if(3!=arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");n=r,a=e,o=i,a[uZ]===a?a[uQ].push({id:n,index:o}):(a[uQ]=[{id:n,index:o}],a[uZ]=a)};return r._id=e,u0.set(e,r),r}var u2=u1("BufferService"),u5=u1("CoreMouseService"),u3=u1("CoreService"),u4=u1("CharsetService"),u6=u1("InstantiationService"),u8=u1("LogService"),u7=u1("OptionsService"),u9=u1("OscLinkService"),he=u1("UnicodeService"),ht=u1("DecorationService"),hr=class{constructor(e,r,s){this._bufferService=e,this._optionsService=r,this._oscLinkService=s}provideLinks(e,r){let s=this._bufferService.buffer.lines.get(e-1);if(!s)return void r(void 0);let i=[],n=this._optionsService.rawOptions.linkHandler,a=new uJ,o=s.getTrimmedLength(),l=-1,c=-1,d=!1;for(let r=0;r<o;r++)if(!(-1===c&&!s.hasContent(r))){if(s.loadCell(r,a),a.hasExtendedAttrs()&&a.extended.urlId)if(-1===c){c=r,l=a.extended.urlId;continue}else d=a.extended.urlId!==l;else -1!==c&&(d=!0);if(d||-1!==c&&r===o-1){let s=this._oscLinkService.getLinkData(l)?.uri;if(s){let a={start:{x:c+1,y:e},end:{x:r+ +(!d&&r===o-1),y:e}},l=!1;if(!n?.allowNonHttpProtocols)try{let e=new URL(s);["http:","https:"].includes(e.protocol)||(l=!0)}catch{l=!0}l||i.push({text:s,range:a,activate:(e,r)=>n?n.activate(e,r,a):function(e,r){if(confirm(`Do you want to navigate to ${r}?
|
|
12
|
+
|
|
13
|
+
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=r}else console.warn("Opening link blocked as opener could not be cleared")}}(0,r),hover:(e,r)=>n?.hover?.(e,r,a),leave:(e,r)=>n?.leave?.(e,r,a)})}d=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=r,l=a.extended.urlId):(c=-1,l=-1)}}r(i)}};hr=uI([uO(0,u2),uO(1,u7),uO(2,u9)],hr);var hs=u1("CharSizeService"),hi=u1("CoreBrowserService"),hn=u1("MouseService"),ha=u1("RenderService"),ho=u1("SelectionService"),hl=u1("CharacterJoinerService"),hc=u1("ThemeService"),hd=u1("LinkProviderService"),hu=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?hm.isErrorNoTelemetry(e)?new hm(e.message+`
|
|
14
|
+
|
|
15
|
+
`+e.stack):Error(e.message+`
|
|
16
|
+
|
|
17
|
+
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(r=>{r(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function hh(e){var r;(r=e)instanceof hp||r instanceof Error&&r.name===hf&&r.message===hf||hu.onUnexpectedError(e)}var hf="Canceled",hp=class extends Error{constructor(){super(hf),this.name=this.message}},hm=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(r){if(r instanceof e)return r;let s=new e;return s.message=r.message,s.stack=r.stack,s}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}},hg=class e extends Error{constructor(r){super(r||"An unexpected bug occurred."),Object.setPrototypeOf(this,e.prototype)}};function hx(e,r=0){return e[e.length-(1+r)]}(h$=hU||={}).isLessThan=function(e){return e<0},h$.isLessThanOrEqual=function(e){return e<=0},h$.isGreaterThan=function(e){return e>0},h$.isNeitherLessOrGreaterThan=function(e){return 0===e},h$.greaterThan=1,h$.lessThan=-1,h$.neitherLessOrGreaterThan=0;var hv=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(r=>(e(r),!0))}toArray(){let e=[];return this.iterate(r=>(e.push(r),!0)),e}filter(r){return new e(e=>this.iterate(s=>!r(s)||e(s)))}map(r){return new e(e=>this.iterate(s=>e(r(s))))}some(e){let r=!1;return this.iterate(s=>!(r=e(s))),r}findFirst(e){let r;return this.iterate(s=>!e(s)||(r=s,!1)),r}findLast(e){let r;return this.iterate(s=>(e(s)&&(r=s),!0)),r}findLastMaxBy(e){let r,s=!0;return this.iterate(i=>((s||hU.isGreaterThan(e(i,r)))&&(s=!1,r=i),!0)),r}};hv.empty=new hv(e=>{});function h_(e){}function hy(e,r){}function hb(e){if(hK.is(e)){let r=[];for(let s of e)if(s)try{s.dispose()}catch(e){r.push(e)}if(1===r.length)throw r[0];if(r.length>1)throw AggregateError(r,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function hw(e){let r={dispose:function(e,r){let s=this,i=!1,n;return function(){if(i)return n;if(i=!0,r)try{n=e.apply(s,arguments)}finally{r()}else n=e.apply(s,arguments);return n}}(()=>{h_(r),e()})};return r}(e=>{function r(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=r;let s=Object.freeze([]);function*i(e){yield e}e.empty=function(){return s},e.single=i,e.wrap=function(e){return r(e)?e:i(e)},e.from=function(e){return e||s},e.reverse=function*(e){for(let r=e.length-1;r>=0;r--)yield e[r]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,r){let s=0;for(let i of e)if(r(i,s++))return!0;return!1},e.find=function(e,r){for(let s of e)if(r(s))return s},e.filter=function*(e,r){for(let s of e)r(s)&&(yield s)},e.map=function*(e,r){let s=0;for(let i of e)yield r(i,s++)},e.flatMap=function*(e,r){let s=0;for(let i of e)yield*r(i,s++)},e.concat=function*(...e){for(let r of e)yield*r},e.reduce=function(e,r,s){let i=s;for(let s of e)i=r(i,s);return i},e.slice=function*(e,r,s=e.length){for(r<0&&(r+=e.length),s<0?s+=e.length:s>e.length&&(s=e.length);r<s;r++)yield e[r]},e.consume=function(r,s=1/0){let i=[];if(0===s)return[i,r];let n=r[Symbol.iterator]();for(let r=0;r<s;r++){let r=n.next();if(r.done)return[i,e.empty()];i.push(r.value)}return[i,{[Symbol.iterator]:()=>n}]},e.asyncToArray=async function(e){let r=[];for await(let s of e)r.push(s);return Promise.resolve(r)}})(hK||={});var hS=class e{constructor(){var e;this._toDispose=new Set,this._isDisposed=!1,e=this}dispose(){this._isDisposed||(h_(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{hb(this._toDispose)}finally{this._toDispose.clear()}}add(r){if(!r)return r;if(r===this)throw Error("Cannot register a disposable on itself!");return hy(r,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(r),r}delete(e){if(e){if(e===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),hy(e,null))}};hS.DISABLE_DISPOSED_WARNING=!1;var hC=hS,hj=class{constructor(){var e;this._store=new hC,e=this,hy(this._store,this)}dispose(){h_(this),this._store.dispose()}_register(e){if(e===this)throw Error("Cannot register a disposable on itself!");return this._store.add(e)}};hj.None=Object.freeze({dispose(){}});var hk=class{constructor(){var e;this._isDisposed=!1,e=this}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&hy(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,h_(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&hy(e,null),e}},hN="object"==typeof window?window:globalThis,hE=class e{constructor(r){this.element=r,this.next=e.Undefined,this.prev=e.Undefined}};hE.Undefined=new hE(void 0);var hD=class{constructor(){this._first=hE.Undefined,this._last=hE.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===hE.Undefined}clear(){let e=this._first;for(;e!==hE.Undefined;){let r=e.next;e.prev=hE.Undefined,e.next=hE.Undefined,e=r}this._first=hE.Undefined,this._last=hE.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,r){let s=new hE(e);if(this._first===hE.Undefined)this._first=s,this._last=s;else if(r){let e=this._last;this._last=s,s.prev=e,e.next=s}else{let e=this._first;this._first=s,s.next=e,e.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==hE.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==hE.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==hE.Undefined&&e.next!==hE.Undefined){let r=e.prev;r.next=e.next,e.next.prev=r}else e.prev===hE.Undefined&&e.next===hE.Undefined?(this._first=hE.Undefined,this._last=hE.Undefined):e.next===hE.Undefined?(this._last=this._last.prev,this._last.next=hE.Undefined):e.prev===hE.Undefined&&(this._first=this._first.next,this._first.prev=hE.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==hE.Undefined;)yield e.element,e=e.next}},hR=globalThis.performance&&"function"==typeof globalThis.performance.now,hA=class e{static create(r){return new e(r)}constructor(e){this._now=hR&&!1===e?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return -1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function r(e){}function s(e){return(r,s=null,i)=>{let n=!1,a;return a=e(e=>{if(!n)return a?a.dispose():n=!0,r.call(s,e)},null,i),n&&a.dispose(),a}}function i(e,r,s){return a((s,i=null,n)=>e(e=>s.call(i,r(e)),null,n),s)}function n(e,r,s){return a((s,i=null,n)=>e(e=>r(e)&&s.call(i,e),null,n),s)}function a(e,s){let i,n={onWillAddFirstListener(){i=e(a.fire,a)},onDidRemoveLastListener(){i?.dispose()}};s||r(n);let a=new hQ(n);return s?.add(a),a.event}function o(e,s,i=100,n=!1,a=!1,l,c){let d,u,h,f=0,p,m={leakWarningThreshold:l,onWillAddFirstListener(){d=e(e=>{f++,u=s(u,e),n&&!h&&(g.fire(u),u=void 0),p=()=>{let e=u;u=void 0,h=void 0,(!n||f>1)&&g.fire(e),f=0},"number"==typeof i?(clearTimeout(h),h=setTimeout(p,i)):void 0===h&&(h=0,queueMicrotask(p))})},onWillRemoveListener(){a&&f>0&&p?.()},onDidRemoveLastListener(){p=void 0,d.dispose()}};c||r(m);let g=new hQ(m);return c?.add(g),g.event}e.None=()=>hj.None,e.defer=function(e,r){return o(e,()=>{},0,void 0,!0,void 0,r)},e.once=s,e.map=i,e.forEach=function(e,r,s){return a((s,i=null,n)=>e(e=>{r(e),s.call(i,e)},null,n),s)},e.filter=n,e.signal=function(e){return e},e.any=function(...e){return(r,s=null,i)=>{var n,a;return n=function(...e){var r,s;let i=hw(()=>hb(e));return r=0,s=0,i}(...e.map(e=>e(e=>r.call(s,e)))),(a=i)instanceof Array?a.push(n):a&&a.add(n),n}},e.reduce=function(e,r,s,n){let a=s;return i(e,e=>a=r(a,e),n)},e.debounce=o,e.accumulate=function(r,s=0,i){return e.debounce(r,(e,r)=>e?(e.push(r),e):[r],s,void 0,!0,void 0,i)},e.latch=function(e,r=(e,r)=>e===r,s){let i=!0,a;return n(e,e=>{let s=i||!r(e,a);return i=!1,a=e,s},s)},e.split=function(r,s,i){return[e.filter(r,s,i),e.filter(r,e=>!s(e),i)]},e.buffer=function(e,r=!1,s=[],i){let n=s.slice(),a=e(e=>{n?n.push(e):l.fire(e)});i&&i.add(a);let o=()=>{n?.forEach(e=>l.fire(e)),n=null},l=new hQ({onWillAddFirstListener(){a||(a=e(e=>l.fire(e)),i&&i.add(a))},onDidAddFirstListener(){n&&(r?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return i&&i.add(l),l.event},e.chain=function(e,r){return(s,i,n)=>{let a=r(new c);return e(function(e){let r=a.evaluate(e);r!==l&&s.call(i,r)},void 0,n)}};let l=Symbol("HaltChainable");class c{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(r=>(e(r),r)),this}filter(e){return this.steps.push(r=>e(r)?r:l),this}reduce(e,r){let s=r;return this.steps.push(r=>s=e(s,r)),this}latch(e=(e,r)=>e===r){let r=!0,s;return this.steps.push(i=>{let n=r||!e(i,s);return r=!1,s=i,n?i:l}),this}evaluate(e){for(let r of this.steps)if((e=r(e))===l)break;return e}}e.fromNodeEventEmitter=function(e,r,s=e=>e){let i=(...e)=>n.fire(s(...e)),n=new hQ({onWillAddFirstListener:()=>e.on(r,i),onDidRemoveLastListener:()=>e.removeListener(r,i)});return n.event},e.fromDOMEventEmitter=function(e,r,s=e=>e){let i=(...e)=>n.fire(s(...e)),n=new hQ({onWillAddFirstListener:()=>e.addEventListener(r,i),onDidRemoveLastListener:()=>e.removeEventListener(r,i)});return n.event},e.toPromise=function(e){return new Promise(r=>s(e)(r))},e.fromPromise=function(e){let r=new hQ;return e.then(e=>{r.fire(e)},()=>{r.fire(void 0)}).finally(()=>{r.dispose()}),r.event},e.forward=function(e,r){return e(e=>r.fire(e))},e.runAndSubscribe=function(e,r,s){return r(s),e(e=>r(e))};class d{constructor(e,s){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};s||r(i),this.emitter=new hQ(i),s&&s.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,r){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,r){return new d(e,r).emitter.event},e.fromObservableLight=function(e){return(r,s,i)=>{let n=0,a=!1,o={beginUpdate(){n++},endUpdate(){0==--n&&(e.reportChanges(),a&&(a=!1,r.call(s)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let l={dispose(){e.removeObserver(o)}};return i instanceof hC?i.add(l):Array.isArray(i)&&i.push(l),l}}})(hq||={});var hM=class e{constructor(r){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${r}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new hA,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};hM.all=new Set,hM._idPool=0;var hF=class e{constructor(r,s,i=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=r,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,r){let s=this.threshold;if(s<=0||r<s)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*s;let[e,i]=this.getMostFrequentStack(),n=`[${this.name}] potential listener LEAK detected, having ${r} listeners already. MOST frequent listener (${i}):`;console.warn(n),console.warn(e);let a=new hG(n,e);this._errorHandler(a)}return()=>{let r=this._stacks.get(e.value)||0;this._stacks.set(e.value,r-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,r=0;for(let[s,i]of this._stacks)(!e||r<i)&&(e=[s,i],r=i);return e}};hF._idPool=1;var hT,hP,hB,hL,hI,hO,hz,h$,hW,hH,hU,hK,hq,hV,hY=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??"")}print(){console.warn(this.value.split(`
|
|
18
|
+
`).slice(2).join(`
|
|
19
|
+
`))}},hG=class extends Error{constructor(e,r){super(e),this.name="ListenerLeakError",this.stack=r}},hX=class extends Error{constructor(e,r){super(e),this.name="ListenerRefusalError",this.stack=r}},hJ=0,hZ=class{constructor(e){this.value=e,this.id=hJ++}},hQ=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new hF(e?.onListenerError??hh,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new hM(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,r,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let r=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],s=new hX(`${e}. HINT: Stack shows most frequent listener (${r[1]}-times)`,r[0]);return(this._options?.onListenerError||hh)(s),hj.None}if(this._disposed)return hj.None;r&&(e=e.bind(r));let i=new hZ(e),n;this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(i.stack=hY.create(),n=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof hZ?(this._deliveryQueue??=new h0,this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=hw(()=>{hV?.unregister(a),n?.(),this._removeListener(i)});if(s instanceof hC?s.add(a):Array.isArray(s)&&s.push(a),hV){let e=Error().stack.split(`
|
|
20
|
+
`).slice(2,3).join(`
|
|
21
|
+
`).trim(),r=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);hV.register(a,r?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let r=this._listeners,s=r.indexOf(e);if(-1===s)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,r[s]=void 0;let i=this._deliveryQueue.current===this;if(2*this._size<=r.length){let e=0;for(let s=0;s<r.length;s++)r[s]?r[e++]=r[s]:i&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);r.length=e}}_deliver(e,r){if(!e)return;let s=this._options?.onListenerError||hh;try{e.value(r)}catch(e){s(e)}}_deliverQueue(e){let r=e.current._listeners;for(;e.i<e.end;)this._deliver(r[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof hZ)this._deliver(this._listeners,e);else{let r=this._deliveryQueue;r.enqueue(this,e,this._listeners.length),this._deliverQueue(r)}this._perfMon?.stop()}hasListeners(){return this._size>0}},h0=class{constructor(){this.i=-1,this.end=0}enqueue(e,r,s){this.i=0,this.end=s,this.current=e,this.value=r}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},h1=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new hQ,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new hQ,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,r){if(this.getZoomLevel(r)===e)return;let s=this.getWindowId(r);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,r){this.mapWindowIdToZoomFactor.set(this.getWindowId(r),e)}setFullscreen(e,r){if(this.isFullscreen(r)===e)return;let s=this.getWindowId(r);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};h1.INSTANCE=new h1,h1.INSTANCE.onDidChangeZoomLevel,h1.INSTANCE.onDidChangeFullscreen;var h2="object"==typeof navigator?navigator.userAgent:"",h5=h2.indexOf("Firefox")>=0,h3=h2.indexOf("AppleWebKit")>=0,h4=h2.indexOf("Chrome")>=0,h6=!h4&&h2.indexOf("Safari")>=0;h2.indexOf("Electron/"),h2.indexOf("Android");var h8=!1;if("function"==typeof hN.matchMedia){let e=hN.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),r=hN.matchMedia("(display-mode: fullscreen)");h8=e.matches,h7=e,"string"==typeof h7&&(h7=hN.matchMedia(h7)),h7.addEventListener("change",({matches:e})=>{h8&&r.matches||(h8=e)})}var h7,h9,fe,ft=!1,fr=!1,fs=!1,fi=!1,fn=!1,fa="en",fo=globalThis;"u">typeof fo.vscode&&"u">typeof fo.vscode.process?fe=fo.vscode.process:"u">typeof uP.default&&"string"==typeof uP.default?.versions?.node&&(fe=uP.default);var fl="string"==typeof fe?.versions?.electron&&fe?.type==="renderer";if("object"==typeof fe){ft="win32"===fe.platform,fr="darwin"===fe.platform,(fs="linux"===fe.platform)&&fe.env.SNAP&&fe.env.SNAP_REVISION,fe.env.CI||fe.env.BUILD_ARTIFACTSTAGINGDIRECTORY,fa="en";let e=fe.env.VSCODE_NLS_CONFIG;if(e)try{let r=JSON.parse(e);r.userLocale,r.osLocale,fa=r.resolvedLanguage||"en",r.languagePack?.translationsConfigFile}catch{}fi=!0}else"object"!=typeof navigator||fl?console.error("Unable to resolve platform."):(ft=(h9=navigator.userAgent).indexOf("Windows")>=0,fr=h9.indexOf("Macintosh")>=0,(h9.indexOf("Macintosh")>=0||h9.indexOf("iPad")>=0||h9.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,fs=h9.indexOf("Linux")>=0,h9?.indexOf("Mobi"),fn=!0,fa=globalThis._VSCODE_NLS_LANGUAGE||"en",navigator.language.toLowerCase());var fc=ft,fd=fr,fu=fs,fh=fi;fn&&"function"==typeof fo.importScripts&&fo.origin;var ff,fp=h9,fm=fa;(fj=ff||={}).value=function(){return fm},fj.isDefaultVariant=function(){return 2===fm.length?"en"===fm:fm.length>=3&&"e"===fm[0]&&"n"===fm[1]&&"-"===fm[2]},fj.isDefault=function(){return"en"===fm};var fg="function"==typeof fo.postMessage&&!fo.importScripts,fx=(()=>{if(fg){let e=[];fo.addEventListener("message",r=>{if(r.data&&r.data.vscodeScheduleAsyncWork)for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.id===r.data.vscodeScheduleAsyncWork){e.splice(s,1),i.callback();return}}});let r=0;return s=>{let i=++r;e.push({id:i,callback:s}),fo.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})(),fv=!!(fp&&fp.indexOf("Chrome")>=0);fp&&fp.indexOf("Firefox"),!fv&&fp&&fp.indexOf("Safari"),fp&&fp.indexOf("Edg/"),fp&&fp.indexOf("Android");var f_="object"==typeof navigator?navigator:{};fh||document.queryCommandSupported&&document.queryCommandSupported("copy")||f_&&f_.clipboard&&f_.clipboard.writeText,fh||f_&&f_.clipboard&&f_.clipboard.readText,fh||h8||f_.keyboard,"ontouchstart"in hN||f_.maxTouchPoints,hN.PointerEvent&&("ontouchstart"in hN||navigator.maxTouchPoints);var fy=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,r){this._keyCodeToStr[e]=r,this._strToKeyCode[r.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},fb=new fy,fw=new fy,fS=new fy,fC=Array(230);(fk=fN||={}).toString=function(e){return fb.keyCodeToStr(e)},fk.fromString=function(e){return fb.strToKeyCode(e)},fk.toUserSettingsUS=function(e){return fw.keyCodeToStr(e)},fk.toUserSettingsGeneral=function(e){return fS.keyCodeToStr(e)},fk.fromUserSettings=function(e){return fw.strToKeyCode(e)||fS.strToKeyCode(e)},fk.toElectronAccelerator=function(e){if(e>=98&&e<=113)return null;switch(e){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return fb.keyCodeToStr(e)};var fj,fk,fN,fE,fD=class e{constructor(e,r,s,i,n){this.ctrlKey=e,this.shiftKey=r,this.altKey=s,this.metaKey=i,this.keyCode=n}equals(r){return r instanceof e&&this.ctrlKey===r.ctrlKey&&this.shiftKey===r.shiftKey&&this.altKey===r.altKey&&this.metaKey===r.metaKey&&this.keyCode===r.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",r=this.shiftKey?"1":"0",s=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${e}${r}${s}${i}${this.keyCode}`}isModifierKey(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode}toKeybinding(){return new fR([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},fR=class{constructor(e){if(0===e.length)throw function(e){return e?Error(`Illegal argument: ${e}`):Error("Illegal argument")}("chords");this.chords=e}getHashCode(){let e="";for(let r=0,s=this.chords.length;r<s;r++)0!==r&&(e+=";"),e+=this.chords[r].getHashCode();return e}equals(e){if(null===e||this.chords.length!==e.chords.length)return!1;for(let r=0;r<this.chords.length;r++)if(!this.chords[r].equals(e.chords[r]))return!1;return!0}},fA=fd?256:2048,fM=fd?2048:256,fF=class{constructor(e){this._standardKeyboardEventBrand=!0,this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=function(e){if(e.charCode){let r=String.fromCharCode(e.charCode).toUpperCase();return fN.fromString(r)}let r=e.keyCode;if(3===r)return 7;if(h5)switch(r){case 59:return 85;case 60:if(fu)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(fd)return 57}else if(h3&&(fd&&93===r||!fd&&92===r))return 57;return fC[r]||0}(e),this.code=e.code,this.ctrlKey=this.ctrlKey||5===this.keyCode,this.altKey=this.altKey||6===this.keyCode,this.shiftKey=this.shiftKey||4===this.keyCode,this.metaKey=this.metaKey||57===this.keyCode,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode);let r=0;return this.ctrlKey&&(r|=fA),this.altKey&&(r|=512),this.shiftKey&&(r|=1024),this.metaKey&&(r|=fM),r|=e}_computeKeyCodeChord(){let e=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode),new fD(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},fT=new WeakMap,fP=class{static getSameOriginWindowChain(e){let r=fT.get(e);if(!r){r=[],fT.set(e,r);let s=e,i;do(i=function(e){if(!e.parent||e.parent===e)return null;try{let r=e.location,s=e.parent.location;if("null"!==r.origin&&"null"!==s.origin&&r.origin!==s.origin)return null}catch{return null}return e.parent}(s))?r.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):r.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return r.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,r){if(!r||e===r)return{top:0,left:0};let s=0,i=0;for(let n of this.getSameOriginWindowChain(e)){let e=n.window.deref();if(s+=e?.scrollY??0,i+=e?.scrollX??0,e===r||!n.iframeElement)break;let a=n.iframeElement.getBoundingClientRect();s+=a.top,i+=a.left}return{top:s,left:i}}},fB=class{constructor(e,r){this.timestamp=Date.now(),this.browserEvent=r,this.leftButton=0===r.button,this.middleButton=1===r.button,this.rightButton=2===r.button,this.buttons=r.buttons,this.target=r.target,this.detail=r.detail||1,"dblclick"===r.type&&(this.detail=2),this.ctrlKey=r.ctrlKey,this.shiftKey=r.shiftKey,this.altKey=r.altKey,this.metaKey=r.metaKey,"number"==typeof r.pageX?(this.posx=r.pageX,this.posy=r.pageY):(this.posx=r.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=r.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=fP.getPositionOfChildWindowRelativeToAncestorWindow(e,r.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},fL=class{constructor(e,r=0,s=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=r;let i=!1;if(h4){let e=navigator.userAgent.match(/Chrome\/(\d+)/);i=(e?parseInt(e[1]):123)<=122}if(e){let r=e.view?.devicePixelRatio||1;"u">typeof e.wheelDeltaY?i?this.deltaY=e.wheelDeltaY/(120*r):this.deltaY=e.wheelDeltaY/120:"u">typeof e.VERTICAL_AXIS&&e.axis===e.VERTICAL_AXIS?this.deltaY=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?h5&&!fd?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40),"u">typeof e.wheelDeltaX?h6&&fc?this.deltaX=-(e.wheelDeltaX/120):i?this.deltaX=e.wheelDeltaX/(120*r):this.deltaX=e.wheelDeltaX/120:"u">typeof e.HORIZONTAL_AXIS&&e.axis===e.HORIZONTAL_AXIS?this.deltaX=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?h5&&!fd?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40),0===this.deltaY&&0===this.deltaX&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*r):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},fI=Object.freeze(function(e,r){let s=setTimeout(e.bind(r),0);return{dispose(){clearTimeout(s)}}});(pE=fE||={}).isCancellationToken=function(e){return e===pE.None||e===pE.Cancelled||e instanceof fO||!!e&&"object"==typeof e&&"boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested},pE.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:hq.None}),pE.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:fI});var fO=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?fI:(this._emitter||(this._emitter=new hQ),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};Symbol("MicrotaskDelay");var fz=class{constructor(e,r){this._isDisposed=!1,this._token=-1,"function"==typeof e&&"number"==typeof r&&this.setIfNotSet(e,r)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){-1!==this._token&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,r){if(this._isDisposed)throw new hg("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},r)}setIfNotSet(e,r){if(this._isDisposed)throw new hg("Calling 'setIfNotSet' on a disposed TimeoutTimer");-1===this._token&&(this._token=setTimeout(()=>{this._token=-1,e()},r))}},f$=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,r,s=globalThis){if(this.isDisposed)throw new hg("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},r);this.disposable=hw(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(pD=pR||={}).settled=async function(e){let r,s=await Promise.all(e.map(e=>e.then(e=>e,e=>{r||(r=e)})));if("u">typeof r)throw r;return s},pD.withAsyncBody=function(e){return new Promise(async(r,s)=>{try{await e(r,s)}catch(e){s(e)}})};var fW=class e{static fromArray(r){return new e(e=>{e.emitMany(r)})}static fromPromise(r){return new e(async e=>{e.emitMany(await r)})}static fromPromises(r){return new e(async e=>{await Promise.all(r.map(async r=>e.emitOne(await r)))})}static merge(r){return new e(async e=>{await Promise.all(r.map(async r=>{for await(let s of r)e.emitOne(s)}))})}constructor(e,r){this._state=0,this._results=[],this._error=null,this._onReturn=r,this._onStateChanged=new hQ,queueMicrotask(async()=>{let r={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(r)),this.resolve()}catch(e){this.reject(e)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await hq.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(r,s){return new e(async e=>{for await(let i of r)e.emitOne(s(i))})}map(r){return e.map(this,r)}static filter(r,s){return new e(async e=>{for await(let i of r)s(i)&&e.emitOne(i)})}filter(r){return e.filter(this,r)}static coalesce(r){return e.filter(r,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let r=[];for await(let s of e)r.push(s);return r}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};fW.EMPTY=fW.fromArray([]);function fH(e,r){return(r<<5)-r+e|0}function fU(e,r){r=fH(149417,r);for(let s=0,i=e.length;s<i;s++)r=fH(e.charCodeAt(s),r);return r}new DataView(new ArrayBuffer(320));var{registerWindow:fK,getWindow:fq,getDocument:fV,getWindows:fY,getWindowsCount:fG,getWindowId:fX,getWindowById:fJ,hasWindow:fZ,onDidRegisterWindow:fQ,onWillUnregisterWindow:f0,onDidUnregisterWindow:f1}=(n=new Map,a={window:hN,disposables:new hC},n.set(hN.vscodeWindowId,a),o=new hQ,l=new hQ,c=new hQ,{onDidRegisterWindow:o.event,onWillUnregisterWindow:c.event,onDidUnregisterWindow:l.event,registerWindow(e){if(n.has(e.vscodeWindowId))return hj.None;let r=new hC,s={window:e,disposables:r.add(new hC)};return n.set(e.vscodeWindowId,s),r.add(hw(()=>{n.delete(e.vscodeWindowId),l.fire(e)})),r.add(f5(e,f7.BEFORE_UNLOAD,()=>{c.fire(e)})),o.fire(s),r},getWindows:()=>n.values(),getWindowsCount:()=>n.size,getWindowId:e=>e.vscodeWindowId,hasWindow:e=>n.has(e),getWindowById:function(e,r){return("number"==typeof e?n.get(e):void 0)??(r?a:void 0)},getWindow:e=>e?.ownerDocument?.defaultView?e.ownerDocument.defaultView.window:e?.view?e.view.window:hN,getDocument:e=>fq(e).document}),f2=class{constructor(e,r,s,i){this._node=e,this._type=r,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function f5(e,r,s,i){return new f2(e,r,s,i)}var f3=function(e,r,s,i){var n;let a=s;return"click"===r||"mousedown"===r||"contextmenu"===r?(n=fq(e),a=function(e){return s(new fB(n,e))}):("keydown"===r||"keypress"===r||"keyup"===r)&&(a=function(e){return s(new fF(e))}),f5(e,r,a,i)},f4=class extends f${constructor(e){super(),this.defaultTarget=e&&fq(e)}cancelAndSet(e,r,s){return super.cancelAndSet(e,r,s??this.defaultTarget)}},f6=class{constructor(e,r=0){this._runner=e,this.priority=r,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){hh(e)}}static sort(e,r){return r.priority-e.priority}};d=new Map,u=new Map,h=new Map,f=new Map,pA=(e,r,s=0)=>{let i=fX(e),n=new f6(r,s),a=d.get(i);return a||(a=[],d.set(i,a)),a.push(n),h.get(i)||(h.set(i,!0),e.requestAnimationFrame(()=>(e=>{h.set(e,!1);let r=d.get(e)??[];for(u.set(e,r),d.set(e,[]),f.set(e,!0);r.length>0;)r.sort(f6.sort),r.shift().execute();f.set(e,!1)})(i))),n};var f8=class e{constructor(e,r){this.width=e,this.height=r}with(r=this.width,s=this.height){return r!==this.width||s!==this.height?new e(r,s):this}static is(e){return"object"==typeof e&&"number"==typeof e.height&&"number"==typeof e.width}static lift(r){return r instanceof e?r:new e(r.width,r.height)}static equals(e,r){return e===r||!!e&&!!r&&e.width===r.width&&e.height===r.height}};f8.None=new f8(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,r,s){let i=this.mutationObservers.get(e);i||(i=new Map,this.mutationObservers.set(e,i));let n=function e(r,s){switch(typeof r){case"object":var i,n,a,o;return null===r?fH(349,s):Array.isArray(r)?(i=r,n=fH(104579,n=s),i.reduce((r,s)=>e(s,r),n)):(a=r,o=fH(181387,o=s),Object.keys(a).sort().reduce((r,s)=>(r=fU(s,r),e(a[s],r)),o));case"string":return fU(r,s);case"boolean":return fH(r?433:863,s);case"number":return fH(r,s);case"undefined":return fH(937,s);default:return fH(617,s)}}(s,0),a=i.get(n);if(a)a.users+=1;else{let o=new hQ,l=new MutationObserver(e=>o.fire(e));l.observe(e,s);let c=a={users:1,observer:l,onDidMutate:o.event};r.add(hw(()=>{c.users-=1,0===c.users&&(o.dispose(),l.disconnect(),i?.delete(n),i?.size===0&&this.mutationObservers.delete(e))})),i.set(n,a)}return a.onDidMutate}};var f7={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},f9=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let r=pe(e);this._maxWidth!==r&&(this._maxWidth=r,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let r=pe(e);this._width!==r&&(this._width=r,this.domNode.style.width=this._width)}setHeight(e){let r=pe(e);this._height!==r&&(this._height=r,this.domNode.style.height=this._height)}setTop(e){let r=pe(e);this._top!==r&&(this._top=r,this.domNode.style.top=this._top)}setLeft(e){let r=pe(e);this._left!==r&&(this._left=r,this.domNode.style.left=this._left)}setBottom(e){let r=pe(e);this._bottom!==r&&(this._bottom=r,this.domNode.style.bottom=this._bottom)}setRight(e){let r=pe(e);this._right!==r&&(this._right=r,this.domNode.style.right=this._right)}setPaddingTop(e){let r=pe(e);this._paddingTop!==r&&(this._paddingTop=r,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let r=pe(e);this._paddingLeft!==r&&(this._paddingLeft=r,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let r=pe(e);this._paddingBottom!==r&&(this._paddingBottom=r,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let r=pe(e);this._paddingRight!==r&&(this._paddingRight=r,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let r=pe(e);this._fontSize!==r&&(this._fontSize=r,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let r=pe(e);this._lineHeight!==r&&(this._lineHeight=r,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let r=pe(e);this._letterSpacing!==r&&(this._letterSpacing=r,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,r){this.domNode.classList.toggle(e,r),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,r){this.domNode.setAttribute(e,r)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function pe(e){return"number"==typeof e?`${e}px`:e}function pt(e){return new f9(e)}var pr=class{constructor(){this._hooks=new hC,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,r){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(r)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,r,s,i,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=n;let a=e;try{e.setPointerCapture(r),this._hooks.add(hw(()=>{try{e.releasePointerCapture(r)}catch{}}))}catch{a=fq(e)}this._hooks.add(f5(a,f7.POINTER_MOVE,e=>{e.buttons!==s?this.stopMonitoring(!0):(e.preventDefault(),this._pointerMoveCallback(e))})),this._hooks.add(f5(a,f7.POINTER_UP,e=>this.stopMonitoring(!0)))}};(p=pM||={}).Tap="-xterm-gesturetap",p.Change="-xterm-gesturechange",p.Start="-xterm-gesturestart",p.End="-xterm-gesturesend",p.Contextmenu="-xterm-gesturecontextmenu";var ps=class e extends hj{constructor(){super(),this.dispatched=!1,this.targets=new hD,this.ignoreTargets=new hD,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(hq.runAndSubscribe(fQ,({window:e,disposables:r})=>{r.add(f5(e.document,"touchstart",e=>this.onTouchStart(e),{passive:!1})),r.add(f5(e.document,"touchend",r=>this.onTouchEnd(e,r))),r.add(f5(e.document,"touchmove",e=>this.onTouchMove(e),{passive:!1}))},{window:hN,disposables:this._store}))}static addTarget(r){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),hw(e.INSTANCE.targets.push(r))):hj.None}static ignoreTarget(r){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),hw(e.INSTANCE.ignoreTargets.push(r))):hj.None}static isTouchDevice(){return"ontouchstart"in hN||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let r=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,i=e.targetTouches.length;s<i;s++){let i=e.targetTouches.item(s);this.activeTouches[i.identifier]={id:i.identifier,initialTarget:i.target,initialTimeStamp:r,initialPageX:i.pageX,initialPageY:i.pageY,rollingTimestamps:[r],rollingPageX:[i.pageX],rollingPageY:[i.pageY]};let n=this.newGestureEvent(pM.Start,i.target);n.pageX=i.pageX,n.pageY=i.pageY,this.dispatchEvent(n)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(r,s){let i=Date.now(),n=Object.keys(this.activeTouches).length;for(let a=0,o=s.changedTouches.length;a<o;a++){let o=s.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("move of an UNKNOWN touch",o);continue}let l=this.activeTouches[o.identifier],c=Date.now()-l.initialTimeStamp;if(c<e.HOLD_DELAY&&30>Math.abs(l.initialPageX-hx(l.rollingPageX))&&30>Math.abs(l.initialPageY-hx(l.rollingPageY))){let e=this.newGestureEvent(pM.Tap,l.initialTarget);e.pageX=hx(l.rollingPageX),e.pageY=hx(l.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&30>Math.abs(l.initialPageX-hx(l.rollingPageX))&&30>Math.abs(l.initialPageY-hx(l.rollingPageY))){let e=this.newGestureEvent(pM.Contextmenu,l.initialTarget);e.pageX=hx(l.rollingPageX),e.pageY=hx(l.rollingPageY),this.dispatchEvent(e)}else if(1===n){let e=hx(l.rollingPageX),s=hx(l.rollingPageY),n=hx(l.rollingTimestamps)-l.rollingTimestamps[0],a=e-l.rollingPageX[0],o=s-l.rollingPageY[0],c=[...this.targets].filter(e=>l.initialTarget instanceof Node&&e.contains(l.initialTarget));this.inertia(r,c,i,Math.abs(a)/n,a>0?1:-1,e,Math.abs(o)/n,o>0?1:-1,s)}this.dispatchEvent(this.newGestureEvent(pM.End,l.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,r){let s=document.createEvent("CustomEvent");return s.initEvent(e,!1,!0),s.initialTarget=r,s.tapCount=0,s}dispatchEvent(r){if(r.type===pM.Tap){let s=new Date().getTime(),i=0;i=s-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=s,r.tapCount=i}else(r.type===pM.Change||r.type===pM.Contextmenu)&&(this._lastSetTapCountTime=0);if(r.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(r.initialTarget))return;let e=[];for(let s of this.targets)if(s.contains(r.initialTarget)){let i=0,n=r.initialTarget;for(;n&&n!==s;)i++,n=n.parentElement;e.push([i,s])}for(let[s,i]of(e.sort((e,r)=>e[0]-r[0]),e))i.dispatchEvent(r),this.dispatched=!0}}inertia(r,s,i,n,a,o,l,c,d){this.handle=pA(r,()=>{let u=Date.now(),h=u-i,f=0,p=0,m=!0;n+=e.SCROLL_FRICTION*h,l+=e.SCROLL_FRICTION*h,n>0&&(m=!1,f=a*n*h),l>0&&(m=!1,p=c*l*h);let g=this.newGestureEvent(pM.Change);g.translationX=f,g.translationY=p,s.forEach(e=>e.dispatchEvent(g)),m||this.inertia(r,s,u,n,a,o+f,l,c,d+p)})}onTouchMove(e){let r=Date.now();for(let s=0,i=e.changedTouches.length;s<i;s++){let i=e.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(i.identifier))){console.warn("end of an UNKNOWN touch",i);continue}let n=this.activeTouches[i.identifier],a=this.newGestureEvent(pM.Change,n.initialTarget);a.translationX=i.pageX-hx(n.rollingPageX),a.translationY=i.pageY-hx(n.rollingPageY),a.pageX=i.pageX,a.pageY=i.pageY,this.dispatchEvent(a),n.rollingPageX.length>3&&(n.rollingPageX.shift(),n.rollingPageY.shift(),n.rollingTimestamps.shift()),n.rollingPageX.push(i.pageX),n.rollingPageY.push(i.pageY),n.rollingTimestamps.push(r)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};ps.SCROLL_FRICTION=-.005,ps.HOLD_DELAY=700,ps.CLEAR_TAP_COUNT_TIME=400,uI([function(e,r,s){let i=null,n=null;if("function"==typeof s.value?(i="value",0!==(n=s.value).length&&console.warn("Memoize should only be used in functions with zero parameters")):"function"==typeof s.get&&(i="get",n=s.get),!n)throw Error("not supported");let a=`$memoize$${r}`;s[i]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:n.apply(this,e)}),this[a]}}],ps,"isTouchDevice",1);var pi=class extends hj{onclick(e,r){this._register(f5(e,f7.CLICK,s=>r(new fB(fq(e),s))))}onmousedown(e,r){this._register(f5(e,f7.MOUSE_DOWN,s=>r(new fB(fq(e),s))))}onmouseover(e,r){this._register(f5(e,f7.MOUSE_OVER,s=>r(new fB(fq(e),s))))}onmouseleave(e,r){this._register(f5(e,f7.MOUSE_LEAVE,s=>r(new fB(fq(e),s))))}onkeydown(e,r){this._register(f5(e,f7.KEY_DOWN,e=>r(new fF(e))))}onkeyup(e,r){this._register(f5(e,f7.KEY_UP,e=>r(new fF(e))))}oninput(e,r){this._register(f5(e,f7.INPUT,r))}onblur(e,r){this._register(f5(e,f7.BLUR,r))}onfocus(e,r){this._register(f5(e,f7.FOCUS,r))}onchange(e,r){this._register(f5(e,f7.CHANGE,r))}ignoreGesture(e){return ps.ignoreTarget(e)}},pn=class extends pi{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px","u">typeof e.top&&(this.bgDomNode.style.top="0px"),"u">typeof e.left&&(this.bgDomNode.style.left="0px"),"u">typeof e.bottom&&(this.bgDomNode.style.bottom="0px"),"u">typeof e.right&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width="11px",this.domNode.style.height="11px","u">typeof e.top&&(this.domNode.style.top=e.top+"px"),"u">typeof e.left&&(this.domNode.style.left=e.left+"px"),"u">typeof e.bottom&&(this.domNode.style.bottom=e.bottom+"px"),"u">typeof e.right&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new pr),this._register(f3(this.bgDomNode,f7.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(f3(this.domNode,f7.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new f4),this._pointerdownScheduleRepeatTimer=this._register(new fz)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let r=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,fq(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(r,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},pa=class e{constructor(e,r,s,i,n,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(r|=0,s|=0,i|=0,n|=0,a|=0,o|=0),this.rawScrollLeft=i,this.rawScrollTop=o,r<0&&(r=0),i+r>s&&(i=s-r),i<0&&(i=0),n<0&&(n=0),o+n>a&&(o=a-n),o<0&&(o=0),this.width=r,this.scrollWidth=s,this.scrollLeft=i,this.height=n,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(r,s){return new e(this._forceIntegerValues,"u">typeof r.width?r.width:this.width,"u">typeof r.scrollWidth?r.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,"u">typeof r.height?r.height:this.height,"u">typeof r.scrollHeight?r.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(r){return new e(this._forceIntegerValues,this.width,this.scrollWidth,"u">typeof r.scrollLeft?r.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,"u">typeof r.scrollTop?r.scrollTop:this.rawScrollTop)}createScrollEvent(e,r){let s=this.width!==e.width,i=this.scrollWidth!==e.scrollWidth,n=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,l=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:r,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:i,scrollLeftChanged:n,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:l}}},po=class extends hj{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new hQ),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new pa(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,r){let s=this._state.withScrollDimensions(e,r);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let r=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(r,!1)}setScrollPositionSmooth(e,r){if(0===this._smoothScrollDuration)return this.setScrollPositionNow(e);if(this._smoothScrolling){let s;e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;s=r?new pd(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let r=this._state.withScrollPosition(e);this._smoothScrolling=pd.start(this._state,r,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),r=this._state.withScrollPosition(e);if(this._setState(r,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,r){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,r)))}},pl=class{constructor(e,r,s){this.scrollLeft=e,this.scrollTop=r,this.isDone=s}};function pc(e,r){let s=r-e;return function(r){return e+s*(1-Math.pow(1-r,3))}}var pd=class e{constructor(e,r,s,i){this.from=e,this.to=r,this.duration=i,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,r,s){if(Math.abs(e-r)>2.5*s){var i,n;let a,o;return e<r?(a=e+.75*s,o=r-.75*s):(a=e-.75*s,o=r+.75*s),i=pc(e,a),n=pc(o,r),function(e){return e<.33?i(e/.33):n((e-.33)/(1-.33))}}return pc(e,r)}dispose(){null!==this.animationFrameDisposable&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let r=(e-this.startTime)/this.duration;return r<1?new pl(this.scrollLeft(r),this.scrollTop(r),!1):new pl(this.to.scrollLeft,this.to.scrollTop,!0)}combine(r,s,i){return e.start(r,s,i)}static start(r,s,i){return i+=10,new e(r,s,Date.now()-10,i)}},pu=class extends hj{constructor(e,r,s){super(),this._visibility=e,this._visibleClassName=r,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new fz)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return 2!==this._visibility&&(3===this._visibility||this._rawShouldBeVisible)}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},ph=class extends pi{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new pu(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new pr),this._shouldRender=!0,this.domNode=pt(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(f5(this.domNode.domNode,f7.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let r=this._register(new pn(e));this.domNode.domNode.appendChild(r.bgDomNode),this.domNode.domNode.appendChild(r.domNode)}_createSlider(e,r,s,i){this.slider=pt(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(r),"number"==typeof s&&this.slider.setWidth(s),"number"==typeof i&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(f5(this.slider.domNode,f7.POINTER_DOWN,e=>{0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let r=this.domNode.domNode.getClientRects()[0].top,s=r+this._scrollbarState.getSliderPosition(),i=r+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=i?0===e.button&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let r,s;if(e.target===this.domNode.domNode&&"number"==typeof e.offsetX&&"number"==typeof e.offsetY)r=e.offsetX,s=e.offsetY;else{var i;let n,a,o=(n=(i=this.domNode.domNode).getBoundingClientRect(),a=fq(i),{left:n.left+a.scrollX,top:n.top+a.scrollY,width:n.width,height:n.height});r=e.pageX-o.left,s=e.pageY-o.top}let n=this._pointerDownRelativePosition(r,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let r=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let n=Math.abs(this._sliderOrthogonalPointerPosition(e)-s);if(fc&&n>140)return void this._setDesiredScrollPositionNow(i.getScrollPosition());let a=this._sliderPointerPosition(e)-r;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(a))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let r={};this.writeScrollPosition(r,e),this._scrollable.setScrollPositionNow(r)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},pf=class e{constructor(e,r,s,i,n,a){this._scrollbarSize=Math.round(r),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(e),this._visibleSize=i,this._scrollSize=n,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let r=Math.round(e);return this._visibleSize!==r&&(this._visibleSize=r,this._refreshComputedValues(),!0)}setScrollSize(e){let r=Math.round(e);return this._scrollSize!==r&&(this._scrollSize=r,this._refreshComputedValues(),!0)}setScrollPosition(e){let r=Math.round(e);return this._scrollPosition!==r&&(this._scrollPosition=r,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,r,s,i,n){let a=Math.max(0,s-e),o=Math.max(0,a-2*r),l=i>0&&i>s;if(!l)return{computedAvailableSize:Math.round(a),computedIsNeeded:l,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(s*o/i))),d=(o-c)/(i-s);return{computedAvailableSize:Math.round(a),computedIsNeeded:l,computedSliderSize:Math.round(c),computedSliderRatio:d,computedSliderPosition:Math.round(n*d)}}_refreshComputedValues(){let r=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=r.computedAvailableSize,this._computedIsNeeded=r.computedIsNeeded,this._computedSliderSize=r.computedSliderSize,this._computedSliderRatio=r.computedSliderRatio,this._computedSliderPosition=r.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){return this._computedIsNeeded?Math.round((e-this._arrowSize-this._computedSliderSize/2)/this._computedSliderRatio):0}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let r=e-this._arrowSize,s=this._scrollPosition;return r<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(e){return this._computedIsNeeded?Math.round((this._computedSliderPosition+e)/this._computedSliderRatio):0}},pp=class extends ph{constructor(e,r,s){let i=e.getScrollDimensions();if(super({lazyRender:r.lazyRender,host:s,scrollbarState:new pf(r.horizontalHasArrows?r.arrowSize:0,2===r.horizontal?0:r.horizontalScrollbarSize,2===r.vertical?0:r.verticalScrollbarSize,i.width,i.scrollWidth,e.getCurrentScrollPosition().scrollLeft),visibility:r.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:r.scrollByPage}),r.horizontalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((r.horizontalScrollbarSize-r.horizontalSliderSize)/2),0,void 0,r.horizontalSliderSize)}_updateSlider(e,r){this.slider.setWidth(e),this.slider.setLeft(r)}_renderDomNode(e,r){this.domNode.setWidth(e),this.domNode.setHeight(r),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,r){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,r){e.scrollLeft=r}updateOptions(e){this.updateScrollbarSize(2===e.horizontal?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},pm=class extends ph{constructor(e,r,s){let i=e.getScrollDimensions();if(super({lazyRender:r.lazyRender,host:s,scrollbarState:new pf(r.verticalHasArrows?r.arrowSize:0,2===r.vertical?0:r.verticalScrollbarSize,0,i.height,i.scrollHeight,e.getCurrentScrollPosition().scrollTop),visibility:r.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:r.scrollByPage}),r.verticalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((r.verticalScrollbarSize-r.verticalSliderSize)/2),r.verticalSliderSize,void 0)}_updateSlider(e,r){this.slider.setHeight(e),this.slider.setTop(r)}_renderDomNode(e,r){this.domNode.setWidth(r),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,r){return r}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,r){e.scrollTop=r}updateOptions(e){this.updateScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},pg=class{constructor(e,r,s){this.timestamp=e,this.deltaX=r,this.deltaY=s,this.score=0}},px=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(-1===this._front&&-1===this._rear)return!1;let e=1,r=0,s=1,i=this._rear;for(;;){let n=i===this._front?e:Math.pow(2,-s);if(e-=n,r+=this._memory[i].score*n,i===this._front)break;i=(this._capacity+i-1)%this._capacity,s++}return r<=.5}acceptStandardWheelEvent(e){if(h4){var r;let s=(r=fq(e.browserEvent),h1.INSTANCE.getZoomFactor(r));this.accept(Date.now(),e.deltaX*s,e.deltaY*s)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,r,s){let i=null,n=new pg(e,r,s);-1===this._front&&-1===this._rear?(this._memory[0]=n,this._front=0,this._rear=0):(i=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,i)}_computeScore(e,r){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let s=.5;if(this._isAlmostInt(e.deltaX)&&this._isAlmostInt(e.deltaY)||(s+=.25),r){let i=Math.abs(e.deltaX),n=Math.abs(e.deltaY),a=Math.abs(r.deltaX),o=Math.abs(r.deltaY),l=Math.max(Math.min(i,a),1),c=Math.max(Math.min(n,o),1),d=Math.max(n,o);Math.max(i,a)%l==0&&d%c==0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(e){return .01>Math.abs(Math.round(e)-e)}};px.INSTANCE=new px;var pv=class extends pi{constructor(e,r,s){super(),this._onScroll=this._register(new hQ),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new hQ),this.onWillScroll=this._onWillScroll.event,this._options=function(e){let r={lazyRender:"u">typeof e.lazyRender&&e.lazyRender,className:"u">typeof e.className?e.className:"",useShadows:!("u">typeof e.useShadows)||e.useShadows,handleMouseWheel:!("u">typeof e.handleMouseWheel)||e.handleMouseWheel,flipAxes:"u">typeof e.flipAxes&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:"u">typeof e.consumeMouseWheelIfScrollbarIsNeeded&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:"u">typeof e.alwaysConsumeMouseWheel&&e.alwaysConsumeMouseWheel,scrollYToX:"u">typeof e.scrollYToX&&e.scrollYToX,mouseWheelScrollSensitivity:"u">typeof e.mouseWheelScrollSensitivity?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:"u">typeof e.fastScrollSensitivity?e.fastScrollSensitivity:5,scrollPredominantAxis:!("u">typeof e.scrollPredominantAxis)||e.scrollPredominantAxis,mouseWheelSmoothScroll:!("u">typeof e.mouseWheelSmoothScroll)||e.mouseWheelSmoothScroll,arrowSize:"u">typeof e.arrowSize?e.arrowSize:11,listenOnDomNode:"u">typeof e.listenOnDomNode?e.listenOnDomNode:null,horizontal:"u">typeof e.horizontal?e.horizontal:1,horizontalScrollbarSize:"u">typeof e.horizontalScrollbarSize?e.horizontalScrollbarSize:10,horizontalSliderSize:"u">typeof e.horizontalSliderSize?e.horizontalSliderSize:0,horizontalHasArrows:"u">typeof e.horizontalHasArrows&&e.horizontalHasArrows,vertical:"u">typeof e.vertical?e.vertical:1,verticalScrollbarSize:"u">typeof e.verticalScrollbarSize?e.verticalScrollbarSize:10,verticalHasArrows:"u">typeof e.verticalHasArrows&&e.verticalHasArrows,verticalSliderSize:"u">typeof e.verticalSliderSize?e.verticalSliderSize:0,scrollByPage:"u">typeof e.scrollByPage&&e.scrollByPage};return r.horizontalSliderSize="u">typeof e.horizontalSliderSize?e.horizontalSliderSize:r.horizontalScrollbarSize,r.verticalSliderSize="u">typeof e.verticalSliderSize?e.verticalSliderSize:r.verticalScrollbarSize,fd&&(r.className+=" mac"),r}(r),this._scrollable=s,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let i={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new pm(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new pp(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=pt(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=pt(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=pt(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new fz),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=hb(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,fd&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){"u">typeof e.handleMouseWheel&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),"u">typeof e.mouseWheelScrollSensitivity&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),"u">typeof e.fastScrollSensitivity&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),"u">typeof e.scrollPredominantAxis&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),"u">typeof e.horizontal&&(this._options.horizontal=e.horizontal),"u">typeof e.vertical&&(this._options.vertical=e.vertical),"u">typeof e.horizontalScrollbarSize&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),"u">typeof e.verticalScrollbarSize&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),"u">typeof e.scrollByPage&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new fL(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=hb(this._mouseWheelToDispose),e)){let e=e=>{this._onMouseWheel(new fL(e))};this._mouseWheelToDispose.push(f5(this._listenOnDomNode,f7.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let r=px.INSTANCE;r.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let i=e.deltaY*this._options.mouseWheelScrollSensitivity,n=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&n+i===0?n=i=0:Math.abs(i)>=Math.abs(n)?n=0:i=0),this._options.flipAxes&&([i,n]=[n,i]);let a=!fd&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!n&&(n=i,i=0),e.browserEvent&&e.browserEvent.altKey&&(n*=this._options.fastScrollSensitivity,i*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),l={};if(i){let e=50*i,r=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(l,r)}if(n){let e=50*n,r=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(l,r)}l=this._scrollable.validateScrollPosition(l),(o.scrollLeft!==l.scrollLeft||o.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&r.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),r=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",n=r?" top":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${n}`),this._topLeftShadowDomNode.setClassName(`shadow${s||r?" top-left-corner":""}${n}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){this._mouseIsOver||this._isDragging||(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){this._mouseIsOver||this._isDragging||this._hideTimeout.cancelAndSet(()=>this._hide(),500)}},p_=class extends pv{constructor(e,r,s){super(e,r,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}},py=class extends hj{constructor(e,r,s,i,n,a,o,l){super(),this._bufferService=s,this._optionsService=o,this._renderService=l,this._onRequestScrollLines=this._register(new hQ),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new po({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>pA(i.window,e)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new p_(r,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(16&e)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(hq.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(hw(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),r.appendChild(this._styleElement),this._register(hw(()=>this._styleElement.remove())),this._register(hq.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${a.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${a.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${a.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
22
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let r=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:r.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,r){r&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!r,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){void 0!==e&&(this._latestYDisp=e),void 0===this._queuedAnimationFrame&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let r=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=r-this._bufferService.buffer.ydisp;0!==s&&(this._latestYDisp=r,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};py=uI([uO(2,u2),uO(3,hi),uO(4,u5),uO(5,hc),uO(6,u7),uO(7,ha)],py);var pb=class extends hj{constructor(e,r,s,i,n){super(),this._screenElement=e,this._bufferService=r,this._coreBrowserService=s,this._decorationService=i,this._renderService=n,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(hw(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){void 0===this._animationFrame&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let r=this._coreBrowserService.mainDocument.createElement("div");r.classList.add("xterm-decoration"),r.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(r.style.display="none"),this._refreshXPosition(e,r),r}_refreshStyle(e){let r=e.marker.line-this._bufferService.buffers.active.ydisp;if(r<0||r>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${r*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,r=e.element){if(!r)return;let s=e.options.x??0;"right"===(e.options.anchor||"left")?r.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":r.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};pb=uI([uO(1,u2),uO(2,hi),uO(3,ht),uO(4,ha)],pb);var pw=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let r of this._zones)if(r.color===e.options.overviewRulerOptions.color&&r.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(r,e.marker.line))return;if(this._lineAdjacentToZone(r,e.marker.line,e.options.overviewRulerOptions.position))return void this._addLineToZone(r,e.marker.line)}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,r){return r>=e.startBufferLine&&r<=e.endBufferLine}_lineAdjacentToZone(e,r,s){return r>=e.startBufferLine-this._linePadding[s||"full"]&&r<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,r){e.startBufferLine=Math.min(e.startBufferLine,r),e.endBufferLine=Math.max(e.endBufferLine,r)}},pS={full:0,left:0,center:0,right:0},pC={full:0,left:0,center:0,right:0},pj={full:0,left:0,center:0,right:0},pk=class extends hj{constructor(e,r,s,i,n,a,o,l){super(),this._viewportElement=e,this._screenElement=r,this._bufferService=s,this._decorationService=i,this._renderService=n,this._optionsService=a,this._themeService=o,this._coreBrowserService=l,this._colorZoneStore=new pw,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(hw(()=>this._canvas?.remove()));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),r=Math.ceil((this._canvas.width-1)/3);pC.full=this._canvas.width,pC.left=e,pC.center=r,pC.right=e,this._refreshDrawHeightConstants(),pj.full=1,pj.left=1,pj.center=1+pC.left,pj.right=1+pC.left+pC.center}_refreshDrawHeightConstants(){pS.full=Math.round(2*this._coreBrowserService.dpr);let e=Math.round(Math.max(Math.min(this._canvas.height/this._bufferService.buffer.lines.length,12),6)*this._coreBrowserService.dpr);pS.left=e,pS.center=e,pS.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pS.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pS.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pS.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pS.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){for(let e of(this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear(),this._decorationService.decorations))this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let r of e)"full"!==r.position&&this._renderColorZone(r);for(let r of e)"full"===r.position&&this._renderColorZone(r);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(pj[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-pS[e.position||"full"]/2),pC[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+pS[e.position||"full"]))}_queueRefresh(e,r){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=r||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};pk=uI([uO(2,u2),uO(3,ht),uO(4,ha),uO(5,u7),uO(6,hc),uO(7,hi)],pk),(m=pF||={}).NUL="\0",m.SOH="\x01",m.STX="\x02",m.ETX="\x03",m.EOT="\x04",m.ENQ="\x05",m.ACK="\x06",m.BEL="\x07",m.BS="\b",m.HT=" ",m.LF=`
|
|
23
|
+
`,m.VT="\v",m.FF="\f",m.CR="\r",m.SO="\x0e",m.SI="\x0f",m.DLE="\x10",m.DC1="\x11",m.DC2="\x12",m.DC3="\x13",m.DC4="\x14",m.NAK="\x15",m.SYN="\x16",m.ETB="\x17",m.CAN="\x18",m.EM="\x19",m.SUB="\x1a",m.ESC="\x1b",m.FS="\x1c",m.GS="\x1d",m.RS="\x1e",m.US="\x1f",m.SP=" ",m.DEL="",(g=pT||={}).PAD="",g.HOP="",g.BPH="",g.NBH="",g.IND="",g.NEL="
",g.SSA="",g.ESA="",g.HTS="",g.HTJ="",g.VTS="",g.PLD="",g.PLU="",g.RI="",g.SS2="",g.SS3="",g.DCS="",g.PU1="",g.PU2="",g.STS="",g.CCH="",g.MW="",g.SPA="",g.EPA="",g.SOS="",g.SGCI="",g.SCI="",g.CSI="",g.ST="",g.OSC="",g.PM="",g.APC="",(pP||={}).ST=`${pF.ESC}\\`;var pN=class{constructor(e,r,s,i,n,a){this._textarea=e,this._compositionView=r,this._bufferService=s,this._optionsService=i,this._coreService=n,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(20===e.keyCode||229===e.keyCode||16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this._finalizeComposition(!1)}return 229!==e.keyCode||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let r;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,(r=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start)).length>0&&this._coreService.triggerDataEvent(r,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let r=this._textarea.value,s=r.replace(e,"");this._dataAlreadySent=s,r.length>e.length?this._coreService.triggerDataEvent(s,!0):r.length<e.length?this._coreService.triggerDataEvent(`${pF.DEL}`,!0):r.length===e.length&&r!==e&&this._coreService.triggerDataEvent(r,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),r=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,i=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=i+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=i+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};pN=uI([uO(2,u2),uO(3,u7),uO(4,u3),uO(5,ha)],pN);var pE,pD,pR,pA,pM,pF,pT,pP,pB,pL=0,pI=0,pO=0,pz=0,p$={css:"#00000000",rgba:0};(gg=pB||={}).toCss=function(e,r,s,i){return void 0!==i?`#${pG(e)}${pG(r)}${pG(s)}${pG(i)}`:`#${pG(e)}${pG(r)}${pG(s)}`},gg.toRgba=function(e,r,s,i=255){return(e<<24|r<<16|s<<8|i)>>>0},gg.toColor=function(e,r,s,i){return{css:gg.toCss(e,r,s,i),rgba:gg.toRgba(e,r,s,i)}};var pW=gx||={};function pH(e,r){return pz=Math.round(255*r),[pL,pI,pO]=gy.toChannels(e.rgba),{css:pB.toCss(pL,pI,pO,pz),rgba:pB.toRgba(pL,pI,pO,pz)}}pW.blend=function(e,r){if(1==(pz=(255&r.rgba)/255))return{css:r.css,rgba:r.rgba};let s=r.rgba>>24&255,i=r.rgba>>16&255,n=r.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,l=e.rgba>>8&255;return pL=a+Math.round((s-a)*pz),pI=o+Math.round((i-o)*pz),pO=l+Math.round((n-l)*pz),{css:pB.toCss(pL,pI,pO),rgba:pB.toRgba(pL,pI,pO)}},pW.isOpaque=function(e){return(255&e.rgba)==255},pW.ensureContrastRatio=function(e,r,s){let i=gy.ensureContrastRatio(e.rgba,r.rgba,s);if(i)return pB.toColor(i>>24&255,i>>16&255,i>>8&255)},pW.opaque=function(e){let r=(255|e.rgba)>>>0;return[pL,pI,pO]=gy.toChannels(r),{css:pB.toCss(pL,pI,pO),rgba:r}},pW.opacity=pH,pW.multiplyOpacity=function(e,r){return pz=255&e.rgba,pH(e,pz*r/255)},pW.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]},(e=>{let r,s;try{let e=document.createElement("canvas");e.width=1,e.height=1;let i=e.getContext("2d",{willReadFrequently:!0});i&&((r=i).globalCompositeOperation="copy",s=r.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return pL=parseInt(e.slice(1,2).repeat(2),16),pI=parseInt(e.slice(2,3).repeat(2),16),pO=parseInt(e.slice(3,4).repeat(2),16),pB.toColor(pL,pI,pO);case 5:return pL=parseInt(e.slice(1,2).repeat(2),16),pI=parseInt(e.slice(2,3).repeat(2),16),pO=parseInt(e.slice(3,4).repeat(2),16),pz=parseInt(e.slice(4,5).repeat(2),16),pB.toColor(pL,pI,pO,pz);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let i=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(i)return pL=parseInt(i[1]),pI=parseInt(i[2]),pO=parseInt(i[3]),pz=Math.round((void 0===i[5]?1:parseFloat(i[5]))*255),pB.toColor(pL,pI,pO,pz);if(!r||!s||(r.fillStyle=s,r.fillStyle=e,"string"!=typeof r.fillStyle)||(r.fillRect(0,0,1,1),[pL,pI,pO,pz]=r.getImageData(0,0,1,1).data,255!==pz))throw Error("css.toColor: Unsupported css format");return{rgba:pB.toRgba(pL,pI,pO,pz),css:e}}})(gv||={});var pU=g_||={};function pK(e,r,s){let i=e/255,n=r/255,a=s/255;return .2126*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.0722*(a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4))}pU.relativeLuminance=function(e){return pK(e>>16&255,e>>8&255,255&e)},pU.relativeLuminance2=pK;var pq=gy||={};function pV(e,r,s){let i=e>>24&255,n=e>>16&255,a=e>>8&255,o=r>>24&255,l=r>>16&255,c=r>>8&255,d=pX(g_.relativeLuminance2(o,l,c),g_.relativeLuminance2(i,n,a));for(;d<s&&(o>0||l>0||c>0);)o-=Math.max(0,Math.ceil(.1*o)),l-=Math.max(0,Math.ceil(.1*l)),c-=Math.max(0,Math.ceil(.1*c)),d=pX(g_.relativeLuminance2(o,l,c),g_.relativeLuminance2(i,n,a));return(o<<24|l<<16|c<<8|255)>>>0}function pY(e,r,s){let i=e>>24&255,n=e>>16&255,a=e>>8&255,o=r>>24&255,l=r>>16&255,c=r>>8&255,d=pX(g_.relativeLuminance2(o,l,c),g_.relativeLuminance2(i,n,a));for(;d<s&&(o<255||l<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),l=Math.min(255,l+Math.ceil((255-l)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),d=pX(g_.relativeLuminance2(o,l,c),g_.relativeLuminance2(i,n,a));return(o<<24|l<<16|c<<8|255)>>>0}function pG(e){let r=e.toString(16);return r.length<2?"0"+r:r}function pX(e,r){return e<r?(r+.05)/(e+.05):(e+.05)/(r+.05)}pq.blend=function(e,r){if(1==(pz=(255&r)/255))return r;let s=e>>24&255,i=e>>16&255,n=e>>8&255;return pL=s+Math.round(((r>>24&255)-s)*pz),pI=i+Math.round(((r>>16&255)-i)*pz),pO=n+Math.round(((r>>8&255)-n)*pz),pB.toRgba(pL,pI,pO)},pq.ensureContrastRatio=function(e,r,s){let i=g_.relativeLuminance(e>>8),n=g_.relativeLuminance(r>>8);if(pX(i,n)<s){if(n<i){let n=pV(e,r,s),a=pX(i,g_.relativeLuminance(n>>8));if(a<s){let o=pY(e,r,s);return a>pX(i,g_.relativeLuminance(o>>8))?n:o}return n}let a=pY(e,r,s),o=pX(i,g_.relativeLuminance(a>>8));if(o<s){let n=pV(e,r,s);return o>pX(i,g_.relativeLuminance(n>>8))?a:n}return a}},pq.reduceLuminance=pV,pq.increaseLuminance=pY,pq.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]};var pJ=class extends uG{constructor(e,r,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=r,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},pZ=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new uJ}register(e){let r={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(r),r.id}deregister(e){for(let r=0;r<this._characterJoiners.length;r++)if(this._characterJoiners[r].id===e)return this._characterJoiners.splice(r,1),!0;return!1}getJoinedCharacters(e){if(0===this._characterJoiners.length)return[];let r=this._bufferService.buffer.lines.get(e);if(!r||0===r.length)return[];let s=[],i=r.translateToString(!0),n=0,a=0,o=0,l=r.getFg(0),c=r.getBg(0);for(let e=0;e<r.getTrimmedLength();e++)if(r.loadCell(e,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==l||this._workCell.bg!==c){if(e-n>1){let e=this._getJoinedRanges(i,o,a,r,n);for(let r=0;r<e.length;r++)s.push(e[r])}n=e,o=a,l=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||1}if(this._bufferService.cols-n>1){let e=this._getJoinedRanges(i,o,a,r,n);for(let r=0;r<e.length;r++)s.push(e[r])}return s}_getJoinedRanges(e,r,s,i,n){let a=e.substring(r,s),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let r=this._characterJoiners[e].handler(a);for(let e=0;e<r.length;e++)pZ._mergeRanges(o,r[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,i,n),o}_stringRangesToCellRanges(e,r,s){let i=0,n=!1,a=0,o=e[0];if(o){for(let l=s;l<this._bufferService.cols;l++){let s=r.getWidth(l),c=r.getString(l).length||1;if(0!==s){if(!n&&o[0]<=a&&(o[0]=l,n=!0),o[1]<=a){if(o[1]=l,!(o=e[++i]))break;o[0]<=a?(o[0]=l,n=!0):n=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,r){let s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(s){if(r[1]<=n[0])return e[i-1][1]=r[1],e;if(r[1]<=n[1])return e[i-1][1]=Math.max(r[1],n[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(r[1]<=n[0])return e.splice(i,0,r),e;if(r[1]<=n[1])return n[0]=Math.min(r[0],n[0]),e;r[0]<n[1]&&(n[0]=Math.min(r[0],n[0]),s=!0);continue}}return s?e[e.length-1][1]=r[1]:e.push(r),e}};function pQ(){return{width:0,height:0}}pZ=uI([uO(0,u2)],pZ);var p0=class{constructor(e,r,s,i,n,a,o){this._document=e,this._characterJoinerService=r,this._optionsService=s,this._coreBrowserService=i,this._coreService=n,this._decorationService=a,this._themeService=o,this._workCell=new uJ,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,r,s){this._selectionStart=e,this._selectionEnd=r,this._columnSelectMode=s}createRow(e,r,s,i,n,a,o,l,c,d,u){let h=[],f=this._characterJoinerService.getJoinedCharacters(r),p=this._themeService.colors,m=e.getNoBgTrimmedLength();s&&m<a+1&&(m=a+1);let g,x=0,v="",_=0,y=0,b=0,w=0,S=!1,C=0,j=!1,k=0,N=0,E=[],D=-1!==d&&-1!==u;for(let R=0;R<m;R++){let m;e.loadCell(R,this._workCell);let A=this._workCell.getWidth();if(0===A)continue;let M=!1,F=R>=N,T=R,P=this._workCell;if(f.length>0&&R===f[0][0]&&F){let i=f.shift(),n=this._isCellInSelection(i[0],r);for(_=i[0]+1;_<i[1];_++)F&&=n===this._isCellInSelection(_,r);(F&&=!s||a<i[0]||a>=i[1])?(M=!0,P=new pJ(this._workCell,e.translateToString(!0,i[0],i[1]),i[1]-i[0]),T=i[1]-1,A=P.getWidth()):N=i[1]}let B=this._isCellInSelection(R,r),L=s&&R===a,I=D&&R>=d&&R<=u,O=!1;this._decorationService.forEachDecorationAtCell(R,r,void 0,e=>{O=!0});let z=P.getChars()||" ";if(" "===z&&(P.isUnderline()||P.isOverline())&&(z=" "),k=A*l-c.get(z,P.isBold(),P.isItalic()),g)if(x&&(B&&j||!B&&!j&&P.bg===y)&&(B&&j&&p.selectionForeground||P.fg===b)&&P.extended.ext===w&&I===S&&k===C&&!L&&!M&&!O&&F){P.isInvisible()?v+=" ":v+=z,x++;continue}else x&&(g.textContent=v),g=this._document.createElement("span"),x=0,v="";else g=this._document.createElement("span");if(y=P.bg,b=P.fg,w=P.extended.ext,S=I,C=k,j=B,M&&a>=R&&a<=T&&(a=R),!this._coreService.isCursorHidden&&L&&this._coreService.isCursorInitialized){if(E.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&E.push("xterm-cursor-blink"),E.push("bar"===i?"xterm-cursor-bar":"underline"===i?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":E.push("xterm-cursor-outline");break;case"block":E.push("xterm-cursor-block");break;case"bar":E.push("xterm-cursor-bar");break;case"underline":E.push("xterm-cursor-underline")}}if(P.isBold()&&E.push("xterm-bold"),P.isItalic()&&E.push("xterm-italic"),P.isDim()&&E.push("xterm-dim"),v=P.isInvisible()?" ":P.getChars()||" ",P.isUnderline()&&(E.push(`xterm-underline-${P.extended.underlineStyle}`)," "===v&&(v=" "),!P.isUnderlineColorDefault()))if(P.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${uG.toColorRGB(P.getUnderlineColor()).join(",")})`;else{let e=P.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&P.isBold()&&e<8&&(e+=8),g.style.textDecorationColor=p.ansi[e].css}P.isOverline()&&(E.push("xterm-overline")," "===v&&(v=" ")),P.isStrikethrough()&&E.push("xterm-strikethrough"),I&&(g.style.textDecoration="underline");let $=P.getFgColor(),W=P.getFgColorMode(),H=P.getBgColor(),U=P.getBgColorMode(),K=!!P.isInverse();if(K){let e=$;$=H,H=e;let r=W;W=U,U=r}let q,V,Y=!1;switch(this._decorationService.forEachDecorationAtCell(R,r,void 0,e=>{"top"!==e.options.layer&&Y||(e.backgroundColorRGB&&(U=0x3000000,H=e.backgroundColorRGB.rgba>>8&0xffffff,q=e.backgroundColorRGB),e.foregroundColorRGB&&(W=0x3000000,$=e.foregroundColorRGB.rgba>>8&0xffffff,V=e.foregroundColorRGB),Y="top"===e.options.layer)}),!Y&&B&&(H=(q=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque).rgba>>8&0xffffff,U=0x3000000,Y=!0,p.selectionForeground&&(W=0x3000000,$=p.selectionForeground.rgba>>8&0xffffff,V=p.selectionForeground)),Y&&E.push("xterm-decoration-top"),U){case 0x1000000:case 0x2000000:m=p.ansi[H],E.push(`xterm-bg-${H}`);break;case 0x3000000:m=pB.toColor(H>>16,H>>8&255,255&H),this._addStyle(g,`background-color:#${p1((H>>>0).toString(16),"0",6)}`);break;default:K?(m=p.foreground,E.push("xterm-bg-257")):m=p.background}switch(q||P.isDim()&&(q=gx.multiplyOpacity(m,.5)),W){case 0x1000000:case 0x2000000:P.isBold()&&$<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&($+=8),this._applyMinimumContrast(g,m,p.ansi[$],P,q,void 0)||E.push(`xterm-fg-${$}`);break;case 0x3000000:let G=pB.toColor($>>16&255,$>>8&255,255&$);this._applyMinimumContrast(g,m,G,P,q,V)||this._addStyle(g,`color:#${p1($.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,m,p.foreground,P,q,V)||K&&E.push("xterm-fg-257")}E.length&&(g.className=E.join(" "),E.length=0),L||M||O||!F?g.textContent=v:x++,k!==this.defaultSpacing&&(g.style.letterSpacing=`${k}px`),h.push(g),R=T}return g&&x&&(g.textContent=v),h}_applyMinimumContrast(e,r,s,i,n,a){var o,l,c;if(1===this._optionsService.rawOptions.minimumContrastRatio||57508<=(l=o=i.getCode())&&l<=57558||9472<=(c=o)&&c<=9631)return!1;let d=this._getContrastCache(i),u;if(n||a||(u=d.getColor(r.rgba,s.rgba)),void 0===u){let e=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);u=gx.ensureContrastRatio(n||r,a||s,e),d.setColor((n||r).rgba,(a||s).rgba,u??null)}return!!u&&(this._addStyle(e,`color:${u.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,r){e.setAttribute("style",`${e.getAttribute("style")||""}${r};`)}_isCellInSelection(e,r){let s=this._selectionStart,i=this._selectionEnd;return!!s&&!!i&&(this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&r>=s[1]&&e<i[0]&&r<=i[1]:e<s[0]&&r>=s[1]&&e>=i[0]&&r<=i[1]:r>s[1]&&r<i[1]||s[1]===i[1]&&r===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&r===i[1]&&e<i[0]||s[1]<i[1]&&r===s[1]&&e>=s[0])}};function p1(e,r,s){for(;e.length<s;)e=r+e;return e}p0=uI([uO(1,hl),uO(2,u7),uO(3,hi),uO(4,u3),uO(5,ht),uO(6,hc)],p0);var p2=class{constructor(e,r){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontWeight="bold",a.style.fontStyle="italic",this._measureElements=[s,i,n,a],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(n),this._container.appendChild(a),r.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,r,s,i){e===this._font&&r===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=r,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,r,s){let i=0;if(!r&&!s&&1===e.length&&(i=e.charCodeAt(0))<256){if(-9999!==this._flat[i])return this._flat[i];let r=this._measure(e,0);return r>0&&(this._flat[i]=r),r}let n=e;r&&(n+="B"),s&&(n+="I");let a=this._holey.get(n);if(void 0===a){let i=0;r&&(i|=1),s&&(i|=2),(a=this._measure(e,i))>0&&this._holey.set(n,a)}return a}_measure(e,r){let s=this._measureElements[r];return s.textContent=e.repeat(32),s.offsetWidth/32}},p5=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,r,s,i=!1){if(this.selectionStart=r,this.selectionEnd=s,!r||!s||r[0]===s[0]&&r[1]===s[1])return void this.clear();let n=e.buffers.active.ydisp,a=r[1]-n,o=s[1]-n,l=Math.max(a,0),c=Math.min(o,e.rows-1);l>=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=r[0],this.endCol=s[0])}isCellSelected(e,r,s){return!!this.hasSelection&&(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?r>=this.startCol&&s>=this.viewportCappedStartRow&&r<this.endCol&&s<=this.viewportCappedEndRow:r<this.startCol&&s>=this.viewportCappedStartRow&&r>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&r>=this.startCol&&r<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&r<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&r>=this.startCol)}},p3="xterm-dom-renderer-owner-",p4="xterm-rows",p6="xterm-fg-",p8="xterm-bg-",p7="xterm-focus",p9="xterm-selection",me=1,mt=class extends hj{constructor(e,r,s,i,n,a,o,l,c,d,u,h,f,p){super(),this._terminal=e,this._document=r,this._element=s,this._screenElement=i,this._viewportElement=n,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=d,this._bufferService=u,this._coreService=h,this._coreBrowserService=f,this._themeService=p,this._terminalClass=me++,this._rowElements=[],this._selectionRenderModel=new p5,this.onRequestRedraw=this._register(new hQ).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(p4),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(p9),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions={css:{canvas:pQ(),cell:pQ()},device:{canvas:pQ(),cell:pQ(),char:{width:0,height:0,left:0,top:0}}},this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(p0,document),this._element.classList.add(p3+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(hw(()=>{this._element.classList.remove(p3+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new p2(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;for(let r of(this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows,this._rowElements))r.style.width=`${this.dimensions.css.canvas.width}px`,r.style.height=`${this.dimensions.css.cell.height}px`,r.style.lineHeight=`${this.dimensions.css.cell.height}px`,r.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let r=`${this._terminalSelector} .${p4} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=r,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let r=`${this._terminalSelector} .${p4} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;r+=`${this._terminalSelector} .${p4} .xterm-dim { color: ${gx.multiplyOpacity(e.foreground,.5).css};}${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;for(let[a,o]of(r+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}@keyframes ${i} { 50% { box-shadow: none; }}@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}${this._terminalSelector} .${p4}.${p7} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${p4}.${p7} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${p4}.${p7} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${p4} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${p4} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${p4} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${p4} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${p4} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}${this._terminalSelector} .${p9} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${p9} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${p9} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`,e.ansi.entries()))r+=`${this._terminalSelector} .${p6}${a} { color: ${o.css}; }${this._terminalSelector} .${p6}${a}.xterm-dim { color: ${gx.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${p8}${a} { background-color: ${o.css}; }`;r+=`${this._terminalSelector} .${p6}257 { color: ${gx.opaque(e.background).css}; }${this._terminalSelector} .${p6}257.xterm-dim { color: ${gx.multiplyOpacity(gx.opaque(e.background),.5).css}; }${this._terminalSelector} .${p8}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=r}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,r){for(let e=this._rowElements.length;e<=r;e++){let e=this._document.createElement("div");this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>r;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,r){this._refreshRowElements(e,r),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(p7),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(p7),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,r,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,r,s),this.renderRows(0,this._bufferService.rows-1),!e||!r||(this._selectionRenderModel.update(this._terminal,e,r,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let s=e[0]>r[0];l.appendChild(this._createSelectionElement(a,s?r[0]:e[0],s?e[0]:r[0],o-a+1))}else{let s=i===a?e[0]:0,c=a===n?r[0]:this._bufferService.cols;if(l.appendChild(this._createSelectionElement(a,s,c)),l.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,o-a-1)),a!==o){let e=n===o?r[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,r,s,i=1){let n=this._document.createElement("div"),a=r*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(s-r);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),n.style.height=`${i*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${a}px`,n.style.width=`${o}px`,n}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,r){let s=this._bufferService.buffer,i=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=r;c++){let e=c+s.ydisp,r=this._rowElements[c],d=s.lines.get(e);if(!r||!d)break;r.replaceChildren(...this._rowFactory.createRow(d,e,e===i,o,l,n,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${p3}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,r,s,i,n,a){s<0&&(e=0),i<0&&(r=0);let o=this._bufferService.rows-1;s=Math.max(Math.min(s,o),0),i=Math.max(Math.min(i,o),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,c=l.ybase+l.y,d=Math.min(l.x,n-1),u=this._optionsService.rawOptions.cursorBlink,h=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=s;o<=i;++o){let p=o+l.ydisp,m=this._rowElements[o],g=l.lines.get(p);if(!m||!g)break;m.replaceChildren(...this._rowFactory.createRow(g,p,p===c,h,f,d,u,this.dimensions.css.cell.width,this._widthCache,a?o===s?e:0:-1,a?(o===i?r:n)-1:-1))}}};mt=uI([uO(7,u6),uO(8,hs),uO(9,u7),uO(10,u2),uO(11,u3),uO(12,hi),uO(13,hc)],mt);var mr=class extends hj{constructor(e,r,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new hQ),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new mn(this._optionsService))}catch{this._measureStrategy=this._register(new mi(e,r,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};mr=uI([uO(2,u7)],mr);var ms=class extends hj{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,r){void 0!==e&&e>0&&void 0!==r&&r>0&&(this._result.width=e,this._result.height=r)}},mi=class extends ms{constructor(e,r,s){super(),this._document=e,this._parentElement=r,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},mn=class extends ms{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let r=this._ctx.measureText("W");if(!("width"in r&&"fontBoundingBoxAscent"in r&&"fontBoundingBoxDescent"in r))throw Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},ma=class extends hj{constructor(e,r,s){super(),this._textarea=e,this._window=r,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new mo(this._window)),this._onDprChange=this._register(new hQ),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new hQ),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(hq.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(f5(this._textarea,"focus",()=>this._isFocused=!0)),this._register(f5(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},mo=class extends hj{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new hk),this._onDprChange=this._register(new hQ),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(hw(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=f5(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},ml=class extends hj{constructor(){super(),this.linkProviders=[],this._register(hw(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let r=this.linkProviders.indexOf(e);-1!==r&&this.linkProviders.splice(r,1)}}}};function mc(e,r,s){let i=s.getBoundingClientRect(),n=e.getComputedStyle(s),a=parseInt(n.getPropertyValue("padding-left")),o=parseInt(n.getPropertyValue("padding-top"));return[r.clientX-i.left-a,r.clientY-i.top-o]}var md=class{constructor(e,r){this._renderService=e,this._charSizeService=r}getCoords(e,r,s,i,n){return function(e,r,s,i,n,a,o,l,c){if(!a)return;let d=mc(e,r,s);return d[0]=Math.ceil((d[0]+(c?o/2:0))/o),d[1]=Math.ceil(d[1]/l),d[0]=Math.min(Math.max(d[0],1),i+ +!!c),d[1]=Math.min(Math.max(d[1],1),n),d}(window,e,r,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,r){let s=mc(window,e,r);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};md=uI([uO(0,ha),uO(1,hs)],md);var mu=class{constructor(e,r){this._renderCallback=e,this._coreBrowserService=r,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,r,s){this._rowCount=s,e=void 0!==e?e:0,r=void 0!==r?r:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,r):r,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return void this._runRefreshCallbacks();let e=Math.max(this._rowStart,0),r=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,r),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},mh={},mf={getSafariVersion:()=>mb,isChromeOS:()=>mN,isFirefox:()=>mv,isIpad:()=>mS,isIphone:()=>mC,isLegacyEdge:()=>m_,isLinux:()=>mk,isMac:()=>mw,isNode:()=>mm,isSafari:()=>my,isWindows:()=>mj};for(var mp in mf)uB(mh,mp,{get:mf[mp],enumerable:!0});var mm="u">typeof uP.default&&"title"in uP.default,mg=mm?"node":navigator.userAgent,mx=mm?"node":navigator.platform,mv=mg.includes("Firefox"),m_=mg.includes("Edge"),my=/^((?!chrome|android).)*safari/i.test(mg);function mb(){if(!my)return 0;let e=mg.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])}var mw=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(mx),mS="iPad"===mx,mC="iPhone"===mx,mj=["Windows","Win16","Win32","WinCE"].includes(mx),mk=mx.indexOf("Linux")>=0,mN=/\bCrOS\b/.test(mg),mE=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let r=0,s=0,i=e.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(r=performance.now(),this._tasks[this._i]()||this._i++,1.5*(s=Math.max(r=Math.max(1,performance.now()-r),s))>(n=e.timeRemaining())){i-r<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-r))}ms`),this._start();return}i=n}this.clear()}},mD=class extends mE{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let r=performance.now()+e;return{timeRemaining:()=>Math.max(0,r-performance.now())}}},mR=class extends mE{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},mA=!mm&&"requestIdleCallback"in window?mR:mD,mM=class{constructor(){this._queue=new mA}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},mF=class extends hj{constructor(e,r,s,i,n,a,o,l,c){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new hk),this._pausedResizeTask=new mM,this._observerDisposable=this._register(new hk),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new hQ),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new hQ),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new hQ),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new hQ),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new mu((e,r)=>this._renderRows(e,r),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new mT(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(hw(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,r),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,r)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,r){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});s.observe(r),this._observerDisposable.value=hw(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=void 0===e.isIntersecting?0===e.intersectionRatio:!e.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,r,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,r);let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),r=Math.max(r,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,r,this._rowCount)}_renderRows(e,r){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,r);e=Math.min(e,this._rowCount-1),r=Math.min(r,this._rowCount-1),this._renderer.value.renderRows(e,r),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:r}),this._onRender.fire({start:e,end:r}),this._isNextRenderRedrawOnly=!0}}resize(e,r){this._rowCount=r,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,r){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,r)):this._renderer.value.handleResize(e,r),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,r,s){this._selectionState.start=e,this._selectionState.end=r,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,r,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};mF=uI([uO(2,u7),uO(3,hs),uO(4,u3),uO(5,ht),uO(6,u2),uO(7,hi),uO(8,hc)],mF);var mT=class{constructor(e,r,s){this._coreBrowserService=e,this._coreService=r,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,r){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,r)):(this._start=e,this._end=r,this._isBuffering=!0),void 0===this._timeout&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function mP(e,r,s,i){return mO(Math.abs(e-mB(e,s)-(r-mB(r,s)))-function(e,r,s){let i=0,n=e-mB(e,s),a=r-mB(r,s);for(let o=0;o<Math.abs(n-a);o++){let a="A"===function(e,r){return e>r?"A":"B"}(e,r)?-1:1;s.buffer.lines.get(n+a*o)?.isWrapped&&i++}return i}(e,r,s),mI(e>r?"A":"B",i))}function mB(e,r){let s=0,i=r.buffer.lines.get(e),n=i?.isWrapped;for(;n&&e>=0&&e<r.rows;)s++,i=r.buffer.lines.get(--e),n=i?.isWrapped;return s}function mL(e,r,s,i,n,a){let o=e,l=r,c="";for(;(o!==s||l!==i)&&l>=0&&l<a.buffer.lines.length;)o+=n?1:-1,n&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(l,!1,e,o),o=0,e=0,l++):!n&&o<0&&(c+=a.buffer.translateBufferLineToString(l,!1,0,e+1),e=o=a.cols-1,l--);return c+a.buffer.translateBufferLineToString(l,!1,e,o)}function mI(e,r){return pF.ESC+(r?"O":"[")+e}function mO(e,r){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=r;return s}var mz=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,r=this.selectionEnd;return!!e&&!!r&&(e[1]>r[1]||e[1]===r[1]&&e[0]>r[0])}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function m$(e,r){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return r*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var mW=RegExp(" ","g"),mH=class extends hj{constructor(e,r,s,i,n,a,o,l,c){super(),this._element=e,this._screenElement=r,this._linkifier=s,this._bufferService=i,this._coreService=n,this._mouseService=a,this._optionsService=o,this._renderService=l,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new uJ,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new hQ),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new hQ),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new hQ),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new hQ),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new mz(this._bufferService),this._activeSelectionMode=0,this._register(hw(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!!e&&!!r&&(e[0]!==r[0]||e[1]!==r[1])}get selectionText(){let e=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;if(!e||!r)return"";let s=this._bufferService.buffer,i=[];if(3===this._activeSelectionMode){if(e[0]===r[0])return"";let n=e[0]<r[0]?e[0]:r[0],a=e[0]<r[0]?r[0]:e[0];for(let o=e[1];o<=r[1];o++){let e=s.translateBufferLineToString(o,!0,n,a);i.push(e)}}else{let n=e[1]===r[1]?r[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let n=e[1]+1;n<=r[1]-1;n++){let e=s.lines.get(n),r=s.translateBufferLineToString(n,!0);e?.isWrapped?i[i.length-1]+=r:i.push(r)}if(e[1]!==r[1]){let e=s.lines.get(r[1]),n=s.translateBufferLineToString(r[1],!0,0,r[0]);e&&e.isWrapped?i[i.length-1]+=n:i.push(n)}}return i.map(e=>e.replace(mW," ")).join(mj?`\r
|
|
24
|
+
`:`
|
|
25
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),mk&&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:3===this._activeSelectionMode})}_isClickInSelection(e){let r=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!!s&&!!i&&!!r&&this._areCoordsInSelection(r,s,i)}isCellInSelection(e,r){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!!s&&!!i&&this._areCoordsInSelection([e,r],s,i)}_areCoordsInSelection(e,r,s){return e[1]>r[1]&&e[1]<s[1]||r[1]===s[1]&&e[1]===r[1]&&e[0]>=r[0]&&e[0]<s[0]||r[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||r[1]<s[1]&&e[1]===r[1]&&e[0]>=r[0]}_selectWordAtCursor(e,r){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=m$(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return!!i&&(this._selectWordAt(i,r),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,r){this._model.clearSelection(),e=Math.max(e,0),r=Math.min(r,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,r],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let r=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(r)return r[0]--,r[1]--,r[1]+=this._bufferService.buffer.ydisp,r}_getMouseEventScrollAmount(e){let r=mc(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return r>=0&&r<=s?0:(r>s&&(r-=s),(r=Math.min(Math.max(r,-50),50)/50)/Math.abs(r)+Math.round(14*r))}shouldForceSelection(e){return mw?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(2===e.button&&this.hasSelection)&&0===e.button){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):1===e.detail?this._handleSingleClick(e):2===e.detail?this._handleDoubleClick(e):3===e.detail&&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(),50)}_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=3*!!this.shouldColumnSelect(e),this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let r=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);r&&r.length!==this._model.selectionStart[0]&&0===r.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let r=this._getMouseBufferCoords(e);r&&(this._activeSelectionMode=2,this._selectLineAt(r[1]))}shouldColumnSelect(e){return e.altKey&&!(mw&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let r=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd)return void this.refresh(!0);2===this._activeSelectionMode?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let e=s.lines.get(this._model.selectionEnd[1]);e&&0===e.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}r&&r[0]===this._model.selectionEnd[0]&&r[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?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let r=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&r<500&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&void 0!==r[0]&&void 0!==r[1]){let e=function(e,r,s,i){var n,a,o,l,c,d,u,h,f,p,m,g,x,v,_,y,b,w;let S,C=s.buffer.x,j=s.buffer.y;if(!s.buffer.hasScrollback){let b,w,S;return n=C,o=0,(0===mP(a=j,r,l=s,c=i).length?"":mO(mL(n,a,n,a-mB(a,l),!1,l).length,mI("D",c)))+mP(j,r,s,i)+(d=C,u=j,h=e,b=mP(u,f=r,p=s,m=i).length>0?f-mB(f,p):u,S=(g=d,x=u,w=mP(v=h,_=f,y=p,m).length>0?_-mB(_,y):x,g<v&&w<=_||g>=v&&w<_?"C":"D"),mO(mL(d,b,h,f,"C"===S,p).length,mI(S,m)))}if(j===r)return S=C>e?"D":"C",mO(Math.abs(C-e),mI(S,i));S=j>r?"D":"C";let k=Math.abs(j-r);return mO((b=j>r?e:C,s.cols-b+(k-1)*s.cols+1+(w=0,(j>r?C:e)-1)),mI(S,i))}(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,r=this._model.finalSelectionEnd,s=!!e&&!!r&&(e[0]!==r[0]||e[1]!==r[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,r,s);return}!e||!r||this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&r[0]===this._oldSelectionEnd[0]&&r[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,r,s)}_fireOnSelectionChange(e,r,s){this._oldSelectionStart=e,this._oldSelectionEnd=r,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,r){let s=r;for(let i=0;r>=i;i++){let n=e.loadCell(i,this._workCell).getChars().length;0===this._workCell.getWidth()?s--:n>1&&r!==i&&(s+=n-1)}return s}setSelection(e,r,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,r],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,r,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,a=n.lines.get(e[1]);if(!a)return;let o=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(a,e[0]),c=l,d=e[0]-l,u=0,h=0,f=0,p=0;if(" "===o.charAt(l)){for(;l>0&&" "===o.charAt(l-1);)l--;for(;c<o.length&&" "===o.charAt(c+1);)c++}else{let r=e[0],s=e[0];0===a.getWidth(r)&&(u++,r--),2===a.getWidth(s)&&(h++,s++);let i=a.getString(s).length;for(i>1&&(p+=i-1,c+=i-1);r>0&&l>0&&!this._isCharWordSeparator(a.loadCell(r-1,this._workCell));){a.loadCell(r-1,this._workCell);let e=this._workCell.getChars().length;0===this._workCell.getWidth()?(u++,r--):e>1&&(f+=e-1,l-=e-1),l--,r--}for(;s<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(s+1,this._workCell));){a.loadCell(s+1,this._workCell);let e=this._workCell.getChars().length;2===this._workCell.getWidth()?(h++,s++):e>1&&(p+=e-1,c+=e-1),c++,s++}}c++;let m=l+d-u+f,g=Math.min(this._bufferService.cols,c-l+u+h-f-p);if(!(!r&&""===o.slice(l,c).trim())){if(s&&0===m&&32!==a.getCodePoint(0)){let r=n.lines.get(e[1]-1);if(r&&a.isWrapped&&32!==r.getCodePoint(this._bufferService.cols-1)){let r=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(r){let e=this._bufferService.cols-r.start;m-=e,g+=e}}}if(i&&m+g===this._bufferService.cols&&32!==a.getCodePoint(this._bufferService.cols-1)){let r=n.lines.get(e[1]+1);if(r?.isWrapped&&32!==r.getCodePoint(0)){let r=this._getWordAt([0,e[1]+1],!1,!1,!0);r&&(g+=r.length)}}return{start:m,length:g}}}_selectWordAt(e,r){let s=this._getWordAt(e,r);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let r=this._getWordAt(e,!0);if(r){let s=e[1];for(;r.start<0;)r.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;r.start+r.length>this._bufferService.cols;)r.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?r.start:r.start+r.length,s]}}_isCharWordSeparator(e){return 0!==e.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let r=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:r.first},end:{x:this._bufferService.cols-1,y:r.last}};this._model.selectionStart=[0,r.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=m$(s,this._bufferService.cols)}};mH=uI([uO(3,u2),uO(4,u3),uO(5,hn),uO(6,u7),uO(7,ha),uO(8,hi)],mH);var mU=class{constructor(){this._data={}}set(e,r,s){this._data[e]||(this._data[e]={}),this._data[e][r]=s}get(e,r){return this._data[e]?this._data[e][r]:void 0}clear(){this._data={}}},mK=class{constructor(){this._color=new mU,this._css=new mU}setCss(e,r,s){this._css.set(e,r,s)}getCss(e,r){return this._css.get(e,r)}setColor(e,r,s){this._color.set(e,r,s)}getColor(e,r){return this._color.get(e,r)}clear(){this._color.clear(),this._css.clear()}},mq=Object.freeze((()=>{let e=[gv.toColor("#2e3436"),gv.toColor("#cc0000"),gv.toColor("#4e9a06"),gv.toColor("#c4a000"),gv.toColor("#3465a4"),gv.toColor("#75507b"),gv.toColor("#06989a"),gv.toColor("#d3d7cf"),gv.toColor("#555753"),gv.toColor("#ef2929"),gv.toColor("#8ae234"),gv.toColor("#fce94f"),gv.toColor("#729fcf"),gv.toColor("#ad7fa8"),gv.toColor("#34e2e2"),gv.toColor("#eeeeec")],r=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=r[s/36%6|0],n=r[s/6%6|0],a=r[s%6];e.push({css:pB.toCss(i,n,a),rgba:pB.toRgba(i,n,a)})}for(let r=0;r<24;r++){let s=8+10*r;e.push({css:pB.toCss(s,s,s),rgba:pB.toRgba(s,s,s)})}return e})()),mV=gv.toColor("#ffffff"),mY=gv.toColor("#000000"),mG=gv.toColor("#ffffff"),mX={css:"rgba(255, 255, 255, 0.3)",rgba:0xffffff4d},mJ=class extends hj{constructor(e){super(),this._optionsService=e,this._contrastCache=new mK,this._halfContrastCache=new mK,this._onChangeColors=this._register(new hQ),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:mV,background:mY,cursor:mG,cursorAccent:mY,selectionForeground:void 0,selectionBackgroundTransparent:mX,selectionBackgroundOpaque:gx.blend(mY,mX),selectionInactiveBackgroundTransparent:mX,selectionInactiveBackgroundOpaque:gx.blend(mY,mX),scrollbarSliderBackground:gx.opacity(mV,.2),scrollbarSliderHoverBackground:gx.opacity(mV,.4),scrollbarSliderActiveBackground:gx.opacity(mV,.5),overviewRulerBorder:mV,ansi:mq.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 r=this._colors;if(r.foreground=mZ(e.foreground,mV),r.background=mZ(e.background,mY),r.cursor=gx.blend(r.background,mZ(e.cursor,mG)),r.cursorAccent=gx.blend(r.background,mZ(e.cursorAccent,mY)),r.selectionBackgroundTransparent=mZ(e.selectionBackground,mX),r.selectionBackgroundOpaque=gx.blend(r.background,r.selectionBackgroundTransparent),r.selectionInactiveBackgroundTransparent=mZ(e.selectionInactiveBackground,r.selectionBackgroundTransparent),r.selectionInactiveBackgroundOpaque=gx.blend(r.background,r.selectionInactiveBackgroundTransparent),r.selectionForeground=e.selectionForeground?mZ(e.selectionForeground,p$):void 0,r.selectionForeground===p$&&(r.selectionForeground=void 0),gx.isOpaque(r.selectionBackgroundTransparent)&&(r.selectionBackgroundTransparent=gx.opacity(r.selectionBackgroundTransparent,.3)),gx.isOpaque(r.selectionInactiveBackgroundTransparent)&&(r.selectionInactiveBackgroundTransparent=gx.opacity(r.selectionInactiveBackgroundTransparent,.3)),r.scrollbarSliderBackground=mZ(e.scrollbarSliderBackground,gx.opacity(r.foreground,.2)),r.scrollbarSliderHoverBackground=mZ(e.scrollbarSliderHoverBackground,gx.opacity(r.foreground,.4)),r.scrollbarSliderActiveBackground=mZ(e.scrollbarSliderActiveBackground,gx.opacity(r.foreground,.5)),r.overviewRulerBorder=mZ(e.overviewRulerBorder,mV),r.ansi=mq.slice(),r.ansi[0]=mZ(e.black,mq[0]),r.ansi[1]=mZ(e.red,mq[1]),r.ansi[2]=mZ(e.green,mq[2]),r.ansi[3]=mZ(e.yellow,mq[3]),r.ansi[4]=mZ(e.blue,mq[4]),r.ansi[5]=mZ(e.magenta,mq[5]),r.ansi[6]=mZ(e.cyan,mq[6]),r.ansi[7]=mZ(e.white,mq[7]),r.ansi[8]=mZ(e.brightBlack,mq[8]),r.ansi[9]=mZ(e.brightRed,mq[9]),r.ansi[10]=mZ(e.brightGreen,mq[10]),r.ansi[11]=mZ(e.brightYellow,mq[11]),r.ansi[12]=mZ(e.brightBlue,mq[12]),r.ansi[13]=mZ(e.brightMagenta,mq[13]),r.ansi[14]=mZ(e.brightCyan,mq[14]),r.ansi[15]=mZ(e.brightWhite,mq[15]),e.extendedAnsi){let s=Math.min(r.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)r.ansi[i+16]=mZ(e.extendedAnsi[i],mq[i+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(void 0===e){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()}}};function mZ(e,r){if(void 0!==e)try{return gv.toColor(e)}catch{}return r}mJ=uI([uO(0,u7)],mJ);var mQ=class{constructor(...e){for(let[r,s]of(this._entries=new Map,e))this.set(r,s)}set(e,r){let s=this._entries.get(e);return this._entries.set(e,r),s}forEach(e){for(let[r,s]of this._entries.entries())e(r,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},m0=class{constructor(){this._services=new mQ,this._services.set(u6,this)}setService(e,r){this._services.set(e,r)}getService(e){return this._services.get(e)}createInstance(e,...r){let s=(e[uQ]||[]).sort((e,r)=>e.index-r.index),i=[];for(let r of s){let s=this._services.get(r.id);if(!s)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${r.id._id}.`);i.push(s)}let n=s.length>0?s[0].index:r.length;if(r.length!==n)throw Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${r.length} static arguments`);return new e(...r,...i)}},m1={trace:0,debug:1,info:2,warn:3,error:4,off:5},m2=class extends hj{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=m1[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let r=0;r<e.length;r++)"function"==typeof e[r]&&(e[r]=e[r]())}_log(e,r,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+r,...s)}trace(e,...r){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,r)}debug(e,...r){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,r)}info(e,...r){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,r)}warn(e,...r){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,r)}error(e,...r){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,r)}};m2=uI([uO(0,u7)],m2);var m5=class extends hj{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new hQ),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new hQ),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new hQ),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 r=Array(e);for(let s=0;s<Math.min(e,this.length);s++)r[s]=this._array[this._getCyclicIndex(s)];this._array=r,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let r=this._length;r<e;r++)this._array[r]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,r){this._array[this._getCyclicIndex(e)]=r}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,r,...s){if(r){for(let s=e;s<this._length-r;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+r)];this._length-=r,this.onDeleteEmitter.fire({index:e,amount:r})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<s.length;r++)this._array[this._getCyclicIndex(e+r)]=s[r];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let e=this._length+s.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,r,s){if(!(r<=0)){if(e<0||e>=this._length)throw Error("start argument out of range");if(e+s<0)throw Error("Cannot shift elements in list beyond index 0");if(s>0){for(let i=r-1;i>=0;i--)this.set(e+i+s,this.get(e+i));let i=e+r+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<r;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},m3=Object.freeze(new uG),m4=0,m6=class e{constructor(e,r,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);let i=r||uJ.fromCharData([0,"",1,0]);for(let r=0;r<e;++r)this.setCell(r,i);this.length=e}get(e){let r=this._data[3*e+0],s=2097151&r;return[this._data[3*e+1],2097152&r?this._combined[e]:s?uK(s):"",r>>22,2097152&r?this._combined[e].charCodeAt(this._combined[e].length-1):s]}set(e,r){this._data[3*e+1]=r[0],r[1].length>1?(this._combined[e]=r[1],this._data[3*e+0]=2097152|e|r[2]<<22):this._data[3*e+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(e){return this._data[3*e+0]>>22}hasWidth(e){return 0xc00000&this._data[3*e+0]}getFg(e){return this._data[3*e+1]}getBg(e){return this._data[3*e+2]}hasContent(e){return 4194303&this._data[3*e+0]}getCodePoint(e){let r=this._data[3*e+0];return 2097152&r?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&r}isCombined(e){return 2097152&this._data[3*e+0]}getString(e){let r=this._data[3*e+0];return 2097152&r?this._combined[e]:2097151&r?uK(2097151&r):""}isProtected(e){return 0x20000000&this._data[3*e+2]}loadCell(e,r){return m4=3*e,r.content=this._data[m4+0],r.fg=this._data[m4+1],r.bg=this._data[m4+2],2097152&r.content&&(r.combinedData=this._combined[e]),0x10000000&r.bg&&(r.extended=this._extendedAttrs[e]),r}setCell(e,r){2097152&r.content&&(this._combined[e]=r.combinedData),0x10000000&r.bg&&(this._extendedAttrs[e]=r.extended),this._data[3*e+0]=r.content,this._data[3*e+1]=r.fg,this._data[3*e+2]=r.bg}setCellFromCodepoint(e,r,s,i){0x10000000&i.bg&&(this._extendedAttrs[e]=i.extended),this._data[3*e+0]=r|s<<22,this._data[3*e+1]=i.fg,this._data[3*e+2]=i.bg}addCodepointToCell(e,r,s){let i=this._data[3*e+0];2097152&i?this._combined[e]+=uK(r):2097151&i?(this._combined[e]=uK(2097151&i)+uK(r),i&=-2097152,i|=2097152):i=4194304|r,s&&(i&=-0xc00001,i|=s<<22),this._data[3*e+0]=i}insertCells(e,r,s){if((e%=this.length)&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),r<this.length-e){let i=new uJ;for(let s=this.length-e-r-1;s>=0;--s)this.setCell(e+r+s,this.loadCell(e+s,i));for(let i=0;i<r;++i)this.setCell(e+i,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(e,r,s){if(e%=this.length,r<this.length-e){let i=new uJ;for(let s=0;s<this.length-e-r;++s)this.setCell(e+s,this.loadCell(e+r+s,i));for(let e=this.length-r;e<this.length;++e)this.setCell(e,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),0!==this.getWidth(e)||this.hasContent(e)||this.setCellFromCodepoint(e,0,1,s)}replaceCells(e,r,s,i=!1){if(i){for(e&&2===this.getWidth(e-1)&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),r<this.length&&2===this.getWidth(r-1)&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,s);e<r&&e<this.length;)this.isProtected(e)||this.setCell(e,s),e++;return}for(e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),r<this.length&&2===this.getWidth(r-1)&&this.setCellFromCodepoint(r,0,1,s);e<r&&e<this.length;)this.setCell(e++,s)}resize(e,r){if(e===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let s=3*e;if(e>this.length){if(this._data.buffer.byteLength>=4*s)this._data=new Uint32Array(this._data.buffer,0,s);else{let e=new Uint32Array(s);e.set(this._data),this._data=e}for(let s=this.length;s<e;++s)this.setCell(s,r)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let s=0;s<r.length;s++){let i=parseInt(r[s],10);i>=e&&delete this._combined[i]}let i=Object.keys(this._extendedAttrs);for(let r=0;r<i.length;r++){let s=parseInt(i[r],10);s>=e&&delete this._extendedAttrs[s]}}return this.length=e,4*s*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,r=!1){if(r){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,e);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,e)}copyFrom(e){for(let r in this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={},e._combined)this._combined[r]=e._combined[r];for(let r in this._extendedAttrs={},e._extendedAttrs)this._extendedAttrs[r]=e._extendedAttrs[r];this.isWrapped=e.isWrapped}clone(){let r=new e(0);for(let e in r._data=new Uint32Array(this._data),r.length=this.length,this._combined)r._combined[e]=this._combined[e];for(let e in this._extendedAttrs)r._extendedAttrs[e]=this._extendedAttrs[e];return r.isWrapped=this.isWrapped,r}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0]||0x3000000&this._data[3*e+2])return e+(this._data[3*e+0]>>22);return 0}copyCellsFrom(e,r,s,i,n){let a=e._data;if(n)for(let n=i-1;n>=0;n--){for(let e=0;e<3;e++)this._data[(s+n)*3+e]=a[(r+n)*3+e];0x10000000&a[(r+n)*3+2]&&(this._extendedAttrs[s+n]=e._extendedAttrs[r+n])}else for(let n=0;n<i;n++){for(let e=0;e<3;e++)this._data[(s+n)*3+e]=a[(r+n)*3+e];0x10000000&a[(r+n)*3+2]&&(this._extendedAttrs[s+n]=e._extendedAttrs[r+n])}let o=Object.keys(e._combined);for(let i=0;i<o.length;i++){let n=parseInt(o[i],10);n>=r&&(this._combined[n-r+s]=e._combined[n])}}translateToString(e,r,s,i){r=r??0,s=s??this.length,e&&(s=Math.min(s,this.getTrimmedLength())),i&&(i.length=0);let n="";for(;r<s;){let e=this._data[3*r+0],s=2097151&e,a=2097152&e?this._combined[r]:s?uK(s):" ";if(n+=a,i)for(let e=0;e<a.length;++e)i.push(r);r+=e>>22||1}return i&&i.push(r),n}};function m8(e,r,s){if(r===e.length-1)return e[r].getTrimmedLength();let i=!e[r].hasContent(s-1)&&1===e[r].getWidth(s-1),n=2===e[r+1].getWidth(0);return i&&n?s-1:s}var m7=class e{constructor(r){this.line=r,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new hQ),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),hb(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};m7._nextId=1;var m9={},ge=m9.B;m9[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:"≥","{":"π","|":"≠","}":"£","~":"·"},m9.A={"#":"£"},m9.B=void 0,m9[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},m9.C=m9[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},m9.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},m9.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},m9.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},m9.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},m9.E=m9[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},m9.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},m9.H=m9[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},m9["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var gt=class{constructor(e,r,s){this._hasScrollback=e,this._optionsService=r,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=m3.clone(),this.savedCharset=ge,this.markers=[],this._nullCell=uJ.fromCharData([0,"",1,0]),this._whitespaceCell=uJ.fromCharData([0," ",1,32]),this._isClearing=!1,this._memoryCleanupQueue=new mA,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new m5(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 uX),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 uX),this._whitespaceCell}getBlankLine(e,r){return new m6(this._bufferService.cols,this.getNullCell(e),r)}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 r=e+this._optionsService.rawOptions.scrollback;return r>0xffffffff?0xffffffff:r}fillViewportRows(e){if(0===this.lines.length){void 0===e&&(e=m3);let r=this._rows;for(;r--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new m5(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,r){let s=this.getNullCell(m3),i=0,n=this._getCorrectBufferLength(r);if(n>this.lines.maxLength&&(this.lines.maxLength=n),this.lines.length>0){if(this._cols<e)for(let r=0;r<this.lines.length;r++)i+=+this.lines.get(r).resize(e,s);let a=0;if(this._rows<r)for(let i=this._rows;i<r;i++)this.lines.length<r+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new m6(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new m6(e,s)));else for(let e=this._rows;e>r;e--)this.lines.length>r+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(n<this.lines.maxLength){let e=this.lines.length-n;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=n}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,r-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=r-1,this._isReflowEnabled&&(this._reflow(e,r),this._cols>e))for(let r=0;r<this.lines.length;r++)i+=+this.lines.get(r).resize(e,s);this._cols=e,this._rows=r,this._memoryCleanupQueue.clear(),i>.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 r=0;for(;this._memoryCleanupPosition<this.lines.length;)if((r+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory())>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&"conpty"===e.backend&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,r){this._cols!==e&&(e>this._cols?this._reflowLarger(e,r):this._reflowSmaller(e,r))}_reflowLarger(e,r){let s=this._optionsService.rawOptions.reflowCursorLine,i=function(e,r,s,i,n,a){let o=[];for(let l=0;l<e.length-1;l++){let c=l,d=e.get(++c);if(!d.isWrapped)continue;let u=[e.get(l)];for(;c<e.length&&d.isWrapped;)u.push(d),d=e.get(++c);if(!a&&i>=l&&i<c){l+=u.length-1;continue}let h=0,f=m8(u,0,r),p=1,m=0;for(;p<u.length;){let e=m8(u,p,r),i=Math.min(e-m,s-f);u[h].copyCellsFrom(u[p],m,f,i,!1),(f+=i)===s&&(h++,f=0),(m+=i)===e&&(p++,m=0),0===f&&0!==h&&2===u[h-1].getWidth(s-1)&&(u[h].copyCellsFrom(u[h-1],s-1,f++,1,!1),u[h-1].setCell(s-1,n))}u[h].replaceCells(f,s,n);let g=0;for(let e=u.length-1;e>0&&(e>h||0===u[e].getTrimmedLength());e--)g++;g>0&&(o.push(l+u.length-g),o.push(g)),l+=u.length-1}return o}(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(m3),s);if(i.length>0){let s=function(e,r){let s=[],i=0,n=r[0],a=0;for(let o=0;o<e.length;o++)if(n===o){let s=r[++i];e.onDeleteEmitter.fire({index:o-a,amount:s}),o+=s-1,a+=s,n=r[++i]}else s.push(o);return{layout:s,countRemoved:a}}(this.lines,i);(function(e,r){let s=[];for(let i=0;i<r.length;i++)s.push(e.get(r[i]));for(let r=0;r<s.length;r++)e.set(r,s[r]);e.length=r.length})(this.lines,s.layout),this._reflowLargerAdjustViewport(e,r,s.countRemoved)}}_reflowLargerAdjustViewport(e,r,s){let i=this.getNullCell(m3),n=s;for(;n-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<r&&this.lines.push(new m6(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,r){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(m3),n=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let l=this.lines.get(o);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let c=[l];for(;l.isWrapped&&o>0;)l=this.lines.get(--o),c.unshift(l);if(!s){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let d=c[c.length-1].getTrimmedLength(),u=function(e,r,s){let i=[],n=e.map((s,i)=>m8(e,i,r)).reduce((e,r)=>e+r),a=0,o=0,l=0;for(;l<n;){if(n-l<s){i.push(n-l);break}a+=s;let c=m8(e,o,r);a>c&&(a-=c,o++);let d=2===e[o].getWidth(a-1);d&&a--;let u=d?s-1:s;i.push(u),l+=u}return i}(c,this._cols,e),h=u.length-c.length,f;f=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+h):Math.max(0,this.lines.length-this.lines.maxLength+h);let p=[];for(let e=0;e<h;e++){let e=this.getBlankLine(m3,!0);p.push(e)}p.length>0&&(n.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,g=u[m];0===g&&(g=u[--m]);let x=c.length-h-1,v=d;for(;x>=0;){let e=Math.min(v,g);if(void 0===c[m])break;c[m].copyCellsFrom(c[x],v-e,g-e,e,!0),0==(g-=e)&&(g=u[--m]),0==(v-=e)&&(v=m8(c,Math.max(--x,0),this._cols))}for(let r=0;r<c.length;r++)u[r]<e&&c[r].setCell(u[r],i);let _=h-f;for(;_-- >0;)0===this.ybase?this.y<r-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-r&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+h,this.ybase+r-1)}if(n.length>0){let e=[],r=[];for(let e=0;e<this.lines.length;e++)r.push(this.lines.get(e));let s=this.lines.length,i=s-1,o=0,l=n[0];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let d=Math.min(this.lines.maxLength-1,s+a-1);d>=0;d--)if(l&&l.start>i+c){for(let e=l.newLines.length-1;e>=0;e--)this.lines.set(d--,l.newLines[e]);d++,e.push({index:i+1,amount:l.newLines.length}),c+=l.newLines.length,l=n[++o]}else this.lines.set(d,r[i--]);let d=0;for(let r=e.length-1;r>=0;r--)e[r].index+=d,this.lines.onInsertEmitter.fire(e[r]),d+=e[r].amount;let u=Math.max(0,s+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,r,s=0,i){let n=this.lines.get(e);return n?n.translateToString(r,s,i):""}getWrappedRangeForLine(e){let r=e,s=e;for(;r>0&&this.lines.get(r).isWrapped;)r--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:r,last:s}}setupTabStops(e){for(null!=e?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(null==e&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(null==e&&(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 r=0;r<this.markers.length;r++)this.markers[r].line===e&&(this.markers[r].dispose(),this.markers.splice(r--,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 r=new m7(e);return this.markers.push(r),r.register(this.lines.onTrim(e=>{r.line-=e,r.line<0&&r.dispose()})),r.register(this.lines.onInsert(e=>{r.line>=e.index&&(r.line+=e.amount)})),r.register(this.lines.onDelete(e=>{r.line>=e.index&&r.line<e.index+e.amount&&r.dispose(),r.line>e.index&&(r.line-=e.amount)})),r.register(r.onDispose(()=>this._removeMarker(r))),r}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},gr=class extends hj{constructor(e,r){super(),this._optionsService=e,this._bufferService=r,this._onBufferActivate=this._register(new hQ),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 gt(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new gt(!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,r){this._normal.resize(e,r),this._alt.resize(e,r),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},gs=class extends hj{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new hQ),this.onResize=this._onResize.event,this._onScroll=this._register(new hQ),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,2),this.rows=Math.max(e.rawOptions.rows||0,1),this.buffers=this._register(new gr(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,r){let s=this.cols!==e,i=this.rows!==r;this.cols=e,this.rows=r,this.buffers.resize(e,r),this._onResize.fire({cols:e,rows:r,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,r=!1){let s=this.buffer,i;(i=this._cachedBlankLine)&&i.length===this.cols&&i.getFg(0)===e.fg&&i.getBg(0)===e.bg||(i=s.getBlankLine(e,r),this._cachedBlankLine=i),i.isWrapped=r;let n=s.ybase+s.scrollTop,a=s.ybase+s.scrollBottom;if(0===s.scrollTop){let e=s.lines.isFull;a===s.lines.length-1?e?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(a+1,0,i.clone()),e?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let e=a-n+1;s.lines.shiftElements(n+1,e-1,-1),s.lines.set(a,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,r){let s=this.buffer;if(e<0){if(0===s.ydisp)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(r||this._onScroll.fire(s.ydisp))}};gs=uI([uO(0,u7)],gs);var gi={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:mw,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},gn=["normal","bold","100","200","300","400","500","600","700","800","900"],ga=class extends hj{constructor(e){super(),this._onOptionChange=this._register(new hQ),this.onOptionChange=this._onOptionChange.event;let r={...gi};for(let s in e)if(s in r)try{let i=e[s];r[s]=this._sanitizeAndValidateOption(s,i)}catch(e){console.error(e)}this.rawOptions=r,this.options={...r},this._setupOptions(),this._register(hw(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,r){return this.onOptionChange(s=>{s===e&&r(this.rawOptions[e])})}onMultipleOptionChange(e,r){return this.onOptionChange(s=>{-1!==e.indexOf(s)&&r()})}_setupOptions(){let e=e=>{if(!(e in gi))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},r=(e,r)=>{if(!(e in gi))throw Error(`No option with key "${e}"`);r=this._sanitizeAndValidateOption(e,r),this.rawOptions[e]!==r&&(this.rawOptions[e]=r,this._onOptionChange.fire(e))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:r.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,r){switch(e){case"cursorStyle":var s;if(r||(r=gi[e]),"block"!==(s=r)&&"underline"!==s&&"bar"!==s)throw Error(`"${r}" is not a valid value for ${e}`);break;case"wordSeparator":r||(r=gi[e]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof r&&1<=r&&r<=1e3)break;r=gn.includes(r)?r:gi[e];break;case"cursorWidth":r=Math.floor(r);case"lineHeight":case"tabStopWidth":if(r<1)throw Error(`${e} cannot be less than 1, value: ${r}`);break;case"minimumContrastRatio":r=Math.max(1,Math.min(21,Math.round(10*r)/10));break;case"scrollback":if((r=Math.min(r,0xffffffff))<0)throw Error(`${e} cannot be less than 0, value: ${r}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(r<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${r}`);break;case"rows":case"cols":if(!r&&0!==r)throw Error(`${e} must be numeric, value: ${r}`);break;case"windowsPty":r=r??{}}return r}};function go(e,r=5){if("object"!=typeof e)return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=r<=1?e[i]:e[i]&&go(e[i],r-1);return s}var gl=Object.freeze({insertMode:!1}),gc=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),gd=class extends hj{constructor(e,r,s){super(),this._bufferService=e,this._logService=r,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new hQ),this.onData=this._onData.event,this._onUserInput=this._register(new hQ),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new hQ),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new hQ),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=go(gl),this.decPrivateModes=go(gc)}reset(){this.modes=go(gl),this.decPrivateModes=go(gc)}triggerDataEvent(e,r=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;r&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),r&&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))}};gd=uI([uO(0,u2),uO(1,u8),uO(2,u7)],gd);var gu={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>32!==e.action},DRAG:{events:23,restrict:e=>32!==e.action||3!==e.button},ANY:{events:31,restrict:e=>!0}};function gh(e,r){let s=16*!!e.ctrl|4*!!e.shift|8*!!e.alt;return 4===e.button?(s|=64,s|=e.action):(s|=3&e.button,4&e.button&&(s|=64),8&e.button&&(s|=128),32===e.action?s|=32:0!==e.action||r||(s|=3)),s}var gf=String.fromCharCode,gp={DEFAULT:e=>{let r=[gh(e,!1)+32,e.col+32,e.row+32];return r[0]>255||r[1]>255||r[2]>255?"":`\x1b[M${gf(r[0])}${gf(r[1])}${gf(r[2])}`},SGR:e=>{let r=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${gh(e,!0)};${e.col};${e.row}${r}`},SGR_PIXELS:e=>{let r=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${gh(e,!0)};${e.x};${e.y}${r}`}},gm=class extends hj{constructor(e,r,s){for(let i of(super(),this._bufferService=e,this._coreService=r,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new hQ),this.onProtocolChange=this._onProtocolChange.event,Object.keys(gu)))this.addProtocol(i,gu[i]);for(let e of Object.keys(gp))this.addEncoding(e,gp[e]);this.reset()}addProtocol(e,r){this._protocols[e]=r}addEncoding(e,r){this._encodings[e]=r}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}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,r,s){if(0===e.deltaY||e.shiftKey||void 0===r||void 0===s)return 0;let i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r/s+0,50>Math.abs(e.deltaY)&&(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,r){return r.altKey||r.ctrlKey||r.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||4===e.button&&32===e.action||3===e.button&&32!==e.action||4!==e.button&&(2===e.action||3===e.action)||(e.col++,e.row++,32===e.action&&this._lastEvent&&this._equalEvents(this._lastEvent,e,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(e))return!1;let r=this._encodings[this._activeEncoding](e);return r&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(r):this._coreService.triggerDataEvent(r,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_equalEvents(e,r,s){if(s){if(e.x!==r.x||e.y!==r.y)return!1}else if(e.col!==r.col||e.row!==r.row)return!1;return e.button===r.button&&e.action===r.action&&e.ctrl===r.ctrl&&e.alt===r.alt&&e.shift===r.shift}};gm=uI([uO(0,u2),uO(1,u3),uO(2,u7)],gm);var gg,gx,gv,g_,gy,gb,gw=[[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]],gS=[[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]],gC=class{constructor(){if(this.version="6",!gb){(gb=new Uint8Array(65536)).fill(1),gb[0]=0,gb.fill(0,1,32),gb.fill(0,127,160),gb.fill(2,4352,4448),gb[9001]=2,gb[9002]=2,gb.fill(2,11904,42192),gb[12351]=1,gb.fill(2,44032,55204),gb.fill(2,63744,64256),gb.fill(2,65040,65050),gb.fill(2,65072,65136),gb.fill(2,65280,65377),gb.fill(2,65504,65511);for(let e=0;e<gw.length;++e)gb.fill(0,gw[e][0],gw[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?gb[e]:!function(e,r){let s=0,i=r.length-1,n;if(e<r[0][0]||e>r[i][1])return!1;for(;i>=s;)if(e>r[n=s+i>>1][1])s=n+1;else{if(!(e<r[n][0]))return!0;i=n-1}return!1}(e,gS)?e>=131072&&e<=196605||e>=196608&&e<=262141?2:1:0}charProperties(e,r){let s=this.wcwidth(e),i=0===s&&0!==r;if(i){let e=gj.extractWidth(r);0===e?i=!1:e>s&&(s=e)}return gj.createPropertyValue(0,s,i)}},gj=class e{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new hQ,this.onChange=this._onChange.event;let e=new gC;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(1&e)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,r,s=!1){return(0xffffff&e)<<3|(3&r)<<1|!!s}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(r){let s=0,i=0,n=r.length;for(let a=0;a<n;++a){let o=r.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=n)return s+this.wcwidth(o);let e=r.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:s+=this.wcwidth(e)}let l=this.charProperties(o,i),c=e.extractWidth(l);e.extractShouldJoin(l)&&(c-=e.extractWidth(i)),s+=c,i=l}return s}charProperties(e,r){return this._activeProvider.charProperties(e,r)}},gk=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,r){this._charsets[e]=r,this.glevel===e&&(this.charset=r)}};function gN(e){let r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&r&&(s.isWrapped=0!==r[3]&&32!==r[3])}var gE=class e{constructor(e=32,r=32){if(this.maxLength=e,this.maxSubParamsLength=r,r>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(r){let s=new e;if(!r.length)return s;for(let e=+!!Array.isArray(r[0]);e<r.length;++e){let i=r[e];if(Array.isArray(i))for(let e=0;e<i.length;++e)s.addSubParam(i[e]);else s.addParam(i)}return s}clone(){let r=new e(this.maxLength,this.maxSubParamsLength);return r.params.set(this.params),r.length=this.length,r._subParams.set(this._subParams),r._subParamsLength=this._subParamsLength,r._subParamsIdx.set(this._subParamsIdx),r._rejectDigits=this._rejectDigits,r._rejectSubDigits=this._rejectSubDigits,r._digitIsSub=this._digitIsSub,r}toArray(){let e=[];for(let r=0;r<this.length;++r){e.push(this.params[r]);let s=this._subParamsIdx[r]>>8,i=255&this._subParamsIdx[r];i-s>0&&e.push(Array.prototype.slice.call(this._subParams,s,i))}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>0x7fffffff?0x7fffffff: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>0x7fffffff?0x7fffffff:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let r=this._subParamsIdx[e]>>8,s=255&this._subParamsIdx[e];return s-r>0?this._subParams.subarray(r,s):null}getSubParamsAll(){let e={};for(let r=0;r<this.length;++r){let s=this._subParamsIdx[r]>>8,i=255&this._subParamsIdx[r];i-s>0&&(e[r]=this._subParams.slice(s,i))}return e}addDigit(e){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,i=s[r-1];s[r-1]=~i?Math.min(10*i+e,0x7fffffff):e}},gD=[],gR=class{constructor(){this._state=0,this._active=gD,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,r){void 0===this._handlers[e]&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(r),{dispose:()=>{let e=s.indexOf(r);-1!==e&&s.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=gD}reset(){if(2===this._state)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=gD,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||gD,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,"START")}_put(e,r,s){if(this._active.length)for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,r,s);else this._handlerFb(this._id,"PUT",uq(e,r,s))}start(){this.reset(),this._state=1}put(e,r,s){if(3!==this._state){if(1===this._state)for(;r<s;){let s=e[r++];if(59===s){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}-1===this._id&&(this._id=0),this._id=10*this._id+s-48}2===this._state&&s-r>0&&this._put(e,r,s)}}end(e,r=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=r,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===s){for(;i>=0&&!0!==(s=this._active[i].end(e));i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if((s=this._active[i].end(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}else this._handlerFb(this._id,"END",e);this._active=gD,this._id=-1,this._state=0}}},gA=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,r,s){this._hitLimit||(this._data+=uq(e,r,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let r=!1;if(this._hitLimit)r=!1;else if(e&&(r=this._handler(this._data))instanceof Promise)return r.then(e=>(this._data="",this._hitLimit=!1,e));return this._data="",this._hitLimit=!1,r}},gM=[],gF=class{constructor(){this._handlers=Object.create(null),this._active=gM,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=gM}registerHandler(e,r){void 0===this._handlers[e]&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(r),{dispose:()=>{let e=s.indexOf(r);-1!==e&&s.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=gM,this._ident=0}hook(e,r){if(this.reset(),this._ident=e,this._active=this._handlers[e]||gM,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(r);else this._handlerFb(this._ident,"HOOK",r)}put(e,r,s){if(this._active.length)for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,r,s);else this._handlerFb(this._ident,"PUT",uq(e,r,s))}unhook(e,r=!0){if(this._active.length){let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=r,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===s){for(;i>=0&&!0!==(s=this._active[i].unhook(e));i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if((s=this._active[i].unhook(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}else this._handlerFb(this._ident,"UNHOOK",e);this._active=gM,this._ident=0}},gT=new gE;gT.addParam(0);var gP=class{constructor(e){this._handler=e,this._data="",this._params=gT,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():gT,this._data="",this._hitLimit=!1}put(e,r,s){this._hitLimit||(this._data+=uq(e,r,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let r=!1;if(this._hitLimit)r=!1;else if(e&&(r=this._handler(this._data,this._params))instanceof Promise)return r.then(e=>(this._params=gT,this._data="",this._hitLimit=!1,e));return this._params=gT,this._data="",this._hitLimit=!1,r}},gB=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,r){this.table.fill(e<<4|r)}add(e,r,s,i){this.table[r<<8|e]=s<<4|i}addMany(e,r,s,i){for(let n=0;n<e.length;n++)this.table[r<<8|e[n]]=s<<4|i}},gL=function(){let e=new gB(4095),r=Array.apply(null,Array(256)).map((e,r)=>r),s=(e,s)=>r.slice(e,s),i=s(32,127),n=s(0,24);n.push(25),n.push.apply(n,s(28,32));let a=s(0,14),o;for(o in e.setDefault(1,0),e.addMany(i,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(s(128,144),o,3,0),e.addMany(s(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(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(160,0,2,0),e.add(160,8,5,8),e.add(160,6,0,6),e.add(160,11,0,11),e.add(160,13,13,13),e}(),gI=class extends hj{constructor(e=gL){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 gE,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,r,s)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,r)=>{},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(hw(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new gR),this._dcsParser=this._register(new gF),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,r=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw Error("only one byte as prefix supported");if((s=e.prefix.charCodeAt(0))&&60>s||s>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 r=0;r<e.intermediates.length;++r){let i=e.intermediates.charCodeAt(r);if(32>i||i>47)throw Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=i}}if(1!==e.final.length)throw Error("final must be a single byte");let i=e.final.charCodeAt(0);if(r[0]>i||i>r[1])throw Error(`final must be in range ${r[0]} .. ${r[1]}`);return s<<=8,s|=i}identToString(e){let r=[];for(;e;)r.push(String.fromCharCode(255&e)),e>>=8;return r.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,r){let s=this._identifier(e,[48,126]);void 0===this._escHandlers[s]&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(r),{dispose:()=>{let e=i.indexOf(r);-1!==e&&i.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,r){this._executeHandlers[e.charCodeAt(0)]=r}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,r){let s=this._identifier(e);void 0===this._csiHandlers[s]&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(r),{dispose:()=>{let e=i.indexOf(r);-1!==e&&i.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,r){return this._dcsParser.registerHandler(this._identifier(e),r)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,r){return this._oscParser.registerHandler(e,r)}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,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,r,s,i,n){this._parseStack.state=e,this._parseStack.handlers=r,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=n}parse(e,r,s){let i=0,n=0,a=0,o;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(void 0===s||1===this._parseStack.state)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let r=this._parseStack.handlers,n=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===s&&n>-1){for(;n>=0&&!0!==(o=r[n](this._params));n--)if(o instanceof Promise)return this._parseStack.handlerPos=n,o}this._parseStack.handlers=[];break;case 4:if(!1===s&&n>-1){for(;n>=0&&!0!==(o=r[n]());n--)if(o instanceof Promise)return this._parseStack.handlerPos=n,o}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(24!==i&&26!==i,s))return o;27===i&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],o=this._oscParser.end(24!==i&&26!==i,s))return o;27===i&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let s=a;s<r;++s){switch(i=e[s],(n=this._transitions.table[this.currentState<<8|(i<160?i:160)])>>4){case 2:for(let n=s+1;;++n)if(n>=r||(i=e[n])<32||i>126&&i<160||++n>=r||(i=e[n])<32||i>126&&i<160||++n>=r||(i=e[n])<32||i>126&&i<160||++n>=r||(i=e[n])<32||i>126&&i<160){this._printHandler(e,s,n),s=n-1;break}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:s,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|i],l=a?a.length-1:-1;for(;l>=0&&!0!==(o=a[l](this._params));l--)if(o instanceof Promise)return this._preserveStack(3,a,l,n,s),o;l<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++s<r&&(i=e[s])>47&&i<60)s--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let c=this._escHandlers[this._collect<<8|i],d=c?c.length-1:-1;for(;d>=0&&!0!==(o=c[d]());d--)if(o instanceof Promise)return this._preserveStack(4,c,d,n,s),o;d<0&&this._escHandlerFb(this._collect<<8|i),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|i,this._params);break;case 13:for(let n=s+1;;++n)if(n>=r||24===(i=e[n])||26===i||27===i||i>127&&i<160){this._dcsParser.put(e,s,n),s=n-1;break}break;case 14:if(o=this._dcsParser.unhook(24!==i&&26!==i))return this._preserveStack(6,[],0,n,s),o;27===i&&(n|=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 n=s+1;;n++)if(n>=r||(i=e[n])<32||i>127&&i<160){this._oscParser.put(e,s,n),s=n-1;break}break;case 6:if(o=this._oscParser.end(24!==i&&26!==i))return this._preserveStack(5,[],0,n,s),o;27===i&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&n}}},gO=/^([\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})$/,gz=/^[\da-f]+$/;function g$(e){if(!e)return;let r=e.toLowerCase();if(0===r.indexOf("rgb:")){r=r.slice(4);let e=gO.exec(r);if(e){let r=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/r*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/r*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/r*255)]}}else if(0===r.indexOf("#")&&(r=r.slice(1),gz.exec(r)&&[3,6,9,12].includes(r.length))){let e=r.length/3,s=[0,0,0];for(let i=0;i<3;++i){let n=parseInt(r.slice(e*i,e*i+e),16);s[i]=1===e?n<<4:2===e?n:3===e?n>>4:n>>8}return s}}function gW(e,r){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(r){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}var gH={"(":0,")":1,"*":2,"+":3,"-":1,".":2};function gU(e,r){if(e>24)return r.setWinLines||!1;switch(e){case 1:return!!r.restoreWin;case 2:return!!r.minimizeWin;case 3:return!!r.setWinPosition;case 4:return!!r.setWinSizePixels;case 5:return!!r.raiseWin;case 6:return!!r.lowerWin;case 7:return!!r.refreshWin;case 8:return!!r.setWinSizeChars;case 9:return!!r.maximizeWin;case 10:return!!r.fullscreenWin;case 11:return!!r.getWinState;case 13:return!!r.getWinPosition;case 14:return!!r.getWinSizePixels;case 15:return!!r.getScreenSizePixels;case 16:return!!r.getCellSizePixels;case 18:return!!r.getWinSizeChars;case 19:return!!r.getScreenSizeChars;case 20:return!!r.getIconTitle;case 21:return!!r.getWinTitle;case 22:return!!r.pushTitle;case 23:return!!r.popTitle;case 24:return!!r.setWinLines}return!1}var gK=0,gq=class extends hj{constructor(e,r,s,i,n,a,o,l,c=new gI){for(let d in super(),this._bufferService=e,this._charsetService=r,this._coreService=s,this._logService=i,this._optionsService=n,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new uV,this._utf8Decoder=new uY,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=m3.clone(),this._eraseAttrDataInternal=m3.clone(),this._onRequestBell=this._register(new hQ),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new hQ),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new hQ),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new hQ),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new hQ),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new hQ),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new hQ),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new hQ),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new hQ),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new hQ),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new hQ),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new hQ),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new hQ),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 gV(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,r)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(e),params:r.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,r,s)=>{this._logService.debug("Unknown OSC code: ",{identifier:e,action:r,data:s})}),this._parser.setDcsHandlerFallback((e,r,s)=>{"HOOK"===r&&(s=s.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(e),action:r,payload:s})}),this._parser.setPrintHandler((e,r,s)=>this.print(e,r,s)),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(pF.BEL,()=>this.bell()),this._parser.setExecuteHandler(pF.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(pF.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(pF.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(pF.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(pF.BS,()=>this.backspace()),this._parser.setExecuteHandler(pF.HT,()=>this.tab()),this._parser.setExecuteHandler(pF.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(pF.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(pT.IND,()=>this.index()),this._parser.setExecuteHandler(pT.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(pT.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new gA(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new gA(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new gA(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new gA(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new gA(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new gA(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new gA(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new gA(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new gA(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new gA(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new gA(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new gA(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()),m9)this._parser.registerEscHandler({intermediates:"(",final:d},()=>this.selectCharset("("+d)),this._parser.registerEscHandler({intermediates:")",final:d},()=>this.selectCharset(")"+d)),this._parser.registerEscHandler({intermediates:"*",final:d},()=>this.selectCharset("*"+d)),this._parser.registerEscHandler({intermediates:"+",final:d},()=>this.selectCharset("+"+d)),this._parser.registerEscHandler({intermediates:"-",final:d},()=>this.selectCharset("-"+d)),this._parser.registerEscHandler({intermediates:".",final:d},()=>this.selectCharset("."+d)),this._parser.registerEscHandler({intermediates:"/",final:d},()=>this.selectCharset("/"+d));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 gP((e,r)=>this.requestStatusString(e,r)))}getAttrData(){return this._curAttrData}_preserveStack(e,r,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=r,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),5e3))]).catch(e=>{if("#SLOW_TIMEOUT"!==e)throw e;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,r){let s,i=this._activeBuffer.x,n=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,r))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>131072&&(a=this._parseStack.position+131072)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${"string"==typeof e?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join("")}"`}`),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof e?e.split("").map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<131072&&(this._parseBuffer=new Uint32Array(Math.min(e.length,131072))),o||this._dirtyRowTracker.clearRange(),e.length>131072)for(let r=a;r<e.length;r+=131072){let a=r+131072<e.length?r+131072:e.length,o="string"==typeof e?this._stringDecoder.decode(e.substring(r,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(r,a),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,o))return this._preserveStack(i,n,o,r),this._logSlowResolvingAsync(s),s}else if(!o){let r="string"==typeof e?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,r))return this._preserveStack(i,n,r,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let l=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(l,this._bufferService.rows-1)})}print(e,r,s){let i,n,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,d=this._coreService.modes.insertMode,u=this._curAttrData,h=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-r>0&&2===h.getWidth(this._activeBuffer.x-1)&&h.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=r;p<s;++p){if((i=e[p])<127&&a){let e=a[String.fromCharCode(i)];e&&(i=e.charCodeAt(0))}let r=this._unicodeService.charProperties(i,f);n=gj.extractWidth(r);let s=gj.extractShouldJoin(r),m=s?gj.extractWidth(f):0;if(f=r,o&&this._onA11yChar.fire(uK(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-m>l){if(c){let e=h,r=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),h=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&h instanceof m6&&h.copyCellsFrom(e,r,0,m,!1);r<l;)e.setCellFromCodepoint(r++,0,1,u)}else if(this._activeBuffer.x=l-1,2===n)continue}if(s&&this._activeBuffer.x){let e=h.getWidth(this._activeBuffer.x-1)?1:2;h.addCodepointToCell(this._activeBuffer.x-e,i,n);for(let e=n-m;--e>=0;)h.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(d&&(h.insertCells(this._activeBuffer.x,n-m,this._activeBuffer.getNullCell(u)),2===h.getWidth(l-1)&&h.setCellFromCodepoint(l-1,0,1,u)),h.setCellFromCodepoint(this._activeBuffer.x++,i,n,u),n>0)for(;--n;)h.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-r>0&&0===h.getWidth(this._activeBuffer.x)&&!h.hasContent(this._activeBuffer.x)&&h.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,r){return"t"!==e.final||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,r):this._parser.registerCsiHandler(e,e=>!gU(e.params[0],this._optionsService.rawOptions.windowOptions)||r(e))}registerDcsHandler(e,r){return this._parser.registerDcsHandler(e,new gP(r))}registerEscHandler(e,r){return this._parser.registerEscHandler(e,r)}registerOscHandler(e,r){return this._parser.registerOscHandler(e,new gA(r))}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(0===this._activeBuffer.x&&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,r){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+r):(this._activeBuffer.x=e,this._activeBuffer.y=r),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,r){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+r)}cursorUp(e){let r=this._activeBuffer.y-this._activeBuffer.scrollTop;return r>=0?this._moveCursor(0,-Math.min(r,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let r=this._activeBuffer.scrollBottom-this._activeBuffer.y;return r>=0?this._moveCursor(0,Math.min(r,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 r=e.params[0];return 0===r?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===r&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let r=e.params[0]||1;for(;r--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let r=e.params[0]||1;for(;r--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let r=e.params[0];return 1===r&&(this._curAttrData.bg|=0x20000000),(2===r||0===r)&&(this._curAttrData.bg&=-0x20000001),!0}_eraseInBufferLine(e,r,s,i=!1,n=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(r,s,this._activeBuffer.getNullCell(this._eraseAttrData()),n),i&&(a.isWrapped=!1)}_resetBufferLine(e,r=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),r),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,r=!1){let s;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,r);s<this._bufferService.rows;s++)this._resetBufferLine(s,r);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,r),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,r);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,r);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,0),this._onScroll.fire(0))}return!0}eraseInLine(e,r=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,r);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,r);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,r)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let r=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;r--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(s,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 r=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;r--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,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 r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.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 r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let r=e.params[0]||1;for(;r--;)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 r=e.params[0]||1;for(;r--;)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(m3));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 r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.deleteCells(0,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.insertCells(0,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.insertCells(this._activeBuffer.x,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.deleteCells(this._activeBuffer.x,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.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 r=this._parser.precedingJoinState;if(!r)return!0;let s=e.params[0]||1,i=gj.extractWidth(r),n=this._activeBuffer.x-i,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(n),o=new Uint32Array(a.length*s),l=0;for(let e=0;e<a.length;){let r=a.codePointAt(e)||0;o[l++]=r,e+=r>65535?2:1}let c=l;for(let e=1;e<s;++e)o.copyWithin(c,0,l),c+=l;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(pF.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(pF.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(pF.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(pF.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(pF.ESC+"[>83;40003;0c")),!0}_is(e){return 0===(this._optionsService.rawOptions.termName+"").indexOf(e)}setMode(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,ge),this._charsetService.setgCharset(1,ge),this._charsetService.setgCharset(2,ge),this._charsetService.setgCharset(3,ge);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}return!0}resetMode(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let r=0;r<e.length;r++)switch(e.params[r]){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:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===e.params[r]&&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)}return!0}requestMode(e,r){let s,i,n,a;(i=s||={})[i.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",i[i.SET=1]="SET",i[i.RESET=2]="RESET",i[i.PERMANENTLY_SET=3]="PERMANENTLY_SET",i[i.PERMANENTLY_RESET=4]="PERMANENTLY_RESET";let o=this._coreService.decPrivateModes,{activeProtocol:l,activeEncoding:c}=this._coreMouseService,d=this._coreService,{buffers:u,cols:h}=this._bufferService,{active:f,alt:p}=u,m=this._optionsService.rawOptions,g=e=>e?1:2,x=e.params[0];return n=x,a=r?2===x?4:4===x?g(d.modes.insertMode):12===x?3:20===x?g(m.convertEol):0:1===x?g(o.applicationCursorKeys):3===x?m.windowOptions.setWinLines?80===h?2:+(132===h):0:6===x?g(o.origin):7===x?g(o.wraparound):8===x?3:9===x?g("X10"===l):12===x?g(m.cursorBlink):25===x?g(!d.isCursorHidden):45===x?g(o.reverseWraparound):66===x?g(o.applicationKeypad):67===x?4:1e3===x?g("VT200"===l):1002===x?g("DRAG"===l):1003===x?g("ANY"===l):1004===x?g(o.sendFocus):1005===x?4:1006===x?g("SGR"===c):1015===x?4:1016===x?g("SGR_PIXELS"===c):1048===x?1:47===x||1047===x||1049===x?g(f===p):2004===x?g(o.bracketedPasteMode):2026===x?g(o.synchronizedOutput):0,d.triggerDataEvent(`${pF.ESC}[${r?"":"?"}${n};${a}$y`),!0}_updateAttrColor(e,r,s,i,n){return 2===r?(e|=0x3000000,e&=-0x1000000,e|=uG.fromColorRGB([s,i,n])):5===r&&(e&=-0x3000100,e|=0x2000000|255&s),e}_extractColor(e,r,s){let i=[0,0,-1,0,0,0],n=0,a=0;do{if(i[a+n]=e.params[r+a],e.hasSubParams(r+a)){let s=e.getSubParams(r+a),o=0;do 5===i[1]&&(n=1),i[a+o+1+n]=s[o];while(++o<s.length&&o+a+1+n<i.length)break}if(5===i[1]&&a+n>=2||2===i[1]&&a+n>=5)break;i[1]&&(n=1)}while(++a+r<e.length&&a+n<i.length)for(let e=2;e<i.length;++e)-1===i[e]&&(i[e]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return a}_processUnderline(e,r){r.extended=r.extended.clone(),(!~e||e>5)&&(e=1),r.extended.underlineStyle=e,r.fg|=0x10000000,0===e&&(r.fg&=-0x10000001),r.updateExtended()}_processSGR0(e){e.fg=m3.fg,e.bg=m3.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-0x4000000,e.updateExtended()}charAttributes(e){if(1===e.length&&0===e.params[0])return this._processSGR0(this._curAttrData),!0;let r=e.length,s,i=this._curAttrData;for(let n=0;n<r;n++)(s=e.params[n])>=30&&s<=37?(i.fg&=-0x3000100,i.fg|=0x1000000|s-30):s>=40&&s<=47?(i.bg&=-0x3000100,i.bg|=0x1000000|s-40):s>=90&&s<=97?(i.fg&=-0x3000100,i.fg|=0x1000000|s-90|8):s>=100&&s<=107?(i.bg&=-0x3000100,i.bg|=0x1000000|s-100|8):0===s?this._processSGR0(i):1===s?i.fg|=0x8000000:3===s?i.bg|=0x4000000:4===s?(i.fg|=0x10000000,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,i)):5===s?i.fg|=0x20000000:7===s?i.fg|=0x4000000:8===s?i.fg|=0x40000000:9===s?i.fg|=0x80000000:2===s?i.bg|=0x8000000:21===s?this._processUnderline(2,i):22===s?(i.fg&=-0x8000001,i.bg&=-0x8000001):23===s?i.bg&=-0x4000001:24===s?(i.fg&=-0x10000001,this._processUnderline(0,i)):25===s?i.fg&=-0x20000001:27===s?i.fg&=-0x4000001:28===s?i.fg&=-0x40000001:29===s?i.fg&=0x7fffffff:39===s?(i.fg&=-0x4000000,i.fg|=0xffffff&m3.fg):49===s?(i.bg&=-0x4000000,i.bg|=0xffffff&m3.bg):38===s||48===s||58===s?n+=this._extractColor(e,n,i):53===s?i.bg|=0x40000000:55===s?i.bg&=-0x40000001:59===s?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):100===s?(i.fg&=-0x4000000,i.fg|=0xffffff&m3.fg,i.bg&=-0x4000000,i.bg|=0xffffff&m3.bg):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${pF.ESC}[0n`);break;case 6:let r=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pF.ESC}[${r};${s}R`)}return!0}deviceStatusPrivate(e){if(6===e.params[0]){let e=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pF.ESC}[?${e};${r}R`)}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=m3.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 r=0===e.length?1:e.params[0];if(0===r)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(r){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"}this._coreService.decPrivateModes.cursorBlink=r%2==1}return!0}setScrollRegion(e){let r=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||0===s)&&(s=this._bufferService.rows),s>r&&(this._activeBuffer.scrollTop=r-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!gU(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let r=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:2!==r&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${pF.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===r||2===r)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===r||1===r)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===r||2===r)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===r||1===r)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}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 r=[],s=e.split(";");for(;s.length>1;){let e=s.shift(),i=s.shift();if(/^\d+$/.exec(e)){let s=parseInt(e);if(gY(s))if("?"===i)r.push({type:0,index:s});else{let e=g$(i);e&&r.push({type:1,index:s,color:e})}}}return r.length&&this._onColor.fire(r),!0}setHyperlink(e){let r=e.indexOf(";");if(-1===r)return!0;let s=e.slice(0,r).trim(),i=e.slice(r+1);return i?this._createHyperlink(s,i):!s.trim()&&this._finishHyperlink()}_createHyperlink(e,r){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,n=s.findIndex(e=>e.startsWith("id="));return -1!==n&&(i=s[n].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:r}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,r){let s=e.split(";");for(let e=0;e<s.length&&!(r>=this._specialColors.length);++e,++r)if("?"===s[e])this._onColor.fire([{type:0,index:this._specialColors[r]}]);else{let i=g$(s[e]);i&&this._onColor.fire([{type:1,index:this._specialColors[r],color:i}])}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 r=[],s=e.split(";");for(let e=0;e<s.length;++e)if(/^\d+$/.exec(s[e])){let i=parseInt(s[e]);gY(i)&&r.push({type:2,index:i})}return r.length&&this._onColor.fire(r),!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,ge),!0}selectCharset(e){return 2!==e.length?this.selectDefaultCharset():"/"===e[0]||this._charsetService.setgCharset(gH[e[0]],m9[e[1]]||ge),!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=m3.clone(),this._eraseAttrDataInternal=m3.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-0x4000000,this._eraseAttrDataInternal.bg|=0x3ffffff&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new uJ;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let r=0;r<this._bufferService.rows;++r){let s=this._activeBuffer.ybase+this._activeBuffer.y+r,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,r){let s=e=>(this._coreService.triggerDataEvent(`${pF.ESC}${e}${pF.ESC}\\`),!0),i=this._bufferService.buffer,n=this._optionsService.rawOptions;return s('"q'===e?`P1$r${+!!this._curAttrData.isProtected()}"q`:'"p'===e?'P1$r61;1"p':"r"===e?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:"m"===e?"P1$r0m":" q"===e?`P1$r${({block:2,underline:4,bar:6})[n.cursorStyle]-!!n.cursorBlink} q`:"P0$r")}markRangeDirty(e,r){this._dirtyRowTracker.markRangeDirty(e,r)}},gV=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,r){e>r&&(gK=e,e=r,r=gK),e<this.start&&(this.start=e),r>this.end&&(this.end=r)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function gY(e){return 0<=e&&e<256}gV=uI([uO(0,u2)],gV);var gG=class extends hj{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 hQ),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,r){let s;if(void 0!==r&&this._syncCalls>r){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,!this._isSyncWriting){for(this._isSyncWriting=!0;s=this._writeBuffer.shift();){this._action(s);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=0x7fffffff,this._isSyncWriting=!1,this._syncCalls=0}}write(e,r){if(this._pendingData>5e7)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(r),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(r)}_innerWrite(e=0,r=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],i=this._action(e,r);if(i){let e=e=>performance.now()-s>=12?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(s,e);i.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-s>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(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()}},gX=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let r=this._bufferService.buffer;if(void 0===e.id){let s=r.addMarker(r.ybase+r.y),i={data:e,id:this._nextId++,lines:[s]};return s.onDispose(()=>this._removeMarkerFromLink(i,s)),this._dataByLinkId.set(i.id,i),i.id}let s=this._getEntryIdKey(e),i=this._entriesWithId.get(s);if(i)return this.addLineToLink(i.id,r.ybase+r.y),i.id;let n=r.addMarker(r.ybase+r.y),a={id:this._nextId++,key:this._getEntryIdKey(e),data:e,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(a,n)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,r){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(e=>e.line!==r)){let e=this._bufferService.buffer.addMarker(r);s.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(s,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,r){let s=e.lines.indexOf(r);-1!==s&&(e.lines.splice(s,1),0===e.lines.length&&(void 0!==e.data.id&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};gX=uI([uO(0,u2)],gX);var gJ=!1,gZ=class extends hj{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new hk),this._onBinary=this._register(new hQ),this.onBinary=this._onBinary.event,this._onData=this._register(new hQ),this.onData=this._onData.event,this._onLineFeed=this._register(new hQ),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new hQ),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new hQ),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new hQ),this._instantiationService=new m0,this.optionsService=this._register(new ga(e)),this._instantiationService.setService(u7,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(gs)),this._instantiationService.setService(u2,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(m2)),this._instantiationService.setService(u8,this._logService),this.coreService=this._register(this._instantiationService.createInstance(gd)),this._instantiationService.setService(u3,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(gm)),this._instantiationService.setService(u5,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(gj)),this._instantiationService.setService(he,this.unicodeService),this._charsetService=this._instantiationService.createInstance(gk),this._instantiationService.setService(u4,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(gX),this._instantiationService.setService(u9,this._oscLinkService),this._inputHandler=this._register(new gq(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(hq.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(hq.forward(this._bufferService.onResize,this._onResize)),this._register(hq.forward(this.coreService.onData,this._onData)),this._register(hq.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 gG((e,r)=>this._inputHandler.parse(e,r))),this._register(hq.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new hQ),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 r in e)this.optionsService.options[r]=e[r]}write(e,r){this._writeBuffer.write(e,r)}writeSync(e,r){this._logService.logLevel<=3&&!gJ&&(this._logService.warn("writeSync is unreliable and will be removed soon."),gJ=!0),this._writeBuffer.writeSync(e,r)}input(e,r=!0){this.coreService.triggerDataEvent(e,r)}resize(e,r){isNaN(e)||isNaN(r)||(e=Math.max(e,2),r=Math.max(r,1),this._bufferService.resize(e,r))}scroll(e,r=!1){this._bufferService.scroll(e,r)}scrollLines(e,r){this._bufferService.scrollLines(e,r)}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 r=e-this._bufferService.buffer.ydisp;0!==r&&this.scrollLines(r)}registerEscHandler(e,r){return this._inputHandler.registerEscHandler(e,r)}registerDcsHandler(e,r){return this._inputHandler.registerDcsHandler(e,r)}registerCsiHandler(e,r){return this._inputHandler.registerCsiHandler(e,r)}registerOscHandler(e,r){return this._inputHandler.registerOscHandler(e,r)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,r=this.optionsService.rawOptions.windowsPty;r&&void 0!==r.buildNumber&&void 0!==r.buildNumber?e="conpty"===r.backend&&r.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(gN.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(gN(this._bufferService),!1))),this._windowsWrappingHeuristics.value=hw(()=>{for(let r of e)r.dispose()})}}},gQ={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:["'",'"']},g0=0,g1=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new mA,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new mA,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(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,r)=>this._getKey(e)-this._getKey(r)),r=0,s=0,i=Array(this._array.length+this._insertedValues.length);for(let n=0;n<i.length;n++)s>=this._array.length||this._getKey(e[r])<=this._getKey(this._array[s])?(i[n]=e[r],r++):i[n]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),0===this._array.length)return!1;let r=this._getKey(e);if(void 0===r||-1===(g0=this._search(r))||this._getKey(this._array[g0])!==r)return!1;do if(this._array[g0]===e)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(g0),!0;while(++g0<this._array.length&&this._getKey(this._array[g0])===r)return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,r)=>e-r),r=0,s=Array(this._array.length-e.length),i=0;for(let n=0;n<this._array.length;n++)e[r]===n?r++:s[i++]=this._array[n];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((g0=this._search(e))<0||g0>=this._array.length)&&this._getKey(this._array[g0])===e)do yield this._array[g0];while(++g0<this._array.length&&this._getKey(this._array[g0])===e)}forEachByKey(e,r){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((g0=this._search(e))<0||g0>=this._array.length)&&this._getKey(this._array[g0])===e)do r(this._array[g0]);while(++g0<this._array.length&&this._getKey(this._array[g0])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let r=0,s=this._array.length-1;for(;s>=r;){let i=r+s>>1,n=this._getKey(this._array[i]);if(n>e)s=i-1;else if(n<e)r=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return r}},g2=0,g5=0,g3=class extends hj{constructor(){super(),this._decorations=new g1(e=>e?.marker.line),this._onDecorationRegistered=this._register(new hQ),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new hQ),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(hw(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let r=new g4(e);if(r){let e=r.marker.onDispose(()=>r.dispose()),s=r.onDispose(()=>{s.dispose(),r&&(this._decorations.delete(r)&&this._onDecorationRemoved.fire(r),e.dispose())});this._decorations.insert(r),this._onDecorationRegistered.fire(r)}return r}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,r,s){let i=0,n=0;for(let a of this._decorations.getKeyIterator(r))n=(i=a.options.x??0)+(a.options.width??1),e>=i&&e<n&&(!s||(a.options.layer??"bottom")===s)&&(yield a)}forEachDecorationAtCell(e,r,s,i){this._decorations.forEachByKey(r,r=>{g5=(g2=r.options.x??0)+(r.options.width??1),e>=g2&&e<g5&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},g4=class extends hC{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new hQ),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new hQ),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 null===this._cachedBg&&(this.options.backgroundColor?this._cachedBg=gv.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this.options.foregroundColor?this._cachedFg=gv.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},g6=class{constructor(e,r=1e3){this._renderCallback=e,this._debounceThresholdMS=r,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,r,s){this._rowCount=s,e=void 0!==e?e:0,r=void 0!==r?r:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,r):r;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=i-this._lastRefreshMs,r=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},r)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return;let e=Math.max(this._rowStart,0),r=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,r)}},g8=class extends hj{constructor(e,r,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let n=this._coreBrowserService.mainDocument;this._accessibilityContainer=n.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=n.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=n.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new g6(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(`
|
|
26
|
+
`))),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(f5(n,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(hw(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let r=0;r<e;r++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
27
|
+
`&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=u$)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,r){this._liveRegionDebouncer.refresh(e,r,this._terminal.rows)}_renderRows(e,r){let s=this._terminal.buffer,i=s.lines.length.toString();for(let n=e;n<=r;n++){let e=s.lines.get(s.ydisp+n),r=[],a=e?.translateToString(!0,void 0,void 0,r)||"",o=(s.ydisp+n+1).toString(),l=this._rowElements[n];l&&(0===a.length?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,r)),l.setAttribute("aria-posinset",o),l.setAttribute("aria-setsize",i),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,r){let s,i,n=e.target,a=this._rowElements[0===r?1:this._rowElements.length-2];if(n.getAttribute("aria-posinset")!==(0===r?"1":`${this._terminal.buffer.lines.length}`)&&e.relatedTarget===a){if(0===r?(s=n,i=this._rowElements.pop(),this._rowContainer.removeChild(i)):(s=this._rowElements.shift(),i=n,this._rowContainer.removeChild(s)),s.removeEventListener("focus",this._topBoundaryFocusListener),i.removeEventListener("focus",this._bottomBoundaryFocusListener),0===r){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(0===r?-1:1),this._rowElements[0===r?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)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)return void console.error("anchorNode and/or focusNode are null");let r={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((r.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||r.node===s.node&&r.offset>s.offset)&&([r,s]=[s,r]),r.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(r={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(r.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:i.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let n=({node:e,offset:r})=>{let s=e instanceof Text?e.parentNode:e,i=parseInt(s?.getAttribute("aria-posinset"),10)-1;if(isNaN(i))return console.warn("row is invalid. Race condition?"),null;let n=this._rowColumns.get(s);if(!n)return console.warn("columns is null. Race condition?"),null;let a=r<n.length?n[r]:n.slice(-1)[0]+1;return a>=this._terminal.cols&&(++i,a=0),{row:i,column:a}},a=n(r),o=n(s);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 r=e.getBoundingClientRect().width,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/r})`}};g8=uI([uO(1,u6),uO(2,hi),uO(3,ha)],g8);var g7=class extends hj{constructor(e,r,s,i,n){super(),this._element=e,this._mouseService=r,this._renderService=s,this._bufferService=i,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new hQ),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new hQ),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(hw(()=>{hb(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(f5(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(f5(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(f5(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(f5(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let r=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!r)return;this._isMouseOut=!1;let s=e.composedPath();for(let e=0;e<s.length;e++){let r=s[e];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}this._lastBufferCell&&r.x===this._lastBufferCell.x&&r.y===this._lastBufferCell.y||(this._handleHover(r),this._lastBufferCell=r)}_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,r){this._activeProviderReplies&&r||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[i,n]of this._linkProviderService.linkProviders.entries())r?this._activeProviderReplies?.get(i)&&(s=this._checkLinkProviderResult(i,e,s)):n.provideLinks(e.y,r=>{if(this._isMouseOut)return;let n=r?.map(e=>({link:e}));this._activeProviderReplies?.set(i,n),s=this._checkLinkProviderResult(i,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,r){let s=new Set;for(let i=0;i<r.size;i++){let n=r.get(i);if(n)for(let r=0;r<n.length;r++){let i=n[r],a=i.link.range.start.y<e?0:i.link.range.start.x,o=i.link.range.end.y>e?this._bufferService.cols:i.link.range.end.x;for(let e=a;e<=o;e++){if(s.has(e)){n.splice(r--,1);break}s.add(e)}}}}_checkLinkProviderResult(e,r,s){if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),n=!1;for(let r=0;r<e;r++)(!this._activeProviderReplies.has(r)||this._activeProviderReplies.get(r))&&(n=!0);if(!n&&i){let e=i.find(e=>this._linkAtPosition(e.link,r));e&&(s=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let e=0;e<this._activeProviderReplies.size;e++){let i=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,r));if(i){s=!0,this._handleNewLink(i);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){var r,s;if(!this._currentLink)return;let i=this._positionFromMouseEvent(e,this._element,this._mouseService);i&&this._mouseDownLink&&(r=this._mouseDownLink.link,s=this._currentLink.link,r.text===s.text&&r.range.start.x===s.range.start.x&&r.range.start.y===s.range.start.y&&r.range.end.x===s.range.end.x&&r.range.end.y===s.range.end.y)&&this._linkAtPosition(this._currentLink.link,i)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,r){this._currentLink&&this._lastMouseEvent&&(!e||!r||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=r)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,hb(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let r=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);r&&this._linkAtPosition(e.link,r)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:void 0===e.link.decorations||e.link.decorations.underline,pointerCursor:void 0===e.link.decorations||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:r=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let r=0===e.start?0:e.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(r,s),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,r,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(r,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),r.hover&&r.hover(s,r.text)}_fireUnderlineEvent(e,r){let s=e.range,i=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(r?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,r,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(r,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),r.leave&&r.leave(s,r.text)}_linkAtPosition(e,r){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,n=r.y*this._bufferService.cols+r.x;return s<=n&&n<=i}_positionFromMouseEvent(e,r,s){let i=s.getCoords(e,r,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,r,s,i,n){return{x1:e,y1:r,x2:s,y2:i,cols:this._bufferService.cols,fg:n}}};g7=uI([uO(1,hn),uO(2,ha),uO(3,u2),uO(4,hd)],g7);var g9=class extends gZ{constructor(e={}){super(e),this._linkifier=this._register(new hk),this.browser=mh,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new hk),this._onCursorMove=this._register(new hQ),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new hQ),this.onKey=this._onKey.event,this._onRender=this._register(new hQ),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new hQ),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new hQ),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new hQ),this.onBell=this._onBell.event,this._onFocus=this._register(new hQ),this._onBlur=this._register(new hQ),this._onA11yCharEmitter=this._register(new hQ),this._onA11yTabEmitter=this._register(new hQ),this._onWillOpen=this._register(new hQ),this._setup(),this._decorationService=this._instantiationService.createInstance(g3),this._instantiationService.setService(ht,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ml),this._instantiationService.setService(hd,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(hr)),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(hq.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(hq.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(hq.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(hq.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(hw(()=>{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 r of e){let e,s="";switch(r.index){case 256:e="foreground",s="10";break;case 257:e="background",s="11";break;case 258:e="cursor",s="12";break;default:e="ansi",s="4;"+r.index}switch(r.type){case 0:let i=gx.toColorRGB("ansi"===e?this._themeService.colors.ansi[r.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${pF.ESC}]${s};${function(e,r=16){let[s,i,n]=e;return`rgb:${gW(s,r)}/${gW(i,r)}/${gW(n,r)}`}(i)}${pP.ST}`);break;case 1:if("ansi"===e)this._themeService.modifyColors(e=>e.ansi[r.index]=pB.toColor(...r.color));else{let s=e;this._themeService.modifyColors(e=>e[s]=pB.toColor(...r.color))}break;case 2:this._themeService.restoreColor(r.index)}}}_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(g8,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(pF.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(pF.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,r=this.buffer.lines.get(e);if(!r)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,n=r.getWidth(s),a=this._renderService.dimensions.css.cell.width*n,o=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=o+"px",this.textarea.style.width=a+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(f5(this.element,"copy",e=>{var r;this.hasSelection()&&(r=this._selectionService,e.clipboardData&&e.clipboardData.setData("text/plain",r.selectionText),e.preventDefault())}));let e=e=>{var r,s,i;return r=this.textarea,s=this.coreService,i=this.optionsService,void(e.stopPropagation(),e.clipboardData&&uW(e.clipboardData.getData("text/plain"),r,s,i))};this._register(f5(this.textarea,"paste",e)),this._register(f5(this.element,"paste",e)),mv?this._register(f5(this.element,"mousedown",e=>{2===e.button&&uU(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(f5(this.element,"contextmenu",e=>{uU(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),mk&&this._register(f5(this.element,"auxclick",e=>{1===e.button&&uH(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(f5(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(f5(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(f5(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(f5(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(f5(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(f5(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(f5(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 r=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),r.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(f5(this.screenElement,"mousemove",e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),r.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",uz),mN||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",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(ma,this.textarea,e.ownerDocument.defaultView??window,this._document??"u">typeof window?window.document:null)),this._instantiationService.setService(hi,this._coreBrowserService),this._register(f5(this.textarea,"focus",e=>this._handleTextAreaFocus(e))),this._register(f5(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(mr,this._document,this._helperContainer),this._instantiationService.setService(hs,this._charSizeService),this._themeService=this._instantiationService.createInstance(mJ),this._instantiationService.setService(hc,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(pZ),this._instantiationService.setService(hl,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(mF,this.rows,this.screenElement)),this._instantiationService.setService(ha,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(pN,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(md),this._instantiationService.setService(hn,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(g7,this.screenElement));this.element.appendChild(r);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(py,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(mH,this.element,this.screenElement,i)),this._instantiationService.setService(ho,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(hq.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(pb,this.screenElement)),this._register(f5(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(g8,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pk,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pk,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(mt,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,r=this.element;function s(r){let s,i,n=e._mouseService.getMouseReportCoords(r,e.screenElement);if(!n)return!1;switch(r.overrideType||r.type){case"mousemove":i=32,void 0===r.buttons?(s=3,void 0!==r.button&&(s=r.button<3?r.button:3)):s=1&r.buttons?0:4&r.buttons?1:2&r.buttons?2:3;break;case"mouseup":i=0,s=r.button<3?r.button:3;break;case"mousedown":i=1,s=r.button<3?r.button:3;break;case"wheel":if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(r))return!1;let a=r.deltaY;if(0===a||0===e.coreMouseService.consumeWheelEvent(r,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return!1;i=a<0?0:1,s=4;break;default:return!1}return void 0!==i&&void 0!==s&&!(s>4)&&e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:s,action:i,ctrl:r.ctrlKey,alt:r.altKey,shift:r.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n=e=>(s(e),e.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(e)),a=e=>(s(e),this.cancel(e,!0)),o=e=>{e.buttons&&s(e)},l=e=>{e.buttons||s(e)};this._register(this.coreMouseService.onProtocolChange(e=>{e?("debug"===this.optionsService.rawOptions.logLevel&&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()),8&e?i.mousemove||(r.addEventListener("mousemove",l),i.mousemove=l):(r.removeEventListener("mousemove",i.mousemove),i.mousemove=null),16&e?i.wheel||(r.addEventListener("wheel",a,{passive:!1}),i.wheel=a):(r.removeEventListener("wheel",i.wheel),i.wheel=null),2&e?i.mouseup||(i.mouseup=n):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),4&e?i.mousedrag||(i.mousedrag=o):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(f5(r,"mousedown",e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return s(e),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(e)})),this._register(f5(r,"wheel",r=>{if(!i.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(r))return!1;if(!this.buffer.hasScrollback){if(0===r.deltaY)return!1;if(0===e.coreMouseService.consumeWheelEvent(r,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return this.cancel(r,!0);let s=pF.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(r.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(s,!0),this.cancel(r,!0)}}},{passive:!1}))}refresh(e,r){this._renderService?.refreshRows(e,r)}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,r){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,r),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 r=e-this._bufferService.buffer.ydisp;0!==r&&this.scrollLines(r)}paste(e){uW(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 r=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),r}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}select(e,r,s){this._selectionService.setSelection(e,r,s)}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,r){this._selectionService?.selectLines(e,r)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;let r=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!r&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;r||"Dead"!==e.key&&"AltGraph"!==e.key||(this._unprocessedDeadKey=!0);let s=function(e,r,s,i){let n={type:0,cancel:!1,key:void 0},a=!!e.shiftKey|2*!!e.altKey|4*!!e.ctrlKey|8*!!e.metaKey;switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?r?n.key=pF.ESC+"OA":n.key=pF.ESC+"[A":"UIKeyInputLeftArrow"===e.key?r?n.key=pF.ESC+"OD":n.key=pF.ESC+"[D":"UIKeyInputRightArrow"===e.key?r?n.key=pF.ESC+"OC":n.key=pF.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(r?n.key=pF.ESC+"OB":n.key=pF.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":pF.DEL,e.altKey&&(n.key=pF.ESC+n.key);break;case 9:if(e.shiftKey){n.key=pF.ESC+"[Z";break}n.key=pF.HT,n.cancel=!0;break;case 13:n.key=e.altKey?pF.ESC+pF.CR:pF.CR,n.cancel=!0;break;case 27:n.key=pF.ESC,e.altKey&&(n.key=pF.ESC+pF.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;a?n.key=pF.ESC+"[1;"+(a+1)+"D":r?n.key=pF.ESC+"OD":n.key=pF.ESC+"[D";break;case 39:if(e.metaKey)break;a?n.key=pF.ESC+"[1;"+(a+1)+"C":r?n.key=pF.ESC+"OC":n.key=pF.ESC+"[C";break;case 38:if(e.metaKey)break;a?n.key=pF.ESC+"[1;"+(a+1)+"A":r?n.key=pF.ESC+"OA":n.key=pF.ESC+"[A";break;case 40:if(e.metaKey)break;a?n.key=pF.ESC+"[1;"+(a+1)+"B":r?n.key=pF.ESC+"OB":n.key=pF.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(n.key=pF.ESC+"[2~");break;case 46:a?n.key=pF.ESC+"[3;"+(a+1)+"~":n.key=pF.ESC+"[3~";break;case 36:a?n.key=pF.ESC+"[1;"+(a+1)+"H":r?n.key=pF.ESC+"OH":n.key=pF.ESC+"[H";break;case 35:a?n.key=pF.ESC+"[1;"+(a+1)+"F":r?n.key=pF.ESC+"OF":n.key=pF.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=pF.ESC+"[5;"+(a+1)+"~":n.key=pF.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=pF.ESC+"[6;"+(a+1)+"~":n.key=pF.ESC+"[6~";break;case 112:a?n.key=pF.ESC+"[1;"+(a+1)+"P":n.key=pF.ESC+"OP";break;case 113:a?n.key=pF.ESC+"[1;"+(a+1)+"Q":n.key=pF.ESC+"OQ";break;case 114:a?n.key=pF.ESC+"[1;"+(a+1)+"R":n.key=pF.ESC+"OR";break;case 115:a?n.key=pF.ESC+"[1;"+(a+1)+"S":n.key=pF.ESC+"OS";break;case 116:a?n.key=pF.ESC+"[15;"+(a+1)+"~":n.key=pF.ESC+"[15~";break;case 117:a?n.key=pF.ESC+"[17;"+(a+1)+"~":n.key=pF.ESC+"[17~";break;case 118:a?n.key=pF.ESC+"[18;"+(a+1)+"~":n.key=pF.ESC+"[18~";break;case 119:a?n.key=pF.ESC+"[19;"+(a+1)+"~":n.key=pF.ESC+"[19~";break;case 120:a?n.key=pF.ESC+"[20;"+(a+1)+"~":n.key=pF.ESC+"[20~";break;case 121:a?n.key=pF.ESC+"[21;"+(a+1)+"~":n.key=pF.ESC+"[21~";break;case 122:a?n.key=pF.ESC+"[23;"+(a+1)+"~":n.key=pF.ESC+"[23~";break;case 123:a?n.key=pF.ESC+"[24;"+(a+1)+"~":n.key=pF.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if((!s||i)&&e.altKey&&!e.metaKey){let r=gQ[e.keyCode]?.[+!!e.shiftKey];if(r)n.key=pF.ESC+r;else if(e.keyCode>=65&&e.keyCode<=90){let r=String.fromCharCode(e.ctrlKey?e.keyCode-64:e.keyCode+32);e.shiftKey&&(r=r.toUpperCase()),n.key=pF.ESC+r}else if(32===e.keyCode)n.key=pF.ESC+(e.ctrlKey?pF.NUL:" ");else if("Dead"===e.key&&e.code.startsWith("Key")){let r=e.code.slice(3,4);e.shiftKey||(r=r.toLowerCase()),n.key=pF.ESC+r,n.cancel=!0}}else!s||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?!e.key||e.ctrlKey||e.altKey||e.metaKey||!(e.keyCode>=48)||1!==e.key.length?e.key&&e.ctrlKey&&("_"===e.key&&(n.key=pF.US),"@"===e.key&&(n.key=pF.NUL)):n.key=e.key:65===e.keyCode&&(n.type=1);else e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?n.key=pF.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?n.key=pF.DEL:219===e.keyCode?n.key=pF.ESC:220===e.keyCode?n.key=pF.FS:221===e.keyCode&&(n.key=pF.GS)}return n}(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===s.type||2===s.type){let r=this.rows-1;return this.scrollLines(2===s.type?-r:r),this.cancel(e,!0)}return 1===s.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&1===e.key.length&&e.key.charCodeAt(0)>=65&&90>=e.key.charCodeAt(0))||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((s.key===pF.ETX||s.key===pF.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)?this.cancel(e,!0):void(this._keyDownHandled=!0))}_isThirdLevelShift(e,r){let s=e.isMac&&!this.options.macOptionIsMeta&&r.altKey&&!r.ctrlKey&&!r.metaKey||e.isWindows&&r.altKey&&r.ctrlKey&&!r.metaKey||e.isWindows&&r.getModifierState("AltGraph");return"keypress"===r.type?s:s&&(!r.keyCode||r.keyCode>47)}_keyUp(e){var r;this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(16===(r=e).keyCode||17===r.keyCode||18===r.keyCode||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let r;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)r=e.charCode;else if(null===e.which||void 0===e.which)r=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;r=e.which}return!!r&&(!e.altKey&&!e.ctrlKey&&!e.metaKey||!!this._isThirdLevelShift(this.browser,e))&&(r=String.fromCharCode(r),this._onKey.fire({key:r,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&"insertText"===e.inputType&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let r=e.data;return this.coreService.triggerDataEvent(r,!0),this.cancel(e),!0}return!1}resize(e,r){if(e===this.cols&&r===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,r)}_afterResize(e,r){this._charSizeService?.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){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(m3));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(pF.ESC+"[I"):this.coreService.triggerDataEvent(pF.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let r=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${pF.ESC}[4;${s};${r}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${pF.ESC}[6;${n};${i}t`)}}cancel(e,r){if(!(!this.options.cancelEvents&&!r))return e.preventDefault(),e.stopPropagation(),!1}},xe=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,r){let s={instance:r,dispose:r.dispose,isDisposed:!1};this._addons.push(s),r.dispose=()=>this._wrappedAddonDispose(s),r.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let r=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){r=s;break}if(-1===r)throw Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(r,1)}},xt=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,r){if(!(e<0||e>=this._line.length))return r?(this._line.loadCell(e,r),r):this._line.loadCell(e,new uJ)}translateToString(e,r,s){return this._line.translateToString(e,r,s)}},xr=class{constructor(e,r){this._buffer=e,this.type=r}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 r=this._buffer.lines.get(e);if(r)return new xt(r)}getNullCell(){return new uJ}},xs=class extends hj{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new hQ),this.onBufferChange=this._onBufferChange.event,this._normal=new xr(this._core.buffers.normal,"normal"),this._alternate=new xr(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)}},xi=class{constructor(e){this._core=e}registerCsiHandler(e,r){return this._core.registerCsiHandler(e,e=>r(e.toArray()))}addCsiHandler(e,r){return this.registerCsiHandler(e,r)}registerDcsHandler(e,r){return this._core.registerDcsHandler(e,(e,s)=>r(e,s.toArray()))}addDcsHandler(e,r){return this.registerDcsHandler(e,r)}registerEscHandler(e,r){return this._core.registerEscHandler(e,r)}addEscHandler(e,r){return this.registerEscHandler(e,r)}registerOscHandler(e,r){return this._core.registerOscHandler(e,r)}addOscHandler(e,r){return this.registerOscHandler(e,r)}},xn=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}},xa=["cols","rows"],xo=0,xl=class extends hj{constructor(e){super(),this._core=this._register(new g9(e)),this._addonManager=this._register(new xe),this._publicOptions={...this._core.options};let r=e=>this._core.options[e],s=(e,r)=>{this._checkReadonlyOptions(e),this._core.options[e]=r};for(let e in this._core.options){let i={get:r.bind(this,e),set:s.bind(this,e)};Object.defineProperty(this._publicOptions,e,i)}}_checkReadonlyOptions(e){if(xa.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||(this._parser=new xi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new xn(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._buffer=this._register(new xs(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,r="none";switch(this._core.coreMouseService.activeProtocol){case"X10":r="x10";break;case"VT200":r="vt200";break;case"DRAG":r="drag";break;case"ANY":r="any"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:r,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 r in e)this._publicOptions[r]=e[r]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,r=!0){this._core.input(e,r)}resize(e,r){this._verifyIntegers(e,r),this._core.resize(e,r)}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,r,s){this._verifyIntegers(e,r,s),this._core.select(e,r,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,r){this._verifyIntegers(e,r),this._core.selectLines(e,r)}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,r){this._core.write(e,r)}writeln(e,r){this._core.write(e),this._core.write(`\r
|
|
28
|
+
`,r)}paste(e){this._core.paste(e)}refresh(e,r){this._verifyIntegers(e,r),this._core.refresh(e,r)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return uz},set promptLabel(t){uz=t},get tooMuchOutput(){return u$},set tooMuchOutput(t){u$=t}}}_verifyIntegers(...e){for(xo of e)if(xo===1/0||isNaN(xo)||xo%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(xo of e)if(xo&&(xo===1/0||isNaN(xo)||xo%1!=0||xo<0))throw Error("This API only accepts positive integers")}},xc=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let r=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(r._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(0===e.css.cell.width||0===e.css.cell.height)return;let r=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),n=Math.max(0,parseInt(s.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"))},l=o.top+o.bottom;return{cols:Math.max(2,Math.floor((n-(o.right+o.left)-r)/e.css.cell.width)),rows:Math.max(1,Math.floor((i-l)/e.css.cell.height))}}},xd=class{constructor(e,r,s,i={}){this._terminal=e,this._regex=r,this._handler=s,this._options=i}provideLinks(e,r){let s=xu.computeLink(e,this._regex,this._terminal,this._handler);r(this._addCallbacks(s))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(r,s)=>{if(this._options.hover){let{range:i}=e;this._options.hover(r,s,i)}},e))}},xu=class e{static computeLink(r,s,i,n){let a=RegExp(s.source,(s.flags||"")+"g"),[o,l]=e._getWindowedLineStrings(r-1,i),c=o.join(""),d,u=[];for(;d=a.exec(c);){let r=d[0];if(!function(e){try{let r=new URL(e),s=r.password&&r.username?`${r.protocol}//${r.username}:${r.password}@${r.host}`:r.username?`${r.protocol}//${r.username}@${r.host}`:`${r.protocol}//${r.host}`;return e.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}(r))continue;let[s,a]=e._mapStrIdx(i,l,0,d.index),[o,c]=e._mapStrIdx(i,s,a,r.length);if(-1===s||-1===a||-1===o||-1===c)continue;let h={start:{x:a+1,y:s+1},end:{x:c,y:o+1}};u.push({range:h,text:r,activate:n})}return u}static _getWindowedLineStrings(e,r){let s,i=e,n=e,a=0,o="",l=[];if(s=r.buffer.active.getLine(e)){let e=s.translateToString(!0);if(s.isWrapped&&" "!==e[0]){for(a=0;(s=r.buffer.active.getLine(--i))&&a<2048&&(a+=(o=s.translateToString(!0)).length,l.push(o),!(!s.isWrapped||-1!==o.indexOf(" "))););l.reverse()}for(l.push(e),a=0;(s=r.buffer.active.getLine(++n))&&s.isWrapped&&a<2048&&(a+=(o=s.translateToString(!0)).length,l.push(o),-1===o.indexOf(" ")););}return[l,i]}static _mapStrIdx(e,r,s,i){let n=e.buffer.active,a=n.getNullCell(),o=s;for(;i;){let e=n.getLine(r);if(!e)return[-1,-1];for(let s=o;s<e.length;++s){e.getCell(s,a);let o=a.getChars();if(a.getWidth()&&(i-=o.length||1,s===e.length-1&&""===o)){let e=n.getLine(r+1);e&&e.isWrapped&&(e.getCell(0,a),2===a.getWidth()&&(i+=1))}if(i<0)return[r,s]}r++,o=0}return[r,o]}},xh=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function xf(e,r){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=r}else console.warn("Opening link blocked as opener could not be cleared")}var xp=class{constructor(e=xf,r={}){this._handler=e,this._options=r}activate(e){this._terminal=e;let r=this._options,s=r.urlRegex||xh;this._linkProvider=this._terminal.registerLinkProvider(new xd(this._terminal,s,this._handler,r))}dispose(){this._linkProvider?.dispose()}};let xm=(0,ew.default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);var xg=e.i(754219);let xx=/\x1B(?:\][^\x07]*(?:\x07|\x1B\\)|[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g;function xv({logs:e,isPty:r,className:s,onInput:i,onResize:n,muteInput:a,processId:o,executorId:l,target:c,status:d,exitCode:u}){let h=(0,$.useRef)(null),f=(0,$.useRef)(null),p=(0,$.useRef)(null),m=(0,$.useRef)(0),g=(0,$.useRef)(0),x=(0,$.useRef)(a);x.current!==a&&console.log(`[ExecutorOutput] muteInput changed: ${x.current} → ${a}`),x.current=a;let{settings:v}=(0,d4.useTerminalSettings)(),_=(0,$.useRef)(v),[y,b]=(0,$.useState)(!1),w=(0,$.useRef)(0),S=(0,$.useRef)(e);S.current=e;let C=async()=>{if(!y){w.current=S.current.length,b(!0);return}let e=S.current,r=Math.min(w.current,e.length),s=e.slice(r).map(e=>"stdout"===e.type||"stderr"===e.type||"pty"===e.type?e.data:"").join("");b(!1);let i=s.replace(xx,"");if(!i)return void xg.toast.info("Capture stopped — no output to copy");try{await navigator.clipboard.writeText(i),xg.toast.success("Copied captured output to clipboard")}catch{xg.toast.error("Failed to copy to clipboard")}};(0,$.useEffect)(()=>{if(!h.current||f.current)return;let e=_.current,s=new xl({cursorBlink:r,cursorStyle:r?"block":"underline",disableStdin:!r,convertEol:!0,fontSize:e.fontSize,fontFamily:e.fontFamily,scrollback:e.scrollback,theme:{background:"#09090b",foreground:"#fafafa",cursor:r?"#fafafa":"#09090b",cursorAccent:"#09090b",selectionBackground:"#3f3f46",black:"#09090b",red:"#f87171",green:"#4ade80",yellow:"#facc15",blue:"#60a5fa",magenta:"#c084fc",cyan:"#22d3ee",white:"#fafafa",brightBlack:"#71717a",brightRed:"#fca5a5",brightGreen:"#86efac",brightYellow:"#fde047",brightBlue:"#93c5fd",brightMagenta:"#d8b4fe",brightCyan:"#67e8f9",brightWhite:"#ffffff"},allowProposedApi:!0}),a=new xc,o=new xp;return s.loadAddon(a),s.loadAddon(o),s.open(h.current),setTimeout(()=>{try{let e=h.current;if(!e||0===e.clientWidth||0===e.clientHeight)return;a.fit(),r&&n?.(s.cols,s.rows)}catch{}},0),f.current=s,p.current=a,r&&i&&s.onData(e=>{x.current||0!==g.current||i(e)}),r&&n&&s.onResize(({cols:e,rows:r})=>{n(e,r)}),()=>{s.dispose(),f.current=null,p.current=null,m.current=0,g.current=0}},[r,i,n]),(0,$.useEffect)(()=>{if(!f.current)return;e.length<m.current&&(f.current.reset(),m.current=0);let r="",s="";for(let i=m.current;i<e.length;i++){let n=e[i];("pty"===n.type||"stdout"===n.type||"stderr"===n.type)&&(n.historical?r+=n.data:s+=n.data)}if(m.current=e.length,r){g.current++;try{f.current.write(r,()=>{g.current=Math.max(0,g.current-1)})}catch(e){g.current=Math.max(0,g.current-1),console.error("[ExecutorOutput] terminal write failed",e)}}if(s)try{f.current.write(s)}catch(e){console.error("[ExecutorOutput] terminal write failed",e)}},[e]),(0,$.useEffect)(()=>{let e=f.current;if(e){e.options.fontSize=v.fontSize,e.options.fontFamily=v.fontFamily,e.options.scrollback=v.scrollback;try{p.current?.fit()}catch{}}},[v.fontSize,v.fontFamily,v.scrollback]),(0,$.useEffect)(()=>{if(!h.current||!p.current)return;let e=new ResizeObserver(()=>{try{let e=h.current;if(!e||0===e.clientWidth||0===e.clientHeight)return;p.current?.fit()}catch{}});return e.observe(h.current),()=>{e.disconnect()}},[]);let j="closed"===d&&null!==u?`closed \xb7 exit ${u}`:d??null;return(0,z.jsxs)("div",{className:(0,ey.cn)("relative h-[300px] rounded-md border bg-zinc-950 overflow-hidden",s),children:[(0,z.jsx)("div",{ref:h,className:"h-full w-full"}),(0,z.jsxs)("div",{className:"absolute top-2 right-3 z-10 flex items-center gap-1.5",children:[(0,z.jsxs)(ap,{children:[(0,z.jsx)(am,{asChild:!0,children:(0,z.jsx)("button",{type:"button",title:"Process info","aria-label":"Show process info",className:(0,ey.cn)("flex h-6 w-6 items-center justify-center rounded","bg-zinc-900/70 backdrop-blur-sm border border-zinc-700/60","text-zinc-400 hover:text-zinc-100 hover:border-zinc-500 transition-colors"),children:(0,z.jsx)(xm,{className:"h-3 w-3"})})}),(0,z.jsxs)(ag,{align:"end",className:"w-72",children:[(0,z.jsx)(ab,{className:"text-xs text-muted-foreground",children:"Process info"}),[{label:"Process",value:o??null},{label:"Executor",value:l??null},{label:"Target",value:c??null},{label:"Status",value:j}].map(e=>(0,z.jsxs)(ax,{disabled:!e.value,onSelect:r=>{var s,i;r.preventDefault(),s=e.label,(i=e.value)&&(navigator.clipboard.writeText(i),xg.toast.success(`${s} copied`))},className:"flex items-center justify-between gap-3 font-mono text-xs",children:[(0,z.jsx)("span",{className:"shrink-0 text-muted-foreground",children:e.label}),(0,z.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,z.jsx)("span",{className:"truncate",children:e.value??"—"}),e.value&&(0,z.jsx)(ul.Copy,{className:"h-3 w-3 shrink-0 opacity-60"})]})]},e.label))]})]}),(0,z.jsx)("button",{type:"button",onClick:C,title:y?"Stop capture & copy to clipboard":"Start capturing output","aria-label":y?"Stop capture and copy":"Start capturing output",className:(0,ey.cn)("flex h-6 w-6 items-center justify-center rounded","bg-zinc-900/70 backdrop-blur-sm border border-zinc-700/60","text-zinc-400 hover:text-zinc-100 hover:border-zinc-500 transition-colors",y&&"text-red-400 border-red-500/70 hover:text-red-300"),children:y?(0,z.jsx)(uA,{className:"h-3 w-3 fill-current"}):(0,z.jsx)(rS,{className:"h-3 w-3"})})]})]})}let x_=(0,ew.default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]),xy=[{name:"Dev Server",command:"pnpm dev",executor_type:"command",pty:!0,description:"Start the development server with hot reload"},{name:"Build",command:"pnpm build",executor_type:"command",pty:!0,description:"Build the project for production"},{name:"Lint",command:"pnpm lint",executor_type:"command",pty:!0,description:"Run the linter to check code quality"},{name:"Type Check",command:"npx tsc --noEmit",executor_type:"command",pty:!0,description:"Run TypeScript type checking without emitting files"},{name:"Test",command:"pnpm test",executor_type:"command",pty:!0,description:"Run the test suite"},{name:"Rebase on and merge into main",command:"Our goal is to sync the current local branch with the local branch/worktree `main`. The two branches may have diverged.\n\nPlease do the following in order. Only proceed to the next step if the previous step succeeds:\n\n1. Rebase the current local branch onto the local branch `main`, and resolve any conflicts if needed.\n2. If, after the rebase, `main` does not yet contain the current branch's commits, switch to the `main` branch/worktree and merge the current branch into `main` using `git merge`. Do not use `git branch -f`.\n3. If the current branch is already fully contained in `main`, and `main` has newer commits, update the current branch so it includes the latest commits from `main`.\n4. Push both the current local branch and the local branch `main` to the remote.",executor_type:"prompt",pty:!1,description:"Rebase current branch onto main, merge into main, and push both branches"},{name:"Reset to main",command:"git reset --hard main",executor_type:"command",pty:!0,description:"Hard reset the current branch to match main"},{name:"Push to remote",command:"git push --force-with-lease",executor_type:"command",pty:!0,description:"Force push to remote with lease safety check"},{name:"Git commit",command:"Inspect the modified and untracked and deleted files in the current repository, generate an appropriate commit message, and commit all relevant files.\n\nCommit message rules:\n- Use Conventional Commits format (feat:, fix:, chore:, refactor:, docs:, test:, ci:, build:, perf:, style:, etc.)\n- Choose the type that best matches the main purpose of the changes\n- Make the message specific to the actual changes\n- Keep it within 50 characters if possible\n- Use lowercase\n- Do not end with a period\n- Do not wrap the message in quotes, backticks, or markdown\n\nCommit requirements:\n- Include all relevant modified and untracked files\n- Do not include unrelated files\n- If there are no meaningful changes to commit, do not create a commit\n\nWhen finished, output only the final commit message.",executor_type:"prompt",pty:!1,description:"Inspect changes, generate a conventional commit message, and commit"},{name:"Tag and push",command:"Find the latest SemVer tag in the repository, increase the patch number by 1, create the new tag from the current commit, and push it to origin.",executor_type:"prompt",pty:!1,description:"Bump the patch version tag and push it to origin"}];function xb({open:e,onOpenChange:r,executor:s,onSubmit:i}){let[n,a]=(0,$.useState)(s?.name??""),[o,l]=(0,$.useState)(s?.executor_type??"command"),[c,d]=(0,$.useState)(s?.prompt_provider??"claude"),[u,h]=(0,$.useState)(s?.command??""),[f,p]=(0,$.useState)(s?.cwd??""),[m,g]=(0,$.useState)(s?.pty??!0),[x,v]=(0,$.useState)(!1),[_,y]=(0,$.useState)(!1),[b,w]=(0,$.useState)(null),[S,C]=(0,$.useState)(null),[j,k]=(0,$.useState)(""),N=!!s;(0,$.useEffect)(()=>{e&&(y(!1),w(null),C(null),k(""),s&&(a(s.name),l(s.executor_type??"command"),d(s.prompt_provider??"claude"),h(s.command),p(s.cwd??""),g(s.pty)))},[e]);let E=async e=>{if(e.preventDefault(),n.trim()&&u.trim()){v(!0);try{await i({name:n.trim(),command:u.trim(),executor_type:o,prompt_provider:"prompt"===o?c:null,cwd:f.trim()||void 0,pty:"prompt"===o||m}),r(!1),N||(a(""),l("command"),d("claude"),h(""),p(""),g(!0))}finally{v(!1)}}};return(0,z.jsx)(t7,{open:e,onOpenChange:r,children:(0,z.jsxs)(rr,{children:[(0,z.jsx)(rs,{children:(0,z.jsxs)("div",{className:"flex items-center justify-between pr-6",children:[(0,z.jsx)(rn,{children:_?"Select Preset":N?"Edit Executor":"Add Executor"}),!N&&!_&&(0,z.jsx)("button",{type:"button",className:"text-sm text-muted-foreground hover:text-foreground transition-colors",onClick:()=>y(!0),children:"Select from presets"})]})}),(0,z.jsxs)("div",{className:"h-[420px] flex flex-col",children:[!_&&(0,z.jsxs)("form",{onSubmit:E,className:"space-y-4 flex-1 flex flex-col",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,z.jsx)(ro,{placeholder:"e.g., Dev Server",value:n,onChange:e=>a(e.target.value),required:!0})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Type"}),(0,z.jsxs)("div",{className:"flex rounded-md border border-input overflow-hidden",children:[(0,z.jsx)("button",{type:"button",className:(0,ey.cn)("flex-1 px-3 py-1.5 text-sm font-medium transition-colors","command"===o?"bg-primary text-primary-foreground":"bg-background text-muted-foreground hover:bg-muted"),onClick:()=>l("command"),children:"Command"}),(0,z.jsx)("button",{type:"button",className:(0,ey.cn)("flex-1 px-3 py-1.5 text-sm font-medium transition-colors border-l border-input","prompt"===o?"bg-primary text-primary-foreground":"bg-background text-muted-foreground hover:bg-muted"),onClick:()=>l("prompt"),children:"Prompt"})]})]}),"prompt"===o&&(0,z.jsxs)("div",{className:"flex gap-3",children:[(0,z.jsxs)("div",{className:"w-[140px] shrink-0 space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Provider"}),(0,z.jsxs)(cX,{value:c,onValueChange:e=>d(e),children:[(0,z.jsx)(cZ,{className:"w-full",children:(0,z.jsx)(cJ,{})}),(0,z.jsxs)(cQ,{children:[(0,z.jsx)(c0,{value:"claude",children:"Claude"}),(0,z.jsx)(c0,{value:"codex",children:"Codex"})]})]})]}),(0,z.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,z.jsxs)("label",{className:"text-sm font-medium",children:["Working Directory"," ",(0,z.jsx)("span",{className:"text-muted-foreground",children:"(optional)"})]}),(0,z.jsx)(ro,{placeholder:"Relative to worktree root",value:f,onChange:e=>p(e.target.value)})]})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"prompt"===o?"Prompt":"Command"}),"prompt"===o?(0,z.jsx)("textarea",{className:"flex min-h-[90px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-y",placeholder:"e.g., Review the code and suggest improvements",value:u,onChange:e=>h(e.target.value),required:!0}):(0,z.jsx)(ro,{placeholder:"e.g., npm run dev",value:u,onChange:e=>h(e.target.value),required:!0})]}),"command"===o&&(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsxs)("label",{className:"text-sm font-medium",children:["Working Directory"," ",(0,z.jsx)("span",{className:"text-muted-foreground",children:"(optional)"})]}),(0,z.jsx)(ro,{placeholder:"Relative to worktree root (leave empty for root)",value:f,onChange:e=>p(e.target.value)})]}),"command"===o&&(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{className:"space-y-0.5",children:[(0,z.jsx)("label",{className:"text-sm font-medium",children:"Terminal Mode (PTY)"}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:"Enable for interactive commands like top, vim, htop"})]}),(0,z.jsx)("button",{type:"button",role:"switch","aria-checked":m,onClick:()=>g(!m),className:(0,ey.cn)("relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",m?"bg-primary":"bg-input"),children:(0,z.jsx)("span",{className:(0,ey.cn)("pointer-events-none inline-block h-5 w-5 transform rounded-full bg-background shadow-lg ring-0 transition-transform",m?"translate-x-5":"translate-x-0")})})]}),(0,z.jsx)("div",{className:"flex-1"}),(0,z.jsxs)(ri,{children:[(0,z.jsx)(W.Button,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),(0,z.jsx)(W.Button,{type:"submit",disabled:x||!n.trim()||!u.trim(),children:x?"Saving...":N?"Save":"Add"})]})]}),_&&(0,z.jsxs)("div",{className:"space-y-4 flex-1 flex flex-col min-h-0",children:[(0,z.jsx)(ro,{placeholder:"Search presets...",value:j,onChange:e=>k(e.target.value),autoFocus:!0}),(0,z.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0 space-y-1",children:xy.filter(e=>{if(!j.trim())return!0;let r=j.toLowerCase();return e.name.toLowerCase().includes(r)||e.command.toLowerCase().includes(r)||(e.description?.toLowerCase().includes(r)??!1)}).map(e=>{let r=b?.command===e.command,s=S===e.command;return(0,z.jsxs)("div",{className:"rounded-md overflow-hidden",children:[(0,z.jsxs)("button",{type:"button",className:(0,ey.cn)("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",r?"bg-primary/10 text-primary":"hover:bg-muted"),onClick:()=>w(e),children:["command"===e.executor_type?(0,z.jsx)(aN,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):(0,z.jsx)(x_,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,z.jsx)("span",{className:"font-medium flex-1 text-left",children:e.name}),(0,z.jsx)("button",{type:"button",className:"shrink-0 p-0.5 rounded hover:bg-muted-foreground/10 transition-colors",onClick:r=>{r.stopPropagation(),C(s?null:e.command)},children:s?(0,z.jsx)(sw,{className:"h-4 w-4 text-muted-foreground"}):(0,z.jsx)(af,{className:"h-4 w-4 text-muted-foreground"})})]}),s&&(0,z.jsxs)("div",{className:(0,ey.cn)("px-3 pb-2 pt-1 text-xs text-muted-foreground space-y-1 border-t border-border/50",r?"bg-primary/5":"bg-muted/50"),children:[e.description&&(0,z.jsx)("p",{children:e.description}),(0,z.jsx)("pre",{className:"whitespace-pre-wrap break-all bg-muted/50 rounded px-2 py-1 font-mono",children:e.command}),(0,z.jsxs)("div",{className:"flex gap-3",children:[(0,z.jsxs)("span",{children:["Type: ",(0,z.jsx)("span",{className:"font-medium text-foreground/70",children:e.executor_type})]}),(0,z.jsxs)("span",{children:["PTY: ",(0,z.jsx)("span",{className:"font-medium text-foreground/70",children:e.pty?"on":"off"})]})]})]})]},e.command)})}),(0,z.jsxs)(ri,{children:[(0,z.jsx)(W.Button,{type:"button",variant:"outline",onClick:()=>{y(!1),w(null),C(null)},children:"Cancel"}),(0,z.jsx)(W.Button,{type:"button",disabled:!b,onClick:()=>{b&&(a(b.name),h(b.command),l(b.executor_type),g(b.pty),y(!1),w(null),C(null))},children:"Select"})]})]})]})]})})}let xw={logs:[],status:"connecting",exitCode:null,isPty:!1,replayingHistory:!0},xS=(0,$.createContext)(null);function xC({projectId:e,children:r}){let s=(0,$.useRef)(new Map),i=(0,$.useRef)(new Map),n=(0,$.useRef)(new Set),a=(0,$.useRef)(null),o=(0,$.useRef)(0),l=(0,$.useRef)(null),c=(0,$.useCallback)(e=>{i.current.get(e)?.forEach(e=>e())},[]),d=(0,$.useCallback)((e,r)=>{let i=s.current.get(e)??xw;s.current.set(e,{...i,...r}),c(e)},[c]),u=(0,$.useCallback)(e=>{a.current?.readyState===WebSocket.OPEN&&a.current.send(JSON.stringify(e))},[]),h=(0,$.useCallback)(e=>{let{processId:r}=e,i="error"===e.type?e.message:"finished"===e.type?`exitCode=${e.exitCode}`:"init"===e.type?`isPty=${e.isPty}`:"history_end"===e.type?"":`${e.data.length}b`;if(console.log("[diag:mux] recv",e.type,r,i),"init"===e.type)d(r,{isPty:e.isPty,replayingHistory:!0,logs:[],status:"connected"});else if("history_end"===e.type)d(r,{replayingHistory:!1});else if("finished"===e.type)console.log(`[diag:remote-stop] ${new Date().toISOString()} mux received FINISHED processId=${r} exitCode=${e.exitCode} — will trigger markProcessFinished → button flips to Start`),d(r,{exitCode:e.exitCode,status:"closed"});else if("error"===e.type)console.log(`[diag:remote-stop] ${new Date().toISOString()} mux received ERROR processId=${r} — status=error, does NOT flip isRunning`),d(r,{status:"error"});else{let i=s.current.get(r)??xw,{processId:n,...a}=e;d(r,{logs:[...i.logs,{...a,historical:i.replayingHistory}]})}},[d]);(0,$.useEffect)(()=>{if(!e)return;let r=!1;o.current=0;let i=()=>{r||(0,rv.getFreshToken)().then(()=>{r||(()=>{if(r)return;let c=new WebSocket((0,rv.getWebSocketUrl)(`/api/executor-logs/stream?projectId=${encodeURIComponent(e)}`));a.current=c,c.onopen=()=>{if(!r)for(let e of(o.current=0,console.log("[diag:mux] WS open, resubscribing",[...n.current]),n.current))c.send(JSON.stringify({type:"subscribe",processId:e}))},c.onmessage=e=>{if(!r)try{h(JSON.parse(e.data))}catch(e){console.error("[ExecutorLogs] parse error:",e)}},c.onclose=()=>{if(a.current=null,console.log("[diag:mux] WS close, reconnectAttempt=",o.current,"cancelled=",r),r)return;let e=e=>{let r=s.current.get(e);return r?.status==="closed"||r?.status==="error"};if(o.current<8){let s=o.current++,a=Math.min(15e3,1e3*2**s),c=a+a*Math.random()*.25;for(let r of n.current)e(r)||d(r,{status:"connecting"});l.current=setTimeout(()=>{l.current=null,r||i()},c)}else for(let r of n.current)e(r)||d(r,{status:"error"})}})()})};return i(),()=>{r=!0,l.current&&clearTimeout(l.current),l.current=null,a.current?.close(),a.current=null}},[e,h,d]);let f=(0,$.useMemo)(()=>({subscribeProcess:e=>{n.current.has(e)||(n.current.add(e),s.current.set(e,{...xw}),c(e),console.log("[diag:mux] send subscribe",e,"(state reset to EMPTY)"),u({type:"subscribe",processId:e}))},unsubscribeProcess:e=>{n.current.has(e)&&(n.current.delete(e),console.log("[diag:mux] send unsubscribe",e),u({type:"unsubscribe",processId:e}))},sendInput:(e,r)=>u({type:"input",processId:e,data:r}),sendResize:(e,r,s)=>u({type:"resize",processId:e,cols:r,rows:s}),onProcessChange:(e,r)=>{let s=i.current.get(e);return s||(s=new Set,i.current.set(e,s)),s.add(r),()=>{s?.delete(r)}},getProcessState:e=>s.current.get(e)??xw}),[c,u]);return(0,z.jsx)(xS.Provider,{value:f,children:r})}let xj="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function xk(e){let r=Object.prototype.toString.call(e);return"[object Window]"===r||"[object global]"===r}function xN(e){return"nodeType"in e}function xE(e){var r,s;return e?xk(e)?e:xN(e)&&null!=(r=null==(s=e.ownerDocument)?void 0:s.defaultView)?r:window:window}function xD(e){let{Document:r}=xE(e);return e instanceof r}function xR(e){return!xk(e)&&e instanceof xE(e).HTMLElement}function xA(e){return e instanceof xE(e).SVGElement}function xM(e){return e?xk(e)?e.document:xN(e)?xD(e)?e:xR(e)||xA(e)?e.ownerDocument:document:document:document}let xF=xj?$.useLayoutEffect:$.useEffect;function xT(e){let r=(0,$.useRef)(e);return xF(()=>{r.current=e}),(0,$.useCallback)(function(){for(var e=arguments.length,s=Array(e),i=0;i<e;i++)s[i]=arguments[i];return null==r.current?void 0:r.current(...s)},[])}function xP(e,r){void 0===r&&(r=[e]);let s=(0,$.useRef)(e);return xF(()=>{s.current!==e&&(s.current=e)},r),s}function xB(e,r){let s=(0,$.useRef)();return(0,$.useMemo)(()=>{let r=e(s.current);return s.current=r,r},[...r])}function xL(e){let r=xT(e),s=(0,$.useRef)(null),i=(0,$.useCallback)(e=>{e!==s.current&&(null==r||r(e,s.current)),s.current=e},[]);return[s,i]}function xI(e){let r=(0,$.useRef)();return(0,$.useEffect)(()=>{r.current=e},[e]),r.current}let xO={};function xz(e,r){return(0,$.useMemo)(()=>{if(r)return r;let s=null==xO[e]?0:xO[e]+1;return xO[e]=s,e+"-"+s},[e,r])}function x$(e){return function(r){for(var s=arguments.length,i=Array(s>1?s-1:0),n=1;n<s;n++)i[n-1]=arguments[n];return i.reduce((r,s)=>{for(let[i,n]of Object.entries(s)){let s=r[i];null!=s&&(r[i]=s+e*n)}return r},{...r})}}let xW=x$(1),xH=x$(-1);function xU(e){if(!e)return!1;let{KeyboardEvent:r}=xE(e.target);return r&&e instanceof r}function xK(e){if(function(e){if(!e)return!1;let{TouchEvent:r}=xE(e.target);return r&&e instanceof r}(e)){if(e.touches&&e.touches.length){let{clientX:r,clientY:s}=e.touches[0];return{x:r,y:s}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:r,clientY:s}=e.changedTouches[0];return{x:r,y:s}}}return"clientX"in e&&"clientY"in e?{x:e.clientX,y:e.clientY}:null}let xq=Object.freeze({Translate:{toString(e){if(!e)return;let{x:r,y:s}=e;return"translate3d("+(r?Math.round(r):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;let{scaleX:r,scaleY:s}=e;return"scaleX("+r+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[xq.Translate.toString(e),xq.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:r,duration:s,easing:i}=e;return r+" "+s+"ms "+i}}}),xV="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]",xY={display:"none"};function xG(e){let{id:r,value:s}=e;return $.default.createElement("div",{id:r,style:xY},s)}function xX(e){let{id:r,announcement:s,ariaLiveType:i="assertive"}=e;return $.default.createElement("div",{id:r,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":i,"aria-atomic":!0},s)}let xJ=(0,$.createContext)(null),xZ={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},xQ={onDragStart(e){let{active:r}=e;return"Picked up draggable item "+r.id+"."},onDragOver(e){let{active:r,over:s}=e;return s?"Draggable item "+r.id+" was moved over droppable area "+s.id+".":"Draggable item "+r.id+" is no longer over a droppable area."},onDragEnd(e){let{active:r,over:s}=e;return s?"Draggable item "+r.id+" was dropped over droppable area "+s.id:"Draggable item "+r.id+" was dropped."},onDragCancel(e){let{active:r}=e;return"Dragging was cancelled. Draggable item "+r.id+" was dropped."}};function x0(e){var r;let s,{announcements:i=xQ,container:n,hiddenTextDescribedById:a,screenReaderInstructions:o=xZ}=e,{announce:l,announcement:c}=function(){let[e,r]=(0,$.useState)("");return{announce:(0,$.useCallback)(e=>{null!=e&&r(e)},[]),announcement:e}}(),d=xz("DndLiveRegion"),[u,h]=(0,$.useState)(!1);if((0,$.useEffect)(()=>{h(!0)},[]),r=(0,$.useMemo)(()=>({onDragStart(e){let{active:r}=e;l(i.onDragStart({active:r}))},onDragMove(e){let{active:r,over:s}=e;i.onDragMove&&l(i.onDragMove({active:r,over:s}))},onDragOver(e){let{active:r,over:s}=e;l(i.onDragOver({active:r,over:s}))},onDragEnd(e){let{active:r,over:s}=e;l(i.onDragEnd({active:r,over:s}))},onDragCancel(e){let{active:r,over:s}=e;l(i.onDragCancel({active:r,over:s}))}}),[l,i]),s=(0,$.useContext)(xJ),(0,$.useEffect)(()=>{if(!s)throw Error("useDndMonitor must be used within a children of <DndContext>");return s(r)},[r,s]),!u)return null;let f=$.default.createElement($.default.Fragment,null,$.default.createElement(xG,{id:a,value:o.draggable}),$.default.createElement(xX,{id:d,announcement:c}));return n?(0,ee.createPortal)(f,n):f}function x1(){}function x2(e,r){return(0,$.useMemo)(()=>({sensor:e,options:null!=r?r:{}}),[e,r])}(_=E||(E={})).DragStart="dragStart",_.DragMove="dragMove",_.DragEnd="dragEnd",_.DragCancel="dragCancel",_.DragOver="dragOver",_.RegisterDroppable="registerDroppable",_.SetDroppableDisabled="setDroppableDisabled",_.UnregisterDroppable="unregisterDroppable";let x5=Object.freeze({x:0,y:0});function x3(e,r){return Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2))}function x4(e,r){let{data:{value:s}}=e,{data:{value:i}}=r;return s-i}function x6(e,r){let{data:{value:s}}=e,{data:{value:i}}=r;return i-s}function x8(e){let{left:r,top:s,height:i,width:n}=e;return[{x:r,y:s},{x:r+n,y:s},{x:r,y:s+i},{x:r+n,y:s+i}]}function x7(e,r){if(!e||0===e.length)return null;let[s]=e;return r?s[r]:s}function x9(e,r,s){return void 0===r&&(r=e.left),void 0===s&&(s=e.top),{x:r+.5*e.width,y:s+.5*e.height}}let ve=e=>{let{collisionRect:r,droppableRects:s,droppableContainers:i}=e,n=[];for(let e of i){let{id:i}=e,a=s.get(i);if(a){let s=function(e,r){let s=Math.max(r.top,e.top),i=Math.max(r.left,e.left),n=Math.min(r.left+r.width,e.left+e.width),a=Math.min(r.top+r.height,e.top+e.height);if(i<n&&s<a){let o=r.width*r.height,l=e.width*e.height,c=(n-i)*(a-s);return Number((c/(o+l-c)).toFixed(4))}return 0}(a,r);s>0&&n.push({id:i,data:{droppableContainer:e,value:s}})}}return n.sort(x6)};function vt(e,r){return e&&r?{x:e.left-r.left,y:e.top-r.top}:x5}let vr=function(e){for(var r=arguments.length,s=Array(r>1?r-1:0),i=1;i<r;i++)s[i-1]=arguments[i];return s.reduce((e,r)=>({...e,top:e.top+ +r.y,bottom:e.bottom+ +r.y,left:e.left+ +r.x,right:e.right+ +r.x}),{...e})},vs={ignoreTransform:!1};function vi(e,r){void 0===r&&(r=vs);let s=e.getBoundingClientRect();if(r.ignoreTransform){let{transform:r,transformOrigin:i}=xE(e).getComputedStyle(e);r&&(s=function(e,r,s){let i=function(e){if(e.startsWith("matrix3d(")){let r=e.slice(9,-1).split(/, /);return{x:+r[12],y:+r[13],scaleX:+r[0],scaleY:+r[5]}}if(e.startsWith("matrix(")){let r=e.slice(7,-1).split(/, /);return{x:+r[4],y:+r[5],scaleX:+r[0],scaleY:+r[3]}}return null}(r);if(!i)return e;let{scaleX:n,scaleY:a,x:o,y:l}=i,c=e.left-o-(1-n)*parseFloat(s),d=e.top-l-(1-a)*parseFloat(s.slice(s.indexOf(" ")+1)),u=n?e.width/n:e.width,h=a?e.height/a:e.height;return{width:u,height:h,top:d,right:c+u,bottom:d+h,left:c}}(s,r,i))}let{top:i,left:n,width:a,height:o,bottom:l,right:c}=s;return{top:i,left:n,width:a,height:o,bottom:l,right:c}}function vn(e){return vi(e,{ignoreTransform:!0})}function va(e,r){let s=[];return e?function i(n){var a,o;let l;if(null!=r&&s.length>=r||!n)return s;if(xD(n)&&null!=n.scrollingElement&&!s.includes(n.scrollingElement))return s.push(n.scrollingElement),s;if(!xR(n)||xA(n)||s.includes(n))return s;let c=xE(e).getComputedStyle(n);return(n!==e&&(void 0===(a=c)&&(a=xE(n).getComputedStyle(n)),l=/(auto|scroll|overlay)/,["overflow","overflowX","overflowY"].some(e=>{let r=a[e];return"string"==typeof r&&l.test(r)}))&&s.push(n),void 0===(o=c)&&(o=xE(n).getComputedStyle(n)),"fixed"===o.position)?s:i(n.parentNode)}(e):s}function vo(e){let[r]=va(e,1);return null!=r?r:null}function vl(e){return xj&&e?xk(e)?e:xN(e)?xD(e)||e===xM(e).scrollingElement?window:xR(e)?e:null:null:null}function vc(e){return xk(e)?e.scrollX:e.scrollLeft}function vd(e){return xk(e)?e.scrollY:e.scrollTop}function vu(e){return{x:vc(e),y:vd(e)}}function vh(e){return!!xj&&!!e&&e===document.scrollingElement}function vf(e){let r={x:0,y:0},s=vh(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},i={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},n=e.scrollTop<=r.y,a=e.scrollLeft<=r.x;return{isTop:n,isLeft:a,isBottom:e.scrollTop>=i.y,isRight:e.scrollLeft>=i.x,maxScroll:i,minScroll:r}}(y=D||(D={}))[y.Forward=1]="Forward",y[y.Backward=-1]="Backward";let vp={x:.2,y:.2};function vm(e){return e.reduce((e,r)=>xW(e,vu(r)),x5)}let vg=[["x",["left","right"],function(e){return e.reduce((e,r)=>e+vc(r),0)}],["y",["top","bottom"],function(e){return e.reduce((e,r)=>e+vd(r),0)}]];class vx{constructor(e,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=va(r),i=vm(s);for(const[r,n,a]of(this.rect={...e},this.width=e.width,this.height=e.height,vg))for(const e of n)Object.defineProperty(this,e,{get:()=>{let n=a(s),o=i[r]-n;return this.rect[e]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class vv{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>{var r;return null==(r=this.target)?void 0:r.removeEventListener(...e)})},this.target=e}add(e,r,s){var i;null==(i=this.target)||i.addEventListener(e,r,s),this.listeners.push([e,r,s])}}function v_(e,r){let s=Math.abs(e.x),i=Math.abs(e.y);return"number"==typeof r?Math.sqrt(s**2+i**2)>r:"x"in r&&"y"in r?s>r.x&&i>r.y:"x"in r?s>r.x:"y"in r&&i>r.y}function vy(e){e.preventDefault()}function vb(e){e.stopPropagation()}(b=R||(R={})).Click="click",b.DragStart="dragstart",b.Keydown="keydown",b.ContextMenu="contextmenu",b.Resize="resize",b.SelectionChange="selectionchange",b.VisibilityChange="visibilitychange",(w=A||(A={})).Space="Space",w.Down="ArrowDown",w.Right="ArrowRight",w.Left="ArrowLeft",w.Up="ArrowUp",w.Esc="Escape",w.Enter="Enter",w.Tab="Tab";let vw={start:[A.Space,A.Enter],cancel:[A.Esc],end:[A.Space,A.Enter,A.Tab]},vS=(e,r)=>{let{currentCoordinates:s}=r;switch(e.code){case A.Right:return{...s,x:s.x+25};case A.Left:return{...s,x:s.x-25};case A.Down:return{...s,y:s.y+25};case A.Up:return{...s,y:s.y-25}}};class vC{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:r}}=e;this.props=e,this.listeners=new vv(xM(r)),this.windowListeners=new vv(xE(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(R.Resize,this.handleCancel),this.windowListeners.add(R.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(R.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:r}=this.props,s=e.node.current;s&&function(e,r){if(void 0===r&&(r=vi),!e)return;let{top:s,left:i,bottom:n,right:a}=r(e);vo(e)&&(n<=0||a<=0||s>=window.innerHeight||i>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(s),r(x5)}handleKeyDown(e){if(xU(e)){let{active:r,context:s,options:i}=this.props,{keyboardCodes:n=vw,coordinateGetter:a=vS,scrollBehavior:o="smooth"}=i,{code:l}=e;if(n.end.includes(l))return void this.handleEnd(e);if(n.cancel.includes(l))return void this.handleCancel(e);let{collisionRect:c}=s.current,d=c?{x:c.left,y:c.top}:x5;this.referenceCoordinates||(this.referenceCoordinates=d);let u=a(e,{active:r,context:s.current,currentCoordinates:d});if(u){let r=xH(u,d),i={x:0,y:0},{scrollableAncestors:n}=s.current;for(let s of n){let n=e.code,{isTop:a,isRight:l,isLeft:c,isBottom:d,maxScroll:h,minScroll:f}=vf(s),p=function(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:r}=window;return{top:0,left:0,right:e,bottom:r,width:e,height:r}}let{top:r,left:s,right:i,bottom:n}=e.getBoundingClientRect();return{top:r,left:s,right:i,bottom:n,width:e.clientWidth,height:e.clientHeight}}(s),m={x:Math.min(n===A.Right?p.right-p.width/2:p.right,Math.max(n===A.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(n===A.Down?p.bottom-p.height/2:p.bottom,Math.max(n===A.Down?p.top:p.top+p.height/2,u.y))},g=n===A.Right&&!l||n===A.Left&&!c,x=n===A.Down&&!d||n===A.Up&&!a;if(g&&m.x!==u.x){let e=s.scrollLeft+r.x,a=n===A.Right&&e<=h.x||n===A.Left&&e>=f.x;if(a&&!r.y)return void s.scrollTo({left:e,behavior:o});a?i.x=s.scrollLeft-e:i.x=n===A.Right?s.scrollLeft-h.x:s.scrollLeft-f.x,i.x&&s.scrollBy({left:-i.x,behavior:o});break}if(x&&m.y!==u.y){let e=s.scrollTop+r.y,a=n===A.Down&&e<=h.y||n===A.Up&&e>=f.y;if(a&&!r.x)return void s.scrollTo({top:e,behavior:o});a?i.y=s.scrollTop-e:i.y=n===A.Down?s.scrollTop-h.y:s.scrollTop-f.y,i.y&&s.scrollBy({top:-i.y,behavior:o});break}}this.handleMove(e,xW(xH(u,this.referenceCoordinates),i))}}}handleMove(e,r){let{onMove:s}=this.props;e.preventDefault(),s(r)}handleEnd(e){let{onEnd:r}=this.props;e.preventDefault(),this.detach(),r()}handleCancel(e){let{onCancel:r}=this.props;e.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function vj(e){return!!(e&&"distance"in e)}function vk(e){return!!(e&&"delay"in e)}vC.activators=[{eventName:"onKeyDown",handler:(e,r,s)=>{let{keyboardCodes:i=vw,onActivation:n}=r,{active:a}=s,{code:o}=e.nativeEvent;if(i.start.includes(o)){let r=a.activatorNode.current;return(!r||e.target===r)&&(e.preventDefault(),null==n||n({event:e.nativeEvent}),!0)}return!1}}];class vN{constructor(e,r,s){var i;void 0===s&&(s=function(e){let{EventTarget:r}=xE(e);return e instanceof r?e:xM(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=r;const{event:n}=e,{target:a}=n;this.props=e,this.events=r,this.document=xM(a),this.documentListeners=new vv(this.document),this.listeners=new vv(s),this.windowListeners=new vv(xE(a)),this.initialCoordinates=null!=(i=xK(n))?i:x5,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:r,bypassActivationConstraint:s}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(R.Resize,this.handleCancel),this.windowListeners.add(R.DragStart,vy),this.windowListeners.add(R.VisibilityChange,this.handleCancel),this.windowListeners.add(R.ContextMenu,vy),this.documentListeners.add(R.Keydown,this.handleKeydown),r){if(null!=s&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(vk(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(vj(r))return void this.handlePending(r)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,r){let{active:s,onPending:i}=this.props;i(s,e,this.initialCoordinates,r)}handleStart(){let{initialCoordinates:e}=this,{onStart:r}=this.props;e&&(this.activated=!0,this.documentListeners.add(R.Click,vb,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(R.SelectionChange,this.removeTextSelection),r(e))}handleMove(e){var r;let{activated:s,initialCoordinates:i,props:n}=this,{onMove:a,options:{activationConstraint:o}}=n;if(!i)return;let l=null!=(r=xK(e))?r:x5,c=xH(i,l);if(!s&&o){if(vj(o)){if(null!=o.tolerance&&v_(c,o.tolerance))return this.handleCancel();if(v_(c,o.distance))return this.handleStart()}return vk(o)&&v_(c,o.tolerance)?this.handleCancel():void this.handlePending(o,c)}e.cancelable&&e.preventDefault(),a(l)}handleEnd(){let{onAbort:e,onEnd:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleCancel(){let{onAbort:e,onCancel:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleKeydown(e){e.code===A.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}let vE={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class vD extends vN{constructor(e){const{event:r}=e;super(e,vE,xM(r.target))}}vD.activators=[{eventName:"onPointerDown",handler:(e,r)=>{let{nativeEvent:s}=e,{onActivation:i}=r;return!!s.isPrimary&&0===s.button&&(null==i||i({event:s}),!0)}}];(S=M||(M={}))[S.RightClick=2]="RightClick";(C=F||(F={}))[C.Pointer=0]="Pointer",C[C.DraggableRect=1]="DraggableRect",(j=T||(T={}))[j.TreeOrder=0]="TreeOrder",j[j.ReversedTreeOrder=1]="ReversedTreeOrder";let vR={x:{[D.Backward]:!1,[D.Forward]:!1},y:{[D.Backward]:!1,[D.Forward]:!1}};(k=P||(P={}))[k.Always=0]="Always",k[k.BeforeDragging=1]="BeforeDragging",k[k.WhileDragging=2]="WhileDragging",(B||(B={})).Optimized="optimized";let vA=new Map;function vM(e,r){return xB(s=>e?s||("function"==typeof r?r(e):e):null,[r,e])}function vF(e){let{callback:r,disabled:s}=e,i=xT(r),n=(0,$.useMemo)(()=>{if(s||"undefined"==typeof window||void 0===window.ResizeObserver)return;let{ResizeObserver:e}=window;return new e(i)},[s]);return(0,$.useEffect)(()=>()=>null==n?void 0:n.disconnect(),[n]),n}function vT(e){return new vx(vi(e),e)}function vP(e,r,s){void 0===r&&(r=vT);let[i,n]=(0,$.useState)(null);function a(){n(i=>{if(!e)return null;if(!1===e.isConnected){var n;return null!=(n=null!=i?i:s)?n:null}let a=r(e);return JSON.stringify(i)===JSON.stringify(a)?i:a})}let o=function(e){let{callback:r,disabled:s}=e,i=xT(r),n=(0,$.useMemo)(()=>{if(s||"undefined"==typeof window||void 0===window.MutationObserver)return;let{MutationObserver:e}=window;return new e(i)},[i,s]);return(0,$.useEffect)(()=>()=>null==n?void 0:n.disconnect(),[n]),n}({callback(r){if(e)for(let s of r){let{type:r,target:i}=s;if("childList"===r&&i instanceof HTMLElement&&i.contains(e)){a();break}}}}),l=vF({callback:a});return xF(()=>{a(),e?(null==l||l.observe(e),null==o||o.observe(document.body,{childList:!0,subtree:!0})):(null==l||l.disconnect(),null==o||o.disconnect())},[e]),i}let vB=[];function vL(e,r){void 0===r&&(r=[]);let s=(0,$.useRef)(null);return(0,$.useEffect)(()=>{s.current=null},r),(0,$.useEffect)(()=>{let r=e!==x5;r&&!s.current&&(s.current=e),!r&&s.current&&(s.current=null)},[e]),s.current?xH(e,s.current):x5}function vI(e){return(0,$.useMemo)(()=>{let r,s;return e?(r=e.innerWidth,{top:0,left:0,right:r,bottom:s=e.innerHeight,width:r,height:s}):null},[e])}let vO=[],vz=[{sensor:vD,options:{}},{sensor:vC,options:{}}],v$={current:{}},vW={draggable:{measure:vn},droppable:{measure:vn,strategy:P.WhileDragging,frequency:B.Optimized},dragOverlay:{measure:vi}};class vH extends Map{get(e){var r;return null!=e&&null!=(r=super.get(e))?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:r}=e;return!r})}getNodeFor(e){var r,s;return null!=(r=null==(s=this.get(e))?void 0:s.node.current)?r:void 0}}let vU={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new vH,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:x1},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:vW,measureDroppableContainers:x1,windowRect:null,measuringScheduled:!1},vK={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:x1,draggableNodes:new Map,over:null,measureDroppableContainers:x1},vq=(0,$.createContext)(vK),vV=(0,$.createContext)(vU);function vY(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new vH}}}function vG(e,r){switch(r.type){case E.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:r.initialCoordinates,active:r.active}};case E.DragMove:if(null==e.draggable.active)return e;return{...e,draggable:{...e.draggable,translate:{x:r.coordinates.x-e.draggable.initialCoordinates.x,y:r.coordinates.y-e.draggable.initialCoordinates.y}}};case E.DragEnd:case E.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case E.RegisterDroppable:{let{element:s}=r,{id:i}=s,n=new vH(e.droppable.containers);return n.set(i,s),{...e,droppable:{...e.droppable,containers:n}}}case E.SetDroppableDisabled:{let{id:s,key:i,disabled:n}=r,a=e.droppable.containers.get(s);if(!a||i!==a.key)return e;let o=new vH(e.droppable.containers);return o.set(s,{...a,disabled:n}),{...e,droppable:{...e.droppable,containers:o}}}case E.UnregisterDroppable:{let{id:s,key:i}=r,n=e.droppable.containers.get(s);if(!n||i!==n.key)return e;let a=new vH(e.droppable.containers);return a.delete(s),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function vX(e){let{disabled:r}=e,{active:s,activatorEvent:i,draggableNodes:n}=(0,$.useContext)(vq),a=xI(i),o=xI(null==s?void 0:s.id);return(0,$.useEffect)(()=>{if(!r&&!i&&a&&null!=o){if(!xU(a)||document.activeElement===a.target)return;let e=n.get(o);if(!e)return;let{activatorNode:r,node:s}=e;(r.current||s.current)&&requestAnimationFrame(()=>{for(let e of[r.current,s.current]){if(!e)continue;let r=e.matches(xV)?e:e.querySelector(xV);if(r){r.focus();break}}})}},[i,r,n,o,a]),null}let vJ=(0,$.createContext)({...x5,scaleX:1,scaleY:1});(N=L||(L={}))[N.Uninitialized=0]="Uninitialized",N[N.Initializing=1]="Initializing",N[N.Initialized=2]="Initialized";let vZ=(0,$.memo)(function(e){var r,s,i,n,a,o,l,c;let d,u,h,f,p,m,g,x,{id:v,accessibility:_,autoScroll:y=!0,children:b,sensors:w=vz,collisionDetection:S=ve,measuring:C,modifiers:j,...k}=e,[N,R]=(0,$.useReducer)(vG,void 0,vY),[A,M]=function(){let[e]=(0,$.useState)(()=>new Set),r=(0,$.useCallback)(r=>(e.add(r),()=>e.delete(r)),[e]);return[(0,$.useCallback)(r=>{let{type:s,event:i}=r;e.forEach(e=>{var r;return null==(r=e[s])?void 0:r.call(e,i)})},[e]),r]}(),[B,I]=(0,$.useState)(L.Uninitialized),O=B===L.Initialized,{draggable:{active:z,nodes:W,translate:H},droppable:{containers:U}}=N,K=null!=z?W.get(z):null,q=(0,$.useRef)({initial:null,translated:null}),V=(0,$.useMemo)(()=>{var e;return null!=z?{id:z,data:null!=(e=null==K?void 0:K.data)?e:v$,rect:q}:null},[z,K]),Y=(0,$.useRef)(null),[G,X]=(0,$.useState)(null),[J,Z]=(0,$.useState)(null),Q=xP(k,Object.values(k)),et=xz("DndDescribedBy",v),er=(0,$.useMemo)(()=>U.getEnabled(),[U]),es=(0,$.useMemo)(()=>({draggable:{...vW.draggable,...null==C?void 0:C.draggable},droppable:{...vW.droppable,...null==C?void 0:C.droppable},dragOverlay:{...vW.dragOverlay,...null==C?void 0:C.dragOverlay}}),[null==C?void 0:C.draggable,null==C?void 0:C.droppable,null==C?void 0:C.dragOverlay]),{droppableRects:ei,measureDroppableContainers:en,measuringScheduled:ea}=function(e,r){let{dragging:s,dependencies:i,config:n}=r,[a,o]=(0,$.useState)(null),{frequency:l,measure:c,strategy:d}=n,u=(0,$.useRef)(e),h=function(){switch(d){case P.Always:return!1;case P.BeforeDragging:return s;default:return!s}}(),f=xP(h),p=(0,$.useCallback)(function(e){void 0===e&&(e=[]),f.current||o(r=>null===r?e:r.concat(e.filter(e=>!r.includes(e))))},[f]),m=(0,$.useRef)(null),g=xB(r=>{if(h&&!s)return vA;if(!r||r===vA||u.current!==e||null!=a){let r=new Map;for(let s of e){if(!s)continue;if(a&&a.length>0&&!a.includes(s.id)&&s.rect.current){r.set(s.id,s.rect.current);continue}let e=s.node.current,i=e?new vx(c(e),e):null;s.rect.current=i,i&&r.set(s.id,i)}return r}return r},[e,a,s,h,c]);return(0,$.useEffect)(()=>{u.current=e},[e]),(0,$.useEffect)(()=>{h||p()},[s,h]),(0,$.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,$.useEffect)(()=>{h||"number"!=typeof l||null!==m.current||(m.current=setTimeout(()=>{p(),m.current=null},l))},[l,h,p,...i]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:null!=a}}(er,{dragging:O,dependencies:[H.x,H.y],config:es.droppable}),eo=xB(e=>{var r;return null==z?null:null!=(r=null!=p?p:e)?r:null},[p=(f=null!=z?W.get(z):void 0)?f.node.current:null,z]),el=(0,$.useMemo)(()=>J?xK(J):null,[J]),ec=(d=(null==G?void 0:G.autoScrollEnabled)===!1,u="object"==typeof y?!1===y.enabled:!1===y,h=O&&!d&&!u,"object"==typeof y?{...y,enabled:h}:{enabled:h}),ed=vM(eo,es.draggable.measure);!function(e){let{activeNode:r,measure:s,initialRect:i,config:n=!0}=e,a=(0,$.useRef)(!1),{x:o,y:l}="boolean"==typeof n?{x:n,y:n}:n;xF(()=>{if(!o&&!l||!r){a.current=!1;return}if(a.current||!i)return;let e=null==r?void 0:r.node.current;if(!e||!1===e.isConnected)return;let n=vt(s(e),i);if(o||(n.x=0),l||(n.y=0),a.current=!0,Math.abs(n.x)>0||Math.abs(n.y)>0){let r=vo(e);r&&r.scrollBy({top:n.y,left:n.x})}},[r,o,l,i,s])}({activeNode:null!=z?W.get(z):null,config:ec.layoutShiftCompensation,initialRect:ed,measure:es.draggable.measure});let eu=vP(eo,es.draggable.measure,ed),eh=vP(eo?eo.parentElement:null),ef=(0,$.useRef)({activatorEvent:null,active:null,activeNode:eo,collisionRect:null,collisions:null,droppableRects:ei,draggableNodes:W,draggingNode:null,draggingNodeRect:null,droppableContainers:U,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ep=U.getNodeFor(null==(r=ef.current.over)?void 0:r.id),em=function(e){let{measure:r}=e,[s,i]=(0,$.useState)(null),n=vF({callback:(0,$.useCallback)(e=>{for(let{target:s}of e)if(xR(s)){i(e=>{let i=r(s);return e?{...e,width:i.width,height:i.height}:i});break}},[r])}),[a,o]=xL((0,$.useCallback)(e=>{let s=function(e){if(!e)return null;if(e.children.length>1)return e;let r=e.children[0];return xR(r)?r:e}(e);null==n||n.disconnect(),s&&(null==n||n.observe(s)),i(s?r(s):null)},[r,n]));return(0,$.useMemo)(()=>({nodeRef:a,rect:s,setRef:o}),[s,a,o])}({measure:es.dragOverlay.measure}),eg=null!=(s=em.nodeRef.current)?s:eo,ex=O?null!=(i=em.rect)?i:eu:null,ev=!!(em.nodeRef.current&&em.rect),e_=(m=vM(a=ev?null:eu),vt(a,m)),ey=vI(eg?xE(eg):null),eb=(o=O?null!=ep?ep:eo:null,g=(0,$.useRef)(o),x=xB(e=>o?e&&e!==vB&&o&&g.current&&o.parentNode===g.current.parentNode?e:va(o):vB,[o]),(0,$.useEffect)(()=>{g.current=o},[o]),x),ew=function(e,r){void 0===r&&(r=vi);let[s]=e,i=vI(s?xE(s):null),[n,a]=(0,$.useState)(vO);function o(){a(()=>e.length?e.map(e=>vh(e)?i:new vx(r(e),e)):vO)}let l=vF({callback:o});return xF(()=>{null==l||l.disconnect(),o(),e.forEach(e=>null==l?void 0:l.observe(e))},[e]),n}(eb),eS=function(e,r){let{transform:s,...i}=r;return null!=e&&e.length?e.reduce((e,r)=>r({transform:e,...i}),s):s}(j,{transform:{x:H.x-e_.x,y:H.y-e_.y,scaleX:1,scaleY:1},activatorEvent:J,active:V,activeNodeRect:eu,containerNodeRect:eh,draggingNodeRect:ex,over:ef.current.over,overlayNodeRect:em.rect,scrollableAncestors:eb,scrollableAncestorRects:ew,windowRect:ey}),eC=el?xW(el,H):null,ej=function(e){let[r,s]=(0,$.useState)(null),i=(0,$.useRef)(e),n=(0,$.useCallback)(e=>{let r=vl(e.target);r&&s(e=>e?(e.set(r,vu(r)),new Map(e)):null)},[]);return(0,$.useEffect)(()=>{let r=i.current;if(e!==r){a(r);let o=e.map(e=>{let r=vl(e);return r?(r.addEventListener("scroll",n,{passive:!0}),[r,vu(r)]):null}).filter(e=>null!=e);s(o.length?new Map(o):null),i.current=e}return()=>{a(e),a(r)};function a(e){e.forEach(e=>{let r=vl(e);null==r||r.removeEventListener("scroll",n)})}},[n,e]),(0,$.useMemo)(()=>e.length?r?Array.from(r.values()).reduce((e,r)=>xW(e,r),x5):vm(e):x5,[e,r])}(eb),ek=vL(ej),eN=vL(ej,[eu]),eE=xW(eS,ek),eD=ex?vr(ex,eS):null,eR=V&&eD?S({active:V,collisionRect:eD,droppableRects:ei,droppableContainers:er,pointerCoordinates:eC}):null,eA=x7(eR,"id"),[eM,eF]=(0,$.useState)(null),eT=(l=ev?eS:xW(eS,eN),c=null!=(n=null==eM?void 0:eM.rect)?n:null,{...l,scaleX:c&&eu?c.width/eu.width:1,scaleY:c&&eu?c.height/eu.height:1}),eP=(0,$.useRef)(null),eB=(0,$.useCallback)((e,r)=>{let{sensor:s,options:i}=r;if(null==Y.current)return;let n=W.get(Y.current);if(!n)return;let a=e.nativeEvent,o=new s({active:Y.current,activeNode:n,event:a,options:i,context:ef,onAbort(e){if(!W.get(e))return;let{onDragAbort:r}=Q.current,s={id:e};null==r||r(s),A({type:"onDragAbort",event:s})},onPending(e,r,s,i){if(!W.get(e))return;let{onDragPending:n}=Q.current,a={id:e,constraint:r,initialCoordinates:s,offset:i};null==n||n(a),A({type:"onDragPending",event:a})},onStart(e){let r=Y.current;if(null==r)return;let s=W.get(r);if(!s)return;let{onDragStart:i}=Q.current,n={activatorEvent:a,active:{id:r,data:s.data,rect:q}};(0,ee.unstable_batchedUpdates)(()=>{null==i||i(n),I(L.Initializing),R({type:E.DragStart,initialCoordinates:e,active:r}),A({type:"onDragStart",event:n}),X(eP.current),Z(a)})},onMove(e){R({type:E.DragMove,coordinates:e})},onEnd:l(E.DragEnd),onCancel:l(E.DragCancel)});function l(e){return async function(){let{active:r,collisions:s,over:i,scrollAdjustedTranslate:n}=ef.current,o=null;if(r&&n){let{cancelDrop:l}=Q.current;o={activatorEvent:a,active:r,collisions:s,delta:n,over:i},e===E.DragEnd&&"function"==typeof l&&await Promise.resolve(l(o))&&(e=E.DragCancel)}Y.current=null,(0,ee.unstable_batchedUpdates)(()=>{R({type:e}),I(L.Uninitialized),eF(null),X(null),Z(null),eP.current=null;let r=e===E.DragEnd?"onDragEnd":"onDragCancel";if(o){let e=Q.current[r];null==e||e(o),A({type:r,event:o})}})}}eP.current=o},[W]),eL=(0,$.useCallback)((e,r)=>(s,i)=>{let n=s.nativeEvent,a=W.get(i);null!==Y.current||!a||n.dndKit||n.defaultPrevented||!0===e(s,r.options,{active:a})&&(n.dndKit={capturedBy:r.sensor},Y.current=i,eB(s,r))},[W,eB]),eI=(0,$.useMemo)(()=>w.reduce((e,r)=>{let{sensor:s}=r;return[...e,...s.activators.map(e=>({eventName:e.eventName,handler:eL(e.handler,r)}))]},[]),[w,eL]);(0,$.useEffect)(()=>{if(!xj)return;let e=w.map(e=>{let{sensor:r}=e;return null==r.setup?void 0:r.setup()});return()=>{for(let r of e)null==r||r()}},w.map(e=>{let{sensor:r}=e;return r})),xF(()=>{eu&&B===L.Initializing&&I(L.Initialized)},[eu,B]),(0,$.useEffect)(()=>{let{onDragMove:e}=Q.current,{active:r,activatorEvent:s,collisions:i,over:n}=ef.current;if(!r||!s)return;let a={active:r,activatorEvent:s,collisions:i,delta:{x:eE.x,y:eE.y},over:n};(0,ee.unstable_batchedUpdates)(()=>{null==e||e(a),A({type:"onDragMove",event:a})})},[eE.x,eE.y]),(0,$.useEffect)(()=>{let{active:e,activatorEvent:r,collisions:s,droppableContainers:i,scrollAdjustedTranslate:n}=ef.current;if(!e||null==Y.current||!r||!n)return;let{onDragOver:a}=Q.current,o=i.get(eA),l=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:r,collisions:s,delta:{x:n.x,y:n.y},over:l};(0,ee.unstable_batchedUpdates)(()=>{eF(l),null==a||a(c),A({type:"onDragOver",event:c})})},[eA]),xF(()=>{ef.current={activatorEvent:J,active:V,activeNode:eo,collisionRect:eD,collisions:eR,droppableRects:ei,draggableNodes:W,draggingNode:eg,draggingNodeRect:ex,droppableContainers:U,over:eM,scrollableAncestors:eb,scrollAdjustedTranslate:eE},q.current={initial:ex,translated:eD}},[V,eo,eR,eD,W,eg,ex,ei,U,eM,eb,eE]),function(e){let r,{acceleration:s,activator:i=F.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:c=T.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:h,delta:f,threshold:p}=e,m=function(e){let{delta:r,disabled:s}=e,i=xI(r);return xB(e=>{if(s||!i||!e)return vR;let n={x:Math.sign(r.x-i.x),y:Math.sign(r.y-i.y)};return{x:{[D.Backward]:e.x[D.Backward]||-1===n.x,[D.Forward]:e.x[D.Forward]||1===n.x},y:{[D.Backward]:e.y[D.Backward]||-1===n.y,[D.Forward]:e.y[D.Forward]||1===n.y}}},[s,r,i])}({delta:f,disabled:!o}),[g,x]=(r=(0,$.useRef)(null),[(0,$.useCallback)((e,s)=>{r.current=setInterval(e,s)},[]),(0,$.useCallback)(()=>{null!==r.current&&(clearInterval(r.current),r.current=null)},[])]),v=(0,$.useRef)({x:0,y:0}),_=(0,$.useRef)({x:0,y:0}),y=(0,$.useMemo)(()=>{switch(i){case F.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case F.DraggableRect:return a}},[i,a,d]),b=(0,$.useRef)(null),w=(0,$.useCallback)(()=>{let e=b.current;if(!e)return;let r=v.current.x*_.current.x,s=v.current.y*_.current.y;e.scrollBy(r,s)},[]),S=(0,$.useMemo)(()=>c===T.TreeOrder?[...u].reverse():u,[c,u]);(0,$.useEffect)(()=>{if(!o||!u.length||!y)return void x();for(let e of S){if((null==n?void 0:n(e))===!1)continue;let r=h[u.indexOf(e)];if(!r)continue;let{direction:i,speed:a}=function(e,r,s,i,n){let{top:a,left:o,right:l,bottom:c}=s;void 0===i&&(i=10),void 0===n&&(n=vp);let{isTop:d,isBottom:u,isLeft:h,isRight:f}=vf(e),p={x:0,y:0},m={x:0,y:0},g={height:r.height*n.y,width:r.width*n.x};return!d&&a<=r.top+g.height?(p.y=D.Backward,m.y=i*Math.abs((r.top+g.height-a)/g.height)):!u&&c>=r.bottom-g.height&&(p.y=D.Forward,m.y=i*Math.abs((r.bottom-g.height-c)/g.height)),!f&&l>=r.right-g.width?(p.x=D.Forward,m.x=i*Math.abs((r.right-g.width-l)/g.width)):!h&&o<=r.left+g.width&&(p.x=D.Backward,m.x=i*Math.abs((r.left+g.width-o)/g.width)),{direction:p,speed:m}}(e,r,y,s,p);for(let e of["x","y"])m[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){x(),b.current=e,g(w,l),v.current=a,_.current=i;return}}v.current={x:0,y:0},_.current={x:0,y:0},x()},[s,w,n,x,o,l,JSON.stringify(y),JSON.stringify(m),g,u,S,h,JSON.stringify(p)])}({...ec,delta:H,draggingRect:eD,pointerCoordinates:eC,scrollableAncestors:eb,scrollableAncestorRects:ew});let eO=(0,$.useMemo)(()=>({active:V,activeNode:eo,activeNodeRect:eu,activatorEvent:J,collisions:eR,containerNodeRect:eh,dragOverlay:em,draggableNodes:W,droppableContainers:U,droppableRects:ei,over:eM,measureDroppableContainers:en,scrollableAncestors:eb,scrollableAncestorRects:ew,measuringConfiguration:es,measuringScheduled:ea,windowRect:ey}),[V,eo,eu,J,eR,eh,em,W,U,ei,eM,en,eb,ew,es,ea,ey]),ez=(0,$.useMemo)(()=>({activatorEvent:J,activators:eI,active:V,activeNodeRect:eu,ariaDescribedById:{draggable:et},dispatch:R,draggableNodes:W,over:eM,measureDroppableContainers:en}),[J,eI,V,eu,R,et,W,eM,en]);return $.default.createElement(xJ.Provider,{value:M},$.default.createElement(vq.Provider,{value:ez},$.default.createElement(vV.Provider,{value:eO},$.default.createElement(vJ.Provider,{value:eT},b)),$.default.createElement(vX,{disabled:(null==_?void 0:_.restoreFocus)===!1})),$.default.createElement(x0,{..._,hiddenTextDescribedById:et}))}),vQ=(0,$.createContext)(null),v0="button",v1={timeout:25},v2={position:"fixed",touchAction:"none"},v5=e=>xU(e)?"transform 250ms ease":void 0;function v3(e,r,s){let i=e.slice();return i.splice(s<0?i.length+s:s,0,i.splice(r,1)[0]),i}function v4(e){return null!==e&&e>=0}(e,r)=>{let{as:s,activatorEvent:i,adjustScale:n,children:a,className:o,rect:l,style:c,transform:d,transition:u=v5}=e;if(!l)return null;let h=n?d:{...d,scaleX:1,scaleY:1},f={...v2,width:l.width,height:l.height,top:l.top,left:l.left,transform:xq.Transform.toString(h),transformOrigin:n&&i?function(e,r){let s=xK(e);if(!s)return"0 0";let i={x:(s.x-r.left)/r.width*100,y:(s.y-r.top)/r.height*100};return i.x+"% "+i.y+"%"}(i,l):void 0,transition:"function"==typeof u?u(i):u,...c};return $.default.createElement(s,{className:o,style:f,ref:r},a)},x={styles:{active:{opacity:"0"}}};let v6=e=>{let{rects:r,activeIndex:s,overIndex:i,index:n}=e,a=v3(r,i,s),o=r[n],l=a[n];return l&&o?{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}:null},v8={scaleX:1,scaleY:1},v7=e=>{var r,s,i,n;let a,o,l,{activeIndex:c,activeNodeRect:d,index:u,rects:h,overIndex:f}=e,p=null!=(r=h[c])?r:d;if(!p)return null;if(u===c){let e=h[f];return e?{x:0,y:c<f?e.top+e.height-(p.top+p.height):e.top-p.top,...v8}:null}let m=(s=h,i=u,n=c,a=s[i],o=s[i-1],l=s[i+1],a?n<i?o?a.top-(o.top+o.height):l?l.top-(a.top+a.height):0:l?l.top-(a.top+a.height):o?a.top-(o.top+o.height):0:0);return u>c&&u<=f?{x:0,y:-p.height-m,...v8}:u<c&&u>=f?{x:0,y:p.height+m,...v8}:{x:0,y:0,...v8}},v9="Sortable",_e=$.default.createContext({activeIndex:-1,containerId:v9,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:v6,disabled:{draggable:!1,droppable:!1}});function _t(e){let{children:r,id:s,items:i,strategy:n=v6,disabled:a=!1}=e,{active:o,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:u}=(0,$.useContext)(vV),h=xz(v9,s),f=null!==l.rect,p=(0,$.useMemo)(()=>i.map(e=>"object"==typeof e&&"id"in e?e.id:e),[i]),m=null!=o,g=o?p.indexOf(o.id):-1,x=d?p.indexOf(d.id):-1,v=(0,$.useRef)(p),_=!function(e,r){if(e===r)return!0;if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==r[s])return!1;return!0}(p,v.current),y=-1!==x&&-1===g||_,b="boolean"==typeof a?{draggable:a,droppable:a}:a;xF(()=>{_&&m&&u(p)},[_,p,m,u]),(0,$.useEffect)(()=>{v.current=p},[p]);let w=(0,$.useMemo)(()=>({activeIndex:g,containerId:h,disabled:b,disableTransforms:y,items:p,overIndex:x,useDragOverlay:f,sortedRects:p.reduce((e,r,s)=>{let i=c.get(r);return i&&(e[s]=i),e},Array(p.length)),strategy:n}),[g,h,b.draggable,b.droppable,y,p,x,c,f,n]);return $.default.createElement(_e.Provider,{value:w},r)}let _r=e=>{let{id:r,items:s,activeIndex:i,overIndex:n}=e;return v3(s,i,n).indexOf(r)},_s=e=>{let{containerId:r,isSorting:s,wasDragging:i,index:n,items:a,newIndex:o,previousItems:l,previousContainerId:c,transition:d}=e;return!!d&&!!i&&(l===a||n!==o)&&(!!s||o!==n&&r===c)},_i={duration:200,easing:"ease"},_n="transform",_a=xq.Transition.toString({property:_n,duration:0,easing:"linear"}),_o={roleDescription:"sortable"};function _l(e){if(!e)return!1;let r=e.data.current;return!!r&&"sortable"in r&&"object"==typeof r.sortable&&"containerId"in r.sortable&&"items"in r.sortable&&"index"in r.sortable}let _c=[A.Down,A.Right,A.Up,A.Left],_d=(e,r)=>{let{context:{active:s,collisionRect:i,droppableRects:n,droppableContainers:a,over:o,scrollableAncestors:l}}=r;if(_c.includes(e.code)){if(e.preventDefault(),!s||!i)return;let r=[];a.getEnabled().forEach(s=>{if(!s||null!=s&&s.disabled)return;let a=n.get(s.id);if(a)switch(e.code){case A.Down:i.top<a.top&&r.push(s);break;case A.Up:i.top>a.top&&r.push(s);break;case A.Left:i.left>a.left&&r.push(s);break;case A.Right:i.left<a.left&&r.push(s)}});let u=(e=>{let{collisionRect:r,droppableRects:s,droppableContainers:i}=e,n=x8(r),a=[];for(let e of i){let{id:r}=e,i=s.get(r);if(i){let s=x8(i),o=Number((n.reduce((e,r,i)=>e+x3(s[i],r),0)/4).toFixed(4));a.push({id:r,data:{droppableContainer:e,value:o}})}}return a.sort(x4)})({active:s,collisionRect:i,droppableRects:n,droppableContainers:r,pointerCoordinates:null}),h=x7(u,"id");if(h===(null==o?void 0:o.id)&&u.length>1&&(h=u[1].id),null!=h){let e=a.get(s.id),r=a.get(h),o=r?n.get(r.id):null,u=null==r?void 0:r.node.current;if(u&&o&&e&&r){var c,d;let s=va(u).some((e,r)=>l[r]!==e),n=_u(e,r),a=(c=e,d=r,!!_l(c)&&!!_l(d)&&!!_u(c,d)&&c.data.current.sortable.index<d.data.current.sortable.index),h=s||!n?{x:0,y:0}:{x:a?i.width-o.width:0,y:a?i.height-o.height:0},f={x:o.left,y:o.top};return h.x&&h.y?f:xH(f,h)}}}};function _u(e,r){return!!_l(e)&&!!_l(r)&&e.data.current.sortable.containerId===r.data.current.sortable.containerId}function _h({executor:e,executorMode:r,isOpen:s,onOpenChange:i,onStart:n,onStop:a,onUpdate:o,onDelete:l,onProcessFinished:c}){let d,u,h,f,p,m,g,[x,v]=(0,$.useState)(!1),[_,y]=(0,$.useState)(e.currentProcessId??e.lastProcessId),b=(0,$.useRef)(!1),w=(0,$.useRef)(e.currentProcessId),{attributes:S,listeners:C,setNodeRef:j,transform:k,transition:N,isDragging:D}=function(e){var r,s,i,n;let{animateLayoutChanges:a=_s,attributes:o,disabled:l,data:c,getNewIndex:d=_r,id:u,strategy:h,resizeObserverConfig:f,transition:p=_i}=e,{items:m,containerId:g,activeIndex:x,disabled:v,disableTransforms:_,sortedRects:y,overIndex:b,useDragOverlay:w,strategy:S}=(0,$.useContext)(_e),C=(r=l,s=v,"boolean"==typeof r?{draggable:r,droppable:!1}:{draggable:null!=(i=null==r?void 0:r.draggable)?i:s.draggable,droppable:null!=(n=null==r?void 0:r.droppable)?n:s.droppable}),j=m.indexOf(u),k=(0,$.useMemo)(()=>({sortable:{containerId:g,index:j,items:m},...c}),[g,c,j,m]),N=(0,$.useMemo)(()=>m.slice(m.indexOf(u)),[m,u]),{rect:D,node:R,isOver:A,setNodeRef:M}=function(e){let{data:r,disabled:s=!1,id:i,resizeObserverConfig:n}=e,a=xz("Droppable"),{active:o,dispatch:l,over:c,measureDroppableContainers:d}=(0,$.useContext)(vq),u=(0,$.useRef)({disabled:s}),h=(0,$.useRef)(!1),f=(0,$.useRef)(null),p=(0,$.useRef)(null),{disabled:m,updateMeasurementsFor:g,timeout:x}={...v1,...n},v=xP(null!=g?g:i),_=vF({callback:(0,$.useCallback)(()=>{if(!h.current){h.current=!0;return}null!=p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{d(Array.isArray(v.current)?v.current:[v.current]),p.current=null},x)},[x]),disabled:m||!o}),[y,b]=xL((0,$.useCallback)((e,r)=>{_&&(r&&(_.unobserve(r),h.current=!1),e&&_.observe(e))},[_])),w=xP(r);return(0,$.useEffect)(()=>{_&&y.current&&(_.disconnect(),h.current=!1,_.observe(y.current))},[y,_]),(0,$.useEffect)(()=>(l({type:E.RegisterDroppable,element:{id:i,key:a,disabled:s,node:y,rect:f,data:w}}),()=>l({type:E.UnregisterDroppable,key:a,id:i})),[i]),(0,$.useEffect)(()=>{s!==u.current.disabled&&(l({type:E.SetDroppableDisabled,id:i,key:a,disabled:s}),u.current.disabled=s)},[i,a,s,l]),{active:o,rect:f,isOver:(null==c?void 0:c.id)===i,node:y,over:c,setNodeRef:b}}({id:u,data:k,disabled:C.droppable,resizeObserverConfig:{updateMeasurementsFor:N,...f}}),{active:F,activatorEvent:T,activeNodeRect:P,attributes:B,setNodeRef:L,listeners:I,isDragging:O,over:z,setActivatorNodeRef:W,transform:H}=function(e){let{id:r,data:s,disabled:i=!1,attributes:n}=e,a=xz("Draggable"),{activators:o,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:h,over:f}=(0,$.useContext)(vq),{role:p=v0,roleDescription:m="draggable",tabIndex:g=0}=null!=n?n:{},x=(null==c?void 0:c.id)===r,v=(0,$.useContext)(x?vJ:vQ),[_,y]=xL(),[b,w]=xL(),S=(0,$.useMemo)(()=>o.reduce((e,s)=>{let{eventName:i,handler:n}=s;return e[i]=e=>{n(e,r)},e},{}),[o,r]),C=xP(s);return xF(()=>(h.set(r,{id:r,key:a,node:_,activatorNode:b,data:C}),()=>{let e=h.get(r);e&&e.key===a&&h.delete(r)}),[h,r]),{active:c,activatorEvent:l,activeNodeRect:d,attributes:(0,$.useMemo)(()=>({role:p,tabIndex:g,"aria-disabled":i,"aria-pressed":!!x&&p===v0||void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[i,p,g,x,m,u.draggable]),isDragging:x,listeners:i?void 0:S,node:_,over:f,setNodeRef:y,setActivatorNodeRef:w,transform:v}}({id:u,data:k,attributes:{..._o,...o},disabled:C.draggable}),U=function(){for(var e=arguments.length,r=Array(e),s=0;s<e;s++)r[s]=arguments[s];return(0,$.useMemo)(()=>e=>{r.forEach(r=>r(e))},r)}(M,L),K=!!F,q=K&&!_&&v4(x)&&v4(b),V=!w&&O,Y=V&&q?H:null,G=q?null!=Y?Y:(null!=h?h:S)({rects:y,activeNodeRect:P,activeIndex:x,overIndex:b,index:j}):null,X=v4(x)&&v4(b)?d({id:u,items:m,activeIndex:x,overIndex:b}):j,J=null==F?void 0:F.id,Z=(0,$.useRef)({activeId:J,items:m,newIndex:X,containerId:g}),Q=m!==Z.current.items,ee=a({active:F,containerId:g,isDragging:O,isSorting:K,id:u,index:j,items:m,newIndex:Z.current.newIndex,previousItems:Z.current.items,previousContainerId:Z.current.containerId,transition:p,wasDragging:null!=Z.current.activeId}),et=function(e){let{disabled:r,index:s,node:i,rect:n}=e,[a,o]=(0,$.useState)(null),l=(0,$.useRef)(s);return xF(()=>{if(!r&&s!==l.current&&i.current){let e=n.current;if(e){let r=vi(i.current,{ignoreTransform:!0}),s={x:e.left-r.left,y:e.top-r.top,scaleX:e.width/r.width,scaleY:e.height/r.height};(s.x||s.y)&&o(s)}}s!==l.current&&(l.current=s)},[r,s,i,n]),(0,$.useEffect)(()=>{a&&o(null)},[a]),a}({disabled:!ee,index:j,node:R,rect:D});return(0,$.useEffect)(()=>{K&&Z.current.newIndex!==X&&(Z.current.newIndex=X),g!==Z.current.containerId&&(Z.current.containerId=g),m!==Z.current.items&&(Z.current.items=m)},[K,X,g,m]),(0,$.useEffect)(()=>{if(J===Z.current.activeId)return;if(null!=J&&null==Z.current.activeId){Z.current.activeId=J;return}let e=setTimeout(()=>{Z.current.activeId=J},50);return()=>clearTimeout(e)},[J]),{active:F,activeIndex:x,attributes:B,data:k,rect:D,index:j,newIndex:X,items:m,isOver:A,isSorting:K,isDragging:O,listeners:I,node:R,overIndex:b,over:z,setNodeRef:U,setActivatorNodeRef:W,setDroppableNodeRef:M,setDraggableNodeRef:L,transform:null!=et?et:G,transition:et||Q&&Z.current.newIndex===j?_a:(!V||xU(T))&&p&&(K||ee)?xq.Transition.toString({...p,property:_n}):void 0}}({id:e.id}),R={transform:xq.Translate.toString(k),transition:N,zIndex:D?50:void 0,position:D?"relative":void 0,opacity:D?1:void 0},{logs:A,status:M,exitCode:F,isPty:T,replayingHistory:P,sendInput:B,sendResize:L}=(d=function(){let e=(0,$.useContext)(xS);if(!e)throw Error("useExecutorLogsStore must be used within ExecutorLogsProvider");return e}(),u=(0,$.useCallback)(e=>{if(!_)return()=>{};d.subscribeProcess(_);let r=d.onProcessChange(_,e);return()=>{r(),d.unsubscribeProcess(_)}},[_,r,d]),h=(0,$.useCallback)(()=>_?d.getProcessState(_):null,[_,d]),f=(0,$.useSyncExternalStore)(u,h,h),p=(0,$.useCallback)(()=>{},[]),m=(0,$.useCallback)(e=>{_&&d.sendInput(_,e)},[_,d]),g=(0,$.useCallback)((e,r)=>{_&&d.sendResize(_,e,r)},[_,d]),{logs:f?.logs??[],status:f?.status??"closed",exitCode:f?.exitCode??null,isPty:f?.isPty??!1,replayingHistory:f?.replayingHistory??!0,clearLogs:p,sendInput:m,sendResize:g});(0,$.useEffect)(()=>(console.log("[diag:mux] ExecutorItem MOUNT",e.id,"localProcessId=",_),()=>console.log("[diag:mux] ExecutorItem UNMOUNT",e.id)),[]),(0,$.useEffect)(()=>{console.log("[diag:mux] localProcessId →",_,"executor=",e.id)},[_,e.id]),(0,$.useEffect)(()=>{let r=w.current;w.current=e.currentProcessId,e.currentProcessId&&e.currentProcessId!==r&&(y(e.currentProcessId),b.current=!1,i(!0))},[e.currentProcessId,i]),(0,$.useEffect)(()=>{e.currentProcessId||e.lastProcessId&&y(r=>r??e.lastProcessId)},[e.currentProcessId,e.lastProcessId]),(0,$.useEffect)(()=>{"closed"!==M||null===F||b.current||(b.current=!0,console.log(`[diag:remote-stop] ${new Date().toISOString()} executor-item marking finished executorId=${e.id} processId=${_} exitCode=${F} — removing from runningProcesses (button → Start)`),c(_))},[M,F,_,c]);let I=async()=>{console.log(`[ExecutorItem] Starting executor ${e.id}`),b.current=!1;let r=await n();console.log(`[ExecutorItem] Got processId: ${r}`),r&&(y(r),i(!0))},O=async()=>{await a(_||void 0)},H=e.isRunning,U=e.isDisabled,K=e.lastStartedAt?new Date(e.lastStartedAt).toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"}):null;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(uE,{open:s,onOpenChange:i,children:(0,z.jsxs)("div",{ref:j,style:R,className:(0,ey.cn)("border rounded-lg",D&&"shadow-lg bg-background"),children:[(0,z.jsx)(uD,{asChild:!0,children:(0,z.jsxs)("div",{className:"group flex items-center justify-between p-3 cursor-pointer hover:bg-muted/50",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...S,...C,onClick:e=>e.stopPropagation(),children:(0,z.jsx)(uF,{className:"h-4 w-4"})}),s?(0,z.jsx)(sw,{className:"h-4 w-4"}):(0,z.jsx)(af,{className:"h-4 w-4"}),(0,z.jsx)("span",{className:(0,ey.cn)("font-medium",U&&"text-muted-foreground line-through"),children:e.name}),U?(0,z.jsxs)(sb,{variant:"outline",className:"text-muted-foreground border-muted-foreground/40 gap-1",children:[(0,z.jsx)(uT,{className:"h-3 w-3"}),"Disabled"]}):(0,z.jsx)(sb,{variant:H?"default":"secondary",className:(0,ey.cn)(H&&"bg-green-600 hover:bg-green-600"),children:H?"Running":null!==F?0===F?"Completed":"Failed":"Stopped"})]}),(0,z.jsxs)("div",{className:"flex items-center gap-2",onClick:e=>e.stopPropagation(),children:[K&&(0,z.jsxs)("span",{className:"text-xs text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",title:new Date(e.lastStartedAt).toLocaleString(),children:["Last run: ",K]}),H?(0,z.jsxs)(W.Button,{size:"sm",variant:"destructive",onClick:O,className:"w-20 border border-destructive",children:[(0,z.jsx)(uA,{className:"h-3 w-3 mr-1"}),"Stop"]}):(0,z.jsxs)(W.Button,{size:"sm",onClick:I,disabled:U,title:U?"Executor is disabled":void 0,className:"w-20",children:[(0,z.jsx)(rh,{className:"h-3 w-3 mr-1"}),"Start"]}),(0,z.jsxs)(ap,{children:[(0,z.jsx)(am,{asChild:!0,children:(0,z.jsx)(W.Button,{size:"icon",variant:"ghost",className:"h-8 w-8",children:(0,z.jsx)(uM,{className:"h-4 w-4"})})}),(0,z.jsxs)(ag,{align:"end",children:[(0,z.jsxs)(ax,{onClick:()=>v(!0),children:[(0,z.jsx)(rg,{className:"h-4 w-4 mr-2"}),"Edit"]}),(0,z.jsx)(ax,{onClick:()=>o({target:r??"local",disabled:!U}),children:U?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(rC,{className:"h-4 w-4 mr-2"}),"Enable"]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(uT,{className:"h-4 w-4 mr-2"}),"Disable"]})}),(0,z.jsxs)(ax,{onClick:l,className:"text-destructive",children:[(0,z.jsx)(rc,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})]})}),(0,z.jsx)(uR,{children:(0,z.jsxs)("div",{className:"px-3 pb-3",children:[(0,z.jsx)("div",{className:"text-xs text-muted-foreground mb-2 font-mono",children:"prompt"===e.executor_type?`${e.prompt_provider??"claude"} → ${e.command}`:`$ ${e.command}`}),(0,z.jsx)(xv,{logs:A,isPty:T,onInput:B,onResize:L,muteInput:P,processId:_,executorId:e.id,target:r??"local",status:M,exitCode:F})]})})]})}),(0,z.jsx)(xb,{open:x,onOpenChange:v,executor:e,onSubmit:async e=>{await o(e)}})]})}let _f=(0,$.createContext)(null);function _p({projectId:e,children:r}){let s=sc(e,{withStatus:!0});return(0,z.jsx)(_f.Provider,{value:s,children:r})}function _m(){let e=(0,$.useContext)(_f);if(!e)throw Error("useProjectRemotesContext must be used within a ProjectRemotesProvider");return e}let _g=e=>{let{droppableContainers:r,pointerCoordinates:s}=e;if(!s)return(e=>{let{collisionRect:r,droppableRects:s,droppableContainers:i}=e,n=x9(r,r.left,r.top),a=[];for(let e of i){let{id:r}=e,i=s.get(r);if(i){let s=x3(x9(i),n);a.push({id:r,data:{droppableContainer:e,value:s}})}}return a.sort(x4)})(e);let i=[];for(let e of r){let r=e.rect.current;if(!r)continue;let n=r.top,a=r.top+52;s.x>=r.left&&s.x<=r.right&&s.y>=n&&s.y<=a&&i.push({id:e.id,data:{droppableContainer:e}})}if(i.length>0)return i;let n=null;for(let e of r){let r=e.rect.current;if(!r)continue;let i=r.top+26,a=r.left+r.width/2,o=Math.sqrt(Math.pow(s.x-a,2)+Math.pow(s.y-i,2));(!n||o<n.distance)&&(n={id:e.id,distance:o,data:{droppableContainer:e}})}return n?[{id:n.id,data:n.data}]:[]};function _x({projectId:e,selectedBranch:r,project:s,onExecutorModeChange:i}){let[n,a]=(0,$.useState)(!1),[o,l]=(0,$.useState)(new Set),{remotes:c}=_m(),d=[];for(let e of(s?.path&&d.push({id:"local",label:"Local",icon:aD}),c))d.push({id:e.remote_server_id,label:e.server_name,icon:sd(e)});let{activeGroup:u,loading:h,createGroup:f}=function(e,r){let[s,i]=(0,$.useState)([]),[n,a]=(0,$.useState)(null),[o,l]=(0,$.useState)(!0),c=r??"",d=(0,$.useCallback)(async()=>{if(!e){i([]),a(null),l(!1);return}try{let[r,s]=await Promise.all([rv.api.getExecutorGroups(e),rv.api.getExecutorGroupByBranch(e,c)]);i(r),a(s)}catch(e){console.error("Failed to fetch executor groups:",e)}finally{l(!1)}},[e,c]);(0,$.useEffect)(()=>{l(!0),d()},[d]);let u=(0,$.useCallback)(async r=>{if(!e)return null;try{let s=await rv.api.createExecutorGroup(e,{name:r,branch:c});return i(e=>[...e,s]),a(s),s}catch(e){return console.error("Failed to create executor group:",e),null}},[e,c]);return{groups:s,activeGroup:n,loading:o,createGroup:u,updateGroup:(0,$.useCallback)(async(e,r)=>{try{let s=await rv.api.updateExecutorGroup(e,r);return i(r=>r.map(r=>r.id===e?s:r)),a(r=>r?.id===e?s:r),s}catch(e){return console.error("Failed to update executor group:",e),null}},[]),deleteGroup:(0,$.useCallback)(async e=>{try{await rv.api.deleteExecutorGroup(e),i(r=>r.filter(r=>r.id!==e)),a(r=>r?.id===e?null:r)}catch(e){console.error("Failed to delete executor group:",e)}},[]),refetch:d}}(e,r),{executors:p,loading:m,createExecutor:g,updateExecutor:x,deleteExecutor:v,startExecutor:_,stopExecutor:y,markProcessFinished:b,reorderExecutors:w}=function(e,r,s){let[i,n]=(0,$.useState)([]),[a,o]=(0,$.useState)(new Map),[l,c]=(0,$.useState)(new Map),[d,u]=(0,$.useState)(!0),h=(0,$.useCallback)(async()=>{if(!e||!r){n([]),u(!1);return}try{let s=await rv.api.getExecutors(e,r);n(s)}catch(e){console.error("Failed to fetch executors:",e)}finally{u(!1)}},[e,r]),f=(0,$.useCallback)(async()=>{try{let e=await rv.api.getRunningProcesses();console.log(`[useExecutors] fetchRunningProcesses: ${e.length} running`,e.map(e=>`${e.executor_id}/${e.id}/${e.target??"local"}`));let{runningProcesses:r,lastStartedProcess:s}=function(e){let r=new Map,s=new Map;for(let i of e){let e={processId:i.id,target:i.target??"local"},n=r.get(i.executor_id);n?n.push(e):r.set(i.executor_id,[e]),s.set(i.executor_id,e)}return{runningProcesses:r,lastStartedProcess:s}}(e);o(r),c(e=>{let i=function(e,r){let s=new Map;for(let[i,n]of e)r.get(i)?.some(e=>e.processId===n.processId&&e.target===n.target)&&s.set(i,n);return s}(e,r);for(let[e,r]of s)i.set(e,r);return i})}catch(e){console.error("Failed to fetch running processes:",e)}},[]);(0,$.useEffect)(()=>{h()},[h]),(0,$.useEffect)(()=>{f()},[f]),(0,$.useEffect)(()=>{e&&f()},[e,f]),(0,$.useEffect)(()=>{let e=()=>{"visible"===document.visibilityState&&f()};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[f]);let p=(0,$.useRef)(new Set);(0,$.useEffect)(()=>{p.current=new Set(i.map(e=>e.id))},[i]),(0,ok.useGlobalEventStream)(r=>{if(("executor:started"===r.type||"executor:stopped"===r.type)&&console.log(`[useExecutors] SSE received: ${r.type} executor=${r.executorId} process=${r.processId} target=${r.target??"local"} project=${r.projectId}`),!e||r.projectId!==e){("executor:started"===r.type||"executor:stopped"===r.type)&&console.log(`[useExecutors] SSE filtered: projectId mismatch (event=${r.projectId}, hook=${e})`);return}if(!p.current.has(r.executorId)){("executor:started"===r.type||"executor:stopped"===r.type)&&console.log(`[useExecutors] SSE filtered: executorId ${r.executorId} not in current group (known: ${Array.from(p.current).join(",")})`);return}"executor:started"===r.type?(console.log("[useExecutors] Processing executor:started, adding to runningProcesses"),o(e=>{let s=e.get(r.executorId)??[];if(s.some(e=>e.processId===r.processId))return e;let i=new Map(e);return i.set(r.executorId,[...s,{processId:r.processId,target:r.target??"local"}]),i}),c(e=>{let s=new Map(e);return s.set(r.executorId,{processId:r.processId,target:r.target??"local"}),s}),n(e=>e.map(e=>{if(e.id!==r.executorId)return e;let s=r.target??"local";return{...e,last_runs:{...e.last_runs??{},[s]:{started_at:new Date().toISOString(),process_id:r.processId}}}}))):"executor:stopped"===r.type&&(console.log("[useExecutors] Processing executor:stopped, removing from runningProcesses"),console.log(`[diag:remote-stop] ${new Date().toISOString()} SSE executor:stopped executor=${r.executorId} process=${r.processId} target=${r.target??"local"} — flips button via SSE (NOT the mux finished path)`),o(e=>{let s=e.get(r.executorId);if(!s)return e;let i=s.filter(e=>e.processId!==r.processId),n=new Map(e);return 0===i.length?n.delete(r.executorId):n.set(r.executorId,i),n}),c(e=>{let s=e.get(r.executorId);if(!s||s.processId!==r.processId)return e;let i=new Map(e);return i.delete(r.executorId),i}))});let m=(0,$.useCallback)(async s=>{if(!e||!r)return null;try{let i=await rv.api.createExecutor(e,{...s,group_id:r});return n(e=>[...e,i]),i}catch(e){return console.error("Failed to create executor:",e),null}},[e,r]),g=(0,$.useCallback)(async(e,r)=>{try{let s=await rv.api.updateExecutor(e,r);return n(r=>r.map(r=>r.id===e?s:r)),s}catch(e){return console.error("Failed to update executor:",e),xg.toast.error("Failed to update executor",{description:e instanceof Error?e.message:void 0}),null}},[]),x=(0,$.useCallback)(async e=>{try{await rv.api.deleteExecutor(e),n(r=>r.filter(r=>r.id!==e))}catch(e){console.error("Failed to delete executor:",e)}},[]),v=(0,$.useCallback)(async(e,r)=>{try{let i=await rv.api.startExecutor(e,r,s),a=s??"local";return o(r=>{let s=r.get(e)??[],n=new Map(r);return n.set(e,[...s,{processId:i,target:a}]),n}),c(r=>{let s=new Map(r);return s.set(e,{processId:i,target:a}),s}),n(r=>r.map(r=>r.id!==e?r:{...r,last_runs:{...r.last_runs??{},[a]:{started_at:new Date().toISOString(),process_id:i}}})),i}catch(e){return console.error("Failed to start executor:",e),null}},[s]),_=(0,$.useCallback)(async(e,r)=>{let i=a.get(e),n=i?.find(e=>e.target===(s??"local")),l=r||n?.processId;if(l){try{await rv.api.stopProcess(l)}catch(e){console.error("Failed to stop executor:",e)}o(r=>{let s=r.get(e);if(!s)return r;let i=s.filter(e=>e.processId!==l),n=new Map(r);return 0===i.length?n.delete(e):n.set(e,i),n}),c(r=>{let s=r.get(e);if(!s||s.processId!==l)return r;let i=new Map(r);return i.delete(e),i})}},[a,s]),y=(0,$.useCallback)((e,r)=>{o(s=>{let i=s.get(e);if(!i)return s;if(r){let n=i.filter(e=>e.processId!==r);if(n.length===i.length)return s;let a=new Map(s);return 0===n.length?a.delete(e):a.set(e,n),a}let n=new Map(s);return n.delete(e),n}),c(s=>{if(!r){if(!s.has(e))return s;let r=new Map(s);return r.delete(e),r}let i=s.get(e);if(!i||i.processId!==r)return s;let n=new Map(s);return n.delete(e),n})},[]),b=(0,$.useCallback)(async s=>{if(e&&r){n(s.map(e=>i.find(r=>r.id===e)).filter(e=>void 0!==e));try{await rv.api.reorderExecutors(e,s,r)}catch(e){console.error("Failed to reorder executors:",e),n(i)}}},[e,r,i]);return{executors:i.map(e=>{let r=a.get(e.id),i=s??"local",n=r?.find(e=>e.target===i),o=l.get(e.id),c=o?.target===i?o:void 0,d=e.last_runs?.[i];return{...e,currentProcessId:n?.processId??c?.processId??null,isRunning:!!n,lastProcessId:d?.process_id??null,lastStartedAt:d?.started_at??null,isDisabled:e.disabled_targets.includes(i)}}),loading:d,createExecutor:m,updateExecutor:g,deleteExecutor:x,startExecutor:v,stopExecutor:_,markProcessFinished:y,reorderExecutors:b,refetch:h}}(e,u?.id,s?.executor_mode),S=function(){for(var e=arguments.length,r=Array(e),s=0;s<e;s++)r[s]=arguments[s];return(0,$.useMemo)(()=>[...r].filter(e=>null!=e),[...r])}(x2(vD,{activationConstraint:{distance:8}}),x2(vC,{coordinateGetter:_d}));return e?(0,z.jsx)(xC,{projectId:e,children:(0,z.jsxs)("div",{className:"h-full flex flex-col",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border/60 h-10",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsxs)("h2",{className:"text-xs font-semibold flex items-center gap-2 text-foreground",children:[(0,z.jsx)(aN,{className:"h-3.5 w-3.5"}),u?u.name:"Executors"]}),d.length>1&&i&&(0,z.jsx)(ak,{targets:d,activeTarget:s?.executor_mode??"local",onTargetChange:i})]}),u&&(0,z.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>a(!0),children:[(0,z.jsx)(eS,{className:"h-3 w-3 mr-1"}),"Add"]})]}),(0,z.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,z.jsx)("div",{className:"p-4 space-y-3",children:h||m?(0,z.jsx)("div",{className:"text-center text-muted-foreground py-8",children:"Loading executors..."}):u?0===p.length?(0,z.jsxs)("div",{className:"text-center text-muted-foreground py-8",children:[(0,z.jsx)("p",{children:"No executors configured"}),(0,z.jsx)("p",{className:"text-sm mt-1",children:'Add an executor to run commands like "npm run dev"'})]}):(0,z.jsx)(vZ,{sensors:S,collisionDetection:_g,onDragEnd:e=>{let{active:r,over:s}=e;if(s&&r.id!==s.id){let e=p.findIndex(e=>e.id===r.id),i=p.findIndex(e=>e.id===s.id),n=[...p],[a]=n.splice(e,1);n.splice(i,0,a),w(n.map(e=>e.id))}},children:(0,z.jsx)(_t,{items:p.map(e=>e.id),strategy:v7,children:p.map(e=>(0,z.jsx)(_h,{executor:e,executorMode:s?.executor_mode??"local",isOpen:o.has(e.id),onOpenChange:r=>l(s=>{let i=new Set(s);return r?i.add(e.id):i.delete(e.id),i}),onStart:()=>_(e.id,r),onStop:r=>y(e.id,r||e.currentProcessId||void 0),onUpdate:r=>x(e.id,r),onDelete:()=>v(e.id),onProcessFinished:r=>b(e.id,r)},`${e.id}-${s?.executor_mode??"local"}`))})}):(0,z.jsxs)("div",{className:"text-center text-muted-foreground py-8",children:[(0,z.jsx)("p",{children:"No executor group for this branch"}),(0,z.jsx)("p",{className:"text-sm mt-1 mb-4",children:"Create a group to start adding executors"}),(0,z.jsxs)(W.Button,{size:"sm",onClick:()=>f(r?`Executors (${r})`:"Default"),children:[(0,z.jsx)(on,{className:"h-4 w-4 mr-1"}),"Create Group"]})]})})}),(0,z.jsx)(xb,{open:n,onOpenChange:a,onSubmit:async e=>{await g(e)}})]})},`${e??"none"}-${s?.executor_mode??"local"}`):(0,z.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,z.jsxs)("div",{className:"text-center",children:[(0,z.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,z.jsx)(aN,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,z.jsx)("p",{className:"text-sm",children:"Select a project to manage executors"})]})})}let _v=(0,ew.default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),__=(0,ew.default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);function _y({line:e}){let r="add"===e.type?"+":"delete"===e.type?"-":" ",s="add"===e.type,i="delete"===e.type,n=s?"bg-emerald-500/[0.07]":i?"bg-rose-500/[0.07]":"",a=s?"bg-emerald-500/[0.10]":i?"bg-rose-500/[0.10]":"bg-secondary",o=s?"text-emerald-600":i?"text-rose-600":"text-muted-foreground/70";return(0,z.jsxs)("div",{className:"flex font-mono text-[11.5px] leading-[1.55]",children:[(0,z.jsx)("span",{className:(0,ey.cn)("w-9 flex-shrink-0 text-right pr-2 select-none border-r border-border/60",a,o),children:e.oldLineNo??""}),(0,z.jsx)("span",{className:(0,ey.cn)("w-9 flex-shrink-0 text-right pr-2 select-none border-r border-border/60",a,o),children:e.newLineNo??""}),(0,z.jsx)("span",{className:(0,ey.cn)("w-5 flex-shrink-0 text-center select-none",n,o),children:r}),(0,z.jsx)("span",{className:(0,ey.cn)("whitespace-pre-wrap break-all pr-4 flex-1 min-w-0 pl-2",n,(s||i)&&"text-foreground"),children:e.content})]})}let _b={modified:"bg-yellow-500/20 text-yellow-500",added:"bg-green-500/20 text-green-500",deleted:"bg-red-500/20 text-red-500",renamed:"bg-blue-500/20 text-blue-500"},_w={modified:"Modified",added:"Added",deleted:"Deleted",renamed:"Renamed"};function _S({file:e,defaultOpen:r=!0}){let[s,i]=(0,$.useState)(r);return(0,z.jsxs)(uE,{open:s,onOpenChange:i,className:"border border-border rounded-lg overflow-hidden",children:[(0,z.jsxs)(uD,{className:"flex items-center gap-2 px-4 py-2 bg-secondary border-b border-border w-full cursor-pointer hover:bg-muted transition-colors",children:[s?(0,z.jsx)(sw,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,z.jsx)(af,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,z.jsx)("span",{className:"font-mono text-[11.5px] flex-1 min-w-0 truncate text-left text-foreground font-medium",children:e.oldPath&&"renamed"===e.status?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("span",{className:"text-muted-foreground font-normal",children:e.oldPath}),(0,z.jsx)("span",{className:"mx-2 text-muted-foreground",children:"→"}),e.path]}):e.path}),(0,z.jsx)(sb,{variant:"secondary",className:_b[e.status],children:_w[e.status]})]}),(0,z.jsx)(uR,{children:(0,z.jsx)("div",{children:e.hunks.map((e,r)=>(0,z.jsxs)("div",{children:[(0,z.jsxs)("div",{className:"px-4 py-0.5 bg-accent text-accent-foreground text-[11px] font-mono font-medium sticky top-0",children:["@@ -",e.oldStart,",",e.oldLines," +",e.newStart,",",e.newLines," @@"]}),e.lines.map((e,r)=>(0,z.jsx)(_y,{line:e},r))]},r))})})]})}let _C=(0,ew.default)("git-commit-horizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]),_j="__head__",_k="__compare__";function _N({commits:e,selectedCommit:r,onSelectCommit:s,compareTarget:i,compareSelected:n,onSelectCompare:a,loading:o,disabled:l}){return(0,z.jsxs)(cX,{value:n?_k:r??_j,onValueChange:e=>{e===_k?a?.():s(e===_j?null:e)},disabled:l||o,children:[(0,z.jsxs)(cZ,{size:"sm",className:"w-[200px]",children:[(0,z.jsx)(_C,{className:"h-3.5 w-3.5 shrink-0"}),(0,z.jsx)(cJ,{placeholder:"Select commit..."})]}),(0,z.jsxs)(cQ,{children:[(0,z.jsx)(c0,{value:_j,children:"HEAD (uncommitted)"}),i&&(0,z.jsxs)(c0,{value:_k,children:["vs ",(0,z.jsx)("span",{className:"font-mono text-xs",children:i})]}),e.map(e=>(0,z.jsxs)(c0,{value:e.hash,children:[(0,z.jsx)("span",{className:"font-mono text-xs",children:e.shortHash})," ",(0,z.jsx)("span",{className:"truncate",children:e.message.length>40?e.message.slice(0,40)+"...":e.message})]},e.hash))]})]})}function _E({projectId:e,selectedBranch:r,onMergeRequest:s,project:i,mergeTarget:n,compareRequestNonce:a}){let[o,l]=(0,$.useState)(null),[c,d]=(0,$.useState)(!1),[u,h]=(0,$.useState)(a),[f,p]=(0,$.useState)(r),m=void 0!==a&&a!==u;m&&(h(a),d(!0),l(null)),r!==f&&(p(r),l(null),m||d(!1));let{remotes:g}=_m(),x=[];for(let e of(i?.path&&x.push({id:"local",label:"Local",icon:aD}),g))x.push({id:e.remote_server_id,label:e.server_name,icon:so});let v=i?.path?"local":g.length>0?g[0].remote_server_id:"local",[_,y]=(0,$.useState)(v),[b,w]=(0,$.useState)(!0),[S,C]=(0,$.useState)(0),j="local"===_?i?.path?"local":void 0:"remote",{diff:k,loading:N,error:E,refresh:D}=function(e,r,s,i,n){let[a,o]=(0,$.useState)(null),[l,c]=(0,$.useState)(!1),[d,u]=(0,$.useState)(null),h=(0,$.useCallback)(async()=>{if(!e)return void o(null);c(!0),u(null);try{let a=await rv.api.getDiff(e,r,s,i,n);o(a)}catch(e){u(e instanceof Error?e.message:"Failed to load diff"),o(null)}finally{c(!1)}},[e,r,s,i,n]);return{diff:a,loading:l,error:d,refresh:h}}(e,r,o,j,c&&n?n:null),{commits:R,loading:A,refetch:M}=function(e,r,s,i){let[n,a]=(0,$.useState)([]),[o,l]=(0,$.useState)(!1);return{commits:n,loading:o,refetch:(0,$.useCallback)(async()=>{if(!e)return void a([]);l(!0);try{let n=await rv.api.getCommits(e,r,s,i);a(n)}catch{a([])}finally{l(!1)}},[e,r,s,i])}}(e,r,void 0,j);if((0,$.useEffect)(()=>{D()},[D]),(0,$.useEffect)(()=>{M()},[M]),(0,$.useEffect)(()=>{y(v)},[e,v]),!e)return(0,z.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,z.jsxs)("div",{className:"text-center",children:[(0,z.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,z.jsx)(rw,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,z.jsx)("p",{className:"text-sm",children:"Select a project to view changes"})]})});let F=k?.files.length??0;return(0,z.jsxs)("div",{className:"h-full flex flex-col",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border/60 h-10",children:[(0,z.jsx)("div",{className:"flex items-center gap-4",children:F>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)("span",{className:"text-xs text-muted-foreground",children:[F," file",1!==F?"s":""," changed"]}),(0,z.jsxs)(W.Button,{size:"sm",variant:"ghost",onClick:()=>{w(e=>!e),C(e=>e+1)},title:b?"Collapse all":"Expand all",children:[(0,z.jsx)(__,{className:"h-4 w-4 mr-1"}),b?"Collapse all":"Expand all"]})]})}),(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[x.length>1&&(0,z.jsx)(ak,{targets:x,activeTarget:_,onTargetChange:y,disabled:N}),(0,z.jsx)("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Commit:"}),(0,z.jsx)(_N,{commits:R,selectedCommit:o,onSelectCommit:e=>{d(!1),l(e)},compareTarget:n,compareSelected:c,onSelectCompare:()=>{d(!0),l(null)},loading:A,disabled:N}),(0,z.jsxs)(W.Button,{size:"sm",variant:"outline",onClick:s,disabled:N||0===F,children:[(0,z.jsx)(ld,{className:"h-4 w-4 mr-1"}),"Merge"]}),(0,z.jsxs)(W.Button,{size:"sm",variant:"outline",onClick:D,disabled:N,children:[(0,z.jsx)(_v,{className:`h-4 w-4 mr-1 ${N?"animate-spin":""}`}),"Refresh"]})]})]}),(0,z.jsx)(or,{className:"flex-1 overflow-hidden",children:(0,z.jsx)("div",{className:"p-4 space-y-4",children:N&&!k?(0,z.jsx)("div",{className:"text-center text-muted-foreground py-8",children:"Loading changes..."}):E?(0,z.jsx)("div",{className:"text-center text-red-400 py-8",children:E}):0===F?(0,z.jsx)("div",{className:"text-center text-muted-foreground py-8",children:(0,z.jsx)("p",{children:c&&n?`No changes vs ${n}`:o?"No changes in this commit":"No uncommitted changes"})}):k?.files.map((e,r)=>(0,z.jsx)(_S,{file:e,defaultOpen:b},`${r}-${S}`))})})]})}function _D({terminalId:e,onExit:r}){let{logs:s,sendInput:i,sendResize:n,exitCode:a,replayingHistory:o}=function(e,r){let[s,i]=(0,$.useState)([]),[n,a]=(0,$.useState)("closed"),[o,l]=(0,$.useState)(null),[c,d]=(0,$.useState)(!1),[u,h]=(0,$.useState)(!0),f=(0,$.useRef)(null),p=(0,$.useRef)(null),m=(0,$.useRef)(0),g=(0,$.useRef)(null),x=(0,$.useRef)(!1),v=(0,$.useCallback)(()=>{i([]),l(null),d(!1)},[]),_=(0,$.useCallback)(e=>{f.current?.readyState===WebSocket.OPEN&&f.current.send(JSON.stringify({type:"input",data:e}))},[]),y=(0,$.useCallback)((e,r)=>{f.current?.readyState===WebSocket.OPEN?f.current.send(JSON.stringify({type:"resize",cols:e,rows:r})):p.current={cols:e,rows:r}},[]);return(0,$.useEffect)(()=>{if(!e)return;i([]),l(null),d(!1),x.current=!1,m.current=0;let r=!1;return function s(){r||x.current||(0,rv.getFreshToken)().then(()=>{r||x.current||function(){if(r||x.current)return;a("connecting");let n=(0,rv.getWebSocketUrl)(`/api/executor-processes/${e}/logs`);console.log(`[useExecutorLogs] Connecting to WebSocket: ${n}`);let o=new WebSocket(n);f.current=o;let c=!1,u=!1;o.onopen=()=>{if(!r&&(console.log("[useExecutorLogs] WebSocket connected"),a("connected"),i([]),p.current)){let{cols:e,rows:r}=p.current;o.send(JSON.stringify({type:"resize",cols:e,rows:r})),p.current=null}},o.onmessage=e=>{if(!r)try{let r=JSON.parse(e.data);if("init"===r.type)d(r.isPty),h(!0),console.log("[useExecutorLogs] init received, setReplayingHistory(true)");else if("history_end"===r.type)u=!0,h(!1),console.log("[useExecutorLogs] history_end received, setReplayingHistory(false)");else if("finished"===r.type)x.current=!0,l(r.exitCode),a("closed");else if("error"===r.type)x.current=!0,a("error");else{u&&(c=!0,m.current=0);let e="stdout"===r.type||"stderr"===r.type||"pty"===r.type?{...r,historical:!u}:r;i(r=>[...r,e])}}catch(e){console.error("Failed to parse WebSocket message:",e)}},o.onerror=e=>{r||console.error("[useExecutorLogs] WebSocket error:",e)},o.onclose=e=>{if(console.log("[useExecutorLogs] WebSocket closed:",e.code,e.reason),f.current=null,x.current||r)return void a("closed");if(u&&!c){console.log(`[useExecutorLogs] Server closed after history with no live data — treating as terminal`),x.current=!0,a("closed");return}if(m.current<8){let e=m.current,i=Math.min(15e3,1e3*Math.pow(2,e)),n=i*Math.random()*.25,o=i+n;console.log(`[useExecutorLogs] Scheduling reconnect in ${Math.round(o)}ms (attempt ${e+1}/8)`),a("connecting"),m.current=e+1,g.current=setTimeout(()=>{g.current=null,r||s()},o)}else console.log("[useExecutorLogs] Max reconnect attempts reached"),a("error")}}()})}(),()=>{r=!0,g.current&&(clearTimeout(g.current),g.current=null),f.current&&(f.current.close(),f.current=null)}},[e,void 0]),{logs:s,status:n,exitCode:o,isPty:c,replayingHistory:u,clearLogs:v,sendInput:_,sendResize:y}}(e);return(0,$.useEffect)(()=>{null!==a&&r(e)},[a,r,e]),(0,z.jsx)(xv,{logs:s,isPty:!0,className:"h-full rounded-none border-0",onInput:i,onResize:n,muteInput:o})}function _R({projectId:e,selectedBranch:r,project:s}){let{terminals:i,activeTerminalId:n,createTerminal:a,closeTerminal:o,setActiveTerminal:l,removeTerminal:c}=function(e,r){let[s,i]=(0,$.useState)([]),[n,a]=(0,$.useState)(null);(0,$.useEffect)(()=>{if(!e){i([]),a(null);return}rv.api.getTerminals(e,r).then(e=>{i(e),a(e.length>0?e[0].id:null)})},[e,r]);let o=(0,$.useCallback)(async(s,n)=>{if(e)try{let o=await rv.api.createTerminal(e,r,s,n);i(e=>[...e,o]),a(o.id)}catch(e){console.error("[useTerminals] Failed to create terminal:",e)}},[e,r]),l=(0,$.useCallback)(async e=>{await rv.api.closeTerminal(e),i(r=>{let s=r.filter(r=>r.id!==e);return a(r=>r===e?s.length>0?s[s.length-1].id:null:r),s})},[]);return{terminals:s,activeTerminalId:n,createTerminal:o,closeTerminal:l,setActiveTerminal:(0,$.useCallback)(e=>{a(e)},[]),removeTerminal:(0,$.useCallback)(e=>{i(r=>{let s=r.filter(r=>r.id!==e);return a(r=>r===e?s.length>0?s[s.length-1].id:null:r),s})},[])}}(e,r),{remotes:d}=_m(),[u,h]=(0,$.useState)(!1),f=(0,$.useRef)(null),p=!!s?.path,m=d.length>0,g=p&&m||d.length>1,x=!p&&m||g&&s?.executor_mode!=="local"?"remote":"local",v=(0,$.useCallback)(()=>{a(x)},[a,x]),_=(0,$.useCallback)((e,r)=>{h(!1),a(e,r)},[a]);(0,$.useEffect)(()=>{if(u)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){f.current&&!f.current.contains(e.target)&&h(!1)}},[u]);let y=(0,$.useCallback)(e=>{c(e)},[c]);return e?(0,z.jsxs)("div",{className:"h-full flex flex-col",children:[(0,z.jsxs)("div",{className:"flex items-center h-10 border-b border-border/60 px-2 gap-1 shrink-0 bg-muted/20",children:[(0,z.jsx)("div",{className:"flex-1 min-w-0 flex items-center gap-1 overflow-hidden",children:i.map(e=>{let r="remote"===e.location||e.id.startsWith("remote-"),s=g?r?so:aD:aN,i=n===e.id;return(0,z.jsxs)("button",{onClick:()=>l(e.id),title:e.name,className:(0,ey.cn)("group flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all duration-150 border flex-1 min-w-0 basis-0 max-w-[180px]",i?"bg-background text-foreground border-border shadow-sm":"text-muted-foreground hover:text-foreground bg-muted/40 hover:bg-background/60 border-border/30 hover:border-border/60"),children:[(0,z.jsx)(s,{className:"h-3 w-3 shrink-0"}),(0,z.jsx)("span",{className:"truncate flex-1 text-left",children:e.name}),(0,z.jsx)("span",{role:"button",onClick:r=>{r.stopPropagation(),o(e.id)},className:(0,ey.cn)("shrink-0 rounded-sm p-0.5 hover:bg-destructive/10 hover:text-destructive",i?"opacity-80 hover:opacity-100":"opacity-0 group-hover:opacity-80 hover:!opacity-100"),children:(0,z.jsx)(t8,{className:"h-3 w-3"})})]},e.id)})}),(0,z.jsxs)("div",{className:"relative shrink-0",ref:f,children:[(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:g?()=>h(e=>!e):v,children:(0,z.jsx)(eS,{className:"h-3.5 w-3.5"})}),g&&u&&(0,z.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[160px] rounded-md border bg-popover p-1 shadow-md",children:[p&&(0,z.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>_("local"),children:[(0,z.jsx)(aD,{className:"h-3.5 w-3.5"}),"Local Terminal"]}),d.map(e=>(0,z.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>_("remote",e.remote_server_id),children:[(0,z.jsx)(so,{className:"h-3.5 w-3.5"}),e.server_name," Terminal"]},e.remote_server_id))]})]})]}),(0,z.jsx)("div",{className:"flex-1 overflow-hidden bg-zinc-950",children:n?(0,z.jsx)(_D,{terminalId:n,onExit:y},n):(0,z.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,z.jsx)(aN,{className:"h-10 w-10 text-muted-foreground/70"})})})]}):(0,z.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,z.jsxs)("div",{className:"text-center",children:[(0,z.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,z.jsx)(aN,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,z.jsx)("p",{className:"text-sm",children:"Select a project to use the terminal"})]})})}let _A=(0,ew.default)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),_M=(0,$.createContext)(null),_F=({className:e,children:r,defaultUrl:s="",onUrlChange:i,...n})=>{let[a,o]=(0,$.useState)(s),[l,c]=(0,$.useState)(!1);return(0,z.jsx)(_M.Provider,{value:{url:a,setUrl:e=>{o(e),i?.(e)},consoleOpen:l,setConsoleOpen:c},children:(0,z.jsx)("div",{className:(0,ey.cn)("flex size-full flex-col bg-card",e),...n,children:r})})},_T=({className:e,children:r,...s})=>(0,z.jsx)("div",{className:(0,ey.cn)("flex items-center gap-1 border-b p-2 h-14",e),...s,children:r}),_P=({onClick:e,disabled:r,tooltip:s,children:i,...n})=>(0,z.jsx)(ls,{children:(0,z.jsxs)(li,{children:[(0,z.jsx)(ln,{asChild:!0,children:(0,z.jsx)(W.Button,{className:"h-8 w-8 p-0 hover:text-foreground",disabled:r,onClick:e,size:"sm",variant:"ghost",...n,children:i})}),(0,z.jsx)(la,{children:(0,z.jsx)("p",{children:s})})]})}),_B=({value:e,onChange:r,onKeyDown:s,...i})=>{let{url:n,setUrl:a}=(()=>{let e=(0,$.useContext)(_M);if(!e)throw Error("WebPreview components must be used within a WebPreview");return e})(),[o,l]=(0,$.useState)(n);return(0,$.useEffect)(()=>{l(n)},[n]),(0,z.jsx)(ro,{className:"h-8 flex-1 text-sm",onChange:r??(e=>{l(e.target.value),r?.(e)}),onKeyDown:e=>{"Enter"===e.key&&a(e.target.value),s?.(e)},placeholder:"Enter URL...",value:e??o,...i})};var _L=e.i(254824);function _I({projectId:e}){let r=(0,$.useRef)(null),s=(0,$.useRef)(null),{addFrame:i,updateFrameUrl:n,refreshFrame:a,hasFrame:o,claimFrame:l,getFrameUrl:c}=(0,_L.useBrowserFrames)(),d=e?c(e):void 0;(0,$.useEffect)(()=>{if(e&&d&&r.current){let i=setTimeout(()=>{r.current&&(s.current?.(),s.current=l(e,r.current))},50);return()=>{clearTimeout(i),s.current?.(),s.current=null}}return()=>{s.current?.(),s.current=null}},[e,d,l]);let u=(0,$.useCallback)(()=>{e&&a(e)},[e,a]),h=(0,$.useCallback)(()=>{d&&window.open(d,"_blank")},[d]),f=(0,$.useCallback)(r=>{e&&(o(e)?n(e,r):i(e,r))},[e,o,n,i]);return(0,z.jsx)("div",{className:"h-full flex flex-col",children:(0,z.jsxs)(_F,{defaultUrl:d??"",onUrlChange:f,className:"h-full",children:[(0,z.jsxs)(_T,{className:"h-10 p-1.5 gap-0.5",children:[(0,z.jsx)(_P,{tooltip:"Refresh",onClick:u,disabled:!d,children:(0,z.jsx)(_v,{className:"h-3.5 w-3.5"})}),(0,z.jsx)(_P,{tooltip:"Open in browser",onClick:h,disabled:!d,children:(0,z.jsx)(_A,{className:"h-3.5 w-3.5"})}),(0,z.jsx)(_B,{className:"h-7 text-xs"})]}),d?(0,z.jsx)("div",{ref:r,className:"flex-1 bg-white"}):(0,z.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,z.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,z.jsx)(ry,{className:"h-8 w-8 opacity-40"}),(0,z.jsx)("p",{className:"text-sm",children:"Enter a URL above to preview"})]})})]})})}let _O=(0,ew.default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),_z=(0,ew.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),_$=(0,ew.default)("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]),_W=(0,ew.default)("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);var _H=e.i(553154);let _U=(0,ew.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),_K=(0,$.createContext)(null);_K.displayName="PanelGroupContext";let _q="data-panel-group-direction",_V="data-panel-group-id",_Y="data-resize-handle",_G="data-panel-resize-handle-id",_X=$.useLayoutEffect,_J=$["useId".toString()],_Z="function"==typeof _J?_J:()=>null,_Q=0;function _0(e=null){let r=_Z(),s=(0,$.useRef)(e||r||null);return null===s.current&&(s.current=""+_Q++),null!=e?e:s.current}function _1({children:e,className:r="",collapsedSize:s,collapsible:i,defaultSize:n,forwardedRef:a,id:o,maxSize:l,minSize:c,onCollapse:d,onExpand:u,onResize:h,order:f,style:p,tagName:m="div",...g}){let x=(0,$.useContext)(_K);if(null===x)throw Error("Panel components must be rendered within a PanelGroup container");let{collapsePanel:v,expandPanel:_,getPanelSize:y,getPanelStyle:b,groupId:w,isPanelCollapsed:S,reevaluatePanelConstraints:C,registerPanel:j,resizePanel:k,unregisterPanel:N}=x,E=_0(o),D=(0,$.useRef)({callbacks:{onCollapse:d,onExpand:u,onResize:h},constraints:{collapsedSize:s,collapsible:i,defaultSize:n,maxSize:l,minSize:c},id:E,idIsFromProps:void 0!==o,order:f});(0,$.useRef)({didLogMissingDefaultSizeWarning:!1}),_X(()=>{let{callbacks:e,constraints:r}=D.current,a={...r};D.current.id=E,D.current.idIsFromProps=void 0!==o,D.current.order=f,e.onCollapse=d,e.onExpand=u,e.onResize=h,r.collapsedSize=s,r.collapsible=i,r.defaultSize=n,r.maxSize=l,r.minSize=c,(a.collapsedSize!==r.collapsedSize||a.collapsible!==r.collapsible||a.maxSize!==r.maxSize||a.minSize!==r.minSize)&&C(D.current,a)}),_X(()=>{let e=D.current;return j(e),()=>{N(e)}},[f,E,j,N]),(0,$.useImperativeHandle)(a,()=>({collapse:()=>{v(D.current)},expand:e=>{_(D.current,e)},getId:()=>E,getSize:()=>y(D.current),isCollapsed:()=>S(D.current),isExpanded:()=>!S(D.current),resize:e=>{k(D.current,e)}}),[v,_,y,S,E,k]);let R=b(D.current,n);return(0,$.createElement)(m,{...g,children:e,className:r,id:E,style:{...R,...p},[_V]:w,"data-panel":"","data-panel-collapsible":i||void 0,"data-panel-id":E,"data-panel-size":parseFloat(""+R.flexGrow).toFixed(1)})}let _2=(0,$.forwardRef)((e,r)=>(0,$.createElement)(_1,{...e,forwardedRef:r}));_1.displayName="Panel",_2.displayName="forwardRef(Panel)";let _5=null,_3=-1,_4=null;function _6(e,s){var i,n,a;let o=function(e,r){if(r){let e=(r&ya)!=0,s=(r&yo)!=0,i=(r&yl)!=0,n=(r&yc)!=0;if(e)if(i)return"se-resize";else if(n)return"ne-resize";else return"e-resize";if(s)if(i)return"sw-resize";else if(n)return"nw-resize";else return"w-resize";if(i)return"s-resize";else if(n)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,s);_5!==o&&(_5=o,null===_4&&(_4=document.createElement("style"),r&&_4.setAttribute("nonce",r),document.head.appendChild(_4)),_3>=0&&(null==(a=_4.sheet)||a.removeRule(_3)),_3=null!=(i=null==(n=_4.sheet)?void 0:n.insertRule(`*{cursor: ${o} !important;}`))?i:-1)}function _8(e){return"keydown"===e.type}function _7(e){return e.type.startsWith("pointer")}function _9(e){return e.type.startsWith("mouse")}function ye(e){if(_7(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(_9(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}let yt=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function yr(e){let r=e.length;for(;r--;){let s=e[r];if(yj(s,"Missing node"),function(e){var r;let s,i=getComputedStyle(e);return"fixed"===i.position||!!("auto"!==i.zIndex&&("static"!==i.position||"flex"===(s=getComputedStyle(null!=(r=yn(e))?r:e).display)||"inline-flex"===s)||1>+i.opacity||"transform"in i&&"none"!==i.transform||"webkitTransform"in i&&"none"!==i.webkitTransform||"mixBlendMode"in i&&"normal"!==i.mixBlendMode||"filter"in i&&"none"!==i.filter||"webkitFilter"in i&&"none"!==i.webkitFilter||"isolation"in i&&"isolate"===i.isolation||yt.test(i.willChange))||"touch"===i.webkitOverflowScrolling}(s))return s}return null}function ys(e){return e&&Number(getComputedStyle(e).zIndex)||0}function yi(e){let r=[];for(;e;)r.push(e),e=yn(e);return r}function yn(e){let{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}let ya=1,yo=2,yl=4,yc=8,yd="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}(),yu=[],yh=!1,yf=new Map,yp=new Map,ym=new Set;function yg(e){let{target:r}=e,{x:s,y:i}=ye(e);yh=!0,yy({target:r,x:s,y:i}),yS(),yu.length>0&&(yC("down",e),e.preventDefault(),y_(r)||e.stopImmediatePropagation())}function yx(e){let{x:r,y:s}=ye(e);if(yh&&0===e.buttons&&(yh=!1,yC("up",e)),!yh){let{target:i}=e;yy({target:i,x:r,y:s})}yC("move",e),yb(),yu.length>0&&e.preventDefault()}function yv(e){let{target:r}=e,{x:s,y:i}=ye(e);yp.clear(),yh=!1,yu.length>0&&(e.preventDefault(),y_(r)||e.stopImmediatePropagation()),yC("up",e),yy({target:r,x:s,y:i}),yb(),yS()}function y_(e){let r=e;for(;r;){if(r.hasAttribute(_Y))return!0;r=r.parentElement}return!1}function yy({target:e,x:r,y:s}){yu.splice(0);let i=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(i=e),ym.forEach(e=>{let{element:n,hitAreaMargins:a}=e,o=n.getBoundingClientRect(),{bottom:l,left:c,right:d,top:u}=o,h=yd?a.coarse:a.fine;if(r>=c-h&&r<=d+h&&s>=u-h&&s<=l+h){if(null!==i&&document.contains(i)&&n!==i&&!n.contains(i)&&!i.contains(n)&&function(e,r){let s;if(e===r)throw Error("Cannot compare node with itself");let i={a:yi(e),b:yi(r)};for(;i.a.at(-1)===i.b.at(-1);)e=i.a.pop(),r=i.b.pop(),s=e;yj(s,"Stacking order can only be calculated for elements with a common ancestor");let n={a:ys(yr(i.a)),b:ys(yr(i.b))};if(n.a===n.b){let e=s.childNodes,r={a:i.a.at(-1),b:i.b.at(-1)},n=e.length;for(;n--;){let s=e[n];if(s===r.a)return 1;if(s===r.b)return -1}}return Math.sign(n.a-n.b)}(i,n)>0){let e=i,r=!1;for(;e;){var f;if(e.contains(n))break;if(f=e.getBoundingClientRect(),f.x<o.x+o.width&&f.x+f.width>o.x&&f.y<o.y+o.height&&f.y+f.height>o.y){r=!0;break}e=e.parentElement}if(r)return}yu.push(e)}})}function yb(){let e=!1,r=!1;yu.forEach(s=>{let{direction:i}=s;"horizontal"===i?e=!0:r=!0});let s=0;yp.forEach(e=>{s|=e}),e&&r?_6("intersection",s):e?_6("horizontal",s):r?_6("vertical",s):null!==_4&&(document.head.removeChild(_4),_5=null,_4=null,_3=-1)}let yw=new AbortController;function yS(){yw.abort();let e={capture:!0,signal:(yw=new AbortController).signal};ym.size&&(yh?(yu.length>0&&yf.forEach((r,s)=>{let{body:i}=s;r>0&&(i.addEventListener("contextmenu",yv,e),i.addEventListener("pointerleave",yx,e),i.addEventListener("pointermove",yx,e))}),window.addEventListener("pointerup",yv,e),window.addEventListener("pointercancel",yv,e)):yf.forEach((r,s)=>{let{body:i}=s;r>0&&(i.addEventListener("pointerdown",yg,e),i.addEventListener("pointermove",yx,e))}))}function yC(e,r){ym.forEach(s=>{let{setResizeHandlerState:i}=s;i(e,yu.includes(s),r)})}function yj(e,r){if(!e)throw console.error(r),Error(r)}function yk(e,r,s=10){return e.toFixed(s)===r.toFixed(s)?0:e>r?1:-1}function yN(e,r,s=10){return 0===yk(e,r,s)}function yE(e,r,s){return 0===yk(e,r,s)}function yD({panelConstraints:e,panelIndex:r,size:s}){let i=e[r];yj(null!=i,`Panel constraints not found for index ${r}`);let{collapsedSize:n=0,collapsible:a,maxSize:o=100,minSize:l=0}=i;return 0>yk(s,l)&&(s=a&&0>yk(s,(n+l)/2)?n:l),s=parseFloat((s=Math.min(o,s)).toFixed(10))}function yR({delta:e,initialLayout:r,panelConstraints:s,pivotIndices:i,prevLayout:n,trigger:a}){if(yE(e,0))return r;let o=[...r],[l,c]=i;yj(null!=l,"Invalid first pivot index"),yj(null!=c,"Invalid second pivot index");let d=0;if("keyboard"===a){{let i=e<0?c:l,n=s[i];yj(n,`Panel constraints not found for index ${i}`);let{collapsedSize:a=0,collapsible:o,minSize:d=0}=n;if(o){let s=r[i];if(yj(null!=s,`Previous layout not found for panel index ${i}`),yE(s,a)){let r=d-s;yk(r,Math.abs(e))>0&&(e=e<0?0-r:r)}}}{let i=e<0?l:c,n=s[i];yj(n,`No panel constraints found for index ${i}`);let{collapsedSize:a=0,collapsible:o,minSize:d=0}=n;if(o){let s=r[i];if(yj(null!=s,`Previous layout not found for panel index ${i}`),yE(s,d)){let r=s-a;yk(r,Math.abs(e))>0&&(e=e<0?0-r:r)}}}}{let i=e<0?1:-1,n=e<0?c:l,a=0;for(;;){let e=r[n];if(yj(null!=e,`Previous layout not found for panel index ${n}`),a+=yD({panelConstraints:s,panelIndex:n,size:100})-e,(n+=i)<0||n>=s.length)break}let o=Math.min(Math.abs(e),Math.abs(a));e=e<0?0-o:o}{let i=e<0?l:c;for(;i>=0&&i<s.length;){let n=Math.abs(e)-Math.abs(d),a=r[i];yj(null!=a,`Previous layout not found for panel index ${i}`);let l=yD({panelConstraints:s,panelIndex:i,size:a-n});if(!yE(a,l)&&(d+=a-l,o[i]=l,d.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?i--:i++}}if(function(e,r,s){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(!yE(e[s],r[s],void 0))return!1;return!0}(n,o))return n;{let i=e<0?c:l,n=r[i];yj(null!=n,`Previous layout not found for panel index ${i}`);let a=n+d,u=yD({panelConstraints:s,panelIndex:i,size:a});if(o[i]=u,!yE(u,a)){let r=a-u,i=e<0?c:l;for(;i>=0&&i<s.length;){let n=o[i];yj(null!=n,`Previous layout not found for panel index ${i}`);let a=yD({panelConstraints:s,panelIndex:i,size:n+r});if(yE(n,a)||(r-=a-n,o[i]=a),yE(r,0))break;e>0?i--:i++}}}return yE(o.reduce((e,r)=>r+e,0),100)?o:n}function yA(e,r=document){return Array.from(r.querySelectorAll(`[${_G}][data-panel-group-id="${e}"]`))}function yM(e,r,s=document){let i=yA(e,s).findIndex(e=>e.getAttribute(_G)===r);return null!=i?i:null}function yF(e,r,s){let i=yM(e,r,s);return null!=i?[i,i+1]:[-1,-1]}function yT(e,r=document){var s;if(r instanceof HTMLElement&&(null==r||null==(s=r.dataset)?void 0:s.panelGroupId)==e)return r;let i=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return i||null}function yP(e,r=document){let s=r.querySelector(`[${_G}="${e}"]`);return s||null}function yB(e,r){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==r[s])return!1;return!0}function yL(e,r){let{x:s,y:i}=ye(r);return"horizontal"===e?s:i}function yI(e,r,s){r.forEach((r,i)=>{let n=e[i];yj(n,`Panel data not found for index ${i}`);let{callbacks:a,constraints:o,id:l}=n,{collapsedSize:c=0,collapsible:d}=o,u=s[l];if(null==u||r!==u){s[l]=r;let{onCollapse:e,onExpand:i,onResize:n}=a;n&&n(r,u),d&&(e||i)&&(i&&(null==u||yN(u,c))&&!yN(r,c)&&i(),e&&(null==u||!yN(u,c))&&yN(r,c)&&e())}})}function yO(e,r){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!=r[s])return!1;return!0}function yz(e){try{if("undefined"!=typeof localStorage)e.getItem=e=>localStorage.getItem(e),e.setItem=(e,r)=>{localStorage.setItem(e,r)};else throw Error("localStorage not supported in this environment")}catch(r){console.error(r),e.getItem=()=>null,e.setItem=()=>{}}}function y$(e){return`react-resizable-panels:${e}`}function yW(e){return e.map(e=>{let{constraints:r,id:s,idIsFromProps:i,order:n}=e;return i?s:n?`${n}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((e,r)=>e.localeCompare(r)).join(",")}function yH(e,r){try{let s=y$(e),i=r.getItem(s);if(i){let e=JSON.parse(i);if("object"==typeof e&&null!=e)return e}}catch(e){}return null}function yU(e,r,s,i,n){var a;let o=y$(e),l=yW(r),c=null!=(a=yH(e,n))?a:{};c[l]={expandToSizes:Object.fromEntries(s.entries()),layout:i};try{n.setItem(o,JSON.stringify(c))}catch(e){console.error(e)}}function yK({layout:e,panelConstraints:r}){let s=[...e],i=s.reduce((e,r)=>e+r,0);if(s.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${s.map(e=>`${e}%`).join(", ")}`);if(!yE(i,100)&&s.length>0)for(let e=0;e<r.length;e++){let r=s[e];yj(null!=r,`No layout data found for index ${e}`);let n=100/i*r;s[e]=n}let n=0;for(let e=0;e<r.length;e++){let i=s[e];yj(null!=i,`No layout data found for index ${e}`);let a=yD({panelConstraints:r,panelIndex:e,size:i});i!=a&&(n+=i-a,s[e]=a)}if(!yE(n,0))for(let e=0;e<r.length;e++){let i=s[e];yj(null!=i,`No layout data found for index ${e}`);let a=yD({panelConstraints:r,panelIndex:e,size:i+n});if(i!==a&&(n-=a-i,s[e]=a,yE(n,0)))break}return s}let yq={getItem:e=>(yz(yq),yq.getItem(e)),setItem:(e,r)=>{yz(yq),yq.setItem(e,r)}},yV={};function yY({autoSaveId:e=null,children:r,className:s="",direction:i,forwardedRef:n,id:a=null,onLayout:o=null,keyboardResizeBy:l=null,storage:c=yq,style:d,tagName:u="div",...h}){let f=_0(a),p=(0,$.useRef)(null),[m,g]=(0,$.useState)(null),[x,v]=(0,$.useState)([]),_=function(){let[e,r]=(0,$.useState)(0);return(0,$.useCallback)(()=>r(e=>e+1),[])}(),y=(0,$.useRef)({}),b=(0,$.useRef)(new Map),w=(0,$.useRef)(0),S=(0,$.useRef)({autoSaveId:e,direction:i,dragState:m,id:f,keyboardResizeBy:l,onLayout:o,storage:c}),C=(0,$.useRef)({layout:x,panelDataArray:[],panelDataArrayChanged:!1});(0,$.useRef)({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),(0,$.useImperativeHandle)(n,()=>({getId:()=>S.current.id,getLayout:()=>{let{layout:e}=C.current;return e},setLayout:e=>{let{onLayout:r}=S.current,{layout:s,panelDataArray:i}=C.current,n=yK({layout:e,panelConstraints:i.map(e=>e.constraints)});yB(s,n)||(v(n),C.current.layout=n,r&&r(n),yI(i,n,y.current))}}),[]),_X(()=>{S.current.autoSaveId=e,S.current.direction=i,S.current.dragState=m,S.current.id=f,S.current.onLayout=o,S.current.storage=c}),function({committedValuesRef:e,eagerValuesRef:r,groupId:s,layout:i,panelDataArray:n,panelGroupElement:a,setLayout:o}){(0,$.useRef)({didWarnAboutMissingResizeHandle:!1}),_X(()=>{if(!a)return;let e=yA(s,a);for(let r=0;r<n.length-1;r++){let{valueMax:s,valueMin:a,valueNow:o}=function({layout:e,panelsArray:r,pivotIndices:s}){let i=0,n=100,a=0,o=0,l=s[0];return yj(null!=l,"No pivot index found"),r.forEach((e,r)=>{let{constraints:s}=e,{maxSize:c=100,minSize:d=0}=s;r===l?(i=d,n=c):(a+=d,o+=c)}),{valueMax:Math.min(n,100-a),valueMin:Math.max(i,100-o),valueNow:e[l]}}({layout:i,panelsArray:n,pivotIndices:[r,r+1]}),l=e[r];if(null==l);else{let e=n[r];yj(e,`No panel data found for index "${r}"`),l.setAttribute("aria-controls",e.id),l.setAttribute("aria-valuemax",""+Math.round(s)),l.setAttribute("aria-valuemin",""+Math.round(a)),l.setAttribute("aria-valuenow",null!=o?""+Math.round(o):"")}}return()=>{e.forEach((e,r)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")})}},[s,i,n,a]),(0,$.useEffect)(()=>{if(!a)return;let e=r.current;yj(e,"Eager values not found");let{panelDataArray:n}=e;yj(null!=yT(s,a),`No group found for id "${s}"`);let l=yA(s,a);yj(l,`No resize handles found for group id "${s}"`);let c=l.map(e=>{let r=e.getAttribute(_G);yj(r,"Resize handle element has no handle id attribute");let[l,c]=function(e,r,s,i=document){var n,a,o,l;let c=yP(r,i),d=yA(e,i),u=c?d.indexOf(c):-1;return[null!=(n=null==(a=s[u])?void 0:a.id)?n:null,null!=(o=null==(l=s[u+1])?void 0:l.id)?o:null]}(s,r,n,a);if(null==l||null==c)return()=>{};let d=e=>{if(!e.defaultPrevented&&"Enter"===e.key){e.preventDefault();let c=n.findIndex(e=>e.id===l);if(c>=0){let e=n[c];yj(e,`No panel data found for index ${c}`);let l=i[c],{collapsedSize:d=0,collapsible:u,minSize:h=0}=e.constraints;if(null!=l&&u){let e=yR({delta:yE(l,d)?h-d:d-l,initialLayout:i,panelConstraints:n.map(e=>e.constraints),pivotIndices:yF(s,r,a),prevLayout:i,trigger:"keyboard"});i!==e&&o(e)}}}};return e.addEventListener("keydown",d),()=>{e.removeEventListener("keydown",d)}});return()=>{c.forEach(e=>e())}},[a,e,r,s,i,n,o])}({committedValuesRef:S,eagerValuesRef:C,groupId:f,layout:x,panelDataArray:C.current.panelDataArray,setLayout:v,panelGroupElement:p.current}),(0,$.useEffect)(()=>{let{panelDataArray:r}=C.current;if(e){if(0===x.length||x.length!==r.length)return;let s=yV[e];null==s&&(s=function(e,r=10){let s=null;return(...i)=>{null!==s&&clearTimeout(s),s=setTimeout(()=>{e(...i)},r)}}(yU,100),yV[e]=s),s(e,[...r],new Map(b.current),x,c)}},[e,x,c]),(0,$.useEffect)(()=>{});let j=(0,$.useCallback)(e=>{let{onLayout:r}=S.current,{layout:s,panelDataArray:i}=C.current;if(e.constraints.collapsible){let n=i.map(e=>e.constraints),{collapsedSize:a=0,panelSize:o,pivotIndices:l}=yJ(i,e,s);if(yj(null!=o,`Panel size not found for panel "${e.id}"`),!yN(o,a)){b.current.set(e.id,o);let c=yR({delta:yX(i,e)===i.length-1?o-a:a-o,initialLayout:s,panelConstraints:n,pivotIndices:l,prevLayout:s,trigger:"imperative-api"});yO(s,c)||(v(c),C.current.layout=c,r&&r(c),yI(i,c,y.current))}}},[]),k=(0,$.useCallback)((e,r)=>{let{onLayout:s}=S.current,{layout:i,panelDataArray:n}=C.current;if(e.constraints.collapsible){let a=n.map(e=>e.constraints),{collapsedSize:o=0,panelSize:l=0,minSize:c=0,pivotIndices:d}=yJ(n,e,i),u=null!=r?r:c;if(yN(l,o)){let r=b.current.get(e.id),o=null!=r&&r>=u?r:u,c=yR({delta:yX(n,e)===n.length-1?l-o:o-l,initialLayout:i,panelConstraints:a,pivotIndices:d,prevLayout:i,trigger:"imperative-api"});yO(i,c)||(v(c),C.current.layout=c,s&&s(c),yI(n,c,y.current))}}},[]),N=(0,$.useCallback)(e=>{let{layout:r,panelDataArray:s}=C.current,{panelSize:i}=yJ(s,e,r);return yj(null!=i,`Panel size not found for panel "${e.id}"`),i},[]),E=(0,$.useCallback)((e,r)=>{let{panelDataArray:s}=C.current,i=yX(s,e);return function({defaultSize:e,dragState:r,layout:s,panelData:i,panelIndex:n,precision:a=3}){let o=s[n];return{flexBasis:0,flexGrow:null==o?void 0!=e?e.toPrecision(a):"1":1===i.length?"1":o.toPrecision(a),flexShrink:1,overflow:"hidden",pointerEvents:null!==r?"none":void 0}}({defaultSize:r,dragState:m,layout:x,panelData:s,panelIndex:i})},[m,x]),D=(0,$.useCallback)(e=>{let{layout:r,panelDataArray:s}=C.current,{collapsedSize:i=0,collapsible:n,panelSize:a}=yJ(s,e,r);return yj(null!=a,`Panel size not found for panel "${e.id}"`),!0===n&&yN(a,i)},[]),R=(0,$.useCallback)(e=>{let{layout:r,panelDataArray:s}=C.current,{collapsedSize:i=0,collapsible:n,panelSize:a}=yJ(s,e,r);return yj(null!=a,`Panel size not found for panel "${e.id}"`),!n||yk(a,i)>0},[]),A=(0,$.useCallback)(e=>{let{panelDataArray:r}=C.current;r.push(e),r.sort((e,r)=>{let s=e.order,i=r.order;return null==s&&null==i?0:null==s?-1:null==i?1:s-i}),C.current.panelDataArrayChanged=!0,_()},[_]);_X(()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;let{autoSaveId:s,onLayout:i,storage:n}=S.current,{layout:a,panelDataArray:o}=C.current,l=null;if(s){var e,r;let i=null!=(r=(null!=(e=yH(s,n))?e:{})[yW(o)])?r:null;i&&(b.current=new Map(Object.entries(i.expandToSizes)),l=i.layout)}null==l&&(l=function({panelDataArray:e}){let r=Array(e.length),s=e.map(e=>e.constraints),i=0,n=100;for(let a=0;a<e.length;a++){let e=s[a];yj(e,`Panel constraints not found for index ${a}`);let{defaultSize:o}=e;null!=o&&(i++,r[a]=o,n-=o)}for(let a=0;a<e.length;a++){let o=s[a];yj(o,`Panel constraints not found for index ${a}`);let{defaultSize:l}=o;if(null!=l)continue;let c=n/(e.length-i);i++,r[a]=c,n-=c}return r}({panelDataArray:o}));let c=yK({layout:l,panelConstraints:o.map(e=>e.constraints)});yB(a,c)||(v(c),C.current.layout=c,i&&i(c),yI(o,c,y.current))}}),_X(()=>{let e=C.current;return()=>{e.layout=[]}},[]);let M=(0,$.useCallback)(e=>{let r=!1,s=p.current;return s&&"rtl"===window.getComputedStyle(s,null).getPropertyValue("direction")&&(r=!0),function(s){var i,n;s.preventDefault();let a=p.current;if(!a)return()=>null;let{direction:o,dragState:l,id:c,keyboardResizeBy:d,onLayout:u}=S.current,{layout:h,panelDataArray:f}=C.current,{initialLayout:m}=null!=l?l:{},g=yF(c,e,a),x=function(e,r,s,i,n,a){if(_8(e)){let r="horizontal"===s,i=0;i=e.shiftKey?100:null!=n?n:10;let a=0;switch(e.key){case"ArrowDown":a=r?0:i;break;case"ArrowLeft":a=r?-i:0;break;case"ArrowRight":a=r?i:0;break;case"ArrowUp":a=r?0:-i;break;case"End":a=100;break;case"Home":a=-100}return a}return null==i?0:function(e,r,s,i,n){let a="horizontal"===s,o=yP(r,n);yj(o,`No resize handle element found for id "${r}"`);let l=o.getAttribute(_V);yj(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=i,d=yL(s,e),u=yT(l,n);yj(u,`No group element found for id "${l}"`);let h=u.getBoundingClientRect();return(d-c)/(a?h.width:h.height)*100}(e,r,s,i,a)}(s,e,o,l,d,a),_="horizontal"===o;_&&r&&(x=-x);let b=yR({delta:x,initialLayout:null!=m?m:h,panelConstraints:f.map(e=>e.constraints),pivotIndices:g,prevLayout:h,trigger:_8(s)?"keyboard":"mouse-or-touch"}),j=!yO(h,b);(_7(s)||_9(s))&&w.current!=x&&((w.current=x,j||0===x)?yp.set(e,0):_?(i=x<0?ya:yo,yp.set(e,i)):(n=x<0?yl:yc,yp.set(e,n))),j&&(v(b),C.current.layout=b,u&&u(b),yI(f,b,y.current))}},[]),F=(0,$.useCallback)((e,r)=>{let{onLayout:s}=S.current,{layout:i,panelDataArray:n}=C.current,a=n.map(e=>e.constraints),{panelSize:o,pivotIndices:l}=yJ(n,e,i);yj(null!=o,`Panel size not found for panel "${e.id}"`);let c=yR({delta:yX(n,e)===n.length-1?o-r:r-o,initialLayout:i,panelConstraints:a,pivotIndices:l,prevLayout:i,trigger:"imperative-api"});yO(i,c)||(v(c),C.current.layout=c,s&&s(c),yI(n,c,y.current))},[]),T=(0,$.useCallback)((e,r)=>{let{layout:s,panelDataArray:i}=C.current,{collapsedSize:n=0,collapsible:a}=r,{collapsedSize:o=0,collapsible:l,maxSize:c=100,minSize:d=0}=e.constraints,{panelSize:u}=yJ(i,e,s);null!=u&&(a&&l&&yN(u,n)?yN(n,o)||F(e,o):u<d?F(e,d):u>c&&F(e,c))},[F]),P=(0,$.useCallback)((e,r)=>{let{direction:s}=S.current,{layout:i}=C.current;if(!p.current)return;let n=yP(e,p.current);yj(n,`Drag handle element not found for id "${e}"`);let a=yL(s,r);g({dragHandleId:e,dragHandleRect:n.getBoundingClientRect(),initialCursorPosition:a,initialLayout:i})},[]),B=(0,$.useCallback)(()=>{g(null)},[]),L=(0,$.useCallback)(e=>{let{panelDataArray:r}=C.current,s=yX(r,e);s>=0&&(r.splice(s,1),delete y.current[e.id],C.current.panelDataArrayChanged=!0,_())},[_]),I=(0,$.useMemo)(()=>({collapsePanel:j,direction:i,dragState:m,expandPanel:k,getPanelSize:N,getPanelStyle:E,groupId:f,isPanelCollapsed:D,isPanelExpanded:R,reevaluatePanelConstraints:T,registerPanel:A,registerResizeHandle:M,resizePanel:F,startDragging:P,stopDragging:B,unregisterPanel:L,panelGroupElement:p.current}),[j,m,i,k,N,E,f,D,R,T,A,M,F,P,B,L]);return(0,$.createElement)(_K.Provider,{value:I},(0,$.createElement)(u,{...h,children:r,className:s,id:a,ref:p,style:{display:"flex",flexDirection:"horizontal"===i?"row":"column",height:"100%",overflow:"hidden",width:"100%",...d},"data-panel-group":"",[_q]:i,[_V]:f}))}let yG=(0,$.forwardRef)((e,r)=>(0,$.createElement)(yY,{...e,forwardedRef:r}));function yX(e,r){return e.findIndex(e=>e===r||e.id===r.id)}function yJ(e,r,s){let i=yX(e,r),n=i===e.length-1,a=s[i];return{...r.constraints,panelSize:a,pivotIndices:n?[i-1,i]:[i,i+1]}}function yZ({children:e=null,className:r="",disabled:s=!1,hitAreaMargins:i,id:n,onBlur:a,onClick:o,onDragging:l,onFocus:c,onPointerDown:d,onPointerUp:u,style:h={},tabIndex:f=0,tagName:p="div",...m}){var g,x;let v=(0,$.useRef)(null),_=(0,$.useRef)({onClick:o,onDragging:l,onPointerDown:d,onPointerUp:u});(0,$.useEffect)(()=>{_.current.onClick=o,_.current.onDragging=l,_.current.onPointerDown=d,_.current.onPointerUp=u});let y=(0,$.useContext)(_K);if(null===y)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");let{direction:b,groupId:w,registerResizeHandle:S,startDragging:C,stopDragging:j,panelGroupElement:k}=y,N=_0(n),[E,D]=(0,$.useState)("inactive"),[R,A]=(0,$.useState)(!1),[M,F]=(0,$.useState)(null),T=(0,$.useRef)({state:E});_X(()=>{T.current.state=E}),(0,$.useEffect)(()=>{if(s)F(null);else{let e=S(N);F(()=>e)}},[s,N,S]);let P=null!=(g=null==i?void 0:i.coarse)?g:15,B=null!=(x=null==i?void 0:i.fine)?x:5;return(0,$.useEffect)(()=>{if(s||null==M)return;let e=v.current;yj(e,"Element ref not attached");let r=!1;return function(e,r,s,i,n){var a;let{ownerDocument:o}=r,l={direction:s,element:r,hitAreaMargins:i,setResizeHandlerState:n},c=null!=(a=yf.get(o))?a:0;return yf.set(o,c+1),ym.add(l),yS(),function(){var r;yp.delete(e),ym.delete(l);let s=null!=(r=yf.get(o))?r:1;if(yf.set(o,s-1),yS(),1===s&&yf.delete(o),yu.includes(l)){let e=yu.indexOf(l);e>=0&&yu.splice(e,1),yb(),n("up",!0,null)}}}(N,e,b,{coarse:P,fine:B},(e,s,i)=>{if(!s)return void D("inactive");switch(e){case"down":{D("drag"),r=!1,yj(i,'Expected event to be defined for "down" action'),C(N,i);let{onDragging:e,onPointerDown:s}=_.current;null==e||e(!0),null==s||s();break}case"move":{let{state:e}=T.current;r=!0,"drag"!==e&&D("hover"),yj(i,'Expected event to be defined for "move" action'),M(i);break}case"up":{D("hover"),j();let{onClick:e,onDragging:s,onPointerUp:i}=_.current;null==s||s(!1),null==i||i(),r||null==e||e()}}})},[P,b,s,B,S,N,M,C,j]),!function({disabled:e,handleId:r,resizeHandler:s,panelGroupElement:i}){(0,$.useEffect)(()=>{if(e||null==s||null==i)return;let n=yP(r,i);if(null==n)return;let a=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),s(e);break;case"F6":{e.preventDefault();let s=n.getAttribute(_V);yj(s,`No group element found for id "${s}"`);let a=yA(s,i),o=yM(s,r,i);yj(null!==o,`No resize element found for id "${r}"`);let l=e.shiftKey?o>0?o-1:a.length-1:o+1<a.length?o+1:0;a[l].focus()}}};return n.addEventListener("keydown",a),()=>{n.removeEventListener("keydown",a)}},[i,e,r,s])}({disabled:s,handleId:N,resizeHandler:M,panelGroupElement:k}),(0,$.createElement)(p,{...m,children:e,className:r,id:n,onBlur:()=>{A(!1),null==a||a()},onFocus:()=>{A(!0),null==c||c()},ref:v,role:"separator",style:{touchAction:"none",userSelect:"none",...h},tabIndex:f,[_q]:b,[_V]:w,[_Y]:"","data-resize-handle-active":"drag"===E?"pointer":R?"keyboard":void 0,"data-panel-resize-handle-enabled":!s,[_G]:N,"data-resize-handle-state":E})}yY.displayName="PanelGroup",yG.displayName="forwardRef(PanelGroup)",yZ.displayName="PanelResizeHandle";let yQ=({className:e,...r})=>(0,z.jsx)(yG,{className:(0,ey.cn)("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r}),y0=({withHandle:e,className:r,...s})=>(0,z.jsx)(yZ,{className:(0,ey.cn)("relative flex w-px items-center justify-center bg-border/60 after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-[''] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:inset-x-0 data-[panel-group-direction=vertical]:after:-top-1 data-[panel-group-direction=vertical]:after:-bottom-1 data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:right-0 [&[data-resize-handle-active]]:bg-ring",r),...s,children:e&&(0,z.jsx)("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:(0,z.jsx)(uF,{className:"h-2.5 w-2.5"})})});function y1({className:e,...r}){return(0,z.jsx)("div",{"data-slot":"input-group",role:"group",className:(0,ey.cn)("group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none","h-9 min-w-0 has-[textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",e),...r})}let y2=(0,s_.cva)("text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]","block-start":"order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5","block-end":"order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function y5({className:e,align:r="inline-start",...s}){return(0,z.jsx)("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:(0,ey.cn)(y2({align:r}),e),onClick:e=>{e.target.closest("button")||e.currentTarget.parentElement?.querySelector("input")?.focus()},...s})}let y3=(0,s_.cva)("text-sm shadow-none flex gap-2 items-center",{variants:{size:{xs:"h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",sm:"h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function y4({className:e,type:r="button",variant:s="ghost",size:i="xs",...n}){return(0,z.jsx)(W.Button,{type:r,"data-size":i,variant:s,className:(0,ey.cn)(y3({size:i}),e),...n})}function y6({className:e,...r}){return(0,z.jsx)(ro,{"data-slot":"input-group-control",className:(0,ey.cn)("flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",e),...r})}function y8({className:e,...r}){return(0,z.jsx)(rl,{"data-slot":"input-group-control",className:(0,ey.cn)("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",e),...r})}var y7=/[\\\/_+.#"@\[\(\{&]/,y9=/[\\\/_+.#"@\[\(\{&]/g,be=/[\s-]/,bt=/[\s-]/g;function br(e){return e.toLowerCase().replace(bt," ")}var bs=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,r)=>{let s=sm(`Primitive.${r}`),i=$.forwardRef((e,i)=>{let{asChild:n,...a}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,z.jsx)(n?s:r,{...a,ref:i})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{}),bi='[cmdk-group=""]',bn='[cmdk-group-items=""]',ba='[cmdk-item=""]',bo=`${ba}:not([aria-disabled="true"])`,bl="cmdk-item-select",bc="data-value",bd=(e,r,s)=>{var i;return i=e,function e(r,s,i,n,a,o,l){if(o===s.length)return a===r.length?1:.99;var c=`${a},${o}`;if(void 0!==l[c])return l[c];for(var d,u,h,f,p=n.charAt(o),m=i.indexOf(p,a),g=0;m>=0;)(d=e(r,s,i,n,m+1,o+1,l))>g&&(m===a?d*=1:y7.test(r.charAt(m-1))?(d*=.8,(h=r.slice(a,m-1).match(y9))&&a>0&&(d*=Math.pow(.999,h.length))):be.test(r.charAt(m-1))?(d*=.9,(f=r.slice(a,m-1).match(bt))&&a>0&&(d*=Math.pow(.999,f.length))):(d*=.17,a>0&&(d*=Math.pow(.999,m-a))),r.charAt(m)!==s.charAt(o)&&(d*=.9999)),(d<.1&&i.charAt(m-1)===n.charAt(o+1)||n.charAt(o+1)===n.charAt(o)&&i.charAt(m-1)!==n.charAt(o))&&.1*(u=e(r,s,i,n,m+1,o+2,l))>d&&(d=.1*u),d>g&&(g=d),m=i.indexOf(p,m+1);return l[c]=g,g}(i=s&&s.length>0?`${i+" "+s.join(" ")}`:i,r,br(i),br(r),0,0,{})},bu=$.createContext(void 0),bh=$.createContext(void 0),bf=$.createContext(void 0),bp=$.forwardRef((e,r)=>{let s=bC(()=>{var r,s;return{search:"",value:null!=(s=null!=(r=e.value)?r:e.defaultValue)?s:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),i=bC(()=>new Set),n=bC(()=>new Map),a=bC(()=>new Map),o=bC(()=>new Set),l=bw(e),{label:c,children:d,value:u,onValueChange:h,filter:f,shouldFilter:p,loop:m,disablePointerSelection:g=!1,vimBindings:x=!0,...v}=e,_=ek(),y=ek(),b=ek(),w=$.useRef(null),S=bN();bS(()=>{if(void 0!==u){let e=u.trim();s.current.value=e,C.emit()}},[u]),bS(()=>{S(6,R)},[]);let C=$.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>s.current,setState:(e,r,i)=>{var n,a,o,c;if(!Object.is(s.current[e],r)){if(s.current[e]=r,"search"===e)D(),N(),S(1,E);else if("value"===e){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let e=document.getElementById(b);e?e.focus():null==(n=document.getElementById(_))||n.focus()}if(S(7,()=>{var e;s.current.selectedItemId=null==(e=A())?void 0:e.id,C.emit()}),i||S(5,R),(null==(a=l.current)?void 0:a.value)!==void 0){null==(c=(o=l.current).onValueChange)||c.call(o,null!=r?r:"");return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),j=$.useMemo(()=>({value:(e,r,i)=>{var n;r!==(null==(n=a.current.get(e))?void 0:n.value)&&(a.current.set(e,{value:r,keywords:i}),s.current.filtered.items.set(e,k(r,i)),S(2,()=>{N(),C.emit()}))},item:(e,r)=>(i.current.add(e),r&&(n.current.has(r)?n.current.get(r).add(e):n.current.set(r,new Set([e]))),S(3,()=>{D(),N(),s.current.value||E(),C.emit()}),()=>{a.current.delete(e),i.current.delete(e),s.current.filtered.items.delete(e);let r=A();S(4,()=>{D(),(null==r?void 0:r.getAttribute("id"))===e&&E(),C.emit()})}),group:e=>(n.current.has(e)||n.current.set(e,new Set),()=>{a.current.delete(e),n.current.delete(e)}),filter:()=>l.current.shouldFilter,label:c||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:_,inputId:b,labelId:y,listInnerRef:w}),[]);function k(e,r){var i,n;let a=null!=(n=null==(i=l.current)?void 0:i.filter)?n:bd;return e?a(e,s.current.search,r):0}function N(){if(!s.current.search||!1===l.current.shouldFilter)return;let e=s.current.filtered.items,r=[];s.current.filtered.groups.forEach(s=>{let i=n.current.get(s),a=0;i.forEach(r=>{a=Math.max(e.get(r),a)}),r.push([s,a])});let i=w.current;M().sort((r,s)=>{var i,n;let a=r.getAttribute("id"),o=s.getAttribute("id");return(null!=(i=e.get(o))?i:0)-(null!=(n=e.get(a))?n:0)}).forEach(e=>{let r=e.closest(bn);r?r.appendChild(e.parentElement===r?e:e.closest(`${bn} > *`)):i.appendChild(e.parentElement===i?e:e.closest(`${bn} > *`))}),r.sort((e,r)=>r[1]-e[1]).forEach(e=>{var r;let s=null==(r=w.current)?void 0:r.querySelector(`${bi}[${bc}="${encodeURIComponent(e[0])}"]`);null==s||s.parentElement.appendChild(s)})}function E(){let e=M().find(e=>"true"!==e.getAttribute("aria-disabled")),r=null==e?void 0:e.getAttribute(bc);C.setState("value",r||void 0)}function D(){var e,r,o,c;if(!s.current.search||!1===l.current.shouldFilter){s.current.filtered.count=i.current.size;return}s.current.filtered.groups=new Set;let d=0;for(let n of i.current){let i=k(null!=(r=null==(e=a.current.get(n))?void 0:e.value)?r:"",null!=(c=null==(o=a.current.get(n))?void 0:o.keywords)?c:[]);s.current.filtered.items.set(n,i),i>0&&d++}for(let[e,r]of n.current)for(let i of r)if(s.current.filtered.items.get(i)>0){s.current.filtered.groups.add(e);break}s.current.filtered.count=d}function R(){var e,r,s;let i=A();i&&((null==(e=i.parentElement)?void 0:e.firstChild)===i&&(null==(s=null==(r=i.closest(bi))?void 0:r.querySelector('[cmdk-group-heading=""]'))||s.scrollIntoView({block:"nearest"})),i.scrollIntoView({block:"nearest"}))}function A(){var e;return null==(e=w.current)?void 0:e.querySelector(`${ba}[aria-selected="true"]`)}function M(){var e;return Array.from((null==(e=w.current)?void 0:e.querySelectorAll(bo))||[])}function F(e){let r=M()[e];r&&C.setState("value",r.getAttribute(bc))}function T(e){var r;let s=A(),i=M(),n=i.findIndex(e=>e===s),a=i[n+e];null!=(r=l.current)&&r.loop&&(a=n+e<0?i[i.length-1]:n+e===i.length?i[0]:i[n+e]),a&&C.setState("value",a.getAttribute(bc))}function P(e){let r=A(),s=null==r?void 0:r.closest(bi),i;for(;s&&!i;)i=null==(s=e>0?function(e,r){let s=e.nextElementSibling;for(;s;){if(s.matches(r))return s;s=s.nextElementSibling}}(s,bi):function(e,r){let s=e.previousElementSibling;for(;s;){if(s.matches(r))return s;s=s.previousElementSibling}}(s,bi))?void 0:s.querySelector(bo);i?C.setState("value",i.getAttribute(bc)):T(e)}let B=()=>F(M().length-1),L=e=>{e.preventDefault(),e.metaKey?B():e.altKey?P(1):T(1)},I=e=>{e.preventDefault(),e.metaKey?F(0):e.altKey?P(-1):T(-1)};return $.createElement(bs.div,{ref:r,tabIndex:-1,...v,"cmdk-root":"",onKeyDown:e=>{var r;null==(r=v.onKeyDown)||r.call(v,e);let s=e.nativeEvent.isComposing||229===e.keyCode;if(!(e.defaultPrevented||s))switch(e.key){case"n":case"j":x&&e.ctrlKey&&L(e);break;case"ArrowDown":L(e);break;case"p":case"k":x&&e.ctrlKey&&I(e);break;case"ArrowUp":I(e);break;case"Home":e.preventDefault(),F(0);break;case"End":e.preventDefault(),B();break;case"Enter":{e.preventDefault();let r=A();if(r){let e=new Event(bl);r.dispatchEvent(e)}}}}},$.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:bD},c),bE(e,e=>$.createElement(bh.Provider,{value:C},$.createElement(bu.Provider,{value:j},e))))}),bm=$.forwardRef((e,r)=>{var s,i;let n=ek(),a=$.useRef(null),o=$.useContext(bf),l=$.useContext(bu),c=bw(e),d=null!=(i=null==(s=c.current)?void 0:s.forceMount)?i:null==o?void 0:o.forceMount;bS(()=>{if(!d)return l.item(n,null==o?void 0:o.id)},[d]);let u=bk(n,a,[e.value,e.children,a],e.keywords),h=$.useContext(bh),f=bj(e=>e.value&&e.value===u.current),p=bj(e=>!!d||!1===l.filter()||!e.search||e.filtered.items.get(n)>0);function m(){var e,r;g(),null==(r=(e=c.current).onSelect)||r.call(e,u.current)}function g(){h.setState("value",u.current,!0)}if($.useEffect(()=>{let r=a.current;if(!(!r||e.disabled))return r.addEventListener(bl,m),()=>r.removeEventListener(bl,m)},[p,e.onSelect,e.disabled]),!p)return null;let{disabled:x,value:v,onSelect:_,forceMount:y,keywords:b,...w}=e;return $.createElement(bs.div,{ref:(0,U.composeRefs)(a,r),...w,id:n,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!f,"data-disabled":!!x,"data-selected":!!f,onPointerMove:x||l.getDisablePointerSelection()?void 0:g,onClick:x?void 0:m},e.children)}),bg=$.forwardRef((e,r)=>{let{heading:s,children:i,forceMount:n,...a}=e,o=ek(),l=$.useRef(null),c=$.useRef(null),d=ek(),u=$.useContext(bu),h=bj(e=>!!n||!1===u.filter()||!e.search||e.filtered.groups.has(o));bS(()=>u.group(o),[]),bk(o,l,[e.value,e.heading,c]);let f=$.useMemo(()=>({id:o,forceMount:n}),[n]);return $.createElement(bs.div,{ref:(0,U.composeRefs)(l,r),...a,"cmdk-group":"",role:"presentation",hidden:!h||void 0},s&&$.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},s),bE(e,e=>$.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":s?d:void 0},$.createElement(bf.Provider,{value:f},e))))}),bx=$.forwardRef((e,r)=>{let{alwaysRender:s,...i}=e,n=$.useRef(null),a=bj(e=>!e.search);return s||a?$.createElement(bs.div,{ref:(0,U.composeRefs)(n,r),...i,"cmdk-separator":"",role:"separator"}):null}),bv=$.forwardRef((e,r)=>{let{onValueChange:s,...i}=e,n=null!=e.value,a=$.useContext(bh),o=bj(e=>e.search),l=bj(e=>e.selectedItemId),c=$.useContext(bu);return $.useEffect(()=>{null!=e.value&&a.setState("search",e.value)},[e.value]),$.createElement(bs.input,{ref:r,...i,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":l,id:c.inputId,type:"text",value:n?e.value:o,onChange:e=>{n||a.setState("search",e.target.value),null==s||s(e.target.value)}})}),b_=$.forwardRef((e,r)=>{let{children:s,label:i="Suggestions",...n}=e,a=$.useRef(null),o=$.useRef(null),l=bj(e=>e.selectedItemId),c=$.useContext(bu);return $.useEffect(()=>{if(o.current&&a.current){let e=o.current,r=a.current,s,i=new ResizeObserver(()=>{s=requestAnimationFrame(()=>{let s=e.offsetHeight;r.style.setProperty("--cmdk-list-height",s.toFixed(1)+"px")})});return i.observe(e),()=>{cancelAnimationFrame(s),i.unobserve(e)}}},[]),$.createElement(bs.div,{ref:(0,U.composeRefs)(a,r),...n,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":i,id:c.listId},bE(e,e=>$.createElement("div",{ref:(0,U.composeRefs)(o,c.listInnerRef),"cmdk-list-sizer":""},e)))}),by=$.forwardRef((e,r)=>{let{open:s,onOpenChange:i,overlayClassName:n,contentClassName:a,container:o,...l}=e;return $.createElement(tF,{open:s,onOpenChange:i},$.createElement(tO,{container:o},$.createElement(t$,{"cmdk-overlay":"",className:n}),$.createElement(tK,{"aria-label":e.label,"cmdk-dialog":"",className:a},$.createElement(bp,{ref:r,...l}))))}),bb=Object.assign(bp,{List:b_,Item:bm,Input:bv,Group:bg,Separator:bx,Dialog:by,Empty:$.forwardRef((e,r)=>bj(e=>0===e.filtered.count)?$.createElement(bs.div,{ref:r,...e,"cmdk-empty":"",role:"presentation"}):null),Loading:$.forwardRef((e,r)=>{let{progress:s,children:i,label:n="Loading...",...a}=e;return $.createElement(bs.div,{ref:r,...a,"cmdk-loading":"",role:"progressbar","aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100,"aria-label":n},bE(e,e=>$.createElement("div",{"aria-hidden":!0},e)))})});function bw(e){let r=$.useRef(e);return bS(()=>{r.current=e}),r}var bS="undefined"==typeof window?$.useEffect:$.useLayoutEffect;function bC(e){let r=$.useRef();return void 0===r.current&&(r.current=e()),r}function bj(e){let r=$.useContext(bh),s=()=>e(r.snapshot());return $.useSyncExternalStore(r.subscribe,s,s)}function bk(e,r,s,i=[]){let n=$.useRef(),a=$.useContext(bu);return bS(()=>{var o;let l=(()=>{var e;for(let r of s){if("string"==typeof r)return r.trim();if("object"==typeof r&&"current"in r)return r.current?null==(e=r.current.textContent)?void 0:e.trim():n.current}})(),c=i.map(e=>e.trim());a.value(e,l,c),null==(o=r.current)||o.setAttribute(bc,l),n.current=l}),n}var bN=()=>{let[e,r]=$.useState(),s=bC(()=>new Map);return bS(()=>{s.current.forEach(e=>e()),s.current=new Map},[e]),(e,i)=>{s.current.set(e,i),r({})}};function bE({asChild:e,children:r},s){let i;return e&&$.isValidElement(r)?$.cloneElement("function"==typeof(i=r.type)?i(r.props):"render"in i?i.render(r.props):r,{ref:r.ref},s(r.props.children)):s(r)}var bD={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function bR({className:e,...r}){return(0,z.jsx)(bb,{"data-slot":"command",className:(0,ey.cn)("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...r})}function bA({title:e="Command Palette",description:r="Search for a command to run...",children:s,className:i,showCloseButton:n=!0,shouldFilter:a,...o}){return(0,z.jsxs)(t7,{...o,children:[(0,z.jsxs)(rs,{className:"sr-only",children:[(0,z.jsx)(rn,{children:e}),(0,z.jsx)(ra,{children:r})]}),(0,z.jsx)(rr,{className:(0,ey.cn)("overflow-hidden p-0",i),showCloseButton:n,children:(0,z.jsx)(bR,{shouldFilter:a,className:"[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:s})})]})}function bM({className:e,...r}){return(0,z.jsxs)("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[(0,z.jsx)(dt,{className:"size-4 shrink-0 opacity-50"}),(0,z.jsx)(bb.Input,{"data-slot":"command-input",className:(0,ey.cn)("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...r})]})}function bF({className:e,...r}){return(0,z.jsx)(bb.List,{"data-slot":"command-list",className:(0,ey.cn)("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...r})}function bT({...e}){return(0,z.jsx)(bb.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function bP({className:e,...r}){return(0,z.jsx)(bb.Group,{"data-slot":"command-group",className:(0,ey.cn)("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...r})}function bB({className:e,...r}){return(0,z.jsx)(bb.Item,{"data-slot":"command-item",className:(0,ey.cn)("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}let bL=(0,ew.default)("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]),bI=(0,ew.default)("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]),bO=(0,ew.default)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),bz=new Set(["ts","tsx","js","jsx","py","rb","go","rs","java","c","cpp","h","css","scss","html","vue","svelte","php","swift","kt","sh","bash","yaml","yml","toml","json","xml","sql","graphql","proto"]),b$=new Set(["md","txt","log","csv","env","gitignore","dockerignore","editorconfig"]);function bW(e){return Array.from(e.dataTransfer.types).includes("Files")}function bH(e){let r=e.dataTransfer.items;if(r&&r.length>0&&"function"==typeof r[0].webkitGetAsEntry){let e=[];for(let s of Array.from(r)){if("file"!==s.kind)continue;let r=s.webkitGetAsEntry();if(r?.isDirectory)continue;let i=s.getAsFile();i&&e.push(i)}return e}return Array.from(e.dataTransfer.files)}function bU({path:e}){let[r,s]=(0,$.useState)(!1),i=(0,$.useCallback)(r=>{r.stopPropagation(),navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),1500)},[e]);return(0,z.jsx)("button",{onClick:i,className:"p-0.5 rounded hover:bg-muted-foreground/20 transition-colors",title:`Copy path: ${e}`,children:r?(0,z.jsx)(rf.Check,{className:"h-3 w-3 text-green-500"}):(0,z.jsx)(ul.Copy,{className:"h-3 w-3 text-muted-foreground"})})}function bK({entryPath:e,type:r,deleting:s,onRequestDelete:i}){return s?(0,z.jsx)(rk,{className:"h-3 w-3 animate-spin text-muted-foreground"}):(0,z.jsx)("button",{onClick:s=>{s.stopPropagation(),i(e,r)},className:"p-0.5 rounded hover:bg-destructive/20 transition-colors",title:`Delete ${e}`,"aria-label":`Delete ${e}`,children:(0,z.jsx)(rc,{className:"h-3 w-3 text-muted-foreground hover:text-destructive"})})}function bq({entry:e,path:r,depth:s,expandedDirs:i,directoryContents:n,loadingDirs:a,selectedFile:o,uploadingDirs:l,dragOverPath:c,deletingPaths:d,onToggleDirectory:u,onSelectFile:h,onUploadFiles:f,onSetDragOverPath:p,onRequestDelete:m}){var g,x,v;let _,y,b,w,S,C=i.has(r),j=a.has(r),k=n.get(r),N=e.name.startsWith(".");if("directory"===e.type){let g=C?r_:oi,x=c===r,v=l.has(r),_=d.has(r);return(0,z.jsxs)("div",{children:[(0,z.jsxs)("div",{className:(0,ey.cn)("group flex items-center w-full px-2 py-2 rounded-sm transition-colors cursor-pointer",x?"bg-primary/15 outline-2 -outline-offset-2 outline-dashed outline-primary/60":"hover:bg-accent"),style:{paddingLeft:`${16*s+8}px`},onClick:()=>u(r),onDragOver:e=>{bW(e)&&(e.preventDefault(),e.stopPropagation(),p(r))},onDrop:e=>{if(!bW(e))return;e.preventDefault(),e.stopPropagation(),p(null);let s=bH(e);s.length&&f(r,s)},children:[(0,z.jsxs)("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[v||j?(0,z.jsx)(rk,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,z.jsx)(C?sw:af,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,z.jsx)(g,{className:(0,ey.cn)("h-4 w-4 shrink-0 text-blue-500",N&&"opacity-60")}),(0,z.jsx)("span",{className:(0,ey.cn)("truncate",N&&"text-muted-foreground"),children:e.name})]}),(0,z.jsxs)("div",{className:(0,ey.cn)("shrink-0 ml-1 items-center gap-1",_?"flex":"hidden group-hover:flex"),children:[(0,z.jsx)(bU,{path:r}),(0,z.jsx)(bK,{entryPath:r,type:"directory",deleting:_,onRequestDelete:m})]})]}),C&&k&&(0,z.jsx)("div",{children:k.map(e=>{let g=r?`${r}/${e.name}`:e.name;return(0,z.jsx)(bq,{entry:e,path:g,depth:s+1,expandedDirs:i,directoryContents:n,loadingDirs:a,selectedFile:o,uploadingDirs:l,dragOverPath:c,deletingPaths:d,onToggleDirectory:u,onSelectFile:h,onUploadFiles:f,onSetDragOverPath:p,onRequestDelete:m},g)})})]})}let E=(g=e.name,_=g.split(".").pop()?.toLowerCase()??"",bz.has(_)?bI:b$.has(_)?bO:bL),D=o===r,R=r.includes("/")?r.slice(0,r.lastIndexOf("/")):"",A=d.has(r);return(0,z.jsxs)("div",{className:(0,ey.cn)("group flex items-center w-full px-2 py-2 rounded-sm transition-colors cursor-pointer",D?"bg-accent text-accent-foreground":"hover:bg-accent/50"),style:{paddingLeft:`${16*s+8+18}px`},onClick:()=>h(r),onDragOver:e=>{bW(e)&&(e.preventDefault(),e.stopPropagation(),p(R))},onDrop:e=>{if(!bW(e))return;e.preventDefault(),e.stopPropagation(),p(null);let r=bH(e);r.length&&f(R,r)},children:[(0,z.jsxs)("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[(0,z.jsx)(E,{className:(0,ey.cn)("h-4 w-4 shrink-0 text-muted-foreground",N&&"opacity-60")}),(0,z.jsx)("span",{className:(0,ey.cn)("truncate",N&&"text-muted-foreground"),children:e.name})]}),(0,z.jsxs)("div",{className:"shrink-0 flex items-center gap-2 ml-1",children:[(0,z.jsx)("span",{className:"text-[11px] text-muted-foreground/70 group-hover:hidden whitespace-nowrap w-[52px] text-right tabular-nums",children:e.mtime&&(x=e.mtime,y=Date.now(),S=Math.floor((w=Math.floor((b=Math.floor(Math.floor((y-new Date(x).getTime())/1e3)/60))/60))/24),b<1?"just now":b<60?`${b}m ago`:w<24?`${w}h ago`:S<30?`${S}d ago`:new Date(x).toLocaleDateString(void 0,{month:"short",day:"numeric"}))}),(0,z.jsx)("span",{className:"text-[11px] text-muted-foreground/70 group-hover:hidden whitespace-nowrap w-[52px] text-right tabular-nums",children:null!=e.size&&((v=e.size)<1024?`${v} B`:v<1048576?`${(v/1024).toFixed(1)} KB`:`${(v/1048576).toFixed(1)} MB`)}),(0,z.jsxs)("div",{className:(0,ey.cn)("items-center gap-1",A?"flex":"hidden group-hover:flex"),children:[(0,z.jsx)(bU,{path:r}),(0,z.jsx)(bK,{entryPath:r,type:"file",deleting:A,onRequestDelete:m})]})]})]})}function bV({entries:e,expandedDirs:r,directoryContents:s,loadingDirs:i,selectedFile:n,uploadingDirs:a,rootLoading:o,deletingPaths:l,onToggleDirectory:c,onSelectFile:d,onUploadFiles:u,onDeleteEntry:h}){let[f,p]=(0,$.useState)(null),[m,g]=(0,$.useState)(null),x=""===f,v=a.has(""),_=(0,$.useCallback)((e,r)=>{g({path:e,type:r})},[]),y=m?m.path.includes("/")?m.path.slice(m.path.lastIndexOf("/")+1):m.path:"";return(0,z.jsxs)("div",{className:(0,ey.cn)("h-full transition-colors",x&&"bg-accent/30 outline-2 -outline-offset-2 outline-dashed outline-primary/50"),style:{fontSize:"var(--files-tree-font-size, 14px)"},onDragOver:e=>{bW(e)&&(e.preventDefault(),p(""))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||p(null)},onDrop:e=>{if(!bW(e))return;e.preventDefault(),p(null);let r=bH(e);r.length&&u("",r)},children:[(0,z.jsx)(or,{className:"h-full",children:(0,z.jsxs)("div",{className:"py-1",children:[v&&(0,z.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 text-xs text-muted-foreground",children:[(0,z.jsx)(rk,{className:"h-3.5 w-3.5 animate-spin"}),"Uploading…"]}),o&&0===e.length?(0,z.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"Loading files..."}):0===e.length?(0,z.jsx)("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-sm",children:x?"Drop files to upload":"No files found. Drop files here to upload."}):e.map(e=>{let o=e.name;return(0,z.jsx)(bq,{entry:e,path:o,depth:0,expandedDirs:r,directoryContents:s,loadingDirs:i,selectedFile:n,uploadingDirs:a,dragOverPath:f,deletingPaths:l,onToggleDirectory:c,onSelectFile:d,onUploadFiles:u,onSetDragOverPath:p,onRequestDelete:_},o)})]})}),(0,z.jsx)(lU,{open:null!==m,onOpenChange:e=>{e||g(null)},children:(0,z.jsxs)(lV,{children:[(0,z.jsxs)(lY,{children:[(0,z.jsxs)(lX,{children:["Delete ",m?.type==="directory"?"folder":"file","?"]}),(0,z.jsx)(lJ,{children:m?.type==="directory"?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("span",{className:"font-medium text-foreground",children:y})," and all its contents will be permanently deleted. This can't be undone."]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("span",{className:"font-medium text-foreground",children:y})," will be permanently deleted. This can't be undone."]})})]}),(0,z.jsxs)(lG,{children:[(0,z.jsx)(lQ,{children:"Cancel"}),(0,z.jsx)(lZ,{className:(0,ey.cn)((0,W.buttonVariants)({variant:"destructive"}),"border-transparent"),onClick:()=>{m&&h(m.path,m.type)},children:"Delete"})]})]})})]})}let bY=(0,ew.default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]),bG=(0,ew.default)("file-exclamation-point",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),bX=(0,ew.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),bJ=(0,ew.default)("list-collapse",[["path",{d:"M10 5h11",key:"1hkqpe"}],["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 19h11",key:"14g2nv"}],["path",{d:"m3 10 3-3-3-3",key:"i7pm08"}],["path",{d:"m3 20 3-3-3-3",key:"20gx1n"}]]),bZ=(0,ew.default)("list-tree",[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]]),bQ=/[\0-\x1F!-,\.\/:-@\[-\^`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482\u0530\u0557\u0558\u055A-\u055F\u0589-\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05EB-\u05EE\u05F3-\u060F\u061B-\u061F\u066A-\u066D\u06D4\u06DD\u06DE\u06E9\u06FD\u06FE\u0700-\u070F\u074B\u074C\u07B2-\u07BF\u07F6-\u07F9\u07FB\u07FC\u07FE\u07FF\u082E-\u083F\u085C-\u085F\u086B-\u089F\u08B5\u08C8-\u08D2\u08E2\u0964\u0965\u0970\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09F2-\u09FB\u09FD\u09FF\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF0-\u0AF8\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B54\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B70\u0B72-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BF0-\u0BFF\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5B-\u0C5F\u0C64\u0C65\u0C70-\u0C7F\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0CFF\u0D0D\u0D11\u0D45\u0D49\u0D4F-\u0D53\u0D58-\u0D5E\u0D64\u0D65\u0D70-\u0D79\u0D80\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DE5\u0DF0\u0DF1\u0DF4-\u0E00\u0E3B-\u0E3F\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F17\u0F1A-\u0F1F\u0F2A-\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F48\u0F6D-\u0F70\u0F85\u0F98\u0FBD-\u0FC5\u0FC7-\u0FFF\u104A-\u104F\u109E\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u1360-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u170D\u1715-\u171F\u1735-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17D4-\u17D6\u17D8-\u17DB\u17DE\u17DF\u17EA-\u180A\u180E\u180F\u181A-\u181F\u1879-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191F\u192C-\u192F\u193C-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DA-\u19FF\u1A1C-\u1A1F\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1AAF\u1AC1-\u1AFF\u1B4C-\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BF4-\u1BFF\u1C38-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C89-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CCF\u1CD3\u1CFB-\u1CFF\u1DFA\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u203E\u2041-\u2053\u2055-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u20CF\u20F1-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u215F\u2189-\u24B5\u24EA-\u2BFF\u2C2F\u2C5F\u2CE5-\u2CEA\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E00-\u2E2E\u2E30-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u3040\u3097\u3098\u309B\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31C0-\u31EF\u3200-\u33FF\u4DC0-\u4DFF\u9FFD-\u9FFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA673\uA67E\uA6F2-\uA716\uA720\uA721\uA789\uA78A\uA7C0\uA7C1\uA7CB-\uA7F4\uA828-\uA82B\uA82D-\uA83F\uA874-\uA87F\uA8C6-\uA8CF\uA8DA-\uA8DF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA954-\uA95F\uA97D-\uA97F\uA9C1-\uA9CE\uA9DA-\uA9DF\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAAC3-\uAADA\uAADE\uAADF\uAAF0\uAAF1\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABEB\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFDFF\uFE10-\uFE1F\uFE30-\uFE32\uFE35-\uFE4C\uFE50-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF3E\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD3F\uDD75-\uDDFC\uDDFE-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEDF\uDEE1-\uDEFF\uDF20-\uDF2C\uDF4B-\uDF4F\uDF7B-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56-\uDC5F\uDC77-\uDC7F\uDC9F-\uDCDF\uDCF3\uDCF6-\uDCFF\uDD16-\uDD1F\uDD3A-\uDD7F\uDDB8-\uDDBD\uDDC0-\uDDFF\uDE04\uDE07-\uDE0B\uDE14\uDE18\uDE36\uDE37\uDE3B-\uDE3E\uDE40-\uDE5F\uDE7D-\uDE7F\uDE9D-\uDEBF\uDEC8\uDEE7-\uDEFF\uDF36-\uDF3F\uDF56-\uDF5F\uDF73-\uDF7F\uDF92-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCFF\uDD28-\uDD2F\uDD3A-\uDE7F\uDEAA\uDEAD-\uDEAF\uDEB2-\uDEFF\uDF1D-\uDF26\uDF28-\uDF2F\uDF51-\uDFAF\uDFC5-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC47-\uDC65\uDC70-\uDC7E\uDCBB-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDCFF\uDD35\uDD40-\uDD43\uDD48-\uDD4F\uDD74\uDD75\uDD77-\uDD7F\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDFF\uDE12\uDE38-\uDE3D\uDE3F-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEEB-\uDEEF\uDEFA-\uDEFF\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A\uDF45\uDF46\uDF49\uDF4A\uDF4E\uDF4F\uDF51-\uDF56\uDF58-\uDF5C\uDF64\uDF65\uDF6D-\uDF6F\uDF75-\uDFFF]|\uD805[\uDC4B-\uDC4F\uDC5A-\uDC5D\uDC62-\uDC7F\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDB6\uDDB7\uDDC1-\uDDD7\uDDDE-\uDDFF\uDE41-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEB9-\uDEBF\uDECA-\uDEFF\uDF1B\uDF1C\uDF2C-\uDF2F\uDF3A-\uDFFF]|\uD806[\uDC3B-\uDC9F\uDCEA-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD36\uDD39\uDD3A\uDD44-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD8\uDDD9\uDDE2\uDDE5-\uDDFF\uDE3F-\uDE46\uDE48-\uDE4F\uDE9A-\uDE9C\uDE9E-\uDEBF\uDEF9-\uDFFF]|\uD807[\uDC09\uDC37\uDC41-\uDC4F\uDC5A-\uDC71\uDC90\uDC91\uDCA8\uDCB7-\uDCFF\uDD07\uDD0A\uDD37-\uDD39\uDD3B\uDD3E\uDD48-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8F\uDD92\uDD99-\uDD9F\uDDAA-\uDEDF\uDEF7-\uDFAF\uDFB1-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD80B\uD80E-\uD810\uD812-\uD819\uD824-\uD82B\uD82D\uD82E\uD830-\uD833\uD837\uD839\uD83D\uD83F\uD87B-\uD87D\uD87F\uD885-\uDB3F\uDB41-\uDBFF][\uDC00-\uDFFF]|\uD80D[\uDC2F-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDECF\uDEEE\uDEEF\uDEF5-\uDEFF\uDF37-\uDF3F\uDF44-\uDF4F\uDF5A-\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDE3F\uDE80-\uDEFF\uDF4B-\uDF4E\uDF88-\uDF8E\uDFA0-\uDFDF\uDFE2\uDFE5-\uDFEF\uDFF2-\uDFFF]|\uD821[\uDFF8-\uDFFF]|\uD823[\uDCD6-\uDCFF\uDD09-\uDFFF]|\uD82C[\uDD1F-\uDD4F\uDD53-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDC9C\uDC9F-\uDFFF]|\uD834[\uDC00-\uDD64\uDD6A-\uDD6C\uDD73-\uDD7A\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDE41\uDE45-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE9A\uDEA0\uDEB0-\uDFFF]|\uD838[\uDC07\uDC19\uDC1A\uDC22\uDC25\uDC2B-\uDCFF\uDD2D-\uDD2F\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDEBF\uDEFA-\uDFFF]|\uD83A[\uDCC5-\uDCCF\uDCD7-\uDCFF\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDD2F\uDD4A-\uDD4F\uDD6A-\uDD6F\uDD8A-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEDE-\uDEFF]|\uD86D[\uDF35-\uDF3F]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEA2-\uDEAF]|\uD87A[\uDFE1-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDFFF]|\uDB40[\uDC00-\uDCFF\uDDF0-\uDFFF]/g,b0=Object.hasOwnProperty;var b1=e.i(216920);let b2={},b5=new class{constructor(){this.occurrences,this.reset()}slug(e,r){var s,i;let n=(s=e,i=!0===r,"string"!=typeof s?"":(i||(s=s.toLowerCase()),s.replace(bQ,"").replace(/ /g,"-"))),a=n;for(;b0.call(this.occurrences,n);)this.occurrences[a]++,n=a+"-"+this.occurrences[a];return this.occurrences[n]=0,n}reset(){this.occurrences=Object.create(null)}};function b3(e){let r=(e||b2).prefix||"";return function(e){b5.reset(),(0,b1.visit)(e,"element",function(e){let s,i;((i=2===(s="element"===e.type?e.tagName.toLowerCase():"").length&&104===s.charCodeAt(0)?s.charCodeAt(1):0)>48&&i<55?i-48:void 0)&&!e.properties.id&&(e.properties.id=r+b5.slug("children"in e?function e(r){let s=-1,i=[];for(;++s<r.children.length;){var n;i[s]="text"===(n=r.children[s]).type?n.value:"children"in n?e(n):""}return i.join("")}(e):"value"in e?e.value:""))})}}var b4=oM,H=H,b6=e.i(829692),b6=b6,b8=e.i(615742);let b7=(0,$.createContext)({code:""}),b9={name:"line-data",line(e,r){e.properties["data-line"]=String(r)}},we={name:"line-numbers",line(e,r){e.children.unshift({type:"element",tagName:"span",properties:{className:["inline-block","min-w-10","mr-2","text-right","select-none","text-muted-foreground"]},children:[{type:"text",value:String(r)}]})}};async function wt(e,r,s=!1,i){let n=[b9];return i&&i.size>0&&n.push({name:"fold-gutter",line(e,r){e.children.unshift({type:"element",tagName:"span",properties:i.has(r)?{className:["code-fold-toggle"],"data-fold-start":String(r)}:{className:["code-fold-spacer"]},children:[]})}}),s&&n.push(we),await Promise.all([(0,b8.codeToHtml)(e,{lang:r,theme:"one-light",transformers:n}),(0,b8.codeToHtml)(e,{lang:r,theme:"one-dark-pro",transformers:n})])}let wr=(0,$.forwardRef)(function({code:e,language:r,showLineNumbers:s=!1,scrollToLine:i,scrollKey:n,foldable:a=!1,className:o,children:l,...c},d){let[u,h]=(0,$.useState)(""),[f,p]=(0,$.useState)(""),m=(0,$.useRef)(!1),g=(0,$.useRef)(null),x=(0,$.useMemo)(()=>a?function(e,r={}){return function(...e){let r=new Map;for(let s of e.flat())!(s.endLine<=s.startLine)&&(r.has(s.startLine)||r.set(s.startLine,s));let s=[...r.values()].sort((e,r)=>e.startLine-r.startLine||r.endLine-e.endLine),i=[],n=[];for(let e of s){for(;n.length&&n[n.length-1].endLine<e.startLine;)n.pop();let r=n[n.length-1];r&&e.endLine>r.endLine||(i.push(e),n.push(e))}return i}((r.tokenIndex,[]),function(e){let r=e.split("\n"),s=[],i=[],n=0,a=e=>{n>e.line&&s.push({startLine:e.line+1,endLine:n+1})};for(let e=0;e<r.length;e++){let s=function(e){let r=e.match(/^[ \t]*/),s=r?r[0].length:0;return s===e.length?null:s}(r[e]);if(null!==s){for(;i.length&&i[i.length-1].indent>=s;)a(i.pop());i.push({indent:s,line:e}),n=e}}for(;i.length;)a(i.pop());return s}(e))}(e):[],[a,e]),v=(0,$.useMemo)(()=>new Set(x.map(e=>e.startLine)),[x]),[_,y]=(0,$.useState)(new Set),[b,w]=(0,$.useState)(e),[S,C]=(0,$.useState)({line:i,key:n});if((0,$.useImperativeHandle)(d,()=>({foldAll:()=>y(new Set(x.map(e=>e.startLine))),expandAll:()=>y(new Set)}),[x]),(0,$.useEffect)(()=>(wt(e,r,s,v).then(([e,r])=>{m.current||(h(e),p(r),m.current=!0)}),()=>{m.current=!1}),[e,r,s,v]),(0,$.useEffect)(()=>{let e=g.current;if(!e)return;let r=new Map(x.map(e=>[e.startLine,e])),s=new Set;for(let e of _){let i=r.get(e);if(i)for(let e=i.startLine+1;e<=i.endLine;e++)s.add(e)}for(let r of e.querySelectorAll("[data-line]")){let e=Number(r.getAttribute("data-line"));r.style.display=s.has(e)?"none":"",r.classList.toggle("code-line-collapsed",_.has(e))}},[_,x,u,f]),(0,$.useEffect)(()=>{if(!a)return;let e=g.current;if(!e)return;let r=e=>{let r=e.target?.closest?.("[data-fold-start]");if(!r)return;e.stopPropagation(),e.preventDefault();let s=Number(r.getAttribute("data-fold-start"));y(e=>{let r=new Set(e);return r.has(s)?r.delete(s):r.add(s),r})};return e.addEventListener("click",r),()=>e.removeEventListener("click",r)},[a]),(0,$.useEffect)(()=>{if(null==i)return;let e=g.current;if(!e||!u&&!f)return;let r=Array.from(e.querySelectorAll(`[data-line="${i}"]`));if(0===r.length)return;let s=r.find(e=>null!==e.offsetParent)??r[0],n=requestAnimationFrame(()=>{s.scrollIntoView({block:"center",behavior:"auto"}),r.forEach(e=>e.classList.add("code-line-highlight"))}),a=window.setTimeout(()=>r.forEach(e=>e.classList.remove("code-line-highlight")),1600);return()=>{cancelAnimationFrame(n),window.clearTimeout(a),r.forEach(e=>e.classList.remove("code-line-highlight"))}},[i,n,u,f]),e!==b&&(w(e),y(new Set)),(S.line!==i||S.key!==n)&&(C({line:i,key:n}),null!=i&&_.size>0)){let e=!1,r=new Set(_);for(let s of x)r.has(s.startLine)&&i>s.startLine&&i<=s.endLine&&(r.delete(s.startLine),e=!0);e&&y(r)}return(0,z.jsx)(b7.Provider,{value:{code:e},children:(0,z.jsx)("div",{ref:g,className:(0,ey.cn)("group relative w-full overflow-hidden rounded-md border bg-background text-foreground",o),...c,children:(0,z.jsxs)("div",{className:"relative",children:[(0,z.jsx)("div",{className:"overflow-auto dark:hidden [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:grid [&_code]:font-mono [&_code]:text-sm",dangerouslySetInnerHTML:{__html:u}}),(0,z.jsx)("div",{className:"hidden overflow-auto dark:block [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:grid [&_code]:font-mono [&_code]:text-sm",dangerouslySetInnerHTML:{__html:f}}),l&&(0,z.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:l})]})})})}),ws=({onCopy:e,onError:r,timeout:s=2e3,children:i,className:n,...a})=>{let[o,l]=(0,$.useState)(!1),{code:c}=(0,$.useContext)(b7),d=async()=>{if(!navigator?.clipboard?.writeText)return void r?.(Error("Clipboard API not available"));try{await navigator.clipboard.writeText(c),l(!0),e?.(),setTimeout(()=>l(!1),s)}catch(e){r?.(e)}},u=o?H.default:b6.default;return(0,z.jsx)(W.Button,{className:(0,ey.cn)("shrink-0",n),onClick:d,size:"icon",variant:"ghost",...a,children:i??(0,z.jsx)(u,{size:14})})};var wi="horizontal",wn=["horizontal","vertical"],wa=$.forwardRef((e,r)=>{var s;let{decorative:i,orientation:n=wi,...a}=e,o=(s=n,wn.includes(s))?n:wi;return(0,z.jsx)(er.div,{"data-orientation":o,...i?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"},...a,ref:r})});wa.displayName="Separator",e.s(["Root",()=>wa,"Separator",()=>wa],691102),e.i(691102),(0,s_.cva)("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}}),(0,ew.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);var oF=oM;let wo=({className:e,from:r,...s})=>(0,z.jsx)("div",{className:(0,ey.cn)("group flex w-full max-w-[95%] flex-col gap-2","user"===r?"is-user ml-auto justify-end":"is-assistant",e),...s}),wl=({children:e,className:r,...s})=>(0,z.jsx)("div",{className:(0,ey.cn)("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",r),...s,children:e}),wc=(0,$.memo)(({className:e,...r})=>(0,z.jsx)(oF.i,{className:(0,ey.cn)("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...r}),(e,r)=>e.children===r.children);function wd({className:e,...r}){return(0,z.jsx)("div",{"data-slot":"skeleton",className:(0,ey.cn)("bg-accent animate-pulse rounded-md",e),...r})}function wu({projectId:e,symbol:r,branch:s,target:i,currentFile:n,anchor:a,onJump:o,onClose:l}){let[c,d]=(0,$.useState)(!0),[u,h]=(0,$.useState)([]),[f,p]=(0,$.useState)(!1),m=(0,$.useRef)(null);(0,$.useEffect)(()=>{let n=!0;return d(!0),rv.api.searchSymbol(e,r,s,i).then(e=>{n&&(h(e.hits),p(e.truncated))}).catch(()=>{n&&h([])}).finally(()=>{n&&d(!1)}),()=>{n=!1}},[e,r,s,i]),(0,$.useEffect)(()=>{let e=e=>{e.detail>=2||m.current&&!m.current.contains(e.target)&&l()},s=e=>{if("Escape"===e.key)return void l();if((e.metaKey||e.ctrlKey)&&("c"===e.key||"C"===e.key)){let s=window.getSelection();if(s&&s.rangeCount>0&&!s.isCollapsed)return;e.preventDefault(),navigator.clipboard?.writeText(r)}};return document.addEventListener("mousedown",e),document.addEventListener("keydown",s),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",s)}},[l,r]);let g=(e,r)=>Number(r.file===n)-Number(e.file===n),x=u.filter(e=>"definition"===e.kind).sort(g),v=u.filter(e=>"reference"===e.kind).sort(g),_=Math.max(8,Math.min(a.x,window.innerWidth-440-8)),y=window.innerHeight-8-(a.y+18),b=a.y-18-8,w=y>=340||y>=b,S=Math.max(120,Math.min(340,w?y:b)),C=w?{top:a.y+18}:{bottom:window.innerHeight-(a.y-18)},j=({hit:e})=>(0,z.jsxs)("button",{type:"button",onClick:()=>{o(e.file,e.line),l()},className:"flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left hover:bg-accent",children:[(0,z.jsxs)("span",{className:"flex w-full items-baseline justify-between gap-2",children:[(0,z.jsxs)("span",{className:"truncate font-mono text-xs",children:[e.file.split("/").pop(),(0,z.jsxs)("span",{className:"text-muted-foreground",children:[":",e.line]})]}),e.file===n&&(0,z.jsx)("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:"this file"})]}),(0,z.jsx)("code",{className:"w-full truncate text-xs text-muted-foreground",children:e.text.trim()})]}),k=({title:e,children:r})=>(0,z.jsxs)("div",{className:"mb-1",children:[(0,z.jsx)("div",{className:"px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:e}),r]});return(0,ee.createPortal)((0,z.jsxs)("div",{ref:m,style:{left:_,...C,width:440,maxHeight:S},className:"fixed z-50 flex flex-col overflow-hidden rounded-lg border bg-popover text-popover-foreground shadow-lg select-none",children:[(0,z.jsx)("div",{className:"border-b px-3 py-1.5 text-xs font-medium",children:(0,z.jsx)("span",{className:"font-mono",children:r})}),(0,z.jsx)("div",{className:"flex-1 overflow-auto p-1",children:c?(0,z.jsxs)("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin"})," Searching…"]}):0===u.length?(0,z.jsx)("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"No results."}):(0,z.jsxs)(z.Fragment,{children:[x.length>0&&(0,z.jsx)(k,{title:`Definitions (${x.length})`,children:x.map((e,r)=>(0,z.jsx)(j,{hit:e},`d-${r}`))}),v.length>0&&(0,z.jsx)(k,{title:`References (${v.length})`,children:v.map((e,r)=>(0,z.jsx)(j,{hit:e},`r-${r}`))}),f&&(0,z.jsx)("div",{className:"px-2 py-1.5 text-[11px] text-muted-foreground",children:"Showing first matches — results truncated."})]})})]}),document.body)}wc.displayName="MessageResponse";let wh=(0,ew.default)("image-off",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]);function wf({projectId:e,filePath:r,branch:s,target:i,onDownload:n}){let[a,o]=(0,$.useState)(null),[l,c]=(0,$.useState)(!1);return((0,$.useEffect)(()=>{let n=null,a=!1;return rv.api.getFileBlob(e,r,s,i).then(e=>{a||o(n=URL.createObjectURL(e))}).catch(()=>{a||c(!0)}),()=>{a=!0,n&&URL.revokeObjectURL(n)}},[e,r,s,i]),l)?(0,z.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",children:[(0,z.jsx)(wh,{className:"h-10 w-10"}),(0,z.jsx)("p",{className:"text-sm",children:"Couldn't load image"}),(0,z.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:n,children:[(0,z.jsx)(bY,{className:"h-4 w-4 mr-2"}),"Download"]})]}):a?(0,z.jsx)("div",{className:"flex items-center justify-center h-full p-4 bg-muted/30",children:(0,z.jsx)("img",{src:a,alt:r.split("/").pop()??"image",className:"max-w-full max-h-full object-contain",onError:()=>c(!0)})}):(0,z.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:(0,z.jsx)(rk,{className:"h-6 w-6 animate-spin"})})}async function wp(e,r){let s=await (0,b8.codeToTokensBase)(e,{lang:r,theme:"one-light",includeExplanation:"scopeName"}),i=new Map;return s.forEach((e,r)=>{let s=0,n=[];for(let r of e){let e=(r.explanation??[]).flatMap(e=>e.scopes.map(e=>e.scopeName)),i=s+r.content.length;n.push({start:s,end:i,kind:e.some(e=>e.startsWith("comment"))?"comment":e.some(e=>e.startsWith("string")||e.startsWith("constant.character"))?"string":e.some(e=>e.startsWith("keyword")||e.startsWith("storage")||e.startsWith("constant.language")||e.startsWith("variable.language"))?"keyword":"code"}),s=i}i.set(r+1,n)}),i}let wm=new Set(["png","jpg","jpeg","gif","webp","bmp","ico","avif","svg"]);function wg(e){let r=e.split("/").pop()?.split(".").pop()?.toLowerCase()??"";return wm.has(r)}let wx=/^[A-Za-z_$][A-Za-z0-9_$]*$/,wv="symbol-nav";function w_(e,r,s){let i=document.createRange();return i.selectNodeContents(e),i.setEnd(r,s),i.toString().length}function wy(e,r){let s,i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=0;for(;s=i.nextNode();){let e=(s.textContent??"").length;if(r<=n+e)return{node:s,offset:r-n};n+=e}return null}function wb(e){let r=Array.from(document.querySelectorAll(`[data-line="${CSS.escape(e.line)}"]`)),s=r.find(e=>null!==e.offsetParent)??r[0];if(!s)return null;let i=wy(s,e.start),n=wy(s,e.end);if(!i||!n)return null;let a=document.createRange();return a.setStart(i.node,i.offset),a.setEnd(n.node,n.offset),a}let ww=/[A-Za-z0-9_$]/;function wS(e,r,s){let i=document,n=null,a=0;if(i.caretRangeFromPoint){let s=i.caretRangeFromPoint(e,r);s&&(n=s.startContainer,a=s.startOffset)}else if(i.caretPositionFromPoint){let s=i.caretPositionFromPoint(e,r);s&&(n=s.offsetNode,a=s.offset)}if(!n||n.nodeType!==Node.TEXT_NODE)return null;let o=n.textContent??"",l=a,c=a;for(;l>0&&ww.test(o[l-1]);)l--;for(;c<o.length&&ww.test(o[c]);)c++;if(l>=c)return null;let d=o.slice(l,c);if(!wx.test(d))return null;let u=document.createRange();u.setStart(n,l),u.setEnd(n,c);let h=function(e){let r=e.startContainer.nodeType===Node.ELEMENT_NODE?e.startContainer:e.startContainer.parentElement,s=r?.closest("[data-line]");if(!s||!s.contains(e.endContainer))return null;let i=s.getAttribute("data-line");if(null===i)return null;let n=w_(s,e.startContainer,e.startOffset),a=w_(s,e.endContainer,e.endOffset);return n>=a?null:{line:i,start:n,end:a}}(u);if(!h)return null;if(s){let e=h.start-h.line.length,r=function(e,r,s){let i=e.get(r);if(!i)return null;for(let e of i)if(s>=e.start&&s<e.end)return e.kind;return null}(s,Number(h.line),e);if(r&&"code"!==r)return null}return{word:d,anchor:h}}function wC(){return"undefined"!=typeof CSS&&"highlights"in CSS&&"undefined"!=typeof Highlight}let wj=!1;function wk(){wC()&&CSS.highlights.delete(wv)}let wN={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",cs:"csharp",css:"css",scss:"scss",html:"html",vue:"vue",svelte:"svelte",php:"php",swift:"swift",kt:"kotlin",sh:"bash",bash:"bash",zsh:"bash",yaml:"yaml",yml:"yaml",toml:"toml",json:"json",xml:"xml",sql:"sql",graphql:"graphql",md:"markdown",mdx:"mdx",dockerfile:"dockerfile",makefile:"makefile",lua:"lua",r:"r",scala:"scala",zig:"zig"};function wE(e){let r=e.split("/").pop()?.toLowerCase()??"";return"dockerfile"===r?"dockerfile":"makefile"===r?"makefile":wN[r.split(".").pop()?.toLowerCase()??""]??"text"}function wD(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function wR({filePath:e,fileContent:r,loading:s,downloadUrl:i,projectId:n,branch:a,target:o,scrollToLine:l,scrollKey:c,onJump:d,restoreScrollTop:u,restoreScrollKey:h,onScroll:f}){let p,[m,g]=(0,$.useState)("rendered"),[x,v]=(0,$.useState)(e),[_,y]=(0,$.useState)(null),b=(0,$.useRef)(null),w=(0,$.useRef)(null),S=(0,$.useRef)(!1);(0,$.useEffect)(()=>{S.current=null!==_},[_]);let C=(0,$.useCallback)(e=>{if(e.detail>=2){let r=window.getSelection();if(S.current){r?.removeAllRanges(),y(e=>e?{...e,selectWord:!0}:e);return}let s=wS(e.clientX,e.clientY),i=s?wb(s.anchor):null;i&&(r?.removeAllRanges(),r?.addRange(i));return}let r=window.getSelection();if(r&&!r.isCollapsed)return;let s=wS(e.clientX,e.clientY,b.current);s&&(r?.removeAllRanges(),y({symbol:s.word,x:e.clientX,y:e.clientY,anchor:s.anchor,selectWord:!1}))},[]),j=(0,$.useCallback)(e=>{e.detail>=2&&e.preventDefault()},[]);(0,$.useEffect)(()=>{if(!_?.anchor)return void wk();let e=wb(_.anchor);if(!e)return void wk();if(_.selectWord){wk();let r=window.getSelection();r?.removeAllRanges(),r?.addRange(e);return}return wC()?(!function(){if(wj||"undefined"==typeof document)return;wj=!0;let e=document.createElement("style");e.textContent=`::highlight(${wv}){background-color:rgba(255, 196, 0, 0.32);}`,document.head.appendChild(e)}(),CSS.highlights.set(wv,new Highlight(e)),wk):void wk()},[_]),(0,$.useEffect)(()=>{b.current=null;let s=r?.content;if(!e||null==s||r?.binary||r?.tooLarge)return;let i=!1;return wp(s,wE(e)).then(e=>{i||(b.current=e)}).catch(()=>{}),()=>{i=!0}},[e,r]);let k=(0,$.useRef)(null),N=(0,$.useRef)(null),E=(0,$.useCallback)(e=>{let r=k.current;if(!r)return;let s=r.querySelector(`[id="${CSS.escape(e)}"]`);if(!s)return;N.current?.();let i=()=>s.scrollIntoView({block:"start",behavior:"auto"});i();let n=new ResizeObserver(i);n.observe(r);let a=()=>{n.disconnect(),window.clearTimeout(o),window.removeEventListener("wheel",a),window.removeEventListener("touchmove",a),window.removeEventListener("keydown",a),N.current=null},o=window.setTimeout(a,1e3);window.addEventListener("wheel",a,{passive:!0}),window.addEventListener("touchmove",a,{passive:!0}),window.addEventListener("keydown",a),N.current=a},[]);(0,$.useEffect)(()=>()=>N.current?.(),[]);let D=(0,$.useRef)(null),R=(0,$.useRef)(!1),A=(0,$.useRef)(f);A.current=f;let M=(0,$.useRef)(null),F=(0,$.useRef)(null),T=(0,$.useCallback)(e=>{if(R.current)return;let r=e.currentTarget.scrollTop;M.current&&clearTimeout(M.current),M.current=setTimeout(()=>A.current?.(r),200)},[]);(0,$.useEffect)(()=>{void 0!==h&&(F.current=u??0)},[h,u]),(0,$.useEffect)(()=>{let e=D.current;e&&(e.scrollTop=0)},[e]),(0,$.useEffect)(()=>{let e=F.current;if(null==e)return;let r=D.current;if(!r||(F.current=null,!e))return;R.current=!0;let s=()=>{r.scrollTop=e};s();let i=new ResizeObserver(s);i.observe(r.firstElementChild??r);let n=()=>{R.current=!1,i.disconnect(),window.clearTimeout(a),r.removeEventListener("wheel",n),r.removeEventListener("touchmove",n),r.removeEventListener("keydown",n)},a=window.setTimeout(n,1500);return r.addEventListener("wheel",n,{passive:!0}),r.addEventListener("touchmove",n,{passive:!0}),r.addEventListener("keydown",n),n},[r]);let P=(0,$.useMemo)(()=>[...Object.values(b4.e),b3],[]),B=(0,$.useMemo)(()=>({a:({href:e,children:r,className:s,node:i,...n})=>{let a="string"==typeof e&&e.startsWith("#");return(0,z.jsx)("a",{href:e,className:(0,ey.cn)("wrap-anywhere font-medium text-primary underline",s),"data-streamdown":"link",...a?{onClick:r=>{r.preventDefault(),E(decodeURIComponent(e.slice(1)))}}:{target:"_blank",rel:"noreferrer"},...n,children:r})}}),[E]);if(e!==x&&(v(e),g("rendered"),y(null)),!e)return(0,z.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Select a file to preview."});if(s)return(0,z.jsxs)("div",{className:"flex flex-col h-full",children:[(0,z.jsx)("div",{className:"flex items-center justify-between px-4 py-2 border-b flex-shrink-0",children:(0,z.jsx)(wd,{className:"h-4 w-48"})}),(0,z.jsxs)("div",{className:"flex-1 p-4",children:[(0,z.jsx)(wd,{className:"h-4 w-full mb-2"}),(0,z.jsx)(wd,{className:"h-4 w-3/4 mb-2"}),(0,z.jsx)(wd,{className:"h-4 w-5/6 mb-2"}),(0,z.jsx)(wd,{className:"h-4 w-2/3"})]})]});if(!r)return(0,z.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Failed to load file."});let L=()=>{e&&rv.api.downloadFile(n,e,a,o).catch(e=>{console.error("Failed to download file",e)})},I=("markdown"===(p=wE(e))||"mdx"===p)&&!r.tooLarge&&!r.binary&&!!r.content,O=I&&"rendered"===m,H=!r.tooLarge&&!r.binary&&!O&&null!==r.content;return(0,z.jsxs)("div",{className:"flex flex-col h-full",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b flex-shrink-0 gap-2",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,z.jsx)("span",{className:"text-sm font-mono truncate",children:e}),(0,z.jsx)("span",{className:"text-xs text-muted-foreground shrink-0",children:wD(r.size)})]}),(0,z.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[I&&(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>g(e=>"rendered"===e?"source":"rendered"),title:O?"View source":"View rendered",children:O?(0,z.jsx)(bX,{className:"h-3.5 w-3.5"}):(0,z.jsx)(_O,{className:"h-3.5 w-3.5"})}),H&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>w.current?.foldAll(),title:"Fold all",children:(0,z.jsx)(bJ,{className:"h-3.5 w-3.5"})}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>w.current?.expandAll(),title:"Expand all",children:(0,z.jsx)(bZ,{className:"h-3.5 w-3.5"})})]}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{navigator.clipboard.writeText(e)},title:"Copy path",children:(0,z.jsx)(ul.Copy,{className:"h-3.5 w-3.5"})}),i&&(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:L,title:"Download",children:(0,z.jsx)(bY,{className:"h-3.5 w-3.5"})})]})]}),(0,z.jsx)("div",{className:"flex-1 overflow-auto",ref:D,onScroll:T,children:r.tooLarge?(0,z.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",children:[(0,z.jsx)(bG,{className:"h-10 w-10"}),(0,z.jsxs)("p",{className:"text-sm",children:["File too large to preview (",wD(r.size),")"]}),i&&(0,z.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:L,children:[(0,z.jsx)(bY,{className:"h-4 w-4 mr-2"}),"Download"]})]}):r.binary&&wg(e)&&r.size<=0xa00000?(0,z.jsx)(wf,{projectId:n,filePath:e,branch:a,target:o,onDownload:L},e):r.binary?(0,z.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",children:[(0,z.jsx)(bG,{className:"h-10 w-10"}),(0,z.jsx)("p",{className:"text-sm",children:wg(e)?`Image too large to preview (${wD(r.size)})`:`Binary file (${wD(r.size)})`}),i&&(0,z.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:L,children:[(0,z.jsx)(bY,{className:"h-4 w-4 mr-2"}),"Download"]})]}):O?(0,z.jsx)("div",{className:"p-4",style:{fontSize:"var(--files-content-font-size, 14px)"},ref:k,children:(0,z.jsx)(wc,{components:B,rehypePlugins:P,children:r.content??""})}):null!==r.content?(0,z.jsx)("div",{className:"h-full [&_pre]:text-[length:var(--files-content-font-size,14px)]! [&_code]:text-[length:var(--files-content-font-size,14px)]!",onMouseDown:j,onClick:C,children:(0,z.jsx)(wr,{ref:w,code:r.content,language:wE(e),showLineNumbers:!0,foldable:!0,scrollToLine:l,scrollKey:c,className:"border-0 rounded-none",children:(0,z.jsx)(ws,{})})}):(0,z.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Empty file."})}),_&&(0,z.jsx)(wu,{projectId:n,symbol:_.symbol,branch:a,target:o,currentFile:e,anchor:{x:_.x,y:_.y},onJump:d,onClose:()=>y(null)})]})}class wA{capacity;map;constructor(e){if(this.capacity=e,this.map=new Map,e<1)throw Error("LRUCache capacity must be at least 1")}get(e){if(!this.map.has(e))return;let r=this.map.get(e);return this.map.delete(e),this.map.set(e,r),r}has(e){return this.map.has(e)}set(e,r){for(this.map.has(e)&&this.map.delete(e),this.map.set(e,r);this.map.size>this.capacity;){let e=this.map.keys().next().value;if(void 0===e)break;this.map.delete(e)}}delete(e){return this.map.delete(e)}deleteWhere(e){for(let r of[...this.map.keys()])e(r)&&this.map.delete(r)}clear(){this.map.clear()}get size(){return this.map.size}}let wM="vibedeckx:files:views";function wF(){return{v:1,views:{}}}function wT(){try{let e=localStorage.getItem(wM);if(!e)return wF();let r=JSON.parse(e);if(!r||1!==r.v||!r.views||"object"!=typeof r.views)return wF();return r}catch{return wF()}}function wP(e){try{localStorage.setItem(wM,JSON.stringify(e))}catch{}}function wB(e){return e.slice(e.lastIndexOf("\0")+1)}let wL=new Set(["/","-","_","."," "]);function wI({projectId:e,project:r,selectedBranch:s,navRequest:i}){let n=r&&!r.path?"remote":void 0,[a,o]=(0,$.useState)(!1),{settings:l}=(0,dh.useConversationSettings)(),c=(0,$.useRef)(null),[d,u]=(0,$.useState)(!1),h=(0,$.useCallback)(()=>{let e=c.current;e&&(e.isCollapsed()?e.expand():e.collapse())},[]),{rootEntries:f,directoryContents:p,expandedDirs:m,selectedFile:g,fileContent:x,fileLoading:v,rootLoading:_,loadingDirs:y,uploadingDirs:b,deletingPaths:w,jumpTarget:S,canGoBack:C,canGoForward:j,fetchRoot:k,refresh:N,reportScroll:E,restoreScroll:D,toggleDirectory:R,navigate:A,jumpTo:M,goBack:F,goForward:T,uploadFiles:P,deleteEntry:B}=function({projectId:e,branch:r,target:s,showHidden:i=!1}){let[n,a]=(0,$.useState)([]),[o,l]=(0,$.useState)(new Map),[c,d]=(0,$.useState)(new Set),[u,h]=(0,$.useState)(null),[f,p]=(0,$.useState)(null),[m,g]=(0,$.useState)(null),x=(0,$.useRef)(0),[v,_]=(0,$.useState)({entries:[],index:-1}),y=(0,$.useRef)(v);y.current=v;let[b,w]=(0,$.useState)(!1),[S,C]=(0,$.useState)(!1),[j,k]=(0,$.useState)(new Set),[N,E]=(0,$.useState)(new Set),[D,R]=(0,$.useState)(new Set),A=(0,$.useRef)(0),M=(0,$.useRef)(0),F=(0,$.useRef)(new wA(50)),T=e?[e,r??"",s??""].join("|"):null,P=(0,$.useRef)(T);P.current=T;let B=(0,$.useRef)(u);B.current=u;let L=(0,$.useRef)(0),I=(0,$.useRef)(null),O=(0,$.useRef)(0),[z,W]=(0,$.useState)(null),H=(0,$.useRef)(null),U=(0,$.useCallback)(i=>[e,r??"",s??"",i].join("\0"),[e,r,s]),K=(0,$.useCallback)(()=>{let e,r,s=P.current;if(!s||I.current!==s)return;let i={selectedFile:B.current,history:y.current,scrollTop:L.current};(e=wT()).views[s]={...i,updatedAt:Date.now()},(r=Object.keys(e.views)).length>30&&r.sort((r,s)=>e.views[r].updatedAt-e.views[s].updatedAt).slice(0,r.length-30).forEach(r=>delete e.views[r]),wP(e)},[]),q=(0,$.useCallback)(()=>{H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{H.current=null,K()},300)},[K]),V=(0,$.useCallback)(e=>{L.current=e,q()},[q]);(0,$.useEffect)(()=>{q()},[u,v,q]);let Y=(0,$.useCallback)(async n=>{if(e&&(d(e=>{let r=new Set(e);return r.has(n)?r.delete(n):r.add(n),r}),!o.has(n))){k(e=>new Set(e).add(n));try{let a=await rv.api.browseProjectDirectory(e,n,r,s,i);l(e=>{let r=new Map(e);return r.set(n,a.items),r})}catch(e){console.error("Failed to browse directory:",e),xg.toast.error(`Failed to open ${n}`,{description:e instanceof Error?e.message:String(e)})}finally{k(e=>{let r=new Set(e);return r.delete(n),r})}}},[e,r,s,i,o]),G=(0,$.useCallback)(async i=>{if(!e)return"failed";let n=U(i),a=F.current.get(n);if(a)return p(a),w(!1),"loaded";let o=++M.current;w(!0),p(null);try{let a=await rv.api.getFileContent(e,i,r,s);if(o!==M.current)return"stale";return F.current.set(n,a),p(a),"loaded"}catch(e){if(o!==M.current)return"stale";return console.error("Failed to get file content:",e),p(null),"failed"}finally{o===M.current&&w(!1)}},[e,r,s,U]),X=(0,$.useCallback)(async r=>{e&&(h(r),await G(r))},[e,G]),J=(0,$.useCallback)(async()=>{if(!e)return!1;C(!0);let n=++A.current;try{let o=await rv.api.browseProjectDirectory(e,void 0,r,s,i);if(n!==A.current)return!1;return a(o.items),l(new Map),d(new Set),!0}catch(e){if(console.error("Failed to browse root directory:",e),n!==A.current)return!1;return a([]),xg.toast.error("Failed to browse files",{description:e instanceof Error?e.message:String(e)}),!1}finally{n===A.current&&C(!1)}},[e,r,s,i]),Z=(0,$.useCallback)(async()=>{let r;if(!e||!await J())return;let s=P.current,i=s?(r=wT().views[s])&&"object"==typeof r&&(null===r.selectedFile||"string"==typeof r.selectedFile)&&r.history&&"object"==typeof r.history&&Array.isArray(r.history.entries)&&"number"==typeof r.history.index?{selectedFile:r.selectedFile,history:r.history,scrollTop:"number"==typeof r.scrollTop&&Number.isFinite(r.scrollTop)?r.scrollTop:0}:null:null;if(s&&i&&i.selectedFile){if(_(i.history.entries.length?i.history:{entries:[{path:i.selectedFile,line:null}],index:0}),L.current=i.scrollTop,W({top:i.scrollTop,nonce:++O.current}),h(i.selectedFile),I.current=s,"failed"===await G(i.selectedFile)){let e;h(null),_({entries:[],index:-1}),L.current=0,(e=wT()).views[s]&&(delete e.views[s],wP(e))}}else h(null),p(null),_({entries:[],index:-1}),L.current=0,I.current=s},[e,J,G]),Q=(0,$.useCallback)(async()=>{if(!e||(F.current.clear(),!await J()))return;let r=B.current;r&&await G(r)},[e,J,G]),ee=(0,$.useCallback)(async(e,r=null)=>{_(({entries:s,index:i})=>{let n=s[i];if(n&&n.path===e){let n=s.slice();return n[i]={path:e,line:r},{entries:n,index:i}}let a=s.slice(0,i+1);return{entries:[...a,{path:e,line:r}],index:a.length}}),await X(e),null!=r&&g({line:r,nonce:++x.current})},[X]),et=(0,$.useCallback)((e,r)=>ee(e,r),[ee]),er=(0,$.useCallback)(()=>{let{entries:e,index:r}=y.current;if(r<=0)return;let s=e[r-1];_(e=>({...e,index:e.index-1})),X(s.path),null!=s.line&&g({line:s.line,nonce:++x.current})},[X]),es=(0,$.useCallback)(()=>{let{entries:e,index:r}=y.current;if(r>=e.length-1)return;let s=e[r+1];_(e=>({...e,index:e.index+1})),X(s.path),null!=s.line&&g({line:s.line,nonce:++x.current})},[X]),ei=(0,$.useCallback)(async n=>{if(e)if(""===n)a((await rv.api.browseProjectDirectory(e,void 0,r,s,i)).items);else{let a=await rv.api.browseProjectDirectory(e,n,r,s,i);l(e=>{let r=new Map(e);return r.set(n,a.items),r})}},[e,r,s,i]),en=(0,$.useCallback)(async(i,n)=>{if(e&&0!==n.length){E(e=>new Set(e).add(i));try{let{uploaded:a}=await rv.api.uploadFiles(e,n,i,r,s),o=new Set(a.map(e=>i?`${i}/${e}`:e));F.current.deleteWhere(e=>o.has(wB(e))),""!==i&&d(e=>new Set(e).add(i)),await ei(i),xg.toast.success(`Uploaded ${a.length} file${1===a.length?"":"s"}`)}catch(e){console.error("Failed to upload files:",e),xg.toast.error("Upload failed",{description:e instanceof Error?e.message:String(e)})}finally{E(e=>{let r=new Set(e);return r.delete(i),r})}}},[e,r,s,ei]),ea=(0,$.useCallback)(async i=>{if(e&&i){R(e=>new Set(e).add(i));try{await rv.api.deleteFile(e,i,r,s),F.current.deleteWhere(e=>{let r=wB(e);return r===i||r.startsWith(`${i}/`)}),h(e=>e===i||e&&e.startsWith(`${i}/`)?(p(null),null):e);let n=i.includes("/")?i.slice(0,i.lastIndexOf("/")):"";await ei(n),xg.toast.success("Deleted")}catch(e){console.error("Failed to delete:",e),xg.toast.error("Delete failed",{description:e instanceof Error?e.message:String(e)})}finally{R(e=>{let r=new Set(e);return r.delete(i),r})}}},[e,r,s,ei]);return{rootEntries:n,directoryContents:o,expandedDirs:c,selectedFile:u,fileContent:f,fileLoading:b,rootLoading:S,loadingDirs:j,uploadingDirs:N,deletingPaths:D,jumpTarget:m,canGoBack:v.index>0,canGoForward:v.index<v.entries.length-1,fetchRoot:Z,refresh:Q,reportScroll:V,restoreScroll:z,toggleDirectory:Y,selectFile:X,navigate:ee,jumpTo:et,goBack:er,goForward:es,uploadFiles:en,refreshDirectory:ei,deleteEntry:ea}}({projectId:e,branch:s,target:n,showHidden:a}),L=function({projectId:e,branch:r,target:s}){let[i,n]=(0,$.useState)([]),[a,o]=(0,$.useState)(!1),[l,c]=(0,$.useState)(!1),[d,u]=(0,$.useState)(!1),[h,f]=(0,$.useState)(""),p=(0,$.useRef)(0);(0,$.useEffect)(()=>{n([]),o(!1),u(!1),c(!1),f(""),p.current++},[e,r,s]);let m=(0,$.useCallback)(async()=>{if(!e)return;c(!0);let i=++p.current;try{let a=await rv.api.listProjectFiles(e,r,s);if(i!==p.current)return;n(a.files),o(a.truncated),u(!0)}catch(e){if(i!==p.current)return;n([]),u(!1),xg.toast.error("Failed to load file list",{description:e instanceof Error?e.message:String(e)})}finally{i===p.current&&c(!1)}},[e,r,s]),g=(0,$.useCallback)(()=>{d||l||m()},[d,l,m]),x=(0,$.useCallback)(()=>{u(!1),p.current++,h&&m()},[h,m]),v=(0,$.useDeferredValue)(h);return{query:h,setQuery:f,results:(0,$.useMemo)(()=>(function(e,r,s){if(!r.trim())return[];let i=[];for(let s of e){let e=function(e,r){let s=e.toLowerCase().replace(/\s+/g,"");if(!s)return null;let i=r.toLowerCase(),n=r.lastIndexOf("/")+1,a=0,o=0,l=-2;for(let e=0;e<s.length;e++){let c=s[e],d=-1;for(;o<i.length;o++)if(i[o]===c){d=o;break}if(-1===d)return null;let u=1;d===l+1&&(u+=5),d>=n&&(u+=3);let h=d>0?r[d-1]:"/";(0===d||d===n||wL.has(h))&&(u+=4),a+=u,l=d,o=d+1}return a+.1*Math.max(0,40-r.length)}(r,s);null!==e&&i.push({path:s,score:e})}return i.sort((e,r)=>r.score-e.score||e.path.length-r.path.length),i.slice(0,50)})(i,v,0),[i,v]),truncated:a,loading:l,loaded:d,ensureLoaded:g,refresh:x}}({projectId:e,branch:s,target:n});(0,$.useEffect)(()=>{k()},[k]),(0,$.useEffect)(()=>{i&&(null!=i.line?M(i.path,i.line):A(i.path))},[i?.nonce]);let I=(0,$.useCallback)(()=>{N(),L.refresh()},[N,L]),O=(0,$.useCallback)(e=>{A(e),L.setQuery("")},[A,L]);if(!e)return(0,z.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:(0,z.jsxs)("div",{className:"text-center",children:[(0,z.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,z.jsx)(_v,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,z.jsx)("p",{className:"text-sm",children:"Select a project to browse files."})]})});let H=g&&e?rv.api.getFileDownloadUrl(e,g,s,n):null;return(0,z.jsxs)("div",{className:"flex flex-col h-full",style:{"--files-tree-font-size":`${l.filesTreeFontSize}px`,"--files-content-font-size":`${l.filesContentFontSize}px`},children:[(0,z.jsx)(lb,{title:"Files",actions:(0,z.jsxs)("div",{className:"flex items-center gap-1",children:[(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:h,title:d?"Show file tree":"Hide file tree","aria-pressed":!d,children:d?(0,z.jsx)(_W,{className:"h-3.5 w-3.5"}):(0,z.jsx)(_$,{className:"h-3.5 w-3.5"})}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:`h-7 w-7 hover:text-foreground ${a?"text-foreground":"text-muted-foreground"}`,onClick:()=>o(e=>!e),title:a?"Hide hidden files":"Show hidden files","aria-pressed":a,children:a?(0,z.jsx)(_O,{className:"h-3.5 w-3.5"}):(0,z.jsx)(_z,{className:"h-3.5 w-3.5"})}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:F,disabled:!C,title:"Back",children:(0,z.jsx)(_H.ArrowLeft,{className:"h-3.5 w-3.5"})}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:T,disabled:!j,title:"Forward",children:(0,z.jsx)(_U,{className:"h-3.5 w-3.5"})}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:I,title:"Refresh",children:(0,z.jsx)(_v,{className:`h-3.5 w-3.5 ${_?"animate-spin":""}`})})]})}),(0,z.jsxs)(yQ,{direction:"horizontal",autoSaveId:"files-panels",className:"flex-1",children:[(0,z.jsx)(_2,{ref:c,collapsible:!0,collapsedSize:0,defaultSize:33,minSize:20,onCollapse:()=>u(!0),onExpand:()=>u(!1),children:(0,z.jsxs)(bR,{shouldFilter:!1,className:"flex h-full flex-col bg-transparent",children:[(0,z.jsx)("div",{className:"border-b p-2",children:(0,z.jsxs)(y1,{children:[(0,z.jsx)(y5,{children:(0,z.jsx)(dt,{className:"h-3.5 w-3.5"})}),(0,z.jsx)(y6,{type:"search",name:"files-search",autoComplete:"off","data-1p-ignore":!0,"data-lpignore":"true","data-form-type":"other",readOnly:!0,onFocus:e=>{e.currentTarget.removeAttribute("readonly"),L.ensureLoaded()},placeholder:"Search files...",value:L.query,onChange:e=>L.setQuery(e.target.value)}),L.query&&(0,z.jsx)(y5,{align:"inline-end",children:(0,z.jsx)(y4,{size:"icon-xs","aria-label":"Clear search",onClick:()=>L.setQuery(""),children:(0,z.jsx)(t8,{className:"h-3.5 w-3.5"})})})]})}),L.query?(0,z.jsx)(bF,{className:"max-h-none flex-1",children:L.loading&&0===L.results.length?(0,z.jsxs)("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin"}),"Loading files…"]}):0===L.results.length?(0,z.jsx)("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"No matching files."}):(0,z.jsxs)(z.Fragment,{children:[L.results.map(e=>{let r=e.path.lastIndexOf("/"),s=r>=0?e.path.slice(0,r+1):"",i=r>=0?e.path.slice(r+1):e.path;return(0,z.jsxs)(bB,{value:e.path,onSelect:()=>O(e.path),className:"flex-col items-start gap-0 text-[length:var(--files-tree-font-size,14px)]!",children:[(0,z.jsx)("span",{className:"font-medium",children:i}),s&&(0,z.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:s})]},e.path)}),L.truncated&&(0,z.jsx)("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"Showing first 50,000 files — refine your search to narrow results."})]})}):(0,z.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,z.jsx)(bV,{entries:f,expandedDirs:m,directoryContents:p,loadingDirs:y,selectedFile:g,uploadingDirs:b,rootLoading:_,deletingPaths:w,onToggleDirectory:R,onSelectFile:A,onUploadFiles:P,onDeleteEntry:B})})]})}),(0,z.jsx)(y0,{withHandle:!0}),(0,z.jsx)(_2,{defaultSize:67,minSize:25,children:(0,z.jsx)("div",{className:"h-full overflow-hidden",children:(0,z.jsx)(wR,{filePath:g,fileContent:x,loading:v,downloadUrl:H,projectId:e,branch:s,target:n,scrollToLine:S?.line??null,scrollKey:S?.nonce,onJump:M,restoreScrollTop:D?.top??null,restoreScrollKey:D?.nonce,onScroll:E})})})]})]})}let wO=(0,$.createContext)(null),wz={openFile:()=>{},index:null};function w$(){return(0,$.useContext)(wO)??wz}let wW=wO.Provider,wH=0;function wU(e){let r=e.lastIndexOf("/");return r>=0?e.slice(r+1):e}let wK=[500,1e3,2e3,4e3,8e3];async function wq(e,r={}){let s=r.delaysMs??wK,i=r.sleep??(e=>new Promise(r=>setTimeout(r,e))),n=r.cancelled??(()=>!1);for(let r=0;;r++){if(n())return null;let a=null;try{a=await e()}catch{a=null}if(n())return null;if(a&&a.files.length>0||r>=s.length)return a;await i(s[r])}}function wV({projectId:e,selectedBranch:r,onMergeRequest:s,project:i,onExecutorModeChange:n,agentSlot:a,activateAgentTabNonce:o,diffCompareNonce:l,mergeTarget:c,active:d=!0}){let[u,h]=function(e,r){let s=`vibedeckx:activeTab:${e??"none"}:${r??"main"}`,[i,n]=(0,$.useState)(()=>localStorage.getItem(s)??"agent");return(0,$.useEffect)(()=>{n(localStorage.getItem(s)??"agent")},[s]),[i,(0,$.useCallback)(e=>{n(e),localStorage.setItem(s,e)},[s])]}(e,r),f=(0,$.useRef)(o);(0,$.useEffect)(()=>{void 0===o||f.current!==o&&(f.current=o,h("agent"))},[o,h]);let p=(0,$.useRef)(l);(0,$.useEffect)(()=>{void 0===l||p.current!==l&&(p.current=l,h("diff"))},[l,h]);let m=function({projectId:e,branch:r,target:s,enabled:i=!0}){let[n,a]=(0,$.useState)(null),o=(0,$.useRef)(0);return(0,$.useEffect)(()=>{if(a(null),!i||!e)return;let n=++o.current;wq(()=>rv.api.listProjectFiles(e,r,s),{cancelled:()=>n!==o.current}).then(e=>{n===o.current&&e&&a(function(e){let r=`idx-${++wH}`,s=new Set(e),i=new Map;for(let r of e){let e=wU(r),s=i.get(e);s?s.push(r):i.set(e,[r])}return{version:r,resolve(e){if(!e)return[];let r=e.replace(/^\/+/,"");if(!r)return[];if(r.includes("/")){if(s.has(r))return[r];let e=wU(r);return(i.get(e)??[]).filter(e=>e===r||e.endsWith("/"+r)||r.endsWith("/"+e))}return i.get(r)??[]}}}(e.files))})},[e,r,s,i]),n}({projectId:e,branch:r,target:i&&!i.path?"remote":void 0,enabled:d}),g=(0,$.useRef)(0),[x,v]=(0,$.useState)(null),_=(0,$.useCallback)((e,r=null)=>{h("files"),v({path:e,line:r,nonce:++g.current})},[h]),y=(0,$.useMemo)(()=>({openFile:_,index:m}),[_,m]);return(0,z.jsx)(wW,{value:y,children:(0,z.jsxs)("div",{className:"h-full flex flex-col",children:[(0,z.jsx)("div",{className:"flex items-center px-3 gap-4 border-b border-border",children:[{id:"agent",icon:aE,label:"Agent"},{id:"executors",icon:aN,label:"Executors"},{id:"diff",icon:rw,label:"Diff"},{id:"terminal",icon:dl,label:"Terminal"},{id:"preview",icon:ry,label:"Browser"},{id:"files",icon:r_,label:"Files"}].map(({id:e,icon:r,label:s})=>(0,z.jsxs)($.Fragment,{children:[(0,z.jsxs)("button",{onClick:()=>h(e),className:(0,ey.cn)("flex items-center gap-0.5 py-2.5 text-xs font-medium border-b-2 transition-colors",u===e?"text-foreground border-primary":"text-muted-foreground border-transparent hover:text-foreground/70"),children:[(0,z.jsx)(r,{className:"h-3.5 w-3.5"}),s]}),"agent"===e&&(0,z.jsx)("span",{className:"h-4 w-px bg-border/60 mx-1.5","aria-hidden":!0})]},e))}),(0,z.jsxs)("div",{className:"relative flex-1 overflow-hidden",children:[(0,z.jsx)("div",{className:(0,ey.cn)("absolute inset-0 overflow-hidden","agent"!==u&&"invisible pointer-events-none"),children:a}),(0,z.jsx)("div",{className:(0,ey.cn)("absolute inset-0 overflow-hidden","executors"!==u&&"hidden"),children:(0,z.jsx)(_x,{projectId:e,selectedBranch:r,project:i,onExecutorModeChange:n})}),(0,z.jsx)("div",{className:(0,ey.cn)("absolute inset-0 overflow-hidden","diff"!==u&&"hidden"),children:(0,z.jsx)(_E,{projectId:e,selectedBranch:r,onMergeRequest:s,project:i,mergeTarget:c,compareRequestNonce:l})}),(0,z.jsx)("div",{className:(0,ey.cn)("absolute inset-0 overflow-hidden","terminal"!==u&&"hidden"),children:(0,z.jsx)(_R,{projectId:e,selectedBranch:r,project:i})}),(0,z.jsx)("div",{className:(0,ey.cn)("absolute inset-0 overflow-hidden","preview"!==u&&"hidden"),children:(0,z.jsx)(_I,{projectId:e,selectedBranch:r,project:i})}),(0,z.jsx)("div",{className:(0,ey.cn)("absolute inset-0 overflow-hidden","files"!==u&&"hidden"),children:(0,z.jsx)(wI,{projectId:e,project:i,selectedBranch:r,navRequest:x})})]})]})})}var wY=Symbol.for("immer-nothing"),wG=Symbol.for("immer-draftable"),wX=Symbol.for("immer-state");function wJ(e){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var wZ=Object.getPrototypeOf;function wQ(e){return!!e&&!!e[wX]}function w0(e){return!!e&&(w5(e)||Array.isArray(e)||!!e[wG]||!!e.constructor?.[wG]||w7(e)||w9(e))}var w1=Object.prototype.constructor.toString(),w2=new WeakMap;function w5(e){if(!e||"object"!=typeof e)return!1;let r=Object.getPrototypeOf(e);if(null===r||r===Object.prototype)return!0;let s=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;if(s===Object)return!0;if("function"!=typeof s)return!1;let i=w2.get(s);return void 0===i&&(i=Function.toString.call(s),w2.set(s,i)),i===w1}function w3(e,r,s=!0){0===w4(e)?(s?Reflect.ownKeys(e):Object.keys(e)).forEach(s=>{r(s,e[s],e)}):e.forEach((s,i)=>r(i,s,e))}function w4(e){let r=e[wX];return r?r.type_:Array.isArray(e)?1:w7(e)?2:3*!!w9(e)}function w6(e,r){return 2===w4(e)?e.has(r):Object.prototype.hasOwnProperty.call(e,r)}function w8(e,r,s){let i=w4(e);2===i?e.set(r,s):3===i?e.add(s):e[r]=s}function w7(e){return e instanceof Map}function w9(e){return e instanceof Set}function Se(e){return e.copy_||e.base_}function St(e,r){if(w7(e))return new Map(e);if(w9(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let s=w5(e);if(!0!==r&&("class_only"!==r||s)){let r=wZ(e);return null!==r&&s?{...e}:Object.assign(Object.create(r),e)}{let r=Object.getOwnPropertyDescriptors(e);delete r[wX];let s=Reflect.ownKeys(r);for(let i=0;i<s.length;i++){let n=s[i],a=r[n];!1===a.writable&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[n]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[n]})}return Object.create(wZ(e),r)}}function Sr(e,r=!1){return Si(e)||wQ(e)||!w0(e)||(w4(e)>1&&Object.defineProperties(e,{set:Ss,add:Ss,clear:Ss,delete:Ss}),Object.freeze(e),r&&Object.values(e).forEach(e=>Sr(e,!0))),e}var Ss={value:function(){wJ(2)}};function Si(e){return null===e||"object"!=typeof e||Object.isFrozen(e)}var Sn={};function Sa(e){let r=Sn[e];return r||wJ(0,e),r}function So(e,r){r&&(Sa("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=r)}function Sl(e){Sc(e),e.drafts_.forEach(Su),e.drafts_=null}function Sc(e){e===I&&(I=e.parent_)}function Sd(e){return I={drafts_:[],parent_:I,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Su(e){let r=e[wX];0===r.type_||1===r.type_?r.revoke_():r.revoked_=!0}function Sh(e,r){r.unfinalizedDrafts_=r.drafts_.length;let s=r.drafts_[0];return void 0!==e&&e!==s?(s[wX].modified_&&(Sl(r),wJ(4)),w0(e)&&(e=Sf(r,e),r.parent_||Sm(r,e)),r.patches_&&Sa("Patches").generateReplacementPatches_(s[wX].base_,e,r.patches_,r.inversePatches_)):e=Sf(r,s,[]),Sl(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),e!==wY?e:void 0}function Sf(e,r,s){if(Si(r))return r;let i=e.immer_.shouldUseStrictIteration(),n=r[wX];if(!n)return w3(r,(i,a)=>Sp(e,n,r,i,a,s),i),r;if(n.scope_!==e)return r;if(!n.modified_)return Sm(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;let r=n.copy_,a=r,o=!1;3===n.type_&&(a=new Set(r),r.clear(),o=!0),w3(a,(i,a)=>Sp(e,n,r,i,a,s,o),i),Sm(e,r,!1),s&&e.patches_&&Sa("Patches").generatePatches_(n,s,e.patches_,e.inversePatches_)}return n.copy_}function Sp(e,r,s,i,n,a,o){if(null==n||"object"!=typeof n&&!o)return;let l=Si(n);if(!l||o){if(wQ(n)){let o=Sf(e,n,a&&r&&3!==r.type_&&!w6(r.assigned_,i)?a.concat(i):void 0);if(w8(s,i,o),!wQ(o))return;e.canAutoFreeze_=!1}else o&&s.add(n);if(w0(n)&&!l){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||r&&r.base_&&r.base_[i]===n&&l)return;Sf(e,n),(!r||!r.scope_.parent_)&&"symbol"!=typeof i&&(w7(s)?s.has(i):Object.prototype.propertyIsEnumerable.call(s,i))&&Sm(e,n)}}}function Sm(e,r,s=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Sr(r,s)}var Sg={get(e,r){if(r===wX)return e;let s=Se(e);if(!w6(s,r)){var i;let n;return i=e,(n=S_(s,r))?"value"in n?n.value:n.get?.call(i.draft_):void 0}let n=s[r];return e.finalized_||!w0(n)?n:n===Sv(e.base_,r)?(Sb(e),e.copy_[r]=Sw(n,e)):n},has:(e,r)=>r in Se(e),ownKeys:e=>Reflect.ownKeys(Se(e)),set(e,r,s){let i=S_(Se(e),r);if(i?.set)return i.set.call(e.draft_,s),!0;if(!e.modified_){let i=Sv(Se(e),r),n=i?.[wX];if(n&&n.base_===s)return e.copy_[r]=s,e.assigned_[r]=!1,!0;if((s===i?0!==s||1/s==1/i:s!=s&&i!=i)&&(void 0!==s||w6(e.base_,r)))return!0;Sb(e),Sy(e)}return!!(e.copy_[r]===s&&(void 0!==s||r in e.copy_)||Number.isNaN(s)&&Number.isNaN(e.copy_[r]))||(e.copy_[r]=s,e.assigned_[r]=!0,!0)},deleteProperty:(e,r)=>(void 0!==Sv(e.base_,r)||r in e.base_?(e.assigned_[r]=!1,Sb(e),Sy(e)):delete e.assigned_[r],e.copy_&&delete e.copy_[r],!0),getOwnPropertyDescriptor(e,r){let s=Se(e),i=Reflect.getOwnPropertyDescriptor(s,r);return i?{writable:!0,configurable:1!==e.type_||"length"!==r,enumerable:i.enumerable,value:s[r]}:i},defineProperty(){wJ(11)},getPrototypeOf:e=>wZ(e.base_),setPrototypeOf(){wJ(12)}},Sx={};function Sv(e,r){let s=e[wX];return(s?Se(s):e)[r]}function S_(e,r){if(!(r in e))return;let s=wZ(e);for(;s;){let e=Object.getOwnPropertyDescriptor(s,r);if(e)return e;s=wZ(s)}}function Sy(e){!e.modified_&&(e.modified_=!0,e.parent_&&Sy(e.parent_))}function Sb(e){e.copy_||(e.copy_=St(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function Sw(e,r){let s=w7(e)?Sa("MapSet").proxyMap_(e,r):w9(e)?Sa("MapSet").proxySet_(e,r):function(e,r){let s=Array.isArray(e),i={type_:+!!s,scope_:r?r.scope_:I,modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},n=i,a=Sg;s&&(n=[i],a=Sx);let{revoke:o,proxy:l}=Proxy.revocable(n,a);return i.draft_=l,i.revoke_=o,l}(e,r);return(r?r.scope_:I).drafts_.push(s),s}w3(Sg,(e,r)=>{Sx[e]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),Sx.deleteProperty=function(e,r){return Sx.set.call(this,e,r,void 0)},Sx.set=function(e,r,s){return Sg.set.call(this,e[0],r,s,e[0])};var SS=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,r,s)=>{let i;if("function"==typeof e&&"function"!=typeof r){let s=r;r=e;let i=this;return function(e=s,...n){return i.produce(e,e=>r.call(this,e,...n))}}if("function"!=typeof r&&wJ(6),void 0!==s&&"function"!=typeof s&&wJ(7),w0(e)){let n=Sd(this),a=Sw(e,void 0),o=!0;try{i=r(a),o=!1}finally{o?Sl(n):Sc(n)}return So(n,s),Sh(i,n)}if(e&&"object"==typeof e)wJ(1,e);else{if(void 0===(i=r(e))&&(i=e),i===wY&&(i=void 0),this.autoFreeze_&&Sr(i,!0),s){let r=[],n=[];Sa("Patches").generateReplacementPatches_(e,i,r,n),s(r,n)}return i}},this.produceWithPatches=(e,r)=>{let s,i;return"function"==typeof e?(r,...s)=>this.produceWithPatches(r,r=>e(r,...s)):[this.produce(e,r,(e,r)=>{s=e,i=r}),s,i]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),"boolean"==typeof e?.useStrictIteration&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){var r;w0(e)||wJ(8),wQ(e)&&(wQ(r=e)||wJ(10,r),e=function e(r){let s;if(!w0(r)||Si(r))return r;let i=r[wX],n=!0;if(i){if(!i.modified_)return i.base_;i.finalized_=!0,s=St(r,i.scope_.immer_.useStrictShallowCopy_),n=i.scope_.immer_.shouldUseStrictIteration()}else s=St(r,!0);return w3(s,(r,i)=>{w8(s,r,e(i))},n),i&&(i.finalized_=!1),s}(r));let s=Sd(this),i=Sw(e,void 0);return i[wX].isManual_=!0,Sc(s),i}finishDraft(e,r){let s=e&&e[wX];s&&s.isManual_||wJ(9);let{scope_:i}=s;return So(i,r),Sh(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,r){let s;for(s=r.length-1;s>=0;s--){let i=r[s];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}s>-1&&(r=r.slice(s+1));let i=Sa("Patches").applyPatches_;return wQ(e)?i(e,r):this.produce(e,e=>i(e,r))}}().produce;let SC="vibedeckx:placeholder-workspaces";function Sj(e){try{window.localStorage.setItem(SC,JSON.stringify([...e]))}catch{}}let Sk=function(){try{let e=window.localStorage.getItem(SC);if(!e)return new Map;let r=JSON.parse(e);if(!Array.isArray(r))return new Map;let s=new Map;for(let e of r)Array.isArray(e)&&"string"==typeof e[0]&&"number"==typeof e[1]?s.set(e[0],e[1]):"string"==typeof e&&s.set(e,Date.now());return s}catch{return new Map}}(),SN=new Set,SE=new Map;function SD(){for(let e of SN)e()}function SR(e){return SN.add(e),()=>{SN.delete(e)}}function SA(){return Sk}function SM(){return SE}function SF(e,r,s){return`${e}:${r??""}:${s??""}`}function ST(e){if(!Sk.has(e))return!1;let r=new Map(Sk);return r.delete(e),Sj(Sk=r),SD(),!0}function SP(){return"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}async function SB(e,r,s,i){let n=await (0,rv.authFetch)(`${SP()}/api/projects/${e}/agent-sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:r,permissionMode:s,agentType:i})});if(!n.ok)throw Error("Failed to load session");return n.json()}async function SL(e,r){let s=await (0,rv.authFetch)(`${SP()}/api/agent-sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r})});if(!s.ok){let r="";try{let e=await s.json();if(e.errorCode){let s=[`${e.errorCode}`];e.attempts&&s.push(`${e.attempts} attempts`),e.totalDurationMs&&s.push(`${(e.totalDurationMs/1e3).toFixed(1)}s`),r=` (${s.join(", ")})`}else e.error&&(r=` — ${e.error}`)}catch{}throw console.error(`[AgentSession] /message failed: status=${s.status}, sessionId=${e}, detail=${r}`),Error(`Failed to send message [${s.status}]${r}`)}}async function SI(e,r){let s=await (0,rv.authFetch)(`${SP()}/api/agent-sessions/${e}/paste`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r})});if(!s.ok){let r="";try{let e=await s.json();if(e.errorCode){let s=[`${e.errorCode}`];e.attempts&&s.push(`${e.attempts} attempts`),e.totalDurationMs&&s.push(`${(e.totalDurationMs/1e3).toFixed(1)}s`),r=` (${s.join(", ")})`}else e.error&&(r=` — ${e.error}`)}catch{}throw console.error(`[AgentSession] /paste failed: status=${s.status}, sessionId=${e}, detail=${r}`),Error(`Failed to upload paste [${s.status}]${r}`)}return s.json()}async function SO(e,r){if(!(await (0,rv.authFetch)(`${SP()}/api/agent-sessions/${e}/restart`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentType:r})})).ok)throw Error("Failed to restart session")}async function Sz(e,r){let s=await (0,rv.authFetch)(`${SP()}/api/agent-sessions/${e}/agent-type`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentType:r})});if(!s.ok){let e="";try{let r=await s.json();r.error&&(e=r.error)}catch{}throw Error(e||`Failed to switch agent [${s.status}]`)}}async function S$(e){if(!(await (0,rv.authFetch)(`${SP()}/api/agent-sessions/${e}/stop`,{method:"POST"})).ok)throw Error("Failed to stop session")}async function SW(e,r){if(!(await (0,rv.authFetch)(`${SP()}/api/agent-sessions/${e}/switch-mode`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:r})})).ok)throw Error("Failed to switch mode")}async function SH(e,r){if(!(await (0,rv.authFetch)(`${SP()}/api/agent-sessions/${e}/accept-plan`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({planContent:r})})).ok)throw Error("Failed to accept plan")}let SU=new Map;function SK(e,r,s){return`${e}:${r??""}:${s??"latest"}`}async function Sq(e){let r=await (0,rv.authFetch)(`${SP()}/api/agent-sessions/${e}`);if(!r.ok)throw Error(`Session ${e} not found`);return r.json()}let SV=(0,ew.default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),SY=(0,ew.default)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]),SG=(0,ew.default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]),SX=(0,ew.default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),SJ=(0,ew.default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),SZ=(0,ew.default)("file-check",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]),SQ=(0,ew.default)("folder-search",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]),S0=(0,ew.default)("workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]),S1=(0,ew.default)("file-pen-line",[["path",{d:"m18.226 5.226-2.52-2.52A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.351",key:"1k2beg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]),S2=(0,ew.default)("file-plus-corner",[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]]),S5=(0,ew.default)("earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),S3=(0,ew.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);var oF=oM,b4=oM;let S4=RegExp("(?<![\\w./-])([\\w-]+(?:[./][\\w-]+)+)(?::(\\d+)(?::\\d+)?|#L(\\d+)(?:-L?\\d+)?)?","g"),S6=/\[([^\]\n]*)\]\(\s*([^)\s]+?)\s*\)/g;function S8(e){return e.includes("/")||/\.[A-Za-z0-9]+$/.test(e)}function S7(e){let r=e.trim();if(!r)return null;let s=/^(.*?)(?::(\d+)(?::\d+)?|#L(\d+)(?:-L?\d+)?)?$/.exec(r);if(!s||!s[1])return null;let i=s[1];return/^[a-z][a-z0-9+.-]*:/i.test(i)||i.startsWith("//")||i.startsWith("#")?null:{rawPath:i,line:s[2]?Number(s[2]):s[3]?Number(s[3]):null}}function S9(e){let r=r=>e.index?e.index.resolve(r):[];function s(e,r,s){return{type:"element",tagName:"a",properties:{className:["file-ref"],href:"#file-ref",dataFilePaths:JSON.stringify(e),...null!=r?{dataFileLine:String(r)}:{}},children:s}}return e=>{!function e(i,n=!1){if(!i.children)return;let a=n||"pre"===i.tagName,o=[];for(let n of i.children)"text"===n.type?a?o.push(n):o.push(...function(e){let i=function(e){let r,s=[],i=[];for(S6.lastIndex=0;null!==(r=S6.exec(e));){let e=S7(r[2]);if(!e||!S8(e.rawPath))continue;let n=r.index,a=r.index+r[0].length;s.push({start:n,end:a,rawPath:e.rawPath,line:e.line,display:r[1]||void 0}),i.push([n,a])}for(S4.lastIndex=0;null!==(r=S4.exec(e));){let e=r.index;if(i.some(([r,s])=>e>=r&&e<s))continue;let n=r[1];if(!S8(n))continue;let a=r[2]?Number(r[2]):r[3]?Number(r[3]):null;s.push({start:e,end:e+r[0].length,rawPath:n,line:a})}return s.sort((e,r)=>e.start-r.start),s}(e);if(0===i.length)return[{type:"text",value:e}];let n=[],a=0,o=!1;for(let l of i){let i=r(l.rawPath);if(0===i.length)continue;l.start>a&&n.push({type:"text",value:e.slice(a,l.start)});let c=l.display??e.slice(l.start,l.end);n.push(s(i,l.line,[{type:"text",value:c}])),a=l.end,o=!0}return o?(a<e.length&&n.push({type:"text",value:e.slice(a)}),n):[{type:"text",value:e}]}(n.value??"")):"element"===n.type&&"pre"===n.tagName?(e(n,!0),o.push(n)):"element"!==n.type||"a"!==n.tagName||a?(e(n,a),o.push(n)):o.push(...function(e){let i=S7(String(e.properties?.href??""));if(!i)return[e];let n=r(i.rawPath);return 0===n.length?e.children??[]:[s(n,i.line,e.children??[])]}(n));i.children=o}(e)}}let Ce="text-primary underline decoration-dotted underline-offset-2 cursor-pointer hover:decoration-solid";function Ct({node:e,children:r,href:s,...i}){let{openFile:n}=w$(),a=e?.properties?.dataFilePaths;if(!a)return"string"==typeof s&&s.startsWith("#")?(0,z.jsx)("a",{href:s,...i,children:r}):(0,z.jsx)("a",{href:s,target:"_blank",rel:"noreferrer noopener",...i,children:r});let o=[];try{o=JSON.parse(a)}catch{o=[]}let l=e?.properties?.dataFileLine,c=null!=l?Number(l):null;return o.length<=1?(0,z.jsx)("a",{href:"#",className:Ce,onClick:e=>{e.preventDefault(),o[0]&&n(o[0],c)},children:r}):(0,z.jsx)(Cr,{paths:o,line:c,children:r})}function Cr({paths:e,line:r,children:s}){let{openFile:i}=w$();return(0,z.jsxs)(ap,{children:[(0,z.jsx)(am,{asChild:!0,children:(0,z.jsx)("a",{href:"#",className:Ce,onClick:e=>e.preventDefault(),children:s})}),(0,z.jsxs)(ag,{align:"start",className:"max-w-md",children:[(0,z.jsxs)(ab,{children:[e.length," matching files"]}),e.map(e=>(0,z.jsx)(ax,{className:"font-mono text-xs",onSelect:()=>i(e,r),children:e},e))]})]})}let Cs=(0,$.memo)(function({children:e}){let{index:r}=w$(),{harden:s,...i}=b4.e,n=[...Object.values(i),[S9,{index:r}],...s?[s]:[]];return(0,z.jsx)(oF.i,{className:"size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",rehypePlugins:n,components:{a:Ct},children:e},r?.version??"no-file-ref-index")});function Ci({input:e,messageIndex:r}){let{sendMessage:s,messages:i}=kf(),n=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&Array.isArray(r.questions)&&r.questions.length>0&&r.questions.every(e=>"string"==typeof e.question&&"string"==typeof e.header&&Array.isArray(e.options)))return r}catch{}return null}(e),a=i[r+1],o=a?.type==="user",l=o?a.content:"",c="string"==typeof l?l:l.filter(e=>"text"===e.type).map(e=>e.text).join("\n");if(!n){let r="string"==typeof e?e:JSON.stringify(e,null,2);return(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r.length>500?r.substring(0,500)+"...":r})}return o?(0,z.jsx)(Cn,{questions:n.questions,answeredText:c}):(0,z.jsx)(Ca,{questions:n.questions,sendMessage:s})}function Cn({questions:e,answeredText:r}){return(0,z.jsx)("div",{className:"space-y-3 mt-2",children:e.map((e,s)=>(0,z.jsxs)("div",{className:"rounded-lg border bg-muted/30 p-3",children:[(0,z.jsx)("div",{className:"flex items-center gap-2 mb-1.5",children:(0,z.jsx)(sb,{variant:"secondary",className:"text-[10px]",children:e.header})}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground mb-2",children:e.question}),(0,z.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400",children:[(0,z.jsx)(rC,{className:"h-4 w-4"}),(0,z.jsx)("span",{className:"font-medium",children:r})]})]},s))})}function Ca({questions:e,sendMessage:r}){let[s,i]=(0,$.useState)(new Map),[n,a]=(0,$.useState)(new Map),[o,l]=(0,$.useState)(new Set),[c,d]=(0,$.useState)(!1);async function u(){let i=[];for(let r=0;r<e.length;r++)if(o.has(r)){let e=n.get(r)?.trim();e&&i.push(e)}else{let e=s.get(r);e&&e.size>0&&i.push(Array.from(e).join(", "))}if(i.length>0){d(!0);try{await r(i.join("\n"))}finally{d(!1)}}}let h=e.some((e,r)=>{if(o.has(r))return!!n.get(r)?.trim();let i=s.get(r);return i&&i.size>0});return(0,z.jsxs)("div",{className:"space-y-4 mt-2",children:[e.map((e,r)=>{let c=s.get(r)||new Set,d=n.get(r)||"",u=o.has(r);return(0,z.jsxs)("div",{className:"rounded-lg border bg-card p-3",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,z.jsx)(SJ,{className:"h-3.5 w-3.5 text-violet-500"}),(0,z.jsx)(sb,{variant:"secondary",className:"text-[10px]",children:e.header})]}),(0,z.jsx)("p",{className:"text-sm font-medium mb-3",children:e.question}),(0,z.jsxs)("div",{className:"grid gap-2",children:[e.options.map(s=>{let n=c.has(s.label)&&!u;return(0,z.jsx)(W.Button,{variant:n?"default":"outline",className:(0,ey.cn)("h-auto py-2 px-3 justify-start text-left whitespace-normal",n&&"ring-2 ring-primary/50"),onClick:()=>{var n,a;return n=s.label,a=e.multiSelect,void(i(e=>{let s=new Map(e),i=new Set(s.get(r)||[]);return a?i.has(n)?i.delete(n):i.add(n):i.has(n)?i.clear():(i.clear(),i.add(n)),s.set(r,i),s}),l(e=>{let s=new Set(e);return s.delete(r),s}))},children:(0,z.jsxs)("div",{children:[(0,z.jsx)("span",{className:"font-medium text-sm",children:s.label}),s.description&&(0,z.jsx)("span",{className:"block text-xs text-muted-foreground mt-0.5",children:s.description})]})},s.label)}),(0,z.jsx)("div",{className:"flex items-center gap-2 mt-1",children:(0,z.jsx)(ro,{placeholder:"Other...",value:d,onChange:e=>{var s;return s=e.target.value,void(a(e=>new Map(e).set(r,s)),s&&(i(e=>{let s=new Map(e);return s.set(r,new Set),s}),l(e=>new Set(e).add(r))))},className:"text-sm"})})]})]},r)}),(0,z.jsxs)(W.Button,{onClick:u,disabled:!h||c,size:"sm",className:"active:scale-95 transition-transform",children:[c&&(0,z.jsx)(rk,{className:"h-3.5 w-3.5 animate-spin"}),c?"Submitting...":"Submit"]})]})}function Co(e){try{return JSON.parse(e)}catch{return null}}function Cl({input:e,messageIndex:r}){let{messages:s,acceptPlan:i,permissionMode:n,agentType:a}=kf(),[o,l]=(0,$.useState)(!0),[c,d]=(0,$.useState)(!1),u=function(e,r,s){let i="string"==typeof e?Co(e):e;if(i&&"object"==typeof i&&"plan"in i){let e=i.plan;if(e)return e}if("claude-code"===s)for(let e=r.length-1;e>=0;e--){let s=r[e];if("tool_use"===s.type&&"Write"===s.tool){let e="string"==typeof s.input?Co(s.input):s.input;if(e&&"object"==typeof e&&e.file_path?.includes(".claude/plans/")&&e.content)return e.content}}return"Plan written to file"}(e,s,a),h=(0,$.useCallback)(async()=>{d(!0);try{await i(u)}catch{d(!1)}},[i,u]),f="edit"===n,p=!1,m="";for(let e=r+1;e<s.length;e++){let r=s[e];if(r?.type==="user"){p=!0;let e=r.content??"";m="string"==typeof e?e:e.filter(e=>"text"===e.type).map(e=>e.text).join("\n");break}}return(f&&!p&&(p=!0),f||p)?(0,z.jsxs)("div",{className:"space-y-2 mt-2",children:[f?(0,z.jsxs)(sb,{variant:"default",className:"bg-green-600 hover:bg-green-700 text-white",children:[(0,z.jsx)(rC,{className:"h-3 w-3 mr-1"}),"Plan Accepted"]}):(0,z.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,z.jsx)(x_,{className:"h-3.5 w-3.5"}),(0,z.jsxs)("span",{children:["Feedback sent: ",m.length>100?m.substring(0,100)+"...":m]})]}),(0,z.jsxs)("details",{open:!f,children:[(0,z.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"View Plan"}),(0,z.jsx)("div",{className:"mt-2 rounded-lg border p-3 bg-muted/30",children:(0,z.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words",style:{fontSize:"var(--conv-font-size, 14px)"},children:(0,z.jsx)(wc,{children:u})})})]})]}):(0,z.jsxs)("div",{className:"space-y-3 mt-2",children:[(0,z.jsxs)("div",{className:"rounded-lg border p-3 bg-card",children:[(0,z.jsxs)("button",{onClick:()=>l(!o),className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground mb-2 block",children:[o?"Collapse":"Expand"," Plan"]}),o&&(0,z.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words max-h-96 overflow-y-auto",style:{fontSize:"var(--conv-font-size, 14px)"},children:(0,z.jsx)(wc,{children:u})})]}),(0,z.jsxs)(W.Button,{onClick:h,disabled:c,className:"bg-green-600 hover:bg-green-700 text-white",size:"sm",children:[c?(0,z.jsx)(rk,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):(0,z.jsx)(rh,{className:"h-3.5 w-3.5 mr-1.5"}),c?"Accepting Plan...":"Accept Plan & Start Editing"]})]})}function Cc({requestId:e,command:r,cwd:s,messageIndex:i}){let{messages:n,sessionId:a}=kf(),[o,l]=(0,$.useState)(!1),[c,d]=(0,$.useState)(null),u=!1;for(let e=i+1;e<n.length;e++)if(n[e]?.type==="user"){u=!0;break}c&&(u=!0);let h=(0,$.useCallback)(async r=>{if(a){l(!0),d(r);try{await (0,rv.sendApprovalResponse)(a,e,r)}catch{d(null),l(!1)}}},[a,e]);return u?(0,z.jsxs)("div",{className:"space-y-2 mt-2",children:[(0,z.jsxs)("div",{className:"rounded-lg border bg-muted/30 p-3",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,z.jsx)(aN,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,z.jsx)("span",{className:"text-xs text-muted-foreground",children:"Command"})]}),(0,z.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r||"(empty)"}),s&&(0,z.jsxs)("p",{className:"text-xs text-muted-foreground mt-1",children:["cwd: ",s]})]}),(0,z.jsxs)(sb,{variant:"default",className:"decline"===c?"bg-red-600 hover:bg-red-700 text-white":"bg-green-600 hover:bg-green-700 text-white",children:[(0,z.jsx)(rC,{className:"h-3 w-3 mr-1"}),"decline"===c?"Denied":"Allowed"]})]}):(0,z.jsxs)("div",{className:"space-y-2 mt-2",children:[(0,z.jsxs)("div",{className:"rounded-lg border bg-card p-3",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,z.jsx)(aN,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,z.jsx)("span",{className:"text-xs text-muted-foreground",children:"Command"})]}),(0,z.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r||"(empty)"}),s&&(0,z.jsxs)("p",{className:"text-xs text-muted-foreground mt-1",children:["cwd: ",s]})]}),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsxs)(W.Button,{onClick:()=>h("accept"),disabled:o,className:"bg-green-600 hover:bg-green-700 text-white",size:"sm",children:[o&&"accept"===c?(0,z.jsx)(rk,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,z.jsx)(rC,{className:"h-3.5 w-3.5 mr-1"}),"Allow"]}),(0,z.jsxs)(W.Button,{onClick:()=>h("decline"),disabled:o,variant:"destructive",size:"sm",children:[o&&"decline"===c?(0,z.jsx)(rk,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,z.jsx)(rj,{className:"h-3.5 w-3.5 mr-1"}),"Deny"]})]})]})}function Cd({requestId:e,changes:r,messageIndex:s}){let{messages:i,sessionId:n}=kf(),[a,o]=(0,$.useState)(!1),[l,c]=(0,$.useState)(null),d=!1;for(let e=s+1;e<i.length;e++)if(i[e]?.type==="user"){d=!0;break}l&&(d=!0);let u=(0,$.useCallback)(async r=>{if(n){o(!0),c(r);try{await (0,rv.sendApprovalResponse)(n,e,r)}catch{c(null),o(!1)}}},[n,e]),h=r??[],f=()=>(0,z.jsx)("div",{className:"rounded-lg border bg-muted/30 p-3 space-y-2",children:0===h.length?(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:"No file changes"}):h.map((e,r)=>(0,z.jsxs)("div",{children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(bO,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),(0,z.jsx)("code",{className:"text-xs break-all",children:e.path}),(0,z.jsx)(sb,{variant:"secondary",className:`text-[10px] ${function(e){switch(e){case"added":case"add":return"bg-green-500/10 text-green-600";case"deleted":case"delete":return"bg-red-500/10 text-red-600";default:return"bg-blue-500/10 text-blue-600"}}(e.kind)}`,children:function(e){switch(e){case"added":case"add":return"added";case"deleted":case"delete":return"deleted";default:return"modified"}}(e.kind)})]}),e.diff&&(0,z.jsxs)("details",{className:"mt-1",children:[(0,z.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"View diff"}),(0,z.jsx)("pre",{className:"mt-1 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.diff.split("\n").map((e,r)=>{let s="";return e.startsWith("+")?s="bg-green-500/10 text-green-700 dark:text-green-400":e.startsWith("-")&&(s="bg-red-500/10 text-red-700 dark:text-red-400"),(0,z.jsx)("div",{className:s,children:e},r)})})]})]},r))});return d?(0,z.jsxs)("div",{className:"space-y-2 mt-2",children:[f(),(0,z.jsxs)(sb,{variant:"default",className:"decline"===l?"bg-red-600 hover:bg-red-700 text-white":"bg-green-600 hover:bg-green-700 text-white",children:[(0,z.jsx)(rC,{className:"h-3 w-3 mr-1"}),"decline"===l?"Denied":"Allowed"]})]}):(0,z.jsxs)("div",{className:"space-y-2 mt-2",children:[f(),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsxs)(W.Button,{onClick:()=>u("accept"),disabled:a,className:"bg-green-600 hover:bg-green-700 text-white",size:"sm",children:[a&&"accept"===l?(0,z.jsx)(rk,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,z.jsx)(rC,{className:"h-3.5 w-3.5 mr-1"}),"Allow"]}),(0,z.jsxs)(W.Button,{onClick:()=>u("decline"),disabled:a,variant:"destructive",size:"sm",children:[a&&"decline"===l?(0,z.jsx)(rk,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,z.jsx)(rj,{className:"h-3.5 w-3.5 mr-1"}),"Deny"]})]})]})}let Cu=(0,ew.default)("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),Ch=(0,ew.default)("badge",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}]]);function Cf({status:e,className:r}){switch(e){case"completed":return(0,z.jsx)(rC,{className:(0,ey.cn)("h-4 w-4 text-green-500",r)});case"in_progress":return(0,z.jsx)(rk,{className:(0,ey.cn)("h-4 w-4 text-cyan-500 animate-spin",r)});case"pending":default:return(0,z.jsx)(rS,{className:(0,ey.cn)("h-4 w-4 text-muted-foreground",r)});case"deleted":return(0,z.jsx)(rj,{className:(0,ey.cn)("h-4 w-4 text-red-400",r)})}}function Cp(e,r){try{let s="string"==typeof e?JSON.parse(e):e;if(s&&"object"==typeof s&&r(s))return s}catch{}return null}function Cm({input:e}){let r="string"==typeof e?e:JSON.stringify(e,null,2);return(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r.length>500?r.substring(0,500)+"...":r})}function Cg({input:e}){let r=Cp(e,e=>Array.isArray(e.todos)&&e.todos.length>0);return r?(0,z.jsx)("div",{className:"mt-2 space-y-1",children:r.todos.map((e,r)=>(0,z.jsxs)("div",{className:"flex items-start gap-2 py-0.5",children:[(0,z.jsx)(Cf,{status:e.status,className:"mt-0.5 flex-shrink-0"}),(0,z.jsxs)("div",{className:"min-w-0",children:[(0,z.jsx)("span",{className:(0,ey.cn)("text-sm break-words","completed"===e.status&&"line-through text-muted-foreground"),children:e.subject??e.content??"Untitled task"}),"in_progress"===e.status&&e.activeForm&&(0,z.jsx)("span",{className:"block text-xs italic text-cyan-500",children:e.activeForm})]})]},e.id??r))}):(0,z.jsx)(Cm,{input:e})}function Cx({input:e}){let r=Cp(e,e=>"string"==typeof e.subject);return r?(0,z.jsxs)("div",{className:"mt-2 flex items-start gap-2",children:[(0,z.jsx)(Cu,{className:"h-4 w-4 text-cyan-500 mt-0.5 flex-shrink-0"}),(0,z.jsxs)("div",{className:"min-w-0",children:[(0,z.jsx)("span",{className:"text-sm font-medium break-words",children:r.subject}),r.description&&(0,z.jsx)("span",{className:"block text-xs text-muted-foreground mt-0.5 break-words",children:r.description.length>200?r.description.substring(0,200)+"...":r.description})]})]}):(0,z.jsx)(Cm,{input:e})}function Cv({input:e}){let r=Cp(e,e=>"string"==typeof e.taskId);return r?(0,z.jsxs)("div",{className:"mt-2 flex items-start gap-2 flex-wrap",children:[r.status?(0,z.jsx)(Cf,{status:r.status,className:"mt-0.5 flex-shrink-0"}):(0,z.jsx)(_U,{className:"h-4 w-4 text-cyan-500 mt-0.5 flex-shrink-0"}),(0,z.jsxs)("span",{className:"text-sm break-words",children:["Task #",r.taskId,r.status&&(0,z.jsxs)(z.Fragment,{children:[" ",(0,z.jsx)(_U,{className:"inline h-3 w-3 text-muted-foreground mx-0.5"})," ",r.status]}),r.subject&&(0,z.jsxs)("span",{className:"text-muted-foreground",children:[" — ",r.subject]})]}),r.addBlockedBy&&r.addBlockedBy.length>0&&(0,z.jsx)("div",{className:"flex gap-1 mt-1 w-full pl-6",children:r.addBlockedBy.map(e=>(0,z.jsxs)(sb,{variant:"outline",className:"text-[10px]",children:[(0,z.jsx)(Ch,{className:"h-2.5 w-2.5 mr-0.5"}),"blocked by #",e]},e))}),r.addBlocks&&r.addBlocks.length>0&&(0,z.jsx)("div",{className:"flex gap-1 mt-1 w-full pl-6",children:r.addBlocks.map(e=>(0,z.jsxs)(sb,{variant:"outline",className:"text-[10px]",children:[(0,z.jsx)(Ch,{className:"h-2.5 w-2.5 mr-0.5"}),"blocks #",e]},e))})]}):(0,z.jsx)(Cm,{input:e})}function C_(){return(0,z.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin text-cyan-500"}),(0,z.jsx)("span",{children:"Listing tasks..."})]})}function Cy({input:e}){let r=Cp(e,e=>"string"==typeof e.taskId);return r?(0,z.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin text-cyan-500"}),(0,z.jsxs)("span",{children:["Fetching task #",r.taskId,"..."]})]}):(0,z.jsx)(Cm,{input:e})}function Cb({output:e}){let r=function(e){try{let r=JSON.parse(e);if(Array.isArray(r))return r.filter(e=>e.id&&e.subject).map(e=>({id:String(e.id),subject:String(e.subject),status:e.status||"pending",owner:e.owner?String(e.owner):void 0,blockedBy:Array.isArray(e.blockedBy)?e.blockedBy.map(String):void 0}));let s=r.tasks??r.items??r.data;if(Array.isArray(s))return s.filter(e=>e.id&&e.subject).map(e=>({id:String(e.id),subject:String(e.subject),status:e.status||"pending",owner:e.owner?String(e.owner):void 0,blockedBy:Array.isArray(e.blockedBy)?e.blockedBy.map(String):void 0}))}catch{let r=e.trim().split("\n").filter(Boolean),s=[];for(let e of r){let r=e.match(/^#?(\d+)[\s.:\-]+\[?(completed|in_progress|pending|deleted)\]?\s+(.+)/i);r&&s.push({id:r[1],status:r[2].toLowerCase(),subject:r[3].trim()})}if(s.length>0)return s}return null}(e);return r?(0,z.jsx)("div",{className:"mt-1 space-y-1",children:r.map(e=>(0,z.jsxs)("div",{className:"flex items-start gap-2 py-0.5",children:[(0,z.jsx)(Cf,{status:e.status,className:"mt-0.5 flex-shrink-0"}),(0,z.jsxs)("div",{className:"min-w-0 flex items-center gap-1.5 flex-wrap",children:[(0,z.jsxs)("span",{className:"text-xs text-muted-foreground",children:["#",e.id]}),(0,z.jsx)("span",{className:(0,ey.cn)("text-sm break-words","completed"===e.status&&"line-through text-muted-foreground"),children:e.subject}),e.blockedBy&&e.blockedBy.length>0&&(0,z.jsx)(sb,{variant:"outline",className:"text-[10px]",children:"blocked"})]})]},e.id))}):null}function Cw({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.file_path)return r;return null}catch{return null}}(e);if(!r)return(0,z.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{file_path:s,offset:i,limit:n}=r,a=s.split("/"),o=a.pop()||s,l=a.join("/"),c=null!=i||null!=n,d="";if(c){let e=i??1;d=null!=n?`Lines ${e}\u2013${e+n-1}`:`From line ${e}`}return(0,z.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,z.jsxs)("div",{className:"min-w-0",children:[(0,z.jsx)("span",{className:"text-sm font-medium break-all",children:o}),l&&(0,z.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:s,children:l})]}),c&&(0,z.jsx)(sb,{variant:"outline",className:"text-xs shrink-0",children:d})]})}function CS({output:e}){let r=e.split("\n").length;return(0,z.jsxs)("details",{children:[(0,z.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["File contents (",r," ",1===r?"line":"lines",")"]}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function CC({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.file_path)return r;return null}catch{return null}}(e);if(!r)return(0,z.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{file_path:s,content:i}=r,n=s.split("/"),a=n.pop()||s,o=n.join("/"),l=i.split("\n").length;return(0,z.jsxs)("div",{className:"space-y-1",children:[(0,z.jsxs)("div",{className:"min-w-0",children:[(0,z.jsx)("span",{className:"text-sm font-medium break-all",children:a}),o&&(0,z.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:s,children:o})]}),(0,z.jsxs)("details",{children:[(0,z.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Content (",l," ",1===l?"line":"lines",")"]}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:i.length>1e3?i.substring(0,1e3)+"...":i})]})]})}function Cj({output:e}){return e&&""!==e.trim()?(0,z.jsxs)("details",{children:[(0,z.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Result"}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]}):(0,z.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"File written"})}function Ck({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.command)return r;return null}catch{return null}}(e);if(!r)return(0,z.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{command:s,description:i,timeout:n}=r;return(0,z.jsxs)("div",{className:"space-y-1",children:[i&&(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:i}),(0,z.jsxs)("div",{className:"flex items-start gap-2",children:[(0,z.jsxs)("pre",{className:"flex-1 min-w-0 bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:[(0,z.jsx)("span",{className:"text-muted-foreground select-none",children:"$ "}),s]}),null!=n&&(0,z.jsx)(sb,{variant:"outline",className:"text-xs shrink-0 mt-1",children:function(e){if(e>=6e4){let r=e/6e4;return`${r%1==0?r:r.toFixed(1)}m`}return`${e/1e3}s`}(n)})]})]})}function CN({output:e}){if(!e||""===e.trim())return(0,z.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,z.jsxs)("details",{children:[(0,z.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Output (",r," ",1===r?"line":"lines",")"]}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function CE({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.pattern)return r;return null}catch{return null}}(e);if(!r)return(0,z.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let s=[];return r.path&&s.push({label:r.path}),r.glob&&s.push({label:r.glob}),r.type&&s.push({label:`.${r.type}`}),r.output_mode&&"files_with_matches"!==r.output_mode&&s.push({label:r.output_mode}),null!=r.context&&s.push({label:`context: ${r.context}`}),null!=r["-C"]&&s.push({label:`context: ${r["-C"]}`}),null!=r["-B"]&&s.push({label:`before: ${r["-B"]}`}),null!=r["-A"]&&s.push({label:`after: ${r["-A"]}`}),r["-i"]&&s.push({label:"case-insensitive"}),r.multiline&&s.push({label:"multiline"}),null!=r.head_limit&&s.push({label:`limit: ${r.head_limit}`}),null!=r.offset&&s.push({label:`offset: ${r.offset}`}),(0,z.jsxs)("div",{className:"space-y-1",children:[(0,z.jsx)("div",{className:"flex items-start gap-2",children:(0,z.jsxs)("pre",{className:"flex-1 min-w-0 bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:[(0,z.jsx)("span",{className:"text-muted-foreground select-none",children:"/ "}),r.pattern]})}),s.length>0&&(0,z.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap",children:s.map((e,r)=>(0,z.jsx)(sb,{variant:"outline",className:"text-xs",children:e.label},r))})]})}function CD({output:e}){if(!e||""===e.trim())return(0,z.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No matches"});let r=e.split("\n").length;return(0,z.jsxs)("details",{children:[(0,z.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Results (",r," ",1===r?"line":"lines",")"]}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function CR({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.pattern)return r;return null}catch{return null}}(e);return r?(0,z.jsxs)("div",{className:"space-y-1",children:[(0,z.jsx)("div",{className:"flex items-start gap-2",children:(0,z.jsx)("pre",{className:"flex-1 min-w-0 bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r.pattern})}),r.path&&(0,z.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap",children:(0,z.jsx)(sb,{variant:"outline",className:"text-xs",children:r.path})})]}):(0,z.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)})}function CA({output:e}){if(!e||""===e.trim())return(0,z.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No matches"});let r=e.trim().split("\n").length;return(0,z.jsxs)("details",{children:[(0,z.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:[r," ",1===r?"file":"files"," found"]}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}let CM={Explore:"Explore",Bash:"Bash",Plan:"Plan","general-purpose":"General","code-simplifier":"Simplify","superpowers:code-reviewer":"Review","memory-leak-detector":"Memory","directory-structure-validator":"Structure","tech-docs-finder":"Docs","claude-code-guide":"Guide","statusline-setup":"Status"};function CF({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.description&&"string"==typeof r.subagent_type)return r;return null}catch{return null}}(e);if(!r)return(0,z.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{description:s,subagent_type:i,prompt:n,model:a,max_turns:o,resume:l,run_in_background:c}=r,d=[];return d.push({label:CM[i]||i}),a&&d.push({label:a}),null!=o&&d.push({label:`${o} turns`}),c&&d.push({label:"background"}),l&&d.push({label:"resume"}),(0,z.jsxs)("div",{className:"space-y-1",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,z.jsx)("span",{className:"text-sm",children:s}),d.map((e,r)=>(0,z.jsx)(sb,{variant:"outline",className:"text-xs shrink-0",children:e.label},r))]}),n&&(0,z.jsxs)("details",{children:[(0,z.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Prompt (",n.length>1e3?`${Math.round(n.length/1e3)}k chars`:`${n.length} chars`,")"]}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:n.length>1e3?n.substring(0,1e3)+"...":n})]})]})}function CT({output:e}){if(!e||""===e.trim())return(0,z.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,z.jsxs)("details",{children:[(0,z.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Agent result (",r," ",1===r?"line":"lines",")"]}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function CP(e,r){return e.length>r?e.substring(0,r)+"...":e}function CB({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.file_path&&"string"==typeof r.old_string&&"string"==typeof r.new_string)return r;return null}catch{return null}}(e);if(!r)return(0,z.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{file_path:s,old_string:i,new_string:n,replace_all:a}=r,o=s.split("/"),l=o.pop()||s,c=o.join("/"),d=i.split("\n").length,u=n.split("\n").length;return(0,z.jsxs)("div",{className:"space-y-1",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,z.jsxs)("div",{className:"min-w-0",children:[(0,z.jsx)("span",{className:"text-sm font-medium break-all",children:l}),c&&(0,z.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:s,children:c})]}),(0,z.jsx)(sb,{variant:"outline",className:"text-xs shrink-0",children:d===u?`${d} ${1===d?"line":"lines"}`:`${d}\u2192${u} lines`}),a&&(0,z.jsx)(sb,{variant:"outline",className:"text-xs shrink-0",children:"replace all"})]}),(0,z.jsxs)("details",{children:[(0,z.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Diff"}),(0,z.jsxs)("div",{className:"mt-1 text-xs rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full",children:[(0,z.jsxs)("pre",{className:"bg-red-500/10 p-1.5 rounded-t whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:[(0,z.jsx)("span",{className:"text-red-500 select-none",children:"- "}),CP(i,500)]}),(0,z.jsxs)("pre",{className:"bg-green-500/10 p-1.5 rounded-b whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:[(0,z.jsx)("span",{className:"text-green-500 select-none",children:"+ "}),CP(n,500)]})]})]})]})}function CL({output:e}){if(!e||""===e.trim())return(0,z.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});if(e.length<=200)return(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:e});let r=e.split("\n").length;return(0,z.jsxs)("details",{children:[(0,z.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Result (",r," ",1===r?"line":"lines",")"]}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function CI({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.url&&"string"==typeof r.prompt)return r;return null}catch{return null}}(e);if(!r)return(0,z.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{display:s,href:i}=function(e){try{let r=new URL(e),s="/"===r.pathname?"":r.pathname,i=r.hostname+s;return{display:i.length>80?i.substring(0,77)+"...":i,href:e}}catch{return{display:e.length>80?e.substring(0,77)+"...":e,href:e}}}(r.url),n=r.prompt.length>150?r.prompt.substring(0,147)+"...":r.prompt;return(0,z.jsxs)("div",{className:"space-y-1",children:[(0,z.jsx)("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"block text-xs font-mono text-blue-500 hover:underline truncate",children:s}),(0,z.jsxs)("p",{className:"text-xs text-muted-foreground",children:['"',n,'"']})]})}function CO({output:e}){if(!e||""===e.trim())return(0,z.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No content fetched"});let r=e.split("\n").length;return(0,z.jsxs)("details",{children:[(0,z.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Response (",r," ",1===r?"line":"lines",")"]}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function Cz({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.query)return r;return null}catch{return null}}(e);return r?(0,z.jsxs)("div",{className:"space-y-1.5",children:[(0,z.jsx)("p",{className:"text-xs font-mono bg-muted/50 px-2 py-1 rounded break-words",children:r.query}),r.allowed_domains&&r.allowed_domains.length>0&&(0,z.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,z.jsx)("span",{className:"text-xs text-muted-foreground",children:"only:"}),r.allowed_domains.map(e=>(0,z.jsx)(sb,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:e},e))]}),r.blocked_domains&&r.blocked_domains.length>0&&(0,z.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,z.jsx)("span",{className:"text-xs text-muted-foreground",children:"exclude:"}),r.blocked_domains.map(e=>(0,z.jsx)(sb,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:e},e))]})]}):(0,z.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)})}function C$({output:e}){if(!e||""===e.trim())return(0,z.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No search results"});let r=e.split("\n").length;return(0,z.jsxs)("details",{children:[(0,z.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Results (",r," ",1===r?"line":"lines",")"]}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function CW({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.skill)return r;return null}catch{return null}}(e);return r?(0,z.jsxs)("div",{className:"space-y-1",children:[(0,z.jsx)("p",{className:"text-xs font-mono text-pink-500",children:r.skill}),r.args&&(0,z.jsxs)("p",{className:"text-xs text-muted-foreground truncate",children:["args: ",r.args]})]}):(0,z.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)})}function CH({output:e}){if(!e||""===e.trim())return(0,z.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,z.jsxs)("details",{children:[(0,z.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Loaded (",r," ",1===r?"line":"lines",")"]}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function CU({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.task_id)return r;return null}catch{return null}}(e);if(!r)return(0,z.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{task_id:s,block:i,timeout:n}=r,a=[];return a.push({label:!1===i?"non-blocking":"blocking"}),null!=n&&a.push({label:`${Math.round(n/1e3)}s`}),(0,z.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,z.jsx)("code",{className:"text-sm bg-muted/50 px-1.5 py-0.5 rounded",children:s}),a.map((e,r)=>(0,z.jsx)(sb,{variant:"outline",className:"text-xs shrink-0",children:e.label},r))]})}function CK({output:e}){if(!e||""===e.trim())return(0,z.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,z.jsxs)("details",{children:[(0,z.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Task output (",r," ",1===r?"line":"lines",")"]}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function Cq({input:e}){let r="string"==typeof e?function(e){try{return JSON.parse(e)}catch{return null}}(e):e,s=r?.changes??[];return 0===s.length?(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:"No file changes"}):(0,z.jsx)("div",{className:"space-y-2 mt-1",children:s.map((e,r)=>(0,z.jsxs)("div",{children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(bO,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),(0,z.jsx)("code",{className:"text-xs break-all",children:e.path}),(0,z.jsx)(sb,{variant:"secondary",className:`text-[10px] ${function(e){switch(e){case"added":case"add":return"bg-green-500/10 text-green-600";case"deleted":case"delete":return"bg-red-500/10 text-red-600";default:return"bg-blue-500/10 text-blue-600"}}(e.kind)}`,children:function(e){switch(e){case"added":case"add":return"added";case"deleted":case"delete":return"deleted";default:return"modified"}}(e.kind)})]}),e.diff&&(0,z.jsxs)("details",{className:"mt-1",children:[(0,z.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"View diff"}),(0,z.jsx)("pre",{className:"mt-1 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:e.diff.split("\n").map((e,r)=>{let s="";return e.startsWith("+")?s="bg-green-500/10 text-green-700 dark:text-green-400":e.startsWith("-")&&(s="bg-red-500/10 text-red-700 dark:text-red-400"),(0,z.jsx)("div",{className:s,children:e},r)})})]})]},r))})}function CV({output:e}){let r=e.toLowerCase(),s="text-muted-foreground";return r.includes("completed")||r.includes("success")?s="text-green-600 dark:text-green-400":r.includes("failed")||r.includes("error")?s="text-red-600 dark:text-red-400":(r.includes("declined")||r.includes("denied"))&&(s="text-amber-600 dark:text-amber-400"),(0,z.jsx)("p",{className:`text-xs ${s}`,children:e})}function CY({path:e,size:r}){let s;return(0,z.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-muted/60 px-1.5 py-0.5 text-xs font-mono align-baseline",title:e,children:[(0,z.jsx)(bO,{className:"w-3 h-3 text-muted-foreground shrink-0"}),(0,z.jsx)("span",{className:"truncate max-w-[18ch]",children:(s=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")))>=0?e.slice(s+1):e}),(0,z.jsx)("span",{className:"text-muted-foreground",children:function(e){if(e<1024)return`${e} B`;let r=e/1024;return r<10?`${r.toFixed(1)} KB`:r<1024?`${Math.round(r)} KB`:`${(r/1024).toFixed(1)} MB`}(r)})]})}let CG=/<vpaste path="([^"]+)" size="(\d+)" \/>/g;function CX({message:e,messageIndex:r}){let s=function(e,r){switch(e.type){case"user":return(0,z.jsx)(CZ,{content:e.content});case"assistant":return(0,z.jsx)(CQ,{content:e.content,agentType:e.agentType});case"tool_use":return(0,z.jsx)(C0,{tool:e.tool,input:e.input,messageIndex:r});case"tool_result":return(0,z.jsx)(C1,{tool:e.tool,output:e.output});case"thinking":return(0,z.jsx)(C2,{content:e.content});case"error":return(0,z.jsx)(C5,{message:e.message});case"system":return(0,z.jsx)(C3,{content:e.content});case"approval_request":return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-amber-500/10 flex items-center justify-center",children:(0,z.jsx)(S3,{className:"w-4 h-4 text-amber-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-amber-500 mb-1",children:"command"===e.requestType?"Command Approval":"File Change Approval"}),"command"===e.requestType?(0,z.jsx)(Cc,{requestId:e.requestId,command:e.command,cwd:e.cwd,messageIndex:r}):(0,z.jsx)(Cd,{requestId:e.requestId,changes:e.changes,messageIndex:r})]})]});default:return null}}(e,r);return s?(0,z.jsxs)("div",{className:"group relative",children:[s,(0,z.jsx)("span",{className:"pointer-events-none absolute right-0 top-3 text-xs tabular-nums text-muted-foreground opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:function(e){let r=new Date(e),s=new Date,i=r.getFullYear()===s.getFullYear()&&r.getMonth()===s.getMonth()&&r.getDate()===s.getDate(),n=r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});if(i)return n;let a=r.toLocaleDateString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"});return`${a} ${n}`}(e.timestamp)})]}):null}function CJ(e){let r=function(e){let r,s=[],i=0,n=RegExp(CG.source,"g");for(;null!==(r=n.exec(e));)r.index>i&&s.push({kind:"text",text:e.slice(i,r.index)}),s.push({kind:"chip",path:r[1],size:Number(r[2])}),i=r.index+r[0].length;return i<e.length&&s.push({kind:"text",text:e.slice(i)}),s}(e);return 1===r.length&&"text"===r[0].kind?(0,z.jsx)("span",{className:"whitespace-pre-wrap break-words",children:e??""}):(0,z.jsx)("div",{className:"text-foreground max-w-none break-words",style:{fontSize:"var(--conv-font-size, 14px)"},children:r.map((e,r)=>"text"===e.kind?(0,z.jsx)("span",{className:"whitespace-pre-wrap break-words",children:e.text},r):(0,z.jsx)(CY,{path:e.path,size:e.size},r))})}function CZ({content:e}){return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-primary/10 flex items-center justify-center",children:(0,z.jsx)(SV,{className:"w-3.5 h-3.5 text-primary"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-foreground mb-1",children:"You"}),(0,z.jsx)("div",{className:"text-foreground max-w-none break-words",style:{fontSize:"var(--conv-font-size, 14px)"},children:"string"==typeof e?CJ(e):e.map((e,r)=>"text"===e.type?(0,z.jsx)($.Fragment,{children:CJ(e.text)},r):(0,z.jsx)("img",{src:`data:${e.mediaType};base64,${e.data}`,alt:"Attached image",className:"max-w-sm rounded-lg mt-2"},r))})]})]})}function CQ({content:e,agentType:r}){let s=function(){try{return kf().agentType}catch{return"claude-code"}}(),i="codex"===(r??s),[n,a]=(0,$.useState)(!1);return(0,z.jsxs)("div",{className:"group flex gap-3 py-3",children:[(0,z.jsx)("div",{className:`flex-shrink-0 w-7 h-7 rounded-lg ${i?"bg-green-500/10":"bg-violet-500/10"} flex items-center justify-center`,children:(0,z.jsx)(aE,{className:`w-3.5 h-3.5 ${i?"text-green-500":"text-violet-500"}`})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,z.jsx)("p",{className:`text-sm font-medium ${i?"text-green-500":"text-violet-500"}`,children:i?"Codex":"Claude"}),(0,z.jsx)("button",{type:"button",onClick:()=>a(e=>!e),title:n?"View rendered":"View source","aria-label":n?"View rendered":"View source","aria-pressed":n,className:"opacity-0 group-hover:opacity-100 focus-visible:opacity-100 transition-opacity text-muted-foreground hover:text-foreground",children:n?(0,z.jsx)(_O,{className:"w-3.5 h-3.5"}):(0,z.jsx)(bX,{className:"w-3.5 h-3.5"})})]}),n?(0,z.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words bg-muted/50 rounded-md p-3 overflow-x-auto text-foreground select-text",children:e??""}):(0,z.jsx)("div",{className:"text-foreground prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words",style:{fontSize:"var(--conv-font-size, 14px)"},children:(0,z.jsx)(Cs,{children:e??""})})]})]})}function C0({tool:e,input:r,messageIndex:s}){if("AskUserQuestion"===e)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-violet-500/10 flex items-center justify-center",children:(0,z.jsx)(SJ,{className:"w-4 h-4 text-violet-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-violet-500 mb-1",children:"Question"}),(0,z.jsx)(Ci,{input:r,messageIndex:s})]})]});if("ExitPlanMode"===e)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-green-500/10 flex items-center justify-center",children:(0,z.jsx)(SZ,{className:"w-4 h-4 text-green-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-green-500 mb-1",children:"Plan Ready"}),(0,z.jsx)(Cl,{input:r,messageIndex:s})]})]});let i={TodoWrite:{label:"Tasks",ui:(0,z.jsx)(Cg,{input:r})},TaskCreate:{label:"Create Task",ui:(0,z.jsx)(Cx,{input:r})},TaskUpdate:{label:"Update Task",ui:(0,z.jsx)(Cv,{input:r})},TaskList:{label:"Task List",ui:(0,z.jsx)(C_,{})},TaskGet:{label:"Get Task",ui:(0,z.jsx)(Cy,{input:r})}}[e];if(i)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-cyan-500/10 flex items-center justify-center",children:(0,z.jsx)(oP,{className:"w-4 h-4 text-cyan-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-cyan-500 mb-1",children:i.label}),i.ui]})]});if("Read"===e)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-sky-500/10 flex items-center justify-center",children:(0,z.jsx)(bO,{className:"w-4 h-4 text-sky-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-sky-500 mb-1",children:"Read File"}),(0,z.jsx)(Cw,{input:r})]})]});if("Edit"===e)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-sky-500/10 flex items-center justify-center",children:(0,z.jsx)(S1,{className:"w-4 h-4 text-sky-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-sky-500 mb-1",children:"Edit File"}),(0,z.jsx)(CB,{input:r})]})]});if("Write"===e)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-sky-500/10 flex items-center justify-center",children:(0,z.jsx)(S2,{className:"w-4 h-4 text-sky-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-sky-500 mb-1",children:"Write File"}),(0,z.jsx)(CC,{input:r})]})]});if("Bash"===e)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-emerald-500/10 flex items-center justify-center",children:(0,z.jsx)(aN,{className:"w-4 h-4 text-emerald-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-emerald-500 mb-1",children:"Run Command"}),(0,z.jsx)(Ck,{input:r})]})]});if("Grep"===e)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-orange-500/10 flex items-center justify-center",children:(0,z.jsx)(dt,{className:"w-4 h-4 text-orange-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-orange-500 mb-1",children:"Search"}),(0,z.jsx)(CE,{input:r})]})]});if("Glob"===e)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-teal-500/10 flex items-center justify-center",children:(0,z.jsx)(SQ,{className:"w-4 h-4 text-teal-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-teal-500 mb-1",children:"Glob"}),(0,z.jsx)(CR,{input:r})]})]});if("Task"===e||"Agent"===e)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-purple-500/10 flex items-center justify-center",children:(0,z.jsx)(S0,{className:"w-4 h-4 text-purple-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-purple-500 mb-1",children:"Agent"}),(0,z.jsx)(CF,{input:r})]})]});if("TaskOutput"===e)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-purple-500/10 flex items-center justify-center",children:(0,z.jsx)(S0,{className:"w-4 h-4 text-purple-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-purple-500 mb-1",children:"Task Output"}),(0,z.jsx)(CU,{input:r})]})]});if("WebFetch"===e)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-blue-500/10 flex items-center justify-center",children:(0,z.jsx)(ry,{className:"w-4 h-4 text-blue-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-blue-500 mb-1",children:"Fetch Web Page"}),(0,z.jsx)(CI,{input:r})]})]});if("WebSearch"===e)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-indigo-500/10 flex items-center justify-center",children:(0,z.jsx)(S5,{className:"w-4 h-4 text-indigo-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-indigo-500 mb-1",children:"Web Search"}),(0,z.jsx)(Cz,{input:r})]})]});if("Skill"===e)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-pink-500/10 flex items-center justify-center",children:(0,z.jsx)(da,{className:"w-4 h-4 text-pink-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-pink-500 mb-1",children:"Skill"}),(0,z.jsx)(CW,{input:r})]})]});if("FileChange"===e)return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-sky-500/10 flex items-center justify-center",children:(0,z.jsx)(S1,{className:"w-4 h-4 text-sky-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-sky-500 mb-1",children:"File Changes"}),(0,z.jsx)(Cq,{input:r})]})]});let n="string"==typeof r?r:JSON.stringify(r,null,2);return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-amber-500/10 flex items-center justify-center",children:(0,z.jsx)(SY,{className:"w-4 h-4 text-amber-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsxs)("p",{className:"text-sm font-medium text-amber-500 mb-1 break-words",children:["Tool: ",e]}),(0,z.jsxs)("details",{open:!0,children:[(0,z.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Input"}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:n.length>500?n.substring(0,500)+"...":n})]})]})]})}function C1({tool:e,output:r}){if(["TodoWrite","TaskCreate","TaskUpdate","TaskList","TaskGet"].includes(e)){let s="TaskList"===e?(0,z.jsx)(Cb,{output:r}):null;return(0,z.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsxs)("p",{className:"text-xs text-muted-foreground mb-1",children:["Result (",e,")"]}),s||(0,z.jsxs)("details",{children:[(0,z.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Output"}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r.length>1e3?r.substring(0,1e3)+"...":r})]})]})})}if("Read"===e)return(0,z.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,z.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,z.jsx)(CS,{output:r})})});if("Edit"===e)return(0,z.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,z.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,z.jsx)(CL,{output:r})})});if("Write"===e)return(0,z.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,z.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,z.jsx)(Cj,{output:r})})});if("Bash"===e)return(0,z.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,z.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,z.jsx)(CN,{output:r})})});if("Grep"===e)return(0,z.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,z.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,z.jsx)(CD,{output:r})})});if("Glob"===e)return(0,z.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,z.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,z.jsx)(CA,{output:r})})});if("Task"===e||"Agent"===e)return(0,z.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,z.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,z.jsx)(CT,{output:r})})});if("TaskOutput"===e)return(0,z.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,z.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,z.jsx)(CK,{output:r})})});if("WebFetch"===e)return(0,z.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,z.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,z.jsx)(CO,{output:r})})});if("WebSearch"===e)return(0,z.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,z.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,z.jsx)(C$,{output:r})})});if("Skill"===e)return(0,z.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,z.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,z.jsx)(CH,{output:r})})});if("FileChange"===e)return(0,z.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,z.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,z.jsx)(CV,{output:r})})});let s=r.length>200;return(0,z.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsxs)("p",{className:"text-xs text-muted-foreground mb-1",children:["Result",e?` (${e})`:""]}),(0,z.jsxs)("details",{className:(0,ey.cn)(!s&&"open"),children:[(0,z.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Output"}),(0,z.jsx)("pre",{className:"mt-1 bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",style:{fontSize:"var(--conv-font-size, 12px)"},children:r.length>1e3?r.substring(0,1e3)+"...":r})]})]})})}function C2({content:e}){let r=e??"",s=r.trim().length>0,i=s?r.length>500?r.substring(0,500)+"...":r:"Reasoning unavailable — this model does not expose its thinking content.";return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-blue-500/10 flex items-center justify-center",children:(0,z.jsx)(SG,{className:"w-3.5 h-3.5 text-blue-500"})}),(0,z.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,z.jsxs)("details",{children:[(0,z.jsx)("summary",{className:"text-xs font-medium text-blue-500 cursor-pointer hover:underline",children:"Thinking..."}),(0,z.jsx)("div",{className:`mt-2 whitespace-pre-wrap break-words bg-blue-500/5 p-2 rounded-md overflow-hidden ${s?"text-muted-foreground":"text-muted-foreground/70 italic"}`,style:{fontSize:"var(--conv-font-size, 12px)"},children:i})]})})]})}function C5({message:e}){return(0,z.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-red-500/10 flex items-center justify-center",children:(0,z.jsx)(SX,{className:"w-3.5 h-3.5 text-red-500"})}),(0,z.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-red-500 mb-1",children:"Error"}),(0,z.jsx)("p",{className:"text-red-500/80 break-words whitespace-pre-wrap",style:{fontSize:"var(--conv-font-size, 14px)"},children:e})]})]})}function C3({content:e}){return(0,z.jsxs)("div",{className:"flex gap-3 py-2",children:[(0,z.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-gray-500/10 flex items-center justify-center",children:(0,z.jsx)(xm,{className:"w-3.5 h-3.5 text-gray-500"})}),(0,z.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,z.jsx)("p",{className:"text-muted-foreground break-words",style:{fontSize:"var(--conv-font-size, 12px)"},children:e??""})})]})}let C4=(0,ew.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),C6={damping:.7,stiffness:.05,mass:1.25},C8=1e3/60,C7=!1;function C9(e,r){let s=(0,$.useCallback)(r=>(s.current=r,e(r)),r);return s}globalThis.document?.addEventListener("mousedown",()=>{C7=!0}),globalThis.document?.addEventListener("mouseup",()=>{C7=!1}),globalThis.document?.addEventListener("click",()=>{C7=!1});let je=new Map;function jt(...e){let r={...C6},s=!1;for(let i of e){if("instant"===i){s=!0;continue}"object"==typeof i&&(s=!1,r.damping=i.damping??r.damping,r.stiffness=i.stiffness??r.stiffness,r.mass=i.mass??r.mass)}let i=JSON.stringify(r);return je.has(i)||je.set(i,Object.freeze(r)),s?"instant":je.get(i)}let jr=(0,$.createContext)(null),js="undefined"!=typeof window?$.useLayoutEffect:$.useEffect;function ji({instance:e,children:r,resize:s,initial:i,mass:n,damping:a,stiffness:o,targetScrollTop:l,contextRef:c,...d}){let u=(0,$.useRef)(null),h=((e={})=>{let[r,s]=(0,$.useState)(!1),[i,n]=(0,$.useState)(!1!==e.initial),[a,o]=(0,$.useState)(!1),l=(0,$.useRef)(null);l.current=e;let c=(0,$.useCallback)(()=>{if(!C7)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let r=e.getRangeAt(0);return r.commonAncestorContainer.contains(x.current)||x.current?.contains(r.commonAncestorContainer)},[]),d=(0,$.useCallback)(e=>{h.isAtBottom=e,n(e)},[]),u=(0,$.useCallback)(e=>{h.escapedFromLock=e,s(e)},[]),h=(0,$.useMemo)(()=>{let s;return{escapedFromLock:r,isAtBottom:i,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return x.current?.scrollTop??0},set scrollTop(scrollTop){x.current&&(x.current.scrollTop=scrollTop,h.ignoreScrollToTop=x.current.scrollTop)},get targetScrollTop(){if(!x.current||!v.current)return 0;return x.current.scrollHeight-1-x.current.clientHeight},get calculatedTargetScrollTop(){if(!x.current||!v.current)return 0;let{targetScrollTop:r}=this;if(!e.targetScrollTop)return r;if(s?.targetScrollTop===r)return s.calculatedScrollTop;let i=Math.max(Math.min(e.targetScrollTop(r,{scrollElement:x.current,contentElement:v.current}),r),0);return s={targetScrollTop:r,calculatedScrollTop:i},requestAnimationFrame(()=>{s=void 0}),i},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=70}}},[]),f=(0,$.useCallback)((e={})=>{let r;"string"==typeof e&&(e={animation:e}),e.preserveScrollPosition||d(!0);let s=Date.now()+(Number(e.wait)||0),i=jt(l.current,e.animation),{ignoreEscapes:n=!1}=e,a=h.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{r=Date.now()}):r=s+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!h.isAtBottom)return h.animation=void 0,!1;let{scrollTop:d}=h,u=performance.now(),p=(u-(h.lastTick??u))/C8;if(h.animation||(h.animation={behavior:i,promise:e,ignoreEscapes:n}),h.animation.behavior===i&&(h.lastTick=u),c()||s>Date.now())return o();if(d<Math.min(a,h.calculatedTargetScrollTop)){if(h.animation?.behavior===i){if("instant"===i)return h.scrollTop=h.calculatedTargetScrollTop,o();h.velocity=(i.damping*h.velocity+i.stiffness*h.scrollDifference)/i.mass,h.accumulated+=h.velocity*p,h.scrollTop+=h.accumulated,h.scrollTop!==d&&(h.accumulated=0)}return o()}return r>Date.now()?(a=h.calculatedTargetScrollTop,o()):(h.animation=void 0,h.scrollTop<h.calculatedTargetScrollTop)?f({animation:jt(l.current,l.current.resize),ignoreEscapes:n,duration:Math.max(0,r-Date.now())||void 0}):h.isAtBottom});return e.then(e=>(requestAnimationFrame(()=>{h.animation||(h.lastTick=void 0,h.velocity=0)}),e))};return(!0!==e.wait&&(h.animation=void 0),h.animation?.behavior===i)?h.animation.promise:o()},[d,c,h]),p=(0,$.useCallback)(()=>{u(!0),d(!1)},[u,d]),m=(0,$.useCallback)(({target:e})=>{if(e!==x.current)return;let{scrollTop:r,ignoreScrollToTop:s}=h,{lastScrollTop:i=r}=h;h.lastScrollTop=r,h.ignoreScrollToTop=void 0,s&&s>r&&(i=s),o(h.isNearBottom),setTimeout(()=>{if(h.resizeDifference||r===s)return;if(c()){u(!0),d(!1);return}let e=r>i,n=r<i;if(h.animation?.ignoreEscapes){h.scrollTop=i;return}n&&(u(!0),d(!1)),e&&u(!1),!h.escapedFromLock&&h.isNearBottom&&d(!0)},1)},[u,d,c,h]),g=(0,$.useCallback)(({target:e,deltaY:r})=>{let s=e;for(;!["scroll","auto"].includes(getComputedStyle(s).overflow);){if(!s.parentElement)return;s=s.parentElement}s===x.current&&r<0&&x.current.scrollHeight>x.current.clientHeight&&!h.animation?.ignoreEscapes&&(u(!0),d(!1))},[u,d,h]),x=C9(e=>{x.current?.removeEventListener("scroll",m),x.current?.removeEventListener("wheel",g),e?.addEventListener("scroll",m,{passive:!0}),e?.addEventListener("wheel",g,{passive:!0})},[]),v=C9(e=>{let r;h.resizeObserver?.disconnect(),e&&(h.resizeObserver=new ResizeObserver(([e])=>{let{height:s}=e.contentRect,i=s-(r??s);if(h.resizeDifference=i,h.scrollTop>h.targetScrollTop&&(h.scrollTop=h.targetScrollTop),o(h.isNearBottom),i>=0){let e=jt(l.current,r?l.current.resize:l.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:"instant"===e?void 0:350})}else h.isNearBottom&&(u(!1),d(!0));r=s,requestAnimationFrame(()=>{setTimeout(()=>{h.resizeDifference===i&&(h.resizeDifference=0)},1)})}),h.resizeObserver?.observe(e))},[]);return{contentRef:v,scrollRef:x,scrollToBottom:f,stopScroll:p,isAtBottom:i||a,isNearBottom:a,escapedFromLock:r,state:h}})({mass:n,damping:a,stiffness:o,resize:s,initial:i,targetScrollTop:$.useCallback((e,r)=>{let s=y?.targetScrollTop??l;return s?.(e,r)??e},[l])}),{scrollRef:f,contentRef:p,scrollToBottom:m,stopScroll:g,isAtBottom:x,escapedFromLock:v,state:_}=e??h,y=(0,$.useMemo)(()=>({scrollToBottom:m,stopScroll:g,scrollRef:f,isAtBottom:x,escapedFromLock:v,contentRef:p,state:_,get targetScrollTop(){return u.current},set targetScrollTop(targetScrollTop){u.current=targetScrollTop}}),[m,x,p,f,g,v,_]);return(0,$.useImperativeHandle)(c,()=>y,[y]),js(()=>{f.current&&"visible"===getComputedStyle(f.current).overflow&&(f.current.style.overflow="auto")},[]),$.createElement(jr.Provider,{value:y},$.createElement("div",{...d},"function"==typeof r?r(y):r))}function jn(){let e=(0,$.useContext)(jr);if(!e)throw Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}(ji||(ji={})).Content=function({children:e,scrollClassName:r,...s}){let i=jn();return $.createElement("div",{ref:i.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:r},$.createElement("div",{...s,ref:i.contentRef},"function"==typeof e?e(i):e))};let ja=({className:e,...r})=>(0,z.jsx)(ji,{className:(0,ey.cn)("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...r}),jo=({className:e,...r})=>(0,z.jsx)(ji.Content,{className:(0,ey.cn)("flex flex-col gap-8 p-4",e),...r}),jl=({className:e,...r})=>{let{isAtBottom:s,scrollToBottom:i}=jn(),n=(0,$.useCallback)(()=>{i()},[i]);return!s&&(0,z.jsx)(W.Button,{className:(0,ey.cn)("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:n,size:"icon",type:"button",variant:"outline",...r,children:(0,z.jsx)(C4,{className:"size-4"})})};var jc="HoverCard",[jd,ju]=K(jc,[i$]),jh=i$(),[jf,jp]=jd(jc),jm=e=>{let{__scopeHoverCard:r,children:s,open:i,defaultOpen:n,onOpenChange:a,openDelay:o=700,closeDelay:l=300}=e,c=jh(r),d=$.useRef(0),u=$.useRef(0),h=$.useRef(!1),f=$.useRef(!1),[p,m]=G({prop:i,defaultProp:n??!1,onChange:a,caller:jc}),g=$.useCallback(()=>{clearTimeout(u.current),d.current=window.setTimeout(()=>m(!0),o)},[o,m]),x=$.useCallback(()=>{clearTimeout(d.current),h.current||f.current||(u.current=window.setTimeout(()=>m(!1),l))},[l,m]),v=$.useCallback(()=>m(!1),[m]);return $.useEffect(()=>()=>{clearTimeout(d.current),clearTimeout(u.current)},[]),(0,z.jsx)(jf,{scope:r,open:p,onOpenChange:m,onOpen:g,onClose:x,onDismiss:v,hasSelectionRef:h,isPointerDownOnContentRef:f,children:(0,z.jsx)(iU,{...c,children:s})})};jm.displayName=jc;var jg="HoverCardTrigger",jx=$.forwardRef((e,r)=>{let{__scopeHoverCard:s,...i}=e,n=jp(jg,s),a=jh(s);return(0,z.jsx)(iq,{asChild:!0,...a,children:(0,z.jsx)(er.a,{"data-state":n.open?"open":"closed",...i,ref:r,onPointerEnter:q(e.onPointerEnter,jj(n.onOpen)),onPointerLeave:q(e.onPointerLeave,jj(n.onClose)),onFocus:q(e.onFocus,n.onOpen),onBlur:q(e.onBlur,n.onClose),onTouchStart:q(e.onTouchStart,e=>e.preventDefault())})})});jx.displayName=jg;var jv="HoverCardPortal",[j_,jy]=jd(jv,{forceMount:void 0}),jb=e=>{let{__scopeHoverCard:r,forceMount:s,children:i,container:n}=e,a=jp(jv,r);return(0,z.jsx)(j_,{scope:r,forceMount:s,children:(0,z.jsx)(Z,{present:s||a.open,children:(0,z.jsx)(eW,{asChild:!0,container:n,children:i})})})};jb.displayName=jv;var jw="HoverCardContent",jS=$.forwardRef((e,r)=>{let s=jy(jw,e.__scopeHoverCard),{forceMount:i=s.forceMount,...n}=e,a=jp(jw,e.__scopeHoverCard);return(0,z.jsx)(Z,{present:i||a.open,children:(0,z.jsx)(jC,{"data-state":a.open?"open":"closed",...n,onPointerEnter:q(e.onPointerEnter,jj(a.onOpen)),onPointerLeave:q(e.onPointerLeave,jj(a.onClose)),ref:r})})});jS.displayName=jw;var jC=$.forwardRef((e,r)=>{let{__scopeHoverCard:s,onEscapeKeyDown:i,onPointerDownOutside:n,onFocusOutside:a,onInteractOutside:o,...l}=e,c=jp(jw,s),d=jh(s),u=$.useRef(null),h=(0,U.useComposedRefs)(r,u),[f,p]=$.useState(!1);return $.useEffect(()=>{if(f){let e=document.body;return O=e.style.userSelect||e.style.webkitUserSelect,e.style.userSelect="none",e.style.webkitUserSelect="none",()=>{e.style.userSelect=O,e.style.webkitUserSelect=O}}},[f]),$.useEffect(()=>{if(u.current){let e=()=>{p(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(c.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",e),()=>{document.removeEventListener("pointerup",e),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),$.useEffect(()=>{u.current&&(function(e){let r=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;s.nextNode();)r.push(s.currentNode);return r})(u.current).forEach(e=>e.setAttribute("tabindex","-1"))}),(0,z.jsx)(eR,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:o,onEscapeKeyDown:i,onPointerDownOutside:n,onFocusOutside:q(a,e=>{e.preventDefault()}),onDismiss:c.onDismiss,children:(0,z.jsx)(iX,{...d,...l,onPointerDown:q(l.onPointerDown,e=>{e.currentTarget.contains(e.target)&&p(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:h,style:{...l.style,userSelect:f?"text":void 0,WebkitUserSelect:f?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})});function jj(e){return r=>"touch"===r.pointerType?void 0:e()}function jk({...e}){return(0,z.jsx)(jm,{"data-slot":"hover-card",...e})}function jN({...e}){return(0,z.jsx)(jx,{"data-slot":"hover-card-trigger",...e})}function jE({className:e,align:r="center",sideOffset:s=4,...i}){return(0,z.jsx)(jb,{"data-slot":"hover-card-portal",children:(0,z.jsx)(jS,{"data-slot":"hover-card-content",align:r,sideOffset:s,className:(0,ey.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...i})})}$.forwardRef((e,r)=>{let{__scopeHoverCard:s,...i}=e,n=jh(s);return(0,z.jsx)(iQ,{...n,...i,ref:r})}).displayName="HoverCardArrow";let jD=(0,ew.default)("corner-down-left",[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]]),jR=(0,ew.default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);(0,ew.default)("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);let jA=(0,ew.default)("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),jM=(e=21)=>{let r="",s=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)r+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&s[e]];return r},jF=(0,$.createContext)(null),jT=(0,$.createContext)(null),jP=()=>(0,$.useContext)(jF),jB=(0,$.createContext)(null),jL=()=>{let e=(0,$.useContext)(jT),r=(0,$.useContext)(jB),s=e??r;if(!s)throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return s};function jI({data:e,className:r,...s}){let i=jL(),n=e.filename||"",a="image"==(e.mediaType?.startsWith("image/")&&e.url?"image":"file"),o=n||(a?"Image":"Attachment");return(0,z.jsxs)(jX,{children:[(0,z.jsx)(jN,{asChild:!0,children:(0,z.jsxs)("div",{className:(0,ey.cn)("group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",r),...s,children:[(0,z.jsxs)("div",{className:"relative size-5 shrink-0",children:[(0,z.jsx)("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:a?(0,z.jsx)("img",{alt:n||"attachment",className:"size-5 object-cover",height:20,src:e.url,width:20}):(0,z.jsx)("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:(0,z.jsx)(jA,{className:"size-3"})})}),(0,z.jsxs)(W.Button,{"aria-label":"Remove attachment",className:"absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:r=>{r.stopPropagation(),i.remove(e.id)},type:"button",variant:"ghost",children:[(0,z.jsx)(t8,{}),(0,z.jsx)("span",{className:"sr-only",children:"Remove"})]})]}),(0,z.jsx)("span",{className:"flex-1 truncate",children:o})]},e.id)}),(0,z.jsx)(jJ,{className:"w-auto p-2",children:(0,z.jsxs)("div",{className:"w-auto space-y-3",children:[a&&(0,z.jsx)("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:(0,z.jsx)("img",{alt:n||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:e.url,width:448})}),(0,z.jsx)("div",{className:"flex items-center gap-2.5",children:(0,z.jsxs)("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[(0,z.jsx)("h4",{className:"truncate font-semibold text-sm leading-none",children:n||(a?"Image":"Attachment")}),e.mediaType&&(0,z.jsx)("p",{className:"truncate font-mono text-muted-foreground text-xs",children:e.mediaType})]})})]})})]})}function jO({children:e,className:r,...s}){let i=jL();return i.files.length?(0,z.jsx)("div",{className:(0,ey.cn)("flex flex-wrap items-center gap-2 p-3 w-full",r),...s,children:i.files.map(r=>(0,z.jsx)($.Fragment,{children:e(r)},r.id))}):null}let jz=({label:e="Add photos or files",...r})=>{let s=jL();return(0,z.jsxs)(ax,{...r,onSelect:e=>{e.preventDefault(),s.openFileDialog()},children:[(0,z.jsx)(jR,{className:"mr-2 size-4"})," ",e]})},j$=({className:e,accept:r,multiple:s,globalDrop:i,syncHiddenInput:n,maxFiles:a,maxFileSize:o,onError:l,onSubmit:c,children:d,...u})=>{let h=jP(),f=!!h,p=(0,$.useRef)(null),m=(0,$.useRef)(null),[g,x]=(0,$.useState)([]),v=f?h.attachments.files:g,_=(0,$.useRef)(v);_.current=v;let y=(0,$.useCallback)(()=>{p.current?.click()},[]),b=(0,$.useCallback)(e=>!r||""===r.trim()||r.split(",").map(e=>e.trim()).filter(Boolean).some(r=>{if(r.endsWith("/*")){let s=r.slice(0,-1);return e.type.startsWith(s)}return e.type===r}),[r]),w=(0,$.useCallback)(e=>{let r=Array.from(e),s=r.filter(e=>b(e));if(r.length&&0===s.length)return void l?.({code:"accept",message:"No files match the accepted types."});let i=s.filter(e=>!o||e.size<=o);s.length>0&&0===i.length?l?.({code:"max_file_size",message:"All files exceed the maximum size."}):x(e=>{let r="number"==typeof a?Math.max(0,a-e.length):void 0,s="number"==typeof r?i.slice(0,r):i;"number"==typeof r&&i.length>r&&l?.({code:"max_files",message:"Too many files. Some were not added."});let n=[];for(let e of s)n.push({id:jM(),type:"file",url:URL.createObjectURL(e),mediaType:e.type,filename:e.name});return e.concat(n)})},[b,a,o,l]),S=(0,$.useCallback)(e=>x(r=>{let s=r.find(r=>r.id===e);return s?.url&&URL.revokeObjectURL(s.url),r.filter(r=>r.id!==e)}),[]),C=(0,$.useCallback)(()=>x(e=>{for(let r of e)r.url&&URL.revokeObjectURL(r.url);return[]}),[]),j=f?h.attachments.add:w,k=f?h.attachments.remove:S,N=f?h.attachments.clear:C,E=f?h.attachments.openFileDialog:y;(0,$.useEffect)(()=>{f&&h.__registerFileInput(p,()=>p.current?.click())},[f,h]),(0,$.useEffect)(()=>{n&&p.current&&0===v.length&&(p.current.value="")},[v,n]),(0,$.useEffect)(()=>{let e=m.current;if(!e||i)return;let r=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},s=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&j(e.dataTransfer.files)};return e.addEventListener("dragover",r),e.addEventListener("drop",s),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",s)}},[j,i]),(0,$.useEffect)(()=>{if(!i)return;let e=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},r=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&j(e.dataTransfer.files)};return document.addEventListener("dragover",e),document.addEventListener("drop",r),()=>{document.removeEventListener("dragover",e),document.removeEventListener("drop",r)}},[j,i]),(0,$.useEffect)(()=>()=>{if(!f)for(let e of _.current)e.url&&URL.revokeObjectURL(e.url)},[f]);let D=async e=>{try{let r=await fetch(e),s=await r.blob();return new Promise(e=>{let r=new FileReader;r.onloadend=()=>e(r.result),r.onerror=()=>e(null),r.readAsDataURL(s)})}catch{return null}},R=(0,$.useMemo)(()=>({files:v.map(e=>({...e,id:e.id})),add:j,remove:k,clear:N,openFileDialog:E,fileInputRef:p}),[v,j,k,N,E]),A=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("input",{accept:r,"aria-label":"Upload files",className:"hidden",multiple:s,onChange:e=>{e.currentTarget.files&&j(e.currentTarget.files),e.currentTarget.value=""},ref:p,title:"Upload files",type:"file"}),(0,z.jsx)("form",{className:(0,ey.cn)("w-full",e),onSubmit:e=>{e.preventDefault();let r=e.currentTarget,s=f?h.textInput.value:new FormData(r).get("message")||"";f||r.reset(),Promise.all(v.map(async({id:e,...r})=>{if(r.url&&r.url.startsWith("blob:")){let e=await D(r.url);return{...r,url:e??r.url}}return r})).then(r=>{try{let i=c({text:s,files:r},e);i instanceof Promise?i.then(()=>{N(),f&&h.textInput.clear()}).catch(()=>{}):(N(),f&&h.textInput.clear())}catch{}}).catch(()=>{})},ref:m,...u,children:(0,z.jsx)(y1,{className:"overflow-hidden",children:d})})]});return f?A:(0,z.jsx)(jB.Provider,{value:R,children:A})},jW=({onChange:e,onKeyDown:r,onPasteText:s,className:i,placeholder:n="What would you like to know?",...a})=>{let o=jP(),l=jL(),[c,d]=(0,$.useState)(!1),u=o?{value:o.textInput.value,onChange:r=>{o.textInput.setInput(r.currentTarget.value),e?.(r)}}:{onChange:e};return(0,z.jsx)(y8,{className:(0,ey.cn)("field-sizing-content max-h-48 min-h-9",i),name:"message",onCompositionEnd:()=>d(!1),onCompositionStart:()=>d(!0),onKeyDown:e=>{if(r?.(e),!e.defaultPrevented){if("Enter"===e.key){if(c||e.nativeEvent.isComposing||e.shiftKey)return;e.preventDefault();let r=e.currentTarget.form,s=r?.querySelector('button[type="submit"]');if(s?.disabled)return;r?.requestSubmit()}if("Backspace"===e.key&&""===e.currentTarget.value&&l.files.length>0){e.preventDefault();let r=l.files.at(-1);r&&l.remove(r.id)}}},onPaste:e=>{let r=e.clipboardData?.items;if(!r)return;let i=[];for(let e of r)if("file"===e.kind){let r=e.getAsFile();r&&i.push(r)}if(i.length>0){e.preventDefault(),l.add(i);return}if(s){let r=e.clipboardData.getData("text");r.length>0&&s(e,r)}},placeholder:n,...a,...u})},jH=({className:e,...r})=>(0,z.jsx)(y5,{align:"block-end",className:(0,ey.cn)("order-first flex-wrap gap-1",e),...r}),jU=({variant:e="ghost",className:r,size:s,...i})=>{let n=s??($.Children.count(i.children)>1?"sm":"icon-sm");return(0,z.jsx)(y4,{className:(0,ey.cn)(r),size:n,type:"button",variant:e,...i})},jK=e=>(0,z.jsx)(ap,{...e}),jq=({className:e,children:r,...s})=>(0,z.jsx)(am,{asChild:!0,children:(0,z.jsx)(jU,{className:e,...s,children:r??(0,z.jsx)(eS,{className:"size-4"})})}),jV=({className:e,...r})=>(0,z.jsx)(ag,{align:"start",className:(0,ey.cn)(e),...r}),jY=({className:e,...r})=>(0,z.jsx)(ax,{className:(0,ey.cn)(e),...r}),jG=({className:e,variant:r="default",size:s="icon-sm",status:i,children:n,...a})=>{let o=(0,z.jsx)(jD,{className:"size-4"});return"submitted"===i?o=(0,z.jsx)(rk,{className:"size-4 animate-spin"}):"streaming"===i?o=(0,z.jsx)(uA,{className:"size-4"}):"error"===i&&(o=(0,z.jsx)(t8,{className:"size-4"})),(0,z.jsx)(y4,{"aria-label":"Submit",className:(0,ey.cn)(e),size:s,type:"submit",variant:r,...a,children:n??o})},jX=({openDelay:e=0,closeDelay:r=0,...s})=>(0,z.jsx)(jk,{closeDelay:r,openDelay:e,...s}),jJ=({align:e="start",...r})=>(0,z.jsx)(jE,{align:e,...r}),jZ=({size:e=16})=>(0,z.jsxs)("svg",{height:e,strokeLinejoin:"round",style:{color:"currentcolor"},viewBox:"0 0 16 16",width:e,children:[(0,z.jsx)("title",{children:"Loader"}),(0,z.jsxs)("g",{clipPath:"url(#clip0_2393_1490)",children:[(0,z.jsx)("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),(0,z.jsx)("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),(0,z.jsx)("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),(0,z.jsx)("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),(0,z.jsx)("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),(0,z.jsx)("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),(0,z.jsx)("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),(0,z.jsx)("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),(0,z.jsx)("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),(0,z.jsx)("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),(0,z.jsx)("defs",{children:(0,z.jsx)("clipPath",{id:"clip0_2393_1490",children:(0,z.jsx)("rect",{fill:"white",height:"16",width:"16"})})})]}),jQ=({className:e,size:r=16,...s})=>(0,z.jsx)("div",{className:(0,ey.cn)("inline-flex animate-spin items-center justify-center",e),...s,children:(0,z.jsx)(jZ,{size:r})}),j0=(0,ew.default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),j1=(0,ew.default)("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),j2=(0,ew.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),j5=(0,ew.default)("languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),j3=(0,ew.default)("split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]]),j4=e=>(0,ey.cn)("flex h-5 w-5 shrink-0 items-center justify-center rounded-full","codex"===e?"bg-emerald-500/10 text-emerald-600":"bg-violet-500/10 text-violet-600");function j6({agentType:e,currentAgentName:r,alternateProviders:s,onBranch:i,disabled:n,emphasis:a="normal"}){return(0,z.jsxs)(ap,{children:[(0,z.jsx)(am,{asChild:!0,children:(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:(0,ey.cn)("h-7 w-7 rounded-md transition-colors hover:bg-muted hover:text-foreground","subtle"===a?"text-muted-foreground/50 group-hover:text-muted-foreground group-focus-within:text-muted-foreground":"text-muted-foreground"),disabled:n,"aria-label":"Branch conversation",children:n?(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin"}):(0,z.jsx)(j3,{className:"h-4 w-4"})})}),(0,z.jsxs)(ag,{align:"start",className:"w-44 p-1.5",children:[(0,z.jsx)(ab,{className:"px-2 py-1.5",children:(0,z.jsx)("div",{className:"text-xs font-medium",children:"Branch conversation"})}),(0,z.jsxs)(ax,{className:"h-8 cursor-pointer items-center gap-2 rounded-md px-2 text-xs",onSelect:()=>i(),children:[(0,z.jsx)("div",{className:j4(e),children:(0,z.jsx)(aE,{className:"h-3 w-3"})}),(0,z.jsx)("span",{className:"min-w-0 flex-1 truncate",children:r}),(0,z.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:"current"})]}),s.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(aw,{className:"my-1"}),s.map(e=>(0,z.jsxs)(ax,{className:"h-8 cursor-pointer items-center gap-2 rounded-md px-2 text-xs",onSelect:()=>i(e.type),children:[(0,z.jsx)("div",{className:j4(e.type),children:(0,z.jsx)(aE,{className:"h-3 w-3"})}),(0,z.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.displayName})]},e.type))]})]})]})}function j8({durationMs:e,outcome:r,emphasis:s,agentType:i,currentAgentName:n,alternateProviders:a,onBranch:o,disabled:l}){let c=void 0!==e?function(e){let r=Math.round(e/1e3);if(r<60)return`${r}s`;let s=Math.floor(r/60),i=r%60;if(s<60)return i?`${s}m ${i}s`:`${s}m`;let n=Math.floor(s/60),a=s%60;return a?`${n}h ${a}m`:`${n}h`}(e):"server_restart"===r?"interrupted":null;return(0,z.jsxs)("div",{className:"group flex items-center gap-2 py-0.5","data-turn-end":!0,children:[(0,z.jsx)("div",{className:"h-px flex-1 bg-border/60"}),null!==c&&(0,z.jsx)("span",{className:(0,ey.cn)("shrink-0 text-[11px] tabular-nums transition-colors","subtle"===s?"text-muted-foreground/50 group-hover:text-muted-foreground group-focus-within:text-muted-foreground":"text-muted-foreground"),children:c}),(0,z.jsx)(j6,{agentType:i,currentAgentName:n,alternateProviders:a,onBranch:o,disabled:l,emphasis:s}),(0,z.jsx)("div",{className:"h-px flex-1 bg-border/60"})]})}let j7=(0,ew.default)("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);function j9({mode:e,onModeChange:r,disabled:s}){return(0,z.jsxs)("div",{className:"inline-flex items-center rounded-md border bg-muted/50 px-0.5 text-xs",children:[(0,z.jsxs)("button",{onClick:()=>r("plan"),disabled:s,className:(0,ey.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors","plan"===e?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground",s&&"opacity-50 cursor-not-allowed"),children:[(0,z.jsx)(j7,{className:"h-3 w-3"}),"Plan"]}),(0,z.jsxs)("button",{onClick:()=>r("edit"),disabled:s,className:(0,ey.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors","edit"===e?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground",s&&"opacity-50 cursor-not-allowed"),children:[(0,z.jsx)(rg,{className:"h-3 w-3"}),"Edit"]})]})}function ke(e){if(!e)return[];try{let r=window.localStorage.getItem(e);if(!r)return[];let s=JSON.parse(r);if(!Array.isArray(s))return[];return s.filter(e=>"string"==typeof e)}catch{return[]}}function kt(e){if(!e)return"";try{return window.localStorage.getItem(e)??""}catch{return""}}function kr(e){let r=e.parentElement;for(;r;){let{overflowY:e}=getComputedStyle(r);if("auto"===e||"scroll"===e)return r;r=r.parentElement}return null}function ks({messages:e,contentRef:r}){let[s,i]=(0,$.useState)([]),[n,a]=(0,$.useState)(!1),[o,l]=(0,$.useState)(null),c=(0,$.useRef)(null),d=(0,$.useCallback)(()=>{let s=r.current;if(!s)return;c.current||(c.current=kr(s));let n=c.current;if(!n)return;let o=n.scrollHeight>n.clientHeight;if(a(o),!o)return void i([]);let l=s.querySelectorAll("[data-user-msg-idx]"),d=n.getBoundingClientRect(),u=[];l.forEach(r=>{let s=parseInt(r.dataset.userMsgIdx,10),i=e[s];if(!i)return;let a=(r.getBoundingClientRect().top-d.top+n.scrollTop)/n.scrollHeight;u.push({index:s,position:Math.max(0,Math.min(1,a)),preview:function(e){if("user"!==e.type)return"";let r=e.content,s="string"==typeof r?r:r.filter(e=>"text"===e.type).map(e=>e.text).join(" "),i="string"!=typeof r&&r.some(e=>"image"===e.type),n=s.split("\n")[0]??"";return(n.length>80?n.slice(0,77)+"...":n)||(i?"(Image)":"")}(i)})}),i(u)},[e,r]);(0,$.useEffect)(()=>{let e=r.current;if(!e){c.current=null,i([]),a(!1);return}let s=kr(e);if(!s)return;c.current=s,d();let n=new ResizeObserver(d);return n.observe(s),n.observe(e),()=>{n.disconnect()}},[e,d,r]);let u=(0,$.useCallback)(e=>{let s=r.current;if(!s)return;let i=s.querySelector(`[data-user-msg-idx="${e}"]`);i&&i.scrollIntoView({block:"start",behavior:"smooth"})},[r]);return n&&0!==s.length?(0,z.jsx)("div",{className:"absolute right-0 top-0 bottom-0 w-6 z-20 pointer-events-none",children:s.map(e=>(0,z.jsxs)("div",{className:"absolute right-0.5 -translate-y-1/2 pointer-events-auto",style:{top:`${100*e.position}%`},children:[(0,z.jsx)("div",{className:"w-3 h-[3px] rounded-sm bg-primary/50 hover:bg-primary cursor-pointer transition-colors",onClick:()=>u(e.index),onMouseEnter:()=>l(e.index),onMouseLeave:()=>l(null)}),o===e.index&&e.preview&&(0,z.jsxs)("div",{className:"absolute right-full mr-2 top-1/2 -translate-y-1/2 max-w-64 px-2.5 py-1.5 bg-popover border border-border rounded-md shadow-md text-xs text-popover-foreground whitespace-nowrap overflow-hidden text-ellipsis pointer-events-none",children:[e.preview,(0,z.jsx)("div",{className:"absolute top-1/2 -translate-y-1/2 -right-1 w-2 h-2 bg-popover border-r border-t border-border rotate-45"})]})]},e.index))}):null}let ki=(0,ew.default)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);function kn({projectId:e,branch:r,currentSessionId:s,refreshKey:i,pendingTitleSessionId:n,aiTitleOverride:a,onSwitch:o,onDelete:l}){let[c,d]=(0,$.useState)([]),[u,h]=(0,$.useState)(null),[f,p]=(0,$.useState)(""),[m,g]=(0,$.useState)(!1),[x,v]=(0,$.useState)(null),[_,y]=(0,$.useState)(null),[b,w]=(0,$.useState)(0),S=(0,$.useCallback)(()=>w(e=>e+1),[]);(0,$.useEffect)(()=>{let s=!1;return(0,rv.listBranchSessions)(e,r).then(e=>{s||d(e.sessions)}).catch(e=>{s||console.error("[SessionHistoryDropdown] refresh failed:",e)}),()=>{s=!0}},[e,r,i,b]);let C=(0,$.useRef)(null);(0,$.useEffect)(()=>{if(!s)return;if(c.some(e=>e.id===s)){C.current=null;return}if(C.current===s)return;C.current=s;let i=!1;return(0,rv.listBranchSessions)(e,r).then(e=>{if(i)return;d(e.sessions);let r=e.sessions.find(e=>e.id===s),n=!!r&&(a?.sessionId===r.id||!!(r.title&&r.title.trim().length>0));r&&!n&&y(s)}).catch(e=>{i||console.error("[SessionHistoryDropdown] missing-session refresh failed:",e)}),()=>{i=!0}},[s,c,e,r,a]),(0,$.useEffect)(()=>{if(!_)return;let e=setTimeout(()=>{y(e=>e===_?null:e)},3e4);return()=>clearTimeout(e)},[_]),(0,$.useEffect)(()=>{if(!_)return;let e=setTimeout(()=>{y(e=>e===_?null:e)},3e4);return()=>clearTimeout(e)},[_]);let j=async(e,r)=>{let s=r.trim().length>0?r.trim():null;try{await (0,rv.renameSession)(e,s),d(r=>r.map(r=>r.id===e?{...r,title:s}:r)),h(null),xg.toast.success("Renamed")}catch(e){xg.toast.error("Rename failed"),console.error(e)}},k=async(e,r)=>{let s=null==r,i=s?Date.now():null;d(r=>r.map(r=>r.id===e?{...r,favorited_at:i}:r));try{await (0,rv.setSessionFavorited)(e,s)}catch(i){d(s=>s.map(s=>s.id===e?{...s,favorited_at:r}:s)),xg.toast.error(s?"Favorite failed":"Unfavorite failed"),console.error(i)}},N=async e=>{try{await (0,rv.deleteSession)(e);let r=c.filter(r=>r.id!==e);d(r),l?.(e,r),xg.toast.success("Deleted")}catch(e){xg.toast.error("Delete failed"),console.error(e)}},E=e=>a&&a.sessionId===e.id?a.title:e.title&&e.title.trim().length>0?e.title:e.updated_at?new Date(e.updated_at).toLocaleString():new Date(e.created_at).toLocaleString(),D=e=>{let r;return a?.sessionId!==e.id&&(!e.title||!(e.title.trim().length>0))&&(r=e.id,null!==n&&n===r||_===e.id)},R=c.find(e=>e.id===s),A=null!==s&&(!R||D(R)),M=R?E(R):null===s?"New Session":"History",F=A?"Generating title…":M;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(ap,{open:m,onOpenChange:e=>{g(e),e&&S()},children:[(0,z.jsx)(am,{asChild:!0,children:(0,z.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1 w-[200px] justify-start",title:F,children:[A?(0,z.jsx)("span",{className:"block h-3 flex-1 rounded-sm bg-accent animate-pulse",role:"status","aria-label":"Generating title"}):(0,z.jsx)("span",{className:"truncate flex-1 text-left",children:M}),(0,z.jsx)(sw,{className:"h-3 w-3 flex-shrink-0"})]})}),(0,z.jsxs)(ag,{align:"start",className:"w-80 max-h-96 overflow-y-auto",children:[0===c.length&&(0,z.jsx)("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:"No history yet."}),c.map(e=>{let r=e.id===s,i=u===e.id;return(0,z.jsxs)(ax,{onSelect:s=>{i?s.preventDefault():r||o(e.id)},onPointerMove:null!==u?e=>e.preventDefault():void 0,className:`flex items-center gap-2 group ${r?"bg-accent text-accent-foreground":""}`,children:[(0,z.jsx)("div",{className:"flex-1 min-w-0",children:i?(0,z.jsxs)("div",{className:"flex items-center gap-1",children:[(0,z.jsx)(ro,{value:f,onChange:e=>p(e.target.value),onKeyDown:r=>{r.stopPropagation(),"Enter"===r.key&&j(e.id,f),"Escape"===r.key&&h(null)},autoFocus:!0,className:"h-6 text-xs"}),(0,z.jsx)("button",{type:"button","aria-label":"Save rename",onClick:r=>{r.stopPropagation(),j(e.id,f)},children:(0,z.jsx)(rf.Check,{className:"h-3 w-3"})}),(0,z.jsx)("button",{type:"button","aria-label":"Cancel rename",onClick:e=>{e.stopPropagation(),h(null)},children:(0,z.jsx)(t8,{className:"h-3 w-3"})})]}):D(e)?(0,z.jsx)("div",{className:"py-0.5",title:"Generating title…",children:(0,z.jsx)("span",{className:"block h-3 w-40 rounded-sm bg-accent animate-pulse",role:"status","aria-label":"Generating title"})}):(0,z.jsx)("div",{className:"truncate text-xs",title:`${e.updated_at?new Date(e.updated_at).toLocaleString():new Date(e.created_at).toLocaleString()} • ${e.entry_count??0} messages • status: ${e.status}`,children:E(e)})}),!i&&(0,z.jsxs)("div",{className:"flex items-center gap-1",children:[(0,z.jsxs)("div",{className:"opacity-0 group-hover:opacity-100 flex items-center gap-1",children:[(0,z.jsx)("button",{type:"button","aria-label":"Rename conversation",onClick:r=>{r.stopPropagation(),h(e.id),p(e.title??"")},className:"p-1 hover:bg-muted rounded",children:(0,z.jsx)(rg,{className:"h-3 w-3"})}),(0,z.jsx)("button",{type:"button","aria-label":"Delete conversation",onClick:r=>{r.stopPropagation(),g(!1),v(e)},className:"p-1 hover:bg-muted rounded text-destructive",children:(0,z.jsx)(rc,{className:"h-3 w-3"})})]}),(0,z.jsx)("button",{type:"button","aria-label":null!=e.favorited_at?"Unfavorite conversation":"Favorite conversation",title:null!=e.favorited_at?"Unfavorite":"Favorite",onClick:r=>{r.stopPropagation(),k(e.id,e.favorited_at??null)},className:`p-1 hover:bg-muted rounded ${null!=e.favorited_at?"opacity-100 text-yellow-500":"opacity-0 group-hover:opacity-100 text-muted-foreground"}`,children:(0,z.jsx)(ki,{className:`h-3 w-3 ${null!=e.favorited_at?"fill-current":""}`})})]})]},e.id)}),c.length>0&&(0,z.jsx)(aw,{}),(0,z.jsx)(ax,{onSelect:()=>S(),className:"text-xs text-muted-foreground",children:"Refresh"})]})]}),(0,z.jsx)(lU,{open:null!==x,onOpenChange:e=>{e||v(null)},children:(0,z.jsxs)(lV,{children:[(0,z.jsxs)(lY,{children:[(0,z.jsx)(lX,{children:"Delete conversation?"}),(0,z.jsx)(lJ,{children:x?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("span",{className:"font-medium text-foreground",children:E(x)})," ","and its message history will be permanently deleted. This cannot be undone."]}):null})]}),(0,z.jsxs)(lG,{children:[(0,z.jsx)(lQ,{children:"Cancel"}),(0,z.jsx)(lZ,{className:(0,ey.cn)((0,W.buttonVariants)({variant:"destructive"}),"border-transparent"),onClick:()=>{x&&N(x.id),v(null)},children:"Delete"})]})]})})]})}let ka=(0,ew.default)("quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);function ko(e,r){let s=e;for(;s&&s!==r;){if(s.nodeType===Node.ELEMENT_NODE){let e=s.getAttribute("data-message-idx");if(null!==e)return e}s=s.parentNode}return null}function kl({containerRef:e,onQuote:r}){let[s,i]=(0,$.useState)(null);if((0,$.useEffect)(()=>{function r(){let r=e.current;if(!r)return void i(null);let s=window.getSelection();if(!s||s.isCollapsed||0===s.rangeCount)return void i(null);let n=s.toString();if(!n.trim())return void i(null);let{anchorNode:a,focusNode:o}=s;if(!a||!o||!r.contains(a)||!r.contains(o))return void i(null);let l=ko(a,r),c=ko(o,r);if(null===l||null===c||l!==c)return void i(null);let d=s.getRangeAt(0).getBoundingClientRect();0===d.width&&0===d.height?i(null):i({text:n,rect:{top:d.top,bottom:d.bottom,left:d.left,width:d.width}})}function s(){let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||i(null)}return document.addEventListener("mouseup",r),document.addEventListener("keyup",r),document.addEventListener("touchend",r),document.addEventListener("selectionchange",s),window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),()=>{document.removeEventListener("mouseup",r),document.removeEventListener("keyup",r),document.removeEventListener("touchend",r),document.removeEventListener("selectionchange",s),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",r)}},[e]),!s||"undefined"==typeof document)return null;let n=s.rect.top-8-30<8?s.rect.bottom+8:s.rect.top-8-30,a=s.rect.left+s.rect.width/2,o=Math.max(8,Math.min(window.innerWidth-8,a));return(0,ee.createPortal)((0,z.jsxs)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),r(s.text),window.getSelection()?.removeAllRanges(),i(null)},style:{position:"fixed",top:n,left:o,transform:"translateX(-50%)",zIndex:50},className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-2xl hover:bg-accent",children:[(0,z.jsx)(ka,{className:"h-3 w-3"}),"Quote"]}),document.body)}let kc=(0,ew.default)("search-check",[["path",{d:"m8 11 2 2 4-4",key:"1sed1v"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);function kd({projectId:e,branch:r,sessionId:s}){let[i,n]=(0,$.useState)(!1),[a,o]=(0,$.useState)(""),[l,c]=(0,$.useState)(!1),[d,u]=(0,$.useState)(null);if(!s)return null;let h=async()=>{c(!0),u(null);try{await rv.api.createWorkflowRun({projectId:e,branch:r,sourceSessionId:s,reviewFocus:a.trim()||void 0}),n(!1),o("")}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}};return(0,z.jsxs)(t7,{open:i,onOpenChange:n,children:[(0,z.jsx)(t9,{asChild:!0,children:(0,z.jsx)(W.Button,{variant:"ghost",size:"sm",title:"让另一个 agent review 这个 session 的最新成果",children:(0,z.jsx)(kc,{className:"h-4 w-4"})})}),(0,z.jsxs)(rr,{className:"sm:max-w-md",children:[(0,z.jsx)(rs,{children:(0,z.jsx)(rn,{children:"发起 Review"})}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"将创建一个 reviewer session 审查本 session 最近完成的工作。反馈会先经你确认,再发回本 session。"}),(0,z.jsx)("input",{className:"w-full rounded-md border bg-transparent px-3 py-2 text-sm",placeholder:"Review focus(可选):本次审查重点…",value:a,onChange:e=>o(e.target.value)}),d&&(0,z.jsx)("p",{className:"text-sm text-destructive",children:d}),(0,z.jsx)(ri,{children:(0,z.jsx)(W.Button,{onClick:h,disabled:l,children:"开始 Review"})})]})]})}function ku(){return 0===jL().files.length?null:(0,z.jsx)(jH,{children:(0,z.jsx)(jO,{children:e=>(0,z.jsx)(jI,{data:e})})})}let kh=(0,$.createContext)(null);function kf(){let e=(0,$.useContext)(kh);if(!e)throw Error("useAgentConversation must be used within AgentConversationContext");return e}let kp=/\[📎 paste #(\d+) \([^)]+\)\]/g;function km(e,r){return`[📎 paste #${e} (${function(e){if(e<1024)return`${e}B`;let r=e/1024;return r<10?`${r.toFixed(1)}KB`:`${Math.round(r)}KB`}(r)})]`}let kg=(0,$.forwardRef)(function({projectId:e,branch:r,sessionId:s,setSessionUrlParam:i,project:n,onAgentModeChange:a,onTaskCompleted:o,onSessionStarted:l,onSessionTitleUpdated:c,onStatusChange:d,onNewConversation:u},h){var f;let p,m,g,x,[v,_]=function(e,r){let s=e&&r?`vibedeckx:agent-draft:${e}:${r}`:null,[i,n]=(0,$.useState)(()=>kt(s)),[a,o]=(0,$.useState)(s);return a!==s&&(o(s),n(kt(s))),[i,(0,$.useCallback)(e=>{n(e);if(s)try{e?window.localStorage.setItem(s,e):window.localStorage.removeItem(s)}catch{}},[s])]}(e,r),[y,b]=(0,$.useState)([]),[w,S]=(0,$.useState)(1),[C,j]=(0,$.useState)("edit"),[k,N]=(0,$.useState)(!1),[E,D]=(0,$.useState)(!1),[R,A]=(0,$.useState)(!1),[M,F]=(0,$.useState)("claude-code"),[T,P]=(0,$.useState)([]),[B,L]=(0,$.useState)(0),[I,O]=(0,$.useState)(null),[H,U]=(0,$.useState)(null),K=(0,$.useRef)(null),q=(0,$.useCallback)(e=>{if("ArrowUp"!==e.key&&"ArrowDown"!==e.key||!e.shiftKey||e.ctrlKey||e.metaKey||e.altKey)return;let r=K.current;if(!r)return;let s=kr(r);if(!s)return;let i=s.getBoundingClientRect(),n=s.scrollTop,a="ArrowUp"===e.key,o=null,l=a?-1/0:1/0;r.querySelectorAll("[data-user-msg-idx]").forEach(e=>{let r=e.getBoundingClientRect().top-i.top+s.scrollTop;a?r<n-12&&r>l&&(l=r,o=e):r>n+12&&r<l&&(l=r,o=e)}),o&&(e.preventDefault(),o.scrollIntoView({block:"start",behavior:"smooth"}))},[K]),V=(0,$.useRef)(null),Y=function(e,r,s){let i=r&&s?`vibedeckx:agent-input-history:${r}:${s}`:null,n=(0,$.useRef)(ke(i)),a=(0,$.useRef)(-1),o=(0,$.useRef)(""),[l,c]=(0,$.useState)(i);return l!==i&&(c(i),n.current=ke(i),a.current=-1,o.current=""),{push:(0,$.useCallback)(e=>{let r=e.trim();if(!r)return;let s=n.current;if(s.length>0&&s[s.length-1]===r){a.current=-1;return}s.push(r),s.length>50&&s.shift(),a.current=-1;if(i)try{0===s.length?window.localStorage.removeItem(i):window.localStorage.setItem(i,JSON.stringify(s))}catch{}},[i]),handleKeyDown:(0,$.useCallback)(r=>{let s=r.currentTarget,i=n.current;if(0!==i.length)if("ArrowUp"===r.key){if(0!==s.selectionStart||0!==s.selectionEnd)return;if(r.preventDefault(),-1===a.current)o.current=s.value,a.current=i.length-1;else{if(!(a.current>0))return;a.current--}e(i[a.current])}else if("ArrowDown"===r.key){if(-1===a.current)return;let n=s.value.length;if(s.selectionStart!==n||s.selectionEnd!==n)return;r.preventDefault(),a.current<i.length-1?(a.current++,e(i[a.current])):(a.current=-1,e(o.current))}else -1!==a.current&&(a.current=-1)},[e])}}(_,e,r),{remotes:G}=_m(),X=[];for(let e of(n?.path&&X.push({id:"local",label:"Local",icon:aD}),G))X.push({id:e.remote_server_id,label:e.server_name,icon:sd(e)});let{session:J,messages:Z,status:Q,isConnected:ee,isInitialized:et,isLoading:er,error:es,remoteStatus:ei,sendMessage:en,uploadPaste:ea,stopSession:eo,switchAgentType:el,startNewConversation:ec,ensureSession:ed,switchMode:eu,acceptPlan:eh,residentLimitPrompt:ef}=function(e,r,s,i,n){let a=n?.sessionId??null,[o,l]=(0,$.useState)(null),[c,d]=(0,$.useState)([]),[u,h]=(0,$.useState)("stopped"),[f,p]=(0,$.useState)(!1),[m,g]=(0,$.useState)(!1),[x,v]=(0,$.useState)(!1),[_,y]=(0,$.useState)(null),[b,w]=(0,$.useState)(null),S=(0,$.useRef)(null),C=(0,$.useRef)(null),j=(0,$.useRef)(()=>{}),k=(0,$.useRef)(null),N=(0,$.useRef)(0),E=(0,$.useRef)({entries:[],status:"stopped"}),D=(0,$.useRef)(!1),R=(0,$.useRef)(!0),A=(0,$.useRef)(null),M=(0,$.useRef)(null),F=(0,$.useRef)(0),T=(0,$.useRef)(!1),P=(0,$.useRef)(0),B=(0,$.useRef)(!1),L=(0,$.useRef)(!1),I=(0,$.useRef)(n?.onTaskCompleted),O=(0,$.useRef)(n?.onSessionStarted),z=(0,$.useRef)(n?.onTitleUpdated),W=(0,$.useRef)(e),H=(0,$.useRef)(r),U=(0,$.useRef)(a);(0,$.useEffect)(()=>{I.current=n?.onTaskCompleted,O.current=n?.onSessionStarted,z.current=n?.onTitleUpdated,W.current=e,H.current=r,U.current=a});let K=(0,$.useCallback)((e,r=!1)=>{(0,rv.getFreshToken)(r?{skipCache:!0}:void 0).then(()=>j.current(e))},[]),q=(0,$.useCallback)(e=>{let r=()=>{let e=W.current;if(!e)return;let r=H.current;SU.delete(SK(e,r,U.current));let s=C.current;s&&SU.delete(SK(e,r,s))};if(S.current&&C.current!==e&&(console.log(`[AgentSession] Closing stale WS for ${C.current}, switching to ${e}`),S.current.close(1e3,"session-switch"),S.current=null,C.current=null),S.current?.readyState===WebSocket.OPEN||S.current?.readyState===WebSocket.CONNECTING)return;0===E.current.entries.filter(Boolean).length&&(E.current={entries:[],status:"running"}),D.current=!1,T.current=!0;let s=(0,rv.getWebSocketUrl)(`/api/agent-sessions/${e}/stream`);console.log("[AgentSession] Connecting to WebSocket:",s);let i=new WebSocket(s);S.current=i,C.current=e,i.onopen=()=>{console.log("[AgentSession] WebSocket connected"),p(!0),y(null),w(null),A.current=Date.now(),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{console.log("[AgentSession] Connection stable, resetting backoff counter"),N.current=0,F.current=0},5e3)},i.onmessage=e=>{try{let n=JSON.parse(e.data);if("JsonPatch"in n){var s;let e=n.JsonPatch;s=E.current,E.current=SS(s,r=>{for(let s of e){let{op:e,path:i,value:n}=s;if("/entries"===i&&"replace"===e&&n?.type==="ENTRY"&&n.content?.type==="system"&&n.content?.content==="__CLEAR_ALL__"){console.log("[JsonPatch] Received clearAll signal - clearing all entries"),r.entries=[];continue}if(i.startsWith("/entries/")){let s=parseInt(i.replace("/entries/",""),10);if(isNaN(s)){console.warn(`[JsonPatch] Invalid index in path: ${i}`);continue}if(n?.type!=="ENTRY"){console.warn("[JsonPatch] Expected ENTRY type for entries path");continue}switch(e){case"add":for(;r.entries.length<=s;)r.entries.push(null);r.entries[s]=n.content;break;case"replace":s<r.entries.length?r.entries[s]=n.content:console.warn(`[JsonPatch] Replace index out of bounds: ${s}`);break;case"remove":s<r.entries.length&&r.entries.splice(s,1)}}else"/status"===i&&n?.type==="STATUS"&&(console.log("[AgentSession] /status patch →",n.content),r.status=n.content)}}),T.current?console.log("[AgentSession] /status patch applied during replay (no setStatus), container.status =",E.current.status):(d([...E.current.entries.filter(Boolean)]),console.log("[AgentSession] setStatus(live) →",E.current.status),h(E.current.status),("stopped"===E.current.status||"error"===E.current.status)&&r());return}if("Ready"in n){console.log("[AgentSession] Received Ready signal - history complete, status=",E.current.status),T.current=!1,d([...E.current.entries.filter(Boolean)]),h(E.current.status),g(!0);return}if("finished"in n){console.log("[AgentSession] Received finished signal, invalidating cache"),D.current=!0,r(),i.close(1e3,"finished");return}if("taskCompleted"in n){let{duration_ms:e,cost_usd:r,input_tokens:s,output_tokens:i}=n.taskCompleted,a=[];if(null!=e){let r=(e/1e3).toFixed(1);a.push(`${r}s`)}if(null!=r)a.push(`$${r.toFixed(4)}`);else if(null!=s||null!=i){let e=(s??0)+(i??0),r=e>1e3?`${(e/1e3).toFixed(1)}K`:String(e);a.push(`${r} tokens`)}xg.toast.success("Task completed",{description:a.length>0?a.join(" · "):void 0}),I.current?.();return}if("remoteStatus"in n)return void w(n.remoteStatus);if("titleUpdated"in n)return void z.current?.(n.titleUpdated.title,C.current);if("error"in n){console.error("[AgentSession] Server error:",n.error),y(n.error),"Session not found"===n.error&&(console.log("[AgentSession] Session invalid, invalidating cache, will create new session"),r(),D.current=!0,l(null),h("stopped"),g(!1),R.current=!0);return}}catch(e){console.error("[AgentSession] Failed to parse message:",e)}},i.onclose=e=>{let s,i;console.log("[AgentSession] WebSocket disconnected",e.code,e.reason),p(!1),M.current&&(clearTimeout(M.current),M.current=null);let n=A.current?Date.now()-A.current:0;if(A.current=null,n>0&&n<5e3){if(F.current++,console.log(`[AgentSession] Short-lived connection (${n}ms), count: ${F.current}, backoff attempt: ${N.current}`),F.current>=3){if(console.log("[AgentSession] Multiple short-lived connections detected, session likely invalid - will recreate"),B.current){console.log("[AgentSession] Skipping auto-restart: last session creation failed"),y("Unable to connect to remote server. Please check the server configuration.");return}r(),l(null),y(null),N.current=0,F.current=0,R.current=!0;return}}else n>=5e3&&(F.current=0);if(D.current||1e3===e.code)return;if(N.current>=10){console.log("[AgentSession] Max reconnect attempts reached"),y("Unable to connect to server. Please check if the backend is running.");return}let a=(i=(s=Math.min(3e4,1e3*Math.pow(2,N.current)))*Math.random()*.25,s+i);console.log(`[AgentSession] Reconnecting in ${Math.round(a)}ms (attempt ${N.current+1})`),N.current++,k.current=setTimeout(()=>{let e=C.current;e&&!D.current&&K(e,!0)},a)},i.onerror=e=>{console.error("[AgentSession] WebSocket error:",e)}},[K]);(0,$.useEffect)(()=>{j.current=q},[q]);let V=(0,$.useCallback)(async s=>{if(!e)return null;if(L.current)return console.log("[AgentSession] startSession already in progress, skipping"),null;L.current=!0;let n=P.current;y(null),w(null),g(!1),B.current=!1;let o=SK(e,r,a),c=SU.get(o);if(c)return console.log(`[AgentSession] Cache hit for ${o}, reconnecting WebSocket directly`),l(c),h(c.status),K(c.id),O.current?.(c),L.current=!1,c;v(!0);try{console.log(`[AgentSession] Starting REST call: projectId=${e}, branch=${r}, sessionId=${a??"latest"}, agentType=${i}, generation=${n}`);let{session:c,messages:u}=a?await Sq(a):await SB(e,r,s,i);if(P.current!==n)return console.log("[AgentSession] Discarding stale session response (generation mismatch)"),null;if(!c)return console.log(`[AgentSession] No existing session for ${e}/${r??"<null>"} — placeholder`),l(null),h("stopped"),d([]),E.current={entries:[],status:"stopped"},g(!0),null;return console.log(`[AgentSession] REST response: sessionId=${c.id}, msgCount=${u?.length??0}, status=${c.status}, explicitSessionIdRequested=${a??"<null>"}`),SU.set(o,c),a&&SU.set(SK(e,r,c.id),c),l(c),h(c.status),u&&u.length>0&&(d(u),E.current={entries:[...u],status:c.status}),K(c.id),O.current?.(c),c}catch(e){if(console.error("[AgentSession] startSession error:",e),P.current!==n)return console.log("[AgentSession] Discarding error (generation mismatch)"),null;return y(e instanceof Error?e.message:"Failed to start session"),B.current=!0,null}finally{L.current=!1,P.current===n&&v(!1)}},[e,r,i,a,K]),Y=(0,$.useCallback)(async(s,i)=>{let n=i||o?.id;if(!n)return void console.warn("[AgentSession] sendMessage: no session ID available (sessionId param:",i,", session?.id:",o?.id,")");if(("string"!=typeof s||s.trim())&&(!Array.isArray(s)||0!==s.length)){console.log(`[AgentSession] sendMessage: targetSessionId=${n}, source=${i?"explicit":"state"}`);try{let e="string"==typeof s?s.trim():s;await SL(n,e)}catch(i){let s=i instanceof Error?i.message:"Failed to send message";console.error("[AgentSession] Failed to send message:",s),s.includes("[404]")&&(e&&(SU.delete(SK(e,r,a)),o?.id&&SU.delete(SK(e,r,o.id))),l(null),h("stopped"),g(!1),R.current=!0),y(s),xg.toast.error("Failed to send message",{description:s})}}},[o?.id,e,r,a]),G=(0,$.useCallback)(async(e,r)=>{let s=r||o?.id;if(!s)throw Error("No session id available for paste upload");return SI(s,e)},[o?.id]),X=(0,$.useCallback)(async()=>{if(o?.id)try{await S$(o.id)}catch(e){e instanceof Error&&e.message,console.error("[AgentSession] Failed to stop session:",e),xg.toast.error("Failed to stop session")}},[o?.id]),J=(0,$.useCallback)(async s=>{if(o?.id){e&&(SU.delete(SK(e,r,a)),SU.delete(SK(e,r,o.id))),v(!0),y(null);try{await SO(o.id,s),s&&l(e=>e?{...e,agentType:s}:null)}catch(e){y(e instanceof Error?e.message:"Failed to restart session"),console.error("[AgentSession] Failed to restart session:",e)}finally{v(!1)}}},[o?.id,e,r,a]),Z=(0,$.useCallback)(async s=>{if(!o?.id)return"No active session";y(null);try{return await Sz(o.id,s),l(i=>{if(!i)return i;let n={...i,agentType:s};return e&&(SU.set(SK(e,r,a),n),SU.set(SK(e,r,n.id),n)),n}),null}catch(r){let e=r instanceof Error?r.message:"Failed to switch agent";return console.error("[AgentSession] Failed to switch agent:",r),e}},[o?.id,e,r,a]),Q=(0,$.useCallback)(async s=>{if(o?.id){y(null);try{await SW(o.id,s),l(i=>{if(!i)return i;let n={...i,permissionMode:s};return e&&(SU.set(SK(e,r,a),n),SU.set(SK(e,r,n.id),n)),n})}catch(e){y(e instanceof Error?e.message:"Failed to switch mode"),console.error("[AgentSession] Failed to switch mode:",e)}}},[o?.id,e,r,a]),ee=(0,$.useCallback)(async s=>{if(o?.id){y(null);try{await SH(o.id,s),l(s=>{if(!s)return s;let i={...s,permissionMode:"edit"};return e&&(SU.set(SK(e,r,a),i),SU.set(SK(e,r,i.id),i)),i})}catch(e){y(e instanceof Error?e.message:"Failed to accept plan"),console.error("[AgentSession] Failed to accept plan:",e)}}},[o?.id,e,r,a]),et=(0,$.useCallback)(async()=>{var i;let n;return e?(o?.id&&SU.delete(SK(e,r,o.id)),SU.delete(SK(e,r,a)),S.current&&(S.current.close(1e3,"new-conversation"),S.current=null,C.current=null),k.current&&(clearTimeout(k.current),k.current=null),M.current&&(clearTimeout(M.current),M.current=null),D.current=!1,T.current=!1,p(!1),l(null),h("stopped"),g(!0),y(null),w(null),d([]),E.current={entries:[],status:"stopped"},i=SF(e,r,s),(n=new Map(Sk)).set(i,Date.now()),Sj(Sk=n),SD(),null):null},[e,r,s,o?.id,a]),[er,es]=(0,$.useState)(null),ei=(0,$.useRef)(null),en=(0,$.useCallback)(()=>{ei.current?.resolve(!1),ei.current=null,es(null)},[]),ea=(0,$.useRef)(null),eo=(0,$.useCallback)(n=>{if(!e)return Promise.resolve(null);if(o)return Promise.resolve(o);let c=P.current,d=ea.current;if(d&&d.generation===c)return d.promise;let u=(async()=>{v(!0),y(null);try{let o;try{o=await (0,rv.createNewAgentSession)(e,r,n,i)}catch(u){let s;if(!(u instanceof rv.ResidentLimitError))throw u;let a=new Promise(e=>{s=e}),l={maxResidentAgentProcesses:u.maxResidentAgentProcesses,runningSessions:u.runningSessions,resolve:s};ei.current=l,es(l);let d=await a;if(ei.current===l&&(ei.current=null),es(e=>e===l?null:e),P.current!==c)return null;if(!d)throw u;o=await (0,rv.createNewAgentSession)(e,r,n,i,!0)}if(P.current!==c)return console.log("[AgentSession] Discarding stale ensureSession result (generation mismatch)"),null;let d={id:o.session.id,projectId:o.session.projectId,branch:o.session.branch,status:o.session.status,permissionMode:o.session.permissionMode??"edit",agentType:o.session.agentType??"claude-code",processAlive:o.session.processAlive??!0};return SU.set(SK(e,r,a),d),SU.set(SK(e,r,d.id),d),l(d),h(d.status),g(!0),ST(SF(e,r,s)),K(d.id),O.current?.(d),d}catch(e){if(console.error("[AgentSession] ensureSession:",e),P.current!==c)return null;return y(e instanceof Error?e.message:"Failed to create session"),null}finally{ea.current?.generation===c&&(ea.current=null),P.current===c&&v(!1)}})();return ea.current={generation:c,promise:u},u},[e,r,s,i,o,a,K]);return(0,$.useEffect)(()=>()=>{S.current&&(D.current=!0,S.current.close(),C.current=null),k.current&&clearTimeout(k.current),M.current&&clearTimeout(M.current),P.current+=1,en()},[en]),(0,$.useEffect)(()=>{S.current&&(S.current.close(1e3,"branch-switch"),S.current=null,C.current=null),k.current&&(clearTimeout(k.current),k.current=null),M.current&&(clearTimeout(M.current),M.current=null),P.current+=1,en();let i=e?SF(e,r,s):null;i&&a&&ST(i);let n=!a&&null!==i&&Sk.has(i);l(null),h("stopped"),p(!1),g(n),y(null),v(!1),w(null),d([]),E.current={entries:[],status:"stopped"},D.current=!1,N.current=0,A.current=null,F.current=0,B.current=!1,L.current=!1,R.current=!n,e&&SU.delete(SK(e,r,a))},[e,r,s,a,en]),(0,$.useEffect)(()=>{var i;let n=null!==e&&(i=SF(e,r,s),Sk.has(i));!R.current||!e||o||x||B.current||n||(R.current=!1,console.log(`[AgentSession] Auto-start: projectId=${e}, branch=${r}, agentMode=${s}`),V())},[e,r,s,o,x,V]),(0,$.useEffect)(()=>{let e=()=>{if("visible"===document.visibilityState&&o?.id&&!D.current){let e=S.current;e&&e.readyState!==WebSocket.CLOSED&&e.readyState!==WebSocket.CLOSING||(console.log("[AgentSession] Tab visible, WebSocket disconnected - reconnecting"),N.current=0,F.current=0,k.current&&(clearTimeout(k.current),k.current=null),K(o.id))}};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[o?.id,K]),(0,$.useEffect)(()=>{o?.id&&!D.current&&K(o.id)},[o?.id,K]),{session:o,messages:c,status:u,isConnected:f,isInitialized:m,isLoading:x,error:_,remoteStatus:b,startSession:V,sendMessage:Y,uploadPaste:G,stopSession:X,restartSession:J,switchAgentType:Z,startNewConversation:et,ensureSession:eo,switchMode:Q,acceptPlan:ee,residentLimitPrompt:er}}(e,r,n?.agent_mode,M,{sessionId:s,onTaskCompleted:o,onSessionStarted:l,onTitleUpdated:(e,r)=>{let s=r??J?.id;s&&e&&(U({sessionId:s,title:e}),c?.(s,e)),L(e=>e+1),O(null)}});f=J?.id??null,(0,ok.useGlobalEventStream)(s=>{"session:status"!==s.type||"running"!==s.status||!e||s.projectId!==e||(s.branch??null)!==(r??null)||s.sessionId&&s.sessionId!==f&&(e=>i?.(e))(s.sessionId)}),(0,$.useEffect)(()=>{(0,rv.getAgentProviders)().then(P).catch(()=>{})},[]),(0,$.useEffect)(()=>{J?.permissionMode&&j(J.permissionMode)},[J?.permissionMode]),(0,$.useEffect)(()=>{J?.agentType&&F(J.agentType)},[J?.agentType]),(0,$.useEffect)(()=>{b([]),S(1)},[e,r]);let ep=(0,$.useRef)({sessionId:null,count:0});(0,$.useEffect)(()=>{let e=J?.id??null,r=ep.current;e&&r.sessionId===e&&0===r.count&&Z.length>0&&O(e),ep.current={sessionId:e,count:Z.length}},[J?.id,Z.length]),(0,$.useEffect)(()=>{I&&J?.id!==I&&O(null)},[J?.id,I]),(0,$.useEffect)(()=>{H&&J?.id!==H.sessionId&&U(null)},[J?.id,H]),(0,$.useEffect)(()=>{if(!H)return;let e=setTimeout(()=>{U(e=>e===H?null:e)},5e3);return()=>clearTimeout(e)},[H]),(0,$.useEffect)(()=>{if(!I)return;let e=setTimeout(()=>{O(e=>e===I?null:e)},3e4);return()=>clearTimeout(e)},[I]);let[em,eg]=(0,$.useState)(!1);(0,$.useEffect)(()=>{eg(!1)},[J?.id]),(0,$.useEffect)(()=>{ee&&eg(!0)},[ee]);let ex=async e=>{j(e),J&&await eu(e)},ev=async e=>{await eh(e),j("edit"),d?.()},[e_,eb]=(0,$.useState)(!1),ew=async(e,r)=>{if(J&&!e_){eb(!0);try{let s=await (0,rv.branchAgentSession)(J.id,e,r);L(e=>e+1),i?.(s.session.id)}catch(r){let e=r instanceof Error?r.message:"Failed to branch conversation";xg.toast.error("Branch failed",{description:e})}finally{eb(!1)}}},eS=T.find(e=>e.type===M)?.displayName??("codex"===M?"Codex":"Claude Code"),eC=T.filter(e=>e.available).filter(e=>e.type!==M),ej=(0,$.useMemo)(()=>{for(let e=Z.length-1;e>=0;e--)if(Z[e]?.type==="turn_end")return e;return -1},[Z]),ek=(0,$.useCallback)(e=>{var r,s;let i;_((r=v,s=e,i=0===r.length||r.endsWith("\n\n")?"":r.endsWith("\n")?"\n":"\n\n",r+i+(s.replace(/\r?\n/g,"\n").split("\n").map(e=>`> ${e}`).join("\n")+"\n\n"))),requestAnimationFrame(()=>{let e=V.current?.querySelector("textarea");if(!e)return;e.focus();let r=e.value.length;try{e.setSelectionRange(r,r)}catch{}})},[_,v]);(0,$.useImperativeHandle)(h,()=>({submitMessage:async e=>{if(d?.(),J)en(e);else{let r=await ed(C);r&&(O(r.id),en(e,r.id))}}}),[J,ed,en,C,d]);let eN=(0,$.useCallback)((e,r)=>{if(r.length<=2e3)return;e.preventDefault();let s=e.currentTarget,i=s.selectionStart??v.length,n=s.selectionEnd??v.length,a=new TextEncoder().encode(r).length,o=km(w,a);_(v.slice(0,i)+o+v.slice(n)),b(e=>[...e,{id:w,content:r,size:a}]),S(w+1);let l=i+o.length;requestAnimationFrame(()=>{try{s.setSelectionRange(l,l)}catch{}})},[v,w,_]);async function eE(e,r,s,i){let n=new Set;for(let r of e.matchAll(kp))n.add(Number(r[1]));let a=r.filter(e=>n.has(e.id));if(0===a.length)return e;let o=e;for(let e of a){let r=await s(e.content,i),n=km(e.id,e.size),a=`<vpaste path="${r.path}" size="${r.size}" />`;o=o.split(n).join(a)}return o}let eD=async e=>{let r=e.text,s=e.files.length>0,i=y.length>0,n=r.trim();if(n||s){A(!0);try{let a;_(""),Y.push(n),d?.();let o=J?.id,l=null;if(!J){if(!(l=await ed(C)))return void _(r);o=l.id,O(l.id)}let c=n;if(i)try{c=(await eE(r,y,ea,o)).trim()}catch(s){let e=s instanceof Error?s.message:"Failed to upload paste";xg.toast.error("Paste upload failed",{description:e}),_(r);return}if(c.length>2e3)try{let e=await ea(c,o);c=`<vpaste path="${e.path}" size="${e.size}" />`}catch(s){let e=s instanceof Error?s.message:"Failed to upload paste";xg.toast.error("Paste upload failed",{description:e}),_(r);return}if(b([]),S(1),s){let r=[];for(let s of(c&&r.push({type:"text",text:c}),e.files))if(s.mediaType&&s.url){let e=s.url.match(/^data:[^;]+;base64,(.+)$/);e&&r.push({type:"image",mediaType:s.mediaType,data:e[1]})}a=r}else a=c;if(k){let e="string"==typeof a?a:a.filter(e=>"text"===e.type).map(e=>e.text).join("\n");if(e.trim()){D(!0);try{let s=await (0,rv.translateText)(e);if(s.error){_(r),b(y),S(w),xg.toast.error("Translation failed",{description:"Disable translation to send the original text."});return}a="string"==typeof a?s.translatedText:a.map(e=>"text"===e.type?{...e,text:s.translatedText}:e)}catch{_(r),b(y),S(w),xg.toast.error("Translation failed",{description:"Disable translation to send the original text."});return}finally{D(!1)}}}l?(console.log(`[AgentConversation] handleSubmit: using freshly started session ${l.id}`),await en(a,l.id)):(console.log(`[AgentConversation] handleSubmit: existing session ${J.id}, status=${Q}`),await en(a))}finally{A(!1)}}},{settings:eR}=(0,dh.useConversationSettings)();return e?(0,z.jsxs)("div",{className:"h-full flex flex-col min-h-0",style:{"--conv-font-size":`${eR.agentFontSize}px`},children:[(0,z.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-between px-4 h-10 border-b border-border/60 bg-muted/20",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[T.length>1?(0,z.jsxs)(ap,{children:[(0,z.jsx)(am,{asChild:!0,children:(0,z.jsxs)("button",{disabled:er||"running"===Q&&Z.length>0,className:(0,ey.cn)("inline-flex items-center gap-1 rounded-md border bg-muted/50 px-2 py-0.5 text-xs font-medium transition-colors hover:bg-muted",(er||"running"===Q&&Z.length>0)&&"opacity-50 cursor-not-allowed"),children:[T.find(e=>e.type===M)?.displayName??("codex"===M?"Codex":"Claude Code"),(0,z.jsx)(sw,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,z.jsx)(ag,{align:"start",children:(0,z.jsx)(a_,{value:M,onValueChange:async e=>{if(!J)return void F(e);let r=await el(e);r?xg.toast.error("Failed to switch agent",{description:r}):F(e)},children:T.map(e=>(0,z.jsx)(ay,{value:e.type,disabled:!e.available,className:"text-xs pl-2 [&>span:first-child]:hidden data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",children:e.displayName},e.type))})})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(aE,{className:`h-4 w-4 ${"codex"===M?"text-green-500":"text-violet-500"}`}),(0,z.jsx)("span",{className:"text-sm font-medium",children:"codex"===M?"Codex":"Claude Code"})]}),(0,z.jsx)(j9,{mode:C,onModeChange:ex}),X.length>=1&&a&&(0,z.jsx)(ak,{targets:X,activeTarget:n?.agent_mode??"local",onTargetChange:a}),J&&(p=J.id.startsWith("remote-"),m="text-muted-foreground",g=(0,z.jsx)(j1,{className:"h-3 w-3"}),x="Disconnected",ee?p&&"connected"!==ei&&null!==ei?"reconnecting"===ei?(m="text-amber-500",g=(0,z.jsx)(j0,{className:"h-3 w-3 animate-pulse"}),x="Reconnecting..."):"disconnected"===ei&&(m="text-red-500",g=(0,z.jsx)(j1,{className:"h-3 w-3"}),x="Remote disconnected"):(m="text-green-500",g=(0,z.jsx)(j0,{className:"h-3 w-3"}),x="Connected"):em||(m="text-amber-500",g=(0,z.jsx)(j0,{className:"h-3 w-3 animate-pulse"}),x="Connecting..."),(0,z.jsxs)("span",{className:`flex items-center gap-1 text-xs ${m}`,children:[g,x]}))]}),(0,z.jsxs)("div",{className:"flex items-center gap-1",children:[e&&(0,z.jsx)(kd,{projectId:e,branch:r,sessionId:J?.id??null}),e&&(0,z.jsx)(kn,{projectId:e,branch:r,currentSessionId:J?.id??null,refreshKey:B,pendingTitleSessionId:I,aiTitleOverride:H,onSwitch:e=>{i?.(e)},onDelete:(e,r)=>{if(e===J?.id){let e=r[0];i?.(e?e.id:null)}}}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:async()=>{await ec(),u?.(),i?.(null)},disabled:er||!J,className:"h-7 w-7",title:"New Conversation",children:(0,z.jsx)(j2,{className:"h-3.5 w-3.5"})}),(0,z.jsxs)(W.Button,{variant:"ghost",size:"sm",onClick:()=>eo(),disabled:"running"!==Q,className:"h-7 text-xs",children:[(0,z.jsx)(uA,{className:"h-3 w-3 mr-1"}),"Stop"]})]})]}),(0,z.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[(0,z.jsxs)(ja,{className:"h-full",initial:"instant",children:[(0,z.jsxs)(jo,{className:"gap-1 p-4",scrollClassName:"edge-scrollbar",children:[J||0!==Z.length?(0,z.jsx)(kh.Provider,{value:{sendMessage:en,messages:Z,acceptPlan:ev,permissionMode:J?.permissionMode??C,agentType:J?.agentType??M,sessionId:J?.id??null},children:(0,z.jsxs)("div",{className:"space-y-1 outline-none",ref:K,tabIndex:-1,onKeyDown:q,children:[Z.map((e,r)=>e?.type==="turn_end"?(0,z.jsx)(j8,{durationMs:e.durationMs,outcome:e.outcome,emphasis:r===ej?"normal":"subtle",agentType:M,currentAgentName:eS,alternateProviders:eC,onBranch:e=>ew(e,r),disabled:e_},r):(0,z.jsx)("div",{"data-message-idx":r,..."user"===e.type?{"data-user-msg-idx":r}:{},className:"scroll-mt-2",children:(0,z.jsx)(CX,{message:e,messageIndex:r})},r)),er&&(0,z.jsxs)("div",{className:"flex items-center gap-2 py-4 text-muted-foreground",children:[(0,z.jsx)(jQ,{className:"h-4 w-4"}),(0,z.jsx)("span",{className:"text-sm",children:"Connecting to agent..."})]})]})}):(0,z.jsx)("div",{className:"text-center py-16",children:er||e&&!et?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(jQ,{className:"h-6 w-6 mx-auto mb-4"}),(0,z.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"Connecting to agent..."}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Setting up the session for this worktree"})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("div",{className:"mx-auto w-12 h-12 rounded-xl bg-primary/10 flex items-center justify-center mb-4",children:(0,z.jsx)(aE,{className:"h-6 w-6 text-primary/60"})}),(0,z.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"Start a conversation"}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Ask the agent to help you with coding tasks in this worktree"})]})}),es&&(0,z.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-red-500/10 rounded-lg text-red-500 text-sm mt-4",children:[(0,z.jsx)(SX,{className:"h-4 w-4"}),es]})]}),(0,z.jsx)(jl,{})]}),(0,z.jsx)(ks,{messages:Z,contentRef:K}),(0,z.jsx)(kl,{containerRef:K,onQuote:ek})]}),(0,z.jsx)("div",{className:"flex-shrink-0 border-t border-border/60 p-3",children:(0,z.jsxs)(j$,{onSubmit:eD,accept:"image/*",className:"w-full",children:[(0,z.jsx)(ku,{}),(0,z.jsxs)("div",{className:"relative flex w-full flex-col",children:[k&&(0,z.jsx)("div",{className:"flex items-center pl-12 pr-2 pt-1.5 pb-0.5",children:(0,z.jsxs)("button",{type:"button",onClick:()=>N(!1),className:"inline-flex shrink-0 items-center gap-1.5 rounded-full bg-blue-500/10 text-blue-600 dark:text-blue-400 px-2.5 py-0.5 text-xs font-medium hover:bg-blue-500/20 transition-colors",children:[E?(0,z.jsx)(rk,{className:"size-3 animate-spin"}):(0,z.jsx)(j5,{className:"size-3"}),"Translate",(0,z.jsx)(t8,{className:"size-3"})]})}),(0,z.jsxs)("div",{className:"flex w-full items-center",children:[(0,z.jsxs)(jK,{children:[(0,z.jsx)(jq,{className:"ml-1"}),(0,z.jsxs)(jV,{children:[(0,z.jsx)(jz,{label:"Add images"}),(0,z.jsxs)(jY,{onSelect:()=>{N(!k)},children:[(0,z.jsx)(j5,{className:"mr-2 size-4"}),k?"Disable translation":"Translate"]})]})]}),(0,z.jsx)("div",{ref:V,className:"contents",children:(0,z.jsx)(jW,{value:v,onChange:e=>_(e.target.value),onPasteText:eN,onKeyDown:Y.handleKeyDown,placeholder:J?"Ask the agent to help with your code...":"Type your first message to start...",className:"pr-12",style:{fontSize:"var(--conv-font-size, 14px)"}})}),(0,z.jsx)("div",{className:"pointer-events-none absolute bottom-0 right-1 flex items-center text-base md:text-sm",style:{fontSize:"var(--conv-font-size, 14px)",height:"calc(1lh + 1.5rem)"},children:(0,z.jsx)(jG,{className:"pointer-events-auto",disabled:!v.trim()&&!er||E||R,status:R||E?"submitted":er?"streaming":"ready"})})]})]})]})}),(0,z.jsx)(lU,{open:null!==ef,onOpenChange:e=>{e||ef?.resolve(!1)},children:(0,z.jsxs)(lV,{children:[(0,z.jsxs)(lY,{children:[(0,z.jsx)(lX,{children:"Agent process limit reached"}),(0,z.jsxs)(lJ,{children:["All ",ef?.maxResidentAgentProcesses," resident agent processes for this workspace branch are running. Starting a new conversation will stop the least recently active running session in this branch."]})]}),(0,z.jsxs)(lG,{children:[(0,z.jsx)(lQ,{children:"Cancel"}),(0,z.jsx)(lZ,{onClick:()=>ef?.resolve(!0),children:"Stop & start new"})]})]})})]}):(0,z.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,z.jsxs)("div",{className:"text-center",children:[(0,z.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,z.jsx)(aE,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,z.jsx)("p",{className:"text-sm",children:"Select a project to start coding"})]})})});function kx(){return"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}async function kv(e,r){let s=await (0,rv.authFetch)(`${kx()}/api/projects/${e}/chat-sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:r})});if(!s.ok)throw Error("Failed to create chat session");return s.json()}async function k_(e,r){if(!(await (0,rv.authFetch)(`${kx()}/api/chat-sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r})})).ok)throw Error("Failed to send message")}async function ky(e){if(!(await (0,rv.authFetch)(`${kx()}/api/chat-sessions/${e}/stop`,{method:"POST"})).ok)throw Error("Failed to stop generation")}let kb=new Map;function kw(e,r){return`chat:${e}:${r??""}`}function kS({sessionId:e,approvalId:r,tool:s,input:i,resolved:n}){let[a,o]=(0,$.useState)(null),l=function(e){if(null!==e&&"object"==typeof e){if("string"==typeof e.message)return e.message;if("string"==typeof e.prompt)return e.prompt}return JSON.stringify(e)}(i),c=async s=>{if(!a&&!n){o(s?"approve":"deny");try{await rv.api.chatToolApproval(e,r,s)}finally{o(null)}}};return(0,z.jsx)("div",{className:"mx-4 my-1",children:(0,z.jsxs)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 space-y-2",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(aE,{className:"h-3.5 w-3.5 text-amber-500 shrink-0"}),(0,z.jsxs)("span",{className:"text-xs font-medium text-amber-600 dark:text-amber-400",children:["Approval needed · ","spawnAgentSession"===s?"Start a new coding agent":"Send to the coding agent"]})]}),(0,z.jsx)("pre",{className:"bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all text-foreground/80",style:{fontSize:"var(--conv-font-size, 12px)"},children:l}),n?(0,z.jsxs)(sb,{variant:"default",className:"approved"===n?"bg-green-600 hover:bg-green-700 text-white":"bg-red-600 hover:bg-red-700 text-white",children:["approved"===n?(0,z.jsx)(rC,{className:"h-3 w-3 mr-1"}):(0,z.jsx)(rj,{className:"h-3 w-3 mr-1"}),"approved"===n?"Approved — sent.":"Denied — not sent."]}):(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsxs)(W.Button,{onClick:()=>c(!0),disabled:null!==a,className:"bg-green-600 hover:bg-green-700 text-white",size:"sm",children:["approve"===a?(0,z.jsx)(rk,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,z.jsx)(rC,{className:"h-3.5 w-3.5 mr-1"}),"Approve"]}),(0,z.jsxs)(W.Button,{onClick:()=>c(!1),disabled:null!==a,variant:"destructive",size:"sm",children:["deny"===a?(0,z.jsx)(rk,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,z.jsx)(rj,{className:"h-3.5 w-3.5 mr-1"}),"Deny"]})]})]})})}let kC=new Set(["waiting_reviewer","waiting_feedback","sending_feedback"]);function kj({projectId:e,branch:r,runUpdate:s,onRunsChange:i}){let[n,a]=(0,$.useState)([]),[o,l]=(0,$.useState)({}),[c,d]=(0,$.useState)(null),[u,h]=(0,$.useState)(null),f=(0,$.useCallback)(async()=>{if(e)try{let s=await rv.api.getActiveWorkflowRuns(e,r);a(s),i?.(s)}catch{}},[e,r,i]);(0,$.useEffect)(()=>{f()},[f]),(0,$.useEffect)(()=>{s&&f()},[s,f]),(0,$.useEffect)(()=>{if(0===n.length)return;let e=setInterval(()=>void f(),5e3);return()=>clearInterval(e)},[n.length,f]);let p=async(e,r)=>{d(r),h(null);try{await e()}catch(e){h(e instanceof Error?e.message:String(e))}finally{d(null),await f()}},m=n.filter(e=>kC.has(e.status));return 0===m.length?null:(0,z.jsx)("div",{className:"border-b bg-muted/30 px-4 py-2 space-y-2",children:m.map(e=>(0,z.jsxs)("div",{className:"text-sm space-y-2",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("span",{className:"font-medium",children:["Review",e.review_focus?` — ${e.review_focus}`:"",(0,z.jsxs)("span",{className:"ml-2 text-muted-foreground",children:["waiting_reviewer"===e.status&&"reviewer 审查中…","waiting_feedback"===e.status&&"等你确认反馈","sending_feedback"===e.status&&"发送中…"]})]}),(0,z.jsxs)(W.Button,{variant:"ghost",size:"sm",disabled:c===e.id,onClick:()=>p(()=>rv.api.cancelWorkflowRun(e.id),e.id),children:[(0,z.jsx)(t8,{className:"h-3 w-3 mr-1"}),"结束"]})]}),e.error&&(0,z.jsx)("div",{className:"text-xs text-amber-600",children:e.error}),"waiting_reviewer"===e.status&&(0,z.jsxs)("div",{className:"flex items-center text-muted-foreground text-xs",children:[(0,z.jsx)(rk,{className:"h-3 w-3 mr-1 animate-spin"})," reviewer session 正在工作"]}),"waiting_feedback"===e.status&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(rl,{className:"text-xs font-mono min-h-28",value:o[e.id]??e.feedback_snapshot??"",onChange:r=>l(s=>({...s,[e.id]:r.target.value}))}),(0,z.jsx)("div",{className:"flex gap-2",children:(0,z.jsx)(W.Button,{size:"sm",disabled:c===e.id,onClick:()=>p(()=>rv.api.workflowRunGate(e.id,"approve",o[e.id]??void 0),e.id),children:"发送反馈给原 session"})})]}),u&&(0,z.jsx)("div",{className:"text-xs text-destructive",children:u})]},e.id))})}let kk=(0,ew.default)("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);function kN({messages:e}){let{scrollToBottom:r}=jn(),s=(0,$.useRef)(e.length);return(0,$.useEffect)(()=>{let i=s.current;if(s.current=e.length,!(e.length<=i))for(let s=i;s<e.length;s++){let i=e[s];if("user"===i.type&&i.content.startsWith("[Executor Event:"))return void r({animation:"instant"})}},[e,r]),null}let kE=(0,$.forwardRef)(function({projectId:e,branch:r},s){let{session:i,messages:n,status:a,isInitialized:o,isLoading:l,error:c,sendMessage:d,stopGeneration:u,restartSession:h,workflowRunUpdate:f}=function(e,r){let[s,i]=(0,$.useState)(null),[n,a]=(0,$.useState)([]),[o,l]=(0,$.useState)("stopped"),[c,d]=(0,$.useState)(!1),[u,h]=(0,$.useState)(!1),[f,p]=(0,$.useState)(!1),[m,g]=(0,$.useState)(null),[x,v]=(0,$.useState)(null),_=(0,$.useRef)(null),y=(0,$.useRef)(()=>{}),b=(0,$.useRef)(null),w=(0,$.useRef)(0),S=(0,$.useRef)({entries:[],status:"stopped"}),C=(0,$.useRef)(!1),j=(0,$.useRef)(!0),k=(0,$.useRef)(!1),N=(0,$.useRef)(0),E=(0,$.useRef)(null),D=(0,$.useRef)(null),R=(0,$.useRef)(0),A=(0,$.useRef)(!1),M=(0,$.useCallback)((e,r=!1)=>{_.current?.readyState!==WebSocket.OPEN&&_.current?.readyState!==WebSocket.CONNECTING&&(0,rv.getFreshToken)(r?{skipCache:!0}:void 0).then(()=>y.current(e))},[]),F=(0,$.useCallback)(n=>{if(_.current?.readyState===WebSocket.OPEN||_.current?.readyState===WebSocket.CONNECTING)return;S.current={entries:[],status:"stopped"},C.current=!1,k.current=!0;let o=new WebSocket((0,rv.getWebSocketUrl)(`/api/chat-sessions/${n}/stream`));_.current=o;let c=N.current;o.onopen=()=>{d(!0),g(null),E.current=Date.now(),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{w.current=0,R.current=0},5e3)},o.onmessage=s=>{if(c===N.current)try{let c=JSON.parse(s.data);if("JsonPatch"in c){var i,n;let e=S.current.entries.filter(Boolean).length;i=S.current,n=c.JsonPatch,S.current=SS(i,e=>{for(let r of n){let{op:s,path:i,value:n}=r;if("/entries"===i&&"replace"===s&&n?.type==="ENTRY"&&n.content?.type==="system"&&n.content?.content==="__CLEAR_ALL__"){e.entries=[];continue}if(i.startsWith("/entries/")){let r=parseInt(i.replace("/entries/",""),10);if(isNaN(r)||n?.type!=="ENTRY")continue;switch(s){case"add":for(;e.entries.length<=r;)e.entries.push(null);e.entries[r]=n.content;break;case"replace":r<e.entries.length&&(e.entries[r]=n.content);break;case"remove":r<e.entries.length&&e.entries.splice(r,1)}}else"/status"===i&&n?.type==="STATUS"&&(e.status=n.content)}});let r=S.current.entries.filter(Boolean).length;k.current?r!==e&&console.log(`[ChatSession] WS patch added message (${e} → ${r}) but isReplaying=true, state NOT updated`):(r!==e&&console.log(`[ChatSession] New message via WS patch (${e} → ${r}), calling setMessages`),a([...S.current.entries.filter(Boolean)]),l(S.current.status));return}if("Ready"in c){k.current=!1;let e=S.current.entries.filter(Boolean).length;console.log(`[ChatSession] Ready received, isReplaying → false, ${e} messages`),a([...S.current.entries.filter(Boolean)]),l(S.current.status),h(!0);return}if("finished"in c){C.current=!0,o.close(1e3,"finished");return}if("openPreviewFrame"in c)return void(0,_L.openPreviewFrame)(c.openPreviewFrame.projectId,c.openPreviewFrame.url);if("WorkflowRunUpdated"in c)return void v(c.WorkflowRunUpdated);if("browserCommand"in c){let r=c.browserCommand;e&&(0,_L.sendCommandToIframe)(e,{type:"vibedeckx-command",...r}).then(e=>{e&&o.readyState===WebSocket.OPEN&&o.send(JSON.stringify({type:"browser_result",result:{id:r.id,success:e.success??!1,error:e.error,content:e.content,found:e.found,tag:e.tag,text:e.text}}))});return}if("error"in c){g(c.error),"Session not found"===c.error&&(e&&kb.delete(kw(e,r)),C.current=!0);return}}catch(e){console.error("[ChatSession] Failed to parse message:",e)}},o.onclose=n=>{let a,o;if(c!==N.current)return;d(!1),_.current=null,D.current&&(clearTimeout(D.current),D.current=null);let l=4e3===n.code,u=E.current?Date.now()-E.current:0;if(E.current=null,!l&&u>0&&u<5e3){if(R.current++,R.current>=3)return A.current?void g("Unable to connect to remote server. Please check the server configuration."):(e&&kb.delete(kw(e,r)),i(null),g(null),w.current=0,R.current=0,void(j.current=!0))}else u>=5e3&&(R.current=0);if(C.current||1e3===n.code)return;if(w.current>=10)return void g("Unable to connect to server.");let h=(o=(a=Math.min(3e4,1e3*Math.pow(2,w.current)))*Math.random()*.25,a+o);w.current++,b.current=setTimeout(()=>{s?.id&&!C.current&&M(s.id,!0)},h)},o.onerror=()=>{}},[s?.id,M]);(0,$.useEffect)(()=>{y.current=F},[F]);let T=(0,$.useCallback)(async()=>{if(!e)return null;let s=N.current;g(null),h(!1),A.current=!1;let n=kw(e,r),o=kb.get(n);if(o)return i(o),l(o.status),M(o.id),o;p(!0);try{let{session:o,messages:c}=await kv(e,r);if(N.current!==s)return null;return kb.set(n,o),i(o),l(o.status),c&&c.length>0&&a(c),M(o.id),o}catch(e){if(N.current!==s)return null;return g(e instanceof Error?e.message:"Failed to start session"),A.current=!0,null}finally{N.current===s&&p(!1)}},[e,r,M]),P=(0,$.useCallback)(async e=>{let r=s?.id;if(r&&e.trim())try{await k_(r,e.trim())}catch(r){let e=r instanceof Error?r.message:"Failed to send message";g(e),xg.toast.error("Failed to send message",{description:e})}},[s?.id]),B=(0,$.useCallback)(async()=>{if(s?.id)try{await ky(s.id)}catch(e){console.error("[ChatSession] Failed to stop generation:",e)}},[s?.id]),L=(0,$.useCallback)(async()=>{if(s?.id)try{await rv.api.resetChatSession(s.id),a([]),l("stopped"),S.current={entries:[],status:"stopped"}}catch(e){console.error("[ChatSession] Failed to reset session:",e),xg.toast.error("Failed to start new conversation")}},[s?.id]);return(0,$.useEffect)(()=>()=>{_.current&&(C.current=!0,_.current.close()),b.current&&clearTimeout(b.current),D.current&&clearTimeout(D.current)},[]),(0,$.useEffect)(()=>{_.current&&(_.current.close(1e3,"branch-switch"),_.current=null),b.current&&(clearTimeout(b.current),b.current=null),D.current&&(clearTimeout(D.current),D.current=null),N.current+=1,i(null),l("stopped"),d(!1),h(!1),g(null),p(!1),S.current={entries:[],status:"stopped"},C.current=!1,w.current=0,E.current=null,R.current=0,A.current=!1,j.current=!0},[e,r]),(0,$.useEffect)(()=>{!j.current||!e||s||f||A.current||(j.current=!1,T())},[e,s,f,T]),(0,$.useEffect)(()=>{!s?.id||c||C.current||M(s.id)},[s?.id,c,M]),(0,$.useEffect)(()=>{let e=()=>{if("visible"!==document.visibilityState||!s?.id||C.current)return;let e=_.current,r=S.current.entries.filter(Boolean).length;console.log(`[ChatSession] Tab visible: ws.readyState=${e?.readyState??"null"}, isReplaying=${k.current}, messages=${r}`),e&&e.readyState===WebSocket.OPEN&&e.close(4e3,"visibility-recovery")};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[s?.id]),{session:s,messages:n,status:o,isConnected:c,isInitialized:u,isLoading:f,error:m,workflowRunUpdate:x,sendMessage:P,stopGeneration:B,restartSession:L}}(e,r),{settings:p}=(0,dh.useConversationSettings)(),[m,g]=(0,$.useState)([]);(0,$.useImperativeHandle)(s,()=>({sendMessage:async e=>{let r=e.trim();r&&await d(r)}}),[d]);let[x,v]=(0,$.useState)(""),[_,y]=(0,$.useState)(!1);(0,$.useEffect)(()=>{i?.eventListeningEnabled!=null&&y(i.eventListeningEnabled)},[i?.eventListeningEnabled]);let b="running"===a,w=(0,$.useCallback)(async e=>{let r=e.text.trim();r&&(v(""),await d(r))},[d]);return e?(0,z.jsxs)("div",{className:"h-full flex flex-col min-h-0",style:{"--conv-font-size":`${p.chatFontSize}px`},children:[(0,z.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-between px-4 h-10 border-b border-border/60 bg-muted/20",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(x_,{className:"h-3.5 w-3.5 text-primary"}),(0,z.jsx)("span",{className:"text-xs font-medium text-foreground",children:"Main Chat"}),b&&(0,z.jsx)(rk,{className:"h-3 w-3 animate-spin text-primary/60"})]}),i&&(0,z.jsxs)("div",{className:"flex items-center gap-1",children:[(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:async()=>{let e=!_;try{await rv.api.setChatEventListening(i.id,e),y(e)}catch{xg.toast.error("Failed to toggle event listening")}},className:`h-7 w-7 ${_?"text-amber-500":""}`,title:_?"Listening to executor events (click to disable)":"Listen to executor events (click to enable)",children:(0,z.jsx)(kk,{className:"h-3.5 w-3.5"})}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>h(),disabled:b,className:"h-7 w-7",title:"New Conversation",children:(0,z.jsx)(j2,{className:"h-3.5 w-3.5"})})]})]}),(0,z.jsx)(kj,{projectId:e,branch:r,runUpdate:f,onRunsChange:g}),(0,z.jsxs)(ja,{className:"flex-1 min-h-0",initial:"instant",children:[(0,z.jsx)(kN,{messages:n}),(0,z.jsxs)(jo,{className:"gap-4 p-4",children:[l&&0===n.length&&(0,z.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,z.jsx)(rk,{className:"h-6 w-6 animate-spin text-muted-foreground"})}),!l&&o&&0===n.length&&(0,z.jsxs)("div",{className:"text-center py-16",children:[(0,z.jsx)("div",{className:"mx-auto w-12 h-12 rounded-xl bg-primary/10 flex items-center justify-center mb-4",children:(0,z.jsx)(x_,{className:"h-6 w-6 text-primary/60"})}),(0,z.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"Start a conversation"}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Chat with the AI assistant about your project"})]}),n.map((s,n)=>{if("turn_end"===s.type)return(0,z.jsxs)("div",{className:"mx-4 my-3 flex items-center gap-2","aria-hidden":!0,children:[(0,z.jsx)("div",{className:"h-px flex-1 bg-border"}),(0,z.jsx)("div",{className:"h-1 w-1 shrink-0 rounded-full bg-border"}),(0,z.jsx)("div",{className:"h-px flex-1 bg-border"})]},n);if("user"===s.type&&s.content.startsWith("[System Invariant Violation]")){let e=s.content.replace(/^\[System Invariant Violation\]\n?/,"");return(0,z.jsxs)("div",{className:"mx-4 my-2 flex gap-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2",children:[(0,z.jsx)(ll,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-500"}),(0,z.jsxs)("div",{className:"min-w-0",children:[(0,z.jsx)("div",{className:"text-xs font-medium text-amber-600 dark:text-amber-400",children:"System invariant correction"}),(0,z.jsx)("div",{className:"mt-0.5 whitespace-pre-wrap text-muted-foreground",style:{fontSize:"var(--conv-font-size, 12px)"},children:e})]})]},n)}if("user"===s.type){let i=s.event,a=i?.kind==="agent_task_completed"&&m.some(e=>e.source_session_id===i.sessionId||e.reviewer_session_id===i.sessionId);return(0,z.jsxs)("div",{children:[(0,z.jsx)(wo,{from:"user",children:(0,z.jsx)(wl,{style:{fontSize:"var(--conv-font-size, 14px)"},children:s.content})}),i?.kind==="agent_task_completed"&&(0,z.jsx)("div",{className:"mt-1 flex justify-end",children:(0,z.jsx)(W.Button,{variant:"outline",size:"sm",disabled:a,title:a?"该 session 已在一个进行中的 review 里":void 0,onClick:async()=>{if(e)try{await rv.api.createWorkflowRun({projectId:e,branch:r,sourceSessionId:i.sessionId,sourceTurnEndIndex:i.turnEndEntryIndex})}catch(e){alert(e instanceof Error?e.message:String(e))}},children:"Review"})})]},n)}return"assistant"===s.type?(0,z.jsx)(wo,{from:"assistant",children:(0,z.jsx)(wl,{style:{fontSize:"var(--conv-font-size, 14px)"},children:(0,z.jsx)(wc,{children:s.content})})},n):"tool_use"===s.type?(0,z.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 text-xs text-muted-foreground",children:[(0,z.jsx)(dt,{className:"w-3.5 h-3.5 animate-pulse"}),(0,z.jsx)("span",{children:function(e){switch(e){case"getExecutorStatus":return"Checking executor status...";case"getAgentConversation":return"Checking agent conversation...";case"listTerminals":return"Listing terminals...";case"runInTerminal":return"Sending command to terminal...";case"spawnAgentSession":return"Starting a coding agent...";case"sendToAgentSession":return"Sending a message to the agent...";default:return`Running ${e}...`}}(s.tool)})]},n):"tool_result"===s.type?(0,z.jsx)("div",{className:"px-4 py-2",children:(0,z.jsxs)("details",{className:"text-xs text-muted-foreground",children:[(0,z.jsx)("summary",{className:"cursor-pointer hover:text-foreground",children:"Tool result"}),(0,z.jsx)("pre",{className:"mt-1 p-2 bg-muted/50 rounded overflow-x-auto whitespace-pre-wrap",style:{fontSize:"var(--conv-font-size, 12px)"},children:s.output})]})},n):"tool_approval_request"===s.type?i?(0,z.jsx)(kS,{sessionId:i.id,approvalId:s.approvalId,tool:s.tool,input:s.input,resolved:s.resolved},n):null:"error"===s.type?(0,z.jsx)("div",{className:"mx-auto max-w-[90%] rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-destructive",style:{fontSize:"var(--conv-font-size, 14px)"},children:s.message},n):null}),c&&(0,z.jsx)("div",{className:"mx-auto max-w-[90%] rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:c})]}),(0,z.jsx)(jl,{})]}),(0,z.jsxs)("div",{className:"flex-shrink-0 border-t border-border/60 p-3",children:[b&&(0,z.jsx)("div",{className:"flex justify-center mb-2",children:(0,z.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:u,className:"gap-1.5",children:[(0,z.jsx)(uA,{className:"h-3 w-3"}),"Stop generating"]})}),(0,z.jsxs)(j$,{onSubmit:w,className:"w-full",children:[(0,z.jsx)(jW,{disabled:!o||b,placeholder:o?b?"Waiting for response...":"Type a message...":"Connecting...",className:"pr-12",style:{fontSize:"var(--conv-font-size, 14px)"},value:x,onChange:e=>v(e.currentTarget.value)}),(0,z.jsx)("div",{className:"pointer-events-none absolute bottom-0 right-1 flex items-center text-base md:text-sm",style:{fontSize:"var(--conv-font-size, 14px)",height:"calc(1lh + 1.5rem)"},children:(0,z.jsx)(jG,{className:"pointer-events-auto",disabled:!o||b||!x.trim()})})]})]})]}):(0,z.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,z.jsxs)("div",{className:"text-center",children:[(0,z.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,z.jsx)(x_,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,z.jsx)("p",{className:"text-sm",children:"Select a project to start chatting"})]})})}),kD=(0,ew.default)("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),kR=(0,ew.default)("archive-restore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);function kA({task:e,onUpdate:r,onDelete:s,onArchive:i,onUnarchive:n,archivedView:a,onClick:o,worktrees:l,assignedBranches:c,onAssign:d}){let[u,h]=(0,$.useState)(!1),[f,p]=(0,$.useState)(e.title),m=(0,$.useRef)(null);(0,$.useEffect)(()=>{u&&(m.current?.focus(),m.current?.select())},[u]),(0,$.useEffect)(()=>{p(e.title)},[e.title]);let g=()=>{h(!1);let s=f.trim();s&&s!==e.title?r(e.id,{title:s}):p(e.title)},x="done"===e.status||"cancelled"===e.status;return(0,z.jsxs)(l5,{className:"group cursor-pointer",onClick:()=>o?.(e),children:[(0,z.jsx)(l4,{className:"w-10",onClick:e=>e.stopPropagation(),children:(0,z.jsx)(eb,{checked:"done"===e.status,onCheckedChange:s=>{r(e.id,{status:s?"done":"todo"})}})}),(0,z.jsx)(l4,{className:"font-medium",children:u?(0,z.jsx)("input",{ref:m,className:"w-full bg-transparent border-b border-primary outline-none text-sm py-0.5",value:f,onChange:e=>p(e.target.value),onBlur:g,onClick:e=>e.stopPropagation(),onKeyDown:r=>{"Enter"===r.key&&g(),"Escape"===r.key&&(p(e.title),h(!1))}}):(0,z.jsxs)("div",{children:[(0,z.jsx)("span",{className:`cursor-pointer hover:underline text-sm ${x?"line-through text-muted-foreground":""}`,onClick:e=>{e.stopPropagation(),h(!0)},children:e.title}),e.description&&(0,z.jsx)("p",{className:"text-xs text-muted-foreground truncate max-w-[400px] mt-0.5",children:e.description.length>80?e.description.slice(0,80)+"...":e.description})]})}),(0,z.jsx)(l4,{onClick:e=>e.stopPropagation(),children:(0,z.jsxs)(ap,{children:[(0,z.jsx)(am,{asChild:!0,children:(0,z.jsx)("button",{className:"focus:outline-none",children:(0,z.jsx)(sb,{variant:"outline",className:`cursor-pointer text-xs ${op[e.status].color}`,children:op[e.status].label})})}),(0,z.jsx)(ag,{align:"start",children:og.map(s=>(0,z.jsxs)(ax,{onClick:()=>r(e.id,{status:s}),children:[(0,z.jsx)("span",{className:`inline-block w-2 h-2 rounded-full mr-2 ${op[s].color}`}),op[s].label]},s))})]})}),(0,z.jsx)(l4,{onClick:e=>e.stopPropagation(),children:(0,z.jsxs)(ap,{children:[(0,z.jsx)(am,{asChild:!0,children:(0,z.jsx)("button",{className:"focus:outline-none",children:(0,z.jsx)(sb,{variant:"outline",className:`cursor-pointer text-xs ${om[e.priority].color}`,children:om[e.priority].label})})}),(0,z.jsx)(ag,{align:"start",children:ox.map(s=>(0,z.jsxs)(ax,{onClick:()=>r(e.id,{priority:s}),children:[(0,z.jsx)("span",{className:`inline-block w-2 h-2 rounded-full mr-2 ${om[s].color}`}),om[s].label]},s))})]})}),(0,z.jsx)(l4,{onClick:e=>e.stopPropagation(),children:(0,z.jsxs)(ap,{children:[(0,z.jsx)(am,{asChild:!0,children:(0,z.jsx)("button",{className:"focus:outline-none",children:(0,z.jsxs)(sb,{variant:"outline",className:`cursor-pointer text-xs font-mono ${null!==e.assigned_branch?"bg-accent text-accent-foreground border-transparent":"text-muted-foreground"}`,children:[(0,z.jsx)(rw,{className:"h-3 w-3 mr-1"}),null!==e.assigned_branch?""===e.assigned_branch?"main":e.assigned_branch:"Unassigned"]})})}),(0,z.jsxs)(ag,{align:"start",children:[null!==e.assigned_branch&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ax,{onClick:()=>d(e.id,null),children:"Unassign"}),(0,z.jsx)(aw,{})]}),l.filter(r=>{let s=null===r.branch?"":r.branch;return!(e.assigned_branch===s||c.has(s))}).map(r=>{let s=null===r.branch?"":r.branch,i=r.branch??"main";return(0,z.jsxs)(ax,{onClick:()=>d(e.id,s),children:[(0,z.jsx)(rw,{className:"h-3 w-3 mr-2"}),i]},s)})]})]})}),(0,z.jsx)(l4,{className:"text-muted-foreground text-[10.5px] font-mono",children:new Date(e.created_at).toLocaleDateString()}),(0,z.jsx)(l4,{className:"w-10",onClick:e=>e.stopPropagation(),children:(0,z.jsxs)("div",{className:"flex items-center gap-0.5",children:[a?(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",title:"Unarchive",onClick:()=>n(e.id),children:(0,z.jsx)(kR,{className:"h-3.5 w-3.5 text-muted-foreground"})}):(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",title:"Archive",onClick:()=>i(e.id),children:(0,z.jsx)(kD,{className:"h-3.5 w-3.5 text-muted-foreground"})}),(0,z.jsx)(W.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",title:"Delete",onClick:()=>s(e.id),children:(0,z.jsx)(rc,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})})]})}let kM={todo:0,in_progress:1,done:2,cancelled:3},kF={urgent:0,high:1,medium:2,low:3};function kT({tasks:e,onUpdate:r,onDelete:s,onArchive:i,onUnarchive:n,archivedView:a,worktrees:o,onAssign:l}){let[c,d]=(0,$.useState)(null),[u,h]=(0,$.useState)("asc"),[f,p]=(0,$.useState)(null),[m,g]=(0,$.useState)(!1),x=e=>{c===e?h(e=>"asc"===e?"desc":"asc"):(d(e),h("asc"))},v=(0,$.useMemo)(()=>{if(!c)return e;let r="asc"===u?1:-1;return[...e].sort((e,s)=>{switch(c){case"title":return r*e.title.localeCompare(s.title);case"status":return r*(kM[e.status]-kM[s.status]);case"priority":return r*(kF[e.priority]-kF[s.priority]);case"created_at":return r*(new Date(e.created_at).getTime()-new Date(s.created_at).getTime());default:return 0}})},[e,c,u]),_=e=>c!==e?null:"asc"===u?" ↑":" ↓",y=(0,$.useMemo)(()=>new Set(e.filter(e=>null!==e.assigned_branch).map(e=>e.assigned_branch)),[e]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(l0,{children:[(0,z.jsx)(l1,{children:(0,z.jsxs)(l5,{children:[(0,z.jsx)(l3,{className:"w-10"}),(0,z.jsxs)(l3,{className:"cursor-pointer select-none",onClick:()=>x("title"),children:["Title",_("title")]}),(0,z.jsxs)(l3,{className:"cursor-pointer select-none w-32",onClick:()=>x("status"),children:["Status",_("status")]}),(0,z.jsxs)(l3,{className:"cursor-pointer select-none w-28",onClick:()=>x("priority"),children:["Priority",_("priority")]}),(0,z.jsx)(l3,{className:"w-32",children:"Assign"}),(0,z.jsxs)(l3,{className:"cursor-pointer select-none w-28",onClick:()=>x("created_at"),children:["Created",_("created_at")]}),(0,z.jsx)(l3,{className:"w-10"})]})}),(0,z.jsxs)(l2,{children:[v.map(e=>(0,z.jsx)(kA,{task:e,onUpdate:r,onDelete:s,onArchive:i,onUnarchive:n,archivedView:a,onClick:e=>{p(e),g(!0)},worktrees:o,assignedBranches:y,onAssign:l},e.id)),0===e.length&&(0,z.jsx)(l5,{children:(0,z.jsx)("td",{colSpan:7,className:"text-center text-muted-foreground py-12 text-sm",children:(0,z.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,z.jsx)("p",{className:"text-sm font-medium text-foreground/60",children:"No tasks yet"}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:"Create one to get started."})]})})})]})]}),(0,z.jsx)(ov,{task:f,open:m,onOpenChange:g})]})}function kP({open:e,onOpenChange:r,onSubmit:s}){let[i,n]=(0,$.useState)(""),[a,o]=(0,$.useState)("todo"),[l,c]=(0,$.useState)("medium");return(0,z.jsx)(t7,{open:e,onOpenChange:r,children:(0,z.jsxs)(rr,{className:"sm:max-w-md max-h-[85vh] flex flex-col",children:[(0,z.jsx)(rs,{children:(0,z.jsx)(rn,{children:"Create Task"})}),(0,z.jsxs)("form",{onSubmit:e=>{e.preventDefault(),i.trim()&&(s({description:i.trim(),status:a,priority:l}),n(""),o("todo"),c("medium"),r(!1))},className:"space-y-4 overflow-y-auto min-h-0 px-0.5",children:[(0,z.jsx)("div",{className:"space-y-2",children:(0,z.jsx)(rl,{placeholder:"Describe the task...",value:i,onChange:e=>n(e.target.value),className:"max-h-[40vh] focus-visible:border-input focus-visible:ring-0",rows:3,autoFocus:!0})}),(0,z.jsxs)("div",{className:"flex gap-3",children:[(0,z.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,z.jsx)("label",{className:"text-xs text-muted-foreground",children:"Status"}),(0,z.jsxs)(cX,{value:a,onValueChange:e=>o(e),children:[(0,z.jsx)(cZ,{children:(0,z.jsx)(cJ,{})}),(0,z.jsx)(cQ,{children:og.map(e=>(0,z.jsx)(c0,{value:e,children:op[e].label},e))})]})]}),(0,z.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,z.jsx)("label",{className:"text-xs text-muted-foreground",children:"Priority"}),(0,z.jsxs)(cX,{value:l,onValueChange:e=>c(e),children:[(0,z.jsx)(cZ,{children:(0,z.jsx)(cJ,{})}),(0,z.jsx)(cQ,{children:ox.map(e=>(0,z.jsx)(c0,{value:e,children:om[e].label},e))})]})]})]}),(0,z.jsxs)(ri,{children:[(0,z.jsx)(W.Button,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),(0,z.jsx)(W.Button,{type:"submit",disabled:!i.trim(),children:"Create"})]})]})]})})}let kB=[{value:"all",label:"All"},{value:"todo",label:"Todo"},{value:"in_progress",label:"Doing"},{value:"done",label:"Done"},{value:"cancelled",label:"Cancelled"},{value:"archived",label:"Archived"}];function kL({projectId:e,tasks:r,loading:s,worktrees:i,onCreateTask:n,onUpdateTask:a,onDeleteTask:o,onArchiveTask:l,onUnarchiveTask:c}){let[d,u]=(0,$.useState)(!1),[h,f]=(0,$.useState)("all"),p=(0,$.useMemo)(()=>r.filter(e=>null===e.archived_at),[r]),m=(0,$.useMemo)(()=>r.filter(e=>null!==e.archived_at),[r]),g=(0,$.useMemo)(()=>{let e={all:p.length,todo:0,in_progress:0,done:0,cancelled:0,archived:m.length};for(let r of p)e[r.status]++;return e},[p,m]),x=(0,$.useMemo)(()=>"archived"===h?m:"all"===h?p:p.filter(e=>e.status===h),[p,m,h]),v="archived"===h;return e?(0,z.jsxs)("div",{className:"flex flex-col h-full",children:[(0,z.jsx)(lb,{title:"Tasks",count:p.length,actions:(0,z.jsxs)(W.Button,{size:"sm",onClick:()=>u(!0),className:"shadow-sm",children:[(0,z.jsx)(eS,{className:"h-3.5 w-3.5 mr-1.5"}),"New Task"]})}),(0,z.jsx)(lw,{children:kB.map(e=>(0,z.jsx)(lS,{active:h===e.value,count:g[e.value],onClick:()=>f(e.value),children:e.label},e.value))}),(0,z.jsx)("div",{className:"flex-1 overflow-auto px-5 edge-scrollbar",children:s?(0,z.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"Loading tasks..."}):(0,z.jsx)(kT,{tasks:x,onUpdate:a,onDelete:o,onArchive:l,onUnarchive:c,archivedView:v,worktrees:i,onAssign:(e,r)=>{a(e,{assigned_branch:r})}})}),(0,z.jsx)(kP,{open:d,onOpenChange:u,onSubmit:n})]}):(0,z.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:(0,z.jsxs)("div",{className:"text-center",children:[(0,z.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,z.jsx)(eS,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,z.jsx)("p",{className:"text-sm",children:"Select a project to view tasks."})]})})}let kI=(0,ew.default)("folder-git-2",[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]);function kO({open:e,onOpenChange:r,onNavigateProject:s,onNavigateWorkspace:i,onNavigateSession:n}){let[a,o]=(0,$.useState)(""),[l,c]=(0,$.useState)(null),[d,u]=(0,$.useState)(!1),h=(0,$.useRef)(null),f=(0,$.useRef)(null),p=(0,$.useRef)("");(0,$.useLayoutEffect)(()=>{p.current=a},[a]);let[m,g]=(0,$.useState)(e);e!==m&&(g(e),e&&(o(""),c(null),u(!1)));let x=(0,$.useCallback)(async e=>{h.current?.abort();let r=new AbortController;h.current=r;try{let s=await (0,rv.searchAll)(e,{signal:r.signal});r.signal.aborted||(c(s),u(!1))}catch{r.signal.aborted||u(!0)}},[]),v=(0,$.useRef)(!1);(0,$.useEffect)(()=>{let r=e&&!v.current;if(v.current=e,e)return f.current&&clearTimeout(f.current),f.current=setTimeout(()=>void x(a),150*!r),()=>{f.current&&clearTimeout(f.current)}},[a,e,x]),(0,$.useEffect)(()=>{if(!e)return;let r=!1;return(0,rv.refreshSearchCache)().then(()=>{r||x(p.current)}).catch(()=>{}),()=>{r=!0,h.current?.abort()}},[e,x]);let _=null===l,y=!!l&&0===l.projects.length&&0===l.workspaces.length&&0===l.sessions.length,b=l?.cacheState==="cold";return(0,z.jsxs)(bA,{open:e,onOpenChange:r,title:"Quick Switcher",description:"Search projects, workspaces, and sessions",shouldFilter:!1,children:[(0,z.jsx)(bM,{placeholder:"Search projects, workspaces, sessions…",value:a,onValueChange:o}),(0,z.jsxs)(bF,{children:[d&&(0,z.jsxs)("div",{className:"flex items-center justify-between gap-2 px-4 py-3 text-sm text-destructive",children:[(0,z.jsx)("span",{children:"Search failed."}),(0,z.jsx)(W.Button,{variant:"link",size:"sm",className:"h-auto p-0 text-destructive",onClick:()=>void x(p.current),children:"Retry"})]}),!d&&_&&(0,z.jsxs)("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin"}),"Searching…"]}),!d&&!_&&y&&b&&(0,z.jsxs)("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[(0,z.jsx)(rk,{className:"h-4 w-4 animate-spin"}),"Syncing history…"]}),!d&&!_&&y&&!b&&(0,z.jsx)(bT,{children:"No results found."}),l&&l.projects.length>0&&(0,z.jsx)(bP,{heading:"Projects",children:l.projects.map(e=>(0,z.jsxs)(bB,{value:`project-${e.id}`,onSelect:()=>s(e.id),children:[(0,z.jsx)(kI,{}),(0,z.jsx)("span",{children:e.name}),e.path&&(0,z.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:e.path})]},e.id))}),l&&l.workspaces.length>0&&(0,z.jsx)(bP,{heading:"Workspaces",children:l.workspaces.map(e=>(0,z.jsxs)(bB,{value:`ws-${e.projectId}-${e.targetId}-${e.branch??""}`,onSelect:()=>i(e),children:[(0,z.jsx)(rw,{}),(0,z.jsx)("span",{children:e.branch??"main"}),(0,z.jsx)("span",{className:"text-xs text-muted-foreground",children:e.projectName})]},`${e.projectId}-${e.targetId}-${e.branch??""}`))}),l&&l.sessions.length>0&&(0,z.jsx)(bP,{heading:"Sessions",children:l.sessions.map(e=>(0,z.jsxs)(bB,{value:`session-${e.sessionId}`,onSelect:()=>n(e),children:[(0,z.jsx)(x_,{}),(0,z.jsx)("span",{className:"truncate",children:e.title??"Untitled session"}),e.favoritedAt&&(0,z.jsx)(ki,{className:"h-3.5 w-3.5 shrink-0 fill-current text-amber-500"}),(0,z.jsxs)("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:[e.projectName," · ",e.branch??"main"," · ",function(e){if(!e)return"";let r=Date.now()-e;return r<6e4?"just now":r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:`${Math.floor(r/864e5)}d ago`}(e.lastActiveAt)]})]},e.sessionId))})]})]})}let kz={completed:"/sounds/sound1.mp3","main-completed":"/sounds/sound2.mp3"};function k$(e,r){return`${e}:${r??""}`}let kW="vibedeckx:completion-notifications";function kH(e){return"object"==typeof e&&null!==e&&"string"==typeof e.id&&"string"==typeof e.projectId&&("string"==typeof e.branch||null===e.branch)&&("string"==typeof e.sessionId||null===e.sessionId||void 0===e.sessionId)&&("completed"===e.type||"main-completed"===e.type)&&"number"==typeof e.at&&"boolean"==typeof e.read}let kU=new Map,kK=new Set,kq=(0,ew.default)("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]),kV={completed:{label:"Agent finished",dot:"bg-lime-400"},"main-completed":{label:"Chat finished",dot:"bg-emerald-500"}};function kY({notifications:e,unreadCount:r,projects:s,onNavigate:i,markRead:n,markAllRead:a,remove:o,clear:l}){return(0,z.jsxs)(ap,{children:[(0,z.jsx)(am,{asChild:!0,children:(0,z.jsxs)(W.Button,{variant:"ghost",size:"icon-sm",className:"relative","aria-label":r>0?`${r} unread completion notifications`:"Completion notifications",children:[(0,z.jsx)(kq,{className:"h-4 w-4"}),r>0&&(0,z.jsx)("span",{className:"absolute -top-0.5 -right-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[9px] font-semibold leading-none text-primary-foreground",children:r>9?"9+":r})]})}),(0,z.jsxs)(ag,{align:"end",className:"w-80 p-0",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,z.jsx)("span",{className:"text-[12.5px] font-semibold text-foreground",children:"Notifications"}),e.length>0&&(0,z.jsxs)("div",{className:"flex items-center gap-1",children:[(0,z.jsxs)("button",{onClick:a,disabled:0===r,className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-40",title:"Mark all read",children:[(0,z.jsx)(lo,{className:"h-3 w-3"}),"Mark all read"]}),(0,z.jsx)("button",{onClick:l,className:"rounded px-1.5 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:"Clear all",children:"Clear"})]})]}),(0,z.jsx)("div",{className:"max-h-[60vh] overflow-y-auto border-t border-border",children:0===e.length?(0,z.jsx)("div",{className:"px-3 py-8 text-center text-[12px] text-muted-foreground/70",children:"No completions yet."}):e.map(e=>{let r,a=kV[e.type];return(0,z.jsxs)(ax,{onSelect:()=>{n(e.id),i(e.projectId,e.branch,e.sessionId)},className:(0,ey.cn)("group flex flex-col items-start gap-0.5 rounded-none px-3 py-2",!e.read&&"bg-primary/[0.08]"),children:[(0,z.jsxs)("div",{className:"flex w-full items-center gap-2",children:[(0,z.jsx)("span",{className:(0,ey.cn)("h-[7px] w-[7px] shrink-0 rounded-full",a.dot)}),(0,z.jsx)("span",{className:(0,ey.cn)("min-w-0 flex-1 truncate text-[12.5px]",e.read?"text-foreground/70":"font-medium text-foreground"),children:(r=e.projectId,s.find(e=>e.id===r)?.name??"Unknown project")}),(0,z.jsx)("span",{className:"shrink-0 text-[10.5px] text-muted-foreground/70",children:function(e){let r=Math.max(0,Math.round((Date.now()-e)/1e3));if(r<60)return"just now";let s=Math.round(r/60);if(s<60)return`${s}m ago`;let i=Math.round(s/60);if(i<24)return`${i}h ago`;let n=Math.round(i/24);return`${n}d ago`}(e.at)}),(0,z.jsx)("button",{onClick:r=>{r.stopPropagation(),o(e.id)},className:"shrink-0 rounded p-0.5 text-muted-foreground/60 opacity-0 transition-all hover:bg-muted hover:text-foreground group-hover:opacity-100",title:"Dismiss",children:(0,z.jsx)(t8,{className:"h-3 w-3"})})]}),(0,z.jsxs)("div",{className:"flex w-full items-center gap-1.5 pl-[15px] text-[11px] text-muted-foreground",children:[(0,z.jsx)("span",{className:"font-mono truncate",children:e.branch??"main"}),(0,z.jsx)("span",{className:"text-muted-foreground/50",children:"·"}),(0,z.jsx)("span",{className:"shrink-0",children:a.label})]})]},e.id)})})]})]})}function kG(e){if(null===e)return"尚未连接";let r=Math.max(0,Math.round((Date.now()-e)/1e3));if(r<60)return`${r} 秒前`;let s=Math.floor(r/60);return s<60?`${s} 分钟前`:`${Math.floor(s/60)} 小时前`}function kX(){let{state:e,lastEventAt:r,reconnect:s}=(0,ok.useConnectionStatus)(),[,i]=(0,$.useState)(0);if((0,$.useEffect)(()=>{let e=setInterval(()=>i(e=>e+1),5e3);return()=>clearInterval(e)},[]),"stale"===e)return(0,z.jsxs)("button",{type:"button",onClick:s,title:`实时更新已断开 \xb7 上次更新 ${kG(r)} \xb7 点击重新连接`,className:"flex items-center gap-1.5 rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-600 transition-colors hover:bg-amber-500/20",children:[(0,z.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500"}),"实时更新已断开"]});let n="live"===e;return(0,z.jsx)("span",{title:n?`实时更新正常 \xb7 上次更新 ${kG(r)}`:"正在连接实时更新…",className:"flex items-center px-1","aria-label":n?"实时更新正常":"正在连接实时更新",children:(0,z.jsx)("span",{className:n?"h-1.5 w-1.5 rounded-full bg-emerald-500":"h-1.5 w-1.5 animate-pulse rounded-full bg-muted-foreground/40"})})}let kJ=new Set(["workspace","tasks","schedules","remote-servers","settings","project-info"]),kZ="tasks";function kQ(){let e=window.location.pathname,r=new URLSearchParams(window.location.search),s=r.get("project");if(s){let e=r.get("tab");return{projectId:s,tab:e&&kJ.has(e)?e:kZ,branch:r.get("branch")}}let i=e.split("/").filter(Boolean);if(1===i.length&&kJ.has(i[0])){let e=i[0];if("remote-servers"===e||"settings"===e)return{projectId:null,tab:e,branch:null}}let n=null,a=kZ;if("p"===i[0]&&i[1]){n=i[1];let e=i[2];e&&kJ.has(e)&&(a=e)}return{projectId:n,tab:a,branch:r.get("branch")}}function k0(e){let{projectId:r,tab:s,branch:i}=e;if("remote-servers"===s||"settings"===s)return`/${s}`;if(!r)return"/";let n=`/p/${r}/${s??kZ}`;return i&&(n+=`?branch=${encodeURIComponent(i)}`),n}function k1(e,r,s,i){return!!e&&e.projectId===r&&e.branch===s&&e.sessionId===i}function k2(){var e,r,s,i,n;let a,o,l,c,d,{projectId:u,tab:h,branch:f}=function(){let[e,r]=(0,$.useState)(kQ);return(0,$.useEffect)(()=>{let e=()=>r(kQ());return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]),e}(),[p,m]=(0,$.useState)(()=>new URLSearchParams(window.location.search).get("session")),[g,x]=(0,$.useState)(null),v=(0,$.useCallback)(e=>{m(e);let r=new URL(window.location.href);e?r.searchParams.set("session",e):r.searchParams.delete("session"),window.history.replaceState(null,"",r.toString())},[]);(0,$.useEffect)(()=>{let e=()=>{m(new URLSearchParams(window.location.search).get("session"))};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]),(0,$.useEffect)(()=>{if(new URLSearchParams(window.location.search).has("project")){let e=k0({projectId:u,tab:h,branch:f});window.history.replaceState(null,"",e)}},[]);let[_,y]=(0,$.useState)(!1),[b,w]=(0,$.useState)(!1),[S,C]=(0,$.useState)(!1),[j,k]=(0,$.useState)(null),[N,E]=(0,$.useState)(f),[D,R]=(0,$.useState)(h),[A,M]=(0,$.useState)(0),[F,T]=(0,$.useState)(0),P=(0,$.useRef)(null),[B,L]=(0,$.useState)(void 0),[I,O]=(0,$.useTransition)(),{projects:H,currentProject:U,loading:K,addProject:q,createProject:V,updateProject:Y,deleteProject:G,selectProject:X}=function(e){let[r,s]=(0,$.useState)([]),[i,n]=(0,$.useState)(null),[a,o]=(0,$.useState)(!0),l=(0,$.useCallback)(async()=>{o(!0);try{let r=await rv.api.getProjects();if(s(r),r.length>0&&!i){let s=e?r.find(r=>r.id===e):null;n(s??r[0])}}finally{o(!1)}},[i,e]);(0,$.useEffect)(()=>{l()},[]);let c=async(e,r)=>{let a=await rv.api.updateProject(e,r);return s(r=>r.map(r=>r.id===e?a:r)),i?.id===e&&n(a),a},d=async e=>{await rv.api.deleteProject(e),s(r=>r.filter(r=>r.id!==e)),i?.id===e&&n(r.find(r=>r.id!==e)??null)};return{projects:r,currentProject:i,loading:a,addProject:e=>{s(r=>[e,...r]),n(e)},createProject:async e=>{let r=await rv.api.createProject(e);return s(e=>[r,...e]),n(r),r},updateProject:c,deleteProject:d,selectProject:e=>{n(e)},refresh:l}}(u);U?.id!==B&&(void 0!==B&&E(null),L(U?.id));let{worktrees:J,loading:Z,refetch:Q}=function(e){let[r,s]=(0,$.useState)([]),[i,n]=(0,$.useState)(!0),[a,o]=(0,$.useState)(null),l=(0,$.useCallback)(async()=>{if(!e){s([]),o(null),n(!1);return}n(!0);try{let r=await rv.api.getProjectWorktrees(e);s(r)}catch(e){console.error("Failed to fetch worktrees:",e),s([{branch:null}])}finally{o(e),n(!1)}},[e]);return(0,$.useEffect)(()=>{l()},[l]),{worktrees:r,loading:i||a!==e,refetch:l}}(U?.id??null),{statuses:ee,defaultTarget:et,repositoryLabel:er,setTarget:es,refetch:ei}=function(e,r){let[s,i]=(0,$.useState)(new Map),[n,a]=(0,$.useState)(null),[o,l]=(0,$.useState)(null),[c,d]=(0,$.useState)(0),[u,h]=(0,$.useState)(e);e!==u&&(h(e),i(new Map),a(null),l(null));let f=(0,$.useCallback)(()=>d(e=>e+1),[]);return(0,$.useEffect)(()=>{let s=r.map(e=>e.branch).filter(e=>null!==e),n=!1;return(async()=>{if(!e||0===s.length){n||(i(new Map),a(null),l(null));return}if(oE(e).length>0&&(await function(e){let r=oD.get(e);if(r)return r;let s=(async()=>{let r=new Map;for(;;){let s=oE(e).filter(({key:e,target:s})=>r.get(e)!==s);if(0===s.length)break;for(let{key:i,branch:n,target:a}of s){r.set(i,a);let s=!1;try{s=await rv.api.setMergeTarget(e,n,a,{ifAbsent:!0})}catch{}if(s)try{localStorage.getItem(i)===a&&localStorage.removeItem(i)}catch{}}}})();return oD.set(e,s),s.finally(()=>{oD.get(e)===s&&oD.delete(e)}),s}(e),n))return;let r=s.map(e=>({branch:e})),o=await rv.api.getMergeStatus(e,r);n||o.ok&&(i(function(e){let r=new Map;for(let s of e){if("target-not-found"===s.error&&s.requestedTarget){r.set(s.branch,{branch:s.branch,error:s.error,requestedTarget:s.requestedTarget,targetSource:s.targetSource});continue}!s.error&&s.target&&s.status&&r.set(s.branch,{branch:s.branch,status:s.status,unmergedCount:s.unmergedCount??0,dirty:s.dirty??!1,target:s.target})}return r}(o.entries)),a(function(e){for(let r of e)if("default"===r.targetSource&&r.target)return r.target;return null}(o.entries)),l(o.repository.label))})(),()=>{n=!0}},[e,r,c,f]),{statuses:s,defaultTarget:n,repositoryLabel:o,setTarget:(0,$.useCallback)((r,s)=>{e&&rv.api.setMergeTarget(e,r,s).then(e=>{e&&f()})},[e,f]),refetch:f}}(U?.id??null,J),en=function(e,r,s){let i=(0,$.useMemo)(()=>r?.map(e=>e.branch)??[],[r]),[n,a]=(0,$.useState)([]),o=(0,$.useCallback)(async()=>{if(!e||0===i.length)return void a([]);let r=await Promise.all(i.map(async r=>(await (0,rv.listBranchSessions)(e,r)).sessions.filter(e=>e.processAlive).map(s=>({id:s.id,projectId:e,branch:r,title:s.title?.trim()||"New Session",status:s.status,processAlive:!0,updated_at:s.updated_at}))));a(e=>{var s;let i;return s=r.flat(),i=new Map(e.map(e=>[e.id,e])),s.map(e=>{let r=i.get(e.id);return r&&"New Session"===e.title&&"New Session"!==r.title?{...e,title:r.title}:e})})},[i,e]);(0,$.useEffect)(()=>{let e=!1;return o().catch(r=>{e||console.warn("[ResidentSessions] refresh failed:",r)}),()=>{e=!0}},[o]);let{state:l}=(0,ok.useConnectionStatus)(),c=(0,$.useRef)(null),d=(0,$.useRef)(!1);return(0,$.useEffect)(()=>{var e;let r=c.current;c.current=l;let s=(e=d.current,"live"===l&&e&&"live"!==r);"live"===l&&(d.current=!0),s&&o().catch(e=>console.warn("[ResidentSessions] reconnect refresh failed:",e))},[l,o]),(0,$.useEffect)(()=>{s&&s.processAlive&&e&&s.projectId===e&&a(e=>(function(e,r){let s=e.findIndex(e=>e.id===r.id);if(-1===s)return[r,...e];let i=e[s],n="New Session"===r.title&&"New Session"!==i.title?i.title:r.title,a=[...e];return a[s]={...r,title:n},a})(e,s))},[e,s]),(0,ok.useGlobalEventStream)(r=>{if(e&&r.projectId===e){if("session:process"===r.type){let e="string"==typeof r.sessionId?r.sessionId:null,s="boolean"==typeof r.alive?r.alive:null,i="string"==typeof r.branch?r.branch:null;if(!e||null===s)return;if(!s)return void a(r=>r.filter(r=>r.id!==e));o().catch(e=>console.warn("[ResidentSessions] process refresh failed:",e)),null!==i&&a(r=>r.map(r=>r.id===e?{...r,branch:i}:r))}if("session:status"===r.type){let e="string"==typeof r.sessionId?r.sessionId:null,s="string"==typeof r.status?r.status:null;if(!e||!s)return;a(r=>r.map(r=>r.id===e?{...r,status:s}:r))}if("session:title"===r.type){let e="string"==typeof r.sessionId?r.sessionId:null;if(!e)return;a(s=>{var i,n;return n=("string"==typeof(i=r.title)?i.trim():"")||"New Session",s.map(r=>r.id===e?{...r,title:n}:r)})}}}),(0,$.useMemo)(()=>{let e=new Map;for(let r of n){let s=r.branch??"",i=e.get(s)??[];i.push(r),e.set(s,i)}for(let r of e.values())r.sort((e,r)=>(r.updated_at??"").localeCompare(e.updated_at??""));return e},[n])}(U?.id??null,J,g),{tasks:ea,loading:eo,createTask:el,updateTask:ec,deleteTask:ed,archive:eu,unarchive:eh,refetch:ef}=function(e){let[r,s]=(0,$.useState)([]),[i,n]=(0,$.useState)(!0),a=(0,$.useCallback)(async()=>{if(!e){s([]),n(!1);return}try{let r=await rv.api.getTasks(e,{includeArchived:!0});s(r)}catch(e){console.error("Failed to fetch tasks:",e)}finally{n(!1)}},[e]);(0,$.useEffect)(()=>{a()},[a]);let o=(0,$.useCallback)(async r=>{if(!e)return null;try{let i=await rv.api.createTask(e,r);return s(e=>[...e,i]),i}catch(e){return console.error("Failed to create task:",e),null}},[e]),l=(0,$.useCallback)(async(e,i)=>{s(r=>r.map(r=>r.id===e?{...r,...i,updated_at:new Date().toISOString()}:r));try{let r=await rv.api.updateTask(e,i);return s(s=>s.map(s=>s.id===e?r:s)),r}catch(e){return console.error("Failed to update task:",e),s(r),null}},[r]),c=(0,$.useCallback)(async e=>{s(r=>r.filter(r=>r.id!==e));try{await rv.api.deleteTask(e)}catch(e){console.error("Failed to delete task:",e),s(r)}},[r]),d=(0,$.useCallback)(async e=>{s(r=>r.map(r=>r.id===e?{...r,archived_at:Date.now()}:r));try{let r=await rv.api.archiveTask(e);s(s=>s.map(s=>s.id===e?r:s))}catch(e){console.error("Failed to archive task:",e),s(r)}},[r]),u=(0,$.useCallback)(async e=>{s(r=>r.map(r=>r.id===e?{...r,archived_at:null}:r));try{let r=await rv.api.unarchiveTask(e);s(s=>s.map(s=>s.id===e?r:s))}catch(e){console.error("Failed to unarchive task:",e),s(r)}},[r]),h=(0,$.useCallback)(async i=>{if(e){s(i.map(e=>r.find(r=>r.id===e)).filter(e=>void 0!==e));try{await rv.api.reorderTasks(e,i)}catch(e){console.error("Failed to reorder tasks:",e),s(r)}}},[e,r]);return{tasks:r,loading:i,createTask:o,updateTask:l,deleteTask:c,archive:d,unarchive:u,reorderTasks:h,refetch:a}}(U?.id??null),{schedules:ep,loading:em,createSchedule:eg,updateSchedule:ex,deleteSchedule:ev,runNow:e_}=function(e){let[r,s]=(0,$.useState)([]),[i,n]=(0,$.useState)(!1),a=(0,$.useRef)(e),o=(0,$.useRef)(0),l=(0,$.useCallback)(async(e,r,i)=>{if(!e){o.current===r&&(s([]),n(!1));return}i&&n(!0);try{let i=await rv.api.getSchedules(e);o.current===r&&s(i)}catch(e){console.error("Failed to fetch schedules:",e)}finally{i&&o.current===r&&n(!1)}},[]);(0,$.useEffect)(()=>{a.current=e,o.current+=1,l(e,o.current,!0)},[e,l]);let c=(0,$.useCallback)(async()=>{let e=a.current;e&&await l(e,o.current,!1)},[l]),d=(0,$.useRef)(c);(0,$.useEffect)(()=>{d.current=c},[c]),(0,ok.useGlobalEventStream)(e=>{!e.type?.startsWith("schedule:")||a.current&&e.projectId===a.current&&d.current()});let u=(0,$.useCallback)(async r=>{if(!e)throw Error("No project selected");let s=await rv.api.createSchedule(e,r);return await c(),s},[e,c]),h=(0,$.useCallback)(async(e,r)=>{let s=await rv.api.updateSchedule(e,r);return await c(),s},[c]),f=(0,$.useCallback)(async e=>{await rv.api.deleteSchedule(e),await c()},[c]),p=(0,$.useCallback)(async e=>{let r=await rv.api.runScheduleNow(e);return await c(),r},[c]);return{schedules:r,loading:i,refetch:c,createSchedule:u,updateSchedule:h,deleteSchedule:f,runNow:p}}(U?.id??null),[ey,eb]=(0,$.useState)(null),[ew,eC]=(0,$.useState)(!1),{activity:ej,since:ek,refetch:eN,setOptimisticActivity:eE}=function(e){let[r,s]=(0,$.useState)(new Map),[i,n]=(0,$.useState)(new Map),a=(0,$.useRef)(new Map),o=(0,$.useRef)(new Map),l=(0,$.useRef)(null),c=(0,$.useCallback)(async()=>{if(!e){s(new Map),n(new Map),o.current=new Map,l.current=null,a.current=new Map;return}try{let r=await (0,rv.authFetch)(`${"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}/api/projects/${e}/branches/activity`);if(!r.ok)return;let i=await r.json(),c=l.current!==e,{nextActivity:d,nextSince:u}=function(e,r,s,i){let n=new Map,a=new Map,o=[];for(let l of e){let e=l.branch??"",c=s.get(e)??0;if(!i&&l.since<c){let s=r.get(e);if(void 0!==s){n.set(e,s),a.set(e,c);continue}}n.set(e,l.activity),a.set(e,l.since),i||r.get(e)===l.activity||o.push(l.branch)}return{nextActivity:n,nextSince:a,transitions:o}}(i.branches,o.current,a.current,c);s(d),n(u),o.current=d,l.current=e,a.current=u}catch{}},[e]);return(0,$.useEffect)(()=>{c()},[c]),(0,ok.useGlobalEventStream)(r=>{var i,l,c;let d,u;if("branch:activity"!==r.type||!e||r.projectId!==e)return;let h=(i=r,l=o.current,c=a.current,d=i.branch??"",u=c.get(d)??0,i.since<u?{kind:"stale"}:l.get(d)===i.activity?{kind:"redundant",key:d}:{kind:"transition",key:d});"stale"===h.kind||(a.current.set(h.key,r.since),n(new Map(a.current)),"redundant"!==h.kind&&s(e=>{let s=new Map(e);return s.set(h.key,r.activity),o.current=s,s}))}),{activity:r,since:i,refetch:c,setOptimisticActivity:(0,$.useCallback)((e,r)=>{s(s=>{let i=function(e,r,s){let i=r??"";if(e.get(i)===s)return e;let n=new Map(e);return n.set(i,s),n}(s,e,r);return o.current=i,i})},[])}}(U?.id??null),{rules:eD,createRule:eR,updateRule:eA,deleteRule:eM}=function(e,r){let[s,i]=(0,$.useState)([]),[n,a]=(0,$.useState)(!0),o=(0,$.useCallback)(async()=>{if(!e){i([]),a(!1);return}try{let s=await rv.api.getRules(e,r);i(s)}catch(e){console.error("Failed to fetch rules:",e)}finally{a(!1)}},[e,r]);(0,$.useEffect)(()=>{o()},[o]);let l=(0,$.useCallback)(async s=>{if(!e)return null;try{let n=await rv.api.createRule(e,{...s,branch:r});return i(e=>[...e,n]),n}catch(e){return console.error("Failed to create rule:",e),null}},[e,r]),c=(0,$.useCallback)(async(e,r)=>{i(s=>s.map(s=>s.id===e?{...s,...r,enabled:void 0!==r.enabled?+!!r.enabled:s.enabled,updated_at:new Date().toISOString()}:s));try{let s=await rv.api.updateRule(e,r);return i(r=>r.map(r=>r.id===e?s:r)),s}catch(e){return console.error("Failed to update rule:",e),i(s),null}},[s]),d=(0,$.useCallback)(async e=>{i(r=>r.filter(r=>r.id!==e));try{await rv.api.deleteRule(e)}catch(e){console.error("Failed to delete rule:",e),i(s)}},[s]);return{rules:s,loading:n,createRule:l,updateRule:c,deleteRule:d,refetch:o}}(U?.id??null,N),{commands:eF,createCommand:eT,updateCommand:eP,deleteCommand:eB}=function(e,r){let[s,i]=(0,$.useState)([]),[n,a]=(0,$.useState)(!0),o=(0,$.useCallback)(async()=>{if(!e){i([]),a(!1);return}try{let s=await rv.api.getCommands(e,r);i(s)}catch(e){console.error("Failed to fetch commands:",e)}finally{a(!1)}},[e,r]);(0,$.useEffect)(()=>{o()},[o]);let l=(0,$.useCallback)(async s=>{if(!e)return null;try{let n=await rv.api.createCommand(e,{...s,branch:r});return i(e=>[...e,n]),n}catch(e){return console.error("Failed to create command:",e),null}},[e,r]),c=(0,$.useCallback)(async(e,r)=>{i(s=>s.map(s=>s.id===e?{...s,...r,updated_at:new Date().toISOString()}:s));try{let s=await rv.api.updateCommand(e,r);return i(r=>r.map(r=>r.id===e?s:r)),s}catch(e){return console.error("Failed to update command:",e),i(s),null}},[s]),d=(0,$.useCallback)(async e=>{i(r=>r.filter(r=>r.id!==e));try{await rv.api.deleteCommand(e)}catch(e){console.error("Failed to delete command:",e),i(s)}},[s]);return{commands:s,loading:n,createCommand:l,updateCommand:c,deleteCommand:d,refetch:o}}(U?.id??null,N),eL=(0,$.useRef)(null),eI=(0,$.useSyncExternalStore)(SR,SA,SM),eO=U?.id??null,ez=U?.agent_mode??null,e$=(0,$.useCallback)(e=>!!eO&&eI.has(SF(eO,e,ez)),[eI,eO,ez]),eW=(0,$.useCallback)(e=>{if(eO)return eI.get(SF(eO,e,ez))},[eI,eO,ez]),eH=(0,$.useCallback)(e=>ek.get(su(e)),[ek]),eU=(0,$.useMemo)(()=>(function(e,r,s,i){let n=new Map;if(!e)return n;for(let a of e){let e=su(a.branch),o=r.get(e);if(!s?.(a.branch)){n.set(e,o??"idle");continue}if("main-running"===o)n.set(e,"main-running");else if("main-completed"===o){let r=i?.backendSince?.(a.branch)??0,s=i?.placeholderSince?.(a.branch)??0;n.set(e,s>r?"idle":"main-completed")}else n.set(e,"idle")}return n})(J,ej,e$,{backendSince:eH,placeholderSince:eW}),[J,ej,e$,eH,eW]);s=ei,i=eU,n=U?.id??null,a=(0,$.useRef)(new Set),l=(o=function(e){let r=new Set;if(!e)return r;for(let[s,i]of e)oR.has(i)&&r.add(s);return r}(i)).size>0,c=JSON.stringify(Array.from(o).sort()),(0,$.useEffect)(()=>{let e=new Set(JSON.parse(c)),r=a.current;a.current=e,function(e,r){for(let s of e)if(!r.has(s))return!0;return!1}(r,e)&&s()},[c,s]),(0,$.useEffect)(()=>{let e=()=>s();return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)},[s]),(0,ok.useGlobalEventStream)(e=>{"executor:stopped"===e.type&&e.projectId===n&&s(),"merge-target:updated"===e.type&&null!==n&&e.projectId===n&&s()}),(0,$.useEffect)(()=>{let e=null,r=()=>{null!==e&&(clearInterval(e),e=null)},i=()=>{r(),e=setInterval(s,l?3e4:6e4)},n=()=>{"visible"===document.visibilityState?i():r()};return"visible"===document.visibilityState&&i(),document.addEventListener("visibilitychange",n),()=>{r(),document.removeEventListener("visibilitychange",n)}},[s,l]);let{notifications:eK,unreadCount:eq,markRead:eV,markAllRead:eY,remove:eG,clear:eX}=function(e){let[r,s]=(0,$.useState)([]),i=(0,$.useRef)(new Map);(0,$.useEffect)(()=>{for(let e of Object.values(kz))kU.has(e)||kK.has(e)||(kK.add(e),(async()=>{try{let r=await fetch(e),s=await r.blob(),i=new Audio(URL.createObjectURL(s));i.preload="auto",i.load(),kU.set(e,i),console.log(`[sound-preload-debug] warmed ${e} bytes=${s.size}`)}catch(r){console.log(`[sound-preload-debug] warm failed ${e}`,r)}finally{kK.delete(e)}})())},[]);let n=(0,$.useRef)(e);(0,$.useEffect)(()=>{n.current=e},[e]),(0,$.useEffect)(()=>{e&&s(r=>r.some(r=>r.id===e&&!r.read)?r.map(r=>r.id===e?{...r,read:!0}:r):r)},[e,r]),(0,ok.useGlobalEventStream)(e=>{var r,a;let o;if("branch:activity"!==e.type)return;let l=k$(e.projectId,e.branch),c=i.current.get(l)!==e.activity;if(i.current.set(l,e.activity),!c||"completed"!==(r=e.activity)&&"main-completed"!==r)return;let d=e.activity;a=kz[d],(o=kU.get(a))||((o=new Audio(a)).preload="auto",kU.set(a,o)),o.currentTime=0,console.log(`[sound-preload-debug] play ${a} readyState=${o.readyState}`),o.play().catch(()=>{});let u=n.current===l;s(r=>{var s;return[(s={...e,activity:d},{id:k$(s.projectId,s.branch),projectId:s.projectId,branch:s.branch,sessionId:s.sessionId??null,type:s.activity,at:s.since,read:u}),...r.filter(e=>e.id!==l)].slice(0,50)})}),(0,$.useEffect)(()=>{let e=function(){try{var e=window.localStorage.getItem(kW);if(!e)return[];try{let r=JSON.parse(e);if(!Array.isArray(r))return[];return r.filter(kH).map(e=>({...e,sessionId:e.sessionId??null})).slice(0,50)}catch{return[]}}catch{return[]}}();0!==e.length&&s(r=>{if(0===r.length)return e;let s=new Set(r.map(e=>e.id));return[...r,...e.filter(e=>!s.has(e.id))].slice(0,50)})},[]);let a=(0,$.useRef)(!1);(0,$.useEffect)(()=>{if(!a.current){a.current=!0;return}try{window.localStorage.setItem(kW,JSON.stringify(r))}catch{}},[r]);let o=(0,$.useCallback)(e=>{s(r=>r.map(r=>r.id===e?{...r,read:!0}:r))},[]),l=(0,$.useCallback)(()=>{s(e=>e.some(e=>!e.read)?e.map(e=>({...e,read:!0})):e)},[]),c=(0,$.useCallback)(e=>{s(r=>r.filter(r=>r.id!==e))},[]),d=(0,$.useCallback)(()=>{s(e=>e.length?[]:e)},[]),u=r.reduce((e,r)=>e+ +!r.read,0);return{notifications:r,unreadCount:u,markRead:o,markAllRead:l,remove:c,clear:d}}(U&&"workspace"===D?`${U.id}:${N??""}`:null),eJ=(0,$.useCallback)(()=>{eE(N,"working")},[N,eE]),eZ=(0,$.useRef)(null),eQ=(0,$.useCallback)(()=>{ef()},[ef]),e0=(0,$.useCallback)((e,r,s)=>{eZ.current={projectId:s??U?.id,branch:e,sessionId:r},E(e),v(r),M(e=>e+1)},[U?.id,v]),e1=(0,$.useCallback)(e=>{e0(e.branch,e.id),R("workspace")},[e0]),e2=(0,$.useCallback)(e=>{eN(),!1!==e.processAlive&&x({id:e.id,projectId:e.projectId,branch:e.branch,title:"New Session",status:e.status,processAlive:!0,updated_at:new Date().toISOString()})},[eN]),e5=(0,$.useCallback)((e,r)=>{U?.id&&r.trim()&&x(s=>({id:e,projectId:U.id,branch:s?.id===e?s.branch:N,title:r,status:s?.id===e?s.status:"running",processAlive:!0,updated_at:s?.id===e?s.updated_at:new Date().toISOString()}))},[U?.id,N]),e3=(0,$.useCallback)(()=>{eE(N,"idle")},[N,eE]),e4=(0,$.useCallback)(()=>{ef()},[ef]);e=U?.id??null,r={onTaskChanged:e4},d=(0,$.useRef)(r.onTaskChanged),(0,$.useEffect)(()=>{d.current=r.onTaskChanged}),(0,ok.useGlobalEventStream)(r=>{e&&r.projectId===e&&("task:created"===r.type||"task:updated"===r.type||"task:deleted"===r.type)&&d.current?.()});let e6=(0,$.useMemo)(()=>{let e=su(N);return ea.find(r=>r.assigned_branch===e)??null},[ea,N]);(0,$.useCallback)(e=>{O(async()=>{await P.current?.submitMessage(e.description??e.title)})},[]),(0,$.useCallback)(e=>{ec(e,{assigned_branch:null})},[ec]);let e8=(0,$.useRef)(void 0);(0,$.useEffect)(()=>{if(Z||0===J.length)return;let e=e8.current;if(void 0!==e){if(J.some(r=>r.branch===e.branch)){e8.current=void 0,e.sessionId?e0(e.branch,e.sessionId):E(e.branch);return}e8.current=void 0}J.some(e=>e.branch===N)||E(J[0].branch)},[J,Z,N,e0]);let e7=(0,$.useCallback)((e,r,s=null)=>{if(R("workspace"),e===U?.id)return void(s?e0(r,s):E(r));let i=H.find(r=>r.id===e);i&&(e8.current={branch:r,sessionId:s},X(i))},[U?.id,H,X,e0]),[e9,te]=(0,$.useState)(!1);(0,$.useEffect)(()=>{let e=e=>{"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),te(e=>!e))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let tt=(0,$.useRef)(!1),tr=(0,$.useCallback)(async(e,r)=>{let s=H.find(r=>r.id===e);if(!s)return null;let i="local"===r?"local":r;return(s.agent_mode??"local")!==i?Y(s.id,{agentMode:i}):s},[H,Y]),ts=(0,$.useCallback)(e=>{if(tt.current)return;let r=H.find(r=>r.id===e);r&&(te(!1),X(r),R("project-info"))},[H,X]),ti=(0,$.useCallback)(async e=>{if(!tt.current){tt.current=!0,te(!1);try{let r=await tr(e.projectId,e.targetId);if(!r)return;R("workspace"),r.id===U?.id?(E(e.branch),v(null)):(e8.current={branch:e.branch,sessionId:null},X(r))}catch(e){console.error("Quick switcher navigation failed:",e),xg.toast.error("Failed to open workspace")}finally{tt.current=!1}}},[U?.id,tr,X,v]),tn=(0,$.useCallback)(async e=>{if(!tt.current){tt.current=!0,te(!1);try{let r=await tr(e.projectId,e.targetId);if(!r)return;R("workspace"),r.id===U?.id?e0(e.branch,e.sessionId,e.projectId):(e8.current={branch:e.branch,sessionId:e.sessionId},X(r))}catch(e){console.error("Quick switcher navigation failed:",e),xg.toast.error("Failed to open session")}finally{tt.current=!1}}},[U?.id,tr,X,e0]),ta=(0,$.useRef)(N),to=(0,$.useRef)(U?.id),tl=(0,$.useRef)(!1);(0,$.useEffect)(()=>{if(K)return;let e=!tl.current,r=!e&&ta.current!==N,s=!e&&to.current!==U?.id;ta.current=N,to.current=U?.id,tl.current=!0;let i=eZ.current;if(k1(i,U?.id,N,p)&&(eZ.current=null),function({branchChanged:e,projectChanged:r,urlSessionId:s,pendingSessionSelection:i,currentProjectId:n,selectedBranch:a}){return(!!e||!!r)&&!!s&&!k1(i,n,a,s)}({branchChanged:r,projectChanged:s,urlSessionId:p,pendingSessionSelection:i,currentProjectId:U?.id,selectedBranch:N})){eZ.current=null,v(null);return}let n=k0({projectId:U?.id,tab:D,branch:N});if(p){let e=new URL(n,window.location.origin);e.searchParams.set("session",p),window.history.replaceState(null,"",e.pathname+e.search)}else window.history.replaceState(null,"",n)},[U?.id,D,N,K,p,v]);let tc=(0,$.useCallback)(e=>{Q(),E(e)},[Q]);(0,$.useCallback)((e,r)=>{U&&r!==U.agent_mode?Y(U.id,{agentMode:r}).then(()=>{P.current?.submitMessage(e)}):P.current?.submitMessage(e)},[U,Y]);let td=(0,$.useRef)({content:"",at:0}),tu=(0,$.useCallback)(e=>{let r=Date.now(),s=td.current;s.content===e&&r-s.at<600||(td.current={content:e,at:r},eL.current?.sendMessage(e))},[]),th=(0,$.useCallback)(()=>{let e=`Please perform the following git operations for this worktree:
|
|
29
|
+
|
|
30
|
+
1. Commit all current uncommitted changes with an appropriate commit message
|
|
31
|
+
2. Fetch the latest changes from the remote main branch
|
|
32
|
+
3. Rebase the current branch onto main (resolve any conflicts if needed)
|
|
33
|
+
4. Merge the current branch into main
|
|
34
|
+
|
|
35
|
+
Please proceed step by step and let me know if there are any issues or conflicts that need manual resolution.`;P.current?.submitMessage(e)},[]),tf=(0,$.useCallback)(async e=>{if(U)try{await Y(U.id,{agentMode:e})}catch(e){console.error("Failed to update agent mode:",e)}},[U,Y]),tp=(0,$.useCallback)(async e=>{if(U)try{await Y(U.id,{executorMode:e})}catch(e){console.error("Failed to update executor mode:",e)}},[U,Y]),tm=!U;return(0,z.jsxs)("div",{className:"h-screen flex flex-col w-full",children:[(0,z.jsxs)("div",{className:"border-b border-border bg-card px-3 h-[44px] flex items-center justify-between sticky top-0 z-10",children:[(0,z.jsxs)("div",{className:"flex items-center gap-[9px]",children:[(0,z.jsx)(um.Logo,{size:22}),(0,z.jsxs)("h1",{className:"text-[13px] font-semibold tracking-tight text-foreground",children:["VibeDeck",(0,z.jsx)("span",{className:"text-primary font-bold",children:"X"})]})]}),(0,z.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,z.jsx)(W.Button,{variant:"ghost",size:"icon-sm","aria-label":"Search projects, workspaces, and sessions",title:"Search (⌘K / Ctrl+K)",onClick:()=>te(!0),children:(0,z.jsx)(dt,{className:"h-4 w-4"})}),(0,z.jsx)(kX,{}),(0,z.jsx)(kY,{notifications:eK,unreadCount:eq,projects:H,onNavigate:e7,markRead:eV,markAllRead:eY,remove:eG,clear:eX}),(0,z.jsx)(up,{})]})]}),(0,z.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,z.jsx)(ly,{activeView:D,onViewChange:R,worktrees:J,selectedBranch:N,onBranchChange:E,currentProject:U,onCreateWorktreeOpen:()=>w(!0),onDeleteWorktree:e=>{k(e),C(!0)},mergeStatuses:ee,mergeDefaultTarget:et,mergeRepositoryLabel:er,onMergeTargetChange:es,onMergeBadgeClick:e=>{E(e),R("workspace"),T(e=>e+1)},workspaceStatuses:eU,residentSessions:en,selectedSessionId:p,onResidentSessionSelect:e1,hasProject:!tm,projects:H,onSelectProject:X,onCreateProjectOpen:()=>y(!0),schedules:ep,selectedScheduleId:ey,onScheduleSelect:e=>{eb(e),R("schedules")},onCreateScheduleOpen:()=>{R("schedules"),eC(!0)}}),(0,z.jsx)("div",{className:tm&&("workspace"===D||"tasks"===D||"project-info"===D)?"flex-1 overflow-hidden":"hidden",children:(0,z.jsx)("div",{className:"h-full flex items-center justify-center bg-background",children:(0,z.jsxs)("div",{className:"text-center space-y-6",children:[(0,z.jsx)("div",{className:"mx-auto w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center",children:(0,z.jsx)(eS,{className:"h-8 w-8 text-primary"})}),(0,z.jsx)("h1",{className:"text-3xl font-bold tracking-tight text-foreground",children:"Welcome to VibeDeckX"}),(0,z.jsx)("p",{className:"text-muted-foreground max-w-sm mx-auto leading-relaxed",children:"Create your first project to get started with AI-powered development."}),(0,z.jsxs)(W.Button,{variant:"accent",size:"lg",onClick:()=>y(!0),className:"shadow-md",children:[(0,z.jsx)(eS,{className:"h-5 w-5 mr-2"}),"Create Project"]})]})})}),(0,z.jsx)("div",{className:"workspace"!==D||tm?"hidden":"flex-1 overflow-hidden flex",children:(0,z.jsx)(_p,{projectId:U?.id??void 0,children:(0,z.jsxs)(yQ,{direction:"horizontal",autoSaveId:"workspace-panels",children:[(0,z.jsx)(_2,{defaultSize:33,minSize:25,children:(0,z.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[U&&(0,z.jsx)("div",{className:"px-4 py-3 border-b border-border/60 flex-shrink-0",children:(0,z.jsx)(rx,{assignedTask:e6,rules:eD,commands:eF,onCreateRule:eR,onUpdateRule:eA,onDeleteRule:eM,onCreateCommand:eT,onUpdateCommand:eP,onDeleteCommand:eB,onExecuteCommand:tu,onUpdateTaskTitle:(e,r)=>ec(e,{title:r}),onCompleteTask:e=>{ec(e,{status:"done",assigned_branch:null})}})}),(0,z.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,z.jsx)(kE,{ref:eL,projectId:U?.id??null,branch:N})})]})}),(0,z.jsx)(y0,{withHandle:!0}),(0,z.jsx)(_2,{defaultSize:67,minSize:25,children:(0,z.jsx)("div",{className:"h-full flex flex-col overflow-hidden",children:(0,z.jsx)(wV,{active:"workspace"===D,projectId:U?.id??null,selectedBranch:N,activateAgentTabNonce:A,diffCompareNonce:F,mergeTarget:N?oN(ee.get(N))??et:null,onMergeRequest:th,project:U,onExecutorModeChange:tp,agentSlot:(0,z.jsx)(kg,{ref:P,projectId:U?.id??null,branch:N,sessionId:p,setSessionUrlParam:v,project:U,onAgentModeChange:tf,onTaskCompleted:eQ,onSessionStarted:e2,onSessionTitleUpdated:e5,onStatusChange:eJ,onNewConversation:e3})})})})]})})}),(0,z.jsx)("div",{className:"tasks"!==D||tm?"hidden":"flex-1 overflow-hidden",children:(0,z.jsx)(kL,{projectId:U?.id??null,tasks:ea,loading:eo,worktrees:J,onCreateTask:el,onUpdateTask:ec,onDeleteTask:ed,onArchiveTask:eu,onUnarchiveTask:eh})}),"project-info"===D&&!tm&&U&&(0,z.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,z.jsx)(oj,{project:U,tasks:ea,worktrees:J,selectedBranch:N,workspaceStatuses:eU,onSelectBranch:e=>{E(e),R("workspace")},onProjectUpdated:Y})}),"schedules"===D&&!tm&&U&&(0,z.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,z.jsx)(de,{projectId:U?.id??"",schedules:ep,loading:em,selectedId:ey,onSelect:eb,worktrees:J,onCreate:eg,onUpdate:ex,onDelete:async e=>{await ev(e),ey===e&&eb(null)},onRunNow:e_,createOpen:ew,onCreateOpenChange:eC})}),"remote-servers"===D&&(0,z.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,z.jsxs)("div",{className:"h-full flex flex-col overflow-auto",children:[(0,z.jsx)(lb,{title:"Remote Servers"}),(0,z.jsx)("div",{className:"flex-1 px-6 py-5 flex justify-center",children:(0,z.jsx)("div",{className:"w-full max-w-2xl",children:(0,z.jsx)(ud,{})})})]})}),(0,z.jsx)("div",{className:"settings"!==D?"hidden":"flex-1 overflow-hidden",children:(0,z.jsx)(un,{})})]}),U&&(0,z.jsx)(uu,{projectId:U.id,project:U,open:b,onOpenChange:w,onWorktreeCreated:tc}),(0,z.jsx)(ds,{open:_,onOpenChange:y,onProjectCreated:e=>{q(e),R("project-info")}}),U&&(0,z.jsx)(uh,{projectId:U.id,worktree:j,open:S,onOpenChange:C,onWorktreeDeleted:Q}),(0,z.jsx)(kO,{open:e9,onOpenChange:te,onNavigateProject:ts,onNavigateWorkspace:ti,onNavigateSession:tn})]})}e.s(["default",()=>k2],837031)}]);
|