yepanywhere 0.2.8 → 0.2.9
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.
|
@@ -142,4 +142,4 @@ User uploaded files:
|
|
|
142
142
|
`)){const p=f.match(d);p&&n.push({originalName:p[1]??"",size:p[2]??"",mimeType:p[3]??"",path:p[4]??""})}return{textWithoutUploads:l,uploadedFiles:n}}function Cv(e){const{textWithoutUploads:n,uploadedFiles:r}=dA(e);return{text:Nw(n),openedFiles:Ew(n),uploadedFiles:r}}const Mf=12,mf=Mf*100;function dc({files:e}){return e.length===0?null:a.jsx("div",{className:"user-prompt-metadata",children:e.map(n=>a.jsx("span",{className:"opened-file",title:`file was opened in editor: ${n}`,children:uA(n)},n))})}function fA(e){return e.startsWith("image/")}function hA(e){const n=e.split("/");if(n.length<3)return null;const r=n[n.length-1],o=n[n.length-2],l=n[n.length-3];return!r||!o||!l||!/^[0-9a-f-]{36}_/.test(r)?null:`/api/projects/${l}/sessions/${o}/upload/${encodeURIComponent(r)}`}function mA({file:e}){const[n,r]=h.useState(!1),o=fA(e.mimeType),l=o?hA(e.path):null,{url:u,loading:d,error:f}=cA(l);return o&&l?a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"uploaded-file uploaded-file-clickable",title:`${e.mimeType}, ${e.size}`,onClick:()=>r(!0),children:["📎 ",e.originalName]}),n&&a.jsx(os,{title:e.originalName,onClose:()=>r(!1),children:a.jsxs("div",{className:"uploaded-image-modal",children:[d&&a.jsx("div",{className:"image-loading",children:"Loading..."}),f&&a.jsx("div",{className:"image-error",children:"Failed to load image"}),u&&a.jsx("img",{src:u,alt:e.originalName})]})})]}):a.jsxs("span",{className:"uploaded-file",title:`${e.mimeType}, ${e.size}`,children:["📎 ",e.originalName]})}function fc({files:e}){return e.length===0?null:a.jsx("div",{className:"user-prompt-metadata",children:e.map(n=>a.jsx(mA,{file:n},n.path))})}function kv({text:e}){const[n,r]=h.useState(!1),o=e.split(`
|
|
143
143
|
`),l=o.length>Mf,u=e.length>mf,d=l||u;if(!d||n)return a.jsxs("div",{className:"text-block",children:[e,n&&d&&a.jsx("button",{type:"button",className:"show-more-btn",onClick:()=>r(!1),children:"Show less"})]});let f=l?o.slice(0,Mf).join(`
|
|
144
144
|
`):e;return f.length>mf&&(f=f.slice(0,mf)),a.jsxs("div",{className:"text-block collapsible-text",children:[a.jsxs("div",{className:"truncated-content",children:[f,a.jsx("div",{className:"fade-overlay"})]}),a.jsx("button",{type:"button",className:"show-more-btn",onClick:()=>r(!0),children:"Show more"})]})}const pA=h.memo(function({content:n}){if(typeof n=="string"){const{text:d,openedFiles:f,uploadedFiles:p}=Cv(n);return d?a.jsxs("div",{className:"user-prompt-container",children:[a.jsx("div",{className:"message message-user-prompt",children:a.jsxs("div",{className:"message-content",children:[a.jsx(kv,{text:d}),a.jsx(fc,{files:p})]})}),a.jsx(dc,{files:f})]}):f.length>0||p.length>0?a.jsxs(a.Fragment,{children:[a.jsx(fc,{files:p}),a.jsx(dc,{files:f})]}):null}const r=n.filter(d=>d.type==="text"&&d.text).map(d=>d.text).join(`
|
|
145
|
-
`),{text:o,openedFiles:l,uploadedFiles:u}=Cv(r);return o?a.jsxs("div",{className:"user-prompt-container",children:[a.jsx("div",{className:"message message-user-prompt",children:a.jsxs("div",{className:"message-content",children:[a.jsx(kv,{text:o}),a.jsx(fc,{files:u})]})}),a.jsx(dc,{files:l})]}):l.length>0||u.length>0?a.jsxs(a.Fragment,{children:[a.jsx(fc,{files:u}),a.jsx(dc,{files:l})]}):a.jsx("div",{className:"message message-user-prompt",children:a.jsx("div",{className:"message-content",children:a.jsx("div",{className:"text-block",children:"[Complex content]"})})})}),Of=h.memo(function({item:n,isStreaming:r,thinkingExpanded:o,toggleThinkingExpanded:l}){const u=h.useCallback(f=>{const p=window.getSelection();p&&p.toString().length>0||f.shiftKey&&!f.ctrlKey&&!f.metaKey&&(f.preventDefault(),f.stopPropagation(),console.log("[DEBUG] RenderItem:",n),console.log("[DEBUG] Source JSONL entries:",n.sourceMessages))},[n]),d=()=>{switch(n.type){case"text":return a.jsx(h4,{text:n.text,isStreaming:n.isStreaming,augmentHtml:n.augmentHtml});case"thinking":return a.jsx(g4,{thinking:n.thinking,status:n.status,isExpanded:o,onToggle:l});case"tool_call":return a.jsx(aA,{id:n.id,toolName:n.toolName,toolInput:n.toolInput,toolResult:n.toolResult,status:n.status});case"user_prompt":return a.jsx(pA,{content:n.content});case"system":{const f=n.subtype==="status"&&n.status==="compacting";return a.jsxs("div",{className:`system-message ${f?"system-message-compacting":""}`,children:[a.jsx("span",{className:`system-message-icon ${f?"spinning":""}`,children:"⟳"}),a.jsx("span",{className:"system-message-text",children:n.content})]})}default:return null}};return a.jsx("div",{className:n.isSubagent?"subagent-item":void 0,"data-render-type":n.type,"data-render-id":n.id,onClick:u,children:d()})});function gA(e){const n=[];let r=[];for(const o of e)o.type==="user_prompt"?(r.length>0&&(n.push({isUserPrompt:!1,items:r}),r=[]),n.push({isUserPrompt:!0,items:[o]})):r.push(o);return r.length>0&&n.push({isUserPrompt:!1,items:r}),n}const xA=h.memo(function({messages:n,isStreaming:r=!1,isProcessing:o=!1,isCompacting:l=!1,scrollTrigger:u=0,pendingMessages:d=[],deferredMessages:f=[],onCancelDeferred:p,markdownAugments:x,activeToolApproval:v}){const y=h.useRef(null),S=h.useRef(!0),w=h.useRef(!0),C=h.useRef(!1),_=h.useRef(0),E=h.useRef(null),[k,M]=h.useState(!1),O=h.useCallback(V=>{C.current=!0,V.scrollTop=V.scrollHeight-V.clientHeight,_.current=V.scrollHeight,requestAnimationFrame(()=>{C.current=!1}),E.current!==null&&clearTimeout(E.current),E.current=setTimeout(()=>{E.current=null,S.current&&(C.current=!0,V.scrollTop=V.scrollHeight-V.clientHeight,_.current=V.scrollHeight,requestAnimationFrame(()=>{C.current=!1}))},50)},[]),B=h.useMemo(()=>dh(n,{markdown:x,activeToolApproval:v}),[n,x,v]),L=h.useMemo(()=>gA(B),[B]),U=h.useCallback(()=>{M(V=>!V)},[]),$=h.useCallback(()=>{var ge;if(C.current)return;const V=(ge=y.current)==null?void 0:ge.parentElement;if(!V)return;const F=100,X=V.scrollHeight-V.scrollTop-V.clientHeight;S.current=X<F},[]);return h.useEffect(()=>{var F;const V=(F=y.current)==null?void 0:F.parentElement;if(V)return V.addEventListener("scroll",$),()=>{V.removeEventListener("scroll",$)}},[$]),h.useEffect(()=>{var ge;const V=(ge=y.current)==null?void 0:ge.parentElement;if(!V)return;const F=V;_.current=F.scrollHeight;const X=new ResizeObserver(()=>{const ee=F.scrollHeight;ee>_.current&&S.current?O(F):_.current=ee});return y.current&&X.observe(y.current),()=>{X.disconnect(),E.current!==null&&clearTimeout(E.current)}},[O]),h.useEffect(()=>{var V;if(u>0){S.current=!0;const F=(V=y.current)==null?void 0:V.parentElement;F&&O(F)}},[u,O]),h.useEffect(()=>{var V;if(w.current&&B.length>0){const F=(V=y.current)==null?void 0:V.parentElement;F&&O(F),w.current=!1}},[B.length,O]),a.jsxs("div",{className:"message-list",ref:y,children:[L.map(V=>{if(V.isUserPrompt){const X=V.items[0];return X?a.jsx(Of,{item:X,isStreaming:r,thinkingExpanded:k,toggleThinkingExpanded:U},X.id):null}const F=V.items[0];return F?a.jsx("div",{className:"assistant-turn",children:V.items.map(X=>a.jsx(Of,{item:X,isStreaming:r,thinkingExpanded:k,toggleThinkingExpanded:U},X.id))},`turn-${F.id}`):null}),d.map(V=>a.jsxs("div",{className:"pending-message",children:[a.jsx("div",{className:"message-user-prompt pending-message-bubble",children:V.content}),a.jsx("div",{className:"pending-message-status",children:"Sending..."})]},V.tempId)),f.map((V,F)=>a.jsxs("div",{className:"deferred-message",children:[a.jsx("div",{className:"message-user-prompt deferred-message-bubble",children:V.content}),a.jsxs("div",{className:"deferred-message-footer",children:[a.jsx("span",{className:"deferred-message-status",children:F===0?"Queued (next)":`Queued (#${F+1})`}),V.tempId&&p&&a.jsx("button",{type:"button",className:"deferred-message-cancel",onClick:()=>p(V.tempId),"aria-label":"Cancel queued message",children:"×"})]})]},V.tempId??`deferred-${F}`)),l&&a.jsxs("div",{className:"system-message system-message-compacting",children:[a.jsx("span",{className:"system-message-icon spinning",children:"⟳"}),a.jsx("span",{className:"system-message-text",children:"Compacting context..."})]}),a.jsx(c4,{isProcessing:o})]})});function $b(){const[e,n]=h.useState({connected:ln.connected,connectionState:Jn.state});return h.useEffect(()=>Jn.on("stateChange",o=>{n({connected:o==="connected",connectionState:o})}),[]),e}function vA(e){return e?e>=1e3?`${Math.round(e/1e3)}K tokens`:`${e} tokens`:"Disabled"}function bA(e){const n=new Date(e),o=new Date().getTime()-n.getTime(),l=Math.floor(o/1e3),u=Math.floor(l/60),d=Math.floor(u/60),f=Math.floor(d/24);return f>0?`${f}d ${d%24}h`:d>0?`${d}h ${u%60}m`:u>0?`${u}m ${l%60}s`:`${l}s`}function pf(e){return new Date(e).toLocaleString()}function yA(e){if(!e)return"Never";const n=Math.floor((Date.now()-e)/1e3);if(n<5)return"Just now";if(n<60)return`${n}s ago`;const r=Math.floor(n/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ${r%60}m ago`}function wn({label:e,value:n,mono:r=!1}){return n==null?null:a.jsxs("div",{className:"process-info-row",children:[a.jsx("span",{className:"process-info-label",children:e}),a.jsx("span",{className:`process-info-value ${r?"mono":""}`,children:n})]})}function To({title:e,children:n}){return a.jsxs("div",{className:"process-info-section",children:[a.jsx("h3",{className:"process-info-section-title",children:e}),n]})}function SA({sessionId:e,provider:n,model:r,status:o,processState:l,contextUsage:u,sessionStreamConnected:d,lastSessionEventAt:f,onClose:p}){const[x,v]=h.useState(null),[y,S]=h.useState(!1),[w,C]=h.useState(null),{connected:_,connectionState:E}=$b();h.useEffect(()=>{o.owner==="self"&&(S(!0),C(null),Ae.getProcessInfo(e).then(O=>{v(O.process)}).catch(O=>{C(O.message||"Failed to fetch process info")}).finally(()=>{S(!1)}))},[e,o.owner]);const k=O=>O.split("-").map(B=>B.charAt(0).toUpperCase()+B.slice(1)).join(" "),M=O=>{switch(O){case"claude":return"Claude (Anthropic)";case"codex":return"Codex (OpenAI)";case"codex-oss":return"Codex OSS (Local)";case"gemini":return"Gemini (Google)";case"opencode":return"OpenCode";default:return O}};return a.jsx(os,{title:"Session Info",onClose:p,children:a.jsxs("div",{className:"process-info-content",children:[a.jsxs(To,{title:"Session",children:[a.jsx(wn,{label:"Session ID",value:e,mono:!0}),a.jsx(wn,{label:"Provider",value:M(n)}),a.jsx(wn,{label:"Model",value:r||"Default",mono:!0}),a.jsx(wn,{label:"Ownership",value:k(o.owner)}),a.jsx(wn,{label:"Activity",value:k(l)})]}),a.jsxs(To,{title:"Connection",children:[a.jsx(wn,{label:"Activity stream",value:_?"Connected":"Disconnected"}),a.jsx(wn,{label:"Connection state",value:E}),a.jsx(wn,{label:"Session stream",value:o.owner==="self"?d?"Connected":"Disconnected":"Not subscribed"}),o.owner==="self"&&f&&a.jsx(wn,{label:"Last session event",value:yA(new Date(f).getTime())})]}),u&&a.jsxs(To,{title:"Token Usage",children:[a.jsx(wn,{label:"Input tokens",value:u.inputTokens.toLocaleString()}),u.outputTokens!==void 0&&a.jsx(wn,{label:"Output tokens",value:u.outputTokens.toLocaleString()}),a.jsx(wn,{label:"Context used",value:`${u.percentage.toFixed(1)}%`}),u.cacheReadTokens!==void 0&&a.jsx(wn,{label:"Cache read",value:u.cacheReadTokens.toLocaleString()}),u.cacheCreationTokens!==void 0&&a.jsx(wn,{label:"Cache created",value:u.cacheCreationTokens.toLocaleString()})]}),a.jsx(To,{title:"Process",children:o.owner==="self"?a.jsxs(a.Fragment,{children:[y&&a.jsx("div",{className:"process-info-loading",children:"Loading..."}),w&&a.jsx("div",{className:"process-info-error",children:w}),x&&a.jsxs(a.Fragment,{children:[a.jsx(wn,{label:"Process ID",value:x.id,mono:!0}),a.jsx(wn,{label:"Started",value:pf(x.startedAt)}),a.jsx(wn,{label:"Uptime",value:bA(x.startedAt)}),a.jsx(wn,{label:"Queue depth",value:x.queueDepth}),a.jsx(wn,{label:"Extended thinking",value:vA(x.maxThinkingTokens)}),x.idleSince&&a.jsx(wn,{label:"Idle since",value:pf(x.idleSince)}),x.holdSince&&a.jsx(wn,{label:"Hold since",value:pf(x.holdSince)})]}),!y&&!x&&!w&&a.jsx("div",{className:"process-info-loading",children:"No process data"})]}):o.owner==="external"?a.jsx("div",{className:"process-info-muted",children:"Session controlled by external process (VS Code, CLI)"}):a.jsx("div",{className:"process-info-muted",children:"No active process"})}),x&&a.jsxs(To,{title:"Project",children:[a.jsx(wn,{label:"Name",value:x.projectName}),a.jsx(wn,{label:"Path",value:x.projectPath,mono:!0}),a.jsx(wn,{label:"Remote host",value:x.executor,mono:!0})]})]})})}const jA={claude:"var(--provider-claude)",codex:"var(--provider-codex)","codex-oss":"var(--provider-codex)",gemini:"var(--provider-gemini)","gemini-acp":"var(--provider-gemini)",opencode:"var(--provider-opencode)"},wA={claude:"Claude",codex:"Codex","codex-oss":"CodexOSS",gemini:"Gemini","gemini-acp":"Gemini ACP",opencode:"OpenCode"};function NA({provider:e,compact:n=!1,model:r,isThinking:o=!1,className:l=""}){const u=jA[e],d=wA[e],p=(y=>{if(!y||y==="default")return null;const S=kf.find(C=>C.value===y);if(S&&S.value!=="default")return S.label;const w=y.match(/claude-(\w+)-/);if(w!=null&&w[1]){const C=w[1],_=kf.find(E=>E.value===C);return _?_.label:C.charAt(0).toUpperCase()+C.slice(1)}return y.charAt(0).toUpperCase()+y.slice(1)})(r);if(n)return a.jsx("span",{className:`provider-badge-stripe ${l}`,style:{backgroundColor:u},title:p?`${d} (${p})`:d,"aria-label":`Provider: ${d}${p?` (${p})`:""}`});const x=o?"provider-badge-dot-inline thinking":"provider-badge-dot-inline",v=o?{backgroundColor:"var(--thinking-color)"}:{backgroundColor:u};return a.jsxs("span",{className:`provider-badge ${l}`,style:{borderColor:u,color:u},children:[a.jsx("span",{className:x,style:v}),a.jsx("span",{className:"provider-badge-label",children:d}),p&&a.jsx("span",{className:"provider-badge-model",children:p})]})}const Pb="draft-tool-prompt-";function _A(e){const n=`${Pb}${e}-toolApprovalFeedback`,[r,o]=h.useState(()=>{try{return localStorage.getItem(n)??""}catch{return""}}),l=h.useCallback(d=>{o(d);try{d?localStorage.setItem(n,d):localStorage.removeItem(n)}catch{}},[n]),u=h.useCallback(()=>{o("");try{localStorage.removeItem(n)}catch{}},[n]);return[r,l,u]}function EA(e){const n=`${Pb}${e}-questionOther`,[r,o]=h.useState(()=>{try{const d=localStorage.getItem(n);return d?JSON.parse(d):{}}catch{return{}}}),l=h.useCallback((d,f)=>{o(p=>{const x={...p};f?x[d]=f:delete x[d];try{Object.keys(x).length>0?localStorage.setItem(n,JSON.stringify(x)):localStorage.removeItem(n)}catch{}return x})},[n]),u=h.useCallback(()=>{o({});try{localStorage.removeItem(n)}catch{}},[n]);return[r,l,u]}function CA({request:e,sessionId:n,onSubmit:r,onDeny:o}){const l=e.toolInput,u=(l==null?void 0:l.questions)||[],[d,f]=h.useState(0),[p,x]=h.useState({}),[v,y,S]=EA(n),[w,C]=h.useState(!1),[_,E]=h.useState(!1),k=h.useRef(null),M=u[d],O=d===u.length-1,B=M?p[M.question]:void 0,L=B==="__other__",U=u.every(ee=>{const ne=p[ee.question];return ne?ne==="__other__"?(v[ee.question]||"").trim().length>0:!0:!1});h.useEffect(()=>{L&&k.current&&(k.current.focus(),setTimeout(()=>{var ee;(ee=k.current)==null||ee.scrollIntoView({behavior:"smooth",block:"center"})},100))},[L]);const $=h.useCallback(ee=>{M&&x(ne=>({...ne,[M.question]:ee}))},[M]),V=h.useCallback(ee=>{M&&y(M.question,ee)},[M,y]),F=h.useCallback(()=>{O||f(ee=>ee+1)},[O]),X=h.useCallback(async()=>{if(!U||w)return;const ee={};for(const ne of u){const Ne=p[ne.question];Ne==="__other__"?ee[ne.question]=v[ne.question]||"":Ne&&(ee[ne.question]=Ne)}C(!0);try{await r(ee),S()}finally{C(!1)}},[U,w,u,p,v,r,S]),ge=h.useCallback(async()=>{C(!0);try{await o()}finally{C(!1)}},[o]);return h.useEffect(()=>{const ee=ne=>{if(!w){if(ne.key==="Escape"){ne.preventDefault(),ge();return}if(ne.key==="Enter"&&!ne.shiftKey){const Ne=B&&B!=="__other__",ke=B==="__other__"&&(v[(M==null?void 0:M.question)||""]||"").trim().length>0;(Ne||ke)&&(ne.preventDefault(),O&&U?X():F())}ne.key==="Tab"&&!L&&(ne.preventDefault(),ne.shiftKey?f(Ne=>Math.max(0,Ne-1)):f(Ne=>Math.min(u.length-1,Ne+1)))}};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[w,B,M,v,O,U,L,u.length,ge,X,F]),u.length?a.jsxs("div",{className:"question-panel-wrapper",children:[a.jsx("button",{type:"button",className:"question-panel-toggle",onClick:()=>E(!_),"aria-label":_?"Expand question panel":"Collapse question panel","aria-expanded":!_,children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:_?"chevron-up":"chevron-down","aria-hidden":"true",children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})}),!_&&a.jsxs("div",{className:"question-panel",children:[a.jsx("div",{className:"question-tabs",children:u.map((ee,ne)=>{const Ne=ne===d,ke=!!p[ee.question];return a.jsxs("button",{type:"button",className:`question-tab ${Ne?"active":""} ${ke?"answered":""}`,onClick:()=>f(ne),children:[ke&&a.jsx("span",{className:"question-tab-check",children:"✓"}),ee.header]},ee.question)})}),M&&a.jsxs("div",{className:"question-content",children:[a.jsx("div",{className:"question-text",children:M.question}),a.jsxs("div",{className:"question-options-list",children:[M.options.map(ee=>{const ne=B===ee.label;return a.jsxs("button",{type:"button",className:`question-option-btn ${ne?"selected":""}`,onClick:()=>$(ee.label),children:[a.jsx("span",{className:"question-option-radio",children:M.multiSelect?ne?"☑":"☐":ne?"●":"○"}),a.jsxs("div",{className:"question-option-text",children:[a.jsx("span",{className:"question-option-label",children:ee.label}),ee.description&&a.jsx("span",{className:"question-option-desc",children:ee.description})]})]},ee.label)}),a.jsxs("button",{type:"button",className:`question-option-btn other ${L?"selected":""}`,onClick:()=>$("__other__"),children:[a.jsx("span",{className:"question-option-radio",children:L?"●":"○"}),a.jsx("div",{className:"question-option-text",children:a.jsx("span",{className:"question-option-label",children:"Other"})})]}),L&&a.jsx("div",{className:"question-other-input",children:a.jsx("input",{ref:k,type:"text",placeholder:"Type your answer...",value:v[M.question]||"",onChange:ee=>V(ee.target.value)})})]})]}),a.jsxs("div",{className:"question-actions",children:[a.jsxs("button",{type:"button",className:"question-btn deny",onClick:ge,disabled:w,children:["Cancel",a.jsx("kbd",{children:"esc"})]}),O?a.jsxs("button",{type:"button",className:"question-btn submit",onClick:X,disabled:!U||w,children:["Submit",a.jsx("kbd",{children:"↵"})]}):a.jsxs("button",{type:"button",className:"question-btn next",onClick:F,disabled:!B||w,children:["Next",a.jsx("kbd",{children:"↵"})]})]})]})]}):a.jsx("div",{className:"question-panel-wrapper",children:a.jsx("div",{className:"question-panel",children:a.jsx("div",{className:"question-panel-empty",children:"No questions to answer"})})})}const Tv=10;function kA(e){const n=Date.now(),r=new Date(e).getTime(),o=n-r,l=Math.floor(o/6e4),u=Math.floor(o/36e5),d=Math.floor(o/864e5);return l<1?"now":l<60?`${l}m`:u<24?`${u}h`:d<7?`${d}d`:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function TA(e){return e.customTitle||e.title||"Untitled"}function RA({session:e}){if(e.activity==="in-turn")return a.jsx(Tr,{});if(e.pendingInputType){const r=e.pendingInputType==="tool-approval"?"Appr":"Q";return a.jsx("span",{className:"recent-sessions-badge needs-input",children:r})}return e.ownership.owner==="external"?a.jsx("span",{className:"recent-sessions-badge external",children:"Ext"}):null}function AA({currentSessionId:e,isOpen:n,onClose:r,onNavigate:o,triggerRef:l,basePath:u=""}){var S;const d=h.useRef(null),{sessions:f}=Ec({limit:Tv+5}),p=f.filter(w=>w.id!==e&&!w.isArchived).slice(0,Tv);if(h.useEffect(()=>{if(!n)return;const w=_=>{const E=_.target;d.current&&!d.current.contains(E)&&l.current&&!l.current.contains(E)&&r()},C=_=>{_.key==="Escape"&&r()};return document.addEventListener("mousedown",w),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",C)}},[n,r,l]),h.useEffect(()=>{if(!n)return;const w=()=>r();return window.addEventListener("scroll",w,{passive:!0}),()=>window.removeEventListener("scroll",w)},[n,r]),!n)return null;const x=(S=l.current)==null?void 0:S.getBoundingClientRect(),v=x?{position:"fixed",top:x.bottom+4,left:Math.max(8,x.left-100),width:"min(830px, calc(100vw - 32px))"}:{},y=a.jsxs("div",{ref:d,className:"recent-sessions-dropdown",style:v,children:[a.jsx("div",{className:"recent-sessions-header",children:"Recent Sessions"}),p.length===0?a.jsx("div",{className:"recent-sessions-empty",children:"No other sessions"}):a.jsx("div",{className:"recent-sessions-list",children:p.map(w=>a.jsxs(Vs,{to:`${u}/projects/${w.projectId}/sessions/${w.id}`,className:`recent-session-item${w.hasUnread?" unread":""}`,onClick:()=>{o(w.id,w.projectId),r()},children:[a.jsxs("div",{className:"recent-session-content",children:[a.jsxs("span",{className:"recent-session-title",children:[w.isStarred&&a.jsx("svg",{className:"recent-session-star",width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),a.jsx("span",{className:"recent-session-title-text",children:TA(w)})]}),a.jsx("span",{className:"recent-session-project",children:w.projectName})]}),a.jsxs("div",{className:"recent-session-meta",children:[a.jsx(RA,{session:w}),a.jsx("span",{className:"recent-session-time",children:kA(w.updatedAt)})]})]},w.id))})]});return ki.createPortal(y,document.body)}const MA=["Edit","Write","NotebookEdit"],gf=e=>e==="ExitPlanMode",OA=150;function zA({request:e,sessionId:n,onApprove:r,onDeny:o,onApproveAcceptEdits:l,onDenyWithFeedback:u,collapsed:d=!1,onCollapsedChange:f}){const[p,x]=h.useState(!1),[v,y]=h.useState(!1),[S,w,C]=_A(n),[_,E]=h.useState(()=>S.length>0),k=h.useRef(null);h.useEffect(()=>{y(!1);const V=setTimeout(()=>y(!0),OA);return()=>clearTimeout(V)},[e.id]);const M=e.toolName&&MA.includes(e.toolName),O=h.useCallback(async()=>{x(!0);try{await r()}finally{x(!1)}},[r]),B=h.useCallback(async()=>{if(l){x(!0);try{await l()}finally{x(!1)}}},[l]),L=h.useCallback(async()=>{x(!0);try{await o()}finally{x(!1)}},[o]),U=h.useCallback(async()=>{if(!(!u||!S.trim())){x(!0);try{await u(S.trim()),C(),E(!1)}finally{x(!1)}}},[u,S,C]);h.useEffect(()=>{_&&k.current&&k.current.focus()},[_]),h.useEffect(()=>{const V=F=>{if(p||!v)return;if(_){F.key==="Escape"?(F.preventDefault(),E(!1),C()):F.key==="Enter"&&S.trim()&&(F.preventDefault(),U());return}gf(e.toolName)?F.key==="1"&&l?(F.preventDefault(),B()):F.key==="2"?(F.preventDefault(),O()):F.key==="3"?(F.preventDefault(),L()):F.key==="Enter"&&!F.shiftKey&&l?(F.preventDefault(),B()):F.key==="Escape"&&(F.preventDefault(),L()):F.key==="1"?(F.preventDefault(),O()):F.key==="2"&&M&&l?(F.preventDefault(),B()):F.key==="3"||F.key==="2"&&(!M||!l)?(F.preventDefault(),L()):F.key==="Enter"&&!F.shiftKey?(F.preventDefault(),O()):F.key==="Escape"&&(F.preventDefault(),L())};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[O,B,L,U,p,v,_,S,C,M,l,e.toolName]);const $=e.toolName?Ib(e.toolName,e.toolInput,void 0,"pending"):e.prompt;return a.jsxs("div",{className:"tool-approval-wrapper",children:[a.jsx("button",{type:"button",className:`tool-approval-toggle ${d?"has-pending":""}`,onClick:()=>f==null?void 0:f(!d),"aria-label":d?"Expand approval panel":"Collapse approval panel","aria-expanded":!d,children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:d?"chevron-up":"chevron-down","aria-hidden":"true",children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})}),!d&&a.jsxs("div",{className:"tool-approval-panel",children:[a.jsx("div",{className:"tool-approval-header",children:gf(e.toolName)?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"tool-approval-title",children:"Accept this plan?"}),a.jsx("span",{className:"tool-approval-subtitle",children:"Review the plan above and decide whether to proceed"})]}):a.jsxs("span",{className:"tool-approval-question",children:["Allow"," ",a.jsx("span",{className:"tool-approval-name",children:e.toolName})," ",$,"?"]})}),a.jsxs("div",{className:"tool-approval-options",children:[gf(e.toolName)?a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"tool-approval-option primary",onClick:B,disabled:!v||p||!l,children:[a.jsx("kbd",{children:"1"}),a.jsx("span",{children:"Yes, and auto-accept"})]}),a.jsxs("button",{type:"button",className:"tool-approval-option",onClick:O,disabled:!v||p,children:[a.jsx("kbd",{children:"2"}),a.jsx("span",{children:"Yes, and manually approve edits"})]}),a.jsxs("button",{type:"button",className:"tool-approval-option",onClick:L,disabled:!v||p,children:[a.jsx("kbd",{children:"3"}),a.jsx("span",{children:"No, keep planning"})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"tool-approval-option primary",onClick:O,disabled:!v||p,children:[a.jsx("kbd",{children:"1"}),a.jsx("span",{children:"Yes"})]}),M&&l&&a.jsxs("button",{type:"button",className:"tool-approval-option",onClick:B,disabled:!v||p,children:[a.jsx("kbd",{children:"2"}),a.jsx("span",{children:"Yes, and don't ask again"})]}),a.jsxs("button",{type:"button",className:"tool-approval-option",onClick:L,disabled:!v||p,children:[a.jsx("kbd",{children:M&&l?"3":"2"}),a.jsx("span",{children:"No"})]})]}),u&&!_&&a.jsx("button",{type:"button",className:"tool-approval-option feedback-toggle",onClick:()=>E(!0),disabled:!v||p,children:a.jsx("span",{children:"Tell Claude what to do instead"})}),u&&_&&a.jsxs("div",{className:"tool-approval-feedback",children:[a.jsx("input",{ref:k,type:"text",placeholder:"Tell Claude what to do instead...",value:S,onChange:V=>w(V.target.value),disabled:!v||p,className:"tool-approval-feedback-input"}),a.jsx("button",{type:"button",className:"tool-approval-feedback-submit",onClick:U,disabled:!v||p||!S.trim(),children:"Send"})]})]})]})]})}const LA=3e4,Rv=2e3;function UA(e){const{sessionId:n,activityAt:r,updatedAt:o,lastSeenAt:l,hasUnread:u=!1,enabled:d=!0}=e,f=h.useRef(Date.now()),p=h.useRef(null),x=h.useRef(null),v=h.useRef(!0),y=h.useRef(!0),S=h.useCallback(()=>r?l?r>l||u:!0:!1,[r,l,u]),w=h.useCallback(()=>{const E=document.hasFocus(),k=Date.now()-f.current<LA;return E&&k},[]),C=h.useCallback(()=>{!d||!v.current||!r||!o||p.current!==r&&w()&&S()&&(x.current&&clearTimeout(x.current),x.current=setTimeout(async()=>{if(v.current)try{await Ae.markSessionSeen(n,o),p.current=r}catch(E){console.warn("[useEngagementTracking] Failed to mark session as seen:",E)}},Rv))},[d,n,r,o,w,S]);return h.useEffect(()=>{if(!d)return;const E=()=>{f.current=Date.now(),S()&&w()&&C()},k=["mousemove","keydown","scroll","click","touchstart"];for(const M of k)window.addEventListener(M,E,{passive:!0});return()=>{for(const M of k)window.removeEventListener(M,E)}},[d,S,w,C]),h.useEffect(()=>{if(!d)return;const E=()=>{document.visibilityState==="visible"&&S()&&w()&&C()},k=()=>{f.current=Date.now(),S()&&w()&&C()};return document.addEventListener("visibilitychange",E),window.addEventListener("focus",k),()=>{document.removeEventListener("visibilitychange",E),window.removeEventListener("focus",k)}},[d,S,w,C]),h.useEffect(()=>{d&&(!r||!o||y.current&&(y.current=!1,S()&&(x.current&&clearTimeout(x.current),x.current=setTimeout(async()=>{if(v.current&&p.current!==r)try{await Ae.markSessionSeen(n,o),p.current=r}catch(E){console.warn("[useEngagementTracking] Failed to mark session as seen:",E)}},Rv))))},[d,n,r,o,S]),h.useEffect(()=>(v.current=!0,()=>{v.current=!1,x.current&&clearTimeout(x.current)}),[]),{forceMarkSeen:h.useCallback(async()=>{if(!(!d||!o))try{await Ae.markSessionSeen(n,o),p.current=r}catch(E){console.warn("[useEngagementTracking] Failed to force mark session as seen:",E)}},[d,n,r,o]),isEngaged:w}}function DA(e,n){Ae.recordVisit(e,n).catch(r=>{console.error("Failed to record session visit:",r)})}function BA(e){var o;const n=new Map,r=new Set;for(const l of e){const u=((o=l.message)==null?void 0:o.content)??l.content;if(Array.isArray(u))for(const d of u){if(d.type==="tool_use"&&d.name==="Task"&&typeof d.id=="string"){const f=d.input;n.set(d.id,{description:(f==null?void 0:f.description)??"Unknown task",subagentType:(f==null?void 0:f.subagent_type)??"unknown"})}d.type==="tool_result"&&typeof d.tool_use_id=="string"&&r.add(d.tool_use_id)}}return[...n.entries()].filter(([l])=>!r.has(l)).map(([l,{description:u,subagentType:d}])=>({toolUseId:l,description:u,subagentType:d}))}function IA(e){const n=e.relativePath.split(/[\\/]/).pop();if(!n)return null;let r=n;if(r.endsWith(".jsonl")?r=r.slice(0,-6):r.endsWith(".json")&&(r=r.slice(0,-5)),e.provider==="codex"){const o=r.match(/([0-9a-fA-F-]{36})$/);if(o)return o[1]??null}return r}function $A(e){const{projectId:n,sessionId:r,onLoadComplete:o,onLoadError:l}=e,[u,d]=h.useState([]),[f,p]=h.useState({}),[x,v]=h.useState(()=>new Map),[y,S]=h.useState(!0),[w,C]=h.useState(null),_=h.useRef([]),E=h.useRef(!1),k=h.useRef(void 0),M=h.useRef(void 0);h.useEffect(()=>{const ee=u[u.length-1];ee&&(M.current=Qn(ee))},[u]);const O=h.useCallback(ee=>{d(ne=>OT(ne,ee).messages)},[]),B=h.useCallback((ee,ne)=>{p(Ne=>{const ke=Ne[ne]??{messages:[],status:"running"},D=Qn(ee);return ke.messages.some(q=>Qn(q)===D)?Ne:{...Ne,[ne]:{...ke,messages:[...ke.messages,ee],status:"running"}}})},[]),L=h.useCallback(()=>{const ee=_.current;_.current=[];for(const ne of ee)ne.type==="message"?O(ne.msg):B(ne.msg,ne.agentId)},[O,B]);h.useEffect(()=>{E.current=!1,_.current=[],S(!0),p({}),Ae.getSession(n,r).then(ee=>{C(ee.session),k.current=ee.session.provider;const ne=ee.messages.map(ke=>({...ke,_source:"jsonl"}));d(ne);const Ne=ne[ne.length-1];Ne&&(M.current=Qn(Ne)),E.current=!0,L(),S(!1),o==null||o({session:ee.session,status:ee.ownership,pendingInputRequest:ee.pendingInputRequest})}).catch(ee=>{S(!1),l==null||l(ee)})},[n,r,o,l,L]);const U=h.useCallback((ee,ne)=>{const Ne=Qn(ee);if(Ne){if(ne){p(ke=>{const D=ke[ne]??{messages:[],status:"running"},q=D.messages.findIndex(G=>Qn(G)===Ne);if(q>=0){const G=[...D.messages];return G[q]=ee,{...ke,[ne]:{...D,messages:G}}}return{...ke,[ne]:{...D,messages:[...D.messages,ee]}}});return}d(ke=>{const D=ke.findIndex(q=>Qn(q)===Ne);if(D>=0){const q=[...ke];return q[D]=ee,q}return[...ke,ee]})}},[]),$=h.useCallback(ee=>{if(!E.current){_.current.push({type:"message",msg:ee});return}O(ee)},[O]),V=h.useCallback((ee,ne)=>{if(!E.current){_.current.push({type:"subagent",msg:ee,agentId:ne});return}B(ee,ne)},[B]),F=h.useCallback((ee,ne)=>{v(Ne=>{if(Ne.has(ee))return Ne;const ke=new Map(Ne);return ke.set(ee,ne),ke})},[]),X=h.useCallback(async()=>{try{const ee=await Ae.getSession(n,r,M.current);ee.messages.length>0&&d(ne=>MT(ne,ee.messages,{skipDagOrdering:!gb(ee.session.provider).capabilities.supportsDag}).messages),C(ne=>ne?{...ne,...ee.session,messages:ne.messages}:ee.session)}catch{}},[n,r]),ge=h.useCallback(async()=>{try{const ee=await Ae.getSessionMetadata(n,r);C(ne=>ne?{...ne,...ee.session,messages:ne.messages}:{...ee.session,messages:[]})}catch{}},[n,r]);return{messages:u,agentContent:f,toolUseToAgent:x,loading:y,session:w,setSession:C,handleStreamingUpdate:U,handleStreamMessageEvent:$,handleStreamSubagentMessage:V,registerToolUseAgent:F,setAgentContent:p,setToolUseToAgent:v,setMessages:d,fetchNewMessages:X,fetchSessionMetadata:ge}}function PA(e,n){const[r,o]=h.useState(!1),l=h.useRef(null),u=h.useRef(null),d=h.useRef(n);d.current=n;const f=h.useRef(null),p=h.useRef(!1),x=h.useCallback(()=>{if(!e){f.current=null;return}l.current||f.current!==e&&(f.current=e,v(e,vc()))},[e]),v=h.useCallback((y,S)=>{if(l.current){const E=l.current;l.current=null,E.close()}let w=null;const C=()=>w!==null&&l.current!==w,_={onEvent:(E,k,M)=>{if(Jn.recordEvent(),E==="heartbeat"){Jn.recordHeartbeat();return}k&&(u.current=k),d.current.onMessage({...M,eventType:E})},onOpen:()=>{var E,k;C()||(o(!0),Jn.markConnected(),(k=(E=d.current).onOpen)==null||k.call(E))},onError:E=>{var k,M;if(!C()){if(o(!1),l.current=null,f.current=null,(M=(k=d.current).onError)==null||M.call(k,new Event("error")),xc(E)){console.warn("[useSessionStream] Non-retryable error, not reconnecting:",E.message);return}Jn.handleError(E)}},onClose:()=>{p.current||C()||(o(!1),l.current=null,f.current=null)}};w=S.subscribeSession(y,_,u.current??void 0),l.current=w},[]);return h.useEffect(()=>Jn.on("stateChange",y=>{if(y==="reconnecting"||y==="disconnected"){if(l.current){const S=l.current;l.current=null,S.close()}o(!1),f.current=null}y==="connected"&&e&&!l.current&&x()}),[e,x]),h.useEffect(()=>(x(),()=>{var y;p.current=!0,(y=l.current)==null||y.close(),l.current=null,f.current=null,p.current=!1}),[x]),{connected:r}}function Hb(){const e=localStorage.getItem(is.streamingEnabled);return e===null?!0:e==="true"}function HA(e){localStorage.setItem(is.streamingEnabled,String(e))}function FA(){const[e,n]=h.useState(Hb),r=h.useCallback(o=>{n(o),HA(o)},[]);return{streamingEnabled:e,setStreamingEnabled:r}}function qA(){return Hb()}const ZA=50;function VA(e){const{onUpdateMessage:n,streamingMarkdownCallbacks:r,onToolUseMapping:o,onAgentContextUsage:l}=e,u=h.useRef(new Map),d=h.useRef(null),f=h.useRef(null),p=h.useRef({timer:null,pendingIds:new Set}),x=h.useCallback(_=>{const E=u.current.get(_);if(!E)return;const k={id:_,type:"assistant",role:"assistant",message:{role:"assistant",content:E.blocks},_isStreaming:!0,_source:"sdk"};n(k,E.agentId)},[n]),v=h.useCallback(_=>{const E=p.current;E.pendingIds.add(_),E.timer||(E.timer=setTimeout(()=>{for(const k of E.pendingIds)x(k);E.pendingIds.clear(),E.timer=null},ZA))},[x]),y=h.useCallback(_=>{var $,V;if(_.type!=="stream_event"||!qA())return!1;const k=_.event;if(!k)return!0;const M=k.type,B=_.isSubagent&&typeof _.parentToolUseId=="string"?_.parentToolUseId:void 0;if(B&&o&&o(B,B),M==="message_start"){const F=k.message;if(F!=null&&F.id&&(d.current=F.id,f.current=B??null,($=r==null?void 0:r.setCurrentMessageId)==null||$.call(r,F.id),B&&l)){const X=F.usage;if(X!=null&&X.input_tokens){const ge=X.input_tokens,ee=ge/2e5*100;l(B,{inputTokens:ge,percentage:ee})}}return!0}const L=d.current??`stream-${Date.now()}`,U=f.current??B;if(M==="content_block_start"){const F=k.index,X=k.content_block;if(X){const ge=u.current.get(L)??{blocks:[],isStreaming:!0,agentId:U};for(;ge.blocks.length<=F;)ge.blocks.push({type:"text",text:""});ge.blocks[F]={type:X.type??"text",text:X.text??"",thinking:X.thinking??void 0},u.current.set(L,ge),x(L)}}else if(M==="content_block_delta"){const F=k.index,X=k.delta;if(X){const ge=u.current.get(L);if(ge!=null&&ge.blocks[F]){const ee=ge.blocks[F],ne=X.type;ne==="text_delta"&&X.text?ee.text=(ee.text??"")+X.text:ne==="thinking_delta"&&X.thinking&&(ee.thinking=(ee.thinking??"")+X.thinking),v(L)}}}else M==="content_block_stop"||M==="message_stop"&&(u.current.delete(L),(V=r==null?void 0:r.onStreamEnd)==null||V.call(r));return!0},[x,v,r,o,l]),S=h.useCallback(()=>{u.current.clear(),d.current=null,f.current=null},[]),w=h.useCallback(()=>f.current,[]),C=h.useCallback(()=>{p.current.timer&&(clearTimeout(p.current.timer),p.current.timer=null)},[]);return{handleStreamEvent:y,clearStreaming:S,cleanup:C,getCurrentAgentId:w}}const GA=500;function YA(e,n,r,o){const[l,u]=h.useState(r??{owner:"none"}),[d,f]=h.useState(r?"in-turn":"idle"),[p,x]=h.useState(null),[v,y]=h.useState(null),[S,w]=h.useState(n),[C,_]=h.useState(null),[E,k]=h.useState([]),[M,O]=h.useState([]),[B,L]=h.useState(!1),[U,$]=h.useState({}),[V,F]=h.useState("default"),[X,ge]=h.useState("default"),[ee,ne]=h.useState(0),[Ne,ke]=h.useState([]),[D,q]=h.useState([]),[G,Se]=h.useState([]),Me=h.useRef(0),I=h.useCallback((Oe,vt)=>{vt>=Me.current&&(Me.current=vt,ge(Oe),F(Oe),ne(vt))},[]),re=h.useCallback(Oe=>{u(vt=>vt.owner==="self"&&Oe.status.owner!=="self"?vt:Oe.status),Oe.status.owner==="self"&&Oe.status.permissionMode&&Oe.status.modeVersion!==void 0&&I(Oe.status.permissionMode,Oe.status.modeVersion),Oe.pendingInputRequest&&x(Oe.pendingInputRequest)},[I]),he=h.useCallback(Oe=>{y(Oe)},[]),{messages:oe,agentContent:Ee,toolUseToAgent:Te,loading:We,session:Ie,setSession:je,handleStreamingUpdate:Ze,handleStreamMessageEvent:yt,handleStreamSubagentMessage:be,registerToolUseAgent:St,setAgentContent:_e,setToolUseToAgent:mt,setMessages:pt,fetchNewMessages:Lt}=$A({projectId:e,sessionId:n,onLoadComplete:re,onLoadError:he}),cn=h.useCallback(async Oe=>{if(F(Oe),l.owner==="self"||l.owner==="external")try{const vt=await Ae.setPermissionMode(n,Oe);vt.modeVersion>=Me.current&&(Me.current=vt.modeVersion,ge(vt.permissionMode),ne(vt.modeVersion))}catch(vt){console.warn("Failed to sync permission mode:",vt)}},[n,l.owner]),un=h.useCallback(async Oe=>{if(l.owner!=="self"&&l.owner!=="external"){console.warn("Cannot set hold: no active process");return}try{const vt=await Ae.setHold(n,Oe);vt.state==="hold"?f("hold"):vt.state==="in-turn"&&f("in-turn")}catch(vt){console.warn("Failed to set hold:",vt)}},[n,l.owner]),dn=h.useRef({timer:null,pending:!1}),fn=h.useCallback(Oe=>{const vt=`temp-${Date.now()}`;return k(gn=>[...gn,{tempId:vt,content:Oe,timestamp:new Date().toISOString()}]),vt},[]),Z=h.useCallback(Oe=>{k(vt=>vt.filter(gn=>gn.tempId!==Oe))},[]),xe=h.useRef(null);h.useEffect(()=>{if(We||xe.current===n||oe.length===0)return;(async()=>{xe.current=n;const vt=BA(oe);if(vt.length!==0)try{const{mappings:gn}=await Ae.getAgentMappings(e,n),Gn=new Map(gn.map(ze=>[ze.toolUseId,ze.agentId]));mt(ze=>{const Ft=new Map(ze);for(const[mn,Xt]of Gn)Ft.has(mn)||Ft.set(mn,Xt);return Ft});for(const ze of vt){const Ft=Gn.get(ze.toolUseId);if(Ft)try{const mn=await Ae.getAgentSession(e,n,Ft);_e(Xt=>{const Tt=Xt[Ft];if(Tt&&Tt.messages.length>0){const bs=new Set(Tt.messages.map(ts=>Qn(ts))),ls=mn.messages.filter(ts=>!bs.has(Qn(ts)));return{...Xt,[Ft]:{messages:[...Tt.messages,...ls],status:mn.status}}}return{...Xt,[Ft]:mn}})}catch{}}}catch{}})()},[We,oe,e,n,_e,mt]);const Be=h.useCallback(()=>{const Oe=dn.current;Oe.timer?Oe.pending=!0:(Lt(),Oe.timer=setTimeout(()=>{Oe.timer=null,Oe.pending&&(Oe.pending=!1,Be())},GA))},[Lt]),st=h.useCallback(Oe=>{Oe.fileType!=="session"&&Oe.fileType!=="agent-session"||IA(Oe)!==n||l.owner!=="self"&&Be()},[n,l.owner,Be]),kt=h.useCallback(Oe=>{Oe.sessionId===n&&je(vt=>vt&&{...vt,...Oe.title!==void 0&&{title:Oe.title},...Oe.messageCount!==void 0&&{messageCount:Oe.messageCount},...Oe.updatedAt!==void 0&&{updatedAt:Oe.updatedAt},...Oe.contextUsage!==void 0&&{contextUsage:Oe.contextUsage},...Oe.model!==void 0&&{model:Oe.model}})},[n,je]),Et=h.useCallback(Oe=>{Oe.sessionId===n&&u(Oe.ownership)},[n]),an=h.useCallback(async Oe=>{Oe.sessionId===n&&((Oe.activity==="idle"||Oe.activity==="in-turn"||Oe.activity==="waiting-input"||Oe.activity==="hold")&&f(Oe.activity),Oe.activity==="waiting-input"&&Oe.pendingInputType&&x(vt=>vt||(Ae.getSessionMetadata(e,n).then(gn=>{gn.pendingInputRequest&&x(gn.pendingInputRequest)}),vt)))},[e,n]),fs=h.useCallback(async()=>{Lt();try{const Oe=await Ae.getSessionMetadata(e,n);u(Oe.ownership),Oe.ownership.owner==="none"&&(f("idle"),x(null))}catch{}},[e,n,Lt]);Ai({onSessionStatusChange:Et,onFileChange:st,onSessionUpdated:kt,onProcessStateChange:an,onReconnect:fs}),h.useEffect(()=>()=>{dn.current.timer&&clearTimeout(dn.current.timer)},[]);const hs=h.useCallback((Oe,vt)=>{_e(gn=>{const Gn=gn[Oe]??{messages:[],status:"running"};return{...gn,[Oe]:{...Gn,contextUsage:vt}}})},[_e]),{handleStreamEvent:gt,clearStreaming:Bt,cleanup:Rn}=VA({onUpdateMessage:Ze,onToolUseMapping:St,onAgentContextUsage:hs,streamingMarkdownCallbacks:o});h.useEffect(()=>()=>{Rn()},[Rn]);const Ht=h.useCallback(Oe=>{var vt,gn,Gn;if(Oe.eventType==="message"){_(new Date().toISOString());const ze=Oe,Ft=ze.uuid,mn=ze.id,Xt=(typeof Ft=="string"?Ft:null)??(typeof mn=="string"?mn:null)??`msg-${Date.now()}`,Tt=typeof ze.type=="string"?ze.type:void 0,bs=ze.role;if(Tt==="stream_event"&>(ze))return;if(Tt==="assistant"){const ar=ze.isSubagent&&typeof ze.parentToolUseId=="string"?ze.parentToolUseId:void 0;Bt(),ar?_e(pn=>{const Un=pn[ar];if(!Un)return pn;const N=Un.messages.filter(R=>!R._isStreaming);return N.length===Un.messages.length?pn:{...pn,[ar]:{...Un,messages:N}}}):pt(pn=>pn.filter(Un=>!Un._isStreaming))}const ls={...ze,id:Xt,type:Tt,role:bs??(Tt==="user"||Tt==="assistant"?Tt:void 0)};if(ls.eventType=void 0,Tt==="system"&&ze.subtype==="init"&&(Array.isArray(ze.slash_commands)&&ke(ze.slash_commands),Array.isArray(ze.tools)&&q(ze.tools),Array.isArray(ze.mcp_servers)&&Se(ze.mcp_servers)),Tt==="system"&&ze.subtype==="status"){const Yn=ze.status;L(Yn==="compacting");return}Tt==="system"&&ze.subtype==="compact_boundary"&&L(!1);const ts=ze.tempId;if(Tt==="user"&&ts&&Z(ts),ze.isSubagent&&typeof ze.parentToolUseId=="string"){const Yn=ze.parentToolUseId;St(Yn,Yn),be(ls,Yn);return}yt(ls)}else if(Oe.eventType==="status"){const ze=Oe;(ze.state==="idle"||ze.state==="in-turn"||ze.state==="waiting-input"||ze.state==="hold")&&f(ze.state),ze.state==="waiting-input"&&ze.request?(x(ze.request),ze.request.sessionId&&ze.request.sessionId!==n&&w(ze.request.sessionId)):x(null)}else if(Oe.eventType==="deferred-queue")O(Oe.messages??[]);else if(Oe.eventType==="complete")f("idle"),u({owner:"none"}),x(null),O([]);else if(Oe.eventType==="connected"){const ze=Oe,Ft=ze.sessionId??((vt=ze.request)==null?void 0:vt.sessionId);Ft&&Ft!==n&&w(Ft),(ze.state==="idle"||ze.state==="in-turn"||ze.state==="waiting-input"||ze.state==="hold")&&f(ze.state),ze.state==="waiting-input"&&ze.request?x(ze.request):x(null),ze.permissionMode&&ze.modeVersion!==void 0&&I(ze.permissionMode,ze.modeVersion);const mn=ze.provider,Xt=ze.model;mn&&je(Tt=>Tt&&{...Tt,provider:Tt.provider||mn,...Xt&&{model:Xt}}),O(ze.deferredMessages??[]),Lt()}else if(Oe.eventType==="mode-change"){const ze=Oe;ze.permissionMode&&ze.modeVersion!==void 0&&I(ze.permissionMode,ze.modeVersion)}else if(Oe.eventType==="markdown-augment"){const ze=Oe;ze.messageId&&ze.blockIndex===void 0&&ze.html?$(Ft=>({...Ft,[ze.messageId]:{html:ze.html}})):ze.blockIndex!==void 0&&((gn=o==null?void 0:o.onAugment)==null||gn.call(o,{blockIndex:ze.blockIndex,html:ze.html,type:ze.type??"text",messageId:ze.messageId}))}else if(Oe.eventType==="pending"){const ze=Oe;(Gn=o==null?void 0:o.onPending)==null||Gn.call(o,{html:ze.html})}else if(Oe.eventType==="session-id-changed"){const ze=Oe;ze.newSessionId&&ze.newSessionId!==n&&(w(ze.newSessionId),x(Ft=>Ft&&Ft.sessionId===ze.oldSessionId?{...Ft,sessionId:ze.newSessionId}:Ft))}},[I,n,gt,Bt,Z,o,yt,be,St,_e,pt,je,Lt]),hn=h.useCallback(async()=>{try{(await Ae.getSessionMetadata(e,n)).ownership.owner!=="self"&&(u({owner:"none"}),f("idle"))}catch{u({owner:"none"}),f("idle")}},[e,n]),{connected:en}=PA(l.owner==="self"?n:null,{onMessage:Ht,onError:hn});return{session:Ie,messages:oe,agentContent:Ee,setAgentContent:_e,toolUseToAgent:Te,markdownAugments:U,status:l,processState:d,isCompacting:B,isHeld:d==="hold",pendingInputRequest:p,actualSessionId:S,permissionMode:V,modeVersion:ee,loading:We,error:v,connected:en,lastStreamActivityAt:C,setStatus:u,setProcessState:f,setPermissionMode:cn,setHold:un,pendingMessages:E,addPendingMessage:fn,removePendingMessage:Z,deferredMessages:M,slashCommands:Ne,sessionTools:D,mcpServers:G}}function WA(){const{projectId:e,sessionId:n}=kc();return!e||!n?a.jsx("div",{className:"error",children:"Invalid session URL"}):a.jsx(u4,{children:a.jsx(XA,{projectId:e,sessionId:n},n)})}function XA({projectId:e,sessionId:n}){const{openSidebar:r,isWideScreen:o,toggleSidebar:l,isSidebarCollapsed:u}=za(),d=Oi(),{project:f}=F0(e),p=us(),x=Cs(),v=x.state,y=v==null?void 0:v.initialStatus,S=v==null?void 0:v.initialTitle,w=v==null?void 0:v.initialModel,C=v==null?void 0:v.initialProvider,_=Cb(),E=h.useMemo(()=>{if(_)return{onAugment:_.dispatchAugment,onPending:_.dispatchPending,onStreamEnd:_.dispatchStreamEnd,setCurrentMessageId:_.setCurrentMessageId,captureHtml:_.captureStreamingHtml}},[_]),{session:k,messages:M,agentContent:O,setAgentContent:B,toolUseToAgent:L,markdownAugments:U,status:$,processState:V,isCompacting:F,pendingInputRequest:X,actualSessionId:ge,permissionMode:ee,loading:ne,error:Ne,connected:ke,lastStreamActivityAt:D,setStatus:q,setProcessState:G,setPermissionMode:Se,setHold:Me,isHeld:I,pendingMessages:re,addPendingMessage:he,removePendingMessage:oe,deferredMessages:Ee,slashCommands:Te}=YA(e,n,y,E),{holdModeEnabled:We}=Vo(),{connectionState:Ie}=$b(),je="idle",Ze=(k==null?void 0:k.provider)??C,yt=(k==null?void 0:k.model)??w,[be,St]=h.useState(0),_e=h.useRef(null),mt=h.useCallback(J=>{_e.current=J},[]),{showToast:pt}=oh(),Lt=vb(),cn=bb(),un=h.useMemo(()=>[...Te,"login"],[Te]),{providers:dn}=uh(),fn=h.useMemo(()=>k!=null&&k.provider?dn.find(J=>J.name===k.provider)??null:null,[dn,k==null?void 0:k.provider]),Z=(fn==null?void 0:fn.supportsPermissionMode)??!0,xe=(fn==null?void 0:fn.supportsThinkingToggle)??!0,Be=(fn==null?void 0:fn.supportsSlashCommands)??!1,[st,kt]=h.useState(!1),[Et,an]=h.useState(""),[fs,hs]=h.useState(!1),gt=h.useRef(null),Bt=h.useRef(!1),[Rn,Ht]=h.useState(!1),hn=h.useRef(null),[en,Oe]=h.useState(void 0),[vt,gn]=h.useState(void 0),[Gn,ze]=h.useState(void 0),[Ft,mn]=h.useState(void 0);h.useEffect(()=>{Oe(void 0),gn(void 0),ze(void 0),mn(void 0)},[n]),h.useEffect(()=>{DA(n,e)},[n,e]),h.useEffect(()=>{ge&&ge!==n&&p(`${d}/projects/${e}/sessions/${ge}`,{replace:!0,state:x.state})},[ge,n,e,p,x.state,d]);const[Xt,Tt]=h.useState([]),[bs,ls]=h.useState([]),[ts,Yn]=h.useState(!1),[ar,pn]=h.useState(!1),Un=(k==null?void 0:k.updatedAt)??null,N=h.useMemo(()=>!Un&&!D?null:Un?D?Un>D?Un:D:Un:D,[Un,D]);UA({sessionId:n,activityAt:N,updatedAt:Un,lastSeenAt:k==null?void 0:k.lastSeenAt,hasUnread:k==null?void 0:k.hasUnread,enabled:$.owner!=="external"});const R=async J=>{var qe,rt,at;if(J.trim()==="/login"){Lt.startLogin();return}const te=he(J);G("in-turn"),St(et=>et+1);const fe=[...Xt];Tt([]);try{if($.owner==="none"){const et=(k==null?void 0:k.model)??_c(),P=Oo(),jt=await Ae.resumeSession(e,n,J,{mode:ee,model:et,thinking:P,provider:Ze,executor:k==null?void 0:k.executor},fe.length>0?fe:void 0,te);q({owner:"self",processId:jt.processId})}else{const et=Oo(),P=await Ae.queueMessage(n,J,ee,fe.length>0?fe:void 0,te,et);P.restarted&&P.processId&&q({owner:"self",processId:P.processId})}(qe=_e.current)==null||qe.clearDraft()}catch(et){if(console.error("Failed to send:",et),et instanceof Error&&(et.message.includes("404")||et.message.includes("No active process")))try{const bt=(k==null?void 0:k.model)??_c(),Ot=Oo(),wt=await Ae.resumeSession(e,n,J,{mode:ee,model:bt,thinking:Ot,provider:Ze,executor:k==null?void 0:k.executor},fe.length>0?fe:void 0,te);q({owner:"self",processId:wt.processId}),(rt=_e.current)==null||rt.clearDraft();return}catch(bt){console.error("Failed to resume session:",bt)}oe(te),(at=_e.current)==null||at.restoreFromStorage(),Tt(fe),G("idle");const jt=et instanceof Error?et.message:"Unknown error";pt(`Failed to send message: ${jt}`,"error")}},T=async J=>{var qe,rt;const te=he(J);St(at=>at+1);const fe=[...Xt];Tt([]);try{const at=Oo();await Ae.queueMessage(n,J,ee,fe.length>0?fe:void 0,te,at,!0),(qe=_e.current)==null||qe.clearDraft()}catch(at){console.error("Failed to queue deferred message:",at),oe(te),(rt=_e.current)==null||rt.restoreFromStorage(),Tt(fe);const et=at instanceof Error?at.message:"Unknown error";pt(`Failed to queue message: ${et}`,"error")}},b=async()=>{if($.owner==="self"&&$.processId){try{if((await Ae.interruptProcess($.processId)).interrupted)return}catch{}await Ae.abortProcess($.processId)}},z=h.useCallback(async()=>{if(X)try{await Ae.respondToInput(n,X.id,"approve")}catch(J){const te=J.status,fe=te?`Error ${te}`:"Failed to approve";pt(fe,"error")}},[n,X,pt]),W=h.useCallback(async()=>{if(X)try{await Ae.respondToInput(n,X.id,"approve_accept_edits"),Se("acceptEdits")}catch(J){const te=J.status,fe=te?`Error ${te}`:"Failed to approve";pt(fe,"error")}},[n,X,Se,pt]),K=h.useCallback(async()=>{if(X)try{await Ae.respondToInput(n,X.id,"deny")}catch(J){const te=J.status,fe=te?`Error ${te}`:"Failed to deny";pt(fe,"error")}},[n,X,pt]),me=h.useCallback(async J=>{if(X)try{await Ae.respondToInput(n,X.id,"deny",void 0,J)}catch(te){const fe=te.status,qe=fe?`Error ${fe}`:"Failed to send feedback";pt(qe,"error")}},[n,X,pt]),Re=h.useCallback(async J=>{if(X)try{await Ae.respondToInput(n,X.id,"approve",J)}catch(te){const fe=te.status,qe=fe?`Error ${fe}`:"Failed to submit answer";pt(qe,"error")}},[n,X,pt]),Ke=h.useCallback(async J=>{for(const te of J){const fe=crypto.randomUUID();ls(qe=>[...qe,{fileId:fe,fileName:te.name,bytesUploaded:0,totalBytes:te.size,percent:0}]);try{const qe=await cn.upload(e,n,te,{onProgress:rt=>{ls(at=>at.map(et=>et.fileId===fe?{...et,bytesUploaded:rt,percent:Math.round(rt/te.size*100)}:et))}});Tt(rt=>[...rt,qe])}catch(qe){console.error("Upload failed:",qe);const rt=qe instanceof Error?qe.message:"Upload failed";pt(`Failed to upload ${te.name}: ${rt}`,"error")}finally{ls(qe=>qe.filter(rt=>rt.fileId!==fe))}}},[e,n,pt,cn]),He=h.useCallback(J=>{Tt(te=>te.filter(fe=>fe.id!==J))},[]),Mt=(X==null?void 0:X.toolName)==="AskUserQuestion",Ge=V==="in-turn"||V==="waiting-input",lt=h.useMemo(()=>$.owner!=="none"?!1:dh(M).some(te=>te.type==="tool_call"&&te.status==="pending"),[M,$.owner]),ht=_r(k),ct=en??(ht!=="Untitled"?ht:null)??S??"Untitled",dt=vt??(k==null?void 0:k.isArchived)??!1,ot=Gn??(k==null?void 0:k.isStarred)??!1;wb(f==null?void 0:f.name,ct);const ft=()=>{an(ct),kt(!0),setTimeout(()=>{var J,te;(J=gt.current)==null||J.focus(),(te=gt.current)==null||te.select()},0)},Xe=()=>{Bt.current||(kt(!1),an(""))},Ye=()=>{if(!Bt.current){if(!Et.trim()||Et.trim()===ct){Xe();return}tt()}},tt=async()=>{if(!(!Et.trim()||fs)){Bt.current=!0,hs(!0);try{await Ae.updateSessionMetadata(n,{title:Et.trim()}),Oe(Et.trim()),kt(!1),pt("Session renamed","success")}catch(J){console.error("Failed to rename session:",J),pt("Failed to rename session","error")}finally{hs(!1),Bt.current=!1}}},$e=J=>{J.key==="Enter"?(J.preventDefault(),tt()):J.key==="Escape"&&(J.preventDefault(),Xe())},Ve=async()=>{const J=!dt;try{await Ae.updateSessionMetadata(n,{archived:J}),gn(J),pt(J?"Session archived":"Session unarchived","success")}catch(te){console.error("Failed to update archive status:",te),pt("Failed to update archive status","error")}},Je=async()=>{const J=!ot;try{await Ae.updateSessionMetadata(n,{starred:J}),ze(J),pt(J?"Session starred":"Session unstarred","success")}catch(te){console.error("Failed to update star status:",te),pt("Failed to update star status","error")}},Pe=Ft??(k==null?void 0:k.hasUnread)??!1,ce=async()=>{const J=!Pe;mn(J);try{J?await Ae.markSessionUnread(n):await Ae.markSessionSeen(n),pt(J?"Marked as unread":"Marked as read","success")}catch(te){console.error("Failed to update read status:",te),mn(void 0),pt("Failed to update read status","error")}},ue=async()=>{if($.owner==="self"&&$.processId)try{await Ae.abortProcess($.processId),pt("Session terminated","success")}catch(J){console.error("Failed to terminate session:",J);const te=J instanceof Error?J.message:"Unknown error";pt(`Failed to terminate: ${te}`,"error")}};if(Ne)return a.jsxs("div",{className:"error",children:["Error: ",Ne.message]});const Ce=()=>a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),a.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]});return a.jsx("div",{className:o?"main-content-wrapper":"main-content-mobile",children:a.jsxs("div",{className:o?"main-content-constrained":"main-content-mobile-inner",children:[a.jsx("header",{className:"session-header",children:a.jsxs("div",{className:"session-header-inner",children:[a.jsxs("div",{className:"session-header-left",children:[!(o&&u)&&a.jsx("button",{type:"button",className:"sidebar-toggle",onClick:o?l:r,title:o?"Toggle sidebar":"Open sidebar","aria-label":o?"Toggle sidebar":"Open sidebar",children:a.jsx(Ce,{})}),(f==null?void 0:f.name)&&a.jsx(Vs,{to:`${d}/sessions?project=${e}`,className:"project-breadcrumb",title:f.name,children:f.name.length>12?`${f.name.slice(0,12)}...`:f.name}),a.jsxs("div",{className:"session-title-row",children:[ot&&a.jsxs("svg",{className:"star-indicator-inline",width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2",role:"img","aria-label":"Starred",children:[a.jsx("title",{children:"Starred"}),a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})]}),ne?a.jsx("span",{className:"session-title-skeleton"}):st?a.jsx("input",{ref:gt,type:"text",className:"session-title-input",value:Et,onChange:J=>an(J.target.value),onKeyDown:$e,onBlur:Ye,disabled:fs}):a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:hn,type:"button",className:"session-title session-title-dropdown-trigger",onClick:()=>Ht(!Rn),title:(k==null?void 0:k.fullTitle)??ct,children:[a.jsx("span",{className:"session-title-text",children:ct}),a.jsx("svg",{className:"session-title-chevron",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),a.jsx(AA,{currentSessionId:n,isOpen:Rn,onClose:()=>Ht(!1),onNavigate:()=>Ht(!1),triggerRef:hn,basePath:d})]}),!ne&&dt&&a.jsx("span",{className:"archived-badge",children:"Archived"}),!ne&&a.jsx(xb,{sessionId:n,projectId:e,isStarred:ot,isArchived:dt,hasUnread:Pe,provider:k==null?void 0:k.provider,processId:$.owner==="self"?$.processId:void 0,onToggleStar:Je,onToggleArchive:Ve,onToggleRead:ce,onRename:ft,onClone:J=>{p(`${d}/projects/${e}/sessions/${J}`)},onTerminate:ue,useFixedPositioning:!0,useEllipsisIcon:!0})]})]}),a.jsx("div",{className:"session-header-right",children:!ne&&Ze&&a.jsx("button",{type:"button",className:"provider-badge-button",onClick:()=>pn(!0),title:"View session info",children:a.jsx(NA,{provider:Ze,model:yt,isThinking:V==="in-turn"})})})]})}),ar&&k&&a.jsx(SA,{sessionId:ge,provider:k.provider,model:k.model,status:$,processState:V,contextUsage:k.contextUsage,sessionStreamConnected:ke,lastSessionEventAt:D,onClose:()=>pn(!1)}),$.owner==="external"&&a.jsx("div",{className:"external-session-warning",children:"External session active - enter messages at your own risk!"}),lt&&a.jsx("div",{className:"external-session-warning pending-tool-warning",children:"This session may be waiting for input in another process (VS Code, CLI). Check there before sending a message."}),a.jsx("main",{className:"session-messages",children:ne?a.jsx("div",{className:"loading",children:"Loading session..."}):a.jsx(U4,{projectId:e,projectPath:(f==null?void 0:f.path)??null,sessionId:n,children:a.jsx(vR,{agentContent:O,setAgentContent:B,toolUseToAgent:L,projectId:e,sessionId:n,children:a.jsx(xA,{messages:M,isProcessing:$.owner==="self"&&V==="in-turn",isCompacting:F,scrollTrigger:be,pendingMessages:re,deferredMessages:Ee,onCancelDeferred:J=>Ae.cancelDeferredMessage(n,J),markdownAugments:U,activeToolApproval:Ge})})})}),a.jsxs("footer",{className:"session-input",children:[a.jsx("div",{className:`session-connection-bar session-connection-${je}`}),a.jsxs("div",{className:"session-input-inner",children:[X&&X.sessionId===ge&&Mt&&a.jsx(CA,{request:X,sessionId:ge,onSubmit:Re,onDeny:K}),X&&X.sessionId===ge&&!Mt&&a.jsxs(a.Fragment,{children:[a.jsx(zA,{request:X,sessionId:ge,onApprove:z,onDeny:K,onApproveAcceptEdits:W,onDenyWithFeedback:me,collapsed:ts,onCollapsedChange:Yn}),a.jsx(Nb,{mode:ee,onModeChange:Se,isHeld:We?I:void 0,onHoldChange:We?Me:void 0,supportsPermissionMode:Z,supportsThinkingToggle:xe,contextUsage:k==null?void 0:k.contextUsage,isRunning:$.owner==="self",isThinking:V==="in-turn",onStop:b,pendingApproval:ts?{type:"tool-approval",onExpand:()=>Yn(!1)}:void 0})]}),!(X&&X.sessionId===ge&&!Mt)&&a.jsx(Q3,{onSend:R,onQueue:$.owner!=="none"&&V!=="idle"?T:void 0,placeholder:$.owner==="external"?"External session - send at your own risk...":V==="idle"?"Send a message to resume...":"Queue a message...",mode:ee,onModeChange:Se,isHeld:We?I:void 0,onHoldChange:We?Me:void 0,supportsPermissionMode:Z,supportsThinkingToggle:xe,isRunning:$.owner==="self",isThinking:V==="in-turn",onStop:b,draftKey:`draft-message-${n}`,onDraftControlsReady:mt,collapsed:!!(X&&X.sessionId===ge),contextUsage:k==null?void 0:k.contextUsage,projectId:e,sessionId:n,attachments:Xt,onAttach:Ke,onRemoveAttachment:He,uploadProgress:bs,slashCommands:Be&&$.owner==="self"?un:[]})]})]}),Lt.isOpen&&a.jsx(jb,{authMethod:Lt.authMethod,onSelectMethod:Lt.selectMethod,url:Lt.url,statusMessage:Lt.statusMessage,startupError:Lt.error,onSuccess:Lt.handleSuccess,onCancel:Lt.handleCancel})]})})}let Ea=null;function KA(){const[e,n]=h.useState(!1),[r,o]=h.useState(!1);h.useEffect(()=>{if(window.matchMedia("(display-mode: standalone)").matches||"standalone"in navigator&&navigator.standalone===!0){o(!0);return}Ea&&n(!0);const d=p=>{p.preventDefault(),Ea=p,n(!0)},f=()=>{o(!0),n(!1),Ea=null};return window.addEventListener("beforeinstallprompt",d),window.addEventListener("appinstalled",f),()=>{window.removeEventListener("beforeinstallprompt",d),window.removeEventListener("appinstalled",f)}},[]);const l=h.useCallback(async()=>{if(!Ea)return!1;await Ea.prompt();const{outcome:u}=await Ea.userChoice;return u==="accepted"?(n(!1),Ea=null,!0):!1},[]);return{canInstall:e,isInstalled:r,install:l}}function JA(){const[e,n]=h.useState(null),[r,o]=h.useState(!0),[l,u]=h.useState(null),d=h.useRef(!1),f=h.useCallback(async()=>{o(!0),u(null);try{const p=await Ae.getVersion();n(p)}catch(p){u(p instanceof Error?p:new Error(String(p)))}finally{o(!1)}},[]);return h.useEffect(()=>{d.current||(d.current=!0,f())},[f]),{version:e,loading:r,error:l,refetch:f}}function QA(){const{canInstall:e,isInstalled:n,install:r}=KA(),{version:o}=JA(),{resetOnboarding:l}=lb(),{remoteLogCollectionEnabled:u,setRemoteLogCollectionEnabled:d}=Vo(),[f,p]=h.useState(!1),[x,v]=h.useState(0);h.useEffect(()=>{Ue("/status/workers").then(S=>v(S.activeWorkers)).catch(()=>{})},[]),h.useEffect(()=>{if(f)return ln.on("reconnect",()=>{p(!1)})},[f]);const y=h.useCallback(async()=>{p(!0);try{await Ae.restartServer()}catch{}},[]);return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"About"}),a.jsxs("div",{className:"settings-group",children:[(e||n)&&a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Install App"}),a.jsx("p",{children:n?"Yep Anywhere is installed on your device.":"Add Yep Anywhere to your home screen for quick access."})]}),n?a.jsx("span",{className:"settings-status-badge",children:"Installed"}):a.jsx("button",{type:"button",className:"settings-button",onClick:r,children:"Install"})]}),a.jsx("div",{className:"settings-item",children:a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Version"}),a.jsxs("p",{children:["Server:"," ",o?a.jsxs(a.Fragment,{children:["v",o.current,o.updateAvailable&&o.latest?a.jsxs("span",{className:"settings-update-available",children:[" ","(v",o.latest," available)"]}):o.latest?a.jsx("span",{className:"settings-up-to-date",children:" (up to date)"}):null]}):"Loading..."]}),a.jsxs("p",{children:["Client: v","0.2.8"]}),(o==null?void 0:o.updateAvailable)&&a.jsxs("p",{className:"settings-update-hint",children:["Run ",a.jsx("code",{children:"npm i -g yepanywhere"})," to update"]})]})}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Restart Server"}),a.jsx("p",{children:"Restart the backend server process."}),x>0&&!f&&a.jsxs("p",{className:"settings-warning",children:[x," active session",x!==1?"s":""," will be interrupted"]})]}),a.jsx("button",{type:"button",className:`settings-button ${x>0?"settings-button-danger":""}`,onClick:y,disabled:f,children:f?"Restarting...":x>0?"Restart Anyway":"Restart Server"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Report a Bug"}),a.jsx("p",{children:"Found an issue? Report it on GitHub to help improve Yep Anywhere."})]}),a.jsx("a",{href:"https://github.com/kzahel/yepanywhere/issues",target:"_blank",rel:"noopener noreferrer",className:"settings-button",children:"Report Bug"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Setup Wizard"}),a.jsx("p",{children:"Run the initial setup wizard again to configure theme and remote access."})]}),a.jsx("button",{type:"button",className:"settings-button",onClick:l,children:"Launch Wizard"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Connection Diagnostics"}),a.jsx("p",{children:"Capture connection logs and send to server for debugging."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:u,onChange:S=>d(S.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]})]})]})}function e5(){const{fontSize:e,setFontSize:n}=ET(),{theme:r,setTheme:o}=tb(),{streamingEnabled:l,setStreamingEnabled:u}=FA(),{funPhrasesEnabled:d,setFunPhrasesEnabled:f}=s4(),{showConnectionBars:p,setShowConnectionBars:x}=Vo();return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Appearance"}),a.jsxs("div",{className:"settings-group",children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Theme"}),a.jsx("p",{children:"Choose your preferred color scheme."})]}),a.jsx("div",{className:"font-size-selector",children:rh.map(v=>a.jsx("button",{type:"button",className:`font-size-option ${r===v?"active":""}`,onClick:()=>o(v),children:J0(v)},v))})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Font Size"}),a.jsx("p",{children:"Adjust the text size throughout the application."})]}),a.jsx("div",{className:"font-size-selector",children:db.map(v=>a.jsx("button",{type:"button",className:`font-size-option ${e===v?"active":""}`,onClick:()=>n(v),children:NT(v)},v))})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Response Streaming"}),a.jsx("p",{children:"Show responses as they are generated, token by token. Disable for better performance on slower devices."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:l,onChange:v=>u(v.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Fun Phrases"}),a.jsx("p",{children:'Show playful status messages while waiting for responses. Disable to show only "Thinking..."'})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:d,onChange:v=>f(v.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Connection Bars"}),a.jsx("p",{children:"Show colored status bars for relay and session connections (green/orange/red)."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:p,onChange:v=>x(v.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]})]})]})}function Fb(){const[e,n]=h.useState(null),[r,o]=h.useState(!0),[l,u]=h.useState(null),d=h.useCallback(async()=>{try{o(!0),u(null);const p=await Ae.getServerSettings();n(p.settings)}catch(p){console.error("[useServerSettings] Failed to fetch settings:",p),u(p instanceof Error?p.message:"Failed to load settings")}finally{o(!1)}},[]);h.useEffect(()=>{d()},[d]);const f=h.useCallback(async(p,x)=>{try{u(null);const v=await Ae.updateServerSettings({[p]:x});n(v.settings)}catch(v){throw console.error("[useServerSettings] Failed to update setting:",v),u(v instanceof Error?v.message:"Failed to update setting"),v}},[]);return{settings:e,isLoading:r,error:l,updateSetting:f,refetch:d}}function t5(){const{isManualReloadMode:e,pendingReloads:n,connected:r,reloadBackend:o,unsafeToRestart:l,workerActivity:u}=lh(),{settings:d,setEnabled:f}=rb(),{holdModeEnabled:p,setHoldModeEnabled:x}=Vo(),{ignoredTools:v,clearIgnoredTools:y}=Fn(),{settings:S,updateSetting:w}=Fb(),[C,_]=h.useState(!1);h.useEffect(()=>{C&&r&&_(!1)},[C,r]);const E=async()=>{_(!0),await o()};return e?a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Development"}),a.jsxs("div",{className:"settings-group",children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Schema Validation"}),a.jsx("p",{children:"Validate tool results against expected schemas. Shows toast notifications and logs errors to console."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:d.enabled,onChange:k=>f(k.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]}),v.length>0&&a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Ignored Tools"}),a.jsx("p",{children:"Tools with validation errors you chose to ignore. They will not show toast notifications."}),a.jsx("div",{className:"ignored-tools-list",children:v.map(k=>a.jsx("span",{className:"ignored-tool-badge",children:k},k))})]}),a.jsx("button",{type:"button",className:"settings-button settings-button-secondary",onClick:y,children:"Clear Ignored"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Hold Mode"}),a.jsx("p",{children:"Show hold/resume option in the mode selector. Pauses execution at the next yield point (experimental)."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:p,onChange:k=>x(k.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Service Worker"}),a.jsx("p",{children:"Enable service worker for push notifications. Disabling can help with page reload issues during development. Requires restart."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:(S==null?void 0:S.serviceWorkerEnabled)??!0,onChange:k=>w("serviceWorkerEnabled",k.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]})]}),a.jsx("div",{className:"settings-group",children:a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Restart Server"}),a.jsxs("p",{children:["Restart the backend server to pick up code changes.",n.backend&&a.jsx("span",{className:"settings-pending",children:" (changes pending)"})]}),l&&a.jsxs("p",{className:"settings-warning",children:[u.activeWorkers," active session",u.activeWorkers!==1?"s":""," will be interrupted"]})]}),a.jsx("button",{type:"button",className:`settings-button ${l?"settings-button-danger":""}`,onClick:E,disabled:C,children:C?"Restarting...":l?"Restart Anyway":"Restart Server"})]})})]}):null}function n5(){const[e,n]=h.useState({profiles:[],isLoading:!0,error:null}),r=h.useCallback(async()=>{n(l=>({...l,isLoading:!0,error:null}));try{const{profiles:l}=await Ae.getBrowserProfiles();n({profiles:l,isLoading:!1,error:null})}catch(l){console.error("[useBrowserProfiles] Failed to fetch:",l),n(u=>({...u,isLoading:!1,error:l instanceof Error?l.message:"Failed to load profiles"}))}},[]);h.useEffect(()=>{r()},[r]);const o=h.useCallback(async l=>{n(u=>({...u,isLoading:!0,error:null}));try{await Ae.deleteBrowserProfile(l),await r()}catch(u){console.error("[useBrowserProfiles] Failed to delete:",u),n(d=>({...d,isLoading:!1,error:u instanceof Error?u.message:"Failed to delete profile"}))}},[r]);return{...e,deleteProfile:o,refetch:r}}function qb(){const[e,n]=h.useState({connections:new Map,isLoading:!0,error:null}),r=h.useCallback(async()=>{n(o=>({...o,isLoading:!0,error:null}));try{const{connections:o}=await Ae.getConnections(),l=new Map;for(const u of o)l.set(u.browserProfileId,u);n({connections:l,isLoading:!1,error:null})}catch(o){console.error("[useConnectedDevices] Failed to fetch:",o),n(l=>({...l,isLoading:!1,error:o instanceof Error?o.message:"Failed to load connections"}))}},[]);return h.useEffect(()=>{r()},[r]),h.useEffect(()=>{const o=ln.on("browser-tab-connected",f=>{n(p=>{var v;const x=new Map(p.connections);return x.set(f.browserProfileId,{browserProfileId:f.browserProfileId,connectionCount:f.tabCount,connectedAt:f.timestamp,deviceName:(v=p.connections.get(f.browserProfileId))==null?void 0:v.deviceName}),{...p,connections:x}})}),l=ln.on("browser-tab-disconnected",f=>{n(p=>{const x=new Map(p.connections);if(f.tabCount===0)x.delete(f.browserProfileId);else{const v=x.get(f.browserProfileId);v&&x.set(f.browserProfileId,{...v,connectionCount:f.tabCount})}return{...p,connections:x}})}),u=ln.on("reconnect",()=>{r()}),d=ln.on("refresh",()=>{r()});return()=>{o(),l(),u(),d()}},[r]),{...e,connectionList:Array.from(e.connections.values()),refetch:r}}const s5="/sw.js";function mh(){const[e,n]=h.useState({isSupported:!1,isSubscribed:!1,isLoading:!0,error:null,permission:"default",browserProfileId:null}),[r,o]=h.useState(null),l=typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window;h.useEffect(()=>{(async()=>{if(!l){const y=sa("browserProfileId",vs.browserProfileId);n(S=>({...S,isSupported:!1,isLoading:!1,error:"Push notifications not supported in this browser",browserProfileId:y}));return}try{const y=await navigator.serviceWorker.register(s5);o(y),await navigator.serviceWorker.ready;const S=await y.pushManager.getSubscription(),w=Ro();n({isSupported:!0,isSubscribed:!!S,isLoading:!1,error:null,permission:Notification.permission,browserProfileId:w})}catch(y){console.error("[usePushNotifications] Init error:",y),n(S=>({...S,isSupported:!0,isLoading:!1,error:y instanceof Error?y.message:"Failed to initialize"}))}})()},[l]);const u=h.useCallback(async()=>{if(!r){n(v=>({...v,error:"Service worker not ready"}));return}n(v=>({...v,isLoading:!0,error:null}));try{const v=await Notification.requestPermission();if(n(E=>({...E,permission:v})),v!=="granted"){n(E=>({...E,isLoading:!1,error:"Notification permission denied"}));return}const{publicKey:y}=await Ae.getPushPublicKey(),S=r5(y),w=await r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:S.buffer}),C=Ro(),_=w.toJSON();await Ae.subscribePush(C,_,a5()),n(E=>({...E,isSubscribed:!0,isLoading:!1,error:null,browserProfileId:C}))}catch(v){console.error("[usePushNotifications] Subscribe error:",v),n(y=>({...y,isLoading:!1,error:v instanceof Error?v.message:"Failed to subscribe"}))}},[r]),d=h.useCallback(async()=>{if(!r){n(v=>({...v,error:"Service worker not ready"}));return}n(v=>({...v,isLoading:!0,error:null}));try{const v=await r.pushManager.getSubscription();v&&await v.unsubscribe();const y=Ro();await Ae.unsubscribePush(y),n(S=>({...S,isSubscribed:!1,isLoading:!1,error:null}))}catch(v){console.error("[usePushNotifications] Unsubscribe error:",v),n(y=>({...y,isLoading:!1,error:v instanceof Error?v.message:"Failed to unsubscribe"}))}},[r]),f=h.useCallback(async(v="normal")=>{const y=Ro();n(S=>({...S,isLoading:!0,error:null}));try{await Ae.testPush(y,void 0,v),n(S=>({...S,isLoading:!1}))}catch(S){console.error("[usePushNotifications] Test push error:",S),n(w=>({...w,isLoading:!1,error:S instanceof Error?S.message:"Failed to send test"}))}},[]),p=h.useCallback(async()=>{var y;const v=(y=navigator.serviceWorker)==null?void 0:y.controller;return v?new Promise(S=>{const w=new MessageChannel;w.port1.onmessage=C=>{var _;S(((_=C.data)==null?void 0:_.logs)||[])},v.postMessage({type:"get-sw-logs"},[w.port2]),setTimeout(()=>S([]),2e3)}):(console.warn("[usePushNotifications] No active service worker"),[])},[]),x=h.useCallback(async()=>{var y;const v=(y=navigator.serviceWorker)==null?void 0:y.controller;if(v)return new Promise(S=>{const w=new MessageChannel;w.port1.onmessage=()=>S(),v.postMessage({type:"clear-sw-logs"},[w.port2]),setTimeout(S,1e3)})},[]);return{...e,subscribe:u,unsubscribe:d,sendTest:f,getSwLogs:p,clearSwLogs:x}}function r5(e){const n="=".repeat((4-e.length%4)%4),r=(e+n).replace(/-/g,"+").replace(/_/g,"/"),o=window.atob(r),l=new Uint8Array(o.length);for(let u=0;u<o.length;++u)l[u]=o.charCodeAt(u);return l}function a5(){const e=navigator.userAgent;return/iPhone/.test(e)?"iPhone":/iPad/.test(e)?"iPad":/Android/.test(e)?"Android":/Mac/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Linux/.test(e)?"Linux":"Browser"}function Av(e){const n=new Date(e),o=new Date().getTime()-n.getTime(),l=Math.floor(o/(1e3*60)),u=Math.floor(o/(1e3*60*60)),d=Math.floor(o/(1e3*60*60*24));return l<1?"just now":l<60?`${l} minute${l===1?"":"s"} ago`:u<24?`${u} hour${u===1?"":"s"} ago`:d===1?"yesterday":d<7?`${d} days ago`:n.toLocaleDateString()}function i5(){const{profiles:e,isLoading:n,error:r,deleteProfile:o}=n5(),{browserProfileId:l}=mh(),{connections:u}=qb();return a.jsx(a.Fragment,{children:a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Browser Profiles"}),a.jsx("p",{className:"settings-section-description",children:"Devices that have connected to this server, with their access origins. Each browser profile may connect from multiple URLs (localhost, Tailscale, etc.)."}),r&&a.jsx("p",{className:"form-error",children:r}),a.jsx("div",{className:"settings-group",children:n?a.jsx("p",{className:"settings-hint",children:"Loading profiles..."}):e.length===0?a.jsx("p",{className:"settings-hint",children:"No browser profiles recorded yet. Connect from a browser to see profiles here."}):a.jsx("div",{className:"device-list",children:e.map(d=>{const f=d.browserProfileId===l,p=u.has(d.browserProfileId),x=d.deviceName||`${d.browserProfileId.slice(0,8)}...`;return a.jsxs("div",{className:"device-list-item device-profile-item",children:[a.jsxs("div",{className:"device-list-info",children:[a.jsxs("strong",{children:[a.jsx("span",{className:`device-status ${p?"device-status-online":"device-status-offline"}`,title:p?"Connected":"Disconnected"}),x,f&&a.jsx("span",{className:"device-current-badge",children:"This device"})]}),a.jsx("div",{className:"device-origins",children:d.origins.map(v=>{const{browser:y,os:S}=K0(v.userAgent);return a.jsxs("div",{className:"device-origin",children:[a.jsx("code",{className:"device-origin-url",children:v.origin}),a.jsxs("span",{className:"device-origin-details",children:[y," · ",S]}),a.jsxs("span",{className:"device-origin-time",children:["Last seen ",Av(v.lastSeen)]})]},v.origin)})}),a.jsxs("p",{className:"device-profile-meta",children:["First seen ",Av(d.createdAt)]})]}),a.jsx("button",{type:"button",className:"settings-button settings-button-danger-subtle",onClick:()=>o(d.browserProfileId),title:"Forget this device",children:"Forget"})]},d.browserProfileId)})})})]})})}function o5(){const[e,n]=h.useState(null),[r,o]=h.useState(!0),[l,u]=h.useState(null),[d,f]=h.useState(!1),p=h.useRef(!1),x=h.useCallback(async()=>{o(!0),u(null);try{const S=await Ae.getNetworkBinding();n(S)}catch(S){u(S instanceof Error?S:new Error(String(S)))}finally{o(!1)}},[]);h.useEffect(()=>{p.current||(p.current=!0,x())},[x]);const v=h.useCallback(async S=>{f(!0),u(null);try{const w=await Ae.setNetworkBinding(S);if(!w.success)throw new Error(w.error??"Failed to update binding");return await x(),{redirectUrl:w.redirectUrl}}catch(w){const C=w instanceof Error?w:new Error(String(w));throw u(C),C}finally{f(!1)}},[x]),y=h.useCallback(async()=>{f(!0),u(null);try{const S=await Ae.disableNetworkBinding();if(!S.success)throw new Error(S.error??"Failed to disable network socket");await x()}catch(S){const w=S instanceof Error?S:new Error(String(S));throw u(w),w}finally{f(!1)}},[x]);return{binding:e,loading:r,error:l,applying:d,updateBinding:v,disableNetwork:y,refetch:x}}function l5(){const[e,n]=h.useState(null),[r,o]=h.useState(!0),[l,u]=h.useState(null),d=h.useRef(!1),f=h.useCallback(async()=>{o(!0),u(null);try{const p=await Ae.getServerInfo();n(p)}catch(p){u(p instanceof Error?p:new Error(String(p)))}finally{o(!1)}},[]);return h.useEffect(()=>{d.current||(d.current=!0,f())},[f]),{serverInfo:e,loading:r,error:l,refetch:f}}function c5(){const e=X6(),n=Lc(),{relayDebugEnabled:r,setRelayDebugEnabled:o}=Vo(),{serverInfo:l,loading:u}=l5(),{binding:d,loading:f,applying:p,updateBinding:x}=o5(),{settings:v,isLoading:y}=Fb(),[S,w]=h.useState(""),[C,_]=h.useState(!1),[E,k]=h.useState(""),[M,O]=h.useState(""),[B,L]=h.useState(!1),[U,$]=h.useState(""),[V,F]=h.useState(""),[X,ge]=h.useState(!1),[ee,ne]=h.useState(""),[Ne,ke]=h.useState(null),[D,q]=h.useState(!1),[G,Se]=h.useState(!1),[Me,I]=h.useState(!1);if(d&&e&&v&&!Me){w(String(d.localhost.port)),_(d.network.enabled),k(d.network.host??""),L(e.authEnabled);const Te=v.allowedHosts;Te==="*"?(ge(!0),ne("")):(ge(!1),ne(Te??"")),I(!0)}const re=(Te,We)=>Te?"*":We.trim()||void 0,he=(Te,We,Ie,je,Ze,yt,be)=>{if(!d||!e||!v)return!1;const St=Te!==String(d.localhost.port),_e=We!==d.network.enabled,mt=Ie!==(d.network.host??""),pt=je!==e.authEnabled,Lt=Ze.length>0,cn=re(yt,be),un=v.allowedHosts;return St||_e||mt||pt||Lt||(cn??"")!==(un??"")},oe=Te=>{q(he(Te.port??S,Te.networkEnabled??C,Te.iface??E,Te.requirePw??B,Te.password??U,Te.allowAll??X,Te.hostsText??ee))},Ee=async()=>{if(!e)return;ke(null);const Te=Number.parseInt(S,10);if(Number.isNaN(Te)||Te<1||Te>65535){ke("Port must be a number between 1 and 65535");return}const We=B&&!e.authEnabled,Ie=B&&e.authEnabled&&U.length>0;if(We||Ie){if(U.length<6){ke("Password must be at least 6 characters");return}if(U!==V){ke("Passwords do not match");return}}const je=E==="custom"?M:E;Se(!0);try{const Ze=await x({localhostPort:Te,network:{enabled:C,host:C?je:void 0}});We?(await e.enableAuth(U),$(""),F("")):Ie?(await e.changePassword(U),$(""),F("")):!B&&e.authEnabled&&await e.disableAuth();const yt=re(X,ee);if(await Ae.updateServerSettings({allowedHosts:yt??""}),Ze.redirectUrl){const be=new URL(Ze.redirectUrl);be.pathname=window.location.pathname,be.search=window.location.search,window.location.href=be.toString()}else q(!1)}catch(Ze){ke(Ze instanceof Error?Ze.message:"Failed to apply changes")}finally{Se(!1)}};if(e){if(u||f||y||e.isLoading||!Me)return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Local Access"}),a.jsx("p",{className:"settings-section-description",children:"Loading..."})]});const We=B;return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Local Access"}),a.jsx("p",{className:"settings-section-description",children:"Control how this server is accessed on your local network."}),a.jsx("div",{className:"settings-group",children:a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Status"}),a.jsx("p",{children:l?(()=>{const Ie=d==null?void 0:d.network.host,je=(d==null?void 0:d.network.port)??l.port,Ze=Ie==="0.0.0.0"||Ie==="::",yt=je===l.port;return d!=null&&d.network.enabled&&Ze&&yt?a.jsxs(a.Fragment,{children:["Listening on"," ",a.jsxs("code",{children:[Ie,":",je]})]}):a.jsxs(a.Fragment,{children:["Listening on"," ",a.jsxs("code",{children:[l.host,":",l.port]}),(d==null?void 0:d.network.enabled)&&Ie&&a.jsxs(a.Fragment,{children:[" ","and"," ",a.jsxs("code",{children:[Ie,":",je]})]})]})})():"Unable to fetch server info"})]}),(l==null?void 0:l.localhostOnly)&&!(d!=null&&d.network.enabled)&&a.jsx("span",{className:"settings-status-badge settings-status-detected",children:"Local Only"}),((l==null?void 0:l.boundToAllInterfaces)||(d==null?void 0:d.network.enabled))&&!e.authEnabled&&a.jsx("span",{className:"settings-status-badge settings-status-warning",children:"Network Exposed"})]})}),a.jsxs("form",{className:"settings-group",onSubmit:Ie=>{Ie.preventDefault(),Ee()},children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Listening Port"}),a.jsx("p",{children:"Port used for all network access"})]}),d!=null&&d.localhost.overriddenByCli?a.jsxs("span",{className:"settings-value-readonly",children:[d.localhost.port," ",a.jsx("span",{className:"settings-hint",children:"(set via --port)"})]}):a.jsx("input",{type:"number",className:"settings-input-small",value:S,onChange:Ie=>{w(Ie.target.value),oe({port:Ie.target.value})},min:1,max:65535,autoComplete:"off"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Local Network Access"}),a.jsx("p",{children:"Allow access from other devices on your network"})]}),d!=null&&d.network.overriddenByCli?a.jsxs("span",{className:"settings-value-readonly",children:[d.network.host,":",d.network.port," ",a.jsx("span",{className:"settings-hint",children:"(set via --host)"})]}):a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:C,onChange:Ie=>{_(Ie.target.checked),oe({networkEnabled:Ie.target.checked})}}),a.jsx("span",{className:"toggle-slider"})]})]}),C&&!(d!=null&&d.network.overriddenByCli)&&d&&a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Interface"}),a.jsx("p",{children:"Select which network interface to bind to"})]}),a.jsx(Ta,{label:"Interface",placeholder:"Select interface...",multiSelect:!1,align:"right",options:[...d.interfaces.map(Ie=>({value:Ie.address,label:Ie.displayName})),{value:"0.0.0.0",label:"All interfaces (0.0.0.0)"},{value:"custom",label:"Custom IP..."}],selected:E?[E]:[],onChange:Ie=>{const je=Ie[0]??"";k(je),oe({iface:je})}})]}),C&&!(d!=null&&d.network.overriddenByCli)&&E==="custom"&&a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Custom IP"}),a.jsx("p",{children:"Enter the IP address to bind to"})]}),a.jsx("input",{type:"text",className:"settings-input",placeholder:"192.168.1.100",value:M,onChange:Ie=>O(Ie.target.value)})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Allow All Hostnames"}),a.jsx("p",{children:"Accept requests from any hostname (disables DNS rebinding protection)"})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:X,onChange:Ie=>{ge(Ie.target.checked),oe({allowAll:Ie.target.checked})}}),a.jsx("span",{className:"toggle-slider"})]})]}),!X&&a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Allowed Hostnames"}),a.jsx("p",{children:"Comma-separated list of additional allowed hostnames"})]}),a.jsx("input",{type:"text",className:"settings-input",placeholder:"mydomain.com, other.example.com",value:ee,onChange:Ie=>{ne(Ie.target.value),oe({hostsText:Ie.target.value})}})]}),a.jsx("p",{className:"form-hint",children:"localhost, private IPs, and *.ts.net are always allowed."}),!e.authDisabledByEnv&&a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Require Password"}),a.jsx("p",{children:"Require a password to access this server"})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:B,onChange:Ie=>{L(Ie.target.checked),oe({requirePw:Ie.target.checked})}}),a.jsx("span",{className:"toggle-slider"})]})]}),We&&a.jsxs(a.Fragment,{children:[a.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{position:"absolute",visibility:"hidden",pointerEvents:"none"},tabIndex:-1}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Password"}),a.jsx("p",{children:e.authEnabled?"Leave blank to keep current":"At least 6 characters"})]}),a.jsx("input",{type:"password",className:"settings-input",value:U,onChange:Ie=>{$(Ie.target.value),oe({password:Ie.target.value})},autoComplete:"new-password",placeholder:e.authEnabled?"New password":"Enter password"})]}),U.length>0&&a.jsxs("div",{className:"settings-item",children:[a.jsx("div",{className:"settings-item-info",children:a.jsx("strong",{children:"Confirm Password"})}),a.jsx("input",{type:"password",className:"settings-input",value:V,onChange:Ie=>F(Ie.target.value),autoComplete:"new-password",placeholder:"Confirm password"})]}),!e.authEnabled&&a.jsxs("p",{className:"form-hint",children:["If you forget your password, restart with"," ",a.jsx("code",{children:"--auth-disable"})," to bypass auth."]})]}),e.authDisabledByEnv&&a.jsx("p",{className:"form-warning",children:"Authentication is bypassed by --auth-disable flag."}),a.jsxs("div",{className:"settings-item",children:[Ne&&a.jsx("p",{className:"form-error",children:Ne}),a.jsx("button",{type:"submit",className:"settings-button",disabled:!D||G||p,children:G||p?"Applying...":"Apply Changes"})]})]}),e.authEnabled&&e.isAuthenticated&&a.jsx("div",{className:"settings-group",children:a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Logout"}),a.jsx("p",{children:"Sign out on this device"})]}),a.jsx("button",{type:"button",className:"settings-button settings-button-danger",onClick:e.logout,children:"Logout"})]})})]})}return n?a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Local Access"}),a.jsx("p",{className:"settings-section-description",children:"You are connected to a remote server via relay."}),a.jsxs("div",{className:"settings-group",children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Logout"}),a.jsx("p",{children:"Disconnect from the remote server."})]}),a.jsx("button",{type:"button",className:"settings-button settings-button-danger",onClick:()=>n.disconnect(),children:"Logout"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Relay Debug Logging"}),a.jsx("p",{children:"Log relay requests and responses to the browser console. Useful for debugging connection timeouts."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:r,onChange:Te=>o(Te.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]})]})]}):null}function u5(){const{model:e,setModel:n,thinkingLevel:r,setThinkingLevel:o}=Uc();return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Model"}),a.jsxs("div",{className:"settings-group",children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Model"}),a.jsx("p",{children:"Select which Claude model to use for new sessions."})]}),a.jsx("div",{className:"font-size-selector",children:kf.map(l=>a.jsx("button",{type:"button",className:`font-size-option ${e===l.value?"active":""}`,onClick:()=>n(l.value),children:l.label},l.value))})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Thinking Level"}),a.jsx("p",{children:"Token budget for extended thinking. Higher levels enable deeper reasoning but use more tokens."})]}),a.jsx("div",{className:"font-size-selector",children:T6.map(l=>a.jsxs("button",{type:"button",className:`font-size-option ${r===l.value?"active":""}`,onClick:()=>o(l.value),title:l.description,children:[l.label," (",l.description,")"]},l.value))})]})]})]})}function Zb(){const[e,n]=h.useState(()=>{const l=typeof window<"u"&&"Notification"in window,u=U6();return{isSupported:l&&!u,isMobile:u,permission:l?Notification.permission:"denied",isRequesting:!1}});h.useEffect(()=>{if(!e.isSupported)return;const l=()=>{const u=Notification.permission;u!==e.permission&&n(d=>({...d,permission:u}))};return window.addEventListener("focus",l),()=>window.removeEventListener("focus",l)},[e.isSupported,e.permission]);const r=h.useCallback(async()=>{if(e.isSupported&&e.permission!=="granted"){n(l=>({...l,isRequesting:!0}));try{const l=await Notification.requestPermission();n(u=>({...u,permission:l,isRequesting:!1}))}catch(l){console.error("[useBrowserNotifications] Permission request failed:",l),n(u=>({...u,isRequesting:!1}))}}},[e.isSupported,e.permission]),o=h.useCallback((l,u)=>{if(!e.isSupported||e.permission!=="granted")return!1;try{return new Notification(l,u),!0}catch(d){return console.error("[useBrowserNotifications] Failed to show notification:",d),!1}},[e.isSupported,e.permission]);return{...e,isEnabled:e.permission==="granted",isDenied:e.permission==="denied",requestPermission:r,showNotification:o}}function d5(){const{isSupported:e,isMobile:n,isEnabled:r,isDenied:o,isRequesting:l,requestPermission:u,showNotification:d}=Zb();if(n)return null;if(!e)return a.jsx("div",{className:"settings-item",children:a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Desktop Notifications"}),a.jsx("p",{children:"Notifications are not supported in this browser."})]})});if(o)return a.jsx("div",{className:"settings-item",children:a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Desktop Notifications"}),a.jsx("p",{className:"settings-warning",children:"Notifications are blocked. Enable them in your browser settings to receive desktop alerts."})]})});if(r){const f=()=>{d("Test Notification",{body:"Desktop notifications are working!",icon:"/icon-192.png"})};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Desktop Notifications"}),a.jsx("p",{children:"Enabled. You'll receive notifications when sessions need attention (while the tab is open)."})]}),a.jsx("span",{className:"settings-badge settings-badge-success",children:"Enabled"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Test Desktop Notification"}),a.jsx("p",{children:"Send a test notification to verify it's working."})]}),a.jsx("button",{type:"button",className:"settings-button",onClick:f,children:"Send Test"})]})]})}return a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Desktop Notifications"}),a.jsx("p",{children:"Get notified when sessions need your attention. Works while the tab is open in the background."})]}),a.jsx("button",{type:"button",className:"settings-button",onClick:u,disabled:l,children:l?"Requesting...":"Enable"})]})}function f5(){const{isSupported:e,isSubscribed:n,isLoading:r,error:o,permission:l,subscribe:u,unsubscribe:d,sendTest:f}=mh(),{notifyInApp:p,setNotifyInApp:x}=cT(),[v,y]=h.useState("normal"),S=async()=>{n?await d():await u()};if(!e){const w=o==null?void 0:o.includes("Service worker disabled in dev mode");return a.jsx("div",{className:"settings-item",children:a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Push Notifications"}),a.jsx("p",{children:o||"Push notifications are not supported in this browser."}),w&&a.jsxs("div",{className:"settings-info-box",style:{marginTop:"0.5rem"},children:[a.jsxs("p",{children:["This only affects ",a.jsx("strong",{children:"this device"}),". Other subscribed devices will still receive notifications from the server."]}),a.jsxs("p",{children:["To enable push on this device in dev mode, restart with"," ",a.jsx("code",{children:"VITE_ENABLE_SW=true"}),"."]})]}),a.jsx("p",{style:{marginTop:"0.5rem"},children:a.jsx("a",{href:"https://github.com/kzahel/yepanywhere/blob/main/docs/push-notifications.md",target:"_blank",rel:"noopener noreferrer",children:"Troubleshooting guide"})})]})})}return l==="denied"?a.jsx("div",{className:"settings-item",children:a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Push Notifications"}),a.jsx("p",{className:"settings-warning",children:"Notifications are blocked. Enable them in your browser settings to receive push notifications."})]})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Push Notifications"}),a.jsx("p",{children:"Receive notifications when a session needs your attention, even when the app is in the background."}),o&&a.jsx("p",{className:"settings-error",children:o})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:n,onChange:S,disabled:r}),a.jsx("span",{className:"toggle-slider"})]})]}),n&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Notify When In App"}),a.jsx("p",{children:"Show notifications even when the app is open, as long as you're not viewing that session."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:p,onChange:w=>x(w.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Test Notification"}),a.jsx("p",{children:"Send a test notification to verify push is working."})]}),a.jsxs("div",{className:"settings-item-actions",children:[a.jsxs("select",{className:"settings-select",value:v,onChange:w=>y(w.target.value),disabled:r,children:[a.jsx("option",{value:"normal",children:"Normal (auto-dismiss)"}),a.jsx("option",{value:"persistent",children:"Persistent (stays visible)"}),a.jsx("option",{value:"silent",children:"Silent (no sound)"})]}),a.jsx("button",{type:"button",className:"settings-button",onClick:()=>f(v),disabled:r,children:r?"Sending...":"Send Test"})]})]})]})]})}function h5(){const[e,n]=h.useState({settings:null,isLoading:!0,error:null});h.useEffect(()=>{(async()=>{try{const{settings:l}=await Ae.getNotificationSettings();n({settings:l,isLoading:!1,error:null})}catch(l){console.error("[useNotificationSettings] Failed to fetch:",l),n(u=>({...u,isLoading:!1,error:l instanceof Error?l.message:"Failed to load settings"}))}})()},[]);const r=h.useCallback(async(o,l)=>{n(u=>({...u,isLoading:!0,error:null}));try{const{settings:u}=await Ae.updateNotificationSettings({[o]:l});n({settings:u,isLoading:!1,error:null})}catch(u){console.error("[useNotificationSettings] Failed to update:",u),n(d=>({...d,isLoading:!1,error:u instanceof Error?u.message:"Failed to update"}))}},[]);return{...e,updateSetting:r}}function m5(){const[e,n]=h.useState({devices:[],isLoading:!0,error:null}),r=h.useCallback(async()=>{n(l=>({...l,isLoading:!0,error:null}));try{const{subscriptions:l}=await Ae.getPushSubscriptions();n({devices:l,isLoading:!1,error:null})}catch(l){console.error("[useSubscribedDevices] Failed to fetch:",l),n(u=>({...u,isLoading:!1,error:l instanceof Error?l.message:"Failed to load devices"}))}},[]);h.useEffect(()=>{r()},[r]);const o=h.useCallback(async l=>{n(u=>({...u,isLoading:!0,error:null}));try{await Ae.deletePushSubscription(l),await r()}catch(u){console.error("[useSubscribedDevices] Failed to remove:",u),n(d=>({...d,isLoading:!1,error:u instanceof Error?u.message:"Failed to remove device"}))}},[r]);return{...e,removeDevice:o,refetch:r}}function p5(e,n){const r=e||"Unknown device";return n!=null&&n.includes("google")?{displayName:r,browserType:"(Android/Chrome)"}:n!=null&&n.includes("apple")||n!=null&&n.includes("push.apple")?{displayName:r,browserType:"(iOS/Safari)"}:n!=null&&n.includes("mozilla")||n!=null&&n.includes("push.services.mozilla")?{displayName:r,browserType:"(Firefox)"}:{displayName:r,browserType:""}}function g5(e){const n=new Date(e),o=new Date().getTime()-n.getTime(),l=Math.floor(o/(1e3*60*60*24));return l===0?"today":l===1?"yesterday":l<7?`${l} days ago`:n.toLocaleDateString()}function x5(e,n,r){const o=new Map;for(const u of e){const{displayName:d,browserType:f}=p5(u.deviceName,u.endpointDomain),p=n.get(u.browserProfileId);o.set(u.browserProfileId,{browserProfileId:u.browserProfileId,displayName:d,browserType:f,isSubscribed:!0,isConnected:!!p,tabCount:(p==null?void 0:p.connectionCount)??0,subscribedAt:u.createdAt,isCurrentDevice:u.browserProfileId===r})}for(const[u,d]of n)if(!o.has(u)){const f=u.slice(0,8);o.set(u,{browserProfileId:u,displayName:f,browserType:"",isSubscribed:!1,isConnected:!0,tabCount:d.connectionCount,isCurrentDevice:u===r})}const l=Array.from(o.values());return l.sort((u,d)=>u.isCurrentDevice&&!d.isCurrentDevice?-1:!u.isCurrentDevice&&d.isCurrentDevice?1:u.isConnected&&!d.isConnected?-1:!u.isConnected&&d.isConnected?1:u.isConnected&&d.isConnected?d.tabCount-u.tabCount:u.subscribedAt&&d.subscribedAt?new Date(d.subscribedAt).getTime()-new Date(u.subscribedAt).getTime():0),l}function v5(){const{browserProfileId:e}=mh(),{isMobile:n}=Zb(),{devices:r,isLoading:o,removeDevice:l}=m5(),{connections:u,isLoading:d}=qb(),{settings:f,isLoading:p,updateSetting:x}=h5(),v=r.length>0,y=o||d,S=x5(r,u,e);return a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Server Notification Types"}),a.jsx("p",{className:"settings-section-description",children:"Control what types of events trigger push notifications to all devices."}),a.jsxs("div",{className:"settings-group",children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Tool Approvals"}),a.jsx("p",{children:"Notify when Claude needs permission to run a tool (file edits, commands, etc.)"})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:(f==null?void 0:f.toolApproval)??!0,onChange:w=>x("toolApproval",w.target.checked),disabled:p||!v}),a.jsx("span",{className:"toggle-slider"})]})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"User Questions"}),a.jsx("p",{children:"Notify when Claude asks a question and needs your response."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:(f==null?void 0:f.userQuestion)??!0,onChange:w=>x("userQuestion",w.target.checked),disabled:p||!v}),a.jsx("span",{className:"toggle-slider"})]})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Session Halted"}),a.jsx("p",{children:"Notify when a session completes, errors out, or becomes idle."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:(f==null?void 0:f.sessionHalted)??!0,onChange:w=>x("sessionHalted",w.target.checked),disabled:p||!v}),a.jsx("span",{className:"toggle-slider"})]})]}),!v&&!o&&a.jsx("p",{className:"settings-hint",children:"No devices subscribed. Enable push notifications below to use these settings."})]})]}),!n&&a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Desktop Notifications"}),a.jsx("p",{className:"settings-section-description",children:"Get browser notifications when sessions need attention. Works while the tab is open."}),a.jsx("div",{className:"settings-group",children:a.jsx(d5,{})})]}),a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Push Notifications"}),a.jsx("p",{className:"settings-section-description",children:"Receive push notifications even when the browser is closed or you're on another device."}),a.jsx("div",{className:"settings-group",children:a.jsx(f5,{})})]}),a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Devices"}),a.jsx("p",{className:"settings-section-description",children:"All devices connected to or subscribed to this server."}),a.jsx("div",{className:"settings-group",children:y?a.jsx("p",{className:"settings-hint",children:"Loading devices..."}):S.length===0?a.jsx("p",{className:"settings-hint",children:"No devices connected or subscribed. Enable push notifications above."}):a.jsx("div",{className:"device-list",children:S.map(w=>a.jsxs("div",{className:"device-list-item",children:[a.jsxs("div",{className:"device-list-info",children:[a.jsxs("strong",{children:[w.displayName,w.browserType&&` ${w.browserType}`,w.isCurrentDevice&&a.jsx("span",{className:"device-current-badge",children:"This device"})]}),a.jsxs("p",{children:[w.isConnected?a.jsx("span",{className:"device-status device-status-online",children:w.tabCount===1?"1 tab":`${w.tabCount} tabs`}):a.jsx("span",{className:"device-status device-status-offline",children:"Offline"}),!w.isSubscribed&&a.jsx("span",{className:"device-no-push",children:"No push"}),w.subscribedAt&&a.jsxs("span",{className:"device-subscribed-date",children:["Subscribed ",g5(w.subscribedAt)]})]})]}),w.isSubscribed&&a.jsx("button",{type:"button",className:"settings-button settings-button-danger-subtle",onClick:()=>l(w.browserProfileId),title:w.isCurrentDevice?"Unsubscribe this device":"Remove this device",children:"Remove"})]},w.browserProfileId))})})]})]})}function b5(){const{providers:e}=uh(),r=ZT().map(o=>{const l=e.find(u=>u.name===o.id);return{...o,installed:(l==null?void 0:l.installed)??!1,authenticated:(l==null?void 0:l.authenticated)??!1}});return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Providers"}),a.jsx("p",{className:"settings-section-description",children:"AI providers are auto-detected when their CLI is installed."}),a.jsx("div",{className:"settings-group",children:r.map(o=>a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsxs("div",{className:"settings-item-header",children:[a.jsx("strong",{children:o.displayName}),o.installed?a.jsx("span",{className:"settings-status-badge settings-status-detected",children:"Detected"}):a.jsx("span",{className:"settings-status-badge settings-status-not-detected",children:"Not Detected"})]}),a.jsx("p",{children:o.metadata.description}),o.metadata.limitations.length>0&&a.jsx("ul",{className:"settings-limitations",children:o.metadata.limitations.map(l=>a.jsx("li",{children:l},l))})]}),o.metadata.website&&a.jsx("a",{href:o.metadata.website,target:"_blank",rel:"noopener noreferrer",className:"settings-link",children:"Website"})]},o.id))})]})}function y5(){const[e,n]=h.useState(null),[r,o]=h.useState(null),[l,u]=h.useState(null),[d,f]=h.useState([]),[p,x]=h.useState(!0),[v,y]=h.useState(null),S=h.useCallback(async()=>{try{const[L,U,$,V]=await Promise.all([Ue("/remote-access/config"),Ue("/remote-access/relay"),Ue("/remote-access/relay/status"),Ue("/remote-access/sessions")]);n(L),o(U.relay),u($),f(V.sessions),y(null)}catch(L){console.error("[useRemoteAccess] Failed to fetch config:",L),y(L instanceof Error?L.message:"Failed to fetch config")}},[]);h.useEffect(()=>{x(!0),S().finally(()=>x(!1))},[S]);const w=h.useCallback(async L=>{try{await Ue("/remote-access/configure",{method:"POST",body:JSON.stringify({password:L})}),await S()}catch(U){const $=U instanceof Error?U.message:"Failed to configure remote access";throw y($),new Error($)}},[S]),C=h.useCallback(async()=>{try{await Ue("/remote-access/enable",{method:"POST"}),await S()}catch(L){const U=L instanceof Error?L.message:"Failed to enable remote access";throw y(U),new Error(U)}},[S]),_=h.useCallback(async()=>{try{await Ue("/remote-access/disable",{method:"POST"}),await S()}catch(L){const U=L instanceof Error?L.message:"Failed to disable remote access";throw y(U),new Error(U)}},[S]),E=h.useCallback(async()=>{try{await Ue("/remote-access/clear",{method:"POST"}),await S()}catch(L){const U=L instanceof Error?L.message:"Failed to clear remote access credentials";throw y(U),new Error(U)}},[S]),k=h.useCallback(async L=>{try{await Ue("/remote-access/relay",{method:"PUT",body:JSON.stringify(L)}),await S()}catch(U){const $=U instanceof Error?U.message:"Failed to update relay configuration";throw y($),new Error($)}},[S]),M=h.useCallback(async()=>{try{await Ue("/remote-access/relay",{method:"DELETE"}),await S()}catch(L){const U=L instanceof Error?L.message:"Failed to clear relay configuration";throw y(U),new Error(U)}},[S]),O=h.useCallback(async L=>{try{await Ue(`/remote-access/sessions/${L}`,{method:"DELETE"}),await S()}catch(U){const $=U instanceof Error?U.message:"Failed to revoke session";throw y($),new Error($)}},[S]),B=h.useCallback(async()=>{try{await Ue("/remote-access/sessions",{method:"DELETE"}),await S()}catch(L){const U=L instanceof Error?L.message:"Failed to revoke all sessions";throw y(U),new Error(U)}},[S]);return{config:e,relayConfig:r,relayStatus:l,sessions:d,loading:p,error:v,configure:w,enable:C,disable:_,clearCredentials:E,updateRelayConfig:k,clearRelayConfig:M,revokeSession:O,revokeAllSessions:B,refresh:S}}var Ca=(e=>(e[e.Border=-1]="Border",e[e.Data=0]="Data",e[e.Function=1]="Function",e[e.Position=2]="Position",e[e.Timing=3]="Timing",e[e.Alignment=4]="Alignment",e))(Ca||{}),S5=Object.defineProperty,j5=(e,n,r)=>n in e?S5(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,hc=(e,n,r)=>(j5(e,typeof n!="symbol"?n+"":n,r),r);const w5=[0,1],Vb=[1,0],Gb=[2,3],Yb=[3,2],N5={L:w5,M:Vb,Q:Gb,H:Yb},_5=/^[0-9]*$/,E5=/^[A-Z0-9 $%*+.\/:-]*$/,xf="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",ph=1,gh=40,Mv=3,C5=3,mc=40,k5=10,Wb=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],Xb=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];class T5{constructor(n,r,o,l){if(this.version=n,this.ecc=r,hc(this,"size"),hc(this,"mask"),hc(this,"modules",[]),hc(this,"types",[]),n<ph||n>gh)throw new RangeError("Version value out of range");if(l<-1||l>7)throw new RangeError("Mask value out of range");this.size=n*4+17;const u=Array.from({length:this.size},()=>!1);for(let f=0;f<this.size;f++)this.modules.push(u.slice()),this.types.push(u.map(()=>0));this.drawFunctionPatterns();const d=this.addEccAndInterleave(o);if(this.drawCodewords(d),l===-1){let f=1e9;for(let p=0;p<8;p++){this.applyMask(p),this.drawFormatBits(p);const x=this.getPenaltyScore();x<f&&(l=p,f=x),this.applyMask(p)}}this.mask=l,this.applyMask(l),this.drawFormatBits(l)}getModule(n,r){return n>=0&&n<this.size&&r>=0&&r<this.size&&this.modules[r][n]}drawFunctionPatterns(){for(let o=0;o<this.size;o++)this.setFunctionModule(6,o,o%2===0,Ca.Timing),this.setFunctionModule(o,6,o%2===0,Ca.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const n=this.getAlignmentPatternPositions(),r=n.length;for(let o=0;o<r;o++)for(let l=0;l<r;l++)o===0&&l===0||o===0&&l===r-1||o===r-1&&l===0||this.drawAlignmentPattern(n[o],n[l]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(n){const r=this.ecc[1]<<3|n;let o=r;for(let u=0;u<10;u++)o=o<<1^(o>>>9)*1335;const l=(r<<10|o)^21522;for(let u=0;u<=5;u++)this.setFunctionModule(8,u,Nr(l,u));this.setFunctionModule(8,7,Nr(l,6)),this.setFunctionModule(8,8,Nr(l,7)),this.setFunctionModule(7,8,Nr(l,8));for(let u=9;u<15;u++)this.setFunctionModule(14-u,8,Nr(l,u));for(let u=0;u<8;u++)this.setFunctionModule(this.size-1-u,8,Nr(l,u));for(let u=8;u<15;u++)this.setFunctionModule(8,this.size-15+u,Nr(l,u));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let n=this.version;for(let o=0;o<12;o++)n=n<<1^(n>>>11)*7973;const r=this.version<<12|n;for(let o=0;o<18;o++){const l=Nr(r,o),u=this.size-11+o%3,d=Math.floor(o/3);this.setFunctionModule(u,d,l),this.setFunctionModule(d,u,l)}}drawFinderPattern(n,r){for(let o=-4;o<=4;o++)for(let l=-4;l<=4;l++){const u=Math.max(Math.abs(l),Math.abs(o)),d=n+l,f=r+o;d>=0&&d<this.size&&f>=0&&f<this.size&&this.setFunctionModule(d,f,u!==2&&u!==4,Ca.Position)}}drawAlignmentPattern(n,r){for(let o=-2;o<=2;o++)for(let l=-2;l<=2;l++)this.setFunctionModule(n+l,r+o,Math.max(Math.abs(l),Math.abs(o))!==1,Ca.Alignment)}setFunctionModule(n,r,o,l=Ca.Function){this.modules[r][n]=o,this.types[r][n]=l}addEccAndInterleave(n){const r=this.version,o=this.ecc;if(n.length!==yc(r,o))throw new RangeError("Invalid argument");const l=Xb[o[0]][r],u=Wb[o[0]][r],d=Math.floor(zf(r)/8),f=l-d%l,p=Math.floor(d/l),x=[],v=B5(u);for(let S=0,w=0;S<l;S++){const C=n.slice(w,w+p-u+(S<f?0:1));w+=C.length;const _=I5(C,v);S<f&&C.push(0),x.push(C.concat(_))}const y=[];for(let S=0;S<x[0].length;S++)x.forEach((w,C)=>{(S!==p-u||C>=f)&&y.push(w[S])});return y}drawCodewords(n){if(n.length!==Math.floor(zf(this.version)/8))throw new RangeError("Invalid argument");let r=0;for(let o=this.size-1;o>=1;o-=2){o===6&&(o=5);for(let l=0;l<this.size;l++)for(let u=0;u<2;u++){const d=o-u,p=(o+1&2)===0?this.size-1-l:l;!this.types[p][d]&&r<n.length*8&&(this.modules[p][d]=Nr(n[r>>>3],7-(r&7)),r++)}}}applyMask(n){if(n<0||n>7)throw new RangeError("Mask value out of range");for(let r=0;r<this.size;r++)for(let o=0;o<this.size;o++){let l;switch(n){case 0:l=(o+r)%2===0;break;case 1:l=r%2===0;break;case 2:l=o%3===0;break;case 3:l=(o+r)%3===0;break;case 4:l=(Math.floor(o/3)+Math.floor(r/2))%2===0;break;case 5:l=o*r%2+o*r%3===0;break;case 6:l=(o*r%2+o*r%3)%2===0;break;case 7:l=((o+r)%2+o*r%3)%2===0;break;default:throw new Error("Unreachable")}!this.types[r][o]&&l&&(this.modules[r][o]=!this.modules[r][o])}}getPenaltyScore(){let n=0;for(let u=0;u<this.size;u++){let d=!1,f=0;const p=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[u][x]===d?(f++,f===5?n+=Mv:f>5&&n++):(this.finderPenaltyAddHistory(f,p),d||(n+=this.finderPenaltyCountPatterns(p)*mc),d=this.modules[u][x],f=1);n+=this.finderPenaltyTerminateAndCount(d,f,p)*mc}for(let u=0;u<this.size;u++){let d=!1,f=0;const p=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][u]===d?(f++,f===5?n+=Mv:f>5&&n++):(this.finderPenaltyAddHistory(f,p),d||(n+=this.finderPenaltyCountPatterns(p)*mc),d=this.modules[x][u],f=1);n+=this.finderPenaltyTerminateAndCount(d,f,p)*mc}for(let u=0;u<this.size-1;u++)for(let d=0;d<this.size-1;d++){const f=this.modules[u][d];f===this.modules[u][d+1]&&f===this.modules[u+1][d]&&f===this.modules[u+1][d+1]&&(n+=C5)}let r=0;for(const u of this.modules)r=u.reduce((d,f)=>d+(f?1:0),r);const o=this.size*this.size,l=Math.ceil(Math.abs(r*20-o*10)/o)-1;return n+=l*k5,n}getAlignmentPatternPositions(){if(this.version===1)return[];{const n=Math.floor(this.version/7)+2,r=this.version===32?26:Math.ceil((this.version*4+4)/(n*2-2))*2,o=[6];for(let l=this.size-7;o.length<n;l-=r)o.splice(1,0,l);return o}}finderPenaltyCountPatterns(n){const r=n[1],o=r>0&&n[2]===r&&n[3]===r*3&&n[4]===r&&n[5]===r;return(o&&n[0]>=r*4&&n[6]>=r?1:0)+(o&&n[6]>=r*4&&n[0]>=r?1:0)}finderPenaltyTerminateAndCount(n,r,o){return n&&(this.finderPenaltyAddHistory(r,o),r=0),r+=this.size,this.finderPenaltyAddHistory(r,o),this.finderPenaltyCountPatterns(o)}finderPenaltyAddHistory(n,r){r[0]===0&&(n+=this.size),r.pop(),r.unshift(n)}}function Er(e,n,r){if(n<0||n>31||e>>>n)throw new RangeError("Value out of range");for(let o=n-1;o>=0;o--)r.push(e>>>o&1)}function Nr(e,n){return(e>>>n&1)!==0}class xh{constructor(n,r,o){if(this.mode=n,this.numChars=r,this.bitData=o,r<0)throw new RangeError("Invalid argument");this.bitData=o.slice()}getData(){return this.bitData.slice()}}const R5=[1,10,12,14],A5=[2,9,11,13],M5=[4,8,16,16];function Kb(e,n){return e[Math.floor((n+7)/17)+1]}function Jb(e){const n=[];for(const r of e)Er(r,8,n);return new xh(M5,e.length,n)}function O5(e){if(!Qb(e))throw new RangeError("String contains non-numeric characters");const n=[];for(let r=0;r<e.length;){const o=Math.min(e.length-r,3);Er(Number.parseInt(e.substring(r,r+o),10),o*3+1,n),r+=o}return new xh(R5,e.length,n)}function z5(e){if(!ey(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");const n=[];let r;for(r=0;r+2<=e.length;r+=2){let o=xf.indexOf(e.charAt(r))*45;o+=xf.indexOf(e.charAt(r+1)),Er(o,11,n)}return r<e.length&&Er(xf.indexOf(e.charAt(r)),6,n),new xh(A5,e.length,n)}function L5(e){return e===""?[]:Qb(e)?[O5(e)]:ey(e)?[z5(e)]:[Jb(D5(e))]}function Qb(e){return _5.test(e)}function ey(e){return E5.test(e)}function U5(e,n){let r=0;for(const o of e){const l=Kb(o.mode,n);if(o.numChars>=1<<l)return Number.POSITIVE_INFINITY;r+=4+l+o.bitData.length}return r}function D5(e){e=encodeURI(e);const n=[];for(let r=0;r<e.length;r++)e.charAt(r)!=="%"?n.push(e.charCodeAt(r)):(n.push(Number.parseInt(e.substring(r+1,r+3),16)),r+=2);return n}function zf(e){if(e<ph||e>gh)throw new RangeError("Version number out of range");let n=(16*e+128)*e+64;if(e>=2){const r=Math.floor(e/7)+2;n-=(25*r-10)*r-55,e>=7&&(n-=36)}return n}function yc(e,n){return Math.floor(zf(e)/8)-Wb[n[0]][e]*Xb[n[0]][e]}function B5(e){if(e<1||e>255)throw new RangeError("Degree out of range");const n=[];for(let o=0;o<e-1;o++)n.push(0);n.push(1);let r=1;for(let o=0;o<e;o++){for(let l=0;l<n.length;l++)n[l]=Lf(n[l],r),l+1<n.length&&(n[l]^=n[l+1]);r=Lf(r,2)}return n}function I5(e,n){const r=n.map(o=>0);for(const o of e){const l=o^r.shift();r.push(0),n.forEach((u,d)=>r[d]^=Lf(u,l))}return r}function Lf(e,n){if(e>>>8||n>>>8)throw new RangeError("Byte out of range");let r=0;for(let o=7;o>=0;o--)r=r<<1^(r>>>7)*285,r^=(n>>>o&1)*e;return r}function $5(e,n,r=1,o=40,l=-1,u=!0){if(!(ph<=r&&r<=o&&o<=gh)||l<-1||l>7)throw new RangeError("Invalid value");let d,f;for(d=r;;d++){const y=yc(d,n)*8,S=U5(e,d);if(S<=y){f=S;break}if(d>=o)throw new RangeError("Data too long")}for(const y of[Vb,Gb,Yb])u&&f<=yc(d,y)*8&&(n=y);const p=[];for(const y of e){Er(y.mode[0],4,p),Er(y.numChars,Kb(y.mode,d),p);for(const S of y.getData())p.push(S)}const x=yc(d,n)*8;Er(0,Math.min(4,x-p.length),p),Er(0,(8-p.length%8)%8,p);for(let y=236;p.length<x;y^=253)Er(y,8,p);const v=Array.from({length:Math.ceil(p.length/8)},()=>0);return p.forEach((y,S)=>v[S>>>3]|=y<<7-(S&7)),new T5(d,n,v,l)}function P5(e,n){const{ecc:r="L",boostEcc:o=!1,minVersion:l=1,maxVersion:u=40,maskPattern:d=-1,border:f=1}={},p=typeof e=="string"?L5(e):Array.isArray(e)?[Jb(e)]:void 0;if(!p)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);const x=$5(p,N5[r],l,u,d,o);return H5({version:x.version,maskPattern:x.mask,size:x.size,data:x.modules,types:x.types},f)}function H5(e,n=1){if(!n)return e;const{size:r}=e,o=r+n*2;e.size=o,e.data.forEach(u=>{for(let d=0;d<n;d++)u.unshift(!1),u.push(!1)});for(let u=0;u<n;u++)e.data.unshift(Array.from({length:o},d=>!1)),e.data.push(Array.from({length:o},d=>!1));const l=Ca.Border;e.types.forEach(u=>{for(let d=0;d<n;d++)u.unshift(l),u.push(l)});for(let u=0;u<n;u++)e.types.unshift(Array.from({length:o},d=>l)),e.types.push(Array.from({length:o},d=>l));return e}function F5({value:e,size:n=200,color:r="#000000",bgColor:o="#ffffff"}){const{data:l}=P5(e),u=l.length,d=n/u;let f="";for(let p=0;p<u;p++){const x=l[p];if(x){for(let v=0;v<u;v++)if(x[v]){const y=v*d,S=p*d;f+=`M${y},${S}h${d}v${d}h-${d}z`}}}return a.jsxs("svg",{width:n,height:n,viewBox:`0 0 ${n} ${n}`,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"QR code",children:[a.jsx("rect",{width:n,height:n,fill:o}),a.jsx("path",{d:f,fill:r})]})}const mi="wss://relay.yepanywhere.com/ws",vf="https://yepanywhere.com/remote/login/relay";function Ov(e){const n=new Date(e),o=new Date().getTime()-n.getTime(),l=Math.floor(o/(1e3*60)),u=Math.floor(o/(1e3*60*60)),d=Math.floor(o/(1e3*60*60*24));return l<1?"just now":l<60?`${l} minute${l===1?"":"s"} ago`:u<24?`${u} hour${u===1?"":"s"} ago`:d===1?"yesterday":d<7?`${d} days ago`:n.toLocaleDateString()}function q5(e,n,r){if(!n)return{text:"Disabled",className:"status-disabled"};if(!r)return{text:"Not configured",className:"status-warning"};switch(e){case"waiting":return{text:"Connected",className:"status-success"};case"connecting":return{text:"Connecting...",className:"status-pending"};case"registering":return{text:"Registering...",className:"status-pending"};case"rejected":return{text:"Username taken",className:"status-error"};default:return{text:"Disconnected",className:"status-warning"}}}function Z5({title:e="Remote Access",description:n="Access your server from anywhere.",onSetupComplete:r}){const{config:o,relayConfig:l,relayStatus:u,sessions:d,loading:f,error:p,configure:x,enable:v,disable:y,updateRelayConfig:S,revokeSession:w,revokeAllSessions:C,refresh:_}=y5(),[E,k]=h.useState(""),[M,O]=h.useState(""),[B,L]=h.useState(""),[U,$]=h.useState("default"),[V,F]=h.useState(""),[X,ge]=h.useState(!1),[ee,ne]=h.useState(null),[Ne,ke]=h.useState(!1),[D,q]=h.useState(!1),[G,Se]=h.useState(null),[Me,I]=h.useState(!1);h.useEffect(()=>{l&&(k(l.username),l.url===mi?($("default"),F("")):($("custom"),F(l.url)))},[l]),h.useEffect(()=>{const _e=E!==((l==null?void 0:l.username)??""),mt=M.length>0,pt=U==="default"?mi:V,Lt=(l==null?void 0:l.url)??mi;q(_e||mt||pt!==Lt)},[E,M,U,V,l]),h.useEffect(()=>{if((u==null?void 0:u.status)==="connecting"||(u==null?void 0:u.status)==="registering"){const _e=setInterval(_,2e3);return()=>clearInterval(_e)}},[u==null?void 0:u.status,_]);const re=(o==null?void 0:o.enabled)??!1,he=!!(o!=null&&o.username),oe=()=>U==="default"?mi:V,Ee=async()=>{if(ne(null),!E.trim())return ne("Username is required"),!1;if(E.length<3)return ne("Username must be at least 3 characters"),!1;if(!he&&!M)return ne("Password is required"),!1;if(M&&M.length<8)return ne("Password must be at least 8 characters"),!1;if(M&&M!==B)return ne("Passwords do not match"),!1;if(U==="custom"&&!V.trim())return ne("Custom relay URL is required"),!1;try{const _e=oe();return(E!==(l==null?void 0:l.username)||_e!==(l==null?void 0:l.url))&&await S({url:_e,username:E}),M&&(await x(M),Se(M)),O(""),L(""),q(!1),!0}catch(_e){return ne(_e instanceof Error?_e.message:"Failed to save"),!1}},Te=async _e=>{ne(null),ge(!0);try{if(_e)if(D){if(!await Ee()){ge(!1);return}r==null||r()}else he&&(await v(),r==null||r());else await y()}catch(mt){ne(mt instanceof Error?mt.message:"Failed to update")}finally{ge(!1)}},We=async _e=>{_e.preventDefault(),ge(!0),await Ee()&&(r==null||r()),ge(!1)},Ie=async _e=>{await navigator.clipboard.writeText(_e),ke(!0),setTimeout(()=>ke(!1),2e3)};if(f)return a.jsxs("div",{className:"remote-access-setup",children:[a.jsx("div",{className:"remote-access-header",children:a.jsxs("div",{children:[a.jsx("h3",{children:e}),a.jsx("p",{children:n})]})}),a.jsx("div",{className:"remote-access-loading",children:"Loading..."})]});const je=q5((u==null?void 0:u.status)??null,re,he),Ze=(()=>{const _e=new URLSearchParams;E&&_e.set("u",E);const mt=oe();mt!==mi&&_e.set("r",mt);const pt=_e.toString();return pt?`${vf}?${pt}`:vf})(),yt=(()=>{if(!G||!E)return null;const _e=new URLSearchParams;_e.set("u",E),_e.set("p",G);const mt=oe();return mt!==mi&&_e.set("r",mt),`${vf}#${_e.toString()}`})(),be=re&&(u==null?void 0:u.status)==="waiting"&&yt!==null,St=he||E&&M;return a.jsxs("div",{className:"remote-access-setup",children:[a.jsxs("div",{className:"remote-access-header",children:[a.jsxs("div",{children:[a.jsx("h3",{children:e}),a.jsx("p",{children:n})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:re,onChange:_e=>Te(_e.target.checked),disabled:X||!re&&!St}),a.jsx("span",{className:"toggle-slider"})]})]}),a.jsxs("form",{onSubmit:We,className:"remote-access-form",children:[a.jsxs("div",{className:"form-field",children:[a.jsx("label",{htmlFor:"remote-username",children:"Username"}),a.jsx("input",{id:"remote-username",type:"text",value:E,onChange:_e=>k(_e.target.value.toLowerCase()),placeholder:"my-server",minLength:3,maxLength:32,pattern:"[a-z0-9][a-z0-9-]*[a-z0-9]|[a-z0-9]{1,2}",title:"Lowercase letters, numbers, and hyphens only",autoComplete:"username",disabled:X})]}),a.jsxs("div",{className:"form-field",children:[a.jsx("label",{htmlFor:"remote-password",children:he?"New Password (leave blank to keep)":"Password"}),a.jsx("input",{id:"remote-password",type:"password",value:M,onChange:_e=>O(_e.target.value),placeholder:he?"••••••••":"",minLength:8,autoComplete:"new-password",disabled:X})]}),M&&a.jsxs("div",{className:"form-field",children:[a.jsx("label",{htmlFor:"remote-confirm",children:"Confirm Password"}),a.jsx("input",{id:"remote-confirm",type:"password",value:B,onChange:_e=>L(_e.target.value),minLength:8,autoComplete:"new-password",disabled:X})]}),a.jsxs("div",{className:"form-field",children:[a.jsx("label",{htmlFor:"relay-select",children:"Relay Server"}),a.jsxs("select",{id:"relay-select",value:U,onChange:_e=>$(_e.target.value),disabled:X,className:"form-select",children:[a.jsx("option",{value:"default",children:"Default"}),a.jsx("option",{value:"custom",children:"Custom"})]})]}),U==="custom"&&a.jsxs("div",{className:"form-field",children:[a.jsx("label",{htmlFor:"custom-relay-url",children:"Custom Relay URL"}),a.jsx("input",{id:"custom-relay-url",type:"text",value:V,onChange:_e=>F(_e.target.value),placeholder:"wss://your-relay.example.com/ws",disabled:X})]}),a.jsxs("div",{className:"remote-access-status",children:[a.jsx("span",{className:"status-label",children:"Status:"}),a.jsx("span",{className:`status-indicator ${je.className}`,children:je.text}),(u==null?void 0:u.error)&&a.jsx("span",{className:"status-error-detail",children:u.error})]}),(ee||p)&&a.jsx("p",{className:"form-error",children:ee||p}),re&&E&&a.jsxs("div",{className:"remote-access-connect",children:[a.jsx("span",{className:"connect-label",children:"Connect from:"}),a.jsxs("div",{className:"connect-url-row",children:[a.jsx("code",{className:"connect-url",children:Ze}),a.jsx("button",{type:"button",className:"copy-button",onClick:()=>Ie(Ze),title:"Copy URL",children:Ne?"Copied!":"Copy"})]})]}),be&&a.jsxs("div",{className:"remote-access-qr",children:[a.jsx("button",{type:"button",className:"qr-toggle-button",onClick:()=>I(!Me),children:Me?"Hide QR Code":"Show QR Code"}),Me&&yt&&a.jsxs("div",{className:"qr-code-container",children:[a.jsx(F5,{value:yt,size:200}),a.jsx("p",{className:"qr-code-hint",children:"Scan to connect and auto-login from your phone"})]})]}),a.jsxs("div",{className:"remote-access-sessions",children:[a.jsxs("div",{className:"sessions-header",children:[a.jsxs("span",{className:"sessions-title",children:["Sessions (",d.length,")"]}),d.length>0&&a.jsx("button",{type:"button",className:"revoke-all-button",onClick:()=>C(),disabled:X,children:"Revoke All"})]}),d.length===0?a.jsx("p",{className:"sessions-empty",children:"No sessions"}):a.jsx("ul",{className:"sessions-list",children:d.map(_e=>{const{browser:mt,os:pt}=_e.userAgent?K0(_e.userAgent):{browser:"Unknown",os:"Unknown"},Lt=_e.userAgent||_e.origin;return a.jsxs("li",{className:"session-item",children:[a.jsx("div",{className:"session-info",children:Lt?a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"session-device",children:[mt," · ",pt]}),_e.origin&&a.jsx("code",{className:"session-origin",children:_e.origin}),a.jsxs("span",{className:"session-dates",children:["Created ",Ov(_e.createdAt)," · Last used ",Ov(_e.lastUsed)]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"session-created",children:["Created:"," ",new Date(_e.createdAt).toLocaleDateString()]}),a.jsxs("span",{className:"session-last-used",children:["Last used:"," ",new Date(_e.lastUsed).toLocaleDateString()]})]})}),a.jsx("button",{type:"button",className:"revoke-button",onClick:()=>w(_e.sessionId),disabled:X,children:"Revoke"})]},_e.sessionId)})})]}),a.jsx("div",{className:"remote-access-actions",children:a.jsx("button",{type:"submit",className:"settings-button",disabled:X||!D,children:X?"Saving...":"Save"})})]})]})}function V5(){const e=us(),n=Lc(),r=()=>{n==null||n.disconnect(),e("/login")};if(n){const o=n.currentHostId?C6(n.currentHostId):null,l=(o==null?void 0:o.displayName)||n.storedUsername||"Remote server";return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Remote Access"}),a.jsx("p",{className:"settings-section-description",children:"You are connected to a remote server via relay."}),a.jsxs("div",{className:"settings-group",children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Current Host"}),a.jsx("p",{children:l})]}),a.jsx("button",{type:"button",className:"settings-button",onClick:r,children:"Switch Host"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Logout"}),a.jsx("p",{children:"Disconnect from the remote server"})]}),a.jsx("button",{type:"button",className:"settings-button settings-button-danger",onClick:()=>n.disconnect(),children:"Logout"})]})]})]})}return a.jsx("section",{className:"settings-section",children:a.jsx(Z5,{title:"Remote Access",description:"Access your yepanywhere server from anywhere through an encrypted relay connection."})})}function G5(){const{executors:e,loading:n,addExecutor:r,removeExecutor:o,testExecutor:l}=Sb(),[u,d]=h.useState(""),[f,p]=h.useState(!1),[x,v]=h.useState(null),[y,S]=h.useState({}),w=async()=>{if(!(!u.trim()||f)){p(!0),v(null);try{await r(u.trim()),d("")}catch(k){v(k instanceof Error?k.message:"Failed to add executor")}finally{p(!1)}}},C=async k=>{try{await o(k),S(M=>{const{[k]:O,...B}=M;return B})}catch(M){console.error("Failed to remove executor:",M)}},_=async k=>{S(M=>({...M,[k]:{testing:!0}}));try{const M=await l(k);S(O=>({...O,[k]:{testing:!1,result:M}}))}catch(M){S(O=>({...O,[k]:{testing:!1,result:{success:!1,error:M instanceof Error?M.message:"Connection failed"}}}))}},E=k=>{k.key==="Enter"&&(k.preventDefault(),w())};return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Remote Executors"}),a.jsx("p",{className:"settings-section-description",children:"Run Claude sessions on remote machines via SSH. Add SSH host aliases from your ~/.ssh/config file."}),a.jsx("div",{className:"settings-group",children:a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Add Remote Executor"}),a.jsx("p",{children:'Enter an SSH host alias (e.g., "devbox", "gpu-server")'})]}),a.jsxs("div",{className:"remote-executor-add",children:[a.jsx("input",{type:"text",value:u,onChange:k=>d(k.target.value),onKeyDown:E,placeholder:"SSH host alias",disabled:f,className:"remote-executor-input"}),a.jsx("button",{type:"button",onClick:w,disabled:!u.trim()||f,className:"remote-executor-add-button",children:f?"Adding...":"Add"})]}),x&&a.jsx("p",{className:"settings-error",children:x})]})}),a.jsxs("div",{className:"settings-group",children:[a.jsx("h3",{children:"Configured Executors"}),n?a.jsx("p",{className:"settings-loading",children:"Loading..."}):e.length===0?a.jsx("p",{className:"settings-empty",children:"No remote executors configured. Add one above to run sessions on remote machines."}):a.jsx("div",{className:"remote-executor-list",children:e.map(k=>{var O;const M=y[k];return a.jsxs("div",{className:"remote-executor-item",children:[a.jsxs("div",{className:"remote-executor-item-info",children:[a.jsx("span",{className:"remote-executor-host",children:k}),(M==null?void 0:M.result)&&a.jsx("span",{className:`settings-status-badge ${M.result.success?"settings-status-detected":"settings-status-not-detected"}`,children:M.result.success?"Connected":"Failed"})]}),(M==null?void 0:M.result)&&!M.result.success&&a.jsx("p",{className:"settings-error remote-executor-error",children:M.result.error}),((O=M==null?void 0:M.result)==null?void 0:O.success)&&a.jsx("p",{className:"remote-executor-details",children:M.result.claudeAvailable?"Claude CLI available":"Claude CLI not found"}),a.jsxs("div",{className:"remote-executor-actions",children:[a.jsx("button",{type:"button",onClick:()=>_(k),disabled:M==null?void 0:M.testing,className:"remote-executor-test-button",children:M!=null&&M.testing?"Testing...":"Test Connection"}),a.jsx("button",{type:"button",onClick:()=>C(k),className:"remote-executor-remove-button",children:"Remove"})]})]},k)})})]}),a.jsxs("div",{className:"settings-group",children:[a.jsx("h3",{children:"Setup Requirements"}),a.jsxs("ul",{className:"settings-requirements",children:[a.jsx("li",{children:"SSH host alias configured in ~/.ssh/config"}),a.jsx("li",{children:"SSH key-based authentication (no password prompts)"}),a.jsx("li",{children:"Claude CLI installed on the remote machine"}),a.jsx("li",{children:"Project paths must be the same on local and remote machines (e.g., ~/code/project)"})]})]})]})}const zv=[{id:"appearance",label:"Appearance",icon:"🎨",description:"Theme, font size, streaming"},{id:"model",label:"Model",icon:"🧠",description:"Claude model and thinking settings"},{id:"notifications",label:"Notifications",icon:"🔔",description:"Push notification preferences"},{id:"devices",label:"Devices",icon:"📱",description:"Browser profiles and connection origins"},{id:"local-access",label:"Local Access",icon:"🔒",description:"Network binding and authentication"},{id:"remote",label:"Remote Access",icon:"🌐",description:"Relay server configuration"},{id:"providers",label:"Providers",icon:"🔌",description:"AI provider integrations"},{id:"remote-executors",label:"Remote Executors",icon:"🖥️",description:"Run sessions on remote machines"},{id:"about",label:"About",icon:"ℹ️",description:"Version and support"}],Y5={id:"development",label:"Development",icon:"🛠️",description:"Developer tools and debugging"},W5={appearance:e5,model:u5,notifications:v5,devices:i5,"local-access":c5,remote:V5,providers:b5,"remote-executors":G5,about:QA,development:t5};function Lv({category:e,isActive:n,onClick:r}){return a.jsxs("button",{type:"button",className:`settings-category-item ${n?"active":""}`,onClick:r,children:[a.jsx("span",{className:"settings-category-icon",children:e.icon}),a.jsxs("div",{className:"settings-category-text",children:[a.jsx("span",{className:"settings-category-label",children:e.label}),a.jsx("span",{className:"settings-category-description",children:e.description})]}),a.jsx("span",{className:"settings-category-chevron",children:"›"})]})}function Uv(){var S;const{category:e}=kc(),n=us(),{openSidebar:r,isWideScreen:o,toggleSidebar:l,isSidebarCollapsed:u}=za(),{isManualReloadMode:d}=lh(),f=d?[...zv,Y5]:zv,p=e||(o?(S=f[0])==null?void 0:S.id:void 0),x=w=>{n(`/settings/${w}`)},v=()=>{n("/settings")},y=p?W5[p]:null;if(!o){if(!e)return a.jsx("div",{className:"main-content-mobile",children:a.jsxs("div",{className:"main-content-mobile-inner",children:[a.jsx(Rr,{title:"Settings",onOpenSidebar:r,onToggleSidebar:l,isWideScreen:o,isSidebarCollapsed:u}),a.jsx("main",{className:"page-scroll-container",children:a.jsx("div",{className:"page-content-inner",children:a.jsx("div",{className:"settings-category-list",children:f.map(C=>a.jsx(Lv,{category:C,isActive:!1,onClick:()=>x(C.id)},C.id))})})})]})});const w=f.find(C=>C.id===e);return a.jsx("div",{className:"main-content-mobile",children:a.jsxs("div",{className:"main-content-mobile-inner",children:[a.jsx(Rr,{title:(w==null?void 0:w.label)||"Settings",onOpenSidebar:r,showBack:!0,onBack:v}),a.jsx("main",{className:"page-scroll-container",children:a.jsx("div",{className:"page-content-inner",children:y&&a.jsx(y,{})})})]})})}return a.jsx("div",{className:"main-content-wrapper",children:a.jsxs("div",{className:"main-content-constrained",children:[a.jsx(Rr,{title:"Settings",onOpenSidebar:r,onToggleSidebar:l,isWideScreen:o,isSidebarCollapsed:u}),a.jsx("main",{className:"page-scroll-container",children:a.jsxs("div",{className:"settings-two-column",children:[a.jsx("nav",{className:"settings-category-nav",children:a.jsx("div",{className:"settings-category-list",children:f.map(w=>a.jsx(Lv,{category:w,isActive:p===w.id,onClick:()=>x(w.id)},w.id))})}),a.jsx("div",{className:"settings-content-panel",children:y&&a.jsx(y,{})})]})})]})})}const X5=h.Fragment;Z6();CT();const K5="/".replace(/\/$/,"")||void 0,ty=document.getElementById("root");if(!ty)throw new Error("Root element not found");gS.createRoot(ty).render(a.jsx(X5,{children:a.jsx(ST,{children:a.jsx(Pj,{basename:K5,children:a.jsx(yT,{children:a.jsxs(gj,{children:[a.jsx(gs,{path:"/",element:a.jsx(dx,{to:"/projects",replace:!0})}),a.jsx(gs,{path:"/login",element:a.jsx(D3,{})}),a.jsxs(gs,{element:a.jsx(XT,{}),children:[a.jsx(gs,{path:"/projects",element:a.jsx(Y3,{})}),a.jsx(gs,{path:"/sessions",element:a.jsx(M3,{})}),a.jsx(gs,{path:"/agents",element:a.jsx(p3,{})}),a.jsx(gs,{path:"/inbox",element:a.jsx(U3,{})}),a.jsx(gs,{path:"/settings",element:a.jsx(Uv,{})}),a.jsx(gs,{path:"/settings/:category",element:a.jsx(Uv,{})}),a.jsx(gs,{path:"/projects/:projectId",element:a.jsx(dx,{to:"/sessions",replace:!0})}),a.jsx(gs,{path:"/new-session",element:a.jsx(Z3,{})}),a.jsx(gs,{path:"/projects/:projectId/sessions/:sessionId",element:a.jsx(WA,{})})]}),a.jsx(gs,{path:"/projects/:projectId/file",element:a.jsx(k3,{})}),a.jsx(gs,{path:"/activity",element:a.jsx(s3,{})})]})})})})}));
|
|
145
|
+
`),{text:o,openedFiles:l,uploadedFiles:u}=Cv(r);return o?a.jsxs("div",{className:"user-prompt-container",children:[a.jsx("div",{className:"message message-user-prompt",children:a.jsxs("div",{className:"message-content",children:[a.jsx(kv,{text:o}),a.jsx(fc,{files:u})]})}),a.jsx(dc,{files:l})]}):l.length>0||u.length>0?a.jsxs(a.Fragment,{children:[a.jsx(fc,{files:u}),a.jsx(dc,{files:l})]}):a.jsx("div",{className:"message message-user-prompt",children:a.jsx("div",{className:"message-content",children:a.jsx("div",{className:"text-block",children:"[Complex content]"})})})}),Of=h.memo(function({item:n,isStreaming:r,thinkingExpanded:o,toggleThinkingExpanded:l}){const u=h.useCallback(f=>{const p=window.getSelection();p&&p.toString().length>0||f.shiftKey&&!f.ctrlKey&&!f.metaKey&&(f.preventDefault(),f.stopPropagation(),console.log("[DEBUG] RenderItem:",n),console.log("[DEBUG] Source JSONL entries:",n.sourceMessages))},[n]),d=()=>{switch(n.type){case"text":return a.jsx(h4,{text:n.text,isStreaming:n.isStreaming,augmentHtml:n.augmentHtml});case"thinking":return a.jsx(g4,{thinking:n.thinking,status:n.status,isExpanded:o,onToggle:l});case"tool_call":return a.jsx(aA,{id:n.id,toolName:n.toolName,toolInput:n.toolInput,toolResult:n.toolResult,status:n.status});case"user_prompt":return a.jsx(pA,{content:n.content});case"system":{const f=n.subtype==="status"&&n.status==="compacting";return a.jsxs("div",{className:`system-message ${f?"system-message-compacting":""}`,children:[a.jsx("span",{className:`system-message-icon ${f?"spinning":""}`,children:"⟳"}),a.jsx("span",{className:"system-message-text",children:n.content})]})}default:return null}};return a.jsx("div",{className:n.isSubagent?"subagent-item":void 0,"data-render-type":n.type,"data-render-id":n.id,onClick:u,children:d()})});function gA(e){const n=[];let r=[];for(const o of e)o.type==="user_prompt"?(r.length>0&&(n.push({isUserPrompt:!1,items:r}),r=[]),n.push({isUserPrompt:!0,items:[o]})):r.push(o);return r.length>0&&n.push({isUserPrompt:!1,items:r}),n}const xA=h.memo(function({messages:n,isStreaming:r=!1,isProcessing:o=!1,isCompacting:l=!1,scrollTrigger:u=0,pendingMessages:d=[],deferredMessages:f=[],onCancelDeferred:p,markdownAugments:x,activeToolApproval:v}){const y=h.useRef(null),S=h.useRef(!0),w=h.useRef(!0),C=h.useRef(!1),_=h.useRef(0),E=h.useRef(null),[k,M]=h.useState(!1),O=h.useCallback(V=>{C.current=!0,V.scrollTop=V.scrollHeight-V.clientHeight,_.current=V.scrollHeight,requestAnimationFrame(()=>{C.current=!1}),E.current!==null&&clearTimeout(E.current),E.current=setTimeout(()=>{E.current=null,S.current&&(C.current=!0,V.scrollTop=V.scrollHeight-V.clientHeight,_.current=V.scrollHeight,requestAnimationFrame(()=>{C.current=!1}))},50)},[]),B=h.useMemo(()=>dh(n,{markdown:x,activeToolApproval:v}),[n,x,v]),L=h.useMemo(()=>gA(B),[B]),U=h.useCallback(()=>{M(V=>!V)},[]),$=h.useCallback(()=>{var ge;if(C.current)return;const V=(ge=y.current)==null?void 0:ge.parentElement;if(!V)return;const F=100,X=V.scrollHeight-V.scrollTop-V.clientHeight;S.current=X<F},[]);return h.useEffect(()=>{var F;const V=(F=y.current)==null?void 0:F.parentElement;if(V)return V.addEventListener("scroll",$),()=>{V.removeEventListener("scroll",$)}},[$]),h.useEffect(()=>{var ge;const V=(ge=y.current)==null?void 0:ge.parentElement;if(!V)return;const F=V;_.current=F.scrollHeight;const X=new ResizeObserver(()=>{const ee=F.scrollHeight;ee>_.current&&S.current?O(F):_.current=ee});return y.current&&X.observe(y.current),()=>{X.disconnect(),E.current!==null&&clearTimeout(E.current)}},[O]),h.useEffect(()=>{var V;if(u>0){S.current=!0;const F=(V=y.current)==null?void 0:V.parentElement;F&&O(F)}},[u,O]),h.useEffect(()=>{var V;if(w.current&&B.length>0){const F=(V=y.current)==null?void 0:V.parentElement;F&&O(F),w.current=!1}},[B.length,O]),a.jsxs("div",{className:"message-list",ref:y,children:[L.map(V=>{if(V.isUserPrompt){const X=V.items[0];return X?a.jsx(Of,{item:X,isStreaming:r,thinkingExpanded:k,toggleThinkingExpanded:U},X.id):null}const F=V.items[0];return F?a.jsx("div",{className:"assistant-turn",children:V.items.map(X=>a.jsx(Of,{item:X,isStreaming:r,thinkingExpanded:k,toggleThinkingExpanded:U},X.id))},`turn-${F.id}`):null}),d.map(V=>a.jsxs("div",{className:"pending-message",children:[a.jsx("div",{className:"message-user-prompt pending-message-bubble",children:V.content}),a.jsx("div",{className:"pending-message-status",children:"Sending..."})]},V.tempId)),f.map((V,F)=>a.jsxs("div",{className:"deferred-message",children:[a.jsx("div",{className:"message-user-prompt deferred-message-bubble",children:V.content}),a.jsxs("div",{className:"deferred-message-footer",children:[a.jsx("span",{className:"deferred-message-status",children:F===0?"Queued (next)":`Queued (#${F+1})`}),V.tempId&&p&&a.jsx("button",{type:"button",className:"deferred-message-cancel",onClick:()=>p(V.tempId),"aria-label":"Cancel queued message",children:"×"})]})]},V.tempId??`deferred-${F}`)),l&&a.jsxs("div",{className:"system-message system-message-compacting",children:[a.jsx("span",{className:"system-message-icon spinning",children:"⟳"}),a.jsx("span",{className:"system-message-text",children:"Compacting context..."})]}),a.jsx(c4,{isProcessing:o})]})});function $b(){const[e,n]=h.useState({connected:ln.connected,connectionState:Jn.state});return h.useEffect(()=>Jn.on("stateChange",o=>{n({connected:o==="connected",connectionState:o})}),[]),e}function vA(e){return e?e>=1e3?`${Math.round(e/1e3)}K tokens`:`${e} tokens`:"Disabled"}function bA(e){const n=new Date(e),o=new Date().getTime()-n.getTime(),l=Math.floor(o/1e3),u=Math.floor(l/60),d=Math.floor(u/60),f=Math.floor(d/24);return f>0?`${f}d ${d%24}h`:d>0?`${d}h ${u%60}m`:u>0?`${u}m ${l%60}s`:`${l}s`}function pf(e){return new Date(e).toLocaleString()}function yA(e){if(!e)return"Never";const n=Math.floor((Date.now()-e)/1e3);if(n<5)return"Just now";if(n<60)return`${n}s ago`;const r=Math.floor(n/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ${r%60}m ago`}function wn({label:e,value:n,mono:r=!1}){return n==null?null:a.jsxs("div",{className:"process-info-row",children:[a.jsx("span",{className:"process-info-label",children:e}),a.jsx("span",{className:`process-info-value ${r?"mono":""}`,children:n})]})}function To({title:e,children:n}){return a.jsxs("div",{className:"process-info-section",children:[a.jsx("h3",{className:"process-info-section-title",children:e}),n]})}function SA({sessionId:e,provider:n,model:r,status:o,processState:l,contextUsage:u,sessionStreamConnected:d,lastSessionEventAt:f,onClose:p}){const[x,v]=h.useState(null),[y,S]=h.useState(!1),[w,C]=h.useState(null),{connected:_,connectionState:E}=$b();h.useEffect(()=>{o.owner==="self"&&(S(!0),C(null),Ae.getProcessInfo(e).then(O=>{v(O.process)}).catch(O=>{C(O.message||"Failed to fetch process info")}).finally(()=>{S(!1)}))},[e,o.owner]);const k=O=>O.split("-").map(B=>B.charAt(0).toUpperCase()+B.slice(1)).join(" "),M=O=>{switch(O){case"claude":return"Claude (Anthropic)";case"codex":return"Codex (OpenAI)";case"codex-oss":return"Codex OSS (Local)";case"gemini":return"Gemini (Google)";case"opencode":return"OpenCode";default:return O}};return a.jsx(os,{title:"Session Info",onClose:p,children:a.jsxs("div",{className:"process-info-content",children:[a.jsxs(To,{title:"Session",children:[a.jsx(wn,{label:"Session ID",value:e,mono:!0}),a.jsx(wn,{label:"Provider",value:M(n)}),a.jsx(wn,{label:"Model",value:r||"Default",mono:!0}),a.jsx(wn,{label:"Ownership",value:k(o.owner)}),a.jsx(wn,{label:"Activity",value:k(l)})]}),a.jsxs(To,{title:"Connection",children:[a.jsx(wn,{label:"Activity stream",value:_?"Connected":"Disconnected"}),a.jsx(wn,{label:"Connection state",value:E}),a.jsx(wn,{label:"Session stream",value:o.owner==="self"?d?"Connected":"Disconnected":"Not subscribed"}),o.owner==="self"&&f&&a.jsx(wn,{label:"Last session event",value:yA(new Date(f).getTime())})]}),u&&a.jsxs(To,{title:"Token Usage",children:[a.jsx(wn,{label:"Input tokens",value:u.inputTokens.toLocaleString()}),u.outputTokens!==void 0&&a.jsx(wn,{label:"Output tokens",value:u.outputTokens.toLocaleString()}),a.jsx(wn,{label:"Context used",value:`${u.percentage.toFixed(1)}%`}),u.cacheReadTokens!==void 0&&a.jsx(wn,{label:"Cache read",value:u.cacheReadTokens.toLocaleString()}),u.cacheCreationTokens!==void 0&&a.jsx(wn,{label:"Cache created",value:u.cacheCreationTokens.toLocaleString()})]}),a.jsx(To,{title:"Process",children:o.owner==="self"?a.jsxs(a.Fragment,{children:[y&&a.jsx("div",{className:"process-info-loading",children:"Loading..."}),w&&a.jsx("div",{className:"process-info-error",children:w}),x&&a.jsxs(a.Fragment,{children:[a.jsx(wn,{label:"Process ID",value:x.id,mono:!0}),a.jsx(wn,{label:"Started",value:pf(x.startedAt)}),a.jsx(wn,{label:"Uptime",value:bA(x.startedAt)}),a.jsx(wn,{label:"Queue depth",value:x.queueDepth}),a.jsx(wn,{label:"Extended thinking",value:vA(x.maxThinkingTokens)}),x.idleSince&&a.jsx(wn,{label:"Idle since",value:pf(x.idleSince)}),x.holdSince&&a.jsx(wn,{label:"Hold since",value:pf(x.holdSince)})]}),!y&&!x&&!w&&a.jsx("div",{className:"process-info-loading",children:"No process data"})]}):o.owner==="external"?a.jsx("div",{className:"process-info-muted",children:"Session controlled by external process (VS Code, CLI)"}):a.jsx("div",{className:"process-info-muted",children:"No active process"})}),x&&a.jsxs(To,{title:"Project",children:[a.jsx(wn,{label:"Name",value:x.projectName}),a.jsx(wn,{label:"Path",value:x.projectPath,mono:!0}),a.jsx(wn,{label:"Remote host",value:x.executor,mono:!0})]})]})})}const jA={claude:"var(--provider-claude)",codex:"var(--provider-codex)","codex-oss":"var(--provider-codex)",gemini:"var(--provider-gemini)","gemini-acp":"var(--provider-gemini)",opencode:"var(--provider-opencode)"},wA={claude:"Claude",codex:"Codex","codex-oss":"CodexOSS",gemini:"Gemini","gemini-acp":"Gemini ACP",opencode:"OpenCode"};function NA({provider:e,compact:n=!1,model:r,isThinking:o=!1,className:l=""}){const u=jA[e],d=wA[e],p=(y=>{if(!y||y==="default")return null;const S=kf.find(C=>C.value===y);if(S&&S.value!=="default")return S.label;const w=y.match(/claude-(\w+)-/);if(w!=null&&w[1]){const C=w[1],_=kf.find(E=>E.value===C);return _?_.label:C.charAt(0).toUpperCase()+C.slice(1)}return y.charAt(0).toUpperCase()+y.slice(1)})(r);if(n)return a.jsx("span",{className:`provider-badge-stripe ${l}`,style:{backgroundColor:u},title:p?`${d} (${p})`:d,"aria-label":`Provider: ${d}${p?` (${p})`:""}`});const x=o?"provider-badge-dot-inline thinking":"provider-badge-dot-inline",v=o?{backgroundColor:"var(--thinking-color)"}:{backgroundColor:u};return a.jsxs("span",{className:`provider-badge ${l}`,style:{borderColor:u,color:u},children:[a.jsx("span",{className:x,style:v}),a.jsx("span",{className:"provider-badge-label",children:d}),p&&a.jsx("span",{className:"provider-badge-model",children:p})]})}const Pb="draft-tool-prompt-";function _A(e){const n=`${Pb}${e}-toolApprovalFeedback`,[r,o]=h.useState(()=>{try{return localStorage.getItem(n)??""}catch{return""}}),l=h.useCallback(d=>{o(d);try{d?localStorage.setItem(n,d):localStorage.removeItem(n)}catch{}},[n]),u=h.useCallback(()=>{o("");try{localStorage.removeItem(n)}catch{}},[n]);return[r,l,u]}function EA(e){const n=`${Pb}${e}-questionOther`,[r,o]=h.useState(()=>{try{const d=localStorage.getItem(n);return d?JSON.parse(d):{}}catch{return{}}}),l=h.useCallback((d,f)=>{o(p=>{const x={...p};f?x[d]=f:delete x[d];try{Object.keys(x).length>0?localStorage.setItem(n,JSON.stringify(x)):localStorage.removeItem(n)}catch{}return x})},[n]),u=h.useCallback(()=>{o({});try{localStorage.removeItem(n)}catch{}},[n]);return[r,l,u]}function CA({request:e,sessionId:n,onSubmit:r,onDeny:o}){const l=e.toolInput,u=(l==null?void 0:l.questions)||[],[d,f]=h.useState(0),[p,x]=h.useState({}),[v,y,S]=EA(n),[w,C]=h.useState(!1),[_,E]=h.useState(!1),k=h.useRef(null),M=u[d],O=d===u.length-1,B=M?p[M.question]:void 0,L=B==="__other__",U=u.every(ee=>{const ne=p[ee.question];return ne?ne==="__other__"?(v[ee.question]||"").trim().length>0:!0:!1});h.useEffect(()=>{L&&k.current&&(k.current.focus(),setTimeout(()=>{var ee;(ee=k.current)==null||ee.scrollIntoView({behavior:"smooth",block:"center"})},100))},[L]);const $=h.useCallback(ee=>{M&&x(ne=>({...ne,[M.question]:ee}))},[M]),V=h.useCallback(ee=>{M&&y(M.question,ee)},[M,y]),F=h.useCallback(()=>{O||f(ee=>ee+1)},[O]),X=h.useCallback(async()=>{if(!U||w)return;const ee={};for(const ne of u){const Ne=p[ne.question];Ne==="__other__"?ee[ne.question]=v[ne.question]||"":Ne&&(ee[ne.question]=Ne)}C(!0);try{await r(ee),S()}finally{C(!1)}},[U,w,u,p,v,r,S]),ge=h.useCallback(async()=>{C(!0);try{await o()}finally{C(!1)}},[o]);return h.useEffect(()=>{const ee=ne=>{if(!w){if(ne.key==="Escape"){ne.preventDefault(),ge();return}if(ne.key==="Enter"&&!ne.shiftKey){const Ne=B&&B!=="__other__",ke=B==="__other__"&&(v[(M==null?void 0:M.question)||""]||"").trim().length>0;(Ne||ke)&&(ne.preventDefault(),O&&U?X():F())}ne.key==="Tab"&&!L&&(ne.preventDefault(),ne.shiftKey?f(Ne=>Math.max(0,Ne-1)):f(Ne=>Math.min(u.length-1,Ne+1)))}};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[w,B,M,v,O,U,L,u.length,ge,X,F]),u.length?a.jsxs("div",{className:"question-panel-wrapper",children:[a.jsx("button",{type:"button",className:"question-panel-toggle",onClick:()=>E(!_),"aria-label":_?"Expand question panel":"Collapse question panel","aria-expanded":!_,children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:_?"chevron-up":"chevron-down","aria-hidden":"true",children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})}),!_&&a.jsxs("div",{className:"question-panel",children:[a.jsx("div",{className:"question-tabs",children:u.map((ee,ne)=>{const Ne=ne===d,ke=!!p[ee.question];return a.jsxs("button",{type:"button",className:`question-tab ${Ne?"active":""} ${ke?"answered":""}`,onClick:()=>f(ne),children:[ke&&a.jsx("span",{className:"question-tab-check",children:"✓"}),ee.header]},ee.question)})}),M&&a.jsxs("div",{className:"question-content",children:[a.jsx("div",{className:"question-text",children:M.question}),a.jsxs("div",{className:"question-options-list",children:[M.options.map(ee=>{const ne=B===ee.label;return a.jsxs("button",{type:"button",className:`question-option-btn ${ne?"selected":""}`,onClick:()=>$(ee.label),children:[a.jsx("span",{className:"question-option-radio",children:M.multiSelect?ne?"☑":"☐":ne?"●":"○"}),a.jsxs("div",{className:"question-option-text",children:[a.jsx("span",{className:"question-option-label",children:ee.label}),ee.description&&a.jsx("span",{className:"question-option-desc",children:ee.description})]})]},ee.label)}),a.jsxs("button",{type:"button",className:`question-option-btn other ${L?"selected":""}`,onClick:()=>$("__other__"),children:[a.jsx("span",{className:"question-option-radio",children:L?"●":"○"}),a.jsx("div",{className:"question-option-text",children:a.jsx("span",{className:"question-option-label",children:"Other"})})]}),L&&a.jsx("div",{className:"question-other-input",children:a.jsx("input",{ref:k,type:"text",placeholder:"Type your answer...",value:v[M.question]||"",onChange:ee=>V(ee.target.value)})})]})]}),a.jsxs("div",{className:"question-actions",children:[a.jsxs("button",{type:"button",className:"question-btn deny",onClick:ge,disabled:w,children:["Cancel",a.jsx("kbd",{children:"esc"})]}),O?a.jsxs("button",{type:"button",className:"question-btn submit",onClick:X,disabled:!U||w,children:["Submit",a.jsx("kbd",{children:"↵"})]}):a.jsxs("button",{type:"button",className:"question-btn next",onClick:F,disabled:!B||w,children:["Next",a.jsx("kbd",{children:"↵"})]})]})]})]}):a.jsx("div",{className:"question-panel-wrapper",children:a.jsx("div",{className:"question-panel",children:a.jsx("div",{className:"question-panel-empty",children:"No questions to answer"})})})}const Tv=10;function kA(e){const n=Date.now(),r=new Date(e).getTime(),o=n-r,l=Math.floor(o/6e4),u=Math.floor(o/36e5),d=Math.floor(o/864e5);return l<1?"now":l<60?`${l}m`:u<24?`${u}h`:d<7?`${d}d`:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function TA(e){return e.customTitle||e.title||"Untitled"}function RA({session:e}){if(e.activity==="in-turn")return a.jsx(Tr,{});if(e.pendingInputType){const r=e.pendingInputType==="tool-approval"?"Appr":"Q";return a.jsx("span",{className:"recent-sessions-badge needs-input",children:r})}return e.ownership.owner==="external"?a.jsx("span",{className:"recent-sessions-badge external",children:"Ext"}):null}function AA({currentSessionId:e,isOpen:n,onClose:r,onNavigate:o,triggerRef:l,basePath:u=""}){var S;const d=h.useRef(null),{sessions:f}=Ec({limit:Tv+5}),p=f.filter(w=>w.id!==e&&!w.isArchived).slice(0,Tv);if(h.useEffect(()=>{if(!n)return;const w=_=>{const E=_.target;d.current&&!d.current.contains(E)&&l.current&&!l.current.contains(E)&&r()},C=_=>{_.key==="Escape"&&r()};return document.addEventListener("mousedown",w),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",C)}},[n,r,l]),h.useEffect(()=>{if(!n)return;const w=()=>r();return window.addEventListener("scroll",w,{passive:!0}),()=>window.removeEventListener("scroll",w)},[n,r]),!n)return null;const x=(S=l.current)==null?void 0:S.getBoundingClientRect(),v=x?{position:"fixed",top:x.bottom+4,left:Math.max(8,x.left-100),width:"min(830px, calc(100vw - 32px))"}:{},y=a.jsxs("div",{ref:d,className:"recent-sessions-dropdown",style:v,children:[a.jsx("div",{className:"recent-sessions-header",children:"Recent Sessions"}),p.length===0?a.jsx("div",{className:"recent-sessions-empty",children:"No other sessions"}):a.jsx("div",{className:"recent-sessions-list",children:p.map(w=>a.jsxs(Vs,{to:`${u}/projects/${w.projectId}/sessions/${w.id}`,className:`recent-session-item${w.hasUnread?" unread":""}`,onClick:()=>{o(w.id,w.projectId),r()},children:[a.jsxs("div",{className:"recent-session-content",children:[a.jsxs("span",{className:"recent-session-title",children:[w.isStarred&&a.jsx("svg",{className:"recent-session-star",width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),a.jsx("span",{className:"recent-session-title-text",children:TA(w)})]}),a.jsx("span",{className:"recent-session-project",children:w.projectName})]}),a.jsxs("div",{className:"recent-session-meta",children:[a.jsx(RA,{session:w}),a.jsx("span",{className:"recent-session-time",children:kA(w.updatedAt)})]})]},w.id))})]});return ki.createPortal(y,document.body)}const MA=["Edit","Write","NotebookEdit"],gf=e=>e==="ExitPlanMode",OA=150;function zA({request:e,sessionId:n,onApprove:r,onDeny:o,onApproveAcceptEdits:l,onDenyWithFeedback:u,collapsed:d=!1,onCollapsedChange:f}){const[p,x]=h.useState(!1),[v,y]=h.useState(!1),[S,w,C]=_A(n),[_,E]=h.useState(()=>S.length>0),k=h.useRef(null);h.useEffect(()=>{y(!1);const V=setTimeout(()=>y(!0),OA);return()=>clearTimeout(V)},[e.id]);const M=e.toolName&&MA.includes(e.toolName),O=h.useCallback(async()=>{x(!0);try{await r()}finally{x(!1)}},[r]),B=h.useCallback(async()=>{if(l){x(!0);try{await l()}finally{x(!1)}}},[l]),L=h.useCallback(async()=>{x(!0);try{await o()}finally{x(!1)}},[o]),U=h.useCallback(async()=>{if(!(!u||!S.trim())){x(!0);try{await u(S.trim()),C(),E(!1)}finally{x(!1)}}},[u,S,C]);h.useEffect(()=>{_&&k.current&&k.current.focus()},[_]),h.useEffect(()=>{const V=F=>{if(p||!v)return;if(_){F.key==="Escape"?(F.preventDefault(),E(!1),C()):F.key==="Enter"&&S.trim()&&(F.preventDefault(),U());return}gf(e.toolName)?F.key==="1"&&l?(F.preventDefault(),B()):F.key==="2"?(F.preventDefault(),O()):F.key==="3"?(F.preventDefault(),L()):F.key==="Enter"&&!F.shiftKey&&l?(F.preventDefault(),B()):F.key==="Escape"&&(F.preventDefault(),L()):F.key==="1"?(F.preventDefault(),O()):F.key==="2"&&M&&l?(F.preventDefault(),B()):F.key==="3"||F.key==="2"&&(!M||!l)?(F.preventDefault(),L()):F.key==="Enter"&&!F.shiftKey?(F.preventDefault(),O()):F.key==="Escape"&&(F.preventDefault(),L())};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[O,B,L,U,p,v,_,S,C,M,l,e.toolName]);const $=e.toolName?Ib(e.toolName,e.toolInput,void 0,"pending"):e.prompt;return a.jsxs("div",{className:"tool-approval-wrapper",children:[a.jsx("button",{type:"button",className:`tool-approval-toggle ${d?"has-pending":""}`,onClick:()=>f==null?void 0:f(!d),"aria-label":d?"Expand approval panel":"Collapse approval panel","aria-expanded":!d,children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:d?"chevron-up":"chevron-down","aria-hidden":"true",children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})}),!d&&a.jsxs("div",{className:"tool-approval-panel",children:[a.jsx("div",{className:"tool-approval-header",children:gf(e.toolName)?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"tool-approval-title",children:"Accept this plan?"}),a.jsx("span",{className:"tool-approval-subtitle",children:"Review the plan above and decide whether to proceed"})]}):a.jsxs("span",{className:"tool-approval-question",children:["Allow"," ",a.jsx("span",{className:"tool-approval-name",children:e.toolName})," ",$,"?"]})}),a.jsxs("div",{className:"tool-approval-options",children:[gf(e.toolName)?a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"tool-approval-option primary",onClick:B,disabled:!v||p||!l,children:[a.jsx("kbd",{children:"1"}),a.jsx("span",{children:"Yes, and auto-accept"})]}),a.jsxs("button",{type:"button",className:"tool-approval-option",onClick:O,disabled:!v||p,children:[a.jsx("kbd",{children:"2"}),a.jsx("span",{children:"Yes, and manually approve edits"})]}),a.jsxs("button",{type:"button",className:"tool-approval-option",onClick:L,disabled:!v||p,children:[a.jsx("kbd",{children:"3"}),a.jsx("span",{children:"No, keep planning"})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"tool-approval-option primary",onClick:O,disabled:!v||p,children:[a.jsx("kbd",{children:"1"}),a.jsx("span",{children:"Yes"})]}),M&&l&&a.jsxs("button",{type:"button",className:"tool-approval-option",onClick:B,disabled:!v||p,children:[a.jsx("kbd",{children:"2"}),a.jsx("span",{children:"Yes, and don't ask again"})]}),a.jsxs("button",{type:"button",className:"tool-approval-option",onClick:L,disabled:!v||p,children:[a.jsx("kbd",{children:M&&l?"3":"2"}),a.jsx("span",{children:"No"})]})]}),u&&!_&&a.jsx("button",{type:"button",className:"tool-approval-option feedback-toggle",onClick:()=>E(!0),disabled:!v||p,children:a.jsx("span",{children:"Tell Claude what to do instead"})}),u&&_&&a.jsxs("div",{className:"tool-approval-feedback",children:[a.jsx("input",{ref:k,type:"text",placeholder:"Tell Claude what to do instead...",value:S,onChange:V=>w(V.target.value),disabled:!v||p,className:"tool-approval-feedback-input"}),a.jsx("button",{type:"button",className:"tool-approval-feedback-submit",onClick:U,disabled:!v||p||!S.trim(),children:"Send"})]})]})]})]})}const LA=3e4,Rv=2e3;function UA(e){const{sessionId:n,activityAt:r,updatedAt:o,lastSeenAt:l,hasUnread:u=!1,enabled:d=!0}=e,f=h.useRef(Date.now()),p=h.useRef(null),x=h.useRef(null),v=h.useRef(!0),y=h.useRef(!0),S=h.useCallback(()=>r?l?r>l||u:!0:!1,[r,l,u]),w=h.useCallback(()=>{const E=document.hasFocus(),k=Date.now()-f.current<LA;return E&&k},[]),C=h.useCallback(()=>{!d||!v.current||!r||!o||p.current!==r&&w()&&S()&&(x.current&&clearTimeout(x.current),x.current=setTimeout(async()=>{if(v.current)try{await Ae.markSessionSeen(n,o),p.current=r}catch(E){console.warn("[useEngagementTracking] Failed to mark session as seen:",E)}},Rv))},[d,n,r,o,w,S]);return h.useEffect(()=>{if(!d)return;const E=()=>{f.current=Date.now(),S()&&w()&&C()},k=["mousemove","keydown","scroll","click","touchstart"];for(const M of k)window.addEventListener(M,E,{passive:!0});return()=>{for(const M of k)window.removeEventListener(M,E)}},[d,S,w,C]),h.useEffect(()=>{if(!d)return;const E=()=>{document.visibilityState==="visible"&&S()&&w()&&C()},k=()=>{f.current=Date.now(),S()&&w()&&C()};return document.addEventListener("visibilitychange",E),window.addEventListener("focus",k),()=>{document.removeEventListener("visibilitychange",E),window.removeEventListener("focus",k)}},[d,S,w,C]),h.useEffect(()=>{d&&(!r||!o||y.current&&(y.current=!1,S()&&(x.current&&clearTimeout(x.current),x.current=setTimeout(async()=>{if(v.current&&p.current!==r)try{await Ae.markSessionSeen(n,o),p.current=r}catch(E){console.warn("[useEngagementTracking] Failed to mark session as seen:",E)}},Rv))))},[d,n,r,o,S]),h.useEffect(()=>(v.current=!0,()=>{v.current=!1,x.current&&clearTimeout(x.current)}),[]),{forceMarkSeen:h.useCallback(async()=>{if(!(!d||!o))try{await Ae.markSessionSeen(n,o),p.current=r}catch(E){console.warn("[useEngagementTracking] Failed to force mark session as seen:",E)}},[d,n,r,o]),isEngaged:w}}function DA(e,n){Ae.recordVisit(e,n).catch(r=>{console.error("Failed to record session visit:",r)})}function BA(e){var o;const n=new Map,r=new Set;for(const l of e){const u=((o=l.message)==null?void 0:o.content)??l.content;if(Array.isArray(u))for(const d of u){if(d.type==="tool_use"&&d.name==="Task"&&typeof d.id=="string"){const f=d.input;n.set(d.id,{description:(f==null?void 0:f.description)??"Unknown task",subagentType:(f==null?void 0:f.subagent_type)??"unknown"})}d.type==="tool_result"&&typeof d.tool_use_id=="string"&&r.add(d.tool_use_id)}}return[...n.entries()].filter(([l])=>!r.has(l)).map(([l,{description:u,subagentType:d}])=>({toolUseId:l,description:u,subagentType:d}))}function IA(e){const n=e.relativePath.split(/[\\/]/).pop();if(!n)return null;let r=n;if(r.endsWith(".jsonl")?r=r.slice(0,-6):r.endsWith(".json")&&(r=r.slice(0,-5)),e.provider==="codex"){const o=r.match(/([0-9a-fA-F-]{36})$/);if(o)return o[1]??null}return r}function $A(e){const{projectId:n,sessionId:r,onLoadComplete:o,onLoadError:l}=e,[u,d]=h.useState([]),[f,p]=h.useState({}),[x,v]=h.useState(()=>new Map),[y,S]=h.useState(!0),[w,C]=h.useState(null),_=h.useRef([]),E=h.useRef(!1),k=h.useRef(void 0),M=h.useRef(void 0);h.useEffect(()=>{const ee=u[u.length-1];ee&&(M.current=Qn(ee))},[u]);const O=h.useCallback(ee=>{d(ne=>OT(ne,ee).messages)},[]),B=h.useCallback((ee,ne)=>{p(Ne=>{const ke=Ne[ne]??{messages:[],status:"running"},D=Qn(ee);return ke.messages.some(q=>Qn(q)===D)?Ne:{...Ne,[ne]:{...ke,messages:[...ke.messages,ee],status:"running"}}})},[]),L=h.useCallback(()=>{const ee=_.current;_.current=[];for(const ne of ee)ne.type==="message"?O(ne.msg):B(ne.msg,ne.agentId)},[O,B]);h.useEffect(()=>{E.current=!1,_.current=[],S(!0),p({}),Ae.getSession(n,r).then(ee=>{C(ee.session),k.current=ee.session.provider;const ne=ee.messages.map(ke=>({...ke,_source:"jsonl"}));d(ne);const Ne=ne[ne.length-1];Ne&&(M.current=Qn(Ne)),E.current=!0,L(),S(!1),o==null||o({session:ee.session,status:ee.ownership,pendingInputRequest:ee.pendingInputRequest})}).catch(ee=>{S(!1),l==null||l(ee)})},[n,r,o,l,L]);const U=h.useCallback((ee,ne)=>{const Ne=Qn(ee);if(Ne){if(ne){p(ke=>{const D=ke[ne]??{messages:[],status:"running"},q=D.messages.findIndex(G=>Qn(G)===Ne);if(q>=0){const G=[...D.messages];return G[q]=ee,{...ke,[ne]:{...D,messages:G}}}return{...ke,[ne]:{...D,messages:[...D.messages,ee]}}});return}d(ke=>{const D=ke.findIndex(q=>Qn(q)===Ne);if(D>=0){const q=[...ke];return q[D]=ee,q}return[...ke,ee]})}},[]),$=h.useCallback(ee=>{if(!E.current){_.current.push({type:"message",msg:ee});return}O(ee)},[O]),V=h.useCallback((ee,ne)=>{if(!E.current){_.current.push({type:"subagent",msg:ee,agentId:ne});return}B(ee,ne)},[B]),F=h.useCallback((ee,ne)=>{v(Ne=>{if(Ne.has(ee))return Ne;const ke=new Map(Ne);return ke.set(ee,ne),ke})},[]),X=h.useCallback(async()=>{try{const ee=await Ae.getSession(n,r,M.current);ee.messages.length>0&&d(ne=>MT(ne,ee.messages,{skipDagOrdering:!gb(ee.session.provider).capabilities.supportsDag}).messages),C(ne=>ne?{...ne,...ee.session,messages:ne.messages}:ee.session)}catch{}},[n,r]),ge=h.useCallback(async()=>{try{const ee=await Ae.getSessionMetadata(n,r);C(ne=>ne?{...ne,...ee.session,messages:ne.messages}:{...ee.session,messages:[]})}catch{}},[n,r]);return{messages:u,agentContent:f,toolUseToAgent:x,loading:y,session:w,setSession:C,handleStreamingUpdate:U,handleStreamMessageEvent:$,handleStreamSubagentMessage:V,registerToolUseAgent:F,setAgentContent:p,setToolUseToAgent:v,setMessages:d,fetchNewMessages:X,fetchSessionMetadata:ge}}function PA(e,n){const[r,o]=h.useState(!1),l=h.useRef(null),u=h.useRef(null),d=h.useRef(n);d.current=n;const f=h.useRef(null),p=h.useRef(!1),x=h.useCallback(()=>{if(!e){f.current=null;return}l.current||f.current!==e&&(f.current=e,v(e,vc()))},[e]),v=h.useCallback((y,S)=>{if(l.current){const E=l.current;l.current=null,E.close()}let w=null;const C=()=>w!==null&&l.current!==w,_={onEvent:(E,k,M)=>{if(Jn.recordEvent(),E==="heartbeat"){Jn.recordHeartbeat();return}k&&(u.current=k),d.current.onMessage({...M,eventType:E})},onOpen:()=>{var E,k;C()||(o(!0),Jn.markConnected(),(k=(E=d.current).onOpen)==null||k.call(E))},onError:E=>{var k,M;if(!C()){if(o(!1),l.current=null,f.current=null,(M=(k=d.current).onError)==null||M.call(k,new Event("error")),xc(E)){console.warn("[useSessionStream] Non-retryable error, not reconnecting:",E.message);return}Jn.handleError(E)}},onClose:()=>{p.current||C()||(o(!1),l.current=null,f.current=null)}};w=S.subscribeSession(y,_,u.current??void 0),l.current=w},[]);return h.useEffect(()=>Jn.on("stateChange",y=>{if(y==="reconnecting"||y==="disconnected"){if(l.current){const S=l.current;l.current=null,S.close()}o(!1),f.current=null}y==="connected"&&e&&!l.current&&x()}),[e,x]),h.useEffect(()=>(x(),()=>{var y;p.current=!0,(y=l.current)==null||y.close(),l.current=null,f.current=null,p.current=!1}),[x]),{connected:r}}function Hb(){const e=localStorage.getItem(is.streamingEnabled);return e===null?!0:e==="true"}function HA(e){localStorage.setItem(is.streamingEnabled,String(e))}function FA(){const[e,n]=h.useState(Hb),r=h.useCallback(o=>{n(o),HA(o)},[]);return{streamingEnabled:e,setStreamingEnabled:r}}function qA(){return Hb()}const ZA=50;function VA(e){const{onUpdateMessage:n,streamingMarkdownCallbacks:r,onToolUseMapping:o,onAgentContextUsage:l}=e,u=h.useRef(new Map),d=h.useRef(null),f=h.useRef(null),p=h.useRef({timer:null,pendingIds:new Set}),x=h.useCallback(_=>{const E=u.current.get(_);if(!E)return;const k={id:_,type:"assistant",role:"assistant",message:{role:"assistant",content:E.blocks},_isStreaming:!0,_source:"sdk"};n(k,E.agentId)},[n]),v=h.useCallback(_=>{const E=p.current;E.pendingIds.add(_),E.timer||(E.timer=setTimeout(()=>{for(const k of E.pendingIds)x(k);E.pendingIds.clear(),E.timer=null},ZA))},[x]),y=h.useCallback(_=>{var $,V;if(_.type!=="stream_event"||!qA())return!1;const k=_.event;if(!k)return!0;const M=k.type,B=_.isSubagent&&typeof _.parentToolUseId=="string"?_.parentToolUseId:void 0;if(B&&o&&o(B,B),M==="message_start"){const F=k.message;if(F!=null&&F.id&&(d.current=F.id,f.current=B??null,($=r==null?void 0:r.setCurrentMessageId)==null||$.call(r,F.id),B&&l)){const X=F.usage;if(X!=null&&X.input_tokens){const ge=X.input_tokens,ee=ge/2e5*100;l(B,{inputTokens:ge,percentage:ee})}}return!0}const L=d.current??`stream-${Date.now()}`,U=f.current??B;if(M==="content_block_start"){const F=k.index,X=k.content_block;if(X){const ge=u.current.get(L)??{blocks:[],isStreaming:!0,agentId:U};for(;ge.blocks.length<=F;)ge.blocks.push({type:"text",text:""});ge.blocks[F]={type:X.type??"text",text:X.text??"",thinking:X.thinking??void 0},u.current.set(L,ge),x(L)}}else if(M==="content_block_delta"){const F=k.index,X=k.delta;if(X){const ge=u.current.get(L);if(ge!=null&&ge.blocks[F]){const ee=ge.blocks[F],ne=X.type;ne==="text_delta"&&X.text?ee.text=(ee.text??"")+X.text:ne==="thinking_delta"&&X.thinking&&(ee.thinking=(ee.thinking??"")+X.thinking),v(L)}}}else M==="content_block_stop"||M==="message_stop"&&(u.current.delete(L),(V=r==null?void 0:r.onStreamEnd)==null||V.call(r));return!0},[x,v,r,o,l]),S=h.useCallback(()=>{u.current.clear(),d.current=null,f.current=null},[]),w=h.useCallback(()=>f.current,[]),C=h.useCallback(()=>{p.current.timer&&(clearTimeout(p.current.timer),p.current.timer=null)},[]);return{handleStreamEvent:y,clearStreaming:S,cleanup:C,getCurrentAgentId:w}}const GA=500;function YA(e,n,r,o){const[l,u]=h.useState(r??{owner:"none"}),[d,f]=h.useState(r?"in-turn":"idle"),[p,x]=h.useState(null),[v,y]=h.useState(null),[S,w]=h.useState(n),[C,_]=h.useState(null),[E,k]=h.useState([]),[M,O]=h.useState([]),[B,L]=h.useState(!1),[U,$]=h.useState({}),[V,F]=h.useState("default"),[X,ge]=h.useState("default"),[ee,ne]=h.useState(0),[Ne,ke]=h.useState([]),[D,q]=h.useState([]),[G,Se]=h.useState([]),Me=h.useRef(0),I=h.useCallback((Oe,vt)=>{vt>=Me.current&&(Me.current=vt,ge(Oe),F(Oe),ne(vt))},[]),re=h.useCallback(Oe=>{u(vt=>vt.owner==="self"&&Oe.status.owner!=="self"?vt:Oe.status),Oe.status.owner==="self"&&Oe.status.permissionMode&&Oe.status.modeVersion!==void 0&&I(Oe.status.permissionMode,Oe.status.modeVersion),Oe.pendingInputRequest&&x(Oe.pendingInputRequest)},[I]),he=h.useCallback(Oe=>{y(Oe)},[]),{messages:oe,agentContent:Ee,toolUseToAgent:Te,loading:We,session:Ie,setSession:je,handleStreamingUpdate:Ze,handleStreamMessageEvent:yt,handleStreamSubagentMessage:be,registerToolUseAgent:St,setAgentContent:_e,setToolUseToAgent:mt,setMessages:pt,fetchNewMessages:Lt}=$A({projectId:e,sessionId:n,onLoadComplete:re,onLoadError:he}),cn=h.useCallback(async Oe=>{if(F(Oe),l.owner==="self"||l.owner==="external")try{const vt=await Ae.setPermissionMode(n,Oe);vt.modeVersion>=Me.current&&(Me.current=vt.modeVersion,ge(vt.permissionMode),ne(vt.modeVersion))}catch(vt){console.warn("Failed to sync permission mode:",vt)}},[n,l.owner]),un=h.useCallback(async Oe=>{if(l.owner!=="self"&&l.owner!=="external"){console.warn("Cannot set hold: no active process");return}try{const vt=await Ae.setHold(n,Oe);vt.state==="hold"?f("hold"):vt.state==="in-turn"&&f("in-turn")}catch(vt){console.warn("Failed to set hold:",vt)}},[n,l.owner]),dn=h.useRef({timer:null,pending:!1}),fn=h.useCallback(Oe=>{const vt=`temp-${Date.now()}`;return k(gn=>[...gn,{tempId:vt,content:Oe,timestamp:new Date().toISOString()}]),vt},[]),Z=h.useCallback(Oe=>{k(vt=>vt.filter(gn=>gn.tempId!==Oe))},[]),xe=h.useRef(null);h.useEffect(()=>{if(We||xe.current===n||oe.length===0)return;(async()=>{xe.current=n;const vt=BA(oe);if(vt.length!==0)try{const{mappings:gn}=await Ae.getAgentMappings(e,n),Gn=new Map(gn.map(ze=>[ze.toolUseId,ze.agentId]));mt(ze=>{const Ft=new Map(ze);for(const[mn,Xt]of Gn)Ft.has(mn)||Ft.set(mn,Xt);return Ft});for(const ze of vt){const Ft=Gn.get(ze.toolUseId);if(Ft)try{const mn=await Ae.getAgentSession(e,n,Ft);_e(Xt=>{const Tt=Xt[Ft];if(Tt&&Tt.messages.length>0){const bs=new Set(Tt.messages.map(ts=>Qn(ts))),ls=mn.messages.filter(ts=>!bs.has(Qn(ts)));return{...Xt,[Ft]:{messages:[...Tt.messages,...ls],status:mn.status}}}return{...Xt,[Ft]:mn}})}catch{}}}catch{}})()},[We,oe,e,n,_e,mt]);const Be=h.useCallback(()=>{const Oe=dn.current;Oe.timer?Oe.pending=!0:(Lt(),Oe.timer=setTimeout(()=>{Oe.timer=null,Oe.pending&&(Oe.pending=!1,Be())},GA))},[Lt]),st=h.useCallback(Oe=>{Oe.fileType!=="session"&&Oe.fileType!=="agent-session"||IA(Oe)!==n||l.owner!=="self"&&Be()},[n,l.owner,Be]),kt=h.useCallback(Oe=>{Oe.sessionId===n&&je(vt=>vt&&{...vt,...Oe.title!==void 0&&{title:Oe.title},...Oe.messageCount!==void 0&&{messageCount:Oe.messageCount},...Oe.updatedAt!==void 0&&{updatedAt:Oe.updatedAt},...Oe.contextUsage!==void 0&&{contextUsage:Oe.contextUsage},...Oe.model!==void 0&&{model:Oe.model}})},[n,je]),Et=h.useCallback(Oe=>{Oe.sessionId===n&&u(Oe.ownership)},[n]),an=h.useCallback(async Oe=>{Oe.sessionId===n&&((Oe.activity==="idle"||Oe.activity==="in-turn"||Oe.activity==="waiting-input"||Oe.activity==="hold")&&f(Oe.activity),Oe.activity==="waiting-input"&&Oe.pendingInputType&&x(vt=>vt||(Ae.getSessionMetadata(e,n).then(gn=>{gn.pendingInputRequest&&x(gn.pendingInputRequest)}),vt)))},[e,n]),fs=h.useCallback(async()=>{Lt();try{const Oe=await Ae.getSessionMetadata(e,n);u(Oe.ownership),Oe.ownership.owner==="none"&&(f("idle"),x(null))}catch{}},[e,n,Lt]);Ai({onSessionStatusChange:Et,onFileChange:st,onSessionUpdated:kt,onProcessStateChange:an,onReconnect:fs}),h.useEffect(()=>()=>{dn.current.timer&&clearTimeout(dn.current.timer)},[]);const hs=h.useCallback((Oe,vt)=>{_e(gn=>{const Gn=gn[Oe]??{messages:[],status:"running"};return{...gn,[Oe]:{...Gn,contextUsage:vt}}})},[_e]),{handleStreamEvent:gt,clearStreaming:Bt,cleanup:Rn}=VA({onUpdateMessage:Ze,onToolUseMapping:St,onAgentContextUsage:hs,streamingMarkdownCallbacks:o});h.useEffect(()=>()=>{Rn()},[Rn]);const Ht=h.useCallback(Oe=>{var vt,gn,Gn;if(Oe.eventType==="message"){_(new Date().toISOString());const ze=Oe,Ft=ze.uuid,mn=ze.id,Xt=(typeof Ft=="string"?Ft:null)??(typeof mn=="string"?mn:null)??`msg-${Date.now()}`,Tt=typeof ze.type=="string"?ze.type:void 0,bs=ze.role;if(Tt==="stream_event"&>(ze))return;if(Tt==="assistant"){const ar=ze.isSubagent&&typeof ze.parentToolUseId=="string"?ze.parentToolUseId:void 0;Bt(),ar?_e(pn=>{const Un=pn[ar];if(!Un)return pn;const N=Un.messages.filter(R=>!R._isStreaming);return N.length===Un.messages.length?pn:{...pn,[ar]:{...Un,messages:N}}}):pt(pn=>pn.filter(Un=>!Un._isStreaming))}const ls={...ze,id:Xt,type:Tt,role:bs??(Tt==="user"||Tt==="assistant"?Tt:void 0)};if(ls.eventType=void 0,Tt==="system"&&ze.subtype==="init"&&(Array.isArray(ze.slash_commands)&&ke(ze.slash_commands),Array.isArray(ze.tools)&&q(ze.tools),Array.isArray(ze.mcp_servers)&&Se(ze.mcp_servers)),Tt==="system"&&ze.subtype==="status"){const Yn=ze.status;L(Yn==="compacting");return}Tt==="system"&&ze.subtype==="compact_boundary"&&L(!1);const ts=ze.tempId;if(Tt==="user"&&ts&&Z(ts),ze.isSubagent&&typeof ze.parentToolUseId=="string"){const Yn=ze.parentToolUseId;St(Yn,Yn),be(ls,Yn);return}yt(ls)}else if(Oe.eventType==="status"){const ze=Oe;(ze.state==="idle"||ze.state==="in-turn"||ze.state==="waiting-input"||ze.state==="hold")&&f(ze.state),ze.state==="waiting-input"&&ze.request?(x(ze.request),ze.request.sessionId&&ze.request.sessionId!==n&&w(ze.request.sessionId)):x(null)}else if(Oe.eventType==="deferred-queue")O(Oe.messages??[]);else if(Oe.eventType==="complete")f("idle"),u({owner:"none"}),x(null),O([]);else if(Oe.eventType==="connected"){const ze=Oe,Ft=ze.sessionId??((vt=ze.request)==null?void 0:vt.sessionId);Ft&&Ft!==n&&w(Ft),(ze.state==="idle"||ze.state==="in-turn"||ze.state==="waiting-input"||ze.state==="hold")&&f(ze.state),ze.state==="waiting-input"&&ze.request?x(ze.request):x(null),ze.permissionMode&&ze.modeVersion!==void 0&&I(ze.permissionMode,ze.modeVersion);const mn=ze.provider,Xt=ze.model;mn&&je(Tt=>Tt&&{...Tt,provider:Tt.provider||mn,...Xt&&{model:Xt}}),O(ze.deferredMessages??[]),Lt()}else if(Oe.eventType==="mode-change"){const ze=Oe;ze.permissionMode&&ze.modeVersion!==void 0&&I(ze.permissionMode,ze.modeVersion)}else if(Oe.eventType==="markdown-augment"){const ze=Oe;ze.messageId&&ze.blockIndex===void 0&&ze.html?$(Ft=>({...Ft,[ze.messageId]:{html:ze.html}})):ze.blockIndex!==void 0&&((gn=o==null?void 0:o.onAugment)==null||gn.call(o,{blockIndex:ze.blockIndex,html:ze.html,type:ze.type??"text",messageId:ze.messageId}))}else if(Oe.eventType==="pending"){const ze=Oe;(Gn=o==null?void 0:o.onPending)==null||Gn.call(o,{html:ze.html})}else if(Oe.eventType==="session-id-changed"){const ze=Oe;ze.newSessionId&&ze.newSessionId!==n&&(w(ze.newSessionId),x(Ft=>Ft&&Ft.sessionId===ze.oldSessionId?{...Ft,sessionId:ze.newSessionId}:Ft))}},[I,n,gt,Bt,Z,o,yt,be,St,_e,pt,je,Lt]),hn=h.useCallback(async()=>{try{(await Ae.getSessionMetadata(e,n)).ownership.owner!=="self"&&(u({owner:"none"}),f("idle"))}catch{u({owner:"none"}),f("idle")}},[e,n]),{connected:en}=PA(l.owner==="self"?n:null,{onMessage:Ht,onError:hn});return{session:Ie,messages:oe,agentContent:Ee,setAgentContent:_e,toolUseToAgent:Te,markdownAugments:U,status:l,processState:d,isCompacting:B,isHeld:d==="hold",pendingInputRequest:p,actualSessionId:S,permissionMode:V,modeVersion:ee,loading:We,error:v,connected:en,lastStreamActivityAt:C,setStatus:u,setProcessState:f,setPermissionMode:cn,setHold:un,pendingMessages:E,addPendingMessage:fn,removePendingMessage:Z,deferredMessages:M,slashCommands:Ne,sessionTools:D,mcpServers:G}}function WA(){const{projectId:e,sessionId:n}=kc();return!e||!n?a.jsx("div",{className:"error",children:"Invalid session URL"}):a.jsx(u4,{children:a.jsx(XA,{projectId:e,sessionId:n},n)})}function XA({projectId:e,sessionId:n}){const{openSidebar:r,isWideScreen:o,toggleSidebar:l,isSidebarCollapsed:u}=za(),d=Oi(),{project:f}=F0(e),p=us(),x=Cs(),v=x.state,y=v==null?void 0:v.initialStatus,S=v==null?void 0:v.initialTitle,w=v==null?void 0:v.initialModel,C=v==null?void 0:v.initialProvider,_=Cb(),E=h.useMemo(()=>{if(_)return{onAugment:_.dispatchAugment,onPending:_.dispatchPending,onStreamEnd:_.dispatchStreamEnd,setCurrentMessageId:_.setCurrentMessageId,captureHtml:_.captureStreamingHtml}},[_]),{session:k,messages:M,agentContent:O,setAgentContent:B,toolUseToAgent:L,markdownAugments:U,status:$,processState:V,isCompacting:F,pendingInputRequest:X,actualSessionId:ge,permissionMode:ee,loading:ne,error:Ne,connected:ke,lastStreamActivityAt:D,setStatus:q,setProcessState:G,setPermissionMode:Se,setHold:Me,isHeld:I,pendingMessages:re,addPendingMessage:he,removePendingMessage:oe,deferredMessages:Ee,slashCommands:Te}=YA(e,n,y,E),{holdModeEnabled:We}=Vo(),{connectionState:Ie}=$b(),je="idle",Ze=(k==null?void 0:k.provider)??C,yt=(k==null?void 0:k.model)??w,[be,St]=h.useState(0),_e=h.useRef(null),mt=h.useCallback(J=>{_e.current=J},[]),{showToast:pt}=oh(),Lt=vb(),cn=bb(),un=h.useMemo(()=>[...Te,"login"],[Te]),{providers:dn}=uh(),fn=h.useMemo(()=>k!=null&&k.provider?dn.find(J=>J.name===k.provider)??null:null,[dn,k==null?void 0:k.provider]),Z=(fn==null?void 0:fn.supportsPermissionMode)??!0,xe=(fn==null?void 0:fn.supportsThinkingToggle)??!0,Be=(fn==null?void 0:fn.supportsSlashCommands)??!1,[st,kt]=h.useState(!1),[Et,an]=h.useState(""),[fs,hs]=h.useState(!1),gt=h.useRef(null),Bt=h.useRef(!1),[Rn,Ht]=h.useState(!1),hn=h.useRef(null),[en,Oe]=h.useState(void 0),[vt,gn]=h.useState(void 0),[Gn,ze]=h.useState(void 0),[Ft,mn]=h.useState(void 0);h.useEffect(()=>{Oe(void 0),gn(void 0),ze(void 0),mn(void 0)},[n]),h.useEffect(()=>{DA(n,e)},[n,e]),h.useEffect(()=>{ge&&ge!==n&&p(`${d}/projects/${e}/sessions/${ge}`,{replace:!0,state:x.state})},[ge,n,e,p,x.state,d]);const[Xt,Tt]=h.useState([]),[bs,ls]=h.useState([]),[ts,Yn]=h.useState(!1),[ar,pn]=h.useState(!1),Un=(k==null?void 0:k.updatedAt)??null,N=h.useMemo(()=>!Un&&!D?null:Un?D?Un>D?Un:D:Un:D,[Un,D]);UA({sessionId:n,activityAt:N,updatedAt:Un,lastSeenAt:k==null?void 0:k.lastSeenAt,hasUnread:k==null?void 0:k.hasUnread,enabled:$.owner!=="external"});const R=async J=>{var qe,rt,at;if(J.trim()==="/login"){Lt.startLogin();return}const te=he(J);G("in-turn"),St(et=>et+1);const fe=[...Xt];Tt([]);try{if($.owner==="none"){const et=(k==null?void 0:k.model)??_c(),P=Oo(),jt=await Ae.resumeSession(e,n,J,{mode:ee,model:et,thinking:P,provider:Ze,executor:k==null?void 0:k.executor},fe.length>0?fe:void 0,te);q({owner:"self",processId:jt.processId})}else{const et=Oo(),P=await Ae.queueMessage(n,J,ee,fe.length>0?fe:void 0,te,et);P.restarted&&P.processId&&q({owner:"self",processId:P.processId})}(qe=_e.current)==null||qe.clearDraft()}catch(et){if(console.error("Failed to send:",et),et instanceof Error&&(et.message.includes("404")||et.message.includes("No active process")))try{const bt=(k==null?void 0:k.model)??_c(),Ot=Oo(),wt=await Ae.resumeSession(e,n,J,{mode:ee,model:bt,thinking:Ot,provider:Ze,executor:k==null?void 0:k.executor},fe.length>0?fe:void 0,te);q({owner:"self",processId:wt.processId}),(rt=_e.current)==null||rt.clearDraft();return}catch(bt){console.error("Failed to resume session:",bt)}oe(te),(at=_e.current)==null||at.restoreFromStorage(),Tt(fe),G("idle");const jt=et instanceof Error?et.message:"Unknown error";pt(`Failed to send message: ${jt}`,"error")}},T=async J=>{var qe,rt;const te=he(J);St(at=>at+1);const fe=[...Xt];Tt([]);try{const at=Oo();await Ae.queueMessage(n,J,ee,fe.length>0?fe:void 0,te,at,!0),(qe=_e.current)==null||qe.clearDraft()}catch(at){console.error("Failed to queue deferred message:",at),oe(te),(rt=_e.current)==null||rt.restoreFromStorage(),Tt(fe);const et=at instanceof Error?at.message:"Unknown error";pt(`Failed to queue message: ${et}`,"error")}},b=async()=>{if($.owner==="self"&&$.processId){try{if((await Ae.interruptProcess($.processId)).interrupted)return}catch{}await Ae.abortProcess($.processId)}},z=h.useCallback(async()=>{if(X)try{await Ae.respondToInput(n,X.id,"approve")}catch(J){const te=J.status,fe=te?`Error ${te}`:"Failed to approve";pt(fe,"error")}},[n,X,pt]),W=h.useCallback(async()=>{if(X)try{await Ae.respondToInput(n,X.id,"approve_accept_edits"),Se("acceptEdits")}catch(J){const te=J.status,fe=te?`Error ${te}`:"Failed to approve";pt(fe,"error")}},[n,X,Se,pt]),K=h.useCallback(async()=>{if(X)try{await Ae.respondToInput(n,X.id,"deny")}catch(J){const te=J.status,fe=te?`Error ${te}`:"Failed to deny";pt(fe,"error")}},[n,X,pt]),me=h.useCallback(async J=>{if(X)try{await Ae.respondToInput(n,X.id,"deny",void 0,J)}catch(te){const fe=te.status,qe=fe?`Error ${fe}`:"Failed to send feedback";pt(qe,"error")}},[n,X,pt]),Re=h.useCallback(async J=>{if(X)try{await Ae.respondToInput(n,X.id,"approve",J)}catch(te){const fe=te.status,qe=fe?`Error ${fe}`:"Failed to submit answer";pt(qe,"error")}},[n,X,pt]),Ke=h.useCallback(async J=>{for(const te of J){const fe=crypto.randomUUID();ls(qe=>[...qe,{fileId:fe,fileName:te.name,bytesUploaded:0,totalBytes:te.size,percent:0}]);try{const qe=await cn.upload(e,n,te,{onProgress:rt=>{ls(at=>at.map(et=>et.fileId===fe?{...et,bytesUploaded:rt,percent:Math.round(rt/te.size*100)}:et))}});Tt(rt=>[...rt,qe])}catch(qe){console.error("Upload failed:",qe);const rt=qe instanceof Error?qe.message:"Upload failed";pt(`Failed to upload ${te.name}: ${rt}`,"error")}finally{ls(qe=>qe.filter(rt=>rt.fileId!==fe))}}},[e,n,pt,cn]),He=h.useCallback(J=>{Tt(te=>te.filter(fe=>fe.id!==J))},[]),Mt=(X==null?void 0:X.toolName)==="AskUserQuestion",Ge=V==="in-turn"||V==="waiting-input",lt=h.useMemo(()=>$.owner!=="none"?!1:dh(M).some(te=>te.type==="tool_call"&&te.status==="pending"),[M,$.owner]),ht=_r(k),ct=en??(ht!=="Untitled"?ht:null)??S??"Untitled",dt=vt??(k==null?void 0:k.isArchived)??!1,ot=Gn??(k==null?void 0:k.isStarred)??!1;wb(f==null?void 0:f.name,ct);const ft=()=>{an(ct),kt(!0),setTimeout(()=>{var J,te;(J=gt.current)==null||J.focus(),(te=gt.current)==null||te.select()},0)},Xe=()=>{Bt.current||(kt(!1),an(""))},Ye=()=>{if(!Bt.current){if(!Et.trim()||Et.trim()===ct){Xe();return}tt()}},tt=async()=>{if(!(!Et.trim()||fs)){Bt.current=!0,hs(!0);try{await Ae.updateSessionMetadata(n,{title:Et.trim()}),Oe(Et.trim()),kt(!1),pt("Session renamed","success")}catch(J){console.error("Failed to rename session:",J),pt("Failed to rename session","error")}finally{hs(!1),Bt.current=!1}}},$e=J=>{J.key==="Enter"?(J.preventDefault(),tt()):J.key==="Escape"&&(J.preventDefault(),Xe())},Ve=async()=>{const J=!dt;try{await Ae.updateSessionMetadata(n,{archived:J}),gn(J),pt(J?"Session archived":"Session unarchived","success")}catch(te){console.error("Failed to update archive status:",te),pt("Failed to update archive status","error")}},Je=async()=>{const J=!ot;try{await Ae.updateSessionMetadata(n,{starred:J}),ze(J),pt(J?"Session starred":"Session unstarred","success")}catch(te){console.error("Failed to update star status:",te),pt("Failed to update star status","error")}},Pe=Ft??(k==null?void 0:k.hasUnread)??!1,ce=async()=>{const J=!Pe;mn(J);try{J?await Ae.markSessionUnread(n):await Ae.markSessionSeen(n),pt(J?"Marked as unread":"Marked as read","success")}catch(te){console.error("Failed to update read status:",te),mn(void 0),pt("Failed to update read status","error")}},ue=async()=>{if($.owner==="self"&&$.processId)try{await Ae.abortProcess($.processId),pt("Session terminated","success")}catch(J){console.error("Failed to terminate session:",J);const te=J instanceof Error?J.message:"Unknown error";pt(`Failed to terminate: ${te}`,"error")}};if(Ne)return a.jsxs("div",{className:"error",children:["Error: ",Ne.message]});const Ce=()=>a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),a.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]});return a.jsx("div",{className:o?"main-content-wrapper":"main-content-mobile",children:a.jsxs("div",{className:o?"main-content-constrained":"main-content-mobile-inner",children:[a.jsx("header",{className:"session-header",children:a.jsxs("div",{className:"session-header-inner",children:[a.jsxs("div",{className:"session-header-left",children:[!(o&&u)&&a.jsx("button",{type:"button",className:"sidebar-toggle",onClick:o?l:r,title:o?"Toggle sidebar":"Open sidebar","aria-label":o?"Toggle sidebar":"Open sidebar",children:a.jsx(Ce,{})}),(f==null?void 0:f.name)&&a.jsx(Vs,{to:`${d}/sessions?project=${e}`,className:"project-breadcrumb",title:f.name,children:f.name.length>12?`${f.name.slice(0,12)}...`:f.name}),a.jsxs("div",{className:"session-title-row",children:[ot&&a.jsxs("svg",{className:"star-indicator-inline",width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2",role:"img","aria-label":"Starred",children:[a.jsx("title",{children:"Starred"}),a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})]}),ne?a.jsx("span",{className:"session-title-skeleton"}):st?a.jsx("input",{ref:gt,type:"text",className:"session-title-input",value:Et,onChange:J=>an(J.target.value),onKeyDown:$e,onBlur:Ye,disabled:fs}):a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:hn,type:"button",className:"session-title session-title-dropdown-trigger",onClick:()=>Ht(!Rn),title:(k==null?void 0:k.fullTitle)??ct,children:[a.jsx("span",{className:"session-title-text",children:ct}),a.jsx("svg",{className:"session-title-chevron",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),a.jsx(AA,{currentSessionId:n,isOpen:Rn,onClose:()=>Ht(!1),onNavigate:()=>Ht(!1),triggerRef:hn,basePath:d})]}),!ne&&dt&&a.jsx("span",{className:"archived-badge",children:"Archived"}),!ne&&a.jsx(xb,{sessionId:n,projectId:e,isStarred:ot,isArchived:dt,hasUnread:Pe,provider:k==null?void 0:k.provider,processId:$.owner==="self"?$.processId:void 0,onToggleStar:Je,onToggleArchive:Ve,onToggleRead:ce,onRename:ft,onClone:J=>{p(`${d}/projects/${e}/sessions/${J}`)},onTerminate:ue,useFixedPositioning:!0,useEllipsisIcon:!0})]})]}),a.jsx("div",{className:"session-header-right",children:!ne&&Ze&&a.jsx("button",{type:"button",className:"provider-badge-button",onClick:()=>pn(!0),title:"View session info",children:a.jsx(NA,{provider:Ze,model:yt,isThinking:V==="in-turn"})})})]})}),ar&&k&&a.jsx(SA,{sessionId:ge,provider:k.provider,model:k.model,status:$,processState:V,contextUsage:k.contextUsage,sessionStreamConnected:ke,lastSessionEventAt:D,onClose:()=>pn(!1)}),$.owner==="external"&&a.jsx("div",{className:"external-session-warning",children:"External session active - enter messages at your own risk!"}),lt&&a.jsx("div",{className:"external-session-warning pending-tool-warning",children:"This session may be waiting for input in another process (VS Code, CLI). Check there before sending a message."}),a.jsx("main",{className:"session-messages",children:ne?a.jsx("div",{className:"loading",children:"Loading session..."}):a.jsx(U4,{projectId:e,projectPath:(f==null?void 0:f.path)??null,sessionId:n,children:a.jsx(vR,{agentContent:O,setAgentContent:B,toolUseToAgent:L,projectId:e,sessionId:n,children:a.jsx(xA,{messages:M,isProcessing:$.owner==="self"&&V==="in-turn",isCompacting:F,scrollTrigger:be,pendingMessages:re,deferredMessages:Ee,onCancelDeferred:J=>Ae.cancelDeferredMessage(n,J),markdownAugments:U,activeToolApproval:Ge})})})}),a.jsxs("footer",{className:"session-input",children:[a.jsx("div",{className:`session-connection-bar session-connection-${je}`}),a.jsxs("div",{className:"session-input-inner",children:[X&&X.sessionId===ge&&Mt&&a.jsx(CA,{request:X,sessionId:ge,onSubmit:Re,onDeny:K}),X&&X.sessionId===ge&&!Mt&&a.jsxs(a.Fragment,{children:[a.jsx(zA,{request:X,sessionId:ge,onApprove:z,onDeny:K,onApproveAcceptEdits:W,onDenyWithFeedback:me,collapsed:ts,onCollapsedChange:Yn}),a.jsx(Nb,{mode:ee,onModeChange:Se,isHeld:We?I:void 0,onHoldChange:We?Me:void 0,supportsPermissionMode:Z,supportsThinkingToggle:xe,contextUsage:k==null?void 0:k.contextUsage,isRunning:$.owner==="self",isThinking:V==="in-turn",onStop:b,pendingApproval:ts?{type:"tool-approval",onExpand:()=>Yn(!1)}:void 0})]}),!(X&&X.sessionId===ge&&!Mt)&&a.jsx(Q3,{onSend:R,onQueue:$.owner!=="none"&&V!=="idle"?T:void 0,placeholder:$.owner==="external"?"External session - send at your own risk...":V==="idle"?"Send a message to resume...":"Queue a message...",mode:ee,onModeChange:Se,isHeld:We?I:void 0,onHoldChange:We?Me:void 0,supportsPermissionMode:Z,supportsThinkingToggle:xe,isRunning:$.owner==="self",isThinking:V==="in-turn",onStop:b,draftKey:`draft-message-${n}`,onDraftControlsReady:mt,collapsed:!!(X&&X.sessionId===ge),contextUsage:k==null?void 0:k.contextUsage,projectId:e,sessionId:n,attachments:Xt,onAttach:Ke,onRemoveAttachment:He,uploadProgress:bs,slashCommands:Be&&$.owner==="self"?un:[]})]})]}),Lt.isOpen&&a.jsx(jb,{authMethod:Lt.authMethod,onSelectMethod:Lt.selectMethod,url:Lt.url,statusMessage:Lt.statusMessage,startupError:Lt.error,onSuccess:Lt.handleSuccess,onCancel:Lt.handleCancel})]})})}let Ea=null;function KA(){const[e,n]=h.useState(!1),[r,o]=h.useState(!1);h.useEffect(()=>{if(window.matchMedia("(display-mode: standalone)").matches||"standalone"in navigator&&navigator.standalone===!0){o(!0);return}Ea&&n(!0);const d=p=>{p.preventDefault(),Ea=p,n(!0)},f=()=>{o(!0),n(!1),Ea=null};return window.addEventListener("beforeinstallprompt",d),window.addEventListener("appinstalled",f),()=>{window.removeEventListener("beforeinstallprompt",d),window.removeEventListener("appinstalled",f)}},[]);const l=h.useCallback(async()=>{if(!Ea)return!1;await Ea.prompt();const{outcome:u}=await Ea.userChoice;return u==="accepted"?(n(!1),Ea=null,!0):!1},[]);return{canInstall:e,isInstalled:r,install:l}}function JA(){const[e,n]=h.useState(null),[r,o]=h.useState(!0),[l,u]=h.useState(null),d=h.useRef(!1),f=h.useCallback(async()=>{o(!0),u(null);try{const p=await Ae.getVersion();n(p)}catch(p){u(p instanceof Error?p:new Error(String(p)))}finally{o(!1)}},[]);return h.useEffect(()=>{d.current||(d.current=!0,f())},[f]),{version:e,loading:r,error:l,refetch:f}}function QA(){const{canInstall:e,isInstalled:n,install:r}=KA(),{version:o}=JA(),{resetOnboarding:l}=lb(),{remoteLogCollectionEnabled:u,setRemoteLogCollectionEnabled:d}=Vo(),[f,p]=h.useState(!1),[x,v]=h.useState(0);h.useEffect(()=>{Ue("/status/workers").then(S=>v(S.activeWorkers)).catch(()=>{})},[]),h.useEffect(()=>{if(f)return ln.on("reconnect",()=>{p(!1)})},[f]);const y=h.useCallback(async()=>{p(!0);try{await Ae.restartServer()}catch{}},[]);return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"About"}),a.jsxs("div",{className:"settings-group",children:[(e||n)&&a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Install App"}),a.jsx("p",{children:n?"Yep Anywhere is installed on your device.":"Add Yep Anywhere to your home screen for quick access."})]}),n?a.jsx("span",{className:"settings-status-badge",children:"Installed"}):a.jsx("button",{type:"button",className:"settings-button",onClick:r,children:"Install"})]}),a.jsx("div",{className:"settings-item",children:a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Version"}),a.jsxs("p",{children:["Server:"," ",o?a.jsxs(a.Fragment,{children:["v",o.current,o.updateAvailable&&o.latest?a.jsxs("span",{className:"settings-update-available",children:[" ","(v",o.latest," available)"]}):o.latest?a.jsx("span",{className:"settings-up-to-date",children:" (up to date)"}):null]}):"Loading..."]}),a.jsxs("p",{children:["Client: v","0.2.9"]}),(o==null?void 0:o.updateAvailable)&&a.jsxs("p",{className:"settings-update-hint",children:["Run ",a.jsx("code",{children:"npm i -g yepanywhere"})," to update"]})]})}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Restart Server"}),a.jsx("p",{children:"Restart the backend server process."}),x>0&&!f&&a.jsxs("p",{className:"settings-warning",children:[x," active session",x!==1?"s":""," will be interrupted"]})]}),a.jsx("button",{type:"button",className:`settings-button ${x>0?"settings-button-danger":""}`,onClick:y,disabled:f,children:f?"Restarting...":x>0?"Restart Anyway":"Restart Server"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Report a Bug"}),a.jsx("p",{children:"Found an issue? Report it on GitHub to help improve Yep Anywhere."})]}),a.jsx("a",{href:"https://github.com/kzahel/yepanywhere/issues",target:"_blank",rel:"noopener noreferrer",className:"settings-button",children:"Report Bug"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Setup Wizard"}),a.jsx("p",{children:"Run the initial setup wizard again to configure theme and remote access."})]}),a.jsx("button",{type:"button",className:"settings-button",onClick:l,children:"Launch Wizard"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Connection Diagnostics"}),a.jsx("p",{children:"Capture connection logs and send to server for debugging."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:u,onChange:S=>d(S.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]})]})]})}function e5(){const{fontSize:e,setFontSize:n}=ET(),{theme:r,setTheme:o}=tb(),{streamingEnabled:l,setStreamingEnabled:u}=FA(),{funPhrasesEnabled:d,setFunPhrasesEnabled:f}=s4(),{showConnectionBars:p,setShowConnectionBars:x}=Vo();return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Appearance"}),a.jsxs("div",{className:"settings-group",children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Theme"}),a.jsx("p",{children:"Choose your preferred color scheme."})]}),a.jsx("div",{className:"font-size-selector",children:rh.map(v=>a.jsx("button",{type:"button",className:`font-size-option ${r===v?"active":""}`,onClick:()=>o(v),children:J0(v)},v))})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Font Size"}),a.jsx("p",{children:"Adjust the text size throughout the application."})]}),a.jsx("div",{className:"font-size-selector",children:db.map(v=>a.jsx("button",{type:"button",className:`font-size-option ${e===v?"active":""}`,onClick:()=>n(v),children:NT(v)},v))})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Response Streaming"}),a.jsx("p",{children:"Show responses as they are generated, token by token. Disable for better performance on slower devices."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:l,onChange:v=>u(v.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Fun Phrases"}),a.jsx("p",{children:'Show playful status messages while waiting for responses. Disable to show only "Thinking..."'})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:d,onChange:v=>f(v.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Connection Bars"}),a.jsx("p",{children:"Show colored status bars for relay and session connections (green/orange/red)."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:p,onChange:v=>x(v.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]})]})]})}function Fb(){const[e,n]=h.useState(null),[r,o]=h.useState(!0),[l,u]=h.useState(null),d=h.useCallback(async()=>{try{o(!0),u(null);const p=await Ae.getServerSettings();n(p.settings)}catch(p){console.error("[useServerSettings] Failed to fetch settings:",p),u(p instanceof Error?p.message:"Failed to load settings")}finally{o(!1)}},[]);h.useEffect(()=>{d()},[d]);const f=h.useCallback(async(p,x)=>{try{u(null);const v=await Ae.updateServerSettings({[p]:x});n(v.settings)}catch(v){throw console.error("[useServerSettings] Failed to update setting:",v),u(v instanceof Error?v.message:"Failed to update setting"),v}},[]);return{settings:e,isLoading:r,error:l,updateSetting:f,refetch:d}}function t5(){const{isManualReloadMode:e,pendingReloads:n,connected:r,reloadBackend:o,unsafeToRestart:l,workerActivity:u}=lh(),{settings:d,setEnabled:f}=rb(),{holdModeEnabled:p,setHoldModeEnabled:x}=Vo(),{ignoredTools:v,clearIgnoredTools:y}=Fn(),{settings:S,updateSetting:w}=Fb(),[C,_]=h.useState(!1);h.useEffect(()=>{C&&r&&_(!1)},[C,r]);const E=async()=>{_(!0),await o()};return e?a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Development"}),a.jsxs("div",{className:"settings-group",children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Schema Validation"}),a.jsx("p",{children:"Validate tool results against expected schemas. Shows toast notifications and logs errors to console."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:d.enabled,onChange:k=>f(k.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]}),v.length>0&&a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Ignored Tools"}),a.jsx("p",{children:"Tools with validation errors you chose to ignore. They will not show toast notifications."}),a.jsx("div",{className:"ignored-tools-list",children:v.map(k=>a.jsx("span",{className:"ignored-tool-badge",children:k},k))})]}),a.jsx("button",{type:"button",className:"settings-button settings-button-secondary",onClick:y,children:"Clear Ignored"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Hold Mode"}),a.jsx("p",{children:"Show hold/resume option in the mode selector. Pauses execution at the next yield point (experimental)."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:p,onChange:k=>x(k.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Service Worker"}),a.jsx("p",{children:"Enable service worker for push notifications. Disabling can help with page reload issues during development. Requires restart."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:(S==null?void 0:S.serviceWorkerEnabled)??!0,onChange:k=>w("serviceWorkerEnabled",k.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]})]}),a.jsx("div",{className:"settings-group",children:a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Restart Server"}),a.jsxs("p",{children:["Restart the backend server to pick up code changes.",n.backend&&a.jsx("span",{className:"settings-pending",children:" (changes pending)"})]}),l&&a.jsxs("p",{className:"settings-warning",children:[u.activeWorkers," active session",u.activeWorkers!==1?"s":""," will be interrupted"]})]}),a.jsx("button",{type:"button",className:`settings-button ${l?"settings-button-danger":""}`,onClick:E,disabled:C,children:C?"Restarting...":l?"Restart Anyway":"Restart Server"})]})})]}):null}function n5(){const[e,n]=h.useState({profiles:[],isLoading:!0,error:null}),r=h.useCallback(async()=>{n(l=>({...l,isLoading:!0,error:null}));try{const{profiles:l}=await Ae.getBrowserProfiles();n({profiles:l,isLoading:!1,error:null})}catch(l){console.error("[useBrowserProfiles] Failed to fetch:",l),n(u=>({...u,isLoading:!1,error:l instanceof Error?l.message:"Failed to load profiles"}))}},[]);h.useEffect(()=>{r()},[r]);const o=h.useCallback(async l=>{n(u=>({...u,isLoading:!0,error:null}));try{await Ae.deleteBrowserProfile(l),await r()}catch(u){console.error("[useBrowserProfiles] Failed to delete:",u),n(d=>({...d,isLoading:!1,error:u instanceof Error?u.message:"Failed to delete profile"}))}},[r]);return{...e,deleteProfile:o,refetch:r}}function qb(){const[e,n]=h.useState({connections:new Map,isLoading:!0,error:null}),r=h.useCallback(async()=>{n(o=>({...o,isLoading:!0,error:null}));try{const{connections:o}=await Ae.getConnections(),l=new Map;for(const u of o)l.set(u.browserProfileId,u);n({connections:l,isLoading:!1,error:null})}catch(o){console.error("[useConnectedDevices] Failed to fetch:",o),n(l=>({...l,isLoading:!1,error:o instanceof Error?o.message:"Failed to load connections"}))}},[]);return h.useEffect(()=>{r()},[r]),h.useEffect(()=>{const o=ln.on("browser-tab-connected",f=>{n(p=>{var v;const x=new Map(p.connections);return x.set(f.browserProfileId,{browserProfileId:f.browserProfileId,connectionCount:f.tabCount,connectedAt:f.timestamp,deviceName:(v=p.connections.get(f.browserProfileId))==null?void 0:v.deviceName}),{...p,connections:x}})}),l=ln.on("browser-tab-disconnected",f=>{n(p=>{const x=new Map(p.connections);if(f.tabCount===0)x.delete(f.browserProfileId);else{const v=x.get(f.browserProfileId);v&&x.set(f.browserProfileId,{...v,connectionCount:f.tabCount})}return{...p,connections:x}})}),u=ln.on("reconnect",()=>{r()}),d=ln.on("refresh",()=>{r()});return()=>{o(),l(),u(),d()}},[r]),{...e,connectionList:Array.from(e.connections.values()),refetch:r}}const s5="/sw.js";function mh(){const[e,n]=h.useState({isSupported:!1,isSubscribed:!1,isLoading:!0,error:null,permission:"default",browserProfileId:null}),[r,o]=h.useState(null),l=typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window;h.useEffect(()=>{(async()=>{if(!l){const y=sa("browserProfileId",vs.browserProfileId);n(S=>({...S,isSupported:!1,isLoading:!1,error:"Push notifications not supported in this browser",browserProfileId:y}));return}try{const y=await navigator.serviceWorker.register(s5);o(y),await navigator.serviceWorker.ready;const S=await y.pushManager.getSubscription(),w=Ro();n({isSupported:!0,isSubscribed:!!S,isLoading:!1,error:null,permission:Notification.permission,browserProfileId:w})}catch(y){console.error("[usePushNotifications] Init error:",y),n(S=>({...S,isSupported:!0,isLoading:!1,error:y instanceof Error?y.message:"Failed to initialize"}))}})()},[l]);const u=h.useCallback(async()=>{if(!r){n(v=>({...v,error:"Service worker not ready"}));return}n(v=>({...v,isLoading:!0,error:null}));try{const v=await Notification.requestPermission();if(n(E=>({...E,permission:v})),v!=="granted"){n(E=>({...E,isLoading:!1,error:"Notification permission denied"}));return}const{publicKey:y}=await Ae.getPushPublicKey(),S=r5(y),w=await r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:S.buffer}),C=Ro(),_=w.toJSON();await Ae.subscribePush(C,_,a5()),n(E=>({...E,isSubscribed:!0,isLoading:!1,error:null,browserProfileId:C}))}catch(v){console.error("[usePushNotifications] Subscribe error:",v),n(y=>({...y,isLoading:!1,error:v instanceof Error?v.message:"Failed to subscribe"}))}},[r]),d=h.useCallback(async()=>{if(!r){n(v=>({...v,error:"Service worker not ready"}));return}n(v=>({...v,isLoading:!0,error:null}));try{const v=await r.pushManager.getSubscription();v&&await v.unsubscribe();const y=Ro();await Ae.unsubscribePush(y),n(S=>({...S,isSubscribed:!1,isLoading:!1,error:null}))}catch(v){console.error("[usePushNotifications] Unsubscribe error:",v),n(y=>({...y,isLoading:!1,error:v instanceof Error?v.message:"Failed to unsubscribe"}))}},[r]),f=h.useCallback(async(v="normal")=>{const y=Ro();n(S=>({...S,isLoading:!0,error:null}));try{await Ae.testPush(y,void 0,v),n(S=>({...S,isLoading:!1}))}catch(S){console.error("[usePushNotifications] Test push error:",S),n(w=>({...w,isLoading:!1,error:S instanceof Error?S.message:"Failed to send test"}))}},[]),p=h.useCallback(async()=>{var y;const v=(y=navigator.serviceWorker)==null?void 0:y.controller;return v?new Promise(S=>{const w=new MessageChannel;w.port1.onmessage=C=>{var _;S(((_=C.data)==null?void 0:_.logs)||[])},v.postMessage({type:"get-sw-logs"},[w.port2]),setTimeout(()=>S([]),2e3)}):(console.warn("[usePushNotifications] No active service worker"),[])},[]),x=h.useCallback(async()=>{var y;const v=(y=navigator.serviceWorker)==null?void 0:y.controller;if(v)return new Promise(S=>{const w=new MessageChannel;w.port1.onmessage=()=>S(),v.postMessage({type:"clear-sw-logs"},[w.port2]),setTimeout(S,1e3)})},[]);return{...e,subscribe:u,unsubscribe:d,sendTest:f,getSwLogs:p,clearSwLogs:x}}function r5(e){const n="=".repeat((4-e.length%4)%4),r=(e+n).replace(/-/g,"+").replace(/_/g,"/"),o=window.atob(r),l=new Uint8Array(o.length);for(let u=0;u<o.length;++u)l[u]=o.charCodeAt(u);return l}function a5(){const e=navigator.userAgent;return/iPhone/.test(e)?"iPhone":/iPad/.test(e)?"iPad":/Android/.test(e)?"Android":/Mac/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Linux/.test(e)?"Linux":"Browser"}function Av(e){const n=new Date(e),o=new Date().getTime()-n.getTime(),l=Math.floor(o/(1e3*60)),u=Math.floor(o/(1e3*60*60)),d=Math.floor(o/(1e3*60*60*24));return l<1?"just now":l<60?`${l} minute${l===1?"":"s"} ago`:u<24?`${u} hour${u===1?"":"s"} ago`:d===1?"yesterday":d<7?`${d} days ago`:n.toLocaleDateString()}function i5(){const{profiles:e,isLoading:n,error:r,deleteProfile:o}=n5(),{browserProfileId:l}=mh(),{connections:u}=qb();return a.jsx(a.Fragment,{children:a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Browser Profiles"}),a.jsx("p",{className:"settings-section-description",children:"Devices that have connected to this server, with their access origins. Each browser profile may connect from multiple URLs (localhost, Tailscale, etc.)."}),r&&a.jsx("p",{className:"form-error",children:r}),a.jsx("div",{className:"settings-group",children:n?a.jsx("p",{className:"settings-hint",children:"Loading profiles..."}):e.length===0?a.jsx("p",{className:"settings-hint",children:"No browser profiles recorded yet. Connect from a browser to see profiles here."}):a.jsx("div",{className:"device-list",children:e.map(d=>{const f=d.browserProfileId===l,p=u.has(d.browserProfileId),x=d.deviceName||`${d.browserProfileId.slice(0,8)}...`;return a.jsxs("div",{className:"device-list-item device-profile-item",children:[a.jsxs("div",{className:"device-list-info",children:[a.jsxs("strong",{children:[a.jsx("span",{className:`device-status ${p?"device-status-online":"device-status-offline"}`,title:p?"Connected":"Disconnected"}),x,f&&a.jsx("span",{className:"device-current-badge",children:"This device"})]}),a.jsx("div",{className:"device-origins",children:d.origins.map(v=>{const{browser:y,os:S}=K0(v.userAgent);return a.jsxs("div",{className:"device-origin",children:[a.jsx("code",{className:"device-origin-url",children:v.origin}),a.jsxs("span",{className:"device-origin-details",children:[y," · ",S]}),a.jsxs("span",{className:"device-origin-time",children:["Last seen ",Av(v.lastSeen)]})]},v.origin)})}),a.jsxs("p",{className:"device-profile-meta",children:["First seen ",Av(d.createdAt)]})]}),a.jsx("button",{type:"button",className:"settings-button settings-button-danger-subtle",onClick:()=>o(d.browserProfileId),title:"Forget this device",children:"Forget"})]},d.browserProfileId)})})})]})})}function o5(){const[e,n]=h.useState(null),[r,o]=h.useState(!0),[l,u]=h.useState(null),[d,f]=h.useState(!1),p=h.useRef(!1),x=h.useCallback(async()=>{o(!0),u(null);try{const S=await Ae.getNetworkBinding();n(S)}catch(S){u(S instanceof Error?S:new Error(String(S)))}finally{o(!1)}},[]);h.useEffect(()=>{p.current||(p.current=!0,x())},[x]);const v=h.useCallback(async S=>{f(!0),u(null);try{const w=await Ae.setNetworkBinding(S);if(!w.success)throw new Error(w.error??"Failed to update binding");return await x(),{redirectUrl:w.redirectUrl}}catch(w){const C=w instanceof Error?w:new Error(String(w));throw u(C),C}finally{f(!1)}},[x]),y=h.useCallback(async()=>{f(!0),u(null);try{const S=await Ae.disableNetworkBinding();if(!S.success)throw new Error(S.error??"Failed to disable network socket");await x()}catch(S){const w=S instanceof Error?S:new Error(String(S));throw u(w),w}finally{f(!1)}},[x]);return{binding:e,loading:r,error:l,applying:d,updateBinding:v,disableNetwork:y,refetch:x}}function l5(){const[e,n]=h.useState(null),[r,o]=h.useState(!0),[l,u]=h.useState(null),d=h.useRef(!1),f=h.useCallback(async()=>{o(!0),u(null);try{const p=await Ae.getServerInfo();n(p)}catch(p){u(p instanceof Error?p:new Error(String(p)))}finally{o(!1)}},[]);return h.useEffect(()=>{d.current||(d.current=!0,f())},[f]),{serverInfo:e,loading:r,error:l,refetch:f}}function c5(){const e=X6(),n=Lc(),{relayDebugEnabled:r,setRelayDebugEnabled:o}=Vo(),{serverInfo:l,loading:u}=l5(),{binding:d,loading:f,applying:p,updateBinding:x}=o5(),{settings:v,isLoading:y}=Fb(),[S,w]=h.useState(""),[C,_]=h.useState(!1),[E,k]=h.useState(""),[M,O]=h.useState(""),[B,L]=h.useState(!1),[U,$]=h.useState(""),[V,F]=h.useState(""),[X,ge]=h.useState(!1),[ee,ne]=h.useState(""),[Ne,ke]=h.useState(null),[D,q]=h.useState(!1),[G,Se]=h.useState(!1),[Me,I]=h.useState(!1);if(d&&e&&v&&!Me){w(String(d.localhost.port)),_(d.network.enabled),k(d.network.host??""),L(e.authEnabled);const Te=v.allowedHosts;Te==="*"?(ge(!0),ne("")):(ge(!1),ne(Te??"")),I(!0)}const re=(Te,We)=>Te?"*":We.trim()||void 0,he=(Te,We,Ie,je,Ze,yt,be)=>{if(!d||!e||!v)return!1;const St=Te!==String(d.localhost.port),_e=We!==d.network.enabled,mt=Ie!==(d.network.host??""),pt=je!==e.authEnabled,Lt=Ze.length>0,cn=re(yt,be),un=v.allowedHosts;return St||_e||mt||pt||Lt||(cn??"")!==(un??"")},oe=Te=>{q(he(Te.port??S,Te.networkEnabled??C,Te.iface??E,Te.requirePw??B,Te.password??U,Te.allowAll??X,Te.hostsText??ee))},Ee=async()=>{if(!e)return;ke(null);const Te=Number.parseInt(S,10);if(Number.isNaN(Te)||Te<1||Te>65535){ke("Port must be a number between 1 and 65535");return}const We=B&&!e.authEnabled,Ie=B&&e.authEnabled&&U.length>0;if(We||Ie){if(U.length<6){ke("Password must be at least 6 characters");return}if(U!==V){ke("Passwords do not match");return}}const je=E==="custom"?M:E;Se(!0);try{const Ze=await x({localhostPort:Te,network:{enabled:C,host:C?je:void 0}});We?(await e.enableAuth(U),$(""),F("")):Ie?(await e.changePassword(U),$(""),F("")):!B&&e.authEnabled&&await e.disableAuth();const yt=re(X,ee);if(await Ae.updateServerSettings({allowedHosts:yt??""}),Ze.redirectUrl){const be=new URL(Ze.redirectUrl);be.pathname=window.location.pathname,be.search=window.location.search,window.location.href=be.toString()}else q(!1)}catch(Ze){ke(Ze instanceof Error?Ze.message:"Failed to apply changes")}finally{Se(!1)}};if(e){if(u||f||y||e.isLoading||!Me)return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Local Access"}),a.jsx("p",{className:"settings-section-description",children:"Loading..."})]});const We=B;return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Local Access"}),a.jsx("p",{className:"settings-section-description",children:"Control how this server is accessed on your local network."}),a.jsx("div",{className:"settings-group",children:a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Status"}),a.jsx("p",{children:l?(()=>{const Ie=d==null?void 0:d.network.host,je=(d==null?void 0:d.network.port)??l.port,Ze=Ie==="0.0.0.0"||Ie==="::",yt=je===l.port;return d!=null&&d.network.enabled&&Ze&&yt?a.jsxs(a.Fragment,{children:["Listening on"," ",a.jsxs("code",{children:[Ie,":",je]})]}):a.jsxs(a.Fragment,{children:["Listening on"," ",a.jsxs("code",{children:[l.host,":",l.port]}),(d==null?void 0:d.network.enabled)&&Ie&&a.jsxs(a.Fragment,{children:[" ","and"," ",a.jsxs("code",{children:[Ie,":",je]})]})]})})():"Unable to fetch server info"})]}),(l==null?void 0:l.localhostOnly)&&!(d!=null&&d.network.enabled)&&a.jsx("span",{className:"settings-status-badge settings-status-detected",children:"Local Only"}),((l==null?void 0:l.boundToAllInterfaces)||(d==null?void 0:d.network.enabled))&&!e.authEnabled&&a.jsx("span",{className:"settings-status-badge settings-status-warning",children:"Network Exposed"})]})}),a.jsxs("form",{className:"settings-group",onSubmit:Ie=>{Ie.preventDefault(),Ee()},children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Listening Port"}),a.jsx("p",{children:"Port used for all network access"})]}),d!=null&&d.localhost.overriddenByCli?a.jsxs("span",{className:"settings-value-readonly",children:[d.localhost.port," ",a.jsx("span",{className:"settings-hint",children:"(set via --port)"})]}):a.jsx("input",{type:"number",className:"settings-input-small",value:S,onChange:Ie=>{w(Ie.target.value),oe({port:Ie.target.value})},min:1,max:65535,autoComplete:"off"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Local Network Access"}),a.jsx("p",{children:"Allow access from other devices on your network"})]}),d!=null&&d.network.overriddenByCli?a.jsxs("span",{className:"settings-value-readonly",children:[d.network.host,":",d.network.port," ",a.jsx("span",{className:"settings-hint",children:"(set via --host)"})]}):a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:C,onChange:Ie=>{_(Ie.target.checked),oe({networkEnabled:Ie.target.checked})}}),a.jsx("span",{className:"toggle-slider"})]})]}),C&&!(d!=null&&d.network.overriddenByCli)&&d&&a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Interface"}),a.jsx("p",{children:"Select which network interface to bind to"})]}),a.jsx(Ta,{label:"Interface",placeholder:"Select interface...",multiSelect:!1,align:"right",options:[...d.interfaces.map(Ie=>({value:Ie.address,label:Ie.displayName})),{value:"0.0.0.0",label:"All interfaces (0.0.0.0)"},{value:"custom",label:"Custom IP..."}],selected:E?[E]:[],onChange:Ie=>{const je=Ie[0]??"";k(je),oe({iface:je})}})]}),C&&!(d!=null&&d.network.overriddenByCli)&&E==="custom"&&a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Custom IP"}),a.jsx("p",{children:"Enter the IP address to bind to"})]}),a.jsx("input",{type:"text",className:"settings-input",placeholder:"192.168.1.100",value:M,onChange:Ie=>O(Ie.target.value)})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Allow All Hostnames"}),a.jsx("p",{children:"Accept requests from any hostname (disables DNS rebinding protection)"})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:X,onChange:Ie=>{ge(Ie.target.checked),oe({allowAll:Ie.target.checked})}}),a.jsx("span",{className:"toggle-slider"})]})]}),!X&&a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Allowed Hostnames"}),a.jsx("p",{children:"Comma-separated list of additional allowed hostnames"})]}),a.jsx("input",{type:"text",className:"settings-input",placeholder:"mydomain.com, other.example.com",value:ee,onChange:Ie=>{ne(Ie.target.value),oe({hostsText:Ie.target.value})}})]}),a.jsx("p",{className:"form-hint",children:"localhost, private IPs, and *.ts.net are always allowed."}),!e.authDisabledByEnv&&a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Require Password"}),a.jsx("p",{children:"Require a password to access this server"})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:B,onChange:Ie=>{L(Ie.target.checked),oe({requirePw:Ie.target.checked})}}),a.jsx("span",{className:"toggle-slider"})]})]}),We&&a.jsxs(a.Fragment,{children:[a.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{position:"absolute",visibility:"hidden",pointerEvents:"none"},tabIndex:-1}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Password"}),a.jsx("p",{children:e.authEnabled?"Leave blank to keep current":"At least 6 characters"})]}),a.jsx("input",{type:"password",className:"settings-input",value:U,onChange:Ie=>{$(Ie.target.value),oe({password:Ie.target.value})},autoComplete:"new-password",placeholder:e.authEnabled?"New password":"Enter password"})]}),U.length>0&&a.jsxs("div",{className:"settings-item",children:[a.jsx("div",{className:"settings-item-info",children:a.jsx("strong",{children:"Confirm Password"})}),a.jsx("input",{type:"password",className:"settings-input",value:V,onChange:Ie=>F(Ie.target.value),autoComplete:"new-password",placeholder:"Confirm password"})]}),!e.authEnabled&&a.jsxs("p",{className:"form-hint",children:["If you forget your password, restart with"," ",a.jsx("code",{children:"--auth-disable"})," to bypass auth."]})]}),e.authDisabledByEnv&&a.jsx("p",{className:"form-warning",children:"Authentication is bypassed by --auth-disable flag."}),a.jsxs("div",{className:"settings-item",children:[Ne&&a.jsx("p",{className:"form-error",children:Ne}),a.jsx("button",{type:"submit",className:"settings-button",disabled:!D||G||p,children:G||p?"Applying...":"Apply Changes"})]})]}),e.authEnabled&&e.isAuthenticated&&a.jsx("div",{className:"settings-group",children:a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Logout"}),a.jsx("p",{children:"Sign out on this device"})]}),a.jsx("button",{type:"button",className:"settings-button settings-button-danger",onClick:e.logout,children:"Logout"})]})})]})}return n?a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Local Access"}),a.jsx("p",{className:"settings-section-description",children:"You are connected to a remote server via relay."}),a.jsxs("div",{className:"settings-group",children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Logout"}),a.jsx("p",{children:"Disconnect from the remote server."})]}),a.jsx("button",{type:"button",className:"settings-button settings-button-danger",onClick:()=>n.disconnect(),children:"Logout"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Relay Debug Logging"}),a.jsx("p",{children:"Log relay requests and responses to the browser console. Useful for debugging connection timeouts."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:r,onChange:Te=>o(Te.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]})]})]}):null}function u5(){const{model:e,setModel:n,thinkingLevel:r,setThinkingLevel:o}=Uc();return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Model"}),a.jsxs("div",{className:"settings-group",children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Model"}),a.jsx("p",{children:"Select which Claude model to use for new sessions."})]}),a.jsx("div",{className:"font-size-selector",children:kf.map(l=>a.jsx("button",{type:"button",className:`font-size-option ${e===l.value?"active":""}`,onClick:()=>n(l.value),children:l.label},l.value))})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Thinking Level"}),a.jsx("p",{children:"Token budget for extended thinking. Higher levels enable deeper reasoning but use more tokens."})]}),a.jsx("div",{className:"font-size-selector",children:T6.map(l=>a.jsxs("button",{type:"button",className:`font-size-option ${r===l.value?"active":""}`,onClick:()=>o(l.value),title:l.description,children:[l.label," (",l.description,")"]},l.value))})]})]})]})}function Zb(){const[e,n]=h.useState(()=>{const l=typeof window<"u"&&"Notification"in window,u=U6();return{isSupported:l&&!u,isMobile:u,permission:l?Notification.permission:"denied",isRequesting:!1}});h.useEffect(()=>{if(!e.isSupported)return;const l=()=>{const u=Notification.permission;u!==e.permission&&n(d=>({...d,permission:u}))};return window.addEventListener("focus",l),()=>window.removeEventListener("focus",l)},[e.isSupported,e.permission]);const r=h.useCallback(async()=>{if(e.isSupported&&e.permission!=="granted"){n(l=>({...l,isRequesting:!0}));try{const l=await Notification.requestPermission();n(u=>({...u,permission:l,isRequesting:!1}))}catch(l){console.error("[useBrowserNotifications] Permission request failed:",l),n(u=>({...u,isRequesting:!1}))}}},[e.isSupported,e.permission]),o=h.useCallback((l,u)=>{if(!e.isSupported||e.permission!=="granted")return!1;try{return new Notification(l,u),!0}catch(d){return console.error("[useBrowserNotifications] Failed to show notification:",d),!1}},[e.isSupported,e.permission]);return{...e,isEnabled:e.permission==="granted",isDenied:e.permission==="denied",requestPermission:r,showNotification:o}}function d5(){const{isSupported:e,isMobile:n,isEnabled:r,isDenied:o,isRequesting:l,requestPermission:u,showNotification:d}=Zb();if(n)return null;if(!e)return a.jsx("div",{className:"settings-item",children:a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Desktop Notifications"}),a.jsx("p",{children:"Notifications are not supported in this browser."})]})});if(o)return a.jsx("div",{className:"settings-item",children:a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Desktop Notifications"}),a.jsx("p",{className:"settings-warning",children:"Notifications are blocked. Enable them in your browser settings to receive desktop alerts."})]})});if(r){const f=()=>{d("Test Notification",{body:"Desktop notifications are working!",icon:"/icon-192.png"})};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Desktop Notifications"}),a.jsx("p",{children:"Enabled. You'll receive notifications when sessions need attention (while the tab is open)."})]}),a.jsx("span",{className:"settings-badge settings-badge-success",children:"Enabled"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Test Desktop Notification"}),a.jsx("p",{children:"Send a test notification to verify it's working."})]}),a.jsx("button",{type:"button",className:"settings-button",onClick:f,children:"Send Test"})]})]})}return a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Desktop Notifications"}),a.jsx("p",{children:"Get notified when sessions need your attention. Works while the tab is open in the background."})]}),a.jsx("button",{type:"button",className:"settings-button",onClick:u,disabled:l,children:l?"Requesting...":"Enable"})]})}function f5(){const{isSupported:e,isSubscribed:n,isLoading:r,error:o,permission:l,subscribe:u,unsubscribe:d,sendTest:f}=mh(),{notifyInApp:p,setNotifyInApp:x}=cT(),[v,y]=h.useState("normal"),S=async()=>{n?await d():await u()};if(!e){const w=o==null?void 0:o.includes("Service worker disabled in dev mode");return a.jsx("div",{className:"settings-item",children:a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Push Notifications"}),a.jsx("p",{children:o||"Push notifications are not supported in this browser."}),w&&a.jsxs("div",{className:"settings-info-box",style:{marginTop:"0.5rem"},children:[a.jsxs("p",{children:["This only affects ",a.jsx("strong",{children:"this device"}),". Other subscribed devices will still receive notifications from the server."]}),a.jsxs("p",{children:["To enable push on this device in dev mode, restart with"," ",a.jsx("code",{children:"VITE_ENABLE_SW=true"}),"."]})]}),a.jsx("p",{style:{marginTop:"0.5rem"},children:a.jsx("a",{href:"https://github.com/kzahel/yepanywhere/blob/main/docs/push-notifications.md",target:"_blank",rel:"noopener noreferrer",children:"Troubleshooting guide"})})]})})}return l==="denied"?a.jsx("div",{className:"settings-item",children:a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Push Notifications"}),a.jsx("p",{className:"settings-warning",children:"Notifications are blocked. Enable them in your browser settings to receive push notifications."})]})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Push Notifications"}),a.jsx("p",{children:"Receive notifications when a session needs your attention, even when the app is in the background."}),o&&a.jsx("p",{className:"settings-error",children:o})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:n,onChange:S,disabled:r}),a.jsx("span",{className:"toggle-slider"})]})]}),n&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Notify When In App"}),a.jsx("p",{children:"Show notifications even when the app is open, as long as you're not viewing that session."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:p,onChange:w=>x(w.target.checked)}),a.jsx("span",{className:"toggle-slider"})]})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Test Notification"}),a.jsx("p",{children:"Send a test notification to verify push is working."})]}),a.jsxs("div",{className:"settings-item-actions",children:[a.jsxs("select",{className:"settings-select",value:v,onChange:w=>y(w.target.value),disabled:r,children:[a.jsx("option",{value:"normal",children:"Normal (auto-dismiss)"}),a.jsx("option",{value:"persistent",children:"Persistent (stays visible)"}),a.jsx("option",{value:"silent",children:"Silent (no sound)"})]}),a.jsx("button",{type:"button",className:"settings-button",onClick:()=>f(v),disabled:r,children:r?"Sending...":"Send Test"})]})]})]})]})}function h5(){const[e,n]=h.useState({settings:null,isLoading:!0,error:null});h.useEffect(()=>{(async()=>{try{const{settings:l}=await Ae.getNotificationSettings();n({settings:l,isLoading:!1,error:null})}catch(l){console.error("[useNotificationSettings] Failed to fetch:",l),n(u=>({...u,isLoading:!1,error:l instanceof Error?l.message:"Failed to load settings"}))}})()},[]);const r=h.useCallback(async(o,l)=>{n(u=>({...u,isLoading:!0,error:null}));try{const{settings:u}=await Ae.updateNotificationSettings({[o]:l});n({settings:u,isLoading:!1,error:null})}catch(u){console.error("[useNotificationSettings] Failed to update:",u),n(d=>({...d,isLoading:!1,error:u instanceof Error?u.message:"Failed to update"}))}},[]);return{...e,updateSetting:r}}function m5(){const[e,n]=h.useState({devices:[],isLoading:!0,error:null}),r=h.useCallback(async()=>{n(l=>({...l,isLoading:!0,error:null}));try{const{subscriptions:l}=await Ae.getPushSubscriptions();n({devices:l,isLoading:!1,error:null})}catch(l){console.error("[useSubscribedDevices] Failed to fetch:",l),n(u=>({...u,isLoading:!1,error:l instanceof Error?l.message:"Failed to load devices"}))}},[]);h.useEffect(()=>{r()},[r]);const o=h.useCallback(async l=>{n(u=>({...u,isLoading:!0,error:null}));try{await Ae.deletePushSubscription(l),await r()}catch(u){console.error("[useSubscribedDevices] Failed to remove:",u),n(d=>({...d,isLoading:!1,error:u instanceof Error?u.message:"Failed to remove device"}))}},[r]);return{...e,removeDevice:o,refetch:r}}function p5(e,n){const r=e||"Unknown device";return n!=null&&n.includes("google")?{displayName:r,browserType:"(Android/Chrome)"}:n!=null&&n.includes("apple")||n!=null&&n.includes("push.apple")?{displayName:r,browserType:"(iOS/Safari)"}:n!=null&&n.includes("mozilla")||n!=null&&n.includes("push.services.mozilla")?{displayName:r,browserType:"(Firefox)"}:{displayName:r,browserType:""}}function g5(e){const n=new Date(e),o=new Date().getTime()-n.getTime(),l=Math.floor(o/(1e3*60*60*24));return l===0?"today":l===1?"yesterday":l<7?`${l} days ago`:n.toLocaleDateString()}function x5(e,n,r){const o=new Map;for(const u of e){const{displayName:d,browserType:f}=p5(u.deviceName,u.endpointDomain),p=n.get(u.browserProfileId);o.set(u.browserProfileId,{browserProfileId:u.browserProfileId,displayName:d,browserType:f,isSubscribed:!0,isConnected:!!p,tabCount:(p==null?void 0:p.connectionCount)??0,subscribedAt:u.createdAt,isCurrentDevice:u.browserProfileId===r})}for(const[u,d]of n)if(!o.has(u)){const f=u.slice(0,8);o.set(u,{browserProfileId:u,displayName:f,browserType:"",isSubscribed:!1,isConnected:!0,tabCount:d.connectionCount,isCurrentDevice:u===r})}const l=Array.from(o.values());return l.sort((u,d)=>u.isCurrentDevice&&!d.isCurrentDevice?-1:!u.isCurrentDevice&&d.isCurrentDevice?1:u.isConnected&&!d.isConnected?-1:!u.isConnected&&d.isConnected?1:u.isConnected&&d.isConnected?d.tabCount-u.tabCount:u.subscribedAt&&d.subscribedAt?new Date(d.subscribedAt).getTime()-new Date(u.subscribedAt).getTime():0),l}function v5(){const{browserProfileId:e}=mh(),{isMobile:n}=Zb(),{devices:r,isLoading:o,removeDevice:l}=m5(),{connections:u,isLoading:d}=qb(),{settings:f,isLoading:p,updateSetting:x}=h5(),v=r.length>0,y=o||d,S=x5(r,u,e);return a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Server Notification Types"}),a.jsx("p",{className:"settings-section-description",children:"Control what types of events trigger push notifications to all devices."}),a.jsxs("div",{className:"settings-group",children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Tool Approvals"}),a.jsx("p",{children:"Notify when Claude needs permission to run a tool (file edits, commands, etc.)"})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:(f==null?void 0:f.toolApproval)??!0,onChange:w=>x("toolApproval",w.target.checked),disabled:p||!v}),a.jsx("span",{className:"toggle-slider"})]})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"User Questions"}),a.jsx("p",{children:"Notify when Claude asks a question and needs your response."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:(f==null?void 0:f.userQuestion)??!0,onChange:w=>x("userQuestion",w.target.checked),disabled:p||!v}),a.jsx("span",{className:"toggle-slider"})]})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Session Halted"}),a.jsx("p",{children:"Notify when a session completes, errors out, or becomes idle."})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:(f==null?void 0:f.sessionHalted)??!0,onChange:w=>x("sessionHalted",w.target.checked),disabled:p||!v}),a.jsx("span",{className:"toggle-slider"})]})]}),!v&&!o&&a.jsx("p",{className:"settings-hint",children:"No devices subscribed. Enable push notifications below to use these settings."})]})]}),!n&&a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Desktop Notifications"}),a.jsx("p",{className:"settings-section-description",children:"Get browser notifications when sessions need attention. Works while the tab is open."}),a.jsx("div",{className:"settings-group",children:a.jsx(d5,{})})]}),a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Push Notifications"}),a.jsx("p",{className:"settings-section-description",children:"Receive push notifications even when the browser is closed or you're on another device."}),a.jsx("div",{className:"settings-group",children:a.jsx(f5,{})})]}),a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Devices"}),a.jsx("p",{className:"settings-section-description",children:"All devices connected to or subscribed to this server."}),a.jsx("div",{className:"settings-group",children:y?a.jsx("p",{className:"settings-hint",children:"Loading devices..."}):S.length===0?a.jsx("p",{className:"settings-hint",children:"No devices connected or subscribed. Enable push notifications above."}):a.jsx("div",{className:"device-list",children:S.map(w=>a.jsxs("div",{className:"device-list-item",children:[a.jsxs("div",{className:"device-list-info",children:[a.jsxs("strong",{children:[w.displayName,w.browserType&&` ${w.browserType}`,w.isCurrentDevice&&a.jsx("span",{className:"device-current-badge",children:"This device"})]}),a.jsxs("p",{children:[w.isConnected?a.jsx("span",{className:"device-status device-status-online",children:w.tabCount===1?"1 tab":`${w.tabCount} tabs`}):a.jsx("span",{className:"device-status device-status-offline",children:"Offline"}),!w.isSubscribed&&a.jsx("span",{className:"device-no-push",children:"No push"}),w.subscribedAt&&a.jsxs("span",{className:"device-subscribed-date",children:["Subscribed ",g5(w.subscribedAt)]})]})]}),w.isSubscribed&&a.jsx("button",{type:"button",className:"settings-button settings-button-danger-subtle",onClick:()=>l(w.browserProfileId),title:w.isCurrentDevice?"Unsubscribe this device":"Remove this device",children:"Remove"})]},w.browserProfileId))})})]})]})}function b5(){const{providers:e}=uh(),r=ZT().map(o=>{const l=e.find(u=>u.name===o.id);return{...o,installed:(l==null?void 0:l.installed)??!1,authenticated:(l==null?void 0:l.authenticated)??!1}});return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Providers"}),a.jsx("p",{className:"settings-section-description",children:"AI providers are auto-detected when their CLI is installed."}),a.jsx("div",{className:"settings-group",children:r.map(o=>a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsxs("div",{className:"settings-item-header",children:[a.jsx("strong",{children:o.displayName}),o.installed?a.jsx("span",{className:"settings-status-badge settings-status-detected",children:"Detected"}):a.jsx("span",{className:"settings-status-badge settings-status-not-detected",children:"Not Detected"})]}),a.jsx("p",{children:o.metadata.description}),o.metadata.limitations.length>0&&a.jsx("ul",{className:"settings-limitations",children:o.metadata.limitations.map(l=>a.jsx("li",{children:l},l))})]}),o.metadata.website&&a.jsx("a",{href:o.metadata.website,target:"_blank",rel:"noopener noreferrer",className:"settings-link",children:"Website"})]},o.id))})]})}function y5(){const[e,n]=h.useState(null),[r,o]=h.useState(null),[l,u]=h.useState(null),[d,f]=h.useState([]),[p,x]=h.useState(!0),[v,y]=h.useState(null),S=h.useCallback(async()=>{try{const[L,U,$,V]=await Promise.all([Ue("/remote-access/config"),Ue("/remote-access/relay"),Ue("/remote-access/relay/status"),Ue("/remote-access/sessions")]);n(L),o(U.relay),u($),f(V.sessions),y(null)}catch(L){console.error("[useRemoteAccess] Failed to fetch config:",L),y(L instanceof Error?L.message:"Failed to fetch config")}},[]);h.useEffect(()=>{x(!0),S().finally(()=>x(!1))},[S]);const w=h.useCallback(async L=>{try{await Ue("/remote-access/configure",{method:"POST",body:JSON.stringify({password:L})}),await S()}catch(U){const $=U instanceof Error?U.message:"Failed to configure remote access";throw y($),new Error($)}},[S]),C=h.useCallback(async()=>{try{await Ue("/remote-access/enable",{method:"POST"}),await S()}catch(L){const U=L instanceof Error?L.message:"Failed to enable remote access";throw y(U),new Error(U)}},[S]),_=h.useCallback(async()=>{try{await Ue("/remote-access/disable",{method:"POST"}),await S()}catch(L){const U=L instanceof Error?L.message:"Failed to disable remote access";throw y(U),new Error(U)}},[S]),E=h.useCallback(async()=>{try{await Ue("/remote-access/clear",{method:"POST"}),await S()}catch(L){const U=L instanceof Error?L.message:"Failed to clear remote access credentials";throw y(U),new Error(U)}},[S]),k=h.useCallback(async L=>{try{await Ue("/remote-access/relay",{method:"PUT",body:JSON.stringify(L)}),await S()}catch(U){const $=U instanceof Error?U.message:"Failed to update relay configuration";throw y($),new Error($)}},[S]),M=h.useCallback(async()=>{try{await Ue("/remote-access/relay",{method:"DELETE"}),await S()}catch(L){const U=L instanceof Error?L.message:"Failed to clear relay configuration";throw y(U),new Error(U)}},[S]),O=h.useCallback(async L=>{try{await Ue(`/remote-access/sessions/${L}`,{method:"DELETE"}),await S()}catch(U){const $=U instanceof Error?U.message:"Failed to revoke session";throw y($),new Error($)}},[S]),B=h.useCallback(async()=>{try{await Ue("/remote-access/sessions",{method:"DELETE"}),await S()}catch(L){const U=L instanceof Error?L.message:"Failed to revoke all sessions";throw y(U),new Error(U)}},[S]);return{config:e,relayConfig:r,relayStatus:l,sessions:d,loading:p,error:v,configure:w,enable:C,disable:_,clearCredentials:E,updateRelayConfig:k,clearRelayConfig:M,revokeSession:O,revokeAllSessions:B,refresh:S}}var Ca=(e=>(e[e.Border=-1]="Border",e[e.Data=0]="Data",e[e.Function=1]="Function",e[e.Position=2]="Position",e[e.Timing=3]="Timing",e[e.Alignment=4]="Alignment",e))(Ca||{}),S5=Object.defineProperty,j5=(e,n,r)=>n in e?S5(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,hc=(e,n,r)=>(j5(e,typeof n!="symbol"?n+"":n,r),r);const w5=[0,1],Vb=[1,0],Gb=[2,3],Yb=[3,2],N5={L:w5,M:Vb,Q:Gb,H:Yb},_5=/^[0-9]*$/,E5=/^[A-Z0-9 $%*+.\/:-]*$/,xf="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",ph=1,gh=40,Mv=3,C5=3,mc=40,k5=10,Wb=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],Xb=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];class T5{constructor(n,r,o,l){if(this.version=n,this.ecc=r,hc(this,"size"),hc(this,"mask"),hc(this,"modules",[]),hc(this,"types",[]),n<ph||n>gh)throw new RangeError("Version value out of range");if(l<-1||l>7)throw new RangeError("Mask value out of range");this.size=n*4+17;const u=Array.from({length:this.size},()=>!1);for(let f=0;f<this.size;f++)this.modules.push(u.slice()),this.types.push(u.map(()=>0));this.drawFunctionPatterns();const d=this.addEccAndInterleave(o);if(this.drawCodewords(d),l===-1){let f=1e9;for(let p=0;p<8;p++){this.applyMask(p),this.drawFormatBits(p);const x=this.getPenaltyScore();x<f&&(l=p,f=x),this.applyMask(p)}}this.mask=l,this.applyMask(l),this.drawFormatBits(l)}getModule(n,r){return n>=0&&n<this.size&&r>=0&&r<this.size&&this.modules[r][n]}drawFunctionPatterns(){for(let o=0;o<this.size;o++)this.setFunctionModule(6,o,o%2===0,Ca.Timing),this.setFunctionModule(o,6,o%2===0,Ca.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const n=this.getAlignmentPatternPositions(),r=n.length;for(let o=0;o<r;o++)for(let l=0;l<r;l++)o===0&&l===0||o===0&&l===r-1||o===r-1&&l===0||this.drawAlignmentPattern(n[o],n[l]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(n){const r=this.ecc[1]<<3|n;let o=r;for(let u=0;u<10;u++)o=o<<1^(o>>>9)*1335;const l=(r<<10|o)^21522;for(let u=0;u<=5;u++)this.setFunctionModule(8,u,Nr(l,u));this.setFunctionModule(8,7,Nr(l,6)),this.setFunctionModule(8,8,Nr(l,7)),this.setFunctionModule(7,8,Nr(l,8));for(let u=9;u<15;u++)this.setFunctionModule(14-u,8,Nr(l,u));for(let u=0;u<8;u++)this.setFunctionModule(this.size-1-u,8,Nr(l,u));for(let u=8;u<15;u++)this.setFunctionModule(8,this.size-15+u,Nr(l,u));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let n=this.version;for(let o=0;o<12;o++)n=n<<1^(n>>>11)*7973;const r=this.version<<12|n;for(let o=0;o<18;o++){const l=Nr(r,o),u=this.size-11+o%3,d=Math.floor(o/3);this.setFunctionModule(u,d,l),this.setFunctionModule(d,u,l)}}drawFinderPattern(n,r){for(let o=-4;o<=4;o++)for(let l=-4;l<=4;l++){const u=Math.max(Math.abs(l),Math.abs(o)),d=n+l,f=r+o;d>=0&&d<this.size&&f>=0&&f<this.size&&this.setFunctionModule(d,f,u!==2&&u!==4,Ca.Position)}}drawAlignmentPattern(n,r){for(let o=-2;o<=2;o++)for(let l=-2;l<=2;l++)this.setFunctionModule(n+l,r+o,Math.max(Math.abs(l),Math.abs(o))!==1,Ca.Alignment)}setFunctionModule(n,r,o,l=Ca.Function){this.modules[r][n]=o,this.types[r][n]=l}addEccAndInterleave(n){const r=this.version,o=this.ecc;if(n.length!==yc(r,o))throw new RangeError("Invalid argument");const l=Xb[o[0]][r],u=Wb[o[0]][r],d=Math.floor(zf(r)/8),f=l-d%l,p=Math.floor(d/l),x=[],v=B5(u);for(let S=0,w=0;S<l;S++){const C=n.slice(w,w+p-u+(S<f?0:1));w+=C.length;const _=I5(C,v);S<f&&C.push(0),x.push(C.concat(_))}const y=[];for(let S=0;S<x[0].length;S++)x.forEach((w,C)=>{(S!==p-u||C>=f)&&y.push(w[S])});return y}drawCodewords(n){if(n.length!==Math.floor(zf(this.version)/8))throw new RangeError("Invalid argument");let r=0;for(let o=this.size-1;o>=1;o-=2){o===6&&(o=5);for(let l=0;l<this.size;l++)for(let u=0;u<2;u++){const d=o-u,p=(o+1&2)===0?this.size-1-l:l;!this.types[p][d]&&r<n.length*8&&(this.modules[p][d]=Nr(n[r>>>3],7-(r&7)),r++)}}}applyMask(n){if(n<0||n>7)throw new RangeError("Mask value out of range");for(let r=0;r<this.size;r++)for(let o=0;o<this.size;o++){let l;switch(n){case 0:l=(o+r)%2===0;break;case 1:l=r%2===0;break;case 2:l=o%3===0;break;case 3:l=(o+r)%3===0;break;case 4:l=(Math.floor(o/3)+Math.floor(r/2))%2===0;break;case 5:l=o*r%2+o*r%3===0;break;case 6:l=(o*r%2+o*r%3)%2===0;break;case 7:l=((o+r)%2+o*r%3)%2===0;break;default:throw new Error("Unreachable")}!this.types[r][o]&&l&&(this.modules[r][o]=!this.modules[r][o])}}getPenaltyScore(){let n=0;for(let u=0;u<this.size;u++){let d=!1,f=0;const p=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[u][x]===d?(f++,f===5?n+=Mv:f>5&&n++):(this.finderPenaltyAddHistory(f,p),d||(n+=this.finderPenaltyCountPatterns(p)*mc),d=this.modules[u][x],f=1);n+=this.finderPenaltyTerminateAndCount(d,f,p)*mc}for(let u=0;u<this.size;u++){let d=!1,f=0;const p=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][u]===d?(f++,f===5?n+=Mv:f>5&&n++):(this.finderPenaltyAddHistory(f,p),d||(n+=this.finderPenaltyCountPatterns(p)*mc),d=this.modules[x][u],f=1);n+=this.finderPenaltyTerminateAndCount(d,f,p)*mc}for(let u=0;u<this.size-1;u++)for(let d=0;d<this.size-1;d++){const f=this.modules[u][d];f===this.modules[u][d+1]&&f===this.modules[u+1][d]&&f===this.modules[u+1][d+1]&&(n+=C5)}let r=0;for(const u of this.modules)r=u.reduce((d,f)=>d+(f?1:0),r);const o=this.size*this.size,l=Math.ceil(Math.abs(r*20-o*10)/o)-1;return n+=l*k5,n}getAlignmentPatternPositions(){if(this.version===1)return[];{const n=Math.floor(this.version/7)+2,r=this.version===32?26:Math.ceil((this.version*4+4)/(n*2-2))*2,o=[6];for(let l=this.size-7;o.length<n;l-=r)o.splice(1,0,l);return o}}finderPenaltyCountPatterns(n){const r=n[1],o=r>0&&n[2]===r&&n[3]===r*3&&n[4]===r&&n[5]===r;return(o&&n[0]>=r*4&&n[6]>=r?1:0)+(o&&n[6]>=r*4&&n[0]>=r?1:0)}finderPenaltyTerminateAndCount(n,r,o){return n&&(this.finderPenaltyAddHistory(r,o),r=0),r+=this.size,this.finderPenaltyAddHistory(r,o),this.finderPenaltyCountPatterns(o)}finderPenaltyAddHistory(n,r){r[0]===0&&(n+=this.size),r.pop(),r.unshift(n)}}function Er(e,n,r){if(n<0||n>31||e>>>n)throw new RangeError("Value out of range");for(let o=n-1;o>=0;o--)r.push(e>>>o&1)}function Nr(e,n){return(e>>>n&1)!==0}class xh{constructor(n,r,o){if(this.mode=n,this.numChars=r,this.bitData=o,r<0)throw new RangeError("Invalid argument");this.bitData=o.slice()}getData(){return this.bitData.slice()}}const R5=[1,10,12,14],A5=[2,9,11,13],M5=[4,8,16,16];function Kb(e,n){return e[Math.floor((n+7)/17)+1]}function Jb(e){const n=[];for(const r of e)Er(r,8,n);return new xh(M5,e.length,n)}function O5(e){if(!Qb(e))throw new RangeError("String contains non-numeric characters");const n=[];for(let r=0;r<e.length;){const o=Math.min(e.length-r,3);Er(Number.parseInt(e.substring(r,r+o),10),o*3+1,n),r+=o}return new xh(R5,e.length,n)}function z5(e){if(!ey(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");const n=[];let r;for(r=0;r+2<=e.length;r+=2){let o=xf.indexOf(e.charAt(r))*45;o+=xf.indexOf(e.charAt(r+1)),Er(o,11,n)}return r<e.length&&Er(xf.indexOf(e.charAt(r)),6,n),new xh(A5,e.length,n)}function L5(e){return e===""?[]:Qb(e)?[O5(e)]:ey(e)?[z5(e)]:[Jb(D5(e))]}function Qb(e){return _5.test(e)}function ey(e){return E5.test(e)}function U5(e,n){let r=0;for(const o of e){const l=Kb(o.mode,n);if(o.numChars>=1<<l)return Number.POSITIVE_INFINITY;r+=4+l+o.bitData.length}return r}function D5(e){e=encodeURI(e);const n=[];for(let r=0;r<e.length;r++)e.charAt(r)!=="%"?n.push(e.charCodeAt(r)):(n.push(Number.parseInt(e.substring(r+1,r+3),16)),r+=2);return n}function zf(e){if(e<ph||e>gh)throw new RangeError("Version number out of range");let n=(16*e+128)*e+64;if(e>=2){const r=Math.floor(e/7)+2;n-=(25*r-10)*r-55,e>=7&&(n-=36)}return n}function yc(e,n){return Math.floor(zf(e)/8)-Wb[n[0]][e]*Xb[n[0]][e]}function B5(e){if(e<1||e>255)throw new RangeError("Degree out of range");const n=[];for(let o=0;o<e-1;o++)n.push(0);n.push(1);let r=1;for(let o=0;o<e;o++){for(let l=0;l<n.length;l++)n[l]=Lf(n[l],r),l+1<n.length&&(n[l]^=n[l+1]);r=Lf(r,2)}return n}function I5(e,n){const r=n.map(o=>0);for(const o of e){const l=o^r.shift();r.push(0),n.forEach((u,d)=>r[d]^=Lf(u,l))}return r}function Lf(e,n){if(e>>>8||n>>>8)throw new RangeError("Byte out of range");let r=0;for(let o=7;o>=0;o--)r=r<<1^(r>>>7)*285,r^=(n>>>o&1)*e;return r}function $5(e,n,r=1,o=40,l=-1,u=!0){if(!(ph<=r&&r<=o&&o<=gh)||l<-1||l>7)throw new RangeError("Invalid value");let d,f;for(d=r;;d++){const y=yc(d,n)*8,S=U5(e,d);if(S<=y){f=S;break}if(d>=o)throw new RangeError("Data too long")}for(const y of[Vb,Gb,Yb])u&&f<=yc(d,y)*8&&(n=y);const p=[];for(const y of e){Er(y.mode[0],4,p),Er(y.numChars,Kb(y.mode,d),p);for(const S of y.getData())p.push(S)}const x=yc(d,n)*8;Er(0,Math.min(4,x-p.length),p),Er(0,(8-p.length%8)%8,p);for(let y=236;p.length<x;y^=253)Er(y,8,p);const v=Array.from({length:Math.ceil(p.length/8)},()=>0);return p.forEach((y,S)=>v[S>>>3]|=y<<7-(S&7)),new T5(d,n,v,l)}function P5(e,n){const{ecc:r="L",boostEcc:o=!1,minVersion:l=1,maxVersion:u=40,maskPattern:d=-1,border:f=1}={},p=typeof e=="string"?L5(e):Array.isArray(e)?[Jb(e)]:void 0;if(!p)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);const x=$5(p,N5[r],l,u,d,o);return H5({version:x.version,maskPattern:x.mask,size:x.size,data:x.modules,types:x.types},f)}function H5(e,n=1){if(!n)return e;const{size:r}=e,o=r+n*2;e.size=o,e.data.forEach(u=>{for(let d=0;d<n;d++)u.unshift(!1),u.push(!1)});for(let u=0;u<n;u++)e.data.unshift(Array.from({length:o},d=>!1)),e.data.push(Array.from({length:o},d=>!1));const l=Ca.Border;e.types.forEach(u=>{for(let d=0;d<n;d++)u.unshift(l),u.push(l)});for(let u=0;u<n;u++)e.types.unshift(Array.from({length:o},d=>l)),e.types.push(Array.from({length:o},d=>l));return e}function F5({value:e,size:n=200,color:r="#000000",bgColor:o="#ffffff"}){const{data:l}=P5(e),u=l.length,d=n/u;let f="";for(let p=0;p<u;p++){const x=l[p];if(x){for(let v=0;v<u;v++)if(x[v]){const y=v*d,S=p*d;f+=`M${y},${S}h${d}v${d}h-${d}z`}}}return a.jsxs("svg",{width:n,height:n,viewBox:`0 0 ${n} ${n}`,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"QR code",children:[a.jsx("rect",{width:n,height:n,fill:o}),a.jsx("path",{d:f,fill:r})]})}const mi="wss://relay.yepanywhere.com/ws",vf="https://yepanywhere.com/remote/login/relay";function Ov(e){const n=new Date(e),o=new Date().getTime()-n.getTime(),l=Math.floor(o/(1e3*60)),u=Math.floor(o/(1e3*60*60)),d=Math.floor(o/(1e3*60*60*24));return l<1?"just now":l<60?`${l} minute${l===1?"":"s"} ago`:u<24?`${u} hour${u===1?"":"s"} ago`:d===1?"yesterday":d<7?`${d} days ago`:n.toLocaleDateString()}function q5(e,n,r){if(!n)return{text:"Disabled",className:"status-disabled"};if(!r)return{text:"Not configured",className:"status-warning"};switch(e){case"waiting":return{text:"Connected",className:"status-success"};case"connecting":return{text:"Connecting...",className:"status-pending"};case"registering":return{text:"Registering...",className:"status-pending"};case"rejected":return{text:"Username taken",className:"status-error"};default:return{text:"Disconnected",className:"status-warning"}}}function Z5({title:e="Remote Access",description:n="Access your server from anywhere.",onSetupComplete:r}){const{config:o,relayConfig:l,relayStatus:u,sessions:d,loading:f,error:p,configure:x,enable:v,disable:y,updateRelayConfig:S,revokeSession:w,revokeAllSessions:C,refresh:_}=y5(),[E,k]=h.useState(""),[M,O]=h.useState(""),[B,L]=h.useState(""),[U,$]=h.useState("default"),[V,F]=h.useState(""),[X,ge]=h.useState(!1),[ee,ne]=h.useState(null),[Ne,ke]=h.useState(!1),[D,q]=h.useState(!1),[G,Se]=h.useState(null),[Me,I]=h.useState(!1);h.useEffect(()=>{l&&(k(l.username),l.url===mi?($("default"),F("")):($("custom"),F(l.url)))},[l]),h.useEffect(()=>{const _e=E!==((l==null?void 0:l.username)??""),mt=M.length>0,pt=U==="default"?mi:V,Lt=(l==null?void 0:l.url)??mi;q(_e||mt||pt!==Lt)},[E,M,U,V,l]),h.useEffect(()=>{if((u==null?void 0:u.status)==="connecting"||(u==null?void 0:u.status)==="registering"){const _e=setInterval(_,2e3);return()=>clearInterval(_e)}},[u==null?void 0:u.status,_]);const re=(o==null?void 0:o.enabled)??!1,he=!!(o!=null&&o.username),oe=()=>U==="default"?mi:V,Ee=async()=>{if(ne(null),!E.trim())return ne("Username is required"),!1;if(E.length<3)return ne("Username must be at least 3 characters"),!1;if(!he&&!M)return ne("Password is required"),!1;if(M&&M.length<8)return ne("Password must be at least 8 characters"),!1;if(M&&M!==B)return ne("Passwords do not match"),!1;if(U==="custom"&&!V.trim())return ne("Custom relay URL is required"),!1;try{const _e=oe();return(E!==(l==null?void 0:l.username)||_e!==(l==null?void 0:l.url))&&await S({url:_e,username:E}),M&&(await x(M),Se(M)),O(""),L(""),q(!1),!0}catch(_e){return ne(_e instanceof Error?_e.message:"Failed to save"),!1}},Te=async _e=>{ne(null),ge(!0);try{if(_e)if(D){if(!await Ee()){ge(!1);return}r==null||r()}else he&&(await v(),r==null||r());else await y()}catch(mt){ne(mt instanceof Error?mt.message:"Failed to update")}finally{ge(!1)}},We=async _e=>{_e.preventDefault(),ge(!0),await Ee()&&(r==null||r()),ge(!1)},Ie=async _e=>{await navigator.clipboard.writeText(_e),ke(!0),setTimeout(()=>ke(!1),2e3)};if(f)return a.jsxs("div",{className:"remote-access-setup",children:[a.jsx("div",{className:"remote-access-header",children:a.jsxs("div",{children:[a.jsx("h3",{children:e}),a.jsx("p",{children:n})]})}),a.jsx("div",{className:"remote-access-loading",children:"Loading..."})]});const je=q5((u==null?void 0:u.status)??null,re,he),Ze=(()=>{const _e=new URLSearchParams;E&&_e.set("u",E);const mt=oe();mt!==mi&&_e.set("r",mt);const pt=_e.toString();return pt?`${vf}?${pt}`:vf})(),yt=(()=>{if(!G||!E)return null;const _e=new URLSearchParams;_e.set("u",E),_e.set("p",G);const mt=oe();return mt!==mi&&_e.set("r",mt),`${vf}#${_e.toString()}`})(),be=re&&(u==null?void 0:u.status)==="waiting"&&yt!==null,St=he||E&&M;return a.jsxs("div",{className:"remote-access-setup",children:[a.jsxs("div",{className:"remote-access-header",children:[a.jsxs("div",{children:[a.jsx("h3",{children:e}),a.jsx("p",{children:n})]}),a.jsxs("label",{className:"toggle-switch",children:[a.jsx("input",{type:"checkbox",checked:re,onChange:_e=>Te(_e.target.checked),disabled:X||!re&&!St}),a.jsx("span",{className:"toggle-slider"})]})]}),a.jsxs("form",{onSubmit:We,className:"remote-access-form",children:[a.jsxs("div",{className:"form-field",children:[a.jsx("label",{htmlFor:"remote-username",children:"Username"}),a.jsx("input",{id:"remote-username",type:"text",value:E,onChange:_e=>k(_e.target.value.toLowerCase()),placeholder:"my-server",minLength:3,maxLength:32,pattern:"[a-z0-9][a-z0-9-]*[a-z0-9]|[a-z0-9]{1,2}",title:"Lowercase letters, numbers, and hyphens only",autoComplete:"username",disabled:X})]}),a.jsxs("div",{className:"form-field",children:[a.jsx("label",{htmlFor:"remote-password",children:he?"New Password (leave blank to keep)":"Password"}),a.jsx("input",{id:"remote-password",type:"password",value:M,onChange:_e=>O(_e.target.value),placeholder:he?"••••••••":"",minLength:8,autoComplete:"new-password",disabled:X})]}),M&&a.jsxs("div",{className:"form-field",children:[a.jsx("label",{htmlFor:"remote-confirm",children:"Confirm Password"}),a.jsx("input",{id:"remote-confirm",type:"password",value:B,onChange:_e=>L(_e.target.value),minLength:8,autoComplete:"new-password",disabled:X})]}),a.jsxs("div",{className:"form-field",children:[a.jsx("label",{htmlFor:"relay-select",children:"Relay Server"}),a.jsxs("select",{id:"relay-select",value:U,onChange:_e=>$(_e.target.value),disabled:X,className:"form-select",children:[a.jsx("option",{value:"default",children:"Default"}),a.jsx("option",{value:"custom",children:"Custom"})]})]}),U==="custom"&&a.jsxs("div",{className:"form-field",children:[a.jsx("label",{htmlFor:"custom-relay-url",children:"Custom Relay URL"}),a.jsx("input",{id:"custom-relay-url",type:"text",value:V,onChange:_e=>F(_e.target.value),placeholder:"wss://your-relay.example.com/ws",disabled:X})]}),a.jsxs("div",{className:"remote-access-status",children:[a.jsx("span",{className:"status-label",children:"Status:"}),a.jsx("span",{className:`status-indicator ${je.className}`,children:je.text}),(u==null?void 0:u.error)&&a.jsx("span",{className:"status-error-detail",children:u.error})]}),(ee||p)&&a.jsx("p",{className:"form-error",children:ee||p}),re&&E&&a.jsxs("div",{className:"remote-access-connect",children:[a.jsx("span",{className:"connect-label",children:"Connect from:"}),a.jsxs("div",{className:"connect-url-row",children:[a.jsx("code",{className:"connect-url",children:Ze}),a.jsx("button",{type:"button",className:"copy-button",onClick:()=>Ie(Ze),title:"Copy URL",children:Ne?"Copied!":"Copy"})]})]}),be&&a.jsxs("div",{className:"remote-access-qr",children:[a.jsx("button",{type:"button",className:"qr-toggle-button",onClick:()=>I(!Me),children:Me?"Hide QR Code":"Show QR Code"}),Me&&yt&&a.jsxs("div",{className:"qr-code-container",children:[a.jsx(F5,{value:yt,size:200}),a.jsx("p",{className:"qr-code-hint",children:"Scan to connect and auto-login from your phone"})]})]}),a.jsxs("div",{className:"remote-access-sessions",children:[a.jsxs("div",{className:"sessions-header",children:[a.jsxs("span",{className:"sessions-title",children:["Sessions (",d.length,")"]}),d.length>0&&a.jsx("button",{type:"button",className:"revoke-all-button",onClick:()=>C(),disabled:X,children:"Revoke All"})]}),d.length===0?a.jsx("p",{className:"sessions-empty",children:"No sessions"}):a.jsx("ul",{className:"sessions-list",children:d.map(_e=>{const{browser:mt,os:pt}=_e.userAgent?K0(_e.userAgent):{browser:"Unknown",os:"Unknown"},Lt=_e.userAgent||_e.origin;return a.jsxs("li",{className:"session-item",children:[a.jsx("div",{className:"session-info",children:Lt?a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"session-device",children:[mt," · ",pt]}),_e.origin&&a.jsx("code",{className:"session-origin",children:_e.origin}),a.jsxs("span",{className:"session-dates",children:["Created ",Ov(_e.createdAt)," · Last used ",Ov(_e.lastUsed)]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"session-created",children:["Created:"," ",new Date(_e.createdAt).toLocaleDateString()]}),a.jsxs("span",{className:"session-last-used",children:["Last used:"," ",new Date(_e.lastUsed).toLocaleDateString()]})]})}),a.jsx("button",{type:"button",className:"revoke-button",onClick:()=>w(_e.sessionId),disabled:X,children:"Revoke"})]},_e.sessionId)})})]}),a.jsx("div",{className:"remote-access-actions",children:a.jsx("button",{type:"submit",className:"settings-button",disabled:X||!D,children:X?"Saving...":"Save"})})]})]})}function V5(){const e=us(),n=Lc(),r=()=>{n==null||n.disconnect(),e("/login")};if(n){const o=n.currentHostId?C6(n.currentHostId):null,l=(o==null?void 0:o.displayName)||n.storedUsername||"Remote server";return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Remote Access"}),a.jsx("p",{className:"settings-section-description",children:"You are connected to a remote server via relay."}),a.jsxs("div",{className:"settings-group",children:[a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Current Host"}),a.jsx("p",{children:l})]}),a.jsx("button",{type:"button",className:"settings-button",onClick:r,children:"Switch Host"})]}),a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Logout"}),a.jsx("p",{children:"Disconnect from the remote server"})]}),a.jsx("button",{type:"button",className:"settings-button settings-button-danger",onClick:()=>n.disconnect(),children:"Logout"})]})]})]})}return a.jsx("section",{className:"settings-section",children:a.jsx(Z5,{title:"Remote Access",description:"Access your yepanywhere server from anywhere through an encrypted relay connection."})})}function G5(){const{executors:e,loading:n,addExecutor:r,removeExecutor:o,testExecutor:l}=Sb(),[u,d]=h.useState(""),[f,p]=h.useState(!1),[x,v]=h.useState(null),[y,S]=h.useState({}),w=async()=>{if(!(!u.trim()||f)){p(!0),v(null);try{await r(u.trim()),d("")}catch(k){v(k instanceof Error?k.message:"Failed to add executor")}finally{p(!1)}}},C=async k=>{try{await o(k),S(M=>{const{[k]:O,...B}=M;return B})}catch(M){console.error("Failed to remove executor:",M)}},_=async k=>{S(M=>({...M,[k]:{testing:!0}}));try{const M=await l(k);S(O=>({...O,[k]:{testing:!1,result:M}}))}catch(M){S(O=>({...O,[k]:{testing:!1,result:{success:!1,error:M instanceof Error?M.message:"Connection failed"}}}))}},E=k=>{k.key==="Enter"&&(k.preventDefault(),w())};return a.jsxs("section",{className:"settings-section",children:[a.jsx("h2",{children:"Remote Executors"}),a.jsx("p",{className:"settings-section-description",children:"Run Claude sessions on remote machines via SSH. Add SSH host aliases from your ~/.ssh/config file."}),a.jsx("div",{className:"settings-group",children:a.jsxs("div",{className:"settings-item",children:[a.jsxs("div",{className:"settings-item-info",children:[a.jsx("strong",{children:"Add Remote Executor"}),a.jsx("p",{children:'Enter an SSH host alias (e.g., "devbox", "gpu-server")'})]}),a.jsxs("div",{className:"remote-executor-add",children:[a.jsx("input",{type:"text",value:u,onChange:k=>d(k.target.value),onKeyDown:E,placeholder:"SSH host alias",disabled:f,className:"remote-executor-input"}),a.jsx("button",{type:"button",onClick:w,disabled:!u.trim()||f,className:"remote-executor-add-button",children:f?"Adding...":"Add"})]}),x&&a.jsx("p",{className:"settings-error",children:x})]})}),a.jsxs("div",{className:"settings-group",children:[a.jsx("h3",{children:"Configured Executors"}),n?a.jsx("p",{className:"settings-loading",children:"Loading..."}):e.length===0?a.jsx("p",{className:"settings-empty",children:"No remote executors configured. Add one above to run sessions on remote machines."}):a.jsx("div",{className:"remote-executor-list",children:e.map(k=>{var O;const M=y[k];return a.jsxs("div",{className:"remote-executor-item",children:[a.jsxs("div",{className:"remote-executor-item-info",children:[a.jsx("span",{className:"remote-executor-host",children:k}),(M==null?void 0:M.result)&&a.jsx("span",{className:`settings-status-badge ${M.result.success?"settings-status-detected":"settings-status-not-detected"}`,children:M.result.success?"Connected":"Failed"})]}),(M==null?void 0:M.result)&&!M.result.success&&a.jsx("p",{className:"settings-error remote-executor-error",children:M.result.error}),((O=M==null?void 0:M.result)==null?void 0:O.success)&&a.jsx("p",{className:"remote-executor-details",children:M.result.claudeAvailable?"Claude CLI available":"Claude CLI not found"}),a.jsxs("div",{className:"remote-executor-actions",children:[a.jsx("button",{type:"button",onClick:()=>_(k),disabled:M==null?void 0:M.testing,className:"remote-executor-test-button",children:M!=null&&M.testing?"Testing...":"Test Connection"}),a.jsx("button",{type:"button",onClick:()=>C(k),className:"remote-executor-remove-button",children:"Remove"})]})]},k)})})]}),a.jsxs("div",{className:"settings-group",children:[a.jsx("h3",{children:"Setup Requirements"}),a.jsxs("ul",{className:"settings-requirements",children:[a.jsx("li",{children:"SSH host alias configured in ~/.ssh/config"}),a.jsx("li",{children:"SSH key-based authentication (no password prompts)"}),a.jsx("li",{children:"Claude CLI installed on the remote machine"}),a.jsx("li",{children:"Project paths must be the same on local and remote machines (e.g., ~/code/project)"})]})]})]})}const zv=[{id:"appearance",label:"Appearance",icon:"🎨",description:"Theme, font size, streaming"},{id:"model",label:"Model",icon:"🧠",description:"Claude model and thinking settings"},{id:"notifications",label:"Notifications",icon:"🔔",description:"Push notification preferences"},{id:"devices",label:"Devices",icon:"📱",description:"Browser profiles and connection origins"},{id:"local-access",label:"Local Access",icon:"🔒",description:"Network binding and authentication"},{id:"remote",label:"Remote Access",icon:"🌐",description:"Relay server configuration"},{id:"providers",label:"Providers",icon:"🔌",description:"AI provider integrations"},{id:"remote-executors",label:"Remote Executors",icon:"🖥️",description:"Run sessions on remote machines"},{id:"about",label:"About",icon:"ℹ️",description:"Version and support"}],Y5={id:"development",label:"Development",icon:"🛠️",description:"Developer tools and debugging"},W5={appearance:e5,model:u5,notifications:v5,devices:i5,"local-access":c5,remote:V5,providers:b5,"remote-executors":G5,about:QA,development:t5};function Lv({category:e,isActive:n,onClick:r}){return a.jsxs("button",{type:"button",className:`settings-category-item ${n?"active":""}`,onClick:r,children:[a.jsx("span",{className:"settings-category-icon",children:e.icon}),a.jsxs("div",{className:"settings-category-text",children:[a.jsx("span",{className:"settings-category-label",children:e.label}),a.jsx("span",{className:"settings-category-description",children:e.description})]}),a.jsx("span",{className:"settings-category-chevron",children:"›"})]})}function Uv(){var S;const{category:e}=kc(),n=us(),{openSidebar:r,isWideScreen:o,toggleSidebar:l,isSidebarCollapsed:u}=za(),{isManualReloadMode:d}=lh(),f=d?[...zv,Y5]:zv,p=e||(o?(S=f[0])==null?void 0:S.id:void 0),x=w=>{n(`/settings/${w}`)},v=()=>{n("/settings")},y=p?W5[p]:null;if(!o){if(!e)return a.jsx("div",{className:"main-content-mobile",children:a.jsxs("div",{className:"main-content-mobile-inner",children:[a.jsx(Rr,{title:"Settings",onOpenSidebar:r,onToggleSidebar:l,isWideScreen:o,isSidebarCollapsed:u}),a.jsx("main",{className:"page-scroll-container",children:a.jsx("div",{className:"page-content-inner",children:a.jsx("div",{className:"settings-category-list",children:f.map(C=>a.jsx(Lv,{category:C,isActive:!1,onClick:()=>x(C.id)},C.id))})})})]})});const w=f.find(C=>C.id===e);return a.jsx("div",{className:"main-content-mobile",children:a.jsxs("div",{className:"main-content-mobile-inner",children:[a.jsx(Rr,{title:(w==null?void 0:w.label)||"Settings",onOpenSidebar:r,showBack:!0,onBack:v}),a.jsx("main",{className:"page-scroll-container",children:a.jsx("div",{className:"page-content-inner",children:y&&a.jsx(y,{})})})]})})}return a.jsx("div",{className:"main-content-wrapper",children:a.jsxs("div",{className:"main-content-constrained",children:[a.jsx(Rr,{title:"Settings",onOpenSidebar:r,onToggleSidebar:l,isWideScreen:o,isSidebarCollapsed:u}),a.jsx("main",{className:"page-scroll-container",children:a.jsxs("div",{className:"settings-two-column",children:[a.jsx("nav",{className:"settings-category-nav",children:a.jsx("div",{className:"settings-category-list",children:f.map(w=>a.jsx(Lv,{category:w,isActive:p===w.id,onClick:()=>x(w.id)},w.id))})}),a.jsx("div",{className:"settings-content-panel",children:y&&a.jsx(y,{})})]})})]})})}const X5=h.Fragment;Z6();CT();const K5="/".replace(/\/$/,"")||void 0,ty=document.getElementById("root");if(!ty)throw new Error("Root element not found");gS.createRoot(ty).render(a.jsx(X5,{children:a.jsx(ST,{children:a.jsx(Pj,{basename:K5,children:a.jsx(yT,{children:a.jsxs(gj,{children:[a.jsx(gs,{path:"/",element:a.jsx(dx,{to:"/projects",replace:!0})}),a.jsx(gs,{path:"/login",element:a.jsx(D3,{})}),a.jsxs(gs,{element:a.jsx(XT,{}),children:[a.jsx(gs,{path:"/projects",element:a.jsx(Y3,{})}),a.jsx(gs,{path:"/sessions",element:a.jsx(M3,{})}),a.jsx(gs,{path:"/agents",element:a.jsx(p3,{})}),a.jsx(gs,{path:"/inbox",element:a.jsx(U3,{})}),a.jsx(gs,{path:"/settings",element:a.jsx(Uv,{})}),a.jsx(gs,{path:"/settings/:category",element:a.jsx(Uv,{})}),a.jsx(gs,{path:"/projects/:projectId",element:a.jsx(dx,{to:"/sessions",replace:!0})}),a.jsx(gs,{path:"/new-session",element:a.jsx(Z3,{})}),a.jsx(gs,{path:"/projects/:projectId/sessions/:sessionId",element:a.jsx(WA,{})})]}),a.jsx(gs,{path:"/projects/:projectId/file",element:a.jsx(k3,{})}),a.jsx(gs,{path:"/activity",element:a.jsx(s3,{})})]})})})})}));
|
package/client-dist/index.html
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
document.documentElement.setAttribute('data-theme', theme);
|
|
28
28
|
})();
|
|
29
29
|
</script>
|
|
30
|
-
<script type="module" crossorigin src="/assets/index-
|
|
30
|
+
<script type="module" crossorigin src="/assets/index-F0q8DglR.js"></script>
|
|
31
31
|
<link rel="stylesheet" crossorigin href="/assets/index-pzXtuJDt.css">
|
|
32
32
|
</head>
|
|
33
33
|
<body>
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as os from "node:os";
|
|
4
4
|
import * as path from "node:path";
|
|
@@ -494,12 +494,36 @@ async function startServer() {
|
|
|
494
494
|
console.log(`Permission mode: ${config.defaultPermissionMode}`);
|
|
495
495
|
if (config.openBrowser) {
|
|
496
496
|
const platform = os.platform();
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
497
|
+
let cmd;
|
|
498
|
+
let args;
|
|
499
|
+
if (platform === "darwin") {
|
|
500
|
+
cmd = "open";
|
|
501
|
+
args = [serverUrl];
|
|
502
|
+
}
|
|
503
|
+
else if (platform === "win32") {
|
|
504
|
+
cmd = "cmd";
|
|
505
|
+
args = ["/c", "start", "", serverUrl];
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
// Detect WSL: use cmd.exe to open in Windows browser
|
|
509
|
+
let isWsl = false;
|
|
510
|
+
try {
|
|
511
|
+
isWsl = fs
|
|
512
|
+
.readFileSync("/proc/version", "utf-8")
|
|
513
|
+
.toLowerCase()
|
|
514
|
+
.includes("microsoft");
|
|
515
|
+
}
|
|
516
|
+
catch { }
|
|
517
|
+
if (isWsl) {
|
|
518
|
+
cmd = "cmd.exe";
|
|
519
|
+
args = ["/c", "start", "", serverUrl];
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
cmd = "xdg-open";
|
|
523
|
+
args = [serverUrl];
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
execFile(cmd, args, (err) => {
|
|
503
527
|
if (err) {
|
|
504
528
|
console.warn(`Could not open browser: ${err.message}`);
|
|
505
529
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACL,cAAc,EACd,UAAU,EACV,gBAAg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