@codexhost/cli-win32-arm64 0.27.0 → 0.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +369 -163
- package/app/console-web.js +223 -9
- package/app/desktop-controller.mjs +105 -4
- package/app/host-runtime.mjs +1938 -1024
- package/app/plugins/antigravity/plugin.mjs +390 -135
- package/app/plugins/claude-code/plugin.mjs +383 -32
- package/app/plugins/codebuddy/plugin.mjs +213 -30
- package/app/plugins/codex-usage/plugin.mjs +370 -52
- package/app/plugins/copilot/plugin.mjs +105 -4
- package/app/plugins/cursor-cli/plugin.mjs +126 -4
- package/app/plugins/deepseek-harness/plugin.mjs +107 -4
- package/app/plugins/devin/plugin.mjs +106 -4
- package/app/plugins/grok/plugin.mjs +186 -25
- package/app/plugins/hermes/plugin.mjs +107 -4
- package/app/plugins/kimi-code/plugin.mjs +105 -4
- package/app/plugins/kiro-cli/plugin.mjs +105 -4
- package/app/plugins/omp/plugin.mjs +261 -45
- package/app/plugins/opencode/plugin.mjs +107 -4
- package/app/plugins/pi/plugin.mjs +312 -48
- package/app/plugins/qoder/plugin.mjs +179 -18
- package/app/plugins/qoder-cn/plugin.mjs +179 -18
- package/app/plugins/qwen-code/plugin.mjs +105 -4
- package/app/plugins/workbuddy/plugin.mjs +213 -30
- package/app/plugins/zcode/plugin.mjs +225 -85
- package/app/renderer-extension.js +11973 -11468
- package/app/web/assets/index-BJq8mT6r.js +204 -0
- package/app/web/assets/index-CMDliP5b.css +1 -0
- package/app/web/codexhost-settings.js +110 -49
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +65 -65
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +75 -75
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +72 -72
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +14 -14
- package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +5 -5
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.pdf.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
- package/app/web-modules/server.mjs +2494 -1132
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shell.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-D9l7_ThH.js +0 -199
- package/app/web/assets/index-nw2RXcDu.css +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-chat`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e},u=(e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule||!c.call(e,`default`)?i(n,`default`,{value:e,enumerable:!0}):n,e));let d=e("react");d=u(d,1);let f=e("react/jsx-runtime"),p=e("@deepseek-ai/dsh-client-ui-primitives"),m=e("@deepseek-ai/dsh-client-store"),h=e("react-dom"),g=`@deepseek-ai/dsh-client-ui-chat/ChangeStat.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(g)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=g,e.textContent=`._6NQHLq_stat{font-size:var(--dsh-change-stat-font-size,inherit);font-variant-numeric:tabular-nums;white-space:nowrap;gap:6px;display:inline-flex}._6NQHLq_added{color:var(--dsw-alias-state-success-primary)}._6NQHLq_removed{color:var(--dsw-alias-state-error-primary)}`,document.head.appendChild(e)}var _={added:`_6NQHLq_added`,removed:`_6NQHLq_removed`,stat:`_6NQHLq_stat`};function v({added:e,removed:t}){return/* @__PURE__ */ (0,f.jsxs)(`span`,{className:_.stat,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:_.added,children:`+${e}`}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:_.removed,children:`-${t}`})]})}let y=[],b={getSnapshot:()=>void 0,subscribe:()=>()=>{}};function x(e){let t=/* @__PURE__ */ new Map;for(let n of e){let{parentCallId:e,isError:r,meta:i}=n;if(e!==void 0||r===!0||!Array.isArray(i?.diffs))continue;let a=/* @__PURE__ */ new Map;for(let e of i.diffs)typeof e?.path==`string`&&a.set(e.path,[...a.get(e.path)??[],e]);for(let[e,n]of a)t.set(e,n)}return[...t].map(([e,t])=>({path:e,...(0,p.diffTotals)(t),hunks:t}))}function S(e,t,n){let r=n(`codexhostTurnChanges`,e=>t===void 0?void 0:e?.[t]),i=t===void 0||r!==void 0?b:e.turnDataSource(t,`tool-call`),a=(0,d.useSyncExternalStore)(i.subscribe,i.getSnapshot);return r===void 0?a===void 0?y:x(a.map(e=>e.root)):r}function C(e){return{added:e.reduce((e,t)=>e+t.added,0),removed:e.reduce((e,t)=>e+t.removed,0)}}function w(e){return e.split(/[\\/]/).at(-1)??e}let T=`@deepseek-ai/dsh-client-ui-chat/ChangesDock.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(T)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=T,e.textContent=`.iSRiBq_root{justify-content:center;margin-bottom:6px;display:flex}.iSRiBq_anchor{corner-shape:round;border-radius:16px;position:relative}.iSRiBq_anchor:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:2px}.iSRiBq_pill{border:1px solid var(--dsw-alias-border-l1);border-radius:inherit;corner-shape:round;color:var(--dsw-alias-label-tertiary);font-size:calc(var(--dsh-content-font-size-secondary,13px) + 2px);white-space:nowrap;--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) + 1px);--dsw-alias-state-success-primary:var(--dsw-alias-file-diff-added-marker);--dsw-alias-state-error-primary:var(--dsw-alias-file-diff-deleted-marker);background:0 0;align-items:center;gap:4px;padding:8px 12px;line-height:20px;display:inline-flex}.iSRiBq_list{corner-shape:round;background:var(--dsw-alias-button-floating-fill);box-shadow:var(--dsw-elevation-panel);color:var(--dsw-alias-label-primary);font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);white-space:nowrap;border-radius:12px;margin:0;padding:4px 12px;list-style:none;display:none;position:absolute;bottom:calc(100% + 6px);left:50%;transform:translate(-50%)}.iSRiBq_anchor:is(:hover,:focus-visible) .iSRiBq_list{display:block}.iSRiBq_file{justify-content:space-between;gap:16px;max-width:360px;padding:3px 0;display:flex}.iSRiBq_path{text-overflow:ellipsis;overflow:hidden}`,document.head.appendChild(e)}var E={anchor:`iSRiBq_anchor`,file:`iSRiBq_file`,list:`iSRiBq_list`,path:`iSRiBq_path`,pill:`iSRiBq_pill`,root:`iSRiBq_root`};let ee=(0,d.memo)(function({useChat:e,useSession:t,useProjection:n,t:r}){let i=t(e=>e.running),a=e(e=>e.nodes),o=e(e=>e.navigation.items().at(-1)?.turn),s=S(a,i?o:void 0,n);if(!i||s.length===0)return null;let{added:c,removed:l}=C(s);return/* @__PURE__ */ (0,f.jsx)(`div`,{className:E.root,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:E.anchor,tabIndex:0,children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:E.list,children:s.map(e=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:E.file,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:E.path,children:w(e.path)}),/* @__PURE__ */ (0,f.jsx)(v,{added:e.added,removed:e.removed})]},e.path))}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:E.pill,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:r(`chat.filesChanged`,{count:s.length})}),/* @__PURE__ */ (0,f.jsx)(v,{added:c,removed:l})]})]})})});function D(e){return encodeURIComponent(e).replace(/%3A/gi,`:`)}function O(e){return e.split(`/`).map(D).join(`/`)}function te(e,t){let n=t.replace(/\\/g,`/`).replace(/^(?:\.\/)+/,``);return`dsh-resource://file/session/${D(e)}/${O(n)}`}function ne(e){return/^[A-Za-z]:[/\\]/.test(e)||e.startsWith(`\\\\`)}function re(e){return e.startsWith(`/`)||ne(e)}function ie(e,t){if(re(t)||e===void 0||e===``)return t;let n=ne(e)&&e.includes(`\\`)?`\\`:`/`;return`${e.replace(/[/\\]+$/,``)}${n}${t.replace(/^[/\\]+/,``)}`}function ae(e,t,n){let r=n.replace(/\\/g,`/`);if(!re(r))return te(e,r);let i=t===void 0?``:t.replace(/\\/g,`/`).replace(/\/+$/,``);return i!==``&&r===i?te(e,``):i!==``&&r.startsWith(`${i}/`)?te(e,r.slice(i.length+1)):te(e,r)}function oe(e,t){if(!(!/^https?:/u.test(e)&&!e.startsWith(`dsh-app://app/`)||!re(t)||/^[/\\]{2}/u.test(t)||/[\u0000-\u001f\u007f]/u.test(t)))return new URL(`api/file?path=${encodeURIComponent(t)}`,e).href}let k=[],se={turnOrder:k,turns:/* @__PURE__ */ new Map},ce={getSnapshot:()=>void 0,subscribe:()=>()=>{}},le={getSnapshot:()=>void 0,subscribe:()=>()=>{}},ue={getSnapshot:()=>k,subscribe:()=>()=>{}},A={order:k,nodes:{get:()=>void 0,source:()=>ce,turnDataSource:()=>ue,processSource:()=>le,values:()=>k},locations:{getTurn:()=>k,getStep:()=>k},navigation:{items:()=>k},timeline:se,legacy:{nodes:k,turnTimings:/* @__PURE__ */ new Map,turnEnds:/* @__PURE__ */ new Map,partial:null,runningCalls:k}};function de(e){if(e!==void 0)try{let t=JSON.parse(e.argsRaw);return typeof t.command==`string`?t.command:void 0}catch{return}}function fe({callId:e,useChat:t}){return t(t=>{for(let n of t.nodes.values()){let t=n.kind===`tool-call`?n.data.root:void 0;if(t!==void 0&&t.callId===e&&!(`kind`in t)&&t.phase===`start`)return de(t)}})??null}function pe(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function me(e,t=`|`){return e.map(e=>Ve(e)).join(t)}function he(e,t){return typeof t==`bigint`?t.toString():t}var ge=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function _e(e){return new ge(e)}function ve(e){return e==null}function ye(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function be(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}let xe=/* @__PURE__*/ Symbol(`evaluating`);function Se(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==xe)return r===void 0&&(r=xe,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ce(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function we(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Te(e){return we(e._zod.def)??e._zod.def.shape}function Ee(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Ce(this,t,e),e},enumerable:!0,configurable:!0})}function De(e,t,n){t in e?Ce(e,t,n):e[t]=n}function Oe(e,t,n,r){let i=Te(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Ee(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):De(e,a,r?r(n.value,a):n.value))}}function ke(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Ee(e,n,()=>t[n]):De(e,n,r.value))}}function Ae(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function je(e){return JSON.stringify(e)}function Me(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let Ne=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Pe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let Fe=/* @__PURE__*/ _e(()=>{if(At.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Ie(e){if(Pe(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Pe(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Le(e){return Ie(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let Re=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function ze(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Be(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function j(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ve(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function He(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}let Ue={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},We={int64:[/* @__PURE__*/ BigInt(`-9223372036854775808`),/* @__PURE__*/ BigInt(`9223372036854775807`)],uint64:[/* @__PURE__*/ BigInt(0),/* @__PURE__*/ BigInt(`18446744073709551615`)]};function Ge(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return Oe(i,e,Ke(e,t)),Be(e,Ae(n,{shape:i,checks:[]}))}function Ke(e,t){let n=Te(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function qe(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Ke(e,t)),a={};return Oe(a,e,Reflect.ownKeys(Te(e)).filter(e=>!i.has(e))),Be(e,Ae(n,{shape:a,checks:[]}))}function Je(e,t){if(!Ie(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Te(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Be(e,Ae(e._zod.def,{shape:Ye(e,t)}))}function Ye(e,t){let n={};return Oe(n,e,Reflect.ownKeys(Te(e))),ke(n,t),n}function Xe(e,t){if(!Ie(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Be(e,Ae(e._zod.def,{shape:Ye(e,t)}))}function Ze(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return Oe(n,e,Reflect.ownKeys(Te(e))),Oe(n,t,Reflect.ownKeys(Te(t))),Be(e,Ae(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Qe(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Ke(t,n)):void 0,o={};return Oe(o,t,Reflect.ownKeys(Te(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),Be(t,Ae(t._zod.def,{shape:o,checks:[]}))}function $e(e,t,n){let r=n?new Set(Ke(t,n)):void 0,i={};return Oe(i,t,Reflect.ownKeys(Te(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),Be(t,Ae(t._zod.def,{shape:i}))}function et(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function tt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function nt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function rt(e){return typeof e==`string`?e:e?.message}function it(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function at(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function ot(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:rt(e.inst?._zod.def?.error?.(e))??rt(a?.(e))??rt(t?.error?.(e))??rt(n.customError?.(e))??rt(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}let st=/[\uD800-\uDBFF]/;function ct(e){let t=e.length;if(!st.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function lt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function ut(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function dt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function ft(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):gt(e,n,r.value)}}function pt(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function mt(e,t,n){return pt(e,t,n,!1)}function ht(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return pt(this,n,r(this))},set(e){pt(this,n,e)}})}return t}function gt(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:pt(this,t,n.bind(this))},set(e){pt(this,t,e)}})}function _t(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let vt,yt=!1,bt={configurable:!0,get(){yt=!0}};function M(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&vt!==e._zod?vt=void 0:(vt=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,bt);let e=yt;yt=!1;try{let r=n(this);return yt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),yt||=e,r}catch(n){throw delete this[t],yt||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function xt(e,t,n,r){let i=_t(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function St(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var Ct;let wt=/*@__PURE__*/ Object.freeze({status:`aborted`}),Tt={value:void 0,enumerable:!1},Et=`captureStackTrace`in Error?Error:null;function Dt(e){let t=Et;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Et=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function N(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=/* @__PURE__ */ new Set}a.prototype=i;let o=n,s=o&&/* @__PURE__ */ new WeakSet;function c(n,r){if(!n._zod){Tt.value=new a(r);try{Object.defineProperty(n,"_zod",Tt)}finally{Tt.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),ft(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Dt(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Ot=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},kt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Ct=globalThis).__zod_globalConfig??(Ct.__zod_globalConfig={});let At=globalThis.__zod_globalConfig;function jt(e){return e&&Object.assign(At,e),At}function Mt(){let e=this._zod;return e.message??=JSON.stringify(e.def,he,2),e.message}function Nt(e){this._zod.message=e}let Pt={get:Mt,set:Nt,enumerable:!0,configurable:!0},Ft={value:void 0,enumerable:!1},It=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),Lt=(e,t)=>{e.name=`$ZodError`,Ft.value=t,Object.defineProperty(e,"issues",Ft),Ft.value=void 0,Object.defineProperty(e,"message",Pt);let n=Object.getPrototypeOf(e);It.has(n)||(It.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Rt=N(`$ZodError`,Lt);N(`$ZodError`,Lt,void 0,{Parent:Error});function zt(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Bt(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?zt(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Vt(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Ht(e,t){return{callee:t?.callee??e,Err:t?.Err}}let Ut=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Ot;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>ot(e,o,jt())));throw Ne(n,a?.callee??t),n}return s.value};return t},Wt=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>ot(e,o,jt())));throw Ne(n,a?.callee??t),n}return s.value};return t},Gt=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Ot;return a.issues.length?Kt(e,a.issues,i):{success:!0,data:a.value}};function Kt(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>ot(e,n,jt()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}let qt=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Kt(e,a.issues,i):{success:!0,data:a.value}},Jt=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),Yt=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),Xt=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Jt)return!0;if(r.definite===!0&&n===void 0)return!1}return Zt(e,t,n)});function Zt(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Yt]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Ot;return a.issues.length===0}let Qt=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},$t=e=>{let t=Ut(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Ht(n,a))};return n},en=e=>{let t=Ut(e),n=(e,r,i,a)=>t(e,r,i,Ht(n,a));return n},tn=e=>{let t=Wt(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Ht(n,a))};return n},nn=e=>{let t=Wt(e),n=async(e,r,i,a)=>await t(e,r,i,Ht(n,a));return n},rn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Gt(e)(t,n,i)},an=e=>(t,n,r)=>Gt(e)(t,n,r),on=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return qt(e)(t,n,i)},sn=e=>async(t,n,r)=>qt(e)(t,n,r),cn=/^[cC][0-9a-z]{6,}$/,ln=/^[0-9a-z]+$/,un=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,dn=/^[0-9a-vA-V]{20}$/,fn=/^[A-Za-z0-9]{27}$/,pn=/^[a-zA-Z0-9_-]{21}$/;function mn(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}let hn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,_n=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,vn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function yn(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}let bn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,xn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Sn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Cn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,wn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Tn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,En=/^https?$/,Dn=/^\+[1-9]\d{6,14}$/,On=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function kn(e){return RegExp(`^${e}$`)}let An=/*@__PURE__*/ kn(On);function jn(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Mn(e){return RegExp(`^${jn(e)}$`)}function Nn(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${jn({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${jn({precision:e.precision})}`:n;return RegExp(`^${On}T(?:${r})$`)}let Pn=/^[\s\S]{0,}$/,Fn=/^-?\d+$/,In=/^-?\d+(?:\.\d+)?$/,Ln=/^(?:true|false)$/i,Rn=/^null$/i,zn=/^[^A-Z]*$/,Bn=/^[^a-z]*$/,Vn=/*@__PURE__*/ N(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Hn=e=>{let t=e.value;return!ve(t)&&t.length!==void 0},Un={number:`number`,bigint:`bigint`,object:`date`},Wn=/*@__PURE__*/ N(`$ZodCheckLessThan`,(e,t)=>{Vn.init(e,t);let n=Un[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Un[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Gn=/*@__PURE__*/ N(`$ZodCheckGreaterThan`,(e,t)=>{Vn.init(e,t);let n=Un[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Un[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Kn=/*@__PURE__*/ N(`$ZodCheckMultipleOf`,(e,t)=>{Vn.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):be(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),qn=/*@__PURE__*/ N(`$ZodCheckNumberFormat`,(e,t)=>{Vn.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Ue[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Jn=/*@__PURE__*/ N(`$ZodCheckMaxLength`,(e,t)=>{var n;Vn.init(e,t),(n=e._zod.def).when??(n.when=Hn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?ct(r):i)<=t.maximum)return;let a=lt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Yn=/*@__PURE__*/ N(`$ZodCheckMinLength`,(e,t)=>{var n;Vn.init(e,t),(n=e._zod.def).when??(n.when=Hn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?ct(r):i)>=t.minimum)return;let a=lt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Xn=/*@__PURE__*/ N(`$ZodCheckLengthEquals`,(e,t)=>{var n;Vn.init(e,t),(n=e._zod.def).when??(n.when=Hn),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?ct(r):i;if(a===t.length)return;let o=lt(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Zn=/*@__PURE__*/ N(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Vn.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Qn=/*@__PURE__*/ N(`$ZodCheckRegex`,(e,t)=>{Zn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),$n=/*@__PURE__*/ N(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=zn,Zn.init(e,t)}),er=/*@__PURE__*/ N(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Bn,Zn.init(e,t)}),tr=/*@__PURE__*/ N(`$ZodCheckIncludes`,(e,t)=>{Vn.init(e,t);let n=ze(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),nr=/*@__PURE__*/ N(`$ZodCheckStartsWith`,(e,t)=>{Vn.init(e,t);let n=RegExp(`^${ze(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),rr=/*@__PURE__*/ N(`$ZodCheckEndsWith`,(e,t)=>{Vn.init(e,t);let n=RegExp(`.*${ze(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),ir=/*@__PURE__*/ N(`$ZodCheckOverwrite`,(e,t)=>{Vn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var ar=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
1
|
+
window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-chat`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e},u=(e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule||!c.call(e,`default`)?i(n,`default`,{value:e,enumerable:!0}):n,e));let d=e("react");d=u(d,1);let f=e("react/jsx-runtime"),p=e("@deepseek-ai/dsh-client-ui-primitives"),m=e("@deepseek-ai/dsh-client-store"),h=e("react-dom"),g=`@deepseek-ai/dsh-client-ui-chat/ChangeStat.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(g)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=g,e.textContent=`._6NQHLq_stat{font-size:var(--dsh-change-stat-font-size,inherit);font-variant-numeric:tabular-nums;white-space:nowrap;gap:6px;display:inline-flex}._6NQHLq_added{color:var(--dsw-alias-state-success-primary)}._6NQHLq_removed{color:var(--dsw-alias-state-error-primary)}`,document.head.appendChild(e)}var _={added:`_6NQHLq_added`,removed:`_6NQHLq_removed`,stat:`_6NQHLq_stat`};function v({added:e,removed:t}){return/* @__PURE__ */ (0,f.jsxs)(`span`,{className:_.stat,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:_.added,children:`+${e}`}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:_.removed,children:`-${t}`})]})}let y=[],b={getSnapshot:()=>void 0,subscribe:()=>()=>{}};function x(e){let t=/* @__PURE__ */ new Map;for(let n of e){let{parentCallId:e,isError:r,meta:i}=n;if(e!==void 0||r===!0||!Array.isArray(i?.diffs))continue;let a=/* @__PURE__ */ new Map;for(let e of i.diffs)typeof e?.path==`string`&&a.set(e.path,[...a.get(e.path)??[],e]);for(let[e,n]of a)t.set(e,n)}return[...t].map(([e,t])=>({path:e,...(0,p.diffTotals)(t),hunks:t}))}function S(e,t,n){let r=n(`codexhostTurnChanges`,e=>t===void 0?void 0:e?.[t]),i=t===void 0||r!==void 0?b:e.turnDataSource(t,`tool-call`),a=(0,d.useSyncExternalStore)(i.subscribe,i.getSnapshot);return r===void 0?a===void 0?y:x(a.map(e=>e.root)):r}function C(e){return{added:e.reduce((e,t)=>e+t.added,0),removed:e.reduce((e,t)=>e+t.removed,0)}}function w(e){return e.split(/[\\/]/).at(-1)??e}let T=`@deepseek-ai/dsh-client-ui-chat/ChangesDock.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(T)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=T,e.textContent=`.iSRiBq_root{justify-content:center;margin-bottom:6px;display:flex}.iSRiBq_anchor{corner-shape:round;border-radius:16px;position:relative}.iSRiBq_anchor:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:2px}.iSRiBq_pill{border:1px solid var(--dsw-alias-border-l1);border-radius:inherit;corner-shape:round;color:var(--dsw-alias-label-tertiary);font-size:calc(var(--dsh-content-font-size-secondary,13px) + 2px);white-space:nowrap;--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) + 1px);--dsw-alias-state-success-primary:var(--dsw-alias-file-diff-added-marker);--dsw-alias-state-error-primary:var(--dsw-alias-file-diff-deleted-marker);background:0 0;align-items:center;gap:4px;padding:8px 12px;line-height:20px;display:inline-flex}.iSRiBq_list{corner-shape:round;background:var(--dsw-alias-button-floating-fill);box-shadow:var(--dsw-elevation-panel);color:var(--dsw-alias-label-primary);font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);white-space:nowrap;border-radius:12px;margin:0;padding:4px 12px;list-style:none;display:none;position:absolute;bottom:calc(100% + 6px);left:50%;transform:translate(-50%)}.iSRiBq_anchor:is(:hover,:focus-visible) .iSRiBq_list{display:block}.iSRiBq_file{justify-content:space-between;gap:16px;max-width:360px;padding:3px 0;display:flex}.iSRiBq_path{text-overflow:ellipsis;overflow:hidden}`,document.head.appendChild(e)}var E={anchor:`iSRiBq_anchor`,file:`iSRiBq_file`,list:`iSRiBq_list`,path:`iSRiBq_path`,pill:`iSRiBq_pill`,root:`iSRiBq_root`};let D=(0,d.memo)(function({useChat:e,useSession:t,useProjection:n,t:r}){let i=t(e=>e.running),a=e(e=>e.nodes),o=e(e=>e.navigation.items().at(-1)?.turn),s=S(a,i?o:void 0,n);if(!i||s.length===0)return null;let{added:c,removed:l}=C(s);return/* @__PURE__ */ (0,f.jsx)(`div`,{className:E.root,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:E.anchor,tabIndex:0,children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:E.list,children:s.map(e=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:E.file,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:E.path,children:w(e.path)}),/* @__PURE__ */ (0,f.jsx)(v,{added:e.added,removed:e.removed})]},e.path))}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:E.pill,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:r(`chat.filesChanged`,{count:s.length})}),/* @__PURE__ */ (0,f.jsx)(v,{added:c,removed:l})]})]})})});function O(e){return encodeURIComponent(e).replace(/%3A/gi,`:`)}function k(e){return e.split(`/`).map(O).join(`/`)}function ee(e,t){let n=t.replace(/\\/g,`/`).replace(/^(?:\.\/)+/,``);return`dsh-resource://file/session/${O(e)}/${k(n)}`}function te(e){return/^[A-Za-z]:[/\\]/.test(e)||e.startsWith(`\\\\`)}function A(e){return e.startsWith(`/`)||te(e)}function ne(e,t){if(A(t)||e===void 0||e===``)return t;let n=te(e)&&e.includes(`\\`)?`\\`:`/`;return`${e.replace(/[/\\]+$/,``)}${n}${t.replace(/^[/\\]+/,``)}`}function re(e,t,n){let r=n.replace(/\\/g,`/`);if(!A(r))return ee(e,r);let i=t===void 0?``:t.replace(/\\/g,`/`).replace(/\/+$/,``);return i!==``&&r===i?ee(e,``):i!==``&&r.startsWith(`${i}/`)?ee(e,r.slice(i.length+1)):ee(e,r)}function ie(e,t){if(!(!/^https?:/u.test(e)&&!e.startsWith(`dsh-app://app/`)||!A(t)||/^[/\\]{2}/u.test(t)||/[\u0000-\u001f\u007f]/u.test(t)))return new URL(`api/file?path=${encodeURIComponent(t)}`,e).href}let ae=[],oe={turnOrder:ae,turns:/* @__PURE__ */ new Map},se={getSnapshot:()=>void 0,subscribe:()=>()=>{}},ce={getSnapshot:()=>void 0,subscribe:()=>()=>{}},le={getSnapshot:()=>ae,subscribe:()=>()=>{}},ue={order:ae,nodes:{get:()=>void 0,source:()=>se,turnDataSource:()=>le,processSource:()=>ce,values:()=>ae},locations:{getTurn:()=>ae,getStep:()=>ae},navigation:{items:()=>ae},timeline:oe,legacy:{nodes:ae,turnTimings:/* @__PURE__ */ new Map,turnEnds:/* @__PURE__ */ new Map,partial:null,runningCalls:ae}};function de(e){if(e!==void 0)try{let t=JSON.parse(e.argsRaw);return typeof t.command==`string`?t.command:void 0}catch{return}}function j({callId:e,useChat:t}){return t(t=>{for(let n of t.nodes.values()){let t=n.kind===`tool-call`?n.data.root:void 0;if(t!==void 0&&t.callId===e&&!(`kind`in t)&&t.phase===`start`)return de(t)}})??null}function fe(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function pe(e,t=`|`){return e.map(e=>Be(e)).join(t)}function me(e,t){return typeof t==`bigint`?t.toString():t}var he=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function ge(e){return new he(e)}function _e(e){return e==null}function ve(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ye(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}let be=/* @__PURE__*/ Symbol(`evaluating`);function xe(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==be)return r===void 0&&(r=be,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Se(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ce(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function we(e){return Ce(e._zod.def)??e._zod.def.shape}function Te(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Se(this,t,e),e},enumerable:!0,configurable:!0})}function Ee(e,t,n){t in e?Se(e,t,n):e[t]=n}function De(e,t,n,r){let i=we(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Te(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Ee(e,a,r?r(n.value,a):n.value))}}function Oe(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Te(e,n,()=>t[n]):Ee(e,n,r.value))}}function ke(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ae(e){return JSON.stringify(e)}function je(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let Me=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let Pe=/* @__PURE__*/ ge(()=>{if(kt.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Fe(e){if(Ne(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Ne(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Ie(e){return Fe(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let Le=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function Re(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ze(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function M(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Be(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Ve(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}let He={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ue={int64:[/* @__PURE__*/ BigInt(`-9223372036854775808`),/* @__PURE__*/ BigInt(`9223372036854775807`)],uint64:[/* @__PURE__*/ BigInt(0),/* @__PURE__*/ BigInt(`18446744073709551615`)]};function We(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return De(i,e,Ge(e,t)),ze(e,ke(n,{shape:i,checks:[]}))}function Ge(e,t){let n=we(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Ke(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Ge(e,t)),a={};return De(a,e,Reflect.ownKeys(we(e)).filter(e=>!i.has(e))),ze(e,ke(n,{shape:a,checks:[]}))}function qe(e,t){if(!Fe(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=we(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ze(e,ke(e._zod.def,{shape:Je(e,t)}))}function Je(e,t){let n={};return De(n,e,Reflect.ownKeys(we(e))),Oe(n,t),n}function Ye(e,t){if(!Fe(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return ze(e,ke(e._zod.def,{shape:Je(e,t)}))}function Xe(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return De(n,e,Reflect.ownKeys(we(e))),De(n,t,Reflect.ownKeys(we(t))),ze(e,ke(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Ze(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Ge(t,n)):void 0,o={};return De(o,t,Reflect.ownKeys(we(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),ze(t,ke(t._zod.def,{shape:o,checks:[]}))}function Qe(e,t,n){let r=n?new Set(Ge(t,n)):void 0,i={};return De(i,t,Reflect.ownKeys(we(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),ze(t,ke(t._zod.def,{shape:i}))}function $e(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function et(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function tt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function nt(e){return typeof e==`string`?e:e?.message}function rt(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function it(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function at(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:nt(e.inst?._zod.def?.error?.(e))??nt(a?.(e))??nt(t?.error?.(e))??nt(n.customError?.(e))??nt(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}let ot=/[\uD800-\uDBFF]/;function st(e){let t=e.length;if(!ot.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function ct(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function lt(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function ut(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function dt(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):ht(e,n,r.value)}}function ft(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function pt(e,t,n){return ft(e,t,n,!1)}function mt(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return ft(this,n,r(this))},set(e){ft(this,n,e)}})}return t}function ht(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:ft(this,t,n.bind(this))},set(e){ft(this,t,e)}})}function gt(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let _t,vt=!1,yt={configurable:!0,get(){vt=!0}};function N(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&_t!==e._zod?_t=void 0:(_t=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,yt);let e=vt;vt=!1;try{let r=n(this);return vt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),vt||=e,r}catch(n){throw delete this[t],vt||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function bt(e,t,n,r){let i=gt(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function xt(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var St;let Ct=/*@__PURE__*/ Object.freeze({status:`aborted`}),wt={value:void 0,enumerable:!1},Tt=`captureStackTrace`in Error?Error:null;function Et(e){let t=Tt;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Tt=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function P(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=/* @__PURE__ */ new Set}a.prototype=i;let o=n,s=o&&/* @__PURE__ */ new WeakSet;function c(n,r){if(!n._zod){wt.value=new a(r);try{Object.defineProperty(n,"_zod",wt)}finally{wt.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),dt(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Et(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Dt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Ot=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(St=globalThis).__zod_globalConfig??(St.__zod_globalConfig={});let kt=globalThis.__zod_globalConfig;function At(e){return e&&Object.assign(kt,e),kt}function jt(){let e=this._zod;return e.message??=JSON.stringify(e.def,me,2),e.message}function Mt(e){this._zod.message=e}let Nt={get:jt,set:Mt,enumerable:!0,configurable:!0},Pt={value:void 0,enumerable:!1},Ft=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),It=(e,t)=>{e.name=`$ZodError`,Pt.value=t,Object.defineProperty(e,"issues",Pt),Pt.value=void 0,Object.defineProperty(e,"message",Nt);let n=Object.getPrototypeOf(e);Ft.has(n)||(Ft.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Lt=P(`$ZodError`,It);P(`$ZodError`,It,void 0,{Parent:Error});function Rt(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function zt(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Rt(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Bt(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Vt(e,t){return{callee:t?.callee??e,Err:t?.Err}}let Ht=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Dt;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>at(e,o,At())));throw Me(n,a?.callee??t),n}return s.value};return t},Ut=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>at(e,o,At())));throw Me(n,a?.callee??t),n}return s.value};return t},Wt=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Dt;return a.issues.length?Gt(e,a.issues,i):{success:!0,data:a.value}};function Gt(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>at(e,n,At()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}let Kt=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Gt(e,a.issues,i):{success:!0,data:a.value}},qt=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),Jt=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),Yt=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==qt)return!0;if(r.definite===!0&&n===void 0)return!1}return Xt(e,t,n)});function Xt(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Jt]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Dt;return a.issues.length===0}let Zt=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Qt=e=>{let t=Ht(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Vt(n,a))};return n},$t=e=>{let t=Ht(e),n=(e,r,i,a)=>t(e,r,i,Vt(n,a));return n},en=e=>{let t=Ut(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Vt(n,a))};return n},tn=e=>{let t=Ut(e),n=async(e,r,i,a)=>await t(e,r,i,Vt(n,a));return n},nn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Wt(e)(t,n,i)},rn=e=>(t,n,r)=>Wt(e)(t,n,r),an=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Kt(e)(t,n,i)},on=e=>async(t,n,r)=>Kt(e)(t,n,r),sn=/^[cC][0-9a-z]{6,}$/,cn=/^[0-9a-z]+$/,ln=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,un=/^[0-9a-vA-V]{20}$/,dn=/^[A-Za-z0-9]{27}$/,fn=/^[a-zA-Z0-9_-]{21}$/;function pn(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}let mn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,hn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,gn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,_n=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function vn(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}let yn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,bn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,xn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Sn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Cn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,wn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Tn=/^https?$/,En=/^\+[1-9]\d{6,14}$/,Dn=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function On(e){return RegExp(`^${e}$`)}let kn=/*@__PURE__*/ On(Dn);function An(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function jn(e){return RegExp(`^${An(e)}$`)}function Mn(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${An({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${An({precision:e.precision})}`:n;return RegExp(`^${Dn}T(?:${r})$`)}let Nn=/^[\s\S]{0,}$/,Pn=/^-?\d+$/,Fn=/^-?\d+(?:\.\d+)?$/,In=/^(?:true|false)$/i,Ln=/^null$/i,Rn=/^[^A-Z]*$/,zn=/^[^a-z]*$/,Bn=/*@__PURE__*/ P(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Vn=e=>{let t=e.value;return!_e(t)&&t.length!==void 0},Hn={number:`number`,bigint:`bigint`,object:`date`},Un=/*@__PURE__*/ P(`$ZodCheckLessThan`,(e,t)=>{Bn.init(e,t);let n=Hn[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Hn[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Wn=/*@__PURE__*/ P(`$ZodCheckGreaterThan`,(e,t)=>{Bn.init(e,t);let n=Hn[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Hn[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Gn=/*@__PURE__*/ P(`$ZodCheckMultipleOf`,(e,t)=>{Bn.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):ye(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Kn=/*@__PURE__*/ P(`$ZodCheckNumberFormat`,(e,t)=>{Bn.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=He[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),qn=/*@__PURE__*/ P(`$ZodCheckMaxLength`,(e,t)=>{var n;Bn.init(e,t),(n=e._zod.def).when??(n.when=Vn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?st(r):i)<=t.maximum)return;let a=ct(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Jn=/*@__PURE__*/ P(`$ZodCheckMinLength`,(e,t)=>{var n;Bn.init(e,t),(n=e._zod.def).when??(n.when=Vn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?st(r):i)>=t.minimum)return;let a=ct(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Yn=/*@__PURE__*/ P(`$ZodCheckLengthEquals`,(e,t)=>{var n;Bn.init(e,t),(n=e._zod.def).when??(n.when=Vn),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?st(r):i;if(a===t.length)return;let o=ct(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Xn=/*@__PURE__*/ P(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Bn.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Zn=/*@__PURE__*/ P(`$ZodCheckRegex`,(e,t)=>{Xn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Qn=/*@__PURE__*/ P(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Rn,Xn.init(e,t)}),$n=/*@__PURE__*/ P(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=zn,Xn.init(e,t)}),er=/*@__PURE__*/ P(`$ZodCheckIncludes`,(e,t)=>{Bn.init(e,t);let n=Re(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),tr=/*@__PURE__*/ P(`$ZodCheckStartsWith`,(e,t)=>{Bn.init(e,t);let n=RegExp(`^${Re(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),nr=/*@__PURE__*/ P(`$ZodCheckEndsWith`,(e,t)=>{Bn.init(e,t);let n=RegExp(`.*${Re(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),rr=/*@__PURE__*/ P(`$ZodCheckOverwrite`,(e,t)=>{Bn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var ir=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
2
2
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
3
|
-
`)}\n};`)(...Object.values(this.closed))}};let or={major:4,minor:6,patch:7},P=/*@__PURE__*/ N(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=or;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=et(t),a;for(let o of n){if(o._zod.def.when){if(tt(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Ot;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(at(t.issues,n,e),i||=et(t,n))});else{if(t.issues.length===n)continue;at(t.issues,n,e),i||=et(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(et(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Ot;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Ot;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return mt(this,`~standard`,lr(this))},set"~standard"(e){pt(this,`~standard`,e)}}),sr=(e,t)=>e.issues.length?{issues:e.issues.map(e=>ot(e,t,jt()))}:{value:e.value};async function cr(e,t){let n={async:!0};return sr(await e._zod.run({value:t,issues:[]},n),n)}function lr(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return sr(r,n)}catch{}return cr(e,t)},vendor:`zod`,version:1}}let ur=/*@__PURE__*/ N(`$ZodString`,(e,t)=>{P.init(e,t),e._zod.pattern=t.pattern??Pn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),F=/*@__PURE__*/ N(`$ZodStringFormat`,(e,t)=>{Zn.init(e,t),ur.init(e,t)}),dr=/*@__PURE__*/ N(`$ZodGUID`,(e,t)=>{t.pattern??=gn,F.init(e,t)}),fr=/*@__PURE__*/ N(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=_n(e)}else t.pattern??=_n();F.init(e,t)}),pr=/*@__PURE__*/ N(`$ZodEmail`,(e,t)=>{t.pattern??=vn,F.init(e,t)});function mr(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function hr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?mr(e)||2:gr(e,t)}function gr(e,t){if(!t.normalize&&t.protocol?.source===En.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}let _r=/[\t\n\r]/g;function vr(e){return e.replace(_r,``)}function yr(e,t){return t.lastIndex=0,t.test(e.hostname)}function br(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}let xr=/*@__PURE__*/ N(`$ZodURL`,(e,t)=>{F.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=hr(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=vr(r);return}t.hostname&&!yr(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!br(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:vr(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Sr=/*@__PURE__*/ N(`$ZodEmoji`,(e,t)=>{t.pattern??=yn(),F.init(e,t)}),Cr=/*@__PURE__*/ N(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?pn:mn(t.length),F.init(e,t)}),wr=/*@__PURE__*/ N(`$ZodCUID`,(e,t)=>{t.pattern??=cn,F.init(e,t)}),Tr=/*@__PURE__*/ N(`$ZodCUID2`,(e,t)=>{t.pattern??=ln,F.init(e,t)}),Er=/*@__PURE__*/ N(`$ZodULID`,(e,t)=>{t.pattern??=un,F.init(e,t)}),Dr=/*@__PURE__*/ N(`$ZodXID`,(e,t)=>{t.pattern??=dn,F.init(e,t)}),Or=/*@__PURE__*/ N(`$ZodKSUID`,(e,t)=>{t.pattern??=fn,F.init(e,t)}),kr=/*@__PURE__*/ N(`$ZodISODateTime`,(e,t)=>{t.pattern??=Nn(t),F.init(e,t)}),Ar=/*@__PURE__*/ N(`$ZodISODate`,(e,t)=>{t.pattern??=An,F.init(e,t)}),jr=/*@__PURE__*/ N(`$ZodISOTime`,(e,t)=>{t.pattern??=Mn(t),F.init(e,t)}),Mr=/*@__PURE__*/ N(`$ZodISODuration`,(e,t)=>{t.pattern??=hn,F.init(e,t)}),Nr=/*@__PURE__*/ N(`$ZodIPv4`,(e,t)=>{t.pattern??=bn,F.init(e,t)}),Pr=/^[0-9a-fA-F:.]+$/;function Fr(e){return Pr.test(e)?mr(`http://[${e}]`):!1}let Ir=/*@__PURE__*/ N(`$ZodIPv6`,(e,t)=>{t.pattern??=xn,F.init(e,t),e._zod.check=n=>{Fr(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Lr=/*@__PURE__*/ N(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Sn,F.init(e,t)});function Rr(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Fr(n)}let zr=/*@__PURE__*/ N(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Cn,F.init(e,t),e._zod.check=n=>{Rr(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Br(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let Vr=/^[0-9a-zA-Z+/]*={0,2}$/,Hr=/*@__PURE__*/ N(`$ZodBase64`,(e,t)=>{t.pattern??=Vr,F.init(e,t),e._zod.check=n=>{Br(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Ur=/^[A-Za-z0-9_-]*$/;function Wr(e){if(!Ur.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Br(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let Gr=/*@__PURE__*/ N(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ur,F.init(e,t),e._zod.check=n=>{Wr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Kr=/*@__PURE__*/ N(`$ZodE164`,(e,t)=>{t.pattern??=Dn,F.init(e,t)});function qr(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}let Jr=/*@__PURE__*/ N(`$ZodJWT`,(e,t)=>{F.init(e,t),e._zod.check=n=>{qr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Yr=/*@__PURE__*/ N(`$ZodNumber`,(e,t)=>{P.init(e,t),e._zod.pattern=In,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Xr=/*@__PURE__*/ N(`$ZodNumberFormat`,(e,t)=>{qn.init(e,t),Yr.init(e,t)}),Zr=/*@__PURE__*/ N(`$ZodBoolean`,(e,t)=>{P.init(e,t),e._zod.pattern=Ln,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Qr=/*@__PURE__*/ N(`$ZodNull`,(e,t)=>{P.init(e,t),e._zod.pattern=Rn,e._zod.values=/* @__PURE__ */ new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),$r=/*@__PURE__*/ N(`$ZodUnknown`,(e,t)=>{P.init(e,t),e._zod.parse=e=>e}),ei=/*@__PURE__*/ N(`$ZodNever`,(e,t)=>{P.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function ti(e,t){let n=it(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of it(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,at(n.issues,t,e),n}}return i(n,a)}}let ni=e=>Array.isArray(e)?e.length:-1;function ri(e,t,n){e.issues.length&&t.issues.push(...nt(n,e.issues)),t.value[n]=e.value}let ii=/*@__PURE__*/ N(`$ZodArray`,(e,t)=>{P.init(e,t);let n=At.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>ri(t,r,e)));else if(ri(c,r,e),s&&c.issues.length!==0&&et(c))break}return o.length?Promise.all(o).then(()=>r):r},ti(e,ni)});function ai(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...nt(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}let oi=[];function si(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:oi,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=He(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function ci(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(et(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ai(e,n,i,t,d,f))):ai(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}let li=/*@__PURE__*/ N(`$ZodObject`,(e,t)=>{P.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=_e(()=>si(t));M(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Ce(n,e,/* @__PURE__ */ new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=Pe,o=t.catchall,s,c=At.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(et(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>ai(n,t,e,r,a,o))):ai(s,t,e,r,a,o)}return o?ci(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),ui=/*@__PURE__*/ N(`$ZodObjectJIT`,(e,t)=>{li.init(e,t);let n=e._zod.parse,r=_e(()=>si(t)),i=At.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new ar([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
3
|
+
`)}\n};`)(...Object.values(this.closed))}};let ar={major:4,minor:6,patch:7},F=/*@__PURE__*/ P(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ar;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=$e(t),a;for(let o of n){if(o._zod.def.when){if(et(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Dt;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(it(t.issues,n,e),i||=$e(t,n))});else{if(t.issues.length===n)continue;it(t.issues,n,e),i||=$e(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if($e(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Dt;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Dt;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return pt(this,`~standard`,cr(this))},set"~standard"(e){ft(this,`~standard`,e)}}),or=(e,t)=>e.issues.length?{issues:e.issues.map(e=>at(e,t,At()))}:{value:e.value};async function sr(e,t){let n={async:!0};return or(await e._zod.run({value:t,issues:[]},n),n)}function cr(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return or(r,n)}catch{}return sr(e,t)},vendor:`zod`,version:1}}let lr=/*@__PURE__*/ P(`$ZodString`,(e,t)=>{F.init(e,t),e._zod.pattern=t.pattern??Nn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),I=/*@__PURE__*/ P(`$ZodStringFormat`,(e,t)=>{Xn.init(e,t),lr.init(e,t)}),ur=/*@__PURE__*/ P(`$ZodGUID`,(e,t)=>{t.pattern??=hn,I.init(e,t)}),dr=/*@__PURE__*/ P(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=gn(e)}else t.pattern??=gn();I.init(e,t)}),fr=/*@__PURE__*/ P(`$ZodEmail`,(e,t)=>{t.pattern??=_n,I.init(e,t)});function pr(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function mr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?pr(e)||2:hr(e,t)}function hr(e,t){if(!t.normalize&&t.protocol?.source===Tn.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}let gr=/[\t\n\r]/g;function _r(e){return e.replace(gr,``)}function vr(e,t){return t.lastIndex=0,t.test(e.hostname)}function yr(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}let br=/*@__PURE__*/ P(`$ZodURL`,(e,t)=>{I.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=mr(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=_r(r);return}t.hostname&&!vr(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!yr(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:_r(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),xr=/*@__PURE__*/ P(`$ZodEmoji`,(e,t)=>{t.pattern??=vn(),I.init(e,t)}),Sr=/*@__PURE__*/ P(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?fn:pn(t.length),I.init(e,t)}),Cr=/*@__PURE__*/ P(`$ZodCUID`,(e,t)=>{t.pattern??=sn,I.init(e,t)}),wr=/*@__PURE__*/ P(`$ZodCUID2`,(e,t)=>{t.pattern??=cn,I.init(e,t)}),Tr=/*@__PURE__*/ P(`$ZodULID`,(e,t)=>{t.pattern??=ln,I.init(e,t)}),Er=/*@__PURE__*/ P(`$ZodXID`,(e,t)=>{t.pattern??=un,I.init(e,t)}),Dr=/*@__PURE__*/ P(`$ZodKSUID`,(e,t)=>{t.pattern??=dn,I.init(e,t)}),Or=/*@__PURE__*/ P(`$ZodISODateTime`,(e,t)=>{t.pattern??=Mn(t),I.init(e,t)}),kr=/*@__PURE__*/ P(`$ZodISODate`,(e,t)=>{t.pattern??=kn,I.init(e,t)}),Ar=/*@__PURE__*/ P(`$ZodISOTime`,(e,t)=>{t.pattern??=jn(t),I.init(e,t)}),jr=/*@__PURE__*/ P(`$ZodISODuration`,(e,t)=>{t.pattern??=mn,I.init(e,t)}),Mr=/*@__PURE__*/ P(`$ZodIPv4`,(e,t)=>{t.pattern??=yn,I.init(e,t)}),Nr=/^[0-9a-fA-F:.]+$/;function Pr(e){return Nr.test(e)?pr(`http://[${e}]`):!1}let Fr=/*@__PURE__*/ P(`$ZodIPv6`,(e,t)=>{t.pattern??=bn,I.init(e,t),e._zod.check=n=>{Pr(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Ir=/*@__PURE__*/ P(`$ZodCIDRv4`,(e,t)=>{t.pattern??=xn,I.init(e,t)});function Lr(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Pr(n)}let Rr=/*@__PURE__*/ P(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Sn,I.init(e,t),e._zod.check=n=>{Lr(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function zr(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let Br=/^[0-9a-zA-Z+/]*={0,2}$/,Vr=/*@__PURE__*/ P(`$ZodBase64`,(e,t)=>{t.pattern??=Br,I.init(e,t),e._zod.check=n=>{zr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Hr=/^[A-Za-z0-9_-]*$/;function Ur(e){if(!Hr.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return zr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let Wr=/*@__PURE__*/ P(`$ZodBase64URL`,(e,t)=>{t.pattern??=Hr,I.init(e,t),e._zod.check=n=>{Ur(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Gr=/*@__PURE__*/ P(`$ZodE164`,(e,t)=>{t.pattern??=En,I.init(e,t)});function Kr(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}let qr=/*@__PURE__*/ P(`$ZodJWT`,(e,t)=>{I.init(e,t),e._zod.check=n=>{Kr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Jr=/*@__PURE__*/ P(`$ZodNumber`,(e,t)=>{F.init(e,t),e._zod.pattern=Fn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Yr=/*@__PURE__*/ P(`$ZodNumberFormat`,(e,t)=>{Kn.init(e,t),Jr.init(e,t)}),Xr=/*@__PURE__*/ P(`$ZodBoolean`,(e,t)=>{F.init(e,t),e._zod.pattern=In,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Zr=/*@__PURE__*/ P(`$ZodNull`,(e,t)=>{F.init(e,t),e._zod.pattern=Ln,e._zod.values=/* @__PURE__ */ new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Qr=/*@__PURE__*/ P(`$ZodUnknown`,(e,t)=>{F.init(e,t),e._zod.parse=e=>e}),$r=/*@__PURE__*/ P(`$ZodNever`,(e,t)=>{F.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function ei(e,t){let n=rt(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of rt(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,it(n.issues,t,e),n}}return i(n,a)}}let ti=e=>Array.isArray(e)?e.length:-1;function ni(e,t,n){e.issues.length&&t.issues.push(...tt(n,e.issues)),t.value[n]=e.value}let ri=/*@__PURE__*/ P(`$ZodArray`,(e,t)=>{F.init(e,t);let n=kt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>ni(t,r,e)));else if(ni(c,r,e),s&&c.issues.length!==0&&$e(c))break}return o.length?Promise.all(o).then(()=>r):r},ei(e,ti)});function ii(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...tt(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}let ai=[];function oi(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ai,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Ve(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function si(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if($e(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ii(e,n,i,t,d,f))):ii(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}let ci=/*@__PURE__*/ P(`$ZodObject`,(e,t)=>{F.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=ge(()=>oi(t));N(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Se(n,e,/* @__PURE__ */ new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=Ne,o=t.catchall,s,c=kt.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if($e(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>ii(n,t,e,r,a,o))):ii(s,t,e,r,a,o)}return o?si(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),li=/*@__PURE__*/ P(`$ZodObjectJIT`,(e,t)=>{ci.init(e,t);let n=e._zod.parse,r=ge(()=>oi(t)),i=kt.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new ir([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
4
4
|
let ${e}_ab = false;
|
|
5
5
|
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
6
6
|
const iss = ${e}.issues[i];
|
|
@@ -11,7 +11,7 @@ window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-chat`,factory:e=>{v
|
|
|
11
11
|
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
12
12
|
payload.value = newResult;
|
|
13
13
|
return payload;
|
|
14
|
-
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:
|
|
14
|
+
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:Ae(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
|
|
15
15
|
const ${n}_present = ${i};
|
|
16
16
|
if (!${n}.issues.length || ${n}_present) {
|
|
17
17
|
if (${n}.issues.length) {${c(n,r)}
|
|
@@ -50,82 +50,82 @@ window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-chat`,factory:e=>{v
|
|
|
50
50
|
newResult[${r}] = ${n}.value;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Pe,c=!At.jitless,l=c&&Fe.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?ci([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function di(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!et(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>ot(e,r,jt())))}),t)}let fi=/*@__PURE__*/ N(`$ZodUnion`,(e,t)=>{P.init(e,t),M(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),M(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),M(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),M(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>ye(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>di(t,r,e,i)):di(o,r,e,i)}});function pi(e){let t=/* @__PURE__ */ new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}let mi=/*@__PURE__*/ N(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,fi.init(e,t);let n=e._zod.parse;M(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||Ce(t,e,/* @__PURE__ */ new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=we(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=_e(()=>pi(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Pe(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),hi=/*@__PURE__*/ N(`$ZodIntersection`,(e,t)=>{P.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>_i(e,t,n)):_i(e,i,a)}});function gi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ie(e)&&Ie(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=gi(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=gi(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function _i(e,t,n){let r=/* @__PURE__ */ new Map,i,a=/* @__PURE__ */ new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=gi(t.value,n.value);if(!c.valid){if(et(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}let vi=/*@__PURE__*/ N(`$ZodTuple`,(e,t)=>{P.init(e,t);let n=t.items,r=At.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:`tuple`,code:`invalid_type`}),i;i.value=r?r.alloc(e,i,[],a):[];let s=[],c=yi(n,`optin`),l=yi(n,`optout`);if(!t.rest){if(o.length<c)return i.issues.push({code:`too_small`,minimum:c,inclusive:!0,input:o,inst:e,origin:`array`}),i;o.length>n.length&&i.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:o,inst:e,origin:`array`})}let u=Array(n.length),d=t.rest?a?.abortEarly:void 0,f=!1;for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:o[e],issues:[]},a);t instanceof Promise?s.push(t.then(t=>{u[e]=t})):(u[e]=t,d&&!f&&t.issues.length&&(f=et(t)))}if(t.rest&&!f){let e=n.length-1,r=o.slice(n.length),c=i.issues.length;for(let n of r){if(d&&i.issues.length!==c){if(et(i,c))break;c=i.issues.length}e++;let r=t.rest._zod.run({value:n,issues:[]},a);r instanceof Promise?s.push(r.then(t=>bi(t,i,e))):bi(r,i,e)}}return s.length?Promise.all(s).then(()=>xi(u,i,n,o,l)):xi(u,i,n,o,l)}});function yi(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function bi(e,t,n){e.issues.length&&t.issues.push(...nt(n,e.issues)),t.value[n]=e.value}function xi(e,t,n,r,i){for(let a=0;a<n.length;a++){let o=e[a],s=a<r.length;if(!s&&a>=i&&n[a]._zod.optin===`optional`){t.value.length=a;break}if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...nt(a,o.issues))}t.value[a]=o.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}let Si=/*@__PURE__*/ N(`$ZodRecord`,(e,t)=>{P.init(e,t);let n=At.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Ie(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=/* @__PURE__ */ new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>ot(e,i,jt())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...nt(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...nt(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&In.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>ot(e,i,jt())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...nt(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...nt(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Ci=/*@__PURE__*/ N(`$ZodEnum`,(e,t)=>{P.init(e,t);let n=pe(t.entries),r=new Set(n);e._zod.values=r,M(e,`pattern`,e=>{let t=pe(e.def.entries).filter(e=>Re.has(typeof e));return RegExp(t.length?`^(${t.map(e=>ze(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),wi=/*@__PURE__*/ N(`$ZodLiteral`,(e,t)=>{P.init(e,t);let n=new Set(t.values);e._zod.values=n,M(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?ze(e):e?ze(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Ti=/*@__PURE__*/ N(`$ZodTransform`,(e,t)=>{P.init(e,t),e._zod.optin=`optional`,At.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new kt(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Ot;return n.value=i,n}});function Ei(e,t){return e.value=t.issues.length?void 0:t.value,e}let Di=/*@__PURE__*/ N(`$ZodOptional`,(e,t)=>{P.init(e,t),M(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,M(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?/* @__PURE__ */ new Set([...t,void 0]):void 0}),M(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ye(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Ei(e,t)):Ei(e,r)}return t.innerType._zod.run(e,n)}}),Oi=/*@__PURE__*/ N(`$ZodExactOptional`,(e,t)=>{Di.init(e,t),M(e,`values`,e=>e.def.innerType._zod.values),M(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ki=/*@__PURE__*/ N(`$ZodNullable`,(e,t)=>{P.init(e,t),M(e,`optin`,e=>e.def.innerType._zod.optin),M(e,`optout`,e=>e.def.innerType._zod.optout),M(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ye(t.source)}|null)$`):void 0}),M(e,`values`,e=>e.def.innerType._zod.values?/* @__PURE__ */ new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ai=/*@__PURE__*/ N(`$ZodDefault`,(e,t)=>{P.init(e,t),e._zod.optin=`defaulted`,M(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>ji(e,t)):ji(r,t)}});function ji(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let Mi=/*@__PURE__*/ N(`$ZodPrefault`,(e,t)=>{P.init(e,t),e._zod.optin=`defaulted`,M(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ni=/*@__PURE__*/ N(`$ZodNonOptional`,(e,t)=>{P.init(e,t),M(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Pi(t,e)):Pi(i,e)}});function Pi(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Fi(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>ot(e,r,jt()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}let Ii=/*@__PURE__*/ N(`$ZodCatch`,(e,t)=>{P.init(e,t),M(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),M(e,`optout`,e=>e.def.innerType._zod.optout),M(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Fi(e,r,t,n)):Fi(e,r,t,n)}}),Li=/*@__PURE__*/ N(`$ZodPipe`,(e,t)=>{P.init(e,t),M(e,`values`,e=>e.def.in._zod.values),M(e,`optin`,e=>e.def.in._zod.optin),M(e,`optout`,e=>e.def.out._zod.optout),M(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Ri(e,t.in,n)):Ri(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ri(e,t.out,n)):Ri(r,t.out,n)}});function Ri(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}let zi=/*@__PURE__*/ N(`$ZodReadonly`,(e,t)=>{P.init(e,t),M(e,`propValues`,e=>e.def.innerType._zod.propValues),M(e,`values`,e=>e.def.innerType._zod.values),M(e,`optin`,e=>e.def.innerType?._zod?.optin),M(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Bi):Bi(r)}});function Bi(e){return e.memo||(e.value=Object.freeze(e.value)),e}let Vi=/*@__PURE__*/ N(`$ZodLazy`,(e,t)=>{P.init(e,t),Se(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),M(e,`pattern`,e=>e.innerType?._zod?.pattern),M(e,`propValues`,e=>e.innerType?._zod?.propValues),M(e,`optin`,e=>e.innerType?._zod?.optin??void 0),M(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Hi=/*@__PURE__*/ N(`$ZodCustom`,(e,t)=>{Vn.init(e,t),P.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Ui(t,n,r,e));Ui(i,n,r,e)}});function Ui(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(dt(e))}}var Wi=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};let Gi=`~memo`,Ki=[];function qi(e){return typeof e==`object`&&!!e}function Ji(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}let Yi=/*@__PURE__*/ new WeakMap;function Xi(e,t,n){let r=Yi.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=Xi(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?Xi(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=we(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Xi(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Zi(e,i)}function Zi(e,t){return t!==1&&Yi.set(e,t===2),t}function Qi(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */ new WeakMap,e.buckets.set(t,n)),n}let $i,ea=[],ta={alloc(e,t,n){let r=$i;if(!r)return n;$i=void 0;let i={value:n,issues:null};return r.set(t.value,i),ea.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&ra(n,e.value))throw new Wi;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Xi(e,/* @__PURE__ */ new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!qi(l))return t(s,c);let u=c[Gi];u||(u={buckets:/* @__PURE__ */ new WeakMap,backEdges:void 0},c[Gi]=u);let d;i===c?d=a:(d=Qi(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Ji(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=/* @__PURE__ */ new WeakSet),u.backEdges.add(f.value)),s;$i=d;let p=ea.length,m=t(s,c);$i=void 0;let h=ea.length>p?ea.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Ji(e.issues):Ki),e)):(h&&(h.issues=m.issues.length?Ji(m.issues):Ki),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function na(){return ta}function ra(e,t){let n=e[Gi]?.backEdges;return n!==void 0&&qi(t)&&n.has(t)}let ia=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(ut(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Ve(e.values[0])}`:`Invalid option: expected one of ${me(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${me(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function aa(){return{localeError:ia()}}var oa,sa=class{constructor(){this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ca(){return new sa}(oa=globalThis).__zod_globalRegistry??(oa.__zod_globalRegistry=ca());let la=globalThis.__zod_globalRegistry;function ua(e){return e.checks&&=[...e.checks],e}// @__NO_SIDE_EFFECTS__
|
|
54
|
-
function
|
|
55
|
-
function
|
|
56
|
-
function
|
|
57
|
-
function
|
|
58
|
-
function
|
|
59
|
-
function
|
|
60
|
-
function
|
|
61
|
-
function
|
|
62
|
-
function
|
|
63
|
-
function
|
|
64
|
-
function
|
|
65
|
-
function
|
|
66
|
-
function
|
|
67
|
-
function
|
|
68
|
-
function
|
|
69
|
-
function
|
|
70
|
-
function
|
|
71
|
-
function
|
|
72
|
-
function
|
|
73
|
-
function
|
|
74
|
-
function
|
|
75
|
-
function
|
|
76
|
-
function
|
|
77
|
-
function
|
|
78
|
-
function
|
|
79
|
-
function
|
|
80
|
-
function
|
|
81
|
-
function
|
|
82
|
-
function
|
|
83
|
-
function
|
|
84
|
-
function
|
|
85
|
-
function
|
|
86
|
-
function
|
|
87
|
-
function
|
|
88
|
-
function
|
|
89
|
-
function
|
|
90
|
-
function
|
|
91
|
-
function
|
|
92
|
-
function
|
|
93
|
-
function
|
|
94
|
-
function
|
|
95
|
-
function
|
|
96
|
-
function
|
|
97
|
-
function
|
|
98
|
-
function
|
|
99
|
-
function
|
|
100
|
-
function
|
|
101
|
-
function
|
|
102
|
-
function
|
|
103
|
-
function
|
|
104
|
-
function
|
|
105
|
-
function
|
|
106
|
-
function
|
|
107
|
-
function
|
|
108
|
-
function
|
|
109
|
-
function
|
|
110
|
-
function
|
|
111
|
-
function
|
|
53
|
+
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Ne,c=!kt.jitless,l=c&&Pe.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?si([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function ui(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!$e(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>at(e,r,At())))}),t)}let di=/*@__PURE__*/ P(`$ZodUnion`,(e,t)=>{F.init(e,t),N(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),N(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),N(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),N(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>ve(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>ui(t,r,e,i)):ui(o,r,e,i)}});function fi(e){let t=/* @__PURE__ */ new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}let pi=/*@__PURE__*/ P(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,di.init(e,t);let n=e._zod.parse;N(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||Se(t,e,/* @__PURE__ */ new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=Ce(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=ge(()=>fi(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Ne(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),mi=/*@__PURE__*/ P(`$ZodIntersection`,(e,t)=>{F.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>gi(e,t,n)):gi(e,i,a)}});function hi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Fe(e)&&Fe(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=hi(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=hi(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function gi(e,t,n){let r=/* @__PURE__ */ new Map,i,a=/* @__PURE__ */ new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=hi(t.value,n.value);if(!c.valid){if($e(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}let _i=/*@__PURE__*/ P(`$ZodTuple`,(e,t)=>{F.init(e,t);let n=t.items,r=kt.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:`tuple`,code:`invalid_type`}),i;i.value=r?r.alloc(e,i,[],a):[];let s=[],c=vi(n,`optin`),l=vi(n,`optout`);if(!t.rest){if(o.length<c)return i.issues.push({code:`too_small`,minimum:c,inclusive:!0,input:o,inst:e,origin:`array`}),i;o.length>n.length&&i.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:o,inst:e,origin:`array`})}let u=Array(n.length),d=t.rest?a?.abortEarly:void 0,f=!1;for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:o[e],issues:[]},a);t instanceof Promise?s.push(t.then(t=>{u[e]=t})):(u[e]=t,d&&!f&&t.issues.length&&(f=$e(t)))}if(t.rest&&!f){let e=n.length-1,r=o.slice(n.length),c=i.issues.length;for(let n of r){if(d&&i.issues.length!==c){if($e(i,c))break;c=i.issues.length}e++;let r=t.rest._zod.run({value:n,issues:[]},a);r instanceof Promise?s.push(r.then(t=>yi(t,i,e))):yi(r,i,e)}}return s.length?Promise.all(s).then(()=>bi(u,i,n,o,l)):bi(u,i,n,o,l)}});function vi(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function yi(e,t,n){e.issues.length&&t.issues.push(...tt(n,e.issues)),t.value[n]=e.value}function bi(e,t,n,r,i){for(let a=0;a<n.length;a++){let o=e[a],s=a<r.length;if(!s&&a>=i&&n[a]._zod.optin===`optional`){t.value.length=a;break}if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...tt(a,o.issues))}t.value[a]=o.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}let xi=/*@__PURE__*/ P(`$ZodRecord`,(e,t)=>{F.init(e,t);let n=kt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Fe(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=/* @__PURE__ */ new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>at(e,i,At())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...tt(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...tt(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Fn.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>at(e,i,At())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...tt(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...tt(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Si=/*@__PURE__*/ P(`$ZodEnum`,(e,t)=>{F.init(e,t);let n=fe(t.entries),r=new Set(n);e._zod.values=r,N(e,`pattern`,e=>{let t=fe(e.def.entries).filter(e=>Le.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Re(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Ci=/*@__PURE__*/ P(`$ZodLiteral`,(e,t)=>{F.init(e,t);let n=new Set(t.values);e._zod.values=n,N(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?Re(e):e?Re(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),wi=/*@__PURE__*/ P(`$ZodTransform`,(e,t)=>{F.init(e,t),e._zod.optin=`optional`,kt.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ot(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Dt;return n.value=i,n}});function Ti(e,t){return e.value=t.issues.length?void 0:t.value,e}let Ei=/*@__PURE__*/ P(`$ZodOptional`,(e,t)=>{F.init(e,t),N(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,N(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?/* @__PURE__ */ new Set([...t,void 0]):void 0}),N(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ve(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Ti(e,t)):Ti(e,r)}return t.innerType._zod.run(e,n)}}),Di=/*@__PURE__*/ P(`$ZodExactOptional`,(e,t)=>{Ei.init(e,t),N(e,`values`,e=>e.def.innerType._zod.values),N(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Oi=/*@__PURE__*/ P(`$ZodNullable`,(e,t)=>{F.init(e,t),N(e,`optin`,e=>e.def.innerType._zod.optin),N(e,`optout`,e=>e.def.innerType._zod.optout),N(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ve(t.source)}|null)$`):void 0}),N(e,`values`,e=>e.def.innerType._zod.values?/* @__PURE__ */ new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ki=/*@__PURE__*/ P(`$ZodDefault`,(e,t)=>{F.init(e,t),e._zod.optin=`defaulted`,N(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ai(e,t)):Ai(r,t)}});function Ai(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let ji=/*@__PURE__*/ P(`$ZodPrefault`,(e,t)=>{F.init(e,t),e._zod.optin=`defaulted`,N(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Mi=/*@__PURE__*/ P(`$ZodNonOptional`,(e,t)=>{F.init(e,t),N(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ni(t,e)):Ni(i,e)}});function Ni(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Pi(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>at(e,r,At()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}let Fi=/*@__PURE__*/ P(`$ZodCatch`,(e,t)=>{F.init(e,t),N(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),N(e,`optout`,e=>e.def.innerType._zod.optout),N(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Pi(e,r,t,n)):Pi(e,r,t,n)}}),Ii=/*@__PURE__*/ P(`$ZodPipe`,(e,t)=>{F.init(e,t),N(e,`values`,e=>e.def.in._zod.values),N(e,`optin`,e=>e.def.in._zod.optin),N(e,`optout`,e=>e.def.out._zod.optout),N(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Li(e,t.in,n)):Li(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Li(e,t.out,n)):Li(r,t.out,n)}});function Li(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}let Ri=/*@__PURE__*/ P(`$ZodReadonly`,(e,t)=>{F.init(e,t),N(e,`propValues`,e=>e.def.innerType._zod.propValues),N(e,`values`,e=>e.def.innerType._zod.values),N(e,`optin`,e=>e.def.innerType?._zod?.optin),N(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(zi):zi(r)}});function zi(e){return e.memo||(e.value=Object.freeze(e.value)),e}let Bi=/*@__PURE__*/ P(`$ZodLazy`,(e,t)=>{F.init(e,t),xe(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),N(e,`pattern`,e=>e.innerType?._zod?.pattern),N(e,`propValues`,e=>e.innerType?._zod?.propValues),N(e,`optin`,e=>e.innerType?._zod?.optin??void 0),N(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Vi=/*@__PURE__*/ P(`$ZodCustom`,(e,t)=>{Bn.init(e,t),F.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Hi(t,n,r,e));Hi(i,n,r,e)}});function Hi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(ut(e))}}var Ui=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};let Wi=`~memo`,Gi=[];function Ki(e){return typeof e==`object`&&!!e}function qi(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}let Ji=/*@__PURE__*/ new WeakMap;function Yi(e,t,n){let r=Ji.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=Yi(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?Yi(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Ce(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Yi(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Xi(e,i)}function Xi(e,t){return t!==1&&Ji.set(e,t===2),t}function Zi(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */ new WeakMap,e.buckets.set(t,n)),n}let Qi,$i=[],ea={alloc(e,t,n){let r=Qi;if(!r)return n;Qi=void 0;let i={value:n,issues:null};return r.set(t.value,i),$i.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&na(n,e.value))throw new Ui;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Yi(e,/* @__PURE__ */ new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!Ki(l))return t(s,c);let u=c[Wi];u||(u={buckets:/* @__PURE__ */ new WeakMap,backEdges:void 0},c[Wi]=u);let d;i===c?d=a:(d=Zi(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...qi(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=/* @__PURE__ */ new WeakSet),u.backEdges.add(f.value)),s;Qi=d;let p=$i.length,m=t(s,c);Qi=void 0;let h=$i.length>p?$i.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?qi(e.issues):Gi),e)):(h&&(h.issues=m.issues.length?qi(m.issues):Gi),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function ta(){return ea}function na(e,t){let n=e[Wi]?.backEdges;return n!==void 0&&Ki(t)&&n.has(t)}let ra=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(lt(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Be(e.values[0])}`:`Invalid option: expected one of ${pe(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${pe(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function ia(){return{localeError:ra()}}var aa,oa=class{constructor(){this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function sa(){return new oa}(aa=globalThis).__zod_globalRegistry??(aa.__zod_globalRegistry=sa());let ca=globalThis.__zod_globalRegistry;function la(e){return e.checks&&=[...e.checks],e}// @__NO_SIDE_EFFECTS__
|
|
54
|
+
function ua(e,t){return new e(la({type:`string`,...M(t)}))}// @__NO_SIDE_EFFECTS__
|
|
55
|
+
function da(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
56
|
+
function fa(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
57
|
+
function pa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
58
|
+
function ma(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
59
|
+
function ha(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
60
|
+
function ga(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
61
|
+
function _a(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
62
|
+
function va(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
63
|
+
function ya(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
64
|
+
function ba(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
65
|
+
function xa(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
66
|
+
function Sa(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
67
|
+
function Ca(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
68
|
+
function wa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
69
|
+
function Ta(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
70
|
+
function Ea(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
71
|
+
function Da(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
72
|
+
function Oa(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
73
|
+
function ka(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
74
|
+
function Aa(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
75
|
+
function ja(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
76
|
+
function Ma(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
77
|
+
function Na(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
78
|
+
function Pa(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
79
|
+
function Fa(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
80
|
+
function Ia(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
81
|
+
function La(e,t){return new e(la({type:`number`,checks:[],...M(t)}))}// @__NO_SIDE_EFFECTS__
|
|
82
|
+
function Ra(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
83
|
+
function za(e,t){return new e({type:`boolean`,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
84
|
+
function Ba(e,t){return new e({type:`null`,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
85
|
+
function Va(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
|
|
86
|
+
function Ha(e,t){return new e({type:`never`,...M(t)})}// @__NO_SIDE_EFFECTS__
|
|
87
|
+
function Ua(e,t){return new Un({check:`less_than`,...M(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
|
|
88
|
+
function Wa(e,t){return new Un({check:`less_than`,...M(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
|
|
89
|
+
function Ga(e,t){return new Wn({check:`greater_than`,...M(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
|
|
90
|
+
function Ka(e,t){return new Wn({check:`greater_than`,...M(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
|
|
91
|
+
function qa(e,t){return new Gn({check:`multiple_of`,...M(t),value:e})}// @__NO_SIDE_EFFECTS__
|
|
92
|
+
function Ja(e,t){return new qn({check:`max_length`,...M(t),maximum:e})}// @__NO_SIDE_EFFECTS__
|
|
93
|
+
function Ya(e,t){return new Jn({check:`min_length`,...M(t),minimum:e})}// @__NO_SIDE_EFFECTS__
|
|
94
|
+
function Xa(e,t){return new Yn({check:`length_equals`,...M(t),length:e})}// @__NO_SIDE_EFFECTS__
|
|
95
|
+
function Za(e,t){return new Zn({check:`string_format`,format:`regex`,...M(t),pattern:e})}// @__NO_SIDE_EFFECTS__
|
|
96
|
+
function Qa(e){return new Qn({check:`string_format`,format:`lowercase`,...M(e)})}// @__NO_SIDE_EFFECTS__
|
|
97
|
+
function $a(e){return new $n({check:`string_format`,format:`uppercase`,...M(e)})}// @__NO_SIDE_EFFECTS__
|
|
98
|
+
function eo(e,t){return new er({check:`string_format`,format:`includes`,...M(t),includes:e})}// @__NO_SIDE_EFFECTS__
|
|
99
|
+
function to(e,t){return new tr({check:`string_format`,format:`starts_with`,...M(t),prefix:e})}// @__NO_SIDE_EFFECTS__
|
|
100
|
+
function no(e,t){return new nr({check:`string_format`,format:`ends_with`,...M(t),suffix:e})}// @__NO_SIDE_EFFECTS__
|
|
101
|
+
function ro(e){return new rr({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
|
|
102
|
+
function io(e){return/* @__PURE__ */ ro(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
|
|
103
|
+
function ao(){return/* @__PURE__ */ ro(e=>e.trim())}// @__NO_SIDE_EFFECTS__
|
|
104
|
+
function oo(){return/* @__PURE__ */ ro(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
|
|
105
|
+
function so(){return/* @__PURE__ */ ro(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
|
|
106
|
+
function co(){return/* @__PURE__ */ ro(e=>je(e))}// @__NO_SIDE_EFFECTS__
|
|
107
|
+
function lo(e,t,n){return new e({type:`array`,element:t,...M(n)})}// @__NO_SIDE_EFFECTS__
|
|
108
|
+
function uo(e,t,n){let r=M(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}// @__NO_SIDE_EFFECTS__
|
|
109
|
+
function fo(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...M(n)})}// @__NO_SIDE_EFFECTS__
|
|
110
|
+
function po(e,t){let n=/* @__PURE__ */ mo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(ut(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(ut(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
|
|
111
|
+
function mo(e,t){let n=new Bn({check:`custom`,...M(t)});return n._zod.check=e,n}function ho(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Se(e,t,n[t]);return e}function go(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??ca,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function _o(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function vo(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,vo(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&ho(o.schema,c),t.io===`input`&&Oo(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function yo(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function bo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=/* @__PURE__ */ new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${yo(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+yo(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
112
112
|
|
|
113
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function xo(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;xo(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}let So=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),Co=[`oneOf`,`anyOf`];function wo(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function To(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!So.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??wo(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Ce(n,r,e.length===1?e[0]:To(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=wo(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Eo(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of So)if(t in e)return;let n=t.filter(e=>Co.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=To(t);else{let e=n[0],i=Co.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>To([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,go(e,r))}function Do(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):go(i,s),go(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())xo(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Eo(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}go(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Ce(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Ao(t,`input`,e.processors),output:Ao(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Oo(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Oo(r.element,n);if(r.type===`set`)return Oo(r.valueType,n);if(r.type===`lazy`)return Oo(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Oo(r.innerType,n);if(r.type===`intersection`)return Oo(r.left,n)||Oo(r.right,n);if(r.type===`record`||r.type===`map`)return Oo(r.keyType,n)||Oo(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Oo(r.in,n)||Oo(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Oo(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Oo(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Oo(e,n))return!0;return!!(r.rest&&Oo(r.rest,n))}return!1}let ko=(e,t={})=>n=>{let r=_o({...n,processors:t});return I(e,r),bo(r,e),Do(r,e)},Ao=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=_o({...i??{},target:a,io:t,processors:n});return I(e,o),bo(o,e),Do(o,e)},jo=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Mo=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},No=(e,t)=>{jo(e,`minimum`,t),Mo(e,`maximum`,t)},Po=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Fo=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},Io=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Lo=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Ro=(e,t)=>jo(e,`minimum`,t.minimum),zo=(e,t)=>Mo(e,`maximum`,t.maximum),Bo=e=>(t,n)=>{Lo(t,n.format);let[r,i]=e[n.format];jo(t,`minimum`,r),Mo(t,`maximum`,i)},Vo={greater_than:(e,t)=>jo(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Mo(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Po(e,t.value),number_format:Bo(Ue),bigint_format:Bo(We),min_length:Ro,max_length:zo,length_equals:(e,t)=>No(e,t.length),min_size:Ro,max_size:zo,size_equals:(e,t)=>No(e,t.size),string_format:(e,t)=>{Lo(e,t.format),t.pattern&&Fo(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Io(e,t.mime)};function Ho(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Vo[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&jo(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&jo(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Mo(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Mo(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Po(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Io(t,i.mime);for(let e of i.patterns??[])Fo(t,e);return t}let Uo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Wo=/* @__PURE__ */ new Map([[Vr,wn],[Ur,Tn]]),Go=e=>Wo.get(e)??e,Ko=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Ho(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Uo[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Go);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},qo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Ho(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):vo(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Jo=(e,t,n,r)=>{n.type=`boolean`},Yo=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Xo=(e,t,n,r)=>{n.not={}},Zo=(e,t,n,r)=>{let i=e._zod.def,a=pe(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Qo=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(vo(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(vo(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},$o=(e,t,n,r)=>{vo(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},es=(e,t,n,r)=>{vo(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},ts=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Ho(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=I(a.element,t,{...r,path:[...r.path,`items`]})};function ns(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ns(t.out):t.type===`catch`?ns(t.innerType):e._zod.optin}let rs=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&vo(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Ce(i.properties,e,I(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?ns(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=I(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},is=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>I(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},as=(e,t,n,r)=>{let i=e._zod.def,a=I(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=I(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},os=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>I(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?I(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?ns(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=Ho(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function ss(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=ss(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>ss(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?In:Fn).source)),p}let cs=/* @__PURE__ */ new WeakMap;function ls(e){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=/* @__PURE__ */ new Map;for(let r of cs.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=ss(t,a,/* @__PURE__ */ new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}let us=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Ho(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=I(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Ce(i.patternProperties,Go(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=I(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=cs.get(t);n||(n=[],cs.set(t,n),t.deferred.push(()=>ls(t))),n.push(e)}i.additionalProperties=I(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&ns(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},ds=(e,t,n,r)=>{let i=e._zod.def,a=I(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},fs=(e,t,n,r)=>{let i=e._zod.def;I(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ps=Symbol();function ms(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(vo(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),ps):JSON.parse(o)}let hs=(e,t,n,r)=>{let i=e._zod.def;I(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=ms(i.defaultValue,e,t,n,r);o!==ps&&(n.default=o)},gs=(e,t,n,r)=>{let i=e._zod.def;I(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=ms(i.defaultValue,e,t,n,r);o!==ps&&(n._prefault=o)},_s=(e,t,n,r)=>{let i=e._zod.def;I(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{vo(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},vs=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;I(o,t,r);let s=t.seen.get(e);s.ref=o},ys=(e,t,n,r)=>{let i=e._zod.def;I(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},bs=(e,t,n,r)=>{let i=e._zod.def;I(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xs=(e,t,n,r)=>{let i=e._zod.innerType;I(i,t,r);let a=t.seen.get(e);a.ref=i},Ss=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function Cs(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let ws=/*@__PURE__*/ N(`ZodError`,(e,t)=>{Rt.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Ss.has(n)||(Ss.add(n),Cs(n,`format`,e=>t=>Vt(e,t)),Cs(n,`flatten`,e=>t=>Bt(e,t)),Cs(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,he,2)}),Cs(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,he,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Ts=/* @__PURE__ */ Ut(ws),Es=/* @__PURE__ */ Wt(ws),Ds=/* @__PURE__ */ Gt(ws),Os=/* @__PURE__ */ qt(ws),ks=/* @__PURE__ */ $t(ws),As=/* @__PURE__ */ en(ws),js=/* @__PURE__ */ tn(ws),Ms=/* @__PURE__ */ nn(ws),Ns=/* @__PURE__ */ rn(ws),Ps=/* @__PURE__ */ an(ws),Fs=/* @__PURE__ */ on(ws),Is=/* @__PURE__ */ sn(ws);function Ls(){At.localeError||jt(aa())}function Rs(){At.memoizer||jt({memoizer:na()})}let L=/*@__PURE__*/ N(`ZodType`,(e,t)=>(Ls(),P.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Ae(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Be(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(sl(e,t))},superRefine(e,t){return this.check(cl(e,t))},overwrite(e){return this.check(/* @__PURE__ */ io(e))},optional(){return Bc(this)},exactOptional(){return Hc(this)},nullable(){return Wc(this)},nullish(){return Bc(Wc(this))},nonoptional(e){return Xc(this,e)},array(){return V(this)},or(e){return Ec([this,e])},and(e){return Ac(this,e)},transform(e){return el(this,Rc(e))},default(e){return Kc(this,e)},prefault(e){return Jc(this,e)},catch(e){return Qc(this,e)},pipe(e){return el(this,e)},readonly(){return nl(this)},describe(e){let t=this.clone();return la.add(t,{description:e}),t},meta(...e){if(e.length===0)return la.get(this);let t=this.clone();return la.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return mt(this,`~standard`,{...lr(this),jsonSchema:{input:Ao(this,`input`),output:Ao(this,`output`)}})},set"~standard"(e){pt(this,`~standard`,e)},parse:function e(t,n){return Ts(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Es(this,t,n,{callee:e})},safeParse(e,t){return Ds(this,e,t)},async safeParseAsync(e,t){return Os(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){pt(this,`spa`,e)},validate(e,t){return Xt(this,e,t)},validateAsync(e,t){return Qt(this,e,t)},encode:function e(t,n){return ks(this,t,n,{callee:e})},decode:function e(t,n){return As(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await js(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Ms(this,t,n,{callee:e})},safeEncode(e,t){return Ns(this,e,t)},safeDecode(e,t){return Ps(this,e,t)},async safeEncodeAsync(e,t){return Fs(this,e,t)},async safeDecodeAsync(e,t){return Is(this,e,t)},toJSONSchema(e){return ko(this,{})(e)},get description(){return la.get(this)?.description},get _def(){return this._zod.def}}),zs=/*@__PURE__*/ N(`_ZodString`,(e,t)=>{ur.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ko(e,t,n,r)},/*@__PURE__*/ ht({format:e=>Ho(e).format??null,minLength:e=>Ho(e).minimum??null,maxLength:e=>Ho(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ Qa(...e))},includes(...e){return this.check(/* @__PURE__ */ to(...e))},startsWith(...e){return this.check(/* @__PURE__ */ no(...e))},endsWith(...e){return this.check(/* @__PURE__ */ ro(...e))},min(...e){return this.check(/* @__PURE__ */ Xa(...e))},max(...e){return this.check(/* @__PURE__ */ Ya(...e))},length(...e){return this.check(/* @__PURE__ */ Za(...e))},nonempty(...e){return this.check(/* @__PURE__ */ Xa(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ $a(e))},uppercase(e){return this.check(/* @__PURE__ */ eo(e))},trim(){return this.check(/* @__PURE__ */ oo())},normalize(...e){return this.check(/* @__PURE__ */ ao(...e))},toLowerCase(){return this.check(/* @__PURE__ */ so())},toUpperCase(){return this.check(/* @__PURE__ */ co())},slugify(){return this.check(/* @__PURE__ */ lo())}})),Bs=/*@__PURE__*/ N(`ZodString`,(e,t)=>{ur.init(e,t),zs.init(e,t)},{email(e){return this.check(/* @__PURE__ */ fa(Ks,e))},url(e){return this.check(/* @__PURE__ */ va(Xs,e))},jwt(e){return this.check(/* @__PURE__ */ Na(fc,e))},emoji(e){return this.check(/* @__PURE__ */ ya(Qs,e))},guid(e){return this.check(/* @__PURE__ */ pa(qs,e))},uuid(e){return this.check(/* @__PURE__ */ ma(Js,e))},uuidv4(e){return this.check(/* @__PURE__ */ ha(Js,e))},uuidv6(e){return this.check(/* @__PURE__ */ ga(Js,e))},uuidv7(e){return this.check(/* @__PURE__ */ _a(Js,e))},nanoid(e){return this.check(/* @__PURE__ */ ba($s,e))},cuid(e){return this.check(/* @__PURE__ */ xa(ec,e))},cuid2(e){return this.check(/* @__PURE__ */ Sa(tc,e))},ulid(e){return this.check(/* @__PURE__ */ Ca(nc,e))},base64(e){return this.check(/* @__PURE__ */ Aa(lc,e))},base64url(e){return this.check(/* @__PURE__ */ ja(uc,e))},xid(e){return this.check(/* @__PURE__ */ wa(rc,e))},ksuid(e){return this.check(/* @__PURE__ */ Ta(ic,e))},ipv4(e){return this.check(/* @__PURE__ */ Ea(ac,e))},ipv6(e){return this.check(/* @__PURE__ */ Da(oc,e))},cidrv4(e){return this.check(/* @__PURE__ */ Oa(sc,e))},cidrv6(e){return this.check(/* @__PURE__ */ ka(cc,e))},e164(e){return this.check(/* @__PURE__ */ Ma(dc,e))},datetime(e){return this.check(/* @__PURE__ */ Pa(Hs,e))},date(e){return this.check(/* @__PURE__ */ Fa(Us,e))},time(e){return this.check(/* @__PURE__ */ Ia(Ws,e))},duration(e){return this.check(/* @__PURE__ */ La(Gs,e))}});function R(e){return/* @__PURE__ */ da(Bs,e)}let Vs=/*@__PURE__*/ N(`ZodStringFormat`,(e,t)=>{F.init(e,t),zs.init(e,t)}),Hs=/*@__PURE__*/ N(`ZodISODateTime`,(e,t)=>{kr.init(e,t),Vs.init(e,t)}),Us=/*@__PURE__*/ N(`ZodISODate`,(e,t)=>{Ar.init(e,t),Vs.init(e,t)}),Ws=/*@__PURE__*/ N(`ZodISOTime`,(e,t)=>{jr.init(e,t),Vs.init(e,t)}),Gs=/*@__PURE__*/ N(`ZodISODuration`,(e,t)=>{Mr.init(e,t),Vs.init(e,t)}),Ks=/*@__PURE__*/ N(`ZodEmail`,(e,t)=>{pr.init(e,t),Vs.init(e,t)}),qs=/*@__PURE__*/ N(`ZodGUID`,(e,t)=>{dr.init(e,t),Vs.init(e,t)}),Js=/*@__PURE__*/ N(`ZodUUID`,(e,t)=>{fr.init(e,t),Vs.init(e,t)});function Ys(e){return/* @__PURE__ */ ma(Js,e)}let Xs=/*@__PURE__*/ N(`ZodURL`,(e,t)=>{xr.init(e,t),Vs.init(e,t)});function Zs(e){return/* @__PURE__ */ va(Xs,e)}let Qs=/*@__PURE__*/ N(`ZodEmoji`,(e,t)=>{Sr.init(e,t),Vs.init(e,t)}),$s=/*@__PURE__*/ N(`ZodNanoID`,(e,t)=>{Cr.init(e,t),Vs.init(e,t)}),ec=/*@__PURE__*/ N(`ZodCUID`,(e,t)=>{wr.init(e,t),Vs.init(e,t)}),tc=/*@__PURE__*/ N(`ZodCUID2`,(e,t)=>{Tr.init(e,t),Vs.init(e,t)}),nc=/*@__PURE__*/ N(`ZodULID`,(e,t)=>{Er.init(e,t),Vs.init(e,t)}),rc=/*@__PURE__*/ N(`ZodXID`,(e,t)=>{Dr.init(e,t),Vs.init(e,t)}),ic=/*@__PURE__*/ N(`ZodKSUID`,(e,t)=>{Or.init(e,t),Vs.init(e,t)}),ac=/*@__PURE__*/ N(`ZodIPv4`,(e,t)=>{Nr.init(e,t),Vs.init(e,t)}),oc=/*@__PURE__*/ N(`ZodIPv6`,(e,t)=>{Ir.init(e,t),Vs.init(e,t)}),sc=/*@__PURE__*/ N(`ZodCIDRv4`,(e,t)=>{Lr.init(e,t),Vs.init(e,t)}),cc=/*@__PURE__*/ N(`ZodCIDRv6`,(e,t)=>{zr.init(e,t),Vs.init(e,t)}),lc=/*@__PURE__*/ N(`ZodBase64`,(e,t)=>{Hr.init(e,t),Vs.init(e,t)}),uc=/*@__PURE__*/ N(`ZodBase64URL`,(e,t)=>{Gr.init(e,t),Vs.init(e,t)}),dc=/*@__PURE__*/ N(`ZodE164`,(e,t)=>{Kr.init(e,t),Vs.init(e,t)}),fc=/*@__PURE__*/ N(`ZodJWT`,(e,t)=>{Jr.init(e,t),Vs.init(e,t)}),pc=/*@__PURE__*/ N(`ZodNumber`,(e,t)=>{Yr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ ht({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Ho(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Ho(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Ho(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Ho(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ Ka(e,t))},gte(e,t){return this.check(/* @__PURE__ */ qa(e,t))},min(e,t){return this.check(/* @__PURE__ */ qa(e,t))},lt(e,t){return this.check(/* @__PURE__ */ Wa(e,t))},lte(e,t){return this.check(/* @__PURE__ */ Ga(e,t))},max(e,t){return this.check(/* @__PURE__ */ Ga(e,t))},int(e){return this.check(hc(e))},safe(e){return this.check(hc(e))},positive(e){return this.check(/* @__PURE__ */ Ka(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ qa(0,e))},negative(e){return this.check(/* @__PURE__ */ Wa(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ Ga(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ Ja(e,t))},step(e,t){return this.check(/* @__PURE__ */ Ja(e,t))},finite(){return this}}));function z(e){return/* @__PURE__ */ Ra(pc,e)}let mc=/*@__PURE__*/ N(`ZodNumberFormat`,(e,t)=>{Xr.init(e,t),pc.init(e,t)});function hc(e){return/* @__PURE__ */ za(mc,e)}let gc=/*@__PURE__*/ N(`ZodBoolean`,(e,t)=>{Zr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r)});function B(e){return/* @__PURE__ */ Ba(gc,e)}let _c=/*@__PURE__*/ N(`ZodNull`,(e,t)=>{Qr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r)});function vc(e){return/* @__PURE__ */ Va(_c,e)}let yc=/*@__PURE__*/ N(`ZodUnknown`,(e,t)=>{$r.init(e,t),L.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function bc(){return/* @__PURE__ */ Ha(yc)}let xc=/*@__PURE__*/ N(`ZodNever`,(e,t)=>{ei.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r)});function Sc(e){return/* @__PURE__ */ Ua(xc,e)}let Cc=/*@__PURE__*/ N(`ZodArray`,(e,t)=>{Rs(),ii.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ Xa(e,t))},nonempty(e){return this.check(/* @__PURE__ */ Xa(1,e))},max(e,t){return this.check(/* @__PURE__ */ Ya(e,t))},length(e,t){return this.check(/* @__PURE__ */ Za(e,t))},unwrap(){return this.element}});function V(e,t){return/* @__PURE__ */ uo(Cc,e,t)}let wc=/*@__PURE__*/ N(`ZodObject`,(e,t)=>{Rs(),ui.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r),xt(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return W(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Ae(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Ae(this._zod.def,{catchall:bc()}))},loose(){return this.clone(Ae(this._zod.def,{catchall:bc()}))},strict(){return this.clone(Ae(this._zod.def,{catchall:Sc()}))},strip(){return this.clone(Ae(this._zod.def,{catchall:void 0}))},extend(e){return Je(this,e)},safeExtend(e){return Xe(this,e)},merge(e){return Ze(this,e)},pick(e){return Ge(this,e)},omit(e){return qe(this,e)},partial(...e){return Qe(zc,this,e[0])},exactPartial(...e){return Qe(Vc,this,e[0],`exactPartial`)},required(...e){return $e(Yc,this,e[0])}});function H(e,t){let n={type:`object`,shape:e??{},...j(t)};return new wc(n)}function U(e,t){return new wc({type:`object`,shape:e,catchall:Sc(),...j(t)})}let Tc=/*@__PURE__*/ N(`ZodUnion`,(e,t)=>{fi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r),e.options=t.options});function Ec(e,t){return new Tc({type:`union`,options:e,...j(t)})}let Dc=/*@__PURE__*/ N(`ZodDiscriminatedUnion`,(e,t)=>{Tc.init(e,t),mi.init(e,t)});function Oc(e,t,n){return new Dc({type:`union`,options:t,discriminator:e,...j(n)})}let kc=/*@__PURE__*/ N(`ZodIntersection`,(e,t)=>{hi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r)});function Ac(e,t){return new kc({type:`intersection`,left:e,right:t})}let jc=/*@__PURE__*/ N(`ZodTuple`,(e,t)=>{Rs(),vi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new zc({type:`optional`,innerType:e}))})}});function Mc(e,t,n){let r=t instanceof P;return new jc({type:`tuple`,items:e,rest:r?t:null,...j(r?n:t)})}let Nc=/*@__PURE__*/ N(`ZodRecord`,(e,t)=>{Rs(),Si.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Pc(e,t,n){return!t||!t._zod?new Nc({type:`record`,keyType:R(),valueType:e,...j(t)}):new Nc({type:`record`,keyType:e,valueType:t,...j(n)})}let Fc=/*@__PURE__*/ N(`ZodEnum`,(e,t)=>{Ci.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Fc({...t,checks:[],...j(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Fc({...t,checks:[],...j(r),entries:i})}});function W(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Fc({type:`enum`,entries:n,...j(t)})}let Ic=/*@__PURE__*/ N(`ZodLiteral`,(e,t)=>{wi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function G(e,t){return new Ic({type:`literal`,values:Array.isArray(e)?e:[e],...j(t)})}let Lc=/*@__PURE__*/ N(`ZodTransform`,(e,t)=>{Rs(),Ti.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new kt(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(dt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(dt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Rc(e){return new Lc({type:`transform`,transform:e})}let zc=/*@__PURE__*/ N(`ZodOptional`,(e,t)=>{Di.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bc(e){return new zc({type:`optional`,innerType:e})}let Vc=/*@__PURE__*/ N(`ZodExactOptional`,(e,t)=>{Oi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hc(e){return new Vc({type:`optional`,innerType:e})}let Uc=/*@__PURE__*/ N(`ZodNullable`,(e,t)=>{ki.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wc(e){return new Uc({type:`nullable`,innerType:e})}let Gc=/*@__PURE__*/ N(`ZodDefault`,(e,t)=>{Ai.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Kc(e,t){return new Gc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Le(t)}})}let qc=/*@__PURE__*/ N(`ZodPrefault`,(e,t)=>{Mi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jc(e,t){return new qc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Le(t)}})}let Yc=/*@__PURE__*/ N(`ZodNonOptional`,(e,t)=>{Ni.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xc(e,t){return new Yc({type:`nonoptional`,innerType:e,...j(t)})}let Zc=/*@__PURE__*/ N(`ZodCatch`,(e,t)=>{Ii.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Qc(e,t){return new Zc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:St(t)})}let $c=/*@__PURE__*/ N(`ZodPipe`,(e,t)=>{Li.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),e.in=t.in,e.out=t.out});function el(e,t){return new $c({type:`pipe`,in:e,out:t})}let tl=/*@__PURE__*/ N(`ZodReadonly`,(e,t)=>{zi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nl(e){return new tl({type:`readonly`,innerType:e})}let rl=/*@__PURE__*/ N(`ZodLazy`,(e,t)=>{Vi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function il(e){return new rl({type:`lazy`,getter:e})}let al=/*@__PURE__*/ N(`ZodCustom`,(e,t)=>{Hi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(e,t,n,r)});function ol(e,t){return/* @__PURE__ */ fo(al,e??(()=>!0),t)}function sl(e,t={}){return/* @__PURE__ */ po(al,e,t)}function cl(e,t){return/* @__PURE__ */ mo(e,t)}function ll(e){return/* @__PURE__ */ Pa(Hs,e)}function ul(e){return(t,n)=>{for(let r of e)Object.hasOwn(t,r)&&t[r]===void 0&&n.addIssue({code:`custom`,path:[r],message:`Explicit undefined is not valid JSON`})}}let dl=Ec([R(),z(),B(),vc()]);function fl(e){let t=/* @__PURE__ */ new WeakSet,n=[{value:e,leaving:!1}];try{for(;n.length>0;){let e=n.pop();if(!e)break;if(e.leaving)t.delete(e.value);else if(typeof e.value==`object`&&e.value!==null){if(t.has(e.value))return!1;t.add(e.value),n.push({value:e.value,leaving:!0});for(let t of Object.values(e.value))n.push({value:t,leaving:!1})}}}catch{return!1}return!0}let pl=ol(fl,{message:`JSON value must not contain circular references`}),ml=il(()=>Ec([dl,V(ml),Pc(R(),ml)])),hl=pl.pipe(ml);pl.pipe(V(ml));let gl=pl.pipe(Pc(R(),ml)),_l=U({code:R().min(1),message:R().min(1),retryable:B(),diagnostic:R().min(1).optional(),stage:R().min(1).optional(),durationMs:z().int().nonnegative().optional(),stderrTail:R().min(1).optional()}).superRefine(ul([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),vl=R().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),yl=e=>R().min(1).max(e).refine(e=>e.trim().length>0),bl=Pc(vl,H({label:yl(256).optional(),description:yl(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),xl=Pc(vl,yl(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),Sl=R().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),Cl=Sl.brand(),K=Sl.brand(),wl=Sl.brand();Sl.brand(),Sl.brand();let Tl=R().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),El=Tl.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),Dl=H({modes:V(H({id:El,label:Tl.max(256),description:Tl.max(1024).optional(),dangerous:B().optional(),localizations:bl.optional()}).strict()).min(1).max(32),defaultModeId:El}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.modes.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Permission Mode IDs must be unique`,path:[`modes`,r,`id`]}),n.add(i.id);n.has(e.defaultModeId)||t.addIssue({code:`custom`,message:`Default Permission Mode must exist in the catalog`,path:[`defaultModeId`]})});H({threadId:K,permissionModeId:El}).strict();let Ol=R().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`});H({sourceThreadId:K,lastTurnId:wl.optional(),targetHarnessId:Cl,targetModel:Ol.max(1024).optional(),targetThinkingOptionId:Ol.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).optional()}).strict();let kl=H({sourceThreadId:K,sourceHarnessId:Cl,sourceHarnessLabel:Ol.max(256).optional(),sourceModel:Ol.max(1024).optional(),targetHarnessId:Cl,targetHarnessLabel:Ol.max(256).optional(),targetModel:Ol.max(1024).optional(),totalTurns:z().int().min(1),boundaryTurnNumber:z().int().min(1),includedTurnNumbers:V(z().int().min(1)),omittedTurns:z().int().min(0),preview:R().max(32e3),createdAtMs:z().int().nonnegative()}).strict();H({threadId:K,handoff:kl}).strict();let Al=z().int().safe().nonnegative(),jl=z().finite().nonnegative(),Ml=z().finite().min(0).max(100),Nl=H({version:Ec([G(3),G(4)]).optional(),requestId:R().min(1),turnId:R().min(1).max(1024),outputTokens:Al,startedAtMs:Al,completedAtMs:Al}).strict().refine(e=>e.completedAtMs>e.startedAtMs),Pl=H({version:Ec([G(2),G(3),G(4)]).optional(),value:jl,turnId:R().min(1).max(1024),at:Al}).strict();H({outputTimings:V(Nl).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:Pl.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:Pl.extend({value:Al}).optional()}).strict();let Fl=e=>xl.refine(t=>Object.values(t).every(t=>t.length<=e)),Il=H({composerIndicators:V(H({kind:G(`countdown`),id:R().min(1).max(64),expiresAtUnix:Al,label:Fl(256).optional(),tooltip:Fl(1024).optional()}).strict()).max(2).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,{message:`Composer indicator IDs must be unique`}).optional(),inputTokens:Al.optional(),cachedInputTokens:Al.optional(),cacheWriteInputTokens:Al.optional(),outputTokens:Al.optional(),outputTokensPerSecond:jl.optional(),sessionOutputTokensPerSecond:jl.optional(),apiOutputTokensPerSecond:jl.optional(),reasoningOutputTokens:Al.optional(),totalTokens:Al.optional(),totalCostUsd:jl.optional(),totalCredits:jl.optional(),contextUsagePercent:jl.optional(),cacheHitRatePercent:Ml.optional(),contextWindowTokens:Al.optional(),contextUsedTokens:Al.optional(),planFiveHourUsedPercent:Ml.optional(),planFiveHourResetsAtUnix:Al.optional(),planSevenDayUsedPercent:Ml.optional(),planSevenDayResetsAtUnix:Al.optional(),sessionCacheHitRatePercent:Ml.optional(),timeToFirstOutputMs:Al.optional(),latestRequestTimeToFirstOutputMs:Al.optional(),costSource:W([`publicPrice`,`native`]).optional(),unpricedModels:V(R().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{Object.keys(e).length===0&&t.addIssue({code:`custom`,message:`Thread Usage must contain a reliable field`});let n=e.contextUsedTokens!==void 0;n!==(e.contextWindowTokens!==void 0)&&t.addIssue({code:`custom`,message:`Thread Usage context fields must be provided together`,path:[n?`contextWindowTokens`:`contextUsedTokens`]}),e.contextWindowTokens===0&&t.addIssue({code:`custom`,message:`Thread Usage contextWindowTokens must be greater than zero`,path:[`contextWindowTokens`]}),e.costSource!==void 0&&e.totalCostUsd===void 0&&t.addIssue({code:`custom`,message:`Thread Usage costSource must be provided with totalCostUsd`,path:[`costSource`]}),e.unpricedModels!==void 0&&e.costSource!==`publicPrice`&&t.addIssue({code:`custom`,message:`Thread Usage unpricedModels must be provided with a publicPrice cost`,path:[`unpricedModels`]}),e.planFiveHourResetsAtUnix!==void 0&&e.planFiveHourUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planFiveHourResetsAtUnix must be provided with planFiveHourUsedPercent`,path:[`planFiveHourResetsAtUnix`]}),e.planSevenDayResetsAtUnix!==void 0&&e.planSevenDayUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planSevenDayResetsAtUnix must be provided with planSevenDayUsedPercent`,path:[`planSevenDayResetsAtUnix`]})}),Ll=z().finite().min(0).max(100),Rl=W([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),zl=H({id:R().min(1).max(256),label:R().min(1).max(256),localizations:bl.optional()}).strict(),Bl=H({product:R().min(1),periodType:Rl.optional(),scope:zl.optional(),localizations:bl.optional(),used:z().finite().nonnegative().optional(),limit:z().finite().nonnegative().optional(),unit:R().min(1).max(32).optional(),usagePercent:Ll,resetsAt:R().min(1).optional()}).strict(),Vl=H({availableCount:z().int().safe().positive(),nextExpiresAt:R().min(1).optional(),expiresAt:V(R().min(1)).min(1).max(32).optional()}).strict(),Hl=H({used:z().finite().nonnegative().optional(),limit:z().finite().nonnegative().optional(),unit:R().min(1).max(32).optional(),label:R().min(1).optional(),scope:zl.optional(),localizations:bl.optional(),usedPercent:Ll,resetsAt:R().min(1).optional(),periodType:Rl,productUsage:V(Bl).min(1).optional(),resetCredits:Vl.optional()}).strict(),Ul=H({amount:z().finite().nonnegative(),currency:R().trim().min(1).max(8),label:R().trim().min(1).max(128).optional()}).strict();H({threadId:K,refresh:G(`exact`).optional()}).strict(),H({threadId:K,usage:Il.nullable(),accountCredits:Hl.optional(),accountBalance:Ul.optional(),accountCreditsSupported:B().optional()}).strict();let Wl=R().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),Gl=R().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Model Ref must not contain control characters`).brand(),Kl=W([`priority`,`ultrafast`]),ql=H({id:Gl,serviceTier:Kl.optional()}).strict();function Jl(e,t){return e?.id===t?.id&&e?.serviceTier===t?.serviceTier}let Yl=Wl.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand(),Xl=Wl.max(256),Zl=H({id:Yl,label:Wl.max(256)}).strict(),Ql=H({ref:ql,label:Wl.max(256),resolvedModelLabel:Xl.optional(),fastModel:ql.optional(),supportedThinkingOptionIds:V(Yl).optional()}).strict().refine(e=>e.fastModel?.serviceTier===void 0||e.fastModel.id===e.ref.id,{path:[`fastModel`,`id`],message:`A tiered Fast Model must share the base Model ID`});function $l(e,t){if(t)return e?.models.find(e=>Jl(e.ref,t)||Jl(e.fastModel,t))}let eu=V(Zl).superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Thinking option IDs must be unique`,path:[r,`id`]}),n.add(i.id)}),tu=H({models:V(Ql),defaultModel:ql.optional(),thinkingOptions:eu,defaultThinkingOptionId:Yl.optional()}).strict().superRefine((e,t)=>{let n=[],r=new Set(e.thinkingOptions.map(({id:e})=>e));for(let[i,a]of e.models.entries()){n.some(e=>Jl(e,a.ref))&&t.addIssue({code:`custom`,message:`Model Catalog refs must be unique`,path:[`models`,i,`ref`,`id`]}),n.push(a.ref),a.fastModel&&(n.some(e=>Jl(e,a.fastModel))&&t.addIssue({code:`custom`,message:`Fast Model refs must be distinct and unique`,path:[`models`,i,`fastModel`]}),n.push(a.fastModel));let e=/* @__PURE__ */ new Set;for(let[n,o]of(a.supportedThinkingOptionIds??[]).entries())e.has(o)&&t.addIssue({code:`custom`,message:`Supported Thinking option IDs must be unique per Model`,path:[`models`,i,`supportedThinkingOptionIds`,n]}),e.add(o),r.has(o)||t.addIssue({code:`custom`,message:`Supported Thinking option must exist in the catalog`,path:[`models`,i,`supportedThinkingOptionIds`,n]})}e.defaultModel&&!$l(e,e.defaultModel)&&t.addIssue({code:`custom`,message:`Default Model must exist in the Model Catalog`,path:[`defaultModel`,`id`]}),e.defaultThinkingOptionId&&!r.has(e.defaultThinkingOptionId)&&t.addIssue({code:`custom`,message:`Default Thinking option must exist in the catalog`,path:[`defaultThinkingOptionId`]})}),nu=H({fork:B(),forkAcrossCwd:B(),rollbackLastTurn:B()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),ru=W([`live`,`atCreate`]),iu=H({configuration:H({selectModel:B(),selectThinkingOption:B(),selectPermissionMode:B(),permissionModeScope:ru.default(`live`)}).strict(),history:nu,subagents:H({observe:B(),readTranscript:B()}).strict().optional(),autonomousTurns:H({observe:B()}).strict().optional(),steer:B().optional(),persistentPlan:B().optional()}).strict();H({effectiveModel:ql.optional(),resolvedModelLabel:Xl.optional(),effectiveThinkingOptionId:Yl.optional(),availableThinkingOptions:eu.optional(),effectivePermissionModeId:El.optional()}).strict().superRefine((e,t)=>{e.effectiveThinkingOptionId&&e.availableThinkingOptions&&!e.availableThinkingOptions.some(({id:t})=>t===e.effectiveThinkingOptionId)&&t.addIssue({code:`custom`,message:`Effective Thinking option must be currently available`,path:[`effectiveThinkingOptionId`]})});let au=H({open:G(!0)}).strict();Ec([H({status:G(`ready`),catalog:tu,permissionModes:Dl.optional(),capabilities:iu,webUi:au.optional()}).strict().superRefine((e,t)=>{let n=e.capabilities.configuration.selectPermissionMode;n!==!!e.permissionModes&&t.addIssue({code:`custom`,message:`Permission Mode catalog and capability must agree`,path:n?[`permissionModes`]:[`capabilities`,`configuration`,`selectPermissionMode`]})}),H({status:W([`notInstalled`,`unavailable`,`error`]),error:_l}).strict()]),H({harnessId:Cl,cwd:Wl.max(16384).optional(),refresh:B().optional(),purpose:G(`availability`).optional(),credentialAccess:W([`allow`,`retry`]).optional()}).strict(),H({harnessId:Cl}).strict(),H({}).strict(),H({threadId:K,model:ql}).strict(),H({threadId:K,thinkingOptionId:Yl}).strict(),H({threadId:K,includeReferenceCapability:B().optional()}).strict(),Oc(`owner`,[H({owner:G(`codex`),locked:B(),effectiveModel:ql.optional(),resolvedModelLabel:Xl.optional(),effectiveThinkingOptionId:Yl.optional(),effectivePermissionModeId:El.optional(),history:nu.optional(),supportsThreadReferences:G(!0).optional(),handoff:kl.optional()}).strict(),H({owner:G(`external`),harnessId:Wl.max(256),transportModelId:Wl.max(8192),effectiveModel:ql.optional(),resolvedModelLabel:Xl.optional(),effectiveThinkingOptionId:Yl.optional(),availableThinkingOptions:eu.optional(),effectivePermissionModeId:El.optional(),catalog:tu.optional(),history:nu,usage:Il.optional(),handoff:kl.optional(),locked:G(!0)}).strict()]),H({threadIds:V(K).min(1).max(100)}).strict().superRefine(({threadIds:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i)&&t.addIssue({code:`custom`,message:`Thread ownership-list IDs must be unique`,path:[`threadIds`,r]}),n.add(i)});let ou=Oc(`owner`,[H({threadId:K,owner:G(`codex`)}).strict(),H({threadId:K,owner:G(`external`),harnessId:R().max(256).pipe(Cl)}).strict()]);H({threads:V(ou).min(1).max(100)}).strict().superRefine(({threads:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.threadId)&&t.addIssue({code:`custom`,message:`Thread ownership-list results must be unique`,path:[`threads`,r,`threadId`]}),n.add(i.threadId)}),H({threadId:K,text:R().optional()}).strict(),H({kind:G(`application`),value:R().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),wt}}).pipe(H({expectedTurnId:wl,clientUserMessageId:R().min(1),delivery:W([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),W([`activeTurn`,`newTurn`]),H({delivery:W([`official`,`activeTurn`,`newTurn`])}).strict();let su=R().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u),cu=su.pipe(Cl),lu=cu.refine(e=>e!==`codex`,`The official Codex identity is reserved`),uu=R().min(1).max(512).refine(e=>!/[\\\u0000:#?]/u.test(e)&&!e.startsWith(`/`)&&!e.split(`/`).some(e=>e===`..`||e===``),`Plugin resources must be relative paths inside the plugin`),du=Zs().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),fu=H({en:R().max(4096),"zh-CN":R().max(4096).optional()}).strict(),pu=H({commands:V(H({terminal:R().max(256),command:R().max(4096)}).strict()).max(8),before:fu.optional(),after:fu.optional(),downloads:V(H({label:R().max(128),url:du}).strict()).max(8).optional()}).strict(),mu={id:cu,name:R().trim().min(1).max(128),version:R().min(1).max(128),kind:G(`usage`).optional(),iconStyle:H({vector:H({viewBox:R().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:R().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:V(H({d:R().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:W([`evenodd`,`nonzero`]).optional(),fill:R().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:R().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:z().min(0).max(50).optional(),paddingRatio:z().min(0).max(.25).optional()}).strict().optional(),installation:pu.optional(),notice:fu.optional(),launchCommand:G(!0).optional(),links:H({website:du.optional(),documentation:du.optional(),installation:du.optional()}).strict().optional()};H({manifestVersion:G(1),...mu,adapterApiVersion:z().int().positive(),entry:uu,icon:uu.optional()}).strict();let hu=R().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),gu=H({...mu,icon:hu.optional()}).strict();H({}).strict(),H({plugins:V(gu.extend({id:lu})).max(128)}).strict(),H({version:G(1),enabled:V(cu).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]});let _u=su,vu=W([`sidebar.thread-layout`,`sidebar.thread-badge`,`appearance.theme`]),yu=W([`appearance`,`interface`,`workflow`,`analytics`,`integrations`,`tools`]),bu=R().trim().min(1).max(128);function xu(e){switch(e.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`webp`:return`image/webp`;default:return}}let Su=e=>e.split(`/`).every(e=>!/[. ]$/u.test(e)),Cu=uu.refine(e=>xu(e)!==void 0&&Su(e),`Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space`),wu=R().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu,`Expected an HTTP(S) URL`).pipe(Zs({protocol:/^https?$/u})).refine(e=>{let{username:t,password:n}=new URL(e);return!t&&!n&&!/[\\\s]/u.test(e)},`URL must not contain credentials, backslashes, or whitespace`);function Tu(e){return U({en:e,"zh-CN":e})}let Eu=Tu(R().trim().min(1)),Du=V(yu).max(yu.options.length).refine(e=>new Set(e).size===e.length,`Duplicate categories`),Ou=V(vu).max(vu.options.length).refine(e=>new Set(e).size===e.length,`Duplicate slots`),ku={key:R().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),label:Eu,description:Eu.optional()},Au={...ku,step:z().positive().optional(),default:z().optional()},ju=U({value:R(),label:Eu}),Mu=Oc(`type`,[U({...ku,type:G(`boolean`),default:B().optional()}),U({...ku,type:G(`string`),placeholder:Eu.optional(),default:R().optional()}),U({...Au,type:G(`number`),min:z().optional(),max:z().optional()}),U({...Au,type:G(`range`),min:z(),max:z()}),U({...ku,type:G(`select`),options:V(ju).min(1),default:R().optional()})]).superRefine((e,t)=>{let n=(e,n)=>t.addIssue({code:`custom`,path:[e],message:n});if(e.type===`number`||e.type===`range`){let{min:t=-1/0,max:r=1/0,default:i}=e;t>r&&n(`max`,`Must be at least min`),i!==void 0&&(i<t||i>r)&&n(`default`,`Must be within min and max`)}else if(e.type===`select`){let t=new Set(e.options.map(({value:e})=>e));t.size!==e.options.length&&n(`options`,`Duplicate option values`),e.default!==void 0&&!t.has(e.default)&&n(`default`,`Must match an option value`)}}),Nu=H({manifestVersion:hc().positive(),id:_u,name:Ec([bu,Tu(bu)]),version:R().min(1).max(128),desktopApi:hc().positive()}).passthrough().extend({manifestVersion:G(1),desktopApi:G(1),description:U({en:R().max(4096),"zh-CN":R().max(4096).optional()}).optional(),author:R().trim().min(1).max(128).optional(),repository:wu.optional(),details:U({en:R().max(16384),"zh-CN":R().max(16384).optional()}).optional(),icon:Cu.optional(),screenshots:V(Cu).max(4).refine(e=>new Set(e).size===e.length,`Duplicate screenshots`).optional(),desktop:U({script:uu,style:uu.optional()}).optional(),backend:U({script:uu.refine(Su)}).optional(),slots:Ou.default(()=>[]),settingsSchema:V(Mu).max(32).refine(e=>new Set(e.map(({key:e})=>e)).size===e.length,`Duplicate setting keys`).optional(),categories:Du.optional()}).strict().refine(e=>e.desktop!==void 0||e.backend!==void 0,`Expected at least one desktop or backend entry`),Pu=R().regex(/^[a-f0-9]{64}$/u),Fu=U({state:W([`running`,`disabled`,`invalid`,`incompatible`,`conflict`,`failed`,`waiting`]),hash:Pu.optional(),error:R().optional(),conflictWith:_u.optional()});U({controllerPid:hc().positive(),targetId:R().nullable(),updatedAt:ll(),handledReloadToken:Ys().optional(),extensions:Pc(R(),Fu),surfaces:Pc(R(),Fu).optional()});let Iu=W([`official`,`community`]);function Lu(e){return e.origin===`https://api.github.com`&&/^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(e.pathname)}let Ru=wu.refine(e=>{let t=new URL(e);return/\.zip$/iu.test(t.pathname)||Lu(t)||t.origin===`https://github.com`&&/^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(t.pathname)||t.origin===`https://codeload.github.com`&&/^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(t.pathname)},`Expected a .zip download URL or a GitHub zipball URL`),zu=U({id:_u,version:R().trim().min(1).max(128),name:Eu.extend({en:bu,"zh-CN":bu}),description:Tu(R().trim().min(1).max(4096)),details:Tu(R().trim().min(1).max(16384)).optional(),author:R().trim().min(1).max(128),repository:wu,stars:z().int().min(0).optional(),downloads:z().int().min(0).optional(),categories:Du.optional(),trustTier:Iu.default(`community`),icon:wu.optional(),screenshots:V(wu).max(4).optional(),downloadUrl:Ru,sha256:Pu,slots:Ou.optional(),publishedAt:R().optional(),updatedAt:R().optional(),minCodexHostVersion:R().optional()});U({schemaVersion:G(1),generatedAt:R(),extensions:V(zu).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)});let Bu=R().trim().min(1).max(128),Vu=/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu,Hu=_u.refine(e=>!Vu.test(e),`Reserved extension ID`),Uu=W([`desktop`,`web`]),Wu=Pu,Gu=Ys(),Ku=uu.refine(e=>!/[\x00-\x1f\x7f<>"|*]/u.test(e)&&e.split(`/`).every(e=>!/[. ]$/u.test(e)&&!Vu.test(e)),`Expected a portable relative resource path`).refine(e=>e.split(`/`).length<=32,`Extension resources may be at most 32 segments deep`),qu=Nu.shape,Ju=(e,t=0)=>U({en:R().trim().min(t).max(e),"zh-CN":R().trim().min(t).max(e)}),Yu=e=>Ku.refine(t=>t.endsWith(e),`Expected a ${e} file`),Xu=Yu(`.mjs`),Zu=Yu(`.css`).optional(),Qu=e=>e.normalize(`NFC`).toLowerCase(),$u=U({manifestVersion:G(2),id:Hu,name:Ju(128,1),version:R().trim().min(1).max(128),description:Ju(4096),details:Ju(16384).optional(),author:qu.author,repository:qu.repository,icon:qu.icon.refine(e=>e===void 0||Ku.safeParse(e).success),screenshots:qu.screenshots.refine(e=>e===void 0||e.every(e=>Ku.safeParse(e).success)),categories:qu.categories,settingsSchema:qu.settingsSchema,slots:qu.slots.removeDefault().optional(),page:U({apiVersion:G(1),entry:Xu,style:Zu,title:Ju(128,1).optional()}).optional(),widget:U({apiVersion:G(1),entry:Xu,style:Zu}).optional(),desktop:U({apiVersion:G(1),script:Yu(`.js`),style:Zu}).optional(),web:U({apiVersion:G(1),entry:Xu.optional(),style:Zu}).refine(({entry:e,style:t})=>e!==void 0||t!==void 0,`Expected a Web entry or style`).optional(),backend:U({apiVersion:G(1),entry:Xu}).optional()}).refine(({page:e,widget:t,desktop:n,web:r,backend:i})=>!!(e||t||n||r||i),`Expected at least one page, widget, desktop, web, or backend entry`).refine(({page:e,widget:t,web:n,backend:r})=>!r||[e?.entry,t?.entry,n?.entry].every(e=>e===void 0||Qu(e)!==Qu(r.entry)),{path:[`backend`,`entry`],message:`A backend entry cannot also be a frontend entry`});function ed({hasPage:e,hasWidget:t,hasDesktop:n,hasWeb:r,hasBackend:i}){if(e||t||i&&!n&&!r)return[`desktop`,`web`];let a=[];return n&&a.push(`desktop`),r&&a.push(`web`),a}let td=Bu,nd=hc().nonnegative(),rd=U({revision:nd,enabled:V(Hu).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)}),{downloadUrl:id,...ad}=zu.shape,od=H({...ad,id:Hu,format:G(`codexhost`),targets:V(Uu).min(1).max(2).refine(e=>new Set(e).size===e.length,`Duplicate targets`),apis:U({page:hc().positive().optional(),widget:hc().positive().optional(),desktop:hc().positive().optional(),web:hc().positive().optional(),backend:hc().positive().optional()}),downloadUrl:id.refine(e=>e.startsWith(`https://`),`Expected HTTPS`)}).refine(({targets:e,apis:t})=>{let n=ed({hasPage:!!t.page,hasWidget:!!t.widget,hasDesktop:!!t.desktop,hasWeb:!!t.web,hasBackend:!!t.backend});return e.length===n.length&&n.every(t=>e.includes(t))},`Catalog targets must match the declared APIs`);H({schemaVersion:G(2),generatedAt:R().min(1),extensions:V(od).max(1e4).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)}).extend({catalogUrl:wu,fetchedAt:ll(),cached:B()});let sd={id:Hu},cd={...sd,activationId:Gu,digest:Wu},ld={...sd,activationId:cd.activationId.optional()},ud=R().min(1).max(4096).refine(e=>/^(?:\/|[a-z]:[/\\])/iu.test(e)&&!e.includes(`\0`)&&!e.split(/[/\\]/u).some(e=>e===`.`||e===`..`),`Expected an absolute local path without dot segments`),dd=R().min(1).max(256).refine(e=>e.split(`/`).every(e=>e&&/^[a-z0-9_.-]+$/iu.test(e)&&e!==`.`&&e!==`..`),`Invalid GitHub ref`);function fd(e){return R().max(4*Math.ceil(e/3)).refine(t=>{let n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return t.length%4==0&&t.length*3/4-n<=e&&/^[A-Za-z0-9+/]*={0,2}$/u.test(t)},`Expected bounded standard padded base64`)}let pd=U({type:G(`github`),repository:R().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),ref:dd.optional(),tag:dd.optional(),asset:R().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),subpath:Ku.optional()}).refine(({ref:e,tag:t,asset:n})=>!e||!t&&!n,`Use either a zipball ref or a release tag/asset`),md=Ec([U({type:G(`catalog`),...sd}),pd,U({type:G(`zip`),base64:fd(67108864).min(4)}),U({type:G(`zip`),localZipPath:ud}),U({type:G(`localDir`),localDir:ud})]),hd=Oc(`type`,[U({type:G(`catalog`),...sd}),pd,U({type:G(`zip`)}),U({type:G(`localDir`)})]),gd=U({...cd,manifest:$u,installedAt:ll(),source:hd.optional()}),_d=e=>R().max(23+4*Math.ceil(e/3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u),vd={desktopConflictWith:Hu.optional()},yd=W([`none`,`inactive`,`starting`,`running`,`failed`]),bd=Oc(`state`,[gd.extend({state:G(`valid`),enabled:B(),...vd,iconDataUrl:_d(131072).optional(),screenshotDataUrls:V(_d(524288)).max(4).optional(),backendState:yd.optional(),backendError:R().optional()}),U({state:W([`invalid`,`incompatible`]),id:R().min(1),enabled:B(),error:R()})]);U({revision:nd,configuration:rd,diagnostics:V(R()),extensions:V(bd)}),U({revision:nd,extensions:V(gd.extend({...vd,settingsRevision:nd})).max(64)});let xd={list:`codexhost/extensions/list`,snapshot:`codexhost/extensions/snapshot`,catalog:`codexhost/extensions/catalog`,install:`codexhost/extensions/install`,update:`codexhost/extensions/update`,enable:`codexhost/extensions/enable`,disable:`codexhost/extensions/disable`,uninstall:`codexhost/extensions/uninstall`,recover:`codexhost/extensions/recover`,asset:`codexhost/extensions/asset`,settingsGet:`codexhost/extensions/settings/get`,settingsSet:`codexhost/extensions/settings/set`,backendInvoke:`codexhost/extensions/backend/invoke`},Sd=Object.freeze(Object.values(xd));new Set(Sd),U({});let Cd={expectedRevision:nd};U({...sd,...Cd}),gd.extend({replaced:B()}),Oc(`state`,[U({state:G(`saved`),configuration:rd}),U({state:G(`revision-conflict`),revision:nd})]),U({...ld,digest:cd.digest.optional(),path:Ku}),U({mimeType:R().min(1),base64:fd(16777216),digest:cd.digest}),U({settingsRevision:nd,values:gl}),xd.list,xd.snapshot,xd.catalog,U({forceRefresh:B().optional()}),xd.install,U({source:md}),xd.update,U({...sd,expectedDigest:cd.digest,expectedActivationId:cd.activationId.optional(),source:md.optional()}),xd.enable,xd.disable,xd.uninstall,U({...sd,removeData:B().optional(),expectedDigest:cd.digest.optional()}),U({...sd,removed:B()}),xd.recover,U({expectedRevision:Cd.expectedRevision.optional()}),xd.asset,xd.settingsGet,U(ld),xd.settingsSet,U({...ld,expectedSettingsRevision:nd,values:gl}),xd.backendInvoke,U({...ld,method:td,params:hl.optional()}),U({result:hl}),H({threadId:K}).strict(),H({confirmed:B()}).strict(),[...Sd],H({sections:V(H({id:R().min(1),name:R().min(1),threads:V(gl)}).strict())}).strict(),H({threadId:R().min(1).max(1024),sectionId:R().min(1).max(1024).nullable()}).strict(),H({threadIds:V(R().min(1))}).strict(),H({threadId:R().min(1).max(1024),pinned:B()}).strict(),H({}).strict(),H({parents:Pc(R().min(1),R().min(1))}).strict(),H({prompt:R().max(16384).optional()}).strict(),H({projects:V(H({id:R(),name:R(),rootPaths:V(R())})),nativeProjects:G(!0).optional(),assignments:Pc(R(),R()),projectless:V(R()),pinned:V(R()),sectionProjects:Pc(R(),V(R())).optional()});let wd=Pc(R(),bc()),Td=H({epoch:R().uuid(),sequence:z().int().nonnegative()});Oc(`type`,[H({type:G(`projects-changed`),cursor:Td}),H({type:G(`skills-changed`),cursor:Td,cwd:R().optional()}),H({type:G(`harness-inspection-changed`),cursor:Td,harnessId:R().min(1)}),H({type:G(`display-settings-changed`),cursor:Td}),H({type:G(`preferences-changed`),cursor:Td,revision:z().int().nonnegative()}),H({type:G(`extensions-changed`),cursor:Td,revision:nd}),H({type:G(`hello`),version:G(1),cursor:Td,reset:B()}),H({type:G(`changed`),cursor:Td,threadId:R().min(1),method:R().min(1)})]);let Ed=Oc(`type`,[H({type:G(`text`),id:R(),prompt:R(),secret:B().optional(),optional:B().optional()}),H({type:G(`choice`),id:R(),prompt:R(),multiple:B(),allowOther:B(),optional:B().optional(),options:V(H({value:R(),label:R(),description:R().optional()}))})]),Dd=Oc(`type`,[H({type:G(`approval`),title:R(),description:R().optional(),subject:bc().optional(),actions:V(H({id:R(),label:R(),effect:R()}))}),H({type:G(`question`),title:R().optional(),questions:V(Ed)})]),Od=H({requestId:Ec([R(),z().int()]),threadId:R(),kind:W([`approval`,`question`]),interaction:Dd,request:wd}),kd=H({id:R().min(1),clientUserMessageId:R().min(1),input:V(wd),presentationInput:V(wd).nullable().optional()}).passthrough();H({fields:V(H({path:V(Ec([R(),z().int().nonnegative()])),originalLength:z().int().nonnegative()}))});let Ad=H({id:R().min(1),status:R().min(1),codexhostTurnOutcome:H({status:G(`unknown`),reason:R()}).optional(),items:V(H({id:R().min(1),type:R().min(1)}).passthrough()),codexhostFileOperations:V(H({beforeItemId:R().nullable(),item:H({id:R().min(1),type:R().min(1)}).passthrough()})).optional(),error:H({message:R().optional()}).passthrough().nullable().optional(),fingerprint:R().min(1).optional(),unchanged:G(!0).optional()}).passthrough(),jd=H({id:R().min(1).max(512),fingerprint:R().min(1).max(128)});H({threadId:R().min(1),knownTurns:V(jd).max(64).optional(),truncateToolOutput:B().optional()});let Md=H({harnessId:R().min(1),nativeSessionId:R().min(1)});H({cursor:Td,activeTurnId:R().min(1).nullable().optional(),command:H({name:R().min(1),turn:Ad,subsequentTurnId:R().min(1).optional()}).optional(),thread:H({id:R().min(1),cwd:R(),modelProvider:R().min(1),createdAt:z(),updatedAt:z(),status:H({type:R()}).passthrough(),name:R().nullable().optional(),preview:R().optional(),codexhostImportSource:Md.optional(),turns:V(Ad).length(0)}).passthrough(),turnsPage:H({data:V(Ad).max(5),nextCursor:R().nullable()}),configuration:H({native:H({model:R().min(1).max(1024).optional(),reasoningEffort:R().min(1).max(128).optional()}).optional(),effectiveModel:ql.optional(),effectiveThinkingOptionId:Yl.optional(),effectivePermissionModeId:El.optional()}),queue:H({items:V(kd),pausedReason:W([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:V(Od),handoff:kl.optional()}),H({version:G(1),owner:G(`service`).optional(),pid:z().int().positive(),port:z().int().min(1).max(65535),token:R().regex(/^[0-9a-f]{64}$/u),startedAt:z(),epoch:R().uuid(),capabilities:H({peerDelegation:G(1).optional()}).optional()}),H({epoch:R().uuid(),threadId:R().min(1),requestId:Ec([R(),z().int()]),result:wd}),H({includeArchived:B().optional(),officialCursor:H({live:R().nullable(),archived:R().nullable().optional()}).strict().optional(),scope:Ec([H({cwd:R().min(1).max(4096),excludeCwds:V(R().min(1).max(4096)).max(1024)}).strict(),H({projectId:R().min(1).max(1024),legacyThreadIds:V(R().min(1).max(1024)).max(1024),rootPaths:V(R().min(1).max(4096)).max(1024).optional()}).strict()]).optional()}).strict(),H({threads:V(gl),ownership:V(ou),archivedThreadIds:V(K),officialCursor:H({live:R().nullable(),archived:R().nullable().optional()}).strict().optional()}).strict();let Nd=W([`running`,`waiting`,`idle`,`unknown`]),Pd=U({harnessId:Cl,title:R().optional(),status:Nd,archived:B()}),Fd=U({revision:hc().nonnegative(),parents:Pc(K,K),nodes:Pc(K,Pd),truncated:B()}).refine(e=>Object.keys(e.nodes).length<=5e3,`Too many Thread tree nodes`).refine(({parents:e,nodes:t})=>Object.entries(e).every(([e,n])=>Object.hasOwn(t,e)&&Object.hasOwn(t,n)),`Missing Thread tree node`),Id=R().min(1).max(128);U({});let Ld=U({subscriptionId:Id});U({}),Ld.extend({snapshot:Fd});let Rd=R().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);H({available:B()}).strict(),H({path:R().min(1),mimeType:Rd}).strict();let zd=W([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);Oc(`ok`,[H({ok:G(!0),text:R()}).strict(),H({ok:G(!1),error:H({code:zd}).strict()}).strict()]),H({threadId:K.optional(),cwd:R().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let Bd=H({name:R().min(1).regex(/^[^\s[\]]+$/u),description:R().optional(),path:R().min(1),scope:W([`project`,`global`]),source:R().min(1)}).strict();H({revision:z().int().nonnegative(),complete:B(),skills:V(Bd),warnings:V(R()).optional()}).strict(),H({cwd:R().min(1).optional()}).strict();let Vd=H({kind:W([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:R().min(1)}).strict(),Hd=Oc(`status`,[H({status:G(`not-installed`)}),H({status:G(`not-running`)}),H({status:G(`not-logged-in`)}),H({status:G(`https-disabled`)}),H({status:G(`not-serving`),command:R()}),H({status:G(`occupied`),target:R()}),H({status:G(`serving`),url:R(),funnel:B()}),H({status:G(`error`),message:R()})]);H({state:Hd,error:R().optional()}).strict();let Ud=Oc(`status`,[H({status:G(`on`)}),H({status:G(`off`)}),H({status:G(`invalid`),reason:R()})]),Wd=H({lan:B(),autostart:Ud}).strict(),Gd=H({expiresAt:R().optional(),issuing:B(),failure:H({detail:R().optional(),retryAt:R(),paused:B()}).optional()}),Kd=Oc(`status`,[H({status:G(`off`),reason:W([`invite`,`name-taken`,`banned`]).optional()}),H({status:G(`connecting`),reason:W([`full`,`unreachable`]).optional()}),H({status:G(`connected`),url:R(),certificate:Gd}),H({status:G(`missing-certificate`),url:R(),certificate:Gd}),H({status:G(`stopped`),reason:W([`replaced`,`rejected`,`unsupported-version`])})]);R().max(253).regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/i).transform(e=>e.toLowerCase()),R().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let qd=W([`official`,`self-hosted`]);H({secret:R().min(1),lastUsedAt:z().nullable(),networkUrls:V(Vd),directCandidates:V(Vd).optional(),tailscale:Hd,background:Wd.optional(),relay:H({state:Kd,enabled:B(),kind:qd,officialHost:R(),customHost:R().optional(),officialHostname:R().optional(),customHostname:R().optional(),quotaUntil:R().optional()}).strict().optional()}).strict();let Jd=U({threadId:R().min(1).max(1024),view:W([`result`,`messages`]),from:z().int().min(1).max(2**53-1).optional(),to:z().int().min(1).max(2**53-1).optional()}),Yd=R().regex(/^[a-zA-Z0-9_-]{1,64}$/u),Xd=R().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u),Zd=W([`relay`,`tailscale`,`lan`,`custom`]),Qd=[`blue`,`purple`,`cyan`,`green`,`amber`,`rose`,`slate`],$d=W(Qd);new Set(Qd);let ef=W([`connected`,`connecting`,`auth-error`,`offline`,`disabled`]);H({peers:V(H({peerId:Yd,hostId:Xd,name:R().min(1).max(120),color:$d.optional(),origin:R().min(1).max(2048),transportKind:Zd,encrypted:B(),enabled:B(),state:ef,latencyMs:z().int().nonnegative().optional(),version:R().max(128).optional(),platform:R().max(64).optional(),hostname:R().max(255).optional(),homeDir:R().max(4096).optional(),lastError:R().max(1e3).optional(),projectCount:z().int().nonnegative(),createdAt:R(),updatedAt:R()}))}),H({connectionUrl:R().min(1).max(4096).optional(),origin:R().min(1).max(2048).optional(),token:R().min(1).max(2048).optional(),name:R().trim().min(1).max(120).optional(),color:$d.optional()}).refine(e=>!!e.connectionUrl||!!e.origin&&!!e.token,`Provide either connectionUrl or both origin and token`),H({peerId:Yd,name:R().trim().min(1).max(120).optional(),color:$d.nullable().optional(),connectionUrl:R().min(1).max(4096).optional(),origin:R().min(1).max(2048).optional(),token:R().min(1).max(2048).optional(),enabled:B().optional()}),H({peerId:Yd}),H({removed:B()}),H({peerId:Yd.optional(),connectionUrl:R().min(1).max(4096).optional(),origin:R().min(1).max(2048).optional(),token:R().min(1).max(2048).optional()}).refine(e=>!!e.peerId||!!e.connectionUrl||!!e.origin&&!!e.token,`Provide peerId, connectionUrl, or both origin and token`);let tf=H({id:R().min(1).max(1024),name:R().min(1).max(512),path:R().min(1).max(8192)});H({ok:B(),latencyMs:z().int().nonnegative().optional(),origin:R().max(2048).optional(),transportKind:Zd.optional(),encrypted:B().optional(),version:R().max(128).optional(),platform:R().max(64).optional(),hostname:R().max(255).optional(),homeDir:R().max(4096).optional(),projectCount:z().int().nonnegative().optional(),projects:V(tf).optional(),error:R().max(1e3).optional()});let nf=H({id:R().min(1).max(1024),name:R().min(1).max(512),path:R().min(1).max(8192),threadIds:V(R().min(1).max(1024))}),rf=H({attachments:G(1).optional(),workspaceFiles:G(1).optional(),officePreview:G(1).optional(),delegation:G(1).optional()}),af=H({version:R().max(128),platform:R().max(64),hostname:R().max(255),homeDir:R().max(4096).optional(),epoch:R().min(1).max(256),projects:V(nf),capabilities:rf.optional()});U({threadId:R().min(1).max(1024),scope:R().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u).optional(),requestId:R().min(1).max(256).optional(),mode:W([`queue`,`steer`]).optional(),expectedTurnId:R().min(1).max(1024).nullable().optional(),content:V(Oc(`type`,[U({type:G(`text`),text:R()}),U({type:G(`file`),receiptId:R().min(1).max(128)})])).min(1).max(64)});let of=H({ok:G(!1),error:H({code:R(),message:R(),details:Pc(R(),bc()).optional()})});Ec([H({ok:G(!0),value:H({receiptId:R().min(1),file:H({attachmentId:R(),name:R(),bytes:z().int().nonnegative()})})}),of]),Ec([H({ok:G(!0),value:H({accepted:G(!0)})}),of]);let sf=H({name:R().min(1).max(512),path:R().min(1).max(8192),kind:G(`directory`)});H({peerId:Yd,path:R().min(1).max(8192).optional()}),H({path:R().min(1).max(8192),parentPath:R().min(1).max(8192).nullable(),homeDir:R().min(1).max(8192).optional(),entries:V(sf)}),H({peerId:Yd,parentPath:R().min(1).max(8192),name:R().min(1).max(255).refine(e=>e.trim().length>0,`Directory name cannot be blank`)}),H({path:R().min(1).max(8192),name:R().min(1).max(255)}),H({peerId:Yd,path:R().min(1).max(8192),title:R().trim().min(1).max(255).optional()}),H({peerId:Yd,workspaceId:R().min(1).max(1024),title:R().trim().min(1).max(255)}),H({peerId:Yd,workspaceId:R().min(1).max(1024)}),H({workspaceId:R().min(1).max(1024).optional(),manifest:af});let cf=W([`listHarnesses`,`inspect`,`start`,`send`,`cancel`,`read`,`answer`,`list`]);U({operation:cf,hopCount:z().int().min(0).max(16),sourceId:Yd.optional(),input:gl});let lf=U({code:R().min(1).max(128),message:R().max(4096),details:gl.optional()});Ec([U({ok:G(!0),value:hl}),U({ok:G(!1),error:lf})]);let uf=U({id:R().min(1).max(1024),name:R().min(1).max(512),path:R().min(1).max(8192)});U({hosts:V(U({hostId:Xd,displayName:R().min(1).max(120),online:B(),state:ef,delegation:B(),projects:V(uf),platform:R().max(64).optional(),hostname:R().max(255).optional(),homeDir:R().max(4096).optional()}))}),U({version:G(1),instanceId:R().min(1).max(128),pid:z().int().positive(),endpoint:R().min(1).max(256),token:R().regex(/^[0-9a-f]{64}$/u),startedAt:z().int().nonnegative()}),Ec([U({operation:G(`hosts`)}),U({operation:cf,hostId:Xd,hopCount:z().int().min(0).max(16),timeoutMs:z().int().min(1).max(12e4).optional(),input:gl})]);let df=H({id:R().min(1).max(256),harnessId:R().min(1),label:R().min(1).max(512),provider:W([`openai-codex`,`xai`])}).strict(),ff=R().regex(/^[a-z][a-z0-9-]{0,47}$/),pf=H({name:ff,source:df,importedAt:R()}).strict(),mf=Oc(`action`,[H({action:G(`list`)}).strict(),H({action:G(`import`),sourceId:R().min(1).max(256),name:ff,confirmed:G(!0)}).strict(),H({action:G(`reimport`),sourceId:R().min(1).max(256),name:ff,confirmed:G(!0)}).strict(),H({action:G(`remove`),name:ff,confirmed:G(!0)}).strict()]),hf=H({provider:R().min(1).max(128),type:W([`oauth`,`api_key`,`unknown`]),label:R().min(1).max(512).optional(),vendor:W([`openai-codex`,`xai`]).optional()}).strict();H({sources:V(df),targets:V(H({harnessId:R(),providers:V(W([`openai-codex`,`xai`])),imports:V(pf),others:V(hf).default([])}).strict())}).strict(),H({targetHarnessId:R().min(1).max(128).optional(),request:mf}).strict(),H({events:B()});let gf=V(U({agent:R().min(1).max(128),section:W([`main`,`more`,`auto`])})).max(256).refine(e=>new Set(e.map(e=>e.agent)).size===e.length,`Duplicate Harness IDs`);U({entries:gf.nullable()}),U({}),U({entries:gf,initializeOnly:B().optional()});let _f=U({enabled:B(),timeoutMinutes:z().int().min(5).max(1440)});Object.freeze({enabled:!0,timeoutMinutes:10});let vf=R().regex(/^external$/u),yf=Cl.transform(e=>String(e)),bf=U({model:ql.optional(),thinkingOptionId:Yl.optional(),permissionModeId:El.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`),xf=U({lastHarness:Cl.optional(),byHarness:Pc(yf,bf)}),Sf=U({model:ql.optional(),thinkingOptionId:Yl.optional()}).refine(e=>!!(e.model||e.thinkingOptionId),`A delegation default must contain a Model or Thinking option`),Cf=U({byHarness:Pc(yf,Sf)}),wf=R().min(1).max(1024),Tf=U({idleRelease:_f.optional(),favorites:Pc(yf,V(wf).max(2048)).default({}),newThread:xf.optional(),delegation:Cf.optional()});U({scope:vf,revision:z().int().nonnegative(),values:Tf}),U({scope:vf.default(`external`)});let Ef=Oc(`kind`,[U({kind:G(`idleRelease`),value:_f}),U({kind:G(`favorite`),harnessId:Cl,modelId:wf,enabled:B()}),U({kind:G(`favorites`),harnessId:Cl,modelIds:V(wf).max(2048)}),U({kind:G(`newThread`),lastHarness:Cl.optional(),harnessId:Cl.optional(),configuration:bf.optional()}),U({kind:G(`delegation`),harnessId:Cl,configuration:Sf.nullable()})]);U({scope:vf.default(`external`),operations:V(Ef).min(1).max(256),initializeOnly:B().optional(),expectedRevision:z().int().nonnegative().optional()}).superRefine((e,t)=>{for(let n of e.operations)n.kind===`newThread`&&(!n.lastHarness&&!n.configuration||!!n.harnessId!=!!n.configuration)&&t.addIssue({code:`custom`,message:`A default Harness or complete configuration is required`})}),U({version:G(1),revision:z().int().nonnegative(),scopes:Pc(vf,Tf)});let Df=z().finite().nonnegative(),Of=U({input:Df,output:Df,cacheRead:Df.optional(),cacheWrite:Df.optional(),cacheWrite1h:Df.optional()}),kf=R().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);U({path:R(),entries:V(U({key:R(),price:Of})),error:R().nullable()}),U({}),U({key:kf,price:Of.nullable(),previousKey:kf.optional()}),U({model:kf});let Af=U({official:B().optional(),canonicalModelId:R().min(1).optional(),provider:R().min(1).max(512),model:R().min(1).max(512),price:Of});U({price:Of.nullable(),suggestions:V(Af).max(6).optional()});let jf=[`today`,`7d`,`30d`,`90d`,`all`],Mf=z().int().min(0).max(2**53-1),Nf=R().regex(/^\d{4}-\d{2}-\d{2}$/u),Pf=R().min(1).max(128),Ff=R().min(1).max(512),If=R().min(1).max(4096);U({range:W(jf),timeZone:R().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:Pf.optional(),model:Ff.nullable().optional(),project:If.nullable().optional(),date:Nf.optional()});let Lf=U({requests:Mf,inputTokens:Mf,cachedInputTokens:Mf,cacheWriteInputTokens:Mf,cacheKnownInputTokens:Mf,cacheHitCachedInputTokens:Mf,cacheHitInputTokens:Mf,outputTokens:Mf,reasoningOutputTokens:Mf,costUsd:z().finite().min(0),unpricedRequests:Mf,unmeteredRequests:Mf}),Rf=Lf.shape,zf=U({harness:Pf,sessionId:R().min(1).max(512),project:If.nullable(),title:R().min(1).max(200).optional(),models:V(Ff).max(16),firstAtMs:Mf,lastAtMs:Mf,...Rf});U({range:W(jf),from:Nf.nullable(),to:Nf,filters:U({harness:Pf.nullable(),model:Ff.nullable(),unknownModel:B(),project:If.nullable(),unknownProject:B(),date:Nf.nullable()}),reading:U({complete:B(),sources:Mf,read:Mf}),failures:V(U({harness:Pf,message:R().max(2048)})).max(256),options:U({harnesses:V(Pf).max(256),models:V(Ff.nullable()).max(4096),projects:V(If.nullable()).max(4096)}),modelLabels:V(U({harness:Pf,model:Ff,label:Ff})).max(4096).optional(),credits:V(U({harness:Pf,model:Ff.nullable(),credits:z().finite().min(0),reportedRequests:Mf,requests:Mf})).max(4096).optional(),totals:Lf,daily:V(U({date:Nf,harness:Pf,...Rf})).max(2e5),hourly:V(U({weekday:z().int().min(0).max(6),hour:z().int().min(0).max(23),...Rf})).max(168),byHarness:V(U({harness:Pf,...Rf})).max(256),byModel:V(U({model:Ff.nullable(),...Rf,harnessPricedRequests:Mf})).max(4096),byProject:V(U({project:If.nullable(),...Rf})).max(4096),sessions:V(zf).max(100),recentSessions:V(zf).max(100).optional()}),H({threadId:K}),H({discarded:B()});let Bf=Oc(`type`,[H({id:R().min(1),type:G(`choice`),prompt:R(),options:V(H({value:R().min(1),label:R(),description:R().optional()})).min(1),multiple:B(),allowOther:B(),optional:B()}),H({id:R().min(1),type:G(`text`),prompt:R(),multiline:B(),secret:G(!1),optional:B(),placeholder:R().optional(),prefill:R().optional()})]),Vf=H({interactionId:R().min(1),turnId:R().min(1),title:R().optional(),questions:V(Bf).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});U({threadId:R().min(1)}),H({questions:V(Vf)}),U({threadId:R().min(1),turnId:R().min(1),interactionId:R().min(1),answers:Pc(R(),V(R())),cancelled:B().default(!1)}),H({accepted:G(!0)});let Hf=H({path:R(),oldText:R().nullable(),newText:R()});H({sessionId:R().min(1),turn:z().int().nonnegative(),path:R().min(1).optional()}),H({diffs:V(Hf)}),U({}),U({}),H({reference:H({sessionId:R().min(1),epoch:R().min(1),turn:z().int().nonnegative(),seq:z().int().nonnegative(),callId:R().min(1),part:z().int().nonnegative(),version:R().min(1)}),length:z().int().nonnegative(),bytes:z().int().nonnegative()}),U({title:R().trim().min(1).max(200),type:W([`info`,`warning`,`danger`]),body:R().trim().min(1).max(16384)}),U({}),U({url:R().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)}),Object.freeze(/* @__PURE__ */ `codexhost/console/remote-connections.codexhost/runtime/status.codexhost/remote/ssh-setup.codexhost/harness/plugins/list.codexhost/harness/display-settings/capabilities.codexhost/harness/display-settings/get.codexhost/harness/display-settings/set.codexhost/harness/inspect.codexhost/harness/installation.codexhost/harness/installation/start.codexhost/harness/installation/status.codexhost/harness/launch-settings/get.codexhost/harness/launch-settings/set.codexhost/harness/web-ui/open.codexhost/harness/accounts/sources.codexhost/harness/accounts/list.codexhost/harness/accounts/inspect.codexhost/harness/credential-imports.codexhost/harness/session-import/sources.codexhost/harness/session-import/list.codexhost/harness/session-import/import.codexhost/account/list.codexhost/account/refresh.codexhost/account/usage/inspect.codexhost/usage/model-prices/get.codexhost/usage/model-prices/set.codexhost/usage/model-prices/default.codexhost/usage/statistics/get.codexhost/update/check.codexhost/update/start.codexhost/update/status`.split(`.`));let Uf=W([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),Wf=W([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);U({threadId:R(),title:R(),harnessId:R(),state:Uf,reason:Wf,inactiveMs:z().nonnegative()}),U({threadId:K,turnId:wl});let Gf=H({email:R().trim().min(1).max(320).optional(),label:R().trim().min(1).max(256).optional(),plan:R().trim().min(1).max(128).optional(),credits:Hl.optional(),balance:Ul.optional()}).strict();function Kf(e){return e.refine(e=>{let t=e;return t.credits!==void 0||t.balance!==void 0},{message:`Account must report either credits or a balance`})}let qf=Kf(Gf),Jf={harnessId:Cl,harnessName:R().trim().min(1).max(128)},Yf=H(Jf).strict();H({}).strict(),H({sources:V(Yf).max(128)}).strict(),H({harnessId:Cl,refresh:B().optional()}).strict(),H({...Jf,account:qf.nullable(),accounts:V(qf).max(8).optional()}).strict(),H({refresh:B().optional()}).strict(),H({accounts:V(Kf(Gf.extend(Jf))).max(128)}).strict(),H({harnessId:lu,model:ql.optional(),thinkingOptionId:Yl.optional(),permissionModeId:El.optional(),prewarm:G(!0).optional()}).strict();let Xf=R().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);H({harnessId:lu}).strict().extend({path:Xf.nullable()}),H({path:Xf.nullable(),restartRequired:B()}).strict(),H({harnessId:Cl,action:W([`check`,`update`,`install`]),confirmedVersion:R().min(1).max(128).optional()}).strict().refine(({action:e,confirmedVersion:t})=>e===`update`||t===void 0);let Zf=H({currentVersion:R().min(1).max(128),latestVersion:R().min(1).max(128),updateAvailable:B(),canUpdate:B(),latestVerifiedVersion:R().min(1).max(128).optional(),confirmationRequired:G(!0).optional(),versionKind:W([`cli`,`application`]).optional(),manualUpdateUrl:Zs().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:R().max(2048).optional(),messageCode:R().min(1).max(128).optional(),notice:xl.optional(),latestVersionKind:W([`unknown`,`tracking-branch`]).optional()}).strict();H({taskId:R().uuid()}).strict(),Oc(`status`,[H({taskId:R().uuid(),status:G(`running`)}).strict(),H({taskId:R().uuid(),status:G(`succeeded`),result:Zf}).strict(),H({taskId:R().uuid(),status:G(`failed`),error:H({code:z().int(),message:R().min(1).max(2048)}).strict()}).strict()]);let Qf=R().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),$f=R().trim().min(1),ep=W([`free`,`go`,`plus`,`pro`,`prolite`,`team`,`self_serve_business_prolite`,`self_serve_business_usage_based`,`business`,`ent26`,`enterprise_cbp_automation`,`enterprise_cbp_usage_based`,`enterprise`,`edu`,`edu_plus`,`edu_pro`,`unknown`]),tp=H({accountId:Qf,label:$f.max(256),email:R().email().max(320).optional(),planType:ep.optional()}).strict(),np=W([`ready`,`unavailable`]);H({version:G(2),currentAccountId:Qf.nullable(),phase:np,revision:z().int().nonnegative(),instanceId:$f.max(1024).optional(),accounts:V(tp).max(1)}).strict(),H({accountId:Qf,refresh:B().optional()}).strict(),H({accountId:Qf,usage:Il.nullable(),accountCredits:Hl.optional(),freshness:W([`live`,`cached`]),observedAt:R().datetime().nullable()}).strict();let rp=1e3,ip=R().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),ap=ip.max(1024),op=H({nativeSessionId:ap,title:ip.max(4096).nullable(),updatedAt:z().int().nonnegative().max(864e13),cwd:ip.max(16384),running:B().nullable()}).strict();H({}).strict(),H({harnesses:V(H({harnessId:lu,name:ip.max(128)}).strict()).max(128)}).strict(),H({harnessId:lu,query:R().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:z().int().nonnegative().safe().optional(),limit:z().int().min(1).max(rp).optional()}).strict(),H({candidates:V(op).max(rp),total:z().int().nonnegative().safe()}).strict(),H({harnessId:lu,nativeSessionId:ap}).strict(),H({threadId:ip.max(1024).pipe(K)}).strict();let sp=R().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),cp=ap,lp=op;H({}).strict(),H({candidates:V(lp).max(1e3)}).strict(),H({nativeSessionId:cp}).strict(),H({threadId:sp.max(1024).pipe(K)}).strict(),H({threadId:K,lastTurnId:wl}).strict(),H({threadId:K}).strict();let up=R().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();H({commands:V(H({id:up,invocation:R().min(1).max(128),label:R().trim().min(1).max(128),description:R().trim().min(1).max(512).optional(),localizations:bl.optional(),argumentMode:W([`none`,`text`]),kind:W([`command`,`skill`]).optional()}).strict()),warnings:V(R().min(1)).optional(),source:W([`live`,`static`]).optional()}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.commands.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Harness command IDs must be unique`,path:[`commands`,r,`id`]}),n.add(i.id)}),H({harnessId:Cl,cwd:R().min(1).optional()}).strict(),H({threadId:K}).strict(),H({threadId:K,commandId:up,turnId:wl.optional(),arguments:gl.optional()}).strict(),H({accepted:G(!0),turnId:wl.optional()}).strict();let dp=G(`2.0`).optional(),fp=Sc().optional(),pp=R().min(1),mp=Ec([R(),z().int()]),hp=H({code:z().int(),message:R(),data:hl.optional()}).catchall(hl).superRefine(ul([`data`]));Ec([H({jsonrpc:dp,id:mp,method:pp,params:hl.optional(),result:fp,error:fp}).catchall(hl).superRefine(ul([`jsonrpc`,`params`,`result`,`error`])),H({jsonrpc:dp,id:fp,method:pp,params:hl.optional(),result:fp,error:fp}).catchall(hl).superRefine(ul([`jsonrpc`,`id`,`params`,`result`,`error`])),H({jsonrpc:dp,id:mp,method:fp,params:fp,result:hl,error:fp}).catchall(hl).superRefine(ul([`jsonrpc`,`method`,`params`,`error`])),H({jsonrpc:dp,id:mp,method:fp,params:fp,result:fp,error:hp}).catchall(hl).superRefine(ul([`jsonrpc`,`method`,`params`,`result`]))]);let gp=R().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});U({harnessId:Cl,nativeSessionId:gp,locator:hl.optional(),formatVersion:G(1)}).superRefine(ul([`locator`])),U({harnessId:Cl,nativeSessionId:gp,nativeTurnKey:gp,formatVersion:G(1)}),U({harnessId:Cl,nativeSessionId:gp,checkpointId:gp,locator:hl.optional(),formatVersion:G(1)}).superRefine(ul([`locator`]));let _p=R().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),vp=W([`npm`,`windows-installer`,`macos-dmg`,`linux-archive`]),yp=U({version:_p,installation:vp,phase:W([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),updatedAt:z().int().nonnegative(),downloadedBytes:z().int().nonnegative().optional(),totalBytes:z().int().positive().optional(),error:R().min(1).max(500).nullable(),serviceStopOutput:R().optional()}).superRefine((e,t)=>{e.downloadedBytes!==void 0&&e.totalBytes!==void 0&&e.downloadedBytes>e.totalBytes&&t.addIssue({code:`custom`,path:[`downloadedBytes`],message:`downloadedBytes must not exceed totalBytes`})});U({});let bp=R().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u,`release notes URL must identify a codexhost GitHub Release`);U({currentVersion:_p,installation:vp.nullable(),latestVersion:_p.nullable(),updateAvailable:B(),installationAvailable:B(),releaseNotes:R().min(1).max(2e4).nullable(),releaseNotesUrl:bp.nullable(),status:yp.nullable(),error:R().min(1).max(500).nullable()}),U({status:yp}),U({status:yp.nullable()});let xp=U({icon:R().min(1).max(16).optional(),title:R().min(1).max(120),body:R().min(1).max(1200),contributors:V(R().min(1).max(39)).max(30)}),Sp=U({summary:R().min(1).max(600).optional(),themes:V(xp).min(1).max(12)}),Cp=U({version:_p,publishedAt:ll(),url:R().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),zh:Sp.nullable(),en:Sp.nullable()}).refine(e=>e.zh!==null||e.en!==null,{message:`an announcement needs at least one language`});U({manual:B().optional()}),U({announcement:Cp.nullable(),unread:B()}),U({version:_p});let wp=RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);function Tp(e){let[t,...n]=e.trim().split(/\r?\n/u);if(t!==`[codexhost thread watch] Read each Thread's result, then continue your task:`)return;let r=[];for(let e of n){if(!e.trim())continue;let t=wp.exec(e);if(!t)return;let[,n=``,i=``,a,o]=t;r.push({threadId:i,label:n,outcome:a,...o?{note:o}:{}})}return r.length>0?r:void 0}let Ep=`<response-annotations>`,Dp=`</response-annotations>`,Op=/## My request(?: for Codex)?:/gu;function kp(e){if(e.length===0)return``;let t=e.map(({text:e,annotation:t})=>({text:e,...t===void 0?{}:{annotation:t}}));return`\n# Response annotations:\nEach item contains text selected from an earlier Codex response and may include a user comment. Treat items as Annotation 1, Annotation 2, and so on in array order. Use every selection as context and address every comment. For every annotation you address, include its inline directive \`:codex-annotation{index="N"}\`, where N is its one-based array position (for example, \`:codex-annotation{index="1"}\`). Do not use unstructured annotation labels.\n${Ep}\n${JSON.stringify(t)}\n${Dp}\n`}function Ap(e,t){let n=kp(e);return n===``?t:`${n}\n## My request:\n${t}\n`}function jp(e){let t=e.trimStart().startsWith(`# Response annotations:`)?0:e.length,n=e.indexOf(`\n${Ep}\n`,t);if(n<0)return``;let r=n+1+22+1,i=e.indexOf(`\n${Dp}`,r);return i<0?``:e.slice(r,i)}function Mp(e){return{annotations:Fp(e),body:Np(e)}}function Np(e){let t=0;for(let n of e.matchAll(Op))t=n.index+n[0].length;return e.slice(t).trim()}function Pp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Fp(e){let t=jp(e);if(t===``)return[];let n;try{n=JSON.parse(t)}catch{return[]}if(!Array.isArray(n)||n.length===0)return[];let r=[];for(let e of n){if(!Pp(e))return[];let{text:t,annotation:n}=e;if(typeof t!=`string`||t.length===0||n!==void 0&&(typeof n!=`string`||n.length===0))return[];r.push({text:t,...n===void 0?{}:{annotation:n}})}return r}function Ip(e){return Fp(e)}let Lp=W([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);H({runningVersion:R().nullable(),installedVersion:R().nullable(),restartRequired:B(),remote:B(),updateSupported:B(),update:H({phase:Lp,targetVersion:R().nullable(),error:R().nullable()})});let Rp=H({version:R().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();H({hostname:R().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:z().int().min(1).max(65535).nullable(),identity:R().max(4096).nullable(),action:W([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:B().optional(),version:R().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),H({state:W([`installed`,`not-installed`])}).strict();let q=R().min(1).max(1024),zp={hostId:q.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)},Bp={...zp,threadId:q},Vp=R().min(1).max(8e3),Hp={text:Vp,requestId:q};Oc(`accepted`,[H({accepted:G(!0),startQueuedItemId:q.optional()}),H({accepted:G(!1),code:W([`remote/queue-unavailable`,`remote/steer-unavailable`,`remote/turn-changed`,`remote/send-rejected`,`session/queue-item-not-found`,`session/queue-item-starting`]),message:R()})]),Oc(`available`,[H({available:G(!1)}),H({available:G(!0),items:V(H({id:q,clientUserMessageId:q,preview:R().max(801)})).max(100)})]);let Up=Oc(`kind`,[U({kind:G(`hosts`)}),U({kind:G(`create`),...zp,cwd:R().min(1).max(8192),epoch:q}),U({kind:G(`projectHarnesses`),...zp,epoch:q}),U({kind:G(`inspectHarness`),...zp,epoch:q,cwd:R().min(1).max(8192),harnessId:q}),U({kind:G(`startSelected`),...zp,epoch:q,cwd:R().min(1).max(8192),harnessId:q,model:R().min(1).max(4096),serviceTier:W([`priority`,`ultrafast`]).optional(),reasoningEffort:q.optional()}),U({kind:G(`status`),...Bp}),U({kind:G(`list`),...zp,cursor:R().nullable(),archived:B(),includeLoaded:G(!0).optional()}),U({kind:G(`read`),...Bp,page:U({cursor:R().min(1).max(8192).nullable(),epoch:q.optional(),sortDirection:W([`asc`,`desc`]).optional(),limit:z().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),U({kind:G(`usage`),...Bp,epoch:q}),U({kind:G(`configure`),...Bp,epoch:q,modelId:q.optional(),serviceTier:Kl.optional(),thinkingOptionId:q.optional(),permissionModeId:q.optional()}).refine(e=>[e.modelId,e.thinkingOptionId,e.permissionModeId].filter(e=>e!==void 0).length===1,`Select exactly one remote setting`).refine(e=>e.serviceTier===void 0||e.modelId!==void 0,{message:`A service tier requires a Model ID`}),U({kind:G(`prompt`),...Bp,epoch:q,text:Vp,requestId:q.optional()}),U({kind:G(`queue`),...Bp,epoch:q}),U({kind:G(`delivery`),...Bp,epoch:q,action:Oc(`kind`,[U({kind:G(`enqueue`),...Hp}),U({kind:G(`steer`),...Hp,turnId:q}),U({kind:G(`remove`),itemId:q}),U({kind:G(`start`),itemId:q,onlyIfHead:G(!0).optional()}),U({kind:G(`sendNow`),itemId:q})])}),U({kind:G(`interrupt`),...Bp,epoch:q,turnId:q}),U({kind:G(`rename`),...Bp,epoch:q,name:R().min(1).max(512)}),U({kind:G(`archive`),...Bp,epoch:q,archived:B()}),U({kind:G(`respond`),...Bp,epoch:q,requestId:Ec([q,z().int()]),result:Pc(R(),bc())})]),Wp=R().min(1).max(1024),Gp=H({hostId:Wp,displayName:R().min(1).max(1024),source:W([`codex-managed`,`discovered`]),sshAlias:R().max(1024).nullable(),sshHost:R().min(1).max(1024),sshPort:z().int().min(1).max(65535).nullable(),identity:R().max(4096).nullable(),autoConnect:B(),connectionAnalyticsId:R().max(1024).optional()}),Kp=U({displayName:R().min(1).max(1024),hostname:R().min(1).max(1024),sshPort:z().int().min(1).max(65535).nullable(),identity:R().max(4096).nullable()});Oc(`action`,[U({action:G(`session`),operation:Up}),U({action:G(`list`)}),U({action:G(`catalog`)}),U({action:G(`read-thread`),hostId:Wp.refine(e=>e!==`local`),input:Jd}),U({action:G(`save`),draft:Kp,previous:Gp.nullable()}),U({action:G(`remove`),previous:Gp}),U({action:G(`connect`),hostId:Wp,enabled:B()}),U({action:G(`state`),hostId:Wp}),U({action:G(`runtime`),hostId:Wp}),U({action:G(`update`),hostId:Wp.refine(e=>e!==`local`),version:Rp.shape.version})]),Ec([U({result:hl}),U({error:U({code:z().int(),message:R()})})]),U({prompt:R().trim().min(1).max(2e3),cwd:R().max(4096).nullable()}),R().trim().min(1).max(60).nullable();let qp=R().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),Jp=Ec([R(),H({en:R()}).catchall(R())]),Yp=H({title:Jp.optional(),description:Jp.optional(),icon:R().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:R().optional()});H({extensions:V(H({id:qp,name:R().min(1).max(214),version:R().min(1).max(128),format:G(`dsh`),supportedTargets:Mc([G(`web`)]),enabledTargets:V(G(`web`)).max(1),source:R().min(1).max(4096),projectUrl:R().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:R(),meta:Yp.optional(),loadError:R().optional()})),loadedIds:V(qp),safeMode:B(),storeError:R().optional()});let Xp=R().trim().max(2048).url({protocol:/^https?$/u,normalize:!0}).refine(e=>!/[\s\\?#]/u.test(e)&&!e.split(`/`)[2]?.includes(`@`),`Use an HTTP(S) registry URL without credentials, a query, or a fragment.`).transform(e=>e.endsWith(`/`)?e:`${e}/`);H({spec:R().trim().min(1).max(4096),registry:Xp.optional()}).strict(),H({id:qp,enabled:B()}).strict(),H({id:qp}).strict(),G(1);function Zp(e){return{code:{copyLabel:e(`copy`),copiedLabel:e(`copied`),toolbarLabels:{codeLabel:e(`codeBlock.title`),wrapLabel:e(`codeBlock.wrap`),unwrapLabel:e(`codeBlock.unwrap`)}},footnotes:e(`markdown.footnotes`)}}function Qp(e){return{label:t=>e(`annotation.label`,{index:t}),railLabel:t=>e(`annotation.chipLabel`,{index:t}),railTitle:(t,n)=>e(`annotation.title`,{index:t,excerpt:n}),remove:t=>e(`annotation.remove`,{index:t}),selectedText:e(`annotation.selectedText`),userComment:e(`annotation.userComment`)}}let $p=`@deepseek-ai/dsh-client-ui-chat/ThreadWatchNotice.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify($p)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=$p,e.textContent=`._5b1uNW_card{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-base);width:fit-content;max-width:100%;color:var(--dsw-alias-label-secondary);font-size:var(--dsh-content-font-size-secondary,13px);align-items:flex-start;gap:10px;padding:10px 14px;line-height:20px;display:flex}._5b1uNW_list{min-width:0;margin:0;padding:0;list-style:none}._5b1uNW_entry+._5b1uNW_entry{margin-top:10px}._5b1uNW_line{align-items:center;gap:8px;min-width:0;display:flex}._5b1uNW_line>svg,._5b1uNW_bell{flex-shrink:0}._5b1uNW_bell{color:var(--dsw-alias-label-tertiary);margin-top:3px}._5b1uNW_title{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-primary);overflow:hidden}._5b1uNW_outcome,._5b1uNW_open{white-space:nowrap;flex-shrink:0}._5b1uNW_outcome[data-outcome=completed]{color:var(--dsw-alias-state-success-primary)}._5b1uNW_outcome[data-outcome=failed]{color:var(--dsw-alias-state-error-primary)}._5b1uNW_open a{color:var(--dsw-alias-state-business-primary);text-decoration:none}._5b1uNW_open a:hover{text-decoration:underline}._5b1uNW_open a:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}._5b1uNW_note{color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;margin:4px 0 0 24px}@media (width<=480px){._5b1uNW_line{flex-wrap:wrap}._5b1uNW_title{flex:calc(100% - 52px)}._5b1uNW_outcome{margin-left:24px}}`,document.head.appendChild(e)}var em={bell:`_5b1uNW_bell`,card:`_5b1uNW_card`,entry:`_5b1uNW_entry`,line:`_5b1uNW_line`,list:`_5b1uNW_list`,note:`_5b1uNW_note`,open:`_5b1uNW_open`,outcome:`_5b1uNW_outcome`,title:`_5b1uNW_title`};let tm=()=>()=>{};function nm({entry:e,links:t,t:n}){let r=`codex://threads/${e.threadId}`,i=()=>t?.describe?.(r)?.title,a=(0,d.useSyncExternalStore)(t?.resolve.subscribe??tm,i,i),o=a!==void 0;return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:em.entry,"data-thread-watch-entry":e.threadId,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:em.line,children:[o?t?.describe?.(r)?.icon:/* @__PURE__ */ (0,f.jsx)(p.ReferenceIconRegular,{kind:`session`,size:14}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:em.title,title:a??e.label,children:a??e.label}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:em.outcome,"data-outcome":e.outcome,children:n(`message.watch.${e.outcome}`)}),o&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:em.open,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownAnchor,{href:r,glyph:!1,children:[n(`message.watch.open`)]})})]}),e.note!==void 0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:em.note,children:e.note})]})}function rm({entries:e,links:t,t:n}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:em.card,"data-thread-watch-notice":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.IconBellOutlineRegular,{className:em.bell}),/* @__PURE__ */ (0,f.jsx)(`ul`,{className:em.list,children:e.map((e,r)=>/* @__PURE__ */ (0,f.jsx)(nm,{entry:e,links:t,t:n},r))})]})}let im=`@deepseek-ai/dsh-client-ui-chat/MessageItem.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(im)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=im,e.textContent=`.h5bUAG_userRow{flex-direction:column;align-items:flex-end;gap:6px;display:flex}.h5bUAG_noticeRow{flex-direction:column;align-items:center;gap:6px;min-width:0;display:flex}.h5bUAG_noticeStack{min-width:0;max-width:100%}.h5bUAG_userStack{min-width:0;max-width:min(calc(var(--dsh-chat-content-width,748px) * .702), 82%);flex-direction:column;align-items:flex-end;gap:8px;display:flex}.h5bUAG_annotationRow{flex-wrap:wrap;justify-content:flex-end;gap:6px;display:flex}.h5bUAG_bubble{background:var(--dsw-specific-bubble);border-radius:var(--dsw-radius-xl);max-width:100%;font-size:var(--dsh-content-font-size,14px);line-height:calc(22px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-primary);white-space:pre-wrap;word-break:break-word;padding:10px 16px}body[data-codexhost-wallpaper] .h5bUAG_bubble{background:color-mix(in srgb, var(--dsw-specific-bubble) 84%, transparent);backdrop-filter:blur(12px)}body[data-codexhost-wallpaper] [data-chat-flow-key]:not([data-chat-flow-key] *,[data-chat-near-viewport]) .h5bUAG_bubble{backdrop-filter:none}@supports (-webkit-touch-callout:none){body[data-codexhost-wallpaper] .h5bUAG_userRow{transform:translateZ(0)}}.h5bUAG_referenceSummary{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}.h5bUAG_contextRow{padding:2px 0}.h5bUAG_compactionRow{--dsh-compaction-header-height:calc(24px + var(--dsh-content-font-delta,0px));padding:2px 0}.h5bUAG_compactionButton{width:100%;height:var(--dsh-compaction-header-height);border-radius:var(--dsw-radius-sm);min-width:0;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:left;background:0 0;border:none;align-items:center;padding:0;transition:color .1s;display:flex}.h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton{z-index:7;background:var(--dsw-alias-bg-base);border-radius:0;position:sticky;top:0}body[data-codexhost-wallpaper] .h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton{background:color-mix(in srgb, var(--dsw-alias-bg-base) 78%, transparent);backdrop-filter:blur(12px)}body[data-codexhost-wallpaper] [data-chat-flow-key]:not([data-chat-flow-key] *,[data-chat-near-viewport]) .h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton{backdrop-filter:none}.h5bUAG_compactionBody :has(>[data-code-block-banner]){top:var(--dsh-compaction-header-height)}@media (hover:hover){.h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton:hover{background:var(--dsw-alias-interactive-bg-hover-solid)}.h5bUAG_compactionButton:hover{color:var(--dsw-alias-label-secondary)}.h5bUAG_compactionButton:not(:disabled):hover{background:var(--dsw-alias-interactive-bg-hover)}}.h5bUAG_compactionButton:not(:disabled){cursor:pointer}.h5bUAG_compactionButton:not(:disabled):active{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover)}.h5bUAG_compactionLeading{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));color:inherit;flex:none;place-items:center;margin-right:6px;display:inline-grid}.h5bUAG_compactionLeading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}.h5bUAG_compactionContextIcon,.h5bUAG_compactionDisclosureIcon{grid-area:1/1;justify-content:center;align-items:center;display:inline-flex}.h5bUAG_compactionDisclosureIcon,.h5bUAG_compactionButton:not(:disabled):hover .h5bUAG_compactionContextIcon,.h5bUAG_compactionButton:not(:disabled):focus-visible .h5bUAG_compactionContextIcon{opacity:0}.h5bUAG_compactionButton:not(:disabled):hover .h5bUAG_compactionDisclosureIcon,.h5bUAG_compactionButton:not(:disabled):focus-visible .h5bUAG_compactionDisclosureIcon{opacity:1}.h5bUAG_compactionTitle{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:inherit;flex:none}.h5bUAG_compactionSep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.h5bUAG_compactionSummary{min-width:0;color:inherit;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.h5bUAG_compactionBody{padding:4px 0 4px calc(22px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px))}.h5bUAG_retryRow{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px))}.h5bUAG_retrySummary{border-radius:var(--dsw-radius-sm);width:fit-content;max-width:100%;color:inherit;cursor:pointer;user-select:none;align-items:center;gap:7px;padding:2px 0;list-style:none;display:inline-flex}.h5bUAG_retrySummary::-webkit-details-marker{display:none}.h5bUAG_retrySummary:after{content:"";border-bottom:1.5px solid;border-right:1.5px solid;flex:none;width:6px;height:6px;margin-right:2px;transition:transform .12s;transform:rotate(-45deg)}.h5bUAG_retrySummary:hover{color:var(--dsw-alias-label-secondary)}@media (prefers-reduced-motion:reduce){.h5bUAG_compactionButton{transition:none}}.h5bUAG_retrySummary:focus-visible{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}.h5bUAG_retryText{overflow-wrap:anywhere;min-width:0}.h5bUAG_retryRow[open] .h5bUAG_retrySummary:after{transform:rotate(45deg)}.h5bUAG_retryDetails{overflow-wrap:anywhere;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));gap:2px;margin-top:3px;padding-left:14px;display:grid}.h5bUAG_retryDetailLabel{color:var(--dsw-alias-label-secondary)}.h5bUAG_turnErrorRow{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));grid-template-columns:10px minmax(0,1fr) auto;align-items:start;gap:8px;padding:2px 0;display:grid}.h5bUAG_turnErrorDot{margin-top:5px}.h5bUAG_turnErrorCopy{overflow-wrap:anywhere;min-width:0}.h5bUAG_turnErrorTitle{color:var(--dsw-alias-state-error-primary);margin-right:6px;font-weight:600}.h5bUAG_turnErrorMessage{color:var(--dsw-alias-label-secondary)}.h5bUAG_turnErrorCode{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-markdown-code-block-small)}.h5bUAG_maxTokensTitle{color:var(--dsw-alias-state-warn-primary);margin-right:6px;font-weight:600}.h5bUAG_attachmentRow{flex-wrap:wrap;justify-content:flex-end;gap:8px;max-width:100%;display:flex}.h5bUAG_pendingAttachment{flex-direction:column;align-items:flex-end;gap:4px;min-width:0;display:flex}.h5bUAG_fileCard{border:.5px solid var(--dsw-alias-border-l2,#0000001f);border-radius:var(--dsw-radius-xl);background:var(--dsw-specific-input-major,transparent);box-sizing:border-box;flex:none;align-items:center;gap:10px;width:240px;min-height:64px;padding:8px 12px;display:inline-flex}.h5bUAG_fileIcon{flex:none;width:28px;height:28px}.h5bUAG_fileContent{flex-direction:column;flex:1;min-width:0;display:flex}.h5bUAG_fileName{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px;overflow:hidden}.h5bUAG_fileMeta{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-tertiary,#00000073);font-size:12px;line-height:15px;overflow:hidden}.h5bUAG_editAction{color:inherit;cursor:pointer;border-radius:var(--dsw-radius-sm);background:0 0;border:0;justify-content:center;align-items:center;width:28px;height:28px;padding:6px;display:inline-flex}.h5bUAG_editAction:hover{background:var(--dsw-alias-interactive-bg-hover)}.h5bUAG_editAction svg{width:15px;height:15px}.h5bUAG_userStack:has(.h5bUAG_sentEditor){width:100%}.h5bUAG_sentEditor{box-sizing:border-box;border:1px solid var(--dsw-alias-border-main);border-radius:12px;width:100%;min-width:0;padding:12px}.h5bUAG_sentEditor textarea{resize:vertical;width:100%;min-height:100px;color:inherit;font:inherit;box-sizing:border-box;background:0 0;border:0;outline:0;line-height:1.6}.h5bUAG_sentEditor:focus-within{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}.h5bUAG_sentEditorActions{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}`,document.head.appendChild(e)}var J={annotationRow:`h5bUAG_annotationRow`,attachmentRow:`h5bUAG_attachmentRow`,bubble:`h5bUAG_bubble`,compactionBody:`h5bUAG_compactionBody`,compactionButton:`h5bUAG_compactionButton`,compactionContextIcon:`h5bUAG_compactionContextIcon`,compactionDisclosureIcon:`h5bUAG_compactionDisclosureIcon`,compactionLeading:`h5bUAG_compactionLeading`,compactionRow:`h5bUAG_compactionRow`,compactionSep:`h5bUAG_compactionSep`,compactionSummary:`h5bUAG_compactionSummary`,compactionTitle:`h5bUAG_compactionTitle`,contextRow:`h5bUAG_contextRow`,editAction:`h5bUAG_editAction`,fileCard:`h5bUAG_fileCard`,fileContent:`h5bUAG_fileContent`,fileIcon:`h5bUAG_fileIcon`,fileMeta:`h5bUAG_fileMeta`,fileName:`h5bUAG_fileName`,maxTokensTitle:`h5bUAG_maxTokensTitle`,noticeRow:`h5bUAG_noticeRow`,noticeStack:`h5bUAG_noticeStack`,pendingAttachment:`h5bUAG_pendingAttachment`,referenceSummary:`h5bUAG_referenceSummary`,retryDetailLabel:`h5bUAG_retryDetailLabel`,retryDetails:`h5bUAG_retryDetails`,retryRow:`h5bUAG_retryRow`,retrySummary:`h5bUAG_retrySummary`,retryText:`h5bUAG_retryText`,sentEditor:`h5bUAG_sentEditor`,sentEditorActions:`h5bUAG_sentEditorActions`,turnErrorCode:`h5bUAG_turnErrorCode`,turnErrorCopy:`h5bUAG_turnErrorCopy`,turnErrorDot:`h5bUAG_turnErrorDot`,turnErrorMessage:`h5bUAG_turnErrorMessage`,turnErrorRow:`h5bUAG_turnErrorRow`,turnErrorTitle:`h5bUAG_turnErrorTitle`,userRow:`h5bUAG_userRow`,userStack:`h5bUAG_userStack`};let am=(0,d.memo)(function({node:e,title:t,fallbackSummary:n,t:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useMemo)(()=>Zp(r),[r]),s=e.summary!==null,c=s&&i,l=e.shadowedItemCount!==null&&e.shadowedTokenCount!==null?r(`message.compaction.completed`,{items:e.shadowedItemCount,tokens:e.shadowedTokenCount}):n??r(s?`message.compaction.expand`:`message.compaction.unavailable`);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.compactionRow,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:J.compactionButton,disabled:!s,"aria-expanded":s?c:void 0,onClick:()=>{a(e=>!e)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:J.compactionLeading,"aria-hidden":!0,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionContextIcon,"data-compaction-icon":`context`,children:/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionDisclosureIcon,"data-compaction-disclosure":c?`expanded`:`collapsed`,children:c?/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronRightOutlineRegular,{})})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionTitle,children:t??r(`message.compaction`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionSep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionSummary,children:l})]}),c&&e.summary!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.compactionBody,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:e.summary,labels:o})})]})}),om=`@deepseek-ai/dsh-client-ui-chat/ContextBody.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(om)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=om,e.textContent=`.p4W7kq_text{color:var(--dsw-alias-label-secondary);font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.p4W7kq_fields{border-top:.5px solid var(--dsw-alias-border-l2);flex-direction:column;gap:2px;margin:8px 0 0;padding-top:8px;display:flex}.p4W7kq_field{gap:8px;min-width:0;display:flex}.p4W7kq_fieldKey{min-width:96px;color:var(--dsw-alias-label-caption);flex:none}.p4W7kq_fieldValue{min-width:0;color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;flex:auto;margin:0}.p4W7kq_files{flex-wrap:wrap;gap:4px 12px;margin:0 0 8px;padding:0;list-style:none;display:flex}.p4W7kq_file{align-items:baseline;gap:6px;min-width:0;display:flex}.p4W7kq_filePath{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}.p4W7kq_fileAction{color:var(--dsw-alias-label-caption)}.p4W7kq_catalogNotice{color:var(--dsw-alias-label-caption);margin:0 0 6px}.p4W7kq_entries{flex-direction:column;gap:4px;margin:0;padding:0;list-style:none;display:flex}.p4W7kq_entry{gap:8px;min-width:0;display:flex}.p4W7kq_entryName{color:var(--dsw-alias-label-secondary);flex:none}.p4W7kq_entryDescription{min-width:0;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.p4W7kq_sections{flex-direction:column;gap:8px;margin:0;display:flex}.p4W7kq_section{flex-direction:column;gap:2px;min-width:0;display:flex}.p4W7kq_sectionName{color:var(--dsw-alias-label-caption)}.p4W7kq_sectionText{color:var(--dsw-alias-label-secondary);white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.p4W7kq_relaySender{color:var(--dsw-alias-label-caption);overflow-wrap:anywhere;margin:0 0 6px}.p4W7kq_recalls{flex-direction:column;gap:2px;margin:0 0 8px;padding:0;list-style:none;display:flex}.p4W7kq_recall{gap:8px;min-width:0;display:flex}.p4W7kq_recallLabel{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}.p4W7kq_recallCounts{color:var(--dsw-alias-label-caption);flex:none}`,document.head.appendChild(e)}var Y={catalogNotice:`p4W7kq_catalogNotice`,entries:`p4W7kq_entries`,entry:`p4W7kq_entry`,entryDescription:`p4W7kq_entryDescription`,entryName:`p4W7kq_entryName`,field:`p4W7kq_field`,fieldKey:`p4W7kq_fieldKey`,fieldValue:`p4W7kq_fieldValue`,fields:`p4W7kq_fields`,file:`p4W7kq_file`,fileAction:`p4W7kq_fileAction`,filePath:`p4W7kq_filePath`,files:`p4W7kq_files`,recall:`p4W7kq_recall`,recallCounts:`p4W7kq_recallCounts`,recallLabel:`p4W7kq_recallLabel`,recalls:`p4W7kq_recalls`,relaySender:`p4W7kq_relaySender`,section:`p4W7kq_section`,sectionName:`p4W7kq_sectionName`,sectionText:`p4W7kq_sectionText`,sections:`p4W7kq_sections`,text:`p4W7kq_text`};let sm=2e4;function cm(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function lm(e){let t=[];for(let n of e){if(n.type!==`text`){t.push({block:n});continue}let e=t[t.length-1];e!==void 0&&`text`in e?e.text+=n.text:t.push({text:n.text})}return t}function um(e){return lm(e).flatMap(e=>`block`in e?[e.block]:[])}function dm(e,t){return e.length>sm?`${e.slice(0,sm)}\n${t(`json.truncated`,{total:e.length})}`:e}function fm(e,t){return dm(typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e),t)}function pm({source:e,formRendered:t,t:n}){let r=cm(e);if(r===null)return null;let i=t?[`kind`,`form`]:[`kind`],a=Object.entries(r).filter(([e])=>!i.includes(e));return a.length===0?null:/* @__PURE__ */ (0,f.jsx)(`dl`,{className:Y.fields,"data-context-fields":!0,children:a.map(([e,t])=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.field,children:[/* @__PURE__ */ (0,f.jsx)(`dt`,{className:Y.fieldKey,children:e}),/* @__PURE__ */ (0,f.jsx)(`dd`,{className:Y.fieldValue,children:fm(t,n)})]},e))})}function mm({blocks:e,t}){return/* @__PURE__ */ (0,f.jsx)(f.Fragment,{children:e.map((e,n)=>/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownBlock`),payload:e,truncatedLabel:e=>t(`json.truncated`,{total:e})},n))})}function hm({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(f.Fragment,{children:lm(e).map((e,n)=>`text`in e?e.text!==``&&/* @__PURE__ */ (0,f.jsx)(`pre`,{className:Y.text,"data-context-text":!0,children:dm(e.text,t)},n):/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownBlock`),payload:e.block,truncatedLabel:e=>t(`json.truncated`,{total:e})},n))})}function gm({content:e,source:t,t:n}){return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(hm,{content:e,t:n}),/* @__PURE__ */ (0,f.jsx)(pm,{source:t,formRendered:!1,t:n})]})}function _m(e){let t=cm(e),n=t===null?void 0:t.changes;if(!Array.isArray(n))return null;let r=[],i=/* @__PURE__ */ new Set;for(let e of n){let t=cm(e);if(t===null)return null;let n=t.path;if(typeof n!=`string`||n===``)return null;let a=t.action;if(a!==`set`&&a!==`replace`&&a!==`remove`)return null;let o=t.digest;i.has(n)||(i.add(n),r.push({action:a,path:n,...typeof o==`string`?{digest:o}:{}}))}return r.length===0?null:r}function vm(e,t){return e===`remove`?`message.context.instructions.removed`:t?`message.context.instructions.loaded`:e===`set`?`message.context.instructions.added`:`message.context.instructions.updated`}function ym({content:e,source:t,t:n}){let r=_m(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(gm,{content:e,source:t,t:n});let i=cm(t)?.baseline===!0;return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Y.files,"data-context-files":!0,children:r.map(e=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Y.file,title:e.digest,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.filePath,children:e.path}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.fileAction,children:n(vm(e.action,i))})]},e.path))}),/* @__PURE__ */ (0,f.jsx)(hm,{content:e,t:n})]})}function bm(e){let t=cm(e),n=t===null?void 0:t.entries;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=cm(e);if(t===null)return null;let n=t.name,i=t.description;if(typeof n!=`string`||n===``||typeof i!=`string`)return null;r.push({name:n,description:i})}return r}function xm({content:e,source:t,t:n}){let r=bm(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(gm,{content:e,source:t,t:n});let i=cm(t)?.update===!0,a=r.slice(0,200),o=um(e);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[i&&/* @__PURE__ */ (0,f.jsx)(`p`,{className:Y.catalogNotice,"data-context-catalog-update":!0,children:n(`message.context.catalog.replaced`)}),/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Y.entries,"data-context-entries":!0,children:a.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Y.entry,children:[/* @__PURE__ */ (0,f.jsx)(`code`,{className:Y.entryName,children:e.name}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.entryDescription,children:e.description})]},t))}),a.length<r.length&&/* @__PURE__ */ (0,f.jsx)(`p`,{className:Y.catalogNotice,"data-context-entries-truncated":!0,children:n(`message.context.catalog.more`,{count:r.length-a.length})}),/* @__PURE__ */ (0,f.jsx)(mm,{blocks:o,t:n})]})}function Sm(e){let t=cm(e),n=t===null?void 0:t.sections;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=cm(e);if(t===null)return null;let n=t.name,i=t.text;if(typeof n!=`string`||n===``||typeof i!=`string`)return null;r.push({name:n,text:i})}return r.length===0?null:r}function Cm({content:e,source:t,t:n}){let r=Sm(t);return r===null?/* @__PURE__ */ (0,f.jsx)(gm,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:Y.catalogNotice,"data-context-snapshot-supersedes":!0,children:n(`message.context.snapshot.supersedes`)}),/* @__PURE__ */ (0,f.jsx)(`dl`,{className:Y.sections,"data-context-sections":!0,children:r.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.section,children:[/* @__PURE__ */ (0,f.jsx)(`dt`,{className:Y.sectionName,children:e.name}),/* @__PURE__ */ (0,f.jsx)(`dd`,{className:Y.sectionText,children:dm(e.text,n)})]},t))})]})}function wm({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(hm,{content:e,t})}function Tm({content:e,source:t,t:n}){let r=Em(t);return r===null?/* @__PURE__ */ (0,f.jsx)(gm,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:Y.relaySender,"data-context-relay-sender":!0,children:n(`message.context.relay.from`,{session:r})}),/* @__PURE__ */ (0,f.jsx)(hm,{content:e,t:n})]})}function Em(e){let t=cm(e)?.senderSessionId;return typeof t==`string`&&t!==``?t:null}function Dm(e){let t=cm(e),n=t===null?void 0:t.references;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=cm(e);if(t===null)return null;let n=t.label,i=t.retainedMessages,a=t.omittedMessages,o=t.truncated;if(typeof n!=`string`||n===``||typeof i!=`number`||typeof a!=`number`||typeof o!=`boolean`)return null;r.push({label:n,retained:i,omitted:a,truncated:o})}return r.length===0?null:r}function Om({content:e,source:t,t:n}){let r=Dm(t);return r===null?/* @__PURE__ */ (0,f.jsx)(gm,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Y.recalls,"data-context-recalls":!0,children:r.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Y.recall,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.recallLabel,children:e.label}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.recallCounts,children:n(`message.context.recall.counts`,{retained:e.retained,omitted:e.omitted})}),e.truncated&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.recallCounts,children:n(`message.context.recall.truncated`)})]},t))}),/* @__PURE__ */ (0,f.jsx)(hm,{content:e,t:n})]})}function km(e){let t=cm(e)?.summary;return typeof t==`string`&&t!==``?t:null}function Am(e,t){let n={rendered:null,summary:null,body:/* @__PURE__ */ (0,f.jsx)(gm,{...t})};switch(e){case`instructions`:return _m(t.source)===null?n:{rendered:`instructions`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(ym,{...t})};case`catalog`:return bm(t.source)===null?n:{rendered:`catalog`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(xm,{...t})};case`snapshot`:return Sm(t.source)===null?n:{rendered:`snapshot`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Cm,{...t})};case`notice`:{let e=km(t.source);return e===null?n:{rendered:`notice`,summary:e,body:/* @__PURE__ */ (0,f.jsx)(wm,{...t})}}case`relay`:return Em(t.source)===null?n:{rendered:`relay`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Tm,{...t})};case`recall`:return Dm(t.source)===null?n:{rendered:`recall`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Om,{...t})};case null:return n;
|
|
113
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function xo(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;xo(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}let So=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),Co=[`oneOf`,`anyOf`];function wo(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function To(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!So.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??wo(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Se(n,r,e.length===1?e[0]:To(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=wo(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Eo(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of So)if(t in e)return;let n=t.filter(e=>Co.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=To(t);else{let e=n[0],i=Co.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>To([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,ho(e,r))}function Do(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):ho(i,s),ho(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())xo(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Eo(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}ho(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Se(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Ao(t,`input`,e.processors),output:Ao(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Oo(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Oo(r.element,n);if(r.type===`set`)return Oo(r.valueType,n);if(r.type===`lazy`)return Oo(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Oo(r.innerType,n);if(r.type===`intersection`)return Oo(r.left,n)||Oo(r.right,n);if(r.type===`record`||r.type===`map`)return Oo(r.keyType,n)||Oo(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Oo(r.in,n)||Oo(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Oo(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Oo(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Oo(e,n))return!0;return!!(r.rest&&Oo(r.rest,n))}return!1}let ko=(e,t={})=>n=>{let r=go({...n,processors:t});return vo(e,r),bo(r,e),Do(r,e)},Ao=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=go({...i??{},target:a,io:t,processors:n});return vo(e,o),bo(o,e),Do(o,e)},jo=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Mo=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},No=(e,t)=>{jo(e,`minimum`,t),Mo(e,`maximum`,t)},Po=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Fo=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},Io=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Lo=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Ro=(e,t)=>jo(e,`minimum`,t.minimum),zo=(e,t)=>Mo(e,`maximum`,t.maximum),Bo=e=>(t,n)=>{Lo(t,n.format);let[r,i]=e[n.format];jo(t,`minimum`,r),Mo(t,`maximum`,i)},Vo={greater_than:(e,t)=>jo(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Mo(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Po(e,t.value),number_format:Bo(He),bigint_format:Bo(Ue),min_length:Ro,max_length:zo,length_equals:(e,t)=>No(e,t.length),min_size:Ro,max_size:zo,size_equals:(e,t)=>No(e,t.size),string_format:(e,t)=>{Lo(e,t.format),t.pattern&&Fo(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Io(e,t.mime)};function Ho(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Vo[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&jo(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&jo(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Mo(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Mo(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Po(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Io(t,i.mime);for(let e of i.patterns??[])Fo(t,e);return t}let Uo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Wo=/* @__PURE__ */ new Map([[Br,Cn],[Hr,wn]]),Go=e=>Wo.get(e)??e,Ko=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Ho(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Uo[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Go);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},qo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Ho(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):_o(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Jo=(e,t,n,r)=>{n.type=`boolean`},Yo=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Xo=(e,t,n,r)=>{n.not={}},Zo=(e,t,n,r)=>{let i=e._zod.def,a=fe(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Qo=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(_o(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(_o(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},$o=(e,t,n,r)=>{_o(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},es=(e,t,n,r)=>{_o(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},ts=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Ho(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=vo(a.element,t,{...r,path:[...r.path,`items`]})};function ns(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ns(t.out):t.type===`catch`?ns(t.innerType):e._zod.optin}let rs=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&_o(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Se(i.properties,e,vo(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?ns(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=vo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},is=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>vo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},as=(e,t,n,r)=>{let i=e._zod.def,a=vo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=vo(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},os=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>vo(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?vo(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?ns(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=Ho(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function ss(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=ss(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>ss(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Fn:Pn).source)),p}let cs=/* @__PURE__ */ new WeakMap;function ls(e){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=/* @__PURE__ */ new Map;for(let r of cs.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=ss(t,a,/* @__PURE__ */ new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}let us=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Ho(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=vo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Se(i.patternProperties,Go(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=vo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=cs.get(t);n||(n=[],cs.set(t,n),t.deferred.push(()=>ls(t))),n.push(e)}i.additionalProperties=vo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&ns(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},ds=(e,t,n,r)=>{let i=e._zod.def,a=vo(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},fs=(e,t,n,r)=>{let i=e._zod.def;vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ps=Symbol();function ms(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(_o(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),ps):JSON.parse(o)}let hs=(e,t,n,r)=>{let i=e._zod.def;vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=ms(i.defaultValue,e,t,n,r);o!==ps&&(n.default=o)},gs=(e,t,n,r)=>{let i=e._zod.def;vo(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=ms(i.defaultValue,e,t,n,r);o!==ps&&(n._prefault=o)},_s=(e,t,n,r)=>{let i=e._zod.def;vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{_o(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},vs=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;vo(o,t,r);let s=t.seen.get(e);s.ref=o},ys=(e,t,n,r)=>{let i=e._zod.def;vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},bs=(e,t,n,r)=>{let i=e._zod.def;vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xs=(e,t,n,r)=>{let i=e._zod.innerType;vo(i,t,r);let a=t.seen.get(e);a.ref=i},Ss=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function Cs(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let ws=/*@__PURE__*/ P(`ZodError`,(e,t)=>{Lt.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Ss.has(n)||(Ss.add(n),Cs(n,`format`,e=>t=>Bt(e,t)),Cs(n,`flatten`,e=>t=>zt(e,t)),Cs(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,me,2)}),Cs(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,me,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Ts=/* @__PURE__ */ Ht(ws),Es=/* @__PURE__ */ Ut(ws),Ds=/* @__PURE__ */ Wt(ws),Os=/* @__PURE__ */ Kt(ws),ks=/* @__PURE__ */ Qt(ws),As=/* @__PURE__ */ $t(ws),js=/* @__PURE__ */ en(ws),Ms=/* @__PURE__ */ tn(ws),Ns=/* @__PURE__ */ nn(ws),Ps=/* @__PURE__ */ rn(ws),Fs=/* @__PURE__ */ an(ws),Is=/* @__PURE__ */ on(ws);function Ls(){kt.localeError||At(ia())}function Rs(){kt.memoizer||At({memoizer:ta()})}let L=/*@__PURE__*/ P(`ZodType`,(e,t)=>(Ls(),F.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ke(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ze(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(sl(e,t))},superRefine(e,t){return this.check(cl(e,t))},overwrite(e){return this.check(/* @__PURE__ */ ro(e))},optional(){return Bc(this)},exactOptional(){return Hc(this)},nullable(){return Wc(this)},nullish(){return Bc(Wc(this))},nonoptional(e){return Xc(this,e)},array(){return V(this)},or(e){return Ec([this,e])},and(e){return Ac(this,e)},transform(e){return el(this,Rc(e))},default(e){return Kc(this,e)},prefault(e){return Jc(this,e)},catch(e){return Qc(this,e)},pipe(e){return el(this,e)},readonly(){return nl(this)},describe(e){let t=this.clone();return ca.add(t,{description:e}),t},meta(...e){if(e.length===0)return ca.get(this);let t=this.clone();return ca.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return pt(this,`~standard`,{...cr(this),jsonSchema:{input:Ao(this,`input`),output:Ao(this,`output`)}})},set"~standard"(e){ft(this,`~standard`,e)},parse:function e(t,n){return Ts(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Es(this,t,n,{callee:e})},safeParse(e,t){return Ds(this,e,t)},async safeParseAsync(e,t){return Os(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){ft(this,`spa`,e)},validate(e,t){return Yt(this,e,t)},validateAsync(e,t){return Zt(this,e,t)},encode:function e(t,n){return ks(this,t,n,{callee:e})},decode:function e(t,n){return As(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await js(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Ms(this,t,n,{callee:e})},safeEncode(e,t){return Ns(this,e,t)},safeDecode(e,t){return Ps(this,e,t)},async safeEncodeAsync(e,t){return Fs(this,e,t)},async safeDecodeAsync(e,t){return Is(this,e,t)},toJSONSchema(e){return ko(this,{})(e)},get description(){return ca.get(this)?.description},get _def(){return this._zod.def}}),zs=/*@__PURE__*/ P(`_ZodString`,(e,t)=>{lr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ko(e,t,n,r)},/*@__PURE__*/ mt({format:e=>Ho(e).format??null,minLength:e=>Ho(e).minimum??null,maxLength:e=>Ho(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ Za(...e))},includes(...e){return this.check(/* @__PURE__ */ eo(...e))},startsWith(...e){return this.check(/* @__PURE__ */ to(...e))},endsWith(...e){return this.check(/* @__PURE__ */ no(...e))},min(...e){return this.check(/* @__PURE__ */ Ya(...e))},max(...e){return this.check(/* @__PURE__ */ Ja(...e))},length(...e){return this.check(/* @__PURE__ */ Xa(...e))},nonempty(...e){return this.check(/* @__PURE__ */ Ya(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ Qa(e))},uppercase(e){return this.check(/* @__PURE__ */ $a(e))},trim(){return this.check(/* @__PURE__ */ ao())},normalize(...e){return this.check(/* @__PURE__ */ io(...e))},toLowerCase(){return this.check(/* @__PURE__ */ oo())},toUpperCase(){return this.check(/* @__PURE__ */ so())},slugify(){return this.check(/* @__PURE__ */ co())}})),Bs=/*@__PURE__*/ P(`ZodString`,(e,t)=>{lr.init(e,t),zs.init(e,t)},{email(e){return this.check(/* @__PURE__ */ da(Ks,e))},url(e){return this.check(/* @__PURE__ */ _a(Xs,e))},jwt(e){return this.check(/* @__PURE__ */ Ma(fc,e))},emoji(e){return this.check(/* @__PURE__ */ va(Qs,e))},guid(e){return this.check(/* @__PURE__ */ fa(qs,e))},uuid(e){return this.check(/* @__PURE__ */ pa(Js,e))},uuidv4(e){return this.check(/* @__PURE__ */ ma(Js,e))},uuidv6(e){return this.check(/* @__PURE__ */ ha(Js,e))},uuidv7(e){return this.check(/* @__PURE__ */ ga(Js,e))},nanoid(e){return this.check(/* @__PURE__ */ ya($s,e))},cuid(e){return this.check(/* @__PURE__ */ ba(ec,e))},cuid2(e){return this.check(/* @__PURE__ */ xa(tc,e))},ulid(e){return this.check(/* @__PURE__ */ Sa(nc,e))},base64(e){return this.check(/* @__PURE__ */ ka(lc,e))},base64url(e){return this.check(/* @__PURE__ */ Aa(uc,e))},xid(e){return this.check(/* @__PURE__ */ Ca(rc,e))},ksuid(e){return this.check(/* @__PURE__ */ wa(ic,e))},ipv4(e){return this.check(/* @__PURE__ */ Ta(ac,e))},ipv6(e){return this.check(/* @__PURE__ */ Ea(oc,e))},cidrv4(e){return this.check(/* @__PURE__ */ Da(sc,e))},cidrv6(e){return this.check(/* @__PURE__ */ Oa(cc,e))},e164(e){return this.check(/* @__PURE__ */ ja(dc,e))},datetime(e){return this.check(/* @__PURE__ */ Na(Hs,e))},date(e){return this.check(/* @__PURE__ */ Pa(Us,e))},time(e){return this.check(/* @__PURE__ */ Fa(Ws,e))},duration(e){return this.check(/* @__PURE__ */ Ia(Gs,e))}});function R(e){return/* @__PURE__ */ ua(Bs,e)}let Vs=/*@__PURE__*/ P(`ZodStringFormat`,(e,t)=>{I.init(e,t),zs.init(e,t)}),Hs=/*@__PURE__*/ P(`ZodISODateTime`,(e,t)=>{Or.init(e,t),Vs.init(e,t)}),Us=/*@__PURE__*/ P(`ZodISODate`,(e,t)=>{kr.init(e,t),Vs.init(e,t)}),Ws=/*@__PURE__*/ P(`ZodISOTime`,(e,t)=>{Ar.init(e,t),Vs.init(e,t)}),Gs=/*@__PURE__*/ P(`ZodISODuration`,(e,t)=>{jr.init(e,t),Vs.init(e,t)}),Ks=/*@__PURE__*/ P(`ZodEmail`,(e,t)=>{fr.init(e,t),Vs.init(e,t)}),qs=/*@__PURE__*/ P(`ZodGUID`,(e,t)=>{ur.init(e,t),Vs.init(e,t)}),Js=/*@__PURE__*/ P(`ZodUUID`,(e,t)=>{dr.init(e,t),Vs.init(e,t)});function Ys(e){return/* @__PURE__ */ pa(Js,e)}let Xs=/*@__PURE__*/ P(`ZodURL`,(e,t)=>{br.init(e,t),Vs.init(e,t)});function Zs(e){return/* @__PURE__ */ _a(Xs,e)}let Qs=/*@__PURE__*/ P(`ZodEmoji`,(e,t)=>{xr.init(e,t),Vs.init(e,t)}),$s=/*@__PURE__*/ P(`ZodNanoID`,(e,t)=>{Sr.init(e,t),Vs.init(e,t)}),ec=/*@__PURE__*/ P(`ZodCUID`,(e,t)=>{Cr.init(e,t),Vs.init(e,t)}),tc=/*@__PURE__*/ P(`ZodCUID2`,(e,t)=>{wr.init(e,t),Vs.init(e,t)}),nc=/*@__PURE__*/ P(`ZodULID`,(e,t)=>{Tr.init(e,t),Vs.init(e,t)}),rc=/*@__PURE__*/ P(`ZodXID`,(e,t)=>{Er.init(e,t),Vs.init(e,t)}),ic=/*@__PURE__*/ P(`ZodKSUID`,(e,t)=>{Dr.init(e,t),Vs.init(e,t)}),ac=/*@__PURE__*/ P(`ZodIPv4`,(e,t)=>{Mr.init(e,t),Vs.init(e,t)}),oc=/*@__PURE__*/ P(`ZodIPv6`,(e,t)=>{Fr.init(e,t),Vs.init(e,t)}),sc=/*@__PURE__*/ P(`ZodCIDRv4`,(e,t)=>{Ir.init(e,t),Vs.init(e,t)}),cc=/*@__PURE__*/ P(`ZodCIDRv6`,(e,t)=>{Rr.init(e,t),Vs.init(e,t)}),lc=/*@__PURE__*/ P(`ZodBase64`,(e,t)=>{Vr.init(e,t),Vs.init(e,t)}),uc=/*@__PURE__*/ P(`ZodBase64URL`,(e,t)=>{Wr.init(e,t),Vs.init(e,t)}),dc=/*@__PURE__*/ P(`ZodE164`,(e,t)=>{Gr.init(e,t),Vs.init(e,t)}),fc=/*@__PURE__*/ P(`ZodJWT`,(e,t)=>{qr.init(e,t),Vs.init(e,t)}),pc=/*@__PURE__*/ P(`ZodNumber`,(e,t)=>{Jr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ mt({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Ho(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Ho(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Ho(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Ho(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ Ga(e,t))},gte(e,t){return this.check(/* @__PURE__ */ Ka(e,t))},min(e,t){return this.check(/* @__PURE__ */ Ka(e,t))},lt(e,t){return this.check(/* @__PURE__ */ Ua(e,t))},lte(e,t){return this.check(/* @__PURE__ */ Wa(e,t))},max(e,t){return this.check(/* @__PURE__ */ Wa(e,t))},int(e){return this.check(hc(e))},safe(e){return this.check(hc(e))},positive(e){return this.check(/* @__PURE__ */ Ga(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ Ka(0,e))},negative(e){return this.check(/* @__PURE__ */ Ua(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ Wa(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ qa(e,t))},step(e,t){return this.check(/* @__PURE__ */ qa(e,t))},finite(){return this}}));function z(e){return/* @__PURE__ */ La(pc,e)}let mc=/*@__PURE__*/ P(`ZodNumberFormat`,(e,t)=>{Yr.init(e,t),pc.init(e,t)});function hc(e){return/* @__PURE__ */ Ra(mc,e)}let gc=/*@__PURE__*/ P(`ZodBoolean`,(e,t)=>{Xr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r)});function B(e){return/* @__PURE__ */ za(gc,e)}let _c=/*@__PURE__*/ P(`ZodNull`,(e,t)=>{Zr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r)});function vc(e){return/* @__PURE__ */ Ba(_c,e)}let yc=/*@__PURE__*/ P(`ZodUnknown`,(e,t)=>{Qr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function bc(){return/* @__PURE__ */ Va(yc)}let xc=/*@__PURE__*/ P(`ZodNever`,(e,t)=>{$r.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r)});function Sc(e){return/* @__PURE__ */ Ha(xc,e)}let Cc=/*@__PURE__*/ P(`ZodArray`,(e,t)=>{Rs(),ri.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ Ya(e,t))},nonempty(e){return this.check(/* @__PURE__ */ Ya(1,e))},max(e,t){return this.check(/* @__PURE__ */ Ja(e,t))},length(e,t){return this.check(/* @__PURE__ */ Xa(e,t))},unwrap(){return this.element}});function V(e,t){return/* @__PURE__ */ lo(Cc,e,t)}let wc=/*@__PURE__*/ P(`ZodObject`,(e,t)=>{Rs(),li.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r),bt(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return W(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ke(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ke(this._zod.def,{catchall:bc()}))},loose(){return this.clone(ke(this._zod.def,{catchall:bc()}))},strict(){return this.clone(ke(this._zod.def,{catchall:Sc()}))},strip(){return this.clone(ke(this._zod.def,{catchall:void 0}))},extend(e){return qe(this,e)},safeExtend(e){return Ye(this,e)},merge(e){return Xe(this,e)},pick(e){return We(this,e)},omit(e){return Ke(this,e)},partial(...e){return Ze(zc,this,e[0])},exactPartial(...e){return Ze(Vc,this,e[0],`exactPartial`)},required(...e){return Qe(Yc,this,e[0])}});function H(e,t){let n={type:`object`,shape:e??{},...M(t)};return new wc(n)}function U(e,t){return new wc({type:`object`,shape:e,catchall:Sc(),...M(t)})}let Tc=/*@__PURE__*/ P(`ZodUnion`,(e,t)=>{di.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r),e.options=t.options});function Ec(e,t){return new Tc({type:`union`,options:e,...M(t)})}let Dc=/*@__PURE__*/ P(`ZodDiscriminatedUnion`,(e,t)=>{Tc.init(e,t),pi.init(e,t)});function Oc(e,t,n){return new Dc({type:`union`,options:t,discriminator:e,...M(n)})}let kc=/*@__PURE__*/ P(`ZodIntersection`,(e,t)=>{mi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r)});function Ac(e,t){return new kc({type:`intersection`,left:e,right:t})}let jc=/*@__PURE__*/ P(`ZodTuple`,(e,t)=>{Rs(),_i.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new zc({type:`optional`,innerType:e}))})}});function Mc(e,t,n){let r=t instanceof F;return new jc({type:`tuple`,items:e,rest:r?t:null,...M(r?n:t)})}let Nc=/*@__PURE__*/ P(`ZodRecord`,(e,t)=>{Rs(),xi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Pc(e,t,n){return!t||!t._zod?new Nc({type:`record`,keyType:R(),valueType:e,...M(t)}):new Nc({type:`record`,keyType:e,valueType:t,...M(n)})}let Fc=/*@__PURE__*/ P(`ZodEnum`,(e,t)=>{Si.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Fc({...t,checks:[],...M(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Fc({...t,checks:[],...M(r),entries:i})}});function W(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Fc({type:`enum`,entries:n,...M(t)})}let Ic=/*@__PURE__*/ P(`ZodLiteral`,(e,t)=>{Ci.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function G(e,t){return new Ic({type:`literal`,values:Array.isArray(e)?e:[e],...M(t)})}let Lc=/*@__PURE__*/ P(`ZodTransform`,(e,t)=>{Rs(),wi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ot(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(ut(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(ut(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Rc(e){return new Lc({type:`transform`,transform:e})}let zc=/*@__PURE__*/ P(`ZodOptional`,(e,t)=>{Ei.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bc(e){return new zc({type:`optional`,innerType:e})}let Vc=/*@__PURE__*/ P(`ZodExactOptional`,(e,t)=>{Di.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hc(e){return new Vc({type:`optional`,innerType:e})}let Uc=/*@__PURE__*/ P(`ZodNullable`,(e,t)=>{Oi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wc(e){return new Uc({type:`nullable`,innerType:e})}let Gc=/*@__PURE__*/ P(`ZodDefault`,(e,t)=>{ki.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Kc(e,t){return new Gc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ie(t)}})}let qc=/*@__PURE__*/ P(`ZodPrefault`,(e,t)=>{ji.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jc(e,t){return new qc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ie(t)}})}let Yc=/*@__PURE__*/ P(`ZodNonOptional`,(e,t)=>{Mi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xc(e,t){return new Yc({type:`nonoptional`,innerType:e,...M(t)})}let Zc=/*@__PURE__*/ P(`ZodCatch`,(e,t)=>{Fi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Qc(e,t){return new Zc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:xt(t)})}let $c=/*@__PURE__*/ P(`ZodPipe`,(e,t)=>{Ii.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),e.in=t.in,e.out=t.out});function el(e,t){return new $c({type:`pipe`,in:e,out:t})}let tl=/*@__PURE__*/ P(`ZodReadonly`,(e,t)=>{Ri.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nl(e){return new tl({type:`readonly`,innerType:e})}let rl=/*@__PURE__*/ P(`ZodLazy`,(e,t)=>{Bi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function il(e){return new rl({type:`lazy`,getter:e})}let al=/*@__PURE__*/ P(`ZodCustom`,(e,t)=>{Vi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(e,t,n,r)});function ol(e,t){return/* @__PURE__ */ uo(al,e??(()=>!0),t)}function sl(e,t={}){return/* @__PURE__ */ fo(al,e,t)}function cl(e,t){return/* @__PURE__ */ po(e,t)}function ll(e){return/* @__PURE__ */ Na(Hs,e)}function ul(e){return(t,n)=>{for(let r of e)Object.hasOwn(t,r)&&t[r]===void 0&&n.addIssue({code:`custom`,path:[r],message:`Explicit undefined is not valid JSON`})}}let dl=Ec([R(),z(),B(),vc()]);function fl(e){let t=/* @__PURE__ */ new WeakSet,n=[{value:e,leaving:!1}];try{for(;n.length>0;){let e=n.pop();if(!e)break;if(e.leaving)t.delete(e.value);else if(typeof e.value==`object`&&e.value!==null){if(t.has(e.value))return!1;t.add(e.value),n.push({value:e.value,leaving:!0});for(let t of Object.values(e.value))n.push({value:t,leaving:!1})}}}catch{return!1}return!0}let pl=ol(fl,{message:`JSON value must not contain circular references`}),ml=il(()=>Ec([dl,V(ml),Pc(R(),ml)])),hl=pl.pipe(ml);pl.pipe(V(ml));let gl=pl.pipe(Pc(R(),ml)),_l=U({code:R().min(1),message:R().min(1),retryable:B(),diagnostic:R().min(1).optional(),stage:R().min(1).optional(),durationMs:z().int().nonnegative().optional(),stderrTail:R().min(1).optional()}).superRefine(ul([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),vl=R().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),yl=e=>R().min(1).max(e).refine(e=>e.trim().length>0),bl=Pc(vl,H({label:yl(256).optional(),description:yl(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),xl=Pc(vl,yl(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),Sl=R().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),Cl=Sl.brand(),K=Sl.brand(),wl=Sl.brand();Sl.brand(),Sl.brand();let Tl=R().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),El=Tl.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),Dl=H({modes:V(H({id:El,label:Tl.max(256),description:Tl.max(1024).optional(),dangerous:B().optional(),localizations:bl.optional()}).strict()).min(1).max(32),defaultModeId:El}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.modes.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Permission Mode IDs must be unique`,path:[`modes`,r,`id`]}),n.add(i.id);n.has(e.defaultModeId)||t.addIssue({code:`custom`,message:`Default Permission Mode must exist in the catalog`,path:[`defaultModeId`]})});H({threadId:K,permissionModeId:El}).strict();let Ol=R().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`});H({sourceThreadId:K,lastTurnId:wl.optional(),targetHarnessId:Cl,targetModel:Ol.max(1024).optional(),targetThinkingOptionId:Ol.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).optional()}).strict();let kl=H({sourceThreadId:K,sourceHarnessId:Cl,sourceHarnessLabel:Ol.max(256).optional(),sourceModel:Ol.max(1024).optional(),targetHarnessId:Cl,targetHarnessLabel:Ol.max(256).optional(),targetModel:Ol.max(1024).optional(),totalTurns:z().int().min(1),boundaryTurnNumber:z().int().min(1),includedTurnNumbers:V(z().int().min(1)),omittedTurns:z().int().min(0),preview:R().max(32e3),createdAtMs:z().int().nonnegative()}).strict();H({threadId:K,handoff:kl}).strict();let Al=z().int().safe().nonnegative(),jl=z().finite().nonnegative(),Ml=z().finite().min(0).max(100),Nl=H({version:Ec([G(3),G(4)]).optional(),requestId:R().min(1),turnId:R().min(1).max(1024),outputTokens:Al,startedAtMs:Al,completedAtMs:Al}).strict().refine(e=>e.completedAtMs>e.startedAtMs),Pl=H({version:Ec([G(2),G(3),G(4)]).optional(),value:jl,turnId:R().min(1).max(1024),at:Al}).strict();H({outputTimings:V(Nl).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:Pl.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:Pl.extend({value:Al}).optional()}).strict();let Fl=e=>xl.refine(t=>Object.values(t).every(t=>t.length<=e)),Il=H({composerIndicators:V(H({kind:G(`countdown`),id:R().min(1).max(64),expiresAtUnix:Al,label:Fl(256).optional(),tooltip:Fl(1024).optional()}).strict()).max(2).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,{message:`Composer indicator IDs must be unique`}).optional(),inputTokens:Al.optional(),cachedInputTokens:Al.optional(),cacheWriteInputTokens:Al.optional(),outputTokens:Al.optional(),outputTokensPerSecond:jl.optional(),sessionOutputTokensPerSecond:jl.optional(),apiOutputTokensPerSecond:jl.optional(),reasoningOutputTokens:Al.optional(),totalTokens:Al.optional(),totalCostUsd:jl.optional(),totalCredits:jl.optional(),contextUsagePercent:jl.optional(),cacheHitRatePercent:Ml.optional(),contextWindowTokens:Al.optional(),contextUsedTokens:Al.optional(),planFiveHourUsedPercent:Ml.optional(),planFiveHourResetsAtUnix:Al.optional(),planSevenDayUsedPercent:Ml.optional(),planSevenDayResetsAtUnix:Al.optional(),sessionCacheHitRatePercent:Ml.optional(),timeToFirstOutputMs:Al.optional(),latestRequestTimeToFirstOutputMs:Al.optional(),costSource:W([`publicPrice`,`native`]).optional(),unpricedModels:V(R().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{Object.keys(e).length===0&&t.addIssue({code:`custom`,message:`Thread Usage must contain a reliable field`});let n=e.contextUsedTokens!==void 0;n!==(e.contextWindowTokens!==void 0)&&t.addIssue({code:`custom`,message:`Thread Usage context fields must be provided together`,path:[n?`contextWindowTokens`:`contextUsedTokens`]}),e.contextWindowTokens===0&&t.addIssue({code:`custom`,message:`Thread Usage contextWindowTokens must be greater than zero`,path:[`contextWindowTokens`]}),e.costSource!==void 0&&e.totalCostUsd===void 0&&t.addIssue({code:`custom`,message:`Thread Usage costSource must be provided with totalCostUsd`,path:[`costSource`]}),e.unpricedModels!==void 0&&e.costSource!==`publicPrice`&&t.addIssue({code:`custom`,message:`Thread Usage unpricedModels must be provided with a publicPrice cost`,path:[`unpricedModels`]}),e.planFiveHourResetsAtUnix!==void 0&&e.planFiveHourUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planFiveHourResetsAtUnix must be provided with planFiveHourUsedPercent`,path:[`planFiveHourResetsAtUnix`]}),e.planSevenDayResetsAtUnix!==void 0&&e.planSevenDayUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planSevenDayResetsAtUnix must be provided with planSevenDayUsedPercent`,path:[`planSevenDayResetsAtUnix`]})}),Ll=z().finite().min(0).max(100),Rl=W([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),zl=H({id:R().min(1).max(256),label:R().min(1).max(256),localizations:bl.optional()}).strict(),Bl=H({product:R().min(1),periodType:Rl.optional(),scope:zl.optional(),localizations:bl.optional(),used:z().finite().nonnegative().optional(),limit:z().finite().nonnegative().optional(),unit:R().min(1).max(32).optional(),usagePercent:Ll,resetsAt:R().min(1).optional()}).strict(),Vl=H({availableCount:z().int().safe().positive(),nextExpiresAt:R().min(1).optional(),expiresAt:V(R().min(1)).min(1).max(32).optional()}).strict(),Hl=H({used:z().finite().nonnegative().optional(),limit:z().finite().nonnegative().optional(),unit:R().min(1).max(32).optional(),label:R().min(1).optional(),scope:zl.optional(),localizations:bl.optional(),usedPercent:Ll,resetsAt:R().min(1).optional(),periodType:Rl,productUsage:V(Bl).min(1).optional(),resetCredits:Vl.optional()}).strict(),Ul=H({amount:z().finite().nonnegative(),currency:R().trim().min(1).max(8),label:R().trim().min(1).max(128).optional()}).strict();H({threadId:K,refresh:G(`exact`).optional()}).strict(),H({threadId:K,usage:Il.nullable(),accountCredits:Hl.optional(),accountBalance:Ul.optional(),accountCreditsSupported:B().optional()}).strict();let Wl=R().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),Gl=R().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Model Ref must not contain control characters`).brand(),Kl=W([`priority`,`ultrafast`]),ql=H({id:Gl,serviceTier:Kl.optional()}).strict();function Jl(e,t){return e?.id===t?.id&&e?.serviceTier===t?.serviceTier}let Yl=Wl.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand(),Xl=Wl.max(256),Zl=H({id:Yl,label:Wl.max(256)}).strict(),Ql=H({ref:ql,label:Wl.max(256),resolvedModelLabel:Xl.optional(),fastModel:ql.optional(),supportedThinkingOptionIds:V(Yl).optional()}).strict().refine(e=>e.fastModel?.serviceTier===void 0||e.fastModel.id===e.ref.id,{path:[`fastModel`,`id`],message:`A tiered Fast Model must share the base Model ID`});function $l(e,t){if(t)return e?.models.find(e=>Jl(e.ref,t)||Jl(e.fastModel,t))}let eu=V(Zl).superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Thinking option IDs must be unique`,path:[r,`id`]}),n.add(i.id)}),tu=W([`catalog`,`activeModel`]),nu=H({models:V(Ql),defaultModel:ql.optional(),thinkingOptions:eu,defaultThinkingOptionId:Yl.optional(),thinkingOptionsScope:tu.optional()}).strict().superRefine((e,t)=>{let n=[],r=new Set(e.thinkingOptions.map(({id:e})=>e));for(let[i,a]of e.models.entries()){n.some(e=>Jl(e,a.ref))&&t.addIssue({code:`custom`,message:`Model Catalog refs must be unique`,path:[`models`,i,`ref`,`id`]}),n.push(a.ref),a.fastModel&&(n.some(e=>Jl(e,a.fastModel))&&t.addIssue({code:`custom`,message:`Fast Model refs must be distinct and unique`,path:[`models`,i,`fastModel`]}),n.push(a.fastModel));let e=/* @__PURE__ */ new Set;for(let[n,o]of(a.supportedThinkingOptionIds??[]).entries())e.has(o)&&t.addIssue({code:`custom`,message:`Supported Thinking option IDs must be unique per Model`,path:[`models`,i,`supportedThinkingOptionIds`,n]}),e.add(o),r.has(o)||t.addIssue({code:`custom`,message:`Supported Thinking option must exist in the catalog`,path:[`models`,i,`supportedThinkingOptionIds`,n]})}e.defaultModel&&!$l(e,e.defaultModel)&&t.addIssue({code:`custom`,message:`Default Model must exist in the Model Catalog`,path:[`defaultModel`,`id`]}),e.defaultThinkingOptionId&&!r.has(e.defaultThinkingOptionId)&&t.addIssue({code:`custom`,message:`Default Thinking option must exist in the catalog`,path:[`defaultThinkingOptionId`]})}),ru=H({fork:B(),forkAcrossCwd:B(),rollbackLastTurn:B()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),iu=W([`live`,`atCreate`]),au=H({configuration:H({selectModel:B(),selectThinkingOption:B(),selectPermissionMode:B(),permissionModeScope:iu.default(`live`)}).strict(),history:ru,subagents:H({observe:B(),readTranscript:B()}).strict().optional(),autonomousTurns:H({observe:B()}).strict().optional(),steer:B().optional(),persistentPlan:B().optional()}).strict();H({effectiveModel:ql.optional(),resolvedModelLabel:Xl.optional(),effectiveThinkingOptionId:Yl.optional(),availableThinkingOptions:eu.optional(),effectivePermissionModeId:El.optional()}).strict().superRefine((e,t)=>{e.effectiveThinkingOptionId&&e.availableThinkingOptions&&!e.availableThinkingOptions.some(({id:t})=>t===e.effectiveThinkingOptionId)&&t.addIssue({code:`custom`,message:`Effective Thinking option must be currently available`,path:[`effectiveThinkingOptionId`]})});let ou=H({open:G(!0)}).strict();Ec([H({status:G(`ready`),catalog:nu,permissionModes:Dl.optional(),capabilities:au,webUi:ou.optional()}).strict().superRefine((e,t)=>{let n=e.capabilities.configuration.selectPermissionMode;n!==!!e.permissionModes&&t.addIssue({code:`custom`,message:`Permission Mode catalog and capability must agree`,path:n?[`permissionModes`]:[`capabilities`,`configuration`,`selectPermissionMode`]})}),H({status:W([`notInstalled`,`unavailable`,`error`]),error:_l}).strict()]),H({harnessId:Cl,cwd:Wl.max(16384).optional(),refresh:B().optional(),purpose:G(`availability`).optional(),credentialAccess:W([`allow`,`retry`]).optional()}).strict(),H({harnessId:Cl}).strict(),H({}).strict(),H({threadId:K,model:ql}).strict(),H({threadId:K,thinkingOptionId:Yl}).strict(),H({threadId:K,includeReferenceCapability:B().optional()}).strict(),Oc(`owner`,[H({owner:G(`codex`),locked:B(),effectiveModel:ql.optional(),resolvedModelLabel:Xl.optional(),effectiveThinkingOptionId:Yl.optional(),effectivePermissionModeId:El.optional(),history:ru.optional(),supportsThreadReferences:G(!0).optional(),handoff:kl.optional()}).strict(),H({owner:G(`external`),harnessId:Wl.max(256),transportModelId:Wl.max(8192),effectiveModel:ql.optional(),resolvedModelLabel:Xl.optional(),effectiveThinkingOptionId:Yl.optional(),availableThinkingOptions:eu.optional(),effectivePermissionModeId:El.optional(),catalog:nu.optional(),history:ru,usage:Il.optional(),handoff:kl.optional(),locked:G(!0)}).strict()]),H({threadIds:V(K).min(1).max(100)}).strict().superRefine(({threadIds:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i)&&t.addIssue({code:`custom`,message:`Thread ownership-list IDs must be unique`,path:[`threadIds`,r]}),n.add(i)});let su=Oc(`owner`,[H({threadId:K,owner:G(`codex`)}).strict(),H({threadId:K,owner:G(`external`),harnessId:R().max(256).pipe(Cl)}).strict()]);H({threads:V(su).min(1).max(100)}).strict().superRefine(({threads:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.threadId)&&t.addIssue({code:`custom`,message:`Thread ownership-list results must be unique`,path:[`threads`,r,`threadId`]}),n.add(i.threadId)}),H({threadId:K,text:R().optional()}).strict(),H({kind:G(`application`),value:R().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),Ct}}).pipe(H({expectedTurnId:wl,clientUserMessageId:R().min(1),delivery:W([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),W([`activeTurn`,`newTurn`]),H({delivery:W([`official`,`activeTurn`,`newTurn`])}).strict();let cu=R().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u),lu=cu.pipe(Cl),uu=lu.refine(e=>e!==`codex`,`The official Codex identity is reserved`),du=R().min(1).max(512).refine(e=>!/[\\\u0000:#?]/u.test(e)&&!e.startsWith(`/`)&&!e.split(`/`).some(e=>e===`..`||e===``),`Plugin resources must be relative paths inside the plugin`),fu=Zs().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),pu=H({en:R().max(4096),"zh-CN":R().max(4096).optional()}).strict(),mu=H({commands:V(H({terminal:R().max(256),command:R().max(4096)}).strict()).max(8),before:pu.optional(),after:pu.optional(),downloads:V(H({label:R().max(128),url:fu}).strict()).max(8).optional()}).strict(),hu={id:lu,name:R().trim().min(1).max(128),version:R().min(1).max(128),kind:G(`usage`).optional(),iconStyle:H({vector:H({viewBox:R().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:R().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:V(H({d:R().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:W([`evenodd`,`nonzero`]).optional(),fill:R().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:R().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:z().min(0).max(50).optional(),paddingRatio:z().min(0).max(.25).optional()}).strict().optional(),installation:mu.optional(),notice:pu.optional(),launchCommand:G(!0).optional(),links:H({website:fu.optional(),documentation:fu.optional(),installation:fu.optional()}).strict().optional()};H({manifestVersion:G(1),...hu,adapterApiVersion:z().int().positive(),entry:du,icon:du.optional()}).strict();let gu=R().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),_u=H({...hu,icon:gu.optional()}).strict();H({}).strict(),H({plugins:V(_u.extend({id:uu})).max(128)}).strict(),H({version:G(1),enabled:V(lu).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]});let vu=cu,yu=W([`sidebar.thread-layout`,`sidebar.thread-badge`,`appearance.theme`]),bu=W([`appearance`,`interface`,`workflow`,`analytics`,`integrations`,`tools`]),xu=R().trim().min(1).max(128);function Su(e){switch(e.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`webp`:return`image/webp`;default:return}}let Cu=e=>e.split(`/`).every(e=>!/[. ]$/u.test(e)),wu=du.refine(e=>Su(e)!==void 0&&Cu(e),`Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space`),Tu=R().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu,`Expected an HTTP(S) URL`).pipe(Zs({protocol:/^https?$/u})).refine(e=>{let{username:t,password:n}=new URL(e);return!t&&!n&&!/[\\\s]/u.test(e)},`URL must not contain credentials, backslashes, or whitespace`);function Eu(e){return U({en:e,"zh-CN":e})}let Du=Eu(R().trim().min(1)),Ou=V(bu).max(bu.options.length).refine(e=>new Set(e).size===e.length,`Duplicate categories`),ku=V(yu).max(yu.options.length).refine(e=>new Set(e).size===e.length,`Duplicate slots`),Au={key:R().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),label:Du,description:Du.optional()},ju={...Au,step:z().positive().optional(),default:z().optional()},Mu=U({value:R(),label:Du}),Nu=Oc(`type`,[U({...Au,type:G(`boolean`),default:B().optional()}),U({...Au,type:G(`string`),placeholder:Du.optional(),default:R().optional()}),U({...ju,type:G(`number`),min:z().optional(),max:z().optional()}),U({...ju,type:G(`range`),min:z(),max:z()}),U({...Au,type:G(`select`),options:V(Mu).min(1),default:R().optional()})]).superRefine((e,t)=>{let n=(e,n)=>t.addIssue({code:`custom`,path:[e],message:n});if(e.type===`number`||e.type===`range`){let{min:t=-1/0,max:r=1/0,default:i}=e;t>r&&n(`max`,`Must be at least min`),i!==void 0&&(i<t||i>r)&&n(`default`,`Must be within min and max`)}else if(e.type===`select`){let t=new Set(e.options.map(({value:e})=>e));t.size!==e.options.length&&n(`options`,`Duplicate option values`),e.default!==void 0&&!t.has(e.default)&&n(`default`,`Must match an option value`)}}),Pu=H({manifestVersion:hc().positive(),id:vu,name:Ec([xu,Eu(xu)]),version:R().min(1).max(128),desktopApi:hc().positive()}).passthrough().extend({manifestVersion:G(1),desktopApi:G(1),description:U({en:R().max(4096),"zh-CN":R().max(4096).optional()}).optional(),author:R().trim().min(1).max(128).optional(),repository:Tu.optional(),details:U({en:R().max(16384),"zh-CN":R().max(16384).optional()}).optional(),icon:wu.optional(),screenshots:V(wu).max(4).refine(e=>new Set(e).size===e.length,`Duplicate screenshots`).optional(),desktop:U({script:du,style:du.optional()}).optional(),backend:U({script:du.refine(Cu)}).optional(),slots:ku.default(()=>[]),settingsSchema:V(Nu).max(32).refine(e=>new Set(e.map(({key:e})=>e)).size===e.length,`Duplicate setting keys`).optional(),categories:Ou.optional()}).strict().refine(e=>e.desktop!==void 0||e.backend!==void 0,`Expected at least one desktop or backend entry`),Fu=R().regex(/^[a-f0-9]{64}$/u),Iu=U({state:W([`running`,`disabled`,`invalid`,`incompatible`,`conflict`,`failed`,`waiting`]),hash:Fu.optional(),error:R().optional(),conflictWith:vu.optional()});U({controllerPid:hc().positive(),targetId:R().nullable(),updatedAt:ll(),handledReloadToken:Ys().optional(),extensions:Pc(R(),Iu),surfaces:Pc(R(),Iu).optional()});let Lu=W([`official`,`community`]);function Ru(e){return e.origin===`https://api.github.com`&&/^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(e.pathname)}let zu=Tu.refine(e=>{let t=new URL(e);return/\.zip$/iu.test(t.pathname)||Ru(t)||t.origin===`https://github.com`&&/^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(t.pathname)||t.origin===`https://codeload.github.com`&&/^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(t.pathname)},`Expected a .zip download URL or a GitHub zipball URL`),Bu=U({id:vu,version:R().trim().min(1).max(128),name:Du.extend({en:xu,"zh-CN":xu}),description:Eu(R().trim().min(1).max(4096)),details:Eu(R().trim().min(1).max(16384)).optional(),author:R().trim().min(1).max(128),repository:Tu,stars:z().int().min(0).optional(),downloads:z().int().min(0).optional(),categories:Ou.optional(),trustTier:Lu.default(`community`),icon:Tu.optional(),screenshots:V(Tu).max(4).optional(),downloadUrl:zu,sha256:Fu,slots:ku.optional(),publishedAt:R().optional(),updatedAt:R().optional(),minCodexHostVersion:R().optional()});U({schemaVersion:G(1),generatedAt:R(),extensions:V(Bu).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)});let Vu=R().trim().min(1).max(128),Hu=/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu,Uu=vu.refine(e=>!Hu.test(e),`Reserved extension ID`),Wu=W([`desktop`,`web`]),Gu=Fu,Ku=Ys(),qu=du.refine(e=>!/[\x00-\x1f\x7f<>"|*]/u.test(e)&&e.split(`/`).every(e=>!/[. ]$/u.test(e)&&!Hu.test(e)),`Expected a portable relative resource path`).refine(e=>e.split(`/`).length<=32,`Extension resources may be at most 32 segments deep`),Ju=Pu.shape,Yu=(e,t=0)=>U({en:R().trim().min(t).max(e),"zh-CN":R().trim().min(t).max(e)}),Xu=e=>qu.refine(t=>t.endsWith(e),`Expected a ${e} file`),Zu=Xu(`.mjs`),Qu=Xu(`.css`).optional(),$u=e=>e.normalize(`NFC`).toLowerCase(),ed=U({manifestVersion:G(2),id:Uu,name:Yu(128,1),version:R().trim().min(1).max(128),description:Yu(4096),details:Yu(16384).optional(),author:Ju.author,repository:Ju.repository,icon:Ju.icon.refine(e=>e===void 0||qu.safeParse(e).success),screenshots:Ju.screenshots.refine(e=>e===void 0||e.every(e=>qu.safeParse(e).success)),categories:Ju.categories,settingsSchema:Ju.settingsSchema,slots:Ju.slots.removeDefault().optional(),page:U({apiVersion:G(1),entry:Zu,style:Qu,title:Yu(128,1).optional()}).optional(),widget:U({apiVersion:G(1),entry:Zu,style:Qu}).optional(),desktop:U({apiVersion:G(1),script:Xu(`.js`),style:Qu}).optional(),web:U({apiVersion:G(1),entry:Zu.optional(),style:Qu}).refine(({entry:e,style:t})=>e!==void 0||t!==void 0,`Expected a Web entry or style`).optional(),backend:U({apiVersion:G(1),entry:Zu}).optional()}).refine(({page:e,widget:t,desktop:n,web:r,backend:i})=>!!(e||t||n||r||i),`Expected at least one page, widget, desktop, web, or backend entry`).refine(({page:e,widget:t,web:n,backend:r})=>!r||[e?.entry,t?.entry,n?.entry].every(e=>e===void 0||$u(e)!==$u(r.entry)),{path:[`backend`,`entry`],message:`A backend entry cannot also be a frontend entry`});function td({hasPage:e,hasWidget:t,hasDesktop:n,hasWeb:r,hasBackend:i}){if(e||t||i&&!n&&!r)return[`desktop`,`web`];let a=[];return n&&a.push(`desktop`),r&&a.push(`web`),a}let nd=Vu,rd=hc().nonnegative(),id=U({revision:rd,enabled:V(Uu).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)}),{downloadUrl:ad,...od}=Bu.shape,sd=H({...od,id:Uu,format:G(`codexhost`),targets:V(Wu).min(1).max(2).refine(e=>new Set(e).size===e.length,`Duplicate targets`),apis:U({page:hc().positive().optional(),widget:hc().positive().optional(),desktop:hc().positive().optional(),web:hc().positive().optional(),backend:hc().positive().optional()}),downloadUrl:ad.refine(e=>e.startsWith(`https://`),`Expected HTTPS`)}).refine(({targets:e,apis:t})=>{let n=td({hasPage:!!t.page,hasWidget:!!t.widget,hasDesktop:!!t.desktop,hasWeb:!!t.web,hasBackend:!!t.backend});return e.length===n.length&&n.every(t=>e.includes(t))},`Catalog targets must match the declared APIs`);H({schemaVersion:G(2),generatedAt:R().min(1),extensions:V(sd).max(1e4).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)}).extend({catalogUrl:Tu,fetchedAt:ll(),cached:B()});let cd={id:Uu},ld={...cd,activationId:Ku,digest:Gu},ud={...cd,activationId:ld.activationId.optional()},dd=R().min(1).max(4096).refine(e=>/^(?:\/|[a-z]:[/\\])/iu.test(e)&&!e.includes(`\0`)&&!e.split(/[/\\]/u).some(e=>e===`.`||e===`..`),`Expected an absolute local path without dot segments`),fd=R().min(1).max(256).refine(e=>e.split(`/`).every(e=>e&&/^[a-z0-9_.-]+$/iu.test(e)&&e!==`.`&&e!==`..`),`Invalid GitHub ref`);function pd(e){return R().max(4*Math.ceil(e/3)).refine(t=>{let n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return t.length%4==0&&t.length*3/4-n<=e&&/^[A-Za-z0-9+/]*={0,2}$/u.test(t)},`Expected bounded standard padded base64`)}let md=U({type:G(`github`),repository:R().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),ref:fd.optional(),tag:fd.optional(),asset:R().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),subpath:qu.optional()}).refine(({ref:e,tag:t,asset:n})=>!e||!t&&!n,`Use either a zipball ref or a release tag/asset`),hd=Ec([U({type:G(`catalog`),...cd}),md,U({type:G(`zip`),base64:pd(67108864).min(4)}),U({type:G(`zip`),localZipPath:dd}),U({type:G(`localDir`),localDir:dd})]),gd=Oc(`type`,[U({type:G(`catalog`),...cd}),md,U({type:G(`zip`)}),U({type:G(`localDir`)})]),_d=U({...ld,manifest:ed,installedAt:ll(),source:gd.optional()}),vd=e=>R().max(23+4*Math.ceil(e/3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u),yd={desktopConflictWith:Uu.optional()},bd=W([`none`,`inactive`,`starting`,`running`,`failed`]),xd=Oc(`state`,[_d.extend({state:G(`valid`),enabled:B(),...yd,iconDataUrl:vd(131072).optional(),screenshotDataUrls:V(vd(524288)).max(4).optional(),backendState:bd.optional(),backendError:R().optional()}),U({state:W([`invalid`,`incompatible`]),id:R().min(1),enabled:B(),error:R()})]);U({revision:rd,configuration:id,diagnostics:V(R()),extensions:V(xd)}),U({revision:rd,extensions:V(_d.extend({...yd,settingsRevision:rd})).max(64)});let Sd={list:`codexhost/extensions/list`,snapshot:`codexhost/extensions/snapshot`,catalog:`codexhost/extensions/catalog`,install:`codexhost/extensions/install`,update:`codexhost/extensions/update`,enable:`codexhost/extensions/enable`,disable:`codexhost/extensions/disable`,uninstall:`codexhost/extensions/uninstall`,recover:`codexhost/extensions/recover`,asset:`codexhost/extensions/asset`,settingsGet:`codexhost/extensions/settings/get`,settingsSet:`codexhost/extensions/settings/set`,backendInvoke:`codexhost/extensions/backend/invoke`},Cd=Object.freeze(Object.values(Sd));new Set(Cd),U({});let wd={expectedRevision:rd};U({...cd,...wd}),_d.extend({replaced:B()}),Oc(`state`,[U({state:G(`saved`),configuration:id}),U({state:G(`revision-conflict`),revision:rd})]),U({...ud,digest:ld.digest.optional(),path:qu}),U({mimeType:R().min(1),base64:pd(16777216),digest:ld.digest}),U({settingsRevision:rd,values:gl}),Sd.list,Sd.snapshot,Sd.catalog,U({forceRefresh:B().optional()}),Sd.install,U({source:hd}),Sd.update,U({...cd,expectedDigest:ld.digest,expectedActivationId:ld.activationId.optional(),source:hd.optional()}),Sd.enable,Sd.disable,Sd.uninstall,U({...cd,removeData:B().optional(),expectedDigest:ld.digest.optional()}),U({...cd,removed:B()}),Sd.recover,U({expectedRevision:wd.expectedRevision.optional()}),Sd.asset,Sd.settingsGet,U(ud),Sd.settingsSet,U({...ud,expectedSettingsRevision:rd,values:gl}),Sd.backendInvoke,U({...ud,method:nd,params:hl.optional()}),U({result:hl}),H({threadId:K}).strict(),H({confirmed:B()}).strict(),[...Cd],H({sections:V(H({id:R().min(1),name:R().min(1),threads:V(gl)}).strict())}).strict(),H({threadId:R().min(1).max(1024),sectionId:R().min(1).max(1024).nullable()}).strict(),H({threadIds:V(R().min(1))}).strict(),H({threadId:R().min(1).max(1024),pinned:B()}).strict(),H({}).strict(),H({parents:Pc(R().min(1),R().min(1))}).strict(),H({prompt:R().max(16384).optional()}).strict(),H({projects:V(H({id:R(),name:R(),rootPaths:V(R()),createdAt:z().int().optional()})),nativeProjects:G(!0).optional(),assignments:Pc(R(),R()),projectless:V(R()),pinned:V(R()),sectionProjects:Pc(R(),V(R())).optional()});let Td=Pc(R(),bc()),Ed=H({epoch:R().uuid(),sequence:z().int().nonnegative()});Oc(`type`,[H({type:G(`projects-changed`),cursor:Ed}),H({type:G(`skills-changed`),cursor:Ed,cwd:R().optional()}),H({type:G(`harness-inspection-changed`),cursor:Ed,harnessId:R().min(1)}),H({type:G(`display-settings-changed`),cursor:Ed}),H({type:G(`preferences-changed`),cursor:Ed,revision:z().int().nonnegative()}),H({type:G(`extensions-changed`),cursor:Ed,revision:rd}),H({type:G(`hello`),version:G(1),cursor:Ed,reset:B()}),H({type:G(`changed`),cursor:Ed,threadId:R().min(1),method:R().min(1)})]);let Dd=Oc(`type`,[H({type:G(`text`),id:R(),prompt:R(),secret:B().optional(),optional:B().optional()}),H({type:G(`choice`),id:R(),prompt:R(),multiple:B(),allowOther:B(),optional:B().optional(),options:V(H({value:R(),label:R(),description:R().optional()}))})]),Od=Oc(`type`,[H({type:G(`approval`),title:R(),description:R().optional(),subject:bc().optional(),actions:V(H({id:R(),label:R(),effect:R()}))}),H({type:G(`question`),title:R().optional(),questions:V(Dd)})]),kd=H({requestId:Ec([R(),z().int()]),threadId:R(),kind:W([`approval`,`question`]),interaction:Od,request:Td}),Ad=H({id:R().min(1),clientUserMessageId:R().min(1),input:V(Td),presentationInput:V(Td).nullable().optional()}).passthrough();H({fields:V(H({path:V(Ec([R(),z().int().nonnegative()])),originalLength:z().int().nonnegative()}))});let jd=H({id:R().min(1),status:R().min(1),codexhostTurnOutcome:H({status:G(`unknown`),reason:R()}).optional(),items:V(H({id:R().min(1),type:R().min(1)}).passthrough()),codexhostFileOperations:V(H({beforeItemId:R().nullable(),item:H({id:R().min(1),type:R().min(1)}).passthrough()})).optional(),error:H({message:R().optional()}).passthrough().nullable().optional(),fingerprint:R().min(1).optional(),unchanged:G(!0).optional()}).passthrough(),Md=H({id:R().min(1).max(512),fingerprint:R().min(1).max(128)});H({threadId:R().min(1),knownTurns:V(Md).max(64).optional(),truncateToolOutput:B().optional()});let Nd=H({harnessId:R().min(1),nativeSessionId:R().min(1)});H({cursor:Ed,activeTurnId:R().min(1).nullable().optional(),command:H({name:R().min(1),turn:jd,subsequentTurnId:R().min(1).optional()}).optional(),thread:H({id:R().min(1),cwd:R(),modelProvider:R().min(1),createdAt:z(),updatedAt:z(),status:H({type:R()}).passthrough(),name:R().nullable().optional(),preview:R().optional(),codexhostImportSource:Nd.optional(),turns:V(jd).length(0)}).passthrough(),turnsPage:H({data:V(jd).max(5),nextCursor:R().nullable()}),configuration:H({native:H({model:R().min(1).max(1024).optional(),reasoningEffort:R().min(1).max(128).optional()}).optional(),effectiveModel:ql.optional(),effectiveThinkingOptionId:Yl.optional(),effectivePermissionModeId:El.optional()}),queue:H({items:V(Ad),pausedReason:W([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:V(kd),handoff:kl.optional()}),H({version:G(1),owner:G(`service`).optional(),pid:z().int().positive(),port:z().int().min(1).max(65535),token:R().regex(/^[0-9a-f]{64}$/u),startedAt:z(),epoch:R().uuid(),capabilities:H({peerDelegation:G(1).optional()}).optional()}),H({epoch:R().uuid(),threadId:R().min(1),requestId:Ec([R(),z().int()]),result:Td}),H({includeArchived:B().optional(),officialCursor:H({live:R().nullable(),archived:R().nullable().optional()}).strict().optional(),scope:Ec([H({cwd:R().min(1).max(4096),excludeCwds:V(R().min(1).max(4096)).max(1024)}).strict(),H({projectId:R().min(1).max(1024),legacyThreadIds:V(R().min(1).max(1024)).max(1024),rootPaths:V(R().min(1).max(4096)).max(1024).optional()}).strict()]).optional()}).strict(),H({threads:V(gl),ownership:V(su),archivedThreadIds:V(K),officialCursor:H({live:R().nullable(),archived:R().nullable().optional()}).strict().optional()}).strict();let Pd=W([`running`,`waiting`,`idle`,`unknown`]),Fd=U({harnessId:Cl,title:R().optional(),status:Pd,archived:B()}),Id=U({revision:hc().nonnegative(),parents:Pc(K,K),nodes:Pc(K,Fd),truncated:B()}).refine(e=>Object.keys(e.nodes).length<=5e3,`Too many Thread tree nodes`).refine(({parents:e,nodes:t})=>Object.entries(e).every(([e,n])=>Object.hasOwn(t,e)&&Object.hasOwn(t,n)),`Missing Thread tree node`),Ld=R().min(1).max(128);U({});let Rd=U({subscriptionId:Ld});U({}),Rd.extend({snapshot:Id});let zd=R().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);H({available:B()}).strict(),H({path:R().min(1),mimeType:zd}).strict();let Bd=W([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);Oc(`ok`,[H({ok:G(!0),text:R()}).strict(),H({ok:G(!1),error:H({code:Bd}).strict()}).strict()]),H({threadId:K.optional(),cwd:R().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let Vd=H({name:R().min(1).regex(/^[^\s[\]]+$/u),description:R().optional(),path:R().min(1),scope:W([`project`,`global`]),source:R().min(1)}).strict();H({revision:z().int().nonnegative(),complete:B(),skills:V(Vd),warnings:V(R()).optional()}).strict(),H({cwd:R().min(1).optional()}).strict();let Hd=H({kind:W([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:R().min(1)}).strict(),Ud=Oc(`status`,[H({status:G(`not-installed`)}),H({status:G(`not-running`)}),H({status:G(`not-logged-in`)}),H({status:G(`https-disabled`)}),H({status:G(`not-serving`),command:R()}),H({status:G(`occupied`),target:R()}),H({status:G(`serving`),url:R(),funnel:B()}),H({status:G(`error`),message:R()})]);H({state:Ud,error:R().optional()}).strict();let Wd=Oc(`status`,[H({status:G(`on`)}),H({status:G(`off`)}),H({status:G(`invalid`),reason:R()})]),Gd=H({lan:B(),autostart:Wd}).strict(),Kd=H({expiresAt:R().optional(),issuing:B(),failure:H({detail:R().optional(),retryAt:R(),paused:B()}).optional()}),qd=Oc(`status`,[H({status:G(`off`),reason:W([`invite`,`name-taken`,`banned`]).optional()}),H({status:G(`connecting`),reason:W([`full`,`unreachable`]).optional()}),H({status:G(`connected`),url:R(),certificate:Kd}),H({status:G(`missing-certificate`),url:R(),certificate:Kd}),H({status:G(`stopped`),reason:W([`replaced`,`rejected`,`unsupported-version`])})]);R().max(253).regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/i).transform(e=>e.toLowerCase()),R().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let Jd=W([`official`,`self-hosted`]);H({secret:R().min(1),lastUsedAt:z().nullable(),networkUrls:V(Hd),directCandidates:V(Hd).optional(),tailscale:Ud,background:Gd.optional(),relay:H({state:qd,enabled:B(),kind:Jd,officialHost:R(),customHost:R().optional(),officialHostname:R().optional(),customHostname:R().optional(),quotaUntil:R().optional()}).strict().optional()}).strict();let Yd=U({threadId:R().min(1).max(1024),view:W([`result`,`messages`]),from:z().int().min(1).max(2**53-1).optional(),to:z().int().min(1).max(2**53-1).optional()}),Xd=/^[a-zA-Z0-9_-]{1,64}$/u,Zd=R().regex(Xd),Qd=R().regex(Xd),$d=R().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u),ef=W([`relay`,`tailscale`,`lan`,`custom`]),tf=[`blue`,`purple`,`cyan`,`green`,`amber`,`rose`,`slate`],nf=W(tf);new Set(tf);let rf=W([`connected`,`connecting`,`auth-error`,`offline`,`disabled`]);H({peers:V(H({peerId:Zd,hostId:$d,nodeId:Qd.optional(),name:R().min(1).max(120),color:nf.optional(),origin:R().min(1).max(2048),transportKind:ef,encrypted:B(),enabled:B(),state:rf,supportsPeerPairing:B().optional(),pairedBack:B().optional(),linkedPeerIds:V(Zd).max(128).optional(),latencyMs:z().int().nonnegative().optional(),version:R().max(128).optional(),platform:R().max(64).optional(),hostname:R().max(255).optional(),homeDir:R().max(4096).optional(),lastError:R().max(1e3).optional(),projectCount:z().int().nonnegative(),createdAt:R(),updatedAt:R()}))}),H({connectionUrl:R().min(1).max(4096).optional(),origin:R().min(1).max(2048).optional(),token:R().min(1).max(2048).optional(),name:R().trim().min(1).max(120).optional(),color:nf.optional(),pairBack:B().optional(),meshPeerIds:V(Zd).max(64).optional(),selfOrigin:R().min(1).max(2048).optional()}).refine(e=>!!e.connectionUrl||!!e.origin&&!!e.token,`Provide either connectionUrl or both origin and token`),U({origin:R().min(1).max(2048),token:R().min(1).max(2048),name:R().trim().min(1).max(120).optional(),color:nf.optional(),expectedNodeId:Qd.optional()}),H({status:W([`added`,`updated`,`existing`]),peerId:Zd,hostId:$d,nodeId:Qd.optional()});let af=W([`added`,`updated`,`existing`,`failed`,`skipped`]);H({results:V(H({targetPeerId:Zd,targetName:R().min(1).max(120),introducedHost:Ec([G(`local`),Zd]),introducedName:R().min(1).max(120),status:af,error:R().max(1e3).optional()}))}),H({peerIds:V(Zd).max(64).optional(),includeSelf:B().optional(),includeMesh:B().optional(),selfOrigin:R().min(1).max(2048).optional()}),H({peerId:Zd,name:R().trim().min(1).max(120).optional(),color:nf.nullable().optional(),connectionUrl:R().min(1).max(4096).optional(),origin:R().min(1).max(2048).optional(),token:R().min(1).max(2048).optional(),enabled:B().optional()}),H({peerId:Zd}),H({removed:B()}),H({peerId:Zd.optional(),connectionUrl:R().min(1).max(4096).optional(),origin:R().min(1).max(2048).optional(),token:R().min(1).max(2048).optional()}).refine(e=>!!e.peerId||!!e.connectionUrl||!!e.origin&&!!e.token,`Provide peerId, connectionUrl, or both origin and token`);let of=H({id:R().min(1).max(1024),name:R().min(1).max(512),path:R().min(1).max(8192)});H({ok:B(),nodeId:Qd.optional(),supportsPeerPairing:B().optional(),pairedBack:B().optional(),latencyMs:z().int().nonnegative().optional(),origin:R().max(2048).optional(),transportKind:ef.optional(),encrypted:B().optional(),version:R().max(128).optional(),platform:R().max(64).optional(),hostname:R().max(255).optional(),homeDir:R().max(4096).optional(),projectCount:z().int().nonnegative().optional(),projects:V(of).optional(),error:R().max(1e3).optional()});let sf=H({id:R().min(1).max(1024),name:R().min(1).max(512),path:R().min(1).max(8192),threadIds:V(R().min(1).max(1024))}),cf=H({attachments:G(1).optional(),workspaceFiles:G(1).optional(),officePreview:G(1).optional(),delegation:G(1).optional(),peerPairing:G(1).optional()}),lf=H({version:R().max(128),platform:R().max(64),hostname:R().max(255),homeDir:R().max(4096).optional(),epoch:R().min(1).max(256),nodeId:Qd.optional(),peerNodes:Pc($d,Qd).refine(e=>Object.keys(e).length<=128).optional(),projects:V(sf),capabilities:cf.optional()});U({threadId:R().min(1).max(1024),scope:R().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u).optional(),requestId:R().min(1).max(256).optional(),mode:W([`queue`,`steer`]).optional(),expectedTurnId:R().min(1).max(1024).nullable().optional(),content:V(Oc(`type`,[U({type:G(`text`),text:R()}),U({type:G(`file`),receiptId:R().min(1).max(128)})])).min(1).max(64)});let uf=H({ok:G(!1),error:H({code:R(),message:R(),details:Pc(R(),bc()).optional()})});Ec([H({ok:G(!0),value:H({receiptId:R().min(1),file:H({attachmentId:R(),name:R(),bytes:z().int().nonnegative()})})}),uf]),Ec([H({ok:G(!0),value:H({accepted:G(!0)})}),uf]);let df=H({name:R().min(1).max(512),path:R().min(1).max(8192),kind:G(`directory`)});H({peerId:Zd,path:R().min(1).max(8192).optional()}),H({path:R().min(1).max(8192),parentPath:R().min(1).max(8192).nullable(),homeDir:R().min(1).max(8192).optional(),entries:V(df)}),H({peerId:Zd,parentPath:R().min(1).max(8192),name:R().min(1).max(255).refine(e=>e.trim().length>0,`Directory name cannot be blank`)}),H({path:R().min(1).max(8192),name:R().min(1).max(255)}),H({peerId:Zd,path:R().min(1).max(8192),title:R().trim().min(1).max(255).optional()}),H({peerId:Zd,workspaceId:R().min(1).max(1024),title:R().trim().min(1).max(255)}),H({peerId:Zd,workspaceId:R().min(1).max(1024)}),H({workspaceId:R().min(1).max(1024).optional(),manifest:lf}),H({sessionHostId:R().min(1).max(128).optional()}),H({hosts:V(H({hostId:Ec([G(`local`),$d]),name:R().min(1).max(120),isLocal:B().optional(),color:nf.optional(),hostname:R().max(255).optional()}))}),H({hostId:Ec([G(`local`),$d])}),H({harnesses:V(H({id:R().regex(/^[a-z0-9][a-z0-9-]*$/u),name:R().min(1).max(120)}))});let ff=W([`listHarnesses`,`inspect`,`start`,`send`,`cancel`,`read`,`answer`,`list`]);U({operation:ff,hopCount:z().int().min(0).max(16),sourceId:Zd.optional(),input:gl});let pf=U({code:R().min(1).max(128),message:R().max(4096),details:gl.optional()});Ec([U({ok:G(!0),value:hl}),U({ok:G(!1),error:pf})]);let mf=U({id:R().min(1).max(1024),name:R().min(1).max(512),path:R().min(1).max(8192)});U({hosts:V(U({hostId:$d,nodeId:Qd.optional(),displayName:R().min(1).max(120),online:B(),state:rf,delegation:B(),projects:V(mf),platform:R().max(64).optional(),hostname:R().max(255).optional(),homeDir:R().max(4096).optional()}))}),U({version:G(1),instanceId:R().min(1).max(128),pid:z().int().positive(),endpoint:R().min(1).max(256),token:R().regex(/^[0-9a-f]{64}$/u),startedAt:z().int().nonnegative()}),Ec([U({operation:G(`hosts`)}),U({operation:ff,hostId:$d,hopCount:z().int().min(0).max(16),timeoutMs:z().int().min(1).max(12e4).optional(),input:gl})]);let hf=H({id:R().min(1).max(256),harnessId:R().min(1),label:R().min(1).max(512),provider:W([`openai-codex`,`xai`])}).strict(),gf=R().regex(/^[a-z][a-z0-9-]{0,47}$/),_f=H({name:gf,source:hf,importedAt:R()}).strict(),vf=Oc(`action`,[H({action:G(`list`)}).strict(),H({action:G(`import`),sourceId:R().min(1).max(256),name:gf,confirmed:G(!0)}).strict(),H({action:G(`reimport`),sourceId:R().min(1).max(256),name:gf,confirmed:G(!0)}).strict(),H({action:G(`remove`),name:gf,confirmed:G(!0)}).strict()]),yf=H({provider:R().min(1).max(128),type:W([`oauth`,`api_key`,`unknown`]),label:R().min(1).max(512).optional(),vendor:W([`openai-codex`,`xai`]).optional()}).strict();H({sources:V(hf),targets:V(H({harnessId:R(),providers:V(W([`openai-codex`,`xai`])),imports:V(_f),others:V(yf).default([])}).strict())}).strict(),H({targetHarnessId:R().min(1).max(128).optional(),request:vf}).strict(),H({events:B()});let bf=V(U({agent:R().min(1).max(128),section:W([`main`,`more`,`auto`])})).max(256).refine(e=>new Set(e.map(e=>e.agent)).size===e.length,`Duplicate Harness IDs`);U({entries:bf.nullable()}),U({}),U({entries:bf,initializeOnly:B().optional()});let xf=U({enabled:B(),timeoutMinutes:z().int().min(5).max(1440)});Object.freeze({enabled:!0,timeoutMinutes:10});let Sf=R().regex(/^external$/u),Cf=Cl.transform(e=>String(e)),wf=U({model:ql.optional(),thinkingOptionId:Yl.optional(),permissionModeId:El.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`),Tf=U({lastHarness:Cl.optional(),byHarness:Pc(Cf,wf)}),Ef=U({model:ql.optional(),thinkingOptionId:Yl.optional()}).refine(e=>!!(e.model||e.thinkingOptionId),`A delegation default must contain a Model or Thinking option`),Df=U({byHarness:Pc(Cf,Ef)}),Of=R().min(1).max(1024),kf=U({idleRelease:xf.optional(),favorites:Pc(Cf,V(Of).max(2048)).default({}),newThread:Tf.optional(),delegation:Df.optional()});U({scope:Sf,revision:z().int().nonnegative(),values:kf}),U({scope:Sf.default(`external`)});let Af=Oc(`kind`,[U({kind:G(`idleRelease`),value:xf}),U({kind:G(`favorite`),harnessId:Cl,modelId:Of,enabled:B()}),U({kind:G(`favorites`),harnessId:Cl,modelIds:V(Of).max(2048)}),U({kind:G(`newThread`),lastHarness:Cl.optional(),harnessId:Cl.optional(),configuration:wf.optional()}),U({kind:G(`delegation`),harnessId:Cl,configuration:Ef.nullable()})]);U({scope:Sf.default(`external`),operations:V(Af).min(1).max(256),initializeOnly:B().optional(),expectedRevision:z().int().nonnegative().optional()}).superRefine((e,t)=>{for(let n of e.operations)n.kind===`newThread`&&(!n.lastHarness&&!n.configuration||!!n.harnessId!=!!n.configuration)&&t.addIssue({code:`custom`,message:`A default Harness or complete configuration is required`})}),U({version:G(1),revision:z().int().nonnegative(),scopes:Pc(Sf,kf)});let jf=z().finite().nonnegative(),Mf=U({input:jf,output:jf,cacheRead:jf.optional(),cacheWrite:jf.optional(),cacheWrite1h:jf.optional()}),Nf=R().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);U({path:R(),entries:V(U({key:R(),price:Mf})),error:R().nullable()}),U({}),U({key:Nf,price:Mf.nullable(),previousKey:Nf.optional()}),U({model:Nf});let Pf=U({official:B().optional(),canonicalModelId:R().min(1).optional(),provider:R().min(1).max(512),model:R().min(1).max(512),price:Mf});U({price:Mf.nullable(),suggestions:V(Pf).max(6).optional()});let Ff=[`today`,`7d`,`30d`,`90d`,`all`],If=z().int().min(0).max(2**53-1),Lf=R().regex(/^\d{4}-\d{2}-\d{2}$/u),Rf=R().min(1).max(128),zf=R().min(1).max(512),Bf=R().min(1).max(4096);U({range:W(Ff),timeZone:R().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:Rf.optional(),model:zf.nullable().optional(),project:Bf.nullable().optional(),date:Lf.optional()});let Vf=U({requests:If,inputTokens:If,cachedInputTokens:If,cacheWriteInputTokens:If,cacheKnownInputTokens:If,cacheHitCachedInputTokens:If,cacheHitInputTokens:If,outputTokens:If,reasoningOutputTokens:If,costUsd:z().finite().min(0),unpricedRequests:If,unmeteredRequests:If}),Hf=Vf.shape,Uf=U({harness:Rf,sessionId:R().min(1).max(512),project:Bf.nullable(),title:R().min(1).max(200).optional(),models:V(zf).max(16),firstAtMs:If,lastAtMs:If,...Hf});U({range:W(Ff),from:Lf.nullable(),to:Lf,filters:U({harness:Rf.nullable(),model:zf.nullable(),unknownModel:B(),project:Bf.nullable(),unknownProject:B(),date:Lf.nullable()}),reading:U({complete:B(),sources:If,read:If}),failures:V(U({harness:Rf,message:R().max(2048)})).max(256),options:U({harnesses:V(Rf).max(256),models:V(zf.nullable()).max(4096),projects:V(Bf.nullable()).max(4096)}),modelLabels:V(U({harness:Rf,model:zf,label:zf})).max(4096).optional(),credits:V(U({harness:Rf,model:zf.nullable(),credits:z().finite().min(0),reportedRequests:If,requests:If})).max(4096).optional(),totals:Vf,daily:V(U({date:Lf,harness:Rf,...Hf})).max(2e5),hourly:V(U({weekday:z().int().min(0).max(6),hour:z().int().min(0).max(23),...Hf})).max(168),byHarness:V(U({harness:Rf,...Hf})).max(256),byModel:V(U({model:zf.nullable(),...Hf,harnessPricedRequests:If})).max(4096),byProject:V(U({project:Bf.nullable(),...Hf})).max(4096),sessions:V(Uf).max(100),recentSessions:V(Uf).max(100).optional()}),H({threadId:K}),H({discarded:B()});let Wf=Oc(`type`,[H({id:R().min(1),type:G(`choice`),prompt:R(),options:V(H({value:R().min(1),label:R(),description:R().optional()})).min(1),multiple:B(),allowOther:B(),optional:B()}),H({id:R().min(1),type:G(`text`),prompt:R(),multiline:B(),secret:G(!1),optional:B(),placeholder:R().optional(),prefill:R().optional()})]),Gf=H({interactionId:R().min(1),turnId:R().min(1),title:R().optional(),questions:V(Wf).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});U({threadId:R().min(1)}),H({questions:V(Gf)}),U({threadId:R().min(1),turnId:R().min(1),interactionId:R().min(1),answers:Pc(R(),V(R())),cancelled:B().default(!1)}),H({accepted:G(!0)});let Kf=H({path:R(),oldText:R().nullable(),newText:R()});H({sessionId:R().min(1),turn:z().int().nonnegative(),path:R().min(1).optional()}),H({diffs:V(Kf)}),U({}),U({}),H({reference:H({sessionId:R().min(1),epoch:R().min(1),turn:z().int().nonnegative(),seq:z().int().nonnegative(),callId:R().min(1),part:z().int().nonnegative(),version:R().min(1)}),length:z().int().nonnegative(),bytes:z().int().nonnegative()}),U({title:R().trim().min(1).max(200),type:W([`info`,`warning`,`danger`]),body:R().trim().min(1).max(16384)}),U({}),U({url:R().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)}),Object.freeze(/* @__PURE__ */ `codexhost/console/remote-connections.codexhost/runtime/status.codexhost/remote/ssh-setup.codexhost/harness/plugins/list.codexhost/harness/display-settings/capabilities.codexhost/harness/display-settings/get.codexhost/harness/display-settings/set.codexhost/harness/inspect.codexhost/harness/installation.codexhost/harness/installation/start.codexhost/harness/installation/status.codexhost/harness/launch-settings/get.codexhost/harness/launch-settings/set.codexhost/harness/web-ui/open.codexhost/harness/accounts/sources.codexhost/harness/accounts/list.codexhost/harness/accounts/inspect.codexhost/harness/credential-imports.codexhost/harness/session-import/sources.codexhost/harness/session-import/list.codexhost/harness/session-import/import.codexhost/account/list.codexhost/account/refresh.codexhost/account/usage/inspect.codexhost/usage/model-prices/get.codexhost/usage/model-prices/set.codexhost/usage/model-prices/default.codexhost/usage/statistics/get.codexhost/update/check.codexhost/update/start.codexhost/update/status`.split(`.`));let qf=W([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),Jf=W([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);U({threadId:R(),title:R(),harnessId:R(),state:qf,reason:Jf,inactiveMs:z().nonnegative()}),U({threadId:K,turnId:wl});let Yf=H({email:R().trim().min(1).max(320).optional(),label:R().trim().min(1).max(256).optional(),plan:R().trim().min(1).max(128).optional(),credits:Hl.optional(),balance:Ul.optional()}).strict();function Xf(e){return e.refine(e=>{let t=e;return t.credits!==void 0||t.balance!==void 0},{message:`Account must report either credits or a balance`})}let Zf=Xf(Yf),Qf={harnessId:Cl,harnessName:R().trim().min(1).max(128)},$f=H(Qf).strict();H({}).strict(),H({sources:V($f).max(128)}).strict(),H({harnessId:Cl,refresh:B().optional()}).strict(),H({...Qf,account:Zf.nullable(),accounts:V(Zf).max(8).optional()}).strict(),H({refresh:B().optional()}).strict(),H({accounts:V(Xf(Yf.extend(Qf))).max(128)}).strict(),H({harnessId:uu,model:ql.optional(),thinkingOptionId:Yl.optional(),permissionModeId:El.optional(),prewarm:G(!0).optional()}).strict();let ep=R().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);H({harnessId:uu}).strict().extend({path:ep.nullable()}),H({path:ep.nullable(),restartRequired:B()}).strict(),H({harnessId:Cl,action:W([`check`,`update`,`install`]),confirmedVersion:R().min(1).max(128).optional()}).strict().refine(({action:e,confirmedVersion:t})=>e===`update`||t===void 0);let tp=H({currentVersion:R().min(1).max(128),latestVersion:R().min(1).max(128),updateAvailable:B(),canUpdate:B(),latestVerifiedVersion:R().min(1).max(128).optional(),confirmationRequired:G(!0).optional(),versionKind:W([`cli`,`application`]).optional(),manualUpdateUrl:Zs().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:R().max(2048).optional(),messageCode:R().min(1).max(128).optional(),notice:xl.optional(),latestVersionKind:W([`unknown`,`tracking-branch`]).optional()}).strict();H({taskId:R().uuid()}).strict(),Oc(`status`,[H({taskId:R().uuid(),status:G(`running`)}).strict(),H({taskId:R().uuid(),status:G(`succeeded`),result:tp}).strict(),H({taskId:R().uuid(),status:G(`failed`),error:H({code:z().int(),message:R().min(1).max(2048)}).strict()}).strict()]);let np=R().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),rp=R().trim().min(1),ip=W([`free`,`go`,`plus`,`pro`,`prolite`,`team`,`self_serve_business_prolite`,`self_serve_business_usage_based`,`business`,`ent26`,`enterprise_cbp_automation`,`enterprise_cbp_usage_based`,`enterprise`,`edu`,`edu_plus`,`edu_pro`,`unknown`]),ap=H({accountId:np,label:rp.max(256),email:R().email().max(320).optional(),planType:ip.optional()}).strict(),op=W([`ready`,`unavailable`]);H({version:G(2),currentAccountId:np.nullable(),phase:op,revision:z().int().nonnegative(),instanceId:rp.max(1024).optional(),accounts:V(ap).max(1)}).strict(),H({accountId:np,refresh:B().optional()}).strict(),H({accountId:np,usage:Il.nullable(),accountCredits:Hl.optional(),freshness:W([`live`,`cached`]),observedAt:R().datetime().nullable()}).strict();let sp=1e3,cp=R().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),lp=cp.max(1024),up=H({nativeSessionId:lp,title:cp.max(4096).nullable(),updatedAt:z().int().nonnegative().max(864e13),cwd:cp.max(16384),running:B().nullable()}).strict();H({}).strict(),H({harnesses:V(H({harnessId:uu,name:cp.max(128)}).strict()).max(128)}).strict(),H({harnessId:uu,query:R().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:z().int().nonnegative().safe().optional(),limit:z().int().min(1).max(sp).optional()}).strict(),H({candidates:V(up).max(sp),total:z().int().nonnegative().safe()}).strict(),H({harnessId:uu,nativeSessionId:lp}).strict(),H({threadId:cp.max(1024).pipe(K)}).strict();let dp=R().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),fp=lp,pp=up;H({}).strict(),H({candidates:V(pp).max(1e3)}).strict(),H({nativeSessionId:fp}).strict(),H({threadId:dp.max(1024).pipe(K)}).strict(),H({threadId:K,lastTurnId:wl}).strict(),H({threadId:K}).strict();let mp=R().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();H({commands:V(H({id:mp,invocation:R().min(1).max(128),label:R().trim().min(1).max(128),description:R().trim().min(1).max(512).optional(),localizations:bl.optional(),argumentMode:W([`none`,`text`]),kind:W([`command`,`skill`]).optional()}).strict()),warnings:V(R().min(1)).optional(),source:W([`live`,`static`]).optional()}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.commands.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Harness command IDs must be unique`,path:[`commands`,r,`id`]}),n.add(i.id)}),H({harnessId:Cl,cwd:R().min(1).optional()}).strict(),H({threadId:K}).strict(),H({threadId:K,commandId:mp,turnId:wl.optional(),arguments:gl.optional()}).strict(),H({accepted:G(!0),turnId:wl.optional()}).strict();let hp=G(`2.0`).optional(),gp=Sc().optional(),_p=R().min(1),vp=Ec([R(),z().int()]),yp=H({code:z().int(),message:R(),data:hl.optional()}).catchall(hl).superRefine(ul([`data`]));Ec([H({jsonrpc:hp,id:vp,method:_p,params:hl.optional(),result:gp,error:gp}).catchall(hl).superRefine(ul([`jsonrpc`,`params`,`result`,`error`])),H({jsonrpc:hp,id:gp,method:_p,params:hl.optional(),result:gp,error:gp}).catchall(hl).superRefine(ul([`jsonrpc`,`id`,`params`,`result`,`error`])),H({jsonrpc:hp,id:vp,method:gp,params:gp,result:hl,error:gp}).catchall(hl).superRefine(ul([`jsonrpc`,`method`,`params`,`error`])),H({jsonrpc:hp,id:vp,method:gp,params:gp,result:gp,error:yp}).catchall(hl).superRefine(ul([`jsonrpc`,`method`,`params`,`result`]))]);let bp=R().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});U({harnessId:Cl,nativeSessionId:bp,locator:hl.optional(),formatVersion:G(1)}).superRefine(ul([`locator`])),U({harnessId:Cl,nativeSessionId:bp,nativeTurnKey:bp,formatVersion:G(1)}),U({harnessId:Cl,nativeSessionId:bp,checkpointId:bp,locator:hl.optional(),formatVersion:G(1)}).superRefine(ul([`locator`]));let xp=R().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),Sp=W([`npm`,`windows-installer`,`macos-dmg`,`linux-archive`]),Cp=W([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),wp=U({completed:z().int().nonnegative(),total:z().int().positive()}).refine(e=>e.completed<=e.total,{path:[`completed`],message:`completed must not exceed total`}),Tp=U({version:xp,installation:Sp,phase:Cp,updatedAt:z().int().nonnegative(),downloadedBytes:z().int().nonnegative().optional(),totalBytes:z().int().positive().optional(),npmDownload:wp.optional(),error:R().min(1).max(500).nullable(),serviceStopOutput:R().optional()}).superRefine((e,t)=>{e.downloadedBytes!==void 0&&e.totalBytes!==void 0&&e.downloadedBytes>e.totalBytes&&t.addIssue({code:`custom`,path:[`downloadedBytes`],message:`downloadedBytes must not exceed totalBytes`})});U({});let Ep=R().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u,`release notes URL must identify a codexhost GitHub Release`);U({currentVersion:xp,installation:Sp.nullable(),latestVersion:xp.nullable(),updateAvailable:B(),installationAvailable:B(),releaseNotes:R().min(1).max(2e4).nullable(),releaseNotesUrl:Ep.nullable(),status:Tp.nullable(),error:R().min(1).max(500).nullable()}),U({status:Tp}),U({status:Tp.nullable()});let Dp=U({icon:R().min(1).max(16).optional(),title:R().min(1).max(120),body:R().min(1).max(1200),contributors:V(R().min(1).max(39)).max(30)}),Op=U({summary:R().min(1).max(600).optional(),themes:V(Dp).min(1).max(12)}),kp=U({version:xp,publishedAt:ll(),url:R().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),zh:Op.nullable(),en:Op.nullable()}).refine(e=>e.zh!==null||e.en!==null,{message:`an announcement needs at least one language`});U({manual:B().optional()}),U({announcement:kp.nullable(),unread:B()}),U({version:xp});let Ap=RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);function jp(e){let[t,...n]=e.trim().split(/\r?\n/u);if(t!==`[codexhost thread watch] Read each Thread's result, then continue your task:`)return;let r=[];for(let e of n){if(!e.trim())continue;let t=Ap.exec(e);if(!t)return;let[,n=``,i=``,a,o]=t;r.push({threadId:i,label:n,outcome:a,...o?{note:o}:{}})}return r.length>0?r:void 0}let Mp=`<response-annotations>`,Np=`</response-annotations>`,Pp=/## My request(?: for Codex)?:/gu;function Fp(e){if(e.length===0)return``;let t=e.map(({text:e,annotation:t})=>({text:e,...t===void 0?{}:{annotation:t}}));return`\n# Response annotations:\nEach item contains text selected from an earlier Codex response and may include a user comment. Treat items as Annotation 1, Annotation 2, and so on in array order. Use every selection as context and address every comment. For every annotation you address, include its inline directive \`:codex-annotation{index="N"}\`, where N is its one-based array position (for example, \`:codex-annotation{index="1"}\`). Do not use unstructured annotation labels.\n${Mp}\n${JSON.stringify(t)}\n${Np}\n`}function Ip(e,t){let n=Fp(e);return n===``?t:`${n}\n## My request:\n${t}\n`}function Lp(e){let t=e.trimStart().startsWith(`# Response annotations:`)?0:e.length,n=e.indexOf(`\n${Mp}\n`,t);if(n<0)return``;let r=n+1+22+1,i=e.indexOf(`\n${Np}`,r);return i<0?``:e.slice(r,i)}function Rp(e){return{annotations:Vp(e),body:zp(e)}}function zp(e){let t=0;for(let n of e.matchAll(Pp))t=n.index+n[0].length;return e.slice(t).trim()}function Bp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Vp(e){let t=Lp(e);if(t===``)return[];let n;try{n=JSON.parse(t)}catch{return[]}if(!Array.isArray(n)||n.length===0)return[];let r=[];for(let e of n){if(!Bp(e))return[];let{text:t,annotation:n}=e;if(typeof t!=`string`||t.length===0||n!==void 0&&(typeof n!=`string`||n.length===0))return[];r.push({text:t,...n===void 0?{}:{annotation:n}})}return r}function Hp(e){return Vp(e)}let Up=W([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);H({runningVersion:R().nullable(),installedVersion:R().nullable(),restartRequired:B(),remote:B(),updateSupported:B(),update:H({phase:Up,targetVersion:R().nullable(),error:R().nullable()})});let Wp=H({version:R().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();H({hostname:R().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:z().int().min(1).max(65535).nullable(),identity:R().max(4096).nullable(),action:W([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:B().optional(),version:R().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),H({state:W([`installed`,`not-installed`])}).strict();let q=R().min(1).max(1024),Gp={hostId:q.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)},Kp={...Gp,threadId:q},qp=R().min(1).max(8e3),Jp={text:qp,requestId:q};Oc(`accepted`,[H({accepted:G(!0),startQueuedItemId:q.optional()}),H({accepted:G(!1),code:W([`remote/queue-unavailable`,`remote/steer-unavailable`,`remote/turn-changed`,`remote/send-rejected`,`session/queue-item-not-found`,`session/queue-item-starting`]),message:R()})]),Oc(`available`,[H({available:G(!1)}),H({available:G(!0),items:V(H({id:q,clientUserMessageId:q,preview:R().max(801)})).max(100)})]);let Yp=Oc(`kind`,[U({kind:G(`hosts`)}),U({kind:G(`create`),...Gp,cwd:R().min(1).max(8192),epoch:q}),U({kind:G(`projectHarnesses`),...Gp,epoch:q}),U({kind:G(`inspectHarness`),...Gp,epoch:q,cwd:R().min(1).max(8192),harnessId:q}),U({kind:G(`startSelected`),...Gp,epoch:q,cwd:R().min(1).max(8192),harnessId:q,model:R().min(1).max(4096),serviceTier:W([`priority`,`ultrafast`]).optional(),reasoningEffort:q.optional()}),U({kind:G(`status`),...Kp}),U({kind:G(`list`),...Gp,cursor:R().nullable(),archived:B(),includeLoaded:G(!0).optional()}),U({kind:G(`read`),...Kp,page:U({cursor:R().min(1).max(8192).nullable(),epoch:q.optional(),sortDirection:W([`asc`,`desc`]).optional(),limit:z().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),U({kind:G(`usage`),...Kp,epoch:q}),U({kind:G(`configure`),...Kp,epoch:q,modelId:q.optional(),serviceTier:Kl.optional(),thinkingOptionId:q.optional(),permissionModeId:q.optional()}).refine(e=>[e.modelId,e.thinkingOptionId,e.permissionModeId].filter(e=>e!==void 0).length===1,`Select exactly one remote setting`).refine(e=>e.serviceTier===void 0||e.modelId!==void 0,{message:`A service tier requires a Model ID`}),U({kind:G(`prompt`),...Kp,epoch:q,text:qp,requestId:q.optional()}),U({kind:G(`queue`),...Kp,epoch:q}),U({kind:G(`delivery`),...Kp,epoch:q,action:Oc(`kind`,[U({kind:G(`enqueue`),...Jp}),U({kind:G(`steer`),...Jp,turnId:q}),U({kind:G(`remove`),itemId:q}),U({kind:G(`start`),itemId:q,onlyIfHead:G(!0).optional()}),U({kind:G(`sendNow`),itemId:q})])}),U({kind:G(`interrupt`),...Kp,epoch:q,turnId:q}),U({kind:G(`rename`),...Kp,epoch:q,name:R().min(1).max(512)}),U({kind:G(`archive`),...Kp,epoch:q,archived:B()}),U({kind:G(`respond`),...Kp,epoch:q,requestId:Ec([q,z().int()]),result:Pc(R(),bc())})]),Xp=R().min(1).max(1024),Zp=H({hostId:Xp,displayName:R().min(1).max(1024),source:W([`codex-managed`,`discovered`]),sshAlias:R().max(1024).nullable(),sshHost:R().min(1).max(1024),sshPort:z().int().min(1).max(65535).nullable(),identity:R().max(4096).nullable(),autoConnect:B(),connectionAnalyticsId:R().max(1024).optional()}),Qp=U({displayName:R().min(1).max(1024),hostname:R().min(1).max(1024),sshPort:z().int().min(1).max(65535).nullable(),identity:R().max(4096).nullable()});Oc(`action`,[U({action:G(`session`),operation:Yp}),U({action:G(`list`)}),U({action:G(`catalog`)}),U({action:G(`read-thread`),hostId:Xp.refine(e=>e!==`local`),input:Yd}),U({action:G(`save`),draft:Qp,previous:Zp.nullable()}),U({action:G(`remove`),previous:Zp}),U({action:G(`connect`),hostId:Xp,enabled:B()}),U({action:G(`state`),hostId:Xp}),U({action:G(`runtime`),hostId:Xp}),U({action:G(`update`),hostId:Xp.refine(e=>e!==`local`),version:Wp.shape.version})]),Ec([U({result:hl}),U({error:U({code:z().int(),message:R()})})]),U({prompt:R().trim().min(1).max(2e3),cwd:R().max(4096).nullable()}),R().trim().min(1).max(60).nullable();let $p=R().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),em=Ec([R(),H({en:R()}).catchall(R())]),tm=H({title:em.optional(),description:em.optional(),icon:R().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:R().optional()});H({extensions:V(H({id:$p,name:R().min(1).max(214),version:R().min(1).max(128),format:G(`dsh`),supportedTargets:Mc([G(`web`)]),enabledTargets:V(G(`web`)).max(1),source:R().min(1).max(4096),projectUrl:R().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:R(),meta:tm.optional(),loadError:R().optional()})),loadedIds:V($p),safeMode:B(),storeError:R().optional()});let nm=R().trim().max(2048).url({protocol:/^https?$/u,normalize:!0}).refine(e=>!/[\s\\?#]/u.test(e)&&!e.split(`/`)[2]?.includes(`@`),`Use an HTTP(S) registry URL without credentials, a query, or a fragment.`).transform(e=>e.endsWith(`/`)?e:`${e}/`);H({spec:R().trim().min(1).max(4096),registry:nm.optional()}).strict(),H({id:$p,enabled:B()}).strict(),H({id:$p}).strict(),G(1);function rm(e){return{code:{copyLabel:e(`copy`),copiedLabel:e(`copied`),toolbarLabels:{codeLabel:e(`codeBlock.title`),wrapLabel:e(`codeBlock.wrap`),unwrapLabel:e(`codeBlock.unwrap`)}},footnotes:e(`markdown.footnotes`)}}function im(e){return{label:t=>e(`annotation.label`,{index:t}),railLabel:t=>e(`annotation.chipLabel`,{index:t}),railTitle:(t,n)=>e(`annotation.title`,{index:t,excerpt:n}),remove:t=>e(`annotation.remove`,{index:t}),selectedText:e(`annotation.selectedText`),userComment:e(`annotation.userComment`)}}let am=`@deepseek-ai/dsh-client-ui-chat/ThreadWatchNotice.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(am)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=am,e.textContent=`._5b1uNW_card{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-base);width:fit-content;max-width:100%;color:var(--dsw-alias-label-secondary);font-size:var(--dsh-content-font-size-secondary,13px);align-items:flex-start;gap:10px;padding:10px 14px;line-height:20px;display:flex}._5b1uNW_list{min-width:0;margin:0;padding:0;list-style:none}._5b1uNW_entry+._5b1uNW_entry{margin-top:10px}._5b1uNW_line{align-items:center;gap:8px;min-width:0;display:flex}._5b1uNW_line>svg,._5b1uNW_bell{flex-shrink:0}._5b1uNW_bell{color:var(--dsw-alias-label-tertiary);margin-top:3px}._5b1uNW_title{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-primary);overflow:hidden}._5b1uNW_outcome,._5b1uNW_open{white-space:nowrap;flex-shrink:0}._5b1uNW_outcome[data-outcome=completed]{color:var(--dsw-alias-state-success-primary)}._5b1uNW_outcome[data-outcome=failed]{color:var(--dsw-alias-state-error-primary)}._5b1uNW_open a{color:var(--dsw-alias-state-business-primary);text-decoration:none}._5b1uNW_open a:hover{text-decoration:underline}._5b1uNW_open a:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}._5b1uNW_note{color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;margin:4px 0 0 24px}@media (width<=480px){._5b1uNW_line{flex-wrap:wrap}._5b1uNW_title{flex:calc(100% - 52px)}._5b1uNW_outcome{margin-left:24px}}`,document.head.appendChild(e)}var om={bell:`_5b1uNW_bell`,card:`_5b1uNW_card`,entry:`_5b1uNW_entry`,line:`_5b1uNW_line`,list:`_5b1uNW_list`,note:`_5b1uNW_note`,open:`_5b1uNW_open`,outcome:`_5b1uNW_outcome`,title:`_5b1uNW_title`};let sm=()=>()=>{};function cm({entry:e,links:t,t:n}){let r=`codex://threads/${e.threadId}`,i=()=>t?.describe?.(r)?.title,a=(0,d.useSyncExternalStore)(t?.resolve.subscribe??sm,i,i),o=a!==void 0;return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:om.entry,"data-thread-watch-entry":e.threadId,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:om.line,children:[o?t?.describe?.(r)?.icon:/* @__PURE__ */ (0,f.jsx)(p.ReferenceIconRegular,{kind:`session`,size:14}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:om.title,title:a??e.label,children:a??e.label}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:om.outcome,"data-outcome":e.outcome,children:n(`message.watch.${e.outcome}`)}),o&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:om.open,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownAnchor,{href:r,glyph:!1,children:[n(`message.watch.open`)]})})]}),e.note!==void 0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:om.note,children:e.note})]})}function lm({entries:e,links:t,t:n}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:om.card,"data-thread-watch-notice":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.IconBellOutlineRegular,{className:om.bell}),/* @__PURE__ */ (0,f.jsx)(`ul`,{className:om.list,children:e.map((e,r)=>/* @__PURE__ */ (0,f.jsx)(cm,{entry:e,links:t,t:n},r))})]})}let um=`@deepseek-ai/dsh-client-ui-chat/MessageItem.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(um)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=um,e.textContent=`.h5bUAG_userRow{flex-direction:column;align-items:flex-end;gap:6px;display:flex}.h5bUAG_noticeRow{flex-direction:column;align-items:center;gap:6px;min-width:0;display:flex}.h5bUAG_noticeStack{min-width:0;max-width:100%}.h5bUAG_userStack{min-width:0;max-width:min(calc(var(--dsh-chat-content-width,748px) * .702), 82%);flex-direction:column;align-items:flex-end;gap:8px;display:flex}.h5bUAG_annotationRow{flex-wrap:wrap;justify-content:flex-end;gap:6px;display:flex}.h5bUAG_bubble{background:var(--dsw-specific-bubble);border-radius:var(--dsw-radius-xl);max-width:100%;font-size:var(--dsh-content-font-size,14px);line-height:calc(22px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-primary);white-space:pre-wrap;word-break:break-word;padding:10px 16px}body[data-codexhost-wallpaper] .h5bUAG_bubble{background:color-mix(in srgb, var(--dsw-specific-bubble) 84%, transparent);backdrop-filter:blur(12px)}body[data-codexhost-wallpaper] [data-chat-flow-key]:not([data-chat-flow-key] *,[data-chat-near-viewport]) .h5bUAG_bubble{backdrop-filter:none}@supports (-webkit-touch-callout:none){body[data-codexhost-wallpaper] .h5bUAG_userRow{transform:translateZ(0)}}.h5bUAG_referenceSummary{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}.h5bUAG_contextRow{padding:2px 0}.h5bUAG_compactionRow{--dsh-compaction-header-height:calc(24px + var(--dsh-content-font-delta,0px));padding:2px 0}.h5bUAG_compactionButton{width:100%;height:var(--dsh-compaction-header-height);border-radius:var(--dsw-radius-sm);min-width:0;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:left;background:0 0;border:none;align-items:center;padding:0;transition:color .1s;display:flex}.h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton{z-index:7;background:var(--dsw-alias-bg-base);border-radius:0;position:sticky;top:0}body[data-codexhost-wallpaper] .h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton{background:color-mix(in srgb, var(--dsw-alias-bg-base) 78%, transparent);backdrop-filter:blur(12px)}body[data-codexhost-wallpaper] [data-chat-flow-key]:not([data-chat-flow-key] *,[data-chat-near-viewport]) .h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton{backdrop-filter:none}.h5bUAG_compactionBody :has(>[data-code-block-banner]){top:var(--dsh-compaction-header-height)}@media (hover:hover){.h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton:hover{background:var(--dsw-alias-interactive-bg-hover-solid)}.h5bUAG_compactionButton:hover{color:var(--dsw-alias-label-secondary)}.h5bUAG_compactionButton:not(:disabled):hover{background:var(--dsw-alias-interactive-bg-hover)}}.h5bUAG_compactionButton:not(:disabled){cursor:pointer}.h5bUAG_compactionButton:not(:disabled):active{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover)}.h5bUAG_compactionLeading{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));color:inherit;flex:none;place-items:center;margin-right:6px;display:inline-grid}.h5bUAG_compactionLeading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}.h5bUAG_compactionContextIcon,.h5bUAG_compactionDisclosureIcon{grid-area:1/1;justify-content:center;align-items:center;display:inline-flex}.h5bUAG_compactionDisclosureIcon,.h5bUAG_compactionButton:not(:disabled):hover .h5bUAG_compactionContextIcon,.h5bUAG_compactionButton:not(:disabled):focus-visible .h5bUAG_compactionContextIcon{opacity:0}.h5bUAG_compactionButton:not(:disabled):hover .h5bUAG_compactionDisclosureIcon,.h5bUAG_compactionButton:not(:disabled):focus-visible .h5bUAG_compactionDisclosureIcon{opacity:1}.h5bUAG_compactionTitle{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:inherit;flex:none}.h5bUAG_compactionSep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.h5bUAG_compactionSummary{min-width:0;color:inherit;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.h5bUAG_compactionBody{padding:4px 0 4px calc(22px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px))}.h5bUAG_retryRow{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px))}.h5bUAG_retrySummary{border-radius:var(--dsw-radius-sm);width:fit-content;max-width:100%;color:inherit;cursor:pointer;user-select:none;align-items:center;gap:7px;padding:2px 0;list-style:none;display:inline-flex}.h5bUAG_retrySummary::-webkit-details-marker{display:none}.h5bUAG_retrySummary:after{content:"";border-bottom:1.5px solid;border-right:1.5px solid;flex:none;width:6px;height:6px;margin-right:2px;transition:transform .12s;transform:rotate(-45deg)}.h5bUAG_retrySummary:hover{color:var(--dsw-alias-label-secondary)}@media (prefers-reduced-motion:reduce){.h5bUAG_compactionButton{transition:none}}.h5bUAG_retrySummary:focus-visible{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}.h5bUAG_retryText{overflow-wrap:anywhere;min-width:0}.h5bUAG_retryRow[open] .h5bUAG_retrySummary:after{transform:rotate(45deg)}.h5bUAG_retryDetails{overflow-wrap:anywhere;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));gap:2px;margin-top:3px;padding-left:14px;display:grid}.h5bUAG_retryDetailLabel{color:var(--dsw-alias-label-secondary)}.h5bUAG_turnErrorRow{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));grid-template-columns:10px minmax(0,1fr) auto;align-items:start;gap:8px;padding:2px 0;display:grid}.h5bUAG_turnErrorDot{margin-top:5px}.h5bUAG_turnErrorCopy{overflow-wrap:anywhere;min-width:0}.h5bUAG_turnErrorTitle{color:var(--dsw-alias-state-error-primary);margin-right:6px;font-weight:600}.h5bUAG_turnErrorMessage{color:var(--dsw-alias-label-secondary)}.h5bUAG_turnErrorCode{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-markdown-code-block-small)}.h5bUAG_maxTokensTitle{color:var(--dsw-alias-state-warn-primary);margin-right:6px;font-weight:600}.h5bUAG_attachmentRow{flex-wrap:wrap;justify-content:flex-end;gap:8px;max-width:100%;display:flex}.h5bUAG_pendingAttachment{flex-direction:column;align-items:flex-end;gap:4px;min-width:0;display:flex}.h5bUAG_fileCard{border:.5px solid var(--dsw-alias-border-l2,#0000001f);border-radius:var(--dsw-radius-xl);background:var(--dsw-specific-input-major,transparent);box-sizing:border-box;flex:none;align-items:center;gap:10px;width:240px;min-height:64px;padding:8px 12px;display:inline-flex}.h5bUAG_fileIcon{flex:none;width:28px;height:28px}.h5bUAG_fileContent{flex-direction:column;flex:1;min-width:0;display:flex}.h5bUAG_fileName{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px;overflow:hidden}.h5bUAG_fileMeta{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-tertiary,#00000073);font-size:12px;line-height:15px;overflow:hidden}.h5bUAG_editAction{color:inherit;cursor:pointer;border-radius:var(--dsw-radius-sm);background:0 0;border:0;justify-content:center;align-items:center;width:28px;height:28px;padding:6px;display:inline-flex}.h5bUAG_editAction:hover{background:var(--dsw-alias-interactive-bg-hover)}.h5bUAG_editAction svg{width:15px;height:15px}.h5bUAG_userStack:has(.h5bUAG_sentEditor){width:100%}.h5bUAG_sentEditor{box-sizing:border-box;border:1px solid var(--dsw-alias-border-main);border-radius:12px;width:100%;min-width:0;padding:12px}.h5bUAG_sentEditor textarea{resize:vertical;width:100%;min-height:100px;color:inherit;font:inherit;box-sizing:border-box;background:0 0;border:0;outline:0;line-height:1.6}.h5bUAG_sentEditor:focus-within{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}.h5bUAG_sentEditorActions{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}`,document.head.appendChild(e)}var J={annotationRow:`h5bUAG_annotationRow`,attachmentRow:`h5bUAG_attachmentRow`,bubble:`h5bUAG_bubble`,compactionBody:`h5bUAG_compactionBody`,compactionButton:`h5bUAG_compactionButton`,compactionContextIcon:`h5bUAG_compactionContextIcon`,compactionDisclosureIcon:`h5bUAG_compactionDisclosureIcon`,compactionLeading:`h5bUAG_compactionLeading`,compactionRow:`h5bUAG_compactionRow`,compactionSep:`h5bUAG_compactionSep`,compactionSummary:`h5bUAG_compactionSummary`,compactionTitle:`h5bUAG_compactionTitle`,contextRow:`h5bUAG_contextRow`,editAction:`h5bUAG_editAction`,fileCard:`h5bUAG_fileCard`,fileContent:`h5bUAG_fileContent`,fileIcon:`h5bUAG_fileIcon`,fileMeta:`h5bUAG_fileMeta`,fileName:`h5bUAG_fileName`,maxTokensTitle:`h5bUAG_maxTokensTitle`,noticeRow:`h5bUAG_noticeRow`,noticeStack:`h5bUAG_noticeStack`,pendingAttachment:`h5bUAG_pendingAttachment`,referenceSummary:`h5bUAG_referenceSummary`,retryDetailLabel:`h5bUAG_retryDetailLabel`,retryDetails:`h5bUAG_retryDetails`,retryRow:`h5bUAG_retryRow`,retrySummary:`h5bUAG_retrySummary`,retryText:`h5bUAG_retryText`,sentEditor:`h5bUAG_sentEditor`,sentEditorActions:`h5bUAG_sentEditorActions`,turnErrorCode:`h5bUAG_turnErrorCode`,turnErrorCopy:`h5bUAG_turnErrorCopy`,turnErrorDot:`h5bUAG_turnErrorDot`,turnErrorMessage:`h5bUAG_turnErrorMessage`,turnErrorRow:`h5bUAG_turnErrorRow`,turnErrorTitle:`h5bUAG_turnErrorTitle`,userRow:`h5bUAG_userRow`,userStack:`h5bUAG_userStack`};let dm=(0,d.memo)(function({node:e,title:t,fallbackSummary:n,t:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useMemo)(()=>rm(r),[r]),s=e.summary!==null,c=s&&i,l=e.shadowedItemCount!==null&&e.shadowedTokenCount!==null?r(`message.compaction.completed`,{items:e.shadowedItemCount,tokens:e.shadowedTokenCount}):n??r(s?`message.compaction.expand`:`message.compaction.unavailable`);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.compactionRow,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:J.compactionButton,disabled:!s,"aria-expanded":s?c:void 0,onClick:()=>{a(e=>!e)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:J.compactionLeading,"aria-hidden":!0,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionContextIcon,"data-compaction-icon":`context`,children:/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionDisclosureIcon,"data-compaction-disclosure":c?`expanded`:`collapsed`,children:c?/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronRightOutlineRegular,{})})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionTitle,children:t??r(`message.compaction`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionSep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionSummary,children:l})]}),c&&e.summary!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.compactionBody,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:e.summary,labels:o})})]})}),fm=`@deepseek-ai/dsh-client-ui-chat/ContextBody.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(fm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=fm,e.textContent=`.p4W7kq_text{color:var(--dsw-alias-label-secondary);font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.p4W7kq_fields{border-top:.5px solid var(--dsw-alias-border-l2);flex-direction:column;gap:2px;margin:8px 0 0;padding-top:8px;display:flex}.p4W7kq_field{gap:8px;min-width:0;display:flex}.p4W7kq_fieldKey{min-width:96px;color:var(--dsw-alias-label-caption);flex:none}.p4W7kq_fieldValue{min-width:0;color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;flex:auto;margin:0}.p4W7kq_files{flex-wrap:wrap;gap:4px 12px;margin:0 0 8px;padding:0;list-style:none;display:flex}.p4W7kq_file{align-items:baseline;gap:6px;min-width:0;display:flex}.p4W7kq_filePath{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}.p4W7kq_fileAction{color:var(--dsw-alias-label-caption)}.p4W7kq_catalogNotice{color:var(--dsw-alias-label-caption);margin:0 0 6px}.p4W7kq_entries{flex-direction:column;gap:4px;margin:0;padding:0;list-style:none;display:flex}.p4W7kq_entry{gap:8px;min-width:0;display:flex}.p4W7kq_entryName{color:var(--dsw-alias-label-secondary);flex:none}.p4W7kq_entryDescription{min-width:0;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.p4W7kq_sections{flex-direction:column;gap:8px;margin:0;display:flex}.p4W7kq_section{flex-direction:column;gap:2px;min-width:0;display:flex}.p4W7kq_sectionName{color:var(--dsw-alias-label-caption)}.p4W7kq_sectionText{color:var(--dsw-alias-label-secondary);white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.p4W7kq_relaySender{color:var(--dsw-alias-label-caption);overflow-wrap:anywhere;margin:0 0 6px}.p4W7kq_recalls{flex-direction:column;gap:2px;margin:0 0 8px;padding:0;list-style:none;display:flex}.p4W7kq_recall{gap:8px;min-width:0;display:flex}.p4W7kq_recallLabel{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}.p4W7kq_recallCounts{color:var(--dsw-alias-label-caption);flex:none}`,document.head.appendChild(e)}var Y={catalogNotice:`p4W7kq_catalogNotice`,entries:`p4W7kq_entries`,entry:`p4W7kq_entry`,entryDescription:`p4W7kq_entryDescription`,entryName:`p4W7kq_entryName`,field:`p4W7kq_field`,fieldKey:`p4W7kq_fieldKey`,fieldValue:`p4W7kq_fieldValue`,fields:`p4W7kq_fields`,file:`p4W7kq_file`,fileAction:`p4W7kq_fileAction`,filePath:`p4W7kq_filePath`,files:`p4W7kq_files`,recall:`p4W7kq_recall`,recallCounts:`p4W7kq_recallCounts`,recallLabel:`p4W7kq_recallLabel`,recalls:`p4W7kq_recalls`,relaySender:`p4W7kq_relaySender`,section:`p4W7kq_section`,sectionName:`p4W7kq_sectionName`,sectionText:`p4W7kq_sectionText`,sections:`p4W7kq_sections`,text:`p4W7kq_text`};let pm=2e4;function mm(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function hm(e){let t=[];for(let n of e){if(n.type!==`text`){t.push({block:n});continue}let e=t[t.length-1];e!==void 0&&`text`in e?e.text+=n.text:t.push({text:n.text})}return t}function gm(e){return hm(e).flatMap(e=>`block`in e?[e.block]:[])}function _m(e,t){return e.length>pm?`${e.slice(0,pm)}\n${t(`json.truncated`,{total:e.length})}`:e}function vm(e,t){return _m(typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e),t)}function ym({source:e,formRendered:t,t:n}){let r=mm(e);if(r===null)return null;let i=t?[`kind`,`form`]:[`kind`],a=Object.entries(r).filter(([e])=>!i.includes(e));return a.length===0?null:/* @__PURE__ */ (0,f.jsx)(`dl`,{className:Y.fields,"data-context-fields":!0,children:a.map(([e,t])=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.field,children:[/* @__PURE__ */ (0,f.jsx)(`dt`,{className:Y.fieldKey,children:e}),/* @__PURE__ */ (0,f.jsx)(`dd`,{className:Y.fieldValue,children:vm(t,n)})]},e))})}function bm({blocks:e,t}){return/* @__PURE__ */ (0,f.jsx)(f.Fragment,{children:e.map((e,n)=>/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownBlock`),payload:e,truncatedLabel:e=>t(`json.truncated`,{total:e})},n))})}function xm({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(f.Fragment,{children:hm(e).map((e,n)=>`text`in e?e.text!==``&&/* @__PURE__ */ (0,f.jsx)(`pre`,{className:Y.text,"data-context-text":!0,children:_m(e.text,t)},n):/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownBlock`),payload:e.block,truncatedLabel:e=>t(`json.truncated`,{total:e})},n))})}function Sm({content:e,source:t,t:n}){return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(xm,{content:e,t:n}),/* @__PURE__ */ (0,f.jsx)(ym,{source:t,formRendered:!1,t:n})]})}function Cm(e){let t=mm(e),n=t===null?void 0:t.changes;if(!Array.isArray(n))return null;let r=[],i=/* @__PURE__ */ new Set;for(let e of n){let t=mm(e);if(t===null)return null;let n=t.path;if(typeof n!=`string`||n===``)return null;let a=t.action;if(a!==`set`&&a!==`replace`&&a!==`remove`)return null;let o=t.digest;i.has(n)||(i.add(n),r.push({action:a,path:n,...typeof o==`string`?{digest:o}:{}}))}return r.length===0?null:r}function wm(e,t){return e===`remove`?`message.context.instructions.removed`:t?`message.context.instructions.loaded`:e===`set`?`message.context.instructions.added`:`message.context.instructions.updated`}function Tm({content:e,source:t,t:n}){let r=Cm(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(Sm,{content:e,source:t,t:n});let i=mm(t)?.baseline===!0;return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Y.files,"data-context-files":!0,children:r.map(e=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Y.file,title:e.digest,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.filePath,children:e.path}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.fileAction,children:n(wm(e.action,i))})]},e.path))}),/* @__PURE__ */ (0,f.jsx)(xm,{content:e,t:n})]})}function Em(e){let t=mm(e),n=t===null?void 0:t.entries;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=mm(e);if(t===null)return null;let n=t.name,i=t.description;if(typeof n!=`string`||n===``||typeof i!=`string`)return null;r.push({name:n,description:i})}return r}function Dm({content:e,source:t,t:n}){let r=Em(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(Sm,{content:e,source:t,t:n});let i=mm(t)?.update===!0,a=r.slice(0,200),o=gm(e);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[i&&/* @__PURE__ */ (0,f.jsx)(`p`,{className:Y.catalogNotice,"data-context-catalog-update":!0,children:n(`message.context.catalog.replaced`)}),/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Y.entries,"data-context-entries":!0,children:a.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Y.entry,children:[/* @__PURE__ */ (0,f.jsx)(`code`,{className:Y.entryName,children:e.name}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.entryDescription,children:e.description})]},t))}),a.length<r.length&&/* @__PURE__ */ (0,f.jsx)(`p`,{className:Y.catalogNotice,"data-context-entries-truncated":!0,children:n(`message.context.catalog.more`,{count:r.length-a.length})}),/* @__PURE__ */ (0,f.jsx)(bm,{blocks:o,t:n})]})}function Om(e){let t=mm(e),n=t===null?void 0:t.sections;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=mm(e);if(t===null)return null;let n=t.name,i=t.text;if(typeof n!=`string`||n===``||typeof i!=`string`)return null;r.push({name:n,text:i})}return r.length===0?null:r}function km({content:e,source:t,t:n}){let r=Om(t);return r===null?/* @__PURE__ */ (0,f.jsx)(Sm,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:Y.catalogNotice,"data-context-snapshot-supersedes":!0,children:n(`message.context.snapshot.supersedes`)}),/* @__PURE__ */ (0,f.jsx)(`dl`,{className:Y.sections,"data-context-sections":!0,children:r.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.section,children:[/* @__PURE__ */ (0,f.jsx)(`dt`,{className:Y.sectionName,children:e.name}),/* @__PURE__ */ (0,f.jsx)(`dd`,{className:Y.sectionText,children:_m(e.text,n)})]},t))})]})}function Am({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(xm,{content:e,t})}function jm({content:e,source:t,t:n}){let r=Mm(t);return r===null?/* @__PURE__ */ (0,f.jsx)(Sm,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:Y.relaySender,"data-context-relay-sender":!0,children:n(`message.context.relay.from`,{session:r})}),/* @__PURE__ */ (0,f.jsx)(xm,{content:e,t:n})]})}function Mm(e){let t=mm(e)?.senderSessionId;return typeof t==`string`&&t!==``?t:null}function Nm(e){let t=mm(e),n=t===null?void 0:t.references;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=mm(e);if(t===null)return null;let n=t.label,i=t.retainedMessages,a=t.omittedMessages,o=t.truncated;if(typeof n!=`string`||n===``||typeof i!=`number`||typeof a!=`number`||typeof o!=`boolean`)return null;r.push({label:n,retained:i,omitted:a,truncated:o})}return r.length===0?null:r}function Pm({content:e,source:t,t:n}){let r=Nm(t);return r===null?/* @__PURE__ */ (0,f.jsx)(Sm,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Y.recalls,"data-context-recalls":!0,children:r.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Y.recall,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.recallLabel,children:e.label}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.recallCounts,children:n(`message.context.recall.counts`,{retained:e.retained,omitted:e.omitted})}),e.truncated&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.recallCounts,children:n(`message.context.recall.truncated`)})]},t))}),/* @__PURE__ */ (0,f.jsx)(xm,{content:e,t:n})]})}function Fm(e){let t=mm(e)?.summary;return typeof t==`string`&&t!==``?t:null}function Im(e,t){let n={rendered:null,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Sm,{...t})};switch(e){case`instructions`:return Cm(t.source)===null?n:{rendered:`instructions`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Tm,{...t})};case`catalog`:return Em(t.source)===null?n:{rendered:`catalog`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Dm,{...t})};case`snapshot`:return Om(t.source)===null?n:{rendered:`snapshot`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(km,{...t})};case`notice`:{let e=Fm(t.source);return e===null?n:{rendered:`notice`,summary:e,body:/* @__PURE__ */ (0,f.jsx)(Am,{...t})}}case`relay`:return Mm(t.source)===null?n:{rendered:`relay`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(jm,{...t})};case`recall`:return Nm(t.source)===null?n:{rendered:`recall`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Pm,{...t})};case null:return n;
|
|
114
114
|
/* v8 ignore next 4 -- closed-union backstop; the compiler rejects a new
|
|
115
115
|
KnownContextForm here rather than letting it degrade to opaque silently. */
|
|
116
|
-
default:throw Error(`unreachable context form: ${String(e)}`)}}let jm=`@deepseek-ai/dsh-client-ui-chat/ContextInjectionRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(jm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=jm,e.textContent=`.uawKOW_root{min-width:0}.uawKOW_root[data-open]{padding-bottom:4px}.uawKOW_chevron{color:var(--dsw-alias-label-secondary)}.uawKOW_sep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.uawKOW_source{min-width:0;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:none;overflow:hidden}.uawKOW_summary{min-width:0;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.uawKOW_body{box-sizing:border-box;width:calc(100% - 22px - var(--dsh-content-font-delta,0px));max-height:141px;margin:4px 0 0 calc(22px + var(--dsh-content-font-delta,0px));border-radius:var(--dsw-radius-md);background:var(--dsw-alias-markdown-code-block);color:var(--dsw-alias-label-tertiary);font:400 11px/16px var(--ds-font-family-code);border:none;padding:10px 16px 12px 12px;overflow:auto}.uawKOW_toolChanges{white-space:nowrap}`,document.head.appendChild(e)}var Mm={body:`uawKOW_body`,chevron:`uawKOW_chevron`,root:`uawKOW_root`,sep:`uawKOW_sep`,source:`uawKOW_source`,summary:`uawKOW_summary`,toolChanges:`uawKOW_toolChanges`};function Nm({content:e,source:t,producer:n,form:r,t:i}){let[a,o]=(0,d.useState)(!1),{rendered:s,summary:c,body:l}=Am(r,{content:e,source:t,t:i}),u=e.length>0&&e.every(e=>e.type===`tool-addition`||e.type===`tool-removal`)?e:void 0,m=u?.flatMap(e=>e.type===`tool-addition`?[e.toolName]:[])??[],h=u?.flatMap(e=>e.type===`tool-removal`?[e.toolName]:[])??[],g=u?.length===1?u[0]:void 0,_=u===void 0||g!==void 0?null:m.length>0&&h.length>0?i(`message.toolsChanged`,{added:m.length,removed:h.length}):m.length>0?i(`message.toolsAddedCount`,{count:m.length}):i(`message.toolsRemovedCount`,{count:h.length});return/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{className:Mm.root,icon:u===void 0?n.role===`recall`?/* @__PURE__ */ (0,f.jsx)(`span`,{"data-context-recall-icon":!0,children:/* @__PURE__ */ (0,f.jsx)(p.ReferenceIconRegular,{kind:`session`})}):/* @__PURE__ */ (0,f.jsx)(p.IconContextInjectionOutlineRegular,{size:14}):/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),chevronClassName:Mm.chevron,title:g===void 0?i(u===void 0?n.role===`recall`?`message.contextRecall`:`message.contextInjection`:`message.toolsUpdated`):i(g.type===`tool-addition`?`message.toolAdded`:`message.toolRemoved`,{name:g.toolName}),collapsedContent:_===null?u!==void 0||n.label===null?void 0:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mm.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mm.source,"data-context-source":!0,children:n.label}),c!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mm.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mm.summary,"data-context-summary":!0,children:c})]})]}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mm.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mm.summary,children:_})]}),keepContentWhenOpen:!0,open:a&&g===void 0,expandable:g===void 0,expandOnRowClick:!0,onToggle:()=>{o(e=>!e)},children:/* @__PURE__ */ (0,f.jsx)(`div`,{className:Mm.body,"data-context-injection-body":!0,"data-context-form":s??void 0,children:u===void 0?l:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Mm.toolChanges,children:[m.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{children:i(`message.toolsAdded`,{names:m.join(`, `)})}),h.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{children:i(`message.toolsRemoved`,{names:h.join(`, `)})})]})})})}function Pm(e){return String(e).padStart(2,`0`)}function Fm(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function Im(e){let t=new Date(e);return t.setHours(24,0,0,0),Math.max(t.getTime()-e,1)}function Lm(e,t){let n=Math.max(0,Math.floor(e/1e3)),r=Math.floor(n/3600),i=Math.floor(n/60)%60,a=n%60,o=[];return r>0&&o.push({text:String(r),numeric:!0},{text:t(`duration.hourUnit`),numeric:!1}),n>=60&&o.push({text:String(i),numeric:!0},{text:t(`duration.minuteUnit`),numeric:!1}),o.push({text:String(a),numeric:!0},{text:t(`duration.secondUnit`),numeric:!1}),o}function Rm(e,t,n=Date.now()){let r=new Date(e),i=new Date(n),a=`${Pm(r.getHours())}:${Pm(r.getMinutes())}`;if(r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate())return a;let o={y:r.getFullYear(),m:r.getMonth()+1,d:r.getDate()};return`${r.getFullYear()===i.getFullYear()?t(`clock.md`,o):t(`clock.ymd`,o)} ${a}`}function zm(e){let t=e.harnessLabel?.trim()||e.harnessId,n=Bm(e.model,e.harnessId);return n===void 0?{display:t,title:t}:{display:n,title:n.toLowerCase()===t.toLowerCase()?n:`${t} · ${n}`}}function Bm(e,t){if(e===void 0)return;let n=e.trim();if(n===``)return;let r=n.indexOf(``);r!==-1&&(n=n.slice(0,r).trim()),n=n.replace(/^codexhost[:/]+/iu,``),n=n.replace(/^(?:harness|external|route)\/+/iu,``);let i=t.replace(/[.*+?^${}()|[\]\\]/gu,`\\$&`);if(n=n.replace(RegExp(`^${i}[:/]+`,`iu`),``),n=n.trim(),n!==``&&n.toLowerCase()!==`harness`)return n}function Vm({size:e=16,className:t}){return/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:t,"aria-hidden":`true`,stroke:`currentColor`,strokeWidth:`1.35`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M2.5 5.25H13.25`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M10.5 2.75L13.25 5.25L10.5 7.75`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M13.5 10.75H2.75`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M5.5 8.25L2.75 10.75L5.5 13.25`})]})}function Hm({harnessId:e,label:t,hostId:n,size:r=15,className:i}){let a=(0,p.harnessIconSources)(e,n);return/* @__PURE__ */ (0,f.jsx)(`span`,{className:i,"data-harness-id":e,"aria-hidden":`true`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:r,height:r,flexShrink:0},children:e===`codex`?/* @__PURE__ */ (0,f.jsx)(`img`,{src:a.src,width:r,height:r,alt:t??``,style:{display:`block`,width:r,height:r,objectFit:`contain`}}):/* @__PURE__ */ (0,f.jsx)(p.RemotePluginIcon,{id:e,src:a.src,presentationUrl:a.presentationUrl,size:r,fallback:/* @__PURE__ */ (0,f.jsx)(p.IconDataOutlineRegular,{size:r})})})}function Um(){let[e,t]=(0,d.useState)(()=>Fm(Date.now()));return(0,d.useEffect)(()=>{let e,n=()=>{let r=Date.now();t(Fm(r)),e=setTimeout(n,Im(r))};return e=setTimeout(n,Im(Date.now())),()=>{clearTimeout(e)}},[]),e}let Wm=`@deepseek-ai/dsh-client-ui-chat/MessageIconActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Wm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Wm,e.textContent=`.MIPpJq_actions{height:calc(28px + var(--dsh-content-font-delta,0px));-webkit-user-select:none;user-select:none;align-items:center;gap:8px;display:flex}.MIPpJq_timeStart{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);white-space:nowrap;padding-right:12px}.MIPpJq_timeEnd{font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:inherit;white-space:nowrap}.MIPpJq_endInfo{min-width:0;color:var(--dsw-alias-label-tertiary);align-items:center;gap:8px;margin-left:8px;display:inline-flex}@media (hover:hover){[data-actions-reveal=hover] .MIPpJq_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])) .MIPpJq_actions{opacity:0;transition:opacity 80ms}[data-actions-reveal=hover]:hover .MIPpJq_actions,[data-actions-reveal=hover]:focus-within .MIPpJq_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])):hover .MIPpJq_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])):focus-within .MIPpJq_actions{opacity:1}}.MIPpJq_action{width:calc(28px + var(--dsh-content-font-delta,0px));height:calc(28px + var(--dsh-content-font-delta,0px));border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:6px;display:inline-flex}.MIPpJq_action svg{width:calc(15px + var(--dsh-content-font-delta,0px));height:calc(15px + var(--dsh-content-font-delta,0px))}.MIPpJq_actions[data-clock=end] .MIPpJq_action svg{width:calc(17px + var(--dsh-content-font-delta,0px));height:calc(17px + var(--dsh-content-font-delta,0px))}.MIPpJq_action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.MIPpJq_action[data-unavailable]{cursor:default;opacity:.4}.MIPpJq_action[data-unavailable]:hover{color:var(--dsw-alias-label-tertiary);background:0 0}.MIPpJq_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var Gm={action:`MIPpJq_action`,actions:`MIPpJq_actions`,endInfo:`MIPpJq_endInfo`,timeEnd:`MIPpJq_timeEnd`,timeStart:`MIPpJq_timeStart`,visuallyHidden:`MIPpJq_visuallyHidden`};function Km({text:e,time:t,clock:n,onBranch:r,branchUnavailable:i=!1,onHandoff:a,handoffUnavailable:o=!1,className:s,extraActions:c,t:l}){let u=Um(),m=(0,d.useId)(),h=(0,d.useId)(),[g,_]=(0,d.useState)(!1),v=(0,d.useRef)(!1),y=(0,d.useRef)(null),b=(0,d.useRef)(0);(0,d.useEffect)(()=>()=>{b.current+=1,v.current=!1,y.current!==null&&clearTimeout(y.current)},[]);let x=(0,d.useCallback)(()=>{if(g||v.current)return;let t=b.current;v.current=!0,(0,p.writeClipboard)(e).then(e=>{t===b.current&&(v.current=!1,e&&(_(!0),y.current=window.setTimeout(()=>{y.current=null,_(!1)},1e3)))})},[g,e]),S=t===void 0?null:/* @__PURE__ */ (0,f.jsx)(`span`,{className:n===`start`?Gm.timeStart:Gm.timeEnd,children:Rm(t,l,u)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:s===void 0?Gm.actions:`${Gm.actions} ${s}`,"data-clock":n,children:[n===`start`?S:null,/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:l(g?`copied`:`copy`),side:`bottom`,portal:!0,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Gm.action,"aria-label":l(g?`copied`:`copy`),onClick:x,children:g?/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconCopyOutlineRegular,{})})}),c,r!==void 0&&/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:l(i?`message.branchUnavailable`:`message.branch`),side:`bottom`,portal:!0,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Gm.action,"aria-label":l(`message.branch`),"aria-disabled":i||void 0,"aria-describedby":i?m:void 0,"data-unavailable":i||void 0,onClick:i?void 0:r,children:/* @__PURE__ */ (0,f.jsx)(p.IconBranchOutlineRegular,{})})}),r!==void 0&&i&&/* @__PURE__ */ (0,f.jsx)(`span`,{id:m,className:Gm.visuallyHidden,children:l(`message.branchUnavailable`)}),a!==void 0&&/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:l(o?`message.handoffUnavailable`:`message.handoff`),side:`bottom`,portal:!0,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Gm.action,"aria-label":l(`message.handoff`),"aria-disabled":o||void 0,"aria-describedby":o?h:void 0,"data-unavailable":o||void 0,"data-action-handoff":``,onClick:o?void 0:a,children:/* @__PURE__ */ (0,f.jsx)(Vm,{})})}),a!==void 0&&o&&/* @__PURE__ */ (0,f.jsx)(`span`,{id:h,className:Gm.visuallyHidden,children:l(`message.handoffUnavailable`)}),n===`end`?/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gm.endInfo,children:S}):null]})}function qm(e,t,n){return e(`codexhostTurnTimes`,e=>t===void 0?void 0:e?.[t]?.[n]??void 0)}function Jm(e,t,n){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(!1);return(0,d.useMemo)(()=>({targetSeq:e&&!n?t:null,draft:r,begin(e,r,o,s=[]){a.current||n||e!==t||i({seq:e,text:r,content:o,responseAnnotations:s,pending:!1,blocked:!1})},change(e){i(t=>t&&!t.pending?{...t,text:e}:t)},cancel(){a.current||i(null)},send(){!e||!r||r.blocked||a.current||n||!r.text.trim()&&r.responseAnnotations.length===0||(a.current=!0,i({...r,pending:!0,error:void 0}),e(r.seq,Ap(r.responseAnnotations,r.text)).then(e=>{e.status===`accepted`?i(null):i({...r,pending:!1,blocked:e.status!==`rejected`,error:e.message})},e=>{i({...r,pending:!1,blocked:!0,error:e instanceof Error?e.message:String(e)})}).finally(()=>{a.current=!1}))}}),[e,t,n,r])}function Ym({editing:e,t}){let n=e.draft;return n?/* @__PURE__ */ (0,f.jsxs)(`form`,{className:J.sentEditor,"data-sent-message-editor":!0,onSubmit:t=>{t.preventDefault(),e.send()},children:[/* @__PURE__ */ (0,f.jsx)(`textarea`,{autoFocus:!0,"aria-label":t(`message.edit`),value:n.text,disabled:n.pending,onChange:t=>e.change(t.target.value),onKeyDown:t=>{t.nativeEvent.isComposing||t.keyCode===229||(t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),e.send()),t.key===`Escape`&&(t.preventDefault(),e.cancel()))}}),!n.pending&&!n.error&&e.targetSeq!==n.seq&&/* @__PURE__ */ (0,f.jsx)(`div`,{role:`status`,children:t(`message.edit.changed`)}),n.error&&/* @__PURE__ */ (0,f.jsxs)(`div`,{role:`alert`,children:[n.error,n.blocked?` ${t(`message.edit.checkHistory`)}`:``]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.sentEditorActions,children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,size:`sm`,disabled:n.pending,onClick:e.cancel,children:t(`message.edit.cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,size:`sm`,type:`submit`,disabled:n.pending||n.blocked||!n.text.trim()&&n.responseAnnotations.length===0||e.targetSeq!==n.seq,children:n.pending?t(`message.edit.sending`):t(`message.edit.send`)})]})]}):null}function Xm(e){return`nativePath`in e&&typeof e.nativePath==`string`?e.nativePath:void 0}function Zm({upload:e,t}){let n=(0,d.useSyncExternalStore)(e.subscribe,e.getSnapshot);return n?.status===`uploading`?/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.fileMeta,role:`status`,"data-upload-progress":!0,children:n.total===void 0||n.total===0?t(`message.uploading`):t(`message.uploadingPercent`,{percent:Math.round(Math.min(1,(n.loaded??0)/n.total)*100)})}):null}function Qm(e){let t=[],n=[],r=[];for(let i of e){let e=i;e.type===`text`&&typeof e.text==`string`?t.push(Mp(e.text).body):e.type===`image`&&e.attachment!==void 0?n.push({type:`image`,image:{attachment:e.attachment}}):e.type===`file`&&e.attachment!==void 0?n.push({type:`file`,file:e.attachment}):r.push(i)}return{text:t.join(``),attachments:n,rest:r}}function $m(e){return Math.max(1,Math.ceil(e/1e3))}function eh(e,t,n){return t===`ACCOUNT_SIGNED_OUT`?n(`message.failure.accountSignedOut`):t===`ACCOUNT_SIGN_IN_REQUIRED`?n(`message.failure.accountSignInRequired`):t===`QUOTA`||t===`ACCOUNT_QUOTA`?n(`message.failure.quota`):t===`AUTH`?n(`message.failure.auth`):e}function th({node:e,active:t,t:n}){let r=(0,d.useMemo)(()=>Date.now()+e.delayMs,[e.delayMs,e.seq]),i=$m(e.delayMs),a=e.mode===`normal`?e.maxRetries:`∞`,[o,s]=(0,d.useState)(()=>({deadline:r,seconds:$m(r-Date.now())})),c=o.deadline===r?o.seconds:$m(r-Date.now());(0,d.useEffect)(()=>{if(!t)return;let e=()=>{let e=$m(r-Date.now());return s(t=>t.deadline===r&&t.seconds===e?t:{deadline:r,seconds:e}),e};if(e()===1)return;let n=window.setInterval(()=>{e()===1&&window.clearInterval(n)},250);return()=>{window.clearInterval(n)}},[t,r]);let l=t?n(`message.retry.active`):e.retryState===`cancelled`?n(`message.retry.cancelled`):e.retryState===`started`?n(`message.retry.started`):n(`message.retry.scheduled`),u=t?c:i;return/* @__PURE__ */ (0,f.jsxs)(`details`,{className:J.retryRow,"data-active":t||void 0,children:[/* @__PURE__ */ (0,f.jsx)(`summary`,{className:J.retrySummary,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.retryText,role:`status`,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:t,children:n(`message.retry.status`,{label:l,retry:e.retry,maximum:a,seconds:u})})})}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.retryDetails,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.retryDetailLabel,children:n(`message.retry.delay`)}),n(`duration.milliseconds`,{milliseconds:Math.round(e.delayMs)})]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.retryDetailLabel,children:n(`message.retry.failure`)}),eh(e.failure.message,e.failure.code,n)]})]})]})}function nh({node:e,t}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.turnErrorRow,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`error`,className:J.turnErrorDot}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.turnErrorCopy,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.turnErrorTitle,children:e.code===`ACCOUNT_SIGNED_OUT`?t(`message.accountStopped`):t(`message.turnError`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.turnErrorMessage,children:eh(e.message,e.code,t)})]}),e.code!==void 0&&/* @__PURE__ */ (0,f.jsx)(`code`,{className:J.turnErrorCode,children:e.code})]})}function rh({t:e}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.turnErrorRow,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`warning`,className:J.turnErrorDot}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.turnErrorCopy,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.maxTokensTitle,children:e(`message.maxTokens`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.turnErrorMessage,children:e(`message.maxTokens.hint`)})]})]})}function ih({content:e,renderMessageImages:t,actions:n,pending:r=!1,echo:i=!1,referenceLabels:a=[],skillNames:o=[],responseAnnotations:s=[],previewAttachments:c,references:l,links:u,editor:d,t:m}){let{text:h,attachments:g,rest:_}=Qm(e),v=c??g,y=v.length>1,b=e=>m(`json.truncated`,{total:e}),x=h!==``||_.length>0,S=Tp(h);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:S?J.noticeRow:J.userRow,"data-pending-steering":r||void 0,"data-submission-echo":i||void 0,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:S?J.noticeStack:J.userStack,children:[s.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.annotationRow,"data-message-annotations":!0,children:s.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(p.ResponseAnnotationChip,{index:t+1,annotation:e,labels:Qp(m)},`${String(t)}:${e.text}`))}),v.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.attachmentRow,"data-message-attachments":!0,children:v.map((e,n)=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.pendingAttachment,children:[e.type===`image`?t({images:[e.image],align:`end`,compact:y}):/* @__PURE__ */ (0,f.jsxs)(`span`,{className:J.fileCard,title:Xm(e.file)??e.file.name,children:[/* @__PURE__ */ (0,f.jsx)(p.FileTypeIcon,{path:e.file.name,className:J.fileIcon}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:J.fileContent,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.fileName,children:e.file.name}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.fileMeta,children:[(0,p.fileExtension)(e.file.name).toUpperCase().slice(0,8),Xm(e.file)===void 0?(0,p.fileSizeText)(e.file.bytes):void 0].filter(Boolean).join(` `)})]})]}),e.upload&&/* @__PURE__ */ (0,f.jsx)(Zm,{upload:e.upload,t:m})]},n))}),d??(x&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:S?void 0:J.bubble,children:[S?/* @__PURE__ */ (0,f.jsx)(rm,{entries:S,links:u,t:m}):(0,p.projectUserText)(h,a,o,`skill`,l),_.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:m(`message.extraBlock`),payload:e,truncatedLabel:b},t))]})),a.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.referenceSummary,children:m(`message.referenceSummary`,{labels:a.join(m(`message.referenceSeparator`))})})]}),!S&&n?.(h)]})}function ah({content:e,renderMessageImages:t,t:n}){return/* @__PURE__ */ (0,f.jsx)(ih,{content:e,renderMessageImages:t,pending:!0,t:n,actions:e=>/* @__PURE__ */ (0,f.jsx)(Km,{text:e,clock:`start`,className:J.actions,t:n})})}function oh({submission:e,renderMessageImages:t,t:n}){let r=(0,d.useMemo)(()=>e.text===``?[]:[{type:`text`,text:e.text}],[e.text]),i=(0,d.useMemo)(()=>e.attachments.map(e=>({upload:e.upload,...e.type===`image`?{type:`image`,image:{preview:{url:e.value.previewUrl,...e.value.name===void 0?{}:{name:e.value.name},...e.value.width===void 0?{}:{width:e.value.width},...e.value.height===void 0?{}:{height:e.value.height}}}}:{type:`file`,file:e.value}})),[e.attachments]);return/* @__PURE__ */ (0,f.jsx)(ih,{content:r,previewAttachments:i,renderMessageImages:t,pending:e.placement===`steering`,echo:!0,t:n,actions:t=>/* @__PURE__ */ (0,f.jsx)(Km,{text:t,time:e.time,clock:`start`,className:J.actions,t:n})})}let sh=(0,d.memo)(function({node:e,renderMessageImages:t,openFile:n,openSkill:r,messageEditing:i,useProjection:a,links:o,t:s}){let c=e.data,l=qm(a,e.location.kind===`turn`||e.location.kind===`step`?e.location.turn.turn:void 0,`start`);return/* @__PURE__ */ (0,f.jsx)(ih,{content:c.content,editor:i?.draft?.seq===c.seq?/* @__PURE__ */ (0,f.jsx)(Ym,{editing:i,t:s}):void 0,references:{openFile:n,openSkill:r},links:o,renderMessageImages:t,responseAnnotations:c.responseAnnotations,...c.referenceLabels===void 0?{}:{referenceLabels:c.referenceLabels},...c.skillNames===void 0?{}:{skillNames:c.skillNames},t:s,actions:t=>/* @__PURE__ */ (0,f.jsx)(Km,{extraActions:e.kind===`user`&&i?.targetSeq===c.seq&&!i.draft?/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:J.editAction,"aria-label":s(`message.edit`),title:s(`message.edit`),onClick:()=>i.begin(c.seq,t,c.content,c.responseAnnotations),children:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{})}):null,text:t,time:e.kind===`user`?l:void 0,clock:`start`,className:J.actions,t:s})})});function ch({editing:e,renderMessageImages:t,t:n}){return/* @__PURE__ */ (0,f.jsx)(ih,{content:e.draft?.content??[],responseAnnotations:e.draft?.responseAnnotations,renderMessageImages:t,editor:/* @__PURE__ */ (0,f.jsx)(Ym,{editing:e,t:n}),t:n})}let lh=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(Nm,{content:n.content,source:n.source,producer:n.producer,form:n.form,t})}),uh=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(am,{node:e.data,t})}),dh=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(th,{node:n.current,active:n.current.retryState===`scheduled`,t})}),fh=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(nh,{node:e.data,t})}),ph=(0,d.memo)(function({t:e}){return/* @__PURE__ */ (0,f.jsx)(rh,{t:e})}),mh=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.contextRow,children:/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownSurface`,{type:n.type}),payload:n.data,truncatedLabel:e=>t(`json.truncated`,{total:e})})})}),hh=/* @__PURE__ */ new Set([`system-prompt`,`user`,`steering`,`turn-trigger`,`turn-process`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function gh(e,t){return e.turn===t.turn&&e.controlAnchorSeq===t.controlAnchorSeq&&e.processStartSeq===t.processStartSeq&&e.answerAnchorSeq===t.answerAnchorSeq&&e.answerStep===t.answerStep&&e.inlineReasoning===t.inlineReasoning&&e.messageCount===t.messageCount&&e.toolCallCount===t.toolCallCount&&e.subagentCount===t.subagentCount}function _h(e){return e===`subagent`||e.startsWith(`subagent_`)}function vh(e){return e===`compact_context`}function yh(e){let t=e?.location;if(t?.kind!==`turn`&&t?.kind!==`step`)return!1;let n=t.turn.end?.data.reason.kind;return t.turn.status===`open`||t.turn.end?.data.finalAssistantStep===null||n===`aborted`||n===`error`}function bh(e,t){return e.turnProcesses.find(e=>e.turn===t)}function xh(){return(0,m.defineStore)({init:()=>({turnProcesses:[]}),actions:{setTurnProcessOpen:(e,t,n,r)=>{let i=e.turnProcesses.findIndex(e=>e.turn===t);if(!r){i>=0&&e.turnProcesses.splice(i,1);return}let a={turn:t,answerStep:n};i<0?e.turnProcesses.push(a):e.turnProcesses[i]=a}}})}let Sh=`data-chat-near-viewport`,Ch=/* @__PURE__ */ new WeakMap;function wh(e){let t=Ch.get(e);return t===void 0&&(t=new IntersectionObserver(e=>{for(let t of e)t.target.toggleAttribute(Sh,t.isIntersecting)},{root:e,rootMargin:`100% 0px`}),Ch.set(e,t)),t}function Th(e,t){(0,d.useLayoutEffect)(()=>{let t=e.current;if(t===null||t.matches(`[data-chat-flow-key] *`))return;t.setAttribute(Sh,``);let n=t.closest(`[data-conversation-scroll]`);if(n===null)return;let r=wh(n);return r.observe(t),()=>{r.unobserve(t)}},[e,t])}function Eh(e,t){let n=(0,d.useRef)(null);return(0,d.useLayoutEffect)(()=>{let r=n.current;r!==null&&(e&&r.contains(r.ownerDocument.activeElement)?t():e?r.setAttribute(`hidden`,`until-found`):r.removeAttribute(`hidden`))},[e,t]),(0,d.useEffect)(()=>{let e=n.current;if(e!==null)return e.addEventListener(`beforematch`,t),()=>{e.removeEventListener(`beforematch`,t)}},[t]),n}let Dh=[],Oh={getSnapshot:()=>Dh,subscribe:()=>()=>{}};function kh(e){let t=Dh;return{getSnapshot:()=>{let n=e.getSnapshot().flatMap(e=>e.responseAnnotations??[]);return n.length===t.length&&n.every((e,n)=>e===t[n])||(t=n.length===0?Dh:n),t},subscribe:e.subscribe}}function Ah(e,t){let n=(0,d.useMemo)(()=>t===void 0?Oh:kh(e.turnDataSource(t,`user`)),[e,t]);return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let jh=`@deepseek-ai/dsh-client-ui-chat/ChatView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(jh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=jh,e.textContent=`.BZ5KQW_frame{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative;container-type:inline-size}.BZ5KQW_root{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative;overflow:visible clip}.BZ5KQW_scroll{min-height:0;padding:16px calc(var(--dsh-composer-side-clearance) + 16px);flex:auto;overflow-y:auto;container-type:inline-size}.BZ5KQW_root[data-chat-following-tail] .BZ5KQW_scroll,[data-conversation-scroll]:has(.BZ5KQW_root[data-chat-following-tail]){overflow-anchor:none}[data-conversation-scroll] .BZ5KQW_frame,[data-conversation-scroll] .BZ5KQW_root{flex:none;height:auto;min-height:auto}[data-conversation-scroll] .BZ5KQW_scroll{flex:none;min-height:auto;overflow:visible}.BZ5KQW_column{max-width:var(--dsh-chat-content-width);flex-direction:column;width:100%;margin:0 auto;display:flex}.BZ5KQW_column>:not([hidden]):not(.BZ5KQW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)))~:not([hidden]):not(.BZ5KQW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))){margin-top:var(--dsh-chat-flow-gap,6px)}.BZ5KQW_flowItem[data-chat-group-part=response],.BZ5KQW_column>[data-chat-group-part=response]:not([hidden]):not(:empty)+:not([hidden]):not(.BZ5KQW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))):not(.BZ5KQW_running){--dsh-chat-flow-gap:12px}.BZ5KQW_flowItem{min-width:0}.BZ5KQW_flowItem[data-chat-flow-kind=turn-process],.BZ5KQW_flowItem[data-turn-process-answer],.BZ5KQW_column>[data-chat-flow-kind=turn-process]+:not([hidden]):not(.BZ5KQW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))):not(.BZ5KQW_running){--dsh-chat-flow-gap:16px}.BZ5KQW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)){height:0}.BZ5KQW_callRow{border-radius:var(--dsw-radius-sm)}.BZ5KQW_syncing{color:var(--dsw-alias-label-secondary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));align-items:center;gap:6px;padding-block:8px;display:flex}@media (prefers-reduced-motion:reduce){.BZ5KQW_syncingIcon{display:none}}.BZ5KQW_hint{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}.BZ5KQW_running{--dsh-chat-flow-gap:12px;--dsw-alias-label-shimmer:var(--dsw-alias-label-deep-diving-shimmer);color:var(--dsw-alias-label-deep-diving);font-size:calc(var(--dsh-content-font-size,14px) - 2px);line-height:calc(22px + var(--dsh-content-font-delta,0px));flex-direction:column;align-items:flex-start;display:flex}.BZ5KQW_column>:nth-last-child(2 of :not([hidden]):not(.BZ5KQW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)))):is(.BZ5KQW_flowItem:not([data-chat-flow-kind=user]):not([data-chat-flow-kind=steering]):not([data-chat-flow-kind=turn-trigger]),[data-chat-group-key])~.BZ5KQW_running>.BZ5KQW_runningDivider{display:block}.BZ5KQW_runningDivider{background:color-mix(in srgb, var(--dsw-alias-border-l1) 75%, var(--dsw-alias-border-l2));pointer-events:none;width:100%;height:.5px;margin:8px 0 10px;display:none}.BZ5KQW_runningContent{align-items:center;gap:6px;min-width:0;display:inline-flex}.BZ5KQW_runningText{font-variant-numeric:tabular-nums;min-width:0}.BZ5KQW_runningIcon{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));contain:strict;flex:none;display:inline-flex;overflow:hidden}.BZ5KQW_runningIconMotion{transform-origin:50% 60%;width:100%;height:100%;display:inline-flex}@keyframes BZ5KQW_runningIconSway{0%,to{transform:translateY(.5px)rotate(-20deg)}50%{transform:translateY(-.6px)rotate(20deg)}}@media (prefers-reduced-motion:no-preference) and (forced-colors:none){.BZ5KQW_runningIconMotion{animation:1.6s ease-in-out infinite BZ5KQW_runningIconSway}}.BZ5KQW_openError{color:var(--dsw-alias-state-error-primary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}.BZ5KQW_older{min-height:28px;color:var(--dsw-alias-label-secondary);flex-wrap:wrap;justify-content:center;align-items:center;gap:8px;font-size:12px;display:flex}.BZ5KQW_older button{border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover-solid);cursor:pointer;border:none;padding:4px 12px;font-size:12px}.BZ5KQW_older button:disabled{cursor:default;opacity:.6}.BZ5KQW_toBottomSlot{z-index:8;height:0;padding-right:max(calc(var(--dsh-composer-side-clearance) + 16px), calc((100% - var(--dsh-chat-content-width)) / 2));pointer-events:none;justify-content:flex-end;display:flex;position:absolute;bottom:16px;left:0;right:0}[data-conversation-scroll] .BZ5KQW_toBottomSlot{bottom:calc(var(--dsh-composer-height,152px) + 16px);position:sticky}.BZ5KQW_toBottom{--dsw-elevation-stroke-color:var(--dsw-alias-border-l3);corner-shape:round;width:34px;height:34px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-button-floating-fill);box-shadow:var(--dsw-elevation-panel);cursor:pointer;pointer-events:auto;border:0;border-radius:100px;justify-content:center;align-items:center;margin-top:-34px;padding:0;display:flex}.BZ5KQW_toBottom:hover{background:var(--dsw-alias-button-floating-hover)}.BZ5KQW_modalAction{min-width:72px}`,document.head.appendChild(e)}var Mh={callRow:`BZ5KQW_callRow`,column:`BZ5KQW_column`,flowItem:`BZ5KQW_flowItem`,frame:`BZ5KQW_frame`,hint:`BZ5KQW_hint`,modalAction:`BZ5KQW_modalAction`,older:`BZ5KQW_older`,openError:`BZ5KQW_openError`,root:`BZ5KQW_root`,running:`BZ5KQW_running`,runningContent:`BZ5KQW_runningContent`,runningDivider:`BZ5KQW_runningDivider`,runningIcon:`BZ5KQW_runningIcon`,runningIconMotion:`BZ5KQW_runningIconMotion`,runningIconSway:`BZ5KQW_runningIconSway`,runningText:`BZ5KQW_runningText`,scroll:`BZ5KQW_scroll`,syncing:`BZ5KQW_syncing`,syncingIcon:`BZ5KQW_syncingIcon`,toBottom:`BZ5KQW_toBottom`,toBottomSlot:`BZ5KQW_toBottomSlot`};function Nh(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.data:void 0}function Ph(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function Fh(e){return e?.kind===`tool-call`&&vh(e.data.root.name)}let Ih=(0,d.memo)(function({nodeKey:e,groupPart:t,nodeStore:n,useChatNode:r,useChatNodeProcess:i,usePresentation:a,cwd:o,openFile:s,openSkill:c,inspectCall:l,forkAt:u,handoffAt:h,loadTurnDiffs:g,messageEditing:_,loadImage:v,renderMessageImages:y,fileMentions:b,useStore:x,actions:S,renderSlot:C,t:w}){let T=r(e),E=T,ee=Ph(E),D=i(e),O=D?.spec,te=x(e=>O===void 0?void 0:bh(e,O.turn)),ne=O!==void 0&&te?.answerStep===(O.answerStep??0)?te:void 0,re=D!==void 0&&!D.turnClosed,ie=D?.hasInterleavedInput===!0,ae=re||ie||yh(E),oe=ae||ne!==void 0,k=(0,d.useCallback)(e=>{O!==void 0&&!ae&&S.setTurnProcessOpen(O.turn,O.answerStep??0,e)},[S,O,ae]),se=a(e=>e.foldCompletedTurns),ce=O!==void 0&&D!==void 0&&se&&D.turn===O.turn&&(D.turnStarted||D.turnClosed),le=E!==void 0&&ce&&!re&&t!==`reasoning`&&E.kind===`assistant-step`&&E.data.step===O.answerStep,ue=E!==void 0&&ce&&!le&&!hh.has(E.kind)&&!Fh(E)&&E.anchorSeq>=O.processStartSeq,A=E?.kind===`turn-process`||le,de=ce&&(re||ue||A),fe=(0,d.useMemo)(()=>O===void 0?void 0:{spec:O,foldable:de,hasContent:!ie&&(D?.hasExternalProcess===!0||O.inlineReasoning),open:oe,setOpen:k},[de,ie,oe,O,D?.hasExternalProcess,k]),pe=E?.kind===`turn-process`&&se&&!de,me=le&&de&&D.compactAnswer&&!oe,he=pe||de&&ue&&!oe,ge=Eh(he,(0,d.useCallback)(()=>{ue&&k(!0)},[ue,k]));Th(ge,T!==void 0);let[_e]=(0,d.useState)(()=>(0,m.createSnapshotStore)(0)),ve=Ah(n,ee),ye=Nh(E),be=(0,d.useMemo)(()=>({turnData:ye,disclosureReset:_e}),[ye,_e]);(0,d.useEffect)(()=>{ue&&he&&ge.current?.hasAttribute(`hidden`)&&_e.set(_e.getSnapshot()+1)},[ue,he,ge,_e]);let xe=(0,d.useMemo)(()=>T===void 0?null:{...t===void 0?{}:{groupPart:t},cwd:o,openFile:s,openSkill:c,inspectCall:l,forkAt:u,handoffAt:h,loadTurnDiffs:g,messageEditing:_,loadImage:v,renderMessageImages:y,fileMentions:b,turnProcess:fe,responseAnnotations:ve},[T,t,o,s,c,l,u,h,g,_,v,y,b,fe,ve]);if(E===void 0||xe===null)return null;let Se={...xe,node:E},Ce=t===void 0||t===`response`?E.key:JSON.stringify([E.key,t]);return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:ge,className:Mh.flowItem,"data-chat-anchor-key":Ce,"data-chat-flow-key":Ce,"data-chat-paging-anchor":E.kind!==`turn-process`||void 0,"data-chat-node-key":E.key,"data-chat-group-part":t,"data-chat-flow-kind":E.kind,"data-chat-turn":ee,"data-turn-process-member":ue||void 0,"data-turn-process-hidden":he||void 0,"data-turn-process-answer":me||void 0,children:C(`conversation.chat.node`,Se,{entryKey:E.kind,hookContext:be,fallback:/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:w(`message.unknownSurface`,{type:E.kind}),payload:E.data,truncatedLabel:e=>w(`json.truncated`,{total:e})})})})}),Lh={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
|
|
117
|
-
`,r:`\r`,t:` `},
|
|
118
|
-
`||e===`\r`||e===` `}function
|
|
116
|
+
default:throw Error(`unreachable context form: ${String(e)}`)}}let Lm=`@deepseek-ai/dsh-client-ui-chat/ContextInjectionRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Lm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Lm,e.textContent=`.uawKOW_root{min-width:0}.uawKOW_root[data-open]{padding-bottom:4px}.uawKOW_chevron{color:var(--dsw-alias-label-secondary)}.uawKOW_sep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.uawKOW_source{min-width:0;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:none;overflow:hidden}.uawKOW_summary{min-width:0;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.uawKOW_body{box-sizing:border-box;width:calc(100% - 22px - var(--dsh-content-font-delta,0px));max-height:141px;margin:4px 0 0 calc(22px + var(--dsh-content-font-delta,0px));border-radius:var(--dsw-radius-md);background:var(--dsw-alias-markdown-code-block);color:var(--dsw-alias-label-tertiary);font:400 11px/16px var(--ds-font-family-code);border:none;padding:10px 16px 12px 12px;overflow:auto}.uawKOW_toolChanges{white-space:nowrap}`,document.head.appendChild(e)}var Rm={body:`uawKOW_body`,chevron:`uawKOW_chevron`,root:`uawKOW_root`,sep:`uawKOW_sep`,source:`uawKOW_source`,summary:`uawKOW_summary`,toolChanges:`uawKOW_toolChanges`};function zm({content:e,source:t,producer:n,form:r,t:i}){let[a,o]=(0,d.useState)(!1),{rendered:s,summary:c,body:l}=Im(r,{content:e,source:t,t:i}),u=e.length>0&&e.every(e=>e.type===`tool-addition`||e.type===`tool-removal`)?e:void 0,m=u?.flatMap(e=>e.type===`tool-addition`?[e.toolName]:[])??[],h=u?.flatMap(e=>e.type===`tool-removal`?[e.toolName]:[])??[],g=u?.length===1?u[0]:void 0,_=u===void 0||g!==void 0?null:m.length>0&&h.length>0?i(`message.toolsChanged`,{added:m.length,removed:h.length}):m.length>0?i(`message.toolsAddedCount`,{count:m.length}):i(`message.toolsRemovedCount`,{count:h.length});return/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{className:Rm.root,icon:u===void 0?n.role===`recall`?/* @__PURE__ */ (0,f.jsx)(`span`,{"data-context-recall-icon":!0,children:/* @__PURE__ */ (0,f.jsx)(p.ReferenceIconRegular,{kind:`session`})}):/* @__PURE__ */ (0,f.jsx)(p.IconContextInjectionOutlineRegular,{size:14}):/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),chevronClassName:Rm.chevron,title:g===void 0?i(u===void 0?n.role===`recall`?`message.contextRecall`:`message.contextInjection`:`message.toolsUpdated`):i(g.type===`tool-addition`?`message.toolAdded`:`message.toolRemoved`,{name:g.toolName}),collapsedContent:_===null?u!==void 0||n.label===null?void 0:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Rm.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Rm.source,"data-context-source":!0,children:n.label}),c!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Rm.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Rm.summary,"data-context-summary":!0,children:c})]})]}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Rm.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Rm.summary,children:_})]}),keepContentWhenOpen:!0,open:a&&g===void 0,expandable:g===void 0,expandOnRowClick:!0,onToggle:()=>{o(e=>!e)},children:/* @__PURE__ */ (0,f.jsx)(`div`,{className:Rm.body,"data-context-injection-body":!0,"data-context-form":s??void 0,children:u===void 0?l:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Rm.toolChanges,children:[m.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{children:i(`message.toolsAdded`,{names:m.join(`, `)})}),h.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{children:i(`message.toolsRemoved`,{names:h.join(`, `)})})]})})})}function Bm(e){return String(e).padStart(2,`0`)}function Vm(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function Hm(e){let t=new Date(e);return t.setHours(24,0,0,0),Math.max(t.getTime()-e,1)}function Um(e,t){let n=Math.max(0,Math.floor(e/1e3)),r=Math.floor(n/3600),i=Math.floor(n/60)%60,a=n%60,o=[];return r>0&&o.push({text:String(r),numeric:!0},{text:t(`duration.hourUnit`),numeric:!1}),n>=60&&o.push({text:String(i),numeric:!0},{text:t(`duration.minuteUnit`),numeric:!1}),o.push({text:String(a),numeric:!0},{text:t(`duration.secondUnit`),numeric:!1}),o}function Wm(e,t,n=Date.now()){let r=new Date(e),i=new Date(n),a=`${Bm(r.getHours())}:${Bm(r.getMinutes())}`;if(r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate())return a;let o={y:r.getFullYear(),m:r.getMonth()+1,d:r.getDate()};return`${r.getFullYear()===i.getFullYear()?t(`clock.md`,o):t(`clock.ymd`,o)} ${a}`}function Gm(e){let t=e.harnessLabel?.trim()||e.harnessId,n=Km(e.model,e.harnessId);return n===void 0?{display:t,title:t}:{display:n,title:n.toLowerCase()===t.toLowerCase()?n:`${t} · ${n}`}}function Km(e,t){if(e===void 0)return;let n=e.trim();if(n===``)return;let r=n.indexOf(``);r!==-1&&(n=n.slice(0,r).trim()),n=n.replace(/^codexhost[:/]+/iu,``),n=n.replace(/^(?:harness|external|route)\/+/iu,``);let i=t.replace(/[.*+?^${}()|[\]\\]/gu,`\\$&`);if(n=n.replace(RegExp(`^${i}[:/]+`,`iu`),``),n=n.trim(),n!==``&&n.toLowerCase()!==`harness`)return n}function qm({size:e=16,className:t}){return/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:t,"aria-hidden":`true`,stroke:`currentColor`,strokeWidth:`1.35`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M2.5 5.25H13.25`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M10.5 2.75L13.25 5.25L10.5 7.75`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M13.5 10.75H2.75`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M5.5 8.25L2.75 10.75L5.5 13.25`})]})}function Jm({harnessId:e,label:t,hostId:n,size:r=15,className:i}){let a=(0,p.harnessIconSources)(e,n);return/* @__PURE__ */ (0,f.jsx)(`span`,{className:i,"data-harness-id":e,"aria-hidden":`true`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:r,height:r,flexShrink:0},children:e===`codex`?/* @__PURE__ */ (0,f.jsx)(`img`,{src:a.src,width:r,height:r,alt:t??``,style:{display:`block`,width:r,height:r,objectFit:`contain`}}):/* @__PURE__ */ (0,f.jsx)(p.RemotePluginIcon,{id:e,src:a.src,presentationUrl:a.presentationUrl,size:r,fallback:/* @__PURE__ */ (0,f.jsx)(p.IconDataOutlineRegular,{size:r})})})}function Ym(){let[e,t]=(0,d.useState)(()=>Vm(Date.now()));return(0,d.useEffect)(()=>{let e,n=()=>{let r=Date.now();t(Vm(r)),e=setTimeout(n,Hm(r))};return e=setTimeout(n,Hm(Date.now())),()=>{clearTimeout(e)}},[]),e}let Xm=`@deepseek-ai/dsh-client-ui-chat/MessageIconActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Xm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Xm,e.textContent=`.MIPpJq_actions{height:calc(28px + var(--dsh-content-font-delta,0px));-webkit-user-select:none;user-select:none;align-items:center;gap:8px;display:flex}.MIPpJq_timeStart{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);white-space:nowrap;padding-right:12px}.MIPpJq_timeEnd{font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:inherit;white-space:nowrap}.MIPpJq_endInfo{min-width:0;color:var(--dsw-alias-label-tertiary);align-items:center;gap:8px;margin-left:8px;display:inline-flex}@media (hover:hover){[data-actions-reveal=hover] .MIPpJq_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])) .MIPpJq_actions{opacity:0;transition:opacity 80ms}[data-actions-reveal=hover]:hover .MIPpJq_actions,[data-actions-reveal=hover]:focus-within .MIPpJq_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])):hover .MIPpJq_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])):focus-within .MIPpJq_actions{opacity:1}}.MIPpJq_action{width:calc(28px + var(--dsh-content-font-delta,0px));height:calc(28px + var(--dsh-content-font-delta,0px));border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:6px;display:inline-flex}.MIPpJq_action svg{width:calc(15px + var(--dsh-content-font-delta,0px));height:calc(15px + var(--dsh-content-font-delta,0px))}.MIPpJq_actions[data-clock=end] .MIPpJq_action svg{width:calc(17px + var(--dsh-content-font-delta,0px));height:calc(17px + var(--dsh-content-font-delta,0px))}.MIPpJq_action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.MIPpJq_action[data-unavailable]{cursor:default;opacity:.4}.MIPpJq_action[data-unavailable]:hover{color:var(--dsw-alias-label-tertiary);background:0 0}.MIPpJq_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var Zm={action:`MIPpJq_action`,actions:`MIPpJq_actions`,endInfo:`MIPpJq_endInfo`,timeEnd:`MIPpJq_timeEnd`,timeStart:`MIPpJq_timeStart`,visuallyHidden:`MIPpJq_visuallyHidden`};function Qm({text:e,time:t,clock:n,onBranch:r,branchUnavailable:i=!1,onHandoff:a,handoffUnavailable:o=!1,className:s,extraActions:c,t:l}){let u=Ym(),m=(0,d.useId)(),h=(0,d.useId)(),[g,_]=(0,d.useState)(!1),v=(0,d.useRef)(!1),y=(0,d.useRef)(null),b=(0,d.useRef)(0);(0,d.useEffect)(()=>()=>{b.current+=1,v.current=!1,y.current!==null&&clearTimeout(y.current)},[]);let x=(0,d.useCallback)(()=>{if(g||v.current)return;let t=b.current;v.current=!0,(0,p.writeClipboard)(e).then(e=>{t===b.current&&(v.current=!1,e&&(_(!0),y.current=window.setTimeout(()=>{y.current=null,_(!1)},1e3)))})},[g,e]),S=t===void 0?null:/* @__PURE__ */ (0,f.jsx)(`span`,{className:n===`start`?Zm.timeStart:Zm.timeEnd,children:Wm(t,l,u)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:s===void 0?Zm.actions:`${Zm.actions} ${s}`,"data-clock":n,children:[n===`start`?S:null,/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:l(g?`copied`:`copy`),side:`bottom`,portal:!0,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Zm.action,"aria-label":l(g?`copied`:`copy`),onClick:x,children:g?/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconCopyOutlineRegular,{})})}),c,r!==void 0&&/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:l(i?`message.branchUnavailable`:`message.branch`),side:`bottom`,portal:!0,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Zm.action,"aria-label":l(`message.branch`),"aria-disabled":i||void 0,"aria-describedby":i?m:void 0,"data-unavailable":i||void 0,onClick:i?void 0:r,children:/* @__PURE__ */ (0,f.jsx)(p.IconBranchOutlineRegular,{})})}),r!==void 0&&i&&/* @__PURE__ */ (0,f.jsx)(`span`,{id:m,className:Zm.visuallyHidden,children:l(`message.branchUnavailable`)}),a!==void 0&&/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:l(o?`message.handoffUnavailable`:`message.handoff`),side:`bottom`,portal:!0,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Zm.action,"aria-label":l(`message.handoff`),"aria-disabled":o||void 0,"aria-describedby":o?h:void 0,"data-unavailable":o||void 0,"data-action-handoff":``,onClick:o?void 0:a,children:/* @__PURE__ */ (0,f.jsx)(qm,{})})}),a!==void 0&&o&&/* @__PURE__ */ (0,f.jsx)(`span`,{id:h,className:Zm.visuallyHidden,children:l(`message.handoffUnavailable`)}),n===`end`?/* @__PURE__ */ (0,f.jsx)(`span`,{className:Zm.endInfo,children:S}):null]})}function $m(e,t,n){return e(`codexhostTurnTimes`,e=>t===void 0?void 0:e?.[t]?.[n]??void 0)}function eh(e,t,n){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(!1);return(0,d.useMemo)(()=>({targetSeq:e&&!n?t:null,draft:r,begin(e,r,o,s=[]){a.current||n||e!==t||i({seq:e,text:r,content:o,responseAnnotations:s,pending:!1,blocked:!1})},change(e){i(t=>t&&!t.pending?{...t,text:e}:t)},cancel(){a.current||i(null)},send(){!e||!r||r.blocked||a.current||n||!r.text.trim()&&r.responseAnnotations.length===0||(a.current=!0,i({...r,pending:!0,error:void 0}),e(r.seq,Ip(r.responseAnnotations,r.text)).then(e=>{e.status===`accepted`?i(null):i({...r,pending:!1,blocked:e.status!==`rejected`,error:e.message})},e=>{i({...r,pending:!1,blocked:!0,error:e instanceof Error?e.message:String(e)})}).finally(()=>{a.current=!1}))}}),[e,t,n,r])}function th({editing:e,t}){let n=e.draft;return n?/* @__PURE__ */ (0,f.jsxs)(`form`,{className:J.sentEditor,"data-sent-message-editor":!0,onSubmit:t=>{t.preventDefault(),e.send()},children:[/* @__PURE__ */ (0,f.jsx)(`textarea`,{autoFocus:!0,"aria-label":t(`message.edit`),value:n.text,disabled:n.pending,onChange:t=>e.change(t.target.value),onKeyDown:t=>{t.nativeEvent.isComposing||t.keyCode===229||(t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),e.send()),t.key===`Escape`&&(t.preventDefault(),e.cancel()))}}),!n.pending&&!n.error&&e.targetSeq!==n.seq&&/* @__PURE__ */ (0,f.jsx)(`div`,{role:`status`,children:t(`message.edit.changed`)}),n.error&&/* @__PURE__ */ (0,f.jsxs)(`div`,{role:`alert`,children:[n.error,n.blocked?` ${t(`message.edit.checkHistory`)}`:``]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.sentEditorActions,children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,size:`sm`,disabled:n.pending,onClick:e.cancel,children:t(`message.edit.cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,size:`sm`,type:`submit`,disabled:n.pending||n.blocked||!n.text.trim()&&n.responseAnnotations.length===0||e.targetSeq!==n.seq,children:n.pending?t(`message.edit.sending`):t(`message.edit.send`)})]})]}):null}function nh(e){return`nativePath`in e&&typeof e.nativePath==`string`?e.nativePath:void 0}function rh({upload:e,t}){let n=(0,d.useSyncExternalStore)(e.subscribe,e.getSnapshot);return n?.status===`uploading`?/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.fileMeta,role:`status`,"data-upload-progress":!0,children:n.total===void 0||n.total===0?t(`message.uploading`):t(`message.uploadingPercent`,{percent:Math.round(Math.min(1,(n.loaded??0)/n.total)*100)})}):null}function ih(e){let t=[],n=[],r=[];for(let i of e){let e=i;e.type===`text`&&typeof e.text==`string`?t.push(Rp(e.text).body):e.type===`image`&&e.attachment!==void 0?n.push({type:`image`,image:{attachment:e.attachment}}):e.type===`file`&&e.attachment!==void 0?n.push({type:`file`,file:e.attachment}):r.push(i)}return{text:t.join(``),attachments:n,rest:r}}function ah(e){return Math.max(1,Math.ceil(e/1e3))}function oh(e,t,n){return t===`ACCOUNT_SIGNED_OUT`?n(`message.failure.accountSignedOut`):t===`ACCOUNT_SIGN_IN_REQUIRED`?n(`message.failure.accountSignInRequired`):t===`QUOTA`||t===`ACCOUNT_QUOTA`?n(`message.failure.quota`):t===`AUTH`?n(`message.failure.auth`):e}function sh({node:e,active:t,t:n}){let r=(0,d.useMemo)(()=>Date.now()+e.delayMs,[e.delayMs,e.seq]),i=ah(e.delayMs),a=e.mode===`normal`?e.maxRetries:`∞`,[o,s]=(0,d.useState)(()=>({deadline:r,seconds:ah(r-Date.now())})),c=o.deadline===r?o.seconds:ah(r-Date.now());(0,d.useEffect)(()=>{if(!t)return;let e=()=>{let e=ah(r-Date.now());return s(t=>t.deadline===r&&t.seconds===e?t:{deadline:r,seconds:e}),e};if(e()===1)return;let n=window.setInterval(()=>{e()===1&&window.clearInterval(n)},250);return()=>{window.clearInterval(n)}},[t,r]);let l=t?n(`message.retry.active`):e.retryState===`cancelled`?n(`message.retry.cancelled`):e.retryState===`started`?n(`message.retry.started`):n(`message.retry.scheduled`),u=t?c:i;return/* @__PURE__ */ (0,f.jsxs)(`details`,{className:J.retryRow,"data-active":t||void 0,children:[/* @__PURE__ */ (0,f.jsx)(`summary`,{className:J.retrySummary,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.retryText,role:`status`,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:t,children:n(`message.retry.status`,{label:l,retry:e.retry,maximum:a,seconds:u})})})}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.retryDetails,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.retryDetailLabel,children:n(`message.retry.delay`)}),n(`duration.milliseconds`,{milliseconds:Math.round(e.delayMs)})]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.retryDetailLabel,children:n(`message.retry.failure`)}),oh(e.failure.message,e.failure.code,n)]})]})]})}function ch({node:e,t}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.turnErrorRow,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`error`,className:J.turnErrorDot}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.turnErrorCopy,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.turnErrorTitle,children:e.code===`ACCOUNT_SIGNED_OUT`?t(`message.accountStopped`):t(`message.turnError`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.turnErrorMessage,children:oh(e.message,e.code,t)})]}),e.code!==void 0&&/* @__PURE__ */ (0,f.jsx)(`code`,{className:J.turnErrorCode,children:e.code})]})}function lh({t:e}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.turnErrorRow,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`warning`,className:J.turnErrorDot}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.turnErrorCopy,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.maxTokensTitle,children:e(`message.maxTokens`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.turnErrorMessage,children:e(`message.maxTokens.hint`)})]})]})}function uh({content:e,renderMessageImages:t,actions:n,pending:r=!1,echo:i=!1,referenceLabels:a=[],skillNames:o=[],responseAnnotations:s=[],previewAttachments:c,references:l,links:u,editor:d,t:m}){let{text:h,attachments:g,rest:_}=ih(e),v=c??g,y=v.length>1,b=e=>m(`json.truncated`,{total:e}),x=h!==``||_.length>0,S=jp(h);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:S?J.noticeRow:J.userRow,"data-pending-steering":r||void 0,"data-submission-echo":i||void 0,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:S?J.noticeStack:J.userStack,children:[s.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.annotationRow,"data-message-annotations":!0,children:s.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(p.ResponseAnnotationChip,{index:t+1,annotation:e,labels:im(m)},`${String(t)}:${e.text}`))}),v.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.attachmentRow,"data-message-attachments":!0,children:v.map((e,n)=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.pendingAttachment,children:[e.type===`image`?t({images:[e.image],align:`end`,compact:y}):/* @__PURE__ */ (0,f.jsxs)(`span`,{className:J.fileCard,title:nh(e.file)??e.file.name,children:[/* @__PURE__ */ (0,f.jsx)(p.FileTypeIcon,{path:e.file.name,className:J.fileIcon}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:J.fileContent,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.fileName,children:e.file.name}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.fileMeta,children:[(0,p.fileExtension)(e.file.name).toUpperCase().slice(0,8),nh(e.file)===void 0?(0,p.fileSizeText)(e.file.bytes):void 0].filter(Boolean).join(` `)})]})]}),e.upload&&/* @__PURE__ */ (0,f.jsx)(rh,{upload:e.upload,t:m})]},n))}),d??(x&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:S?void 0:J.bubble,children:[S?/* @__PURE__ */ (0,f.jsx)(lm,{entries:S,links:u,t:m}):(0,p.projectUserText)(h,a,o,`skill`,l),_.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:m(`message.extraBlock`),payload:e,truncatedLabel:b},t))]})),a.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.referenceSummary,children:m(`message.referenceSummary`,{labels:a.join(m(`message.referenceSeparator`))})})]}),!S&&n?.(h)]})}function dh({content:e,renderMessageImages:t,t:n}){return/* @__PURE__ */ (0,f.jsx)(uh,{content:e,renderMessageImages:t,pending:!0,t:n,actions:e=>/* @__PURE__ */ (0,f.jsx)(Qm,{text:e,clock:`start`,className:J.actions,t:n})})}function fh({submission:e,renderMessageImages:t,t:n}){let r=(0,d.useMemo)(()=>e.text===``?[]:[{type:`text`,text:e.text}],[e.text]),i=(0,d.useMemo)(()=>e.attachments.map(e=>({upload:e.upload,...e.type===`image`?{type:`image`,image:{preview:{url:e.value.previewUrl,...e.value.name===void 0?{}:{name:e.value.name},...e.value.width===void 0?{}:{width:e.value.width},...e.value.height===void 0?{}:{height:e.value.height}}}}:{type:`file`,file:e.value}})),[e.attachments]);return/* @__PURE__ */ (0,f.jsx)(uh,{content:r,previewAttachments:i,renderMessageImages:t,pending:e.placement===`steering`,echo:!0,t:n,actions:t=>/* @__PURE__ */ (0,f.jsx)(Qm,{text:t,time:e.time,clock:`start`,className:J.actions,t:n})})}let ph=(0,d.memo)(function({node:e,renderMessageImages:t,openFile:n,openSkill:r,messageEditing:i,useProjection:a,links:o,t:s}){let c=e.data,l=$m(a,e.location.kind===`turn`||e.location.kind===`step`?e.location.turn.turn:void 0,`start`);return/* @__PURE__ */ (0,f.jsx)(uh,{content:c.content,editor:i?.draft?.seq===c.seq?/* @__PURE__ */ (0,f.jsx)(th,{editing:i,t:s}):void 0,references:{openFile:n,openSkill:r},links:o,renderMessageImages:t,responseAnnotations:c.responseAnnotations,...c.referenceLabels===void 0?{}:{referenceLabels:c.referenceLabels},...c.skillNames===void 0?{}:{skillNames:c.skillNames},t:s,actions:t=>/* @__PURE__ */ (0,f.jsx)(Qm,{extraActions:e.kind===`user`&&i?.targetSeq===c.seq&&!i.draft?/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:J.editAction,"aria-label":s(`message.edit`),title:s(`message.edit`),onClick:()=>i.begin(c.seq,t,c.content,c.responseAnnotations),children:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{})}):null,text:t,time:e.kind===`user`?l:void 0,clock:`start`,className:J.actions,t:s})})});function mh({editing:e,renderMessageImages:t,t:n}){return/* @__PURE__ */ (0,f.jsx)(uh,{content:e.draft?.content??[],responseAnnotations:e.draft?.responseAnnotations,renderMessageImages:t,editor:/* @__PURE__ */ (0,f.jsx)(th,{editing:e,t:n}),t:n})}let hh=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(zm,{content:n.content,source:n.source,producer:n.producer,form:n.form,t})}),gh=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(dm,{node:e.data,t})}),_h=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(sh,{node:n.current,active:n.current.retryState===`scheduled`,t})}),vh=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(ch,{node:e.data,t})}),yh=(0,d.memo)(function({t:e}){return/* @__PURE__ */ (0,f.jsx)(lh,{t:e})}),bh=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.contextRow,children:/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownSurface`,{type:n.type}),payload:n.data,truncatedLabel:e=>t(`json.truncated`,{total:e})})})}),xh=/* @__PURE__ */ new Set([`system-prompt`,`user`,`steering`,`turn-trigger`,`turn-process`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function Sh(e,t){return e.turn===t.turn&&e.controlAnchorSeq===t.controlAnchorSeq&&e.processStartSeq===t.processStartSeq&&e.answerAnchorSeq===t.answerAnchorSeq&&e.answerStep===t.answerStep&&e.inlineReasoning===t.inlineReasoning&&e.messageCount===t.messageCount&&e.toolCallCount===t.toolCallCount&&e.subagentCount===t.subagentCount}function Ch(e){return e===`subagent`||e.startsWith(`subagent_`)}function wh(e){return e===`compact_context`}function Th(e){let t=e?.location;if(t?.kind!==`turn`&&t?.kind!==`step`)return!1;let n=t.turn.end?.data.reason.kind;return t.turn.status===`open`||t.turn.end?.data.finalAssistantStep===null||n===`aborted`||n===`error`}function Eh(e,t){return e.turnProcesses.find(e=>e.turn===t)}function Dh(){return(0,m.defineStore)({init:()=>({turnProcesses:[]}),actions:{setTurnProcessOpen:(e,t,n,r)=>{let i=e.turnProcesses.findIndex(e=>e.turn===t);if(!r){i>=0&&e.turnProcesses.splice(i,1);return}let a={turn:t,answerStep:n};i<0?e.turnProcesses.push(a):e.turnProcesses[i]=a}}})}let Oh=`data-chat-near-viewport`,kh=/* @__PURE__ */ new WeakMap;function Ah(e){let t=kh.get(e);return t===void 0&&(t=new IntersectionObserver(e=>{for(let t of e)t.target.toggleAttribute(Oh,t.isIntersecting)},{root:e,rootMargin:`100% 0px`}),kh.set(e,t)),t}function jh(e,t){(0,d.useLayoutEffect)(()=>{let t=e.current;if(t===null||t.matches(`[data-chat-flow-key] *`))return;t.setAttribute(Oh,``);let n=t.closest(`[data-conversation-scroll]`);if(n===null)return;let r=Ah(n);return r.observe(t),()=>{r.unobserve(t)}},[e,t])}function Mh(e,t){let n=(0,d.useRef)(null);return(0,d.useLayoutEffect)(()=>{let r=n.current;r!==null&&(e&&r.contains(r.ownerDocument.activeElement)?t():e?r.setAttribute(`hidden`,`until-found`):r.removeAttribute(`hidden`))},[e,t]),(0,d.useEffect)(()=>{let e=n.current;if(e!==null)return e.addEventListener(`beforematch`,t),()=>{e.removeEventListener(`beforematch`,t)}},[t]),n}let Nh=[],Ph={getSnapshot:()=>Nh,subscribe:()=>()=>{}};function Fh(e){let t=Nh;return{getSnapshot:()=>{let n=e.getSnapshot().flatMap(e=>e.responseAnnotations??[]);return n.length===t.length&&n.every((e,n)=>e===t[n])||(t=n.length===0?Nh:n),t},subscribe:e.subscribe}}function Ih(e,t){let n=(0,d.useMemo)(()=>t===void 0?Ph:Fh(e.turnDataSource(t,`user`)),[e,t]);return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let Lh=`@deepseek-ai/dsh-client-ui-chat/ChatView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Lh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Lh,e.textContent=`.BZ5KQW_frame{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative;container-type:inline-size}.BZ5KQW_root{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative;overflow:visible clip}.BZ5KQW_scroll{--dsh-chat-scroll-pad-x:calc(var(--dsh-composer-side-clearance,0px) + 16px);min-height:0;padding:16px var(--dsh-chat-scroll-pad-x);flex:auto;overflow-y:auto}.BZ5KQW_root[data-chat-following-tail] .BZ5KQW_scroll,[data-conversation-scroll]:has(.BZ5KQW_root[data-chat-following-tail]){overflow-anchor:none}[data-conversation-scroll] .BZ5KQW_frame,[data-conversation-scroll] .BZ5KQW_root{flex:none;height:auto;min-height:auto}[data-conversation-scroll] .BZ5KQW_scroll{flex:none;min-height:auto;overflow:visible}.BZ5KQW_column{max-width:var(--dsh-chat-content-width);flex-direction:column;width:100%;margin:0 auto;display:flex}.BZ5KQW_column>:not([hidden]):not(.BZ5KQW_flowItem:not([data-chat-virtualized]):is(:empty,[data-chat-empty]))~:not([hidden]):not(.BZ5KQW_flowItem:not([data-chat-virtualized]):is(:empty,[data-chat-empty])){margin-top:var(--dsh-chat-flow-gap,6px)}.BZ5KQW_flowItem[data-chat-group-part=response],.BZ5KQW_column>[data-chat-group-part=response]:not([hidden]):not(:is(:empty,[data-chat-empty]):not([data-chat-virtualized]))+:not([hidden]):not(.BZ5KQW_flowItem:not([data-chat-virtualized]):is(:empty,[data-chat-empty])):not(.BZ5KQW_running){--dsh-chat-flow-gap:12px}.BZ5KQW_flowItem{min-width:0}.BZ5KQW_flowItem[data-chat-flow-kind=turn-process],.BZ5KQW_flowItem[data-turn-process-answer],.BZ5KQW_column>[data-chat-flow-kind=turn-process]+:not([hidden]):not(.BZ5KQW_flowItem:not([data-chat-virtualized]):is(:empty,[data-chat-empty])):not(.BZ5KQW_running){--dsh-chat-flow-gap:16px}.BZ5KQW_flowItem:not([data-chat-virtualized]):is(:empty,[data-chat-empty]){height:0}.BZ5KQW_callRow{border-radius:var(--dsw-radius-sm)}.BZ5KQW_syncing{color:var(--dsw-alias-label-secondary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));align-items:center;gap:6px;padding-block:8px;display:flex}@media (prefers-reduced-motion:reduce){.BZ5KQW_syncingIcon{display:none}}.BZ5KQW_hint{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}.BZ5KQW_running{--dsh-chat-flow-gap:12px;--dsw-alias-label-shimmer:var(--dsw-alias-label-deep-diving-shimmer);color:var(--dsw-alias-label-deep-diving);font-size:calc(var(--dsh-content-font-size,14px) - 2px);line-height:calc(22px + var(--dsh-content-font-delta,0px));flex-direction:column;align-items:flex-start;display:flex}.BZ5KQW_column>:nth-last-child(2 of :not([hidden]):not(.BZ5KQW_flowItem:not([data-chat-virtualized]):is(:empty,[data-chat-empty]))):is(.BZ5KQW_flowItem:not([data-chat-flow-kind=user]):not([data-chat-flow-kind=steering]):not([data-chat-flow-kind=turn-trigger]),[data-chat-group-key])~.BZ5KQW_running>.BZ5KQW_runningDivider{display:block}.BZ5KQW_runningDivider{background:color-mix(in srgb, var(--dsw-alias-border-l1) 75%, var(--dsw-alias-border-l2));pointer-events:none;width:100%;height:.5px;margin:8px 0 10px;display:none}.BZ5KQW_runningContent{align-items:center;gap:6px;min-width:0;display:inline-flex}.BZ5KQW_runningText{font-variant-numeric:tabular-nums;min-width:0}.BZ5KQW_runningIcon{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));contain:strict;flex:none;display:inline-flex;overflow:hidden}.BZ5KQW_runningIconMotion{transform-origin:50% 60%;width:100%;height:100%;display:inline-flex}@keyframes BZ5KQW_runningIconSway{0%,to{transform:translateY(.5px)rotate(-20deg)}50%{transform:translateY(-.6px)rotate(20deg)}}@media (prefers-reduced-motion:no-preference) and (forced-colors:none){.BZ5KQW_runningIconMotion{animation:1.6s ease-in-out infinite BZ5KQW_runningIconSway}}.BZ5KQW_openError{color:var(--dsw-alias-state-error-primary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}.BZ5KQW_older{min-height:28px;color:var(--dsw-alias-label-secondary);flex-wrap:wrap;justify-content:center;align-items:center;gap:8px;font-size:12px;display:flex}.BZ5KQW_older button{border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover-solid);cursor:pointer;border:none;padding:4px 12px;font-size:12px}.BZ5KQW_older button:disabled{cursor:default;opacity:.6}.BZ5KQW_toBottomSlot{z-index:8;height:0;padding-right:max(calc(var(--dsh-composer-side-clearance) + 16px), calc((100% - var(--dsh-chat-content-width)) / 2));pointer-events:none;justify-content:flex-end;display:flex;position:absolute;bottom:16px;left:0;right:0}[data-conversation-scroll] .BZ5KQW_toBottomSlot{bottom:calc(var(--dsh-composer-height,152px) + 16px);position:sticky}.BZ5KQW_toBottom{--dsw-elevation-stroke-color:var(--dsw-alias-border-l3);corner-shape:round;width:34px;height:34px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-button-floating-fill);box-shadow:var(--dsw-elevation-panel);cursor:pointer;pointer-events:auto;border:0;border-radius:100px;justify-content:center;align-items:center;margin-top:-34px;padding:0;display:flex}.BZ5KQW_toBottom:hover{background:var(--dsw-alias-button-floating-hover)}.BZ5KQW_modalAction{min-width:72px}`,document.head.appendChild(e)}var Rh={callRow:`BZ5KQW_callRow`,column:`BZ5KQW_column`,flowItem:`BZ5KQW_flowItem`,frame:`BZ5KQW_frame`,hint:`BZ5KQW_hint`,modalAction:`BZ5KQW_modalAction`,older:`BZ5KQW_older`,openError:`BZ5KQW_openError`,root:`BZ5KQW_root`,running:`BZ5KQW_running`,runningContent:`BZ5KQW_runningContent`,runningDivider:`BZ5KQW_runningDivider`,runningIcon:`BZ5KQW_runningIcon`,runningIconMotion:`BZ5KQW_runningIconMotion`,runningIconSway:`BZ5KQW_runningIconSway`,runningText:`BZ5KQW_runningText`,scroll:`BZ5KQW_scroll`,syncing:`BZ5KQW_syncing`,syncingIcon:`BZ5KQW_syncingIcon`,toBottom:`BZ5KQW_toBottom`,toBottomSlot:`BZ5KQW_toBottomSlot`};function zh(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.data:void 0}function Bh(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function Vh(e){return e?.kind===`tool-call`&&wh(e.data.root.name)}function Hh(e){for(let t=e.firstElementChild;t!==null;t=t.nextElementSibling)if(t.getAttribute(`data-slot`)===`conversation.chat.node`)return t;return null}function Uh(e){for(let t=e.firstChild;t!==null;t=t.nextSibling)if(t.nodeType===Node.ELEMENT_NODE||(t.nodeType===Node.TEXT_NODE||t.nodeType===Node.CDATA_SECTION_NODE)&&(t.nodeValue?.length??0)>0)return!1;return!0}function Wh(e,t){t!==null&&Uh(t)?e.setAttribute(`data-chat-empty`,``):e.removeAttribute(`data-chat-empty`)}let Gh=(0,d.memo)(function({nodeKey:e,groupPart:t,nodeStore:n,useChatNode:r,useChatNodeProcess:i,usePresentation:a,cwd:o,openFile:s,openSkill:c,inspectCall:l,forkAt:u,handoffAt:h,loadTurnDiffs:g,messageEditing:_,loadImage:v,renderMessageImages:y,fileMentions:b,useStore:x,actions:S,renderSlot:C,t:w,mounted:T=!0,placeholderHeight:E,registerRow:D}){let O=r(e),k=O,ee=Bh(k),te=i(e),A=te?.spec,ne=x(e=>A===void 0?void 0:Eh(e,A.turn)),re=A!==void 0&&ne?.answerStep===(A.answerStep??0)?ne:void 0,ie=te!==void 0&&!te.turnClosed,ae=te?.hasInterleavedInput===!0,oe=ie||ae||Th(k),se=oe||re!==void 0,ce=(0,d.useCallback)(e=>{A!==void 0&&!oe&&S.setTurnProcessOpen(A.turn,A.answerStep??0,e)},[S,A,oe]),le=a(e=>e.foldCompletedTurns),ue=A!==void 0&&te!==void 0&&le&&te.turn===A.turn&&(te.turnStarted||te.turnClosed),de=k!==void 0&&ue&&!ie&&t!==`reasoning`&&k.kind===`assistant-step`&&k.data.step===A.answerStep,j=k!==void 0&&ue&&!de&&!xh.has(k.kind)&&!Vh(k)&&k.anchorSeq>=A.processStartSeq,fe=k?.kind===`turn-process`||de,pe=ue&&(ie||j||fe),me=(0,d.useMemo)(()=>A===void 0?void 0:{spec:A,foldable:pe,hasContent:!ae&&(te?.hasExternalProcess===!0||A.inlineReasoning),open:se,setOpen:ce},[pe,ae,se,A,te?.hasExternalProcess,ce]),he=k?.kind===`turn-process`&&le&&!pe,ge=de&&pe&&te.compactAnswer&&!se,_e=he||pe&&j&&!se,ve=Mh(_e,(0,d.useCallback)(()=>{j&&ce(!0)},[j,ce]));jh(ve,O!==void 0);let ye=k===void 0?void 0:t===void 0||t===`response`?k.key:JSON.stringify([k.key,t]),be=k!==void 0&&ye!==void 0;(0,d.useLayoutEffect)(()=>{let e=ve.current;if(e===null)return;if(!T||!be){e.removeAttribute(`data-chat-empty`);return}let t=Hh(e);if(Wh(e,t),typeof MutationObserver>`u`)return;let n=new MutationObserver(()=>{let r=Hh(e);r!==t&&(n.disconnect(),n.observe(e,{childList:!0}),r!==null&&n.observe(r,{childList:!0}),t=r),Wh(e,r)});return n.observe(e,{childList:!0}),t!==null&&n.observe(t,{childList:!0}),()=>{n.disconnect()}},[T,be,ve]),(0,d.useLayoutEffect)(()=>{let e=ve.current;e!==null&&T&&be&&Wh(e,Hh(e))}),(0,d.useLayoutEffect)(()=>{if(D===void 0||ye===void 0)return;let e=ve.current;if(e!==null)return D(ye,e),()=>{D(ye,null)}},[D,ye,ve]);let[xe]=(0,d.useState)(()=>(0,m.createSnapshotStore)(0)),Se=(0,p.useCodeBlockFoldMemory)(),Ce=(0,d.useRef)(null);Se===void 0&&Ce.current===null&&(Ce.current=/* @__PURE__ */ new Map);let we=Se??Ce.current,Te=Ih(n,ee),Ee=zh(k),De=(0,d.useMemo)(()=>({turnData:Ee,disclosureReset:xe}),[Ee,xe]);(0,d.useEffect)(()=>{j&&_e&&ve.current?.hasAttribute(`hidden`)&&xe.set(xe.getSnapshot()+1)},[j,_e,ve,xe]);let Oe=(0,d.useMemo)(()=>O===void 0?null:{...t===void 0?{}:{groupPart:t},cwd:o,openFile:s,openSkill:c,inspectCall:l,forkAt:u,handoffAt:h,loadTurnDiffs:g,messageEditing:_,loadImage:v,renderMessageImages:y,fileMentions:b,turnProcess:me,responseAnnotations:Te},[O,t,o,s,c,l,u,h,g,_,v,y,b,me,Te]);if(k===void 0||Oe===null||ye===void 0)return null;let ke={...Oe,node:k},Ae=!T&&!_e&&E!==void 0&&E>0;return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:ve,className:Rh.flowItem,"data-chat-anchor-key":ye,"data-chat-flow-key":ye,"data-chat-paging-anchor":k.kind!==`turn-process`||void 0,"data-chat-node-key":k.key,"data-chat-group-part":t,"data-chat-flow-kind":k.kind,"data-chat-turn":ee,"data-turn-process-member":j||void 0,"data-turn-process-hidden":_e||void 0,"data-turn-process-answer":ge||void 0,"data-chat-virtualized":Ae?``:void 0,style:Ae?{minHeight:E}:void 0,children:T?/* @__PURE__ */ (0,f.jsx)(p.CodeBlockFoldMemoryProvider,{memory:we,scope:ye,children:C(`conversation.chat.node`,ke,{entryKey:k.kind,hookContext:De,fallback:/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:w(`message.unknownSurface`,{type:k.kind}),payload:k.data,truncatedLabel:e=>w(`json.truncated`,{total:e})})})}):null})}),Kh={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
|
|
117
|
+
`,r:`\r`,t:` `},qh=/[\\\u0000-\u001f]/u;function Jh(e){return e===` `||e===`
|
|
118
|
+
`||e===`\r`||e===` `}function Yh(e){return e>=`0`&&e<=`9`||e>=`a`&&e<=`f`||e>=`A`&&e<=`F`}var Xh=class e{static EMPTY=e.fromObject({});static fromText(t){let n=new e;return n.append(t),n.sealed=!0,n}static fromObject(t){let n=new e;return n.object=typeof t==`object`&&t&&!Array.isArray(t)?t:{},n.sealed=!0,n}chunks=[];object;sealed=!1;#e=[];#t=0;#n=0;#r=`root`;#i=!1;#a=0;#o=!1;#s=``;#c=null;#l=[];#u=!1;#d;#f=!1;#p=/* @__PURE__ */ new Map;#m=[];#h=/* @__PURE__ */ new Map;get isSealed(){return this.sealed}get invalid(){return this.scan(),this.#r===`invalid`||this.#f}append(e){if(this.sealed)throw Error(`PartialArguments: cannot append to a sealed view`);e.length!==0&&(this.chunks.push(e),this.#t+=e.length,this.#e.push(this.#t))}settle(t){if(this.object!==void 0||t.length!==this.#t)return e.fromText(t);let n=0;for(let r of this.chunks){if(!t.startsWith(r,n))return e.fromText(t);n+=r.length}return this.chunks=t.length===0?[]:[t],this.#e=t.length===0?[]:[t.length],this.sealed=!0,this}refresh(){if(this.#h.size===0)return!1;this.scan();let e=!1,t=!1;for(let n of this.#h.values())n.completion?t=!0:e=this.refreshRead(n)||e;if(t)for(let t of this.#h.values())t.completion&&(e=this.refreshRead(t)||e);return this.sealed&&this.#h.clear(),e}refreshRead(e){let t=e.answer();return!Object.is(t,e.last)&&(e.last=t,!0)}closed(){return this.remember(`closed`,``,()=>this.closedNow())}keys(){return this.remember(`keys`,``,()=>this.keysNow(),e=>e.length)}has(e){return this.remember(`has`,e,()=>this.hasNow(e))}complete(e){return this.remember(`complete`,e,()=>this.completeNow(e))}stringLength(e,t){let n=Math.max(1,Math.floor(t?.step??1)),r=t?.offset??0;return this.remember(`length:${n}:${r}`,e,()=>this.lengthNow(e),e=>e===void 0?void 0:Math.ceil((e+r)/n))}stringExceeds(e,t){let n=Math.max(0,Math.floor(t));return this.remember(`exceeds:${n}`,e,()=>(this.lengthNow(e,n+1)??0)>n)}text(e){return this.remember(`text`,e,()=>this.textNow(e))}textPrefix(e,t){let n=Math.max(1,Math.floor(t));return this.remember(`prefix:${n}`,e,()=>this.textPrefixNow(e,n))}value(e){return this.remember(`value`,e,()=>this.valueNow(e))}remember(e,t,n,r){this.scan();let i=n();if(!this.sealed){let a=`${e}/${t}`;this.#h.has(a)||this.#h.set(a,{completion:e===`complete`,answer:r===void 0?n:()=>r(n()),last:r===void 0?i:r(i)})}return i}closedNow(){return this.sealed||this.#r===`closed`||this.#r===`invalid`}keysNow(){return this.object===void 0?this.#m:Object.keys(this.object)}hasNow(e){return this.object===void 0?this.#p.has(e):Object.hasOwn(this.object,e)}completeNow(e){if(this.object!==void 0)return Object.hasOwn(this.object,e);let t=this.#p.get(e);return t!==void 0&&t.end>=0&&(t.kind===`string`?t.invalidAt===void 0:!t.invalid)}lengthNow(e,t=1/0){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t.length:void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;if(n.text!==void 0&&n.text.at===n.end)return n.text.length;let r=n.length??={at:n.start,length:0,text:``};return this.readString(n,r,t,!1),r.length}textNow(e){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t:void 0}let t=this.#p.get(e);if(t?.kind!==`string`)return;if(t.text===void 0&&t.end>=0&&t.needsDecoding&&t.invalidAt===void 0){let e;try{e=JSON.parse(`"${this.slice(t.start,t.end)}"`)}catch{}e!==void 0&&(t.text={at:t.end,length:e.length,text:e})}let n=t.text??={at:t.start,length:0,text:``};return this.readString(t,n,1/0,!0),n.text}textPrefixNow(e,t){if(this.object!==void 0){let n=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof n==`string`?n.slice(0,t):void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;let r=n.prefixes??=/* @__PURE__ */ new Map,i=r.get(t);return i===void 0&&(i={at:n.start,length:0,text:``},r.set(t,i)),this.readString(n,i,t,!0),i.text}valueNow(e){if(this.object!==void 0){if(!Object.hasOwn(this.object,e))return;let t=this.object[e];return typeof t==`string`?void 0:t}let t=this.#p.get(e);if(!(t?.kind!==`value`||t.end<0||t.invalid)){if(t.parsed===void 0)try{t.parsed=JSON.parse(this.slice(t.start,t.end))}catch{t.invalid=!0,this.#f=!0}return t.parsed}}chunkAt(e){let t=0,n=this.#e.length;for(;t<n;){let r=t+n>>>1;this.#e[r]<=e?t=r+1:n=r}return t}slice(e,t){if(e>=t)return``;let n=this.chunkAt(e),r=this.chunkAt(t-1),i=n===0?0:this.#e[n-1];if(n===r)return this.chunks[n].slice(e-i,t-i);let a=[this.chunks[n].slice(e-i)];for(let e=n+1;e<r;e++)a.push(this.chunks[e]);return a.push(this.chunks[r].slice(0,t-this.#e[r-1])),a.join(``)}readString(e,t,n,r){let i=Math.min(e.end<0?this.#n:e.end,e.invalidAt??1/0,this.#d??1/0);if(!e.needsDecoding){let e=Math.min(i-t.at,n-t.length);if(e<=0)return;r&&(t.text+=this.slice(t.at,t.at+e)),t.at+=e,t.length+=e;return}let a=this.chunkAt(t.at);for(;t.at<i&&t.length<n;){let o=a===0?0:this.#e[a-1],s=this.chunks[a],c=s.slice(t.at-o,Math.min(s.length,i-o)),l=c.search(qh),u=Math.min(l<0?c.length:l,n-t.length);if(u>0){r&&(t.text+=c.slice(0,u)),t.at+=u,t.length+=u,t.at===o+s.length&&a++;continue}let d=c.length>1?c[1]:t.at+1<i?this.chunks[a+1][0]:void 0,f,p=2;if(c[0]===`\\`&&d===void 0&&e.end<0)return;if(c[0]===`\\`&&d===`u`){let n=this.slice(t.at+2,Math.min(i,t.at+6)),r=!0;for(let e=0;e<n.length;e++)Yh(n[e])||(r=!1);if(r){if(n.length<4&&e.end<0)return;n.length===4&&(f=String.fromCharCode(Number.parseInt(n,16)))}p=6}else c[0]===`\\`&&d!==void 0&&(f=Kh[d]);if(f===void 0){e.invalidAt=t.at,this.#f=!0;return}for(r&&(t.text+=f),t.length++,t.at+=p;a<this.chunks.length&&t.at>=this.#e[a];)a++}}scan(){if(this.object===void 0&&this.#n!==this.#t)for(let e=this.chunkAt(this.#n);e<this.chunks.length&&this.#d===void 0;e++){let t=this.chunks[e],n=e===0?0:this.#e[e-1];for(let e=this.#n-n;e<t.length&&this.#r!==`invalid`;e++){if(this.#r===`string`||this.#r===`nested`&&this.#u){let n=this.stringBoundary(t,e);if(this.#n+=n-e,e=n,e===t.length)break}this.step(t[e],this.#n),this.#n++}}}stringBoundary(e,t){let n=t;for(;;){let t=e.indexOf(`"`,n),r=t<0?e.length:t;if(this.#r===`string`){let t=this.#c;!t.needsDecoding&&qh.test(e.slice(n,r))&&(t.needsDecoding=!0)}let i=r;for(;i>n&&e[i-1]===`\\`;)i--;let a=(r-i)%2==1!==(i===n&&this.#i);if(this.#i=t<0&&a,t<0||!a)return r;n=t+1}}step(e,t){switch(this.#r){case`root`:if(Jh(e))return;if(e===`{`){this.#r=`key-or-end`;return}this.fail();return;case`key-or-end`:if(Jh(e))return;if(e===`}`){this.#r=`closed`;return}if(e===`"`){this.beginKey(t);return}this.fail();return;case`key-only`:if(Jh(e))return;if(e===`"`){this.beginKey(t);return}this.fail();return;case`key`:this.stepKey(e,t);return;case`colon`:if(Jh(e))return;if(e===`:`){this.#r=`value`;return}this.fail();return;case`value`:this.beginValue(e,t);return;case`string`:{let e=this.#c;e.end=t,this.#c=null,this.#r=`comma-or-end`;return}case`scalar`:this.stepScalar(e,t);return;case`nested`:this.stepNested(e,t);return;case`comma-or-end`:if(Jh(e))return;if(e===`,`){this.#r=`key-only`;return}if(e===`}`){this.#r=`closed`;return}this.fail();return;case`closed`:if(Jh(e))return;this.fail();return;
|
|
119
119
|
/* v8 ignore next 2 -- scan() stops stepping once the view is invalid. */
|
|
120
120
|
case`invalid`:return;
|
|
121
121
|
/* v8 ignore next 2 -- Every scanner mode has a handler above. */
|
|
122
|
-
default:Hh(this.#r)}}fail(){this.#d=this.#n,this.#r=`invalid`,this.#c=null}beginKey(e){this.#r=`key`,this.#a=e+1,this.#o=!1,this.#i=!1}stepKey(e,t){if(e<` `){this.fail();return}if(this.#i){this.#i=!1;return}if(e===`\\`){this.#i=!0,this.#o=!0;return}if(e!==`"`)return;let n=this.slice(this.#a,t);if(this.#o)try{this.#s=JSON.parse(`"${n}"`)}catch{this.fail();return}else this.#s=n;this.#r=`colon`}open(e){this.#p.has(this.#s)||this.#m.push(this.#s),this.#p.set(this.#s,e),this.#c=e}beginValue(e,t){zh(e)||(e===`"`?(this.open({kind:`string`,start:t+1,end:-1,needsDecoding:!1,invalidAt:void 0,length:void 0,text:void 0,prefixes:void 0}),this.#i=!1,this.#r=`string`):e===`}`||e===`,`||e===`:`||e===`]`?this.fail():(this.open({kind:`value`,start:t,end:-1,parsed:void 0,invalid:!1}),e===`{`||e===`[`?(this.#r=`nested`,this.#l=[e===`{`?`}`:`]`],this.#u=!1,this.#i=!1):this.#r=`scalar`))}stepScalar(e,t){(e===`,`||e===`}`||zh(e))&&(this.closeValue(t),this.#r=e===`,`?`key-only`:e===`}`?`closed`:`comma-or-end`)}stepNested(e,t){if(this.#u)this.#u=!1;else if(e===`"`)this.#u=!0;else if(e===`{`||e===`[`)this.#l.push(e===`{`?`}`:`]`);else if(e===`}`||e===`]`){if(this.#l.pop()!==e){this.fail();return}this.#l.length===0&&(this.closeValue(t+1),this.#r=`comma-or-end`)}}closeValue(e){let t=this.#c;t.end=e,this.#c=null}};function Hh(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}function Uh(e){switch(e.kind){case`node`:return JSON.stringify([`node`,e.key,e.groupPart??null]);case`group`:return JSON.stringify([`group`,e.key]);default:return Hh(e)}}function Wh(e,t){let n=e.counts.slice(0,3).map(({kind:e})=>t(`message.stepProcess.done.${e}`)),r=n[0];if(r===void 0)return t(`message.stepProcess.done.thinking`);let i=e=>e.charAt(0).toLowerCase()+e.slice(1),a=n[1];if(a===void 0)return r;if(n.length===2){let e=t(`message.stepProcess.sharedPrefix`);return t(`message.stepProcess.joinTwo`,{first:r,second:i(e!==``&&r.startsWith(e)&&a.startsWith(e)?a.slice(e.length):a)})}let o=[r,...n.slice(1).map(i)].join(t(`message.stepProcess.comma`));return e.counts.length>3?t(`message.stepProcess.more`,{title:o}):o}function Gh(e=0){let[t,n]=(0,d.useState)(null);return{expanded:t===e,setExpanded:(0,d.useCallback)(t=>{n(t?e:null)},[e]),toggle:(0,d.useCallback)(()=>{n(t=>t===e?null:e)},[e])}}function Kh(e){let t=t=>e.subscribe(t),n=()=>e.getSnapshot();return function(){return Gh((0,d.useSyncExternalStore)(t,n))}}function qh(e){let t=e.clientHeight;return{top:e.scrollTop,height:t,floor:Math.max(0,e.scrollHeight-t)}}var Jh=class e{following;threshold;static owners=/* @__PURE__ */ new WeakMap;target=null;sampledTop;constructor(e,t){this.following=e,this.threshold=t}static forElement(e){return this.owners.get(e)}bind(t){return e.owners.set(t,this),()=>{e.owners.get(t)===this&&e.owners.delete(t)}}get active(){return this.following}get animating(){return this.target!==null}nearBottom(e){return e.floor-e.top<=this.threshold}setFollowing(e){this.following=e,e||(this.target=null)}reset(){this.setFollowing(!1),this.sampledTop=void 0}sample(e,t=this.sampledTop===void 0||Math.abs(e.top-this.sampledTop)>.5){return this.sampledTop=e.top,!this.animating&&t&&(this.following=this.nearBottom(e)),this.active}settle(e){let t=this.target;return this.target=null,this.sample(e,t===null?void 0:Math.abs(e.top-Math.min(t,e.floor))>this.threshold)}jump(e,t,n){let r=this.animating;this.target=null;let i=Math.max(0,Math.min(t.floor,n));r?e.scrollTo({top:i,behavior:`instant`}):i!==t.top&&(e.scrollTop=i);let a={...t,top:e.scrollTop};return this.sampledTop=a.top,this.following=this.nearBottom(a),a}toBottom(e,t,n){return this.following=!0,n===`instant`||t.top>=t.floor||!this.animating&&this.nearBottom(t)||typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?this.jump(e,t,t.floor):(this.target===null&&(this.target=t.floor,e.scrollTo({top:t.floor,behavior:`smooth`})),t)}interrupt(e,t){this.animating&&(this.target=null,this.sampledTop=t.top,e.scrollTo({top:t.top,behavior:`instant`}))}};function Yh(e,t){let[n]=(0,d.useState)(()=>new Jh(e,t));return n}let Xh={canScrollUp:!1,canScrollDown:!1},Zh=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);function Qh(e,t,n,r){let i=Yh(!1,1),a=(0,d.useRef)(null),[o,s]=(0,d.useState)(Xh),c=(0,d.useCallback)(e=>{a.current=e},[]),l=(0,d.useCallback)(t=>{let n=e.current,r=Xh;if(n!==null&&n.closest(`[hidden], [data-group-expanded-mode]`)===null){let e=qh(n),o=t===`resize`?a.current:null;if(o!==null)e=i.jump(n,e,o===`bottom`?e.floor:0),o===`top`&&i.setFollowing(!1),a.current=null;else{let r=i.animating;t===`scrollend`?i.settle(e):i.sample(e),i.active&&(t===`resize`||t===`scrollend`&&r)&&(e=i.toBottom(n,e,`smooth`))}r={canScrollUp:e.top>1,canScrollDown:e.top<e.floor-1}}else i.reset();s(e=>e.canScrollUp===r.canScrollUp&&e.canScrollDown===r.canScrollDown?e:r)},[e,i]),u=(0,d.useCallback)(()=>{let t=e.current;t!==null&&i.animating&&i.interrupt(t,qh(t))},[e,i]),f=(0,d.useMemo)(()=>({onScroll:()=>{l(`scroll`)},onWheel:u,onTouchStart:u,onPointerDown:u,onKeyDown:e=>{!e.defaultPrevented&&Zh.has(e.key)&&u()}}),[u,l]);return(0,d.useLayoutEffect)(()=>{u(),i.reset(),(!r||!n)&&(a.current=null)},[i,r,u,n]),(0,d.useLayoutEffect)(()=>{let r=e.current;if(r===null||!n||typeof ResizeObserver>`u`)return;let a=i.bind(r),o=new ResizeObserver(()=>{l(`resize`)}),s=e=>{e.target===r&&l(`scrollend`)};return r.addEventListener(`scrollend`,s),o.observe(r),t.current!==null&&o.observe(t.current),()=>{a(),o.disconnect(),r.removeEventListener(`scrollend`,s)}},[e,t,i,n,l]),{edges:o,events:f,initialize:c}}let $h=`@deepseek-ai/dsh-client-ui-chat/ChatGroupSeat.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify($h)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=$h,e.textContent=`.M49uyW_root{min-width:0}.M49uyW_title{max-width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size,14px);text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:6px;padding:0;transition:color .1s;display:flex}@media (hover:hover){.M49uyW_title:hover{color:var(--dsw-alias-label-secondary)}}.M49uyW_title:active{color:var(--dsw-alias-label-secondary)}.M49uyW_leading{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));color:inherit;flex:none;justify-content:center;align-items:center;display:inline-flex;position:relative}.M49uyW_leading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}.M49uyW_leading svg[width="16"]{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px))}.M49uyW_activityIcon,.M49uyW_chevron{justify-content:center;align-items:center;transition:opacity .1s;display:inline-flex;position:absolute;inset:0}.M49uyW_activityIcon{opacity:1}.M49uyW_chevron{opacity:0}html:not([data-input-modality=pointer]) .M49uyW_title:focus-visible .M49uyW_activityIcon{opacity:0}html:not([data-input-modality=pointer]) .M49uyW_title:focus-visible .M49uyW_chevron{opacity:1}@media (hover:hover){.M49uyW_title:hover .M49uyW_activityIcon{opacity:0}.M49uyW_title:hover .M49uyW_chevron{opacity:1}}.M49uyW_title[aria-expanded=true] .M49uyW_activityIcon{opacity:0}.M49uyW_title[aria-expanded=true] .M49uyW_chevron{opacity:1}.M49uyW_title[aria-expanded=true]{padding-bottom:8px}.M49uyW_body{--dsh-chat-flow-gap:6px;overscroll-behavior-y:auto;scrollbar-gutter:stable;max-height:min(400px,50vh);overflow-y:auto}.M49uyW_label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.M49uyW_fadeTop{mask-image:linear-gradient(#0000 0,#000 24px 100%)}.M49uyW_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 24px),#0000 100%)}.M49uyW_fadeTop.M49uyW_fadeBottom{mask-image:linear-gradient(#0000 0,#000 24px calc(100% - 24px),#0000 100%)}@media (prefers-reduced-motion:reduce){.M49uyW_title,.M49uyW_activityIcon,.M49uyW_chevron{transition:none}}.M49uyW_content{flex-direction:column;display:flex}.M49uyW_content>*{flex-shrink:0}.M49uyW_content>:not([hidden]):not(:empty)~:not([hidden]):not(:empty){margin-top:var(--dsh-chat-flow-gap,6px)}.M49uyW_expandedBody{scrollbar-gutter:auto;max-height:none;overflow:visible}`,document.head.appendChild(e)}var eg={activityIcon:`M49uyW_activityIcon`,body:`M49uyW_body`,chevron:`M49uyW_chevron`,content:`M49uyW_content`,expandedBody:`M49uyW_expandedBody`,fadeBottom:`M49uyW_fadeBottom`,fadeTop:`M49uyW_fadeTop`,label:`M49uyW_label`,leading:`M49uyW_leading`,root:`M49uyW_root`,title:`M49uyW_title`};let tg={thinking:/* @__PURE__ */ (0,f.jsx)(p.IconThinkOutlineRegular,{}),read:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),readImage:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),search:/* @__PURE__ */ (0,f.jsx)(p.IconSearchOutlineRegular,{size:14}),edit:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{size:14}),write:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{size:14}),commands:/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{}),code:/* @__PURE__ */ (0,f.jsx)(p.IconCodeOutlineRegular,{size:14}),webSearch:/* @__PURE__ */ (0,f.jsx)(p.IconGlobeOutlineRegular,{}),webFetch:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),subagents:/* @__PURE__ */ (0,f.jsx)(p.IconAgentPresetOutlineRegular,{size:14}),plan:/* @__PURE__ */ (0,f.jsx)(p.IconPlanOutlineRegular,{}),questions:/* @__PURE__ */ (0,f.jsx)(p.IconQuestionOutlineRegular,{}),tools:/* @__PURE__ */ (0,f.jsx)(p.IconSparkleRegular,{size:14})};function ng(e,t){return e.activity===t.activity&&e.detail===t.detail&&e.preparing===t.preparing}function rg(e,t){let[n,r]=(0,d.useState)(e),i=(0,d.useRef)(n),a=(0,d.useRef)(e),o=(0,d.useRef)(Date.now());return(0,d.useEffect)(()=>{if(a.current=e,!t||ng(i.current,e))return;let n=150-(Date.now()-o.current),s=()=>{let e=a.current;i.current=e,o.current=Date.now(),r(e)};if(n<=0){s();return}let c=setTimeout(s,n);return()=>{clearTimeout(c)}},[t,e.activity,e.detail,e.preparing]),t?n:e}let ig=(0,d.memo)(function({members:e,...t}){return e.map(e=>/* @__PURE__ */ (0,d.createElement)(Ih,{...t,key:Uh(e),nodeKey:e.key,...e.groupPart===void 0?{}:{groupPart:e.groupPart}}))}),ag=(0,d.memo)(function({groupKey:e,useChatGroup:t,usePresentation:n,t:r,open:i,bodyId:a,toggle:o}){let s=t(e,e=>e?.data),c=n(e=>s?.closed===!1&&e.liveProcessDetail),l=rg({activity:s?.summary.running??`thinking`,detail:s?.summary.runningDetail??``,preparing:s?.summary.preparing===!0},s!==void 0&&!s.closed);if(s===void 0)return null;let u=s.closed?Wh(s.summary,r):l.preparing?r(`message.stepProcess.prepare.${l.activity===`thinking`?`tools`:l.activity}`):r(`message.stepProcess.${l.activity}`),d=c&&!s.closed?l.detail:``,m=d===``?u:`${u}${r(`message.turnProcess.separator`)}${d}`,h=s.closed?s.summary.counts[0]?.kind??`thinking`:l.activity;return/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:eg.title,"aria-expanded":i,"aria-controls":a,"data-process-activity":h,onClick:e=>{e.currentTarget.focus(),o()},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:eg.leading,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:eg.activityIcon,"data-step-process-icon":!0,children:tg[h]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:eg.chevron,"data-step-process-chevron":!0,children:i?/* @__PURE__ */ (0,f.jsx)(p.IconChevronUpOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{})})]}),/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:!s.closed,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{className:eg.label,children:m})})]})}),og=(0,d.memo)(function({groupKey:e,useChatGroup:t,...n}){let r=t(e,e=>e?.members),i=t(e,e=>e?.data.turn),a=t(e,e=>e?.data.closed),o=n.usePresentation(e=>e.foldCompletedTurns),{expanded:s,setExpanded:c}=Gh(),l=r?.[0]?.key??``,u=n.useChatNodeProcess(l),p=n.useChatNode(l,e=>{let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}),m=n.usePresentation(e=>e.stepGrouping===`collapsed`||e.stepGrouping===`history`&&p?.status!==`open`),h=p?.end?.data.reason.kind,g=u?.turnClosed===!1||u?.hasInterleavedInput===!0||p?.end?.data.finalAssistantStep===null||h===`aborted`||h===`error`,_=u?.spec,v=(0,d.useCallback)(e=>i===void 0?void 0:bh(e,i),[i]),y=n.useStore(v),b=o&&u?.turnClosed===!0&&_!==void 0&&!g&&y?.answerStep!==(_.answerStep??0),x=Eh(b,(0,d.useCallback)(()=>{_!==void 0&&!g&&n.actions.setTurnProcessOpen(_.turn,_.answerStep??0,!0)},[n.actions,_,g]));Th(x,r!==void 0),(0,d.useEffect)(()=>{b&&x.current?.hasAttribute(`hidden`)&&c(!1)},[b,x,c]);let S=(0,d.useCallback)(()=>{c(!0)},[c]),C=Eh(m&&!s,S),w=(0,d.useRef)(null),T=(0,d.useId)(),{edges:E,events:ee,initialize:D}=Qh(C,w,s,m),O=(0,d.useCallback)(()=>{s||D(a===!1?`bottom`:`top`),c(!s)},[a,D,s,c]);if(r===void 0)return null;let te=[eg.body,m?``:eg.expandedBody,m&&E.canScrollUp?eg.fadeTop:``,m&&E.canScrollDown?eg.fadeBottom:``];return/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:x,className:eg.root,"data-chat-group-key":e,"data-chat-flow-key":e,"data-chat-anchor-key":`group:${e}`,"data-chat-turn":i,"data-chat-paging-anchor":m&&!s||void 0,"data-step-process":!0,"data-group-expanded-mode":!m||void 0,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{hidden:!m,children:/* @__PURE__ */ (0,f.jsx)(ag,{groupKey:e,useChatGroup:t,usePresentation:n.usePresentation,t:n.t,open:s,bodyId:T,toggle:O})}),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:C,id:T,className:te.join(` `),"data-step-process-body":!0,"data-scroll-up":E.canScrollUp||void 0,"data-scroll-down":E.canScrollDown||void 0,...ee,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:w,className:eg.content,"data-step-process-content":!0,"data-chat-flow":``,children:/* @__PURE__ */ (0,f.jsx)(ig,{...n,members:r})})})]})});function sg(e){return typeof e==`object`?e.key:e}function cg(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function lg(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function ug(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}let dg=(e,t)=>Math.abs(e-t)<1.01,fg=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},pg,mg=()=>{if(pg!==void 0)return pg;if(typeof navigator>`u`)return pg=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return pg=!0;let e=navigator.maxTouchPoints;return pg=navigator.platform===`MacIntel`&&e!==void 0&&e>0},hg=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},gg=e=>e,_g=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},vg=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(hg(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(hg(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},yg={passive:!0},bg=typeof window>`u`||`onscrollend`in window,xg=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&bg,o=0,s=a?null:fg(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,yg),a&&r.addEventListener(`scrollend`,u,yg),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},Sg=(e,t)=>xg(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Cg=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},wg=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})};function Tg(e,t,n,r){if(t===0)return!1;let i=r(0),a=/* @__PURE__ */ new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var Eg=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=/* @__PURE__ */ new Map,this.itemSizeCacheVersion=0,this.laneAssignments=/* @__PURE__ */ new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=/* @__PURE__ */ new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=/* @__PURE__ */ (()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:gg,rangeExtractor:_g,onChange:()=>{},measureElement:Cg,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>sg(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||Tg(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:c}=this.options,l=0;for(;l<a&&c(l)!==e;)l++;if(l<a){let e=n[l];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=lg(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,mg()&&this.targetWindow!=null&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,yg),e.addEventListener(`touchend`,n,yg),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(mg()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this.scrollState?.behavior===`smooth`&&!dg(this.getScrollOffset()-i,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=lg(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=lg(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=cg(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=lg(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=kg(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=lg(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(!this.isIndexInRange(e))return;let n,r,i,a=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&a!=null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=this.itemSizeCache.get(i)??n,s=t-o;if(s!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,c=a?this.getTotalSize():0,l=this.getScrollOffset()+this.scrollAdjustments,u=this.itemSizeCache.has(i)?r+o<=l&&this.scrollDirection!==`backward`:r<l,d=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?u:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},s,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++;let f=!1;a?f=this.applyScrollAdjustment(this.getTotalSize()-c):d&&(f=this.applyScrollAdjustment(s)),this.notify(f),this._retryClampedAdjustment()}},this.getVirtualItems=lg(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return ug(t[Dg(0,t.length-1,r?e=>n[e*2]:e=>ug(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{this.options.count>0?this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e}):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){if(e===0)return!1;if(mg()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=e,!1;{let n=this.getScrollOffset()+this.scrollAdjustments+e,r=this.scrollElement,i=r!==null&&(`scrollHeight`in r||`document`in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=i!==null&&n>i+.5?{target:n,maxAtWrite:i}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&dg(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}};let Dg=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Og(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function kg(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=Og(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=Dg(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}let Ag=typeof document<`u`?d.useLayoutEffect:d.useEffect;function jg({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=d.useReducer(e=>e+1,0)[1],a=d.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:/* @__PURE__ */ new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=d.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=e=>{let t=a.current;if(!t.enabled||!t.container)return;s(e);let n=!!e.options.horizontal,r=t.mode===`transform`,i=n?`left`:`top`,o=e.options.scrollMargin,c=e.getVirtualItems();for(let a of c){let s=a.start-o,c=e.elementsCache.get(a.key);c&&t.lastPositions.get(c)!==s&&(t.lastPositions.set(c,s),r?c.style.transform=n?`translate3d(${s}px, 0, 0)`:`translate3d(0, ${s}px, 0)`:c.style[i]=`${s}px`)}},l={...r,onChange:(t,n)=>{var s;let l=a.current,u=!0;if(l.enabled){c(t);let e=t.range,n=l.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(l.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,h.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[u]=d.useState(()=>{let e=new Eg(l),t=e.measureElement;return e.measureElement=e=>{o.current=!0;try{t(e)}finally{o.current=!1}},Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return u.setOptions(l),Ag(()=>u._didMount(),[]),Ag(()=>(s(u),u._willUpdate())),Ag(()=>{c(u)}),u}function Mg(e){return jg({observeElementRect:vg,observeElementOffset:Sg,scrollToFn:wg,...e})}let Ng=`@deepseek-ai/dsh-client-ui-chat/TurnNavigator.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ng)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Ng,e.textContent=`.R6aBma_slot{z-index:7;height:0;padding-inline:calc(var(--dsh-composer-side-clearance) + 16px);pointer-events:none;position:absolute;top:0;left:0;right:0;container-type:inline-size}[data-conversation-scroll] .R6aBma_slot{position:sticky}.R6aBma_frame{--turn-rail-band:calc(var(--dsh-conversation-viewport-height,100dvh) - var(--dsh-composer-height,152px));--turn-preview-height:104px;top:calc(var(--turn-rail-band) / 2);width:36px;max-height:min(max(0px, calc(var(--turn-rail-band) - 64px)), 70vh, 640px);contain:layout;cursor:pointer;pointer-events:auto;position:absolute;left:12px;transform:translateY(-50%)}.R6aBma_frame[hidden]{display:none}.R6aBma_scroller{max-height:inherit;overscroll-behavior:contain;scrollbar-width:none;position:relative;overflow-y:auto}.R6aBma_scroller::-webkit-scrollbar{display:none}.R6aBma_fadeTop{mask-image:linear-gradient(#0000 0,#000 40px 100%)}.R6aBma_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 40px),#0000 100%)}.R6aBma_fadeTop.R6aBma_fadeBottom{mask-image:linear-gradient(#0000 0,#000 40px calc(100% - 40px),#0000 100%)}.R6aBma_marks{position:relative}.R6aBma_mark{cursor:pointer;background:0 0;border:0;border-radius:8px;height:10px;padding:0;position:absolute;top:0;left:0;right:0}.R6aBma_mark:before{background:var(--dsw-alias-label-tertiary);opacity:.4;content:"";transform-origin:0;width:26px;height:2px;transition:transform .16s cubic-bezier(.2,.8,.2,1),background-color .16s,opacity .16s;position:absolute;top:50%;left:0;transform:translateY(-50%)scaleX(.230769)}.R6aBma_markUnloaded:before{opacity:.25}.R6aBma_mark[data-neighbor-distance="3"]:before{transform:translateY(-50%)scaleX(.384615)}.R6aBma_mark[data-neighbor-distance="2"]:before{transform:translateY(-50%)scaleX(.538462)}.R6aBma_mark[data-neighbor-distance="1"]:before{transform:translateY(-50%)scaleX(.769231)}.R6aBma_markBusy:before{animation:1s ease-in-out infinite R6aBma_dsh-turn-mark-busy}.R6aBma_markActive:before{background:var(--dsw-alias-label-primary);opacity:.6}.R6aBma_frame[data-previewing] .R6aBma_markActive:not(.R6aBma_markPreview):not(:focus-visible):before{background:var(--dsw-alias-label-tertiary);opacity:.4}.R6aBma_markPreview:before{background:var(--dsw-alias-label-primary);opacity:1;transform:translateY(-50%)scaleX(1)}.R6aBma_frame[data-scrubbing] .R6aBma_mark:before{transition:none}.R6aBma_mark:focus-visible:before{background:var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));opacity:1;transform:translateY(-50%)scaleX(1)}.R6aBma_mark:focus-visible{outline:none}.R6aBma_mark:focus-visible:after{border-radius:inherit;outline:1px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-1px;content:"";width:28px;position:absolute;inset:0 auto 0 0}.R6aBma_preview{top:clamp(0px, calc(var(--turn-preview-center) - var(--turn-preview-height) / 2), calc(100% - var(--turn-preview-height)));box-sizing:border-box;width:min(320px,100cqw - 48px);max-height:var(--turn-preview-height);border:.5px solid var(--dsw-alias-border-l4);color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);box-shadow:var(--dsw-elevation-panel);pointer-events:none;border-radius:12px;padding:8px;transition:top .14s cubic-bezier(.2,.8,.2,1);animation:.12s ease-out R6aBma_dsh-turn-preview-enter;position:absolute;left:100%;overflow:hidden}.R6aBma_previewPrompt,.R6aBma_previewResponse{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.R6aBma_previewPrompt{-webkit-line-clamp:1;font-size:14px;font-weight:500;line-height:20px}.R6aBma_previewResponse{color:var(--dsw-alias-label-caption);-webkit-line-clamp:3;margin-top:4px;font-size:14px;line-height:20px}@keyframes R6aBma_dsh-turn-preview-enter{0%{opacity:0;transform:translate(-4px)}to{opacity:1;transform:translate(0)}}@keyframes R6aBma_dsh-turn-mark-busy{0%,to{opacity:1}50%{opacity:.35}}@media (prefers-reduced-motion:reduce){.R6aBma_frame,.R6aBma_scroller,.R6aBma_mark:before,.R6aBma_markBusy:before,.R6aBma_preview{scroll-behavior:auto;transition:none;animation:none}}`,document.head.appendChild(e)}var Pg={"dsh-turn-mark-busy":`R6aBma_dsh-turn-mark-busy`,"dsh-turn-preview-enter":`R6aBma_dsh-turn-preview-enter`,fadeBottom:`R6aBma_fadeBottom`,fadeTop:`R6aBma_fadeTop`,frame:`R6aBma_frame`,mark:`R6aBma_mark`,markActive:`R6aBma_markActive`,markBusy:`R6aBma_markBusy`,markPreview:`R6aBma_markPreview`,markUnloaded:`R6aBma_markUnloaded`,marks:`R6aBma_marks`,preview:`R6aBma_preview`,previewPrompt:`R6aBma_previewPrompt`,previewResponse:`R6aBma_previewResponse`,scroller:`R6aBma_scroller`,slot:`R6aBma_slot`};function Fg(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}let Ig=(0,d.memo)(function({item:e,index:t,active:n,busy:r,previewId:i,neighborDistance:a,registerElement:o,onNavigate:s,onPreview:c,onFocusChange:l,t:u}){let d=[Pg.mark];return e.anchor.kind===`unloaded`&&d.push(Pg.markUnloaded),n&&d.push(Pg.markActive),a===0&&d.push(Pg.markPreview),r&&d.push(Pg.markBusy),/* @__PURE__ */ (0,f.jsx)(`button`,{ref:o,"data-index":t,"data-neighbor-distance":a,type:`button`,className:d.join(` `),"aria-label":u(e.anchor.kind===`loaded`?`chat.turnNavigation.jump`:`chat.turnNavigation.jumpLoad`,{turn:t+1}),"aria-current":n?`true`:void 0,"aria-busy":r?`true`:void 0,"aria-describedby":i,onPointerMove:t=>{t.buttons===0&&c(e.turn)},onClick:()=>{s(e)},onFocus:()=>{l(e.turn)},onBlur:()=>{l(null)}})});function Lg({items:e,activeTurn:t,busyTurn:n,onNavigate:r,t:i},a){let[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(null),[u,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(!1),v=(0,d.useRef)(null),y=(0,d.useRef)(null),b=(0,d.useRef)(!1),x=(0,d.useRef)(void 0),S=(0,d.useRef)(null),C=(0,d.useRef)({placed:!1,index:0,follow:null,publishOffset:null}),w=(0,d.useRef)(!1),T=(0,d.useId)(),E=e.length>=2;(0,d.useLayoutEffect)(()=>{let e=v.current,t=e?.parentElement?.querySelector(`[data-chat-flow]`),n=e?.closest(`[data-conversation-scroll]`)??e?.parentElement;if(!t||!n)return;let r=()=>{let e=n.getBoundingClientRect(),r=n.offsetWidth>0?e.width/n.offsetWidth:1;h((t.getBoundingClientRect().left-e.left)/(r||1)>=48)},i=new ResizeObserver(r);return i.observe(t),i.observe(n),r(),()=>i.disconnect()},[E]),(0,d.useEffect)(()=>{if(o===null){p(!1);return}if(u)return;let e=setTimeout(()=>p(!0),150);return()=>clearTimeout(e)},[o,u]),(0,d.useEffect)(()=>()=>{clearTimeout(x.current);let e=y.current;y.current=null,e?.button.hasPointerCapture(e.pointerId)&&e.button.releasePointerCapture(e.pointerId)},[]);let ee=(0,d.useMemo)(()=>{let t=/* @__PURE__ */ new Map;return e.forEach((e,n)=>{t.set(e.turn,n)}),t},[e]),D=t===null?void 0:ee.get(t);(0,d.useLayoutEffect)(()=>{C.current.index=D??0},[D]);let O=c===null?void 0:ee.get(c),te=o===null?void 0:ee.get(o),ne=(0,d.useCallback)(e=>{l(e),s(e),p(e!==null)},[]),re=Mg({count:e.length,enabled:E,directDomUpdates:!0,directDomUpdatesMode:`transform`,useScrollendEvent:!0,getScrollElement:(0,d.useCallback)(()=>S.current,[]),getItemKey:(0,d.useCallback)(t=>e[t]?.turn??t,[e]),estimateSize:()=>10,measureElement:()=>10,initialRect:{width:0,height:0},initialOffset:0,scrollToFn:(e,t,n)=>{C.current.placed&&wg(e,t,n)},observeElementOffset:(e,t)=>{C.current.publishOffset=t;let n=Sg(e,t);return()=>{n?.(),C.current.placed=!1,C.current.follow=null,C.current.publishOffset=null}},observeElementRect:(e,t)=>{let n=e.scrollElement,r=e.targetWindow?.ResizeObserver;if(n===null||r===void 0)return;let i=new r(([r])=>{if(r===void 0)return;let i=r.borderBoxSize[0],a={width:Math.round(i?.inlineSize??r.contentRect.width),height:Math.round(i?.blockSize??r.contentRect.height)},o=C.current;if(!o.placed&&a.height>0){let t=Math.max(0,e.getTotalSize()-a.height),r=o.index*10+6,i=Math.max(0,Math.min(t,r-a.height/2));o.placed=!0,o.follow={index:o.index,count:e.options.count,height:a.height},n.scrollTop=i,o.publishOffset?.(i,!1)}t(a)});return i.observe(n,{box:`border-box`}),()=>{i.disconnect()}},paddingStart:1,paddingEnd:1,scrollPaddingStart:40,scrollPaddingEnd:40,overscan:3,rangeExtractor:(0,d.useCallback)(e=>{let t=_g(e);if(O!==void 0){let n=Math.min(e.count-1,O+1);for(let e=Math.max(0,O-1);e<=n;e++)t.includes(e)||t.push(e);t.sort((e,t)=>e-t)}return t},[O])}),ie=re.scrollOffset??0,ae=re.scrollRect?.height??0,oe=re.getVirtualItems(),k=(0,d.useCallback)((e,t,n=Fg())=>{let r=re.measurementsCache[e],i=re.scrollRect?.height??0;if(r===void 0||i<=0)return;let a=re.scrollOffset??0,o=r.start+r.size/2;if(t===`if-needed`){let{scrollPaddingStart:e,scrollPaddingEnd:t}=re.options;if(o>=a+e&&o<=a+i-t)return}let s=o-i/2,c=Math.max(0,re.getTotalSize()-i),l=Math.max(0,Math.min(c,s))-a;l!==0&&re.scrollBy(l,{behavior:n})},[re]);(0,d.useImperativeHandle)(a,()=>({activateTurn(t){let n=ee.get(t),i=n===void 0?void 0:e[n];i!==void 0&&r(i)},scrollToTurn(e){let t=ee.get(e);t!==void 0&&k(t,`always`)}}),[e,ee,r,k]),(0,d.useEffect)(()=>{if(ae<=0){C.current.follow=null;return}if(D===void 0||w.current)return;let t=C.current.follow;if(t?.index===D&&t.count===e.length&&t.height===ae)return;C.current.follow={index:D,count:e.length,height:ae};let n=t?.count===e.length&&t.height===ae?Fg():`instant`;k(D,`if-needed`,n)},[D,e.length,ae,k]);let se=(0,d.useCallback)(e=>{b.current?b.current=!1:r(e)},[r]),ce=t=>{if(t.button!==0||!(t.target instanceof Element))return;let n=t.target.closest(`button[data-index]`);if(!n||!S.current?.contains(n))return;let r=e[Number(n.dataset.index)];r&&(clearTimeout(x.current),b.current=!1,y.current={pointerId:t.pointerId,button:n,turn:r.turn,moved:!1},n.setPointerCapture(t.pointerId),_(!0),s(r.turn),p(!0))},le=t=>{let n=y.current,i=S.current;if(!n||!i||t.pointerId!==n.pointerId||!(t.buttons&1))return;let a=i.getBoundingClientRect(),o=Math.max(a.top,Math.min(t.clientY,a.bottom-1)),c=e[Math.max(0,Math.min(e.length-1,Math.round((o-a.top+i.scrollTop-6)/10)))];c&&c.turn!==n.turn&&(n.turn=c.turn,n.moved=!0,s(c.turn),c.anchor.kind===`loaded`&&r(c))},ue=e=>{let t=y.current;t&&e.pointerId===t.pointerId&&(y.current=null,_(!1),b.current=t.moved,t.button.hasPointerCapture(e.pointerId)&&t.button.releasePointerCapture(e.pointerId),x.current=setTimeout(()=>{b.current=!1},0),w.current||s(null))};if(!E)return null;let A=!u||te===void 0?void 0:e[te],de=oe.find(e=>e.index===te),fe=[Pg.scroller];return ie>1&&fe.push(Pg.fadeTop),ie<re.getTotalSize()-ae-1&&fe.push(Pg.fadeBottom),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:v,className:Pg.slot,children:/* @__PURE__ */ (0,f.jsxs)(`nav`,{className:Pg.frame,hidden:!m,"data-turn-navigation":``,"data-previewing":te!==void 0||void 0,"data-scrubbing":g||void 0,onPointerDownCapture:ce,onPointerMove:le,onPointerUpCapture:ue,onPointerCancelCapture:ue,onLostPointerCapture:ue,"aria-label":i(`chat.turnNavigation.label`),onPointerEnter:()=>{w.current=!0},onPointerLeave:()=>{w.current=!1,y.current||s(null)},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{ref:S,className:fe.join(` `),children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:re.containerRef,className:Pg.marks,children:oe.map(({index:r,key:a})=>{let c=e[r];return c===void 0?null:/* @__PURE__ */ (0,f.jsx)(Ig,{item:c,index:r,active:c.turn===t,busy:c.turn===n,previewId:u&&c.turn===o?T:void 0,neighborDistance:te!==void 0&&Math.abs(r-te)<=3?Math.abs(r-te):void 0,registerElement:re.measureElement,onNavigate:se,onPreview:s,onFocusChange:ne,t:i},a)})})}),A!==void 0&&de!==void 0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:T,role:`tooltip`,className:Pg.preview,style:{"--turn-preview-center":`${String(de.start+de.size/2-ie)}px`},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Pg.previewPrompt,children:A.prompt||i(`chat.turnNavigation.turn`,{turn:(te??0)+1})}),A.response!==``&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Pg.previewResponse,children:A.response})]})]})})}let Rg=(0,d.memo)((0,d.forwardRef)(Lg));function zg(){return/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mh.runningIcon,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mh.runningIconMotion,children:/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:`100%`,height:`100%`,viewBox:`2 2 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:1.2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M16.1 5.3C11.8 2.9 6.6 5 5.1 9.4c-1.8 5.4 1.7 10.2 6.9 10.3 4.8.2 8-3.8 7.2-8.3-.4 3.2-2 5.1-4.2 5.8`}),/* @__PURE__ */ (0,f.jsx)(`rect`,{x:`9.5`,y:`9.1`,width:`4.6`,height:`4.6`,rx:`1`,transform:`rotate(-10 11.8 11.4)`})]})})})}let Bg=`@deepseek-ai/dsh-client-ui-chat/accessibility.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Bg)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Bg,e.textContent=`.F76jpa_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var Vg={visuallyHidden:`F76jpa_visuallyHidden`};let Hg=(0,d.memo)(function({startTime:e,compacting:t,stale:n,t:r}){let[i,a]=(0,d.useState)(Date.now);(0,d.useEffect)(()=>{if(e===void 0||t||n)return;a(Date.now());let r=setInterval(()=>{a(Date.now())},1e3);return()=>{clearInterval(r)}},[e,t,n]);let o=n?r(`chat.statusUnconfirmed`):t?r(`message.compaction.running`):e===void 0?r(`chat.deepDiving`):r(`chat.deepDivingFor`,{duration:Lm(Math.max(1e3,i-e),r).map(e=>e.text).join(``)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Mh.running,"data-chat-running":!0,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Vg.visuallyHidden,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:r(n?`chat.statusUnconfirmed`:t?`message.compaction.running`:`chat.deepDiving`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mh.runningDivider,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Mh.runningContent,children:[n?null:/* @__PURE__ */ (0,f.jsx)(zg,{}),/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:!n,className:Mh.runningText,children:o})]})]})});function Ug(e){return e}function Wg(e){return e}function Gg(e){if(!Number.isSafeInteger(e)||e<0||Object.is(e,-0))throw TypeError(`SessionSeq must be a non-negative safe integer, got ${String(e)}`);return Wg(e)}let Kg=[];function qg(e){if(typeof e!=`object`||!e)return;let t=e;if(!(typeof t.turn!=`number`||!Number.isSafeInteger(t.turn)||t.turn<0)&&!(typeof t.seq!=`number`||!Number.isSafeInteger(t.seq)||t.seq<0||Object.is(t.seq,-0)))return{turn:t.turn,seq:Gg(t.seq),prompt:typeof t.prompt==`string`?t.prompt:``,response:typeof t.response==`string`?t.response:``}}function Jg(e){return Array.isArray(e)?e:Kg}function Yg(e,t){let n=/* @__PURE__ */ new Map;for(let e of Jg(t)){let t=qg(e);t!==void 0&&n.set(t.turn,{turn:t.turn,prompt:t.prompt,response:t.response,anchor:{kind:`unloaded`,seq:t.seq}})}for(let t of e){let e=n.get(t.turn);n.set(t.turn,{turn:t.turn,prompt:t.prompt===``?e?.prompt??``:t.prompt,response:t.response===``?e?.response??``:t.response,anchor:{kind:`loaded`,key:t.anchorKey}})}return n.size===0?Kg:[...n.values()].sort((e,t)=>e.turn-t.turn)}var Xg=class{viewport;reading;input;onBusyTurn;jump=null;settleFrame=null;requestedHead;constructor(e,t,n,r){this.viewport=e,this.reading=t,this.input=n,this.onBusyTurn=r}setInput(e){this.input=e}reset(){this.requestedHead=void 0,this.cancel()}dispose(){this.clearTask()}cancel(){this.clearTask(),this.onBusyTurn(null)}clearTask(){this.cancelFrame(),this.jump=null,this.viewport.stopPreserving()}navigateToTurn=e=>{if(e.anchor.kind===`loaded`){this.cancel();let t=this.viewport.scrollToTurn(e.turn);if(t===null)return;this.reading.acceptNavigation(t),this.input.loadingOlder&&this.viewport.beginPreserving(t.position);return}if(!this.input.historyReady)return;this.cancel(),this.viewport.beginPreserving(),this.reading.pauseFollowing();let t={turn:e.turn,seq:e.anchor.seq,phase:`loading`,landing:`pending`,repageHead:null};this.jump=t,this.onBusyTurn(t.turn),this.request(t)};autoLoadEarlier=()=>{if(this.jump!==null||this.input.olderFailed||this.requestedHead===this.input.firstSeq)return;let e=this.viewport.readScroll();e===null||e.metrics.top>240||this.loadEarlier()};loadEarlier=()=>{this.input.historyReady&&this.input.hasMore&&!this.input.loadingOlder&&(this.requestedHead=this.input.firstSeq,this.cancel(),this.viewport.beginPaging(),this.reading.pauseFollowing(),this.input.loadOlder())};readerSampled(e){e.movedByReader&&this.jump?.landing===`landed`&&(this.jump.landing=`interrupted`),(e.followingTail||e.movedByReader)&&this.viewport.stopPreserving()}contentCommitted(){if(!this.viewport.preserving||this.reading.pending)return!1;if(this.landJump(!1))return!0;let e=this.viewport.preserve();return e!==null&&(this.reading.preservePosition(e),!0)}readerSettled(){this.input.loadingOlder&&this.jump===null&&!this.viewport.preserving&&!this.reading.followingTail&&this.viewport.beginPreserving()}reconcile(){let e=this.jump;if(!this.input.historyReady||e===null||this.reading.pending)return;if(e.phase===`loading`){e.landing===`pending`&&this.landJump(!1);return}if(this.input.loadingOlder||this.landJump(!0))return;if((this.input.firstSeq===null||this.input.firstSeq>e.seq)&&this.input.hasMore&&e.repageHead!==this.input.firstSeq){e.repageHead=this.input.firstSeq,this.viewport.beginPreserving(),this.request(e);return}let t=this.viewport.scrollToTurnAtOrAfter(e.turn);this.cancel(),t!==null&&this.reading.acceptNavigation(t)}landJump(e){let t=this.jump;if(t===null)return!1;if(t.landing===`interrupted`)return e?(this.cancel(),!0):!1;let n=this.viewport.scrollToTurn(t.turn);return n!==null&&(this.reading.acceptNavigation(n),e?this.cancel():(this.viewport.beginPreserving(n.position),t.landing=`landed`),!0)}request(e){e.phase=`loading`;let t=()=>{this.jump===e&&(e.phase=`settled`,this.cancelFrame(),typeof requestAnimationFrame==`function`?this.settleFrame=requestAnimationFrame(()=>{this.settleFrame=null,this.jump===e&&this.reconcile()}):this.reconcile())};this.input.loadThrough(e.seq).then(t,t)}cancelFrame(){this.settleFrame!==null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.settleFrame),this.settleFrame=null}};function Zg(e,t,n){let[r,i]=(0,d.useState)(null),[a]=(0,d.useState)(()=>new Xg(e,t,n,i));return(0,d.useLayoutEffect)(()=>{a.setInput(n)},[a,n]),(0,d.useLayoutEffect)(()=>()=>{a.dispose()},[a]),{navigation:a,busyTurn:r}}var Qg=class{viewport;store;state;onChange;follow;sampleTimer=null;probeFrame=null;sampled=null;constructor(e,t,n,r,i){this.viewport=e,this.store=t,this.state=n,this.onChange=r,this.follow=i}get pending(){return this.sampleTimer!==null}get followingTail(){return this.state.followingTail}setStore(e){this.store=e}connect(e){return this.sampled=e,()=>{this.sampled===e&&(this.sampled=null)}}dispose(){this.cancelPending(),this.sampled=null}pauseFollowing(){this.cancelPending(),this.publish({...this.state,followingTail:!1})}followTail(){let e=this.viewport.scrollToBottom(this.follow);e!==null&&(this.cancelPending(),this.commit(e,!0,this.viewport.latestTurn))}restore(){let e=this.store.read();if(e===null){this.followTail();return}let t=this.viewport.restore(e);if(t===null)return;this.cancelPending();let n=this.follow.nearBottom(t.metrics);if(this.commit(t,n,n?this.viewport.latestTurn:this.state.activeTurn,n),!this.state.followingTail&&t.position===null){let e=this.viewport.capturePosition();e!==null&&this.store.save(e)}this.refreshActiveTurn()}acceptNavigation(e){this.cancelPending();let t=this.follow.nearBottom(e.metrics);this.commit(e,t,e.turn??(t?this.viewport.latestTurn:this.state.activeTurn))}preservePosition(e){this.cancelPending(),this.commit(e,this.state.followingTail,this.state.activeTurn)}onScroll=e=>{!e.movedByReader&&this.state.followingTail||e.movedByReader&&e.metrics.top>=e.metrics.floor?(this.followTail(),this.sampled?.({position:null,movedByReader:e.movedByReader,followingTail:!0})):this.sampleTimer??=window.setTimeout(this.flushSample,500)};onScrollEnd=()=>{this.flushSample()};onResize(){this.pending||(this.state.followingTail?this.followTail():this.refreshActiveTurn())}refreshActiveTurn(){this.pending||(this.state.followingTail?this.publish({...this.state,initialized:!0,activeTurn:this.viewport.latestTurn}):this.probeFrame===null&&(typeof requestAnimationFrame==`function`?this.probeFrame=requestAnimationFrame(this.probe):this.probe()))}commit(e,t,n,r=!0){t?this.store.save(null):e.position!==null&&this.store.save(e.position),this.publish({initialized:r,followingTail:t,activeTurn:n})}publish(e){this.follow.setFollowing(e.followingTail),(e.initialized!==this.state.initialized||e.followingTail!==this.state.followingTail||e.activeTurn!==this.state.activeTurn)&&(this.state=e,this.onChange(e))}cancelPending(){this.sampleTimer!==null&&window.clearTimeout(this.sampleTimer),this.probeFrame!==null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.probeFrame),this.sampleTimer=null,this.probeFrame=null}probe=()=>{if(this.probeFrame=null,this.pending)return;let e=this.viewport.readScroll();if(e===null)return;let t=this.follow.nearBottom(e.metrics)?this.viewport.latestTurn:this.viewport.readVisibleTurn(e.metrics);this.publish({...this.state,initialized:!0,activeTurn:t})};flushSample=()=>{if(!this.pending)return;this.cancelPending();let e=this.viewport.readScroll();if(e===null)return;let t=this.follow.sample(e.metrics,e.movedByReader),n=null;if(!e.movedByReader&&t)this.followTail();else{n=t?null:this.viewport.capturePosition(),this.viewport.acknowledge(e.metrics),(t||n!==null)&&this.store.save(n);let r=this.follow.nearBottom(e.metrics)?this.viewport.latestTurn:this.viewport.readVisibleTurn(e.metrics);this.publish({initialized:!0,followingTail:t,activeTurn:r})}this.sampled?.({position:n,movedByReader:e.movedByReader,followingTail:t})}};function $g(e,t,n){let[r,i]=(0,d.useState)(()=>({initialized:!1,followingTail:t.read()===null,activeTurn:n})),a=Yh(r.followingTail,25),[o]=(0,d.useState)(()=>new Qg(e,t,r,i,a));return(0,d.useLayoutEffect)(()=>{o.setStore(t)},[o,t]),(0,d.useLayoutEffect)(()=>()=>{o.dispose()},[o]),{reading:o,state:r}}let e_=[`[data-code-block-controls]`,`[data-selection-actions]`,`[contenteditable='true']`,`textarea`].join(`,`),t_=/* @__PURE__ */ new Set([`BLOCKQUOTE`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`P`,`PRE`]);function n_(e){let t=e.startContainer.ownerDocument;if(t===null)return``;let n=t.createElement(`div`);n.append(e.cloneContents());for(let e of n.querySelectorAll(e_))e.remove();for(let e of n.querySelectorAll(`ol, ul`))e.replaceWith(`
|
|
123
|
-
`,...Array.from(e.childNodes));let r=e.commonAncestorContainer;return
|
|
124
|
-
`;case`TABLE`:return`${Array.from(n.querySelectorAll(`tr`)).map(
|
|
125
|
-
`)}\n`;case`TD`:case`TH`:return`${n.previousElementSibling?.matches(`td, th`)?` `:``}${
|
|
126
|
-
`:``}${s_(e)}\n`}let d_=[`wheel`,`touchstart`,`touchmove`,`touchend`,`touchcancel`,`pointerdown`,`keydown`,`beforematch`],f_=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);var p_=class{elements=null;observer=null;events=null;turns=[];observation={top:0,landing:null};paging=null;touchY=null;attach(e,t){this.detach();let n=e.closest(`[data-conversation-scroll]`)??e,r=n.querySelector(`[data-composer-seat]`),i={list:e,column:t,scroller:n,composer:r};this.elements=i,n.addEventListener(`scroll`,this.onScroll,{passive:!0}),n.addEventListener(`scrollend`,this.onScrollEnd,{passive:!0,capture:!0});for(let e of d_)n.addEventListener(e,this.onIntent,{passive:!0,capture:!0});typeof ResizeObserver<`u`&&(this.observer=new ResizeObserver(()=>{this.elements===i&&(this.invalidate(),this.events?.resize())}),this.observer.observe(t),this.observer.observe(n),r!==null&&this.observer.observe(r))}detach(){this.stopPreserving(),this.elements?.scroller.removeEventListener(`scroll`,this.onScroll),this.elements?.scroller.removeEventListener(`scrollend`,this.onScrollEnd,!0);for(let e of d_)this.elements?.scroller.removeEventListener(e,this.onIntent,!0);this.observer?.disconnect(),this.observer=null,this.elements=null,this.events=null,this.turns=[],this.touchY=null,this.observation={top:0,landing:null}}connect(e){return this.events=e,()=>{this.events===e&&(this.events=null)}}updateTurns(e){this.turns=e}get latestTurn(){return this.turns.at(-1)?.turn??null}invalidate(){this.observation.landing=null}acknowledge(e){this.observation={top:e.top,landing:null}}readScroll(){let e=this.metrics();return e===null?null:{metrics:e,movedByReader:Math.abs(e.top-Math.min(this.observation.top,e.floor))>.5,towardStart:e.top<Math.min(this.observation.top,e.floor)-.5}}metrics(){let e=this.elements?.scroller;return e===void 0?null:qh(e)}anchor(e,t=`position`){if(this.elements===null)return null;let n=null;for(let r of this.elements.list.querySelectorAll(`[data-chat-anchor-key]:not([hidden]):not([hidden] *)`)){if(r.dataset.chatAnchorKey===e||t===`node`&&r.dataset.chatNodeKey===e)return r;n===null&&r.dataset.chatNodeKey===e&&(n=r)}return n}capturePosition(){let e=this.elements;if(e===null)return null;let{list:t,scroller:n,composer:r}=e,i=n.getBoundingClientRect(),a=r?.getBoundingClientRect().top??i.bottom,o=null;if(typeof document.elementsFromPoint==`function`&&a>i.top){let e=t.getBoundingClientRect(),n=Math.max(i.left,e.left),r=Math.min(i.right,e.right);for(let e of document.elementsFromPoint(n+Math.max(0,r-n)/2,i.top+1)){let n=e instanceof HTMLElement?e.closest(`[data-chat-anchor-key]`):null;if(n!==null&&n.dataset.chatFlowKind!==`turn-process`&&t.contains(n)){o=n.dataset.chatGroupKey===void 0?n:n.querySelector(`[data-step-process-content] > [data-chat-anchor-key]:not(:empty):not([hidden]):not([hidden] *)`)??n;break}}}if(o===null){let e=t.querySelectorAll(`[data-chat-flow-key]:not([data-chat-group-key]):not([data-chat-flow-kind="turn-process"]):not(:empty):not([hidden]):not([hidden] *)`),n=0,r=e.length;for(;n<r;){let t=n+r>>>1;e.item(t).getBoundingClientRect().bottom>i.top?r=t:n=t+1}let s=e[n];o=s!==void 0&&s.getBoundingClientRect().top<a?s:e[0]??null}let s=o?.dataset.chatAnchorKey;return o===null||s===void 0?null:{anchorKey:s,anchorTop:o.getBoundingClientRect().top-i.top,scrollTop:n.scrollTop}}readVisibleTurn(e=this.metrics()){let t=this.observation.landing?.turn;if(t!=null&&e?.top===this.observation.top)return t;let n=this.elements,r=this.turns[0];if(n===null||e===null||r===void 0)return null;let i=n.scroller.getBoundingClientRect().top+Math.min(96,e.height*.2),a=n.column.children,o=0,s=a.length,c=r.turn;for(;o<s;){let e=o+s>>>1,t=a[e];if(t.getBoundingClientRect().top>i)s=e;else{let n=t.getAttribute(`data-chat-turn`),r=n===null?NaN:Number(n);Number.isSafeInteger(r)&&(c=r),o=e+1}}return c}scrollToTurn(e){let t=this.turns.find(t=>t.turn===e);if(t===void 0)return null;let n=this.anchor(t.anchorKey,`node`);return n===null?null:this.align(n,24,e)}scrollToTurnAtOrAfter(e){if(this.elements===null)return null;for(let t of this.elements.list.querySelectorAll(`[data-chat-turn]:not([hidden]):not([hidden] *)`)){let n=Number(t.dataset.chatTurn);if(Number.isSafeInteger(n)&&n>=e)return this.align(t,24,n)}return null}scrollToResponseAnnotation(e){let t=this.elements,n=e.anchor;if(t===null||n===void 0)return null;let r=a_(t.column,n,e.text);if(r===void 0)return null;let i=Array.from(r.range.getClientRects()).find(e=>e.width!==0||e.height!==0)??(()=>{let e=r.range.getBoundingClientRect();return e.width===0&&e.height===0?void 0:e})(),a=this.metrics();if(i===void 0||a===null)return null;let o=t.scroller.getBoundingClientRect().top,s=r.host.closest(`[data-chat-anchor-key]`),c=r.host.closest(`[data-chat-turn]`)?.getAttribute(`data-chat-turn`),l=c==null?NaN:Number(c),u=Number.isSafeInteger(l)?l:null,d=a.top+i.top-o-a.height*.3;return s===null?this.write(d,a,u):this.write(d,a,u,{key:s.getAttribute(`data-chat-anchor-key`)??void 0,top:s.getBoundingClientRect().top-o})}restore(e){let t=this.anchor(e.anchorKey);if(t!==null)return this.align(t,e.anchorTop,null);let n=this.metrics();return n===null?null:this.write(e.scrollTop,n,null)}beginPaging(){this.stopPreserving();let e=this.elements?.list.querySelector(`[data-chat-paging-anchor]:not(:empty):not([hidden]):not([hidden] *)`);e!=null&&this.retain(e)}beginPreserving(e=this.capturePosition()){if(this.stopPreserving(),e===null)return;let t=this.anchor(e.anchorKey);t!==null&&this.retain(t,e)}retain(e,t,n){let r=this.elements,i=e.dataset.chatAnchorKey;if(r===null||i===void 0)return null;let a=this.paging?.group;a!=null&&this.observer?.unobserve(a.content);let o=e.getBoundingClientRect().top,s=e.closest(`[data-step-process-body]`),c=s?.querySelector(`[data-step-process-content]`),l=s===null||c==null?null:{body:s,content:c,top:n??o-s.getBoundingClientRect().top};return this.paging={row:e,group:l,position:t??{anchorKey:i,anchorTop:o-r.scroller.getBoundingClientRect().top,scrollTop:r.scroller.scrollTop}},l!==null&&this.observer?.observe(l.content),this.paging}stopPreserving(){let e=this.paging?.group;e!=null&&this.observer?.unobserve(e.content),this.paging=null}get preserving(){return this.paging!==null}preserve(){let e=this.paging,t=this.elements;if(e===null||t===null)return null;if(!t.list.contains(e.row)){let t=this.anchor(e.position.anchorKey);if(t===null)return this.stopPreserving(),null;if(e=this.retain(t,e.position,e.group?.top),e===null)return null}let{row:n,group:r,position:i}=e;if(n.closest(`[hidden]`)!==null||n.matches(`:empty`))return this.stopPreserving(),null;if(r!==null&&r.body.contains(n)){let e=n.getBoundingClientRect().top-r.body.getBoundingClientRect().top,t=qh(r.body),i=Math.max(0,Math.min(t.floor,t.top+e-r.top));if(t.top!==i){let e=Jh.forElement(r.body);e===void 0?r.body.scrollTop=i:(e.jump(r.body,t,i),e.setFollowing(!1))}}let a=this.metrics();if(a===null)return null;let o=n.getBoundingClientRect().top-t.scroller.getBoundingClientRect().top,s=a.top+o-i.anchorTop;return this.write(s,a,null,{key:i.anchorKey,top:o})}scrollToBottom(e){let t=this.metrics();if(t===null||this.elements===null)return null;let n={metrics:t.top>t.floor?t:e.toBottom(this.elements.scroller,t,`instant`),position:null,turn:this.latestTurn};return this.observation={top:n.metrics.top,landing:n},n}align(e,t,n){let r=this.metrics();if(r===null||this.elements===null)return null;let i=e.getBoundingClientRect().top-this.elements.scroller.getBoundingClientRect().top;return this.write(r.top+i-t,r,n,{key:e.dataset.chatAnchorKey,top:i})}write(e,t,n,r){if(this.elements===null)return null;let i=Math.max(0,Math.min(t.floor,e));i!==t.top&&(this.elements.scroller.scrollTop=i);let a=this.elements.scroller.scrollTop,o={metrics:{...t,top:a},turn:n,position:r?.key===void 0?null:{anchorKey:r.key,anchorTop:r.top-(a-t.top),scrollTop:a}};return this.observation={top:a,landing:o},o}onScroll=e=>{if(this.elements===null||e.target!==this.elements.scroller||this.observation.landing!==null&&this.elements.scroller.scrollTop===this.observation.top)return;this.invalidate();let t=this.readScroll();t!==null&&this.events?.scroll(t)};onScrollEnd=e=>{(e.target===this.elements?.scroller||e.target instanceof HTMLElement&&e.target.hasAttribute(`data-step-process-body`))&&this.events?.scrollEnd()};onIntent=e=>{if(e.type===`touchend`||e.type===`touchcancel`){this.touchY=null;return}if(e.target instanceof Element&&e.target.closest(`[data-composer-seat], [data-turn-navigation], input, textarea, [contenteditable="true"]`)||e.type===`keydown`&&(!(e instanceof KeyboardEvent)||!f_.has(e.key)))return;let t=e instanceof WheelEvent?e.deltaY<0:e instanceof KeyboardEvent&&([`ArrowUp`,`PageUp`,`Home`].includes(e.key)||e.key===` `&&e.shiftKey);if(typeof TouchEvent<`u`&&e instanceof TouchEvent){let n=e.touches[0]?.clientY;if(t=e.type===`touchmove`&&n!==void 0&&this.touchY!==null&&n>this.touchY,this.touchY=n??null,e.type===`touchstart`)return}if(!(e instanceof PointerEvent&&e.pointerType===`touch`)){if(t&&e.target instanceof Element){for(let n=e.target;n&&n!==this.elements?.scroller;n=n.parentElement)if(n instanceof HTMLElement&&n.scrollTop>0&&n.scrollHeight>n.clientHeight&&/auto|scroll/.test(getComputedStyle(n).overflowY)){t=!1;break}}this.paging!==null&&!(t&&this.observation.top<=0&&(this.elements?.scroller.scrollTop??0)<=0)&&(this.stopPreserving(),this.events?.interact()),t&&this.events?.olderIntent()}}};function m_(){let e=(0,d.useRef)(null),t=(0,d.useRef)(null),[n]=(0,d.useState)(()=>new p_);return(0,d.useLayoutEffect)(()=>{if(e.current!==null&&t.current!==null)return n.attach(e.current,t.current),()=>{n.detach()}},[n]),{viewport:n,listRef:e,columnRef:t}}function h_(e){let{displayReady:t,historyReady:n,order:r,firstSeq:i,lastKey:a,lastIsUser:o,steeringId:s,submissionId:c,running:l,loadedTurns:u,chatScroll:f,hasMore:p,loadingOlder:m,olderFailed:h,loadOlder:g,loadThrough:_}=e,{viewport:v,listRef:y,columnRef:b}=m_(),{reading:x,state:S}=$g(v,f,u.at(-1)?.turn??null),C=(0,d.useMemo)(()=>({historyReady:n,firstSeq:i,loadingOlder:m,olderFailed:h,hasMore:p,loadOlder:g,loadThrough:_}),[n,i,m,h,p,g,_]),{navigation:w,busyTurn:T}=Zg(v,x,C),E=(0,d.useRef)({input:e,applied:null,opened:!1}),ee=(0,d.useCallback)(()=>{let e=E.current.input,t=E.current.applied,n=e.lastIsUser&&e.lastKey!==t?.lastKey||e.steeringId!==null&&e.steeringId!==t?.steeringId&&e.steeringId!==t?.submissionId||e.submissionId!==null&&e.submissionId!==t?.submissionId&&e.submissionId!==t?.steeringId;(!x.pending||n)&&(E.current.applied=e,e.displayReady&&!E.current.opened?(E.current.opened=!0,w.reset(),x.restore()):n?(w.cancel(),x.followTail()):w.contentCommitted()?w.reconcile():(t===null||e.displayReady!==t.displayReady||e.firstSeq!==t.firstSeq||e.lastKey!==t.lastKey||e.order.length!==t.order.length||e.running!==t.running||e.steeringId!==t.steeringId||e.submissionId!==t.submissionId)&&x.followingTail?(w.cancel(),x.followTail()):w.reconcile())},[x,w]);(0,d.useLayoutEffect)(()=>{let e=null,t=()=>{e===null&&E.current.opened&&E.current.input.historyReady&&(e=requestAnimationFrame(()=>{e=null,E.current.opened&&E.current.input.historyReady&&w.autoLoadEarlier()}))},n=v.connect({scroll:e=>{x.onScroll(e),e.movedByReader&&e.towardStart&&t()},olderIntent:t,scrollEnd:()=>{x.onScrollEnd(),w.readerSettled()},interact:()=>{w.cancel()},resize:()=>{w.contentCommitted()||x.onResize(),w.reconcile()}}),r=x.connect(e=>{w.readerSampled(e),ee()});return()=>{e!==null&&cancelAnimationFrame(e),n(),r(),E.current.opened=!1,E.current.applied=null}},[v,x,w,ee]),(0,d.useLayoutEffect)(()=>{let e=E.current.input;E.current.input={displayReady:t,order:r,lastKey:a,lastIsUser:o,steeringId:s,submissionId:c,running:l,loadedTurns:u,chatScroll:f,...C},v.updateTurns(u);let n=e.order!==r||e.displayReady!==t;n&&v.invalidate(),ee(),n&&x.refreshActiveTurn()},[v,x,ee,C,t,r,a,o,s,c,l,u,f]);let D=(0,d.useCallback)(()=>{w.cancel(),x.followTail()},[w,x]),O=(0,d.useCallback)(e=>{w.cancel();let t=v.scrollToResponseAnnotation(e);t!==null&&(x.acceptNavigation(t),E.current.input.loadingOlder&&v.beginPreserving(t.position))},[w,x,v]);return{listRef:y,columnRef:b,...S,busyTurn:T,navigateToTurn:w.navigateToTurn,revealResponseAnnotation:O,loadEarlier:w.loadEarlier,returnToBottom:D}}function g_(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=g_(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function __(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=g_(e))&&(r&&(r+=` `),r+=t);return r}let v_=`@deepseek-ai/dsh-client-ui-chat/SelectionActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(v_)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=v_,e.textContent=`._4l2sSq_popover{z-index:30;background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground);border:.5px solid color-mix(in srgb, var(--dsw-alias-label-primary-foreground) 16%, transparent);box-shadow:var(--dsw-shadow-lv3);border-radius:9999px;padding:2px;animation:.14s cubic-bezier(.175,.885,.32,1.275) _4l2sSq_selection-island-in;display:flex;position:fixed;overflow:hidden}._4l2sSq_action{height:24px;color:inherit;font-family:var(--dsw-font-family);letter-spacing:-.01em;white-space:nowrap;cursor:pointer;background:0 0;border:none;border-radius:9999px;align-items:center;gap:5px;padding:0 10px;font-size:12px;font-weight:500;transition:background-color .12s,transform .12s cubic-bezier(.175,.885,.32,1.275);display:inline-flex}._4l2sSq_action+._4l2sSq_action{margin-left:1px;position:relative}._4l2sSq_action+._4l2sSq_action:before{content:"";background:color-mix(in srgb, currentColor 24%, transparent);width:1px;position:absolute;top:5px;bottom:5px;left:-1px}._4l2sSq_action svg{color:currentColor;flex-shrink:0}._4l2sSq_action:hover{background:color-mix(in srgb, currentColor 14%, transparent)}._4l2sSq_action:active{background:color-mix(in srgb, currentColor 22%, transparent);transform:scale(.96)}._4l2sSq_answer{position:relative}::highlight(codexhost-response-annotation){background-color:color-mix(in srgb, var(--dsw-alias-state-business-primary) 16%, transparent);text-decoration:underline color-mix(in srgb, var(--dsw-alias-state-business-primary) 65%, transparent)}::highlight(codexhost-response-annotation-hover){background-color:color-mix(in srgb, var(--dsw-alias-state-business-primary) 30%, transparent);text-decoration:underline var(--dsw-alias-state-business-primary)}._4l2sSq_annotationMark{z-index:1;user-select:none;position:absolute;inset-inline-start:100%}._4l2sSq_annotationMark button{justify-content:center;width:24px;height:24px}._4l2sSq_annotationNumber{box-sizing:border-box;background:color-mix(in srgb, var(--dsw-alias-state-business-primary) 14%, var(--dsw-alias-bg-base));min-width:18px;min-height:18px;color:var(--dsw-alias-state-business-primary);font-variant-numeric:tabular-nums;border-radius:999px;place-items:center;padding:0 5px;font-size:10.5px;font-weight:600;line-height:1;transition:background-color .12s,transform .12s;display:inline-grid}._4l2sSq_annotationNumberHovered{background:color-mix(in srgb, var(--dsw-alias-state-business-primary) 28%, var(--dsw-alias-bg-base));transform:scale(1.1)}@keyframes _4l2sSq_selection-island-in{0%{opacity:0;scale:.9}to{opacity:1;scale:1}}@media (prefers-reduced-motion:reduce){._4l2sSq_popover{animation:none}._4l2sSq_action,._4l2sSq_annotationNumber{transition:none}}`,document.head.appendChild(e)}var y_={action:`_4l2sSq_action`,annotationMark:`_4l2sSq_annotationMark`,annotationNumber:`_4l2sSq_annotationNumber`,annotationNumberHovered:`_4l2sSq_annotationNumberHovered`,answer:`_4l2sSq_answer`,popover:`_4l2sSq_popover`,"selection-island-in":`_4l2sSq_selection-island-in`};let b_=`codexhost-response-annotation`;function x_(e){let t=e.getClientRects();for(let e=t.length-1;e>=0;--e){let n=t[e];if(n!==void 0&&(n.width!==0||n.height!==0))return n}let n=e.getBoundingClientRect();return n.width===0&&n.height===0?void 0:n}function S_(e,t=b_,n=0){let r=globalThis.CSS?.highlights;if(e.length===0||r===void 0||typeof Highlight>`u`)return()=>{};let i=r.get(t)??new Highlight;i.priority=n;for(let t of e)i.add(t);return r.set(t,i),()=>{for(let t of e)i.delete(t);i.size===0&&r.get(t)===i&&r.delete(t)}}let C_=[];function w_({answer:e,answerKey:t,useInput:n,inputActions:r,labels:i}){let a=n(e=>e.responseAnnotations),o=n(e=>{let n=e.hoveredResponseAnnotationId;if(n!==void 0)return e.responseAnnotations?.some(e=>e.id===n&&e.anchor?.answerKey===t)?n:void 0}),s=(0,d.useMemo)(()=>a?.flatMap((e,n)=>e.anchor?.answerKey===t?[{annotation:e,index:n+1}]:[]),[a,t]),[c,l]=(0,d.useState)(C_),u=(0,d.useRef)([]),[m,h]=(0,d.useState)(0),g=(0,d.useRef)(null),_=(0,d.useRef)(r);return _.current=r,(0,d.useEffect)(()=>()=>{g.current!==null&&(g.current=null,_.current?.hoverResponseAnnotation(null))},[]),(0,d.useLayoutEffect)(()=>{let t=e.current;if(t===null||s===void 0||s.length===0){u.current=[],l(C_),h(e=>e+1);return}let n=()=>{},r=()=>{if(!t.isConnected)return;let e=t.getBoundingClientRect().top,n=u.current.flatMap(({annotation:t,index:n,range:r})=>{let i=x_(r);return i===void 0?[]:[{annotation:t,index:n,top:i.top-e+(i.height-24)/2}]});n.sort((e,t)=>e.top-t.top);let r=0,i=n.length===0?C_:n.map(e=>{let t=Math.max(e.top,r);return r=t+24+2,{...e,top:t}});l(e=>e.length===i.length&&e.every((e,t)=>e.annotation===i[t]?.annotation&&e.index===i[t]?.index&&Math.abs(e.top-(i[t]?.top??0))<.5)?e:i)},i=()=>{n(),n=()=>{},t.isConnected?(u.current=s.flatMap(e=>{let{anchor:n,text:r}=e.annotation,i=n&&i_(t,n,r);return i===void 0?[]:[{...e,range:i}]}),n=S_(u.current.map(({range:e})=>e),b_),h(e=>e+1),r()):(u.current=[],l(C_),h(e=>e+1))};i();let a=typeof ResizeObserver>`u`?null:new ResizeObserver(r);a?.observe(t);let o=typeof MutationObserver>`u`?null:new MutationObserver(i),c=t.firstElementChild;return c!==null&&!c.hasAttribute(`data-selection-actions`)&&o?.observe(c,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`,`open`]}),t.addEventListener(`scroll`,r,!0),()=>{n(),n=()=>{},u.current=[],a?.disconnect(),o?.disconnect(),t.removeEventListener(`scroll`,r,!0)}},[e,s]),(0,d.useLayoutEffect)(()=>{if(o!==void 0)return S_(u.current.filter(({annotation:e})=>e.id===o).map(({range:e})=>e),`codexhost-response-annotation-hover`,1)},[o,m]),c.map(({annotation:e,index:t,top:n})=>{let a=o===e.id;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:y_.annotationMark,style:{top:n},"data-selection-actions":!0,onPointerEnter:t=>{t.pointerType!==`touch`&&(g.current=e.id,r?.hoverResponseAnnotation(e.id))},onPointerLeave:t=>{t.pointerType!==`touch`&&(g.current===e.id&&(g.current=null),r?.hoverResponseAnnotation(null))},onFocus:t=>{t.target instanceof Element&&t.target.matches(`:focus-visible`)&&(g.current=e.id,r?.hoverResponseAnnotation(e.id))},onBlur:t=>{!t.currentTarget.contains(t.relatedTarget)&&o===e.id&&(g.current===e.id&&(g.current=null),r?.hoverResponseAnnotation(null))},children:/* @__PURE__ */ (0,f.jsx)(p.ResponseAnnotationPopover,{annotation:e,labels:i,title:i.label(t),anchor:/* @__PURE__ */ (0,f.jsx)(`span`,{className:__(y_.annotationNumber,a&&y_.annotationNumberHovered),"data-hovered":a||void 0,"aria-label":i.label(t),children:t})})},e.id)})}let T_=`@deepseek-ai/dsh-client-ui-chat/SelectionCommentCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(T_)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=T_,e.textContent=`.lPRhsq_card{z-index:30;box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-specific-input-major);width:344px;box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);border-radius:16px;flex-direction:column;gap:8px;padding:12px;animation:.14s cubic-bezier(.175,.885,.32,1.275) lPRhsq_selection-comment-in;display:flex;position:fixed}.lPRhsq_header{align-items:flex-start;gap:8px;display:flex}.lPRhsq_excerpt{border-left:2px solid var(--dsw-alias-border-l3);min-width:0;color:var(--dsw-alias-label-tertiary);-webkit-line-clamp:2;overflow-wrap:anywhere;-webkit-box-orient:vertical;flex:auto;margin:0;padding-left:9px;font-size:12px;line-height:17px;display:-webkit-box;overflow:hidden}.lPRhsq_close{width:22px;height:22px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:0;border-radius:6px;flex:none;place-items:center;margin:-3px -4px 0 0;padding:0;transition:background-color .11s,color .11s;display:inline-grid}@media (hover:hover) and (pointer:fine){.lPRhsq_close:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}}.lPRhsq_close:focus-visible{outline:1.5px solid var(--dsw-alias-state-business-primary);outline-offset:0}.lPRhsq_inputRow{align-items:flex-end;gap:8px;display:flex}.lPRhsq_field{box-sizing:border-box;field-sizing:content;min-width:0;min-height:28px;max-height:116px;color:var(--dsw-alias-label-primary);font:inherit;resize:none;background:0 0;border:0;outline:none;flex:auto;padding:4px 0;font-size:13px;line-height:19px}.lPRhsq_field::placeholder{color:var(--dsw-alias-label-tertiary)}.lPRhsq_submit{background:var(--dsw-alias-button-primary-fill);height:28px;color:var(--dsw-alias-label-primary-foreground);font:inherit;white-space:nowrap;cursor:pointer;touch-action:manipulation;user-select:none;-webkit-tap-highlight-color:transparent;border:0;border-radius:9999px;flex:none;justify-content:center;align-items:center;gap:5px;padding:0 12px;font-size:12px;font-weight:500;line-height:16px;transition:background-color .12s,opacity .12s,transform .12s cubic-bezier(.175,.885,.32,1.275);display:inline-flex}@media (hover:hover) and (pointer:fine){.lPRhsq_submit:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}}.lPRhsq_submit:disabled{opacity:.35;cursor:default}.lPRhsq_submit:not(:disabled):active{transform:scale(.96)}.lPRhsq_kbd{color:currentColor;opacity:.72;background:0 0;border:0;justify-content:center;align-items:center;padding:0;font-family:inherit;font-size:11px;font-weight:500;line-height:1;display:inline-flex}.lPRhsq_error{color:var(--dsw-alias-state-error-primary);font-size:11.5px;line-height:16px}@media (hover:none),(pointer:coarse){.lPRhsq_card{width:min(344px,100vw - 16px)}.lPRhsq_field{font-size:16px;line-height:22px}.lPRhsq_submit{height:32px;padding:0 14px;font-size:13px}.lPRhsq_kbd{display:none}}@keyframes lPRhsq_selection-comment-in{0%{opacity:0;scale:.96}to{opacity:1;scale:1}}@media (prefers-reduced-motion:reduce){.lPRhsq_card{animation:none}.lPRhsq_submit,.lPRhsq_close{transition:none}}`,document.head.appendChild(e)}var E_={card:`lPRhsq_card`,close:`lPRhsq_close`,error:`lPRhsq_error`,excerpt:`lPRhsq_excerpt`,field:`lPRhsq_field`,header:`lPRhsq_header`,inputRow:`lPRhsq_inputRow`,kbd:`lPRhsq_kbd`,"selection-comment-in":`lPRhsq_selection-comment-in`,submit:`lPRhsq_submit`};function D_(){return typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`field-sizing`,`content`)}function O_({excerpt:e,labels:t,fieldRef:n,style:r,below:i,onSubmit:a,onCancel:o}){let[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(!1),m=(0,d.useRef)(null),h=s.trim();(0,d.useEffect)(()=>{n.current?.focus({preventScroll:!0});let e=(0,p.observeComposition)(document);return m.current=e,()=>{e.dispose(),m.current===e&&(m.current=null)}},[n]),(0,d.useLayoutEffect)(()=>{let e=n.current;e===null||D_()||(e.style.height=`auto`,e.style.height=`${String(Math.min(e.scrollHeight,116))}px`)},[n,s]);let g=()=>{h!==``&&!a(h)&&u(!0)};return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:E_.card,role:`dialog`,"aria-label":t.placeholder,"data-placement":i?`below`:`above`,style:r,"data-selection-actions":!0,onKeyDown:e=>{e.key===`Escape`&&m.current?.guards(e.nativeEvent)!==!0&&(e.preventDefault(),e.stopPropagation(),o())},onMouseDown:e=>{e.target!==n.current&&e.preventDefault()},children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:E_.header,children:[/* @__PURE__ */ (0,f.jsx)(`blockquote`,{className:E_.excerpt,children:e.replace(/\s+/gu,` `)}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:E_.close,"aria-label":t.cancel,title:t.cancel,onClick:o,children:/* @__PURE__ */ (0,f.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M2.5 2.5l7 7M9.5 2.5l-7 7`})})})]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:E_.inputRow,children:[/* @__PURE__ */ (0,f.jsx)(`textarea`,{ref:n,className:E_.field,rows:1,value:s,placeholder:t.placeholder,"aria-label":t.placeholder,onChange:e=>{c(e.target.value)},onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||m.current?.guards(e.nativeEvent)!==!0&&(e.preventDefault(),g())}}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:E_.submit,disabled:h===``,onClick:g,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:t.submit}),/* @__PURE__ */ (0,f.jsx)(`kbd`,{className:E_.kbd,"aria-hidden":`true`,children:`↵`})]})]}),l&&/* @__PURE__ */ (0,f.jsx)(`div`,{role:`alert`,className:E_.error,children:t.unavailable})]})}function k_(e){return e instanceof Element?e:e.parentElement}function A_(e){if(e===null||typeof window>`u`)return null;let t=window.getSelection();if(t===null||t.rangeCount===0||t.isCollapsed)return null;let n=t.getRangeAt(0),r=k_(n.startContainer),i=k_(n.endContainer),a=r?.closest(`[data-selection-answer]`);if(a==null||!e.contains(a)||i?.closest(`[data-selection-answer]`)!==a||a.hasAttribute(`data-selection-answer-streaming`)||r?.closest(e_)!=null||i?.closest(e_)!=null)return null;let o=n_(n),s=x_(n);return o===``||s===void 0?null:{text:o,rect:s,range:n.cloneRange(),host:a}}function j_(e){let t=window.getSelection();t!==null&&e.contains(t.anchorNode)&&e.contains(t.focusNode)&&t.removeAllRanges()}function M_(e,t=0){let n=window.visualViewport,r=n?.width??window.innerWidth,i=n?.offsetLeft??0,a=e.right-i,o=window.matchMedia(`(hover: none)`).matches,s=n?.offsetTop??0,c=s+(n?.height??window.innerHeight),l=e.top-8-t>=s+8,u=e.bottom+8+t<=c-8,d=t===0?o:o?u||!l:!l&&u,f=r-8-a,p=d?e.bottom+8:e.top-8,m=s+8+(d?0:t),h=c-8-(d?t:0);return{left:e.right,top:t===0?p:Math.max(m,Math.min(p,h)),maxWidth:r-16,transform:`translateX(clamp(${String(8-a)}px, -100%, calc(${String(f)}px - 100%)))`+(d?``:` translateY(-100%)`),below:d}}function N_({labels:e,onAdd:t,container:n}){let[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(null),s=(0,d.useRef)(null),c=(0,d.useRef)(!1),l=(0,d.useRef)(null),u=(0,d.useRef)(!1),p=(0,d.useRef)(null),m=(0,d.useRef)(null),g=(0,d.useCallback)(e=>{m.current=e,i(e)},[]),_=(0,d.useCallback)(()=>{c.current=!1,o(null)},[]),v=(0,d.useCallback)(()=>{if(l.current=null,u.current||c.current)return;let e=A_(n.current),t=p.current;e!==null&&t!==null&&e.host===t.host&&e.text===t.text?g(null):((e===null||t===null||e.host!==t.host||e.text!==t.text)&&(p.current=null),g(e))},[n,g]),y=(0,d.useCallback)(()=>{l.current===null&&(l.current=window.requestAnimationFrame(v))},[v]);(0,d.useEffect)(()=>{let e=()=>{u.current=!1,y()},t=e=>{let t=e.target;(t instanceof Element?t:t instanceof Node?t.parentElement:null)?.closest(`[data-selection-actions]`)??(u.current=!0,p.current=null,g(null),_())},n=()=>{let e=window.getSelection();e===null||e.rangeCount===0||e.isCollapsed?(p.current=null,g(null)):y()},r=e=>{let t=e.target;if(t instanceof Element&&t.closest(`[data-selection-actions]`)!==null)return;let n=s.current;(n===null||n!==document.activeElement&&n.value===``)&&(g(null),_())},i=e=>{let t=m.current;e.key!==`Escape`||e.defaultPrevented||e.isComposing||c.current||t===null||(e.preventDefault(),p.current={host:t.host,text:t.text},g(null))};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`pointerup`,e,!0),document.addEventListener(`pointercancel`,e,!0),document.addEventListener(`selectionchange`,n),document.addEventListener(`keydown`,i),window.addEventListener(`keyup`,y),window.addEventListener(`scroll`,r,!0),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`pointerup`,e,!0),document.removeEventListener(`pointercancel`,e,!0),document.removeEventListener(`selectionchange`,n),document.removeEventListener(`keydown`,i),window.removeEventListener(`keyup`,y),window.removeEventListener(`scroll`,r,!0),l.current!==null&&window.cancelAnimationFrame(l.current),l.current=null}},[y,_,g]);let b=a?.rect,x=a?.range;(0,d.useEffect)(()=>{if(b===void 0||x===void 0)return;let e=window.visualViewport,t=s.current?.closest(`[data-selection-actions]`),n=()=>{let e=t?.offsetHeight??104,n=M_(b,e);o(e=>e?.rect===b?{...e,placement:n}:e)},r=S_([x]),i=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return t!=null&&i?.observe(t),window.addEventListener(`resize`,n),e?.addEventListener(`resize`,n),e?.addEventListener(`scroll`,n,{passive:!0}),n(),()=>{r(),i?.disconnect(),window.removeEventListener(`resize`,n),e?.removeEventListener(`resize`,n),e?.removeEventListener(`scroll`,n)}},[b,x]);let S=e=>e.host.isConnected&&n.current?.contains(e.host)===!0;if(a!==null){let n=a.placement;return(0,h.createPortal)(/* @__PURE__ */ (0,f.jsx)(O_,{excerpt:a.text,labels:e,fieldRef:s,below:n.below,style:{left:n.left,top:n.top,maxWidth:n.maxWidth,transform:`${n.transform} translateZ(0)`},onSubmit:e=>!S(a)||!t(a.anchor===void 0?{text:a.text,annotation:e}:{text:a.text,annotation:e,anchor:a.anchor})?!1:(j_(a.host),_(),!0),onCancel:_}),document.body)}if(r===null)return null;let C=M_(r.rect),w=()=>r.host.isConnected&&n.current?.contains(r.host)===!0;return(0,h.createPortal)(/* @__PURE__ */ (0,f.jsxs)(`div`,{className:y_.popover,"data-placement":C.below?`below`:`above`,style:{left:C.left,top:C.top,maxWidth:C.maxWidth,transform:`${C.transform} translateZ(0)`},"data-selection-actions":!0,onPointerDown:e=>{e.preventDefault()},children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:y_.action,onClick:()=>{if(!w())return;let e=r_(r.host,r.range);t(e===void 0?{text:r.text}:{text:r.text,anchor:e})&&(j_(r.host),g(null))},children:[/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M12 7v6`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M9 10h6`})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:e.addToChat})]}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:y_.action,onClick:()=>{if(!w())return;let e=r_(r.host,r.range);j_(r.host),c.current=!0,o({...r,anchor:e,placement:M_(r.rect,104)}),g(null)},children:/* @__PURE__ */ (0,f.jsx)(`span`,{children:e.comment})})]}),document.body)}let P_=`@deepseek-ai/dsh-client-ui-chat/ChatMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(P_)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=P_,e.textContent=`.DT2SAW_linkMenu[data-menu-material]{--link-menu-fill:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 68%, var(--dsw-alias-bg-overlay));--dsw-menu-surface-fill:color-mix(in srgb, var(--link-menu-fill) 78%, transparent);--dsw-menu-backdrop-filter:blur(20px) saturate(140%);--dsw-alias-interactive-bg-hover:color-mix(in srgb, var(--dsw-alias-link) 18%, transparent);--dsw-alias-menu-icon:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l4);min-width:148px;padding:4px;box-shadow:inset 0 1px #fff3,0 2px 5px #0000001a,0 9px 22px #0000002e}.DT2SAW_linkMenu[data-menu-material] [role=menuitem]{min-height:24px;font:500 13px/18px var(--dsw-font-family);border-radius:6px;gap:8px;padding:2px 8px}.DT2SAW_linkMenu[data-menu-material] [role=menuitem]>span:has(>svg),.DT2SAW_linkMenu[data-menu-material] [role=menuitem] svg{width:14px;height:14px}@media (pointer:coarse){.DT2SAW_linkMenu[data-menu-material] [role=menuitem]{min-height:44px}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){.DT2SAW_linkMenu[data-menu-material]{--dsw-menu-surface-fill:var(--link-menu-fill);--dsw-menu-backdrop-filter:none}}@media (forced-colors:active){.DT2SAW_linkMenu[data-menu-material]{--dsw-menu-surface-fill:Canvas;--dsw-menu-backdrop-filter:none;border-color:canvastext}.DT2SAW_linkMenu[data-menu-material] [role=menuitem]:is(:hover,:focus-visible){outline-offset:-1px;outline:1px solid highlight}}`,document.head.appendChild(e)}var F_={linkMenu:`DT2SAW_linkMenu`};function I_({children:e,openFile:t,openLinkInSidebar:n,hideLocalFileActions:r=!1,t:i,...a}){let[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(!1),u=(0,d.useCallback)(()=>s(null),[]),m=(0,d.useCallback)(()=>o?.position??null,[o]);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.MarkdownDelegateProvider,{...a,openFile:t,onLinkContextMenu:s,children:e}),/* @__PURE__ */ (0,f.jsx)(p.Menu,{anchor:null,open:o!==null,portal:!0,compact:!0,autoFocus:!0,listClassName:F_.linkMenu,getAnchorRect:m,focusReturnTarget:o?.trigger,onClose:u,children:o!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[(o.kind===`file`||n!==void 0)&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:o.kind===`file`?/* @__PURE__ */ (0,f.jsx)(p.LinkIconMedium,{kind:`document`}):/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineMedium,{}),onSelect:()=>{u(),o.kind===`file`?t(o.path,o.line===void 0?void 0:{line:o.line}):n?.(o.href)},children:i(`linkMenu.openInCodexhost`)}),/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconLinkOutlineMedium,{}),onSelect:()=>{u(),(0,p.writeClipboard)(o.href).then(e=>l(!e))},children:i(`linkMenu.copy`)}),(o.kind===`web`||!r)&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconRightUpOutlineMedium,{}),onSelect:()=>{u(),o.kind===`web`?window.open(o.href,`_blank`,`noopener,noreferrer`):t(o.path,{external:!0,...o.line===void 0?{}:{line:o.line}})},children:i(o.kind===`web`?`linkMenu.openBrowser`:`linkMenu.openFile`)}),o.kind===`file`&&!r&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconFolderOpenOutlineMedium,{}),onSelect:()=>{u(),t(o.path,{reveal:!0})},children:i(`linkMenu.openFolder`)})]})}),c&&/* @__PURE__ */ (0,f.jsx)(p.Toast,{text:i(`linkMenu.copyFailed`),onDone:()=>l(!1)})]})}let L_=`@deepseek-ai/dsh-client-ui-chat/HandoffDivider.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(L_)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=L_,e.textContent=`.SfZcya_root{flex-direction:column;gap:10px;width:100%;min-width:0;padding:6px 0 8px;display:flex}.SfZcya_dividerBar{align-items:center;gap:10px;width:100%;min-width:0;display:flex}.SfZcya_line{background:var(--dsw-alias-border-l2);opacity:.72;flex:20px;min-width:12px;height:1px}.SfZcya_trigger{border-radius:var(--dsw-radius-sm,8px);min-width:0;max-width:calc(100% - 36px);color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size-secondary,13px);cursor:pointer;background:0 0;border:none;flex-wrap:wrap;justify-content:center;align-items:center;gap:4px 7px;padding:4px 10px;line-height:20px;transition:background-color .12s,color .12s;display:inline-flex}.SfZcya_trigger:hover,.SfZcya_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}.SfZcya_trigger:focus-visible{outline:2px solid var(--dsw-alias-link);outline-offset:1px}.SfZcya_titleGroup{color:var(--dsw-alias-label-tertiary);flex-shrink:0;align-items:center;gap:5px;display:inline-flex}.SfZcya_swapIcon{opacity:.85;flex-shrink:0}.SfZcya_endpoints{flex-wrap:wrap;justify-content:center;align-items:center;gap:2px 6px;min-width:0;max-width:100%;display:inline-flex}.SfZcya_endpoint{align-items:center;gap:5px;min-width:0;max-width:100%;display:inline-flex}.SfZcya_sourceLabel{color:var(--dsw-alias-label-secondary);text-overflow:ellipsis;white-space:nowrap;max-width:240px;font-weight:450;overflow:hidden}.SfZcya_arrow{color:var(--dsw-alias-label-caption);flex-shrink:0;font-size:12px;line-height:1}.SfZcya_targetLabel{color:color-mix(in srgb, var(--dsw-alias-link) 82%, var(--dsw-alias-label-secondary));text-overflow:ellipsis;white-space:nowrap;max-width:240px;font-weight:500;overflow:hidden}.SfZcya_chevron{color:var(--dsw-alias-label-caption);opacity:.55;flex-shrink:0;align-items:center;transition:transform .14s,opacity .12s;display:inline-flex}.SfZcya_trigger:hover .SfZcya_chevron,.SfZcya_trigger[aria-expanded=true] .SfZcya_chevron{opacity:.95}.SfZcya_chevronOpen{transform:rotate(180deg)}.SfZcya_panel{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md,10px);background:var(--dsw-alias-bg-module-platform);flex-direction:column;gap:10px;min-width:0;padding:12px 14px;display:flex}body[data-codexhost-wallpaper] .SfZcya_panel{background:color-mix(in srgb, var(--dsw-alias-bg-module-platform) 84%, transparent);backdrop-filter:blur(12px)}.SfZcya_panelHeader{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px;display:flex}.SfZcya_turnSummary{color:var(--dsw-alias-label-secondary);font-size:12.5px;line-height:18px}.SfZcya_sourceButton{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;flex-shrink:0;align-items:center;gap:5px;padding:4px 10px;font-size:12px;font-weight:500;line-height:16px;transition:background-color .12s,border-color .12s;display:inline-flex}.SfZcya_sourceButton:hover{background:var(--dsw-alias-interactive-bg-hover-solid);border-color:var(--dsw-alias-border-l3)}.SfZcya_sourceButton:focus-visible{outline:2px solid var(--dsw-alias-link);outline-offset:1px}.SfZcya_preview{border:1px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-base);max-height:260px;color:var(--dsw-alias-label-secondary);white-space:pre-wrap;overflow-wrap:anywhere;margin:0;padding:10px 12px;font-family:inherit;font-size:12.5px;line-height:1.55;overflow-y:auto}.SfZcya_previewEmpty{color:var(--dsw-alias-label-tertiary);font-style:italic}@media (width<=520px){.SfZcya_dividerBar{gap:6px}.SfZcya_line{flex-basis:10px;min-width:8px}.SfZcya_trigger{column-gap:5px;max-width:calc(100% - 28px);padding:4px 6px;font-size:12px;line-height:18px}.SfZcya_sourceLabel,.SfZcya_targetLabel{max-width:148px}.SfZcya_panel{padding:10px 12px}}`,document.head.appendChild(e)}var R_={arrow:`SfZcya_arrow`,chevron:`SfZcya_chevron`,chevronOpen:`SfZcya_chevronOpen`,dividerBar:`SfZcya_dividerBar`,endpoint:`SfZcya_endpoint`,endpoints:`SfZcya_endpoints`,line:`SfZcya_line`,panel:`SfZcya_panel`,panelHeader:`SfZcya_panelHeader`,preview:`SfZcya_preview`,previewEmpty:`SfZcya_previewEmpty`,root:`SfZcya_root`,sourceButton:`SfZcya_sourceButton`,sourceLabel:`SfZcya_sourceLabel`,swapIcon:`SfZcya_swapIcon`,targetLabel:`SfZcya_targetLabel`,titleGroup:`SfZcya_titleGroup`,trigger:`SfZcya_trigger`,turnSummary:`SfZcya_turnSummary`};let z_=(0,d.memo)(function({handoff:e,hostId:t,onOpenSource:n,t:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useId)(),s=zm({harnessId:e.sourceHarnessId,harnessLabel:e.sourceHarnessLabel,model:e.sourceModel}),c=zm({harnessId:e.targetHarnessId,harnessLabel:e.targetHarnessLabel,model:e.targetModel}),l=e.includedTurnNumbers.length,u=e.omittedTurns>0?r(`handoff.divider.turnsPartial`,{included:l,total:e.totalTurns,omitted:e.omittedTurns,boundary:e.boundaryTurnNumber}):e.boundaryTurnNumber<e.totalTurns?r(`handoff.divider.turnsPrefix`,{boundary:e.boundaryTurnNumber,total:e.totalTurns}):r(`handoff.divider.turnsAll`,{total:e.totalTurns}),m=e.preview.trim();return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:R_.root,"data-handoff-divider":``,"aria-label":r(`handoff.divider.label`),children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:R_.dividerBar,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:R_.line,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:R_.trigger,"aria-expanded":i,"aria-controls":o,"aria-label":r(i?`handoff.divider.collapse`:`handoff.divider.expand`),onClick:()=>{a(e=>!e)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:R_.titleGroup,children:[/* @__PURE__ */ (0,f.jsx)(Vm,{size:14,className:R_.swapIcon}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:r(`handoff.divider.label`)})]}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:R_.endpoints,children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:R_.endpoint,title:s.title,children:[/* @__PURE__ */ (0,f.jsx)(Hm,{harnessId:e.sourceHarnessId,label:e.sourceHarnessLabel??e.sourceHarnessId,hostId:t,size:15}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:R_.sourceLabel,children:s.display})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:R_.arrow,"aria-hidden":`true`,children:`→`}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:R_.endpoint,title:c.title,children:[/* @__PURE__ */ (0,f.jsx)(Hm,{harnessId:e.targetHarnessId,label:e.targetHarnessLabel??e.targetHarnessId,hostId:t,size:15}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:R_.targetLabel,children:c.display})]})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:i?`${R_.chevron} ${R_.chevronOpen}`:R_.chevron,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:12})})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:R_.line,"aria-hidden":`true`})]}),i&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:o,className:R_.panel,"data-handoff-panel":``,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:R_.panelHeader,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:R_.turnSummary,children:u}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:R_.sourceButton,onClick:()=>{n(e.sourceThreadId)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:r(`handoff.divider.openSource`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]})]}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:m===``?`${R_.preview} ${R_.previewEmpty}`:R_.preview,children:m===``?r(`handoff.divider.previewEmpty`):e.preview})]})]})}),B_=`@deepseek-ai/dsh-client-ui-chat/HandoffModal.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(B_)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=B_,e.textContent=`.psMsOW_dialog{width:min(440px,100%)}.psMsOW_sections{flex-direction:column;gap:16px;min-width:0;display:flex}.psMsOW_section{flex-direction:column;gap:8px;min-width:0;display:flex}.psMsOW_sectionLabel{color:var(--dsw-alias-label-secondary);font-size:12.5px;font-weight:500;line-height:18px}.psMsOW_harnessGrid{grid-template-columns:repeat(auto-fill,minmax(128px,1fr));gap:8px;display:grid}.psMsOW_harnessOption{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,8px);background:var(--dsw-alias-bg-base);min-width:0;color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer;align-items:center;gap:8px;padding:8px 10px;font-size:13px;line-height:18px;transition:background-color .12s,border-color .12s;display:flex}.psMsOW_harnessOption:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);border-color:var(--dsw-alias-border-l3)}.psMsOW_harnessOption[data-selected]{border-color:var(--dsw-alias-link);background:color-mix(in srgb, var(--dsw-alias-link) 10%, var(--dsw-alias-bg-base))}.psMsOW_harnessOption:disabled{opacity:.55;cursor:default}.psMsOW_harnessName{text-overflow:ellipsis;white-space:nowrap;flex:auto;min-width:0;font-weight:500;overflow:hidden}.psMsOW_checkIcon{color:var(--dsw-alias-link);flex-shrink:0}.psMsOW_searchInput{width:100%}.psMsOW_modelList{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,8px);background:var(--dsw-alias-bg-module-platform);flex-direction:column;gap:4px;max-height:216px;padding:4px;display:flex;overflow-y:auto}.psMsOW_modelOption{border-radius:var(--dsw-radius-sm,6px);width:100%;min-width:0;color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer;background:0 0;border:none;justify-content:space-between;align-items:center;gap:8px;padding:7px 10px;font-size:13px;line-height:18px;transition:background-color .1s;display:flex}.psMsOW_modelOption:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.psMsOW_modelOption[data-selected]{background:var(--dsw-alias-bg-base);box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--dsw-alias-link) 45%, var(--dsw-alias-border-l2))}.psMsOW_modelOption:disabled{opacity:.55;cursor:default}.psMsOW_modelInfo{flex-direction:column;flex:auto;min-width:0;display:flex}.psMsOW_modelTitleRow{align-items:center;gap:6px;min-width:0;display:flex}.psMsOW_modelName{text-overflow:ellipsis;white-space:nowrap;font-weight:450;overflow:hidden}.psMsOW_defaultBadge{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-tertiary);border-radius:4px;flex-shrink:0;padding:1px 5px;font-size:11px;line-height:14px}.psMsOW_modelDesc{text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary);font-size:11.5px;line-height:16px;overflow:hidden}.psMsOW_status{color:var(--dsw-alias-label-secondary);align-items:center;gap:8px;padding:12px 2px;font-size:13px;line-height:18px;display:flex}.psMsOW_empty{color:var(--dsw-alias-label-tertiary);padding:10px;font-size:12.5px;line-height:18px}.psMsOW_errorBox{border-radius:var(--dsw-radius-sm,8px);border:1px solid color-mix(in srgb, var(--dsw-alias-state-error-primary) 28%, transparent);background:color-mix(in srgb, var(--dsw-alias-state-error-primary) 8%, transparent);color:var(--dsw-alias-state-error-primary);justify-content:space-between;align-items:center;gap:8px;padding:9px 11px;font-size:12.5px;line-height:18px;display:flex}.psMsOW_errorText{overflow-wrap:anywhere;min-width:0}.psMsOW_modalAction{min-width:78px}.psMsOW_submittingContent{align-items:center;gap:6px;display:inline-flex}@media (width<=640px){.psMsOW_harnessGrid{grid-template-columns:repeat(2,minmax(0,1fr))}}`,document.head.appendChild(e)}var X={checkIcon:`psMsOW_checkIcon`,defaultBadge:`psMsOW_defaultBadge`,dialog:`psMsOW_dialog`,empty:`psMsOW_empty`,errorBox:`psMsOW_errorBox`,errorText:`psMsOW_errorText`,harnessGrid:`psMsOW_harnessGrid`,harnessName:`psMsOW_harnessName`,harnessOption:`psMsOW_harnessOption`,modalAction:`psMsOW_modalAction`,modelDesc:`psMsOW_modelDesc`,modelInfo:`psMsOW_modelInfo`,modelList:`psMsOW_modelList`,modelName:`psMsOW_modelName`,modelOption:`psMsOW_modelOption`,modelTitleRow:`psMsOW_modelTitleRow`,searchInput:`psMsOW_searchInput`,section:`psMsOW_section`,sectionLabel:`psMsOW_sectionLabel`,sections:`psMsOW_sections`,status:`psMsOW_status`,submittingContent:`psMsOW_submittingContent`};function V_(e,t){if(t===void 0||t.models.length===0)return;let n=e.rememberedSelections?.[t.id]?.model;return n!==void 0&&t.models.some(e=>e.id===n)?n:e.default?.provider===t.id&&t.models.some(t=>t.id===e.default?.model)?e.default.model:t.models[0]?.id}function H_(e,t,n){if(e===null||t===void 0||n===void 0)return;let r=t.models.find(e=>e.id===n),i=r?.reasoning?.efforts;if(i===void 0||i.length===0)return;let a=e.rememberedSelections?.[t.id];if(a?.model===n&&a.reasoningEffort!==void 0&&i.some(e=>e.id===a.reasoningEffort))return a.reasoningEffort;if(r?.reasoning?.defaultEffort!==void 0&&i.some(e=>e.id===r.reasoning?.defaultEffort))return r.reasoning.defaultEffort}function U_(e){if(e===null)return[];let t=e.harnessOrder??[];return[...e.groups].sort((e,n)=>{let r=t.indexOf(e.id),i=t.indexOf(n.id);return(r<0?1/0:r)-(i<0?1/0:i)})}function W_(e,t){if(e.length!==0)return e.find(e=>e.id!==t)??e[0]}function G_({open:e,atSeq:t,currentHarnessId:n,loadModelCatalog:r,onSubmit:i,onClose:a,t:o}){let[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(`idle`),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(null),[v,y]=(0,d.useState)(void 0),[b,x]=(0,d.useState)(``),[S,C]=(0,d.useState)(!1),[w,T]=(0,d.useState)(null),E=(0,d.useCallback)(()=>{let e=!0;return u(`loading`),h(null),r().then(t=>{if(!e)return;let r=W_(U_(t),n);c(t),u(`ready`),_(r?.id??null),y(V_(t,r))},t=>{e&&(u(`error`),h(t instanceof Error?t.message:String(t)))}),()=>{e=!1}},[n,r]);(0,d.useEffect)(()=>{if(e)return T(null),x(``),E()},[e,E]);let ee=(0,d.useMemo)(()=>U_(s),[s]),D=(0,d.useMemo)(()=>ee.find(e=>e.id===g),[ee,g]),O=(0,d.useMemo)(()=>s===null?void 0:V_(s,D),[s,D]),te=(D?.models.length??0)>6,ne=(0,d.useMemo)(()=>{let e=D?.models??[];return!te||b.trim()===``?e:(0,p.rankByName)(e,b.trim())},[b,D?.models,te]),re=e=>{S||(_(e.id),y(s===null?e.models[0]?.id:V_(s,e)),x(``),T(null))},ie=()=>{if(S||g===null)return;let e=H_(s,D,v),n=v===void 0||v===`harness`?void 0:v;C(!0),T(null),i({...t===void 0?{}:{atSeq:t},targetHarnessId:g,...n===void 0?{}:{targetModel:n},...e===void 0?{}:{targetThinkingOptionId:e}}).then(()=>{C(!1),a()},e=>{C(!1),T(e instanceof Error?e.message:String(e))})},ae=!S&&l===`ready`&&g!==null;return/* @__PURE__ */ (0,f.jsx)(p.Modal,{open:e,onClose:S?()=>{}:a,closeLabel:o(`close`),title:o(`handoff.modal.title`),description:o(`handoff.modal.description`),className:X.dialog,footer:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,className:X.modalAction,disabled:S,onClick:a,children:o(`cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,className:X.modalAction,disabled:!ae,onClick:ie,children:S?/* @__PURE__ */ (0,f.jsxs)(`span`,{className:X.submittingContent,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:o(`handoff.modal.submitting`)})]}):o(`handoff.modal.confirm`)})]}),children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.sections,"data-handoff-modal":``,children:[l===`loading`&&s===null&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.status,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:o(`handoff.modal.loadingCatalog`)})]}),l===`error`&&m!==null&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.errorBox,role:`alert`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.errorText,children:o(`handoff.modal.catalogError`,{message:m})}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,size:`sm`,onClick:()=>void E(),children:o(`retry`)})]}),s!==null&&ee.length===0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.empty,children:o(`handoff.modal.noHarnesses`)}),ee.length>0&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.section,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.sectionLabel,children:o(`handoff.modal.targetHarness`)}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.harnessGrid,role:`radiogroup`,"aria-label":o(`handoff.modal.targetHarness`),children:ee.map(e=>{let t=e.id===g;return/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-selected":t||void 0,disabled:S,className:X.harnessOption,onClick:()=>re(e),children:[/* @__PURE__ */ (0,f.jsx)(Hm,{harnessId:e.id,label:e.name,size:16}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.harnessName,children:e.name}),t&&/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{size:14,className:X.checkIcon})]},e.id)})})]}),D!==void 0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.section,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.sectionLabel,children:o(`handoff.modal.targetModel`)}),te&&/* @__PURE__ */ (0,f.jsx)(p.Input,{className:X.searchInput,type:`text`,role:`searchbox`,placeholder:o(`handoff.modal.searchModels`),"aria-label":o(`handoff.modal.searchModels`),value:b,disabled:S,onChange:e=>{x(e.target.value)}}),D.models.length===0?/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.empty,children:o(`handoff.modal.noModels`)}):/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.modelList,role:`radiogroup`,"aria-label":o(`handoff.modal.targetModel`),children:ne.length===0?/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.empty,children:o(`handoff.modal.noMatchingModels`)}):ne.map(e=>{let t=e.id===v,n=e.id===O;return/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-selected":t||void 0,disabled:S,className:X.modelOption,onClick:()=>{y(e.id),T(null)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:X.modelInfo,children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:X.modelTitleRow,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.modelName,children:e.name}),n&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.defaultBadge,children:o(`handoff.modal.defaultBadge`)})]}),e.description!==void 0&&e.description!==``&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.modelDesc,children:e.description})]}),t&&/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{size:14,className:X.checkIcon})]},e.id)})})]})]}),w!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.errorBox,role:`alert`,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.errorText,children:o(`handoff.modal.failed`,{message:w})})})]})})}function K_(e,t,n){if(/^https?:/u.test(e)&&n!==``&&!/[\u0000-\u001f\u007f]/u.test(n))return new URL(`/api/remote-peer/file?sessionId=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,e).href}function q_(e,t){let n=e instanceof Error?e.message:String(e);return n===``?t:n}function J_(e,t){let n=/* @__PURE__ */ new Set,r;for(let i of e){let e=t.get(i);if(e===void 0||e.kind!==`user`&&e.kind!==`steering`&&e.kind!==`turn-trigger`||((e.location.kind===`turn`||e.location.kind===`step`)&&(r=e.location.turn.turn),e.kind===`turn-trigger`))continue;let a=e.data.source;a?.kind===`user`&&typeof a.rpcId==`string`&&n.add(a.rpcId)}return{rpcIds:n,lastInputTurn:r}}let Y_=(0,d.memo)(function({entries:e,useChatGroup:t,pendingInputs:n,lastInputTurn:r,...i}){let a=e.map(e=>{switch(e.kind){case`node`:return/* @__PURE__ */ (0,d.createElement)(Ih,{...i,key:Uh(e),nodeKey:e.key,...e.groupPart===void 0?{}:{groupPart:e.groupPart}});case`group`:return/* @__PURE__ */ (0,d.createElement)(og,{...i,key:Uh(e),groupKey:e.key,useChatGroup:t});default:return Hh(e)}}),o=n.map(e=>`requestId`in e?/* @__PURE__ */ (0,f.jsx)(oh,{submission:e,renderMessageImages:i.renderMessageImages,t:i.t},e.requestId):/* @__PURE__ */ (0,f.jsx)(ah,{content:e.content,renderMessageImages:i.renderMessageImages,t:i.t},e.id)),s=e.at(-1),c=s?.kind===`node`?i.nodeStore.get(s.key):void 0;if(c?.kind===`turn-process`&&c.location.kind===`turn`&&c.location.turn.status===`open`&&c.location.turn.turn!==r){let e=n.findIndex(e=>`requestId`in e&&e.placement===`transcript`);e!==-1&&a.splice(a.length-1,0,...o.splice(e,1))}return[...a,...o]});function X_({connection:e,useSession:t,useChat:n,useChatNode:r,useChatNodeProcess:i,useChatGroup:a,useConversation:o,useSessions:s,useStore:c,actions:l,renderSlot:u,sessionId:m,openFile:h,openSkill:g,openExternalLink:_,openLinkInSidebar:v,useBrowserAvailable:y,resolveLink:b,loadOlder:x,loadThrough:S,loadImage:C,inspectCall:w,chatScroll:T,forkAt:E,openSession:ee,handoff:D,loadModelCatalog:O,loadTurnDiffs:te,editMessage:ne,fileMentions:re,usePresentation:ae,useProjection:k,useInput:se,inputActions:ce,viewRequest:le,completeViewRequest:ue,t:A}){let de=n(e=>e.order),fe=y(e=>e),pe=o(e=>e.views.grouped(`chat`)?.entries),me=(0,d.useMemo)(()=>pe??de.map(e=>({kind:`node`,key:e})),[pe,de]),he=n(e=>e.nodes),ge=n(e=>e.navigation.items()),_e=ge.at(-1)?.anchorKey,ve=r(_e??``,e=>{let t=e?.location;return(t?.kind===`turn`||t?.kind===`step`)&&t.turn.status===`open`?t.turn.start?.time:void 0}),ye=k(`turnOutline`),be=(0,d.useMemo)(()=>Yg(ge,ye),[ge,ye]),xe=k(`inbox`),Se=s(e=>e.byId[m]?.cwd),Ce=s(e=>e.byId[m]?.projectionValues?.remoteHost?.hostId),we=s(e=>(e.byId[m]?.projectionValues)?.harnessIdentity?.id),Te=s(e=>!!e.byId[m]?.projectionValues?.remoteHost),Ee=s(e=>{let t=e.byId[m]?.projectionValues?.remoteHost;return t?.hostId.startsWith(`remote-peer:`)===!0&&t.filePreview===!0}),De=(0,d.useMemo)(()=>({resolve:e=>{if(Ee)return K_(document.baseURI,m,e);if(!Te)return oe(document.baseURI,ie(Se,e))},labels:{open:A(`image.open`),loading:A(`image.loading`),failed:A(`image.failed`),dialog:A(`image.dialog`),close:A(`image.close`)}}),[Se,Te,Ee,m,A]),Oe=(0,d.useCallback)(e=>ce?.addResponseAnnotation(e,{focus:`end`})!==void 0,[ce]),ke=t(e=>e.running),Ae=(0,d.useSyncExternalStore)(e.state.subscribe,e.state.getSnapshot),je=(0,p.useSustainedRecovery)(Ae!==`connected`),Me=k(`compacting`),Ne=k(`codexhostHandoff`),[Pe,Fe]=(0,d.useState)(null),Ie=Pe?.sessionId===m?Pe:null,Le=(0,d.useCallback)(e=>{Fe({sessionId:m,atSeq:e})},[m]),Re=(0,d.useCallback)(()=>{Fe(null)},[]),ze=D!==void 0&&O!==void 0,Be=t(e=>e.openState),j=k(`remoteHistoryError`),Ve=k(`nativeConnection`),He=Ae===`disconnected`||je||Be===`error`||!!j||Ve?.state===`reconnecting`,Ue=t(e=>e.openError),We=t(e=>e.hasMore),Ge=t(e=>e.loadingOlder),Ke=t(e=>e.olderError),[qe,Je]=(0,d.useState)(null),[Ye,Xe]=(0,d.useState)(!1),Ze=(0,d.useRef)(0),Qe=(0,d.useCallback)((e,t)=>{let n=++Ze.current;Xe(!0),(t===void 0?h(e):h(e,t)).then(()=>{n===Ze.current&&(Je(null),Xe(!1))},r=>{n===Ze.current&&(Je({path:e,options:t,message:q_(r,A(t?.reveal?`fileOpen.folder`:`fileOpen.unknown`))}),Xe(!1))})},[h,A]),$e=(0,d.useCallback)(()=>{Ze.current+=1,Je(null),Xe(!1)},[]),et=(0,d.useMemo)(()=>xe?.[`next-step`].filter(e=>e.source.kind===`user`)??[],[xe]),tt=t(e=>e.pendingSubmissions),nt=Jm(ne,k(`sentMessageEdit`)?.seq??null,Be!==`open`||ke||tt.length>0||(xe?.[`next-turn`].length??0)>0),rt=nt.draft&&de.some(e=>{let t=he.get(e);return t?.kind===`user`&&t.data.seq===nt.draft?.seq}),it=ke||tt.some(e=>e.placement!==`queued`),[at,ot]=(0,d.useMemo)(()=>{if(tt.length===0)return[tt,void 0];let e=J_(de,he);return[tt.filter(t=>t.placement!==`queued`&&!e.rpcIds.has(t.requestId)),e.lastInputTurn]},[tt,de,he]),st=(0,d.useMemo)(()=>{let e=new Map(at.map(e=>[e.requestId,e])),t=new Set(tt.filter(e=>e.placement!==`queued`).map(e=>e.requestId));return[...et.flatMap(n=>{let r=n.source;if(r.kind!==`user`||!(`rpcId`in r))return[n];let i=e.get(r.rpcId);return i===void 0?t.has(r.rpcId)?[]:[n]:(e.delete(r.rpcId),[i])}),...e.values()]},[et,tt,at]),ct=(0,d.useCallback)(e=>u(`conversation.message.images`,{...e,loadImage:C}),[C,u]),lt=de[0],ut=lt===void 0?null:he.get(lt)?.anchorSeq??null,dt=de.at(-1)??null,ft=st.findLast(e=>`source`in e),pt=ft?.source.kind===`user`&&`rpcId`in ft.source?ft.source.rpcId:ft?.id??null,mt=h_({displayReady:Be===`open`||de.length>0,historyReady:Be===`open`,order:de,firstSeq:ut,lastKey:dt,running:ke,loadingOlder:Ge,olderFailed:Ke!=null,hasMore:We,chatScroll:T,loadOlder:x,loadThrough:S,lastIsUser:dt!==null&&he.get(dt)?.kind===`user`,steeringId:pt,submissionId:at.at(-1)?.requestId??null,loadedTurns:ge}),ht=se(e=>e.responseAnnotations.find(e=>e.id===le?.focus)),{initialized:gt,revealResponseAnnotation:_t}=mt;return(0,d.useLayoutEffect)(()=>{gt&&le?.view===`chat`&&(ht!==void 0&&_t(ht),ue())},[gt,le,ht,_t,ue]),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Mh.frame,children:[mt.initialized&&/* @__PURE__ */ (0,f.jsx)(Rg,{items:be,activeTurn:mt.activeTurn,busyTurn:mt.busyTurn,onNavigate:mt.navigateToTurn,t:A}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:Mh.root,"data-chat-following-tail":mt.followingTail?``:void 0,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:mt.listRef,className:Mh.scroll,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:mt.columnRef,className:Mh.column,"data-chat-flow":``,children:[Be===`loading`&&de.length===0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Mh.hint,children:A(`chat.loadingHistory`)}),Be===`error`&&Ue!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Mh.openError,children:A(`chat.loadError`,{message:Ue.message,code:Ue.code})}),We&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Mh.older,children:Ke==null?/* @__PURE__ */ (0,f.jsx)(`span`,{role:Ge?`status`:void 0,children:A(Ge?`chat.loadingOlder`:`chat.scrollOlder`)}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{role:`alert`,children:A(`chat.loadOlderError`,{message:Ke.message})}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,disabled:Ge,onClick:mt.loadEarlier,children:A(`chat.retryOlder`)})]})}),!We&&Ne!=null&&/* @__PURE__ */ (0,f.jsx)(z_,{handoff:Ne,hostId:Ce,onOpenSource:ee,t:A}),/* @__PURE__ */ (0,f.jsx)(I_,{openExternalLink:_,openLinkInSidebar:fe?v:void 0,hideLocalFileActions:Te,resolveLink:b,openFile:Qe,fileImages:De,t:A,children:/* @__PURE__ */ (0,f.jsx)(Y_,{entries:me,pendingInputs:st,lastInputTurn:ot,nodeStore:he,useChatGroup:a,useChatNode:r,useChatNodeProcess:i,usePresentation:ae,useStore:c,actions:l,cwd:Se,openFile:Qe,openSkill:g,inspectCall:w,forkAt:E,handoffAt:ze?Le:void 0,loadTurnDiffs:te,messageEditing:nt,loadImage:C,renderMessageImages:ct,fileMentions:re,renderSlot:u,t:A})},m),nt.draft&&!rt&&/* @__PURE__ */ (0,f.jsx)(ch,{editing:nt,renderMessageImages:ct,t:A}),it&&/* @__PURE__ */ (0,f.jsx)(Hg,{startTime:ve,compacting:Me,stale:He,t:A}),Be===`loading`&&de.length>0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Mh.syncing,role:`status`,"data-history-syncing":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`,className:Mh.syncingIcon}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:A(`chat.syncing`)})]})]})})}),ce!==void 0&&/* @__PURE__ */ (0,f.jsx)(N_,{labels:{addToChat:A(`selection.addToChat`),comment:A(`selection.comment`),placeholder:A(`selection.commentPlaceholder`),submit:A(`selection.commentSubmit`),cancel:A(`message.edit.cancel`),unavailable:A(`selection.commentUnavailable`)},onAdd:Oe,container:mt.columnRef},m),!mt.followingTail&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Mh.toBottomSlot,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Mh.toBottom,"aria-label":A(`chat.toBottom`),onClick:mt.returnToBottom,children:/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{})})}),Ie!==null&&D!==void 0&&O!==void 0&&/* @__PURE__ */ (0,f.jsx)(G_,{open:!0,atSeq:Ie.atSeq,currentHarnessId:we,loadModelCatalog:O,onSubmit:D,onClose:Re,t:A},`${m}:${Ie.atSeq??`latest`}`),qe!==null&&/* @__PURE__ */ (0,f.jsx)(Z_,{title:A(qe.options?.reveal?`fileOpen.folder`:`fileOpen.title`),message:qe.message,busy:Ye,onClose:$e,onRetry:()=>{Qe(qe.path,qe.options)},t:A})]})}function Z_({title:e,message:t,busy:n,onClose:r,onRetry:i,t:a}){return/* @__PURE__ */ (0,f.jsx)(p.Modal,{open:!0,onClose:r,closeLabel:a(`close`),title:e,description:t,footer:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,className:Mh.modalAction,onClick:r,children:a(`cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,className:Mh.modalAction,disabled:n,onClick:i,children:a(`retry`)})]})})}let Q_=`chat`,$_={"message.stepProcess.thinking":`正在分析请求`,"message.stepProcess.read":`正在读取文件`,"message.stepProcess.readImage":`正在读取图片`,"message.stepProcess.write":`正在写入文件`,"message.stepProcess.search":`正在搜索代码`,"message.stepProcess.edit":`正在编辑文件`,"message.stepProcess.commands":`正在运行命令`,"message.stepProcess.code":`正在运行代码`,"message.stepProcess.webSearch":`正在搜索网页`,"message.stepProcess.webFetch":`正在访问网页`,"message.stepProcess.subagents":`正在协调子智能体`,"message.stepProcess.plan":`正在更新计划`,"message.stepProcess.questions":`等待你的操作`,"message.stepProcess.tools":`正在调用工具`,"message.stepProcess.prepare.read":`准备读取文件`,"message.stepProcess.prepare.readImage":`准备读取图片`,"message.stepProcess.prepare.write":`准备写入文件`,"message.stepProcess.prepare.search":`准备搜索代码`,"message.stepProcess.prepare.edit":`准备编辑文件`,"message.stepProcess.prepare.commands":`准备运行命令`,"message.stepProcess.prepare.code":`准备运行代码`,"message.stepProcess.prepare.webSearch":`准备搜索网页`,"message.stepProcess.prepare.webFetch":`准备访问网页`,"message.stepProcess.prepare.subagents":`准备协调子智能体`,"message.stepProcess.prepare.plan":`准备更新计划`,"message.stepProcess.prepare.questions":`准备提问`,"message.stepProcess.prepare.tools":`准备调用工具`,"message.stepProcess.done.thinking":`已完成分析`,"message.stepProcess.done.read":`已读取文件`,"message.stepProcess.done.readImage":`已读取图片`,"message.stepProcess.done.write":`已写入文件`,"message.stepProcess.done.search":`已搜索代码`,"message.stepProcess.done.edit":`修改了文件`,"message.stepProcess.done.commands":`执行了命令`,"message.stepProcess.done.code":`运行了代码`,"message.stepProcess.done.webSearch":`已搜索网页`,"message.stepProcess.done.webFetch":`已访问网页`,"message.stepProcess.done.subagents":`已协调子智能体`,"message.stepProcess.done.plan":`更新了计划`,"message.stepProcess.done.questions":`向用户提出了问题`,"message.stepProcess.done.tools":`已调用工具`,"message.stepProcess.joinTwo":`{first}并{second}`,"message.stepProcess.comma":`,`,"message.stepProcess.sharedPrefix":`已`,"message.stepProcess.more":`{title}等`,"message.trigger.request":`收到执行请求`,"message.trigger.goal":`继续执行目标`,"message.trigger.agent":`收到任务消息`,"message.trigger.team":`收到团队消息`,"message.trigger.subagent":`子任务状态更新`,"message.trigger.github":`收到 GitHub 事件`,"message.trigger.webhook":`收到外部事件`,"message.trigger.schedule":`自动化任务`,"message.trigger.job":`后台任务状态更新`,"message.trigger.plugin":`插件状态更新`,"message.trigger.explanation":`这条通知触发了本轮回复。`,"message.turnProcess.worked":`已完成`,"message.turnProcess.unknown":`已结束`,"message.turnProcess.took":`已完成,用时 `,"message.turnProcess.failed":`处理失败`,"view.chat":`对话`,"image.open":`查看大图`,"image.loading":`加载图片…`,"image.failed":`图片无法预览`,"image.dialog":`图片预览`,"image.close":`关闭图片预览`,"message.imageViews.one":`已查看 1 张图像`,"message.imageViews.many":`已查看 {count} 张图像`,"duration.milliseconds":`{milliseconds}毫秒`,"chat.loadingHistory":`载入历史…`,"selection.addToChat":`添加到对话`,"selection.comment":`添加批注`,"selection.commentPlaceholder":`写下你的批注…`,"selection.commentSubmit":`添加`,"selection.commentUnavailable":`当前无法添加批注,请稍后重试。`,"annotation.label":`批注 {index}`,"annotation.chipLabel":`{index}.`,"annotation.title":`批注 {index}:{excerpt}`,"annotation.remove":`移除批注 {index}`,"annotation.selectedText":`选中文字:`,"annotation.userComment":`你的批注:`,"chat.syncing":`正在获取最新消息…`,"chat.loadingDiff":`载入差异…`,"chat.retryDiff":`重试`,"chat.loadError":`历史加载失败:{message}({code})`,"chat.loadOlder":`加载更早`,"chat.scrollOlder":`向上滚动查看更早消息`,"chat.loadingOlder":`正在加载更早消息…`,"chat.loadOlderError":`更早消息加载失败:{message}`,"chat.retryOlder":`重试加载`,"chat.toBottom":`回到底部`,"chat.filesChanged":`{count} 个文件已更改`,"chat.fileEdited":`已编辑 {name}`,"chat.filesEdited":`已编辑 {count} 个文件`,"chat.viewChanges":`查看变更`,"chat.hideChanges":`收起变更`,"chat.openFile":`打开 {path}`,"chat.showMoreFiles":`再显示 {count} 个文件`,"chat.collapseFiles":`收起文件`,"diff.code":`代码`,"diff.wrap":`自动换行`,"diff.unwrap":`取消换行`,"diff.copy":`复制`,"diff.copied":`已复制`,"diff.collapseAria":`折叠差异`,"diff.expandAria":`展开 {count} 行隐藏内容`,"diff.collapse":`折叠`,"diff.expand":`展开 {count} 行`,"chat.deepDiving":`正在处理`,"chat.statusUnconfirmed":`任务状态待确认`,"chat.deepDivingFor":`正在处理 · {duration}`,"chat.turnNavigation.label":`轮次导航`,"chat.turnNavigation.jump":`跳转到用户消息 {turn}`,"chat.turnNavigation.jumpLoad":`加载并跳转到用户消息 {turn}`,"chat.turnNavigation.turn":`用户消息 {turn}`,"settings.links.title":`网页链接默认打开方式`,"settings.links.description":`对话中网页链接的打开位置`,"settings.links.sidebar":`应用内侧边栏`,"settings.links.newTab":`默认浏览器`,"settings.transcript.title":`工作步骤展示`,"settings.transcript.description":`选择希望看到多少工具调用细节`,"settings.transcript.compact":`简洁`,"settings.transcript.standard":`标准`,"settings.transcript.detailed":`详细`,"settings.transcript.verbose":`完全展开`,"fileOpen.title":`无法打开文件`,"fileOpen.folder":`无法打开所在文件夹`,"fileOpen.unknown":`无法打开此文件`,"linkMenu.copy":`复制链接`,"linkMenu.copyFailed":`无法复制链接`,"linkMenu.openBrowser":`在浏览器中打开`,"linkMenu.openFile":`用默认应用打开`,"linkMenu.openFolder":`打开所在文件夹`,"linkMenu.openInCodexhost":`在 codexhost 中打开`,"message.watch.completed":`已完成`,"message.watch.failed":`失败`,"message.watch.interrupted":`已中断`,"message.watch.timedOut":`监听已到期`,"message.watch.unreadable":`状态未知`,"message.watch.notFound":`会话不存在`,"message.watch.open":`打开会话`,"message.extraBlock":`附加内容块`,"message.uploading":`上传中…`,"message.uploadingPercent":`上传中 {percent}%`,"message.systemPrompt":`系统提示词`,"message.systemPromptUpdate":`系统提示词更新`,"message.toolAdded":`已添加工具:{name}`,"message.toolRemoved":`已移除工具:{name}`,"message.toolsAdded":`新增:{names}`,"message.toolsAddedCount":`新增 {count} 个`,"message.toolsChanged":`新增 {added} 个,移除 {removed} 个`,"message.toolsRemoved":`移除:{names}`,"message.toolsRemovedCount":`移除 {count} 个`,"message.toolsUpdated":`工具已更新`,"message.contextInjection":`上下文注入`,"message.contextRecall":`跨会话召回`,"message.referenceSummary":`引用会话 · {labels}`,"message.referenceSeparator":`、`,"message.context.instructions.loaded":`已载入`,"message.context.instructions.added":`已新增`,"message.context.instructions.updated":`已更新`,"message.context.instructions.removed":`已移除`,"message.context.catalog.replaced":`替换目录`,"message.context.catalog.more":`…还有 {count} 条`,"message.context.snapshot.supersedes":`取代先前的快照`,"message.context.relay.from":`来自会话 {session}`,"message.context.recall.counts":`保留 {retained} 条 · 省略 {omitted} 条`,"message.context.recall.truncated":`已截断`,"message.compaction":`上下文已压缩`,"message.compaction.running":`正在压缩…`,"message.compaction.completed":`已压缩 {items} 条历史记录(约 {tokens} tokens)`,"message.compaction.expand":`点击查看压缩摘要`,"message.compaction.unavailable":`压缩摘要不可用`,"message.compaction.commandTitle":`compact`,"message.think":`思考`,"message.unknownSurface":`未知 surface 事件:{type}`,"message.unknownBlock":`未知内容块`,"message.turnProcess.toolCalls.one":`{count} 次工具调用`,"message.turnProcess.toolCalls.other":`{count} 次工具调用`,"message.turnProcess.messages.one":`{count} 条消息`,"message.turnProcess.messages.other":`{count} 条消息`,"message.turnProcess.subagents.one":`{count} 个 subagent`,"message.turnProcess.subagents.other":`{count} 个 subagent`,"message.turnProcess.thoughtForAWhile":`已思考`,"message.turnProcess.separator":` · `,"message.stopped":`已停止`,"message.edit":`编辑消息`,"message.edit.changed":`会话状态已变化,请核对当前历史后继续。`,"message.edit.cancel":`取消`,"message.edit.send":`发送`,"message.edit.sending":`正在回退并重跑…`,"message.edit.checkHistory":`请核对当前历史后再继续;编辑文本已保留,不会自动重发。`,"message.branch":`在新对话中分支`,"message.branchFailed":`分叉未完成:{message}`,"message.branchUnavailable":`仅可从已完成轮次的最后一条消息分支`,"message.handoff":`上下文交接`,"message.handoffUnavailable":`仅可从已完成轮次的最后一条消息交接`,"handoff.divider.label":`上下文交接`,"handoff.divider.expand":`展开上下文交接详情`,"handoff.divider.collapse":`收起上下文交接详情`,"handoff.divider.turnsAll":`已携带全部 {total} 轮对话`,"handoff.divider.turnsPrefix":`已携带前 {boundary} / {total} 轮对话`,"handoff.divider.turnsPartial":`已携带 {included} / {total} 轮对话(省略 {omitted} 轮,截至第 {boundary} 轮)`,"handoff.divider.openSource":`跳回源会话`,"handoff.divider.previewEmpty":`暂无交接上下文预览`,"handoff.modal.title":`上下文交接`,"handoff.modal.description":`将当前对话上下文整理并交接到新的会话中继续处理。`,"handoff.modal.targetHarness":`目标 Agent`,"handoff.modal.targetModel":`模型`,"handoff.modal.searchModels":`搜索模型…`,"handoff.modal.noModels":`该 Agent 未提供可选模型,将使用默认配置`,"handoff.modal.noHarnesses":`暂无可用的目标 Agent`,"handoff.modal.noMatchingModels":`没有匹配的模型`,"handoff.modal.loadingCatalog":`正在加载可用 Agent 与模型…`,"handoff.modal.catalogError":`加载模型目录失败:{message}`,"handoff.modal.confirm":`确认交接`,"handoff.modal.submitting":`正在交接…`,"handoff.modal.failed":`交接失败:{message}`,"handoff.modal.defaultBadge":`默认`,"message.retry.active":`正在重试模型请求`,"message.retry.cancelled":`模型请求重试已取消`,"message.retry.started":`已重试模型请求`,"message.retry.scheduled":`等待重试模型请求`,"message.retry.status":`{label}({retry}/{maximum}) · {seconds}s`,"message.retry.delay":`重试延迟:`,"message.retry.failure":`失败原因:`,"message.failure.auth":`API 密钥无效`,"message.accountStopped":`任务已停止`,"message.failure.accountSignedOut":`任务已因退出 DeepSeek 登录而停止。`,"message.failure.accountSignInRequired":`请先登录 DeepSeek,并确认请求地址支持账号认证。`,"message.failure.quota":`当前请求的额度已用尽`,"message.turnError":`本轮运行失败`,"message.maxTokens":`已达到输出 token 上限`,"message.maxTokens.hint":`回答被截断,已有输出保留在对话中。发送“继续”可让模型接着输出。`,"duration.secondUnit":`秒`,"duration.minuteUnit":`分`,"duration.hourUnit":`小时`,"command.running":`执行中…`,"command.failed":`指令失败`,"command.done":`已完成`,"command.title":`指令`,"row.running":`运行中`,"row.failed":`失败`,"json.truncated":`… 已截断,共 {total} 字符`,"clock.md":`{m}月{d}日`,"clock.ymd":`{y}年{m}月{d}日`},ev={"message.stepProcess.thinking":`Analyzing the request`,"message.stepProcess.read":`Reading files`,"message.stepProcess.readImage":`Reading images`,"message.stepProcess.write":`Writing files`,"message.stepProcess.search":`Searching code`,"message.stepProcess.edit":`Editing files`,"message.stepProcess.commands":`Running commands`,"message.stepProcess.code":`Running code`,"message.stepProcess.webSearch":`Searching the web`,"message.stepProcess.webFetch":`Visiting web pages`,"message.stepProcess.subagents":`Coordinating subagents`,"message.stepProcess.plan":`Updating the plan`,"message.stepProcess.questions":`Waiting for your action`,"message.stepProcess.tools":`Calling tools`,"message.stepProcess.prepare.read":`Preparing to read files`,"message.stepProcess.prepare.readImage":`Preparing to read images`,"message.stepProcess.prepare.write":`Preparing to write files`,"message.stepProcess.prepare.search":`Preparing to search code`,"message.stepProcess.prepare.edit":`Preparing to edit files`,"message.stepProcess.prepare.commands":`Preparing to run commands`,"message.stepProcess.prepare.code":`Preparing to run code`,"message.stepProcess.prepare.webSearch":`Preparing to search the web`,"message.stepProcess.prepare.webFetch":`Preparing to visit web pages`,"message.stepProcess.prepare.subagents":`Preparing to coordinate subagents`,"message.stepProcess.prepare.plan":`Preparing to update the plan`,"message.stepProcess.prepare.questions":`Preparing questions`,"message.stepProcess.prepare.tools":`Preparing tool calls`,"message.stepProcess.done.thinking":`Analysis completed`,"message.stepProcess.done.read":`Read files`,"message.stepProcess.done.readImage":`Read images`,"message.stepProcess.done.write":`Wrote files`,"message.stepProcess.done.search":`Searched code`,"message.stepProcess.done.edit":`Edited files`,"message.stepProcess.done.commands":`Ran commands`,"message.stepProcess.done.code":`Ran code`,"message.stepProcess.done.webSearch":`Searched the web`,"message.stepProcess.done.webFetch":`Visited web pages`,"message.stepProcess.done.subagents":`Coordinated subagents`,"message.stepProcess.done.plan":`Updated the plan`,"message.stepProcess.done.questions":`Asked questions`,"message.stepProcess.done.tools":`Called tools`,"message.stepProcess.joinTwo":`{first} and {second}`,"message.stepProcess.comma":`, `,"message.stepProcess.sharedPrefix":``,"message.stepProcess.more":`{title}, etc.`,"message.trigger.request":`Execution requested`,"message.trigger.goal":`Continuing goal`,"message.trigger.agent":`Task message received`,"message.trigger.team":`Team message received`,"message.trigger.subagent":`Subtask status updated`,"message.trigger.github":`GitHub event received`,"message.trigger.webhook":`External event received`,"message.trigger.schedule":`Automation task`,"message.trigger.job":`Background task updated`,"message.trigger.plugin":`Plugin status updated`,"message.trigger.explanation":`This notification triggered this response.`,"message.turnProcess.worked":`Completed`,"message.turnProcess.unknown":`Ended`,"message.turnProcess.took":`Completed in `,"message.turnProcess.failed":`Failed`,"view.chat":`Chat`,"image.open":`View full image`,"image.loading":`Loading image…`,"image.failed":`Image preview unavailable`,"image.dialog":`Image preview`,"image.close":`Close image preview`,"message.imageViews.one":`Viewed 1 image`,"message.imageViews.many":`Viewed {count} images`,"duration.milliseconds":`{milliseconds}ms`,"chat.loadingHistory":`Loading history…`,"selection.addToChat":`Add to chat`,"selection.comment":`Add comment`,"selection.commentPlaceholder":`Add a comment…`,"selection.commentSubmit":`Add`,"selection.commentUnavailable":`Could not add the comment. Try again in a moment.`,"annotation.label":`Annotation {index}`,"annotation.chipLabel":`{index}.`,"annotation.title":`Annotation {index}: {excerpt}`,"annotation.remove":`Remove annotation {index}`,"annotation.selectedText":`Selected text:`,"annotation.userComment":`Your comment:`,"chat.syncing":`Fetching latest messages…`,"chat.loadingDiff":`Loading diff…`,"chat.retryDiff":`Retry`,"chat.loadError":`Failed to load history: {message} ({code})`,"chat.loadOlder":`Load earlier`,"chat.scrollOlder":`Scroll up for earlier messages`,"chat.loadingOlder":`Loading earlier messages…`,"chat.loadOlderError":`Could not load earlier messages: {message}`,"chat.retryOlder":`Retry loading`,"chat.toBottom":`Back to bottom`,"chat.filesChanged":`{count} files changed`,"chat.fileEdited":`Edited {name}`,"chat.filesEdited":`Edited {count} files`,"chat.viewChanges":`View changes`,"chat.hideChanges":`Hide changes`,"chat.openFile":`Open {path}`,"chat.showMoreFiles":`Show {count} more`,"chat.collapseFiles":`Collapse files`,"diff.code":`Code`,"diff.wrap":`Wrap lines`,"diff.unwrap":`Unwrap lines`,"diff.copy":`Copy`,"diff.copied":`Copied`,"diff.collapseAria":`Collapse diff`,"diff.expandAria":`Expand {count} hidden lines`,"diff.collapse":`Collapse`,"diff.expand":`Expand {count} lines`,"chat.deepDiving":`Working`,"chat.statusUnconfirmed":`Task status unconfirmed`,"chat.deepDivingFor":`Working · {duration}`,"chat.turnNavigation.label":`Turn navigation`,"chat.turnNavigation.jump":`Jump to user message {turn}`,"chat.turnNavigation.jumpLoad":`Load and jump to user message {turn}`,"chat.turnNavigation.turn":`User message {turn}`,"settings.links.title":`Open chat links in`,"settings.links.description":`Choose where to open web links`,"settings.links.sidebar":`In-App Sidebar`,"settings.links.newTab":`Default Browser`,"settings.transcript.title":`Work details`,"settings.transcript.description":`Choose how much detail to show for tool calls`,"settings.transcript.compact":`Compact`,"settings.transcript.standard":`Standard`,"settings.transcript.detailed":`Detailed`,"settings.transcript.verbose":`Verbose`,"fileOpen.title":`Couldn’t open file`,"fileOpen.folder":`Couldn’t open containing folder`,"fileOpen.unknown":`Couldn’t open this file`,"linkMenu.copy":`Copy link`,"linkMenu.copyFailed":`Couldn’t copy link`,"linkMenu.openBrowser":`Open in browser`,"linkMenu.openFile":`Open in default app`,"linkMenu.openFolder":`Open containing folder`,"linkMenu.openInCodexhost":`Open in codexhost`,"message.watch.completed":`Completed`,"message.watch.failed":`Failed`,"message.watch.interrupted":`Interrupted`,"message.watch.timedOut":`Watch expired`,"message.watch.unreadable":`State unknown`,"message.watch.notFound":`Session not found`,"message.watch.open":`Open session`,"message.extraBlock":`Extra content block`,"message.uploading":`Uploading…`,"message.uploadingPercent":`Uploading {percent}%`,"message.systemPrompt":`System prompt`,"message.systemPromptUpdate":`System prompt update`,"message.toolAdded":`Tool added: {name}`,"message.toolRemoved":`Tool removed: {name}`,"message.toolsAdded":`Added: {names}`,"message.toolsAddedCount":`{count} added`,"message.toolsChanged":`{added} added, {removed} removed`,"message.toolsRemoved":`Removed: {names}`,"message.toolsRemovedCount":`{count} removed`,"message.toolsUpdated":`Tools updated`,"message.contextInjection":`Context injection`,"message.contextRecall":`Session recall`,"message.referenceSummary":`Referenced session · {labels}`,"message.referenceSeparator":`, `,"message.context.instructions.loaded":`loaded`,"message.context.instructions.added":`added`,"message.context.instructions.updated":`updated`,"message.context.instructions.removed":`removed`,"message.context.catalog.replaced":`Replacement catalog`,"message.context.catalog.more":`… {count} more`,"message.context.snapshot.supersedes":`Supersedes earlier snapshots`,"message.context.relay.from":`From session {session}`,"message.context.recall.counts":`{retained} kept · {omitted} omitted`,"message.context.recall.truncated":`truncated`,"message.compaction":`Context compacted`,"message.compaction.running":`Compacting context…`,"message.compaction.completed":`Compacted {items} history items (~{tokens} tokens)`,"message.compaction.expand":`View compaction summary`,"message.compaction.unavailable":`Compaction summary unavailable`,"message.compaction.commandTitle":`compact`,"message.think":`Think`,"message.unknownSurface":`Unknown surface event: {type}`,"message.unknownBlock":`Unknown content block`,"message.turnProcess.toolCalls.one":`{count} tool call`,"message.turnProcess.toolCalls.other":`{count} tool calls`,"message.turnProcess.messages.one":`{count} message`,"message.turnProcess.messages.other":`{count} messages`,"message.turnProcess.subagents.one":`{count} subagent`,"message.turnProcess.subagents.other":`{count} subagents`,"message.turnProcess.thoughtForAWhile":`Thought for a while`,"message.turnProcess.separator":` · `,"message.stopped":`Stopped`,"message.edit":`Edit message`,"message.edit.changed":`Conversation state changed. Check current history before continuing.`,"message.edit.cancel":`Cancel`,"message.edit.send":`Send`,"message.edit.sending":`Reverting and rerunning…`,"message.edit.checkHistory":`Check current history before continuing. Your edit is retained and will not be resent automatically.`,"message.branch":`Branch into a new conversation`,"message.branchFailed":`Fork did not complete: {message}`,"message.branchUnavailable":`Available only on the last message of a completed turn`,"message.handoff":`Hand off context`,"message.handoffUnavailable":`Available only on the last message of a completed turn`,"handoff.divider.label":`Context handoff`,"handoff.divider.expand":`Expand context handoff details`,"handoff.divider.collapse":`Collapse context handoff details`,"handoff.divider.turnsAll":`Carried all {total} turns`,"handoff.divider.turnsPrefix":`Carried first {boundary} of {total} turns`,"handoff.divider.turnsPartial":`Carried {included} of {total} turns ({omitted} omitted, up to turn {boundary})`,"handoff.divider.openSource":`Open source session`,"handoff.divider.previewEmpty":`No handoff context preview available`,"handoff.modal.title":`Context handoff`,"handoff.modal.description":`Package the current conversation context and continue in a new session.`,"handoff.modal.targetHarness":`Target Agent`,"handoff.modal.targetModel":`Model`,"handoff.modal.searchModels":`Search models…`,"handoff.modal.noModels":`No selectable models — default configuration will be used`,"handoff.modal.noHarnesses":`No available target Agents`,"handoff.modal.noMatchingModels":`No matching models`,"handoff.modal.loadingCatalog":`Loading available Agents and models…`,"handoff.modal.catalogError":`Failed to load model catalog: {message}`,"handoff.modal.confirm":`Hand off`,"handoff.modal.submitting":`Handing off…`,"handoff.modal.failed":`Handoff failed: {message}`,"handoff.modal.defaultBadge":`Default`,"message.retry.active":`Retrying model request`,"message.retry.cancelled":`Model request retry cancelled`,"message.retry.started":`Retried model request`,"message.retry.scheduled":`Waiting to retry model request`,"message.retry.status":`{label} ({retry}/{maximum}) · {seconds}s`,"message.retry.delay":`Retry delay: `,"message.retry.failure":`Failure reason: `,"message.failure.auth":`API key is invalid`,"message.accountStopped":`Task stopped`,"message.failure.accountSignedOut":`Stopped because you signed out of DeepSeek.`,"message.failure.accountSignInRequired":`Sign in to DeepSeek and ensure the request destination supports account authentication.`,"message.failure.quota":`Request quota exhausted.`,"message.turnError":`This turn failed`,"message.maxTokens":`Output token limit reached`,"message.maxTokens.hint":`The reply was cut off; earlier output is preserved in the conversation. Send "continue" to let the model resume.`,"duration.secondUnit":`s`,"duration.minuteUnit":`m `,"duration.hourUnit":`h `,"command.running":`Running…`,"command.failed":`Command failed`,"command.done":`Completed`,"command.title":`Command`,"row.running":`Running`,"row.failed":`Failed`,"json.truncated":`… truncated, {total} characters total`,"clock.md":`{m}/{d}`,"clock.ymd":`{y}-{m}-{d}`},tv=`@deepseek-ai/dsh-client-ui-chat/ReasoningRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(tv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=tv,e.textContent=`.akEvLW_root{flex-direction:column;display:flex}.akEvLW_root:not([data-expanded]){contain:size layout;height:calc(24px + var(--dsh-content-font-delta,0px))}.akEvLW_row{overflow:hidden}.akEvLW_root[data-expanded] [data-open] [data-disclosure-row]{z-index:1;background:var(--dsw-alias-bg-base);position:sticky;top:0}body[data-codexhost-wallpaper] .akEvLW_root[data-expanded] [data-open] [data-disclosure-row]{background:color-mix(in srgb, var(--dsw-alias-bg-base) 76%, transparent);backdrop-filter:blur(12px);border-radius:var(--dsw-radius-sm,8px)}body[data-codexhost-wallpaper] [data-chat-flow-key]:not([data-chat-flow-key] *,[data-chat-near-viewport]) .akEvLW_root[data-expanded] [data-open] [data-disclosure-row]{backdrop-filter:none}.akEvLW_leading{flex-shrink:0}.akEvLW_title{font-weight:400}.akEvLW_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.akEvLW_summary{min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));white-space:nowrap;flex:auto;overflow:hidden}.akEvLW_summaryText{text-overflow:ellipsis;display:block;overflow:hidden}.akEvLW_summary[data-streaming]{mask-image:linear-gradient(90deg,#000 calc(100% - 48px),#0000)}.akEvLW_summary[data-streaming] .akEvLW_summaryText{text-overflow:clip;overflow:visible}.akEvLW_root:not([data-preview]) .akEvLW_separator,.akEvLW_root:not([data-preview]) .akEvLW_summary{display:none}.akEvLW_thinkBody{padding:4px 0 4px calc(22px + var(--dsh-content-font-delta,0px));min-width:0}`,document.head.appendChild(e)}var nv={leading:`akEvLW_leading`,root:`akEvLW_root`,row:`akEvLW_row`,separator:`akEvLW_separator`,summary:`akEvLW_summary`,summaryText:`akEvLW_summaryText`,thinkBody:`akEvLW_thinkBody`,title:`akEvLW_title`};let rv=/* @__PURE__ */ (0,f.jsx)(p.IconThinkOutlineRegular,{size:14});function iv(e){let t=e.indexOf(`
|
|
127
|
-
`);return t===-1?e:e.slice(0,t)}function
|
|
122
|
+
default:Zh(this.#r)}}fail(){this.#d=this.#n,this.#r=`invalid`,this.#c=null}beginKey(e){this.#r=`key`,this.#a=e+1,this.#o=!1,this.#i=!1}stepKey(e,t){if(e<` `){this.fail();return}if(this.#i){this.#i=!1;return}if(e===`\\`){this.#i=!0,this.#o=!0;return}if(e!==`"`)return;let n=this.slice(this.#a,t);if(this.#o)try{this.#s=JSON.parse(`"${n}"`)}catch{this.fail();return}else this.#s=n;this.#r=`colon`}open(e){this.#p.has(this.#s)||this.#m.push(this.#s),this.#p.set(this.#s,e),this.#c=e}beginValue(e,t){Jh(e)||(e===`"`?(this.open({kind:`string`,start:t+1,end:-1,needsDecoding:!1,invalidAt:void 0,length:void 0,text:void 0,prefixes:void 0}),this.#i=!1,this.#r=`string`):e===`}`||e===`,`||e===`:`||e===`]`?this.fail():(this.open({kind:`value`,start:t,end:-1,parsed:void 0,invalid:!1}),e===`{`||e===`[`?(this.#r=`nested`,this.#l=[e===`{`?`}`:`]`],this.#u=!1,this.#i=!1):this.#r=`scalar`))}stepScalar(e,t){(e===`,`||e===`}`||Jh(e))&&(this.closeValue(t),this.#r=e===`,`?`key-only`:e===`}`?`closed`:`comma-or-end`)}stepNested(e,t){if(this.#u)this.#u=!1;else if(e===`"`)this.#u=!0;else if(e===`{`||e===`[`)this.#l.push(e===`{`?`}`:`]`);else if(e===`}`||e===`]`){if(this.#l.pop()!==e){this.fail();return}this.#l.length===0&&(this.closeValue(t+1),this.#r=`comma-or-end`)}}closeValue(e){let t=this.#c;t.end=e,this.#c=null}};function Zh(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}function Qh(e){switch(e.kind){case`node`:return JSON.stringify([`node`,e.key,e.groupPart??null]);case`group`:return JSON.stringify([`group`,e.key]);default:return Zh(e)}}function $h(e,t){let n=e.counts.slice(0,3).map(({kind:e})=>t(`message.stepProcess.done.${e}`)),r=n[0];if(r===void 0)return t(`message.stepProcess.done.thinking`);let i=e=>e.charAt(0).toLowerCase()+e.slice(1),a=n[1];if(a===void 0)return r;if(n.length===2){let e=t(`message.stepProcess.sharedPrefix`);return t(`message.stepProcess.joinTwo`,{first:r,second:i(e!==``&&r.startsWith(e)&&a.startsWith(e)?a.slice(e.length):a)})}let o=[r,...n.slice(1).map(i)].join(t(`message.stepProcess.comma`));return e.counts.length>3?t(`message.stepProcess.more`,{title:o}):o}function eg(e=0){let[t,n]=(0,d.useState)(null);return{expanded:t===e,setExpanded:(0,d.useCallback)(t=>{n(t?e:null)},[e]),toggle:(0,d.useCallback)(()=>{n(t=>t===e?null:e)},[e])}}function tg(e){let t=t=>e.subscribe(t),n=()=>e.getSnapshot();return function(){return eg((0,d.useSyncExternalStore)(t,n))}}function ng(e){let t=e.clientHeight;return{top:e.scrollTop,height:t,floor:Math.max(0,e.scrollHeight-t)}}var rg=class e{following;threshold;static owners=/* @__PURE__ */ new WeakMap;target=null;sampledTop;constructor(e,t){this.following=e,this.threshold=t}static forElement(e){return this.owners.get(e)}bind(t){return e.owners.set(t,this),()=>{e.owners.get(t)===this&&e.owners.delete(t)}}get active(){return this.following}get animating(){return this.target!==null}nearBottom(e){return e.floor-e.top<=this.threshold}setFollowing(e){this.following=e,e||(this.target=null)}reset(){this.setFollowing(!1),this.sampledTop=void 0}sample(e,t=this.sampledTop===void 0||Math.abs(e.top-this.sampledTop)>.5){return this.sampledTop=e.top,!this.animating&&t&&(this.following=this.nearBottom(e)),this.active}settle(e){let t=this.target;return this.target=null,this.sample(e,t===null?void 0:Math.abs(e.top-Math.min(t,e.floor))>this.threshold)}jump(e,t,n){let r=this.animating;this.target=null;let i=Math.max(0,Math.min(t.floor,n));r?e.scrollTo({top:i,behavior:`instant`}):i!==t.top&&(e.scrollTop=i);let a={...t,top:e.scrollTop};return this.sampledTop=a.top,this.following=this.nearBottom(a),a}toBottom(e,t,n){return this.following=!0,n===`instant`||t.top>=t.floor||!this.animating&&this.nearBottom(t)||typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?this.jump(e,t,t.floor):(this.target===null&&(this.target=t.floor,e.scrollTo({top:t.floor,behavior:`smooth`})),t)}interrupt(e,t){this.animating&&(this.target=null,this.sampledTop=t.top,e.scrollTo({top:t.top,behavior:`instant`}))}};function ig(e,t){let[n]=(0,d.useState)(()=>new rg(e,t));return n}let ag={canScrollUp:!1,canScrollDown:!1},og=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);function sg(e,t,n,r){let i=ig(!1,1),a=(0,d.useRef)(null),[o,s]=(0,d.useState)(ag),c=(0,d.useCallback)(e=>{a.current=e},[]),l=(0,d.useCallback)(t=>{let n=e.current,r=ag;if(n!==null&&n.closest(`[hidden], [data-group-expanded-mode]`)===null){let e=ng(n),o=t===`resize`?a.current:null;if(o!==null)e=i.jump(n,e,o===`bottom`?e.floor:0),o===`top`&&i.setFollowing(!1),a.current=null;else{let r=i.animating;t===`scrollend`?i.settle(e):i.sample(e),i.active&&(t===`resize`||t===`scrollend`&&r)&&(e=i.toBottom(n,e,`smooth`))}r={canScrollUp:e.top>1,canScrollDown:e.top<e.floor-1}}else i.reset();s(e=>e.canScrollUp===r.canScrollUp&&e.canScrollDown===r.canScrollDown?e:r)},[e,i]),u=(0,d.useCallback)(()=>{let t=e.current;t!==null&&i.animating&&i.interrupt(t,ng(t))},[e,i]),f=(0,d.useMemo)(()=>({onScroll:()=>{l(`scroll`)},onWheel:u,onTouchStart:u,onPointerDown:u,onKeyDown:e=>{!e.defaultPrevented&&og.has(e.key)&&u()}}),[u,l]);return(0,d.useLayoutEffect)(()=>{u(),i.reset(),(!r||!n)&&(a.current=null)},[i,r,u,n]),(0,d.useLayoutEffect)(()=>{let r=e.current;if(r===null||!n||typeof ResizeObserver>`u`)return;let a=i.bind(r),o=new ResizeObserver(()=>{l(`resize`)}),s=e=>{e.target===r&&l(`scrollend`)};return r.addEventListener(`scrollend`,s),o.observe(r),t.current!==null&&o.observe(t.current),()=>{a(),o.disconnect(),r.removeEventListener(`scrollend`,s)}},[e,t,i,n,l]),{edges:o,events:f,initialize:c}}let cg=`@deepseek-ai/dsh-client-ui-chat/ChatGroupSeat.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(cg)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=cg,e.textContent=`.M49uyW_root{min-width:0}.M49uyW_title{max-width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size,14px);text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:6px;padding:0;transition:color .1s;display:flex}@media (hover:hover){.M49uyW_title:hover{color:var(--dsw-alias-label-secondary)}}.M49uyW_title:active{color:var(--dsw-alias-label-secondary)}.M49uyW_leading{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));color:inherit;flex:none;justify-content:center;align-items:center;display:inline-flex;position:relative}.M49uyW_leading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}.M49uyW_leading svg[width="16"]{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px))}.M49uyW_activityIcon,.M49uyW_chevron{justify-content:center;align-items:center;transition:opacity .1s;display:inline-flex;position:absolute;inset:0}.M49uyW_activityIcon{opacity:1}.M49uyW_chevron{opacity:0}html:not([data-input-modality=pointer]) .M49uyW_title:focus-visible .M49uyW_activityIcon{opacity:0}html:not([data-input-modality=pointer]) .M49uyW_title:focus-visible .M49uyW_chevron{opacity:1}@media (hover:hover){.M49uyW_title:hover .M49uyW_activityIcon{opacity:0}.M49uyW_title:hover .M49uyW_chevron{opacity:1}}.M49uyW_title[aria-expanded=true] .M49uyW_activityIcon{opacity:0}.M49uyW_title[aria-expanded=true] .M49uyW_chevron{opacity:1}.M49uyW_title[aria-expanded=true]{padding-bottom:8px}.M49uyW_body{--dsh-chat-flow-gap:6px;overscroll-behavior-y:auto;scrollbar-gutter:stable;max-height:min(400px,50vh);overflow-y:auto}.M49uyW_label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.M49uyW_fadeTop{mask-image:linear-gradient(#0000 0,#000 24px 100%)}.M49uyW_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 24px),#0000 100%)}.M49uyW_fadeTop.M49uyW_fadeBottom{mask-image:linear-gradient(#0000 0,#000 24px calc(100% - 24px),#0000 100%)}@media (prefers-reduced-motion:reduce){.M49uyW_title,.M49uyW_activityIcon,.M49uyW_chevron{transition:none}}.M49uyW_content{flex-direction:column;display:flex}.M49uyW_content>*{flex-shrink:0}.M49uyW_content>:not([hidden]):not(:empty)~:not([hidden]):not(:empty){margin-top:var(--dsh-chat-flow-gap,6px)}.M49uyW_expandedBody{scrollbar-gutter:auto;max-height:none;overflow:visible}`,document.head.appendChild(e)}var lg={activityIcon:`M49uyW_activityIcon`,body:`M49uyW_body`,chevron:`M49uyW_chevron`,content:`M49uyW_content`,expandedBody:`M49uyW_expandedBody`,fadeBottom:`M49uyW_fadeBottom`,fadeTop:`M49uyW_fadeTop`,label:`M49uyW_label`,leading:`M49uyW_leading`,root:`M49uyW_root`,title:`M49uyW_title`};let ug={thinking:/* @__PURE__ */ (0,f.jsx)(p.IconThinkOutlineRegular,{}),read:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),readImage:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),search:/* @__PURE__ */ (0,f.jsx)(p.IconSearchOutlineRegular,{size:14}),edit:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{size:14}),write:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{size:14}),commands:/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{}),code:/* @__PURE__ */ (0,f.jsx)(p.IconCodeOutlineRegular,{size:14}),webSearch:/* @__PURE__ */ (0,f.jsx)(p.IconGlobeOutlineRegular,{}),webFetch:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),subagents:/* @__PURE__ */ (0,f.jsx)(p.IconAgentPresetOutlineRegular,{size:14}),plan:/* @__PURE__ */ (0,f.jsx)(p.IconPlanOutlineRegular,{}),questions:/* @__PURE__ */ (0,f.jsx)(p.IconQuestionOutlineRegular,{}),tools:/* @__PURE__ */ (0,f.jsx)(p.IconSparkleRegular,{size:14})};function dg(e,t){return e.activity===t.activity&&e.detail===t.detail&&e.preparing===t.preparing}function fg(e,t){let[n,r]=(0,d.useState)(e),i=(0,d.useRef)(n),a=(0,d.useRef)(e),o=(0,d.useRef)(Date.now());return(0,d.useEffect)(()=>{if(a.current=e,!t||dg(i.current,e))return;let n=150-(Date.now()-o.current),s=()=>{let e=a.current;i.current=e,o.current=Date.now(),r(e)};if(n<=0){s();return}let c=setTimeout(s,n);return()=>{clearTimeout(c)}},[t,e.activity,e.detail,e.preparing]),t?n:e}let pg=(0,d.memo)(function({members:e,...t}){return e.map(e=>/* @__PURE__ */ (0,d.createElement)(Gh,{...t,key:Qh(e),nodeKey:e.key,...e.groupPart===void 0?{}:{groupPart:e.groupPart}}))}),mg=(0,d.memo)(function({groupKey:e,useChatGroup:t,usePresentation:n,t:r,open:i,bodyId:a,toggle:o}){let s=t(e,e=>e?.data),c=n(e=>s?.closed===!1&&e.liveProcessDetail),l=fg({activity:s?.summary.running??`thinking`,detail:s?.summary.runningDetail??``,preparing:s?.summary.preparing===!0},s!==void 0&&!s.closed);if(s===void 0)return null;let u=s.closed?$h(s.summary,r):l.preparing?r(`message.stepProcess.prepare.${l.activity===`thinking`?`tools`:l.activity}`):r(`message.stepProcess.${l.activity}`),d=c&&!s.closed?l.detail:``,m=d===``?u:`${u}${r(`message.turnProcess.separator`)}${d}`,h=s.closed?s.summary.counts[0]?.kind??`thinking`:l.activity;return/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:lg.title,"aria-expanded":i,"aria-controls":a,"data-process-activity":h,onClick:e=>{e.currentTarget.focus(),o()},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:lg.leading,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:lg.activityIcon,"data-step-process-icon":!0,children:ug[h]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:lg.chevron,"data-step-process-chevron":!0,children:i?/* @__PURE__ */ (0,f.jsx)(p.IconChevronUpOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{})})]}),/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:!s.closed,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{className:lg.label,children:m})})]})}),hg=(0,d.memo)(function({groupKey:e,useChatGroup:t,members:n,closed:r,grouped:i,open:a,setOpen:o,...s}){let c=(0,d.useCallback)(()=>{o(!0)},[o]),l=Mh(i&&!a,c),u=(0,d.useRef)(null),p=(0,d.useId)(),{edges:m,events:h,initialize:g}=sg(l,u,a,i),_=(0,d.useCallback)(()=>{a||g(r===!1?`bottom`:`top`),o(!a)},[r,g,a,o]),v=[lg.body,i?``:lg.expandedBody,i&&m.canScrollUp?lg.fadeTop:``,i&&m.canScrollDown?lg.fadeBottom:``];return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`div`,{hidden:!i,children:/* @__PURE__ */ (0,f.jsx)(mg,{groupKey:e,useChatGroup:t,usePresentation:s.usePresentation,t:s.t,open:a,bodyId:p,toggle:_})}),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:l,id:p,className:v.join(` `),"data-step-process-body":!0,"data-scroll-up":m.canScrollUp||void 0,"data-scroll-down":m.canScrollDown||void 0,...h,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:u,className:lg.content,"data-step-process-content":!0,"data-chat-flow":``,children:/* @__PURE__ */ (0,f.jsx)(pg,{...s,members:n})})})]})}),gg=(0,d.memo)(function({groupKey:e,useChatGroup:t,mounted:n=!0,placeholderHeight:r,registerRow:i,...a}){let o=t(e,e=>e?.members),s=t(e,e=>e?.data.turn),c=t(e,e=>e?.data.closed),l=a.usePresentation(e=>e.foldCompletedTurns),{expanded:u,setExpanded:m}=eg(),h=o?.[0]?.key??``,g=a.useChatNodeProcess(h),_=a.useChatNode(h,e=>{let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}),v=a.usePresentation(e=>e.stepGrouping===`collapsed`||e.stepGrouping===`history`&&_?.status!==`open`),y=_?.end?.data.reason.kind,b=g?.turnClosed===!1||g?.hasInterleavedInput===!0||_?.end?.data.finalAssistantStep===null||y===`aborted`||y===`error`,x=g?.spec,S=(0,d.useCallback)(e=>s===void 0?void 0:Eh(e,s),[s]),C=a.useStore(S),w=l&&g?.turnClosed===!0&&x!==void 0&&!b&&C?.answerStep!==(x.answerStep??0),T=Mh(w,(0,d.useCallback)(()=>{x!==void 0&&!b&&a.actions.setTurnProcessOpen(x.turn,x.answerStep??0,!0)},[a.actions,x,b])),E=(0,d.useRef)(null);if(E.current===null&&(E.current=/* @__PURE__ */ new Map),jh(T,o!==void 0),(0,d.useLayoutEffect)(()=>{if(i===void 0||o===void 0)return;let t=T.current;if(t!==null)return i(e,t),()=>{i(e,null)}},[i,e,T,o!==void 0]),(0,d.useEffect)(()=>{w&&T.current?.hasAttribute(`hidden`)&&m(!1)},[w,T,m]),o===void 0)return null;let D=!n&&!w&&r!==void 0&&r>0;return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:T,className:lg.root,"data-chat-group-key":e,"data-chat-flow-key":e,"data-chat-anchor-key":`group:${e}`,"data-chat-turn":s,"data-chat-paging-anchor":v&&!u||void 0,"data-step-process":!0,"data-group-expanded-mode":!v||void 0,"data-chat-virtualized":D?``:void 0,style:D?{minHeight:r}:void 0,children:n?/* @__PURE__ */ (0,f.jsx)(p.CodeBlockFoldMemoryProvider,{memory:E.current,scope:e,children:/* @__PURE__ */ (0,f.jsx)(hg,{...a,groupKey:e,useChatGroup:t,members:o,closed:c,grouped:v,open:u,setOpen:m})}):null})});function _g(e){return typeof e==`object`?e.key:e}function vg(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function yg(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function bg(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}let xg=(e,t)=>Math.abs(e-t)<1.01,Sg=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},Cg,wg=()=>{if(Cg!==void 0)return Cg;if(typeof navigator>`u`)return Cg=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Cg=!0;let e=navigator.maxTouchPoints;return Cg=navigator.platform===`MacIntel`&&e!==void 0&&e>0},Tg=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Eg=e=>e,Dg=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},Og=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Tg(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(Tg(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},kg={passive:!0},Ag=typeof window>`u`||`onscrollend`in window,jg=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Ag,o=0,s=a?null:Sg(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,kg),a&&r.addEventListener(`scrollend`,u,kg),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},Mg=(e,t)=>jg(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Ng=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Pg=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})};function Fg(e,t,n,r){if(t===0)return!1;let i=r(0),a=/* @__PURE__ */ new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var Ig=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=/* @__PURE__ */ new Map,this.itemSizeCacheVersion=0,this.laneAssignments=/* @__PURE__ */ new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=/* @__PURE__ */ new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=/* @__PURE__ */ (()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Eg,rangeExtractor:Dg,onChange:()=>{},measureElement:Ng,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>_g(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||Fg(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:c}=this.options,l=0;for(;l<a&&c(l)!==e;)l++;if(l<a){let e=n[l];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=yg(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,wg()&&this.targetWindow!=null&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,kg),e.addEventListener(`touchend`,n,kg),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(wg()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this.scrollState?.behavior===`smooth`&&!xg(this.getScrollOffset()-i,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=yg(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=yg(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=vg(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=yg(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=zg(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=yg(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(!this.isIndexInRange(e))return;let n,r,i,a=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&a!=null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=this.itemSizeCache.get(i)??n,s=t-o;if(s!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,c=a?this.getTotalSize():0,l=this.getScrollOffset()+this.scrollAdjustments,u=this.itemSizeCache.has(i)?r+o<=l&&this.scrollDirection!==`backward`:r<l,d=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?u:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},s,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++;let f=!1;a?f=this.applyScrollAdjustment(this.getTotalSize()-c):d&&(f=this.applyScrollAdjustment(s)),this.notify(f),this._retryClampedAdjustment()}},this.getVirtualItems=yg(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return bg(t[Lg(0,t.length-1,r?e=>n[e*2]:e=>bg(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{this.options.count>0?this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e}):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){if(e===0)return!1;if(wg()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=e,!1;{let n=this.getScrollOffset()+this.scrollAdjustments+e,r=this.scrollElement,i=r!==null&&(`scrollHeight`in r||`document`in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=i!==null&&n>i+.5?{target:n,maxAtWrite:i}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&xg(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}};let Lg=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Rg(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function zg(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=Rg(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=Lg(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}let Bg=typeof document<`u`?d.useLayoutEffect:d.useEffect;function Vg({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=d.useReducer(e=>e+1,0)[1],a=d.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:/* @__PURE__ */ new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=d.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=e=>{let t=a.current;if(!t.enabled||!t.container)return;s(e);let n=!!e.options.horizontal,r=t.mode===`transform`,i=n?`left`:`top`,o=e.options.scrollMargin,c=e.getVirtualItems();for(let a of c){let s=a.start-o,c=e.elementsCache.get(a.key);c&&t.lastPositions.get(c)!==s&&(t.lastPositions.set(c,s),r?c.style.transform=n?`translate3d(${s}px, 0, 0)`:`translate3d(0, ${s}px, 0)`:c.style[i]=`${s}px`)}},l={...r,onChange:(t,n)=>{var s;let l=a.current,u=!0;if(l.enabled){c(t);let e=t.range,n=l.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(l.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,h.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[u]=d.useState(()=>{let e=new Ig(l),t=e.measureElement;return e.measureElement=e=>{o.current=!0;try{t(e)}finally{o.current=!1}},Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return u.setOptions(l),Bg(()=>u._didMount(),[]),Bg(()=>(s(u),u._willUpdate())),Bg(()=>{c(u)}),u}function Hg(e){return Vg({observeElementRect:Og,observeElementOffset:Mg,scrollToFn:Pg,...e})}let Ug=`@deepseek-ai/dsh-client-ui-chat/TurnNavigator.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ug)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Ug,e.textContent=`.R6aBma_slot{z-index:7;height:0;padding-inline:calc(var(--dsh-composer-side-clearance) + 16px);pointer-events:none;position:absolute;top:0;left:0;right:0;container-type:inline-size}[data-conversation-scroll] .R6aBma_slot{position:sticky}.R6aBma_frame{--turn-rail-band:calc(var(--dsh-conversation-viewport-height,100dvh) - var(--dsh-composer-height,152px));--turn-preview-height:104px;top:calc(var(--turn-rail-band) / 2);width:36px;max-height:min(max(0px, calc(var(--turn-rail-band) - 64px)), 70vh, 640px);contain:layout;cursor:pointer;pointer-events:auto;position:absolute;left:12px;transform:translateY(-50%)}.R6aBma_frame[hidden]{display:none}.R6aBma_scroller{max-height:inherit;overscroll-behavior:contain;scrollbar-width:none;position:relative;overflow-y:auto}.R6aBma_scroller::-webkit-scrollbar{display:none}.R6aBma_fadeTop{mask-image:linear-gradient(#0000 0,#000 40px 100%)}.R6aBma_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 40px),#0000 100%)}.R6aBma_fadeTop.R6aBma_fadeBottom{mask-image:linear-gradient(#0000 0,#000 40px calc(100% - 40px),#0000 100%)}.R6aBma_marks{position:relative}.R6aBma_mark{cursor:pointer;background:0 0;border:0;border-radius:8px;height:10px;padding:0;position:absolute;top:0;left:0;right:0}.R6aBma_mark:before{background:var(--dsw-alias-label-tertiary);opacity:.4;content:"";transform-origin:0;width:26px;height:2px;transition:transform .16s cubic-bezier(.2,.8,.2,1),background-color .16s,opacity .16s;position:absolute;top:50%;left:0;transform:translateY(-50%)scaleX(.230769)}.R6aBma_markUnloaded:before{opacity:.25}.R6aBma_mark[data-neighbor-distance="3"]:before{transform:translateY(-50%)scaleX(.384615)}.R6aBma_mark[data-neighbor-distance="2"]:before{transform:translateY(-50%)scaleX(.538462)}.R6aBma_mark[data-neighbor-distance="1"]:before{transform:translateY(-50%)scaleX(.769231)}.R6aBma_markBusy:before{animation:1s ease-in-out infinite R6aBma_dsh-turn-mark-busy}.R6aBma_markActive:before{background:var(--dsw-alias-label-primary);opacity:.6}.R6aBma_frame[data-previewing] .R6aBma_markActive:not(.R6aBma_markPreview):not(:focus-visible):before{background:var(--dsw-alias-label-tertiary);opacity:.4}.R6aBma_markPreview:before{background:var(--dsw-alias-label-primary);opacity:1;transform:translateY(-50%)scaleX(1)}.R6aBma_frame[data-scrubbing] .R6aBma_mark:before{transition:none}.R6aBma_mark:focus-visible:before{background:var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));opacity:1;transform:translateY(-50%)scaleX(1)}.R6aBma_mark:focus-visible{outline:none}.R6aBma_mark:focus-visible:after{border-radius:inherit;outline:1px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-1px;content:"";width:28px;position:absolute;inset:0 auto 0 0}.R6aBma_preview{top:clamp(0px, calc(var(--turn-preview-center) - var(--turn-preview-height) / 2), calc(100% - var(--turn-preview-height)));box-sizing:border-box;width:min(320px,100cqw - 48px);max-height:var(--turn-preview-height);border:.5px solid var(--dsw-alias-border-l4);color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);box-shadow:var(--dsw-elevation-panel);pointer-events:none;border-radius:12px;padding:8px;transition:top .14s cubic-bezier(.2,.8,.2,1);animation:.12s ease-out R6aBma_dsh-turn-preview-enter;position:absolute;left:100%;overflow:hidden}.R6aBma_previewPrompt,.R6aBma_previewResponse{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.R6aBma_previewPrompt{-webkit-line-clamp:1;font-size:14px;font-weight:500;line-height:20px}.R6aBma_previewResponse{color:var(--dsw-alias-label-caption);-webkit-line-clamp:3;margin-top:4px;font-size:14px;line-height:20px}@keyframes R6aBma_dsh-turn-preview-enter{0%{opacity:0;transform:translate(-4px)}to{opacity:1;transform:translate(0)}}@keyframes R6aBma_dsh-turn-mark-busy{0%,to{opacity:1}50%{opacity:.35}}@media (prefers-reduced-motion:reduce){.R6aBma_frame,.R6aBma_scroller,.R6aBma_mark:before,.R6aBma_markBusy:before,.R6aBma_preview{scroll-behavior:auto;transition:none;animation:none}}`,document.head.appendChild(e)}var Wg={"dsh-turn-mark-busy":`R6aBma_dsh-turn-mark-busy`,"dsh-turn-preview-enter":`R6aBma_dsh-turn-preview-enter`,fadeBottom:`R6aBma_fadeBottom`,fadeTop:`R6aBma_fadeTop`,frame:`R6aBma_frame`,mark:`R6aBma_mark`,markActive:`R6aBma_markActive`,markBusy:`R6aBma_markBusy`,markPreview:`R6aBma_markPreview`,markUnloaded:`R6aBma_markUnloaded`,marks:`R6aBma_marks`,preview:`R6aBma_preview`,previewPrompt:`R6aBma_previewPrompt`,previewResponse:`R6aBma_previewResponse`,scroller:`R6aBma_scroller`,slot:`R6aBma_slot`};function Gg(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}let Kg=(0,d.memo)(function({item:e,index:t,active:n,busy:r,previewId:i,neighborDistance:a,registerElement:o,onNavigate:s,onPreview:c,onFocusChange:l,t:u}){let d=[Wg.mark];return e.anchor.kind===`unloaded`&&d.push(Wg.markUnloaded),n&&d.push(Wg.markActive),a===0&&d.push(Wg.markPreview),r&&d.push(Wg.markBusy),/* @__PURE__ */ (0,f.jsx)(`button`,{ref:o,"data-index":t,"data-neighbor-distance":a,type:`button`,className:d.join(` `),"aria-label":u(e.anchor.kind===`loaded`?`chat.turnNavigation.jump`:`chat.turnNavigation.jumpLoad`,{turn:t+1}),"aria-current":n?`true`:void 0,"aria-busy":r?`true`:void 0,"aria-describedby":i,onPointerMove:t=>{t.buttons===0&&c(e.turn)},onClick:()=>{s(e)},onFocus:()=>{l(e.turn)},onBlur:()=>{l(null)}})});function qg({items:e,activeTurn:t,busyTurn:n,onNavigate:r,t:i},a){let[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(null),[u,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(!1),v=(0,d.useRef)(null),y=(0,d.useRef)(null),b=(0,d.useRef)(!1),x=(0,d.useRef)(void 0),S=(0,d.useRef)(null),C=(0,d.useRef)({placed:!1,index:0,follow:null,publishOffset:null}),w=(0,d.useRef)(!1),T=(0,d.useId)(),E=e.length>=2;(0,d.useLayoutEffect)(()=>{let e=v.current,t=e?.parentElement?.querySelector(`[data-chat-flow]`),n=e?.closest(`[data-conversation-scroll]`)??e?.parentElement;if(!t||!n)return;let r=()=>{let e=n.getBoundingClientRect(),r=n.offsetWidth>0?e.width/n.offsetWidth:1;h((t.getBoundingClientRect().left-e.left)/(r||1)>=48)},i=new ResizeObserver(r);return i.observe(t),i.observe(n),r(),()=>i.disconnect()},[E]),(0,d.useEffect)(()=>{if(o===null){p(!1);return}if(u)return;let e=setTimeout(()=>p(!0),150);return()=>clearTimeout(e)},[o,u]),(0,d.useEffect)(()=>()=>{clearTimeout(x.current);let e=y.current;y.current=null,e?.button.hasPointerCapture(e.pointerId)&&e.button.releasePointerCapture(e.pointerId)},[]);let D=(0,d.useMemo)(()=>{let t=/* @__PURE__ */ new Map;return e.forEach((e,n)=>{t.set(e.turn,n)}),t},[e]),O=t===null?void 0:D.get(t);(0,d.useLayoutEffect)(()=>{C.current.index=O??0},[O]);let k=c===null?void 0:D.get(c),ee=o===null?void 0:D.get(o),te=(0,d.useCallback)(e=>{l(e),s(e),p(e!==null)},[]),A=Hg({count:e.length,enabled:E,directDomUpdates:!0,directDomUpdatesMode:`transform`,useScrollendEvent:!0,getScrollElement:(0,d.useCallback)(()=>S.current,[]),getItemKey:(0,d.useCallback)(t=>e[t]?.turn??t,[e]),estimateSize:()=>10,measureElement:()=>10,initialRect:{width:0,height:0},initialOffset:0,scrollToFn:(e,t,n)=>{C.current.placed&&Pg(e,t,n)},observeElementOffset:(e,t)=>{C.current.publishOffset=t;let n=Mg(e,t);return()=>{n?.(),C.current.placed=!1,C.current.follow=null,C.current.publishOffset=null}},observeElementRect:(e,t)=>{let n=e.scrollElement,r=e.targetWindow?.ResizeObserver;if(n===null||r===void 0)return;let i=new r(([r])=>{if(r===void 0)return;let i=r.borderBoxSize[0],a={width:Math.round(i?.inlineSize??r.contentRect.width),height:Math.round(i?.blockSize??r.contentRect.height)},o=C.current;if(!o.placed&&a.height>0){let t=Math.max(0,e.getTotalSize()-a.height),r=o.index*10+6,i=Math.max(0,Math.min(t,r-a.height/2));o.placed=!0,o.follow={index:o.index,count:e.options.count,height:a.height},n.scrollTop=i,o.publishOffset?.(i,!1)}t(a)});return i.observe(n,{box:`border-box`}),()=>{i.disconnect()}},paddingStart:1,paddingEnd:1,scrollPaddingStart:40,scrollPaddingEnd:40,overscan:3,rangeExtractor:(0,d.useCallback)(e=>{let t=Dg(e);if(k!==void 0){let n=Math.min(e.count-1,k+1);for(let e=Math.max(0,k-1);e<=n;e++)t.includes(e)||t.push(e);t.sort((e,t)=>e-t)}return t},[k])}),ne=A.scrollOffset??0,re=A.scrollRect?.height??0,ie=A.getVirtualItems(),ae=(0,d.useCallback)((e,t,n=Gg())=>{let r=A.measurementsCache[e],i=A.scrollRect?.height??0;if(r===void 0||i<=0)return;let a=A.scrollOffset??0,o=r.start+r.size/2;if(t===`if-needed`){let{scrollPaddingStart:e,scrollPaddingEnd:t}=A.options;if(o>=a+e&&o<=a+i-t)return}let s=o-i/2,c=Math.max(0,A.getTotalSize()-i),l=Math.max(0,Math.min(c,s))-a;l!==0&&A.scrollBy(l,{behavior:n})},[A]);(0,d.useImperativeHandle)(a,()=>({activateTurn(t){let n=D.get(t),i=n===void 0?void 0:e[n];i!==void 0&&r(i)},scrollToTurn(e){let t=D.get(e);t!==void 0&&ae(t,`always`)}}),[e,D,r,ae]),(0,d.useEffect)(()=>{if(re<=0){C.current.follow=null;return}if(O===void 0||w.current)return;let t=C.current.follow;if(t?.index===O&&t.count===e.length&&t.height===re)return;C.current.follow={index:O,count:e.length,height:re};let n=t?.count===e.length&&t.height===re?Gg():`instant`;ae(O,`if-needed`,n)},[O,e.length,re,ae]);let oe=(0,d.useCallback)(e=>{b.current?b.current=!1:r(e)},[r]),se=t=>{if(t.button!==0||!(t.target instanceof Element))return;let n=t.target.closest(`button[data-index]`);if(!n||!S.current?.contains(n))return;let r=e[Number(n.dataset.index)];r&&(clearTimeout(x.current),b.current=!1,y.current={pointerId:t.pointerId,button:n,turn:r.turn,moved:!1},n.setPointerCapture(t.pointerId),_(!0),s(r.turn),p(!0))},ce=t=>{let n=y.current,i=S.current;if(!n||!i||t.pointerId!==n.pointerId||!(t.buttons&1))return;let a=i.getBoundingClientRect(),o=Math.max(a.top,Math.min(t.clientY,a.bottom-1)),c=e[Math.max(0,Math.min(e.length-1,Math.round((o-a.top+i.scrollTop-6)/10)))];c&&c.turn!==n.turn&&(n.turn=c.turn,n.moved=!0,s(c.turn),c.anchor.kind===`loaded`&&r(c))},le=e=>{let t=y.current;t&&e.pointerId===t.pointerId&&(y.current=null,_(!1),b.current=t.moved,t.button.hasPointerCapture(e.pointerId)&&t.button.releasePointerCapture(e.pointerId),x.current=setTimeout(()=>{b.current=!1},0),w.current||s(null))};if(!E)return null;let ue=!u||ee===void 0?void 0:e[ee],de=ie.find(e=>e.index===ee),j=[Wg.scroller];return ne>1&&j.push(Wg.fadeTop),ne<A.getTotalSize()-re-1&&j.push(Wg.fadeBottom),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:v,className:Wg.slot,children:/* @__PURE__ */ (0,f.jsxs)(`nav`,{className:Wg.frame,hidden:!m,"data-turn-navigation":``,"data-previewing":ee!==void 0||void 0,"data-scrubbing":g||void 0,onPointerDownCapture:se,onPointerMove:ce,onPointerUpCapture:le,onPointerCancelCapture:le,onLostPointerCapture:le,"aria-label":i(`chat.turnNavigation.label`),onPointerEnter:()=>{w.current=!0},onPointerLeave:()=>{w.current=!1,y.current||s(null)},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{ref:S,className:j.join(` `),children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:A.containerRef,className:Wg.marks,children:ie.map(({index:r,key:a})=>{let c=e[r];return c===void 0?null:/* @__PURE__ */ (0,f.jsx)(Kg,{item:c,index:r,active:c.turn===t,busy:c.turn===n,previewId:u&&c.turn===o?T:void 0,neighborDistance:ee!==void 0&&Math.abs(r-ee)<=3?Math.abs(r-ee):void 0,registerElement:A.measureElement,onNavigate:oe,onPreview:s,onFocusChange:te,t:i},a)})})}),ue!==void 0&&de!==void 0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:T,role:`tooltip`,className:Wg.preview,style:{"--turn-preview-center":`${String(de.start+de.size/2-ne)}px`},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Wg.previewPrompt,children:ue.prompt||i(`chat.turnNavigation.turn`,{turn:(ee??0)+1})}),ue.response!==``&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Wg.previewResponse,children:ue.response})]})]})})}let Jg=(0,d.memo)((0,d.forwardRef)(qg));function Yg(){return/* @__PURE__ */ (0,f.jsx)(`span`,{className:Rh.runningIcon,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:Rh.runningIconMotion,children:/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:`100%`,height:`100%`,viewBox:`2 2 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:1.2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M16.1 5.3C11.8 2.9 6.6 5 5.1 9.4c-1.8 5.4 1.7 10.2 6.9 10.3 4.8.2 8-3.8 7.2-8.3-.4 3.2-2 5.1-4.2 5.8`}),/* @__PURE__ */ (0,f.jsx)(`rect`,{x:`9.5`,y:`9.1`,width:`4.6`,height:`4.6`,rx:`1`,transform:`rotate(-10 11.8 11.4)`})]})})})}let Xg=`@deepseek-ai/dsh-client-ui-chat/accessibility.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Xg)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Xg,e.textContent=`.F76jpa_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var Zg={visuallyHidden:`F76jpa_visuallyHidden`};let Qg=(0,d.memo)(function({startTime:e,compacting:t,stale:n,t:r}){let[i,a]=(0,d.useState)(Date.now);(0,d.useEffect)(()=>{if(e===void 0||t||n)return;a(Date.now());let r=setInterval(()=>{a(Date.now())},1e3);return()=>{clearInterval(r)}},[e,t,n]);let o=n?r(`chat.statusUnconfirmed`):t?r(`message.compaction.running`):e===void 0?r(`chat.deepDiving`):r(`chat.deepDivingFor`,{duration:Um(Math.max(1e3,i-e),r).map(e=>e.text).join(``)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Rh.running,"data-chat-running":!0,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Zg.visuallyHidden,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:r(n?`chat.statusUnconfirmed`:t?`message.compaction.running`:`chat.deepDiving`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Rh.runningDivider,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Rh.runningContent,children:[n?null:/* @__PURE__ */ (0,f.jsx)(Yg,{}),/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:!n,className:Rh.runningText,children:o})]})]})});function $g(e){return e}function e_(e){return e}function t_(e){if(!Number.isSafeInteger(e)||e<0||Object.is(e,-0))throw TypeError(`SessionSeq must be a non-negative safe integer, got ${String(e)}`);return e_(e)}let n_=[];function r_(e){if(typeof e!=`object`||!e)return;let t=e;if(!(typeof t.turn!=`number`||!Number.isSafeInteger(t.turn)||t.turn<0)&&!(typeof t.seq!=`number`||!Number.isSafeInteger(t.seq)||t.seq<0||Object.is(t.seq,-0)))return{turn:t.turn,seq:t_(t.seq),prompt:typeof t.prompt==`string`?t.prompt:``,response:typeof t.response==`string`?t.response:``}}function i_(e){return Array.isArray(e)?e:n_}function a_(e,t){let n=/* @__PURE__ */ new Map;for(let e of i_(t)){let t=r_(e);t!==void 0&&n.set(t.turn,{turn:t.turn,prompt:t.prompt,response:t.response,anchor:{kind:`unloaded`,seq:t.seq}})}for(let t of e){let e=n.get(t.turn);n.set(t.turn,{turn:t.turn,prompt:t.prompt===``?e?.prompt??``:t.prompt,response:t.response===``?e?.response??``:t.response,anchor:{kind:`loaded`,key:t.anchorKey}})}return n.size===0?n_:[...n.values()].sort((e,t)=>e.turn-t.turn)}var o_=class{viewport;reading;input;onBusyTurn;jump=null;settleFrame=null;requestedHead;constructor(e,t,n,r){this.viewport=e,this.reading=t,this.input=n,this.onBusyTurn=r}setInput(e){this.input=e}reset(){this.requestedHead=void 0,this.cancel()}dispose(){this.clearTask()}cancel(){this.clearTask(),this.onBusyTurn(null)}clearTask(){this.cancelFrame(),this.jump=null,this.viewport.stopPreserving()}navigateToTurn=e=>{if(e.anchor.kind===`loaded`){this.cancel();let t=this.viewport.scrollToTurn(e.turn);if(t===null)return;this.reading.acceptNavigation(t),this.input.loadingOlder&&this.viewport.beginPreserving(t.position);return}if(!this.input.historyReady)return;this.cancel(),this.viewport.beginPreserving(),this.reading.pauseFollowing();let t={turn:e.turn,seq:e.anchor.seq,phase:`loading`,landing:`pending`,repageHead:null};this.jump=t,this.onBusyTurn(t.turn),this.request(t)};autoLoadEarlier=()=>{if(this.jump!==null||this.input.olderFailed||this.requestedHead===this.input.firstSeq)return;let e=this.viewport.readScroll();e===null||e.metrics.top>240||this.loadEarlier()};loadEarlier=()=>{this.input.historyReady&&this.input.hasMore&&!this.input.loadingOlder&&(this.requestedHead=this.input.firstSeq,this.cancel(),this.viewport.beginPaging(),this.reading.pauseFollowing(),this.input.loadOlder())};readerSampled(e){e.movedByReader&&this.jump?.landing===`landed`&&(this.jump.landing=`interrupted`),(e.followingTail||e.movedByReader)&&this.viewport.stopPreserving()}contentCommitted(){if(!this.viewport.preserving||this.reading.pending)return!1;if(this.landJump(!1))return!0;let e=this.viewport.preserve();return e!==null&&(this.reading.preservePosition(e),!0)}readerSettled(){this.input.loadingOlder&&this.jump===null&&!this.viewport.preserving&&!this.reading.followingTail&&this.viewport.beginPreserving()}reconcile(){let e=this.jump;if(!this.input.historyReady||e===null||this.reading.pending)return;if(e.phase===`loading`){e.landing===`pending`&&this.landJump(!1);return}if(this.input.loadingOlder||this.landJump(!0))return;if((this.input.firstSeq===null||this.input.firstSeq>e.seq)&&this.input.hasMore&&e.repageHead!==this.input.firstSeq){e.repageHead=this.input.firstSeq,this.viewport.beginPreserving(),this.request(e);return}let t=this.viewport.scrollToTurnAtOrAfter(e.turn);this.cancel(),t!==null&&this.reading.acceptNavigation(t)}landJump(e){let t=this.jump;if(t===null)return!1;if(t.landing===`interrupted`)return e?(this.cancel(),!0):!1;let n=this.viewport.scrollToTurn(t.turn);return n!==null&&(this.reading.acceptNavigation(n),e?this.cancel():(this.viewport.beginPreserving(n.position),t.landing=`landed`),!0)}request(e){e.phase=`loading`;let t=()=>{this.jump===e&&(e.phase=`settled`,this.cancelFrame(),typeof requestAnimationFrame==`function`?this.settleFrame=requestAnimationFrame(()=>{this.settleFrame=null,this.jump===e&&this.reconcile()}):this.reconcile())};this.input.loadThrough(e.seq).then(t,t)}cancelFrame(){this.settleFrame!==null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.settleFrame),this.settleFrame=null}};function s_(e,t,n){let[r,i]=(0,d.useState)(null),[a]=(0,d.useState)(()=>new o_(e,t,n,i));return(0,d.useLayoutEffect)(()=>{a.setInput(n)},[a,n]),(0,d.useLayoutEffect)(()=>()=>{a.dispose()},[a]),{navigation:a,busyTurn:r}}var c_=class{viewport;store;state;onChange;follow;sampleTimer=null;probeFrame=null;sampled=null;constructor(e,t,n,r,i){this.viewport=e,this.store=t,this.state=n,this.onChange=r,this.follow=i}get pending(){return this.sampleTimer!==null}get followingTail(){return this.state.followingTail}setStore(e){this.store=e}connect(e){return this.sampled=e,()=>{this.sampled===e&&(this.sampled=null)}}dispose(){this.cancelPending(),this.sampled=null}pauseFollowing(){this.cancelPending(),this.publish({...this.state,followingTail:!1})}followTail(){let e=this.viewport.scrollToBottom(this.follow);e!==null&&(this.cancelPending(),this.commit(e,!0,this.viewport.latestTurn))}restore(){let e=this.store.read();if(e===null){this.followTail();return}let t=this.viewport.restore(e);if(t===null)return;this.cancelPending();let n=this.follow.nearBottom(t.metrics);if(this.commit(t,n,n?this.viewport.latestTurn:this.state.activeTurn,n),!this.state.followingTail&&t.position===null){let e=this.viewport.capturePosition();e!==null&&this.store.save(e)}this.refreshActiveTurn()}acceptNavigation(e){this.cancelPending();let t=this.follow.nearBottom(e.metrics);this.commit(e,t,e.turn??(t?this.viewport.latestTurn:this.state.activeTurn))}preservePosition(e){this.cancelPending(),this.commit(e,this.state.followingTail,this.state.activeTurn)}onScroll=e=>{!e.movedByReader&&this.state.followingTail||e.movedByReader&&e.metrics.top>=e.metrics.floor?(this.followTail(),this.sampled?.({position:null,movedByReader:e.movedByReader,followingTail:!0})):this.sampleTimer??=window.setTimeout(this.flushSample,500)};onScrollEnd=()=>{this.flushSample()};onResize(){this.pending||(this.state.followingTail?this.followTail():this.refreshActiveTurn())}refreshActiveTurn(){this.pending||(this.state.followingTail?this.publish({...this.state,initialized:!0,activeTurn:this.viewport.latestTurn}):this.probeFrame===null&&(typeof requestAnimationFrame==`function`?this.probeFrame=requestAnimationFrame(this.probe):this.probe()))}commit(e,t,n,r=!0){t?this.store.save(null):e.position!==null&&this.store.save(e.position),this.publish({initialized:r,followingTail:t,activeTurn:n})}publish(e){this.follow.setFollowing(e.followingTail),(e.initialized!==this.state.initialized||e.followingTail!==this.state.followingTail||e.activeTurn!==this.state.activeTurn)&&(this.state=e,this.onChange(e))}cancelPending(){this.sampleTimer!==null&&window.clearTimeout(this.sampleTimer),this.probeFrame!==null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.probeFrame),this.sampleTimer=null,this.probeFrame=null}probe=()=>{if(this.probeFrame=null,this.pending)return;let e=this.viewport.readScroll();if(e===null)return;let t=this.follow.nearBottom(e.metrics)?this.viewport.latestTurn:this.viewport.readVisibleTurn(e.metrics);this.publish({...this.state,initialized:!0,activeTurn:t})};flushSample=()=>{if(!this.pending)return;this.cancelPending();let e=this.viewport.readScroll();if(e===null)return;let t=this.follow.sample(e.metrics,e.movedByReader),n=null;if(!e.movedByReader&&t)this.followTail();else{n=t?null:this.viewport.capturePosition(),this.viewport.acknowledge(e.metrics),(t||n!==null)&&this.store.save(n);let r=this.follow.nearBottom(e.metrics)?this.viewport.latestTurn:this.viewport.readVisibleTurn(e.metrics);this.publish({initialized:!0,followingTail:t,activeTurn:r})}this.sampled?.({position:n,movedByReader:e.movedByReader,followingTail:t})}};function l_(e,t,n){let[r,i]=(0,d.useState)(()=>({initialized:!1,followingTail:t.read()===null,activeTurn:n})),a=ig(r.followingTail,25),[o]=(0,d.useState)(()=>new c_(e,t,r,i,a));return(0,d.useLayoutEffect)(()=>{o.setStore(t)},[o,t]),(0,d.useLayoutEffect)(()=>()=>{o.dispose()},[o]),{reading:o,state:r}}let u_=[`[data-code-block-controls]`,`[data-selection-actions]`,`[contenteditable='true']`,`textarea`].join(`,`),d_=/* @__PURE__ */ new Set([`BLOCKQUOTE`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`P`,`PRE`]);function f_(e){let t=e.startContainer.ownerDocument;if(t===null)return``;let n=t.createElement(`div`);n.append(e.cloneContents());for(let e of n.querySelectorAll(u_))e.remove();for(let e of n.querySelectorAll(`ol, ul`))e.replaceWith(`
|
|
123
|
+
`,...Array.from(e.childNodes));let r=e.commonAncestorContainer;return __(n,r.nodeType===1?r.tagName:r.parentElement?.tagName??n.tagName).trim()}function p_(e,t){let n=e.getAttribute(`data-selection-answer`);if(!n||t.collapsed||!e.contains(t.startContainer)||!e.contains(t.endContainer))return;let r=0,i=0;for(let n of g_(e)){let e=t.comparePoint(n,n.length);if(n===t.startContainer?r+=t.startOffset:e<0&&(r+=n.length),n===t.endContainer){i+=t.endOffset;break}if(e>0)break;i+=n.length}return i>r&&f_(t)!==``?{answerKey:n,start:r,end:i}:void 0}function m_(e,t,n){if(e.getAttribute(`data-selection-answer`)!==t.answerKey||!Number.isSafeInteger(t.start)||!Number.isSafeInteger(t.end)||t.start<0||t.end<=t.start)return;let r=0,i;for(let a of g_(e)){let o=r+a.length;if(i===void 0&&t.start<o&&(i=e.ownerDocument.createRange(),i.setStart(a,t.start-r)),i!==void 0&&t.end<=o)return i.setEnd(a,t.end-r),f_(i)===n?i:void 0;r=o}}function h_(e,t,n){let r=e.matches(`[data-selection-answer]`)?[e,...e.querySelectorAll(`[data-selection-answer]`)]:Array.from(e.querySelectorAll(`[data-selection-answer]`));for(let e of r){if(e.getAttribute(`data-selection-answer`)!==t.answerKey)continue;let r=m_(e,t,n);if(r!==void 0)return{host:e,range:r}}}function*g_(e){let t=e.ownerDocument.createTreeWalker(e,4);for(let e=t.nextNode();e!==null;e=t.nextNode()){let t=e;t.length>0&&t.parentElement?.closest(u_)==null&&(yield t)}}function __(e,t=e.tagName){let n=``;for(let r of e.childNodes)n+=v_(r,t);return n}function v_(e,t){if(e.nodeType===3)return e.textContent??``;if(e.nodeType!==1)return``;let n=e;switch(n.tagName){case`BR`:return`
|
|
124
|
+
`;case`TABLE`:return`${Array.from(n.querySelectorAll(`tr`)).map(y_).join(`
|
|
125
|
+
`)}\n`;case`TD`:case`TH`:return`${n.previousElementSibling?.matches(`td, th`)?` `:``}${__(n).trimEnd()}`;case`TR`:return`${y_(n)}\n`;case`THEAD`:case`TBODY`:case`TFOOT`:return __(n);case`P`:return b_(n,t);default:{let e=__(n);return d_.has(n.tagName)?`${e}\n`:e}}}function y_(e){return Array.from(e.children).filter(e=>e.tagName===`TH`||e.tagName===`TD`).map(e=>__(e).trim()).join(` `)}function b_(e,t){let n=e.previousElementSibling;return`${n?.tagName===`P`&&n.textContent?.trim()!==``&&e.textContent?.trim()!==``&&t!==`LI`?`
|
|
126
|
+
`:``}${__(e)}\n`}let x_=[`wheel`,`touchstart`,`touchmove`,`touchend`,`touchcancel`,`pointerdown`,`keydown`,`beforematch`],S_=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);var C_=class{elements=null;observer=null;events=null;turns=[];observation={top:0,landing:null};paging=null;touchY=null;attach(e,t){this.detach();let n=e.closest(`[data-conversation-scroll]`)??e,r=n.querySelector(`[data-composer-seat]`),i={list:e,column:t,scroller:n,composer:r};this.elements=i,n.addEventListener(`scroll`,this.onScroll,{passive:!0}),n.addEventListener(`scrollend`,this.onScrollEnd,{passive:!0,capture:!0});for(let e of x_)n.addEventListener(e,this.onIntent,{passive:!0,capture:!0});typeof ResizeObserver<`u`&&(this.observer=new ResizeObserver(()=>{this.elements===i&&(this.invalidate(),this.events?.resize())}),this.observer.observe(t),this.observer.observe(n),r!==null&&this.observer.observe(r))}detach(){this.stopPreserving(),this.elements?.scroller.removeEventListener(`scroll`,this.onScroll),this.elements?.scroller.removeEventListener(`scrollend`,this.onScrollEnd,!0);for(let e of x_)this.elements?.scroller.removeEventListener(e,this.onIntent,!0);this.observer?.disconnect(),this.observer=null,this.elements=null,this.events=null,this.turns=[],this.touchY=null,this.observation={top:0,landing:null}}connect(e){return this.events=e,()=>{this.events===e&&(this.events=null)}}updateTurns(e){this.turns=e}get latestTurn(){return this.turns.at(-1)?.turn??null}invalidate(){this.observation.landing=null}acknowledge(e){this.observation={top:e.top,landing:null}}readScroll(){let e=this.metrics();return e===null?null:{metrics:e,movedByReader:Math.abs(e.top-Math.min(this.observation.top,e.floor))>.5,towardStart:e.top<Math.min(this.observation.top,e.floor)-.5}}metrics(){let e=this.elements?.scroller;return e===void 0?null:ng(e)}anchor(e,t=`position`){if(this.elements===null)return null;let n=null;for(let r of this.elements.list.querySelectorAll(`[data-chat-anchor-key]:not([hidden]):not([hidden] *)`)){if(r.dataset.chatAnchorKey===e||t===`node`&&r.dataset.chatNodeKey===e)return r;n===null&&r.dataset.chatNodeKey===e&&(n=r)}return n}capturePosition(){let e=this.elements;if(e===null)return null;let{list:t,scroller:n,composer:r}=e,i=n.getBoundingClientRect(),a=r?.getBoundingClientRect().top??i.bottom,o=null;if(typeof document.elementsFromPoint==`function`&&a>i.top){let e=t.getBoundingClientRect(),n=Math.max(i.left,e.left),r=Math.min(i.right,e.right);for(let e of document.elementsFromPoint(n+Math.max(0,r-n)/2,i.top+1)){let n=e instanceof HTMLElement?e.closest(`[data-chat-anchor-key]`):null;if(n!==null&&n.dataset.chatFlowKind!==`turn-process`&&t.contains(n)){o=n.dataset.chatGroupKey===void 0?n:n.querySelector(`[data-step-process-content] > [data-chat-anchor-key]:not(:empty:not([data-chat-virtualized])):not([hidden]):not([hidden] *)`)??n;break}}}if(o===null){let e=t.querySelectorAll(`[data-chat-flow-key]:not([data-chat-group-key]):not([data-chat-flow-kind="turn-process"]):not(:empty:not([data-chat-virtualized])):not([hidden]):not([hidden] *)`),n=0,r=e.length;for(;n<r;){let t=n+r>>>1;e.item(t).getBoundingClientRect().bottom>i.top?r=t:n=t+1}let s=e[n];o=s!==void 0&&s.getBoundingClientRect().top<a?s:e[0]??null}let s=o?.dataset.chatAnchorKey;return o===null||s===void 0?null:{anchorKey:s,anchorTop:o.getBoundingClientRect().top-i.top,scrollTop:n.scrollTop}}readVisibleTurn(e=this.metrics()){let t=this.observation.landing?.turn;if(t!=null&&e?.top===this.observation.top)return t;let n=this.elements,r=this.turns[0];if(n===null||e===null||r===void 0)return null;let i=n.scroller.getBoundingClientRect().top+Math.min(96,e.height*.2),a=n.column.children,o=0,s=a.length,c=r.turn;for(;o<s;){let e=o+s>>>1,t=a[e];if(t.getBoundingClientRect().top>i)s=e;else{let n=t.getAttribute(`data-chat-turn`),r=n===null?NaN:Number(n);Number.isSafeInteger(r)&&(c=r),o=e+1}}return c}scrollToTurn(e){let t=this.turns.find(t=>t.turn===e);if(t===void 0)return null;let n=this.anchor(t.anchorKey,`node`);return n===null?null:this.align(n,24,e)}scrollToTurnAtOrAfter(e){if(this.elements===null)return null;for(let t of this.elements.list.querySelectorAll(`[data-chat-turn]:not([hidden]):not([hidden] *)`)){let n=Number(t.dataset.chatTurn);if(Number.isSafeInteger(n)&&n>=e)return this.align(t,24,n)}return null}scrollToResponseAnnotation(e){let t=this.elements,n=e.anchor;if(t===null||n===void 0)return null;let r=h_(t.column,n,e.text);if(r===void 0)return null;let i=Array.from(r.range.getClientRects()).find(e=>e.width!==0||e.height!==0)??(()=>{let e=r.range.getBoundingClientRect();return e.width===0&&e.height===0?void 0:e})(),a=this.metrics();if(i===void 0||a===null)return null;let o=t.scroller.getBoundingClientRect().top,s=r.host.closest(`[data-chat-anchor-key]`),c=r.host.closest(`[data-chat-turn]`)?.getAttribute(`data-chat-turn`),l=c==null?NaN:Number(c),u=Number.isSafeInteger(l)?l:null,d=a.top+i.top-o-a.height*.3;return s===null?this.write(d,a,u):this.write(d,a,u,{key:s.getAttribute(`data-chat-anchor-key`)??void 0,top:s.getBoundingClientRect().top-o})}restore(e){let t=this.anchor(e.anchorKey);if(t!==null)return this.align(t,e.anchorTop,null);let n=this.metrics();return n===null?null:this.write(e.scrollTop,n,null)}beginPaging(){this.stopPreserving();let e=this.elements?.list.querySelector(`[data-chat-paging-anchor]:not(:empty:not([data-chat-virtualized])):not([hidden]):not([hidden] *)`);e!=null&&this.retain(e)}beginPreserving(e=this.capturePosition()){if(this.stopPreserving(),e===null)return;let t=this.anchor(e.anchorKey);t!==null&&this.retain(t,e)}retain(e,t,n){let r=this.elements,i=e.dataset.chatAnchorKey;if(r===null||i===void 0)return null;let a=this.paging?.group;a!=null&&this.observer?.unobserve(a.content);let o=e.getBoundingClientRect().top,s=e.closest(`[data-step-process-body]`),c=s?.querySelector(`[data-step-process-content]`),l=s===null||c==null?null:{body:s,content:c,top:n??o-s.getBoundingClientRect().top};return this.paging={row:e,group:l,position:t??{anchorKey:i,anchorTop:o-r.scroller.getBoundingClientRect().top,scrollTop:r.scroller.scrollTop}},l!==null&&this.observer?.observe(l.content),this.paging}stopPreserving(){let e=this.paging?.group;e!=null&&this.observer?.unobserve(e.content),this.paging=null}get preserving(){return this.paging!==null}preserve(){let e=this.paging,t=this.elements;if(e===null||t===null)return null;if(!t.list.contains(e.row)){let t=this.anchor(e.position.anchorKey);if(t===null)return this.stopPreserving(),null;if(e=this.retain(t,e.position,e.group?.top),e===null)return null}let{row:n,group:r,position:i}=e;if(n.closest(`[hidden]`)!==null||n.matches(`:empty:not([data-chat-virtualized])`))return this.stopPreserving(),null;if(r!==null&&r.body.contains(n)){let e=n.getBoundingClientRect().top-r.body.getBoundingClientRect().top,t=ng(r.body),i=Math.max(0,Math.min(t.floor,t.top+e-r.top));if(t.top!==i){let e=rg.forElement(r.body);e===void 0?r.body.scrollTop=i:(e.jump(r.body,t,i),e.setFollowing(!1))}}let a=this.metrics();if(a===null)return null;let o=n.getBoundingClientRect().top-t.scroller.getBoundingClientRect().top,s=a.top+o-i.anchorTop;return this.write(s,a,null,{key:i.anchorKey,top:o})}scrollToBottom(e){let t=this.metrics();if(t===null||this.elements===null)return null;let n={metrics:t.top>t.floor?t:e.toBottom(this.elements.scroller,t,`instant`),position:null,turn:this.latestTurn};return this.observation={top:n.metrics.top,landing:n},n}align(e,t,n){let r=this.metrics();if(r===null||this.elements===null)return null;let i=e.getBoundingClientRect().top-this.elements.scroller.getBoundingClientRect().top;return this.write(r.top+i-t,r,n,{key:e.dataset.chatAnchorKey,top:i})}write(e,t,n,r){if(this.elements===null)return null;let i=Math.max(0,Math.min(t.floor,e));i!==t.top&&(this.elements.scroller.scrollTop=i);let a=this.elements.scroller.scrollTop,o={metrics:{...t,top:a},turn:n,position:r?.key===void 0?null:{anchorKey:r.key,anchorTop:r.top-(a-t.top),scrollTop:a}};return this.observation={top:a,landing:o},o}onScroll=e=>{if(this.elements===null||e.target!==this.elements.scroller||this.observation.landing!==null&&this.elements.scroller.scrollTop===this.observation.top)return;this.invalidate();let t=this.readScroll();t!==null&&this.events?.scroll(t)};onScrollEnd=e=>{(e.target===this.elements?.scroller||e.target instanceof HTMLElement&&e.target.hasAttribute(`data-step-process-body`))&&this.events?.scrollEnd()};onIntent=e=>{if(e.type===`touchend`||e.type===`touchcancel`){this.touchY=null;return}if(e.target instanceof Element&&e.target.closest(`[data-composer-seat], [data-turn-navigation], input, textarea, [contenteditable="true"]`)||e.type===`keydown`&&(!(e instanceof KeyboardEvent)||!S_.has(e.key)))return;let t=e instanceof WheelEvent?e.deltaY<0:e instanceof KeyboardEvent&&([`ArrowUp`,`PageUp`,`Home`].includes(e.key)||e.key===` `&&e.shiftKey);if(typeof TouchEvent<`u`&&e instanceof TouchEvent){let n=e.touches[0]?.clientY;if(t=e.type===`touchmove`&&n!==void 0&&this.touchY!==null&&n>this.touchY,this.touchY=n??null,e.type===`touchstart`)return}if(!(e instanceof PointerEvent&&e.pointerType===`touch`)){if(t&&e.target instanceof Element){for(let n=e.target;n&&n!==this.elements?.scroller;n=n.parentElement)if(n instanceof HTMLElement&&n.scrollTop>0&&n.scrollHeight>n.clientHeight&&/auto|scroll/.test(getComputedStyle(n).overflowY)){t=!1;break}}this.paging!==null&&!(t&&this.observation.top<=0&&(this.elements?.scroller.scrollTop??0)<=0)&&(this.stopPreserving(),this.events?.interact()),t&&this.events?.olderIntent()}}};function w_(){let e=(0,d.useRef)(null),t=(0,d.useRef)(null),[n]=(0,d.useState)(()=>new C_);return(0,d.useLayoutEffect)(()=>{if(e.current!==null&&t.current!==null)return n.attach(e.current,t.current),()=>{n.detach()}},[n]),{viewport:n,listRef:e,columnRef:t}}function T_(e){let{displayReady:t,historyReady:n,order:r,firstSeq:i,lastKey:a,lastIsUser:o,steeringId:s,submissionId:c,running:l,loadedTurns:u,chatScroll:f,hasMore:p,loadingOlder:m,olderFailed:h,loadOlder:g,loadThrough:_}=e,{viewport:v,listRef:y,columnRef:b}=w_(),{reading:x,state:S}=l_(v,f,u.at(-1)?.turn??null),C=(0,d.useMemo)(()=>({historyReady:n,firstSeq:i,loadingOlder:m,olderFailed:h,hasMore:p,loadOlder:g,loadThrough:_}),[n,i,m,h,p,g,_]),{navigation:w,busyTurn:T}=s_(v,x,C),E=(0,d.useRef)({input:e,applied:null,opened:!1}),D=(0,d.useCallback)(()=>{let e=E.current.input,t=E.current.applied,n=e.lastIsUser&&e.lastKey!==t?.lastKey||e.steeringId!==null&&e.steeringId!==t?.steeringId&&e.steeringId!==t?.submissionId||e.submissionId!==null&&e.submissionId!==t?.submissionId&&e.submissionId!==t?.steeringId;(!x.pending||n)&&(E.current.applied=e,e.displayReady&&!E.current.opened?(E.current.opened=!0,w.reset(),x.restore()):n?(w.cancel(),x.followTail()):w.contentCommitted()?w.reconcile():(t===null||e.displayReady!==t.displayReady||e.firstSeq!==t.firstSeq||e.lastKey!==t.lastKey||e.order.length!==t.order.length||e.running!==t.running||e.steeringId!==t.steeringId||e.submissionId!==t.submissionId)&&x.followingTail?(w.cancel(),x.followTail()):w.reconcile())},[x,w]);(0,d.useLayoutEffect)(()=>{let e=null,t=()=>{e===null&&E.current.opened&&E.current.input.historyReady&&(e=requestAnimationFrame(()=>{e=null,E.current.opened&&E.current.input.historyReady&&w.autoLoadEarlier()}))},n=v.connect({scroll:e=>{x.onScroll(e),e.movedByReader&&e.towardStart&&t()},olderIntent:t,scrollEnd:()=>{x.onScrollEnd(),w.readerSettled()},interact:()=>{w.cancel()},resize:()=>{w.contentCommitted()||x.onResize(),w.reconcile()}}),r=x.connect(e=>{w.readerSampled(e),D()});return()=>{e!==null&&cancelAnimationFrame(e),n(),r(),E.current.opened=!1,E.current.applied=null}},[v,x,w,D]),(0,d.useLayoutEffect)(()=>{let e=E.current.input;E.current.input={displayReady:t,order:r,lastKey:a,lastIsUser:o,steeringId:s,submissionId:c,running:l,loadedTurns:u,chatScroll:f,...C},v.updateTurns(u);let n=e.order!==r||e.displayReady!==t;n&&v.invalidate(),D(),n&&x.refreshActiveTurn()},[v,x,D,C,t,r,a,o,s,c,l,u,f]);let O=(0,d.useCallback)(()=>{w.cancel(),x.followTail()},[w,x]),k=(0,d.useCallback)(()=>{x.followingTail&&!x.pending&&x.followTail()},[x]),ee=(0,d.useCallback)(e=>{w.cancel();let t=v.scrollToResponseAnnotation(e);t!==null&&(x.acceptNavigation(t),E.current.input.loadingOlder&&v.beginPreserving(t.position))},[w,x,v]);return{listRef:y,columnRef:b,...S,busyTurn:T,navigateToTurn:w.navigateToTurn,revealResponseAnnotation:ee,loadEarlier:w.loadEarlier,returnToBottom:O,reconcileTail:k}}let E_=`1200px 0px`,D_=/* @__PURE__ */ new Set;function O_(e){return!Number.isFinite(e)||e<=0?E_:`${Math.max(320,Math.ceil(e*1.5/160)*160)}px 0px`}function k_(e){return e.kind===`group`||e.groupPart===void 0||e.groupPart===`response`?e.key:JSON.stringify([e.key,e.groupPart])}function A_(e){try{let t=JSON.parse(e);if(!Array.isArray(t)||typeof t[0]!=`string`)return null;let[n,r]=t;return r==null||r===`response`?n:JSON.stringify([n,String(r)])}catch{return null}}function j_(e,t,n){let r=A_(e);if(r===null)return null;for(let e of t){if(k_(e)===r)return r;if(e.kind===`node`&&e.key===r)return k_(e)}if(n!==void 0)for(let e of t){if(e.kind!==`group`)continue;let t=n.groupSource(e.key).getSnapshot()?.members;if(t!==void 0&&t.some(e=>k_(e)===r||e.key===r))return e.key}return r}function M_(e){return e.startsWith(`group:`)?e.slice(6):e}function N_(e){return(e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()===`f`}function P_(e){if(typeof e!=`object`||!e)return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable===!0)return!0;if(typeof t.getAttribute==`function`){let e=t.getAttribute(`contenteditable`);if(e===``||e===`true`)return!0}return typeof t.closest==`function`&&t.closest(`[contenteditable=''], [contenteditable='true']`)!==null}function F_(e){return!!(N_(e)||(e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()===`g`||e.key===`F3`||e.key===`Enter`&&!P_(e.target))}function I_(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function L_(e){if(e.childNodes.length===0)return!0;if(e.childElementCount===1){let t=e.firstElementChild;if(t?.hasAttribute(`data-slot`)&&t.childNodes.length===0)return!0}return!1}function R_(e){let t=e.getBoundingClientRect().height;return t>0?t:e.offsetHeight}function z_(e,t,n,r){if(n.hasAttribute(`hidden`)||n.hasAttribute(`data-chat-virtualized`))return;let i=r!==void 0&&r>0?r:R_(n);i>0?e.set(t,Math.round(i)):L_(n)&&e.set(t,0)}function B_(e,t){if(e===null)return null;let n=e instanceof Element?e:e.parentElement;if(n===null||!t.contains(n))return null;for(;n!==null&&n.parentElement!==t;)n=n.parentElement;return n===null||n.parentElement!==t?null:n.getAttribute(`data-chat-flow-key`)}function V_(e,t,n,r){let i=e.childNodes.length;for(let a=t;a>=0&&a<i;a+=n){let t=e.childNodes[a];if(t instanceof Element){let e=t.getAttribute(`data-chat-flow-key`);if(e!==null){let t=r.get(e);if(t!==void 0)return t}}}return null}function H_(e,t,n,r,i){let a=r.childNodes.length;if(a===0)return null;let o=n===`end`?-1:1;if(e===r)return n===`end`&&t<=0||n===`start`&&t>=a?null:V_(r,n===`end`?Math.min(t-1,a-1):Math.max(0,t),o,i);let s=e;for(;s!==null&&s.parentNode!==r;)s=s.parentNode;if(s===null||s.parentNode!==r)return null;if(s instanceof Element){let e=s.getAttribute(`data-chat-flow-key`);if(e!==null)return i.get(e)??null}for(let e=0;e<a;e+=1)if(r.childNodes[e]===s)return V_(r,e+o,o,i);return null}function U_(e,t,n,r){if(e===null||e.rangeCount===0||e.isCollapsed||n.length===0)return null;let i=t.ownerDocument.createRange();t.parentNode===null?i.selectNodeContents(t):i.selectNode(t);let a=1/0,o=-1;for(let s=0;s<e.rangeCount;s+=1){let c=e.getRangeAt(s);if(c.collapsed)continue;let l,u;try{l=c.compareBoundaryPoints(c.END_TO_START,i)<0,u=c.compareBoundaryPoints(c.START_TO_END,i)>0}catch{continue}if(!l||!u)continue;let d=t.contains(c.startContainer),f=t.contains(c.endContainer),p;p=d?H_(c.startContainer,c.startOffset,`start`,t,r):c.compareBoundaryPoints(c.START_TO_START,i)<=0?0:null;let m;m=f?H_(c.endContainer,c.endOffset,`end`,t,r):c.compareBoundaryPoints(c.END_TO_END,i)>=0?n.length-1:null,!(p===null||m===null||p>m)&&(a=Math.min(a,p),o=Math.max(o,m))}if(o<0||!Number.isFinite(a))return null;let s=n[a],c=n[o];return s===void 0||c===void 0?null:{startKey:s,endKey:c}}function W_(e,t){return e===t?!0:e===null||t===null?!1:e.startKey===t.startKey&&e.endKey===t.endKey}function G_(e,t){return e===t?!0:e===null||t===null?!1:e.turn===t.turn&&e.anchorKey===t.anchorKey}function K_(e,t){if(e.size!==t.size)return!0;for(let n of e)if(!t.has(n))return!0;return!1}function q_({sessionId:e,entries:t,nodeStore:n,listRef:r,columnRef:i,editingFlowKey:a=null,revealTargetFlowKey:o=null,savedAnchorFlowKey:s=null,busyTurn:c=null,findLeaseTimeoutMs:l=3e4,findLeaseMaxDurationMs:u=18e4,overscanMargin:f,onTailScrollClamp:p}){let m=typeof IntersectionObserver<`u`,h=t.length>48&&m,g=(0,d.useRef)(e),_=(0,d.useRef)(/* @__PURE__ */ new Map),v=(0,d.useRef)(/* @__PURE__ */ new Map),y=(0,d.useRef)(/* @__PURE__ */ new Set),b=(0,d.useRef)(D_),x=(0,d.useRef)(null),S=(0,d.useRef)(!1),C=(0,d.useRef)(null),w=(0,d.useRef)(/* @__PURE__ */ new Set),T=(0,d.useRef)(null),E=(0,d.useRef)(null),D=(0,d.useRef)(null),O=(0,d.useRef)(null),k=(0,d.useRef)(p);k.current=p,g.current!==e&&(g.current=e,_.current.clear(),y.current=/* @__PURE__ */ new Set,b.current=D_,S.current=!1,E.current=null,D.current=null,O.current=null);let[ee,te]=(0,d.useState)(()=>({sessionId:e,keys:/* @__PURE__ */ new Set})),[A,ne]=(0,d.useState)(()=>({sessionId:e,settled:!1})),[re,ie]=(0,d.useState)(E_),[ae,oe]=(0,d.useState)(()=>({sessionId:e,range:null})),[se,ce]=(0,d.useState)(()=>({sessionId:e,flowKey:null})),[le,ue]=(0,d.useState)(()=>({sessionId:e,target:null})),[de,j]=(0,d.useState)(()=>({sessionId:e,active:!1})),fe=ee.sessionId===e?ee.keys:y.current,pe=h&&A.sessionId===e&&A.settled,me=f??re,he=ae.sessionId===e?ae.range:null,ge=se.sessionId===e?se.flowKey:null,_e=le.sessionId===e?le.target:null,ve=h&&de.sessionId===e&&de.active,{flowKeys:ye,flowKeyToIndex:be}=(0,d.useMemo)(()=>{let e=Array(t.length),n=/* @__PURE__ */ new Map;for(let r=0;r<t.length;r+=1){let i=k_(t[r]);e[r]=i,n.set(i,r)}return{flowKeys:e,flowKeyToIndex:n}},[t]),xe=(0,d.useRef)(ye),Se=(0,d.useRef)(be);xe.current=ye,Se.current=be;let Ce=(0,d.useCallback)(()=>{let e=_.current,t=v.current;for(let n of b.current){let r=t.get(n);r!==void 0&&z_(e,n,r)}},[]),we=(0,d.useCallback)(()=>{T.current!==null&&(clearTimeout(T.current),T.current=null)},[]),Te=(0,d.useCallback)(()=>{we(),E.current=null,Ce(),j(t=>t.sessionId===e&&!t.active?t:{sessionId:e,active:!1})},[we,Ce,e]),Ee=(0,d.useCallback)(t=>{we(),T.current=setTimeout(()=>{T.current=null,E.current=null,Ce(),j(t=>t.sessionId===e&&!t.active?t:{sessionId:e,active:!1})},t)},[we,Ce,e]),De=(0,d.useCallback)(()=>{E.current=Date.now(),j(t=>t.sessionId===e&&t.active?t:{sessionId:e,active:!0}),Ee(Math.min(l,u))},[u,l,Ee,e]),Oe=(0,d.useCallback)(()=>{let e=E.current??Date.now();E.current=e;let t=u-(Date.now()-e);t<=0?Te():Ee(Math.min(l,t))},[u,l,Te,Ee]);(0,d.useEffect)(()=>{if(!h)we(),E.current=null,S.current=!1,j(t=>t.sessionId===e&&!t.active?t:{sessionId:e,active:!1}),ne(t=>t.sessionId===e&&!t.settled?t:{sessionId:e,settled:!1});else return()=>{we()}},[we,h,e]),(0,d.useLayoutEffect)(()=>{if(!h||f!==void 0)return;let e=r.current,t=e?.closest(`[data-conversation-scroll]`)??e??null;if(t===null)return;let n=e=>{let t=O_(e);ie(e=>e===t?e:t)};if(n(t.clientHeight),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(e=>{let r=e.at(-1)?.contentRect.height??t.clientHeight;n(r>0?r:t.clientHeight)});return i.observe(t),()=>{i.disconnect()}},[h,r,f,e]),(0,d.useLayoutEffect)(()=>{if(!h){x.current=null,S.current=!1;return}let t=r.current,n=t?.closest(`[data-conversation-scroll]`)??t??null,i=new IntersectionObserver(t=>{let n=!1,r=new Set(y.current);for(let e of t){let t=e.target;if(!(t instanceof HTMLElement))continue;let i=t.dataset.chatFlowKey;if(i!==void 0){if(e.isIntersecting)r.has(i)||(r.add(i),n=!0);else{if(b.current.has(i)&&!_.current.has(i)){let n=e.boundingClientRect?.height;z_(_.current,i,t,n)}r.has(i)&&(r.delete(i),n=!0)}}}S.current||(S.current=!0,ne(t=>t.sessionId===e&&t.settled?t:{sessionId:e,settled:!0})),n&&(y.current=r,te({sessionId:e,keys:r}))},{root:n,rootMargin:me});x.current=i;for(let e of v.current.values())i.observe(e);return()=>{i.disconnect(),x.current===i&&(x.current=null)}},[me,h,r,e]),(0,d.useEffect)(()=>{if(!h||typeof document>`u`)return;let t=()=>{let t=i.current,n=t===null?null:U_(document.getSelection(),t,xe.current,Se.current);oe(t=>{let r=t.sessionId===e?t.range:null;return W_(r,n)?t:(r!==null&&Ce(),{sessionId:e,range:n})})};return t(),document.addEventListener(`selectionchange`,t),()=>{document.removeEventListener(`selectionchange`,t)}},[i,h,Ce,e]),(0,d.useEffect)(()=>{if(!h||typeof document>`u`)return;let t=i.current;if(t===null)return;let n=t=>{ce(n=>{let r=n.sessionId===e?n.flowKey:null;return r===t?n:(r!==null&&Ce(),{sessionId:e,flowKey:t})})},r=()=>{n(B_(document.activeElement,t))},a=e=>{let r=e.target instanceof Node?e.target:document.activeElement;n(B_(r,t))},o=e=>{e.relatedTarget instanceof Node?n(B_(e.relatedTarget,t)):queueMicrotask(()=>{t.isConnected&&r()})};return r(),t.addEventListener(`focusin`,a),t.addEventListener(`focusout`,o),()=>{t.removeEventListener(`focusin`,a),t.removeEventListener(`focusout`,o)}},[i,h,Ce,e]);let ke=(0,d.useRef)(ve);ke.current=ve,(0,d.useEffect)(()=>{if(!h||typeof window>`u`)return;let e=r.current,t=e?.closest(`[data-conversation-scroll]`)??e??null,n=e=>{N_(e)?De():ke.current&&(e.key===`Escape`?Te():F_(e)&&Oe())},i=()=>{ke.current&&Oe()},a=e=>{ke.current&&P_(e.target)&&Te()},o=()=>{ke.current&&Oe()},s=()=>{if(!ke.current)return;let e=document.getSelection();e!==null&&e.rangeCount>0&&!e.isCollapsed&&Oe()};return window.addEventListener(`keydown`,n,!0),document.addEventListener(`beforematch`,i,!0),document.addEventListener(`focusin`,a,!0),document.addEventListener(`selectionchange`,s),t?.addEventListener(`scroll`,o,{passive:!0}),()=>{window.removeEventListener(`keydown`,n,!0),document.removeEventListener(`beforematch`,i,!0),document.removeEventListener(`focusin`,a,!0),document.removeEventListener(`selectionchange`,s),t?.removeEventListener(`scroll`,o)}},[De,h,r,Te,Oe,e]);let Ae=(0,d.useMemo)(()=>{let e=/* @__PURE__ */ new Set,r=(n,r)=>{let i=Math.min(t.length-1,n+r);for(let t=n;t<=i;t+=1){let n=ye[t];n!==void 0&&e.add(n)}},i=(e,n=0)=>{if(e==null||e===``)return;let i=M_(e),a=be.get(i);if(a!==void 0)r(a,n);else for(let e=0;e<t.length;e+=1){let a=t[e];if(a.kind===`node`&&a.key===i){r(e,n);return}}},l=e=>{if(e!=null)for(let i=0;i<t.length;i+=1){let a=t[i];if(a.kind===`node`&&I_(n.get(a.key))===e){r(i,2);return}}};return a!==null&&e.add(a),ge!==null&&e.add(ge),o!==null&&i(o,0),s!==null&&i(s,2),c!==null&&l(c),_e!==null&&(_e.anchorKey===null?_e.turn!==null&&l(_e.turn):i(_e.anchorKey,2)),e},[c,a,t,be,ye,ge,_e,n,o,s]),je=(0,d.useMemo)(()=>{if(he===null)return null;let e=be.get(he.startKey),t=be.get(he.endKey);return e===void 0||t===void 0?null:e<=t?{start:e,end:t}:{start:t,end:e}},[be,he]),Me=h&&pe&&!ve,Ne=Math.max(0,t.length-10),Pe=Me?fe:null,Fe=Me?Ae:null,Ie=Me?je:null,Le=Me?Ne:0,Re=(0,d.useCallback)((e,t)=>!!(!Me||e>=Le||Pe!==null&&Pe.has(t)||Fe!==null&&Fe.has(t)||Ie!==null&&e>=Ie.start&&e<=Ie.end),[Fe,Ie,Le,Pe,Me]),ze=(0,d.useMemo)(()=>{if(!h)return D_;let e=/* @__PURE__ */ new Set;for(let n=0;n<t.length;n+=1){let t=ye[n];Re(n,t)&&e.add(t)}return e},[h,t.length,ye,Re]);if(D.current=null,O.current=null,h&&b.current.size>0){let e=b.current,t=r.current,n=t?.closest(`[data-conversation-scroll]`)??t??null;if(n!==null&&n.isConnected){let r=Math.max(0,n.scrollHeight-n.clientHeight),i=t?.closest(`[data-chat-following-tail]`)!==null;if(r<=0||r-n.scrollTop<=24||i)i&&r>0&&r-n.scrollTop<=24&&K_(e,ze)&&(O.current=n);else{let t=n.getBoundingClientRect().top,r=v.current,i=!1;for(let n of ze){if(e.has(n))continue;let a=r.get(n);if(a!==void 0&&a.isConnected&&!a.hasAttribute(`hidden`)&&a.getBoundingClientRect().top<t){i=!0;break}}if(i){let i=null,a=1/0,o=null,s=1/0;for(let n of e){if(!ze.has(n))continue;let e=r.get(n);if(e===void 0||!e.isConnected||e.hasAttribute(`hidden`))continue;let c=e.getBoundingClientRect();c.bottom<=t||(c.top>=t&&c.top<a?(i=e,a=c.top):c.top<s&&(o=e,s=c.top))}if(i===null&&o===null)for(let e of r.values()){if(!e.isConnected||e.hasAttribute(`hidden`))continue;let n=e.getBoundingClientRect();n.bottom<=t||n.top>=t&&n.top<a&&(i=e,a=n.top)}let c=i??o,l=i===null?s:a;c!==null&&Number.isFinite(l)&&(D.current={scroller:n,anchorEl:c,prevTop:l,prevScrollTop:n.scrollTop})}}}}(0,d.useLayoutEffect)(()=>{let e=b.current;b.current=ze;let t=O.current;if(O.current=null,t!==null&&t.isConnected){let e=Math.max(0,t.scrollHeight-t.clientHeight);e>0&&e-t.scrollTop>.5&&(k.current===void 0?t.scrollTop=e:k.current())}let n=D.current;if(D.current=null,n!==null&&n.scroller.isConnected&&n.anchorEl.isConnected&&Math.abs(n.scroller.scrollTop-n.prevScrollTop)<=.5){let e=n.anchorEl.getBoundingClientRect().top-n.prevTop;Math.abs(e)>.5&&(n.scroller.scrollTop+=e)}if(!h){C.current?.disconnect(),C.current=null,w.current.clear();return}typeof ResizeObserver<`u`&&C.current===null&&(C.current=new ResizeObserver(e=>{for(let t of e){let e=t.target;if(!(e instanceof HTMLElement))continue;let n=e.dataset.chatFlowKey;if(n===void 0||!b.current.has(n))continue;let r=t.borderBoxSize?.[0]?.blockSize??t.contentRect.height;z_(_.current,n,e,r)}}));let r=C.current,i=w.current,a=v.current;for(let e of Array.from(i)){let t=e.dataset.chatFlowKey;(t===void 0||!ze.has(t)||a.get(t)!==e)&&(r?.unobserve(e),i.delete(e))}for(let t of ze){let n=a.get(t);n!==void 0&&(((r===null?!e.has(t):!i.has(n))||!_.current.has(t))&&z_(_.current,t,n),r!==null&&!i.has(n)&&(r.observe(n),i.add(n)))}},[ze,h]),(0,d.useEffect)(()=>()=>{C.current?.disconnect(),C.current=null,w.current.clear()},[]);let M=(0,d.useCallback)((e,t)=>{let n=v.current,r=n.get(e);r!==void 0&&r!==t&&(x.current?.unobserve(r),C.current?.unobserve(r),w.current.delete(r)),t===null?n.delete(e):(n.set(e,t),x.current?.observe(t),b.current.has(e)&&(z_(_.current,e,t),C.current!==null&&!w.current.has(t)&&(C.current.observe(t),w.current.add(t))))},[]),Be=(0,d.useCallback)((e,t)=>{let n=_.current.get(e);if(n!==void 0)return n;let r=b.current.has(e)?v.current.get(e):void 0;if(r!==void 0&&!r.hasAttribute(`hidden`)&&!r.hasAttribute(`data-chat-virtualized`)){let t=R_(r);if(t>0){let n=Math.round(t);return _.current.set(e,n),n}if(L_(r))return _.current.set(e,0),0}return t===`group`?32:80},[]),Ve=(0,d.useCallback)(e=>{if(!Me)return!0;let n=M_(e),r=be.get(n);if(r!==void 0)return Re(r,n);for(let e=0;e<t.length;e+=1){let r=t[e];if(r.kind===`node`&&r.key===n)return Re(e,ye[e])}return!1},[t,be,ye,Re,Me]),He=(0,d.useCallback)(t=>{ue(n=>{let r=n.sessionId===e?n.target:null;return G_(r,t)?n:(r!==null&&Ce(),{sessionId:e,target:t})})},[Ce,e]),Ue=(0,d.useCallback)(()=>{He(null)},[He]);return(0,d.useMemo)(()=>({active:h,findLeaseActive:ve,isMounted:Re,isAnchorMounted:Ve,placeholderHeight:Be,registerRow:M,pinNavigationTarget:He,clearNavigationPin:Ue}),[Ue,h,ve,Ve,Re,He,Be,M])}function J_(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=J_(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Y_(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=J_(e))&&(r&&(r+=` `),r+=t);return r}let X_=`@deepseek-ai/dsh-client-ui-chat/SelectionActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(X_)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=X_,e.textContent=`._4l2sSq_popover{z-index:30;background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground);border:.5px solid color-mix(in srgb, var(--dsw-alias-label-primary-foreground) 16%, transparent);box-shadow:var(--dsw-shadow-lv3);border-radius:9999px;padding:2px;animation:.14s cubic-bezier(.175,.885,.32,1.275) _4l2sSq_selection-island-in;display:flex;position:fixed;overflow:hidden}._4l2sSq_action{height:24px;color:inherit;font-family:var(--dsw-font-family);letter-spacing:-.01em;white-space:nowrap;cursor:pointer;background:0 0;border:none;border-radius:9999px;align-items:center;gap:5px;padding:0 10px;font-size:12px;font-weight:500;transition:background-color .12s,transform .12s cubic-bezier(.175,.885,.32,1.275);display:inline-flex}._4l2sSq_action+._4l2sSq_action{margin-left:1px;position:relative}._4l2sSq_action+._4l2sSq_action:before{content:"";background:color-mix(in srgb, currentColor 24%, transparent);width:1px;position:absolute;top:5px;bottom:5px;left:-1px}._4l2sSq_action svg{color:currentColor;flex-shrink:0}._4l2sSq_action:hover{background:color-mix(in srgb, currentColor 14%, transparent)}._4l2sSq_action:active{background:color-mix(in srgb, currentColor 22%, transparent);transform:scale(.96)}._4l2sSq_answer{position:relative}::highlight(codexhost-response-annotation){background-color:color-mix(in srgb, var(--dsw-alias-state-business-primary) 16%, transparent);text-decoration:underline color-mix(in srgb, var(--dsw-alias-state-business-primary) 65%, transparent)}::highlight(codexhost-response-annotation-hover){background-color:color-mix(in srgb, var(--dsw-alias-state-business-primary) 30%, transparent);text-decoration:underline var(--dsw-alias-state-business-primary)}._4l2sSq_annotationMark{z-index:1;user-select:none;position:absolute;inset-inline-start:100%}._4l2sSq_annotationMark button{justify-content:center;width:24px;height:24px}._4l2sSq_annotationNumber{box-sizing:border-box;background:color-mix(in srgb, var(--dsw-alias-state-business-primary) 14%, var(--dsw-alias-bg-base));min-width:18px;min-height:18px;color:var(--dsw-alias-state-business-primary);font-variant-numeric:tabular-nums;border-radius:999px;place-items:center;padding:0 5px;font-size:10.5px;font-weight:600;line-height:1;transition:background-color .12s,transform .12s;display:inline-grid}._4l2sSq_annotationNumberHovered{background:color-mix(in srgb, var(--dsw-alias-state-business-primary) 28%, var(--dsw-alias-bg-base));transform:scale(1.1)}@keyframes _4l2sSq_selection-island-in{0%{opacity:0;scale:.9}to{opacity:1;scale:1}}@media (prefers-reduced-motion:reduce){._4l2sSq_popover{animation:none}._4l2sSq_action,._4l2sSq_annotationNumber{transition:none}}`,document.head.appendChild(e)}var Z_={action:`_4l2sSq_action`,annotationMark:`_4l2sSq_annotationMark`,annotationNumber:`_4l2sSq_annotationNumber`,annotationNumberHovered:`_4l2sSq_annotationNumberHovered`,answer:`_4l2sSq_answer`,popover:`_4l2sSq_popover`,"selection-island-in":`_4l2sSq_selection-island-in`};let Q_=`codexhost-response-annotation`;function $_(e){let t=e.getClientRects();for(let e=t.length-1;e>=0;--e){let n=t[e];if(n!==void 0&&(n.width!==0||n.height!==0))return n}let n=e.getBoundingClientRect();return n.width===0&&n.height===0?void 0:n}function ev(e,t=Q_,n=0){let r=globalThis.CSS?.highlights;if(e.length===0||r===void 0||typeof Highlight>`u`)return()=>{};let i=r.get(t)??new Highlight;i.priority=n;for(let t of e)i.add(t);return r.set(t,i),()=>{for(let t of e)i.delete(t);i.size===0&&r.get(t)===i&&r.delete(t)}}let tv=[];function nv({answer:e,answerKey:t,useInput:n,inputActions:r,labels:i}){let a=n(e=>e.responseAnnotations),o=n(e=>{let n=e.hoveredResponseAnnotationId;if(n!==void 0)return e.responseAnnotations?.some(e=>e.id===n&&e.anchor?.answerKey===t)?n:void 0}),s=(0,d.useMemo)(()=>a?.flatMap((e,n)=>e.anchor?.answerKey===t?[{annotation:e,index:n+1}]:[]),[a,t]),[c,l]=(0,d.useState)(tv),u=(0,d.useRef)([]),[m,h]=(0,d.useState)(0),g=(0,d.useRef)(null),_=(0,d.useRef)(r);return _.current=r,(0,d.useEffect)(()=>()=>{g.current!==null&&(g.current=null,_.current?.hoverResponseAnnotation(null))},[]),(0,d.useLayoutEffect)(()=>{let t=e.current;if(t===null||s===void 0||s.length===0){u.current=[],l(tv),h(e=>e+1);return}let n=()=>{},r=()=>{if(!t.isConnected)return;let e=t.getBoundingClientRect().top,n=u.current.flatMap(({annotation:t,index:n,range:r})=>{let i=$_(r);return i===void 0?[]:[{annotation:t,index:n,top:i.top-e+(i.height-24)/2}]});n.sort((e,t)=>e.top-t.top);let r=0,i=n.length===0?tv:n.map(e=>{let t=Math.max(e.top,r);return r=t+24+2,{...e,top:t}});l(e=>e.length===i.length&&e.every((e,t)=>e.annotation===i[t]?.annotation&&e.index===i[t]?.index&&Math.abs(e.top-(i[t]?.top??0))<.5)?e:i)},i=()=>{n(),n=()=>{},t.isConnected?(u.current=s.flatMap(e=>{let{anchor:n,text:r}=e.annotation,i=n&&m_(t,n,r);return i===void 0?[]:[{...e,range:i}]}),n=ev(u.current.map(({range:e})=>e),Q_),h(e=>e+1),r()):(u.current=[],l(tv),h(e=>e+1))};i();let a=typeof ResizeObserver>`u`?null:new ResizeObserver(r);a?.observe(t);let o=typeof MutationObserver>`u`?null:new MutationObserver(i),c=t.firstElementChild;return c!==null&&!c.hasAttribute(`data-selection-actions`)&&o?.observe(c,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`,`open`]}),t.addEventListener(`scroll`,r,!0),()=>{n(),n=()=>{},u.current=[],a?.disconnect(),o?.disconnect(),t.removeEventListener(`scroll`,r,!0)}},[e,s]),(0,d.useLayoutEffect)(()=>{if(o!==void 0)return ev(u.current.filter(({annotation:e})=>e.id===o).map(({range:e})=>e),`codexhost-response-annotation-hover`,1)},[o,m]),c.map(({annotation:e,index:t,top:n})=>{let a=o===e.id;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:Z_.annotationMark,style:{top:n},"data-selection-actions":!0,onPointerEnter:t=>{t.pointerType!==`touch`&&(g.current=e.id,r?.hoverResponseAnnotation(e.id))},onPointerLeave:t=>{t.pointerType!==`touch`&&(g.current===e.id&&(g.current=null),r?.hoverResponseAnnotation(null))},onFocus:t=>{t.target instanceof Element&&t.target.matches(`:focus-visible`)&&(g.current=e.id,r?.hoverResponseAnnotation(e.id))},onBlur:t=>{!t.currentTarget.contains(t.relatedTarget)&&o===e.id&&(g.current===e.id&&(g.current=null),r?.hoverResponseAnnotation(null))},children:/* @__PURE__ */ (0,f.jsx)(p.ResponseAnnotationPopover,{annotation:e,labels:i,title:i.label(t),anchor:/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y_(Z_.annotationNumber,a&&Z_.annotationNumberHovered),"data-hovered":a||void 0,"aria-label":i.label(t),children:t})})},e.id)})}let rv=`@deepseek-ai/dsh-client-ui-chat/SelectionCommentCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(rv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=rv,e.textContent=`.lPRhsq_card{z-index:30;box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-specific-input-major);width:344px;box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);border-radius:16px;flex-direction:column;gap:8px;padding:12px;animation:.14s cubic-bezier(.175,.885,.32,1.275) lPRhsq_selection-comment-in;display:flex;position:fixed}.lPRhsq_header{align-items:flex-start;gap:8px;display:flex}.lPRhsq_excerpt{border-left:2px solid var(--dsw-alias-border-l3);min-width:0;color:var(--dsw-alias-label-tertiary);-webkit-line-clamp:2;overflow-wrap:anywhere;-webkit-box-orient:vertical;flex:auto;margin:0;padding-left:9px;font-size:12px;line-height:17px;display:-webkit-box;overflow:hidden}.lPRhsq_close{width:22px;height:22px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:0;border-radius:6px;flex:none;place-items:center;margin:-3px -4px 0 0;padding:0;transition:background-color .11s,color .11s;display:inline-grid}@media (hover:hover) and (pointer:fine){.lPRhsq_close:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}}.lPRhsq_close:focus-visible{outline:1.5px solid var(--dsw-alias-state-business-primary);outline-offset:0}.lPRhsq_inputRow{align-items:flex-end;gap:8px;display:flex}.lPRhsq_field{box-sizing:border-box;field-sizing:content;min-width:0;min-height:28px;max-height:116px;color:var(--dsw-alias-label-primary);font:inherit;resize:none;background:0 0;border:0;outline:none;flex:auto;padding:4px 0;font-size:13px;line-height:19px}.lPRhsq_field::placeholder{color:var(--dsw-alias-label-tertiary)}.lPRhsq_submit{background:var(--dsw-alias-button-primary-fill);height:28px;color:var(--dsw-alias-label-primary-foreground);font:inherit;white-space:nowrap;cursor:pointer;touch-action:manipulation;user-select:none;-webkit-tap-highlight-color:transparent;border:0;border-radius:9999px;flex:none;justify-content:center;align-items:center;gap:5px;padding:0 12px;font-size:12px;font-weight:500;line-height:16px;transition:background-color .12s,opacity .12s,transform .12s cubic-bezier(.175,.885,.32,1.275);display:inline-flex}@media (hover:hover) and (pointer:fine){.lPRhsq_submit:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}}.lPRhsq_submit:disabled{opacity:.35;cursor:default}.lPRhsq_submit:not(:disabled):active{transform:scale(.96)}.lPRhsq_kbd{color:currentColor;opacity:.72;background:0 0;border:0;justify-content:center;align-items:center;padding:0;font-family:inherit;font-size:11px;font-weight:500;line-height:1;display:inline-flex}.lPRhsq_error{color:var(--dsw-alias-state-error-primary);font-size:11.5px;line-height:16px}@media (hover:none),(pointer:coarse){.lPRhsq_card{width:min(344px,100vw - 16px)}.lPRhsq_field{font-size:16px;line-height:22px}.lPRhsq_submit{height:32px;padding:0 14px;font-size:13px}.lPRhsq_kbd{display:none}}@keyframes lPRhsq_selection-comment-in{0%{opacity:0;scale:.96}to{opacity:1;scale:1}}@media (prefers-reduced-motion:reduce){.lPRhsq_card{animation:none}.lPRhsq_submit,.lPRhsq_close{transition:none}}`,document.head.appendChild(e)}var iv={card:`lPRhsq_card`,close:`lPRhsq_close`,error:`lPRhsq_error`,excerpt:`lPRhsq_excerpt`,field:`lPRhsq_field`,header:`lPRhsq_header`,inputRow:`lPRhsq_inputRow`,kbd:`lPRhsq_kbd`,"selection-comment-in":`lPRhsq_selection-comment-in`,submit:`lPRhsq_submit`};function av(){return typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`field-sizing`,`content`)}function ov({excerpt:e,labels:t,fieldRef:n,style:r,below:i,onSubmit:a,onCancel:o}){let[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(!1),m=(0,d.useRef)(null),h=s.trim();(0,d.useEffect)(()=>{n.current?.focus({preventScroll:!0});let e=(0,p.observeComposition)(document);return m.current=e,()=>{e.dispose(),m.current===e&&(m.current=null)}},[n]),(0,d.useLayoutEffect)(()=>{let e=n.current;e===null||av()||(e.style.height=`auto`,e.style.height=`${String(Math.min(e.scrollHeight,116))}px`)},[n,s]);let g=()=>{h!==``&&!a(h)&&u(!0)};return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:iv.card,role:`dialog`,"aria-label":t.placeholder,"data-placement":i?`below`:`above`,style:r,"data-selection-actions":!0,onKeyDown:e=>{e.key===`Escape`&&m.current?.guards(e.nativeEvent)!==!0&&(e.preventDefault(),e.stopPropagation(),o())},onMouseDown:e=>{e.target!==n.current&&e.preventDefault()},children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:iv.header,children:[/* @__PURE__ */ (0,f.jsx)(`blockquote`,{className:iv.excerpt,children:e.replace(/\s+/gu,` `)}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:iv.close,"aria-label":t.cancel,title:t.cancel,onClick:o,children:/* @__PURE__ */ (0,f.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M2.5 2.5l7 7M9.5 2.5l-7 7`})})})]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:iv.inputRow,children:[/* @__PURE__ */ (0,f.jsx)(`textarea`,{ref:n,className:iv.field,rows:1,value:s,placeholder:t.placeholder,"aria-label":t.placeholder,onChange:e=>{c(e.target.value)},onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||m.current?.guards(e.nativeEvent)!==!0&&(e.preventDefault(),g())}}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:iv.submit,disabled:h===``,onClick:g,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:t.submit}),/* @__PURE__ */ (0,f.jsx)(`kbd`,{className:iv.kbd,"aria-hidden":`true`,children:`↵`})]})]}),l&&/* @__PURE__ */ (0,f.jsx)(`div`,{role:`alert`,className:iv.error,children:t.unavailable})]})}function sv(e){return e instanceof Element?e:e.parentElement}function cv(e){if(e===null||typeof window>`u`)return null;let t=window.getSelection();if(t===null||t.rangeCount===0||t.isCollapsed)return null;let n=t.getRangeAt(0),r=sv(n.startContainer),i=sv(n.endContainer),a=r?.closest(`[data-selection-answer]`);if(a==null||!e.contains(a)||i?.closest(`[data-selection-answer]`)!==a||a.hasAttribute(`data-selection-answer-streaming`)||r?.closest(u_)!=null||i?.closest(u_)!=null)return null;let o=f_(n),s=$_(n);return o===``||s===void 0?null:{text:o,rect:s,range:n.cloneRange(),host:a}}function lv(e){let t=window.getSelection();t!==null&&e.contains(t.anchorNode)&&e.contains(t.focusNode)&&t.removeAllRanges()}function uv(e,t=0){let n=window.visualViewport,r=n?.width??window.innerWidth,i=n?.offsetLeft??0,a=e.right-i,o=window.matchMedia(`(hover: none)`).matches,s=n?.offsetTop??0,c=s+(n?.height??window.innerHeight),l=e.top-8-t>=s+8,u=e.bottom+8+t<=c-8,d=t===0?o:o?u||!l:!l&&u,f=r-8-a,p=d?e.bottom+8:e.top-8,m=s+8+(d?0:t),h=c-8-(d?t:0);return{left:e.right,top:t===0?p:Math.max(m,Math.min(p,h)),maxWidth:r-16,transform:`translateX(clamp(${String(8-a)}px, -100%, calc(${String(f)}px - 100%)))`+(d?``:` translateY(-100%)`),below:d}}function dv({labels:e,onAdd:t,container:n}){let[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(null),s=(0,d.useRef)(null),c=(0,d.useRef)(!1),l=(0,d.useRef)(null),u=(0,d.useRef)(!1),p=(0,d.useRef)(null),m=(0,d.useRef)(null),g=(0,d.useCallback)(e=>{m.current=e,i(e)},[]),_=(0,d.useCallback)(()=>{c.current=!1,o(null)},[]),v=(0,d.useCallback)(()=>{if(l.current=null,u.current||c.current)return;let e=cv(n.current),t=p.current;e!==null&&t!==null&&e.host===t.host&&e.text===t.text?g(null):((e===null||t===null||e.host!==t.host||e.text!==t.text)&&(p.current=null),g(e))},[n,g]),y=(0,d.useCallback)(()=>{l.current===null&&(l.current=window.requestAnimationFrame(v))},[v]);(0,d.useEffect)(()=>{let e=()=>{u.current=!1,y()},t=e=>{let t=e.target;(t instanceof Element?t:t instanceof Node?t.parentElement:null)?.closest(`[data-selection-actions]`)??(u.current=!0,p.current=null,g(null),_())},n=()=>{let e=window.getSelection();e===null||e.rangeCount===0||e.isCollapsed?(p.current=null,g(null)):y()},r=e=>{let t=e.target;if(t instanceof Element&&t.closest(`[data-selection-actions]`)!==null)return;let n=s.current;(n===null||n!==document.activeElement&&n.value===``)&&(g(null),_())},i=e=>{let t=m.current;e.key!==`Escape`||e.defaultPrevented||e.isComposing||c.current||t===null||(e.preventDefault(),p.current={host:t.host,text:t.text},g(null))};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`pointerup`,e,!0),document.addEventListener(`pointercancel`,e,!0),document.addEventListener(`selectionchange`,n),document.addEventListener(`keydown`,i),window.addEventListener(`keyup`,y),window.addEventListener(`scroll`,r,!0),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`pointerup`,e,!0),document.removeEventListener(`pointercancel`,e,!0),document.removeEventListener(`selectionchange`,n),document.removeEventListener(`keydown`,i),window.removeEventListener(`keyup`,y),window.removeEventListener(`scroll`,r,!0),l.current!==null&&window.cancelAnimationFrame(l.current),l.current=null}},[y,_,g]);let b=a?.rect,x=a?.range;(0,d.useEffect)(()=>{if(b===void 0||x===void 0)return;let e=window.visualViewport,t=s.current?.closest(`[data-selection-actions]`),n=()=>{let e=t?.offsetHeight??104,n=uv(b,e);o(e=>e?.rect===b?{...e,placement:n}:e)},r=ev([x]),i=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return t!=null&&i?.observe(t),window.addEventListener(`resize`,n),e?.addEventListener(`resize`,n),e?.addEventListener(`scroll`,n,{passive:!0}),n(),()=>{r(),i?.disconnect(),window.removeEventListener(`resize`,n),e?.removeEventListener(`resize`,n),e?.removeEventListener(`scroll`,n)}},[b,x]);let S=e=>e.host.isConnected&&n.current?.contains(e.host)===!0;if(a!==null){let n=a.placement;return(0,h.createPortal)(/* @__PURE__ */ (0,f.jsx)(ov,{excerpt:a.text,labels:e,fieldRef:s,below:n.below,style:{left:n.left,top:n.top,maxWidth:n.maxWidth,transform:`${n.transform} translateZ(0)`},onSubmit:e=>!S(a)||!t(a.anchor===void 0?{text:a.text,annotation:e}:{text:a.text,annotation:e,anchor:a.anchor})?!1:(lv(a.host),_(),!0),onCancel:_}),document.body)}if(r===null)return null;let C=uv(r.rect),w=()=>r.host.isConnected&&n.current?.contains(r.host)===!0;return(0,h.createPortal)(/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z_.popover,"data-placement":C.below?`below`:`above`,style:{left:C.left,top:C.top,maxWidth:C.maxWidth,transform:`${C.transform} translateZ(0)`},"data-selection-actions":!0,onPointerDown:e=>{e.preventDefault()},children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z_.action,onClick:()=>{if(!w())return;let e=p_(r.host,r.range);t(e===void 0?{text:r.text}:{text:r.text,anchor:e})&&(lv(r.host),g(null))},children:[/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M12 7v6`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M9 10h6`})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:e.addToChat})]}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Z_.action,onClick:()=>{if(!w())return;let e=p_(r.host,r.range);lv(r.host),c.current=!0,o({...r,anchor:e,placement:uv(r.rect,104)}),g(null)},children:/* @__PURE__ */ (0,f.jsx)(`span`,{children:e.comment})})]}),document.body)}let fv=`@deepseek-ai/dsh-client-ui-chat/ChatMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(fv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=fv,e.textContent=`.DT2SAW_linkMenu[data-menu-material]{--link-menu-fill:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 68%, var(--dsw-alias-bg-overlay));--dsw-menu-surface-fill:color-mix(in srgb, var(--link-menu-fill) 78%, transparent);--dsw-menu-backdrop-filter:blur(20px) saturate(140%);--dsw-alias-interactive-bg-hover:color-mix(in srgb, var(--dsw-alias-link) 18%, transparent);--dsw-alias-menu-icon:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l4);min-width:148px;padding:4px;box-shadow:inset 0 1px #fff3,0 2px 5px #0000001a,0 9px 22px #0000002e}.DT2SAW_linkMenu[data-menu-material] [role=menuitem]{min-height:24px;font:500 13px/18px var(--dsw-font-family);border-radius:6px;gap:8px;padding:2px 8px}.DT2SAW_linkMenu[data-menu-material] [role=menuitem]>span:has(>svg),.DT2SAW_linkMenu[data-menu-material] [role=menuitem] svg{width:14px;height:14px}@media (pointer:coarse){.DT2SAW_linkMenu[data-menu-material] [role=menuitem]{min-height:44px}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){.DT2SAW_linkMenu[data-menu-material]{--dsw-menu-surface-fill:var(--link-menu-fill);--dsw-menu-backdrop-filter:none}}@media (forced-colors:active){.DT2SAW_linkMenu[data-menu-material]{--dsw-menu-surface-fill:Canvas;--dsw-menu-backdrop-filter:none;border-color:canvastext}.DT2SAW_linkMenu[data-menu-material] [role=menuitem]:is(:hover,:focus-visible){outline-offset:-1px;outline:1px solid highlight}}`,document.head.appendChild(e)}var pv={linkMenu:`DT2SAW_linkMenu`};function mv({children:e,openFile:t,openLinkInSidebar:n,hideLocalFileActions:r=!1,t:i,...a}){let[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(!1),u=(0,d.useCallback)(()=>s(null),[]),m=(0,d.useCallback)(()=>o?.position??null,[o]),h=(0,d.useCallback)(e=>i(`codeBlock.expand`,{count:e}),[i]),g=i(`codeBlock.collapse`);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.MarkdownDelegateProvider,{collapsibleCodeBlocks:!0,expandCodeLabel:h,collapseCodeLabel:g,...a,openFile:t,onLinkContextMenu:s,children:e}),/* @__PURE__ */ (0,f.jsx)(p.Menu,{anchor:null,open:o!==null,portal:!0,compact:!0,autoFocus:!0,listClassName:pv.linkMenu,getAnchorRect:m,focusReturnTarget:o?.trigger,onClose:u,children:o!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[(o.kind===`file`||n!==void 0)&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:o.kind===`file`?/* @__PURE__ */ (0,f.jsx)(p.LinkIconMedium,{kind:`document`}):/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineMedium,{}),onSelect:()=>{u(),o.kind===`file`?t(o.path,o.line===void 0?void 0:{line:o.line}):n?.(o.href)},children:i(`linkMenu.openInCodexhost`)}),/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconLinkOutlineMedium,{}),onSelect:()=>{u(),(0,p.writeClipboard)(o.href).then(e=>l(!e))},children:i(`linkMenu.copy`)}),(o.kind===`web`||!r)&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconRightUpOutlineMedium,{}),onSelect:()=>{u(),o.kind===`web`?window.open(o.href,`_blank`,`noopener,noreferrer`):t(o.path,{external:!0,...o.line===void 0?{}:{line:o.line}})},children:i(o.kind===`web`?`linkMenu.openBrowser`:`linkMenu.openFile`)}),o.kind===`file`&&!r&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconFolderOpenOutlineMedium,{}),onSelect:()=>{u(),t(o.path,{reveal:!0})},children:i(`linkMenu.openFolder`)})]})}),c&&/* @__PURE__ */ (0,f.jsx)(p.Toast,{text:i(`linkMenu.copyFailed`),onDone:()=>l(!1)})]})}let hv=`@deepseek-ai/dsh-client-ui-chat/HandoffDivider.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(hv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=hv,e.textContent=`.SfZcya_root{flex-direction:column;gap:10px;width:100%;min-width:0;padding:6px 0 8px;display:flex}.SfZcya_dividerBar{align-items:center;gap:10px;width:100%;min-width:0;display:flex}.SfZcya_line{background:var(--dsw-alias-border-l2);opacity:.72;flex:20px;min-width:12px;height:1px}.SfZcya_trigger{border-radius:var(--dsw-radius-sm,8px);min-width:0;max-width:calc(100% - 36px);color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size-secondary,13px);cursor:pointer;background:0 0;border:none;flex-wrap:wrap;justify-content:center;align-items:center;gap:4px 7px;padding:4px 10px;line-height:20px;transition:background-color .12s,color .12s;display:inline-flex}.SfZcya_trigger:hover,.SfZcya_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}.SfZcya_trigger:focus-visible{outline:2px solid var(--dsw-alias-link);outline-offset:1px}.SfZcya_titleGroup{color:var(--dsw-alias-label-tertiary);flex-shrink:0;align-items:center;gap:5px;display:inline-flex}.SfZcya_swapIcon{opacity:.85;flex-shrink:0}.SfZcya_endpoints{flex-wrap:wrap;justify-content:center;align-items:center;gap:2px 6px;min-width:0;max-width:100%;display:inline-flex}.SfZcya_endpoint{align-items:center;gap:5px;min-width:0;max-width:100%;display:inline-flex}.SfZcya_sourceLabel{color:var(--dsw-alias-label-secondary);text-overflow:ellipsis;white-space:nowrap;max-width:240px;font-weight:450;overflow:hidden}.SfZcya_arrow{color:var(--dsw-alias-label-caption);flex-shrink:0;font-size:12px;line-height:1}.SfZcya_targetLabel{color:color-mix(in srgb, var(--dsw-alias-link) 82%, var(--dsw-alias-label-secondary));text-overflow:ellipsis;white-space:nowrap;max-width:240px;font-weight:500;overflow:hidden}.SfZcya_chevron{color:var(--dsw-alias-label-caption);opacity:.55;flex-shrink:0;align-items:center;transition:transform .14s,opacity .12s;display:inline-flex}.SfZcya_trigger:hover .SfZcya_chevron,.SfZcya_trigger[aria-expanded=true] .SfZcya_chevron{opacity:.95}.SfZcya_chevronOpen{transform:rotate(180deg)}.SfZcya_panel{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md,10px);background:var(--dsw-alias-bg-module-platform);flex-direction:column;gap:10px;min-width:0;padding:12px 14px;display:flex}body[data-codexhost-wallpaper] .SfZcya_panel{background:color-mix(in srgb, var(--dsw-alias-bg-module-platform) 84%, transparent);backdrop-filter:blur(12px)}.SfZcya_panelHeader{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px;display:flex}.SfZcya_turnSummary{color:var(--dsw-alias-label-secondary);font-size:12.5px;line-height:18px}.SfZcya_sourceButton{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;flex-shrink:0;align-items:center;gap:5px;padding:4px 10px;font-size:12px;font-weight:500;line-height:16px;transition:background-color .12s,border-color .12s;display:inline-flex}.SfZcya_sourceButton:hover{background:var(--dsw-alias-interactive-bg-hover-solid);border-color:var(--dsw-alias-border-l3)}.SfZcya_sourceButton:focus-visible{outline:2px solid var(--dsw-alias-link);outline-offset:1px}.SfZcya_preview{border:1px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-base);max-height:260px;color:var(--dsw-alias-label-secondary);white-space:pre-wrap;overflow-wrap:anywhere;margin:0;padding:10px 12px;font-family:inherit;font-size:12.5px;line-height:1.55;overflow-y:auto}.SfZcya_previewEmpty{color:var(--dsw-alias-label-tertiary);font-style:italic}@media (width<=520px){.SfZcya_dividerBar{gap:6px}.SfZcya_line{flex-basis:10px;min-width:8px}.SfZcya_trigger{column-gap:5px;max-width:calc(100% - 28px);padding:4px 6px;font-size:12px;line-height:18px}.SfZcya_sourceLabel,.SfZcya_targetLabel{max-width:148px}.SfZcya_panel{padding:10px 12px}}`,document.head.appendChild(e)}var gv={arrow:`SfZcya_arrow`,chevron:`SfZcya_chevron`,chevronOpen:`SfZcya_chevronOpen`,dividerBar:`SfZcya_dividerBar`,endpoint:`SfZcya_endpoint`,endpoints:`SfZcya_endpoints`,line:`SfZcya_line`,panel:`SfZcya_panel`,panelHeader:`SfZcya_panelHeader`,preview:`SfZcya_preview`,previewEmpty:`SfZcya_previewEmpty`,root:`SfZcya_root`,sourceButton:`SfZcya_sourceButton`,sourceLabel:`SfZcya_sourceLabel`,swapIcon:`SfZcya_swapIcon`,targetLabel:`SfZcya_targetLabel`,titleGroup:`SfZcya_titleGroup`,trigger:`SfZcya_trigger`,turnSummary:`SfZcya_turnSummary`};let _v=(0,d.memo)(function({handoff:e,hostId:t,onOpenSource:n,t:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useId)(),s=Gm({harnessId:e.sourceHarnessId,harnessLabel:e.sourceHarnessLabel,model:e.sourceModel}),c=Gm({harnessId:e.targetHarnessId,harnessLabel:e.targetHarnessLabel,model:e.targetModel}),l=e.includedTurnNumbers.length,u=e.omittedTurns>0?r(`handoff.divider.turnsPartial`,{included:l,total:e.totalTurns,omitted:e.omittedTurns,boundary:e.boundaryTurnNumber}):e.boundaryTurnNumber<e.totalTurns?r(`handoff.divider.turnsPrefix`,{boundary:e.boundaryTurnNumber,total:e.totalTurns}):r(`handoff.divider.turnsAll`,{total:e.totalTurns}),m=e.preview.trim();return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:gv.root,"data-handoff-divider":``,"aria-label":r(`handoff.divider.label`),children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:gv.dividerBar,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:gv.line,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:gv.trigger,"aria-expanded":i,"aria-controls":o,"aria-label":r(i?`handoff.divider.collapse`:`handoff.divider.expand`),onClick:()=>{a(e=>!e)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:gv.titleGroup,children:[/* @__PURE__ */ (0,f.jsx)(qm,{size:14,className:gv.swapIcon}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:r(`handoff.divider.label`)})]}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:gv.endpoints,children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:gv.endpoint,title:s.title,children:[/* @__PURE__ */ (0,f.jsx)(Jm,{harnessId:e.sourceHarnessId,label:e.sourceHarnessLabel??e.sourceHarnessId,hostId:t,size:15}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:gv.sourceLabel,children:s.display})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:gv.arrow,"aria-hidden":`true`,children:`→`}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:gv.endpoint,title:c.title,children:[/* @__PURE__ */ (0,f.jsx)(Jm,{harnessId:e.targetHarnessId,label:e.targetHarnessLabel??e.targetHarnessId,hostId:t,size:15}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:gv.targetLabel,children:c.display})]})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:i?`${gv.chevron} ${gv.chevronOpen}`:gv.chevron,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:12})})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:gv.line,"aria-hidden":`true`})]}),i&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:o,className:gv.panel,"data-handoff-panel":``,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:gv.panelHeader,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:gv.turnSummary,children:u}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:gv.sourceButton,onClick:()=>{n(e.sourceThreadId)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:r(`handoff.divider.openSource`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]})]}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:m===``?`${gv.preview} ${gv.previewEmpty}`:gv.preview,children:m===``?r(`handoff.divider.previewEmpty`):e.preview})]})]})}),vv=`@deepseek-ai/dsh-client-ui-chat/HandoffModal.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(vv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=vv,e.textContent=`.psMsOW_dialog{width:min(440px,100%)}.psMsOW_sections{flex-direction:column;gap:16px;min-width:0;display:flex}.psMsOW_section{flex-direction:column;gap:8px;min-width:0;display:flex}.psMsOW_sectionLabel{color:var(--dsw-alias-label-secondary);font-size:12.5px;font-weight:500;line-height:18px}.psMsOW_harnessGrid{grid-template-columns:repeat(auto-fill,minmax(128px,1fr));gap:8px;display:grid}.psMsOW_harnessOption{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,8px);background:var(--dsw-alias-bg-base);min-width:0;color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer;align-items:center;gap:8px;padding:8px 10px;font-size:13px;line-height:18px;transition:background-color .12s,border-color .12s;display:flex}.psMsOW_harnessOption:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);border-color:var(--dsw-alias-border-l3)}.psMsOW_harnessOption[data-selected]{border-color:var(--dsw-alias-link);background:color-mix(in srgb, var(--dsw-alias-link) 10%, var(--dsw-alias-bg-base))}.psMsOW_harnessOption:disabled{opacity:.55;cursor:default}.psMsOW_harnessName{text-overflow:ellipsis;white-space:nowrap;flex:auto;min-width:0;font-weight:500;overflow:hidden}.psMsOW_checkIcon{color:var(--dsw-alias-link);flex-shrink:0}.psMsOW_searchInput{width:100%}.psMsOW_modelList{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,8px);background:var(--dsw-alias-bg-module-platform);flex-direction:column;gap:4px;max-height:216px;padding:4px;display:flex;overflow-y:auto}.psMsOW_modelOption{border-radius:var(--dsw-radius-sm,6px);width:100%;min-width:0;color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer;background:0 0;border:none;justify-content:space-between;align-items:center;gap:8px;padding:7px 10px;font-size:13px;line-height:18px;transition:background-color .1s;display:flex}.psMsOW_modelOption:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.psMsOW_modelOption[data-selected]{background:var(--dsw-alias-bg-base);box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--dsw-alias-link) 45%, var(--dsw-alias-border-l2))}.psMsOW_modelOption:disabled{opacity:.55;cursor:default}.psMsOW_modelInfo{flex-direction:column;flex:auto;min-width:0;display:flex}.psMsOW_modelTitleRow{align-items:center;gap:6px;min-width:0;display:flex}.psMsOW_modelName{text-overflow:ellipsis;white-space:nowrap;font-weight:450;overflow:hidden}.psMsOW_defaultBadge{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-tertiary);border-radius:4px;flex-shrink:0;padding:1px 5px;font-size:11px;line-height:14px}.psMsOW_modelDesc{text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary);font-size:11.5px;line-height:16px;overflow:hidden}.psMsOW_status{color:var(--dsw-alias-label-secondary);align-items:center;gap:8px;padding:12px 2px;font-size:13px;line-height:18px;display:flex}.psMsOW_empty{color:var(--dsw-alias-label-tertiary);padding:10px;font-size:12.5px;line-height:18px}.psMsOW_errorBox{border-radius:var(--dsw-radius-sm,8px);border:1px solid color-mix(in srgb, var(--dsw-alias-state-error-primary) 28%, transparent);background:color-mix(in srgb, var(--dsw-alias-state-error-primary) 8%, transparent);color:var(--dsw-alias-state-error-primary);justify-content:space-between;align-items:center;gap:8px;padding:9px 11px;font-size:12.5px;line-height:18px;display:flex}.psMsOW_errorText{overflow-wrap:anywhere;min-width:0}.psMsOW_modalAction{min-width:78px}.psMsOW_submittingContent{align-items:center;gap:6px;display:inline-flex}@media (width<=640px){.psMsOW_harnessGrid{grid-template-columns:repeat(2,minmax(0,1fr))}}`,document.head.appendChild(e)}var X={checkIcon:`psMsOW_checkIcon`,defaultBadge:`psMsOW_defaultBadge`,dialog:`psMsOW_dialog`,empty:`psMsOW_empty`,errorBox:`psMsOW_errorBox`,errorText:`psMsOW_errorText`,harnessGrid:`psMsOW_harnessGrid`,harnessName:`psMsOW_harnessName`,harnessOption:`psMsOW_harnessOption`,modalAction:`psMsOW_modalAction`,modelDesc:`psMsOW_modelDesc`,modelInfo:`psMsOW_modelInfo`,modelList:`psMsOW_modelList`,modelName:`psMsOW_modelName`,modelOption:`psMsOW_modelOption`,modelTitleRow:`psMsOW_modelTitleRow`,searchInput:`psMsOW_searchInput`,section:`psMsOW_section`,sectionLabel:`psMsOW_sectionLabel`,sections:`psMsOW_sections`,status:`psMsOW_status`,submittingContent:`psMsOW_submittingContent`};function yv(e,t){if(t===void 0||t.models.length===0)return;let n=e.rememberedSelections?.[t.id]?.model;return n!==void 0&&t.models.some(e=>e.id===n)?n:e.default?.provider===t.id&&t.models.some(t=>t.id===e.default?.model)?e.default.model:t.models[0]?.id}function bv(e,t,n){if(e===null||t===void 0||n===void 0)return;let r=t.models.find(e=>e.id===n),i=r?.reasoning?.efforts;if(i===void 0||i.length===0)return;let a=e.rememberedSelections?.[t.id];if(a?.model===n&&a.reasoningEffort!==void 0&&i.some(e=>e.id===a.reasoningEffort))return a.reasoningEffort;if(r?.reasoning?.defaultEffort!==void 0&&i.some(e=>e.id===r.reasoning?.defaultEffort))return r.reasoning.defaultEffort}function xv(e){if(e===null)return[];let t=e.harnessOrder??[];return[...e.groups].sort((e,n)=>{let r=t.indexOf(e.id),i=t.indexOf(n.id);return(r<0?1/0:r)-(i<0?1/0:i)})}function Sv(e,t,n){if(e.length!==0){if(n!==void 0){let t=e.find(e=>e.id===n);if(t!==void 0)return t}return e.find(e=>e.id!==t)??e[0]}}function Cv({open:e,atSeq:t,currentHarnessId:n,initialHarnessId:r,loadModelCatalog:i,onSubmit:a,onClose:o,t:s}){let[c,l]=(0,d.useState)(null),[u,m]=(0,d.useState)(`idle`),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(void 0),[x,S]=(0,d.useState)(``),[C,w]=(0,d.useState)(!1),[T,E]=(0,d.useState)(null),D=(0,d.useCallback)(()=>{let e=!0;return m(`loading`),g(null),i().then(t=>{if(!e)return;let i=Sv(xv(t),n,r);l(t),m(`ready`),v(i?.id??null),b(yv(t,i))},t=>{e&&(m(`error`),g(t instanceof Error?t.message:String(t)))}),()=>{e=!1}},[n,r,i]);(0,d.useEffect)(()=>{if(e)return E(null),S(``),D()},[e,D]);let O=(0,d.useMemo)(()=>xv(c),[c]),k=(0,d.useMemo)(()=>O.find(e=>e.id===_),[O,_]),ee=(0,d.useMemo)(()=>c===null?void 0:yv(c,k),[c,k]),te=(k?.models.length??0)>6,A=(0,d.useMemo)(()=>{let e=k?.models??[];return!te||x.trim()===``?e:(0,p.rankByName)(e,x.trim())},[x,k?.models,te]),ne=e=>{C||(v(e.id),b(c===null?e.models[0]?.id:yv(c,e)),S(``),E(null))},re=()=>{if(C||_===null)return;let e=bv(c,k,y),n=y===void 0||y===`harness`?void 0:y;w(!0),E(null),a({...t===void 0?{}:{atSeq:t},targetHarnessId:_,...n===void 0?{}:{targetModel:n},...e===void 0?{}:{targetThinkingOptionId:e}}).then(()=>{w(!1),o()},e=>{w(!1),E(e instanceof Error?e.message:String(e))})},ie=!C&&u===`ready`&&_!==null;return/* @__PURE__ */ (0,f.jsx)(p.Modal,{open:e,onClose:C?()=>{}:o,closeLabel:s(`close`),title:s(`handoff.modal.title`),description:s(`handoff.modal.description`),className:X.dialog,footer:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,className:X.modalAction,disabled:C,onClick:o,children:s(`cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,className:X.modalAction,disabled:!ie,onClick:re,children:C?/* @__PURE__ */ (0,f.jsxs)(`span`,{className:X.submittingContent,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:s(`handoff.modal.submitting`)})]}):s(`handoff.modal.confirm`)})]}),children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.sections,"data-handoff-modal":``,children:[u===`loading`&&c===null&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.status,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:s(`handoff.modal.loadingCatalog`)})]}),u===`error`&&h!==null&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.errorBox,role:`alert`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.errorText,children:s(`handoff.modal.catalogError`,{message:h})}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,size:`sm`,onClick:()=>void D(),children:s(`retry`)})]}),c!==null&&O.length===0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.empty,children:s(`handoff.modal.noHarnesses`)}),O.length>0&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.section,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.sectionLabel,children:s(`handoff.modal.targetHarness`)}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.harnessGrid,role:`radiogroup`,"aria-label":s(`handoff.modal.targetHarness`),children:O.map(e=>{let t=e.id===_;return/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-selected":t||void 0,disabled:C,className:X.harnessOption,onClick:()=>ne(e),children:[/* @__PURE__ */ (0,f.jsx)(Jm,{harnessId:e.id,label:e.name,size:16}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.harnessName,children:e.name}),t&&/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{size:14,className:X.checkIcon})]},e.id)})})]}),k!==void 0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.section,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.sectionLabel,children:s(`handoff.modal.targetModel`)}),te&&/* @__PURE__ */ (0,f.jsx)(p.Input,{className:X.searchInput,type:`text`,role:`searchbox`,placeholder:s(`handoff.modal.searchModels`),"aria-label":s(`handoff.modal.searchModels`),value:x,disabled:C,onChange:e=>{S(e.target.value)}}),k.models.length===0?/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.empty,children:s(`handoff.modal.noModels`)}):/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.modelList,role:`radiogroup`,"aria-label":s(`handoff.modal.targetModel`),children:A.length===0?/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.empty,children:s(`handoff.modal.noMatchingModels`)}):A.map(e=>{let t=e.id===y,n=e.id===ee;return/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-selected":t||void 0,disabled:C,className:X.modelOption,onClick:()=>{b(e.id),E(null)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:X.modelInfo,children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:X.modelTitleRow,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.modelName,children:e.name}),n&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.defaultBadge,children:s(`handoff.modal.defaultBadge`)})]}),e.description!==void 0&&e.description!==``&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.modelDesc,children:e.description})]}),t&&/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{size:14,className:X.checkIcon})]},e.id)})})]})]}),T!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.errorBox,role:`alert`,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.errorText,children:s(`handoff.modal.failed`,{message:T})})})]})})}function wv(e,t,n){if(/^https?:/u.test(e)&&n!==``&&!/[\u0000-\u001f\u007f]/u.test(n))return new URL(`/api/remote-peer/file?sessionId=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,e).href}function Tv(e,t){let n=e instanceof Error?e.message:String(e);return n===``?t:n}function Ev(e,t){let n=/* @__PURE__ */ new Set,r;for(let i of e){let e=t.get(i);if(e===void 0||e.kind!==`user`&&e.kind!==`steering`&&e.kind!==`turn-trigger`||((e.location.kind===`turn`||e.location.kind===`step`)&&(r=e.location.turn.turn),e.kind===`turn-trigger`))continue;let a=e.data.source;a?.kind===`user`&&typeof a.rpcId==`string`&&n.add(a.rpcId)}return{rpcIds:n,lastInputTurn:r}}let Dv=(0,d.memo)(function({entries:e,useChatGroup:t,pendingInputs:n,lastInputTurn:r,virtualization:i,...a}){let o=i.active?i.registerRow:void 0,s=e.map((e,n)=>{let r=k_(e),s=i.isMounted(n,r),c=s?void 0:i.placeholderHeight(r,e.kind);switch(e.kind){case`node`:return/* @__PURE__ */ (0,d.createElement)(Gh,{...a,key:Qh(e),nodeKey:e.key,mounted:s,placeholderHeight:c,registerRow:o,...e.groupPart===void 0?{}:{groupPart:e.groupPart}});case`group`:return/* @__PURE__ */ (0,d.createElement)(gg,{...a,key:Qh(e),groupKey:e.key,useChatGroup:t,mounted:s,placeholderHeight:c,registerRow:o});default:return Zh(e)}}),c=n.map(e=>`requestId`in e?/* @__PURE__ */ (0,f.jsx)(fh,{submission:e,renderMessageImages:a.renderMessageImages,t:a.t},e.requestId):/* @__PURE__ */ (0,f.jsx)(dh,{content:e.content,renderMessageImages:a.renderMessageImages,t:a.t},e.id)),l=e.at(-1),u=l?.kind===`node`?a.nodeStore.get(l.key):void 0;if(u?.kind===`turn-process`&&u.location.kind===`turn`&&u.location.turn.status===`open`&&u.location.turn.turn!==r){let e=n.findIndex(e=>`requestId`in e&&e.placement===`transcript`);e!==-1&&s.splice(s.length-1,0,...c.splice(e,1))}return[...s,...c]});function Ov({connection:e,useSession:t,useChat:n,useChatNode:r,useChatNodeProcess:i,useChatGroup:a,useConversation:o,useSessions:s,useStore:c,actions:l,renderSlot:u,sessionId:m,openFile:h,openSkill:g,openExternalLink:_,openLinkInSidebar:v,useBrowserAvailable:y,resolveLink:b,loadOlder:x,loadThrough:S,loadImage:C,inspectCall:w,chatScroll:T,forkAt:E,openSession:D,handoff:O,clearHandoffRequest:k,loadModelCatalog:ee,loadTurnDiffs:te,editMessage:A,fileMentions:re,usePresentation:ae,useHandoffRequest:oe,useProjection:se,useInput:ce,inputActions:le,viewRequest:ue,completeViewRequest:de,t:j}){let fe=n(e=>e.order),pe=y(e=>e),me=o(e=>e.views.grouped(`chat`)),he=o(e=>e.views.grouped(`chat`)?.entries),ge=(0,d.useMemo)(()=>he??fe.map(e=>({kind:`node`,key:e})),[he,fe]),_e=n(e=>e.nodes),ve=n(e=>e.navigation.items()),ye=ve.at(-1)?.anchorKey,be=r(ye??``,e=>{let t=e?.location;return(t?.kind===`turn`||t?.kind===`step`)&&t.turn.status===`open`?t.turn.start?.time:void 0}),xe=se(`turnOutline`),Se=(0,d.useMemo)(()=>a_(ve,xe),[ve,xe]),Ce=se(`inbox`),we=s(e=>e.byId[m]?.cwd),Te=s(e=>e.byId[m]?.projectionValues?.remoteHost?.hostId),Ee=s(e=>(e.byId[m]?.projectionValues)?.harnessIdentity?.id),De=s(e=>!!e.byId[m]?.projectionValues?.remoteHost),Oe=s(e=>{let t=e.byId[m]?.projectionValues?.remoteHost;return t?.hostId.startsWith(`remote-peer:`)===!0&&t.filePreview===!0}),ke=(0,d.useMemo)(()=>({resolve:e=>{if(Oe)return wv(document.baseURI,m,e);if(!De)return ie(document.baseURI,ne(we,e))},labels:{open:j(`image.open`),loading:j(`image.loading`),failed:j(`image.failed`),dialog:j(`image.dialog`),close:j(`image.close`)}}),[we,De,Oe,m,j]),Ae=(0,d.useCallback)(e=>le?.addResponseAnnotation(e,{focus:`end`})!==void 0,[le]),je=t(e=>e.running),Me=(0,d.useSyncExternalStore)(e.state.subscribe,e.state.getSnapshot),Ne=(0,p.useSustainedRecovery)(Me!==`connected`),Pe=se(`compacting`),Fe=se(`codexhostHandoff`),Ie=oe(e=>e),[Le,Re]=(0,d.useState)(null),ze=Le?.sessionId===m?Le:null,M=(0,d.useCallback)(e=>{Re({sessionId:m,atSeq:e})},[m]),Be=(0,d.useCallback)(()=>{Re(null)},[]),Ve=O!==void 0&&ee!==void 0;(0,d.useEffect)(()=>{Ie!==null&&Ie.sessionId===m&&Ve&&(Re({sessionId:m,...Ie.atSeq===void 0?{}:{atSeq:Ie.atSeq},...Ie.targetHarnessId===void 0?{}:{initialHarnessId:Ie.targetHarnessId}}),k(Ie.seq))},[k,Ve,Ie,m]);let He=t(e=>e.openState),Ue=se(`remoteHistoryError`),We=se(`nativeConnection`),Ge=Me===`disconnected`||Ne||He===`error`||!!Ue||We?.state===`reconnecting`,Ke=t(e=>e.openError),qe=t(e=>e.hasMore),Je=t(e=>e.loadingOlder),Ye=t(e=>e.olderError),[Xe,Ze]=(0,d.useState)(null),[Qe,$e]=(0,d.useState)(!1),et=(0,d.useRef)(0),tt=(0,d.useCallback)((e,t)=>{let n=++et.current;$e(!0),(t===void 0?h(e):h(e,t)).then(()=>{n===et.current&&(Ze(null),$e(!1))},r=>{n===et.current&&(Ze({path:e,options:t,message:Tv(r,j(t?.reveal?`fileOpen.folder`:`fileOpen.unknown`))}),$e(!1))})},[h,j]),nt=(0,d.useCallback)(()=>{et.current+=1,Ze(null),$e(!1)},[]),rt=(0,d.useMemo)(()=>Ce?.[`next-step`].filter(e=>e.source.kind===`user`)??[],[Ce]),it=t(e=>e.pendingSubmissions),at=eh(A,se(`sentMessageEdit`)?.seq??null,He!==`open`||je||it.length>0||(Ce?.[`next-turn`].length??0)>0),ot=at.draft&&fe.some(e=>{let t=_e.get(e);return t?.kind===`user`&&t.data.seq===at.draft?.seq}),st=je||it.some(e=>e.placement!==`queued`),[ct,lt]=(0,d.useMemo)(()=>{if(it.length===0)return[it,void 0];let e=Ev(fe,_e);return[it.filter(t=>t.placement!==`queued`&&!e.rpcIds.has(t.requestId)),e.lastInputTurn]},[it,fe,_e]),ut=(0,d.useMemo)(()=>{let e=new Map(ct.map(e=>[e.requestId,e])),t=new Set(it.filter(e=>e.placement!==`queued`).map(e=>e.requestId));return[...rt.flatMap(n=>{let r=n.source;if(r.kind!==`user`||!(`rpcId`in r))return[n];let i=e.get(r.rpcId);return i===void 0?t.has(r.rpcId)?[]:[n]:(e.delete(r.rpcId),[i])}),...e.values()]},[rt,it,ct]),dt=(0,d.useCallback)(e=>u(`conversation.message.images`,{...e,loadImage:C}),[C,u]),ft=fe[0],pt=ft===void 0?null:_e.get(ft)?.anchorSeq??null,mt=fe.at(-1)??null,ht=ut.findLast(e=>`source`in e),gt=ht?.source.kind===`user`&&`rpcId`in ht.source?ht.source.rpcId:ht?.id??null,_t=T_({displayReady:He===`open`||fe.length>0,historyReady:He===`open`,order:fe,firstSeq:pt,lastKey:mt,running:je,loadingOlder:Je,olderFailed:Ye!=null,hasMore:qe,chatScroll:T,loadOlder:x,loadThrough:S,lastIsUser:mt!==null&&_e.get(mt)?.kind===`user`,steeringId:gt,submissionId:ct.at(-1)?.requestId??null,loadedTurns:ve}),vt=ce(e=>e.responseAnnotations.find(e=>e.id===ue?.focus)),yt=(0,d.useMemo)(()=>{let e=at.draft?.seq;if(e===void 0)return null;for(let t of ge){if(t.kind!==`node`)continue;let n=_e.get(t.key);if(n?.kind===`user`&&n.data.seq===e)return k_(t)}return null},[ge,at.draft?.seq,_e]),N=(0,d.useMemo)(()=>ue?.view===`chat`&&vt?.anchor!==void 0?j_(vt.anchor.answerKey,ge,me):null,[vt?.anchor,ge,me,ue?.view]),{initialized:bt,revealResponseAnnotation:xt}=_t,St=(0,d.useMemo)(()=>{if(bt)return null;let e=T.read();return e===null?null:M_(e.anchorKey)},[T,bt,m]),Ct=q_({sessionId:m,entries:ge,nodeStore:_e,listRef:_t.listRef,columnRef:_t.columnRef,editingFlowKey:yt,revealTargetFlowKey:N,savedAnchorFlowKey:St,busyTurn:_t.busyTurn,onTailScrollClamp:_t.reconcileTail}),[wt,Tt]=(0,d.useState)(null),Et=wt?.sessionId===m?wt.item:null,P=(0,d.useCallback)(e=>{let t=e.anchor.kind===`loaded`?e.anchor.key:null;Ct.pinNavigationTarget({turn:e.turn,anchorKey:t}),e.anchor.kind===`loaded`&&Ct.active&&t!==null&&!Ct.isAnchorMounted(t)?Tt({sessionId:m,item:e}):(Tt(null),_t.navigateToTurn(e))},[_t,m,Ct]),Dt=(0,d.useCallback)(()=>{Tt(null),Ct.clearNavigationPin(),_t.returnToBottom()},[_t,Ct]);return(0,d.useLayoutEffect)(()=>{Et!==null&&(Tt(null),_t.navigateToTurn(Et))},[Et,_t]),(0,d.useLayoutEffect)(()=>{if(bt&&ue?.view===`chat`){if(N!==null){Ct.pinNavigationTarget({turn:null,anchorKey:N});let e=ge.some(e=>k_(e)===N||e.kind===`node`&&e.key===N);if(Ct.active&&e&&!Ct.isAnchorMounted(N))return}vt!==void 0&&xt(vt),de()}},[bt,ue,vt,ge,xt,N,de,Ct]),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Rh.frame,children:[_t.initialized&&/* @__PURE__ */ (0,f.jsx)(Jg,{items:Se,activeTurn:_t.activeTurn,busyTurn:_t.busyTurn,onNavigate:P,t:j}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:Rh.root,"data-chat-following-tail":_t.followingTail?``:void 0,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:_t.listRef,className:Rh.scroll,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:_t.columnRef,className:Rh.column,"data-chat-flow":``,children:[He===`loading`&&fe.length===0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Rh.hint,children:j(`chat.loadingHistory`)}),He===`error`&&Ke!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Rh.openError,children:j(`chat.loadError`,{message:Ke.message,code:Ke.code})}),qe&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Rh.older,children:Ye==null?/* @__PURE__ */ (0,f.jsx)(`span`,{role:Je?`status`:void 0,children:j(Je?`chat.loadingOlder`:`chat.scrollOlder`)}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{role:`alert`,children:j(`chat.loadOlderError`,{message:Ye.message})}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,disabled:Je,onClick:_t.loadEarlier,children:j(`chat.retryOlder`)})]})}),!qe&&Fe!=null&&/* @__PURE__ */ (0,f.jsx)(_v,{handoff:Fe,hostId:Te,onOpenSource:D,t:j}),/* @__PURE__ */ (0,f.jsx)(mv,{openExternalLink:_,openLinkInSidebar:pe?v:void 0,hideLocalFileActions:De,resolveLink:b,openFile:tt,fileImages:ke,t:j,children:/* @__PURE__ */ (0,f.jsx)(Dv,{entries:ge,pendingInputs:ut,lastInputTurn:lt,nodeStore:_e,useChatGroup:a,useChatNode:r,useChatNodeProcess:i,usePresentation:ae,useStore:c,actions:l,cwd:we,openFile:tt,openSkill:g,inspectCall:w,forkAt:E,handoffAt:Ve?M:void 0,loadTurnDiffs:te,messageEditing:at,loadImage:C,renderMessageImages:dt,fileMentions:re,renderSlot:u,virtualization:Ct,t:j})},m),at.draft&&!ot&&/* @__PURE__ */ (0,f.jsx)(mh,{editing:at,renderMessageImages:dt,t:j}),st&&/* @__PURE__ */ (0,f.jsx)(Qg,{startTime:be,compacting:Pe,stale:Ge,t:j}),He===`loading`&&fe.length>0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Rh.syncing,role:`status`,"data-history-syncing":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`,className:Rh.syncingIcon}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:j(`chat.syncing`)})]})]})})}),le!==void 0&&/* @__PURE__ */ (0,f.jsx)(dv,{labels:{addToChat:j(`selection.addToChat`),comment:j(`selection.comment`),placeholder:j(`selection.commentPlaceholder`),submit:j(`selection.commentSubmit`),cancel:j(`message.edit.cancel`),unavailable:j(`selection.commentUnavailable`)},onAdd:Ae,container:_t.columnRef},m),!_t.followingTail&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Rh.toBottomSlot,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Rh.toBottom,"aria-label":j(`chat.toBottom`),onClick:Dt,children:/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{})})}),ze!==null&&O!==void 0&&ee!==void 0&&/* @__PURE__ */ (0,f.jsx)(Cv,{open:!0,atSeq:ze.atSeq,currentHarnessId:Ee,initialHarnessId:ze.initialHarnessId,loadModelCatalog:ee,onSubmit:O,onClose:Be,t:j},`${m}:${ze.atSeq??`latest`}:${ze.initialHarnessId??`auto`}`),Xe!==null&&/* @__PURE__ */ (0,f.jsx)(kv,{title:j(Xe.options?.reveal?`fileOpen.folder`:`fileOpen.title`),message:Xe.message,busy:Qe,onClose:nt,onRetry:()=>{tt(Xe.path,Xe.options)},t:j})]})}function kv({title:e,message:t,busy:n,onClose:r,onRetry:i,t:a}){return/* @__PURE__ */ (0,f.jsx)(p.Modal,{open:!0,onClose:r,closeLabel:a(`close`),title:e,description:t,footer:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,className:Rh.modalAction,onClick:r,children:a(`cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,className:Rh.modalAction,disabled:n,onClick:i,children:a(`retry`)})]})})}let Av=`chat`,jv={"message.stepProcess.thinking":`正在分析请求`,"message.stepProcess.read":`正在读取文件`,"message.stepProcess.readImage":`正在读取图片`,"message.stepProcess.write":`正在写入文件`,"message.stepProcess.search":`正在搜索代码`,"message.stepProcess.edit":`正在编辑文件`,"message.stepProcess.commands":`正在运行命令`,"message.stepProcess.code":`正在运行代码`,"message.stepProcess.webSearch":`正在搜索网页`,"message.stepProcess.webFetch":`正在访问网页`,"message.stepProcess.subagents":`正在协调子智能体`,"message.stepProcess.plan":`正在更新计划`,"message.stepProcess.questions":`等待你的操作`,"message.stepProcess.tools":`正在调用工具`,"message.stepProcess.prepare.read":`准备读取文件`,"message.stepProcess.prepare.readImage":`准备读取图片`,"message.stepProcess.prepare.write":`准备写入文件`,"message.stepProcess.prepare.search":`准备搜索代码`,"message.stepProcess.prepare.edit":`准备编辑文件`,"message.stepProcess.prepare.commands":`准备运行命令`,"message.stepProcess.prepare.code":`准备运行代码`,"message.stepProcess.prepare.webSearch":`准备搜索网页`,"message.stepProcess.prepare.webFetch":`准备访问网页`,"message.stepProcess.prepare.subagents":`准备协调子智能体`,"message.stepProcess.prepare.plan":`准备更新计划`,"message.stepProcess.prepare.questions":`准备提问`,"message.stepProcess.prepare.tools":`准备调用工具`,"message.stepProcess.done.thinking":`已完成分析`,"message.stepProcess.done.read":`已读取文件`,"message.stepProcess.done.readImage":`已读取图片`,"message.stepProcess.done.write":`已写入文件`,"message.stepProcess.done.search":`已搜索代码`,"message.stepProcess.done.edit":`修改了文件`,"message.stepProcess.done.commands":`执行了命令`,"message.stepProcess.done.code":`运行了代码`,"message.stepProcess.done.webSearch":`已搜索网页`,"message.stepProcess.done.webFetch":`已访问网页`,"message.stepProcess.done.subagents":`已协调子智能体`,"message.stepProcess.done.plan":`更新了计划`,"message.stepProcess.done.questions":`向用户提出了问题`,"message.stepProcess.done.tools":`已调用工具`,"message.stepProcess.joinTwo":`{first}并{second}`,"message.stepProcess.comma":`,`,"message.stepProcess.sharedPrefix":`已`,"message.stepProcess.more":`{title}等`,"message.trigger.request":`收到执行请求`,"message.trigger.goal":`继续执行目标`,"message.trigger.agent":`收到任务消息`,"message.trigger.team":`收到团队消息`,"message.trigger.subagent":`子任务状态更新`,"message.trigger.github":`收到 GitHub 事件`,"message.trigger.webhook":`收到外部事件`,"message.trigger.schedule":`自动化任务`,"message.trigger.job":`后台任务状态更新`,"message.trigger.plugin":`插件状态更新`,"message.trigger.explanation":`这条通知触发了本轮回复。`,"message.turnProcess.worked":`已完成`,"message.turnProcess.unknown":`已结束`,"message.turnProcess.took":`已完成,用时 `,"message.turnProcess.failed":`处理失败`,"view.chat":`对话`,"image.open":`查看大图`,"image.loading":`加载图片…`,"image.failed":`图片无法预览`,"image.dialog":`图片预览`,"image.close":`关闭图片预览`,"message.imageViews.one":`已查看 1 张图像`,"message.imageViews.many":`已查看 {count} 张图像`,"duration.milliseconds":`{milliseconds}毫秒`,"chat.loadingHistory":`载入历史…`,"selection.addToChat":`添加到对话`,"selection.comment":`添加批注`,"selection.commentPlaceholder":`写下你的批注…`,"selection.commentSubmit":`添加`,"selection.commentUnavailable":`当前无法添加批注,请稍后重试。`,"annotation.label":`批注 {index}`,"annotation.chipLabel":`{index}.`,"annotation.title":`批注 {index}:{excerpt}`,"annotation.remove":`移除批注 {index}`,"annotation.selectedText":`选中文字:`,"annotation.userComment":`你的批注:`,"chat.syncing":`正在获取最新消息…`,"chat.loadingDiff":`载入差异…`,"chat.retryDiff":`重试`,"chat.loadError":`历史加载失败:{message}({code})`,"chat.loadOlder":`加载更早`,"chat.scrollOlder":`向上滚动查看更早消息`,"chat.loadingOlder":`正在加载更早消息…`,"chat.loadOlderError":`更早消息加载失败:{message}`,"chat.retryOlder":`重试加载`,"chat.toBottom":`回到底部`,"chat.filesChanged":`{count} 个文件已更改`,"chat.fileEdited":`已编辑 {name}`,"chat.filesEdited":`已编辑 {count} 个文件`,"chat.viewChanges":`查看变更`,"chat.hideChanges":`收起变更`,"chat.openFile":`打开 {path}`,"chat.showMoreFiles":`再显示 {count} 个文件`,"chat.collapseFiles":`收起文件`,"diff.code":`代码`,"diff.wrap":`自动换行`,"diff.unwrap":`取消换行`,"diff.copy":`复制`,"diff.copied":`已复制`,"diff.collapseAria":`折叠差异`,"diff.expandAria":`展开 {count} 行隐藏内容`,"diff.collapse":`折叠`,"diff.expand":`展开 {count} 行`,"codeBlock.expand":`展开全部(共 {count} 行)`,"codeBlock.collapse":`收起代码`,"chat.deepDiving":`正在处理`,"chat.statusUnconfirmed":`任务状态待确认`,"chat.deepDivingFor":`正在处理 · {duration}`,"chat.turnNavigation.label":`轮次导航`,"chat.turnNavigation.jump":`跳转到用户消息 {turn}`,"chat.turnNavigation.jumpLoad":`加载并跳转到用户消息 {turn}`,"chat.turnNavigation.turn":`用户消息 {turn}`,"settings.links.title":`网页链接默认打开方式`,"settings.links.description":`对话中网页链接的打开位置`,"settings.links.sidebar":`应用内侧边栏`,"settings.links.newTab":`默认浏览器`,"settings.transcript.title":`工作步骤展示`,"settings.transcript.description":`选择希望看到多少工具调用细节`,"settings.transcript.compact":`简洁`,"settings.transcript.standard":`标准`,"settings.transcript.detailed":`详细`,"settings.transcript.verbose":`完全展开`,"fileOpen.title":`无法打开文件`,"fileOpen.folder":`无法打开所在文件夹`,"fileOpen.unknown":`无法打开此文件`,"linkMenu.copy":`复制链接`,"linkMenu.copyFailed":`无法复制链接`,"linkMenu.openBrowser":`在浏览器中打开`,"linkMenu.openFile":`用默认应用打开`,"linkMenu.openFolder":`打开所在文件夹`,"linkMenu.openInCodexhost":`在 codexhost 中打开`,"message.watch.completed":`已完成`,"message.watch.failed":`失败`,"message.watch.interrupted":`已中断`,"message.watch.timedOut":`监听已到期`,"message.watch.unreadable":`状态未知`,"message.watch.notFound":`会话不存在`,"message.watch.open":`打开会话`,"message.extraBlock":`附加内容块`,"message.uploading":`上传中…`,"message.uploadingPercent":`上传中 {percent}%`,"message.systemPrompt":`系统提示词`,"message.systemPromptUpdate":`系统提示词更新`,"message.toolAdded":`已添加工具:{name}`,"message.toolRemoved":`已移除工具:{name}`,"message.toolsAdded":`新增:{names}`,"message.toolsAddedCount":`新增 {count} 个`,"message.toolsChanged":`新增 {added} 个,移除 {removed} 个`,"message.toolsRemoved":`移除:{names}`,"message.toolsRemovedCount":`移除 {count} 个`,"message.toolsUpdated":`工具已更新`,"message.contextInjection":`上下文注入`,"message.contextRecall":`跨会话召回`,"message.referenceSummary":`引用会话 · {labels}`,"message.referenceSeparator":`、`,"message.context.instructions.loaded":`已载入`,"message.context.instructions.added":`已新增`,"message.context.instructions.updated":`已更新`,"message.context.instructions.removed":`已移除`,"message.context.catalog.replaced":`替换目录`,"message.context.catalog.more":`…还有 {count} 条`,"message.context.snapshot.supersedes":`取代先前的快照`,"message.context.relay.from":`来自会话 {session}`,"message.context.recall.counts":`保留 {retained} 条 · 省略 {omitted} 条`,"message.context.recall.truncated":`已截断`,"message.compaction":`上下文已压缩`,"message.compaction.running":`正在压缩…`,"message.compaction.completed":`已压缩 {items} 条历史记录(约 {tokens} tokens)`,"message.compaction.expand":`点击查看压缩摘要`,"message.compaction.unavailable":`压缩摘要不可用`,"message.compaction.commandTitle":`compact`,"message.think":`思考`,"message.unknownSurface":`未知 surface 事件:{type}`,"message.unknownBlock":`未知内容块`,"message.turnProcess.toolCalls.one":`{count} 次工具调用`,"message.turnProcess.toolCalls.other":`{count} 次工具调用`,"message.turnProcess.messages.one":`{count} 条消息`,"message.turnProcess.messages.other":`{count} 条消息`,"message.turnProcess.subagents.one":`{count} 个 subagent`,"message.turnProcess.subagents.other":`{count} 个 subagent`,"message.turnProcess.thoughtForAWhile":`已思考`,"message.turnProcess.separator":` · `,"message.stopped":`已停止`,"message.edit":`编辑消息`,"message.edit.changed":`会话状态已变化,请核对当前历史后继续。`,"message.edit.cancel":`取消`,"message.edit.send":`发送`,"message.edit.sending":`正在回退并重跑…`,"message.edit.checkHistory":`请核对当前历史后再继续;编辑文本已保留,不会自动重发。`,"message.branch":`在新对话中分支`,"message.branchFailed":`分叉未完成:{message}`,"message.branchUnavailable":`仅可从已完成轮次的最后一条消息分支`,"message.handoff":`上下文交接`,"message.handoffUnavailable":`仅可从已完成轮次的最后一条消息交接`,"handoff.divider.label":`上下文交接`,"handoff.divider.expand":`展开上下文交接详情`,"handoff.divider.collapse":`收起上下文交接详情`,"handoff.divider.turnsAll":`已携带全部 {total} 轮对话`,"handoff.divider.turnsPrefix":`已携带前 {boundary} / {total} 轮对话`,"handoff.divider.turnsPartial":`已携带 {included} / {total} 轮对话(省略 {omitted} 轮,截至第 {boundary} 轮)`,"handoff.divider.openSource":`跳回源会话`,"handoff.divider.previewEmpty":`暂无交接上下文预览`,"handoff.modal.title":`上下文交接`,"handoff.modal.description":`将当前对话上下文整理并交接到新的会话中继续处理。`,"handoff.modal.targetHarness":`目标 Agent`,"handoff.modal.targetModel":`模型`,"handoff.modal.searchModels":`搜索模型…`,"handoff.modal.noModels":`该 Agent 未提供可选模型,将使用默认配置`,"handoff.modal.noHarnesses":`暂无可用的目标 Agent`,"handoff.modal.noMatchingModels":`没有匹配的模型`,"handoff.modal.loadingCatalog":`正在加载可用 Agent 与模型…`,"handoff.modal.catalogError":`加载模型目录失败:{message}`,"handoff.modal.confirm":`确认交接`,"handoff.modal.submitting":`正在交接…`,"handoff.modal.failed":`交接失败:{message}`,"handoff.modal.defaultBadge":`默认`,"message.retry.active":`正在重试模型请求`,"message.retry.cancelled":`模型请求重试已取消`,"message.retry.started":`已重试模型请求`,"message.retry.scheduled":`等待重试模型请求`,"message.retry.status":`{label}({retry}/{maximum}) · {seconds}s`,"message.retry.delay":`重试延迟:`,"message.retry.failure":`失败原因:`,"message.failure.auth":`API 密钥无效`,"message.accountStopped":`任务已停止`,"message.failure.accountSignedOut":`任务已因退出 DeepSeek 登录而停止。`,"message.failure.accountSignInRequired":`请先登录 DeepSeek,并确认请求地址支持账号认证。`,"message.failure.quota":`当前请求的额度已用尽`,"message.turnError":`本轮运行失败`,"message.maxTokens":`已达到输出 token 上限`,"message.maxTokens.hint":`回答被截断,已有输出保留在对话中。发送“继续”可让模型接着输出。`,"duration.secondUnit":`秒`,"duration.minuteUnit":`分`,"duration.hourUnit":`小时`,"command.running":`执行中…`,"command.failed":`指令失败`,"command.done":`已完成`,"command.title":`指令`,"row.running":`运行中`,"row.failed":`失败`,"json.truncated":`… 已截断,共 {total} 字符`,"clock.md":`{m}月{d}日`,"clock.ymd":`{y}年{m}月{d}日`},Mv={"message.stepProcess.thinking":`Analyzing the request`,"message.stepProcess.read":`Reading files`,"message.stepProcess.readImage":`Reading images`,"message.stepProcess.write":`Writing files`,"message.stepProcess.search":`Searching code`,"message.stepProcess.edit":`Editing files`,"message.stepProcess.commands":`Running commands`,"message.stepProcess.code":`Running code`,"message.stepProcess.webSearch":`Searching the web`,"message.stepProcess.webFetch":`Visiting web pages`,"message.stepProcess.subagents":`Coordinating subagents`,"message.stepProcess.plan":`Updating the plan`,"message.stepProcess.questions":`Waiting for your action`,"message.stepProcess.tools":`Calling tools`,"message.stepProcess.prepare.read":`Preparing to read files`,"message.stepProcess.prepare.readImage":`Preparing to read images`,"message.stepProcess.prepare.write":`Preparing to write files`,"message.stepProcess.prepare.search":`Preparing to search code`,"message.stepProcess.prepare.edit":`Preparing to edit files`,"message.stepProcess.prepare.commands":`Preparing to run commands`,"message.stepProcess.prepare.code":`Preparing to run code`,"message.stepProcess.prepare.webSearch":`Preparing to search the web`,"message.stepProcess.prepare.webFetch":`Preparing to visit web pages`,"message.stepProcess.prepare.subagents":`Preparing to coordinate subagents`,"message.stepProcess.prepare.plan":`Preparing to update the plan`,"message.stepProcess.prepare.questions":`Preparing questions`,"message.stepProcess.prepare.tools":`Preparing tool calls`,"message.stepProcess.done.thinking":`Analysis completed`,"message.stepProcess.done.read":`Read files`,"message.stepProcess.done.readImage":`Read images`,"message.stepProcess.done.write":`Wrote files`,"message.stepProcess.done.search":`Searched code`,"message.stepProcess.done.edit":`Edited files`,"message.stepProcess.done.commands":`Ran commands`,"message.stepProcess.done.code":`Ran code`,"message.stepProcess.done.webSearch":`Searched the web`,"message.stepProcess.done.webFetch":`Visited web pages`,"message.stepProcess.done.subagents":`Coordinated subagents`,"message.stepProcess.done.plan":`Updated the plan`,"message.stepProcess.done.questions":`Asked questions`,"message.stepProcess.done.tools":`Called tools`,"message.stepProcess.joinTwo":`{first} and {second}`,"message.stepProcess.comma":`, `,"message.stepProcess.sharedPrefix":``,"message.stepProcess.more":`{title}, etc.`,"message.trigger.request":`Execution requested`,"message.trigger.goal":`Continuing goal`,"message.trigger.agent":`Task message received`,"message.trigger.team":`Team message received`,"message.trigger.subagent":`Subtask status updated`,"message.trigger.github":`GitHub event received`,"message.trigger.webhook":`External event received`,"message.trigger.schedule":`Automation task`,"message.trigger.job":`Background task updated`,"message.trigger.plugin":`Plugin status updated`,"message.trigger.explanation":`This notification triggered this response.`,"message.turnProcess.worked":`Completed`,"message.turnProcess.unknown":`Ended`,"message.turnProcess.took":`Completed in `,"message.turnProcess.failed":`Failed`,"view.chat":`Chat`,"image.open":`View full image`,"image.loading":`Loading image…`,"image.failed":`Image preview unavailable`,"image.dialog":`Image preview`,"image.close":`Close image preview`,"message.imageViews.one":`Viewed 1 image`,"message.imageViews.many":`Viewed {count} images`,"duration.milliseconds":`{milliseconds}ms`,"chat.loadingHistory":`Loading history…`,"selection.addToChat":`Add to chat`,"selection.comment":`Add comment`,"selection.commentPlaceholder":`Add a comment…`,"selection.commentSubmit":`Add`,"selection.commentUnavailable":`Could not add the comment. Try again in a moment.`,"annotation.label":`Annotation {index}`,"annotation.chipLabel":`{index}.`,"annotation.title":`Annotation {index}: {excerpt}`,"annotation.remove":`Remove annotation {index}`,"annotation.selectedText":`Selected text:`,"annotation.userComment":`Your comment:`,"chat.syncing":`Fetching latest messages…`,"chat.loadingDiff":`Loading diff…`,"chat.retryDiff":`Retry`,"chat.loadError":`Failed to load history: {message} ({code})`,"chat.loadOlder":`Load earlier`,"chat.scrollOlder":`Scroll up for earlier messages`,"chat.loadingOlder":`Loading earlier messages…`,"chat.loadOlderError":`Could not load earlier messages: {message}`,"chat.retryOlder":`Retry loading`,"chat.toBottom":`Back to bottom`,"chat.filesChanged":`{count} files changed`,"chat.fileEdited":`Edited {name}`,"chat.filesEdited":`Edited {count} files`,"chat.viewChanges":`View changes`,"chat.hideChanges":`Hide changes`,"chat.openFile":`Open {path}`,"chat.showMoreFiles":`Show {count} more`,"chat.collapseFiles":`Collapse files`,"diff.code":`Code`,"diff.wrap":`Wrap lines`,"diff.unwrap":`Unwrap lines`,"diff.copy":`Copy`,"diff.copied":`Copied`,"diff.collapseAria":`Collapse diff`,"diff.expandAria":`Expand {count} hidden lines`,"diff.collapse":`Collapse`,"diff.expand":`Expand {count} lines`,"codeBlock.expand":`Expand all ({count} lines)`,"codeBlock.collapse":`Collapse code`,"chat.deepDiving":`Working`,"chat.statusUnconfirmed":`Task status unconfirmed`,"chat.deepDivingFor":`Working · {duration}`,"chat.turnNavigation.label":`Turn navigation`,"chat.turnNavigation.jump":`Jump to user message {turn}`,"chat.turnNavigation.jumpLoad":`Load and jump to user message {turn}`,"chat.turnNavigation.turn":`User message {turn}`,"settings.links.title":`Open chat links in`,"settings.links.description":`Choose where to open web links`,"settings.links.sidebar":`In-App Sidebar`,"settings.links.newTab":`Default Browser`,"settings.transcript.title":`Work details`,"settings.transcript.description":`Choose how much detail to show for tool calls`,"settings.transcript.compact":`Compact`,"settings.transcript.standard":`Standard`,"settings.transcript.detailed":`Detailed`,"settings.transcript.verbose":`Verbose`,"fileOpen.title":`Couldn’t open file`,"fileOpen.folder":`Couldn’t open containing folder`,"fileOpen.unknown":`Couldn’t open this file`,"linkMenu.copy":`Copy link`,"linkMenu.copyFailed":`Couldn’t copy link`,"linkMenu.openBrowser":`Open in browser`,"linkMenu.openFile":`Open in default app`,"linkMenu.openFolder":`Open containing folder`,"linkMenu.openInCodexhost":`Open in codexhost`,"message.watch.completed":`Completed`,"message.watch.failed":`Failed`,"message.watch.interrupted":`Interrupted`,"message.watch.timedOut":`Watch expired`,"message.watch.unreadable":`State unknown`,"message.watch.notFound":`Session not found`,"message.watch.open":`Open session`,"message.extraBlock":`Extra content block`,"message.uploading":`Uploading…`,"message.uploadingPercent":`Uploading {percent}%`,"message.systemPrompt":`System prompt`,"message.systemPromptUpdate":`System prompt update`,"message.toolAdded":`Tool added: {name}`,"message.toolRemoved":`Tool removed: {name}`,"message.toolsAdded":`Added: {names}`,"message.toolsAddedCount":`{count} added`,"message.toolsChanged":`{added} added, {removed} removed`,"message.toolsRemoved":`Removed: {names}`,"message.toolsRemovedCount":`{count} removed`,"message.toolsUpdated":`Tools updated`,"message.contextInjection":`Context injection`,"message.contextRecall":`Session recall`,"message.referenceSummary":`Referenced session · {labels}`,"message.referenceSeparator":`, `,"message.context.instructions.loaded":`loaded`,"message.context.instructions.added":`added`,"message.context.instructions.updated":`updated`,"message.context.instructions.removed":`removed`,"message.context.catalog.replaced":`Replacement catalog`,"message.context.catalog.more":`… {count} more`,"message.context.snapshot.supersedes":`Supersedes earlier snapshots`,"message.context.relay.from":`From session {session}`,"message.context.recall.counts":`{retained} kept · {omitted} omitted`,"message.context.recall.truncated":`truncated`,"message.compaction":`Context compacted`,"message.compaction.running":`Compacting context…`,"message.compaction.completed":`Compacted {items} history items (~{tokens} tokens)`,"message.compaction.expand":`View compaction summary`,"message.compaction.unavailable":`Compaction summary unavailable`,"message.compaction.commandTitle":`compact`,"message.think":`Think`,"message.unknownSurface":`Unknown surface event: {type}`,"message.unknownBlock":`Unknown content block`,"message.turnProcess.toolCalls.one":`{count} tool call`,"message.turnProcess.toolCalls.other":`{count} tool calls`,"message.turnProcess.messages.one":`{count} message`,"message.turnProcess.messages.other":`{count} messages`,"message.turnProcess.subagents.one":`{count} subagent`,"message.turnProcess.subagents.other":`{count} subagents`,"message.turnProcess.thoughtForAWhile":`Thought for a while`,"message.turnProcess.separator":` · `,"message.stopped":`Stopped`,"message.edit":`Edit message`,"message.edit.changed":`Conversation state changed. Check current history before continuing.`,"message.edit.cancel":`Cancel`,"message.edit.send":`Send`,"message.edit.sending":`Reverting and rerunning…`,"message.edit.checkHistory":`Check current history before continuing. Your edit is retained and will not be resent automatically.`,"message.branch":`Branch into a new conversation`,"message.branchFailed":`Fork did not complete: {message}`,"message.branchUnavailable":`Available only on the last message of a completed turn`,"message.handoff":`Hand off context`,"message.handoffUnavailable":`Available only on the last message of a completed turn`,"handoff.divider.label":`Context handoff`,"handoff.divider.expand":`Expand context handoff details`,"handoff.divider.collapse":`Collapse context handoff details`,"handoff.divider.turnsAll":`Carried all {total} turns`,"handoff.divider.turnsPrefix":`Carried first {boundary} of {total} turns`,"handoff.divider.turnsPartial":`Carried {included} of {total} turns ({omitted} omitted, up to turn {boundary})`,"handoff.divider.openSource":`Open source session`,"handoff.divider.previewEmpty":`No handoff context preview available`,"handoff.modal.title":`Context handoff`,"handoff.modal.description":`Package the current conversation context and continue in a new session.`,"handoff.modal.targetHarness":`Target Agent`,"handoff.modal.targetModel":`Model`,"handoff.modal.searchModels":`Search models…`,"handoff.modal.noModels":`No selectable models — default configuration will be used`,"handoff.modal.noHarnesses":`No available target Agents`,"handoff.modal.noMatchingModels":`No matching models`,"handoff.modal.loadingCatalog":`Loading available Agents and models…`,"handoff.modal.catalogError":`Failed to load model catalog: {message}`,"handoff.modal.confirm":`Hand off`,"handoff.modal.submitting":`Handing off…`,"handoff.modal.failed":`Handoff failed: {message}`,"handoff.modal.defaultBadge":`Default`,"message.retry.active":`Retrying model request`,"message.retry.cancelled":`Model request retry cancelled`,"message.retry.started":`Retried model request`,"message.retry.scheduled":`Waiting to retry model request`,"message.retry.status":`{label} ({retry}/{maximum}) · {seconds}s`,"message.retry.delay":`Retry delay: `,"message.retry.failure":`Failure reason: `,"message.failure.auth":`API key is invalid`,"message.accountStopped":`Task stopped`,"message.failure.accountSignedOut":`Stopped because you signed out of DeepSeek.`,"message.failure.accountSignInRequired":`Sign in to DeepSeek and ensure the request destination supports account authentication.`,"message.failure.quota":`Request quota exhausted.`,"message.turnError":`This turn failed`,"message.maxTokens":`Output token limit reached`,"message.maxTokens.hint":`The reply was cut off; earlier output is preserved in the conversation. Send "continue" to let the model resume.`,"duration.secondUnit":`s`,"duration.minuteUnit":`m `,"duration.hourUnit":`h `,"command.running":`Running…`,"command.failed":`Command failed`,"command.done":`Completed`,"command.title":`Command`,"row.running":`Running`,"row.failed":`Failed`,"json.truncated":`… truncated, {total} characters total`,"clock.md":`{m}/{d}`,"clock.ymd":`{y}-{m}-{d}`},Nv=`@deepseek-ai/dsh-client-ui-chat/ReasoningRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Nv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Nv,e.textContent=`.akEvLW_root{flex-direction:column;display:flex}.akEvLW_root:not([data-expanded]){contain:size layout;height:calc(24px + var(--dsh-content-font-delta,0px))}.akEvLW_row{overflow:hidden}.akEvLW_root[data-expanded] [data-open] [data-disclosure-row]{z-index:1;background:var(--dsw-alias-bg-base);position:sticky;top:0}body[data-codexhost-wallpaper] .akEvLW_root[data-expanded] [data-open] [data-disclosure-row]{background:color-mix(in srgb, var(--dsw-alias-bg-base) 76%, transparent);backdrop-filter:blur(12px);border-radius:var(--dsw-radius-sm,8px)}body[data-codexhost-wallpaper] [data-chat-flow-key]:not([data-chat-flow-key] *,[data-chat-near-viewport]) .akEvLW_root[data-expanded] [data-open] [data-disclosure-row]{backdrop-filter:none}.akEvLW_leading{flex-shrink:0}.akEvLW_title{font-weight:400}.akEvLW_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.akEvLW_summary{min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));white-space:nowrap;flex:auto;overflow:hidden}.akEvLW_summaryText{text-overflow:ellipsis;display:block;overflow:hidden}.akEvLW_summary[data-streaming]{mask-image:linear-gradient(90deg,#000 calc(100% - 48px),#0000)}.akEvLW_summary[data-streaming] .akEvLW_summaryText{text-overflow:clip;overflow:visible}.akEvLW_root:not([data-preview]) .akEvLW_separator,.akEvLW_root:not([data-preview]) .akEvLW_summary{display:none}.akEvLW_thinkBody{padding:4px 0 4px calc(22px + var(--dsh-content-font-delta,0px));min-width:0}`,document.head.appendChild(e)}var Pv={leading:`akEvLW_leading`,root:`akEvLW_root`,row:`akEvLW_row`,separator:`akEvLW_separator`,summary:`akEvLW_summary`,summaryText:`akEvLW_summaryText`,thinkBody:`akEvLW_thinkBody`,title:`akEvLW_title`};let Fv=/* @__PURE__ */ (0,f.jsx)(p.IconThinkOutlineRegular,{size:14});function Iv(e){let t=e.indexOf(`
|
|
127
|
+
`);return t===-1?e:e.slice(0,t)}function Lv(e){let t=``,n=0,r=/\r?\n(?:[\t ]*\r?\n)+/g;for(;;){let i=r.exec(e),a=i===null?e.length:i.index+i[0].indexOf(`
|
|
128
128
|
`),o=e.indexOf(`
|
|
129
|
-
`,n);if(o!==-1&&o<=a){let r=e.slice(n,o).trim();r!==``&&(t=r)}if(i===null)return t;n=i.index+i[0].length}}let ov=(0,d.memo)(function({text:e,running:t,usePresentation:n,useDisclosure:r,t:i}){let{expanded:a,toggle:o}=r(),s=(0,d.useMemo)(()=>Zp(i),[i]),c=t?av(e):iv(e),l=(0,d.useMemo)(()=>c.replaceAll(`**`,``),[c]),u=n(e=>!a&&l!==``&&(t||e.settledReasoningPreview)),m=(0,d.useMemo)(()=>/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:nv.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:nv.summary,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:nv.summaryText,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{children:l})})})]}),[t,l]),h=(0,d.useMemo)(()=>a?/* @__PURE__ */ (0,f.jsx)(`div`,{className:nv.thinkBody,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:e,streaming:t,labels:s,variant:`compact`})}):void 0,[a,s,t,e]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:nv.root,"data-variant":`think`,"data-state":t?`running`:`ok`,"data-expanded":a||void 0,"data-preview":u||void 0,children:[t&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Vg.visuallyHidden,children:i(`row.running`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{rowClassName:nv.row,leadingClassName:nv.leading,titleClassName:nv.title,icon:rv,title:i(`message.think`),running:t,open:a,expandable:!0,expandOnRowClick:!0,onToggle:o,collapsedContent:m,children:h})]})}),sv=`@deepseek-ai/dsh-client-ui-chat/AssistantMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(sv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=sv,e.textContent=`.-BFQla_root{font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-primary);flex-direction:column;display:flex}.-BFQla_body{flex-direction:column;gap:16px;display:flex}.-BFQla_viewedImages{flex-direction:column;align-items:flex-start;gap:10px;display:flex}.-BFQla_viewedImagesToggle{min-height:24px;color:var(--dsw-alias-label-tertiary);font:inherit;cursor:pointer;background:0 0;border:none;align-items:center;gap:6px;padding:0;display:inline-flex}.-BFQla_viewedImagesToggle:hover{color:var(--dsw-alias-label-secondary)}.-BFQla_viewedImagesToggle:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-alias-state-business-primary);outline-offset:2px;border-radius:var(--dsw-radius-sm)}.-BFQla_viewedImagesIcon{flex:none;width:16px;height:16px;position:relative}.-BFQla_viewedImagesIcon:before,.-BFQla_viewedImagesIcon:after{content:"";border:1px solid;border-radius:3px;width:11px;height:9px;position:absolute}.-BFQla_viewedImagesIcon:before{top:2px;left:2px}.-BFQla_viewedImagesIcon:after{top:5px;left:5px}.-BFQla_viewedImagesChevron{flex:none;width:12px;height:12px}.-BFQla_body .md-table-wide{--dsh-table-spare:max(0px, calc((100cqw - var(--dsh-chat-content-width)) / 2));--dsh-table-lead:calc(var(--dsh-table-spare) + min(var(--dsh-chat-content-width), 100cqw) - 100%);box-sizing:border-box;width:calc(100% + var(--dsh-table-lead) + var(--dsh-table-spare));max-width:none;margin-left:calc(-1 * var(--dsh-table-lead));padding-left:var(--dsh-table-lead)}.-BFQla_body .md-table-wide>table{z-index:1;position:relative}.-BFQla_body>[data-turn-process-inline][hidden]{margin-bottom:-16px}.-BFQla_stopped{border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-tertiary);align-self:flex-start;padding:0 6px;font-size:11px;line-height:18px}.-BFQla_actions{margin-top:16px;margin-left:-6px}`,document.head.appendChild(e)}var cv={actions:`-BFQla_actions`,body:`-BFQla_body`,root:`-BFQla_root`,stopped:`-BFQla_stopped`,viewedImages:`-BFQla_viewedImages`,viewedImagesChevron:`-BFQla_viewedImagesChevron`,viewedImagesIcon:`-BFQla_viewedImagesIcon`,viewedImagesToggle:`-BFQla_viewedImagesToggle`};function lv({images:e,renderMessageImages:t,t:n}){let[r,i]=(0,d.useState)(!1),a=e.length===1?n(`message.imageViews.one`):n(`message.imageViews.many`,{count:e.length});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:cv.viewedImages,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:cv.viewedImagesToggle,"aria-expanded":r,onClick:()=>{i(e=>!e)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:cv.viewedImagesIcon,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:a}),r?/* @__PURE__ */ (0,f.jsx)(p.IconChevronUpOutlineRegular,{className:cv.viewedImagesChevron}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:cv.viewedImagesChevron})]}),r&&t({images:e,align:`start`})]})}function uv(e,t,n){let r;try{r=decodeURIComponent(t.split(/[?#]/u)[0]??``)}catch{return}return n===void 0?oe(e,r):n(r)}let dv=(0,d.memo)(function({blocks:e,streaming:t,interrupted:n,renderMessageImages:r,groupPart:i,useDisclosure:a,reasoningHidden:o=!1,usePresentation:s,revealProcess:c,mentions:l,responseAnnotations:u,t:m}){let h=(0,d.useMemo)(()=>Zp(m),[m]),{fileImages:g}=(0,p.useMarkdownDelegate)(),_=(0,d.useMemo)(()=>({resolve:e=>uv(document.baseURI,e,g?.resolve)}),[g]),v=e.length-1;if(!(t||n===!0||e.some(e=>e.kind!==`tool-call`)))return null;let y=[];for(let n=0;n<e.length;n++){let g=e[n];if(g!==void 0&&(i!==`reasoning`||g.kind===`reasoning`)&&(i!==`response`||g.kind!==`reasoning`))switch(g.kind){case`text`:y.push(/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:g.text,streaming:t,breaks:!0,labels:h,fileMentions:l,pathImages:_,responseAnnotations:u},n));break;case`reasoning`:y.push(/* @__PURE__ */ (0,f.jsx)(fv,{hidden:o,reveal:c,children:/* @__PURE__ */ (0,f.jsx)(ov,{text:g.text,running:t&&n===v,usePresentation:s,useDisclosure:a,t:m})},n));break;case`image`:{let t=n,i=[g];for(;n+1<e.length;){let t=e[n+1];if(t===void 0||t.kind!==`image`)break;i.push(t),n+=1}y.push(/* @__PURE__ */ (0,f.jsx)(d.Fragment,{children:r({images:i.map(({attachment:e})=>({attachment:e})),align:`start`})},t));break}case`viewed-images`:{let t=n,i=[g];for(;n+1<e.length;){let t=e[n+1];if(t===void 0||t.kind!==`viewed-images`)break;i.push(t),n+=1}y.push(/* @__PURE__ */ (0,f.jsx)(lv,{images:i.map(({attachment:e})=>({attachment:e})),renderMessageImages:r,t:m},t));break}case`tool-call`:break;default:y.push(/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:m(`message.unknownBlock`),payload:g.block,truncatedLabel:e=>m(`json.truncated`,{total:e})},n))}}return/* @__PURE__ */ (0,f.jsx)(`div`,{className:cv.root,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:cv.body,children:[y,n&&(i===void 0||i===`response`||!e.some(e=>e.kind!==`reasoning`&&e.kind!==`tool-call`))&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:cv.stopped,children:m(`message.stopped`)})]})})});function fv({hidden:e,reveal:t,children:n}){let r=Eh(e,t??pv);return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:r,"data-turn-process-inline":e||void 0,children:n})}let pv=()=>{};function mv(e,t){for(let n=e;n!==null&&n!==t;n=n.parentElement)if(n.classList.contains(y_.annotationMark))return!0;return!1}function hv(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(let r=t.nextNode();r!==null;r=t.nextNode()){let t=r.parentElement;r.nodeValue&&t!==null&&t.closest(e_)===null&&!mv(t,e)&&(n=r)}return n}function gv(e){let t=e.ownerDocument.defaultView?.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return;let n=t.getRangeAt(0);if(!e.contains(n.startContainer)||e.contains(n.endContainer)||!(e.compareDocumentPosition(n.endContainer)&Node.DOCUMENT_POSITION_FOLLOWING)||(n.startContainer instanceof Element?n.startContainer:n.startContainer.parentElement)?.closest(e_)!=null)return;let r=hv(e);if(r===null)return;let i=n.cloneRange();i.setEnd(r,r.data.length),t.removeAllRanges(),t.addRange(i)}let _v=(0,d.memo)(function({node:e,groupPart:t,useDisclosure:n,useTurnData:r,turnProcess:i,openFile:a,renderMessageImages:o,fileMentions:s,responseAnnotations:c,useInput:l,inputActions:u,usePresentation:p,t:m}){let h=e.data,g=(0,d.useRef)(null),_=JSON.stringify([e.key,t??null]),v=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,y=r(`turn-tail`),b=(0,d.useMemo)(()=>{if(v?.status===`closed`&&h.finalNode!==void 0&&y?.closing?.finalNode.seq===h.finalNode.seq)return{turn:v,seq:h.finalNode.seq,openFile:a}},[h.finalNode,a,y,v]),x=(0,d.useMemo)(()=>b===void 0?void 0:s(b),[s,b]),S=i!==void 0&&i.foldable&&i.spec.answerStep===h.step&&i.spec.inlineReasoning&&!i.open,C=(0,d.useCallback)(()=>{i?.setOpen(!0)},[i]),w=(0,d.useMemo)(()=>Qp(m),[m]),T=(0,d.useMemo)(()=>({labels:w,resolve:e=>c[e-1]}),[w,c]),E=(0,d.useCallback)(e=>{e.detail>=2&&g.current!==null&&gv(g.current)},[]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:g,className:y_.answer,"data-selection-answer":_,"data-selection-answer-streaming":h.status===`running`||void 0,onClick:E,children:[/* @__PURE__ */ (0,f.jsx)(dv,{blocks:h.blocks,groupPart:t,useDisclosure:n,streaming:h.status===`running`,interrupted:h.status===`interrupted`,renderMessageImages:o,reasoningHidden:S,usePresentation:p,revealProcess:C,mentions:x,responseAnnotations:T,t:m}),h.status!==`running`&&/* @__PURE__ */ (0,f.jsx)(w_,{answer:g,answerKey:_,useInput:l,inputActions:u,labels:w})]})}),vv=`@deepseek-ai/dsh-client-ui-chat/GenericCommandCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(vv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=vv,e.textContent=`.lHK2Ya_root{flex-direction:column;display:flex}.lHK2Ya_leading{flex-shrink:0}.lHK2Ya_title{font-weight:400}.lHK2Ya_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.lHK2Ya_summary{min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.lHK2Ya_summary[data-error],.lHK2Ya_body[data-error]{color:var(--dsw-alias-state-error-primary)}.lHK2Ya_body{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-markdown-code-block);max-height:260px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-markdown-code-block-small);white-space:pre-wrap;margin:4px 0 4px 4px;padding:12px 16px;overflow:auto}`,document.head.appendChild(e)}var yv={body:`lHK2Ya_body`,leading:`lHK2Ya_leading`,root:`lHK2Ya_root`,separator:`lHK2Ya_separator`,summary:`lHK2Ya_summary`,title:`lHK2Ya_title`};let bv=/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{size:14});function xv(e){return e===null?`running`:e.kind===`error`?`error`:`ok`}let Sv=(0,d.memo)(function({node:e,t,runningSummary:n,successSummary:r}){let[i,a]=(0,d.useState)(!1),o=e.outcome?.text,s=e.outcome===null?n??t(`command.running`):o??(e.outcome.kind===`error`?t(`command.failed`):r??t(`command.done`)),c=e.name??t(`command.title`),l=xv(e.outcome),u=l===`running`,m=o!==void 0&&o.includes(`
|
|
130
|
-
`)?o:null,h=i&&m!==null,g=(0,d.useCallback)(()=>{a(e=>!e)},[]),_=(0,d.useMemo)(()=>/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:yv.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:yv.summary,"data-error":l===`error`||void 0,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{children:s})})]}),[u,l,s]),v=(0,d.useMemo)(()=>h?/* @__PURE__ */ (0,f.jsx)(`pre`,{className:yv.body,"data-error":l===`error`||void 0,children:m}):void 0,[m,h,l]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:yv.root,"data-variant":`others`,"data-command":e.name??void 0,"data-state":l,children:[l===`running`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Vg.visuallyHidden,children:t(`row.running`)}),l===`error`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Vg.visuallyHidden,children:t(`row.failed`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{leadingClassName:yv.leading,titleClassName:yv.title,icon:bv,title:c,running:u,open:h,expandable:m!==null,expandOnRowClick:!0,keepContentWhenOpen:!0,onToggle:g,collapsedContent:_,children:v})]})});function Cv({node:e,compaction:t,t:n}){return t===void 0?/* @__PURE__ */ (0,f.jsx)(Sv,{node:e,t:n,runningSummary:n(`message.compaction.running`),successSummary:n(`message.compaction`)}):/* @__PURE__ */ (0,f.jsx)(am,{node:t,title:n(`message.compaction.commandTitle`),fallbackSummary:e.outcome?.text??null,t:n})}let wv=(0,d.memo)(function({node:e,renderSlot:t,t:n}){let r=e.data,i=(0,d.useMemo)(()=>({node:r}),[r]);return/* @__PURE__ */ (0,f.jsx)(`div`,{className:Mh.callRow,children:t(`conversation.chat.commandview`,i,{entryKey:r.name??``,fallback:/* @__PURE__ */ (0,f.jsx)(Sv,{...i,t:n})})})}),Tv=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:Mh.callRow,children:/* @__PURE__ */ (0,f.jsx)(Cv,{node:n.command,...n.compaction===null?{}:{compaction:n.compaction},t})})});function Ev({text:e,update:t=!1,t:n}){let[r,i]=(0,d.useState)(!1);return/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{className:Mm.root,icon:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),chevronClassName:Mm.chevron,title:n(t?`message.systemPromptUpdate`:`message.systemPrompt`),open:r,expandable:!0,expandOnRowClick:!0,onToggle:()=>{i(e=>!e)},children:/* @__PURE__ */ (0,f.jsx)(`div`,{className:Mm.body,"data-system-prompt-body":!0,children:/* @__PURE__ */ (0,f.jsx)(gm,{content:[{type:`text`,text:e}],source:null,t:n})})})}let Dv=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(Ev,{text:e.data.text,update:e.data.update===!0,t})}),Ov=`@deepseek-ai/dsh-client-ui-chat/TurnProcessNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ov)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Ov,e.textContent=`.NsInEG_root{box-sizing:border-box;width:100%;min-width:0;height:calc(33px + var(--dsh-content-font-delta,0px));border:none;border-bottom:.5px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size,14px);cursor:pointer;text-align:left;background:0 0;align-items:center;padding:0 0 8px;transition:color .1s;display:flex}.NsInEG_root:disabled{cursor:default}@media (hover:hover){.NsInEG_root:hover:not(:disabled){color:var(--dsw-alias-label-secondary)}}.NsInEG_root:active:not(:disabled){color:var(--dsw-alias-label-secondary)}.NsInEG_chevron{width:14px;height:14px;color:inherit;flex:none;margin-left:4px;transition:transform .1s}.NsInEG_root[data-open] .NsInEG_chevron{transform:rotate(180deg)}.NsInEG_label{min-width:0;font-size:inherit;line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.NsInEG_durationNumber{font-family:var(--ds-font-family-code);font-variant-numeric:tabular-nums}@media (prefers-reduced-motion:reduce){.NsInEG_root,.NsInEG_chevron{transition:none}}`,document.head.appendChild(e)}var kv={chevron:`NsInEG_chevron`,durationNumber:`NsInEG_durationNumber`,label:`NsInEG_label`,root:`NsInEG_root`};let Av=(0,d.memo)(function({node:e,turnProcess:t,t:n}){if(t===void 0)throw Error(`turn-process node requires Turn process owner state`);let r=!t.foldable||t.open,i=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0;if(i?.status!==`closed`)return null;let a=t.foldable&&t.hasContent&&!yh(e),o=i.end?.data.reason.kind,s=i.start===void 0||i.end===void 0||i.end.time<=i.start.time?void 0:Math.max(1e3,i.end.time-i.start.time),c=s===void 0||o===`aborted`||o===`error`||o===`unknown`?void 0:Lm(s,n),l=n(o===`unknown`?`message.turnProcess.unknown`:o===`aborted`?`message.stopped`:o===`error`?`message.turnProcess.failed`:c===void 0?`message.turnProcess.worked`:`message.turnProcess.took`),u=n(o===`unknown`?`message.turnProcess.unknown`:o===`aborted`?`message.stopped`:o===`error`?`message.turnProcess.failed`:`message.turnProcess.worked`);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Vg.visuallyHidden,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:u}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:kv.root,"data-open":r||void 0,"data-turn-process":e.data.turn,"data-turn-process-messages":e.data.messageCount,"data-turn-process-tool-calls":e.data.toolCallCount,"data-turn-process-subagents":e.data.subagentCount,disabled:!a,"aria-expanded":t.hasContent?r:void 0,onClick:e=>{e.currentTarget.focus(),t.setOpen(!r)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:kv.label,children:[l,c?.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(`span`,{className:e.numeric?kv.durationNumber:void 0,children:e.text},t))]}),a&&/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:kv.chevron})]})]})});function jv(e,t,n,r){let[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(),[c,l]=(0,d.useState)(0),u=JSON.stringify(t.filter(e=>n.has(e.path)&&e.hunks===void 0).map(e=>[e.path,e.revision]));return(0,d.useEffect)(()=>{let t=JSON.parse(u).filter(([e,t])=>i[e]?.revision!==t);if(!r||t.length===0)return;let n=!0;return s(void 0),Promise.all(t.map(async([t,n])=>[t,{revision:n,diffs:(await r(e,t)).filter(e=>e.path===t)}])).then(e=>{n&&a(t=>({...t,...Object.fromEntries(e)}))},e=>{n&&s(e instanceof Error?e.message:String(e))}),()=>{n=!1}},[e,u,r,i,c]),{diffs:e=>e.hunks??(i[e.path]?.revision===e.revision?i[e.path]?.diffs:void 0),error:o,retry:()=>l(e=>e+1)}}let Mv=`@deepseek-ai/dsh-client-ui-chat/TurnChangesCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Mv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Mv,e.textContent=`.U56YlW_card{border:1px solid var(--dsw-alias-border-l2);corner-shape:round;color:var(--dsw-alias-label-primary);font-size:calc(var(--dsh-content-font-size-secondary,13px) + 2px);--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) + 1px);--dsw-alias-state-success-primary:var(--dsw-alias-file-diff-added-marker);--dsw-alias-state-error-primary:var(--dsw-alias-file-diff-deleted-marker);border-radius:12px;margin:8px 0;line-height:20px;overflow:hidden}.U56YlW_header{-webkit-user-select:none;user-select:none;align-items:center;gap:12px;padding:12px;display:flex}.U56YlW_icon{corner-shape:round;background:color-mix(in srgb, var(--dsw-alias-label-primary) 4%, transparent);width:44px;height:44px;color:var(--dsw-alias-label-secondary);border-radius:12px;flex:none;place-items:center;display:grid}.U56YlW_text{flex-direction:column;flex:auto;gap:2px;min-width:0;display:flex}.U56YlW_title{text-overflow:ellipsis;white-space:nowrap;font-weight:600;overflow:hidden}.U56YlW_titleLink{max-width:100%;color:inherit;font-family:inherit;font-size:inherit;line-height:inherit;text-align:left;cursor:pointer;background:0 0;border:0;align-self:flex-start;margin:0;padding:0}.U56YlW_review,.U56YlW_fileHead,.U56YlW_openFile,.U56YlW_more{color:inherit;font:inherit;text-align:left;cursor:pointer;-webkit-user-select:none;user-select:none;background:0 0;border:0}.U56YlW_review{border:1px solid var(--dsw-alias-border-l2);corner-shape:round;font-size:var(--dsh-content-font-size,14px);white-space:nowrap;border-radius:12px;flex:none;padding:4px 8px;font-weight:500}@media (hover:hover){.U56YlW_review:hover,.U56YlW_fileHead:hover,.U56YlW_openFile:hover,.U56YlW_more:hover{background:var(--dsw-alias-interactive-bg-hover)}.U56YlW_titleLink:hover{text-underline-offset:3px;text-decoration:underline}}.U56YlW_review:active,.U56YlW_fileHead:active,.U56YlW_openFile:active,.U56YlW_more:active{background:var(--dsw-alias-interactive-bg-hover)}.U56YlW_review:focus-visible,.U56YlW_fileHead:focus-visible,.U56YlW_openFile:focus-visible,.U56YlW_more:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:-2px}.U56YlW_titleLink:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:2px}.U56YlW_files{border-top:1px solid var(--dsw-alias-border-l2);margin:0;padding:0;list-style:none}.U56YlW_fileRow{align-items:center;display:flex}.U56YlW_fileRow .U56YlW_fileHead{flex:auto;min-width:0}.U56YlW_openFile{corner-shape:round;width:28px;height:28px;color:var(--dsw-alias-label-secondary);border-radius:8px;flex:none;place-items:center;margin-right:8px;padding:0;display:grid}.U56YlW_fileHead{justify-content:space-between;align-items:center;gap:12px;width:100%;min-height:40px;padding:8px 12px;display:flex}.U56YlW_fileHead .U56YlW_path{min-width:0;font-size:inherit;--dsw-alias-label-tertiary:var(--dsw-alias-label-secondary);flex:1}.U56YlW_diff{padding:0 12px 12px}.U56YlW_file:first-child .U56YlW_diff:first-child{padding-top:12px}.U56YlW_more{align-items:center;gap:8px;width:100%;min-height:40px;padding:8px 12px;font-weight:500;display:flex}.U56YlW_mobileChevron,.U56YlW_mobileFileIcon,.U56YlW_mobilePath,.U56YlW_mobileFullPath{display:none}.U56YlW_chevron{flex:none;transition:transform .15s}.U56YlW_chevron[data-open=true]{transform:rotate(180deg)}@media (width<=480px){.U56YlW_header{grid-template-columns:36px minmax(0,1fr);gap:8px;display:grid}.U56YlW_icon{width:36px;height:36px}.U56YlW_review{grid-column:2;justify-self:start}}[data-phone] .U56YlW_card{-webkit-text-size-adjust:100%;text-size-adjust:100%;min-width:0;max-width:100%;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);--dsh-diff-inline-padding:12px;--dsh-diff-body-padding:4px 0 8px}[data-phone] .U56YlW_header{grid-template-columns:20px minmax(0,1fr) 44px;gap:8px;min-height:52px;padding:0 4px 0 12px;display:grid}[data-phone] .U56YlW_icon{background:0 0;border-radius:0;width:20px;height:20px}[data-phone] .U56YlW_icon>svg{width:16px;height:16px}[data-phone] .U56YlW_text{flex-direction:row;align-items:center;gap:8px}[data-phone] .U56YlW_title{flex:auto;min-width:0;font-weight:500}[data-phone] .U56YlW_review{border-radius:var(--dsw-radius-sm);border:0;grid-column:auto;justify-self:stretch;place-items:center;width:44px;height:44px;padding:0;display:grid}[data-phone] .U56YlW_reviewLabel{display:none}[data-phone] .U56YlW_mobileChevron,[data-phone] .U56YlW_mobileFileIcon{color:var(--dsw-alias-label-secondary);flex:none;display:block}[data-phone] .U56YlW_mobileChevron{transition:transform .15s}[data-phone] .U56YlW_mobileChevron[data-open=true]{transform:rotate(180deg)}[data-phone] .U56YlW_fileHead,[data-phone] .U56YlW_more{gap:8px;min-height:44px;padding:0 12px}[data-phone] .U56YlW_titleLink{align-self:center;min-height:44px}[data-phone] .U56YlW_openFile{border-radius:var(--dsw-radius-sm);width:44px;height:44px;margin-right:0}[data-phone] .U56YlW_file+.U56YlW_file{border-top:1px solid var(--dsw-alias-border-l2)}[data-phone] .U56YlW_path{display:none}[data-phone] .U56YlW_mobilePath{flex-direction:column;flex:1;min-width:0;padding-block:4px;display:flex}[data-phone] .U56YlW_fileName{text-overflow:ellipsis;white-space:nowrap;font-weight:500;overflow:hidden}[data-phone] .U56YlW_directory,[data-phone] .U56YlW_mobileFullPath{color:var(--dsw-alias-label-secondary);font-size:calc(11px + var(--dsh-content-font-delta-secondary,0px));line-height:calc(16px + var(--dsh-content-font-delta-secondary,0px));white-space:normal;overflow-wrap:anywhere}[data-phone] .U56YlW_mobileFullPath{user-select:text;padding:4px 12px;display:block}[data-phone] .U56YlW_diff,[data-phone] .U56YlW_file:first-child .U56YlW_diff:first-child{padding:0}[data-phone] .U56YlW_diffStatus{overflow-wrap:anywhere;padding:12px;display:block}[data-phone] .U56YlW_diffStatus button{min-width:44px;min-height:44px}[data-phone] .U56YlW_inlineDiff{border-radius:0;min-width:0;max-width:100%;margin:0}[data-phone] .U56YlW_inlineDiff [data-diff-body]{box-sizing:border-box;-webkit-text-size-adjust:100%;text-size-adjust:100%;width:100%;min-width:0;font-size:calc(var(--dsw-font-markdown-code-block-font-size,11px) + var(--dsh-content-font-delta,0px));line-height:calc(var(--dsw-font-markdown-code-block-line-height,19px) + var(--dsh-content-font-delta,0px));tab-size:2;overscroll-behavior-x:contain}[data-phone] .U56YlW_inlineDiff [data-diff-row=path]{display:none}[data-phone] .U56YlW_inlineDiff [data-code-block-banner]{gap:8px;min-height:44px;padding:0 8px 0 12px}[data-phone] .U56YlW_inlineDiff [data-code-block-banner] button{width:44px;height:44px}@media (prefers-reduced-motion:reduce){[data-phone] .U56YlW_mobileChevron{transition:none}}`,document.head.appendChild(e)}var Z={card:`U56YlW_card`,chevron:`U56YlW_chevron`,diff:`U56YlW_diff`,diffStatus:`U56YlW_diffStatus`,directory:`U56YlW_directory`,file:`U56YlW_file`,fileHead:`U56YlW_fileHead`,fileName:`U56YlW_fileName`,fileRow:`U56YlW_fileRow`,files:`U56YlW_files`,header:`U56YlW_header`,icon:`U56YlW_icon`,inlineDiff:`U56YlW_inlineDiff`,mobileChevron:`U56YlW_mobileChevron`,mobileFileIcon:`U56YlW_mobileFileIcon`,mobileFullPath:`U56YlW_mobileFullPath`,mobilePath:`U56YlW_mobilePath`,more:`U56YlW_more`,openFile:`U56YlW_openFile`,path:`U56YlW_path`,review:`U56YlW_review`,reviewLabel:`U56YlW_reviewLabel`,text:`U56YlW_text`,title:`U56YlW_title`,titleLink:`U56YlW_titleLink`};let Nv=(0,d.memo)(function({nodeStore:e,turn:t,t:n,useProjection:r,loadTurnDiffs:i,openFile:a}){let o=S(e,t,r),s=(0,d.useMemo)(()=>{let e=/* @__PURE__ */ new Map;for(let t of o){let n=w(t.path);e.set(n,(e.get(n)??0)+1)}return e},[o]),[c,l]=(0,d.useState)(()=>/* @__PURE__ */ new Set),[u,m]=(0,d.useState)(!1),h=jv(t,o,c,i),g=(0,d.useMemo)(()=>({codeLabel:n(`diff.code`),wrapLabel:n(`diff.wrap`),unwrapLabel:n(`diff.unwrap`),copy:n(`diff.copy`),copied:n(`diff.copied`),collapseAria:n(`diff.collapseAria`),expandAria:e=>n(`diff.expandAria`,{count:e}),collapse:n(`diff.collapse`),expand:e=>n(`diff.expand`,{count:e})}),[n]);if(o.length===0)return null;let{added:_,removed:y}=C(o),[b]=o,x=o.length===1&&b!==void 0?n(`chat.fileEdited`,{name:w(b.path)}):n(`chat.filesEdited`,{count:o.length}),T=o.some(e=>c.has(e.path)),E=u?o:o.slice(0,3),ee=o.length-E.length;return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:Z.card,"data-turn-changes":t,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.header,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.icon,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(p.IconFileDiffOutlineRegular,{size:24})}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Z.text,children:[o.length===1&&b!==void 0&&a!==void 0?/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:`${Z.title} ${Z.titleLink}`,title:n(`chat.openFile`,{path:b.path}),onClick:()=>a(b.path),children:x}):/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.title,title:x,children:x}),/* @__PURE__ */ (0,f.jsx)(v,{added:_,removed:y})]}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.review,"aria-expanded":T,"aria-label":n(T?`chat.hideChanges`:`chat.viewChanges`),onClick:()=>{l(new Set(T?[]:o.map(e=>e.path))),T||m(!0)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.reviewLabel,children:n(T?`chat.hideChanges`:`chat.viewChanges`)}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.mobileChevron,"data-open":T})]})]}),(o.length>1||T)&&/* @__PURE__ */ (0,f.jsxs)(`ul`,{className:Z.files,children:[E.map(e=>{let t=h.diffs(e),r=w(e.path);return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Z.file,children:[o.length>1&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.fileRow,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.fileHead,"aria-expanded":c.has(e.path),onClick:()=>{l(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n})},children:[/* @__PURE__ */ (0,f.jsx)(p.IconFileDiffOutlineRegular,{size:16,className:Z.mobileFileIcon}),/* @__PURE__ */ (0,f.jsx)(p.PathLabel,{path:e.path,className:Z.path}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Z.mobilePath,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.fileName,"aria-hidden":`true`,children:r}),(s.get(r)??0)>1&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.directory,"aria-hidden":`true`,children:e.path.slice(0,e.path.length-r.length)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Vg.visuallyHidden,children:e.path})]}),/* @__PURE__ */ (0,f.jsx)(v,{added:e.added,removed:e.removed}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.mobileChevron,"data-open":c.has(e.path)})]}),a!==void 0&&/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Z.openFile,"aria-label":n(`chat.openFile`,{path:e.path}),title:n(`chat.openFile`,{path:e.path}),onClick:()=>a(e.path),children:/* @__PURE__ */ (0,f.jsx)(p.IconRightUpOutlineRegular,{size:16})})]}),c.has(e.path)&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.diff,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Z.mobileFullPath,children:e.path}),t===void 0?h.error?/* @__PURE__ */ (0,f.jsxs)(`div`,{role:`alert`,className:Z.diffStatus,children:[h.error,` `,/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,onClick:h.retry,children:n(`chat.retryDiff`)})]}):/* @__PURE__ */ (0,f.jsx)(`span`,{role:`status`,className:Z.diffStatus,children:n(`chat.loadingDiff`)}):/* @__PURE__ */ (0,f.jsx)(p.DiffBlock,{diffs:[...t],labels:g,maxLines:1/0,className:Z.inlineDiff})]})]},e.path)}),o.length>3&&/* @__PURE__ */ (0,f.jsx)(`li`,{children:/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.more,"aria-expanded":u,onClick:()=>m(e=>!e),children:[ee>0?n(`chat.showMoreFiles`,{count:ee}):n(`chat.collapseFiles`),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.chevron,"data-open":u})]})})]})]})});function Pv(e){return e.flatMap(e=>e.kind===`text`?[e.text]:[]).join(``)}function Fv(e){return e.some(e=>e.kind===`reasoning`||e.kind===`tool-call`?!1:e.kind!==`text`||e.text.trim()!==``)}let Iv=`@deepseek-ai/dsh-client-ui-chat/TurnTailNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Iv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Iv,e.textContent=`.zJ_1ta_root{flex-direction:column;gap:16px;display:flex}.zJ_1ta_actions{margin-top:4px;margin-left:-6px}`,document.head.appendChild(e)}var Lv={actions:`zJ_1ta_actions`,root:`zJ_1ta_root`};function Rv(e,t,n){let r=e.locations.getTurn(t);for(let t=r.length-1;t>=0;t--){let i=e.nodes.get(r[t]);if(!(i===void 0||i.kind===`turn-tail`||i.kind===`turn-process`||n&&i.kind===`turn-max-tokens`))return i}}let zv=(0,d.memo)(function({node:e,openFile:t,forkAt:n,handoffAt:r,loadTurnDiffs:i,renderSlot:a,t:o,useChat:s,useSession:c,useProjection:l}){let u=c(e=>e.openState===`open`),p=(0,d.useRef)(!1),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(),v=e.data,y=s(e=>e.nodes),b=s(e=>(Rv(e,v.turn,!0)?.anchorSeq??-1)>(v.closing?.finalNode.seq??v.seq)),x=s(e=>{if(e.timeline.turnOrder.at(-1)!==v.turn)return!1;let t=Rv(e,v.turn,!1),n=t?.kind===`assistant-step`?t.data.blocks.findLast(e=>e.kind!==`text`&&e.kind!==`reasoning`||e.text.trim()!==``):void 0;return n!==void 0&&Fv([n])}),S=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,C=qm(l,S?.turn,`end`);if(S===void 0)return null;let w=v.closing,T=a(`conversation.chat.turnTail`,{turn:S,seq:w?.finalNode.seq??v.seq,openFile:t});if(w===null)return T===null?null:/* @__PURE__ */ (0,f.jsx)(`div`,{className:Lv.root,"data-turn-tail":v.turn,children:T});let E=w.finalNode.messageId,ee=E===void 0?null:a(`conversation.chat.assistant-actions`,{messageId:E});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Lv.root,"data-turn-tail":v.turn,"data-actions-reveal":x?`always`:`hover`,children:[/* @__PURE__ */ (0,f.jsx)(Nv,{nodeStore:y,turn:v.turn,t:o,useProjection:l,loadTurnDiffs:i,openFile:t}),T,/* @__PURE__ */ (0,f.jsx)(Km,{text:Pv(w.blocks),time:C,clock:`end`,onBranch:()=>{!p.current&&u&&(p.current=!0,h(!0),_(void 0),n(v.seq).catch(e=>{_(e instanceof Error?e.message:String(e))}).finally(()=>{p.current=!1,h(!1)}))},branchUnavailable:!u||m||v.branchUnavailable||b,onHandoff:r===void 0?void 0:()=>{u&&r(v.seq)},handoffUnavailable:!u||v.branchUnavailable||b,className:Lv.actions,extraActions:ee,t:o}),g!==void 0&&/* @__PURE__ */ (0,f.jsx)(`p`,{role:`alert`,children:o(`message.branchFailed`,{message:g})})]})});function Bv(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Vv(e,t){return typeof e[t]==`string`?e[t]:``}function Hv(e){let t=Bv(e.source),n=Vv(t,`kind`),r=`message.trigger.request`,i=`request`;switch(n){case`goal`:r=`message.trigger.goal`,i=`goal`;break;case`agent-message`:r=`message.trigger.agent`,i=`agent`;break;case`team-message`:r=`message.trigger.team`,i=`team`;break;case`subagent-settled`:r=`message.trigger.subagent`,i=`subagent`;break;case`webhook`:{let e=Vv(t,`provider`)===`github`;r=e?`message.trigger.github`:`message.trigger.webhook`,i=e?`github`:`webhook`;break}case`schedule`:r=`message.trigger.schedule`,i=`schedule`;break;case`tool-jobs`:r=`message.trigger.job`,i=`job`;break;case`cordis-host-runner`:r=`message.trigger.plugin`,i=`plugin`}return{title:r,icon:i}}let Uv=`@deepseek-ai/dsh-client-ui-chat/TurnTriggerNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Uv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Uv,e.textContent=`.kkOUVW_root{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-xl);background:var(--dsw-alias-turn-trigger-bg,var(--dsw-alias-markdown-code-block));min-width:0;transition:background-color .1s}@media (hover:hover){.kkOUVW_root:hover{background:var(--dsw-alias-turn-trigger-bg-hover,var(--dsw-alias-interactive-bg-hover))}}.kkOUVW_header{width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:10px;padding:12px 16px;transition:color .1s;display:flex}@media (hover:hover){.kkOUVW_header:hover{color:var(--dsw-alias-label-secondary)}}.kkOUVW_header:active{color:var(--dsw-alias-label-secondary)}.kkOUVW_icon{color:inherit;flex:none;display:inline-flex}.kkOUVW_title{font-size:var(--dsh-content-font-size,14px);flex:none}.kkOUVW_time{color:inherit;font:var(--dsw-font-xxs-12);flex:none;margin-left:auto}.kkOUVW_chevron,.kkOUVW_openChevron{color:inherit;flex:none}.kkOUVW_openChevron{transform:rotate(180deg)}.kkOUVW_body{padding:0 16px 12px 40px}.kkOUVW_explanation{color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xxs-12);margin:8px 0}.kkOUVW_content{white-space:pre-wrap;overflow-wrap:anywhere;max-height:240px;font:var(--dsw-font-xxs-12);overflow:auto}@media (prefers-reduced-motion:reduce){.kkOUVW_root,.kkOUVW_header{transition:none}}`,document.head.appendChild(e)}var Wv={body:`kkOUVW_body`,chevron:`kkOUVW_chevron`,content:`kkOUVW_content`,explanation:`kkOUVW_explanation`,header:`kkOUVW_header`,icon:`kkOUVW_icon`,openChevron:`kkOUVW_openChevron`,root:`kkOUVW_root`,time:`kkOUVW_time`,title:`kkOUVW_title`};let Gv={request:p.IconContextInjectionOutlineRegular,goal:p.IconGoalOutlineRegular,agent:p.IconPaperPlaneOutlineRegular,team:p.IconAgentPresetOutlineRegular,subagent:p.IconAgentPresetOutlineRegular,github:p.IconBranchOutlineRegular,webhook:p.IconGlobeOutlineRegular,schedule:p.IconClockOutlineRegular,job:p.IconQueueOutlineRegular,plugin:p.IconCordisPluginOutlineRegular};function Kv({node:e,t}){let[n,r]=(0,d.useState)(!1),i=(0,d.useId)(),a=Hv(e.data),o=Gv[a.icon],s=new Date(e.data.time),c=Rm(e.data.time,t);return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:Wv.root,"data-turn-trigger":!0,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{className:Wv.header,type:`button`,"aria-expanded":n,"aria-controls":i,onClick:()=>{r(!n)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Wv.icon,"aria-hidden":!0,children:/* @__PURE__ */ (0,f.jsx)(o,{size:14})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Wv.title,children:t(a.title)}),/* @__PURE__ */ (0,f.jsx)(`time`,{className:Wv.time,dateTime:s.toISOString(),children:c}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:12,className:n?Wv.openChevron:Wv.chevron})]}),n&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:i,className:Wv.body,children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:Wv.explanation,children:t(`message.trigger.explanation`)}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:Wv.content,children:/* @__PURE__ */ (0,f.jsx)(wm,{content:e.data.content,source:e.data.source,t})})]})]})}function qv(e,t){e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`user`,locale:Q_,inject:()=>({links:e.get(`chatLinks`)})},sh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`steering`,locale:Q_,inject:()=>({links:e.get(`chatLinks`)})},sh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`context`,locale:Q_},lh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-trigger`,locale:Q_},Kv)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`system-prompt`,locale:Q_},Dv)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`assistant-step`,locale:Q_,inject:()=>({hooks:{presentation:t}})},_v)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`command`,locale:Q_,children:{"conversation.chat.commandview":{kind:`keyed`,scope:`session`}}},wv)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`manual-compaction`,locale:Q_},Tv)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`compaction`,locale:Q_},uh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`model-retry`,locale:Q_},dh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-error`,locale:Q_},fh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-max-tokens`,locale:Q_},ph)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-process`,locale:Q_},Av)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-tail`,locale:Q_,children:{"conversation.chat.turnTail":{kind:`list`,scope:`session`},"conversation.chat.assistant-actions":{kind:`list`,scope:`session`}}},zv)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`unknown`,locale:Q_},mh))}let Jv={interruptedAssistant:-.9,interruptedFollowup:-.8,processControl:-.1,maxTokensNotice:.05,finalizedFollowup:.1};function Yv(e){return e.start?.location??e.matches[0]?.location??{kind:`unresolved`}}function Xv(e,t,n,r,i={}){return{key:e.key,kind:t,id:e.id,target:`chat`,anchorSeq:n,location:i.location??Yv(e),visibility:i.visibility??`visible`,data:r}}function Zv(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Qv(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function $v(e,t,n){let r=e[t];if(!Array.isArray(r))return[];let i=[];for(let e of r){let t=Zv(e),r=t===null?null:Qv(t,n);r!==null&&!i.includes(r)&&i.push(r)}return i}function ey(e){return e.length>0?e.join(`, `):null}let ty=[`instructions`,`catalog`,`snapshot`,`notice`,`relay`,`recall`];function ny(e){let t=Zv(e),n=t===null?null:Qv(t,`form`);return n!==null&&ty.includes(n)?n:null}function ry(e){let t=Zv(e),n=t===null?null:Qv(t,`kind`);if(t===null||n===null)return{role:`inject`,label:null};switch(n){case`session-reference`:return{role:`recall`,label:ey($v(t,`references`,`label`))??n};case`agent-instructions`:return{role:`inject`,label:ey($v(t,`changes`,`path`))??n};case`skill-invocation`:return{role:`inject`,label:Qv(t,`name`)??n};default:return{role:`inject`,label:n}}}function iy(e){let t=Zv(e);return t===null||Qv(t,`kind`)!==`session-reference`?[]:$v(t,`references`,`label`)}function ay(e){let t=Zv(e);return t===null||Qv(t,`kind`)!==`skill-invocation`?null:Qv(t,`name`)}function oy(e){return e.map(sy)}function sy(e){switch(e.type){case`text`:return{kind:`text`,text:e.text};case`reasoning`:return{kind:`reasoning`,text:e.text};case`image`:return e.codexhostImageView===!0?{kind:`viewed-images`,attachment:e.attachment}:{kind:`image`,attachment:e.attachment};case`tool-call`:return{kind:`tool-call`,callId:String(e.id),name:e.name,argsRaw:e.arguments};default:return{kind:`other`,block:e}}}function cy(e){switch(e){case`text`:return{kind:`text`,text:``};case`reasoning`:return{kind:`reasoning`,text:``};case`tool-call`:return{kind:`tool-call`,callId:``,name:``,argsRaw:``};default:return{kind:`other`,block:null}}}function ly(e){if(typeof e!=`object`||!e)return{message:String(e)};let t=e,n=typeof t.code==`string`?t.code:void 0;return n===`AUTH`?{code:n,message:``}:{...n===void 0?{}:{code:n},message:typeof t.message==`string`?t.message:JSON.stringify(e)}}function uy(e){switch(e.type){case`text-delta`:case`reasoning-delta`:return e.text!==``;case`tool-call-delta`:return e.argumentsDelta!==``||e.name!==void 0;default:return!1}}function dy(e,t){return{turn:e,step:t,blocks:[],visibleByIndex:[],visibleBlocks:0,firstVisibleSeq:void 0,firstVisibleTime:void 0,firstTokenTime:void 0,final:void 0,usage:void 0}}function fy(e){return e.filter(e=>e!==void 0)}function py(e){return e===void 0||e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0}function my(e){return e.some(py)}function hy(e){return e.some(e=>e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function gy(e){return{...dy(e.turn,e.step),firstTokenTime:e.firstTokenTime}}function _y(e,t,n,r){if(t.type===`tool-call-delta`){let n=e.blocks[t.index];if(n?.kind===`tool-call`&&n.callId!==``&&(t.name===void 0||t.name===n.name)&&(e.firstTokenTime!==void 0||!uy(t)))return e}let i=[...e.blocks],a=-1,o=!1,s=!1;switch(t.type){case`block-start`:a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]=cy(t.blockType),s=py(i[t.index]);break;case`text-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`text`,text:(n?.kind===`text`?n.text:``)+t.text},s=n?.kind===`text`&&o||t.text.trim()!==``;break}case`reasoning-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`reasoning`,text:(n?.kind===`reasoning`?n.text:``)+t.text},s=n?.kind===`reasoning`&&o||t.text.trim()!==``;break}case`tool-call-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`tool-call`,callId:(n?.kind===`tool-call`?n.callId:``)||String(t.id),name:t.name??(n?.kind===`tool-call`?n.name:``),argsRaw:n?.kind===`tool-call`?n.argsRaw:``};break}case`block-end`:a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]=sy(t.block),s=py(i[t.index]);break;case`usage`:return{...e,usage:t.usage};default:return e}let c=e.visibleBlocks-Number(o)+Number(s),l=e.visibleByIndex;if(o!==s){let e=[...l];e[a]=s,l=e}let u=uy(t);return{...e,blocks:i,visibleByIndex:l,visibleBlocks:c,...c>0&&e.firstVisibleSeq===void 0?{firstVisibleSeq:n,firstVisibleTime:r}:{},...u&&e.firstTokenTime===void 0?{firstTokenTime:r}:{}}}function vy(e,t,n){let r=oy(n.data.message.content),i=r.map(py);return{...e,blocks:r,visibleByIndex:i,visibleBlocks:i.reduce((e,t)=>e+Number(t),0),final:t,usage:n.data.usage}}function yy(e){if(e.kind===`step`&&e.step.status===`closed`&&e.step.end!==void 0)return e.step.end;if((e.kind===`step`||e.kind===`turn`)&&e.turn.status===`closed`&&e.turn.end!==void 0)return e.turn.end}function by(e,t){let n=e.final;if(n?.event.type===`assistant/message`){let r=n.event;return{kind:`assistant`,seq:r.seq,messageId:r.data.message.id,time:r.time,turn:e.turn,step:e.step,blocks:oy(r.data.message.content),usage:r.data.usage,timing:{stepStartTime:t.start?.event.time??null,firstTokenTime:e.firstTokenTime??null,completedTime:r.time},...r.data.interrupted===!0?{interrupted:!0}:{}}}let r=t.start?.location??t.matches.at(-1)?.location,i=r===void 0?void 0:yy(r);if(i===void 0)return;let a=fy(e.blocks);if(hy(a))return{kind:`assistant`,seq:i.seq+Jv.interruptedAssistant,time:i.time,turn:e.turn,step:e.step,blocks:a,interrupted:!0}}function xy(e){let t;for(let n of e.matches)n.event.type===`assistant/live-chunk`?(t??=dy(n.event.data.turn,n.event.data.step),t=_y(t,n.event.data.chunk,n.event.seq,n.event.time)):n.event.type===`assistant/message`?(t??=dy(n.event.data.turn,n.event.data.step),t=vy(t,n,n.event)):n.event.type===`llm/retry`&&t!==void 0&&(t=gy(t));return t}function Sy(e){let t=e.state??xy(e);if(t===void 0)return;let n=by(t,e),r=n?.blocks??fy(t.blocks),i=n===void 0?t.visibleBlocks>0:my(r),a=n?.interrupted===!0?`interrupted`:n===void 0?`running`:`settled`,o=(n?.interrupted===!0?n.seq:t.firstVisibleSeq??n?.seq)??e.matches[0]?.event.seq??0,s=n?.time??t.firstVisibleTime??e.matches[0]?.event.time??0;return{anchorSeq:o,visible:i,settled:n,data:{status:a,turn:t.turn,step:t.step,blocks:r,time:s,...t.usage===void 0?{}:{usage:t.usage},...n===void 0?{}:{finalNode:n}}}}function Cy(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`step`?t.step.data.get(`assistant-step`):void 0}let wy={kind:`assistant-step`,target:`chat`,match:e=>e.type===`step/start`?{id:`${e.data.turn}:${e.data.step}`,role:`start`}:e.type===`assistant/live-chunk`||e.type===`assistant/message`&&e.surfaceOp===`append`||e.type===`llm/retry`?{id:`${e.data.turn}:${e.data.step}`,role:`update`}:null,start:(e,t)=>{if(t.event.type!==`step/start`)throw Error(`assistant-step start requires step/start`);return dy(t.event.data.turn,t.event.data.step)},update:(e,t)=>t.event.type===`assistant/live-chunk`?_y(e.state,t.event.data.chunk,t.event.seq,t.event.time):t.event.type===`assistant/message`?vy(e.state,t,t.event):t.event.type===`llm/retry`?gy(e.state):e.state,publication:e=>{if(e.event.type===`step/start`)return`none`;if(e.event.type!==`assistant/live-chunk`)return`immediate`;let t=e.event.data.chunk.type;return t===`usage`||t===`finish`?`none`:`animation-frame`},buildLocationData:(e,t)=>{if(t!==`step`)return null;let n=Sy(e);return n===void 0?null:{kind:`step`,turn:n.data.turn,step:n.data.step,key:`assistant-step`,value:n.data}},buildViewNode:e=>{let t=e.current.get(`chat`),n=e.state??xy(e),r=Cy(e);if(n===void 0||r===void 0)return t==null?null:{...t,visibility:`hidden`};let i=r.finalNode,a=i===void 0?n.visibleBlocks>0:my(r.blocks);return i===void 0&&!a&&t==null?null:Xv(e,`assistant-step`,(i?.interrupted===!0?i.seq:n.firstVisibleSeq??i?.seq)??e.matches[0]?.event.seq??0,r,{visibility:i?.interrupted===!0||a?`visible`:`hidden`})}};function Ty(e){let t=wy.match.bind(wy);e.uiConversation.events.register({...wy,match:{"step/start":t,"assistant/live-chunk":t,"assistant/message":t,"llm/retry":t}})}function Ey(e){return`kind`in e}function Dy(e){return!Ey(e)}function Oy(e){return e.visibility===`visible`&&e.kind!==`system-prompt`&&(e.kind!==`context`||e.data.content.some(e=>e.type===`tool-addition`||e.type===`tool-removal`))&&(e.kind!==`command`||e.data.name!==`permission`)}function ky(e,t){let n=``,r=!1;for(let i of e){if(n.length>=t*2){r=!0;break}let e=i.length>t*2,a=e?i.slice(0,t*2):i;if(n+=n===``?a:` ${a}`,e){r=!0;break}}let i=n.replace(/\s+/g,` `).trim();return i.length>t-1?`${i.slice(0,t-1).trimEnd()}…`:r?`${i}…`:i}function Ay(e){return e.kind===`user`?ky(e.data.content.flatMap(e=>e.type===`text`?[e.text]:[]),50):``}function jy(e){return e.kind===`assistant-step`?ky(e.data.blocks.flatMap(e=>e.kind===`text`?[e.text]:[]),120):``}function My(e,t){return e===void 0||t===void 0?e===t:e.turn===t.turn&&e.anchorKey===t.anchorKey&&e.prompt===t.prompt&&e.response===t.response}function Ny(e,t,n){let r=t.getTurn(e).map(e=>n.get(e)).filter(e=>e!==void 0&&Oy(e)),i=r.find(e=>e.kind===`user`),a=i??r[0];if(a===void 0)return;let o=r.findLast(e=>jy(e)!==``);return{turn:e,anchorKey:a.key,prompt:i===void 0?``:Ay(i),response:o===void 0?``:jy(o)}}function Py(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function Fy(e,t){return e===t||e!==void 0&&t!==void 0&&e.spec===t.spec&&e.turn===t.turn&&e.turnStarted===t.turnStarted&&e.turnClosed===t.turnClosed&&e.hasExternalProcess===t.hasExternalProcess&&e.hasInterleavedInput===t.hasInterleavedInput&&e.compactAnswer===t.compactAnswer}function Iy(e,t,n){let r=t.getTurn(e),i=r.map(e=>n.get(e)).find(e=>e?.kind===`turn-process`);if(i===void 0)return;let a=i.data,o=i.location;if(o.kind!==`turn`&&o.kind!==`step`)return;let s;for(let e of r){let t=n.get(e);(t?.kind===`user`||t?.kind===`steering`||t?.kind===`turn-trigger`)&&(a.controlAnchorSeq===o.turn.start?.seq||t.anchorSeq<a.controlAnchorSeq)&&(s=Math.max(s??t.anchorSeq,t.anchorSeq))}let c=!1,l=!1,u=!0;for(let e of r){let t=n.get(e);t!==void 0&&Oy(t)&&t.kind!==`turn-process`&&((t.kind===`user`||t.kind===`steering`||t.kind===`turn-trigger`)&&(s===void 0||t.anchorSeq>s)&&(l=!0,(a.answerAnchorSeq===null||t.anchorSeq<a.answerAnchorSeq)&&(u=!1)),!(hh.has(t.kind)||t.anchorSeq<a.processStartSeq)&&(t.kind!==`assistant-step`||a.answerStep===null||t.data.step!==a.answerStep)&&(c=!0))}return{turn:e,spec:a,turnStarted:o.turn.start!==void 0,turnClosed:o.turn.status===`closed`,hasExternalProcess:c,hasInterleavedInput:l,compactAnswer:u}}var Ly=class{presentations=/* @__PURE__ */ new Map;get(e){let t=Py(e);return t===void 0?void 0:this.presentations.get(t)}replace(e,t,n){let r=/* @__PURE__ */ new Set;for(let t of e){let e=Py(n.get(t));e!==void 0&&r.add(e)}let i=/* @__PURE__ */ new Set;for(let e of/* @__PURE__ */ new Set([...this.presentations.keys(),...r]))this.set(e,r.has(e)?Iy(e,t,n):void 0)&&i.add(e);return i}update(e,t,n){let r=/* @__PURE__ */ new Set;for(let i of e)this.set(i,Iy(i,t,n))&&r.add(i);return r}set(e,t){return!Fy(this.presentations.get(e),t)&&(t===void 0?this.presentations.delete(e):this.presentations.set(e,t),!0)}};let Ry=[],zy=[],By=[],Vy=[];function Hy(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Uy(e,t,n){let r=e.get(t);return r===void 0&&(r=n(),e.set(t,r)),r}var Wy=class{read;label;listeners=/* @__PURE__ */ new Set;published;constructor(e,t){this.read=e,this.label=t,this.published=e()}getSnapshot=()=>this.read();subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(){let e=this.getSnapshot();this.published!==e&&(this.published=e,(0,m.notifySubscribers)(this.listeners,this.label))}},Gy=class{nodes=/* @__PURE__ */ new Map;current=Vy;dirty=!1;observable;source(){return this.observable??=new Wy(()=>this.read(),`[ui-chat] turn kind nodes`)}set(e){let t=this.nodes.get(e.key);this.nodes.set(e.key,e),(t===void 0||t.data!==e.data||t.anchorSeq!==e.anchorSeq)&&(this.dirty=!0)}delete(e){this.nodes.delete(e),this.dirty=!0}publish(){this.observable?.publish()}read(){return this.dirty&&=(this.current=[...this.nodes.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).map(e=>e.data),!1),this.current}},Ky=class{byKey=/* @__PURE__ */ new Map;turnProcesses=new Ly;sources=/* @__PURE__ */ new Map;processSources=/* @__PURE__ */ new Map;dirtyKeys=/* @__PURE__ */ new Set;dirtyProcessKeys=/* @__PURE__ */ new Set;turnKinds=/* @__PURE__ */ new Map;dirtyTurnKinds=/* @__PURE__ */ new Set;valuesCache=Vy;valuesDirty=!1;get(e){return this.byKey.get(e)}source(e){return Uy(this.sources,e,()=>new Wy(()=>this.get(e),`[ui-chat] node source ${e}`))}turnDataSource(e,t){return this.turnKind(e,t).source()}turnKind(e,t){return Uy(Uy(this.turnKinds,e,()=>/* @__PURE__ */ new Map),t,()=>new Gy)}updateTurnKind(e,t){let n=e===void 0?void 0:Zy(e.location).turn,r=t===void 0?void 0:Zy(t.location).turn;if(e!==void 0&&n!==void 0&&(n!==r||e.kind!==t?.kind)){let t=this.turnKind(n,e.kind);t.delete(e.key),this.dirtyTurnKinds.add(t)}if(t!==void 0&&r!==void 0){let e=this.turnKind(r,t.kind);e.set(t),this.dirtyTurnKinds.add(e)}}processSource(e){return Uy(this.processSources,e,()=>new Wy(()=>this.process(e),`[ui-chat] node process source ${e}`))}process(e){return this.turnProcesses.get(this.get(e))}values(){return this.valuesDirty&&=(this.valuesCache=[...this.byKey.values()],!1),this.valuesCache}replace(e){let t=new Map(this.byKey);this.byKey.clear();for(let n of e)this.byKey.set(n.key,n),t.get(n.key)!==n&&(this.updateTurnKind(t.get(n.key),n),this.dirtyKeys.add(n.key),this.dirtyProcessKeys.add(n.key)),t.delete(n.key);for(let e of t.keys())this.updateTurnKind(t.get(e),void 0),this.dirtyKeys.add(e),this.dirtyProcessKeys.add(e);this.valuesCache=[...this.byKey.values()],this.valuesDirty=!1}upsert(e){let t=!1;for(let n of e)this.byKey.get(n.key)!==n&&(this.updateTurnKind(this.byKey.get(n.key),n),this.byKey.set(n.key,n),this.dirtyKeys.add(n.key),this.dirtyProcessKeys.add(n.key),t=!0);t&&(this.valuesDirty=!0)}touchProcesses(e,t){for(let n of e)for(let e of t.getTurn(n))this.dirtyProcessKeys.add(e)}replaceProcesses(e,t){this.touchProcesses(this.turnProcesses.replace(e,t,this),t)}updateProcesses(e,t){this.touchProcesses(this.turnProcesses.update(e,t,this),t)}publish(){let e=[...this.dirtyKeys],t=[...this.dirtyProcessKeys],n=[...this.dirtyTurnKinds];this.dirtyKeys.clear(),this.dirtyProcessKeys.clear(),this.dirtyTurnKinds.clear();for(let t of e)this.sources.get(t)?.publish();for(let e of t)this.processSources.get(e)?.publish();for(let e of n)e.publish()}},qy=class{turns=/* @__PURE__ */ new Map;steps=/* @__PURE__ */ new Map;positions=/* @__PURE__ */ new Map;getTurn(e){return this.turns.get(e)??Ry}getStep(e,t){return this.steps.get(Xy(e,t))??Ry}getPosition(e){return this.positions.get(e)}rebuild(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Set;for(let[o,s]of e.entries()){let c=t.get(s)?.location;if(c===void 0)continue;let l=Zy(c),u=this.positions.get(s),d={turn:l.turn,previous:e[o-1],next:e[o+1]},f=u!==void 0&&u.turn===d.turn&&u.previous===d.previous&&u.next===d.next;if(i.set(s,f?u:d),f||(u?.turn!==void 0&&a.add(u.turn),d.turn!==void 0&&a.add(d.turn)),l.turn===void 0)continue;let p=n.get(l.turn)??[];if(p.push(s),n.set(l.turn,p),l.step===void 0)continue;let m=Xy(l.turn,l.step),h=r.get(m)??[];h.push(s),r.set(m,h)}for(let[e,t]of this.positions)!i.has(e)&&t.turn!==void 0&&a.add(t.turn);return this.positions=i,this.turns=Jy(this.turns,n),this.steps=Jy(this.steps,r),[...a]}touch(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let r of e){let e=Zy(r.location);e.turn!==void 0&&this.turns.get(e.turn)?.includes(r.key)&&(t.add(e.turn),e.step!==void 0&&n.add(Xy(e.turn,e.step)))}for(let e of t){let t=this.turns.get(e);t!==void 0&&this.turns.set(e,[...t])}for(let e of n){let t=this.steps.get(e);t!==void 0&&this.steps.set(e,[...t])}}};function Jy(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set([...e.keys(),...t.keys()]);for(let i of r){let r=e.get(i)??Ry,a=t.get(i)??Ry,o=Hy(r,a)?r:a;a.length>0&&n.set(i,o)}return n}var Yy=class{current=By;byTurn=/* @__PURE__ */ new Map;items(){return this.current}rebuild(e,t,n){let r=[],i=/* @__PURE__ */ new Map;for(let a of e.turnOrder){let e=Ny(a,t,n);if(e===void 0)continue;let o=this.byTurn.get(a),s=o!==void 0&&My(o,e)?o:e;r.push(s),i.set(a,s)}this.byTurn=i,r.length===this.current.length&&r.every((e,t)=>e===this.current[t])||(this.current=r)}touch(e,t,n){if(e.size===0)return;let r=this.current.map(r=>{if(!e.has(r.turn))return r;let i=Ny(r.turn,t,n);return i===void 0||My(r,i)?r:(this.byTurn.set(r.turn,i),i)});r.some((e,t)=>e!==this.current[t])&&(this.current=r)}};function Xy(e,t){return`${e}:${t}`}function Zy(e){return e.kind===`step`?{turn:e.turn.turn,step:e.step.step}:e.kind===`turn`?{turn:e.turn.turn}:{}}function Qy(e){return e.kind===`turn`||e.kind===`step`?e.turn.status:void 0}function $y(e,t,n){return n||e===void 0||Qy(e.location)!==Qy(t.location)?!0:e.kind===`turn-process`&&t.kind===`turn-process`?e.data!==t.data:e.kind===`assistant-step`&&t.kind===`assistant-step`&&e.data.step!==t.data.step}function eb(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=n;e.kind===`turn-process`&&t.set(e.data.turn,{...t.get(e.data.turn),control:e})}for(let n of e){let e=n,r=e.location;if(r.kind!==`turn`&&r.kind!==`step`)continue;let i=t.get(r.turn.turn)??{},a=i.control?.data.controlAnchorSeq;(e.kind===`user`||e.kind===`turn-trigger`||e.kind===`steering`)&&a!==void 0&&(a===r.turn.start?.seq||e.anchorSeq<a)?t.set(r.turn.turn,{...i,openingInputAnchor:Math.max(i.openingInputAnchor??e.anchorSeq,e.anchorSeq)}):hh.has(e.kind)||t.set(r.turn.turn,{...i,earliestProcessAnchor:Math.min(i.earliestProcessAnchor??e.anchorSeq,e.anchorSeq)})}return t}function tb(e,t){let n=e,r=n.location;if(r.kind!==`turn`&&r.kind!==`step`)return{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq};let i=t.get(r.turn.turn);if(i===void 0)return{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq};let a=i.openingInputAnchor;return a!==void 0&&n.anchorSeq<a&&!hh.has(n.kind)?{anchor:a,rank:2,originalAnchor:n.anchorSeq}:i.control!==void 0&&n.key===i.control.key?a===void 0?{anchor:i.earliestProcessAnchor??n.anchorSeq,rank:-1,originalAnchor:n.anchorSeq}:{anchor:a,rank:1,originalAnchor:n.anchorSeq}:{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq}}function nb(e){let t=e.filter(e=>Oy(e)),n=eb(t);return t.sort((e,t)=>{let r=tb(e,n),i=tb(t,n);return r.anchor-i.anchor||r.rank-i.rank||r.originalAnchor-i.originalAnchor||e.key.localeCompare(t.key)})}function rb(e){let t=e;return t.kind===`user`||t.kind===`steering`?t.data.seq:void 0}function ib(e){let t=e;if(t.kind===`context`)return{messageSeq:t.data.seq-1,labels:iy(t.data.source)}}function ab(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.referenceLabels??Ry,i=Object.hasOwn(n.data,`referenceLabels`);if(Hy(r,t)&&i===t.length>0)return e;let a={...n.data};return t.length===0?delete a.referenceLabels:a.referenceLabels=t,{...n,data:a}}var ob=class{messagesBySeq=/* @__PURE__ */ new Map;labelsByMessageSeq=/* @__PURE__ */ new Map;replace(e){this.messagesBySeq.clear(),this.labelsByMessageSeq.clear();for(let t of e){let e=rb(t);e!==void 0&&this.messagesBySeq.set(e,t.key);let n=ib(t);n!==void 0&&n.labels.length>0&&this.labelsByMessageSeq.set(n.messageSeq,n.labels)}return e.map(e=>{let t=rb(e);return t===void 0?e:ab(e,this.labelsByMessageSeq.get(t)??Ry)})}apply(e,t){let n=new Map(e.map(e=>[e.key,e])),r=/* @__PURE__ */ new Set;for(let t of e){let e=rb(t);e!==void 0&&(this.messagesBySeq.set(e,t.key),r.add(e));let n=ib(t);if(n===void 0)continue;let i=this.labelsByMessageSeq.get(n.messageSeq);n.labels.length===0?this.labelsByMessageSeq.delete(n.messageSeq):this.labelsByMessageSeq.set(n.messageSeq,i!==void 0&&Hy(i,n.labels)?i:n.labels),r.add(n.messageSeq)}for(let e of r){let r=this.messagesBySeq.get(e);if(r===void 0)continue;let i=n.get(r)??t.get(r);i!==void 0&&n.set(r,ab(i,this.labelsByMessageSeq.get(e)??Ry))}return[...n.values()]}};function sb(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.skillNames??Ry,i=Object.hasOwn(n.data,`skillNames`);if(Hy(r,t)&&i===t.length>0)return e;let a={...n.data};return t.length===0?delete a.skillNames:a.skillNames=t,{...n,data:a}}function cb(e){let t=e;if(t.kind===`user`||t.kind===`steering`)return{key:e.key,seq:e.anchorSeq,kind:`message`,name:null};if(t.kind===`context`){let n=ay(t.data.source);return n===null?null:{key:e.key,seq:e.anchorSeq,kind:`skill`,name:n}}return{key:e.key,seq:e.anchorSeq,kind:`boundary`,name:null}}function lb(e,t){return e.seq===t.seq&&e.kind===t.kind&&e.name===t.name}var ub=class{entries=/* @__PURE__ */ new Map;sorted=[];replace(e){this.entries.clear(),this.sorted=[];for(let t of e){let e=cb(t);e!==null&&(this.entries.set(e.key,e),this.sorted.push(e))}this.sorted.sort((e,t)=>e.seq-t.seq);let t=/* @__PURE__ */ new Map;for(let e=0;e<this.sorted.length;e++){if(this.sorted[e]?.kind===`boundary`)continue;let n=this.runEnd(e);this.assignRun(e,n,t),e=n}return e.map(e=>sb(e,t.get(e.key)??Ry))}apply(e,t){let n=[];for(let t of e){let e=cb(t),r=this.entries.get(t.key);if(r!==void 0){if(e!==null&&lb(r,e)){e.kind===`message`&&n.push(e.seq);continue}this.remove(r),n.push(r.seq)}e!==null&&(this.insert(e),n.push(e.seq))}if(n.length===0)return e;let r=/* @__PURE__ */ new Map;for(let e of n)this.collectAround(e,r);let i=new Map(e.map(e=>[e.key,e]));for(let[e,n]of r){let r=i.get(e)??t.get(e);if(r===void 0)continue;let a=sb(r,n);(a!==r||i.has(e))&&i.set(e,a)}return[...i.values()]}insert(e){this.sorted.splice(this.lowerBound(e.seq),0,e),this.entries.set(e.key,e)}remove(e){this.sorted.splice(this.sorted.indexOf(e),1),this.entries.delete(e.key)}lowerBound(e){let t=0,n=this.sorted.length;for(;t<n;){let r=t+n>>>1;(this.sorted[r]?.seq??1/0)<e?t=r+1:n=r}return t}runEnd(e){let t=e;for(;t+1<this.sorted.length&&this.sorted[t+1]?.kind!==`boundary`;)t++;return t}runStart(e){let t=e;for(;t-1>=0&&this.sorted[t-1]?.kind!==`boundary`;)t--;return t}assignRun(e,t,n){let r=[];for(let n=e;n<=t;n++){let e=this.sorted[n];e?.kind===`skill`&&e.name!==null&&!r.includes(e.name)&&r.push(e.name)}for(let i=e;i<=t;i++){let e=this.sorted[i];e?.kind===`message`&&n.set(e.key,r)}}collectAround(e,t){let n=this.lowerBound(e),r=this.sorted[n];if(r!==void 0&&r.seq===e&&r.kind!==`boundary`){this.assignRun(this.runStart(n),this.runEnd(n),t);return}n-1>=0&&this.sorted[n-1]?.kind!==`boundary`&&this.assignRun(this.runStart(n-1),n-1,t);let i=r!==void 0&&r.seq===e?n+1:n;i<this.sorted.length&&this.sorted[i]?.kind!==`boundary`&&this.assignRun(i,this.runEnd(i),t)}};let db={anchorSeq:0,nodes:Vy,partial:null,running:null};function fb(e){let t=e;if(e.visibility!==`visible`&&t.kind!==`assistant-step`)return db;switch(t.kind){case`user`:case`steering`:case`context`:case`command`:case`compaction`:case`turn-error`:case`turn-max-tokens`:case`unknown`:return{anchorSeq:t.anchorSeq,nodes:[t.data],partial:null,running:null};case`assistant-step`:{let n=t.data;return n.status===`running`?e.visibility===`visible`?{anchorSeq:t.anchorSeq,nodes:Vy,partial:{turn:n.turn,step:n.step,blocks:n.blocks},running:null}:db:{anchorSeq:t.anchorSeq,nodes:n.finalNode===void 0?Vy:[n.finalNode],partial:null,running:null}}case`tool-call`:{let e=t.data.root;return Dy(e)?{anchorSeq:t.anchorSeq,nodes:Vy,partial:null,running:e}:{anchorSeq:t.anchorSeq,nodes:[e],partial:null,running:null}}case`manual-compaction`:{let e=t.data;return{anchorSeq:t.anchorSeq,nodes:e.compaction===null?[e.command]:[e.command,e.compaction],partial:null,running:null}}case`model-retry`:return{anchorSeq:t.anchorSeq,nodes:t.data.attempts,partial:null,running:null};case`turn-tail`:case`system-prompt`:return db;default:return db}}function pb(e,t){return e!==void 0&&e.anchorSeq===t.anchorSeq&&e.partial?.blocks===t.partial?.blocks&&e.partial?.turn===t.partial?.turn&&e.partial?.step===t.partial?.step&&e.running===t.running&&Hy(e.nodes,t.nodes)}var mb=class{contributions=/* @__PURE__ */ new Map;finalizedContributions=/* @__PURE__ */ new Map;runningContributions=/* @__PURE__ */ new Map;partialContributions=/* @__PURE__ */ new Map;finalized=Vy;runningCalls=Vy;partial=null;timeline;turnTimings=/* @__PURE__ */ new Map;turnEnds=/* @__PURE__ */ new Map;replace(e,t){this.contributions.clear(),this.finalizedContributions.clear(),this.runningContributions.clear(),this.partialContributions.clear();for(let t of e){let e=fb(t);this.contributions.set(t.key,e),this.indexContribution(t.key,e)}return this.rebuildFinalized(),this.rebuildRunning(),this.rebuildPartial(),this.updateTimeline(t),this.snapshot()}apply(e,t){let n=!1,r=!1,i=!1;for(let t of e){let e=fb(t),a=this.contributions.get(t.key);pb(a,e)||(n||=gb(a,e),r||=_b(a,e),i||=vb(a,e),this.contributions.set(t.key,e),this.indexContribution(t.key,e))}return n&&this.rebuildFinalized(),r&&this.rebuildRunning(),i&&this.rebuildPartial(),this.updateTimeline(t),this.snapshot()}indexContribution(e,t){hb(this.finalizedContributions,e,t,t.nodes.length>0),hb(this.runningContributions,e,t,t.running!==null),hb(this.partialContributions,e,t,t.partial!==null)}rebuildFinalized(){let e=[...this.finalizedContributions.values()].flatMap(e=>e.nodes).sort((e,t)=>e.seq-t.seq);Hy(this.finalized,e)||(this.finalized=e)}rebuildRunning(){let e=[...this.runningContributions.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).flatMap(e=>e.running===null?[]:[e.running]);Hy(this.runningCalls,e)||(this.runningCalls=e)}rebuildPartial(){let e=[...this.partialContributions.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).findLast(e=>e.partial!==null)?.partial??null;(this.partial?.blocks!==e?.blocks||this.partial?.turn!==e?.turn||this.partial?.step!==e?.step)&&(this.partial=e)}updateTimeline(e){if(this.timeline===e)return;this.timeline=e;let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let r of e.turns.values())r.start!==void 0&&t.set(r.turn,{startTime:r.start.time,...r.end===void 0?{}:{endTime:r.end.time}}),r.end!==void 0&&n.set(r.turn,r.end.seq);this.turnTimings=t,this.turnEnds=n}snapshot(){return{nodes:this.finalized,turnTimings:this.turnTimings,turnEnds:this.turnEnds,partial:this.partial,runningCalls:this.runningCalls}}};function hb(e,t,n,r){r?e.set(t,n):e.delete(t)}function gb(e,t){let n=e?.nodes??Vy;return!Hy(n,t.nodes)||(n.length>0||t.nodes.length>0)&&e?.anchorSeq!==t.anchorSeq}function _b(e,t){return e?.running!==t.running||(e.running!==null||t.running!==null)&&e.anchorSeq!==t.anchorSeq}function vb(e,t){return e?.partial?.blocks!==t.partial?.blocks||e?.partial?.turn!==t.partial?.turn||e?.partial?.step!==t.partial?.step||((e?.partial??null)!==null||t.partial!==null)&&e?.anchorSeq!==t.anchorSeq}var yb=class{store=new Ky;locations=new qy;navigation=new Yy;legacy=new mb;referenceLabels=new ob;skillNames=new ub;order=Ry;latestGroupInput;readGroupNode=e=>this.store.get(e);readGroupTurn=e=>this.locations.getTurn(e);readGroupPosition=e=>this.locations.getPosition(e);timeline=null;empty;constructor(){this.empty=this.snapshot({turnOrder:zy,turns:/* @__PURE__ */ new Map}),this.latestGroupInput={kind:`replace`,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:this.empty.timeline}}replace(e){let t=this.skillNames.replace(this.referenceLabels.replace(e.nodes));return this.store.replace(t),this.order=nb(t).map(e=>e.key),this.locations.rebuild(this.order,this.store),this.store.replaceProcesses(this.order,this.locations),this.navigation.rebuild(e.timeline,this.locations,this.store),this.timeline=e.timeline,this.latestGroupInput={kind:`replace`,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:e.timeline},this.snapshot(e.timeline,this.legacy.replace(t,e.timeline))}apply(e){let t=this.skillNames.apply(this.referenceLabels.apply(e.upserts,this.store),this.store),n=/* @__PURE__ */ new Set,r=!1,i=[],a=[];for(let e of t){let t=this.store.get(e.key);t!==e&&a.push({previous:t,current:e});let o=t===void 0||t.kind!==e.kind||t.anchorSeq!==e.anchorSeq||t.visibility!==e.visibility||xb(t.location)!==xb(e.location);if(r||=o,o||i.push(e),$y(t,e,o)){let r=t===void 0?void 0:Zy(t.location).turn,i=Zy(e.location).turn;r!==void 0&&n.add(r),i!==void 0&&n.add(i)}}this.store.upsert(t);let o=zy;if(r){let e=nb(this.store.values()).map(e=>e.key);this.order=Hy(this.order,e)?this.order:e,o=this.locations.rebuild(this.order,this.store)}return this.locations.touch(i),this.store.updateProcesses(n,this.locations),r||e.timeline!==this.timeline?this.navigation.rebuild(e.timeline,this.locations,this.store):this.navigation.touch(bb(i),this.locations,this.store),this.timeline=e.timeline,this.latestGroupInput={kind:`apply`,changes:a,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:e.timeline,changedTurns:e.changedTurns??zy,changedTurnOrders:o},this.snapshot(e.timeline,this.legacy.apply(t,e.timeline))}groupInput(){return this.latestGroupInput}publish(){this.store.publish()}snapshot(e,t=this.legacy.replace(Vy,e)){return{order:this.order,nodes:this.store,locations:this.locations,navigation:this.navigation,timeline:e,legacy:t}}};function bb(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=Zy(n.location).turn;e!==void 0&&t.add(e)}return t}function xb(e){let t=Zy(e);return`${e.kind}:${t.turn??``}:${t.step??``}`}let Sb={target:`chat`,create:()=>new yb,isActive:e=>e.order.some(t=>e.nodes.get(t)?.kind!==`command`)};function Cb(e){e.uiConversation.views.register(Sb)}let wb=/* @__PURE__ */ new Set([`system/message`,`developer/message`,`user/message`,`assistant/message`,`tool/result`]);function Tb(e){return wb.has(e.type)?e.surfaceOp!==void 0:!1}function Eb(e){return Tb(e)&&e.surfaceOp===`append`}function Db(e){return Tb(e)&&e.surfaceOp!==`append`}function Ob(e){if(e.event.type!==`command/run`)throw Error(`command start requires command/run`);let t=e.event.data;return{kind:`command`,seq:e.event.seq,time:e.event.time,commandId:t.commandId,name:t.name,args:t.args??null,outcome:null}}function kb(e,t){if(e.event.type!==`command/done`)throw Error(`command update requires command/done`);let n=e.event.data,r=n.kind===`success`&&n.sourceEventSeq!==void 0&&Number.isSafeInteger(n.sourceEventSeq)&&n.sourceEventSeq>=0?n.sourceEventSeq:void 0;return{kind:`command`,seq:t?.seq??e.event.seq,time:t?.time??e.event.time,commandId:n.commandId,name:t?.name??null,args:t?.args??null,outcome:{kind:n.kind,...n.text===void 0?{}:{text:n.text},...r===void 0?{}:{sourceEventSeq:r}}}}function Ab(e){if(e.type!==`user/message`||!Db(e))return;let t=e.data.source;if(t.kind===`compact-checkpoint`&&typeof t.compactionId==`string`)return{compactionId:t.compactionId,...t.sourceCommandId===void 0?{}:{sourceCommandId:t.sourceCommandId}}}function jb(e,t){let n=null,r=null,i=null;if(e?.event.type===`compaction/summary`){let t=e.event.data;if(Array.isArray(t.summary)){let e=t.summary.map(e=>e.type===`text`?e.text:``).join(``);n=e.trim()===``?null:e}r=Array.isArray(t.shadowedSeqs)&&t.shadowedSeqs.every(e=>Number.isSafeInteger(e)&&e>=0)?t.shadowedSeqs.length:null,i=Number.isSafeInteger(t.shadowedTokenCount)&&t.shadowedTokenCount>=0?t.shadowedTokenCount:null}return{kind:`compaction`,seq:t.event.seq,time:t.event.time,summary:n,summaryEventSeq:e?.event.seq??null,shadowedItemCount:r,shadowedTokenCount:i}}function Mb(e){let t=e.matches.find(e=>e.event.type===`command/done`),n=e.matches.find(e=>Ab(e.event)!==void 0),r=e.matches.find(e=>e.event.type===`compaction/summary`);if(n===void 0)return t===void 0?void 0:{command:kb(t)};let i=Ab(n.event);return i?.sourceCommandId===void 0?t===void 0?void 0:{command:kb(t)}:{command:t===void 0?{kind:`command`,seq:n.event.seq,time:n.event.time,commandId:i.sourceCommandId,name:`compact`,args:null,outcome:null}:{...kb(t),name:`compact`},checkpoint:n,...r===void 0?{}:{summary:r}}}function Nb(e,t){return t.event.type===`compaction/summary`?{...e,summary:t}:Ab(t.event)===void 0?e:{...e,checkpoint:t}}let Pb={kind:`command`,target:`chat`,match:e=>{if(e.type===`command/run`)return{id:String(e.data.commandId),role:`start`};if(e.type===`command/done`)return{id:String(e.data.commandId),role:`update`};let t=Ab(e);return t?.sourceCommandId===void 0?(e.type===`compaction/start`||e.type===`compaction/summary`||e.type===`compaction/end`)&&e.data.sourceCommandId!==void 0?{id:String(e.data.sourceCommandId),role:`update`}:null:{id:String(t.sourceCommandId),role:`update`}},start:(e,t)=>({command:Ob(t)}),update:(e,t)=>t.event.type===`command/done`?{...e.state,command:kb(t,e.state.command)}:Nb(e.state,t),buildViewNode:e=>{let t=e.state??Mb(e);if(t===void 0)return null;if(t.command.name!==`compact`)return Xv(e,`command`,t.command.seq,t.command);let n=t.checkpoint===void 0?null:jb(t.summary,t.checkpoint),r={command:t.command,compaction:n};return Xv(e,`manual-compaction`,n?.seq??t.command.seq,r)}};function Fb(e){e.uiConversation.events.register(Pb)}function Ib(e){let t=e.matches.find(e=>e.event.type===`compaction/summary`),n=e.matches.find(e=>Ab(e.event)!==void 0);return{...t===void 0?{}:{summary:t},...n===void 0?{}:{checkpoint:n}}}let Lb={kind:`compaction`,target:`chat`,match:e=>{let t=Ab(e);if(t!==void 0&&t.sourceCommandId===void 0)return{id:t.compactionId,role:`update`};if(e.type===`compaction/start`||e.type===`compaction/summary`||e.type===`compaction/end`){if(e.data.sourceCommandId!==void 0)return null;let t=e.data.compactionId;return typeof t!=`string`||t===``?null:{id:t,role:e.type===`compaction/start`?`start`:`update`}}return null},start:()=>({}),update:(e,t)=>Nb(e.state,t),buildViewNode:e=>{let t=e.state??Ib(e);if(t.checkpoint===void 0)return null;let n=jb(t.summary,t.checkpoint);return Xv(e,`compaction`,n.seq,n)}};function Rb(e){e.uiConversation.events.register(Lb)}let zb={kind:`unknown-surface`,target:`chat`,match:e=>e.type!==`assistant/live-chunk`&&Eb(e)?{id:String(e.seq),role:`start`}:null,start:(e,t)=>({kind:`unknown`,seq:t.event.seq,time:t.event.time,type:t.event.type,data:t.event.data}),update:e=>e.state,buildViewNode:e=>e.state===void 0?null:Xv(e,`unknown`,e.state.seq,e.state)};function Bb(e){e.uiConversation.events.registerFallback(zb)}let Vb={kind:`snapshot`,ids:[]},Hb=/* @__PURE__ */ new Set;function Ub(e){let t=[],n=e;for(;n.kind===`splice`;)t.push(n),n=n.previous;let r=[...n.ids];for(let e of t.reverse())r.splice(e.start,e.removedCount,...e.inserted);return r}function Wb(e,t){let n;for(let{id:r}of t)e.has(r)&&(n??=new Set(e),n.delete(r));return n??e}function Gb(e,t,n){let r=e?.state.pending??Vb,i=t.inserted,a=t.removedCount??0;if(a>0&&t.outcome!==`canceled`){let e=Ub(r),o=e.splice(t.start,a,...i);return{pending:{kind:`snapshot`,ids:e},currentClaimed:new Set(o.map(e=>e.id)),claimSeq:n,claimedHuman:o.some(e=>e.source.kind===`user`)}}let o=Wb(e?.state.currentClaimed??Hb,i);return{pending:{kind:`splice`,previous:r,start:t.start,removedCount:a,inserted:i},currentClaimed:o,claimSeq:e?.state.claimSeq??-1,claimedHuman:e?.state.claimedHuman??!1}}function Kb(e){let t=`inbox-${e}`;return{kind:t,match:t=>t.type===`agent/inbox/spliced`&&t.data.target===e?{id:String(t.seq),role:`start`}:null,start:(e,n,r)=>{if(n.event.type!==`agent/inbox/spliced`)throw Error(`inbox start requires agent/inbox/spliced`);return Gb(r.previous(t),n.event.data,n.event.seq)},update:e=>e.state,publication:()=>`none`}}let qb=Kb(`next-step`),Jb=Kb(`next-turn`);function Yb(e){e.uiConversation.events.register(qb),e.uiConversation.events.register(Jb)}function Xb(e){return e.type!==`user/message`||!Db(e)?!1:e.data.source.kind===`compact-checkpoint`}function Zb(e,t){return{kind:`context`,seq:e.seq,time:e.time,content:t.content,source:t.source,producer:ry(t.source),form:ny(t.source)}}let Qb={kind:`input-message`,target:`chat`,match:e=>e.type===`user/message`&&Eb(e)&&!Xb(e)?{id:String(e.data.id),role:`start`}:null,start:(e,t,n)=>{let r=t.event;if(r.type!==`user/message`)throw Error(`input-message start requires user/message`);if(r.data.source.kind!==`user`){let e=n.previous(`inbox-next-turn`)?.state,i=n.previous(`inbox-next-step`)?.state,a=t.location,o=a.kind===`step`?a.turn.start?.seq:void 0,s=a.kind===`step`&&a.step.step===1&&o!==void 0&&(i?.claimSeq??-1)>o&&(e?.claimSeq??-1)<o&&i?.claimedHuman===!1&&i.currentClaimed.has(String(r.data.id));return{...Zb(r,r.data),waking:e?.currentClaimed.has(String(r.data.id))===!0||s}}return n.previous(`inbox-next-step`)?.state.currentClaimed.has(String(r.data.id))===!0?{kind:`steering`,messageId:r.data.id,seq:r.seq,time:r.time,content:r.data.content,source:r.data.source}:{kind:`user`,seq:r.seq,time:r.time,content:r.data.content,source:r.data.source}},update:e=>e.state,buildViewNode:e=>{if(e.state===void 0)return null;let t=e.state.kind===`context`&&e.start?.event.type===`user/message`&&e.state.waking===!0,n=e.state.kind===`user`||e.state.kind===`steering`?{...e.state,...$b(e.state)}:e.state;return Xv(e,t?`turn-trigger`:e.state.kind,e.state.seq,n)}};function $b(e){let t=Ip(e.content.flatMap(e=>e.type===`text`?[e.text]:[]).join(`
|
|
131
|
-
`));return t.length===0?{}:{responseAnnotations:t}}let ex={...Qb,kind:`developer-message`,match:e=>e.type===`developer/message`?{id:String(e.data.message.id),role:`start`}:null,start:(e,t)=>{let n=t.event;if(n.type!==`developer/message`)throw Error(`developer-message start requires developer/message`);return Zb(n,n.data.message)}};function tx(e){e.uiConversation.events.register(Qb),e.uiConversation.events.register(ex)}function nx(e,t,n){return e.location.kind!==`step`||t===void 0&&!n||t?.turn===e.location.turn.turn&&t.step===e.location.step.step?e.event.seq:e.location.step.step===1?e.location.turn.start?.seq??e.location.step.start?.seq??e.event.seq:e.location.step.start?.seq??e.event.seq}function rx(e,t,n,r){let i=e.current.get(`chat`);return i?.kind===`system-prompt`?i.anchorSeq:nx(t,n,r)}function ix(e){return{kind:`system-message`,target:`chat`,match:e=>e.type===`system/message`||`surfaceOp`in e&&e.surfaceOp!==`append`?{id:String(e.seq),role:`start`}:null,start:(t,n,r)=>{if(n.event.type===`assistant/live-chunk`)throw Error(`system-message requires a durable event`);return e(r.previous(`system-message`)?.state,n.event)},update:e=>e.state,buildViewNode:e=>{let t=e.state?.introduced;return t===void 0||t.text===``||e.start?.event.type!==`system/message`||e.start.event.surfaceOp!==`append`?null:Xv(e,`system-prompt`,t.update?t.seq:nx(e.start,void 0,!0),{text:t.text,...t.update?{update:!0}:{}})}}}function ax(e){return{kind:`request-prompt`,target:`chat`,match:e=>e.type===`request/header`?{id:String(e.seq),role:`start`}:null,start:(t,n,r)=>{if(n.event.type!==`request/header`)throw Error(`request-prompt start requires request/header`);let i=r.previous(`request-prompt`)?.state,a=r.previous(`system-message`),o=a?.state.effective,s=n.location.kind===`step`?{turn:n.location.turn.turn,step:n.location.step.step}:{},c=e(i?.prompt,n.event,o),l=c.change?.kind,u=a?.matches[0]?.event,d=o!==void 0&&u?.type===`system/message`&&u.surfaceOp===`append`&&(o.update||i===void 0)&&o.turn===s.turn&&o.step===s.step;return{anchorSeq:rx(t,n,i,n.event.data.reason===`initial`),showsPrompt:!d&&(i===void 0||n.event.data.reason!==`change`||n.event.data.startsSeries===!0||l===`system`||l===`system-and-tools`),...s,...c}},update:e=>e.state,buildViewNode:e=>{let t=e.state;if(t===void 0)return null;let n=e.current.get(`chat`),r=t.showsPrompt&&t.prompt.system!==``;return!r&&n?.kind!==`system-prompt`?null:Xv(e,`system-prompt`,t.anchorSeq,{text:t.prompt.system},{visibility:r?`visible`:`hidden`})}}}function ox(e){e.uiConversation.events.register(ix((t,n)=>e.uiConversation.inspectSystemPrompt(t,n))),e.uiConversation.events.register(ax((t,n,r)=>e.uiConversation.inspectRequestPrompt(t,n,r)))}function sx(e){if(e.event.type===`llm/retry`)return{kind:`model-retry`,seq:e.event.seq,time:e.event.time,retryState:`scheduled`,...e.event.data}}function cx(e){return e.kind===`step`&&e.step.status===`closed`||(e.kind===`step`||e.kind===`turn`)&&e.turn.status===`closed`}let lx={kind:`model-retry`,target:`chat`,match:e=>{if(e.type===`llm/retry`){let t=e.data.retryId;return typeof t!=`string`||t===``?null:{id:t,role:e.data.retry===1?`start`:`update`}}if(e.type===`llm/retry-started`){let t=e.data.retryId;return typeof t==`string`&&t!==``?{id:t,role:`update`}:null}return null},start:(e,t)=>{let n=sx(t);if(n===void 0)throw Error(`model-retry start requires a valid llm/retry event`);return{turn:n.turn,step:n.step,attempts:[n]}},update:(e,t)=>{if(t.event.type===`llm/retry`){let n=sx(t);return n===void 0?e.state:{...e.state,attempts:[...e.state.attempts,n]}}if(t.event.type!==`llm/retry-started`)return e.state;let n=t.event.data.retry;return{...e.state,attempts:e.state.attempts.map(e=>e.retry===n?{...e,retryState:`started`}:e)}},buildViewNode:e=>{if(e.state===void 0||e.state.attempts.length===0)return null;let t=e.start?.location??e.matches[0]?.location??{kind:`unresolved`},n=e.state.attempts,r=n.map((e,r)=>r===n.length-1&&e.retryState===`scheduled`&&cx(t)?{...e,retryState:`cancelled`}:e),i=r.at(-1);if(i===void 0)return null;let a={attempts:r,current:i};return Xv(e,`model-retry`,r[0]?.seq??i.seq,a)}};function ux(e){e.uiConversation.events.register(lx)}let dx=/* @__PURE__ */ new WeakMap;function fx(e){return JSON.stringify(e)}function px(e,t){if(e.event.type!==`tool/call`)throw Error(`tool-call start requires tool/call`);return{phase:`start`,callId:String(e.event.data.callId),name:e.event.data.name,argsRaw:e.event.data.arguments,args:t===void 0?Vh.fromText(e.event.data.arguments):t.args.settle(e.event.data.arguments),turn:e.event.data.turn,step:e.event.data.step,time:e.event.time,subCalls:[]}}function mx(e,t){let n=t.event;if(n.type!==`assistant/live-chunk`)return e;let r=n.data.chunk,i=e.root;if(r.type===`block-end`&&r.block.type===`tool-call`)return i===void 0||`kind`in i||i.phase!==`preparing`?e:{...e,root:{...i,name:r.block.name,args:i.args.settle(r.block.arguments)}};if(r.type!==`tool-call-delta`)return e;if(i===void 0){if(!r.name)return e;let t=new Vh;return t.append(r.argumentsDelta),{...e,root:{phase:`preparing`,callId:String(r.id),name:r.name,turn:n.data.turn,step:n.data.step,time:n.time,subCalls:[],args:t}}}return`kind`in i||i.phase!==`preparing`||i.args.isSealed||i.args.append(r.argumentsDelta),e}function hx(e,t){let n=e.args.refresh();return!n&&t!==void 0&&!(`kind`in t)&&t.phase===`preparing`&&t.name===e.name&&t.args===e.args?t:n?{...e}:e}function gx(e,t){if(e.event.type!==`tool/result`)return;let n=e.event.data.message;return{kind:`tool-result`,seq:e.event.seq,time:e.event.time,callId:String(n.source.callId),name:t?.name??``,args:t?.args??Vh.EMPTY,call:t===void 0?null:{name:t.name,argsRaw:t.argsRaw},callTime:t?.time??null,content:n.content,isError:n.isError===!0,...e.event.data.error===void 0?{}:{error:e.event.data.error},meta:e.event.data.meta,subCalls:[]}}function _x(e,t){return{phase:`start`,callId:t.subCallId,parentCallId:t.parentCallId,name:t.name,argsRaw:fx(t.arguments),args:Vh.fromObject(t.arguments),turn:yx(e),step:bx(e),time:e.event.time,subCalls:[]}}function vx(e,t,n){return{kind:`tool-result`,seq:e.event.seq,time:e.event.time,callId:t.subCallId,parentCallId:t.parentCallId,name:t.name,args:n!==void 0&&!(`kind`in n)?n.args:Vh.fromObject(t.arguments),call:{name:t.name,argsRaw:fx(t.arguments)},callTime:n?.time??null,content:t.content??[],isError:t.isError===!0,...t.error===void 0?{}:{error:t.error},subCalls:[]}}function yx(e){return e.location.kind===`step`||e.location.kind===`turn`?e.location.turn.turn:0}function bx(e){return e.location.kind===`step`?e.location.step.step:0}function xx(e,t,n){if(t===n||e.parents.has(n))return!1;let r=t,i=0,a=/* @__PURE__ */ new Set;for(;r!==void 0;){if(r===n||a.has(r))return!1;a.add(r),i++,r=e.parents.get(r)}let o=[{callId:n,depth:1}],s=/* @__PURE__ */ new Set,c=0;for(let t of o){if(s.has(t.callId))return!1;s.add(t.callId),c=Math.max(c,t.depth);for(let n of e.children.get(t.callId)??[])o.push({callId:n.callId,depth:t.depth+1})}return i+c<=256}function Sx(e,t){let n=t.event;if(n.type!==`tool/ptc-dispatch-start`&&n.type!==`tool/ptc-dispatch`)return e;let r=n.data,i=String(r.parentCallId),a=String(r.subCallId),o=e.children.get(i)??[],s=o.findIndex(e=>e.callId===a);if(n.type===`tool/ptc-dispatch-start`){if(s>=0||!xx(e,i,a))return e;let n=new Map(e.children);n.set(i,[...o,_x(t,r)]);let c=new Map(e.parents);return c.set(a,i),{...e,children:n,parents:c}}if(s<0&&!xx(e,i,a))return e;let c=vx(t,r,s<0?void 0:o[s]),l=new Map(e.children);l.set(i,s<0?[...o,c]:o.map((e,t)=>t===s?c:e));let u=new Map(e.parents);return s<0&&u.set(a,i),{...e,children:l,parents:u}}function Cx(e,t,n,r=/* @__PURE__ */ new Set,i=1){if(!(`kind`in e)&&e.phase===`preparing`)return e;if(r.has(e.callId)||i>256)return{...e,subCalls:[]};let a=new Set(r);a.add(e.callId);let o=(t.children.get(e.callId)??e.subCalls).map(e=>Cx(e,t,n,a,i+1)),s=`kind`in e?void 0:n?.seq,c=`kind`in e?void 0:n?.time,l=dx.get(e);if(l!==void 0&&l.interruptionSeq===s&&l.interruptionTime===c&&wx(l.children,o))return l.value;let u=`kind`in e||n===void 0?wx(e.subCalls,o)?e:{...e,subCalls:o}:{kind:`tool-result`,seq:n.seq+Jv.interruptedFollowup,time:n.time,callId:e.callId,...e.parentCallId===void 0?{}:{parentCallId:e.parentCallId},name:e.name,args:e.args,call:{name:e.name,argsRaw:e.argsRaw},callTime:e.time,content:[],isError:!0,error:{name:`Interrupted`,code:`interrupted`},subCalls:o};return dx.set(e,{children:o,interruptionSeq:s,interruptionTime:c,value:u}),u}function wx(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Tx(e){let t=e.start?.location;if(t?.kind===`step`&&t.step.status===`closed`)return t.step.end;if((t?.kind===`step`||t?.kind===`turn`)&&t.turn.status===`closed`)return t.turn.end}function Ex(e){let t=e.matches.find(e=>e.event.type===`tool/result`),n=t===void 0?void 0:gx(t);if(n===void 0)return;let r={root:n,children:/* @__PURE__ */ new Map,parents:/* @__PURE__ */ new Map};for(let t of e.matches)r=Sx(r,t);return r}let Dx={kind:`tool-call`,target:`chat`,match:e=>{if(e.type===`assistant/live-chunk`){let t=e.data.chunk;return t.type===`block-end`&&t.block.type===`tool-call`?{id:String(t.block.id),role:`start`}:t.type===`tool-call-delta`?{id:String(t.id),role:`start`}:null}if(e.type===`tool/call`)return{id:String(e.data.callId),role:`start`};if(e.type===`tool/result`&&Eb(e))return{id:String(e.data.message.source.callId),role:`update`};if(e.type===`tool/ptc-dispatch-start`||e.type===`tool/ptc-dispatch`){let t=e.data.rootCallId;return typeof t==`string`&&t!==``?{id:t,role:`update`}:null}return null},start:(e,t)=>{let n={root:void 0,children:/* @__PURE__ */ new Map,parents:/* @__PURE__ */ new Map};return t.event.type===`tool/call`?{...n,root:px(t)}:mx(n,t)},update:(e,t)=>{if(t.event.type===`assistant/live-chunk`)return mx(e.state,t);if(t.event.type===`tool/call`)return{...e.state,root:px(t,e.state.root)};if(t.event.type===`tool/result`){let n=e.state.root,r=gx(t,n!==void 0&&!(`kind`in n)&&n.phase===`start`?n:void 0);return r===void 0?e.state:{...e.state,root:r}}return Sx(e.state,t)},publication:e=>e.event.type===`assistant/live-chunk`?`animation-frame`:`immediate`,buildViewNode:e=>{let t=e.current.get(`chat`),n=e.state??Ex(e);if(n?.root===void 0)return t==null?null:t.visibility===`hidden`?t:{...t,visibility:`hidden`};let r=Tx(e),i=Cx(!(`kind`in n.root)&&n.root.phase===`preparing`?hx(n.root,t?.data.root):n.root,n,r),a=e.start?.event.seq??(`kind`in n.root?n.root.seq:e.matches[0]?.event.seq??0),o=!(`kind`in i)&&i.phase===`preparing`&&r!==void 0?`hidden`:`visible`,s=Yv(e),c=vh(i.name)&&s.kind===`step`?{kind:`turn`,turn:s.turn}:s,l=t?.data.root===i?t.data:{root:i};return t?.data===l&&t.anchorSeq===a&&t.visibility===o&&t.location===c?t:Xv(e,`tool-call`,a,l,{visibility:o,location:c})}};function Ox(e){let t=Dx.match.bind(Dx);e.uiConversation.events.register({...Dx,match:{"assistant/live-chunk":t,"tool/call":t,"tool/result":t,"tool/ptc-dispatch-start":t,"tool/ptc-dispatch":t}})}function kx(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind!==`turn`&&t?.kind!==`step`?0:t.turn.steps.at(-1)?.step??0}function Ax(e){if(e.event.type!==`turn/end`)return;let t=e.event.data.reason,n=t.kind===`error`?t.error:t.kind===`aborted`&&t.reason.kind===`hook`&&t.reason.reason===`deepseek-account/signed-out`?{message:`Stopped because you signed out of DeepSeek.`,code:`ACCOUNT_SIGNED_OUT`}:void 0;if(n===void 0)return;let r=ly(n);return{seq:e.event.seq,time:e.event.time,message:r.message,...r.code===void 0?{}:{code:r.code}}}function jx(e){let t=e.matches.find(e=>Ax(e)!==void 0);if(t?.event.type!==`turn/end`)return;let n=Ax(t);if(n!==void 0)return{turn:t.event.data.turn,failure:n}}let Mx={kind:`turn-error`,target:`chat`,match:e=>e.type===`turn/start`?{id:String(e.data.turn),role:`start`}:e.type===`turn/end`&&(e.data.reason.kind===`error`||e.data.reason.kind===`aborted`&&e.data.reason.reason.kind===`hook`&&e.data.reason.reason.reason===`deepseek-account/signed-out`)?{id:String(e.data.turn),role:`update`}:null,start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-error start requires turn/start`);return{turn:t.event.data.turn}},update:(e,t)=>{let n=Ax(t);return n===void 0?e.state:{...e.state,failure:n}},buildViewNode:e=>{let t=e.state??jx(e);if(t?.failure===void 0)return null;let n=t.failure,r={kind:`turn-error`,seq:n.seq,time:n.time,turn:t.turn,step:kx(e),message:n.message,...n.code===void 0?{}:{code:n.code}};return Xv(e,`turn-error`,r.seq,r)}};function Nx(e){e.uiConversation.events.register(Mx)}function Px(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind!==`turn`&&t?.kind!==`step`?0:t.turn.steps.at(-1)?.step??0}function Fx(e,t){let n=e.start?.location??e.matches[0]?.location;if(n?.kind!==`turn`&&n?.kind!==`step`)return t;let r=n.turn.data.get(`turn-tail`)?.closing;return r==null?t:r.finalNode.seq+Jv.maxTokensNotice}function Ix(e){if(e.event.type===`turn/end`&&e.event.data.reason.kind===`max-tokens`)return{turn:e.event.data.turn,seq:e.event.seq,time:e.event.time}}let Lx={kind:`turn-max-tokens`,target:`chat`,match:e=>e.type===`turn/end`&&e.data.reason.kind===`max-tokens`?{id:String(e.data.turn),role:`start`}:null,start:(e,t)=>{let n=Ix(t);if(n===void 0)throw Error(`turn-max-tokens start requires a max-tokens turn/end`);return n},update:e=>e.state,buildViewNode:e=>{let t=e.state;if(t===void 0)return null;let n={kind:`turn-max-tokens`,seq:t.seq,time:t.time,turn:t.turn,step:Px(e)};return Xv(e,`turn-max-tokens`,Fx(e,t.seq),n)}};function Rx(e){e.uiConversation.events.register(Lx)}function zx(e){let t=e.data;return typeof t.turn==`number`?t.turn:void 0}function Bx(e){if(e.type===`text-delta`||e.type===`reasoning-delta`)return e.text.trim()!==``;if(e.type===`block-start`)return e.blockType!==`text`&&e.blockType!==`reasoning`&&e.blockType!==`tool-call`;if(e.type!==`block-end`)return!1;let t=e.block;return t.type===`tool-call`?!1:t.type===`text`||t.type===`reasoning`?t.text.trim()!==``:!0}function Vx(e){return e.type===`assistant/live-chunk`?Bx(e.data.chunk):e.type!==`assistant/attempt`&&e.type===`assistant/message`&&e.surfaceOp===`append`&&oy(e.data.message.content).some(e=>e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function Hx(e,t){return e.type===`tool/call`?vh(e.data.name):e.type===`tool/result`&&t.has(String(e.data.message.source.callId))}function Ux(e,t){if(Vx(e))return e.type!==`assistant/live-chunk`&&e.type!==`assistant/message`&&e.type!==`assistant/attempt`?void 0:{kind:`assistant`,seq:e.seq,step:e.data.step};if(!Hx(e,t)&&(e.type===`tool/call`||e.type===`tool/result`&&e.surfaceOp===`append`||e.type===`llm/retry`))return{kind:`other`,seq:e.seq}}function Wx(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function Gx(e){let t=e.matches.map(e=>zx(e.event)).find(e=>e!==void 0);if(t===void 0)return;let n={turn:t,assistantStartByStep:/* @__PURE__ */ new Map,messageCountByStep:/* @__PURE__ */ new Map,messageCount:0,toolCallCount:0,subagentCount:0,contextCompactionCalls:/* @__PURE__ */ new Set};for(let t of e.matches)n=Yx(n,t.event);return n}function Kx(e){return e?.finalNode!==void 0}function qx(e){let t=e.end?.data.finalAssistantStep;if(t===null)return null;let n=(t===void 0?e.steps.at(-1):e.steps.find(e=>e.step===t))?.data.get(`assistant-step`);return!Kx(n)||n.finalNode.interrupted===!0||!Fv(n.blocks)||t===void 0&&n.blocks.some(e=>e.kind===`tool-call`)?null:n}function Jx(e,t){let n=e.controlAnchorSeq??t.start?.seq;if(n===void 0)return null;let r=qx(t),i={messageCount:r===null?e.messageCount:[...e.messageCountByStep].filter(([e])=>e!==r.step).reduce((e,[,t])=>e+t,0),toolCallCount:e.toolCallCount,subagentCount:e.subagentCount};if(r===null)return{turn:t.turn,controlAnchorSeq:n,processStartSeq:n,answerAnchorSeq:null,answerStep:null,inlineReasoning:!1,...i};let a=r.blocks.some(e=>e.kind===`reasoning`&&e.text.trim()!==``),o=Math.min(...[...e.assistantStartByStep].filter(([e])=>e<r.step).map(([,e])=>e)),s=Math.min(e.otherStartSeq??1/0,o);return{turn:t.turn,controlAnchorSeq:n,processStartSeq:t.start?.seq??(Number.isFinite(s)?s:r.finalNode.seq),answerAnchorSeq:r.finalNode.seq,answerStep:r.step,inlineReasoning:a,...i}}function Yx(e,t){let n=e;if(t.type===`assistant/message`&&t.surfaceOp===`append`&&Fv(oy(t.data.message.content))){let e=new Map(n.messageCountByStep);e.set(t.data.step,(e.get(t.data.step)??0)+1),n={...n,messageCountByStep:e,messageCount:n.messageCount+1}}if(t.type===`tool/call`){if(vh(t.data.name)){let e=new Set(n.contextCompactionCalls);e.add(String(t.data.callId)),n={...n,contextCompactionCalls:e}}else{let e=_h(t.data.name);n={...n,toolCallCount:n.toolCallCount+ +!e,subagentCount:n.subagentCount+ +!!e}}}let r=Ux(t,n.contextCompactionCalls);if(r===void 0)return n;if(r.kind===`other`)return n.otherStartSeq===void 0?{...n,otherStartSeq:r.seq,controlAnchorSeq:Math.min(n.controlAnchorSeq??1/0,r.seq)}:n;if(n.assistantStartByStep.has(r.step))return n;let i=new Map(n.assistantStartByStep);return i.set(r.step,r.seq),{...n,assistantStartByStep:i,controlAnchorSeq:Math.min(n.controlAnchorSeq??1/0,r.seq)}}let Xx={kind:`turn-process`,target:`chat`,match:e=>{if(e.type===`turn/start`)return{id:String(e.data.turn),role:`start`};let t=zx(e);return t===void 0?null:e.type===`assistant/live-chunk`||e.type===`assistant/message`||e.type===`tool/call`||e.type===`tool/result`||e.type===`llm/retry`||e.type===`step/start`||e.type===`step/end`||e.type===`turn/end`?{id:String(t),role:`update`}:null},start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-process start requires turn/start`);return{turn:t.event.data.turn,assistantStartByStep:/* @__PURE__ */ new Map,messageCountByStep:/* @__PURE__ */ new Map,messageCount:0,toolCallCount:0,subagentCount:0,contextCompactionCalls:/* @__PURE__ */ new Set}},update:(e,t)=>Yx(e.state,t.event),publication:e=>{if(e.event.type===`assistant/live-chunk`){let t=e.event.data.chunk.type;return t===`usage`||t===`finish`?`none`:`animation-frame`}return`immediate`},buildLocationData:(e,t,n)=>{if(t!==`turn`)return null;let r=e.state??Gx(e);if(r===void 0)return null;let i=Wx(e);if(i===void 0)return null;let a=e.current.get(`chat`),o=i.steps.at(-1);if(n?.kind===`turn`&&n.key===`turn-process`&&a?.kind===`turn-process`&&a.data.answerAnchorSeq===null&&a.data.controlAnchorSeq===r.controlAnchorSeq&&a.data.messageCount===r.messageCount&&a.data.toolCallCount===r.toolCallCount&&a.data.subagentCount===r.subagentCount&&i.status!==`closed`&&o?.status!==`closed`)return n;let s=Jx(r,i);return s===null?null:n?.kind===`turn`&&n.turn===s.turn&&n.key===`turn-process`&&gh(n.value,s)?n:{kind:`turn`,turn:i.turn,key:`turn-process`,value:s}},buildViewNode:e=>{let t=Wx(e),n=t?.data.get(`turn-process`);if(t===void 0||n===void 0)return null;let r=e.current.get(`chat`),i=e.state;return r?.kind===`turn-process`&&i!==void 0&&r.data.answerAnchorSeq===null&&r.data.controlAnchorSeq===i.controlAnchorSeq&&r.data.messageCount===i.messageCount&&r.data.toolCallCount===i.toolCallCount&&r.data.subagentCount===i.subagentCount&&t.status!==`closed`&&t.steps.at(-1)?.status!==`closed`&&r.location===(e.start?.location??e.matches[0]?.location)?r:Xv(e,`turn-process`,n.controlAnchorSeq+Jv.processControl,n)}};function Zx(e){let t=Xx.match.bind(Xx);e.uiConversation.events.register({...Xx,match:{"turn/start":t,"assistant/live-chunk":t,"assistant/message":t,"tool/call":t,"tool/result":t,"llm/retry":t,"step/start":t,"step/end":t,"turn/end":t}})}function Qx(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(r.type===`chunk`&&r.chunk.type===t)return r.chunk}}function $x(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function eS(e){let t=0;for(let n of e)if(t+=n,!Number.isSafeInteger(t))return;return t}function tS(e){let{provider:t,model:n}=e.source;return t.length>0&&n.length>0?{provider:t,model:n}:void 0}function nS(e){return Qx(e,`usage`)?.usage}function rS(e,t){let{inputTokens:n,outputTokens:r,cacheReadTokens:i,cacheWriteTokens:a,reasoningTokens:o,totalTokens:s}=e;if(!$x(n)||!$x(r)||i!==void 0&&!$x(i)||a!==void 0&&!$x(a)||o!==void 0&&(!$x(o)||o>r))return;let c=eS([n,...i===void 0?[]:[i],...a===void 0?[]:[a]]);if(c===void 0)return;let l;if(s!==void 0){if(!$x(s))return;let e=s-r;if(!$x(e)||e<c||i!==void 0&&a!==void 0&&e!==c)return;l=s}else{if(i===void 0||a===void 0)return;let e=eS([c,r]);if(e===void 0)return;l=e}return{inputTokens:n,outputTokens:r,totalTokens:l,...i===void 0?{}:{cacheReadTokens:i},...a===void 0?{}:{cacheWriteTokens:a},...o===void 0?{}:{reasoningTokens:o},...t===void 0?{}:{route:t}}}function iS(e){if(e.length===0)return;let t=eS(e.map(e=>e.inputTokens)),n=eS(e.map(e=>e.outputTokens)),r=eS(e.map(e=>e.totalTokens));if(t===void 0||n===void 0||r===void 0)return;let i=e.map(e=>e.cacheReadTokens),a=e.map(e=>e.cacheWriteTokens),o=e.map(e=>e.reasoningTokens),s=i.every($x)?eS(i):void 0,c=a.every($x)?eS(a):void 0,l=o.every($x)?eS(o):void 0,u,d=e.map(e=>e.route);if(d.every(e=>e!==void 0)){let e=/* @__PURE__ */ new Map;for(let t of d)e.set(`${t.provider}\0${t.model}`,t);u=[...e.values()]}return{uncachedInputTokens:t,outputTokens:n,totalTokens:r,...s===void 0?{}:{cacheReadTokens:s},...c===void 0?{}:{cacheWriteTokens:c},...l===void 0?{}:{reasoningTokens:l},...u===void 0?{}:{routes:u}}}function aS(e,t,n){return e.turn===t&&e.step===n}function oS(e){let t={kind:`idle`},n=[],r,i=!1,a=!1,o=e=>{if(t.kind!==`open`||t.sample===void 0)return!1;let r=rS(t.sample,e);return r!==void 0&&(n.push(r),!0)};for(let n of e){if(a)break;if(n.type===`turn/start`)r!==void 0||t.kind!==`idle`?a=!0:r=n.data.turn;else{if(r===void 0){a=!0;break}if(n.type===`turn/end`)n.data.turn!==r||t.kind!==`idle`||i?a=!0:i=!0;else{if(i){a=!0;break}if(n.type===`step/start`)n.data.turn!==r||t.kind!==`idle`?a=!0:t={kind:`open`,turn:r,step:n.data.step};else if(n.type===`llm/retry-started`)n.data.turn!==r||t.kind!==`settled`||t.by!==`retry`||!aS(t,n.data.turn,n.data.step)?a=!0:t={kind:`open`,turn:r,step:n.data.step};else if(n.type===`assistant/attempt`){if(n.data.turn!==r||t.kind!==`open`||!aS(t,n.data.turn,n.data.step)){a=!0;continue}let e=nS(n.data.stream)??t.sample;t={kind:`open`,turn:r,step:n.data.step,...e===void 0?{}:{sample:e}},o()?t={kind:`finishClosed`,turn:r,step:n.data.step}:a=!0}else if(n.type===`assistant/message`){if(n.data.turn!==r||t.kind!==`open`||!aS(t,n.data.turn,n.data.step)){a=!0;continue}let e=n.data.usage??nS(n.data.stream);e!==void 0&&(t={...t,sample:e}),o(tS(n.data.message))?t={kind:`settled`,turn:r,step:n.data.step,by:`message`}:a=!0}else if(n.type===`llm/retry`){if(n.data.turn!==r||t.kind===`idle`||!aS(t,n.data.turn,n.data.step)){a=!0;continue}(t.kind===`settled`||t.kind===`open`&&!o())&&(a=!0),a||(t={kind:`settled`,turn:r,step:n.data.step,by:`retry`})}else if(n.type===`step/end`){if(n.data.turn!==r||t.kind===`idle`||!aS(t,n.data.turn,n.data.step)){a=!0;continue}t.kind===`open`&&!o()&&(a=!0),a||(t={kind:`idle`})}}}}return a||!i||t.kind!==`idle`?void 0:iS(n)}function sS(e){return e.type!==`assistant/live-chunk`}function cS(e){if(e.type===`assistant/message`||e.type===`assistant/attempt`||e.type===`assistant/live-chunk`||e.type===`step/start`||e.type===`step/end`||e.type===`llm/retry`||e.type===`llm/retry-started`)return{turn:e.data.turn,step:e.data.step}}function lS(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function uS(e){return e.finalNode!==void 0&&e.blocks.some(e=>e.kind===`text`&&e.text.trim()!==``)}function dS(e){let t=e.state===void 0?e.matches.find(e=>e.event.type===`turn/end`):e.state.end;if(t?.event.type!==`turn/end`)return null;let n=lS(e);if(n===void 0)return null;let r=n.steps.map(e=>e.data.get(`assistant-step`)).filter(e=>e!==void 0).filter(e=>e.finalNode!==void 0).sort((e,t)=>e.finalNode.seq-t.finalNode.seq),i=r.findLast(uS)??null,a=r.at(-1)?.finalNode.seq;for(let t of e.matches){let e=t.event,n=e.type===`tool/call`||e.type===`tool/result`&&e.surfaceOp===`append`||e.type===`turn/end`&&e.data.reason.kind===`error`||e.type===`llm/retry`?e.seq:void 0;n!==void 0&&(a===void 0||n>a)&&(a=n)}let o=e.start?.event.type===`turn/start`?oS(e.matches.map(e=>e.event).filter(sS)):void 0;return{turn:t.event.data.turn,seq:t.event.seq,time:t.event.time,closing:i,branchUnavailable:i===null||a!==i.finalNode.seq,...o===void 0?{}:{tokenUsage:o}}}let fS={kind:`turn-tail`,target:`chat`,match:e=>{if(e.type===`turn/start`)return{id:String(e.data.turn),role:`start`};if(e.type===`turn/end`||e.type===`tool/call`||e.type===`tool/result`)return{id:String(e.data.turn),role:`update`};let t=cS(e);return t===void 0?null:{id:String(t.turn),role:`update`}},start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-tail start requires turn/start`);return{turn:t.event.data.turn}},update:(e,t)=>t.event.type===`turn/end`?{...e.state,end:t}:e.state,publication:e=>e.event.type===`turn/end`?`immediate`:`none`,buildLocationData:(e,t)=>{if(t!==`turn`)return null;let n=dS(e);return n===null?null:{kind:`turn`,turn:n.turn,key:`turn-tail`,value:n}},buildViewNode:e=>{let t=lS(e)?.data.get(`turn-tail`);return t===void 0?null:Xv(e,`turn-tail`,t.seq+Jv.finalizedFollowup,t)}};function pS(e){let t=fS.match.bind(fS);e.uiConversation.events.register({...fS,match:{"turn/start":t,"turn/end":t,"tool/call":t,"tool/result":t,"assistant/message":t,"assistant/attempt":t,"assistant/live-chunk":t,"step/start":t,"step/end":t,"llm/retry":t,"llm/retry-started":t}})}function mS(e){return e===`read`?`read`:e===`read_image`?`readImage`:e===`grep`||e===`glob`||e.endsWith(`_inspect`)?`search`:e===`write`?`write`:e===`edit`||e===`apply_patch`?`edit`:[`bash`,`pwsh`,`exec_command`,`write_stdin`].includes(e)||e.startsWith(`terminal_`)?`commands`:e===`run_code`?`code`:e===`web_search`?`webSearch`:e===`web_fetch`?`webFetch`:e===`subagent`||e.startsWith(`subagent_`)?`subagents`:[`todo_write`,`create_goal`,`update_goal`,`get_goal`].includes(e)?`plan`:e===`ask_user_question`||e===`request_user_input`?`questions`:`tools`}let hS=new Intl.Segmenter(void 0,{granularity:`grapheme`}),gS=[`title`,`description`,`objective`,`task`,`task_name`,`name`,`question`,`questions`,`prompt`,`message`,`command`,`cmd`,`queries`,`query`,`pattern`,`url`,`uri`,`file_path`,`path`,`target`,`action`,`status`];function _S(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=160)return{text:t,truncated:!1};let n=[];for(let{segment:e}of hS.segment(t)){if(n.length===160)return{text:`${n.slice(0,159).join(``).trimEnd()}…`,truncated:!0};n.push(e)}return{text:t,truncated:!1}}function vS(e){return _S(typeof e==`string`?e:Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(`, `):``).text}function yS(e,t){let n=512;for(;;){let r=e.textPrefix(t,n);if(r===void 0)return;let i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319){let i=e.textPrefix(t,n+1),a=i.charCodeAt(r.length);a>=56320&&a<=57343?(r=i,n++):i.length===r.length&&!e.isSealed&&!e.complete(t)&&(r=r.slice(0,-1))}let a=_S(r);if(a.truncated||!e.stringExceeds(t,n))return a.text;n*=2}}function bS(e){if(!Array.isArray(e))return``;for(let t of e){if(typeof t!=`object`||!t)continue;let e=vS(Reflect.get(t,`question`));if(e!==``)return e}return``}function xS(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.kind===`assistant-step`&&n.data.status===`running`)for(let e=n.data.blocks.length-1;e>=0;e--){let t=n.data.blocks[e];if(t?.kind!==`reasoning`)continue;let r=t.text.split(/\r?\n[\t ]*\r?\n/);for(let e=r.length-1;e>=0;e--){let t=vS(r[e]?.replaceAll(`**`,``));if(t!==``)return t}}}return``}function SS(e,t){for(let e of gS){if(!t.has(e))continue;let n=e===`questions`?bS(t.value(e)):yS(t,e)??vS(t.value(e));if(n!==``)return n}return t.closed()?vS(e):``}function CS(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r,i=``,a=-1/0,o,s=e=>{if(n.has(e.callId))return;n.add(e.callId);let c=Dy(e)?e:e.call;if(c!==null){let n=mS(c.name);Dy(e)&&e.time>=a&&(r=n,o=e.phase===`preparing`,i=SS(e.name,e.args),a=e.time),t.set(n,(t.get(n)??0)+1)}for(let t of e.subCalls)s(t)};for(let t of e)t.kind===`tool-call`&&s(t.data.root);return r===void 0&&(i=xS(e)),{counts:[...t].map(([e,t])=>({kind:e,count:t})).sort((e,t)=>t.count-e.count),running:r,runningDetail:i,...o?{preparing:!0}:{}}}let wS=/* @__PURE__ */ new Set([`user`,`steering`,`turn-trigger`,`model-retry`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function TS(e){let t=e.location;return t.kind===`turn`||t.kind===`step`?t.turn.turn:void 0}function ES(e){return wS.has(e.kind)||e.kind===`tool-call`&&vh(e.data.root.name)}function DS(e){return e.kind===`assistant-step`&&e.data.blocks.some(e=>e.kind===`reasoning`&&e.text.trim()!==``)}function OS(e){return e.kind===`assistant-step`&&Fv(e.data.blocks)}function kS(e,t){return e.running===t.running&&e.runningDetail===t.runningDetail&&e.preparing===t.preparing&&e.counts.length===t.counts.length&&e.counts.every((e,n)=>e.kind===t.counts[n]?.kind&&e.count===t.counts[n].count)}function AS(e,t){return e.length===t.length&&e.every((e,n)=>e.key===t[n]?.key&&e.groupPart===t[n].groupPart)}function jS(e,t){return!Oy(t)&&(e===void 0||!Oy(e))?!1:e===void 0||e.kind!==t.kind||TS(e)!==TS(t)||Oy(e)!==Oy(t)||DS(e)!==DS(t)||OS(e)!==OS(t)}function MS(e,t){let n=e.readNode(t);if(n===void 0)throw Error(`Chat grouping input is missing Node ${t}`);return n}function NS(e,t){let n=/* @__PURE__ */ new Set;for(let r of t){let t=MS(e,r);t.kind===`question-reply`&&n.add(t.id)}return n}var PS=class{key;turn;members;nodes=[];forceClosed=!1;sameTurnFollowed=!1;snapshot;constructor(e,t,n){this.key=e,this.turn=t,this.members=n,this.snapshot={key:e,members:n,data:{turn:t,closed:!1,summary:{counts:[],running:void 0,runningDetail:``}}}}get isForceClosed(){return this.forceClosed}get isSameTurnFollowed(){return this.sameTurnFollowed}refresh(e,t,n,r){this.forceClosed=t,this.sameTurnFollowed=n;let i=this.members.map(t=>MS(e,t.key)),a=i.length===this.nodes.length&&i.every((e,t)=>e===this.nodes[t]),o=this.snapshot.data,s=r===`closed`||t||n&&r!==`open`,c=a&&(!o.closed||s)?o.summary:CS(i),l=s||n&&c.running===void 0,u=l?{counts:c.counts,running:void 0,runningDetail:``}:c;this.nodes=i,(o.closed!==l||!kS(o.summary,u))&&(this.snapshot={key:this.key,members:this.members,data:{turn:this.turn,closed:l,summary:u}})}},FS=class{turn;groups=/* @__PURE__ */ new Map;membership=/* @__PURE__ */ new Map;roots=/* @__PURE__ */ new Map;lastTurnStatus;constructor(e){this.turn=e}references(e){return this.roots.get(e)??[]}snapshots(){return[...this.groups.values()].map(e=>e.snapshot)}refresh(e,t){let n=/* @__PURE__ */ new Set;for(let e of t){let t=this.membership.get(e);t!==void 0&&n.add(t)}let r=e.timeline.turns.get(this.turn)?.status;if(r!==this.lastTurnStatus){for(let e of this.groups.values())n.add(e.key);this.lastTurnStatus=r}let i=[];for(let t of n){let n=this.groups.get(t),a=n.snapshot;n.refresh(e,n.isForceClosed,n.isSameTurnFollowed,r),n.snapshot!==a&&i.push(n.snapshot)}return i}rebuild(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=[],o=[],s=e.timeline.turns.get(this.turn)?.status;this.lastTurnStatus=s;let c=(e,t)=>{n.set(e,[...n.get(e)??[],t])},l=(n,l)=>{let u=a[0];if(u===void 0)return;let d=this.extendedGroup(a,t)?.key??Ug(JSON.stringify([`process`,u.key,u.groupPart??null])),f=this.groups.get(d),p=f?.snapshot,m=f!==void 0&&AS(f.members,a)?f:new PS(d,this.turn,a);m.refresh(e,n,l,s),r.set(m.key,m),c(u.key,{kind:`group`,key:m.key});for(let e of a)i.set(e.key,m.key);m.snapshot!==p&&o.push(m.snapshot),a=[]},u,d=!1,f=e.readTurn(this.turn),p=NS(e,f);for(let t of f){let n=IS(e,t);u!==void 0&&n.previous!==u&&l(!0,!1),u=t,d=n.next!==void 0;let r=MS(e,t);r.kind===`turn-trigger`&&p.has(r.id)||(ES(r)?(l(!1,!0),c(t,{kind:`node`,key:t})):r.kind===`turn-process`?c(a[0]?.key??t,{kind:`node`,key:t}):r.kind===`assistant-step`?(DS(r)&&a.push({kind:`node`,key:t,groupPart:`reasoning`}),OS(r)&&(l(!1,!0),c(t,{kind:`node`,key:t,groupPart:`response`}))):a.push({kind:`node`,key:t}))}l(d,!1);let m=[...this.groups.keys()].filter(e=>!r.has(e));return this.groups=r,this.membership=i,this.roots=n,{upserts:o,removes:m}}extendedGroup(e,t){let n=e.findIndex(e=>!t.has(e.key)),r=e[n];if(r===void 0)return;let i=this.membership.get(r.key),a=i===void 0?void 0:this.groups.get(i);if(!(a===void 0||n+a.members.length>e.length)){for(let t=0;t<a.members.length;t++){let r=a.members[t],i=e[n+t];if(r.key!==i.key||r.groupPart!==i.groupPart)return}for(let r=n+a.members.length;r<e.length;r++)if(!t.has(e[r].key))return;return a}}};function IS(e,t){let n=e.readPosition(t);if(n===void 0)throw Error(`Chat grouping order is missing position for Node ${t}`);return n}var LS=class{turns=/* @__PURE__ */ new Map;order=[];pending=null;accept(e){if(e.kind===`replace`){let t=new Set(this.order),n=new Set(e.order.filter(e=>!t.has(e))),r=/* @__PURE__ */ new Map;for(let t of e.order){let i=IS(e,t).turn;if(i===void 0||r.has(i))continue;let a=this.turns.get(i)??new FS(i);a.rebuild(e,n),r.set(i,a)}this.turns=r,this.order=e.order,this.pending={entries:this.rootEntries(e),groups:{kind:`replace`,snapshots:[...r.values()].flatMap(e=>e.snapshots())}};return}let t=new Set(e.changedTurnOrders),n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Map,i=e=>{let t=r.get(e);return t===void 0&&(t=/* @__PURE__ */ new Set,r.set(e,t)),t};for(let r of e.changes){let e=r.previous,a=r.current,o=TS(a);if((e===void 0||!Oy(e))&&n.add(a.key),jS(e,a)){let n=e===void 0?void 0:TS(e);n!==void 0&&t.add(n),o!==void 0&&t.add(o)}o!==void 0&&i(o).add(a.key)}for(let t of e.changedTurns)i(t);let a=[],o=[];for(let r of t){let t=this.turns.get(r)??new FS(r),i=t.rebuild(e,n);a.push(...i.upserts),o.push(...i.removes),e.readTurn(r).length===0?this.turns.delete(r):this.turns.set(r,t)}for(let[n,i]of r)t.has(n)||a.push(...this.turns.get(n)?.refresh(e,i)??[]);let s=e.order!==this.order||t.size>0;this.order=e.order;let c=new Set(a.map(e=>e.key));this.pending=s||a.length>0||o.length>0?{...s?{entries:this.rootEntries(e)}:{},groups:{kind:`apply`,upserts:a,removes:o.filter(e=>!c.has(e))}}:null}rootEntries(e){let t=NS(e,e.order.filter(t=>IS(e,t).turn===void 0));return e.order.flatMap(n=>{let r=IS(e,n).turn;if(r===void 0){let r=MS(e,n);return r.kind===`turn-trigger`&&t.has(r.id)?[]:[{kind:`node`,key:n}]}let i=this.turns.get(r);if(i===void 0)throw Error(`Chat grouping order is missing Turn ${r}`);return i.references(n)})}output(){return this.pending}};let RS={kind:`process-groups`,target:`chat`,create:()=>new LS,update:(e,t)=>(e.state.accept(t),e.state),buildGroups:e=>e.state.output()};function zS(e){Yb(e),tx(e),ox(e),Ty(e),Zx(e),Ox(e),Fb(e),Rb(e),ux(e),Nx(e),Rx(e),pS(e),Bb(e),Cb(e),e.uiConversation.groups.register(RS)}function BS({useNotice:e,dismissNotice:t,keepNoticeOpen:n,renderSlotChain:r,t:i}){let a=e(e=>e);if(a===null)return null;let o={code:a.code,message:i(`message.failure.quota`),dismiss:t,keepOpen:n};return/* @__PURE__ */ (0,f.jsx)(d.Fragment,{children:r(`shell.quota-notice`,o,{fallback:/* @__PURE__ */ (0,f.jsx)(p.Toast,{text:o.message,icon:/* @__PURE__ */ (0,f.jsx)(p.IconWarningOutlineRegular,{size:18}),onDone:t})})},`quota-notice-${String(a.seq)}`)}function VS(e){return e==null}function HS(e){return e&&typeof e==`object`&&!Array.isArray(e)}function US(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function WS(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function GS(e,t,n){if(!t)return{...e};let r={};for(let i of t)(n||e[i]!==void 0)&&(r[i]=e[i]);return r}let KS=Symbol.for(`cosmokit.volatile.write`);function qS(e,t=/* @__PURE__ */ new Set){if(typeof e==`function`)throw TypeError(`volatile config cannot contain functions`);if(typeof e!=`object`||!e)return e;if(t.has(e))throw TypeError(`volatile config cannot contain cycles`);t.add(e);try{if(Array.isArray(e))return Object.freeze(e.map(e=>qS(e,t)));if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`volatile config objects must be plain objects or arrays`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,qS(n,t)])))}finally{t.delete(e)}}function JS(e){let t=qS(e);return Object.freeze({get:()=>t,[KS]:e=>{t=e}})}function YS(e){return typeof e==`object`&&!!e&&KS in e}function XS(e,t){return arguments.length===1?t=>XS(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function ZS(e){return XS(`ArrayBuffer`,e)||XS(`SharedArrayBuffer`,e)}function QS(e){return ZS(e)||ArrayBuffer.isView(e)}let $S;(function(e){e.is=ZS,e.isSource=QS;function t(e){return ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}e.fromSource=t;function n(e){if(e=t(e),typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let n=``,r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)n+=String.fromCharCode(r[e]);return btoa(n)}e.toBase64=n;function r(e){return typeof Buffer<`u`?t(Buffer.from(e,`base64`)):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}e.fromBase64=r;function i(e){return e=t(e),typeof Buffer<`u`?Buffer.from(e).toString(`hex`):Array.from(new Uint8Array(e),e=>e.toString(16).padStart(2,`0`)).join(``)}e.toHex=i;function a(e){if(typeof Buffer<`u`)return t(Buffer.from(e,`hex`));let n=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(`${n[e]}${n[e+1]}`,16));return Uint8Array.from(r).buffer}e.fromHex=a})($S||={}),$S.fromBase64,$S.toBase64,$S.fromHex,$S.toHex;function eC(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(XS(`Date`,e))return new Date(e.valueOf());if(XS(`RegExp`,e))return new RegExp(e.source,e.flags);if(ZS(e))return e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let n=t.get(e);if(n)return n;if(Array.isArray(e)){let n=[];return t.set(e,n),e.forEach((e,r)=>{n[r]=Reflect.apply(eC,null,[e,t])}),n}let r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(let n of Reflect.ownKeys(e)){let i={...Reflect.getOwnPropertyDescriptor(e,n)};`value`in i&&(i.value=Reflect.apply(eC,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function tC(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(YS(e)||YS(t))return YS(e)&&YS(t);if(!n&&VS(e)&&VS(t))return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||!t||r.has(e))return!1;function a(n,r){return n(e)?n(t)?r(e,t):!1:!n(t)&&void 0}r.add(e);try{return a(Array.isArray,(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0})??a(XS(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(XS(`URL`),(e,t)=>e.href===t.href)??a(XS(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(ZS,(e,t)=>{if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0})??((!n||[e,t].every(e=>Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null))&&Object.keys({...e,...t}).every(n=>i(e[n],t[n])))}finally{r.delete(e)}}return i(e,t)}let nC;(function(e){e.millisecond=1;let t=e.second=1e3,n=e.minute=t*60,r=e.hour=n*60,i=e.day=r*24,a=e.week=i*7,o=(/* @__PURE__ */ new Date()).getTimezoneOffset();function s(e){o=e}e.setTimezoneOffset=s;function c(){return o}e.getTimezoneOffset=c;function l(e=/* @__PURE__ */ new Date,t){return typeof e==`number`&&(e=new Date(e)),t===void 0&&(t=o),Math.floor((e.valueOf()/n-t)/1440)}e.getDateNumber=l;function u(e,t){let r=new Date(e*i);return t===void 0&&(t=o),new Date(+r+t*n)}e.fromDateNumber=u;let d=RegExp(`^${[`w(?:eek(?:s)?)?`,`d(?:ay(?:s)?)?`,`h(?:our(?:s)?)?`,`m(?:in(?:ute)?(?:s)?)?`,`s(?:ec(?:ond)?(?:s)?)?`].map(e=>`(\\d+(?:\\.\\d+)?${e})?`).join(``)}$`);function f(e){let o=d.exec(e);return o?(parseFloat(o[1])*a||0)+(parseFloat(o[2])*i||0)+(parseFloat(o[3])*r||0)+(parseFloat(o[4])*n||0)+(parseFloat(o[5])*t||0):0}e.parseTime=f;function p(e){let t=f(e);return t?e=Date.now()+t:/^\d{1,2}(:\d{1,2}){1,2}$/.test(e)?e=`${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${e}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(e)&&(e=`${(/* @__PURE__ */ new Date()).getFullYear()}-${e}`),e?new Date(e):/* @__PURE__ */ new Date}e.parseDate=p;function m(e){let a=Math.abs(e);return a>=i-r/2?Math.round(e/i)+`d`:a>=r-n/2?Math.round(e/r)+`h`:a>=n-t/2?Math.round(e/n)+`m`:a>=t?Math.round(e/t)+`s`:e+`ms`}e.format=m;function h(e,t=2){return e.toString().padStart(t,`0`)}e.toDigits=h;function g(e,t=/* @__PURE__ */ new Date){return e.replace(`yyyy`,t.getFullYear().toString()).replace(`yy`,t.getFullYear().toString().slice(2)).replace(`MM`,h(t.getMonth()+1)).replace(`dd`,h(t.getDate())).replace(`hh`,h(t.getHours())).replace(`mm`,h(t.getMinutes())).replace(`ss`,h(t.getSeconds())).replace(`SSS`,h(t.getMilliseconds(),3))}e.template=g})(nC||={});let rC=Symbol.for(`schemastery`),iC=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var Q=class extends TypeError{options;name=`ValidationError`;constructor(e,t){let n=`$`;for(let e of t.path||[])typeof e==`string`?n+=`.`+e:typeof e==`number`?n+=`[`+e+`]`:typeof e==`symbol`&&(n+=`[Symbol(${e.toString()})]`);n.startsWith(`.`)&&(n=n.slice(1)),super((n===`$`?``:`${n} `)+e),this.options=t}static is(e){return!!e?.[iC]}};Object.defineProperty(Q.prototype,iC,{value:!0});let $=function(e){let t=function(e,n={}){return $.resolve(e,t,n)[0]};if(e.refs){let t=WS(e.refs,e=>new $(e)),n=e=>t[e];for(let e in t){let r=t[e];r.sKey=n(r.sKey),r.inner=n(r.inner),r.list=r.list&&r.list.map(n),r.dict=r.dict&&WS(r.dict,n)}return t[e.uid]}if(Object.assign(t,e),typeof t.callback==`string`)try{t.callback=Function(`return `+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,$.prototype),t.meta||={},t.toString=t.toString.bind(t),t};$.prototype=Object.create(Function.prototype),$.prototype[rC]=!0,Object.defineProperty($.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:$.resolve(e,this,{})[0]}}catch(e){if(Q.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),$.ValidationError=Q,$.prototype.toJSON=function(){if(globalThis.__schemastery_refs__)return globalThis.__schemastery_refs__[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));let e={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,e},$.prototype.set=function(e,t){return this.dict[e]=t,this},$.prototype.push=function(e){return this.list.push(e),this};function aC(e,t){let n=typeof e==`string`?{"":e}:{...e};for(let e in t){let r=t[e];r?.$description||r?.$desc?n[e]=r.$description||r.$desc:typeof r==`string`&&(n[e]=r)}return n}function oC(e){return e?.$value??e?.$inner}function sC(e){return US(e??{},e=>!e.startsWith(`$`))}$.prototype.i18n=function(e){let t=$(this),n=aC(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=WS(t.dict,(t,n)=>t.i18n(WS(e,e=>oC(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(WS(e,(e={})=>Array.isArray(oC(e))?oC(e)[n]:Array.isArray(e)?e[n]:sC(e)))),t.inner&&=t.inner.i18n(WS(e,e=>oC(e)?oC(e):sC(e))),t.sKey&&=t.sKey.i18n(WS(e,e=>e?.$key)),t},$.prototype.extra=function(e,t){let n=$(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign($.prototype,{[e](t=!0){let n=$(this);return n.meta={...n.meta,[e]:t},n}});$.prototype.deprecated=function(){let e=$(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},$.prototype.experimental=function(){let e=$(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},$.prototype.pattern=function(e){let t=$(this),n=GS(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},$.prototype.simplify=function(e){if(YS(e)&&(e=e.get()),tC(e,this.meta.default,this.type===`dict`))return null;if(VS(e))return e;if(this.type===`object`||this.type===`dict`){let t={};for(let n in e){let r=(this.type===`object`?this.dict[n]:this.inner)?.simplify(e[n]);(this.type===`dict`||!VS(r))&&(t[n]=r)}return tC(t,this.meta.default,this.type===`dict`)?null:t}if(this.type===`array`||this.type===`tuple`){let t=[];return e.forEach((e,n)=>{let r=this.type===`array`?this.inner:this.list[n],i=r?r.simplify(e):e;t.push(i)}),t}if(this.type===`intersect`){let t={};for(let n of this.list)Object.assign(t,n.simplify(e));return t}if(this.type===`union`)for(let t of this.list)try{return $.resolve(e,t,{}),t.simplify(e)}catch{}return e},$.prototype.toString=function(e){return gC[this.type]?.(this,e)??`Schema<${this.type}>`},$.prototype.role=function(e,t){let n=$(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign($.prototype,{[e](t){let n=$(this);return n.meta={...n.meta,[e]:t},n}});$.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let cC={},lC=Symbol(`checked-volatile-schema`);function uC(e,t=[],n=!1,r=/* @__PURE__ */ new Map){let i=r.get(e)??/* @__PURE__ */ new Set;if(i.has(n))return;if(i.add(n),r.set(e,i),e.meta?.volatile&&n)throw new Q(`volatile fields require a fixed object path without an enclosing volatile field`,{path:t});let a=n||!!e.meta?.volatile;if(e.dict)for(let[n,i]of Object.entries(e.dict))uC(i,[...t,n],a,r);if(e.sKey&&uC(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[rC])&&uC(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)uC(e.list[n],[...t,String(n)],!0,r)}$.extend=function(e,t){cC[e]=t},$.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[lC]||(uC(t,n.path),n={...n,[lC]:!0}),t.meta?.volatile){let i=$(t);i.meta={...t.meta,volatile:!1};let[a,o]=$.resolve(e,i,n,r);try{return[JS(a),o]}catch(e){throw new Q(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(VS(e)&&t.type!==`lazy`){if(t.meta.required)throw new Q(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&VS(i);)r=r.list[0],i=r?.meta.default;if(VS(i))return[e];e=eC(i)}let i=cC[t.type];if(!i)throw new Q(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},$.from=function(e){if(VS(e))return $.any();if([`string`,`number`,`boolean`].includes(typeof e))return $.const(e).required();if(e[rC])return e;if(typeof e==`function`)switch(e){case String:return $.string().required();case Number:return $.number().required();case Boolean:return $.boolean().required();case Function:return $.function().required();default:return $.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},$.lazy=function(e){let t=new $({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[rC]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},$.natural=function(){return $.number().step(1).min(0)},$.percent=function(){return $.number().step(.01).min(0).max(1).role(`slider`)},$.date=function(){return $.union([$.is(Date),$.transform($.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new Q(`invalid date "${e}"`,t);return n},!0)])},$.regExp=function(e=``){return $.union([$.is(RegExp),$.transform($.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new Q(e.message,n)}},!0)])},$.arrayBuffer=function(e){return $.union([$.is(ArrayBuffer),$.is(SharedArrayBuffer),$.transform($.any(),(e,t)=>{if($S.isSource(e))return $S.fromSource(e);throw new Q(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[$.transform($.string(),(t,n)=>{try{return e===`base64`?$S.fromBase64(t):$S.fromHex(t)}catch(e){throw new Q(e.message,n)}},!0)]:[]])},$.extend(`lazy`,(e,t,n,r)=>(t.inner[rC]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},uC(t.inner,n.path,!0)),$.resolve(e,t.inner,n,r))),$.extend(`any`,e=>[e]),$.extend(`never`,(e,t,n)=>{throw new Q(`expected nullable but got ${e}`,n)}),$.extend(`const`,(e,{value:t},n)=>{if(tC(e,t))return[t];throw new Q(`expected ${t} but got ${e}`,n)});function dC(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new Q(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new Q(`expected ${n} >= ${o} but got ${e}`,r)}$.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new Q(`expected string but got ${e}`,n);if(t.pattern){let r=new RegExp(t.pattern.source,t.pattern.flags);if(!r.test(e))throw new Q(`expect string to match regexp ${r}`,n)}return dC(e.length,t,`string length`,n),[e]});function fC(e,t){let n=e.toString();if(n.includes(`e`))return e*10**t;let r=n.indexOf(`.`);if(r===-1)return e*10**t;let i=n.slice(r+1),a=n.slice(0,r);return i.length<=t?+(a+i.padEnd(t,`0`)):+(a+i.slice(0,t)+`.`+i.slice(t))}function pC(e,t,n){if(n=Math.abs(n),!/^\d+\.\d+$/.test(n.toString()))return(e-t)%n===0;let r=n.toString().indexOf(`.`),i=n.toString().slice(r+1).length;return Math.abs(fC(e,i)-fC(t,i))%fC(n,i)===0}$.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new Q(`expected number but got ${e}`,n);dC(e,t,`number`,n);let{step:r}=t;if(r&&!pC(e,t.min??0,r))throw new Q(`expected number multiple of ${r} but got ${e}`,n);return[e]}),$.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new Q(`expected boolean but got ${e}`,n)}),$.extend(`bitset`,(e,{bits:t,meta:n},r)=>{let i=0,a=[];if(typeof e==`number`){i=e;for(let n in t)e&t[n]&&a.push(n)}else if(Array.isArray(e)){a=e;for(let e of a){if(typeof e!=`string`)throw new Q(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new Q(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),$.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new Q(`expected function but got ${e}`,n)}),$.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new Q(`expected ${t.name} but got ${e}`,n)}{if(VS(e))throw new Q(`expected ${t} but got ${e}`,n);let r=Object.getPrototypeOf(e);for(;r;){if(r.constructor?.name===t)return[e];r=Object.getPrototypeOf(r)}throw new Q(`expected ${t} but got ${e}`,n)}});function mC(e,t,n,r){try{let[i,a]=$.resolve(e[t],n,{...r,path:[...r.path||[],t]});return a!==void 0&&(e[t]=a),i}catch(i){if(!r?.autofix)throw i;return delete e[t],n.meta.volatile?JS(n.meta.default):n.meta.default}}$.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new Q(`expected array but got ${e}`,r);return dC(e.length,n,`array length`,r,!VS(t.meta.default)),[e.map((n,i)=>mC(e,i,t,r))]}),$.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!HS(e))throw new Q(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=$.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=mC(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),$.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new Q(`expected array but got ${e}`,n);let i=t.map((t,r)=>mC(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function hC(e,t){for(let n in t)n in e||(e[n]=t[n])}$.extend(`object`,(e,{dict:t},n,r)=>{if(!HS(e))throw new Q(`expected object but got ${e}`,n);let i={};for(let r in t){let a=mC(e,r,t[r],n);(!VS(a)||r in e)&&(i[r]=a)}return r||hC(i,e),[i]}),$.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return $.resolve(e,n,r,i)}catch(e){a.push(e)}throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),$.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=$.resolve(e,i,r,!0)[0];if(!VS(t)){if(VS(a))a=t;else if(typeof a!=typeof t)throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)hC(a??={},t);else if(a!==t)throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&HS(e)&&hC(a,e),[a]}),$.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=$.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let gC={};function _C(e,t,n){gC[e]=n,Object.assign($,{[e](...n){let r=new $({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??$.string();break;case`inner`:r.inner=$.from(n[t]);break;case`list`:r.list=n[t].map($.from);break;case`dict`:r.dict=WS(n[t],$.from);break;case`bits`:r.bits={};for(let e in n[t])typeof n[t][e]==`number`&&(r.bits[e]=n[t][e]);break;case`callback`:{let e=r.callback=n[t];e.toJSON||=()=>e.toString();break}case`constructor`:{let e=r.constructor=n[t];typeof e==`function`&&(e.toJSON||=()=>e.name);break}default:r[e]=n[t]}}),e===`object`||e===`dict`?r.meta.default={}:e===`array`||e===`tuple`?r.meta.default=[]:e===`bitset`&&(r.meta.default=0),r}})}_C(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),_C(`any`,[],()=>`any`),_C(`never`,[],()=>`never`),_C(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),_C(`string`,[],()=>`string`),_C(`number`,[],()=>`number`),_C(`boolean`,[],()=>`boolean`),_C(`bitset`,[`bits`],()=>`bitset`),_C(`function`,[],()=>`function`),_C(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),_C(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),_C(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),_C(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),_C(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),_C(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),_C(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let vC=`transcriptView`,yC=[`compact`,`standard`,`detailed`,`verbose`],bC=[...yC,`normal`,`expanded`],xC=`standard`,SC={linkOpening:$.union([`sidebar`,`new-tab`]).default(`sidebar`),[vC]:$.union([...bC]).loose()};$.object(SC);let CC=`@deepseek-ai/dsh-client-ui-chat/PreferenceRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(CC)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=CC,e.textContent=`.B8MZ0a_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.B8MZ0a_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.B8MZ0a_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.B8MZ0a_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.B8MZ0a_selector{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;touch-action:manipulation;user-select:none;-webkit-tap-highlight-color:transparent;border:none;flex-shrink:0;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.B8MZ0a_selector:active{background:var(--dsw-alias-interactive-bg-active)}.B8MZ0a_chevron{flex:none}@media (hover:hover) and (pointer:fine){.B8MZ0a_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}}@media (width<=640px){.B8MZ0a_row{gap:12px;min-height:44px;padding:12px 0}.B8MZ0a_rowText{padding-right:0}.B8MZ0a_selector{gap:8px;height:44px;min-height:44px;padding:0 12px;font-size:13.5px}}`,document.head.appendChild(e)}var wC={chevron:`B8MZ0a_chevron`,desc:`B8MZ0a_desc`,row:`B8MZ0a_row`,rowText:`B8MZ0a_rowText`,selector:`B8MZ0a_selector`,title:`B8MZ0a_title`};function TC({title:e,description:t,value:n,selectedLabel:r,options:i,onSelect:a}){let[o,s]=(0,d.useState)(!1),c=(0,d.useRef)(null),l=()=>{s(!1)},u=e=>{c.current?.focus({preventScroll:!0}),l(),a(e)},m=/* @__PURE__ */ (0,f.jsxs)(`button`,{ref:c,type:`button`,className:wC.selector,"aria-haspopup":`menu`,"aria-expanded":o,onClick:()=>{s(e=>!e)},children:[r,/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:wC.chevron})]});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:wC.row,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:wC.rowText,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:wC.title,children:e}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:wC.desc,children:t})]}),/* @__PURE__ */ (0,f.jsx)(p.Menu,{open:o,onClose:l,items:i,selectedId:n,onSelect:u,align:`end`,portal:!0,anchor:m})]})}let EC={compact:`settings.transcript.compact`,standard:`settings.transcript.standard`,detailed:`settings.transcript.detailed`,verbose:`settings.transcript.verbose`};function DC({useTranscriptView:e,setTranscriptView:t,t:n}){let r=e(e=>e);return/* @__PURE__ */ (0,f.jsx)(TC,{title:n(`settings.transcript.title`),description:n(`settings.transcript.description`),value:r,selectedLabel:n(EC[r]),options:yC.map(e=>({id:e,label:n(EC[e])})),onSelect:e=>{t(e)}})}var OC=class{host;defaultMode;unsubscribe;mode;constructor(e,t=xC){this.host=e,this.defaultMode=t,this.mode=(0,m.createSnapshotStore)(t),this.unsubscribe=e.subscribe(()=>{this.adopt()}),this.adopt()}dispose(){this.unsubscribe()}setMode(e){this.mode.getSnapshot()!==e&&(this.mode.set(e),this.host.set(vC,e))}adopt(){let e=this.host.getSnapshot().value;if(e===void 0)return;let t=e.transcriptView,n=t===`normal`||t===`expanded`?`detailed`:t??this.defaultMode;this.mode.getSnapshot()!==n&&this.mode.set(n)}};let kC={compact:{mode:`compact`,foldCompletedTurns:!0,stepGrouping:`collapsed`,liveProcessDetail:!1,settledReasoningPreview:!1},standard:{mode:`standard`,foldCompletedTurns:!0,stepGrouping:`collapsed`,liveProcessDetail:!0,settledReasoningPreview:!0},detailed:{mode:`detailed`,foldCompletedTurns:!0,stepGrouping:`history`,liveProcessDetail:!0,settledReasoningPreview:!0},verbose:{mode:`verbose`,foldCompletedTurns:!1,stepGrouping:`none`,liveProcessDetail:!1,settledReasoningPreview:!0}};function AC(e){return{getSnapshot:()=>kC[e.getSnapshot()],subscribe:t=>e.subscribe(t)}}function jC({useLinkOpening:e,useBrowserAvailable:t,setLinkOpening:n,t:r}){let i=e(e=>e);return t(e=>e)?/* @__PURE__ */ (0,f.jsx)(TC,{title:r(`settings.links.title`),description:r(`settings.links.description`),value:i,selectedLabel:r(i===`sidebar`?`settings.links.sidebar`:`settings.links.newTab`),options:[{id:`sidebar`,label:r(`settings.links.sidebar`)},{id:`new-tab`,label:r(`settings.links.newTab`)}],onSelect:e=>{n(e)}}):null}let MC={getSnapshot:()=>void 0,subscribe:()=>()=>{}};function NC(e,t){let n=e?.source(t)??MC;return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let PC={hooks:{turnData:(e,{turnData:t})=>function(e){return NC(t,e)},disclosure:(e,{disclosureReset:t})=>Kh(t)}},FC=[`slots`,`sessions`,`uiWorkspace`,`uiSession`,`uiConversation`,`locale`,`configForms`,`remote`,`remote.session`,`remote.workspaceFiles`,`sidebarRight`];function IC(e){let t=(0,m.createSnapshotStore)(null),n=0,r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new WeakMap,a=/* @__PURE__ */ new Set;e.effect(()=>async()=>{await Promise.all([...a].map(e=>e()))},`ui-chat: live quota notices`);let o=o=>{let s=i.get(o);if(s===void 0){let c=o.ctx.effect(()=>{let e=o.eventSource.subscribe(()=>{let{change:e}=o.eventSource.getSnapshot();if(e.kind===`append`)for(let{event:i}of e.entries){if(i.type!==`turn/end`||i.data.reason.kind!==`error`)continue;let{code:e}=i.data.reason.error;r.size>0||e!==`QUOTA`&&e!==`ACCOUNT_QUOTA`||t.set({code:e,seq:++n})}});return()=>{e(),i.delete(o),a.delete(c)}},`ui-chat: Provider binding quota notices`);a.add(c);let l=e.uiConversation.binding(o).target(`chat`);s={getSnapshot:()=>l.getSnapshot()??A,subscribe:e=>l.subscribe(e)},i.set(o,s)}return s};zS(e),e.uiSession.provide({hooks:[`chat`],resolve:e=>({hooks:{chat:o(e)}})}),e.effect(()=>e.locale.register(Q_,{zh:$_,en:ev}),`ui-chat: dictionaries`);let s=e.locale.bind(Q_),c=xh(),l=/* @__PURE__ */ new Map,u=e.configForms.get(`ui-chat`),d=(0,m.createSnapshotStore)(u.getSnapshot().value?.linkOpening??`sidebar`);e.effect(()=>u.subscribe(()=>{let e=u.getSnapshot().value?.linkOpening;e!==void 0&&d.set(e)}));let f={getSnapshot:()=>e.get(`sidebarRightTabs`)?.get(`browser`)!==void 0,subscribe:t=>e.get(`sidebarRightTabs`)?.subscribe(t)??(()=>{})},p=t=>f.getSnapshot()?(e.sidebarRight.openTab(`browser`,{params:{url:t}}),!0):!1;e.inject([`sidebarRightTabs`],e=>{e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`link-opening`,order:17,locale:Q_,inject:()=>({hooks:{linkOpening:d,browserAvailable:f},setLinkOpening:e=>{d.set(e),u.set(`linkOpening`,e).catch(()=>{})}})},jC))});let h=new OC(u,`dshDesktop`in globalThis?`standard`:xC),g=AC(h.mode);e.effect(()=>()=>{h.dispose()}),qv(e,g),e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`transcript-view`,order:12,locale:Q_,inject:()=>({hooks:{transcriptView:h.mode},setTranscriptView:e=>{h.setMode(e)}})},DC)),e.slots.inject(`conversation.view`,()=>e.slots.register({name:`conversation.view`,id:`chat`,order:0,label:()=>s(`view.chat`),locale:Q_,children:{"conversation.chat.node":{kind:`keyed`,scope:`session`,inject:PC},"conversation.message.images":{kind:`single`,scope:`session`}},store:c,inject:t=>{let n=e.sessions.binding(t);if(n===void 0)throw Error(`ui-chat: unknown session "${t}"`);let r=n.session,i=o(n),a=e.uiConversation.binding(n),s=e.get(`chatMessageEditing`),c=e.get(`chatTurnDiffs`),u=e.get(`chatHandoff`),m=u!==void 0&&!String(t).startsWith(`web-remote:`)&&e.sessions.subagentAddress(t)===void 0;return{connection:e.get(`connection`),hooks:{presentation:g,browserAvailable:f},keyedHooks:{chatNode:e=>i.getSnapshot().nodes.source(e),chatNodeProcess:e=>i.getSnapshot().nodes.processSource(e),chatGroup:e=>a.snapshot.getSnapshot().views.grouped(`chat`)?.groupSource(e)},fileMentions:n=>e.get(`chatFileMentions`)?.forClosing(n,t),openFile:async(n,r)=>{let i=e.sessions.list.getSnapshot().byId[t]?.cwd;if(r?.external||r?.reveal){let a=ie(i,n);if(!r.reveal||!re(a)){let r=await e.remote.workspaceFiles.stat(t,n);if(!r.ok)throw Error(r.error.message);a=r.value.absolutePath}let o=await e.remote.session.openWorkspacePath({sessionId:t,path:a,...r.reveal?{action:`reveal`}:{}});if(!o.ok)throw Error(o.error.message);return}let a=ae(t,i,n);r?.line===void 0?e.sidebarRight.openResource(a):e.sidebarRight.openResource(a,{params:{line:r.line}}),await Promise.resolve()},openSkill:n=>{let r=e.sessions.scope(t);r!==void 0&&e.get(`inputTriggers`)?.sessionOf(r).openReference(`skill`,{ref:`/${n}`})},resolveLink:e.get(`chatLinks`)?.resolve,openLinkInSidebar:p,openExternalLink:e=>{d.getSnapshot()===`sidebar`&&p(e)||window.open(e,`_blank`,`noopener,noreferrer`)},loadOlder:()=>{r.loadOlder()},loadThrough:e=>r.loadThrough(e),loadImage:Object.assign(n=>e.uiConversation.imageUrl(t,n),{peek:n=>e.uiConversation.peekImageUrl(t,n)}),chatScroll:{save:e=>{e===null?l.delete(t):l.set(t,e)},read:()=>l.get(t)??null},loadTurnDiffs:c?(e,n)=>c.read(t,e,n):void 0,editMessage:s?(e,n)=>s.send(t,e,n):void 0,forkAt:n=>{let r=[...i.getSnapshot().timeline.turns.values()].find(e=>e.end?.seq===n)?.data.get(`turn-tail`)?.closing?.finalNode.messageId;return e.sessions.fork({sessionId:t,atSeq:n,increaseTitle:!0,onCreated:n=>{e.get(`productAnalytics`)?.track(`branch_session_click`,{session_id:n,parent_session_id:t,...r===void 0?{}:{parent_message_id:r},click_position:`footer`})}}).then(t=>{e.uiWorkspace.openSession(t)})},openSession:t=>{let n=t;e.sessions.list.getSnapshot().byId[n]===void 0?e.sessions.loadSummary(n).catch(()=>void 0).finally(()=>{e.uiWorkspace.openSession(n)}):e.uiWorkspace.openSession(n)},loadModelCatalog:m?async()=>{let t=await e.remote.session.modelCatalog(void 0);if(!t.ok)throw Error(t.error.message);return t.value}:void 0,handoff:m?async({atSeq:n,targetHarnessId:r,targetModel:i,targetThinkingOptionId:a})=>{let o=(await u.handoff({sessionId:t,...n===void 0?{}:{atSeq:n},targetHarnessId:r,...i===void 0?{}:{targetModel:i},...a===void 0?{}:{targetThinkingOptionId:a}})).sessionId;e.sessions.list.getSnapshot().byId[o]===void 0&&await e.sessions.loadSummary(o).catch(()=>void 0),e.uiWorkspace.openSession(o)}:void 0}}},X_)),e.slots.inject(`shell.overlay`,()=>e.slots.register({name:`shell.overlay`,id:`chat.quota-notice`,locale:Q_,children:{"shell.quota-notice":{kind:`chain`,scope:`root`}},inject:()=>({hooks:{notice:t},dismissNotice:()=>{r.clear(),t.set(null)},keepNoticeOpen:()=>{if(t.getSnapshot()===null)return()=>{};let e=Symbol(`ui-chat quota notice hold`);return r.add(e),()=>{r.delete(e)}}})},BS)),e.slots.inject(`conversation.input.dock`,()=>e.slots.register({name:`conversation.input.dock`,id:`file-changes`,order:5,locale:Q_},ee)),e.slots.inject(`conversation.approval.detail`,()=>e.slots.register({name:`conversation.approval.detail`},fe))}return n.EMPTY_CHAT_SNAPSHOT=A,n.apply=IC,n.inject=FC,n.isRunningTool=Dy,n.isSettledTool=Ey,t.exports}});
|
|
129
|
+
`,n);if(o!==-1&&o<=a){let r=e.slice(n,o).trim();r!==``&&(t=r)}if(i===null)return t;n=i.index+i[0].length}}let Rv=(0,d.memo)(function({text:e,running:t,usePresentation:n,useDisclosure:r,t:i}){let{expanded:a,toggle:o}=r(),s=(0,d.useMemo)(()=>rm(i),[i]),c=t?Lv(e):Iv(e),l=(0,d.useMemo)(()=>c.replaceAll(`**`,``),[c]),u=n(e=>!a&&l!==``&&(t||e.settledReasoningPreview)),m=(0,d.useMemo)(()=>/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Pv.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Pv.summary,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:Pv.summaryText,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{children:l})})})]}),[t,l]),h=(0,d.useMemo)(()=>a?/* @__PURE__ */ (0,f.jsx)(`div`,{className:Pv.thinkBody,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:e,streaming:t,labels:s,variant:`compact`})}):void 0,[a,s,t,e]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Pv.root,"data-variant":`think`,"data-state":t?`running`:`ok`,"data-expanded":a||void 0,"data-preview":u||void 0,children:[t&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Zg.visuallyHidden,children:i(`row.running`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{rowClassName:Pv.row,leadingClassName:Pv.leading,titleClassName:Pv.title,icon:Fv,title:i(`message.think`),running:t,open:a,expandable:!0,expandOnRowClick:!0,onToggle:o,collapsedContent:m,children:h})]})}),zv=`@deepseek-ai/dsh-client-ui-chat/AssistantMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(zv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=zv,e.textContent=`.-BFQla_root{font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-primary);flex-direction:column;display:flex}.-BFQla_body{flex-direction:column;gap:16px;display:flex}.-BFQla_viewedImages{flex-direction:column;align-items:flex-start;gap:10px;display:flex}.-BFQla_viewedImagesToggle{min-height:24px;color:var(--dsw-alias-label-tertiary);font:inherit;cursor:pointer;background:0 0;border:none;align-items:center;gap:6px;padding:0;display:inline-flex}.-BFQla_viewedImagesToggle:hover{color:var(--dsw-alias-label-secondary)}.-BFQla_viewedImagesToggle:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-alias-state-business-primary);outline-offset:2px;border-radius:var(--dsw-radius-sm)}.-BFQla_viewedImagesIcon{flex:none;width:16px;height:16px;position:relative}.-BFQla_viewedImagesIcon:before,.-BFQla_viewedImagesIcon:after{content:"";border:1px solid;border-radius:3px;width:11px;height:9px;position:absolute}.-BFQla_viewedImagesIcon:before{top:2px;left:2px}.-BFQla_viewedImagesIcon:after{top:5px;left:5px}.-BFQla_viewedImagesChevron{flex:none;width:12px;height:12px}.-BFQla_body .md-table-wide{--dsh-table-viewport:calc(100cqw - 2 * var(--dsh-chat-scroll-pad-x,0px));--dsh-table-spare:max(0px, calc((var(--dsh-table-viewport) - var(--dsh-chat-content-width)) / 2));--dsh-table-lead:calc(var(--dsh-table-spare) + min(var(--dsh-chat-content-width), var(--dsh-table-viewport)) - 100%);box-sizing:border-box;width:calc(100% + var(--dsh-table-lead) + var(--dsh-table-spare));max-width:none;margin-left:calc(-1 * var(--dsh-table-lead));padding-left:var(--dsh-table-lead)}.-BFQla_body .md-table-wide>table{z-index:1;position:relative}.-BFQla_body>[data-turn-process-inline][hidden]{margin-bottom:-16px}.-BFQla_stopped{border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-tertiary);align-self:flex-start;padding:0 6px;font-size:11px;line-height:18px}.-BFQla_actions{margin-top:16px;margin-left:-6px}`,document.head.appendChild(e)}var Bv={actions:`-BFQla_actions`,body:`-BFQla_body`,root:`-BFQla_root`,stopped:`-BFQla_stopped`,viewedImages:`-BFQla_viewedImages`,viewedImagesChevron:`-BFQla_viewedImagesChevron`,viewedImagesIcon:`-BFQla_viewedImagesIcon`,viewedImagesToggle:`-BFQla_viewedImagesToggle`};function Vv({images:e,renderMessageImages:t,t:n}){let[r,i]=(0,d.useState)(!1),a=e.length===1?n(`message.imageViews.one`):n(`message.imageViews.many`,{count:e.length});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Bv.viewedImages,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Bv.viewedImagesToggle,"aria-expanded":r,onClick:()=>{i(e=>!e)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Bv.viewedImagesIcon,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:a}),r?/* @__PURE__ */ (0,f.jsx)(p.IconChevronUpOutlineRegular,{className:Bv.viewedImagesChevron}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:Bv.viewedImagesChevron})]}),r&&t({images:e,align:`start`})]})}function Hv(e,t,n){let r;try{r=decodeURIComponent(t.split(/[?#]/u)[0]??``)}catch{return}return n===void 0?ie(e,r):n(r)}let Uv=(0,d.memo)(function({blocks:e,streaming:t,interrupted:n,renderMessageImages:r,groupPart:i,useDisclosure:a,reasoningHidden:o=!1,usePresentation:s,revealProcess:c,mentions:l,responseAnnotations:u,t:m}){let h=(0,d.useMemo)(()=>rm(m),[m]),{fileImages:g}=(0,p.useMarkdownDelegate)(),_=(0,d.useMemo)(()=>({resolve:e=>Hv(document.baseURI,e,g?.resolve)}),[g]),v=e.length-1;if(!(t||n===!0||e.some(e=>e.kind!==`tool-call`)))return null;let y=[];for(let n=0;n<e.length;n++){let g=e[n];if(g!==void 0&&(i!==`reasoning`||g.kind===`reasoning`)&&(i!==`response`||g.kind!==`reasoning`))switch(g.kind){case`text`:y.push(/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:g.text,streaming:t,breaks:!0,labels:h,fileMentions:l,pathImages:_,responseAnnotations:u},n));break;case`reasoning`:y.push(/* @__PURE__ */ (0,f.jsx)(Wv,{hidden:o,reveal:c,children:/* @__PURE__ */ (0,f.jsx)(Rv,{text:g.text,running:t&&n===v,usePresentation:s,useDisclosure:a,t:m})},n));break;case`image`:{let t=n,i=[g];for(;n+1<e.length;){let t=e[n+1];if(t===void 0||t.kind!==`image`)break;i.push(t),n+=1}y.push(/* @__PURE__ */ (0,f.jsx)(d.Fragment,{children:r({images:i.map(({attachment:e})=>({attachment:e})),align:`start`})},t));break}case`viewed-images`:{let t=n,i=[g];for(;n+1<e.length;){let t=e[n+1];if(t===void 0||t.kind!==`viewed-images`)break;i.push(t),n+=1}y.push(/* @__PURE__ */ (0,f.jsx)(Vv,{images:i.map(({attachment:e})=>({attachment:e})),renderMessageImages:r,t:m},t));break}case`tool-call`:break;default:y.push(/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:m(`message.unknownBlock`),payload:g.block,truncatedLabel:e=>m(`json.truncated`,{total:e})},n))}}return/* @__PURE__ */ (0,f.jsx)(`div`,{className:Bv.root,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Bv.body,children:[y,n&&(i===void 0||i===`response`||!e.some(e=>e.kind!==`reasoning`&&e.kind!==`tool-call`))&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Bv.stopped,children:m(`message.stopped`)})]})})});function Wv({hidden:e,reveal:t,children:n}){let r=Mh(e,t??Gv);return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:r,"data-turn-process-inline":e||void 0,children:n})}let Gv=()=>{};function Kv(e,t){for(let n=e;n!==null&&n!==t;n=n.parentElement)if(n.classList.contains(Z_.annotationMark))return!0;return!1}function qv(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(let r=t.nextNode();r!==null;r=t.nextNode()){let t=r.parentElement;r.nodeValue&&t!==null&&t.closest(u_)===null&&!Kv(t,e)&&(n=r)}return n}function Jv(e){let t=e.ownerDocument.defaultView?.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return;let n=t.getRangeAt(0);if(!e.contains(n.startContainer)||e.contains(n.endContainer)||!(e.compareDocumentPosition(n.endContainer)&Node.DOCUMENT_POSITION_FOLLOWING)||(n.startContainer instanceof Element?n.startContainer:n.startContainer.parentElement)?.closest(u_)!=null)return;let r=qv(e);if(r===null)return;let i=n.cloneRange();i.setEnd(r,r.data.length),t.removeAllRanges(),t.addRange(i)}let Yv=(0,d.memo)(function({node:e,groupPart:t,useDisclosure:n,useTurnData:r,turnProcess:i,openFile:a,renderMessageImages:o,fileMentions:s,responseAnnotations:c,useInput:l,inputActions:u,usePresentation:p,t:m}){let h=e.data,g=(0,d.useRef)(null),_=JSON.stringify([e.key,t??null]),v=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,y=r(`turn-tail`),b=(0,d.useMemo)(()=>{if(v?.status===`closed`&&h.finalNode!==void 0&&y?.closing?.finalNode.seq===h.finalNode.seq)return{turn:v,seq:h.finalNode.seq,openFile:a}},[h.finalNode,a,y,v]),x=(0,d.useMemo)(()=>b===void 0?void 0:s(b),[s,b]),S=i!==void 0&&i.foldable&&i.spec.answerStep===h.step&&i.spec.inlineReasoning&&!i.open,C=(0,d.useCallback)(()=>{i?.setOpen(!0)},[i]),w=(0,d.useMemo)(()=>im(m),[m]),T=(0,d.useMemo)(()=>({labels:w,resolve:e=>c[e-1]}),[w,c]),E=(0,d.useCallback)(e=>{e.detail>=2&&g.current!==null&&Jv(g.current)},[]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:g,className:Z_.answer,"data-selection-answer":_,"data-selection-answer-streaming":h.status===`running`||void 0,onClick:E,children:[/* @__PURE__ */ (0,f.jsx)(Uv,{blocks:h.blocks,groupPart:t,useDisclosure:n,streaming:h.status===`running`,interrupted:h.status===`interrupted`,renderMessageImages:o,reasoningHidden:S,usePresentation:p,revealProcess:C,mentions:x,responseAnnotations:T,t:m}),h.status!==`running`&&/* @__PURE__ */ (0,f.jsx)(nv,{answer:g,answerKey:_,useInput:l,inputActions:u,labels:w})]})}),Xv=`@deepseek-ai/dsh-client-ui-chat/GenericCommandCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Xv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Xv,e.textContent=`.lHK2Ya_root{flex-direction:column;display:flex}.lHK2Ya_leading{flex-shrink:0}.lHK2Ya_title{font-weight:400}.lHK2Ya_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.lHK2Ya_summary{min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.lHK2Ya_summary[data-error],.lHK2Ya_body[data-error]{color:var(--dsw-alias-state-error-primary)}.lHK2Ya_body{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-markdown-code-block);max-height:260px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-markdown-code-block-small);white-space:pre-wrap;margin:4px 0 4px 4px;padding:12px 16px;overflow:auto}`,document.head.appendChild(e)}var Zv={body:`lHK2Ya_body`,leading:`lHK2Ya_leading`,root:`lHK2Ya_root`,separator:`lHK2Ya_separator`,summary:`lHK2Ya_summary`,title:`lHK2Ya_title`};let Qv=/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{size:14});function $v(e){return e===null?`running`:e.kind===`error`?`error`:`ok`}let ey=(0,d.memo)(function({node:e,t,runningSummary:n,successSummary:r}){let[i,a]=(0,d.useState)(!1),o=e.outcome?.text,s=e.outcome===null?n??t(`command.running`):o??(e.outcome.kind===`error`?t(`command.failed`):r??t(`command.done`)),c=e.name??t(`command.title`),l=$v(e.outcome),u=l===`running`,m=o!==void 0&&o.includes(`
|
|
130
|
+
`)?o:null,h=i&&m!==null,g=(0,d.useCallback)(()=>{a(e=>!e)},[]),_=(0,d.useMemo)(()=>/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Zv.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Zv.summary,"data-error":l===`error`||void 0,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{children:s})})]}),[u,l,s]),v=(0,d.useMemo)(()=>h?/* @__PURE__ */ (0,f.jsx)(`pre`,{className:Zv.body,"data-error":l===`error`||void 0,children:m}):void 0,[m,h,l]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Zv.root,"data-variant":`others`,"data-command":e.name??void 0,"data-state":l,children:[l===`running`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Zg.visuallyHidden,children:t(`row.running`)}),l===`error`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Zg.visuallyHidden,children:t(`row.failed`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{leadingClassName:Zv.leading,titleClassName:Zv.title,icon:Qv,title:c,running:u,open:h,expandable:m!==null,expandOnRowClick:!0,keepContentWhenOpen:!0,onToggle:g,collapsedContent:_,children:v})]})});function ty({node:e,compaction:t,t:n}){return t===void 0?/* @__PURE__ */ (0,f.jsx)(ey,{node:e,t:n,runningSummary:n(`message.compaction.running`),successSummary:n(`message.compaction`)}):/* @__PURE__ */ (0,f.jsx)(dm,{node:t,title:n(`message.compaction.commandTitle`),fallbackSummary:e.outcome?.text??null,t:n})}let ny=(0,d.memo)(function({node:e,renderSlot:t,t:n}){let r=e.data,i=(0,d.useMemo)(()=>({node:r}),[r]);return/* @__PURE__ */ (0,f.jsx)(`div`,{className:Rh.callRow,children:t(`conversation.chat.commandview`,i,{entryKey:r.name??``,fallback:/* @__PURE__ */ (0,f.jsx)(ey,{...i,t:n})})})}),ry=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:Rh.callRow,children:/* @__PURE__ */ (0,f.jsx)(ty,{node:n.command,...n.compaction===null?{}:{compaction:n.compaction},t})})});function iy({text:e,update:t=!1,t:n}){let[r,i]=(0,d.useState)(!1);return/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{className:Rm.root,icon:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),chevronClassName:Rm.chevron,title:n(t?`message.systemPromptUpdate`:`message.systemPrompt`),open:r,expandable:!0,expandOnRowClick:!0,onToggle:()=>{i(e=>!e)},children:/* @__PURE__ */ (0,f.jsx)(`div`,{className:Rm.body,"data-system-prompt-body":!0,children:/* @__PURE__ */ (0,f.jsx)(Sm,{content:[{type:`text`,text:e}],source:null,t:n})})})}let ay=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(iy,{text:e.data.text,update:e.data.update===!0,t})}),oy=`@deepseek-ai/dsh-client-ui-chat/TurnProcessNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(oy)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=oy,e.textContent=`.NsInEG_root{box-sizing:border-box;width:100%;min-width:0;height:calc(33px + var(--dsh-content-font-delta,0px));border:none;border-bottom:.5px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size,14px);cursor:pointer;text-align:left;background:0 0;align-items:center;padding:0 0 8px;transition:color .1s;display:flex}.NsInEG_root:disabled{cursor:default}@media (hover:hover){.NsInEG_root:hover:not(:disabled){color:var(--dsw-alias-label-secondary)}}.NsInEG_root:active:not(:disabled){color:var(--dsw-alias-label-secondary)}.NsInEG_chevron{width:14px;height:14px;color:inherit;flex:none;margin-left:4px;transition:transform .1s}.NsInEG_root[data-open] .NsInEG_chevron{transform:rotate(180deg)}.NsInEG_label{min-width:0;font-size:inherit;line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.NsInEG_durationNumber{font-family:var(--ds-font-family-code);font-variant-numeric:tabular-nums}@media (prefers-reduced-motion:reduce){.NsInEG_root,.NsInEG_chevron{transition:none}}`,document.head.appendChild(e)}var sy={chevron:`NsInEG_chevron`,durationNumber:`NsInEG_durationNumber`,label:`NsInEG_label`,root:`NsInEG_root`};let cy=(0,d.memo)(function({node:e,turnProcess:t,t:n}){if(t===void 0)throw Error(`turn-process node requires Turn process owner state`);let r=!t.foldable||t.open,i=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0;if(i?.status!==`closed`)return null;let a=t.foldable&&t.hasContent&&!Th(e),o=i.end?.data.reason.kind,s=i.start===void 0||i.end===void 0||i.end.time<=i.start.time?void 0:Math.max(1e3,i.end.time-i.start.time),c=s===void 0||o===`aborted`||o===`error`||o===`unknown`?void 0:Um(s,n),l=n(o===`unknown`?`message.turnProcess.unknown`:o===`aborted`?`message.stopped`:o===`error`?`message.turnProcess.failed`:c===void 0?`message.turnProcess.worked`:`message.turnProcess.took`),u=n(o===`unknown`?`message.turnProcess.unknown`:o===`aborted`?`message.stopped`:o===`error`?`message.turnProcess.failed`:`message.turnProcess.worked`);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Zg.visuallyHidden,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:u}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:sy.root,"data-open":r||void 0,"data-turn-process":e.data.turn,"data-turn-process-messages":e.data.messageCount,"data-turn-process-tool-calls":e.data.toolCallCount,"data-turn-process-subagents":e.data.subagentCount,disabled:!a,"aria-expanded":t.hasContent?r:void 0,onClick:e=>{e.currentTarget.focus(),t.setOpen(!r)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:sy.label,children:[l,c?.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(`span`,{className:e.numeric?sy.durationNumber:void 0,children:e.text},t))]}),a&&/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:sy.chevron})]})]})});function ly(e,t,n,r){let[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(),[c,l]=(0,d.useState)(0),u=JSON.stringify(t.filter(e=>n.has(e.path)&&e.hunks===void 0).map(e=>[e.path,e.revision]));return(0,d.useEffect)(()=>{let t=JSON.parse(u).filter(([e,t])=>i[e]?.revision!==t);if(!r||t.length===0)return;let n=!0;return s(void 0),Promise.all(t.map(async([t,n])=>[t,{revision:n,diffs:(await r(e,t)).filter(e=>e.path===t)}])).then(e=>{n&&a(t=>({...t,...Object.fromEntries(e)}))},e=>{n&&s(e instanceof Error?e.message:String(e))}),()=>{n=!1}},[e,u,r,i,c]),{diffs:e=>e.hunks??(i[e.path]?.revision===e.revision?i[e.path]?.diffs:void 0),error:o,retry:()=>l(e=>e+1)}}let uy=`@deepseek-ai/dsh-client-ui-chat/TurnChangesCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(uy)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=uy,e.textContent=`.U56YlW_card{border:1px solid var(--dsw-alias-border-l2);corner-shape:round;color:var(--dsw-alias-label-primary);font-size:calc(var(--dsh-content-font-size-secondary,13px) + 2px);--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) + 1px);--dsw-alias-state-success-primary:var(--dsw-alias-file-diff-added-marker);--dsw-alias-state-error-primary:var(--dsw-alias-file-diff-deleted-marker);border-radius:12px;margin:8px 0;line-height:20px;overflow:hidden}.U56YlW_header{-webkit-user-select:none;user-select:none;align-items:center;gap:12px;padding:12px;display:flex}.U56YlW_icon{corner-shape:round;background:color-mix(in srgb, var(--dsw-alias-label-primary) 4%, transparent);width:44px;height:44px;color:var(--dsw-alias-label-secondary);border-radius:12px;flex:none;place-items:center;display:grid}.U56YlW_text{flex-direction:column;flex:auto;gap:2px;min-width:0;display:flex}.U56YlW_title{text-overflow:ellipsis;white-space:nowrap;font-weight:600;overflow:hidden}.U56YlW_titleLink{max-width:100%;color:inherit;font-family:inherit;font-size:inherit;line-height:inherit;text-align:left;cursor:pointer;background:0 0;border:0;align-self:flex-start;margin:0;padding:0}.U56YlW_review,.U56YlW_fileHead,.U56YlW_openFile,.U56YlW_more{color:inherit;font:inherit;text-align:left;cursor:pointer;-webkit-user-select:none;user-select:none;background:0 0;border:0}.U56YlW_review{border:1px solid var(--dsw-alias-border-l2);corner-shape:round;font-size:var(--dsh-content-font-size,14px);white-space:nowrap;border-radius:12px;flex:none;padding:4px 8px;font-weight:500}@media (hover:hover){.U56YlW_review:hover,.U56YlW_fileHead:hover,.U56YlW_openFile:hover,.U56YlW_more:hover{background:var(--dsw-alias-interactive-bg-hover)}.U56YlW_titleLink:hover{text-underline-offset:3px;text-decoration:underline}}.U56YlW_review:active,.U56YlW_fileHead:active,.U56YlW_openFile:active,.U56YlW_more:active{background:var(--dsw-alias-interactive-bg-hover)}.U56YlW_review:focus-visible,.U56YlW_fileHead:focus-visible,.U56YlW_openFile:focus-visible,.U56YlW_more:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:-2px}.U56YlW_titleLink:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:2px}.U56YlW_files{border-top:1px solid var(--dsw-alias-border-l2);margin:0;padding:0;list-style:none}.U56YlW_fileRow{align-items:center;display:flex}.U56YlW_fileRow .U56YlW_fileHead{flex:auto;min-width:0}.U56YlW_openFile{corner-shape:round;width:28px;height:28px;color:var(--dsw-alias-label-secondary);border-radius:8px;flex:none;place-items:center;margin-right:8px;padding:0;display:grid}.U56YlW_fileHead{justify-content:space-between;align-items:center;gap:12px;width:100%;min-height:40px;padding:8px 12px;display:flex}.U56YlW_fileHead .U56YlW_path{min-width:0;font-size:inherit;--dsw-alias-label-tertiary:var(--dsw-alias-label-secondary);flex:1}.U56YlW_diff{padding:0 12px 12px}.U56YlW_file:first-child .U56YlW_diff:first-child{padding-top:12px}.U56YlW_more{align-items:center;gap:8px;width:100%;min-height:40px;padding:8px 12px;font-weight:500;display:flex}.U56YlW_mobileChevron,.U56YlW_mobileFileIcon,.U56YlW_mobilePath,.U56YlW_mobileFullPath{display:none}.U56YlW_chevron{flex:none;transition:transform .15s}.U56YlW_chevron[data-open=true]{transform:rotate(180deg)}@media (width<=480px){.U56YlW_header{grid-template-columns:36px minmax(0,1fr);gap:8px;display:grid}.U56YlW_icon{width:36px;height:36px}.U56YlW_review{grid-column:2;justify-self:start}}[data-phone] .U56YlW_card{-webkit-text-size-adjust:100%;text-size-adjust:100%;min-width:0;max-width:100%;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);--dsh-diff-inline-padding:12px;--dsh-diff-body-padding:4px 0 8px}[data-phone] .U56YlW_header{grid-template-columns:20px minmax(0,1fr) 44px;gap:8px;min-height:52px;padding:0 4px 0 12px;display:grid}[data-phone] .U56YlW_icon{background:0 0;border-radius:0;width:20px;height:20px}[data-phone] .U56YlW_icon>svg{width:16px;height:16px}[data-phone] .U56YlW_text{flex-direction:row;align-items:center;gap:8px}[data-phone] .U56YlW_title{flex:auto;min-width:0;font-weight:500}[data-phone] .U56YlW_review{border-radius:var(--dsw-radius-sm);border:0;grid-column:auto;justify-self:stretch;place-items:center;width:44px;height:44px;padding:0;display:grid}[data-phone] .U56YlW_reviewLabel{display:none}[data-phone] .U56YlW_mobileChevron,[data-phone] .U56YlW_mobileFileIcon{color:var(--dsw-alias-label-secondary);flex:none;display:block}[data-phone] .U56YlW_mobileChevron{transition:transform .15s}[data-phone] .U56YlW_mobileChevron[data-open=true]{transform:rotate(180deg)}[data-phone] .U56YlW_fileHead,[data-phone] .U56YlW_more{gap:8px;min-height:44px;padding:0 12px}[data-phone] .U56YlW_titleLink{align-self:center;min-height:44px}[data-phone] .U56YlW_openFile{border-radius:var(--dsw-radius-sm);width:44px;height:44px;margin-right:0}[data-phone] .U56YlW_file+.U56YlW_file{border-top:1px solid var(--dsw-alias-border-l2)}[data-phone] .U56YlW_path{display:none}[data-phone] .U56YlW_mobilePath{flex-direction:column;flex:1;min-width:0;padding-block:4px;display:flex}[data-phone] .U56YlW_fileName{text-overflow:ellipsis;white-space:nowrap;font-weight:500;overflow:hidden}[data-phone] .U56YlW_directory,[data-phone] .U56YlW_mobileFullPath{color:var(--dsw-alias-label-secondary);font-size:calc(11px + var(--dsh-content-font-delta-secondary,0px));line-height:calc(16px + var(--dsh-content-font-delta-secondary,0px));white-space:normal;overflow-wrap:anywhere}[data-phone] .U56YlW_mobileFullPath{user-select:text;padding:4px 12px;display:block}[data-phone] .U56YlW_diff,[data-phone] .U56YlW_file:first-child .U56YlW_diff:first-child{padding:0}[data-phone] .U56YlW_diffStatus{overflow-wrap:anywhere;padding:12px;display:block}[data-phone] .U56YlW_diffStatus button{min-width:44px;min-height:44px}[data-phone] .U56YlW_inlineDiff{border-radius:0;min-width:0;max-width:100%;margin:0}[data-phone] .U56YlW_inlineDiff [data-diff-body]{box-sizing:border-box;-webkit-text-size-adjust:100%;text-size-adjust:100%;width:100%;min-width:0;font-size:calc(var(--dsw-font-markdown-code-block-font-size,11px) + var(--dsh-content-font-delta,0px));line-height:calc(var(--dsw-font-markdown-code-block-line-height,19px) + var(--dsh-content-font-delta,0px));tab-size:2;overscroll-behavior-x:contain}[data-phone] .U56YlW_inlineDiff [data-diff-row=path]{display:none}[data-phone] .U56YlW_inlineDiff [data-code-block-banner]{gap:8px;min-height:44px;padding:0 8px 0 12px}[data-phone] .U56YlW_inlineDiff [data-code-block-banner] button{width:44px;height:44px}@media (prefers-reduced-motion:reduce){[data-phone] .U56YlW_mobileChevron{transition:none}}`,document.head.appendChild(e)}var Z={card:`U56YlW_card`,chevron:`U56YlW_chevron`,diff:`U56YlW_diff`,diffStatus:`U56YlW_diffStatus`,directory:`U56YlW_directory`,file:`U56YlW_file`,fileHead:`U56YlW_fileHead`,fileName:`U56YlW_fileName`,fileRow:`U56YlW_fileRow`,files:`U56YlW_files`,header:`U56YlW_header`,icon:`U56YlW_icon`,inlineDiff:`U56YlW_inlineDiff`,mobileChevron:`U56YlW_mobileChevron`,mobileFileIcon:`U56YlW_mobileFileIcon`,mobileFullPath:`U56YlW_mobileFullPath`,mobilePath:`U56YlW_mobilePath`,more:`U56YlW_more`,openFile:`U56YlW_openFile`,path:`U56YlW_path`,review:`U56YlW_review`,reviewLabel:`U56YlW_reviewLabel`,text:`U56YlW_text`,title:`U56YlW_title`,titleLink:`U56YlW_titleLink`};let dy=(0,d.memo)(function({nodeStore:e,turn:t,t:n,useProjection:r,loadTurnDiffs:i,openFile:a}){let o=S(e,t,r),s=(0,d.useMemo)(()=>{let e=/* @__PURE__ */ new Map;for(let t of o){let n=w(t.path);e.set(n,(e.get(n)??0)+1)}return e},[o]),[c,l]=(0,d.useState)(()=>/* @__PURE__ */ new Set),[u,m]=(0,d.useState)(!1),h=ly(t,o,c,i),g=(0,d.useMemo)(()=>({codeLabel:n(`diff.code`),wrapLabel:n(`diff.wrap`),unwrapLabel:n(`diff.unwrap`),copy:n(`diff.copy`),copied:n(`diff.copied`),collapseAria:n(`diff.collapseAria`),expandAria:e=>n(`diff.expandAria`,{count:e}),collapse:n(`diff.collapse`),expand:e=>n(`diff.expand`,{count:e})}),[n]);if(o.length===0)return null;let{added:_,removed:y}=C(o),[b]=o,x=o.length===1&&b!==void 0?n(`chat.fileEdited`,{name:w(b.path)}):n(`chat.filesEdited`,{count:o.length}),T=o.some(e=>c.has(e.path)),E=u?o:o.slice(0,3),D=o.length-E.length;return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:Z.card,"data-turn-changes":t,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.header,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.icon,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(p.IconFileDiffOutlineRegular,{size:24})}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Z.text,children:[o.length===1&&b!==void 0&&a!==void 0?/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:`${Z.title} ${Z.titleLink}`,title:n(`chat.openFile`,{path:b.path}),onClick:()=>a(b.path),children:x}):/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.title,title:x,children:x}),/* @__PURE__ */ (0,f.jsx)(v,{added:_,removed:y})]}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.review,"aria-expanded":T,"aria-label":n(T?`chat.hideChanges`:`chat.viewChanges`),onClick:()=>{l(new Set(T?[]:o.map(e=>e.path))),T||m(!0)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.reviewLabel,children:n(T?`chat.hideChanges`:`chat.viewChanges`)}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.mobileChevron,"data-open":T})]})]}),(o.length>1||T)&&/* @__PURE__ */ (0,f.jsxs)(`ul`,{className:Z.files,children:[E.map(e=>{let t=h.diffs(e),r=w(e.path);return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Z.file,children:[o.length>1&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.fileRow,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.fileHead,"aria-expanded":c.has(e.path),onClick:()=>{l(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n})},children:[/* @__PURE__ */ (0,f.jsx)(p.IconFileDiffOutlineRegular,{size:16,className:Z.mobileFileIcon}),/* @__PURE__ */ (0,f.jsx)(p.PathLabel,{path:e.path,className:Z.path}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Z.mobilePath,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.fileName,"aria-hidden":`true`,children:r}),(s.get(r)??0)>1&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.directory,"aria-hidden":`true`,children:e.path.slice(0,e.path.length-r.length)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Zg.visuallyHidden,children:e.path})]}),/* @__PURE__ */ (0,f.jsx)(v,{added:e.added,removed:e.removed}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.mobileChevron,"data-open":c.has(e.path)})]}),a!==void 0&&/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Z.openFile,"aria-label":n(`chat.openFile`,{path:e.path}),title:n(`chat.openFile`,{path:e.path}),onClick:()=>a(e.path),children:/* @__PURE__ */ (0,f.jsx)(p.IconRightUpOutlineRegular,{size:16})})]}),c.has(e.path)&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.diff,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Z.mobileFullPath,children:e.path}),t===void 0?h.error?/* @__PURE__ */ (0,f.jsxs)(`div`,{role:`alert`,className:Z.diffStatus,children:[h.error,` `,/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,onClick:h.retry,children:n(`chat.retryDiff`)})]}):/* @__PURE__ */ (0,f.jsx)(`span`,{role:`status`,className:Z.diffStatus,children:n(`chat.loadingDiff`)}):/* @__PURE__ */ (0,f.jsx)(p.DiffBlock,{diffs:[...t],labels:g,maxLines:1/0,className:Z.inlineDiff})]})]},e.path)}),o.length>3&&/* @__PURE__ */ (0,f.jsx)(`li`,{children:/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.more,"aria-expanded":u,onClick:()=>m(e=>!e),children:[D>0?n(`chat.showMoreFiles`,{count:D}):n(`chat.collapseFiles`),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.chevron,"data-open":u})]})})]})]})});function fy(e){return e.flatMap(e=>e.kind===`text`?[e.text]:[]).join(``)}function py(e){return e.some(e=>e.kind===`reasoning`||e.kind===`tool-call`?!1:e.kind!==`text`||e.text.trim()!==``)}let my=`@deepseek-ai/dsh-client-ui-chat/TurnTailNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(my)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=my,e.textContent=`.zJ_1ta_root{flex-direction:column;gap:16px;display:flex}.zJ_1ta_actions{margin-top:4px;margin-left:-6px}`,document.head.appendChild(e)}var hy={actions:`zJ_1ta_actions`,root:`zJ_1ta_root`};function gy(e,t,n){let r=e.locations.getTurn(t);for(let t=r.length-1;t>=0;t--){let i=e.nodes.get(r[t]);if(!(i===void 0||i.kind===`turn-tail`||i.kind===`turn-process`||n&&i.kind===`turn-max-tokens`))return i}}let _y=(0,d.memo)(function({node:e,openFile:t,forkAt:n,handoffAt:r,loadTurnDiffs:i,renderSlot:a,t:o,useChat:s,useSession:c,useProjection:l}){let u=c(e=>e.openState===`open`),p=(0,d.useRef)(!1),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(),v=e.data,y=s(e=>e.nodes),b=s(e=>(gy(e,v.turn,!0)?.anchorSeq??-1)>(v.closing?.finalNode.seq??v.seq)),x=s(e=>{if(e.timeline.turnOrder.at(-1)!==v.turn)return!1;let t=gy(e,v.turn,!1),n=t?.kind===`assistant-step`?t.data.blocks.findLast(e=>e.kind!==`text`&&e.kind!==`reasoning`||e.text.trim()!==``):void 0;return n!==void 0&&py([n])}),S=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,C=$m(l,S?.turn,`end`);if(S===void 0)return null;let w=v.closing,T=a(`conversation.chat.turnTail`,{turn:S,seq:w?.finalNode.seq??v.seq,openFile:t});if(w===null)return T===null?null:/* @__PURE__ */ (0,f.jsx)(`div`,{className:hy.root,"data-turn-tail":v.turn,children:T});let E=w.finalNode.messageId,D=E===void 0?null:a(`conversation.chat.assistant-actions`,{messageId:E});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:hy.root,"data-turn-tail":v.turn,"data-actions-reveal":x?`always`:`hover`,children:[/* @__PURE__ */ (0,f.jsx)(dy,{nodeStore:y,turn:v.turn,t:o,useProjection:l,loadTurnDiffs:i,openFile:t}),T,/* @__PURE__ */ (0,f.jsx)(Qm,{text:fy(w.blocks),time:C,clock:`end`,onBranch:()=>{!p.current&&u&&(p.current=!0,h(!0),_(void 0),n(v.seq).catch(e=>{_(e instanceof Error?e.message:String(e))}).finally(()=>{p.current=!1,h(!1)}))},branchUnavailable:!u||m||v.branchUnavailable||b,onHandoff:r===void 0?void 0:()=>{u&&r(v.seq)},handoffUnavailable:!u||v.branchUnavailable||b,className:hy.actions,extraActions:D,t:o}),g!==void 0&&/* @__PURE__ */ (0,f.jsx)(`p`,{role:`alert`,children:o(`message.branchFailed`,{message:g})})]})});function vy(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function yy(e,t){return typeof e[t]==`string`?e[t]:``}function by(e){let t=vy(e.source),n=yy(t,`kind`),r=`message.trigger.request`,i=`request`;switch(n){case`goal`:r=`message.trigger.goal`,i=`goal`;break;case`agent-message`:r=`message.trigger.agent`,i=`agent`;break;case`team-message`:r=`message.trigger.team`,i=`team`;break;case`subagent-settled`:r=`message.trigger.subagent`,i=`subagent`;break;case`webhook`:{let e=yy(t,`provider`)===`github`;r=e?`message.trigger.github`:`message.trigger.webhook`,i=e?`github`:`webhook`;break}case`schedule`:r=`message.trigger.schedule`,i=`schedule`;break;case`tool-jobs`:r=`message.trigger.job`,i=`job`;break;case`cordis-host-runner`:r=`message.trigger.plugin`,i=`plugin`}return{title:r,icon:i}}let xy=`@deepseek-ai/dsh-client-ui-chat/TurnTriggerNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(xy)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=xy,e.textContent=`.kkOUVW_root{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-xl);background:var(--dsw-alias-turn-trigger-bg,var(--dsw-alias-markdown-code-block));min-width:0;transition:background-color .1s}@media (hover:hover){.kkOUVW_root:hover{background:var(--dsw-alias-turn-trigger-bg-hover,var(--dsw-alias-interactive-bg-hover))}}.kkOUVW_header{width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:10px;padding:12px 16px;transition:color .1s;display:flex}@media (hover:hover){.kkOUVW_header:hover{color:var(--dsw-alias-label-secondary)}}.kkOUVW_header:active{color:var(--dsw-alias-label-secondary)}.kkOUVW_icon{color:inherit;flex:none;display:inline-flex}.kkOUVW_title{font-size:var(--dsh-content-font-size,14px);flex:none}.kkOUVW_time{color:inherit;font:var(--dsw-font-xxs-12);flex:none;margin-left:auto}.kkOUVW_chevron,.kkOUVW_openChevron{color:inherit;flex:none}.kkOUVW_openChevron{transform:rotate(180deg)}.kkOUVW_body{padding:0 16px 12px 40px}.kkOUVW_explanation{color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xxs-12);margin:8px 0}.kkOUVW_content{white-space:pre-wrap;overflow-wrap:anywhere;max-height:240px;font:var(--dsw-font-xxs-12);overflow:auto}@media (prefers-reduced-motion:reduce){.kkOUVW_root,.kkOUVW_header{transition:none}}`,document.head.appendChild(e)}var Sy={body:`kkOUVW_body`,chevron:`kkOUVW_chevron`,content:`kkOUVW_content`,explanation:`kkOUVW_explanation`,header:`kkOUVW_header`,icon:`kkOUVW_icon`,openChevron:`kkOUVW_openChevron`,root:`kkOUVW_root`,time:`kkOUVW_time`,title:`kkOUVW_title`};let Cy={request:p.IconContextInjectionOutlineRegular,goal:p.IconGoalOutlineRegular,agent:p.IconPaperPlaneOutlineRegular,team:p.IconAgentPresetOutlineRegular,subagent:p.IconAgentPresetOutlineRegular,github:p.IconBranchOutlineRegular,webhook:p.IconGlobeOutlineRegular,schedule:p.IconClockOutlineRegular,job:p.IconQueueOutlineRegular,plugin:p.IconCordisPluginOutlineRegular};function wy({node:e,t}){let[n,r]=(0,d.useState)(!1),i=(0,d.useId)(),a=by(e.data),o=Cy[a.icon],s=new Date(e.data.time),c=Wm(e.data.time,t);return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:Sy.root,"data-turn-trigger":!0,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{className:Sy.header,type:`button`,"aria-expanded":n,"aria-controls":i,onClick:()=>{r(!n)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Sy.icon,"aria-hidden":!0,children:/* @__PURE__ */ (0,f.jsx)(o,{size:14})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Sy.title,children:t(a.title)}),/* @__PURE__ */ (0,f.jsx)(`time`,{className:Sy.time,dateTime:s.toISOString(),children:c}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:12,className:n?Sy.openChevron:Sy.chevron})]}),n&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:i,className:Sy.body,children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:Sy.explanation,children:t(`message.trigger.explanation`)}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:Sy.content,children:/* @__PURE__ */ (0,f.jsx)(Am,{content:e.data.content,source:e.data.source,t})})]})]})}function Ty(e,t){e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`user`,locale:Av,inject:()=>({links:e.get(`chatLinks`)})},ph)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`steering`,locale:Av,inject:()=>({links:e.get(`chatLinks`)})},ph)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`context`,locale:Av},hh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-trigger`,locale:Av},wy)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`system-prompt`,locale:Av},ay)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`assistant-step`,locale:Av,inject:()=>({hooks:{presentation:t}})},Yv)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`command`,locale:Av,children:{"conversation.chat.commandview":{kind:`keyed`,scope:`session`}}},ny)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`manual-compaction`,locale:Av},ry)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`compaction`,locale:Av},gh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`model-retry`,locale:Av},_h)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-error`,locale:Av},vh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-max-tokens`,locale:Av},yh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-process`,locale:Av},cy)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-tail`,locale:Av,children:{"conversation.chat.turnTail":{kind:`list`,scope:`session`},"conversation.chat.assistant-actions":{kind:`list`,scope:`session`}}},_y)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`unknown`,locale:Av},bh))}let Ey={interruptedAssistant:-.9,interruptedFollowup:-.8,processControl:-.1,maxTokensNotice:.05,finalizedFollowup:.1};function Dy(e){return e.start?.location??e.matches[0]?.location??{kind:`unresolved`}}function Oy(e,t,n,r,i={}){return{key:e.key,kind:t,id:e.id,target:`chat`,anchorSeq:n,location:i.location??Dy(e),visibility:i.visibility??`visible`,data:r}}function ky(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Ay(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function jy(e,t,n){let r=e[t];if(!Array.isArray(r))return[];let i=[];for(let e of r){let t=ky(e),r=t===null?null:Ay(t,n);r!==null&&!i.includes(r)&&i.push(r)}return i}function My(e){return e.length>0?e.join(`, `):null}let Ny=[`instructions`,`catalog`,`snapshot`,`notice`,`relay`,`recall`];function Py(e){let t=ky(e),n=t===null?null:Ay(t,`form`);return n!==null&&Ny.includes(n)?n:null}function Fy(e){let t=ky(e),n=t===null?null:Ay(t,`kind`);if(t===null||n===null)return{role:`inject`,label:null};switch(n){case`session-reference`:return{role:`recall`,label:My(jy(t,`references`,`label`))??n};case`agent-instructions`:return{role:`inject`,label:My(jy(t,`changes`,`path`))??n};case`skill-invocation`:return{role:`inject`,label:Ay(t,`name`)??n};default:return{role:`inject`,label:n}}}function Iy(e){let t=ky(e);return t===null||Ay(t,`kind`)!==`session-reference`?[]:jy(t,`references`,`label`)}function Ly(e){let t=ky(e);return t===null||Ay(t,`kind`)!==`skill-invocation`?null:Ay(t,`name`)}function Ry(e){return e.map(zy)}function zy(e){switch(e.type){case`text`:return{kind:`text`,text:e.text};case`reasoning`:return{kind:`reasoning`,text:e.text};case`image`:return e.codexhostImageView===!0?{kind:`viewed-images`,attachment:e.attachment}:{kind:`image`,attachment:e.attachment};case`tool-call`:return{kind:`tool-call`,callId:String(e.id),name:e.name,argsRaw:e.arguments};default:return{kind:`other`,block:e}}}function By(e){switch(e){case`text`:return{kind:`text`,text:``};case`reasoning`:return{kind:`reasoning`,text:``};case`tool-call`:return{kind:`tool-call`,callId:``,name:``,argsRaw:``};default:return{kind:`other`,block:null}}}function Vy(e){if(typeof e!=`object`||!e)return{message:String(e)};let t=e,n=typeof t.code==`string`?t.code:void 0;return n===`AUTH`?{code:n,message:``}:{...n===void 0?{}:{code:n},message:typeof t.message==`string`?t.message:JSON.stringify(e)}}function Hy(e){switch(e.type){case`text-delta`:case`reasoning-delta`:return e.text!==``;case`tool-call-delta`:return e.argumentsDelta!==``||e.name!==void 0;default:return!1}}function Uy(e,t){return{turn:e,step:t,blocks:[],visibleByIndex:[],visibleBlocks:0,firstVisibleSeq:void 0,firstVisibleTime:void 0,firstTokenTime:void 0,final:void 0,usage:void 0}}function Wy(e){return e.filter(e=>e!==void 0)}function Gy(e){return e===void 0||e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0}function Ky(e){return e.some(Gy)}function qy(e){return e.some(e=>e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function Jy(e){return{...Uy(e.turn,e.step),firstTokenTime:e.firstTokenTime}}function Yy(e,t,n,r){if(t.type===`tool-call-delta`){let n=e.blocks[t.index];if(n?.kind===`tool-call`&&n.callId!==``&&(t.name===void 0||t.name===n.name)&&(e.firstTokenTime!==void 0||!Hy(t)))return e}let i=[...e.blocks],a=-1,o=!1,s=!1;switch(t.type){case`block-start`:a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]=By(t.blockType),s=Gy(i[t.index]);break;case`text-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`text`,text:(n?.kind===`text`?n.text:``)+t.text},s=n?.kind===`text`&&o||t.text.trim()!==``;break}case`reasoning-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`reasoning`,text:(n?.kind===`reasoning`?n.text:``)+t.text},s=n?.kind===`reasoning`&&o||t.text.trim()!==``;break}case`tool-call-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`tool-call`,callId:(n?.kind===`tool-call`?n.callId:``)||String(t.id),name:t.name??(n?.kind===`tool-call`?n.name:``),argsRaw:n?.kind===`tool-call`?n.argsRaw:``};break}case`block-end`:a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]=zy(t.block),s=Gy(i[t.index]);break;case`usage`:return{...e,usage:t.usage};default:return e}let c=e.visibleBlocks-Number(o)+Number(s),l=e.visibleByIndex;if(o!==s){let e=[...l];e[a]=s,l=e}let u=Hy(t);return{...e,blocks:i,visibleByIndex:l,visibleBlocks:c,...c>0&&e.firstVisibleSeq===void 0?{firstVisibleSeq:n,firstVisibleTime:r}:{},...u&&e.firstTokenTime===void 0?{firstTokenTime:r}:{}}}function Xy(e,t,n){let r=Ry(n.data.message.content),i=r.map(Gy);return{...e,blocks:r,visibleByIndex:i,visibleBlocks:i.reduce((e,t)=>e+Number(t),0),final:t,usage:n.data.usage}}function Zy(e){if(e.kind===`step`&&e.step.status===`closed`&&e.step.end!==void 0)return e.step.end;if((e.kind===`step`||e.kind===`turn`)&&e.turn.status===`closed`&&e.turn.end!==void 0)return e.turn.end}function Qy(e,t){let n=e.final;if(n?.event.type===`assistant/message`){let r=n.event;return{kind:`assistant`,seq:r.seq,messageId:r.data.message.id,time:r.time,turn:e.turn,step:e.step,blocks:Ry(r.data.message.content),usage:r.data.usage,timing:{stepStartTime:t.start?.event.time??null,firstTokenTime:e.firstTokenTime??null,completedTime:r.time},...r.data.interrupted===!0?{interrupted:!0}:{}}}let r=t.start?.location??t.matches.at(-1)?.location,i=r===void 0?void 0:Zy(r);if(i===void 0)return;let a=Wy(e.blocks);if(qy(a))return{kind:`assistant`,seq:i.seq+Ey.interruptedAssistant,time:i.time,turn:e.turn,step:e.step,blocks:a,interrupted:!0}}function $y(e){let t;for(let n of e.matches)n.event.type===`assistant/live-chunk`?(t??=Uy(n.event.data.turn,n.event.data.step),t=Yy(t,n.event.data.chunk,n.event.seq,n.event.time)):n.event.type===`assistant/message`?(t??=Uy(n.event.data.turn,n.event.data.step),t=Xy(t,n,n.event)):n.event.type===`llm/retry`&&t!==void 0&&(t=Jy(t));return t}function eb(e){let t=e.state??$y(e);if(t===void 0)return;let n=Qy(t,e),r=n?.blocks??Wy(t.blocks),i=n===void 0?t.visibleBlocks>0:Ky(r),a=n?.interrupted===!0?`interrupted`:n===void 0?`running`:`settled`,o=(n?.interrupted===!0?n.seq:t.firstVisibleSeq??n?.seq)??e.matches[0]?.event.seq??0,s=n?.time??t.firstVisibleTime??e.matches[0]?.event.time??0;return{anchorSeq:o,visible:i,settled:n,data:{status:a,turn:t.turn,step:t.step,blocks:r,time:s,...t.usage===void 0?{}:{usage:t.usage},...n===void 0?{}:{finalNode:n}}}}function tb(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`step`?t.step.data.get(`assistant-step`):void 0}let nb={kind:`assistant-step`,target:`chat`,match:e=>e.type===`step/start`?{id:`${e.data.turn}:${e.data.step}`,role:`start`}:e.type===`assistant/live-chunk`||e.type===`assistant/message`&&e.surfaceOp===`append`||e.type===`llm/retry`?{id:`${e.data.turn}:${e.data.step}`,role:`update`}:null,start:(e,t)=>{if(t.event.type!==`step/start`)throw Error(`assistant-step start requires step/start`);return Uy(t.event.data.turn,t.event.data.step)},update:(e,t)=>t.event.type===`assistant/live-chunk`?Yy(e.state,t.event.data.chunk,t.event.seq,t.event.time):t.event.type===`assistant/message`?Xy(e.state,t,t.event):t.event.type===`llm/retry`?Jy(e.state):e.state,publication:e=>{if(e.event.type===`step/start`)return`none`;if(e.event.type!==`assistant/live-chunk`)return`immediate`;let t=e.event.data.chunk.type;return t===`usage`||t===`finish`?`none`:`animation-frame`},buildLocationData:(e,t)=>{if(t!==`step`)return null;let n=eb(e);return n===void 0?null:{kind:`step`,turn:n.data.turn,step:n.data.step,key:`assistant-step`,value:n.data}},buildViewNode:e=>{let t=e.current.get(`chat`),n=e.state??$y(e),r=tb(e);if(n===void 0||r===void 0)return t==null?null:{...t,visibility:`hidden`};let i=r.finalNode,a=i===void 0?n.visibleBlocks>0:Ky(r.blocks);return i===void 0&&!a&&t==null?null:Oy(e,`assistant-step`,(i?.interrupted===!0?i.seq:n.firstVisibleSeq??i?.seq)??e.matches[0]?.event.seq??0,r,{visibility:i?.interrupted===!0||a?`visible`:`hidden`})}};function rb(e){let t=nb.match.bind(nb);e.uiConversation.events.register({...nb,match:{"step/start":t,"assistant/live-chunk":t,"assistant/message":t,"llm/retry":t}})}function ib(e){return`kind`in e}function ab(e){return!ib(e)}function ob(e){return e.visibility===`visible`&&e.kind!==`system-prompt`&&(e.kind!==`context`||e.data.content.some(e=>e.type===`tool-addition`||e.type===`tool-removal`))&&(e.kind!==`command`||e.data.name!==`permission`)}function sb(e,t){let n=``,r=!1;for(let i of e){if(n.length>=t*2){r=!0;break}let e=i.length>t*2,a=e?i.slice(0,t*2):i;if(n+=n===``?a:` ${a}`,e){r=!0;break}}let i=n.replace(/\s+/g,` `).trim();return i.length>t-1?`${i.slice(0,t-1).trimEnd()}…`:r?`${i}…`:i}function cb(e){return e.kind===`user`?sb(e.data.content.flatMap(e=>e.type===`text`?[e.text]:[]),50):``}function lb(e){return e.kind===`assistant-step`?sb(e.data.blocks.flatMap(e=>e.kind===`text`?[e.text]:[]),120):``}function ub(e,t){return e===void 0||t===void 0?e===t:e.turn===t.turn&&e.anchorKey===t.anchorKey&&e.prompt===t.prompt&&e.response===t.response}function db(e,t,n){let r=t.getTurn(e).map(e=>n.get(e)).filter(e=>e!==void 0&&ob(e)),i=r.find(e=>e.kind===`user`),a=i??r[0];if(a===void 0)return;let o=r.findLast(e=>lb(e)!==``);return{turn:e,anchorKey:a.key,prompt:i===void 0?``:cb(i),response:o===void 0?``:lb(o)}}function fb(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function pb(e,t){return e===t||e!==void 0&&t!==void 0&&e.spec===t.spec&&e.turn===t.turn&&e.turnStarted===t.turnStarted&&e.turnClosed===t.turnClosed&&e.hasExternalProcess===t.hasExternalProcess&&e.hasInterleavedInput===t.hasInterleavedInput&&e.compactAnswer===t.compactAnswer}function mb(e,t,n){let r=t.getTurn(e),i=r.map(e=>n.get(e)).find(e=>e?.kind===`turn-process`);if(i===void 0)return;let a=i.data,o=i.location;if(o.kind!==`turn`&&o.kind!==`step`)return;let s;for(let e of r){let t=n.get(e);(t?.kind===`user`||t?.kind===`steering`||t?.kind===`turn-trigger`)&&(a.controlAnchorSeq===o.turn.start?.seq||t.anchorSeq<a.controlAnchorSeq)&&(s=Math.max(s??t.anchorSeq,t.anchorSeq))}let c=!1,l=!1,u=!0;for(let e of r){let t=n.get(e);t!==void 0&&ob(t)&&t.kind!==`turn-process`&&((t.kind===`user`||t.kind===`steering`||t.kind===`turn-trigger`)&&(s===void 0||t.anchorSeq>s)&&(l=!0,(a.answerAnchorSeq===null||t.anchorSeq<a.answerAnchorSeq)&&(u=!1)),!(xh.has(t.kind)||t.anchorSeq<a.processStartSeq)&&(t.kind!==`assistant-step`||a.answerStep===null||t.data.step!==a.answerStep)&&(c=!0))}return{turn:e,spec:a,turnStarted:o.turn.start!==void 0,turnClosed:o.turn.status===`closed`,hasExternalProcess:c,hasInterleavedInput:l,compactAnswer:u}}var hb=class{presentations=/* @__PURE__ */ new Map;get(e){let t=fb(e);return t===void 0?void 0:this.presentations.get(t)}replace(e,t,n){let r=/* @__PURE__ */ new Set;for(let t of e){let e=fb(n.get(t));e!==void 0&&r.add(e)}let i=/* @__PURE__ */ new Set;for(let e of/* @__PURE__ */ new Set([...this.presentations.keys(),...r]))this.set(e,r.has(e)?mb(e,t,n):void 0)&&i.add(e);return i}update(e,t,n){let r=/* @__PURE__ */ new Set;for(let i of e)this.set(i,mb(i,t,n))&&r.add(i);return r}set(e,t){return!pb(this.presentations.get(e),t)&&(t===void 0?this.presentations.delete(e):this.presentations.set(e,t),!0)}};let gb=[],_b=[],vb=[],yb=[];function bb(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function xb(e,t,n){let r=e.get(t);return r===void 0&&(r=n(),e.set(t,r)),r}var Sb=class{read;label;listeners=/* @__PURE__ */ new Set;published;constructor(e,t){this.read=e,this.label=t,this.published=e()}getSnapshot=()=>this.read();subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(){let e=this.getSnapshot();this.published!==e&&(this.published=e,(0,m.notifySubscribers)(this.listeners,this.label))}},Cb=class{nodes=/* @__PURE__ */ new Map;current=yb;dirty=!1;observable;source(){return this.observable??=new Sb(()=>this.read(),`[ui-chat] turn kind nodes`)}set(e){let t=this.nodes.get(e.key);this.nodes.set(e.key,e),(t===void 0||t.data!==e.data||t.anchorSeq!==e.anchorSeq)&&(this.dirty=!0)}delete(e){this.nodes.delete(e),this.dirty=!0}publish(){this.observable?.publish()}read(){return this.dirty&&=(this.current=[...this.nodes.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).map(e=>e.data),!1),this.current}},wb=class{byKey=/* @__PURE__ */ new Map;turnProcesses=new hb;sources=/* @__PURE__ */ new Map;processSources=/* @__PURE__ */ new Map;dirtyKeys=/* @__PURE__ */ new Set;dirtyProcessKeys=/* @__PURE__ */ new Set;turnKinds=/* @__PURE__ */ new Map;dirtyTurnKinds=/* @__PURE__ */ new Set;valuesCache=yb;valuesDirty=!1;get(e){return this.byKey.get(e)}source(e){return xb(this.sources,e,()=>new Sb(()=>this.get(e),`[ui-chat] node source ${e}`))}turnDataSource(e,t){return this.turnKind(e,t).source()}turnKind(e,t){return xb(xb(this.turnKinds,e,()=>/* @__PURE__ */ new Map),t,()=>new Cb)}updateTurnKind(e,t){let n=e===void 0?void 0:kb(e.location).turn,r=t===void 0?void 0:kb(t.location).turn;if(e!==void 0&&n!==void 0&&(n!==r||e.kind!==t?.kind)){let t=this.turnKind(n,e.kind);t.delete(e.key),this.dirtyTurnKinds.add(t)}if(t!==void 0&&r!==void 0){let e=this.turnKind(r,t.kind);e.set(t),this.dirtyTurnKinds.add(e)}}processSource(e){return xb(this.processSources,e,()=>new Sb(()=>this.process(e),`[ui-chat] node process source ${e}`))}process(e){return this.turnProcesses.get(this.get(e))}values(){return this.valuesDirty&&=(this.valuesCache=[...this.byKey.values()],!1),this.valuesCache}replace(e){let t=new Map(this.byKey);this.byKey.clear();for(let n of e)this.byKey.set(n.key,n),t.get(n.key)!==n&&(this.updateTurnKind(t.get(n.key),n),this.dirtyKeys.add(n.key),this.dirtyProcessKeys.add(n.key)),t.delete(n.key);for(let e of t.keys())this.updateTurnKind(t.get(e),void 0),this.dirtyKeys.add(e),this.dirtyProcessKeys.add(e);this.valuesCache=[...this.byKey.values()],this.valuesDirty=!1}upsert(e){let t=!1;for(let n of e)this.byKey.get(n.key)!==n&&(this.updateTurnKind(this.byKey.get(n.key),n),this.byKey.set(n.key,n),this.dirtyKeys.add(n.key),this.dirtyProcessKeys.add(n.key),t=!0);t&&(this.valuesDirty=!0)}touchProcesses(e,t){for(let n of e)for(let e of t.getTurn(n))this.dirtyProcessKeys.add(e)}replaceProcesses(e,t){this.touchProcesses(this.turnProcesses.replace(e,t,this),t)}updateProcesses(e,t){this.touchProcesses(this.turnProcesses.update(e,t,this),t)}publish(){let e=[...this.dirtyKeys],t=[...this.dirtyProcessKeys],n=[...this.dirtyTurnKinds];this.dirtyKeys.clear(),this.dirtyProcessKeys.clear(),this.dirtyTurnKinds.clear();for(let t of e)this.sources.get(t)?.publish();for(let e of t)this.processSources.get(e)?.publish();for(let e of n)e.publish()}},Tb=class{turns=/* @__PURE__ */ new Map;steps=/* @__PURE__ */ new Map;positions=/* @__PURE__ */ new Map;getTurn(e){return this.turns.get(e)??gb}getStep(e,t){return this.steps.get(Ob(e,t))??gb}getPosition(e){return this.positions.get(e)}rebuild(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Set;for(let[o,s]of e.entries()){let c=t.get(s)?.location;if(c===void 0)continue;let l=kb(c),u=this.positions.get(s),d={turn:l.turn,previous:e[o-1],next:e[o+1]},f=u!==void 0&&u.turn===d.turn&&u.previous===d.previous&&u.next===d.next;if(i.set(s,f?u:d),f||(u?.turn!==void 0&&a.add(u.turn),d.turn!==void 0&&a.add(d.turn)),l.turn===void 0)continue;let p=n.get(l.turn)??[];if(p.push(s),n.set(l.turn,p),l.step===void 0)continue;let m=Ob(l.turn,l.step),h=r.get(m)??[];h.push(s),r.set(m,h)}for(let[e,t]of this.positions)!i.has(e)&&t.turn!==void 0&&a.add(t.turn);return this.positions=i,this.turns=Eb(this.turns,n),this.steps=Eb(this.steps,r),[...a]}touch(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let r of e){let e=kb(r.location);e.turn!==void 0&&this.turns.get(e.turn)?.includes(r.key)&&(t.add(e.turn),e.step!==void 0&&n.add(Ob(e.turn,e.step)))}for(let e of t){let t=this.turns.get(e);t!==void 0&&this.turns.set(e,[...t])}for(let e of n){let t=this.steps.get(e);t!==void 0&&this.steps.set(e,[...t])}}};function Eb(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set([...e.keys(),...t.keys()]);for(let i of r){let r=e.get(i)??gb,a=t.get(i)??gb,o=bb(r,a)?r:a;a.length>0&&n.set(i,o)}return n}var Db=class{current=vb;byTurn=/* @__PURE__ */ new Map;items(){return this.current}rebuild(e,t,n){let r=[],i=/* @__PURE__ */ new Map;for(let a of e.turnOrder){let e=db(a,t,n);if(e===void 0)continue;let o=this.byTurn.get(a),s=o!==void 0&&ub(o,e)?o:e;r.push(s),i.set(a,s)}this.byTurn=i,r.length===this.current.length&&r.every((e,t)=>e===this.current[t])||(this.current=r)}touch(e,t,n){if(e.size===0)return;let r=this.current.map(r=>{if(!e.has(r.turn))return r;let i=db(r.turn,t,n);return i===void 0||ub(r,i)?r:(this.byTurn.set(r.turn,i),i)});r.some((e,t)=>e!==this.current[t])&&(this.current=r)}};function Ob(e,t){return`${e}:${t}`}function kb(e){return e.kind===`step`?{turn:e.turn.turn,step:e.step.step}:e.kind===`turn`?{turn:e.turn.turn}:{}}function Ab(e){return e.kind===`turn`||e.kind===`step`?e.turn.status:void 0}function jb(e,t,n){return n||e===void 0||Ab(e.location)!==Ab(t.location)?!0:e.kind===`turn-process`&&t.kind===`turn-process`?e.data!==t.data:e.kind===`assistant-step`&&t.kind===`assistant-step`&&e.data.step!==t.data.step}function Mb(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=n;e.kind===`turn-process`&&t.set(e.data.turn,{...t.get(e.data.turn),control:e})}for(let n of e){let e=n,r=e.location;if(r.kind!==`turn`&&r.kind!==`step`)continue;let i=t.get(r.turn.turn)??{},a=i.control?.data.controlAnchorSeq;(e.kind===`user`||e.kind===`turn-trigger`||e.kind===`steering`)&&a!==void 0&&(a===r.turn.start?.seq||e.anchorSeq<a)?t.set(r.turn.turn,{...i,openingInputAnchor:Math.max(i.openingInputAnchor??e.anchorSeq,e.anchorSeq)}):xh.has(e.kind)||t.set(r.turn.turn,{...i,earliestProcessAnchor:Math.min(i.earliestProcessAnchor??e.anchorSeq,e.anchorSeq)})}return t}function Nb(e,t){let n=e,r=n.location;if(r.kind!==`turn`&&r.kind!==`step`)return{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq};let i=t.get(r.turn.turn);if(i===void 0)return{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq};let a=i.openingInputAnchor;return a!==void 0&&n.anchorSeq<a&&!xh.has(n.kind)?{anchor:a,rank:2,originalAnchor:n.anchorSeq}:i.control!==void 0&&n.key===i.control.key?a===void 0?{anchor:i.earliestProcessAnchor??n.anchorSeq,rank:-1,originalAnchor:n.anchorSeq}:{anchor:a,rank:1,originalAnchor:n.anchorSeq}:{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq}}function Pb(e){let t=e.filter(e=>ob(e)),n=Mb(t);return t.sort((e,t)=>{let r=Nb(e,n),i=Nb(t,n);return r.anchor-i.anchor||r.rank-i.rank||r.originalAnchor-i.originalAnchor||e.key.localeCompare(t.key)})}function Fb(e){let t=e;return t.kind===`user`||t.kind===`steering`?t.data.seq:void 0}function Ib(e){let t=e;if(t.kind===`context`)return{messageSeq:t.data.seq-1,labels:Iy(t.data.source)}}function Lb(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.referenceLabels??gb,i=Object.hasOwn(n.data,`referenceLabels`);if(bb(r,t)&&i===t.length>0)return e;let a={...n.data};return t.length===0?delete a.referenceLabels:a.referenceLabels=t,{...n,data:a}}var Rb=class{messagesBySeq=/* @__PURE__ */ new Map;labelsByMessageSeq=/* @__PURE__ */ new Map;replace(e){this.messagesBySeq.clear(),this.labelsByMessageSeq.clear();for(let t of e){let e=Fb(t);e!==void 0&&this.messagesBySeq.set(e,t.key);let n=Ib(t);n!==void 0&&n.labels.length>0&&this.labelsByMessageSeq.set(n.messageSeq,n.labels)}return e.map(e=>{let t=Fb(e);return t===void 0?e:Lb(e,this.labelsByMessageSeq.get(t)??gb)})}apply(e,t){let n=new Map(e.map(e=>[e.key,e])),r=/* @__PURE__ */ new Set;for(let t of e){let e=Fb(t);e!==void 0&&(this.messagesBySeq.set(e,t.key),r.add(e));let n=Ib(t);if(n===void 0)continue;let i=this.labelsByMessageSeq.get(n.messageSeq);n.labels.length===0?this.labelsByMessageSeq.delete(n.messageSeq):this.labelsByMessageSeq.set(n.messageSeq,i!==void 0&&bb(i,n.labels)?i:n.labels),r.add(n.messageSeq)}for(let e of r){let r=this.messagesBySeq.get(e);if(r===void 0)continue;let i=n.get(r)??t.get(r);i!==void 0&&n.set(r,Lb(i,this.labelsByMessageSeq.get(e)??gb))}return[...n.values()]}};function zb(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.skillNames??gb,i=Object.hasOwn(n.data,`skillNames`);if(bb(r,t)&&i===t.length>0)return e;let a={...n.data};return t.length===0?delete a.skillNames:a.skillNames=t,{...n,data:a}}function Bb(e){let t=e;if(t.kind===`user`||t.kind===`steering`)return{key:e.key,seq:e.anchorSeq,kind:`message`,name:null};if(t.kind===`context`){let n=Ly(t.data.source);return n===null?null:{key:e.key,seq:e.anchorSeq,kind:`skill`,name:n}}return{key:e.key,seq:e.anchorSeq,kind:`boundary`,name:null}}function Vb(e,t){return e.seq===t.seq&&e.kind===t.kind&&e.name===t.name}var Hb=class{entries=/* @__PURE__ */ new Map;sorted=[];replace(e){this.entries.clear(),this.sorted=[];for(let t of e){let e=Bb(t);e!==null&&(this.entries.set(e.key,e),this.sorted.push(e))}this.sorted.sort((e,t)=>e.seq-t.seq);let t=/* @__PURE__ */ new Map;for(let e=0;e<this.sorted.length;e++){if(this.sorted[e]?.kind===`boundary`)continue;let n=this.runEnd(e);this.assignRun(e,n,t),e=n}return e.map(e=>zb(e,t.get(e.key)??gb))}apply(e,t){let n=[];for(let t of e){let e=Bb(t),r=this.entries.get(t.key);if(r!==void 0){if(e!==null&&Vb(r,e)){e.kind===`message`&&n.push(e.seq);continue}this.remove(r),n.push(r.seq)}e!==null&&(this.insert(e),n.push(e.seq))}if(n.length===0)return e;let r=/* @__PURE__ */ new Map;for(let e of n)this.collectAround(e,r);let i=new Map(e.map(e=>[e.key,e]));for(let[e,n]of r){let r=i.get(e)??t.get(e);if(r===void 0)continue;let a=zb(r,n);(a!==r||i.has(e))&&i.set(e,a)}return[...i.values()]}insert(e){this.sorted.splice(this.lowerBound(e.seq),0,e),this.entries.set(e.key,e)}remove(e){this.sorted.splice(this.sorted.indexOf(e),1),this.entries.delete(e.key)}lowerBound(e){let t=0,n=this.sorted.length;for(;t<n;){let r=t+n>>>1;(this.sorted[r]?.seq??1/0)<e?t=r+1:n=r}return t}runEnd(e){let t=e;for(;t+1<this.sorted.length&&this.sorted[t+1]?.kind!==`boundary`;)t++;return t}runStart(e){let t=e;for(;t-1>=0&&this.sorted[t-1]?.kind!==`boundary`;)t--;return t}assignRun(e,t,n){let r=[];for(let n=e;n<=t;n++){let e=this.sorted[n];e?.kind===`skill`&&e.name!==null&&!r.includes(e.name)&&r.push(e.name)}for(let i=e;i<=t;i++){let e=this.sorted[i];e?.kind===`message`&&n.set(e.key,r)}}collectAround(e,t){let n=this.lowerBound(e),r=this.sorted[n];if(r!==void 0&&r.seq===e&&r.kind!==`boundary`){this.assignRun(this.runStart(n),this.runEnd(n),t);return}n-1>=0&&this.sorted[n-1]?.kind!==`boundary`&&this.assignRun(this.runStart(n-1),n-1,t);let i=r!==void 0&&r.seq===e?n+1:n;i<this.sorted.length&&this.sorted[i]?.kind!==`boundary`&&this.assignRun(i,this.runEnd(i),t)}};let Ub={anchorSeq:0,nodes:yb,partial:null,running:null};function Wb(e){let t=e;if(e.visibility!==`visible`&&t.kind!==`assistant-step`)return Ub;switch(t.kind){case`user`:case`steering`:case`context`:case`command`:case`compaction`:case`turn-error`:case`turn-max-tokens`:case`unknown`:return{anchorSeq:t.anchorSeq,nodes:[t.data],partial:null,running:null};case`assistant-step`:{let n=t.data;return n.status===`running`?e.visibility===`visible`?{anchorSeq:t.anchorSeq,nodes:yb,partial:{turn:n.turn,step:n.step,blocks:n.blocks},running:null}:Ub:{anchorSeq:t.anchorSeq,nodes:n.finalNode===void 0?yb:[n.finalNode],partial:null,running:null}}case`tool-call`:{let e=t.data.root;return ab(e)?{anchorSeq:t.anchorSeq,nodes:yb,partial:null,running:e}:{anchorSeq:t.anchorSeq,nodes:[e],partial:null,running:null}}case`manual-compaction`:{let e=t.data;return{anchorSeq:t.anchorSeq,nodes:e.compaction===null?[e.command]:[e.command,e.compaction],partial:null,running:null}}case`model-retry`:return{anchorSeq:t.anchorSeq,nodes:t.data.attempts,partial:null,running:null};case`turn-tail`:case`system-prompt`:return Ub;default:return Ub}}function Gb(e,t){return e!==void 0&&e.anchorSeq===t.anchorSeq&&e.partial?.blocks===t.partial?.blocks&&e.partial?.turn===t.partial?.turn&&e.partial?.step===t.partial?.step&&e.running===t.running&&bb(e.nodes,t.nodes)}var Kb=class{contributions=/* @__PURE__ */ new Map;finalizedContributions=/* @__PURE__ */ new Map;runningContributions=/* @__PURE__ */ new Map;partialContributions=/* @__PURE__ */ new Map;finalized=yb;runningCalls=yb;partial=null;timeline;turnTimings=/* @__PURE__ */ new Map;turnEnds=/* @__PURE__ */ new Map;replace(e,t){this.contributions.clear(),this.finalizedContributions.clear(),this.runningContributions.clear(),this.partialContributions.clear();for(let t of e){let e=Wb(t);this.contributions.set(t.key,e),this.indexContribution(t.key,e)}return this.rebuildFinalized(),this.rebuildRunning(),this.rebuildPartial(),this.updateTimeline(t),this.snapshot()}apply(e,t){let n=!1,r=!1,i=!1;for(let t of e){let e=Wb(t),a=this.contributions.get(t.key);Gb(a,e)||(n||=Jb(a,e),r||=Yb(a,e),i||=Xb(a,e),this.contributions.set(t.key,e),this.indexContribution(t.key,e))}return n&&this.rebuildFinalized(),r&&this.rebuildRunning(),i&&this.rebuildPartial(),this.updateTimeline(t),this.snapshot()}indexContribution(e,t){qb(this.finalizedContributions,e,t,t.nodes.length>0),qb(this.runningContributions,e,t,t.running!==null),qb(this.partialContributions,e,t,t.partial!==null)}rebuildFinalized(){let e=[...this.finalizedContributions.values()].flatMap(e=>e.nodes).sort((e,t)=>e.seq-t.seq);bb(this.finalized,e)||(this.finalized=e)}rebuildRunning(){let e=[...this.runningContributions.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).flatMap(e=>e.running===null?[]:[e.running]);bb(this.runningCalls,e)||(this.runningCalls=e)}rebuildPartial(){let e=[...this.partialContributions.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).findLast(e=>e.partial!==null)?.partial??null;(this.partial?.blocks!==e?.blocks||this.partial?.turn!==e?.turn||this.partial?.step!==e?.step)&&(this.partial=e)}updateTimeline(e){if(this.timeline===e)return;this.timeline=e;let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let r of e.turns.values())r.start!==void 0&&t.set(r.turn,{startTime:r.start.time,...r.end===void 0?{}:{endTime:r.end.time}}),r.end!==void 0&&n.set(r.turn,r.end.seq);this.turnTimings=t,this.turnEnds=n}snapshot(){return{nodes:this.finalized,turnTimings:this.turnTimings,turnEnds:this.turnEnds,partial:this.partial,runningCalls:this.runningCalls}}};function qb(e,t,n,r){r?e.set(t,n):e.delete(t)}function Jb(e,t){let n=e?.nodes??yb;return!bb(n,t.nodes)||(n.length>0||t.nodes.length>0)&&e?.anchorSeq!==t.anchorSeq}function Yb(e,t){return e?.running!==t.running||(e.running!==null||t.running!==null)&&e.anchorSeq!==t.anchorSeq}function Xb(e,t){return e?.partial?.blocks!==t.partial?.blocks||e?.partial?.turn!==t.partial?.turn||e?.partial?.step!==t.partial?.step||((e?.partial??null)!==null||t.partial!==null)&&e?.anchorSeq!==t.anchorSeq}var Zb=class{store=new wb;locations=new Tb;navigation=new Db;legacy=new Kb;referenceLabels=new Rb;skillNames=new Hb;order=gb;latestGroupInput;readGroupNode=e=>this.store.get(e);readGroupTurn=e=>this.locations.getTurn(e);readGroupPosition=e=>this.locations.getPosition(e);timeline=null;empty;constructor(){this.empty=this.snapshot({turnOrder:_b,turns:/* @__PURE__ */ new Map}),this.latestGroupInput={kind:`replace`,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:this.empty.timeline}}replace(e){let t=this.skillNames.replace(this.referenceLabels.replace(e.nodes));return this.store.replace(t),this.order=Pb(t).map(e=>e.key),this.locations.rebuild(this.order,this.store),this.store.replaceProcesses(this.order,this.locations),this.navigation.rebuild(e.timeline,this.locations,this.store),this.timeline=e.timeline,this.latestGroupInput={kind:`replace`,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:e.timeline},this.snapshot(e.timeline,this.legacy.replace(t,e.timeline))}apply(e){let t=this.skillNames.apply(this.referenceLabels.apply(e.upserts,this.store),this.store),n=/* @__PURE__ */ new Set,r=!1,i=[],a=[];for(let e of t){let t=this.store.get(e.key);t!==e&&a.push({previous:t,current:e});let o=t===void 0||t.kind!==e.kind||t.anchorSeq!==e.anchorSeq||t.visibility!==e.visibility||$b(t.location)!==$b(e.location);if(r||=o,o||i.push(e),jb(t,e,o)){let r=t===void 0?void 0:kb(t.location).turn,i=kb(e.location).turn;r!==void 0&&n.add(r),i!==void 0&&n.add(i)}}this.store.upsert(t);let o=_b;if(r){let e=Pb(this.store.values()).map(e=>e.key);this.order=bb(this.order,e)?this.order:e,o=this.locations.rebuild(this.order,this.store)}return this.locations.touch(i),this.store.updateProcesses(n,this.locations),r||e.timeline!==this.timeline?this.navigation.rebuild(e.timeline,this.locations,this.store):this.navigation.touch(Qb(i),this.locations,this.store),this.timeline=e.timeline,this.latestGroupInput={kind:`apply`,changes:a,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:e.timeline,changedTurns:e.changedTurns??_b,changedTurnOrders:o},this.snapshot(e.timeline,this.legacy.apply(t,e.timeline))}groupInput(){return this.latestGroupInput}publish(){this.store.publish()}snapshot(e,t=this.legacy.replace(yb,e)){return{order:this.order,nodes:this.store,locations:this.locations,navigation:this.navigation,timeline:e,legacy:t}}};function Qb(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=kb(n.location).turn;e!==void 0&&t.add(e)}return t}function $b(e){let t=kb(e);return`${e.kind}:${t.turn??``}:${t.step??``}`}let ex={target:`chat`,create:()=>new Zb,isActive:e=>e.order.some(t=>e.nodes.get(t)?.kind!==`command`)};function tx(e){e.uiConversation.views.register(ex)}let nx=/* @__PURE__ */ new Set([`system/message`,`developer/message`,`user/message`,`assistant/message`,`tool/result`]);function rx(e){return nx.has(e.type)?e.surfaceOp!==void 0:!1}function ix(e){return rx(e)&&e.surfaceOp===`append`}function ax(e){return rx(e)&&e.surfaceOp!==`append`}function ox(e){if(e.event.type!==`command/run`)throw Error(`command start requires command/run`);let t=e.event.data;return{kind:`command`,seq:e.event.seq,time:e.event.time,commandId:t.commandId,name:t.name,args:t.args??null,outcome:null}}function sx(e,t){if(e.event.type!==`command/done`)throw Error(`command update requires command/done`);let n=e.event.data,r=n.kind===`success`&&n.sourceEventSeq!==void 0&&Number.isSafeInteger(n.sourceEventSeq)&&n.sourceEventSeq>=0?n.sourceEventSeq:void 0;return{kind:`command`,seq:t?.seq??e.event.seq,time:t?.time??e.event.time,commandId:n.commandId,name:t?.name??null,args:t?.args??null,outcome:{kind:n.kind,...n.text===void 0?{}:{text:n.text},...r===void 0?{}:{sourceEventSeq:r}}}}function cx(e){if(e.type!==`user/message`||!ax(e))return;let t=e.data.source;if(t.kind===`compact-checkpoint`&&typeof t.compactionId==`string`)return{compactionId:t.compactionId,...t.sourceCommandId===void 0?{}:{sourceCommandId:t.sourceCommandId}}}function lx(e,t){let n=null,r=null,i=null;if(e?.event.type===`compaction/summary`){let t=e.event.data;if(Array.isArray(t.summary)){let e=t.summary.map(e=>e.type===`text`?e.text:``).join(``);n=e.trim()===``?null:e}r=Array.isArray(t.shadowedSeqs)&&t.shadowedSeqs.every(e=>Number.isSafeInteger(e)&&e>=0)?t.shadowedSeqs.length:null,i=Number.isSafeInteger(t.shadowedTokenCount)&&t.shadowedTokenCount>=0?t.shadowedTokenCount:null}return{kind:`compaction`,seq:t.event.seq,time:t.event.time,summary:n,summaryEventSeq:e?.event.seq??null,shadowedItemCount:r,shadowedTokenCount:i}}function ux(e){let t=e.matches.find(e=>e.event.type===`command/done`),n=e.matches.find(e=>cx(e.event)!==void 0),r=e.matches.find(e=>e.event.type===`compaction/summary`);if(n===void 0)return t===void 0?void 0:{command:sx(t)};let i=cx(n.event);return i?.sourceCommandId===void 0?t===void 0?void 0:{command:sx(t)}:{command:t===void 0?{kind:`command`,seq:n.event.seq,time:n.event.time,commandId:i.sourceCommandId,name:`compact`,args:null,outcome:null}:{...sx(t),name:`compact`},checkpoint:n,...r===void 0?{}:{summary:r}}}function dx(e,t){return t.event.type===`compaction/summary`?{...e,summary:t}:cx(t.event)===void 0?e:{...e,checkpoint:t}}let fx={kind:`command`,target:`chat`,match:e=>{if(e.type===`command/run`)return{id:String(e.data.commandId),role:`start`};if(e.type===`command/done`)return{id:String(e.data.commandId),role:`update`};let t=cx(e);return t?.sourceCommandId===void 0?(e.type===`compaction/start`||e.type===`compaction/summary`||e.type===`compaction/end`)&&e.data.sourceCommandId!==void 0?{id:String(e.data.sourceCommandId),role:`update`}:null:{id:String(t.sourceCommandId),role:`update`}},start:(e,t)=>({command:ox(t)}),update:(e,t)=>t.event.type===`command/done`?{...e.state,command:sx(t,e.state.command)}:dx(e.state,t),buildViewNode:e=>{let t=e.state??ux(e);if(t===void 0)return null;if(t.command.name!==`compact`)return Oy(e,`command`,t.command.seq,t.command);let n=t.checkpoint===void 0?null:lx(t.summary,t.checkpoint),r={command:t.command,compaction:n};return Oy(e,`manual-compaction`,n?.seq??t.command.seq,r)}};function px(e){e.uiConversation.events.register(fx)}function mx(e){let t=e.matches.find(e=>e.event.type===`compaction/summary`),n=e.matches.find(e=>cx(e.event)!==void 0);return{...t===void 0?{}:{summary:t},...n===void 0?{}:{checkpoint:n}}}let hx={kind:`compaction`,target:`chat`,match:e=>{let t=cx(e);if(t!==void 0&&t.sourceCommandId===void 0)return{id:t.compactionId,role:`update`};if(e.type===`compaction/start`||e.type===`compaction/summary`||e.type===`compaction/end`){if(e.data.sourceCommandId!==void 0)return null;let t=e.data.compactionId;return typeof t!=`string`||t===``?null:{id:t,role:e.type===`compaction/start`?`start`:`update`}}return null},start:()=>({}),update:(e,t)=>dx(e.state,t),buildViewNode:e=>{let t=e.state??mx(e);if(t.checkpoint===void 0)return null;let n=lx(t.summary,t.checkpoint);return Oy(e,`compaction`,n.seq,n)}};function gx(e){e.uiConversation.events.register(hx)}let _x={kind:`unknown-surface`,target:`chat`,match:e=>e.type!==`assistant/live-chunk`&&ix(e)?{id:String(e.seq),role:`start`}:null,start:(e,t)=>({kind:`unknown`,seq:t.event.seq,time:t.event.time,type:t.event.type,data:t.event.data}),update:e=>e.state,buildViewNode:e=>e.state===void 0?null:Oy(e,`unknown`,e.state.seq,e.state)};function vx(e){e.uiConversation.events.registerFallback(_x)}let yx={kind:`snapshot`,ids:[]},bx=/* @__PURE__ */ new Set;function xx(e){let t=[],n=e;for(;n.kind===`splice`;)t.push(n),n=n.previous;let r=[...n.ids];for(let e of t.reverse())r.splice(e.start,e.removedCount,...e.inserted);return r}function Sx(e,t){let n;for(let{id:r}of t)e.has(r)&&(n??=new Set(e),n.delete(r));return n??e}function Cx(e,t,n){let r=e?.state.pending??yx,i=t.inserted,a=t.removedCount??0;if(a>0&&t.outcome!==`canceled`){let e=xx(r),o=e.splice(t.start,a,...i);return{pending:{kind:`snapshot`,ids:e},currentClaimed:new Set(o.map(e=>e.id)),claimSeq:n,claimedHuman:o.some(e=>e.source.kind===`user`)}}let o=Sx(e?.state.currentClaimed??bx,i);return{pending:{kind:`splice`,previous:r,start:t.start,removedCount:a,inserted:i},currentClaimed:o,claimSeq:e?.state.claimSeq??-1,claimedHuman:e?.state.claimedHuman??!1}}function wx(e){let t=`inbox-${e}`;return{kind:t,match:t=>t.type===`agent/inbox/spliced`&&t.data.target===e?{id:String(t.seq),role:`start`}:null,start:(e,n,r)=>{if(n.event.type!==`agent/inbox/spliced`)throw Error(`inbox start requires agent/inbox/spliced`);return Cx(r.previous(t),n.event.data,n.event.seq)},update:e=>e.state,publication:()=>`none`}}let Tx=wx(`next-step`),Ex=wx(`next-turn`);function Dx(e){e.uiConversation.events.register(Tx),e.uiConversation.events.register(Ex)}function Ox(e){return e.type!==`user/message`||!ax(e)?!1:e.data.source.kind===`compact-checkpoint`}function kx(e,t){return{kind:`context`,seq:e.seq,time:e.time,content:t.content,source:t.source,producer:Fy(t.source),form:Py(t.source)}}let Ax={kind:`input-message`,target:`chat`,match:e=>e.type===`user/message`&&ix(e)&&!Ox(e)?{id:String(e.data.id),role:`start`}:null,start:(e,t,n)=>{let r=t.event;if(r.type!==`user/message`)throw Error(`input-message start requires user/message`);if(r.data.source.kind!==`user`){let e=n.previous(`inbox-next-turn`)?.state,i=n.previous(`inbox-next-step`)?.state,a=t.location,o=a.kind===`step`?a.turn.start?.seq:void 0,s=a.kind===`step`&&a.step.step===1&&o!==void 0&&(i?.claimSeq??-1)>o&&(e?.claimSeq??-1)<o&&i?.claimedHuman===!1&&i.currentClaimed.has(String(r.data.id));return{...kx(r,r.data),waking:e?.currentClaimed.has(String(r.data.id))===!0||s}}return n.previous(`inbox-next-step`)?.state.currentClaimed.has(String(r.data.id))===!0?{kind:`steering`,messageId:r.data.id,seq:r.seq,time:r.time,content:r.data.content,source:r.data.source}:{kind:`user`,seq:r.seq,time:r.time,content:r.data.content,source:r.data.source}},update:e=>e.state,buildViewNode:e=>{if(e.state===void 0)return null;let t=e.state.kind===`context`&&e.start?.event.type===`user/message`&&e.state.waking===!0,n=e.state.kind===`user`||e.state.kind===`steering`?{...e.state,...jx(e.state)}:e.state;return Oy(e,t?`turn-trigger`:e.state.kind,e.state.seq,n)}};function jx(e){let t=Hp(e.content.flatMap(e=>e.type===`text`?[e.text]:[]).join(`
|
|
131
|
+
`));return t.length===0?{}:{responseAnnotations:t}}let Mx={...Ax,kind:`developer-message`,match:e=>e.type===`developer/message`?{id:String(e.data.message.id),role:`start`}:null,start:(e,t)=>{let n=t.event;if(n.type!==`developer/message`)throw Error(`developer-message start requires developer/message`);return kx(n,n.data.message)}};function Nx(e){e.uiConversation.events.register(Ax),e.uiConversation.events.register(Mx)}function Px(e,t,n){return e.location.kind!==`step`||t===void 0&&!n||t?.turn===e.location.turn.turn&&t.step===e.location.step.step?e.event.seq:e.location.step.step===1?e.location.turn.start?.seq??e.location.step.start?.seq??e.event.seq:e.location.step.start?.seq??e.event.seq}function Fx(e,t,n,r){let i=e.current.get(`chat`);return i?.kind===`system-prompt`?i.anchorSeq:Px(t,n,r)}function Ix(e){return{kind:`system-message`,target:`chat`,match:e=>e.type===`system/message`||`surfaceOp`in e&&e.surfaceOp!==`append`?{id:String(e.seq),role:`start`}:null,start:(t,n,r)=>{if(n.event.type===`assistant/live-chunk`)throw Error(`system-message requires a durable event`);return e(r.previous(`system-message`)?.state,n.event)},update:e=>e.state,buildViewNode:e=>{let t=e.state?.introduced;return t===void 0||t.text===``||e.start?.event.type!==`system/message`||e.start.event.surfaceOp!==`append`?null:Oy(e,`system-prompt`,t.update?t.seq:Px(e.start,void 0,!0),{text:t.text,...t.update?{update:!0}:{}})}}}function Lx(e){return{kind:`request-prompt`,target:`chat`,match:e=>e.type===`request/header`?{id:String(e.seq),role:`start`}:null,start:(t,n,r)=>{if(n.event.type!==`request/header`)throw Error(`request-prompt start requires request/header`);let i=r.previous(`request-prompt`)?.state,a=r.previous(`system-message`),o=a?.state.effective,s=n.location.kind===`step`?{turn:n.location.turn.turn,step:n.location.step.step}:{},c=e(i?.prompt,n.event,o),l=c.change?.kind,u=a?.matches[0]?.event,d=o!==void 0&&u?.type===`system/message`&&u.surfaceOp===`append`&&(o.update||i===void 0)&&o.turn===s.turn&&o.step===s.step;return{anchorSeq:Fx(t,n,i,n.event.data.reason===`initial`),showsPrompt:!d&&(i===void 0||n.event.data.reason!==`change`||n.event.data.startsSeries===!0||l===`system`||l===`system-and-tools`),...s,...c}},update:e=>e.state,buildViewNode:e=>{let t=e.state;if(t===void 0)return null;let n=e.current.get(`chat`),r=t.showsPrompt&&t.prompt.system!==``;return!r&&n?.kind!==`system-prompt`?null:Oy(e,`system-prompt`,t.anchorSeq,{text:t.prompt.system},{visibility:r?`visible`:`hidden`})}}}function Rx(e){e.uiConversation.events.register(Ix((t,n)=>e.uiConversation.inspectSystemPrompt(t,n))),e.uiConversation.events.register(Lx((t,n,r)=>e.uiConversation.inspectRequestPrompt(t,n,r)))}function zx(e){if(e.event.type===`llm/retry`)return{kind:`model-retry`,seq:e.event.seq,time:e.event.time,retryState:`scheduled`,...e.event.data}}function Bx(e){return e.kind===`step`&&e.step.status===`closed`||(e.kind===`step`||e.kind===`turn`)&&e.turn.status===`closed`}let Vx={kind:`model-retry`,target:`chat`,match:e=>{if(e.type===`llm/retry`){let t=e.data.retryId;return typeof t!=`string`||t===``?null:{id:t,role:e.data.retry===1?`start`:`update`}}if(e.type===`llm/retry-started`){let t=e.data.retryId;return typeof t==`string`&&t!==``?{id:t,role:`update`}:null}return null},start:(e,t)=>{let n=zx(t);if(n===void 0)throw Error(`model-retry start requires a valid llm/retry event`);return{turn:n.turn,step:n.step,attempts:[n]}},update:(e,t)=>{if(t.event.type===`llm/retry`){let n=zx(t);return n===void 0?e.state:{...e.state,attempts:[...e.state.attempts,n]}}if(t.event.type!==`llm/retry-started`)return e.state;let n=t.event.data.retry;return{...e.state,attempts:e.state.attempts.map(e=>e.retry===n?{...e,retryState:`started`}:e)}},buildViewNode:e=>{if(e.state===void 0||e.state.attempts.length===0)return null;let t=e.start?.location??e.matches[0]?.location??{kind:`unresolved`},n=e.state.attempts,r=n.map((e,r)=>r===n.length-1&&e.retryState===`scheduled`&&Bx(t)?{...e,retryState:`cancelled`}:e),i=r.at(-1);if(i===void 0)return null;let a={attempts:r,current:i};return Oy(e,`model-retry`,r[0]?.seq??i.seq,a)}};function Hx(e){e.uiConversation.events.register(Vx)}let Ux=/* @__PURE__ */ new WeakMap;function Wx(e){return JSON.stringify(e)}function Gx(e,t){if(e.event.type!==`tool/call`)throw Error(`tool-call start requires tool/call`);return{phase:`start`,callId:String(e.event.data.callId),name:e.event.data.name,argsRaw:e.event.data.arguments,args:t===void 0?Xh.fromText(e.event.data.arguments):t.args.settle(e.event.data.arguments),turn:e.event.data.turn,step:e.event.data.step,time:e.event.time,subCalls:[]}}function Kx(e,t){let n=t.event;if(n.type!==`assistant/live-chunk`)return e;let r=n.data.chunk,i=e.root;if(r.type===`block-end`&&r.block.type===`tool-call`)return i===void 0||`kind`in i||i.phase!==`preparing`?e:{...e,root:{...i,name:r.block.name,args:i.args.settle(r.block.arguments)}};if(r.type!==`tool-call-delta`)return e;if(i===void 0){if(!r.name)return e;let t=new Xh;return t.append(r.argumentsDelta),{...e,root:{phase:`preparing`,callId:String(r.id),name:r.name,turn:n.data.turn,step:n.data.step,time:n.time,subCalls:[],args:t}}}return`kind`in i||i.phase!==`preparing`||i.args.isSealed||i.args.append(r.argumentsDelta),e}function qx(e,t){let n=e.args.refresh();return!n&&t!==void 0&&!(`kind`in t)&&t.phase===`preparing`&&t.name===e.name&&t.args===e.args?t:n?{...e}:e}function Jx(e,t){if(e.event.type!==`tool/result`)return;let n=e.event.data.message;return{kind:`tool-result`,seq:e.event.seq,time:e.event.time,callId:String(n.source.callId),name:t?.name??``,args:t?.args??Xh.EMPTY,call:t===void 0?null:{name:t.name,argsRaw:t.argsRaw},callTime:t?.time??null,content:n.content,isError:n.isError===!0,...e.event.data.error===void 0?{}:{error:e.event.data.error},meta:e.event.data.meta,subCalls:[]}}function Yx(e,t){return{phase:`start`,callId:t.subCallId,parentCallId:t.parentCallId,name:t.name,argsRaw:Wx(t.arguments),args:Xh.fromObject(t.arguments),turn:Zx(e),step:Qx(e),time:e.event.time,subCalls:[]}}function Xx(e,t,n){return{kind:`tool-result`,seq:e.event.seq,time:e.event.time,callId:t.subCallId,parentCallId:t.parentCallId,name:t.name,args:n!==void 0&&!(`kind`in n)?n.args:Xh.fromObject(t.arguments),call:{name:t.name,argsRaw:Wx(t.arguments)},callTime:n?.time??null,content:t.content??[],isError:t.isError===!0,...t.error===void 0?{}:{error:t.error},subCalls:[]}}function Zx(e){return e.location.kind===`step`||e.location.kind===`turn`?e.location.turn.turn:0}function Qx(e){return e.location.kind===`step`?e.location.step.step:0}function $x(e,t,n){if(t===n||e.parents.has(n))return!1;let r=t,i=0,a=/* @__PURE__ */ new Set;for(;r!==void 0;){if(r===n||a.has(r))return!1;a.add(r),i++,r=e.parents.get(r)}let o=[{callId:n,depth:1}],s=/* @__PURE__ */ new Set,c=0;for(let t of o){if(s.has(t.callId))return!1;s.add(t.callId),c=Math.max(c,t.depth);for(let n of e.children.get(t.callId)??[])o.push({callId:n.callId,depth:t.depth+1})}return i+c<=256}function eS(e,t){let n=t.event;if(n.type!==`tool/ptc-dispatch-start`&&n.type!==`tool/ptc-dispatch`)return e;let r=n.data,i=String(r.parentCallId),a=String(r.subCallId),o=e.children.get(i)??[],s=o.findIndex(e=>e.callId===a);if(n.type===`tool/ptc-dispatch-start`){if(s>=0||!$x(e,i,a))return e;let n=new Map(e.children);n.set(i,[...o,Yx(t,r)]);let c=new Map(e.parents);return c.set(a,i),{...e,children:n,parents:c}}if(s<0&&!$x(e,i,a))return e;let c=Xx(t,r,s<0?void 0:o[s]),l=new Map(e.children);l.set(i,s<0?[...o,c]:o.map((e,t)=>t===s?c:e));let u=new Map(e.parents);return s<0&&u.set(a,i),{...e,children:l,parents:u}}function tS(e,t,n,r=/* @__PURE__ */ new Set,i=1){if(!(`kind`in e)&&e.phase===`preparing`)return e;if(r.has(e.callId)||i>256)return{...e,subCalls:[]};let a=new Set(r);a.add(e.callId);let o=(t.children.get(e.callId)??e.subCalls).map(e=>tS(e,t,n,a,i+1)),s=`kind`in e?void 0:n?.seq,c=`kind`in e?void 0:n?.time,l=Ux.get(e);if(l!==void 0&&l.interruptionSeq===s&&l.interruptionTime===c&&nS(l.children,o))return l.value;let u=`kind`in e||n===void 0?nS(e.subCalls,o)?e:{...e,subCalls:o}:{kind:`tool-result`,seq:n.seq+Ey.interruptedFollowup,time:n.time,callId:e.callId,...e.parentCallId===void 0?{}:{parentCallId:e.parentCallId},name:e.name,args:e.args,call:{name:e.name,argsRaw:e.argsRaw},callTime:e.time,content:[],isError:!0,error:{name:`Interrupted`,code:`interrupted`},subCalls:o};return Ux.set(e,{children:o,interruptionSeq:s,interruptionTime:c,value:u}),u}function nS(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function rS(e){let t=e.start?.location;if(t?.kind===`step`&&t.step.status===`closed`)return t.step.end;if((t?.kind===`step`||t?.kind===`turn`)&&t.turn.status===`closed`)return t.turn.end}function iS(e){let t=e.matches.find(e=>e.event.type===`tool/result`),n=t===void 0?void 0:Jx(t);if(n===void 0)return;let r={root:n,children:/* @__PURE__ */ new Map,parents:/* @__PURE__ */ new Map};for(let t of e.matches)r=eS(r,t);return r}let aS={kind:`tool-call`,target:`chat`,match:e=>{if(e.type===`assistant/live-chunk`){let t=e.data.chunk;return t.type===`block-end`&&t.block.type===`tool-call`?{id:String(t.block.id),role:`start`}:t.type===`tool-call-delta`?{id:String(t.id),role:`start`}:null}if(e.type===`tool/call`)return{id:String(e.data.callId),role:`start`};if(e.type===`tool/result`&&ix(e))return{id:String(e.data.message.source.callId),role:`update`};if(e.type===`tool/ptc-dispatch-start`||e.type===`tool/ptc-dispatch`){let t=e.data.rootCallId;return typeof t==`string`&&t!==``?{id:t,role:`update`}:null}return null},start:(e,t)=>{let n={root:void 0,children:/* @__PURE__ */ new Map,parents:/* @__PURE__ */ new Map};return t.event.type===`tool/call`?{...n,root:Gx(t)}:Kx(n,t)},update:(e,t)=>{if(t.event.type===`assistant/live-chunk`)return Kx(e.state,t);if(t.event.type===`tool/call`)return{...e.state,root:Gx(t,e.state.root)};if(t.event.type===`tool/result`){let n=e.state.root,r=Jx(t,n!==void 0&&!(`kind`in n)&&n.phase===`start`?n:void 0);return r===void 0?e.state:{...e.state,root:r}}return eS(e.state,t)},publication:e=>e.event.type===`assistant/live-chunk`?`animation-frame`:`immediate`,buildViewNode:e=>{let t=e.current.get(`chat`),n=e.state??iS(e);if(n?.root===void 0)return t==null?null:t.visibility===`hidden`?t:{...t,visibility:`hidden`};let r=rS(e),i=tS(!(`kind`in n.root)&&n.root.phase===`preparing`?qx(n.root,t?.data.root):n.root,n,r),a=e.start?.event.seq??(`kind`in n.root?n.root.seq:e.matches[0]?.event.seq??0),o=!(`kind`in i)&&i.phase===`preparing`&&r!==void 0?`hidden`:`visible`,s=Dy(e),c=wh(i.name)&&s.kind===`step`?{kind:`turn`,turn:s.turn}:s,l=t?.data.root===i?t.data:{root:i};return t?.data===l&&t.anchorSeq===a&&t.visibility===o&&t.location===c?t:Oy(e,`tool-call`,a,l,{visibility:o,location:c})}};function oS(e){let t=aS.match.bind(aS);e.uiConversation.events.register({...aS,match:{"assistant/live-chunk":t,"tool/call":t,"tool/result":t,"tool/ptc-dispatch-start":t,"tool/ptc-dispatch":t}})}function sS(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind!==`turn`&&t?.kind!==`step`?0:t.turn.steps.at(-1)?.step??0}function cS(e){if(e.event.type!==`turn/end`)return;let t=e.event.data.reason,n=t.kind===`error`?t.error:t.kind===`aborted`&&t.reason.kind===`hook`&&t.reason.reason===`deepseek-account/signed-out`?{message:`Stopped because you signed out of DeepSeek.`,code:`ACCOUNT_SIGNED_OUT`}:void 0;if(n===void 0)return;let r=Vy(n);return{seq:e.event.seq,time:e.event.time,message:r.message,...r.code===void 0?{}:{code:r.code}}}function lS(e){let t=e.matches.find(e=>cS(e)!==void 0);if(t?.event.type!==`turn/end`)return;let n=cS(t);if(n!==void 0)return{turn:t.event.data.turn,failure:n}}let uS={kind:`turn-error`,target:`chat`,match:e=>e.type===`turn/start`?{id:String(e.data.turn),role:`start`}:e.type===`turn/end`&&(e.data.reason.kind===`error`||e.data.reason.kind===`aborted`&&e.data.reason.reason.kind===`hook`&&e.data.reason.reason.reason===`deepseek-account/signed-out`)?{id:String(e.data.turn),role:`update`}:null,start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-error start requires turn/start`);return{turn:t.event.data.turn}},update:(e,t)=>{let n=cS(t);return n===void 0?e.state:{...e.state,failure:n}},buildViewNode:e=>{let t=e.state??lS(e);if(t?.failure===void 0)return null;let n=t.failure,r={kind:`turn-error`,seq:n.seq,time:n.time,turn:t.turn,step:sS(e),message:n.message,...n.code===void 0?{}:{code:n.code}};return Oy(e,`turn-error`,r.seq,r)}};function dS(e){e.uiConversation.events.register(uS)}function fS(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind!==`turn`&&t?.kind!==`step`?0:t.turn.steps.at(-1)?.step??0}function pS(e,t){let n=e.start?.location??e.matches[0]?.location;if(n?.kind!==`turn`&&n?.kind!==`step`)return t;let r=n.turn.data.get(`turn-tail`)?.closing;return r==null?t:r.finalNode.seq+Ey.maxTokensNotice}function mS(e){if(e.event.type===`turn/end`&&e.event.data.reason.kind===`max-tokens`)return{turn:e.event.data.turn,seq:e.event.seq,time:e.event.time}}let hS={kind:`turn-max-tokens`,target:`chat`,match:e=>e.type===`turn/end`&&e.data.reason.kind===`max-tokens`?{id:String(e.data.turn),role:`start`}:null,start:(e,t)=>{let n=mS(t);if(n===void 0)throw Error(`turn-max-tokens start requires a max-tokens turn/end`);return n},update:e=>e.state,buildViewNode:e=>{let t=e.state;if(t===void 0)return null;let n={kind:`turn-max-tokens`,seq:t.seq,time:t.time,turn:t.turn,step:fS(e)};return Oy(e,`turn-max-tokens`,pS(e,t.seq),n)}};function gS(e){e.uiConversation.events.register(hS)}function _S(e){let t=e.data;return typeof t.turn==`number`?t.turn:void 0}function vS(e){if(e.type===`text-delta`||e.type===`reasoning-delta`)return e.text.trim()!==``;if(e.type===`block-start`)return e.blockType!==`text`&&e.blockType!==`reasoning`&&e.blockType!==`tool-call`;if(e.type!==`block-end`)return!1;let t=e.block;return t.type===`tool-call`?!1:t.type===`text`||t.type===`reasoning`?t.text.trim()!==``:!0}function yS(e){return e.type===`assistant/live-chunk`?vS(e.data.chunk):e.type!==`assistant/attempt`&&e.type===`assistant/message`&&e.surfaceOp===`append`&&Ry(e.data.message.content).some(e=>e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function bS(e,t){return e.type===`tool/call`?wh(e.data.name):e.type===`tool/result`&&t.has(String(e.data.message.source.callId))}function xS(e,t){if(yS(e))return e.type!==`assistant/live-chunk`&&e.type!==`assistant/message`&&e.type!==`assistant/attempt`?void 0:{kind:`assistant`,seq:e.seq,step:e.data.step};if(!bS(e,t)&&(e.type===`tool/call`||e.type===`tool/result`&&e.surfaceOp===`append`||e.type===`llm/retry`))return{kind:`other`,seq:e.seq}}function SS(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function CS(e){let t=e.matches.map(e=>_S(e.event)).find(e=>e!==void 0);if(t===void 0)return;let n={turn:t,assistantStartByStep:/* @__PURE__ */ new Map,messageCountByStep:/* @__PURE__ */ new Map,messageCount:0,toolCallCount:0,subagentCount:0,contextCompactionCalls:/* @__PURE__ */ new Set};for(let t of e.matches)n=DS(n,t.event);return n}function wS(e){return e?.finalNode!==void 0}function TS(e){let t=e.end?.data.finalAssistantStep;if(t===null)return null;let n=(t===void 0?e.steps.at(-1):e.steps.find(e=>e.step===t))?.data.get(`assistant-step`);return!wS(n)||n.finalNode.interrupted===!0||!py(n.blocks)||t===void 0&&n.blocks.some(e=>e.kind===`tool-call`)?null:n}function ES(e,t){let n=e.controlAnchorSeq??t.start?.seq;if(n===void 0)return null;let r=TS(t),i={messageCount:r===null?e.messageCount:[...e.messageCountByStep].filter(([e])=>e!==r.step).reduce((e,[,t])=>e+t,0),toolCallCount:e.toolCallCount,subagentCount:e.subagentCount};if(r===null)return{turn:t.turn,controlAnchorSeq:n,processStartSeq:n,answerAnchorSeq:null,answerStep:null,inlineReasoning:!1,...i};let a=r.blocks.some(e=>e.kind===`reasoning`&&e.text.trim()!==``),o=Math.min(...[...e.assistantStartByStep].filter(([e])=>e<r.step).map(([,e])=>e)),s=Math.min(e.otherStartSeq??1/0,o);return{turn:t.turn,controlAnchorSeq:n,processStartSeq:t.start?.seq??(Number.isFinite(s)?s:r.finalNode.seq),answerAnchorSeq:r.finalNode.seq,answerStep:r.step,inlineReasoning:a,...i}}function DS(e,t){let n=e;if(t.type===`assistant/message`&&t.surfaceOp===`append`&&py(Ry(t.data.message.content))){let e=new Map(n.messageCountByStep);e.set(t.data.step,(e.get(t.data.step)??0)+1),n={...n,messageCountByStep:e,messageCount:n.messageCount+1}}if(t.type===`tool/call`){if(wh(t.data.name)){let e=new Set(n.contextCompactionCalls);e.add(String(t.data.callId)),n={...n,contextCompactionCalls:e}}else{let e=Ch(t.data.name);n={...n,toolCallCount:n.toolCallCount+ +!e,subagentCount:n.subagentCount+ +!!e}}}let r=xS(t,n.contextCompactionCalls);if(r===void 0)return n;if(r.kind===`other`)return n.otherStartSeq===void 0?{...n,otherStartSeq:r.seq,controlAnchorSeq:Math.min(n.controlAnchorSeq??1/0,r.seq)}:n;if(n.assistantStartByStep.has(r.step))return n;let i=new Map(n.assistantStartByStep);return i.set(r.step,r.seq),{...n,assistantStartByStep:i,controlAnchorSeq:Math.min(n.controlAnchorSeq??1/0,r.seq)}}let OS={kind:`turn-process`,target:`chat`,match:e=>{if(e.type===`turn/start`)return{id:String(e.data.turn),role:`start`};let t=_S(e);return t===void 0?null:e.type===`assistant/live-chunk`||e.type===`assistant/message`||e.type===`tool/call`||e.type===`tool/result`||e.type===`llm/retry`||e.type===`step/start`||e.type===`step/end`||e.type===`turn/end`?{id:String(t),role:`update`}:null},start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-process start requires turn/start`);return{turn:t.event.data.turn,assistantStartByStep:/* @__PURE__ */ new Map,messageCountByStep:/* @__PURE__ */ new Map,messageCount:0,toolCallCount:0,subagentCount:0,contextCompactionCalls:/* @__PURE__ */ new Set}},update:(e,t)=>DS(e.state,t.event),publication:e=>{if(e.event.type===`assistant/live-chunk`){let t=e.event.data.chunk.type;return t===`usage`||t===`finish`?`none`:`animation-frame`}return`immediate`},buildLocationData:(e,t,n)=>{if(t!==`turn`)return null;let r=e.state??CS(e);if(r===void 0)return null;let i=SS(e);if(i===void 0)return null;let a=e.current.get(`chat`),o=i.steps.at(-1);if(n?.kind===`turn`&&n.key===`turn-process`&&a?.kind===`turn-process`&&a.data.answerAnchorSeq===null&&a.data.controlAnchorSeq===r.controlAnchorSeq&&a.data.messageCount===r.messageCount&&a.data.toolCallCount===r.toolCallCount&&a.data.subagentCount===r.subagentCount&&i.status!==`closed`&&o?.status!==`closed`)return n;let s=ES(r,i);return s===null?null:n?.kind===`turn`&&n.turn===s.turn&&n.key===`turn-process`&&Sh(n.value,s)?n:{kind:`turn`,turn:i.turn,key:`turn-process`,value:s}},buildViewNode:e=>{let t=SS(e),n=t?.data.get(`turn-process`);if(t===void 0||n===void 0)return null;let r=e.current.get(`chat`),i=e.state;return r?.kind===`turn-process`&&i!==void 0&&r.data.answerAnchorSeq===null&&r.data.controlAnchorSeq===i.controlAnchorSeq&&r.data.messageCount===i.messageCount&&r.data.toolCallCount===i.toolCallCount&&r.data.subagentCount===i.subagentCount&&t.status!==`closed`&&t.steps.at(-1)?.status!==`closed`&&r.location===(e.start?.location??e.matches[0]?.location)?r:Oy(e,`turn-process`,n.controlAnchorSeq+Ey.processControl,n)}};function kS(e){let t=OS.match.bind(OS);e.uiConversation.events.register({...OS,match:{"turn/start":t,"assistant/live-chunk":t,"assistant/message":t,"tool/call":t,"tool/result":t,"llm/retry":t,"step/start":t,"step/end":t,"turn/end":t}})}function AS(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(r.type===`chunk`&&r.chunk.type===t)return r.chunk}}function jS(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function MS(e){let t=0;for(let n of e)if(t+=n,!Number.isSafeInteger(t))return;return t}function NS(e){let{provider:t,model:n}=e.source;return t.length>0&&n.length>0?{provider:t,model:n}:void 0}function PS(e){return AS(e,`usage`)?.usage}function FS(e,t){let{inputTokens:n,outputTokens:r,cacheReadTokens:i,cacheWriteTokens:a,reasoningTokens:o,totalTokens:s}=e;if(!jS(n)||!jS(r)||i!==void 0&&!jS(i)||a!==void 0&&!jS(a)||o!==void 0&&(!jS(o)||o>r))return;let c=MS([n,...i===void 0?[]:[i],...a===void 0?[]:[a]]);if(c===void 0)return;let l;if(s!==void 0){if(!jS(s))return;let e=s-r;if(!jS(e)||e<c||i!==void 0&&a!==void 0&&e!==c)return;l=s}else{if(i===void 0||a===void 0)return;let e=MS([c,r]);if(e===void 0)return;l=e}return{inputTokens:n,outputTokens:r,totalTokens:l,...i===void 0?{}:{cacheReadTokens:i},...a===void 0?{}:{cacheWriteTokens:a},...o===void 0?{}:{reasoningTokens:o},...t===void 0?{}:{route:t}}}function IS(e){if(e.length===0)return;let t=MS(e.map(e=>e.inputTokens)),n=MS(e.map(e=>e.outputTokens)),r=MS(e.map(e=>e.totalTokens));if(t===void 0||n===void 0||r===void 0)return;let i=e.map(e=>e.cacheReadTokens),a=e.map(e=>e.cacheWriteTokens),o=e.map(e=>e.reasoningTokens),s=i.every(jS)?MS(i):void 0,c=a.every(jS)?MS(a):void 0,l=o.every(jS)?MS(o):void 0,u,d=e.map(e=>e.route);if(d.every(e=>e!==void 0)){let e=/* @__PURE__ */ new Map;for(let t of d)e.set(`${t.provider}\0${t.model}`,t);u=[...e.values()]}return{uncachedInputTokens:t,outputTokens:n,totalTokens:r,...s===void 0?{}:{cacheReadTokens:s},...c===void 0?{}:{cacheWriteTokens:c},...l===void 0?{}:{reasoningTokens:l},...u===void 0?{}:{routes:u}}}function LS(e,t,n){return e.turn===t&&e.step===n}function RS(e){let t={kind:`idle`},n=[],r,i=!1,a=!1,o=e=>{if(t.kind!==`open`||t.sample===void 0)return!1;let r=FS(t.sample,e);return r!==void 0&&(n.push(r),!0)};for(let n of e){if(a)break;if(n.type===`turn/start`)r!==void 0||t.kind!==`idle`?a=!0:r=n.data.turn;else{if(r===void 0){a=!0;break}if(n.type===`turn/end`)n.data.turn!==r||t.kind!==`idle`||i?a=!0:i=!0;else{if(i){a=!0;break}if(n.type===`step/start`)n.data.turn!==r||t.kind!==`idle`?a=!0:t={kind:`open`,turn:r,step:n.data.step};else if(n.type===`llm/retry-started`)n.data.turn!==r||t.kind!==`settled`||t.by!==`retry`||!LS(t,n.data.turn,n.data.step)?a=!0:t={kind:`open`,turn:r,step:n.data.step};else if(n.type===`assistant/attempt`){if(n.data.turn!==r||t.kind!==`open`||!LS(t,n.data.turn,n.data.step)){a=!0;continue}let e=PS(n.data.stream)??t.sample;t={kind:`open`,turn:r,step:n.data.step,...e===void 0?{}:{sample:e}},o()?t={kind:`finishClosed`,turn:r,step:n.data.step}:a=!0}else if(n.type===`assistant/message`){if(n.data.turn!==r||t.kind!==`open`||!LS(t,n.data.turn,n.data.step)){a=!0;continue}let e=n.data.usage??PS(n.data.stream);e!==void 0&&(t={...t,sample:e}),o(NS(n.data.message))?t={kind:`settled`,turn:r,step:n.data.step,by:`message`}:a=!0}else if(n.type===`llm/retry`){if(n.data.turn!==r||t.kind===`idle`||!LS(t,n.data.turn,n.data.step)){a=!0;continue}(t.kind===`settled`||t.kind===`open`&&!o())&&(a=!0),a||(t={kind:`settled`,turn:r,step:n.data.step,by:`retry`})}else if(n.type===`step/end`){if(n.data.turn!==r||t.kind===`idle`||!LS(t,n.data.turn,n.data.step)){a=!0;continue}t.kind===`open`&&!o()&&(a=!0),a||(t={kind:`idle`})}}}}return a||!i||t.kind!==`idle`?void 0:IS(n)}function zS(e){return e.type!==`assistant/live-chunk`}function BS(e){if(e.type===`assistant/message`||e.type===`assistant/attempt`||e.type===`assistant/live-chunk`||e.type===`step/start`||e.type===`step/end`||e.type===`llm/retry`||e.type===`llm/retry-started`)return{turn:e.data.turn,step:e.data.step}}function VS(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function HS(e){return e.finalNode!==void 0&&e.blocks.some(e=>e.kind===`text`&&e.text.trim()!==``)}function US(e){let t=e.state===void 0?e.matches.find(e=>e.event.type===`turn/end`):e.state.end;if(t?.event.type!==`turn/end`)return null;let n=VS(e);if(n===void 0)return null;let r=n.steps.map(e=>e.data.get(`assistant-step`)).filter(e=>e!==void 0).filter(e=>e.finalNode!==void 0).sort((e,t)=>e.finalNode.seq-t.finalNode.seq),i=r.findLast(HS)??null,a=r.at(-1)?.finalNode.seq;for(let t of e.matches){let e=t.event,n=e.type===`tool/call`||e.type===`tool/result`&&e.surfaceOp===`append`||e.type===`turn/end`&&e.data.reason.kind===`error`||e.type===`llm/retry`?e.seq:void 0;n!==void 0&&(a===void 0||n>a)&&(a=n)}let o=e.start?.event.type===`turn/start`?RS(e.matches.map(e=>e.event).filter(zS)):void 0;return{turn:t.event.data.turn,seq:t.event.seq,time:t.event.time,closing:i,branchUnavailable:i===null||a!==i.finalNode.seq,...o===void 0?{}:{tokenUsage:o}}}let WS={kind:`turn-tail`,target:`chat`,match:e=>{if(e.type===`turn/start`)return{id:String(e.data.turn),role:`start`};if(e.type===`turn/end`||e.type===`tool/call`||e.type===`tool/result`)return{id:String(e.data.turn),role:`update`};let t=BS(e);return t===void 0?null:{id:String(t.turn),role:`update`}},start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-tail start requires turn/start`);return{turn:t.event.data.turn}},update:(e,t)=>t.event.type===`turn/end`?{...e.state,end:t}:e.state,publication:e=>e.event.type===`turn/end`?`immediate`:`none`,buildLocationData:(e,t)=>{if(t!==`turn`)return null;let n=US(e);return n===null?null:{kind:`turn`,turn:n.turn,key:`turn-tail`,value:n}},buildViewNode:e=>{let t=VS(e)?.data.get(`turn-tail`);return t===void 0?null:Oy(e,`turn-tail`,t.seq+Ey.finalizedFollowup,t)}};function GS(e){let t=WS.match.bind(WS);e.uiConversation.events.register({...WS,match:{"turn/start":t,"turn/end":t,"tool/call":t,"tool/result":t,"assistant/message":t,"assistant/attempt":t,"assistant/live-chunk":t,"step/start":t,"step/end":t,"llm/retry":t,"llm/retry-started":t}})}function KS(e){return e===`read`?`read`:e===`read_image`?`readImage`:e===`grep`||e===`glob`||e.endsWith(`_inspect`)?`search`:e===`write`?`write`:e===`edit`||e===`apply_patch`?`edit`:[`bash`,`pwsh`,`exec_command`,`write_stdin`].includes(e)||e.startsWith(`terminal_`)?`commands`:e===`run_code`?`code`:e===`web_search`?`webSearch`:e===`web_fetch`?`webFetch`:e===`subagent`||e.startsWith(`subagent_`)?`subagents`:[`todo_write`,`create_goal`,`update_goal`,`get_goal`].includes(e)?`plan`:e===`ask_user_question`||e===`request_user_input`?`questions`:`tools`}let qS=new Intl.Segmenter(void 0,{granularity:`grapheme`}),JS=[`title`,`description`,`objective`,`task`,`task_name`,`name`,`question`,`questions`,`prompt`,`message`,`command`,`cmd`,`queries`,`query`,`pattern`,`url`,`uri`,`file_path`,`path`,`target`,`action`,`status`];function YS(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=160)return{text:t,truncated:!1};let n=[];for(let{segment:e}of qS.segment(t)){if(n.length===160)return{text:`${n.slice(0,159).join(``).trimEnd()}…`,truncated:!0};n.push(e)}return{text:t,truncated:!1}}function XS(e){return YS(typeof e==`string`?e:Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(`, `):``).text}function ZS(e,t){let n=512;for(;;){let r=e.textPrefix(t,n);if(r===void 0)return;let i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319){let i=e.textPrefix(t,n+1),a=i.charCodeAt(r.length);a>=56320&&a<=57343?(r=i,n++):i.length===r.length&&!e.isSealed&&!e.complete(t)&&(r=r.slice(0,-1))}let a=YS(r);if(a.truncated||!e.stringExceeds(t,n))return a.text;n*=2}}function QS(e){if(!Array.isArray(e))return``;for(let t of e){if(typeof t!=`object`||!t)continue;let e=XS(Reflect.get(t,`question`));if(e!==``)return e}return``}function $S(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.kind===`assistant-step`&&n.data.status===`running`)for(let e=n.data.blocks.length-1;e>=0;e--){let t=n.data.blocks[e];if(t?.kind!==`reasoning`)continue;let r=t.text.split(/\r?\n[\t ]*\r?\n/);for(let e=r.length-1;e>=0;e--){let t=XS(r[e]?.replaceAll(`**`,``));if(t!==``)return t}}}return``}function eC(e,t){for(let e of JS){if(!t.has(e))continue;let n=e===`questions`?QS(t.value(e)):ZS(t,e)??XS(t.value(e));if(n!==``)return n}return t.closed()?XS(e):``}function tC(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r,i=``,a=-1/0,o,s=e=>{if(n.has(e.callId))return;n.add(e.callId);let c=ab(e)?e:e.call;if(c!==null){let n=KS(c.name);ab(e)&&e.time>=a&&(r=n,o=e.phase===`preparing`,i=eC(e.name,e.args),a=e.time),t.set(n,(t.get(n)??0)+1)}for(let t of e.subCalls)s(t)};for(let t of e)t.kind===`tool-call`&&s(t.data.root);return r===void 0&&(i=$S(e)),{counts:[...t].map(([e,t])=>({kind:e,count:t})).sort((e,t)=>t.count-e.count),running:r,runningDetail:i,...o?{preparing:!0}:{}}}let nC=/* @__PURE__ */ new Set([`user`,`steering`,`turn-trigger`,`model-retry`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function rC(e){let t=e.location;return t.kind===`turn`||t.kind===`step`?t.turn.turn:void 0}function iC(e){return nC.has(e.kind)||e.kind===`tool-call`&&wh(e.data.root.name)}function aC(e){return e.kind===`assistant-step`&&e.data.blocks.some(e=>e.kind===`reasoning`&&e.text.trim()!==``)}function oC(e){return e.kind===`assistant-step`&&py(e.data.blocks)}function sC(e,t){return e.running===t.running&&e.runningDetail===t.runningDetail&&e.preparing===t.preparing&&e.counts.length===t.counts.length&&e.counts.every((e,n)=>e.kind===t.counts[n]?.kind&&e.count===t.counts[n].count)}function cC(e,t){return e.length===t.length&&e.every((e,n)=>e.key===t[n]?.key&&e.groupPart===t[n].groupPart)}function lC(e,t){return!ob(t)&&(e===void 0||!ob(e))?!1:e===void 0||e.kind!==t.kind||rC(e)!==rC(t)||ob(e)!==ob(t)||aC(e)!==aC(t)||oC(e)!==oC(t)}function uC(e,t){let n=e.readNode(t);if(n===void 0)throw Error(`Chat grouping input is missing Node ${t}`);return n}function dC(e,t){let n=/* @__PURE__ */ new Set;for(let r of t){let t=uC(e,r);t.kind===`question-reply`&&n.add(t.id)}return n}var fC=class{key;turn;members;nodes=[];forceClosed=!1;sameTurnFollowed=!1;snapshot;constructor(e,t,n){this.key=e,this.turn=t,this.members=n,this.snapshot={key:e,members:n,data:{turn:t,closed:!1,summary:{counts:[],running:void 0,runningDetail:``}}}}get isForceClosed(){return this.forceClosed}get isSameTurnFollowed(){return this.sameTurnFollowed}refresh(e,t,n,r){this.forceClosed=t,this.sameTurnFollowed=n;let i=this.members.map(t=>uC(e,t.key)),a=i.length===this.nodes.length&&i.every((e,t)=>e===this.nodes[t]),o=this.snapshot.data,s=r===`closed`||t||n&&r!==`open`,c=a&&(!o.closed||s)?o.summary:tC(i),l=s||n&&c.running===void 0,u=l?{counts:c.counts,running:void 0,runningDetail:``}:c;this.nodes=i,(o.closed!==l||!sC(o.summary,u))&&(this.snapshot={key:this.key,members:this.members,data:{turn:this.turn,closed:l,summary:u}})}},pC=class{turn;groups=/* @__PURE__ */ new Map;membership=/* @__PURE__ */ new Map;roots=/* @__PURE__ */ new Map;lastTurnStatus;constructor(e){this.turn=e}references(e){return this.roots.get(e)??[]}snapshots(){return[...this.groups.values()].map(e=>e.snapshot)}refresh(e,t){let n=/* @__PURE__ */ new Set;for(let e of t){let t=this.membership.get(e);t!==void 0&&n.add(t)}let r=e.timeline.turns.get(this.turn)?.status;if(r!==this.lastTurnStatus){for(let e of this.groups.values())n.add(e.key);this.lastTurnStatus=r}let i=[];for(let t of n){let n=this.groups.get(t),a=n.snapshot;n.refresh(e,n.isForceClosed,n.isSameTurnFollowed,r),n.snapshot!==a&&i.push(n.snapshot)}return i}rebuild(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=[],o=[],s=e.timeline.turns.get(this.turn)?.status;this.lastTurnStatus=s;let c=(e,t)=>{n.set(e,[...n.get(e)??[],t])},l=(n,l)=>{let u=a[0];if(u===void 0)return;let d=this.extendedGroup(a,t)?.key??$g(JSON.stringify([`process`,u.key,u.groupPart??null])),f=this.groups.get(d),p=f?.snapshot,m=f!==void 0&&cC(f.members,a)?f:new fC(d,this.turn,a);m.refresh(e,n,l,s),r.set(m.key,m),c(u.key,{kind:`group`,key:m.key});for(let e of a)i.set(e.key,m.key);m.snapshot!==p&&o.push(m.snapshot),a=[]},u,d=!1,f=e.readTurn(this.turn),p=dC(e,f);for(let t of f){let n=mC(e,t);u!==void 0&&n.previous!==u&&l(!0,!1),u=t,d=n.next!==void 0;let r=uC(e,t);r.kind===`turn-trigger`&&p.has(r.id)||(iC(r)?(l(!1,!0),c(t,{kind:`node`,key:t})):r.kind===`turn-process`?c(a[0]?.key??t,{kind:`node`,key:t}):r.kind===`assistant-step`?(aC(r)&&a.push({kind:`node`,key:t,groupPart:`reasoning`}),oC(r)&&(l(!1,!0),c(t,{kind:`node`,key:t,groupPart:`response`}))):a.push({kind:`node`,key:t}))}l(d,!1);let m=[...this.groups.keys()].filter(e=>!r.has(e));return this.groups=r,this.membership=i,this.roots=n,{upserts:o,removes:m}}extendedGroup(e,t){let n=e.findIndex(e=>!t.has(e.key)),r=e[n];if(r===void 0)return;let i=this.membership.get(r.key),a=i===void 0?void 0:this.groups.get(i);if(!(a===void 0||n+a.members.length>e.length)){for(let t=0;t<a.members.length;t++){let r=a.members[t],i=e[n+t];if(r.key!==i.key||r.groupPart!==i.groupPart)return}for(let r=n+a.members.length;r<e.length;r++)if(!t.has(e[r].key))return;return a}}};function mC(e,t){let n=e.readPosition(t);if(n===void 0)throw Error(`Chat grouping order is missing position for Node ${t}`);return n}var hC=class{turns=/* @__PURE__ */ new Map;order=[];pending=null;accept(e){if(e.kind===`replace`){let t=new Set(this.order),n=new Set(e.order.filter(e=>!t.has(e))),r=/* @__PURE__ */ new Map;for(let t of e.order){let i=mC(e,t).turn;if(i===void 0||r.has(i))continue;let a=this.turns.get(i)??new pC(i);a.rebuild(e,n),r.set(i,a)}this.turns=r,this.order=e.order,this.pending={entries:this.rootEntries(e),groups:{kind:`replace`,snapshots:[...r.values()].flatMap(e=>e.snapshots())}};return}let t=new Set(e.changedTurnOrders),n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Map,i=e=>{let t=r.get(e);return t===void 0&&(t=/* @__PURE__ */ new Set,r.set(e,t)),t};for(let r of e.changes){let e=r.previous,a=r.current,o=rC(a);if((e===void 0||!ob(e))&&n.add(a.key),lC(e,a)){let n=e===void 0?void 0:rC(e);n!==void 0&&t.add(n),o!==void 0&&t.add(o)}o!==void 0&&i(o).add(a.key)}for(let t of e.changedTurns)i(t);let a=[],o=[];for(let r of t){let t=this.turns.get(r)??new pC(r),i=t.rebuild(e,n);a.push(...i.upserts),o.push(...i.removes),e.readTurn(r).length===0?this.turns.delete(r):this.turns.set(r,t)}for(let[n,i]of r)t.has(n)||a.push(...this.turns.get(n)?.refresh(e,i)??[]);let s=e.order!==this.order||t.size>0;this.order=e.order;let c=new Set(a.map(e=>e.key));this.pending=s||a.length>0||o.length>0?{...s?{entries:this.rootEntries(e)}:{},groups:{kind:`apply`,upserts:a,removes:o.filter(e=>!c.has(e))}}:null}rootEntries(e){let t=dC(e,e.order.filter(t=>mC(e,t).turn===void 0));return e.order.flatMap(n=>{let r=mC(e,n).turn;if(r===void 0){let r=uC(e,n);return r.kind===`turn-trigger`&&t.has(r.id)?[]:[{kind:`node`,key:n}]}let i=this.turns.get(r);if(i===void 0)throw Error(`Chat grouping order is missing Turn ${r}`);return i.references(n)})}output(){return this.pending}};let gC={kind:`process-groups`,target:`chat`,create:()=>new hC,update:(e,t)=>(e.state.accept(t),e.state),buildGroups:e=>e.state.output()};function _C(e){Dx(e),Nx(e),Rx(e),rb(e),kS(e),oS(e),px(e),gx(e),Hx(e),dS(e),gS(e),GS(e),vx(e),tx(e),e.uiConversation.groups.register(gC)}function vC({useNotice:e,dismissNotice:t,keepNoticeOpen:n,renderSlotChain:r,t:i}){let a=e(e=>e);if(a===null)return null;let o={code:a.code,message:i(`message.failure.quota`),dismiss:t,keepOpen:n};return/* @__PURE__ */ (0,f.jsx)(d.Fragment,{children:r(`shell.quota-notice`,o,{fallback:/* @__PURE__ */ (0,f.jsx)(p.Toast,{text:o.message,icon:/* @__PURE__ */ (0,f.jsx)(p.IconWarningOutlineRegular,{size:18}),onDone:t})})},`quota-notice-${String(a.seq)}`)}function yC(e){return e==null}function bC(e){return e&&typeof e==`object`&&!Array.isArray(e)}function xC(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function SC(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function CC(e,t,n){if(!t)return{...e};let r={};for(let i of t)(n||e[i]!==void 0)&&(r[i]=e[i]);return r}let wC=Symbol.for(`cosmokit.volatile.write`);function TC(e,t=/* @__PURE__ */ new Set){if(typeof e==`function`)throw TypeError(`volatile config cannot contain functions`);if(typeof e!=`object`||!e)return e;if(t.has(e))throw TypeError(`volatile config cannot contain cycles`);t.add(e);try{if(Array.isArray(e))return Object.freeze(e.map(e=>TC(e,t)));if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`volatile config objects must be plain objects or arrays`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,TC(n,t)])))}finally{t.delete(e)}}function EC(e){let t=TC(e);return Object.freeze({get:()=>t,[wC]:e=>{t=e}})}function DC(e){return typeof e==`object`&&!!e&&wC in e}function OC(e,t){return arguments.length===1?t=>OC(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function kC(e){return OC(`ArrayBuffer`,e)||OC(`SharedArrayBuffer`,e)}function AC(e){return kC(e)||ArrayBuffer.isView(e)}let jC;(function(e){e.is=kC,e.isSource=AC;function t(e){return ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}e.fromSource=t;function n(e){if(e=t(e),typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let n=``,r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)n+=String.fromCharCode(r[e]);return btoa(n)}e.toBase64=n;function r(e){return typeof Buffer<`u`?t(Buffer.from(e,`base64`)):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}e.fromBase64=r;function i(e){return e=t(e),typeof Buffer<`u`?Buffer.from(e).toString(`hex`):Array.from(new Uint8Array(e),e=>e.toString(16).padStart(2,`0`)).join(``)}e.toHex=i;function a(e){if(typeof Buffer<`u`)return t(Buffer.from(e,`hex`));let n=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(`${n[e]}${n[e+1]}`,16));return Uint8Array.from(r).buffer}e.fromHex=a})(jC||={}),jC.fromBase64,jC.toBase64,jC.fromHex,jC.toHex;function MC(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(OC(`Date`,e))return new Date(e.valueOf());if(OC(`RegExp`,e))return new RegExp(e.source,e.flags);if(kC(e))return e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let n=t.get(e);if(n)return n;if(Array.isArray(e)){let n=[];return t.set(e,n),e.forEach((e,r)=>{n[r]=Reflect.apply(MC,null,[e,t])}),n}let r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(let n of Reflect.ownKeys(e)){let i={...Reflect.getOwnPropertyDescriptor(e,n)};`value`in i&&(i.value=Reflect.apply(MC,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function NC(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(DC(e)||DC(t))return DC(e)&&DC(t);if(!n&&yC(e)&&yC(t))return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||!t||r.has(e))return!1;function a(n,r){return n(e)?n(t)?r(e,t):!1:!n(t)&&void 0}r.add(e);try{return a(Array.isArray,(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0})??a(OC(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(OC(`URL`),(e,t)=>e.href===t.href)??a(OC(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(kC,(e,t)=>{if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0})??((!n||[e,t].every(e=>Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null))&&Object.keys({...e,...t}).every(n=>i(e[n],t[n])))}finally{r.delete(e)}}return i(e,t)}let PC;(function(e){e.millisecond=1;let t=e.second=1e3,n=e.minute=t*60,r=e.hour=n*60,i=e.day=r*24,a=e.week=i*7,o=(/* @__PURE__ */ new Date()).getTimezoneOffset();function s(e){o=e}e.setTimezoneOffset=s;function c(){return o}e.getTimezoneOffset=c;function l(e=/* @__PURE__ */ new Date,t){return typeof e==`number`&&(e=new Date(e)),t===void 0&&(t=o),Math.floor((e.valueOf()/n-t)/1440)}e.getDateNumber=l;function u(e,t){let r=new Date(e*i);return t===void 0&&(t=o),new Date(+r+t*n)}e.fromDateNumber=u;let d=RegExp(`^${[`w(?:eek(?:s)?)?`,`d(?:ay(?:s)?)?`,`h(?:our(?:s)?)?`,`m(?:in(?:ute)?(?:s)?)?`,`s(?:ec(?:ond)?(?:s)?)?`].map(e=>`(\\d+(?:\\.\\d+)?${e})?`).join(``)}$`);function f(e){let o=d.exec(e);return o?(parseFloat(o[1])*a||0)+(parseFloat(o[2])*i||0)+(parseFloat(o[3])*r||0)+(parseFloat(o[4])*n||0)+(parseFloat(o[5])*t||0):0}e.parseTime=f;function p(e){let t=f(e);return t?e=Date.now()+t:/^\d{1,2}(:\d{1,2}){1,2}$/.test(e)?e=`${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${e}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(e)&&(e=`${(/* @__PURE__ */ new Date()).getFullYear()}-${e}`),e?new Date(e):/* @__PURE__ */ new Date}e.parseDate=p;function m(e){let a=Math.abs(e);return a>=i-r/2?Math.round(e/i)+`d`:a>=r-n/2?Math.round(e/r)+`h`:a>=n-t/2?Math.round(e/n)+`m`:a>=t?Math.round(e/t)+`s`:e+`ms`}e.format=m;function h(e,t=2){return e.toString().padStart(t,`0`)}e.toDigits=h;function g(e,t=/* @__PURE__ */ new Date){return e.replace(`yyyy`,t.getFullYear().toString()).replace(`yy`,t.getFullYear().toString().slice(2)).replace(`MM`,h(t.getMonth()+1)).replace(`dd`,h(t.getDate())).replace(`hh`,h(t.getHours())).replace(`mm`,h(t.getMinutes())).replace(`ss`,h(t.getSeconds())).replace(`SSS`,h(t.getMilliseconds(),3))}e.template=g})(PC||={});let FC=Symbol.for(`schemastery`),IC=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var Q=class extends TypeError{options;name=`ValidationError`;constructor(e,t){let n=`$`;for(let e of t.path||[])typeof e==`string`?n+=`.`+e:typeof e==`number`?n+=`[`+e+`]`:typeof e==`symbol`&&(n+=`[Symbol(${e.toString()})]`);n.startsWith(`.`)&&(n=n.slice(1)),super((n===`$`?``:`${n} `)+e),this.options=t}static is(e){return!!e?.[IC]}};Object.defineProperty(Q.prototype,IC,{value:!0});let $=function(e){let t=function(e,n={}){return $.resolve(e,t,n)[0]};if(e.refs){let t=SC(e.refs,e=>new $(e)),n=e=>t[e];for(let e in t){let r=t[e];r.sKey=n(r.sKey),r.inner=n(r.inner),r.list=r.list&&r.list.map(n),r.dict=r.dict&&SC(r.dict,n)}return t[e.uid]}if(Object.assign(t,e),typeof t.callback==`string`)try{t.callback=Function(`return `+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,$.prototype),t.meta||={},t.toString=t.toString.bind(t),t};$.prototype=Object.create(Function.prototype),$.prototype[FC]=!0,Object.defineProperty($.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:$.resolve(e,this,{})[0]}}catch(e){if(Q.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),$.ValidationError=Q,$.prototype.toJSON=function(){if(globalThis.__schemastery_refs__)return globalThis.__schemastery_refs__[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));let e={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,e},$.prototype.set=function(e,t){return this.dict[e]=t,this},$.prototype.push=function(e){return this.list.push(e),this};function LC(e,t){let n=typeof e==`string`?{"":e}:{...e};for(let e in t){let r=t[e];r?.$description||r?.$desc?n[e]=r.$description||r.$desc:typeof r==`string`&&(n[e]=r)}return n}function RC(e){return e?.$value??e?.$inner}function zC(e){return xC(e??{},e=>!e.startsWith(`$`))}$.prototype.i18n=function(e){let t=$(this),n=LC(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=SC(t.dict,(t,n)=>t.i18n(SC(e,e=>RC(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(SC(e,(e={})=>Array.isArray(RC(e))?RC(e)[n]:Array.isArray(e)?e[n]:zC(e)))),t.inner&&=t.inner.i18n(SC(e,e=>RC(e)?RC(e):zC(e))),t.sKey&&=t.sKey.i18n(SC(e,e=>e?.$key)),t},$.prototype.extra=function(e,t){let n=$(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign($.prototype,{[e](t=!0){let n=$(this);return n.meta={...n.meta,[e]:t},n}});$.prototype.deprecated=function(){let e=$(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},$.prototype.experimental=function(){let e=$(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},$.prototype.pattern=function(e){let t=$(this),n=CC(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},$.prototype.simplify=function(e){if(DC(e)&&(e=e.get()),NC(e,this.meta.default,this.type===`dict`))return null;if(yC(e))return e;if(this.type===`object`||this.type===`dict`){let t={};for(let n in e){let r=(this.type===`object`?this.dict[n]:this.inner)?.simplify(e[n]);(this.type===`dict`||!yC(r))&&(t[n]=r)}return NC(t,this.meta.default,this.type===`dict`)?null:t}if(this.type===`array`||this.type===`tuple`){let t=[];return e.forEach((e,n)=>{let r=this.type===`array`?this.inner:this.list[n],i=r?r.simplify(e):e;t.push(i)}),t}if(this.type===`intersect`){let t={};for(let n of this.list)Object.assign(t,n.simplify(e));return t}if(this.type===`union`)for(let t of this.list)try{return $.resolve(e,t,{}),t.simplify(e)}catch{}return e},$.prototype.toString=function(e){return JC[this.type]?.(this,e)??`Schema<${this.type}>`},$.prototype.role=function(e,t){let n=$(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign($.prototype,{[e](t){let n=$(this);return n.meta={...n.meta,[e]:t},n}});$.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let BC={},VC=Symbol(`checked-volatile-schema`);function HC(e,t=[],n=!1,r=/* @__PURE__ */ new Map){let i=r.get(e)??/* @__PURE__ */ new Set;if(i.has(n))return;if(i.add(n),r.set(e,i),e.meta?.volatile&&n)throw new Q(`volatile fields require a fixed object path without an enclosing volatile field`,{path:t});let a=n||!!e.meta?.volatile;if(e.dict)for(let[n,i]of Object.entries(e.dict))HC(i,[...t,n],a,r);if(e.sKey&&HC(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[FC])&&HC(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)HC(e.list[n],[...t,String(n)],!0,r)}$.extend=function(e,t){BC[e]=t},$.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[VC]||(HC(t,n.path),n={...n,[VC]:!0}),t.meta?.volatile){let i=$(t);i.meta={...t.meta,volatile:!1};let[a,o]=$.resolve(e,i,n,r);try{return[EC(a),o]}catch(e){throw new Q(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(yC(e)&&t.type!==`lazy`){if(t.meta.required)throw new Q(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&yC(i);)r=r.list[0],i=r?.meta.default;if(yC(i))return[e];e=MC(i)}let i=BC[t.type];if(!i)throw new Q(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},$.from=function(e){if(yC(e))return $.any();if([`string`,`number`,`boolean`].includes(typeof e))return $.const(e).required();if(e[FC])return e;if(typeof e==`function`)switch(e){case String:return $.string().required();case Number:return $.number().required();case Boolean:return $.boolean().required();case Function:return $.function().required();default:return $.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},$.lazy=function(e){let t=new $({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[FC]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},$.natural=function(){return $.number().step(1).min(0)},$.percent=function(){return $.number().step(.01).min(0).max(1).role(`slider`)},$.date=function(){return $.union([$.is(Date),$.transform($.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new Q(`invalid date "${e}"`,t);return n},!0)])},$.regExp=function(e=``){return $.union([$.is(RegExp),$.transform($.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new Q(e.message,n)}},!0)])},$.arrayBuffer=function(e){return $.union([$.is(ArrayBuffer),$.is(SharedArrayBuffer),$.transform($.any(),(e,t)=>{if(jC.isSource(e))return jC.fromSource(e);throw new Q(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[$.transform($.string(),(t,n)=>{try{return e===`base64`?jC.fromBase64(t):jC.fromHex(t)}catch(e){throw new Q(e.message,n)}},!0)]:[]])},$.extend(`lazy`,(e,t,n,r)=>(t.inner[FC]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},HC(t.inner,n.path,!0)),$.resolve(e,t.inner,n,r))),$.extend(`any`,e=>[e]),$.extend(`never`,(e,t,n)=>{throw new Q(`expected nullable but got ${e}`,n)}),$.extend(`const`,(e,{value:t},n)=>{if(NC(e,t))return[t];throw new Q(`expected ${t} but got ${e}`,n)});function UC(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new Q(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new Q(`expected ${n} >= ${o} but got ${e}`,r)}$.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new Q(`expected string but got ${e}`,n);if(t.pattern){let r=new RegExp(t.pattern.source,t.pattern.flags);if(!r.test(e))throw new Q(`expect string to match regexp ${r}`,n)}return UC(e.length,t,`string length`,n),[e]});function WC(e,t){let n=e.toString();if(n.includes(`e`))return e*10**t;let r=n.indexOf(`.`);if(r===-1)return e*10**t;let i=n.slice(r+1),a=n.slice(0,r);return i.length<=t?+(a+i.padEnd(t,`0`)):+(a+i.slice(0,t)+`.`+i.slice(t))}function GC(e,t,n){if(n=Math.abs(n),!/^\d+\.\d+$/.test(n.toString()))return(e-t)%n===0;let r=n.toString().indexOf(`.`),i=n.toString().slice(r+1).length;return Math.abs(WC(e,i)-WC(t,i))%WC(n,i)===0}$.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new Q(`expected number but got ${e}`,n);UC(e,t,`number`,n);let{step:r}=t;if(r&&!GC(e,t.min??0,r))throw new Q(`expected number multiple of ${r} but got ${e}`,n);return[e]}),$.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new Q(`expected boolean but got ${e}`,n)}),$.extend(`bitset`,(e,{bits:t,meta:n},r)=>{let i=0,a=[];if(typeof e==`number`){i=e;for(let n in t)e&t[n]&&a.push(n)}else if(Array.isArray(e)){a=e;for(let e of a){if(typeof e!=`string`)throw new Q(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new Q(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),$.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new Q(`expected function but got ${e}`,n)}),$.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new Q(`expected ${t.name} but got ${e}`,n)}{if(yC(e))throw new Q(`expected ${t} but got ${e}`,n);let r=Object.getPrototypeOf(e);for(;r;){if(r.constructor?.name===t)return[e];r=Object.getPrototypeOf(r)}throw new Q(`expected ${t} but got ${e}`,n)}});function KC(e,t,n,r){try{let[i,a]=$.resolve(e[t],n,{...r,path:[...r.path||[],t]});return a!==void 0&&(e[t]=a),i}catch(i){if(!r?.autofix)throw i;return delete e[t],n.meta.volatile?EC(n.meta.default):n.meta.default}}$.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new Q(`expected array but got ${e}`,r);return UC(e.length,n,`array length`,r,!yC(t.meta.default)),[e.map((n,i)=>KC(e,i,t,r))]}),$.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!bC(e))throw new Q(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=$.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=KC(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),$.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new Q(`expected array but got ${e}`,n);let i=t.map((t,r)=>KC(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function qC(e,t){for(let n in t)n in e||(e[n]=t[n])}$.extend(`object`,(e,{dict:t},n,r)=>{if(!bC(e))throw new Q(`expected object but got ${e}`,n);let i={};for(let r in t){let a=KC(e,r,t[r],n);(!yC(a)||r in e)&&(i[r]=a)}return r||qC(i,e),[i]}),$.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return $.resolve(e,n,r,i)}catch(e){a.push(e)}throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),$.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=$.resolve(e,i,r,!0)[0];if(!yC(t)){if(yC(a))a=t;else if(typeof a!=typeof t)throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)qC(a??={},t);else if(a!==t)throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&bC(e)&&qC(a,e),[a]}),$.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=$.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let JC={};function YC(e,t,n){JC[e]=n,Object.assign($,{[e](...n){let r=new $({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??$.string();break;case`inner`:r.inner=$.from(n[t]);break;case`list`:r.list=n[t].map($.from);break;case`dict`:r.dict=SC(n[t],$.from);break;case`bits`:r.bits={};for(let e in n[t])typeof n[t][e]==`number`&&(r.bits[e]=n[t][e]);break;case`callback`:{let e=r.callback=n[t];e.toJSON||=()=>e.toString();break}case`constructor`:{let e=r.constructor=n[t];typeof e==`function`&&(e.toJSON||=()=>e.name);break}default:r[e]=n[t]}}),e===`object`||e===`dict`?r.meta.default={}:e===`array`||e===`tuple`?r.meta.default=[]:e===`bitset`&&(r.meta.default=0),r}})}YC(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),YC(`any`,[],()=>`any`),YC(`never`,[],()=>`never`),YC(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),YC(`string`,[],()=>`string`),YC(`number`,[],()=>`number`),YC(`boolean`,[],()=>`boolean`),YC(`bitset`,[`bits`],()=>`bitset`),YC(`function`,[],()=>`function`),YC(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),YC(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),YC(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),YC(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),YC(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),YC(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),YC(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let XC=`transcriptView`,ZC=[`compact`,`standard`,`detailed`,`verbose`],QC=[...ZC,`normal`,`expanded`],$C=`standard`,ew={linkOpening:$.union([`sidebar`,`new-tab`]).default(`sidebar`),[XC]:$.union([...QC]).loose()};$.object(ew);let tw=`@deepseek-ai/dsh-client-ui-chat/PreferenceRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(tw)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=tw,e.textContent=`.B8MZ0a_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.B8MZ0a_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.B8MZ0a_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.B8MZ0a_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.B8MZ0a_selector{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;touch-action:manipulation;user-select:none;-webkit-tap-highlight-color:transparent;border:none;flex-shrink:0;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.B8MZ0a_selector:active{background:var(--dsw-alias-interactive-bg-active)}.B8MZ0a_chevron{flex:none}@media (hover:hover) and (pointer:fine){.B8MZ0a_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}}@media (width<=640px){.B8MZ0a_row{gap:12px;min-height:44px;padding:12px 0}.B8MZ0a_rowText{padding-right:0}.B8MZ0a_selector{gap:8px;height:44px;min-height:44px;padding:0 12px;font-size:13.5px}}`,document.head.appendChild(e)}var nw={chevron:`B8MZ0a_chevron`,desc:`B8MZ0a_desc`,row:`B8MZ0a_row`,rowText:`B8MZ0a_rowText`,selector:`B8MZ0a_selector`,title:`B8MZ0a_title`};function rw({title:e,description:t,value:n,selectedLabel:r,options:i,onSelect:a}){let[o,s]=(0,d.useState)(!1),c=(0,d.useRef)(null),l=()=>{s(!1)},u=e=>{c.current?.focus({preventScroll:!0}),l(),a(e)},m=/* @__PURE__ */ (0,f.jsxs)(`button`,{ref:c,type:`button`,className:nw.selector,"aria-haspopup":`menu`,"aria-expanded":o,onClick:()=>{s(e=>!e)},children:[r,/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:nw.chevron})]});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:nw.row,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:nw.rowText,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:nw.title,children:e}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:nw.desc,children:t})]}),/* @__PURE__ */ (0,f.jsx)(p.Menu,{open:o,onClose:l,items:i,selectedId:n,onSelect:u,align:`end`,portal:!0,anchor:m})]})}let iw={compact:`settings.transcript.compact`,standard:`settings.transcript.standard`,detailed:`settings.transcript.detailed`,verbose:`settings.transcript.verbose`};function aw({useTranscriptView:e,setTranscriptView:t,t:n}){let r=e(e=>e);return/* @__PURE__ */ (0,f.jsx)(rw,{title:n(`settings.transcript.title`),description:n(`settings.transcript.description`),value:r,selectedLabel:n(iw[r]),options:ZC.map(e=>({id:e,label:n(iw[e])})),onSelect:e=>{t(e)}})}var ow=class{host;defaultMode;unsubscribe;mode;constructor(e,t=$C){this.host=e,this.defaultMode=t,this.mode=(0,m.createSnapshotStore)(t),this.unsubscribe=e.subscribe(()=>{this.adopt()}),this.adopt()}dispose(){this.unsubscribe()}setMode(e){this.mode.getSnapshot()!==e&&(this.mode.set(e),this.host.set(XC,e))}adopt(){let e=this.host.getSnapshot().value;if(e===void 0)return;let t=e.transcriptView,n=t===`normal`||t===`expanded`?`detailed`:t??this.defaultMode;this.mode.getSnapshot()!==n&&this.mode.set(n)}};let sw={compact:{mode:`compact`,foldCompletedTurns:!0,stepGrouping:`collapsed`,liveProcessDetail:!1,settledReasoningPreview:!1},standard:{mode:`standard`,foldCompletedTurns:!0,stepGrouping:`collapsed`,liveProcessDetail:!0,settledReasoningPreview:!0},detailed:{mode:`detailed`,foldCompletedTurns:!0,stepGrouping:`history`,liveProcessDetail:!0,settledReasoningPreview:!0},verbose:{mode:`verbose`,foldCompletedTurns:!1,stepGrouping:`none`,liveProcessDetail:!1,settledReasoningPreview:!0}};function cw(e){return{getSnapshot:()=>sw[e.getSnapshot()],subscribe:t=>e.subscribe(t)}}function lw({useLinkOpening:e,useBrowserAvailable:t,setLinkOpening:n,t:r}){let i=e(e=>e);return t(e=>e)?/* @__PURE__ */ (0,f.jsx)(rw,{title:r(`settings.links.title`),description:r(`settings.links.description`),value:i,selectedLabel:r(i===`sidebar`?`settings.links.sidebar`:`settings.links.newTab`),options:[{id:`sidebar`,label:r(`settings.links.sidebar`)},{id:`new-tab`,label:r(`settings.links.newTab`)}],onSelect:e=>{n(e)}}):null}let uw={getSnapshot:()=>void 0,subscribe:()=>()=>{}};function dw(e,t){let n=e?.source(t)??uw;return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let fw={hooks:{turnData:(e,{turnData:t})=>function(e){return dw(t,e)},disclosure:(e,{disclosureReset:t})=>tg(t)}},pw=[`slots`,`sessions`,`uiWorkspace`,`uiSession`,`uiConversation`,`locale`,`configForms`,`remote`,`remote.session`,`remote.workspaceFiles`,`sidebarRight`];function mw(e){let t=(0,m.createSnapshotStore)(null),n=0,r=(0,m.createSnapshotStore)(null),i=0;e.provide(`chatHandoffLauncher`,{open(e,t){r.set({seq:++i,sessionId:e,...t?.targetHarnessId===void 0?{}:{targetHarnessId:t.targetHarnessId},...t?.atSeq===void 0?{}:{atSeq:t.atSeq}})}});let a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new WeakMap,s=/* @__PURE__ */ new Set;e.effect(()=>async()=>{await Promise.all([...s].map(e=>e()))},`ui-chat: live quota notices`);let c=r=>{let i=o.get(r);if(i===void 0){let c=r.ctx.effect(()=>{let e=r.eventSource.subscribe(()=>{let{change:e}=r.eventSource.getSnapshot();if(e.kind===`append`)for(let{event:r}of e.entries){if(r.type!==`turn/end`||r.data.reason.kind!==`error`)continue;let{code:e}=r.data.reason.error;a.size>0||e!==`QUOTA`&&e!==`ACCOUNT_QUOTA`||t.set({code:e,seq:++n})}});return()=>{e(),o.delete(r),s.delete(c)}},`ui-chat: Provider binding quota notices`);s.add(c);let l=e.uiConversation.binding(r).target(`chat`);i={getSnapshot:()=>l.getSnapshot()??ue,subscribe:e=>l.subscribe(e)},o.set(r,i)}return i};_C(e),e.uiSession.provide({hooks:[`chat`],resolve:e=>({hooks:{chat:c(e)}})}),e.effect(()=>e.locale.register(Av,{zh:jv,en:Mv}),`ui-chat: dictionaries`);let l=e.locale.bind(Av),u=Dh(),d=/* @__PURE__ */ new Map,f=e.configForms.get(`ui-chat`),p=(0,m.createSnapshotStore)(f.getSnapshot().value?.linkOpening??`sidebar`);e.effect(()=>f.subscribe(()=>{let e=f.getSnapshot().value?.linkOpening;e!==void 0&&p.set(e)}));let h={getSnapshot:()=>e.get(`sidebarRightTabs`)?.get(`browser`)!==void 0,subscribe:t=>e.get(`sidebarRightTabs`)?.subscribe(t)??(()=>{})},g=t=>h.getSnapshot()?(e.sidebarRight.openTab(`browser`,{params:{url:t}}),!0):!1;e.inject([`sidebarRightTabs`],e=>{e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`link-opening`,order:17,locale:Av,inject:()=>({hooks:{linkOpening:p,browserAvailable:h},setLinkOpening:e=>{p.set(e),f.set(`linkOpening`,e).catch(()=>{})}})},lw))});let _=new ow(f,`dshDesktop`in globalThis?`standard`:$C),v=cw(_.mode);e.effect(()=>()=>{_.dispose()}),Ty(e,v),e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`transcript-view`,order:12,locale:Av,inject:()=>({hooks:{transcriptView:_.mode},setTranscriptView:e=>{_.setMode(e)}})},aw)),e.slots.inject(`conversation.view`,()=>e.slots.register({name:`conversation.view`,id:`chat`,order:0,label:()=>l(`view.chat`),locale:Av,children:{"conversation.chat.node":{kind:`keyed`,scope:`session`,inject:fw},"conversation.message.images":{kind:`single`,scope:`session`}},store:u,inject:t=>{let n=e.sessions.binding(t);if(n===void 0)throw Error(`ui-chat: unknown session "${t}"`);let i=n.session,a=c(n),o=e.uiConversation.binding(n),s=e.get(`chatMessageEditing`),l=e.get(`chatTurnDiffs`),u=e.get(`chatHandoff`),f=u!==void 0&&!String(t).startsWith(`web-remote:`)&&e.sessions.subagentAddress(t)===void 0;return{connection:e.get(`connection`),hooks:{presentation:v,browserAvailable:h,handoffRequest:r},keyedHooks:{chatNode:e=>a.getSnapshot().nodes.source(e),chatNodeProcess:e=>a.getSnapshot().nodes.processSource(e),chatGroup:e=>o.snapshot.getSnapshot().views.grouped(`chat`)?.groupSource(e)},fileMentions:n=>e.get(`chatFileMentions`)?.forClosing(n,t),openFile:async(n,r)=>{let i=e.sessions.list.getSnapshot().byId[t]?.cwd;if(r?.external||r?.reveal){let a=ne(i,n);if(!r.reveal||!A(a)){let r=await e.remote.workspaceFiles.stat(t,n);if(!r.ok)throw Error(r.error.message);a=r.value.absolutePath}let o=await e.remote.session.openWorkspacePath({sessionId:t,path:a,...r.reveal?{action:`reveal`}:{}});if(!o.ok)throw Error(o.error.message);return}let a=re(t,i,n);r?.line===void 0?e.sidebarRight.openResource(a):e.sidebarRight.openResource(a,{params:{line:r.line}}),await Promise.resolve()},openSkill:n=>{let r=e.sessions.scope(t);r!==void 0&&e.get(`inputTriggers`)?.sessionOf(r).openReference(`skill`,{ref:`/${n}`})},resolveLink:e.get(`chatLinks`)?.resolve,openLinkInSidebar:g,openExternalLink:e=>{p.getSnapshot()===`sidebar`&&g(e)||window.open(e,`_blank`,`noopener,noreferrer`)},loadOlder:()=>{i.loadOlder()},loadThrough:e=>i.loadThrough(e),loadImage:Object.assign(n=>e.uiConversation.imageUrl(t,n),{peek:n=>e.uiConversation.peekImageUrl(t,n)}),chatScroll:{save:e=>{e===null?d.delete(t):d.set(t,e)},read:()=>d.get(t)??null},loadTurnDiffs:l?(e,n)=>l.read(t,e,n):void 0,editMessage:s?(e,n)=>s.send(t,e,n):void 0,forkAt:n=>{let r=[...a.getSnapshot().timeline.turns.values()].find(e=>e.end?.seq===n)?.data.get(`turn-tail`)?.closing?.finalNode.messageId;return e.sessions.fork({sessionId:t,atSeq:n,increaseTitle:!0,onCreated:n=>{e.get(`productAnalytics`)?.track(`branch_session_click`,{session_id:n,parent_session_id:t,...r===void 0?{}:{parent_message_id:r},click_position:`footer`})}}).then(t=>{e.uiWorkspace.openSession(t)})},openSession:t=>{let n=t;e.sessions.list.getSnapshot().byId[n]===void 0?e.sessions.loadSummary(n).catch(()=>void 0).finally(()=>{e.uiWorkspace.openSession(n)}):e.uiWorkspace.openSession(n)},clearHandoffRequest:e=>{r.getSnapshot()?.seq===e&&r.set(null)},loadModelCatalog:f?async()=>{let t=await e.remote.session.modelCatalog(void 0);if(!t.ok)throw Error(t.error.message);return t.value}:void 0,handoff:f?async({atSeq:n,targetHarnessId:r,targetModel:i,targetThinkingOptionId:a})=>{let o=(await u.handoff({sessionId:t,...n===void 0?{}:{atSeq:n},targetHarnessId:r,...i===void 0?{}:{targetModel:i},...a===void 0?{}:{targetThinkingOptionId:a}})).sessionId;e.sessions.list.getSnapshot().byId[o]===void 0&&await e.sessions.loadSummary(o).catch(()=>void 0),e.uiWorkspace.openSession(o)}:void 0}}},Ov)),e.slots.inject(`shell.overlay`,()=>e.slots.register({name:`shell.overlay`,id:`chat.quota-notice`,locale:Av,children:{"shell.quota-notice":{kind:`chain`,scope:`root`}},inject:()=>({hooks:{notice:t},dismissNotice:()=>{a.clear(),t.set(null)},keepNoticeOpen:()=>{if(t.getSnapshot()===null)return()=>{};let e=Symbol(`ui-chat quota notice hold`);return a.add(e),()=>{a.delete(e)}}})},vC)),e.slots.inject(`conversation.input.dock`,()=>e.slots.register({name:`conversation.input.dock`,id:`file-changes`,order:5,locale:Av},D)),e.slots.inject(`conversation.approval.detail`,()=>e.slots.register({name:`conversation.approval.detail`},j))}return n.EMPTY_CHAT_SNAPSHOT=ue,n.apply=mw,n.inject=pw,n.isRunningTool=ab,n.isSettledTool=ib,t.exports}});
|