@codexhost/cli-darwin-x64 0.25.0 → 0.26.0-rc.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.
Files changed (50) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +174 -18
  4. package/app/console-web.js +543 -230
  5. package/app/desktop-controller.mjs +154 -5
  6. package/app/host-runtime.mjs +1064 -645
  7. package/app/plugins/antigravity/plugin.mjs +202 -19
  8. package/app/plugins/claude-code/plugin.mjs +195 -10
  9. package/app/plugins/codebuddy/plugin.mjs +154 -5
  10. package/app/plugins/codex-usage/plugin.mjs +154 -5
  11. package/app/plugins/copilot/plugin.mjs +154 -5
  12. package/app/plugins/cursor-cli/plugin.mjs +154 -5
  13. package/app/plugins/deepseek-harness/plugin.mjs +182 -36
  14. package/app/plugins/devin/plugin.mjs +154 -5
  15. package/app/plugins/grok/plugin.mjs +154 -5
  16. package/app/plugins/hermes/plugin.mjs +198 -20
  17. package/app/plugins/kimi-code/plugin.mjs +154 -5
  18. package/app/plugins/kiro-cli/plugin.mjs +154 -5
  19. package/app/plugins/omp/plugin.mjs +154 -5
  20. package/app/plugins/opencode/plugin.mjs +155 -9
  21. package/app/plugins/pi/plugin.mjs +296 -33
  22. package/app/plugins/qoder/plugin.mjs +154 -5
  23. package/app/plugins/qoder-cn/plugin.mjs +154 -5
  24. package/app/plugins/qwen-code/plugin.mjs +154 -5
  25. package/app/plugins/workbuddy/plugin.mjs +154 -5
  26. package/app/plugins/zcode/plugin.mjs +154 -5
  27. package/app/renderer-extension.js +1132 -330
  28. package/app/web/assets/{index-DUOvhHbV.js → index-Bl_9AU27.js} +70 -70
  29. package/app/web/assets/{index-CTCFIQbU.css → index-arwoPpaG.css} +1 -1
  30. package/app/web/codexhost-settings.js +230 -140
  31. package/app/web/index.html +2 -2
  32. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  33. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -10
  34. package/app/web/plugins/deepseek-ai__dsh-client-ui-brand-official/client.js +1 -1
  35. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +13 -13
  36. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +73 -73
  37. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +75 -75
  38. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  39. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +1 -1
  40. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +1 -1
  41. package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
  42. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  43. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +11 -11
  44. package/app/web-modules/server.mjs +14416 -13144
  45. package/bin/codexhost +0 -0
  46. package/libexec/CodexHost.app/Contents/Info.plist +2 -2
  47. package/libexec/CodexHost.app/Contents/MacOS/CodexHost +0 -0
  48. package/libexec/codexhost-shim +0 -0
  49. package/libexec/codexhost-updater +0 -0
  50. package/package.json +1 -1
@@ -119,22 +119,22 @@ function Bi(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...j(n)})}//
119
119
  function Vi(e,t){let n=/* @__PURE__ */ Hi(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(tt(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(tt(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
120
120
  function Hi(e,t){let n=new Qt({check:`custom`,...j(t)});return n._zod.check=e,n}function Ui(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??Rr,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function P(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);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,P(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Ki(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 Wi(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);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}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+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>
121
121
 
122
- 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)}}}function Gi(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)):Object.assign(i,s),Object.assign(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??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);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)}Object.assign(i,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??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}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:Ji(t,`input`,e.processors),output:Ji(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ki(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 Ki(r.element,n);if(r.type===`set`)return Ki(r.valueType,n);if(r.type===`lazy`)return Ki(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`)return Ki(r.innerType,n);if(r.type===`intersection`)return Ki(r.left,n)||Ki(r.right,n);if(r.type===`record`||r.type===`map`)return Ki(r.keyType,n)||Ki(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ki(r.in,n)||Ki(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ki(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ki(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ki(e,n))return!0;return!!(r.rest&&Ki(r.rest,n))}return!1}let qi=(e,t={})=>n=>{let r=Ui({...n,processors:t});return P(e,r),Wi(r,e),Gi(r,e)},Ji=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ui({...i??{},target:a,io:t,processors:n});return P(e,o),Wi(o,e),Gi(o,e)},Yi={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Xi=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Yi[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];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}))])}},Zi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Qi=(e,t,n,r)=>{n.type=`boolean`},$i=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},ea=(e,t,n,r)=>{n.not={}},ta=(e,t,n,r)=>{let i=e._zod.def,a=xe(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},na=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);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}},ra=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ia=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},aa=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=P(a.element,t,{...r,path:[...r.path,`items`]})},oa=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=P(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=P(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},sa=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>P(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ca=(e,t,n,r)=>{let i=e._zod.def,a=P(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=P(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},la=(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)=>P(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?P(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},ua=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=P(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=P(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=P(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},da=(e,t,n,r)=>{let i=e._zod.def,a=P(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`}]},fa=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},pa=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ma=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},ha=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ga=(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;P(o,t,r);let s=t.seen.get(e);s.ref=o},_a=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},va=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ya=(e,t,n,r)=>{let i=e._zod.innerType;P(i,t,r);let a=t.seen.get(e);a.ref=i},ba=/*@__PURE__*/ k(`ZodISODateTime`,(e,t)=>{An.init(e,t),L.init(e,t)});function xa(e){return/* @__PURE__ */ ci(ba,e)}let Sa=/*@__PURE__*/ k(`ZodISODate`,(e,t)=>{jn.init(e,t),L.init(e,t)});function Ca(e){return/* @__PURE__ */ li(Sa,e)}let wa=/*@__PURE__*/ k(`ZodISOTime`,(e,t)=>{Mn.init(e,t),L.init(e,t)});function Ta(e){return/* @__PURE__ */ ui(wa,e)}let Ea=/*@__PURE__*/ k(`ZodISODuration`,(e,t)=>{Nn.init(e,t),L.init(e,t)});function Da(e){return/* @__PURE__ */ di(Ea,e)}let Oa=/*@__PURE__*/ k(`ZodError`,(e,t)=>{rt.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>ot(e,t)},flatten:{value:t=>at(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Se,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Se,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),ka=/* @__PURE__ */ st(Oa),Aa=/* @__PURE__ */ ct(Oa),ja=/* @__PURE__ */ lt(Oa),Ma=/* @__PURE__ */ dt(Oa),Na=/* @__PURE__ */ pt(Oa),Pa=/* @__PURE__ */ mt(Oa),Fa=/* @__PURE__ */ ht(Oa),Ia=/* @__PURE__ */ gt(Oa),La=/* @__PURE__ */ _t(Oa),Ra=/* @__PURE__ */ vt(Oa),za=/* @__PURE__ */ yt(Oa),Ba=/* @__PURE__ */ bt(Oa),Va=/* @__PURE__ */ new WeakMap;function Ha(e,t,n){let r=Object.getPrototypeOf(e),i=Va.get(r);if(i||(i=/* @__PURE__ */ new Set,Va.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}let F=/*@__PURE__*/ k(`ZodType`,(e,t)=>(M.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Ji(e,`input`),output:Ji(e,`output`)}}),e.toJSONSchema=qi(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>ka(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ja(e,t,n),e.parseAsync=async(t,n)=>Aa(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ma(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Na(e,t,n),e.decode=(t,n)=>Pa(e,t,n),e.encodeAsync=async(t,n)=>Fa(e,t,n),e.decodeAsync=async(t,n)=>Ia(e,t,n),e.safeEncode=(t,n)=>La(e,t,n),e.safeDecode=(t,n)=>Ra(e,t,n),e.safeEncodeAsync=async(t,n)=>za(e,t,n),e.safeDecodeAsync=async(t,n)=>Ba(e,t,n),Ha(e,`ZodType`,{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(os(e,t))},superRefine(e,t){return this.check(ss(e,t))},overwrite(e){return this.check(/* @__PURE__ */ Mi(e))},optional(){return zo(this)},exactOptional(){return Vo(this)},nullable(){return Uo(this)},nullish(){return zo(Uo(this))},nonoptional(e){return Yo(this,e)},array(){return B(this)},or(e){return Eo([this,e])},and(e){return ko(this,e)},transform(e){return $o(this,Lo(e))},default(e){return Go(this,e)},prefault(e){return qo(this,e)},catch(e){return Zo(this,e)},pipe(e){return $o(this,e)},readonly(){return ts(this)},describe(e){let t=this.clone();return Rr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Rr.get(this);let t=this.clone();return Rr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Rr.get(e)?.description},configurable:!0}),e)),Ua=/*@__PURE__*/ k(`_ZodString`,(e,t)=>{vn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xi(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ha(e,`_ZodString`,{regex(...e){return this.check(/* @__PURE__ */ Ei(...e))},includes(...e){return this.check(/* @__PURE__ */ ki(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Ai(...e))},endsWith(...e){return this.check(/* @__PURE__ */ ji(...e))},min(...e){return this.check(/* @__PURE__ */ wi(...e))},max(...e){return this.check(/* @__PURE__ */ Ci(...e))},length(...e){return this.check(/* @__PURE__ */ Ti(...e))},nonempty(...e){return this.check(/* @__PURE__ */ wi(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ Di(e))},uppercase(e){return this.check(/* @__PURE__ */ Oi(e))},trim(){return this.check(/* @__PURE__ */ Pi())},normalize(...e){return this.check(/* @__PURE__ */ Ni(...e))},toLowerCase(){return this.check(/* @__PURE__ */ Fi())},toUpperCase(){return this.check(/* @__PURE__ */ Ii())},slugify(){return this.check(/* @__PURE__ */ Li())}})}),Wa=/*@__PURE__*/ k(`ZodString`,(e,t)=>{vn.init(e,t),Ua.init(e,t),e.email=t=>e.check(/* @__PURE__ */ Br(Ga,t)),e.url=t=>e.check(/* @__PURE__ */ Kr(Ya,t)),e.jwt=t=>e.check(/* @__PURE__ */ si(fo,t)),e.emoji=t=>e.check(/* @__PURE__ */ qr(Za,t)),e.guid=t=>e.check(/* @__PURE__ */ Vr(Ka,t)),e.uuid=t=>e.check(/* @__PURE__ */ Hr(qa,t)),e.uuidv4=t=>e.check(/* @__PURE__ */ Ur(qa,t)),e.uuidv6=t=>e.check(/* @__PURE__ */ Wr(qa,t)),e.uuidv7=t=>e.check(/* @__PURE__ */ Gr(qa,t)),e.nanoid=t=>e.check(/* @__PURE__ */ Jr(Qa,t)),e.guid=t=>e.check(/* @__PURE__ */ Vr(Ka,t)),e.cuid=t=>e.check(/* @__PURE__ */ Yr($a,t)),e.cuid2=t=>e.check(/* @__PURE__ */ Xr(eo,t)),e.ulid=t=>e.check(/* @__PURE__ */ Zr(to,t)),e.base64=t=>e.check(/* @__PURE__ */ ii(co,t)),e.base64url=t=>e.check(/* @__PURE__ */ ai(lo,t)),e.xid=t=>e.check(/* @__PURE__ */ Qr(no,t)),e.ksuid=t=>e.check(/* @__PURE__ */ $r(ro,t)),e.ipv4=t=>e.check(/* @__PURE__ */ ei(io,t)),e.ipv6=t=>e.check(/* @__PURE__ */ ti(ao,t)),e.cidrv4=t=>e.check(/* @__PURE__ */ ni(oo,t)),e.cidrv6=t=>e.check(/* @__PURE__ */ ri(so,t)),e.e164=t=>e.check(/* @__PURE__ */ oi(uo,t)),e.datetime=t=>e.check(xa(t)),e.date=t=>e.check(Ca(t)),e.time=t=>e.check(Ta(t)),e.duration=t=>e.check(Da(t))});function I(e){return/* @__PURE__ */ zr(Wa,e)}let L=/*@__PURE__*/ k(`ZodStringFormat`,(e,t)=>{N.init(e,t),Ua.init(e,t)}),Ga=/*@__PURE__*/ k(`ZodEmail`,(e,t)=>{xn.init(e,t),L.init(e,t)}),Ka=/*@__PURE__*/ k(`ZodGUID`,(e,t)=>{yn.init(e,t),L.init(e,t)}),qa=/*@__PURE__*/ k(`ZodUUID`,(e,t)=>{bn.init(e,t),L.init(e,t)});function Ja(e){return/* @__PURE__ */ Hr(qa,e)}let Ya=/*@__PURE__*/ k(`ZodURL`,(e,t)=>{Sn.init(e,t),L.init(e,t)});function Xa(e){return/* @__PURE__ */ Kr(Ya,e)}let Za=/*@__PURE__*/ k(`ZodEmoji`,(e,t)=>{Cn.init(e,t),L.init(e,t)}),Qa=/*@__PURE__*/ k(`ZodNanoID`,(e,t)=>{wn.init(e,t),L.init(e,t)}),$a=/*@__PURE__*/ k(`ZodCUID`,(e,t)=>{Tn.init(e,t),L.init(e,t)}),eo=/*@__PURE__*/ k(`ZodCUID2`,(e,t)=>{En.init(e,t),L.init(e,t)}),to=/*@__PURE__*/ k(`ZodULID`,(e,t)=>{Dn.init(e,t),L.init(e,t)}),no=/*@__PURE__*/ k(`ZodXID`,(e,t)=>{On.init(e,t),L.init(e,t)}),ro=/*@__PURE__*/ k(`ZodKSUID`,(e,t)=>{kn.init(e,t),L.init(e,t)}),io=/*@__PURE__*/ k(`ZodIPv4`,(e,t)=>{Pn.init(e,t),L.init(e,t)}),ao=/*@__PURE__*/ k(`ZodIPv6`,(e,t)=>{Fn.init(e,t),L.init(e,t)}),oo=/*@__PURE__*/ k(`ZodCIDRv4`,(e,t)=>{In.init(e,t),L.init(e,t)}),so=/*@__PURE__*/ k(`ZodCIDRv6`,(e,t)=>{Ln.init(e,t),L.init(e,t)}),co=/*@__PURE__*/ k(`ZodBase64`,(e,t)=>{zn.init(e,t),L.init(e,t)}),lo=/*@__PURE__*/ k(`ZodBase64URL`,(e,t)=>{Vn.init(e,t),L.init(e,t)}),uo=/*@__PURE__*/ k(`ZodE164`,(e,t)=>{Hn.init(e,t),L.init(e,t)}),fo=/*@__PURE__*/ k(`ZodJWT`,(e,t)=>{Wn.init(e,t),L.init(e,t)}),po=/*@__PURE__*/ k(`ZodNumber`,(e,t)=>{Gn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zi(e,t,n,r),Ha(e,`ZodNumber`,{gt(e,t){return this.check(/* @__PURE__ */ bi(e,t))},gte(e,t){return this.check(/* @__PURE__ */ xi(e,t))},min(e,t){return this.check(/* @__PURE__ */ xi(e,t))},lt(e,t){return this.check(/* @__PURE__ */ vi(e,t))},lte(e,t){return this.check(/* @__PURE__ */ yi(e,t))},max(e,t){return this.check(/* @__PURE__ */ yi(e,t))},int(e){return this.check(ho(e))},safe(e){return this.check(ho(e))},positive(e){return this.check(/* @__PURE__ */ bi(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ xi(0,e))},negative(e){return this.check(/* @__PURE__ */ vi(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ yi(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ Si(e,t))},step(e,t){return this.check(/* @__PURE__ */ Si(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function R(e){return/* @__PURE__ */ fi(po,e)}let mo=/*@__PURE__*/ k(`ZodNumberFormat`,(e,t)=>{Kn.init(e,t),po.init(e,t)});function ho(e){return/* @__PURE__ */ pi(mo,e)}let go=/*@__PURE__*/ k(`ZodBoolean`,(e,t)=>{qn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qi(e,t,n,r)});function z(e){return/* @__PURE__ */ mi(go,e)}let _o=/*@__PURE__*/ k(`ZodNull`,(e,t)=>{Jn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$i(e,t,n,r)});function vo(e){return/* @__PURE__ */ hi(_o,e)}let yo=/*@__PURE__*/ k(`ZodUnknown`,(e,t)=>{Yn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function bo(){return/* @__PURE__ */ gi(yo)}let xo=/*@__PURE__*/ k(`ZodNever`,(e,t)=>{Xn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ea(e,t,n,r)});function So(e){return/* @__PURE__ */ _i(xo,e)}let Co=/*@__PURE__*/ k(`ZodArray`,(e,t)=>{Qn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aa(e,t,n,r),e.element=t.element,Ha(e,`ZodArray`,{min(e,t){return this.check(/* @__PURE__ */ wi(e,t))},nonempty(e){return this.check(/* @__PURE__ */ wi(1,e))},max(e,t){return this.check(/* @__PURE__ */ Ci(e,t))},length(e,t){return this.check(/* @__PURE__ */ Ti(e,t))},unwrap(){return this.element}})});function B(e,t){return/* @__PURE__ */ Ri(Co,e,t)}let wo=/*@__PURE__*/ k(`ZodObject`,(e,t)=>{rr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oa(e,t,n,r),A(e,`shape`,()=>t.shape),Ha(e,`ZodObject`,{keyof(){return W(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:bo()})},loose(){return this.clone({...this._zod.def,catchall:bo()})},strict(){return this.clone({...this._zod.def,catchall:So()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return We(this,e)},safeExtend(e){return Ge(this,e)},merge(e){return Ke(this,e)},pick(e){return He(this,e)},omit(e){return Ue(this,e)},partial(...e){return qe(Ro,this,e[0])},required(...e){return Je(Jo,this,e[0])}})});function V(e,t){let n={type:`object`,shape:e??{},...j(t)};return new wo(n)}function H(e,t){return new wo({type:`object`,shape:e,catchall:So(),...j(t)})}let To=/*@__PURE__*/ k(`ZodUnion`,(e,t)=>{ar.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sa(e,t,n,r),e.options=t.options});function Eo(e,t){return new To({type:`union`,options:e,...j(t)})}let Do=/*@__PURE__*/ k(`ZodDiscriminatedUnion`,(e,t)=>{To.init(e,t),or.init(e,t)});function U(e,t,n){return new Do({type:`union`,options:t,discriminator:e,...j(n)})}let Oo=/*@__PURE__*/ k(`ZodIntersection`,(e,t)=>{sr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ca(e,t,n,r)});function ko(e,t){return new Oo({type:`intersection`,left:e,right:t})}let Ao=/*@__PURE__*/ k(`ZodTuple`,(e,t)=>{ur.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>la(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function jo(e,t,n){let r=t instanceof M;return new Ao({type:`tuple`,items:e,rest:r?t:null,...j(r?n:t)})}let Mo=/*@__PURE__*/ k(`ZodRecord`,(e,t)=>{mr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ua(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function No(e,t,n){return!t||!t._zod?new Mo({type:`record`,keyType:I(),valueType:e,...j(t)}):new Mo({type:`record`,keyType:e,valueType:t,...j(n)})}let Po=/*@__PURE__*/ k(`ZodEnum`,(e,t)=>{hr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ta(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);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 Po({...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 Po({...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 Po({type:`enum`,entries:n,...j(t)})}let Fo=/*@__PURE__*/ k(`ZodLiteral`,(e,t)=>{gr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>na(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 Fo({type:`literal`,values:Array.isArray(e)?e:[e],...j(t)})}let Io=/*@__PURE__*/ k(`ZodTransform`,(e,t)=>{_r.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ia(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ve(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(tt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(tt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Lo(e){return new Io({type:`transform`,transform:e})}let Ro=/*@__PURE__*/ k(`ZodOptional`,(e,t)=>{yr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>va(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zo(e){return new Ro({type:`optional`,innerType:e})}let Bo=/*@__PURE__*/ k(`ZodExactOptional`,(e,t)=>{br.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>va(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vo(e){return new Bo({type:`optional`,innerType:e})}let Ho=/*@__PURE__*/ k(`ZodNullable`,(e,t)=>{xr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>da(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uo(e){return new Ho({type:`nullable`,innerType:e})}let Wo=/*@__PURE__*/ k(`ZodDefault`,(e,t)=>{Sr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Go(e,t){return new Wo({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ie(t)}})}let Ko=/*@__PURE__*/ k(`ZodPrefault`,(e,t)=>{wr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ma(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qo(e,t){return new Ko({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ie(t)}})}let Jo=/*@__PURE__*/ k(`ZodNonOptional`,(e,t)=>{Tr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yo(e,t){return new Jo({type:`nonoptional`,innerType:e,...j(t)})}let Xo=/*@__PURE__*/ k(`ZodCatch`,(e,t)=>{Dr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ha(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Zo(e,t){return new Xo({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}let Qo=/*@__PURE__*/ k(`ZodPipe`,(e,t)=>{Or.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ga(e,t,n,r),e.in=t.in,e.out=t.out});function $o(e,t){return new Qo({type:`pipe`,in:e,out:t})}let es=/*@__PURE__*/ k(`ZodReadonly`,(e,t)=>{Ar.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_a(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ts(e){return new es({type:`readonly`,innerType:e})}let ns=/*@__PURE__*/ k(`ZodLazy`,(e,t)=>{Mr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ya(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function rs(e){return new ns({type:`lazy`,getter:e})}let is=/*@__PURE__*/ k(`ZodCustom`,(e,t)=>{Nr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ra(e,t,n,r)});function as(e,t){return/* @__PURE__ */ zi(is,e??(()=>!0),t)}function os(e,t={}){return/* @__PURE__ */ Bi(is,e,t)}function ss(e,t){return/* @__PURE__ */ Vi(e,t)}function cs(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 ls=Eo([I(),R(),z(),vo()]);function us(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 ds=as(us,{message:`JSON value must not contain circular references`}),fs=rs(()=>Eo([ls,B(fs),No(I(),fs)])),ps=ds.pipe(fs);ds.pipe(B(fs));let ms=ds.pipe(No(I(),fs)),hs=H({code:I().min(1),message:I().min(1),retryable:z(),diagnostic:I().min(1).optional(),stage:I().min(1).optional(),durationMs:R().int().nonnegative().optional(),stderrTail:I().min(1).optional()}).superRefine(cs([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),gs=I().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),_s=e=>I().min(1).max(e).refine(e=>e.trim().length>0),vs=No(gs,V({label:_s(256).optional(),description:_s(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),ys=No(gs,_s(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),bs=I().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),xs=bs.brand(),K=bs.brand(),Ss=bs.brand();bs.brand(),bs.brand();let Cs=I().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),ws=Cs.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),Ts=V({modes:B(V({id:ws,label:Cs.max(256),description:Cs.max(1024).optional(),dangerous:z().optional(),localizations:vs.optional()}).strict()).min(1).max(32),defaultModeId:ws}).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`]})});V({threadId:K,permissionModeId:ws}).strict();let Es=R().int().safe().nonnegative(),Ds=R().finite().nonnegative(),Os=R().finite().min(0).max(100),ks=V({version:Eo([G(3),G(4)]).optional(),requestId:I().min(1),turnId:I().min(1).max(1024),outputTokens:Es,startedAtMs:Es,completedAtMs:Es}).strict().refine(e=>e.completedAtMs>e.startedAtMs),As=V({version:Eo([G(2),G(3),G(4)]).optional(),value:Ds,turnId:I().min(1).max(1024),at:Es}).strict();V({outputTimings:B(ks).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:As.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:As.extend({value:Es}).optional()}).strict();let js=e=>ys.refine(t=>Object.values(t).every(t=>t.length<=e)),Ms=V({composerIndicators:B(V({kind:G(`countdown`),id:I().min(1).max(64),expiresAtUnix:Es,label:js(256).optional(),tooltip:js(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:Es.optional(),cachedInputTokens:Es.optional(),cacheWriteInputTokens:Es.optional(),outputTokens:Es.optional(),outputTokensPerSecond:Ds.optional(),sessionOutputTokensPerSecond:Ds.optional(),apiOutputTokensPerSecond:Ds.optional(),reasoningOutputTokens:Es.optional(),totalTokens:Es.optional(),totalCostUsd:Ds.optional(),totalCredits:Ds.optional(),contextUsagePercent:Ds.optional(),cacheHitRatePercent:Os.optional(),contextWindowTokens:Es.optional(),contextUsedTokens:Es.optional(),planFiveHourUsedPercent:Os.optional(),planFiveHourResetsAtUnix:Es.optional(),planSevenDayUsedPercent:Os.optional(),planSevenDayResetsAtUnix:Es.optional(),sessionCacheHitRatePercent:Os.optional(),timeToFirstOutputMs:Es.optional(),latestRequestTimeToFirstOutputMs:Es.optional(),costSource:W([`publicPrice`,`native`]).optional(),unpricedModels:B(I().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`]})}),Ns=R().finite().min(0).max(100),Ps=W([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),Fs=V({id:I().min(1).max(256),label:I().min(1).max(256),localizations:vs.optional()}).strict(),Is=V({product:I().min(1),periodType:Ps.optional(),scope:Fs.optional(),localizations:vs.optional(),used:R().finite().nonnegative().optional(),limit:R().finite().nonnegative().optional(),unit:I().min(1).max(32).optional(),usagePercent:Ns,resetsAt:I().min(1).optional()}).strict(),Ls=V({availableCount:R().int().safe().positive(),nextExpiresAt:I().min(1).optional(),expiresAt:B(I().min(1)).min(1).max(32).optional()}).strict(),Rs=V({used:R().finite().nonnegative().optional(),limit:R().finite().nonnegative().optional(),unit:I().min(1).max(32).optional(),label:I().min(1).optional(),scope:Fs.optional(),localizations:vs.optional(),usedPercent:Ns,resetsAt:I().min(1).optional(),periodType:Ps,productUsage:B(Is).min(1).optional(),resetCredits:Ls.optional()}).strict(),zs=V({amount:R().finite().nonnegative(),currency:I().trim().min(1).max(8),label:I().trim().min(1).max(128).optional()}).strict();V({threadId:K,refresh:G(`exact`).optional()}).strict(),V({threadId:K,usage:Ms.nullable(),accountCredits:Rs.optional(),accountBalance:zs.optional(),accountCreditsSupported:z().optional()}).strict();let Bs=I().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),Vs=I().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Model Ref must not contain control characters`).brand(),Hs=W([`priority`,`ultrafast`]),Us=V({id:Vs,serviceTier:Hs.optional()}).strict();function Ws(e,t){return e?.id===t?.id&&e?.serviceTier===t?.serviceTier}let Gs=Bs.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand(),Ks=Bs.max(256),qs=V({id:Gs,label:Bs.max(256)}).strict(),Js=V({ref:Us,label:Bs.max(256),resolvedModelLabel:Ks.optional(),fastModel:Us.optional(),supportedThinkingOptionIds:B(Gs).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 Ys(e,t){if(t)return e?.models.find(e=>Ws(e.ref,t)||Ws(e.fastModel,t))}let Xs=B(qs).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)}),Zs=V({models:B(Js),defaultModel:Us.optional(),thinkingOptions:Xs,defaultThinkingOptionId:Gs.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=>Ws(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=>Ws(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&&!Ys(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`]})}),Qs=V({fork:z(),forkAcrossCwd:z(),rollbackLastTurn:z()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),$s=W([`live`,`atCreate`]),ec=V({configuration:V({selectModel:z(),selectThinkingOption:z(),selectPermissionMode:z(),permissionModeScope:$s.default(`live`)}).strict(),history:Qs,subagents:V({observe:z(),readTranscript:z()}).strict().optional(),autonomousTurns:V({observe:z()}).strict().optional(),steer:z().optional(),persistentPlan:z().optional()}).strict();V({effectiveModel:Us.optional(),resolvedModelLabel:Ks.optional(),effectiveThinkingOptionId:Gs.optional(),availableThinkingOptions:Xs.optional(),effectivePermissionModeId:ws.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 tc=V({open:G(!0)}).strict();Eo([V({status:G(`ready`),catalog:Zs,permissionModes:Ts.optional(),capabilities:ec,webUi:tc.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`]})}),V({status:W([`notInstalled`,`unavailable`,`error`]),error:hs}).strict()]),V({harnessId:xs,cwd:Bs.max(16384).optional(),refresh:z().optional(),purpose:G(`availability`).optional(),credentialAccess:W([`allow`,`retry`]).optional()}).strict(),V({harnessId:xs}).strict(),V({}).strict(),V({threadId:K,model:Us}).strict(),V({threadId:K,thinkingOptionId:Gs}).strict(),V({threadId:K,includeReferenceCapability:z().optional()}).strict(),U(`owner`,[V({owner:G(`codex`),locked:z(),effectiveModel:Us.optional(),resolvedModelLabel:Ks.optional(),effectiveThinkingOptionId:Gs.optional(),effectivePermissionModeId:ws.optional(),history:Qs.optional(),supportsThreadReferences:G(!0).optional()}).strict(),V({owner:G(`external`),harnessId:Bs.max(256),transportModelId:Bs.max(8192),effectiveModel:Us.optional(),resolvedModelLabel:Ks.optional(),effectiveThinkingOptionId:Gs.optional(),availableThinkingOptions:Xs.optional(),effectivePermissionModeId:ws.optional(),catalog:Zs.optional(),history:Qs,usage:Ms.optional(),locked:G(!0)}).strict()]),V({threadIds:B(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 nc=U(`owner`,[V({threadId:K,owner:G(`codex`)}).strict(),V({threadId:K,owner:G(`external`),harnessId:I().max(256).pipe(xs)}).strict()]);V({threads:B(nc).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)}),V({threadId:K,text:I().optional()}).strict(),V({kind:G(`application`),value:I().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),ge}}).pipe(V({expectedTurnId:Ss,clientUserMessageId:I().min(1),delivery:W([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),W([`activeTurn`,`newTurn`]),V({delivery:W([`official`,`activeTurn`,`newTurn`])}).strict();let rc=I().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u),ic=rc.pipe(xs),ac=ic.refine(e=>e!==`codex`,`The official Codex identity is reserved`),oc=I().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`),sc=Xa().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),cc=V({en:I().max(4096),"zh-CN":I().max(4096).optional()}).strict(),lc=V({commands:B(V({terminal:I().max(256),command:I().max(4096)}).strict()).max(8),before:cc.optional(),after:cc.optional(),downloads:B(V({label:I().max(128),url:sc}).strict()).max(8).optional()}).strict(),uc={id:ic,name:I().trim().min(1).max(128),version:I().min(1).max(128),kind:G(`usage`).optional(),iconStyle:V({vector:V({viewBox:I().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:I().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:B(V({d:I().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:W([`evenodd`,`nonzero`]).optional(),fill:I().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:I().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:R().min(0).max(50).optional(),paddingRatio:R().min(0).max(.25).optional()}).strict().optional(),installation:lc.optional(),notice:cc.optional(),launchCommand:G(!0).optional(),links:V({website:sc.optional(),documentation:sc.optional(),installation:sc.optional()}).strict().optional()};V({manifestVersion:G(1),...uc,adapterApiVersion:R().int().positive(),entry:oc,icon:oc.optional()}).strict();let dc=I().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),fc=V({...uc,icon:dc.optional()}).strict();V({}).strict(),V({plugins:B(fc.extend({id:ac})).max(128)}).strict(),V({version:G(1),enabled:B(ic).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]});let pc=rc,mc=W([`sidebar.thread-layout`,`sidebar.thread-badge`,`appearance.theme`]),hc=W([`appearance`,`interface`,`workflow`,`analytics`,`integrations`,`tools`]),gc=I().trim().min(1).max(128);function _c(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 vc=e=>e.split(`/`).every(e=>!/[. ]$/u.test(e)),yc=oc.refine(e=>_c(e)!==void 0&&vc(e),`Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space`),bc=I().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu,`Expected an HTTP(S) URL`).pipe(Xa({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 xc(e){return H({en:e,"zh-CN":e})}let Sc=xc(I().trim().min(1)),Cc=B(hc).max(hc.options.length).refine(e=>new Set(e).size===e.length,`Duplicate categories`),wc=B(mc).max(mc.options.length).refine(e=>new Set(e).size===e.length,`Duplicate slots`),Tc={key:I().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),label:Sc,description:Sc.optional()},Ec={...Tc,step:R().positive().optional(),default:R().optional()},Dc=H({value:I(),label:Sc}),Oc=U(`type`,[H({...Tc,type:G(`boolean`),default:z().optional()}),H({...Tc,type:G(`string`),placeholder:Sc.optional(),default:I().optional()}),H({...Ec,type:G(`number`),min:R().optional(),max:R().optional()}),H({...Ec,type:G(`range`),min:R(),max:R()}),H({...Tc,type:G(`select`),options:B(Dc).min(1),default:I().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`)}}),kc=V({manifestVersion:ho().positive(),id:pc,name:Eo([gc,xc(gc)]),version:I().min(1).max(128),desktopApi:ho().positive()}).passthrough().extend({manifestVersion:G(1),desktopApi:G(1),description:H({en:I().max(4096),"zh-CN":I().max(4096).optional()}).optional(),author:I().trim().min(1).max(128).optional(),repository:bc.optional(),details:H({en:I().max(16384),"zh-CN":I().max(16384).optional()}).optional(),icon:yc.optional(),screenshots:B(yc).max(4).refine(e=>new Set(e).size===e.length,`Duplicate screenshots`).optional(),desktop:H({script:oc,style:oc.optional()}).optional(),backend:H({script:oc.refine(vc)}).optional(),slots:wc.default(()=>[]),settingsSchema:B(Oc).max(32).refine(e=>new Set(e.map(({key:e})=>e)).size===e.length,`Duplicate setting keys`).optional(),categories:Cc.optional()}).strict().refine(e=>e.desktop!==void 0||e.backend!==void 0,`Expected at least one desktop or backend entry`),Ac=I().regex(/^[a-f0-9]{64}$/u),jc=H({state:W([`running`,`disabled`,`invalid`,`incompatible`,`conflict`,`failed`,`waiting`]),hash:Ac.optional(),error:I().optional(),conflictWith:pc.optional()});H({controllerPid:ho().positive(),targetId:I().nullable(),updatedAt:xa(),handledReloadToken:Ja().optional(),extensions:No(I(),jc),surfaces:No(I(),jc).optional()});let Mc=W([`official`,`community`]);function Nc(e){return e.origin===`https://api.github.com`&&/^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(e.pathname)}let Pc=bc.refine(e=>{let t=new URL(e);return/\.zip$/iu.test(t.pathname)||Nc(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`),Fc=H({id:pc,version:I().trim().min(1).max(128),name:Sc.extend({en:gc,"zh-CN":gc}),description:xc(I().trim().min(1).max(4096)),details:xc(I().trim().min(1).max(16384)).optional(),author:I().trim().min(1).max(128),repository:bc,stars:R().int().min(0).optional(),downloads:R().int().min(0).optional(),categories:Cc.optional(),trustTier:Mc.default(`community`),icon:bc.optional(),screenshots:B(bc).max(4).optional(),downloadUrl:Pc,sha256:Ac,slots:wc.optional(),publishedAt:I().optional(),updatedAt:I().optional(),minCodexHostVersion:I().optional()});H({schemaVersion:G(1),generatedAt:I(),extensions:B(Fc).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)});let Ic=I().trim().min(1).max(128),Lc=/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu,Rc=pc.refine(e=>!Lc.test(e),`Reserved extension ID`),zc=W([`desktop`,`web`]),Bc=Ac,Vc=Ja(),Hc=oc.refine(e=>!/[\x00-\x1f\x7f<>"|*]/u.test(e)&&e.split(`/`).every(e=>!/[. ]$/u.test(e)&&!Lc.test(e)),`Expected a portable relative resource path`).refine(e=>e.split(`/`).length<=32,`Extension resources may be at most 32 segments deep`),Uc=kc.shape,Wc=(e,t=0)=>H({en:I().trim().min(t).max(e),"zh-CN":I().trim().min(t).max(e)}),Gc=e=>Hc.refine(t=>t.endsWith(e),`Expected a ${e} file`),Kc=Gc(`.mjs`),qc=Gc(`.css`).optional(),Jc=e=>e.normalize(`NFC`).toLowerCase(),Yc=H({manifestVersion:G(2),id:Rc,name:Wc(128,1),version:I().trim().min(1).max(128),description:Wc(4096),details:Wc(16384).optional(),author:Uc.author,repository:Uc.repository,icon:Uc.icon.refine(e=>e===void 0||Hc.safeParse(e).success),screenshots:Uc.screenshots.refine(e=>e===void 0||e.every(e=>Hc.safeParse(e).success)),categories:Uc.categories,settingsSchema:Uc.settingsSchema,slots:Uc.slots.removeDefault().optional(),page:H({apiVersion:G(1),entry:Kc,style:qc,title:Wc(128,1).optional()}).optional(),widget:H({apiVersion:G(1),entry:Kc,style:qc}).optional(),desktop:H({apiVersion:G(1),script:Gc(`.js`),style:qc}).optional(),web:H({apiVersion:G(1),entry:Kc.optional(),style:qc}).refine(({entry:e,style:t})=>e!==void 0||t!==void 0,`Expected a Web entry or style`).optional(),backend:H({apiVersion:G(1),entry:Kc}).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||Jc(e)!==Jc(r.entry)),{path:[`backend`,`entry`],message:`A backend entry cannot also be a frontend entry`});function Xc({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 Zc=Ic,Qc=ho().nonnegative(),$c=H({revision:Qc,enabled:B(Rc).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)}),{downloadUrl:el,...tl}=Fc.shape,nl=V({...tl,id:Rc,format:G(`codexhost`),targets:B(zc).min(1).max(2).refine(e=>new Set(e).size===e.length,`Duplicate targets`),apis:H({page:ho().positive().optional(),widget:ho().positive().optional(),desktop:ho().positive().optional(),web:ho().positive().optional(),backend:ho().positive().optional()}),downloadUrl:el.refine(e=>e.startsWith(`https://`),`Expected HTTPS`)}).refine(({targets:e,apis:t})=>{let n=Xc({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`);V({schemaVersion:G(2),generatedAt:I().min(1),extensions:B(nl).max(1e4).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)}).extend({catalogUrl:bc,fetchedAt:xa(),cached:z()});let rl={id:Rc},il={...rl,activationId:Vc,digest:Bc},al={...rl,activationId:il.activationId.optional()},ol=I().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`),sl=I().min(1).max(256).refine(e=>e.split(`/`).every(e=>e&&/^[a-z0-9_.-]+$/iu.test(e)&&e!==`.`&&e!==`..`),`Invalid GitHub ref`);function cl(e){return I().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 ll=H({type:G(`github`),repository:I().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),ref:sl.optional(),tag:sl.optional(),asset:I().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),subpath:Hc.optional()}).refine(({ref:e,tag:t,asset:n})=>!e||!t&&!n,`Use either a zipball ref or a release tag/asset`),ul=Eo([H({type:G(`catalog`),...rl}),ll,H({type:G(`zip`),base64:cl(67108864).min(4)}),H({type:G(`zip`),localZipPath:ol}),H({type:G(`localDir`),localDir:ol})]),dl=U(`type`,[H({type:G(`catalog`),...rl}),ll,H({type:G(`zip`)}),H({type:G(`localDir`)})]),fl=H({...il,manifest:Yc,installedAt:xa(),source:dl.optional()}),pl=e=>I().max(23+4*Math.ceil(e/3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u),ml={desktopConflictWith:Rc.optional()},hl=W([`none`,`inactive`,`starting`,`running`,`failed`]),gl=U(`state`,[fl.extend({state:G(`valid`),enabled:z(),...ml,iconDataUrl:pl(131072).optional(),screenshotDataUrls:B(pl(524288)).max(4).optional(),backendState:hl.optional(),backendError:I().optional()}),H({state:W([`invalid`,`incompatible`]),id:I().min(1),enabled:z(),error:I()})]);H({revision:Qc,configuration:$c,diagnostics:B(I()),extensions:B(gl)}),H({revision:Qc,extensions:B(fl.extend({...ml,settingsRevision:Qc})).max(64)});let _l={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`},vl=Object.freeze(Object.values(_l));new Set(vl),H({});let yl={expectedRevision:Qc};H({...rl,...yl}),fl.extend({replaced:z()}),U(`state`,[H({state:G(`saved`),configuration:$c}),H({state:G(`revision-conflict`),revision:Qc})]),H({...al,digest:il.digest.optional(),path:Hc}),H({mimeType:I().min(1),base64:cl(16777216),digest:il.digest}),H({settingsRevision:Qc,values:ms}),_l.list,_l.snapshot,_l.catalog,H({forceRefresh:z().optional()}),_l.install,H({source:ul}),_l.update,H({...rl,expectedDigest:il.digest,expectedActivationId:il.activationId.optional(),source:ul.optional()}),_l.enable,_l.disable,_l.uninstall,H({...rl,removeData:z().optional(),expectedDigest:il.digest.optional()}),H({...rl,removed:z()}),_l.recover,H({expectedRevision:yl.expectedRevision.optional()}),_l.asset,_l.settingsGet,H(al),_l.settingsSet,H({...al,expectedSettingsRevision:Qc,values:ms}),_l.backendInvoke,H({...al,method:Zc,params:ps.optional()}),H({result:ps}),V({threadId:K}).strict(),V({confirmed:z()}).strict(),[...vl],V({sections:B(V({id:I().min(1),name:I().min(1),threads:B(ms)}).strict())}).strict(),V({threadId:I().min(1).max(1024),sectionId:I().min(1).max(1024).nullable()}).strict(),V({threadIds:B(I().min(1))}).strict(),V({threadId:I().min(1).max(1024),pinned:z()}).strict(),V({}).strict(),V({parents:No(I().min(1),I().min(1))}).strict(),V({prompt:I().max(16384).optional()}).strict(),V({projects:B(V({id:I(),name:I(),rootPaths:B(I())})),assignments:No(I(),I()),projectless:B(I()),pinned:B(I())});let bl=No(I(),bo()),xl=V({epoch:I().uuid(),sequence:R().int().nonnegative()});U(`type`,[V({type:G(`skills-changed`),cursor:xl,cwd:I().optional()}),V({type:G(`harness-inspection-changed`),cursor:xl,harnessId:I().min(1)}),V({type:G(`display-settings-changed`),cursor:xl}),V({type:G(`preferences-changed`),cursor:xl,revision:R().int().nonnegative()}),V({type:G(`extensions-changed`),cursor:xl,revision:Qc}),V({type:G(`hello`),version:G(1),cursor:xl,reset:z()}),V({type:G(`changed`),cursor:xl,threadId:I().min(1),method:I().min(1)})]);let Sl=U(`type`,[V({type:G(`text`),id:I(),prompt:I(),secret:z().optional(),optional:z().optional()}),V({type:G(`choice`),id:I(),prompt:I(),multiple:z(),allowOther:z(),optional:z().optional(),options:B(V({value:I(),label:I(),description:I().optional()}))})]),Cl=U(`type`,[V({type:G(`approval`),title:I(),description:I().optional(),subject:bo().optional(),actions:B(V({id:I(),label:I(),effect:I()}))}),V({type:G(`question`),title:I().optional(),questions:B(Sl)})]),wl=V({requestId:Eo([I(),R().int()]),threadId:I(),kind:W([`approval`,`question`]),interaction:Cl,request:bl}),Tl=V({id:I().min(1),clientUserMessageId:I().min(1),input:B(bl),presentationInput:B(bl).nullable().optional()}).passthrough();V({fields:B(V({path:B(Eo([I(),R().int().nonnegative()])),originalLength:R().int().nonnegative()}))});let El=V({id:I().min(1),status:I().min(1),codexhostTurnOutcome:V({status:G(`unknown`),reason:I()}).optional(),items:B(V({id:I().min(1),type:I().min(1)}).passthrough()),codexhostFileOperations:B(V({beforeItemId:I().nullable(),item:V({id:I().min(1),type:I().min(1)}).passthrough()})).optional(),error:V({message:I().optional()}).passthrough().nullable().optional(),fingerprint:I().min(1).optional(),unchanged:G(!0).optional()}).passthrough(),Dl=V({id:I().min(1).max(512),fingerprint:I().min(1).max(128)});V({threadId:I().min(1),knownTurns:B(Dl).max(64).optional(),truncateToolOutput:z().optional()});let Ol=V({harnessId:I().min(1),nativeSessionId:I().min(1)});V({cursor:xl,activeTurnId:I().min(1).nullable().optional(),command:V({name:I().min(1),turn:El,subsequentTurnId:I().min(1).optional()}).optional(),thread:V({id:I().min(1),cwd:I(),modelProvider:I().min(1),createdAt:R(),updatedAt:R(),status:V({type:I()}).passthrough(),name:I().nullable().optional(),preview:I().optional(),codexhostImportSource:Ol.optional(),turns:B(El).length(0)}).passthrough(),turnsPage:V({data:B(El).max(5),nextCursor:I().nullable()}),configuration:V({native:V({model:I().min(1).max(1024).optional(),reasoningEffort:I().min(1).max(128).optional()}).optional(),effectiveModel:Us.optional(),effectiveThinkingOptionId:Gs.optional(),effectivePermissionModeId:ws.optional()}),queue:V({items:B(Tl),pausedReason:W([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:B(wl)}),V({version:G(1),owner:G(`service`).optional(),pid:R().int().positive(),port:R().int().min(1).max(65535),token:I().regex(/^[0-9a-f]{64}$/u),startedAt:R(),epoch:I().uuid()}),V({epoch:I().uuid(),threadId:I().min(1),requestId:Eo([I(),R().int()]),result:bl}),V({includeArchived:z().optional(),officialCursor:V({live:I().nullable(),archived:I().nullable().optional()}).strict().optional()}).strict(),V({threads:B(ms),ownership:B(nc),archivedThreadIds:B(K),officialCursor:V({live:I().nullable(),archived:I().nullable().optional()}).strict().optional()}).strict();let kl=W([`running`,`waiting`,`idle`,`unknown`]),Al=H({harnessId:xs,title:I().optional(),status:kl,archived:z()}),jl=H({revision:ho().nonnegative(),parents:No(K,K),nodes:No(K,Al),truncated:z()}).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`),Ml=I().min(1).max(128);H({});let Nl=H({subscriptionId:Ml});H({}),Nl.extend({snapshot:jl});let Pl=I().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);V({available:z()}).strict(),V({path:I().min(1),mimeType:Pl}).strict();let Fl=W([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);U(`ok`,[V({ok:G(!0),text:I()}).strict(),V({ok:G(!1),error:V({code:Fl}).strict()}).strict()]),V({threadId:K.optional(),cwd:I().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let Il=V({name:I().min(1).regex(/^[^\s[\]]+$/u),description:I().optional(),path:I().min(1),scope:W([`project`,`global`]),source:I().min(1)}).strict();V({revision:R().int().nonnegative(),complete:z(),skills:B(Il),warnings:B(I()).optional()}).strict(),V({cwd:I().min(1).optional()}).strict();let Ll=V({kind:W([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:I().min(1)}).strict(),Rl=U(`status`,[V({status:G(`not-installed`)}),V({status:G(`not-running`)}),V({status:G(`not-logged-in`)}),V({status:G(`https-disabled`)}),V({status:G(`not-serving`),command:I()}),V({status:G(`occupied`),target:I()}),V({status:G(`serving`),url:I(),funnel:z()}),V({status:G(`error`),message:I()})]);V({state:Rl,error:I().optional()}).strict();let zl=U(`status`,[V({status:G(`on`)}),V({status:G(`off`)}),V({status:G(`invalid`),reason:I()})]),Bl=V({lan:z(),autostart:zl}).strict(),Vl=V({expiresAt:I().optional(),issuing:z(),failure:V({detail:I().optional(),retryAt:I(),paused:z()}).optional()}),Hl=U(`status`,[V({status:G(`off`),reason:W([`invite`,`name-taken`,`banned`]).optional()}),V({status:G(`connecting`),reason:W([`full`,`unreachable`]).optional()}),V({status:G(`connected`),url:I(),certificate:Vl}),V({status:G(`missing-certificate`),url:I(),certificate:Vl}),V({status:G(`stopped`),reason:W([`replaced`,`rejected`,`unsupported-version`])})]);I().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()),I().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let Ul=W([`official`,`self-hosted`]);V({secret:I().min(1),lastUsedAt:R().nullable(),networkUrls:B(Ll),directCandidates:B(Ll).optional(),tailscale:Rl,background:Bl.optional(),relay:V({state:Hl,enabled:z(),kind:Ul,officialHost:I(),customHost:I().optional(),officialHostname:I().optional(),customHostname:I().optional(),quotaUntil:I().optional()}).strict().optional()}).strict();let Wl=H({threadId:I().min(1).max(1024),view:W([`result`,`messages`]),from:R().int().min(1).max(2**53-1).optional(),to:R().int().min(1).max(2**53-1).optional()}),Gl=V({id:I().min(1).max(256),harnessId:I().min(1),label:I().min(1).max(512),provider:W([`openai-codex`,`xai`])}).strict(),Kl=I().regex(/^[a-z][a-z0-9-]{0,47}$/),ql=V({name:Kl,source:Gl,importedAt:I()}).strict(),Jl=U(`action`,[V({action:G(`list`)}).strict(),V({action:G(`import`),sourceId:I().min(1).max(256),name:Kl,confirmed:G(!0)}).strict(),V({action:G(`reimport`),sourceId:I().min(1).max(256),name:Kl,confirmed:G(!0)}).strict(),V({action:G(`remove`),name:Kl,confirmed:G(!0)}).strict()]),Yl=V({provider:I().min(1).max(128),type:W([`oauth`,`api_key`,`unknown`]),label:I().min(1).max(512).optional(),vendor:W([`openai-codex`,`xai`]).optional()}).strict();V({sources:B(Gl),targets:B(V({harnessId:I(),providers:B(W([`openai-codex`,`xai`])),imports:B(ql),others:B(Yl).default([])}).strict())}).strict(),V({targetHarnessId:I().min(1).max(128).optional(),request:Jl}).strict(),V({events:z()});let Xl=B(H({agent:I().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`);H({entries:Xl.nullable()}),H({}),H({entries:Xl,initializeOnly:z().optional()});let Zl=H({enabled:z(),timeoutMinutes:R().int().min(5).max(1440)});Object.freeze({enabled:!1,timeoutMinutes:10});let Ql=I().regex(/^external$/u),$l=xs.transform(e=>String(e)),eu=H({model:Us.optional(),thinkingOptionId:Gs.optional(),permissionModeId:ws.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`),tu=H({lastHarness:xs.optional(),byHarness:No($l,eu)}),nu=H({model:Us.optional(),thinkingOptionId:Gs.optional()}).refine(e=>!!(e.model||e.thinkingOptionId),`A delegation default must contain a Model or Thinking option`),ru=H({byHarness:No($l,nu)}),iu=I().min(1).max(1024),au=H({idleRelease:Zl.optional(),favorites:No($l,B(iu).max(2048)).default({}),newThread:tu.optional(),delegation:ru.optional()});H({scope:Ql,revision:R().int().nonnegative(),values:au}),H({scope:Ql.default(`external`)});let ou=U(`kind`,[H({kind:G(`idleRelease`),value:Zl}),H({kind:G(`favorite`),harnessId:xs,modelId:iu,enabled:z()}),H({kind:G(`favorites`),harnessId:xs,modelIds:B(iu).max(2048)}),H({kind:G(`newThread`),lastHarness:xs.optional(),harnessId:xs.optional(),configuration:eu.optional()}),H({kind:G(`delegation`),harnessId:xs,configuration:nu.nullable()})]);H({scope:Ql.default(`external`),operations:B(ou).min(1).max(256),initializeOnly:z().optional(),expectedRevision:R().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`})}),H({version:G(1),revision:R().int().nonnegative(),scopes:No(Ql,au)});let su=R().finite().nonnegative(),cu=H({input:su,output:su,cacheRead:su.optional(),cacheWrite:su.optional(),cacheWrite1h:su.optional()}),lu=I().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);H({path:I(),entries:B(H({key:I(),price:cu})),error:I().nullable()}),H({}),H({key:lu,price:cu.nullable(),previousKey:lu.optional()}),H({model:lu});let uu=H({official:z().optional(),canonicalModelId:I().min(1).optional(),provider:I().min(1).max(512),model:I().min(1).max(512),price:cu});H({price:cu.nullable(),suggestions:B(uu).max(6).optional()});let du=[`today`,`7d`,`30d`,`90d`,`all`],fu=R().int().min(0).max(2**53-1),pu=I().regex(/^\d{4}-\d{2}-\d{2}$/u),mu=I().min(1).max(128),hu=I().min(1).max(512),gu=I().min(1).max(4096);H({range:W(du),timeZone:I().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:mu.optional(),model:hu.nullable().optional(),project:gu.nullable().optional(),date:pu.optional()});let _u=H({requests:fu,inputTokens:fu,cachedInputTokens:fu,cacheWriteInputTokens:fu,cacheKnownInputTokens:fu,cacheHitCachedInputTokens:fu,cacheHitInputTokens:fu,outputTokens:fu,reasoningOutputTokens:fu,costUsd:R().finite().min(0),unpricedRequests:fu,unmeteredRequests:fu}),vu=_u.shape,yu=H({harness:mu,sessionId:I().min(1).max(512),project:gu.nullable(),title:I().min(1).max(200).optional(),models:B(hu).max(16),firstAtMs:fu,lastAtMs:fu,...vu});H({range:W(du),from:pu.nullable(),to:pu,filters:H({harness:mu.nullable(),model:hu.nullable(),unknownModel:z(),project:gu.nullable(),unknownProject:z(),date:pu.nullable()}),reading:H({complete:z(),sources:fu,read:fu}),failures:B(H({harness:mu,message:I().max(2048)})).max(256),options:H({harnesses:B(mu).max(256),models:B(hu.nullable()).max(4096),projects:B(gu.nullable()).max(4096)}),modelLabels:B(H({harness:mu,model:hu,label:hu})).max(4096).optional(),credits:B(H({harness:mu,model:hu.nullable(),credits:R().finite().min(0),reportedRequests:fu,requests:fu})).max(4096).optional(),totals:_u,daily:B(H({date:pu,harness:mu,...vu})).max(2e5),hourly:B(H({weekday:R().int().min(0).max(6),hour:R().int().min(0).max(23),...vu})).max(168),byHarness:B(H({harness:mu,...vu})).max(256),byModel:B(H({model:hu.nullable(),...vu,harnessPricedRequests:fu})).max(4096),byProject:B(H({project:gu.nullable(),...vu})).max(4096),sessions:B(yu).max(100),recentSessions:B(yu).max(100).optional()}),V({threadId:K}),V({discarded:z()});let bu=U(`type`,[V({id:I().min(1),type:G(`choice`),prompt:I(),options:B(V({value:I().min(1),label:I(),description:I().optional()})).min(1),multiple:z(),allowOther:z(),optional:z()}),V({id:I().min(1),type:G(`text`),prompt:I(),multiline:z(),secret:G(!1),optional:z(),placeholder:I().optional(),prefill:I().optional()})]),xu=V({interactionId:I().min(1),turnId:I().min(1),title:I().optional(),questions:B(bu).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});H({threadId:I().min(1)}),V({questions:B(xu)}),H({threadId:I().min(1),turnId:I().min(1),interactionId:I().min(1),answers:No(I(),B(I())),cancelled:z().default(!1)}),V({accepted:G(!0)});let Su=V({path:I(),oldText:I().nullable(),newText:I()});V({sessionId:I().min(1),turn:R().int().nonnegative(),path:I().min(1).optional()}),V({diffs:B(Su)}),H({}),H({}),V({reference:V({sessionId:I().min(1),epoch:I().min(1),turn:R().int().nonnegative(),seq:R().int().nonnegative(),callId:I().min(1),part:R().int().nonnegative(),version:I().min(1)}),length:R().int().nonnegative(),bytes:R().int().nonnegative()}),H({title:I().trim().min(1).max(200),type:W([`info`,`warning`,`danger`]),body:I().trim().min(1).max(16384)}),H({}),H({url:I().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 Cu=W([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),wu=W([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);H({threadId:I(),title:I(),harnessId:I(),state:Cu,reason:wu,inactiveMs:R().nonnegative()}),H({threadId:K,turnId:Ss});let Tu=V({email:I().trim().min(1).max(320).optional(),label:I().trim().min(1).max(256).optional(),plan:I().trim().min(1).max(128).optional(),credits:Rs.optional(),balance:zs.optional()}).strict();function Eu(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 Du=Eu(Tu),Ou={harnessId:xs,harnessName:I().trim().min(1).max(128)},ku=V(Ou).strict();V({}).strict(),V({sources:B(ku).max(128)}).strict(),V({harnessId:xs,refresh:z().optional()}).strict(),V({...Ou,account:Du.nullable(),accounts:B(Du).max(8).optional()}).strict(),V({refresh:z().optional()}).strict(),V({accounts:B(Eu(Tu.extend(Ou))).max(128)}).strict(),V({harnessId:ac,model:Us.optional(),thinkingOptionId:Gs.optional(),permissionModeId:ws.optional(),prewarm:G(!0).optional()}).strict();let Au=I().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);V({harnessId:ac}).strict().extend({path:Au.nullable()}),V({path:Au.nullable(),restartRequired:z()}).strict(),V({harnessId:xs,action:W([`check`,`update`,`install`]),confirmedVersion:I().min(1).max(128).optional()}).strict().refine(({action:e,confirmedVersion:t})=>e===`update`||t===void 0);let ju=V({currentVersion:I().min(1).max(128),latestVersion:I().min(1).max(128),updateAvailable:z(),canUpdate:z(),latestVerifiedVersion:I().min(1).max(128).optional(),confirmationRequired:G(!0).optional(),versionKind:W([`cli`,`application`]).optional(),manualUpdateUrl:Xa().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:I().max(2048).optional(),messageCode:I().min(1).max(128).optional(),notice:ys.optional(),latestVersionKind:W([`unknown`,`tracking-branch`]).optional()}).strict();V({taskId:I().uuid()}).strict(),U(`status`,[V({taskId:I().uuid(),status:G(`running`)}).strict(),V({taskId:I().uuid(),status:G(`succeeded`),result:ju}).strict(),V({taskId:I().uuid(),status:G(`failed`),error:V({code:R().int(),message:I().min(1).max(2048)}).strict()}).strict()]);let Mu=I().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),Nu=I().trim().min(1),Pu=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`]),Fu=V({accountId:Mu,label:Nu.max(256),email:I().email().max(320).optional(),planType:Pu.optional()}).strict(),Iu=W([`ready`,`unavailable`]);V({version:G(2),currentAccountId:Mu.nullable(),phase:Iu,revision:R().int().nonnegative(),instanceId:Nu.max(1024).optional(),accounts:B(Fu).max(1)}).strict(),V({accountId:Mu,refresh:z().optional()}).strict(),V({accountId:Mu,usage:Ms.nullable(),accountCredits:Rs.optional(),freshness:W([`live`,`cached`]),observedAt:I().datetime().nullable()}).strict();let Lu=1e3,Ru=I().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),zu=Ru.max(1024),Bu=V({nativeSessionId:zu,title:Ru.max(4096).nullable(),updatedAt:R().int().nonnegative().max(864e13),cwd:Ru.max(16384),running:z().nullable()}).strict();V({}).strict(),V({harnesses:B(V({harnessId:ac,name:Ru.max(128)}).strict()).max(128)}).strict(),V({harnessId:ac,query:I().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:R().int().nonnegative().safe().optional(),limit:R().int().min(1).max(Lu).optional()}).strict(),V({candidates:B(Bu).max(Lu),total:R().int().nonnegative().safe()}).strict(),V({harnessId:ac,nativeSessionId:zu}).strict(),V({threadId:Ru.max(1024).pipe(K)}).strict();let Vu=I().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),Hu=zu,Uu=Bu;V({}).strict(),V({candidates:B(Uu).max(1e3)}).strict(),V({nativeSessionId:Hu}).strict(),V({threadId:Vu.max(1024).pipe(K)}).strict(),V({threadId:K,lastTurnId:Ss}).strict(),V({threadId:K}).strict();let Wu=I().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();V({commands:B(V({id:Wu,invocation:I().min(1).max(128),label:I().trim().min(1).max(128),description:I().trim().min(1).max(512).optional(),localizations:vs.optional(),argumentMode:W([`none`,`text`]),kind:W([`command`,`skill`]).optional()}).strict()),warnings:B(I().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)}),V({harnessId:xs,cwd:I().min(1).optional()}).strict(),V({threadId:K}).strict(),V({threadId:K,commandId:Wu,turnId:Ss.optional(),arguments:ms.optional()}).strict(),V({accepted:G(!0),turnId:Ss.optional()}).strict();let Gu=G(`2.0`).optional(),Ku=So().optional(),qu=I().min(1),Ju=Eo([I(),R().int()]),Yu=V({code:R().int(),message:I(),data:ps.optional()}).catchall(ps).superRefine(cs([`data`]));Eo([V({jsonrpc:Gu,id:Ju,method:qu,params:ps.optional(),result:Ku,error:Ku}).catchall(ps).superRefine(cs([`jsonrpc`,`params`,`result`,`error`])),V({jsonrpc:Gu,id:Ku,method:qu,params:ps.optional(),result:Ku,error:Ku}).catchall(ps).superRefine(cs([`jsonrpc`,`id`,`params`,`result`,`error`])),V({jsonrpc:Gu,id:Ju,method:Ku,params:Ku,result:ps,error:Ku}).catchall(ps).superRefine(cs([`jsonrpc`,`method`,`params`,`error`])),V({jsonrpc:Gu,id:Ju,method:Ku,params:Ku,result:Ku,error:Yu}).catchall(ps).superRefine(cs([`jsonrpc`,`method`,`params`,`result`]))]);let Xu=I().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});H({harnessId:xs,nativeSessionId:Xu,locator:ps.optional(),formatVersion:G(1)}).superRefine(cs([`locator`])),H({harnessId:xs,nativeSessionId:Xu,nativeTurnKey:Xu,formatVersion:G(1)}),H({harnessId:xs,nativeSessionId:Xu,checkpointId:Xu,locator:ps.optional(),formatVersion:G(1)}).superRefine(cs([`locator`]));let Zu=I().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),Qu=W([`npm`,`windows-installer`,`macos-dmg`]),$u=H({version:Zu,installation:Qu,phase:W([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),updatedAt:R().int().nonnegative(),downloadedBytes:R().int().nonnegative().optional(),totalBytes:R().int().positive().optional(),error:I().min(1).max(500).nullable(),serviceStopOutput:I().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`})});H({});let ed=I().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`);H({currentVersion:Zu,installation:Qu.nullable(),latestVersion:Zu.nullable(),updateAvailable:z(),installationAvailable:z(),releaseNotes:I().min(1).max(2e4).nullable(),releaseNotesUrl:ed.nullable(),status:$u.nullable(),error:I().min(1).max(500).nullable()}),H({status:$u}),H({status:$u.nullable()});let td=H({icon:I().min(1).max(16).optional(),title:I().min(1).max(120),body:I().min(1).max(1200),contributors:B(I().min(1).max(39)).max(30)}),nd=H({summary:I().min(1).max(600).optional(),themes:B(td).min(1).max(12)}),rd=H({version:Zu,publishedAt:xa(),url:I().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),zh:nd.nullable(),en:nd.nullable()}).refine(e=>e.zh!==null||e.en!==null,{message:`an announcement needs at least one language`});H({manual:z().optional()}),H({announcement:rd.nullable(),unread:z()}),H({version:Zu});let id=RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);function ad(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=id.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 od=`<response-annotations>`,sd=`</response-annotations>`,cd=/## My request(?: for Codex)?:/gu;function ld(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${od}\n${JSON.stringify(t)}\n${sd}\n`}function ud(e,t){let n=ld(e);return n===``?t:`${n}\n## My request:\n${t}\n`}function dd(e){let t=e.trimStart().startsWith(`# Response annotations:`)?0:e.length,n=e.indexOf(`\n${od}\n`,t);if(n<0)return``;let r=n+1+22+1,i=e.indexOf(`\n${sd}`,r);return i<0?``:e.slice(r,i)}function fd(e){return{annotations:hd(e),body:pd(e)}}function pd(e){let t=0;for(let n of e.matchAll(cd))t=n.index+n[0].length;return e.slice(t).trim()}function md(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function hd(e){let t=dd(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(!md(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 gd(e){return hd(e)}let _d=W([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);V({runningVersion:I().nullable(),installedVersion:I().nullable(),restartRequired:z(),remote:z(),updateSupported:z(),update:V({phase:_d,targetVersion:I().nullable(),error:I().nullable()})});let vd=V({version:I().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();V({hostname:I().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:R().int().min(1).max(65535).nullable(),identity:I().max(4096).nullable(),action:W([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:z().optional(),version:I().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),V({state:W([`installed`,`not-installed`])}).strict();let q=I().min(1).max(1024),yd={hostId:q.regex(/^remote-(?:ssh(?:-|:)|control:)/u)},bd={...yd,threadId:q},xd=I().min(1).max(8e3),Sd={text:xd,requestId:q};U(`accepted`,[V({accepted:G(!0),startQueuedItemId:q.optional()}),V({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:I()})]),U(`available`,[V({available:G(!1)}),V({available:G(!0),items:B(V({id:q,clientUserMessageId:q,preview:I().max(801)})).max(100)})]);let Cd=U(`kind`,[H({kind:G(`hosts`)}),H({kind:G(`create`),...yd,cwd:I().min(1).max(8192),epoch:q}),H({kind:G(`projectHarnesses`),...yd,epoch:q}),H({kind:G(`inspectHarness`),...yd,epoch:q,cwd:I().min(1).max(8192),harnessId:q}),H({kind:G(`startSelected`),...yd,epoch:q,cwd:I().min(1).max(8192),harnessId:q,model:I().min(1).max(4096),serviceTier:W([`priority`,`ultrafast`]).optional(),reasoningEffort:q.optional()}),H({kind:G(`status`),...bd}),H({kind:G(`list`),...yd,cursor:I().nullable(),archived:z(),includeLoaded:G(!0).optional()}),H({kind:G(`read`),...bd,page:H({cursor:I().min(1).max(8192).nullable(),epoch:q.optional(),sortDirection:W([`asc`,`desc`]).optional(),limit:R().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),H({kind:G(`usage`),...bd,epoch:q}),H({kind:G(`configure`),...bd,epoch:q,modelId:q.optional(),serviceTier:Hs.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`}),H({kind:G(`prompt`),...bd,epoch:q,text:xd,requestId:q.optional()}),H({kind:G(`queue`),...bd,epoch:q}),H({kind:G(`delivery`),...bd,epoch:q,action:U(`kind`,[H({kind:G(`enqueue`),...Sd}),H({kind:G(`steer`),...Sd,turnId:q}),H({kind:G(`remove`),itemId:q}),H({kind:G(`start`),itemId:q,onlyIfHead:G(!0).optional()})])}),H({kind:G(`interrupt`),...bd,epoch:q,turnId:q}),H({kind:G(`rename`),...bd,epoch:q,name:I().min(1).max(512)}),H({kind:G(`archive`),...bd,epoch:q,archived:z()}),H({kind:G(`respond`),...bd,epoch:q,requestId:Eo([q,R().int()]),result:No(I(),bo())})]),wd=I().min(1).max(1024),Td=V({hostId:wd,displayName:I().min(1).max(1024),source:W([`codex-managed`,`discovered`]),sshAlias:I().max(1024).nullable(),sshHost:I().min(1).max(1024),sshPort:R().int().min(1).max(65535).nullable(),identity:I().max(4096).nullable(),autoConnect:z(),connectionAnalyticsId:I().max(1024).optional()}),Ed=H({displayName:I().min(1).max(1024),hostname:I().min(1).max(1024),sshPort:R().int().min(1).max(65535).nullable(),identity:I().max(4096).nullable()});U(`action`,[H({action:G(`session`),operation:Cd}),H({action:G(`list`)}),H({action:G(`catalog`)}),H({action:G(`read-thread`),hostId:wd.refine(e=>e!==`local`),input:Wl}),H({action:G(`save`),draft:Ed,previous:Td.nullable()}),H({action:G(`remove`),previous:Td}),H({action:G(`connect`),hostId:wd,enabled:z()}),H({action:G(`state`),hostId:wd}),H({action:G(`runtime`),hostId:wd}),H({action:G(`update`),hostId:wd.refine(e=>e!==`local`),version:vd.shape.version})]),Eo([H({result:ps}),H({error:H({code:R().int(),message:I()})})]),H({prompt:I().trim().min(1).max(2e3),cwd:I().max(4096).nullable()}),I().trim().min(1).max(60).nullable();let Dd=I().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),Od=Eo([I(),V({en:I()}).catchall(I())]),kd=V({title:Od.optional(),description:Od.optional(),icon:I().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:I().optional()});V({extensions:B(V({id:Dd,name:I().min(1).max(214),version:I().min(1).max(128),format:G(`dsh`),supportedTargets:jo([G(`web`)]),enabledTargets:B(G(`web`)).max(1),source:I().min(1).max(4096),projectUrl:I().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:I(),meta:kd.optional(),loadError:I().optional()})),loadedIds:B(Dd),safeMode:z(),storeError:I().optional()});let Ad=I().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}/`);V({spec:I().trim().min(1).max(4096),registry:Ad.optional()}).strict(),V({id:Dd,enabled:z()}).strict(),V({id:Dd}).strict(),G(1);function jd(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 Md(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 Nd=`@deepseek-ai/dsh-client-ui-chat/ThreadWatchNotice.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Nd)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Nd,e.textContent=`.XZWmHW_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}.XZWmHW_list{min-width:0;margin:0;padding:0;list-style:none}.XZWmHW_entry+.XZWmHW_entry{margin-top:10px}.XZWmHW_line{align-items:center;gap:8px;min-width:0;display:flex}.XZWmHW_line>svg,.XZWmHW_bell{flex-shrink:0}.XZWmHW_bell{color:var(--dsw-alias-label-tertiary);margin-top:3px}.XZWmHW_title{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-primary);overflow:hidden}.XZWmHW_outcome,.XZWmHW_open{white-space:nowrap;flex-shrink:0}.XZWmHW_outcome[data-outcome=completed]{color:var(--dsw-alias-state-success-primary)}.XZWmHW_outcome[data-outcome=failed]{color:var(--dsw-alias-state-error-primary)}.XZWmHW_open a{color:var(--dsw-alias-state-business-primary);text-decoration:none}.XZWmHW_open a:hover{text-decoration:underline}.XZWmHW_open a:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}.XZWmHW_note{color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;margin:4px 0 0 24px}@media (width<=480px){.XZWmHW_line{flex-wrap:wrap}.XZWmHW_title{flex:calc(100% - 52px)}.XZWmHW_outcome{margin-left:24px}}`,document.head.appendChild(e)}var Pd={bell:`XZWmHW_bell`,card:`XZWmHW_card`,entry:`XZWmHW_entry`,line:`XZWmHW_line`,list:`XZWmHW_list`,note:`XZWmHW_note`,open:`XZWmHW_open`,outcome:`XZWmHW_outcome`,title:`XZWmHW_title`};let Fd=()=>()=>{};function Id({entry:e,links:t,t:n}){let r=`codex://threads/${e.threadId}`,i=()=>t?.describe?.(r)?.title,a=(0,d.useSyncExternalStore)(t?.resolve.subscribe??Fd,i,i),o=a!==void 0;return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Pd.entry,"data-thread-watch-entry":e.threadId,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Pd.line,children:[o?t?.describe?.(r)?.icon:/* @__PURE__ */ (0,f.jsx)(p.ReferenceIconRegular,{kind:`session`,size:14}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Pd.title,title:a??e.label,children:a??e.label}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Pd.outcome,"data-outcome":e.outcome,children:n(`message.watch.${e.outcome}`)}),o&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Pd.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:Pd.note,children:e.note})]})}function Ld({entries:e,links:t,t:n}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Pd.card,"data-thread-watch-notice":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.IconBellOutlineRegular,{className:Pd.bell}),/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Pd.list,children:e.map((e,r)=>/* @__PURE__ */ (0,f.jsx)(Id,{entry:e,links:t,t:n},r))})]})}let Rd=`@deepseek-ai/dsh-client-ui-chat/MessageItem.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Rd)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Rd,e.textContent=`.EnoZlW_userRow{flex-direction:column;align-items:flex-end;gap:6px;display:flex}.EnoZlW_noticeRow{flex-direction:column;align-items:center;gap:6px;min-width:0;display:flex}.EnoZlW_noticeStack{min-width:0;max-width:100%}.EnoZlW_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}.EnoZlW_annotationRow{flex-wrap:wrap;justify-content:flex-end;gap:6px;display:flex}.EnoZlW_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] .EnoZlW_bubble{background:color-mix(in srgb, var(--dsw-specific-bubble) 84%, transparent);backdrop-filter:blur(12px)}.EnoZlW_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))}.EnoZlW_contextRow{padding:2px 0}.EnoZlW_compactionRow{--dsh-compaction-header-height:calc(24px + var(--dsh-content-font-delta,0px));padding:2px 0}.EnoZlW_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}.EnoZlW_compactionRow:has(.EnoZlW_compactionBody) .EnoZlW_compactionButton{z-index:7;background:var(--dsw-alias-bg-base);border-radius:0;position:sticky;top:0}body[data-codexhost-wallpaper] .EnoZlW_compactionRow:has(.EnoZlW_compactionBody) .EnoZlW_compactionButton{background:color-mix(in srgb, var(--dsw-alias-bg-base) 78%, transparent);backdrop-filter:blur(12px)}.EnoZlW_compactionBody :has(>[data-code-block-banner]){top:var(--dsh-compaction-header-height)}@media (hover:hover){.EnoZlW_compactionRow:has(.EnoZlW_compactionBody) .EnoZlW_compactionButton:hover{background:var(--dsw-alias-interactive-bg-hover-solid)}.EnoZlW_compactionButton:hover{color:var(--dsw-alias-label-secondary)}.EnoZlW_compactionButton:not(:disabled):hover{background:var(--dsw-alias-interactive-bg-hover)}}.EnoZlW_compactionButton:not(:disabled){cursor:pointer}.EnoZlW_compactionButton:not(:disabled):active{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover)}.EnoZlW_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}.EnoZlW_compactionLeading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}.EnoZlW_compactionContextIcon,.EnoZlW_compactionDisclosureIcon{grid-area:1/1;justify-content:center;align-items:center;display:inline-flex}.EnoZlW_compactionDisclosureIcon,.EnoZlW_compactionButton:not(:disabled):hover .EnoZlW_compactionContextIcon,.EnoZlW_compactionButton:not(:disabled):focus-visible .EnoZlW_compactionContextIcon{opacity:0}.EnoZlW_compactionButton:not(:disabled):hover .EnoZlW_compactionDisclosureIcon,.EnoZlW_compactionButton:not(:disabled):focus-visible .EnoZlW_compactionDisclosureIcon{opacity:1}.EnoZlW_compactionTitle{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:inherit;flex:none}.EnoZlW_compactionSep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.EnoZlW_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}.EnoZlW_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))}.EnoZlW_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))}.EnoZlW_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}.EnoZlW_retrySummary::-webkit-details-marker{display:none}.EnoZlW_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)}.EnoZlW_retrySummary:hover{color:var(--dsw-alias-label-secondary)}@media (prefers-reduced-motion:reduce){.EnoZlW_compactionButton{transition:none}}.EnoZlW_retrySummary:focus-visible{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}.EnoZlW_retryText{overflow-wrap:anywhere;min-width:0}.EnoZlW_retryRow[open] .EnoZlW_retrySummary:after{transform:rotate(45deg)}.EnoZlW_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}.EnoZlW_retryDetailLabel{color:var(--dsw-alias-label-secondary)}.EnoZlW_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}.EnoZlW_turnErrorDot{margin-top:5px}.EnoZlW_turnErrorCopy{overflow-wrap:anywhere;min-width:0}.EnoZlW_turnErrorTitle{color:var(--dsw-alias-state-error-primary);margin-right:6px;font-weight:600}.EnoZlW_turnErrorMessage{color:var(--dsw-alias-label-secondary)}.EnoZlW_turnErrorCode{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-markdown-code-block-small)}.EnoZlW_maxTokensTitle{color:var(--dsw-alias-state-warn-primary);margin-right:6px;font-weight:600}.EnoZlW_attachmentRow{flex-wrap:wrap;justify-content:flex-end;gap:8px;max-width:100%;display:flex}.EnoZlW_pendingAttachment{flex-direction:column;align-items:flex-end;gap:4px;min-width:0;display:flex}.EnoZlW_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}.EnoZlW_fileIcon{flex:none;width:28px;height:28px}.EnoZlW_fileContent{flex-direction:column;flex:1;min-width:0;display:flex}.EnoZlW_fileName{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px;overflow:hidden}.EnoZlW_fileMeta{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-tertiary,#00000073);font-size:12px;line-height:15px;overflow:hidden}.EnoZlW_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}.EnoZlW_editAction:hover{background:var(--dsw-alias-interactive-bg-hover)}.EnoZlW_editAction svg{width:15px;height:15px}.EnoZlW_userStack:has(.EnoZlW_sentEditor){width:100%}.EnoZlW_sentEditor{box-sizing:border-box;border:1px solid var(--dsw-alias-border-main);border-radius:12px;width:100%;min-width:0;padding:12px}.EnoZlW_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}.EnoZlW_sentEditor:focus-within{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}.EnoZlW_sentEditorActions{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}`,document.head.appendChild(e)}var J={annotationRow:`EnoZlW_annotationRow`,attachmentRow:`EnoZlW_attachmentRow`,bubble:`EnoZlW_bubble`,compactionBody:`EnoZlW_compactionBody`,compactionButton:`EnoZlW_compactionButton`,compactionContextIcon:`EnoZlW_compactionContextIcon`,compactionDisclosureIcon:`EnoZlW_compactionDisclosureIcon`,compactionLeading:`EnoZlW_compactionLeading`,compactionRow:`EnoZlW_compactionRow`,compactionSep:`EnoZlW_compactionSep`,compactionSummary:`EnoZlW_compactionSummary`,compactionTitle:`EnoZlW_compactionTitle`,contextRow:`EnoZlW_contextRow`,editAction:`EnoZlW_editAction`,fileCard:`EnoZlW_fileCard`,fileContent:`EnoZlW_fileContent`,fileIcon:`EnoZlW_fileIcon`,fileMeta:`EnoZlW_fileMeta`,fileName:`EnoZlW_fileName`,maxTokensTitle:`EnoZlW_maxTokensTitle`,noticeRow:`EnoZlW_noticeRow`,noticeStack:`EnoZlW_noticeStack`,pendingAttachment:`EnoZlW_pendingAttachment`,referenceSummary:`EnoZlW_referenceSummary`,retryDetailLabel:`EnoZlW_retryDetailLabel`,retryDetails:`EnoZlW_retryDetails`,retryRow:`EnoZlW_retryRow`,retrySummary:`EnoZlW_retrySummary`,retryText:`EnoZlW_retryText`,sentEditor:`EnoZlW_sentEditor`,sentEditorActions:`EnoZlW_sentEditorActions`,turnErrorCode:`EnoZlW_turnErrorCode`,turnErrorCopy:`EnoZlW_turnErrorCopy`,turnErrorDot:`EnoZlW_turnErrorDot`,turnErrorMessage:`EnoZlW_turnErrorMessage`,turnErrorRow:`EnoZlW_turnErrorRow`,turnErrorTitle:`EnoZlW_turnErrorTitle`,userRow:`EnoZlW_userRow`,userStack:`EnoZlW_userStack`};let zd=(0,d.memo)(function({node:e,title:t,fallbackSummary:n,t:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useMemo)(()=>jd(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})})]})}),Bd=`@deepseek-ai/dsh-client-ui-chat/ContextBody.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Bd)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Bd,e.textContent=`._3_H96G_text{color:var(--dsw-alias-label-secondary);font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;margin:0}._3_H96G_fields{border-top:.5px solid var(--dsw-alias-border-l2);flex-direction:column;gap:2px;margin:8px 0 0;padding-top:8px;display:flex}._3_H96G_field{gap:8px;min-width:0;display:flex}._3_H96G_fieldKey{min-width:96px;color:var(--dsw-alias-label-caption);flex:none}._3_H96G_fieldValue{min-width:0;color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;flex:auto;margin:0}._3_H96G_files{flex-wrap:wrap;gap:4px 12px;margin:0 0 8px;padding:0;list-style:none;display:flex}._3_H96G_file{align-items:baseline;gap:6px;min-width:0;display:flex}._3_H96G_filePath{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}._3_H96G_fileAction{color:var(--dsw-alias-label-caption)}._3_H96G_catalogNotice{color:var(--dsw-alias-label-caption);margin:0 0 6px}._3_H96G_entries{flex-direction:column;gap:4px;margin:0;padding:0;list-style:none;display:flex}._3_H96G_entry{gap:8px;min-width:0;display:flex}._3_H96G_entryName{color:var(--dsw-alias-label-secondary);flex:none}._3_H96G_entryDescription{min-width:0;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}._3_H96G_sections{flex-direction:column;gap:8px;margin:0;display:flex}._3_H96G_section{flex-direction:column;gap:2px;min-width:0;display:flex}._3_H96G_sectionName{color:var(--dsw-alias-label-caption)}._3_H96G_sectionText{color:var(--dsw-alias-label-secondary);white-space:pre-wrap;overflow-wrap:anywhere;margin:0}._3_H96G_relaySender{color:var(--dsw-alias-label-caption);overflow-wrap:anywhere;margin:0 0 6px}._3_H96G_recalls{flex-direction:column;gap:2px;margin:0 0 8px;padding:0;list-style:none;display:flex}._3_H96G_recall{gap:8px;min-width:0;display:flex}._3_H96G_recallLabel{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}._3_H96G_recallCounts{color:var(--dsw-alias-label-caption);flex:none}`,document.head.appendChild(e)}var Y={catalogNotice:`_3_H96G_catalogNotice`,entries:`_3_H96G_entries`,entry:`_3_H96G_entry`,entryDescription:`_3_H96G_entryDescription`,entryName:`_3_H96G_entryName`,field:`_3_H96G_field`,fieldKey:`_3_H96G_fieldKey`,fieldValue:`_3_H96G_fieldValue`,fields:`_3_H96G_fields`,file:`_3_H96G_file`,fileAction:`_3_H96G_fileAction`,filePath:`_3_H96G_filePath`,files:`_3_H96G_files`,recall:`_3_H96G_recall`,recallCounts:`_3_H96G_recallCounts`,recallLabel:`_3_H96G_recallLabel`,recalls:`_3_H96G_recalls`,relaySender:`_3_H96G_relaySender`,section:`_3_H96G_section`,sectionName:`_3_H96G_sectionName`,sectionText:`_3_H96G_sectionText`,sections:`_3_H96G_sections`,text:`_3_H96G_text`};let Vd=2e4;function Hd(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Ud(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 Wd(e){return Ud(e).flatMap(e=>`block`in e?[e.block]:[])}function Gd(e,t){return e.length>Vd?`${e.slice(0,Vd)}\n${t(`json.truncated`,{total:e.length})}`:e}function Kd(e,t){return Gd(typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e),t)}function qd({source:e,formRendered:t,t:n}){let r=Hd(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:Kd(t,n)})]},e))})}function Jd({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 Yd({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(f.Fragment,{children:Ud(e).map((e,n)=>`text`in e?e.text!==``&&/* @__PURE__ */ (0,f.jsx)(`pre`,{className:Y.text,"data-context-text":!0,children:Gd(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 Xd({content:e,source:t,t:n}){return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(Yd,{content:e,t:n}),/* @__PURE__ */ (0,f.jsx)(qd,{source:t,formRendered:!1,t:n})]})}function Zd(e){let t=Hd(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=Hd(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 Qd(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 $d({content:e,source:t,t:n}){let r=Zd(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(Xd,{content:e,source:t,t:n});let i=Hd(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(Qd(e.action,i))})]},e.path))}),/* @__PURE__ */ (0,f.jsx)(Yd,{content:e,t:n})]})}function ef(e){let t=Hd(e),n=t===null?void 0:t.entries;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=Hd(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 tf({content:e,source:t,t:n}){let r=ef(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(Xd,{content:e,source:t,t:n});let i=Hd(t)?.update===!0,a=r.slice(0,200),o=Wd(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)(Jd,{blocks:o,t:n})]})}function nf(e){let t=Hd(e),n=t===null?void 0:t.sections;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=Hd(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 rf({content:e,source:t,t:n}){let r=nf(t);return r===null?/* @__PURE__ */ (0,f.jsx)(Xd,{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:Gd(e.text,n)})]},t))})]})}function af({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(Yd,{content:e,t})}function of({content:e,source:t,t:n}){let r=sf(t);return r===null?/* @__PURE__ */ (0,f.jsx)(Xd,{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)(Yd,{content:e,t:n})]})}function sf(e){let t=Hd(e)?.senderSessionId;return typeof t==`string`&&t!==``?t:null}function cf(e){let t=Hd(e),n=t===null?void 0:t.references;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=Hd(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 lf({content:e,source:t,t:n}){let r=cf(t);return r===null?/* @__PURE__ */ (0,f.jsx)(Xd,{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)(Yd,{content:e,t:n})]})}function uf(e){let t=Hd(e)?.summary;return typeof t==`string`&&t!==``?t:null}function df(e,t){let n={rendered:null,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Xd,{...t})};switch(e){case`instructions`:return Zd(t.source)===null?n:{rendered:`instructions`,summary:null,body:/* @__PURE__ */ (0,f.jsx)($d,{...t})};case`catalog`:return ef(t.source)===null?n:{rendered:`catalog`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(tf,{...t})};case`snapshot`:return nf(t.source)===null?n:{rendered:`snapshot`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(rf,{...t})};case`notice`:{let e=uf(t.source);return e===null?n:{rendered:`notice`,summary:e,body:/* @__PURE__ */ (0,f.jsx)(af,{...t})}}case`relay`:return sf(t.source)===null?n:{rendered:`relay`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(of,{...t})};case`recall`:return cf(t.source)===null?n:{rendered:`recall`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(lf,{...t})};case null:return n;
122
+ 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)}}}function Gi(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)):Object.assign(i,s),Object.assign(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??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);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)}Object.assign(i,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??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}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:Ji(t,`input`,e.processors),output:Ji(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ki(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 Ki(r.element,n);if(r.type===`set`)return Ki(r.valueType,n);if(r.type===`lazy`)return Ki(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`)return Ki(r.innerType,n);if(r.type===`intersection`)return Ki(r.left,n)||Ki(r.right,n);if(r.type===`record`||r.type===`map`)return Ki(r.keyType,n)||Ki(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ki(r.in,n)||Ki(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ki(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ki(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ki(e,n))return!0;return!!(r.rest&&Ki(r.rest,n))}return!1}let qi=(e,t={})=>n=>{let r=Ui({...n,processors:t});return P(e,r),Wi(r,e),Gi(r,e)},Ji=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ui({...i??{},target:a,io:t,processors:n});return P(e,o),Wi(o,e),Gi(o,e)},Yi={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Xi=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Yi[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];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}))])}},Zi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Qi=(e,t,n,r)=>{n.type=`boolean`},$i=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},ea=(e,t,n,r)=>{n.not={}},ta=(e,t,n,r)=>{let i=e._zod.def,a=xe(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},na=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);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}},ra=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ia=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},aa=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=P(a.element,t,{...r,path:[...r.path,`items`]})},oa=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=P(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=P(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},sa=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>P(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ca=(e,t,n,r)=>{let i=e._zod.def,a=P(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=P(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},la=(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)=>P(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?P(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},ua=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=P(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=P(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=P(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},da=(e,t,n,r)=>{let i=e._zod.def,a=P(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`}]},fa=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},pa=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ma=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},ha=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ga=(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;P(o,t,r);let s=t.seen.get(e);s.ref=o},_a=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},va=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ya=(e,t,n,r)=>{let i=e._zod.innerType;P(i,t,r);let a=t.seen.get(e);a.ref=i},ba=/*@__PURE__*/ k(`ZodISODateTime`,(e,t)=>{An.init(e,t),L.init(e,t)});function xa(e){return/* @__PURE__ */ ci(ba,e)}let Sa=/*@__PURE__*/ k(`ZodISODate`,(e,t)=>{jn.init(e,t),L.init(e,t)});function Ca(e){return/* @__PURE__ */ li(Sa,e)}let wa=/*@__PURE__*/ k(`ZodISOTime`,(e,t)=>{Mn.init(e,t),L.init(e,t)});function Ta(e){return/* @__PURE__ */ ui(wa,e)}let Ea=/*@__PURE__*/ k(`ZodISODuration`,(e,t)=>{Nn.init(e,t),L.init(e,t)});function Da(e){return/* @__PURE__ */ di(Ea,e)}let Oa=/*@__PURE__*/ k(`ZodError`,(e,t)=>{rt.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>ot(e,t)},flatten:{value:t=>at(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Se,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Se,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),ka=/* @__PURE__ */ st(Oa),Aa=/* @__PURE__ */ ct(Oa),ja=/* @__PURE__ */ lt(Oa),Ma=/* @__PURE__ */ dt(Oa),Na=/* @__PURE__ */ pt(Oa),Pa=/* @__PURE__ */ mt(Oa),Fa=/* @__PURE__ */ ht(Oa),Ia=/* @__PURE__ */ gt(Oa),La=/* @__PURE__ */ _t(Oa),Ra=/* @__PURE__ */ vt(Oa),za=/* @__PURE__ */ yt(Oa),Ba=/* @__PURE__ */ bt(Oa),Va=/* @__PURE__ */ new WeakMap;function Ha(e,t,n){let r=Object.getPrototypeOf(e),i=Va.get(r);if(i||(i=/* @__PURE__ */ new Set,Va.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}let F=/*@__PURE__*/ k(`ZodType`,(e,t)=>(M.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Ji(e,`input`),output:Ji(e,`output`)}}),e.toJSONSchema=qi(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>ka(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ja(e,t,n),e.parseAsync=async(t,n)=>Aa(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ma(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Na(e,t,n),e.decode=(t,n)=>Pa(e,t,n),e.encodeAsync=async(t,n)=>Fa(e,t,n),e.decodeAsync=async(t,n)=>Ia(e,t,n),e.safeEncode=(t,n)=>La(e,t,n),e.safeDecode=(t,n)=>Ra(e,t,n),e.safeEncodeAsync=async(t,n)=>za(e,t,n),e.safeDecodeAsync=async(t,n)=>Ba(e,t,n),Ha(e,`ZodType`,{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(os(e,t))},superRefine(e,t){return this.check(ss(e,t))},overwrite(e){return this.check(/* @__PURE__ */ Mi(e))},optional(){return zo(this)},exactOptional(){return Vo(this)},nullable(){return Uo(this)},nullish(){return zo(Uo(this))},nonoptional(e){return Yo(this,e)},array(){return B(this)},or(e){return Eo([this,e])},and(e){return ko(this,e)},transform(e){return $o(this,Lo(e))},default(e){return Go(this,e)},prefault(e){return qo(this,e)},catch(e){return Zo(this,e)},pipe(e){return $o(this,e)},readonly(){return ts(this)},describe(e){let t=this.clone();return Rr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Rr.get(this);let t=this.clone();return Rr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Rr.get(e)?.description},configurable:!0}),e)),Ua=/*@__PURE__*/ k(`_ZodString`,(e,t)=>{vn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xi(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ha(e,`_ZodString`,{regex(...e){return this.check(/* @__PURE__ */ Ei(...e))},includes(...e){return this.check(/* @__PURE__ */ ki(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Ai(...e))},endsWith(...e){return this.check(/* @__PURE__ */ ji(...e))},min(...e){return this.check(/* @__PURE__ */ wi(...e))},max(...e){return this.check(/* @__PURE__ */ Ci(...e))},length(...e){return this.check(/* @__PURE__ */ Ti(...e))},nonempty(...e){return this.check(/* @__PURE__ */ wi(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ Di(e))},uppercase(e){return this.check(/* @__PURE__ */ Oi(e))},trim(){return this.check(/* @__PURE__ */ Pi())},normalize(...e){return this.check(/* @__PURE__ */ Ni(...e))},toLowerCase(){return this.check(/* @__PURE__ */ Fi())},toUpperCase(){return this.check(/* @__PURE__ */ Ii())},slugify(){return this.check(/* @__PURE__ */ Li())}})}),Wa=/*@__PURE__*/ k(`ZodString`,(e,t)=>{vn.init(e,t),Ua.init(e,t),e.email=t=>e.check(/* @__PURE__ */ Br(Ga,t)),e.url=t=>e.check(/* @__PURE__ */ Kr(Ya,t)),e.jwt=t=>e.check(/* @__PURE__ */ si(fo,t)),e.emoji=t=>e.check(/* @__PURE__ */ qr(Za,t)),e.guid=t=>e.check(/* @__PURE__ */ Vr(Ka,t)),e.uuid=t=>e.check(/* @__PURE__ */ Hr(qa,t)),e.uuidv4=t=>e.check(/* @__PURE__ */ Ur(qa,t)),e.uuidv6=t=>e.check(/* @__PURE__ */ Wr(qa,t)),e.uuidv7=t=>e.check(/* @__PURE__ */ Gr(qa,t)),e.nanoid=t=>e.check(/* @__PURE__ */ Jr(Qa,t)),e.guid=t=>e.check(/* @__PURE__ */ Vr(Ka,t)),e.cuid=t=>e.check(/* @__PURE__ */ Yr($a,t)),e.cuid2=t=>e.check(/* @__PURE__ */ Xr(eo,t)),e.ulid=t=>e.check(/* @__PURE__ */ Zr(to,t)),e.base64=t=>e.check(/* @__PURE__ */ ii(co,t)),e.base64url=t=>e.check(/* @__PURE__ */ ai(lo,t)),e.xid=t=>e.check(/* @__PURE__ */ Qr(no,t)),e.ksuid=t=>e.check(/* @__PURE__ */ $r(ro,t)),e.ipv4=t=>e.check(/* @__PURE__ */ ei(io,t)),e.ipv6=t=>e.check(/* @__PURE__ */ ti(ao,t)),e.cidrv4=t=>e.check(/* @__PURE__ */ ni(oo,t)),e.cidrv6=t=>e.check(/* @__PURE__ */ ri(so,t)),e.e164=t=>e.check(/* @__PURE__ */ oi(uo,t)),e.datetime=t=>e.check(xa(t)),e.date=t=>e.check(Ca(t)),e.time=t=>e.check(Ta(t)),e.duration=t=>e.check(Da(t))});function I(e){return/* @__PURE__ */ zr(Wa,e)}let L=/*@__PURE__*/ k(`ZodStringFormat`,(e,t)=>{N.init(e,t),Ua.init(e,t)}),Ga=/*@__PURE__*/ k(`ZodEmail`,(e,t)=>{xn.init(e,t),L.init(e,t)}),Ka=/*@__PURE__*/ k(`ZodGUID`,(e,t)=>{yn.init(e,t),L.init(e,t)}),qa=/*@__PURE__*/ k(`ZodUUID`,(e,t)=>{bn.init(e,t),L.init(e,t)});function Ja(e){return/* @__PURE__ */ Hr(qa,e)}let Ya=/*@__PURE__*/ k(`ZodURL`,(e,t)=>{Sn.init(e,t),L.init(e,t)});function Xa(e){return/* @__PURE__ */ Kr(Ya,e)}let Za=/*@__PURE__*/ k(`ZodEmoji`,(e,t)=>{Cn.init(e,t),L.init(e,t)}),Qa=/*@__PURE__*/ k(`ZodNanoID`,(e,t)=>{wn.init(e,t),L.init(e,t)}),$a=/*@__PURE__*/ k(`ZodCUID`,(e,t)=>{Tn.init(e,t),L.init(e,t)}),eo=/*@__PURE__*/ k(`ZodCUID2`,(e,t)=>{En.init(e,t),L.init(e,t)}),to=/*@__PURE__*/ k(`ZodULID`,(e,t)=>{Dn.init(e,t),L.init(e,t)}),no=/*@__PURE__*/ k(`ZodXID`,(e,t)=>{On.init(e,t),L.init(e,t)}),ro=/*@__PURE__*/ k(`ZodKSUID`,(e,t)=>{kn.init(e,t),L.init(e,t)}),io=/*@__PURE__*/ k(`ZodIPv4`,(e,t)=>{Pn.init(e,t),L.init(e,t)}),ao=/*@__PURE__*/ k(`ZodIPv6`,(e,t)=>{Fn.init(e,t),L.init(e,t)}),oo=/*@__PURE__*/ k(`ZodCIDRv4`,(e,t)=>{In.init(e,t),L.init(e,t)}),so=/*@__PURE__*/ k(`ZodCIDRv6`,(e,t)=>{Ln.init(e,t),L.init(e,t)}),co=/*@__PURE__*/ k(`ZodBase64`,(e,t)=>{zn.init(e,t),L.init(e,t)}),lo=/*@__PURE__*/ k(`ZodBase64URL`,(e,t)=>{Vn.init(e,t),L.init(e,t)}),uo=/*@__PURE__*/ k(`ZodE164`,(e,t)=>{Hn.init(e,t),L.init(e,t)}),fo=/*@__PURE__*/ k(`ZodJWT`,(e,t)=>{Wn.init(e,t),L.init(e,t)}),po=/*@__PURE__*/ k(`ZodNumber`,(e,t)=>{Gn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zi(e,t,n,r),Ha(e,`ZodNumber`,{gt(e,t){return this.check(/* @__PURE__ */ bi(e,t))},gte(e,t){return this.check(/* @__PURE__ */ xi(e,t))},min(e,t){return this.check(/* @__PURE__ */ xi(e,t))},lt(e,t){return this.check(/* @__PURE__ */ vi(e,t))},lte(e,t){return this.check(/* @__PURE__ */ yi(e,t))},max(e,t){return this.check(/* @__PURE__ */ yi(e,t))},int(e){return this.check(ho(e))},safe(e){return this.check(ho(e))},positive(e){return this.check(/* @__PURE__ */ bi(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ xi(0,e))},negative(e){return this.check(/* @__PURE__ */ vi(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ yi(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ Si(e,t))},step(e,t){return this.check(/* @__PURE__ */ Si(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function R(e){return/* @__PURE__ */ fi(po,e)}let mo=/*@__PURE__*/ k(`ZodNumberFormat`,(e,t)=>{Kn.init(e,t),po.init(e,t)});function ho(e){return/* @__PURE__ */ pi(mo,e)}let go=/*@__PURE__*/ k(`ZodBoolean`,(e,t)=>{qn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qi(e,t,n,r)});function z(e){return/* @__PURE__ */ mi(go,e)}let _o=/*@__PURE__*/ k(`ZodNull`,(e,t)=>{Jn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$i(e,t,n,r)});function vo(e){return/* @__PURE__ */ hi(_o,e)}let yo=/*@__PURE__*/ k(`ZodUnknown`,(e,t)=>{Yn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function bo(){return/* @__PURE__ */ gi(yo)}let xo=/*@__PURE__*/ k(`ZodNever`,(e,t)=>{Xn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ea(e,t,n,r)});function So(e){return/* @__PURE__ */ _i(xo,e)}let Co=/*@__PURE__*/ k(`ZodArray`,(e,t)=>{Qn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aa(e,t,n,r),e.element=t.element,Ha(e,`ZodArray`,{min(e,t){return this.check(/* @__PURE__ */ wi(e,t))},nonempty(e){return this.check(/* @__PURE__ */ wi(1,e))},max(e,t){return this.check(/* @__PURE__ */ Ci(e,t))},length(e,t){return this.check(/* @__PURE__ */ Ti(e,t))},unwrap(){return this.element}})});function B(e,t){return/* @__PURE__ */ Ri(Co,e,t)}let wo=/*@__PURE__*/ k(`ZodObject`,(e,t)=>{rr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oa(e,t,n,r),A(e,`shape`,()=>t.shape),Ha(e,`ZodObject`,{keyof(){return W(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:bo()})},loose(){return this.clone({...this._zod.def,catchall:bo()})},strict(){return this.clone({...this._zod.def,catchall:So()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return We(this,e)},safeExtend(e){return Ge(this,e)},merge(e){return Ke(this,e)},pick(e){return He(this,e)},omit(e){return Ue(this,e)},partial(...e){return qe(Ro,this,e[0])},required(...e){return Je(Jo,this,e[0])}})});function V(e,t){let n={type:`object`,shape:e??{},...j(t)};return new wo(n)}function H(e,t){return new wo({type:`object`,shape:e,catchall:So(),...j(t)})}let To=/*@__PURE__*/ k(`ZodUnion`,(e,t)=>{ar.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sa(e,t,n,r),e.options=t.options});function Eo(e,t){return new To({type:`union`,options:e,...j(t)})}let Do=/*@__PURE__*/ k(`ZodDiscriminatedUnion`,(e,t)=>{To.init(e,t),or.init(e,t)});function U(e,t,n){return new Do({type:`union`,options:t,discriminator:e,...j(n)})}let Oo=/*@__PURE__*/ k(`ZodIntersection`,(e,t)=>{sr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ca(e,t,n,r)});function ko(e,t){return new Oo({type:`intersection`,left:e,right:t})}let Ao=/*@__PURE__*/ k(`ZodTuple`,(e,t)=>{ur.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>la(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function jo(e,t,n){let r=t instanceof M;return new Ao({type:`tuple`,items:e,rest:r?t:null,...j(r?n:t)})}let Mo=/*@__PURE__*/ k(`ZodRecord`,(e,t)=>{mr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ua(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function No(e,t,n){return!t||!t._zod?new Mo({type:`record`,keyType:I(),valueType:e,...j(t)}):new Mo({type:`record`,keyType:e,valueType:t,...j(n)})}let Po=/*@__PURE__*/ k(`ZodEnum`,(e,t)=>{hr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ta(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);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 Po({...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 Po({...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 Po({type:`enum`,entries:n,...j(t)})}let Fo=/*@__PURE__*/ k(`ZodLiteral`,(e,t)=>{gr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>na(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 Fo({type:`literal`,values:Array.isArray(e)?e:[e],...j(t)})}let Io=/*@__PURE__*/ k(`ZodTransform`,(e,t)=>{_r.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ia(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ve(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(tt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(tt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Lo(e){return new Io({type:`transform`,transform:e})}let Ro=/*@__PURE__*/ k(`ZodOptional`,(e,t)=>{yr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>va(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zo(e){return new Ro({type:`optional`,innerType:e})}let Bo=/*@__PURE__*/ k(`ZodExactOptional`,(e,t)=>{br.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>va(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vo(e){return new Bo({type:`optional`,innerType:e})}let Ho=/*@__PURE__*/ k(`ZodNullable`,(e,t)=>{xr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>da(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uo(e){return new Ho({type:`nullable`,innerType:e})}let Wo=/*@__PURE__*/ k(`ZodDefault`,(e,t)=>{Sr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Go(e,t){return new Wo({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ie(t)}})}let Ko=/*@__PURE__*/ k(`ZodPrefault`,(e,t)=>{wr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ma(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qo(e,t){return new Ko({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ie(t)}})}let Jo=/*@__PURE__*/ k(`ZodNonOptional`,(e,t)=>{Tr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yo(e,t){return new Jo({type:`nonoptional`,innerType:e,...j(t)})}let Xo=/*@__PURE__*/ k(`ZodCatch`,(e,t)=>{Dr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ha(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Zo(e,t){return new Xo({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}let Qo=/*@__PURE__*/ k(`ZodPipe`,(e,t)=>{Or.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ga(e,t,n,r),e.in=t.in,e.out=t.out});function $o(e,t){return new Qo({type:`pipe`,in:e,out:t})}let es=/*@__PURE__*/ k(`ZodReadonly`,(e,t)=>{Ar.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_a(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ts(e){return new es({type:`readonly`,innerType:e})}let ns=/*@__PURE__*/ k(`ZodLazy`,(e,t)=>{Mr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ya(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function rs(e){return new ns({type:`lazy`,getter:e})}let is=/*@__PURE__*/ k(`ZodCustom`,(e,t)=>{Nr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ra(e,t,n,r)});function as(e,t){return/* @__PURE__ */ zi(is,e??(()=>!0),t)}function os(e,t={}){return/* @__PURE__ */ Bi(is,e,t)}function ss(e,t){return/* @__PURE__ */ Vi(e,t)}function cs(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 ls=Eo([I(),R(),z(),vo()]);function us(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 ds=as(us,{message:`JSON value must not contain circular references`}),fs=rs(()=>Eo([ls,B(fs),No(I(),fs)])),ps=ds.pipe(fs);ds.pipe(B(fs));let ms=ds.pipe(No(I(),fs)),hs=H({code:I().min(1),message:I().min(1),retryable:z(),diagnostic:I().min(1).optional(),stage:I().min(1).optional(),durationMs:R().int().nonnegative().optional(),stderrTail:I().min(1).optional()}).superRefine(cs([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),gs=I().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),_s=e=>I().min(1).max(e).refine(e=>e.trim().length>0),vs=No(gs,V({label:_s(256).optional(),description:_s(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),ys=No(gs,_s(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),bs=I().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),xs=bs.brand(),K=bs.brand(),Ss=bs.brand();bs.brand(),bs.brand();let Cs=I().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),ws=Cs.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),Ts=V({modes:B(V({id:ws,label:Cs.max(256),description:Cs.max(1024).optional(),dangerous:z().optional(),localizations:vs.optional()}).strict()).min(1).max(32),defaultModeId:ws}).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`]})});V({threadId:K,permissionModeId:ws}).strict();let Es=R().int().safe().nonnegative(),Ds=R().finite().nonnegative(),Os=R().finite().min(0).max(100),ks=V({version:Eo([G(3),G(4)]).optional(),requestId:I().min(1),turnId:I().min(1).max(1024),outputTokens:Es,startedAtMs:Es,completedAtMs:Es}).strict().refine(e=>e.completedAtMs>e.startedAtMs),As=V({version:Eo([G(2),G(3),G(4)]).optional(),value:Ds,turnId:I().min(1).max(1024),at:Es}).strict();V({outputTimings:B(ks).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:As.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:As.extend({value:Es}).optional()}).strict();let js=e=>ys.refine(t=>Object.values(t).every(t=>t.length<=e)),Ms=V({composerIndicators:B(V({kind:G(`countdown`),id:I().min(1).max(64),expiresAtUnix:Es,label:js(256).optional(),tooltip:js(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:Es.optional(),cachedInputTokens:Es.optional(),cacheWriteInputTokens:Es.optional(),outputTokens:Es.optional(),outputTokensPerSecond:Ds.optional(),sessionOutputTokensPerSecond:Ds.optional(),apiOutputTokensPerSecond:Ds.optional(),reasoningOutputTokens:Es.optional(),totalTokens:Es.optional(),totalCostUsd:Ds.optional(),totalCredits:Ds.optional(),contextUsagePercent:Ds.optional(),cacheHitRatePercent:Os.optional(),contextWindowTokens:Es.optional(),contextUsedTokens:Es.optional(),planFiveHourUsedPercent:Os.optional(),planFiveHourResetsAtUnix:Es.optional(),planSevenDayUsedPercent:Os.optional(),planSevenDayResetsAtUnix:Es.optional(),sessionCacheHitRatePercent:Os.optional(),timeToFirstOutputMs:Es.optional(),latestRequestTimeToFirstOutputMs:Es.optional(),costSource:W([`publicPrice`,`native`]).optional(),unpricedModels:B(I().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`]})}),Ns=R().finite().min(0).max(100),Ps=W([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),Fs=V({id:I().min(1).max(256),label:I().min(1).max(256),localizations:vs.optional()}).strict(),Is=V({product:I().min(1),periodType:Ps.optional(),scope:Fs.optional(),localizations:vs.optional(),used:R().finite().nonnegative().optional(),limit:R().finite().nonnegative().optional(),unit:I().min(1).max(32).optional(),usagePercent:Ns,resetsAt:I().min(1).optional()}).strict(),Ls=V({availableCount:R().int().safe().positive(),nextExpiresAt:I().min(1).optional(),expiresAt:B(I().min(1)).min(1).max(32).optional()}).strict(),Rs=V({used:R().finite().nonnegative().optional(),limit:R().finite().nonnegative().optional(),unit:I().min(1).max(32).optional(),label:I().min(1).optional(),scope:Fs.optional(),localizations:vs.optional(),usedPercent:Ns,resetsAt:I().min(1).optional(),periodType:Ps,productUsage:B(Is).min(1).optional(),resetCredits:Ls.optional()}).strict(),zs=V({amount:R().finite().nonnegative(),currency:I().trim().min(1).max(8),label:I().trim().min(1).max(128).optional()}).strict();V({threadId:K,refresh:G(`exact`).optional()}).strict(),V({threadId:K,usage:Ms.nullable(),accountCredits:Rs.optional(),accountBalance:zs.optional(),accountCreditsSupported:z().optional()}).strict();let Bs=I().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),Vs=I().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Model Ref must not contain control characters`).brand(),Hs=W([`priority`,`ultrafast`]),Us=V({id:Vs,serviceTier:Hs.optional()}).strict();function Ws(e,t){return e?.id===t?.id&&e?.serviceTier===t?.serviceTier}let Gs=Bs.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand(),Ks=Bs.max(256),qs=V({id:Gs,label:Bs.max(256)}).strict(),Js=V({ref:Us,label:Bs.max(256),resolvedModelLabel:Ks.optional(),fastModel:Us.optional(),supportedThinkingOptionIds:B(Gs).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 Ys(e,t){if(t)return e?.models.find(e=>Ws(e.ref,t)||Ws(e.fastModel,t))}let Xs=B(qs).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)}),Zs=V({models:B(Js),defaultModel:Us.optional(),thinkingOptions:Xs,defaultThinkingOptionId:Gs.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=>Ws(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=>Ws(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&&!Ys(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`]})}),Qs=V({fork:z(),forkAcrossCwd:z(),rollbackLastTurn:z()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),$s=W([`live`,`atCreate`]),ec=V({configuration:V({selectModel:z(),selectThinkingOption:z(),selectPermissionMode:z(),permissionModeScope:$s.default(`live`)}).strict(),history:Qs,subagents:V({observe:z(),readTranscript:z()}).strict().optional(),autonomousTurns:V({observe:z()}).strict().optional(),steer:z().optional(),persistentPlan:z().optional()}).strict();V({effectiveModel:Us.optional(),resolvedModelLabel:Ks.optional(),effectiveThinkingOptionId:Gs.optional(),availableThinkingOptions:Xs.optional(),effectivePermissionModeId:ws.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 tc=V({open:G(!0)}).strict();Eo([V({status:G(`ready`),catalog:Zs,permissionModes:Ts.optional(),capabilities:ec,webUi:tc.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`]})}),V({status:W([`notInstalled`,`unavailable`,`error`]),error:hs}).strict()]),V({harnessId:xs,cwd:Bs.max(16384).optional(),refresh:z().optional(),purpose:G(`availability`).optional(),credentialAccess:W([`allow`,`retry`]).optional()}).strict(),V({harnessId:xs}).strict(),V({}).strict(),V({threadId:K,model:Us}).strict(),V({threadId:K,thinkingOptionId:Gs}).strict(),V({threadId:K,includeReferenceCapability:z().optional()}).strict(),U(`owner`,[V({owner:G(`codex`),locked:z(),effectiveModel:Us.optional(),resolvedModelLabel:Ks.optional(),effectiveThinkingOptionId:Gs.optional(),effectivePermissionModeId:ws.optional(),history:Qs.optional(),supportsThreadReferences:G(!0).optional()}).strict(),V({owner:G(`external`),harnessId:Bs.max(256),transportModelId:Bs.max(8192),effectiveModel:Us.optional(),resolvedModelLabel:Ks.optional(),effectiveThinkingOptionId:Gs.optional(),availableThinkingOptions:Xs.optional(),effectivePermissionModeId:ws.optional(),catalog:Zs.optional(),history:Qs,usage:Ms.optional(),locked:G(!0)}).strict()]),V({threadIds:B(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 nc=U(`owner`,[V({threadId:K,owner:G(`codex`)}).strict(),V({threadId:K,owner:G(`external`),harnessId:I().max(256).pipe(xs)}).strict()]);V({threads:B(nc).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)}),V({threadId:K,text:I().optional()}).strict(),V({kind:G(`application`),value:I().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),ge}}).pipe(V({expectedTurnId:Ss,clientUserMessageId:I().min(1),delivery:W([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),W([`activeTurn`,`newTurn`]),V({delivery:W([`official`,`activeTurn`,`newTurn`])}).strict();let rc=I().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u),ic=rc.pipe(xs),ac=ic.refine(e=>e!==`codex`,`The official Codex identity is reserved`),oc=I().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`),sc=Xa().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),cc=V({en:I().max(4096),"zh-CN":I().max(4096).optional()}).strict(),lc=V({commands:B(V({terminal:I().max(256),command:I().max(4096)}).strict()).max(8),before:cc.optional(),after:cc.optional(),downloads:B(V({label:I().max(128),url:sc}).strict()).max(8).optional()}).strict(),uc={id:ic,name:I().trim().min(1).max(128),version:I().min(1).max(128),kind:G(`usage`).optional(),iconStyle:V({vector:V({viewBox:I().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:I().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:B(V({d:I().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:W([`evenodd`,`nonzero`]).optional(),fill:I().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:I().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:R().min(0).max(50).optional(),paddingRatio:R().min(0).max(.25).optional()}).strict().optional(),installation:lc.optional(),notice:cc.optional(),launchCommand:G(!0).optional(),links:V({website:sc.optional(),documentation:sc.optional(),installation:sc.optional()}).strict().optional()};V({manifestVersion:G(1),...uc,adapterApiVersion:R().int().positive(),entry:oc,icon:oc.optional()}).strict();let dc=I().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),fc=V({...uc,icon:dc.optional()}).strict();V({}).strict(),V({plugins:B(fc.extend({id:ac})).max(128)}).strict(),V({version:G(1),enabled:B(ic).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]});let pc=rc,mc=W([`sidebar.thread-layout`,`sidebar.thread-badge`,`appearance.theme`]),hc=W([`appearance`,`interface`,`workflow`,`analytics`,`integrations`,`tools`]),gc=I().trim().min(1).max(128);function _c(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 vc=e=>e.split(`/`).every(e=>!/[. ]$/u.test(e)),yc=oc.refine(e=>_c(e)!==void 0&&vc(e),`Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space`),bc=I().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu,`Expected an HTTP(S) URL`).pipe(Xa({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 xc(e){return H({en:e,"zh-CN":e})}let Sc=xc(I().trim().min(1)),Cc=B(hc).max(hc.options.length).refine(e=>new Set(e).size===e.length,`Duplicate categories`),wc=B(mc).max(mc.options.length).refine(e=>new Set(e).size===e.length,`Duplicate slots`),Tc={key:I().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),label:Sc,description:Sc.optional()},Ec={...Tc,step:R().positive().optional(),default:R().optional()},Dc=H({value:I(),label:Sc}),Oc=U(`type`,[H({...Tc,type:G(`boolean`),default:z().optional()}),H({...Tc,type:G(`string`),placeholder:Sc.optional(),default:I().optional()}),H({...Ec,type:G(`number`),min:R().optional(),max:R().optional()}),H({...Ec,type:G(`range`),min:R(),max:R()}),H({...Tc,type:G(`select`),options:B(Dc).min(1),default:I().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`)}}),kc=V({manifestVersion:ho().positive(),id:pc,name:Eo([gc,xc(gc)]),version:I().min(1).max(128),desktopApi:ho().positive()}).passthrough().extend({manifestVersion:G(1),desktopApi:G(1),description:H({en:I().max(4096),"zh-CN":I().max(4096).optional()}).optional(),author:I().trim().min(1).max(128).optional(),repository:bc.optional(),details:H({en:I().max(16384),"zh-CN":I().max(16384).optional()}).optional(),icon:yc.optional(),screenshots:B(yc).max(4).refine(e=>new Set(e).size===e.length,`Duplicate screenshots`).optional(),desktop:H({script:oc,style:oc.optional()}).optional(),backend:H({script:oc.refine(vc)}).optional(),slots:wc.default(()=>[]),settingsSchema:B(Oc).max(32).refine(e=>new Set(e.map(({key:e})=>e)).size===e.length,`Duplicate setting keys`).optional(),categories:Cc.optional()}).strict().refine(e=>e.desktop!==void 0||e.backend!==void 0,`Expected at least one desktop or backend entry`),Ac=I().regex(/^[a-f0-9]{64}$/u),jc=H({state:W([`running`,`disabled`,`invalid`,`incompatible`,`conflict`,`failed`,`waiting`]),hash:Ac.optional(),error:I().optional(),conflictWith:pc.optional()});H({controllerPid:ho().positive(),targetId:I().nullable(),updatedAt:xa(),handledReloadToken:Ja().optional(),extensions:No(I(),jc),surfaces:No(I(),jc).optional()});let Mc=W([`official`,`community`]);function Nc(e){return e.origin===`https://api.github.com`&&/^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(e.pathname)}let Pc=bc.refine(e=>{let t=new URL(e);return/\.zip$/iu.test(t.pathname)||Nc(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`),Fc=H({id:pc,version:I().trim().min(1).max(128),name:Sc.extend({en:gc,"zh-CN":gc}),description:xc(I().trim().min(1).max(4096)),details:xc(I().trim().min(1).max(16384)).optional(),author:I().trim().min(1).max(128),repository:bc,stars:R().int().min(0).optional(),downloads:R().int().min(0).optional(),categories:Cc.optional(),trustTier:Mc.default(`community`),icon:bc.optional(),screenshots:B(bc).max(4).optional(),downloadUrl:Pc,sha256:Ac,slots:wc.optional(),publishedAt:I().optional(),updatedAt:I().optional(),minCodexHostVersion:I().optional()});H({schemaVersion:G(1),generatedAt:I(),extensions:B(Fc).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)});let Ic=I().trim().min(1).max(128),Lc=/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu,Rc=pc.refine(e=>!Lc.test(e),`Reserved extension ID`),zc=W([`desktop`,`web`]),Bc=Ac,Vc=Ja(),Hc=oc.refine(e=>!/[\x00-\x1f\x7f<>"|*]/u.test(e)&&e.split(`/`).every(e=>!/[. ]$/u.test(e)&&!Lc.test(e)),`Expected a portable relative resource path`).refine(e=>e.split(`/`).length<=32,`Extension resources may be at most 32 segments deep`),Uc=kc.shape,Wc=(e,t=0)=>H({en:I().trim().min(t).max(e),"zh-CN":I().trim().min(t).max(e)}),Gc=e=>Hc.refine(t=>t.endsWith(e),`Expected a ${e} file`),Kc=Gc(`.mjs`),qc=Gc(`.css`).optional(),Jc=e=>e.normalize(`NFC`).toLowerCase(),Yc=H({manifestVersion:G(2),id:Rc,name:Wc(128,1),version:I().trim().min(1).max(128),description:Wc(4096),details:Wc(16384).optional(),author:Uc.author,repository:Uc.repository,icon:Uc.icon.refine(e=>e===void 0||Hc.safeParse(e).success),screenshots:Uc.screenshots.refine(e=>e===void 0||e.every(e=>Hc.safeParse(e).success)),categories:Uc.categories,settingsSchema:Uc.settingsSchema,slots:Uc.slots.removeDefault().optional(),page:H({apiVersion:G(1),entry:Kc,style:qc,title:Wc(128,1).optional()}).optional(),widget:H({apiVersion:G(1),entry:Kc,style:qc}).optional(),desktop:H({apiVersion:G(1),script:Gc(`.js`),style:qc}).optional(),web:H({apiVersion:G(1),entry:Kc.optional(),style:qc}).refine(({entry:e,style:t})=>e!==void 0||t!==void 0,`Expected a Web entry or style`).optional(),backend:H({apiVersion:G(1),entry:Kc}).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||Jc(e)!==Jc(r.entry)),{path:[`backend`,`entry`],message:`A backend entry cannot also be a frontend entry`});function Xc({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 Zc=Ic,Qc=ho().nonnegative(),$c=H({revision:Qc,enabled:B(Rc).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)}),{downloadUrl:el,...tl}=Fc.shape,nl=V({...tl,id:Rc,format:G(`codexhost`),targets:B(zc).min(1).max(2).refine(e=>new Set(e).size===e.length,`Duplicate targets`),apis:H({page:ho().positive().optional(),widget:ho().positive().optional(),desktop:ho().positive().optional(),web:ho().positive().optional(),backend:ho().positive().optional()}),downloadUrl:el.refine(e=>e.startsWith(`https://`),`Expected HTTPS`)}).refine(({targets:e,apis:t})=>{let n=Xc({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`);V({schemaVersion:G(2),generatedAt:I().min(1),extensions:B(nl).max(1e4).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)}).extend({catalogUrl:bc,fetchedAt:xa(),cached:z()});let rl={id:Rc},il={...rl,activationId:Vc,digest:Bc},al={...rl,activationId:il.activationId.optional()},ol=I().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`),sl=I().min(1).max(256).refine(e=>e.split(`/`).every(e=>e&&/^[a-z0-9_.-]+$/iu.test(e)&&e!==`.`&&e!==`..`),`Invalid GitHub ref`);function cl(e){return I().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 ll=H({type:G(`github`),repository:I().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),ref:sl.optional(),tag:sl.optional(),asset:I().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),subpath:Hc.optional()}).refine(({ref:e,tag:t,asset:n})=>!e||!t&&!n,`Use either a zipball ref or a release tag/asset`),ul=Eo([H({type:G(`catalog`),...rl}),ll,H({type:G(`zip`),base64:cl(67108864).min(4)}),H({type:G(`zip`),localZipPath:ol}),H({type:G(`localDir`),localDir:ol})]),dl=U(`type`,[H({type:G(`catalog`),...rl}),ll,H({type:G(`zip`)}),H({type:G(`localDir`)})]),fl=H({...il,manifest:Yc,installedAt:xa(),source:dl.optional()}),pl=e=>I().max(23+4*Math.ceil(e/3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u),ml={desktopConflictWith:Rc.optional()},hl=W([`none`,`inactive`,`starting`,`running`,`failed`]),gl=U(`state`,[fl.extend({state:G(`valid`),enabled:z(),...ml,iconDataUrl:pl(131072).optional(),screenshotDataUrls:B(pl(524288)).max(4).optional(),backendState:hl.optional(),backendError:I().optional()}),H({state:W([`invalid`,`incompatible`]),id:I().min(1),enabled:z(),error:I()})]);H({revision:Qc,configuration:$c,diagnostics:B(I()),extensions:B(gl)}),H({revision:Qc,extensions:B(fl.extend({...ml,settingsRevision:Qc})).max(64)});let _l={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`},vl=Object.freeze(Object.values(_l));new Set(vl),H({});let yl={expectedRevision:Qc};H({...rl,...yl}),fl.extend({replaced:z()}),U(`state`,[H({state:G(`saved`),configuration:$c}),H({state:G(`revision-conflict`),revision:Qc})]),H({...al,digest:il.digest.optional(),path:Hc}),H({mimeType:I().min(1),base64:cl(16777216),digest:il.digest}),H({settingsRevision:Qc,values:ms}),_l.list,_l.snapshot,_l.catalog,H({forceRefresh:z().optional()}),_l.install,H({source:ul}),_l.update,H({...rl,expectedDigest:il.digest,expectedActivationId:il.activationId.optional(),source:ul.optional()}),_l.enable,_l.disable,_l.uninstall,H({...rl,removeData:z().optional(),expectedDigest:il.digest.optional()}),H({...rl,removed:z()}),_l.recover,H({expectedRevision:yl.expectedRevision.optional()}),_l.asset,_l.settingsGet,H(al),_l.settingsSet,H({...al,expectedSettingsRevision:Qc,values:ms}),_l.backendInvoke,H({...al,method:Zc,params:ps.optional()}),H({result:ps}),V({threadId:K}).strict(),V({confirmed:z()}).strict(),[...vl],V({sections:B(V({id:I().min(1),name:I().min(1),threads:B(ms)}).strict())}).strict(),V({threadId:I().min(1).max(1024),sectionId:I().min(1).max(1024).nullable()}).strict(),V({threadIds:B(I().min(1))}).strict(),V({threadId:I().min(1).max(1024),pinned:z()}).strict(),V({}).strict(),V({parents:No(I().min(1),I().min(1))}).strict(),V({prompt:I().max(16384).optional()}).strict(),V({projects:B(V({id:I(),name:I(),rootPaths:B(I())})),assignments:No(I(),I()),projectless:B(I()),pinned:B(I()),sectionProjects:No(I(),B(I())).optional()});let bl=No(I(),bo()),xl=V({epoch:I().uuid(),sequence:R().int().nonnegative()});U(`type`,[V({type:G(`skills-changed`),cursor:xl,cwd:I().optional()}),V({type:G(`harness-inspection-changed`),cursor:xl,harnessId:I().min(1)}),V({type:G(`display-settings-changed`),cursor:xl}),V({type:G(`preferences-changed`),cursor:xl,revision:R().int().nonnegative()}),V({type:G(`extensions-changed`),cursor:xl,revision:Qc}),V({type:G(`hello`),version:G(1),cursor:xl,reset:z()}),V({type:G(`changed`),cursor:xl,threadId:I().min(1),method:I().min(1)})]);let Sl=U(`type`,[V({type:G(`text`),id:I(),prompt:I(),secret:z().optional(),optional:z().optional()}),V({type:G(`choice`),id:I(),prompt:I(),multiple:z(),allowOther:z(),optional:z().optional(),options:B(V({value:I(),label:I(),description:I().optional()}))})]),Cl=U(`type`,[V({type:G(`approval`),title:I(),description:I().optional(),subject:bo().optional(),actions:B(V({id:I(),label:I(),effect:I()}))}),V({type:G(`question`),title:I().optional(),questions:B(Sl)})]),wl=V({requestId:Eo([I(),R().int()]),threadId:I(),kind:W([`approval`,`question`]),interaction:Cl,request:bl}),Tl=V({id:I().min(1),clientUserMessageId:I().min(1),input:B(bl),presentationInput:B(bl).nullable().optional()}).passthrough();V({fields:B(V({path:B(Eo([I(),R().int().nonnegative()])),originalLength:R().int().nonnegative()}))});let El=V({id:I().min(1),status:I().min(1),codexhostTurnOutcome:V({status:G(`unknown`),reason:I()}).optional(),items:B(V({id:I().min(1),type:I().min(1)}).passthrough()),codexhostFileOperations:B(V({beforeItemId:I().nullable(),item:V({id:I().min(1),type:I().min(1)}).passthrough()})).optional(),error:V({message:I().optional()}).passthrough().nullable().optional(),fingerprint:I().min(1).optional(),unchanged:G(!0).optional()}).passthrough(),Dl=V({id:I().min(1).max(512),fingerprint:I().min(1).max(128)});V({threadId:I().min(1),knownTurns:B(Dl).max(64).optional(),truncateToolOutput:z().optional()});let Ol=V({harnessId:I().min(1),nativeSessionId:I().min(1)});V({cursor:xl,activeTurnId:I().min(1).nullable().optional(),command:V({name:I().min(1),turn:El,subsequentTurnId:I().min(1).optional()}).optional(),thread:V({id:I().min(1),cwd:I(),modelProvider:I().min(1),createdAt:R(),updatedAt:R(),status:V({type:I()}).passthrough(),name:I().nullable().optional(),preview:I().optional(),codexhostImportSource:Ol.optional(),turns:B(El).length(0)}).passthrough(),turnsPage:V({data:B(El).max(5),nextCursor:I().nullable()}),configuration:V({native:V({model:I().min(1).max(1024).optional(),reasoningEffort:I().min(1).max(128).optional()}).optional(),effectiveModel:Us.optional(),effectiveThinkingOptionId:Gs.optional(),effectivePermissionModeId:ws.optional()}),queue:V({items:B(Tl),pausedReason:W([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:B(wl)}),V({version:G(1),owner:G(`service`).optional(),pid:R().int().positive(),port:R().int().min(1).max(65535),token:I().regex(/^[0-9a-f]{64}$/u),startedAt:R(),epoch:I().uuid()}),V({epoch:I().uuid(),threadId:I().min(1),requestId:Eo([I(),R().int()]),result:bl}),V({includeArchived:z().optional(),officialCursor:V({live:I().nullable(),archived:I().nullable().optional()}).strict().optional(),scope:V({cwd:I().min(1).max(4096),excludeCwds:B(I().min(1).max(4096)).max(1024)}).strict().optional()}).strict(),V({threads:B(ms),ownership:B(nc),archivedThreadIds:B(K),officialCursor:V({live:I().nullable(),archived:I().nullable().optional()}).strict().optional()}).strict();let kl=W([`running`,`waiting`,`idle`,`unknown`]),Al=H({harnessId:xs,title:I().optional(),status:kl,archived:z()}),jl=H({revision:ho().nonnegative(),parents:No(K,K),nodes:No(K,Al),truncated:z()}).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`),Ml=I().min(1).max(128);H({});let Nl=H({subscriptionId:Ml});H({}),Nl.extend({snapshot:jl});let Pl=I().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);V({available:z()}).strict(),V({path:I().min(1),mimeType:Pl}).strict();let Fl=W([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);U(`ok`,[V({ok:G(!0),text:I()}).strict(),V({ok:G(!1),error:V({code:Fl}).strict()}).strict()]),V({threadId:K.optional(),cwd:I().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let Il=V({name:I().min(1).regex(/^[^\s[\]]+$/u),description:I().optional(),path:I().min(1),scope:W([`project`,`global`]),source:I().min(1)}).strict();V({revision:R().int().nonnegative(),complete:z(),skills:B(Il),warnings:B(I()).optional()}).strict(),V({cwd:I().min(1).optional()}).strict();let Ll=V({kind:W([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:I().min(1)}).strict(),Rl=U(`status`,[V({status:G(`not-installed`)}),V({status:G(`not-running`)}),V({status:G(`not-logged-in`)}),V({status:G(`https-disabled`)}),V({status:G(`not-serving`),command:I()}),V({status:G(`occupied`),target:I()}),V({status:G(`serving`),url:I(),funnel:z()}),V({status:G(`error`),message:I()})]);V({state:Rl,error:I().optional()}).strict();let zl=U(`status`,[V({status:G(`on`)}),V({status:G(`off`)}),V({status:G(`invalid`),reason:I()})]),Bl=V({lan:z(),autostart:zl}).strict(),Vl=V({expiresAt:I().optional(),issuing:z(),failure:V({detail:I().optional(),retryAt:I(),paused:z()}).optional()}),Hl=U(`status`,[V({status:G(`off`),reason:W([`invite`,`name-taken`,`banned`]).optional()}),V({status:G(`connecting`),reason:W([`full`,`unreachable`]).optional()}),V({status:G(`connected`),url:I(),certificate:Vl}),V({status:G(`missing-certificate`),url:I(),certificate:Vl}),V({status:G(`stopped`),reason:W([`replaced`,`rejected`,`unsupported-version`])})]);I().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()),I().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let Ul=W([`official`,`self-hosted`]);V({secret:I().min(1),lastUsedAt:R().nullable(),networkUrls:B(Ll),directCandidates:B(Ll).optional(),tailscale:Rl,background:Bl.optional(),relay:V({state:Hl,enabled:z(),kind:Ul,officialHost:I(),customHost:I().optional(),officialHostname:I().optional(),customHostname:I().optional(),quotaUntil:I().optional()}).strict().optional()}).strict();let Wl=H({threadId:I().min(1).max(1024),view:W([`result`,`messages`]),from:R().int().min(1).max(2**53-1).optional(),to:R().int().min(1).max(2**53-1).optional()}),Gl=V({id:I().min(1).max(256),harnessId:I().min(1),label:I().min(1).max(512),provider:W([`openai-codex`,`xai`])}).strict(),Kl=I().regex(/^[a-z][a-z0-9-]{0,47}$/),ql=V({name:Kl,source:Gl,importedAt:I()}).strict(),Jl=U(`action`,[V({action:G(`list`)}).strict(),V({action:G(`import`),sourceId:I().min(1).max(256),name:Kl,confirmed:G(!0)}).strict(),V({action:G(`reimport`),sourceId:I().min(1).max(256),name:Kl,confirmed:G(!0)}).strict(),V({action:G(`remove`),name:Kl,confirmed:G(!0)}).strict()]),Yl=V({provider:I().min(1).max(128),type:W([`oauth`,`api_key`,`unknown`]),label:I().min(1).max(512).optional(),vendor:W([`openai-codex`,`xai`]).optional()}).strict();V({sources:B(Gl),targets:B(V({harnessId:I(),providers:B(W([`openai-codex`,`xai`])),imports:B(ql),others:B(Yl).default([])}).strict())}).strict(),V({targetHarnessId:I().min(1).max(128).optional(),request:Jl}).strict(),V({events:z()});let Xl=B(H({agent:I().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`);H({entries:Xl.nullable()}),H({}),H({entries:Xl,initializeOnly:z().optional()});let Zl=H({enabled:z(),timeoutMinutes:R().int().min(5).max(1440)});Object.freeze({enabled:!0,timeoutMinutes:10});let Ql=I().regex(/^external$/u),$l=xs.transform(e=>String(e)),eu=H({model:Us.optional(),thinkingOptionId:Gs.optional(),permissionModeId:ws.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`),tu=H({lastHarness:xs.optional(),byHarness:No($l,eu)}),nu=H({model:Us.optional(),thinkingOptionId:Gs.optional()}).refine(e=>!!(e.model||e.thinkingOptionId),`A delegation default must contain a Model or Thinking option`),ru=H({byHarness:No($l,nu)}),iu=I().min(1).max(1024),au=H({idleRelease:Zl.optional(),favorites:No($l,B(iu).max(2048)).default({}),newThread:tu.optional(),delegation:ru.optional()});H({scope:Ql,revision:R().int().nonnegative(),values:au}),H({scope:Ql.default(`external`)});let ou=U(`kind`,[H({kind:G(`idleRelease`),value:Zl}),H({kind:G(`favorite`),harnessId:xs,modelId:iu,enabled:z()}),H({kind:G(`favorites`),harnessId:xs,modelIds:B(iu).max(2048)}),H({kind:G(`newThread`),lastHarness:xs.optional(),harnessId:xs.optional(),configuration:eu.optional()}),H({kind:G(`delegation`),harnessId:xs,configuration:nu.nullable()})]);H({scope:Ql.default(`external`),operations:B(ou).min(1).max(256),initializeOnly:z().optional(),expectedRevision:R().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`})}),H({version:G(1),revision:R().int().nonnegative(),scopes:No(Ql,au)});let su=R().finite().nonnegative(),cu=H({input:su,output:su,cacheRead:su.optional(),cacheWrite:su.optional(),cacheWrite1h:su.optional()}),lu=I().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);H({path:I(),entries:B(H({key:I(),price:cu})),error:I().nullable()}),H({}),H({key:lu,price:cu.nullable(),previousKey:lu.optional()}),H({model:lu});let uu=H({official:z().optional(),canonicalModelId:I().min(1).optional(),provider:I().min(1).max(512),model:I().min(1).max(512),price:cu});H({price:cu.nullable(),suggestions:B(uu).max(6).optional()});let du=[`today`,`7d`,`30d`,`90d`,`all`],fu=R().int().min(0).max(2**53-1),pu=I().regex(/^\d{4}-\d{2}-\d{2}$/u),mu=I().min(1).max(128),hu=I().min(1).max(512),gu=I().min(1).max(4096);H({range:W(du),timeZone:I().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:mu.optional(),model:hu.nullable().optional(),project:gu.nullable().optional(),date:pu.optional()});let _u=H({requests:fu,inputTokens:fu,cachedInputTokens:fu,cacheWriteInputTokens:fu,cacheKnownInputTokens:fu,cacheHitCachedInputTokens:fu,cacheHitInputTokens:fu,outputTokens:fu,reasoningOutputTokens:fu,costUsd:R().finite().min(0),unpricedRequests:fu,unmeteredRequests:fu}),vu=_u.shape,yu=H({harness:mu,sessionId:I().min(1).max(512),project:gu.nullable(),title:I().min(1).max(200).optional(),models:B(hu).max(16),firstAtMs:fu,lastAtMs:fu,...vu});H({range:W(du),from:pu.nullable(),to:pu,filters:H({harness:mu.nullable(),model:hu.nullable(),unknownModel:z(),project:gu.nullable(),unknownProject:z(),date:pu.nullable()}),reading:H({complete:z(),sources:fu,read:fu}),failures:B(H({harness:mu,message:I().max(2048)})).max(256),options:H({harnesses:B(mu).max(256),models:B(hu.nullable()).max(4096),projects:B(gu.nullable()).max(4096)}),modelLabels:B(H({harness:mu,model:hu,label:hu})).max(4096).optional(),credits:B(H({harness:mu,model:hu.nullable(),credits:R().finite().min(0),reportedRequests:fu,requests:fu})).max(4096).optional(),totals:_u,daily:B(H({date:pu,harness:mu,...vu})).max(2e5),hourly:B(H({weekday:R().int().min(0).max(6),hour:R().int().min(0).max(23),...vu})).max(168),byHarness:B(H({harness:mu,...vu})).max(256),byModel:B(H({model:hu.nullable(),...vu,harnessPricedRequests:fu})).max(4096),byProject:B(H({project:gu.nullable(),...vu})).max(4096),sessions:B(yu).max(100),recentSessions:B(yu).max(100).optional()}),V({threadId:K}),V({discarded:z()});let bu=U(`type`,[V({id:I().min(1),type:G(`choice`),prompt:I(),options:B(V({value:I().min(1),label:I(),description:I().optional()})).min(1),multiple:z(),allowOther:z(),optional:z()}),V({id:I().min(1),type:G(`text`),prompt:I(),multiline:z(),secret:G(!1),optional:z(),placeholder:I().optional(),prefill:I().optional()})]),xu=V({interactionId:I().min(1),turnId:I().min(1),title:I().optional(),questions:B(bu).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});H({threadId:I().min(1)}),V({questions:B(xu)}),H({threadId:I().min(1),turnId:I().min(1),interactionId:I().min(1),answers:No(I(),B(I())),cancelled:z().default(!1)}),V({accepted:G(!0)});let Su=V({path:I(),oldText:I().nullable(),newText:I()});V({sessionId:I().min(1),turn:R().int().nonnegative(),path:I().min(1).optional()}),V({diffs:B(Su)}),H({}),H({}),V({reference:V({sessionId:I().min(1),epoch:I().min(1),turn:R().int().nonnegative(),seq:R().int().nonnegative(),callId:I().min(1),part:R().int().nonnegative(),version:I().min(1)}),length:R().int().nonnegative(),bytes:R().int().nonnegative()}),H({title:I().trim().min(1).max(200),type:W([`info`,`warning`,`danger`]),body:I().trim().min(1).max(16384)}),H({}),H({url:I().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 Cu=W([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),wu=W([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);H({threadId:I(),title:I(),harnessId:I(),state:Cu,reason:wu,inactiveMs:R().nonnegative()}),H({threadId:K,turnId:Ss});let Tu=V({email:I().trim().min(1).max(320).optional(),label:I().trim().min(1).max(256).optional(),plan:I().trim().min(1).max(128).optional(),credits:Rs.optional(),balance:zs.optional()}).strict();function Eu(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 Du=Eu(Tu),Ou={harnessId:xs,harnessName:I().trim().min(1).max(128)},ku=V(Ou).strict();V({}).strict(),V({sources:B(ku).max(128)}).strict(),V({harnessId:xs,refresh:z().optional()}).strict(),V({...Ou,account:Du.nullable(),accounts:B(Du).max(8).optional()}).strict(),V({refresh:z().optional()}).strict(),V({accounts:B(Eu(Tu.extend(Ou))).max(128)}).strict(),V({harnessId:ac,model:Us.optional(),thinkingOptionId:Gs.optional(),permissionModeId:ws.optional(),prewarm:G(!0).optional()}).strict();let Au=I().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);V({harnessId:ac}).strict().extend({path:Au.nullable()}),V({path:Au.nullable(),restartRequired:z()}).strict(),V({harnessId:xs,action:W([`check`,`update`,`install`]),confirmedVersion:I().min(1).max(128).optional()}).strict().refine(({action:e,confirmedVersion:t})=>e===`update`||t===void 0);let ju=V({currentVersion:I().min(1).max(128),latestVersion:I().min(1).max(128),updateAvailable:z(),canUpdate:z(),latestVerifiedVersion:I().min(1).max(128).optional(),confirmationRequired:G(!0).optional(),versionKind:W([`cli`,`application`]).optional(),manualUpdateUrl:Xa().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:I().max(2048).optional(),messageCode:I().min(1).max(128).optional(),notice:ys.optional(),latestVersionKind:W([`unknown`,`tracking-branch`]).optional()}).strict();V({taskId:I().uuid()}).strict(),U(`status`,[V({taskId:I().uuid(),status:G(`running`)}).strict(),V({taskId:I().uuid(),status:G(`succeeded`),result:ju}).strict(),V({taskId:I().uuid(),status:G(`failed`),error:V({code:R().int(),message:I().min(1).max(2048)}).strict()}).strict()]);let Mu=I().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),Nu=I().trim().min(1),Pu=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`]),Fu=V({accountId:Mu,label:Nu.max(256),email:I().email().max(320).optional(),planType:Pu.optional()}).strict(),Iu=W([`ready`,`unavailable`]);V({version:G(2),currentAccountId:Mu.nullable(),phase:Iu,revision:R().int().nonnegative(),instanceId:Nu.max(1024).optional(),accounts:B(Fu).max(1)}).strict(),V({accountId:Mu,refresh:z().optional()}).strict(),V({accountId:Mu,usage:Ms.nullable(),accountCredits:Rs.optional(),freshness:W([`live`,`cached`]),observedAt:I().datetime().nullable()}).strict();let Lu=1e3,Ru=I().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),zu=Ru.max(1024),Bu=V({nativeSessionId:zu,title:Ru.max(4096).nullable(),updatedAt:R().int().nonnegative().max(864e13),cwd:Ru.max(16384),running:z().nullable()}).strict();V({}).strict(),V({harnesses:B(V({harnessId:ac,name:Ru.max(128)}).strict()).max(128)}).strict(),V({harnessId:ac,query:I().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:R().int().nonnegative().safe().optional(),limit:R().int().min(1).max(Lu).optional()}).strict(),V({candidates:B(Bu).max(Lu),total:R().int().nonnegative().safe()}).strict(),V({harnessId:ac,nativeSessionId:zu}).strict(),V({threadId:Ru.max(1024).pipe(K)}).strict();let Vu=I().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),Hu=zu,Uu=Bu;V({}).strict(),V({candidates:B(Uu).max(1e3)}).strict(),V({nativeSessionId:Hu}).strict(),V({threadId:Vu.max(1024).pipe(K)}).strict(),V({threadId:K,lastTurnId:Ss}).strict(),V({threadId:K}).strict();let Wu=I().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();V({commands:B(V({id:Wu,invocation:I().min(1).max(128),label:I().trim().min(1).max(128),description:I().trim().min(1).max(512).optional(),localizations:vs.optional(),argumentMode:W([`none`,`text`]),kind:W([`command`,`skill`]).optional()}).strict()),warnings:B(I().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)}),V({harnessId:xs,cwd:I().min(1).optional()}).strict(),V({threadId:K}).strict(),V({threadId:K,commandId:Wu,turnId:Ss.optional(),arguments:ms.optional()}).strict(),V({accepted:G(!0),turnId:Ss.optional()}).strict();let Gu=G(`2.0`).optional(),Ku=So().optional(),qu=I().min(1),Ju=Eo([I(),R().int()]),Yu=V({code:R().int(),message:I(),data:ps.optional()}).catchall(ps).superRefine(cs([`data`]));Eo([V({jsonrpc:Gu,id:Ju,method:qu,params:ps.optional(),result:Ku,error:Ku}).catchall(ps).superRefine(cs([`jsonrpc`,`params`,`result`,`error`])),V({jsonrpc:Gu,id:Ku,method:qu,params:ps.optional(),result:Ku,error:Ku}).catchall(ps).superRefine(cs([`jsonrpc`,`id`,`params`,`result`,`error`])),V({jsonrpc:Gu,id:Ju,method:Ku,params:Ku,result:ps,error:Ku}).catchall(ps).superRefine(cs([`jsonrpc`,`method`,`params`,`error`])),V({jsonrpc:Gu,id:Ju,method:Ku,params:Ku,result:Ku,error:Yu}).catchall(ps).superRefine(cs([`jsonrpc`,`method`,`params`,`result`]))]);let Xu=I().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});H({harnessId:xs,nativeSessionId:Xu,locator:ps.optional(),formatVersion:G(1)}).superRefine(cs([`locator`])),H({harnessId:xs,nativeSessionId:Xu,nativeTurnKey:Xu,formatVersion:G(1)}),H({harnessId:xs,nativeSessionId:Xu,checkpointId:Xu,locator:ps.optional(),formatVersion:G(1)}).superRefine(cs([`locator`]));let Zu=I().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),Qu=W([`npm`,`windows-installer`,`macos-dmg`,`linux-archive`]),$u=H({version:Zu,installation:Qu,phase:W([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),updatedAt:R().int().nonnegative(),downloadedBytes:R().int().nonnegative().optional(),totalBytes:R().int().positive().optional(),error:I().min(1).max(500).nullable(),serviceStopOutput:I().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`})});H({});let ed=I().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`);H({currentVersion:Zu,installation:Qu.nullable(),latestVersion:Zu.nullable(),updateAvailable:z(),installationAvailable:z(),releaseNotes:I().min(1).max(2e4).nullable(),releaseNotesUrl:ed.nullable(),status:$u.nullable(),error:I().min(1).max(500).nullable()}),H({status:$u}),H({status:$u.nullable()});let td=H({icon:I().min(1).max(16).optional(),title:I().min(1).max(120),body:I().min(1).max(1200),contributors:B(I().min(1).max(39)).max(30)}),nd=H({summary:I().min(1).max(600).optional(),themes:B(td).min(1).max(12)}),rd=H({version:Zu,publishedAt:xa(),url:I().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),zh:nd.nullable(),en:nd.nullable()}).refine(e=>e.zh!==null||e.en!==null,{message:`an announcement needs at least one language`});H({manual:z().optional()}),H({announcement:rd.nullable(),unread:z()}),H({version:Zu});let id=RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);function ad(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=id.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 od=`<response-annotations>`,sd=`</response-annotations>`,cd=/## My request(?: for Codex)?:/gu;function ld(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${od}\n${JSON.stringify(t)}\n${sd}\n`}function ud(e,t){let n=ld(e);return n===``?t:`${n}\n## My request:\n${t}\n`}function dd(e){let t=e.trimStart().startsWith(`# Response annotations:`)?0:e.length,n=e.indexOf(`\n${od}\n`,t);if(n<0)return``;let r=n+1+22+1,i=e.indexOf(`\n${sd}`,r);return i<0?``:e.slice(r,i)}function fd(e){return{annotations:hd(e),body:pd(e)}}function pd(e){let t=0;for(let n of e.matchAll(cd))t=n.index+n[0].length;return e.slice(t).trim()}function md(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function hd(e){let t=dd(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(!md(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 gd(e){return hd(e)}let _d=W([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);V({runningVersion:I().nullable(),installedVersion:I().nullable(),restartRequired:z(),remote:z(),updateSupported:z(),update:V({phase:_d,targetVersion:I().nullable(),error:I().nullable()})});let vd=V({version:I().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();V({hostname:I().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:R().int().min(1).max(65535).nullable(),identity:I().max(4096).nullable(),action:W([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:z().optional(),version:I().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),V({state:W([`installed`,`not-installed`])}).strict();let q=I().min(1).max(1024),yd={hostId:q.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)},bd={...yd,threadId:q},xd=I().min(1).max(8e3),Sd={text:xd,requestId:q};U(`accepted`,[V({accepted:G(!0),startQueuedItemId:q.optional()}),V({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:I()})]),U(`available`,[V({available:G(!1)}),V({available:G(!0),items:B(V({id:q,clientUserMessageId:q,preview:I().max(801)})).max(100)})]);let Cd=U(`kind`,[H({kind:G(`hosts`)}),H({kind:G(`create`),...yd,cwd:I().min(1).max(8192),epoch:q}),H({kind:G(`projectHarnesses`),...yd,epoch:q}),H({kind:G(`inspectHarness`),...yd,epoch:q,cwd:I().min(1).max(8192),harnessId:q}),H({kind:G(`startSelected`),...yd,epoch:q,cwd:I().min(1).max(8192),harnessId:q,model:I().min(1).max(4096),serviceTier:W([`priority`,`ultrafast`]).optional(),reasoningEffort:q.optional()}),H({kind:G(`status`),...bd}),H({kind:G(`list`),...yd,cursor:I().nullable(),archived:z(),includeLoaded:G(!0).optional()}),H({kind:G(`read`),...bd,page:H({cursor:I().min(1).max(8192).nullable(),epoch:q.optional(),sortDirection:W([`asc`,`desc`]).optional(),limit:R().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),H({kind:G(`usage`),...bd,epoch:q}),H({kind:G(`configure`),...bd,epoch:q,modelId:q.optional(),serviceTier:Hs.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`}),H({kind:G(`prompt`),...bd,epoch:q,text:xd,requestId:q.optional()}),H({kind:G(`queue`),...bd,epoch:q}),H({kind:G(`delivery`),...bd,epoch:q,action:U(`kind`,[H({kind:G(`enqueue`),...Sd}),H({kind:G(`steer`),...Sd,turnId:q}),H({kind:G(`remove`),itemId:q}),H({kind:G(`start`),itemId:q,onlyIfHead:G(!0).optional()})])}),H({kind:G(`interrupt`),...bd,epoch:q,turnId:q}),H({kind:G(`rename`),...bd,epoch:q,name:I().min(1).max(512)}),H({kind:G(`archive`),...bd,epoch:q,archived:z()}),H({kind:G(`respond`),...bd,epoch:q,requestId:Eo([q,R().int()]),result:No(I(),bo())})]),wd=I().min(1).max(1024),Td=V({hostId:wd,displayName:I().min(1).max(1024),source:W([`codex-managed`,`discovered`]),sshAlias:I().max(1024).nullable(),sshHost:I().min(1).max(1024),sshPort:R().int().min(1).max(65535).nullable(),identity:I().max(4096).nullable(),autoConnect:z(),connectionAnalyticsId:I().max(1024).optional()}),Ed=H({displayName:I().min(1).max(1024),hostname:I().min(1).max(1024),sshPort:R().int().min(1).max(65535).nullable(),identity:I().max(4096).nullable()});U(`action`,[H({action:G(`session`),operation:Cd}),H({action:G(`list`)}),H({action:G(`catalog`)}),H({action:G(`read-thread`),hostId:wd.refine(e=>e!==`local`),input:Wl}),H({action:G(`save`),draft:Ed,previous:Td.nullable()}),H({action:G(`remove`),previous:Td}),H({action:G(`connect`),hostId:wd,enabled:z()}),H({action:G(`state`),hostId:wd}),H({action:G(`runtime`),hostId:wd}),H({action:G(`update`),hostId:wd.refine(e=>e!==`local`),version:vd.shape.version})]),Eo([H({result:ps}),H({error:H({code:R().int(),message:I()})})]),H({prompt:I().trim().min(1).max(2e3),cwd:I().max(4096).nullable()}),I().trim().min(1).max(60).nullable();let Dd=I().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),Od=Eo([I(),V({en:I()}).catchall(I())]),kd=V({title:Od.optional(),description:Od.optional(),icon:I().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:I().optional()});V({extensions:B(V({id:Dd,name:I().min(1).max(214),version:I().min(1).max(128),format:G(`dsh`),supportedTargets:jo([G(`web`)]),enabledTargets:B(G(`web`)).max(1),source:I().min(1).max(4096),projectUrl:I().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:I(),meta:kd.optional(),loadError:I().optional()})),loadedIds:B(Dd),safeMode:z(),storeError:I().optional()});let Ad=I().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}/`);V({spec:I().trim().min(1).max(4096),registry:Ad.optional()}).strict(),V({id:Dd,enabled:z()}).strict(),V({id:Dd}).strict();let jd=I().regex(/^[a-zA-Z0-9_-]{1,64}$/u),Md=I().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u),Nd=W([`relay`,`tailscale`,`lan`,`custom`]),Pd=W([`connected`,`connecting`,`auth-error`,`offline`,`disabled`]);V({peers:B(V({peerId:jd,hostId:Md,name:I().min(1).max(120),origin:I().min(1).max(2048),transportKind:Nd,encrypted:z(),enabled:z(),state:Pd,latencyMs:R().int().nonnegative().optional(),version:I().max(128).optional(),platform:I().max(64).optional(),hostname:I().max(255).optional(),homeDir:I().max(4096).optional(),lastError:I().max(1e3).optional(),projectCount:R().int().nonnegative(),createdAt:I(),updatedAt:I()}))}),V({connectionUrl:I().min(1).max(4096).optional(),origin:I().min(1).max(2048).optional(),token:I().min(1).max(2048).optional(),name:I().trim().min(1).max(120).optional()}).refine(e=>!!e.connectionUrl||!!e.origin&&!!e.token,`Provide either connectionUrl or both origin and token`),V({peerId:jd,name:I().trim().min(1).max(120).optional(),connectionUrl:I().min(1).max(4096).optional(),origin:I().min(1).max(2048).optional(),token:I().min(1).max(2048).optional(),enabled:z().optional()}),V({peerId:jd}),V({removed:z()}),V({peerId:jd.optional(),connectionUrl:I().min(1).max(4096).optional(),origin:I().min(1).max(2048).optional(),token:I().min(1).max(2048).optional()}).refine(e=>!!e.peerId||!!e.connectionUrl||!!e.origin&&!!e.token,`Provide peerId, connectionUrl, or both origin and token`),V({ok:z(),latencyMs:R().int().nonnegative().optional(),origin:I().max(2048).optional(),transportKind:Nd.optional(),encrypted:z().optional(),version:I().max(128).optional(),platform:I().max(64).optional(),hostname:I().max(255).optional(),homeDir:I().max(4096).optional(),projectCount:R().int().nonnegative().optional(),error:I().max(1e3).optional()});let Fd=V({id:I().min(1).max(1024),name:I().min(1).max(512),path:I().min(1).max(8192),threadIds:B(I().min(1).max(1024))}),Id=V({version:I().max(128),platform:I().max(64),hostname:I().max(255),homeDir:I().max(4096).optional(),epoch:I().min(1).max(256),projects:B(Fd)}),Ld=V({name:I().min(1).max(512),path:I().min(1).max(8192),kind:G(`directory`)});V({peerId:jd,path:I().min(1).max(8192).optional()}),V({path:I().min(1).max(8192),parentPath:I().min(1).max(8192).nullable(),homeDir:I().min(1).max(8192).optional(),entries:B(Ld)}),V({peerId:jd,parentPath:I().min(1).max(8192),name:I().min(1).max(255).refine(e=>e.trim().length>0,`Directory name cannot be blank`)}),V({path:I().min(1).max(8192),name:I().min(1).max(255)}),V({peerId:jd,path:I().min(1).max(8192),title:I().trim().min(1).max(255).optional()}),V({peerId:jd,workspaceId:I().min(1).max(1024),title:I().trim().min(1).max(255)}),V({peerId:jd,workspaceId:I().min(1).max(1024)}),V({workspaceId:I().min(1).max(1024).optional(),manifest:Id}),G(1);function Rd(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 zd(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 Bd=`@deepseek-ai/dsh-client-ui-chat/ThreadWatchNotice.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Bd)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Bd,e.textContent=`.XZWmHW_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}.XZWmHW_list{min-width:0;margin:0;padding:0;list-style:none}.XZWmHW_entry+.XZWmHW_entry{margin-top:10px}.XZWmHW_line{align-items:center;gap:8px;min-width:0;display:flex}.XZWmHW_line>svg,.XZWmHW_bell{flex-shrink:0}.XZWmHW_bell{color:var(--dsw-alias-label-tertiary);margin-top:3px}.XZWmHW_title{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-primary);overflow:hidden}.XZWmHW_outcome,.XZWmHW_open{white-space:nowrap;flex-shrink:0}.XZWmHW_outcome[data-outcome=completed]{color:var(--dsw-alias-state-success-primary)}.XZWmHW_outcome[data-outcome=failed]{color:var(--dsw-alias-state-error-primary)}.XZWmHW_open a{color:var(--dsw-alias-state-business-primary);text-decoration:none}.XZWmHW_open a:hover{text-decoration:underline}.XZWmHW_open a:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}.XZWmHW_note{color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;margin:4px 0 0 24px}@media (width<=480px){.XZWmHW_line{flex-wrap:wrap}.XZWmHW_title{flex:calc(100% - 52px)}.XZWmHW_outcome{margin-left:24px}}`,document.head.appendChild(e)}var Vd={bell:`XZWmHW_bell`,card:`XZWmHW_card`,entry:`XZWmHW_entry`,line:`XZWmHW_line`,list:`XZWmHW_list`,note:`XZWmHW_note`,open:`XZWmHW_open`,outcome:`XZWmHW_outcome`,title:`XZWmHW_title`};let Hd=()=>()=>{};function Ud({entry:e,links:t,t:n}){let r=`codex://threads/${e.threadId}`,i=()=>t?.describe?.(r)?.title,a=(0,d.useSyncExternalStore)(t?.resolve.subscribe??Hd,i,i),o=a!==void 0;return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Vd.entry,"data-thread-watch-entry":e.threadId,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Vd.line,children:[o?t?.describe?.(r)?.icon:/* @__PURE__ */ (0,f.jsx)(p.ReferenceIconRegular,{kind:`session`,size:14}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Vd.title,title:a??e.label,children:a??e.label}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Vd.outcome,"data-outcome":e.outcome,children:n(`message.watch.${e.outcome}`)}),o&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Vd.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:Vd.note,children:e.note})]})}function Wd({entries:e,links:t,t:n}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Vd.card,"data-thread-watch-notice":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.IconBellOutlineRegular,{className:Vd.bell}),/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Vd.list,children:e.map((e,r)=>/* @__PURE__ */ (0,f.jsx)(Ud,{entry:e,links:t,t:n},r))})]})}let Gd=`@deepseek-ai/dsh-client-ui-chat/MessageItem.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Gd)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Gd,e.textContent=`.EnoZlW_userRow{flex-direction:column;align-items:flex-end;gap:6px;display:flex}.EnoZlW_noticeRow{flex-direction:column;align-items:center;gap:6px;min-width:0;display:flex}.EnoZlW_noticeStack{min-width:0;max-width:100%}.EnoZlW_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}.EnoZlW_annotationRow{flex-wrap:wrap;justify-content:flex-end;gap:6px;display:flex}.EnoZlW_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] .EnoZlW_bubble{background:color-mix(in srgb, var(--dsw-specific-bubble) 84%, transparent);backdrop-filter:blur(12px)}@supports (-webkit-touch-callout:none){body[data-codexhost-wallpaper] .EnoZlW_userRow{transform:translateZ(0)}}.EnoZlW_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))}.EnoZlW_contextRow{padding:2px 0}.EnoZlW_compactionRow{--dsh-compaction-header-height:calc(24px + var(--dsh-content-font-delta,0px));padding:2px 0}.EnoZlW_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}.EnoZlW_compactionRow:has(.EnoZlW_compactionBody) .EnoZlW_compactionButton{z-index:7;background:var(--dsw-alias-bg-base);border-radius:0;position:sticky;top:0}body[data-codexhost-wallpaper] .EnoZlW_compactionRow:has(.EnoZlW_compactionBody) .EnoZlW_compactionButton{background:color-mix(in srgb, var(--dsw-alias-bg-base) 78%, transparent);backdrop-filter:blur(12px)}.EnoZlW_compactionBody :has(>[data-code-block-banner]){top:var(--dsh-compaction-header-height)}@media (hover:hover){.EnoZlW_compactionRow:has(.EnoZlW_compactionBody) .EnoZlW_compactionButton:hover{background:var(--dsw-alias-interactive-bg-hover-solid)}.EnoZlW_compactionButton:hover{color:var(--dsw-alias-label-secondary)}.EnoZlW_compactionButton:not(:disabled):hover{background:var(--dsw-alias-interactive-bg-hover)}}.EnoZlW_compactionButton:not(:disabled){cursor:pointer}.EnoZlW_compactionButton:not(:disabled):active{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover)}.EnoZlW_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}.EnoZlW_compactionLeading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}.EnoZlW_compactionContextIcon,.EnoZlW_compactionDisclosureIcon{grid-area:1/1;justify-content:center;align-items:center;display:inline-flex}.EnoZlW_compactionDisclosureIcon,.EnoZlW_compactionButton:not(:disabled):hover .EnoZlW_compactionContextIcon,.EnoZlW_compactionButton:not(:disabled):focus-visible .EnoZlW_compactionContextIcon{opacity:0}.EnoZlW_compactionButton:not(:disabled):hover .EnoZlW_compactionDisclosureIcon,.EnoZlW_compactionButton:not(:disabled):focus-visible .EnoZlW_compactionDisclosureIcon{opacity:1}.EnoZlW_compactionTitle{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:inherit;flex:none}.EnoZlW_compactionSep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.EnoZlW_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}.EnoZlW_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))}.EnoZlW_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))}.EnoZlW_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}.EnoZlW_retrySummary::-webkit-details-marker{display:none}.EnoZlW_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)}.EnoZlW_retrySummary:hover{color:var(--dsw-alias-label-secondary)}@media (prefers-reduced-motion:reduce){.EnoZlW_compactionButton{transition:none}}.EnoZlW_retrySummary:focus-visible{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}.EnoZlW_retryText{overflow-wrap:anywhere;min-width:0}.EnoZlW_retryRow[open] .EnoZlW_retrySummary:after{transform:rotate(45deg)}.EnoZlW_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}.EnoZlW_retryDetailLabel{color:var(--dsw-alias-label-secondary)}.EnoZlW_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}.EnoZlW_turnErrorDot{margin-top:5px}.EnoZlW_turnErrorCopy{overflow-wrap:anywhere;min-width:0}.EnoZlW_turnErrorTitle{color:var(--dsw-alias-state-error-primary);margin-right:6px;font-weight:600}.EnoZlW_turnErrorMessage{color:var(--dsw-alias-label-secondary)}.EnoZlW_turnErrorCode{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-markdown-code-block-small)}.EnoZlW_maxTokensTitle{color:var(--dsw-alias-state-warn-primary);margin-right:6px;font-weight:600}.EnoZlW_attachmentRow{flex-wrap:wrap;justify-content:flex-end;gap:8px;max-width:100%;display:flex}.EnoZlW_pendingAttachment{flex-direction:column;align-items:flex-end;gap:4px;min-width:0;display:flex}.EnoZlW_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}.EnoZlW_fileIcon{flex:none;width:28px;height:28px}.EnoZlW_fileContent{flex-direction:column;flex:1;min-width:0;display:flex}.EnoZlW_fileName{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px;overflow:hidden}.EnoZlW_fileMeta{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-tertiary,#00000073);font-size:12px;line-height:15px;overflow:hidden}.EnoZlW_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}.EnoZlW_editAction:hover{background:var(--dsw-alias-interactive-bg-hover)}.EnoZlW_editAction svg{width:15px;height:15px}.EnoZlW_userStack:has(.EnoZlW_sentEditor){width:100%}.EnoZlW_sentEditor{box-sizing:border-box;border:1px solid var(--dsw-alias-border-main);border-radius:12px;width:100%;min-width:0;padding:12px}.EnoZlW_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}.EnoZlW_sentEditor:focus-within{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}.EnoZlW_sentEditorActions{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}`,document.head.appendChild(e)}var J={annotationRow:`EnoZlW_annotationRow`,attachmentRow:`EnoZlW_attachmentRow`,bubble:`EnoZlW_bubble`,compactionBody:`EnoZlW_compactionBody`,compactionButton:`EnoZlW_compactionButton`,compactionContextIcon:`EnoZlW_compactionContextIcon`,compactionDisclosureIcon:`EnoZlW_compactionDisclosureIcon`,compactionLeading:`EnoZlW_compactionLeading`,compactionRow:`EnoZlW_compactionRow`,compactionSep:`EnoZlW_compactionSep`,compactionSummary:`EnoZlW_compactionSummary`,compactionTitle:`EnoZlW_compactionTitle`,contextRow:`EnoZlW_contextRow`,editAction:`EnoZlW_editAction`,fileCard:`EnoZlW_fileCard`,fileContent:`EnoZlW_fileContent`,fileIcon:`EnoZlW_fileIcon`,fileMeta:`EnoZlW_fileMeta`,fileName:`EnoZlW_fileName`,maxTokensTitle:`EnoZlW_maxTokensTitle`,noticeRow:`EnoZlW_noticeRow`,noticeStack:`EnoZlW_noticeStack`,pendingAttachment:`EnoZlW_pendingAttachment`,referenceSummary:`EnoZlW_referenceSummary`,retryDetailLabel:`EnoZlW_retryDetailLabel`,retryDetails:`EnoZlW_retryDetails`,retryRow:`EnoZlW_retryRow`,retrySummary:`EnoZlW_retrySummary`,retryText:`EnoZlW_retryText`,sentEditor:`EnoZlW_sentEditor`,sentEditorActions:`EnoZlW_sentEditorActions`,turnErrorCode:`EnoZlW_turnErrorCode`,turnErrorCopy:`EnoZlW_turnErrorCopy`,turnErrorDot:`EnoZlW_turnErrorDot`,turnErrorMessage:`EnoZlW_turnErrorMessage`,turnErrorRow:`EnoZlW_turnErrorRow`,turnErrorTitle:`EnoZlW_turnErrorTitle`,userRow:`EnoZlW_userRow`,userStack:`EnoZlW_userStack`};let Kd=(0,d.memo)(function({node:e,title:t,fallbackSummary:n,t:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useMemo)(()=>Rd(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})})]})}),qd=`@deepseek-ai/dsh-client-ui-chat/ContextBody.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(qd)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=qd,e.textContent=`._3_H96G_text{color:var(--dsw-alias-label-secondary);font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;margin:0}._3_H96G_fields{border-top:.5px solid var(--dsw-alias-border-l2);flex-direction:column;gap:2px;margin:8px 0 0;padding-top:8px;display:flex}._3_H96G_field{gap:8px;min-width:0;display:flex}._3_H96G_fieldKey{min-width:96px;color:var(--dsw-alias-label-caption);flex:none}._3_H96G_fieldValue{min-width:0;color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;flex:auto;margin:0}._3_H96G_files{flex-wrap:wrap;gap:4px 12px;margin:0 0 8px;padding:0;list-style:none;display:flex}._3_H96G_file{align-items:baseline;gap:6px;min-width:0;display:flex}._3_H96G_filePath{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}._3_H96G_fileAction{color:var(--dsw-alias-label-caption)}._3_H96G_catalogNotice{color:var(--dsw-alias-label-caption);margin:0 0 6px}._3_H96G_entries{flex-direction:column;gap:4px;margin:0;padding:0;list-style:none;display:flex}._3_H96G_entry{gap:8px;min-width:0;display:flex}._3_H96G_entryName{color:var(--dsw-alias-label-secondary);flex:none}._3_H96G_entryDescription{min-width:0;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}._3_H96G_sections{flex-direction:column;gap:8px;margin:0;display:flex}._3_H96G_section{flex-direction:column;gap:2px;min-width:0;display:flex}._3_H96G_sectionName{color:var(--dsw-alias-label-caption)}._3_H96G_sectionText{color:var(--dsw-alias-label-secondary);white-space:pre-wrap;overflow-wrap:anywhere;margin:0}._3_H96G_relaySender{color:var(--dsw-alias-label-caption);overflow-wrap:anywhere;margin:0 0 6px}._3_H96G_recalls{flex-direction:column;gap:2px;margin:0 0 8px;padding:0;list-style:none;display:flex}._3_H96G_recall{gap:8px;min-width:0;display:flex}._3_H96G_recallLabel{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}._3_H96G_recallCounts{color:var(--dsw-alias-label-caption);flex:none}`,document.head.appendChild(e)}var Y={catalogNotice:`_3_H96G_catalogNotice`,entries:`_3_H96G_entries`,entry:`_3_H96G_entry`,entryDescription:`_3_H96G_entryDescription`,entryName:`_3_H96G_entryName`,field:`_3_H96G_field`,fieldKey:`_3_H96G_fieldKey`,fieldValue:`_3_H96G_fieldValue`,fields:`_3_H96G_fields`,file:`_3_H96G_file`,fileAction:`_3_H96G_fileAction`,filePath:`_3_H96G_filePath`,files:`_3_H96G_files`,recall:`_3_H96G_recall`,recallCounts:`_3_H96G_recallCounts`,recallLabel:`_3_H96G_recallLabel`,recalls:`_3_H96G_recalls`,relaySender:`_3_H96G_relaySender`,section:`_3_H96G_section`,sectionName:`_3_H96G_sectionName`,sectionText:`_3_H96G_sectionText`,sections:`_3_H96G_sections`,text:`_3_H96G_text`};let Jd=2e4;function Yd(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Xd(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 Zd(e){return Xd(e).flatMap(e=>`block`in e?[e.block]:[])}function Qd(e,t){return e.length>Jd?`${e.slice(0,Jd)}\n${t(`json.truncated`,{total:e.length})}`:e}function $d(e,t){return Qd(typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e),t)}function ef({source:e,formRendered:t,t:n}){let r=Yd(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:$d(t,n)})]},e))})}function tf({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 nf({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(f.Fragment,{children:Xd(e).map((e,n)=>`text`in e?e.text!==``&&/* @__PURE__ */ (0,f.jsx)(`pre`,{className:Y.text,"data-context-text":!0,children:Qd(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 rf({content:e,source:t,t:n}){return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(nf,{content:e,t:n}),/* @__PURE__ */ (0,f.jsx)(ef,{source:t,formRendered:!1,t:n})]})}function af(e){let t=Yd(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=Yd(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 of(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 sf({content:e,source:t,t:n}){let r=af(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(rf,{content:e,source:t,t:n});let i=Yd(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(of(e.action,i))})]},e.path))}),/* @__PURE__ */ (0,f.jsx)(nf,{content:e,t:n})]})}function cf(e){let t=Yd(e),n=t===null?void 0:t.entries;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=Yd(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 lf({content:e,source:t,t:n}){let r=cf(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(rf,{content:e,source:t,t:n});let i=Yd(t)?.update===!0,a=r.slice(0,200),o=Zd(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)(tf,{blocks:o,t:n})]})}function uf(e){let t=Yd(e),n=t===null?void 0:t.sections;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=Yd(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 df({content:e,source:t,t:n}){let r=uf(t);return r===null?/* @__PURE__ */ (0,f.jsx)(rf,{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:Qd(e.text,n)})]},t))})]})}function ff({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(nf,{content:e,t})}function pf({content:e,source:t,t:n}){let r=mf(t);return r===null?/* @__PURE__ */ (0,f.jsx)(rf,{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)(nf,{content:e,t:n})]})}function mf(e){let t=Yd(e)?.senderSessionId;return typeof t==`string`&&t!==``?t:null}function hf(e){let t=Yd(e),n=t===null?void 0:t.references;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=Yd(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 gf({content:e,source:t,t:n}){let r=hf(t);return r===null?/* @__PURE__ */ (0,f.jsx)(rf,{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)(nf,{content:e,t:n})]})}function _f(e){let t=Yd(e)?.summary;return typeof t==`string`&&t!==``?t:null}function vf(e,t){let n={rendered:null,summary:null,body:/* @__PURE__ */ (0,f.jsx)(rf,{...t})};switch(e){case`instructions`:return af(t.source)===null?n:{rendered:`instructions`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(sf,{...t})};case`catalog`:return cf(t.source)===null?n:{rendered:`catalog`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(lf,{...t})};case`snapshot`:return uf(t.source)===null?n:{rendered:`snapshot`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(df,{...t})};case`notice`:{let e=_f(t.source);return e===null?n:{rendered:`notice`,summary:e,body:/* @__PURE__ */ (0,f.jsx)(ff,{...t})}}case`relay`:return mf(t.source)===null?n:{rendered:`relay`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(pf,{...t})};case`recall`:return hf(t.source)===null?n:{rendered:`recall`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(gf,{...t})};case null:return n;
123
123
  /* v8 ignore next 4 -- closed-union backstop; the compiler rejects a new
124
124
  KnownContextForm here rather than letting it degrade to opaque silently. */
125
- default:throw Error(`unreachable context form: ${String(e)}`)}}let ff=`@deepseek-ai/dsh-client-ui-chat/ContextInjectionRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ff)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=ff,e.textContent=`.lKMHaq_root{min-width:0}.lKMHaq_root[data-open]{padding-bottom:4px}.lKMHaq_chevron{color:var(--dsw-alias-label-secondary)}.lKMHaq_sep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.lKMHaq_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}.lKMHaq_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}.lKMHaq_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}.lKMHaq_toolChanges{white-space:nowrap}`,document.head.appendChild(e)}var pf={body:`lKMHaq_body`,chevron:`lKMHaq_chevron`,root:`lKMHaq_root`,sep:`lKMHaq_sep`,source:`lKMHaq_source`,summary:`lKMHaq_summary`,toolChanges:`lKMHaq_toolChanges`};function mf({content:e,source:t,producer:n,form:r,t:i}){let[a,o]=(0,d.useState)(!1),{rendered:s,summary:c,body:l}=df(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:pf.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:pf.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:pf.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:pf.source,"data-context-source":!0,children:n.label}),c!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:pf.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:pf.summary,"data-context-summary":!0,children:c})]})]}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:pf.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:pf.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:pf.body,"data-context-injection-body":!0,"data-context-form":s??void 0,children:u===void 0?l:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:pf.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 hf(e){return String(e).padStart(2,`0`)}function gf(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function _f(e){let t=new Date(e);return t.setHours(24,0,0,0),Math.max(t.getTime()-e,1)}function vf(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 yf(e,t,n=Date.now()){let r=new Date(e),i=new Date(n),a=`${hf(r.getHours())}:${hf(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 bf(){let[e,t]=(0,d.useState)(()=>gf(Date.now()));return(0,d.useEffect)(()=>{let e,n=()=>{let r=Date.now();t(gf(r)),e=setTimeout(n,_f(r))};return e=setTimeout(n,_f(Date.now())),()=>{clearTimeout(e)}},[]),e}let xf=`@deepseek-ai/dsh-client-ui-chat/MessageIconActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(xf)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=xf,e.textContent=`.AV_1gq_actions{height:calc(28px + var(--dsh-content-font-delta,0px));align-items:center;gap:8px;display:flex}.AV_1gq_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}.AV_1gq_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}.AV_1gq_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] .AV_1gq_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])) .AV_1gq_actions{opacity:0;transition:opacity 80ms}[data-actions-reveal=hover]:hover .AV_1gq_actions,[data-actions-reveal=hover]:focus-within .AV_1gq_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 .AV_1gq_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 .AV_1gq_actions{opacity:1}}.AV_1gq_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}.AV_1gq_action svg{width:calc(15px + var(--dsh-content-font-delta,0px));height:calc(15px + var(--dsh-content-font-delta,0px))}.AV_1gq_actions[data-clock=end] .AV_1gq_action svg{width:calc(17px + var(--dsh-content-font-delta,0px));height:calc(17px + var(--dsh-content-font-delta,0px))}.AV_1gq_action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.AV_1gq_action[data-unavailable]{cursor:default;opacity:.4}.AV_1gq_action[data-unavailable]:hover{color:var(--dsw-alias-label-tertiary);background:0 0}.AV_1gq_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var Sf={action:`AV_1gq_action`,actions:`AV_1gq_actions`,endInfo:`AV_1gq_endInfo`,timeEnd:`AV_1gq_timeEnd`,timeStart:`AV_1gq_timeStart`,visuallyHidden:`AV_1gq_visuallyHidden`};function Cf({text:e,time:t,clock:n,onBranch:r,branchUnavailable:i=!1,className:a,extraActions:o,t:s}){let c=bf(),l=(0,d.useId)(),[u,m]=(0,d.useState)(!1),h=(0,d.useRef)(!1),g=(0,d.useRef)(null),_=(0,d.useRef)(0);(0,d.useEffect)(()=>()=>{_.current+=1,h.current=!1,g.current!==null&&clearTimeout(g.current)},[]);let v=(0,d.useCallback)(()=>{if(u||h.current)return;let t=_.current;h.current=!0,(0,p.writeClipboard)(e).then(e=>{t===_.current&&(h.current=!1,e&&(m(!0),g.current=window.setTimeout(()=>{g.current=null,m(!1)},1e3)))})},[u,e]),y=t===void 0?null:/* @__PURE__ */ (0,f.jsx)(`span`,{className:n===`start`?Sf.timeStart:Sf.timeEnd,children:yf(t,s,c)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:a===void 0?Sf.actions:`${Sf.actions} ${a}`,"data-clock":n,children:[n===`start`?y:null,/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:s(u?`copied`:`copy`),side:`bottom`,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Sf.action,"aria-label":s(u?`copied`:`copy`),onClick:v,children:u?/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconCopyOutlineRegular,{})})}),o,r!==void 0&&/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:s(i?`message.branchUnavailable`:`message.branch`),side:`bottom`,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Sf.action,"aria-label":s(`message.branch`),"aria-disabled":i||void 0,"aria-describedby":i?l: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:l,className:Sf.visuallyHidden,children:s(`message.branchUnavailable`)}),n===`end`?/* @__PURE__ */ (0,f.jsx)(`span`,{className:Sf.endInfo,children:y}):null]})}function wf(e,t,n){return e(`codexhostTurnTimes`,e=>t===void 0?void 0:e?.[t]?.[n]??void 0)}function Tf(e,t,n){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(!1);return{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,ud(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}))}}}function Ef({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 Df(e){return`nativePath`in e&&typeof e.nativePath==`string`?e.nativePath:void 0}function Of({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 kf(e){let t=[],n=[],r=[];for(let i of e){let e=i;e.type===`text`&&typeof e.text==`string`?t.push(fd(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 Af(e){return Math.max(1,Math.ceil(e/1e3))}function jf(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 Mf({node:e,active:t,t:n}){let r=(0,d.useMemo)(()=>Date.now()+e.delayMs,[e.delayMs,e.seq]),i=Af(e.delayMs),a=e.mode===`normal`?e.maxRetries:`∞`,[o,s]=(0,d.useState)(()=>({deadline:r,seconds:Af(r-Date.now())})),c=o.deadline===r?o.seconds:Af(r-Date.now());(0,d.useEffect)(()=>{if(!t)return;let e=()=>{let e=Af(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`)}),jf(e.failure.message,e.failure.code,n)]})]})]})}function Nf({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:jf(e.message,e.code,t)})]}),e.code!==void 0&&/* @__PURE__ */ (0,f.jsx)(`code`,{className:J.turnErrorCode,children:e.code})]})}function Pf({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 Ff({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:_}=kf(e),v=c??g,y=v.length>1,b=e=>m(`json.truncated`,{total:e}),x=h!==``||_.length>0,ee=ad(h);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:ee?J.noticeRow:J.userRow,"data-pending-steering":r||void 0,"data-submission-echo":i||void 0,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:ee?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:Md(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:Df(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),Df(e.file)===void 0?(0,p.fileSizeText)(e.file.bytes):void 0].filter(Boolean).join(` `)})]})]}),e.upload&&/* @__PURE__ */ (0,f.jsx)(Of,{upload:e.upload,t:m})]},n))}),d??(x&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:ee?void 0:J.bubble,children:[ee?/* @__PURE__ */ (0,f.jsx)(Ld,{entries:ee,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`))})})]}),!ee&&n?.(h)]})}function If({content:e,renderMessageImages:t,t:n}){return/* @__PURE__ */ (0,f.jsx)(Ff,{content:e,renderMessageImages:t,pending:!0,t:n,actions:e=>/* @__PURE__ */ (0,f.jsx)(Cf,{text:e,clock:`start`,className:J.actions,t:n})})}function Lf({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)(Ff,{content:r,previewAttachments:i,renderMessageImages:t,pending:e.placement===`steering`,echo:!0,t:n,actions:t=>/* @__PURE__ */ (0,f.jsx)(Cf,{text:t,time:e.time,clock:`start`,className:J.actions,t:n})})}let Rf=(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=wf(a,e.location.kind===`turn`||e.location.kind===`step`?e.location.turn.turn:void 0,`start`);return/* @__PURE__ */ (0,f.jsx)(Ff,{content:c.content,editor:i?.draft?.seq===c.seq?/* @__PURE__ */ (0,f.jsx)(Ef,{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)(Cf,{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 zf({editing:e,renderMessageImages:t,t:n}){return/* @__PURE__ */ (0,f.jsx)(Ff,{content:e.draft?.content??[],responseAnnotations:e.draft?.responseAnnotations,renderMessageImages:t,editor:/* @__PURE__ */ (0,f.jsx)(Ef,{editing:e,t:n}),t:n})}let Bf=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(mf,{content:n.content,source:n.source,producer:n.producer,form:n.form,t})}),Vf=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(zd,{node:e.data,t})}),Hf=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(Mf,{node:n.current,active:n.current.retryState===`scheduled`,t})}),Uf=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(Nf,{node:e.data,t})}),Wf=(0,d.memo)(function({t:e}){return/* @__PURE__ */ (0,f.jsx)(Pf,{t:e})}),Gf=(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})})})}),Kf=/* @__PURE__ */ new Set([`system-prompt`,`user`,`steering`,`turn-trigger`,`turn-process`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function qf(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 Jf(e){return e===`subagent`||e.startsWith(`subagent_`)}function Yf(e){return e===`compact_context`}function Xf(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 Zf(e,t){return e.turnProcesses.find(e=>e.turn===t)}function Qf(){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}}})}function $f(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 ep=[],tp={getSnapshot:()=>ep,subscribe:()=>()=>{}};function np(e){let t=ep;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?ep:n),t},subscribe:e.subscribe}}function rp(e,t){let n=(0,d.useMemo)(()=>t===void 0?tp:np(e.turnDataSource(t,`user`)),[e,t]);return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let ip=`@deepseek-ai/dsh-client-ui-chat/ChatView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ip)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=ip,e.textContent=`.jjlK2a_frame{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative;container-type:inline-size}.jjlK2a_root{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative;overflow:visible clip}.jjlK2a_scroll{min-height:0;padding:16px calc(var(--dsh-composer-side-clearance) + 16px);flex:auto;overflow-y:auto;container-type:inline-size}.jjlK2a_root[data-chat-following-tail] .jjlK2a_scroll,[data-conversation-scroll]:has(.jjlK2a_root[data-chat-following-tail]){overflow-anchor:none}[data-conversation-scroll] .jjlK2a_frame,[data-conversation-scroll] .jjlK2a_root{flex:none;height:auto;min-height:auto}[data-conversation-scroll] .jjlK2a_scroll{flex:none;min-height:auto;overflow:visible}.jjlK2a_column{max-width:var(--dsh-chat-content-width);flex-direction:column;width:100%;margin:0 auto;display:flex}.jjlK2a_column>:not([hidden]):not(.jjlK2a_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)))~:not([hidden]):not(.jjlK2a_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))){margin-top:var(--dsh-chat-flow-gap,6px)}.jjlK2a_flowItem[data-chat-group-part=response],.jjlK2a_column>[data-chat-group-part=response]:not([hidden]):not(:empty)+:not([hidden]):not(.jjlK2a_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))):not(.jjlK2a_running){--dsh-chat-flow-gap:12px}.jjlK2a_flowItem{min-width:0}.jjlK2a_flowItem[data-chat-flow-kind=turn-process],.jjlK2a_flowItem[data-turn-process-answer],.jjlK2a_column>[data-chat-flow-kind=turn-process]+:not([hidden]):not(.jjlK2a_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))):not(.jjlK2a_running){--dsh-chat-flow-gap:16px}.jjlK2a_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)){height:0}.jjlK2a_callRow{border-radius:var(--dsw-radius-sm)}.jjlK2a_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){.jjlK2a_syncingIcon{display:none}}.jjlK2a_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))}.jjlK2a_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}.jjlK2a_column>:nth-last-child(2 of :not([hidden]):not(.jjlK2a_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)))):is(.jjlK2a_flowItem:not([data-chat-flow-kind=user]):not([data-chat-flow-kind=steering]):not([data-chat-flow-kind=turn-trigger]),[data-chat-group-key])~.jjlK2a_running>.jjlK2a_runningDivider{display:block}.jjlK2a_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}.jjlK2a_runningContent{align-items:center;gap:6px;min-width:0;display:inline-flex}.jjlK2a_runningText{font-variant-numeric:tabular-nums;min-width:0}.jjlK2a_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}.jjlK2a_runningIconMotion{transform-origin:50% 60%;width:100%;height:100%;display:inline-flex}@keyframes jjlK2a_runningIconSway{0%,to{transform:translateY(.5px)rotate(-20deg)}50%{transform:translateY(-.6px)rotate(20deg)}}@media (prefers-reduced-motion:no-preference) and (forced-colors:none){.jjlK2a_runningIconMotion{animation:1.6s ease-in-out infinite jjlK2a_runningIconSway}}.jjlK2a_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))}.jjlK2a_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}.jjlK2a_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}.jjlK2a_older button:disabled{cursor:default;opacity:.6}.jjlK2a_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] .jjlK2a_toBottomSlot{bottom:calc(var(--dsh-composer-height,152px) + 16px);position:sticky}.jjlK2a_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}.jjlK2a_toBottom:hover{background:var(--dsw-alias-button-floating-hover)}.jjlK2a_modalAction{min-width:72px}`,document.head.appendChild(e)}var X={callRow:`jjlK2a_callRow`,column:`jjlK2a_column`,flowItem:`jjlK2a_flowItem`,frame:`jjlK2a_frame`,hint:`jjlK2a_hint`,modalAction:`jjlK2a_modalAction`,older:`jjlK2a_older`,openError:`jjlK2a_openError`,root:`jjlK2a_root`,running:`jjlK2a_running`,runningContent:`jjlK2a_runningContent`,runningDivider:`jjlK2a_runningDivider`,runningIcon:`jjlK2a_runningIcon`,runningIconMotion:`jjlK2a_runningIconMotion`,runningIconSway:`jjlK2a_runningIconSway`,runningText:`jjlK2a_runningText`,scroll:`jjlK2a_scroll`,syncing:`jjlK2a_syncing`,syncingIcon:`jjlK2a_syncingIcon`,toBottom:`jjlK2a_toBottom`,toBottomSlot:`jjlK2a_toBottomSlot`};function ap(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.data:void 0}function op(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function sp(e){return e?.kind===`tool-call`&&Yf(e.data.root.name)}let cp=(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,loadTurnDiffs:h,messageEditing:g,loadImage:_,renderMessageImages:v,fileMentions:y,useStore:b,actions:x,renderSlot:ee,t:S}){let C=r(e),w=C,T=op(w),E=i(e),D=E?.spec,te=b(e=>D===void 0?void 0:Zf(e,D.turn)),ne=D!==void 0&&te?.answerStep===(D.answerStep??0)?te:void 0,re=E!==void 0&&!E.turnClosed,ie=E?.hasInterleavedInput===!0,ae=re||ie||Xf(w),oe=ae||ne!==void 0,se=(0,d.useCallback)(e=>{D!==void 0&&!ae&&x.setTurnProcessOpen(D.turn,D.answerStep??0,e)},[x,D,ae]),ce=a(e=>e.foldCompletedTurns),le=D!==void 0&&E!==void 0&&ce&&E.turn===D.turn&&(E.turnStarted||E.turnClosed),O=w!==void 0&&le&&!re&&t!==`reasoning`&&w.kind===`assistant-step`&&w.data.step===D.answerStep,ue=w!==void 0&&le&&!O&&!Kf.has(w.kind)&&!sp(w)&&w.anchorSeq>=D.processStartSeq,de=w?.kind===`turn-process`||O,fe=le&&(re||ue||de),pe=(0,d.useMemo)(()=>D===void 0?void 0:{spec:D,foldable:fe,hasContent:!ie&&(E?.hasExternalProcess===!0||D.inlineReasoning),open:oe,setOpen:se},[fe,ie,oe,D,E?.hasExternalProcess,se]),me=w?.kind===`turn-process`&&ce&&!fe,he=O&&fe&&E.compactAnswer&&!oe,ge=me||fe&&ue&&!oe,k=$f(ge,(0,d.useCallback)(()=>{ue&&se(!0)},[ue,se])),[_e]=(0,d.useState)(()=>(0,m.createSnapshotStore)(0)),ve=rp(n,T),ye=ap(w),be=(0,d.useMemo)(()=>({turnData:ye,disclosureReset:_e}),[ye,_e]);(0,d.useEffect)(()=>{ue&&ge&&k.current?.hasAttribute(`hidden`)&&_e.set(_e.getSnapshot()+1)},[ue,ge,k,_e]);let xe=(0,d.useMemo)(()=>C===void 0?null:{...t===void 0?{}:{groupPart:t},cwd:o,openFile:s,openSkill:c,inspectCall:l,forkAt:u,loadTurnDiffs:h,messageEditing:g,loadImage:_,renderMessageImages:v,fileMentions:y,turnProcess:pe,responseAnnotations:ve},[C,t,o,s,c,l,u,h,g,_,v,y,pe,ve]);if(w===void 0||xe===null)return null;let Se={...xe,node:w},Ce=t===void 0||t===`response`?w.key:JSON.stringify([w.key,t]);return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:k,className:X.flowItem,"data-chat-anchor-key":Ce,"data-chat-flow-key":Ce,"data-chat-paging-anchor":w.kind!==`turn-process`||void 0,"data-chat-node-key":w.key,"data-chat-group-part":t,"data-chat-flow-kind":w.kind,"data-chat-turn":T,"data-turn-process-member":ue||void 0,"data-turn-process-hidden":ge||void 0,"data-turn-process-answer":he||void 0,children:ee(`conversation.chat.node`,Se,{entryKey:w.kind,hookContext:be,fallback:/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:S(`message.unknownSurface`,{type:w.kind}),payload:w.data,truncatedLabel:e=>S(`json.truncated`,{total:e})})})})}),lp={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
126
- `,r:`\r`,t:` `},up=/[\\\u0000-\u001f]/u;function dp(e){return e===` `||e===`
127
- `||e===`\r`||e===` `}function fp(e){return e>=`0`&&e<=`9`||e>=`a`&&e<=`f`||e>=`A`&&e<=`F`}var pp=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(up),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++)fp(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=lp[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&&up.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(dp(e))return;if(e===`{`){this.#r=`key-or-end`;return}this.fail();return;case`key-or-end`:if(dp(e))return;if(e===`}`){this.#r=`closed`;return}if(e===`"`){this.beginKey(t);return}this.fail();return;case`key-only`:if(dp(e))return;if(e===`"`){this.beginKey(t);return}this.fail();return;case`key`:this.stepKey(e,t);return;case`colon`:if(dp(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(dp(e))return;if(e===`,`){this.#r=`key-only`;return}if(e===`}`){this.#r=`closed`;return}this.fail();return;case`closed`:if(dp(e))return;this.fail();return;
125
+ default:throw Error(`unreachable context form: ${String(e)}`)}}let yf=`@deepseek-ai/dsh-client-ui-chat/ContextInjectionRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(yf)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=yf,e.textContent=`.lKMHaq_root{min-width:0}.lKMHaq_root[data-open]{padding-bottom:4px}.lKMHaq_chevron{color:var(--dsw-alias-label-secondary)}.lKMHaq_sep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.lKMHaq_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}.lKMHaq_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}.lKMHaq_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}.lKMHaq_toolChanges{white-space:nowrap}`,document.head.appendChild(e)}var bf={body:`lKMHaq_body`,chevron:`lKMHaq_chevron`,root:`lKMHaq_root`,sep:`lKMHaq_sep`,source:`lKMHaq_source`,summary:`lKMHaq_summary`,toolChanges:`lKMHaq_toolChanges`};function xf({content:e,source:t,producer:n,form:r,t:i}){let[a,o]=(0,d.useState)(!1),{rendered:s,summary:c,body:l}=vf(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:bf.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:bf.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:bf.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:bf.source,"data-context-source":!0,children:n.label}),c!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:bf.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:bf.summary,"data-context-summary":!0,children:c})]})]}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:bf.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:bf.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:bf.body,"data-context-injection-body":!0,"data-context-form":s??void 0,children:u===void 0?l:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:bf.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 Sf(e){return String(e).padStart(2,`0`)}function Cf(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function wf(e){let t=new Date(e);return t.setHours(24,0,0,0),Math.max(t.getTime()-e,1)}function Tf(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 Ef(e,t,n=Date.now()){let r=new Date(e),i=new Date(n),a=`${Sf(r.getHours())}:${Sf(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 Df(){let[e,t]=(0,d.useState)(()=>Cf(Date.now()));return(0,d.useEffect)(()=>{let e,n=()=>{let r=Date.now();t(Cf(r)),e=setTimeout(n,wf(r))};return e=setTimeout(n,wf(Date.now())),()=>{clearTimeout(e)}},[]),e}let Of=`@deepseek-ai/dsh-client-ui-chat/MessageIconActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Of)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Of,e.textContent=`.AV_1gq_actions{height:calc(28px + var(--dsh-content-font-delta,0px));-webkit-user-select:none;user-select:none;align-items:center;gap:8px;display:flex}.AV_1gq_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}.AV_1gq_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}.AV_1gq_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] .AV_1gq_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])) .AV_1gq_actions{opacity:0;transition:opacity 80ms}[data-actions-reveal=hover]:hover .AV_1gq_actions,[data-actions-reveal=hover]:focus-within .AV_1gq_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 .AV_1gq_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 .AV_1gq_actions{opacity:1}}.AV_1gq_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}.AV_1gq_action svg{width:calc(15px + var(--dsh-content-font-delta,0px));height:calc(15px + var(--dsh-content-font-delta,0px))}.AV_1gq_actions[data-clock=end] .AV_1gq_action svg{width:calc(17px + var(--dsh-content-font-delta,0px));height:calc(17px + var(--dsh-content-font-delta,0px))}.AV_1gq_action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.AV_1gq_action[data-unavailable]{cursor:default;opacity:.4}.AV_1gq_action[data-unavailable]:hover{color:var(--dsw-alias-label-tertiary);background:0 0}.AV_1gq_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var kf={action:`AV_1gq_action`,actions:`AV_1gq_actions`,endInfo:`AV_1gq_endInfo`,timeEnd:`AV_1gq_timeEnd`,timeStart:`AV_1gq_timeStart`,visuallyHidden:`AV_1gq_visuallyHidden`};function Af({text:e,time:t,clock:n,onBranch:r,branchUnavailable:i=!1,className:a,extraActions:o,t:s}){let c=Df(),l=(0,d.useId)(),[u,m]=(0,d.useState)(!1),h=(0,d.useRef)(!1),g=(0,d.useRef)(null),_=(0,d.useRef)(0);(0,d.useEffect)(()=>()=>{_.current+=1,h.current=!1,g.current!==null&&clearTimeout(g.current)},[]);let v=(0,d.useCallback)(()=>{if(u||h.current)return;let t=_.current;h.current=!0,(0,p.writeClipboard)(e).then(e=>{t===_.current&&(h.current=!1,e&&(m(!0),g.current=window.setTimeout(()=>{g.current=null,m(!1)},1e3)))})},[u,e]),y=t===void 0?null:/* @__PURE__ */ (0,f.jsx)(`span`,{className:n===`start`?kf.timeStart:kf.timeEnd,children:Ef(t,s,c)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:a===void 0?kf.actions:`${kf.actions} ${a}`,"data-clock":n,children:[n===`start`?y:null,/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:s(u?`copied`:`copy`),side:`bottom`,portal:!0,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:kf.action,"aria-label":s(u?`copied`:`copy`),onClick:v,children:u?/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconCopyOutlineRegular,{})})}),o,r!==void 0&&/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:s(i?`message.branchUnavailable`:`message.branch`),side:`bottom`,portal:!0,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:kf.action,"aria-label":s(`message.branch`),"aria-disabled":i||void 0,"aria-describedby":i?l: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:l,className:kf.visuallyHidden,children:s(`message.branchUnavailable`)}),n===`end`?/* @__PURE__ */ (0,f.jsx)(`span`,{className:kf.endInfo,children:y}):null]})}function jf(e,t,n){return e(`codexhostTurnTimes`,e=>t===void 0?void 0:e?.[t]?.[n]??void 0)}function Mf(e,t,n){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(!1);return{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,ud(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}))}}}function Nf({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 Pf(e){return`nativePath`in e&&typeof e.nativePath==`string`?e.nativePath:void 0}function Ff({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 If(e){let t=[],n=[],r=[];for(let i of e){let e=i;e.type===`text`&&typeof e.text==`string`?t.push(fd(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 Lf(e){return Math.max(1,Math.ceil(e/1e3))}function Rf(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 zf({node:e,active:t,t:n}){let r=(0,d.useMemo)(()=>Date.now()+e.delayMs,[e.delayMs,e.seq]),i=Lf(e.delayMs),a=e.mode===`normal`?e.maxRetries:`∞`,[o,s]=(0,d.useState)(()=>({deadline:r,seconds:Lf(r-Date.now())})),c=o.deadline===r?o.seconds:Lf(r-Date.now());(0,d.useEffect)(()=>{if(!t)return;let e=()=>{let e=Lf(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`)}),Rf(e.failure.message,e.failure.code,n)]})]})]})}function Bf({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:Rf(e.message,e.code,t)})]}),e.code!==void 0&&/* @__PURE__ */ (0,f.jsx)(`code`,{className:J.turnErrorCode,children:e.code})]})}function Vf({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 Hf({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:_}=If(e),v=c??g,y=v.length>1,b=e=>m(`json.truncated`,{total:e}),x=h!==``||_.length>0,ee=ad(h);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:ee?J.noticeRow:J.userRow,"data-pending-steering":r||void 0,"data-submission-echo":i||void 0,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:ee?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:zd(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:Pf(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),Pf(e.file)===void 0?(0,p.fileSizeText)(e.file.bytes):void 0].filter(Boolean).join(` `)})]})]}),e.upload&&/* @__PURE__ */ (0,f.jsx)(Ff,{upload:e.upload,t:m})]},n))}),d??(x&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:ee?void 0:J.bubble,children:[ee?/* @__PURE__ */ (0,f.jsx)(Wd,{entries:ee,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`))})})]}),!ee&&n?.(h)]})}function Uf({content:e,renderMessageImages:t,t:n}){return/* @__PURE__ */ (0,f.jsx)(Hf,{content:e,renderMessageImages:t,pending:!0,t:n,actions:e=>/* @__PURE__ */ (0,f.jsx)(Af,{text:e,clock:`start`,className:J.actions,t:n})})}function Wf({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)(Hf,{content:r,previewAttachments:i,renderMessageImages:t,pending:e.placement===`steering`,echo:!0,t:n,actions:t=>/* @__PURE__ */ (0,f.jsx)(Af,{text:t,time:e.time,clock:`start`,className:J.actions,t:n})})}let Gf=(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=jf(a,e.location.kind===`turn`||e.location.kind===`step`?e.location.turn.turn:void 0,`start`);return/* @__PURE__ */ (0,f.jsx)(Hf,{content:c.content,editor:i?.draft?.seq===c.seq?/* @__PURE__ */ (0,f.jsx)(Nf,{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)(Af,{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 Kf({editing:e,renderMessageImages:t,t:n}){return/* @__PURE__ */ (0,f.jsx)(Hf,{content:e.draft?.content??[],responseAnnotations:e.draft?.responseAnnotations,renderMessageImages:t,editor:/* @__PURE__ */ (0,f.jsx)(Nf,{editing:e,t:n}),t:n})}let qf=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(xf,{content:n.content,source:n.source,producer:n.producer,form:n.form,t})}),Jf=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(Kd,{node:e.data,t})}),Yf=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(zf,{node:n.current,active:n.current.retryState===`scheduled`,t})}),Xf=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(Bf,{node:e.data,t})}),Zf=(0,d.memo)(function({t:e}){return/* @__PURE__ */ (0,f.jsx)(Vf,{t:e})}),Qf=(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})})})}),$f=/* @__PURE__ */ new Set([`system-prompt`,`user`,`steering`,`turn-trigger`,`turn-process`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function ep(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 tp(e){return e===`subagent`||e.startsWith(`subagent_`)}function np(e){return e===`compact_context`}function rp(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 ip(e,t){return e.turnProcesses.find(e=>e.turn===t)}function ap(){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}}})}function op(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 sp=[],cp={getSnapshot:()=>sp,subscribe:()=>()=>{}};function lp(e){let t=sp;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?sp:n),t},subscribe:e.subscribe}}function up(e,t){let n=(0,d.useMemo)(()=>t===void 0?cp:lp(e.turnDataSource(t,`user`)),[e,t]);return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let dp=`@deepseek-ai/dsh-client-ui-chat/ChatView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(dp)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=dp,e.textContent=`.jjlK2a_frame{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative;container-type:inline-size}.jjlK2a_root{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative;overflow:visible clip}.jjlK2a_scroll{min-height:0;padding:16px calc(var(--dsh-composer-side-clearance) + 16px);flex:auto;overflow-y:auto;container-type:inline-size}.jjlK2a_root[data-chat-following-tail] .jjlK2a_scroll,[data-conversation-scroll]:has(.jjlK2a_root[data-chat-following-tail]){overflow-anchor:none}[data-conversation-scroll] .jjlK2a_frame,[data-conversation-scroll] .jjlK2a_root{flex:none;height:auto;min-height:auto}[data-conversation-scroll] .jjlK2a_scroll{flex:none;min-height:auto;overflow:visible}.jjlK2a_column{max-width:var(--dsh-chat-content-width);flex-direction:column;width:100%;margin:0 auto;display:flex}.jjlK2a_column>:not([hidden]):not(.jjlK2a_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)))~:not([hidden]):not(.jjlK2a_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))){margin-top:var(--dsh-chat-flow-gap,6px)}.jjlK2a_flowItem[data-chat-group-part=response],.jjlK2a_column>[data-chat-group-part=response]:not([hidden]):not(:empty)+:not([hidden]):not(.jjlK2a_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))):not(.jjlK2a_running){--dsh-chat-flow-gap:12px}.jjlK2a_flowItem{min-width:0}.jjlK2a_flowItem[data-chat-flow-kind=turn-process],.jjlK2a_flowItem[data-turn-process-answer],.jjlK2a_column>[data-chat-flow-kind=turn-process]+:not([hidden]):not(.jjlK2a_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))):not(.jjlK2a_running){--dsh-chat-flow-gap:16px}.jjlK2a_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)){height:0}.jjlK2a_callRow{border-radius:var(--dsw-radius-sm)}.jjlK2a_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){.jjlK2a_syncingIcon{display:none}}.jjlK2a_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))}.jjlK2a_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}.jjlK2a_column>:nth-last-child(2 of :not([hidden]):not(.jjlK2a_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)))):is(.jjlK2a_flowItem:not([data-chat-flow-kind=user]):not([data-chat-flow-kind=steering]):not([data-chat-flow-kind=turn-trigger]),[data-chat-group-key])~.jjlK2a_running>.jjlK2a_runningDivider{display:block}.jjlK2a_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}.jjlK2a_runningContent{align-items:center;gap:6px;min-width:0;display:inline-flex}.jjlK2a_runningText{font-variant-numeric:tabular-nums;min-width:0}.jjlK2a_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}.jjlK2a_runningIconMotion{transform-origin:50% 60%;width:100%;height:100%;display:inline-flex}@keyframes jjlK2a_runningIconSway{0%,to{transform:translateY(.5px)rotate(-20deg)}50%{transform:translateY(-.6px)rotate(20deg)}}@media (prefers-reduced-motion:no-preference) and (forced-colors:none){.jjlK2a_runningIconMotion{animation:1.6s ease-in-out infinite jjlK2a_runningIconSway}}.jjlK2a_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))}.jjlK2a_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}.jjlK2a_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}.jjlK2a_older button:disabled{cursor:default;opacity:.6}.jjlK2a_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] .jjlK2a_toBottomSlot{bottom:calc(var(--dsh-composer-height,152px) + 16px);position:sticky}.jjlK2a_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}.jjlK2a_toBottom:hover{background:var(--dsw-alias-button-floating-hover)}.jjlK2a_modalAction{min-width:72px}`,document.head.appendChild(e)}var X={callRow:`jjlK2a_callRow`,column:`jjlK2a_column`,flowItem:`jjlK2a_flowItem`,frame:`jjlK2a_frame`,hint:`jjlK2a_hint`,modalAction:`jjlK2a_modalAction`,older:`jjlK2a_older`,openError:`jjlK2a_openError`,root:`jjlK2a_root`,running:`jjlK2a_running`,runningContent:`jjlK2a_runningContent`,runningDivider:`jjlK2a_runningDivider`,runningIcon:`jjlK2a_runningIcon`,runningIconMotion:`jjlK2a_runningIconMotion`,runningIconSway:`jjlK2a_runningIconSway`,runningText:`jjlK2a_runningText`,scroll:`jjlK2a_scroll`,syncing:`jjlK2a_syncing`,syncingIcon:`jjlK2a_syncingIcon`,toBottom:`jjlK2a_toBottom`,toBottomSlot:`jjlK2a_toBottomSlot`};function fp(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.data:void 0}function pp(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function mp(e){return e?.kind===`tool-call`&&np(e.data.root.name)}let hp=(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,loadTurnDiffs:h,messageEditing:g,loadImage:_,renderMessageImages:v,fileMentions:y,useStore:b,actions:x,renderSlot:ee,t:S}){let C=r(e),w=C,T=pp(w),E=i(e),D=E?.spec,te=b(e=>D===void 0?void 0:ip(e,D.turn)),ne=D!==void 0&&te?.answerStep===(D.answerStep??0)?te:void 0,re=E!==void 0&&!E.turnClosed,ie=E?.hasInterleavedInput===!0,ae=re||ie||rp(w),oe=ae||ne!==void 0,se=(0,d.useCallback)(e=>{D!==void 0&&!ae&&x.setTurnProcessOpen(D.turn,D.answerStep??0,e)},[x,D,ae]),ce=a(e=>e.foldCompletedTurns),le=D!==void 0&&E!==void 0&&ce&&E.turn===D.turn&&(E.turnStarted||E.turnClosed),O=w!==void 0&&le&&!re&&t!==`reasoning`&&w.kind===`assistant-step`&&w.data.step===D.answerStep,ue=w!==void 0&&le&&!O&&!$f.has(w.kind)&&!mp(w)&&w.anchorSeq>=D.processStartSeq,de=w?.kind===`turn-process`||O,fe=le&&(re||ue||de),pe=(0,d.useMemo)(()=>D===void 0?void 0:{spec:D,foldable:fe,hasContent:!ie&&(E?.hasExternalProcess===!0||D.inlineReasoning),open:oe,setOpen:se},[fe,ie,oe,D,E?.hasExternalProcess,se]),me=w?.kind===`turn-process`&&ce&&!fe,he=O&&fe&&E.compactAnswer&&!oe,ge=me||fe&&ue&&!oe,k=op(ge,(0,d.useCallback)(()=>{ue&&se(!0)},[ue,se])),[_e]=(0,d.useState)(()=>(0,m.createSnapshotStore)(0)),ve=up(n,T),ye=fp(w),be=(0,d.useMemo)(()=>({turnData:ye,disclosureReset:_e}),[ye,_e]);(0,d.useEffect)(()=>{ue&&ge&&k.current?.hasAttribute(`hidden`)&&_e.set(_e.getSnapshot()+1)},[ue,ge,k,_e]);let xe=(0,d.useMemo)(()=>C===void 0?null:{...t===void 0?{}:{groupPart:t},cwd:o,openFile:s,openSkill:c,inspectCall:l,forkAt:u,loadTurnDiffs:h,messageEditing:g,loadImage:_,renderMessageImages:v,fileMentions:y,turnProcess:pe,responseAnnotations:ve},[C,t,o,s,c,l,u,h,g,_,v,y,pe,ve]);if(w===void 0||xe===null)return null;let Se={...xe,node:w},Ce=t===void 0||t===`response`?w.key:JSON.stringify([w.key,t]);return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:k,className:X.flowItem,"data-chat-anchor-key":Ce,"data-chat-flow-key":Ce,"data-chat-paging-anchor":w.kind!==`turn-process`||void 0,"data-chat-node-key":w.key,"data-chat-group-part":t,"data-chat-flow-kind":w.kind,"data-chat-turn":T,"data-turn-process-member":ue||void 0,"data-turn-process-hidden":ge||void 0,"data-turn-process-answer":he||void 0,children:ee(`conversation.chat.node`,Se,{entryKey:w.kind,hookContext:be,fallback:/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:S(`message.unknownSurface`,{type:w.kind}),payload:w.data,truncatedLabel:e=>S(`json.truncated`,{total:e})})})})}),gp={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
126
+ `,r:`\r`,t:` `},_p=/[\\\u0000-\u001f]/u;function vp(e){return e===` `||e===`
127
+ `||e===`\r`||e===` `}function yp(e){return e>=`0`&&e<=`9`||e>=`a`&&e<=`f`||e>=`A`&&e<=`F`}var bp=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(_p),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++)yp(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=gp[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&&_p.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(vp(e))return;if(e===`{`){this.#r=`key-or-end`;return}this.fail();return;case`key-or-end`:if(vp(e))return;if(e===`}`){this.#r=`closed`;return}if(e===`"`){this.beginKey(t);return}this.fail();return;case`key-only`:if(vp(e))return;if(e===`"`){this.beginKey(t);return}this.fail();return;case`key`:this.stepKey(e,t);return;case`colon`:if(vp(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(vp(e))return;if(e===`,`){this.#r=`key-only`;return}if(e===`}`){this.#r=`closed`;return}this.fail();return;case`closed`:if(vp(e))return;this.fail();return;
128
128
  /* v8 ignore next 2 -- scan() stops stepping once the view is invalid. */
129
129
  case`invalid`:return;
130
130
  /* v8 ignore next 2 -- Every scanner mode has a handler above. */
131
- default:mp(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){dp(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===`}`||dp(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 mp(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}function hp(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 mp(e)}}function gp(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 _p(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 vp(e){let t=t=>e.subscribe(t),n=()=>e.getSnapshot();return function(){return _p((0,d.useSyncExternalStore)(t,n))}}function yp(e){let t=e.clientHeight;return{top:e.scrollTop,height:t,floor:Math.max(0,e.scrollHeight-t)}}var bp=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 xp(e,t){let[n]=(0,d.useState)(()=>new bp(e,t));return n}let Sp={canScrollUp:!1,canScrollDown:!1},Cp=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);function wp(e,t,n,r){let i=xp(!1,1),a=(0,d.useRef)(null),[o,s]=(0,d.useState)(Sp),c=(0,d.useCallback)(e=>{a.current=e},[]),l=(0,d.useCallback)(t=>{let n=e.current,r=Sp;if(n!==null&&n.closest(`[hidden], [data-group-expanded-mode]`)===null){let e=yp(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,yp(t))},[e,i]),f=(0,d.useMemo)(()=>({onScroll:()=>{l(`scroll`)},onWheel:u,onTouchStart:u,onPointerDown:u,onKeyDown:e=>{!e.defaultPrevented&&Cp.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 Tp=`@deepseek-ai/dsh-client-ui-chat/ChatGroupSeat.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Tp)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Tp,e.textContent=`.yzVGVG_root{min-width:0}.yzVGVG_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){.yzVGVG_title:hover{color:var(--dsw-alias-label-secondary)}}.yzVGVG_title:active{color:var(--dsw-alias-label-secondary)}.yzVGVG_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}.yzVGVG_leading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}.yzVGVG_leading svg[width="16"]{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px))}.yzVGVG_activityIcon,.yzVGVG_chevron{justify-content:center;align-items:center;transition:opacity .1s;display:inline-flex;position:absolute;inset:0}.yzVGVG_activityIcon{opacity:1}.yzVGVG_chevron{opacity:0}html:not([data-input-modality=pointer]) .yzVGVG_title:focus-visible .yzVGVG_activityIcon{opacity:0}html:not([data-input-modality=pointer]) .yzVGVG_title:focus-visible .yzVGVG_chevron{opacity:1}@media (hover:hover){.yzVGVG_title:hover .yzVGVG_activityIcon{opacity:0}.yzVGVG_title:hover .yzVGVG_chevron{opacity:1}}.yzVGVG_title[aria-expanded=true] .yzVGVG_activityIcon{opacity:0}.yzVGVG_title[aria-expanded=true] .yzVGVG_chevron{opacity:1}.yzVGVG_title[aria-expanded=true]{padding-bottom:8px}.yzVGVG_body{--dsh-chat-flow-gap:6px;overscroll-behavior-y:auto;scrollbar-gutter:stable;max-height:min(400px,50vh);overflow-y:auto}.yzVGVG_label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.yzVGVG_fadeTop{mask-image:linear-gradient(#0000 0,#000 24px 100%)}.yzVGVG_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 24px),#0000 100%)}.yzVGVG_fadeTop.yzVGVG_fadeBottom{mask-image:linear-gradient(#0000 0,#000 24px calc(100% - 24px),#0000 100%)}@media (prefers-reduced-motion:reduce){.yzVGVG_title,.yzVGVG_activityIcon,.yzVGVG_chevron{transition:none}}.yzVGVG_content{flex-direction:column;display:flex}.yzVGVG_content>*{flex-shrink:0}.yzVGVG_content>:not([hidden]):not(:empty)~:not([hidden]):not(:empty){margin-top:var(--dsh-chat-flow-gap,6px)}.yzVGVG_expandedBody{scrollbar-gutter:auto;max-height:none;overflow:visible}`,document.head.appendChild(e)}var Ep={activityIcon:`yzVGVG_activityIcon`,body:`yzVGVG_body`,chevron:`yzVGVG_chevron`,content:`yzVGVG_content`,expandedBody:`yzVGVG_expandedBody`,fadeBottom:`yzVGVG_fadeBottom`,fadeTop:`yzVGVG_fadeTop`,label:`yzVGVG_label`,leading:`yzVGVG_leading`,root:`yzVGVG_root`,title:`yzVGVG_title`};let Dp={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 Op(e,t){return e.activity===t.activity&&e.detail===t.detail&&e.preparing===t.preparing}function kp(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||Op(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 Ap=(0,d.memo)(function({members:e,...t}){return e.map(e=>/* @__PURE__ */ (0,d.createElement)(cp,{...t,key:hp(e),nodeKey:e.key,...e.groupPart===void 0?{}:{groupPart:e.groupPart}}))}),jp=(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=kp({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?gp(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:Ep.title,"aria-expanded":i,"aria-controls":a,"data-process-activity":h,onClick:e=>{e.currentTarget.focus(),o()},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Ep.leading,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Ep.activityIcon,"data-step-process-icon":!0,children:Dp[h]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Ep.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:Ep.label,children:m})})]})}),Mp=(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}=_p(),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:Zf(e,i),[i]),y=n.useStore(v),b=o&&u?.turnClosed===!0&&_!==void 0&&!g&&y?.answerStep!==(_.answerStep??0),x=$f(b,(0,d.useCallback)(()=>{_!==void 0&&!g&&n.actions.setTurnProcessOpen(_.turn,_.answerStep??0,!0)},[n.actions,_,g]));(0,d.useEffect)(()=>{b&&x.current?.hasAttribute(`hidden`)&&c(!1)},[b,x,c]);let ee=(0,d.useCallback)(()=>{c(!0)},[c]),S=$f(m&&!s,ee),C=(0,d.useRef)(null),w=(0,d.useId)(),{edges:T,events:E,initialize:D}=wp(S,C,s,m),te=(0,d.useCallback)(()=>{s||D(a===!1?`bottom`:`top`),c(!s)},[a,D,s,c]);if(r===void 0)return null;let ne=[Ep.body,m?``:Ep.expandedBody,m&&T.canScrollUp?Ep.fadeTop:``,m&&T.canScrollDown?Ep.fadeBottom:``];return/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:x,className:Ep.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)(jp,{groupKey:e,useChatGroup:t,usePresentation:n.usePresentation,t:n.t,open:s,bodyId:w,toggle:te})}),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:S,id:w,className:ne.join(` `),"data-step-process-body":!0,"data-scroll-up":T.canScrollUp||void 0,"data-scroll-down":T.canScrollDown||void 0,...E,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:C,className:Ep.content,"data-step-process-content":!0,"data-chat-flow":``,children:/* @__PURE__ */ (0,f.jsx)(Ap,{...n,members:r})})})]})});function Np(e){return typeof e==`object`?e.key:e}function Pp(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 Fp(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 Ip(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}let Lp=(e,t)=>Math.abs(e-t)<1.01,Rp=(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)}})},zp,Bp=()=>{if(zp!==void 0)return zp;if(typeof navigator>`u`)return zp=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return zp=!0;let e=navigator.maxTouchPoints;return zp=navigator.platform===`MacIntel`&&e!==void 0&&e>0},Vp=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Hp=e=>e,Up=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},Wp=(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(Vp(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(Vp(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Gp={passive:!0},Kp=typeof window>`u`||`onscrollend`in window,qp=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Kp,o=0,s=a?null:Rp(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,Gp),a&&r.addEventListener(`scrollend`,u,Gp),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},Jp=(e,t)=>qp(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Yp=(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`]},Xp=(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 Zp(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 Qp=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:Hp,rangeExtractor:Up,onChange:()=>{},measureElement:Yp,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=>Np(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||Zp(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=Fp(()=>(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,Bp()&&this.targetWindow!=null&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Gp),e.addEventListener(`touchend`,n,Gp),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&&(Bp()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this.scrollState?.behavior===`smooth`&&!Lp(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=Fp(()=>[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=Fp(()=>[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=Pp(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=Fp(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=tm(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Fp(()=>{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=Fp(()=>[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 Ip(t[$p(0,t.length-1,r?e=>n[e*2]:e=>Ip(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(Bp()&&(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&&Lp(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 $p=(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 em(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 tm(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=em(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=$p(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 nm=typeof document<`u`?d.useLayoutEffect:d.useEffect;function rm({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 Qp(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),nm(()=>u._didMount(),[]),nm(()=>(s(u),u._willUpdate())),nm(()=>{c(u)}),u}function im(e){return rm({observeElementRect:Wp,observeElementOffset:Jp,scrollToFn:Xp,...e})}let am=`@deepseek-ai/dsh-client-ui-chat/TurnNavigator.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=`.FJ_OyG_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] .FJ_OyG_slot{position:sticky}.FJ_OyG_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%)}.FJ_OyG_frame[hidden]{display:none}.FJ_OyG_scroller{max-height:inherit;overscroll-behavior:contain;scrollbar-width:none;position:relative;overflow-y:auto}.FJ_OyG_scroller::-webkit-scrollbar{display:none}.FJ_OyG_fadeTop{mask-image:linear-gradient(#0000 0,#000 40px 100%)}.FJ_OyG_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 40px),#0000 100%)}.FJ_OyG_fadeTop.FJ_OyG_fadeBottom{mask-image:linear-gradient(#0000 0,#000 40px calc(100% - 40px),#0000 100%)}.FJ_OyG_marks{position:relative}.FJ_OyG_mark{cursor:pointer;background:0 0;border:0;border-radius:8px;height:10px;padding:0;position:absolute;top:0;left:0;right:0}.FJ_OyG_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)}.FJ_OyG_markUnloaded:before{opacity:.25}.FJ_OyG_mark[data-neighbor-distance="3"]:before{transform:translateY(-50%)scaleX(.384615)}.FJ_OyG_mark[data-neighbor-distance="2"]:before{transform:translateY(-50%)scaleX(.538462)}.FJ_OyG_mark[data-neighbor-distance="1"]:before{transform:translateY(-50%)scaleX(.769231)}.FJ_OyG_markBusy:before{animation:1s ease-in-out infinite FJ_OyG_dsh-turn-mark-busy}.FJ_OyG_markActive:before{background:var(--dsw-alias-label-primary);opacity:.6}.FJ_OyG_frame[data-previewing] .FJ_OyG_markActive:not(.FJ_OyG_markPreview):not(:focus-visible):before{background:var(--dsw-alias-label-tertiary);opacity:.4}.FJ_OyG_markPreview:before{background:var(--dsw-alias-label-primary);opacity:1;transform:translateY(-50%)scaleX(1)}.FJ_OyG_frame[data-scrubbing] .FJ_OyG_mark:before{transition:none}.FJ_OyG_mark:focus-visible:before{background:var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));opacity:1;transform:translateY(-50%)scaleX(1)}.FJ_OyG_mark:focus-visible{outline:none}.FJ_OyG_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}.FJ_OyG_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 FJ_OyG_dsh-turn-preview-enter;position:absolute;left:100%;overflow:hidden}.FJ_OyG_previewPrompt,.FJ_OyG_previewResponse{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.FJ_OyG_previewPrompt{-webkit-line-clamp:1;font-size:14px;font-weight:500;line-height:20px}.FJ_OyG_previewResponse{color:var(--dsw-alias-label-caption);-webkit-line-clamp:3;margin-top:4px;font-size:14px;line-height:20px}@keyframes FJ_OyG_dsh-turn-preview-enter{0%{opacity:0;transform:translate(-4px)}to{opacity:1;transform:translate(0)}}@keyframes FJ_OyG_dsh-turn-mark-busy{0%,to{opacity:1}50%{opacity:.35}}@media (prefers-reduced-motion:reduce){.FJ_OyG_frame,.FJ_OyG_scroller,.FJ_OyG_mark:before,.FJ_OyG_markBusy:before,.FJ_OyG_preview{scroll-behavior:auto;transition:none;animation:none}}`,document.head.appendChild(e)}var om={"dsh-turn-mark-busy":`FJ_OyG_dsh-turn-mark-busy`,"dsh-turn-preview-enter":`FJ_OyG_dsh-turn-preview-enter`,fadeBottom:`FJ_OyG_fadeBottom`,fadeTop:`FJ_OyG_fadeTop`,frame:`FJ_OyG_frame`,mark:`FJ_OyG_mark`,markActive:`FJ_OyG_markActive`,markBusy:`FJ_OyG_markBusy`,markPreview:`FJ_OyG_markPreview`,markUnloaded:`FJ_OyG_markUnloaded`,marks:`FJ_OyG_marks`,preview:`FJ_OyG_preview`,previewPrompt:`FJ_OyG_previewPrompt`,previewResponse:`FJ_OyG_previewResponse`,scroller:`FJ_OyG_scroller`,slot:`FJ_OyG_slot`};function sm(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}let cm=(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=[om.mark];return e.anchor.kind===`unloaded`&&d.push(om.markUnloaded),n&&d.push(om.markActive),a===0&&d.push(om.markPreview),r&&d.push(om.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 lm({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),ee=(0,d.useRef)(null),S=(0,d.useRef)({placed:!1,index:0,follow:null,publishOffset:null}),C=(0,d.useRef)(!1),w=(0,d.useId)(),T=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()},[T]),(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 E=(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:E.get(t);(0,d.useLayoutEffect)(()=>{S.current.index=D??0},[D]);let te=c===null?void 0:E.get(c),ne=o===null?void 0:E.get(o),re=(0,d.useCallback)(e=>{l(e),s(e),p(e!==null)},[]),ie=im({count:e.length,enabled:T,directDomUpdates:!0,directDomUpdatesMode:`transform`,useScrollendEvent:!0,getScrollElement:(0,d.useCallback)(()=>ee.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)=>{S.current.placed&&Xp(e,t,n)},observeElementOffset:(e,t)=>{S.current.publishOffset=t;let n=Jp(e,t);return()=>{n?.(),S.current.placed=!1,S.current.follow=null,S.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=S.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=Up(e);if(te!==void 0){let n=Math.min(e.count-1,te+1);for(let e=Math.max(0,te-1);e<=n;e++)t.includes(e)||t.push(e);t.sort((e,t)=>e-t)}return t},[te])}),ae=ie.scrollOffset??0,oe=ie.scrollRect?.height??0,se=ie.getVirtualItems(),ce=(0,d.useCallback)((e,t,n=sm())=>{let r=ie.measurementsCache[e],i=ie.scrollRect?.height??0;if(r===void 0||i<=0)return;let a=ie.scrollOffset??0,o=r.start+r.size/2;if(t===`if-needed`){let{scrollPaddingStart:e,scrollPaddingEnd:t}=ie.options;if(o>=a+e&&o<=a+i-t)return}let s=o-i/2,c=Math.max(0,ie.getTotalSize()-i),l=Math.max(0,Math.min(c,s))-a;l!==0&&ie.scrollBy(l,{behavior:n})},[ie]);(0,d.useImperativeHandle)(a,()=>({activateTurn(t){let n=E.get(t),i=n===void 0?void 0:e[n];i!==void 0&&r(i)},scrollToTurn(e){let t=E.get(e);t!==void 0&&ce(t,`always`)}}),[e,E,r,ce]),(0,d.useEffect)(()=>{if(oe<=0){S.current.follow=null;return}if(D===void 0||C.current)return;let t=S.current.follow;if(t?.index===D&&t.count===e.length&&t.height===oe)return;S.current.follow={index:D,count:e.length,height:oe};let n=t?.count===e.length&&t.height===oe?sm():`instant`;ce(D,`if-needed`,n)},[D,e.length,oe,ce]);let le=(0,d.useCallback)(e=>{b.current?b.current=!1:r(e)},[r]),O=t=>{if(t.button!==0||!(t.target instanceof Element))return;let n=t.target.closest(`button[data-index]`);if(!n||!ee.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))},ue=t=>{let n=y.current,i=ee.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))},de=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),C.current||s(null))};if(!T)return null;let fe=!u||ne===void 0?void 0:e[ne],pe=se.find(e=>e.index===ne),me=[om.scroller];return ae>1&&me.push(om.fadeTop),ae<ie.getTotalSize()-oe-1&&me.push(om.fadeBottom),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:v,className:om.slot,children:/* @__PURE__ */ (0,f.jsxs)(`nav`,{className:om.frame,hidden:!m,"data-turn-navigation":``,"data-previewing":ne!==void 0||void 0,"data-scrubbing":g||void 0,onPointerDownCapture:O,onPointerMove:ue,onPointerUpCapture:de,onPointerCancelCapture:de,onLostPointerCapture:de,"aria-label":i(`chat.turnNavigation.label`),onPointerEnter:()=>{C.current=!0},onPointerLeave:()=>{C.current=!1,y.current||s(null)},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{ref:ee,className:me.join(` `),children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:ie.containerRef,className:om.marks,children:se.map(({index:r,key:a})=>{let c=e[r];return c===void 0?null:/* @__PURE__ */ (0,f.jsx)(cm,{item:c,index:r,active:c.turn===t,busy:c.turn===n,previewId:u&&c.turn===o?w:void 0,neighborDistance:ne!==void 0&&Math.abs(r-ne)<=3?Math.abs(r-ne):void 0,registerElement:ie.measureElement,onNavigate:le,onPreview:s,onFocusChange:re,t:i},a)})})}),fe!==void 0&&pe!==void 0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:w,role:`tooltip`,className:om.preview,style:{"--turn-preview-center":`${String(pe.start+pe.size/2-ae)}px`},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:om.previewPrompt,children:fe.prompt||i(`chat.turnNavigation.turn`,{turn:(ne??0)+1})}),fe.response!==``&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:om.previewResponse,children:fe.response})]})]})})}let um=(0,d.memo)((0,d.forwardRef)(lm));function dm(){return/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.runningIcon,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.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 fm=`@deepseek-ai/dsh-client-ui-chat/accessibility.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=`.lM_Y6G_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var pm={visuallyHidden:`lM_Y6G_visuallyHidden`};let mm=(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:vf(Math.max(1e3,i-e),r).map(e=>e.text).join(``)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.running,"data-chat-running":!0,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:pm.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:X.runningDivider,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:X.runningContent,children:[n?null:/* @__PURE__ */ (0,f.jsx)(dm,{}),/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:!n,className:X.runningText,children:o})]})]})});function hm(e){return e}function gm(e){return e}function _m(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 gm(e)}let vm=[];function ym(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:_m(t.seq),prompt:typeof t.prompt==`string`?t.prompt:``,response:typeof t.response==`string`?t.response:``}}function bm(e){return Array.isArray(e)?e:vm}function xm(e,t){let n=/* @__PURE__ */ new Map;for(let e of bm(t)){let t=ym(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?vm:[...n.values()].sort((e,t)=>e.turn-t.turn)}var Sm=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 Cm(e,t,n){let[r,i]=(0,d.useState)(null),[a]=(0,d.useState)(()=>new Sm(e,t,n,i));return(0,d.useLayoutEffect)(()=>{a.setInput(n)},[a,n]),(0,d.useLayoutEffect)(()=>()=>{a.dispose()},[a]),{navigation:a,busyTurn:r}}var wm=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 Tm(e,t,n){let[r,i]=(0,d.useState)(()=>({initialized:!1,followingTail:t.read()===null,activeTurn:n})),a=xp(r.followingTail,25),[o]=(0,d.useState)(()=>new wm(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 Em=[`[data-code-block-controls]`,`[data-selection-actions]`,`[contenteditable='true']`,`textarea`].join(`,`),Dm=/* @__PURE__ */ new Set([`BLOCKQUOTE`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`P`,`PRE`]);function Om(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(Em))e.remove();for(let e of n.querySelectorAll(`ol, ul`))e.replaceWith(`
132
- `,...Array.from(e.childNodes));let r=e.commonAncestorContainer;return Nm(n,r.nodeType===1?r.tagName:r.parentElement?.tagName??n.tagName).trim()}function km(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 Mm(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&&Om(t)!==``?{answerKey:n,start:r,end:i}:void 0}function Am(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 Mm(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),Om(i)===n?i:void 0;r=o}}function jm(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=Am(e,t,n);if(r!==void 0)return{host:e,range:r}}}function*Mm(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(Em)==null&&(yield t)}}function Nm(e,t=e.tagName){let n=``;for(let r of e.childNodes)n+=Pm(r,t);return n}function Pm(e,t){if(e.nodeType===3)return e.textContent??``;if(e.nodeType!==1)return``;let n=e;switch(n.tagName){case`BR`:return`
133
- `;case`TABLE`:return`${Array.from(n.querySelectorAll(`tr`)).map(Fm).join(`
134
- `)}\n`;case`TD`:case`TH`:return`${n.previousElementSibling?.matches(`td, th`)?` `:``}${Nm(n).trimEnd()}`;case`TR`:return`${Fm(n)}\n`;case`THEAD`:case`TBODY`:case`TFOOT`:return Nm(n);case`P`:return Im(n,t);default:{let e=Nm(n);return Dm.has(n.tagName)?`${e}\n`:e}}}function Fm(e){return Array.from(e.children).filter(e=>e.tagName===`TH`||e.tagName===`TD`).map(e=>Nm(e).trim()).join(` `)}function Im(e,t){let n=e.previousElementSibling;return`${n?.tagName===`P`&&n.textContent?.trim()!==``&&e.textContent?.trim()!==``&&t!==`LI`?`
135
- `:``}${Nm(e)}\n`}let Lm=[`wheel`,`touchstart`,`touchmove`,`touchend`,`touchcancel`,`pointerdown`,`keydown`,`beforematch`],Rm=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);var zm=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 Lm)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 Lm)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:yp(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=jm(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=yp(r.body),i=Math.max(0,Math.min(t.floor,t.top+e-r.top));if(t.top!==i){let e=bp.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)||!Rm.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 Bm(){let e=(0,d.useRef)(null),t=(0,d.useRef)(null),[n]=(0,d.useState)(()=>new zm);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 Vm(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}=Bm(),{reading:x,state:ee}=Tm(v,f,u.at(-1)?.turn??null),S=(0,d.useMemo)(()=>({historyReady:n,firstSeq:i,loadingOlder:m,olderFailed:h,hasMore:p,loadOlder:g,loadThrough:_}),[n,i,m,h,p,g,_]),{navigation:C,busyTurn:w}=Cm(v,x,S),T=(0,d.useRef)({input:e,applied:null,opened:!1}),E=(0,d.useCallback)(()=>{let e=T.current.input,t=T.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)&&(T.current.applied=e,e.displayReady&&!T.current.opened?(T.current.opened=!0,C.reset(),x.restore()):n?(C.cancel(),x.followTail()):C.contentCommitted()?C.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?(C.cancel(),x.followTail()):C.reconcile())},[x,C]);(0,d.useLayoutEffect)(()=>{let e=null,t=()=>{e===null&&T.current.opened&&T.current.input.historyReady&&(e=requestAnimationFrame(()=>{e=null,T.current.opened&&T.current.input.historyReady&&C.autoLoadEarlier()}))},n=v.connect({scroll:e=>{x.onScroll(e),e.movedByReader&&e.towardStart&&t()},olderIntent:t,scrollEnd:()=>{x.onScrollEnd(),C.readerSettled()},interact:()=>{C.cancel()},resize:()=>{C.contentCommitted()||x.onResize(),C.reconcile()}}),r=x.connect(e=>{C.readerSampled(e),E()});return()=>{e!==null&&cancelAnimationFrame(e),n(),r(),T.current.opened=!1,T.current.applied=null}},[v,x,C,E]),(0,d.useLayoutEffect)(()=>{let e=T.current.input;T.current.input={displayReady:t,order:r,lastKey:a,lastIsUser:o,steeringId:s,submissionId:c,running:l,loadedTurns:u,chatScroll:f,...S},v.updateTurns(u);let n=e.order!==r||e.displayReady!==t;n&&v.invalidate(),E(),n&&x.refreshActiveTurn()},[v,x,E,S,t,r,a,o,s,c,l,u,f]);let D=(0,d.useCallback)(()=>{C.cancel(),x.followTail()},[C,x]),te=(0,d.useCallback)(e=>{C.cancel();let t=v.scrollToResponseAnnotation(e);t!==null&&(x.acceptNavigation(t),T.current.input.loadingOlder&&v.beginPreserving(t.position))},[C,x,v]);return{listRef:y,columnRef:b,...ee,busyTurn:w,navigateToTurn:C.navigateToTurn,revealResponseAnnotation:te,loadEarlier:C.loadEarlier,returnToBottom:D}}let Hm=`@deepseek-ai/dsh-client-ui-chat/SelectionActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Hm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Hm,e.textContent=`._0hzOkG_popover{z-index:30;background:#000;border:.5px solid #ffffff38;border-radius:9999px;animation:.14s cubic-bezier(.175,.885,.32,1.275) _0hzOkG_selection-island-in;display:flex;position:fixed;overflow:hidden;box-shadow:inset 0 1px #ffffff52,0 6px 18px #000000bf,0 2px 6px #0006}._0hzOkG_action{color:#f5f5f7;letter-spacing:-.01em;white-space:nowrap;cursor:pointer;background:0 0;border:none;border-radius:9999px;align-items:center;gap:5px;height:25px;padding:0 9px;font-family:-apple-system,BlinkMacSystemFont,SF Pro Text,system-ui,sans-serif;font-size:11.5px;font-weight:500;transition:background-color .12s,transform .12s cubic-bezier(.175,.885,.32,1.275);display:inline-flex}._0hzOkG_action+._0hzOkG_action{border-left:.5px solid #ffffff2e;border-radius:0 9999px 9999px 0}._0hzOkG_action:has(+._0hzOkG_action){border-radius:9999px 0 0 9999px}._0hzOkG_action svg{color:#fff;flex-shrink:0}._0hzOkG_action:hover{background:#ffffff1f}._0hzOkG_action:active{background:#fff3;transform:scale(.96)}._0hzOkG_answer{position:relative}::highlight(codexhost-response-annotation){background-color:color-mix(in srgb, var(--dsw-alias-state-business-primary) 22%, transparent);text-decoration:underline var(--dsw-alias-state-business-primary)}._0hzOkG_annotationMark{z-index:1;user-select:none;position:absolute;inset-inline-start:100%}._0hzOkG_annotationMark button{justify-content:center;width:24px;height:24px}._0hzOkG_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);border-radius:5px;place-items:center;padding:0 3px;font-size:11px;font-weight:600;line-height:1;display:grid}@keyframes _0hzOkG_selection-island-in{0%{opacity:0;scale:.9}to{opacity:1;scale:1}}`,document.head.appendChild(e)}var Um={action:`_0hzOkG_action`,annotationMark:`_0hzOkG_annotationMark`,annotationNumber:`_0hzOkG_annotationNumber`,answer:`_0hzOkG_answer`,popover:`_0hzOkG_popover`,"selection-island-in":`_0hzOkG_selection-island-in`};let Wm=`codexhost-response-annotation`;function Gm(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 Km(e){let t=globalThis.CSS?.highlights;if(e.length===0||t===void 0||typeof Highlight>`u`)return()=>{};let n=t.get(Wm)??new Highlight;for(let t of e)n.add(t);return t.set(Wm,n),()=>{for(let t of e)n.delete(t);n.size===0&&t.delete(Wm)}}let qm=[];function Jm({answer:e,answerKey:t,useInput:n,labels:r}){let i=n(e=>e.responseAnnotations),a=(0,d.useMemo)(()=>i?.flatMap((e,n)=>e.anchor?.answerKey===t?[{annotation:e,index:n+1}]:[]),[i,t]),[o,s]=(0,d.useState)(qm);return(0,d.useLayoutEffect)(()=>{let t=e.current;if(t===null||a===void 0||a.length===0){s(qm);return}let n=[],r=()=>{},i=()=>{if(!t.isConnected)return;let e=t.getBoundingClientRect().top,r=n.flatMap(({annotation:t,index:n,range:r})=>{let i=Gm(r);return i===void 0?[]:[{annotation:t,index:n,top:i.top-e+(i.height-24)/2}]});r.sort((e,t)=>e.top-t.top);let i=0,a=r.length===0?qm:r.map(e=>{let t=Math.max(e.top,i);return i=t+24+2,{...e,top:t}});s(e=>e.length===a.length&&e.every((e,t)=>e.annotation===a[t]?.annotation&&e.index===a[t]?.index&&Math.abs(e.top-a[t].top)<.5)?e:a)},o=()=>{r(),t.isConnected?(n=a.flatMap(e=>{let{anchor:n,text:r}=e.annotation,i=n&&Am(t,n,r);return i===void 0?[]:[{...e,range:i}]}),r=Km(n.map(({range:e})=>e)),i()):(n=[],s(qm))};o();let c=typeof ResizeObserver>`u`?null:new ResizeObserver(i);c?.observe(t);let l=typeof MutationObserver>`u`?null:new MutationObserver(o),u=t.firstElementChild;return u!==null&&!u.hasAttribute(`data-selection-actions`)&&l?.observe(u,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`,`open`]}),t.addEventListener(`scroll`,i,!0),()=>{r(),c?.disconnect(),l?.disconnect(),t.removeEventListener(`scroll`,i,!0)}},[e,a]),o.map(({annotation:e,index:t,top:n})=>/* @__PURE__ */ (0,f.jsx)(`div`,{className:Um.annotationMark,style:{top:n},"data-selection-actions":!0,children:/* @__PURE__ */ (0,f.jsx)(p.ResponseAnnotationPopover,{annotation:e,labels:r,title:r.label(t),anchor:/* @__PURE__ */ (0,f.jsx)(`span`,{className:Um.annotationNumber,"aria-label":r.label(t),children:t})})},e.id))}let Ym=`@deepseek-ai/dsh-client-ui-chat/SelectionCommentCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ym)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Ym,e.textContent=`.dlpXTq_card{z-index:30;box-sizing:border-box;color:#f5f5f7;background:#000;border:.5px solid #ffffff38;border-radius:14px;flex-direction:column;gap:6px;width:280px;padding:8px;font-family:-apple-system,BlinkMacSystemFont,SF Pro Text,system-ui,sans-serif;animation:.14s cubic-bezier(.175,.885,.32,1.275) dlpXTq_selection-comment-in;display:flex;position:fixed;box-shadow:inset 0 1px #ffffff52,0 6px 18px #000000bf,0 2px 6px #0006}.dlpXTq_excerpt{color:#f5f5f794;text-overflow:ellipsis;white-space:nowrap;padding:0 2px;font-size:11.5px;line-height:16px;overflow:hidden}.dlpXTq_field{box-sizing:border-box;width:100%;min-height:44px;max-height:120px;color:inherit;font:inherit;resize:none;background:#ffffff14;border:.5px solid #ffffff2e;border-radius:8px;outline:none;padding:6px 8px;font-size:13px;line-height:18px}.dlpXTq_field::placeholder{color:#f5f5f76b}.dlpXTq_field:focus{border-color:#fff6}.dlpXTq_actions{justify-content:flex-end;gap:6px;display:flex}.dlpXTq_cancel,.dlpXTq_submit{height:25px;font:inherit;cursor:pointer;border:none;border-radius:9999px;padding:0 12px;font-size:11.5px;font-weight:600;transition:opacity .12s,transform .12s cubic-bezier(.175,.885,.32,1.275)}.dlpXTq_cancel{color:inherit;background:#ffffff1a}.dlpXTq_submit{color:#000;background:#f5f5f7}.dlpXTq_error{color:#ff9f9f;font-size:11px;line-height:14px}.dlpXTq_submit:disabled{opacity:.35;cursor:default}.dlpXTq_cancel:active,.dlpXTq_submit:not(:disabled):active{transform:scale(.96)}@media (hover:none),(pointer:coarse){.dlpXTq_field{font-size:16px;line-height:22px}}@keyframes dlpXTq_selection-comment-in{0%{opacity:0;scale:.96}to{opacity:1;scale:1}}`,document.head.appendChild(e)}var Xm={actions:`dlpXTq_actions`,cancel:`dlpXTq_cancel`,card:`dlpXTq_card`,error:`dlpXTq_error`,excerpt:`dlpXTq_excerpt`,field:`dlpXTq_field`,"selection-comment-in":`dlpXTq_selection-comment-in`,submit:`dlpXTq_submit`};function Zm({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),p=s.trim();(0,d.useEffect)(()=>{n.current?.focus({preventScroll:!0})},[n]);let m=()=>{p!==``&&!a(p)&&u(!0)};return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Xm.card,"data-placement":i?`below`:`above`,style:r,"data-selection-actions":!0,onKeyDown:e=>{e.key===`Escape`&&!e.nativeEvent.isComposing&&(e.preventDefault(),o())},onMouseDown:e=>{e.target!==n.current&&e.preventDefault()},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Xm.excerpt,children:e.replace(/\s+/gu,` `)}),/* @__PURE__ */ (0,f.jsx)(`textarea`,{ref:n,className:Xm.field,rows:2,value:s,placeholder:t.placeholder,"aria-label":t.placeholder,onChange:e=>{c(e.target.value)},onKeyDown:e=>{e.nativeEvent.isComposing||e.keyCode===229||e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),m())}}),l&&/* @__PURE__ */ (0,f.jsx)(`div`,{role:`alert`,className:Xm.error,children:t.unavailable}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Xm.actions,children:[/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Xm.cancel,onClick:o,children:t.cancel}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Xm.submit,disabled:p===``,onClick:m,children:t.submit})]})]})}function Qm(e){return e instanceof Element?e:e.parentElement}function $m(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=Qm(n.startContainer),i=Qm(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(Em)!=null||i?.closest(Em)!=null)return null;let o=Om(n),s=Gm(n);return o===``||s===void 0?null:{text:o,rect:s,range:n.cloneRange(),host:a}}function eh(e){let t=window.getSelection();t!==null&&e.contains(t.anchorNode)&&e.contains(t.focusNode)&&t.removeAllRanges()}function th(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 nh({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.useCallback)(()=>{c.current=!1,o(null)},[]),m=(0,d.useCallback)(()=>{l.current=null,!(u.current||c.current)&&i($m(n.current))},[n]),g=(0,d.useCallback)(()=>{l.current===null&&(l.current=window.requestAnimationFrame(m))},[m]);(0,d.useEffect)(()=>{let e=()=>{u.current=!1,g()},t=e=>{let t=e.target;(t instanceof Element?t:t instanceof Node?t.parentElement:null)?.closest(`[data-selection-actions]`)??(u.current=!0,i(null),p())},n=()=>{let e=window.getSelection();e===null||e.rangeCount===0||e.isCollapsed?i(null):g()},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===``)&&(i(null),p())};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`pointerup`,e,!0),document.addEventListener(`pointercancel`,e,!0),document.addEventListener(`selectionchange`,n),window.addEventListener(`keyup`,g),window.addEventListener(`scroll`,r,!0),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`pointerup`,e,!0),document.removeEventListener(`pointercancel`,e,!0),document.removeEventListener(`selectionchange`,n),window.removeEventListener(`keyup`,g),window.removeEventListener(`scroll`,r,!0),l.current!==null&&window.cancelAnimationFrame(l.current),l.current=null}},[g,p]);let _=a?.rect,v=a?.range;(0,d.useEffect)(()=>{if(_===void 0||v===void 0)return;let e=window.visualViewport,t=s.current?.closest(`[data-selection-actions]`),n=()=>{let e=t?.offsetHeight??124,n=th(_,e);o(e=>e?.rect===_?{...e,placement:n}:e)},r=Km([v]),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)}},[_,v]);let y=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)(Zm,{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=>!y(a)||!t(a.anchor===void 0?{text:a.text,annotation:e}:{text:a.text,annotation:e,anchor:a.anchor})?!1:(eh(a.host),p(),!0),onCancel:p}),document.body)}if(r===null)return null;let b=th(r.rect),x=()=>r.host.isConnected&&n.current?.contains(r.host)===!0;return(0,h.createPortal)(/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Um.popover,"data-placement":b.below?`below`:`above`,style:{left:b.left,top:b.top,maxWidth:b.maxWidth,transform:`${b.transform} translateZ(0)`},"data-selection-actions":!0,onPointerDown:e=>{e.preventDefault()},children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Um.action,onClick:()=>{if(!x())return;let e=km(r.host,r.range);t(e===void 0?{text:r.text}:{text:r.text,anchor:e})&&(eh(r.host),i(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:Um.action,onClick:()=>{if(!x())return;let e=km(r.host,r.range);eh(r.host),c.current=!0,o({...r,anchor:e,placement:th(r.rect,124)}),i(null)},children:/* @__PURE__ */ (0,f.jsx)(`span`,{children:e.comment})})]}),document.body)}let rh=`@deepseek-ai/dsh-client-ui-chat/ChatMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(rh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=rh,e.textContent=`.za23tq_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}.za23tq_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}.za23tq_linkMenu[data-menu-material] [role=menuitem]>span:has(>svg),.za23tq_linkMenu[data-menu-material] [role=menuitem] svg{width:14px;height:14px}@media (pointer:coarse){.za23tq_linkMenu[data-menu-material] [role=menuitem]{min-height:44px}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){.za23tq_linkMenu[data-menu-material]{--dsw-menu-surface-fill:var(--link-menu-fill);--dsw-menu-backdrop-filter:none}}@media (forced-colors:active){.za23tq_linkMenu[data-menu-material]{--dsw-menu-surface-fill:Canvas;--dsw-menu-backdrop-filter:none;border-color:canvastext}.za23tq_linkMenu[data-menu-material] [role=menuitem]:is(:hover,:focus-visible){outline-offset:-1px;outline:1px solid highlight}}`,document.head.appendChild(e)}var ih={linkMenu:`za23tq_linkMenu`};function ah({children:e,openFile:t,openLinkInSidebar:n,t:r,...i}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),l=(0,d.useCallback)(()=>o(null),[]),u=(0,d.useCallback)(()=>a?.position??null,[a]);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.MarkdownDelegateProvider,{...i,openFile:t,onLinkContextMenu:o,children:e}),/* @__PURE__ */ (0,f.jsx)(p.Menu,{anchor:null,open:a!==null,portal:!0,compact:!0,autoFocus:!0,listClassName:ih.linkMenu,getAnchorRect:u,focusReturnTarget:a?.trigger,onClose:l,children:a!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[(a.kind===`file`||n!==void 0)&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:a.kind===`file`?/* @__PURE__ */ (0,f.jsx)(p.LinkIconMedium,{kind:`document`}):/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineMedium,{}),onSelect:()=>{l(),a.kind===`file`?t(a.path,a.line===void 0?void 0:{line:a.line}):n?.(a.href)},children:r(`linkMenu.openInCodexhost`)}),/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconLinkOutlineMedium,{}),onSelect:()=>{l(),(0,p.writeClipboard)(a.href).then(e=>c(!e))},children:r(`linkMenu.copy`)}),/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconRightUpOutlineMedium,{}),onSelect:()=>{l(),a.kind===`web`?window.open(a.href,`_blank`,`noopener,noreferrer`):t(a.path,{external:!0,...a.line===void 0?{}:{line:a.line}})},children:r(a.kind===`web`?`linkMenu.openBrowser`:`linkMenu.openFile`)}),a.kind===`file`&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconFolderOpenOutlineMedium,{}),onSelect:()=>{l(),t(a.path,{reveal:!0})},children:r(`linkMenu.openFolder`)})]})}),s&&/* @__PURE__ */ (0,f.jsx)(p.Toast,{text:r(`linkMenu.copyFailed`),onDone:()=>c(!1)})]})}function oh(e,t){let n=e instanceof Error?e.message:String(e);return n===``?t:n}function sh(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 ch=(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)(cp,{...i,key:hp(e),nodeKey:e.key,...e.groupPart===void 0?{}:{groupPart:e.groupPart}});case`group`:return/* @__PURE__ */ (0,d.createElement)(Mp,{...i,key:hp(e),groupKey:e.key,useChatGroup:t});default:return mp(e)}}),o=n.map(e=>`requestId`in e?/* @__PURE__ */ (0,f.jsx)(Lf,{submission:e,renderMessageImages:i.renderMessageImages,t:i.t},e.requestId):/* @__PURE__ */ (0,f.jsx)(If,{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 lh({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:ee,loadImage:S,inspectCall:C,chatScroll:w,forkAt:T,loadTurnDiffs:E,editMessage:D,fileMentions:te,usePresentation:ne,useProjection:re,useInput:ie,inputActions:oe,viewRequest:ce,completeViewRequest:le,t:O}){let ue=n(e=>e.order),de=y(e=>e),fe=o(e=>e.views.grouped(`chat`)?.entries),pe=(0,d.useMemo)(()=>fe??ue.map(e=>({kind:`node`,key:e})),[fe,ue]),me=n(e=>e.nodes),he=n(e=>e.navigation.items()),ge=he.at(-1)?.anchorKey,k=r(ge??``,e=>{let t=e?.location;return(t?.kind===`turn`||t?.kind===`step`)&&t.turn.status===`open`?t.turn.start?.time:void 0}),_e=re(`turnOutline`),ve=(0,d.useMemo)(()=>xm(he,_e),[he,_e]),ye=re(`inbox`),be=s(e=>e.byId[m]?.cwd),xe=s(e=>!!e.byId[m]?.projectionValues?.remoteHost),Se=(0,d.useMemo)(()=>({resolve:e=>xe?void 0:se(document.baseURI,ae(be,e)),labels:{open:O(`image.open`),loading:O(`image.loading`),failed:O(`image.failed`),dialog:O(`image.dialog`),close:O(`image.close`)}}),[be,xe,O]),Ce=(0,d.useCallback)(e=>oe?.addResponseAnnotation(e,{focus:`end`})!==void 0,[oe]),we=t(e=>e.running),Te=(0,d.useSyncExternalStore)(e.state.subscribe,e.state.getSnapshot),Ee=(0,p.useSustainedRecovery)(Te!==`connected`),De=re(`compacting`),A=t(e=>e.openState),Oe=re(`remoteHistoryError`),ke=re(`nativeConnection`),Ae=Te===`disconnected`||Ee||A===`error`||!!Oe||ke?.state===`reconnecting`,je=t(e=>e.openError),Me=t(e=>e.hasMore),Ne=t(e=>e.loadingOlder),Pe=t(e=>e.olderError),[Fe,Ie]=(0,d.useState)(null),[Le,Re]=(0,d.useState)(!1),ze=(0,d.useRef)(0),j=(0,d.useCallback)((e,t)=>{let n=++ze.current;Re(!0),(t===void 0?h(e):h(e,t)).then(()=>{n===ze.current&&(Ie(null),Re(!1))},r=>{n===ze.current&&(Ie({path:e,options:t,message:oh(r,O(t?.reveal?`fileOpen.folder`:`fileOpen.unknown`))}),Re(!1))})},[h,O]),Be=(0,d.useCallback)(()=>{ze.current+=1,Ie(null),Re(!1)},[]),Ve=(0,d.useMemo)(()=>ye?.[`next-step`].filter(e=>e.source.kind===`user`)??[],[ye]),He=t(e=>e.pendingSubmissions),Ue=Tf(D,re(`sentMessageEdit`)?.seq??null,A!==`open`||we||He.length>0||(ye?.[`next-turn`].length??0)>0),We=Ue.draft&&ue.some(e=>{let t=me.get(e);return t?.kind===`user`&&t.data.seq===Ue.draft?.seq}),Ge=we||He.some(e=>e.placement!==`queued`),[Ke,qe]=(0,d.useMemo)(()=>{if(He.length===0)return[He,void 0];let e=sh(ue,me);return[He.filter(t=>t.placement!==`queued`&&!e.rpcIds.has(t.requestId)),e.lastInputTurn]},[He,ue,me]),Je=(0,d.useMemo)(()=>{let e=new Map(Ke.map(e=>[e.requestId,e])),t=new Set(He.filter(e=>e.placement!==`queued`).map(e=>e.requestId));return[...Ve.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()]},[Ve,He,Ke]),Ye=(0,d.useCallback)(e=>u(`conversation.message.images`,{...e,loadImage:S}),[S,u]),Xe=ue[0],Ze=Xe===void 0?null:me.get(Xe)?.anchorSeq??null,Qe=ue.at(-1)??null,$e=Je.findLast(e=>`source`in e),et=$e?.source.kind===`user`&&`rpcId`in $e.source?$e.source.rpcId:$e?.id??null,tt=Vm({displayReady:A===`open`||ue.length>0,historyReady:A===`open`,order:ue,firstSeq:Ze,lastKey:Qe,running:we,loadingOlder:Ne,olderFailed:Pe!=null,hasMore:Me,chatScroll:w,loadOlder:x,loadThrough:ee,lastIsUser:Qe!==null&&me.get(Qe)?.kind===`user`,steeringId:et,submissionId:Ke.at(-1)?.requestId??null,loadedTurns:he}),nt=ie(e=>e.responseAnnotations.find(e=>e.id===ce?.focus)),{initialized:rt,revealResponseAnnotation:it}=tt;return(0,d.useLayoutEffect)(()=>{rt&&ce?.view===`chat`&&(nt!==void 0&&it(nt),le())},[rt,ce,nt,it,le]),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.frame,children:[tt.initialized&&/* @__PURE__ */ (0,f.jsx)(um,{items:ve,activeTurn:tt.activeTurn,busyTurn:tt.busyTurn,onNavigate:tt.navigateToTurn,t:O}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.root,"data-chat-following-tail":tt.followingTail?``:void 0,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:tt.listRef,className:X.scroll,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:tt.columnRef,className:X.column,"data-chat-flow":``,children:[A===`loading`&&ue.length===0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.hint,children:O(`chat.loadingHistory`)}),A===`error`&&je!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.openError,children:O(`chat.loadError`,{message:je.message,code:je.code})}),Me&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.older,children:Pe==null?/* @__PURE__ */ (0,f.jsx)(`span`,{role:Ne?`status`:void 0,children:O(Ne?`chat.loadingOlder`:`chat.scrollOlder`)}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{role:`alert`,children:O(`chat.loadOlderError`,{message:Pe.message})}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,disabled:Ne,onClick:tt.loadEarlier,children:O(`chat.retryOlder`)})]})}),/* @__PURE__ */ (0,f.jsx)(ah,{openExternalLink:_,openLinkInSidebar:de?v:void 0,resolveLink:b,openFile:j,fileImages:Se,t:O,children:/* @__PURE__ */ (0,f.jsx)(ch,{entries:pe,pendingInputs:Je,lastInputTurn:qe,nodeStore:me,useChatGroup:a,useChatNode:r,useChatNodeProcess:i,usePresentation:ne,useStore:c,actions:l,cwd:be,openFile:j,openSkill:g,inspectCall:C,forkAt:T,loadTurnDiffs:E,messageEditing:Ue,loadImage:S,renderMessageImages:Ye,fileMentions:te,renderSlot:u,t:O})},m),Ue.draft&&!We&&/* @__PURE__ */ (0,f.jsx)(zf,{editing:Ue,renderMessageImages:Ye,t:O}),Ge&&/* @__PURE__ */ (0,f.jsx)(mm,{startTime:k,compacting:De,stale:Ae,t:O}),A===`loading`&&ue.length>0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.syncing,role:`status`,"data-history-syncing":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`,className:X.syncingIcon}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:O(`chat.syncing`)})]})]})})}),oe!==void 0&&/* @__PURE__ */ (0,f.jsx)(nh,{labels:{addToChat:O(`selection.addToChat`),comment:O(`selection.comment`),placeholder:O(`selection.commentPlaceholder`),submit:O(`selection.commentSubmit`),cancel:O(`message.edit.cancel`),unavailable:O(`selection.commentUnavailable`)},onAdd:Ce,container:tt.columnRef},m),!tt.followingTail&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.toBottomSlot,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:X.toBottom,"aria-label":O(`chat.toBottom`),onClick:tt.returnToBottom,children:/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{})})}),Fe!==null&&/* @__PURE__ */ (0,f.jsx)(uh,{title:O(Fe.options?.reveal?`fileOpen.folder`:`fileOpen.title`),message:Fe.message,busy:Le,onClose:Be,onRetry:()=>{j(Fe.path,Fe.options)},t:O})]})}function uh({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:X.modalAction,onClick:r,children:a(`cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,className:X.modalAction,disabled:n,onClick:i,children:a(`retry`)})]})})}let dh=`chat`,fh={"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.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.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}日`},ph={"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.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.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}`},mh=`@deepseek-ai/dsh-client-ui-chat/ReasoningRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(mh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=mh,e.textContent=`.nAJelq_root{flex-direction:column;display:flex}.nAJelq_root:not([data-expanded]){contain:size layout;height:calc(24px + var(--dsh-content-font-delta,0px))}.nAJelq_row{overflow:hidden}.nAJelq_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] .nAJelq_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)}.nAJelq_leading{flex-shrink:0}.nAJelq_title{font-weight:400}.nAJelq_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.nAJelq_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}.nAJelq_summaryText{text-overflow:ellipsis;display:block;overflow:hidden}.nAJelq_summary[data-streaming]{mask-image:linear-gradient(90deg,#000 calc(100% - 48px),#0000)}.nAJelq_summary[data-streaming] .nAJelq_summaryText{text-overflow:clip;overflow:visible}.nAJelq_root:not([data-preview]) .nAJelq_separator,.nAJelq_root:not([data-preview]) .nAJelq_summary{display:none}.nAJelq_thinkBody{padding:4px 0 4px calc(22px + var(--dsh-content-font-delta,0px));min-width:0}`,document.head.appendChild(e)}var hh={leading:`nAJelq_leading`,root:`nAJelq_root`,row:`nAJelq_row`,separator:`nAJelq_separator`,summary:`nAJelq_summary`,summaryText:`nAJelq_summaryText`,thinkBody:`nAJelq_thinkBody`,title:`nAJelq_title`};let gh=/* @__PURE__ */ (0,f.jsx)(p.IconThinkOutlineRegular,{size:14});function _h(e){let t=e.indexOf(`
136
- `);return t===-1?e:e.slice(0,t)}function vh(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(`
131
+ default:xp(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){vp(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===`}`||vp(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 xp(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}function Sp(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 xp(e)}}function Cp(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 wp(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 Tp(e){let t=t=>e.subscribe(t),n=()=>e.getSnapshot();return function(){return wp((0,d.useSyncExternalStore)(t,n))}}function Ep(e){let t=e.clientHeight;return{top:e.scrollTop,height:t,floor:Math.max(0,e.scrollHeight-t)}}var Dp=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 Op(e,t){let[n]=(0,d.useState)(()=>new Dp(e,t));return n}let kp={canScrollUp:!1,canScrollDown:!1},Ap=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);function jp(e,t,n,r){let i=Op(!1,1),a=(0,d.useRef)(null),[o,s]=(0,d.useState)(kp),c=(0,d.useCallback)(e=>{a.current=e},[]),l=(0,d.useCallback)(t=>{let n=e.current,r=kp;if(n!==null&&n.closest(`[hidden], [data-group-expanded-mode]`)===null){let e=Ep(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,Ep(t))},[e,i]),f=(0,d.useMemo)(()=>({onScroll:()=>{l(`scroll`)},onWheel:u,onTouchStart:u,onPointerDown:u,onKeyDown:e=>{!e.defaultPrevented&&Ap.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 Mp=`@deepseek-ai/dsh-client-ui-chat/ChatGroupSeat.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Mp)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Mp,e.textContent=`.yzVGVG_root{min-width:0}.yzVGVG_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){.yzVGVG_title:hover{color:var(--dsw-alias-label-secondary)}}.yzVGVG_title:active{color:var(--dsw-alias-label-secondary)}.yzVGVG_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}.yzVGVG_leading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}.yzVGVG_leading svg[width="16"]{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px))}.yzVGVG_activityIcon,.yzVGVG_chevron{justify-content:center;align-items:center;transition:opacity .1s;display:inline-flex;position:absolute;inset:0}.yzVGVG_activityIcon{opacity:1}.yzVGVG_chevron{opacity:0}html:not([data-input-modality=pointer]) .yzVGVG_title:focus-visible .yzVGVG_activityIcon{opacity:0}html:not([data-input-modality=pointer]) .yzVGVG_title:focus-visible .yzVGVG_chevron{opacity:1}@media (hover:hover){.yzVGVG_title:hover .yzVGVG_activityIcon{opacity:0}.yzVGVG_title:hover .yzVGVG_chevron{opacity:1}}.yzVGVG_title[aria-expanded=true] .yzVGVG_activityIcon{opacity:0}.yzVGVG_title[aria-expanded=true] .yzVGVG_chevron{opacity:1}.yzVGVG_title[aria-expanded=true]{padding-bottom:8px}.yzVGVG_body{--dsh-chat-flow-gap:6px;overscroll-behavior-y:auto;scrollbar-gutter:stable;max-height:min(400px,50vh);overflow-y:auto}.yzVGVG_label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.yzVGVG_fadeTop{mask-image:linear-gradient(#0000 0,#000 24px 100%)}.yzVGVG_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 24px),#0000 100%)}.yzVGVG_fadeTop.yzVGVG_fadeBottom{mask-image:linear-gradient(#0000 0,#000 24px calc(100% - 24px),#0000 100%)}@media (prefers-reduced-motion:reduce){.yzVGVG_title,.yzVGVG_activityIcon,.yzVGVG_chevron{transition:none}}.yzVGVG_content{flex-direction:column;display:flex}.yzVGVG_content>*{flex-shrink:0}.yzVGVG_content>:not([hidden]):not(:empty)~:not([hidden]):not(:empty){margin-top:var(--dsh-chat-flow-gap,6px)}.yzVGVG_expandedBody{scrollbar-gutter:auto;max-height:none;overflow:visible}`,document.head.appendChild(e)}var Np={activityIcon:`yzVGVG_activityIcon`,body:`yzVGVG_body`,chevron:`yzVGVG_chevron`,content:`yzVGVG_content`,expandedBody:`yzVGVG_expandedBody`,fadeBottom:`yzVGVG_fadeBottom`,fadeTop:`yzVGVG_fadeTop`,label:`yzVGVG_label`,leading:`yzVGVG_leading`,root:`yzVGVG_root`,title:`yzVGVG_title`};let Pp={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 Fp(e,t){return e.activity===t.activity&&e.detail===t.detail&&e.preparing===t.preparing}function Ip(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||Fp(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 Lp=(0,d.memo)(function({members:e,...t}){return e.map(e=>/* @__PURE__ */ (0,d.createElement)(hp,{...t,key:Sp(e),nodeKey:e.key,...e.groupPart===void 0?{}:{groupPart:e.groupPart}}))}),Rp=(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=Ip({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?Cp(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:Np.title,"aria-expanded":i,"aria-controls":a,"data-process-activity":h,onClick:e=>{e.currentTarget.focus(),o()},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Np.leading,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Np.activityIcon,"data-step-process-icon":!0,children:Pp[h]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Np.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:Np.label,children:m})})]})}),zp=(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}=wp(),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:ip(e,i),[i]),y=n.useStore(v),b=o&&u?.turnClosed===!0&&_!==void 0&&!g&&y?.answerStep!==(_.answerStep??0),x=op(b,(0,d.useCallback)(()=>{_!==void 0&&!g&&n.actions.setTurnProcessOpen(_.turn,_.answerStep??0,!0)},[n.actions,_,g]));(0,d.useEffect)(()=>{b&&x.current?.hasAttribute(`hidden`)&&c(!1)},[b,x,c]);let ee=(0,d.useCallback)(()=>{c(!0)},[c]),S=op(m&&!s,ee),C=(0,d.useRef)(null),w=(0,d.useId)(),{edges:T,events:E,initialize:D}=jp(S,C,s,m),te=(0,d.useCallback)(()=>{s||D(a===!1?`bottom`:`top`),c(!s)},[a,D,s,c]);if(r===void 0)return null;let ne=[Np.body,m?``:Np.expandedBody,m&&T.canScrollUp?Np.fadeTop:``,m&&T.canScrollDown?Np.fadeBottom:``];return/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:x,className:Np.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)(Rp,{groupKey:e,useChatGroup:t,usePresentation:n.usePresentation,t:n.t,open:s,bodyId:w,toggle:te})}),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:S,id:w,className:ne.join(` `),"data-step-process-body":!0,"data-scroll-up":T.canScrollUp||void 0,"data-scroll-down":T.canScrollDown||void 0,...E,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:C,className:Np.content,"data-step-process-content":!0,"data-chat-flow":``,children:/* @__PURE__ */ (0,f.jsx)(Lp,{...n,members:r})})})]})});function Bp(e){return typeof e==`object`?e.key:e}function Vp(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 Hp(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 Up(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}let Wp=(e,t)=>Math.abs(e-t)<1.01,Gp=(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)}})},Kp,qp=()=>{if(Kp!==void 0)return Kp;if(typeof navigator>`u`)return Kp=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Kp=!0;let e=navigator.maxTouchPoints;return Kp=navigator.platform===`MacIntel`&&e!==void 0&&e>0},Jp=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Yp=e=>e,Xp=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},Zp=(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(Jp(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(Jp(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Qp={passive:!0},$p=typeof window>`u`||`onscrollend`in window,em=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&$p,o=0,s=a?null:Gp(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,Qp),a&&r.addEventListener(`scrollend`,u,Qp),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},tm=(e,t)=>em(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),nm=(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`]},rm=(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 im(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 am=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:Yp,rangeExtractor:Xp,onChange:()=>{},measureElement:nm,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=>Bp(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||im(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=Hp(()=>(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,qp()&&this.targetWindow!=null&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Qp),e.addEventListener(`touchend`,n,Qp),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&&(qp()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this.scrollState?.behavior===`smooth`&&!Wp(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=Hp(()=>[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=Hp(()=>[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=Vp(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=Hp(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=cm(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Hp(()=>{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=Hp(()=>[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 Up(t[om(0,t.length-1,r?e=>n[e*2]:e=>Up(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(qp()&&(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&&Wp(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 om=(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 sm(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 cm(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=sm(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=om(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 lm=typeof document<`u`?d.useLayoutEffect:d.useEffect;function um({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 am(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),lm(()=>u._didMount(),[]),lm(()=>(s(u),u._willUpdate())),lm(()=>{c(u)}),u}function dm(e){return um({observeElementRect:Zp,observeElementOffset:tm,scrollToFn:rm,...e})}let fm=`@deepseek-ai/dsh-client-ui-chat/TurnNavigator.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=`.FJ_OyG_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] .FJ_OyG_slot{position:sticky}.FJ_OyG_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%)}.FJ_OyG_frame[hidden]{display:none}.FJ_OyG_scroller{max-height:inherit;overscroll-behavior:contain;scrollbar-width:none;position:relative;overflow-y:auto}.FJ_OyG_scroller::-webkit-scrollbar{display:none}.FJ_OyG_fadeTop{mask-image:linear-gradient(#0000 0,#000 40px 100%)}.FJ_OyG_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 40px),#0000 100%)}.FJ_OyG_fadeTop.FJ_OyG_fadeBottom{mask-image:linear-gradient(#0000 0,#000 40px calc(100% - 40px),#0000 100%)}.FJ_OyG_marks{position:relative}.FJ_OyG_mark{cursor:pointer;background:0 0;border:0;border-radius:8px;height:10px;padding:0;position:absolute;top:0;left:0;right:0}.FJ_OyG_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)}.FJ_OyG_markUnloaded:before{opacity:.25}.FJ_OyG_mark[data-neighbor-distance="3"]:before{transform:translateY(-50%)scaleX(.384615)}.FJ_OyG_mark[data-neighbor-distance="2"]:before{transform:translateY(-50%)scaleX(.538462)}.FJ_OyG_mark[data-neighbor-distance="1"]:before{transform:translateY(-50%)scaleX(.769231)}.FJ_OyG_markBusy:before{animation:1s ease-in-out infinite FJ_OyG_dsh-turn-mark-busy}.FJ_OyG_markActive:before{background:var(--dsw-alias-label-primary);opacity:.6}.FJ_OyG_frame[data-previewing] .FJ_OyG_markActive:not(.FJ_OyG_markPreview):not(:focus-visible):before{background:var(--dsw-alias-label-tertiary);opacity:.4}.FJ_OyG_markPreview:before{background:var(--dsw-alias-label-primary);opacity:1;transform:translateY(-50%)scaleX(1)}.FJ_OyG_frame[data-scrubbing] .FJ_OyG_mark:before{transition:none}.FJ_OyG_mark:focus-visible:before{background:var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));opacity:1;transform:translateY(-50%)scaleX(1)}.FJ_OyG_mark:focus-visible{outline:none}.FJ_OyG_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}.FJ_OyG_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 FJ_OyG_dsh-turn-preview-enter;position:absolute;left:100%;overflow:hidden}.FJ_OyG_previewPrompt,.FJ_OyG_previewResponse{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.FJ_OyG_previewPrompt{-webkit-line-clamp:1;font-size:14px;font-weight:500;line-height:20px}.FJ_OyG_previewResponse{color:var(--dsw-alias-label-caption);-webkit-line-clamp:3;margin-top:4px;font-size:14px;line-height:20px}@keyframes FJ_OyG_dsh-turn-preview-enter{0%{opacity:0;transform:translate(-4px)}to{opacity:1;transform:translate(0)}}@keyframes FJ_OyG_dsh-turn-mark-busy{0%,to{opacity:1}50%{opacity:.35}}@media (prefers-reduced-motion:reduce){.FJ_OyG_frame,.FJ_OyG_scroller,.FJ_OyG_mark:before,.FJ_OyG_markBusy:before,.FJ_OyG_preview{scroll-behavior:auto;transition:none;animation:none}}`,document.head.appendChild(e)}var pm={"dsh-turn-mark-busy":`FJ_OyG_dsh-turn-mark-busy`,"dsh-turn-preview-enter":`FJ_OyG_dsh-turn-preview-enter`,fadeBottom:`FJ_OyG_fadeBottom`,fadeTop:`FJ_OyG_fadeTop`,frame:`FJ_OyG_frame`,mark:`FJ_OyG_mark`,markActive:`FJ_OyG_markActive`,markBusy:`FJ_OyG_markBusy`,markPreview:`FJ_OyG_markPreview`,markUnloaded:`FJ_OyG_markUnloaded`,marks:`FJ_OyG_marks`,preview:`FJ_OyG_preview`,previewPrompt:`FJ_OyG_previewPrompt`,previewResponse:`FJ_OyG_previewResponse`,scroller:`FJ_OyG_scroller`,slot:`FJ_OyG_slot`};function mm(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}let hm=(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=[pm.mark];return e.anchor.kind===`unloaded`&&d.push(pm.markUnloaded),n&&d.push(pm.markActive),a===0&&d.push(pm.markPreview),r&&d.push(pm.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 gm({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),ee=(0,d.useRef)(null),S=(0,d.useRef)({placed:!1,index:0,follow:null,publishOffset:null}),C=(0,d.useRef)(!1),w=(0,d.useId)(),T=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()},[T]),(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 E=(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:E.get(t);(0,d.useLayoutEffect)(()=>{S.current.index=D??0},[D]);let te=c===null?void 0:E.get(c),ne=o===null?void 0:E.get(o),re=(0,d.useCallback)(e=>{l(e),s(e),p(e!==null)},[]),ie=dm({count:e.length,enabled:T,directDomUpdates:!0,directDomUpdatesMode:`transform`,useScrollendEvent:!0,getScrollElement:(0,d.useCallback)(()=>ee.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)=>{S.current.placed&&rm(e,t,n)},observeElementOffset:(e,t)=>{S.current.publishOffset=t;let n=tm(e,t);return()=>{n?.(),S.current.placed=!1,S.current.follow=null,S.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=S.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=Xp(e);if(te!==void 0){let n=Math.min(e.count-1,te+1);for(let e=Math.max(0,te-1);e<=n;e++)t.includes(e)||t.push(e);t.sort((e,t)=>e-t)}return t},[te])}),ae=ie.scrollOffset??0,oe=ie.scrollRect?.height??0,se=ie.getVirtualItems(),ce=(0,d.useCallback)((e,t,n=mm())=>{let r=ie.measurementsCache[e],i=ie.scrollRect?.height??0;if(r===void 0||i<=0)return;let a=ie.scrollOffset??0,o=r.start+r.size/2;if(t===`if-needed`){let{scrollPaddingStart:e,scrollPaddingEnd:t}=ie.options;if(o>=a+e&&o<=a+i-t)return}let s=o-i/2,c=Math.max(0,ie.getTotalSize()-i),l=Math.max(0,Math.min(c,s))-a;l!==0&&ie.scrollBy(l,{behavior:n})},[ie]);(0,d.useImperativeHandle)(a,()=>({activateTurn(t){let n=E.get(t),i=n===void 0?void 0:e[n];i!==void 0&&r(i)},scrollToTurn(e){let t=E.get(e);t!==void 0&&ce(t,`always`)}}),[e,E,r,ce]),(0,d.useEffect)(()=>{if(oe<=0){S.current.follow=null;return}if(D===void 0||C.current)return;let t=S.current.follow;if(t?.index===D&&t.count===e.length&&t.height===oe)return;S.current.follow={index:D,count:e.length,height:oe};let n=t?.count===e.length&&t.height===oe?mm():`instant`;ce(D,`if-needed`,n)},[D,e.length,oe,ce]);let le=(0,d.useCallback)(e=>{b.current?b.current=!1:r(e)},[r]),O=t=>{if(t.button!==0||!(t.target instanceof Element))return;let n=t.target.closest(`button[data-index]`);if(!n||!ee.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))},ue=t=>{let n=y.current,i=ee.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))},de=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),C.current||s(null))};if(!T)return null;let fe=!u||ne===void 0?void 0:e[ne],pe=se.find(e=>e.index===ne),me=[pm.scroller];return ae>1&&me.push(pm.fadeTop),ae<ie.getTotalSize()-oe-1&&me.push(pm.fadeBottom),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:v,className:pm.slot,children:/* @__PURE__ */ (0,f.jsxs)(`nav`,{className:pm.frame,hidden:!m,"data-turn-navigation":``,"data-previewing":ne!==void 0||void 0,"data-scrubbing":g||void 0,onPointerDownCapture:O,onPointerMove:ue,onPointerUpCapture:de,onPointerCancelCapture:de,onLostPointerCapture:de,"aria-label":i(`chat.turnNavigation.label`),onPointerEnter:()=>{C.current=!0},onPointerLeave:()=>{C.current=!1,y.current||s(null)},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{ref:ee,className:me.join(` `),children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:ie.containerRef,className:pm.marks,children:se.map(({index:r,key:a})=>{let c=e[r];return c===void 0?null:/* @__PURE__ */ (0,f.jsx)(hm,{item:c,index:r,active:c.turn===t,busy:c.turn===n,previewId:u&&c.turn===o?w:void 0,neighborDistance:ne!==void 0&&Math.abs(r-ne)<=3?Math.abs(r-ne):void 0,registerElement:ie.measureElement,onNavigate:le,onPreview:s,onFocusChange:re,t:i},a)})})}),fe!==void 0&&pe!==void 0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:w,role:`tooltip`,className:pm.preview,style:{"--turn-preview-center":`${String(pe.start+pe.size/2-ae)}px`},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:pm.previewPrompt,children:fe.prompt||i(`chat.turnNavigation.turn`,{turn:(ne??0)+1})}),fe.response!==``&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:pm.previewResponse,children:fe.response})]})]})})}let _m=(0,d.memo)((0,d.forwardRef)(gm));function vm(){return/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.runningIcon,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.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 ym=`@deepseek-ai/dsh-client-ui-chat/accessibility.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ym)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=ym,e.textContent=`.lM_Y6G_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var bm={visuallyHidden:`lM_Y6G_visuallyHidden`};let xm=(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:Tf(Math.max(1e3,i-e),r).map(e=>e.text).join(``)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.running,"data-chat-running":!0,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:bm.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:X.runningDivider,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:X.runningContent,children:[n?null:/* @__PURE__ */ (0,f.jsx)(vm,{}),/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:!n,className:X.runningText,children:o})]})]})});function Sm(e){return e}function Cm(e){return e}function wm(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 Cm(e)}let Tm=[];function Em(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:wm(t.seq),prompt:typeof t.prompt==`string`?t.prompt:``,response:typeof t.response==`string`?t.response:``}}function Dm(e){return Array.isArray(e)?e:Tm}function Om(e,t){let n=/* @__PURE__ */ new Map;for(let e of Dm(t)){let t=Em(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?Tm:[...n.values()].sort((e,t)=>e.turn-t.turn)}var km=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 Am(e,t,n){let[r,i]=(0,d.useState)(null),[a]=(0,d.useState)(()=>new km(e,t,n,i));return(0,d.useLayoutEffect)(()=>{a.setInput(n)},[a,n]),(0,d.useLayoutEffect)(()=>()=>{a.dispose()},[a]),{navigation:a,busyTurn:r}}var jm=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 Mm(e,t,n){let[r,i]=(0,d.useState)(()=>({initialized:!1,followingTail:t.read()===null,activeTurn:n})),a=Op(r.followingTail,25),[o]=(0,d.useState)(()=>new jm(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 Nm=[`[data-code-block-controls]`,`[data-selection-actions]`,`[contenteditable='true']`,`textarea`].join(`,`),Pm=/* @__PURE__ */ new Set([`BLOCKQUOTE`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`P`,`PRE`]);function Fm(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(Nm))e.remove();for(let e of n.querySelectorAll(`ol, ul`))e.replaceWith(`
132
+ `,...Array.from(e.childNodes));let r=e.commonAncestorContainer;return Bm(n,r.nodeType===1?r.tagName:r.parentElement?.tagName??n.tagName).trim()}function Im(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 zm(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&&Fm(t)!==``?{answerKey:n,start:r,end:i}:void 0}function Lm(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 zm(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),Fm(i)===n?i:void 0;r=o}}function Rm(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=Lm(e,t,n);if(r!==void 0)return{host:e,range:r}}}function*zm(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(Nm)==null&&(yield t)}}function Bm(e,t=e.tagName){let n=``;for(let r of e.childNodes)n+=Vm(r,t);return n}function Vm(e,t){if(e.nodeType===3)return e.textContent??``;if(e.nodeType!==1)return``;let n=e;switch(n.tagName){case`BR`:return`
133
+ `;case`TABLE`:return`${Array.from(n.querySelectorAll(`tr`)).map(Hm).join(`
134
+ `)}\n`;case`TD`:case`TH`:return`${n.previousElementSibling?.matches(`td, th`)?` `:``}${Bm(n).trimEnd()}`;case`TR`:return`${Hm(n)}\n`;case`THEAD`:case`TBODY`:case`TFOOT`:return Bm(n);case`P`:return Um(n,t);default:{let e=Bm(n);return Pm.has(n.tagName)?`${e}\n`:e}}}function Hm(e){return Array.from(e.children).filter(e=>e.tagName===`TH`||e.tagName===`TD`).map(e=>Bm(e).trim()).join(` `)}function Um(e,t){let n=e.previousElementSibling;return`${n?.tagName===`P`&&n.textContent?.trim()!==``&&e.textContent?.trim()!==``&&t!==`LI`?`
135
+ `:``}${Bm(e)}\n`}let Wm=[`wheel`,`touchstart`,`touchmove`,`touchend`,`touchcancel`,`pointerdown`,`keydown`,`beforematch`],Gm=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);var Km=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 Wm)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 Wm)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:Ep(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=Rm(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=Ep(r.body),i=Math.max(0,Math.min(t.floor,t.top+e-r.top));if(t.top!==i){let e=Dp.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)||!Gm.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 qm(){let e=(0,d.useRef)(null),t=(0,d.useRef)(null),[n]=(0,d.useState)(()=>new Km);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 Jm(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}=qm(),{reading:x,state:ee}=Mm(v,f,u.at(-1)?.turn??null),S=(0,d.useMemo)(()=>({historyReady:n,firstSeq:i,loadingOlder:m,olderFailed:h,hasMore:p,loadOlder:g,loadThrough:_}),[n,i,m,h,p,g,_]),{navigation:C,busyTurn:w}=Am(v,x,S),T=(0,d.useRef)({input:e,applied:null,opened:!1}),E=(0,d.useCallback)(()=>{let e=T.current.input,t=T.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)&&(T.current.applied=e,e.displayReady&&!T.current.opened?(T.current.opened=!0,C.reset(),x.restore()):n?(C.cancel(),x.followTail()):C.contentCommitted()?C.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?(C.cancel(),x.followTail()):C.reconcile())},[x,C]);(0,d.useLayoutEffect)(()=>{let e=null,t=()=>{e===null&&T.current.opened&&T.current.input.historyReady&&(e=requestAnimationFrame(()=>{e=null,T.current.opened&&T.current.input.historyReady&&C.autoLoadEarlier()}))},n=v.connect({scroll:e=>{x.onScroll(e),e.movedByReader&&e.towardStart&&t()},olderIntent:t,scrollEnd:()=>{x.onScrollEnd(),C.readerSettled()},interact:()=>{C.cancel()},resize:()=>{C.contentCommitted()||x.onResize(),C.reconcile()}}),r=x.connect(e=>{C.readerSampled(e),E()});return()=>{e!==null&&cancelAnimationFrame(e),n(),r(),T.current.opened=!1,T.current.applied=null}},[v,x,C,E]),(0,d.useLayoutEffect)(()=>{let e=T.current.input;T.current.input={displayReady:t,order:r,lastKey:a,lastIsUser:o,steeringId:s,submissionId:c,running:l,loadedTurns:u,chatScroll:f,...S},v.updateTurns(u);let n=e.order!==r||e.displayReady!==t;n&&v.invalidate(),E(),n&&x.refreshActiveTurn()},[v,x,E,S,t,r,a,o,s,c,l,u,f]);let D=(0,d.useCallback)(()=>{C.cancel(),x.followTail()},[C,x]),te=(0,d.useCallback)(e=>{C.cancel();let t=v.scrollToResponseAnnotation(e);t!==null&&(x.acceptNavigation(t),T.current.input.loadingOlder&&v.beginPreserving(t.position))},[C,x,v]);return{listRef:y,columnRef:b,...ee,busyTurn:w,navigateToTurn:C.navigateToTurn,revealResponseAnnotation:te,loadEarlier:C.loadEarlier,returnToBottom:D}}let Ym=`@deepseek-ai/dsh-client-ui-chat/SelectionActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ym)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Ym,e.textContent=`._0hzOkG_popover{z-index:30;background:#000;border:.5px solid #ffffff38;border-radius:9999px;animation:.14s cubic-bezier(.175,.885,.32,1.275) _0hzOkG_selection-island-in;display:flex;position:fixed;overflow:hidden;box-shadow:inset 0 1px #ffffff52,0 6px 18px #000000bf,0 2px 6px #0006}._0hzOkG_action{color:#f5f5f7;letter-spacing:-.01em;white-space:nowrap;cursor:pointer;background:0 0;border:none;border-radius:9999px;align-items:center;gap:5px;height:25px;padding:0 9px;font-family:-apple-system,BlinkMacSystemFont,SF Pro Text,system-ui,sans-serif;font-size:11.5px;font-weight:500;transition:background-color .12s,transform .12s cubic-bezier(.175,.885,.32,1.275);display:inline-flex}._0hzOkG_action+._0hzOkG_action{border-left:.5px solid #ffffff2e;border-radius:0 9999px 9999px 0}._0hzOkG_action:has(+._0hzOkG_action){border-radius:9999px 0 0 9999px}._0hzOkG_action svg{color:#fff;flex-shrink:0}._0hzOkG_action:hover{background:#ffffff1f}._0hzOkG_action:active{background:#fff3;transform:scale(.96)}._0hzOkG_answer{position:relative}::highlight(codexhost-response-annotation){background-color:color-mix(in srgb, var(--dsw-alias-state-business-primary) 22%, transparent);text-decoration:underline var(--dsw-alias-state-business-primary)}._0hzOkG_annotationMark{z-index:1;user-select:none;position:absolute;inset-inline-start:100%}._0hzOkG_annotationMark button{justify-content:center;width:24px;height:24px}._0hzOkG_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);border-radius:5px;place-items:center;padding:0 3px;font-size:11px;font-weight:600;line-height:1;display:grid}@keyframes _0hzOkG_selection-island-in{0%{opacity:0;scale:.9}to{opacity:1;scale:1}}`,document.head.appendChild(e)}var Xm={action:`_0hzOkG_action`,annotationMark:`_0hzOkG_annotationMark`,annotationNumber:`_0hzOkG_annotationNumber`,answer:`_0hzOkG_answer`,popover:`_0hzOkG_popover`,"selection-island-in":`_0hzOkG_selection-island-in`};let Zm=`codexhost-response-annotation`;function Qm(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 $m(e){let t=globalThis.CSS?.highlights;if(e.length===0||t===void 0||typeof Highlight>`u`)return()=>{};let n=t.get(Zm)??new Highlight;for(let t of e)n.add(t);return t.set(Zm,n),()=>{for(let t of e)n.delete(t);n.size===0&&t.delete(Zm)}}let eh=[];function th({answer:e,answerKey:t,useInput:n,labels:r}){let i=n(e=>e.responseAnnotations),a=(0,d.useMemo)(()=>i?.flatMap((e,n)=>e.anchor?.answerKey===t?[{annotation:e,index:n+1}]:[]),[i,t]),[o,s]=(0,d.useState)(eh);return(0,d.useLayoutEffect)(()=>{let t=e.current;if(t===null||a===void 0||a.length===0){s(eh);return}let n=[],r=()=>{},i=()=>{if(!t.isConnected)return;let e=t.getBoundingClientRect().top,r=n.flatMap(({annotation:t,index:n,range:r})=>{let i=Qm(r);return i===void 0?[]:[{annotation:t,index:n,top:i.top-e+(i.height-24)/2}]});r.sort((e,t)=>e.top-t.top);let i=0,a=r.length===0?eh:r.map(e=>{let t=Math.max(e.top,i);return i=t+24+2,{...e,top:t}});s(e=>e.length===a.length&&e.every((e,t)=>e.annotation===a[t]?.annotation&&e.index===a[t]?.index&&Math.abs(e.top-a[t].top)<.5)?e:a)},o=()=>{r(),t.isConnected?(n=a.flatMap(e=>{let{anchor:n,text:r}=e.annotation,i=n&&Lm(t,n,r);return i===void 0?[]:[{...e,range:i}]}),r=$m(n.map(({range:e})=>e)),i()):(n=[],s(eh))};o();let c=typeof ResizeObserver>`u`?null:new ResizeObserver(i);c?.observe(t);let l=typeof MutationObserver>`u`?null:new MutationObserver(o),u=t.firstElementChild;return u!==null&&!u.hasAttribute(`data-selection-actions`)&&l?.observe(u,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`,`open`]}),t.addEventListener(`scroll`,i,!0),()=>{r(),c?.disconnect(),l?.disconnect(),t.removeEventListener(`scroll`,i,!0)}},[e,a]),o.map(({annotation:e,index:t,top:n})=>/* @__PURE__ */ (0,f.jsx)(`div`,{className:Xm.annotationMark,style:{top:n},"data-selection-actions":!0,children:/* @__PURE__ */ (0,f.jsx)(p.ResponseAnnotationPopover,{annotation:e,labels:r,title:r.label(t),anchor:/* @__PURE__ */ (0,f.jsx)(`span`,{className:Xm.annotationNumber,"aria-label":r.label(t),children:t})})},e.id))}let nh=`@deepseek-ai/dsh-client-ui-chat/SelectionCommentCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(nh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=nh,e.textContent=`.dlpXTq_card{z-index:30;box-sizing:border-box;color:#f5f5f7;background:#000;border:.5px solid #ffffff38;border-radius:14px;flex-direction:column;gap:6px;width:280px;padding:8px;font-family:-apple-system,BlinkMacSystemFont,SF Pro Text,system-ui,sans-serif;animation:.14s cubic-bezier(.175,.885,.32,1.275) dlpXTq_selection-comment-in;display:flex;position:fixed;box-shadow:inset 0 1px #ffffff52,0 6px 18px #000000bf,0 2px 6px #0006}.dlpXTq_excerpt{color:#f5f5f794;text-overflow:ellipsis;white-space:nowrap;padding:0 2px;font-size:11.5px;line-height:16px;overflow:hidden}.dlpXTq_field{box-sizing:border-box;width:100%;min-height:44px;max-height:120px;color:inherit;font:inherit;resize:none;background:#ffffff14;border:.5px solid #ffffff2e;border-radius:8px;outline:none;padding:6px 8px;font-size:13px;line-height:18px}.dlpXTq_field::placeholder{color:#f5f5f76b}.dlpXTq_field:focus{border-color:#fff6}.dlpXTq_actions{justify-content:flex-end;gap:6px;display:flex}.dlpXTq_cancel,.dlpXTq_submit{height:25px;font:inherit;cursor:pointer;border:none;border-radius:9999px;padding:0 12px;font-size:11.5px;font-weight:600;transition:opacity .12s,transform .12s cubic-bezier(.175,.885,.32,1.275)}.dlpXTq_cancel{color:inherit;background:#ffffff1a}.dlpXTq_submit{color:#000;background:#f5f5f7}.dlpXTq_error{color:#ff9f9f;font-size:11px;line-height:14px}.dlpXTq_submit:disabled{opacity:.35;cursor:default}.dlpXTq_cancel:active,.dlpXTq_submit:not(:disabled):active{transform:scale(.96)}@media (hover:none),(pointer:coarse){.dlpXTq_field{font-size:16px;line-height:22px}}@keyframes dlpXTq_selection-comment-in{0%{opacity:0;scale:.96}to{opacity:1;scale:1}}`,document.head.appendChild(e)}var rh={actions:`dlpXTq_actions`,cancel:`dlpXTq_cancel`,card:`dlpXTq_card`,error:`dlpXTq_error`,excerpt:`dlpXTq_excerpt`,field:`dlpXTq_field`,"selection-comment-in":`dlpXTq_selection-comment-in`,submit:`dlpXTq_submit`};function ih({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),p=s.trim();(0,d.useEffect)(()=>{n.current?.focus({preventScroll:!0})},[n]);let m=()=>{p!==``&&!a(p)&&u(!0)};return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:rh.card,"data-placement":i?`below`:`above`,style:r,"data-selection-actions":!0,onKeyDown:e=>{e.key===`Escape`&&!e.nativeEvent.isComposing&&(e.preventDefault(),o())},onMouseDown:e=>{e.target!==n.current&&e.preventDefault()},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:rh.excerpt,children:e.replace(/\s+/gu,` `)}),/* @__PURE__ */ (0,f.jsx)(`textarea`,{ref:n,className:rh.field,rows:2,value:s,placeholder:t.placeholder,"aria-label":t.placeholder,onChange:e=>{c(e.target.value)},onKeyDown:e=>{e.nativeEvent.isComposing||e.keyCode===229||e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),m())}}),l&&/* @__PURE__ */ (0,f.jsx)(`div`,{role:`alert`,className:rh.error,children:t.unavailable}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:rh.actions,children:[/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:rh.cancel,onClick:o,children:t.cancel}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:rh.submit,disabled:p===``,onClick:m,children:t.submit})]})]})}function ah(e){return e instanceof Element?e:e.parentElement}function oh(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=ah(n.startContainer),i=ah(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(Nm)!=null||i?.closest(Nm)!=null)return null;let o=Fm(n),s=Qm(n);return o===``||s===void 0?null:{text:o,rect:s,range:n.cloneRange(),host:a}}function sh(e){let t=window.getSelection();t!==null&&e.contains(t.anchorNode)&&e.contains(t.focusNode)&&t.removeAllRanges()}function ch(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 lh({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.useCallback)(()=>{c.current=!1,o(null)},[]),m=(0,d.useCallback)(()=>{l.current=null,!(u.current||c.current)&&i(oh(n.current))},[n]),g=(0,d.useCallback)(()=>{l.current===null&&(l.current=window.requestAnimationFrame(m))},[m]);(0,d.useEffect)(()=>{let e=()=>{u.current=!1,g()},t=e=>{let t=e.target;(t instanceof Element?t:t instanceof Node?t.parentElement:null)?.closest(`[data-selection-actions]`)??(u.current=!0,i(null),p())},n=()=>{let e=window.getSelection();e===null||e.rangeCount===0||e.isCollapsed?i(null):g()},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===``)&&(i(null),p())};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`pointerup`,e,!0),document.addEventListener(`pointercancel`,e,!0),document.addEventListener(`selectionchange`,n),window.addEventListener(`keyup`,g),window.addEventListener(`scroll`,r,!0),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`pointerup`,e,!0),document.removeEventListener(`pointercancel`,e,!0),document.removeEventListener(`selectionchange`,n),window.removeEventListener(`keyup`,g),window.removeEventListener(`scroll`,r,!0),l.current!==null&&window.cancelAnimationFrame(l.current),l.current=null}},[g,p]);let _=a?.rect,v=a?.range;(0,d.useEffect)(()=>{if(_===void 0||v===void 0)return;let e=window.visualViewport,t=s.current?.closest(`[data-selection-actions]`),n=()=>{let e=t?.offsetHeight??124,n=ch(_,e);o(e=>e?.rect===_?{...e,placement:n}:e)},r=$m([v]),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)}},[_,v]);let y=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)(ih,{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=>!y(a)||!t(a.anchor===void 0?{text:a.text,annotation:e}:{text:a.text,annotation:e,anchor:a.anchor})?!1:(sh(a.host),p(),!0),onCancel:p}),document.body)}if(r===null)return null;let b=ch(r.rect),x=()=>r.host.isConnected&&n.current?.contains(r.host)===!0;return(0,h.createPortal)(/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Xm.popover,"data-placement":b.below?`below`:`above`,style:{left:b.left,top:b.top,maxWidth:b.maxWidth,transform:`${b.transform} translateZ(0)`},"data-selection-actions":!0,onPointerDown:e=>{e.preventDefault()},children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Xm.action,onClick:()=>{if(!x())return;let e=Im(r.host,r.range);t(e===void 0?{text:r.text}:{text:r.text,anchor:e})&&(sh(r.host),i(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:Xm.action,onClick:()=>{if(!x())return;let e=Im(r.host,r.range);sh(r.host),c.current=!0,o({...r,anchor:e,placement:ch(r.rect,124)}),i(null)},children:/* @__PURE__ */ (0,f.jsx)(`span`,{children:e.comment})})]}),document.body)}let uh=`@deepseek-ai/dsh-client-ui-chat/ChatMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(uh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=uh,e.textContent=`.za23tq_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}.za23tq_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}.za23tq_linkMenu[data-menu-material] [role=menuitem]>span:has(>svg),.za23tq_linkMenu[data-menu-material] [role=menuitem] svg{width:14px;height:14px}@media (pointer:coarse){.za23tq_linkMenu[data-menu-material] [role=menuitem]{min-height:44px}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){.za23tq_linkMenu[data-menu-material]{--dsw-menu-surface-fill:var(--link-menu-fill);--dsw-menu-backdrop-filter:none}}@media (forced-colors:active){.za23tq_linkMenu[data-menu-material]{--dsw-menu-surface-fill:Canvas;--dsw-menu-backdrop-filter:none;border-color:canvastext}.za23tq_linkMenu[data-menu-material] [role=menuitem]:is(:hover,:focus-visible){outline-offset:-1px;outline:1px solid highlight}}`,document.head.appendChild(e)}var dh={linkMenu:`za23tq_linkMenu`};function fh({children:e,openFile:t,openLinkInSidebar:n,t:r,...i}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),l=(0,d.useCallback)(()=>o(null),[]),u=(0,d.useCallback)(()=>a?.position??null,[a]);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.MarkdownDelegateProvider,{...i,openFile:t,onLinkContextMenu:o,children:e}),/* @__PURE__ */ (0,f.jsx)(p.Menu,{anchor:null,open:a!==null,portal:!0,compact:!0,autoFocus:!0,listClassName:dh.linkMenu,getAnchorRect:u,focusReturnTarget:a?.trigger,onClose:l,children:a!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[(a.kind===`file`||n!==void 0)&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:a.kind===`file`?/* @__PURE__ */ (0,f.jsx)(p.LinkIconMedium,{kind:`document`}):/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineMedium,{}),onSelect:()=>{l(),a.kind===`file`?t(a.path,a.line===void 0?void 0:{line:a.line}):n?.(a.href)},children:r(`linkMenu.openInCodexhost`)}),/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconLinkOutlineMedium,{}),onSelect:()=>{l(),(0,p.writeClipboard)(a.href).then(e=>c(!e))},children:r(`linkMenu.copy`)}),/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconRightUpOutlineMedium,{}),onSelect:()=>{l(),a.kind===`web`?window.open(a.href,`_blank`,`noopener,noreferrer`):t(a.path,{external:!0,...a.line===void 0?{}:{line:a.line}})},children:r(a.kind===`web`?`linkMenu.openBrowser`:`linkMenu.openFile`)}),a.kind===`file`&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconFolderOpenOutlineMedium,{}),onSelect:()=>{l(),t(a.path,{reveal:!0})},children:r(`linkMenu.openFolder`)})]})}),s&&/* @__PURE__ */ (0,f.jsx)(p.Toast,{text:r(`linkMenu.copyFailed`),onDone:()=>c(!1)})]})}function ph(e,t){let n=e instanceof Error?e.message:String(e);return n===``?t:n}function mh(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 hh=(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)(hp,{...i,key:Sp(e),nodeKey:e.key,...e.groupPart===void 0?{}:{groupPart:e.groupPart}});case`group`:return/* @__PURE__ */ (0,d.createElement)(zp,{...i,key:Sp(e),groupKey:e.key,useChatGroup:t});default:return xp(e)}}),o=n.map(e=>`requestId`in e?/* @__PURE__ */ (0,f.jsx)(Wf,{submission:e,renderMessageImages:i.renderMessageImages,t:i.t},e.requestId):/* @__PURE__ */ (0,f.jsx)(Uf,{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 gh({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:ee,loadImage:S,inspectCall:C,chatScroll:w,forkAt:T,loadTurnDiffs:E,editMessage:D,fileMentions:te,usePresentation:ne,useProjection:re,useInput:ie,inputActions:oe,viewRequest:ce,completeViewRequest:le,t:O}){let ue=n(e=>e.order),de=y(e=>e),fe=o(e=>e.views.grouped(`chat`)?.entries),pe=(0,d.useMemo)(()=>fe??ue.map(e=>({kind:`node`,key:e})),[fe,ue]),me=n(e=>e.nodes),he=n(e=>e.navigation.items()),ge=he.at(-1)?.anchorKey,k=r(ge??``,e=>{let t=e?.location;return(t?.kind===`turn`||t?.kind===`step`)&&t.turn.status===`open`?t.turn.start?.time:void 0}),_e=re(`turnOutline`),ve=(0,d.useMemo)(()=>Om(he,_e),[he,_e]),ye=re(`inbox`),be=s(e=>e.byId[m]?.cwd),xe=s(e=>!!e.byId[m]?.projectionValues?.remoteHost),Se=(0,d.useMemo)(()=>({resolve:e=>xe?void 0:se(document.baseURI,ae(be,e)),labels:{open:O(`image.open`),loading:O(`image.loading`),failed:O(`image.failed`),dialog:O(`image.dialog`),close:O(`image.close`)}}),[be,xe,O]),Ce=(0,d.useCallback)(e=>oe?.addResponseAnnotation(e,{focus:`end`})!==void 0,[oe]),we=t(e=>e.running),Te=(0,d.useSyncExternalStore)(e.state.subscribe,e.state.getSnapshot),Ee=(0,p.useSustainedRecovery)(Te!==`connected`),De=re(`compacting`),A=t(e=>e.openState),Oe=re(`remoteHistoryError`),ke=re(`nativeConnection`),Ae=Te===`disconnected`||Ee||A===`error`||!!Oe||ke?.state===`reconnecting`,je=t(e=>e.openError),Me=t(e=>e.hasMore),Ne=t(e=>e.loadingOlder),Pe=t(e=>e.olderError),[Fe,Ie]=(0,d.useState)(null),[Le,Re]=(0,d.useState)(!1),ze=(0,d.useRef)(0),j=(0,d.useCallback)((e,t)=>{let n=++ze.current;Re(!0),(t===void 0?h(e):h(e,t)).then(()=>{n===ze.current&&(Ie(null),Re(!1))},r=>{n===ze.current&&(Ie({path:e,options:t,message:ph(r,O(t?.reveal?`fileOpen.folder`:`fileOpen.unknown`))}),Re(!1))})},[h,O]),Be=(0,d.useCallback)(()=>{ze.current+=1,Ie(null),Re(!1)},[]),Ve=(0,d.useMemo)(()=>ye?.[`next-step`].filter(e=>e.source.kind===`user`)??[],[ye]),He=t(e=>e.pendingSubmissions),Ue=Mf(D,re(`sentMessageEdit`)?.seq??null,A!==`open`||we||He.length>0||(ye?.[`next-turn`].length??0)>0),We=Ue.draft&&ue.some(e=>{let t=me.get(e);return t?.kind===`user`&&t.data.seq===Ue.draft?.seq}),Ge=we||He.some(e=>e.placement!==`queued`),[Ke,qe]=(0,d.useMemo)(()=>{if(He.length===0)return[He,void 0];let e=mh(ue,me);return[He.filter(t=>t.placement!==`queued`&&!e.rpcIds.has(t.requestId)),e.lastInputTurn]},[He,ue,me]),Je=(0,d.useMemo)(()=>{let e=new Map(Ke.map(e=>[e.requestId,e])),t=new Set(He.filter(e=>e.placement!==`queued`).map(e=>e.requestId));return[...Ve.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()]},[Ve,He,Ke]),Ye=(0,d.useCallback)(e=>u(`conversation.message.images`,{...e,loadImage:S}),[S,u]),Xe=ue[0],Ze=Xe===void 0?null:me.get(Xe)?.anchorSeq??null,Qe=ue.at(-1)??null,$e=Je.findLast(e=>`source`in e),et=$e?.source.kind===`user`&&`rpcId`in $e.source?$e.source.rpcId:$e?.id??null,tt=Jm({displayReady:A===`open`||ue.length>0,historyReady:A===`open`,order:ue,firstSeq:Ze,lastKey:Qe,running:we,loadingOlder:Ne,olderFailed:Pe!=null,hasMore:Me,chatScroll:w,loadOlder:x,loadThrough:ee,lastIsUser:Qe!==null&&me.get(Qe)?.kind===`user`,steeringId:et,submissionId:Ke.at(-1)?.requestId??null,loadedTurns:he}),nt=ie(e=>e.responseAnnotations.find(e=>e.id===ce?.focus)),{initialized:rt,revealResponseAnnotation:it}=tt;return(0,d.useLayoutEffect)(()=>{rt&&ce?.view===`chat`&&(nt!==void 0&&it(nt),le())},[rt,ce,nt,it,le]),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.frame,children:[tt.initialized&&/* @__PURE__ */ (0,f.jsx)(_m,{items:ve,activeTurn:tt.activeTurn,busyTurn:tt.busyTurn,onNavigate:tt.navigateToTurn,t:O}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.root,"data-chat-following-tail":tt.followingTail?``:void 0,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:tt.listRef,className:X.scroll,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:tt.columnRef,className:X.column,"data-chat-flow":``,children:[A===`loading`&&ue.length===0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.hint,children:O(`chat.loadingHistory`)}),A===`error`&&je!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.openError,children:O(`chat.loadError`,{message:je.message,code:je.code})}),Me&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.older,children:Pe==null?/* @__PURE__ */ (0,f.jsx)(`span`,{role:Ne?`status`:void 0,children:O(Ne?`chat.loadingOlder`:`chat.scrollOlder`)}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{role:`alert`,children:O(`chat.loadOlderError`,{message:Pe.message})}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,disabled:Ne,onClick:tt.loadEarlier,children:O(`chat.retryOlder`)})]})}),/* @__PURE__ */ (0,f.jsx)(fh,{openExternalLink:_,openLinkInSidebar:de?v:void 0,resolveLink:b,openFile:j,fileImages:Se,t:O,children:/* @__PURE__ */ (0,f.jsx)(hh,{entries:pe,pendingInputs:Je,lastInputTurn:qe,nodeStore:me,useChatGroup:a,useChatNode:r,useChatNodeProcess:i,usePresentation:ne,useStore:c,actions:l,cwd:be,openFile:j,openSkill:g,inspectCall:C,forkAt:T,loadTurnDiffs:E,messageEditing:Ue,loadImage:S,renderMessageImages:Ye,fileMentions:te,renderSlot:u,t:O})},m),Ue.draft&&!We&&/* @__PURE__ */ (0,f.jsx)(Kf,{editing:Ue,renderMessageImages:Ye,t:O}),Ge&&/* @__PURE__ */ (0,f.jsx)(xm,{startTime:k,compacting:De,stale:Ae,t:O}),A===`loading`&&ue.length>0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.syncing,role:`status`,"data-history-syncing":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`,className:X.syncingIcon}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:O(`chat.syncing`)})]})]})})}),oe!==void 0&&/* @__PURE__ */ (0,f.jsx)(lh,{labels:{addToChat:O(`selection.addToChat`),comment:O(`selection.comment`),placeholder:O(`selection.commentPlaceholder`),submit:O(`selection.commentSubmit`),cancel:O(`message.edit.cancel`),unavailable:O(`selection.commentUnavailable`)},onAdd:Ce,container:tt.columnRef},m),!tt.followingTail&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.toBottomSlot,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:X.toBottom,"aria-label":O(`chat.toBottom`),onClick:tt.returnToBottom,children:/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{})})}),Fe!==null&&/* @__PURE__ */ (0,f.jsx)(_h,{title:O(Fe.options?.reveal?`fileOpen.folder`:`fileOpen.title`),message:Fe.message,busy:Le,onClose:Be,onRetry:()=>{j(Fe.path,Fe.options)},t:O})]})}function _h({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:X.modalAction,onClick:r,children:a(`cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,className:X.modalAction,disabled:n,onClick:i,children:a(`retry`)})]})})}let vh=`chat`,yh={"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.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.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}日`},bh={"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.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.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}`},xh=`@deepseek-ai/dsh-client-ui-chat/ReasoningRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(xh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=xh,e.textContent=`.nAJelq_root{flex-direction:column;display:flex}.nAJelq_root:not([data-expanded]){contain:size layout;height:calc(24px + var(--dsh-content-font-delta,0px))}.nAJelq_row{overflow:hidden}.nAJelq_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] .nAJelq_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)}.nAJelq_leading{flex-shrink:0}.nAJelq_title{font-weight:400}.nAJelq_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.nAJelq_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}.nAJelq_summaryText{text-overflow:ellipsis;display:block;overflow:hidden}.nAJelq_summary[data-streaming]{mask-image:linear-gradient(90deg,#000 calc(100% - 48px),#0000)}.nAJelq_summary[data-streaming] .nAJelq_summaryText{text-overflow:clip;overflow:visible}.nAJelq_root:not([data-preview]) .nAJelq_separator,.nAJelq_root:not([data-preview]) .nAJelq_summary{display:none}.nAJelq_thinkBody{padding:4px 0 4px calc(22px + var(--dsh-content-font-delta,0px));min-width:0}`,document.head.appendChild(e)}var Sh={leading:`nAJelq_leading`,root:`nAJelq_root`,row:`nAJelq_row`,separator:`nAJelq_separator`,summary:`nAJelq_summary`,summaryText:`nAJelq_summaryText`,thinkBody:`nAJelq_thinkBody`,title:`nAJelq_title`};let Ch=/* @__PURE__ */ (0,f.jsx)(p.IconThinkOutlineRegular,{size:14});function wh(e){let t=e.indexOf(`
136
+ `);return t===-1?e:e.slice(0,t)}function Th(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(`
137
137
  `),o=e.indexOf(`
138
- `,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 yh=(0,d.memo)(function({text:e,running:t,usePresentation:n,useDisclosure:r,t:i}){let{expanded:a,toggle:o}=r(),s=(0,d.useMemo)(()=>jd(i),[i]),c=t?vh(e):_h(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:hh.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:hh.summary,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:hh.summaryText,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{children:l})})})]}),[t,l]),h=(0,d.useMemo)(()=>a?/* @__PURE__ */ (0,f.jsx)(`div`,{className:hh.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:hh.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:pm.visuallyHidden,children:i(`row.running`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{rowClassName:hh.row,leadingClassName:hh.leading,titleClassName:hh.title,icon:gh,title:i(`message.think`),running:t,open:a,expandable:!0,expandOnRowClick:!0,onToggle:o,collapsedContent:m,children:h})]})}),bh=`@deepseek-ai/dsh-client-ui-chat/AssistantMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(bh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=bh,e.textContent=`.UoIYma_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}.UoIYma_body{flex-direction:column;gap:16px;display:flex}.UoIYma_viewedImages{flex-direction:column;align-items:flex-start;gap:10px;display:flex}.UoIYma_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}.UoIYma_viewedImagesToggle:hover{color:var(--dsw-alias-label-secondary)}.UoIYma_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)}.UoIYma_viewedImagesIcon{flex:none;width:16px;height:16px;position:relative}.UoIYma_viewedImagesIcon:before,.UoIYma_viewedImagesIcon:after{content:"";border:1px solid;border-radius:3px;width:11px;height:9px;position:absolute}.UoIYma_viewedImagesIcon:before{top:2px;left:2px}.UoIYma_viewedImagesIcon:after{top:5px;left:5px}.UoIYma_viewedImagesChevron{flex:none;width:12px;height:12px}.UoIYma_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)}.UoIYma_body .md-table-wide>table{z-index:1;position:relative}.UoIYma_body>[data-turn-process-inline][hidden]{margin-bottom:-16px}.UoIYma_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}.UoIYma_actions{margin-top:16px;margin-left:-6px}`,document.head.appendChild(e)}var xh={actions:`UoIYma_actions`,body:`UoIYma_body`,root:`UoIYma_root`,stopped:`UoIYma_stopped`,viewedImages:`UoIYma_viewedImages`,viewedImagesChevron:`UoIYma_viewedImagesChevron`,viewedImagesIcon:`UoIYma_viewedImagesIcon`,viewedImagesToggle:`UoIYma_viewedImagesToggle`};function Sh({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:xh.viewedImages,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:xh.viewedImagesToggle,"aria-expanded":r,onClick:()=>{i(e=>!e)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:xh.viewedImagesIcon,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:a}),r?/* @__PURE__ */ (0,f.jsx)(p.IconChevronUpOutlineRegular,{className:xh.viewedImagesChevron}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:xh.viewedImagesChevron})]}),r&&t({images:e,align:`start`})]})}function Ch(e,t,n){let r;try{r=decodeURIComponent(t.split(/[?#]/u)[0]??``)}catch{return}return n===void 0?se(e,r):n(r)}let wh=(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)(()=>jd(m),[m]),{fileImages:g}=(0,p.useMarkdownDelegate)(),_=(0,d.useMemo)(()=>({resolve:e=>Ch(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,labels:h,fileMentions:l,pathImages:_,responseAnnotations:u},n));break;case`reasoning`:y.push(/* @__PURE__ */ (0,f.jsx)(Th,{hidden:o,reveal:c,children:/* @__PURE__ */ (0,f.jsx)(yh,{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)(Sh,{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:xh.root,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:xh.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:xh.stopped,children:m(`message.stopped`)})]})})});function Th({hidden:e,reveal:t,children:n}){let r=$f(e,t??Eh);return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:r,"data-turn-process-inline":e||void 0,children:n})}let Eh=()=>{},Dh=(0,d.memo)(function({node:e,groupPart:t,useDisclosure:n,useTurnData:r,turnProcess:i,openFile:a,renderMessageImages:o,fileMentions:s,responseAnnotations:c,useInput:l,usePresentation:u,t:p}){let m=e.data,h=(0,d.useRef)(null),g=JSON.stringify([e.key,t??null]),_=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,v=r(`turn-tail`),y=(0,d.useMemo)(()=>{if(_?.status===`closed`&&m.finalNode!==void 0&&v?.closing?.finalNode.seq===m.finalNode.seq)return{turn:_,seq:m.finalNode.seq,openFile:a}},[m.finalNode,a,v,_]),b=(0,d.useMemo)(()=>y===void 0?void 0:s(y),[s,y]),x=i!==void 0&&i.foldable&&i.spec.answerStep===m.step&&i.spec.inlineReasoning&&!i.open,ee=(0,d.useCallback)(()=>{i?.setOpen(!0)},[i]),S=(0,d.useMemo)(()=>Md(p),[p]),C=(0,d.useMemo)(()=>({labels:S,resolve:e=>c[e-1]}),[S,c]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:h,className:Um.answer,"data-selection-answer":g,"data-selection-answer-streaming":m.status===`running`||void 0,children:[/* @__PURE__ */ (0,f.jsx)(wh,{blocks:m.blocks,groupPart:t,useDisclosure:n,streaming:m.status===`running`,interrupted:m.status===`interrupted`,renderMessageImages:o,reasoningHidden:x,usePresentation:u,revealProcess:ee,mentions:b,responseAnnotations:C,t:p}),m.status!==`running`&&/* @__PURE__ */ (0,f.jsx)(Jm,{answer:h,answerKey:g,useInput:l,labels:S})]})}),Oh=`@deepseek-ai/dsh-client-ui-chat/GenericCommandCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Oh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Oh,e.textContent=`.hIxFiG_root{flex-direction:column;display:flex}.hIxFiG_leading{flex-shrink:0}.hIxFiG_title{font-weight:400}.hIxFiG_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.hIxFiG_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}.hIxFiG_summary[data-error],.hIxFiG_body[data-error]{color:var(--dsw-alias-state-error-primary)}.hIxFiG_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 kh={body:`hIxFiG_body`,leading:`hIxFiG_leading`,root:`hIxFiG_root`,separator:`hIxFiG_separator`,summary:`hIxFiG_summary`,title:`hIxFiG_title`};let Ah=/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{size:14});function jh(e){return e===null?`running`:e.kind===`error`?`error`:`ok`}let Mh=(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=jh(e.outcome),u=l===`running`,m=o!==void 0&&o.includes(`
139
- `)?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:kh.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:kh.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:kh.body,"data-error":l===`error`||void 0,children:m}):void 0,[m,h,l]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:kh.root,"data-variant":`others`,"data-command":e.name??void 0,"data-state":l,children:[l===`running`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:pm.visuallyHidden,children:t(`row.running`)}),l===`error`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:pm.visuallyHidden,children:t(`row.failed`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{leadingClassName:kh.leading,titleClassName:kh.title,icon:Ah,title:c,running:u,open:h,expandable:m!==null,expandOnRowClick:!0,keepContentWhenOpen:!0,onToggle:g,collapsedContent:_,children:v})]})});function Nh({node:e,compaction:t,t:n}){return t===void 0?/* @__PURE__ */ (0,f.jsx)(Mh,{node:e,t:n,runningSummary:n(`message.compaction.running`),successSummary:n(`message.compaction`)}):/* @__PURE__ */ (0,f.jsx)(zd,{node:t,title:n(`message.compaction.commandTitle`),fallbackSummary:e.outcome?.text??null,t:n})}let Ph=(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:X.callRow,children:t(`conversation.chat.commandview`,i,{entryKey:r.name??``,fallback:/* @__PURE__ */ (0,f.jsx)(Mh,{...i,t:n})})})}),Fh=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.callRow,children:/* @__PURE__ */ (0,f.jsx)(Nh,{node:n.command,...n.compaction===null?{}:{compaction:n.compaction},t})})});function Ih({text:e,update:t=!1,t:n}){let[r,i]=(0,d.useState)(!1);return/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{className:pf.root,icon:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),chevronClassName:pf.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:pf.body,"data-system-prompt-body":!0,children:/* @__PURE__ */ (0,f.jsx)(Xd,{content:[{type:`text`,text:e}],source:null,t:n})})})}let Lh=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(Ih,{text:e.data.text,update:e.data.update===!0,t})}),Rh=`@deepseek-ai/dsh-client-ui-chat/TurnProcessNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Rh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Rh,e.textContent=`.ty-UXa_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}.ty-UXa_root:disabled{cursor:default}@media (hover:hover){.ty-UXa_root:hover:not(:disabled){color:var(--dsw-alias-label-secondary)}}.ty-UXa_root:active:not(:disabled){color:var(--dsw-alias-label-secondary)}.ty-UXa_chevron{width:14px;height:14px;color:inherit;flex:none;margin-left:4px;transition:transform .1s}.ty-UXa_root[data-open] .ty-UXa_chevron{transform:rotate(180deg)}.ty-UXa_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}.ty-UXa_durationNumber{font-family:var(--ds-font-family-code);font-variant-numeric:tabular-nums}@media (prefers-reduced-motion:reduce){.ty-UXa_root,.ty-UXa_chevron{transition:none}}`,document.head.appendChild(e)}var zh={chevron:`ty-UXa_chevron`,durationNumber:`ty-UXa_durationNumber`,label:`ty-UXa_label`,root:`ty-UXa_root`};let Bh=(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&&!Xf(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:vf(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:pm.visuallyHidden,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:u}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:zh.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:zh.label,children:[l,c?.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(`span`,{className:e.numeric?zh.durationNumber:void 0,children:e.text},t))]}),a&&/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:zh.chevron})]})]})});function Vh(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 Hh=`@deepseek-ai/dsh-client-ui-chat/TurnChangesCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Hh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Hh,e.textContent=`.IG8hNq_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}.IG8hNq_header{align-items:center;gap:12px;padding:12px;display:flex}.IG8hNq_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}.IG8hNq_text{flex-direction:column;flex:auto;gap:2px;min-width:0;display:flex}.IG8hNq_title{text-overflow:ellipsis;white-space:nowrap;font-weight:600;overflow:hidden}.IG8hNq_review,.IG8hNq_fileHead,.IG8hNq_more{color:inherit;font:inherit;text-align:left;cursor:pointer;background:0 0;border:0}.IG8hNq_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){.IG8hNq_review:hover,.IG8hNq_fileHead:hover,.IG8hNq_more:hover{background:var(--dsw-alias-interactive-bg-hover)}}.IG8hNq_review:active,.IG8hNq_fileHead:active,.IG8hNq_more:active{background:var(--dsw-alias-interactive-bg-hover)}.IG8hNq_review:focus-visible,.IG8hNq_fileHead:focus-visible,.IG8hNq_more:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:-2px}.IG8hNq_files{border-top:1px solid var(--dsw-alias-border-l2);margin:0;padding:0;list-style:none}.IG8hNq_fileHead{justify-content:space-between;align-items:center;gap:12px;width:100%;min-height:40px;padding:8px 12px;display:flex}.IG8hNq_fileHead .IG8hNq_path{min-width:0;font-size:inherit;--dsw-alias-label-tertiary:var(--dsw-alias-label-secondary);flex:1}.IG8hNq_diff{padding:0 12px 12px}.IG8hNq_file:first-child .IG8hNq_diff:first-child{padding-top:12px}.IG8hNq_more{align-items:center;gap:8px;width:100%;min-height:40px;padding:8px 12px;font-weight:500;display:flex}.IG8hNq_mobileChevron,.IG8hNq_mobileFileIcon,.IG8hNq_mobilePath,.IG8hNq_mobileFullPath{display:none}.IG8hNq_chevron{flex:none;transition:transform .15s}.IG8hNq_chevron[data-open=true]{transform:rotate(180deg)}@media (width<=480px){.IG8hNq_header{grid-template-columns:36px minmax(0,1fr);gap:8px;display:grid}.IG8hNq_icon{width:36px;height:36px}.IG8hNq_review{grid-column:2;justify-self:start}}[data-phone] .IG8hNq_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] .IG8hNq_header{grid-template-columns:20px minmax(0,1fr) 44px;gap:8px;min-height:52px;padding:0 4px 0 12px;display:grid}[data-phone] .IG8hNq_icon{background:0 0;border-radius:0;width:20px;height:20px}[data-phone] .IG8hNq_icon>svg{width:16px;height:16px}[data-phone] .IG8hNq_text{flex-direction:row;align-items:center;gap:8px}[data-phone] .IG8hNq_title{flex:auto;min-width:0;font-weight:500}[data-phone] .IG8hNq_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] .IG8hNq_reviewLabel{display:none}[data-phone] .IG8hNq_mobileChevron,[data-phone] .IG8hNq_mobileFileIcon{color:var(--dsw-alias-label-secondary);flex:none;display:block}[data-phone] .IG8hNq_mobileChevron{transition:transform .15s}[data-phone] .IG8hNq_mobileChevron[data-open=true]{transform:rotate(180deg)}[data-phone] .IG8hNq_fileHead,[data-phone] .IG8hNq_more{gap:8px;min-height:44px;padding:0 12px}[data-phone] .IG8hNq_file+.IG8hNq_file{border-top:1px solid var(--dsw-alias-border-l2)}[data-phone] .IG8hNq_path{display:none}[data-phone] .IG8hNq_mobilePath{flex-direction:column;flex:1;min-width:0;padding-block:4px;display:flex}[data-phone] .IG8hNq_fileName{text-overflow:ellipsis;white-space:nowrap;font-weight:500;overflow:hidden}[data-phone] .IG8hNq_directory,[data-phone] .IG8hNq_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] .IG8hNq_mobileFullPath{user-select:text;padding:4px 12px;display:block}[data-phone] .IG8hNq_diff,[data-phone] .IG8hNq_file:first-child .IG8hNq_diff:first-child{padding:0}[data-phone] .IG8hNq_diffStatus{overflow-wrap:anywhere;padding:12px;display:block}[data-phone] .IG8hNq_diffStatus button{min-width:44px;min-height:44px}[data-phone] .IG8hNq_inlineDiff{border-radius:0;min-width:0;max-width:100%;margin:0}[data-phone] .IG8hNq_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] .IG8hNq_inlineDiff [data-diff-row=path]{display:none}[data-phone] .IG8hNq_inlineDiff [data-code-block-banner]{gap:8px;min-height:44px;padding:0 8px 0 12px}[data-phone] .IG8hNq_inlineDiff [data-code-block-banner] button{width:44px;height:44px}@media (prefers-reduced-motion:reduce){[data-phone] .IG8hNq_mobileChevron{transition:none}}`,document.head.appendChild(e)}var Z={card:`IG8hNq_card`,chevron:`IG8hNq_chevron`,diff:`IG8hNq_diff`,diffStatus:`IG8hNq_diffStatus`,directory:`IG8hNq_directory`,file:`IG8hNq_file`,fileHead:`IG8hNq_fileHead`,fileName:`IG8hNq_fileName`,files:`IG8hNq_files`,header:`IG8hNq_header`,icon:`IG8hNq_icon`,inlineDiff:`IG8hNq_inlineDiff`,mobileChevron:`IG8hNq_mobileChevron`,mobileFileIcon:`IG8hNq_mobileFileIcon`,mobileFullPath:`IG8hNq_mobileFullPath`,mobilePath:`IG8hNq_mobilePath`,more:`IG8hNq_more`,path:`IG8hNq_path`,review:`IG8hNq_review`,reviewLabel:`IG8hNq_reviewLabel`,text:`IG8hNq_text`,title:`IG8hNq_title`};let Uh=(0,d.memo)(function({nodeStore:e,turn:t,t:n,useProjection:r,loadTurnDiffs:i}){let a=ee(e,t,r),o=(0,d.useMemo)(()=>{let e=/* @__PURE__ */ new Map;for(let t of a){let n=C(t.path);e.set(n,(e.get(n)??0)+1)}return e},[a]),[s,c]=(0,d.useState)(()=>/* @__PURE__ */ new Set),[l,u]=(0,d.useState)(!1),m=Vh(t,a,s,i),h=(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(a.length===0)return null;let{added:g,removed:_}=S(a),[y]=a,b=a.length===1&&y!==void 0?n(`chat.fileEdited`,{name:C(y.path)}):n(`chat.filesEdited`,{count:a.length}),x=a.some(e=>s.has(e.path)),w=l?a:a.slice(0,3),T=a.length-w.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:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.title,title:b,children:b}),/* @__PURE__ */ (0,f.jsx)(v,{added:g,removed:_})]}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.review,"aria-expanded":x,"aria-label":n(x?`chat.hideChanges`:`chat.viewChanges`),onClick:()=>{c(new Set(x?[]:a.map(e=>e.path))),x||u(!0)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.reviewLabel,children:n(x?`chat.hideChanges`:`chat.viewChanges`)}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.mobileChevron,"data-open":x})]})]}),(a.length>1||x)&&/* @__PURE__ */ (0,f.jsxs)(`ul`,{className:Z.files,children:[w.map(e=>{let t=m.diffs(e),r=C(e.path);return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Z.file,children:[a.length>1&&/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.fileHead,"aria-expanded":s.has(e.path),onClick:()=>{c(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}),(o.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:pm.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":s.has(e.path)})]}),s.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?m.error?/* @__PURE__ */ (0,f.jsxs)(`div`,{role:`alert`,className:Z.diffStatus,children:[m.error,` `,/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,onClick:m.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:h,maxLines:1/0,className:Z.inlineDiff})]})]},e.path)}),a.length>3&&/* @__PURE__ */ (0,f.jsx)(`li`,{children:/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.more,"aria-expanded":l,onClick:()=>u(e=>!e),children:[T>0?n(`chat.showMoreFiles`,{count:T}):n(`chat.collapseFiles`),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.chevron,"data-open":l})]})})]})]})});function Wh(e){return e.flatMap(e=>e.kind===`text`?[e.text]:[]).join(``)}function Gh(e){return e.some(e=>e.kind===`reasoning`||e.kind===`tool-call`?!1:e.kind!==`text`||e.text.trim()!==``)}let Kh=`@deepseek-ai/dsh-client-ui-chat/TurnTailNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Kh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Kh,e.textContent=`.ONXMya_root{flex-direction:column;gap:16px;display:flex}.ONXMya_actions{margin-top:4px;margin-left:-6px}`,document.head.appendChild(e)}var qh={actions:`ONXMya_actions`,root:`ONXMya_root`};function Jh(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 Yh=(0,d.memo)(function({node:e,openFile:t,forkAt:n,loadTurnDiffs:r,renderSlot:i,t:a,useChat:o,useSession:s,useProjection:c}){let l=s(e=>e.openState===`open`),u=(0,d.useRef)(!1),[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(),_=e.data,v=o(e=>e.nodes),y=o(e=>(Jh(e,_.turn,!0)?.anchorSeq??-1)>(_.closing?.finalNode.seq??_.seq)),b=o(e=>{if(e.timeline.turnOrder.at(-1)!==_.turn)return!1;let t=Jh(e,_.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&&Gh([n])}),x=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,ee=wf(c,x?.turn,`end`);if(x===void 0)return null;let S=_.closing,C=i(`conversation.chat.turnTail`,{turn:x,seq:S?.finalNode.seq??_.seq,openFile:t});if(S===null)return C===null?null:/* @__PURE__ */ (0,f.jsx)(`div`,{className:qh.root,"data-turn-tail":_.turn,children:C});let w=S.finalNode.messageId,T=w===void 0?null:i(`conversation.chat.assistant-actions`,{messageId:w});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:qh.root,"data-turn-tail":_.turn,"data-actions-reveal":b?`always`:`hover`,children:[/* @__PURE__ */ (0,f.jsx)(Uh,{nodeStore:v,turn:_.turn,t:a,useProjection:c,loadTurnDiffs:r}),C,/* @__PURE__ */ (0,f.jsx)(Cf,{text:Wh(S.blocks),time:ee,clock:`end`,onBranch:()=>{!u.current&&l&&(u.current=!0,m(!0),g(void 0),n(_.seq).catch(e=>{g(e instanceof Error?e.message:String(e))}).finally(()=>{u.current=!1,m(!1)}))},branchUnavailable:!l||p||_.branchUnavailable||y,className:qh.actions,extraActions:T,t:a}),h!==void 0&&/* @__PURE__ */ (0,f.jsx)(`p`,{role:`alert`,children:a(`message.branchFailed`,{message:h})})]})});function Xh(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Zh(e,t){return typeof e[t]==`string`?e[t]:``}function Qh(e){let t=Xh(e.source),n=Zh(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=Zh(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 $h=`@deepseek-ai/dsh-client-ui-chat/TurnTriggerNodeView.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=`.u7aAgG_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){.u7aAgG_root:hover{background:var(--dsw-alias-turn-trigger-bg-hover,var(--dsw-alias-interactive-bg-hover))}}.u7aAgG_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){.u7aAgG_header:hover{color:var(--dsw-alias-label-secondary)}}.u7aAgG_header:active{color:var(--dsw-alias-label-secondary)}.u7aAgG_icon{color:inherit;flex:none;display:inline-flex}.u7aAgG_title{font-size:var(--dsh-content-font-size,14px);flex:none}.u7aAgG_time{color:inherit;font:var(--dsw-font-xxs-12);flex:none;margin-left:auto}.u7aAgG_chevron,.u7aAgG_openChevron{color:inherit;flex:none}.u7aAgG_openChevron{transform:rotate(180deg)}.u7aAgG_body{padding:0 16px 12px 40px}.u7aAgG_explanation{color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xxs-12);margin:8px 0}.u7aAgG_content{white-space:pre-wrap;overflow-wrap:anywhere;max-height:240px;font:var(--dsw-font-xxs-12);overflow:auto}@media (prefers-reduced-motion:reduce){.u7aAgG_root,.u7aAgG_header{transition:none}}`,document.head.appendChild(e)}var eg={body:`u7aAgG_body`,chevron:`u7aAgG_chevron`,content:`u7aAgG_content`,explanation:`u7aAgG_explanation`,header:`u7aAgG_header`,icon:`u7aAgG_icon`,openChevron:`u7aAgG_openChevron`,root:`u7aAgG_root`,time:`u7aAgG_time`,title:`u7aAgG_title`};let tg={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 ng({node:e,t}){let[n,r]=(0,d.useState)(!1),i=(0,d.useId)(),a=Qh(e.data),o=tg[a.icon],s=new Date(e.data.time),c=yf(e.data.time,t);return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:eg.root,"data-turn-trigger":!0,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{className:eg.header,type:`button`,"aria-expanded":n,"aria-controls":i,onClick:()=>{r(!n)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:eg.icon,"aria-hidden":!0,children:/* @__PURE__ */ (0,f.jsx)(o,{size:14})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:eg.title,children:t(a.title)}),/* @__PURE__ */ (0,f.jsx)(`time`,{className:eg.time,dateTime:s.toISOString(),children:c}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:12,className:n?eg.openChevron:eg.chevron})]}),n&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:i,className:eg.body,children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:eg.explanation,children:t(`message.trigger.explanation`)}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:eg.content,children:/* @__PURE__ */ (0,f.jsx)(af,{content:e.data.content,source:e.data.source,t})})]})]})}function rg(e,t){e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`user`,locale:dh,inject:()=>({links:e.get(`chatLinks`)})},Rf)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`steering`,locale:dh,inject:()=>({links:e.get(`chatLinks`)})},Rf)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`context`,locale:dh},Bf)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-trigger`,locale:dh},ng)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`system-prompt`,locale:dh},Lh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`assistant-step`,locale:dh,inject:()=>({hooks:{presentation:t}})},Dh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`command`,locale:dh,children:{"conversation.chat.commandview":{kind:`keyed`,scope:`session`}}},Ph)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`manual-compaction`,locale:dh},Fh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`compaction`,locale:dh},Vf)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`model-retry`,locale:dh},Hf)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-error`,locale:dh},Uf)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-max-tokens`,locale:dh},Wf)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-process`,locale:dh},Bh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-tail`,locale:dh,children:{"conversation.chat.turnTail":{kind:`list`,scope:`session`},"conversation.chat.assistant-actions":{kind:`list`,scope:`session`}}},Yh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`unknown`,locale:dh},Gf))}let ig={interruptedAssistant:-.9,interruptedFollowup:-.8,processControl:-.1,maxTokensNotice:.05,finalizedFollowup:.1};function ag(e){return e.start?.location??e.matches[0]?.location??{kind:`unresolved`}}function og(e,t,n,r,i={}){return{key:e.key,kind:t,id:e.id,target:`chat`,anchorSeq:n,location:i.location??ag(e),visibility:i.visibility??`visible`,data:r}}function sg(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function cg(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function lg(e,t,n){let r=e[t];if(!Array.isArray(r))return[];let i=[];for(let e of r){let t=sg(e),r=t===null?null:cg(t,n);r!==null&&!i.includes(r)&&i.push(r)}return i}function ug(e){return e.length>0?e.join(`, `):null}let dg=[`instructions`,`catalog`,`snapshot`,`notice`,`relay`,`recall`];function fg(e){let t=sg(e),n=t===null?null:cg(t,`form`);return n!==null&&dg.includes(n)?n:null}function pg(e){let t=sg(e),n=t===null?null:cg(t,`kind`);if(t===null||n===null)return{role:`inject`,label:null};switch(n){case`session-reference`:return{role:`recall`,label:ug(lg(t,`references`,`label`))??n};case`agent-instructions`:return{role:`inject`,label:ug(lg(t,`changes`,`path`))??n};case`skill-invocation`:return{role:`inject`,label:cg(t,`name`)??n};default:return{role:`inject`,label:n}}}function mg(e){let t=sg(e);return t===null||cg(t,`kind`)!==`session-reference`?[]:lg(t,`references`,`label`)}function hg(e){let t=sg(e);return t===null||cg(t,`kind`)!==`skill-invocation`?null:cg(t,`name`)}function gg(e){return e.map(_g)}function _g(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 vg(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 yg(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 bg(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 xg(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 Sg(e){return e.filter(e=>e!==void 0)}function Cg(e){return e===void 0||e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0}function wg(e){return e.some(Cg)}function Tg(e){return e.some(e=>e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function Eg(e){return{...xg(e.turn,e.step),firstTokenTime:e.firstTokenTime}}function Dg(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||!bg(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]=vg(t.blockType),s=Cg(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]=_g(t.block),s=Cg(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=bg(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 Og(e,t,n){let r=gg(n.data.message.content),i=r.map(Cg);return{...e,blocks:r,visibleByIndex:i,visibleBlocks:i.reduce((e,t)=>e+Number(t),0),final:t,usage:n.data.usage}}function kg(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 Ag(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:gg(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:kg(r);if(i===void 0)return;let a=Sg(e.blocks);if(Tg(a))return{kind:`assistant`,seq:i.seq+ig.interruptedAssistant,time:i.time,turn:e.turn,step:e.step,blocks:a,interrupted:!0}}function jg(e){let t;for(let n of e.matches)n.event.type===`assistant/live-chunk`?(t??=xg(n.event.data.turn,n.event.data.step),t=Dg(t,n.event.data.chunk,n.event.seq,n.event.time)):n.event.type===`assistant/message`?(t??=xg(n.event.data.turn,n.event.data.step),t=Og(t,n,n.event)):n.event.type===`llm/retry`&&t!==void 0&&(t=Eg(t));return t}function Mg(e){let t=e.state??jg(e);if(t===void 0)return;let n=Ag(t,e),r=n?.blocks??Sg(t.blocks),i=n===void 0?t.visibleBlocks>0:wg(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 Ng(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`step`?t.step.data.get(`assistant-step`):void 0}let Pg={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 xg(t.event.data.turn,t.event.data.step)},update:(e,t)=>t.event.type===`assistant/live-chunk`?Dg(e.state,t.event.data.chunk,t.event.seq,t.event.time):t.event.type===`assistant/message`?Og(e.state,t,t.event):t.event.type===`llm/retry`?Eg(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=Mg(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??jg(e),r=Ng(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:wg(r.blocks);return i===void 0&&!a&&t==null?null:og(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 Fg(e){let t=Pg.match.bind(Pg);e.uiConversation.events.register({...Pg,match:{"step/start":t,"assistant/live-chunk":t,"assistant/message":t,"llm/retry":t}})}function Ig(e){return`kind`in e}function Lg(e){return!Ig(e)}function Rg(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 zg(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 Bg(e){return e.kind===`user`?zg(e.data.content.flatMap(e=>e.type===`text`?[e.text]:[]),50):``}function Vg(e){return e.kind===`assistant-step`?zg(e.data.blocks.flatMap(e=>e.kind===`text`?[e.text]:[]),120):``}function Hg(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 Ug(e,t,n){let r=t.getTurn(e).map(e=>n.get(e)).filter(e=>e!==void 0&&Rg(e)),i=r.find(e=>e.kind===`user`),a=i??r[0];if(a===void 0)return;let o=r.findLast(e=>Vg(e)!==``);return{turn:e,anchorKey:a.key,prompt:i===void 0?``:Bg(i),response:o===void 0?``:Vg(o)}}function Wg(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function Gg(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 Kg(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&&Rg(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)),!(Kf.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 qg=class{presentations=/* @__PURE__ */ new Map;get(e){let t=Wg(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=Wg(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)?Kg(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,Kg(i,t,n))&&r.add(i);return r}set(e,t){return!Gg(this.presentations.get(e),t)&&(t===void 0?this.presentations.delete(e):this.presentations.set(e,t),!0)}};let Jg=[],Yg=[],Xg=[],Zg=[];function Qg(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function $g(e,t,n){let r=e.get(t);return r===void 0&&(r=n(),e.set(t,r)),r}var e_=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))}},t_=class{nodes=/* @__PURE__ */ new Map;current=Zg;dirty=!1;observable;source(){return this.observable??=new e_(()=>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}},n_=class{byKey=/* @__PURE__ */ new Map;turnProcesses=new qg;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=Zg;valuesDirty=!1;get(e){return this.byKey.get(e)}source(e){return $g(this.sources,e,()=>new e_(()=>this.get(e),`[ui-chat] node source ${e}`))}turnDataSource(e,t){return this.turnKind(e,t).source()}turnKind(e,t){return $g($g(this.turnKinds,e,()=>/* @__PURE__ */ new Map),t,()=>new t_)}updateTurnKind(e,t){let n=e===void 0?void 0:s_(e.location).turn,r=t===void 0?void 0:s_(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 $g(this.processSources,e,()=>new e_(()=>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()}},r_=class{turns=/* @__PURE__ */ new Map;steps=/* @__PURE__ */ new Map;positions=/* @__PURE__ */ new Map;getTurn(e){return this.turns.get(e)??Jg}getStep(e,t){return this.steps.get(o_(e,t))??Jg}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=s_(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=o_(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=i_(this.turns,n),this.steps=i_(this.steps,r),[...a]}touch(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let r of e){let e=s_(r.location);e.turn!==void 0&&this.turns.get(e.turn)?.includes(r.key)&&(t.add(e.turn),e.step!==void 0&&n.add(o_(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 i_(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)??Jg,a=t.get(i)??Jg,o=Qg(r,a)?r:a;a.length>0&&n.set(i,o)}return n}var a_=class{current=Xg;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=Ug(a,t,n);if(e===void 0)continue;let o=this.byTurn.get(a),s=o!==void 0&&Hg(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=Ug(r.turn,t,n);return i===void 0||Hg(r,i)?r:(this.byTurn.set(r.turn,i),i)});r.some((e,t)=>e!==this.current[t])&&(this.current=r)}};function o_(e,t){return`${e}:${t}`}function s_(e){return e.kind===`step`?{turn:e.turn.turn,step:e.step.step}:e.kind===`turn`?{turn:e.turn.turn}:{}}function c_(e){return e.kind===`turn`||e.kind===`step`?e.turn.status:void 0}function l_(e,t,n){return n||e===void 0||c_(e.location)!==c_(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 u_(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)}):Kf.has(e.kind)||t.set(r.turn.turn,{...i,earliestProcessAnchor:Math.min(i.earliestProcessAnchor??e.anchorSeq,e.anchorSeq)})}return t}function d_(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&&!Kf.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 f_(e){let t=e.filter(e=>Rg(e)),n=u_(t);return t.sort((e,t)=>{let r=d_(e,n),i=d_(t,n);return r.anchor-i.anchor||r.rank-i.rank||r.originalAnchor-i.originalAnchor||e.key.localeCompare(t.key)})}function p_(e){let t=e;return t.kind===`user`||t.kind===`steering`?t.data.seq:void 0}function m_(e){let t=e;if(t.kind===`context`)return{messageSeq:t.data.seq-1,labels:mg(t.data.source)}}function h_(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.referenceLabels??Jg,i=Object.hasOwn(n.data,`referenceLabels`);if(Qg(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 g_=class{messagesBySeq=/* @__PURE__ */ new Map;labelsByMessageSeq=/* @__PURE__ */ new Map;replace(e){this.messagesBySeq.clear(),this.labelsByMessageSeq.clear();for(let t of e){let e=p_(t);e!==void 0&&this.messagesBySeq.set(e,t.key);let n=m_(t);n!==void 0&&n.labels.length>0&&this.labelsByMessageSeq.set(n.messageSeq,n.labels)}return e.map(e=>{let t=p_(e);return t===void 0?e:h_(e,this.labelsByMessageSeq.get(t)??Jg)})}apply(e,t){let n=new Map(e.map(e=>[e.key,e])),r=/* @__PURE__ */ new Set;for(let t of e){let e=p_(t);e!==void 0&&(this.messagesBySeq.set(e,t.key),r.add(e));let n=m_(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&&Qg(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,h_(i,this.labelsByMessageSeq.get(e)??Jg))}return[...n.values()]}};function __(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.skillNames??Jg,i=Object.hasOwn(n.data,`skillNames`);if(Qg(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 v_(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=hg(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 y_(e,t){return e.seq===t.seq&&e.kind===t.kind&&e.name===t.name}var b_=class{entries=/* @__PURE__ */ new Map;sorted=[];replace(e){this.entries.clear(),this.sorted=[];for(let t of e){let e=v_(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=>__(e,t.get(e.key)??Jg))}apply(e,t){let n=[];for(let t of e){let e=v_(t),r=this.entries.get(t.key);if(r!==void 0){if(e!==null&&y_(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=__(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 x_={anchorSeq:0,nodes:Zg,partial:null,running:null};function S_(e){let t=e;if(e.visibility!==`visible`&&t.kind!==`assistant-step`)return x_;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:Zg,partial:{turn:n.turn,step:n.step,blocks:n.blocks},running:null}:x_:{anchorSeq:t.anchorSeq,nodes:n.finalNode===void 0?Zg:[n.finalNode],partial:null,running:null}}case`tool-call`:{let e=t.data.root;return Lg(e)?{anchorSeq:t.anchorSeq,nodes:Zg,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 x_;default:return x_}}function C_(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&&Qg(e.nodes,t.nodes)}var w_=class{contributions=/* @__PURE__ */ new Map;finalizedContributions=/* @__PURE__ */ new Map;runningContributions=/* @__PURE__ */ new Map;partialContributions=/* @__PURE__ */ new Map;finalized=Zg;runningCalls=Zg;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=S_(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=S_(t),a=this.contributions.get(t.key);C_(a,e)||(n||=E_(a,e),r||=D_(a,e),i||=O_(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){T_(this.finalizedContributions,e,t,t.nodes.length>0),T_(this.runningContributions,e,t,t.running!==null),T_(this.partialContributions,e,t,t.partial!==null)}rebuildFinalized(){let e=[...this.finalizedContributions.values()].flatMap(e=>e.nodes).sort((e,t)=>e.seq-t.seq);Qg(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]);Qg(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 T_(e,t,n,r){r?e.set(t,n):e.delete(t)}function E_(e,t){let n=e?.nodes??Zg;return!Qg(n,t.nodes)||(n.length>0||t.nodes.length>0)&&e?.anchorSeq!==t.anchorSeq}function D_(e,t){return e?.running!==t.running||(e.running!==null||t.running!==null)&&e.anchorSeq!==t.anchorSeq}function O_(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 k_=class{store=new n_;locations=new r_;navigation=new a_;legacy=new w_;referenceLabels=new g_;skillNames=new b_;order=Jg;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:Yg,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=f_(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||j_(t.location)!==j_(e.location);if(r||=o,o||i.push(e),l_(t,e,o)){let r=t===void 0?void 0:s_(t.location).turn,i=s_(e.location).turn;r!==void 0&&n.add(r),i!==void 0&&n.add(i)}}this.store.upsert(t);let o=Yg;if(r){let e=f_(this.store.values()).map(e=>e.key);this.order=Qg(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(A_(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??Yg,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(Zg,e)){return{order:this.order,nodes:this.store,locations:this.locations,navigation:this.navigation,timeline:e,legacy:t}}};function A_(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=s_(n.location).turn;e!==void 0&&t.add(e)}return t}function j_(e){let t=s_(e);return`${e.kind}:${t.turn??``}:${t.step??``}`}let M_={target:`chat`,create:()=>new k_,isActive:e=>e.order.some(t=>e.nodes.get(t)?.kind!==`command`)};function N_(e){e.uiConversation.views.register(M_)}let P_=/* @__PURE__ */ new Set([`system/message`,`developer/message`,`user/message`,`assistant/message`,`tool/result`]);function F_(e){return P_.has(e.type)?e.surfaceOp!==void 0:!1}function I_(e){return F_(e)&&e.surfaceOp===`append`}function L_(e){return F_(e)&&e.surfaceOp!==`append`}function R_(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 z_(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 B_(e){if(e.type!==`user/message`||!L_(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 V_(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 H_(e){let t=e.matches.find(e=>e.event.type===`command/done`),n=e.matches.find(e=>B_(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:z_(t)};let i=B_(n.event);return i?.sourceCommandId===void 0?t===void 0?void 0:{command:z_(t)}:{command:t===void 0?{kind:`command`,seq:n.event.seq,time:n.event.time,commandId:i.sourceCommandId,name:`compact`,args:null,outcome:null}:{...z_(t),name:`compact`},checkpoint:n,...r===void 0?{}:{summary:r}}}function U_(e,t){return t.event.type===`compaction/summary`?{...e,summary:t}:B_(t.event)===void 0?e:{...e,checkpoint:t}}let W_={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=B_(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:R_(t)}),update:(e,t)=>t.event.type===`command/done`?{...e.state,command:z_(t,e.state.command)}:U_(e.state,t),buildViewNode:e=>{let t=e.state??H_(e);if(t===void 0)return null;if(t.command.name!==`compact`)return og(e,`command`,t.command.seq,t.command);let n=t.checkpoint===void 0?null:V_(t.summary,t.checkpoint),r={command:t.command,compaction:n};return og(e,`manual-compaction`,n?.seq??t.command.seq,r)}};function G_(e){e.uiConversation.events.register(W_)}function K_(e){let t=e.matches.find(e=>e.event.type===`compaction/summary`),n=e.matches.find(e=>B_(e.event)!==void 0);return{...t===void 0?{}:{summary:t},...n===void 0?{}:{checkpoint:n}}}let q_={kind:`compaction`,target:`chat`,match:e=>{let t=B_(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)=>U_(e.state,t),buildViewNode:e=>{let t=e.state??K_(e);if(t.checkpoint===void 0)return null;let n=V_(t.summary,t.checkpoint);return og(e,`compaction`,n.seq,n)}};function J_(e){e.uiConversation.events.register(q_)}let Y_={kind:`unknown-surface`,target:`chat`,match:e=>e.type!==`assistant/live-chunk`&&I_(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:og(e,`unknown`,e.state.seq,e.state)};function X_(e){e.uiConversation.events.registerFallback(Y_)}let Z_={kind:`snapshot`,ids:[]},Q_=/* @__PURE__ */ new Set;function $_(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 ev(e,t){let n;for(let{id:r}of t)e.has(r)&&(n??=new Set(e),n.delete(r));return n??e}function tv(e,t,n){let r=e?.state.pending??Z_,i=t.inserted,a=t.removedCount??0;if(a>0&&t.outcome!==`canceled`){let e=$_(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=ev(e?.state.currentClaimed??Q_,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 nv(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 tv(r.previous(t),n.event.data,n.event.seq)},update:e=>e.state,publication:()=>`none`}}let rv=nv(`next-step`),iv=nv(`next-turn`);function av(e){e.uiConversation.events.register(rv),e.uiConversation.events.register(iv)}function ov(e){return e.type!==`user/message`||!L_(e)?!1:e.data.source.kind===`compact-checkpoint`}function sv(e,t){return{kind:`context`,seq:e.seq,time:e.time,content:t.content,source:t.source,producer:pg(t.source),form:fg(t.source)}}let cv={kind:`input-message`,target:`chat`,match:e=>e.type===`user/message`&&I_(e)&&!ov(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{...sv(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,...lv(e.state)}:e.state;return og(e,t?`turn-trigger`:e.state.kind,e.state.seq,n)}};function lv(e){let t=gd(e.content.flatMap(e=>e.type===`text`?[e.text]:[]).join(`
140
- `));return t.length===0?{}:{responseAnnotations:t}}let uv={...cv,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 sv(n,n.data.message)}};function dv(e){e.uiConversation.events.register(cv),e.uiConversation.events.register(uv)}function fv(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 pv(e,t,n,r){let i=e.current.get(`chat`);return i?.kind===`system-prompt`?i.anchorSeq:fv(t,n,r)}function mv(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:og(e,`system-prompt`,t.update?t.seq:fv(e.start,void 0,!0),{text:t.text,...t.update?{update:!0}:{}})}}}function hv(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:pv(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:og(e,`system-prompt`,t.anchorSeq,{text:t.prompt.system},{visibility:r?`visible`:`hidden`})}}}function gv(e){e.uiConversation.events.register(mv((t,n)=>e.uiConversation.inspectSystemPrompt(t,n))),e.uiConversation.events.register(hv((t,n,r)=>e.uiConversation.inspectRequestPrompt(t,n,r)))}function _v(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 vv(e){return e.kind===`step`&&e.step.status===`closed`||(e.kind===`step`||e.kind===`turn`)&&e.turn.status===`closed`}let yv={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=_v(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=_v(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`&&vv(t)?{...e,retryState:`cancelled`}:e),i=r.at(-1);if(i===void 0)return null;let a={attempts:r,current:i};return og(e,`model-retry`,r[0]?.seq??i.seq,a)}};function bv(e){e.uiConversation.events.register(yv)}let xv=/* @__PURE__ */ new WeakMap;function Sv(e){return JSON.stringify(e)}function Cv(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?pp.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 wv(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 pp;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 Tv(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 Ev(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??pp.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 Dv(e,t){return{phase:`start`,callId:t.subCallId,parentCallId:t.parentCallId,name:t.name,argsRaw:Sv(t.arguments),args:pp.fromObject(t.arguments),turn:kv(e),step:Av(e),time:e.event.time,subCalls:[]}}function Ov(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:pp.fromObject(t.arguments),call:{name:t.name,argsRaw:Sv(t.arguments)},callTime:n?.time??null,content:t.content??[],isError:t.isError===!0,...t.error===void 0?{}:{error:t.error},subCalls:[]}}function kv(e){return e.location.kind===`step`||e.location.kind===`turn`?e.location.turn.turn:0}function Av(e){return e.location.kind===`step`?e.location.step.step:0}function jv(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 Mv(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||!jv(e,i,a))return e;let n=new Map(e.children);n.set(i,[...o,Dv(t,r)]);let c=new Map(e.parents);return c.set(a,i),{...e,children:n,parents:c}}if(s<0&&!jv(e,i,a))return e;let c=Ov(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 Nv(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=>Nv(e,t,n,a,i+1)),s=`kind`in e?void 0:n?.seq,c=`kind`in e?void 0:n?.time,l=xv.get(e);if(l!==void 0&&l.interruptionSeq===s&&l.interruptionTime===c&&Pv(l.children,o))return l.value;let u=`kind`in e||n===void 0?Pv(e.subCalls,o)?e:{...e,subCalls:o}:{kind:`tool-result`,seq:n.seq+ig.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 xv.set(e,{children:o,interruptionSeq:s,interruptionTime:c,value:u}),u}function Pv(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Fv(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 Iv(e){let t=e.matches.find(e=>e.event.type===`tool/result`),n=t===void 0?void 0:Ev(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=Mv(r,t);return r}let Lv={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`&&I_(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:Cv(t)}:wv(n,t)},update:(e,t)=>{if(t.event.type===`assistant/live-chunk`)return wv(e.state,t);if(t.event.type===`tool/call`)return{...e.state,root:Cv(t,e.state.root)};if(t.event.type===`tool/result`){let n=e.state.root,r=Ev(t,n!==void 0&&!(`kind`in n)&&n.phase===`start`?n:void 0);return r===void 0?e.state:{...e.state,root:r}}return Mv(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??Iv(e);if(n?.root===void 0)return t==null?null:t.visibility===`hidden`?t:{...t,visibility:`hidden`};let r=Fv(e),i=Nv(!(`kind`in n.root)&&n.root.phase===`preparing`?Tv(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=ag(e),c=Yf(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:og(e,`tool-call`,a,l,{visibility:o,location:c})}};function Rv(e){let t=Lv.match.bind(Lv);e.uiConversation.events.register({...Lv,match:{"assistant/live-chunk":t,"tool/call":t,"tool/result":t,"tool/ptc-dispatch-start":t,"tool/ptc-dispatch":t}})}function zv(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 Bv(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=yg(n);return{seq:e.event.seq,time:e.event.time,message:r.message,...r.code===void 0?{}:{code:r.code}}}function Vv(e){let t=e.matches.find(e=>Bv(e)!==void 0);if(t?.event.type!==`turn/end`)return;let n=Bv(t);if(n!==void 0)return{turn:t.event.data.turn,failure:n}}let Hv={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=Bv(t);return n===void 0?e.state:{...e.state,failure:n}},buildViewNode:e=>{let t=e.state??Vv(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:zv(e),message:n.message,...n.code===void 0?{}:{code:n.code}};return og(e,`turn-error`,r.seq,r)}};function Uv(e){e.uiConversation.events.register(Hv)}function Wv(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 Gv(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+ig.maxTokensNotice}function Kv(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 qv={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=Kv(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:Wv(e)};return og(e,`turn-max-tokens`,Gv(e,t.seq),n)}};function Jv(e){e.uiConversation.events.register(qv)}function Yv(e){let t=e.data;return typeof t.turn==`number`?t.turn:void 0}function Xv(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 Zv(e){return e.type===`assistant/live-chunk`?Xv(e.data.chunk):e.type!==`assistant/attempt`&&e.type===`assistant/message`&&e.surfaceOp===`append`&&gg(e.data.message.content).some(e=>e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function Qv(e,t){return e.type===`tool/call`?Yf(e.data.name):e.type===`tool/result`&&t.has(String(e.data.message.source.callId))}function $v(e,t){if(Zv(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(!Qv(e,t)&&(e.type===`tool/call`||e.type===`tool/result`&&e.surfaceOp===`append`||e.type===`llm/retry`))return{kind:`other`,seq:e.seq}}function ey(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function ty(e){let t=e.matches.map(e=>Yv(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=ay(n,t.event);return n}function ny(e){return e?.finalNode!==void 0}function ry(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!ny(n)||n.finalNode.interrupted===!0||!Gh(n.blocks)||t===void 0&&n.blocks.some(e=>e.kind===`tool-call`)?null:n}function iy(e,t){let n=e.controlAnchorSeq??t.start?.seq;if(n===void 0)return null;let r=ry(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 ay(e,t){let n=e;if(t.type===`assistant/message`&&t.surfaceOp===`append`&&Gh(gg(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(Yf(t.data.name)){let e=new Set(n.contextCompactionCalls);e.add(String(t.data.callId)),n={...n,contextCompactionCalls:e}}else{let e=Jf(t.data.name);n={...n,toolCallCount:n.toolCallCount+ +!e,subagentCount:n.subagentCount+ +!!e}}}let r=$v(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 oy={kind:`turn-process`,target:`chat`,match:e=>{if(e.type===`turn/start`)return{id:String(e.data.turn),role:`start`};let t=Yv(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)=>ay(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??ty(e);if(r===void 0)return null;let i=ey(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=iy(r,i);return s===null?null:n?.kind===`turn`&&n.turn===s.turn&&n.key===`turn-process`&&qf(n.value,s)?n:{kind:`turn`,turn:i.turn,key:`turn-process`,value:s}},buildViewNode:e=>{let t=ey(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:og(e,`turn-process`,n.controlAnchorSeq+ig.processControl,n)}};function sy(e){let t=oy.match.bind(oy);e.uiConversation.events.register({...oy,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 cy(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 ly(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function uy(e){let t=0;for(let n of e)if(t+=n,!Number.isSafeInteger(t))return;return t}function dy(e){let{provider:t,model:n}=e.source;return t.length>0&&n.length>0?{provider:t,model:n}:void 0}function fy(e){return cy(e,`usage`)?.usage}function py(e,t){let{inputTokens:n,outputTokens:r,cacheReadTokens:i,cacheWriteTokens:a,reasoningTokens:o,totalTokens:s}=e;if(!ly(n)||!ly(r)||i!==void 0&&!ly(i)||a!==void 0&&!ly(a)||o!==void 0&&(!ly(o)||o>r))return;let c=uy([n,...i===void 0?[]:[i],...a===void 0?[]:[a]]);if(c===void 0)return;let l;if(s!==void 0){if(!ly(s))return;let e=s-r;if(!ly(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=uy([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 my(e){if(e.length===0)return;let t=uy(e.map(e=>e.inputTokens)),n=uy(e.map(e=>e.outputTokens)),r=uy(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(ly)?uy(i):void 0,c=a.every(ly)?uy(a):void 0,l=o.every(ly)?uy(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 hy(e,t,n){return e.turn===t&&e.step===n}function gy(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=py(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`||!hy(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`||!hy(t,n.data.turn,n.data.step)){a=!0;continue}let e=fy(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`||!hy(t,n.data.turn,n.data.step)){a=!0;continue}let e=n.data.usage??fy(n.data.stream);e!==void 0&&(t={...t,sample:e}),o(dy(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`||!hy(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`||!hy(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:my(n)}function _y(e){return e.type!==`assistant/live-chunk`}function vy(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 yy(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function by(e){return e.finalNode!==void 0&&e.blocks.some(e=>e.kind===`text`&&e.text.trim()!==``)}function xy(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=yy(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(by)??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`?gy(e.matches.map(e=>e.event).filter(_y)):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 Sy={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=vy(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=xy(e);return n===null?null:{kind:`turn`,turn:n.turn,key:`turn-tail`,value:n}},buildViewNode:e=>{let t=yy(e)?.data.get(`turn-tail`);return t===void 0?null:og(e,`turn-tail`,t.seq+ig.finalizedFollowup,t)}};function Cy(e){let t=Sy.match.bind(Sy);e.uiConversation.events.register({...Sy,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 wy(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 Ty=new Intl.Segmenter(void 0,{granularity:`grapheme`}),Ey=[`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 Dy(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=160)return{text:t,truncated:!1};let n=[];for(let{segment:e}of Ty.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 Oy(e){return Dy(typeof e==`string`?e:Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(`, `):``).text}function ky(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=Dy(r);if(a.truncated||!e.stringExceeds(t,n))return a.text;n*=2}}function Ay(e){if(!Array.isArray(e))return``;for(let t of e){if(typeof t!=`object`||!t)continue;let e=Oy(Reflect.get(t,`question`));if(e!==``)return e}return``}function jy(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=Oy(r[e]?.replaceAll(`**`,``));if(t!==``)return t}}}return``}function My(e,t){for(let e of Ey){if(!t.has(e))continue;let n=e===`questions`?Ay(t.value(e)):ky(t,e)??Oy(t.value(e));if(n!==``)return n}return t.closed()?Oy(e):``}function Ny(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=Lg(e)?e:e.call;if(c!==null){let n=wy(c.name);Lg(e)&&e.time>=a&&(r=n,o=e.phase===`preparing`,i=My(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=jy(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 Py=/* @__PURE__ */ new Set([`user`,`steering`,`turn-trigger`,`model-retry`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function Fy(e){let t=e.location;return t.kind===`turn`||t.kind===`step`?t.turn.turn:void 0}function Iy(e){return Py.has(e.kind)||e.kind===`tool-call`&&Yf(e.data.root.name)}function Ly(e){return e.kind===`assistant-step`&&e.data.blocks.some(e=>e.kind===`reasoning`&&e.text.trim()!==``)}function Ry(e){return e.kind===`assistant-step`&&Gh(e.data.blocks)}function zy(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 By(e,t){return e.length===t.length&&e.every((e,n)=>e.key===t[n]?.key&&e.groupPart===t[n].groupPart)}function Vy(e,t){return!Rg(t)&&(e===void 0||!Rg(e))?!1:e===void 0||e.kind!==t.kind||Fy(e)!==Fy(t)||Rg(e)!==Rg(t)||Ly(e)!==Ly(t)||Ry(e)!==Ry(t)}function Hy(e,t){let n=e.readNode(t);if(n===void 0)throw Error(`Chat grouping input is missing Node ${t}`);return n}function Uy(e,t){let n=/* @__PURE__ */ new Set;for(let r of t){let t=Hy(e,r);t.kind===`question-reply`&&n.add(t.id)}return n}var Wy=class{key;turn;members;nodes=[];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:``}}}}refresh(e,t){let n=this.members.map(t=>Hy(e,t.key)),r=n.length===this.nodes.length&&n.every((e,t)=>e===this.nodes[t]),i=this.snapshot.data,a=r&&i.closed===t?i.summary:Ny(n),o=t?{counts:a.counts,running:void 0,runningDetail:``}:a;this.nodes=n,(i.closed!==t||!zy(i.summary,o))&&(this.snapshot={key:this.key,members:this.members,data:{turn:this.turn,closed:t,summary:o}})}},Gy=class{turn;groups=/* @__PURE__ */ new Map;membership=/* @__PURE__ */ new Map;roots=/* @__PURE__ */ new Map;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===`closed`;if(r)for(let e of this.groups.values())e.snapshot.data.closed||n.add(e.key);let i=[];for(let t of n){let n=this.groups.get(t),a=n.snapshot;n.refresh(e,a.data.closed||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,t)=>{n.set(e,[...n.get(e)??[],t])},c=n=>{let c=a[0];if(c===void 0)return;let l=this.extendedGroup(a,t)?.key??hm(JSON.stringify([`process`,c.key,c.groupPart??null])),u=this.groups.get(l),d=u?.snapshot,f=u!==void 0&&By(u.members,a)?u:new Wy(l,this.turn,a);f.refresh(e,n||e.timeline.turns.get(this.turn)?.status===`closed`),r.set(f.key,f),s(c.key,{kind:`group`,key:f.key});for(let e of a)i.set(e.key,f.key);f.snapshot!==d&&o.push(f.snapshot),a=[]},l,u=!1,d=e.readTurn(this.turn),f=Uy(e,d);for(let t of d){let n=Ky(e,t);l!==void 0&&n.previous!==l&&c(!0),l=t,u=n.next!==void 0;let r=Hy(e,t);r.kind===`turn-trigger`&&f.has(r.id)||(Iy(r)?(c(!0),s(t,{kind:`node`,key:t})):r.kind===`turn-process`?s(a[0]?.key??t,{kind:`node`,key:t}):r.kind===`assistant-step`?(Ly(r)&&a.push({kind:`node`,key:t,groupPart:`reasoning`}),Ry(r)&&(c(!0),s(t,{kind:`node`,key:t,groupPart:`response`}))):a.push({kind:`node`,key:t}))}c(u);let p=[...this.groups.keys()].filter(e=>!r.has(e));return this.groups=r,this.membership=i,this.roots=n,{upserts:o,removes:p}}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 Ky(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 qy=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=Ky(e,t).turn;if(i===void 0||r.has(i))continue;let a=this.turns.get(i)??new Gy(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=Fy(a);if((e===void 0||!Rg(e))&&n.add(a.key),Vy(e,a)){let n=e===void 0?void 0:Fy(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 Gy(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=Uy(e,e.order.filter(t=>Ky(e,t).turn===void 0));return e.order.flatMap(n=>{let r=Ky(e,n).turn;if(r===void 0){let r=Hy(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 Jy={kind:`process-groups`,target:`chat`,create:()=>new qy,update:(e,t)=>(e.state.accept(t),e.state),buildGroups:e=>e.state.output()};function Yy(e){av(e),dv(e),gv(e),Fg(e),sy(e),Rv(e),G_(e),J_(e),bv(e),Uv(e),Jv(e),Cy(e),X_(e),N_(e),e.uiConversation.groups.register(Jy)}function Xy({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 Zy(e){return e==null}function Qy(e){return e&&typeof e==`object`&&!Array.isArray(e)}function $y(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function eb(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function tb(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 nb=Symbol.for(`cosmokit.volatile.write`);function rb(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=>rb(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,rb(n,t)])))}finally{t.delete(e)}}function ib(e){let t=rb(e);return Object.freeze({get:()=>t,[nb]:e=>{t=e}})}function ab(e){return typeof e==`object`&&!!e&&nb in e}function ob(e,t){return arguments.length===1?t=>ob(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function sb(e){return ob(`ArrayBuffer`,e)||ob(`SharedArrayBuffer`,e)}function cb(e){return sb(e)||ArrayBuffer.isView(e)}let lb;(function(e){e.is=sb,e.isSource=cb;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})(lb||={}),lb.fromBase64,lb.toBase64,lb.fromHex,lb.toHex;function ub(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(ob(`Date`,e))return new Date(e.valueOf());if(ob(`RegExp`,e))return new RegExp(e.source,e.flags);if(sb(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(ub,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(ub,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function db(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(ab(e)||ab(t))return ab(e)&&ab(t);if(!n&&Zy(e)&&Zy(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(ob(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(ob(`URL`),(e,t)=>e.href===t.href)??a(ob(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(sb,(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 fb;(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})(fb||={});let pb=Symbol.for(`schemastery`),mb=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?.[mb]}};Object.defineProperty(Q.prototype,mb,{value:!0});let $=function(e){let t=function(e,n={}){return $.resolve(e,t,n)[0]};if(e.refs){let t=eb(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&&eb(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[pb]=!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 hb(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 gb(e){return e?.$value??e?.$inner}function _b(e){return $y(e??{},e=>!e.startsWith(`$`))}$.prototype.i18n=function(e){let t=$(this),n=hb(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=eb(t.dict,(t,n)=>t.i18n(eb(e,e=>gb(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(eb(e,(e={})=>Array.isArray(gb(e))?gb(e)[n]:Array.isArray(e)?e[n]:_b(e)))),t.inner&&=t.inner.i18n(eb(e,e=>gb(e)?gb(e):_b(e))),t.sKey&&=t.sKey.i18n(eb(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=tb(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},$.prototype.simplify=function(e){if(ab(e)&&(e=e.get()),db(e,this.meta.default,this.type===`dict`))return null;if(Zy(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`||!Zy(r))&&(t[n]=r)}return db(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 Eb[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 vb={},yb=Symbol(`checked-volatile-schema`);function bb(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))bb(i,[...t,n],a,r);if(e.sKey&&bb(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[pb])&&bb(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)bb(e.list[n],[...t,String(n)],!0,r)}$.extend=function(e,t){vb[e]=t},$.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[yb]||(bb(t,n.path),n={...n,[yb]:!0}),t.meta?.volatile){let i=$(t);i.meta={...t.meta,volatile:!1};let[a,o]=$.resolve(e,i,n,r);try{return[ib(a),o]}catch(e){throw new Q(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(Zy(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`&&Zy(i);)r=r.list[0],i=r?.meta.default;if(Zy(i))return[e];e=ub(i)}let i=vb[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(Zy(e))return $.any();if([`string`,`number`,`boolean`].includes(typeof e))return $.const(e).required();if(e[pb])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[pb]||(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(lb.isSource(e))return lb.fromSource(e);throw new Q(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[$.transform($.string(),(t,n)=>{try{return e===`base64`?lb.fromBase64(t):lb.fromHex(t)}catch(e){throw new Q(e.message,n)}},!0)]:[]])},$.extend(`lazy`,(e,t,n,r)=>(t.inner[pb]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},bb(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(db(e,t))return[t];throw new Q(`expected ${t} but got ${e}`,n)});function xb(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 xb(e.length,t,`string length`,n),[e]});function Sb(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 Cb(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(Sb(e,i)-Sb(t,i))%Sb(n,i)===0}$.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new Q(`expected number but got ${e}`,n);xb(e,t,`number`,n);let{step:r}=t;if(r&&!Cb(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(Zy(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 wb(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?ib(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 xb(e.length,n,`array length`,r,!Zy(t.meta.default)),[e.map((n,i)=>wb(e,i,t,r))]}),$.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!Qy(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]=wb(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)=>wb(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function Tb(e,t){for(let n in t)n in e||(e[n]=t[n])}$.extend(`object`,(e,{dict:t},n,r)=>{if(!Qy(e))throw new Q(`expected object but got ${e}`,n);let i={};for(let r in t){let a=wb(e,r,t[r],n);(!Zy(a)||r in e)&&(i[r]=a)}return r||Tb(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(!Zy(t)){if(Zy(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`)Tb(a??={},t);else if(a!==t)throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&Qy(e)&&Tb(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 Eb={};function Db(e,t,n){Eb[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=eb(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}})}Db(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),Db(`any`,[],()=>`any`),Db(`never`,[],()=>`never`),Db(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),Db(`string`,[],()=>`string`),Db(`number`,[],()=>`number`),Db(`boolean`,[],()=>`boolean`),Db(`bitset`,[`bits`],()=>`bitset`),Db(`function`,[],()=>`function`),Db(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),Db(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),Db(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),Db(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),Db(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),Db(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),Db(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let Ob=`transcriptView`,kb=[`compact`,`standard`,`detailed`,`verbose`],Ab=[...kb,`normal`,`expanded`],jb=`standard`,Mb={linkOpening:$.union([`sidebar`,`new-tab`]).default(`sidebar`),[Ob]:$.union([...Ab]).loose()};$.object(Mb);let Nb=`@deepseek-ai/dsh-client-ui-chat/PreferenceRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Nb)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Nb,e.textContent=`.Zxrp0W_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.Zxrp0W_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.Zxrp0W_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.Zxrp0W_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.Zxrp0W_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}.Zxrp0W_selector:active{background:var(--dsw-alias-interactive-bg-active)}.Zxrp0W_chevron{flex:none}@media (hover:hover) and (pointer:fine){.Zxrp0W_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}}@media (width<=640px){.Zxrp0W_row{gap:12px;min-height:44px;padding:12px 0}.Zxrp0W_rowText{padding-right:0}.Zxrp0W_selector{gap:8px;height:44px;min-height:44px;padding:0 12px;font-size:13.5px}}`,document.head.appendChild(e)}var Pb={chevron:`Zxrp0W_chevron`,desc:`Zxrp0W_desc`,row:`Zxrp0W_row`,rowText:`Zxrp0W_rowText`,selector:`Zxrp0W_selector`,title:`Zxrp0W_title`};function Fb({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:Pb.selector,"aria-haspopup":`menu`,"aria-expanded":o,onClick:()=>{s(e=>!e)},children:[r,/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:Pb.chevron})]});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Pb.row,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Pb.rowText,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Pb.title,children:e}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:Pb.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 Ib={compact:`settings.transcript.compact`,standard:`settings.transcript.standard`,detailed:`settings.transcript.detailed`,verbose:`settings.transcript.verbose`};function Lb({useTranscriptView:e,setTranscriptView:t,t:n}){let r=e(e=>e);return/* @__PURE__ */ (0,f.jsx)(Fb,{title:n(`settings.transcript.title`),description:n(`settings.transcript.description`),value:r,selectedLabel:n(Ib[r]),options:kb.map(e=>({id:e,label:n(Ib[e])})),onSelect:e=>{t(e)}})}var Rb=class{host;defaultMode;unsubscribe;mode;constructor(e,t=jb){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(Ob,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 zb={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 Bb(e){return{getSnapshot:()=>zb[e.getSnapshot()],subscribe:t=>e.subscribe(t)}}function Vb({useLinkOpening:e,useBrowserAvailable:t,setLinkOpening:n,t:r}){let i=e(e=>e);return t(e=>e)?/* @__PURE__ */ (0,f.jsx)(Fb,{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 Hb={getSnapshot:()=>void 0,subscribe:()=>()=>{}};function Ub(e,t){let n=e?.source(t)??Hb;return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let Wb={hooks:{turnData:(e,{turnData:t})=>function(e){return Ub(t,e)},disclosure:(e,{disclosureReset:t})=>vp(t)}},Gb=[`slots`,`sessions`,`uiWorkspace`,`uiSession`,`uiConversation`,`locale`,`configForms`,`remote`,`remote.session`,`remote.workspaceFiles`,`sidebarRight`];function Kb(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()??fe,subscribe:e=>l.subscribe(e)},i.set(o,s)}return s};Yy(e),e.uiSession.provide({hooks:[`chat`],resolve:e=>({hooks:{chat:o(e)}})}),e.effect(()=>e.locale.register(dh,{zh:fh,en:ph}),`ui-chat: dictionaries`);let s=e.locale.bind(dh),c=Qf(),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:dh,inject:()=>({hooks:{linkOpening:d,browserAvailable:f},setLinkOpening:e=>{d.set(e),u.set(`linkOpening`,e).catch(()=>{})}})},Vb))});let h=new Rb(u,`dshDesktop`in globalThis?`standard`:jb),g=Bb(h.mode);e.effect(()=>()=>{h.dispose()}),rg(e,g),e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`transcript-view`,order:12,locale:dh,inject:()=>({hooks:{transcriptView:h.mode},setTranscriptView:e=>{h.setMode(e)}})},Lb)),e.slots.inject(`conversation.view`,()=>e.slots.register({name:`conversation.view`,id:`chat`,order:0,label:()=>s(`view.chat`),locale:dh,children:{"conversation.chat.node":{kind:`keyed`,scope:`session`,inject:Wb},"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`);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=ae(i,n);if(!r.reveal||!ie(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({path:a,...r.reveal?{action:`reveal`}:{}});if(!o.ok)throw Error(o.error.message);return}let a=oe(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)})}}}},lh)),e.slots.inject(`shell.overlay`,()=>e.slots.register({name:`shell.overlay`,id:`chat.quota-notice`,locale:dh,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)}}})},Xy)),e.slots.inject(`conversation.input.dock`,()=>e.slots.register({name:`conversation.input.dock`,id:`file-changes`,order:5,locale:dh},E)),e.slots.inject(`conversation.approval.detail`,()=>e.slots.register({name:`conversation.approval.detail`},me))}return n.EMPTY_CHAT_SNAPSHOT=fe,n.apply=Kb,n.inject=Gb,n.isRunningTool=Lg,n.isSettledTool=Ig,t.exports}});
138
+ `,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 Eh=(0,d.memo)(function({text:e,running:t,usePresentation:n,useDisclosure:r,t:i}){let{expanded:a,toggle:o}=r(),s=(0,d.useMemo)(()=>Rd(i),[i]),c=t?Th(e):wh(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:Sh.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Sh.summary,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:Sh.summaryText,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{children:l})})})]}),[t,l]),h=(0,d.useMemo)(()=>a?/* @__PURE__ */ (0,f.jsx)(`div`,{className:Sh.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:Sh.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:bm.visuallyHidden,children:i(`row.running`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{rowClassName:Sh.row,leadingClassName:Sh.leading,titleClassName:Sh.title,icon:Ch,title:i(`message.think`),running:t,open:a,expandable:!0,expandOnRowClick:!0,onToggle:o,collapsedContent:m,children:h})]})}),Dh=`@deepseek-ai/dsh-client-ui-chat/AssistantMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Dh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Dh,e.textContent=`.UoIYma_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}.UoIYma_body{flex-direction:column;gap:16px;display:flex}.UoIYma_viewedImages{flex-direction:column;align-items:flex-start;gap:10px;display:flex}.UoIYma_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}.UoIYma_viewedImagesToggle:hover{color:var(--dsw-alias-label-secondary)}.UoIYma_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)}.UoIYma_viewedImagesIcon{flex:none;width:16px;height:16px;position:relative}.UoIYma_viewedImagesIcon:before,.UoIYma_viewedImagesIcon:after{content:"";border:1px solid;border-radius:3px;width:11px;height:9px;position:absolute}.UoIYma_viewedImagesIcon:before{top:2px;left:2px}.UoIYma_viewedImagesIcon:after{top:5px;left:5px}.UoIYma_viewedImagesChevron{flex:none;width:12px;height:12px}.UoIYma_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)}.UoIYma_body .md-table-wide>table{z-index:1;position:relative}.UoIYma_body>[data-turn-process-inline][hidden]{margin-bottom:-16px}.UoIYma_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}.UoIYma_actions{margin-top:16px;margin-left:-6px}`,document.head.appendChild(e)}var Oh={actions:`UoIYma_actions`,body:`UoIYma_body`,root:`UoIYma_root`,stopped:`UoIYma_stopped`,viewedImages:`UoIYma_viewedImages`,viewedImagesChevron:`UoIYma_viewedImagesChevron`,viewedImagesIcon:`UoIYma_viewedImagesIcon`,viewedImagesToggle:`UoIYma_viewedImagesToggle`};function kh({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:Oh.viewedImages,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Oh.viewedImagesToggle,"aria-expanded":r,onClick:()=>{i(e=>!e)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Oh.viewedImagesIcon,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:a}),r?/* @__PURE__ */ (0,f.jsx)(p.IconChevronUpOutlineRegular,{className:Oh.viewedImagesChevron}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:Oh.viewedImagesChevron})]}),r&&t({images:e,align:`start`})]})}function Ah(e,t,n){let r;try{r=decodeURIComponent(t.split(/[?#]/u)[0]??``)}catch{return}return n===void 0?se(e,r):n(r)}let jh=(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)(()=>Rd(m),[m]),{fileImages:g}=(0,p.useMarkdownDelegate)(),_=(0,d.useMemo)(()=>({resolve:e=>Ah(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,labels:h,fileMentions:l,pathImages:_,responseAnnotations:u},n));break;case`reasoning`:y.push(/* @__PURE__ */ (0,f.jsx)(Mh,{hidden:o,reveal:c,children:/* @__PURE__ */ (0,f.jsx)(Eh,{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)(kh,{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:Oh.root,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Oh.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:Oh.stopped,children:m(`message.stopped`)})]})})});function Mh({hidden:e,reveal:t,children:n}){let r=op(e,t??Nh);return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:r,"data-turn-process-inline":e||void 0,children:n})}let Nh=()=>{};function Ph(e,t){for(let n=e;n!==null&&n!==t;n=n.parentElement)if(n.classList.contains(Xm.annotationMark))return!0;return!1}function Fh(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(Nm)===null&&!Ph(t,e)&&(n=r)}return n}function Ih(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(Nm)!=null)return;let r=Fh(e);if(r===null)return;let i=n.cloneRange();i.setEnd(r,r.data.length),t.removeAllRanges(),t.addRange(i)}let Lh=(0,d.memo)(function({node:e,groupPart:t,useDisclosure:n,useTurnData:r,turnProcess:i,openFile:a,renderMessageImages:o,fileMentions:s,responseAnnotations:c,useInput:l,usePresentation:u,t:p}){let m=e.data,h=(0,d.useRef)(null),g=JSON.stringify([e.key,t??null]),_=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,v=r(`turn-tail`),y=(0,d.useMemo)(()=>{if(_?.status===`closed`&&m.finalNode!==void 0&&v?.closing?.finalNode.seq===m.finalNode.seq)return{turn:_,seq:m.finalNode.seq,openFile:a}},[m.finalNode,a,v,_]),b=(0,d.useMemo)(()=>y===void 0?void 0:s(y),[s,y]),x=i!==void 0&&i.foldable&&i.spec.answerStep===m.step&&i.spec.inlineReasoning&&!i.open,ee=(0,d.useCallback)(()=>{i?.setOpen(!0)},[i]),S=(0,d.useMemo)(()=>zd(p),[p]),C=(0,d.useMemo)(()=>({labels:S,resolve:e=>c[e-1]}),[S,c]),w=(0,d.useCallback)(e=>{e.detail>=2&&h.current!==null&&Ih(h.current)},[]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:h,className:Xm.answer,"data-selection-answer":g,"data-selection-answer-streaming":m.status===`running`||void 0,onClick:w,children:[/* @__PURE__ */ (0,f.jsx)(jh,{blocks:m.blocks,groupPart:t,useDisclosure:n,streaming:m.status===`running`,interrupted:m.status===`interrupted`,renderMessageImages:o,reasoningHidden:x,usePresentation:u,revealProcess:ee,mentions:b,responseAnnotations:C,t:p}),m.status!==`running`&&/* @__PURE__ */ (0,f.jsx)(th,{answer:h,answerKey:g,useInput:l,labels:S})]})}),Rh=`@deepseek-ai/dsh-client-ui-chat/GenericCommandCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Rh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Rh,e.textContent=`.hIxFiG_root{flex-direction:column;display:flex}.hIxFiG_leading{flex-shrink:0}.hIxFiG_title{font-weight:400}.hIxFiG_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.hIxFiG_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}.hIxFiG_summary[data-error],.hIxFiG_body[data-error]{color:var(--dsw-alias-state-error-primary)}.hIxFiG_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 zh={body:`hIxFiG_body`,leading:`hIxFiG_leading`,root:`hIxFiG_root`,separator:`hIxFiG_separator`,summary:`hIxFiG_summary`,title:`hIxFiG_title`};let Bh=/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{size:14});function Vh(e){return e===null?`running`:e.kind===`error`?`error`:`ok`}let Hh=(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=Vh(e.outcome),u=l===`running`,m=o!==void 0&&o.includes(`
139
+ `)?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:zh.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:zh.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:zh.body,"data-error":l===`error`||void 0,children:m}):void 0,[m,h,l]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:zh.root,"data-variant":`others`,"data-command":e.name??void 0,"data-state":l,children:[l===`running`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:bm.visuallyHidden,children:t(`row.running`)}),l===`error`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:bm.visuallyHidden,children:t(`row.failed`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{leadingClassName:zh.leading,titleClassName:zh.title,icon:Bh,title:c,running:u,open:h,expandable:m!==null,expandOnRowClick:!0,keepContentWhenOpen:!0,onToggle:g,collapsedContent:_,children:v})]})});function Uh({node:e,compaction:t,t:n}){return t===void 0?/* @__PURE__ */ (0,f.jsx)(Hh,{node:e,t:n,runningSummary:n(`message.compaction.running`),successSummary:n(`message.compaction`)}):/* @__PURE__ */ (0,f.jsx)(Kd,{node:t,title:n(`message.compaction.commandTitle`),fallbackSummary:e.outcome?.text??null,t:n})}let Wh=(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:X.callRow,children:t(`conversation.chat.commandview`,i,{entryKey:r.name??``,fallback:/* @__PURE__ */ (0,f.jsx)(Hh,{...i,t:n})})})}),Gh=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.callRow,children:/* @__PURE__ */ (0,f.jsx)(Uh,{node:n.command,...n.compaction===null?{}:{compaction:n.compaction},t})})});function Kh({text:e,update:t=!1,t:n}){let[r,i]=(0,d.useState)(!1);return/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{className:bf.root,icon:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),chevronClassName:bf.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:bf.body,"data-system-prompt-body":!0,children:/* @__PURE__ */ (0,f.jsx)(rf,{content:[{type:`text`,text:e}],source:null,t:n})})})}let qh=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(Kh,{text:e.data.text,update:e.data.update===!0,t})}),Jh=`@deepseek-ai/dsh-client-ui-chat/TurnProcessNodeView.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=`.ty-UXa_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}.ty-UXa_root:disabled{cursor:default}@media (hover:hover){.ty-UXa_root:hover:not(:disabled){color:var(--dsw-alias-label-secondary)}}.ty-UXa_root:active:not(:disabled){color:var(--dsw-alias-label-secondary)}.ty-UXa_chevron{width:14px;height:14px;color:inherit;flex:none;margin-left:4px;transition:transform .1s}.ty-UXa_root[data-open] .ty-UXa_chevron{transform:rotate(180deg)}.ty-UXa_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}.ty-UXa_durationNumber{font-family:var(--ds-font-family-code);font-variant-numeric:tabular-nums}@media (prefers-reduced-motion:reduce){.ty-UXa_root,.ty-UXa_chevron{transition:none}}`,document.head.appendChild(e)}var Yh={chevron:`ty-UXa_chevron`,durationNumber:`ty-UXa_durationNumber`,label:`ty-UXa_label`,root:`ty-UXa_root`};let Xh=(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&&!rp(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:Tf(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:bm.visuallyHidden,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:u}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Yh.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:Yh.label,children:[l,c?.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(`span`,{className:e.numeric?Yh.durationNumber:void 0,children:e.text},t))]}),a&&/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:Yh.chevron})]})]})});function Zh(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 Qh=`@deepseek-ai/dsh-client-ui-chat/TurnChangesCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Qh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Qh,e.textContent=`.IG8hNq_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}.IG8hNq_header{-webkit-user-select:none;user-select:none;align-items:center;gap:12px;padding:12px;display:flex}.IG8hNq_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}.IG8hNq_text{flex-direction:column;flex:auto;gap:2px;min-width:0;display:flex}.IG8hNq_title{text-overflow:ellipsis;white-space:nowrap;font-weight:600;overflow:hidden}.IG8hNq_review,.IG8hNq_fileHead,.IG8hNq_more{color:inherit;font:inherit;text-align:left;cursor:pointer;-webkit-user-select:none;user-select:none;background:0 0;border:0}.IG8hNq_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){.IG8hNq_review:hover,.IG8hNq_fileHead:hover,.IG8hNq_more:hover{background:var(--dsw-alias-interactive-bg-hover)}}.IG8hNq_review:active,.IG8hNq_fileHead:active,.IG8hNq_more:active{background:var(--dsw-alias-interactive-bg-hover)}.IG8hNq_review:focus-visible,.IG8hNq_fileHead:focus-visible,.IG8hNq_more:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:-2px}.IG8hNq_files{border-top:1px solid var(--dsw-alias-border-l2);margin:0;padding:0;list-style:none}.IG8hNq_fileHead{justify-content:space-between;align-items:center;gap:12px;width:100%;min-height:40px;padding:8px 12px;display:flex}.IG8hNq_fileHead .IG8hNq_path{min-width:0;font-size:inherit;--dsw-alias-label-tertiary:var(--dsw-alias-label-secondary);flex:1}.IG8hNq_diff{padding:0 12px 12px}.IG8hNq_file:first-child .IG8hNq_diff:first-child{padding-top:12px}.IG8hNq_more{align-items:center;gap:8px;width:100%;min-height:40px;padding:8px 12px;font-weight:500;display:flex}.IG8hNq_mobileChevron,.IG8hNq_mobileFileIcon,.IG8hNq_mobilePath,.IG8hNq_mobileFullPath{display:none}.IG8hNq_chevron{flex:none;transition:transform .15s}.IG8hNq_chevron[data-open=true]{transform:rotate(180deg)}@media (width<=480px){.IG8hNq_header{grid-template-columns:36px minmax(0,1fr);gap:8px;display:grid}.IG8hNq_icon{width:36px;height:36px}.IG8hNq_review{grid-column:2;justify-self:start}}[data-phone] .IG8hNq_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] .IG8hNq_header{grid-template-columns:20px minmax(0,1fr) 44px;gap:8px;min-height:52px;padding:0 4px 0 12px;display:grid}[data-phone] .IG8hNq_icon{background:0 0;border-radius:0;width:20px;height:20px}[data-phone] .IG8hNq_icon>svg{width:16px;height:16px}[data-phone] .IG8hNq_text{flex-direction:row;align-items:center;gap:8px}[data-phone] .IG8hNq_title{flex:auto;min-width:0;font-weight:500}[data-phone] .IG8hNq_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] .IG8hNq_reviewLabel{display:none}[data-phone] .IG8hNq_mobileChevron,[data-phone] .IG8hNq_mobileFileIcon{color:var(--dsw-alias-label-secondary);flex:none;display:block}[data-phone] .IG8hNq_mobileChevron{transition:transform .15s}[data-phone] .IG8hNq_mobileChevron[data-open=true]{transform:rotate(180deg)}[data-phone] .IG8hNq_fileHead,[data-phone] .IG8hNq_more{gap:8px;min-height:44px;padding:0 12px}[data-phone] .IG8hNq_file+.IG8hNq_file{border-top:1px solid var(--dsw-alias-border-l2)}[data-phone] .IG8hNq_path{display:none}[data-phone] .IG8hNq_mobilePath{flex-direction:column;flex:1;min-width:0;padding-block:4px;display:flex}[data-phone] .IG8hNq_fileName{text-overflow:ellipsis;white-space:nowrap;font-weight:500;overflow:hidden}[data-phone] .IG8hNq_directory,[data-phone] .IG8hNq_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] .IG8hNq_mobileFullPath{user-select:text;padding:4px 12px;display:block}[data-phone] .IG8hNq_diff,[data-phone] .IG8hNq_file:first-child .IG8hNq_diff:first-child{padding:0}[data-phone] .IG8hNq_diffStatus{overflow-wrap:anywhere;padding:12px;display:block}[data-phone] .IG8hNq_diffStatus button{min-width:44px;min-height:44px}[data-phone] .IG8hNq_inlineDiff{border-radius:0;min-width:0;max-width:100%;margin:0}[data-phone] .IG8hNq_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] .IG8hNq_inlineDiff [data-diff-row=path]{display:none}[data-phone] .IG8hNq_inlineDiff [data-code-block-banner]{gap:8px;min-height:44px;padding:0 8px 0 12px}[data-phone] .IG8hNq_inlineDiff [data-code-block-banner] button{width:44px;height:44px}@media (prefers-reduced-motion:reduce){[data-phone] .IG8hNq_mobileChevron{transition:none}}`,document.head.appendChild(e)}var Z={card:`IG8hNq_card`,chevron:`IG8hNq_chevron`,diff:`IG8hNq_diff`,diffStatus:`IG8hNq_diffStatus`,directory:`IG8hNq_directory`,file:`IG8hNq_file`,fileHead:`IG8hNq_fileHead`,fileName:`IG8hNq_fileName`,files:`IG8hNq_files`,header:`IG8hNq_header`,icon:`IG8hNq_icon`,inlineDiff:`IG8hNq_inlineDiff`,mobileChevron:`IG8hNq_mobileChevron`,mobileFileIcon:`IG8hNq_mobileFileIcon`,mobileFullPath:`IG8hNq_mobileFullPath`,mobilePath:`IG8hNq_mobilePath`,more:`IG8hNq_more`,path:`IG8hNq_path`,review:`IG8hNq_review`,reviewLabel:`IG8hNq_reviewLabel`,text:`IG8hNq_text`,title:`IG8hNq_title`};let $h=(0,d.memo)(function({nodeStore:e,turn:t,t:n,useProjection:r,loadTurnDiffs:i}){let a=ee(e,t,r),o=(0,d.useMemo)(()=>{let e=/* @__PURE__ */ new Map;for(let t of a){let n=C(t.path);e.set(n,(e.get(n)??0)+1)}return e},[a]),[s,c]=(0,d.useState)(()=>/* @__PURE__ */ new Set),[l,u]=(0,d.useState)(!1),m=Zh(t,a,s,i),h=(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(a.length===0)return null;let{added:g,removed:_}=S(a),[y]=a,b=a.length===1&&y!==void 0?n(`chat.fileEdited`,{name:C(y.path)}):n(`chat.filesEdited`,{count:a.length}),x=a.some(e=>s.has(e.path)),w=l?a:a.slice(0,3),T=a.length-w.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:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.title,title:b,children:b}),/* @__PURE__ */ (0,f.jsx)(v,{added:g,removed:_})]}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.review,"aria-expanded":x,"aria-label":n(x?`chat.hideChanges`:`chat.viewChanges`),onClick:()=>{c(new Set(x?[]:a.map(e=>e.path))),x||u(!0)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.reviewLabel,children:n(x?`chat.hideChanges`:`chat.viewChanges`)}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.mobileChevron,"data-open":x})]})]}),(a.length>1||x)&&/* @__PURE__ */ (0,f.jsxs)(`ul`,{className:Z.files,children:[w.map(e=>{let t=m.diffs(e),r=C(e.path);return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Z.file,children:[a.length>1&&/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.fileHead,"aria-expanded":s.has(e.path),onClick:()=>{c(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}),(o.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:bm.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":s.has(e.path)})]}),s.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?m.error?/* @__PURE__ */ (0,f.jsxs)(`div`,{role:`alert`,className:Z.diffStatus,children:[m.error,` `,/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,onClick:m.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:h,maxLines:1/0,className:Z.inlineDiff})]})]},e.path)}),a.length>3&&/* @__PURE__ */ (0,f.jsx)(`li`,{children:/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.more,"aria-expanded":l,onClick:()=>u(e=>!e),children:[T>0?n(`chat.showMoreFiles`,{count:T}):n(`chat.collapseFiles`),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.chevron,"data-open":l})]})})]})]})});function eg(e){return e.flatMap(e=>e.kind===`text`?[e.text]:[]).join(``)}function tg(e){return e.some(e=>e.kind===`reasoning`||e.kind===`tool-call`?!1:e.kind!==`text`||e.text.trim()!==``)}let ng=`@deepseek-ai/dsh-client-ui-chat/TurnTailNodeView.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=`.ONXMya_root{flex-direction:column;gap:16px;display:flex}.ONXMya_actions{margin-top:4px;margin-left:-6px}`,document.head.appendChild(e)}var rg={actions:`ONXMya_actions`,root:`ONXMya_root`};function ig(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 ag=(0,d.memo)(function({node:e,openFile:t,forkAt:n,loadTurnDiffs:r,renderSlot:i,t:a,useChat:o,useSession:s,useProjection:c}){let l=s(e=>e.openState===`open`),u=(0,d.useRef)(!1),[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(),_=e.data,v=o(e=>e.nodes),y=o(e=>(ig(e,_.turn,!0)?.anchorSeq??-1)>(_.closing?.finalNode.seq??_.seq)),b=o(e=>{if(e.timeline.turnOrder.at(-1)!==_.turn)return!1;let t=ig(e,_.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&&tg([n])}),x=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,ee=jf(c,x?.turn,`end`);if(x===void 0)return null;let S=_.closing,C=i(`conversation.chat.turnTail`,{turn:x,seq:S?.finalNode.seq??_.seq,openFile:t});if(S===null)return C===null?null:/* @__PURE__ */ (0,f.jsx)(`div`,{className:rg.root,"data-turn-tail":_.turn,children:C});let w=S.finalNode.messageId,T=w===void 0?null:i(`conversation.chat.assistant-actions`,{messageId:w});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:rg.root,"data-turn-tail":_.turn,"data-actions-reveal":b?`always`:`hover`,children:[/* @__PURE__ */ (0,f.jsx)($h,{nodeStore:v,turn:_.turn,t:a,useProjection:c,loadTurnDiffs:r}),C,/* @__PURE__ */ (0,f.jsx)(Af,{text:eg(S.blocks),time:ee,clock:`end`,onBranch:()=>{!u.current&&l&&(u.current=!0,m(!0),g(void 0),n(_.seq).catch(e=>{g(e instanceof Error?e.message:String(e))}).finally(()=>{u.current=!1,m(!1)}))},branchUnavailable:!l||p||_.branchUnavailable||y,className:rg.actions,extraActions:T,t:a}),h!==void 0&&/* @__PURE__ */ (0,f.jsx)(`p`,{role:`alert`,children:a(`message.branchFailed`,{message:h})})]})});function og(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function sg(e,t){return typeof e[t]==`string`?e[t]:``}function cg(e){let t=og(e.source),n=sg(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=sg(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 lg=`@deepseek-ai/dsh-client-ui-chat/TurnTriggerNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(lg)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=lg,e.textContent=`.u7aAgG_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){.u7aAgG_root:hover{background:var(--dsw-alias-turn-trigger-bg-hover,var(--dsw-alias-interactive-bg-hover))}}.u7aAgG_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){.u7aAgG_header:hover{color:var(--dsw-alias-label-secondary)}}.u7aAgG_header:active{color:var(--dsw-alias-label-secondary)}.u7aAgG_icon{color:inherit;flex:none;display:inline-flex}.u7aAgG_title{font-size:var(--dsh-content-font-size,14px);flex:none}.u7aAgG_time{color:inherit;font:var(--dsw-font-xxs-12);flex:none;margin-left:auto}.u7aAgG_chevron,.u7aAgG_openChevron{color:inherit;flex:none}.u7aAgG_openChevron{transform:rotate(180deg)}.u7aAgG_body{padding:0 16px 12px 40px}.u7aAgG_explanation{color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xxs-12);margin:8px 0}.u7aAgG_content{white-space:pre-wrap;overflow-wrap:anywhere;max-height:240px;font:var(--dsw-font-xxs-12);overflow:auto}@media (prefers-reduced-motion:reduce){.u7aAgG_root,.u7aAgG_header{transition:none}}`,document.head.appendChild(e)}var ug={body:`u7aAgG_body`,chevron:`u7aAgG_chevron`,content:`u7aAgG_content`,explanation:`u7aAgG_explanation`,header:`u7aAgG_header`,icon:`u7aAgG_icon`,openChevron:`u7aAgG_openChevron`,root:`u7aAgG_root`,time:`u7aAgG_time`,title:`u7aAgG_title`};let dg={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 fg({node:e,t}){let[n,r]=(0,d.useState)(!1),i=(0,d.useId)(),a=cg(e.data),o=dg[a.icon],s=new Date(e.data.time),c=Ef(e.data.time,t);return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:ug.root,"data-turn-trigger":!0,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{className:ug.header,type:`button`,"aria-expanded":n,"aria-controls":i,onClick:()=>{r(!n)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:ug.icon,"aria-hidden":!0,children:/* @__PURE__ */ (0,f.jsx)(o,{size:14})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:ug.title,children:t(a.title)}),/* @__PURE__ */ (0,f.jsx)(`time`,{className:ug.time,dateTime:s.toISOString(),children:c}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:12,className:n?ug.openChevron:ug.chevron})]}),n&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:i,className:ug.body,children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:ug.explanation,children:t(`message.trigger.explanation`)}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:ug.content,children:/* @__PURE__ */ (0,f.jsx)(ff,{content:e.data.content,source:e.data.source,t})})]})]})}function pg(e,t){e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`user`,locale:vh,inject:()=>({links:e.get(`chatLinks`)})},Gf)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`steering`,locale:vh,inject:()=>({links:e.get(`chatLinks`)})},Gf)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`context`,locale:vh},qf)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-trigger`,locale:vh},fg)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`system-prompt`,locale:vh},qh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`assistant-step`,locale:vh,inject:()=>({hooks:{presentation:t}})},Lh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`command`,locale:vh,children:{"conversation.chat.commandview":{kind:`keyed`,scope:`session`}}},Wh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`manual-compaction`,locale:vh},Gh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`compaction`,locale:vh},Jf)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`model-retry`,locale:vh},Yf)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-error`,locale:vh},Xf)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-max-tokens`,locale:vh},Zf)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-process`,locale:vh},Xh)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-tail`,locale:vh,children:{"conversation.chat.turnTail":{kind:`list`,scope:`session`},"conversation.chat.assistant-actions":{kind:`list`,scope:`session`}}},ag)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`unknown`,locale:vh},Qf))}let mg={interruptedAssistant:-.9,interruptedFollowup:-.8,processControl:-.1,maxTokensNotice:.05,finalizedFollowup:.1};function hg(e){return e.start?.location??e.matches[0]?.location??{kind:`unresolved`}}function gg(e,t,n,r,i={}){return{key:e.key,kind:t,id:e.id,target:`chat`,anchorSeq:n,location:i.location??hg(e),visibility:i.visibility??`visible`,data:r}}function _g(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function vg(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function yg(e,t,n){let r=e[t];if(!Array.isArray(r))return[];let i=[];for(let e of r){let t=_g(e),r=t===null?null:vg(t,n);r!==null&&!i.includes(r)&&i.push(r)}return i}function bg(e){return e.length>0?e.join(`, `):null}let xg=[`instructions`,`catalog`,`snapshot`,`notice`,`relay`,`recall`];function Sg(e){let t=_g(e),n=t===null?null:vg(t,`form`);return n!==null&&xg.includes(n)?n:null}function Cg(e){let t=_g(e),n=t===null?null:vg(t,`kind`);if(t===null||n===null)return{role:`inject`,label:null};switch(n){case`session-reference`:return{role:`recall`,label:bg(yg(t,`references`,`label`))??n};case`agent-instructions`:return{role:`inject`,label:bg(yg(t,`changes`,`path`))??n};case`skill-invocation`:return{role:`inject`,label:vg(t,`name`)??n};default:return{role:`inject`,label:n}}}function wg(e){let t=_g(e);return t===null||vg(t,`kind`)!==`session-reference`?[]:yg(t,`references`,`label`)}function Tg(e){let t=_g(e);return t===null||vg(t,`kind`)!==`skill-invocation`?null:vg(t,`name`)}function Eg(e){return e.map(Dg)}function Dg(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 Og(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 kg(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 Ag(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 jg(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 Mg(e){return e.filter(e=>e!==void 0)}function Ng(e){return e===void 0||e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0}function Pg(e){return e.some(Ng)}function Fg(e){return e.some(e=>e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function Ig(e){return{...jg(e.turn,e.step),firstTokenTime:e.firstTokenTime}}function Lg(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||!Ag(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]=Og(t.blockType),s=Ng(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]=Dg(t.block),s=Ng(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=Ag(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 Rg(e,t,n){let r=Eg(n.data.message.content),i=r.map(Ng);return{...e,blocks:r,visibleByIndex:i,visibleBlocks:i.reduce((e,t)=>e+Number(t),0),final:t,usage:n.data.usage}}function zg(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 Bg(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:Eg(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:zg(r);if(i===void 0)return;let a=Mg(e.blocks);if(Fg(a))return{kind:`assistant`,seq:i.seq+mg.interruptedAssistant,time:i.time,turn:e.turn,step:e.step,blocks:a,interrupted:!0}}function Vg(e){let t;for(let n of e.matches)n.event.type===`assistant/live-chunk`?(t??=jg(n.event.data.turn,n.event.data.step),t=Lg(t,n.event.data.chunk,n.event.seq,n.event.time)):n.event.type===`assistant/message`?(t??=jg(n.event.data.turn,n.event.data.step),t=Rg(t,n,n.event)):n.event.type===`llm/retry`&&t!==void 0&&(t=Ig(t));return t}function Hg(e){let t=e.state??Vg(e);if(t===void 0)return;let n=Bg(t,e),r=n?.blocks??Mg(t.blocks),i=n===void 0?t.visibleBlocks>0:Pg(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 Ug(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`step`?t.step.data.get(`assistant-step`):void 0}let Wg={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 jg(t.event.data.turn,t.event.data.step)},update:(e,t)=>t.event.type===`assistant/live-chunk`?Lg(e.state,t.event.data.chunk,t.event.seq,t.event.time):t.event.type===`assistant/message`?Rg(e.state,t,t.event):t.event.type===`llm/retry`?Ig(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=Hg(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??Vg(e),r=Ug(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:Pg(r.blocks);return i===void 0&&!a&&t==null?null:gg(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 Gg(e){let t=Wg.match.bind(Wg);e.uiConversation.events.register({...Wg,match:{"step/start":t,"assistant/live-chunk":t,"assistant/message":t,"llm/retry":t}})}function Kg(e){return`kind`in e}function qg(e){return!Kg(e)}function Jg(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 Yg(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 Xg(e){return e.kind===`user`?Yg(e.data.content.flatMap(e=>e.type===`text`?[e.text]:[]),50):``}function Zg(e){return e.kind===`assistant-step`?Yg(e.data.blocks.flatMap(e=>e.kind===`text`?[e.text]:[]),120):``}function Qg(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 $g(e,t,n){let r=t.getTurn(e).map(e=>n.get(e)).filter(e=>e!==void 0&&Jg(e)),i=r.find(e=>e.kind===`user`),a=i??r[0];if(a===void 0)return;let o=r.findLast(e=>Zg(e)!==``);return{turn:e,anchorKey:a.key,prompt:i===void 0?``:Xg(i),response:o===void 0?``:Zg(o)}}function e_(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function t_(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 n_(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&&Jg(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)),!($f.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 r_=class{presentations=/* @__PURE__ */ new Map;get(e){let t=e_(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=e_(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)?n_(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,n_(i,t,n))&&r.add(i);return r}set(e,t){return!t_(this.presentations.get(e),t)&&(t===void 0?this.presentations.delete(e):this.presentations.set(e,t),!0)}};let i_=[],a_=[],o_=[],s_=[];function c_(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function l_(e,t,n){let r=e.get(t);return r===void 0&&(r=n(),e.set(t,r)),r}var u_=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))}},d_=class{nodes=/* @__PURE__ */ new Map;current=s_;dirty=!1;observable;source(){return this.observable??=new u_(()=>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}},f_=class{byKey=/* @__PURE__ */ new Map;turnProcesses=new r_;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=s_;valuesDirty=!1;get(e){return this.byKey.get(e)}source(e){return l_(this.sources,e,()=>new u_(()=>this.get(e),`[ui-chat] node source ${e}`))}turnDataSource(e,t){return this.turnKind(e,t).source()}turnKind(e,t){return l_(l_(this.turnKinds,e,()=>/* @__PURE__ */ new Map),t,()=>new d_)}updateTurnKind(e,t){let n=e===void 0?void 0:__(e.location).turn,r=t===void 0?void 0:__(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 l_(this.processSources,e,()=>new u_(()=>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()}},p_=class{turns=/* @__PURE__ */ new Map;steps=/* @__PURE__ */ new Map;positions=/* @__PURE__ */ new Map;getTurn(e){return this.turns.get(e)??i_}getStep(e,t){return this.steps.get(g_(e,t))??i_}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=__(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=g_(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=m_(this.turns,n),this.steps=m_(this.steps,r),[...a]}touch(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let r of e){let e=__(r.location);e.turn!==void 0&&this.turns.get(e.turn)?.includes(r.key)&&(t.add(e.turn),e.step!==void 0&&n.add(g_(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 m_(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)??i_,a=t.get(i)??i_,o=c_(r,a)?r:a;a.length>0&&n.set(i,o)}return n}var h_=class{current=o_;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=$g(a,t,n);if(e===void 0)continue;let o=this.byTurn.get(a),s=o!==void 0&&Qg(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=$g(r.turn,t,n);return i===void 0||Qg(r,i)?r:(this.byTurn.set(r.turn,i),i)});r.some((e,t)=>e!==this.current[t])&&(this.current=r)}};function g_(e,t){return`${e}:${t}`}function __(e){return e.kind===`step`?{turn:e.turn.turn,step:e.step.step}:e.kind===`turn`?{turn:e.turn.turn}:{}}function v_(e){return e.kind===`turn`||e.kind===`step`?e.turn.status:void 0}function y_(e,t,n){return n||e===void 0||v_(e.location)!==v_(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 b_(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)}):$f.has(e.kind)||t.set(r.turn.turn,{...i,earliestProcessAnchor:Math.min(i.earliestProcessAnchor??e.anchorSeq,e.anchorSeq)})}return t}function x_(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&&!$f.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 S_(e){let t=e.filter(e=>Jg(e)),n=b_(t);return t.sort((e,t)=>{let r=x_(e,n),i=x_(t,n);return r.anchor-i.anchor||r.rank-i.rank||r.originalAnchor-i.originalAnchor||e.key.localeCompare(t.key)})}function C_(e){let t=e;return t.kind===`user`||t.kind===`steering`?t.data.seq:void 0}function w_(e){let t=e;if(t.kind===`context`)return{messageSeq:t.data.seq-1,labels:wg(t.data.source)}}function T_(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.referenceLabels??i_,i=Object.hasOwn(n.data,`referenceLabels`);if(c_(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 E_=class{messagesBySeq=/* @__PURE__ */ new Map;labelsByMessageSeq=/* @__PURE__ */ new Map;replace(e){this.messagesBySeq.clear(),this.labelsByMessageSeq.clear();for(let t of e){let e=C_(t);e!==void 0&&this.messagesBySeq.set(e,t.key);let n=w_(t);n!==void 0&&n.labels.length>0&&this.labelsByMessageSeq.set(n.messageSeq,n.labels)}return e.map(e=>{let t=C_(e);return t===void 0?e:T_(e,this.labelsByMessageSeq.get(t)??i_)})}apply(e,t){let n=new Map(e.map(e=>[e.key,e])),r=/* @__PURE__ */ new Set;for(let t of e){let e=C_(t);e!==void 0&&(this.messagesBySeq.set(e,t.key),r.add(e));let n=w_(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&&c_(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,T_(i,this.labelsByMessageSeq.get(e)??i_))}return[...n.values()]}};function D_(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.skillNames??i_,i=Object.hasOwn(n.data,`skillNames`);if(c_(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 O_(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=Tg(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 k_(e,t){return e.seq===t.seq&&e.kind===t.kind&&e.name===t.name}var A_=class{entries=/* @__PURE__ */ new Map;sorted=[];replace(e){this.entries.clear(),this.sorted=[];for(let t of e){let e=O_(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=>D_(e,t.get(e.key)??i_))}apply(e,t){let n=[];for(let t of e){let e=O_(t),r=this.entries.get(t.key);if(r!==void 0){if(e!==null&&k_(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=D_(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 j_={anchorSeq:0,nodes:s_,partial:null,running:null};function M_(e){let t=e;if(e.visibility!==`visible`&&t.kind!==`assistant-step`)return j_;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:s_,partial:{turn:n.turn,step:n.step,blocks:n.blocks},running:null}:j_:{anchorSeq:t.anchorSeq,nodes:n.finalNode===void 0?s_:[n.finalNode],partial:null,running:null}}case`tool-call`:{let e=t.data.root;return qg(e)?{anchorSeq:t.anchorSeq,nodes:s_,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 j_;default:return j_}}function N_(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&&c_(e.nodes,t.nodes)}var P_=class{contributions=/* @__PURE__ */ new Map;finalizedContributions=/* @__PURE__ */ new Map;runningContributions=/* @__PURE__ */ new Map;partialContributions=/* @__PURE__ */ new Map;finalized=s_;runningCalls=s_;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=M_(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=M_(t),a=this.contributions.get(t.key);N_(a,e)||(n||=I_(a,e),r||=L_(a,e),i||=R_(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){F_(this.finalizedContributions,e,t,t.nodes.length>0),F_(this.runningContributions,e,t,t.running!==null),F_(this.partialContributions,e,t,t.partial!==null)}rebuildFinalized(){let e=[...this.finalizedContributions.values()].flatMap(e=>e.nodes).sort((e,t)=>e.seq-t.seq);c_(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]);c_(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 F_(e,t,n,r){r?e.set(t,n):e.delete(t)}function I_(e,t){let n=e?.nodes??s_;return!c_(n,t.nodes)||(n.length>0||t.nodes.length>0)&&e?.anchorSeq!==t.anchorSeq}function L_(e,t){return e?.running!==t.running||(e.running!==null||t.running!==null)&&e.anchorSeq!==t.anchorSeq}function R_(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 z_=class{store=new f_;locations=new p_;navigation=new h_;legacy=new P_;referenceLabels=new E_;skillNames=new A_;order=i_;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:a_,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=S_(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||V_(t.location)!==V_(e.location);if(r||=o,o||i.push(e),y_(t,e,o)){let r=t===void 0?void 0:__(t.location).turn,i=__(e.location).turn;r!==void 0&&n.add(r),i!==void 0&&n.add(i)}}this.store.upsert(t);let o=a_;if(r){let e=S_(this.store.values()).map(e=>e.key);this.order=c_(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(B_(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??a_,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(s_,e)){return{order:this.order,nodes:this.store,locations:this.locations,navigation:this.navigation,timeline:e,legacy:t}}};function B_(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=__(n.location).turn;e!==void 0&&t.add(e)}return t}function V_(e){let t=__(e);return`${e.kind}:${t.turn??``}:${t.step??``}`}let H_={target:`chat`,create:()=>new z_,isActive:e=>e.order.some(t=>e.nodes.get(t)?.kind!==`command`)};function U_(e){e.uiConversation.views.register(H_)}let W_=/* @__PURE__ */ new Set([`system/message`,`developer/message`,`user/message`,`assistant/message`,`tool/result`]);function G_(e){return W_.has(e.type)?e.surfaceOp!==void 0:!1}function K_(e){return G_(e)&&e.surfaceOp===`append`}function q_(e){return G_(e)&&e.surfaceOp!==`append`}function J_(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 Y_(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 X_(e){if(e.type!==`user/message`||!q_(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 Z_(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 Q_(e){let t=e.matches.find(e=>e.event.type===`command/done`),n=e.matches.find(e=>X_(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:Y_(t)};let i=X_(n.event);return i?.sourceCommandId===void 0?t===void 0?void 0:{command:Y_(t)}:{command:t===void 0?{kind:`command`,seq:n.event.seq,time:n.event.time,commandId:i.sourceCommandId,name:`compact`,args:null,outcome:null}:{...Y_(t),name:`compact`},checkpoint:n,...r===void 0?{}:{summary:r}}}function $_(e,t){return t.event.type===`compaction/summary`?{...e,summary:t}:X_(t.event)===void 0?e:{...e,checkpoint:t}}let ev={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=X_(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:J_(t)}),update:(e,t)=>t.event.type===`command/done`?{...e.state,command:Y_(t,e.state.command)}:$_(e.state,t),buildViewNode:e=>{let t=e.state??Q_(e);if(t===void 0)return null;if(t.command.name!==`compact`)return gg(e,`command`,t.command.seq,t.command);let n=t.checkpoint===void 0?null:Z_(t.summary,t.checkpoint),r={command:t.command,compaction:n};return gg(e,`manual-compaction`,n?.seq??t.command.seq,r)}};function tv(e){e.uiConversation.events.register(ev)}function nv(e){let t=e.matches.find(e=>e.event.type===`compaction/summary`),n=e.matches.find(e=>X_(e.event)!==void 0);return{...t===void 0?{}:{summary:t},...n===void 0?{}:{checkpoint:n}}}let rv={kind:`compaction`,target:`chat`,match:e=>{let t=X_(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)=>$_(e.state,t),buildViewNode:e=>{let t=e.state??nv(e);if(t.checkpoint===void 0)return null;let n=Z_(t.summary,t.checkpoint);return gg(e,`compaction`,n.seq,n)}};function iv(e){e.uiConversation.events.register(rv)}let av={kind:`unknown-surface`,target:`chat`,match:e=>e.type!==`assistant/live-chunk`&&K_(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:gg(e,`unknown`,e.state.seq,e.state)};function ov(e){e.uiConversation.events.registerFallback(av)}let sv={kind:`snapshot`,ids:[]},cv=/* @__PURE__ */ new Set;function lv(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 uv(e,t){let n;for(let{id:r}of t)e.has(r)&&(n??=new Set(e),n.delete(r));return n??e}function dv(e,t,n){let r=e?.state.pending??sv,i=t.inserted,a=t.removedCount??0;if(a>0&&t.outcome!==`canceled`){let e=lv(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=uv(e?.state.currentClaimed??cv,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 fv(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 dv(r.previous(t),n.event.data,n.event.seq)},update:e=>e.state,publication:()=>`none`}}let pv=fv(`next-step`),mv=fv(`next-turn`);function hv(e){e.uiConversation.events.register(pv),e.uiConversation.events.register(mv)}function gv(e){return e.type!==`user/message`||!q_(e)?!1:e.data.source.kind===`compact-checkpoint`}function _v(e,t){return{kind:`context`,seq:e.seq,time:e.time,content:t.content,source:t.source,producer:Cg(t.source),form:Sg(t.source)}}let vv={kind:`input-message`,target:`chat`,match:e=>e.type===`user/message`&&K_(e)&&!gv(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{..._v(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,...yv(e.state)}:e.state;return gg(e,t?`turn-trigger`:e.state.kind,e.state.seq,n)}};function yv(e){let t=gd(e.content.flatMap(e=>e.type===`text`?[e.text]:[]).join(`
140
+ `));return t.length===0?{}:{responseAnnotations:t}}let bv={...vv,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 _v(n,n.data.message)}};function xv(e){e.uiConversation.events.register(vv),e.uiConversation.events.register(bv)}function Sv(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 Cv(e,t,n,r){let i=e.current.get(`chat`);return i?.kind===`system-prompt`?i.anchorSeq:Sv(t,n,r)}function wv(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:gg(e,`system-prompt`,t.update?t.seq:Sv(e.start,void 0,!0),{text:t.text,...t.update?{update:!0}:{}})}}}function Tv(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:Cv(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:gg(e,`system-prompt`,t.anchorSeq,{text:t.prompt.system},{visibility:r?`visible`:`hidden`})}}}function Ev(e){e.uiConversation.events.register(wv((t,n)=>e.uiConversation.inspectSystemPrompt(t,n))),e.uiConversation.events.register(Tv((t,n,r)=>e.uiConversation.inspectRequestPrompt(t,n,r)))}function Dv(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 Ov(e){return e.kind===`step`&&e.step.status===`closed`||(e.kind===`step`||e.kind===`turn`)&&e.turn.status===`closed`}let kv={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=Dv(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=Dv(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`&&Ov(t)?{...e,retryState:`cancelled`}:e),i=r.at(-1);if(i===void 0)return null;let a={attempts:r,current:i};return gg(e,`model-retry`,r[0]?.seq??i.seq,a)}};function Av(e){e.uiConversation.events.register(kv)}let jv=/* @__PURE__ */ new WeakMap;function Mv(e){return JSON.stringify(e)}function Nv(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?bp.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 Pv(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 bp;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 Fv(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 Iv(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??bp.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 Lv(e,t){return{phase:`start`,callId:t.subCallId,parentCallId:t.parentCallId,name:t.name,argsRaw:Mv(t.arguments),args:bp.fromObject(t.arguments),turn:zv(e),step:Bv(e),time:e.event.time,subCalls:[]}}function Rv(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:bp.fromObject(t.arguments),call:{name:t.name,argsRaw:Mv(t.arguments)},callTime:n?.time??null,content:t.content??[],isError:t.isError===!0,...t.error===void 0?{}:{error:t.error},subCalls:[]}}function zv(e){return e.location.kind===`step`||e.location.kind===`turn`?e.location.turn.turn:0}function Bv(e){return e.location.kind===`step`?e.location.step.step:0}function Vv(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 Hv(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||!Vv(e,i,a))return e;let n=new Map(e.children);n.set(i,[...o,Lv(t,r)]);let c=new Map(e.parents);return c.set(a,i),{...e,children:n,parents:c}}if(s<0&&!Vv(e,i,a))return e;let c=Rv(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 Uv(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=>Uv(e,t,n,a,i+1)),s=`kind`in e?void 0:n?.seq,c=`kind`in e?void 0:n?.time,l=jv.get(e);if(l!==void 0&&l.interruptionSeq===s&&l.interruptionTime===c&&Wv(l.children,o))return l.value;let u=`kind`in e||n===void 0?Wv(e.subCalls,o)?e:{...e,subCalls:o}:{kind:`tool-result`,seq:n.seq+mg.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 jv.set(e,{children:o,interruptionSeq:s,interruptionTime:c,value:u}),u}function Wv(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Gv(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 Kv(e){let t=e.matches.find(e=>e.event.type===`tool/result`),n=t===void 0?void 0:Iv(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=Hv(r,t);return r}let qv={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`&&K_(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:Nv(t)}:Pv(n,t)},update:(e,t)=>{if(t.event.type===`assistant/live-chunk`)return Pv(e.state,t);if(t.event.type===`tool/call`)return{...e.state,root:Nv(t,e.state.root)};if(t.event.type===`tool/result`){let n=e.state.root,r=Iv(t,n!==void 0&&!(`kind`in n)&&n.phase===`start`?n:void 0);return r===void 0?e.state:{...e.state,root:r}}return Hv(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??Kv(e);if(n?.root===void 0)return t==null?null:t.visibility===`hidden`?t:{...t,visibility:`hidden`};let r=Gv(e),i=Uv(!(`kind`in n.root)&&n.root.phase===`preparing`?Fv(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=hg(e),c=np(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:gg(e,`tool-call`,a,l,{visibility:o,location:c})}};function Jv(e){let t=qv.match.bind(qv);e.uiConversation.events.register({...qv,match:{"assistant/live-chunk":t,"tool/call":t,"tool/result":t,"tool/ptc-dispatch-start":t,"tool/ptc-dispatch":t}})}function Yv(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 Xv(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=kg(n);return{seq:e.event.seq,time:e.event.time,message:r.message,...r.code===void 0?{}:{code:r.code}}}function Zv(e){let t=e.matches.find(e=>Xv(e)!==void 0);if(t?.event.type!==`turn/end`)return;let n=Xv(t);if(n!==void 0)return{turn:t.event.data.turn,failure:n}}let Qv={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=Xv(t);return n===void 0?e.state:{...e.state,failure:n}},buildViewNode:e=>{let t=e.state??Zv(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:Yv(e),message:n.message,...n.code===void 0?{}:{code:n.code}};return gg(e,`turn-error`,r.seq,r)}};function $v(e){e.uiConversation.events.register(Qv)}function ey(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 ty(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+mg.maxTokensNotice}function ny(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 ry={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=ny(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:ey(e)};return gg(e,`turn-max-tokens`,ty(e,t.seq),n)}};function iy(e){e.uiConversation.events.register(ry)}function ay(e){let t=e.data;return typeof t.turn==`number`?t.turn:void 0}function oy(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 sy(e){return e.type===`assistant/live-chunk`?oy(e.data.chunk):e.type!==`assistant/attempt`&&e.type===`assistant/message`&&e.surfaceOp===`append`&&Eg(e.data.message.content).some(e=>e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function cy(e,t){return e.type===`tool/call`?np(e.data.name):e.type===`tool/result`&&t.has(String(e.data.message.source.callId))}function ly(e,t){if(sy(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(!cy(e,t)&&(e.type===`tool/call`||e.type===`tool/result`&&e.surfaceOp===`append`||e.type===`llm/retry`))return{kind:`other`,seq:e.seq}}function uy(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function dy(e){let t=e.matches.map(e=>ay(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=hy(n,t.event);return n}function fy(e){return e?.finalNode!==void 0}function py(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!fy(n)||n.finalNode.interrupted===!0||!tg(n.blocks)||t===void 0&&n.blocks.some(e=>e.kind===`tool-call`)?null:n}function my(e,t){let n=e.controlAnchorSeq??t.start?.seq;if(n===void 0)return null;let r=py(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 hy(e,t){let n=e;if(t.type===`assistant/message`&&t.surfaceOp===`append`&&tg(Eg(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(np(t.data.name)){let e=new Set(n.contextCompactionCalls);e.add(String(t.data.callId)),n={...n,contextCompactionCalls:e}}else{let e=tp(t.data.name);n={...n,toolCallCount:n.toolCallCount+ +!e,subagentCount:n.subagentCount+ +!!e}}}let r=ly(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 gy={kind:`turn-process`,target:`chat`,match:e=>{if(e.type===`turn/start`)return{id:String(e.data.turn),role:`start`};let t=ay(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)=>hy(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??dy(e);if(r===void 0)return null;let i=uy(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=my(r,i);return s===null?null:n?.kind===`turn`&&n.turn===s.turn&&n.key===`turn-process`&&ep(n.value,s)?n:{kind:`turn`,turn:i.turn,key:`turn-process`,value:s}},buildViewNode:e=>{let t=uy(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:gg(e,`turn-process`,n.controlAnchorSeq+mg.processControl,n)}};function _y(e){let t=gy.match.bind(gy);e.uiConversation.events.register({...gy,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 vy(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 yy(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function by(e){let t=0;for(let n of e)if(t+=n,!Number.isSafeInteger(t))return;return t}function xy(e){let{provider:t,model:n}=e.source;return t.length>0&&n.length>0?{provider:t,model:n}:void 0}function Sy(e){return vy(e,`usage`)?.usage}function Cy(e,t){let{inputTokens:n,outputTokens:r,cacheReadTokens:i,cacheWriteTokens:a,reasoningTokens:o,totalTokens:s}=e;if(!yy(n)||!yy(r)||i!==void 0&&!yy(i)||a!==void 0&&!yy(a)||o!==void 0&&(!yy(o)||o>r))return;let c=by([n,...i===void 0?[]:[i],...a===void 0?[]:[a]]);if(c===void 0)return;let l;if(s!==void 0){if(!yy(s))return;let e=s-r;if(!yy(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=by([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 wy(e){if(e.length===0)return;let t=by(e.map(e=>e.inputTokens)),n=by(e.map(e=>e.outputTokens)),r=by(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(yy)?by(i):void 0,c=a.every(yy)?by(a):void 0,l=o.every(yy)?by(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 Ty(e,t,n){return e.turn===t&&e.step===n}function Ey(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=Cy(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`||!Ty(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`||!Ty(t,n.data.turn,n.data.step)){a=!0;continue}let e=Sy(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`||!Ty(t,n.data.turn,n.data.step)){a=!0;continue}let e=n.data.usage??Sy(n.data.stream);e!==void 0&&(t={...t,sample:e}),o(xy(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`||!Ty(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`||!Ty(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:wy(n)}function Dy(e){return e.type!==`assistant/live-chunk`}function Oy(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 ky(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function Ay(e){return e.finalNode!==void 0&&e.blocks.some(e=>e.kind===`text`&&e.text.trim()!==``)}function jy(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=ky(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(Ay)??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`?Ey(e.matches.map(e=>e.event).filter(Dy)):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 My={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=Oy(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=jy(e);return n===null?null:{kind:`turn`,turn:n.turn,key:`turn-tail`,value:n}},buildViewNode:e=>{let t=ky(e)?.data.get(`turn-tail`);return t===void 0?null:gg(e,`turn-tail`,t.seq+mg.finalizedFollowup,t)}};function Ny(e){let t=My.match.bind(My);e.uiConversation.events.register({...My,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 Py(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 Fy=new Intl.Segmenter(void 0,{granularity:`grapheme`}),Iy=[`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 Ly(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=160)return{text:t,truncated:!1};let n=[];for(let{segment:e}of Fy.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 Ry(e){return Ly(typeof e==`string`?e:Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(`, `):``).text}function zy(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=Ly(r);if(a.truncated||!e.stringExceeds(t,n))return a.text;n*=2}}function By(e){if(!Array.isArray(e))return``;for(let t of e){if(typeof t!=`object`||!t)continue;let e=Ry(Reflect.get(t,`question`));if(e!==``)return e}return``}function Vy(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=Ry(r[e]?.replaceAll(`**`,``));if(t!==``)return t}}}return``}function Hy(e,t){for(let e of Iy){if(!t.has(e))continue;let n=e===`questions`?By(t.value(e)):zy(t,e)??Ry(t.value(e));if(n!==``)return n}return t.closed()?Ry(e):``}function Uy(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=qg(e)?e:e.call;if(c!==null){let n=Py(c.name);qg(e)&&e.time>=a&&(r=n,o=e.phase===`preparing`,i=Hy(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=Vy(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 Wy=/* @__PURE__ */ new Set([`user`,`steering`,`turn-trigger`,`model-retry`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function Gy(e){let t=e.location;return t.kind===`turn`||t.kind===`step`?t.turn.turn:void 0}function Ky(e){return Wy.has(e.kind)||e.kind===`tool-call`&&np(e.data.root.name)}function qy(e){return e.kind===`assistant-step`&&e.data.blocks.some(e=>e.kind===`reasoning`&&e.text.trim()!==``)}function Jy(e){return e.kind===`assistant-step`&&tg(e.data.blocks)}function Yy(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 Xy(e,t){return e.length===t.length&&e.every((e,n)=>e.key===t[n]?.key&&e.groupPart===t[n].groupPart)}function Zy(e,t){return!Jg(t)&&(e===void 0||!Jg(e))?!1:e===void 0||e.kind!==t.kind||Gy(e)!==Gy(t)||Jg(e)!==Jg(t)||qy(e)!==qy(t)||Jy(e)!==Jy(t)}function Qy(e,t){let n=e.readNode(t);if(n===void 0)throw Error(`Chat grouping input is missing Node ${t}`);return n}function $y(e,t){let n=/* @__PURE__ */ new Set;for(let r of t){let t=Qy(e,r);t.kind===`question-reply`&&n.add(t.id)}return n}var eb=class{key;turn;members;nodes=[];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:``}}}}refresh(e,t){let n=this.members.map(t=>Qy(e,t.key)),r=n.length===this.nodes.length&&n.every((e,t)=>e===this.nodes[t]),i=this.snapshot.data,a=r&&i.closed===t?i.summary:Uy(n),o=t?{counts:a.counts,running:void 0,runningDetail:``}:a;this.nodes=n,(i.closed!==t||!Yy(i.summary,o))&&(this.snapshot={key:this.key,members:this.members,data:{turn:this.turn,closed:t,summary:o}})}},tb=class{turn;groups=/* @__PURE__ */ new Map;membership=/* @__PURE__ */ new Map;roots=/* @__PURE__ */ new Map;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===`closed`;if(r)for(let e of this.groups.values())e.snapshot.data.closed||n.add(e.key);let i=[];for(let t of n){let n=this.groups.get(t),a=n.snapshot;n.refresh(e,a.data.closed||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,t)=>{n.set(e,[...n.get(e)??[],t])},c=n=>{let c=a[0];if(c===void 0)return;let l=this.extendedGroup(a,t)?.key??Sm(JSON.stringify([`process`,c.key,c.groupPart??null])),u=this.groups.get(l),d=u?.snapshot,f=u!==void 0&&Xy(u.members,a)?u:new eb(l,this.turn,a);f.refresh(e,n||e.timeline.turns.get(this.turn)?.status===`closed`),r.set(f.key,f),s(c.key,{kind:`group`,key:f.key});for(let e of a)i.set(e.key,f.key);f.snapshot!==d&&o.push(f.snapshot),a=[]},l,u=!1,d=e.readTurn(this.turn),f=$y(e,d);for(let t of d){let n=nb(e,t);l!==void 0&&n.previous!==l&&c(!0),l=t,u=n.next!==void 0;let r=Qy(e,t);r.kind===`turn-trigger`&&f.has(r.id)||(Ky(r)?(c(!0),s(t,{kind:`node`,key:t})):r.kind===`turn-process`?s(a[0]?.key??t,{kind:`node`,key:t}):r.kind===`assistant-step`?(qy(r)&&a.push({kind:`node`,key:t,groupPart:`reasoning`}),Jy(r)&&(c(!0),s(t,{kind:`node`,key:t,groupPart:`response`}))):a.push({kind:`node`,key:t}))}c(u);let p=[...this.groups.keys()].filter(e=>!r.has(e));return this.groups=r,this.membership=i,this.roots=n,{upserts:o,removes:p}}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 nb(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 rb=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=nb(e,t).turn;if(i===void 0||r.has(i))continue;let a=this.turns.get(i)??new tb(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=Gy(a);if((e===void 0||!Jg(e))&&n.add(a.key),Zy(e,a)){let n=e===void 0?void 0:Gy(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 tb(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=$y(e,e.order.filter(t=>nb(e,t).turn===void 0));return e.order.flatMap(n=>{let r=nb(e,n).turn;if(r===void 0){let r=Qy(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 ib={kind:`process-groups`,target:`chat`,create:()=>new rb,update:(e,t)=>(e.state.accept(t),e.state),buildGroups:e=>e.state.output()};function ab(e){hv(e),xv(e),Ev(e),Gg(e),_y(e),Jv(e),tv(e),iv(e),Av(e),$v(e),iy(e),Ny(e),ov(e),U_(e),e.uiConversation.groups.register(ib)}function ob({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 sb(e){return e==null}function cb(e){return e&&typeof e==`object`&&!Array.isArray(e)}function lb(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function ub(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function db(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 fb=Symbol.for(`cosmokit.volatile.write`);function pb(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=>pb(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,pb(n,t)])))}finally{t.delete(e)}}function mb(e){let t=pb(e);return Object.freeze({get:()=>t,[fb]:e=>{t=e}})}function hb(e){return typeof e==`object`&&!!e&&fb in e}function gb(e,t){return arguments.length===1?t=>gb(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function _b(e){return gb(`ArrayBuffer`,e)||gb(`SharedArrayBuffer`,e)}function vb(e){return _b(e)||ArrayBuffer.isView(e)}let yb;(function(e){e.is=_b,e.isSource=vb;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})(yb||={}),yb.fromBase64,yb.toBase64,yb.fromHex,yb.toHex;function bb(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(gb(`Date`,e))return new Date(e.valueOf());if(gb(`RegExp`,e))return new RegExp(e.source,e.flags);if(_b(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(bb,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(bb,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function xb(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(hb(e)||hb(t))return hb(e)&&hb(t);if(!n&&sb(e)&&sb(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(gb(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(gb(`URL`),(e,t)=>e.href===t.href)??a(gb(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(_b,(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 Sb;(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})(Sb||={});let Cb=Symbol.for(`schemastery`),wb=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?.[wb]}};Object.defineProperty(Q.prototype,wb,{value:!0});let $=function(e){let t=function(e,n={}){return $.resolve(e,t,n)[0]};if(e.refs){let t=ub(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&&ub(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[Cb]=!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 Tb(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 Eb(e){return e?.$value??e?.$inner}function Db(e){return lb(e??{},e=>!e.startsWith(`$`))}$.prototype.i18n=function(e){let t=$(this),n=Tb(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=ub(t.dict,(t,n)=>t.i18n(ub(e,e=>Eb(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(ub(e,(e={})=>Array.isArray(Eb(e))?Eb(e)[n]:Array.isArray(e)?e[n]:Db(e)))),t.inner&&=t.inner.i18n(ub(e,e=>Eb(e)?Eb(e):Db(e))),t.sKey&&=t.sKey.i18n(ub(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=db(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},$.prototype.simplify=function(e){if(hb(e)&&(e=e.get()),xb(e,this.meta.default,this.type===`dict`))return null;if(sb(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`||!sb(r))&&(t[n]=r)}return xb(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 Ib[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 Ob={},kb=Symbol(`checked-volatile-schema`);function Ab(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))Ab(i,[...t,n],a,r);if(e.sKey&&Ab(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[Cb])&&Ab(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)Ab(e.list[n],[...t,String(n)],!0,r)}$.extend=function(e,t){Ob[e]=t},$.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[kb]||(Ab(t,n.path),n={...n,[kb]:!0}),t.meta?.volatile){let i=$(t);i.meta={...t.meta,volatile:!1};let[a,o]=$.resolve(e,i,n,r);try{return[mb(a),o]}catch(e){throw new Q(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(sb(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`&&sb(i);)r=r.list[0],i=r?.meta.default;if(sb(i))return[e];e=bb(i)}let i=Ob[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(sb(e))return $.any();if([`string`,`number`,`boolean`].includes(typeof e))return $.const(e).required();if(e[Cb])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[Cb]||(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(yb.isSource(e))return yb.fromSource(e);throw new Q(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[$.transform($.string(),(t,n)=>{try{return e===`base64`?yb.fromBase64(t):yb.fromHex(t)}catch(e){throw new Q(e.message,n)}},!0)]:[]])},$.extend(`lazy`,(e,t,n,r)=>(t.inner[Cb]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},Ab(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(xb(e,t))return[t];throw new Q(`expected ${t} but got ${e}`,n)});function jb(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 jb(e.length,t,`string length`,n),[e]});function Mb(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 Nb(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(Mb(e,i)-Mb(t,i))%Mb(n,i)===0}$.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new Q(`expected number but got ${e}`,n);jb(e,t,`number`,n);let{step:r}=t;if(r&&!Nb(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(sb(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 Pb(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?mb(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 jb(e.length,n,`array length`,r,!sb(t.meta.default)),[e.map((n,i)=>Pb(e,i,t,r))]}),$.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!cb(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]=Pb(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)=>Pb(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function Fb(e,t){for(let n in t)n in e||(e[n]=t[n])}$.extend(`object`,(e,{dict:t},n,r)=>{if(!cb(e))throw new Q(`expected object but got ${e}`,n);let i={};for(let r in t){let a=Pb(e,r,t[r],n);(!sb(a)||r in e)&&(i[r]=a)}return r||Fb(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(!sb(t)){if(sb(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`)Fb(a??={},t);else if(a!==t)throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&cb(e)&&Fb(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 Ib={};function Lb(e,t,n){Ib[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=ub(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}})}Lb(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),Lb(`any`,[],()=>`any`),Lb(`never`,[],()=>`never`),Lb(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),Lb(`string`,[],()=>`string`),Lb(`number`,[],()=>`number`),Lb(`boolean`,[],()=>`boolean`),Lb(`bitset`,[`bits`],()=>`bitset`),Lb(`function`,[],()=>`function`),Lb(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),Lb(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),Lb(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),Lb(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),Lb(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),Lb(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),Lb(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let Rb=`transcriptView`,zb=[`compact`,`standard`,`detailed`,`verbose`],Bb=[...zb,`normal`,`expanded`],Vb=`standard`,Hb={linkOpening:$.union([`sidebar`,`new-tab`]).default(`sidebar`),[Rb]:$.union([...Bb]).loose()};$.object(Hb);let Ub=`@deepseek-ai/dsh-client-ui-chat/PreferenceRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ub)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Ub,e.textContent=`.Zxrp0W_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.Zxrp0W_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.Zxrp0W_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.Zxrp0W_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.Zxrp0W_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}.Zxrp0W_selector:active{background:var(--dsw-alias-interactive-bg-active)}.Zxrp0W_chevron{flex:none}@media (hover:hover) and (pointer:fine){.Zxrp0W_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}}@media (width<=640px){.Zxrp0W_row{gap:12px;min-height:44px;padding:12px 0}.Zxrp0W_rowText{padding-right:0}.Zxrp0W_selector{gap:8px;height:44px;min-height:44px;padding:0 12px;font-size:13.5px}}`,document.head.appendChild(e)}var Wb={chevron:`Zxrp0W_chevron`,desc:`Zxrp0W_desc`,row:`Zxrp0W_row`,rowText:`Zxrp0W_rowText`,selector:`Zxrp0W_selector`,title:`Zxrp0W_title`};function Gb({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:Wb.selector,"aria-haspopup":`menu`,"aria-expanded":o,onClick:()=>{s(e=>!e)},children:[r,/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:Wb.chevron})]});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Wb.row,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Wb.rowText,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Wb.title,children:e}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:Wb.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 Kb={compact:`settings.transcript.compact`,standard:`settings.transcript.standard`,detailed:`settings.transcript.detailed`,verbose:`settings.transcript.verbose`};function qb({useTranscriptView:e,setTranscriptView:t,t:n}){let r=e(e=>e);return/* @__PURE__ */ (0,f.jsx)(Gb,{title:n(`settings.transcript.title`),description:n(`settings.transcript.description`),value:r,selectedLabel:n(Kb[r]),options:zb.map(e=>({id:e,label:n(Kb[e])})),onSelect:e=>{t(e)}})}var Jb=class{host;defaultMode;unsubscribe;mode;constructor(e,t=Vb){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(Rb,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 Yb={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 Xb(e){return{getSnapshot:()=>Yb[e.getSnapshot()],subscribe:t=>e.subscribe(t)}}function Zb({useLinkOpening:e,useBrowserAvailable:t,setLinkOpening:n,t:r}){let i=e(e=>e);return t(e=>e)?/* @__PURE__ */ (0,f.jsx)(Gb,{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 Qb={getSnapshot:()=>void 0,subscribe:()=>()=>{}};function $b(e,t){let n=e?.source(t)??Qb;return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let ex={hooks:{turnData:(e,{turnData:t})=>function(e){return $b(t,e)},disclosure:(e,{disclosureReset:t})=>Tp(t)}},tx=[`slots`,`sessions`,`uiWorkspace`,`uiSession`,`uiConversation`,`locale`,`configForms`,`remote`,`remote.session`,`remote.workspaceFiles`,`sidebarRight`];function nx(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()??fe,subscribe:e=>l.subscribe(e)},i.set(o,s)}return s};ab(e),e.uiSession.provide({hooks:[`chat`],resolve:e=>({hooks:{chat:o(e)}})}),e.effect(()=>e.locale.register(vh,{zh:yh,en:bh}),`ui-chat: dictionaries`);let s=e.locale.bind(vh),c=ap(),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:vh,inject:()=>({hooks:{linkOpening:d,browserAvailable:f},setLinkOpening:e=>{d.set(e),u.set(`linkOpening`,e).catch(()=>{})}})},Zb))});let h=new Jb(u,`dshDesktop`in globalThis?`standard`:Vb),g=Xb(h.mode);e.effect(()=>()=>{h.dispose()}),pg(e,g),e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`transcript-view`,order:12,locale:vh,inject:()=>({hooks:{transcriptView:h.mode},setTranscriptView:e=>{h.setMode(e)}})},qb)),e.slots.inject(`conversation.view`,()=>e.slots.register({name:`conversation.view`,id:`chat`,order:0,label:()=>s(`view.chat`),locale:vh,children:{"conversation.chat.node":{kind:`keyed`,scope:`session`,inject:ex},"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`);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=ae(i,n);if(!r.reveal||!ie(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({path:a,...r.reveal?{action:`reveal`}:{}});if(!o.ok)throw Error(o.error.message);return}let a=oe(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)})}}}},gh)),e.slots.inject(`shell.overlay`,()=>e.slots.register({name:`shell.overlay`,id:`chat.quota-notice`,locale:vh,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)}}})},ob)),e.slots.inject(`conversation.input.dock`,()=>e.slots.register({name:`conversation.input.dock`,id:`file-changes`,order:5,locale:vh},E)),e.slots.inject(`conversation.approval.detail`,()=>e.slots.register({name:`conversation.approval.detail`},me))}return n.EMPTY_CHAT_SNAPSHOT=fe,n.apply=nx,n.inject=tx,n.isRunningTool=qg,n.isSettledTool=Kg,t.exports}});