@vibe80/vibe80 0.2.0 → 0.2.1

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.
@@ -688,7 +688,7 @@ If it declares any Font Awesome CSS pseudo-elements, they will not be rendered a
688
688
 
689
689
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
690
690
 
691
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return x.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},K7="DialogDescriptionWarning",G7=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${mC(K7).contentName}}.`;return x.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},q7=sC,Y7=lC,J7=cC,X7=uC,Q7=Symbol.for("react.lazy"),Ac=Nd[" use ".trim().toString()];function Z7(e){return typeof e=="object"&&e!==null&&"then"in e}function gC(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Q7&&"_payload"in e&&Z7(e._payload)}function eB(e){const t=tB(e),r=x.forwardRef((n,i)=>{let{children:s,...a}=n;gC(s)&&typeof Ac=="function"&&(s=Ac(s._payload));const o=x.Children.toArray(s),l=o.find(nB);if(l){const c=l.props.children,h=o.map(u=>u===l?x.Children.count(c)>1?x.Children.only(null):x.isValidElement(c)?c.props.children:null:u);return E.jsx(t,{...a,ref:i,children:x.isValidElement(c)?x.cloneElement(c,void 0,h):null})}return E.jsx(t,{...a,ref:i,children:s})});return r.displayName=`${e}.Slot`,r}function tB(e){const t=x.forwardRef((r,n)=>{let{children:i,...s}=r;if(gC(i)&&typeof Ac=="function"&&(i=Ac(i._payload)),x.isValidElement(i)){const a=sB(i),o=iB(s,i.props);return i.type!==x.Fragment&&(o.ref=n?Un(n,a):a),x.cloneElement(i,o)}return x.Children.count(i)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rB=Symbol("radix.slottable");function nB(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rB}function iB(e,t){const r={...t};for(const n in t){const i=e[n],s=t[n];/^on[A-Z]/.test(n)?i&&s?r[n]=(...o)=>{const l=s(...o);return i(...o),l}:i&&(r[n]=i):n==="style"?r[n]={...i,...s}:n==="className"&&(r[n]=[i,s].filter(Boolean).join(" "))}return{...e,...r}}function sB(e){var n,i;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var oB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],qn=oB.reduce((e,t)=>{const r=eB(`Primitive.${t}`),n=x.forwardRef((i,s)=>{const{asChild:a,...o}=i,l=a?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),E.jsx(l,{...o,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),no='[cmdk-group=""]',Kf='[cmdk-group-items=""]',aB='[cmdk-group-heading=""]',vC='[cmdk-item=""]',j1=`${vC}:not([aria-disabled="true"])`,Ld="cmdk-item-select",zi="data-value",lB=(e,t,r)=>aj(e,t,r),_C=x.createContext(void 0),va=()=>x.useContext(_C),yC=x.createContext(void 0),gm=()=>x.useContext(yC),wC=x.createContext(void 0),bC=x.forwardRef((e,t)=>{let r=$i(()=>{var D,T;return{search:"",value:(T=(D=e.value)!=null?D:e.defaultValue)!=null?T:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=$i(()=>new Set),i=$i(()=>new Map),s=$i(()=>new Map),a=$i(()=>new Set),o=kC(e),{label:l,children:c,value:h,onValueChange:u,filter:m,shouldFilter:v,loop:w,disablePointerSelection:_=!1,vimBindings:g=!0,...d}=e,f=Zr(),p=Zr(),y=Zr(),S=x.useRef(null),b=_B();vi(()=>{if(h!==void 0){let D=h.trim();r.current.value=D,k.emit()}},[h]),vi(()=>{b(6,M)},[]);let k=x.useMemo(()=>({subscribe:D=>(a.current.add(D),()=>a.current.delete(D)),snapshot:()=>r.current,setState:(D,T,$)=>{var Y,W,j,N;if(!Object.is(r.current[D],T)){if(r.current[D]=T,D==="search")R(),P(),b(1,O);else if(D==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let G=document.getElementById(y);G?G.focus():(Y=document.getElementById(f))==null||Y.focus()}if(b(7,()=>{var G;r.current.selectedItemId=(G=z())==null?void 0:G.id,k.emit()}),$||b(5,M),((W=o.current)==null?void 0:W.value)!==void 0){let G=T??"";(N=(j=o.current).onValueChange)==null||N.call(j,G);return}}k.emit()}},emit:()=>{a.current.forEach(D=>D())}}),[]),C=x.useMemo(()=>({value:(D,T,$)=>{var Y;T!==((Y=s.current.get(D))==null?void 0:Y.value)&&(s.current.set(D,{value:T,keywords:$}),r.current.filtered.items.set(D,A(T,$)),b(2,()=>{P(),k.emit()}))},item:(D,T)=>(n.current.add(D),T&&(i.current.has(T)?i.current.get(T).add(D):i.current.set(T,new Set([D]))),b(3,()=>{R(),P(),r.current.value||O(),k.emit()}),()=>{s.current.delete(D),n.current.delete(D),r.current.filtered.items.delete(D);let $=z();b(4,()=>{R(),($==null?void 0:$.getAttribute("id"))===D&&O(),k.emit()})}),group:D=>(i.current.has(D)||i.current.set(D,new Set),()=>{s.current.delete(D),i.current.delete(D)}),filter:()=>o.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>o.current.disablePointerSelection,listId:f,inputId:y,labelId:p,listInnerRef:S}),[]);function A(D,T){var $,Y;let W=(Y=($=o.current)==null?void 0:$.filter)!=null?Y:lB;return D?W(D,r.current.search,T):0}function P(){if(!r.current.search||o.current.shouldFilter===!1)return;let D=r.current.filtered.items,T=[];r.current.filtered.groups.forEach(Y=>{let W=i.current.get(Y),j=0;W.forEach(N=>{let G=D.get(N);j=Math.max(G,j)}),T.push([Y,j])});let $=S.current;U().sort((Y,W)=>{var j,N;let G=Y.getAttribute("id"),V=W.getAttribute("id");return((j=D.get(V))!=null?j:0)-((N=D.get(G))!=null?N:0)}).forEach(Y=>{let W=Y.closest(Kf);W?W.appendChild(Y.parentElement===W?Y:Y.closest(`${Kf} > *`)):$.appendChild(Y.parentElement===$?Y:Y.closest(`${Kf} > *`))}),T.sort((Y,W)=>W[1]-Y[1]).forEach(Y=>{var W;let j=(W=S.current)==null?void 0:W.querySelector(`${no}[${zi}="${encodeURIComponent(Y[0])}"]`);j==null||j.parentElement.appendChild(j)})}function O(){let D=U().find($=>$.getAttribute("aria-disabled")!=="true"),T=D==null?void 0:D.getAttribute(zi);k.setState("value",T||void 0)}function R(){var D,T,$,Y;if(!r.current.search||o.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let W=0;for(let j of n.current){let N=(T=(D=s.current.get(j))==null?void 0:D.value)!=null?T:"",G=(Y=($=s.current.get(j))==null?void 0:$.keywords)!=null?Y:[],V=A(N,G);r.current.filtered.items.set(j,V),V>0&&W++}for(let[j,N]of i.current)for(let G of N)if(r.current.filtered.items.get(G)>0){r.current.filtered.groups.add(j);break}r.current.filtered.count=W}function M(){var D,T,$;let Y=z();Y&&(((D=Y.parentElement)==null?void 0:D.firstChild)===Y&&(($=(T=Y.closest(no))==null?void 0:T.querySelector(aB))==null||$.scrollIntoView({block:"nearest"})),Y.scrollIntoView({block:"nearest"}))}function z(){var D;return(D=S.current)==null?void 0:D.querySelector(`${vC}[aria-selected="true"]`)}function U(){var D;return Array.from(((D=S.current)==null?void 0:D.querySelectorAll(j1))||[])}function q(D){let T=U()[D];T&&k.setState("value",T.getAttribute(zi))}function Q(D){var T;let $=z(),Y=U(),W=Y.findIndex(N=>N===$),j=Y[W+D];(T=o.current)!=null&&T.loop&&(j=W+D<0?Y[Y.length-1]:W+D===Y.length?Y[0]:Y[W+D]),j&&k.setState("value",j.getAttribute(zi))}function H(D){let T=z(),$=T==null?void 0:T.closest(no),Y;for(;$&&!Y;)$=D>0?gB($,no):vB($,no),Y=$==null?void 0:$.querySelector(j1);Y?k.setState("value",Y.getAttribute(zi)):Q(D)}let I=()=>q(U().length-1),L=D=>{D.preventDefault(),D.metaKey?I():D.altKey?H(1):Q(1)},B=D=>{D.preventDefault(),D.metaKey?q(0):D.altKey?H(-1):Q(-1)};return x.createElement(qn.div,{ref:t,tabIndex:-1,...d,"cmdk-root":"",onKeyDown:D=>{var T;(T=d.onKeyDown)==null||T.call(d,D);let $=D.nativeEvent.isComposing||D.keyCode===229;if(!(D.defaultPrevented||$))switch(D.key){case"n":case"j":{g&&D.ctrlKey&&L(D);break}case"ArrowDown":{L(D);break}case"p":case"k":{g&&D.ctrlKey&&B(D);break}case"ArrowUp":{B(D);break}case"Home":{D.preventDefault(),q(0);break}case"End":{D.preventDefault(),I();break}case"Enter":{D.preventDefault();let Y=z();if(Y){let W=new Event(Ld);Y.dispatchEvent(W)}}}}},x.createElement("label",{"cmdk-label":"",htmlFor:C.inputId,id:C.labelId,style:wB},l),fu(e,D=>x.createElement(yC.Provider,{value:k},x.createElement(_C.Provider,{value:C},D))))}),SC=x.forwardRef((e,t)=>{var r,n;let i=Zr(),s=x.useRef(null),a=x.useContext(wC),o=va(),l=kC(e),c=(n=(r=l.current)==null?void 0:r.forceMount)!=null?n:a==null?void 0:a.forceMount;vi(()=>{if(!c)return o.item(i,a==null?void 0:a.id)},[c]);let h=xC(i,s,[e.value,e.children,s],e.keywords),u=gm(),m=Hn(b=>b.value&&b.value===h.current),v=Hn(b=>c||o.filter()===!1?!0:b.search?b.filtered.items.get(i)>0:!0);x.useEffect(()=>{let b=s.current;if(!(!b||e.disabled))return b.addEventListener(Ld,w),()=>b.removeEventListener(Ld,w)},[v,e.onSelect,e.disabled]);function w(){var b,k;_(),(k=(b=l.current).onSelect)==null||k.call(b,h.current)}function _(){u.setState("value",h.current,!0)}if(!v)return null;let{disabled:g,value:d,onSelect:f,forceMount:p,keywords:y,...S}=e;return x.createElement(qn.div,{ref:Un(s,t),...S,id:i,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!m,"data-disabled":!!g,"data-selected":!!m,onPointerMove:g||o.getDisablePointerSelection()?void 0:_,onClick:g?void 0:w},e.children)}),cB=x.forwardRef((e,t)=>{let{heading:r,children:n,forceMount:i,...s}=e,a=Zr(),o=x.useRef(null),l=x.useRef(null),c=Zr(),h=va(),u=Hn(v=>i||h.filter()===!1?!0:v.search?v.filtered.groups.has(a):!0);vi(()=>h.group(a),[]),xC(a,o,[e.value,e.heading,l]);let m=x.useMemo(()=>({id:a,forceMount:i}),[i]);return x.createElement(qn.div,{ref:Un(o,t),...s,"cmdk-group":"",role:"presentation",hidden:u?void 0:!0},r&&x.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},r),fu(e,v=>x.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?c:void 0},x.createElement(wC.Provider,{value:m},v))))}),uB=x.forwardRef((e,t)=>{let{alwaysRender:r,...n}=e,i=x.useRef(null),s=Hn(a=>!a.search);return!r&&!s?null:x.createElement(qn.div,{ref:Un(i,t),...n,"cmdk-separator":"",role:"separator"})}),fB=x.forwardRef((e,t)=>{let{onValueChange:r,...n}=e,i=e.value!=null,s=gm(),a=Hn(c=>c.search),o=Hn(c=>c.selectedItemId),l=va();return x.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),x.createElement(qn.input,{ref:t,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":o,id:l.inputId,type:"text",value:i?e.value:a,onChange:c=>{i||s.setState("search",c.target.value),r==null||r(c.target.value)}})}),CC=x.forwardRef((e,t)=>{let{children:r,label:n="Suggestions",...i}=e,s=x.useRef(null),a=x.useRef(null),o=Hn(c=>c.selectedItemId),l=va();return x.useEffect(()=>{if(a.current&&s.current){let c=a.current,h=s.current,u,m=new ResizeObserver(()=>{u=requestAnimationFrame(()=>{let v=c.offsetHeight;h.style.setProperty("--cmdk-list-height",v.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(u),m.unobserve(c)}}},[]),x.createElement(qn.div,{ref:Un(s,t),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":o,"aria-label":n,id:l.listId},fu(e,c=>x.createElement("div",{ref:Un(a,l.listInnerRef),"cmdk-list-sizer":""},c)))}),hB=x.forwardRef((e,t)=>{let{open:r,onOpenChange:n,overlayClassName:i,contentClassName:s,container:a,...o}=e;return x.createElement(q7,{open:r,onOpenChange:n},x.createElement(Y7,{container:a},x.createElement(J7,{"cmdk-overlay":"",className:i}),x.createElement(X7,{"aria-label":e.label,"cmdk-dialog":"",className:s},x.createElement(bC,{ref:t,...o}))))}),dB=x.forwardRef((e,t)=>Hn(r=>r.filtered.count===0)?x.createElement(qn.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),pB=x.forwardRef((e,t)=>{let{progress:r,children:n,label:i="Loading...",...s}=e;return x.createElement(qn.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},fu(e,a=>x.createElement("div",{"aria-hidden":!0},a)))}),mB=Object.assign(bC,{List:CC,Item:SC,Input:fB,Group:cB,Separator:uB,Dialog:hB,Empty:dB,Loading:pB});function gB(e,t){let r=e.nextElementSibling;for(;r;){if(r.matches(t))return r;r=r.nextElementSibling}}function vB(e,t){let r=e.previousElementSibling;for(;r;){if(r.matches(t))return r;r=r.previousElementSibling}}function kC(e){let t=x.useRef(e);return vi(()=>{t.current=e}),t}var vi=typeof window>"u"?x.useEffect:x.useLayoutEffect;function $i(e){let t=x.useRef();return t.current===void 0&&(t.current=e()),t}function Hn(e){let t=gm(),r=()=>e(t.snapshot());return x.useSyncExternalStore(t.subscribe,r,r)}function xC(e,t,r,n=[]){let i=x.useRef(),s=va();return vi(()=>{var a;let o=(()=>{var c;for(let h of r){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(c=h.current.textContent)==null?void 0:c.trim():i.current}})(),l=n.map(c=>c.trim());s.value(e,o,l),(a=t.current)==null||a.setAttribute(zi,o),i.current=o}),i}var _B=()=>{let[e,t]=x.useState(),r=$i(()=>new Map);return vi(()=>{r.current.forEach(n=>n()),r.current=new Map},[e]),(n,i)=>{r.current.set(n,i),t({})}};function yB(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function fu({asChild:e,children:t},r){return e&&x.isValidElement(t)?x.cloneElement(yB(t),{ref:t.ref},r(t.props.children)):r(t)}var wB={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function bB({t:e,activePane:t,isDraggingAttachments:r,onSubmit:n,onDragEnterComposer:i,onDragOverComposer:s,onDragLeaveComposer:a,onDropAttachments:o,composerRef:l,draftAttachments:c,getAttachmentExtension:h,formatAttachmentSize:u,removeDraftAttachment:m,commandMenuOpen:v,filteredCommands:w,setInput:_,setCommandMenuOpen:g,setCommandQuery:d,inputRef:f,commandSelection:p,triggerAttachmentPicker:y,attachmentSession:S,attachmentsLoading:b,isMobileLayout:k,uploadInputRef:C,onUploadAttachments:A,input:P,handleInputChange:O,handleComposerKeyDown:R,onPasteAttachments:M,canInterrupt:z,interruptTurn:U,connected:q,modelSelectorVisible:Q,modelOptions:H,selectedModel:I,modelLoading:L,modelDisabled:B,modelError:D,onModelChange:T,isCodexReady:$,interactionBlocked:Y,attachmentsError:W}){return t!=="chat"?null:E.jsx("form",{className:`composer composer--sticky ${r?"is-dragging":""}`,onSubmit:n,onDragEnter:i,onDragOver:s,onDragLeave:a,onDrop:o,ref:l,children:E.jsxs("div",{className:"composer-inner",children:[c.length?E.jsx("div",{className:"composer-attachments","aria-label":e("Selected attachments"),children:c.map(j=>{const N=(j==null?void 0:j.name)||(j==null?void 0:j.path)||"",G=(j==null?void 0:j.path)||(j==null?void 0:j.name)||N,V=h(j,e),X=j!=null&&j.lineCount||j!=null&&j.lines?e("{{count}} lines",{count:j.lineCount||j.lines}):u(j==null?void 0:j.size,e);return E.jsxs("div",{className:"attachment-card",children:[E.jsxs("div",{className:"attachment-card-body",children:[E.jsx("div",{className:"attachment-card-title",children:N}),X?E.jsx("div",{className:"attachment-card-meta",children:X}):null]}),E.jsxs("div",{className:"attachment-card-footer",children:[E.jsx("span",{className:"attachment-card-type",children:V}),E.jsx("button",{type:"button",className:"attachment-card-remove","aria-label":e("Remove {{label}}",{label:N}),onClick:()=>m((j==null?void 0:j.path)||(j==null?void 0:j.name)),children:E.jsx(Be,{icon:si})})]})]},G)})}):null,v&&E.jsx("div",{className:"composer-command-menu",children:E.jsx(mB,{className:"command-menu",shouldFilter:!1,children:E.jsx(CC,{children:w.length?w.map(j=>E.jsxs(SC,{onSelect:()=>{var N;_(j.insert),g(!1),d(""),(N=f.current)==null||N.focus()},className:`command-item${j.id===p?" is-selected":""}`,children:[E.jsx("span",{className:"command-item-label",children:j.label}),E.jsx("span",{className:"command-item-desc",children:j.description})]},j.id)):E.jsx("div",{className:"command-empty",children:e("No commands found.")})})})}),E.jsxs("div",{className:"composer-main",children:[E.jsxs("button",{type:"button",className:"icon-button composer-attach-button","aria-label":e("Add attachment"),onClick:y,disabled:!S||b,children:["+",k?E.jsx("span",{className:"attachment-badge",children:c.length}):null]}),E.jsx("input",{ref:C,type:"file",multiple:!0,onChange:A,disabled:!S||b,className:"visually-hidden"}),E.jsx("textarea",{className:"composer-input",value:P,onChange:O,onKeyDown:R,onPaste:M,placeholder:e("Write your message…"),rows:1,ref:f}),Q?E.jsxs("select",{className:"composer-model-select",value:I||"",onChange:j=>T==null?void 0:T(j.target.value),disabled:B,"aria-label":e("Model"),title:D||e("Model"),children:[L?E.jsx("option",{value:"",children:e("Loading...")}):null,E.jsx("option",{value:"",children:e("Default model")}),(Array.isArray(H)?H:[]).map(j=>E.jsx("option",{value:j.model||"",children:j.displayName||j.model||""},j.id||j.model))]}):null,z?E.jsx("button",{type:"button",className:"primary stop-button",onClick:U,"aria-label":e("Stop"),title:e("Stop"),children:E.jsx("span",{className:"stop-icon",children:"⏹"})}):E.jsx("button",{type:"submit",className:"primary send-button",disabled:!q||!P.trim()||!$||Y,"aria-label":e("Send"),title:e("Send"),children:E.jsx("span",{className:"send-icon",children:"➤"})})]}),W&&E.jsx("div",{className:"attachments-error composer-attachments-error",children:W})]})})}function SB({t:e,activePane:t,handleViewSelect:r,handleDiffSelect:n,terminalEnabled:i,hasMessages:s,handleClearChat:a}){return t==="settings"?null:E.jsxs("div",{className:"chat-toolbar",role:"toolbar","aria-label":e("Chat tools"),children:[E.jsxs("div",{className:"chat-toolbar-group",children:[E.jsxs("button",{type:"button",className:`chat-toolbar-button ${t==="chat"?"is-active":""}`,onClick:()=>r("chat"),"aria-pressed":t==="chat","aria-label":e("Messages"),title:e("Messages"),children:[E.jsx("span",{className:"chat-toolbar-icon-wrap","aria-hidden":"true",children:E.jsx("span",{className:"chat-toolbar-icon",children:E.jsx(Be,{icon:ZD})})}),E.jsx("span",{className:"chat-toolbar-label",children:e("Messages")})]}),E.jsxs("button",{type:"button",className:`chat-toolbar-button ${t==="diff"?"is-active":""}`,onClick:n,"aria-pressed":t==="diff","aria-label":e("Diff"),title:e("Diff"),children:[E.jsx("span",{className:"chat-toolbar-icon-wrap","aria-hidden":"true",children:E.jsx("span",{className:"chat-toolbar-icon",children:E.jsx(Be,{icon:o6})})}),E.jsx("span",{className:"chat-toolbar-label",children:e("Diff")})]}),E.jsxs("button",{type:"button",className:`chat-toolbar-button ${t==="explorer"?"is-active":""}`,onClick:()=>r("explorer"),"aria-pressed":t==="explorer","aria-label":e("Explorer"),title:e("Explorer"),children:[E.jsx("span",{className:"chat-toolbar-icon-wrap","aria-hidden":"true",children:E.jsx("span",{className:"chat-toolbar-icon",children:E.jsx(Be,{icon:i6})})}),E.jsx("span",{className:"chat-toolbar-label",children:e("Explorer")})]}),E.jsxs("button",{type:"button",className:`chat-toolbar-button ${t==="terminal"?"is-active":""}`,onClick:()=>r("terminal"),"aria-pressed":t==="terminal","aria-label":e("Terminal"),title:e("Terminal"),disabled:!i,children:[E.jsx("span",{className:"chat-toolbar-icon-wrap","aria-hidden":"true",children:E.jsx("span",{className:"chat-toolbar-icon",children:E.jsx(Be,{icon:XD})})}),E.jsx("span",{className:"chat-toolbar-label",children:e("Terminal")})]})]}),E.jsx("div",{className:"chat-toolbar-divider"}),E.jsx("div",{className:"chat-toolbar-group",children:E.jsxs("button",{type:"button",className:"chat-toolbar-button is-danger",onClick:()=>a(),"aria-label":e("Clear"),title:e("Clear"),disabled:!s,children:[E.jsx("span",{className:"chat-toolbar-icon-wrap","aria-hidden":"true",children:E.jsx("span",{className:"chat-toolbar-icon","aria-hidden":"true",children:E.jsx(Be,{icon:YD})})}),E.jsx("span",{className:"chat-toolbar-label",children:e("Clear")})]})})]})}function CB({t:e,input:t,setInput:r,inputRef:n,handleSendMessageRef:i,attachmentSession:s,apiFetch:a,normalizeAttachments:o,setDraftAttachments:l,draftAttachments:c,setAttachmentsLoading:h,setAttachmentsError:u,showToast:m,uploadInputRef:v,attachmentsLoading:w,conversationRef:_,composerRef:g,isMobileLayout:d}){const[f,p]=x.useState(!1),[y,S]=x.useState(""),[b,k]=x.useState(null),[C,A]=x.useState(!1),P=x.useRef(0),O=x.useMemo(()=>[{id:"todo",label:"/todo",description:e("Add to backlog"),insert:"/todo "},{id:"backlog",label:"/backlog",description:e("Show backlog"),insert:"/backlog"},{id:"open",label:"/open",description:e("Open path"),insert:"/open "},{id:"run",label:"/run",description:e("Run shell command"),insert:"/run "},{id:"screenshot",label:"/screenshot",description:e("Capture screenshot"),insert:"/screenshot"},{id:"git",label:"/git",description:e("Run git command"),insert:"/git "},{id:"diff",label:"/diff",description:e("Open diff view"),insert:"/diff"},{id:"annotation",label:"/annotation",description:e("Toggle annotation mode (EXPERIMENTAL)"),insert:"/annotation on"}],[e]),R=x.useMemo(()=>{const W=y.trim().toLowerCase();return W?O.filter(j=>j.label.toLowerCase().includes(W)):O},[O,y]);x.useEffect(()=>{if(!f){k(null);return}if(!R.length){k(null);return}k(W=>R.some(j=>j.id===W)?W:R[0].id)},[f,R]);const M=x.useCallback(W=>{const{value:j}=W.target;r(j),j.startsWith("/")&&!j.includes(" ")?(p(!0),S(j.slice(1))):(p(!1),S("")),n.current&&(n.current.style.height="auto",n.current.style.height=`${n.current.scrollHeight}px`)},[n,r]),z=x.useCallback(W=>{var j,N;if(f){if(W.key==="Escape"){W.preventDefault(),p(!1);return}if(W.key==="ArrowDown"){if(W.preventDefault(),!R.length)return;const G=R.findIndex(X=>X.id===b),V=G===-1||G===R.length-1?0:G+1;k(R[V].id);return}if(W.key==="ArrowUp"){if(W.preventDefault(),!R.length)return;const G=R.findIndex(X=>X.id===b),V=G<=0?R.length-1:G-1;k(R[V].id);return}if(W.key==="Enter"&&!W.shiftKey&&b){W.preventDefault();const G=R.find(V=>V.id===b);G&&(r(G.insert),p(!1),S(""),(j=n.current)==null||j.focus());return}}W.isComposing||W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),(N=i.current)==null||N.call(i))},[f,R,b,i,n,r]);x.useEffect(()=>{n.current&&(n.current.style.height="auto",n.current.style.height=`${n.current.scrollHeight}px`)},[t,d,n]),x.useEffect(()=>{if(!_.current||!g.current)return;const W=()=>{if(!_.current||!g.current)return;const N=g.current.getBoundingClientRect(),G=d?12:16;_.current.style.setProperty("--composer-space",`${Math.ceil(N.height+G)}px`)};W();let j;return typeof ResizeObserver<"u"&&(j=new ResizeObserver(W),j.observe(g.current)),window.addEventListener("resize",W),()=>{window.removeEventListener("resize",W),j&&j.disconnect()}},[d,c.length,_,g]);const U=x.useCallback(async W=>{if(!(!W.length||!(s!=null&&s.sessionId)))try{h(!0),u("");const j=new FormData;W.forEach(X=>j.append("files",X));const N=await a(`/api/v1/sessions/${encodeURIComponent(s.sessionId)}/attachments/upload`,{method:"POST",body:j});if(!N.ok)throw new Error("Upload failed.");const G=await N.json(),V=o(G.files||[]);l(X=>[...X,...V])}catch(j){u(j.message||e("Unable to upload attachments."))}finally{h(!1)}},[a,s==null?void 0:s.sessionId,o,u,h,l,e]),q=x.useCallback(async()=>{var W;if(!(s!=null&&s.sessionId)){m(e("Session not found."),"error");return}if(!((W=navigator.mediaDevices)!=null&&W.getDisplayMedia)){m(e("Screenshot failed."),"error");return}try{const j=await navigator.mediaDevices.getDisplayMedia({video:{cursor:"never"},audio:!1}),N=document.createElement("video");N.srcObject=j,await new Promise(ve=>{N.onloadedmetadata=()=>ve()}),await N.play();const G=document.createElement("canvas");G.width=N.videoWidth||1,G.height=N.videoHeight||1;const V=G.getContext("2d");if(!V)throw new Error("Canvas unavailable");V.drawImage(N,0,0,G.width,G.height),j.getTracks().forEach(ve=>ve.stop());const X=await new Promise((ve,le)=>{G.toBlob(Se=>Se?ve(Se):le(new Error("Blob failed")),"image/png")}),ne=`screenshot-${Date.now()}.png`,ue=new File([X],ne,{type:"image/png"});await U([ue]),m(e("Screenshot captured."))}catch(j){m((j==null?void 0:j.message)||e("Screenshot failed."),"error")}},[s==null?void 0:s.sessionId,m,e,U]),Q=x.useCallback(async W=>{const j=Array.from(W.target.files||[]);await U(j),W.target.value=""},[U]),H=x.useCallback(async W=>{var G;if(!(s!=null&&s.sessionId))return;const N=Array.from(((G=W.clipboardData)==null?void 0:G.items)||[]).filter(V=>V.kind==="file").map(V=>V.getAsFile()).filter(Boolean);N.length&&(W.preventDefault(),await U(N))},[s==null?void 0:s.sessionId,U]),I=x.useCallback(W=>{var j,N;s!=null&&s.sessionId&&(N=(j=W.dataTransfer)==null?void 0:j.types)!=null&&N.includes("Files")&&W.preventDefault()},[s==null?void 0:s.sessionId]),L=x.useCallback(W=>{var j,N;s!=null&&s.sessionId&&(N=(j=W.dataTransfer)==null?void 0:j.types)!=null&&N.includes("Files")&&(W.preventDefault(),P.current+=1,A(!0))},[s==null?void 0:s.sessionId]),B=x.useCallback(W=>{var j,N;s!=null&&s.sessionId&&(N=(j=W.dataTransfer)==null?void 0:j.types)!=null&&N.includes("Files")&&(W.preventDefault(),P.current=Math.max(0,P.current-1),P.current===0&&A(!1))},[s==null?void 0:s.sessionId]),D=x.useCallback(async W=>{var N;if(!(s!=null&&s.sessionId))return;W.preventDefault(),W.stopPropagation(),P.current=0,A(!1);const j=Array.from(((N=W.dataTransfer)==null?void 0:N.files)||[]);j.length&&await U(j)},[s==null?void 0:s.sessionId,U]),T=x.useCallback(W=>{W&&l(j=>j.filter(N=>((N==null?void 0:N.path)||(N==null?void 0:N.name))!==W))},[l]),$=x.useCallback(()=>{!s||w||requestAnimationFrame(()=>{var W;(W=v.current)==null||W.click()})},[s,w,v]),Y=x.useCallback(W=>{var j;W.preventDefault(),(j=i.current)==null||j.call(i)},[i]);return{commandMenuOpen:f,setCommandMenuOpen:p,commandQuery:y,setCommandQuery:S,commandSelection:b,filteredCommands:R,isDraggingAttachments:C,handleInputChange:M,handleComposerKeyDown:z,onSubmit:Y,onUploadAttachments:Q,onPasteAttachments:H,onDragOverComposer:I,onDragEnterComposer:L,onDragLeaveComposer:B,onDropAttachments:D,removeDraftAttachment:T,triggerAttachmentPicker:$,captureScreenshot:q}}function kB({attachmentSessionId:e,workspaceToken:t,socketRef:r,reconnectTimerRef:n,reconnectAttemptRef:i,closingRef:s,pingIntervalRef:a,lastPongRef:o,messageIndex:l,commandIndex:c,rpcLogsEnabledRef:h,mergeAndApplyMessages:u,requestMessageSync:m,requestWorktreesList:v,requestWorktreeMessages:w,applyWorktreesList:_,resyncSession:g,t:d,setStatus:f,setConnected:p,setAppServerReady:y,setHasMainWorktreeStatus:S,setMessages:b,setProcessing:k,setActivity:C,setCurrentTurnId:A,setMainTaskLabel:P,setModelLoading:O,setModelError:R,setModels:M,setProviderModelState:z,setSelectedModel:U,setSelectedReasoningEffort:q,setRepoDiff:Q,setRpcLogs:H,setWorktrees:I,setPaneByTab:L,setLogFilterByTab:B,setActiveWorktreeId:D,activeWorktreeIdRef:T,extractVibe80Task:$,extractFirstLine:Y,getItemActivityLabel:W,maybeNotify:j,normalizeAttachments:N,loadRepoLastCommit:G,loadBranches:V,loadWorktreeLastCommit:X,openAiLoginRequest:ne,setOpenAiLoginRequest:ue,connected:ve}){x.useEffect(()=>{if(!e||!t)return;let le=!0,Se=null;const ye=()=>{n.current&&(clearTimeout(n.current),n.current=null)},Me=()=>{a.current&&(clearInterval(a.current),a.current=null)},Ne=()=>{Se&&(clearInterval(Se),Se=null)},Ue=()=>{Me(),o.current=Date.now(),a.current=setInterval(()=>{const Ce=r.current;if(!Ce||Ce.readyState!==WebSocket.OPEN)return;if(document.hidden){o.current=Date.now();return}if(Date.now()-o.current>15e3){Ce.close();return}Ce.send(JSON.stringify({type:"ping"}))},1e4)},Ke=()=>{Ne();const Ce=()=>{const Z=r.current;if(!Z||Z.readyState!==WebSocket.OPEN)return;const se=(T==null?void 0:T.current)||"main";Z.send(JSON.stringify({type:"wake_up",worktreeId:se}))};Ce(),Se=setInterval(Ce,60*1e3)},Ye=()=>{if(!le)return;const Ce=Math.min(i.current+1,6);i.current=Ce;const we=Math.min(500*2**(Ce-1),1e4),F=Math.floor(Math.random()*250);ye(),n.current=setTimeout(()=>{Ee()},we+F)},Ee=()=>{if(!le)return;f(d("Connecting..."));const Ce=new WebSocket(`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws?session=${encodeURIComponent(e)}`);r.current=Ce;let Z=!1;const se=()=>r.current===Ce;Ce.addEventListener("open",()=>{se()&&Ce.send(JSON.stringify({type:"auth",token:t}))}),Ce.addEventListener("close",()=>{se()&&(p(!1),f(d("Disconnected")),y(!1),Me(),Ne(),s.current||Ye())}),Ce.addEventListener("error",()=>{se()&&Ce.close()}),Ce.addEventListener("message",we=>{var St,ce,he;if(!se())return;let F;try{F=JSON.parse(we.data)}catch{return}const _e=typeof F.worktreeId=="string"?F.worktreeId:"",De=_e.length>0,ee=_e==="main",Ae=De&&!ee,Ie=ee||!De;if(Ie&&(F.type==="assistant_delta"||F.type==="command_execution_delta"||F.type==="command_execution_completed"||F.type==="item_started")&&(k(J=>J||!0),C(d("Processing..."))),F.type==="auth_ok"){if(!Z){Z=!0,i.current=0,ye(),p(!0),f(d("Connected")),Ue(),Ke(),g(),m(),v();const J=r.current;if(J&&J.readyState===WebSocket.OPEN){const K=(T==null?void 0:T.current)||"main";J.send(JSON.stringify({type:"wake_up",worktreeId:K}))}}return}if(Z){if(F.type==="pong"&&(o.current=Date.now()),F.type==="status"&&(f(F.message),F.provider==="codex"&&y(!1)),F.type==="ready"&&(f(d("Ready")),y(!0)),F.type==="provider_status"&&F.provider==="codex"&&y(F.status==="ready"),Ie&&F.type==="assistant_delta"){if(typeof F.delta!="string")return;b(J=>{const K=[...J],re=K.findIndex(ae=>(ae==null?void 0:ae.id)===F.itemId);if(re===-1)return K.push({id:F.itemId,role:"assistant",text:F.delta}),K;const ie={...K[re]};return ie.text+=F.delta,K[re]=ie,K})}if(Ie&&F.type==="assistant_message"){if(typeof F.text!="string")return;const J=$(F.text);J&&P(J),j({id:F.itemId,text:F.text}),b(K=>{const re=[...K],ie=re.findIndex(ae=>(ae==null?void 0:ae.id)===F.itemId);return ie===-1?(re.push({id:F.itemId,role:"assistant",text:F.text}),re):(re[ie]={...re[ie],text:F.text},re)})}if(Ie&&F.type==="action_request"){if(!F.id)return;b(J=>{const K=[...J];return K.findIndex(ie=>(ie==null?void 0:ie.id)===F.id)===-1&&K.push({id:F.id,role:"user",type:"action_request",text:F.text||`/${F.request||"run"} ${F.arg||""}`.trim(),action:{request:F.request,arg:F.arg}}),K})}if(Ie&&F.type==="action_result"){if(!F.id)return;b(J=>{const K=[...J],re=K.findIndex(ae=>(ae==null?void 0:ae.id)===F.id),ie={id:F.id,role:"assistant",type:"action_result",text:F.text||"",action:{request:F.request,arg:F.arg,status:F.status,output:F.output}};return re===-1?K.push(ie):K[re]={...K[re],...ie},K}),(F.request==="run"||F.request==="git")&&(G(),typeof V=="function"&&V())}if(Ie&&F.type==="backlog_view"){if(!F.id)return;b(J=>{const K=[...J];return K.findIndex(ie=>(ie==null?void 0:ie.id)===F.id)===-1&&K.push({id:F.id,role:"assistant",type:"backlog_view",text:F.text||"Backlog",backlog:{items:Array.isArray(F.items)?F.items:[],page:Number.isFinite(F.page)?F.page:0}}),K})}if(Ie&&F.type==="command_execution_delta"){if(typeof F.delta!="string")return;b(J=>{const K=[...J],re=c.get(F.itemId);if(re===void 0){const ae={id:F.itemId,role:"commandExecution",command:d("Command"),output:F.delta,isExpandable:!0,status:"running"};return c.set(F.itemId,K.length),K.push(ae),K}const ie={...K[re]};return ie.output=`${ie.output||""}${F.delta}`,ie.isExpandable=!0,K[re]=ie,K})}if(Ie&&F.type==="command_execution_completed"){const J=F.item,K=F.itemId||(J==null?void 0:J.id);if(!K)return;b(re=>{var Ge;const ie=[...re],ae=c.get(K),oe=((Ge=J==null?void 0:J.commandActions)==null?void 0:Ge.command)||(J==null?void 0:J.command)||d("Command");if(ae===void 0){const We={id:K,role:"commandExecution",command:oe,output:(J==null?void 0:J.aggregatedOutput)||"",isExpandable:!0,status:"completed"};return c.set(K,ie.length),ie.push(We),ie}const ge={...ie[ae]};return ge.command=oe,ge.output=(J==null?void 0:J.aggregatedOutput)||ge.output||"",ge.isExpandable=!0,ge.status="completed",ie[ae]=ge,ie})}if(Ie&&F.type==="turn_error"&&(f(d("Error: {{message}}",{message:F.message})),A(null),P("")),Ie&&F.type==="agent_reasoning"){const J=Y(F.text);J&&P(J)}if(Ie&&F.type==="error"&&(f(F.message||d("Unexpected error")),O(!1),R(F.message||d("Unexpected error"))),Ae&&F.type==="error"&&I(J=>{const K=new Map(J),re=K.get(_e);return re?(K.set(_e,{...re,modelLoading:!1,modelError:F.message||d("Unexpected error")}),K):J}),Ie&&F.type==="turn_started"&&A(F.turnId||null),Ie&&F.type==="turn_completed"){const J=((St=F==null?void 0:F.turn)==null?void 0:St.error)||(F==null?void 0:F.error)||null;if((J==null?void 0:J.codexErrorInfo)==="usageLimitExceeded"){const re=`usage-limit-${F.turnId||((ce=F.turn)==null?void 0:ce.id)||Date.now()}`,ie=(typeof J=="string"?J:J==null?void 0:J.message)||d("Usage limit reached. Please try again later.");b(ae=>ae.some(oe=>oe.id===re)?ae:[...ae,{id:re,role:"assistant",text:`⚠️ ${ie}`}])}A(null),P(""),G()}if(Ie&&F.type==="repo_diff"&&Q({status:F.status||"",diff:F.diff||""}),Ie&&F.type==="model_list"){const J=Array.isArray(F.models)?F.models:[];M(J),F.provider&&z(re=>({...re,[F.provider]:{models:J,loading:!1,error:""}}));const K=J.find(re=>re.isDefault);K!=null&&K.model&&U(K.model),K!=null&&K.defaultReasoningEffort&&q(K.defaultReasoningEffort),O(!1),R("")}if(Ae&&F.type==="model_list"){const J=Array.isArray(F.models)?F.models:[];I(K=>{const re=new Map(K),ie=re.get(_e);if(!ie)return K;const ae=J.find(ge=>ge.isDefault),oe=ie.model||(ae==null?void 0:ae.model)||null;return re.set(_e,{...ie,models:J,model:oe,modelLoading:!1,modelError:""}),re})}if(Ie&&F.type==="model_set"&&(U(F.model||""),F.reasoningEffort!==void 0&&q(F.reasoningEffort||""),O(!1),R("")),Ae&&F.type==="model_set"&&I(J=>{const K=new Map(J),re=K.get(_e);return re?(K.set(_e,{...re,model:F.model||null,reasoningEffort:F.reasoningEffort??re.reasoningEffort??null,modelLoading:!1,modelError:""}),K):J}),Ie&&F.type==="rpc_log"){if(!h.current)return;F.entry&&H(J=>[...J,F.entry])}if(Ie&&F.type==="session_sync"){if(!(F!=null&&F.session))return;const J=F.session;b((J.messages||[]).map((K,re)=>({...K,id:(K==null?void 0:K.id)||`history-${re}`,attachments:N((K==null?void 0:K.attachments)||[]),toolResult:K==null?void 0:K.toolResult}))),Q(J.repoDiff||{status:"",diff:""}),J.provider&&z(K=>({...K,[J.provider]:{models:J.models||[],loading:!1,error:""}}))}if(Ie&&F.type==="worktrees_list"&&_(F.worktrees||[]),Ie&&F.type==="worktree_messages_sync"){if(F.worktreeId==="main"){u(F.messages||[]);return}I(J=>{const K=new Map(J),re=K.get(F.worktreeId);if(re){const ie=(F.messages||[]).map((ge,Ge)=>({...ge,id:(ge==null?void 0:ge.id)||`history-${Ge}`,attachments:N((ge==null?void 0:ge.attachments)||[]),toolResult:ge==null?void 0:ge.toolResult})),ae=new Set(re.messages.map(ge=>ge==null?void 0:ge.id).filter(Boolean)),oe=[...re.messages];ie.forEach(ge=>{ge!=null&&ge.id&&ae.has(ge.id)||(ge!=null&&ge.id&&ae.add(ge.id),oe.push(ge))}),K.set(F.worktreeId,{...re,messages:oe,status:F.status??re.status})}return K})}if(F.type==="worktree_diff"&&I(J=>{const K=new Map(J),re=K.get(F.worktreeId);return re&&K.set(F.worktreeId,{...re,diff:{status:F.status,diff:F.diff}}),K}),Ae&&(F.type==="assistant_delta"||F.type==="assistant_message"||F.type==="action_request"||F.type==="action_result"||F.type==="backlog_view"||F.type==="command_execution_delta"||F.type==="command_execution_completed"||F.type==="turn_started"||F.type==="turn_completed"||F.type==="turn_error")){const J=F.worktreeId;if((F.type==="assistant_delta"||F.type==="command_execution_delta"||F.type==="command_execution_completed"||F.type==="item_started")&&I(K=>{const re=new Map(K),ie=re.get(J);return ie&&ie.status==="ready"&&re.set(J,{...ie,status:"processing"}),re}),F.type==="turn_started"&&I(K=>{const re=new Map(K),ie=re.get(J);return ie&&re.set(J,{...ie,currentTurnId:F.turnId,activity:d("Processing...")}),re}),F.type==="action_request"){if(!F.id)return;I(K=>{const re=new Map(K),ie=re.get(J);return ie&&re.set(J,{...ie,messages:[...ie.messages,{id:F.id,role:"user",type:"action_request",text:F.text||`/${F.request||"run"} ${F.arg||""}`.trim(),action:{request:F.request,arg:F.arg}}]}),re})}if(F.type==="action_result"){if(!F.id)return;I(K=>{const re=new Map(K),ie=re.get(J)||{id:J,name:J,branchName:"",provider:"codex",status:"processing",messages:[],models:[],modelLoading:!1,modelError:"",activity:"",currentTurnId:null};return ie.messages.some(ae=>(ae==null?void 0:ae.id)===F.id)?K:(re.set(J,{...ie,messages:[...ie.messages,{id:F.id,role:"assistant",type:"action_result",text:F.text||"",action:{request:F.request,arg:F.arg,status:F.status,output:F.output}}]}),re)}),(F.request==="run"||F.request==="git")&&(X(J),typeof V=="function"&&J==="main"&&V())}if(F.type==="backlog_view"){if(!F.id)return;I(K=>{const re=new Map(K),ie=re.get(J);return ie&&re.set(J,{...ie,messages:[...ie.messages,{id:F.id,role:"assistant",type:"backlog_view",text:F.text||"Backlog",backlog:{items:Array.isArray(F.items)?F.items:[],page:Number.isFinite(F.page)?F.page:0}}]}),re})}if((F.type==="turn_completed"||F.type==="turn_error")&&I(K=>{const re=new Map(K),ie=re.get(J);return ie&&re.set(J,{...ie,currentTurnId:null,activity:"",taskLabel:""}),re}),F.type==="turn_completed"){const K=((he=F==null?void 0:F.turn)==null?void 0:he.error)||(F==null?void 0:F.error)||null;if((K==null?void 0:K.codexErrorInfo)==="usageLimitExceeded"){const ie=`usage-limit-${F.turnId||Date.now()}`,ae=(typeof K=="string"?K:K==null?void 0:K.message)||d("Usage limit reached. Please try again later.");I(oe=>{const ge=new Map(oe),Ge=ge.get(J);return!Ge||Ge.messages.some(We=>We.id===ie)?oe:(ge.set(J,{...Ge,messages:[...Ge.messages,{id:ie,role:"assistant",text:`⚠️ ${ae}`}]}),ge)})}X(J)}if((F.type==="assistant_delta"||F.type==="assistant_message")&&(I(K=>{const re=new Map(K),ie=re.get(J);if(!ie)return K;const ae=[...ie.messages],oe=ae.findIndex(ge=>ge.id===F.itemId);return F.type==="assistant_delta"?oe===-1?ae.push({id:F.itemId,role:"assistant",text:F.delta||""}):ae[oe]={...ae[oe],text:(ae[oe].text||"")+(F.delta||"")}:oe===-1?ae.push({id:F.itemId,role:"assistant",text:F.text||""}):ae[oe]={...ae[oe],text:F.text||""},re.set(J,{...ie,messages:ae}),re}),F.type==="assistant_message"&&typeof F.text=="string")){const K=$(F.text);K&&I(re=>{const ie=new Map(re),ae=ie.get(J);return ae?(ie.set(J,{...ae,taskLabel:K}),ie):re})}(F.type==="command_execution_delta"||F.type==="command_execution_completed")&&I(K=>{var Ge,We;const re=new Map(K),ie=re.get(J);if(!ie)return K;const ae=[...ie.messages],oe=F.itemId||((Ge=F.item)==null?void 0:Ge.id),ge=ae.findIndex(Je=>Je.id===oe);if(F.type==="command_execution_delta")ge===-1?ae.push({id:oe,role:"commandExecution",command:d("Command"),output:F.delta||"",status:"running",isExpandable:!0}):ae[ge]={...ae[ge],output:(ae[ge].output||"")+(F.delta||"")};else{const Je=F.item,xt=((We=Je==null?void 0:Je.commandActions)==null?void 0:We.command)||(Je==null?void 0:Je.command)||d("Command");ge===-1?ae.push({id:oe,role:"commandExecution",command:xt,output:(Je==null?void 0:Je.aggregatedOutput)||"",status:"completed",isExpandable:!0}):ae[ge]={...ae[ge],command:xt,output:(Je==null?void 0:Je.aggregatedOutput)||ae[ge].output||"",status:"completed"}}return re.set(J,{...ie,messages:ae}),re})}if(F.type==="agent_reasoning"&&Ae){const J=Y(F.text);J&&I(K=>{const re=new Map(K),ie=re.get(F.worktreeId);return ie?(re.set(F.worktreeId,{...ie,taskLabel:J}),re):K})}if(F.type==="item_started"&&Ae){const J=W(F.item);if(!J)return;const K=F.worktreeId;I(re=>{const ie=new Map(re),ae=ie.get(K);return ae&&ie.set(K,{...ae,activity:J}),ie})}if(F.type==="worktree_created"&&(I(J=>{const K=new Map(J);return K.set(F.worktreeId,{id:F.worktreeId,name:F.name,branchName:F.branchName,provider:F.provider,model:F.model||null,reasoningEffort:F.reasoningEffort||null,internetAccess:!!F.internetAccess,denyGitCredentialsAccess:typeof F.denyGitCredentialsAccess=="boolean"?F.denyGitCredentialsAccess:!0,status:F.status||"creating",color:F.color,models:[],modelLoading:!1,modelError:"",messages:[],activity:"",currentTurnId:null}),K}),L(J=>({...J,[F.worktreeId]:J[F.worktreeId]||"chat"})),B(J=>({...J,[F.worktreeId]:J[F.worktreeId]||"all"})),D(F.worktreeId)),F.type==="worktree_ready"&&I(J=>{const K=new Map(J),re=K.get(F.worktreeId);return re&&K.set(F.worktreeId,{...re,status:"ready"}),K}),F.type==="worktree_status"){if(F.worktreeId==="main"){if(!F.status)return;S==null||S(!0);const J=F.status;k(J==="processing"),C(J==="processing"?d("Processing..."):""),J!=="processing"&&P("");return}if(!F.status)return;I(J=>{const K=new Map(J),re=K.get(F.worktreeId);return re&&K.set(F.worktreeId,{...re,status:F.status,error:F.error||null,...F.status==="processing"?{}:{activity:"",taskLabel:"",currentTurnId:null}}),K})}F.type==="worktree_removed"&&(I(J=>{const K=new Map(J);return K.delete(F.worktreeId),K}),L(J=>{const K={...J};return delete K[F.worktreeId],K}),B(J=>{const K={...J};return delete K[F.worktreeId],K}),T.current===F.worktreeId&&D("main")),F.type==="worktree_renamed"&&I(J=>{const K=new Map(J),re=K.get(F.worktreeId);return re&&K.set(F.worktreeId,{...re,name:F.name}),K})}})};Ee();const je=()=>{if(document.hidden||!le)return;o.current=Date.now();const Ce=r.current;if(Ce&&Ce.readyState===WebSocket.OPEN){Ce.send(JSON.stringify({type:"ping"})),g(),m();const Z=(T==null?void 0:T.current)||"main";Ce.send(JSON.stringify({type:"wake_up",worktreeId:Z}))}else ye(),i.current=0,Ee()};return document.addEventListener("visibilitychange",je),()=>{le=!1,s.current=!0,ye(),Me(),document.removeEventListener("visibilitychange",je),r.current&&r.current.close(),Ne(),s.current=!1}},[e,t,l,c,u,m,v,w,_,g,d]),x.useEffect(()=>{if(!e||!ne||!ve)return;const le=r.current;!le||le.readyState!==WebSocket.OPEN||(le.send(JSON.stringify({type:"account_login_start",provider:"codex",params:ne})),ue(null))},[e,ve,ne,ue,r])}const Hl="workspaceToken",Wl="workspaceRefreshToken",Vl="workspaceId",xB="workspace-auth",io="workspaceRefreshLock",EB=15e3,AB=5e3,B1=1500,LB="mono_auth_token",Gf=()=>{try{return localStorage.getItem(Hl)||""}catch{return""}},F1=()=>{try{return localStorage.getItem(Wl)||""}catch{return""}},z1=()=>{try{return localStorage.getItem(Vl)||""}catch{return""}},PB=()=>{const e=String(window.location.hash||"");if(!e||!e.startsWith("#"))return"";const t=e.slice(1);return(new URLSearchParams(t).get("mono_auth")||"").trim()},TB=()=>({codex:{enabled:!1,authType:"api_key",authValue:"",previousAuthType:"api_key"},claude:{enabled:!1,authType:"api_key",authValue:"",previousAuthType:"api_key"}}),DB=()=>({codex:!1,claude:!1}),$1=()=>({codex:"",claude:""});function IB({t:e,encodeBase64:t,copyTextToClipboard:r,extractRepoName:n,setSessionMode:i,showToast:s,getProviderAuthType:a}){const[o,l]=x.useState(1),[c,h]=x.useState("existing"),[u,m]=x.useState(z1()),[v,w]=x.useState(""),[_,g]=x.useState(Gf()),[d,f]=x.useState(F1()),[p,y]=x.useState(z1()),[S,b]=x.useState(null),[k,C]=x.useState(""),[A,P]=x.useState(!1),[O,R]=x.useState([]),[M,z]=x.useState(!1),[U,q]=x.useState(""),[Q,H]=x.useState(null),[I,L]=x.useState({id:!1,secret:!1}),[B,D]=x.useState(!1),[T,$]=x.useState(1),[Y,W]=x.useState(DB),[j,N]=x.useState($1),[G,V]=x.useState(TB),[X,ne]=x.useState(null),ue=x.useRef(`tab-${Math.random().toString(36).slice(2)}-${Date.now()}`),ve=x.useRef(_),le=x.useRef(d),Se=x.useRef(null),ye=x.useRef(null),Me=x.useRef([]),Ne=x.useRef({id:null,secret:null}),Ue=x.useCallback(({token:ce="",refreshToken:he=""}={})=>{typeof ce=="string"&&(ve.current=ce,g(ce)),typeof he=="string"&&(le.current=he,f(he))},[]),Ke=x.useCallback(ce=>{Me.current.splice(0).forEach(J=>{try{J(ce||null)}catch{}})},[]),Ye=x.useCallback((ce=AB)=>new Promise(he=>{const J=setTimeout(()=>{const re=Me.current.indexOf(K);re>=0&&Me.current.splice(re,1),he(null)},ce),K=re=>{clearTimeout(J),he(re||null)};Me.current.push(K)}),[]),Ee=x.useCallback((ce,he={})=>{const J=ye.current;if(J)try{J.postMessage({type:ce,sourceTabId:ue.current,...he})}catch{}},[]),je=x.useCallback(()=>{const ce=Gf(),he=F1();return{token:ce||ve.current||"",refreshToken:he||le.current||""}},[]),Ce=x.useCallback(()=>{const ce=Date.now(),he={owner:ue.current,expiresAt:ce+EB};try{const J=localStorage.getItem(io);if(J){const ie=JSON.parse(J);if(ie&&typeof ie.expiresAt=="number"&&ie.expiresAt>ce&&ie.owner!==ue.current)return!1}localStorage.setItem(io,JSON.stringify(he));const K=localStorage.getItem(io);if(!K)return!1;const re=JSON.parse(K);return(re==null?void 0:re.owner)===ue.current}catch{return!0}},[]),Z=x.useCallback(()=>{try{const ce=localStorage.getItem(io);if(!ce)return;const he=JSON.parse(ce);(he==null?void 0:he.owner)===ue.current&&localStorage.removeItem(io)}catch{}},[]),se=x.useCallback(()=>{Ue({token:"",refreshToken:""}),y(""),m(""),w(""),b(null),C(""),h("existing"),R([]),q(""),z(!1),l(1),D(!1),i&&i("new"),Ee("workspace_left",{}),Ke(null)},[Ue,Ee,Ke,i]),we=x.useCallback(async()=>{const ce=le.current||je().refreshToken;if(!ce)return null;if(Se.current)return Se.current;const he=(async()=>{let J=!1;try{if(J=Ce(),!J){const Ge=await Ye();if(Ge)return Ge;const We=je();if(We.token&&We.token!==ve.current)return Ue({token:We.token,refreshToken:We.refreshToken||le.current}),We.token;if(J=Ce(),!J)return null}Ee("refresh_started",{at:Date.now()});const re=je().refreshToken||ce;if(!re)return null;const ie=await fetch("/api/v1/workspaces/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:re})});if(!ie.ok){const Ge=await Ye(B1);if(Ge)return Ge;const We=je();return We.token&&We.token!==ve.current?(Ue({token:We.token,refreshToken:We.refreshToken||le.current}),We.token):null}const ae=await ie.json(),oe=(ae==null?void 0:ae.workspaceToken)||"",ge=(ae==null?void 0:ae.refreshToken)||"";return oe&&ge?(Ue({token:oe,refreshToken:ge}),Ee("refresh_succeeded",{at:Date.now(),workspaceToken:oe,refreshToken:ge}),Ke(oe),oe):null}catch{const K=await Ye(B1);return K||null}finally{J&&Z(),Se.current=null}})();return Se.current=he,he},[Ce,Ue,Ee,je,Ke,Z,Ye]);x.useEffect(()=>{ve.current=_},[_]),x.useEffect(()=>{le.current=d},[d]),x.useEffect(()=>{if(typeof BroadcastChannel!="function")return;const ce=new BroadcastChannel(xB);ye.current=ce;const he=J=>{const K=J==null?void 0:J.data;!K||K.sourceTabId===ue.current||(K.type==="refresh_succeeded"?(Ue({token:K.workspaceToken||"",refreshToken:K.refreshToken||""}),Ke(K.workspaceToken||null)):K.type==="workspace_left"&&(Ue({token:"",refreshToken:""}),y("")))};return ce.addEventListener("message",he),()=>{ce.removeEventListener("message",he),ce.close(),ye.current=null}},[Ue,Ke]),x.useEffect(()=>{const ce=he=>{if(!(!he||!he.key)){if(he.key===Hl){const J=he.newValue||"";ve.current=J,g(J),J&&Ke(J);return}if(he.key===Wl){const J=he.newValue||"";le.current=J,f(J);return}he.key===Vl&&y(he.newValue||"")}};return window.addEventListener("storage",ce),()=>{window.removeEventListener("storage",ce)}},[Ke]);const F=x.useCallback(async(ce,he={})=>{const J=new Headers(he.headers||{}),K=ve.current||_;K&&J.set("Authorization",`Bearer ${K}`);const re=await fetch(ce,{...he,headers:J});if(re.status!==401)return re;const ie=await we();if(!ie){const oe=ve.current||Gf();if(oe&&oe!==K){const ge=new Headers(he.headers||{});return ge.set("Authorization",`Bearer ${oe}`),fetch(ce,{...he,headers:ge})}return se(),re}const ae=new Headers(he.headers||{});return ae.set("Authorization",`Bearer ${ie}`),fetch(ce,{...he,headers:ae})},[_,we,se]);x.useEffect(()=>{let ce=!1;return(async()=>{try{const J=await fetch("/api/v1/health");if(!J.ok)return;const K=await J.json();!ce&&(K!=null&&K.deploymentMode)&&ne(K.deploymentMode)}catch{}})(),()=>{ce=!0}},[]),x.useEffect(()=>{const ce=PB();if(!ce)return;let he=!1;return(async()=>{try{const K=await fetch("/api/v1/workspaces/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grantType:LB,monoAuthToken:ce})});if(!K.ok){const ie=await K.json().catch(()=>null),ae=(ie==null?void 0:ie.error)||e("Automatic mono-user authentication failed.");he||C(ae);return}const re=await K.json();if(!(re!=null&&re.workspaceToken))return;he||(g(re.workspaceToken||""),f(re.refreshToken||""),y("default"),m("default"),l(4),C(""))}catch{he||C(e("Automatic mono-user authentication failed."))}finally{const K=new URL(window.location.href);K.hash.includes("mono_auth=")&&(K.hash="",window.history.replaceState({},"",K))}})(),()=>{he=!0}},[_,e,y,m,f,l,g,C]),x.useEffect(()=>{try{_?localStorage.setItem(Hl,_):localStorage.removeItem(Hl)}catch{}},[_]),x.useEffect(()=>{try{d?localStorage.setItem(Wl,d):localStorage.removeItem(Wl)}catch{}},[d]),x.useEffect(()=>{try{p?localStorage.setItem(Vl,p):localStorage.removeItem(Vl)}catch{}},[p]),x.useEffect(()=>{if(!_){l(1);return}l(ce=>ce>=3?ce:4)},[_]);const _e=x.useCallback(async()=>{if(_){z(!0),q("");try{const ce=await F("/api/v1/sessions");if(!ce.ok){const K=await ce.json().catch(()=>null);throw new Error((K==null?void 0:K.error)||e("Unable to load sessions."))}const he=await ce.json(),J=Array.isArray(he==null?void 0:he.sessions)?he.sessions:[];R(J)}catch(ce){q(ce.message||e("Unable to load sessions."))}finally{z(!1)}}},[F,_,se,e]);x.useEffect(()=>{!_||o!==4||_e()},[o,_,_e]);const De=x.useCallback(async()=>{const ce=(p||u||"").trim();if(ce){P(!0),C("");try{const he=await F(`/api/v1/workspaces/${encodeURIComponent(ce)}`);if(!he.ok){const re=await he.json().catch(()=>null);throw new Error((re==null?void 0:re.error)||e("Unable to load providers."))}const J=await he.json(),K=(J==null?void 0:J.providers)||{};V(re=>{var ie,ae,oe,ge,Ge,We,Je,xt,xi,Xe;return{codex:{...re.codex,enabled:!!((ie=K==null?void 0:K.codex)!=null&&ie.enabled),authType:((oe=(ae=K==null?void 0:K.codex)==null?void 0:ae.auth)==null?void 0:oe.type)||"api_key",previousAuthType:((Ge=(ge=K==null?void 0:K.codex)==null?void 0:ge.auth)==null?void 0:Ge.type)||"api_key",authValue:""},claude:{...re.claude,enabled:!!((We=K==null?void 0:K.claude)!=null&&We.enabled),authType:((xt=(Je=K==null?void 0:K.claude)==null?void 0:Je.auth)==null?void 0:xt.type)||"api_key",previousAuthType:((Xe=(xi=K==null?void 0:K.claude)==null?void 0:xi.auth)==null?void 0:Xe.type)||"api_key",authValue:""}}}),W(re=>{var ie,ae;return{...re,codex:!!((ie=K==null?void 0:K.codex)!=null&&ie.enabled),claude:!!((ae=K==null?void 0:K.claude)!=null&&ae.enabled)}}),N($1())}catch(he){C(he.message||e("Unable to load providers."))}finally{P(!1)}}},[F,se,e,p,u]),ee=async ce=>{ce.preventDefault(),C(""),P(!0);try{if(c==="existing"){const he=u.trim(),J=v.trim();if(!he||!J)throw new Error(e("Workspace ID and secret are required."));const K=await F("/api/v1/workspaces/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:he,workspaceSecret:J})});if(!K.ok){const ie=await K.json().catch(()=>null);throw new Error((ie==null?void 0:ie.error)||e("Authentication failed."))}const re=await K.json();g(re.workspaceToken||""),f(re.refreshToken||""),y(he),l(4);return}D(!1),$(1),l(2)}catch(he){C(he.message||e("Workspace configuration failed."))}finally{P(!1)}},Ae=async ce=>{ce.preventDefault(),C(""),P(!0);try{const he={};if(["codex","claude"].forEach(ae=>{const oe=G[ae];if(!(oe!=null&&oe.enabled)){he[ae]={enabled:!1};return}const ge=(oe.authValue||"").trim(),Ge=a(ae,oe)||"api_key";if(B&&oe.previousAuthType&&Ge!==oe.previousAuthType&&!ge)throw new Error(e("Key required for {{provider}}.",{provider:ae}));if(!B&&!ge)throw new Error(e("Key required for {{provider}}.",{provider:ae}));if(ge){const We=Ge==="auth_json_b64"&&t?t(ge):ge;he[ae]={enabled:!0,auth:{type:Ge,value:We}}}else he[ae]={enabled:!0,auth:{type:Ge}}}),Object.keys(he).length===0)throw new Error(e("Select at least one provider."));if(B){const ae=(p||u||"").trim();if(!ae)throw new Error(e("Workspace ID required."));const oe=await F(`/api/v1/workspaces/${encodeURIComponent(ae)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providers:he})});if(!oe.ok){const ge=await oe.json().catch(()=>null);throw new Error((ge==null?void 0:ge.error)||e("Workspace update failed."))}await oe.json().catch(()=>null),D(!1),l(4),s==null||s(e("AI providers updated."),"success");return}const J=await F("/api/v1/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providers:he})});if(!J.ok){const ae=await J.json().catch(()=>null);throw new Error((ae==null?void 0:ae.error)||e("Workspace creation failed."))}const K=await J.json();b(K),y(K.workspaceId),m(K.workspaceId);const re=await F("/api/v1/workspaces/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:K.workspaceId,workspaceSecret:K.workspaceSecret})});if(!re.ok){const ae=await re.json().catch(()=>null);throw new Error((ae==null?void 0:ae.error)||e("Authentication failed."))}const ie=await re.json();g(ie.workspaceToken||""),f(ie.refreshToken||""),l(3)}catch(he){C(he.message||e("Workspace configuration failed."))}finally{P(!1)}},Ie=x.useCallback((ce,he)=>{if(!he)return;r&&r(he),L(K=>({...K,[ce]:!0}));const J=Ne.current;J[ce]&&clearTimeout(J[ce]),J[ce]=setTimeout(()=>{L(K=>({...K,[ce]:!1})),J[ce]=null},2e3)},[]);return x.useEffect(()=>()=>{Object.values(Ne.current||{}).forEach(ce=>{ce&&clearTimeout(ce)})},[]),{apiFetch:F,deploymentMode:X,handleDeleteSession:async ce=>{const he=ce==null?void 0:ce.sessionId;if(!he)return;const J=n==null?void 0:n((ce==null?void 0:ce.repoUrl)||""),K=(ce==null?void 0:ce.name)||J||he;if(window.confirm(e('Supprimer la session "{{title}}" ? Cette action est irreversible.',{title:K})))try{H(he),q("");const ie=await F(`/api/v1/sessions/${encodeURIComponent(he)}`,{method:"DELETE"});if(!ie.ok){let ae="";try{const ge=await ie.json();typeof(ge==null?void 0:ge.error)=="string"&&(ae=ge.error)}catch{}const oe=ae?`: ${ae}`:"";throw new Error(e("Unable to delete the session{{suffix}}.",{suffix:oe}))}await _e(),s==null||s(e('Session "{{title}}" supprimee.',{title:K}),"success")}catch(ie){q(ie.message||e("Unable to delete the session."))}finally{H(null)}},handleLeaveWorkspace:se,handleWorkspaceCopy:Ie,handleWorkspaceProvidersSubmit:Ae,handleWorkspaceSubmit:ee,loadWorkspaceProviders:De,loadWorkspaceSessions:_e,providersBackStep:T,refreshWorkspaceToken:we,setProvidersBackStep:$,setWorkspaceAuthExpanded:W,setWorkspaceAuthFiles:N,setWorkspaceError:C,setWorkspaceId:y,setWorkspaceIdInput:m,setWorkspaceMode:h,setWorkspaceProviders:V,setWorkspaceProvidersEditing:D,setWorkspaceRefreshToken:f,setWorkspaceSecretInput:w,setWorkspaceStep:l,setWorkspaceToken:g,workspaceAuthExpanded:Y,workspaceAuthFiles:j,workspaceBusy:A,workspaceCopied:I,workspaceCreated:S,workspaceError:k,workspaceId:p,workspaceIdInput:u,workspaceMode:c,workspaceProviders:G,workspaceProvidersEditing:B,workspaceSecretInput:v,workspaceSessionDeletingId:Q,workspaceSessions:O,workspaceSessionsError:U,workspaceSessionsLoading:M,workspaceStep:o,workspaceToken:_}}function NB({apiFetch:e,attachmentSessionId:t,availableProviders:r,llmProvider:n,messagesRef:i,normalizeAttachments:s,applyMessages:a,socketRef:o,setPaneByTab:l,setLogFilterByTab:c,showToast:h,t:u}){const[m,v]=x.useState(new Map),w=x.useRef(new Map),[_,g]=x.useState("main"),d=x.useRef("main");x.useEffect(()=>{w.current=m},[m]),x.useEffect(()=>{d.current=_},[_]);const f=x.useCallback(R=>{var M;if(!Array.isArray(R))return null;for(let z=R.length-1;z>=0;z-=1)if((M=R[z])!=null&&M.id)return R[z].id;return null},[]),p=x.useCallback(async()=>{if(t)try{const R=await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees/main/messages`);if(!R.ok)return;const M=await R.json().catch(()=>({}));if(Array.isArray(M==null?void 0:M.messages)){const z=M.messages.map((U,q)=>({...U,id:(U==null?void 0:U.id)||`history-${q}`,attachments:s((U==null?void 0:U.attachments)||[]),toolResult:U==null?void 0:U.toolResult}));a(z)}}catch{}},[t,e,a,s]),y=x.useCallback(async R=>{if(!(!t||!R)){if(R==="main"){await p();return}try{const M=await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees/${encodeURIComponent(R)}`);if(!M.ok)return;const z=await M.json().catch(()=>({})),U=await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees/${encodeURIComponent(R)}/messages`);if(!U.ok)return;const q=await U.json().catch(()=>({}));if(!Array.isArray(q==null?void 0:q.messages))return;const Q=q.messages.map((H,I)=>({...H,id:(H==null?void 0:H.id)||`history-${I}`,attachments:s((H==null?void 0:H.attachments)||[]),toolResult:H==null?void 0:H.toolResult}));v(H=>{const I=new Map(H),L=I.get(R);return L&&I.set(R,{...L,messages:Q,status:z.status||L.status}),I})}catch{}}},[t,e,p,s]),S=x.useCallback(R=>{var q;const M=o==null?void 0:o.current;if(!M||M.readyState!==WebSocket.OPEN||!R)return;const z=w.current,U=f(R==="main"?i.current:(q=z.get(R))==null?void 0:q.messages);M.send(JSON.stringify({type:"worktree_messages_sync",worktreeId:R,lastSeenMessageId:U}))},[f,i,o]),b=x.useCallback(R=>{if(!Array.isArray(R))return;const M=new Map;R.forEach(z=>{M.set(z.id,{...z,status:(z==null?void 0:z.status)||"processing",messages:[],models:[],modelLoading:!1,modelError:"",activity:"",currentTurnId:null})}),v(M),l(z=>{const U={...z};return R.forEach(q=>{U[q.id]||(U[q.id]="chat")}),U}),c(z=>{const U={...z};return R.forEach(q=>{U[q.id]||(U[q.id]="all")}),U}),d.current!=="main"&&!R.some(z=>z.id===d.current)&&g("main")},[c,l]),k=x.useCallback(async()=>{if(t)try{const R=await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees`);if(!R.ok)return;const M=await R.json();b(M==null?void 0:M.worktrees)}catch{}},[t,e,b]),C=x.useCallback(R=>{if(!R)return;g(R);const M=o==null?void 0:o.current;M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"wake_up",worktreeId:R})),y(R)},[y,o]),A=x.useCallback(async({context:R,name:M,provider:z,sourceWorktree:U,startingBranch:q,model:Q,reasoningEffort:H,internetAccess:I,denyGitCredentialsAccess:L})=>{if(!t){h==null||h(u("Session not found."),"error");return}try{const B=await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:R==="fork"?"fork":"new",provider:R==="new"?r.includes(z)?z:n:void 0,sourceWorktree:R==="fork"?U||null:void 0,name:M||null,startingBranch:q||null,model:R==="new"?Q||null:void 0,reasoningEffort:R==="new"?H??null:void 0,internetAccess:!!I,denyGitCredentialsAccess:!!L})});if(!B.ok){const T=await B.json().catch(()=>null);throw new Error((T==null?void 0:T.error)||u("Failed to create parallel request."))}const D=await B.json();v(T=>{const $=new Map(T);return $.set(D.worktreeId,{id:D.worktreeId,name:D.name,branchName:D.branchName,provider:D.provider,model:D.model||null,reasoningEffort:D.reasoningEffort||null,context:D.context||"new",sourceWorktreeId:D.sourceWorktreeId||null,internetAccess:!!D.internetAccess,denyGitCredentialsAccess:!!D.denyGitCredentialsAccess,status:D.status||"creating",color:D.color,messages:[],activity:"",currentTurnId:null}),$}),l(T=>({...T,[D.worktreeId]:T[D.worktreeId]||"chat"})),c(T=>({...T,[D.worktreeId]:T[D.worktreeId]||"all"})),g(D.worktreeId),k()}catch(B){h==null||h(B.message||u("Failed to create parallel request."),"error")}},[e,t,r,n,k,c,l,h,u]),P=x.useCallback(async R=>{if(t)try{(await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees/${encodeURIComponent(R)}`,{method:"DELETE"})).ok||console.error("Failed to close worktree")}catch(M){console.error("Error closing worktree:",M)}},[t,e]),O=x.useCallback(async(R,M)=>{if(t)try{(await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees/${encodeURIComponent(R)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:M})})).ok||console.error("Failed to rename worktree")}catch(z){console.error("Error renaming worktree:",z)}},[t,e]);return{activeWorktreeId:_,activeWorktreeIdRef:d,applyWorktreesList:b,closeWorktree:P,createWorktree:A,handleSelectWorktree:C,loadMainWorktreeSnapshot:p,loadWorktreeSnapshot:y,requestWorktreeMessages:S,requestWorktreesList:k,renameWorktreeHandler:O,setActiveWorktreeId:g,setWorktrees:v,worktrees:m}}var EC={exports:{}};(function(e,t){(function(r,n){e.exports=n()})(globalThis,()=>(()=>{var r={4567:function(a,o,l){var c=this&&this.__decorate||function(f,p,y,S){var b,k=arguments.length,C=k<3?p:S===null?S=Object.getOwnPropertyDescriptor(p,y):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(f,p,y,S);else for(var A=f.length-1;A>=0;A--)(b=f[A])&&(C=(k<3?b(C):k>3?b(p,y,C):b(p,y))||C);return k>3&&C&&Object.defineProperty(p,y,C),C},h=this&&this.__param||function(f,p){return function(y,S){p(y,S,f)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const u=l(9042),m=l(9924),v=l(844),w=l(4725),_=l(2585),g=l(3656);let d=o.AccessibilityManager=class extends v.Disposable{constructor(f,p,y,S){super(),this._terminal=f,this._coreBrowserService=y,this._renderService=S,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let b=0;b<this._terminal.rows;b++)this._rowElements[b]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[b]);if(this._topBoundaryFocusListener=b=>this._handleBoundaryFocus(b,0),this._bottomBoundaryFocusListener=b=>this._handleBoundaryFocus(b,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new m.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize(b=>this._handleResize(b.rows))),this.register(this._terminal.onRender(b=>this._refreshRows(b.start,b.end))),this.register(this._terminal.onScroll(()=>this._refreshRows())),this.register(this._terminal.onA11yChar(b=>this._handleChar(b))),this.register(this._terminal.onLineFeed(()=>this._handleChar(`
691
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return x.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},K7="DialogDescriptionWarning",G7=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${mC(K7).contentName}}.`;return x.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},q7=sC,Y7=lC,J7=cC,X7=uC,Q7=Symbol.for("react.lazy"),Ac=Nd[" use ".trim().toString()];function Z7(e){return typeof e=="object"&&e!==null&&"then"in e}function gC(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Q7&&"_payload"in e&&Z7(e._payload)}function eB(e){const t=tB(e),r=x.forwardRef((n,i)=>{let{children:s,...a}=n;gC(s)&&typeof Ac=="function"&&(s=Ac(s._payload));const o=x.Children.toArray(s),l=o.find(nB);if(l){const c=l.props.children,h=o.map(u=>u===l?x.Children.count(c)>1?x.Children.only(null):x.isValidElement(c)?c.props.children:null:u);return E.jsx(t,{...a,ref:i,children:x.isValidElement(c)?x.cloneElement(c,void 0,h):null})}return E.jsx(t,{...a,ref:i,children:s})});return r.displayName=`${e}.Slot`,r}function tB(e){const t=x.forwardRef((r,n)=>{let{children:i,...s}=r;if(gC(i)&&typeof Ac=="function"&&(i=Ac(i._payload)),x.isValidElement(i)){const a=sB(i),o=iB(s,i.props);return i.type!==x.Fragment&&(o.ref=n?Un(n,a):a),x.cloneElement(i,o)}return x.Children.count(i)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rB=Symbol("radix.slottable");function nB(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rB}function iB(e,t){const r={...t};for(const n in t){const i=e[n],s=t[n];/^on[A-Z]/.test(n)?i&&s?r[n]=(...o)=>{const l=s(...o);return i(...o),l}:i&&(r[n]=i):n==="style"?r[n]={...i,...s}:n==="className"&&(r[n]=[i,s].filter(Boolean).join(" "))}return{...e,...r}}function sB(e){var n,i;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var oB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],qn=oB.reduce((e,t)=>{const r=eB(`Primitive.${t}`),n=x.forwardRef((i,s)=>{const{asChild:a,...o}=i,l=a?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),E.jsx(l,{...o,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),no='[cmdk-group=""]',Kf='[cmdk-group-items=""]',aB='[cmdk-group-heading=""]',vC='[cmdk-item=""]',j1=`${vC}:not([aria-disabled="true"])`,Ld="cmdk-item-select",zi="data-value",lB=(e,t,r)=>aj(e,t,r),_C=x.createContext(void 0),va=()=>x.useContext(_C),yC=x.createContext(void 0),gm=()=>x.useContext(yC),wC=x.createContext(void 0),bC=x.forwardRef((e,t)=>{let r=$i(()=>{var D,T;return{search:"",value:(T=(D=e.value)!=null?D:e.defaultValue)!=null?T:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=$i(()=>new Set),i=$i(()=>new Map),s=$i(()=>new Map),a=$i(()=>new Set),o=kC(e),{label:l,children:c,value:h,onValueChange:u,filter:m,shouldFilter:v,loop:w,disablePointerSelection:_=!1,vimBindings:g=!0,...d}=e,f=Zr(),p=Zr(),y=Zr(),S=x.useRef(null),b=_B();vi(()=>{if(h!==void 0){let D=h.trim();r.current.value=D,k.emit()}},[h]),vi(()=>{b(6,M)},[]);let k=x.useMemo(()=>({subscribe:D=>(a.current.add(D),()=>a.current.delete(D)),snapshot:()=>r.current,setState:(D,T,$)=>{var Y,W,j,N;if(!Object.is(r.current[D],T)){if(r.current[D]=T,D==="search")R(),P(),b(1,O);else if(D==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let G=document.getElementById(y);G?G.focus():(Y=document.getElementById(f))==null||Y.focus()}if(b(7,()=>{var G;r.current.selectedItemId=(G=z())==null?void 0:G.id,k.emit()}),$||b(5,M),((W=o.current)==null?void 0:W.value)!==void 0){let G=T??"";(N=(j=o.current).onValueChange)==null||N.call(j,G);return}}k.emit()}},emit:()=>{a.current.forEach(D=>D())}}),[]),C=x.useMemo(()=>({value:(D,T,$)=>{var Y;T!==((Y=s.current.get(D))==null?void 0:Y.value)&&(s.current.set(D,{value:T,keywords:$}),r.current.filtered.items.set(D,A(T,$)),b(2,()=>{P(),k.emit()}))},item:(D,T)=>(n.current.add(D),T&&(i.current.has(T)?i.current.get(T).add(D):i.current.set(T,new Set([D]))),b(3,()=>{R(),P(),r.current.value||O(),k.emit()}),()=>{s.current.delete(D),n.current.delete(D),r.current.filtered.items.delete(D);let $=z();b(4,()=>{R(),($==null?void 0:$.getAttribute("id"))===D&&O(),k.emit()})}),group:D=>(i.current.has(D)||i.current.set(D,new Set),()=>{s.current.delete(D),i.current.delete(D)}),filter:()=>o.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>o.current.disablePointerSelection,listId:f,inputId:y,labelId:p,listInnerRef:S}),[]);function A(D,T){var $,Y;let W=(Y=($=o.current)==null?void 0:$.filter)!=null?Y:lB;return D?W(D,r.current.search,T):0}function P(){if(!r.current.search||o.current.shouldFilter===!1)return;let D=r.current.filtered.items,T=[];r.current.filtered.groups.forEach(Y=>{let W=i.current.get(Y),j=0;W.forEach(N=>{let G=D.get(N);j=Math.max(G,j)}),T.push([Y,j])});let $=S.current;U().sort((Y,W)=>{var j,N;let G=Y.getAttribute("id"),V=W.getAttribute("id");return((j=D.get(V))!=null?j:0)-((N=D.get(G))!=null?N:0)}).forEach(Y=>{let W=Y.closest(Kf);W?W.appendChild(Y.parentElement===W?Y:Y.closest(`${Kf} > *`)):$.appendChild(Y.parentElement===$?Y:Y.closest(`${Kf} > *`))}),T.sort((Y,W)=>W[1]-Y[1]).forEach(Y=>{var W;let j=(W=S.current)==null?void 0:W.querySelector(`${no}[${zi}="${encodeURIComponent(Y[0])}"]`);j==null||j.parentElement.appendChild(j)})}function O(){let D=U().find($=>$.getAttribute("aria-disabled")!=="true"),T=D==null?void 0:D.getAttribute(zi);k.setState("value",T||void 0)}function R(){var D,T,$,Y;if(!r.current.search||o.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let W=0;for(let j of n.current){let N=(T=(D=s.current.get(j))==null?void 0:D.value)!=null?T:"",G=(Y=($=s.current.get(j))==null?void 0:$.keywords)!=null?Y:[],V=A(N,G);r.current.filtered.items.set(j,V),V>0&&W++}for(let[j,N]of i.current)for(let G of N)if(r.current.filtered.items.get(G)>0){r.current.filtered.groups.add(j);break}r.current.filtered.count=W}function M(){var D,T,$;let Y=z();Y&&(((D=Y.parentElement)==null?void 0:D.firstChild)===Y&&(($=(T=Y.closest(no))==null?void 0:T.querySelector(aB))==null||$.scrollIntoView({block:"nearest"})),Y.scrollIntoView({block:"nearest"}))}function z(){var D;return(D=S.current)==null?void 0:D.querySelector(`${vC}[aria-selected="true"]`)}function U(){var D;return Array.from(((D=S.current)==null?void 0:D.querySelectorAll(j1))||[])}function q(D){let T=U()[D];T&&k.setState("value",T.getAttribute(zi))}function Q(D){var T;let $=z(),Y=U(),W=Y.findIndex(N=>N===$),j=Y[W+D];(T=o.current)!=null&&T.loop&&(j=W+D<0?Y[Y.length-1]:W+D===Y.length?Y[0]:Y[W+D]),j&&k.setState("value",j.getAttribute(zi))}function H(D){let T=z(),$=T==null?void 0:T.closest(no),Y;for(;$&&!Y;)$=D>0?gB($,no):vB($,no),Y=$==null?void 0:$.querySelector(j1);Y?k.setState("value",Y.getAttribute(zi)):Q(D)}let I=()=>q(U().length-1),L=D=>{D.preventDefault(),D.metaKey?I():D.altKey?H(1):Q(1)},B=D=>{D.preventDefault(),D.metaKey?q(0):D.altKey?H(-1):Q(-1)};return x.createElement(qn.div,{ref:t,tabIndex:-1,...d,"cmdk-root":"",onKeyDown:D=>{var T;(T=d.onKeyDown)==null||T.call(d,D);let $=D.nativeEvent.isComposing||D.keyCode===229;if(!(D.defaultPrevented||$))switch(D.key){case"n":case"j":{g&&D.ctrlKey&&L(D);break}case"ArrowDown":{L(D);break}case"p":case"k":{g&&D.ctrlKey&&B(D);break}case"ArrowUp":{B(D);break}case"Home":{D.preventDefault(),q(0);break}case"End":{D.preventDefault(),I();break}case"Enter":{D.preventDefault();let Y=z();if(Y){let W=new Event(Ld);Y.dispatchEvent(W)}}}}},x.createElement("label",{"cmdk-label":"",htmlFor:C.inputId,id:C.labelId,style:wB},l),fu(e,D=>x.createElement(yC.Provider,{value:k},x.createElement(_C.Provider,{value:C},D))))}),SC=x.forwardRef((e,t)=>{var r,n;let i=Zr(),s=x.useRef(null),a=x.useContext(wC),o=va(),l=kC(e),c=(n=(r=l.current)==null?void 0:r.forceMount)!=null?n:a==null?void 0:a.forceMount;vi(()=>{if(!c)return o.item(i,a==null?void 0:a.id)},[c]);let h=xC(i,s,[e.value,e.children,s],e.keywords),u=gm(),m=Hn(b=>b.value&&b.value===h.current),v=Hn(b=>c||o.filter()===!1?!0:b.search?b.filtered.items.get(i)>0:!0);x.useEffect(()=>{let b=s.current;if(!(!b||e.disabled))return b.addEventListener(Ld,w),()=>b.removeEventListener(Ld,w)},[v,e.onSelect,e.disabled]);function w(){var b,k;_(),(k=(b=l.current).onSelect)==null||k.call(b,h.current)}function _(){u.setState("value",h.current,!0)}if(!v)return null;let{disabled:g,value:d,onSelect:f,forceMount:p,keywords:y,...S}=e;return x.createElement(qn.div,{ref:Un(s,t),...S,id:i,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!m,"data-disabled":!!g,"data-selected":!!m,onPointerMove:g||o.getDisablePointerSelection()?void 0:_,onClick:g?void 0:w},e.children)}),cB=x.forwardRef((e,t)=>{let{heading:r,children:n,forceMount:i,...s}=e,a=Zr(),o=x.useRef(null),l=x.useRef(null),c=Zr(),h=va(),u=Hn(v=>i||h.filter()===!1?!0:v.search?v.filtered.groups.has(a):!0);vi(()=>h.group(a),[]),xC(a,o,[e.value,e.heading,l]);let m=x.useMemo(()=>({id:a,forceMount:i}),[i]);return x.createElement(qn.div,{ref:Un(o,t),...s,"cmdk-group":"",role:"presentation",hidden:u?void 0:!0},r&&x.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},r),fu(e,v=>x.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?c:void 0},x.createElement(wC.Provider,{value:m},v))))}),uB=x.forwardRef((e,t)=>{let{alwaysRender:r,...n}=e,i=x.useRef(null),s=Hn(a=>!a.search);return!r&&!s?null:x.createElement(qn.div,{ref:Un(i,t),...n,"cmdk-separator":"",role:"separator"})}),fB=x.forwardRef((e,t)=>{let{onValueChange:r,...n}=e,i=e.value!=null,s=gm(),a=Hn(c=>c.search),o=Hn(c=>c.selectedItemId),l=va();return x.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),x.createElement(qn.input,{ref:t,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":o,id:l.inputId,type:"text",value:i?e.value:a,onChange:c=>{i||s.setState("search",c.target.value),r==null||r(c.target.value)}})}),CC=x.forwardRef((e,t)=>{let{children:r,label:n="Suggestions",...i}=e,s=x.useRef(null),a=x.useRef(null),o=Hn(c=>c.selectedItemId),l=va();return x.useEffect(()=>{if(a.current&&s.current){let c=a.current,h=s.current,u,m=new ResizeObserver(()=>{u=requestAnimationFrame(()=>{let v=c.offsetHeight;h.style.setProperty("--cmdk-list-height",v.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(u),m.unobserve(c)}}},[]),x.createElement(qn.div,{ref:Un(s,t),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":o,"aria-label":n,id:l.listId},fu(e,c=>x.createElement("div",{ref:Un(a,l.listInnerRef),"cmdk-list-sizer":""},c)))}),hB=x.forwardRef((e,t)=>{let{open:r,onOpenChange:n,overlayClassName:i,contentClassName:s,container:a,...o}=e;return x.createElement(q7,{open:r,onOpenChange:n},x.createElement(Y7,{container:a},x.createElement(J7,{"cmdk-overlay":"",className:i}),x.createElement(X7,{"aria-label":e.label,"cmdk-dialog":"",className:s},x.createElement(bC,{ref:t,...o}))))}),dB=x.forwardRef((e,t)=>Hn(r=>r.filtered.count===0)?x.createElement(qn.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),pB=x.forwardRef((e,t)=>{let{progress:r,children:n,label:i="Loading...",...s}=e;return x.createElement(qn.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},fu(e,a=>x.createElement("div",{"aria-hidden":!0},a)))}),mB=Object.assign(bC,{List:CC,Item:SC,Input:fB,Group:cB,Separator:uB,Dialog:hB,Empty:dB,Loading:pB});function gB(e,t){let r=e.nextElementSibling;for(;r;){if(r.matches(t))return r;r=r.nextElementSibling}}function vB(e,t){let r=e.previousElementSibling;for(;r;){if(r.matches(t))return r;r=r.previousElementSibling}}function kC(e){let t=x.useRef(e);return vi(()=>{t.current=e}),t}var vi=typeof window>"u"?x.useEffect:x.useLayoutEffect;function $i(e){let t=x.useRef();return t.current===void 0&&(t.current=e()),t}function Hn(e){let t=gm(),r=()=>e(t.snapshot());return x.useSyncExternalStore(t.subscribe,r,r)}function xC(e,t,r,n=[]){let i=x.useRef(),s=va();return vi(()=>{var a;let o=(()=>{var c;for(let h of r){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(c=h.current.textContent)==null?void 0:c.trim():i.current}})(),l=n.map(c=>c.trim());s.value(e,o,l),(a=t.current)==null||a.setAttribute(zi,o),i.current=o}),i}var _B=()=>{let[e,t]=x.useState(),r=$i(()=>new Map);return vi(()=>{r.current.forEach(n=>n()),r.current=new Map},[e]),(n,i)=>{r.current.set(n,i),t({})}};function yB(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function fu({asChild:e,children:t},r){return e&&x.isValidElement(t)?x.cloneElement(yB(t),{ref:t.ref},r(t.props.children)):r(t)}var wB={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function bB({t:e,activePane:t,isDraggingAttachments:r,onSubmit:n,onDragEnterComposer:i,onDragOverComposer:s,onDragLeaveComposer:a,onDropAttachments:o,composerRef:l,draftAttachments:c,getAttachmentExtension:h,formatAttachmentSize:u,removeDraftAttachment:m,commandMenuOpen:v,filteredCommands:w,setInput:_,setCommandMenuOpen:g,setCommandQuery:d,inputRef:f,commandSelection:p,triggerAttachmentPicker:y,attachmentSession:S,attachmentsLoading:b,isMobileLayout:k,uploadInputRef:C,onUploadAttachments:A,input:P,handleInputChange:O,handleComposerKeyDown:R,onPasteAttachments:M,canInterrupt:z,interruptTurn:U,connected:q,modelSelectorVisible:Q,modelOptions:H,selectedModel:I,modelLoading:L,modelDisabled:B,modelError:D,onModelChange:T,isCodexReady:$,interactionBlocked:Y,attachmentsError:W}){return t!=="chat"?null:E.jsx("form",{className:`composer composer--sticky ${r?"is-dragging":""}`,onSubmit:n,onDragEnter:i,onDragOver:s,onDragLeave:a,onDrop:o,ref:l,children:E.jsxs("div",{className:"composer-inner",children:[c.length?E.jsx("div",{className:"composer-attachments","aria-label":e("Selected attachments"),children:c.map(j=>{const N=(j==null?void 0:j.name)||(j==null?void 0:j.path)||"",G=(j==null?void 0:j.path)||(j==null?void 0:j.name)||N,V=h(j,e),X=j!=null&&j.lineCount||j!=null&&j.lines?e("{{count}} lines",{count:j.lineCount||j.lines}):u(j==null?void 0:j.size,e);return E.jsxs("div",{className:"attachment-card",children:[E.jsxs("div",{className:"attachment-card-body",children:[E.jsx("div",{className:"attachment-card-title",children:N}),X?E.jsx("div",{className:"attachment-card-meta",children:X}):null]}),E.jsxs("div",{className:"attachment-card-footer",children:[E.jsx("span",{className:"attachment-card-type",children:V}),E.jsx("button",{type:"button",className:"attachment-card-remove","aria-label":e("Remove {{label}}",{label:N}),onClick:()=>m((j==null?void 0:j.path)||(j==null?void 0:j.name)),children:E.jsx(Be,{icon:si})})]})]},G)})}):null,v&&E.jsx("div",{className:"composer-command-menu",children:E.jsx(mB,{className:"command-menu",shouldFilter:!1,children:E.jsx(CC,{children:w.length?w.map(j=>E.jsxs(SC,{onSelect:()=>{var N;_(j.insert),g(!1),d(""),(N=f.current)==null||N.focus()},className:`command-item${j.id===p?" is-selected":""}`,children:[E.jsx("span",{className:"command-item-label",children:j.label}),E.jsx("span",{className:"command-item-desc",children:j.description})]},j.id)):E.jsx("div",{className:"command-empty",children:e("No commands found.")})})})}),E.jsxs("div",{className:"composer-main",children:[E.jsxs("button",{type:"button",className:"icon-button composer-attach-button","aria-label":e("Add attachment"),onClick:y,disabled:!S||b,children:["+",k?E.jsx("span",{className:"attachment-badge",children:c.length}):null]}),E.jsx("input",{ref:C,type:"file",multiple:!0,onChange:A,disabled:!S||b,className:"visually-hidden"}),E.jsx("textarea",{className:"composer-input",value:P,onChange:O,onKeyDown:R,onPaste:M,placeholder:e("Write your message…"),rows:1,ref:f}),Q?E.jsxs("select",{className:"composer-model-select",value:I||"",onChange:j=>T==null?void 0:T(j.target.value),disabled:B,"aria-label":e("Model"),title:D||e("Model"),children:[L?E.jsx("option",{value:"",children:e("Loading...")}):null,E.jsx("option",{value:"",children:e("Default model")}),(Array.isArray(H)?H:[]).map(j=>E.jsx("option",{value:j.model||"",children:j.displayName||j.model||""},j.id||j.model))]}):null,z?E.jsx("button",{type:"button",className:"primary stop-button",onClick:U,"aria-label":e("Stop"),title:e("Stop"),children:E.jsx("span",{className:"stop-icon",children:"⏹"})}):E.jsx("button",{type:"submit",className:"primary send-button",disabled:!q||!P.trim()||!$||Y,"aria-label":e("Send"),title:e("Send"),children:E.jsx("span",{className:"send-icon",children:"➤"})})]}),W&&E.jsx("div",{className:"attachments-error composer-attachments-error",children:W})]})})}function SB({t:e,activePane:t,handleViewSelect:r,handleDiffSelect:n,terminalEnabled:i,hasMessages:s,handleClearChat:a}){return t==="settings"?null:E.jsxs("div",{className:"chat-toolbar",role:"toolbar","aria-label":e("Chat tools"),children:[E.jsxs("div",{className:"chat-toolbar-group",children:[E.jsxs("button",{type:"button",className:`chat-toolbar-button ${t==="chat"?"is-active":""}`,onClick:()=>r("chat"),"aria-pressed":t==="chat","aria-label":e("Messages"),title:e("Messages"),children:[E.jsx("span",{className:"chat-toolbar-icon-wrap","aria-hidden":"true",children:E.jsx("span",{className:"chat-toolbar-icon",children:E.jsx(Be,{icon:ZD})})}),E.jsx("span",{className:"chat-toolbar-label",children:e("Messages")})]}),E.jsxs("button",{type:"button",className:`chat-toolbar-button ${t==="diff"?"is-active":""}`,onClick:n,"aria-pressed":t==="diff","aria-label":e("Diff"),title:e("Diff"),children:[E.jsx("span",{className:"chat-toolbar-icon-wrap","aria-hidden":"true",children:E.jsx("span",{className:"chat-toolbar-icon",children:E.jsx(Be,{icon:o6})})}),E.jsx("span",{className:"chat-toolbar-label",children:e("Diff")})]}),E.jsxs("button",{type:"button",className:`chat-toolbar-button ${t==="explorer"?"is-active":""}`,onClick:()=>r("explorer"),"aria-pressed":t==="explorer","aria-label":e("Explorer"),title:e("Explorer"),children:[E.jsx("span",{className:"chat-toolbar-icon-wrap","aria-hidden":"true",children:E.jsx("span",{className:"chat-toolbar-icon",children:E.jsx(Be,{icon:i6})})}),E.jsx("span",{className:"chat-toolbar-label",children:e("Explorer")})]}),E.jsxs("button",{type:"button",className:`chat-toolbar-button ${t==="terminal"?"is-active":""}`,onClick:()=>r("terminal"),"aria-pressed":t==="terminal","aria-label":e("Terminal"),title:e("Terminal"),disabled:!i,children:[E.jsx("span",{className:"chat-toolbar-icon-wrap","aria-hidden":"true",children:E.jsx("span",{className:"chat-toolbar-icon",children:E.jsx(Be,{icon:XD})})}),E.jsx("span",{className:"chat-toolbar-label",children:e("Terminal")})]})]}),E.jsx("div",{className:"chat-toolbar-divider"}),E.jsx("div",{className:"chat-toolbar-group",children:E.jsxs("button",{type:"button",className:"chat-toolbar-button is-danger",onClick:()=>a(),"aria-label":e("Clear"),title:e("Clear"),disabled:!s,children:[E.jsx("span",{className:"chat-toolbar-icon-wrap","aria-hidden":"true",children:E.jsx("span",{className:"chat-toolbar-icon","aria-hidden":"true",children:E.jsx(Be,{icon:YD})})}),E.jsx("span",{className:"chat-toolbar-label",children:e("Clear")})]})})]})}function CB({t:e,input:t,setInput:r,inputRef:n,handleSendMessageRef:i,attachmentSession:s,apiFetch:a,normalizeAttachments:o,setDraftAttachments:l,draftAttachments:c,setAttachmentsLoading:h,setAttachmentsError:u,showToast:m,uploadInputRef:v,attachmentsLoading:w,conversationRef:_,composerRef:g,isMobileLayout:d}){const[f,p]=x.useState(!1),[y,S]=x.useState(""),[b,k]=x.useState(null),[C,A]=x.useState(!1),P=x.useRef(0),O=x.useMemo(()=>[{id:"todo",label:"/todo",description:e("Add to backlog"),insert:"/todo "},{id:"backlog",label:"/backlog",description:e("Show backlog"),insert:"/backlog"},{id:"open",label:"/open",description:e("Open path"),insert:"/open "},{id:"run",label:"/run",description:e("Run shell command"),insert:"/run "},{id:"screenshot",label:"/screenshot",description:e("Capture screenshot"),insert:"/screenshot"},{id:"git",label:"/git",description:e("Run git command"),insert:"/git "},{id:"diff",label:"/diff",description:e("Open diff view"),insert:"/diff"},{id:"annotation",label:"/annotation",description:e("Toggle annotation mode (EXPERIMENTAL)"),insert:"/annotation on"}],[e]),R=x.useMemo(()=>{const W=y.trim().toLowerCase();return W?O.filter(j=>j.label.toLowerCase().includes(W)):O},[O,y]);x.useEffect(()=>{if(!f){k(null);return}if(!R.length){k(null);return}k(W=>R.some(j=>j.id===W)?W:R[0].id)},[f,R]);const M=x.useCallback(W=>{const{value:j}=W.target;r(j),j.startsWith("/")&&!j.includes(" ")?(p(!0),S(j.slice(1))):(p(!1),S("")),n.current&&(n.current.style.height="auto",n.current.style.height=`${n.current.scrollHeight}px`)},[n,r]),z=x.useCallback(W=>{var j,N;if(f){if(W.key==="Escape"){W.preventDefault(),p(!1);return}if(W.key==="ArrowDown"){if(W.preventDefault(),!R.length)return;const G=R.findIndex(X=>X.id===b),V=G===-1||G===R.length-1?0:G+1;k(R[V].id);return}if(W.key==="ArrowUp"){if(W.preventDefault(),!R.length)return;const G=R.findIndex(X=>X.id===b),V=G<=0?R.length-1:G-1;k(R[V].id);return}if(W.key==="Enter"&&!W.shiftKey&&b){W.preventDefault();const G=R.find(V=>V.id===b);G&&(r(G.insert),p(!1),S(""),(j=n.current)==null||j.focus());return}}W.isComposing||W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),(N=i.current)==null||N.call(i))},[f,R,b,i,n,r]);x.useEffect(()=>{n.current&&(n.current.style.height="auto",n.current.style.height=`${n.current.scrollHeight}px`)},[t,d,n]),x.useEffect(()=>{if(!_.current||!g.current)return;const W=()=>{if(!_.current||!g.current)return;const N=g.current.getBoundingClientRect(),G=d?12:16;_.current.style.setProperty("--composer-space",`${Math.ceil(N.height+G)}px`)};W();let j;return typeof ResizeObserver<"u"&&(j=new ResizeObserver(W),j.observe(g.current)),window.addEventListener("resize",W),()=>{window.removeEventListener("resize",W),j&&j.disconnect()}},[d,c.length,_,g]);const U=x.useCallback(async W=>{if(!(!W.length||!(s!=null&&s.sessionId)))try{h(!0),u("");const j=new FormData;W.forEach(X=>j.append("files",X));const N=await a(`/api/v1/sessions/${encodeURIComponent(s.sessionId)}/attachments/upload`,{method:"POST",body:j});if(!N.ok)throw new Error("Upload failed.");const G=await N.json(),V=o(G.files||[]);l(X=>[...X,...V])}catch(j){u(j.message||e("Unable to upload attachments."))}finally{h(!1)}},[a,s==null?void 0:s.sessionId,o,u,h,l,e]),q=x.useCallback(async()=>{var W;if(!(s!=null&&s.sessionId)){m(e("Session not found."),"error");return}if(!((W=navigator.mediaDevices)!=null&&W.getDisplayMedia)){m(e("Screenshot failed."),"error");return}try{const j=await navigator.mediaDevices.getDisplayMedia({video:{cursor:"never"},audio:!1}),N=document.createElement("video");N.srcObject=j,await new Promise(ve=>{N.onloadedmetadata=()=>ve()}),await N.play();const G=document.createElement("canvas");G.width=N.videoWidth||1,G.height=N.videoHeight||1;const V=G.getContext("2d");if(!V)throw new Error("Canvas unavailable");V.drawImage(N,0,0,G.width,G.height),j.getTracks().forEach(ve=>ve.stop());const X=await new Promise((ve,le)=>{G.toBlob(Se=>Se?ve(Se):le(new Error("Blob failed")),"image/png")}),ne=`screenshot-${Date.now()}.png`,ue=new File([X],ne,{type:"image/png"});await U([ue]),m(e("Screenshot captured."))}catch(j){m((j==null?void 0:j.message)||e("Screenshot failed."),"error")}},[s==null?void 0:s.sessionId,m,e,U]),Q=x.useCallback(async W=>{const j=Array.from(W.target.files||[]);await U(j),W.target.value=""},[U]),H=x.useCallback(async W=>{var G;if(!(s!=null&&s.sessionId))return;const N=Array.from(((G=W.clipboardData)==null?void 0:G.items)||[]).filter(V=>V.kind==="file").map(V=>V.getAsFile()).filter(Boolean);N.length&&(W.preventDefault(),await U(N))},[s==null?void 0:s.sessionId,U]),I=x.useCallback(W=>{var j,N;s!=null&&s.sessionId&&(N=(j=W.dataTransfer)==null?void 0:j.types)!=null&&N.includes("Files")&&W.preventDefault()},[s==null?void 0:s.sessionId]),L=x.useCallback(W=>{var j,N;s!=null&&s.sessionId&&(N=(j=W.dataTransfer)==null?void 0:j.types)!=null&&N.includes("Files")&&(W.preventDefault(),P.current+=1,A(!0))},[s==null?void 0:s.sessionId]),B=x.useCallback(W=>{var j,N;s!=null&&s.sessionId&&(N=(j=W.dataTransfer)==null?void 0:j.types)!=null&&N.includes("Files")&&(W.preventDefault(),P.current=Math.max(0,P.current-1),P.current===0&&A(!1))},[s==null?void 0:s.sessionId]),D=x.useCallback(async W=>{var N;if(!(s!=null&&s.sessionId))return;W.preventDefault(),W.stopPropagation(),P.current=0,A(!1);const j=Array.from(((N=W.dataTransfer)==null?void 0:N.files)||[]);j.length&&await U(j)},[s==null?void 0:s.sessionId,U]),T=x.useCallback(W=>{W&&l(j=>j.filter(N=>((N==null?void 0:N.path)||(N==null?void 0:N.name))!==W))},[l]),$=x.useCallback(()=>{!s||w||requestAnimationFrame(()=>{var W;(W=v.current)==null||W.click()})},[s,w,v]),Y=x.useCallback(W=>{var j;W.preventDefault(),(j=i.current)==null||j.call(i)},[i]);return{commandMenuOpen:f,setCommandMenuOpen:p,commandQuery:y,setCommandQuery:S,commandSelection:b,filteredCommands:R,isDraggingAttachments:C,handleInputChange:M,handleComposerKeyDown:z,onSubmit:Y,onUploadAttachments:Q,onPasteAttachments:H,onDragOverComposer:I,onDragEnterComposer:L,onDragLeaveComposer:B,onDropAttachments:D,removeDraftAttachment:T,triggerAttachmentPicker:$,captureScreenshot:q}}function kB({attachmentSessionId:e,workspaceToken:t,socketRef:r,reconnectTimerRef:n,reconnectAttemptRef:i,closingRef:s,pingIntervalRef:a,lastPongRef:o,messageIndex:l,commandIndex:c,rpcLogsEnabledRef:h,mergeAndApplyMessages:u,requestMessageSync:m,requestWorktreesList:v,requestWorktreeMessages:w,applyWorktreesList:_,resyncSession:g,t:d,setStatus:f,setConnected:p,setAppServerReady:y,setHasMainWorktreeStatus:S,setMessages:b,setProcessing:k,setActivity:C,setCurrentTurnId:A,setMainTaskLabel:P,setModelLoading:O,setModelError:R,setModels:M,setProviderModelState:z,setSelectedModel:U,setSelectedReasoningEffort:q,setRepoDiff:Q,setRpcLogs:H,setWorktrees:I,setPaneByTab:L,setLogFilterByTab:B,setActiveWorktreeId:D,activeWorktreeIdRef:T,extractVibe80Task:$,extractFirstLine:Y,getItemActivityLabel:W,maybeNotify:j,normalizeAttachments:N,loadRepoLastCommit:G,loadBranches:V,loadWorktreeLastCommit:X,openAiLoginRequest:ne,setOpenAiLoginRequest:ue,connected:ve}){x.useEffect(()=>{if(!e||!t)return;let le=!0,Se=null;const ye=()=>{n.current&&(clearTimeout(n.current),n.current=null)},Me=()=>{a.current&&(clearInterval(a.current),a.current=null)},Ne=()=>{Se&&(clearInterval(Se),Se=null)},Ue=()=>{Me(),o.current=Date.now(),a.current=setInterval(()=>{const Ce=r.current;if(!Ce||Ce.readyState!==WebSocket.OPEN)return;if(document.hidden){o.current=Date.now();return}if(Date.now()-o.current>15e3){Ce.close();return}Ce.send(JSON.stringify({type:"ping"}))},1e4)},Ke=()=>{Ne();const Ce=()=>{const Z=r.current;if(!Z||Z.readyState!==WebSocket.OPEN)return;const se=(T==null?void 0:T.current)||"main";Z.send(JSON.stringify({type:"wake_up",worktreeId:se}))};Ce(),Se=setInterval(Ce,60*1e3)},Ye=()=>{if(!le)return;const Ce=Math.min(i.current+1,6);i.current=Ce;const we=Math.min(500*2**(Ce-1),1e4),F=Math.floor(Math.random()*250);ye(),n.current=setTimeout(()=>{Ee()},we+F)},Ee=()=>{if(!le)return;f(d("Connecting..."));const Ce=new WebSocket(`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws?session=${encodeURIComponent(e)}`);r.current=Ce;let Z=!1;const se=()=>r.current===Ce;Ce.addEventListener("open",()=>{se()&&Ce.send(JSON.stringify({type:"auth",token:t}))}),Ce.addEventListener("close",()=>{se()&&(p(!1),f(d("Disconnected")),y(!1),Me(),Ne(),s.current||Ye())}),Ce.addEventListener("error",()=>{se()&&Ce.close()}),Ce.addEventListener("message",we=>{var St,ce,he;if(!se())return;let F;try{F=JSON.parse(we.data)}catch{return}const _e=typeof F.worktreeId=="string"?F.worktreeId:"",De=_e.length>0,ee=_e==="main",Ae=De&&!ee,Ie=ee||!De;if(Ie&&(F.type==="assistant_delta"||F.type==="command_execution_delta"||F.type==="command_execution_completed"||F.type==="item_started")&&(k(J=>J||!0),C(d("Processing..."))),F.type==="auth_ok"){if(!Z){Z=!0,i.current=0,ye(),p(!0),f(d("Connected")),Ue(),Ke(),g(),m(),v();const J=r.current;if(J&&J.readyState===WebSocket.OPEN){const K=(T==null?void 0:T.current)||"main";J.send(JSON.stringify({type:"wake_up",worktreeId:K}))}}return}if(Z){if(F.type==="pong"&&(o.current=Date.now()),F.type==="status"&&(f(F.message),F.provider==="codex"&&y(!1)),F.type==="ready"&&(f(d("Ready")),y(!0)),F.type==="provider_status"&&F.provider==="codex"&&y(F.status==="ready"),Ie&&F.type==="assistant_delta"){if(typeof F.delta!="string")return;b(J=>{const K=[...J],te=K.findIndex(ae=>(ae==null?void 0:ae.id)===F.itemId);if(te===-1)return K.push({id:F.itemId,role:"assistant",text:F.delta}),K;const ie={...K[te]};return ie.text+=F.delta,K[te]=ie,K})}if(Ie&&F.type==="assistant_message"){if(typeof F.text!="string")return;const J=$(F.text);J&&P(J),j({id:F.itemId,text:F.text}),b(K=>{const te=[...K],ie=te.findIndex(ae=>(ae==null?void 0:ae.id)===F.itemId);return ie===-1?(te.push({id:F.itemId,role:"assistant",text:F.text}),te):(te[ie]={...te[ie],text:F.text},te)})}if(Ie&&F.type==="action_request"){if(!F.id)return;b(J=>{const K=[...J];return K.findIndex(ie=>(ie==null?void 0:ie.id)===F.id)===-1&&K.push({id:F.id,role:"user",type:"action_request",text:F.text||`/${F.request||"run"} ${F.arg||""}`.trim(),action:{request:F.request,arg:F.arg}}),K})}if(Ie&&F.type==="action_result"){if(!F.id)return;b(J=>{const K=[...J],te=K.findIndex(ae=>(ae==null?void 0:ae.id)===F.id),ie={id:F.id,role:"assistant",type:"action_result",text:F.text||"",action:{request:F.request,arg:F.arg,status:F.status,output:F.output}};return te===-1?K.push(ie):K[te]={...K[te],...ie},K}),(F.request==="run"||F.request==="git")&&(G(),typeof V=="function"&&V())}if(Ie&&F.type==="backlog_view"){if(!F.id)return;b(J=>{const K=[...J];return K.findIndex(ie=>(ie==null?void 0:ie.id)===F.id)===-1&&K.push({id:F.id,role:"assistant",type:"backlog_view",text:F.text||"Backlog",backlog:{items:Array.isArray(F.items)?F.items:[],page:Number.isFinite(F.page)?F.page:0}}),K})}if(Ie&&F.type==="command_execution_delta"){if(typeof F.delta!="string")return;b(J=>{const K=[...J],te=c.get(F.itemId);if(te===void 0){const ae={id:F.itemId,role:"commandExecution",command:d("Command"),output:F.delta,isExpandable:!0,status:"running"};return c.set(F.itemId,K.length),K.push(ae),K}const ie={...K[te]};return ie.output=`${ie.output||""}${F.delta}`,ie.isExpandable=!0,K[te]=ie,K})}if(Ie&&F.type==="command_execution_completed"){const J=F.item,K=F.itemId||(J==null?void 0:J.id);if(!K)return;b(te=>{var Ge;const ie=[...te],ae=c.get(K),oe=((Ge=J==null?void 0:J.commandActions)==null?void 0:Ge.command)||(J==null?void 0:J.command)||d("Command");if(ae===void 0){const We={id:K,role:"commandExecution",command:oe,output:(J==null?void 0:J.aggregatedOutput)||"",isExpandable:!0,status:"completed"};return c.set(K,ie.length),ie.push(We),ie}const ge={...ie[ae]};return ge.command=oe,ge.output=(J==null?void 0:J.aggregatedOutput)||ge.output||"",ge.isExpandable=!0,ge.status="completed",ie[ae]=ge,ie})}if(Ie&&F.type==="turn_error"&&(f(d("Error: {{message}}",{message:F.message})),A(null),P("")),Ie&&F.type==="agent_reasoning"){const J=Y(F.text);J&&P(J)}if(Ie&&F.type==="error"&&(f(F.message||d("Unexpected error")),O(!1),R(F.message||d("Unexpected error"))),Ae&&F.type==="error"&&I(J=>{const K=new Map(J),te=K.get(_e);return te?(K.set(_e,{...te,modelLoading:!1,modelError:F.message||d("Unexpected error")}),K):J}),Ie&&F.type==="turn_started"&&A(F.turnId||null),Ie&&F.type==="turn_completed"){const J=((St=F==null?void 0:F.turn)==null?void 0:St.error)||(F==null?void 0:F.error)||null;if((J==null?void 0:J.codexErrorInfo)==="usageLimitExceeded"){const te=`usage-limit-${F.turnId||((ce=F.turn)==null?void 0:ce.id)||Date.now()}`,ie=(typeof J=="string"?J:J==null?void 0:J.message)||d("Usage limit reached. Please try again later.");b(ae=>ae.some(oe=>oe.id===te)?ae:[...ae,{id:te,role:"assistant",text:`⚠️ ${ie}`}])}A(null),P(""),G()}if(Ie&&F.type==="repo_diff"&&Q({status:F.status||"",diff:F.diff||""}),Ie&&F.type==="model_list"){const J=Array.isArray(F.models)?F.models:[];M(J),F.provider&&z(te=>({...te,[F.provider]:{models:J,loading:!1,error:""}}));const K=J.find(te=>te.isDefault);K!=null&&K.model&&U(K.model),K!=null&&K.defaultReasoningEffort&&q(K.defaultReasoningEffort),O(!1),R("")}if(Ae&&F.type==="model_list"){const J=Array.isArray(F.models)?F.models:[];I(K=>{const te=new Map(K),ie=te.get(_e);if(!ie)return K;const ae=J.find(ge=>ge.isDefault),oe=ie.model||(ae==null?void 0:ae.model)||null;return te.set(_e,{...ie,models:J,model:oe,modelLoading:!1,modelError:""}),te})}if(Ie&&F.type==="model_set"&&(U(F.model||""),F.reasoningEffort!==void 0&&q(F.reasoningEffort||""),O(!1),R("")),Ae&&F.type==="model_set"&&I(J=>{const K=new Map(J),te=K.get(_e);return te?(K.set(_e,{...te,model:F.model||null,reasoningEffort:F.reasoningEffort??te.reasoningEffort??null,modelLoading:!1,modelError:""}),K):J}),Ie&&F.type==="rpc_log"){if(!h.current)return;F.entry&&H(J=>[...J,F.entry])}if(Ie&&F.type==="session_sync"){if(!(F!=null&&F.session))return;const J=F.session;b((J.messages||[]).map((K,te)=>({...K,id:(K==null?void 0:K.id)||`history-${te}`,attachments:N((K==null?void 0:K.attachments)||[]),toolResult:K==null?void 0:K.toolResult}))),Q(J.repoDiff||{status:"",diff:""}),J.provider&&z(K=>({...K,[J.provider]:{models:J.models||[],loading:!1,error:""}}))}if(Ie&&F.type==="worktrees_list"&&_(F.worktrees||[]),Ie&&F.type==="worktree_messages_sync"){if(F.worktreeId==="main"){u(F.messages||[]);return}I(J=>{const K=new Map(J),te=K.get(F.worktreeId);if(te){const ie=(F.messages||[]).map((ge,Ge)=>({...ge,id:(ge==null?void 0:ge.id)||`history-${Ge}`,attachments:N((ge==null?void 0:ge.attachments)||[]),toolResult:ge==null?void 0:ge.toolResult})),ae=new Set(te.messages.map(ge=>ge==null?void 0:ge.id).filter(Boolean)),oe=[...te.messages];ie.forEach(ge=>{ge!=null&&ge.id&&ae.has(ge.id)||(ge!=null&&ge.id&&ae.add(ge.id),oe.push(ge))}),K.set(F.worktreeId,{...te,messages:oe,status:F.status??te.status})}return K})}if(F.type==="worktree_diff"&&I(J=>{const K=new Map(J),te=K.get(F.worktreeId);return te&&K.set(F.worktreeId,{...te,diff:{status:F.status,diff:F.diff}}),K}),Ae&&(F.type==="assistant_delta"||F.type==="assistant_message"||F.type==="action_request"||F.type==="action_result"||F.type==="backlog_view"||F.type==="command_execution_delta"||F.type==="command_execution_completed"||F.type==="turn_started"||F.type==="turn_completed"||F.type==="turn_error")){const J=F.worktreeId;if((F.type==="assistant_delta"||F.type==="command_execution_delta"||F.type==="command_execution_completed"||F.type==="item_started")&&I(K=>{const te=new Map(K),ie=te.get(J);return ie&&ie.status==="ready"&&te.set(J,{...ie,status:"processing"}),te}),F.type==="turn_started"&&I(K=>{const te=new Map(K),ie=te.get(J);return ie&&te.set(J,{...ie,currentTurnId:F.turnId,activity:d("Processing...")}),te}),F.type==="action_request"){if(!F.id)return;I(K=>{const te=new Map(K),ie=te.get(J);return ie&&te.set(J,{...ie,messages:[...ie.messages,{id:F.id,role:"user",type:"action_request",text:F.text||`/${F.request||"run"} ${F.arg||""}`.trim(),action:{request:F.request,arg:F.arg}}]}),te})}if(F.type==="action_result"){if(!F.id)return;I(K=>{const te=new Map(K),ie=te.get(J)||{id:J,name:J,branchName:"",provider:"codex",status:"processing",messages:[],models:[],modelLoading:!1,modelError:"",activity:"",currentTurnId:null};return ie.messages.some(ae=>(ae==null?void 0:ae.id)===F.id)?K:(te.set(J,{...ie,messages:[...ie.messages,{id:F.id,role:"assistant",type:"action_result",text:F.text||"",action:{request:F.request,arg:F.arg,status:F.status,output:F.output}}]}),te)}),(F.request==="run"||F.request==="git")&&(X(J),typeof V=="function"&&J==="main"&&V())}if(F.type==="backlog_view"){if(!F.id)return;I(K=>{const te=new Map(K),ie=te.get(J);return ie&&te.set(J,{...ie,messages:[...ie.messages,{id:F.id,role:"assistant",type:"backlog_view",text:F.text||"Backlog",backlog:{items:Array.isArray(F.items)?F.items:[],page:Number.isFinite(F.page)?F.page:0}}]}),te})}if((F.type==="turn_completed"||F.type==="turn_error")&&I(K=>{const te=new Map(K),ie=te.get(J);return ie&&te.set(J,{...ie,currentTurnId:null,activity:"",taskLabel:""}),te}),F.type==="turn_completed"){const K=((he=F==null?void 0:F.turn)==null?void 0:he.error)||(F==null?void 0:F.error)||null;if((K==null?void 0:K.codexErrorInfo)==="usageLimitExceeded"){const ie=`usage-limit-${F.turnId||Date.now()}`,ae=(typeof K=="string"?K:K==null?void 0:K.message)||d("Usage limit reached. Please try again later.");I(oe=>{const ge=new Map(oe),Ge=ge.get(J);return!Ge||Ge.messages.some(We=>We.id===ie)?oe:(ge.set(J,{...Ge,messages:[...Ge.messages,{id:ie,role:"assistant",text:`⚠️ ${ae}`}]}),ge)})}X(J)}if((F.type==="assistant_delta"||F.type==="assistant_message")&&(I(K=>{const te=new Map(K),ie=te.get(J);if(!ie)return K;const ae=[...ie.messages],oe=ae.findIndex(ge=>ge.id===F.itemId);return F.type==="assistant_delta"?oe===-1?ae.push({id:F.itemId,role:"assistant",text:F.delta||""}):ae[oe]={...ae[oe],text:(ae[oe].text||"")+(F.delta||"")}:oe===-1?ae.push({id:F.itemId,role:"assistant",text:F.text||""}):ae[oe]={...ae[oe],text:F.text||""},te.set(J,{...ie,messages:ae}),te}),F.type==="assistant_message"&&typeof F.text=="string")){const K=$(F.text);K&&I(te=>{const ie=new Map(te),ae=ie.get(J);return ae?(ie.set(J,{...ae,taskLabel:K}),ie):te})}(F.type==="command_execution_delta"||F.type==="command_execution_completed")&&I(K=>{var Ge,We;const te=new Map(K),ie=te.get(J);if(!ie)return K;const ae=[...ie.messages],oe=F.itemId||((Ge=F.item)==null?void 0:Ge.id),ge=ae.findIndex(Je=>Je.id===oe);if(F.type==="command_execution_delta")ge===-1?ae.push({id:oe,role:"commandExecution",command:d("Command"),output:F.delta||"",status:"running",isExpandable:!0}):ae[ge]={...ae[ge],output:(ae[ge].output||"")+(F.delta||"")};else{const Je=F.item,xt=((We=Je==null?void 0:Je.commandActions)==null?void 0:We.command)||(Je==null?void 0:Je.command)||d("Command");ge===-1?ae.push({id:oe,role:"commandExecution",command:xt,output:(Je==null?void 0:Je.aggregatedOutput)||"",status:"completed",isExpandable:!0}):ae[ge]={...ae[ge],command:xt,output:(Je==null?void 0:Je.aggregatedOutput)||ae[ge].output||"",status:"completed"}}return te.set(J,{...ie,messages:ae}),te})}if(F.type==="agent_reasoning"&&Ae){const J=Y(F.text);J&&I(K=>{const te=new Map(K),ie=te.get(F.worktreeId);return ie?(te.set(F.worktreeId,{...ie,taskLabel:J}),te):K})}if(F.type==="item_started"&&Ae){const J=W(F.item);if(!J)return;const K=F.worktreeId;I(te=>{const ie=new Map(te),ae=ie.get(K);return ae&&ie.set(K,{...ae,activity:J}),ie})}if(F.type==="worktree_created"&&(I(J=>{const K=new Map(J);return K.set(F.worktreeId,{id:F.worktreeId,name:F.name,branchName:F.branchName,provider:F.provider,model:F.model||null,reasoningEffort:F.reasoningEffort||null,internetAccess:!!F.internetAccess,denyGitCredentialsAccess:typeof F.denyGitCredentialsAccess=="boolean"?F.denyGitCredentialsAccess:!0,status:F.status||"creating",color:F.color,models:[],modelLoading:!1,modelError:"",messages:[],activity:"",currentTurnId:null}),K}),L(J=>({...J,[F.worktreeId]:J[F.worktreeId]||"chat"})),B(J=>({...J,[F.worktreeId]:J[F.worktreeId]||"all"})),D(F.worktreeId)),F.type==="worktree_ready"&&I(J=>{const K=new Map(J),te=K.get(F.worktreeId);return te&&K.set(F.worktreeId,{...te,status:"ready"}),K}),F.type==="worktree_status"){if(F.worktreeId==="main"){if(!F.status)return;S==null||S(!0);const J=F.status;k(J==="processing"),C(J==="processing"?d("Processing..."):""),J!=="processing"&&P("");return}if(!F.status)return;I(J=>{const K=new Map(J),te=K.get(F.worktreeId);return te&&K.set(F.worktreeId,{...te,status:F.status,error:F.error||null,...F.status==="processing"?{}:{activity:"",taskLabel:"",currentTurnId:null}}),K})}F.type==="worktree_removed"&&(I(J=>{const K=new Map(J);return K.delete(F.worktreeId),K}),L(J=>{const K={...J};return delete K[F.worktreeId],K}),B(J=>{const K={...J};return delete K[F.worktreeId],K}),T.current===F.worktreeId&&D("main")),F.type==="worktree_renamed"&&I(J=>{const K=new Map(J),te=K.get(F.worktreeId);return te&&K.set(F.worktreeId,{...te,name:F.name}),K})}})};Ee();const je=()=>{if(document.hidden||!le)return;o.current=Date.now();const Ce=r.current;if(Ce&&Ce.readyState===WebSocket.OPEN){Ce.send(JSON.stringify({type:"ping"})),g(),m();const Z=(T==null?void 0:T.current)||"main";Ce.send(JSON.stringify({type:"wake_up",worktreeId:Z}))}else ye(),i.current=0,Ee()};return document.addEventListener("visibilitychange",je),()=>{le=!1,s.current=!0,ye(),Me(),document.removeEventListener("visibilitychange",je),r.current&&r.current.close(),Ne(),s.current=!1}},[e,t,l,c,u,m,v,w,_,g,d]),x.useEffect(()=>{if(!e||!ne||!ve)return;const le=r.current;!le||le.readyState!==WebSocket.OPEN||(le.send(JSON.stringify({type:"account_login_start",provider:"codex",params:ne})),ue(null))},[e,ve,ne,ue,r])}const Hl="workspaceToken",Wl="workspaceRefreshToken",Vl="workspaceId",xB="workspace-auth",io="workspaceRefreshLock",EB=15e3,AB=5e3,B1=1500,LB="mono_auth_token",Gf=()=>{try{return localStorage.getItem(Hl)||""}catch{return""}},F1=()=>{try{return localStorage.getItem(Wl)||""}catch{return""}},z1=()=>{try{return localStorage.getItem(Vl)||""}catch{return""}},PB=()=>{const e=String(window.location.hash||"");if(!e||!e.startsWith("#"))return"";const t=e.slice(1);return(new URLSearchParams(t).get("mono_auth")||"").trim()},TB=()=>({codex:{enabled:!1,authType:"api_key",authValue:"",previousAuthType:"api_key"},claude:{enabled:!1,authType:"api_key",authValue:"",previousAuthType:"api_key"}}),DB=()=>({codex:!1,claude:!1}),$1=()=>({codex:"",claude:""});function IB({t:e,encodeBase64:t,copyTextToClipboard:r,extractRepoName:n,setSessionMode:i,showToast:s,getProviderAuthType:a}){const[o,l]=x.useState(1),[c,h]=x.useState("existing"),[u,m]=x.useState(z1()),[v,w]=x.useState(""),[_,g]=x.useState(Gf()),[d,f]=x.useState(F1()),[p,y]=x.useState(z1()),[S,b]=x.useState(null),[k,C]=x.useState(""),[A,P]=x.useState(!1),[O,R]=x.useState([]),[M,z]=x.useState(!1),[U,q]=x.useState(""),[Q,H]=x.useState(null),[I,L]=x.useState({id:!1,secret:!1}),[B,D]=x.useState(!1),[T,$]=x.useState(1),[Y,W]=x.useState(DB),[j,N]=x.useState($1),[G,V]=x.useState(TB),[X,ne]=x.useState(null),ue=x.useRef(`tab-${Math.random().toString(36).slice(2)}-${Date.now()}`),ve=x.useRef(_),le=x.useRef(d),Se=x.useRef(null),ye=x.useRef(null),Me=x.useRef([]),Ne=x.useRef({id:null,secret:null}),Ue=x.useCallback(({token:ce="",refreshToken:he=""}={})=>{typeof ce=="string"&&(ve.current=ce,g(ce)),typeof he=="string"&&(le.current=he,f(he))},[]),Ke=x.useCallback(ce=>{Me.current.splice(0).forEach(J=>{try{J(ce||null)}catch{}})},[]),Ye=x.useCallback((ce=AB)=>new Promise(he=>{const J=setTimeout(()=>{const te=Me.current.indexOf(K);te>=0&&Me.current.splice(te,1),he(null)},ce),K=te=>{clearTimeout(J),he(te||null)};Me.current.push(K)}),[]),Ee=x.useCallback((ce,he={})=>{const J=ye.current;if(J)try{J.postMessage({type:ce,sourceTabId:ue.current,...he})}catch{}},[]),je=x.useCallback(()=>{const ce=Gf(),he=F1();return{token:ce||ve.current||"",refreshToken:he||le.current||""}},[]),Ce=x.useCallback(()=>{const ce=Date.now(),he={owner:ue.current,expiresAt:ce+EB};try{const J=localStorage.getItem(io);if(J){const ie=JSON.parse(J);if(ie&&typeof ie.expiresAt=="number"&&ie.expiresAt>ce&&ie.owner!==ue.current)return!1}localStorage.setItem(io,JSON.stringify(he));const K=localStorage.getItem(io);if(!K)return!1;const te=JSON.parse(K);return(te==null?void 0:te.owner)===ue.current}catch{return!0}},[]),Z=x.useCallback(()=>{try{const ce=localStorage.getItem(io);if(!ce)return;const he=JSON.parse(ce);(he==null?void 0:he.owner)===ue.current&&localStorage.removeItem(io)}catch{}},[]),se=x.useCallback(()=>{Ue({token:"",refreshToken:""}),y(""),m(""),w(""),b(null),C(""),h("existing"),R([]),q(""),z(!1),l(1),D(!1),i&&i("new"),Ee("workspace_left",{}),Ke(null)},[Ue,Ee,Ke,i]),we=x.useCallback(async()=>{const ce=le.current||je().refreshToken;if(!ce)return null;if(Se.current)return Se.current;const he=(async()=>{let J=!1;try{if(J=Ce(),!J){const Ge=await Ye();if(Ge)return Ge;const We=je();if(We.token&&We.token!==ve.current)return Ue({token:We.token,refreshToken:We.refreshToken||le.current}),We.token;if(J=Ce(),!J)return null}Ee("refresh_started",{at:Date.now()});const te=je().refreshToken||ce;if(!te)return null;const ie=await fetch("/api/v1/workspaces/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:te})});if(!ie.ok){const Ge=await Ye(B1);if(Ge)return Ge;const We=je();return We.token&&We.token!==ve.current?(Ue({token:We.token,refreshToken:We.refreshToken||le.current}),We.token):null}const ae=await ie.json(),oe=(ae==null?void 0:ae.workspaceToken)||"",ge=(ae==null?void 0:ae.refreshToken)||"";return oe&&ge?(Ue({token:oe,refreshToken:ge}),Ee("refresh_succeeded",{at:Date.now(),workspaceToken:oe,refreshToken:ge}),Ke(oe),oe):null}catch{const K=await Ye(B1);return K||null}finally{J&&Z(),Se.current=null}})();return Se.current=he,he},[Ce,Ue,Ee,je,Ke,Z,Ye]);x.useEffect(()=>{ve.current=_},[_]),x.useEffect(()=>{le.current=d},[d]),x.useEffect(()=>{if(typeof BroadcastChannel!="function")return;const ce=new BroadcastChannel(xB);ye.current=ce;const he=J=>{const K=J==null?void 0:J.data;!K||K.sourceTabId===ue.current||(K.type==="refresh_succeeded"?(Ue({token:K.workspaceToken||"",refreshToken:K.refreshToken||""}),Ke(K.workspaceToken||null)):K.type==="workspace_left"&&(Ue({token:"",refreshToken:""}),y("")))};return ce.addEventListener("message",he),()=>{ce.removeEventListener("message",he),ce.close(),ye.current=null}},[Ue,Ke]),x.useEffect(()=>{const ce=he=>{if(!(!he||!he.key)){if(he.key===Hl){const J=he.newValue||"";ve.current=J,g(J),J&&Ke(J);return}if(he.key===Wl){const J=he.newValue||"";le.current=J,f(J);return}he.key===Vl&&y(he.newValue||"")}};return window.addEventListener("storage",ce),()=>{window.removeEventListener("storage",ce)}},[Ke]);const F=x.useCallback(async(ce,he={})=>{const J=new Headers(he.headers||{}),K=ve.current||_;K&&J.set("Authorization",`Bearer ${K}`);const te=await fetch(ce,{...he,headers:J});if(te.status!==401)return te;const ie=await we();if(!ie){const oe=ve.current||Gf();if(oe&&oe!==K){const ge=new Headers(he.headers||{});return ge.set("Authorization",`Bearer ${oe}`),fetch(ce,{...he,headers:ge})}return se(),te}const ae=new Headers(he.headers||{});return ae.set("Authorization",`Bearer ${ie}`),fetch(ce,{...he,headers:ae})},[_,we,se]);x.useEffect(()=>{let ce=!1;return(async()=>{try{const J=await fetch("/api/v1/health");if(!J.ok)return;const K=await J.json();!ce&&(K!=null&&K.deploymentMode)&&ne(K.deploymentMode)}catch{}})(),()=>{ce=!0}},[]),x.useEffect(()=>{const ce=PB();if(!ce)return;let he=!1;return(async()=>{try{const K=await fetch("/api/v1/workspaces/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grantType:LB,monoAuthToken:ce})});if(!K.ok){const ie=await K.json().catch(()=>null),ae=(ie==null?void 0:ie.error)||e("Automatic mono-user authentication failed.");he||C(ae);return}const te=await K.json();if(!(te!=null&&te.workspaceToken))return;he||(g(te.workspaceToken||""),f(te.refreshToken||""),y("default"),m("default"),l(4),C(""))}catch{he||C(e("Automatic mono-user authentication failed."))}finally{const K=new URL(window.location.href);K.hash.includes("mono_auth=")&&(K.hash="",window.history.replaceState({},"",K))}})(),()=>{he=!0}},[_,e,y,m,f,l,g,C]),x.useEffect(()=>{try{_?localStorage.setItem(Hl,_):localStorage.removeItem(Hl)}catch{}},[_]),x.useEffect(()=>{try{d?localStorage.setItem(Wl,d):localStorage.removeItem(Wl)}catch{}},[d]),x.useEffect(()=>{try{p?localStorage.setItem(Vl,p):localStorage.removeItem(Vl)}catch{}},[p]),x.useEffect(()=>{if(!_){l(1);return}l(ce=>ce>=3?ce:4)},[_]);const _e=x.useCallback(async()=>{if(_){z(!0),q("");try{const ce=await F("/api/v1/sessions");if(!ce.ok){const K=await ce.json().catch(()=>null);throw new Error((K==null?void 0:K.error)||e("Unable to load sessions."))}const he=await ce.json(),J=Array.isArray(he==null?void 0:he.sessions)?he.sessions:[];R(J)}catch(ce){q(ce.message||e("Unable to load sessions."))}finally{z(!1)}}},[F,_,se,e]);x.useEffect(()=>{!_||o!==4||_e()},[o,_,_e]);const De=x.useCallback(async()=>{const ce=(p||u||"").trim();if(ce){P(!0),C("");try{const he=await F(`/api/v1/workspaces/${encodeURIComponent(ce)}`);if(!he.ok){const te=await he.json().catch(()=>null);throw new Error((te==null?void 0:te.error)||e("Unable to load providers."))}const J=await he.json(),K=(J==null?void 0:J.providers)||{};V(te=>{var ie,ae,oe,ge,Ge,We,Je,xt,xi,Xe;return{codex:{...te.codex,enabled:!!((ie=K==null?void 0:K.codex)!=null&&ie.enabled),authType:((oe=(ae=K==null?void 0:K.codex)==null?void 0:ae.auth)==null?void 0:oe.type)||"api_key",previousAuthType:((Ge=(ge=K==null?void 0:K.codex)==null?void 0:ge.auth)==null?void 0:Ge.type)||"api_key",authValue:""},claude:{...te.claude,enabled:!!((We=K==null?void 0:K.claude)!=null&&We.enabled),authType:((xt=(Je=K==null?void 0:K.claude)==null?void 0:Je.auth)==null?void 0:xt.type)||"api_key",previousAuthType:((Xe=(xi=K==null?void 0:K.claude)==null?void 0:xi.auth)==null?void 0:Xe.type)||"api_key",authValue:""}}}),W(te=>{var ie,ae;return{...te,codex:!!((ie=K==null?void 0:K.codex)!=null&&ie.enabled),claude:!!((ae=K==null?void 0:K.claude)!=null&&ae.enabled)}}),N($1())}catch(he){C(he.message||e("Unable to load providers."))}finally{P(!1)}}},[F,se,e,p,u]),ee=async ce=>{ce.preventDefault(),C(""),P(!0);try{if(c==="existing"){const he=u.trim(),J=v.trim();if(!he||!J)throw new Error(e("Workspace ID and secret are required."));const K=await F("/api/v1/workspaces/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:he,workspaceSecret:J})});if(!K.ok){const ie=await K.json().catch(()=>null);throw new Error((ie==null?void 0:ie.error)||e("Authentication failed."))}const te=await K.json();g(te.workspaceToken||""),f(te.refreshToken||""),y(he),l(4);return}D(!1),$(1),l(2)}catch(he){C(he.message||e("Workspace configuration failed."))}finally{P(!1)}},Ae=async ce=>{ce.preventDefault(),C(""),P(!0);try{const he={};if(["codex","claude"].forEach(ae=>{const oe=G[ae];if(!(oe!=null&&oe.enabled)){he[ae]={enabled:!1};return}const ge=(oe.authValue||"").trim(),Ge=a(ae,oe)||"api_key";if(B&&oe.previousAuthType&&Ge!==oe.previousAuthType&&!ge)throw new Error(e("Key required for {{provider}}.",{provider:ae}));if(!B&&!ge)throw new Error(e("Key required for {{provider}}.",{provider:ae}));if(ge){const We=Ge==="auth_json_b64"&&t?t(ge):ge;he[ae]={enabled:!0,auth:{type:Ge,value:We}}}else he[ae]={enabled:!0,auth:{type:Ge}}}),Object.keys(he).length===0)throw new Error(e("Select at least one provider."));if(B){const ae=(p||u||"").trim();if(!ae)throw new Error(e("Workspace ID required."));const oe=await F(`/api/v1/workspaces/${encodeURIComponent(ae)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providers:he})});if(!oe.ok){const ge=await oe.json().catch(()=>null);throw new Error((ge==null?void 0:ge.error)||e("Workspace update failed."))}await oe.json().catch(()=>null),D(!1),l(4),s==null||s(e("AI providers updated."),"success");return}const J=await F("/api/v1/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providers:he})});if(!J.ok){const ae=await J.json().catch(()=>null);throw new Error((ae==null?void 0:ae.error)||e("Workspace creation failed."))}const K=await J.json();b(K),y(K.workspaceId),m(K.workspaceId);const te=await F("/api/v1/workspaces/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:K.workspaceId,workspaceSecret:K.workspaceSecret})});if(!te.ok){const ae=await te.json().catch(()=>null);throw new Error((ae==null?void 0:ae.error)||e("Authentication failed."))}const ie=await te.json();g(ie.workspaceToken||""),f(ie.refreshToken||""),l(3)}catch(he){C(he.message||e("Workspace configuration failed."))}finally{P(!1)}},Ie=x.useCallback((ce,he)=>{if(!he)return;r&&r(he),L(K=>({...K,[ce]:!0}));const J=Ne.current;J[ce]&&clearTimeout(J[ce]),J[ce]=setTimeout(()=>{L(K=>({...K,[ce]:!1})),J[ce]=null},2e3)},[]);return x.useEffect(()=>()=>{Object.values(Ne.current||{}).forEach(ce=>{ce&&clearTimeout(ce)})},[]),{apiFetch:F,deploymentMode:X,handleDeleteSession:async ce=>{const he=ce==null?void 0:ce.sessionId;if(!he)return;const J=n==null?void 0:n((ce==null?void 0:ce.repoUrl)||""),K=(ce==null?void 0:ce.name)||J||he;if(window.confirm(e('Supprimer la session "{{title}}" ? Cette action est irreversible.',{title:K})))try{H(he),q("");const ie=await F(`/api/v1/sessions/${encodeURIComponent(he)}`,{method:"DELETE"});if(!ie.ok){let ae="";try{const ge=await ie.json();typeof(ge==null?void 0:ge.error)=="string"&&(ae=ge.error)}catch{}const oe=ae?`: ${ae}`:"";throw new Error(e("Unable to delete the session{{suffix}}.",{suffix:oe}))}await _e(),s==null||s(e('Session "{{title}}" supprimee.',{title:K}),"success")}catch(ie){q(ie.message||e("Unable to delete the session."))}finally{H(null)}},handleLeaveWorkspace:se,handleWorkspaceCopy:Ie,handleWorkspaceProvidersSubmit:Ae,handleWorkspaceSubmit:ee,loadWorkspaceProviders:De,loadWorkspaceSessions:_e,providersBackStep:T,refreshWorkspaceToken:we,setProvidersBackStep:$,setWorkspaceAuthExpanded:W,setWorkspaceAuthFiles:N,setWorkspaceError:C,setWorkspaceId:y,setWorkspaceIdInput:m,setWorkspaceMode:h,setWorkspaceProviders:V,setWorkspaceProvidersEditing:D,setWorkspaceRefreshToken:f,setWorkspaceSecretInput:w,setWorkspaceStep:l,setWorkspaceToken:g,workspaceAuthExpanded:Y,workspaceAuthFiles:j,workspaceBusy:A,workspaceCopied:I,workspaceCreated:S,workspaceError:k,workspaceId:p,workspaceIdInput:u,workspaceMode:c,workspaceProviders:G,workspaceProvidersEditing:B,workspaceSecretInput:v,workspaceSessionDeletingId:Q,workspaceSessions:O,workspaceSessionsError:U,workspaceSessionsLoading:M,workspaceStep:o,workspaceToken:_}}function NB({apiFetch:e,attachmentSessionId:t,availableProviders:r,llmProvider:n,messagesRef:i,normalizeAttachments:s,applyMessages:a,socketRef:o,setPaneByTab:l,setLogFilterByTab:c,showToast:h,t:u}){const[m,v]=x.useState(new Map),w=x.useRef(new Map),[_,g]=x.useState("main"),d=x.useRef("main");x.useEffect(()=>{w.current=m},[m]),x.useEffect(()=>{d.current=_},[_]);const f=x.useCallback(R=>{var M;if(!Array.isArray(R))return null;for(let z=R.length-1;z>=0;z-=1)if((M=R[z])!=null&&M.id)return R[z].id;return null},[]),p=x.useCallback(async()=>{if(t)try{const R=await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees/main/messages`);if(!R.ok)return;const M=await R.json().catch(()=>({}));if(Array.isArray(M==null?void 0:M.messages)){const z=M.messages.map((U,q)=>({...U,id:(U==null?void 0:U.id)||`history-${q}`,attachments:s((U==null?void 0:U.attachments)||[]),toolResult:U==null?void 0:U.toolResult}));a(z)}}catch{}},[t,e,a,s]),y=x.useCallback(async R=>{if(!(!t||!R)){if(R==="main"){await p();return}try{const M=await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees/${encodeURIComponent(R)}`);if(!M.ok)return;const z=await M.json().catch(()=>({})),U=await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees/${encodeURIComponent(R)}/messages`);if(!U.ok)return;const q=await U.json().catch(()=>({}));if(!Array.isArray(q==null?void 0:q.messages))return;const Q=q.messages.map((H,I)=>({...H,id:(H==null?void 0:H.id)||`history-${I}`,attachments:s((H==null?void 0:H.attachments)||[]),toolResult:H==null?void 0:H.toolResult}));v(H=>{const I=new Map(H),L=I.get(R);return L&&I.set(R,{...L,messages:Q,status:z.status||L.status}),I})}catch{}}},[t,e,p,s]),S=x.useCallback(R=>{var q;const M=o==null?void 0:o.current;if(!M||M.readyState!==WebSocket.OPEN||!R)return;const z=w.current,U=f(R==="main"?i.current:(q=z.get(R))==null?void 0:q.messages);M.send(JSON.stringify({type:"worktree_messages_sync",worktreeId:R,lastSeenMessageId:U}))},[f,i,o]),b=x.useCallback(R=>{if(!Array.isArray(R))return;const M=new Map;R.forEach(z=>{M.set(z.id,{...z,status:(z==null?void 0:z.status)||"processing",messages:[],models:[],modelLoading:!1,modelError:"",activity:"",currentTurnId:null})}),v(M),l(z=>{const U={...z};return R.forEach(q=>{U[q.id]||(U[q.id]="chat")}),U}),c(z=>{const U={...z};return R.forEach(q=>{U[q.id]||(U[q.id]="all")}),U}),d.current!=="main"&&!R.some(z=>z.id===d.current)&&g("main")},[c,l]),k=x.useCallback(async()=>{if(t)try{const R=await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees`);if(!R.ok)return;const M=await R.json();b(M==null?void 0:M.worktrees)}catch{}},[t,e,b]),C=x.useCallback(R=>{if(!R)return;g(R);const M=o==null?void 0:o.current;M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"wake_up",worktreeId:R})),y(R)},[y,o]),A=x.useCallback(async({context:R,name:M,provider:z,sourceWorktree:U,startingBranch:q,model:Q,reasoningEffort:H,internetAccess:I,denyGitCredentialsAccess:L})=>{if(!t){h==null||h(u("Session not found."),"error");return}try{const B=await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:R==="fork"?"fork":"new",provider:R==="new"?r.includes(z)?z:n:void 0,sourceWorktree:R==="fork"?U||null:void 0,name:M||null,startingBranch:q||null,model:R==="new"?Q||null:void 0,reasoningEffort:R==="new"?H??null:void 0,internetAccess:!!I,denyGitCredentialsAccess:!!L})});if(!B.ok){const T=await B.json().catch(()=>null);throw new Error((T==null?void 0:T.error)||u("Failed to create parallel request."))}const D=await B.json();v(T=>{const $=new Map(T);return $.set(D.worktreeId,{id:D.worktreeId,name:D.name,branchName:D.branchName,provider:D.provider,model:D.model||null,reasoningEffort:D.reasoningEffort||null,context:D.context||"new",sourceWorktreeId:D.sourceWorktreeId||null,internetAccess:!!D.internetAccess,denyGitCredentialsAccess:!!D.denyGitCredentialsAccess,status:D.status||"creating",color:D.color,messages:[],activity:"",currentTurnId:null}),$}),l(T=>({...T,[D.worktreeId]:T[D.worktreeId]||"chat"})),c(T=>({...T,[D.worktreeId]:T[D.worktreeId]||"all"})),g(D.worktreeId),k()}catch(B){h==null||h(B.message||u("Failed to create parallel request."),"error")}},[e,t,r,n,k,c,l,h,u]),P=x.useCallback(async R=>{if(t)try{(await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees/${encodeURIComponent(R)}`,{method:"DELETE"})).ok||console.error("Failed to close worktree")}catch(M){console.error("Error closing worktree:",M)}},[t,e]),O=x.useCallback(async(R,M)=>{if(t)try{(await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees/${encodeURIComponent(R)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:M})})).ok||console.error("Failed to rename worktree")}catch(z){console.error("Error renaming worktree:",z)}},[t,e]);return{activeWorktreeId:_,activeWorktreeIdRef:d,applyWorktreesList:b,closeWorktree:P,createWorktree:A,handleSelectWorktree:C,loadMainWorktreeSnapshot:p,loadWorktreeSnapshot:y,requestWorktreeMessages:S,requestWorktreesList:k,renameWorktreeHandler:O,setActiveWorktreeId:g,setWorktrees:v,worktrees:m}}var EC={exports:{}};(function(e,t){(function(r,n){e.exports=n()})(globalThis,()=>(()=>{var r={4567:function(a,o,l){var c=this&&this.__decorate||function(f,p,y,S){var b,k=arguments.length,C=k<3?p:S===null?S=Object.getOwnPropertyDescriptor(p,y):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(f,p,y,S);else for(var A=f.length-1;A>=0;A--)(b=f[A])&&(C=(k<3?b(C):k>3?b(p,y,C):b(p,y))||C);return k>3&&C&&Object.defineProperty(p,y,C),C},h=this&&this.__param||function(f,p){return function(y,S){p(y,S,f)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const u=l(9042),m=l(9924),v=l(844),w=l(4725),_=l(2585),g=l(3656);let d=o.AccessibilityManager=class extends v.Disposable{constructor(f,p,y,S){super(),this._terminal=f,this._coreBrowserService=y,this._renderService=S,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let b=0;b<this._terminal.rows;b++)this._rowElements[b]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[b]);if(this._topBoundaryFocusListener=b=>this._handleBoundaryFocus(b,0),this._bottomBoundaryFocusListener=b=>this._handleBoundaryFocus(b,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new m.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize(b=>this._handleResize(b.rows))),this.register(this._terminal.onRender(b=>this._refreshRows(b.start,b.end))),this.register(this._terminal.onScroll(()=>this._refreshRows())),this.register(this._terminal.onA11yChar(b=>this._handleChar(b))),this.register(this._terminal.onLineFeed(()=>this._handleChar(`
692
692
  `))),this.register(this._terminal.onA11yTab(b=>this._handleTab(b))),this.register(this._terminal.onKey(b=>this._handleKey(b.key))),this.register(this._terminal.onBlur(()=>this._clearLiveRegion())),this.register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this.register((0,g.addDisposableDomListener)(document,"selectionchange",()=>this._handleSelectionChange())),this.register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRows(),this.register((0,v.toDisposable)(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(f){for(let p=0;p<f;p++)this._handleChar(" ")}_handleChar(f){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==f&&(this._charsToAnnounce+=f):this._charsToAnnounce+=f,f===`
693
693
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=u.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(f){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(f)||this._charsToConsume.push(f)}_refreshRows(f,p){this._liveRegionDebouncer.refresh(f,p,this._terminal.rows)}_renderRows(f,p){const y=this._terminal.buffer,S=y.lines.length.toString();for(let b=f;b<=p;b++){const k=y.lines.get(y.ydisp+b),C=[],A=(k==null?void 0:k.translateToString(!0,void 0,void 0,C))||"",P=(y.ydisp+b+1).toString(),O=this._rowElements[b];O&&(A.length===0?(O.innerText=" ",this._rowColumns.set(O,[0,1])):(O.textContent=A,this._rowColumns.set(O,C)),O.setAttribute("aria-posinset",P),O.setAttribute("aria-setsize",S))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(f,p){const y=f.target,S=this._rowElements[p===0?1:this._rowElements.length-2];if(y.getAttribute("aria-posinset")===(p===0?"1":`${this._terminal.buffer.lines.length}`)||f.relatedTarget!==S)return;let b,k;if(p===0?(b=y,k=this._rowElements.pop(),this._rowContainer.removeChild(k)):(b=this._rowElements.shift(),k=y,this._rowContainer.removeChild(b)),b.removeEventListener("focus",this._topBoundaryFocusListener),k.removeEventListener("focus",this._bottomBoundaryFocusListener),p===0){const C=this._createAccessibilityTreeNode();this._rowElements.unshift(C),this._rowContainer.insertAdjacentElement("afterbegin",C)}else{const C=this._createAccessibilityTreeNode();this._rowElements.push(C),this._rowContainer.appendChild(C)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(p===0?-1:1),this._rowElements[p===0?1:this._rowElements.length-2].focus(),f.preventDefault(),f.stopImmediatePropagation()}_handleSelectionChange(){var A;if(this._rowElements.length===0)return;const f=document.getSelection();if(!f)return;if(f.isCollapsed)return void(this._rowContainer.contains(f.anchorNode)&&this._terminal.clearSelection());if(!f.anchorNode||!f.focusNode)return void console.error("anchorNode and/or focusNode are null");let p={node:f.anchorNode,offset:f.anchorOffset},y={node:f.focusNode,offset:f.focusOffset};if((p.node.compareDocumentPosition(y.node)&Node.DOCUMENT_POSITION_PRECEDING||p.node===y.node&&p.offset>y.offset)&&([p,y]=[y,p]),p.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(p={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(p.node))return;const S=this._rowElements.slice(-1)[0];if(y.node.compareDocumentPosition(S)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(y={node:S,offset:((A=S.textContent)==null?void 0:A.length)??0}),!this._rowContainer.contains(y.node))return;const b=({node:P,offset:O})=>{const R=P instanceof Text?P.parentNode:P;let M=parseInt(R==null?void 0:R.getAttribute("aria-posinset"),10)-1;if(isNaN(M))return console.warn("row is invalid. Race condition?"),null;const z=this._rowColumns.get(R);if(!z)return console.warn("columns is null. Race condition?"),null;let U=O<z.length?z[O]:z.slice(-1)[0]+1;return U>=this._terminal.cols&&(++M,U=0),{row:M,column:U}},k=b(p),C=b(y);if(k&&C){if(k.row>C.row||k.row===C.row&&k.column>=C.column)throw new Error("invalid range");this._terminal.select(k.column,k.row,(C.row-k.row)*this._terminal.cols-k.column+C.column)}}_handleResize(f){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let p=this._rowContainer.children.length;p<this._terminal.rows;p++)this._rowElements[p]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[p]);for(;this._rowElements.length>f;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const f=this._coreBrowserService.mainDocument.createElement("div");return f.setAttribute("role","listitem"),f.tabIndex=-1,this._refreshRowDimensions(f),f}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let f=0;f<this._terminal.rows;f++)this._refreshRowDimensions(this._rowElements[f])}}_refreshRowDimensions(f){f.style.height=`${this._renderService.dimensions.css.cell.height}px`}};o.AccessibilityManager=d=c([h(1,_.IInstantiationService),h(2,w.ICoreBrowserService),h(3,w.IRenderService)],d)},3614:(a,o)=>{function l(m){return m.replace(/\r?\n/g,"\r")}function c(m,v){return v?"\x1B[200~"+m+"\x1B[201~":m}function h(m,v,w,_){m=c(m=l(m),w.decPrivateModes.bracketedPasteMode&&_.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(m,!0),v.value=""}function u(m,v,w){const _=w.getBoundingClientRect(),g=m.clientX-_.left-10,d=m.clientY-_.top-10;v.style.width="20px",v.style.height="20px",v.style.left=`${g}px`,v.style.top=`${d}px`,v.style.zIndex="1000",v.focus()}Object.defineProperty(o,"__esModule",{value:!0}),o.rightClickHandler=o.moveTextAreaUnderMouseCursor=o.paste=o.handlePasteEvent=o.copyHandler=o.bracketTextForPaste=o.prepareTextForTerminal=void 0,o.prepareTextForTerminal=l,o.bracketTextForPaste=c,o.copyHandler=function(m,v){m.clipboardData&&m.clipboardData.setData("text/plain",v.selectionText),m.preventDefault()},o.handlePasteEvent=function(m,v,w,_){m.stopPropagation(),m.clipboardData&&h(m.clipboardData.getData("text/plain"),v,w,_)},o.paste=h,o.moveTextAreaUnderMouseCursor=u,o.rightClickHandler=function(m,v,w,_,g){u(m,v,w),g&&_.rightClickSelect(m),v.value=_.selectionText,v.select()}},7239:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ColorContrastCache=void 0;const c=l(1505);o.ColorContrastCache=class{constructor(){this._color=new c.TwoKeyMap,this._css=new c.TwoKeyMap}setCss(h,u,m){this._css.set(h,u,m)}getCss(h,u){return this._css.get(h,u)}setColor(h,u,m){this._color.set(h,u,m)}getColor(h,u){return this._color.get(h,u)}clear(){this._color.clear(),this._css.clear()}}},3656:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.addDisposableDomListener=void 0,o.addDisposableDomListener=function(l,c,h,u){l.addEventListener(c,h,u);let m=!1;return{dispose:()=>{m||(m=!0,l.removeEventListener(c,h,u))}}}},3551:function(a,o,l){var c=this&&this.__decorate||function(d,f,p,y){var S,b=arguments.length,k=b<3?f:y===null?y=Object.getOwnPropertyDescriptor(f,p):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(d,f,p,y);else for(var C=d.length-1;C>=0;C--)(S=d[C])&&(k=(b<3?S(k):b>3?S(f,p,k):S(f,p))||k);return b>3&&k&&Object.defineProperty(f,p,k),k},h=this&&this.__param||function(d,f){return function(p,y){f(p,y,d)}};Object.defineProperty(o,"__esModule",{value:!0}),o.Linkifier=void 0;const u=l(3656),m=l(8460),v=l(844),w=l(2585),_=l(4725);let g=o.Linkifier=class extends v.Disposable{get currentLink(){return this._currentLink}constructor(d,f,p,y,S){super(),this._element=d,this._mouseService=f,this._renderService=p,this._bufferService=y,this._linkProviderService=S,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new m.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new m.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,v.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,v.toDisposable)(()=>{var b;this._lastMouseEvent=void 0,(b=this._activeProviderReplies)==null||b.clear()})),this.register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this.register((0,u.addDisposableDomListener)(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this.register((0,u.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,u.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,u.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(d){this._lastMouseEvent=d;const f=this._positionFromMouseEvent(d,this._element,this._mouseService);if(!f)return;this._isMouseOut=!1;const p=d.composedPath();for(let y=0;y<p.length;y++){const S=p[y];if(S.classList.contains("xterm"))break;if(S.classList.contains("xterm-hover"))return}this._lastBufferCell&&f.x===this._lastBufferCell.x&&f.y===this._lastBufferCell.y||(this._handleHover(f),this._lastBufferCell=f)}_handleHover(d){if(this._activeLine!==d.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(d,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,d)||(this._clearCurrentLink(),this._askForLink(d,!0))}_askForLink(d,f){var y,S;this._activeProviderReplies&&f||((y=this._activeProviderReplies)==null||y.forEach(b=>{b==null||b.forEach(k=>{k.link.dispose&&k.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=d.y);let p=!1;for(const[b,k]of this._linkProviderService.linkProviders.entries())f?(S=this._activeProviderReplies)!=null&&S.get(b)&&(p=this._checkLinkProviderResult(b,d,p)):k.provideLinks(d.y,C=>{var P,O;if(this._isMouseOut)return;const A=C==null?void 0:C.map(R=>({link:R}));(P=this._activeProviderReplies)==null||P.set(b,A),p=this._checkLinkProviderResult(b,d,p),((O=this._activeProviderReplies)==null?void 0:O.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(d.y,this._activeProviderReplies)})}_removeIntersectingLinks(d,f){const p=new Set;for(let y=0;y<f.size;y++){const S=f.get(y);if(S)for(let b=0;b<S.length;b++){const k=S[b],C=k.link.range.start.y<d?0:k.link.range.start.x,A=k.link.range.end.y>d?this._bufferService.cols:k.link.range.end.x;for(let P=C;P<=A;P++){if(p.has(P)){S.splice(b--,1);break}p.add(P)}}}}_checkLinkProviderResult(d,f,p){var b;if(!this._activeProviderReplies)return p;const y=this._activeProviderReplies.get(d);let S=!1;for(let k=0;k<d;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(S=!0);if(!S&&y){const k=y.find(C=>this._linkAtPosition(C.link,f));k&&(p=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!p)for(let k=0;k<this._activeProviderReplies.size;k++){const C=(b=this._activeProviderReplies.get(k))==null?void 0:b.find(A=>this._linkAtPosition(A.link,f));if(C){p=!0,this._handleNewLink(C);break}}return p}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(d){if(!this._currentLink)return;const f=this._positionFromMouseEvent(d,this._element,this._mouseService);f&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,f)&&this._currentLink.link.activate(d,this._currentLink.link.text)}_clearCurrentLink(d,f){this._currentLink&&this._lastMouseEvent&&(!d||!f||this._currentLink.link.range.start.y>=d&&this._currentLink.link.range.end.y<=f)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,v.disposeArray)(this._linkCacheDisposables))}_handleNewLink(d){if(!this._lastMouseEvent)return;const f=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);f&&this._linkAtPosition(d.link,f)&&(this._currentLink=d,this._currentLink.state={decorations:{underline:d.link.decorations===void 0||d.link.decorations.underline,pointerCursor:d.link.decorations===void 0||d.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,d.link,this._lastMouseEvent),d.link.decorations={},Object.defineProperties(d.link.decorations,{pointerCursor:{get:()=>{var p,y;return(y=(p=this._currentLink)==null?void 0:p.state)==null?void 0:y.decorations.pointerCursor},set:p=>{var y;(y=this._currentLink)!=null&&y.state&&this._currentLink.state.decorations.pointerCursor!==p&&(this._currentLink.state.decorations.pointerCursor=p,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",p))}},underline:{get:()=>{var p,y;return(y=(p=this._currentLink)==null?void 0:p.state)==null?void 0:y.decorations.underline},set:p=>{var y,S,b;(y=this._currentLink)!=null&&y.state&&((b=(S=this._currentLink)==null?void 0:S.state)==null?void 0:b.decorations.underline)!==p&&(this._currentLink.state.decorations.underline=p,this._currentLink.state.isHovered&&this._fireUnderlineEvent(d.link,p))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(p=>{if(!this._currentLink)return;const y=p.start===0?0:p.start+1+this._bufferService.buffer.ydisp,S=this._bufferService.buffer.ydisp+1+p.end;if(this._currentLink.link.range.start.y>=y&&this._currentLink.link.range.end.y<=S&&(this._clearCurrentLink(y,S),this._lastMouseEvent)){const b=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);b&&this._askForLink(b,!1)}})))}_linkHover(d,f,p){var y;(y=this._currentLink)!=null&&y.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(f,!0),this._currentLink.state.decorations.pointerCursor&&d.classList.add("xterm-cursor-pointer")),f.hover&&f.hover(p,f.text)}_fireUnderlineEvent(d,f){const p=d.range,y=this._bufferService.buffer.ydisp,S=this._createLinkUnderlineEvent(p.start.x-1,p.start.y-y-1,p.end.x,p.end.y-y-1,void 0);(f?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(S)}_linkLeave(d,f,p){var y;(y=this._currentLink)!=null&&y.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(f,!1),this._currentLink.state.decorations.pointerCursor&&d.classList.remove("xterm-cursor-pointer")),f.leave&&f.leave(p,f.text)}_linkAtPosition(d,f){const p=d.range.start.y*this._bufferService.cols+d.range.start.x,y=d.range.end.y*this._bufferService.cols+d.range.end.x,S=f.y*this._bufferService.cols+f.x;return p<=S&&S<=y}_positionFromMouseEvent(d,f,p){const y=p.getCoords(d,f,this._bufferService.cols,this._bufferService.rows);if(y)return{x:y[0],y:y[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(d,f,p,y,S){return{x1:d,y1:f,x2:p,y2:y,cols:this._bufferService.cols,fg:S}}};o.Linkifier=g=c([h(1,_.IMouseService),h(2,_.IRenderService),h(3,w.IBufferService),h(4,_.ILinkProviderService)],g)},9042:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.tooMuchOutput=o.promptLabel=void 0,o.promptLabel="Terminal input",o.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(a,o,l){var c=this&&this.__decorate||function(_,g,d,f){var p,y=arguments.length,S=y<3?g:f===null?f=Object.getOwnPropertyDescriptor(g,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(_,g,d,f);else for(var b=_.length-1;b>=0;b--)(p=_[b])&&(S=(y<3?p(S):y>3?p(g,d,S):p(g,d))||S);return y>3&&S&&Object.defineProperty(g,d,S),S},h=this&&this.__param||function(_,g){return function(d,f){g(d,f,_)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkProvider=void 0;const u=l(511),m=l(2585);let v=o.OscLinkProvider=class{constructor(_,g,d){this._bufferService=_,this._optionsService=g,this._oscLinkService=d}provideLinks(_,g){var A;const d=this._bufferService.buffer.lines.get(_-1);if(!d)return void g(void 0);const f=[],p=this._optionsService.rawOptions.linkHandler,y=new u.CellData,S=d.getTrimmedLength();let b=-1,k=-1,C=!1;for(let P=0;P<S;P++)if(k!==-1||d.hasContent(P)){if(d.loadCell(P,y),y.hasExtendedAttrs()&&y.extended.urlId){if(k===-1){k=P,b=y.extended.urlId;continue}C=y.extended.urlId!==b}else k!==-1&&(C=!0);if(C||k!==-1&&P===S-1){const O=(A=this._oscLinkService.getLinkData(b))==null?void 0:A.uri;if(O){const R={start:{x:k+1,y:_},end:{x:P+(C||P!==S-1?0:1),y:_}};let M=!1;if(!(p!=null&&p.allowNonHttpProtocols))try{const z=new URL(O);["http:","https:"].includes(z.protocol)||(M=!0)}catch{M=!0}M||f.push({text:O,range:R,activate:(z,U)=>p?p.activate(z,U,R):w(0,U),hover:(z,U)=>{var q;return(q=p==null?void 0:p.hover)==null?void 0:q.call(p,z,U,R)},leave:(z,U)=>{var q;return(q=p==null?void 0:p.leave)==null?void 0:q.call(p,z,U,R)}})}C=!1,y.hasExtendedAttrs()&&y.extended.urlId?(k=P,b=y.extended.urlId):(k=-1,b=-1)}}g(f)}};function w(_,g){if(confirm(`Do you want to navigate to ${g}?
694
694
 
@@ -703,9 +703,9 @@ WARNING: This link could potentially be dangerous`)){const d=window.open();if(d)
703
703
  `)})},[t,r,n,a,o,l,c,h,m]);x.useEffect(()=>{if(!n||e!=="terminal"||!i.current||o.current)return;const w=u==="dark",_=new RB.Terminal({fontFamily:'"Space Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:13,cursorBlink:!0,theme:{background:w?"#0f1110":"#fbf6ee",foreground:w?"#e6edf3":"#2a2418",cursor:w?"#e6edf3":"#2a2418",selection:w?"rgba(255, 255, 255, 0.2)":"rgba(20, 19, 17, 0.15)"}});typeof _.setOption!="function"&&(_.setOption=(d,f)=>{if(d&&typeof d=="object"){_.options=d;return}_.options={[d]:f}});const g=new OB.FitAddon;_.loadAddon(g),_.open(i.current),g.fit(),_.focus(),o.current=_,a.current=g,s.current=_.onData(d=>{const f=c.current;f&&f.readyState===WebSocket.OPEN&&f.send(JSON.stringify({type:"input",data:d}))})},[e,i,s,n,a,o,c,u]),x.useEffect(()=>{const w=o.current;if(!w)return;const _=u==="dark"?{background:"#15120d",foreground:"#f2e9dc",cursor:"#f2e9dc"}:{background:"#fbf6ee",foreground:"#2a2418",cursor:"#2a2418"};typeof w.setOption=="function"?w.setOption("theme",_):w.options={theme:_}},[o,u]),x.useEffect(()=>()=>{s.current&&(s.current.dispose(),s.current=null),o.current&&(o.current.dispose(),o.current=null),a.current=null},[s,a,o]),x.useEffect(()=>{if(e==="terminal"&&n){if(o.current){const w=u==="dark";o.current.setOption("theme",{background:w?"#0f1110":"#fbf6ee",foreground:w?"#e6edf3":"#2a2418",cursor:w?"#e6edf3":"#2a2418",selection:w?"rgba(255, 255, 255, 0.2)":"rgba(20, 19, 17, 0.15)"})}a.current&&requestAnimationFrame(()=>{const w=a.current,_=o.current;if(!w||!_)return;w.fit(),_.focus();const g=c.current;g&&g.readyState===WebSocket.OPEN&&g.send(JSON.stringify({type:"resize",cols:_.cols,rows:_.rows}))}),v()}},[e,v,n,a,o,c,u]),x.useEffect(()=>{const w=()=>{const _=o.current,g=a.current,d=c.current;!_||!g||(g.fit(),d&&d.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:"resize",cols:_.cols,rows:_.rows})))};return window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[a,o,c]),x.useEffect(()=>{!r&&c.current&&(c.current.close(),c.current=null,l.current=null,h.current=null)},[r,l,c,h]),x.useEffect(()=>{n||(c.current&&(c.current.close(),c.current=null),l.current=null,h.current=null,s.current&&(s.current.dispose(),s.current=null),o.current&&(o.current.dispose(),o.current=null),a.current=null)},[s,n,a,o,l,c,h])}function BB({notificationsEnabled:e,t}){const r=x.useRef(null),n=x.useRef(null),i=e,s=x.useCallback(async()=>{if(!("Notification"in window))return"unsupported";if(Notification.permission==="default")try{return await Notification.requestPermission()}catch{return Notification.permission}return Notification.permission},[]),a=x.useCallback(()=>{const h=window.AudioContext||window.webkitAudioContext;if(!h)return;let u=n.current;u||(u=new h,n.current=u),u.state==="suspended"&&u.resume().catch(()=>{})},[]),o=x.useCallback(()=>{if(!i)return;const h=window.AudioContext||window.webkitAudioContext;if(!h)return;let u=n.current;u||(u=new h,n.current=u),u.state==="suspended"&&u.resume().catch(()=>{});const m=u.createOscillator(),v=u.createGain();m.type="sine",m.frequency.value=740,v.gain.value=1e-4,v.gain.exponentialRampToValueAtTime(.12,u.currentTime+.01),v.gain.exponentialRampToValueAtTime(1e-4,u.currentTime+.25),m.connect(v).connect(u.destination),m.start(),m.stop(u.currentTime+.26)},[i]),l=x.useCallback(h=>{if(!h)return"";let u=String(h);const m=u.match(/<!--\s*vibe80:/i);return typeof(m==null?void 0:m.index)=="number"&&(u=u.slice(0,m.index)),u=u.replace(/```([\s\S]*?)```/g,"$1"),u=u.replace(/`([^`]+)`/g,"$1"),u=u.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,"$1"),u=u.replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1"),u=u.replace(/^\s{0,3}#{1,6}\s+/gm,""),u=u.replace(/^\s{0,3}>\s?/gm,""),u=u.replace(/^\s{0,3}[-*+]\s+/gm,""),u=u.replace(/^\s{0,3}\d+\.\s+/gm,""),u=u.replace(/[*_~]{1,3}/g,""),u=u.replace(/\s+/g," ").trim(),u},[]),c=x.useCallback(h=>{if(!e||!("Notification"in window)||Notification.permission!=="granted"||!(h!=null&&h.id)||r.current===h.id||!document.hidden)return;r.current=h.id;const u=l(h.text||"").slice(0,180);try{new Notification(t("New message"),{body:u})}catch{}o()},[e,o,l,t]);return x.useEffect(()=>{e&&(s(),a())},[s,a,e]),{ensureNotificationPermission:s,maybeNotify:c,lastNotifiedIdRef:r}}const FB=100,zB=e=>{var i;const t=String(e||"").trim();if(!t)return null;const r=t.slice(0,2);let n=t.slice(3).trim();if(!r||!n)return null;if((r.startsWith("R")||r.startsWith("C"))&&n.includes(" -> ")&&(n=((i=n.split(" -> ").pop())==null?void 0:i.trim())||n),n.startsWith('"')&&n.endsWith('"'))try{n=JSON.parse(n)}catch{}return{code:r,path:n}};function $B({apiFetch:e,attachmentSessionId:t,currentBranch:r,activeWorktreeId:n,parseDiff:i,setWorktrees:s,worktrees:a,t:o}){const[l,c]=x.useState({status:"",diff:""}),[h,u]=x.useState(null),[m,v]=x.useState([]),[w,_]=x.useState(!1),[g,d]=x.useState(new Map),f=x.useMemo(()=>{if(n&&n!=="main"){const R=a.get(n);return(R==null?void 0:R.diff)||{status:"",diff:""}}return l},[n,a,l]),p=x.useMemo(()=>{if(!f.diff)return[];try{return i(f.diff)}catch{return[]}},[f.diff,i]),y=x.useMemo(()=>(f.status||"").split(/\r?\n/).map(R=>R.trim()).filter(Boolean),[f.status]),S=x.useMemo(()=>y.map(zB).filter(Boolean),[y]),b=x.useMemo(()=>{const R=new Set,M=[];return S.forEach(z=>{if(z.code!=="??")return;const U=String(z.path||"").trim().replace(/\\/g,"/");!U||R.has(U)||(R.add(U),M.push(U))}),M},[S]),k=x.useMemo(()=>y.length>0||!!(f.diff||"").trim(),[y.length,f.diff]);x.useEffect(()=>{if(!t){v([]),_(!1);return}if(!b.length){v([]),_(!1);return}let R=!1;const M=n&&n!=="main"?n:"main";return(async()=>{_(!0);const U=[...b],q=new Set,Q=[];for(;U.length>0&&Q.length<FB&&!R;){const H=String(U.shift()||"").trim();if(!H||q.has(H))continue;if(q.add(H),!H.endsWith("/"))try{const L=await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees/${encodeURIComponent(M)}/file?path=${encodeURIComponent(H)}`);if(L.ok){const B=await L.json().catch(()=>({}));Q.push({path:H,binary:!!(B!=null&&B.binary),content:(B==null?void 0:B.content)||"",truncated:!!(B!=null&&B.truncated),error:!1});continue}}catch{}try{const L=await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees/${encodeURIComponent(M)}/browse?path=${encodeURIComponent(H)}`);if(!L.ok){Q.push({path:H,binary:!1,content:"",truncated:!1,error:!0});continue}const B=await L.json().catch(()=>({}));(Array.isArray(B==null?void 0:B.entries)?B.entries:[]).forEach(T=>{T!=null&&T.path&&U.push(T.path)})}catch{Q.push({path:H,binary:!1,content:"",truncated:!1,error:!0})}}R||(v(Q),_(!1))})(),()=>{R=!0}},[n,e,t,b]);const C=x.useCallback(async()=>{if(t)try{const R=await e(`/api/v1/sessions/${encodeURIComponent(t)}/last-commit`),M=await R.json().catch(()=>({}));if(!R.ok)throw new Error(M.error||o("Unable to load the latest commit."));const z=M.commit||{};u({branch:M.branch||"",sha:z.sha||"",message:z.message||""})}catch{u(null)}},[t,e,o]),A=x.useCallback(async R=>{if(!(!t||!R))try{const M=await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees/${encodeURIComponent(R)}/commits?limit=1`),z=await M.json().catch(()=>({}));if(!M.ok)throw new Error(z.error||o("Unable to load the commit."));const U=Array.isArray(z.commits)?z.commits[0]:null;if(!(U!=null&&U.sha))return;d(q=>{const Q=new Map(q);return Q.set(R,{sha:U.sha,message:U.message||""}),Q})}catch{}},[t,e,o]),P=x.useCallback(async R=>{if(!(!t||!R))try{const M=await e(`/api/v1/sessions/${encodeURIComponent(t)}/worktrees/${encodeURIComponent(R)}/diff`);if(!M.ok)return;const z=await M.json();if(!z)return;s(U=>{const q=new Map(U),Q=q.get(R);return Q&&q.set(R,{...Q,diff:{status:z.status||"",diff:z.diff||""}}),q})}catch{}},[t,e,s]),O=x.useCallback(async()=>{if(t)try{const R=await e(`/api/v1/sessions/${encodeURIComponent(t)}/diff`);if(!R.ok)return;const M=await R.json();if(!M)return;c({status:M.status||"",diff:M.diff||""})}catch{}},[t,e]);return x.useEffect(()=>{if(!t){u(null),d(new Map);return}C()},[t,C]),x.useEffect(()=>{t&&C()},[t,r,C]),{currentDiff:f,diffFiles:p,diffStatusLines:y,hasCurrentChanges:k,untrackedFilePanels:m,untrackedLoading:w,loadRepoLastCommit:C,loadWorktreeLastCommit:A,repoDiff:l,repoLastCommit:h,requestRepoDiff:O,requestWorktreeDiff:P,setRepoDiff:c,setRepoLastCommit:u,setWorktreeLastCommitById:d,worktreeLastCommitById:g}}function UB({attachmentSessionId:e,workspaceToken:t,normalizeAttachments:r,isImageAttachment:n,getAttachmentName:i,attachmentIcon:s,t:a}){const[o,l]=x.useState([]),[c,h]=x.useState(!1),[u,m]=x.useState(""),[v,w]=x.useState(null),_=x.useCallback(d=>{if(!e)return"";const f=new URL(`/api/v1/sessions/${encodeURIComponent(e)}/attachments/file`,window.location.origin);return t&&f.searchParams.set("token",t),d!=null&&d.path?f.searchParams.set("path",d.path):d!=null&&d.name&&f.searchParams.set("name",d.name),f.toString()},[e,t]),g=x.useCallback((d=[])=>{const f=r(d);return f.length?E.jsx("div",{className:"bubble-attachments",children:f.map(p=>{const y=i(p),S=_(p),b=(p==null?void 0:p.path)||(p==null?void 0:p.name)||y;return n(p)?E.jsxs("button",{type:"button",className:"attachment-card attachment-card--image",onClick:()=>S?w({url:S,name:y}):null,disabled:!S,children:[S?E.jsx("img",{src:S,alt:y||a("Attached image"),className:"attachment-thumb",loading:"lazy"}):E.jsx("div",{className:"attachment-thumb attachment-thumb--empty"}),E.jsx("span",{className:"attachment-name",children:y})]},b):S?E.jsxs("a",{className:"attachment-card",href:S,target:"_blank",rel:"noopener noreferrer",children:[E.jsx("span",{className:"attachment-icon","aria-hidden":"true",children:s}),E.jsx("span",{className:"attachment-name",children:y})]},b):E.jsxs("div",{className:"attachment-card",children:[E.jsx("span",{className:"attachment-icon","aria-hidden":"true",children:s}),E.jsx("span",{className:"attachment-name",children:y})]},b)})}):null},[i,_,n,r,a]);return x.useEffect(()=>{e||l([])},[e]),{attachmentPreview:v,attachmentsError:u,attachmentsLoading:c,draftAttachments:o,getAttachmentUrl:_,renderMessageAttachments:g,setAttachmentPreview:w,setAttachmentsError:m,setAttachmentsLoading:h,setDraftAttachments:l}}const U1=e=>{if(e==null||e==="")return null;const t=new Date(e);return Number.isFinite(t.getTime())?t.toISOString():null},H1=e=>!e||typeof e!="object"?e:{...e,createdAt:U1(e.createdAt),doneAt:U1(e.doneAt)};function HB({attachmentSessionId:e,apiFetch:t,normalizeAttachments:r,sendMessage:n,setInput:i,setMessages:s,setWorktrees:a,setDraftAttachments:o,input:l,draftAttachments:c,inputRef:h,showToast:u,t:m}){const[v,w]=x.useState([]),_=x.useMemo(()=>e?`backlog:${e}`:null,[e]);x.useEffect(()=>{if(_)try{const k=JSON.parse(localStorage.getItem(_)||"[]");w(Array.isArray(k)?k.map(H1).filter(Boolean):[])}catch{w([])}},[_]),x.useEffect(()=>{_&&localStorage.setItem(_,JSON.stringify(v))},[v,_]);const g=x.useCallback(k=>{s(C=>C.map(A=>{var R;if((A==null?void 0:A.type)!=="backlog_view")return A;const P=Array.isArray((R=A.backlog)==null?void 0:R.items)?A.backlog.items:[],O=k(P);return O===P?A:{...A,backlog:{...A.backlog||{},items:O}}})),a(C=>{const A=new Map(C);return A.forEach((P,O)=>{if(!Array.isArray(P==null?void 0:P.messages))return;let R=!1;const M=P.messages.map(z=>{var Q;if((z==null?void 0:z.type)!=="backlog_view")return z;const U=Array.isArray((Q=z.backlog)==null?void 0:Q.items)?z.backlog.items:[],q=k(U);return q===U?z:(R=!0,{...z,backlog:{...z.backlog||{},items:q}})});R&&A.set(O,{...P,messages:M})}),A})},[s,a]),d=x.useCallback((k,C,A)=>{if(k&&k!=="main"){a(P=>{const O=new Map(P),R=O.get(k);if(!R)return P;const M=R.messages.map(z=>(z==null?void 0:z.id)===C&&z.type==="backlog_view"?{...z,backlog:{...z.backlog||{},page:A}}:z);return O.set(k,{...R,messages:M}),O});return}s(P=>P.map(O=>(O==null?void 0:O.id)===C&&O.type==="backlog_view"?{...O,backlog:{...O.backlog||{},page:A}}:O))},[s,a]),f=x.useCallback(async k=>{if(!e){u==null||u(m("Session not found."),"error");return}try{const C=await t(`/api/v1/sessions/${encodeURIComponent(e)}/backlog-items/${encodeURIComponent(k)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({done:!0})});if(!C.ok){const O=await C.json().catch(()=>({}));throw new Error((O==null?void 0:O.error)||m("Unable to update backlog."))}const A=await C.json().catch(()=>({})),P=H1(A==null?void 0:A.item);g(O=>O.map(R=>(R==null?void 0:R.id)===k?{...R,...P,done:!0}:R))}catch(C){u==null||u(C.message||m("Unable to update backlog."),"error")}},[t,e,u,m,g]),p=x.useCallback(()=>{const k=l.trim();if(!k)return;const C={id:`backlog-${Date.now()}-${Math.random().toString(16).slice(2,8)}`,text:k,createdAt:new Date().toISOString(),attachments:c};w(A=>[C,...A]),i("")},[c,l,i]),y=x.useCallback(k=>{w(C=>C.filter(A=>A.id!==k))},[]),S=x.useCallback(k=>{var C;i(k.text||""),o(r(k.attachments||[])),(C=h==null?void 0:h.current)==null||C.focus()},[h,r,o,i]),b=x.useCallback(k=>{n(k.text||"",k.attachments||[]),y(k.id)},[y,n]);return{addToBacklog:p,backlog:v,markBacklogItemDone:f,removeFromBacklog:y,editBacklogItem:S,launchBacklogItem:b,setBacklog:w,setBacklogMessagePage:d,updateBacklogMessages:g}}function WB({activeProvider:e,activeWorktreeId:t,addToBacklog:r,apiFetch:n,attachmentSessionId:i,captureScreenshot:s,connected:a,handleSendMessageRef:o,handleViewSelect:l,input:c,isWorktreeStopped:h,isCodexReady:u,isInWorktree:m,openPathInExplorer:v,requestRepoDiff:w,requestWorktreeDiff:_,sendMessage:g,sendWorktreeMessage:d,buildAnnotatedMessage:f,clearScopedAnnotations:p,setAnnotationMode:y,setCommandMenuOpen:S,setDraftAttachments:b,setInput:k,setMessages:C,setWorktrees:A,socketRef:P,t:O,showToast:R}){const M=x.useCallback((z,U)=>{const q=(z??c).trim();if(!q)return;const Q=q.match(/^\/annotation\s+(on|off)\s*$/i);if(Q){const I=Q[1].toLowerCase()==="on";y(I),R(O(I?"Annotation mode enabled.":"Annotation mode disabled."),"info"),k(""),b([]),S(!1);return}if(q.startsWith("/annotation")){R(O("Usage: /annotation on|off"),"info");return}if(h){R(O("Worktree is stopped. Wake it up before sending a message."),"info");return}if(e==="codex"&&!u){R(O("Codex is starting. Please wait."),"info");return}if(q==="/diff"||q.startsWith("/diff ")){l("diff"),t&&t!=="main"?_(t):w(),k(""),b([]),S(!1);return}if(q.startsWith("/backlog")){if(!i){R(O("Session not found."),"error");return}(async()=>{try{const I=await n(`/api/v1/sessions/${encodeURIComponent(i)}/backlog-items`);if(!I.ok){const $=await I.json().catch(()=>null);throw new Error(($==null?void 0:$.error)||O("Unable to load backlog."))}const L=await I.json().catch(()=>({})),B=Array.isArray(L==null?void 0:L.items)?L.items:[],T={id:`backlog-${Date.now()}-${Math.random().toString(16).slice(2,8)}`,role:"assistant",type:"backlog_view",text:"Backlog",backlog:{items:B,page:0}};m&&t?A($=>{const Y=new Map($),W=Y.get(t);return W&&Y.set(t,{...W,messages:[...W.messages||[],T]}),Y}):C($=>[...$,T])}catch(I){R(I.message||O("Unable to load backlog."),"error")}})(),k(""),b([]),S(!1);return}if(q.startsWith("/open")){const I=q.replace(/^\/open\s*/i,"").trim();if(!I){R(O("Path required."),"error");return}v(I).then(()=>{k(""),b([]),S(!1)}).catch(()=>null);return}if(q.startsWith("/todo")){const I=q.replace(/^\/todo\s*/i,"").trim();if(!I){R(O("Todo text required."),"error");return}if(!i){R(O("Session not found."),"error");return}(async()=>{try{const L=await n(`/api/v1/sessions/${encodeURIComponent(i)}/backlog-items`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:I})});if(!L.ok){const B=await L.json().catch(()=>null);throw new Error((B==null?void 0:B.error)||O("Unable to update backlog."))}R(O("Added to backlog."))}catch(L){R(L.message||O("Unable to update backlog."),"error")}})(),k(""),b([]),S(!1);return}if(q.startsWith("/run")){const I=q.replace(/^\/run\s*/i,"").trim();if(!I){R(O("Command required."),"error");return}if(!P.current||!a){R(O("Disconnected"),"error");return}const L=m&&t?t:null;P.current.send(JSON.stringify({type:"action_request",request:"run",arg:I,worktreeId:L||void 0})),k(""),b([]),S(!1);return}if(q.startsWith("/screenshot")){s().then(()=>{k(""),S(!1)}).catch(()=>null);return}if(q.startsWith("/git")){const I=q.replace(/^\/git\s*/i,"").trim();if(!I){R(O("Git command required."),"error");return}if(!P.current||!a){R(O("Disconnected"),"error");return}const L=m&&t?t:null;P.current.send(JSON.stringify({type:"action_request",request:"git",arg:I,worktreeId:L||void 0})),k(""),b([]),S(!1);return}const H=f?f(q):q;m&&t?d(t,q,U,H):g(q,U,H),p==null||p()},[e,t,n,i,f,s,p,a,l,c,h,u,m,v,w,_,g,d,y,S,b,k,R,P,O]);return x.useEffect(()=>{o.current=M},[M,o]),{handleSendMessage:M}}function VB({apiFetch:e,attachmentSessionId:t,llmProvider:r,loadRepoLastCommit:n,processing:i,setBranchMenuOpen:s,socketRef:a,t:o}){const[l,c]=x.useState([]),[h,u]=x.useState(""),[m,v]=x.useState(""),[w,_]=x.useState(!1),[g,d]=x.useState(""),[f,p]=x.useState({}),[y,S]=x.useState([]),[b,k]=x.useState(""),[C,A]=x.useState(""),[P,O]=x.useState(!1),[R,M]=x.useState(""),z=x.useRef(""),U=x.useCallback(async()=>{if(t){O(!0),M("");try{const B=await e(`/api/v1/sessions/${encodeURIComponent(t)}/branches`),D=await B.json().catch(()=>({}));if(!B.ok)throw new Error(D.error||o("Unable to load branches."));S(Array.isArray(D.branches)?D.branches:[]),k(D.current||""),!z.current&&D.current&&(z.current=D.current,A(D.current))}catch(B){M(B.message||o("Unable to load branches."))}finally{O(!1)}}},[t,e,o]),q=x.useCallback(async B=>{if(!(!t||!B)){p(D=>({...D,[B]:{...(D==null?void 0:D[B])||{},loading:!0,error:""}}));try{const D=await e(`/api/v1/sessions/${encodeURIComponent(t)}/models?provider=${encodeURIComponent(B)}`),T=await D.json().catch(()=>({}));if(!D.ok)throw new Error(T.error||o("Unable to load models."));p($=>({...$,[B]:{models:Array.isArray(T.models)?T.models:[],loading:!1,error:""}}))}catch(D){p(T=>({...T,[B]:{...(T==null?void 0:T[B])||{},loading:!1,error:D.message||o("Unable to load models.")}}))}}},[t,e,o]);x.useEffect(()=>{if(!t){S([]),k(""),A(""),M(""),z.current="",p({});return}z.current="",A(""),p({}),U()},[t,U]),x.useEffect(()=>{t&&(n==null||n())},[t,b,n]);const Q=x.useCallback(()=>{!a.current||r!=="codex"||(_(!0),d(""),a.current.send(JSON.stringify({type:"model_list"})))},[r,a]),H=x.useCallback(B=>{const D=B.target.value;u(D),a.current&&(_(!0),d(""),a.current.send(JSON.stringify({type:"model_set",model:D,reasoningEffort:m||null})))},[m,a]),I=x.useCallback(B=>{const D=B.target.value;v(D),a.current&&(_(!0),d(""),a.current.send(JSON.stringify({type:"model_set",model:h||null,reasoningEffort:D||null})))},[h,a]),L=x.useCallback(async B=>{!t||i||(M(o("Branch switching is no longer supported.")),s&&s(!1))},[t,i,s,o]);return{branches:y,branchError:R,branchLoading:P,currentBranch:b,defaultBranch:C,handleBranchSelect:L,handleModelChange:H,handleReasoningEffortChange:I,loadBranches:U,loadProviderModels:q,modelError:g,modelLoading:w,models:l,providerModelState:f,requestModelList:Q,selectedModel:h,selectedReasoningEffort:m,setBranches:S,setCurrentBranch:k,setDefaultBranch:A,setModelError:d,setModelLoading:_,setModels:c,setProviderModelState:p,setSelectedModel:u,setSelectedReasoningEffort:v}}const KB=()=>new URLSearchParams(window.location.search).get("session");function GB({t:e,apiFetch:t,workspaceToken:r,handleLeaveWorkspace:n,repoUrl:i,setRepoUrl:s,repoInput:a,sessionNameInput:o,repoAuth:l,setRepoAuth:c,authMode:h,sshKeyInput:u,httpUsername:m,httpPassword:v,sessionMode:w,sessionRequested:_,setSessionRequested:g,defaultInternetAccess:d,defaultDenyGitCredentialsAccess:f,attachmentSession:p,setAttachmentSession:y,setAttachmentsLoading:S,setAttachmentsError:b,setWorkspaceToken:k,setWorkspaceMode:C,setWorkspaceError:A,setOpenAiLoginPending:P,setOpenAiLoginRequest:O}){x.useEffect(()=>{const z=KB();if(!z||!r||p!=null&&p.sessionId)return;(async()=>{try{g(!0),b("");const q=await t(`/api/v1/sessions/${encodeURIComponent(z)}`);if(!q.ok)throw new Error(e("Session not found."));const Q=await q.json();y(Q)}catch(q){b(q.message||e("Unable to resume the session.")),g(!1)}})()},[r,p==null?void 0:p.sessionId,t,n,y,b,g,e]),x.useEffect(()=>{if(!i||p!=null&&p.sessionId||w!=="new")return;(async()=>{try{S(!0),b("");const U={repoUrl:i,defaultInternetAccess:d,defaultDenyGitCredentialsAccess:f},q=o.trim();q&&(U.name=q),l&&(U.auth=l);const Q=await t("/api/v1/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(U)});if(!Q.ok){let I="",L="";try{const T=await Q.json();typeof(T==null?void 0:T.error)=="string"?I=T.error:typeof(T==null?void 0:T.message)=="string"?I=T.message:typeof T=="string"&&(I=T),typeof(T==null?void 0:T.error_type)=="string"&&(L=T.error_type)}catch{try{I=await Q.text()}catch{I=""}}if(Q.status===401&&(L==="WORKSPACE_TOKEN_INVALID"||typeof I=="string"&&I.toLowerCase().includes("invalid workspace token"))){k(""),C("existing"),A(e("Invalid workspace token. Please sign in again.")),b("");return}const D=I?`: ${I}`:"";throw Q.status===401||Q.status===403?new Error(e("Git authentication failed{{suffix}}.",{suffix:D})):Q.status===404?new Error(e("Git repository not found{{suffix}}.",{suffix:D})):new Error(e("Impossible de creer la session de pieces jointes (HTTP {{status}}{{statusText}}){{suffix}}.",{status:Q.status,statusText:Q.statusText?` ${Q.statusText}`:"",suffix:D}))}const H=await Q.json();y(H)}catch(U){b(U.message||e("Unable to create the attachment session.")),P(!1),O(null)}finally{S(!1),g(!1)}})()},[i,l,p==null?void 0:p.sessionId,t,w,d,f,o,y,b,S,P,O,g,A,C,k,e]),x.useEffect(()=>{if(!(p!=null&&p.sessionId))return;const z=new URL(window.location.href);z.searchParams.set("session",p.sessionId),window.history.replaceState({},"",z)},[p==null?void 0:p.sessionId]);const R=x.useCallback(async z=>{if(z)try{g(!0),b("");const U=await t(`/api/v1/sessions/${encodeURIComponent(z)}`);if(!U.ok)throw new Error(e("Session not found."));const q=await U.json();y(q)}catch(U){b(U.message||e("Unable to resume the session.")),g(!1)}},[t,y,b,g,e]),M=x.useCallback(z=>{z.preventDefault();const U=!!(p!=null&&p.sessionId),q=a.trim();if(!U&&!q){b("URL de depot git requise pour demarrer.");return}let Q=null;if(!U){if(h==="ssh"){const H=u.trim();if(!H){b("Cle SSH privee requise pour demarrer.");return}Q={type:"ssh",privateKey:H}}if(h==="http"){const H=m.trim();if(!H||!v){b(e("Username and password required."));return}Q={type:"http",username:H,password:v}}}b(""),U||(g(!0),c(Q),s(q))},[p==null?void 0:p.sessionId,h,v,m,a,b,c,s,g,u,e]);return{handleResumeSession:R,onRepoSubmit:M}}function qB({t:e,apiFetch:t,attachmentSessionId:r}){const[n,i]=x.useState(!1),[s,a]=x.useState(""),[o,l]=x.useState(null),[c,h]=x.useState(!1),[u,m]=x.useState(""),[v,w]=x.useState(null),_=(f,p)=>JSON.stringify({type:"vibe80_handoff",handoffToken:f,baseUrl:window.location.origin,expiresAt:p}),g=x.useCallback(async()=>{if(r){h(!0),m("");try{const f=await t("/api/v1/sessions/handoff",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:r})});if(!f.ok){const A=await f.json().catch(()=>({}));throw new Error((A==null?void 0:A.error)||e("Unable to generate the QR code."))}const p=await f.json(),y=p==null?void 0:p.handoffToken;if(!y)throw new Error(e("Invalid resume token."));const S=(p==null?void 0:p.expiresAt)??null,b=_(y,S),{default:k}=await wi(async()=>{const{default:A}=await import("./browser-e3WgtMs-.js").then(P=>P.b);return{default:A}},[]),C=await k.toDataURL(b,{width:260,margin:1});a(C),l(S),i(!0)}catch(f){m((f==null?void 0:f.message)||e("Error during generation."))}finally{h(!1)}}},[r,t,e]),d=x.useCallback(()=>{i(!1),m(""),a(""),l(null),w(null)},[]);return x.useEffect(()=>{if(!n||!o){w(null);return}const f=typeof o=="number"?o:new Date(o).getTime();if(!Number.isFinite(f)){w(null);return}const p=()=>{const S=f-Date.now(),b=Math.max(0,Math.ceil(S/1e3));w(b)};p();const y=setInterval(p,1e3);return()=>clearInterval(y)},[n,o]),{handoffOpen:n,handoffQrDataUrl:s,handoffExpiresAt:o,handoffLoading:c,handoffError:u,handoffRemaining:v,requestHandoffQr:g,closeHandoffQr:d}}function YB({t:e,apiFetch:t,attachmentSessionId:r}){const[n,i]=x.useState(""),[s,a]=x.useState(""),[o,l]=x.useState({name:"",email:""}),[c,h]=x.useState({name:"",email:""}),[u,m]=x.useState(!1),[v,w]=x.useState(!1),[_,g]=x.useState(""),[d,f]=x.useState(""),p=x.useCallback(async()=>{var S,b,k,C;if(r){m(!0),g(""),f("");try{const A=await t(`/api/v1/sessions/${encodeURIComponent(r)}/git-identity`);if(!A.ok)throw new Error(e("Unable to load Git identity."));const P=await A.json(),O=((S=P==null?void 0:P.global)==null?void 0:S.name)||"",R=((b=P==null?void 0:P.global)==null?void 0:b.email)||"",M=((k=P==null?void 0:P.repo)==null?void 0:k.name)||"",z=((C=P==null?void 0:P.repo)==null?void 0:C.email)||"";l({name:O,email:R}),h({name:M,email:z}),i(M||O),a(z||R)}catch(A){g((A==null?void 0:A.message)||e("Error during loading."))}finally{m(!1)}}},[r,t,e]),y=x.useCallback(async()=>{var k,C;if(!r)return;const S=n.trim(),b=s.trim();if(!S||!b){g(e("Name and email required."));return}w(!0),g(""),f("");try{const A=await t(`/api/v1/sessions/${encodeURIComponent(r)}/git-identity`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S,email:b})});if(!A.ok){const M=await A.json().catch(()=>({}));throw new Error((M==null?void 0:M.error)||e("Update failed."))}const P=await A.json().catch(()=>({})),O=((k=P==null?void 0:P.repo)==null?void 0:k.name)||S,R=((C=P==null?void 0:P.repo)==null?void 0:C.email)||b;h({name:O,email:R}),f(e("Repository Git identity updated."))}catch(A){g((A==null?void 0:A.message)||e("Update failed."))}finally{w(!1)}},[r,t,s,n,e]);return x.useEffect(()=>{r&&p()},[r,p]),{gitIdentityName:n,gitIdentityEmail:s,gitIdentityGlobal:o,gitIdentityRepo:c,gitIdentityLoading:u,gitIdentitySaving:v,gitIdentityError:_,gitIdentityMessage:d,setGitIdentityName:i,setGitIdentityEmail:a,loadGitIdentity:p,handleSaveGitIdentity:y}}function JB({t:e,choicesKey:t,input:r,setInput:n,handleSendMessageRef:i,draftAttachments:s,setDraftAttachments:a}){const[o,l]=x.useState({}),[c,h]=x.useState(null),[u,m]=x.useState({});x.useEffect(()=>{if(!t){l({});return}try{const p=JSON.parse(localStorage.getItem(t)||"{}");l(p&&typeof p=="object"&&!Array.isArray(p)?p:{})}catch{l({})}},[t]),x.useEffect(()=>{t&&localStorage.setItem(t,JSON.stringify(o))},[o,t]);const v=x.useCallback((p,y)=>{var b;if(!((b=p==null?void 0:p.fields)!=null&&b.length))return;const S={};p.fields.forEach(k=>{var C;k.type==="checkbox"?S[k.id]=!!k.defaultChecked:k.type==="radio"||k.type==="select"?S[k.id]=((C=k.choices)==null?void 0:C[0])||"":S[k.id]=k.defaultValue||""}),h({...p,key:y}),m(S)},[]),w=x.useCallback(()=>{h(null),m({})},[]),_=x.useCallback((p,y)=>{m(S=>({...S,[p]:y}))},[]),g=x.useCallback(p=>{var b;const y=r,S=s;(b=i.current)==null||b.call(i,p,[]),n(y),a(S)},[s,i,r,a,n]),d=x.useCallback(p=>{if(p==null||p.preventDefault(),!c)return;const y=c.fields.map(S=>{let b=u[S.id];return S.type==="checkbox"&&(b=b?"1":"0"),b==null&&(b=""),`${S.id}=${b}`});g(y.join(`
704
704
  `)),w()},[c,u,w,g]),f=x.useCallback((p,y,S)=>{var b;l(k=>({...k,[y]:S})),n(p),(b=i.current)==null||b.call(i,p)},[i,n]);return{choiceSelections:o,setChoiceSelections:l,activeForm:c,activeFormValues:u,openVibe80Form:v,closeVibe80Form:w,updateActiveFormValue:_,submitActiveForm:d,handleChoiceClick:f,setActiveForm:h,setActiveFormValues:m}}function XB({authMode:e,llmProvider:t,selectedProviders:r,openAiAuthMode:n,showChatCommands:i,showToolResults:s,notificationsEnabled:a,themeMode:o,repoHistory:l,debugMode:c,setLlmProvider:h,setOpenAiLoginError:u,setClaudeLoginError:m,AUTH_MODE_KEY:v,LLM_PROVIDER_KEY:w,LLM_PROVIDERS_KEY:_,OPENAI_AUTH_MODE_KEY:g,CHAT_COMMANDS_VISIBLE_KEY:d,TOOL_RESULTS_VISIBLE_KEY:f,NOTIFICATIONS_ENABLED_KEY:p,THEME_MODE_KEY:y,REPO_HISTORY_KEY:S,DEBUG_MODE_KEY:b}){x.useEffect(()=>{try{localStorage.setItem(v,e)}catch{}},[v,e]),x.useEffect(()=>{try{localStorage.setItem(w,t)}catch{}},[w,t]),x.useEffect(()=>{try{localStorage.setItem(_,JSON.stringify(r))}catch{}},[_,r]),x.useEffect(()=>{u(""),m("")},[t,m,u]),x.useEffect(()=>{if(r.includes(t))return;const k=r[0]||"codex";k!==t&&h(k)},[r,t,h]),x.useEffect(()=>{try{localStorage.setItem(g,n)}catch{}},[g,n]),x.useEffect(()=>{try{localStorage.setItem(d,i?"true":"false")}catch{}},[d,i]),x.useEffect(()=>{try{localStorage.setItem(f,s?"true":"false")}catch{}},[f,s]),x.useEffect(()=>{try{localStorage.setItem(p,a?"true":"false")}catch{}},[p,a]),x.useEffect(()=>{try{localStorage.setItem(y,o)}catch{}},[y,o]),x.useEffect(()=>{try{localStorage.setItem(S,JSON.stringify(l))}catch{}},[S,l]),x.useEffect(()=>{try{localStorage.setItem(b,c?"true":"false")}catch{}},[b,c])}function QB({themeMode:e,setSideOpen:t}){const[r,n]=x.useState(()=>window.matchMedia("(max-width: 1024px)").matches);return x.useEffect(()=>{const i=window.matchMedia("(max-width: 1024px)"),s=()=>n(i.matches);return s(),i.addEventListener?(i.addEventListener("change",s),()=>i.removeEventListener("change",s)):(i.addListener(s),()=>i.removeListener(s))},[]),x.useEffect(()=>{document.documentElement.dataset.theme=e},[e]),x.useEffect(()=>{r&&t(!1)},[r,t]),{isMobileLayout:r}}function ZB({rpcLogs:e,activeWorktreeId:t,locale:r,logFilterByTab:n,setLogFilterByTab:i}){const s=n[t]||"all",a=x.useCallback(h=>{const u=t||"main";i(m=>({...m,[u]:h}))},[t]),o=x.useMemo(()=>t&&t!=="main"?(e||[]).filter(h=>(h==null?void 0:h.worktreeId)===t):(e||[]).filter(h=>!(h!=null&&h.worktreeId)),[e,t]),l=x.useMemo(()=>o.map(h=>({...h,timeLabel:h!=null&&h.timestamp?new Date(h.timestamp).toLocaleTimeString(r):""})),[o,r]),c=x.useMemo(()=>s==="stdin"?l.filter(h=>h.direction==="stdin"):s==="stdout"?l.filter(h=>h.direction==="stdout"):l,[l,s]);return{logFilterByTab:n,setLogFilterByTab:i,logFilter:s,setLogFilter:a,scopedRpcLogs:o,formattedRpcLogs:l,filteredRpcLogs:c}}function e9(){const[e,t]=x.useState(!1),r=x.useRef(null);return x.useEffect(()=>{if(!e)return;const n=i=>{var a;const s=i.target;(a=r.current)!=null&&a.contains(s)||t(!1)};return document.addEventListener("pointerdown",n),()=>document.removeEventListener("pointerdown",n)},[e]),{toolbarExportOpen:e,setToolbarExportOpen:t,toolbarExportRef:r}}function t9(){const[e,t]=x.useState({}),[r,n]=x.useState({});return{commandPanelOpen:e,setCommandPanelOpen:t,toolResultPanelOpen:r,setToolResultPanelOpen:n}}function r9({activePane:e,activeWorktreeId:t,debugMode:r,rpcLogsEnabled:n,terminalEnabled:i,setPaneByTab:s,setToolbarExportOpen:a,lastPaneByTabRef:o}){const l=x.useCallback(u=>{if((!r||!n)&&u==="logs"||!i&&u==="terminal")return;const m=t||"main";s(v=>({...v,[m]:u})),a(!1)},[t,r,n,s,a,i]),c=x.useCallback(()=>{if(e!=="settings"){const u=t||"main";o.current.set(u,e)}l("settings")},[e,t,l,o]),h=x.useCallback(()=>{const u=t||"main",m=o.current.get(u);l(m&&m!=="settings"?m:"chat")},[t,l,o]);return x.useEffect(()=>{(!r||!n)&&e==="logs"&&l("chat")},[e,r,l,n]),x.useEffect(()=>{!i&&e==="terminal"&&l("chat")},[e,l,i]),{handleViewSelect:l,handleOpenSettings:c,handleSettingsBack:h}}function n9({setAttachmentSession:e,setRepoUrl:t,setRepoInput:r,setRepoAuth:n,setSessionRequested:i,setAttachmentsError:s,setAttachmentsLoading:a,setMessages:o,setRepoDiff:l,setRpcLogs:c,setRpcLogsEnabled:h,setRepoLastCommit:u,setWorktreeLastCommitById:m,setCurrentTurnId:v,setActivity:w,setDefaultDenyGitCredentialsAccess:_}){return{handleLeaveSession:x.useCallback(()=>{e(null),t(""),r(""),n(null),i(!1),s(""),a(!1),o([]),l({status:"",diff:""}),c([]),h(!0),u(null),m(new Map),v(null),w(""),typeof _=="function"&&_(!1);const d=new URL(window.location.href);d.searchParams.delete("session"),window.history.replaceState({},"",d)},[w,e,s,a,v,o,n,l,r,u,t,c,h,i,_,m])}}function i9({activeWorktreeId:e,isInWorktree:t,currentTurnIdForActive:r,socketRef:n,setWorktrees:i,setActivity:s}){return{interruptTurn:x.useCallback(()=>{if(!r||!n.current)return;const o={type:"turn_interrupt",turnId:r,worktreeId:t&&e?e:void 0};if(n.current.send(JSON.stringify(o)),t&&e){i(l=>{const c=new Map(l),h=c.get(e);return h&&c.set(e,{...h,activity:"Interruption..."}),c});return}s("Interruption...")},[e,r,t,s,i,n])}}function s9({activeWorktreeId:e,handleViewSelect:t,requestWorktreeDiff:r,requestRepoDiff:n}){return{handleDiffSelect:x.useCallback(()=>{t("diff"),e&&e!=="main"?r(e):n()},[e,t,n,r])}}function o9({activeChatKey:e,displayedGroupedMessages:t,CHAT_COLLAPSE_THRESHOLD:r,CHAT_COLLAPSE_VISIBLE:n}){const[i,s]=x.useState({}),a=!!i[e],o=x.useMemo(()=>{const l=t.length;if(!(!a&&l>r))return{visibleMessages:t,hiddenCount:0,isCollapsed:!1};const h=t.slice(Math.max(0,l-n));return{visibleMessages:h,hiddenCount:Math.max(0,l-h.length),isCollapsed:!0}},[t,a,r,n]);return{showOlderMessagesByTab:i,setShowOlderMessagesByTab:s,showOlderMessages:a,collapsedMessages:o}}function a9({attachmentSessionId:e,apiFetch:t,llmProvider:r,setLlmProvider:n,setSelectedProviders:i,setOpenAiReady:s,setClaudeReady:a,setRepoDiff:o,setRpcLogsEnabled:l,setRpcLogs:c,setTerminalEnabled:h,loadMainWorktreeSnapshot:u}){return{resyncSession:x.useCallback(async()=>{if(e)try{const v=await t(`/api/v1/sessions/${encodeURIComponent(e)}`);if(!v.ok)return;const w=await v.json();if(w!=null&&w.defaultProvider&&w.defaultProvider!==r&&n(w.defaultProvider),Array.isArray(w==null?void 0:w.providers)&&w.providers.length){const _=w.providers.filter(g=>g==="codex"||g==="claude");_.length&&(i(_),s(_.includes("codex")),a(_.includes("claude")))}w!=null&&w.repoDiff&&o(w.repoDiff),typeof(w==null?void 0:w.rpcLogsEnabled)=="boolean"&&(l(w.rpcLogsEnabled),w.rpcLogsEnabled||c([])),Array.isArray(w==null?void 0:w.rpcLogs)&&(w==null?void 0:w.rpcLogsEnabled)!==!1&&c(w.rpcLogs),typeof(w==null?void 0:w.terminalEnabled)=="boolean"&&h(w.terminalEnabled),u()}catch{}},[e,t,r,u,a,n,s,o,c,l,i,h])}}function l9({socketRef:e,messagesRef:t}){return{requestMessageSync:x.useCallback(()=>{const n=e.current;if(!n||n.readyState!==WebSocket.OPEN)return;const i=(()=>{var s;if(!Array.isArray(t.current))return null;for(let a=t.current.length-1;a>=0;a-=1)if((s=t.current[a])!=null&&s.id)return t.current[a].id;return null})();n.send(JSON.stringify({type:"worktree_messages_sync",worktreeId:"main",lastSeenMessageId:i}))},[t,e])}}function c9({normalizeAttachments:e,messageIndex:t,commandIndex:r,messagesRef:n,setMessages:i,setCommandPanelOpen:s,setToolResultPanelOpen:a}){const o=x.useCallback((c=[])=>{const h=c.map((u,m)=>({...u,id:u.id||`history-${m}`,role:u.role,text:u.text,toolResult:u.toolResult,attachments:e(u.attachments||[])}));t.clear(),r.clear(),h.forEach((u,m)=>{u.role==="assistant"&&t.set(u.id,m)}),i(h),s({}),a({})},[r,t,e,s,i,a]),l=x.useCallback((c=[])=>{if(!Array.isArray(c)||c.length===0)return;const h=Array.isArray(n.current)?n.current:[],u=new Set(h.map(v=>v==null?void 0:v.id).filter(Boolean)),m=[...h];for(const v of c){const w=v==null?void 0:v.id;w&&u.has(w)||(w&&u.add(w),m.push(v))}o(m)},[o,n]);return{applyMessages:o,mergeAndApplyMessages:l}}function u9({closeConfirm:e,setCloseConfirm:t,setActiveWorktreeId:r,activeWorktreeIdRef:n,closeWorktree:i}){const s=x.useCallback(l=>{!l||l==="main"||t({worktreeId:l})},[t]),a=x.useCallback(()=>{t(null)},[t]),o=x.useCallback(async()=>{e!=null&&e.worktreeId&&(n.current===e.worktreeId&&r("main"),await i(e.worktreeId),t(null))},[n,e,i,r,t]);return{openCloseConfirm:s,closeCloseConfirm:a,handleConfirmDelete:o}}function f9({activeWorktreeId:e,setRpcLogs:t}){return{handleClearRpcLogs:x.useCallback(()=>{t(n=>e&&e!=="main"?n.filter(i=>(i==null?void 0:i.worktreeId)!==e):n.filter(i=>!!(i!=null&&i.worktreeId)))},[e,t])}}const h9=e=>{const r=String(e||"").replace(/\\/g,"/").split("/").filter(Boolean);return r.length?r[r.length-1]:""},so=e=>{const r=String(e||"").replace(/\\/g,"/").split("/").filter(Boolean);return r.length<=1?"":r.slice(0,-1).join("/")},qf=(e,t)=>e?`${e}/${t}`:t,yl=(e,t,r)=>!e||typeof e!="string"?e:e===t?r:e.startsWith(`${t}/`)?`${r}${e.slice(t.length)}`:e;function d9({attachmentSessionId:e,apiFetch:t,t:r,setExplorerByTab:n,explorerDefaultState:i,explorerRef:s,activeWorktreeId:a,handleViewSelect:o,showToast:l,requestExplorerTreeRef:c,requestExplorerStatusRef:h,loadExplorerFileRef:u}){const m=x.useCallback((D,T)=>{n($=>{const Y=$[D]||i;return{...$,[D]:{...i,...Y,...T}}})},[i,n]),v=x.useCallback((D,T)=>{if(!Array.isArray(D))return null;for(const $ of D){if(($==null?void 0:$.path)===T)return $;if(($==null?void 0:$.type)==="dir"&&Array.isArray($.children)){const Y=v($.children,T);if(Y)return Y}}return null},[]),w=x.useCallback((D,T,$)=>{if(!Array.isArray(D))return D;let Y=!1;const W=D.map(j=>{if(!j)return j;if(j.path===T)return Y=!0,{...j,children:$};if(j.type==="dir"&&j.children!=null){const N=w(j.children,T,$);if(N!==j.children)return Y=!0,{...j,children:N}}return j});return Y?W:D},[]),_=x.useCallback((D,T,$)=>{n(Y=>{const W=Y[D]||i,j=Array.isArray(W.tree)?W.tree:[],N=w(j,T,$);return N===j?Y:{...Y,[D]:{...i,...W,tree:N}}})},[i,n,w]),g=x.useCallback(async(D,T)=>{if(!e||!D)return[];const $=await t(`/api/v1/sessions/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(D)}/browse${T?`?path=${encodeURIComponent(T)}`:""}`);if(!$.ok)throw new Error("Failed to load directory");const Y=await $.json().catch(()=>({})),j=(Array.isArray(Y==null?void 0:Y.entries)?Y.entries:[]).map(N=>({...N,children:(N==null?void 0:N.type)==="dir"?(N==null?void 0:N.children)??null:void 0}));return T?_(D,T,j):m(D,{tree:j,loading:!1,error:"",treeTruncated:!1,treeTotal:j.length}),j},[e,t,_,m]),d=x.useCallback(D=>D?D.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/\/+$/,"").replace(/\/+/g,"/"):"",[]),f=x.useCallback((D,T)=>{if(!T)return;const $=T.split("/").filter(Boolean),Y=[];let W="";$.forEach(j=>{W=W?`${W}/${j}`:j,Y.push(W)}),m(D,{expandedPaths:Y})},[m]),p=x.useCallback((D,T,$)=>{!D||!T||m(D,{selectedPath:T,selectedType:$||null})},[m]),y=x.useCallback(async(D,T=!1)=>{var Y;if(!e||!D)return;const $=s.current[D];if(!(!T&&($!=null&&$.tree)&&!($!=null&&$.error))&&!($!=null&&$.loading)){m(D,{loading:!0,error:""});try{if(await g(D,""),T){const W=Array.isArray((Y=s.current[D])==null?void 0:Y.expandedPaths)?s.current[D].expandedPaths:[],j=Array.from(new Set(W.filter(N=>typeof N=="string"&&N.length>0)));for(const N of j)await g(D,N)}}catch{m(D,{loading:!1,error:r("Unable to load the explorer.")})}}},[e,s,m,g,r]),S=x.useCallback(async(D,T=!1)=>{if(!e||!D)return;const $=s.current[D];if(!(!T&&($!=null&&$.statusLoaded)&&!($!=null&&$.statusError))&&!($!=null&&$.statusLoading)){m(D,{statusLoading:!0,statusError:""});try{const Y=await t(`/api/v1/sessions/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(D)}/status`);if(!Y.ok)throw new Error("Failed to load status");const W=await Y.json(),j=Array.isArray(W==null?void 0:W.entries)?W.entries:[],N={};j.forEach(G=>{!(G!=null&&G.path)||!(G!=null&&G.type)||(N[G.path]=G.type)}),m(D,{statusByPath:N,statusLoading:!1,statusError:"",statusLoaded:!0})}catch{m(D,{statusLoading:!1,statusError:r("Unable to load Git status."),statusLoaded:!1})}}},[e,s,m,t,r]),b=x.useCallback(async(D,T,$=!1)=>{var N;if(!e||!D||!T)return;const Y=s.current[D]||i,W=Array.isArray(Y.openTabPaths)?Y.openTabPaths:[],j=(N=Y.filesByPath)==null?void 0:N[T];if(n(G=>{var le;const V=G[D]||i,X=Array.isArray(V.openTabPaths)?V.openTabPaths:[],ne=X.includes(T)?X:[...X,T],ue=((le=V.filesByPath)==null?void 0:le[T])||{},ve=$||ue.content==null;return{...G,[D]:{...i,...V,openTabPaths:ne,activeFilePath:T,selectedPath:T,selectedType:"file",editMode:!0,filesByPath:{...V.filesByPath||{},[T]:{...ue,path:T,loading:ve,error:"",saveError:"",saving:!1,binary:ve?!1:!!ue.binary}}}}}),!(!$&&W.includes(T)&&(j==null?void 0:j.content)!=null))try{const G=await t(`/api/v1/sessions/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(D)}/file?path=${encodeURIComponent(T)}`);if(!G.ok)throw new Error("Failed to load file");const V=await G.json(),X=(V==null?void 0:V.content)||"";n(ne=>{var le;const ue=ne[D]||i,ve=((le=ue.filesByPath)==null?void 0:le[T])||{};return{...ne,[D]:{...i,...ue,filesByPath:{...ue.filesByPath||{},[T]:{...ve,path:T,content:X,draftContent:X,loading:!1,error:"",truncated:!!(V!=null&&V.truncated),binary:!!(V!=null&&V.binary),isDirty:!1}}}}})}catch{n(G=>{var ne;const V=G[D]||i,X=((ne=V.filesByPath)==null?void 0:ne[T])||{};return{...G,[D]:{...i,...V,filesByPath:{...V.filesByPath||{},[T]:{...X,path:T,loading:!1,error:r("Unable to load the file.")}}}}})}},[e,i,s,n,r,t]),k=x.useCallback(D=>{var $;if(!D)return;const T=a||"main";o("explorer"),y(T),S(T),($=u.current)==null||$.call(u,T,D)},[a,o,y,S,u]),C=x.useCallback(async D=>{var G,V,X,ne,ue,ve;const T=a||"main";if(!e){l(r("Session not found."),"error");return}const $=d(D);if(!$){l(r("Path required."),"error");return}let Y=(G=s.current[T])==null?void 0:G.tree;if(!Array.isArray(Y)||Y.length===0)try{await g(T,""),Y=(V=s.current[T])==null?void 0:V.tree}catch{l(r("Unable to load directory."),"error");return}const W=$.split("/").filter(Boolean);let j="",N=null;for(const le of W){const Se=j?`${j}/${le}`:le;if(N=v(Y,Se),!N){l(r("Path not found."),"error");return}if(N.type==="dir"&&N.children===null)try{if(await g(T,N.path),Y=(X=s.current[T])==null?void 0:X.tree,N=v(Y,Se),!N){l(r("Path not found."),"error");return}}catch{l(r("Unable to load directory."),"error");return}j=Se}if(!N){l(r("Path not found."),"error");return}o("explorer"),(ne=c.current)==null||ne.call(c,T),(ue=h.current)==null||ue.call(h,T),p(T,N.path,N.type),N.type==="dir"?f(T,N.path):(ve=u.current)==null||ve.call(u,T,N.path)},[a,e,o,c,h,d,g,v,u,p,f,s,l,r]),A=x.useCallback((D,T)=>{if(!D||!T)return;const $=s.current[D]||i,W=!new Set($.expandedPaths||[]).has(T);n(j=>{const N=j[D]||i,G=new Set(N.expandedPaths||[]);return G.has(T)?G.delete(T):G.add(T),{...j,[D]:{...i,...N,expandedPaths:Array.from(G)}}}),W&&g(D,T).catch(()=>{m(D,{error:r("Unable to load the explorer.")})})},[s,i,n,g,m,r]),P=x.useCallback((D,T,$)=>{var W,j,N,G;if(!D)return;const Y=T||((j=(W=s.current)==null?void 0:W[D])==null?void 0:j.activeFilePath)||((G=(N=s.current)==null?void 0:N[D])==null?void 0:G.selectedPath);Y&&n(V=>{var ve;const X=V[D]||i,ne=(ve=X.filesByPath)==null?void 0:ve[Y];if(!ne)return V;const ue=$??"";return{...V,[D]:{...i,...X,filesByPath:{...X.filesByPath||{},[Y]:{...ne,draftContent:ue,isDirty:ue!==(ne.content||""),saveError:""}}}}})},[s,i,n]),O=x.useCallback(async(D,T)=>{var j,N;if(!e||!D)return;const $=(j=s.current)==null?void 0:j[D],Y=T||($==null?void 0:$.activeFilePath)||($==null?void 0:$.selectedPath),W=Y?(N=$==null?void 0:$.filesByPath)==null?void 0:N[Y]:null;if(!(!Y||!W||W.binary)){n(G=>{var ne;const V=G[D]||i,X=(ne=V.filesByPath)==null?void 0:ne[Y];return X?{...G,[D]:{...i,...V,filesByPath:{...V.filesByPath||{},[Y]:{...X,saving:!0,saveError:""}}}}:G});try{if(!(await t(`/api/v1/sessions/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(D)}/file`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Y,content:W.draftContent||""})})).ok)throw new Error("Failed to save file");n(V=>{var ue;const X=V[D]||i,ne=(ue=X.filesByPath)==null?void 0:ue[Y];return ne?{...V,[D]:{...i,...X,filesByPath:{...X.filesByPath||{},[Y]:{...ne,content:ne.draftContent||"",saving:!1,saveError:"",isDirty:!1}}}}:V}),S(D,!0)}catch{n(G=>{var ne;const V=G[D]||i,X=(ne=V.filesByPath)==null?void 0:ne[Y];return X?{...G,[D]:{...i,...V,filesByPath:{...V.filesByPath||{},[Y]:{...X,saving:!1,saveError:r("Unable to save the file.")}}}}:G})}}},[e,s,i,n,S,t,r]),R=x.useCallback((D,T)=>{!D||!T||m(D,{activeFilePath:T,selectedPath:T,selectedType:"file"})},[m]),M=x.useCallback((D,T)=>{var j,N;if(!D||!T)return;const $=((j=s.current)==null?void 0:j[D])||i;if(!(Array.isArray($.openTabPaths)?$.openTabPaths:[]).includes(T))return;const W=(N=$.filesByPath)==null?void 0:N[T];W!=null&&W.isDirty&&!window.confirm(r("You have unsaved changes. Continue without saving?"))||n(G=>{const V=G[D]||i,X=Array.isArray(V.openTabPaths)?V.openTabPaths:[],ne=X.indexOf(T);if(ne<0)return G;const ue=X.filter(Se=>Se!==T),ve={...V.filesByPath||{}};delete ve[T];let le=V.activeFilePath||null;return le===T&&(le=ue[ne-1]||ue[ne]||ue[ue.length-1]||null),{...G,[D]:{...i,...V,openTabPaths:ue,filesByPath:ve,activeFilePath:le,selectedPath:le,selectedType:le?"file":null,editMode:!!le}}})},[s,i,n,r]),z=x.useCallback(D=>{var Y;if(!D)return!1;const $=(((Y=s.current)==null?void 0:Y[D])||i).selectedPath;return $?(m(D,{renamingPath:$,renameDraft:h9($)}),!0):!1},[s,i,m]),U=x.useCallback(D=>{D&&m(D,{renamingPath:null,renameDraft:""})},[m]),q=x.useCallback((D,T)=>{D&&m(D,{renameDraft:T??""})},[m]),Q=x.useCallback(async D=>{var j;if(!e||!D)return!1;const T=((j=s.current)==null?void 0:j[D])||i,$=T.renamingPath,Y=(T.renameDraft||"").trim();if(!$||!Y)return U(D),!1;if(Y.includes("/"))return l(r("Path required."),"error"),!1;const W=qf(so($),Y);if(!W||W===$)return U(D),!1;try{if(!(await t(`/api/v1/sessions/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(D)}/file/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fromPath:$,toPath:W})})).ok)throw new Error("Failed to rename path");return n(G=>{const V=G[D]||i,X=Array.from(new Set((V.openTabPaths||[]).map(ue=>yl(ue,$,W)))),ne={};return Object.entries(V.filesByPath||{}).forEach(([ue,ve])=>{ne[yl(ue,$,W)]=ve}),{...G,[D]:{...i,...V,openTabPaths:X,filesByPath:ne,activeFilePath:yl(V.activeFilePath,$,W),selectedPath:yl(V.selectedPath,$,W),renamingPath:null,renameDraft:""}}}),await y(D,!0),await S(D,!0),l(r("Renamed."),"success"),!0}catch{return l(r("Unable to rename."),"error"),!1}},[e,s,i,n,t,y,S,U,l,r]),H=x.useCallback(async(D,T)=>{var V;if(!e||!D)return!1;const $=d(T||"");if(!$)return l(r("Path required."),"error"),!1;const Y=((V=s.current)==null?void 0:V[D])||i,W=Y.selectedPath||"",j=Y.selectedType||null,N=j==="dir"?W:j==="file"?so(W):"",G=qf(N,$);try{if(!(await t(`/api/v1/sessions/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(D)}/file`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:G,content:""})})).ok)throw new Error("Failed to create file");return await y(D,!0),await S(D,!0),await b(D,G,!0),l(r("File created."),"success"),!0}catch{return l(r("Unable to create file."),"error"),!1}},[e,s,i,d,y,S,b,t,l,r]),I=x.useCallback(async(D,T)=>{var V;if(!e||!D)return!1;const $=d(T||"");if(!$)return l(r("Path required."),"error"),!1;const Y=((V=s.current)==null?void 0:V[D])||i,W=Y.selectedPath||"",j=Y.selectedType||null,N=j==="dir"?W:j==="file"?so(W):"",G=qf(N,$);try{if(!(await t(`/api/v1/sessions/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(D)}/folder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:G})})).ok)throw new Error("Failed to create folder");return await y(D,!0),await S(D,!0),l(r("Folder created."),"success"),!0}catch{return l(r("Unable to create folder."),"error"),!1}},[e,d,s,i,t,y,S,l,r]),L=x.useCallback(async D=>{var W;if(!e||!D)return!1;const $=(((W=s.current)==null?void 0:W[D])||i).selectedPath||"";if(!$||!window.confirm(r('Delete "{{path}}"? This action is irreversible.',{path:$})))return!1;m(D,{deletingPath:$});try{if(!(await t(`/api/v1/sessions/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(D)}/file/delete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:$})})).ok)throw new Error("Failed to delete path");return n(N=>{const G=N[D]||i,V=(G.openTabPaths||[]).filter(ue=>ue!==$&&!ue.startsWith(`${$}/`)),X={};Object.entries(G.filesByPath||{}).forEach(([ue,ve])=>{ue===$||ue.startsWith(`${$}/`)||(X[ue]=ve)});const ne=G.activeFilePath===$||String(G.activeFilePath||"").startsWith(`${$}/`)?V[V.length-1]||null:G.activeFilePath;return{...N,[D]:{...i,...G,openTabPaths:V,filesByPath:X,activeFilePath:ne,selectedPath:so($)||ne,selectedType:so($)?"dir":ne?"file":null,renamingPath:null,renameDraft:"",deletingPath:null}}}),await y(D,!0),await S(D,!0),l(r("Deleted."),"success"),!0}catch{return m(D,{deletingPath:null}),l(r("Unable to delete."),"error"),!1}},[e,s,i,n,m,y,S,t,l,r]),B=x.useCallback((D,T)=>{D&&m(D,{editMode:T})},[m]);return x.useEffect(()=>{c.current=y},[y,c]),x.useEffect(()=>{h.current=S},[S,h]),x.useEffect(()=>{u.current=b},[b,u]),{updateExplorerState:m,selectExplorerNode:p,openPathInExplorer:C,requestExplorerTree:y,requestExplorerStatus:S,loadExplorerFile:b,openFileInExplorer:k,setActiveExplorerFile:R,closeExplorerFile:M,toggleExplorerDir:A,toggleExplorerEditMode:B,updateExplorerDraft:P,saveExplorerFile:O,startExplorerRename:z,cancelExplorerRename:U,updateExplorerRenameDraft:q,submitExplorerRename:Q,createExplorerFile:H,createExplorerFolder:I,deleteExplorerSelection:L}}function p9({attachmentSessionId:e,socketRef:t,availableProviders:r,llmProvider:n,providerSwitching:i,processing:s,setProviderSwitching:a,setStatus:o,setSelectedProviders:l,setLlmProvider:c,t:h}){const u=x.useCallback(v=>{!t.current||t.current.readyState!==WebSocket.OPEN||r.includes(v)&&(v===n||i||s||(a(!0),o(h("Switching to {{provider}}...",{provider:v})),t.current.send(JSON.stringify({type:"switch_provider",provider:v}))))},[r,n,s,i,a,o,t,h]),m=x.useCallback(v=>{e||l(w=>{const _=w.includes(v),g=_?w.filter(d=>d!==v):[...w,v];if(!_)c(v);else if(v===n){const d=g[0]||v;d!==n&&c(d)}return g})},[e,n,c,l]);return{handleProviderSwitch:u,toggleProviderSelection:m}}function m9({currentMessages:e,attachmentRepoUrl:t,repoUrl:r,isInWorktree:n,activeWorktree:i,t:s,normalizeAttachments:a,downloadTextFile:o,formatExportName:l,extractRepoName:c,setToolbarExportOpen:h}){return{handleExportChat:x.useCallback(m=>{h(!1);const v=Array.isArray(e)?e:[];if(!v.length)return;h(!1);const w=c(t||r||""),_=n&&i?`${i.name||s("Worktree")} (${i.branchName||i.id})`:s("Main");if(m==="markdown"){const d=[`# ${s("Chat history")}`,"",`${s("Export")}: ${new Date().toISOString()}`,`${s("Tab")}: ${_}`,""];v.forEach(p=>{var b,k,C;if(p.role==="commandExecution"){d.push(`## ${s("Command")}`),d.push(`\`${p.command||s("Command")}\``),p.output&&(d.push("```"),d.push(p.output),d.push("```")),d.push("");return}if(p.role==="tool_result"){const A=((b=p.toolResult)==null?void 0:b.name)||((k=p.toolResult)==null?void 0:k.tool)||s("Tool"),P=((C=p.toolResult)==null?void 0:C.output)||p.text||"";d.push(`## ${s("Tool result")}`),d.push(`\`${A}\``),P&&(d.push("```"),d.push(P),d.push("```")),d.push("");return}const y=p.role==="user"?s("Username"):s("Assistant");d.push(`## ${y}`),d.push(p.text||"");const S=a(p.attachments||[]).map(A=>(A==null?void 0:A.name)||(A==null?void 0:A.path)).filter(Boolean);S.length&&d.push(`${s("Attachments")}: ${S.join(", ")}`),d.push("")});const f=d.join(`
705
705
  `).trim()+`
706
- `;o(l(w,"md"),f,"text/markdown");return}const g={exportedAt:new Date().toISOString(),repoUrl:t||r||"",tab:{type:n?"worktree":"main",worktreeId:(i==null?void 0:i.id)||null,worktreeName:(i==null?void 0:i.name)||null,branchName:(i==null?void 0:i.branchName)||null},messages:v.map(d=>d.role==="commandExecution"?{id:d.id,role:d.role,command:d.command||"",output:d.output||"",status:d.status||""}:d.role==="tool_result"?{id:d.id,role:d.role,text:d.text||"",toolResult:d.toolResult||null}:{id:d.id,role:d.role,text:d.text||"",attachments:a(d.attachments||[])})};o(l(w,"json"),JSON.stringify(g,null,2),"application/json")},[i,t,e,o,c,l,n,a,r,h,s])}}function g9({input:e,setInput:t,setMessages:r,setDraftAttachments:n,socketRef:i,connected:s,normalizeAttachments:a,draftAttachments:o,setWorktrees:l,setProcessing:c,setActivity:h,processingLabel:u,handleSendMessageRef:m,ensureNotificationPermission:v}){const w=x.useCallback((d,f,p)=>{const y=(d??e).trim();if(!y||!i.current||!s)return;const S=(p??y).trim();if(!S)return;v==null||v();const b=a(f??o),k=b.map(P=>P==null?void 0:P.path).filter(Boolean),C=k.length>0?`;; attachments: ${JSON.stringify(k)}`:"",A=`${S}${C}`;r(P=>[...P,{id:`user-${Date.now()}`,role:"user",text:y,attachments:b}]),c==null||c(!0),h==null||h(u||"Processing..."),i.current.send(JSON.stringify({type:"worktree_send_message",worktreeId:"main",text:A,displayText:y,attachments:b})),t(""),n([])},[s,o,e,a,n,t,r,i]),_=x.useCallback(d=>{m.current&&m.current(d,[])},[m]),g=x.useCallback((d,f,p,y)=>{const S=(f??e).trim();if(!S||!i.current||!s||!d)return;const b=(y??S).trim();if(!b)return;const k=a(p??o),C=k.map(O=>O==null?void 0:O.path).filter(Boolean),A=C.length>0?`;; attachments: ${JSON.stringify(C)}`:"",P=`${b}${A}`;l(O=>{const R=new Map(O);if(d==="main")return R;const M=R.get(d);if(M){const z=[...M.messages,{id:`user-${Date.now()}`,role:"user",text:S,attachments:k}];R.set(d,{...M,messages:z,status:"processing"})}return R}),d==="main"&&(c==null||c(!0),h==null||h(u||"Processing...")),i.current.send(JSON.stringify({type:"worktree_send_message",worktreeId:d,text:P,displayText:S,attachments:k})),t(""),n([])},[s,o,e,a,n,t,l,i]);return{sendMessage:w,sendCommitMessage:_,sendWorktreeMessage:g}}function v9({activeWorktreeId:e,setToolbarExportOpen:t,setWorktrees:r,lastNotifiedIdRef:n,attachmentSessionId:i,apiFetch:s,setMessages:a,messageIndex:o,commandIndex:l,setChoiceSelections:c,choicesKey:h,setCommandPanelOpen:u,setToolResultPanelOpen:m,llmProvider:v}){return{handleClearChat:x.useCallback(async()=>{if(t(!1),e!=="main"){if(r(_=>{const g=new Map(_),d=g.get(e);return d&&g.set(e,{...d,messages:[]}),g}),n.current=null,i)try{await s(`/api/v1/sessions/${encodeURIComponent(i)}/clear`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:e})})}catch{}return}if(a([]),o.clear(),l.clear(),c({}),h&&localStorage.removeItem(h),u({}),m({}),n.current=null,i)try{await s(`/api/v1/sessions/${encodeURIComponent(i)}/clear`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:v})})}catch{}},[e,s,i,h,l,v,o,c,u,a,m,t,r,n])}}const _9="Rename",y9="Stopped",w9="Annotations",b9={"Provider cannot be disabled: active sessions use it.":"Provider cannot be disabled: active sessions use it.","New file":"New file",Rename:_9,"File path":"File path","e.g. src/new-file.ts":"e.g. src/new-file.ts","Unable to rename.":"Unable to rename.","Unable to create file.":"Unable to create file.","Unable to delete.":"Unable to delete.","Renamed.":"Renamed.","File created.":"File created.","New folder":"New folder","Folder path":"Folder path","e.g. src/new-folder":"e.g. src/new-folder","Folder created.":"Folder created.","Unable to create folder.":"Unable to create folder.","Deleted.":"Deleted.",'Delete "{{path}}"? This action is irreversible.':'Delete "{{path}}"? This action is irreversible.',Stopped:y9,"New worktree":"New worktree","Worktree is stopped. Wake it up before sending a message.":"Worktree is stopped. Wake it up before sending a message.","Claude Code does not natively support forked sessions with directory changes. This feature is experimental.":"Claude Code does not natively support forked sessions with directory changes. This feature is experimental.","binary data":"binary data","Loading untracked files...":"Loading untracked files...","Unable to load file.":"Unable to load file.","User command : {{command}}":"User command : {{command}}","Toggle annotation mode":"Toggle annotation mode","Toggle annotation mode (EXPERIMENTAL)":"Toggle annotation mode (EXPERIMENTAL)","Annotation mode enabled.":"Annotation mode enabled.","Annotation mode disabled.":"Annotation mode disabled.","Usage: /annotation on|off":"Usage: /annotation on|off","Annotate line":"Annotate line",Annotations:w9,"Only sent with the next message.":"Only sent with the next message.","No annotations yet.":"No annotations yet.","Write annotation...":"Write annotation..."},S9="Tout",C9="api_key",k9="Assistant",x9="Pièces jointes",E9="auth_json_b64",A9="Revenir",L9="Backlog",P9="Annuler",T9="Claude",D9="Clear",I9="Cloner",N9="Fermer",R9="Codex",O9="Commande",M9="Commit",j9="Termine",B9="Connecte",F9="Continuer",z9="Copier",$9="Créer",U9="Creation",H9="Supprimer",W9="Diff",V9="Deconnecte",K9="Éditer",G9="Anglais",q9="Explorateur",Y9="Exporter",J9="FILE",X9="Formulaire",Q9="Français",Z9="Langue",eF="Lancer",tF="Logs",rF="Main",nF="Markdown",iF="Messages",sF="Modele",oF="Non",aF="Suivant",lF="Aucune",cF="Notifications",uF="Aperçu",fF="Precedent",hF="Provider",dF="Pret",pF="Reasoning",mF="Rafraichir",gF="Renommer",vF="Arrete",_F="Regenerer",yF="Reprendre",wF="Sauver",bF="Secret",SF="Envoyer",CF="Session",kF="Paramètres",xF="setup_token",EF="Stdin",AF="stdin",LF="Stdout",PF="stdout",TF="Stop",DF="Onglet",IF="Terminal",NF="Tool",RF="Annotations",OF="Utilisateur",MF="workspaceSecret",jF="Worktree",BF="Oui",FF={"-----BEGIN OPENSSH PRIVATE KEY-----":"-----BEGIN OPENSSH PRIVATE KEY-----","Access an existing space with your credentials":"Accedez a un espace existant avec vos identifiants","Add to backlog":"Ajouter au backlog","Add attachment":"Ajouter une pièce jointe","AI providers":"Providers IA","AI providers (required)":"Providers IA (obligatoire)","AI providers updated.":"Providers IA mis a jour.",All:S9,"All changes will be lost. What would you like to do?":"Toutes les modifications seront perdues. Que souhaitez-vous faire ?","Allow default internet access for this session.":"Autoriser l'accès internet par defaut pour cette session.","Allow sharing the Git folder for the main branch by default.":"Autoriser le partage du dossier Git pour la branche principale par defaut.",api_key:C9,"Applying changes...":"Application de modifications...",Assistant:k9,"Attached image":"Image jointe","Added to backlog.":"Ajouté au backlog.",Attachments:x9,"Auth {{provider}}":"Auth {{provider}}",auth_json_b64:E9,"Authentication failed.":"Echec de l'authentification.",Back:A9,"Back to previous view":"Revenir à la vue précédente",Backlog:L9,"Show backlog":"Afficher le backlog","Binary file not displayed.":"Fichier binaire non affiche.",Cancel:P9,"Chat history":"Historique du chat","Chat tools":"Outils du chat",Claude:T9,Clear:D9,Clone:I9,"Clone a repository to start a new session":"Cloner un depot pour demarrer une nouvelle session","Start a session":"Démarrer une session","Click here to learn more.":"Cliquez ici pour en savoir plus.","Cloning repository...":"Clonage du depot...",Close:N9,"Close panel":"Fermer le panneau","Close the worktree?":"Fermer le worktree ?",Codex:R9,"Codex (OpenAI)":"Codex (OpenAI)",Command:O9,"Command required.":"Commande requise.","Capture screenshot":"Capturer une capture d'ecran","Screenshot failed.":"Echec de la capture d'ecran.","Screenshot captured.":"Capture d'ecran ajoutee.","Git command required.":"Commande git requise.","Command: {{command}}":"Commande: {{command}}",Commit:M9,"Commit & Push":"Commit & Push",Completed:j9,"Configure AI providers":"Configurer les providers IA","Configure AI providers for this workspace.":"Configurez les providers IA pour ce workspace.","Configure the workspace":"Configurer le workspace",Connected:B9,"Connecting...":"Connexion...",Continue:F9,"Continue on mobile":"Continuer sur mobile",Copy:z9,"Copy code":"Copier le code","Copy workspace ID":"Copier le workspace ID","Copy workspace secret":"Copier le workspace secret",Create:$9,"Create a new space for you or your team":"Creez un nouvel espace pour vous ou votre equipe","Create a workspace":"Creer un workspace",Creating:U9,"Dark mode":"Mode sombre","Debug mode":"Mode débug","Default model":"Modele par defaut","Default reasoning":"Reasoning par defaut",Delete:H9,'Delete session "{{title}}"? This action is irreversible.':'Supprimer la session "{{title}}" ? Cette action est irreversible.',"Delete worktree":"Supprimer le worktree","Deleting...":"Suppression...",Diff:W9,Disconnected:V9,"e.g. refactor-auth":"ex: refactor-auth",Edit:K9,"Enable access to logs and Markdown/JSON export.":"Active l'accès aux logs et à l'export Markdown/JSON.","Enable the dark theme for the interface.":"Active le thème sombre pour l'interface.",English:G9,Error:"Erreur","Error during generation.":"Erreur lors de la generation.","Error during loading.":"Erreur lors du chargement.","Error: {{message}}":"Erreur: {{message}}","Execution in progress":"Execution en cours","Existing sessions":"Sessions existantes","Expires in {{seconds}}s":"Expire dans {{seconds}}s",Explorer:q9,Export:Y9,FILE:J9,"File truncated for display.":"Fichier tronque pour l'affichage.",Form:X9,French:Q9,"Full name":"Nom complet","Generating QR code...":"Generation du QR code...","Generating response...":"Generation de reponse...","Git authentication failed{{suffix}}.":"Echec d'authentification Git{{suffix}}.","Git identity for this repository":"Identité Git pour ce dépôt","Git repository not found{{suffix}}.":"Depot Git introuvable{{suffix}}.","git@gitea.devops:my-org/my-repo.git":"git@gitea.devops:mon-org/mon-repo.git","Global values: {{name}} / {{email}}.":"Valeurs globales: {{name}} / {{email}}.","In progress":"En cours","Internet access":"Internet access","Internet access enabled":"Accès internet activé","Invalid resume token.":"Token de reprise invalide.","Invalid workspace token. Please sign in again.":"Token workspace invalide. Merci de vous reconnecter.","Join a workspace":"Rejoindre un workspace",JSON:"JSON","JSON credentials":"JSON credentials","JSON-RPC":"JSON-RPC","Key or token":"Cle ou token","Key required for {{provider}}.":"Cle requise pour {{provider}}.",Language:Z9,"Last activity: {{date}}":"Derniere activite: {{date}}",Launch:eF,"Leave session":"Quitter la session","Leave workspace":"Quitter le workspace","List truncated after {{count}} entries.":"Liste tronquee apres {{count}} entrees.","Loading sessions...":"Chargement des sessions...","Loading...":"Chargement...",Logs:tF,Main:rF,Markdown:nF,"Merge into {{branch}}":"Merge vers {{branch}}",Messages:iF,Model:sF,"Name (optional)":"Nom (optionnel)","Name and email required.":"Nom et email requis.","New message":"Nouveau message","New file":"Nouveau fichier","New folder":"Nouveau dossier","New worktree":"Nouveau worktree","New session":"Nouvelle session",No:oF,"No changes detected.":"Aucun changement detecte.","No file found.":"Aucun fichier trouve.","No file selected":"Aucun fichier selectionne","binary data":"données binaires","Loading untracked files...":"Chargement des fichiers non suivis...","Unable to load file.":"Impossible de charger le fichier.","Claude Code does not natively support forked sessions with directory changes. This feature is experimental.":"Claude Code ne supporte pas nativement les sessions forkées avec changement de répertoire, cette feature est expérimentale.","No logs yet.":"Aucun log pour le moment.","No options":"Aucune option","No options.":"Aucune option.","No pending tasks at the moment.":"Aucune tâche en attente pour le moment.","No repository-specific values.":"Aucune valeur spécifique au dépôt.","No sessions available.":"Aucune session disponible.","No commands found.":"Aucune commande trouvée.",Next:aF,"No tasks":"Aucune tâche",None:lF,"Not set":"Non défini",Notifications:cF,"Open form":"Ouvrir le formulaire","Open path":"Ouvrir un chemin","Open settings":"Ouvrir les paramètres","Open diff view":"Ouvrir la vue diff","Run shell command":"Executer une commande shell","Run git command":"Executer une commande git","OpenAI authentication failed.":"Echec de l'authentification OpenAI.","Password or PAT":"Mot de passe ou PAT","Path required.":"Le chemin est requis.","Path not found.":"Chemin introuvable.",Preview:uF,"Private SSH key (not recommended)":"Cle SSH privee (non recommande)",Previous:fF,"Processing...":"Traitement en cours...","Provide user.name and user.email for repository commits.":"Renseignez user.name et user.email pour les commits du dépôt.",Provider:hF,"QR code":"QR code","QR code expired":"QR code expire","QR code unavailable.":"QR code indisponible.",Ready:dF,Reasoning:pF,"Reasoning...":"Raisonnement...",Refresh:mF,Rename:gF,"Renamed.":"Renomme.",Stopped:vF,Regenerate:_F,"Remove {{label}}":"Retirer {{label}}","Repository authentication (optional)":"Authentification depot (optionnelle)","Repository diff":"Diff du repository","Repository Git identity updated.":"Identité Git du dépôt mise à jour.","Repository values: {{name}} / {{email}}.":"Valeurs du dépôt: {{name}} / {{email}}.",Resume:yF,"Resume an already configured worktree":"Reprendre un worktree deja configure","Resume an existing session":"Reprendre une session existante","Resume on mobile":"Reprendre sur mobile",Save:wF,"Saving...":"Sauvegarde...","Scan this QR code in the Android app to resume the current session.":"Scannez ce QR code dans l'application Android pour reprendre la session en cours.",Secret:bF,"Select a branch":"Selectionner une branche","Select a file in the tree.":"Selectionnez un fichier dans l'arborescence.","File path":"Chemin du fichier","Folder path":"Chemin du dossier","e.g. src/new-file.ts":"ex: src/nouveau-fichier.ts","e.g. src/new-folder":"ex: src/nouveau-dossier","Select a language":"Selectionner une langue","Select a valid remote branch.":"Selectionnez une branche distante valide.","Select an existing workspace or create a new one.":"Selectionnez un workspace existant ou creez-en un nouveau.","Select at least one provider.":"Selectionnez au moins un provider.","Selected attachments":"Pièces sélectionnées",Send:SF,"Send 'Commit & Push' in chat":"Envoyer 'Commit & Push' dans le chat","Send 'Commit' in chat":"Envoyer 'Commit' dans le chat","Send a message to start a session.":"Envoyez un message pour demarrer une session.",Session:CF,'Session "{{title}}" deleted.':'Session "{{title}}" supprimee.',"Session name (optional)":"Nom de la session (optionnel)","Session not found.":"Session introuvable.",Settings:kF,setup_token:xF,"Deny git credentials access":"Refuser l'accès aux identifiants Git","Provider cannot be disabled: active sessions use it.":"Impossible de désactiver ce provider : des sessions l'utilisent.","Show a notification and sound when a new message arrives.":"Affiche une notification et un son quand un nouveau message arrive.","Show commands in chat":"Afficher les commandes dans le chat","Show executed command blocks in the conversation.":"Affiche les blocs de commandes exécutées dans la conversation.","Show tool results in chat":"Afficher les tool results dans le chat","Show tool_result blocks in the conversation.":"Affiche les blocs tool_result dans la conversation.","Source branch":"Branche source","Start a session to open the terminal.":"Demarrez une session pour ouvrir le terminal.",Stdin:EF,stdin:AF,Stdout:LF,stdout:PF,Stop:TF,"Switching to {{provider}}...":"Basculement vers {{provider}}...",Tab:DF,Terminal:IF,"The key is stored in ~/.ssh for cloning.":"La cle est stockee dans ~/.ssh pour le clonage.","The password can be replaced by a PAT.":"Le mot de passe peut etre remplace par un PAT.","These settings are stored in your browser.":"Ces réglages sont stockés dans votre navigateur.","Vibe80 can run Codex or Claude Code. To continue, provide your Anthropic and/or OpenAI credentials. If you use pay-as-you-go billing, supply an API key.":"Vibe80 peut piloter Codex ou Claude Code. Pour continuer, fournissez vos identifiants Anthropic et/ou OpenAI. Si vous utilisez une facturation a l'usage, fournissez une API key.","For subscription plans, use auth.json from the Codex CLI login (ChatGPT) or a long-lived token from `claude setup-token` (Claude).":"Pour les abonnements, utilisez auth.json apres login Codex en CLI (ChatGPT) ou un token longue duree via `claude setup-token` (Claude).","Vibe80 opens Git-based work sessions. Even in a secure environment, we recommend short-lived and revocable PATs or keys.":"Vibe80 ouvre des sessions de travail basees sur des depots Git. Meme dans un environnement securise, nous recommandons des jetons PAT/cles ephemeres et revocables.","Vibe80 strictly controls access to resources (Git credentials and internet) using sandboxing. ":"Vibe80 controle strictement l'acces aux ressources (identifiants Git et internet) via le sandboxing. ","A workspace is an isolated, secured environment accessible only with credentials. It lets you reuse AI credentials for all future sessions.":"Un workspace est un espace isole et securise, accessible uniquement avec des identifiants. Il permet de reutiliser vos identifiants IA pour toutes vos futures sessions.","You can create multiple workspaces to separate teams, projects, or security boundaries.":"Vous pouvez creer plusieurs workspaces pour separer equipes, projets ou perimetres de securite.",Tool:NF,"Tool result":"Tool result","Tool: {{tool}}":"Outil: {{tool}}","User command : {{command}}":"Commande utilisateur : {{command}}","Toggle annotation mode":"Activer le mode annotation","Toggle annotation mode (EXPERIMENTAL)":"Activer le mode annotation (EXPERIMENTAL)","Annotation mode enabled.":"Mode annotation activé.","Annotation mode disabled.":"Mode annotation désactivé.","Usage: /annotation on|off":"Usage : /annotation on|off","Annotate line":"Annoter la ligne",Annotations:RF,"Only sent with the next message.":"Envoyées uniquement avec le prochain message.","No annotations yet.":"Pas encore d'annotations.","Write annotation...":"Écrire une annotation...","Todo text required.":"Texte de la todo requis.","Unable to change branch.":"Impossible de changer de branche.","Unable to create the attachment session (HTTP {{status}}{{statusText}}){{suffix}}.":"Impossible de creer la session de pieces jointes (HTTP {{status}}{{statusText}}){{suffix}}.","Unable to create the attachment session.":"Impossible de creer la session de pieces jointes.","Unable to delete the session.":"Impossible de supprimer la session.","Unable to delete the session{{suffix}}.":"Impossible de supprimer la session{{suffix}}.","Unable to generate the QR code.":"Impossible de generer le QR code.","Unable to load branches.":"Impossible de charger les branches.","Unable to load Git identity.":"Impossible de charger l'identité Git.","Unable to load Git status.":"Impossible de charger le statut Git.","Unable to load models.":"Impossible de charger les modeles.","Unable to load sessions.":"Impossible de charger les sessions.","Unable to load the commit.":"Impossible de charger le commit.","Unable to load the explorer.":"Impossible de charger l'explorateur.","Unable to load the file.":"Impossible de charger le fichier.","Unable to load tree.":"Impossible de charger l'arborescence.","Unable to load the latest commit.":"Impossible de charger le dernier commit.","Unable to resume the session.":"Impossible de reprendre la session.","Unable to rename.":"Impossible de renommer.","Unable to delete.":"Impossible de supprimer.","Unable to save the file.":"Impossible d'enregistrer le fichier.","Unable to create file.":"Impossible de creer le fichier.","Unable to create folder.":"Impossible de creer le dossier.","Unable to upload attachments.":"Impossible d'uploader les pieces jointes.","Unable to update backlog.":"Impossible de mettre à jour le backlog.","Unexpected error":"Erreur inattendue","Update failed.":"Echec de la mise à jour.","Usage limit reached. Please try again later.":"Limite d'usage atteinte. Merci de reessayer plus tard.","User settings":"Paramètres utilisateur","user.email":"user.email","user.name":"user.name",Username:OF,"Username + password":"Identifiant + mot de passe","Username and password required.":"Identifiant et mot de passe requis.","Validating...":"Validation...","View previous messages ({{count}})":"Voir les messages precedents ({{count}})","Workspace configuration failed.":"Echec de la configuration du workspace.","Workspace created":"Workspace cree","Workspace created hint":"Votre workspace a ete cree avec succes. Gardez ces identifiants scrupuleusement pour un futur acces.","Workspace creation failed.":"Echec de creation du workspace.","Workspace ID":"Workspace ID","Workspace ID and secret are required.":"Workspace ID et secret requis.","Workspace ID required.":"Workspace ID requis.","Workspace Secret":"Workspace Secret","Workspace update failed.":"Echec de mise a jour du workspace.","workspaceId (e.g. w...)":"workspaceId (ex: w...)",workspaceSecret:MF,Worktree:jF,"Worktree diff":"Diff du worktree","Worktree is stopped. Wake it up before sending a message.":"Le worktree est arrete. Relancez-le avant d'envoyer un message.","File created.":"Fichier cree.","Folder created.":"Dossier cree.","Deleted.":"Supprime.",'Delete "{{path}}"? This action is irreversible.':'Supprimer "{{path}}" ? Cette action est irreversible.',"Write your message…":"Écris ton message…",Yes:BF,"You have unsaved changes. Continue without saving?":"Vous avez des modifications non sauvegardees. Continuer sans sauvegarder ?","your.email@example.com":"ton.email@exemple.com","{{count}} attachment(s)":"{{count}} pièce(s) jointe(s)","{{count}} B":"{{count}} o","{{count}} files modified":"{{count}} fichiers modifies","{{count}} item(s)":"{{count}} élément(s)","{{count}} KB":"{{count}} Ko","{{count}} lines":"{{count}} lignes","{{count}} MB":"{{count}} Mo"},PC="uiLanguage",zF={en:b9||{},fr:FF||{}},$F=()=>{try{const e=localStorage.getItem(PC);if(e==="fr"||e==="en")return e}catch{}return"en"},UF=(e,t)=>t?e.replace(/\{\{(\w+)\}\}/g,(r,n)=>Object.prototype.hasOwnProperty.call(t,n)?String(t[n]):r):e,TC=(e,t,r)=>{const i=(zF[e]||{})[t]||t;return UF(i,r)},DC=x.createContext({language:"en",setLanguage:()=>{},t:(e,t)=>TC("en",e,t),locale:"en-US"}),HF=({children:e})=>{const[t,r]=x.useState($F);x.useEffect(()=>{try{localStorage.setItem(PC,t)}catch{}},[t]);const n=t==="fr"?"fr-FR":"en-US",i=x.useCallback((a,o)=>TC(t,a,o),[t]),s=x.useMemo(()=>({language:t,setLanguage:r,t:i,locale:n}),[t,i,n]);return E.jsx(DC.Provider,{value:s,children:e})},IC=()=>x.useContext(DC),W1={creating:KD,ready:k_,processing:GD,stopped:k_,completed:fd,error:si},V1={creating:"#9ca3af",ready:"#10b981",processing:"#f59e0b",stopped:"#ef4444",completed:"#3b82f6",error:"#ef4444"};function WF({worktrees:e,activeWorktreeId:t,onSelect:r,onCreate:n,onClose:i,onRename:s,provider:a,providers:o,branches:l,defaultBranch:c,branchLoading:h,branchError:u,defaultInternetAccess:m,defaultDenyGitCredentialsAccess:v,deploymentMode:w,onRefreshBranches:_,providerModelState:g,onRequestProviderModels:d,disabled:f,isMobile:p}){var _e,De;const{t:y}=IC(),[S,b]=x.useState(!1),[k,C]=x.useState(null),[A,P]=x.useState(""),[O,R]=x.useState(""),[M,z]=x.useState(""),U=x.useMemo(()=>Array.isArray(o)&&o.length?o:[a||"codex"],[o,a]),[q,Q]=x.useState(U[0]),[H,I]=x.useState("new"),[L,B]=x.useState("main"),[D,T]=x.useState(""),[$,Y]=x.useState(""),[W,j]=x.useState(!!m),[N,G]=x.useState(typeof v=="boolean"?v:!0),V=x.useMemo(()=>({creating:y("Creating"),ready:y("Ready"),processing:y("In progress"),stopped:y("Stopped"),completed:y("Completed"),error:y("Error")}),[y]),X=x.useRef(null),ne=x.useRef(null);x.useEffect(()=>{k&&X.current&&(X.current.focus(),X.current.select())},[k]),x.useEffect(()=>{S&&ne.current&&ne.current.focus()},[S]),x.useEffect(()=>{if(S&&(j(!!m),G(typeof v=="boolean"?v:!0),M||z(c||""),!(l!=null&&l.length)&&_&&!h&&_(),H==="new"&&d)){const ee=(g==null?void 0:g[q])||{};!ee.loading&&!(ee.models||[]).length&&d(q)}},[S,M,c,l,m,v,_,h,H,q,d]),x.useEffect(()=>{U.includes(q)||Q(U[0])},[U,q]),x.useEffect(()=>{if(H==="new"&&d){const ee=(g==null?void 0:g[q])||{};!ee.loading&&!(ee.models||[]).length&&d(q)}H==="new"&&(T(""),Y(""))},[H,q,d]);const ue=(g==null?void 0:g[q])||{},ve=Array.isArray(ue.models)?ue.models:[],le=x.useMemo(()=>Array.isArray(l)?l.map(ee=>ee.trim()).filter(Boolean):[],[l]),Se=(M||c||"").trim(),ye=!!Se&&le.includes(Se),Me=x.useMemo(()=>ve.find(ee=>ee.isDefault)||null,[ve]),Ne=x.useMemo(()=>ve.find(ee=>ee.model===D)||null,[ve,D]),Ue=H==="new"&&q==="codex"&&(((_e=Ne==null?void 0:Ne.supportedReasoningEfforts)==null?void 0:_e.length)||0)>0;x.useEffect(()=>{H==="new"&&(!D&&(Me!=null&&Me.model)&&T(Me.model),q==="codex"&&!$&&(Me!=null&&Me.defaultReasoningEffort)&&Y(Me.defaultReasoningEffort),q!=="codex"&&$&&Y(""))},[H,q,D,$,Me]),x.useEffect(()=>{var Ae;if(H!=="new"||q!=="codex"){$&&Y("");return}if(!((Ae=Ne==null?void 0:Ne.supportedReasoningEfforts)!=null&&Ae.length)){$&&Y("");return}!Ne.supportedReasoningEfforts.some(Ie=>Ie.reasoningEffort===$)&&$&&Y("")},[H,q,Ne,$]);const Ke=()=>{n&&n({context:H,name:O.trim()||null,provider:q,sourceWorktree:H==="fork"?L:null,startingBranch:Se||null,model:H==="new"&&D||null,reasoningEffort:H==="new"&&$||null,internetAccess:W,denyGitCredentialsAccess:N}),R(""),I("new"),Q(U[0]),B("main"),z(c||""),T(""),Y(""),j(!!m),G(typeof v=="boolean"?v:!0),b(!1)},Ye=ee=>{C(ee.id),P(ee.name)},Ee=()=>{k&&A.trim()&&s&&s(k,A.trim()),C(null),P("")},je=ee=>{ee.key==="Enter"?Ee():ee.key==="Escape"&&(C(null),P(""))},Ce=ee=>{ee.key==="Enter"?Ke():ee.key==="Escape"&&b(!1)},Z=(Array.isArray(e)?e:Array.from(((De=e==null?void 0:e.values)==null?void 0:De.call(e))||[])).slice().sort((ee,Ae)=>{if((ee==null?void 0:ee.id)==="main"&&(Ae==null?void 0:Ae.id)!=="main")return-1;if((Ae==null?void 0:Ae.id)==="main"&&(ee==null?void 0:ee.id)!=="main")return 1;const Ie=ee!=null&&ee.createdAt?new Date(ee.createdAt).getTime():0,St=Ae!=null&&Ae.createdAt?new Date(Ae.createdAt).getTime():0;return Ie-St}),se=Z.map(ee=>({id:ee.id,label:ee.id==="main"?"main":ee.name||ee.branchName||ee.id,provider:ee.provider||ee.id==="main"&&a||null})),we=se.find(ee=>ee.id===L),F=H==="fork"&&(we==null?void 0:we.provider)==="claude";return x.useEffect(()=>{var Ae;if(!se.length)return;if(!se.some(Ie=>Ie.id===L)){const Ie=((Ae=se.find(St=>St.id==="main"))==null?void 0:Ae.id)||se[0].id;B(Ie)}},[L,se]),E.jsxs("div",{className:"worktree-tabs-container",children:[E.jsx("div",{className:"worktree-tabs",children:p?E.jsxs("div",{className:"worktree-tabs-select",children:[E.jsx("select",{className:"worktree-select",value:t,onChange:ee=>!f&&(r==null?void 0:r(ee.target.value)),"aria-label":y("Select a branch"),disabled:f,children:Z.map(ee=>E.jsx("option",{value:ee.id,children:ee.name},ee.id))}),E.jsx("button",{className:"worktree-tab-add",onClick:()=>b(!0),disabled:f||Z.length>=10,title:y("New worktree"),"aria-label":y("New worktree"),children:E.jsx(Be,{icon:bc})})]}):E.jsxs(E.Fragment,{children:[Z.map(ee=>E.jsxs("div",{className:`worktree-tab ${t===ee.id?"active":""}`,onClick:()=>!f&&(r==null?void 0:r(ee.id)),style:{"--tab-accent":ee.color||"#3b82f6"},children:[E.jsx("span",{className:`worktree-status ${ee.status==="processing"?"pulse":""}`,style:{color:V1[ee.status]||V1.ready},title:V[ee.status]||ee.status,children:E.jsx(Be,{icon:W1[ee.status]||W1.ready})}),k===ee.id&&ee.id!=="main"?E.jsx("input",{ref:X,className:"worktree-tab-edit",value:A,onChange:Ae=>P(Ae.target.value),onBlur:Ee,onKeyDown:je,onClick:Ae=>Ae.stopPropagation()}):E.jsx("span",{className:"worktree-tab-name",onDoubleClick:Ae=>{Ae.stopPropagation(),ee.id!=="main"&&Ye(ee)},title:ee.id==="main"?ee.name:`${ee.name||ee.branchName} (${ee.branchName||"main"})`,children:ee.id==="main"?ee.name:ee.name||ee.branchName}),ee.id!=="main"&&E.jsx("button",{className:"worktree-tab-close",onClick:Ae=>{Ae.stopPropagation(),i==null||i(ee.id)},title:y("Close"),children:E.jsx(Be,{icon:si})})]},ee.id)),E.jsx("button",{className:"worktree-tab-add",onClick:()=>b(!0),disabled:f||Z.length>=10,title:y("New worktree"),children:E.jsx(Be,{icon:bc})})]})}),S&&E.jsx("div",{className:"worktree-create-dialog-overlay",onClick:()=>b(!1),children:E.jsxs("div",{className:"worktree-create-dialog",onClick:ee=>ee.stopPropagation(),children:[E.jsx("h3",{children:y("New worktree")}),E.jsxs("div",{className:"worktree-create-grid",children:[E.jsxs("div",{className:"worktree-create-field",children:[E.jsx("label",{children:y("Name (optional)")}),E.jsx("input",{ref:ne,type:"text",placeholder:y("e.g. refactor-auth"),value:O,onChange:ee=>R(ee.target.value),onKeyDown:Ce})]}),E.jsxs("div",{className:"worktree-create-field",children:[E.jsx("label",{children:y("Source branch")}),E.jsx("input",{type:"text",list:"worktree-branch-options",placeholder:c||"main",value:M,onChange:ee=>z(ee.target.value),onKeyDown:Ce}),E.jsx("datalist",{id:"worktree-branch-options",children:le.map(ee=>E.jsx("option",{value:ee},ee))}),!ye&&E.jsx("div",{className:"worktree-field-error",children:y("Select a valid remote branch.")}),u&&E.jsx("div",{className:"worktree-field-error",children:u})]}),E.jsxs("div",{className:"worktree-create-field",children:[E.jsx("label",{children:y("Context")}),E.jsxs("select",{value:H,onChange:ee=>I(ee.target.value==="fork"?"fork":"new"),children:[E.jsx("option",{value:"new",children:y("New")}),E.jsx("option",{value:"fork",children:y("Fork")})]})]}),H==="new"?E.jsxs("div",{className:"worktree-create-field",children:[E.jsx("label",{children:y("Provider")}),E.jsxs("select",{value:q,onChange:ee=>Q(ee.target.value),disabled:U.length<=1,children:[U.includes("codex")&&E.jsx("option",{value:"codex",children:y("Codex (OpenAI)")}),U.includes("claude")&&E.jsx("option",{value:"claude",children:y("Claude")})]})]}):E.jsxs("div",{className:"worktree-create-field",children:[E.jsx("label",{children:y("Source worktree")}),E.jsx("select",{value:L,onChange:ee=>B(ee.target.value||"main"),children:se.map(ee=>E.jsx("option",{value:ee.id,children:ee.label},ee.id))})]}),F&&E.jsx("div",{className:"worktree-create-field is-full",children:E.jsx("div",{className:"worktree-warning-bubble",children:y("Claude Code does not natively support forked sessions with directory changes. This feature is experimental.")})}),H==="new"&&(q==="codex"||q==="claude")&&E.jsxs(E.Fragment,{children:[E.jsxs("div",{className:`worktree-create-field ${Ue?"":"is-full"}`,children:[E.jsx("label",{children:y("Model")}),E.jsxs("select",{value:D,onChange:ee=>T(ee.target.value),disabled:ue.loading||ve.length===0,children:[E.jsx("option",{value:"",children:y("Default model")}),ve.map(ee=>E.jsx("option",{value:ee.model,children:ee.displayName||ee.model},ee.id))]}),ue.error&&E.jsx("div",{className:"worktree-field-error",children:ue.error})]}),Ue&&E.jsxs("div",{className:"worktree-create-field",children:[E.jsx("label",{children:y("Reasoning")}),E.jsxs("select",{value:$,onChange:ee=>Y(ee.target.value),disabled:ue.loading||!Ne,children:[E.jsx("option",{value:"",children:y("Default reasoning")}),((Ne==null?void 0:Ne.supportedReasoningEfforts)||[]).map(ee=>E.jsx("option",{value:ee.reasoningEffort,children:ee.reasoningEffort},ee.reasoningEffort))]})]})]}),E.jsx("div",{className:"worktree-create-field worktree-toggle-field",children:E.jsxs("label",{className:"worktree-toggle",children:[E.jsx("input",{type:"checkbox",checked:W,onChange:ee=>{const Ae=ee.target.checked;j(Ae),Ae||G(!1)}}),E.jsx("span",{children:y("Internet access")})]})}),W&&w!=="mono_user"&&E.jsx("div",{className:"worktree-create-field worktree-toggle-field",children:E.jsxs("label",{className:"worktree-toggle",children:[E.jsx("input",{type:"checkbox",checked:N,onChange:ee=>G(ee.target.checked)}),E.jsx("span",{children:y("Deny git credentials access")})]})})]}),E.jsxs("div",{className:"worktree-create-actions",children:[E.jsx("button",{className:"worktree-btn-cancel",onClick:()=>b(!1),children:y("Cancel")}),E.jsx("button",{className:"worktree-btn-create",onClick:Ke,disabled:!ye||H==="fork"&&!L,children:y("Create")})]})]})})]})}function VF({t:e,brandLogo:t,allTabs:r,activeWorktreeId:n,handleSelectWorktree:i,createWorktree:s,openCloseConfirm:a,renameWorktreeHandler:o,llmProvider:l,availableProviders:c,branches:h,defaultBranch:u,currentBranch:m,branchLoading:v,branchError:w,defaultInternetAccess:_,defaultDenyGitCredentialsAccess:g,deploymentMode:d,loadBranches:f,providerModelState:p,loadProviderModels:y,connected:S,isMobileLayout:b,requestHandoffQr:k,attachmentSession:C,handoffLoading:A,handleOpenSettings:P,handleLeaveSession:O}){return E.jsxs("header",{className:"header",children:[E.jsxs("div",{className:"topbar-left",children:[E.jsx("div",{className:"topbar-spacer"}),E.jsx("div",{className:"topbar-brand",children:E.jsx("img",{className:"brand-logo",src:t,alt:"vibe80"})}),E.jsx("div",{className:"topbar-tabs",children:E.jsx(WF,{worktrees:r,activeWorktreeId:n,onSelect:i,onCreate:s,onClose:a,onRename:o,provider:l,providers:c.length?c:[l],branches:h,defaultBranch:u||m,branchLoading:v,branchError:w,defaultInternetAccess:_,defaultDenyGitCredentialsAccess:g,deploymentMode:d,onRefreshBranches:f,providerModelState:p,onRequestProviderModels:y,disabled:!S,isMobile:b})})]}),E.jsxs("div",{className:"topbar-right",children:[E.jsx("button",{type:"button",className:"icon-button","aria-label":e("Resume on mobile"),title:e("Resume on mobile"),onClick:k,disabled:!(C!=null&&C.sessionId)||A,children:E.jsx(Be,{icon:s6})}),E.jsx("button",{type:"button",className:"icon-button","aria-label":e("Open settings"),onClick:P,children:E.jsx(Be,{icon:Rb})}),E.jsx("button",{type:"button",className:"icon-button","aria-label":e("Leave session"),onClick:O,children:E.jsx(Be,{icon:Ob})})]})]})}function KF({t:e,brandLogo:t,showStep1:r,showStep2:n,showStep3:i,showStep4:s,showMonoLoginRequired:a,headerHint:o,workspaceMode:l,setWorkspaceMode:c,formDisabled:h,handleWorkspaceSubmit:u,workspaceIdInput:m,setWorkspaceIdInput:v,workspaceSecretInput:w,setWorkspaceSecretInput:_,workspaceError:g,handleWorkspaceProvidersSubmit:d,workspaceProvider:f,workspaceAuthExpanded:p,setWorkspaceAuthExpanded:y,setWorkspaceProviders:S,providerAuthOptions:b,getProviderAuthType:k,workspaceAuthFiles:C,setWorkspaceAuthFiles:A,sessionMode:P,setSessionMode:O,setSessionRequested:R,setAttachmentsError:M,loadWorkspaceSessions:z,deploymentMode:U,handleLeaveWorkspace:q,workspaceSessionsLoading:Q,workspaceSessions:H,workspaceSessionsError:I,workspaceSessionDeletingId:L,handleResumeSession:B,handleDeleteSession:D,locale:T,extractRepoName:$,getTruncatedText:Y,isCloning:W,repoDisplay:j,onRepoSubmit:N,sessionNameInput:G,setSessionNameInput:V,repoInput:X,setRepoInput:ne,repoHistory:ue,authMode:ve,setAuthMode:le,sshKeyInput:Se,setSshKeyInput:ye,httpUsername:Me,setHttpUsername:Ne,httpPassword:Ue,setHttpPassword:Ke,defaultInternetAccess:Ye,setDefaultInternetAccess:Ee,defaultDenyGitCredentialsAccess:je,setDefaultDenyGitCredentialsAccess:Ce,attachmentsError:Z,sessionRequested:se,workspaceBusy:we,workspaceProvidersEditing:F,providersBackStep:_e,setWorkspaceStep:De,setWorkspaceProvidersEditing:ee,setWorkspaceError:Ae,setProvidersBackStep:Ie,loadWorkspaceProviders:St,workspaceCreated:ce,workspaceId:he,workspaceCopied:J,handleWorkspaceCopy:K,infoContent:re,toast:ie}){var ae;return E.jsxs("div",{className:"session-gate session-fullscreen",children:[E.jsxs("div",{className:"session-layout session-layout--fullscreen",children:[E.jsxs("div",{className:"session-shell",children:[E.jsxs("div",{className:"session-header",children:[E.jsx("img",{className:"brand-logo",src:t,alt:"vibe80"}),E.jsx("h1",{children:e(a?"Login required":s?"Start a session":i?"Workspace created":n?"Configure AI providers":"Configure the workspace")}),o?E.jsx("p",{className:"session-hint",children:o}):null]}),E.jsxs("div",{className:"session-body",children:[r&&E.jsxs(E.Fragment,{children:[E.jsxs("form",{id:"workspace-form",className:"session-form",onSubmit:u,children:[E.jsxs("div",{className:"session-workspace-options",children:[E.jsxs("button",{type:"button",className:`session-workspace-option ${l==="existing"?"is-selected":""}`,onClick:()=>c("existing"),disabled:h,"aria-pressed":l==="existing",children:[E.jsx("span",{className:"session-workspace-icon is-join","aria-hidden":"true",children:E.jsx(Be,{icon:x_})}),E.jsxs("span",{className:"session-workspace-option-text",children:[E.jsx("span",{className:"session-workspace-option-title",children:e("Join a workspace")}),E.jsx("span",{className:"session-workspace-option-subtitle",children:e("Access an existing space with your credentials")})]})]}),E.jsxs("button",{type:"button",className:`session-workspace-option ${l==="new"?"is-selected":""}`,onClick:()=>c("new"),disabled:h,"aria-pressed":l==="new",children:[E.jsx("span",{className:"session-workspace-icon is-create","aria-hidden":"true",children:E.jsx(Be,{icon:bc})}),E.jsxs("span",{className:"session-workspace-option-text",children:[E.jsx("span",{className:"session-workspace-option-title",children:e("Create a workspace")}),E.jsx("span",{className:"session-workspace-option-subtitle",children:e("Create a new space for you or your team")})]})]})]}),E.jsx("div",{className:`session-panel ${l==="existing"?"is-visible":"is-hidden"}`,"aria-hidden":l!=="existing",children:E.jsxs("div",{className:"session-workspace-form",children:[E.jsxs("div",{className:"session-workspace-form-labels",children:[E.jsx("span",{children:e("Workspace ID")}),E.jsx("span",{children:e("Secret")})]}),E.jsxs("div",{className:"session-workspace-form-grid",children:[E.jsx("input",{type:"text",placeholder:e("workspaceId (e.g. w...)"),value:m,onChange:oe=>v(oe.target.value),disabled:h,spellCheck:!1}),E.jsx("input",{type:"password",placeholder:e("workspaceSecret"),value:w,onChange:oe=>_(oe.target.value),disabled:h,autoComplete:"off"})]})]})})]}),g&&E.jsx("div",{className:"attachments-error",children:g})]}),n&&E.jsxs(E.Fragment,{children:[E.jsx("form",{id:"providers-form",className:"session-form",onSubmit:d,children:E.jsx("div",{className:"session-auth-options session-auth-accordion",children:["codex","claude"].map(oe=>{const ge=f(oe),Ge=e(oe==="codex"?"Codex":"Claude"),We=!!p[oe],Je=!!ge.enabled,xt=F&&Array.isArray(H)&&H.some(Xe=>(Array.isArray(Xe.providers)&&Xe.providers.length?Xe.providers:Xe.activeProvider?[Xe.activeProvider]:[]).includes(oe)),xi=h||xt&&Je;return E.jsxs("div",{className:"session-auth-card",children:[E.jsx("div",{className:"session-auth-header",children:E.jsxs("label",{className:"session-auth-option",children:[E.jsx("input",{type:"checkbox",checked:Je,onChange:()=>{if(xt&&Je)return;const Xe=!Je;y(Et=>({...Et,[oe]:Xe})),S(Et=>({...Et,[oe]:{...Et[oe],enabled:Xe}}))},disabled:xi,title:xt&&Je?e("Provider cannot be disabled: active sessions use it."):void 0}),Ge]})}),Je&&We?E.jsxs("div",{className:"session-auth-grid",children:[E.jsx("select",{value:k(oe,ge),onChange:Xe=>S(Et=>({...Et,[oe]:{...Et[oe],authType:Xe.target.value,authValue:""}})),disabled:h,children:(b[oe]||[]).map(Xe=>E.jsx("option",{value:Xe,children:e(Xe)},Xe))}),k(oe,ge)==="auth_json_b64"?E.jsxs("div",{className:"session-auth-file",children:[E.jsx("input",{type:"file",accept:"application/json,.json",onChange:async Xe=>{var Ls;const Et=(Ls=Xe.target.files)==null?void 0:Ls[0];if(!Et)return;const Hr=await Et.text();S(_r=>({..._r,[oe]:{..._r[oe],authValue:Hr}})),A(_r=>({..._r,[oe]:Et.name})),Xe.target.value=""},disabled:h}),C[oe]?E.jsx("span",{className:"session-auth-file-name",children:C[oe]}):null]}):E.jsx("input",{type:"password",placeholder:e("Key or token"),value:ge.authValue,onChange:Xe=>S(Et=>({...Et,[oe]:{...Et[oe],authValue:Xe.target.value}})),disabled:h,autoComplete:"off"})]}):null]},oe)})})}),g&&E.jsx("div",{className:"attachments-error",children:g})]}),i&&E.jsx(E.Fragment,{children:E.jsxs("div",{className:"workspace-created-card",children:[E.jsxs("div",{className:"workspace-created-row",children:[E.jsx("span",{className:"workspace-created-label",children:e("Workspace ID")}),E.jsx("span",{className:"workspace-created-value",children:(ce==null?void 0:ce.workspaceId)||he}),E.jsx("button",{type:"button",className:"workspace-created-copy",onClick:()=>K("id",(ce==null?void 0:ce.workspaceId)||he||""),"aria-label":e("Copy workspace ID"),children:E.jsx(Be,{icon:J.id?fd:hd})})]}),E.jsxs("div",{className:"workspace-created-row",children:[E.jsx("span",{className:"workspace-created-label",children:e("Workspace Secret")}),E.jsx("span",{className:"workspace-created-value",children:(ce==null?void 0:ce.workspaceSecret)||""}),E.jsx("button",{type:"button",className:"workspace-created-copy",onClick:()=>K("secret",(ce==null?void 0:ce.workspaceSecret)||""),"aria-label":e("Copy workspace secret"),children:E.jsx(Be,{icon:J.secret?fd:hd})})]})]})}),s&&E.jsxs("div",{className:"session-step",children:[E.jsxs("div",{className:"session-workspace-toggle",children:[E.jsxs("button",{type:"button",className:`session-workspace-option is-compact ${P==="new"?"is-selected":""}`,onClick:()=>{O("new"),R(!1),M("")},disabled:h,"aria-pressed":P==="new",children:[E.jsx("span",{className:"session-workspace-icon is-create","aria-hidden":"true",children:E.jsx(Be,{icon:bc})}),E.jsx("span",{className:"session-workspace-option-title",children:e("New session")})]}),E.jsxs("button",{type:"button",className:`session-workspace-option is-compact ${P==="existing"?"is-selected":""}`,onClick:()=>{O("existing"),R(!1),M(""),z()},disabled:h,"aria-pressed":P==="existing",children:[E.jsx("span",{className:"session-workspace-icon is-join","aria-hidden":"true",children:E.jsx(Be,{icon:x_})}),E.jsx("span",{className:"session-workspace-option-title",children:e("Resume an existing session")})]}),U!=="mono_user"&&E.jsxs("button",{type:"button",className:"session-workspace-option is-compact",onClick:q,children:[E.jsx("span",{className:"session-workspace-icon is-leave","aria-hidden":"true",children:E.jsx(Be,{icon:Ob})}),E.jsx("span",{className:"session-workspace-option-title",children:e("Leave workspace")})]})]}),E.jsx("div",{className:`session-panel ${P==="existing"?"is-visible":"is-hidden"}`,"aria-hidden":P!=="existing",children:E.jsxs("div",{className:"session-auth",children:[E.jsx("div",{className:"session-auth-title",children:e("Existing sessions")}),Q?E.jsx("div",{className:"session-auth-hint",children:e("Loading sessions...")}):H.length===0?E.jsx("div",{className:"session-auth-hint",children:e("No sessions available.")}):E.jsx("ul",{className:"session-list",children:H.map(oe=>{const ge=$(oe.repoUrl),Ge=oe.name||ge||oe.sessionId,We=oe.repoUrl?Y(oe.repoUrl,72):oe.sessionId,Je=oe.lastActivityAt?new Date(oe.lastActivityAt).toLocaleString(T):oe.createdAt?new Date(oe.createdAt).toLocaleString(T):"",xt=L===oe.sessionId;return E.jsxs("li",{className:"session-item",children:[E.jsxs("div",{className:"session-item-meta",children:[E.jsx("div",{className:"session-item-title",children:Ge}),E.jsx("div",{className:"session-item-sub",children:We}),Je&&E.jsx("div",{className:"session-item-sub",children:e("Last activity: {{date}}",{date:Je})})]}),E.jsxs("div",{className:"session-item-actions",children:[E.jsx("button",{type:"button",className:"session-list-button",onClick:()=>B(oe.sessionId),disabled:h||xt,children:e("Resume")}),E.jsx("button",{type:"button",className:"session-list-button is-danger",onClick:()=>D(oe),disabled:h||xt,children:e(xt?"Deleting...":"Delete")})]})]},oe.sessionId)})}),I&&E.jsx("div",{className:"attachments-error",children:I})]})}),E.jsx("div",{className:`session-panel ${P==="new"?"is-visible":"is-hidden"}`,"aria-hidden":P!=="new",children:W?E.jsxs("div",{className:"session-hint",children:[e("Cloning repository..."),j&&E.jsx("div",{className:"session-meta",children:j})]}):E.jsxs("form",{id:"repo-form",className:"session-form session-form--compact",onSubmit:N,children:[E.jsxs("div",{className:"session-form-row is-compact-grid",children:[E.jsx("input",{type:"text",placeholder:e("Session name (optional)"),value:G,onChange:oe=>V(oe.target.value),disabled:h}),E.jsxs("div",{className:"session-repo-field",children:[E.jsx("input",{type:"text",placeholder:e("git@gitea.devops:my-org/my-repo.git"),value:X,onChange:oe=>{ne(oe.target.value)},disabled:h,required:!0,list:ue.length>0?"repo-history":void 0}),ue.length>0&&E.jsx("datalist",{id:"repo-history",children:ue.map(oe=>E.jsx("option",{value:oe,children:Y(oe,72)},oe))})]})]}),E.jsxs("div",{className:"session-auth",children:[E.jsx("div",{className:"session-auth-title",children:e("Repository authentication (optional)")}),E.jsx("div",{className:"session-auth-options",children:E.jsxs("select",{value:ve,onChange:oe=>le(oe.target.value),disabled:h,children:[E.jsx("option",{value:"none",children:e("None")}),E.jsx("option",{value:"ssh",children:e("Private SSH key (not recommended)")}),E.jsx("option",{value:"http",children:e("Username + password")})]})}),ve==="ssh"&&E.jsx(E.Fragment,{children:E.jsx("textarea",{className:"session-auth-textarea",placeholder:e("-----BEGIN OPENSSH PRIVATE KEY-----"),value:Se,onChange:oe=>ye(oe.target.value),disabled:h,rows:6,spellCheck:!1})}),ve==="http"&&E.jsx(E.Fragment,{children:E.jsxs("div",{className:"session-auth-grid",children:[E.jsx("input",{type:"text",placeholder:e("Username"),value:Me,onChange:oe=>Ne(oe.target.value),disabled:h,autoComplete:"username"}),E.jsx("input",{type:"password",placeholder:e("Password or PAT"),value:Ue,onChange:oe=>Ke(oe.target.value),disabled:h,autoComplete:"current-password"})]})})]}),E.jsxs("div",{className:"session-auth session-auth-compact",children:[E.jsx("div",{className:"session-auth-title",children:e("Permissions")}),E.jsxs("div",{className:"session-auth-options session-auth-options--compact",children:[E.jsxs("label",{className:"session-auth-option",children:[E.jsx("input",{type:"checkbox",checked:Ye,onChange:oe=>{const ge=oe.target.checked;Ee(ge),ge||Ce(!1)},disabled:h}),e("Internet access")]}),Ye&&U!=="mono_user"&&E.jsxs("label",{className:"session-auth-option",children:[E.jsx("input",{type:"checkbox",checked:je,onChange:oe=>Ce(oe.target.checked),disabled:h}),e("Deny git credentials access")]})]})]})]})}),Z&&E.jsx("div",{className:"attachments-error",children:Z})]}),a&&E.jsxs("div",{className:"session-step",children:[E.jsxs("div",{className:"session-auth",children:[E.jsx("div",{className:"session-auth-title",children:e("Login required")}),E.jsx("div",{className:"session-auth-hint",children:e("Please use the console generated URL to login")})]}),g&&E.jsx("div",{className:"attachments-error",children:g})]})]}),E.jsx("div",{className:"session-footer",children:a?null:r?E.jsx("button",{type:"submit",form:"workspace-form",className:"session-button primary",disabled:h,children:e(we?"Validating...":"Continue")}):n?E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button",className:"session-button secondary",onClick:()=>{if(_e===4){ee(!1),De(4);return}De(1)},disabled:h,children:e("Back")}),E.jsx("button",{type:"submit",form:"providers-form",className:"session-button primary",disabled:h,children:e(we?"Validating...":F?"Save":"Continue")})]}):i?E.jsx("button",{type:"button",className:"session-button primary",onClick:()=>De(4),disabled:h,children:e("Continue")}):s?P==="existing"?E.jsx("button",{type:"button",className:"session-button secondary session-footer-full",disabled:h,onClick:()=>{ee(!0),Ae(""),Ie(4),St(),z(),De(2)},children:e("AI providers")}):E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button",className:"session-button secondary",disabled:h,onClick:()=>{ee(!0),Ae(""),Ie(4),St(),z(),De(2)},children:e("AI providers")}),E.jsx("button",{type:"submit",form:"repo-form",className:"session-button primary",disabled:h,children:e(se?"Loading...":"Clone")})]}):null})]}),E.jsx("aside",{className:"session-info",children:E.jsxs("div",{className:"session-info-card",children:[E.jsxs("div",{className:"session-info-title",children:[E.jsx("span",{className:"session-info-icon","aria-hidden":"true",children:"ℹ️"}),re.title]}),(ae=re.paragraphs)==null?void 0:ae.map(oe=>E.jsx("p",{children:oe},oe)),re.securityLink?E.jsxs("p",{children:[e("Vibe80 strictly controls access to resources (Git credentials and internet) using sandboxing. "),E.jsx("a",{className:"session-info-link",href:"https://vibe80.ai/security",target:"_blank",rel:"noreferrer",children:e("Click here to learn more.")})]}):null]})})]}),ie&&E.jsx("div",{className:"toast-container",children:E.jsx("div",{className:`toast is-${ie.type||"success"}`,children:ie.message})})]})}const GF="/assets/vibe80_dark-D7OVPKcU.svg",qF="/assets/vibe80_light-BJK37ybI.svg",YF=x.lazy(()=>wi(()=>import("./ExplorerPanel-D3IbBsXz.js"),[])),JF=x.lazy(()=>wi(()=>import("./DiffPanel-BKLnyIAZ.js"),[])),XF=x.lazy(()=>wi(()=>import("./TerminalPanel-BQfMEm-u.js"),[])),QF=x.lazy(()=>wi(()=>import("./SettingsPanel-BfkchMnR.js"),[])),ZF=x.lazy(()=>wi(()=>import("./LogsPanel-BwJAFHRP.js"),[])),ez=()=>new URLSearchParams(window.location.search).get("session"),tz=()=>new URLSearchParams(window.location.search).get("repository"),Yf=()=>{if(ez())return"";const t=tz();return(t?t.trim():"")||""},rz=e=>{if(!e)return"";try{const t=new TextEncoder().encode(e);let r="";return t.forEach(n=>{r+=String.fromCharCode(n)}),btoa(r)}catch{return btoa(e)}},NC={codex:["api_key","auth_json_b64"],claude:["api_key","setup_token"]},K1=(e,t)=>{const r=NC[e]||[];return r.length?r.includes(t==null?void 0:t.authType)?t.authType:r[0]:(t==null?void 0:t.authType)||"api_key"},RC=e=>{const t=e==null?void 0:e.trim();return t?t.startsWith("{")&&t.endsWith("}")?t.slice(1,-1).trim():t:""},nz=e=>e?e.split(/\r?\n/).map(t=>t.trim()).filter(Boolean).map(t=>{const r=t.split("::"),[n,i,s,...a]=r,o=(n||"").trim().toLowerCase(),l=(i||"").trim(),c=(s||"").trim();if(!o||!l||!c)return null;if(o==="radio"||o==="select"){const h=a.map(u=>u.trim()).filter(Boolean);return{type:o,id:l,label:c,choices:h}}if(o==="checkbox"){const u=a.join("::").trim()==="1";return{type:o,id:l,label:c,defaultChecked:u}}if(o==="input"||o==="textarea"){const h=a.join("::").trim();return{type:o,id:l,label:c,defaultValue:h}}return null}).filter(Boolean):[],iz=(e,t=r=>r)=>{const r=/<!--\s*vibe80:(choices|form)\s*([^>]*)-->([\s\S]*?)<!--\s*\/vibe80:\1\s*-->|<!--\s*vibe80:yesno\s*([^>]*)-->/g,n=/<!--\s*vibe80:fileref\s+([^>]+?)\s*-->/g,i=/<!--\s*vibe80:task\s*[^>]*-->/g,s=[],a=[],o=String(e||"").replace(n,(u,m)=>{const v=String(m||"").trim();return v&&a.push(v),""}).replace(i,"");let l="",c=0,h;for(;(h=r.exec(o))!==null;){l+=o.slice(c,h.index),c=h.index+h[0].length;const u=h[1],m=RC(h[2]||h[4]),v=h[3]||"";if(!u){s.push({type:"yesno",question:m,choices:[t("Yes"),t("No")]});continue}if(u==="choices"){const _=v.split(/\r?\n/).map(g=>g.trim()).filter(Boolean);_.length&&s.push({type:"choices",question:m,choices:_});continue}const w=nz(v);w.length&&s.push({type:"form",question:m,fields:w})}return s.length?(l+=o.slice(c),{cleanedText:l.trim(),blocks:s,filerefs:a}):{cleanedText:o,blocks:[],filerefs:a}},sz=e=>{const t=/<!--\s*vibe80:task\s*([^>]*)-->/g,r=String(e||"");let n="",i;for(;(i=t.exec(r))!==null;){const s=RC(i[1]);s&&(n=s)}return n},oz=e=>{const t=String(e||"");return t?t.split(/\r?\n/)[0].trim():""},G1=async e=>{var r;if(!e)return;if((r=navigator==null?void 0:navigator.clipboard)!=null&&r.writeText)try{await navigator.clipboard.writeText(e);return}catch{}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)},az=1024,lz=5,cz=140,uz=60,OC="repoHistory",MC="authMode",jC="openAiAuthMode",BC="llmProvider",FC="llmProviders",zC="chatCommandsVisible",$C="toolResultsVisible",UC="notificationsEnabled",HC="themeMode",WC="debugMode",fz=10,hz=new Set(["png","jpg","jpeg","gif","webp","bmp","svg","avif"]),wl=(e,t)=>e?e.length<=t?e:`${e.slice(0,t)}…`:"",ta=e=>{if(!e)return"";if(typeof e=="string"){const t=e.split("/");return t[t.length-1]||e}if(e.name)return e.name;if(e.path){const t=e.path.split("/");return t[t.length-1]||e.path}return""},dz=(e,t=r=>r)=>{const r=ta(e);if(!r||!r.includes("."))return t("FILE");const n=r.split(".").pop();return n?n.toUpperCase():t("FILE")},pz=(e,t=r=>r)=>{if(!Number.isFinite(e))return"";if(e<1024)return t("{{count}} B",{count:e});const r=e/1024;if(r<1024)return t("{{count}} KB",{count:Math.round(r)});const n=r/1024;return t("{{count}} MB",{count:n.toFixed(1)})},_n=e=>Array.isArray(e)?e.map(t=>{if(!t)return null;if(typeof t=="string")return{name:ta(t),path:t};if(typeof t=="object"){const r=t.name||ta(t.path);return{...t,name:r}}return null}).filter(Boolean):[],mz=e=>{var n;const t=ta(e);if(!t||!t.includes("."))return!1;const r=(n=t.split(".").pop())==null?void 0:n.toLowerCase();return hz.has(r)},gz=()=>{try{const e=localStorage.getItem(OC);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(r=>typeof r=="string").map(r=>r.trim()).filter(Boolean):[]}catch{return[]}},vz=()=>{try{const e=localStorage.getItem(MC);if(e==="ssh"||e==="http"||e==="none")return e}catch{}return"none"},_z=()=>{try{const e=localStorage.getItem(jC);if(e==="apiKey"||e==="authFile")return e}catch{}return"apiKey"},yz=()=>{try{const e=localStorage.getItem(zC);if(e==="true"||e==="false")return e==="true"}catch{}return!0},wz=()=>{try{const e=localStorage.getItem($C);if(e==="true"||e==="false")return e==="true"}catch{}return!1},bz=()=>{try{const e=localStorage.getItem(UC);if(e==="true"||e==="false")return e==="true"}catch{}return!0},Sz=()=>{try{const e=localStorage.getItem(HC);if(e==="light"||e==="dark")return e}catch{}return"light"},Cz=()=>{try{const e=localStorage.getItem(WC);if(e==="true"||e==="false")return e==="true"}catch{}return!1},fo=()=>{try{const e=localStorage.getItem(BC);if(e==="codex"||e==="claude")return e}catch{}return"codex"},kz=()=>{try{const e=localStorage.getItem(FC);if(!e)return[fo()];const t=JSON.parse(e);if(!Array.isArray(t))return[fo()];const r=t.filter(n=>n==="codex"||n==="claude");return r.length?r:[fo()]}catch{}return[fo()]},xz=(e,t)=>{const r=t.trim();if(!r)return e;const n=[r,...e.filter(i=>i!==r)].slice(0,fz);return n.length===e.length&&n.every((i,s)=>i===e[s])?e:n},Ez=(e,t,r)=>{const n=new Blob([t],{type:r}),i=URL.createObjectURL(n),s=document.createElement("a");s.href=i,s.download=e,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(i)},Az=(e,t)=>{const r=e||"chat",n=new Date().toISOString().replace(/[:.]/g,"-");return`${r}-${n}.${t}`},bl=e=>{if(!e)return"";const n=e.trim().replace(/\/+$/,"").split(/[?#]/)[0].match(/([^/:]+)$/);return n?n[1]:""},Lz=e=>{if(!e)return"plaintext";if((e.split("/").pop()||"").toLowerCase()==="dockerfile")return"dockerfile";const r=e.toLowerCase().match(/\.([a-z0-9]+)$/);switch(r?r[1]:""){case"js":case"cjs":case"mjs":return"javascript";case"jsx":return"javascript";case"ts":return"typescript";case"tsx":return"typescript";case"json":return"json";case"md":case"markdown":return"markdown";case"css":return"css";case"scss":return"scss";case"less":return"less";case"html":case"htm":return"html";case"yml":case"yaml":return"yaml";case"sh":case"bash":case"zsh":return"shell";case"py":return"python";case"go":return"go";case"java":return"java";case"c":return"c";case"cc":case"cpp":case"cxx":case"hpp":case"h":return"cpp";case"rs":return"rust";case"rb":return"ruby";case"php":return"php";case"sql":return"sql";case"toml":return"toml";case"xml":return"xml";case"dockerfile":return"dockerfile";default:return"plaintext"}},Pz=(e,t=r=>r)=>e==="codex"?t("Codex"):e==="claude"?t("Claude"):e||"";function Tz(){const{t:e,language:t,setLanguage:r,locale:n}=IC(),[i,s]=x.useState([]),[a,o]=x.useState(""),[l,c]=x.useState(()=>e("Connecting...")),[h,u]=x.useState(!1),[m,v]=x.useState(!1),[w,_]=x.useState(""),[g,d]=x.useState(!1),[f,p]=x.useState(null),[y,S]=x.useState(Yf),[b,k]=x.useState(Yf),[C,A]=x.useState(""),[P,O]=x.useState(null),[R,M]=x.useState(vz),[z,U]=x.useState(""),[q,Q]=x.useState(""),[H,I]=x.useState(""),[L,B]=x.useState("new"),[D,T]=x.useState(!1),[$,Y]=x.useState({}),[W,j]=x.useState(!0),[N,G]=x.useState(!1),[V,X]=x.useState(null),[ne,ue]=x.useState(fo),[ve,le]=x.useState(kz),[Se,ye]=x.useState(!1),[Me,Ne]=x.useState(_z),[Ue,Ke]=x.useState(null),[Ye,Ee]=x.useState(""),[je,Ce]=x.useState(""),[Z,se]=x.useState(!1),[we,F]=x.useState(null),[_e,De]=x.useState(!1),[ee,Ae]=x.useState(null),[Ie,St]=x.useState(""),[ce,he]=x.useState(!1),[J,K]=x.useState(!1),[re,ie]=x.useState(!1),[ae,oe]=x.useState(()=>!!Yf()),[ge,Ge]=x.useState(yz),[We,Je]=x.useState(wz),[xt,xi]=x.useState(bz),[Xe,Et]=x.useState(Sz),Hr=x.useRef(null),Ls=x.useRef(null),_r=x.useCallback((te,fe="success")=>{X({message:te,type:fe}),Hr.current&&clearTimeout(Hr.current),Hr.current=setTimeout(()=>{X(null),Hr.current=null},3e3)},[]);x.useEffect(()=>()=>{Hr.current&&(clearTimeout(Hr.current),Hr.current=null)},[]);const[VC,Ps]=x.useState({main:"chat"}),_a=x.useRef(null),ya=x.useRef(null),KC=x.useRef(null),GC=x.useRef(null),vm=x.useMemo(()=>({tree:null,loading:!1,error:"",treeTruncated:!1,treeTotal:0,openTabPaths:[],activeFilePath:null,filesByPath:{},selectedPath:null,selectedType:null,renamingPath:null,renameDraft:"",deletingPath:null,fileContent:"",draftContent:"",fileLoading:!1,fileSaving:!1,fileError:"",fileSaveError:"",fileTruncated:!1,fileBinary:!1,editMode:!1,isDirty:!1,statusByPath:{},statusLoading:!1,statusError:"",statusLoaded:!1,expandedPaths:[]}),[]),[hu,du]=x.useState({}),[qC,wa]=x.useState(null),[YC,Ts]=x.useState([]),[pu,mu]=x.useState(!0),[JC,Ds]=x.useState({main:"all"}),[_m,ym]=x.useState(!1),[wm,gu]=x.useState(null),[ba,bm]=x.useState(!0),Sm=x.useRef({}),[XC,vu]=x.useState(""),QC=x.useRef(new Map),ZC=te=>{var fe;if(!(te!=null&&te.type))return"";if(te.type==="commandExecution"){const xe=((fe=te.commandActions)==null?void 0:fe.command)||te.command||e("Command");return e("Command: {{command}}",{command:xe})}return te.type==="fileChange"?e("Applying changes..."):te.type==="mcpToolCall"?e("Tool: {{tool}}",{tool:te.tool}):te.type==="reasoning"?e("Reasoning..."):te.type==="agentMessage"?e("Generating response..."):""},{commandPanelOpen:ek,setCommandPanelOpen:Is,toolResultPanelOpen:tk,setToolResultPanelOpen:Ns}=t9(),[Cm,rk]=x.useState(()=>gz()),[km,Dz]=x.useState(()=>Cz()),cr=x.useRef(null),xm=x.useRef(!0),Sa=x.useRef(null),Ca=x.useRef(null),Em=x.useRef(null),{setToolbarExportOpen:_u}=e9(),Am=x.useRef(null),Lm=x.useRef(null),Pm=x.useRef(null),nk=x.useRef(null),ik=x.useRef(null),sk=x.useRef(null),ok=x.useRef(null),ak=x.useRef(null),lk=x.useRef(null),ck=x.useRef(null),uk=x.useRef(0),fk=x.useRef(!1),hk=x.useRef(null),dk=x.useRef(0),ka=x.useRef([]),{apiFetch:Xt,deploymentMode:yu,handleDeleteSession:pk,handleLeaveWorkspace:Tm,handleWorkspaceCopy:mk,handleWorkspaceProvidersSubmit:gk,handleWorkspaceSubmit:vk,loadWorkspaceProviders:_k,loadWorkspaceSessions:yk,providersBackStep:wk,setProvidersBackStep:bk,setWorkspaceAuthExpanded:Sk,setWorkspaceAuthFiles:Ck,setWorkspaceError:Dm,setWorkspaceIdInput:kk,setWorkspaceMode:Im,setWorkspaceProviders:xk,setWorkspaceProvidersEditing:Ek,setWorkspaceSecretInput:Ak,setWorkspaceStep:Lk,setWorkspaceToken:Pk,workspaceAuthExpanded:Tk,workspaceAuthFiles:Dk,workspaceBusy:Nm,workspaceCopied:Ik,workspaceCreated:Nk,workspaceError:Rk,workspaceId:Ok,workspaceIdInput:Mk,workspaceMode:jk,workspaceProviders:Bk,workspaceProvidersEditing:Fk,workspaceSecretInput:zk,workspaceSessionDeletingId:$k,workspaceSessions:Uk,workspaceSessionsError:Hk,workspaceSessionsLoading:Wk,workspaceStep:xa,workspaceToken:Wr}=IB({t:e,encodeBase64:rz,copyTextToClipboard:G1,extractRepoName:bl,setSessionMode:B,showToast:_r,getProviderAuthType:K1}),{handoffOpen:Vk,handoffQrDataUrl:Rm,handoffLoading:wu,handoffError:Om,handoffRemaining:bu,requestHandoffQr:Mm,closeHandoffQr:jm}=qB({t:e,apiFetch:Xt,attachmentSessionId:f==null?void 0:f.sessionId}),{gitIdentityName:Kk,gitIdentityEmail:Gk,gitIdentityGlobal:qk,gitIdentityRepo:Yk,gitIdentityLoading:Jk,gitIdentitySaving:Xk,gitIdentityError:Qk,gitIdentityMessage:Zk,setGitIdentityName:e2,setGitIdentityEmail:t2,handleSaveGitIdentity:r2}=YB({t:e,apiFetch:Xt,attachmentSessionId:f==null?void 0:f.sessionId}),Ei=x.useMemo(()=>new Map,[]),Rs=x.useMemo(()=>new Map,[]),Os=x.useMemo(()=>bl(f==null?void 0:f.repoUrl),[f==null?void 0:f.repoUrl]),Bm=Xe==="dark"?GF:qF,Fm=x.useMemo(()=>{const te=[];return _e&&te.push("codex"),J&&te.push("claude"),te},[_e,J]),Ms=x.useMemo(()=>ve.filter(te=>Fm.includes(te)),[ve,Fm]);x.useEffect(()=>{ka.current=i},[i]),x.useEffect(()=>{Sm.current=hu},[hu]),x.useEffect(()=>{xm.current=pu},[pu]);const{attachmentPreview:js,attachmentsError:zm,attachmentsLoading:$m,draftAttachments:Bs,renderMessageAttachments:n2,setAttachmentPreview:Um,setAttachmentsError:Ea,setAttachmentsLoading:Su,setDraftAttachments:Fs}=UB({attachmentSessionId:f==null?void 0:f.sessionId,workspaceToken:Wr,normalizeAttachments:_n,isImageAttachment:mz,getAttachmentName:ta,attachmentIcon:E.jsx(Be,{icon:QD}),t:e}),Hm=x.useMemo(()=>f!=null&&f.sessionId?`choices:${f.sessionId}`:null,[f==null?void 0:f.sessionId,Xt]),{choiceSelections:i2,setChoiceSelections:s2,activeForm:Aa,activeFormValues:Wm,openVibe80Form:o2,closeVibe80Form:Cu,updateActiveFormValue:zs,submitActiveForm:a2,handleChoiceClick:l2}=JB({choicesKey:Hm,input:a,setInput:o,handleSendMessageRef:_a,draftAttachments:Bs,setDraftAttachments:Fs});XB({authMode:R,llmProvider:ne,selectedProviders:ve,openAiAuthMode:Me,showChatCommands:ge,showToolResults:We,notificationsEnabled:xt,themeMode:Xe,repoHistory:Cm,debugMode:km,setLlmProvider:ue,setOpenAiLoginError:Ce,setClaudeLoginError:St,AUTH_MODE_KEY:MC,LLM_PROVIDER_KEY:BC,LLM_PROVIDERS_KEY:FC,OPENAI_AUTH_MODE_KEY:jC,CHAT_COMMANDS_VISIBLE_KEY:zC,TOOL_RESULTS_VISIBLE_KEY:$C,NOTIFICATIONS_ENABLED_KEY:UC,THEME_MODE_KEY:HC,REPO_HISTORY_KEY:OC,DEBUG_MODE_KEY:WC}),x.useMemo(()=>{const te=[];return(i||[]).forEach(fe=>{if((fe==null?void 0:fe.role)==="commandExecution"){const xe=te[te.length-1];(xe==null?void 0:xe.groupType)==="commandExecution"?xe.items.push(fe):te.push({groupType:"commandExecution",id:`command-group-${fe.id}`,items:[fe]});return}te.push(fe)}),te},[i]);const{isMobileLayout:hn}=QB({themeMode:Xe,setSideOpen:ym}),{applyMessages:c2,mergeAndApplyMessages:u2}=c9({normalizeAttachments:_n,messageIndex:Ei,commandIndex:Rs,messagesRef:ka,setMessages:s,setCommandPanelOpen:Is,setToolResultPanelOpen:Ns}),{activeWorktreeId:qe,activeWorktreeIdRef:Vm,applyWorktreesList:f2,closeWorktree:h2,createWorktree:d2,handleSelectWorktree:p2,loadMainWorktreeSnapshot:ku,requestWorktreeMessages:m2,requestWorktreesList:g2,renameWorktreeHandler:v2,setActiveWorktreeId:La,setWorktrees:Qt,worktrees:Pa}=NB({apiFetch:Xt,attachmentSessionId:f==null?void 0:f.sessionId,availableProviders:Ms,llmProvider:ne,messagesRef:ka,normalizeAttachments:_n,applyMessages:c2,socketRef:cr,setPaneByTab:Ps,setLogFilterByTab:Ds,showToast:_r,t:e}),{logFilter:_2,setLogFilter:y2,scopedRpcLogs:w2,filteredRpcLogs:b2}=ZB({rpcLogs:YC,activeWorktreeId:qe,locale:n,logFilterByTab:JC,setLogFilterByTab:Ds}),{ensureNotificationPermission:S2,maybeNotify:C2,lastNotifiedIdRef:k2}=BB({notificationsEnabled:xt,t:e}),Ta=x.useRef(()=>{}),x2=x.useCallback((...te)=>{var fe;return(fe=Ta.current)==null?void 0:fe.call(Ta,...te)},[]),{branches:E2,branchError:A2,branchLoading:L2,currentBranch:Ai,defaultBranch:P2,loadBranches:Km,loadProviderModels:T2,modelError:D2,modelLoading:I2,models:Gm,providerModelState:N2,selectedModel:R2,selectedReasoningEffort:qm,setModelError:$s,setModelLoading:Us,setModels:O2,setProviderModelState:M2,setSelectedModel:xu,setSelectedReasoningEffort:j2}=VB({apiFetch:Xt,attachmentSessionId:f==null?void 0:f.sessionId,llmProvider:ne,loadRepoLastCommit:x2,processing:h,socketRef:cr,t:e}),{currentDiff:B2,diffFiles:F2,diffStatusLines:z2,hasCurrentChanges:$2,untrackedFilePanels:U2,untrackedLoading:H2,loadRepoLastCommit:Hs,loadWorktreeLastCommit:Eu,repoLastCommit:Da,requestRepoDiff:Ia,requestWorktreeDiff:Na,setRepoDiff:Ra,setRepoLastCommit:Au,setWorktreeLastCommitById:Lu,worktreeLastCommitById:Pu}=$B({apiFetch:Xt,attachmentSessionId:f==null?void 0:f.sessionId,currentBranch:Ai,activeWorktreeId:qe,parseDiff:q4,setWorktrees:Qt,worktrees:Pa,t:e});x.useEffect(()=>{Ta.current=Hs},[Hs]);const Ze=qe&&qe!=="main",ke=Ze?Pa.get(qe):null,Vr=Ze?ke==null?void 0:ke.provider:ne,Ym=Ze?ke==null?void 0:ke.model:R2,ur=qe||"main",mt=x.useMemo(()=>{const te=f==null?void 0:f.sessionId;return te?`${te}::${ur}`:null},[f==null?void 0:f.sessionId,ur]),Tu=x.useMemo(()=>{if(!mt)return[];const te=$[mt]||{};return Object.values(te).sort((fe,xe)=>fe.messageId!==xe.messageId?String(fe.messageId||"").localeCompare(String(xe.messageId||"")):(fe.lineIndex||0)-(xe.lineIndex||0))},[mt,$]),W2=x.useCallback((te,fe)=>{!mt||!te||Y(xe=>{const Te=xe[mt];return!Te||!Te[te]?xe:{...xe,[mt]:{...Te,[te]:{...Te[te],annotationText:fe}}}})},[mt]),V2=x.useCallback(te=>{!mt||!te||Y(fe=>{const xe=fe[mt];if(!xe||!xe[te])return fe;const Te={...xe};if(delete Te[te],Object.keys(Te).length===0){const $e={...fe};return delete $e[mt],$e}return{...fe,[mt]:Te}})},[mt]),K2=x.useCallback(({messageId:te,lineIndex:fe,lineText:xe})=>{if(!mt||!te)return;const Te=`${te}:${fe}`;Y($e=>{const ft=$e[mt]||{},yr=ft[Te];return{...$e,[mt]:{...ft,[Te]:{annotationKey:Te,messageId:te,lineIndex:fe,lineText:xe||"",annotationText:(yr==null?void 0:yr.annotationText)||""}}}})},[mt]),G2=x.useCallback(()=>{mt&&Y(te=>{if(!te[mt])return te;const fe={...te};return delete fe[mt],fe})},[mt]),q2=x.useCallback(te=>{const fe=String(te||"").trim();if(!fe)return"";const xe=Tu.filter($e=>{var ft;return(ft=$e==null?void 0:$e.annotationText)==null?void 0:ft.trim()}).map($e=>({lineText:$e.lineText||"",annotationText:$e.annotationText.trim()}));return xe.length===0?fe:`${xe.map($e=>`> ${$e.lineText}
706
+ `;o(l(w,"md"),f,"text/markdown");return}const g={exportedAt:new Date().toISOString(),repoUrl:t||r||"",tab:{type:n?"worktree":"main",worktreeId:(i==null?void 0:i.id)||null,worktreeName:(i==null?void 0:i.name)||null,branchName:(i==null?void 0:i.branchName)||null},messages:v.map(d=>d.role==="commandExecution"?{id:d.id,role:d.role,command:d.command||"",output:d.output||"",status:d.status||""}:d.role==="tool_result"?{id:d.id,role:d.role,text:d.text||"",toolResult:d.toolResult||null}:{id:d.id,role:d.role,text:d.text||"",attachments:a(d.attachments||[])})};o(l(w,"json"),JSON.stringify(g,null,2),"application/json")},[i,t,e,o,c,l,n,a,r,h,s])}}function g9({input:e,setInput:t,setMessages:r,setDraftAttachments:n,socketRef:i,connected:s,normalizeAttachments:a,draftAttachments:o,setWorktrees:l,setProcessing:c,setActivity:h,processingLabel:u,handleSendMessageRef:m,ensureNotificationPermission:v}){const w=x.useCallback((d,f,p)=>{const y=(d??e).trim();if(!y||!i.current||!s)return;const S=(p??y).trim();if(!S)return;v==null||v();const b=a(f??o),k=b.map(P=>P==null?void 0:P.path).filter(Boolean),C=k.length>0?`;; attachments: ${JSON.stringify(k)}`:"",A=`${S}${C}`;r(P=>[...P,{id:`user-${Date.now()}`,role:"user",text:y,attachments:b}]),c==null||c(!0),h==null||h(u||"Processing..."),i.current.send(JSON.stringify({type:"worktree_send_message",worktreeId:"main",text:A,displayText:y,attachments:b})),t(""),n([])},[s,o,e,a,n,t,r,i]),_=x.useCallback(d=>{m.current&&m.current(d,[])},[m]),g=x.useCallback((d,f,p,y)=>{const S=(f??e).trim();if(!S||!i.current||!s||!d)return;const b=(y??S).trim();if(!b)return;const k=a(p??o),C=k.map(O=>O==null?void 0:O.path).filter(Boolean),A=C.length>0?`;; attachments: ${JSON.stringify(C)}`:"",P=`${b}${A}`;l(O=>{const R=new Map(O);if(d==="main")return R;const M=R.get(d);if(M){const z=[...M.messages,{id:`user-${Date.now()}`,role:"user",text:S,attachments:k}];R.set(d,{...M,messages:z,status:"processing"})}return R}),d==="main"&&(c==null||c(!0),h==null||h(u||"Processing...")),i.current.send(JSON.stringify({type:"worktree_send_message",worktreeId:d,text:P,displayText:S,attachments:k})),t(""),n([])},[s,o,e,a,n,t,l,i]);return{sendMessage:w,sendCommitMessage:_,sendWorktreeMessage:g}}function v9({activeWorktreeId:e,setToolbarExportOpen:t,setWorktrees:r,lastNotifiedIdRef:n,attachmentSessionId:i,apiFetch:s,setMessages:a,messageIndex:o,commandIndex:l,setChoiceSelections:c,choicesKey:h,setCommandPanelOpen:u,setToolResultPanelOpen:m,llmProvider:v}){return{handleClearChat:x.useCallback(async()=>{if(t(!1),e!=="main"){if(r(_=>{const g=new Map(_),d=g.get(e);return d&&g.set(e,{...d,messages:[]}),g}),n.current=null,i)try{await s(`/api/v1/sessions/${encodeURIComponent(i)}/clear`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:e})})}catch{}return}if(a([]),o.clear(),l.clear(),c({}),h&&localStorage.removeItem(h),u({}),m({}),n.current=null,i)try{await s(`/api/v1/sessions/${encodeURIComponent(i)}/clear`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:v})})}catch{}},[e,s,i,h,l,v,o,c,u,a,m,t,r,n])}}const _9="Rename",y9="Stopped",w9="Annotations",b9={"Provider cannot be disabled: active sessions use it.":"Provider cannot be disabled: active sessions use it.","New file":"New file",Rename:_9,"File path":"File path","e.g. src/new-file.ts":"e.g. src/new-file.ts","Unable to rename.":"Unable to rename.","Unable to create file.":"Unable to create file.","Unable to delete.":"Unable to delete.","Renamed.":"Renamed.","File created.":"File created.","New folder":"New folder","Folder path":"Folder path","e.g. src/new-folder":"e.g. src/new-folder","Folder created.":"Folder created.","Unable to create folder.":"Unable to create folder.","Deleted.":"Deleted.",'Delete "{{path}}"? This action is irreversible.':'Delete "{{path}}"? This action is irreversible.',Stopped:y9,"New worktree":"New worktree","Worktree is stopped. Wake it up before sending a message.":"Worktree is stopped. Wake it up before sending a message.","Claude Code does not natively support forked sessions with directory changes. This feature is experimental.":"Claude Code does not natively support forked sessions with directory changes. This feature is experimental.","binary data":"binary data","Loading untracked files...":"Loading untracked files...","Unable to load file.":"Unable to load file.","User command : {{command}}":"User command : {{command}}","Toggle annotation mode":"Toggle annotation mode","Toggle annotation mode (EXPERIMENTAL)":"Toggle annotation mode (EXPERIMENTAL)","Annotation mode enabled.":"Annotation mode enabled.","Annotation mode disabled.":"Annotation mode disabled.","Usage: /annotation on|off":"Usage: /annotation on|off","Annotate line":"Annotate line",Annotations:w9,"Only sent with the next message.":"Only sent with the next message.","No annotations yet.":"No annotations yet.","Write annotation...":"Write annotation..."},S9="Tout",C9="api_key",k9="Assistant",x9="Pièces jointes",E9="auth_json_b64",A9="Revenir",L9="Backlog",P9="Annuler",T9="Claude",D9="Clear",I9="Cloner",N9="Fermer",R9="Codex",O9="Commande",M9="Commit",j9="Termine",B9="Connecte",F9="Continuer",z9="Copier",$9="Créer",U9="Creation",H9="Supprimer",W9="Diff",V9="Deconnecte",K9="Éditer",G9="Anglais",q9="Explorateur",Y9="Exporter",J9="FILE",X9="Formulaire",Q9="Français",Z9="Langue",eF="Lancer",tF="Logs",rF="Main",nF="Markdown",iF="Messages",sF="Modele",oF="Non",aF="Suivant",lF="Aucune",cF="Notifications",uF="Aperçu",fF="Precedent",hF="Provider",dF="Pret",pF="Reasoning",mF="Rafraichir",gF="Renommer",vF="Arrete",_F="Regenerer",yF="Reprendre",wF="Sauver",bF="Secret",SF="Envoyer",CF="Session",kF="Paramètres",xF="setup_token",EF="Stdin",AF="stdin",LF="Stdout",PF="stdout",TF="Stop",DF="Onglet",IF="Terminal",NF="Tool",RF="Annotations",OF="Utilisateur",MF="workspaceSecret",jF="Worktree",BF="Oui",FF={"-----BEGIN OPENSSH PRIVATE KEY-----":"-----BEGIN OPENSSH PRIVATE KEY-----","Access an existing space with your credentials":"Accedez a un espace existant avec vos identifiants","Add to backlog":"Ajouter au backlog","Add attachment":"Ajouter une pièce jointe","AI providers":"Providers IA","AI providers (required)":"Providers IA (obligatoire)","AI providers updated.":"Providers IA mis a jour.",All:S9,"All changes will be lost. What would you like to do?":"Toutes les modifications seront perdues. Que souhaitez-vous faire ?","Allow default internet access for this session.":"Autoriser l'accès internet par defaut pour cette session.","Allow sharing the Git folder for the main branch by default.":"Autoriser le partage du dossier Git pour la branche principale par defaut.",api_key:C9,"Applying changes...":"Application de modifications...",Assistant:k9,"Attached image":"Image jointe","Added to backlog.":"Ajouté au backlog.",Attachments:x9,"Auth {{provider}}":"Auth {{provider}}",auth_json_b64:E9,"Authentication failed.":"Echec de l'authentification.",Back:A9,"Back to previous view":"Revenir à la vue précédente",Backlog:L9,"Show backlog":"Afficher le backlog","Binary file not displayed.":"Fichier binaire non affiche.",Cancel:P9,"Chat history":"Historique du chat","Chat tools":"Outils du chat",Claude:T9,Clear:D9,Clone:I9,"Clone a repository to start a new session":"Cloner un depot pour demarrer une nouvelle session","Start a session":"Démarrer une session","Click here to learn more.":"Cliquez ici pour en savoir plus.","Cloning repository...":"Clonage du depot...",Close:N9,"Close panel":"Fermer le panneau","Close the worktree?":"Fermer le worktree ?",Codex:R9,"Codex (OpenAI)":"Codex (OpenAI)",Command:O9,"Command required.":"Commande requise.","Capture screenshot":"Capturer une capture d'ecran","Screenshot failed.":"Echec de la capture d'ecran.","Screenshot captured.":"Capture d'ecran ajoutee.","Git command required.":"Commande git requise.","Command: {{command}}":"Commande: {{command}}",Commit:M9,"Commit & Push":"Commit & Push",Completed:j9,"Configure AI providers":"Configurer les providers IA","Configure AI providers for this workspace.":"Configurez les providers IA pour ce workspace.","Configure the workspace":"Configurer le workspace",Connected:B9,"Connecting...":"Connexion...",Continue:F9,"Continue on mobile":"Continuer sur mobile",Copy:z9,"Copy code":"Copier le code","Copy workspace ID":"Copier le workspace ID","Copy workspace secret":"Copier le workspace secret",Create:$9,"Create a new space for you or your team":"Creez un nouvel espace pour vous ou votre equipe","Create a workspace":"Creer un workspace",Creating:U9,"Dark mode":"Mode sombre","Debug mode":"Mode débug","Default model":"Modele par defaut","Default reasoning":"Reasoning par defaut",Delete:H9,'Delete session "{{title}}"? This action is irreversible.':'Supprimer la session "{{title}}" ? Cette action est irreversible.',"Delete worktree":"Supprimer le worktree","Deleting...":"Suppression...",Diff:W9,Disconnected:V9,"e.g. refactor-auth":"ex: refactor-auth",Edit:K9,"Enable access to logs and Markdown/JSON export.":"Active l'accès aux logs et à l'export Markdown/JSON.","Enable the dark theme for the interface.":"Active le thème sombre pour l'interface.",English:G9,Error:"Erreur","Error during generation.":"Erreur lors de la generation.","Error during loading.":"Erreur lors du chargement.","Error: {{message}}":"Erreur: {{message}}","Execution in progress":"Execution en cours","Existing sessions":"Sessions existantes","Expires in {{seconds}}s":"Expire dans {{seconds}}s",Explorer:q9,Export:Y9,FILE:J9,"File truncated for display.":"Fichier tronque pour l'affichage.",Form:X9,French:Q9,"Full name":"Nom complet","Generating QR code...":"Generation du QR code...","Generating response...":"Generation de reponse...","Git authentication failed{{suffix}}.":"Echec d'authentification Git{{suffix}}.","Git identity for this repository":"Identité Git pour ce dépôt","Git repository not found{{suffix}}.":"Depot Git introuvable{{suffix}}.","git@gitea.devops:my-org/my-repo.git":"git@gitea.devops:mon-org/mon-repo.git","Global values: {{name}} / {{email}}.":"Valeurs globales: {{name}} / {{email}}.","In progress":"En cours","Internet access":"Internet access","Internet access enabled":"Accès internet activé","Invalid resume token.":"Token de reprise invalide.","Invalid workspace token. Please sign in again.":"Token workspace invalide. Merci de vous reconnecter.","Join a workspace":"Rejoindre un workspace",JSON:"JSON","JSON credentials":"JSON credentials","JSON-RPC":"JSON-RPC","Key or token":"Cle ou token","Key required for {{provider}}.":"Cle requise pour {{provider}}.",Language:Z9,"Last activity: {{date}}":"Derniere activite: {{date}}",Launch:eF,"Leave session":"Quitter la session","Leave workspace":"Quitter le workspace","List truncated after {{count}} entries.":"Liste tronquee apres {{count}} entrees.","Loading sessions...":"Chargement des sessions...","Loading...":"Chargement...",Logs:tF,Main:rF,Markdown:nF,"Merge into {{branch}}":"Merge vers {{branch}}",Messages:iF,Model:sF,"Name (optional)":"Nom (optionnel)","Name and email required.":"Nom et email requis.","New message":"Nouveau message","New file":"Nouveau fichier","New folder":"Nouveau dossier","New worktree":"Nouveau worktree","New session":"Nouvelle session",No:oF,"No changes detected.":"Aucun changement detecte.","No file found.":"Aucun fichier trouve.","No file selected":"Aucun fichier selectionne","binary data":"données binaires","Loading untracked files...":"Chargement des fichiers non suivis...","Unable to load file.":"Impossible de charger le fichier.","Claude Code does not natively support forked sessions with directory changes. This feature is experimental.":"Claude Code ne supporte pas nativement les sessions forkées avec changement de répertoire, cette feature est expérimentale.","No logs yet.":"Aucun log pour le moment.","No options":"Aucune option","No options.":"Aucune option.","No pending tasks at the moment.":"Aucune tâche en attente pour le moment.","No repository-specific values.":"Aucune valeur spécifique au dépôt.","No sessions available.":"Aucune session disponible.","No commands found.":"Aucune commande trouvée.",Next:aF,"No tasks":"Aucune tâche",None:lF,"Not set":"Non défini",Notifications:cF,"Open form":"Ouvrir le formulaire","Open path":"Ouvrir un chemin","Open settings":"Ouvrir les paramètres","Open diff view":"Ouvrir la vue diff","Run shell command":"Executer une commande shell","Run git command":"Executer une commande git","OpenAI authentication failed.":"Echec de l'authentification OpenAI.","Password or PAT":"Mot de passe ou PAT","Path required.":"Le chemin est requis.","Path not found.":"Chemin introuvable.",Preview:uF,"Private SSH key (not recommended)":"Cle SSH privee (non recommande)",Previous:fF,"Processing...":"Traitement en cours...","Provide user.name and user.email for repository commits.":"Renseignez user.name et user.email pour les commits du dépôt.",Provider:hF,"QR code":"QR code","QR code expired":"QR code expire","QR code unavailable.":"QR code indisponible.",Ready:dF,Reasoning:pF,"Reasoning...":"Raisonnement...",Refresh:mF,Rename:gF,"Renamed.":"Renomme.",Stopped:vF,Regenerate:_F,"Remove {{label}}":"Retirer {{label}}","Repository authentication (optional)":"Authentification depot (optionnelle)","Repository diff":"Diff du repository","Repository Git identity updated.":"Identité Git du dépôt mise à jour.","Repository values: {{name}} / {{email}}.":"Valeurs du dépôt: {{name}} / {{email}}.",Resume:yF,"Resume an already configured worktree":"Reprendre un worktree deja configure","Resume an existing session":"Reprendre une session existante","Resume on mobile":"Reprendre sur mobile",Save:wF,"Saving...":"Sauvegarde...","Scan this QR code in the Android app to resume the current session.":"Scannez ce QR code dans l'application Android pour reprendre la session en cours.",Secret:bF,"Select a branch":"Selectionner une branche","Select a file in the tree.":"Selectionnez un fichier dans l'arborescence.","File path":"Chemin du fichier","Folder path":"Chemin du dossier","e.g. src/new-file.ts":"ex: src/nouveau-fichier.ts","e.g. src/new-folder":"ex: src/nouveau-dossier","Select a language":"Selectionner une langue","Select a valid remote branch.":"Selectionnez une branche distante valide.","Select an existing workspace or create a new one.":"Selectionnez un workspace existant ou creez-en un nouveau.","Select at least one provider.":"Selectionnez au moins un provider.","Selected attachments":"Pièces sélectionnées",Send:SF,"Send 'Commit & Push' in chat":"Envoyer 'Commit & Push' dans le chat","Send 'Commit' in chat":"Envoyer 'Commit' dans le chat","Send a message to start a session.":"Envoyez un message pour demarrer une session.",Session:CF,'Session "{{title}}" deleted.':'Session "{{title}}" supprimee.',"Session name (optional)":"Nom de la session (optionnel)","Session not found.":"Session introuvable.",Settings:kF,setup_token:xF,"Deny git credentials access":"Refuser l'accès aux identifiants Git","Provider cannot be disabled: active sessions use it.":"Impossible de désactiver ce provider : des sessions l'utilisent.","Show a notification and sound when a new message arrives.":"Affiche une notification et un son quand un nouveau message arrive.","Show commands in chat":"Afficher les commandes dans le chat","Show executed command blocks in the conversation.":"Affiche les blocs de commandes exécutées dans la conversation.","Show tool results in chat":"Afficher les tool results dans le chat","Show tool_result blocks in the conversation.":"Affiche les blocs tool_result dans la conversation.","Source branch":"Branche source","Start a session to open the terminal.":"Demarrez une session pour ouvrir le terminal.",Stdin:EF,stdin:AF,Stdout:LF,stdout:PF,Stop:TF,"Switching to {{provider}}...":"Basculement vers {{provider}}...",Tab:DF,Terminal:IF,"The key is stored in ~/.ssh for cloning.":"La cle est stockee dans ~/.ssh pour le clonage.","The password can be replaced by a PAT.":"Le mot de passe peut etre remplace par un PAT.","These settings are stored in your browser.":"Ces réglages sont stockés dans votre navigateur.","Vibe80 can run Codex or Claude Code. To continue, provide your Anthropic and/or OpenAI credentials. If you use pay-as-you-go billing, supply an API key.":"Vibe80 peut piloter Codex ou Claude Code. Pour continuer, fournissez vos identifiants Anthropic et/ou OpenAI. Si vous utilisez une facturation a l'usage, fournissez une API key.","For subscription plans, use auth.json from the Codex CLI login (ChatGPT) or a long-lived token from `claude setup-token` (Claude).":"Pour les abonnements, utilisez auth.json apres login Codex en CLI (ChatGPT) ou un token longue duree via `claude setup-token` (Claude).","Vibe80 opens Git-based work sessions. Even in a secure environment, we recommend short-lived and revocable PATs or keys.":"Vibe80 ouvre des sessions de travail basees sur des depots Git. Meme dans un environnement securise, nous recommandons des jetons PAT/cles ephemeres et revocables.","Vibe80 strictly controls access to resources (Git credentials and internet) using sandboxing. ":"Vibe80 controle strictement l'acces aux ressources (identifiants Git et internet) via le sandboxing. ","A workspace is an isolated, secured environment accessible only with credentials. It lets you reuse AI credentials for all future sessions.":"Un workspace est un espace isole et securise, accessible uniquement avec des identifiants. Il permet de reutiliser vos identifiants IA pour toutes vos futures sessions.","You can create multiple workspaces to separate teams, projects, or security boundaries.":"Vous pouvez creer plusieurs workspaces pour separer equipes, projets ou perimetres de securite.",Tool:NF,"Tool result":"Tool result","Tool: {{tool}}":"Outil: {{tool}}","User command : {{command}}":"Commande utilisateur : {{command}}","Toggle annotation mode":"Activer le mode annotation","Toggle annotation mode (EXPERIMENTAL)":"Activer le mode annotation (EXPERIMENTAL)","Annotation mode enabled.":"Mode annotation activé.","Annotation mode disabled.":"Mode annotation désactivé.","Usage: /annotation on|off":"Usage : /annotation on|off","Annotate line":"Annoter la ligne",Annotations:RF,"Only sent with the next message.":"Envoyées uniquement avec le prochain message.","No annotations yet.":"Pas encore d'annotations.","Write annotation...":"Écrire une annotation...","Todo text required.":"Texte de la todo requis.","Unable to change branch.":"Impossible de changer de branche.","Unable to create the attachment session (HTTP {{status}}{{statusText}}){{suffix}}.":"Impossible de creer la session de pieces jointes (HTTP {{status}}{{statusText}}){{suffix}}.","Unable to create the attachment session.":"Impossible de creer la session de pieces jointes.","Unable to delete the session.":"Impossible de supprimer la session.","Unable to delete the session{{suffix}}.":"Impossible de supprimer la session{{suffix}}.","Unable to generate the QR code.":"Impossible de generer le QR code.","Unable to load branches.":"Impossible de charger les branches.","Unable to load Git identity.":"Impossible de charger l'identité Git.","Unable to load Git status.":"Impossible de charger le statut Git.","Unable to load models.":"Impossible de charger les modeles.","Unable to load sessions.":"Impossible de charger les sessions.","Unable to load the commit.":"Impossible de charger le commit.","Unable to load the explorer.":"Impossible de charger l'explorateur.","Unable to load the file.":"Impossible de charger le fichier.","Unable to load tree.":"Impossible de charger l'arborescence.","Unable to load the latest commit.":"Impossible de charger le dernier commit.","Unable to resume the session.":"Impossible de reprendre la session.","Unable to rename.":"Impossible de renommer.","Unable to delete.":"Impossible de supprimer.","Unable to save the file.":"Impossible d'enregistrer le fichier.","Unable to create file.":"Impossible de creer le fichier.","Unable to create folder.":"Impossible de creer le dossier.","Unable to upload attachments.":"Impossible d'uploader les pieces jointes.","Unable to update backlog.":"Impossible de mettre à jour le backlog.","Unexpected error":"Erreur inattendue","Update failed.":"Echec de la mise à jour.","Usage limit reached. Please try again later.":"Limite d'usage atteinte. Merci de reessayer plus tard.","User settings":"Paramètres utilisateur","user.email":"user.email","user.name":"user.name",Username:OF,"Username + password":"Identifiant + mot de passe","Username and password required.":"Identifiant et mot de passe requis.","Validating...":"Validation...","View previous messages ({{count}})":"Voir les messages precedents ({{count}})","Workspace configuration failed.":"Echec de la configuration du workspace.","Workspace created":"Workspace cree","Workspace created hint":"Votre workspace a ete cree avec succes. Gardez ces identifiants scrupuleusement pour un futur acces.","Workspace creation failed.":"Echec de creation du workspace.","Workspace ID":"Workspace ID","Workspace ID and secret are required.":"Workspace ID et secret requis.","Workspace ID required.":"Workspace ID requis.","Workspace Secret":"Workspace Secret","Workspace update failed.":"Echec de mise a jour du workspace.","workspaceId (e.g. w...)":"workspaceId (ex: w...)",workspaceSecret:MF,Worktree:jF,"Worktree diff":"Diff du worktree","Worktree is stopped. Wake it up before sending a message.":"Le worktree est arrete. Relancez-le avant d'envoyer un message.","File created.":"Fichier cree.","Folder created.":"Dossier cree.","Deleted.":"Supprime.",'Delete "{{path}}"? This action is irreversible.':'Supprimer "{{path}}" ? Cette action est irreversible.',"Write your message…":"Écris ton message…",Yes:BF,"You have unsaved changes. Continue without saving?":"Vous avez des modifications non sauvegardees. Continuer sans sauvegarder ?","your.email@example.com":"ton.email@exemple.com","{{count}} attachment(s)":"{{count}} pièce(s) jointe(s)","{{count}} B":"{{count}} o","{{count}} files modified":"{{count}} fichiers modifies","{{count}} item(s)":"{{count}} élément(s)","{{count}} KB":"{{count}} Ko","{{count}} lines":"{{count}} lignes","{{count}} MB":"{{count}} Mo"},PC="uiLanguage",zF={en:b9||{},fr:FF||{}},$F=()=>{try{const e=localStorage.getItem(PC);if(e==="fr"||e==="en")return e}catch{}return"en"},UF=(e,t)=>t?e.replace(/\{\{(\w+)\}\}/g,(r,n)=>Object.prototype.hasOwnProperty.call(t,n)?String(t[n]):r):e,TC=(e,t,r)=>{const i=(zF[e]||{})[t]||t;return UF(i,r)},DC=x.createContext({language:"en",setLanguage:()=>{},t:(e,t)=>TC("en",e,t),locale:"en-US"}),HF=({children:e})=>{const[t,r]=x.useState($F);x.useEffect(()=>{try{localStorage.setItem(PC,t)}catch{}},[t]);const n=t==="fr"?"fr-FR":"en-US",i=x.useCallback((a,o)=>TC(t,a,o),[t]),s=x.useMemo(()=>({language:t,setLanguage:r,t:i,locale:n}),[t,i,n]);return E.jsx(DC.Provider,{value:s,children:e})},IC=()=>x.useContext(DC),W1={creating:KD,ready:k_,processing:GD,stopped:k_,completed:fd,error:si},V1={creating:"#9ca3af",ready:"#10b981",processing:"#f59e0b",stopped:"#ef4444",completed:"#3b82f6",error:"#ef4444"};function WF({worktrees:e,activeWorktreeId:t,onSelect:r,onCreate:n,onClose:i,onRename:s,provider:a,providers:o,branches:l,defaultBranch:c,branchLoading:h,branchError:u,defaultInternetAccess:m,defaultDenyGitCredentialsAccess:v,deploymentMode:w,onRefreshBranches:_,providerModelState:g,onRequestProviderModels:d,disabled:f,isMobile:p}){var _e,De;const{t:y}=IC(),[S,b]=x.useState(!1),[k,C]=x.useState(null),[A,P]=x.useState(""),[O,R]=x.useState(""),[M,z]=x.useState(""),U=x.useMemo(()=>Array.isArray(o)&&o.length?o:[a||"codex"],[o,a]),[q,Q]=x.useState(U[0]),[H,I]=x.useState("new"),[L,B]=x.useState("main"),[D,T]=x.useState(""),[$,Y]=x.useState(""),[W,j]=x.useState(!!m),[N,G]=x.useState(typeof v=="boolean"?v:!0),V=x.useMemo(()=>({creating:y("Creating"),ready:y("Ready"),processing:y("In progress"),stopped:y("Stopped"),completed:y("Completed"),error:y("Error")}),[y]),X=x.useRef(null),ne=x.useRef(null);x.useEffect(()=>{k&&X.current&&(X.current.focus(),X.current.select())},[k]),x.useEffect(()=>{S&&ne.current&&ne.current.focus()},[S]),x.useEffect(()=>{if(S&&(j(!!m),G(typeof v=="boolean"?v:!0),M||z(c||""),!(l!=null&&l.length)&&_&&!h&&_(),H==="new"&&d)){const ee=(g==null?void 0:g[q])||{};!ee.loading&&!(ee.models||[]).length&&d(q)}},[S,M,c,l,m,v,_,h,H,q,d]),x.useEffect(()=>{U.includes(q)||Q(U[0])},[U,q]),x.useEffect(()=>{if(H==="new"&&d){const ee=(g==null?void 0:g[q])||{};!ee.loading&&!(ee.models||[]).length&&d(q)}H==="new"&&(T(""),Y(""))},[H,q,d]);const ue=(g==null?void 0:g[q])||{},ve=Array.isArray(ue.models)?ue.models:[],le=x.useMemo(()=>Array.isArray(l)?l.map(ee=>ee.trim()).filter(Boolean):[],[l]),Se=(M||c||"").trim(),ye=!!Se&&le.includes(Se),Me=x.useMemo(()=>ve.find(ee=>ee.isDefault)||null,[ve]),Ne=x.useMemo(()=>ve.find(ee=>ee.model===D)||null,[ve,D]),Ue=H==="new"&&q==="codex"&&(((_e=Ne==null?void 0:Ne.supportedReasoningEfforts)==null?void 0:_e.length)||0)>0;x.useEffect(()=>{H==="new"&&(!D&&(Me!=null&&Me.model)&&T(Me.model),q==="codex"&&!$&&(Me!=null&&Me.defaultReasoningEffort)&&Y(Me.defaultReasoningEffort),q!=="codex"&&$&&Y(""))},[H,q,D,$,Me]),x.useEffect(()=>{var Ae;if(H!=="new"||q!=="codex"){$&&Y("");return}if(!((Ae=Ne==null?void 0:Ne.supportedReasoningEfforts)!=null&&Ae.length)){$&&Y("");return}!Ne.supportedReasoningEfforts.some(Ie=>Ie.reasoningEffort===$)&&$&&Y("")},[H,q,Ne,$]);const Ke=()=>{n&&n({context:H,name:O.trim()||null,provider:q,sourceWorktree:H==="fork"?L:null,startingBranch:Se||null,model:H==="new"&&D||null,reasoningEffort:H==="new"&&$||null,internetAccess:W,denyGitCredentialsAccess:N}),R(""),I("new"),Q(U[0]),B("main"),z(c||""),T(""),Y(""),j(!!m),G(typeof v=="boolean"?v:!0),b(!1)},Ye=ee=>{C(ee.id),P(ee.name)},Ee=()=>{k&&A.trim()&&s&&s(k,A.trim()),C(null),P("")},je=ee=>{ee.key==="Enter"?Ee():ee.key==="Escape"&&(C(null),P(""))},Ce=ee=>{ee.key==="Enter"?Ke():ee.key==="Escape"&&b(!1)},Z=(Array.isArray(e)?e:Array.from(((De=e==null?void 0:e.values)==null?void 0:De.call(e))||[])).slice().sort((ee,Ae)=>{if((ee==null?void 0:ee.id)==="main"&&(Ae==null?void 0:Ae.id)!=="main")return-1;if((Ae==null?void 0:Ae.id)==="main"&&(ee==null?void 0:ee.id)!=="main")return 1;const Ie=ee!=null&&ee.createdAt?new Date(ee.createdAt).getTime():0,St=Ae!=null&&Ae.createdAt?new Date(Ae.createdAt).getTime():0;return Ie-St}),se=Z.map(ee=>({id:ee.id,label:ee.id==="main"?"main":ee.name||ee.branchName||ee.id,provider:ee.provider||ee.id==="main"&&a||null})),we=se.find(ee=>ee.id===L),F=H==="fork"&&(we==null?void 0:we.provider)==="claude";return x.useEffect(()=>{var Ae;if(!se.length)return;if(!se.some(Ie=>Ie.id===L)){const Ie=((Ae=se.find(St=>St.id==="main"))==null?void 0:Ae.id)||se[0].id;B(Ie)}},[L,se]),E.jsxs("div",{className:"worktree-tabs-container",children:[E.jsx("div",{className:"worktree-tabs",children:p?E.jsxs("div",{className:"worktree-tabs-select",children:[E.jsx("select",{className:"worktree-select",value:t,onChange:ee=>!f&&(r==null?void 0:r(ee.target.value)),"aria-label":y("Select a branch"),disabled:f,children:Z.map(ee=>E.jsx("option",{value:ee.id,children:ee.name},ee.id))}),E.jsx("button",{className:"worktree-tab-add",onClick:()=>b(!0),disabled:f||Z.length>=10,title:y("New worktree"),"aria-label":y("New worktree"),children:E.jsx(Be,{icon:bc})})]}):E.jsxs(E.Fragment,{children:[Z.map(ee=>E.jsxs("div",{className:`worktree-tab ${t===ee.id?"active":""}`,onClick:()=>!f&&(r==null?void 0:r(ee.id)),style:{"--tab-accent":ee.color||"#3b82f6"},children:[E.jsx("span",{className:`worktree-status ${ee.status==="processing"?"pulse":""}`,style:{color:V1[ee.status]||V1.ready},title:V[ee.status]||ee.status,children:E.jsx(Be,{icon:W1[ee.status]||W1.ready})}),k===ee.id&&ee.id!=="main"?E.jsx("input",{ref:X,className:"worktree-tab-edit",value:A,onChange:Ae=>P(Ae.target.value),onBlur:Ee,onKeyDown:je,onClick:Ae=>Ae.stopPropagation()}):E.jsx("span",{className:"worktree-tab-name",onDoubleClick:Ae=>{Ae.stopPropagation(),ee.id!=="main"&&Ye(ee)},title:ee.id==="main"?ee.name:`${ee.name||ee.branchName} (${ee.branchName||"main"})`,children:ee.id==="main"?ee.name:ee.name||ee.branchName}),ee.id!=="main"&&E.jsx("button",{className:"worktree-tab-close",onClick:Ae=>{Ae.stopPropagation(),i==null||i(ee.id)},title:y("Close"),children:E.jsx(Be,{icon:si})})]},ee.id)),E.jsx("button",{className:"worktree-tab-add",onClick:()=>b(!0),disabled:f||Z.length>=10,title:y("New worktree"),children:E.jsx(Be,{icon:bc})})]})}),S&&E.jsx("div",{className:"worktree-create-dialog-overlay",onClick:()=>b(!1),children:E.jsxs("div",{className:"worktree-create-dialog",onClick:ee=>ee.stopPropagation(),children:[E.jsx("h3",{children:y("New worktree")}),E.jsxs("div",{className:"worktree-create-grid",children:[E.jsxs("div",{className:"worktree-create-field",children:[E.jsx("label",{children:y("Name (optional)")}),E.jsx("input",{ref:ne,type:"text",placeholder:y("e.g. refactor-auth"),value:O,onChange:ee=>R(ee.target.value),onKeyDown:Ce})]}),E.jsxs("div",{className:"worktree-create-field",children:[E.jsx("label",{children:y("Source branch")}),E.jsx("input",{type:"text",list:"worktree-branch-options",placeholder:c||"main",value:M,onChange:ee=>z(ee.target.value),onKeyDown:Ce}),E.jsx("datalist",{id:"worktree-branch-options",children:le.map(ee=>E.jsx("option",{value:ee},ee))}),!ye&&E.jsx("div",{className:"worktree-field-error",children:y("Select a valid remote branch.")}),u&&E.jsx("div",{className:"worktree-field-error",children:u})]}),E.jsxs("div",{className:"worktree-create-field",children:[E.jsx("label",{children:y("Context")}),E.jsxs("select",{value:H,onChange:ee=>I(ee.target.value==="fork"?"fork":"new"),children:[E.jsx("option",{value:"new",children:y("New")}),E.jsx("option",{value:"fork",children:y("Fork")})]})]}),H==="new"?E.jsxs("div",{className:"worktree-create-field",children:[E.jsx("label",{children:y("Provider")}),E.jsxs("select",{value:q,onChange:ee=>Q(ee.target.value),disabled:U.length<=1,children:[U.includes("codex")&&E.jsx("option",{value:"codex",children:y("Codex (OpenAI)")}),U.includes("claude")&&E.jsx("option",{value:"claude",children:y("Claude")})]})]}):E.jsxs("div",{className:"worktree-create-field",children:[E.jsx("label",{children:y("Source worktree")}),E.jsx("select",{value:L,onChange:ee=>B(ee.target.value||"main"),children:se.map(ee=>E.jsx("option",{value:ee.id,children:ee.label},ee.id))})]}),F&&E.jsx("div",{className:"worktree-create-field is-full",children:E.jsx("div",{className:"worktree-warning-bubble",children:y("Claude Code does not natively support forked sessions with directory changes. This feature is experimental.")})}),H==="new"&&(q==="codex"||q==="claude")&&E.jsxs(E.Fragment,{children:[E.jsxs("div",{className:`worktree-create-field ${Ue?"":"is-full"}`,children:[E.jsx("label",{children:y("Model")}),E.jsxs("select",{value:D,onChange:ee=>T(ee.target.value),disabled:ue.loading||ve.length===0,children:[E.jsx("option",{value:"",children:y("Default model")}),ve.map(ee=>E.jsx("option",{value:ee.model,children:ee.displayName||ee.model},ee.id))]}),ue.error&&E.jsx("div",{className:"worktree-field-error",children:ue.error})]}),Ue&&E.jsxs("div",{className:"worktree-create-field",children:[E.jsx("label",{children:y("Reasoning")}),E.jsxs("select",{value:$,onChange:ee=>Y(ee.target.value),disabled:ue.loading||!Ne,children:[E.jsx("option",{value:"",children:y("Default reasoning")}),((Ne==null?void 0:Ne.supportedReasoningEfforts)||[]).map(ee=>E.jsx("option",{value:ee.reasoningEffort,children:ee.reasoningEffort},ee.reasoningEffort))]})]})]}),E.jsx("div",{className:"worktree-create-field worktree-toggle-field",children:E.jsxs("label",{className:"worktree-toggle",children:[E.jsx("input",{type:"checkbox",checked:W,onChange:ee=>{const Ae=ee.target.checked;j(Ae),Ae||G(!1)}}),E.jsx("span",{children:y("Internet access")})]})}),W&&w!=="mono_user"&&E.jsx("div",{className:"worktree-create-field worktree-toggle-field",children:E.jsxs("label",{className:"worktree-toggle",children:[E.jsx("input",{type:"checkbox",checked:N,onChange:ee=>G(ee.target.checked)}),E.jsx("span",{children:y("Deny git credentials access")})]})})]}),E.jsxs("div",{className:"worktree-create-actions",children:[E.jsx("button",{className:"worktree-btn-cancel",onClick:()=>b(!1),children:y("Cancel")}),E.jsx("button",{className:"worktree-btn-create",onClick:Ke,disabled:!ye||H==="fork"&&!L,children:y("Create")})]})]})})]})}function VF({t:e,brandLogo:t,allTabs:r,activeWorktreeId:n,handleSelectWorktree:i,createWorktree:s,openCloseConfirm:a,renameWorktreeHandler:o,llmProvider:l,availableProviders:c,branches:h,defaultBranch:u,currentBranch:m,branchLoading:v,branchError:w,defaultInternetAccess:_,defaultDenyGitCredentialsAccess:g,deploymentMode:d,loadBranches:f,providerModelState:p,loadProviderModels:y,connected:S,isMobileLayout:b,requestHandoffQr:k,attachmentSession:C,handoffLoading:A,handleOpenSettings:P,handleLeaveSession:O}){return E.jsxs("header",{className:"header",children:[E.jsxs("div",{className:"topbar-left",children:[E.jsx("div",{className:"topbar-spacer"}),E.jsx("div",{className:"topbar-brand",children:E.jsx("img",{className:"brand-logo",src:t,alt:"vibe80"})}),E.jsx("div",{className:"topbar-tabs",children:E.jsx(WF,{worktrees:r,activeWorktreeId:n,onSelect:i,onCreate:s,onClose:a,onRename:o,provider:l,providers:c.length?c:[l],branches:h,defaultBranch:u||m,branchLoading:v,branchError:w,defaultInternetAccess:_,defaultDenyGitCredentialsAccess:g,deploymentMode:d,onRefreshBranches:f,providerModelState:p,onRequestProviderModels:y,disabled:!S,isMobile:b})})]}),E.jsxs("div",{className:"topbar-right",children:[E.jsx("button",{type:"button",className:"icon-button","aria-label":e("Resume on mobile"),title:e("Resume on mobile"),onClick:k,disabled:!(C!=null&&C.sessionId)||A,children:E.jsx(Be,{icon:s6})}),E.jsx("button",{type:"button",className:"icon-button","aria-label":e("Open settings"),onClick:P,children:E.jsx(Be,{icon:Rb})}),E.jsx("button",{type:"button",className:"icon-button","aria-label":e("Leave session"),onClick:O,children:E.jsx(Be,{icon:Ob})})]})]})}function KF({t:e,brandLogo:t,showStep1:r,showStep2:n,showStep3:i,showStep4:s,showMonoLoginRequired:a,headerHint:o,workspaceMode:l,setWorkspaceMode:c,formDisabled:h,handleWorkspaceSubmit:u,workspaceIdInput:m,setWorkspaceIdInput:v,workspaceSecretInput:w,setWorkspaceSecretInput:_,workspaceError:g,handleWorkspaceProvidersSubmit:d,workspaceProvider:f,workspaceAuthExpanded:p,setWorkspaceAuthExpanded:y,setWorkspaceProviders:S,providerAuthOptions:b,getProviderAuthType:k,workspaceAuthFiles:C,setWorkspaceAuthFiles:A,sessionMode:P,setSessionMode:O,setSessionRequested:R,setAttachmentsError:M,loadWorkspaceSessions:z,deploymentMode:U,handleLeaveWorkspace:q,workspaceSessionsLoading:Q,workspaceSessions:H,workspaceSessionsError:I,workspaceSessionDeletingId:L,handleResumeSession:B,handleDeleteSession:D,locale:T,extractRepoName:$,getTruncatedText:Y,isCloning:W,repoDisplay:j,onRepoSubmit:N,sessionNameInput:G,setSessionNameInput:V,repoInput:X,setRepoInput:ne,repoHistory:ue,authMode:ve,setAuthMode:le,sshKeyInput:Se,setSshKeyInput:ye,httpUsername:Me,setHttpUsername:Ne,httpPassword:Ue,setHttpPassword:Ke,defaultInternetAccess:Ye,setDefaultInternetAccess:Ee,defaultDenyGitCredentialsAccess:je,setDefaultDenyGitCredentialsAccess:Ce,attachmentsError:Z,sessionRequested:se,workspaceBusy:we,workspaceProvidersEditing:F,providersBackStep:_e,setWorkspaceStep:De,setWorkspaceProvidersEditing:ee,setWorkspaceError:Ae,setProvidersBackStep:Ie,loadWorkspaceProviders:St,workspaceCreated:ce,workspaceId:he,workspaceCopied:J,handleWorkspaceCopy:K,infoContent:te,toast:ie}){var ae;return E.jsxs("div",{className:"session-gate session-fullscreen",children:[E.jsxs("div",{className:"session-layout session-layout--fullscreen",children:[E.jsxs("div",{className:"session-shell",children:[E.jsxs("div",{className:"session-header",children:[E.jsx("img",{className:"brand-logo",src:t,alt:"vibe80"}),E.jsx("h1",{children:e(a?"Login required":s?"Start a session":i?"Workspace created":n?"Configure AI providers":"Configure the workspace")}),o?E.jsx("p",{className:"session-hint",children:o}):null]}),E.jsxs("div",{className:"session-body",children:[r&&E.jsxs(E.Fragment,{children:[E.jsxs("form",{id:"workspace-form",className:"session-form",onSubmit:u,children:[E.jsxs("div",{className:"session-workspace-options",children:[E.jsxs("button",{type:"button",className:`session-workspace-option ${l==="existing"?"is-selected":""}`,onClick:()=>c("existing"),disabled:h,"aria-pressed":l==="existing",children:[E.jsx("span",{className:"session-workspace-icon is-join","aria-hidden":"true",children:E.jsx(Be,{icon:x_})}),E.jsxs("span",{className:"session-workspace-option-text",children:[E.jsx("span",{className:"session-workspace-option-title",children:e("Join a workspace")}),E.jsx("span",{className:"session-workspace-option-subtitle",children:e("Access an existing space with your credentials")})]})]}),E.jsxs("button",{type:"button",className:`session-workspace-option ${l==="new"?"is-selected":""}`,onClick:()=>c("new"),disabled:h,"aria-pressed":l==="new",children:[E.jsx("span",{className:"session-workspace-icon is-create","aria-hidden":"true",children:E.jsx(Be,{icon:bc})}),E.jsxs("span",{className:"session-workspace-option-text",children:[E.jsx("span",{className:"session-workspace-option-title",children:e("Create a workspace")}),E.jsx("span",{className:"session-workspace-option-subtitle",children:e("Create a new space for you or your team")})]})]})]}),E.jsx("div",{className:`session-panel ${l==="existing"?"is-visible":"is-hidden"}`,"aria-hidden":l!=="existing",children:E.jsxs("div",{className:"session-workspace-form",children:[E.jsxs("div",{className:"session-workspace-form-labels",children:[E.jsx("span",{children:e("Workspace ID")}),E.jsx("span",{children:e("Secret")})]}),E.jsxs("div",{className:"session-workspace-form-grid",children:[E.jsx("input",{type:"text",placeholder:e("workspaceId (e.g. w...)"),value:m,onChange:oe=>v(oe.target.value),disabled:h,spellCheck:!1}),E.jsx("input",{type:"password",placeholder:e("workspaceSecret"),value:w,onChange:oe=>_(oe.target.value),disabled:h,autoComplete:"off"})]})]})})]}),g&&E.jsx("div",{className:"attachments-error",children:g})]}),n&&E.jsxs(E.Fragment,{children:[E.jsx("form",{id:"providers-form",className:"session-form",onSubmit:d,children:E.jsx("div",{className:"session-auth-options session-auth-accordion",children:["codex","claude"].map(oe=>{const ge=f(oe),Ge=e(oe==="codex"?"Codex":"Claude"),We=!!p[oe],Je=!!ge.enabled,xt=F&&Array.isArray(H)&&H.some(Xe=>(Array.isArray(Xe.providers)&&Xe.providers.length?Xe.providers:Xe.activeProvider?[Xe.activeProvider]:[]).includes(oe)),xi=h||xt&&Je;return E.jsxs("div",{className:"session-auth-card",children:[E.jsx("div",{className:"session-auth-header",children:E.jsxs("label",{className:"session-auth-option",children:[E.jsx("input",{type:"checkbox",checked:Je,onChange:()=>{if(xt&&Je)return;const Xe=!Je;y(Et=>({...Et,[oe]:Xe})),S(Et=>({...Et,[oe]:{...Et[oe],enabled:Xe}}))},disabled:xi,title:xt&&Je?e("Provider cannot be disabled: active sessions use it."):void 0}),Ge]})}),Je&&We?E.jsxs("div",{className:"session-auth-grid",children:[E.jsx("select",{value:k(oe,ge),onChange:Xe=>S(Et=>({...Et,[oe]:{...Et[oe],authType:Xe.target.value,authValue:""}})),disabled:h,children:(b[oe]||[]).map(Xe=>E.jsx("option",{value:Xe,children:e(Xe)},Xe))}),k(oe,ge)==="auth_json_b64"?E.jsxs("div",{className:"session-auth-file",children:[E.jsx("input",{type:"file",accept:"application/json,.json",onChange:async Xe=>{var Ls;const Et=(Ls=Xe.target.files)==null?void 0:Ls[0];if(!Et)return;const Hr=await Et.text();S(_r=>({..._r,[oe]:{..._r[oe],authValue:Hr}})),A(_r=>({..._r,[oe]:Et.name})),Xe.target.value=""},disabled:h}),C[oe]?E.jsx("span",{className:"session-auth-file-name",children:C[oe]}):null]}):E.jsx("input",{type:"password",placeholder:e("Key or token"),value:ge.authValue,onChange:Xe=>S(Et=>({...Et,[oe]:{...Et[oe],authValue:Xe.target.value}})),disabled:h,autoComplete:"off"})]}):null]},oe)})})}),g&&E.jsx("div",{className:"attachments-error",children:g})]}),i&&E.jsx(E.Fragment,{children:E.jsxs("div",{className:"workspace-created-card",children:[E.jsxs("div",{className:"workspace-created-row",children:[E.jsx("span",{className:"workspace-created-label",children:e("Workspace ID")}),E.jsx("span",{className:"workspace-created-value",children:(ce==null?void 0:ce.workspaceId)||he}),E.jsx("button",{type:"button",className:"workspace-created-copy",onClick:()=>K("id",(ce==null?void 0:ce.workspaceId)||he||""),"aria-label":e("Copy workspace ID"),children:E.jsx(Be,{icon:J.id?fd:hd})})]}),E.jsxs("div",{className:"workspace-created-row",children:[E.jsx("span",{className:"workspace-created-label",children:e("Workspace Secret")}),E.jsx("span",{className:"workspace-created-value",children:(ce==null?void 0:ce.workspaceSecret)||""}),E.jsx("button",{type:"button",className:"workspace-created-copy",onClick:()=>K("secret",(ce==null?void 0:ce.workspaceSecret)||""),"aria-label":e("Copy workspace secret"),children:E.jsx(Be,{icon:J.secret?fd:hd})})]})]})}),s&&E.jsxs("div",{className:"session-step",children:[E.jsxs("div",{className:"session-workspace-toggle",children:[E.jsxs("button",{type:"button",className:`session-workspace-option is-compact ${P==="new"?"is-selected":""}`,onClick:()=>{O("new"),R(!1),M("")},disabled:h,"aria-pressed":P==="new",children:[E.jsx("span",{className:"session-workspace-icon is-create","aria-hidden":"true",children:E.jsx(Be,{icon:bc})}),E.jsx("span",{className:"session-workspace-option-title",children:e("New session")})]}),E.jsxs("button",{type:"button",className:`session-workspace-option is-compact ${P==="existing"?"is-selected":""}`,onClick:()=>{O("existing"),R(!1),M(""),z()},disabled:h,"aria-pressed":P==="existing",children:[E.jsx("span",{className:"session-workspace-icon is-join","aria-hidden":"true",children:E.jsx(Be,{icon:x_})}),E.jsx("span",{className:"session-workspace-option-title",children:e("Resume an existing session")})]}),U!=="mono_user"&&E.jsxs("button",{type:"button",className:"session-workspace-option is-compact",onClick:q,children:[E.jsx("span",{className:"session-workspace-icon is-leave","aria-hidden":"true",children:E.jsx(Be,{icon:Ob})}),E.jsx("span",{className:"session-workspace-option-title",children:e("Leave workspace")})]})]}),E.jsx("div",{className:`session-panel ${P==="existing"?"is-visible":"is-hidden"}`,"aria-hidden":P!=="existing",children:E.jsxs("div",{className:"session-auth",children:[E.jsx("div",{className:"session-auth-title",children:e("Existing sessions")}),Q?E.jsx("div",{className:"session-auth-hint",children:e("Loading sessions...")}):H.length===0?E.jsx("div",{className:"session-auth-hint",children:e("No sessions available.")}):E.jsx("ul",{className:"session-list",children:H.map(oe=>{const ge=$(oe.repoUrl),Ge=oe.name||ge||oe.sessionId,We=oe.repoUrl?Y(oe.repoUrl,72):oe.sessionId,Je=oe.lastActivityAt?new Date(oe.lastActivityAt).toLocaleString(T):oe.createdAt?new Date(oe.createdAt).toLocaleString(T):"",xt=L===oe.sessionId;return E.jsxs("li",{className:"session-item",children:[E.jsxs("div",{className:"session-item-meta",children:[E.jsx("div",{className:"session-item-title",children:Ge}),E.jsx("div",{className:"session-item-sub",children:We}),Je&&E.jsx("div",{className:"session-item-sub",children:e("Last activity: {{date}}",{date:Je})})]}),E.jsxs("div",{className:"session-item-actions",children:[E.jsx("button",{type:"button",className:"session-list-button",onClick:()=>B(oe.sessionId),disabled:h||xt,children:e("Resume")}),E.jsx("button",{type:"button",className:"session-list-button is-danger",onClick:()=>D(oe),disabled:h||xt,children:e(xt?"Deleting...":"Delete")})]})]},oe.sessionId)})}),I&&E.jsx("div",{className:"attachments-error",children:I})]})}),E.jsx("div",{className:`session-panel ${P==="new"?"is-visible":"is-hidden"}`,"aria-hidden":P!=="new",children:W?E.jsxs("div",{className:"session-hint",children:[e("Cloning repository..."),j&&E.jsx("div",{className:"session-meta",children:j})]}):E.jsxs("form",{id:"repo-form",className:"session-form session-form--compact",onSubmit:N,children:[E.jsxs("div",{className:"session-form-row is-compact-grid",children:[E.jsx("input",{type:"text",placeholder:e("Session name (optional)"),value:G,onChange:oe=>V(oe.target.value),disabled:h}),E.jsxs("div",{className:"session-repo-field",children:[E.jsx("input",{type:"text",placeholder:e("git@gitea.devops:my-org/my-repo.git"),value:X,onChange:oe=>{ne(oe.target.value)},disabled:h,required:!0,list:ue.length>0?"repo-history":void 0}),ue.length>0&&E.jsx("datalist",{id:"repo-history",children:ue.map(oe=>E.jsx("option",{value:oe,children:Y(oe,72)},oe))})]})]}),E.jsxs("div",{className:"session-auth",children:[E.jsx("div",{className:"session-auth-title",children:e("Repository authentication (optional)")}),E.jsx("div",{className:"session-auth-options",children:E.jsxs("select",{value:ve,onChange:oe=>le(oe.target.value),disabled:h,children:[E.jsx("option",{value:"none",children:e("None")}),E.jsx("option",{value:"ssh",children:e("Private SSH key (not recommended)")}),E.jsx("option",{value:"http",children:e("Username + password")})]})}),ve==="ssh"&&E.jsx(E.Fragment,{children:E.jsx("textarea",{className:"session-auth-textarea",placeholder:e("-----BEGIN OPENSSH PRIVATE KEY-----"),value:Se,onChange:oe=>ye(oe.target.value),disabled:h,rows:6,spellCheck:!1})}),ve==="http"&&E.jsx(E.Fragment,{children:E.jsxs("div",{className:"session-auth-grid",children:[E.jsx("input",{type:"text",placeholder:e("Username"),value:Me,onChange:oe=>Ne(oe.target.value),disabled:h,autoComplete:"username"}),E.jsx("input",{type:"password",placeholder:e("Password or PAT"),value:Ue,onChange:oe=>Ke(oe.target.value),disabled:h,autoComplete:"current-password"})]})})]}),E.jsxs("div",{className:"session-auth session-auth-compact",children:[E.jsx("div",{className:"session-auth-title",children:e("Permissions")}),E.jsxs("div",{className:"session-auth-options session-auth-options--compact",children:[E.jsxs("label",{className:"session-auth-option",children:[E.jsx("input",{type:"checkbox",checked:Ye,onChange:oe=>{const ge=oe.target.checked;Ee(ge),ge||Ce(!1)},disabled:h}),e("Internet access")]}),Ye&&U!=="mono_user"&&E.jsxs("label",{className:"session-auth-option",children:[E.jsx("input",{type:"checkbox",checked:je,onChange:oe=>Ce(oe.target.checked),disabled:h}),e("Deny git credentials access")]})]})]})]})}),Z&&E.jsx("div",{className:"attachments-error",children:Z})]}),a&&E.jsxs("div",{className:"session-step",children:[E.jsxs("div",{className:"session-auth",children:[E.jsx("div",{className:"session-auth-title",children:e("Login required")}),E.jsx("div",{className:"session-auth-hint",children:e("Please use the console generated URL to login")})]}),g&&E.jsx("div",{className:"attachments-error",children:g})]})]}),E.jsx("div",{className:"session-footer",children:a?null:r?E.jsx("button",{type:"submit",form:"workspace-form",className:"session-button primary",disabled:h,children:e(we?"Validating...":"Continue")}):n?E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button",className:"session-button secondary",onClick:()=>{if(_e===4){ee(!1),De(4);return}De(1)},disabled:h,children:e("Back")}),E.jsx("button",{type:"submit",form:"providers-form",className:"session-button primary",disabled:h,children:e(we?"Validating...":F?"Save":"Continue")})]}):i?E.jsx("button",{type:"button",className:"session-button primary",onClick:()=>De(4),disabled:h,children:e("Continue")}):s?P==="existing"?E.jsx("button",{type:"button",className:"session-button secondary session-footer-full",disabled:h,onClick:()=>{ee(!0),Ae(""),Ie(4),St(),z(),De(2)},children:e("AI providers")}):E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button",className:"session-button secondary",disabled:h,onClick:()=>{ee(!0),Ae(""),Ie(4),St(),z(),De(2)},children:e("AI providers")}),E.jsx("button",{type:"submit",form:"repo-form",className:"session-button primary",disabled:h,children:e(se?"Loading...":"Clone")})]}):null})]}),E.jsx("aside",{className:"session-info",children:E.jsxs("div",{className:"session-info-card",children:[E.jsxs("div",{className:"session-info-title",children:[E.jsx("span",{className:"session-info-icon","aria-hidden":"true",children:"ℹ️"}),te.title]}),(ae=te.paragraphs)==null?void 0:ae.map(oe=>E.jsx("p",{children:oe},oe)),te.setupLink?E.jsx("p",{children:E.jsx("a",{className:"session-info-link",href:"https://vibe80.io/docs/workspace-session-setup",target:"_blank",rel:"noreferrer",children:e("Click here to learn more.")})}):null,te.securityLink?E.jsxs("p",{children:[e("Vibe80 strictly controls access to resources (Git credentials and internet) using sandboxing. "),E.jsx("a",{className:"session-info-link",href:"https://vibe80.io/docs/sandboxing",target:"_blank",rel:"noreferrer",children:e("Click here to learn more.")})]}):null]})})]}),ie&&E.jsx("div",{className:"toast-container",children:E.jsx("div",{className:`toast is-${ie.type||"success"}`,children:ie.message})})]})}const GF="/assets/vibe80_dark-D7OVPKcU.svg",qF="/assets/vibe80_light-BJK37ybI.svg",YF=x.lazy(()=>wi(()=>import("./ExplorerPanel-CGVmxql1.js"),[])),JF=x.lazy(()=>wi(()=>import("./DiffPanel-Luk1GrAd.js"),[])),XF=x.lazy(()=>wi(()=>import("./TerminalPanel-kEz-cjes.js"),[])),QF=x.lazy(()=>wi(()=>import("./SettingsPanel-H2q2eoDf.js"),[])),ZF=x.lazy(()=>wi(()=>import("./LogsPanel-D8Z8Zam8.js"),[])),ez=()=>new URLSearchParams(window.location.search).get("session"),tz=()=>new URLSearchParams(window.location.search).get("repository"),Yf=()=>{if(ez())return"";const t=tz();return(t?t.trim():"")||""},rz=e=>{if(!e)return"";try{const t=new TextEncoder().encode(e);let r="";return t.forEach(n=>{r+=String.fromCharCode(n)}),btoa(r)}catch{return btoa(e)}},NC={codex:["api_key","auth_json_b64"],claude:["api_key","setup_token"]},K1=(e,t)=>{const r=NC[e]||[];return r.length?r.includes(t==null?void 0:t.authType)?t.authType:r[0]:(t==null?void 0:t.authType)||"api_key"},RC=e=>{const t=e==null?void 0:e.trim();return t?t.startsWith("{")&&t.endsWith("}")?t.slice(1,-1).trim():t:""},nz=e=>e?e.split(/\r?\n/).map(t=>t.trim()).filter(Boolean).map(t=>{const r=t.split("::"),[n,i,s,...a]=r,o=(n||"").trim().toLowerCase(),l=(i||"").trim(),c=(s||"").trim();if(!o||!l||!c)return null;if(o==="radio"||o==="select"){const h=a.map(u=>u.trim()).filter(Boolean);return{type:o,id:l,label:c,choices:h}}if(o==="checkbox"){const u=a.join("::").trim()==="1";return{type:o,id:l,label:c,defaultChecked:u}}if(o==="input"||o==="textarea"){const h=a.join("::").trim();return{type:o,id:l,label:c,defaultValue:h}}return null}).filter(Boolean):[],iz=(e,t=r=>r)=>{const r=/<!--\s*vibe80:(choices|form)\s*([^>]*)-->([\s\S]*?)<!--\s*\/vibe80:\1\s*-->|<!--\s*vibe80:yesno\s*([^>]*)-->/g,n=/<!--\s*vibe80:fileref\s+([^>]+?)\s*-->/g,i=/<!--\s*vibe80:task\s*[^>]*-->/g,s=[],a=[],o=String(e||"").replace(n,(u,m)=>{const v=String(m||"").trim();return v&&a.push(v),""}).replace(i,"");let l="",c=0,h;for(;(h=r.exec(o))!==null;){l+=o.slice(c,h.index),c=h.index+h[0].length;const u=h[1],m=RC(h[2]||h[4]),v=h[3]||"";if(!u){s.push({type:"yesno",question:m,choices:[t("Yes"),t("No")]});continue}if(u==="choices"){const _=v.split(/\r?\n/).map(g=>g.trim()).filter(Boolean);_.length&&s.push({type:"choices",question:m,choices:_});continue}const w=nz(v);w.length&&s.push({type:"form",question:m,fields:w})}return s.length?(l+=o.slice(c),{cleanedText:l.trim(),blocks:s,filerefs:a}):{cleanedText:o,blocks:[],filerefs:a}},sz=e=>{const t=/<!--\s*vibe80:task\s*([^>]*)-->/g,r=String(e||"");let n="",i;for(;(i=t.exec(r))!==null;){const s=RC(i[1]);s&&(n=s)}return n},oz=e=>{const t=String(e||"");return t?t.split(/\r?\n/)[0].trim():""},G1=async e=>{var r;if(!e)return;if((r=navigator==null?void 0:navigator.clipboard)!=null&&r.writeText)try{await navigator.clipboard.writeText(e);return}catch{}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)},az=1024,lz=5,cz=140,uz=60,OC="repoHistory",MC="authMode",jC="openAiAuthMode",BC="llmProvider",FC="llmProviders",zC="chatCommandsVisible",$C="toolResultsVisible",UC="notificationsEnabled",HC="themeMode",WC="debugMode",fz=10,hz=new Set(["png","jpg","jpeg","gif","webp","bmp","svg","avif"]),wl=(e,t)=>e?e.length<=t?e:`${e.slice(0,t)}…`:"",ta=e=>{if(!e)return"";if(typeof e=="string"){const t=e.split("/");return t[t.length-1]||e}if(e.name)return e.name;if(e.path){const t=e.path.split("/");return t[t.length-1]||e.path}return""},dz=(e,t=r=>r)=>{const r=ta(e);if(!r||!r.includes("."))return t("FILE");const n=r.split(".").pop();return n?n.toUpperCase():t("FILE")},pz=(e,t=r=>r)=>{if(!Number.isFinite(e))return"";if(e<1024)return t("{{count}} B",{count:e});const r=e/1024;if(r<1024)return t("{{count}} KB",{count:Math.round(r)});const n=r/1024;return t("{{count}} MB",{count:n.toFixed(1)})},_n=e=>Array.isArray(e)?e.map(t=>{if(!t)return null;if(typeof t=="string")return{name:ta(t),path:t};if(typeof t=="object"){const r=t.name||ta(t.path);return{...t,name:r}}return null}).filter(Boolean):[],mz=e=>{var n;const t=ta(e);if(!t||!t.includes("."))return!1;const r=(n=t.split(".").pop())==null?void 0:n.toLowerCase();return hz.has(r)},gz=()=>{try{const e=localStorage.getItem(OC);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(r=>typeof r=="string").map(r=>r.trim()).filter(Boolean):[]}catch{return[]}},vz=()=>{try{const e=localStorage.getItem(MC);if(e==="ssh"||e==="http"||e==="none")return e}catch{}return"none"},_z=()=>{try{const e=localStorage.getItem(jC);if(e==="apiKey"||e==="authFile")return e}catch{}return"apiKey"},yz=()=>{try{const e=localStorage.getItem(zC);if(e==="true"||e==="false")return e==="true"}catch{}return!0},wz=()=>{try{const e=localStorage.getItem($C);if(e==="true"||e==="false")return e==="true"}catch{}return!1},bz=()=>{try{const e=localStorage.getItem(UC);if(e==="true"||e==="false")return e==="true"}catch{}return!0},Sz=()=>{try{const e=localStorage.getItem(HC);if(e==="light"||e==="dark")return e}catch{}return"light"},Cz=()=>{try{const e=localStorage.getItem(WC);if(e==="true"||e==="false")return e==="true"}catch{}return!1},fo=()=>{try{const e=localStorage.getItem(BC);if(e==="codex"||e==="claude")return e}catch{}return"codex"},kz=()=>{try{const e=localStorage.getItem(FC);if(!e)return[fo()];const t=JSON.parse(e);if(!Array.isArray(t))return[fo()];const r=t.filter(n=>n==="codex"||n==="claude");return r.length?r:[fo()]}catch{}return[fo()]},xz=(e,t)=>{const r=t.trim();if(!r)return e;const n=[r,...e.filter(i=>i!==r)].slice(0,fz);return n.length===e.length&&n.every((i,s)=>i===e[s])?e:n},Ez=(e,t,r)=>{const n=new Blob([t],{type:r}),i=URL.createObjectURL(n),s=document.createElement("a");s.href=i,s.download=e,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(i)},Az=(e,t)=>{const r=e||"chat",n=new Date().toISOString().replace(/[:.]/g,"-");return`${r}-${n}.${t}`},bl=e=>{if(!e)return"";const n=e.trim().replace(/\/+$/,"").split(/[?#]/)[0].match(/([^/:]+)$/);return n?n[1]:""},Lz=e=>{if(!e)return"plaintext";if((e.split("/").pop()||"").toLowerCase()==="dockerfile")return"dockerfile";const r=e.toLowerCase().match(/\.([a-z0-9]+)$/);switch(r?r[1]:""){case"js":case"cjs":case"mjs":return"javascript";case"jsx":return"javascript";case"ts":return"typescript";case"tsx":return"typescript";case"json":return"json";case"md":case"markdown":return"markdown";case"css":return"css";case"scss":return"scss";case"less":return"less";case"html":case"htm":return"html";case"yml":case"yaml":return"yaml";case"sh":case"bash":case"zsh":return"shell";case"py":return"python";case"go":return"go";case"java":return"java";case"c":return"c";case"cc":case"cpp":case"cxx":case"hpp":case"h":return"cpp";case"rs":return"rust";case"rb":return"ruby";case"php":return"php";case"sql":return"sql";case"toml":return"toml";case"xml":return"xml";case"dockerfile":return"dockerfile";default:return"plaintext"}},Pz=(e,t=r=>r)=>e==="codex"?t("Codex"):e==="claude"?t("Claude"):e||"";function Tz(){const{t:e,language:t,setLanguage:r,locale:n}=IC(),[i,s]=x.useState([]),[a,o]=x.useState(""),[l,c]=x.useState(()=>e("Connecting...")),[h,u]=x.useState(!1),[m,v]=x.useState(!1),[w,_]=x.useState(""),[g,d]=x.useState(!1),[f,p]=x.useState(null),[y,S]=x.useState(Yf),[b,k]=x.useState(Yf),[C,A]=x.useState(""),[P,O]=x.useState(null),[R,M]=x.useState(vz),[z,U]=x.useState(""),[q,Q]=x.useState(""),[H,I]=x.useState(""),[L,B]=x.useState("new"),[D,T]=x.useState(!1),[$,Y]=x.useState({}),[W,j]=x.useState(!0),[N,G]=x.useState(!1),[V,X]=x.useState(null),[ne,ue]=x.useState(fo),[ve,le]=x.useState(kz),[Se,ye]=x.useState(!1),[Me,Ne]=x.useState(_z),[Ue,Ke]=x.useState(null),[Ye,Ee]=x.useState(""),[je,Ce]=x.useState(""),[Z,se]=x.useState(!1),[we,F]=x.useState(null),[_e,De]=x.useState(!1),[ee,Ae]=x.useState(null),[Ie,St]=x.useState(""),[ce,he]=x.useState(!1),[J,K]=x.useState(!1),[te,ie]=x.useState(!1),[ae,oe]=x.useState(()=>!!Yf()),[ge,Ge]=x.useState(yz),[We,Je]=x.useState(wz),[xt,xi]=x.useState(bz),[Xe,Et]=x.useState(Sz),Hr=x.useRef(null),Ls=x.useRef(null),_r=x.useCallback((re,fe="success")=>{X({message:re,type:fe}),Hr.current&&clearTimeout(Hr.current),Hr.current=setTimeout(()=>{X(null),Hr.current=null},3e3)},[]);x.useEffect(()=>()=>{Hr.current&&(clearTimeout(Hr.current),Hr.current=null)},[]);const[VC,Ps]=x.useState({main:"chat"}),_a=x.useRef(null),ya=x.useRef(null),KC=x.useRef(null),GC=x.useRef(null),vm=x.useMemo(()=>({tree:null,loading:!1,error:"",treeTruncated:!1,treeTotal:0,openTabPaths:[],activeFilePath:null,filesByPath:{},selectedPath:null,selectedType:null,renamingPath:null,renameDraft:"",deletingPath:null,fileContent:"",draftContent:"",fileLoading:!1,fileSaving:!1,fileError:"",fileSaveError:"",fileTruncated:!1,fileBinary:!1,editMode:!1,isDirty:!1,statusByPath:{},statusLoading:!1,statusError:"",statusLoaded:!1,expandedPaths:[]}),[]),[hu,du]=x.useState({}),[qC,wa]=x.useState(null),[YC,Ts]=x.useState([]),[pu,mu]=x.useState(!0),[JC,Ds]=x.useState({main:"all"}),[_m,ym]=x.useState(!1),[wm,gu]=x.useState(null),[ba,bm]=x.useState(!0),Sm=x.useRef({}),[XC,vu]=x.useState(""),QC=x.useRef(new Map),ZC=re=>{var fe;if(!(re!=null&&re.type))return"";if(re.type==="commandExecution"){const xe=((fe=re.commandActions)==null?void 0:fe.command)||re.command||e("Command");return e("Command: {{command}}",{command:xe})}return re.type==="fileChange"?e("Applying changes..."):re.type==="mcpToolCall"?e("Tool: {{tool}}",{tool:re.tool}):re.type==="reasoning"?e("Reasoning..."):re.type==="agentMessage"?e("Generating response..."):""},{commandPanelOpen:ek,setCommandPanelOpen:Is,toolResultPanelOpen:tk,setToolResultPanelOpen:Ns}=t9(),[Cm,rk]=x.useState(()=>gz()),[km,Dz]=x.useState(()=>Cz()),cr=x.useRef(null),xm=x.useRef(!0),Sa=x.useRef(null),Ca=x.useRef(null),Em=x.useRef(null),{setToolbarExportOpen:_u}=e9(),Am=x.useRef(null),Lm=x.useRef(null),Pm=x.useRef(null),nk=x.useRef(null),ik=x.useRef(null),sk=x.useRef(null),ok=x.useRef(null),ak=x.useRef(null),lk=x.useRef(null),ck=x.useRef(null),uk=x.useRef(0),fk=x.useRef(!1),hk=x.useRef(null),dk=x.useRef(0),ka=x.useRef([]),{apiFetch:Xt,deploymentMode:yu,handleDeleteSession:pk,handleLeaveWorkspace:Tm,handleWorkspaceCopy:mk,handleWorkspaceProvidersSubmit:gk,handleWorkspaceSubmit:vk,loadWorkspaceProviders:_k,loadWorkspaceSessions:yk,providersBackStep:wk,setProvidersBackStep:bk,setWorkspaceAuthExpanded:Sk,setWorkspaceAuthFiles:Ck,setWorkspaceError:Dm,setWorkspaceIdInput:kk,setWorkspaceMode:Im,setWorkspaceProviders:xk,setWorkspaceProvidersEditing:Ek,setWorkspaceSecretInput:Ak,setWorkspaceStep:Lk,setWorkspaceToken:Pk,workspaceAuthExpanded:Tk,workspaceAuthFiles:Dk,workspaceBusy:Nm,workspaceCopied:Ik,workspaceCreated:Nk,workspaceError:Rk,workspaceId:Ok,workspaceIdInput:Mk,workspaceMode:jk,workspaceProviders:Bk,workspaceProvidersEditing:Fk,workspaceSecretInput:zk,workspaceSessionDeletingId:$k,workspaceSessions:Uk,workspaceSessionsError:Hk,workspaceSessionsLoading:Wk,workspaceStep:xa,workspaceToken:Wr}=IB({t:e,encodeBase64:rz,copyTextToClipboard:G1,extractRepoName:bl,setSessionMode:B,showToast:_r,getProviderAuthType:K1}),{handoffOpen:Vk,handoffQrDataUrl:Rm,handoffLoading:wu,handoffError:Om,handoffRemaining:bu,requestHandoffQr:Mm,closeHandoffQr:jm}=qB({t:e,apiFetch:Xt,attachmentSessionId:f==null?void 0:f.sessionId}),{gitIdentityName:Kk,gitIdentityEmail:Gk,gitIdentityGlobal:qk,gitIdentityRepo:Yk,gitIdentityLoading:Jk,gitIdentitySaving:Xk,gitIdentityError:Qk,gitIdentityMessage:Zk,setGitIdentityName:e2,setGitIdentityEmail:t2,handleSaveGitIdentity:r2}=YB({t:e,apiFetch:Xt,attachmentSessionId:f==null?void 0:f.sessionId}),Ei=x.useMemo(()=>new Map,[]),Rs=x.useMemo(()=>new Map,[]),Os=x.useMemo(()=>bl(f==null?void 0:f.repoUrl),[f==null?void 0:f.repoUrl]),Bm=Xe==="dark"?GF:qF,Fm=x.useMemo(()=>{const re=[];return _e&&re.push("codex"),J&&re.push("claude"),re},[_e,J]),Ms=x.useMemo(()=>ve.filter(re=>Fm.includes(re)),[ve,Fm]);x.useEffect(()=>{ka.current=i},[i]),x.useEffect(()=>{Sm.current=hu},[hu]),x.useEffect(()=>{xm.current=pu},[pu]);const{attachmentPreview:js,attachmentsError:zm,attachmentsLoading:$m,draftAttachments:Bs,renderMessageAttachments:n2,setAttachmentPreview:Um,setAttachmentsError:Ea,setAttachmentsLoading:Su,setDraftAttachments:Fs}=UB({attachmentSessionId:f==null?void 0:f.sessionId,workspaceToken:Wr,normalizeAttachments:_n,isImageAttachment:mz,getAttachmentName:ta,attachmentIcon:E.jsx(Be,{icon:QD}),t:e}),Hm=x.useMemo(()=>f!=null&&f.sessionId?`choices:${f.sessionId}`:null,[f==null?void 0:f.sessionId,Xt]),{choiceSelections:i2,setChoiceSelections:s2,activeForm:Aa,activeFormValues:Wm,openVibe80Form:o2,closeVibe80Form:Cu,updateActiveFormValue:zs,submitActiveForm:a2,handleChoiceClick:l2}=JB({choicesKey:Hm,input:a,setInput:o,handleSendMessageRef:_a,draftAttachments:Bs,setDraftAttachments:Fs});XB({authMode:R,llmProvider:ne,selectedProviders:ve,openAiAuthMode:Me,showChatCommands:ge,showToolResults:We,notificationsEnabled:xt,themeMode:Xe,repoHistory:Cm,debugMode:km,setLlmProvider:ue,setOpenAiLoginError:Ce,setClaudeLoginError:St,AUTH_MODE_KEY:MC,LLM_PROVIDER_KEY:BC,LLM_PROVIDERS_KEY:FC,OPENAI_AUTH_MODE_KEY:jC,CHAT_COMMANDS_VISIBLE_KEY:zC,TOOL_RESULTS_VISIBLE_KEY:$C,NOTIFICATIONS_ENABLED_KEY:UC,THEME_MODE_KEY:HC,REPO_HISTORY_KEY:OC,DEBUG_MODE_KEY:WC}),x.useMemo(()=>{const re=[];return(i||[]).forEach(fe=>{if((fe==null?void 0:fe.role)==="commandExecution"){const xe=re[re.length-1];(xe==null?void 0:xe.groupType)==="commandExecution"?xe.items.push(fe):re.push({groupType:"commandExecution",id:`command-group-${fe.id}`,items:[fe]});return}re.push(fe)}),re},[i]);const{isMobileLayout:hn}=QB({themeMode:Xe,setSideOpen:ym}),{applyMessages:c2,mergeAndApplyMessages:u2}=c9({normalizeAttachments:_n,messageIndex:Ei,commandIndex:Rs,messagesRef:ka,setMessages:s,setCommandPanelOpen:Is,setToolResultPanelOpen:Ns}),{activeWorktreeId:qe,activeWorktreeIdRef:Vm,applyWorktreesList:f2,closeWorktree:h2,createWorktree:d2,handleSelectWorktree:p2,loadMainWorktreeSnapshot:ku,requestWorktreeMessages:m2,requestWorktreesList:g2,renameWorktreeHandler:v2,setActiveWorktreeId:La,setWorktrees:Qt,worktrees:Pa}=NB({apiFetch:Xt,attachmentSessionId:f==null?void 0:f.sessionId,availableProviders:Ms,llmProvider:ne,messagesRef:ka,normalizeAttachments:_n,applyMessages:c2,socketRef:cr,setPaneByTab:Ps,setLogFilterByTab:Ds,showToast:_r,t:e}),{logFilter:_2,setLogFilter:y2,scopedRpcLogs:w2,filteredRpcLogs:b2}=ZB({rpcLogs:YC,activeWorktreeId:qe,locale:n,logFilterByTab:JC,setLogFilterByTab:Ds}),{ensureNotificationPermission:S2,maybeNotify:C2,lastNotifiedIdRef:k2}=BB({notificationsEnabled:xt,t:e}),Ta=x.useRef(()=>{}),x2=x.useCallback((...re)=>{var fe;return(fe=Ta.current)==null?void 0:fe.call(Ta,...re)},[]),{branches:E2,branchError:A2,branchLoading:L2,currentBranch:Ai,defaultBranch:P2,loadBranches:Km,loadProviderModels:T2,modelError:D2,modelLoading:I2,models:Gm,providerModelState:N2,selectedModel:R2,selectedReasoningEffort:qm,setModelError:$s,setModelLoading:Us,setModels:O2,setProviderModelState:M2,setSelectedModel:xu,setSelectedReasoningEffort:j2}=VB({apiFetch:Xt,attachmentSessionId:f==null?void 0:f.sessionId,llmProvider:ne,loadRepoLastCommit:x2,processing:h,socketRef:cr,t:e}),{currentDiff:B2,diffFiles:F2,diffStatusLines:z2,hasCurrentChanges:$2,untrackedFilePanels:U2,untrackedLoading:H2,loadRepoLastCommit:Hs,loadWorktreeLastCommit:Eu,repoLastCommit:Da,requestRepoDiff:Ia,requestWorktreeDiff:Na,setRepoDiff:Ra,setRepoLastCommit:Au,setWorktreeLastCommitById:Lu,worktreeLastCommitById:Pu}=$B({apiFetch:Xt,attachmentSessionId:f==null?void 0:f.sessionId,currentBranch:Ai,activeWorktreeId:qe,parseDiff:q4,setWorktrees:Qt,worktrees:Pa,t:e});x.useEffect(()=>{Ta.current=Hs},[Hs]);const Ze=qe&&qe!=="main",ke=Ze?Pa.get(qe):null,Vr=Ze?ke==null?void 0:ke.provider:ne,Ym=Ze?ke==null?void 0:ke.model:R2,ur=qe||"main",mt=x.useMemo(()=>{const re=f==null?void 0:f.sessionId;return re?`${re}::${ur}`:null},[f==null?void 0:f.sessionId,ur]),Tu=x.useMemo(()=>{if(!mt)return[];const re=$[mt]||{};return Object.values(re).sort((fe,xe)=>fe.messageId!==xe.messageId?String(fe.messageId||"").localeCompare(String(xe.messageId||"")):(fe.lineIndex||0)-(xe.lineIndex||0))},[mt,$]),W2=x.useCallback((re,fe)=>{!mt||!re||Y(xe=>{const Te=xe[mt];return!Te||!Te[re]?xe:{...xe,[mt]:{...Te,[re]:{...Te[re],annotationText:fe}}}})},[mt]),V2=x.useCallback(re=>{!mt||!re||Y(fe=>{const xe=fe[mt];if(!xe||!xe[re])return fe;const Te={...xe};if(delete Te[re],Object.keys(Te).length===0){const $e={...fe};return delete $e[mt],$e}return{...fe,[mt]:Te}})},[mt]),K2=x.useCallback(({messageId:re,lineIndex:fe,lineText:xe})=>{if(!mt||!re)return;const Te=`${re}:${fe}`;Y($e=>{const ft=$e[mt]||{},yr=ft[Te];return{...$e,[mt]:{...ft,[Te]:{annotationKey:Te,messageId:re,lineIndex:fe,lineText:xe||"",annotationText:(yr==null?void 0:yr.annotationText)||""}}}})},[mt]),G2=x.useCallback(()=>{mt&&Y(re=>{if(!re[mt])return re;const fe={...re};return delete fe[mt],fe})},[mt]),q2=x.useCallback(re=>{const fe=String(re||"").trim();if(!fe)return"";const xe=Tu.filter($e=>{var ft;return(ft=$e==null?void 0:$e.annotationText)==null?void 0:ft.trim()}).map($e=>({lineText:$e.lineText||"",annotationText:$e.annotationText.trim()}));return xe.length===0?fe:`${xe.map($e=>`> ${$e.lineText}
707
707
  ${$e.annotationText}`).join(`
708
708
 
709
709
  `)}
710
710
 
711
- ${fe}`},[Tu]),Jm=Ze?Array.isArray(ke==null?void 0:ke.models)?ke.models:[]:Array.isArray(Gm)?Gm:[],Xm=Ze?!!(ke!=null&&ke.modelLoading):!!I2,Y2=Ze?(ke==null?void 0:ke.modelError)||"":D2,Yn=Ze&&!ke?[]:ke?ke.messages:i,J2=Array.isArray(Yn)&&Yn.length>0,yt=VC[qe]||"chat",Qm=hu[qe]||vm,{handleResumeSession:X2,onRepoSubmit:Q2}=GB({t:e,apiFetch:Xt,workspaceToken:Wr,handleLeaveWorkspace:Tm,repoUrl:y,setRepoUrl:S,repoInput:b,sessionNameInput:C,repoAuth:P,setRepoAuth:O,authMode:R,sshKeyInput:z,httpUsername:q,httpPassword:H,sessionMode:L,sessionRequested:ae,setSessionRequested:oe,defaultInternetAccess:W,defaultDenyGitCredentialsAccess:N,attachmentSession:f,setAttachmentSession:p,setAttachmentsLoading:Su,setAttachmentsError:Ea,setWorkspaceToken:Pk,setWorkspaceMode:Im,setWorkspaceError:Dm,setOpenAiLoginPending:se,setOpenAiLoginRequest:F}),Du=Qm.statusByPath||{},Z2=x.useMemo(()=>{const te={},fe=(xe,Te)=>{if(!xe)return;const $e=te[xe];if($e!=="untracked"){if(Te==="untracked"){te[xe]="untracked";return}$e||(te[xe]=Te)}};return Object.entries(Du).forEach(([xe,Te])=>{if(!xe)return;const $e=xe.split("/").filter(Boolean);if(!($e.length<=1))for(let ft=0;ft<$e.length-1;ft+=1){const yr=$e.slice(0,ft+1).join("/");fe(yr,Te)}}),te},[Du]),{resyncSession:ex}=a9({attachmentSessionId:f==null?void 0:f.sessionId,apiFetch:Xt,llmProvider:ne,setLlmProvider:ue,setSelectedProviders:le,setOpenAiReady:De,setClaudeReady:K,setRepoDiff:Ra,setRpcLogsEnabled:mu,setRpcLogs:Ts,setTerminalEnabled:bm,loadMainWorktreeSnapshot:ku}),{requestMessageSync:tx}=l9({socketRef:cr,messagesRef:ka});kB({attachmentSessionId:f==null?void 0:f.sessionId,workspaceToken:Wr,socketRef:cr,reconnectTimerRef:ck,reconnectAttemptRef:uk,closingRef:fk,pingIntervalRef:hk,lastPongRef:dk,messageIndex:Ei,commandIndex:Rs,rpcLogsEnabledRef:xm,mergeAndApplyMessages:u2,requestMessageSync:tx,requestWorktreesList:g2,requestWorktreeMessages:m2,applyWorktreesList:f2,resyncSession:ex,t:e,setStatus:c,setConnected:d,setAppServerReady:ie,setHasMainWorktreeStatus:v,setMessages:s,setProcessing:u,setActivity:_,setCurrentTurnId:wa,setMainTaskLabel:vu,setModelLoading:Us,setModelError:$s,setModels:O2,setProviderModelState:M2,setSelectedModel:xu,setSelectedReasoningEffort:j2,setRepoDiff:Ra,setRpcLogs:Ts,setWorktrees:Qt,setPaneByTab:Ps,setLogFilterByTab:Ds,setActiveWorktreeId:La,activeWorktreeIdRef:Vm,extractVibe80Task:sz,extractFirstLine:oz,getItemActivityLabel:ZC,maybeNotify:C2,normalizeAttachments:_n,loadRepoLastCommit:Hs,loadBranches:Km,loadWorktreeLastCommit:Eu,openAiLoginRequest:we,setOpenAiLoginRequest:F,connected:g});const Zm=x.useCallback((te="main")=>{const fe=cr.current;!fe||fe.readyState!==WebSocket.OPEN||(te==="main"?(Us(!0),$s("")):Qt(xe=>{const Te=new Map(xe),$e=Te.get(te);return $e?(Te.set(te,{...$e,modelLoading:!0,modelError:""}),Te):xe}),fe.send(JSON.stringify({type:"model_list",worktreeId:te})))},[$s,Us,Qt,cr]),rx=x.useCallback(te=>{const fe=cr.current;if(!fe||fe.readyState!==WebSocket.OPEN)return;const xe=te||null;ur==="main"?(xu(xe||""),Us(!0),$s("")):Qt(Te=>{const $e=new Map(Te),ft=$e.get(ur);return ft?($e.set(ur,{...ft,model:xe,modelLoading:!0,modelError:""}),$e):Te}),fe.send(JSON.stringify({type:"model_set",worktreeId:ur,model:xe,reasoningEffort:ur==="main"?qm||null:(ke==null?void 0:ke.reasoningEffort)??null}))},[ur,ke==null?void 0:ke.reasoningEffort,qm,$s,Us,xu,Qt,cr]);jB({activePane:yt,activeWorktreeId:qe,attachmentSessionId:f==null?void 0:f.sessionId,terminalEnabled:ba,terminalContainerRef:Pm,terminalDisposableRef:sk,terminalFitRef:ik,terminalRef:nk,terminalSessionRef:ak,terminalSocketRef:ok,terminalWorktreeRef:lk,themeMode:Xe,workspaceToken:Wr}),x.useEffect(()=>{typeof(f==null?void 0:f.terminalEnabled)=="boolean"&&bm(f.terminalEnabled)},[f==null?void 0:f.terminalEnabled]),x.useEffect(()=>{ie(!1)},[f==null?void 0:f.sessionId]),x.useEffect(()=>{!g||!(f!=null&&f.sessionId)||Vr!=="codex"&&Vr!=="claude"||Ze&&(ke==null?void 0:ke.status)!=="ready"||!Ze&&Vr==="codex"&&!re||Zm(ur)},[ur,ke==null?void 0:ke.status,Vr,re,f==null?void 0:f.sessionId,g,Ze,Zm]),x.useEffect(()=>{if(!(f!=null&&f.sessionId))return;ku(),Ra(f.repoDiff||{status:"",diff:""});const te=typeof f.rpcLogsEnabled=="boolean"?f.rpcLogsEnabled:!0;mu(te),Ts(te?f.rpcLogs||[]:[]),c(e("Connecting...")),d(!1),v(!1)},[f==null?void 0:f.sessionId,ku,Ei,e]),x.useEffect(()=>{if(f!=null&&f.sessionId){const te=(f==null?void 0:f.name)||Os||e("Session");document.title=`vibe80 - ${te}`}else document.title="vibe80"},[f==null?void 0:f.sessionId,f==null?void 0:f.name,Os,e]),x.useEffect(()=>{typeof(f==null?void 0:f.defaultInternetAccess)=="boolean"&&j(f.defaultInternetAccess)},[f==null?void 0:f.defaultInternetAccess]),x.useEffect(()=>{typeof(f==null?void 0:f.defaultDenyGitCredentialsAccess)=="boolean"&&G(f.defaultDenyGitCredentialsAccess)},[f==null?void 0:f.defaultDenyGitCredentialsAccess]),x.useEffect(()=>{if(!(f!=null&&f.defaultProvider)&&!(f!=null&&f.providers))return;const te=Array.isArray(f.providers)?f.providers.filter(fe=>fe==="codex"||fe==="claude"):[];te.length?(le(te),De(te.includes("codex")),K(te.includes("claude"))):f.defaultProvider&&(le([f.defaultProvider]),De(f.defaultProvider==="codex"),K(f.defaultProvider==="claude")),f.defaultProvider&&f.defaultProvider!==ne&&ue(f.defaultProvider)},[f==null?void 0:f.defaultProvider,f==null?void 0:f.providers]),x.useEffect(()=>{f!=null&&f.repoUrl&&rk(te=>xz(te,f.repoUrl))},[f==null?void 0:f.repoUrl]),p9({attachmentSessionId:f==null?void 0:f.sessionId,socketRef:cr,availableProviders:Ms,llmProvider:ne,providerSwitching:Se,processing:h,setProviderSwitching:ye,setStatus:c,setSelectedProviders:le,setLlmProvider:ue,t:e});const{commandMenuOpen:nx,setCommandMenuOpen:eg,setCommandQuery:ix,commandSelection:sx,filteredCommands:ox,isDraggingAttachments:ax,handleInputChange:lx,handleComposerKeyDown:cx,onSubmit:ux,onUploadAttachments:fx,onPasteAttachments:hx,onDragOverComposer:dx,onDragEnterComposer:px,onDragLeaveComposer:mx,onDropAttachments:gx,removeDraftAttachment:vx,triggerAttachmentPicker:_x,captureScreenshot:yx}=CB({t:e,input:a,setInput:o,inputRef:Ca,handleSendMessageRef:_a,attachmentSession:f,apiFetch:Xt,normalizeAttachments:_n,setDraftAttachments:Fs,draftAttachments:Bs,setAttachmentsLoading:Su,setAttachmentsError:Ea,showToast:_r,uploadInputRef:Em,attachmentsLoading:$m,conversationRef:Am,composerRef:Lm,isMobileLayout:hn}),{sendMessage:tg,sendCommitMessage:wx,sendWorktreeMessage:bx}=g9({input:a,setInput:o,setMessages:s,setDraftAttachments:Fs,socketRef:cr,connected:g,normalizeAttachments:_n,draftAttachments:Bs,setWorktrees:Qt,setProcessing:u,setActivity:_,processingLabel:e("Processing..."),handleSendMessageRef:_a,ensureNotificationPermission:S2}),{openCloseConfirm:Sx,closeCloseConfirm:Iu,handleConfirmDelete:Cx}=u9({closeConfirm:wm,setCloseConfirm:gu,setActiveWorktreeId:La,activeWorktreeIdRef:Vm,closeWorktree:h2});x.useEffect(()=>{Sa.current&&(Sa.current.scrollTop=Sa.current.scrollHeight)},[Yn,h,qe]);const kx=x.useMemo(()=>{const te={id:"main",name:Ai||"Main",branchName:Ai||"main",provider:ne,status:h?"processing":g?m?"ready":"processing":"creating",color:"#6b7280",messages:i},fe=Array.from(Pa.values());return[te,...fe]},[Ai,ne,h,g,m,i,Pa]),xx=x.useMemo(()=>{const te=[];return(Yn||[]).forEach(fe=>{if((fe==null?void 0:fe.role)==="commandExecution"){if(!ge)return;const xe=te[te.length-1];(xe==null?void 0:xe.groupType)==="commandExecution"?xe.items.push(fe):te.push({groupType:"commandExecution",id:`command-group-${fe.id}`,items:[fe]});return}if((fe==null?void 0:fe.role)==="tool_result"){if(!We)return;const xe=te[te.length-1];(xe==null?void 0:xe.groupType)==="toolResult"?xe.items.push(fe):te.push({groupType:"toolResult",id:`tool-result-group-${fe.id}`,items:[fe]});return}if((fe==null?void 0:fe.type)==="action_result"){const xe=te[te.length-1];(xe==null?void 0:xe.groupType)==="toolResult"?xe.items.push(fe):te.push({groupType:"toolResult",id:`tool-result-group-${fe.id}`,items:[fe]});return}te.push(fe)}),te},[Yn,ge,We]),{setShowOlderMessagesByTab:Nu,collapsedMessages:Ex}=o9({activeChatKey:ur,displayedGroupedMessages:xx,CHAT_COLLAPSE_THRESHOLD:cz,CHAT_COLLAPSE_VISIBLE:uz});x.useEffect(()=>{const te=(f==null?void 0:f.sessionId)||null;Ls.current!==te&&(Ls.current=te,s([]),Ei.clear(),Rs.clear(),Qt(new Map),La("main"),Ps({main:"chat"}),Ds({main:"all"}),du({}),Nu({}),Is({}),Ns({}),Au(null),Lu(new Map),wa(null),vu(""),_(""),gu(null),Y({}))},[f==null?void 0:f.sessionId,Rs,Ei,La,_,gu,Is,wa,du,Ds,vu,s,Y,Ps,Au,Nu,Ns,Lu,Qt]);const dn=Ze?Pu.get(qe):Da,rg=Ze?(ke==null?void 0:ke.branchName)||(ke==null?void 0:ke.name)||"":Ai||(Da==null?void 0:Da.branch)||"",ng=typeof(dn==null?void 0:dn.sha)=="string"?dn.sha.slice(0,7):"",Ax=Ze?!!(ke!=null&&ke.internetAccess):!!W,Lx=Ze?(ke==null?void 0:ke.denyGitCredentialsAccess)===!1:N===!1,ig=Pz(Vr,e),sg=Ym||e("Default model"),Px=!!(ig&&sg),Tx=Os||e("Repository"),Dx=!hn&&yt==="chat"&&!!(rg&&ng&&(dn!=null&&dn.message)),Ix=(ke==null?void 0:ke.status)==="processing",og=(ke==null?void 0:ke.status)==="stopped",Ws=Ze?Ix:h,Vs=Ws||Ze&&og,Nx=Ze?(ke==null?void 0:ke.activity)||"":w,Rx=Ws?Ze?ke==null?void 0:ke.taskLabel:XC:"",ag=Ze?ke==null?void 0:ke.currentTurnId:qC,Ox=Ws&&!!ag,lg=Vr!=="codex"?!0:Ze?(ke==null?void 0:ke.status)==="ready":re,Mx=Vr==="codex"||Vr==="claude",jx=!g||Vs||Xm||!Jm.length,Bx=Ym||"",{handleViewSelect:Oa,handleOpenSettings:cg,handleSettingsBack:Fx}=r9({activePane:yt,activeWorktreeId:qe,debugMode:km,rpcLogsEnabled:pu,terminalEnabled:ba,setPaneByTab:Ps,setToolbarExportOpen:_u,lastPaneByTabRef:QC}),{addToBacklog:zx,backlog:Ma,editBacklogItem:$x,launchBacklogItem:Ux,markBacklogItemDone:Hx,removeFromBacklog:Wx,setBacklogMessagePage:Vx}=HB({attachmentSessionId:f==null?void 0:f.sessionId,apiFetch:Xt,normalizeAttachments:_n,sendMessage:tg,setInput:o,setMessages:s,setWorktrees:Qt,setDraftAttachments:Fs,input:a,draftAttachments:Bs,inputRef:Ca,showToast:_r,t:e}),{interruptTurn:Kx}=i9({activeWorktreeId:qe,isInWorktree:Ze,currentTurnIdForActive:ag,socketRef:cr,setWorktrees:Qt,setActivity:_}),{handleLeaveSession:Ru}=n9({setAttachmentSession:p,setRepoUrl:S,setRepoInput:k,setRepoAuth:O,setSessionRequested:oe,setAttachmentsError:Ea,setAttachmentsLoading:Su,setMessages:s,setRepoDiff:Ra,setRpcLogs:Ts,setRpcLogsEnabled:mu,setRepoLastCommit:Au,setWorktreeLastCommitById:Lu,setCurrentTurnId:wa,setActivity:_,setDefaultDenyGitCredentialsAccess:G});x.useEffect(()=>{!Wr&&(f!=null&&f.sessionId)&&Ru()},[Wr,f==null?void 0:f.sessionId,Ru]);const{handleDiffSelect:Gx}=s9({activeWorktreeId:qe,handleViewSelect:Oa,requestWorktreeDiff:Na,requestRepoDiff:Ia}),{openPathInExplorer:qx,requestExplorerTree:Ou,requestExplorerStatus:Mu,openFileInExplorer:Yx,setActiveExplorerFile:Jx,closeExplorerFile:Xx,selectExplorerNode:ug,toggleExplorerDir:Qx,updateExplorerDraft:Zx,saveExplorerFile:eE,startExplorerRename:tE,cancelExplorerRename:fg,updateExplorerRenameDraft:hg,submitExplorerRename:ja,createExplorerFile:rE,createExplorerFolder:nE,deleteExplorerSelection:iE}=d9({attachmentSessionId:f==null?void 0:f.sessionId,apiFetch:Xt,t:e,setExplorerByTab:du,explorerDefaultState:vm,explorerRef:Sm,activeWorktreeId:qe,handleViewSelect:Oa,showToast:_r,requestExplorerTreeRef:KC,requestExplorerStatusRef:GC,loadExplorerFileRef:ya});WB({activeProvider:Vr,activeWorktreeId:qe,addToBacklog:zx,apiFetch:Xt,attachmentSessionId:f==null?void 0:f.sessionId,captureScreenshot:yx,connected:g,handleSendMessageRef:_a,handleViewSelect:Oa,input:a,isWorktreeStopped:og,isCodexReady:lg,isInWorktree:Ze,openPathInExplorer:qx,requestRepoDiff:Ia,requestWorktreeDiff:Na,sendMessage:tg,sendWorktreeMessage:bx,buildAnnotatedMessage:q2,clearScopedAnnotations:G2,setAnnotationMode:T,setCommandMenuOpen:eg,setDraftAttachments:Fs,setInput:o,setMessages:s,setWorktrees:Qt,socketRef:cr,showToast:_r,t:e});const{handleClearRpcLogs:sE}=f9({activeWorktreeId:qe,setRpcLogs:Ts});x.useEffect(()=>{yt==="diff"&&(qe&&qe!=="main"?Na(qe):Ia())},[yt,qe,Ia,Na]),x.useEffect(()=>{if(yt!=="explorer")return;const te=qe||"main";Ou(te,!0),Mu(te,!0)},[yt,qe,Ou,Mu]),x.useEffect(()=>{if(!(!(f!=null&&f.sessionId)||hn||yt!=="chat")){if(Ze&&qe){Pu.has(qe)||Eu(qe);return}Hs()}},[f==null?void 0:f.sessionId,hn,yt,Ze,qe,Pu,Eu,Hs]),m9({currentMessages:Yn,attachmentRepoUrl:f==null?void 0:f.repoUrl,repoUrl:y,isInWorktree:Ze,activeWorktree:ke,t:e,normalizeAttachments:_n,downloadTextFile:Ez,formatExportName:Az,extractRepoName:bl,setToolbarExportOpen:_u});const{handleClearChat:oE}=v9({activeWorktreeId:qe,setToolbarExportOpen:_u,setWorktrees:Qt,lastNotifiedIdRef:k2,attachmentSessionId:f==null?void 0:f.sessionId,apiFetch:Xt,setMessages:s,messageIndex:Ei,commandIndex:Rs,setChoiceSelections:s2,choicesKey:Hm,setCommandPanelOpen:Is,setToolResultPanelOpen:Ns,llmProvider:ne});if(f!=null&&f.sessionId,Ms.length>1&&Ms.find(te=>te!==ne),!(f!=null&&f.sessionId)){const fe=L==="new"&&ae&&!!y,xe=wl(y,72),Te=Nm||ae,$e=Ba=>Bk[Ba]||{},ft=yu==="mono_user"&&!Wr,yr=!ft&&xa===1,pn=!ft&&xa===2,mn=xa===3&&Wr,gt=xa===4&&Wr,ju=ft?e("Please use the console generated URL to login"):pn?e("Configure AI providers for this workspace."):mn?e("Workspace created hint"):null,Bu=ft?{title:e("Login required"),paragraphs:[e("Please use the console generated URL to login")]}:pn?{title:e("Configure AI providers"),paragraphs:[e("Vibe80 can run Codex or Claude Code. To continue, provide your Anthropic and/or OpenAI credentials. If you use pay-as-you-go billing, supply an API key."),e("For subscription plans, use auth.json from the Codex CLI login (ChatGPT) or a long-lived token from `claude setup-token` (Claude).")]}:mn?{title:e("Workspace credentials"),paragraphs:[e("Please keep your workspace credentials (Workspace ID and Workspace Secret) for future access. We do not have a user identification mechanism; your Workspace ID is your only identifier.")]}:gt?{title:e("Start a session"),paragraphs:[e("Vibe80 opens Git-based work sessions. Even in a secure environment, we recommend short-lived and revocable PATs or keys.")],securityLink:!0}:{title:e("Configure the workspace"),paragraphs:[e("A workspace is an isolated, secured environment accessible only with credentials. It lets you reuse AI credentials for all future sessions."),e("You can create multiple workspaces to separate teams, projects, or security boundaries.")]};return E.jsx(KF,{t:e,brandLogo:Bm,showStep1:yr,showStep2:pn,showStep3:mn,showStep4:gt,showMonoLoginRequired:ft,headerHint:ju,workspaceMode:jk,setWorkspaceMode:Im,formDisabled:Te,handleWorkspaceSubmit:vk,workspaceIdInput:Mk,setWorkspaceIdInput:kk,workspaceSecretInput:zk,setWorkspaceSecretInput:Ak,workspaceError:Rk,handleWorkspaceProvidersSubmit:gk,workspaceProvider:$e,workspaceAuthExpanded:Tk,setWorkspaceAuthExpanded:Sk,setWorkspaceProviders:xk,providerAuthOptions:NC,getProviderAuthType:K1,workspaceAuthFiles:Dk,setWorkspaceAuthFiles:Ck,sessionMode:L,setSessionMode:B,setSessionRequested:oe,setAttachmentsError:Ea,loadWorkspaceSessions:yk,deploymentMode:yu,handleLeaveWorkspace:Tm,workspaceSessionsLoading:Wk,workspaceSessions:Uk,workspaceSessionsError:Hk,workspaceSessionDeletingId:$k,handleResumeSession:X2,handleDeleteSession:pk,locale:n,extractRepoName:bl,getTruncatedText:wl,isCloning:fe,repoDisplay:xe,onRepoSubmit:Q2,sessionNameInput:C,setSessionNameInput:A,repoInput:b,setRepoInput:k,repoHistory:Cm,authMode:R,setAuthMode:M,sshKeyInput:z,setSshKeyInput:U,httpUsername:q,setHttpUsername:Q,httpPassword:H,setHttpPassword:I,defaultInternetAccess:W,setDefaultInternetAccess:j,defaultDenyGitCredentialsAccess:N,setDefaultDenyGitCredentialsAccess:G,attachmentsError:zm,sessionRequested:ae,workspaceBusy:Nm,workspaceProvidersEditing:Fk,providersBackStep:wk,setWorkspaceStep:Lk,setWorkspaceProvidersEditing:Ek,setWorkspaceError:Dm,setProvidersBackStep:bk,loadWorkspaceProviders:_k,workspaceCreated:Nk,workspaceId:Ok,workspaceCopied:Ik,handleWorkspaceCopy:mk,infoContent:Bu,toast:V})}const dg=(te,fe,xe,Te,$e,ft,yr,pn,mn)=>!Array.isArray(te)||te.length===0?null:E.jsx("ul",{className:"explorer-tree-list",children:te.map(gt=>{if(gt.type==="dir"){const Ut=xe.has(gt.path),aE=Te===gt.path&&$e==="dir",lE=ft===gt.path,pg=(mn==null?void 0:mn[gt.path])||"";return E.jsxs("li",{className:`explorer-tree-item is-dir ${aE?"is-selected":""} ${pg?`is-${pg}`:""}`,children:[E.jsxs("div",{className:"explorer-tree-entry",children:[E.jsx("button",{type:"button",className:"explorer-tree-caret-button",onClick:Ir=>{Ir.stopPropagation(),Qx(fe,gt.path)},children:E.jsx("span",{className:"explorer-tree-caret","aria-hidden":"true",children:E.jsx(Be,{icon:Ut?e6:qD})})}),lE?E.jsx("div",{className:"explorer-tree-toggle is-renaming",children:E.jsx("input",{className:"explorer-tree-rename-input",value:yr||"",autoFocus:!0,onClick:Ir=>Ir.stopPropagation(),onChange:Ir=>hg(fe,Ir.target.value),onBlur:()=>{ja(fe)},onKeyDown:Ir=>{Ir.key==="Enter"?(Ir.preventDefault(),ja(fe)):Ir.key==="Escape"&&(Ir.preventDefault(),fg(fe))}})}):E.jsx("button",{type:"button",className:"explorer-tree-toggle",onClick:()=>ug(fe,gt.path,"dir"),children:E.jsx("span",{className:"explorer-tree-name",children:gt.name})})]}),Ut?dg(gt.children||[],fe,xe,Te,$e,ft,yr,pn,mn):null]},gt.path)}const ju=Te===gt.path&&$e==="file",Bu=ft===gt.path,Ba=(pn==null?void 0:pn[gt.path])||"";return E.jsx("li",{className:`explorer-tree-item is-file ${ju?"is-selected":""} ${Ba?`is-${Ba}`:""}`,children:Bu?E.jsxs("div",{className:"explorer-tree-file is-renaming",children:[E.jsx("span",{className:"explorer-tree-icon","aria-hidden":"true",children:E.jsx(Be,{icon:E_})}),E.jsx("input",{className:"explorer-tree-rename-input",value:yr||"",autoFocus:!0,onClick:Ut=>Ut.stopPropagation(),onChange:Ut=>hg(fe,Ut.target.value),onBlur:()=>{ja(fe)},onKeyDown:Ut=>{Ut.key==="Enter"?(Ut.preventDefault(),ja(fe)):Ut.key==="Escape"&&(Ut.preventDefault(),fg(fe))}})]}):E.jsxs("button",{type:"button",className:"explorer-tree-file",onClick:()=>{var Ut;ug(fe,gt.path,"file"),(Ut=ya.current)==null||Ut.call(ya,fe,gt.path)},children:[E.jsx("span",{className:"explorer-tree-icon","aria-hidden":"true",children:E.jsx(Be,{icon:E_})}),E.jsx("span",{className:"explorer-tree-name",children:gt.name})]})},gt.path)})});return E.jsxs("div",{className:"app",children:[E.jsx(VF,{t:e,brandLogo:Bm,allTabs:kx,activeWorktreeId:qe,handleSelectWorktree:p2,createWorktree:d2,openCloseConfirm:Sx,renameWorktreeHandler:v2,llmProvider:ne,availableProviders:Ms,branches:E2,defaultBranch:P2,currentBranch:Ai,branchLoading:L2,branchError:A2,defaultInternetAccess:W,defaultDenyGitCredentialsAccess:N,deploymentMode:yu,loadBranches:Km,providerModelState:N2,loadProviderModels:T2,connected:g,isMobileLayout:hn,requestHandoffQr:Mm,attachmentSession:f,handoffLoading:wu,handleOpenSettings:cg,handleLeaveSession:Ru}),E.jsxs("div",{className:`layout ${_m?"is-side-open":"is-side-collapsed"} ${hn?"is-mobile":""}`,children:[hn&&_m?E.jsx("button",{type:"button",className:"side-backdrop","aria-label":e("Close panel"),onClick:()=>ym(!1)}):null,E.jsxs("aside",{className:"side",children:[E.jsx("div",{className:"side-body",children:E.jsxs("section",{className:"backlog",children:[E.jsxs("div",{className:"panel-header",children:[E.jsx("div",{className:"panel-title",children:e("Backlog")}),E.jsx("div",{className:"panel-subtitle",children:Ma.length===0?e("No tasks"):e("{{count}} item(s)",{count:Ma.length})})]}),Ma.length===0?E.jsx("div",{className:"backlog-empty",children:e("No pending tasks at the moment.")}):E.jsx("ul",{className:"backlog-list",children:Ma.map(te=>{var fe;return E.jsxs("li",{className:"backlog-item",children:[E.jsx("div",{className:"backlog-text",children:wl(te.text,180)}),E.jsxs("div",{className:"backlog-actions",children:[E.jsx("button",{type:"button",className:"ghost",onClick:()=>$x(te),children:e("Edit")}),E.jsx("button",{type:"button",onClick:()=>Ux(te),disabled:!g,children:e("Launch")}),E.jsx("button",{type:"button",className:"ghost",onClick:()=>Wx(te.id),children:e("Delete")})]}),(fe=te.attachments)!=null&&fe.length?E.jsx("div",{className:"backlog-meta",children:e("{{count}} attachment(s)",{count:te.attachments.length})}):null]},te.id)})})]})}),E.jsx("div",{className:"side-footer",children:E.jsxs("button",{type:"button",className:`side-footer-button ${yt==="settings"?"is-active":""}`,onClick:cg,"aria-pressed":yt==="settings",children:[E.jsx("span",{className:"side-footer-icon","aria-hidden":"true",children:E.jsx(Be,{icon:Rb})}),e("Settings")]})})]}),E.jsxs("section",{className:"conversation is-chat-narrow",ref:Am,children:[E.jsxs("div",{className:"pane-stack",children:[E.jsx(SB,{t:e,activePane:yt,handleViewSelect:Oa,handleDiffSelect:Gx,terminalEnabled:ba,hasMessages:J2,handleClearChat:oE}),E.jsx(Q8,{t:e,activePane:yt,listRef:Sa,showChatInfoPanel:Dx,repoTitle:Tx,activeBranchLabel:rg,shortSha:ng,activeCommit:dn,showProviderMeta:Px,activeProviderLabel:ig,activeModelLabel:sg,showInternetAccess:Ax,showGitCredentialsShared:Lx,activeTaskLabel:Rx,currentMessages:Yn,chatHistoryWindow:Ex,activeChatKey:ur,setShowOlderMessagesByTab:Nu,showChatCommands:ge,showToolResults:We,commandPanelOpen:ek,setCommandPanelOpen:Is,toolResultPanelOpen:tk,setToolResultPanelOpen:Ns,renderMessageAttachments:n2,currentProcessing:Ws,currentInteractionBlocked:Vs,currentActivity:Nx,extractVibe80Blocks:iz,handleChoiceClick:l2,choiceSelections:i2,openVibe80Form:o2,copyTextToClipboard:G1,openFileInExplorer:Yx,setInput:o,inputRef:Ca,markBacklogItemDone:Hx,setBacklogMessagePage:Vx,activeWorktreeId:qe,BACKLOG_PAGE_SIZE:lz,MAX_USER_DISPLAY_LENGTH:az,getTruncatedText:wl,annotationMode:D,scopedAnnotations:Tu,setAnnotationDraft:W2,removeAnnotation:V2,addOrFocusAnnotation:K2}),E.jsx(x.Suspense,{fallback:null,children:E.jsx(JF,{t:e,activePane:yt,isInWorktree:Ze,diffStatusLines:z2,connected:g,currentProcessing:Ws,hasCurrentChanges:$2,sendCommitMessage:wx,diffFiles:F2,currentDiff:B2,untrackedFilePanels:U2,untrackedLoading:H2})}),E.jsx(x.Suspense,{fallback:null,children:E.jsx(YF,{t:e,activePane:yt,repoName:Os,activeWorktree:ke,isInWorktree:Ze,activeWorktreeId:qe,attachmentSession:f,requestExplorerTree:Ou,requestExplorerStatus:Mu,activeExplorer:Qm,renderExplorerNodes:dg,explorerStatusByPath:Du,explorerDirStatus:Z2,saveExplorerFile:eE,updateExplorerDraft:Zx,setActiveExplorerFile:Jx,closeExplorerFile:Xx,startExplorerRename:tE,createExplorerFile:rE,createExplorerFolder:nE,deleteExplorerSelection:iE,getLanguageForPath:Lz,themeMode:Xe})}),E.jsx(x.Suspense,{fallback:null,children:E.jsx(XF,{t:e,terminalEnabled:ba,activePane:yt,repoName:Os,activeWorktree:ke,isInWorktree:Ze,terminalContainerRef:Pm,attachmentSession:f})}),E.jsx(x.Suspense,{fallback:null,children:E.jsx(ZF,{t:e,activePane:yt,filteredRpcLogs:b2,logFilter:_2,setLogFilter:y2,scopedRpcLogs:w2,handleClearRpcLogs:sE})}),E.jsx(x.Suspense,{fallback:null,children:E.jsx(QF,{t:e,activePane:yt,handleSettingsBack:Fx,language:t,setLanguage:r,showChatCommands:ge,setShowChatCommands:Ge,showToolResults:We,setShowToolResults:Je,notificationsEnabled:xt,setNotificationsEnabled:xi,themeMode:Xe,setThemeMode:Et,gitIdentityName:Kk,setGitIdentityName:e2,gitIdentityEmail:Gk,setGitIdentityEmail:t2,gitIdentityGlobal:qk,gitIdentityRepo:Yk,gitIdentityLoading:Jk,gitIdentitySaving:Xk,gitIdentityError:Qk,gitIdentityMessage:Zk,handleSaveGitIdentity:r2,attachmentSession:f})})]}),E.jsx(bB,{t:e,activePane:yt,isDraggingAttachments:ax,onSubmit:ux,onDragEnterComposer:px,onDragOverComposer:dx,onDragLeaveComposer:mx,onDropAttachments:gx,composerRef:Lm,draftAttachments:Bs,getAttachmentExtension:dz,formatAttachmentSize:pz,removeDraftAttachment:vx,commandMenuOpen:nx,filteredCommands:ox,setInput:o,setCommandMenuOpen:eg,setCommandQuery:ix,inputRef:Ca,commandSelection:sx,triggerAttachmentPicker:_x,attachmentSession:f,attachmentsLoading:$m,isMobileLayout:hn,uploadInputRef:Em,onUploadAttachments:fx,input:a,handleInputChange:lx,handleComposerKeyDown:cx,onPasteAttachments:hx,canInterrupt:Ox,interruptTurn:Kx,connected:g,modelSelectorVisible:Mx,modelOptions:Jm,selectedModel:Bx,modelLoading:Xm,modelDisabled:jx,modelError:Y2,onModelChange:rx,isCodexReady:lg,interactionBlocked:Vs,attachmentsError:zm})]})]}),Aa?E.jsx("div",{className:"vibe80-form-overlay",role:"dialog","aria-modal":"true",onClick:Cu,children:E.jsxs("div",{className:"vibe80-form-dialog",onClick:te=>te.stopPropagation(),children:[E.jsxs("div",{className:"vibe80-form-header",children:[E.jsx("div",{className:"vibe80-form-title",children:Aa.question||e("Form")}),E.jsx("button",{type:"button",className:"vibe80-form-close","aria-label":e("Close"),onClick:Cu,children:E.jsx(Be,{icon:si})})]}),E.jsxs("form",{className:"vibe80-form-body",onSubmit:te=>{if(Vs){te.preventDefault();return}a2(te)},children:[Aa.fields.map(te=>{const fe=`vibe80-${Aa.key}-${te.id}`,xe=Wm[te.id]??"";return te.type==="checkbox"?E.jsx("div",{className:"vibe80-form-field",children:E.jsxs("label",{className:"vibe80-form-checkbox",children:[E.jsx("input",{type:"checkbox",checked:!!Wm[te.id],onChange:Te=>zs(te.id,Te.target.checked)}),E.jsx("span",{children:te.label})]})},te.id):te.type==="textarea"?E.jsxs("div",{className:"vibe80-form-field",children:[E.jsx("label",{className:"vibe80-form-label",htmlFor:fe,children:te.label}),E.jsx("textarea",{id:fe,className:"vibe80-form-input",rows:4,value:xe,onChange:Te=>zs(te.id,Te.target.value)})]},te.id):te.type==="radio"?E.jsxs("div",{className:"vibe80-form-field",children:[E.jsx("div",{className:"vibe80-form-label",children:te.label}),E.jsx("div",{className:"vibe80-form-options",children:(te.choices||[]).length?te.choices.map(Te=>E.jsxs("label",{className:"vibe80-form-option",children:[E.jsx("input",{type:"radio",name:fe,value:Te,checked:xe===Te,onChange:()=>zs(te.id,Te)}),E.jsx("span",{children:Te})]},`${te.id}-${Te}`)):E.jsx("div",{className:"vibe80-form-empty",children:e("No options.")})})]},te.id):te.type==="select"?E.jsxs("div",{className:"vibe80-form-field",children:[E.jsx("label",{className:"vibe80-form-label",htmlFor:fe,children:te.label}),E.jsx("select",{id:fe,className:"vibe80-form-input vibe80-form-select",value:xe,onChange:Te=>zs(te.id,Te.target.value),children:(te.choices||[]).length?te.choices.map(Te=>E.jsx("option",{value:Te,children:Te},`${te.id}-${Te}`)):E.jsx("option",{value:"",children:e("No options")})})]},te.id):E.jsxs("div",{className:"vibe80-form-field",children:[E.jsx("label",{className:"vibe80-form-label",htmlFor:fe,children:te.label}),E.jsx("input",{id:fe,className:"vibe80-form-input",type:"text",value:xe,onChange:Te=>zs(te.id,Te.target.value)})]},te.id)}),E.jsxs("div",{className:"vibe80-form-actions",children:[E.jsx("button",{type:"button",className:"vibe80-form-cancel",onClick:Cu,children:e("Cancel")}),E.jsx("button",{type:"submit",className:"vibe80-form-submit",disabled:Vs,children:e("Send")})]})]})]})}):null,Vk?E.jsx("div",{className:"handoff-modal-overlay",role:"dialog","aria-modal":"true",onClick:jm,children:E.jsxs("div",{className:"handoff-modal",onClick:te=>te.stopPropagation(),children:[E.jsxs("div",{className:"handoff-modal-header",children:[E.jsx("div",{className:"handoff-modal-title",children:e("Continue on mobile")}),E.jsx("button",{type:"button",className:"handoff-modal-close","aria-label":e("Close"),onClick:jm,children:E.jsx(Be,{icon:si})})]}),E.jsxs("div",{className:"handoff-modal-body",children:[E.jsx("p",{className:"handoff-modal-text",children:e("Scan this QR code in the Android app to resume the current session.")}),Om?E.jsx("div",{className:"handoff-modal-error",children:Om}):null,Rm?E.jsx("div",{className:"handoff-modal-qr",children:E.jsx("img",{src:Rm,alt:e("QR code")})}):E.jsx("div",{className:"handoff-modal-placeholder",children:e(wu?"Generating QR code...":"QR code unavailable.")}),typeof bu=="number"?E.jsx("div",{className:"handoff-modal-meta",children:bu>0?e("Expires in {{seconds}}s",{seconds:bu}):e("QR code expired")}):null,E.jsx("div",{className:"handoff-modal-actions",children:E.jsx("button",{type:"button",className:"session-button",onClick:Mm,disabled:wu,children:e("Regenerate")})})]})]})}):null,wm?E.jsx("div",{className:"worktree-close-confirm-overlay",role:"dialog","aria-modal":"true",onClick:Iu,children:E.jsxs("div",{className:"worktree-close-confirm-dialog",onClick:te=>te.stopPropagation(),children:[E.jsxs("div",{className:"worktree-close-confirm-header",children:[E.jsx("div",{className:"worktree-close-confirm-title",children:e("Close the worktree?")}),E.jsx("button",{type:"button",className:"worktree-close-confirm-close","aria-label":e("Close"),onClick:Iu,children:E.jsx(Be,{icon:si})})]}),E.jsx("div",{className:"worktree-close-confirm-body",children:e("All changes will be lost. What would you like to do?")}),E.jsxs("div",{className:"worktree-close-confirm-actions",children:[E.jsx("button",{type:"button",className:"worktree-close-confirm-cancel",onClick:Iu,children:e("Cancel")}),E.jsx("button",{type:"button",className:"worktree-close-confirm-delete",onClick:Cx,children:e("Delete worktree")})]})]})}):null,js?E.jsxs("div",{className:"attachment-modal",role:"dialog","aria-modal":"true",onClick:()=>Um(null),children:[E.jsx("button",{type:"button",className:"attachment-modal-close","aria-label":e("Close"),onClick:()=>Um(null),children:E.jsx(Be,{icon:si})}),E.jsxs("div",{className:"attachment-modal-body",onClick:te=>te.stopPropagation(),children:[E.jsx("img",{src:js.url,alt:js.name||e("Preview")}),js.name?E.jsx("div",{className:"attachment-modal-name",children:js.name}):null]})]}):null]})}B4({immediate:!0});ow(document.getElementById("root")).render(E.jsx(Tc.StrictMode,{children:E.jsx(HF,{children:E.jsx(Tz,{})})}));export{Be as F,cL as H,Tc as W,jz as a,Oz as b,Mz as c,Fz as d,Bz as e,Rz as f,Nz as i,E as j,x as r};
711
+ ${fe}`},[Tu]),Jm=Ze?Array.isArray(ke==null?void 0:ke.models)?ke.models:[]:Array.isArray(Gm)?Gm:[],Xm=Ze?!!(ke!=null&&ke.modelLoading):!!I2,Y2=Ze?(ke==null?void 0:ke.modelError)||"":D2,Yn=Ze&&!ke?[]:ke?ke.messages:i,J2=Array.isArray(Yn)&&Yn.length>0,yt=VC[qe]||"chat",Qm=hu[qe]||vm,{handleResumeSession:X2,onRepoSubmit:Q2}=GB({t:e,apiFetch:Xt,workspaceToken:Wr,handleLeaveWorkspace:Tm,repoUrl:y,setRepoUrl:S,repoInput:b,sessionNameInput:C,repoAuth:P,setRepoAuth:O,authMode:R,sshKeyInput:z,httpUsername:q,httpPassword:H,sessionMode:L,sessionRequested:ae,setSessionRequested:oe,defaultInternetAccess:W,defaultDenyGitCredentialsAccess:N,attachmentSession:f,setAttachmentSession:p,setAttachmentsLoading:Su,setAttachmentsError:Ea,setWorkspaceToken:Pk,setWorkspaceMode:Im,setWorkspaceError:Dm,setOpenAiLoginPending:se,setOpenAiLoginRequest:F}),Du=Qm.statusByPath||{},Z2=x.useMemo(()=>{const re={},fe=(xe,Te)=>{if(!xe)return;const $e=re[xe];if($e!=="untracked"){if(Te==="untracked"){re[xe]="untracked";return}$e||(re[xe]=Te)}};return Object.entries(Du).forEach(([xe,Te])=>{if(!xe)return;const $e=xe.split("/").filter(Boolean);if(!($e.length<=1))for(let ft=0;ft<$e.length-1;ft+=1){const yr=$e.slice(0,ft+1).join("/");fe(yr,Te)}}),re},[Du]),{resyncSession:ex}=a9({attachmentSessionId:f==null?void 0:f.sessionId,apiFetch:Xt,llmProvider:ne,setLlmProvider:ue,setSelectedProviders:le,setOpenAiReady:De,setClaudeReady:K,setRepoDiff:Ra,setRpcLogsEnabled:mu,setRpcLogs:Ts,setTerminalEnabled:bm,loadMainWorktreeSnapshot:ku}),{requestMessageSync:tx}=l9({socketRef:cr,messagesRef:ka});kB({attachmentSessionId:f==null?void 0:f.sessionId,workspaceToken:Wr,socketRef:cr,reconnectTimerRef:ck,reconnectAttemptRef:uk,closingRef:fk,pingIntervalRef:hk,lastPongRef:dk,messageIndex:Ei,commandIndex:Rs,rpcLogsEnabledRef:xm,mergeAndApplyMessages:u2,requestMessageSync:tx,requestWorktreesList:g2,requestWorktreeMessages:m2,applyWorktreesList:f2,resyncSession:ex,t:e,setStatus:c,setConnected:d,setAppServerReady:ie,setHasMainWorktreeStatus:v,setMessages:s,setProcessing:u,setActivity:_,setCurrentTurnId:wa,setMainTaskLabel:vu,setModelLoading:Us,setModelError:$s,setModels:O2,setProviderModelState:M2,setSelectedModel:xu,setSelectedReasoningEffort:j2,setRepoDiff:Ra,setRpcLogs:Ts,setWorktrees:Qt,setPaneByTab:Ps,setLogFilterByTab:Ds,setActiveWorktreeId:La,activeWorktreeIdRef:Vm,extractVibe80Task:sz,extractFirstLine:oz,getItemActivityLabel:ZC,maybeNotify:C2,normalizeAttachments:_n,loadRepoLastCommit:Hs,loadBranches:Km,loadWorktreeLastCommit:Eu,openAiLoginRequest:we,setOpenAiLoginRequest:F,connected:g});const Zm=x.useCallback((re="main")=>{const fe=cr.current;!fe||fe.readyState!==WebSocket.OPEN||(re==="main"?(Us(!0),$s("")):Qt(xe=>{const Te=new Map(xe),$e=Te.get(re);return $e?(Te.set(re,{...$e,modelLoading:!0,modelError:""}),Te):xe}),fe.send(JSON.stringify({type:"model_list",worktreeId:re})))},[$s,Us,Qt,cr]),rx=x.useCallback(re=>{const fe=cr.current;if(!fe||fe.readyState!==WebSocket.OPEN)return;const xe=re||null;ur==="main"?(xu(xe||""),Us(!0),$s("")):Qt(Te=>{const $e=new Map(Te),ft=$e.get(ur);return ft?($e.set(ur,{...ft,model:xe,modelLoading:!0,modelError:""}),$e):Te}),fe.send(JSON.stringify({type:"model_set",worktreeId:ur,model:xe,reasoningEffort:ur==="main"?qm||null:(ke==null?void 0:ke.reasoningEffort)??null}))},[ur,ke==null?void 0:ke.reasoningEffort,qm,$s,Us,xu,Qt,cr]);jB({activePane:yt,activeWorktreeId:qe,attachmentSessionId:f==null?void 0:f.sessionId,terminalEnabled:ba,terminalContainerRef:Pm,terminalDisposableRef:sk,terminalFitRef:ik,terminalRef:nk,terminalSessionRef:ak,terminalSocketRef:ok,terminalWorktreeRef:lk,themeMode:Xe,workspaceToken:Wr}),x.useEffect(()=>{typeof(f==null?void 0:f.terminalEnabled)=="boolean"&&bm(f.terminalEnabled)},[f==null?void 0:f.terminalEnabled]),x.useEffect(()=>{ie(!1)},[f==null?void 0:f.sessionId]),x.useEffect(()=>{!g||!(f!=null&&f.sessionId)||Vr!=="codex"&&Vr!=="claude"||Ze&&(ke==null?void 0:ke.status)!=="ready"||!Ze&&Vr==="codex"&&!te||Zm(ur)},[ur,ke==null?void 0:ke.status,Vr,te,f==null?void 0:f.sessionId,g,Ze,Zm]),x.useEffect(()=>{if(!(f!=null&&f.sessionId))return;ku(),Ra(f.repoDiff||{status:"",diff:""});const re=typeof f.rpcLogsEnabled=="boolean"?f.rpcLogsEnabled:!0;mu(re),Ts(re?f.rpcLogs||[]:[]),c(e("Connecting...")),d(!1),v(!1)},[f==null?void 0:f.sessionId,ku,Ei,e]),x.useEffect(()=>{if(f!=null&&f.sessionId){const re=(f==null?void 0:f.name)||Os||e("Session");document.title=`vibe80 - ${re}`}else document.title="vibe80"},[f==null?void 0:f.sessionId,f==null?void 0:f.name,Os,e]),x.useEffect(()=>{typeof(f==null?void 0:f.defaultInternetAccess)=="boolean"&&j(f.defaultInternetAccess)},[f==null?void 0:f.defaultInternetAccess]),x.useEffect(()=>{typeof(f==null?void 0:f.defaultDenyGitCredentialsAccess)=="boolean"&&G(f.defaultDenyGitCredentialsAccess)},[f==null?void 0:f.defaultDenyGitCredentialsAccess]),x.useEffect(()=>{if(!(f!=null&&f.defaultProvider)&&!(f!=null&&f.providers))return;const re=Array.isArray(f.providers)?f.providers.filter(fe=>fe==="codex"||fe==="claude"):[];re.length?(le(re),De(re.includes("codex")),K(re.includes("claude"))):f.defaultProvider&&(le([f.defaultProvider]),De(f.defaultProvider==="codex"),K(f.defaultProvider==="claude")),f.defaultProvider&&f.defaultProvider!==ne&&ue(f.defaultProvider)},[f==null?void 0:f.defaultProvider,f==null?void 0:f.providers]),x.useEffect(()=>{f!=null&&f.repoUrl&&rk(re=>xz(re,f.repoUrl))},[f==null?void 0:f.repoUrl]),p9({attachmentSessionId:f==null?void 0:f.sessionId,socketRef:cr,availableProviders:Ms,llmProvider:ne,providerSwitching:Se,processing:h,setProviderSwitching:ye,setStatus:c,setSelectedProviders:le,setLlmProvider:ue,t:e});const{commandMenuOpen:nx,setCommandMenuOpen:eg,setCommandQuery:ix,commandSelection:sx,filteredCommands:ox,isDraggingAttachments:ax,handleInputChange:lx,handleComposerKeyDown:cx,onSubmit:ux,onUploadAttachments:fx,onPasteAttachments:hx,onDragOverComposer:dx,onDragEnterComposer:px,onDragLeaveComposer:mx,onDropAttachments:gx,removeDraftAttachment:vx,triggerAttachmentPicker:_x,captureScreenshot:yx}=CB({t:e,input:a,setInput:o,inputRef:Ca,handleSendMessageRef:_a,attachmentSession:f,apiFetch:Xt,normalizeAttachments:_n,setDraftAttachments:Fs,draftAttachments:Bs,setAttachmentsLoading:Su,setAttachmentsError:Ea,showToast:_r,uploadInputRef:Em,attachmentsLoading:$m,conversationRef:Am,composerRef:Lm,isMobileLayout:hn}),{sendMessage:tg,sendCommitMessage:wx,sendWorktreeMessage:bx}=g9({input:a,setInput:o,setMessages:s,setDraftAttachments:Fs,socketRef:cr,connected:g,normalizeAttachments:_n,draftAttachments:Bs,setWorktrees:Qt,setProcessing:u,setActivity:_,processingLabel:e("Processing..."),handleSendMessageRef:_a,ensureNotificationPermission:S2}),{openCloseConfirm:Sx,closeCloseConfirm:Iu,handleConfirmDelete:Cx}=u9({closeConfirm:wm,setCloseConfirm:gu,setActiveWorktreeId:La,activeWorktreeIdRef:Vm,closeWorktree:h2});x.useEffect(()=>{Sa.current&&(Sa.current.scrollTop=Sa.current.scrollHeight)},[Yn,h,qe]);const kx=x.useMemo(()=>{const re={id:"main",name:Ai||"Main",branchName:Ai||"main",provider:ne,status:h?"processing":g?m?"ready":"processing":"creating",color:"#6b7280",messages:i},fe=Array.from(Pa.values());return[re,...fe]},[Ai,ne,h,g,m,i,Pa]),xx=x.useMemo(()=>{const re=[];return(Yn||[]).forEach(fe=>{if((fe==null?void 0:fe.role)==="commandExecution"){if(!ge)return;const xe=re[re.length-1];(xe==null?void 0:xe.groupType)==="commandExecution"?xe.items.push(fe):re.push({groupType:"commandExecution",id:`command-group-${fe.id}`,items:[fe]});return}if((fe==null?void 0:fe.role)==="tool_result"){if(!We)return;const xe=re[re.length-1];(xe==null?void 0:xe.groupType)==="toolResult"?xe.items.push(fe):re.push({groupType:"toolResult",id:`tool-result-group-${fe.id}`,items:[fe]});return}if((fe==null?void 0:fe.type)==="action_result"){const xe=re[re.length-1];(xe==null?void 0:xe.groupType)==="toolResult"?xe.items.push(fe):re.push({groupType:"toolResult",id:`tool-result-group-${fe.id}`,items:[fe]});return}re.push(fe)}),re},[Yn,ge,We]),{setShowOlderMessagesByTab:Nu,collapsedMessages:Ex}=o9({activeChatKey:ur,displayedGroupedMessages:xx,CHAT_COLLAPSE_THRESHOLD:cz,CHAT_COLLAPSE_VISIBLE:uz});x.useEffect(()=>{const re=(f==null?void 0:f.sessionId)||null;Ls.current!==re&&(Ls.current=re,s([]),Ei.clear(),Rs.clear(),Qt(new Map),La("main"),Ps({main:"chat"}),Ds({main:"all"}),du({}),Nu({}),Is({}),Ns({}),Au(null),Lu(new Map),wa(null),vu(""),_(""),gu(null),Y({}))},[f==null?void 0:f.sessionId,Rs,Ei,La,_,gu,Is,wa,du,Ds,vu,s,Y,Ps,Au,Nu,Ns,Lu,Qt]);const dn=Ze?Pu.get(qe):Da,rg=Ze?(ke==null?void 0:ke.branchName)||(ke==null?void 0:ke.name)||"":Ai||(Da==null?void 0:Da.branch)||"",ng=typeof(dn==null?void 0:dn.sha)=="string"?dn.sha.slice(0,7):"",Ax=Ze?!!(ke!=null&&ke.internetAccess):!!W,Lx=Ze?(ke==null?void 0:ke.denyGitCredentialsAccess)===!1:N===!1,ig=Pz(Vr,e),sg=Ym||e("Default model"),Px=!!(ig&&sg),Tx=Os||e("Repository"),Dx=!hn&&yt==="chat"&&!!(rg&&ng&&(dn!=null&&dn.message)),Ix=(ke==null?void 0:ke.status)==="processing",og=(ke==null?void 0:ke.status)==="stopped",Ws=Ze?Ix:h,Vs=Ws||Ze&&og,Nx=Ze?(ke==null?void 0:ke.activity)||"":w,Rx=Ws?Ze?ke==null?void 0:ke.taskLabel:XC:"",ag=Ze?ke==null?void 0:ke.currentTurnId:qC,Ox=Ws&&!!ag,lg=Vr!=="codex"?!0:Ze?(ke==null?void 0:ke.status)==="ready":te,Mx=Vr==="codex"||Vr==="claude",jx=!g||Vs||Xm||!Jm.length,Bx=Ym||"",{handleViewSelect:Oa,handleOpenSettings:cg,handleSettingsBack:Fx}=r9({activePane:yt,activeWorktreeId:qe,debugMode:km,rpcLogsEnabled:pu,terminalEnabled:ba,setPaneByTab:Ps,setToolbarExportOpen:_u,lastPaneByTabRef:QC}),{addToBacklog:zx,backlog:Ma,editBacklogItem:$x,launchBacklogItem:Ux,markBacklogItemDone:Hx,removeFromBacklog:Wx,setBacklogMessagePage:Vx}=HB({attachmentSessionId:f==null?void 0:f.sessionId,apiFetch:Xt,normalizeAttachments:_n,sendMessage:tg,setInput:o,setMessages:s,setWorktrees:Qt,setDraftAttachments:Fs,input:a,draftAttachments:Bs,inputRef:Ca,showToast:_r,t:e}),{interruptTurn:Kx}=i9({activeWorktreeId:qe,isInWorktree:Ze,currentTurnIdForActive:ag,socketRef:cr,setWorktrees:Qt,setActivity:_}),{handleLeaveSession:Ru}=n9({setAttachmentSession:p,setRepoUrl:S,setRepoInput:k,setRepoAuth:O,setSessionRequested:oe,setAttachmentsError:Ea,setAttachmentsLoading:Su,setMessages:s,setRepoDiff:Ra,setRpcLogs:Ts,setRpcLogsEnabled:mu,setRepoLastCommit:Au,setWorktreeLastCommitById:Lu,setCurrentTurnId:wa,setActivity:_,setDefaultDenyGitCredentialsAccess:G});x.useEffect(()=>{!Wr&&(f!=null&&f.sessionId)&&Ru()},[Wr,f==null?void 0:f.sessionId,Ru]);const{handleDiffSelect:Gx}=s9({activeWorktreeId:qe,handleViewSelect:Oa,requestWorktreeDiff:Na,requestRepoDiff:Ia}),{openPathInExplorer:qx,requestExplorerTree:Ou,requestExplorerStatus:Mu,openFileInExplorer:Yx,setActiveExplorerFile:Jx,closeExplorerFile:Xx,selectExplorerNode:ug,toggleExplorerDir:Qx,updateExplorerDraft:Zx,saveExplorerFile:eE,startExplorerRename:tE,cancelExplorerRename:fg,updateExplorerRenameDraft:hg,submitExplorerRename:ja,createExplorerFile:rE,createExplorerFolder:nE,deleteExplorerSelection:iE}=d9({attachmentSessionId:f==null?void 0:f.sessionId,apiFetch:Xt,t:e,setExplorerByTab:du,explorerDefaultState:vm,explorerRef:Sm,activeWorktreeId:qe,handleViewSelect:Oa,showToast:_r,requestExplorerTreeRef:KC,requestExplorerStatusRef:GC,loadExplorerFileRef:ya});WB({activeProvider:Vr,activeWorktreeId:qe,addToBacklog:zx,apiFetch:Xt,attachmentSessionId:f==null?void 0:f.sessionId,captureScreenshot:yx,connected:g,handleSendMessageRef:_a,handleViewSelect:Oa,input:a,isWorktreeStopped:og,isCodexReady:lg,isInWorktree:Ze,openPathInExplorer:qx,requestRepoDiff:Ia,requestWorktreeDiff:Na,sendMessage:tg,sendWorktreeMessage:bx,buildAnnotatedMessage:q2,clearScopedAnnotations:G2,setAnnotationMode:T,setCommandMenuOpen:eg,setDraftAttachments:Fs,setInput:o,setMessages:s,setWorktrees:Qt,socketRef:cr,showToast:_r,t:e});const{handleClearRpcLogs:sE}=f9({activeWorktreeId:qe,setRpcLogs:Ts});x.useEffect(()=>{yt==="diff"&&(qe&&qe!=="main"?Na(qe):Ia())},[yt,qe,Ia,Na]),x.useEffect(()=>{if(yt!=="explorer")return;const re=qe||"main";Ou(re,!0),Mu(re,!0)},[yt,qe,Ou,Mu]),x.useEffect(()=>{if(!(!(f!=null&&f.sessionId)||hn||yt!=="chat")){if(Ze&&qe){Pu.has(qe)||Eu(qe);return}Hs()}},[f==null?void 0:f.sessionId,hn,yt,Ze,qe,Pu,Eu,Hs]),m9({currentMessages:Yn,attachmentRepoUrl:f==null?void 0:f.repoUrl,repoUrl:y,isInWorktree:Ze,activeWorktree:ke,t:e,normalizeAttachments:_n,downloadTextFile:Ez,formatExportName:Az,extractRepoName:bl,setToolbarExportOpen:_u});const{handleClearChat:oE}=v9({activeWorktreeId:qe,setToolbarExportOpen:_u,setWorktrees:Qt,lastNotifiedIdRef:k2,attachmentSessionId:f==null?void 0:f.sessionId,apiFetch:Xt,setMessages:s,messageIndex:Ei,commandIndex:Rs,setChoiceSelections:s2,choicesKey:Hm,setCommandPanelOpen:Is,setToolResultPanelOpen:Ns,llmProvider:ne});if(f!=null&&f.sessionId,Ms.length>1&&Ms.find(re=>re!==ne),!(f!=null&&f.sessionId)){const fe=L==="new"&&ae&&!!y,xe=wl(y,72),Te=Nm||ae,$e=Ba=>Bk[Ba]||{},ft=yu==="mono_user"&&!Wr,yr=!ft&&xa===1,pn=!ft&&xa===2,mn=xa===3&&Wr,gt=xa===4&&Wr,ju=ft?e("Please use the console generated URL to login"):pn?e("Configure AI providers for this workspace."):mn?e("Workspace created hint"):null,Bu=ft?{title:e("Login required"),paragraphs:[e("Please use the console generated URL to login")]}:pn?{title:e("Configure AI providers"),paragraphs:[e("Vibe80 can run Codex or Claude Code. To continue, provide your Anthropic and/or OpenAI credentials. If you use pay-as-you-go billing, supply an API key."),e("For subscription plans, use auth.json from the Codex CLI login (ChatGPT) or a long-lived token from `claude setup-token` (Claude).")],setupLink:!0}:mn?{title:e("Workspace credentials"),paragraphs:[e("Please keep your workspace credentials (Workspace ID and Workspace Secret) for future access. We do not have a user identification mechanism; your Workspace ID is your only identifier.")]}:gt?{title:e("Start a session"),paragraphs:[e("Vibe80 opens Git-based work sessions. Even in a secure environment, we recommend short-lived and revocable PATs or keys.")],securityLink:!0}:{title:e("Configure the workspace"),paragraphs:[e("A workspace is an isolated, secured environment accessible only with credentials. It lets you reuse AI credentials for all future sessions."),e("You can create multiple workspaces to separate teams, projects, or security boundaries.")]};return E.jsx(KF,{t:e,brandLogo:Bm,showStep1:yr,showStep2:pn,showStep3:mn,showStep4:gt,showMonoLoginRequired:ft,headerHint:ju,workspaceMode:jk,setWorkspaceMode:Im,formDisabled:Te,handleWorkspaceSubmit:vk,workspaceIdInput:Mk,setWorkspaceIdInput:kk,workspaceSecretInput:zk,setWorkspaceSecretInput:Ak,workspaceError:Rk,handleWorkspaceProvidersSubmit:gk,workspaceProvider:$e,workspaceAuthExpanded:Tk,setWorkspaceAuthExpanded:Sk,setWorkspaceProviders:xk,providerAuthOptions:NC,getProviderAuthType:K1,workspaceAuthFiles:Dk,setWorkspaceAuthFiles:Ck,sessionMode:L,setSessionMode:B,setSessionRequested:oe,setAttachmentsError:Ea,loadWorkspaceSessions:yk,deploymentMode:yu,handleLeaveWorkspace:Tm,workspaceSessionsLoading:Wk,workspaceSessions:Uk,workspaceSessionsError:Hk,workspaceSessionDeletingId:$k,handleResumeSession:X2,handleDeleteSession:pk,locale:n,extractRepoName:bl,getTruncatedText:wl,isCloning:fe,repoDisplay:xe,onRepoSubmit:Q2,sessionNameInput:C,setSessionNameInput:A,repoInput:b,setRepoInput:k,repoHistory:Cm,authMode:R,setAuthMode:M,sshKeyInput:z,setSshKeyInput:U,httpUsername:q,setHttpUsername:Q,httpPassword:H,setHttpPassword:I,defaultInternetAccess:W,setDefaultInternetAccess:j,defaultDenyGitCredentialsAccess:N,setDefaultDenyGitCredentialsAccess:G,attachmentsError:zm,sessionRequested:ae,workspaceBusy:Nm,workspaceProvidersEditing:Fk,providersBackStep:wk,setWorkspaceStep:Lk,setWorkspaceProvidersEditing:Ek,setWorkspaceError:Dm,setProvidersBackStep:bk,loadWorkspaceProviders:_k,workspaceCreated:Nk,workspaceId:Ok,workspaceCopied:Ik,handleWorkspaceCopy:mk,infoContent:Bu,toast:V})}const dg=(re,fe,xe,Te,$e,ft,yr,pn,mn)=>!Array.isArray(re)||re.length===0?null:E.jsx("ul",{className:"explorer-tree-list",children:re.map(gt=>{if(gt.type==="dir"){const Ut=xe.has(gt.path),aE=Te===gt.path&&$e==="dir",lE=ft===gt.path,pg=(mn==null?void 0:mn[gt.path])||"";return E.jsxs("li",{className:`explorer-tree-item is-dir ${aE?"is-selected":""} ${pg?`is-${pg}`:""}`,children:[E.jsxs("div",{className:"explorer-tree-entry",children:[E.jsx("button",{type:"button",className:"explorer-tree-caret-button",onClick:Ir=>{Ir.stopPropagation(),Qx(fe,gt.path)},children:E.jsx("span",{className:"explorer-tree-caret","aria-hidden":"true",children:E.jsx(Be,{icon:Ut?e6:qD})})}),lE?E.jsx("div",{className:"explorer-tree-toggle is-renaming",children:E.jsx("input",{className:"explorer-tree-rename-input",value:yr||"",autoFocus:!0,onClick:Ir=>Ir.stopPropagation(),onChange:Ir=>hg(fe,Ir.target.value),onBlur:()=>{ja(fe)},onKeyDown:Ir=>{Ir.key==="Enter"?(Ir.preventDefault(),ja(fe)):Ir.key==="Escape"&&(Ir.preventDefault(),fg(fe))}})}):E.jsx("button",{type:"button",className:"explorer-tree-toggle",onClick:()=>ug(fe,gt.path,"dir"),children:E.jsx("span",{className:"explorer-tree-name",children:gt.name})})]}),Ut?dg(gt.children||[],fe,xe,Te,$e,ft,yr,pn,mn):null]},gt.path)}const ju=Te===gt.path&&$e==="file",Bu=ft===gt.path,Ba=(pn==null?void 0:pn[gt.path])||"";return E.jsx("li",{className:`explorer-tree-item is-file ${ju?"is-selected":""} ${Ba?`is-${Ba}`:""}`,children:Bu?E.jsxs("div",{className:"explorer-tree-file is-renaming",children:[E.jsx("span",{className:"explorer-tree-icon","aria-hidden":"true",children:E.jsx(Be,{icon:E_})}),E.jsx("input",{className:"explorer-tree-rename-input",value:yr||"",autoFocus:!0,onClick:Ut=>Ut.stopPropagation(),onChange:Ut=>hg(fe,Ut.target.value),onBlur:()=>{ja(fe)},onKeyDown:Ut=>{Ut.key==="Enter"?(Ut.preventDefault(),ja(fe)):Ut.key==="Escape"&&(Ut.preventDefault(),fg(fe))}})]}):E.jsxs("button",{type:"button",className:"explorer-tree-file",onClick:()=>{var Ut;ug(fe,gt.path,"file"),(Ut=ya.current)==null||Ut.call(ya,fe,gt.path)},children:[E.jsx("span",{className:"explorer-tree-icon","aria-hidden":"true",children:E.jsx(Be,{icon:E_})}),E.jsx("span",{className:"explorer-tree-name",children:gt.name})]})},gt.path)})});return E.jsxs("div",{className:"app",children:[E.jsx(VF,{t:e,brandLogo:Bm,allTabs:kx,activeWorktreeId:qe,handleSelectWorktree:p2,createWorktree:d2,openCloseConfirm:Sx,renameWorktreeHandler:v2,llmProvider:ne,availableProviders:Ms,branches:E2,defaultBranch:P2,currentBranch:Ai,branchLoading:L2,branchError:A2,defaultInternetAccess:W,defaultDenyGitCredentialsAccess:N,deploymentMode:yu,loadBranches:Km,providerModelState:N2,loadProviderModels:T2,connected:g,isMobileLayout:hn,requestHandoffQr:Mm,attachmentSession:f,handoffLoading:wu,handleOpenSettings:cg,handleLeaveSession:Ru}),E.jsxs("div",{className:`layout ${_m?"is-side-open":"is-side-collapsed"} ${hn?"is-mobile":""}`,children:[hn&&_m?E.jsx("button",{type:"button",className:"side-backdrop","aria-label":e("Close panel"),onClick:()=>ym(!1)}):null,E.jsxs("aside",{className:"side",children:[E.jsx("div",{className:"side-body",children:E.jsxs("section",{className:"backlog",children:[E.jsxs("div",{className:"panel-header",children:[E.jsx("div",{className:"panel-title",children:e("Backlog")}),E.jsx("div",{className:"panel-subtitle",children:Ma.length===0?e("No tasks"):e("{{count}} item(s)",{count:Ma.length})})]}),Ma.length===0?E.jsx("div",{className:"backlog-empty",children:e("No pending tasks at the moment.")}):E.jsx("ul",{className:"backlog-list",children:Ma.map(re=>{var fe;return E.jsxs("li",{className:"backlog-item",children:[E.jsx("div",{className:"backlog-text",children:wl(re.text,180)}),E.jsxs("div",{className:"backlog-actions",children:[E.jsx("button",{type:"button",className:"ghost",onClick:()=>$x(re),children:e("Edit")}),E.jsx("button",{type:"button",onClick:()=>Ux(re),disabled:!g,children:e("Launch")}),E.jsx("button",{type:"button",className:"ghost",onClick:()=>Wx(re.id),children:e("Delete")})]}),(fe=re.attachments)!=null&&fe.length?E.jsx("div",{className:"backlog-meta",children:e("{{count}} attachment(s)",{count:re.attachments.length})}):null]},re.id)})})]})}),E.jsx("div",{className:"side-footer",children:E.jsxs("button",{type:"button",className:`side-footer-button ${yt==="settings"?"is-active":""}`,onClick:cg,"aria-pressed":yt==="settings",children:[E.jsx("span",{className:"side-footer-icon","aria-hidden":"true",children:E.jsx(Be,{icon:Rb})}),e("Settings")]})})]}),E.jsxs("section",{className:"conversation is-chat-narrow",ref:Am,children:[E.jsxs("div",{className:"pane-stack",children:[E.jsx(SB,{t:e,activePane:yt,handleViewSelect:Oa,handleDiffSelect:Gx,terminalEnabled:ba,hasMessages:J2,handleClearChat:oE}),E.jsx(Q8,{t:e,activePane:yt,listRef:Sa,showChatInfoPanel:Dx,repoTitle:Tx,activeBranchLabel:rg,shortSha:ng,activeCommit:dn,showProviderMeta:Px,activeProviderLabel:ig,activeModelLabel:sg,showInternetAccess:Ax,showGitCredentialsShared:Lx,activeTaskLabel:Rx,currentMessages:Yn,chatHistoryWindow:Ex,activeChatKey:ur,setShowOlderMessagesByTab:Nu,showChatCommands:ge,showToolResults:We,commandPanelOpen:ek,setCommandPanelOpen:Is,toolResultPanelOpen:tk,setToolResultPanelOpen:Ns,renderMessageAttachments:n2,currentProcessing:Ws,currentInteractionBlocked:Vs,currentActivity:Nx,extractVibe80Blocks:iz,handleChoiceClick:l2,choiceSelections:i2,openVibe80Form:o2,copyTextToClipboard:G1,openFileInExplorer:Yx,setInput:o,inputRef:Ca,markBacklogItemDone:Hx,setBacklogMessagePage:Vx,activeWorktreeId:qe,BACKLOG_PAGE_SIZE:lz,MAX_USER_DISPLAY_LENGTH:az,getTruncatedText:wl,annotationMode:D,scopedAnnotations:Tu,setAnnotationDraft:W2,removeAnnotation:V2,addOrFocusAnnotation:K2}),E.jsx(x.Suspense,{fallback:null,children:E.jsx(JF,{t:e,activePane:yt,isInWorktree:Ze,diffStatusLines:z2,connected:g,currentProcessing:Ws,hasCurrentChanges:$2,sendCommitMessage:wx,diffFiles:F2,currentDiff:B2,untrackedFilePanels:U2,untrackedLoading:H2})}),E.jsx(x.Suspense,{fallback:null,children:E.jsx(YF,{t:e,activePane:yt,repoName:Os,activeWorktree:ke,isInWorktree:Ze,activeWorktreeId:qe,attachmentSession:f,requestExplorerTree:Ou,requestExplorerStatus:Mu,activeExplorer:Qm,renderExplorerNodes:dg,explorerStatusByPath:Du,explorerDirStatus:Z2,saveExplorerFile:eE,updateExplorerDraft:Zx,setActiveExplorerFile:Jx,closeExplorerFile:Xx,startExplorerRename:tE,createExplorerFile:rE,createExplorerFolder:nE,deleteExplorerSelection:iE,getLanguageForPath:Lz,themeMode:Xe})}),E.jsx(x.Suspense,{fallback:null,children:E.jsx(XF,{t:e,terminalEnabled:ba,activePane:yt,repoName:Os,activeWorktree:ke,isInWorktree:Ze,terminalContainerRef:Pm,attachmentSession:f})}),E.jsx(x.Suspense,{fallback:null,children:E.jsx(ZF,{t:e,activePane:yt,filteredRpcLogs:b2,logFilter:_2,setLogFilter:y2,scopedRpcLogs:w2,handleClearRpcLogs:sE})}),E.jsx(x.Suspense,{fallback:null,children:E.jsx(QF,{t:e,activePane:yt,handleSettingsBack:Fx,language:t,setLanguage:r,showChatCommands:ge,setShowChatCommands:Ge,showToolResults:We,setShowToolResults:Je,notificationsEnabled:xt,setNotificationsEnabled:xi,themeMode:Xe,setThemeMode:Et,gitIdentityName:Kk,setGitIdentityName:e2,gitIdentityEmail:Gk,setGitIdentityEmail:t2,gitIdentityGlobal:qk,gitIdentityRepo:Yk,gitIdentityLoading:Jk,gitIdentitySaving:Xk,gitIdentityError:Qk,gitIdentityMessage:Zk,handleSaveGitIdentity:r2,attachmentSession:f})})]}),E.jsx(bB,{t:e,activePane:yt,isDraggingAttachments:ax,onSubmit:ux,onDragEnterComposer:px,onDragOverComposer:dx,onDragLeaveComposer:mx,onDropAttachments:gx,composerRef:Lm,draftAttachments:Bs,getAttachmentExtension:dz,formatAttachmentSize:pz,removeDraftAttachment:vx,commandMenuOpen:nx,filteredCommands:ox,setInput:o,setCommandMenuOpen:eg,setCommandQuery:ix,inputRef:Ca,commandSelection:sx,triggerAttachmentPicker:_x,attachmentSession:f,attachmentsLoading:$m,isMobileLayout:hn,uploadInputRef:Em,onUploadAttachments:fx,input:a,handleInputChange:lx,handleComposerKeyDown:cx,onPasteAttachments:hx,canInterrupt:Ox,interruptTurn:Kx,connected:g,modelSelectorVisible:Mx,modelOptions:Jm,selectedModel:Bx,modelLoading:Xm,modelDisabled:jx,modelError:Y2,onModelChange:rx,isCodexReady:lg,interactionBlocked:Vs,attachmentsError:zm})]})]}),Aa?E.jsx("div",{className:"vibe80-form-overlay",role:"dialog","aria-modal":"true",onClick:Cu,children:E.jsxs("div",{className:"vibe80-form-dialog",onClick:re=>re.stopPropagation(),children:[E.jsxs("div",{className:"vibe80-form-header",children:[E.jsx("div",{className:"vibe80-form-title",children:Aa.question||e("Form")}),E.jsx("button",{type:"button",className:"vibe80-form-close","aria-label":e("Close"),onClick:Cu,children:E.jsx(Be,{icon:si})})]}),E.jsxs("form",{className:"vibe80-form-body",onSubmit:re=>{if(Vs){re.preventDefault();return}a2(re)},children:[Aa.fields.map(re=>{const fe=`vibe80-${Aa.key}-${re.id}`,xe=Wm[re.id]??"";return re.type==="checkbox"?E.jsx("div",{className:"vibe80-form-field",children:E.jsxs("label",{className:"vibe80-form-checkbox",children:[E.jsx("input",{type:"checkbox",checked:!!Wm[re.id],onChange:Te=>zs(re.id,Te.target.checked)}),E.jsx("span",{children:re.label})]})},re.id):re.type==="textarea"?E.jsxs("div",{className:"vibe80-form-field",children:[E.jsx("label",{className:"vibe80-form-label",htmlFor:fe,children:re.label}),E.jsx("textarea",{id:fe,className:"vibe80-form-input",rows:4,value:xe,onChange:Te=>zs(re.id,Te.target.value)})]},re.id):re.type==="radio"?E.jsxs("div",{className:"vibe80-form-field",children:[E.jsx("div",{className:"vibe80-form-label",children:re.label}),E.jsx("div",{className:"vibe80-form-options",children:(re.choices||[]).length?re.choices.map(Te=>E.jsxs("label",{className:"vibe80-form-option",children:[E.jsx("input",{type:"radio",name:fe,value:Te,checked:xe===Te,onChange:()=>zs(re.id,Te)}),E.jsx("span",{children:Te})]},`${re.id}-${Te}`)):E.jsx("div",{className:"vibe80-form-empty",children:e("No options.")})})]},re.id):re.type==="select"?E.jsxs("div",{className:"vibe80-form-field",children:[E.jsx("label",{className:"vibe80-form-label",htmlFor:fe,children:re.label}),E.jsx("select",{id:fe,className:"vibe80-form-input vibe80-form-select",value:xe,onChange:Te=>zs(re.id,Te.target.value),children:(re.choices||[]).length?re.choices.map(Te=>E.jsx("option",{value:Te,children:Te},`${re.id}-${Te}`)):E.jsx("option",{value:"",children:e("No options")})})]},re.id):E.jsxs("div",{className:"vibe80-form-field",children:[E.jsx("label",{className:"vibe80-form-label",htmlFor:fe,children:re.label}),E.jsx("input",{id:fe,className:"vibe80-form-input",type:"text",value:xe,onChange:Te=>zs(re.id,Te.target.value)})]},re.id)}),E.jsxs("div",{className:"vibe80-form-actions",children:[E.jsx("button",{type:"button",className:"vibe80-form-cancel",onClick:Cu,children:e("Cancel")}),E.jsx("button",{type:"submit",className:"vibe80-form-submit",disabled:Vs,children:e("Send")})]})]})]})}):null,Vk?E.jsx("div",{className:"handoff-modal-overlay",role:"dialog","aria-modal":"true",onClick:jm,children:E.jsxs("div",{className:"handoff-modal",onClick:re=>re.stopPropagation(),children:[E.jsxs("div",{className:"handoff-modal-header",children:[E.jsx("div",{className:"handoff-modal-title",children:e("Continue on mobile")}),E.jsx("button",{type:"button",className:"handoff-modal-close","aria-label":e("Close"),onClick:jm,children:E.jsx(Be,{icon:si})})]}),E.jsxs("div",{className:"handoff-modal-body",children:[E.jsx("p",{className:"handoff-modal-text",children:e("Scan this QR code in the Android app to resume the current session.")}),Om?E.jsx("div",{className:"handoff-modal-error",children:Om}):null,Rm?E.jsx("div",{className:"handoff-modal-qr",children:E.jsx("img",{src:Rm,alt:e("QR code")})}):E.jsx("div",{className:"handoff-modal-placeholder",children:e(wu?"Generating QR code...":"QR code unavailable.")}),typeof bu=="number"?E.jsx("div",{className:"handoff-modal-meta",children:bu>0?e("Expires in {{seconds}}s",{seconds:bu}):e("QR code expired")}):null,E.jsx("div",{className:"handoff-modal-actions",children:E.jsx("button",{type:"button",className:"session-button",onClick:Mm,disabled:wu,children:e("Regenerate")})})]})]})}):null,wm?E.jsx("div",{className:"worktree-close-confirm-overlay",role:"dialog","aria-modal":"true",onClick:Iu,children:E.jsxs("div",{className:"worktree-close-confirm-dialog",onClick:re=>re.stopPropagation(),children:[E.jsxs("div",{className:"worktree-close-confirm-header",children:[E.jsx("div",{className:"worktree-close-confirm-title",children:e("Close the worktree?")}),E.jsx("button",{type:"button",className:"worktree-close-confirm-close","aria-label":e("Close"),onClick:Iu,children:E.jsx(Be,{icon:si})})]}),E.jsx("div",{className:"worktree-close-confirm-body",children:e("All changes will be lost. What would you like to do?")}),E.jsxs("div",{className:"worktree-close-confirm-actions",children:[E.jsx("button",{type:"button",className:"worktree-close-confirm-cancel",onClick:Iu,children:e("Cancel")}),E.jsx("button",{type:"button",className:"worktree-close-confirm-delete",onClick:Cx,children:e("Delete worktree")})]})]})}):null,js?E.jsxs("div",{className:"attachment-modal",role:"dialog","aria-modal":"true",onClick:()=>Um(null),children:[E.jsx("button",{type:"button",className:"attachment-modal-close","aria-label":e("Close"),onClick:()=>Um(null),children:E.jsx(Be,{icon:si})}),E.jsxs("div",{className:"attachment-modal-body",onClick:re=>re.stopPropagation(),children:[E.jsx("img",{src:js.url,alt:js.name||e("Preview")}),js.name?E.jsx("div",{className:"attachment-modal-name",children:js.name}):null]})]}):null]})}B4({immediate:!0});ow(document.getElementById("root")).render(E.jsx(Tc.StrictMode,{children:E.jsx(HF,{children:E.jsx(Tz,{})})}));export{Be as F,cL as H,Tc as W,jz as a,Oz as b,Mz as c,Fz as d,Bz as e,Rz as f,Nz as i,E as j,x as r};