remote-codex 0.11.33 → 0.11.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/supervisor-api/dist/index.js +24 -1
- package/apps/supervisor-web/dist/assets/index-BTG-ELMo.css +1 -0
- package/apps/supervisor-web/dist/assets/{index-DIi8wTEY.js → index-PHqiYl42.js} +6 -6
- package/apps/supervisor-web/dist/assets/{thread-ui-B9eC2H4u.js → thread-ui-DoKAPILv.js} +1 -1
- package/apps/supervisor-web/dist/index.html +3 -3
- package/package.json +1 -1
- package/packages/claude/src/runtimeAdapter.test.ts +7 -0
- package/packages/claude/src/runtimeAdapter.ts +29 -1
- package/apps/supervisor-web/dist/assets/index-CdjTdnJt.css +0 -1
|
@@ -3650,7 +3650,7 @@ url = ${JSON.stringify(r.trim())}
|
|
|
3650
3650
|
`).concat(`
|
|
3651
3651
|
`)}const u=a.trimEnd();return u?`${u}
|
|
3652
3652
|
|
|
3653
|
-
${o}`:o}function sl(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function Nn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function Iu(e,r){if(!e)return"Select model";if((r==null?void 0:r.availability)!=="available"||typeof r.tokensInContextWindow!="number"||typeof r.modelContextWindow!="number")return`${e} · context unavailable`;const n=Math.max(r.tokensInContextWindow,0),a=Math.max(r.modelContextWindow,0),o=Math.max(a-n,0);return[e,`${Nn(n)} used / ${Nn(a)}`,`${Nn(o)} left`,`${sl(r.remainingPercent)}% context left`].join(" · ")}function zu(e,r){const n=e.name.trim();if(n)return n;const a=r==="photo"?e.type.includes("png")?".png":e.type.includes("heic")?".heic":e.type.includes("heif")?".heif":e.type.includes("webp")?".webp":".jpg":"";return`${r==="photo"?"photo":"file"}-${Date.now()}${a}`}function Pu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function On(e){return e.type.startsWith("image/")?"photo":"file"}function Wn(e,r){const n=[];if(e)for(const a of Array.from(e)){if(a.kind!=="file")continue;const o=a.getAsFile();o&&n.push(o)}return n.length>0?n:r?Array.from(r):[]}function ss(e,r){return Wn(e,r).length>0}function Ru(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function os(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:Ru(e.originalName)}var Yr=[{value:"preToolUse",label:"PreToolUse",matcherHint:"Bash"},{value:"permissionRequest",label:"PermissionRequest",matcherHint:"Bash"},{value:"postToolUse",label:"PostToolUse",matcherHint:"Bash"},{value:"sessionStart",label:"SessionStart",matcherHint:"startup|resume"},{value:"userPromptSubmit",label:"UserPromptSubmit",matcherHint:""},{value:"stop",label:"Stop",matcherHint:""},{value:"preCompact",label:"PreCompact",matcherHint:""},{value:"postCompact",label:"PostCompact",matcherHint:""}];function Mu({goalComposeMode:e,goalBusy:r,threadConnected:n,busy:a,isShellView:o,disabledPlaceholder:s,settingsBusy:l,supportedEffortCount:i,fastMode:d}){const h=e?"Describe the goal the backend should continue working toward...":s??(o?"Send shell input to the attached terminal...":"Ask the backend to inspect, modify, or explain code..."),u=e?r?"Setting...":"Set goal":!n&&a?"Connecting...":n&&a&&!o?"Sending...":"Send",m=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",f=l;return{promptPlaceholder:h,interruptLabel:o?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:u,sendButtonClassName:m,modelControlsDisabled:f,effortControlsDisabled:f||i===0,effortControlTitle:d?"Fast mode is on. Turn it off from the slash toolbox to edit reasoning.":i===0?"The selected model does not expose adjustable reasoning effort.":"Select reasoning effort"}}function Au({isShellView:e,edgeToEdgeMobile:r,isMobileShell:n,openMenu:a,isDragTargetActive:o,busy:s}){const l=e?"thread-composer-layer thread-shell-composer-layer":"thread-graph-composer-layer",i=e?"thread-composer-form":"thread-graph-composer-form",d=e?"thread-composer-form-floating":"thread-graph-composer-form-floating",h=e?"thread-composer-input":"thread-graph-composer-input";return{composerLayerClassName:a?`${l} relative z-[80] shrink-0`:`${l} relative z-20 shrink-0`,formClassName:e?r||n?`${i} ${d} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} ${r?d:""} relative z-20 shrink-0 border-t px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`,composerShellClassName:e?"thread-composer-shell":"thread-graph-composer-shell",composerToolbarClassName:e?"thread-composer-toolbar":"thread-graph-composer-toolbar",composerInputClassName:h,composerIconButtonClassName:e?"thread-composer-icon-button":"thread-graph-composer-icon-button",composerMenuClassName:e?"thread-composer-menu":"thread-graph-composer-menu",composerMenuItemClassName:e?"thread-composer-menu-item":"thread-graph-composer-menu-item",composerInlineToggleClassName:e?"thread-composer-inline-toggle":"thread-graph-composer-inline-toggle",composerPanelButtonClassName:e?"thread-composer-panel-button":"thread-graph-composer-panel-button",composerChipButtonClassName:e?"thread-composer-chip-button":"thread-graph-composer-chip-button",composerPlanToggleActiveClassName:e?"thread-composer-plan-toggle-active":"thread-graph-composer-plan-toggle-active",composerSendButtonClassName:e?"thread-composer-send-button":"thread-graph-composer-send-button",composerPromptRegionClassName:e?"thread-composer-prompt-region":"thread-graph-composer-prompt-region",promptInputClassName:`${h} min-h-[5.25rem] w-full px-4 pr-14 pt-3 outline-none transition sm:min-h-[5.75rem] ${o?"is-drag-target border-sky-300/80 bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`,graphChatInputGroupClassName:`thread-graph-composer-input-group relative border-0 bg-transparent shadow-none ring-0 ${s?"bg-amber-50/40 dark:bg-amber-400/10":"bg-transparent"}`,graphChatInputClassName:`${h} min-h-[68px] max-h-32 w-full overflow-y-auto px-3 pt-3 text-[16px] leading-relaxed text-slate-800 outline-none transition sm:min-h-[92px] sm:max-h-40 sm:px-4 sm:pt-4 sm:text-[14px] dark:text-slate-100 ${o?"is-drag-target bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`}}function $u(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"m4 5 2 2-2 2"}),t.jsx("path",{d:"M7.75 9.5h4.25"})]})}function _u(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",children:t.jsx("path",{d:"M8 3.25v9.5M3.25 8h9.5"})})}function Du(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.75 2.5 5.25 13.5"}),t.jsx("path",{d:"M4.25 5.25h2.25"}),t.jsx("path",{d:"M9.5 10.75h2.25"})]})}function Bu(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3 4.5A1.75 1.75 0 0 1 4.75 2.75h6.5A1.75 1.75 0 0 1 13 4.5v4A1.75 1.75 0 0 1 11.25 10.25H8l-2.75 2v-2H4.75A1.75 1.75 0 0 1 3 8.5v-4Z"})})}function Gu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-3.5 w-3.5 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function Un(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function Fu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function Hu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Ou(e){var r;return((r=Yr.find(n=>n.value===e))==null?void 0:r.label)??e}function Wu(e){var r;switch(e){case"cloudRequirements":return"Cloud";case"legacyManagedConfigFile":case"legacyManagedConfigMdm":return"Managed";case"sessionFlags":return"Session";default:return((r=e[0])==null?void 0:r.toUpperCase())+e.slice(1)}}function Uu(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function Vu(e){switch(e){case"preToolUse":return"PreToolUse";case"permissionRequest":return"PermissionRequest";case"postToolUse":return"PostToolUse";case"preCompact":return"PreCompact";case"postCompact":return"PostCompact";case"sessionStart":return"SessionStart";case"userPromptSubmit":return"UserPromptSubmit";case"stop":return"Stop"}}function Ku(e){return e.source==="user"?"global":e.source==="project"?"project":null}function ol(e){const r=Ku(e);return!r||e.handlerType!=="command"||!e.command||e.isManaged?null:{scope:r,eventName:e.eventName,matcher:e.matcher,command:e.command,timeoutSec:e.timeoutSec,statusMessage:e.statusMessage}}function qu(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function Xu({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=sl(e==null?void 0:e.remainingPercent);if(r!=="available")return null;const a=n<=20?"rgba(251,113,133,0.90)":n<=40?"rgba(252,211,77,0.85)":"rgba(125,211,252,0.80)";return t.jsx("span",{"aria-hidden":"true",className:"thread-context-progress-track pointer-events-none mt-0.5 block",children:t.jsx("span",{className:"thread-context-progress-fill block",style:{width:`${n}%`,backgroundColor:a}})})}function Bt({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-50":"border-stone-700/90 bg-stone-900/80 text-stone-100";return t.jsx("span",{className:`inline-flex min-w-[3rem] items-center justify-center rounded-full border px-2 py-1.5 text-[10px] font-medium tracking-[0.12em] ${n}`,children:e})}function Yu(e,r){return(e??[]).filter(n=>{switch(n.action){case"fast":return r.fast;case"compact":return r.compact;case"goal":return r.goal;case"fork":return r.fork;case"skills":return r.skills;case"mcp":return r.mcp;case"hooks":return r.hooks;case"prompt":case"unsupported":return!0;default:return!1}})}function Zu(e,{fastMode:r,goalComposeMode:n}){switch(e.action){case"fast":return{type:"toggleFast",fastMode:!r};case"compact":return{type:"runCompact"};case"goal":return n?{type:"exitGoalCompose"}:{type:"enterGoalCompose"};case"fork":case"skills":case"mcp":case"hooks":return{type:"openPanel",panel:e.action};case"prompt":return{type:"insertPrompt",text:`${e.command} `};default:return{type:"noop"}}}function Ju(e,{fastMode:r,compactBusy:n,goalComposeMode:a,goalStatus:o,busy:s}){switch(e.action){case"fast":return r?"On":"Off";case"compact":return n?"Busy":"Run";case"goal":return a?"Composing":o?qu(o):"Open";case"fork":return s?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";case"prompt":return"Compose";case"unsupported":return"Unavailable";default:return""}}function Qu(e,{settingsBusy:r,compactBusy:n,busy:a,forkBusy:o}){switch(e.action){case"fast":return r;case"compact":return n||a;case"fork":return a||o;case"unsupported":return!0;default:return!1}}function em(e,{fastMode:r,goalComposeMode:n,goalStatus:a,menuItemClassName:o}){return`${e.action==="fast"&&r||e.action==="goal"&&(n||a==="active")?"ui-status-warning":o} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`}function tm(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function rm(e){return!!e.querySelector("[style], font")}function Ft(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function ll(e){let r="";for(const n of Array.from(e.childNodes))r+=Ft(n);return r.replace(/\u00a0/g," ")}function ls(e,r,n){var i;let a=null,o=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let u=0;u<Math.min(n,d.length);u+=1){const m=d[u];m&&(h+=Ft(m).length)}return h}if(r.nodeType===Node.TEXT_NODE)a=r;else{const d=Array.from(e.childNodes).find(h=>h.contains(r));if(!d)return ll(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Ft(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?o=u:o=Math.round(Math.min(1,m/f)*u)}catch{o=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),o=h.toString().length}catch{o=Ft(d).length}}}const s=Array.from(e.childNodes);let l=0;for(const d of s){if(d===a)return d.nodeType===Node.TEXT_NODE?l+o:l+Math.min(o,Ft(d).length);l+=Ft(d).length}return l}function nm(e){const r=window.getSelection();if(!r||r.rangeCount===0)return null;const n=r.getRangeAt(0);return!e.contains(n.startContainer)||!e.contains(n.endContainer)?null:{start:ls(e,n.startContainer,n.startOffset),end:ls(e,n.endContainer,n.endOffset)}}function is(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[o,s]of a.entries()){const i=Ft(s).length;if(s.nodeType===Node.TEXT_NODE){if(n<=i)return{node:s,offset:n};n-=i;continue}if(s instanceof HTMLElement&&s.dataset.segmentType==="attachment"){if(n===0)return{node:e,offset:o};if(n<=i){const d=a[o+1];return n===i&&(d==null?void 0:d.nodeType)===Node.TEXT_NODE?{node:d,offset:0}:{node:e,offset:o+1}}n-=i;continue}if(n<=i)return{node:e,offset:o+1};n-=i}return{node:e,offset:e.childNodes.length}}function am(e,r){const n=is(e,r.start),a=is(e,r.end),o=document.createRange();o.setStart(n.node,n.offset),o.setEnd(a.node,a.offset);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(o)}function sm(e,r){if(r.length===0)return!1;const n=r.at(-1);if(!n)return!1;const a=Array.from(e.childNodes).find(i=>i instanceof HTMLElement&&i.dataset.segmentType==="attachment"&&i.dataset.clientId===n);if(!(a instanceof HTMLElement))return!1;const o=document.createRange(),s=a.nextSibling;(s==null?void 0:s.nodeType)===Node.TEXT_NODE?o.setStart(s,0):o.setStartAfter(a),o.collapse(!0);const l=window.getSelection();return l==null||l.removeAllRanges(),l==null||l.addRange(o),!0}nn();Pt();function om({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:rt("group/input-group relative flex w-full min-w-0 items-center rounded-md border shadow-xs outline-none transition-[color,box-shadow]","h-9 has-[>textarea]:h-auto","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col",e),...r})}var lm=Cr("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*=size-])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem]","block-start":"order-first w-full justify-start px-3 pt-3","block-end":"order-last w-full justify-start px-3 pb-3"}},defaultVariants:{align:"inline-start"}});function im({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:rt(lm({align:r}),e),onClick:a=>{var s;if(a.target.closest("button"))return;const o=(s=a.currentTarget.parentElement)==null?void 0:s.querySelector('[data-slot="input-group-control"] [contenteditable="true"], [data-slot="input-group-control"] textarea, [data-slot="input-group-control"] input, [data-slot="input-group-control"]');o==null||o.focus()},...n})}var dm=Cr("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*=size-])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function jt({className:e,type:r="button",variant:n="ghost",size:a="xs",...o}){return t.jsx(Nr,{type:r,"data-size":a,variant:n,className:rt(dm({size:a}),e),...o})}function cm({className:e,...r}){return t.jsx("span",{className:rt("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function hm({photoInputRef:e,fileInputRef:r,onAppendAttachments:n}){function a(o,s){n(o.target.files,s),o.target.value=""}return t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:e,type:"file",accept:"image/*",multiple:!0,tabIndex:-1,className:"sr-only",onChange:o=>a(o,"photo")}),t.jsx("input",{ref:r,type:"file",multiple:!0,tabIndex:-1,className:"sr-only",onChange:o=>a(o,"file")})]})}function um(e){if(!e)return"reset time unavailable";const r=new Date(e);return Number.isNaN(r.getTime())?"reset time unavailable":`resets ${r.toLocaleString()}`}function mm({usage:e}){if(!e||e.authKind!=="subscription"||e.windows.length===0)return null;const r=e.windows.slice(0,2),n=r.map(a=>{const o=Math.max(0,100-a.usedPercent);return`${a.label}: ${o}% remaining, ${um(a.resetsAt)}`}).join(". ");return t.jsx("button",{type:"button",className:"thread-subscription-usage ml-1 inline-flex h-5 items-center gap-2 rounded-[0.7rem] border border-stone-500/60 bg-stone-950/20 px-2 text-[9px] text-stone-200/90 shadow-sm backdrop-blur transition hover:border-sky-300/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-sky-200/70","aria-label":`${e.provider} subscription usage. ${n}`,title:`${n}${e.stale?". Last known values.":""}`,children:r.map(a=>{const o=Math.max(0,Math.min(100,100-a.usedPercent)),s=o<=10?"bg-rose-400":o<=25?"bg-amber-300":"bg-sky-300";return t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{className:"font-semibold",children:a.label}),t.jsx("span",{className:"h-1 w-7 overflow-hidden rounded-full bg-stone-600/70",children:t.jsx("span",{className:`block h-full rounded-full ${s}`,style:{width:`${o}%`}})}),t.jsxs("span",{className:"tabular-nums",children:[Math.round(o),"%"]})]},a.id)})})}function pm({activeView:e,followTail:r,onToggleFollow:n,canJumpToPreviousTurn:a,onJumpToPreviousTurn:o,canJumpToNextTurn:s,onJumpToNextTurn:l,subscriptionUsage:i}){return e!=="chat"?null:t.jsxs("div",{className:"absolute left-1/2 top-0 z-[90] inline-flex h-11 min-w-[9rem] -translate-x-1/2 -translate-y-full items-end justify-center bg-transparent pb-1 touch-manipulation sm:h-10",children:[t.jsxs("span",{className:`thread-jump-latest-badge inline-flex h-5 min-w-[7.5rem] overflow-hidden rounded-[0.7rem] border shadow-sm transition ${r?"is-active border-sky-300/36 bg-sky-300/[0.03] text-sky-100/86":"border-stone-500/70 bg-stone-950/[0.08] text-stone-200/86"}`,children:[t.jsx("button",{type:"button","aria-label":"Jump to previous turn",title:a?"Jump to the start of the previous turn":"No earlier turn",disabled:!a,onClick:()=>o==null?void 0:o(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 12h9M8 10V5M6 7l2-2 2 2"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest messages are in view":"Jump to the bottom",onClick:()=>n==null?void 0:n(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m4 5.5 4 4 4-4M3.5 12.5h9"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to next turn",title:s?"Jump to the start of the next turn":"No later turn",disabled:!s,onClick:()=>l==null?void 0:l(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 4h9M8 6v5m-2-2 2 2 2-2"})})})]}),t.jsx(mm,{usage:i})]})}function fm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:o,error:s,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b,onSubmit:v,formRef:x,promptSlot:j,toolbarSlot:w,goalSlot:y,shellPromptSlot:k}){return t.jsxs("div",{className:r,children:[t.jsx(hm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(pm,{activeView:e,followTail:l,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b}),t.jsxs("form",{ref:x,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:v,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(om,{className:o,children:[j,w]}),y,k]}),s?t.jsx("div",{className:"mt-2 rounded-2xl border border-rose-500/40 bg-rose-500/10 px-4 py-3 text-sm text-rose-200",children:s}):null]})]})}function gm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:o,onPickPhoto:s,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Add attachment",title:"Add attachment",onClick:o,className:`${r} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(_u,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${n} absolute bottom-full left-0 mb-2 w-32 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20`,children:t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",onClick:s,className:`${a} block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"Photo"}),t.jsx("button",{type:"button",onClick:l,className:`${a} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"File"})]})})]})}var il=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function ds(e){var r;return((r=il.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function xm({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:o,reasoningEffort:s,supportedEfforts:l,displayedCollaborationMode:i,sandboxMode:d,planModeAvailable:h,sandboxModeAvailable:u,settingsBusy:m,goalComposeMode:f,goalBusy:p,activeView:g,disabled:b,fastMode:v,sendButtonLabel:x,sendButtonClassName:j,modelControlsDisabled:w,effortControlsDisabled:y,effortControlTitle:k,inlineToggleClassName:S,menuItemClassName:N,planToggleActiveClassName:L,sendButtonBaseClassName:R,onSetOpenMenu:P,onUpdateSettings:J}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:w||n.length===0,onClick:()=>P(D=>D==="model"?null:"model"),title:v?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${S} relative min-w-0 max-w-[8.75rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[11rem]`,children:t.jsx("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap [direction:rtl]",children:r??"Select model"})}),r?t.jsx(Xu,{contextUsage:o}):null,e==="model"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[14rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:n.map(D=>t.jsx("button",{type:"button",onClick:()=>J({model:D.model,reasoningEffort:D.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.model===r?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.model})},D.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:y,onClick:()=>P(D=>D==="effort"?null:"effort"),title:k,className:`${S} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${y?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:ns(s)}),e==="effort"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[8rem] max-w-[12rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:l.map(D=>t.jsx("button",{type:"button",onClick:()=>J({reasoningEffort:D.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.reasoningEffort===s?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:ns(D.reasoningEffort)})},D.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${ds(d)}`,disabled:m,onClick:()=>P(D=>D==="sandbox"?null:"sandbox"),title:`Sandbox: ${ds(d)}`,className:`${S} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:il.map(D=>t.jsx("button",{type:"button",onClick:()=>J({sandboxMode:D.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.mode===d?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.label})},D.mode))})})]}),h&&t.jsx(jt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>J({collaborationMode:i==="plan"?"default":"plan"}),className:`${S} rounded-full px-2.5 ${i==="plan"?`${L} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(jt,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?b:!1),className:`${R} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${j}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function bm({busy:e,shellControlState:r,onPaste:n,onCopy:a,onClear:o,onShellControl:s}){const l=!!(r!=null&&r.shellInputEnabled),i=!!(r!=null&&r.isCommandRunning);return t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute right-0 top-full z-40 mt-2 w-[11.5rem] max-w-[calc(100vw-1.5rem)] rounded-[1rem] border border-stone-700/90 bg-stone-950/96 p-2 shadow-2xl shadow-stone-950/40 sm:w-48",onMouseDown:d=>{d.stopPropagation()},onPointerDown:d=>{d.stopPropagation()},onTouchStart:d=>{d.stopPropagation()},children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2 py-2 text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Un,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center justify-center rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-2 text-stone-100",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Un,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:e,onClick:o,className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!l||!i,onClick:()=>s("ctrl_c"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-C",tone:"rose"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("ctrl_d"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"DOWN"})})]})})}function vm({busy:e,forkBusy:r,composerMenuItemClassName:n,onForkLatest:a,onSelectForkTurnPanel:o}){return t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",disabled:e||r,onClick:()=>void a(),className:`${n} block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from latest"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:r?"Forking":"Run"})]})}),t.jsx("button",{type:"button",disabled:e||r,onClick:s=>{s.stopPropagation(),o()},className:`${n} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from selected turn"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:"Pick"})]})}),e?t.jsx("p",{className:"mt-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Fork is only available while the thread is idle."}):null]})}function km({forkTurnOptionsState:e,forkBusy:r,composerPanelButtonClassName:n,onForkTurn:a}){var o,s;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading turns..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(o=e.data)!=null&&o.length?t.jsx("div",{className:"space-y-2",children:e.data.map(l=>t.jsx("button",{type:"button",disabled:r,onClick:()=>void a(l.turnId),className:`${n} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{className:"text-sm text-stone-100",children:["Turn ",l.turnIndex]}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:r?"Forking":l.status})]})},l.turnId))}):null,e.status!=="loading"&&!e.error&&(((s=e.data)==null?void 0:s.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No turns available to fork yet."}):null]})}function wm({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:o,hookConfigError:s,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:m,hookTimeoutSec:f,hookStatusMessage:p,composerChipButtonClassName:g,onResetHookForm:b,onSetHooksPanelMode:v,onClearHookConfigStatus:x,onSetEditingHookTarget:j,onSetHookScope:w,onSetHookEventName:y,onSetHookMatcher:k,onSetHookCommand:S,onSetHookTimeoutSec:N,onSetHookStatusMessage:L,onSaveHook:R,onStartEditingHook:P,onTrustHook:J,onUntrustHook:D}){var Y,Z,I,re,oe;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"Hook config sources"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:((Y=r.data)==null?void 0:Y.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),b(),v("add"),x()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add Hook"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading hooks..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:s}):null,l?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:l}):null,e==="add"||e==="edit"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[e==="edit"?t.jsxs("p",{className:"rounded-lg border border-stone-800 bg-stone-950 px-3 py-2 text-[11px] text-stone-400",children:["Editing"," ",Vu((i==null?void 0:i.eventName)??h)," ","in ",(i==null?void 0:i.scope)==="global"?"global":"project"," ","hooks.json"]}):null,t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Scope",t.jsxs("select",{"aria-label":"Hook scope",value:d,onChange:$=>w($.target.value),disabled:e==="edit",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:[t.jsx("option",{value:"project",children:"Project"}),t.jsx("option",{value:"global",children:"Global"})]})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Event",t.jsx("select",{"aria-label":"Hook event",value:h,onChange:$=>y($.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:Yr.map($=>t.jsx("option",{value:$.value,children:$.label},$.value))})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Matcher"}),t.jsx("input",{"aria-label":"Hook matcher",value:u,onChange:$=>k($.target.value),placeholder:"Bash",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Command"}),t.jsx("textarea",{"aria-label":"Hook command",value:m,onChange:$=>S($.target.value),rows:3,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 font-mono text-xs text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Timeout",t.jsx("input",{"aria-label":"Hook timeout seconds",value:f,onChange:$=>N($.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:p,onChange:$=>L($.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>{v("list"),j(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void R(),disabled:o,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:o?"Saving...":e==="edit"?"Update Hook":"Write Hook"})]})]}):null,e==="list"&&((Z=r.data)!=null&&Z.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map($=>t.jsx("p",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:$},$))}):null,e==="list"&&((I=r.data)!=null&&I.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map($=>t.jsxs("div",{className:"rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-2 text-xs text-rose-100/90",children:[t.jsx("p",{className:"font-medium",children:$.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:$.path})]},`${$.path}:${$.message}`))}):null,e==="list"&&((re=r.data)!=null&&re.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map($=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"truncate text-sm font-medium text-stone-100",children:[Ou($.eventName),$.matcher?` · ${$.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:$.command??$.handlerType}),$.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:$.statusMessage}):null]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.08em] text-stone-500",children:[ol($)?t.jsx("button",{type:"button",onClick:Q=>{Q.stopPropagation(),P($)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/10`,children:"Edit"}):null,a&&$.trustStatus==="trusted"&&!$.isManaged?t.jsx("button",{type:"button",disabled:o,onClick:Q=>{Q.stopPropagation(),D($)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-amber-100 transition hover:border-amber-300/35 hover:bg-amber-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Untrust"}):null,($.trustStatus==="untrusted"||$.trustStatus==="modified")&&!$.isManaged&&a?t.jsx("button",{type:"button",disabled:o||!$.currentHash,onClick:Q=>{Q.stopPropagation(),J($)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-emerald-100 transition hover:border-emerald-300/35 hover:bg-emerald-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Trust"}):null,t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-0.5 text-stone-300",children:Uu($.trustStatus)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em] text-stone-500",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:Wu($.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:$.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[$.timeoutSec,"s"]})]})]},$.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((oe=r.data)==null?void 0:oe.hooks.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No hooks configured for this workspace."}):null]})}function Ur(e){return e.localGoalId??`${e.createdAt}:${e.objective}`}function ym(e,r){const n=e?[e,...r]:r,a=new Set;return n.filter(o=>{const s=Ur(o);return a.has(s)?!1:(a.add(s),!0)})}function jm(e){if(e<60)return`${e}s`;const r=Math.floor(e/60);return r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`}function Nm(e){switch(e){case"budgetLimited":return"Budget limited";case"complete":return"Complete";case"terminated":return"Terminated";case"paused":return"Paused";default:return"Active"}}function Cm({goalState:e,goalHistory:r,busy:n,onBack:a,onUpdateGoal:o}){const s=ym(e.data,r),l=e.data?Ur(e.data):null;return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 py-2",children:[t.jsx("button",{type:"button",onClick:a,className:"min-h-9 rounded-lg px-2 text-xs font-medium text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--theme-accent-border)]",children:"Back"}),t.jsx("span",{className:"text-xs font-semibold text-[var(--theme-fg)]",children:"Goals"})]}),e.error?t.jsx("p",{className:"m-3 rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-xs text-[var(--status-danger-fg)]",children:e.error}):null,e.status==="loading"&&s.length===0?t.jsxs("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading goals",children:[t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"}),t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"})]}):s.length===0?t.jsx("p",{className:"px-4 py-5 text-center text-sm text-[var(--theme-fg-muted)]",children:"No goals in this thread yet."}):t.jsx("div",{className:"max-h-72 divide-y divide-[var(--theme-border)] overflow-y-auto",children:s.map(i=>{const d=Ur(i)===l&&["active","paused","budgetLimited"].includes(i.status);return t.jsxs("div",{className:"px-3 py-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-sm font-medium leading-5 text-[var(--theme-fg)]",children:i.objective}),t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] font-medium text-[var(--theme-fg-muted)]",children:Nm(i.status)})]}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[var(--theme-fg-muted)]",children:[jm(i.timeUsedSeconds)," · ",i.tokensUsed.toLocaleString()," tokens"]}),d&&o?t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsx("button",{type:"button",disabled:n||i.status==="active",onClick:()=>void o({status:"active"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Continue"}),t.jsx("button",{type:"button",disabled:n||i.status==="paused",onClick:()=>void o({status:"paused"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Pause"}),t.jsx("button",{type:"button",disabled:n,onClick:()=>void o({status:"terminated"}),className:"min-h-9 rounded-lg px-3 text-xs font-medium text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)] disabled:cursor-not-allowed disabled:opacity-45",children:"Terminate"})]}):null]},Ur(i))})})]})}function Sm({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:o,mcpConfigSuccess:s,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:m,onSetMcpPanelMode:f,onClearMcpConfigStatus:p,onSetMcpHttpName:g,onSetMcpHttpUrl:b,onSetMcpRawBlock:v,onPrepareRawMcpBlock:x,onSaveHttpMcp:j,onSaveRawMcpBlock:w}){var y,k;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:s}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:S=>g(S.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:S=>b(S.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void j(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:S=>v(S.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void w(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((y=r.data)!=null&&y.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(S=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:S.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[S.tools.length," tools · ",S.resourceCount," ","resources · ",S.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:Fu(S.authStatus)})]}),S.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:S.tools.slice(0,4).map(N=>N.title??N.name).join(" · ")}):null]},S.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((k=r.data)==null?void 0:k.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function Tm({skillsState:e,copiedSkillName:r,composerChipButtonClassName:n,onCopySkillInvokeName:a}){var o,s,l,i;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading skills..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(o=e.data)!=null&&o.skills.length?t.jsx("div",{className:"space-y-2",children:e.data.skills.map(d=>{var h,u;return t.jsx("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:((h=d.interface)==null?void 0:h.displayName)??d.name}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em]",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1 text-stone-400",children:Hu(d.scope)}),t.jsxs("button",{type:"button",className:`inline-flex items-center gap-1 rounded-full border px-2 py-1 normal-case tracking-normal transition ${r===d.name?"border-emerald-400/45 bg-emerald-400/12 text-emerald-100":`${n} border-stone-700 text-stone-300 hover:border-stone-500`}`,onClick:()=>void a(d.name),title:`Copy $${d.name}`,"aria-label":`Copy $${d.name}`,children:[t.jsx(Un,{}),"$",d.name]})]}),t.jsx("p",{className:"text-xs leading-5 text-stone-400",children:((u=d.interface)==null?void 0:u.shortDescription)??d.shortDescription??d.description})]})},d.path)})}):null,(s=e.data)!=null&&s.errors.length?t.jsx("div",{className:"mt-2 space-y-2",children:e.data.errors.map(d=>t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:[t.jsx("p",{className:"font-medium",children:d.message}),t.jsx("p",{className:"mt-1 break-all text-amber-100/60",children:d.path})]},`${d.path}:${d.message}`))}):null,e.status!=="loading"&&!e.error&&(((l=e.data)==null?void 0:l.skills.length)??0)===0&&(((i=e.data)==null?void 0:i.errors.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No skills available right now."}):null]})}function Em({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:o,forkTurnOptionsState:s,skillsState:l,goalState:i,goalHistory:d,goalBusy:h,copiedSkillName:u,hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:v,hookConfigSuccess:x,editingHookTarget:j,hookScope:w,hookEventName:y,hookMatcher:k,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,mcpPanelMode:R,mcpState:P,mcpConfigEditing:J,mcpConfigPath:D,mcpConfigError:Y,mcpConfigSuccess:Z,mcpConfigBusy:I,mcpHttpName:re,mcpHttpUrl:oe,mcpRawBlock:$,iconButtonClassName:Q,menuClassName:_,menuItemClassName:ee,panelButtonClassName:W,chipButtonClassName:T,onToggle:K,onToolboxItemClick:G,toolboxItemDisabled:E,toolboxItemClassName:C,toolboxItemStatus:U,onSetSlashPanelView:H,onViewGoals:se,onUpdateGoal:q,onOpenForkTurns:de,onForkLatest:te,onForkTurn:be,onCopySkillInvokeName:ie,onResetHookForm:ye,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:Ce,onSetHookScope:Le,onSetHookEventName:X,onSetHookMatcher:ue,onSetHookCommand:ve,onSetHookTimeoutSec:ke,onSetHookStatusMessage:_e,onSaveHook:He,onStartEditingHook:$e,onTrustHook:Ie,onUntrustHook:F,onSetMcpPanelMode:le,onClearMcpConfigStatus:we,onSetMcpHttpName:z,onSetMcpHttpUrl:O,onSetMcpRawBlock:ne,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Te,onSaveRawMcpBlock:Ee}){return t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:K,className:`${Q} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Du,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${_} absolute bottom-full left-0 z-40 mb-2 w-72 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20 backdrop-blur-xl`,onClick:fe=>{fe.stopPropagation()},onMouseDown:fe=>{fe.stopPropagation()},onPointerDown:fe=>{fe.stopPropagation()},onTouchStart:fe=>{fe.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((fe,De)=>fe.action==="goal"?t.jsxs("div",{className:`mt-1 flex min-h-11 overflow-hidden rounded-xl border border-[var(--theme-border)] ${De===0?"mt-0":""}`,title:fe.description??fe.label,children:[t.jsx("button",{type:"button",disabled:E(fe),onClick:()=>{H("goals"),se==null||se()},className:"min-w-0 flex-1 px-3 py-2.5 text-left text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"View goals",children:t.jsx("span",{children:fe.command})}),t.jsx("button",{type:"button",disabled:E(fe),onClick:Be=>G(fe,Be),className:"min-w-14 border-l border-[var(--theme-border)] px-3 text-xs font-semibold text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"Open goal composer",children:"Open"})]},`${fe.action}:${fe.command}`):t.jsx("button",{type:"button",disabled:E(fe),onClick:Be=>G(fe,Be),className:`${C(fe)} ${De===0?"mt-0":""}`,title:fe.description??fe.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:fe.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:U(fe)})]})},`${fe.action}:${fe.command}`)),n.length===0?t.jsx("p",{className:"px-3 py-2 text-sm text-stone-400",children:"No backend tools are available for this thread."}):null]}):t.jsx("div",{className:"max-h-80 overflow-auto",children:r==="goals"?t.jsx(Cm,{goalState:i,goalHistory:d,busy:h,onBack:()=>H("root"),onUpdateGoal:q}):r==="fork"?t.jsx(vm,{busy:a,forkBusy:o,composerMenuItemClassName:ee,onForkLatest:te,onSelectForkTurnPanel:()=>(H("forkTurns"),de())}):r==="forkTurns"?t.jsx(km,{forkTurnOptionsState:s,forkBusy:o,composerPanelButtonClassName:W,onForkTurn:be}):r==="skills"?t.jsx(Tm,{skillsState:l,copiedSkillName:u,composerChipButtonClassName:T,onCopySkillInvokeName:ie}):r==="hooks"?t.jsx(wm,{hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:v,hookConfigSuccess:x,editingHookTarget:j,hookScope:w,hookEventName:y,hookMatcher:k,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,composerChipButtonClassName:T,onResetHookForm:ye,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:Ce,onSetHookScope:Le,onSetHookEventName:X,onSetHookMatcher:ue,onSetHookCommand:ve,onSetHookTimeoutSec:ke,onSetHookStatusMessage:_e,onSaveHook:He,onStartEditingHook:$e,onTrustHook:Ie,onUntrustHook:F}):t.jsx(Sm,{mcpPanelMode:R,mcpState:P,mcpConfigEditing:J,mcpConfigPath:D,mcpConfigError:Y,mcpConfigSuccess:Z,mcpConfigBusy:I,mcpHttpName:re,mcpHttpUrl:oe,mcpRawBlock:$,composerPanelButtonClassName:W,composerChipButtonClassName:T,onSetMcpPanelMode:le,onClearMcpConfigStatus:we,onSetMcpHttpName:z,onSetMcpHttpUrl:O,onSetMcpRawBlock:ne,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Te,onSaveRawMcpBlock:Ee})})})]})}function Lm({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:u,onToggleView:m,onDismissPromptFocus:f,onSetOpenMenu:p}){return t.jsxs(im,{align:"block-end",className:`${s} relative z-30 mb-0 flex items-center gap-2 text-xs`,children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!e&&i?t.jsx(Em,{...i}):null,!e&&d?t.jsx(gm,{...d}):null,r&&t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":e?"Switch to chat":"Switch to shell",title:e?"Switch to chat":"Switch to shell",onClick:()=>m==null?void 0:m(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(Bu,{}):t.jsx($u,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(xm,{...h}):null,e&&a?t.jsx(cm,{className:"min-w-0 max-w-[12rem] truncate rounded-full px-1.5 py-1 text-stone-400",title:a,children:a}):null,n&&t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button","data-composer-menu-trigger":"true","aria-label":o==="shellTools"?"Close shell tools":"Open shell tools","aria-haspopup":"menu","aria-expanded":o==="shellTools",title:o==="shellTools"?"Close shell tools":"Open shell tools",onClick:()=>{f(),p(g=>g==="shellTools"?null:"shellTools")},className:"inline-flex h-7 w-7 items-center justify-center rounded-full border border-stone-700 bg-stone-900/92 text-stone-200 transition hover:bg-stone-800",children:t.jsx(Gu,{})}),o==="shellTools"&&u?t.jsx(bm,{...u}):null]})]})]})}function Im(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function zm(e){return[...e.filter(r=>On(r)==="photo"),...e.filter(r=>On(r)==="file")]}function Pm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:o,pendingSelectionRef:s,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=Im}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=vu({prompt:e,attachments:r,files:f,selection:a()??o.current,kindForFile:p,buildClientId:d});return n(()=>g.draft),s.current=g.selection,o.current=g.selection,l.current=g.insertedAttachmentIds,i==null||i(),!0},[r,d,a,i,l,s,e,o,n]),u=c.useCallback((f,p)=>!f||f.length===0?!1:h(Array.from(f),()=>p),[h]),m=c.useCallback(f=>h(zm(f),On),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function cs(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function Rm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,o]=c.useState({});return c.useEffect(()=>{const s=n.current;if(r){cs(s),o({});return}const l={},i=new Set;for(const d of e){if(d.kind!=="photo")continue;i.add(d.clientId);let h=s.get(d.clientId);h||(h=URL.createObjectURL(d.file),s.set(d.clientId,h)),l[d.clientId]=h}for(const[d,h]of s.entries())i.has(d)||(URL.revokeObjectURL(h),s.delete(d));o(l)},[e,r]),c.useEffect(()=>{const s=n.current;return()=>{cs(s)}},[]),a}var Mm=180;function Cn(e,r){return{prompt:e??"",attachments:r??[]}}function Am({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[o,s]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>Cn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(Mr(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?Mr(Cn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const w=Cn(r,n),y=Mr(w);y!==p.current&&(p.current=y,u.current=y,h.current=w,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(w))},[n,r,m]);const g=c.useCallback(w=>{if(!m||!a)return;const y=Mr(w);y!==u.current&&(u.current=y,a(()=>({prompt:w.prompt,attachments:w.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const b=c.useCallback((w,y)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),y==="immediate"){g(w);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},Mm)}},[m,g]),v=c.useCallback((w=h.current)=>{b(w,"immediate")},[b]),x=c.useCallback((w,y="immediate")=>{if(m){const k=w(h.current);h.current=k,i(k),b(k,y);return}s(k=>w(k))},[m,b]),j=m?l:o;return{prompt:j.prompt,attachments:j.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:v}}function $m({slashPanelView:e,onForkLatest:r,onForkTurn:n,closeMenu:a}){const[o,s]=c.useState(!1);c.useEffect(()=>{e!=="forkTurns"&&s(!1)},[e]);const l=c.useCallback(async()=>{if(r){s(!0);try{await r(),a()}finally{s(!1)}}},[a,r]),i=c.useCallback(async d=>{if(n){s(!0);try{await n(d),a()}finally{s(!1)}}},[a,n]);return{forkBusy:o,forkLatest:l,forkTurn:i}}function _m({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:o,onUpdateGoal:s,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,u]=c.useState(!1),[m,f]=c.useState(""),[p,g]=c.useState(!1),[b,v]=c.useState(null),x=c.useCallback(async()=>{const y=e.trim();if(!y)return v("Goal objective cannot be empty."),!1;const k=m.trim(),S=Cu(k);if(k.length>0&&(S===null||!Number.isInteger(S)||S<=0))return v("Token budget must be a positive number in thousands."),!1;if(!s)return v("/goal is unavailable in this view."),!1;g(!0),v(null);try{return o&&await o({objective:y,tokenBudget:S})===!1?!1:(await s({objective:y,status:"active",tokenBudget:S}),f(""),u(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(N){return v(N instanceof Error?N.message:"Unable to set goal."),!1}finally{g(!1)}},[m,o,s,e,l]),j=c.useCallback(()=>{i(),d(),u(!0),f(Su(r==null?void 0:r.tokenBudget)),v(null),a==null||a(),requestAnimationFrame(()=>{var y;(y=n.current)==null||y.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),w=c.useCallback(()=>{u(!1),v(null)},[]);return{goalComposeMode:h,goalTokenBudget:m,goalBusy:p,goalLocalError:b,setGoalTokenBudget:f,submitGoal:x,enterGoalComposeMode:j,exitGoalComposeMode:w}}var Sn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function Dm(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function Bm({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:o,onUntrustHook:s}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,m]=c.useState("preToolUse"),[f,p]=c.useState("Bash"),[g,b]=c.useState(Sn),[v,x]=c.useState("30"),[j,w]=c.useState("Running hook"),[y,k]=c.useState(null),[S,N]=c.useState(!1),[L,R]=c.useState(null),[P,J]=c.useState(null),D=c.useMemo(()=>Dm(r),[r]),Y=c.useCallback(ee=>D.get(ee)??D.get("preToolUse")??Sn,[D]),Z=c.useMemo(()=>new Set([Sn,...D.values()]),[D]),I=c.useCallback(()=>{R(null),J(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),I())},[I,e]),c.useEffect(()=>{const ee=Yr.find(W=>W.value===u);p(W=>{const T=W.trim(),K=new Set(Yr.map(G=>G.matcherHint).filter(Boolean));return T&&!K.has(T)?W:(ee==null?void 0:ee.matcherHint)??""}),b(W=>Z.has(W.trim())?Y(u):W)},[Y,Z,u]);const re=c.useCallback(()=>{k(null),h("project"),m("preToolUse"),p("Bash"),b(Y("preToolUse")),x("30"),w("Running hook")},[Y]),oe=c.useCallback(ee=>{const W=ol(ee);if(!W){R("Only command hooks in global or project hooks.json can be edited here.");return}k(W),h(W.scope),m(W.eventName),p(W.matcher??""),b(W.command),x(W.timeoutSec?String(W.timeoutSec):""),w(W.statusMessage??""),R(null),J(null),i("edit")},[]),$=c.useCallback(async()=>{if(l==="edit"&&!a){R("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){R("Hook editing is unavailable in this view.");return}if(l==="edit"&&!y){R("Select a hook to edit first.");return}const ee=g.trim();if(!ee){R("Hook command cannot be empty.");return}const W=v.trim(),T=W?Number(W):null;if(W&&(T===null||!Number.isInteger(T)||T<=0)){R("Timeout must be a positive number of seconds.");return}N(!0),R(null),J(null);try{const K={scope:d,eventName:u,matcher:f.trim()||null,command:ee,timeoutSec:T,statusMessage:j.trim()||null};l==="edit"?await(a==null?void 0:a({...K,target:y})):await(n==null?void 0:n(K)),J(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),k(null)}catch(K){R(K instanceof Error?K.message:"Unable to write hooks.json.")}finally{N(!1)}},[y,g,u,f,d,j,v,l,n,a]),Q=c.useCallback(async ee=>{if(!o||!ee.currentHash){R("Hook trust is unavailable in this view.");return}N(!0),R(null),J(null);try{await o({key:ee.key,currentHash:ee.currentHash}),J("Hook trusted.")}catch(W){R(W instanceof Error?W.message:"Unable to trust hook.")}finally{N(!1)}},[o]),_=c.useCallback(async ee=>{if(!s){R("Hook trust is unavailable in this view.");return}N(!0),R(null),J(null);try{await s({key:ee.key}),J("Hook untrusted.")}catch(W){R(W instanceof Error?W.message:"Unable to untrust hook.")}finally{N(!1)}},[s]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:v,hookStatusMessage:j,editingHookTarget:y,hookConfigBusy:S,hookConfigError:L,hookConfigSuccess:P,setHooksPanelMode:i,setEditingHookTarget:k,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:b,setHookTimeoutSec:x,setHookStatusMessage:w,clearHookConfigStatus:I,resetHookForm:re,startEditingHook:oe,saveHook:$,trustHook:Q,untrustHook:_}}var Gm=`[mcp_servers.example_stdio]
|
|
3653
|
+
${o}`:o}function sl(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function Nn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function Iu(e,r){if(!e)return"Select model";if((r==null?void 0:r.availability)!=="available"||typeof r.tokensInContextWindow!="number"||typeof r.modelContextWindow!="number")return`${e} · context unavailable`;const n=Math.max(r.tokensInContextWindow,0),a=Math.max(r.modelContextWindow,0),o=Math.max(a-n,0);return[e,`${Nn(n)} used / ${Nn(a)}`,`${Nn(o)} left`,`${sl(r.remainingPercent)}% context left`].join(" · ")}function zu(e,r){const n=e.name.trim();if(n)return n;const a=r==="photo"?e.type.includes("png")?".png":e.type.includes("heic")?".heic":e.type.includes("heif")?".heif":e.type.includes("webp")?".webp":".jpg":"";return`${r==="photo"?"photo":"file"}-${Date.now()}${a}`}function Pu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function On(e){return e.type.startsWith("image/")?"photo":"file"}function Wn(e,r){const n=[];if(e)for(const a of Array.from(e)){if(a.kind!=="file")continue;const o=a.getAsFile();o&&n.push(o)}return n.length>0?n:r?Array.from(r):[]}function ss(e,r){return Wn(e,r).length>0}function Ru(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function os(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:Ru(e.originalName)}var Yr=[{value:"preToolUse",label:"PreToolUse",matcherHint:"Bash"},{value:"permissionRequest",label:"PermissionRequest",matcherHint:"Bash"},{value:"postToolUse",label:"PostToolUse",matcherHint:"Bash"},{value:"sessionStart",label:"SessionStart",matcherHint:"startup|resume"},{value:"userPromptSubmit",label:"UserPromptSubmit",matcherHint:""},{value:"stop",label:"Stop",matcherHint:""},{value:"preCompact",label:"PreCompact",matcherHint:""},{value:"postCompact",label:"PostCompact",matcherHint:""}];function Mu({goalComposeMode:e,goalBusy:r,threadConnected:n,busy:a,isShellView:o,disabledPlaceholder:s,settingsBusy:l,supportedEffortCount:i,fastMode:d}){const h=e?"Describe the goal the backend should continue working toward...":s??(o?"Send shell input to the attached terminal...":"Ask the backend to inspect, modify, or explain code..."),u=e?r?"Setting...":"Set goal":!n&&a?"Connecting...":n&&a&&!o?"Sending...":"Send",m=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",f=l;return{promptPlaceholder:h,interruptLabel:o?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:u,sendButtonClassName:m,modelControlsDisabled:f,effortControlsDisabled:f||i===0,effortControlTitle:d?"Fast mode is on. Turn it off from the slash toolbox to edit reasoning.":i===0?"The selected model does not expose adjustable reasoning effort.":"Select reasoning effort"}}function Au({isShellView:e,edgeToEdgeMobile:r,isMobileShell:n,openMenu:a,isDragTargetActive:o,busy:s}){const l=e?"thread-composer-layer thread-shell-composer-layer":"thread-graph-composer-layer",i=e?"thread-composer-form":"thread-graph-composer-form",d=e?"thread-composer-form-floating":"thread-graph-composer-form-floating",h=e?"thread-composer-input":"thread-graph-composer-input";return{composerLayerClassName:a?`${l} relative z-[80] shrink-0`:`${l} relative z-20 shrink-0`,formClassName:e?r||n?`${i} ${d} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} ${r?d:""} relative z-20 shrink-0 border-t px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`,composerShellClassName:e?"thread-composer-shell":"thread-graph-composer-shell",composerToolbarClassName:e?"thread-composer-toolbar":"thread-graph-composer-toolbar",composerInputClassName:h,composerIconButtonClassName:e?"thread-composer-icon-button":"thread-graph-composer-icon-button",composerMenuClassName:e?"thread-composer-menu":"thread-graph-composer-menu",composerMenuItemClassName:e?"thread-composer-menu-item":"thread-graph-composer-menu-item",composerInlineToggleClassName:e?"thread-composer-inline-toggle":"thread-graph-composer-inline-toggle",composerPanelButtonClassName:e?"thread-composer-panel-button":"thread-graph-composer-panel-button",composerChipButtonClassName:e?"thread-composer-chip-button":"thread-graph-composer-chip-button",composerPlanToggleActiveClassName:e?"thread-composer-plan-toggle-active":"thread-graph-composer-plan-toggle-active",composerSendButtonClassName:e?"thread-composer-send-button":"thread-graph-composer-send-button",composerPromptRegionClassName:e?"thread-composer-prompt-region":"thread-graph-composer-prompt-region",promptInputClassName:`${h} min-h-[5.25rem] w-full px-4 pr-14 pt-3 outline-none transition sm:min-h-[5.75rem] ${o?"is-drag-target border-sky-300/80 bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`,graphChatInputGroupClassName:`thread-graph-composer-input-group relative border-0 bg-transparent shadow-none ring-0 ${s?"bg-amber-50/40 dark:bg-amber-400/10":"bg-transparent"}`,graphChatInputClassName:`${h} min-h-[68px] max-h-32 w-full overflow-y-auto px-3 pt-3 text-[16px] leading-relaxed text-slate-800 outline-none transition sm:min-h-[92px] sm:max-h-40 sm:px-4 sm:pt-4 sm:text-[14px] dark:text-slate-100 ${o?"is-drag-target bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`}}function $u(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"m4 5 2 2-2 2"}),t.jsx("path",{d:"M7.75 9.5h4.25"})]})}function _u(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",children:t.jsx("path",{d:"M8 3.25v9.5M3.25 8h9.5"})})}function Du(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.75 2.5 5.25 13.5"}),t.jsx("path",{d:"M4.25 5.25h2.25"}),t.jsx("path",{d:"M9.5 10.75h2.25"})]})}function Bu(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3 4.5A1.75 1.75 0 0 1 4.75 2.75h6.5A1.75 1.75 0 0 1 13 4.5v4A1.75 1.75 0 0 1 11.25 10.25H8l-2.75 2v-2H4.75A1.75 1.75 0 0 1 3 8.5v-4Z"})})}function Gu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-3.5 w-3.5 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function Un(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function Fu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function Hu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Ou(e){var r;return((r=Yr.find(n=>n.value===e))==null?void 0:r.label)??e}function Wu(e){var r;switch(e){case"cloudRequirements":return"Cloud";case"legacyManagedConfigFile":case"legacyManagedConfigMdm":return"Managed";case"sessionFlags":return"Session";default:return((r=e[0])==null?void 0:r.toUpperCase())+e.slice(1)}}function Uu(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function Vu(e){switch(e){case"preToolUse":return"PreToolUse";case"permissionRequest":return"PermissionRequest";case"postToolUse":return"PostToolUse";case"preCompact":return"PreCompact";case"postCompact":return"PostCompact";case"sessionStart":return"SessionStart";case"userPromptSubmit":return"UserPromptSubmit";case"stop":return"Stop"}}function Ku(e){return e.source==="user"?"global":e.source==="project"?"project":null}function ol(e){const r=Ku(e);return!r||e.handlerType!=="command"||!e.command||e.isManaged?null:{scope:r,eventName:e.eventName,matcher:e.matcher,command:e.command,timeoutSec:e.timeoutSec,statusMessage:e.statusMessage}}function qu(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function Xu({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=sl(e==null?void 0:e.remainingPercent);if(r!=="available")return null;const a=n<=20?"rgba(251,113,133,0.90)":n<=40?"rgba(252,211,77,0.85)":"rgba(125,211,252,0.80)";return t.jsx("span",{"aria-hidden":"true",className:"thread-context-progress-track pointer-events-none mt-0.5 block",children:t.jsx("span",{className:"thread-context-progress-fill block",style:{width:`${n}%`,backgroundColor:a}})})}function Bt({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-50":"border-stone-700/90 bg-stone-900/80 text-stone-100";return t.jsx("span",{className:`inline-flex min-w-[3rem] items-center justify-center rounded-full border px-2 py-1.5 text-[10px] font-medium tracking-[0.12em] ${n}`,children:e})}function Yu(e,r){return(e??[]).filter(n=>{switch(n.action){case"fast":return r.fast;case"compact":return r.compact;case"goal":return r.goal;case"fork":return r.fork;case"skills":return r.skills;case"mcp":return r.mcp;case"hooks":return r.hooks;case"prompt":case"unsupported":return!0;default:return!1}})}function Zu(e,{fastMode:r,goalComposeMode:n}){switch(e.action){case"fast":return{type:"toggleFast",fastMode:!r};case"compact":return{type:"runCompact"};case"goal":return n?{type:"exitGoalCompose"}:{type:"enterGoalCompose"};case"fork":case"skills":case"mcp":case"hooks":return{type:"openPanel",panel:e.action};case"prompt":return{type:"insertPrompt",text:`${e.command} `};default:return{type:"noop"}}}function Ju(e,{fastMode:r,compactBusy:n,goalComposeMode:a,goalStatus:o,busy:s}){switch(e.action){case"fast":return r?"On":"Off";case"compact":return n?"Busy":"Run";case"goal":return a?"Composing":o?qu(o):"Open";case"fork":return s?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";case"prompt":return"Compose";case"unsupported":return"Unavailable";default:return""}}function Qu(e,{settingsBusy:r,compactBusy:n,busy:a,forkBusy:o}){switch(e.action){case"fast":return r;case"compact":return n||a;case"fork":return a||o;case"unsupported":return!0;default:return!1}}function em(e,{fastMode:r,goalComposeMode:n,goalStatus:a,menuItemClassName:o}){return`${e.action==="fast"&&r||e.action==="goal"&&(n||a==="active")?"ui-status-warning":o} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`}function tm(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function rm(e){return!!e.querySelector("[style], font")}function Ft(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function ll(e){let r="";for(const n of Array.from(e.childNodes))r+=Ft(n);return r.replace(/\u00a0/g," ")}function ls(e,r,n){var i;let a=null,o=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let u=0;u<Math.min(n,d.length);u+=1){const m=d[u];m&&(h+=Ft(m).length)}return h}if(r.nodeType===Node.TEXT_NODE)a=r;else{const d=Array.from(e.childNodes).find(h=>h.contains(r));if(!d)return ll(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Ft(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?o=u:o=Math.round(Math.min(1,m/f)*u)}catch{o=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),o=h.toString().length}catch{o=Ft(d).length}}}const s=Array.from(e.childNodes);let l=0;for(const d of s){if(d===a)return d.nodeType===Node.TEXT_NODE?l+o:l+Math.min(o,Ft(d).length);l+=Ft(d).length}return l}function nm(e){const r=window.getSelection();if(!r||r.rangeCount===0)return null;const n=r.getRangeAt(0);return!e.contains(n.startContainer)||!e.contains(n.endContainer)?null:{start:ls(e,n.startContainer,n.startOffset),end:ls(e,n.endContainer,n.endOffset)}}function is(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[o,s]of a.entries()){const i=Ft(s).length;if(s.nodeType===Node.TEXT_NODE){if(n<=i)return{node:s,offset:n};n-=i;continue}if(s instanceof HTMLElement&&s.dataset.segmentType==="attachment"){if(n===0)return{node:e,offset:o};if(n<=i){const d=a[o+1];return n===i&&(d==null?void 0:d.nodeType)===Node.TEXT_NODE?{node:d,offset:0}:{node:e,offset:o+1}}n-=i;continue}if(n<=i)return{node:e,offset:o+1};n-=i}return{node:e,offset:e.childNodes.length}}function am(e,r){const n=is(e,r.start),a=is(e,r.end),o=document.createRange();o.setStart(n.node,n.offset),o.setEnd(a.node,a.offset);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(o)}function sm(e,r){if(r.length===0)return!1;const n=r.at(-1);if(!n)return!1;const a=Array.from(e.childNodes).find(i=>i instanceof HTMLElement&&i.dataset.segmentType==="attachment"&&i.dataset.clientId===n);if(!(a instanceof HTMLElement))return!1;const o=document.createRange(),s=a.nextSibling;(s==null?void 0:s.nodeType)===Node.TEXT_NODE?o.setStart(s,0):o.setStartAfter(a),o.collapse(!0);const l=window.getSelection();return l==null||l.removeAllRanges(),l==null||l.addRange(o),!0}nn();Pt();function om({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:rt("group/input-group relative flex w-full min-w-0 items-center rounded-md border shadow-xs outline-none transition-[color,box-shadow]","h-9 has-[>textarea]:h-auto","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col",e),...r})}var lm=Cr("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*=size-])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem]","block-start":"order-first w-full justify-start px-3 pt-3","block-end":"order-last w-full justify-start px-3 pb-3"}},defaultVariants:{align:"inline-start"}});function im({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:rt(lm({align:r}),e),onClick:a=>{var s;if(a.target.closest("button"))return;const o=(s=a.currentTarget.parentElement)==null?void 0:s.querySelector('[data-slot="input-group-control"] [contenteditable="true"], [data-slot="input-group-control"] textarea, [data-slot="input-group-control"] input, [data-slot="input-group-control"]');o==null||o.focus()},...n})}var dm=Cr("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*=size-])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function jt({className:e,type:r="button",variant:n="ghost",size:a="xs",...o}){return t.jsx(Nr,{type:r,"data-size":a,variant:n,className:rt(dm({size:a}),e),...o})}function cm({className:e,...r}){return t.jsx("span",{className:rt("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function hm({photoInputRef:e,fileInputRef:r,onAppendAttachments:n}){function a(o,s){n(o.target.files,s),o.target.value=""}return t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:e,type:"file",accept:"image/*",multiple:!0,tabIndex:-1,className:"sr-only",onChange:o=>a(o,"photo")}),t.jsx("input",{ref:r,type:"file",multiple:!0,tabIndex:-1,className:"sr-only",onChange:o=>a(o,"file")})]})}function um(e){if(!e)return"reset time unavailable";const r=new Date(e);return Number.isNaN(r.getTime())?"reset time unavailable":`resets ${r.toLocaleString()}`}function mm({usage:e}){if(!e||e.authKind!=="subscription"||e.windows.length===0)return null;const r=e.windows.slice(0,2),n=r.map(a=>{const o=Math.max(0,100-a.usedPercent);return`${a.label}: ${o}% remaining, ${um(a.resetsAt)}`}).join(". ");return t.jsx("button",{type:"button",className:"thread-subscription-usage pointer-events-auto absolute bottom-1 right-2 inline-flex h-4 items-center gap-1 rounded-[0.55rem] border border-stone-500/45 bg-stone-950/15 px-1 text-[8px] leading-none text-stone-200/80 opacity-70 shadow-sm transition hover:border-sky-300/45 hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-sky-200/70 sm:right-3","aria-label":`${e.provider} subscription usage. ${n}`,title:`${n}${e.stale?". Last known values.":""}`,children:r.map(a=>{const o=Math.max(0,Math.min(100,100-a.usedPercent)),s=o<=10?"bg-rose-400":o<=25?"bg-amber-300":"bg-sky-300";return t.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[t.jsx("span",{className:"font-semibold",children:a.label}),t.jsx("span",{className:"h-0.5 w-3.5 overflow-hidden rounded-full bg-stone-600/60",children:t.jsx("span",{className:`block h-full rounded-full ${s}`,style:{width:`${o}%`}})}),t.jsxs("span",{className:"tabular-nums",children:[Math.round(o),"%"]})]},a.id)})})}function pm({activeView:e,followTail:r,onToggleFollow:n,canJumpToPreviousTurn:a,onJumpToPreviousTurn:o,canJumpToNextTurn:s,onJumpToNextTurn:l,subscriptionUsage:i}){return e!=="chat"?null:t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-11 -translate-y-full bg-transparent touch-manipulation sm:h-10",children:[t.jsxs("span",{role:"group","aria-label":"Timeline navigation",className:`thread-jump-latest-badge pointer-events-auto absolute bottom-1 left-1/2 inline-flex h-5 min-w-[7.5rem] -translate-x-1/2 overflow-hidden rounded-[0.7rem] border shadow-sm transition ${r?"is-active border-sky-300/36 bg-sky-300/[0.03] text-sky-100/86":"border-stone-500/70 bg-stone-950/[0.08] text-stone-200/86"}`,children:[t.jsx("button",{type:"button","aria-label":"Jump to previous turn",title:a?"Jump to the start of the previous turn":"No earlier turn",disabled:!a,onClick:()=>o==null?void 0:o(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 12h9M8 10V5M6 7l2-2 2 2"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest messages are in view":"Jump to the bottom",onClick:()=>n==null?void 0:n(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m4 5.5 4 4 4-4M3.5 12.5h9"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to next turn",title:s?"Jump to the start of the next turn":"No later turn",disabled:!s,onClick:()=>l==null?void 0:l(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 4h9M8 6v5m-2-2 2 2 2-2"})})})]}),t.jsx(mm,{usage:i})]})}function fm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:o,error:s,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b,onSubmit:v,formRef:x,promptSlot:j,toolbarSlot:w,goalSlot:y,shellPromptSlot:k}){return t.jsxs("div",{className:r,children:[t.jsx(hm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(pm,{activeView:e,followTail:l,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b}),t.jsxs("form",{ref:x,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:v,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(om,{className:o,children:[j,w]}),y,k]}),s?t.jsx("div",{className:"mt-2 rounded-2xl border border-rose-500/40 bg-rose-500/10 px-4 py-3 text-sm text-rose-200",children:s}):null]})]})}function gm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:o,onPickPhoto:s,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Add attachment",title:"Add attachment",onClick:o,className:`${r} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(_u,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${n} absolute bottom-full left-0 mb-2 w-32 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20`,children:t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",onClick:s,className:`${a} block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"Photo"}),t.jsx("button",{type:"button",onClick:l,className:`${a} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"File"})]})})]})}var il=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function ds(e){var r;return((r=il.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function xm({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:o,reasoningEffort:s,supportedEfforts:l,displayedCollaborationMode:i,sandboxMode:d,planModeAvailable:h,sandboxModeAvailable:u,settingsBusy:m,goalComposeMode:f,goalBusy:p,activeView:g,disabled:b,fastMode:v,sendButtonLabel:x,sendButtonClassName:j,modelControlsDisabled:w,effortControlsDisabled:y,effortControlTitle:k,inlineToggleClassName:S,menuItemClassName:N,planToggleActiveClassName:L,sendButtonBaseClassName:R,onSetOpenMenu:P,onUpdateSettings:J}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:w||n.length===0,onClick:()=>P(D=>D==="model"?null:"model"),title:v?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${S} relative min-w-0 max-w-[8.75rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[11rem]`,children:t.jsx("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap [direction:rtl]",children:r??"Select model"})}),r?t.jsx(Xu,{contextUsage:o}):null,e==="model"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[14rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:n.map(D=>t.jsx("button",{type:"button",onClick:()=>J({model:D.model,reasoningEffort:D.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.model===r?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.model})},D.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:y,onClick:()=>P(D=>D==="effort"?null:"effort"),title:k,className:`${S} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${y?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:ns(s)}),e==="effort"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[8rem] max-w-[12rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:l.map(D=>t.jsx("button",{type:"button",onClick:()=>J({reasoningEffort:D.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.reasoningEffort===s?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:ns(D.reasoningEffort)})},D.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${ds(d)}`,disabled:m,onClick:()=>P(D=>D==="sandbox"?null:"sandbox"),title:`Sandbox: ${ds(d)}`,className:`${S} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:il.map(D=>t.jsx("button",{type:"button",onClick:()=>J({sandboxMode:D.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.mode===d?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.label})},D.mode))})})]}),h&&t.jsx(jt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>J({collaborationMode:i==="plan"?"default":"plan"}),className:`${S} rounded-full px-2.5 ${i==="plan"?`${L} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(jt,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?b:!1),className:`${R} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${j}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function bm({busy:e,shellControlState:r,onPaste:n,onCopy:a,onClear:o,onShellControl:s}){const l=!!(r!=null&&r.shellInputEnabled),i=!!(r!=null&&r.isCommandRunning);return t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute right-0 top-full z-40 mt-2 w-[11.5rem] max-w-[calc(100vw-1.5rem)] rounded-[1rem] border border-stone-700/90 bg-stone-950/96 p-2 shadow-2xl shadow-stone-950/40 sm:w-48",onMouseDown:d=>{d.stopPropagation()},onPointerDown:d=>{d.stopPropagation()},onTouchStart:d=>{d.stopPropagation()},children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2 py-2 text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Un,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center justify-center rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-2 text-stone-100",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Un,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:e,onClick:o,className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!l||!i,onClick:()=>s("ctrl_c"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-C",tone:"rose"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("ctrl_d"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"DOWN"})})]})})}function vm({busy:e,forkBusy:r,composerMenuItemClassName:n,onForkLatest:a,onSelectForkTurnPanel:o}){return t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",disabled:e||r,onClick:()=>void a(),className:`${n} block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from latest"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:r?"Forking":"Run"})]})}),t.jsx("button",{type:"button",disabled:e||r,onClick:s=>{s.stopPropagation(),o()},className:`${n} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from selected turn"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:"Pick"})]})}),e?t.jsx("p",{className:"mt-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Fork is only available while the thread is idle."}):null]})}function km({forkTurnOptionsState:e,forkBusy:r,composerPanelButtonClassName:n,onForkTurn:a}){var o,s;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading turns..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(o=e.data)!=null&&o.length?t.jsx("div",{className:"space-y-2",children:e.data.map(l=>t.jsx("button",{type:"button",disabled:r,onClick:()=>void a(l.turnId),className:`${n} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{className:"text-sm text-stone-100",children:["Turn ",l.turnIndex]}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:r?"Forking":l.status})]})},l.turnId))}):null,e.status!=="loading"&&!e.error&&(((s=e.data)==null?void 0:s.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No turns available to fork yet."}):null]})}function wm({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:o,hookConfigError:s,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:m,hookTimeoutSec:f,hookStatusMessage:p,composerChipButtonClassName:g,onResetHookForm:b,onSetHooksPanelMode:v,onClearHookConfigStatus:x,onSetEditingHookTarget:j,onSetHookScope:w,onSetHookEventName:y,onSetHookMatcher:k,onSetHookCommand:S,onSetHookTimeoutSec:N,onSetHookStatusMessage:L,onSaveHook:R,onStartEditingHook:P,onTrustHook:J,onUntrustHook:D}){var Y,Z,I,re,oe;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"Hook config sources"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:((Y=r.data)==null?void 0:Y.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),b(),v("add"),x()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add Hook"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading hooks..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:s}):null,l?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:l}):null,e==="add"||e==="edit"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[e==="edit"?t.jsxs("p",{className:"rounded-lg border border-stone-800 bg-stone-950 px-3 py-2 text-[11px] text-stone-400",children:["Editing"," ",Vu((i==null?void 0:i.eventName)??h)," ","in ",(i==null?void 0:i.scope)==="global"?"global":"project"," ","hooks.json"]}):null,t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Scope",t.jsxs("select",{"aria-label":"Hook scope",value:d,onChange:$=>w($.target.value),disabled:e==="edit",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:[t.jsx("option",{value:"project",children:"Project"}),t.jsx("option",{value:"global",children:"Global"})]})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Event",t.jsx("select",{"aria-label":"Hook event",value:h,onChange:$=>y($.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:Yr.map($=>t.jsx("option",{value:$.value,children:$.label},$.value))})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Matcher"}),t.jsx("input",{"aria-label":"Hook matcher",value:u,onChange:$=>k($.target.value),placeholder:"Bash",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Command"}),t.jsx("textarea",{"aria-label":"Hook command",value:m,onChange:$=>S($.target.value),rows:3,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 font-mono text-xs text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Timeout",t.jsx("input",{"aria-label":"Hook timeout seconds",value:f,onChange:$=>N($.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:p,onChange:$=>L($.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>{v("list"),j(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void R(),disabled:o,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:o?"Saving...":e==="edit"?"Update Hook":"Write Hook"})]})]}):null,e==="list"&&((Z=r.data)!=null&&Z.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map($=>t.jsx("p",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:$},$))}):null,e==="list"&&((I=r.data)!=null&&I.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map($=>t.jsxs("div",{className:"rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-2 text-xs text-rose-100/90",children:[t.jsx("p",{className:"font-medium",children:$.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:$.path})]},`${$.path}:${$.message}`))}):null,e==="list"&&((re=r.data)!=null&&re.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map($=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"truncate text-sm font-medium text-stone-100",children:[Ou($.eventName),$.matcher?` · ${$.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:$.command??$.handlerType}),$.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:$.statusMessage}):null]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.08em] text-stone-500",children:[ol($)?t.jsx("button",{type:"button",onClick:Q=>{Q.stopPropagation(),P($)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/10`,children:"Edit"}):null,a&&$.trustStatus==="trusted"&&!$.isManaged?t.jsx("button",{type:"button",disabled:o,onClick:Q=>{Q.stopPropagation(),D($)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-amber-100 transition hover:border-amber-300/35 hover:bg-amber-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Untrust"}):null,($.trustStatus==="untrusted"||$.trustStatus==="modified")&&!$.isManaged&&a?t.jsx("button",{type:"button",disabled:o||!$.currentHash,onClick:Q=>{Q.stopPropagation(),J($)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-emerald-100 transition hover:border-emerald-300/35 hover:bg-emerald-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Trust"}):null,t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-0.5 text-stone-300",children:Uu($.trustStatus)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em] text-stone-500",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:Wu($.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:$.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[$.timeoutSec,"s"]})]})]},$.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((oe=r.data)==null?void 0:oe.hooks.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No hooks configured for this workspace."}):null]})}function Ur(e){return e.localGoalId??`${e.createdAt}:${e.objective}`}function ym(e,r){const n=e?[e,...r]:r,a=new Set;return n.filter(o=>{const s=Ur(o);return a.has(s)?!1:(a.add(s),!0)})}function jm(e){if(e<60)return`${e}s`;const r=Math.floor(e/60);return r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`}function Nm(e){switch(e){case"budgetLimited":return"Budget limited";case"complete":return"Complete";case"terminated":return"Terminated";case"paused":return"Paused";default:return"Active"}}function Cm({goalState:e,goalHistory:r,busy:n,onBack:a,onUpdateGoal:o}){const s=ym(e.data,r),l=e.data?Ur(e.data):null;return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 py-2",children:[t.jsx("button",{type:"button",onClick:a,className:"min-h-9 rounded-lg px-2 text-xs font-medium text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--theme-accent-border)]",children:"Back"}),t.jsx("span",{className:"text-xs font-semibold text-[var(--theme-fg)]",children:"Goals"})]}),e.error?t.jsx("p",{className:"m-3 rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-xs text-[var(--status-danger-fg)]",children:e.error}):null,e.status==="loading"&&s.length===0?t.jsxs("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading goals",children:[t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"}),t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"})]}):s.length===0?t.jsx("p",{className:"px-4 py-5 text-center text-sm text-[var(--theme-fg-muted)]",children:"No goals in this thread yet."}):t.jsx("div",{className:"max-h-72 divide-y divide-[var(--theme-border)] overflow-y-auto",children:s.map(i=>{const d=Ur(i)===l&&["active","paused","budgetLimited"].includes(i.status);return t.jsxs("div",{className:"px-3 py-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-sm font-medium leading-5 text-[var(--theme-fg)]",children:i.objective}),t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] font-medium text-[var(--theme-fg-muted)]",children:Nm(i.status)})]}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[var(--theme-fg-muted)]",children:[jm(i.timeUsedSeconds)," · ",i.tokensUsed.toLocaleString()," tokens"]}),d&&o?t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsx("button",{type:"button",disabled:n||i.status==="active",onClick:()=>void o({status:"active"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Continue"}),t.jsx("button",{type:"button",disabled:n||i.status==="paused",onClick:()=>void o({status:"paused"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Pause"}),t.jsx("button",{type:"button",disabled:n,onClick:()=>void o({status:"terminated"}),className:"min-h-9 rounded-lg px-3 text-xs font-medium text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)] disabled:cursor-not-allowed disabled:opacity-45",children:"Terminate"})]}):null]},Ur(i))})})]})}function Sm({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:o,mcpConfigSuccess:s,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:m,onSetMcpPanelMode:f,onClearMcpConfigStatus:p,onSetMcpHttpName:g,onSetMcpHttpUrl:b,onSetMcpRawBlock:v,onPrepareRawMcpBlock:x,onSaveHttpMcp:j,onSaveRawMcpBlock:w}){var y,k;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:s}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:S=>g(S.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:S=>b(S.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void j(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:S=>v(S.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void w(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((y=r.data)!=null&&y.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(S=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:S.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[S.tools.length," tools · ",S.resourceCount," ","resources · ",S.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:Fu(S.authStatus)})]}),S.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:S.tools.slice(0,4).map(N=>N.title??N.name).join(" · ")}):null]},S.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((k=r.data)==null?void 0:k.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function Tm({skillsState:e,copiedSkillName:r,composerChipButtonClassName:n,onCopySkillInvokeName:a}){var o,s,l,i;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading skills..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(o=e.data)!=null&&o.skills.length?t.jsx("div",{className:"space-y-2",children:e.data.skills.map(d=>{var h,u;return t.jsx("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:((h=d.interface)==null?void 0:h.displayName)??d.name}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em]",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1 text-stone-400",children:Hu(d.scope)}),t.jsxs("button",{type:"button",className:`inline-flex items-center gap-1 rounded-full border px-2 py-1 normal-case tracking-normal transition ${r===d.name?"border-emerald-400/45 bg-emerald-400/12 text-emerald-100":`${n} border-stone-700 text-stone-300 hover:border-stone-500`}`,onClick:()=>void a(d.name),title:`Copy $${d.name}`,"aria-label":`Copy $${d.name}`,children:[t.jsx(Un,{}),"$",d.name]})]}),t.jsx("p",{className:"text-xs leading-5 text-stone-400",children:((u=d.interface)==null?void 0:u.shortDescription)??d.shortDescription??d.description})]})},d.path)})}):null,(s=e.data)!=null&&s.errors.length?t.jsx("div",{className:"mt-2 space-y-2",children:e.data.errors.map(d=>t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:[t.jsx("p",{className:"font-medium",children:d.message}),t.jsx("p",{className:"mt-1 break-all text-amber-100/60",children:d.path})]},`${d.path}:${d.message}`))}):null,e.status!=="loading"&&!e.error&&(((l=e.data)==null?void 0:l.skills.length)??0)===0&&(((i=e.data)==null?void 0:i.errors.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No skills available right now."}):null]})}function Em({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:o,forkTurnOptionsState:s,skillsState:l,goalState:i,goalHistory:d,goalBusy:h,copiedSkillName:u,hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:v,hookConfigSuccess:x,editingHookTarget:j,hookScope:w,hookEventName:y,hookMatcher:k,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,mcpPanelMode:R,mcpState:P,mcpConfigEditing:J,mcpConfigPath:D,mcpConfigError:Y,mcpConfigSuccess:Z,mcpConfigBusy:I,mcpHttpName:re,mcpHttpUrl:oe,mcpRawBlock:$,iconButtonClassName:Q,menuClassName:_,menuItemClassName:ee,panelButtonClassName:W,chipButtonClassName:T,onToggle:K,onToolboxItemClick:G,toolboxItemDisabled:E,toolboxItemClassName:C,toolboxItemStatus:U,onSetSlashPanelView:H,onViewGoals:se,onUpdateGoal:q,onOpenForkTurns:de,onForkLatest:te,onForkTurn:be,onCopySkillInvokeName:ie,onResetHookForm:ye,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:Ce,onSetHookScope:Le,onSetHookEventName:X,onSetHookMatcher:ue,onSetHookCommand:ve,onSetHookTimeoutSec:ke,onSetHookStatusMessage:_e,onSaveHook:He,onStartEditingHook:$e,onTrustHook:Ie,onUntrustHook:F,onSetMcpPanelMode:le,onClearMcpConfigStatus:we,onSetMcpHttpName:z,onSetMcpHttpUrl:O,onSetMcpRawBlock:ne,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Te,onSaveRawMcpBlock:Ee}){return t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:K,className:`${Q} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Du,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${_} absolute bottom-full left-0 z-40 mb-2 w-72 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20 backdrop-blur-xl`,onClick:fe=>{fe.stopPropagation()},onMouseDown:fe=>{fe.stopPropagation()},onPointerDown:fe=>{fe.stopPropagation()},onTouchStart:fe=>{fe.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((fe,De)=>fe.action==="goal"?t.jsxs("div",{className:`mt-1 flex min-h-11 overflow-hidden rounded-xl border border-[var(--theme-border)] ${De===0?"mt-0":""}`,title:fe.description??fe.label,children:[t.jsx("button",{type:"button",disabled:E(fe),onClick:()=>{H("goals"),se==null||se()},className:"min-w-0 flex-1 px-3 py-2.5 text-left text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"View goals",children:t.jsx("span",{children:fe.command})}),t.jsx("button",{type:"button",disabled:E(fe),onClick:Be=>G(fe,Be),className:"min-w-14 border-l border-[var(--theme-border)] px-3 text-xs font-semibold text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"Open goal composer",children:"Open"})]},`${fe.action}:${fe.command}`):t.jsx("button",{type:"button",disabled:E(fe),onClick:Be=>G(fe,Be),className:`${C(fe)} ${De===0?"mt-0":""}`,title:fe.description??fe.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:fe.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:U(fe)})]})},`${fe.action}:${fe.command}`)),n.length===0?t.jsx("p",{className:"px-3 py-2 text-sm text-stone-400",children:"No backend tools are available for this thread."}):null]}):t.jsx("div",{className:"max-h-80 overflow-auto",children:r==="goals"?t.jsx(Cm,{goalState:i,goalHistory:d,busy:h,onBack:()=>H("root"),onUpdateGoal:q}):r==="fork"?t.jsx(vm,{busy:a,forkBusy:o,composerMenuItemClassName:ee,onForkLatest:te,onSelectForkTurnPanel:()=>(H("forkTurns"),de())}):r==="forkTurns"?t.jsx(km,{forkTurnOptionsState:s,forkBusy:o,composerPanelButtonClassName:W,onForkTurn:be}):r==="skills"?t.jsx(Tm,{skillsState:l,copiedSkillName:u,composerChipButtonClassName:T,onCopySkillInvokeName:ie}):r==="hooks"?t.jsx(wm,{hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:v,hookConfigSuccess:x,editingHookTarget:j,hookScope:w,hookEventName:y,hookMatcher:k,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,composerChipButtonClassName:T,onResetHookForm:ye,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:Ce,onSetHookScope:Le,onSetHookEventName:X,onSetHookMatcher:ue,onSetHookCommand:ve,onSetHookTimeoutSec:ke,onSetHookStatusMessage:_e,onSaveHook:He,onStartEditingHook:$e,onTrustHook:Ie,onUntrustHook:F}):t.jsx(Sm,{mcpPanelMode:R,mcpState:P,mcpConfigEditing:J,mcpConfigPath:D,mcpConfigError:Y,mcpConfigSuccess:Z,mcpConfigBusy:I,mcpHttpName:re,mcpHttpUrl:oe,mcpRawBlock:$,composerPanelButtonClassName:W,composerChipButtonClassName:T,onSetMcpPanelMode:le,onClearMcpConfigStatus:we,onSetMcpHttpName:z,onSetMcpHttpUrl:O,onSetMcpRawBlock:ne,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Te,onSaveRawMcpBlock:Ee})})})]})}function Lm({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:u,onToggleView:m,onDismissPromptFocus:f,onSetOpenMenu:p}){return t.jsxs(im,{align:"block-end",className:`${s} relative z-30 mb-0 flex items-center gap-2 text-xs`,children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!e&&i?t.jsx(Em,{...i}):null,!e&&d?t.jsx(gm,{...d}):null,r&&t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":e?"Switch to chat":"Switch to shell",title:e?"Switch to chat":"Switch to shell",onClick:()=>m==null?void 0:m(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(Bu,{}):t.jsx($u,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(xm,{...h}):null,e&&a?t.jsx(cm,{className:"min-w-0 max-w-[12rem] truncate rounded-full px-1.5 py-1 text-stone-400",title:a,children:a}):null,n&&t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button","data-composer-menu-trigger":"true","aria-label":o==="shellTools"?"Close shell tools":"Open shell tools","aria-haspopup":"menu","aria-expanded":o==="shellTools",title:o==="shellTools"?"Close shell tools":"Open shell tools",onClick:()=>{f(),p(g=>g==="shellTools"?null:"shellTools")},className:"inline-flex h-7 w-7 items-center justify-center rounded-full border border-stone-700 bg-stone-900/92 text-stone-200 transition hover:bg-stone-800",children:t.jsx(Gu,{})}),o==="shellTools"&&u?t.jsx(bm,{...u}):null]})]})]})}function Im(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function zm(e){return[...e.filter(r=>On(r)==="photo"),...e.filter(r=>On(r)==="file")]}function Pm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:o,pendingSelectionRef:s,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=Im}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=vu({prompt:e,attachments:r,files:f,selection:a()??o.current,kindForFile:p,buildClientId:d});return n(()=>g.draft),s.current=g.selection,o.current=g.selection,l.current=g.insertedAttachmentIds,i==null||i(),!0},[r,d,a,i,l,s,e,o,n]),u=c.useCallback((f,p)=>!f||f.length===0?!1:h(Array.from(f),()=>p),[h]),m=c.useCallback(f=>h(zm(f),On),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function cs(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function Rm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,o]=c.useState({});return c.useEffect(()=>{const s=n.current;if(r){cs(s),o({});return}const l={},i=new Set;for(const d of e){if(d.kind!=="photo")continue;i.add(d.clientId);let h=s.get(d.clientId);h||(h=URL.createObjectURL(d.file),s.set(d.clientId,h)),l[d.clientId]=h}for(const[d,h]of s.entries())i.has(d)||(URL.revokeObjectURL(h),s.delete(d));o(l)},[e,r]),c.useEffect(()=>{const s=n.current;return()=>{cs(s)}},[]),a}var Mm=180;function Cn(e,r){return{prompt:e??"",attachments:r??[]}}function Am({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[o,s]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>Cn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(Mr(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?Mr(Cn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const w=Cn(r,n),y=Mr(w);y!==p.current&&(p.current=y,u.current=y,h.current=w,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(w))},[n,r,m]);const g=c.useCallback(w=>{if(!m||!a)return;const y=Mr(w);y!==u.current&&(u.current=y,a(()=>({prompt:w.prompt,attachments:w.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const b=c.useCallback((w,y)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),y==="immediate"){g(w);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},Mm)}},[m,g]),v=c.useCallback((w=h.current)=>{b(w,"immediate")},[b]),x=c.useCallback((w,y="immediate")=>{if(m){const k=w(h.current);h.current=k,i(k),b(k,y);return}s(k=>w(k))},[m,b]),j=m?l:o;return{prompt:j.prompt,attachments:j.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:v}}function $m({slashPanelView:e,onForkLatest:r,onForkTurn:n,closeMenu:a}){const[o,s]=c.useState(!1);c.useEffect(()=>{e!=="forkTurns"&&s(!1)},[e]);const l=c.useCallback(async()=>{if(r){s(!0);try{await r(),a()}finally{s(!1)}}},[a,r]),i=c.useCallback(async d=>{if(n){s(!0);try{await n(d),a()}finally{s(!1)}}},[a,n]);return{forkBusy:o,forkLatest:l,forkTurn:i}}function _m({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:o,onUpdateGoal:s,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,u]=c.useState(!1),[m,f]=c.useState(""),[p,g]=c.useState(!1),[b,v]=c.useState(null),x=c.useCallback(async()=>{const y=e.trim();if(!y)return v("Goal objective cannot be empty."),!1;const k=m.trim(),S=Cu(k);if(k.length>0&&(S===null||!Number.isInteger(S)||S<=0))return v("Token budget must be a positive number in thousands."),!1;if(!s)return v("/goal is unavailable in this view."),!1;g(!0),v(null);try{return o&&await o({objective:y,tokenBudget:S})===!1?!1:(await s({objective:y,status:"active",tokenBudget:S}),f(""),u(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(N){return v(N instanceof Error?N.message:"Unable to set goal."),!1}finally{g(!1)}},[m,o,s,e,l]),j=c.useCallback(()=>{i(),d(),u(!0),f(Su(r==null?void 0:r.tokenBudget)),v(null),a==null||a(),requestAnimationFrame(()=>{var y;(y=n.current)==null||y.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),w=c.useCallback(()=>{u(!1),v(null)},[]);return{goalComposeMode:h,goalTokenBudget:m,goalBusy:p,goalLocalError:b,setGoalTokenBudget:f,submitGoal:x,enterGoalComposeMode:j,exitGoalComposeMode:w}}var Sn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function Dm(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function Bm({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:o,onUntrustHook:s}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,m]=c.useState("preToolUse"),[f,p]=c.useState("Bash"),[g,b]=c.useState(Sn),[v,x]=c.useState("30"),[j,w]=c.useState("Running hook"),[y,k]=c.useState(null),[S,N]=c.useState(!1),[L,R]=c.useState(null),[P,J]=c.useState(null),D=c.useMemo(()=>Dm(r),[r]),Y=c.useCallback(ee=>D.get(ee)??D.get("preToolUse")??Sn,[D]),Z=c.useMemo(()=>new Set([Sn,...D.values()]),[D]),I=c.useCallback(()=>{R(null),J(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),I())},[I,e]),c.useEffect(()=>{const ee=Yr.find(W=>W.value===u);p(W=>{const T=W.trim(),K=new Set(Yr.map(G=>G.matcherHint).filter(Boolean));return T&&!K.has(T)?W:(ee==null?void 0:ee.matcherHint)??""}),b(W=>Z.has(W.trim())?Y(u):W)},[Y,Z,u]);const re=c.useCallback(()=>{k(null),h("project"),m("preToolUse"),p("Bash"),b(Y("preToolUse")),x("30"),w("Running hook")},[Y]),oe=c.useCallback(ee=>{const W=ol(ee);if(!W){R("Only command hooks in global or project hooks.json can be edited here.");return}k(W),h(W.scope),m(W.eventName),p(W.matcher??""),b(W.command),x(W.timeoutSec?String(W.timeoutSec):""),w(W.statusMessage??""),R(null),J(null),i("edit")},[]),$=c.useCallback(async()=>{if(l==="edit"&&!a){R("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){R("Hook editing is unavailable in this view.");return}if(l==="edit"&&!y){R("Select a hook to edit first.");return}const ee=g.trim();if(!ee){R("Hook command cannot be empty.");return}const W=v.trim(),T=W?Number(W):null;if(W&&(T===null||!Number.isInteger(T)||T<=0)){R("Timeout must be a positive number of seconds.");return}N(!0),R(null),J(null);try{const K={scope:d,eventName:u,matcher:f.trim()||null,command:ee,timeoutSec:T,statusMessage:j.trim()||null};l==="edit"?await(a==null?void 0:a({...K,target:y})):await(n==null?void 0:n(K)),J(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),k(null)}catch(K){R(K instanceof Error?K.message:"Unable to write hooks.json.")}finally{N(!1)}},[y,g,u,f,d,j,v,l,n,a]),Q=c.useCallback(async ee=>{if(!o||!ee.currentHash){R("Hook trust is unavailable in this view.");return}N(!0),R(null),J(null);try{await o({key:ee.key,currentHash:ee.currentHash}),J("Hook trusted.")}catch(W){R(W instanceof Error?W.message:"Unable to trust hook.")}finally{N(!1)}},[o]),_=c.useCallback(async ee=>{if(!s){R("Hook trust is unavailable in this view.");return}N(!0),R(null),J(null);try{await s({key:ee.key}),J("Hook untrusted.")}catch(W){R(W instanceof Error?W.message:"Unable to untrust hook.")}finally{N(!1)}},[s]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:v,hookStatusMessage:j,editingHookTarget:y,hookConfigBusy:S,hookConfigError:L,hookConfigSuccess:P,setHooksPanelMode:i,setEditingHookTarget:k,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:b,setHookTimeoutSec:x,setHookStatusMessage:w,clearHookConfigStatus:I,resetHookForm:re,startEditingHook:oe,saveHook:$,trustHook:Q,untrustHook:_}}var Gm=`[mcp_servers.example_stdio]
|
|
3654
3654
|
command = "npx"
|
|
3655
3655
|
args = ["-y", "your-mcp-server"]
|
|
3656
3656
|
`,hs="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function Fm({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:o}){const[s,l]=c.useState(""),[i,d]=c.useState(""),[h,u]=c.useState(""),[m,f]=c.useState(null),[p,g]=c.useState(!1),[b,v]=c.useState(null),[x,j]=c.useState(null),w=c.useCallback(()=>{v(null),j(null)},[]),y=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const R=await r();return f(R.path),R},[e,r]),k=c.useCallback(async R=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const P=await n(R);return f(P.path),P},[e,n]),S=c.useCallback(async()=>{const R=Tu(s),P=i.trim();if(!R){v("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(P)){v("HTTP MCP URL must start with http:// or https://");return}g(!0),v(null),j(null);try{const J=await y(),D=as(J.content,R,Lu(R,P));await k(D),j(hs),a("list"),l(""),d(""),o==null||o()}catch(J){v(J instanceof Error?J.message:"Unable to update provider config.")}finally{g(!1)}},[y,s,i,o,a,k]),N=c.useCallback(async()=>{g(!0),v(null),j(null);try{await y(),u(R=>R||Gm),a("stdio")}catch(R){v(R instanceof Error?R.message:"Unable to load provider config.")}finally{g(!1)}},[y,a]),L=c.useCallback(async()=>{const R=Eu(h);if(!R){v("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),v(null),j(null);try{const P=await y(),J=as(P.content,R,h);await k(J),j(hs),a("list"),o==null||o()}catch(P){v(P instanceof Error?P.message:"Unable to update provider config.")}finally{g(!1)}},[y,h,o,a,k]);return{mcpHttpName:s,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:b,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:w,prepareRawMcpBlock:N,saveHttpMcp:S,saveRawMcpBlock:L}}function Hm({openMenu:e,setOpenMenu:r,slashPanelView:n,setSlashPanelView:a,setMcpPanelMode:o,clearMcpConfigStatus:s,clearHookConfigStatus:l}){const[i,d]=c.useState(null);c.useEffect(()=>{e!=="slash"&&(a("root"),o("list"),s(),l())},[l,s,e,o,a]),c.useEffect(()=>{n!=="mcp"&&(o("list"),s())},[s,o,n]),c.useEffect(()=>{if(!i)return;const u=window.setTimeout(()=>{d(m=>m===i?null:m)},1400);return()=>{window.clearTimeout(u)}},[i]),c.useEffect(()=>{function u(m){(typeof m.composedPath=="function"?m.composedPath():[]).some(g=>g instanceof HTMLElement&&(g.dataset.composerMenuSurface==="true"||g.dataset.composerMenuTrigger==="true"))||e&&r(null)}if(e)return window.addEventListener("pointerdown",u),()=>{window.removeEventListener("pointerdown",u)}},[e,r]);const h=c.useCallback(async u=>{try{await navigator.clipboard.writeText(`$${u}`),d(u)}catch{d(null)}},[]);return{copiedSkillName:i,copySkillInvokeName:h}}function Om(e,r){const{attachment:n}=e,a=document.createElement("span");if(a.dataset.segmentType="attachment",a.dataset.clientId=n.clientId,a.dataset.placeholder=n.placeholder,a.contentEditable="false",a.className="thread-composer-attachment-chip mx-[0.12rem] inline-flex max-w-full align-baseline",n.kind==="photo"){a.classList.add("thread-composer-attachment-chip-photo","rounded-[0.95rem]","border","border-sky-300/35","bg-sky-300/10","p-1","shadow-sm","shadow-stone-950/20");const l=r[n.clientId];if(l){const d=document.createElement("img");d.src=l,d.alt=n.originalName||"Pasted image",d.className="thread-composer-attachment-thumb h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-950 object-contain",d.draggable=!1,a.append(d)}else{const d=document.createElement("span");d.className="thread-composer-attachment-thumb inline-block h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-900/80",d.setAttribute("aria-hidden","true"),a.append(d)}const i=document.createElement("span");return i.className="thread-composer-attachment-caption ml-2 inline-flex max-w-[8rem] items-center text-[10px] font-medium tracking-[0.08em] text-sky-50",i.textContent=os(n),a.append(i),a}a.classList.add("items-center","gap-2","rounded-[0.95rem]","border","border-emerald-300/35","bg-emerald-300/10","px-2.5","py-2","text-[10px]","font-medium","tracking-[0.08em]","text-emerald-50","shadow-sm","shadow-stone-950/20");const o=document.createElement("span");o.className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-emerald-200/25 bg-emerald-300/12 text-[9px]",o.textContent="FILE";const s=document.createElement("span");return s.className="inline-flex max-w-[10rem] truncate",s.textContent=os(n),a.append(o,s),a}function Wm(e,r){const n=document.createDocumentFragment();for(const a of e){if(a.type==="text"){n.append(document.createTextNode(a.text===" "?" ":a.text));continue}n.append(Om(a,r))}return n}function Um({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:o,previewSignature:s,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:u,renderedSanitizeNonceRef:m,serializeEditorPrompt:f,restoreSelection:p}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const b=i.current,v=f()!==n||u.current!==s||m.current!==l;v&&(g.replaceChildren(Wm(a,o)),u.current=s,m.current=l),b!==null?(g.focus(),sm(g,d.current)||p(b),h.current=b):document.activeElement===g&&v&&p(h.current),i.current=null,d.current=[]},[o,l,r,s,n,e,a,d,i,u,m,p,h,f])}function Vm({tokenBudget:e,error:r,onTokenBudgetChange:n,onCancel:a}){return t.jsxs("div",{className:"thread-goal-compose-card relative z-20 mb-1.5 flex flex-wrap items-center gap-2 rounded-2xl border px-3 py-2 text-xs shadow-sm",children:[t.jsx("span",{className:"thread-goal-compose-label font-medium uppercase tracking-[0.16em]",children:"Goal"}),t.jsxs("label",{className:"thread-goal-compose-field flex items-center gap-2",children:[t.jsx("span",{children:"Max tokens (k)"}),t.jsx("input",{"aria-label":"Goal token budget",value:e,onChange:o=>n(o.target.value),inputMode:"numeric",placeholder:"Optional",className:"thread-goal-compose-input h-7 w-24 rounded-full border px-3 text-xs outline-none"})]}),r?t.jsx("span",{className:"thread-goal-compose-error min-w-0 flex-1",children:r}):null,t.jsx("button",{type:"button",onClick:a,className:"thread-goal-compose-cancel rounded-full border px-2.5 py-1 text-[11px] transition",children:"Cancel"})]})}function Km({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:o,interruptLabel:s,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:b,onDragOver:v,onDragLeave:x,onDrop:j}){return t.jsxs("div",{"data-slot":"input-group-control",className:`${l} relative w-full`,children:[t.jsxs("div",{className:i,children:[r.length===0&&t.jsx("span",{className:`pointer-events-none absolute left-3 top-3 truncate text-slate-500 sm:left-4 sm:top-4 dark:text-slate-400 ${o?"right-12":"right-3 sm:right-4"}`,children:a}),t.jsx("div",{ref:e,role:"textbox","aria-label":"Prompt","aria-multiline":"true",contentEditable:!n,suppressContentEditableWarning:!0,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:b,onDragOver:v,onDragLeave:x,onDrop:j,className:`relative z-[1] min-h-[4.25rem] whitespace-pre-wrap break-words pb-2 outline-none sm:min-h-[4.25rem] ${o?"pr-12":""} ${n?"cursor-not-allowed text-slate-500":""}`})]}),o?t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":s,title:s,onClick:w=>{w.preventDefault(),d==null||d()},className:"thread-graph-composer-stop-button ui-action-danger absolute right-2 top-2 z-30 h-8 w-8 rounded-full text-sm font-medium",children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}):null]})}function qm({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:o,canInterrupt:s,sendButtonLabel:l,sendButtonClassName:i,sendDisabled:d,onPromptChange:h,onPromptKeyDown:u,onInterrupt:m}){return t.jsxs("div",{className:`${n} relative`,children:[t.jsx("textarea",{"aria-label":"Prompt",disabled:!1,value:e,onChange:f=>h(f.target.value),onKeyDown:u,rows:2,placeholder:r,className:`${a} resize-y pb-10`}),t.jsx("button",{type:"button","aria-label":o,title:o,onClick:()=>void(m==null?void 0:m()),disabled:!s,className:`absolute right-2.5 top-2.5 inline-flex h-8 w-8 items-center justify-center rounded-full border transition ${s?"border-rose-300/55 bg-rose-300/[0.14] text-rose-50 shadow-lg shadow-rose-950/20 hover:bg-rose-300/[0.22]":"cursor-not-allowed border-stone-700/30 bg-stone-400/[0.02] text-stone-500/55 opacity-55"}`,children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}),t.jsx("button",{type:"submit","aria-label":"Send Shell Input",onMouseDown:f=>{f.preventDefault()},onPointerDown:f=>{f.preventDefault()},onTouchStart:f=>{f.preventDefault()},disabled:d,className:`absolute bottom-2.5 right-2.5 rounded-full px-3.5 py-1.5 text-sm font-medium shadow-lg shadow-stone-950/30 transition disabled:cursor-not-allowed disabled:bg-stone-700 disabled:text-stone-300 ${i}`,children:l})]})}function Xm({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:u,goalTokenBudget:m,goalLocalError:f,goalBusy:p,busy:g,sendButtonLabel:b,sendButtonClassName:v,onInterrupt:x,onPromptInput:j,onPromptPaste:w,onPromptKeyDown:y,onPromptKeyUp:k,onPromptMouseUp:S,onPromptBlur:N,onPromptDragEnter:L,onPromptDragOver:R,onPromptDragLeave:P,onPromptDrop:J,onGoalTokenBudgetChange:D,onCancelGoal:Y,onShellPromptChange:Z}){return{promptSlot:e?null:t.jsx(Km,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:j,onPaste:w,onKeyDown:y,onKeyUp:k,onMouseUp:S,onBlur:N,onDragEnter:L,onDragOver:R,onDragLeave:P,onDrop:J}),goalSlot:u&&!e?t.jsx(Vm,{tokenBudget:m,error:f,onTokenBudgetChange:D,onCancel:Y}):null,shellPromptSlot:e?t.jsx(qm,{prompt:n,promptPlaceholder:o,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:s,sendButtonLabel:b,sendButtonClassName:v,sendDisabled:p||g,onPromptChange:Z,onPromptKeyDown:y,onInterrupt:x}):null}}function Ym({collaborationMode:e,onUpdateSettings:r,closeMenu:n}){const[a,o]=c.useState(null),s=a??e;c.useEffect(()=>{o(null)},[e]);const l=c.useCallback(async i=>{const d=Nu({nextMode:i.collaborationMode,previousOptimisticMode:a});d.optimisticMode&&o(d.optimisticMode);try{await(r==null?void 0:r(i)),d.closeMenuOnSuccess&&n()}catch(h){throw d.shouldRollbackMode&&o(d.rollbackMode),h}},[n,r,a]);return{displayedCollaborationMode:s,updateSettings:l}}function Zm({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,inlineToggleClassName:m,planToggleActiveClassName:f,sendButtonBaseClassName:p,slashPanelView:g,availableToolboxItems:b,busy:v,settingsBusy:x,compactBusy:j,forkBusy:w,fastMode:y,goalComposeMode:k,goalBusy:S,goalStatus:N,activeView:L,disabled:R,model:P,modelOptions:J,modelContextTitle:D,contextUsage:Y,reasoningEffort:Z,supportedEfforts:I,displayedCollaborationMode:re,sandboxMode:oe,sendButtonLabel:$,sendButtonClassName:Q,modelControlsDisabled:_,effortControlsDisabled:ee,effortControlTitle:W,forkTurnOptionsState:T,skillsState:K,goalState:G,goalHistory:E,copiedSkillName:C,hooksPanelMode:U,hooksState:H,hookConfigBusy:se,hookConfigError:q,hookConfigSuccess:de,editingHookTarget:te,hookScope:be,hookEventName:ie,hookMatcher:ye,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:Ce,mcpPanelMode:Le,mcpState:X,mcpConfigPath:ue,mcpConfigError:ve,mcpConfigSuccess:ke,mcpConfigBusy:_e,mcpHttpName:He,mcpHttpUrl:$e,mcpRawBlock:Ie,capabilities:F,shellControlState:le,onToggleView:we,onDismissPromptFocus:z,onSetOpenMenu:O,onToolboxItemClick:ne,onSetSlashPanelView:ge,onViewGoals:Te,onUpdateGoal:Ee,onOpenForkTurns:fe,onForkLatest:De,onForkTurn:Be,onCopySkillInvokeName:et,onResetHookForm:Ve,onSetHooksPanelMode:pt,onClearHookConfigStatus:nt,onSetEditingHookTarget:We,onSetHookScope:ot,onSetHookEventName:ht,onSetHookMatcher:ut,onSetHookCommand:M,onSetHookTimeoutSec:V,onSetHookStatusMessage:xe,onSaveHook:je,onStartEditingHook:Ne,onTrustHook:Ye,onUntrustHook:tt,onSetMcpPanelMode:Fe,onClearMcpConfigStatus:Ke,onSetMcpHttpName:lt,onSetMcpHttpUrl:vt,onSetMcpRawBlock:it,onPrepareRawMcpBlock:Nt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:Ct,onPickPhoto:A,onPickFile:pe,onUpdateSettings:Re,onPasteShell:Ge,onCopyShell:Ue,onClearShell:ct,onShellControl:kt}){const qt=e?null:{open:o==="slash",slashPanelView:g,availableToolboxItems:b,busy:v,forkBusy:w,forkTurnOptionsState:T,skillsState:K,goalState:G,goalHistory:E,goalBusy:S,copiedSkillName:C,hooksPanelMode:U,hooksState:H,hostConfigFilesAvailable:F.hostConfigFiles,hookTrustAvailable:F.hookTrust,hookConfigBusy:se,hookConfigError:q,hookConfigSuccess:de,editingHookTarget:te,hookScope:be,hookEventName:ie,hookMatcher:ye,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:Ce,mcpPanelMode:Le,mcpState:X,mcpConfigEditing:F.mcpConfigEditing,mcpConfigPath:ue,mcpConfigError:ve,mcpConfigSuccess:ke,mcpConfigBusy:_e,mcpHttpName:He,mcpHttpUrl:$e,mcpRawBlock:Ie,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>O(at=>at==="slash"?null:"slash"),onToolboxItemClick:ne,toolboxItemDisabled:at=>Qu(at,{settingsBusy:x,compactBusy:j,busy:v,forkBusy:w}),toolboxItemClassName:at=>em(at,{fastMode:y,goalComposeMode:k,goalStatus:N,menuItemClassName:d}),toolboxItemStatus:at=>Ju(at,{fastMode:y,compactBusy:j,goalComposeMode:k,goalStatus:N,busy:v}),onSetSlashPanelView:ge,onViewGoals:Te,onUpdateGoal:Ee,onOpenForkTurns:fe,onForkLatest:De,onForkTurn:Be,onCopySkillInvokeName:et,onResetHookForm:Ve,onSetHooksPanelMode:pt,onClearHookConfigStatus:nt,onSetEditingHookTarget:We,onSetHookScope:ot,onSetHookEventName:ht,onSetHookMatcher:ut,onSetHookCommand:M,onSetHookTimeoutSec:V,onSetHookStatusMessage:xe,onSaveHook:je,onStartEditingHook:Ne,onTrustHook:Ye,onUntrustHook:tt,onSetMcpPanelMode:Fe,onClearMcpConfigStatus:Ke,onSetMcpHttpName:lt,onSetMcpHttpUrl:vt,onSetMcpRawBlock:it,onPrepareRawMcpBlock:Nt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:Ct},Xt=e?null:{open:o==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>O(at=>at==="attachments"?null:"attachments"),onPickPhoto:A,onPickFile:pe},Mt=e?null:{openMenu:o,model:P,modelOptions:J,modelContextTitle:D,contextUsage:Y,reasoningEffort:Z,supportedEfforts:I,displayedCollaborationMode:re,sandboxMode:oe,planModeAvailable:F.planMode,sandboxModeAvailable:F.sandboxMode,settingsBusy:x,goalComposeMode:k,goalBusy:S,activeView:L,disabled:R,fastMode:y,sendButtonLabel:$,sendButtonClassName:Q,modelControlsDisabled:_,effortControlsDisabled:ee,effortControlTitle:W,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:O,onUpdateSettings:Re};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:qt,attachmentMenuProps:Xt,settingsToolbarProps:Mt,shellToolsPanelProps:o==="shellTools"?{busy:v,shellControlState:le,onPaste:Ge,onCopy:Ue,onClear:ct,onShellControl:kt}:null,shellControlState:le,onToggleView:we,onDismissPromptFocus:z,onSetOpenMenu:O}}function Vn({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:o=!1,error:s,model:l=null,reasoningEffort:i=null,fastMode:d=!1,collaborationMode:h="default",sandboxMode:u=null,hideSandboxModeControl:m=!1,modelOptions:f=[],contextUsage:p=null,capabilities:g=null,toolboxItems:b=null,hookCommandTemplates:v=null,mcpConfigFormat:x="none",followTail:j=!1,threadConnected:w=!0,shellAvailable:y=!0,disabled:k=!1,disabledPlaceholder:S,shellControlState:N=null,draftPrompt:L,draftAttachments:R,onPickAttachment:P,skillsState:J={status:"idle",data:null,error:null},mcpState:D={status:"idle",data:null,error:null},hooksState:Y={status:"idle",data:null,error:null},goalState:Z={status:"idle",data:null,error:null},goalHistory:I=[],forkTurnOptionsState:re={status:"idle",data:null,error:null},onDraftChange:oe,onSubmit:$,onInterrupt:Q,onCompact:_,onOpenSkills:ee,onOpenMcp:W,onOpenHooks:T,onCreateHook:K,onUpdateHook:G,onTrustHook:E,onUntrustHook:C,onOpenGoal:U,onPrepareGoalSubmit:H,onUpdateGoal:se,onOpenForkTurns:q,onForkLatest:de,onForkTurn:te,onReadProviderConfig:be,onWriteProviderConfig:ie,onToggleFollow:ye,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:Ce,onJumpToNextTurn:Le,subscriptionUsage:X,onUpdateSettings:ue,onToggleView:ve,onShellCopy:ke,onShellControl:_e,canInterrupt:He=!1}){var Ca;const[$e,Ie]=c.useState(null),[F,le]=c.useState("root"),we=c.useRef(!1),[z,O]=c.useState("list"),ne=c.useMemo(()=>({fast:(g==null?void 0:g.controls.performanceMode)??!1,compact:(g==null?void 0:g.turns.compact)??!1,goal:(g==null?void 0:g.controls.goals)??!1,fork:(g==null?void 0:g.branching.fork)??!1,skills:(g==null?void 0:g.management.skills)??!1,mcp:(g==null?void 0:g.management.mcpStatus)??!1,hooks:(g==null?void 0:g.management.hooks)??!1,hostConfigFiles:(g==null?void 0:g.management.hostConfigFiles)??!1,mcpConfigEditing:x==="codex-toml"&&!!(g!=null&&g.management.hostConfigFiles)&&!!be&&!!ie,hookTrust:(g==null?void 0:g.management.hookTrust)??!1,planMode:(g==null?void 0:g.controls.planMode)??!1,sandboxMode:(g==null?void 0:g.controls.sandboxMode)??!1}),[g,x,be,ie]),ge=c.useMemo(()=>Yu(b,ne),[ne,b]),Te=c.useRef(null),Ee=c.useRef(null),fe=c.useRef(null),De=c.useRef(null),Be=c.useRef(null),et=c.useRef([]),Ve=c.useRef(null),pt=c.useRef(""),nt=c.useRef(0),We=e==="shell",ot=y||We,ht=!!(We&&(N!=null&&N.isMobileShell)),ut=(N==null?void 0:N.promptLabel)??null,[M,V]=c.useState(!1),[xe,je]=c.useState(0),{prompt:Ne,attachments:Ye,isDraftControlled:tt,updateDraft:Fe,flushControlledDraftToHost:Ke}=Am({isShellView:We,draftPrompt:L,draftAttachments:R,onDraftChange:oe}),lt=Rm({attachments:Ye,isShellView:We}),{displayedCollaborationMode:vt,updateSettings:it}=Ym({collaborationMode:h,onUpdateSettings:ue,closeMenu:()=>Ie(null)}),{forkBusy:Nt,forkLatest:Rt,forkTurn:Ct}=$m({slashPanelView:F,onForkLatest:de,onForkTurn:te,closeMenu:()=>Ie(null)}),{hooksPanelMode:A,hookScope:pe,hookEventName:Re,hookMatcher:Ge,hookCommand:Ue,hookTimeoutSec:ct,hookStatusMessage:kt,editingHookTarget:qt,hookConfigBusy:Xt,hookConfigError:Mt,hookConfigSuccess:cr,setHooksPanelMode:at,setEditingHookTarget:cn,setHookScope:hn,setHookEventName:zl,setHookMatcher:Pl,setHookCommand:Rl,setHookTimeoutSec:Ml,setHookStatusMessage:Al,clearHookConfigStatus:ga,resetHookForm:$l,startEditingHook:_l,saveHook:Dl,trustHook:Bl,untrustHook:Gl}=Bm({slashPanelView:F,hookCommandTemplates:v,onCreateHook:K,onUpdateHook:G,onTrustHook:E,onUntrustHook:C}),{goalComposeMode:hr,goalTokenBudget:Fl,goalBusy:un,goalLocalError:Hl,setGoalTokenBudget:Ol,submitGoal:Wl,enterGoalComposeMode:Ul,exitGoalComposeMode:xa}=_m({prompt:Ne,goalTokenBudgetSource:Z.data,promptRef:Ee,onOpenGoal:U,onPrepareGoalSubmit:H,onUpdateGoal:se,updateDraft:Fe,closeMenu:()=>Ie(null),resetSlashPanel:()=>le("root")}),{mcpHttpName:Vl,mcpHttpUrl:Kl,mcpRawBlock:ql,mcpConfigPath:Xl,mcpConfigBusy:Yl,mcpConfigError:Zl,mcpConfigSuccess:Jl,setMcpHttpName:Ql,setMcpHttpUrl:ei,setMcpRawBlock:ti,clearMcpConfigStatus:ba,prepareRawMcpBlock:ri,saveHttpMcp:ni,saveRawMcpBlock:ai}=Fm({hostConfigFilesAvailable:ne.hostConfigFiles,onReadProviderConfig:be,onWriteProviderConfig:ie,setMcpPanelMode:O,onOpenMcp:W}),{copiedSkillName:si,copySkillInvokeName:oi}=Hm({openMenu:$e,setOpenMenu:Ie,slashPanelView:F,setSlashPanelView:le,setMcpPanelMode:O,clearMcpConfigStatus:ba,clearHookConfigStatus:ga}),li=c.useCallback(ae=>{Fe(Se=>{if(typeof ae=="function"){const Me=ae(Se.prompt,Se.attachments);return{prompt:Me.prompt,attachments:Me.attachments??Se.attachments}}return{prompt:ae,attachments:Se.attachments}})},[Fe]),mn=c.useMemo(()=>f.find(ae=>ae.model===l)??null,[l,f]),ii=Iu(l,p),va=(mn==null?void 0:mn.supportedReasoningEfforts)??[],di=c.useMemo(()=>fu(Ne,Ye),[Ye,Ne]),ci=c.useMemo(()=>Object.entries(lt).sort(([ae],[Se])=>ae.localeCompare(Se)).map(([ae,Se])=>`${ae}:${Se}`).join("|"),[lt]);function hi(ae,Se){Se.stopPropagation();const Me=Zu(ae,{fastMode:d,goalComposeMode:hr});switch(Me.type){case"toggleFast":it({fastMode:Me.fastMode});break;case"runCompact":Ie(null),_==null||_();break;case"enterGoalCompose":Ul();break;case"exitGoalCompose":xa(),Ie(null);break;case"openPanel":le(Me.panel),Me.panel==="skills"?ee==null||ee():Me.panel==="mcp"?W==null||W():Me.panel==="hooks"&&(T==null||T());break;case"insertPrompt":gn(Me.text),le("root"),Ie(null);break}}function Yt(){const ae=Ee.current;return ae?nm(ae):null}const ui=c.useCallback(ae=>{const Se=Ee.current;!Se||!ae||am(Se,ae)},[]),pn=c.useCallback(()=>{const ae=Ee.current;return ae?ll(ae):Ne},[Ne]),{appendAttachments:fn,appendDroppedAttachments:ka}=Pm({prompt:Ne,attachments:Ye,updateDraft:Fe,getSelection:Yt,selectionSnapshotRef:Ve,pendingSelectionRef:Be,pendingInsertedAttachmentIdsRef:et,onInserted:()=>Ie(null)}),wa=c.useCallback((ae,Se)=>{var Me;if(At(),P){P({kind:ae,appendAttachments:(Je,st=ae)=>fn(Je,st),defaultPick:()=>{var Je;return(Je=Se.current)==null?void 0:Je.click()}});return}(Me=Se.current)==null||Me.click()},[fn,At,P]);function gn(ae){if(!ae)return;const Se=Yt()??Ve.current,Me=(Se==null?void 0:Se.start)??Ne.length,Je=(Se==null?void 0:Se.end)??Me,st=pu(ae),Zt=`${Ne.slice(0,Me)}${st}${Ne.slice(Je)}`;Fe(Ki=>({prompt:Zt,attachments:Ki.attachments}));const $t=Me+st.length;Be.current={start:$t,end:$t},Ve.current={start:$t,end:$t}}Um({promptRef:Ee,isShellView:We,prompt:Ne,promptSegments:di,attachmentPreviewUrls:lt,previewSignature:ci,editorSanitizeNonce:xe,pendingSelectionRef:Be,pendingInsertedAttachmentIdsRef:et,selectionSnapshotRef:Ve,renderedPreviewSignatureRef:pt,renderedSanitizeNonceRef:nt,serializeEditorPrompt:pn,restoreSelection:ui});function At(){var ae;(ae=Ee.current)==null||ae.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function mi(){var ae;if(At(),Ie(null),!!((ae=navigator.clipboard)!=null&&ae.readText))try{const Se=await navigator.clipboard.readText();gn(Se)}catch{return}}async function ya(){if(!we.current){we.current=!0;try{if(tt&&Ke(),hr&&!We){await Wl();return}const ae=ku({prompt:Ne,attachments:Ye,isShellView:We});if(!ae||await $(ae)===!1)return;Fe(()=>({prompt:"",attachments:[]}))}finally{we.current=!1}}}async function pi(ae){ae.preventDefault(),await ya()}function fi(){const ae=pn(),Se=Yt();Ve.current=Se;const Me=Ee.current;(Me?rm(Me):!1)&&(Be.current=Se,je(st=>st+1)),Fe(st=>({prompt:ae,attachments:st.attachments.filter(Zt=>ae.includes(Zt.placeholder))}),"deferred")}function gi(ae){var Je,st,Zt,$t;const Se=Wn((Je=ae.clipboardData)==null?void 0:Je.items,(st=ae.clipboardData)==null?void 0:st.files),Me=wu({files:Se,plainText:((Zt=ae.clipboardData)==null?void 0:Zt.getData("text/plain"))??"",htmlText:(($t=ae.clipboardData)==null?void 0:$t.getData("text/html"))??"",htmlToText:tm});Me.preventDefault&&ae.preventDefault(),Me.type==="insert-text"?gn(Me.text):Me.type==="append-files"&&ka(Me.files)}function xi(ae){var Me,Je;const Se=rs(ss((Me=ae.dataTransfer)==null?void 0:Me.items,(Je=ae.dataTransfer)==null?void 0:Je.files));Se.preventDefault&&ae.preventDefault(),Se.activateDragTarget&&V(!0)}function bi(ae){var Me,Je;const Se=rs(ss((Me=ae.dataTransfer)==null?void 0:Me.items,(Je=ae.dataTransfer)==null?void 0:Je.files));Se.preventDefault&&ae.preventDefault(),Se.activateDragTarget&&ae.dataTransfer&&(ae.dataTransfer.dropEffect="copy"),Se.activateDragTarget&&V(!0)}function vi(ae){ae.currentTarget.contains(ae.relatedTarget)||V(!1)}function ki(ae){var Je,st;const Se=Wn((Je=ae.dataTransfer)==null?void 0:Je.items,(st=ae.dataTransfer)==null?void 0:st.files),Me=yu(Se);Me.preventDefault&&ae.preventDefault(),Me.type==="accept-files"&&(V(!1),ka(Me.files??[]))}function wi(ae){if(ae.key==="Enter"&&ae.repeat){ae.preventDefault();return}if(e==="chat"&&ae.key==="/"&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&!n&&!k&&ge.length>0&&pn().trim().length===0){ae.preventDefault(),le("root"),Ie("slash");return}const Se=ju({key:ae.key,metaKey:ae.metaKey,ctrlKey:ae.ctrlKey,busy:n,disabled:k});Se.preventDefault&&ae.preventDefault(),Se.submit&&ya()}const{promptPlaceholder:yi,interruptLabel:ji,sendButtonLabel:ja,sendButtonClassName:Na,modelControlsDisabled:Ni,effortControlsDisabled:Ci,effortControlTitle:Si}=Mu({goalComposeMode:hr,goalBusy:un,threadConnected:w,busy:n,isShellView:We,disabledPlaceholder:S,settingsBusy:a,supportedEffortCount:va.length,fastMode:d}),{composerLayerClassName:Ti,formClassName:Ei,composerShellClassName:Li,composerToolbarClassName:Ii,composerIconButtonClassName:zi,composerMenuClassName:Pi,composerMenuItemClassName:Ri,composerInlineToggleClassName:Mi,composerPanelButtonClassName:Ai,composerChipButtonClassName:$i,composerPlanToggleActiveClassName:_i,composerSendButtonClassName:Di,composerPromptRegionClassName:Bi,promptInputClassName:Gi,graphChatInputGroupClassName:Fi,graphChatInputClassName:Hi}=Au({isShellView:We,edgeToEdgeMobile:r,isMobileShell:ht,openMenu:$e!==null,isDragTargetActive:M,busy:n}),Oi=Zm({isShellView:We,canToggleShellView:ot,isMobileShell:ht,shellPromptLabel:ut,openMenu:$e,toolbarClassName:Ii,iconButtonClassName:zi,menuClassName:Pi,menuItemClassName:Ri,panelButtonClassName:Ai,chipButtonClassName:$i,inlineToggleClassName:Mi,planToggleActiveClassName:_i,sendButtonBaseClassName:Di,slashPanelView:F,availableToolboxItems:ge,busy:n,settingsBusy:a,compactBusy:o,forkBusy:Nt,fastMode:d,goalComposeMode:hr,goalBusy:un,goalStatus:(Ca=Z.data)==null?void 0:Ca.status,activeView:e,disabled:k,model:l,modelOptions:f,modelContextTitle:ii,contextUsage:p,reasoningEffort:i,supportedEfforts:va,displayedCollaborationMode:vt,sandboxMode:u,sendButtonLabel:ja,sendButtonClassName:Na,modelControlsDisabled:Ni,effortControlsDisabled:Ci,effortControlTitle:Si,forkTurnOptionsState:re,skillsState:J,goalState:Z,goalHistory:I,copiedSkillName:si,hooksPanelMode:A,hooksState:Y,hookConfigBusy:Xt,hookConfigError:Mt,hookConfigSuccess:cr,editingHookTarget:qt,hookScope:pe,hookEventName:Re,hookMatcher:Ge,hookCommand:Ue,hookTimeoutSec:ct,hookStatusMessage:kt,mcpPanelMode:z,mcpState:D,mcpConfigPath:Xl,mcpConfigError:Zl,mcpConfigSuccess:Jl,mcpConfigBusy:Yl,mcpHttpName:Vl,mcpHttpUrl:Kl,mcpRawBlock:ql,capabilities:{hostConfigFiles:ne.hostConfigFiles,hookTrust:ne.hookTrust,mcpConfigEditing:ne.mcpConfigEditing,planMode:ne.planMode,sandboxMode:m?!1:ne.sandboxMode},shellControlState:N,onToggleView:ve,onDismissPromptFocus:At,onSetOpenMenu:Ie,onToolboxItemClick:hi,onSetSlashPanelView:le,onViewGoals:U,onUpdateGoal:se,onOpenForkTurns:()=>q==null?void 0:q(),onForkLatest:Rt,onForkTurn:Ct,onCopySkillInvokeName:oi,onResetHookForm:$l,onSetHooksPanelMode:at,onClearHookConfigStatus:ga,onSetEditingHookTarget:cn,onSetHookScope:hn,onSetHookEventName:zl,onSetHookMatcher:Pl,onSetHookCommand:Rl,onSetHookTimeoutSec:Ml,onSetHookStatusMessage:Al,onSaveHook:Dl,onStartEditingHook:_l,onTrustHook:Bl,onUntrustHook:Gl,onSetMcpPanelMode:O,onClearMcpConfigStatus:ba,onSetMcpHttpName:Ql,onSetMcpHttpUrl:ei,onSetMcpRawBlock:ti,onPrepareRawMcpBlock:ri,onSaveHttpMcp:ni,onSaveRawMcpBlock:ai,onPickPhoto:()=>wa("photo",fe),onPickFile:()=>wa("file",De),onUpdateSettings:ae=>void it(ae),onPasteShell:()=>void mi(),onCopyShell:()=>{At(),Ie(null),ke==null||ke()},onClearShell:()=>{At(),Ie(null),$({prompt:"clear"})},onShellControl:ae=>{At(),Ie(null),_e==null||_e(ae)}}),{promptSlot:Wi,goalSlot:Ui,shellPromptSlot:Vi}=Xm({isShellView:We,promptRef:Ee,prompt:Ne,disabled:k,promptPlaceholder:yi,canInterrupt:He,interruptLabel:ji,composerPromptRegionClassName:Bi,graphChatInputClassName:Hi,promptInputClassName:Gi,goalComposeMode:hr,goalTokenBudget:Fl,goalLocalError:Hl,goalBusy:un,busy:n,sendButtonLabel:ja,sendButtonClassName:Na,onInterrupt:Q,onPromptInput:fi,onPromptPaste:gi,onPromptKeyDown:wi,onPromptKeyUp:()=>{Ve.current=Yt()},onPromptMouseUp:()=>{Ve.current=Yt()},onPromptBlur:()=>{Ve.current=Yt(),V(!1),tt&&Ke()},onPromptDragEnter:xi,onPromptDragOver:bi,onPromptDragLeave:vi,onPromptDrop:ki,onGoalTokenBudgetChange:Ol,onCancelGoal:xa,onShellPromptChange:li});return t.jsx(fm,{activeView:e,layerClassName:Ti,formClassName:Ei,shellClassName:Li,inputGroupClassName:Fi,error:s,followTail:j,photoInputRef:fe,fileInputRef:De,onAppendAttachments:fn,onToggleFollow:ye,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:Ce,onJumpToNextTurn:Le,subscriptionUsage:X,onSubmit:pi,formRef:Te,promptSlot:Wi,toolbarSlot:t.jsx(Lm,{...Oi}),goalSlot:Ui,shellPromptSlot:Vi})}var Jm=c.createContext(null);function dl(){return c.useContext(Jm)}function xt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Wt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function Qm(e){switch(e){case"idle":return"Idle";case"running":return"Running";case"interrupted":return"Interrupted";case"failed":return"Failed";case"not_loaded":return"Not Loaded";case"system_error":return"System Error"}}function ep(e){switch(e){case"idle":return"ui-status-neutral";case"running":return"ui-status-info";case"interrupted":return"ui-status-warning";case"failed":case"system_error":return"ui-status-danger";case"not_loaded":return"ui-status-neutral"}}function cl(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function tp({open:e,title:r,label:n,value:a,busy:o=!1,onChange:s,onCancel:l,onSubmit:i}){if(c.useEffect(()=>{if(!e)return;function h(u){u.key==="Escape"&&!o&&l()}return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[o,l,e]),!e)return null;function d(h){h.preventDefault(),i()}return Zr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close rename dialog",onClick:l,disabled:o,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("form",{role:"dialog","aria-modal":"true","aria-label":r,onSubmit:d,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-1 text-sm text-stone-500",children:"Changes are saved only after confirmation."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:l,disabled:o,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5",children:[t.jsx("label",{htmlFor:"rename-dialog-input",className:"text-sm font-medium text-stone-200",children:n}),t.jsx("input",{id:"rename-dialog-input","aria-label":n,autoFocus:!0,value:a,onChange:h=>s(h.target.value),className:"mt-2 w-full rounded-2xl border border-stone-700 bg-stone-950 px-4 py-3 text-stone-100 outline-none transition focus:border-amber-300"})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:l,disabled:o,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:o||!a.trim(),className:"ui-action-success rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:"Save"})]})]})]}),document.body)}function rp({children:e,effectiveTheme:r,layoutMode:n,themeMode:a,viewportConstrained:o}){return t.jsx("div",{className:`thread-ui-shell ${r==="dark"?"thread-ui-theme-dark dark":""} ${o?"thread-ui-viewport-constrained":""} ${o?"h-[100svh] max-h-[100svh] min-h-0 overflow-hidden overscroll-none":"min-h-[100svh] overflow-hidden"} bg-[#f6f8fb] text-slate-900 transition-colors duration-200 sm:p-2`,"data-theme-effective":r,"data-theme-mode":a??r,"data-thread-layout":n,children:e})}function np({children:e,roomsRailCollapsed:r}){return t.jsx("div",{className:`thread-shell-frame relative h-full min-h-0 ${r?"is-rail-collapsed sm:grid-cols-[56px_minmax(0,1fr)]":"sm:grid-cols-[264px_minmax(0,1fr)]"}`,children:e})}function ap({onClose:e,open:r}){return r?t.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,className:"thread-mobile-only-block thread-mobile-scrim fixed inset-0 z-40 bg-slate-950/35 backdrop-blur-[1px]",onClick:e}):null}function sp({children:e,collapsed:r,mobileOpen:n}){return t.jsx("aside",{className:`thread-graph-rooms-surface thread-rooms-rail fixed inset-y-0 left-0 z-50 flex min-h-0 min-w-0 w-[min(20rem,calc(100vw-2rem))] flex-col overflow-x-hidden border-r border-slate-200/80 bg-white shadow-[0_20px_50px_rgba(15,23,42,0.18)] transition-transform duration-200 ease-out sm:static sm:z-auto sm:w-auto sm:translate-x-0 sm:rounded-[12px] sm:border sm:shadow-[0_10px_30px_rgba(15,23,42,0.04)] ${n?"translate-x-0":"pointer-events-none -translate-x-full sm:pointer-events-auto"} ${r?"thread-ui-rail-collapsed sm:items-center":""}`,style:{paddingTop:"var(--android-safe-area-top, 0px)"},children:e})}function op({children:e}){return t.jsx("main",{className:"thread-shell-main h-full min-h-0 min-w-0 overflow-hidden",children:t.jsx("div",{className:"thread-main-panel thread-shell-card flex h-full min-h-0 flex-col overflow-hidden bg-white shadow-[0_10px_30px_rgba(15,23,42,0.04)] sm:rounded-[12px] sm:border sm:border-slate-200/80",children:e})})}function lp({children:e}){return t.jsx("div",{className:"thread-topbar-surface flex shrink-0 flex-col border-b border-slate-200 bg-white pt-[env(safe-area-inset-top)] sm:pt-0",children:e})}function ip({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}zo();Pt();function us({...e}){return t.jsx(Qi,{"data-slot":"dialog",...e})}function ms({...e}){return t.jsx(ed,{"data-slot":"dialog-trigger",...e})}function dp({...e}){return t.jsx(sd,{"data-slot":"dialog-portal",...e})}function cp({className:e,...r}){return t.jsx(od,{"data-slot":"dialog-overlay",className:rt("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...r})}function ps({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(dp,{"data-slot":"dialog-portal",children:[t.jsx(cp,{}),t.jsxs(td,{"data-slot":"dialog-content",className:rt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",r),...a,children:[e,n?t.jsxs(rd,{"data-slot":"dialog-close",className:"absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx(B.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function fs({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:rt("flex flex-col gap-2 text-center sm:text-left",e),...r})}function gs({className:e,...r}){return t.jsx(nd,{"data-slot":"dialog-title",className:rt("text-lg font-semibold leading-none",e),...r})}function xs({className:e,...r}){return t.jsx(ad,{"data-slot":"dialog-description",className:rt("text-sm text-muted-foreground",e),...r})}var hp=[{value:"system",label:"Follow system",icon:B.Monitor},{value:"dark",label:"Dark",icon:B.Moon},{value:"light",label:"Light",icon:B.Sun}];function up({thread:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:o,getThreadHref:s,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,showDeleteButton:h=!1,showSessionCopyButton:u=!1,collapsed:m=!1}){const[f,p]=c.useState("idle"),g=c.useRef(null),b=a[e.workspaceId],v=b&&!n?b:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function j(){const N=e.providerSessionId;if(N)try{await navigator.clipboard.writeText(N),p("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1200)}catch{p("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1600)}}const w=()=>o(e.id),y=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${x?"is-active":""} ${m?"justify-center px-2 py-2":"px-3 py-2.5"}`,k=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`thread-graph-room-card-icon flex h-8 w-8 shrink-0 items-center justify-center rounded-full ${x?"is-active":""}`,children:t.jsx(B.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${m?"thread-desktop-collapsed-hidden":""}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("p",{className:"thread-graph-room-card-title min-w-0 flex-1 truncate text-sm font-medium",title:e.title,children:e.title}),i&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),i(e)},"aria-label":`Rename thread ${e.title}`,title:"Rename thread",className:"thread-card-quiet-button inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(B.Pencil,{className:"h-3 w-3"})}):null,u&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:f==="copied"?"Copied":f==="failed"?"Copy failed":"Copy session ID",onClick:N=>{N.stopPropagation(),N.preventDefault(),j()},className:"thread-card-quiet-button thread-card-session-copy-button inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(B.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[v?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:v,children:v}):t.jsx("span",{className:"min-w-0 flex-1","aria-hidden":"true"}),t.jsx("span",{className:`shrink-0 rounded-full border px-1.5 py-0.5 text-[9px] uppercase tracking-normal ${ep(e.status)}`,children:Qm(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:xt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),d(e)},"aria-label":`Delete thread ${e.title}`,className:"thread-card-danger-button shrink-0 rounded-full p-1 transition",title:"Delete thread",children:t.jsx(B.Trash2,{className:"h-3.5 w-3.5"})}):null]}),S=s==null?void 0:s(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:k,className:y,onClick:w})}):S?t.jsx("a",{href:S,onClick:N=>{N.preventDefault(),w()},title:m?e.title:void 0,className:y,children:k}):t.jsx("div",{role:"link",tabIndex:0,onClick:w,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),w())},title:m?e.title:void 0,className:y,children:k})}function mp({threads:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:o,getThreadHref:s,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,scrollable:h=!1,maxHeightClassName:u="max-h-full",showDeleteButton:m=!1,showSessionCopyButton:f=!1,collapsed:p=!1}){const g=h?`min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain pr-1 ${u}`:"";return t.jsx("div",{className:g,children:t.jsx("div",{className:"min-w-0 space-y-1",children:e.map(b=>t.jsx(up,{thread:b,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:o,showDeleteButton:m,showSessionCopyButton:f,collapsed:p,...s?{getThreadHref:s}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},b.id))})})}function pp({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:o=!1,layoutMode:s="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,currentThreadId:p,currentThreadLabel:g=null,currentWorkspaceId:b=null,currentWorkspaceLabel:v=null,sessionLabel:x=null,usageLabel:j=null,threadActionsButton:w,topbarActions:y,metaContent:k,settingsContent:S,globalSettingsContent:N,workspaceLabels:L={},workspaceReturnHref:R,onWorkspaceReturn:P,getThreadHref:J,onOpenThread:D,getNewThreadHref:Y,newThreadHref:Z,newThreadLabel:I="New Chat",onNewThread:re,onNewThreadTitle:oe,renderNewThreadDialogContent:$,renderThreadLink:Q,onCloseAppNavigation:_,onRenameThread:ee,onDeleteThread:W,workspaceContent:T,workspaceTitle:K="Workspace",workspaceActions:G,children:E}){const C=dl(),U=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:s==="mobile",[H,se]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),q=i??(C==null?void 0:C.themeMode)??"system",de=l??(C==null?void 0:C.effectiveTheme)??(q==="system"?H?"dark":"light":q),[te,be]=c.useState(!1),[ie,ye]=c.useState(!1),[Ae,ce]=c.useState(!U),[Ce,Le]=c.useState(U),[X,ue]=c.useState("chat"),[ve,ke]=c.useState(null),[_e,He]=c.useState(""),[$e,Ie]=c.useState(null),[F,le]=c.useState(!1),[we,z]=c.useState(""),[O,ne]=c.useState(!1),[ge,Te]=c.useState(!1),[Ee,fe]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const A=window.matchMedia("(max-width: 639px)"),pe=()=>{Le(A.matches)};return pe(),A.addEventListener("change",pe),()=>{A.removeEventListener("change",pe)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const A=window.matchMedia("(prefers-color-scheme: dark)"),pe=()=>{se(A.matches)};return pe(),A.addEventListener("change",pe),()=>{A.removeEventListener("change",pe)}},[]);const De=c.useMemo(()=>[...b?e.filter(pe=>pe.workspaceId===b):e].sort((pe,Re)=>{if(pe.id===p)return-1;if(Re.id===p)return 1;const Ge=Date.parse(pe.lastTurnStartedAt??pe.updatedAt);return Date.parse(Re.lastTurnStartedAt??Re.updatedAt)-Ge}),[p,b,e]),Be=Z??(Y==null?void 0:Y(b)),et=v??b??"all",Ve=x??g??p??"default_session",pt=j??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),nt=d??(C==null?void 0:C.setThemeMode),We=!!nt,ot=()=>{be(!1),_==null||_()};async function ht(A){if(!ee)return;const pe=_e.trim();if(pe){Ie(A);try{await ee(A,pe),ke(null),He("")}finally{Ie(null)}}}function ut(A){ke(A.id),He(A.title)}function M(){ke(null),He("")}function V(A){D==null||D(A),ot()}function xe(){le(!1),z("")}function je(A){if(!Be||!A.trim())return Be;try{const pe=new URL(Be,window.location.origin);return pe.searchParams.set("title",A.trim()),`${pe.pathname}${pe.search}${pe.hash}`}catch{const pe=Be.includes("?")?"&":"?";return`${Be}${pe}title=${encodeURIComponent(A.trim())}`}}async function Ne(){const A=we.trim();ne(!0);try{if(A&&oe){await oe(A),z(""),le(!1),ot();return}if(Be){window.location.assign(je(A)??Be);return}await(re==null?void 0:re()),z(""),le(!1),ot()}finally{ne(!1)}}function Ye(A,pe=!1){const Re=pe?t.jsxs(t.Fragment,{children:[t.jsx(B.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:I})]}):t.jsxs(t.Fragment,{children:[t.jsx(B.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:I})]});return t.jsxs(us,{open:F,onOpenChange:Ge=>{O||le(Ge)},children:[t.jsx(ms,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":pe?I:void 0,title:I,className:A,children:Re})}),t.jsx(ps,{"data-testid":"create-thread-dialog","data-theme-effective":de,"data-theme-mode":q,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:$?$({close:xe,closeNavigation:ot,currentWorkspaceId:b}):t.jsxs(t.Fragment,{children:[t.jsxs(fs,{children:[t.jsx(gs,{children:"Create New Chat"}),t.jsx(xs,{children:"Name the room so it is easy to find later."})]}),t.jsxs("div",{className:"grid gap-3",children:[t.jsx("input",{id:"thread-graph-create-thread-title",name:"thread-title",value:we,onChange:Ge=>z(Ge.target.value),onKeyDown:Ge=>{Ge.key==="Enter"&&(Ge.preventDefault(),Ne())},placeholder:"Chat name","aria-label":"Chat name",autoComplete:"off",className:"thread-graph-create-thread-input h-10 rounded-md border px-3 text-sm outline-none transition"}),t.jsx("button",{type:"button",onClick:()=>void Ne(),disabled:O,className:"thread-graph-create-thread-submit inline-flex h-10 items-center justify-center rounded-md px-4 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:O?"Creating...":"Create"})]})]})})]})}function tt(){if(!S&&!k&&!N&&!We)return null;const A=!!(S||k),pe=!!N,Re=A&&pe,Ge=Ee==="global"&&pe||!A&&pe?"global":"session";return t.jsxs(us,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(ms,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":"Open settings",title:"Settings",className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",children:t.jsx(B.Settings,{className:"h-4 w-4"})})}),t.jsxs(ps,{"data-testid":"settings-dialog","data-theme-effective":de,"data-theme-mode":q,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(fs,{children:[t.jsx(gs,{children:"Settings"}),t.jsx(xs,{children:"Manage this session and host-wide preferences."})]}),We?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-medium text-[var(--theme-fg)]",children:"Appearance"}),t.jsxs("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:["Current theme: ",de]})]}),t.jsx("div",{className:"thread-graph-theme-mode-group grid grid-cols-3 gap-1 rounded-lg border p-1",role:"group","aria-label":"Theme mode",children:hp.map(Ue=>{const ct=Ue.icon,kt=q===Ue.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ue.value}`,"aria-pressed":kt,disabled:!We,onClick:()=>nt==null?void 0:nt(Ue.value),className:`thread-graph-theme-mode-button inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md px-2 text-xs font-medium transition ${kt?"is-selected":""}`,children:[t.jsx(ct,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ue.label})]},Ue.value)})})]})}):null,Re?t.jsxs("div",{className:"thread-graph-settings-tabs grid grid-cols-2 gap-1 rounded-lg border p-1",children:[t.jsx("button",{type:"button","aria-pressed":Ge==="session",onClick:()=>fe("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ge==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Ge==="global",onClick:()=>fe("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ge==="global"?"is-active":""}`,children:"Global"})]}):null,t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Ge==="session"?t.jsxs("div",{className:"grid gap-4",children:[S?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:S}):null,k?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:k}):null,A?null:t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3 text-[var(--theme-fg-muted)]",children:"No session settings are available."})]}):t.jsx("div",{className:"thread-graph-settings-global-content",children:N})})]})]})}function Fe(A=!1){return t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:`mb-3 flex items-center gap-2 px-2 text-xs font-medium tracking-normal text-[var(--theme-fg-muted)] ${A?"justify-center":""}`,children:[t.jsx(B.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:A?"sr-only":"",children:"Rooms"}),!A&&n?t.jsx("span",{className:"ml-auto text-xs text-[var(--theme-fg-muted)]",children:"Refreshing..."}):null]}),t.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto px-1",children:[a?t.jsx("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/10 px-3 py-3 text-sm text-rose-900 dark:text-rose-100",children:a}):null,!a&&De.length===0&&!n?t.jsx("div",{className:"rounded-xl border border-dashed border-[var(--theme-border)] bg-[var(--theme-surface)] px-4 py-6 text-sm text-[var(--theme-fg-muted)]",children:"No threads available in this view."}):null,De.length>0?t.jsx(mp,{threads:De,currentThreadId:p,currentWorkspaceId:b,workspaceLabels:L,onOpenThread:V,collapsed:A,...ee?{onBeginRenameThread:ut}:{},showDeleteButton:!!W,...J?{getThreadHref:J}:{},...Q?{renderThreadLink:Q}:{},...W?{onDeleteThread:W}:{}}):null]})]})})}function Ke(){return T?t.jsxs("div",{className:"thread-workspace-panel relative flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(B.ChevronsRight,{className:"h-4 w-4"})}),G?t.jsx("div",{className:"pointer-events-none absolute right-12 top-2 z-20 flex items-center gap-1",children:t.jsx("div",{className:"pointer-events-auto",children:G})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T})]}):t.jsxs("div",{className:"thread-workspace-panel flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsxs("div",{className:"thread-workspace-panel-header flex h-12 shrink-0 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 sm:h-[60px] sm:px-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-base font-semibold text-[var(--theme-fg)] sm:text-[18px]",children:K}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:v??b??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[G,t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(B.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T??t.jsxs("div",{className:"grid h-full min-h-0 gap-3 overflow-y-auto p-3 text-sm text-[var(--theme-fg-soft)]",children:[t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Runtime"}),t.jsx("p",{className:"mt-2 text-[var(--theme-fg)]",children:(r==null?void 0:r.state)??"unknown"})]}),t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Workspace"}),t.jsx("p",{className:"mt-2 break-words text-[var(--theme-fg)]",children:v??b??"All threads"})]})]})})]})}const lt=!!T,vt=s==="mobile"||s==="responsive"&&Ce,it=vt,Nt=it&&!te,Ct=!!(R||P)?t.jsx("a",{href:R??"#",onClick:A=>{P&&(A.preventDefault(),P())},className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",title:"Back to workspace","aria-label":"Back to workspace",children:t.jsx(B.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(rp,{effectiveTheme:de,layoutMode:s,themeMode:q,viewportConstrained:o,children:t.jsxs(np,{roomsRailCollapsed:ie,children:[t.jsx(ap,{open:te,onClose:()=>be(!1)}),t.jsxs(sp,{collapsed:ie,mobileOpen:te,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-2 sm:h-16 sm:items-center sm:pb-0 ${ie?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${ie?"sm:justify-center":"justify-between"}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>ye(A=>!A),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:ie?"Expand rooms":"Collapse rooms","aria-label":ie?"Expand rooms":"Collapse rooms",children:ie?t.jsx(B.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(B.PanelLeftClose,{className:"h-4 w-4"})}),t.jsx("div",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[var(--theme-accent-solid)] text-sm font-semibold text-[var(--theme-accent-solid-fg)] ${ie?"thread-desktop-collapsed-hidden":""}`,children:(v??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${ie?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:v??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:b??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${ie?"thread-desktop-collapsed-hidden":""}`,children:[tt(),Ct,t.jsx("button",{type:"button",onClick:()=>be(!1),"aria-label":"Close rooms",title:"Close rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:t.jsx(B.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${ie?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:Ye(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${ie?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,ie)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${ie?"w-full px-2 py-2":"px-3 py-3"}`,children:Fe(ie)})]}),t.jsxs(op,{children:[t.jsx(lp,{children:t.jsx("div",{className:"thread-topbar-row flex min-h-12 items-center px-3 py-1.5 sm:min-h-12 sm:px-4",children:t.jsxs("div",{className:"flex w-full items-center justify-between gap-3 sm:gap-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:gap-3",children:[Nt?t.jsx("button",{type:"button",onClick:()=>be(!0),"aria-label":"Open rooms",title:"Open rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full",children:t.jsx(B.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"min-w-0 truncate text-sm font-semibold leading-tight text-[var(--theme-fg)] sm:text-base",title:g??"Shared Workspace",children:g??"Shared Workspace"}),t.jsxs("div",{className:"relative mt-0.5 flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Te(A=>!A)},"aria-expanded":ge,"aria-haspopup":"dialog",className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-1 text-left text-[11px] leading-none sm:text-xs",title:"Session and usage",children:[t.jsx("span",{className:"shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:et})]}),ge?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(28rem,calc(100vw-1.5rem))] rounded-lg border p-2.5 shadow-lg",role:"dialog","aria-label":"Session and usage",children:[t.jsxs("button",{type:"button",onClick:()=>{var A;Ve&&((A=navigator.clipboard)==null||A.writeText(Ve))},className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-2 text-left text-xs leading-5",title:"Copy session ID",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Session"}),t.jsx("span",{className:"truncate font-mono",children:Ve})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-center gap-2 text-xs leading-5",title:"Session token usage and estimated cost",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Usage"}),t.jsx("span",{className:"truncate font-mono",children:pt})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[w||y?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[w,y]}):null,it&&w?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:w}):null,it&<?t.jsx("button",{type:"button",onClick:()=>ue(A=>A==="workspace"?"chat":"workspace"),"aria-label":X==="workspace"?"Show chat":"Show workspace",title:X==="workspace"?"Show chat":"Show workspace",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:X==="workspace"?t.jsx(B.MessageSquare,{className:"h-4 w-4"}):t.jsx(B.Folder,{className:"h-4 w-4"})}):null,it?f:null,it&&h?Ye("thread-secondary-action inline-flex h-10 items-center justify-center gap-2 rounded-lg border px-3 text-sm font-medium sm:h-9"):null]})]})})}),t.jsx(ip,{children:lt&&!Ae?vt?t.jsxs("div",{className:"thread-split-container thread-graph-shell-mobile-split h-full min-h-0 overflow-hidden",children:[t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${X==="chat"?"block":"thread-mobile-chat-hidden"}`,children:E}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${X==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:Ke()})]}):t.jsxs(An,{direction:"horizontal",className:"thread-split-container thread-graph-shell-resizable thread-graph-shell-desktop-split h-full min-h-0 overflow-hidden",children:[t.jsx(sr,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:E}),t.jsx($n,{className:"thread-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(sr,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:Ke()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[lt&&Ae?t.jsx("button",{type:"button",onClick:()=>ce(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(B.ChevronsLeft,{className:"h-4 w-4"})}):null,E]})})]})]})}),t.jsx(tp,{open:ve!==null,title:"Rename Thread",label:"Thread Title",value:_e,busy:$e!==null,onChange:He,onCancel:M,onSubmit:()=>ve?ht(ve):void 0})]})}function fp({open:e,title:r,text:n,onClose:a}){return c.useEffect(()=>{if(!e)return;function o(s){s.key==="Escape"&&a()}return window.addEventListener("keydown",o),()=>{window.removeEventListener("keydown",o)}},[a,e]),e?Zr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[90] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close full text",onClick:a,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] flex max-h-[min(82vh,52rem)] w-full max-w-4xl flex-col overflow-hidden rounded-[1.8rem] border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-stone-800 px-4 py-3 sm:px-5",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:r}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:a,className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-4 sm:px-5",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-stone-200",children:n})})]})]}),document.body):null}var gp=[/^(?: {0,3})#{1,6}\s+\S/m,/^(?: {0,3})>{1,}\s*\S/m,/^(?: {0,3})(?:[-+*]|\d{1,9}[.)])\s+(?:\[[ xX]\]\s+)?\S/m,/^(?: {0,3})(?:```|~~~)/m,/^(?: {0,3})(?:[-*_]\s*){3,}$/m],xp=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,bp=/!?\[[^\]\n]+\]\([^)]+\)/,vp=/`[^`\n]+`/,kp=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,wp=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,yp=/~~[^~\n]+~~/;function jp(e){const r=e.trim();return r?gp.some(n=>n.test(r))||xp.test(r)?!0:/[`[\]*_~!]/.test(r)?bp.test(r)||vp.test(r)||kp.test(r)||wp.test(r)||yp.test(r):!1:!1}nn();function Kn(e,r){const n=new Map(r.map(s=>[s.id,s])),a=e.map(s=>{var l,i;return{...s.manifest,enabled:((l=n.get(s.manifest.id))==null?void 0:l.enabled)??!0,source:((i=n.get(s.manifest.id))==null?void 0:i.source)??"builtin"}}),o=new Set(e.map(s=>s.manifest.id));for(const s of r)o.has(s.id)||a.push(s);return a}function da(e=[]){const r=Kn(e,[]),n=e;return{plugins:r,loading:!1,error:null,async refresh(){},async importPluginManifest(){},async setPluginEnabled(){},async uninstallPlugin(){},renderArtifact:s=>{var i;const l=n.find(d=>d.renderArtifact&&d.manifest.capabilities.artifactTypes.some(h=>h.type===s.artifact.type));return((i=l==null?void 0:l.renderArtifact)==null?void 0:i.call(l,s))??null},renderInlineCode:s=>{for(const l of n)for(const i of l.inlineCodeRenderers??[]){if(!i.languages.includes(s.language.trim().toLowerCase()))continue;const d=i.render(s);if(d)return d}return null},hasRendererForArtifact:s=>n.some(l=>!!l.renderArtifact&&l.manifest.capabilities.artifactTypes.some(i=>i.type===s.type)),getThreadPanels:()=>n.flatMap(s=>s.threadPanels??[])}}var ca=c.createContext(da());function ha(){return c.useContext(ca)??da()}Lr();function hl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function bs(e){return hl(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function ul(e){return typeof e=="string"?t.jsxs("span",{className:"thread-graph-tool-string",children:['"',e,'"']}):typeof e=="number"?t.jsx("span",{className:"thread-graph-tool-number",children:e}):typeof e=="boolean"?t.jsx("span",{className:"thread-graph-tool-boolean",children:String(e)}):e===null?t.jsx("span",{className:"thread-graph-tool-null",children:"null"}):typeof e=="object"?t.jsx("span",{className:"thread-graph-tool-object",children:JSON.stringify(e)}):t.jsx("span",{children:String(e)})}function Np(e,r){return typeof r=="string"&&(e==="stdout"||e==="stderr"||e==="result")?t.jsx("pre",{className:"thread-graph-tool-output",children:r||"(empty)"}):typeof r=="object"&&r!==null?t.jsx("pre",{className:"thread-graph-tool-output",children:JSON.stringify(r,null,2)}):ul(r)}function vs({callId:e,toolName:r,status:n,parameters:a,result:o}){const s=c.useMemo(()=>{switch(n){case"completed":return{className:"is-completed",icon:t.jsx(B.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(B.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(B.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>bs(o),[o]),i=c.useMemo(()=>bs(a),[a]),d=c.useMemo(()=>typeof o=="string"?o.length>0:hl(o)?["stdout","stderr","result"].some(f=>{const p=o[f];return typeof p=="string"&&p.length>0}):!1,[o]),h=n==="pending"||d,[u,m]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&m("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(Sr,{type:"single",collapsible:!0,onValueChange:f=>m(f||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...u!==void 0?{value:u}:{},children:t.jsxs(Tr,{value:"item-1",className:"border-0",children:[t.jsx(an,{className:"thread-graph-tool-trigger px-4 py-3 hover:no-underline",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(B.Wrench,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:r}),t.jsxs("span",{className:`thread-graph-tool-badge ${s.className}`,title:s.label,"aria-label":`Status: ${s.label}`,children:[s.icon,t.jsx("span",{className:"thread-graph-status-label",children:s.label})]})]})}),t.jsxs(Er,{className:"thread-graph-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Parameters"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),i.length>0?i.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),ul(p),g<i.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)):t.jsx("div",{children:t.jsx("span",{className:"thread-graph-tool-null",children:"empty"})}),"}"]})]}),l.length>0?t.jsxs("section",{children:[t.jsx("h4",{children:"Result"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),l.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),Np(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var ks=null;function Cp(){return ks??(ks=Promise.all([Xe(()=>import("./core-DODVy7wn.js"),__vite__mapDeps([0,1,2])),Xe(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Xe(()=>import("./ayu-light-BA47KaF1.js"),[]),Xe(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Xe(()=>import("./javascript-wDzz0qaB.js"),[]),Xe(()=>import("./typescript-BPQ3VLAy.js"),[]),Xe(()=>import("./tsx-COt5Ahok.js"),[]),Xe(()=>import("./jsx-g9-lgVsj.js"),[]),Xe(()=>import("./python-B6aJPvgy.js"),[]),Xe(()=>import("./json-Cp-IABpG.js"),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Xe(()=>import("./yaml-Buea-lGh.js"),[]),Xe(()=>import("./toml-vGWfd6FD.js"),[]),Xe(()=>import("./markdown-Cvjx9yec.js"),[]),Xe(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Xe(()=>import("./css-CLj8gQPS.js"),[]),Xe(()=>import("./sql-CRqJ_cUM.js"),[]),Xe(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,o,s,l,i,d,h,u,m,f,p,g,b,v,x,j])=>e({engine:r(),themes:[n.default,a.default],langs:[o.default,s.default,l.default,i.default,d.default,h.default,u.default,m.default,f.default,p.default,g.default,b.default,v.default,x.default,j.default]}))),ks}function sn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function qn(e){if(!e)return{};if(sn(e)&&Object.prototype.hasOwnProperty.call(e,"0"))try{const r=Object.keys(e).map(Number).filter(n=>Number.isFinite(n)).sort((n,a)=>n-a).map(n=>String(e[String(n)]??"")).join("");return JSON.parse(r)}catch{return e}if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function Xn(){return{finalResult:null,stdout:"",stderr:""}}function Sp(e){return typeof e=="string"?{result:e}:e}function ml(e){const r=sn(e.finalResult)?{...e.finalResult}:e.finalResult!=null?{result:e.finalResult}:{};return e.stdout&&(r.stdout=e.stdout),e.stderr&&(r.stderr=e.stderr),!("status"in r)&&(e.stdout||e.stderr)&&(r.status="pending"),r}function ws(e){if(!e)return"pending";if(!sn(e))return"completed";const r=e.status;return r==="stream"||r==="pending"||r==="running"?"pending":r==="failed"||r==="error"||r==="timed_out"||typeof e.exit_code=="number"&&e.exit_code!==0?"failed":"completed"}function Tp(e){const r=new Map,n=/```tool-result\s*([\s\S]*?)\s*```/g,a=e.replace(n,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id;if(typeof h!="string")return l;const u=Sp(d.result),m=r.get(h)??Xn();return sn(u)&&u.status==="stream"&&typeof u.chunk=="string"?u.stream==="stderr"?m.stderr+=u.chunk:m.stdout+=u.chunk:m.finalResult=u,r.set(h,m),""}catch{return l}}),o=/```tool-call\s*([\s\S]*?)\s*```/g;return{processedContent:a.replace(o,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id,u=d.tool;if(typeof u!="string")return l;const m=qn(d.args);if(typeof h=="string"&&r.has(h)){const f=ml(r.get(h)??Xn());return`\`\`\`tool-merged
|