@oonacode/win32-x64 0.3.209 → 0.3.210
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.
|
@@ -74,7 +74,7 @@ Error generating stack: `+e.message+`
|
|
|
74
74
|
|
|
75
75
|
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);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function ua(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:pa(t,`input`,e.processors),output:pa(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function da(e,t){let n=t??{seen: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 da(r.element,n);if(r.type===`set`)return da(r.valueType,n);if(r.type===`lazy`)return da(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 da(r.innerType,n);if(r.type===`intersection`)return da(r.left,n)||da(r.right,n);if(r.type===`record`||r.type===`map`)return da(r.keyType,n)||da(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:da(r.in,n)||da(r.out,n);if(r.type===`object`){for(let e in r.shape)if(da(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(da(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(da(e,n))return!0;return!!(r.rest&&da(r.rest,n))}return!1}var fa=(e,t={})=>n=>{let r=sa({...n,processors:t});return ca(e,r),la(r,e),ua(r,e)},pa=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=sa({...i??{},target:a,io:t,processors:n});return ca(e,o),la(o,e),ua(o,e)},ma={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ha=(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=ma[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}))])}},ga=(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)},_a=(e,t,n,r)=>{n.type=`boolean`},va=(e,t,n,r)=>{n.not={}},ya=(e,t,n,r)=>{let i=e._zod.def,a=We(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ba=(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}},xa=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Sa=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Ca=(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=ca(a.element,t,{...r,path:[...r.path,`items`]})},wa=(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]=ca(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=ca(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ta=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>ca(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ea=(e,t,n,r)=>{let i=e._zod.def,a=ca(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=ca(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]]},Da=(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=ca(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=ca(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=ca(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)}},Oa=(e,t,n,r)=>{let i=e._zod.def,a=ca(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`}]},ka=(e,t,n,r)=>{let i=e._zod.def;ca(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Aa=(e,t,n,r)=>{let i=e._zod.def;ca(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ja=(e,t,n,r)=>{let i=e._zod.def;ca(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)))},Ma=(e,t,n,r)=>{let i=e._zod.def;ca(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},Na=(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;ca(o,t,r);let s=t.seen.get(e);s.ref=o},Pa=(e,t,n,r)=>{let i=e._zod.def;ca(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Fa=(e,t,n,r)=>{let i=e._zod.def;ca(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ia=B(`ZodISODateTime`,(e,t)=>{nr.init(e,t),co.init(e,t)});function La(e){return Oi(Ia,e)}var Ra=B(`ZodISODate`,(e,t)=>{rr.init(e,t),co.init(e,t)});function za(e){return ki(Ra,e)}var Ba=B(`ZodISOTime`,(e,t)=>{ir.init(e,t),co.init(e,t)});function Va(e){return Ai(Ba,e)}var Ha=B(`ZodISODuration`,(e,t)=>{ar.init(e,t),co.init(e,t)});function Ua(e){return ji(Ha,e)}var Wa=B(`ZodError`,(e,t)=>{Dt.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>At(e,t)},flatten:{value:t=>kt(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ge,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ge,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ga=jt(Wa),Ka=Mt(Wa),qa=Nt(Wa),Ja=Ft(Wa),Ya=Lt(Wa),Xa=Rt(Wa),Za=zt(Wa),Qa=Bt(Wa),$a=Vt(Wa),eo=Ht(Wa),to=Ut(Wa),no=Wt(Wa),ro=new WeakMap;function io(e,t,n){let r=Object.getPrototypeOf(e),i=ro.get(r);if(i||(i=new Set,ro.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})}})}}}var ao=B(`ZodType`,(e,t)=>(Hn.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:pa(e,`input`),output:pa(e,`output`)}}),e.toJSONSchema=fa(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ga(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>qa(e,t,n),e.parseAsync=async(t,n)=>Ka(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ja(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ya(e,t,n),e.decode=(t,n)=>Xa(e,t,n),e.encodeAsync=async(t,n)=>Za(e,t,n),e.decodeAsync=async(t,n)=>Qa(e,t,n),e.safeEncode=(t,n)=>$a(e,t,n),e.safeDecode=(t,n)=>eo(e,t,n),e.safeEncodeAsync=async(t,n)=>to(e,t,n),e.safeDecodeAsync=async(t,n)=>no(e,t,n),io(e,`ZodType`,{check(...e){let t=this.def;return this.clone($e(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 lt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ss(e,t))},superRefine(e,t){return this.check(Cs(e,t))},overwrite(e){return this.check(Zi(e))},optional(){return is(this)},exactOptional(){return os(this)},nullable(){return cs(this)},nullish(){return is(cs(this))},nonoptional(e){return ms(this,e)},array(){return Bo(this)},or(e){return Wo([this,e])},and(e){return Jo(this,e)},transform(e){return vs(this,ns(e))},default(e){return us(this,e)},prefault(e){return fs(this,e)},catch(e){return gs(this,e)},pipe(e){return vs(this,e)},readonly(){return bs(this)},describe(e){let t=this.clone();return ii.add(t,{description:e}),t},meta(...e){if(e.length===0)return ii.get(this);let t=this.clone();return ii.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 ii.get(e)?.description},configurable:!0}),e)),oo=B(`_ZodString`,(e,t)=>{Un.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ha(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,io(e,`_ZodString`,{regex(...e){return this.check(Gi(...e))},includes(...e){return this.check(Ji(...e))},startsWith(...e){return this.check(Yi(...e))},endsWith(...e){return this.check(Xi(...e))},min(...e){return this.check(Ui(...e))},max(...e){return this.check(Hi(...e))},length(...e){return this.check(Wi(...e))},nonempty(...e){return this.check(Ui(1,...e))},lowercase(e){return this.check(Ki(e))},uppercase(e){return this.check(qi(e))},trim(){return this.check($i())},normalize(...e){return this.check(Qi(...e))},toLowerCase(){return this.check(ea())},toUpperCase(){return this.check(ta())},slugify(){return this.check(na())}})}),so=B(`ZodString`,(e,t)=>{Un.init(e,t),oo.init(e,t),e.email=t=>e.check(oi(lo,t)),e.url=t=>e.check(fi(po,t)),e.jwt=t=>e.check(Di(Oo,t)),e.emoji=t=>e.check(pi(mo,t)),e.guid=t=>e.check(si(uo,t)),e.uuid=t=>e.check(ci(fo,t)),e.uuidv4=t=>e.check(li(fo,t)),e.uuidv6=t=>e.check(ui(fo,t)),e.uuidv7=t=>e.check(di(fo,t)),e.nanoid=t=>e.check(mi(ho,t)),e.guid=t=>e.check(si(uo,t)),e.cuid=t=>e.check(hi(go,t)),e.cuid2=t=>e.check(gi(_o,t)),e.ulid=t=>e.check(_i(vo,t)),e.base64=t=>e.check(wi(To,t)),e.base64url=t=>e.check(Ti(Eo,t)),e.xid=t=>e.check(vi(yo,t)),e.ksuid=t=>e.check(yi(bo,t)),e.ipv4=t=>e.check(bi(xo,t)),e.ipv6=t=>e.check(xi(So,t)),e.cidrv4=t=>e.check(Si(Co,t)),e.cidrv6=t=>e.check(Ci(wo,t)),e.e164=t=>e.check(Ei(Do,t)),e.datetime=t=>e.check(La(t)),e.date=t=>e.check(za(t)),e.time=t=>e.check(Va(t)),e.duration=t=>e.check(Ua(t))});function H(e){return ai(so,e)}var co=B(`ZodStringFormat`,(e,t)=>{Wn.init(e,t),oo.init(e,t)}),lo=B(`ZodEmail`,(e,t)=>{qn.init(e,t),co.init(e,t)}),uo=B(`ZodGUID`,(e,t)=>{Gn.init(e,t),co.init(e,t)}),fo=B(`ZodUUID`,(e,t)=>{Kn.init(e,t),co.init(e,t)}),po=B(`ZodURL`,(e,t)=>{Jn.init(e,t),co.init(e,t)}),mo=B(`ZodEmoji`,(e,t)=>{Yn.init(e,t),co.init(e,t)}),ho=B(`ZodNanoID`,(e,t)=>{Xn.init(e,t),co.init(e,t)}),go=B(`ZodCUID`,(e,t)=>{Zn.init(e,t),co.init(e,t)}),_o=B(`ZodCUID2`,(e,t)=>{Qn.init(e,t),co.init(e,t)}),vo=B(`ZodULID`,(e,t)=>{$n.init(e,t),co.init(e,t)}),yo=B(`ZodXID`,(e,t)=>{er.init(e,t),co.init(e,t)}),bo=B(`ZodKSUID`,(e,t)=>{tr.init(e,t),co.init(e,t)}),xo=B(`ZodIPv4`,(e,t)=>{or.init(e,t),co.init(e,t)}),So=B(`ZodIPv6`,(e,t)=>{sr.init(e,t),co.init(e,t)}),Co=B(`ZodCIDRv4`,(e,t)=>{cr.init(e,t),co.init(e,t)}),wo=B(`ZodCIDRv6`,(e,t)=>{lr.init(e,t),co.init(e,t)}),To=B(`ZodBase64`,(e,t)=>{dr.init(e,t),co.init(e,t)}),Eo=B(`ZodBase64URL`,(e,t)=>{pr.init(e,t),co.init(e,t)}),Do=B(`ZodE164`,(e,t)=>{mr.init(e,t),co.init(e,t)}),Oo=B(`ZodJWT`,(e,t)=>{gr.init(e,t),co.init(e,t)}),ko=B(`ZodNumber`,(e,t)=>{_r.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ga(e,t,n,r),io(e,`ZodNumber`,{gt(e,t){return this.check(zi(e,t))},gte(e,t){return this.check(Bi(e,t))},min(e,t){return this.check(Bi(e,t))},lt(e,t){return this.check(Li(e,t))},lte(e,t){return this.check(Ri(e,t))},max(e,t){return this.check(Ri(e,t))},int(e){return this.check(Mo(e))},safe(e){return this.check(Mo(e))},positive(e){return this.check(zi(0,e))},nonnegative(e){return this.check(Bi(0,e))},negative(e){return this.check(Li(0,e))},nonpositive(e){return this.check(Ri(0,e))},multipleOf(e,t){return this.check(Vi(e,t))},step(e,t){return this.check(Vi(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 Ao(e){return Mi(ko,e)}var jo=B(`ZodNumberFormat`,(e,t)=>{vr.init(e,t),ko.init(e,t)});function Mo(e){return Ni(jo,e)}var No=B(`ZodBoolean`,(e,t)=>{yr.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_a(e,t,n,r)});function Po(e){return Pi(No,e)}var Fo=B(`ZodUnknown`,(e,t)=>{br.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Io(){return Fi(Fo)}var Lo=B(`ZodNever`,(e,t)=>{xr.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>va(e,t,n,r)});function Ro(e){return Ii(Lo,e)}var zo=B(`ZodArray`,(e,t)=>{Cr.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ca(e,t,n,r),e.element=t.element,io(e,`ZodArray`,{min(e,t){return this.check(Ui(e,t))},nonempty(e){return this.check(Ui(1,e))},max(e,t){return this.check(Hi(e,t))},length(e,t){return this.check(Wi(e,t))},unwrap(){return this.element}})});function Bo(e,t){return ra(zo,e,t)}var Vo=B(`ZodObject`,(e,t)=>{Or.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wa(e,t,n,r),Ze(e,`shape`,()=>t.shape),io(e,`ZodObject`,{keyof(){return Qo(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Io()})},loose(){return this.clone({...this._zod.def,catchall:Io()})},strict(){return this.clone({...this._zod.def,catchall:Ro()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return mt(this,e)},safeExtend(e){return ht(this,e)},merge(e){return gt(this,e)},pick(e){return ft(this,e)},omit(e){return pt(this,e)},partial(...e){return _t(rs,this,e[0])},required(...e){return vt(ps,this,e[0])}})});function Ho(e,t){return new Vo({type:`object`,shape:e??{},...V(t)})}var Uo=B(`ZodUnion`,(e,t)=>{Ar.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ta(e,t,n,r),e.options=t.options});function Wo(e,t){return new Uo({type:`union`,options:e,...V(t)})}var Go=B(`ZodDiscriminatedUnion`,(e,t)=>{Uo.init(e,t),jr.init(e,t)});function Ko(e,t,n){return new Go({type:`union`,options:t,discriminator:e,...V(n)})}var qo=B(`ZodIntersection`,(e,t)=>{Mr.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ea(e,t,n,r)});function Jo(e,t){return new qo({type:`intersection`,left:e,right:t})}var Yo=B(`ZodRecord`,(e,t)=>{Fr.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Da(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Xo(e,t,n){return!t||!t._zod?new Yo({type:`record`,keyType:H(),valueType:e,...V(t)}):new Yo({type:`record`,keyType:e,valueType:t,...V(n)})}var Zo=B(`ZodEnum`,(e,t)=>{Ir.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ya(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 Zo({...t,checks:[],...V(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 Zo({...t,checks:[],...V(r),entries:i})}});function Qo(e,t){return new Zo({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...V(t)})}var $o=B(`ZodLiteral`,(e,t)=>{Lr.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ba(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 es(e,t){return new $o({type:`literal`,values:Array.isArray(e)?e:[e],...V(t)})}var ts=B(`ZodTransform`,(e,t)=>{Rr.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sa(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 ns(e){return new ts({type:`transform`,transform:e})}var rs=B(`ZodOptional`,(e,t)=>{Br.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function is(e){return new rs({type:`optional`,innerType:e})}var as=B(`ZodExactOptional`,(e,t)=>{Vr.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function os(e){return new as({type:`optional`,innerType:e})}var ss=B(`ZodNullable`,(e,t)=>{Hr.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function cs(e){return new ss({type:`nullable`,innerType:e})}var ls=B(`ZodDefault`,(e,t)=>{Ur.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Aa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function us(e,t){return new ls({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ot(t)}})}var ds=B(`ZodPrefault`,(e,t)=>{Gr.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ja(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fs(e,t){return new ds({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ot(t)}})}var ps=B(`ZodNonOptional`,(e,t)=>{Kr.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ka(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ms(e,t){return new ps({type:`nonoptional`,innerType:e,...V(t)})}var hs=B(`ZodCatch`,(e,t)=>{Jr.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ma(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function gs(e,t){return new hs({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var _s=B(`ZodPipe`,(e,t)=>{Yr.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Na(e,t,n,r),e.in=t.in,e.out=t.out});function vs(e,t){return new _s({type:`pipe`,in:e,out:t})}var ys=B(`ZodReadonly`,(e,t)=>{Zr.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bs(e){return new ys({type:`readonly`,innerType:e})}var xs=B(`ZodCustom`,(e,t)=>{$r.init(e,t),ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xa(e,t,n,r)});function Ss(e,t={}){return ia(xs,e,t)}function Cs(e,t){return aa(e,t)}var ws={artificial_analysis_intelligence_index:{label:`Intelligence index`,scale:`index`},artificial_analysis_coding_index:{label:`Coding index`,scale:`index`},artificial_analysis_math_index:{label:`Math index`,scale:`index`},gpqa:{label:`GPQA Diamond`,scale:`fraction`},hle:{label:`Humanity's Last Exam`,scale:`fraction`},lcr:{label:`Long-context reasoning`,scale:`fraction`},livecodebench:{label:`LiveCodeBench`,scale:`fraction`},scicode:{label:`SciCode`,scale:`fraction`},math_500:{label:`MATH-500`,scale:`fraction`},aime:{label:`AIME`,scale:`fraction`},aime_25:{label:`AIME 2025`,scale:`fraction`},ifbench:{label:`IFBench`,scale:`fraction`},mmlu_pro:{label:`MMLU Pro`,scale:`fraction`},tau2:{label:`τ²-bench (agentic)`,scale:`fraction`},tau_banking:{label:`τ-bench banking`,scale:`fraction`},terminalbench_hard:{label:`Terminal-Bench Hard`,scale:`fraction`},terminalbench_v2_1:{label:`Terminal-Bench 2.1`,scale:`fraction`}};function Ts(e){return(e.credentialVariants??[]).filter(e=>!e.operatorOnly)}function Es(e){let t=new Set(e.map(e=>e.definition.id));return e.filter(e=>!e.definition.clientGroup||e.definition.clientGroup===e.definition.id||!t.has(e.definition.clientGroup))}function Ds(e,t){return e.filter(e=>e.definition.id===t||e.definition.clientGroup===t&&e.definition.id!==t)}function Os(e){return Es(e).filter(e=>e.definition.enabled&&e.definition.credentialClass!==`none`&&e.definition.poolOnly!==!0&&w(e.definition.id)&&!E(e.definition.id))}function ks(e){if(!e)return!1;try{let t=new URL(e).hostname.toLowerCase();return t===`127.0.0.1`||t===`localhost`||t===`::1`||t===`[::1]`}catch{return!1}}function As(e,t={}){let n=e.displayName,r=t.credentialClass??e.credentialClass,i=t.baseUrl??e.baseUrl;return e.id===`oonacode`?{kind:`pool`,badge:`via OonaCode`,detail:`Runs on OonaCode's own provider accounts, through the OonaCode gateway. Priced models are billed to your account in credits; free models cost nothing on any plan.`,viaGateway:!0}:e.engine===`agy`?{kind:`subscription-direct`,badge:`agy · direct to Google`,detail:`Runs on Google’s own agy CLI on this PC, with your Google plan. Each request is recorded here and goes straight from this PC to Google — never through the OonaCode gateway, and OonaCode does not translate it.`,viaGateway:!1}:e.route===`direct`?{kind:`subscription-direct`,badge:`direct to provider`,detail:`Your ${n} subscription runs straight from this PC to the provider — it never passes through the OonaCode gateway.`,viaGateway:!1}:r===`api_key`&&e.kind!==`anthropic-passthrough`?{kind:`own-key-translated`,badge:`direct to provider`,detail:`Your ${n} key stays on this PC: OonaCode translates the request here and calls ${n} from this machine. The gateway sees neither the key nor the traffic.`,viaGateway:!1}:ks(i)?{kind:`local-server`,badge:`on this machine`,detail:`Runs against ${n} on this machine (${i}) — the request never leaves the PC.`,viaGateway:!1}:r===`api_key`&&e.kind===`anthropic-passthrough`&&e.directCapable===!0?{kind:`own-key-direct`,badge:`direct to provider`,detail:`Your ${n} key runs straight from this PC to ${n} — the OonaCode gateway is not in the path.`,viaGateway:!1}:{kind:`gateway`,badge:`via OonaCode`,detail:`Routed to ${n} through the OonaCode gateway.`,viaGateway:!0}}var js=Ko(`type`,[Ho({type:es(`oauth-device`),deviceAuthorizationUrl:H().url(),tokenUrl:H().url(),clientId:H().min(1),scopes:Bo(H().min(1)).min(1),signInLabel:H().min(1).optional(),referrer:H().min(1).optional()}),Ho({type:es(`openai-device`),deviceAuthorizationUrl:H().url(),pollUrl:H().url(),tokenUrl:H().url(),verificationUri:H().url(),redirectUri:H().url(),clientId:H().min(1),signInLabel:H().min(1).optional()})]),Ms=Ho({type:es(`google-loopback`),authorizationUrl:H().url(),tokenUrl:H().url(),redirectUri:H().url(),scopes:Bo(H().min(1)).min(1),clientIdSetting:H().min(1),clientSecretSetting:H().min(1),userinfoUrl:H().url().optional(),signInLabel:H().min(1).optional()}),Ns=Ho({id:H().min(1),displayName:H().min(1),upstreamId:H().min(1).optional(),servedBy:Bo(H().min(1)).optional(),subscriptionServedBy:Bo(H().min(1)).optional(),contextWindow:Ao().int().positive().optional(),maxOutputTokens:Ao().int().positive().optional(),supportsTools:Po().optional(),supportsThinking:Po().optional(),effortLevels:Bo(Qo(ye)).optional(),helperModel:H().min(1).optional(),supportsVision:Po().optional(),inputPricePerM:Ao().nonnegative().optional(),outputPricePerM:Ao().nonnegative().optional(),creditsPerM:Ho({input:Ao().nonnegative(),output:Ao().nonnegative(),maxInput:Ao().nonnegative().optional(),maxOutput:Ao().nonnegative().optional()}).optional(),notes:H().optional(),free:Po().optional(),aaIntelligence:Ao().optional(),aaCoding:Ao().optional(),aaOutputTps:Ao().optional(),aaTtft:Ao().optional(),aa:Ho({fetchedAt:H(),creator:H().optional(),releaseDate:H().optional(),benchmarks:Xo(H(),Ao()).optional()}).loose().optional()}).loose(),Ps=Ho({id:H().regex(/^[a-z0-9][a-z0-9-]{1,40}$/,`provider id must be lowercase kebab-case`),displayName:H().min(1),kind:Qo([`anthropic-passthrough`,`openai-compatible`,`gemini`]),route:Qo([`gateway`,`direct`]),credentialClass:Qo([`api_key`,`subscription`,`none`]),baseUrl:H().url(),messagesPath:H().startsWith(`/`).optional(),modelsPath:H().startsWith(`/`).optional(),auth:Ho({header:Qo([`x-api-key`,`authorization-bearer`,`api-key`,`none`]),extraHeaders:Xo(H(),H()).optional()}),models:Bo(Ns),defaultModel:H().min(1),modelAliases:Xo(H(),H()).optional(),helperModel:H().min(1).optional(),capabilities:Ho({streaming:Po(),tools:Po(),thinking:Po(),vision:Po(),countTokens:Po(),promptCaching:Po(),promptCacheTtlSec:Ao().int().positive().optional()}),translate:Ho({maxTokensParam:Qo([`max_tokens`,`max_completion_tokens`]).optional(),reasoningEffortFromBudget:Po().optional(),reasoningContentField:H().nullable().optional(),supportsParallelToolCalls:Po().optional(),systemRole:Qo([`system`,`developer`]).optional(),streamIncludeUsage:Po().optional(),wire:Qo([`chat`,`responses`,`gemini-code-assist`]).optional()}).optional(),passthrough:Ho({stripCacheControl:Po().optional(),cacheChain:Po().optional(),toolSchemaRequiredArray:Po().optional(),toolDescriptionRequired:Po().optional(),keepOutputConfig:Po().optional(),allowedBetas:Bo(H()).optional(),anthropicVersion:H().optional()}).optional(),userBaseUrl:Po().optional(),engineEnv:Xo(H(),H()).optional(),directCapable:Po().optional(),subscriptionLogin:js.optional(),poolOnly:Po().optional(),phase:Wo([es(1),es(2)]),enabled:Po(),docsUrl:H().url().optional(),notes:H().optional(),references:Bo(Ho({label:H().min(1),url:H().url(),kind:Qo([`docs`,`pricing`,`models`,`console`,`status`,`keys`,`signup`,`other`]).optional()})).optional(),keyFormat:H().optional(),credentialVariants:Bo(Ho({id:H().min(1),label:H().min(1),header:Qo([`x-api-key`,`authorization-bearer`,`api-key`,`none`]).optional(),extraHeaders:Xo(H(),H()).optional(),operatorOnly:Po().optional(),requiresClaudeCodeIdentity:Po().optional(),subscriptionLogin:js.optional(),loopbackLogin:Ms.optional(),claudeCodeShape:Ho({betas:H().min(1),userAgent:H().min(1),billingHeader:H().min(1),headers:Xo(H(),H()).optional()}).optional(),baseUrl:H().url().optional(),keyFormat:H().optional(),notes:H().optional()})).optional(),adminGroup:H().optional(),clientGroup:H().optional(),recordLabel:H().optional(),engine:es(`agy`).optional(),effortLevels:Bo(Qo(ye)).optional()});Ho({version:Ao().int().positive(),updatedAt:H(),providers:Bo(Ps)});function Fs(e,t){return Is(e,Gs(e,t))}function Is(e,t){return e.models.find(e=>e.id===t)?.upstreamId??t}function Ls(e){return/^claude-/i.test(e)}function Rs(e){return/^claude-.+-\d{8}$/i.test(e)?e.replace(/-\d{8}$/,``):null}function zs(e){return e.replace(/\[1m\]$/i,``)}var Bs=new Set([`opus`,`sonnet`,`haiku`,`fable`]);function Vs(e){return Bs.has(e.toLowerCase())}function Hs(e,t){let n=zs(t);if(Vs(n)||e.models.some(e=>e.id===n))return null;let r=e.modelAliases;if(!r)return null;let i=Rs(n);if(i!==null&&e.models.some(e=>e.id===i))return null;let a=r[n]??(i===null?void 0:r[i]);return a!==void 0&&e.models.some(e=>e.id===a)?a:null}function Us(e,t){return{images:e.models.find(e=>e.id===t)?.supportsVision??e.capabilities.vision,documents:Ls(t)}}function Ws(e,t,n){let r=Us(e,t),i=new Set;for(let e of n){let t=e?.type;(t===`image`||t===`document`)&&i.add(t)}let a=e.models.find(e=>e.id===t)?.displayName??t;return i.has(`image`)&&!r.images?`${a} cannot read images. Remove the image, or pick a model that can — the model details say which.`:i.has(`document`)&&!r.documents?`${a} cannot read PDF documents — only Anthropic's Claude models take a PDF. Attach it as text, or pick a Claude model.`:null}function Gs(e,t){if(!t)return e.defaultModel;if(e.models.some(e=>e.id===t))return t;let n=e.modelAliases?.[t];if(n)return n;let r=Hs(e,t);if(r)return r;let i=t.toLowerCase(),a=i.includes(`haiku`)?`haiku`:i.includes(`opus`)?`opus`:i.includes(`sonnet`)?`sonnet`:i.includes(`fable`)?`fable`:null;if(a){if(e.modelAliases?.[a])return e.modelAliases[a];let t=e.models.find(e=>e.id.toLowerCase().includes(a));if(t)return t.id}return e.defaultModel}var Ks={messages:`/v1/messages`,countTokens:`/v1/messages/count_tokens`,models:`/v1/models`,providerMessages:e=>`/p/${e}/v1/messages`,providerCountTokens:e=>`/p/${e}/v1/messages/count_tokens`,providerModels:e=>`/p/${e}/v1/models`,voiceTranslation:`/v1/oonacode/voice-translation`,health:`/api/health`,streamCheck:`/api/stream-check`,register:`/api/auth/register`,login:`/api/auth/login`,refresh:`/api/auth/refresh`,logout:`/api/auth/logout`,me:`/api/auth/me`,prelogin:`/api/auth/prelogin`,tokens:`/api/me/tokens`,token:e=>`/api/me/tokens/${e}`,tokenPurge:e=>`/api/me/tokens/${e}/purge`,tokenUsage:e=>`/api/me/tokens/${e}/usage`,providers:`/api/me/providers`,provider:e=>`/api/me/providers/${e}`,providerTest:e=>`/api/me/providers/${e}/test`,routing:`/api/me/routing`,usage:`/api/me/usage`,usageSession:e=>`/api/me/usage/sessions/${e}`,usageBreakdown:`/api/me/usage/breakdown`,devices:`/api/me/devices`,pushToken:`/api/me/push-token`,hostNotify:`/api/me/hosts/notify`,device:e=>`/api/me/devices/${e}`,hosts:`/api/me/hosts`,hostHeartbeat:`/api/me/hosts/heartbeat`,hostVaultUnlock:e=>`/api/me/hosts/${encodeURIComponent(e)}/vault-unlock`,host:e=>`/api/me/hosts/${encodeURIComponent(e)}`,vault:`/api/me/vault`,vaultEvents:`/api/me/vault/events`,registry:`/api/registry`,agentTools:`/api/agent-tools`,agentToolCalls:`/api/me/agent-tools/calls`,releasesLatest:`/api/releases/latest`,releasesHistory:`/api/releases`,team:`/api/me/team`,teamInvites:`/api/me/team/invites`,teamInvite:e=>`/api/me/team/invites/${e}`,teamInviteLookup:`/api/team/invites/lookup`,teamInviteDecline:`/api/team/invites/decline`,teamJoin:`/api/me/team/join`,teamInvitations:`/api/me/team/invitations`,teamInvitationAccept:e=>`/api/me/team/invitations/${e}/accept`,teamInvitationDecline:e=>`/api/me/team/invitations/${e}/decline`,teamMember:e=>`/api/me/team/members/${e}`,teamLeave:`/api/me/team/leave`,teamTransfer:`/api/me/team/transfer`,teamAudit:`/api/me/team/audit`,teamCheckout:`/api/me/team/checkout`,teamTopup:`/api/me/team/topup`,teamSeats:`/api/me/team/seats`,googleConfig:`/api/auth/google/config`,googleStart:`/api/auth/google/start`,googleCallback:`/api/auth/google/callback`,githubConfig:`/api/auth/github/config`,githubStart:`/api/auth/github/start`,githubCallback:`/api/auth/github/callback`,googleUnlink:`/api/me/google`,telegramConfig:`/api/auth/telegram/config`,telegramAuth:`/api/auth/telegram`,telegram:`/api/me/telegram`,telegramWebhook:`/api/webhooks/telegram`,passphraseSetup:`/api/auth/passphrase/setup`,passphraseRekey:`/api/me/passphrase/rekey`,recovery:`/api/me/recovery`,recoveryChallenge:`/api/auth/recovery/challenge`,recoveryConsume:`/api/auth/recovery/consume`,deviceApprovals:`/api/me/device-approvals`,deviceApproval:e=>`/api/me/device-approvals/${e}`,deviceApprovalApprove:e=>`/api/me/device-approvals/${e}/approve`,deviceApprovalDeny:e=>`/api/me/device-approvals/${e}/deny`,passwordResetRequest:`/api/auth/password-reset/request`,passwordResetConfirm:`/api/auth/password-reset/confirm`,vaultRekeyComplete:`/api/me/vault/rekey-complete`,vaultRekeyPending:`/api/me/vault/rekey-pending`,emailVerifySend:`/api/auth/email/verify/send`,emailVerifyConfirm:`/api/auth/email/verify/confirm`,emailVerifyWatch:`/api/auth/email/verify/watch`,twoFactor:`/api/me/2fa`,twoFactorEnroll:`/api/me/2fa/enroll`,twoFactorConfirm:`/api/me/2fa/confirm`,twoFactorDisable:`/api/me/2fa/disable`,twoFactorDisableRequest:`/api/me/2fa/disable/request`,twoFactorRecoveryCodes:`/api/me/2fa/recovery-codes`,twoFactorVerify:`/api/auth/2fa/verify`,deviceLinkStart:`/api/auth/device/start`,deviceLinkPoll:`/api/auth/device/poll`,deviceLinks:`/api/me/device-links`,deviceLink:e=>`/api/me/device-links/${e}`,deviceLinkApprove:e=>`/api/me/device-links/${e}/approve`,deviceLinkDeny:e=>`/api/me/device-links/${e}/deny`,hostLogs:`/api/me/hosts/logs`,errorReport:`/api/me/errors`,bugReports:`/api/me/bug-reports`,plans:`/api/plans`,myPlan:`/api/me/plan`,checkout:`/api/me/plan/checkout`,creditsTopup:`/api/me/credits/topup`,billing:`/api/me/billing`},qs=2048,Js=16384,Ys=8e3,Xs=5242880,Zs=12582912;new Set(`BCDFGHJKLMNPQRSTVWXZ`.split(``));var Qs=`discard-my-vault-and-history`,$s=`Anyone who can use this device can use your saved provider keys without your passphrase. Turn this off on shared or public computers. You can revoke it any time from Devices.`,ec={name:120,instructions:2e4,goal:2e3,repositories:50,repositoryUrl:500,memory:2e4,minIntervalFloor:1,minIntervalCeiling:10080},tc=`⏰ Scheduled task "`;function nc(e){if(!e.startsWith(tc))return null;let t=e.indexOf(`"
|
|
76
76
|
|
|
77
|
-
`,18);return t<0?null:{title:e.slice(18,t),prompt:e.slice(t+3)}}Object.freeze({tengu_amber_sentinel:!0,tengu_groovy_eclipse:!0,tengu_humble_hammock:!0});function rc(e){return e===null||!Number.isFinite(e)?`neutral`:e>30?`ok`:e>10?`warn`:`danger`}var ic=[`mon`,`tue`,`wed`,`thu`,`fri`,`sat`,`sun`],ac=/^([01]\d|2[0-3]):[0-5]\d$/;Ho({tz:H().min(1),windows:Bo(Ho({from:H().regex(ac,`HH:MM`),to:H().regex(ac,`HH:MM`),days:Bo(Qo(ic)).optional(),kind:Qo([`peak`,`offpeak`])})),offpeakDiscount:Ao().nonnegative().max(1).optional()});var oc=[`priceInputCacheMissPeak`,`priceInputCacheMissOffpeak`,`priceInputCacheHitPeak`,`priceInputCacheHitOffpeak`,`priceCacheWritePeak`,`priceCacheWriteOffpeak`,`priceOutputPeak`,`priceOutputOffpeak`],sc=Ho({inputCacheMiss:Ao().nonnegative(),inputCacheHit:Ao().nonnegative().optional(),cacheWrite:Ao().nonnegative().optional(),output:Ao().nonnegative()});Ho({by:es(`prompt_tokens`),tiers:Bo(Ho({upToPromptTokens:Ao().int().positive().optional(),price:sc.optional(),cost:sc.optional()})).min(1),note:H().optional()}).superRefine((e,t)=>{let n=0;e.tiers.forEach((r,i)=>{!r.cost&&!r.price&&t.addIssue({code:`custom`,message:`a tier needs its cost (the provider’s rates; retail is cost × the record’s ratio)`,path:[`tiers`,i,`cost`]});let a=r.upToPromptTokens;if(a===void 0){i!==e.tiers.length-1&&t.addIssue({code:`custom`,message:`only the LAST tier may omit upToPromptTokens`,path:[`tiers`,i]});return}a<=n&&t.addIssue({code:`custom`,message:`tiers must ascend: ${a} does not exceed ${n}`,path:[`tiers`,i,`upToPromptTokens`]}),n=a})}),[...oc];var cc={realtime:`/v1/realtime`,translations:`/v1/realtime/translations`,live:`/v1/live/sessions`,speechStream:`/v1/audio/speech/stream`,transcriptionStream:`/v1/audio/transcriptions/stream`,clientSecrets:`/v1/realtime/client_secrets`,translationClientSecrets:`/v1/realtime/translations/client_secrets`};cc.realtime,cc.translations,cc.live,cc.speechStream,cc.transcriptionStream;var lc=`M0.72 12a11.28 11.28 0 1 0 22.56 0a11.28 11.28 0 1 0 -22.56 0ZM4.8 12a7.2 7.2 0 1 0 14.4 0a7.2 7.2 0 1 0 -14.4 0ZM7.44 12a4.56 4.56 0 1 0 9.12 0a4.56 4.56 0 1 0 -9.12 0Z`,uc=`M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z`,dc=`M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z`,fc=`M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81`,pc={oonacode:{hex:`#000000`,owner:`OonaCode`,d:lc,fillRule:`evenodd`},anthropic:{hex:`#D97757`,owner:`Anthropic`,d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`},"anthropic-subscription":{hex:`#D97757`,owner:`Anthropic`,d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`},openai:{hex:`#000000`,owner:`OpenAI`,d:dc},xai:{hex:`#000000`,owner:`xAI`,d:uc},deepseek:{hex:`#5786FE`,owner:`DeepSeek`,d:`M23.748 4.651c-.254-.124-.364.113-.512.233-.051.04-.094.09-.137.137-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.155-.708-.311-.955-.65-.172-.24-.219-.509-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.094.172.187.129.323-.082.28-.18.553-.266.833-.055.179-.137.218-.328.14a5.5 5.5 0 0 1-1.737-1.179c-.857-.828-1.631-1.743-2.597-2.46a12 12 0 0 0-.689-.47c-.985-.957.13-1.743.387-1.836.27-.098.094-.433-.778-.428-.872.003-1.67.295-2.687.685a3 3 0 0 1-.465.136 9.6 9.6 0 0 0-2.883-.101c-1.885.21-3.39 1.1-4.497 2.622C.082 8.776-.231 10.854.152 13.02c.403 2.284 1.568 4.175 3.36 5.653 1.857 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.132-.284 4.994-1.86.47.234.962.328 1.78.398.629.058 1.235-.031 1.705-.129.735-.155.684-.836.418-.961-2.155-1.004-1.682-.595-2.112-.926 1.095-1.295 2.768-3.598 3.284-6.733.05-.346.115-.834.108-1.114-.004-.171.035-.238.23-.257a4.2 4.2 0 0 0 1.545-.475c1.397-.763 1.96-2.016 2.093-3.517.02-.23-.004-.467-.247-.588M11.58 18.168c-2.088-1.642-3.101-2.183-3.52-2.16-.39.024-.32.472-.234.763.09.288.207.487.371.74.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.168-1.361-.801-2.5-1.86-3.301-3.306-.775-1.393-1.225-2.888-1.299-4.482-.02-.385.094-.522.477-.592a4.7 4.7 0 0 1 1.53-.038c2.131.311 3.946 1.264 5.467 2.774.868.86 1.525 1.887 2.202 2.89.72 1.066 1.494 2.082 2.48 2.915.348.291.626.513.892.677-.802.09-2.14.109-3.055-.615zm1.001-6.44a.306.306 0 0 1 .415-.287.3.3 0 0 1 .113.074.3.3 0 0 1 .086.214c0 .17-.136.307-.308.307a.303.303 0 0 1-.306-.307m3.11 1.596c-.2.081-.4.151-.591.16a1.25 1.25 0 0 1-.798-.254c-.274-.23-.47-.358-.551-.758a1.7 1.7 0 0 1 .015-.588c.07-.327-.007-.537-.238-.727-.188-.156-.426-.199-.689-.199a.6.6 0 0 1-.254-.078.253.253 0 0 1-.114-.358 1 1 0 0 1 .192-.21c.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.392.451.462.576.685.915.176.264.336.536.446.848.066.194-.02.353-.25.45`},kimi:{hex:`#000000`,owner:`Moonshot`,d:`M21.765.351C22.998.351 24 1.353 24 2.586S22.998 4.82 21.765 4.82h-1.974c-.15 0-.26-.12-.26-.26V2.586A2.237 2.237 0 0 1 21.765.35M9.41 13.388l8.447-8.377c.16-.16.07-.471-.14-.471h-4.55s-.1.02-.14.06l-9.099 9.029c-.14.14-.35.02-.35-.21V4.81c0-.15-.1-.27-.221-.27H.22c-.12 0-.22.12-.22.27v18.57c0 .15.1.27.22.27h3.137c.12 0 .22-.12.22-.27v-3.79c0-.08.03-.16.08-.21l2.826-2.796c.07-.07.16-.08.241-.03l7.546 5.551a8.9 8.9 0 0 0 4.018 1.493c.12.01.23-.11.23-.27V19.76c0-.14-.08-.25-.19-.26a5.8 5.8 0 0 1-2.355-.942l-6.533-4.73c-.14-.09-.15-.32-.03-.441`},qwen:{hex:`#6950EF`,owner:`Alibaba`,d:`M23.919 14.545 20.817 9.17l1.47-2.544a.56.56 0 0 0 0-.566l-1.633-2.83a.57.57 0 0 0-.49-.283h-6.207L12.487.402a.57.57 0 0 0-.49-.284H8.732a.56.56 0 0 0-.49.284L5.139 5.775h-2.94a.56.56 0 0 0-.49.284L.077 8.887a.56.56 0 0 0 0 .567L3.18 14.83l-1.47 2.545a.56.56 0 0 0 0 .566l1.634 2.83a.57.57 0 0 0 .49.283h6.205l1.47 2.545a.57.57 0 0 0 .49.284h3.266a.57.57 0 0 0 .49-.284l3.104-5.375h2.94a.57.57 0 0 0 .49-.283l1.634-2.828a.55.55 0 0 0-.004-.568M8.733.686l1.634 2.828-1.634 2.828H21.8L20.164 9.17H7.425L5.63 6.06Zm1.306 19.801-6.205-.002 1.634-2.83h3.265L2.201 6.344h3.267q3.182 5.517 6.367 11.032zm10.124-5.66L18.53 12l-6.532 11.315-1.634-2.83c2.129-3.673 4.25-7.351 6.373-11.028h3.592l3.102 5.374z`},"xai-subscription":{hex:`#000000`,owner:`xAI`,d:uc},"openai-subscription":{hex:`#000000`,owner:`OpenAI`,d:dc},"google-agy":{hex:`#8E75B2`,owner:`Google`,d:fc},antigravity:{hex:`#8E75B2`,owner:`Google`,d:fc},glm:{hex:`#2D2D2D`,owner:`Z.ai`,d:`M12.606 1.806l-1.677 2.388c-0.258 0.374-0.697 0.606-1.161 0.606h-9.162V1.794C0.594 1.806 12.606 1.806 12.606 1.806zM24 1.806L9.6 22.206 0 22.206 14.4 1.806zM11.394 22.206l1.69-2.4c0.258-0.374 0.697-0.606 1.161-0.606h9.149v3.006H11.394z`},mimo:{hex:`#FF6900`,owner:`Xiaomi`,d:`M12 0C8.016 0 4.756.255 2.493 2.516.23 4.776 0 8.033 0 12.012c0 3.98.23 7.235 2.494 9.497C4.757 23.77 8.017 24 12 24c3.983 0 7.243-.23 9.506-2.491C23.77 19.247 24 15.99 24 12.012c0-3.984-.233-7.243-2.502-9.504C19.234.252 15.978 0 12 0zM4.906 7.405h5.624c1.47 0 3.007.068 3.764.827.746.746.827 2.233.83 3.676v4.54a.15.15 0 0 1-.152.147h-1.947a.15.15 0 0 1-.152-.148V11.83c-.002-.806-.048-1.634-.464-2.051-.358-.36-1.026-.441-1.72-.458H7.158a.15.15 0 0 0-.151.147v6.98a.15.15 0 0 1-.152.148H4.906a.15.15 0 0 1-.15-.148V7.554a.15.15 0 0 1 .15-.149zm12.131 0h1.949a.15.15 0 0 1 .15.15v8.892a.15.15 0 0 1-.15.148h-1.949a.15.15 0 0 1-.151-.148V7.554a.15.15 0 0 1 .151-.149zM8.92 10.948h2.046c.083 0 .15.066.15.147v5.352a.15.15 0 0 1-.15.148H8.92a.15.15 0 0 1-.152-.148v-5.352a.15.15 0 0 1 .152-.147Z`}};function mc(e){return pc[e]??null}function hc(e){let t=e.replace(/\(.*?\)/g,` `).split(/[\s/_-]+/).filter(Boolean);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():`${t[0][0]}${t[1][0]}`.toUpperCase()}var gc=9230,_c=1024,vc=65534,yc=`127.0.0.1`;Object.freeze({enabled:!1,port:gc,inspectMain:!1}),Object.freeze({port:null,listening:!1,fromCommandLine:!1,inspectPort:null,inspectProblem:null});function bc(e){return e+1}function xc(e){return typeof e==`number`&&Number.isInteger(e)}function Sc(e){return!xc(e)||e<1024||e>65534?`The port must be a whole number from ${_c.toLocaleString(`en-US`)} to ${vc.toLocaleString(`en-US`)} (the main-process inspector takes the next one).`:null}function Cc(e){return e.port!==null||e.inspectPort!==null}function wc(e,t){let n=e.enabled?e.port:null,r=e.enabled&&e.inspectMain?bc(e.port):null;return!t.fromCommandLine&&t.port!==n||t.inspectPort!==r}function Tc(e){let t=[];return e.port!==null&&t.push(`${yc}:${e.port}`),e.inspectPort!==null&&t.push(`${yc}:${e.inspectPort}`),t.length===2?`${t[0]} (windows) and ${t[1]} (main process)`:e.inspectPort===null?t[0]??``:`${t[0]} (main process)`}var Ec=[`stable`,`dev`];function Dc(e){return typeof e==`string`&&Ec.includes(e)}function Oc(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return Dc(t)?t:null}var kc=[`win32`,`linux`,`darwin`],Ac=[`x64`,`arm64`];function jc(e,t){let n=Oc(e)??`stable`,r=[];return n!==`stable`&&r.push(`channel=${encodeURIComponent(n)}`),t&&kc.includes(t.platform)&&(r.push(`platform=${t.platform}`),t.arch&&Ac.includes(t.arch)&&r.push(`arch=${t.arch}`)),r.length>0?`${Ks.releasesLatest}?${r.join(`&`)}`:Ks.releasesLatest}function Mc(e,t){let n=Oc(t)??`stable`;return n===`stable`?e:`${e} (${n})`}var Nc=5e4,Pc=6,Fc=[`bg`,`surface`,`surface-2`,`surface-3`,`border`,`fg`,`fg-muted`,`fg-faint`,`accent`,`accent-fg`,`accent-soft`,`project`,`ok`,`ok-soft`,`warn`,`warn-soft`,`danger`,`danger-soft`,`think`,`think-soft`,`code-bg`,`user-bubble`],Ic={agentFinished:!1,permissionRequired:!0,errorOccurred:!0},Lc={autoAcceptPermissions:!1,showReasoningSummaries:!0,notifications:Ic,showAgentPicker:!0,transcriptWindowSize:500,openTabs:[],draftTabs:[],draftTitles:{},activeTab:null,editorLayout:null,remoteTabs:{},sessionPanelOpen:!1,explorerOpen:!1,sidebarWidth:288,sidebarPinned:!0,dismissedUpdateVersion:null,lastSeenReleaseNotes:null,claudeImportOffered:!1,claudeImportOffers:0,collapsedProjects:[],themeColors:{light:{},dark:{}},pinned:[],sidebarView:`recent`};function Rc(e){return Math.min(Math.max(typeof e==`number`&&Number.isFinite(e)?Math.floor(e):0,0),3)}function zc(e){return Math.min(640,Math.max(200,typeof e==`number`&&Number.isFinite(e)?Math.round(e):288))}function Bc(e){return Math.min(Nc,Math.max(100,typeof e==`number`&&Number.isFinite(e)?Math.round(e):500))}function Vc(e,t){return typeof e==`boolean`?e:t}function Hc(e){return typeof e==`string`&&e.length>0&&e.length<=64?e:null}function Uc(e,t=50){if(!Array.isArray(e))return[];let n=[];for(let r of e)if(!(typeof r!=`string`||r.length===0||r.length>200)&&!n.includes(r)&&(n.push(r),n.length>=t))break;return n}function Wc(e,t=50){if(typeof e!=`object`||!e||Array.isArray(e))return{};let n={};for(let[r,i]of Object.entries(e))if(!(r.length===0||r.length>200)&&!(typeof i!=`string`||i.length===0||i.length>200)&&(n[r]=i,Object.keys(n).length>=t))break;return n}function Gc(e){if(typeof e!=`string`)return null;let t=e.trim();return/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():null}function Kc(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(!Fc.includes(n))continue;let e=Gc(r);e!==null&&(t[n]=e)}return t}function qc(e){let t=typeof e==`object`&&e?e:{};return{light:Kc(t.light),dark:Kc(t.dark)}}function Jc(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=n.kind,r=n.id;if((e===`chat`||e===`project`)&&!(typeof r!=`string`||r.length===0||r.length>200)&&!t.some(t=>t.kind===e&&t.id===r)&&(t.push({kind:e,id:r}),t.length>=50))break}return t}function Yc(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return null;let n=e,r=new Set(t),i=new Set,a=0,o=(e,t)=>{if(t>Pc||typeof e!=`object`||!e)return null;let n=e,s=n.group;if(typeof s==`object`&&s&&!Array.isArray(s)){if(a>=8)return null;let e=s,t=[];for(let n of Array.isArray(e.tabs)?e.tabs:[])typeof n!=`string`||!r.has(n)||i.has(n)||(i.add(n),t.push(n));return t.length===0?null:(a+=1,{group:{tabs:t,active:(typeof e.active==`string`&&t.includes(e.active)?e.active:null)??t[t.length-1]}})}let c=n.split;if(c!==`row`&&c!==`column`)return null;let l=Array.isArray(n.children)?n.children:[],u=Array.isArray(n.sizes)?n.sizes:[],d=[],f=[];if(l.slice(0,8).forEach((e,n)=>{let r=o(e,t+1);if(!r)return;d.push(r);let i=u[n];f.push(typeof i==`number`&&Number.isFinite(i)&&i>0?i:0)}),d.length===0)return null;if(d.length===1)return d[0];let p=f.filter(e=>e>0),m=p.length>0?p.reduce((e,t)=>e+t,0)/p.length:1,h=f.map(e=>e>0?e:m),g=h.reduce((e,t)=>e+t,0);return{split:c,sizes:h.map(e=>e/g),children:d}},s=o(n.root,0);if(!s||a<2)return null;let c=n.focused;return{root:s,focused:typeof c==`number`&&Number.isInteger(c)&&c>=0&&c<a?c:0}}function Xc(e,t,n){return e.some(e=>e.kind===t&&e.id===n)}function Zc(e,t,n,r){return r===Xc(e,t,n)?e:r?[...e.length>=50?e.slice(e.length-50+1):e,{kind:t,id:n}]:e.filter(e=>e.kind!==t||e.id!==n)}function Qc(e){let t=typeof e==`object`&&e?e:{},n=typeof t.notifications==`object`&&t.notifications!==null?t.notifications:{},r=Uc(t.openTabs),i=Uc(t.draftTabs).filter(e=>!r.includes(e)),a={};for(let[e,n]of Object.entries(Wc(t.draftTitles)))i.includes(e)&&(a[e]=n);let o=[...r,...i],s=t.activeTab,c=typeof s==`string`&&o.includes(s)?s:o[o.length-1]??null;return{autoAcceptPermissions:Vc(t.autoAcceptPermissions,Lc.autoAcceptPermissions),showReasoningSummaries:Vc(t.showReasoningSummaries,Lc.showReasoningSummaries),notifications:{agentFinished:Vc(n.agentFinished,Ic.agentFinished),permissionRequired:Vc(n.permissionRequired,Ic.permissionRequired),errorOccurred:Vc(n.errorOccurred,Ic.errorOccurred)},showAgentPicker:Vc(t.showAgentPicker,Lc.showAgentPicker),transcriptWindowSize:Bc(t.transcriptWindowSize),openTabs:r,draftTabs:i,draftTitles:a,activeTab:c,editorLayout:Yc(t.editorLayout,o),remoteTabs:Wc(t.remoteTabs),sessionPanelOpen:Vc(t.sessionPanelOpen,Lc.sessionPanelOpen),explorerOpen:Vc(t.explorerOpen,Lc.explorerOpen),sidebarWidth:zc(t.sidebarWidth),sidebarPinned:Vc(t.sidebarPinned,Lc.sidebarPinned),dismissedUpdateVersion:Hc(t.dismissedUpdateVersion),lastSeenReleaseNotes:Hc(t.lastSeenReleaseNotes),claudeImportOffered:Vc(t.claudeImportOffered,Lc.claudeImportOffered),claudeImportOffers:Rc(t.claudeImportOffers),collapsedProjects:Uc(t.collapsedProjects),themeColors:qc(t.themeColors),pinned:Jc(t.pinned),sidebarView:t.sidebarView===`projects`?`projects`:`recent`}}new Set(Object.keys(Lc));var $c=3650,el=[{version:`0.3.209`,date:`2026-10-05`,platforms:[`win32`,`darwin`],added:[`Scheduled tasks say which model a run uses: always the chat’s model at the moment the task fires, named in the Scheduled tasks panel.`],fixed:[`A Google Gemini chat keeps Google’s agent running for half an hour between messages, so the next message after a pause no longer waits about four seconds for agy to start.`,`Commands run in a Google Gemini chat reach servers on your own PC (localhost) and plain http:// sites again.`]},{version:`0.3.209`,date:`2026-10-05`,platforms:[`linux`],added:[`Grok 4.7, xAI’s newest model, on the OonaCode pool and on your own SuperGrok subscription — and an effort picker for Grok 4.7, 4.6 and 4.5 (low, medium, high, extra high), sent the way xAI’s own Grok CLI sends it.`,`Every provider in the model picker shows its own logo — Google’s Gemini mark for Google, xAI’s for your SuperGrok, OpenAI’s for your ChatGPT plan, Z.ai’s for GLM — instead of two letters.`,`Scheduled tasks say which model a run uses: always the chat’s model at the moment the task fires, named in the Scheduled tasks panel.`],fixed:[`When a subscription behind the OonaCode pool refuses or fails a request, the same request is answered at once from the provider’s API key instead of showing you the error.`,`Grok on your own SuperGrok subscription and on the OonaCode pool works again: xAI started refusing the Grok CLI identity OonaCode presented as outdated.`,`When your own subscription’s sign-in stops working, the chat now says so and asks you to sign in again, instead of a confusing “own-subscription providers run directly to the provider” error.`,`A Google Gemini chat keeps Google’s agent running for half an hour between messages, so the next message after a pause no longer waits about four seconds for agy to start.`,`Commands run in a Google Gemini chat reach servers on your own PC (localhost) and plain http:// sites again.`]},{version:`0.3.208`,date:`2026-10-04`,platforms:[`win32`,`darwin`],added:[`Grok 4.7, xAI’s newest model, on the OonaCode pool and on your own SuperGrok subscription — and an effort picker for Grok 4.7, 4.6 and 4.5 (low, medium, high, extra high), sent the way xAI’s own Grok CLI sends it.`,`Every provider in the model picker shows its own logo — Google’s Gemini mark for Google, xAI’s for your SuperGrok, OpenAI’s for your ChatGPT plan, Z.ai’s for GLM — instead of two letters.`],fixed:[`When a subscription behind the OonaCode pool refuses or fails a request, the same request is answered at once from the provider’s API key instead of showing you the error.`,`Grok on your own SuperGrok subscription and on the OonaCode pool works again: xAI started refusing the Grok CLI identity OonaCode presented as outdated.`,`When your own subscription’s sign-in stops working, the chat now says so and asks you to sign in again, instead of a confusing “own-subscription providers run directly to the provider” error.`]},{version:`0.3.207`,date:`2026-10-04`,added:[`Every chat lists every provider you have connected and the OonaCode pool — Google Gemini too, whatever the chat ran on before. Switching keeps the conversation: a chat moving off Google continues with its whole history, and a chat moving onto Google gives Google’s agent the conversation so far, so it can carry on.`],fixed:[`Two messages sent a moment apart while a chat was starting no longer leave one of them stuck in the queued strip: the engine had read them together as one message, and OonaCode now recognises that.`]},{version:`0.3.206`,date:`2026-10-04`,platforms:[`win32`],added:[`Google Gemini installs Google’s agy by itself the first time you use it — open the provider in Settings → Providers, or send a message to a Google Gemini chat — instead of waiting for you to press Install.`],fixed:[`Deleting a chat now says what really happens: a chat is kept only on the PC it runs on, so deleting it there removes it everywhere.`,`oona doctor no longer tells you to change settings that OonaCode stopped reading.`]},{version:`0.3.206`,date:`2026-10-04`,platforms:[`linux`],added:[`Gemini on your own Google plan, through Google’s own agent. Open Settings → Providers → Google Gemini: OonaCode downloads Google’s agy for you and checks it. Then press Sign in with Google, sign in on Google’s own page and paste the one-time code back within the minute agy allows. OonaCode never sees your password. Every model your Google plan offers through agy is listed — Gemini 3.8, 3.7 and 3.6 Flash, Gemini 3.1 Pro, and Claude Opus 5.5, Claude Sonnet 5.5 and GPT-OSS 120B marked “via Google”. A Google Gemini chat runs Google’s agent as it is (Build or Autonomous mode, text only), and the chat’s info panel lists every request it made to Google.`,`Every provider in the model picker ends with a “Custom model…” row: type any model id and the chat runs it on that provider.`],fixed:[`The agents badge highlights what is happening now: “4 working” is blue and the total is grey.`,`Deleting a chat now says what really happens: a chat is kept only on the PC it runs on, so deleting it there removes it everywhere.`]},{version:`0.3.206`,date:`2026-10-04`,platforms:[`darwin`],added:[`Gemini on your own Google plan, through Google’s own agent. Open Settings → Providers → Google Gemini: OonaCode downloads Google’s agy for you and checks it. Then press Sign in with Google, sign in on Google’s own page and paste the one-time code back within the minute agy allows. OonaCode never sees your password. Every model your Google plan offers through agy is listed — Gemini 3.8, 3.7 and 3.6 Flash, Gemini 3.1 Pro, and Claude Opus 5.5, Claude Sonnet 5.5 and GPT-OSS 120B marked “via Google”. A Google Gemini chat runs Google’s agent as it is (Build or Autonomous mode, text only), and the chat’s info panel lists every request it made to Google.`,`Every provider in the model picker ends with a “Custom model…” row: type any model id and the chat runs it on that provider.`],fixed:[`The agents badge highlights what is happening now: “4 working” is blue and the total is grey.`,`The command line’s reinstall hint on a Mac is the one that works: curl -fsSL https://oonacode.oonak.ai/install.sh | bash.`]},{version:`0.3.205`,date:`2026-10-04`,platforms:[`win32`],added:[`Google Gemini now lists every model your Google plan offers through agy, not only Gemini: Claude Opus 5.5, Claude Sonnet 5.5 and GPT-OSS 120B (marked “via Google”) sit beside Gemini 3.8, 3.7 and 3.6 Flash and Gemini 3.1 Pro. They run on Google’s own agent with your Google plan, and have their own usage window.`],fixed:[]},{version:`0.3.204`,date:`2026-10-04`,platforms:[`win32`],added:[`Signing in to Google Gemini opens Google’s page for you and shows how many seconds are left: Google’s agy waits only one minute for the sign-in. Paste the code Google shows and it is sent at once.`],fixed:[`Signing in to Google Gemini finishes. The code you pasted never reached Google’s agy in the installed app (the window it types into dropped everything typed), so the sign-in waited out its minute and failed.`,`The Claude sign-in’s “paste the code” box, which used the same window, can type the code too.`]},{version:`0.3.203`,date:`2026-10-04`,platforms:[`win32`],added:[`Gemini on your own Google plan, through Google’s own agent. Open Settings → Providers → Google Gemini and press Install: OonaCode downloads Google’s agy for you and checks it. Then press Sign in with Google, sign in on Google’s own page and paste the one-time code back here. OonaCode never sees your password. A Google Gemini chat runs Google’s agent as it is (Build or Autonomous mode, text only, no pictures), and the chat’s info panel lists every request it made to Google.`,`Every provider in the model picker ends with a “Custom model…” row: type any model id and the chat runs it on that provider.`],fixed:[`The agents badge highlights what is happening now: “4 working” is blue and the total (“51 agents”) is grey, instead of the other way round.`]},{version:`0.3.202`,date:`2026-10-03`,platforms:[`darwin`],added:[`OonaCode runs on macOS 12 or newer: the agent, your chats, the background service and the desktop app, installed with the same one line as on Linux — curl -fsSL https://oonacode.oonak.ai/install.sh | bash. An Intel build; Apple Silicon Macs run it through Rosetta 2. Your sign-in key is kept in your login keychain.`,`Updating is the same line again, oona update in a terminal, or the update button in the app: it closes OonaCode, puts the new version in place and opens it again. The app is not signed by Apple yet, so it cannot be downloaded from a browser and does not update itself the way it does on Windows.`],fixed:[]},{version:`0.3.202`,date:`2026-10-03`,platforms:[`linux`],added:[],fixed:[`Your sign-in survives a restart on a PC that keeps OonaCode’s key in the login keyring (GNOME Keyring, KWallet): two of OonaCode’s keys shared one keyring entry and overwrote each other, and every start of the host wrote over the stored key — so after a restart you could find yourself signed out.`,`OonaCode never runs a Claude Code you installed yourself as its engine, even when it sits in the same folder as the Node.js that runs OonaCode (an nvm folder, for example).`,`oona update installs from the site your OonaCode was installed from, not always from oonacode.oonak.ai.`]},{version:`0.3.202`,date:`2026-10-03`,platforms:[`win32`],added:[],fixed:[`OonaCode never runs a Claude Code you installed yourself as its engine, even when it sits in the same folder as the Node.js that runs OonaCode.`]},{version:`0.3.201`,date:`2026-10-03`,added:[`The Tools menu lists only tools that work. Desktop control, Clipboard, Screen capture and Run as administrator were demos that never ran anything, and they are gone: the agent already reads and sets your clipboard, takes screenshots and asks Windows for administrator rights through its own commands.`],fixed:[`Oonak Browser keeps working when its window is behind other windows. A browser covered by the OonaCode window used to crawl, and some clicks and scrolls gave up after 30 seconds.`,`Oonak Browser no longer clicks a hidden copy of a link, or a link inside a closed menu, when a site has both a visible and a hidden one.`,`A message you send right after a reply failed no longer stays pinned above the box as “queued” once the agent has read it.`]},{version:`0.3.200`,date:`2026-10-03`,platforms:[`win32`],added:[`Everything OonaCode shows you is in credits, never in dollars: the model picker gives what an OonaCode pool model charges per 1M tokens in credits, and a chat’s spend, Usage, Conversations, Listen and the terminal all count credits. A chat on your own key or your own subscription says so instead of a price.`],fixed:[`Oonak Browser works on sites built from web components, Google’s own forms among them: it reads, finds, clicks and types inside them, where it used to answer “the page changed” or find nothing.`,`The model’s questions appear only in their own window: the chat no longer shows the question’s raw text while you answer, and afterwards keeps one line — “You answered 3 questions” — that opens to your answers.`]},{version:`0.3.200`,date:`2026-10-03`,platforms:[`linux`],added:[`Your chats now live only on the PC that runs them. Your phone, the website and your other PCs read a chat straight from its PC, through the same encrypted connection they use to continue it — OonaCode’s server no longer keeps any copy. While a PC is off or asleep its chats cannot be read from elsewhere; the window says so and they come back when it is online. Update OonaCode on each of your PCs: another device reads a PC’s chats only once that PC runs this version.`,`Everything OonaCode shows you is in credits, never in dollars: the model picker gives what an OonaCode pool model charges per 1M tokens in credits, and a chat’s spend, Usage, Conversations, Listen and the terminal all count credits. A chat on your own key or your own subscription says so instead of a price.`,`Listen has one button: Play. It writes a summary when the chat has none or has moved on, translates it once when you pick a new language, or just plays — saying only “Generating…” or “Translating…” while it works. A summary written in the last ten minutes is used for every language, so switching language never writes it again.`,`A morning briefing in View → What chats are about…: show the chats active in the last 24 hours, 3, 7, 10 or 30 days (or your own dates), tick the ones you want — or all — pick a language, a voice and a speed, and press Play. OonaCode reads each chat’s name and what it is about, one after another, with Next, Previous, Pause and Stop.`,`A chat can offer to move a task to a new chat. When a task deserves its own chat — a separate job, a chat that has grown long, work in another folder — the model proposes it with the first message written out; you can edit it, then Start new chat opens the new chat in a tab, sends the message and carries on there. Nothing starts without your yes.`,`Talk to other chats: a chat can now write to a chat whose switch is off. That chat’s switch stays off and it gets no new tools — it can only answer the chat that wrote to it. Finding a chat by name matches each word, in its name, project, folder and description, and spelling like “AI-control” or “aicontrol” no longer matters.`,`Oonak Browser acts like a person: every click, keystroke and scroll is a real input event, so sites that ignore scripted clicks now respond, and it works inside web components, Google’s own forms among them. Typing into a drop-down picks the option, and typing into an editor adds the text at its end.`,`Scheduled shows at a glance what will still run: paused tasks and one-time tasks that have already run are greyed out, with the day they will be removed — 10 days after their last change.`,`Settings → Developer → Allow debugging: opens a debugging port on this PC only, so a developer can look at and drive the app while fixing a problem with you. Off by default; while it is on, every window shows a red “Debugging on” badge.`],fixed:[`A chat keeps its Build / Plan / Ask first / Autonomous choice, and every device shows the same one. A chat set to “Ask first” now asks you before acting even when this PC answers prompts by itself.`,`A chat no longer ends up on a model nobody picked for it: a model the provider does not offer is refused instead of quietly switching the chat to the provider’s default, and Enter in the model picker no longer picks the row under the mouse pointer.`,`Chats talking to each other no longer ping-pong: a reply needs no answer, several messages from the same chat are read together in one turn, and a message card says “answer requested” until the answer has gone back, then “answered” with the time.`,`A tool you switch on while a chat is replying works for the message you send next, even mid-reply. After an update, a chat that had background tasks running shows one line saying how many stopped, instead of one card per task.`,`The model’s questions appear only in their own window: the chat no longer shows the question’s raw text while you answer, and afterwards keeps one line — “You answered 3 questions” — that opens to your answers.`,`A model your plan does not include now says “not in your plan”, instead of “Failed to authenticate … sign-in needed”.`,`A long message waiting in the queue no longer hides its “Send now” button: it is folded to a few lines, with Show all to read the rest.`,`The account window no longer stays on “offline · vault event stream responded 503” after a short server interruption.`]},{version:`0.3.199`,date:`2026-10-02`,platforms:[`win32`],added:[`Talk to other chats: a chat can now write to a chat whose switch is off. That chat’s switch stays off and it gets no new tools — it can only answer the chat that wrote to it. Finding a chat by name is smarter too: each word is matched, in its name, project, folder and description, and spelling like “AI-control” or “aicontrol” no longer matters.`,`Oonak Browser acts like a person: every click, keystroke and scroll is a real input event, so sites that ignore scripted clicks now respond. Typing into a drop-down picks the option, and typing into an editor adds the text at its end.`],fixed:[`A chat no longer ends up on a model nobody picked for it: a model the provider does not offer is refused instead of quietly switching the chat to the provider’s default, and Enter in the model picker no longer picks the row under the mouse pointer.`]},{version:`0.3.198`,date:`2026-10-01`,platforms:[`win32`],added:[`Listen has one button: Play. It writes a summary when the chat has none or has moved on, translates it once when you pick a new language, or just plays — saying only “Generating…” or “Translating…” while it works. A summary written in the last ten minutes is used for every language, so switching language never writes it again.`],fixed:[`A chat keeps its Build / Plan / Ask first / Autonomous choice, and every device shows the same one — the phone used to show “Ask first” for a Build chat. A chat set to “Ask first” now asks you before acting even when this PC answers prompts by itself.`,`Play in Listen is never greyed out for want of a voice: it gets the text ready and names the voice to install.`]},{version:`0.3.197`,date:`2026-10-01`,platforms:[`win32`],added:[`Oonak Browser, the browser your chats use, moves to version 151 by itself at its next use: a build with no Google services (no Safe Browsing warnings, push notifications or search suggestions). The download is checked against its fingerprint before anything is unpacked, and the old version is removed once no chat’s browser still runs from it.`],fixed:[`A model your plan does not include now says “not in your plan”, instead of “Failed to authenticate … sign-in needed”.`]},{version:`0.3.196`,date:`2026-10-01`,platforms:[`win32`],added:[`Your chats now live only on the PC that runs them. Your phone, the website and your other PCs read a chat straight from its PC, through the same encrypted connection they use to continue it — OonaCode’s server no longer keeps any copy. While a PC is off or asleep its chats cannot be read from elsewhere; the window says so and they come back when it is online. Update OonaCode on each of your PCs: another device reads a PC’s chats only once that PC runs this version.`],fixed:[`The account window no longer stays on “offline · vault event stream responded 503” after a short server interruption: the next sync that works clears it by itself.`]},{version:`0.3.195`,date:`2026-10-01`,platforms:[`win32`],added:[],fixed:[`Chats talking to each other no longer ping-pong. A message asks for an answer only when the chat really needs one; a reply needs no answer and is not answered with a new message; and several messages waiting from the same chat are read together in one turn. Fewer wake-ups, fewer tokens.`,`A message card says what is true: “answer requested” until the answer has gone back, then “answered” with the time — instead of an orange “reply expected” that never went away.`]},{version:`0.3.194`,date:`2026-10-01`,platforms:[`win32`],added:[`A chat can offer to move a task to a new chat. When a task deserves its own chat — a separate job, a chat that has grown long, work in another folder — the model proposes it with the first message written out; you can edit it, then Start new chat opens the new chat in a tab, sends the message and carries on there. Nothing starts without your yes.`,`Settings → Developer → Allow debugging: opens a debugging port on this PC only, so a developer can look at and drive the app while fixing a problem with you. Off by default; while it is on, every window shows a red “Debugging on” badge.`],fixed:[]},{version:`0.3.193`,date:`2026-10-01`,platforms:[`win32`],added:[],fixed:[`A tool you switch on while a chat is replying works for the message you send next, even mid-reply: that message now waits for the chat to restart with the new tool instead of reaching the model without it.`,`After an update, a chat that had background tasks running shows one line — “11 background tasks stopped — they were running when OonaCode restarted this chat” — instead of one card per task. Click it to see each one.`]},{version:`0.3.192`,date:`2026-09-30`,platforms:[`win32`],added:[`A morning briefing in View → What chats are about…: show the chats active in the last 24 hours, 3, 7, 10 or 30 days (or your own dates), tick the ones you want — or all — pick a language, a voice and a speed, and press Play. OonaCode reads each chat’s name and what it is about, one after another, with Next, Previous, Pause and Stop. Other languages are translated once and kept, so hearing the same briefing again costs nothing.`],fixed:[]},{version:`0.3.191`,date:`2026-09-30`,platforms:[`win32`],added:[`Scheduled shows at a glance what will still run: paused tasks and one-time tasks that have already run are greyed out, with the day they will be removed. They are deleted by themselves 10 days after their last change; resuming or editing a paused task gives it another 10 days.`],fixed:[]},{version:`0.3.190`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`A long message waiting in the queue no longer hides its “Send now” button: it is folded to a few lines, with Show all to read the rest.`]},{version:`0.3.189`,date:`2026-09-30`,platforms:[`linux`],added:[`Split views, like VS Code: drag a chat tab to the left, right, top or bottom of the chat area to open it beside the other one — a shaded area shows where it will land. Every chat on screen works on its own, with its own replies streaming and its own message box. Drag the divider to resize; Ctrl+\\ splits the current tab to the right, Ctrl+1, Ctrl+2… jump between views, and a tab’s menu has Split right, Split down and Move to other group.`,`Chats in windows of their own, like Chrome tabs: drag a tab out of the window, or choose “Move to new window” in its menu, and it opens in its own window; “Move to main window” brings it back. On Wayland desktops the new window opens at the usual place rather than under the pointer. Your split views and windows come back when you restart OonaCode.`,`Every language plays in Listen to a chat: each language picks the best voice on its own — OonaCode’s Armenian voices first, then your system’s voices, then eSpeak (install the espeak-ng package if your system has no voice for a language).`],fixed:[`Picking another language for a summary no longer needs a new summary: Play translates the one you have, keeps the translation, shows it and plays it.`,`“Summarise now” says “Up to date — nothing to summarise” while the chat has not changed, instead of seeming to do nothing.`]},{version:`0.3.188`,date:`2026-09-30`,platforms:[`win32`],added:[`Split views, like VS Code: drag a chat tab to the left, right, top or bottom of the chat area to open it beside the other one — a shaded area shows where it will land. Every chat on screen works on its own, with its own replies streaming and its own message box. Drag the divider to resize; Ctrl+\\ splits the current tab to the right, Ctrl+1, Ctrl+2… jump between views, and a tab’s menu has Split right, Split down and Move to other group.`,`Chats in windows of their own, like Chrome tabs: drag a tab out of the window, or choose “Move to new window” in its menu, and it opens in its own window. Drag it back onto the main window’s tabs, or choose “Move to main window”, to bring it back. Your split views and popped-out windows come back when you restart OonaCode.`],fixed:[]},{version:`0.3.187`,date:`2026-09-30`,platforms:[`win32`],added:[`Every language plays in Listen to a chat. Persian, Georgian, Ukrainian — and any language whose Windows voice is not installed — now speak with eSpeak, a free voice that comes with OonaCode (it sounds robotic, but it always works). Each language picks the best voice on its own: OonaCode’s Armenian voices first, then Windows’ own, then eSpeak.`],fixed:[`Picking another language for a summary no longer needs a new summary: Play translates the one you have, keeps the translation, shows it and plays it.`,`“Summarise now” says “Up to date — nothing to summarise” while the chat has not changed, instead of seeming to do nothing.`]},{version:`0.3.186`,date:`2026-09-30`,platforms:[`linux`],added:[`Listen to a chat: right-click a chat → Listen to this chat…, or the speaker button beside the chat’s title. The chat’s own model writes a short spoken summary — the goal, what was done, where it stands, what is left — and OonaCode reads it aloud on this PC, in the voice and at the speed you choose. Every summary is kept with its date, so you can play it again at any time; a new one is written only when the chat has moved on. Other languages are translated once and kept with the summary.`,`OonaCode brings two Armenian voices of its own, Astgh and Artsiv, and also speaks with your system’s voices through speech-dispatcher — install speech-dispatcher and espeak-ng for Persian, Russian and every other language; the Listen window names the packages for your distribution.`,`Listen to a chat from your phone: the OonaCode app’s 🔊 Listen reaches this PC’s summaries and plays them with the phone’s own voices. It needs this update on the PC and the next OonaCode app on the phone.`,`See where your credits go: Account → Usage. Pick the last 24 hours, 7, 30 or 90 days or your own dates, by hour or by day, for the coding agent or your API keys apart. A chart shows the credits over time by model or by what they were for, and the lists below give every model with its tokens and price, and every use — chat turns, a chat’s “about”, images, speech and the rest.`,`The chat list is laid out like the Claude desktop app: New, Projects, Scheduled, then your pinned chats and projects, then Today and Older. The old grouping by project is one click away — the small icon beside “Today”.`,`Projects opens a page of project cards — each with its goal, its chats and when it was last used — with search, sort and New project. Click a card to see that project’s chats, instructions and settings, and to start a new chat in it.`,`Scheduled shows every scheduled task from every chat on this PC in one place, with its next run, its chat, and pause, resume and delete. Pin any chat or project to the top of the list from its menu.`,`Claude Sonnet 5.5 is in the model picker — on the OonaCode pool and on your own Claude subscription — with a 1M-token context. It costs the same as Sonnet 5 per token and usually needs fewer tokens for the same work.`,`Type / at the start of a message to see the chat’s commands and skills, with what each does, in two titled sections. Type to narrow the list, then Enter or Tab. They work with every model, not only Claude.`,`Each chat has a Skills list beside Tools. Every skill starts off, so the model sees none of them and they cost nothing; switch one on to let the model use it by itself in that chat. Typing /name still runs any skill for one turn.`,`Your own skills: Settings → Skills lists the skills OonaCode gives every chat, and “Import from Claude Code…” copies the ones you choose from your Claude Code install — it only reads it, never changes it.`,`In the terminal app (oona), a command the chat’s engine knows — /context, /compact or a skill — now runs instead of answering “unknown command”.`,`Search in the Import window: find a chat by its name, its first or last message or its folder, or pick “Whole conversations” to search inside the chats themselves.`],fixed:[`Import chats shows every chat on this PC, grouped by the app it came from, with nothing folded away. Each row says whether it is new, already imported, moved on since, or deleted by you in OonaCode. Nothing is ticked when you open it yourself: search for a chat and tick it, or tick a whole group at once.`,`The message box fits a narrow chat: its buttons and pickers move onto a second line and the box grows to hold them — Stop and Queue no longer slip outside it.`,`Claude’s thoughts show their words again. Every “Thought” from Claude Opus, Sonnet and Fable came back empty — Anthropic leaves the text out unless it is asked for a summary, and now OonaCode asks. Only new replies change.`,`A chat’s “about” no longer starts in the middle of a sentence when the model wrote a long answer.`,`Commands that only duplicated OonaCode’s own controls or showed misleading numbers are gone from the / menu — /model, /usage, /autocompact, /output-style, /mcp, /list-agents and /reload-skills. Typed, they say why.`,`Skills you import or remove in Settings → Skills reach your chats by themselves, at each chat’s next message.`,`Claude Sonnet 5 is retired: a chat that was on it moves to Sonnet 5.5 at its next message.`,`The engine’s built-in keyboard-shortcuts helper is turned off: it would have edited your own Claude Code settings.`,`Typing /model in a chat updates the chat’s model and the model picker again, and command output such as /context reads the same while it arrives and after you reopen the chat.`,`A chat row’s ⋯ button shows only when you point at the row.`]},{version:`0.3.185`,date:`2026-09-30`,platforms:[`win32`],added:[`Listen to a chat from your phone: the OonaCode app’s 🔊 Listen reaches this PC’s summaries and plays them with the phone’s own voices. It needs this update on the PC and the next OonaCode app on the phone.`],fixed:[`Listening with a Windows voice no longer stops after the first sentence when the voice fails to say it has finished.`]},{version:`0.3.184`,date:`2026-09-30`,platforms:[`win32`],added:[`Listen to a chat: right-click a chat → Listen to this chat…, or the speaker button beside the chat’s title. The chat’s own model writes a short spoken summary — the goal, what was done, where it stands, what is left — and OonaCode reads it aloud on this PC, in the voice and at the speed you choose. Every summary is kept with its date, so you can play it again at any time; a new one is written only when the chat has moved on. Other languages are translated once and kept with the summary.`],fixed:[`A chat’s “about” no longer starts in the middle of a sentence when the model wrote a long answer.`]},{version:`0.3.183`,date:`2026-09-30`,platforms:[`win32`],added:[`See where your credits go: Account → Usage. Pick the last 24 hours, 7, 30 or 90 days or your own dates, by hour or by day, for the coding agent or your API keys apart. A chart shows the credits over time by model or by what they were for, and the lists below give every model with its tokens and price, and every use — chat turns, a chat’s “about”, images, speech and the rest.`],fixed:[]},{version:`0.3.182`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`Import chats shows every chat on this PC, grouped by the app it came from — Claude Code, the Claude app, Qwen Code, Cursor — with nothing folded away. Each row says whether it is new, already imported, moved on since, or deleted by you in OonaCode. Nothing is ticked when you open it yourself: search for a chat and tick it, or tick a whole group at once. The Import button says how many chats it will bring over.`]},{version:`0.3.181`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`The message box fits a narrow chat. In a small window, or with the side panels open, its buttons and pickers move onto a second line and the box grows to hold them — Stop and Queue no longer slip outside it, and the model and effort pickers keep their words readable.`]},{version:`0.3.180`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`Claude’s thoughts show their words again. Every “Thought” from Claude Opus, Sonnet and Fable came back empty — Anthropic leaves the text out unless it is asked for a summary, and now OonaCode asks. Other models were never affected. Only new replies change; older thoughts stay empty.`]},{version:`0.3.179`,date:`2026-09-29`,platforms:[`win32`],added:[],fixed:[`The / menu is easier to read: skills and commands in two titled sections, each with one short line — the full description shows when you point at it.`,`Commands that only duplicated OonaCode’s own controls or showed misleading numbers are gone from the / menu — /model (use the model picker), /usage (the engine’s own estimate, not your credits), /autocompact, /output-style, /mcp, /list-agents and /reload-skills. Typed, they say why.`,`Skills you import or remove in Settings → Skills reach your chats by themselves, at each chat’s next message.`]},{version:`0.3.178`,date:`2026-09-29`,platforms:[`win32`],added:[`The chat list is laid out like the Claude desktop app: New, Projects, Scheduled, then your pinned chats and projects, then Today and Older. The old grouping by project is one click away — the small icon beside “Today”.`,`Projects opens a page of project cards — each with its goal, its chats and when it was last used — with search, sort and New project. Click a card to see that project’s chats, instructions and settings, and to start a new chat in it.`,`Scheduled shows every scheduled task from every chat on this PC in one place, with its next run, its chat, and pause, resume and delete. A dot on it tells you when something is due soon.`,`Pin any chat or project to the top of the list from its menu.`],fixed:[`A chat row’s ⋯ button shows only when you point at the row.`]},{version:`0.3.177`,date:`2026-09-29`,platforms:[`win32`],added:[`Claude Sonnet 5.5 is in the model picker — on the OonaCode pool and on your own Claude subscription — with a 1M-token context. It costs the same as Sonnet 5 per token and usually needs fewer tokens for the same work.`],fixed:[`Claude Sonnet 5 is retired: a chat that was on it moves to Sonnet 5.5 at its next message, and the picker shows Sonnet 5.5.`]},{version:`0.3.176`,date:`2026-09-29`,platforms:[`win32`],added:[`Each chat has a Skills list beside Tools. Every skill starts off, so the model sees none of them and they cost nothing — about 1,400 tokens on every message until now. Switch one on to let the model use it by itself in that chat; the list shows what each one costs per message while on.`,`Typing /name still runs any skill for one turn, whether its switch is on or off.`],fixed:[`The engine’s built-in keyboard-shortcuts helper is turned off: it would have edited your own Claude Code settings.`]},{version:`0.3.175`,date:`2026-09-29`,platforms:[`win32`],added:[`Type / at the start of a message to see the chat’s commands and skills — the Claude Code engine’s own (/compact, /context, /review, /security-review, /init and more) and the skills in your project’s .claude folder — with what each does. Type to narrow the list, then Enter or Tab. They work with every model, not only Claude.`,`Your own skills: Settings → Skills lists the skills OonaCode gives every chat, and “Import from Claude Code…” copies the ones you choose from your Claude Code install — it only reads it, never changes it.`,`In the terminal app (oona), a command the chat’s engine knows — /context, /compact or a skill — now runs instead of answering “unknown command”.`],fixed:[`Typing /model in a chat updates the chat’s model and the model picker again.`,`Command output such as /context reads the same while it arrives and after you reopen the chat.`]},{version:`0.3.174`,date:`2026-09-28`,platforms:[`win32`],added:[`Search in the Import window. Type to find a chat by its name, its first or last message, or its folder — chats folded away as already imported or deleted here show up too when they match. Or open the search options and pick “Whole conversations” to search inside the chats themselves, with a few lines of each match under the chat. It only reads Claude Code, Cursor and the Claude app’s files, never changes them.`],fixed:[`Chats Claude Code switched to another model are answered by that model for real: OonaCode’s pool now serves the model the engine falls back to, and never answers a Claude request with another company’s model.`]},{version:`0.3.173`,date:`2026-09-28`,platforms:[`linux`],added:[`Every chat now has an “about”: a short note, written in the background by a cheap helper model of the chat’s own provider, saying what the chat works on. Your other chats read it — with each chat’s folder and when it was last active — when they look for the right chat to ask. See it, edit it or press Regenerate in the session info panel.`,`View → What chats are about… (and a sidebar button) lists every chat’s about and what writing them cost, with a switch to turn it off and “Generate for all chats now”. The switch and its numbers are also in Settings → This PC.`,`Your phone can now do from anywhere what this PC’s window does: switch each tool on or off per chat, see and control the conversations between your chats, read, edit and regenerate each chat’s “about”, and manage scheduled tasks. It needs this update on the PC and the next OonaCode app on the phone.`,`A chat can switch its own workspace. When the work belongs in another folder — a project you name that lives elsewhere, or a new project folder — the model proposes the switch and you answer Switch or Not now. It always asks you, even with “accept automatically” on, and the chat moves when its current step ends, with the conversation kept.`,`Right-click a chat tab → Delete (in red, under “Close all tabs”) deletes that chat after asking, just like Delete in the sidebar.`,`When Anthropic’s safeguards flag a chat and Claude Code moves it to another model for the rest of the run, the model box says so in red — for example “Opus 4.8 (safeguard)” — and the chat shows a notice at the switch. Picking a model takes the chat back to it at the next message.`],fixed:[`Typing in the message box while a chat is replying is no longer interrupted. With “accept automatically” on, an approval card flashed for an instant on some tool calls and took the cursor away from the box.`,`A permission card that appears while you are typing no longer takes the keyboard, so your next Space or Enter can never press Allow by accident.`,`“Send now” stays disabled and says “Sending now…” until the agent has taken the message — it can take a few seconds while the agent stops its current step, and a second press can no longer send it twice.`,`A message sent from your phone is confirmed by this PC, and the same message is never run twice when the phone sends it again after a lost connection.`,`File and folder names in a reply get their ▶, Open and Show in folder buttons only when they really exist on this PC. A bare file name is also looked for in the folder the reply named just before it.`,`A chat can no longer be moved into your home folder or the root folder through a link. Where /home is itself a link (Fedora Silverblue, Bazzite and similar systems), the home folder passed as an ordinary folder, and the chat would have loaded your own Claude Code settings as its project.`,`Signing in to your own Claude subscription inside the app works on Ubuntu 24.04, Debian, Linux Mint, Pop!_OS and Zorin OS again. There, a part of OonaCode built for newer systems did not load, and the sign-in fell back to a command you had to paste.`,"On Ubuntu, Linux Mint, Pop!_OS, Zorin OS and similar systems, `oona` now works in every new terminal right after you install or update. The installer used to leave it off your PATH until you logged out and back in; now it adds it for new terminals itself, and `oona uninstall` takes that line out again.",`Every way of uninstalling — “oona uninstall”, or the install command with --uninstall — now takes this PC off your account: keep your chats and they stay readable on your other devices; delete them and their copies go too. It never touches your Claude Code or the Claude app, and “oona uninstall” no longer gives up when the background service is stopped.`,`The installer now says at once when a system cannot run OonaCode — one older than Ubuntu 22.04, Debian 12 or RHEL 9, or one built on musl such as Alpine — instead of installing a copy that could not start. The .deb and .rpm tell apt and dnf the same.`]},{version:`0.3.172`,date:`2026-09-28`,platforms:[`win32`],added:[`When Anthropic’s safeguards flag a chat and Claude Code moves it to another model for the rest of the run, the model box says so in red — for example “Opus 4.8 (safeguard)” — and the chat shows a notice at the switch. Picking a model takes the chat back to it at the next message.`],fixed:[`Uninstalling from Settings → Apps now also takes this PC off your account, exactly like “oona uninstall”: keep your chats and they stay readable on your other devices; delete them and their copies go too.`,`“oona uninstall” no longer gives up when the background service is stopped.`,`The “Updating OonaCode…” window shows again on the newest Windows 11 versions (24H2 and later).`]},{version:`0.3.171`,date:`2026-09-28`,platforms:[`win32`],added:[`Oonak Browser now picks its own control port from a range no developer tool uses by default, so it can no longer take a port that Shopify CLI or a dev server wants. If a program needs a particular port kept free, or you want the browser on a specific one, just ask the chat.`],fixed:[`File and folder names in a reply get their ▶, Open and Show in folder buttons only when they really exist on this PC. A bare file name is also looked for in the folder the reply named just before it.`,`Uninstalling OonaCode from Settings → Apps now removes all of it — the app, the command line and its background service — and asks whether to keep your chats. Installing again afterwards no longer says it is already installed. Your Claude Code and Claude app are never touched.`,`“oona uninstall” works again on Windows 11.`,`A chat “about” you wrote yourself no longer shows “stale”.`]},{version:`0.3.170`,date:`2026-09-28`,platforms:[`win32`],added:[`Your phone can now do from anywhere what this PC’s window does: switch each tool on or off per chat, see and control the conversations between your chats, read, edit and regenerate each chat’s “about”, and manage scheduled tasks. It needs this update on the PC and the next OonaCode app on the phone.`],fixed:[`“Send now” stays disabled and says “Sending now…” until the agent has taken the message — it can take a few seconds while the agent stops its current step, and a second press can no longer send it twice.`,`A message sent from your phone is confirmed by this PC, and the same message is never run twice when the phone sends it again after a lost connection.`]},{version:`0.3.169`,date:`2026-09-28`,platforms:[`win32`],added:[`Every chat now has an “about”: a short note, written in the background by a cheap helper model of the chat’s own provider, saying what the chat works on. Your other chats read it — with each chat’s folder and when it was last active — when they look for the right chat to ask. See it, edit it or press Regenerate in the session info panel.`,`View → What chats are about… (and a sidebar button) lists every chat’s about and what writing them cost, with a switch to turn it off and “Generate for all chats now”. The switch and its numbers are also in Settings → This PC.`],fixed:[`A chat can no longer be moved into your user folder or a drive root through a link or junction that points there — its project settings would have been your own Claude Code settings.`]},{version:`0.3.167`,date:`2026-09-27`,platforms:[`win32`],added:[`A chat can switch its own workspace. When the work belongs in another folder — a project you name that lives elsewhere, or a new project folder — the model proposes the switch and you answer Switch or Not now. It always asks you, even with “accept automatically” on, and the chat moves when its current step ends, with the conversation kept.`],fixed:[]},{version:`0.3.166`,date:`2026-09-27`,platforms:[`win32`],added:[],fixed:[`Typing in the message box while a chat is replying is no longer interrupted. With “accept automatically” on, an approval card flashed for an instant on some tool calls and took the cursor away from the box.`,`A permission card that appears while you are typing no longer takes the keyboard, so your next Space or Enter can never press Allow by accident.`]},{version:`0.3.165`,date:`2026-09-27`,platforms:[`win32`],added:[`Right-click a chat tab → Delete (in red, under “Close all tabs”) deletes that chat after asking, just like Delete in the sidebar.`,`Chats now use Oonak Browser, in a window you can see, for everything that needs a web browser — not Chrome, Edge or a hidden script browser — unless you name another browser. It runs without a window (headless) only when you ask for that.`],fixed:[`After an update, the background service comes back by itself. An update could leave it unable to restart, and the app then showed “OonaCode could not start its host service” even though it went on to open normally.`]},{version:`0.3.164`,date:`2026-09-27`,platforms:[`win32`],added:[`Send now: a message you typed while the agent works has a Send now button while it waits. It stops what the agent is doing right now and sends your message immediately — the step that is running is cut. On the desktop and the phone.`,`Conversations → Map: see at a glance which chats are talking to each other. Each conversation is a hub with a line to each of its chats; working chats pulse; click a hub for its history or a chat to open it.`],fixed:[`A restart no longer signs this PC out when OonaCode’s stored key cannot be opened for a moment. OonaCode used to replace the key and lose your sign-in; it now keeps the key and signs you back in by itself as soon as it opens.`]},{version:`0.3.163`,date:`2026-09-27`,platforms:[`linux`],added:[`Send now: a message you typed while the agent works has a Send now button while it waits. It stops what the agent is doing right now and sends your message immediately — the step that is running is cut. On the desktop and the phone.`,`Conversations → Map: see at a glance which chats are talking to each other. Each conversation is a hub with a line to each of its chats; working chats pulse; click a hub for its history or a chat to open it.`],fixed:[`A restart no longer signs this PC out when its security chip is slow to open OonaCode’s stored key. After a system update and reboot, the chip on some machines refuses for a while; OonaCode used to replace the key and lose your sign-in. It now keeps the key and signs you back in by itself as soon as the chip opens it.`]},{version:`0.3.162`,date:`2026-09-27`,added:[],fixed:[`A chat switched to another model knows which model it is. After a switch from Claude to DeepSeek, the model used to keep saying it was Claude — the chat history and Claude Code’s own prompt told it so.`,`Oonak Browser is offered only where it can run. An older OonaCode no longer lists a browser tool it cannot use, so the model does not spend tokens working around it — update to get the browser.`]},{version:`0.3.161`,date:`2026-09-27`,added:[`Settings → This PC → “Replace pictures older than N days”: screenshots and pasted pictures in your chat history are replaced by a short note once they are older than a year (you choose the number, or 0 to keep them). The words of every chat stay; the database stops growing with pictures. It runs by itself.`],fixed:[`The model, Build/Plan/Ask and effort pickers under the message box now look like the dropdowns they are.`,`Switches that are off are easy to see in dark mode.`,`Error messages show what went wrong in words, without raw tags or a provider’s JSON.`,`The ✕ that removes an attachment or a reply is round.`,`Pressing Stop, or an update cutting a turn, no longer files an automatic bug report.`]},{version:`0.3.160`,date:`2026-09-27`,added:[`On Windows, the agent can use a real browser. Ask it to open a site, read a page, click, fill in a form or take a screenshot, and it does it in Oonak Browser, in a window you can see. The first time, OonaCode asks once to install the browser (about 210 MB); after that it opens straight away.`,`Each chat has its own browser profile, so a site you sign in to stays signed in for that chat. Switch the browser off for a chat in its Tools menu.`],fixed:[]},{version:`0.3.159`,date:`2026-09-27`,added:[],fixed:[`A chat reopened after an update no longer says “turn complete” the instant you send a message and then answer anyway. The engine’s own note about work that stopped during the update used to be taken for the end of your turn, with the whole earlier conversation’s tokens on the line.`,`A background task that stopped because OonaCode restarted now says so in plain words, instead of “Orphaned by a previous Claude Code process exit”.`]},{version:`0.3.158`,date:`2026-09-27`,added:[`Every thought in a chat shows how many words it has, so you can tell at a glance whether there is anything to read.`],fixed:[`A thought with nothing in it — some models return only a signature for their thinking — now says “Thought · empty” and no longer opens onto a blank box.`,`A command the agent was allowed to run no longer leaves an “Allowed Bash (automatically)” line under its own card: the card already shows the command and its result. Refusals are still shown.`]},{version:`0.3.157`,date:`2026-09-27`,added:[`On Linux, OonaCode has its own signed apt and dnf repositories. Install the app with apt (Debian, Ubuntu, Mint) or dnf (Fedora, RHEL, Rocky, Alma) — the commands are on the download page — and your package manager keeps it up to date with the rest of the system.`,`Every Linux release is signed with the OonaCode release key, and the one-line installer checks that signature before it installs anything.`],fixed:[`On Linux, the menu bar is drawn in the window in the app’s own colours, and it switches between light and dark with the app instead of keeping the desktop’s theme until a restart.`,`Upgrading the .rpm no longer removes the oonacode command, and removing it no longer leaves empty folders behind.`]},{version:`0.3.156`,date:`2026-09-27`,added:[`Chats can talk to each other. Turn on “Talk to other chats” in a chat’s Tools menu, and its agent can find your other chats that have it on, read them, and ask them for help — one chat or a whole group. A chat that is closed wakes up to answer; a busy one answers when it finishes. The reply comes back to the chat that asked.`,`The Conversations window (in the sidebar) shows every conversation between your chats: who said what to whom, what each answer cost, and buttons to pause, resume, close or stop them all. Each conversation has a budget — 20 messages and 1,000,000 new tokens by default — and pauses itself when it is used up, so chats can never talk forever.`,`Hover over any tool in a chat’s Tools menu to read what it does, how it works, what it costs and how to turn it off.`],fixed:[`A chat woken in the background — by a scheduled task or another chat — shows as working in the sidebar even when it is not open in a tab.`,`A scheduled task no longer slips into a chat at the same moment you send it a message; yours always goes first.`,`A message sent from the terminal no longer waits forever when a chat’s history cannot be resumed and the restart fails. It now says why.`,`Notes OonaCode writes into a chat — a model change, a conversation paused — are still there when you reopen it.`,`When every Claude seat in the OonaCode pool is taken, a new chat now says the model is busy and to try again in a few minutes or pick another model, instead of “Something went wrong on our side”.`,`On Linux, the app tells you it is updating while it swaps itself, so there is no need to start it again.`,`On Linux, removing the .deb or .rpm leaves nothing running and nothing failing at the next login, and the one-line installer checks for free disk space before it changes anything.`]},{version:`0.3.155`,date:`2026-09-27`,added:[`OonaCode runs on Linux. One command installs the command line, the background service and the desktop app: curl -fsSL https://oonacode.oonak.ai/install.sh | bash. The AppImage, .deb and .rpm are on the download page too.`,`On Linux the app lives in the system tray as it does on Windows, follows your desktop’s light or dark theme, and gets its own entry in the applications menu.`,`Uninstalling on Linux removes the desktop app along with the rest, and asks whether to keep your chats for a future install.`],fixed:[`A window no longer stays on “Unauthorized” after the background service restarts with a new key. It reconnects by itself.`]},{version:`0.3.154`,date:`2026-09-26`,added:[],fixed:[`A chat waiting on a long job no longer loses its watcher. OonaCode used to close a chat’s engine ten minutes after the model last spoke, which stopped any Monitor or background command it had left running. The engine now stays up while such work runs, up to 12 hours.`,`A chat moved into a project, or whose project you edit, now follows the project’s instructions from its next message. It used to keep the ones it started with.`]},{version:`0.3.153`,date:`2026-09-25`,added:[],fixed:[`A very long chat no longer answers “Prompt is too long” after OonaCode restarts or updates. The engine was judging the chat’s size by a figure left over from before the restart, and now gets an accurate one.`,`If a message is ever refused as too long before the model has started on it, OonaCode sends it again by itself with a shorter history. You see your message once and then the answer, not an error.`]},{version:`0.3.152`,date:`2026-09-25`,added:[],fixed:[`Uninstalling the app from Windows’ Apps list no longer stops the command-line OonaCode on the same PC from starting after a restart.`]},{version:`0.3.151`,date:`2026-09-25`,added:[`Files the agent names in a chat are clickable. Audio and video play right in the chat with a small player, pictures open as a preview, and in the app every file can be opened in its own program or shown in its folder.`,`Uninstalling the app asks whether to keep your chats on this PC. Keeping them means a new install signs in and continues every chat.`],fixed:[`Installing and updating no longer fail with “The operation has timed out” on PCs whose network drops the newer internet addresses, nor while our server restarts for an update.`]},{version:`0.3.150`,date:`2026-09-25`,added:[],fixed:[`The fix in 0.3.149 for long, sleeping turns now really reaches the agent: the Monitor tool and the block on long waits are on for every chat.`,`A chat compacted after a long pause no longer pays to cache a conversation it is about to replace, and the agent keeps each tool call in its history exactly as it wrote it — both as Claude Code does.`]},{version:`0.3.149`,date:`2026-09-25`,added:[`The agent can watch a long job with the Monitor tool, as Claude Code does, and is woken the moment the job finishes.`],fixed:[`Long chats no longer spend their time asleep. With no way to watch a background job, the agent had been polling it with waits of four to eight minutes. One chat spent more than three and a half hours of a day sleeping, and turns ran for hours while the model worked for a fraction of that. The agent now gets the same working rules as Claude Code, and long waits are blocked.`]},{version:`0.3.148`,date:`2026-09-25`,added:[],fixed:[`A scheduled task that could not be sent — the PC had just restarted, the vault was still locked, the server was not reachable yet — waits and tries again instead of switching itself off. Pausing, editing or deleting a task while its prompt is being sent is no longer undone, and a scheduled prompt no longer lands in a chat whose engine is still starting.`,`A chat on your own DeepSeek key, or one switched with a typed “/model opus”, is no longer shown as withdrawn and locked. “/model fable” picks Claude Fable instead of the default model.`,`Moving a chat to another model no longer lowers its saved effort level to what the old model offered, and a one-off “oona --effort” is no longer saved as the chat’s level.`,`After you pick another model for a locked chat and send, the chat no longer flashes the lock again while the engine starts; if the start fails, your pick is kept.`,`Coming back from a file tab no longer jumps the chat to an old reply or reopens the search bar.`,`The hidden sidebar slides away again when the pointer leaves the window past its edge, and the keyboard no longer tabs through it while it is hidden. Clicking ⓘ in Settings opens its note instead of closing it.`,`Subagents write their prompt cache for five minutes, as Claude Code does for its subscribers; the chat itself keeps the hour. Their cache writes cost less.`]},{version:`0.3.147`,date:`2026-09-25`,added:[`A chat’s scheduled tasks sit beside its subagents: a clock badge says how many are live and when the next one runs, and opens the list — each task’s schedule, its next and last run, Pause and Delete. The tasks run on this PC.`],fixed:[`A prompt the scheduler sends into a chat reads as a “Scheduled task” line, not as your own message waiting in the queue.`,`A chat whose model is no longer offered shows that model in red and waits for you to pick another; its history stays, and the old model is not in the list any more.`,`The effort list follows the server within minutes, without restarting the app. A chat set to a level that has been switched off moves to the nearest one — ultracode becomes xhigh. Chats on your own Claude subscription have an effort picker again.`]},{version:`0.3.146`,date:`2026-09-25`,added:[`A Tools menu beside the model picker: switch OonaCode’s own tools on or off for each chat — browser, desktop and window control, clipboard, screen capture, Office documents and run-as-administrator. Each tool costs the model only a short line until it is used, and the menu shows how much. The first tools are marked Demo while they are tested with every model: a demo tool answers what it would have done, and does nothing on your PC yet.`],fixed:[]},{version:`0.3.145`,date:`2026-09-25`,added:[],fixed:[`Every request of every chat, on every model, is about 3,200 tokens smaller: the engine’s own “auto memory” instructions are gone. OonaCode starts each engine in a fresh private folder and deletes it afterwards, so the notes the model was told to keep there were thrown away when the chat went idle — the model spent tool calls writing memories it would never read. A project’s memory is OonaCode’s own and stays.`,`The engine’s claude.ai Artifact tools are switched off everywhere OonaCode runs it — the app, the terminal, VS Code, the phone, Telegram and the agent API.`]},{version:`0.3.144`,date:`2026-09-25`,added:[],fixed:[`Long chats on Claude models in the OonaCode pool keep their cache for an hour, as Claude Code does for its subscribers. A pause of more than five minutes no longer re-sends the whole conversation at the full cache-write price, which in a large chat was the most expensive part of coming back to it.`,`The session panel’s Context shows how big the conversation is now, not the total of every request the chat ever made — a long chat read “10.7M / 1.0M tokens”.`,`The message box keeps the cursor after you send, so you can go straight on typing the next message.`,`A paid chat’s background work (titles, reading web pages) no longer goes to a free model of the same vendor.`]},{version:`0.3.143`,date:`2026-09-24`,added:[`Search inside your chats: open the search in the chat list, press the sliders button and choose Whole chats. It looks through every message of every chat on this PC, and you choose whose words — yours, the model’s, or both — plus, if you like, the tools’ commands and output and the subagents’ conversations. Results show each message with the words lit; a click opens the chat with its search on them.`,`More search options, for both kinds of search: one project only, a time window (today, 7 or 30 days), match case and whole words.`],fixed:[`While you search the chat list, projects with no matching chat are hidden too.`]},{version:`0.3.142`,date:`2026-09-24`,added:[],fixed:[`A reply you sent shows as the same small chip it had in the message box — “Reply to” and the first few words — instead of the whole quoted text; the full quote appears when you rest the pointer on it, and a click jumps to the message it answers.`,`The model now knows a reply points back into the conversation: it is told the quoted lines are from the chat history, not new input, and whose words they were — its own earlier reply, your earlier message, a file, or a tool’s output.`,`When the chat list is narrow, its buttons wrap onto a second line instead of spilling out of it.`]},{version:`0.3.141`,date:`2026-09-24`,added:[`The chat list on the left can be made wider or narrower: drag its right edge (double-click it for the usual width).`,`The chat list can hide: press the pin in its header, the button at the top left, or View → Sidebar (Ctrl+B). While hidden it slides in when the pointer reaches the left edge of the window, and slides away when you leave it.`,`Search in the chat list is a single magnifier now; click it and the search box opens across the top. Escape or × clears it.`],fixed:[`Opening OonaCode right after a restart no longer leaves the OonaCode pool models out of the model list: if they cannot be read yet, OonaCode asks again by itself a few seconds later and the list fills in.`,`The Artificial Analysis scores (intelligence, coding, speed and benchmarks) show on every model in the model list again — including the models of your own Claude and SuperGrok subscriptions, which never had them.`,`A chat’s details card no longer appears on top of its right-click menu.`]},{version:`0.3.140`,date:`2026-09-24`,added:[`Reply is tidier: the message you reply to shows as a small chip above the message box with its first few words, instead of filling the box. Click the chip — or the quote in a sent reply — to jump to that message; the × removes it.`,`Right-click a project in the sidebar for its settings: Project settings… opens Projects with that project already selected. The gear beside a project’s “+” does the same, and a chat filed in a project offers it in its own menu too.`,`Link GitHub. Under a project’s Repositories (and in Settings → Providers), link your GitHub account once: the agent’s git and gh then clone, pull and push your private repositories on every PC of yours. You type a short code on github.com; the token stays in your encrypted vault and never reaches the OonaCode server. Public repositories need nothing.`],fixed:[]},{version:`0.3.139`,date:`2026-09-24`,added:[`Every setting now says what it does, and resting the pointer on the ⓘ beside it tells you where in OonaCode it applies and what it does not do.`,`Export chats… is in the File menu (and on the sidebar in a browser window) instead of in Settings.`,`With Remote access turned off on a PC, your phone, Telegram, the website and your other PCs still show it — online or not — marked “remote access off”, and opening it tells you to turn Remote access back on in OonaCode on that PC.`],fixed:[`Turning Remote access off now tells your other devices at once. Before, the PC was already unreachable from them, but they could not say why.`,`The settings of This PC save the moment you change them — nothing is lost by closing the dialog.`,`Settings that did nothing, or repeated another one, are gone: the default permission mode (each chat’s Build / Plan / Ask first picker decides), the agent-picker switch, the Git Bash path, the engine path and the extra allowed origins. The server address is shown, not edited — signing in sets it.`]},{version:`0.3.138`,date:`2026-09-24`,added:[`Projects have settings now, like the Claude app’s: a goal, the repositories the project works on, what a new chat in it starts on (model, effort and folder), a project memory the agent keeps up to date, and whether its chats may schedule work — and how often at most. All of it is in Projects, and a Claude app project you import brings its own.`,`OonaCode has a scheduler. Ask the agent to do something later or on a repeat — “check the build every morning at nine” — and it schedules it on this PC; when it is due, the prompt arrives in the chat, even if the chat had gone quiet. The Projects dialog and the chat’s info panel list what is scheduled, where you can pause, resume or delete it.`],fixed:[`Saving a project’s instructions now reaches its chats at their next message, instead of waiting until the chat happened to restart.`]},{version:`0.3.137`,date:`2026-09-24`,added:[],fixed:[`After a PC restart the app could ask for a "host token" and sign you out: two copies of the OonaCode background service started at once and fought over your session. Only one ever runs now, and the app never shows the token page — if its service is replaced it reconnects by itself.`,`The unlock screen stays put until you unlock, and says what went wrong in place — a wrong password, or a connection it is re-establishing — instead of jumping to another page.`,`A message with a picture sent while the agent was working stayed “queued”, and removing it said it was already sent. It now shows as read the moment the agent takes it, and a reopened chat shows it with its picture.`,`In the model’s questions, typing your own answer now clears the options you had picked, and picking an option clears what you typed — the answer sent is exactly the one you chose. The same on the phone, in the terminal and in Telegram.`]},{version:`0.3.136`,date:`2026-09-24`,added:[`Every model now has its own housekeeper — the small, fast model of the same maker that writes a chat’s titles and reads the web pages it fetches. On the OonaCode pool a MiMo v2.6 Pro chat uses MiMo v2.6 Flash, a Qwen chat Qwen3.8 Flash, a GLM chat GLM-5.3 Flash and a GPT-5 chat GPT-5 mini, instead of doing that work on the big model itself. A free model keeps its own, so it stays free.`],fixed:[]},{version:`0.3.135`,date:`2026-09-24`,added:[],fixed:[`Claude models on the OonaCode pool — Opus 5.5, Opus 5, Sonnet 5 and Fable 5.1 — now use their whole 1M context. A long chat no longer stops to summarise itself every ~170k tokens, and its subagents get the same window.`,`Reading a web page is quick again in a Claude chat: pages are read by Claude Haiku, as in Claude Code, instead of a helper that took about a minute a page.`,`Changing a chat’s model now moves its subagents and background helpers to the new model too; before, they stayed on the old one until the app restarted.`,`MiMo v2.5 and v2.5 Pro chats now use their full 1M context too.`]},{version:`0.3.134`,date:`2026-09-23`,added:[],fixed:[`On the Android app, the model’s questions can be answered again. They come one at a time — “Question 2 of 3” — with Back, Next and Skip, and Answer sends them to your PC. The card used to show only the first question, hide the rest below it and wait for all of them, so it could not be sent.`]},{version:`0.3.133`,date:`2026-09-23`,added:[`Bring your Claude desktop app projects across: File → Import chats from other coding agents now lists every project the Claude app has opened on this PC. Each one arrives as an OonaCode project of the same name — its goal, instructions and what Claude noted about it become the project’s instructions — with its project chat and one chat per thread filed under it, ready to carry on.`,`A Claude Code chat you moved into a Claude app project is filed under that project here too.`,`A thread you never opened in the Claude app still comes across, with its task and every reply the project chat saw; open it once in the Claude app and import again for its whole conversation.`],fixed:[`Cursor chats appear in the import list again — they had been left out since September 10.`]},{version:`0.3.132`,date:`2026-09-23`,added:[`Reply to any part of a chat: select some text (or just right-click a block), choose Reply, and it is quoted in your message box — type your answer under it. A quote from a file the agent read names the file.`,`Right-click in a chat: copy what you selected, copy a whole reply or tool output, copy a code block or a link, find the selected words in the chat, or select a block.`,`Search in a chat opens the block its match is in — a folded tool card, a thought, a finished agent’s work — and scrolls to the words themselves.`,`Search matches are now bright orange, the current one strongest, so they stand out on code too.`,`The file viewer shows pictures (PNG, JPEG, GIF, WebP, SVG and more), plays audio and video, and shows Markdown formatted, with a switch to the source.`,`Right-click a file or folder in the explorer to copy its path or delete it.`],fixed:[`Moving a chat to another folder or project while it was working could delete the folder it was working in, start two agents at once, or send your next message to the old folder.`,`The working line no longer says a chat may be stuck while it waits for your approval or answer, or right after you send a message, and it counts time correctly (no more "4m 60s").`,`A date line no longer says "Today" for yesterday’s messages when the app stays open past midnight.`,"Installing with npm (`npm i -g oonacode`) installs this version again; earlier npm releases carried an old program.",`The What’s new window could open again on the next start, showing the same update a second time.`,`An older OonaCode window or VS Code extension no longer resets settings it does not know about, such as your theme colours or which project groups you folded.`,`A new install no longer opens with a list of changes; this window now appears only after an update.`,`The notification switch for permissions now says it also covers the agent’s questions.`]},{version:`0.3.131`,date:`2026-09-23`,added:[`Claude Opus 5.5 is here — the newest Opus, and cheaper to run than Opus 5. Choose it in the model picker, from the OonaCode pool or on your own Claude subscription. It runs on the newer Claude Code engine (2.1.280) that this update brings.`,`Every block in a chat shows its time at the bottom right, in your local time — hover it for the full date — and a date line marks where each day starts.`,`A running chat tells you how long the agent has been quiet, and after five minutes that it may be stuck and what to do.`,`After every update, OonaCode now opens this window to show you what changed.`],fixed:[`A reply that streamed in live had no time on it until the chat was opened again.`,`Chats open in tabs could fail to come back after a restart if a setting changed while they were being restored.`]}];function tl(e,t){let n=e=>{let[t,...n]=e.trim().replace(/^v/,``).split(`-`);return{nums:(t??``).split(`.`).map(e=>Number.parseInt(e,10)||0),pre:n.length>0?n.join(`-`):null}},r=n(e),i=n(t);for(let e=0;e<Math.max(r.nums.length,i.nums.length);e++){let t=(r.nums[e]??0)-(i.nums[e]??0);if(t!==0)return t}return r.pre===i.pre?0:r.pre===null?1:i.pre===null?-1:nl(r.pre,i.pre)}function nl(e,t){let n=e.split(`.`),r=t.split(`.`);for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e],i=r[e];if(t===i)continue;if(t===void 0)return-1;if(i===void 0)return 1;let a=/^\d+$/.test(t),o=/^\d+$/.test(i);if(a&&o){let e=Number(t)-Number(i);if(e!==0)return e;continue}return a===o?t<i?-1:1:a?-1:1}return 0}function rl(e,t,n=el,r=null){if(!e||e===`0.0.0`)return[];let i=n.filter(t=>tl(t.version,e)<=0&&(!r||!t.platforms||t.platforms.includes(r)));return[...t===null?i.filter(t=>tl(t.version,e)===0):i.filter(e=>tl(e.version,t)>0)].sort((e,t)=>tl(t.version,e.version))}function il(e,t,n,r=el,i=null){if(!e||e===`0.0.0`)return{record:null,show:[]};let a=null;for(let e of r)(a===null||tl(e.version,a)>0)&&(a=e.version);let o=a!==null&&tl(e,a)>0?a:e;return{record:t===null||tl(o,t)>0?o:null,show:t===null&&!n?[]:rl(e,t,r,i)}}function al(e,t){if(t==null)return[...e];if(t.length===0)return[];let n=new Set(t),r=e.filter(e=>n.has(e.id));return r.length>0?r:[...e]}var ol=`:free`;function sl(e){return e.endsWith(ol)}function cl(e){return sl(e)?e.slice(0,-5):e}var ll=`the user skipped the question`,ul=`(the user skipped this question)`;function dl(e){let t=e?.questions;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e;if(typeof t.question!=`string`)continue;let r=Array.isArray(t.options)?t.options.map(e=>e&&typeof e==`object`?e:null).filter(e=>e!==null&&typeof e.label==`string`).map(e=>({label:e.label,...typeof e.description==`string`?{description:e.description}:{}})):[];n.push({question:t.question,header:typeof t.header==`string`?t.header:``,options:r,multiSelect:t.multiSelect===!0})}return n}function fl(e,t,n={},r=new Set){let i={};return e.forEach((e,a)=>{if(r.has(a)){i[e.question]=ul;return}let o=(n[a]??``).trim();i[e.question]=o||(t[a]??[]).join(`, `)}),i}function pl(e){let t=e.questions,n=t===1?`question`:`questions`,r=t===1?`the model’s question`:`the model’s questions`,i=t===1?`The model’s question was`:`The model’s questions were`;switch(e.outcome){case`answered`:{let r=e.answers?Object.values(e.answers):null,i=r?r.filter(e=>typeof e==`string`&&e!==``&&e!==`(the user skipped this question)`).length:t;return t>0&&i<t?`You answered ${i} of ${t} ${n}`:t===0?`You answered the model’s questions`:t===1?`You answered the model’s question`:`You answered ${t} ${n}`}case`skipped`:return`You skipped ${r}`;case`dismissed`:return`${i} dismissed`;case`unanswered`:return`${i} not answered — the turn ended`}}function ml(e){if(!e||typeof e!=`object`)return null;let t=e.answers;return t&&typeof t==`object`&&!Array.isArray(t)?t:null}var hl=[`win32`,`linux`,`darwin`],gl=[`demo`,`live`],_l=[`allow`,`ask`],vl=[`string`,`number`,`integer`,`boolean`,`array`,`object`];function yl(e){let t=e/1048576;return t>=100?`${Math.round(t)} MB`:t>=1?`${t.toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function bl(e){if(e.toolName!==`InstallToolPack`)return null;let t=e.input;return!t||typeof t!=`object`||typeof t.pack!=`string`||typeof t.name!=`string`||typeof t.version!=`string`||typeof t.sizeBytes!=`number`||typeof t.path!=`string`?null:{pack:t.pack,name:t.name,version:t.version,sizeBytes:t.sizeBytes,path:t.path}}function xl(e,t){let n=t?.[e.slug];return typeof n==`boolean`?n:e.defaultOn}function Sl(e,t){return e.filter(e=>xl(e,t))}var Cl={slug:48,name:80,entryTool:40,description:2e3,promptLine:1e3,details:8e3,actionDescription:1e3,params:30,paramName:48,paramDescription:400,enumValues:40,callArgKeys:20,callError:500,callBatch:100},wl=/^[A-Za-z0-9_-]+$/;function Tl(e){return typeof e==`string`&&e.length>0&&e.length<=Cl.entryTool&&wl.test(e)}function El(e){return Math.ceil(e.length/4)}function Dl(e){return El(`${e.entryTool} ${e.description}`)+55}function Ol(e){return e.tokensPerRequest??Dl(e)+(e.promptLine?El(e.promptLine):0)}var kl=Ho({type:Qo(vl),required:Po().optional(),enum:Bo(Wo([H(),Ao()])).optional(),description:H().optional()}),Al=Ho({slug:H().min(1),description:H(),params:Xo(H(),kl),permission:Qo(_l),sort:Ao()}),jl=Ho({version:H(),url:H(),sha256:H(),sizeBytes:Ao(),exe:H(),format:es(`zip`)}),Ml=Ho({slug:H().min(1),name:H(),entryTool:H().refine(Tl,`not a valid tool name`),description:H(),promptLine:H().nullable(),details:H().nullable().optional(),status:Qo(gl),defaultOn:Po(),sort:Ao(),install:jl.nullable(),actions:Bo(Al)}).loose();Ho({platform:Qo(hl),version:H(),packs:Bo(Ml),refreshMinutes:Ao()});var Nl=[`No answer needed.`,`"Talk to other chats" is off in this chat: this message is from another chat's agent, not the person, and you cannot message chats. Your final answer goes back to that chat by itself.`,`"Talk to other chats" is off in this chat: this message is from another chat's agent, not the person, and you cannot message chats. It asked for no answer, so nothing goes back.`,`Last hop of this chain: you cannot message chats in this turn; put what you have in your final answer.`];[`**Let this chat work together with your other chats.**`,``,`### What it does`,`- Finds your other chats on this PC and reads their recent messages.`,`- Sends one chat, or a group of chats, a message or a task.`,`- Brings their answers back to this chat, by itself.`,``,`### How it works`,`- A chat that is asleep is woken from its saved history. A busy one gets the message when its current turn ends, never in the middle of it.`,`- The other chat does the work with its own model, folder and tools. Its answer comes back here as a new message only when this chat asked for one.`,`- Several messages from one chat that wait for a busy chat are handed over together, in one turn, with one answer.`,`- Several chats can share one conversation (a group). An answer goes only to the chat that asked, so a group cannot multiply its own messages.`,`- A chat with this switch OFF can still be messaged by a chat that has it on. It does the work, and its final answer goes back to that chat when that chat asked for one. That is all it can do: it gets none of these tools, cannot message or read other chats, and its switch stays off.`,``,`### What it costs`,`- About 650 tokens on every request while it is on, read from the prompt cache. Nothing while it is off, even in a chat that is messaged.`,`- Every message makes the chat that receives it do a turn, which spends its own tokens.`,`- Switching it on or off in a chat that already has a conversation re-writes its prompt cache once.`,``,`### Safety limits`,`- Each conversation has a budget: 20 delivered messages and 1,000,000 new tokens by default (context read back from the prompt cache is not counted). Reaching either pauses the conversation, and the chats say so.`,`- A chain stops after 3 hops (a message caused by a message caused by a message).`,`- At most 5 messages between two chats and 20 from one chat in 10 minutes, and 10 waiting for any one chat. A chat cannot message itself.`,`- A conversation with no activity for 24 hours closes by itself.`,``,`### How to stop it`,`- Turn this switch off: the chat loses these tools, and what it sent and the answers it asked for pause. It still answers a chat that messages it.`,`- Or open the Conversations window and use Pause, Close or Stop all.`,``,`### Privacy`,`- Everything stays on your PC: the messages are kept in this PC's database, never on OonaCode's server.`,`- A message never grants anything. The other chat runs with its own permissions and asks you as usual.`,``,`Only a chat with this switch on can start a conversation; a chat with it off only answers.`].join(`
|
|
77
|
+
`,18);return t<0?null:{title:e.slice(18,t),prompt:e.slice(t+3)}}Object.freeze({tengu_amber_sentinel:!0,tengu_groovy_eclipse:!0,tengu_humble_hammock:!0});function rc(e){return e===null||!Number.isFinite(e)?`neutral`:e>30?`ok`:e>10?`warn`:`danger`}var ic=[`mon`,`tue`,`wed`,`thu`,`fri`,`sat`,`sun`],ac=/^([01]\d|2[0-3]):[0-5]\d$/;Ho({tz:H().min(1),windows:Bo(Ho({from:H().regex(ac,`HH:MM`),to:H().regex(ac,`HH:MM`),days:Bo(Qo(ic)).optional(),kind:Qo([`peak`,`offpeak`])})),offpeakDiscount:Ao().nonnegative().max(1).optional()});var oc=[`priceInputCacheMissPeak`,`priceInputCacheMissOffpeak`,`priceInputCacheHitPeak`,`priceInputCacheHitOffpeak`,`priceCacheWritePeak`,`priceCacheWriteOffpeak`,`priceOutputPeak`,`priceOutputOffpeak`],sc=Ho({inputCacheMiss:Ao().nonnegative(),inputCacheHit:Ao().nonnegative().optional(),cacheWrite:Ao().nonnegative().optional(),output:Ao().nonnegative()});Ho({by:es(`prompt_tokens`),tiers:Bo(Ho({upToPromptTokens:Ao().int().positive().optional(),price:sc.optional(),cost:sc.optional()})).min(1),note:H().optional()}).superRefine((e,t)=>{let n=0;e.tiers.forEach((r,i)=>{!r.cost&&!r.price&&t.addIssue({code:`custom`,message:`a tier needs its cost (the provider’s rates; retail is cost × the record’s ratio)`,path:[`tiers`,i,`cost`]});let a=r.upToPromptTokens;if(a===void 0){i!==e.tiers.length-1&&t.addIssue({code:`custom`,message:`only the LAST tier may omit upToPromptTokens`,path:[`tiers`,i]});return}a<=n&&t.addIssue({code:`custom`,message:`tiers must ascend: ${a} does not exceed ${n}`,path:[`tiers`,i,`upToPromptTokens`]}),n=a})}),[...oc];var cc={realtime:`/v1/realtime`,translations:`/v1/realtime/translations`,live:`/v1/live/sessions`,speechStream:`/v1/audio/speech/stream`,transcriptionStream:`/v1/audio/transcriptions/stream`,clientSecrets:`/v1/realtime/client_secrets`,translationClientSecrets:`/v1/realtime/translations/client_secrets`};cc.realtime,cc.translations,cc.live,cc.speechStream,cc.transcriptionStream;var lc=`M0.72 12a11.28 11.28 0 1 0 22.56 0a11.28 11.28 0 1 0 -22.56 0ZM4.8 12a7.2 7.2 0 1 0 14.4 0a7.2 7.2 0 1 0 -14.4 0ZM7.44 12a4.56 4.56 0 1 0 9.12 0a4.56 4.56 0 1 0 -9.12 0Z`,uc=`M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z`,dc=`M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z`,fc=`M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81`,pc={oonacode:{hex:`#000000`,owner:`OonaCode`,d:lc,fillRule:`evenodd`},anthropic:{hex:`#D97757`,owner:`Anthropic`,d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`},"anthropic-subscription":{hex:`#D97757`,owner:`Anthropic`,d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`},openai:{hex:`#000000`,owner:`OpenAI`,d:dc},xai:{hex:`#000000`,owner:`xAI`,d:uc},deepseek:{hex:`#5786FE`,owner:`DeepSeek`,d:`M23.748 4.651c-.254-.124-.364.113-.512.233-.051.04-.094.09-.137.137-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.155-.708-.311-.955-.65-.172-.24-.219-.509-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.094.172.187.129.323-.082.28-.18.553-.266.833-.055.179-.137.218-.328.14a5.5 5.5 0 0 1-1.737-1.179c-.857-.828-1.631-1.743-2.597-2.46a12 12 0 0 0-.689-.47c-.985-.957.13-1.743.387-1.836.27-.098.094-.433-.778-.428-.872.003-1.67.295-2.687.685a3 3 0 0 1-.465.136 9.6 9.6 0 0 0-2.883-.101c-1.885.21-3.39 1.1-4.497 2.622C.082 8.776-.231 10.854.152 13.02c.403 2.284 1.568 4.175 3.36 5.653 1.857 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.132-.284 4.994-1.86.47.234.962.328 1.78.398.629.058 1.235-.031 1.705-.129.735-.155.684-.836.418-.961-2.155-1.004-1.682-.595-2.112-.926 1.095-1.295 2.768-3.598 3.284-6.733.05-.346.115-.834.108-1.114-.004-.171.035-.238.23-.257a4.2 4.2 0 0 0 1.545-.475c1.397-.763 1.96-2.016 2.093-3.517.02-.23-.004-.467-.247-.588M11.58 18.168c-2.088-1.642-3.101-2.183-3.52-2.16-.39.024-.32.472-.234.763.09.288.207.487.371.74.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.168-1.361-.801-2.5-1.86-3.301-3.306-.775-1.393-1.225-2.888-1.299-4.482-.02-.385.094-.522.477-.592a4.7 4.7 0 0 1 1.53-.038c2.131.311 3.946 1.264 5.467 2.774.868.86 1.525 1.887 2.202 2.89.72 1.066 1.494 2.082 2.48 2.915.348.291.626.513.892.677-.802.09-2.14.109-3.055-.615zm1.001-6.44a.306.306 0 0 1 .415-.287.3.3 0 0 1 .113.074.3.3 0 0 1 .086.214c0 .17-.136.307-.308.307a.303.303 0 0 1-.306-.307m3.11 1.596c-.2.081-.4.151-.591.16a1.25 1.25 0 0 1-.798-.254c-.274-.23-.47-.358-.551-.758a1.7 1.7 0 0 1 .015-.588c.07-.327-.007-.537-.238-.727-.188-.156-.426-.199-.689-.199a.6.6 0 0 1-.254-.078.253.253 0 0 1-.114-.358 1 1 0 0 1 .192-.21c.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.392.451.462.576.685.915.176.264.336.536.446.848.066.194-.02.353-.25.45`},kimi:{hex:`#000000`,owner:`Moonshot`,d:`M21.765.351C22.998.351 24 1.353 24 2.586S22.998 4.82 21.765 4.82h-1.974c-.15 0-.26-.12-.26-.26V2.586A2.237 2.237 0 0 1 21.765.35M9.41 13.388l8.447-8.377c.16-.16.07-.471-.14-.471h-4.55s-.1.02-.14.06l-9.099 9.029c-.14.14-.35.02-.35-.21V4.81c0-.15-.1-.27-.221-.27H.22c-.12 0-.22.12-.22.27v18.57c0 .15.1.27.22.27h3.137c.12 0 .22-.12.22-.27v-3.79c0-.08.03-.16.08-.21l2.826-2.796c.07-.07.16-.08.241-.03l7.546 5.551a8.9 8.9 0 0 0 4.018 1.493c.12.01.23-.11.23-.27V19.76c0-.14-.08-.25-.19-.26a5.8 5.8 0 0 1-2.355-.942l-6.533-4.73c-.14-.09-.15-.32-.03-.441`},qwen:{hex:`#6950EF`,owner:`Alibaba`,d:`M23.919 14.545 20.817 9.17l1.47-2.544a.56.56 0 0 0 0-.566l-1.633-2.83a.57.57 0 0 0-.49-.283h-6.207L12.487.402a.57.57 0 0 0-.49-.284H8.732a.56.56 0 0 0-.49.284L5.139 5.775h-2.94a.56.56 0 0 0-.49.284L.077 8.887a.56.56 0 0 0 0 .567L3.18 14.83l-1.47 2.545a.56.56 0 0 0 0 .566l1.634 2.83a.57.57 0 0 0 .49.283h6.205l1.47 2.545a.57.57 0 0 0 .49.284h3.266a.57.57 0 0 0 .49-.284l3.104-5.375h2.94a.57.57 0 0 0 .49-.283l1.634-2.828a.55.55 0 0 0-.004-.568M8.733.686l1.634 2.828-1.634 2.828H21.8L20.164 9.17H7.425L5.63 6.06Zm1.306 19.801-6.205-.002 1.634-2.83h3.265L2.201 6.344h3.267q3.182 5.517 6.367 11.032zm10.124-5.66L18.53 12l-6.532 11.315-1.634-2.83c2.129-3.673 4.25-7.351 6.373-11.028h3.592l3.102 5.374z`},"xai-subscription":{hex:`#000000`,owner:`xAI`,d:uc},"openai-subscription":{hex:`#000000`,owner:`OpenAI`,d:dc},"google-agy":{hex:`#8E75B2`,owner:`Google`,d:fc},antigravity:{hex:`#8E75B2`,owner:`Google`,d:fc},glm:{hex:`#2D2D2D`,owner:`Z.ai`,d:`M12.606 1.806l-1.677 2.388c-0.258 0.374-0.697 0.606-1.161 0.606h-9.162V1.794C0.594 1.806 12.606 1.806 12.606 1.806zM24 1.806L9.6 22.206 0 22.206 14.4 1.806zM11.394 22.206l1.69-2.4c0.258-0.374 0.697-0.606 1.161-0.606h9.149v3.006H11.394z`},mimo:{hex:`#FF6900`,owner:`Xiaomi`,d:`M12 0C8.016 0 4.756.255 2.493 2.516.23 4.776 0 8.033 0 12.012c0 3.98.23 7.235 2.494 9.497C4.757 23.77 8.017 24 12 24c3.983 0 7.243-.23 9.506-2.491C23.77 19.247 24 15.99 24 12.012c0-3.984-.233-7.243-2.502-9.504C19.234.252 15.978 0 12 0zM4.906 7.405h5.624c1.47 0 3.007.068 3.764.827.746.746.827 2.233.83 3.676v4.54a.15.15 0 0 1-.152.147h-1.947a.15.15 0 0 1-.152-.148V11.83c-.002-.806-.048-1.634-.464-2.051-.358-.36-1.026-.441-1.72-.458H7.158a.15.15 0 0 0-.151.147v6.98a.15.15 0 0 1-.152.148H4.906a.15.15 0 0 1-.15-.148V7.554a.15.15 0 0 1 .15-.149zm12.131 0h1.949a.15.15 0 0 1 .15.15v8.892a.15.15 0 0 1-.15.148h-1.949a.15.15 0 0 1-.151-.148V7.554a.15.15 0 0 1 .151-.149zM8.92 10.948h2.046c.083 0 .15.066.15.147v5.352a.15.15 0 0 1-.15.148H8.92a.15.15 0 0 1-.152-.148v-5.352a.15.15 0 0 1 .152-.147Z`}};function mc(e){return pc[e]??null}function hc(e){let t=e.replace(/\(.*?\)/g,` `).split(/[\s/_-]+/).filter(Boolean);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():`${t[0][0]}${t[1][0]}`.toUpperCase()}var gc=9230,_c=1024,vc=65534,yc=`127.0.0.1`;Object.freeze({enabled:!1,port:gc,inspectMain:!1}),Object.freeze({port:null,listening:!1,fromCommandLine:!1,inspectPort:null,inspectProblem:null});function bc(e){return e+1}function xc(e){return typeof e==`number`&&Number.isInteger(e)}function Sc(e){return!xc(e)||e<1024||e>65534?`The port must be a whole number from ${_c.toLocaleString(`en-US`)} to ${vc.toLocaleString(`en-US`)} (the main-process inspector takes the next one).`:null}function Cc(e){return e.port!==null||e.inspectPort!==null}function wc(e,t){let n=e.enabled?e.port:null,r=e.enabled&&e.inspectMain?bc(e.port):null;return!t.fromCommandLine&&t.port!==n||t.inspectPort!==r}function Tc(e){let t=[];return e.port!==null&&t.push(`${yc}:${e.port}`),e.inspectPort!==null&&t.push(`${yc}:${e.inspectPort}`),t.length===2?`${t[0]} (windows) and ${t[1]} (main process)`:e.inspectPort===null?t[0]??``:`${t[0]} (main process)`}var Ec=[`stable`,`dev`];function Dc(e){return typeof e==`string`&&Ec.includes(e)}function Oc(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return Dc(t)?t:null}var kc=[`win32`,`linux`,`darwin`],Ac=[`x64`,`arm64`];function jc(e,t){let n=Oc(e)??`stable`,r=[];return n!==`stable`&&r.push(`channel=${encodeURIComponent(n)}`),t&&kc.includes(t.platform)&&(r.push(`platform=${t.platform}`),t.arch&&Ac.includes(t.arch)&&r.push(`arch=${t.arch}`)),r.length>0?`${Ks.releasesLatest}?${r.join(`&`)}`:Ks.releasesLatest}function Mc(e,t){let n=Oc(t)??`stable`;return n===`stable`?e:`${e} (${n})`}var Nc=5e4,Pc=6,Fc=[`bg`,`surface`,`surface-2`,`surface-3`,`border`,`fg`,`fg-muted`,`fg-faint`,`accent`,`accent-fg`,`accent-soft`,`project`,`ok`,`ok-soft`,`warn`,`warn-soft`,`danger`,`danger-soft`,`think`,`think-soft`,`code-bg`,`user-bubble`],Ic={agentFinished:!1,permissionRequired:!0,errorOccurred:!0},Lc={autoAcceptPermissions:!1,showReasoningSummaries:!0,notifications:Ic,showAgentPicker:!0,transcriptWindowSize:500,openTabs:[],draftTabs:[],draftTitles:{},activeTab:null,editorLayout:null,remoteTabs:{},sessionPanelOpen:!1,explorerOpen:!1,sidebarWidth:288,sidebarPinned:!0,dismissedUpdateVersion:null,lastSeenReleaseNotes:null,claudeImportOffered:!1,claudeImportOffers:0,collapsedProjects:[],themeColors:{light:{},dark:{}},pinned:[],sidebarView:`recent`};function Rc(e){return Math.min(Math.max(typeof e==`number`&&Number.isFinite(e)?Math.floor(e):0,0),3)}function zc(e){return Math.min(640,Math.max(200,typeof e==`number`&&Number.isFinite(e)?Math.round(e):288))}function Bc(e){return Math.min(Nc,Math.max(100,typeof e==`number`&&Number.isFinite(e)?Math.round(e):500))}function Vc(e,t){return typeof e==`boolean`?e:t}function Hc(e){return typeof e==`string`&&e.length>0&&e.length<=64?e:null}function Uc(e,t=50){if(!Array.isArray(e))return[];let n=[];for(let r of e)if(!(typeof r!=`string`||r.length===0||r.length>200)&&!n.includes(r)&&(n.push(r),n.length>=t))break;return n}function Wc(e,t=50){if(typeof e!=`object`||!e||Array.isArray(e))return{};let n={};for(let[r,i]of Object.entries(e))if(!(r.length===0||r.length>200)&&!(typeof i!=`string`||i.length===0||i.length>200)&&(n[r]=i,Object.keys(n).length>=t))break;return n}function Gc(e){if(typeof e!=`string`)return null;let t=e.trim();return/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():null}function Kc(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(!Fc.includes(n))continue;let e=Gc(r);e!==null&&(t[n]=e)}return t}function qc(e){let t=typeof e==`object`&&e?e:{};return{light:Kc(t.light),dark:Kc(t.dark)}}function Jc(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=n.kind,r=n.id;if((e===`chat`||e===`project`)&&!(typeof r!=`string`||r.length===0||r.length>200)&&!t.some(t=>t.kind===e&&t.id===r)&&(t.push({kind:e,id:r}),t.length>=50))break}return t}function Yc(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return null;let n=e,r=new Set(t),i=new Set,a=0,o=(e,t)=>{if(t>Pc||typeof e!=`object`||!e)return null;let n=e,s=n.group;if(typeof s==`object`&&s&&!Array.isArray(s)){if(a>=8)return null;let e=s,t=[];for(let n of Array.isArray(e.tabs)?e.tabs:[])typeof n!=`string`||!r.has(n)||i.has(n)||(i.add(n),t.push(n));return t.length===0?null:(a+=1,{group:{tabs:t,active:(typeof e.active==`string`&&t.includes(e.active)?e.active:null)??t[t.length-1]}})}let c=n.split;if(c!==`row`&&c!==`column`)return null;let l=Array.isArray(n.children)?n.children:[],u=Array.isArray(n.sizes)?n.sizes:[],d=[],f=[];if(l.slice(0,8).forEach((e,n)=>{let r=o(e,t+1);if(!r)return;d.push(r);let i=u[n];f.push(typeof i==`number`&&Number.isFinite(i)&&i>0?i:0)}),d.length===0)return null;if(d.length===1)return d[0];let p=f.filter(e=>e>0),m=p.length>0?p.reduce((e,t)=>e+t,0)/p.length:1,h=f.map(e=>e>0?e:m),g=h.reduce((e,t)=>e+t,0);return{split:c,sizes:h.map(e=>e/g),children:d}},s=o(n.root,0);if(!s||a<2)return null;let c=n.focused;return{root:s,focused:typeof c==`number`&&Number.isInteger(c)&&c>=0&&c<a?c:0}}function Xc(e,t,n){return e.some(e=>e.kind===t&&e.id===n)}function Zc(e,t,n,r){return r===Xc(e,t,n)?e:r?[...e.length>=50?e.slice(e.length-50+1):e,{kind:t,id:n}]:e.filter(e=>e.kind!==t||e.id!==n)}function Qc(e){let t=typeof e==`object`&&e?e:{},n=typeof t.notifications==`object`&&t.notifications!==null?t.notifications:{},r=Uc(t.openTabs),i=Uc(t.draftTabs).filter(e=>!r.includes(e)),a={};for(let[e,n]of Object.entries(Wc(t.draftTitles)))i.includes(e)&&(a[e]=n);let o=[...r,...i],s=t.activeTab,c=typeof s==`string`&&o.includes(s)?s:o[o.length-1]??null;return{autoAcceptPermissions:Vc(t.autoAcceptPermissions,Lc.autoAcceptPermissions),showReasoningSummaries:Vc(t.showReasoningSummaries,Lc.showReasoningSummaries),notifications:{agentFinished:Vc(n.agentFinished,Ic.agentFinished),permissionRequired:Vc(n.permissionRequired,Ic.permissionRequired),errorOccurred:Vc(n.errorOccurred,Ic.errorOccurred)},showAgentPicker:Vc(t.showAgentPicker,Lc.showAgentPicker),transcriptWindowSize:Bc(t.transcriptWindowSize),openTabs:r,draftTabs:i,draftTitles:a,activeTab:c,editorLayout:Yc(t.editorLayout,o),remoteTabs:Wc(t.remoteTabs),sessionPanelOpen:Vc(t.sessionPanelOpen,Lc.sessionPanelOpen),explorerOpen:Vc(t.explorerOpen,Lc.explorerOpen),sidebarWidth:zc(t.sidebarWidth),sidebarPinned:Vc(t.sidebarPinned,Lc.sidebarPinned),dismissedUpdateVersion:Hc(t.dismissedUpdateVersion),lastSeenReleaseNotes:Hc(t.lastSeenReleaseNotes),claudeImportOffered:Vc(t.claudeImportOffered,Lc.claudeImportOffered),claudeImportOffers:Rc(t.claudeImportOffers),collapsedProjects:Uc(t.collapsedProjects),themeColors:qc(t.themeColors),pinned:Jc(t.pinned),sidebarView:t.sidebarView===`projects`?`projects`:`recent`}}new Set(Object.keys(Lc));var $c=3650,el=[{version:`0.3.210`,date:`2026-10-05`,added:[`Use a project folder opens on the folder the chat runs in — its project, or the workspace OonaCode made for it — instead of an empty box.`],fixed:[`Send now on one queued message no longer makes the other queued messages look sent: they stay under the chat, each with its own Send now, and get their tick when the agent reads them.`,`After you confirm the agent’s request to move a chat to another folder, the chat shows the new folder at once, not only after your next message.`]},{version:`0.3.209`,date:`2026-10-05`,platforms:[`win32`,`darwin`],added:[`Scheduled tasks say which model a run uses: always the chat’s model at the moment the task fires, named in the Scheduled tasks panel.`],fixed:[`A Google Gemini chat keeps Google’s agent running for half an hour between messages, so the next message after a pause no longer waits about four seconds for agy to start.`,`Commands run in a Google Gemini chat reach servers on your own PC (localhost) and plain http:// sites again.`]},{version:`0.3.209`,date:`2026-10-05`,platforms:[`linux`],added:[`Grok 4.7, xAI’s newest model, on the OonaCode pool and on your own SuperGrok subscription — and an effort picker for Grok 4.7, 4.6 and 4.5 (low, medium, high, extra high), sent the way xAI’s own Grok CLI sends it.`,`Every provider in the model picker shows its own logo — Google’s Gemini mark for Google, xAI’s for your SuperGrok, OpenAI’s for your ChatGPT plan, Z.ai’s for GLM — instead of two letters.`,`Scheduled tasks say which model a run uses: always the chat’s model at the moment the task fires, named in the Scheduled tasks panel.`],fixed:[`When a subscription behind the OonaCode pool refuses or fails a request, the same request is answered at once from the provider’s API key instead of showing you the error.`,`Grok on your own SuperGrok subscription and on the OonaCode pool works again: xAI started refusing the Grok CLI identity OonaCode presented as outdated.`,`When your own subscription’s sign-in stops working, the chat now says so and asks you to sign in again, instead of a confusing “own-subscription providers run directly to the provider” error.`,`A Google Gemini chat keeps Google’s agent running for half an hour between messages, so the next message after a pause no longer waits about four seconds for agy to start.`,`Commands run in a Google Gemini chat reach servers on your own PC (localhost) and plain http:// sites again.`]},{version:`0.3.208`,date:`2026-10-04`,platforms:[`win32`,`darwin`],added:[`Grok 4.7, xAI’s newest model, on the OonaCode pool and on your own SuperGrok subscription — and an effort picker for Grok 4.7, 4.6 and 4.5 (low, medium, high, extra high), sent the way xAI’s own Grok CLI sends it.`,`Every provider in the model picker shows its own logo — Google’s Gemini mark for Google, xAI’s for your SuperGrok, OpenAI’s for your ChatGPT plan, Z.ai’s for GLM — instead of two letters.`],fixed:[`When a subscription behind the OonaCode pool refuses or fails a request, the same request is answered at once from the provider’s API key instead of showing you the error.`,`Grok on your own SuperGrok subscription and on the OonaCode pool works again: xAI started refusing the Grok CLI identity OonaCode presented as outdated.`,`When your own subscription’s sign-in stops working, the chat now says so and asks you to sign in again, instead of a confusing “own-subscription providers run directly to the provider” error.`]},{version:`0.3.207`,date:`2026-10-04`,added:[`Every chat lists every provider you have connected and the OonaCode pool — Google Gemini too, whatever the chat ran on before. Switching keeps the conversation: a chat moving off Google continues with its whole history, and a chat moving onto Google gives Google’s agent the conversation so far, so it can carry on.`],fixed:[`Two messages sent a moment apart while a chat was starting no longer leave one of them stuck in the queued strip: the engine had read them together as one message, and OonaCode now recognises that.`]},{version:`0.3.206`,date:`2026-10-04`,platforms:[`win32`],added:[`Google Gemini installs Google’s agy by itself the first time you use it — open the provider in Settings → Providers, or send a message to a Google Gemini chat — instead of waiting for you to press Install.`],fixed:[`Deleting a chat now says what really happens: a chat is kept only on the PC it runs on, so deleting it there removes it everywhere.`,`oona doctor no longer tells you to change settings that OonaCode stopped reading.`]},{version:`0.3.206`,date:`2026-10-04`,platforms:[`linux`],added:[`Gemini on your own Google plan, through Google’s own agent. Open Settings → Providers → Google Gemini: OonaCode downloads Google’s agy for you and checks it. Then press Sign in with Google, sign in on Google’s own page and paste the one-time code back within the minute agy allows. OonaCode never sees your password. Every model your Google plan offers through agy is listed — Gemini 3.8, 3.7 and 3.6 Flash, Gemini 3.1 Pro, and Claude Opus 5.5, Claude Sonnet 5.5 and GPT-OSS 120B marked “via Google”. A Google Gemini chat runs Google’s agent as it is (Build or Autonomous mode, text only), and the chat’s info panel lists every request it made to Google.`,`Every provider in the model picker ends with a “Custom model…” row: type any model id and the chat runs it on that provider.`],fixed:[`The agents badge highlights what is happening now: “4 working” is blue and the total is grey.`,`Deleting a chat now says what really happens: a chat is kept only on the PC it runs on, so deleting it there removes it everywhere.`]},{version:`0.3.206`,date:`2026-10-04`,platforms:[`darwin`],added:[`Gemini on your own Google plan, through Google’s own agent. Open Settings → Providers → Google Gemini: OonaCode downloads Google’s agy for you and checks it. Then press Sign in with Google, sign in on Google’s own page and paste the one-time code back within the minute agy allows. OonaCode never sees your password. Every model your Google plan offers through agy is listed — Gemini 3.8, 3.7 and 3.6 Flash, Gemini 3.1 Pro, and Claude Opus 5.5, Claude Sonnet 5.5 and GPT-OSS 120B marked “via Google”. A Google Gemini chat runs Google’s agent as it is (Build or Autonomous mode, text only), and the chat’s info panel lists every request it made to Google.`,`Every provider in the model picker ends with a “Custom model…” row: type any model id and the chat runs it on that provider.`],fixed:[`The agents badge highlights what is happening now: “4 working” is blue and the total is grey.`,`The command line’s reinstall hint on a Mac is the one that works: curl -fsSL https://oonacode.oonak.ai/install.sh | bash.`]},{version:`0.3.205`,date:`2026-10-04`,platforms:[`win32`],added:[`Google Gemini now lists every model your Google plan offers through agy, not only Gemini: Claude Opus 5.5, Claude Sonnet 5.5 and GPT-OSS 120B (marked “via Google”) sit beside Gemini 3.8, 3.7 and 3.6 Flash and Gemini 3.1 Pro. They run on Google’s own agent with your Google plan, and have their own usage window.`],fixed:[]},{version:`0.3.204`,date:`2026-10-04`,platforms:[`win32`],added:[`Signing in to Google Gemini opens Google’s page for you and shows how many seconds are left: Google’s agy waits only one minute for the sign-in. Paste the code Google shows and it is sent at once.`],fixed:[`Signing in to Google Gemini finishes. The code you pasted never reached Google’s agy in the installed app (the window it types into dropped everything typed), so the sign-in waited out its minute and failed.`,`The Claude sign-in’s “paste the code” box, which used the same window, can type the code too.`]},{version:`0.3.203`,date:`2026-10-04`,platforms:[`win32`],added:[`Gemini on your own Google plan, through Google’s own agent. Open Settings → Providers → Google Gemini and press Install: OonaCode downloads Google’s agy for you and checks it. Then press Sign in with Google, sign in on Google’s own page and paste the one-time code back here. OonaCode never sees your password. A Google Gemini chat runs Google’s agent as it is (Build or Autonomous mode, text only, no pictures), and the chat’s info panel lists every request it made to Google.`,`Every provider in the model picker ends with a “Custom model…” row: type any model id and the chat runs it on that provider.`],fixed:[`The agents badge highlights what is happening now: “4 working” is blue and the total (“51 agents”) is grey, instead of the other way round.`]},{version:`0.3.202`,date:`2026-10-03`,platforms:[`darwin`],added:[`OonaCode runs on macOS 12 or newer: the agent, your chats, the background service and the desktop app, installed with the same one line as on Linux — curl -fsSL https://oonacode.oonak.ai/install.sh | bash. An Intel build; Apple Silicon Macs run it through Rosetta 2. Your sign-in key is kept in your login keychain.`,`Updating is the same line again, oona update in a terminal, or the update button in the app: it closes OonaCode, puts the new version in place and opens it again. The app is not signed by Apple yet, so it cannot be downloaded from a browser and does not update itself the way it does on Windows.`],fixed:[]},{version:`0.3.202`,date:`2026-10-03`,platforms:[`linux`],added:[],fixed:[`Your sign-in survives a restart on a PC that keeps OonaCode’s key in the login keyring (GNOME Keyring, KWallet): two of OonaCode’s keys shared one keyring entry and overwrote each other, and every start of the host wrote over the stored key — so after a restart you could find yourself signed out.`,`OonaCode never runs a Claude Code you installed yourself as its engine, even when it sits in the same folder as the Node.js that runs OonaCode (an nvm folder, for example).`,`oona update installs from the site your OonaCode was installed from, not always from oonacode.oonak.ai.`]},{version:`0.3.202`,date:`2026-10-03`,platforms:[`win32`],added:[],fixed:[`OonaCode never runs a Claude Code you installed yourself as its engine, even when it sits in the same folder as the Node.js that runs OonaCode.`]},{version:`0.3.201`,date:`2026-10-03`,added:[`The Tools menu lists only tools that work. Desktop control, Clipboard, Screen capture and Run as administrator were demos that never ran anything, and they are gone: the agent already reads and sets your clipboard, takes screenshots and asks Windows for administrator rights through its own commands.`],fixed:[`Oonak Browser keeps working when its window is behind other windows. A browser covered by the OonaCode window used to crawl, and some clicks and scrolls gave up after 30 seconds.`,`Oonak Browser no longer clicks a hidden copy of a link, or a link inside a closed menu, when a site has both a visible and a hidden one.`,`A message you send right after a reply failed no longer stays pinned above the box as “queued” once the agent has read it.`]},{version:`0.3.200`,date:`2026-10-03`,platforms:[`win32`],added:[`Everything OonaCode shows you is in credits, never in dollars: the model picker gives what an OonaCode pool model charges per 1M tokens in credits, and a chat’s spend, Usage, Conversations, Listen and the terminal all count credits. A chat on your own key or your own subscription says so instead of a price.`],fixed:[`Oonak Browser works on sites built from web components, Google’s own forms among them: it reads, finds, clicks and types inside them, where it used to answer “the page changed” or find nothing.`,`The model’s questions appear only in their own window: the chat no longer shows the question’s raw text while you answer, and afterwards keeps one line — “You answered 3 questions” — that opens to your answers.`]},{version:`0.3.200`,date:`2026-10-03`,platforms:[`linux`],added:[`Your chats now live only on the PC that runs them. Your phone, the website and your other PCs read a chat straight from its PC, through the same encrypted connection they use to continue it — OonaCode’s server no longer keeps any copy. While a PC is off or asleep its chats cannot be read from elsewhere; the window says so and they come back when it is online. Update OonaCode on each of your PCs: another device reads a PC’s chats only once that PC runs this version.`,`Everything OonaCode shows you is in credits, never in dollars: the model picker gives what an OonaCode pool model charges per 1M tokens in credits, and a chat’s spend, Usage, Conversations, Listen and the terminal all count credits. A chat on your own key or your own subscription says so instead of a price.`,`Listen has one button: Play. It writes a summary when the chat has none or has moved on, translates it once when you pick a new language, or just plays — saying only “Generating…” or “Translating…” while it works. A summary written in the last ten minutes is used for every language, so switching language never writes it again.`,`A morning briefing in View → What chats are about…: show the chats active in the last 24 hours, 3, 7, 10 or 30 days (or your own dates), tick the ones you want — or all — pick a language, a voice and a speed, and press Play. OonaCode reads each chat’s name and what it is about, one after another, with Next, Previous, Pause and Stop.`,`A chat can offer to move a task to a new chat. When a task deserves its own chat — a separate job, a chat that has grown long, work in another folder — the model proposes it with the first message written out; you can edit it, then Start new chat opens the new chat in a tab, sends the message and carries on there. Nothing starts without your yes.`,`Talk to other chats: a chat can now write to a chat whose switch is off. That chat’s switch stays off and it gets no new tools — it can only answer the chat that wrote to it. Finding a chat by name matches each word, in its name, project, folder and description, and spelling like “AI-control” or “aicontrol” no longer matters.`,`Oonak Browser acts like a person: every click, keystroke and scroll is a real input event, so sites that ignore scripted clicks now respond, and it works inside web components, Google’s own forms among them. Typing into a drop-down picks the option, and typing into an editor adds the text at its end.`,`Scheduled shows at a glance what will still run: paused tasks and one-time tasks that have already run are greyed out, with the day they will be removed — 10 days after their last change.`,`Settings → Developer → Allow debugging: opens a debugging port on this PC only, so a developer can look at and drive the app while fixing a problem with you. Off by default; while it is on, every window shows a red “Debugging on” badge.`],fixed:[`A chat keeps its Build / Plan / Ask first / Autonomous choice, and every device shows the same one. A chat set to “Ask first” now asks you before acting even when this PC answers prompts by itself.`,`A chat no longer ends up on a model nobody picked for it: a model the provider does not offer is refused instead of quietly switching the chat to the provider’s default, and Enter in the model picker no longer picks the row under the mouse pointer.`,`Chats talking to each other no longer ping-pong: a reply needs no answer, several messages from the same chat are read together in one turn, and a message card says “answer requested” until the answer has gone back, then “answered” with the time.`,`A tool you switch on while a chat is replying works for the message you send next, even mid-reply. After an update, a chat that had background tasks running shows one line saying how many stopped, instead of one card per task.`,`The model’s questions appear only in their own window: the chat no longer shows the question’s raw text while you answer, and afterwards keeps one line — “You answered 3 questions” — that opens to your answers.`,`A model your plan does not include now says “not in your plan”, instead of “Failed to authenticate … sign-in needed”.`,`A long message waiting in the queue no longer hides its “Send now” button: it is folded to a few lines, with Show all to read the rest.`,`The account window no longer stays on “offline · vault event stream responded 503” after a short server interruption.`]},{version:`0.3.199`,date:`2026-10-02`,platforms:[`win32`],added:[`Talk to other chats: a chat can now write to a chat whose switch is off. That chat’s switch stays off and it gets no new tools — it can only answer the chat that wrote to it. Finding a chat by name is smarter too: each word is matched, in its name, project, folder and description, and spelling like “AI-control” or “aicontrol” no longer matters.`,`Oonak Browser acts like a person: every click, keystroke and scroll is a real input event, so sites that ignore scripted clicks now respond. Typing into a drop-down picks the option, and typing into an editor adds the text at its end.`],fixed:[`A chat no longer ends up on a model nobody picked for it: a model the provider does not offer is refused instead of quietly switching the chat to the provider’s default, and Enter in the model picker no longer picks the row under the mouse pointer.`]},{version:`0.3.198`,date:`2026-10-01`,platforms:[`win32`],added:[`Listen has one button: Play. It writes a summary when the chat has none or has moved on, translates it once when you pick a new language, or just plays — saying only “Generating…” or “Translating…” while it works. A summary written in the last ten minutes is used for every language, so switching language never writes it again.`],fixed:[`A chat keeps its Build / Plan / Ask first / Autonomous choice, and every device shows the same one — the phone used to show “Ask first” for a Build chat. A chat set to “Ask first” now asks you before acting even when this PC answers prompts by itself.`,`Play in Listen is never greyed out for want of a voice: it gets the text ready and names the voice to install.`]},{version:`0.3.197`,date:`2026-10-01`,platforms:[`win32`],added:[`Oonak Browser, the browser your chats use, moves to version 151 by itself at its next use: a build with no Google services (no Safe Browsing warnings, push notifications or search suggestions). The download is checked against its fingerprint before anything is unpacked, and the old version is removed once no chat’s browser still runs from it.`],fixed:[`A model your plan does not include now says “not in your plan”, instead of “Failed to authenticate … sign-in needed”.`]},{version:`0.3.196`,date:`2026-10-01`,platforms:[`win32`],added:[`Your chats now live only on the PC that runs them. Your phone, the website and your other PCs read a chat straight from its PC, through the same encrypted connection they use to continue it — OonaCode’s server no longer keeps any copy. While a PC is off or asleep its chats cannot be read from elsewhere; the window says so and they come back when it is online. Update OonaCode on each of your PCs: another device reads a PC’s chats only once that PC runs this version.`],fixed:[`The account window no longer stays on “offline · vault event stream responded 503” after a short server interruption: the next sync that works clears it by itself.`]},{version:`0.3.195`,date:`2026-10-01`,platforms:[`win32`],added:[],fixed:[`Chats talking to each other no longer ping-pong. A message asks for an answer only when the chat really needs one; a reply needs no answer and is not answered with a new message; and several messages waiting from the same chat are read together in one turn. Fewer wake-ups, fewer tokens.`,`A message card says what is true: “answer requested” until the answer has gone back, then “answered” with the time — instead of an orange “reply expected” that never went away.`]},{version:`0.3.194`,date:`2026-10-01`,platforms:[`win32`],added:[`A chat can offer to move a task to a new chat. When a task deserves its own chat — a separate job, a chat that has grown long, work in another folder — the model proposes it with the first message written out; you can edit it, then Start new chat opens the new chat in a tab, sends the message and carries on there. Nothing starts without your yes.`,`Settings → Developer → Allow debugging: opens a debugging port on this PC only, so a developer can look at and drive the app while fixing a problem with you. Off by default; while it is on, every window shows a red “Debugging on” badge.`],fixed:[]},{version:`0.3.193`,date:`2026-10-01`,platforms:[`win32`],added:[],fixed:[`A tool you switch on while a chat is replying works for the message you send next, even mid-reply: that message now waits for the chat to restart with the new tool instead of reaching the model without it.`,`After an update, a chat that had background tasks running shows one line — “11 background tasks stopped — they were running when OonaCode restarted this chat” — instead of one card per task. Click it to see each one.`]},{version:`0.3.192`,date:`2026-09-30`,platforms:[`win32`],added:[`A morning briefing in View → What chats are about…: show the chats active in the last 24 hours, 3, 7, 10 or 30 days (or your own dates), tick the ones you want — or all — pick a language, a voice and a speed, and press Play. OonaCode reads each chat’s name and what it is about, one after another, with Next, Previous, Pause and Stop. Other languages are translated once and kept, so hearing the same briefing again costs nothing.`],fixed:[]},{version:`0.3.191`,date:`2026-09-30`,platforms:[`win32`],added:[`Scheduled shows at a glance what will still run: paused tasks and one-time tasks that have already run are greyed out, with the day they will be removed. They are deleted by themselves 10 days after their last change; resuming or editing a paused task gives it another 10 days.`],fixed:[]},{version:`0.3.190`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`A long message waiting in the queue no longer hides its “Send now” button: it is folded to a few lines, with Show all to read the rest.`]},{version:`0.3.189`,date:`2026-09-30`,platforms:[`linux`],added:[`Split views, like VS Code: drag a chat tab to the left, right, top or bottom of the chat area to open it beside the other one — a shaded area shows where it will land. Every chat on screen works on its own, with its own replies streaming and its own message box. Drag the divider to resize; Ctrl+\\ splits the current tab to the right, Ctrl+1, Ctrl+2… jump between views, and a tab’s menu has Split right, Split down and Move to other group.`,`Chats in windows of their own, like Chrome tabs: drag a tab out of the window, or choose “Move to new window” in its menu, and it opens in its own window; “Move to main window” brings it back. On Wayland desktops the new window opens at the usual place rather than under the pointer. Your split views and windows come back when you restart OonaCode.`,`Every language plays in Listen to a chat: each language picks the best voice on its own — OonaCode’s Armenian voices first, then your system’s voices, then eSpeak (install the espeak-ng package if your system has no voice for a language).`],fixed:[`Picking another language for a summary no longer needs a new summary: Play translates the one you have, keeps the translation, shows it and plays it.`,`“Summarise now” says “Up to date — nothing to summarise” while the chat has not changed, instead of seeming to do nothing.`]},{version:`0.3.188`,date:`2026-09-30`,platforms:[`win32`],added:[`Split views, like VS Code: drag a chat tab to the left, right, top or bottom of the chat area to open it beside the other one — a shaded area shows where it will land. Every chat on screen works on its own, with its own replies streaming and its own message box. Drag the divider to resize; Ctrl+\\ splits the current tab to the right, Ctrl+1, Ctrl+2… jump between views, and a tab’s menu has Split right, Split down and Move to other group.`,`Chats in windows of their own, like Chrome tabs: drag a tab out of the window, or choose “Move to new window” in its menu, and it opens in its own window. Drag it back onto the main window’s tabs, or choose “Move to main window”, to bring it back. Your split views and popped-out windows come back when you restart OonaCode.`],fixed:[]},{version:`0.3.187`,date:`2026-09-30`,platforms:[`win32`],added:[`Every language plays in Listen to a chat. Persian, Georgian, Ukrainian — and any language whose Windows voice is not installed — now speak with eSpeak, a free voice that comes with OonaCode (it sounds robotic, but it always works). Each language picks the best voice on its own: OonaCode’s Armenian voices first, then Windows’ own, then eSpeak.`],fixed:[`Picking another language for a summary no longer needs a new summary: Play translates the one you have, keeps the translation, shows it and plays it.`,`“Summarise now” says “Up to date — nothing to summarise” while the chat has not changed, instead of seeming to do nothing.`]},{version:`0.3.186`,date:`2026-09-30`,platforms:[`linux`],added:[`Listen to a chat: right-click a chat → Listen to this chat…, or the speaker button beside the chat’s title. The chat’s own model writes a short spoken summary — the goal, what was done, where it stands, what is left — and OonaCode reads it aloud on this PC, in the voice and at the speed you choose. Every summary is kept with its date, so you can play it again at any time; a new one is written only when the chat has moved on. Other languages are translated once and kept with the summary.`,`OonaCode brings two Armenian voices of its own, Astgh and Artsiv, and also speaks with your system’s voices through speech-dispatcher — install speech-dispatcher and espeak-ng for Persian, Russian and every other language; the Listen window names the packages for your distribution.`,`Listen to a chat from your phone: the OonaCode app’s 🔊 Listen reaches this PC’s summaries and plays them with the phone’s own voices. It needs this update on the PC and the next OonaCode app on the phone.`,`See where your credits go: Account → Usage. Pick the last 24 hours, 7, 30 or 90 days or your own dates, by hour or by day, for the coding agent or your API keys apart. A chart shows the credits over time by model or by what they were for, and the lists below give every model with its tokens and price, and every use — chat turns, a chat’s “about”, images, speech and the rest.`,`The chat list is laid out like the Claude desktop app: New, Projects, Scheduled, then your pinned chats and projects, then Today and Older. The old grouping by project is one click away — the small icon beside “Today”.`,`Projects opens a page of project cards — each with its goal, its chats and when it was last used — with search, sort and New project. Click a card to see that project’s chats, instructions and settings, and to start a new chat in it.`,`Scheduled shows every scheduled task from every chat on this PC in one place, with its next run, its chat, and pause, resume and delete. Pin any chat or project to the top of the list from its menu.`,`Claude Sonnet 5.5 is in the model picker — on the OonaCode pool and on your own Claude subscription — with a 1M-token context. It costs the same as Sonnet 5 per token and usually needs fewer tokens for the same work.`,`Type / at the start of a message to see the chat’s commands and skills, with what each does, in two titled sections. Type to narrow the list, then Enter or Tab. They work with every model, not only Claude.`,`Each chat has a Skills list beside Tools. Every skill starts off, so the model sees none of them and they cost nothing; switch one on to let the model use it by itself in that chat. Typing /name still runs any skill for one turn.`,`Your own skills: Settings → Skills lists the skills OonaCode gives every chat, and “Import from Claude Code…” copies the ones you choose from your Claude Code install — it only reads it, never changes it.`,`In the terminal app (oona), a command the chat’s engine knows — /context, /compact or a skill — now runs instead of answering “unknown command”.`,`Search in the Import window: find a chat by its name, its first or last message or its folder, or pick “Whole conversations” to search inside the chats themselves.`],fixed:[`Import chats shows every chat on this PC, grouped by the app it came from, with nothing folded away. Each row says whether it is new, already imported, moved on since, or deleted by you in OonaCode. Nothing is ticked when you open it yourself: search for a chat and tick it, or tick a whole group at once.`,`The message box fits a narrow chat: its buttons and pickers move onto a second line and the box grows to hold them — Stop and Queue no longer slip outside it.`,`Claude’s thoughts show their words again. Every “Thought” from Claude Opus, Sonnet and Fable came back empty — Anthropic leaves the text out unless it is asked for a summary, and now OonaCode asks. Only new replies change.`,`A chat’s “about” no longer starts in the middle of a sentence when the model wrote a long answer.`,`Commands that only duplicated OonaCode’s own controls or showed misleading numbers are gone from the / menu — /model, /usage, /autocompact, /output-style, /mcp, /list-agents and /reload-skills. Typed, they say why.`,`Skills you import or remove in Settings → Skills reach your chats by themselves, at each chat’s next message.`,`Claude Sonnet 5 is retired: a chat that was on it moves to Sonnet 5.5 at its next message.`,`The engine’s built-in keyboard-shortcuts helper is turned off: it would have edited your own Claude Code settings.`,`Typing /model in a chat updates the chat’s model and the model picker again, and command output such as /context reads the same while it arrives and after you reopen the chat.`,`A chat row’s ⋯ button shows only when you point at the row.`]},{version:`0.3.185`,date:`2026-09-30`,platforms:[`win32`],added:[`Listen to a chat from your phone: the OonaCode app’s 🔊 Listen reaches this PC’s summaries and plays them with the phone’s own voices. It needs this update on the PC and the next OonaCode app on the phone.`],fixed:[`Listening with a Windows voice no longer stops after the first sentence when the voice fails to say it has finished.`]},{version:`0.3.184`,date:`2026-09-30`,platforms:[`win32`],added:[`Listen to a chat: right-click a chat → Listen to this chat…, or the speaker button beside the chat’s title. The chat’s own model writes a short spoken summary — the goal, what was done, where it stands, what is left — and OonaCode reads it aloud on this PC, in the voice and at the speed you choose. Every summary is kept with its date, so you can play it again at any time; a new one is written only when the chat has moved on. Other languages are translated once and kept with the summary.`],fixed:[`A chat’s “about” no longer starts in the middle of a sentence when the model wrote a long answer.`]},{version:`0.3.183`,date:`2026-09-30`,platforms:[`win32`],added:[`See where your credits go: Account → Usage. Pick the last 24 hours, 7, 30 or 90 days or your own dates, by hour or by day, for the coding agent or your API keys apart. A chart shows the credits over time by model or by what they were for, and the lists below give every model with its tokens and price, and every use — chat turns, a chat’s “about”, images, speech and the rest.`],fixed:[]},{version:`0.3.182`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`Import chats shows every chat on this PC, grouped by the app it came from — Claude Code, the Claude app, Qwen Code, Cursor — with nothing folded away. Each row says whether it is new, already imported, moved on since, or deleted by you in OonaCode. Nothing is ticked when you open it yourself: search for a chat and tick it, or tick a whole group at once. The Import button says how many chats it will bring over.`]},{version:`0.3.181`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`The message box fits a narrow chat. In a small window, or with the side panels open, its buttons and pickers move onto a second line and the box grows to hold them — Stop and Queue no longer slip outside it, and the model and effort pickers keep their words readable.`]},{version:`0.3.180`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`Claude’s thoughts show their words again. Every “Thought” from Claude Opus, Sonnet and Fable came back empty — Anthropic leaves the text out unless it is asked for a summary, and now OonaCode asks. Other models were never affected. Only new replies change; older thoughts stay empty.`]},{version:`0.3.179`,date:`2026-09-29`,platforms:[`win32`],added:[],fixed:[`The / menu is easier to read: skills and commands in two titled sections, each with one short line — the full description shows when you point at it.`,`Commands that only duplicated OonaCode’s own controls or showed misleading numbers are gone from the / menu — /model (use the model picker), /usage (the engine’s own estimate, not your credits), /autocompact, /output-style, /mcp, /list-agents and /reload-skills. Typed, they say why.`,`Skills you import or remove in Settings → Skills reach your chats by themselves, at each chat’s next message.`]},{version:`0.3.178`,date:`2026-09-29`,platforms:[`win32`],added:[`The chat list is laid out like the Claude desktop app: New, Projects, Scheduled, then your pinned chats and projects, then Today and Older. The old grouping by project is one click away — the small icon beside “Today”.`,`Projects opens a page of project cards — each with its goal, its chats and when it was last used — with search, sort and New project. Click a card to see that project’s chats, instructions and settings, and to start a new chat in it.`,`Scheduled shows every scheduled task from every chat on this PC in one place, with its next run, its chat, and pause, resume and delete. A dot on it tells you when something is due soon.`,`Pin any chat or project to the top of the list from its menu.`],fixed:[`A chat row’s ⋯ button shows only when you point at the row.`]},{version:`0.3.177`,date:`2026-09-29`,platforms:[`win32`],added:[`Claude Sonnet 5.5 is in the model picker — on the OonaCode pool and on your own Claude subscription — with a 1M-token context. It costs the same as Sonnet 5 per token and usually needs fewer tokens for the same work.`],fixed:[`Claude Sonnet 5 is retired: a chat that was on it moves to Sonnet 5.5 at its next message, and the picker shows Sonnet 5.5.`]},{version:`0.3.176`,date:`2026-09-29`,platforms:[`win32`],added:[`Each chat has a Skills list beside Tools. Every skill starts off, so the model sees none of them and they cost nothing — about 1,400 tokens on every message until now. Switch one on to let the model use it by itself in that chat; the list shows what each one costs per message while on.`,`Typing /name still runs any skill for one turn, whether its switch is on or off.`],fixed:[`The engine’s built-in keyboard-shortcuts helper is turned off: it would have edited your own Claude Code settings.`]},{version:`0.3.175`,date:`2026-09-29`,platforms:[`win32`],added:[`Type / at the start of a message to see the chat’s commands and skills — the Claude Code engine’s own (/compact, /context, /review, /security-review, /init and more) and the skills in your project’s .claude folder — with what each does. Type to narrow the list, then Enter or Tab. They work with every model, not only Claude.`,`Your own skills: Settings → Skills lists the skills OonaCode gives every chat, and “Import from Claude Code…” copies the ones you choose from your Claude Code install — it only reads it, never changes it.`,`In the terminal app (oona), a command the chat’s engine knows — /context, /compact or a skill — now runs instead of answering “unknown command”.`],fixed:[`Typing /model in a chat updates the chat’s model and the model picker again.`,`Command output such as /context reads the same while it arrives and after you reopen the chat.`]},{version:`0.3.174`,date:`2026-09-28`,platforms:[`win32`],added:[`Search in the Import window. Type to find a chat by its name, its first or last message, or its folder — chats folded away as already imported or deleted here show up too when they match. Or open the search options and pick “Whole conversations” to search inside the chats themselves, with a few lines of each match under the chat. It only reads Claude Code, Cursor and the Claude app’s files, never changes them.`],fixed:[`Chats Claude Code switched to another model are answered by that model for real: OonaCode’s pool now serves the model the engine falls back to, and never answers a Claude request with another company’s model.`]},{version:`0.3.173`,date:`2026-09-28`,platforms:[`linux`],added:[`Every chat now has an “about”: a short note, written in the background by a cheap helper model of the chat’s own provider, saying what the chat works on. Your other chats read it — with each chat’s folder and when it was last active — when they look for the right chat to ask. See it, edit it or press Regenerate in the session info panel.`,`View → What chats are about… (and a sidebar button) lists every chat’s about and what writing them cost, with a switch to turn it off and “Generate for all chats now”. The switch and its numbers are also in Settings → This PC.`,`Your phone can now do from anywhere what this PC’s window does: switch each tool on or off per chat, see and control the conversations between your chats, read, edit and regenerate each chat’s “about”, and manage scheduled tasks. It needs this update on the PC and the next OonaCode app on the phone.`,`A chat can switch its own workspace. When the work belongs in another folder — a project you name that lives elsewhere, or a new project folder — the model proposes the switch and you answer Switch or Not now. It always asks you, even with “accept automatically” on, and the chat moves when its current step ends, with the conversation kept.`,`Right-click a chat tab → Delete (in red, under “Close all tabs”) deletes that chat after asking, just like Delete in the sidebar.`,`When Anthropic’s safeguards flag a chat and Claude Code moves it to another model for the rest of the run, the model box says so in red — for example “Opus 4.8 (safeguard)” — and the chat shows a notice at the switch. Picking a model takes the chat back to it at the next message.`],fixed:[`Typing in the message box while a chat is replying is no longer interrupted. With “accept automatically” on, an approval card flashed for an instant on some tool calls and took the cursor away from the box.`,`A permission card that appears while you are typing no longer takes the keyboard, so your next Space or Enter can never press Allow by accident.`,`“Send now” stays disabled and says “Sending now…” until the agent has taken the message — it can take a few seconds while the agent stops its current step, and a second press can no longer send it twice.`,`A message sent from your phone is confirmed by this PC, and the same message is never run twice when the phone sends it again after a lost connection.`,`File and folder names in a reply get their ▶, Open and Show in folder buttons only when they really exist on this PC. A bare file name is also looked for in the folder the reply named just before it.`,`A chat can no longer be moved into your home folder or the root folder through a link. Where /home is itself a link (Fedora Silverblue, Bazzite and similar systems), the home folder passed as an ordinary folder, and the chat would have loaded your own Claude Code settings as its project.`,`Signing in to your own Claude subscription inside the app works on Ubuntu 24.04, Debian, Linux Mint, Pop!_OS and Zorin OS again. There, a part of OonaCode built for newer systems did not load, and the sign-in fell back to a command you had to paste.`,"On Ubuntu, Linux Mint, Pop!_OS, Zorin OS and similar systems, `oona` now works in every new terminal right after you install or update. The installer used to leave it off your PATH until you logged out and back in; now it adds it for new terminals itself, and `oona uninstall` takes that line out again.",`Every way of uninstalling — “oona uninstall”, or the install command with --uninstall — now takes this PC off your account: keep your chats and they stay readable on your other devices; delete them and their copies go too. It never touches your Claude Code or the Claude app, and “oona uninstall” no longer gives up when the background service is stopped.`,`The installer now says at once when a system cannot run OonaCode — one older than Ubuntu 22.04, Debian 12 or RHEL 9, or one built on musl such as Alpine — instead of installing a copy that could not start. The .deb and .rpm tell apt and dnf the same.`]},{version:`0.3.172`,date:`2026-09-28`,platforms:[`win32`],added:[`When Anthropic’s safeguards flag a chat and Claude Code moves it to another model for the rest of the run, the model box says so in red — for example “Opus 4.8 (safeguard)” — and the chat shows a notice at the switch. Picking a model takes the chat back to it at the next message.`],fixed:[`Uninstalling from Settings → Apps now also takes this PC off your account, exactly like “oona uninstall”: keep your chats and they stay readable on your other devices; delete them and their copies go too.`,`“oona uninstall” no longer gives up when the background service is stopped.`,`The “Updating OonaCode…” window shows again on the newest Windows 11 versions (24H2 and later).`]},{version:`0.3.171`,date:`2026-09-28`,platforms:[`win32`],added:[`Oonak Browser now picks its own control port from a range no developer tool uses by default, so it can no longer take a port that Shopify CLI or a dev server wants. If a program needs a particular port kept free, or you want the browser on a specific one, just ask the chat.`],fixed:[`File and folder names in a reply get their ▶, Open and Show in folder buttons only when they really exist on this PC. A bare file name is also looked for in the folder the reply named just before it.`,`Uninstalling OonaCode from Settings → Apps now removes all of it — the app, the command line and its background service — and asks whether to keep your chats. Installing again afterwards no longer says it is already installed. Your Claude Code and Claude app are never touched.`,`“oona uninstall” works again on Windows 11.`,`A chat “about” you wrote yourself no longer shows “stale”.`]},{version:`0.3.170`,date:`2026-09-28`,platforms:[`win32`],added:[`Your phone can now do from anywhere what this PC’s window does: switch each tool on or off per chat, see and control the conversations between your chats, read, edit and regenerate each chat’s “about”, and manage scheduled tasks. It needs this update on the PC and the next OonaCode app on the phone.`],fixed:[`“Send now” stays disabled and says “Sending now…” until the agent has taken the message — it can take a few seconds while the agent stops its current step, and a second press can no longer send it twice.`,`A message sent from your phone is confirmed by this PC, and the same message is never run twice when the phone sends it again after a lost connection.`]},{version:`0.3.169`,date:`2026-09-28`,platforms:[`win32`],added:[`Every chat now has an “about”: a short note, written in the background by a cheap helper model of the chat’s own provider, saying what the chat works on. Your other chats read it — with each chat’s folder and when it was last active — when they look for the right chat to ask. See it, edit it or press Regenerate in the session info panel.`,`View → What chats are about… (and a sidebar button) lists every chat’s about and what writing them cost, with a switch to turn it off and “Generate for all chats now”. The switch and its numbers are also in Settings → This PC.`],fixed:[`A chat can no longer be moved into your user folder or a drive root through a link or junction that points there — its project settings would have been your own Claude Code settings.`]},{version:`0.3.167`,date:`2026-09-27`,platforms:[`win32`],added:[`A chat can switch its own workspace. When the work belongs in another folder — a project you name that lives elsewhere, or a new project folder — the model proposes the switch and you answer Switch or Not now. It always asks you, even with “accept automatically” on, and the chat moves when its current step ends, with the conversation kept.`],fixed:[]},{version:`0.3.166`,date:`2026-09-27`,platforms:[`win32`],added:[],fixed:[`Typing in the message box while a chat is replying is no longer interrupted. With “accept automatically” on, an approval card flashed for an instant on some tool calls and took the cursor away from the box.`,`A permission card that appears while you are typing no longer takes the keyboard, so your next Space or Enter can never press Allow by accident.`]},{version:`0.3.165`,date:`2026-09-27`,platforms:[`win32`],added:[`Right-click a chat tab → Delete (in red, under “Close all tabs”) deletes that chat after asking, just like Delete in the sidebar.`,`Chats now use Oonak Browser, in a window you can see, for everything that needs a web browser — not Chrome, Edge or a hidden script browser — unless you name another browser. It runs without a window (headless) only when you ask for that.`],fixed:[`After an update, the background service comes back by itself. An update could leave it unable to restart, and the app then showed “OonaCode could not start its host service” even though it went on to open normally.`]},{version:`0.3.164`,date:`2026-09-27`,platforms:[`win32`],added:[`Send now: a message you typed while the agent works has a Send now button while it waits. It stops what the agent is doing right now and sends your message immediately — the step that is running is cut. On the desktop and the phone.`,`Conversations → Map: see at a glance which chats are talking to each other. Each conversation is a hub with a line to each of its chats; working chats pulse; click a hub for its history or a chat to open it.`],fixed:[`A restart no longer signs this PC out when OonaCode’s stored key cannot be opened for a moment. OonaCode used to replace the key and lose your sign-in; it now keeps the key and signs you back in by itself as soon as it opens.`]},{version:`0.3.163`,date:`2026-09-27`,platforms:[`linux`],added:[`Send now: a message you typed while the agent works has a Send now button while it waits. It stops what the agent is doing right now and sends your message immediately — the step that is running is cut. On the desktop and the phone.`,`Conversations → Map: see at a glance which chats are talking to each other. Each conversation is a hub with a line to each of its chats; working chats pulse; click a hub for its history or a chat to open it.`],fixed:[`A restart no longer signs this PC out when its security chip is slow to open OonaCode’s stored key. After a system update and reboot, the chip on some machines refuses for a while; OonaCode used to replace the key and lose your sign-in. It now keeps the key and signs you back in by itself as soon as the chip opens it.`]},{version:`0.3.162`,date:`2026-09-27`,added:[],fixed:[`A chat switched to another model knows which model it is. After a switch from Claude to DeepSeek, the model used to keep saying it was Claude — the chat history and Claude Code’s own prompt told it so.`,`Oonak Browser is offered only where it can run. An older OonaCode no longer lists a browser tool it cannot use, so the model does not spend tokens working around it — update to get the browser.`]},{version:`0.3.161`,date:`2026-09-27`,added:[`Settings → This PC → “Replace pictures older than N days”: screenshots and pasted pictures in your chat history are replaced by a short note once they are older than a year (you choose the number, or 0 to keep them). The words of every chat stay; the database stops growing with pictures. It runs by itself.`],fixed:[`The model, Build/Plan/Ask and effort pickers under the message box now look like the dropdowns they are.`,`Switches that are off are easy to see in dark mode.`,`Error messages show what went wrong in words, without raw tags or a provider’s JSON.`,`The ✕ that removes an attachment or a reply is round.`,`Pressing Stop, or an update cutting a turn, no longer files an automatic bug report.`]},{version:`0.3.160`,date:`2026-09-27`,added:[`On Windows, the agent can use a real browser. Ask it to open a site, read a page, click, fill in a form or take a screenshot, and it does it in Oonak Browser, in a window you can see. The first time, OonaCode asks once to install the browser (about 210 MB); after that it opens straight away.`,`Each chat has its own browser profile, so a site you sign in to stays signed in for that chat. Switch the browser off for a chat in its Tools menu.`],fixed:[]},{version:`0.3.159`,date:`2026-09-27`,added:[],fixed:[`A chat reopened after an update no longer says “turn complete” the instant you send a message and then answer anyway. The engine’s own note about work that stopped during the update used to be taken for the end of your turn, with the whole earlier conversation’s tokens on the line.`,`A background task that stopped because OonaCode restarted now says so in plain words, instead of “Orphaned by a previous Claude Code process exit”.`]},{version:`0.3.158`,date:`2026-09-27`,added:[`Every thought in a chat shows how many words it has, so you can tell at a glance whether there is anything to read.`],fixed:[`A thought with nothing in it — some models return only a signature for their thinking — now says “Thought · empty” and no longer opens onto a blank box.`,`A command the agent was allowed to run no longer leaves an “Allowed Bash (automatically)” line under its own card: the card already shows the command and its result. Refusals are still shown.`]},{version:`0.3.157`,date:`2026-09-27`,added:[`On Linux, OonaCode has its own signed apt and dnf repositories. Install the app with apt (Debian, Ubuntu, Mint) or dnf (Fedora, RHEL, Rocky, Alma) — the commands are on the download page — and your package manager keeps it up to date with the rest of the system.`,`Every Linux release is signed with the OonaCode release key, and the one-line installer checks that signature before it installs anything.`],fixed:[`On Linux, the menu bar is drawn in the window in the app’s own colours, and it switches between light and dark with the app instead of keeping the desktop’s theme until a restart.`,`Upgrading the .rpm no longer removes the oonacode command, and removing it no longer leaves empty folders behind.`]},{version:`0.3.156`,date:`2026-09-27`,added:[`Chats can talk to each other. Turn on “Talk to other chats” in a chat’s Tools menu, and its agent can find your other chats that have it on, read them, and ask them for help — one chat or a whole group. A chat that is closed wakes up to answer; a busy one answers when it finishes. The reply comes back to the chat that asked.`,`The Conversations window (in the sidebar) shows every conversation between your chats: who said what to whom, what each answer cost, and buttons to pause, resume, close or stop them all. Each conversation has a budget — 20 messages and 1,000,000 new tokens by default — and pauses itself when it is used up, so chats can never talk forever.`,`Hover over any tool in a chat’s Tools menu to read what it does, how it works, what it costs and how to turn it off.`],fixed:[`A chat woken in the background — by a scheduled task or another chat — shows as working in the sidebar even when it is not open in a tab.`,`A scheduled task no longer slips into a chat at the same moment you send it a message; yours always goes first.`,`A message sent from the terminal no longer waits forever when a chat’s history cannot be resumed and the restart fails. It now says why.`,`Notes OonaCode writes into a chat — a model change, a conversation paused — are still there when you reopen it.`,`When every Claude seat in the OonaCode pool is taken, a new chat now says the model is busy and to try again in a few minutes or pick another model, instead of “Something went wrong on our side”.`,`On Linux, the app tells you it is updating while it swaps itself, so there is no need to start it again.`,`On Linux, removing the .deb or .rpm leaves nothing running and nothing failing at the next login, and the one-line installer checks for free disk space before it changes anything.`]},{version:`0.3.155`,date:`2026-09-27`,added:[`OonaCode runs on Linux. One command installs the command line, the background service and the desktop app: curl -fsSL https://oonacode.oonak.ai/install.sh | bash. The AppImage, .deb and .rpm are on the download page too.`,`On Linux the app lives in the system tray as it does on Windows, follows your desktop’s light or dark theme, and gets its own entry in the applications menu.`,`Uninstalling on Linux removes the desktop app along with the rest, and asks whether to keep your chats for a future install.`],fixed:[`A window no longer stays on “Unauthorized” after the background service restarts with a new key. It reconnects by itself.`]},{version:`0.3.154`,date:`2026-09-26`,added:[],fixed:[`A chat waiting on a long job no longer loses its watcher. OonaCode used to close a chat’s engine ten minutes after the model last spoke, which stopped any Monitor or background command it had left running. The engine now stays up while such work runs, up to 12 hours.`,`A chat moved into a project, or whose project you edit, now follows the project’s instructions from its next message. It used to keep the ones it started with.`]},{version:`0.3.153`,date:`2026-09-25`,added:[],fixed:[`A very long chat no longer answers “Prompt is too long” after OonaCode restarts or updates. The engine was judging the chat’s size by a figure left over from before the restart, and now gets an accurate one.`,`If a message is ever refused as too long before the model has started on it, OonaCode sends it again by itself with a shorter history. You see your message once and then the answer, not an error.`]},{version:`0.3.152`,date:`2026-09-25`,added:[],fixed:[`Uninstalling the app from Windows’ Apps list no longer stops the command-line OonaCode on the same PC from starting after a restart.`]},{version:`0.3.151`,date:`2026-09-25`,added:[`Files the agent names in a chat are clickable. Audio and video play right in the chat with a small player, pictures open as a preview, and in the app every file can be opened in its own program or shown in its folder.`,`Uninstalling the app asks whether to keep your chats on this PC. Keeping them means a new install signs in and continues every chat.`],fixed:[`Installing and updating no longer fail with “The operation has timed out” on PCs whose network drops the newer internet addresses, nor while our server restarts for an update.`]},{version:`0.3.150`,date:`2026-09-25`,added:[],fixed:[`The fix in 0.3.149 for long, sleeping turns now really reaches the agent: the Monitor tool and the block on long waits are on for every chat.`,`A chat compacted after a long pause no longer pays to cache a conversation it is about to replace, and the agent keeps each tool call in its history exactly as it wrote it — both as Claude Code does.`]},{version:`0.3.149`,date:`2026-09-25`,added:[`The agent can watch a long job with the Monitor tool, as Claude Code does, and is woken the moment the job finishes.`],fixed:[`Long chats no longer spend their time asleep. With no way to watch a background job, the agent had been polling it with waits of four to eight minutes. One chat spent more than three and a half hours of a day sleeping, and turns ran for hours while the model worked for a fraction of that. The agent now gets the same working rules as Claude Code, and long waits are blocked.`]},{version:`0.3.148`,date:`2026-09-25`,added:[],fixed:[`A scheduled task that could not be sent — the PC had just restarted, the vault was still locked, the server was not reachable yet — waits and tries again instead of switching itself off. Pausing, editing or deleting a task while its prompt is being sent is no longer undone, and a scheduled prompt no longer lands in a chat whose engine is still starting.`,`A chat on your own DeepSeek key, or one switched with a typed “/model opus”, is no longer shown as withdrawn and locked. “/model fable” picks Claude Fable instead of the default model.`,`Moving a chat to another model no longer lowers its saved effort level to what the old model offered, and a one-off “oona --effort” is no longer saved as the chat’s level.`,`After you pick another model for a locked chat and send, the chat no longer flashes the lock again while the engine starts; if the start fails, your pick is kept.`,`Coming back from a file tab no longer jumps the chat to an old reply or reopens the search bar.`,`The hidden sidebar slides away again when the pointer leaves the window past its edge, and the keyboard no longer tabs through it while it is hidden. Clicking ⓘ in Settings opens its note instead of closing it.`,`Subagents write their prompt cache for five minutes, as Claude Code does for its subscribers; the chat itself keeps the hour. Their cache writes cost less.`]},{version:`0.3.147`,date:`2026-09-25`,added:[`A chat’s scheduled tasks sit beside its subagents: a clock badge says how many are live and when the next one runs, and opens the list — each task’s schedule, its next and last run, Pause and Delete. The tasks run on this PC.`],fixed:[`A prompt the scheduler sends into a chat reads as a “Scheduled task” line, not as your own message waiting in the queue.`,`A chat whose model is no longer offered shows that model in red and waits for you to pick another; its history stays, and the old model is not in the list any more.`,`The effort list follows the server within minutes, without restarting the app. A chat set to a level that has been switched off moves to the nearest one — ultracode becomes xhigh. Chats on your own Claude subscription have an effort picker again.`]},{version:`0.3.146`,date:`2026-09-25`,added:[`A Tools menu beside the model picker: switch OonaCode’s own tools on or off for each chat — browser, desktop and window control, clipboard, screen capture, Office documents and run-as-administrator. Each tool costs the model only a short line until it is used, and the menu shows how much. The first tools are marked Demo while they are tested with every model: a demo tool answers what it would have done, and does nothing on your PC yet.`],fixed:[]},{version:`0.3.145`,date:`2026-09-25`,added:[],fixed:[`Every request of every chat, on every model, is about 3,200 tokens smaller: the engine’s own “auto memory” instructions are gone. OonaCode starts each engine in a fresh private folder and deletes it afterwards, so the notes the model was told to keep there were thrown away when the chat went idle — the model spent tool calls writing memories it would never read. A project’s memory is OonaCode’s own and stays.`,`The engine’s claude.ai Artifact tools are switched off everywhere OonaCode runs it — the app, the terminal, VS Code, the phone, Telegram and the agent API.`]},{version:`0.3.144`,date:`2026-09-25`,added:[],fixed:[`Long chats on Claude models in the OonaCode pool keep their cache for an hour, as Claude Code does for its subscribers. A pause of more than five minutes no longer re-sends the whole conversation at the full cache-write price, which in a large chat was the most expensive part of coming back to it.`,`The session panel’s Context shows how big the conversation is now, not the total of every request the chat ever made — a long chat read “10.7M / 1.0M tokens”.`,`The message box keeps the cursor after you send, so you can go straight on typing the next message.`,`A paid chat’s background work (titles, reading web pages) no longer goes to a free model of the same vendor.`]},{version:`0.3.143`,date:`2026-09-24`,added:[`Search inside your chats: open the search in the chat list, press the sliders button and choose Whole chats. It looks through every message of every chat on this PC, and you choose whose words — yours, the model’s, or both — plus, if you like, the tools’ commands and output and the subagents’ conversations. Results show each message with the words lit; a click opens the chat with its search on them.`,`More search options, for both kinds of search: one project only, a time window (today, 7 or 30 days), match case and whole words.`],fixed:[`While you search the chat list, projects with no matching chat are hidden too.`]},{version:`0.3.142`,date:`2026-09-24`,added:[],fixed:[`A reply you sent shows as the same small chip it had in the message box — “Reply to” and the first few words — instead of the whole quoted text; the full quote appears when you rest the pointer on it, and a click jumps to the message it answers.`,`The model now knows a reply points back into the conversation: it is told the quoted lines are from the chat history, not new input, and whose words they were — its own earlier reply, your earlier message, a file, or a tool’s output.`,`When the chat list is narrow, its buttons wrap onto a second line instead of spilling out of it.`]},{version:`0.3.141`,date:`2026-09-24`,added:[`The chat list on the left can be made wider or narrower: drag its right edge (double-click it for the usual width).`,`The chat list can hide: press the pin in its header, the button at the top left, or View → Sidebar (Ctrl+B). While hidden it slides in when the pointer reaches the left edge of the window, and slides away when you leave it.`,`Search in the chat list is a single magnifier now; click it and the search box opens across the top. Escape or × clears it.`],fixed:[`Opening OonaCode right after a restart no longer leaves the OonaCode pool models out of the model list: if they cannot be read yet, OonaCode asks again by itself a few seconds later and the list fills in.`,`The Artificial Analysis scores (intelligence, coding, speed and benchmarks) show on every model in the model list again — including the models of your own Claude and SuperGrok subscriptions, which never had them.`,`A chat’s details card no longer appears on top of its right-click menu.`]},{version:`0.3.140`,date:`2026-09-24`,added:[`Reply is tidier: the message you reply to shows as a small chip above the message box with its first few words, instead of filling the box. Click the chip — or the quote in a sent reply — to jump to that message; the × removes it.`,`Right-click a project in the sidebar for its settings: Project settings… opens Projects with that project already selected. The gear beside a project’s “+” does the same, and a chat filed in a project offers it in its own menu too.`,`Link GitHub. Under a project’s Repositories (and in Settings → Providers), link your GitHub account once: the agent’s git and gh then clone, pull and push your private repositories on every PC of yours. You type a short code on github.com; the token stays in your encrypted vault and never reaches the OonaCode server. Public repositories need nothing.`],fixed:[]},{version:`0.3.139`,date:`2026-09-24`,added:[`Every setting now says what it does, and resting the pointer on the ⓘ beside it tells you where in OonaCode it applies and what it does not do.`,`Export chats… is in the File menu (and on the sidebar in a browser window) instead of in Settings.`,`With Remote access turned off on a PC, your phone, Telegram, the website and your other PCs still show it — online or not — marked “remote access off”, and opening it tells you to turn Remote access back on in OonaCode on that PC.`],fixed:[`Turning Remote access off now tells your other devices at once. Before, the PC was already unreachable from them, but they could not say why.`,`The settings of This PC save the moment you change them — nothing is lost by closing the dialog.`,`Settings that did nothing, or repeated another one, are gone: the default permission mode (each chat’s Build / Plan / Ask first picker decides), the agent-picker switch, the Git Bash path, the engine path and the extra allowed origins. The server address is shown, not edited — signing in sets it.`]},{version:`0.3.138`,date:`2026-09-24`,added:[`Projects have settings now, like the Claude app’s: a goal, the repositories the project works on, what a new chat in it starts on (model, effort and folder), a project memory the agent keeps up to date, and whether its chats may schedule work — and how often at most. All of it is in Projects, and a Claude app project you import brings its own.`,`OonaCode has a scheduler. Ask the agent to do something later or on a repeat — “check the build every morning at nine” — and it schedules it on this PC; when it is due, the prompt arrives in the chat, even if the chat had gone quiet. The Projects dialog and the chat’s info panel list what is scheduled, where you can pause, resume or delete it.`],fixed:[`Saving a project’s instructions now reaches its chats at their next message, instead of waiting until the chat happened to restart.`]},{version:`0.3.137`,date:`2026-09-24`,added:[],fixed:[`After a PC restart the app could ask for a "host token" and sign you out: two copies of the OonaCode background service started at once and fought over your session. Only one ever runs now, and the app never shows the token page — if its service is replaced it reconnects by itself.`,`The unlock screen stays put until you unlock, and says what went wrong in place — a wrong password, or a connection it is re-establishing — instead of jumping to another page.`,`A message with a picture sent while the agent was working stayed “queued”, and removing it said it was already sent. It now shows as read the moment the agent takes it, and a reopened chat shows it with its picture.`,`In the model’s questions, typing your own answer now clears the options you had picked, and picking an option clears what you typed — the answer sent is exactly the one you chose. The same on the phone, in the terminal and in Telegram.`]},{version:`0.3.136`,date:`2026-09-24`,added:[`Every model now has its own housekeeper — the small, fast model of the same maker that writes a chat’s titles and reads the web pages it fetches. On the OonaCode pool a MiMo v2.6 Pro chat uses MiMo v2.6 Flash, a Qwen chat Qwen3.8 Flash, a GLM chat GLM-5.3 Flash and a GPT-5 chat GPT-5 mini, instead of doing that work on the big model itself. A free model keeps its own, so it stays free.`],fixed:[]},{version:`0.3.135`,date:`2026-09-24`,added:[],fixed:[`Claude models on the OonaCode pool — Opus 5.5, Opus 5, Sonnet 5 and Fable 5.1 — now use their whole 1M context. A long chat no longer stops to summarise itself every ~170k tokens, and its subagents get the same window.`,`Reading a web page is quick again in a Claude chat: pages are read by Claude Haiku, as in Claude Code, instead of a helper that took about a minute a page.`,`Changing a chat’s model now moves its subagents and background helpers to the new model too; before, they stayed on the old one until the app restarted.`,`MiMo v2.5 and v2.5 Pro chats now use their full 1M context too.`]},{version:`0.3.134`,date:`2026-09-23`,added:[],fixed:[`On the Android app, the model’s questions can be answered again. They come one at a time — “Question 2 of 3” — with Back, Next and Skip, and Answer sends them to your PC. The card used to show only the first question, hide the rest below it and wait for all of them, so it could not be sent.`]},{version:`0.3.133`,date:`2026-09-23`,added:[`Bring your Claude desktop app projects across: File → Import chats from other coding agents now lists every project the Claude app has opened on this PC. Each one arrives as an OonaCode project of the same name — its goal, instructions and what Claude noted about it become the project’s instructions — with its project chat and one chat per thread filed under it, ready to carry on.`,`A Claude Code chat you moved into a Claude app project is filed under that project here too.`,`A thread you never opened in the Claude app still comes across, with its task and every reply the project chat saw; open it once in the Claude app and import again for its whole conversation.`],fixed:[`Cursor chats appear in the import list again — they had been left out since September 10.`]},{version:`0.3.132`,date:`2026-09-23`,added:[`Reply to any part of a chat: select some text (or just right-click a block), choose Reply, and it is quoted in your message box — type your answer under it. A quote from a file the agent read names the file.`,`Right-click in a chat: copy what you selected, copy a whole reply or tool output, copy a code block or a link, find the selected words in the chat, or select a block.`,`Search in a chat opens the block its match is in — a folded tool card, a thought, a finished agent’s work — and scrolls to the words themselves.`,`Search matches are now bright orange, the current one strongest, so they stand out on code too.`,`The file viewer shows pictures (PNG, JPEG, GIF, WebP, SVG and more), plays audio and video, and shows Markdown formatted, with a switch to the source.`,`Right-click a file or folder in the explorer to copy its path or delete it.`],fixed:[`Moving a chat to another folder or project while it was working could delete the folder it was working in, start two agents at once, or send your next message to the old folder.`,`The working line no longer says a chat may be stuck while it waits for your approval or answer, or right after you send a message, and it counts time correctly (no more "4m 60s").`,`A date line no longer says "Today" for yesterday’s messages when the app stays open past midnight.`,"Installing with npm (`npm i -g oonacode`) installs this version again; earlier npm releases carried an old program.",`The What’s new window could open again on the next start, showing the same update a second time.`,`An older OonaCode window or VS Code extension no longer resets settings it does not know about, such as your theme colours or which project groups you folded.`,`A new install no longer opens with a list of changes; this window now appears only after an update.`,`The notification switch for permissions now says it also covers the agent’s questions.`]},{version:`0.3.131`,date:`2026-09-23`,added:[`Claude Opus 5.5 is here — the newest Opus, and cheaper to run than Opus 5. Choose it in the model picker, from the OonaCode pool or on your own Claude subscription. It runs on the newer Claude Code engine (2.1.280) that this update brings.`,`Every block in a chat shows its time at the bottom right, in your local time — hover it for the full date — and a date line marks where each day starts.`,`A running chat tells you how long the agent has been quiet, and after five minutes that it may be stuck and what to do.`,`After every update, OonaCode now opens this window to show you what changed.`],fixed:[`A reply that streamed in live had no time on it until the chat was opened again.`,`Chats open in tabs could fail to come back after a restart if a setting changed while they were being restored.`]}];function tl(e,t){let n=e=>{let[t,...n]=e.trim().replace(/^v/,``).split(`-`);return{nums:(t??``).split(`.`).map(e=>Number.parseInt(e,10)||0),pre:n.length>0?n.join(`-`):null}},r=n(e),i=n(t);for(let e=0;e<Math.max(r.nums.length,i.nums.length);e++){let t=(r.nums[e]??0)-(i.nums[e]??0);if(t!==0)return t}return r.pre===i.pre?0:r.pre===null?1:i.pre===null?-1:nl(r.pre,i.pre)}function nl(e,t){let n=e.split(`.`),r=t.split(`.`);for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e],i=r[e];if(t===i)continue;if(t===void 0)return-1;if(i===void 0)return 1;let a=/^\d+$/.test(t),o=/^\d+$/.test(i);if(a&&o){let e=Number(t)-Number(i);if(e!==0)return e;continue}return a===o?t<i?-1:1:a?-1:1}return 0}function rl(e,t,n=el,r=null){if(!e||e===`0.0.0`)return[];let i=n.filter(t=>tl(t.version,e)<=0&&(!r||!t.platforms||t.platforms.includes(r)));return[...t===null?i.filter(t=>tl(t.version,e)===0):i.filter(e=>tl(e.version,t)>0)].sort((e,t)=>tl(t.version,e.version))}function il(e,t,n,r=el,i=null){if(!e||e===`0.0.0`)return{record:null,show:[]};let a=null;for(let e of r)(a===null||tl(e.version,a)>0)&&(a=e.version);let o=a!==null&&tl(e,a)>0?a:e;return{record:t===null||tl(o,t)>0?o:null,show:t===null&&!n?[]:rl(e,t,r,i)}}function al(e,t){if(t==null)return[...e];if(t.length===0)return[];let n=new Set(t),r=e.filter(e=>n.has(e.id));return r.length>0?r:[...e]}var ol=`:free`;function sl(e){return e.endsWith(ol)}function cl(e){return sl(e)?e.slice(0,-5):e}var ll=`the user skipped the question`,ul=`(the user skipped this question)`;function dl(e){let t=e?.questions;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e;if(typeof t.question!=`string`)continue;let r=Array.isArray(t.options)?t.options.map(e=>e&&typeof e==`object`?e:null).filter(e=>e!==null&&typeof e.label==`string`).map(e=>({label:e.label,...typeof e.description==`string`?{description:e.description}:{}})):[];n.push({question:t.question,header:typeof t.header==`string`?t.header:``,options:r,multiSelect:t.multiSelect===!0})}return n}function fl(e,t,n={},r=new Set){let i={};return e.forEach((e,a)=>{if(r.has(a)){i[e.question]=ul;return}let o=(n[a]??``).trim();i[e.question]=o||(t[a]??[]).join(`, `)}),i}function pl(e){let t=e.questions,n=t===1?`question`:`questions`,r=t===1?`the model’s question`:`the model’s questions`,i=t===1?`The model’s question was`:`The model’s questions were`;switch(e.outcome){case`answered`:{let r=e.answers?Object.values(e.answers):null,i=r?r.filter(e=>typeof e==`string`&&e!==``&&e!==`(the user skipped this question)`).length:t;return t>0&&i<t?`You answered ${i} of ${t} ${n}`:t===0?`You answered the model’s questions`:t===1?`You answered the model’s question`:`You answered ${t} ${n}`}case`skipped`:return`You skipped ${r}`;case`dismissed`:return`${i} dismissed`;case`unanswered`:return`${i} not answered — the turn ended`}}function ml(e){if(!e||typeof e!=`object`)return null;let t=e.answers;return t&&typeof t==`object`&&!Array.isArray(t)?t:null}var hl=[`win32`,`linux`,`darwin`],gl=[`demo`,`live`],_l=[`allow`,`ask`],vl=[`string`,`number`,`integer`,`boolean`,`array`,`object`];function yl(e){let t=e/1048576;return t>=100?`${Math.round(t)} MB`:t>=1?`${t.toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function bl(e){if(e.toolName!==`InstallToolPack`)return null;let t=e.input;return!t||typeof t!=`object`||typeof t.pack!=`string`||typeof t.name!=`string`||typeof t.version!=`string`||typeof t.sizeBytes!=`number`||typeof t.path!=`string`?null:{pack:t.pack,name:t.name,version:t.version,sizeBytes:t.sizeBytes,path:t.path}}function xl(e,t){let n=t?.[e.slug];return typeof n==`boolean`?n:e.defaultOn}function Sl(e,t){return e.filter(e=>xl(e,t))}var Cl={slug:48,name:80,entryTool:40,description:2e3,promptLine:1e3,details:8e3,actionDescription:1e3,params:30,paramName:48,paramDescription:400,enumValues:40,callArgKeys:20,callError:500,callBatch:100},wl=/^[A-Za-z0-9_-]+$/;function Tl(e){return typeof e==`string`&&e.length>0&&e.length<=Cl.entryTool&&wl.test(e)}function El(e){return Math.ceil(e.length/4)}function Dl(e){return El(`${e.entryTool} ${e.description}`)+55}function Ol(e){return e.tokensPerRequest??Dl(e)+(e.promptLine?El(e.promptLine):0)}var kl=Ho({type:Qo(vl),required:Po().optional(),enum:Bo(Wo([H(),Ao()])).optional(),description:H().optional()}),Al=Ho({slug:H().min(1),description:H(),params:Xo(H(),kl),permission:Qo(_l),sort:Ao()}),jl=Ho({version:H(),url:H(),sha256:H(),sizeBytes:Ao(),exe:H(),format:es(`zip`)}),Ml=Ho({slug:H().min(1),name:H(),entryTool:H().refine(Tl,`not a valid tool name`),description:H(),promptLine:H().nullable(),details:H().nullable().optional(),status:Qo(gl),defaultOn:Po(),sort:Ao(),install:jl.nullable(),actions:Bo(Al)}).loose();Ho({platform:Qo(hl),version:H(),packs:Bo(Ml),refreshMinutes:Ao()});var Nl=[`No answer needed.`,`"Talk to other chats" is off in this chat: this message is from another chat's agent, not the person, and you cannot message chats. Your final answer goes back to that chat by itself.`,`"Talk to other chats" is off in this chat: this message is from another chat's agent, not the person, and you cannot message chats. It asked for no answer, so nothing goes back.`,`Last hop of this chain: you cannot message chats in this turn; put what you have in your final answer.`];[`**Let this chat work together with your other chats.**`,``,`### What it does`,`- Finds your other chats on this PC and reads their recent messages.`,`- Sends one chat, or a group of chats, a message or a task.`,`- Brings their answers back to this chat, by itself.`,``,`### How it works`,`- A chat that is asleep is woken from its saved history. A busy one gets the message when its current turn ends, never in the middle of it.`,`- The other chat does the work with its own model, folder and tools. Its answer comes back here as a new message only when this chat asked for one.`,`- Several messages from one chat that wait for a busy chat are handed over together, in one turn, with one answer.`,`- Several chats can share one conversation (a group). An answer goes only to the chat that asked, so a group cannot multiply its own messages.`,`- A chat with this switch OFF can still be messaged by a chat that has it on. It does the work, and its final answer goes back to that chat when that chat asked for one. That is all it can do: it gets none of these tools, cannot message or read other chats, and its switch stays off.`,``,`### What it costs`,`- About 650 tokens on every request while it is on, read from the prompt cache. Nothing while it is off, even in a chat that is messaged.`,`- Every message makes the chat that receives it do a turn, which spends its own tokens.`,`- Switching it on or off in a chat that already has a conversation re-writes its prompt cache once.`,``,`### Safety limits`,`- Each conversation has a budget: 20 delivered messages and 1,000,000 new tokens by default (context read back from the prompt cache is not counted). Reaching either pauses the conversation, and the chats say so.`,`- A chain stops after 3 hops (a message caused by a message caused by a message).`,`- At most 5 messages between two chats and 20 from one chat in 10 minutes, and 10 waiting for any one chat. A chat cannot message itself.`,`- A conversation with no activity for 24 hours closes by itself.`,``,`### How to stop it`,`- Turn this switch off: the chat loses these tools, and what it sent and the answers it asked for pause. It still answers a chat that messages it.`,`- Or open the Conversations window and use Pause, Close or Stop all.`,``,`### Privacy`,`- Everything stays on your PC: the messages are kept in this PC's database, never on OonaCode's server.`,`- A message never grants anything. The other chat runs with its own permissions and asks you as usual.`,``,`Only a chat with this switch on can start a conversation; a chat with it off only answers.`].join(`
|
|
78
78
|
`);var Pl={hops:3,rateWindowMs:6e5,perPair:5,perSender:20,pendingPerTarget:10,idleCloseMs:864e5,messageChars:2e4,titleChars:80,conversationTitleChars:120,recipients:10,listChats:50,readMessages:50,budgetMessagesMax:1e4,budgetTokensMax:1e9},Fl={message:`✉️ Message from chat "`,reply:`↩️ Reply from chat "`,continue:`↻ Continue the message from chat "`},Il=`⚠ `,Ll=`<local-command-stdout>`,Rl=`</local-command-stdout>`,zl=/^[A-Za-z0-9._:-]{1,128}$/;function Bl(e){let t=(e??``).replace(/["“”]/g,`'`).replace(/\s+/g,` `).trim();if(!t)return`Untitled chat`;let n=Pl.titleChars;return t.length>n?`${t.slice(0,n-1).trimEnd()}…`:t}function Vl(e){return Bl(e.title?.trim()||e.firstPrompt?.trim()||`Chat ${e.id.slice(0,8)}`)}function Hl(e,t){let n=Nl.filter(e=>t===`reply`||e!==`No answer needed.`),r=e;for(let e=!0;e;){e=!1;for(let t of n){if(r===t)return``;r.startsWith(`${t}\n\n`)&&(r=r.slice(t.length+2),e=!0)}}return r}var Ul=/^\[conv:(\S+) chat:(\S+) host:(\S+) msg:(\S+?)(?: reply-to:(\S+?))?( reply expected)?\]$/;function Wl(e){if(typeof e!=`string`)return null;let t=e;t.startsWith(Ll)&&t.endsWith(Rl)&&(t=t.slice(22,t.length-23)),t=t.replace(/\r\n/g,`
|
|
79
79
|
`);let n=t.indexOf(`
|
|
80
80
|
`);if(n<0)return null;let r=t.slice(0,n),i=t.slice(n+1),a=i.indexOf(`
|
|
@@ -93,10 +93,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
93
93
|
`))/^\s*\|?\s*:?-{2,}/.test(e)||(e=e.replace(/\|/g,` `),e=e.replace(/^\s{0,3}#{1,6}\s+/,``).replace(/^\s*>\s?/,``).replace(/^\s*(?:[-*+•]|\d{1,3}[.)])\s+/,``).replace(/(\*\*|__)(.+?)\1/g,`$2`).replace(/(?<![\p{L}\p{N}])[*_]([^*_\n]+)[*_](?![\p{L}\p{N}])/gu,`$1`).replace(/~~(.+?)~~/g,`$1`).replace(/[*_#`~]+/g,` `).replace(/\s+/g,` `).trim(),e=e.replace(/\(\s*\)|\[\s*\]/g,``).replace(/\s+([,.;:!?،؛؟։])/g,`$1`).replace(/([,;:])(?:\s*[,;:])+/g,`$1`).trim(),!(!e||/^[\p{P}\s]+$/u.test(e))&&(/[.!?…։؟:;"'»”)]$/u.test(e)||(e+=`.`),n.push(e)));return n.join(`
|
|
94
94
|
`)}var Xu=/([.!?…։؟。!?]+["'»”)]*)(\s+|$)/gu,Zu=/([,;:،؛՝、,;]\s+)/u;function Qu(e,t=280){let n=[];for(let r of e.split(/\n+/)){let e=r.trim();if(!e)continue;let i=0,a=[];for(let t of e.matchAll(Xu)){let n=(t.index??0)+t[1].length;a.push(e.slice(i,n).trim()),i=n+(t[2]?.length??0)}i<e.length&&a.push(e.slice(i).trim());for(let e of a)if(e)for(let r of $u(e,t)){let e=n[n.length-1];e!==void 0&&r.length<12&&e.length+r.length+1<=t?n[n.length-1]=`${e} ${r}`:n.push(r)}}return n}function $u(e,t){if(e.length<=t)return[e];let n=[],r=``;for(let i of e.split(Zu))if(i){if((r+i).length<=t){r+=i;continue}for(r.trim()&&n.push(r.trim()),r=i;r.length>t;){let e=r.lastIndexOf(` `,t),i=e>t/3?e:t;n.push(r.slice(0,i).trim()),r=r.slice(i)}}return r.trim()&&n.push(r.trim()),n}var ed={version:2,drop:[`՛`,`՜`],numbers:{units:[`զրո`,`մեկ`,`երկու`,`երեք`,`չորս`,`հինգ`,`վեց`,`յոթ`,`ութ`,`ինը`],teens:[`տասը`,`տասնմեկ`,`տասներկու`,`տասներեք`,`տասնչորս`,`տասնհինգ`,`տասնվեց`,`տասնյոթ`,`տասնութ`,`տասնինը`],tens:[``,``,`քսան`,`երեսուն`,`քառասուն`,`հիսուն`,`վաթսուն`,`յոթանասուն`,`ութսուն`,`իննսուն`],hundred:`հարյուր`,thousand:`հազար`,million:`միլիոն`,ordinal_1_4:[``,`առաջին`,`երկրորդ`,`երրորդ`,`չորրորդ`],ordinal_suffix:`երորդ`,ordinal_marks:[`րդ`,`երորդ`]},latin:{visa:`վիզա`,mastercard:`մաստերքարդ`,paypal:`փեյփալ`,"wi-fi":`վայֆայ`,wifi:`վայֆայ`,bluetooth:`բլութութ`,usb:`յուէսբի`,gps:`ջիփիէս`,sms:`էսէմէս`,pdf:`փիդիէֆ`,qr:`քյուառ`,ok:`օքեյ`,online:`օնլայն`,offline:`օֆլայն`,email:`իմեյլ`,"e-mail":`իմեյլ`,iphone:`այֆոն`,android:`անդրոիդ`,windows:`վինդոուս`,google:`գուգլ`,facebook:`ֆեյսբուք`,youtube:`յութուբ`,instagram:`ինստագրամ`,telegram:`տելեգրամ`,whatsapp:`վաթսափ`,viber:`վայբեր`,zoom:`զում`,tiktok:`թիքթոք`,netflix:`նեթֆլիքս`,uber:`ուբեր`,apple:`էփլ`,samsung:`սամսունգ`,microsoft:`մայքրոսոֆթ`,arev:`Արև`,astgh:`Աստղ`,artsiv:`Արծիվ`},lexicon:[[`անգամ`,`անքամ`]]},td={oonacode:`ունակոդ`,claude:`քլոդ`,gemini:`ջեմինի`,github:`գիթհաբ`,linux:`լինուքս`,api:`էյփիայ`,app:`էփ`},nd=/(?<![\p{L}\p{N}_])(\p{Nd}{1,3}(?:[ \u00A0]\p{Nd}{3})+|\p{Nd}+)(?:-([ա-և]+))?/gu,rd=/\p{Nd}/u,id=/[A-Za-z][A-Za-z0-9]*(?:[-'][A-Za-z0-9]+)*/g;function ad(e){return e&&e[0].toUpperCase()+e.slice(1)}function od(e){let t=e.codePointAt(0);if(t>=48&&t<=57)return t-48;let n=t;for(;rd.test(String.fromCodePoint(n-1));)--n;return(t-n)%10}function sd(e,t){let n=Math.floor(e/100),r=e%100,i=[];if(n&&i.push(n===1?t.hundred:`${t.units[n]} ${t.hundred}`),r>=20){let e=r%10;i.push(t.tens[Math.floor(r/10)]+(e?t.units[e]:``))}else r>=10?i.push(t.teens[r-10]):(r||!i.length)&&i.push(t.units[r]);return i.join(` `)}function cd(e,t){if(e.length>9)return Array.from(e,e=>t.units[Number(e)]).join(` `);let n=Number(e),r=Math.floor(n/1e6);n%=1e6;let i=Math.floor(n/1e3);n%=1e3;let a=[];return r&&a.push(`${sd(r,t)} ${t.million}`),i&&a.push(i===1?t.thousand:`${sd(i,t)} ${t.thousand}`),(n||!a.length)&&a.push(sd(n,t)),a.join(` `)}function ld(e,t){if(e.length===1&&e>=`1`&&e<=`4`)return t.ordinal_1_4[Number(e)];let n=cd(e,t);return(n.endsWith(`ը`)?n.slice(0,-1):n)+t.ordinal_suffix}function ud(e,t,n){if(n.ordinal_marks.includes(t))return ld(e,n);let r=cd(e,n);return r.endsWith(`ինը`)?r=`${r.slice(0,-1)}ն`:r.endsWith(`ը`)&&(r=r.slice(0,-1)),r+t}function dd(e){let t=ed,n=e;for(let e of t.drop)n=n.split(e).join(``);n=n.replace(nd,(e,n,r)=>{let i=``;for(let e of n)e!==` `&&e!==`\xA0`&&(i+=String(od(e)));return i=i.replace(/^0+(?=.)/,``),r?ud(i,r,t.numbers):cd(i,t.numbers)}),n=n.replace(id,e=>{let n=e.toLowerCase();return Object.prototype.hasOwnProperty.call(t.latin,n)?t.latin[n]:e});for(let[e,r]of t.lexicon)n=n.split(e).join(r).split(ad(e)).join(ad(r));return n}function fd(e){let t=dd(e);return t=t.replace(id,e=>{let t=e.toLowerCase();return Object.prototype.hasOwnProperty.call(td,t)?td[t]:e}),t}var pd=/[\u06F0-\u06F9]/g,md=/[\u0660-\u0669]/g;function hd(e){return e.replace(pd,e=>String(e.charCodeAt(0)-1776)).replace(md,e=>String(e.charCodeAt(0)-1632)).replace(/(\d)[\u066B](\d)/g,`$1.$2`).replace(/(\d)[\u066C](\d)/g,`$1$2`).replace(/\u066A/g,`%`).replace(/\u064A/g,`ی`).replace(/\u0643/g,`ک`).replace(/\u061F/g,`?`).replace(/\u060C/g,`,`).replace(/\u061B/g,`;`)}function gd(e,t){let n=t.toLowerCase().split(/[-_]/)[0];return n===`hy`?fd(e):n===`fa`?hd(e):e}function _d(e,t,n=Date.now()){let r=e?.summaries[0];if(!e||!r)return!0;if(t!==null&&t!==r.id&&e.summaries.some(e=>e.id===t)||!e.changedSinceNewest)return!1;let i=Date.parse(r.createdAt);return!(Number.isFinite(i)&&n-i<6e5)}function vd(e){return[`en`,...e.translations.map(e=>e.language)]}function yd(e,t){return t===`en`?e.text:e.translations.find(e=>e.language===t)?.text??null}function bd(e){let t=Math.max(0,Math.round(e));return t<60?`${t} s`:`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function xd(e){if(e.credits!==null&&e.credits>0){let t=e.credits.toLocaleString(`en-US`,{maximumFractionDigits:2});return`${t} credit${t===`1`?``:`s`}`}return e.route===`subscription`?`your plan pays`:e.route===`own-key`?tu(`own-key`):e.route===`pool`&&e.credits===0?`0 credits`:`not priced`}var Sd={title:`Listen to this chat`,intro:e=>`A spoken summary of ${e} — its goal, what was done, where it stands and what is pending — written by the chat’s own model, in English. Other languages are translated once by ${Mu.label} on your OonaCode credits and kept with the summary.`,noSummaries:`No summary yet — Play writes one.`,changedSinceNewest:`The chat has moved on since the newest summary — Play writes a new one first.`,unchanged:e=>`Nothing has changed in the chat since the summary of ${e} — that one is used, and nothing was spent.`,generating:`Generating…`,translating:`Translating…`,heading:(e,t)=>t?`${e.name}${e.code===`en`?``:` — ${e.native}`}`:`English — not in ${e.name} yet: Play translates it once`,current:`current`,playerOnly:`Voice and speed only change how this device reads it — they cost nothing.`},Cd={seq:0,conversationIds:null,sessionIds:null};function wd(e,t){return e.conversationIds===null||e.sessionIds===null||t.sessionId&&e.sessionIds.includes(t.sessionId)?!0:(t.conversationIds??[]).some(t=>e.conversationIds.includes(t))}function Td(e){let t=e.members.filter(e=>e.leftAt===null);return t.length>0?t:e.members}function Ed(e){if(e.title?.trim())return e.title.trim();let t=Td(e).map(e=>e.title);return t.length>0?t.join(` · `):`Conversation`}function Dd(e,t){return e.members.some(e=>e.sessionId===t&&e.leftAt===null)}function Od(e,t){return e.filter(e=>e.status!==`closed`&&Dd(e,t))}function kd(e){let t=e.filter(e=>e.status===`active`).length,n=e.length-t,r=e=>`conversation${e===1?``:`s`}`;return t>0?`${t} ${r(t)}${n>0?` · ${n} paused`:``}`:`${n} ${r(n)} · paused`}var Ad={active:`active`,paused:`paused`,closed:`closed`};function jd(e){return e===`active`?`ok`:e===`paused`?`warn`:`neutral`}var Md={message:`Message`,reply:`Reply`,continue:`Continue`,notice:`Notice`},Nd={pending:`Waiting to be delivered: the other chat gets it when its current turn ends, or is woken for it.`,sending:`Being handed to a chat on another PC.`,delivering:`Being handed to the other chat right now.`,delivered:`The other chat is working on it.`,answered:`The other chat finished its turn on it.`,failed:`The other chat could not finish it (stopped, or an error). The sender was told.`,cancelled:`Withdrawn before it was delivered, or the conversation closed.`,paused:`On hold: the conversation is paused, or the chat that started this exchange has "Talk to other chats" off.`};function Pd(e){switch(e){case`answered`:return`ok`;case`failed`:return`danger`;case`paused`:return`warn`;case`delivering`:case`delivered`:case`sending`:return`accent`;default:return`neutral`}}function Fd(e){if(e.kind!==`notice`)return e.text;let t=Wl(e.text);return t?t.body?`${t.headline}\n\n${t.body}`:t.headline:e.text}function Id(e){return e?.status===`answered`?{label:`answered`,answeredAt:e.finishedAt,help:`This chat finished its turn on this message, and its final answer went back to the chat that asked. Nothing more is owed.`}:e?.status===`failed`||e?.status===`cancelled`?{label:`answer requested`,answeredAt:null,help:e.status===`failed`?`The chat that sent this asked for an answer, but this chat's turn on it did not finish (stopped, or an error). The sender was told.`:`The chat that sent this asked for an answer, but the message was withdrawn or its conversation closed.`}:{label:`answer requested`,answeredAt:null,help:`The chat that sent this asked for an answer: this chat's final answer to it goes back by itself when its turn ends.`}}function Ld(e){let t=new Map;for(let n of e??[])for(let e of n.answerRequests??[])t.set(e.messageId,e);return t}function Rd(e){return e.kind===`notice`||e.kind===`reply`||!e.expectsReply?null:e.status===`answered`?{text:`answered`,help:`The chat it went to finished its turn on it; its final answer went back as a reply.`}:e.status===`failed`||e.status===`cancelled`?{text:`not answered`,help:`It asked for an answer, but it was not answered: the turn on it failed, or it was withdrawn.`}:{text:`reply expected`,help:`The sender asked for an answer: the final answer of the turn on it will go back as a reply.`}}function zd(e){return e.batchOf?`handed over in one turn with other messages from the same chat; that turn answered them all`:null}function Bd(e){return e.kind!==`notice`&&(e.status===`pending`||e.status===`paused`)}function Vd(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?+(e>0):Math.max(0,Math.min(1,e/t))}function Hd(e){return e.length>400||e.split(`
|
|
95
95
|
`).length>8}function Ud(e,t){let n=(e,t,n)=>{let r=e.trim();if(!/^\d+$/.test(r))return`${n}: a whole number, please.`;let i=Number(r);return i<1?`${n}: at least 1.`:i>t?`${n}: at most ${t.toLocaleString()}.`:null};return n(e,Pl.budgetMessagesMax,`Messages`)??n(t,Pl.budgetTokensMax,`Tokens`)}function Wd(e){return Ql(e!=null&&e>0?e:0)}function Gd(e,t){return e.credits!==void 0&&e.credits>0?`${t} tokens · ${Ql(e.credits)}`:`${t} tokens`}var Kd={window:`Chats on this PC that have "Talk to other chats" switched on can send each other messages and tasks. Every conversation between them is listed here, with all it said and what it cost.`,stopAll:`Pauses every active conversation on this PC and stops any turn a message between chats is running right now. Nothing is deleted: resume each one when you want.`,status:`Active: messages are delivered. Paused: held until you resume it. Closed: finished — only its history is kept.`,pause:`Holds this conversation: messages waiting in it are not delivered until you resume it. A chat already working on one finishes that turn.`,resume:`Lets the messages waiting in this conversation be delivered again. Not possible while it is over its budget — raise the budget first.`,close:`Ends this conversation for good. Messages still waiting in it are withdrawn; its history stays here.`,budget:`The most this conversation may use before it pauses by itself: delivered messages, and new tokens (context read back from the prompt cache is not counted). A budget below what is used pauses it; raising it resumes one the budget paused.`,removeMember:`Takes this chat out of the conversation: nothing more is delivered to it here. A conversation left with fewer than two chats closes.`,withdraw:`Takes this message back before it is delivered. The other chat never sees it.`,history:`Every message, reply and notice in this conversation, oldest first: who sent it to whom, when, whether it was delivered and answered, and what the turn it caused used. A message not delivered yet can be withdrawn.`,cost:`The credits the OonaCode pool charged for the turns these messages caused, and their new tokens (input and output, not the context read back from the cache). A chat on your own key or plan is not billed in credits: only its tokens count.`,openChat:`Open this chat in a tab.`,listView:`Every conversation, with its controls and its whole history.`,mapView:`Which chats are talking to each other: every chat is a dot (blue and pulsing while it works), every conversation a hub with a line to each of its chats — dashed for a chat that left. Click a hub to see that conversation, a chat to open it.`,showClosed:`Also draw the conversations that are closed, faded.`};function qd(e,t,n){return{...e??{},[t]:n}}function Jd(e,t){let n=Sl(e,t);return{count:n.length,label:`Tools · ${n.length}`,title:n.length>0?`OonaCode tools on in this chat: ${n.map(e=>e.name).join(`, `)}`:`No OonaCode tools are on in this chat`}}function Yd(e){return e&&Object.keys(e).length>0?{toolPacks:{...e}}:{}}var Xd=`Switching a tool restarts this chat's agent; its next message re-reads the conversation once.`;function Zd(e){return e.details?.trim()||null}function Qd(e){return e.description.trim()||`No details for this tool yet.`}var $d=`A demo: its calls are checked and logged, but nothing runs on your PC yet.`;function ef(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function tf(e){if(`at`in e)return`once, ${ef(e.at)}`;if(`everyMinutes`in e){let t=e.everyMinutes;return t%1440==0?t===1440?`every day`:`every ${t/1440} days`:t%60==0?t===60?`every hour`:`every ${t/60} hours`:`every ${t} minutes`}return`cron ${e.cron}`}function nf(e,t){return t?e?`next ${ef(e)}`:`done`:e?`paused`:`done`}function rf(e){return`${e} is offline — its chats can be read while it is online.`}function af(e,t,n){return n?`${e}::${n}::${t}`:`${e}::${t}`}function of(e,t){return e===`oonacode`?-1:t}function sf(e){return e.filter(e=>e.definition.enabled&&e.configured&&e.definition.poolOnly!==!0&&w(e.definition.id)&&!E(e.definition.id)&&e.definition.models.length>0).map((e,t)=>({p:e,order:of(e.definition.id,t)})).sort((e,t)=>e.order-t.order).map(e=>e.p)}function cf(e){let t=Ts(e.definition);if(t.length<2)return[{variantId:null,suffix:``}];let n=new Set((e.credentials??[]).map(e=>e.variantId??`payg`)),r=t.filter(e=>n.has(e.id));return r.length<2?[{variantId:null,suffix:``}]:r.map(e=>({variantId:e.id,suffix:` ${lf(e.id,e.label)}`}))}function lf(e,t){return e===`token-plan`?`Subscription`:e===`payg`||e===`api-key`?`API`:t}function uf(e,t){let n=sf(e),r=e=>{let t=e.definition.clientGroup,r=(t?n.find(e=>e.definition.id===t)?.definition:void 0)?.displayName??e.definition.displayName,i=n.filter(n=>(n.definition.clientGroup??n.definition.id)===(t??e.definition.id));return e.definition.recordLabel&&i.length>1?`${r} ${e.definition.recordLabel}`:r};return n.flatMap(n=>{let i=al(n.definition.models,t?.[n.definition.id]),a=r(n);return cf(n).map(t=>({providerId:n.definition.id,variantId:t.variantId,label:`${a}${t.suffix}`,route:n.definition.route,models:i.map(r=>({providerId:n.definition.id,variantId:t.variantId,modelId:r.id,label:r.displayName||r.id,value:af(n.definition.id,r.id,t.variantId),free:r.free===!0,details:{...r.aaIntelligence===void 0?{}:{intelligence:r.aaIntelligence},...r.aaCoding===void 0?{}:{coding:r.aaCoding},...r.aaOutputTps===void 0?{}:{outputTps:r.aaOutputTps},...r.aaTtft===void 0?{}:{ttft:r.aaTtft},...r.contextWindow===void 0?{}:{contextWindow:r.contextWindow},...r.maxOutputTokens===void 0?{}:{maxOutputTokens:r.maxOutputTokens},...r.supportsThinking===void 0?{}:{thinking:r.supportsThinking},...r.supportsVision===void 0?{}:{vision:r.supportsVision},...r.supportsTools===void 0?{}:{tools:r.supportsTools},...n.definition.id===`oonacode`?r.creditsPerM===void 0?r.free===!0?{creditsPerM:{input:0,output:0}}:{}:{creditsPerM:r.creditsPerM}:{},...r.notes===void 0?{}:{notes:r.notes},...r.aa===void 0?{}:{aa:r.aa},...r.servedBy===void 0?{}:{providers:r.servedBy.map(t=>{let n=e.find(e=>e.definition.id===t)?.definition,i=n?.displayName??t;if(!r.subscriptionServedBy?.includes(t))return i;let a=n?.credentialVariants?.find(e=>e.id===`token-plan`)?.label;return`${i} — ${a?a.replace(/\s*\(.*\)\s*$/,``):`subscription`}`})}}}))}))}).filter(e=>e.models.length>0)}function df(e,t){if(!t.providerId||!t.model)return!1;let n=e.find(e=>e.definition.id===t.providerId)?.definition;if(!n||n.models.length===0)return!1;let r=zs(t.model);if(n.models.some(e=>e.id===r||e.upstreamId===r)||n.modelAliases?.[r]!==void 0||Hs(n,r)!==null)return!1;let i=r.toLowerCase();return!Vs(i)||n.modelAliases?.[i]===void 0&&!n.models.some(e=>e.id.toLowerCase().includes(i))}function ff(e,t){let n=uf(e),r=n[0]??null,i=t.providerId??r?.providerId??null,a=t.variantId??(i?n.find(e=>e.providerId===i)?.variantId??null:r?.variantId??null);if(!i)return{providerId:null,variantId:a,modelId:t.model??null};let o=e.find(e=>e.definition.id===i)?.definition;return t.model?{providerId:i,variantId:a,modelId:(o?Hs(o,t.model):null)??t.model}:{providerId:i,variantId:a,modelId:o?.defaultModel||n.find(e=>e.providerId===i)?.models[0]?.modelId||null}}function pf(e){return`Remote access is turned off on ${e}, so it cannot be reached from here. Turn it on in OonaCode on that PC — Settings → This PC → Remote access — then try again.`}function mf(e,t,n){switch(e){case`host_offline`:return rf(t);case`host_locked`:return`${t} is locked — unlock it to read its chats.`;case`host_remote_access_off`:return pf(t);case`host_outdated`:return`${t} runs an older OonaCode — update it there to read its chats from here.`;case`no_answer`:return`${t} did not answer — try again in a moment.`;case`relay_off`:return`Remote access is off on this PC — turn it on in Settings to reach your other PCs.`;case`vault_locked`:return`Unlock your vault to read the chats on your other PCs.`;case`logged_out`:return`Sign in to your OonaCode account to see your other PCs.`;case`gateway_unreachable`:return`Your account server is unreachable right now.`;default:return n??null}}function hf(e){if(typeof e!=`string`)return null;let t=/^(?:Failed to authenticate\.\s*)?API Error\b:?\s*(?:(\d{3})(?!\d)\s*)?([\s\S]*)$/i.exec(e.trim());return t?{status:t[1]===void 0?null:Number(t[1]),message:(t[2]??``).trim()}:null}function gf(e){return typeof e!=`string`||e===``?!1:/prompt is too long|maximum context length|context[ _-]?length[ _-]?exceeded|input token count exceeds|too many (?:input )?tokens|exceeds? the (?:maximum|model's) context/i.test(e)}var _f=`chat too long for this model`;function vf(e){return typeof e!=`string`||e===``?!1:/safeguards? (?:have )?(?:flagged|blocked)/i.test(e)}var yf=`blocked by safeguards`;function bf(e){return typeof e!=`string`||e===``?!1:/\bnot included in (?:your|the [^.;]*?) plan\b/i.test(e)}var xf=`not in your plan`;function Sf(e){return bf(e)?e.replace(/^\s*Failed to authenticate\.\s*/i,``):e}function Cf(e,t){if(gf(t))return _f;if(vf(t))return yf;if(bf(t))return xf;switch(e){case 400:case 422:return`invalid request`;case 401:return`sign-in needed`;case 402:return`insufficient credits`;case 403:return`not allowed`;case 404:return`model not found`;case 408:case 504:return`timed out`;case 413:return`request too large`;case 429:return`rate limited`;default:return e!==null&&e>=500&&e<=599?`provider error`:`API error`}}var wf={error_max_turns:`max turns reached`,error_max_budget_usd:`budget reached`,error_during_execution:`error during execution`,error_max_structured_output_retries:`structured output failed`,interrupted:`interrupted`,success:`error`};function Tf(e){if(!e.isError)return`turn complete`;let t=hf(e.text);if(t)return Cf(t.status,t.message);let n=wf[e.subtype];if(n!==void 0)return n;let r=e.subtype.replace(/_/g,` `).trim();return r===``?`error`:r}var Ef={authentication_failed:`sign-in needed`,billing_error:`billing problem`,rate_limit:`rate limited`,invalid_request:`invalid request`,server_error:`provider error`};function Df(e,t){if(typeof e!=`string`)return null;let n=e.trim();if(n===``)return null;if(gf(t))return _f;if(vf(t))return yf;if(bf(t))return xf;let r=Ef[n];if(r!==void 0)return r;if(n===`unknown`){let e=hf(t);return e?Cf(e.status,e.message):gf(t)?_f:`error`}return n.replace(/_/g,` `)}var Of=`model_refusal_fallback`,kf=`model_refusal_no_fallback`;function Af(e){return typeof e==`string`&&e.trim()!==``?e.trim():null}function jf(e,t,n){return Af(e[t])??Af(e[n])}function Mf(e){if(typeof e!=`object`||!e)return null;let t=e,n=t.subtype,r=n===`model_refusal_fallback`?`fallback`:n===`model_refusal_no_fallback`?`no_fallback`:t.kind===`fallback`||t.kind===`no_fallback`?t.kind:null;if(!r||t.type!==void 0&&t.type!==`system`)return null;let i=t.retracted_message_uuids??t.retractedMessageUuids??t.retractedUuids;return{kind:r,scope:t.scope===`local`?`local`:`session`,originalModel:jf(t,`original_model`,`originalModel`),fallbackModel:r===`fallback`?jf(t,`fallback_model`,`fallbackModel`):null,category:jf(t,`api_refusal_category`,`apiRefusalCategory`)??Af(t.category),explanation:jf(t,`api_refusal_explanation`,`apiRefusalExplanation`)??Af(t.explanation),text:typeof t.content==`string`?t.content.trim():Af(t.text)??``,retractedUuids:Array.isArray(i)?i.filter(e=>typeof e==`string`):[]}}function Nf(e,t){switch(t.type){case`notice`:return t.notice.kind!==`fallback`||t.notice.scope!==`session`?e:{notice:t.notice,at:t.at,live:t.live};case`engine_start`:case`model_change`:return null}}function Pf(e,t){return!e||t.alive===!1||!e.live&&t.since!==null&&e.at!==null&&e.at<t.since?null:e}function Ff(e){let t=zs(e.trim()),n=t.slice(t.lastIndexOf(`/`)+1),r=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),i=n.split(`-`);if(i[0]?.toLowerCase()!==`claude`)return t;let a=i.slice(1).filter(e=>!/^\d{6,}$/.test(e)),o=a.filter(e=>!/^\d+$/.test(e)),s=a.filter(e=>/^\d+$/.test(e));return o.length!==1||s.length===0?t:`${r(o[0])} ${s.join(`.`)}`}function If(e,t=[]){let n=zs(e.trim()),r=null;for(let e of t)for(let t of e.definition.models){if(t.id===n||zs(t.id)===n)return t.displayName;r===null&&(t.upstreamId===n||cl(t.id)===n)&&(r=t.displayName)}return r??Ff(n)}function Lf(e){return`${e} (safeguard)`}function Rf(e){return typeof e==`number`&&Number.isFinite(e)?e:0}function zf(e,t){let n=typeof e==`object`&&e?e:{},r={input:Rf(n.input_tokens),cached:Rf(n.cache_read_input_tokens)+Rf(n.cache_creation_input_tokens),output:Rf(n.output_tokens)};if(r.input+r.cached+r.output>0||typeof t!=`object`||!t)return r;let i={input:0,cached:0,output:0};for(let e of Object.values(t)){if(typeof e!=`object`||!e)continue;let t=e;i.input+=Rf(t.inputTokens),i.cached+=Rf(t.cacheReadInputTokens)+Rf(t.cacheCreationInputTokens),i.output+=Rf(t.outputTokens)}return i}function Bf(e,t){switch(e){case`chat`:return t===`api`?`Messages API`:t===`all`?`Chat turns & Messages API`:`Chat turns`;case`agent-run`:return`Agent API runs`;case`about`:return`Chat "about" (session info)`;case`voice-summary`:return`Voice — summary`;case`voice-translation`:return`Voice — translation`;case`image`:return`Images`;case`video`:return`Video`;case`speech`:return`Speech (text to speech)`;case`transcription`:return`Transcription`;case`audio-translation`:return`Audio translation`;case`voice-design`:return`Custom voices`;case`realtime`:return`Realtime voice`;case`key-check`:return`Key checks`}}function Vf(e,t){switch(e){case`chat`:return t===`api`?`Calls to /v1/messages with your API keys.`:t===`all`?`Chats on the account’s PCs (subagents, titles and page reading included) and /v1/messages calls with its API keys.`:`Your chats — every model call a turn makes, subagents, titles and page reading included.`;case`agent-run`:return`Model calls made by agent-API runs in their sandboxes.`;case`about`:return`The short background summary each chat keeps for your other chats.`;case`voice-summary`:return`Spoken summaries of replies, written by the housekeeper model.`;case`voice-translation`:return`Translation of what was said, done on the server.`;case`image`:return`Images generated.`;case`video`:return`Videos generated.`;case`speech`:return`Text turned into speech.`;case`transcription`:return`Audio turned into text.`;case`audio-translation`:return`Audio translated into English text.`;case`voice-design`:return`Custom voices made or cloned.`;case`realtime`:return`Live voice sessions, billed by the slice.`;case`key-check`:return`Tests of a key you once added; not charged.`}}var Hf={maxRangeDays:366,maxHourlyRangeDays:31,defaultRangeDays:30,autoHourlyMaxHours:48},Uf=`mcp__oonacode__switch_workspace`,Wf=`Switch workspace`;function Gf(e){if(e.toolName!==`SwitchWorkspace`)return null;let t=e.input;return!t||typeof t!=`object`||typeof t.from!=`string`||typeof t.to!=`string`?null:{from:t.from,to:t.to,create:t.create===!0}}function Kf(e){return`${e.from} → ${e.to}${e.create?` (new folder)`:``}`}var qf=`mcp__oonacode__new_chat`,Jf=`New chat`,Yf={titleChars:120,reasonChars:500,promptChars:1e5};function Xf(e){return typeof e==`string`?e:null}function Zf(e){if(e.toolName!==`NewChat`)return null;let t=e.input;if(!t||typeof t!=`object`)return null;let n=Xf(t.title),r=Xf(t.prompt),i=Xf(t.fromId);return n===null||r===null||i===null?null:{title:n,prompt:r,reason:Xf(t.reason)??``,folder:Xf(t.folder),model:Xf(t.model),providerId:Xf(t.providerId),effort:Xf(t.effort),project:Xf(t.project),fromId:i,fromTitle:Xf(t.fromTitle)??``}}function Qf(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1).trimEnd()}…`:n}function $f(e){return`“${Qf(e.replace(/["“”]/g,`'`),Yf.titleChars)||`Untitled chat`}”`}function ep(e){return e.folder??`a new workspace of its own`}function tp(e){return`${e.model??`the default model`}${e.providerId?` (${e.providerId})`:``}${e.effort?` · effort ${e.effort}`:``}`}function np(e){return`${$f(e.title)} · ${ep(e)} · ${e.model??`default model`}`}var rp=`Started a new chat `,ip=/^Started a new chat “([^”\n]*)” for this task — chat ([0-9A-Za-z-]{8,64})$/;function ap(e){if(typeof e!=`string`)return null;let t=e.trim();if(t.startsWith(`<local-command-stdout>`)&&t.endsWith(`</local-command-stdout>`)&&(t=t.slice(22,t.length-23).trim()),!t.startsWith(rp))return null;let n=ip.exec(t);return n?{title:n[1]??``,sessionId:n[2]}:null}function op(e,t,n=140){let r=bl({toolName:e,input:t});if(r){let e=`${r.name} ${r.version} (${yl(r.sizeBytes)}) → ${r.path}`;return e.length>n?`${e.slice(0,n)}…`:e}let i=Gf({toolName:e,input:t});if(i){let e=Kf(i);return e.length>n?`…${e.slice(e.length-n)}`:e}let a=Zf({toolName:e,input:t});if(a){let e=np(a);return e.length>n?`${e.slice(0,n)}…`:e}let o=e===Uf?Wf:e===qf?Jf:e;if(e===qf){let e=t?.title;if(typeof e==`string`&&e.trim()){let t=e.replace(/\s+/g,` `).trim();return`${o}: ${t.length>n?`${t.slice(0,n)}…`:t}`}}let s=t??{};for(let e of[`command`,`file_path`,`pattern`,`query`,`url`,`path`,`prompt`]){let t=s[e];if(typeof t==`string`&&t.trim().length>0){let e=t.replace(/\s+/g,` `).trim();return`${o}: ${e.length>n?`${e.slice(0,n)}…`:e}`}}return o}var sp={wav:{kind:`audio`,mime:`audio/wav`},mp3:{kind:`audio`,mime:`audio/mpeg`},ogg:{kind:`audio`,mime:`audio/ogg`},oga:{kind:`audio`,mime:`audio/ogg`},opus:{kind:`audio`,mime:`audio/ogg`},m4a:{kind:`audio`,mime:`audio/mp4`},aac:{kind:`audio`,mime:`audio/aac`},flac:{kind:`audio`,mime:`audio/flac`},weba:{kind:`audio`,mime:`audio/webm`},mp4:{kind:`video`,mime:`video/mp4`},m4v:{kind:`video`,mime:`video/mp4`},mov:{kind:`video`,mime:`video/mp4`},webm:{kind:`video`,mime:`video/webm`},mkv:{kind:`video`,mime:`video/x-matroska`},ogv:{kind:`video`,mime:`video/ogg`},png:{kind:`image`,mime:`image/png`},jpg:{kind:`image`,mime:`image/jpeg`},jpeg:{kind:`image`,mime:`image/jpeg`},gif:{kind:`image`,mime:`image/gif`},webp:{kind:`image`,mime:`image/webp`},bmp:{kind:`image`,mime:`image/bmp`},svg:{kind:`image`,mime:`image/svg+xml`},avif:{kind:`image`,mime:`image/avif`}};function cp(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`)),n=e.slice(t+1),r=n.lastIndexOf(`.`);return r<=0?``:n.slice(r+1).toLowerCase()}function lp(e){return sp[cp(e)]??null}var up=`oonacode`,dp=Object.freeze({doctor:`off`,"update-config":`off`,"fewer-permission-prompts":`off`,loop:`off`,insights:`off`,"team-onboarding":`off`,"auto-mode-setup":`off`,"keybindings-help":`off`}),fp=Object.freeze({model:{refusedBy:`app`,reason:`Use the model picker under the message box — the chat keeps the model you pick there.`},usage:{aliases:[`cost`,`stats`],refusedBy:`host`,reason:`It shows the engine's own estimate at list prices, not your OonaCode credits — see Credits used in the chat's Session info, and Credits and plan in the title bar.`,terminalReason:`It shows the engine's own estimate at list prices, not your OonaCode credits — /cost shows what this chat was charged.`},autocompact:{refusedBy:`host`,reason:`OonaCode sets the context window from the model's real size at every engine start — nothing to set here.`},"output-style":{refusedBy:`host`,reason:`A style set here is lost at the chat's next engine start — ask the chat to answer in the style you want.`},mcp:{refusedBy:`host`,reason:`OonaCode's tools are switched per chat in the Tools menu under the message box.`},"list-agents":{aliases:[`peers`],refusedBy:`host`,reason:`This chat's subagents are on the agents badge beside the model picker; chats talking to each other are in View → Conversations.`},"reload-skills":{refusedBy:`host`,reason:`OonaCode reloads skills by itself when you import or remove one in Settings → Skills.`}}),pp=`Needs a Claude account signed in to the engine — OonaCode runs the engine without one.`,mp=`It reads or edits your own Claude Code install (~/.claude), which OonaCode never touches.`,hp=Object.freeze({clear:{availability:`not-in-oonacode`,reason:`It starts a new engine conversation that this chat would not follow — start a new chat (+) instead.`},fast:{availability:`not-in-oonacode`,reason:`The engine answers "Fast mode is not available in the Agent SDK".`},config:{availability:`not-in-oonacode`,reason:`Claude Code's terminal settings, written to a file OonaCode rebuilds at every engine start — OonaCode's own are in Settings.`},effort:{availability:`not-in-oonacode`,reason:`Use the effort picker under the message box — it is saved with the chat.`},rename:{availability:`not-in-oonacode`,reason:`Rename the chat from its tab or the sidebar — the engine's own title is not the chat's.`},color:{availability:`not-in-oonacode`,reason:`The terminal prompt bar's colour — it belongs to Claude Code's terminal.`},"reload-plugins":{availability:`not-in-oonacode`,reason:`OonaCode loads no plugins — import a plugin's skills in Settings → Skills instead.`},heapdump:{availability:`not-in-oonacode`,reason:`It writes the engine's memory dump to your Desktop — a Claude Code diagnostic.`},agents:{availability:`not-in-oonacode`,reason:`The engine removed this wizard — ask the chat to create a subagent in .claude/agents/.`},"__remote-workflow":{availability:`not-in-oonacode`,reason:`It runs only inside Anthropic's cloud sessions.`},"workflow-launch-exec":{availability:`not-in-oonacode`,reason:`It runs only inside Anthropic's cloud sessions.`},doctor:{availability:`not-in-oonacode`,reason:mp},"update-config":{availability:`not-in-oonacode`,reason:mp},"fewer-permission-prompts":{availability:`not-in-oonacode`,reason:mp},"keybindings-help":{availability:`not-in-oonacode`,reason:mp},loop:{availability:`not-in-oonacode`,reason:`It schedules through the engine's own cron, which OonaCode turns off — ask the chat to schedule a task; OonaCode's scheduler runs it.`},insights:{availability:`not-in-oonacode`,reason:`It analyses Claude Code's own session files; OonaCode keeps chats in its own database, so the report would be empty.`},"team-onboarding":{availability:`not-in-oonacode`,reason:`It reads usage from Claude Code's own session files, which OonaCode does not keep — there is nothing to read.`},"auto-mode-setup":{availability:`not-in-oonacode`,reason:`Auto mode is not one of OonaCode's postures (${A.map(e=>e.label).join(`, `)}).`},login:{availability:`needs-anthropic-account`,reason:pp},logout:{availability:`needs-anthropic-account`,reason:pp},upgrade:{availability:`needs-anthropic-account`,reason:pp},"extra-usage":{availability:`needs-anthropic-account`,reason:pp},"rate-limit-options":{availability:`needs-anthropic-account`,reason:pp},"privacy-settings":{availability:`needs-anthropic-account`,reason:pp},feedback:{availability:`needs-anthropic-account`,reason:pp},bug:{availability:`needs-anthropic-account`,reason:pp},"install-github-app":{availability:`needs-anthropic-account`,reason:pp},"install-slack-app":{availability:`needs-anthropic-account`,reason:pp},"remote-control":{availability:`needs-anthropic-account`,reason:pp},"remote-env":{availability:`needs-anthropic-account`,reason:pp},"web-setup":{availability:`needs-anthropic-account`,reason:pp},ultrareview:{availability:`needs-anthropic-account`,reason:pp},ultraplan:{availability:`needs-anthropic-account`,reason:pp},passes:{availability:`needs-anthropic-account`,reason:pp},teleport:{availability:`needs-anthropic-account`,reason:pp},...Object.fromEntries(Object.entries(fp).map(([e,t])=>[e,{availability:`not-in-oonacode`,reason:t.reason,...t.refusedBy===`app`?{refusedBy:`app`}:{},...t.terminalReason?{terminalReason:t.terminalReason}:{}}]))});Object.freeze({});function gp(e){let t=`${up}:`;return e.startsWith(t)&&e.length>t.length?e.slice(t.length):null}function _p(e){let t=/^\/([^\s/]*)$/.exec(e);return t?t[1]:null}function vp(e){let t=/^\/([A-Za-z0-9][\w:.-]*)(?:\s|$)/.exec(e.trimStart());return t?t[1]:null}function yp(e,t=`host`){let n=vp(e);if(n===null)return null;let r=hp[n]??hp[xp[n]??``];return!r||r.availability!==`not-in-oonacode`||r.refusedBy===`app`&&t!==`app`?null:{...r,command:n}}function bp(e){return e.refusedBy===`app`?`/${e.command} is not used here. ${e.reason}`:`/${e.command} is not available in OonaCode. ${e.reason}`}var xp=Object.freeze({reset:`clear`,new:`clear`,settings:`config`,name:`rename`,checkup:`doctor`,proactive:`loop`,...Object.fromEntries(Object.entries(fp).flatMap(([e,t])=>(t.aliases??[]).map(t=>[t,e])))});function Sp(e){let t=!1,n=e.map(e=>{if(e.availability!==`ok`||e.source!==`builtin`&&e.source!==`skill`)return e;let n=hp[e.name];if(!n)return e;t=!0;let{note:r,...i}=e;return{...i,availability:n.availability,reason:n.reason}});return t?n:e}function Cp(e,t,n=60){let r=t.trim().toLowerCase(),i=e=>[e.name,...e.aliases??[]].map(e=>e.toLowerCase()),a=e=>r.length>0&&i(e).includes(r),o=[[],[],[],[]];for(let t of e){if(t.availability!==`ok`&&!a(t))continue;let e=i(t);r.length===0?o[1].push(t):a(t)?o[0].push(t):e.some(e=>e.startsWith(r))?o[1].push(t):e.some(e=>e.includes(r))?o[2].push(t):t.description.toLowerCase().includes(r)&&o[3].push(t)}return o.flat().slice(0,n)}function wp(e,t){if(!/^\/\S+\s/.test(e))return null;let n=vp(e);return n===null?null:t.find(e=>e.name===n)??t.find(e=>e.aliases?.includes(n))??null}function Tp(e){switch(e){case`skill`:return`skill`;case`user`:return`your skill`;case`project`:return`project`;case`plugin`:return`plugin`;case`mcp`:return`MCP`;case`other`:return`other`;default:return null}}var Ep=[`skills`,`commands`],Dp=Object.freeze({skills:`Skills`,commands:`Commands`});function Op(e){if(e.modelSkill!==void 0)return`skills`;switch(e.source){case`skill`:case`user`:case`project`:case`plugin`:return`skills`;default:return`commands`}}function kp(e){let t={skills:[],commands:[]};for(let n of e)t[Op(n)].push(n);return t}var Ap=/(?:^|[\s(])(?:e\.g|i\.e|etc|vs|cf|incl|approx|fig)$/i;function jp(e,t=90){let n=(e.split(/\n\s*\n/)[0]??``).replace(/\s+/g,` `).trim(),r=n,i=/[.!?](?=\s|$)|[。!?]/g;for(let e=i.exec(n);e!==null;e=i.exec(n)){let t=n.slice(0,e.index);if(!(e[0]===`.`&&Ap.test(t))){r=(e[0]!==`.`&&e[0]!==`。`?n.slice(0,e.index+1):t).trim();break}}if(r.length<=t)return r;let a=r.slice(0,t-1),o=a.lastIndexOf(` `);return`${(r[t-1]===` `||o<=t*.66?a:a.slice(0,o)).replace(/[\s,;:—–-]+$/,``)}…`}function Mp(e){return typeof e==`string`&&/^[A-Za-z0-9][\w.:-]{0,127}$/.test(e)}function Np(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e)if(Mp(n)&&!Object.hasOwn(dp,n)&&(t.add(n),t.size>=200))break;return[...t].sort((e,t)=>e.localeCompare(t))}function Pp(e,t,n){let r=new Set(e??[]);return n?r.add(t):r.delete(t),[...r].sort((e,t)=>e.localeCompare(t))}function Fp(e,t){return(e??[]).includes(t)}function Ip(e,t){let n=new Set(t??[]);if(n.size===0)return 0;let r=408;for(let t of e)n.has(t.name)&&(r+=t.tokens);return r}function Lp(e,t){let n=[...new Set(t??[])];return{count:n.length,label:`Skills · ${n.length}`,title:n.length>0?`The model may use on its own in this chat: ${n.map(t=>e?.find(e=>e.name===t)?.label??t).join(`, `)}`:`The model uses no skill on its own in this chat — type /name to use one once`}}function Rp(e){let t=Np(e??[]);return t.length>0?{modelSkills:t}:{}}var zp=`Every skill is always in the / menu — type it to use it once. Switch one on to let the model reach for it by itself in this chat (it then costs its tokens on every message).`,Bp=`Switching a skill restarts this chat's agent: the skill list is part of the prompt, so its next message re-reads the conversation once.`,Vp=`The first skill switched on also brings back the engine's Skill tool (≈388 tokens per request).`;function Hp(e){switch(e){case`user`:return`Yours`;case`project`:return`Project`;case`plugin`:return`Plugin`;case`mcp`:return`MCP`;case`skill`:case`builtin`:return`Built in`;default:return`Other`}}function Up(e){switch(e){case`user`:return`One of your own skills — OonaCode's skills folder (Settings → Skills), on every chat of this PC.`;case`project`:return"This project's own — its `.claude/skills` (or `.claude/commands`) folder.";case`skill`:case`builtin`:return`Built into the coding engine OonaCode runs for every model.`;case`plugin`:return`From a plugin the engine loaded.`;case`mcp`:return`From an MCP server of this chat.`;default:return`Found by the engine in this chat’s configuration.`}}function Wp(e,t){let n=[];return e.description.trim()&&n.push(e.description.trim(),``),n.push(`**Where it comes from.** ${Up(e.source)}`,``),n.push(e.typeable?`**Once, by typing it.** Type \`/${e.label}\` (or pick it in the / menu) and the engine loads it for that message only — whether this switch is on or off, at no cost to any other message.`:`**It cannot be typed.** Its author made it for the model only, so the switch is the only way to use it.`,``),n.push(t?`**On in this chat.** The model sees its name and description on every message here and may load it by itself when it fits.`:`**Off in this chat.** The model is not told it exists here. Switch it on to let the model reach for it by itself.`,``),n.push(`**What it costs while on.** ≈${e.tokens.toLocaleString(`en-US`)} tokens on every request of this chat (and the engine's Skill tool, ≈388, for the first skill on). Switching restarts the chat's agent; its next message re-reads the conversation once.`),n.join(`
|
|
96
|
-
`)}var Gp=/^[A-Za-z0-9][\w.:@+\-/]*(?:\[[0-9a-z]+\])?$/;function Kp(e){return e.length>0&&e.length<=200&&Gp.test(e)&&!e.endsWith(`/`)&&!e.includes(`//`)}function qp(e){let t=/^\/setcustommodel(?:\s+([\s\S]*))?$/i.exec(e.trim());if(!t)return null;let n=(t[1]??``).trim();return n===``||n.toLowerCase()===`off`?{kind:`off`}:/\s/.test(n)?{kind:`invalid`,reason:`one model id, with no spaces`}:Kp(n)?{kind:`set`,model:n}:{kind:`invalid`,reason:`'${n.slice(0,60)}' is not a model id`}}function Jp(e){let t=e.indexOf(`/`);return t<=0||t===e.length-1?null:{prefix:e.slice(0,t).toLowerCase(),model:e.slice(t+1)}}function Yp(e,t,n){let r={providerId:t.providerId,variantId:t.variantId??null},i=Jp(e);return!i||!n.includes(i.prefix)?{...r,model:e}:i.prefix===t.providerId?{...r,model:i.model}:t.providerId===`oonacode`?{...r,model:e}:{providerId:i.prefix,variantId:null,model:i.model}}function Xp(e,t){let n=t.variantId??null;if(t.providerId===`oonacode`)return{providerId:t.providerId,variantId:n,model:e};let r=Jp(e),i=r&&r.prefix===t.providerId.toLowerCase()?r.model:e;return{providerId:t.providerId,variantId:n,model:i}}function Zp(e){return`${e} (custom)`}var Qp=`google-agy`;function $p(e){return e===Qp}var em=[`build`,`auto`];function tm(e){return $p(e)?A.filter(e=>em.includes(e.id)):A}var nm=`Google’s agy cannot ask for permission while OonaCode drives it, so this chat offers Build (agy may edit files; a command it wants to run is declined and reported) and Autonomous (agy may run everything).`,rm=`Sign in on Google’s own page with your own Google account. Google then shows you a one-time code: paste it here. OonaCode never sees your password, and your sign-in stays on this PC.`;function im(e){return typeof e==`string`&&e.length>=8&&e.length<=512&&/^[A-Za-z0-9/_.~%+=-]+$/.test(e)}var am={complete:`/api/v1/account/vault/rekey-complete`,revoke:`/api/v1/account/vault/rekey-revoke`,deviceUnlock:`/api/v1/account/device-unlock`};function om(e){return e?.deviceUnlock??`off`}function sm(e){if(!e?.loggedIn)return null;let t=e;if(t.vaultStatus!==`pending_rekey`)return null;let n=t.vaultRekeyPending??null;return{pending:n,canFinishHere:t.canFinishRekey===!0,trustedDevices:n?.trustedDevices.map(e=>e.label||e.name)??[],since:n?.since??null,from:cm(n)}}function cm(e){if(!e)return null;let t=e.requestedFrom.device?.trim()||null,n=e.requestedFrom.ip?.trim()||null;return t&&n?`${t} (${n})`:t??n}function lm(e){if(!e)return`an unknown date`;let t=Date.parse(e);if(Number.isNaN(t))return`an unknown date`;try{return new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}catch{return new Date(t).toISOString()}}function um(e){let t=e.from?` from ${e.from}`:``;return`A password reset was started on ${lm(e.since)}${t}. Your saved provider keys are still sealed under the old password.`}function dm(e){return e.trustedDevices.length===0?`No device with "keep me unlocked" is left, so nothing here holds the key from before the reset.`:`Open OonaCode on ${pm(e.trustedDevices)} to finish the reset — your saved keys are waiting there.`}var fm=`Either way, your vault Recovery Key still works: sign in on the OonaCode website from any device and finish the reset there. Discarding is the last resort — it deletes your saved provider keys and that Recovery Key for good. Your chats stay on your PCs.`;function pm(e){return e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} or ${e[e.length-1]}`}function mm(e){return e.canFinishHere?`A password reset is waiting: this PC can move your vault to the new password.`:e.trustedDevices.length>0?`A password reset is waiting — your saved keys stay locked until it is finished on ${pm(e.trustedDevices)}.`:`A password reset is waiting and no PC holds the old key — finish it with your vault Recovery Key on the OonaCode website.`}var hm=class extends Error{code;status;details;constructor(e,t,n,r){super(n),this.name=`HostApiError`,this.code=e,this.status=t,this.details=r}get isUnauthorized(){return this.status===401||this.code===`unauthorized`}get isEmailNotVerified(){return this.code===`email_not_verified`}};function gm(e){if(!e)return``;let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!=null&&r!==``&&t.set(n,String(r));let n=t.toString();return n?`?${n}`:``}function _m(e){return e.trim().replace(/\/+$/,``)}function vm(e,t){let n=_m(e.baseUrl),r=t??((e,t)=>fetch(e,t));async function i(t,i,a,o={}){let s={Authorization:`Bearer ${e.token}`,Accept:o.raw||o.bytes?`*/*`:`application/json`},c={method:t,headers:s,credentials:`omit`};o.signal&&(c.signal=o.signal),a!==void 0&&(s[`Content-Type`]=`application/json`,c.body=JSON.stringify(a));let l;try{l=await r(`${n}${i}`,c)}catch(e){throw new hm(`network`,0,`Cannot reach the host at ${n}: ${String(e?.message??e)}`)}if(!l.ok){let e=null,t=``;try{t=await l.text(),e=t?JSON.parse(t):null}catch{e=null}let n=e?.error?.code??(l.status===401?`unauthorized`:`internal`),r=e?.error?.message??(t||`${l.status} ${l.statusText}`);throw new hm(n,l.status,r,e?.error?.details)}if(o.bytes)return await l.arrayBuffer();if(o.raw)return await l.text();if(l.status===204)return;let u=await l.text();if(u)try{return JSON.parse(u)}catch{throw new hm(`parse`,l.status,`Host returned malformed JSON for ${t} ${i}`)}}let a=Ie;return{health:()=>i(a.health,z.health),info:()=>i(a.info,z.info),listSessions:e=>i(a.listSessions,`${z.sessions}${gm(e)}`),createSession:e=>i(a.createSession,z.sessions,e),getSession:e=>i(a.getSession,z.session(e)),updateSession:(e,t)=>i(a.updateSession,z.session(e),t),deleteSession:e=>i(a.deleteSession,z.session(e)),exportSessionsArchive:async t=>{let i=await r(`${n}${z.sessionsExportArchive}`,{method:`POST`,credentials:`omit`,headers:{Authorization:`Bearer ${e.token}`,Accept:`application/zip`,"Content-Type":`application/json`},body:JSON.stringify({password:t})});if(!i.ok){let e=await i.text().catch(()=>``),t=null;try{t=e?JSON.parse(e):null}catch{t=null}throw new hm(t?.error?.code??`internal`,i.status,t?.error?.message??e??`the export failed`)}return i.blob()},listEntries:(e,t)=>i(a.listEntries,`${z.sessionEntries(e)}${gm(t)}`),listMessages:e=>i(a.listMessages,z.sessionMessages(e)),prompt:(e,t)=>i(a.prompt,z.sessionPrompt(e),{...t,stream:!1}),interrupt:e=>i(a.interrupt,z.sessionInterrupt(e),{}),cancelQueued:(e,t)=>i(a.cancelQueued,z.sessionQueued(e,t)),sendQueuedNow:(e,t)=>i(a.sendQueuedNow,z.sessionQueuedNow(e,t),{}),forkSession:(e,t)=>i(a.fork,z.sessionFork(e),t??{}),exportSession:(e,t)=>i(a.export,`${z.sessionExport(e)}${gm(t)}`,void 0,{raw:!0}),listProjects:()=>i(a.listProjects,z.projects),listVaultProjects:()=>i(a.listVaultProjects,z.vaultProjects),createVaultProject:e=>i(a.createVaultProject,z.vaultProjects,e),updateVaultProject:(e,t)=>i(a.updateVaultProject,z.vaultProject(e),t),deleteVaultProject:e=>i(a.deleteVaultProject,z.vaultProject(e)),listScheduledTasks:(e={})=>{let t=new URLSearchParams;e.sessionId&&t.set(`sessionId`,e.sessionId),e.projectId&&t.set(`projectId`,e.projectId);let n=t.toString();return i(a.listScheduledTasks,n?`${z.scheduledTasks}?${n}`:z.scheduledTasks)},createScheduledTask:e=>i(a.createScheduledTask,z.scheduledTasks,e),updateScheduledTask:(e,t)=>i(a.updateScheduledTask,z.scheduledTask(e),t),deleteScheduledTask:e=>i(a.deleteScheduledTask,z.scheduledTask(e)),listConversations:(e={})=>i(a.listConversations,`${z.conversations}${gm({sessionId:e.sessionId})}`),getConversation:e=>i(a.getConversation,z.conversation(encodeURIComponent(e))),conversationAction:(e,t,n)=>i(a.conversationAction,z.conversationAction(encodeURIComponent(e),t),n??{}),stopAllConversations:()=>i(a.stopAllConversations,z.conversationsStopAll,{}),cancelChatMessage:e=>i(a.cancelChatMessage,z.chatMessage(encodeURIComponent(e))),getChatAbout:e=>i(a.getChatAbout,z.sessionAbout(encodeURIComponent(e))),updateChatAbout:(e,t)=>i(a.updateChatAbout,z.sessionAbout(encodeURIComponent(e)),t),regenerateChatAbout:e=>i(a.regenerateChatAbout,z.sessionAboutRegenerate(encodeURIComponent(e)),{}),listChatAbouts:()=>i(a.listChatAbouts,z.chatAbouts),generateAllChatAbouts:()=>i(a.generateAllChatAbouts,z.chatAboutsGenerateAll,{}),stopGenerateAllChatAbouts:()=>i(a.stopGenerateAllChatAbouts,z.chatAboutsGenerateAllStop,{}),generateChatAbouts:e=>i(a.generateChatAbouts,z.chatAboutsGenerate,e),planChatAboutTranslations:e=>i(a.planChatAboutTranslations,z.chatAboutsTranslationPlan,e),translateChatAbout:(e,t)=>i(a.translateChatAbout,z.sessionAboutTranslation(encodeURIComponent(e)),t),getAgyStatus:e=>i(`GET`,`${z.agyStatus}${gm(e?.refresh?{refresh:1}:void 0)}`),listAgyRequests:e=>i(`GET`,z.agyRequests(encodeURIComponent(e))),getAgyRequestBody:(e,t)=>i(`GET`,z.agyRequestBody(encodeURIComponent(e),encodeURIComponent(t))),agyInstall:()=>i(`POST`,z.agyInstall),cancelAgyInstall:()=>i(`DELETE`,z.agyInstall),agyLogin:()=>i(`POST`,z.agyLogin),cancelAgyLogin:()=>i(`DELETE`,z.agyLogin),submitAgyLoginCode:e=>i(`POST`,z.agyLoginCode,{code:e}),listVoiceSummaries:e=>i(a.listVoiceSummaries,z.sessionVoiceSummaries(encodeURIComponent(e))),createVoiceSummary:(e,t)=>i(a.createVoiceSummary,z.sessionVoiceSummaries(encodeURIComponent(e)),t),deleteVoiceSummary:(e,t)=>i(a.deleteVoiceSummary,z.sessionVoiceSummary(encodeURIComponent(e),encodeURIComponent(t))),translateVoiceSummary:(e,t,n)=>i(a.translateVoiceSummary,z.sessionVoiceSummaryTranslations(encodeURIComponent(e),encodeURIComponent(t)),n),getGithubLink:()=>i(a.getGithubLink,z.githubLink),searchEntries:e=>i(a.searchEntries,`${z.sessionSearch}${gm(e)}`),startGithubLink:()=>i(a.startGithubLink,z.githubLinkStart,{}),cancelGithubLink:()=>i(a.cancelGithubLink,z.githubLinkStart),unlinkGithub:()=>i(a.unlinkGithub,z.githubLink),scanClaudeSessions:()=>i(a.scanClaudeSessions,z.importClaude),importClaudeSessions:e=>i(a.importClaudeSessions,z.importClaude,e??{}),searchImportChats:(e,t)=>i(a.searchImportChats,`${z.importSearch}${gm(e)}`,void 0,t?{signal:t}:{}),sessionLink:e=>i(a.sessionLink,z.sessionLink(e)),syncSessionDown:e=>i(a.syncSessionDown,z.sessionSyncDown(e),{}),inspectProject:e=>i(a.inspectProject,`${z.projectInspect}${gm(e)}`),attachSessionProject:(e,t)=>i(a.attachSessionProject,z.sessionProject(e),t),listAgentTools:()=>i(`GET`,z.agentTools),listSessionCommands:e=>i(a.listSessionCommands,z.sessionCommands(encodeURIComponent(e))),listCommands:e=>i(a.listCommands,`${z.commands}${gm(e)}`),listSessionChatSkills:e=>i(a.listSessionChatSkills,z.sessionModelSkills(encodeURIComponent(e))),listChatSkills:e=>i(a.listChatSkills,`${z.modelSkills}${gm(e)}`),listSkills:()=>i(a.listSkills,z.skills),deleteSkill:e=>i(a.deleteSkill,z.skill(e)),scanClaudeSkills:()=>i(a.scanClaudeSkills,z.importClaudeSkills),importClaudeSkills:e=>i(a.importClaudeSkills,z.importClaudeSkills,e),listProviders:()=>i(a.listProviders,z.providers),setActiveProvider:e=>i(a.setActiveProvider,z.providersActive,e),testProvider:e=>i(a.providerTest,z.providerTest(e),{}),probeCredential:(e,t)=>i(a.providerProbe,z.providerProbe(e),t),listModels:e=>i(a.listModels,`${z.models}${gm(e)}`),getSettings:()=>i(a.getSettings,z.settings),updateSettings:e=>i(a.updateSettings,z.settings,e),getAccount:()=>i(a.getAccount,z.account),login:e=>i(a.login,z.accountLogin,e),logout:()=>i(a.logout,z.accountLogout,{}),unlock:e=>i(a.unlock,z.accountUnlock,e),lock:()=>i(`POST`,z.accountLock,{reason:`user`}),plan:()=>i(`GET`,z.accountPlan),accountUsage:e=>i(`GET`,`${z.accountUsage}${gm({...e})}`),remoteUnlockHost:(e,t)=>i(`POST`,z.hostVaultUnlock(e),{password:t}),resendVerification:e=>i(a.resendVerification,z.accountResendVerification,e),startAccountLink:e=>i(a.linkStart,z.accountLinkStart,e??{}),accountLinkStatus:()=>i(a.linkStatus,z.accountLinkStatus),cancelAccountLink:()=>i(a.linkCancel,z.accountLinkCancel,{}),completeVaultRekey:e=>i(`POST`,am.complete,e),revokeVaultRekey:e=>i(`POST`,am.revoke,e),setDeviceUnlock:e=>i(`POST`,am.deviceUnlock,e),listCredentials:()=>i(a.listCredentials,z.credentials),addCredential:e=>i(a.addCredential,z.credentials,e),deleteCredential:e=>i(a.deleteCredential,z.credential(e)),testCredential:e=>i(a.credentialTest,z.credentialTest(e),{}),syncNow:()=>i(a.syncNow,z.syncNow,{}),claudeSubscriptionLogin:()=>i(a.claudeLogin,z.subscriptionClaudeLogin,{}),claudeSubscriptionStatus:()=>i(a.claudeStatus,z.subscriptionClaudeStatus),claudeLoginState:()=>i(a.claudeLoginState,z.subscriptionClaudeLoginState),claudeLoginCode:e=>i(a.claudeLoginCode,z.subscriptionClaudeLoginCode,e),claudeLoginCancel:()=>i(a.claudeLoginCancel,z.subscriptionClaudeLoginCancel,{}),oauthLoginStart:e=>i(a.oauthLogin,z.subscriptionOauthLogin(e),{}),oauthLoginState:e=>i(a.oauthLoginState,z.subscriptionOauthLoginState(e)),oauthLoginCancel:e=>i(a.oauthLoginCancel,z.subscriptionOauthLoginCancel(e),{}),doctor:()=>i(a.doctor,z.doctor),listHosts:()=>i(a.listHosts,z.hosts),listHostSessions:e=>i(a.listHostSessions,z.hostSessions(e)),deleteHostSession:(e,t)=>i(a.deleteHostSession,z.hostSession(e,t),{method:`DELETE`}),updateHost:(e,t)=>i(a.updateHost,z.host(e),t),listHostSessionEntries:(e,t,n)=>i(a.listHostSessionEntries,`${z.hostSessionEntries(e,t)}${gm(n)}`),reportError:e=>i(a.errorReport,z.errorReport,e),sendBugReport:e=>i(a.bugReport,z.bugReport,e),listSessionFiles:(e,t)=>i(a.listSessionFiles,`${z.sessionFiles(e)}${gm({path:t})}`),readSessionFile:(e,t)=>i(a.readSessionFile,`${z.sessionFile(e)}${gm({path:t})}`,void 0,{raw:!0}),readSessionFileBytes:(e,t)=>i(a.readSessionFile,`${z.sessionFile(e)}${gm({path:t})}`,void 0,{bytes:!0}),deleteSessionFile:(e,t)=>i(a.deleteSessionFile,`${z.sessionFile(e)}${gm({path:t})}`),grantLocalFile:async(e,t)=>{let r=await i(a.grantLocalFile,z.sessionLocalFileGrant(e),{path:t});return{...r,url:/^https?:/i.test(r.url)?r.url:`${n}${r.url}`}},statLocalPaths:(e,t)=>i(a.statLocalPaths,z.sessionLocalFileStat(e),{paths:t})}}function ym(e){return e instanceof hm&&(e.status===404||e.status===501)}var bm=120;function xm(){return bm}function Sm(e){let t=e.batchMs??120,n=e.hiddenBatchMs??1e3,r=e.isHidden??(()=>!1),i=e.now??(()=>Date.now()),a=e.setTimeout??((e,t)=>setTimeout(e,t)),o=e.clearTimeout??(e=>clearTimeout(e)),s=[],c=null,l=-1/0,u=!1,d=()=>{if(c!==null&&(o(c),c=null),s.length===0)return;let t=s;s=[],l=i(),e.deliver(t)};return{push(o){if(u)return;if(s.push(o),!e.isStreamFrame(o)){d();return}let f=r()?n:t;if(f<=0){d();return}if(c!==null)return;let p=i()-l;if(p>=f){d();return}c=a(()=>{c=null,d()},f-p)},flush:d,dispose(){u=!0,c!==null&&o(c),c=null,s=[]}}}function Cm(e,t,n){if((t.providerId??``)!==e.providerId||e.variantId!==void 0&&(t.variantId??null)!==(e.variantId??null)||!t.model)return!1;let r=zs(t.model),i=zs(e.model);if(r===i)return!0;let a=n.find(t=>t.definition.id===e.providerId)?.definition;return a!==void 0&&Fs(a,i)===r}function wm(e){return e instanceof hm&&e.code===`email_not_verified`}function Tm(e){if(!wm(e))return null;let t={error:{code:e.code,message:e.message,details:e.details}};return k(t)?t.error.details:null}function Em(e){let t=e.trim(),n=t.indexOf(`@`);return n<=0?`***`:`${t.slice(0,1)}***${t.slice(n)}`}function Dm(e,t){return e===void 0||!Number.isFinite(e)||e<=0?t:t+Math.ceil(e)*1e3}function Om(e,t){return Math.max(0,Math.ceil((e.resendAt-t)/1e3))}function km(e,t){if(!wm(e))return null;let n=t.now??Date.now(),r=Tm(e),i=t.email.trim();return{email:i,displayEmail:r?.email||Em(i),verification:r?.verification??`pending`,registered:t.registered===!0,resendAt:Dm(r?.resendAfterSec,n)}}function Am(e){let t=e.registered?`Account created. `:``;return e.verification===`unverified`?`${t}Confirm your email first — no link is outstanding for ${e.displayEmail}; send a new one.`:`${t}Confirm your email first — we sent a link to ${e.displayEmail}.`}var jm=`new-chat`,Mm=`safeguard-fallback`,Nm=`safeguard-no-fallback`;function Pm(e=null){return{sessionId:e,session:null,items:[],index:new Map,status:`idle`,activeTurnId:null,init:null,statusText:null,pendingPermissions:[],lastSeq:null,totals:{costUsd:0,inputTokens:0,cachedInputTokens:0,outputTokens:0,turns:0},turnCachedTokens:0,contextTokens:null,hydrated:!1,agentActivity:{},hasSubagentItems:!1,hasOptimisticUser:!1,lastLocalPromptId:null,lastFrameAt:null,lastLiveUuid:null,engineSince:null,safeguardFallback:null,subpathParents:{},seen:new Set,streams:{},nextId:1}}function Fm(e,t){let n=e.agentActivity[t.agentId],r={subpath:t.subpath,firstAt:n?Math.min(n.firstAt,t.at):t.at,at:n?Math.max(n.at,t.at):t.at,finished:t.finished,toolUses:(n?.toolUses??0)+t.toolUses};return{...e,agentActivity:{...e.agentActivity,[t.agentId]:r}}}function Im(e,t,n,r,i,a){let o=Eh.exec(t)?.[2];if(!o)return e;let s=i&&Date.parse(i)||0;if(n!==`assistant`)return Fm(e,{agentId:o,subpath:t,at:s,finished:e.agentActivity[o]?.finished??!1,toolUses:0});let c=(Array.isArray(r)?r:[]).filter(e=>e.type===`tool_use`),l=c.length===0;return typeof a==`string`&&(l=a===`end_turn`||a===`stop_sequence`),c.some(e=>e.name===`StructuredOutput`)&&(l=!0),Fm(e,{agentId:o,subpath:t,at:s,finished:l,toolUses:c.length})}function Lm(e,t){switch(t.type){case`frame`:return Vm(e,t.frame,t.receivedAt);case`hydrate`:return Sh(e,t.messages,t.session??null);case`entries`:return wh(e,t.entries);case`session`:return jh(e,t.session);case`local_prompt`:return Nh(e,t);case`local_prompt_failed`:return Ph(e,t.requestId);case`local_permission`:return xh(e,t.requestId,t.behavior,`local`);case`local_system`:{let n={kind:`system`,id:`sys:${e.nextId}`,uuid:null,parentToolUseId:null,turnId:null,timestamp:null,subtype:t.subtype,text:t.text};return Vh({...e,nextId:e.nextId+1},n)}case`model_picked`:return Rm(e,{type:`model_change`});case`reset`:return Pm(e.sessionId)}}function Rm(e,t){let n=Nf(e.safeguardFallback,t);return n===e.safeguardFallback?e:{...e,safeguardFallback:n}}function zm(e){return/^Set model to\s/.test(e)}function Bm(e,t,n){let r=n.uuid?`sys:${n.uuid}`:`sys:${e.nextId}`;if(e.index.get(r)!==void 0)return e;let i=e;if(t.retractedUuids.length>0){let e=new Set(t.retractedUuids),n=new Set(i.items.filter(t=>t.uuid!==null&&e.has(t.uuid)).map(e=>e.id));n.size>0&&(i=Uh(i,n))}let a={kind:`system`,id:r,uuid:n.uuid,parentToolUseId:n.parentToolUseId,turnId:n.turnId,timestamp:n.timestamp,subtype:t.kind===`fallback`?Mm:Nm,text:t.text,refusal:t,...t.kind===`no_fallback`?{refusalBefore:i.safeguardFallback?.notice??null}:{}};if(i=Vh(n.uuid?i:Kh(i),a),n.parentToolUseId!==null)return i;let o=n.timestamp?Date.parse(n.timestamp):NaN;return Rm(i,{type:`notice`,notice:t,at:Number.isFinite(o)?o:null,live:n.live})}function Vm(e,t,n){let r=Km(e,t,n);if(n===void 0||!Um(t,e,r))return r;let i=r.lastFrameAt;return i!==null&&n>=i&&n-i<1e3?r:{...r,lastFrameAt:n}}function Hm(e){return e===`running`||e===`waiting_permission`}function Um(e,t,n){switch(e.type){case`agent`:return e.seq===null?e.message.type!==`system`||e.message.subtype!==`local_command`:!1;case`turn_started`:case`turn_finished`:case`prompt_delivered`:case`subagent_activity`:return!0;case`permission_request`:return n!==t;case`permission_resolved`:return!0;default:return!1}}function Wm(e){if(e.lastFrameAt!==null||!e.hydrated||!Hm(e.status))return e;let t=e.engineSince??0;for(let n=e.items.length-1;n>=0;n--){let r=e.items[n].timestamp,i=r?Date.parse(r):NaN;if(Number.isFinite(i)){i>t&&(t=i);break}}for(let n of Object.values(e.agentActivity))n.at>t&&(t=n.at);return t>0?{...e,lastFrameAt:t}:e}function Gm(e,t,n){return t!==null||n===void 0||typeof e.timestamp==`string`?e:{...e,timestamp:new Date(n).toISOString()}}function Km(e,t,n){switch(t.type){case`agent`:{if(t.seq!==null&&e.seen.has(`seq:${t.seq}`))return e;let r=qm(e,Gm(t.message,t.seq,n),{turnId:t.turnId,receivedAt:n,live:t.seq===null});return t.seq!==null&&(r=Gh(r,`seq:${t.seq}`),(r.lastSeq===null||t.seq>r.lastSeq)&&(r={...r,lastSeq:t.seq})),r}case`turn_started`:{let n=`turnstart:${t.turnId}`;if(e.seen.has(n))return e;let r=Gh(e,n);if(r={...r,activeTurnId:t.turnId,status:`running`,statusText:null,turnCachedTokens:0},t.requestId){let e=r.items.findIndex(e=>e.kind===`user`&&e.requestId===t.requestId);if(e>=0){let n={...r.items[e],turnId:t.turnId,waiting:!1};r=e<r.items.length-1?Vh(Uh(r,new Set([n.id])),n):Hh(r,e,n)}}return r}case`turn_finished`:return gh(e,t.result,t.turnId);case`prompt_delivered`:return fh(e,t.text,t.deliveredAt,t.requestId);case`prompt_cancelled`:{let n=e.items.filter(e=>e.kind===`user`&&!e.failed&&(e.requestId===t.requestId||(e.waiting||e.optimistic)&&e.deliveredAt===null&&e.text===t.text));return Uh(e,new Set(n.map(e=>e.id)))}case`subagent_activity`:return Fm(e,{agentId:t.agentId,subpath:t.subpath,at:Date.parse(t.at)||Date.now(),finished:t.finished,toolUses:t.toolUses});case`permission_request`:return bh(e,t.request,t.turnId,t.settled===!0);case`permission_resolved`:return xh(e,t.requestId,t.behavior,t.resolvedBy);case`session_state`:{let n=t.session;return jh((n.status===`idle`||n.status===`error`)&&e.pendingPermissions.length===0&&e.activeTurnId!==null?{...e,activeTurnId:null}:e,n)}case`error`:{if(t.code===`replay_truncated`||t.code===`replay_windowed`)return e;let r={kind:`error`,id:`err:${e.nextId}`,uuid:null,parentToolUseId:null,turnId:e.activeTurnId,timestamp:n===void 0?null:new Date(n).toISOString(),code:t.code,message:t.message,requestId:t.requestId??null};return Vh({...e,nextId:e.nextId+1},r)}default:return e}}function qm(e,t,n){let r=typeof t.uuid==`string`?t.uuid:null,i=t.type===`stream_event`||t.type===`tool_progress`,a=r&&!i?`uuid:${r}`:null;if(i&&r!==null&&r===e.lastLiveUuid)return e;if(a&&e.seen.has(a))return t.type===`assistant`?Qm(e,t):e;let o=e;switch(t.type){case`system`:o=Jm(e,t,n);break;case`stream_event`:o=Ym(e,t,n);break;case`assistant`:o=Zm(e,t,n);break;case`user`:o=sh(e,t,n);break;case`result`:o=hh(e,t,n);break;case`tool_progress`:o=vh(e,t);break;case`auth_status`:o=yh(e,t,n);break;default:return e}return a?o=Gh(o,a):i&&r!==null&&(o={...o,lastLiveUuid:r}),o}function Jm(e,t,n){switch(t.subtype){case`init`:{let r={model:Zh(t.model),cwd:Zh(t.cwd),tools:Array.isArray(t.tools)?t.tools.filter(e=>typeof e==`string`):[],permissionMode:Zh(t.permissionMode),claudeCodeVersion:Zh(t.claude_code_version),apiKeySource:Zh(t.apiKeySource),sessionId:Zh(t.session_id),mcpServers:Array.isArray(t.mcp_servers)?t.mcp_servers:[]};return{...e,init:r,engineSince:n.receivedAt??Date.now()}}case Of:case kf:{let r=Mf(t);return r?Bm(e,r,{uuid:Jh(t),parentToolUseId:Yh(t),turnId:n.turnId??e.activeTurnId,timestamp:Xh(t),live:n.live===!0}):e}case`compact_boundary`:{let r=t.compact_metadata??{},i={kind:`compact`,id:qh(e,`compact`,t),uuid:Jh(t),parentToolUseId:Yh(t),turnId:n.turnId,timestamp:Xh(t),trigger:r.trigger===`manual`?`manual`:`auto`,preTokens:typeof r.pre_tokens==`number`?r.pre_tokens:0,postTokens:typeof r.post_tokens==`number`?r.post_tokens:null};return Vh(Kh(e),i)}case`status`:{let n=typeof t.status==`string`?t.status:null;return{...e,statusText:n}}case`task_notification`:{let r=_e({taskId:Zh(t.task_id)||null,toolUseId:Zh(t.tool_use_id)||null,status:Zh(t.status)||null,summary:Zh(t.summary)||null});if(Lh(e,r))return e;let i=Jh(t),a={kind:`user`,id:i?`u:${i}`:`i${e.nextId}`,uuid:i,parentToolUseId:Yh(t),turnId:n.turnId,timestamp:Xh(t),text:r,attachments:[],requestId:null,optimistic:!1,failed:!1,waiting:!1,deliveredAt:null,compactSummary:!1,taskNotification:!0,engineNote:!1};return e.index.get(a.id)===void 0?Vh(i?e:Kh(e),a):e}case`permission_denied`:{let n=Zh(t.tool_use_id),r=Zh(t.message);return Wh(e,n,e=>{let t=e.name===`AskUserQuestion`&&r===`the user skipped the question`;return{...e,status:t?`skipped`:`denied`,result:e.result??{content:r||`Permission denied`,isError:!t,structured:null}}})}case`rewind_boundary`:{let n={kind:`system`,id:`sys:${e.nextId}`,uuid:Jh(t),parentToolUseId:Yh(t),turnId:e.activeTurnId,timestamp:Xh(t),subtype:`rewind`,text:typeof t.content==`string`&&t.content.trim()?t.content.trim():`Rewound here — the conversation was taken back to this point and continued differently.`};return Vh({...e,nextId:e.nextId+1},n)}default:{let n=typeof t.content==`string`?t.content.trim():``,r=n?rh(n):null;if(!r||r.subtype===`caveat`)return e;let i=r.subtype===`local-command`?oh(n):null,a=r.subtype===`local-command`&&!i?ap(n):null,o={kind:`system`,id:`sys:${e.nextId}`,uuid:Jh(t),parentToolUseId:Yh(t),turnId:e.activeTurnId,timestamp:Xh(t),subtype:i?`chat-notice`:a?jm:r.subtype,text:r.text,...i?{chatMarker:i}:{},...a?{newChat:a}:{}},s=Vh({...e,nextId:e.nextId+1},o);return r.subtype===`local-command`&&zm(r.text)?Rm(s,{type:`model_change`}):s}}}function Ym(e,t,n){let r=t.event;if(!r||typeof r!=`object`)return e;let i=Yh(t),a=i??``,o=e.streams[a]??{messageId:null,model:null,blocks:{},unclaimed:[]};switch(r.type){case`message_start`:{let t=r.message,n={messageId:t?.id??null,model:t?.model??null,blocks:{},unclaimed:[]},i=e;for(let e of o.unclaimed)i=Xm(i,e);return{...i,streams:{...i.streams,[a]:n}}}case`content_block_start`:{let s=r.content_block,c=e,l;if(s.type===`text`)l={kind:`assistant`,id:`i${e.nextId}`,uuid:null,parentToolUseId:i,turnId:n.turnId,timestamp:Xh(t),text:s.text??``,streaming:!0,model:o.model,messageId:o.messageId,error:null,aborted:!1},c=Kh(c);else if(s.type===`thinking`||s.type===`redacted_thinking`)l={kind:`thinking`,id:`i${e.nextId}`,uuid:null,parentToolUseId:i,turnId:n.turnId,timestamp:Xh(t),text:s.type===`thinking`?s.thinking??``:``,streaming:!0,redacted:s.type===`redacted_thinking`},c=Kh(c);else if(s.type===`tool_use`){let c=s;if(e.index.get(c.id)!==void 0){let t={...o.blocks,[r.index]:c.id};return{...e,streams:{...e.streams,[a]:{...o,blocks:t}}}}let u=c.input&&Object.keys(c.input).length>0;l={kind:`tool`,id:c.id,uuid:null,parentToolUseId:i,turnId:n.turnId,timestamp:Xh(t),toolUseId:c.id,name:c.name,input:u?c.input:null,inputJson:u?JSON.stringify(c.input):``,status:`streaming`,result:null,startedAt:n.receivedAt??null,finishedAt:null,durationMs:null,elapsedSec:null,permissionRequestId:null,messageId:o.messageId}}else return e;c=Vh(c,l);let u={...o.blocks,[r.index]:l.id},d=[...o.unclaimed,l.id];return{...c,streams:{...c.streams,[a]:{...o,blocks:u,unclaimed:d}}}}case`content_block_delta`:{let t=o.blocks[r.index];if(!t)return e;let n=e.index.get(t);if(n===void 0)return e;let i=e.items[n],a=r.delta;return a.type===`text_delta`&&i.kind===`assistant`?Hh(e,n,{...i,text:i.text+a.text}):a.type===`thinking_delta`&&i.kind===`thinking`?Hh(e,n,{...i,text:i.text+a.thinking}):a.type===`input_json_delta`&&i.kind===`tool`?Hh(e,n,{...i,inputJson:i.inputJson+a.partial_json}):e}case`content_block_stop`:{let t=o.blocks[r.index];return t?Xm(e,t,n.receivedAt):e}case`message_delta`:case`message_stop`:case`ping`:return e;case`error`:{let a={kind:`error`,id:`err:${e.nextId}`,uuid:null,parentToolUseId:i,turnId:n.turnId,timestamp:Xh(t),code:r.error?.type??`stream_error`,message:r.error?.message??`stream error`,requestId:null};return Vh(Kh(e),a)}default:return e}}function Xm(e,t,n){let r=e.index.get(t);if(r===void 0)return e;let i=e.items[r];if(i.kind===`assistant`||i.kind===`thinking`)return i.streaming?Hh(e,r,{...i,streaming:!1}):e;if(i.kind===`tool`&&i.status===`streaming`){let t=i.input??tg(i.inputJson);return Hh(e,r,{...i,input:t,status:`running`,startedAt:i.startedAt??n??null})}return e}function Zm(e,t,n){let r=t.local_command_source;if(typeof r==`string`){let i=rh(r.trim());if(i&&(i.subtype===`local-command`||i.subtype===`local-command-error`)){let r={kind:`system`,id:`sys:${e.nextId}`,uuid:Jh(t),parentToolUseId:Yh(t),turnId:n.turnId??e.activeTurnId,timestamp:Xh(t),subtype:i.subtype,text:i.text},a=Vh({...e,nextId:e.nextId+1},r);return i.subtype===`local-command`&&zm(i.text)?Rm(a,{type:`model_change`}):a}}let i=t.message??{},a=$h(i.content),o=Yh(t),s=o??``,c=Jh(t),l=Xh(t),u=typeof t.error==`string`?t.error:null,d=t.aborted===!0,f=e;{let e=Qh(i.usage?.cache_read_input_tokens)+Qh(i.usage?.cache_creation_input_tokens),n=`usage:${i.id??``}`;if(e>0&&i.id&&!f.seen.has(n)&&(f={...Gh(f,n),turnCachedTokens:f.turnCachedTokens+e}),o===null&&t.isSidechain!==!0){let t=Qh(i.usage?.input_tokens)+e+Qh(i.usage?.output_tokens);t>0&&t!==f.contextTokens&&(f={...f,contextTokens:t})}}let p=f.streams[s];for(let e of a){let t=p?$m(f,p,e):null;if(t){let n=f.index.get(t),r=f.items[n];f=Hh(f,n,eh(r,e,{uuid:c,timestamp:l,model:i.model??null,messageId:i.id??null,errorText:u,aborted:d})),p={...p,unclaimed:p.unclaimed.filter(e=>e!==t)},f={...f,streams:{...f.streams,[s]:p}};continue}let r=th(f,e,{uuid:c,timestamp:l,parentToolUseId:o,turnId:n.turnId,model:i.model??null,messageId:i.id??null,errorText:u,aborted:d,receivedAt:n.receivedAt});r&&(f=r)}if(a.length===0&&u){let e={kind:`error`,id:`err:${f.nextId}`,uuid:c,parentToolUseId:o,turnId:n.turnId,timestamp:l,code:`assistant_error`,message:u,requestId:null};f=Vh(Kh(f),e)}return f}function Qm(e,t){let n=Yh(t)??``,r=e.streams[n];if(!r||r.unclaimed.length===0)return e;let i=t.message??{},a=new Set,o=e,s=r;for(let e of $h(i.content)){let t=$m(o,s,e);t&&(a.add(t),s={...s,unclaimed:s.unclaimed.filter(e=>e!==t)},o={...o,streams:{...o.streams,[n]:s}})}return Uh(e,a)}function $m(e,t,n){for(let r of t.unclaimed){let t=e.index.get(r);if(t===void 0)continue;let i=e.items[t];if(!i.uuid&&(n.type===`text`&&i.kind===`assistant`||(n.type===`thinking`||n.type===`redacted_thinking`)&&i.kind===`thinking`||n.type===`tool_use`&&i.kind===`tool`&&i.toolUseId===n.id))return r}return null}function eh(e,t,n){if(e.kind===`assistant`&&t.type===`text`){let r=t.text??e.text;return{...e,uuid:n.uuid,timestamp:n.timestamp??e.timestamp,text:r.length>=e.text.length?r:e.text,streaming:!1,model:n.model??e.model,messageId:n.messageId??e.messageId,error:n.errorText,aborted:n.aborted}}if(e.kind===`thinking`){let r=t.type===`thinking`?t.thinking??e.text:e.text;return{...e,uuid:n.uuid,timestamp:n.timestamp??e.timestamp,text:r||e.text,streaming:!1}}if(e.kind===`tool`&&t.type===`tool_use`){let r=t,i=r.input&&Object.keys(r.input).length>0?r.input:e.input??tg(e.inputJson);return{...e,uuid:n.uuid,timestamp:n.timestamp??e.timestamp,name:r.name??e.name,input:i,inputJson:e.inputJson||(i?JSON.stringify(i):``),status:e.status===`streaming`?`running`:e.status,messageId:n.messageId??e.messageId}}return e}function th(e,t,n){let r={uuid:n.uuid,parentToolUseId:n.parentToolUseId,turnId:n.turnId,timestamp:n.timestamp};if(t.type===`text`){let i={kind:`assistant`,id:`i${e.nextId}`,...r,text:t.text??``,streaming:!1,model:n.model,messageId:n.messageId,error:n.errorText,aborted:n.aborted};return Vh(Kh(e),i)}if(t.type===`thinking`||t.type===`redacted_thinking`){let n={kind:`thinking`,id:`i${e.nextId}`,...r,text:t.type===`thinking`?t.thinking??``:``,streaming:!1,redacted:t.type===`redacted_thinking`};return Vh(Kh(e),n)}if(t.type===`tool_use`){let i=t,a=e.index.get(i.id);if(a!==void 0){let r=e.items[a];return Hh(e,a,eh(r,t,n))}let o=i.input&&typeof i.input==`object`?i.input:null;return Vh(e,{kind:`tool`,id:i.id,...r,toolUseId:i.id,name:i.name,input:o,inputJson:o?JSON.stringify(o):``,status:`running`,result:null,startedAt:n.receivedAt??null,finishedAt:null,durationMs:null,elapsedSec:null,permissionRequestId:null,messageId:n.messageId})}return null}function nh(e){return e.trim().replace(/\s+/g,` `)}function rh(e){if(/^<local-command-caveat>/.test(e))return{subtype:`caveat`,text:``};let t=/^<local-command-(stdout|stderr)>([\s\S]*?)<\/local-command-\1>$/.exec(e);if(t){let e=t[2].replace(/\u001b\[[0-9;]*m/g,``).trim();return{subtype:t[1]===`stderr`?`local-command-error`:`local-command`,text:e}}let n=/<command-name>([^<]*)<\/command-name>/.exec(e);if(n&&/^<command-/.test(e)){let t=/<command-args>([^<]*)<\/command-args>/.exec(e)?.[1]?.trim()??``,r=n[1].trim(),i=gp(r.replace(/^\//,``));return{subtype:`command`,text:`${i===null?r:`/${i}`}${t?` `+t:``}`}}return null}function ih(e){let t=e.charCodeAt(0);return t===9993||t===8617||t===8635||t===9888}function ah(e){return ih(e)?Gl(e):[]}function oh(e){if(!e.startsWith(`<local-command-stdout>`))return null;let t=Wl(e);return t?.kind===`notice`?t:null}function sh(e,t,n){let r=t.message??{},i=Yh(t),a=Jh(t),o=Xh(t),s=t.isSynthetic===!0,c=e,l=[],u=[],d=!1;if(typeof r.content==`string`)l.push(r.content);else for(let e of $h(r.content))if(e.type===`text`)l.push(e.text??``);else if(e.type===`tool_result`){d=!0;let r=e;c=ph(c,r.tool_use_id,{content:r.content??``,isError:r.is_error===!0,structured:t.tool_use_result??null},n.receivedAt)}else(e.type===`image`||e.type===`document`)&&u.push(e);let f=de(l.join(`
|
|
96
|
+
`)}var Gp=/^[A-Za-z0-9][\w.:@+\-/]*(?:\[[0-9a-z]+\])?$/;function Kp(e){return e.length>0&&e.length<=200&&Gp.test(e)&&!e.endsWith(`/`)&&!e.includes(`//`)}function qp(e){let t=/^\/setcustommodel(?:\s+([\s\S]*))?$/i.exec(e.trim());if(!t)return null;let n=(t[1]??``).trim();return n===``||n.toLowerCase()===`off`?{kind:`off`}:/\s/.test(n)?{kind:`invalid`,reason:`one model id, with no spaces`}:Kp(n)?{kind:`set`,model:n}:{kind:`invalid`,reason:`'${n.slice(0,60)}' is not a model id`}}function Jp(e){let t=e.indexOf(`/`);return t<=0||t===e.length-1?null:{prefix:e.slice(0,t).toLowerCase(),model:e.slice(t+1)}}function Yp(e,t,n){let r={providerId:t.providerId,variantId:t.variantId??null},i=Jp(e);return!i||!n.includes(i.prefix)?{...r,model:e}:i.prefix===t.providerId?{...r,model:i.model}:t.providerId===`oonacode`?{...r,model:e}:{providerId:i.prefix,variantId:null,model:i.model}}function Xp(e,t){let n=t.variantId??null;if(t.providerId===`oonacode`)return{providerId:t.providerId,variantId:n,model:e};let r=Jp(e),i=r&&r.prefix===t.providerId.toLowerCase()?r.model:e;return{providerId:t.providerId,variantId:n,model:i}}function Zp(e){return`${e} (custom)`}var Qp=`google-agy`;function $p(e){return e===Qp}var em=[`build`,`auto`];function tm(e){return $p(e)?A.filter(e=>em.includes(e.id)):A}var nm=`Google’s agy cannot ask for permission while OonaCode drives it, so this chat offers Build (agy may edit files; a command it wants to run is declined and reported) and Autonomous (agy may run everything).`,rm=`Sign in on Google’s own page with your own Google account. Google then shows you a one-time code: paste it here. OonaCode never sees your password, and your sign-in stays on this PC.`;function im(e){return typeof e==`string`&&e.length>=8&&e.length<=512&&/^[A-Za-z0-9/_.~%+=-]+$/.test(e)}var am={complete:`/api/v1/account/vault/rekey-complete`,revoke:`/api/v1/account/vault/rekey-revoke`,deviceUnlock:`/api/v1/account/device-unlock`};function om(e){return e?.deviceUnlock??`off`}function sm(e){if(!e?.loggedIn)return null;let t=e;if(t.vaultStatus!==`pending_rekey`)return null;let n=t.vaultRekeyPending??null;return{pending:n,canFinishHere:t.canFinishRekey===!0,trustedDevices:n?.trustedDevices.map(e=>e.label||e.name)??[],since:n?.since??null,from:cm(n)}}function cm(e){if(!e)return null;let t=e.requestedFrom.device?.trim()||null,n=e.requestedFrom.ip?.trim()||null;return t&&n?`${t} (${n})`:t??n}function lm(e){if(!e)return`an unknown date`;let t=Date.parse(e);if(Number.isNaN(t))return`an unknown date`;try{return new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}catch{return new Date(t).toISOString()}}function um(e){let t=e.from?` from ${e.from}`:``;return`A password reset was started on ${lm(e.since)}${t}. Your saved provider keys are still sealed under the old password.`}function dm(e){return e.trustedDevices.length===0?`No device with "keep me unlocked" is left, so nothing here holds the key from before the reset.`:`Open OonaCode on ${pm(e.trustedDevices)} to finish the reset — your saved keys are waiting there.`}var fm=`Either way, your vault Recovery Key still works: sign in on the OonaCode website from any device and finish the reset there. Discarding is the last resort — it deletes your saved provider keys and that Recovery Key for good. Your chats stay on your PCs.`;function pm(e){return e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} or ${e[e.length-1]}`}function mm(e){return e.canFinishHere?`A password reset is waiting: this PC can move your vault to the new password.`:e.trustedDevices.length>0?`A password reset is waiting — your saved keys stay locked until it is finished on ${pm(e.trustedDevices)}.`:`A password reset is waiting and no PC holds the old key — finish it with your vault Recovery Key on the OonaCode website.`}var hm=class extends Error{code;status;details;constructor(e,t,n,r){super(n),this.name=`HostApiError`,this.code=e,this.status=t,this.details=r}get isUnauthorized(){return this.status===401||this.code===`unauthorized`}get isEmailNotVerified(){return this.code===`email_not_verified`}};function gm(e){if(!e)return``;let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!=null&&r!==``&&t.set(n,String(r));let n=t.toString();return n?`?${n}`:``}function _m(e){return e.trim().replace(/\/+$/,``)}function vm(e,t){let n=_m(e.baseUrl),r=t??((e,t)=>fetch(e,t));async function i(t,i,a,o={}){let s={Authorization:`Bearer ${e.token}`,Accept:o.raw||o.bytes?`*/*`:`application/json`},c={method:t,headers:s,credentials:`omit`};o.signal&&(c.signal=o.signal),a!==void 0&&(s[`Content-Type`]=`application/json`,c.body=JSON.stringify(a));let l;try{l=await r(`${n}${i}`,c)}catch(e){throw new hm(`network`,0,`Cannot reach the host at ${n}: ${String(e?.message??e)}`)}if(!l.ok){let e=null,t=``;try{t=await l.text(),e=t?JSON.parse(t):null}catch{e=null}let n=e?.error?.code??(l.status===401?`unauthorized`:`internal`),r=e?.error?.message??(t||`${l.status} ${l.statusText}`);throw new hm(n,l.status,r,e?.error?.details)}if(o.bytes)return await l.arrayBuffer();if(o.raw)return await l.text();if(l.status===204)return;let u=await l.text();if(u)try{return JSON.parse(u)}catch{throw new hm(`parse`,l.status,`Host returned malformed JSON for ${t} ${i}`)}}let a=Ie;return{health:()=>i(a.health,z.health),info:()=>i(a.info,z.info),listSessions:e=>i(a.listSessions,`${z.sessions}${gm(e)}`),createSession:e=>i(a.createSession,z.sessions,e),getSession:e=>i(a.getSession,z.session(e)),updateSession:(e,t)=>i(a.updateSession,z.session(e),t),deleteSession:e=>i(a.deleteSession,z.session(e)),exportSessionsArchive:async t=>{let i=await r(`${n}${z.sessionsExportArchive}`,{method:`POST`,credentials:`omit`,headers:{Authorization:`Bearer ${e.token}`,Accept:`application/zip`,"Content-Type":`application/json`},body:JSON.stringify({password:t})});if(!i.ok){let e=await i.text().catch(()=>``),t=null;try{t=e?JSON.parse(e):null}catch{t=null}throw new hm(t?.error?.code??`internal`,i.status,t?.error?.message??e??`the export failed`)}return i.blob()},listEntries:(e,t)=>i(a.listEntries,`${z.sessionEntries(e)}${gm(t)}`),listMessages:e=>i(a.listMessages,z.sessionMessages(e)),prompt:(e,t)=>i(a.prompt,z.sessionPrompt(e),{...t,stream:!1}),interrupt:e=>i(a.interrupt,z.sessionInterrupt(e),{}),cancelQueued:(e,t)=>i(a.cancelQueued,z.sessionQueued(e,t)),sendQueuedNow:(e,t)=>i(a.sendQueuedNow,z.sessionQueuedNow(e,t),{}),forkSession:(e,t)=>i(a.fork,z.sessionFork(e),t??{}),exportSession:(e,t)=>i(a.export,`${z.sessionExport(e)}${gm(t)}`,void 0,{raw:!0}),listProjects:()=>i(a.listProjects,z.projects),listVaultProjects:()=>i(a.listVaultProjects,z.vaultProjects),createVaultProject:e=>i(a.createVaultProject,z.vaultProjects,e),updateVaultProject:(e,t)=>i(a.updateVaultProject,z.vaultProject(e),t),deleteVaultProject:e=>i(a.deleteVaultProject,z.vaultProject(e)),listScheduledTasks:(e={})=>{let t=new URLSearchParams;e.sessionId&&t.set(`sessionId`,e.sessionId),e.projectId&&t.set(`projectId`,e.projectId);let n=t.toString();return i(a.listScheduledTasks,n?`${z.scheduledTasks}?${n}`:z.scheduledTasks)},createScheduledTask:e=>i(a.createScheduledTask,z.scheduledTasks,e),updateScheduledTask:(e,t)=>i(a.updateScheduledTask,z.scheduledTask(e),t),deleteScheduledTask:e=>i(a.deleteScheduledTask,z.scheduledTask(e)),listConversations:(e={})=>i(a.listConversations,`${z.conversations}${gm({sessionId:e.sessionId})}`),getConversation:e=>i(a.getConversation,z.conversation(encodeURIComponent(e))),conversationAction:(e,t,n)=>i(a.conversationAction,z.conversationAction(encodeURIComponent(e),t),n??{}),stopAllConversations:()=>i(a.stopAllConversations,z.conversationsStopAll,{}),cancelChatMessage:e=>i(a.cancelChatMessage,z.chatMessage(encodeURIComponent(e))),getChatAbout:e=>i(a.getChatAbout,z.sessionAbout(encodeURIComponent(e))),updateChatAbout:(e,t)=>i(a.updateChatAbout,z.sessionAbout(encodeURIComponent(e)),t),regenerateChatAbout:e=>i(a.regenerateChatAbout,z.sessionAboutRegenerate(encodeURIComponent(e)),{}),listChatAbouts:()=>i(a.listChatAbouts,z.chatAbouts),generateAllChatAbouts:()=>i(a.generateAllChatAbouts,z.chatAboutsGenerateAll,{}),stopGenerateAllChatAbouts:()=>i(a.stopGenerateAllChatAbouts,z.chatAboutsGenerateAllStop,{}),generateChatAbouts:e=>i(a.generateChatAbouts,z.chatAboutsGenerate,e),planChatAboutTranslations:e=>i(a.planChatAboutTranslations,z.chatAboutsTranslationPlan,e),translateChatAbout:(e,t)=>i(a.translateChatAbout,z.sessionAboutTranslation(encodeURIComponent(e)),t),getAgyStatus:e=>i(`GET`,`${z.agyStatus}${gm(e?.refresh?{refresh:1}:void 0)}`),listAgyRequests:e=>i(`GET`,z.agyRequests(encodeURIComponent(e))),getAgyRequestBody:(e,t)=>i(`GET`,z.agyRequestBody(encodeURIComponent(e),encodeURIComponent(t))),agyInstall:()=>i(`POST`,z.agyInstall),cancelAgyInstall:()=>i(`DELETE`,z.agyInstall),agyLogin:()=>i(`POST`,z.agyLogin),cancelAgyLogin:()=>i(`DELETE`,z.agyLogin),submitAgyLoginCode:e=>i(`POST`,z.agyLoginCode,{code:e}),listVoiceSummaries:e=>i(a.listVoiceSummaries,z.sessionVoiceSummaries(encodeURIComponent(e))),createVoiceSummary:(e,t)=>i(a.createVoiceSummary,z.sessionVoiceSummaries(encodeURIComponent(e)),t),deleteVoiceSummary:(e,t)=>i(a.deleteVoiceSummary,z.sessionVoiceSummary(encodeURIComponent(e),encodeURIComponent(t))),translateVoiceSummary:(e,t,n)=>i(a.translateVoiceSummary,z.sessionVoiceSummaryTranslations(encodeURIComponent(e),encodeURIComponent(t)),n),getGithubLink:()=>i(a.getGithubLink,z.githubLink),searchEntries:e=>i(a.searchEntries,`${z.sessionSearch}${gm(e)}`),startGithubLink:()=>i(a.startGithubLink,z.githubLinkStart,{}),cancelGithubLink:()=>i(a.cancelGithubLink,z.githubLinkStart),unlinkGithub:()=>i(a.unlinkGithub,z.githubLink),scanClaudeSessions:()=>i(a.scanClaudeSessions,z.importClaude),importClaudeSessions:e=>i(a.importClaudeSessions,z.importClaude,e??{}),searchImportChats:(e,t)=>i(a.searchImportChats,`${z.importSearch}${gm(e)}`,void 0,t?{signal:t}:{}),sessionLink:e=>i(a.sessionLink,z.sessionLink(e)),syncSessionDown:e=>i(a.syncSessionDown,z.sessionSyncDown(e),{}),inspectProject:e=>i(a.inspectProject,`${z.projectInspect}${gm(e)}`),attachSessionProject:(e,t)=>i(a.attachSessionProject,z.sessionProject(e),t),listAgentTools:()=>i(`GET`,z.agentTools),listSessionCommands:e=>i(a.listSessionCommands,z.sessionCommands(encodeURIComponent(e))),listCommands:e=>i(a.listCommands,`${z.commands}${gm(e)}`),listSessionChatSkills:e=>i(a.listSessionChatSkills,z.sessionModelSkills(encodeURIComponent(e))),listChatSkills:e=>i(a.listChatSkills,`${z.modelSkills}${gm(e)}`),listSkills:()=>i(a.listSkills,z.skills),deleteSkill:e=>i(a.deleteSkill,z.skill(e)),scanClaudeSkills:()=>i(a.scanClaudeSkills,z.importClaudeSkills),importClaudeSkills:e=>i(a.importClaudeSkills,z.importClaudeSkills,e),listProviders:()=>i(a.listProviders,z.providers),setActiveProvider:e=>i(a.setActiveProvider,z.providersActive,e),testProvider:e=>i(a.providerTest,z.providerTest(e),{}),probeCredential:(e,t)=>i(a.providerProbe,z.providerProbe(e),t),listModels:e=>i(a.listModels,`${z.models}${gm(e)}`),getSettings:()=>i(a.getSettings,z.settings),updateSettings:e=>i(a.updateSettings,z.settings,e),getAccount:()=>i(a.getAccount,z.account),login:e=>i(a.login,z.accountLogin,e),logout:()=>i(a.logout,z.accountLogout,{}),unlock:e=>i(a.unlock,z.accountUnlock,e),lock:()=>i(`POST`,z.accountLock,{reason:`user`}),plan:()=>i(`GET`,z.accountPlan),accountUsage:e=>i(`GET`,`${z.accountUsage}${gm({...e})}`),remoteUnlockHost:(e,t)=>i(`POST`,z.hostVaultUnlock(e),{password:t}),resendVerification:e=>i(a.resendVerification,z.accountResendVerification,e),startAccountLink:e=>i(a.linkStart,z.accountLinkStart,e??{}),accountLinkStatus:()=>i(a.linkStatus,z.accountLinkStatus),cancelAccountLink:()=>i(a.linkCancel,z.accountLinkCancel,{}),completeVaultRekey:e=>i(`POST`,am.complete,e),revokeVaultRekey:e=>i(`POST`,am.revoke,e),setDeviceUnlock:e=>i(`POST`,am.deviceUnlock,e),listCredentials:()=>i(a.listCredentials,z.credentials),addCredential:e=>i(a.addCredential,z.credentials,e),deleteCredential:e=>i(a.deleteCredential,z.credential(e)),testCredential:e=>i(a.credentialTest,z.credentialTest(e),{}),syncNow:()=>i(a.syncNow,z.syncNow,{}),claudeSubscriptionLogin:()=>i(a.claudeLogin,z.subscriptionClaudeLogin,{}),claudeSubscriptionStatus:()=>i(a.claudeStatus,z.subscriptionClaudeStatus),claudeLoginState:()=>i(a.claudeLoginState,z.subscriptionClaudeLoginState),claudeLoginCode:e=>i(a.claudeLoginCode,z.subscriptionClaudeLoginCode,e),claudeLoginCancel:()=>i(a.claudeLoginCancel,z.subscriptionClaudeLoginCancel,{}),oauthLoginStart:e=>i(a.oauthLogin,z.subscriptionOauthLogin(e),{}),oauthLoginState:e=>i(a.oauthLoginState,z.subscriptionOauthLoginState(e)),oauthLoginCancel:e=>i(a.oauthLoginCancel,z.subscriptionOauthLoginCancel(e),{}),doctor:()=>i(a.doctor,z.doctor),listHosts:()=>i(a.listHosts,z.hosts),listHostSessions:e=>i(a.listHostSessions,z.hostSessions(e)),deleteHostSession:(e,t)=>i(a.deleteHostSession,z.hostSession(e,t),{method:`DELETE`}),updateHost:(e,t)=>i(a.updateHost,z.host(e),t),listHostSessionEntries:(e,t,n)=>i(a.listHostSessionEntries,`${z.hostSessionEntries(e,t)}${gm(n)}`),reportError:e=>i(a.errorReport,z.errorReport,e),sendBugReport:e=>i(a.bugReport,z.bugReport,e),listSessionFiles:(e,t)=>i(a.listSessionFiles,`${z.sessionFiles(e)}${gm({path:t})}`),readSessionFile:(e,t)=>i(a.readSessionFile,`${z.sessionFile(e)}${gm({path:t})}`,void 0,{raw:!0}),readSessionFileBytes:(e,t)=>i(a.readSessionFile,`${z.sessionFile(e)}${gm({path:t})}`,void 0,{bytes:!0}),deleteSessionFile:(e,t)=>i(a.deleteSessionFile,`${z.sessionFile(e)}${gm({path:t})}`),grantLocalFile:async(e,t)=>{let r=await i(a.grantLocalFile,z.sessionLocalFileGrant(e),{path:t});return{...r,url:/^https?:/i.test(r.url)?r.url:`${n}${r.url}`}},statLocalPaths:(e,t)=>i(a.statLocalPaths,z.sessionLocalFileStat(e),{paths:t})}}function ym(e){return e instanceof hm&&(e.status===404||e.status===501)}var bm=120;function xm(){return bm}function Sm(e){let t=e.batchMs??120,n=e.hiddenBatchMs??1e3,r=e.isHidden??(()=>!1),i=e.now??(()=>Date.now()),a=e.setTimeout??((e,t)=>setTimeout(e,t)),o=e.clearTimeout??(e=>clearTimeout(e)),s=[],c=null,l=-1/0,u=!1,d=()=>{if(c!==null&&(o(c),c=null),s.length===0)return;let t=s;s=[],l=i(),e.deliver(t)};return{push(o){if(u)return;if(s.push(o),!e.isStreamFrame(o)){d();return}let f=r()?n:t;if(f<=0){d();return}if(c!==null)return;let p=i()-l;if(p>=f){d();return}c=a(()=>{c=null,d()},f-p)},flush:d,dispose(){u=!0,c!==null&&o(c),c=null,s=[]}}}function Cm(e,t,n){if((t.providerId??``)!==e.providerId||e.variantId!==void 0&&(t.variantId??null)!==(e.variantId??null)||!t.model)return!1;let r=zs(t.model),i=zs(e.model);if(r===i)return!0;let a=n.find(t=>t.definition.id===e.providerId)?.definition;return a!==void 0&&Fs(a,i)===r}function wm(e){return e instanceof hm&&e.code===`email_not_verified`}function Tm(e){if(!wm(e))return null;let t={error:{code:e.code,message:e.message,details:e.details}};return k(t)?t.error.details:null}function Em(e){let t=e.trim(),n=t.indexOf(`@`);return n<=0?`***`:`${t.slice(0,1)}***${t.slice(n)}`}function Dm(e,t){return e===void 0||!Number.isFinite(e)||e<=0?t:t+Math.ceil(e)*1e3}function Om(e,t){return Math.max(0,Math.ceil((e.resendAt-t)/1e3))}function km(e,t){if(!wm(e))return null;let n=t.now??Date.now(),r=Tm(e),i=t.email.trim();return{email:i,displayEmail:r?.email||Em(i),verification:r?.verification??`pending`,registered:t.registered===!0,resendAt:Dm(r?.resendAfterSec,n)}}function Am(e){let t=e.registered?`Account created. `:``;return e.verification===`unverified`?`${t}Confirm your email first — no link is outstanding for ${e.displayEmail}; send a new one.`:`${t}Confirm your email first — we sent a link to ${e.displayEmail}.`}var jm=`new-chat`,Mm=`safeguard-fallback`,Nm=`safeguard-no-fallback`;function Pm(e=null){return{sessionId:e,session:null,items:[],index:new Map,status:`idle`,activeTurnId:null,init:null,statusText:null,pendingPermissions:[],lastSeq:null,totals:{costUsd:0,inputTokens:0,cachedInputTokens:0,outputTokens:0,turns:0},turnCachedTokens:0,contextTokens:null,hydrated:!1,agentActivity:{},hasSubagentItems:!1,hasOptimisticUser:!1,lastLocalPromptId:null,lastFrameAt:null,lastLiveUuid:null,engineSince:null,safeguardFallback:null,subpathParents:{},seen:new Set,streams:{},nextId:1}}function Fm(e,t){let n=e.agentActivity[t.agentId],r={subpath:t.subpath,firstAt:n?Math.min(n.firstAt,t.at):t.at,at:n?Math.max(n.at,t.at):t.at,finished:t.finished,toolUses:(n?.toolUses??0)+t.toolUses};return{...e,agentActivity:{...e.agentActivity,[t.agentId]:r}}}function Im(e,t,n,r,i,a){let o=Eh.exec(t)?.[2];if(!o)return e;let s=i&&Date.parse(i)||0;if(n!==`assistant`)return Fm(e,{agentId:o,subpath:t,at:s,finished:e.agentActivity[o]?.finished??!1,toolUses:0});let c=(Array.isArray(r)?r:[]).filter(e=>e.type===`tool_use`),l=c.length===0;return typeof a==`string`&&(l=a===`end_turn`||a===`stop_sequence`),c.some(e=>e.name===`StructuredOutput`)&&(l=!0),Fm(e,{agentId:o,subpath:t,at:s,finished:l,toolUses:c.length})}function Lm(e,t){switch(t.type){case`frame`:return Vm(e,t.frame,t.receivedAt);case`hydrate`:return Sh(e,t.messages,t.session??null);case`entries`:return wh(e,t.entries);case`session`:return jh(e,t.session);case`local_prompt`:return Nh(e,t);case`local_prompt_failed`:return Ph(e,t.requestId);case`local_permission`:return xh(e,t.requestId,t.behavior,`local`);case`local_system`:{let n={kind:`system`,id:`sys:${e.nextId}`,uuid:null,parentToolUseId:null,turnId:null,timestamp:null,subtype:t.subtype,text:t.text};return Vh({...e,nextId:e.nextId+1},n)}case`model_picked`:return Rm(e,{type:`model_change`});case`reset`:return Pm(e.sessionId)}}function Rm(e,t){let n=Nf(e.safeguardFallback,t);return n===e.safeguardFallback?e:{...e,safeguardFallback:n}}function zm(e){return/^Set model to\s/.test(e)}function Bm(e,t,n){let r=n.uuid?`sys:${n.uuid}`:`sys:${e.nextId}`;if(e.index.get(r)!==void 0)return e;let i=e;if(t.retractedUuids.length>0){let e=new Set(t.retractedUuids),n=new Set(i.items.filter(t=>t.uuid!==null&&e.has(t.uuid)).map(e=>e.id));n.size>0&&(i=Uh(i,n))}let a={kind:`system`,id:r,uuid:n.uuid,parentToolUseId:n.parentToolUseId,turnId:n.turnId,timestamp:n.timestamp,subtype:t.kind===`fallback`?Mm:Nm,text:t.text,refusal:t,...t.kind===`no_fallback`?{refusalBefore:i.safeguardFallback?.notice??null}:{}};if(i=Vh(n.uuid?i:Kh(i),a),n.parentToolUseId!==null)return i;let o=n.timestamp?Date.parse(n.timestamp):NaN;return Rm(i,{type:`notice`,notice:t,at:Number.isFinite(o)?o:null,live:n.live})}function Vm(e,t,n){let r=Km(e,t,n);if(n===void 0||!Um(t,e,r))return r;let i=r.lastFrameAt;return i!==null&&n>=i&&n-i<1e3?r:{...r,lastFrameAt:n}}function Hm(e){return e===`running`||e===`waiting_permission`}function Um(e,t,n){switch(e.type){case`agent`:return e.seq===null?e.message.type!==`system`||e.message.subtype!==`local_command`:!1;case`turn_started`:case`turn_finished`:case`prompt_delivered`:case`subagent_activity`:return!0;case`permission_request`:return n!==t;case`permission_resolved`:return!0;default:return!1}}function Wm(e){if(e.lastFrameAt!==null||!e.hydrated||!Hm(e.status))return e;let t=e.engineSince??0;for(let n=e.items.length-1;n>=0;n--){let r=e.items[n].timestamp,i=r?Date.parse(r):NaN;if(Number.isFinite(i)){i>t&&(t=i);break}}for(let n of Object.values(e.agentActivity))n.at>t&&(t=n.at);return t>0?{...e,lastFrameAt:t}:e}function Gm(e,t,n){return t!==null||n===void 0||typeof e.timestamp==`string`?e:{...e,timestamp:new Date(n).toISOString()}}function Km(e,t,n){switch(t.type){case`agent`:{if(t.seq!==null&&e.seen.has(`seq:${t.seq}`))return e;let r=qm(e,Gm(t.message,t.seq,n),{turnId:t.turnId,receivedAt:n,live:t.seq===null});return t.seq!==null&&(r=Gh(r,`seq:${t.seq}`),(r.lastSeq===null||t.seq>r.lastSeq)&&(r={...r,lastSeq:t.seq})),r}case`turn_started`:{let n=`turnstart:${t.turnId}`;if(e.seen.has(n))return e;let r=Gh(e,n);if(r={...r,activeTurnId:t.turnId,status:`running`,statusText:null,turnCachedTokens:0},t.requestId){let e=r.items.findIndex(e=>e.kind===`user`&&e.requestId===t.requestId);if(e>=0){let n={...r.items[e],turnId:t.turnId,waiting:!1};r=e<r.items.length-1?Vh(Uh(r,new Set([n.id])),n):Hh(r,e,n)}}return r}case`turn_finished`:return gh(e,t.result,t.turnId,t.waitingRequestIds);case`prompt_delivered`:return fh(e,t.text,t.deliveredAt,t.requestId);case`prompt_cancelled`:{let n=e.items.filter(e=>e.kind===`user`&&!e.failed&&(e.requestId===t.requestId||(e.waiting||e.optimistic)&&e.deliveredAt===null&&e.text===t.text));return Uh(e,new Set(n.map(e=>e.id)))}case`subagent_activity`:return Fm(e,{agentId:t.agentId,subpath:t.subpath,at:Date.parse(t.at)||Date.now(),finished:t.finished,toolUses:t.toolUses});case`permission_request`:return bh(e,t.request,t.turnId,t.settled===!0);case`permission_resolved`:return xh(e,t.requestId,t.behavior,t.resolvedBy);case`session_state`:{let n=t.session;return jh((n.status===`idle`||n.status===`error`)&&e.pendingPermissions.length===0&&e.activeTurnId!==null?{...e,activeTurnId:null}:e,n)}case`error`:{if(t.code===`replay_truncated`||t.code===`replay_windowed`)return e;let r={kind:`error`,id:`err:${e.nextId}`,uuid:null,parentToolUseId:null,turnId:e.activeTurnId,timestamp:n===void 0?null:new Date(n).toISOString(),code:t.code,message:t.message,requestId:t.requestId??null};return Vh({...e,nextId:e.nextId+1},r)}default:return e}}function qm(e,t,n){let r=typeof t.uuid==`string`?t.uuid:null,i=t.type===`stream_event`||t.type===`tool_progress`,a=r&&!i?`uuid:${r}`:null;if(i&&r!==null&&r===e.lastLiveUuid)return e;if(a&&e.seen.has(a))return t.type===`assistant`?Qm(e,t):e;let o=e;switch(t.type){case`system`:o=Jm(e,t,n);break;case`stream_event`:o=Ym(e,t,n);break;case`assistant`:o=Zm(e,t,n);break;case`user`:o=sh(e,t,n);break;case`result`:o=hh(e,t,n);break;case`tool_progress`:o=vh(e,t);break;case`auth_status`:o=yh(e,t,n);break;default:return e}return a?o=Gh(o,a):i&&r!==null&&(o={...o,lastLiveUuid:r}),o}function Jm(e,t,n){switch(t.subtype){case`init`:{let r={model:Zh(t.model),cwd:Zh(t.cwd),tools:Array.isArray(t.tools)?t.tools.filter(e=>typeof e==`string`):[],permissionMode:Zh(t.permissionMode),claudeCodeVersion:Zh(t.claude_code_version),apiKeySource:Zh(t.apiKeySource),sessionId:Zh(t.session_id),mcpServers:Array.isArray(t.mcp_servers)?t.mcp_servers:[]};return{...e,init:r,engineSince:n.receivedAt??Date.now()}}case Of:case kf:{let r=Mf(t);return r?Bm(e,r,{uuid:Jh(t),parentToolUseId:Yh(t),turnId:n.turnId??e.activeTurnId,timestamp:Xh(t),live:n.live===!0}):e}case`compact_boundary`:{let r=t.compact_metadata??{},i={kind:`compact`,id:qh(e,`compact`,t),uuid:Jh(t),parentToolUseId:Yh(t),turnId:n.turnId,timestamp:Xh(t),trigger:r.trigger===`manual`?`manual`:`auto`,preTokens:typeof r.pre_tokens==`number`?r.pre_tokens:0,postTokens:typeof r.post_tokens==`number`?r.post_tokens:null};return Vh(Kh(e),i)}case`status`:{let n=typeof t.status==`string`?t.status:null;return{...e,statusText:n}}case`task_notification`:{let r=_e({taskId:Zh(t.task_id)||null,toolUseId:Zh(t.tool_use_id)||null,status:Zh(t.status)||null,summary:Zh(t.summary)||null});if(Lh(e,r))return e;let i=Jh(t),a={kind:`user`,id:i?`u:${i}`:`i${e.nextId}`,uuid:i,parentToolUseId:Yh(t),turnId:n.turnId,timestamp:Xh(t),text:r,attachments:[],requestId:null,optimistic:!1,failed:!1,waiting:!1,deliveredAt:null,compactSummary:!1,taskNotification:!0,engineNote:!1};return e.index.get(a.id)===void 0?Vh(i?e:Kh(e),a):e}case`permission_denied`:{let n=Zh(t.tool_use_id),r=Zh(t.message);return Wh(e,n,e=>{let t=e.name===`AskUserQuestion`&&r===`the user skipped the question`;return{...e,status:t?`skipped`:`denied`,result:e.result??{content:r||`Permission denied`,isError:!t,structured:null}}})}case`rewind_boundary`:{let n={kind:`system`,id:`sys:${e.nextId}`,uuid:Jh(t),parentToolUseId:Yh(t),turnId:e.activeTurnId,timestamp:Xh(t),subtype:`rewind`,text:typeof t.content==`string`&&t.content.trim()?t.content.trim():`Rewound here — the conversation was taken back to this point and continued differently.`};return Vh({...e,nextId:e.nextId+1},n)}default:{let n=typeof t.content==`string`?t.content.trim():``,r=n?rh(n):null;if(!r||r.subtype===`caveat`)return e;let i=r.subtype===`local-command`?oh(n):null,a=r.subtype===`local-command`&&!i?ap(n):null,o={kind:`system`,id:`sys:${e.nextId}`,uuid:Jh(t),parentToolUseId:Yh(t),turnId:e.activeTurnId,timestamp:Xh(t),subtype:i?`chat-notice`:a?jm:r.subtype,text:r.text,...i?{chatMarker:i}:{},...a?{newChat:a}:{}},s=Vh({...e,nextId:e.nextId+1},o);return r.subtype===`local-command`&&zm(r.text)?Rm(s,{type:`model_change`}):s}}}function Ym(e,t,n){let r=t.event;if(!r||typeof r!=`object`)return e;let i=Yh(t),a=i??``,o=e.streams[a]??{messageId:null,model:null,blocks:{},unclaimed:[]};switch(r.type){case`message_start`:{let t=r.message,n={messageId:t?.id??null,model:t?.model??null,blocks:{},unclaimed:[]},i=e;for(let e of o.unclaimed)i=Xm(i,e);return{...i,streams:{...i.streams,[a]:n}}}case`content_block_start`:{let s=r.content_block,c=e,l;if(s.type===`text`)l={kind:`assistant`,id:`i${e.nextId}`,uuid:null,parentToolUseId:i,turnId:n.turnId,timestamp:Xh(t),text:s.text??``,streaming:!0,model:o.model,messageId:o.messageId,error:null,aborted:!1},c=Kh(c);else if(s.type===`thinking`||s.type===`redacted_thinking`)l={kind:`thinking`,id:`i${e.nextId}`,uuid:null,parentToolUseId:i,turnId:n.turnId,timestamp:Xh(t),text:s.type===`thinking`?s.thinking??``:``,streaming:!0,redacted:s.type===`redacted_thinking`},c=Kh(c);else if(s.type===`tool_use`){let c=s;if(e.index.get(c.id)!==void 0){let t={...o.blocks,[r.index]:c.id};return{...e,streams:{...e.streams,[a]:{...o,blocks:t}}}}let u=c.input&&Object.keys(c.input).length>0;l={kind:`tool`,id:c.id,uuid:null,parentToolUseId:i,turnId:n.turnId,timestamp:Xh(t),toolUseId:c.id,name:c.name,input:u?c.input:null,inputJson:u?JSON.stringify(c.input):``,status:`streaming`,result:null,startedAt:n.receivedAt??null,finishedAt:null,durationMs:null,elapsedSec:null,permissionRequestId:null,messageId:o.messageId}}else return e;c=Vh(c,l);let u={...o.blocks,[r.index]:l.id},d=[...o.unclaimed,l.id];return{...c,streams:{...c.streams,[a]:{...o,blocks:u,unclaimed:d}}}}case`content_block_delta`:{let t=o.blocks[r.index];if(!t)return e;let n=e.index.get(t);if(n===void 0)return e;let i=e.items[n],a=r.delta;return a.type===`text_delta`&&i.kind===`assistant`?Hh(e,n,{...i,text:i.text+a.text}):a.type===`thinking_delta`&&i.kind===`thinking`?Hh(e,n,{...i,text:i.text+a.thinking}):a.type===`input_json_delta`&&i.kind===`tool`?Hh(e,n,{...i,inputJson:i.inputJson+a.partial_json}):e}case`content_block_stop`:{let t=o.blocks[r.index];return t?Xm(e,t,n.receivedAt):e}case`message_delta`:case`message_stop`:case`ping`:return e;case`error`:{let a={kind:`error`,id:`err:${e.nextId}`,uuid:null,parentToolUseId:i,turnId:n.turnId,timestamp:Xh(t),code:r.error?.type??`stream_error`,message:r.error?.message??`stream error`,requestId:null};return Vh(Kh(e),a)}default:return e}}function Xm(e,t,n){let r=e.index.get(t);if(r===void 0)return e;let i=e.items[r];if(i.kind===`assistant`||i.kind===`thinking`)return i.streaming?Hh(e,r,{...i,streaming:!1}):e;if(i.kind===`tool`&&i.status===`streaming`){let t=i.input??tg(i.inputJson);return Hh(e,r,{...i,input:t,status:`running`,startedAt:i.startedAt??n??null})}return e}function Zm(e,t,n){let r=t.local_command_source;if(typeof r==`string`){let i=rh(r.trim());if(i&&(i.subtype===`local-command`||i.subtype===`local-command-error`)){let r={kind:`system`,id:`sys:${e.nextId}`,uuid:Jh(t),parentToolUseId:Yh(t),turnId:n.turnId??e.activeTurnId,timestamp:Xh(t),subtype:i.subtype,text:i.text},a=Vh({...e,nextId:e.nextId+1},r);return i.subtype===`local-command`&&zm(i.text)?Rm(a,{type:`model_change`}):a}}let i=t.message??{},a=$h(i.content),o=Yh(t),s=o??``,c=Jh(t),l=Xh(t),u=typeof t.error==`string`?t.error:null,d=t.aborted===!0,f=e;{let e=Qh(i.usage?.cache_read_input_tokens)+Qh(i.usage?.cache_creation_input_tokens),n=`usage:${i.id??``}`;if(e>0&&i.id&&!f.seen.has(n)&&(f={...Gh(f,n),turnCachedTokens:f.turnCachedTokens+e}),o===null&&t.isSidechain!==!0){let t=Qh(i.usage?.input_tokens)+e+Qh(i.usage?.output_tokens);t>0&&t!==f.contextTokens&&(f={...f,contextTokens:t})}}let p=f.streams[s];for(let e of a){let t=p?$m(f,p,e):null;if(t){let n=f.index.get(t),r=f.items[n];f=Hh(f,n,eh(r,e,{uuid:c,timestamp:l,model:i.model??null,messageId:i.id??null,errorText:u,aborted:d})),p={...p,unclaimed:p.unclaimed.filter(e=>e!==t)},f={...f,streams:{...f.streams,[s]:p}};continue}let r=th(f,e,{uuid:c,timestamp:l,parentToolUseId:o,turnId:n.turnId,model:i.model??null,messageId:i.id??null,errorText:u,aborted:d,receivedAt:n.receivedAt});r&&(f=r)}if(a.length===0&&u){let e={kind:`error`,id:`err:${f.nextId}`,uuid:c,parentToolUseId:o,turnId:n.turnId,timestamp:l,code:`assistant_error`,message:u,requestId:null};f=Vh(Kh(f),e)}return f}function Qm(e,t){let n=Yh(t)??``,r=e.streams[n];if(!r||r.unclaimed.length===0)return e;let i=t.message??{},a=new Set,o=e,s=r;for(let e of $h(i.content)){let t=$m(o,s,e);t&&(a.add(t),s={...s,unclaimed:s.unclaimed.filter(e=>e!==t)},o={...o,streams:{...o.streams,[n]:s}})}return Uh(e,a)}function $m(e,t,n){for(let r of t.unclaimed){let t=e.index.get(r);if(t===void 0)continue;let i=e.items[t];if(!i.uuid&&(n.type===`text`&&i.kind===`assistant`||(n.type===`thinking`||n.type===`redacted_thinking`)&&i.kind===`thinking`||n.type===`tool_use`&&i.kind===`tool`&&i.toolUseId===n.id))return r}return null}function eh(e,t,n){if(e.kind===`assistant`&&t.type===`text`){let r=t.text??e.text;return{...e,uuid:n.uuid,timestamp:n.timestamp??e.timestamp,text:r.length>=e.text.length?r:e.text,streaming:!1,model:n.model??e.model,messageId:n.messageId??e.messageId,error:n.errorText,aborted:n.aborted}}if(e.kind===`thinking`){let r=t.type===`thinking`?t.thinking??e.text:e.text;return{...e,uuid:n.uuid,timestamp:n.timestamp??e.timestamp,text:r||e.text,streaming:!1}}if(e.kind===`tool`&&t.type===`tool_use`){let r=t,i=r.input&&Object.keys(r.input).length>0?r.input:e.input??tg(e.inputJson);return{...e,uuid:n.uuid,timestamp:n.timestamp??e.timestamp,name:r.name??e.name,input:i,inputJson:e.inputJson||(i?JSON.stringify(i):``),status:e.status===`streaming`?`running`:e.status,messageId:n.messageId??e.messageId}}return e}function th(e,t,n){let r={uuid:n.uuid,parentToolUseId:n.parentToolUseId,turnId:n.turnId,timestamp:n.timestamp};if(t.type===`text`){let i={kind:`assistant`,id:`i${e.nextId}`,...r,text:t.text??``,streaming:!1,model:n.model,messageId:n.messageId,error:n.errorText,aborted:n.aborted};return Vh(Kh(e),i)}if(t.type===`thinking`||t.type===`redacted_thinking`){let n={kind:`thinking`,id:`i${e.nextId}`,...r,text:t.type===`thinking`?t.thinking??``:``,streaming:!1,redacted:t.type===`redacted_thinking`};return Vh(Kh(e),n)}if(t.type===`tool_use`){let i=t,a=e.index.get(i.id);if(a!==void 0){let r=e.items[a];return Hh(e,a,eh(r,t,n))}let o=i.input&&typeof i.input==`object`?i.input:null;return Vh(e,{kind:`tool`,id:i.id,...r,toolUseId:i.id,name:i.name,input:o,inputJson:o?JSON.stringify(o):``,status:`running`,result:null,startedAt:n.receivedAt??null,finishedAt:null,durationMs:null,elapsedSec:null,permissionRequestId:null,messageId:n.messageId})}return null}function nh(e){return e.trim().replace(/\s+/g,` `)}function rh(e){if(/^<local-command-caveat>/.test(e))return{subtype:`caveat`,text:``};let t=/^<local-command-(stdout|stderr)>([\s\S]*?)<\/local-command-\1>$/.exec(e);if(t){let e=t[2].replace(/\u001b\[[0-9;]*m/g,``).trim();return{subtype:t[1]===`stderr`?`local-command-error`:`local-command`,text:e}}let n=/<command-name>([^<]*)<\/command-name>/.exec(e);if(n&&/^<command-/.test(e)){let t=/<command-args>([^<]*)<\/command-args>/.exec(e)?.[1]?.trim()??``,r=n[1].trim(),i=gp(r.replace(/^\//,``));return{subtype:`command`,text:`${i===null?r:`/${i}`}${t?` `+t:``}`}}return null}function ih(e){let t=e.charCodeAt(0);return t===9993||t===8617||t===8635||t===9888}function ah(e){return ih(e)?Gl(e):[]}function oh(e){if(!e.startsWith(`<local-command-stdout>`))return null;let t=Wl(e);return t?.kind===`notice`?t:null}function sh(e,t,n){let r=t.message??{},i=Yh(t),a=Jh(t),o=Xh(t),s=t.isSynthetic===!0,c=e,l=[],u=[],d=!1;if(typeof r.content==`string`)l.push(r.content);else for(let e of $h(r.content))if(e.type===`text`)l.push(e.text??``);else if(e.type===`tool_result`){d=!0;let r=e;c=ph(c,r.tool_use_id,{content:r.content??``,isError:r.is_error===!0,structured:t.tool_use_result??null},n.receivedAt)}else(e.type===`image`||e.type===`document`)&&u.push(e);let f=de(l.join(`
|
|
97
97
|
`)).trim();if(he(f)&&Lh(c,f))return c;let p=rh(f);if(p?.subtype===`caveat`)return c;if(p){if(p.subtype===`command`&&i===null&&c.hasOptimisticUser){let e=nh(p.text),t=c.items.find(t=>t.kind===`user`&&t.optimistic&&!t.failed&&nh(t.text)===e);t&&(c=Uh(c,new Set([t.id])))}let e=p.subtype===`local-command`?oh(f):null,t=p.subtype===`local-command`&&!e?ap(f):null,n={kind:`system`,id:`sys:${c.nextId}`,uuid:a,parentToolUseId:i,turnId:c.activeTurnId,timestamp:o,subtype:e?`chat-notice`:t?jm:p.subtype,text:p.text,...e?{chatMarker:e}:{},...t?{newChat:t}:{}},r=Vh({...c,nextId:c.nextId+1},n);return p.subtype===`local-command`&&zm(p.text)?Rm(r,{type:`model_change`}):r}if(f.length===0&&u.length===0||d&&f.length===0||s&&d)return c;let m=i===null?ah(f):[],h=m[0]??null;if(i===null&&!s&&c.hasOptimisticUser&&h===null){let e=-1,t=!1;for(let n=0;n<c.items.length;n++){let r=c.items[n];if(!(r.kind!==`user`||!r.optimistic||r.failed)&&(t=!0,r.text===f)){e=n;break}}if(t||(c={...c,hasOptimisticUser:!1}),e>=0){let t=c.items[e],r={...t,uuid:a??t.uuid,timestamp:o??t.timestamp,optimistic:!1,turnId:t.turnId??n.turnId};return t.waiting&&e<c.items.length-1?Vh(Uh(c,new Set([t.id])),{...r,waiting:!1}):Hh(c,e,r)}if(f.includes(`
|
|
98
|
-
`)){let e=dh(c,f,a,o,n.turnId);if(e)return e}}let g=t.isMeta===!0||ce(f)||s&&f.length>0&&!oe(f),_=t.isCompactSummary===!0||ie(f)||he(f),v=nc(f),y={kind:`user`,id:a?`u:${a}`:`i${c.nextId}`,uuid:a,parentToolUseId:i,turnId:n.turnId,timestamp:o,text:f,attachments:u,requestId:null,optimistic:!1,failed:!1,waiting:!s&&!g&&!_&&v===null&&h===null&&i===null&&n.turnId!==null&&ch(c,n.turnId),deliveredAt:null,compactSummary:t.isCompactSummary===!0||ie(f),taskNotification:he(f),engineNote:!ie(f)&&!he(f)&&g,...v?{scheduledTask:v.title}:{},...h?{chatMarker:h}:{},...m.length>1?{chatBatch:m}:{}};return c.index.get(y.id)===void 0?Vh(a?c:Kh(c),y):c}function ch(e,t){if(e.status!==`running`)return!1;for(let n=e.items.length-1;n>=0;n--){let r=e.items[n];if(r.kind===`result`)return!1;if((t===null||r.turnId===null||r.turnId===t)&&(r.kind===`assistant`||r.kind===`thinking`||r.kind===`tool`))return!0}return!1}function lh(e){let t=-1;for(let
|
|
99
|
-
`)!==t)return null;let s=o[0],c=o.map(e=>e.requestId).filter(e=>typeof e==`string`),l={...s,id:n?`u:${n}`:s.id,uuid:n??s.uuid,timestamp:r??s.timestamp,text:t,attachments:o.flatMap(e=>e.attachments),turnId:s.turnId??i,optimistic:!1,waiting:!1,...c.length>0?{mergedRequestIds:c}:{}};return Vh(Uh(e,new Set(o.map(e=>e.id))),l)}function fh(e,t,n,r){let i=e=>r!==void 0&&(e.requestId===r||(e.mergedRequestIds?.includes(r)??!1)),a=e.items.some(e=>e.kind===`user`&&!e.failed&&i(e));for(let r=e.items.length-1;r>=0;r--){let o=e.items[r];if(o.kind!==`user`||o.failed||o.chatMarker!==void 0||(a?!i(o):o.text!==t))continue;if(!o.optimistic&&!o.waiting&&o.deliveredAt!==null)return e;let s={...o,optimistic:!1,waiting:!1,deliveredAt:n??o.deliveredAt??new Date().toISOString()};return o.waiting&&r<e.items.length-1?Vh(Uh(e,new Set([o.id])),s):Hh(e,r,s)}return e}function ph(e,t,n,r){let i=e.index.get(t);if(i===void 0)return Vh(e,{kind:`tool`,id:t,uuid:null,parentToolUseId:null,turnId:null,timestamp:null,toolUseId:t,name:`unknown`,input:null,inputJson:``,status:n.isError?`error`:`done`,result:n,startedAt:null,finishedAt:r??null,durationMs:null,elapsedSec:null,permissionRequestId:null,messageId:null});let a=e.items[i];if(a.result&&a.status!==`running`&&a.status!==`streaming`&&a.status!==`pending`)return e;let o=r??null,s=a.startedAt!==null&&o!==null?Math.max(0,o-a.startedAt):a.durationMs;return Hh(e,i,{...a,input:a.input??tg(a.inputJson),result:mh(a.name,n)?{...n,isError:!1}:n,status:mh(a.name,n)?`skipped`:n.isError?`error`:`done`,finishedAt:o,durationMs:s})}function mh(e,t){return!t.isError||e!==`AskUserQuestion`?!1:typeof t.content==`string`&&t.content.includes(`the user skipped the question`)}function hh(e,t,n){let r=zf(t.usage,t.modelUsage),i=Array.isArray(t.permission_denials)?t.permission_denials:[],a=n.turnId;return _h(e,{kind:`result`,id:a?`result:${a}`:Jh(t)?`result:${Jh(t)}`:`result:${e.nextId}`,uuid:Jh(t),parentToolUseId:null,turnId:a,timestamp:Xh(t),subtype:typeof t.subtype==`string`?t.subtype:`success`,isError:t.is_error===!0||typeof t.result==`string`&&/^API Error\b/i.test(t.result.trim()),costUsd:Qh(t.total_cost_usd),durationMs:Qh(t.duration_ms),durationApiMs:typeof t.duration_api_ms==`number`?t.duration_api_ms:null,numTurns:Qh(t.num_turns),inputTokens:r.input,cachedInputTokens:r.cached||e.turnCachedTokens,outputTokens:r.output,text:typeof t.result==`string`?t.result:null,errors:Array.isArray(t.errors)?t.errors.map(String):[],stopReason:typeof t.stop_reason==`string`?t.stop_reason:null,structuredOutput:t.structured_output??null},new Set(i.map(e=>e.tool_use_id??``)),n.receivedAt)}function gh(e,t,n){e=lh(e);let
|
|
98
|
+
`)){let e=dh(c,f,a,o,n.turnId);if(e)return e}}let g=t.isMeta===!0||ce(f)||s&&f.length>0&&!oe(f),_=t.isCompactSummary===!0||ie(f)||he(f),v=nc(f),y={kind:`user`,id:a?`u:${a}`:`i${c.nextId}`,uuid:a,parentToolUseId:i,turnId:n.turnId,timestamp:o,text:f,attachments:u,requestId:null,optimistic:!1,failed:!1,waiting:!s&&!g&&!_&&v===null&&h===null&&i===null&&n.turnId!==null&&ch(c,n.turnId),deliveredAt:null,compactSummary:t.isCompactSummary===!0||ie(f),taskNotification:he(f),engineNote:!ie(f)&&!he(f)&&g,...v?{scheduledTask:v.title}:{},...h?{chatMarker:h}:{},...m.length>1?{chatBatch:m}:{}};return c.index.get(y.id)===void 0?Vh(a?c:Kh(c),y):c}function ch(e,t){if(e.status!==`running`)return!1;for(let n=e.items.length-1;n>=0;n--){let r=e.items[n];if(r.kind===`result`)return!1;if((t===null||r.turnId===null||r.turnId===t)&&(r.kind===`assistant`||r.kind===`thinking`||r.kind===`tool`))return!0}return!1}function lh(e,t){let n=new Set(t??[]),r=e=>n.size>0&&(e.requestId!==void 0&&e.requestId!==null&&n.has(e.requestId)||(e.mergedRequestIds?.some(e=>n.has(e))??!1)),i=-1;for(let t=e.items.length-1;t>=0;t--){let n=e.items[t];if(n.kind===`user`&&n.waiting&&!r(n)){i=t;break}}if(i<0)return e;let a=e.items.map(e=>e.kind===`user`&&e.waiting&&!r(e)?{...e,waiting:!1}:e);return{...e,items:a}}function uh(e,t){return e.length>0&&`\n${t}\n`.includes(`\n${e}\n`)}function dh(e,t,n,r,i){let a=e.items.filter(e=>e.kind===`user`&&e.optimistic&&!e.failed&&e.parentToolUseId===null&&e.text!==t&&uh(e.text,t));if(a.length<2)return null;let o=[...a].sort((e,n)=>t.indexOf(e.text)-t.indexOf(n.text));if(o.map(e=>e.text).join(`
|
|
99
|
+
`)!==t)return null;let s=o[0],c=o.map(e=>e.requestId).filter(e=>typeof e==`string`),l={...s,id:n?`u:${n}`:s.id,uuid:n??s.uuid,timestamp:r??s.timestamp,text:t,attachments:o.flatMap(e=>e.attachments),turnId:s.turnId??i,optimistic:!1,waiting:!1,...c.length>0?{mergedRequestIds:c}:{}};return Vh(Uh(e,new Set(o.map(e=>e.id))),l)}function fh(e,t,n,r){let i=e=>r!==void 0&&(e.requestId===r||(e.mergedRequestIds?.includes(r)??!1)),a=e.items.some(e=>e.kind===`user`&&!e.failed&&i(e));for(let r=e.items.length-1;r>=0;r--){let o=e.items[r];if(o.kind!==`user`||o.failed||o.chatMarker!==void 0||(a?!i(o):o.text!==t))continue;if(!o.optimistic&&!o.waiting&&o.deliveredAt!==null)return e;let s={...o,optimistic:!1,waiting:!1,deliveredAt:n??o.deliveredAt??new Date().toISOString()};return o.waiting&&r<e.items.length-1?Vh(Uh(e,new Set([o.id])),s):Hh(e,r,s)}return e}function ph(e,t,n,r){let i=e.index.get(t);if(i===void 0)return Vh(e,{kind:`tool`,id:t,uuid:null,parentToolUseId:null,turnId:null,timestamp:null,toolUseId:t,name:`unknown`,input:null,inputJson:``,status:n.isError?`error`:`done`,result:n,startedAt:null,finishedAt:r??null,durationMs:null,elapsedSec:null,permissionRequestId:null,messageId:null});let a=e.items[i];if(a.result&&a.status!==`running`&&a.status!==`streaming`&&a.status!==`pending`)return e;let o=r??null,s=a.startedAt!==null&&o!==null?Math.max(0,o-a.startedAt):a.durationMs;return Hh(e,i,{...a,input:a.input??tg(a.inputJson),result:mh(a.name,n)?{...n,isError:!1}:n,status:mh(a.name,n)?`skipped`:n.isError?`error`:`done`,finishedAt:o,durationMs:s})}function mh(e,t){return!t.isError||e!==`AskUserQuestion`?!1:typeof t.content==`string`&&t.content.includes(`the user skipped the question`)}function hh(e,t,n){let r=zf(t.usage,t.modelUsage),i=Array.isArray(t.permission_denials)?t.permission_denials:[],a=n.turnId;return _h(e,{kind:`result`,id:a?`result:${a}`:Jh(t)?`result:${Jh(t)}`:`result:${e.nextId}`,uuid:Jh(t),parentToolUseId:null,turnId:a,timestamp:Xh(t),subtype:typeof t.subtype==`string`?t.subtype:`success`,isError:t.is_error===!0||typeof t.result==`string`&&/^API Error\b/i.test(t.result.trim()),costUsd:Qh(t.total_cost_usd),durationMs:Qh(t.duration_ms),durationApiMs:typeof t.duration_api_ms==`number`?t.duration_api_ms:null,numTurns:Qh(t.num_turns),inputTokens:r.input,cachedInputTokens:r.cached||e.turnCachedTokens,outputTokens:r.output,text:typeof t.result==`string`?t.result:null,errors:Array.isArray(t.errors)?t.errors.map(String):[],stopReason:typeof t.stop_reason==`string`?t.stop_reason:null,structuredOutput:t.structured_output??null},new Set(i.map(e=>e.tool_use_id??``)),n.receivedAt)}function gh(e,t,n,r){e=lh(e,r);let i=`result:${n}`,a=e.index.get(i),o={kind:`result`,id:i,uuid:a===void 0?null:e.items[a].uuid,parentToolUseId:null,turnId:n,timestamp:a===void 0?null:e.items[a].timestamp,subtype:t.subtype,isError:t.isError,costUsd:t.totalCostUsd,durationMs:t.durationMs,durationApiMs:a===void 0?null:e.items[a].durationApiMs,numTurns:t.numTurns,inputTokens:t.inputTokens,cachedInputTokens:t.cachedInputTokens??(a===void 0?void 0:e.items[a].cachedInputTokens)??e.turnCachedTokens,outputTokens:t.outputTokens,text:t.result,errors:t.errors??[],stopReason:t.stopReason,structuredOutput:t.structuredOutput??null};return _h(e,o,new Set,void 0)}function _h(e,t,n,r){let i=e,a=i.index.get(t.id),o=a!==void 0;i=a===void 0?Vh(Kh(i),t):Hh(i,a,t);let s=i.items.map(e=>{if((e.kind===`assistant`||e.kind===`thinking`)&&e.streaming)return{...e,streaming:!1};if(e.kind===`tool`&&e.result===null&&(e.status===`streaming`||e.status===`running`||e.status===`pending`)){let t=n.has(e.toolUseId)?`denied`:`cancelled`;return{...e,status:t,input:e.input??tg(e.inputJson),finishedAt:r??null}}return e}),c=o?i.totals:{costUsd:i.totals.costUsd+t.costUsd,inputTokens:i.totals.inputTokens+t.inputTokens,cachedInputTokens:i.totals.cachedInputTokens+(t.cachedInputTokens??0),outputTokens:i.totals.outputTokens+t.outputTokens,turns:i.totals.turns+1};return{...i,items:s,totals:c,status:t.isError?`error`:`idle`,activeTurnId:null,statusText:null,streams:{},pendingPermissions:[]}}function vh(e,t){let n=Zh(t.tool_use_id),r=typeof t.elapsed_time_seconds==`number`?t.elapsed_time_seconds:null;return!n||r===null?e:Wh(e,n,e=>e.result?e:{...e,elapsedSec:r})}function yh(e,t,n){let r=Array.isArray(t.output)?t.output.map(String).join(`
|
|
100
100
|
`):``,i=typeof t.error==`string`?t.error:null,a=i?`Authentication error: ${i}`:t.isAuthenticating?`Authenticating…\n${r}`.trim():r;if(!a)return e;let o={kind:`system`,id:`sys:${e.nextId}`,uuid:Jh(t),parentToolUseId:null,turnId:n.turnId,timestamp:Xh(t),subtype:`auth_status`,text:a};return Vh(Kh(e),o)}function bh(e,t,n,r=!1){let i=`perm:${t.requestId}`;if(e.index.get(i)!==void 0)return e;let a=e.index.get(t.toolUseId),o=a===void 0?void 0:e.items[a],s=Vh(e,{kind:`permission`,id:i,uuid:null,parentToolUseId:o?.kind===`tool`?o.parentToolUseId:null,turnId:n,timestamp:t.createdAt,request:t,status:r?`allowed`:`pending`,resolvedBy:r?`auto`:null});return s=Wh(s,t.toolUseId,e=>({...e,permissionRequestId:t.requestId,status:e.result?e.status:r?`running`:`pending`})),r?{...s,activeTurnId:s.activeTurnId??n}:{...s,pendingPermissions:[...s.pendingPermissions.filter(e=>e.requestId!==t.requestId),t],status:`waiting_permission`,activeTurnId:s.activeTurnId??n}}function xh(e,t,n,r){let i=`perm:${t}`,a=e.index.get(i),o=e,s=null;if(a!==void 0){let e=o.items[a];s=e.request.toolUseId,e.status===`pending`&&(o=Hh(o,a,{...e,status:n===`allow`?`allowed`:`denied`,resolvedBy:r}))}let c=o.pendingPermissions.filter(e=>e.requestId!==t);s&&(o=Wh(o,s,e=>e.result?e:{...e,status:n===`allow`?`running`:`denied`}));let l=c.length>0?`waiting_permission`:o.activeTurnId||o.status===`waiting_permission`?`running`:o.status;return{...o,pendingPermissions:c,status:l}}function Sh(e,t,n){return zh(e,e=>Ch(e,t,n))}function Ch(e,t,n){let r=e;for(let e of t){let t=e.parentToolUseId;if(e.subpath&&(r=Im(r,e.subpath,e.role,e.content,e.timestamp)),e.subpath&&(t===null||r.index.get(t)===void 0)){let n=Ah(r,e.subpath);r=n.state,t=n.parentToolUseId}let n={type:e.role===`assistant`?`assistant`:e.role===`user`?`user`:`system`,uuid:e.uuid,parent_tool_use_id:t,timestamp:e.timestamp??void 0};if(e.role===`system`){let t=typeof e.content==`string`?e.content:eg($h(e.content)),n=e.subtype===`model_refusal_fallback`||e.subtype===`model_refusal_no_fallback`?Mf(e.refusal??{subtype:e.subtype,content:t}):null;if(n){if(r.seen.has(`uuid:${e.uuid}`))continue;r=Gh(Bm(r,n,{uuid:e.uuid,parentToolUseId:e.parentToolUseId,turnId:null,timestamp:e.timestamp,live:!1}),`uuid:${e.uuid}`);continue}if(!t||r.seen.has(`uuid:${e.uuid}`))continue;let i=rh(t.trim());i?.subtype===`local-command`&&zm(i.text)&&(r=Rm(r,{type:`model_change`}));let a=oh(t.trim()),o=a?null:ap(t.trim()),s={kind:`system`,id:`sys:${e.uuid}`,uuid:e.uuid,parentToolUseId:e.parentToolUseId,turnId:null,timestamp:e.timestamp,subtype:a?`chat-notice`:o?jm:e.subtype===`rewind_boundary`?`rewind`:`history`,text:a||o?rh(t.trim())?.text??t:t,...a?{chatMarker:a}:{},...o?{newChat:o}:{}};r.index.get(s.id)===void 0&&(r=Gh(Vh(r,s),`uuid:${e.uuid}`));continue}let i=e.role===`assistant`?{id:null,role:`assistant`,model:e.model,content:$h(e.content)}:{role:`user`,content:typeof e.content==`string`?e.content:$h(e.content)};r=qm(r,{...n,message:i},{turnId:null,receivedAt:void 0})}return r={...r,hydrated:!0},r=n?jh(r,n):Mh(r),Wm(r)}function wh(e,t){return zh(e,e=>Th(e,t))}function Th(e,t){let n=e;for(let e of t){let t=`seq:${e.seq}`;if(n.seen.has(t))continue;let r=e.entry,i=e.type||String(r.type??``);if(i===`attachment`){let t=pe(r);if(t!==null){let i={type:`user`,uuid:e.uuid??(typeof r.uuid==`string`?r.uuid:void 0),parent_tool_use_id:null,timestamp:e.timestamp??void 0,message:{role:`user`,content:t.content}};n=qm(n,i,{turnId:null,receivedAt:void 0}),typeof t.content!=`string`&&(n=fh(n,t.text,t.timestamp))}}if(i===`queue-operation`){let e=fe(r);e&&(n=fh(n,e.text,e.deliveredAt))}if(i===`user`||i===`assistant`||i===`system`||i===`result`){let t=r.parent_tool_use_id??null;if(e.subpath){let t=r.message;n=Im(n,e.subpath,i,t?.content,e.timestamp,t?.stop_reason)}if(e.subpath&&(t===null||n.index.get(t)===void 0)){let r=Ah(n,e.subpath);n=r.state,t=r.parentToolUseId}let a={...r,type:i,uuid:e.uuid??(typeof r.uuid==`string`?r.uuid:void 0),parent_tool_use_id:t,timestamp:e.timestamp??void 0};n=qm(n,a,{turnId:null,receivedAt:void 0})}n=Gh(n,t),(n.lastSeq===null||e.seq>n.lastSeq)&&(n={...n,lastSeq:e.seq})}return Wm(Mh({...n,hydrated:!0}))}var Eh=/^subagents\/(?:workflows\/([^/]+)\/)?agent-(.+?)(?:\.jsonl)?$/;function Dh(e){return`subagent:${e}`}function Oh(e){return`subagent:workflows/${e}`}function kh(e,t,n,r){return{kind:`tool`,id:e,uuid:null,parentToolUseId:r,turnId:null,timestamp:null,toolUseId:e,name:t,input:{description:n},inputJson:``,status:`done`,result:null,startedAt:null,finishedAt:null,durationMs:null,elapsedSec:null,permissionRequestId:null,messageId:null}}function Ah(e,t){if(!t)return{state:e,parentToolUseId:null};let n=e.subpathParents[t];if(n!==void 0&&e.index.get(n)!==void 0)return{state:e,parentToolUseId:n};let r=Eh.exec(t);if(!r)return{state:e,parentToolUseId:null};let i=r[1]??null,a=r[2],o=(e,n)=>({state:Rh?(e.subpathParents[t]=n,e):{...e,subpathParents:{...e.subpathParents,[t]:n}},parentToolUseId:n}),s=e.index.get(a);if(s!==void 0){let t=e.items[s];if(t?.kind===`tool`)return o(e,t.toolUseId)}if(i){for(let t of e.items)if(t.kind===`tool`&&t.name===`Workflow`&&t.result!==null&&ng(t.result).includes(i))return o(e,t.toolUseId)}let c=Dh(t);if(e.index.get(c)!==void 0)return o(e,c);let l=a.slice(0,8),u=e,d=null;i&&(d=Oh(i),u.index.get(d)===void 0&&(u=Vh(u,kh(d,`Workflow`,`Workflow run ${i} (transcript)`,null))));let f=kh(c,`Agent`,i?`Agent ${l}`:`Agent ${l} (transcript)`,d);return o(Vh(u,f),c)}function jh(e,t){let n=e.pendingPermissions.length>0?`waiting_permission`:t.status,r=t.engineSince?Date.parse(t.engineSince):NaN,i=e.hydrated&&e.session!==null&&!Hm(e.status)&&Hm(n),a=e.session?.engineSince,o=t.engineSince,s=e.session!==null&&a!==void 0&&o!==void 0&&a!==o,c=Wm(Mh({...e,session:t,sessionId:t.id,status:n,engineSince:Number.isFinite(r)?r:e.engineSince,...i?{lastFrameAt:null}:{},...s&&e.safeguardFallback?.live===!0?{safeguardFallback:Nf(e.safeguardFallback,{type:`engine_start`})}:{}}));if(!i)return c;let l=Date.parse(t.updatedAt);return Number.isFinite(l)&&l>(c.lastFrameAt??0)?{...c,lastFrameAt:l}:c}function Mh(e){if(e.activeTurnId!==null||e.status!==`idle`&&e.status!==`error`)return e;let t=!1,n=e.items.map(e=>(e.kind===`assistant`||e.kind===`thinking`)&&e.streaming?(t=!0,{...e,streaming:!1}):e.kind===`tool`&&e.result===null&&(e.status===`streaming`||e.status===`running`||e.status===`pending`)?(t=!0,{...e,status:`cancelled`,input:e.input??tg(e.inputJson)}):e);return t?{...e,items:n}:e}function Nh(e,t){let n=(t.attachments??[]).filter(e=>typeof e==`object`&&!!e&&typeof e.type==`string`),r={kind:`user`,id:`req:${t.requestId}`,uuid:null,parentToolUseId:null,turnId:null,timestamp:t.at??null,text:t.text,attachments:n,requestId:t.requestId,optimistic:!0,failed:!1,waiting:e.status===`running`,deliveredAt:null,compactSummary:!1,taskNotification:!1,engineNote:!1};if(e.index.get(r.id)!==void 0)return e;let i=new Set(e.items.filter(e=>e.kind===`user`&&e.failed&&e.text===t.text).map(e=>e.id)),a=!Hm(e.status),o=t.at===void 0?NaN:Date.parse(t.at);return{...Vh(Uh(e,i),r),status:`running`,statusText:null,hasOptimisticUser:!0,lastLocalPromptId:r.id,...a?{lastFrameAt:Number.isFinite(o)?o:null}:{}}}function Ph(e,t){let n=e.index.get(`req:${t}`),r=e;if(n!==void 0){let t=e.items[n];t?.kind===`user`&&!t.failed&&(r=Hh(e,n,{...t,failed:!0}))}return r.activeTurnId!==null||r.status!==`running`&&r.status!==`waiting_permission`?r:{...r,status:`error`,statusText:null}}function Fh(e,t){let n=new Map,r=new Map;for(let t of e){let e={item:t,children:[]};n.set(t.id,e),t.kind===`tool`&&r.set(t.toolUseId,e)}let i=[];for(let t of e){let e=n.get(t.id),a=t.parentToolUseId?r.get(t.parentToolUseId):void 0;a&&a!==e?a.children.push(e):i.push(e)}if(!t||t.length===0)return i;let a=new Map,o=e=>{for(let t of e)a.set(t.item.id,t),t.children.length>0&&o(t.children)};o(t);let s=new Map;for(let t=e.length-1;t>=0;t--){let r=n.get(e[t].id);for(let e=0;e<r.children.length;e++){let t=s.get(r.children[e]);t&&(r.children[e]=t)}let i=a.get(r.item.id);s.set(r,i&&Ih(i,r)?i:r)}let c=i.map(e=>s.get(e)??e);return c.length===t.length&&c.every((e,n)=>e===t[n])?t:c}function Ih(e,t){if(e.item!==t.item||e.children.length!==t.children.length)return!1;for(let n=0;n<t.children.length;n++)if(e.children[n]!==t.children[n])return!1;return!0}function Lh(e,t){let n=ve(t);if(!n.taskId)return!1;for(let t=e.items.length-1;t>=0;t--){let r=e.items[t];if(r.kind!==`user`||!r.taskNotification)continue;let i=ve(r.text);if(i.taskId===n.taskId&&(i.toolUseId??null)===(n.toolUseId??null))return!0}return!1}var Rh=!1;function zh(e,t){if(Rh)return t(e);Rh=!0;try{return t({...e,items:e.items.slice(),index:new Map(e.index),seen:new Set(e.seen),subpathParents:{...e.subpathParents}})}finally{Rh=!1}}var Bh=new Set([`Task`,`Agent`,`Workflow`]);function Vh(e,t){let n=e.hasSubagentItems||t.kind===`tool`&&Bh.has(t.name);if(Rh)return e.items.push(t),e.index.set(t.id,e.items.length-1),e.hasSubagentItems=n,e;let r=[...e.items,t];return{...e,items:r,index:new Map(e.index).set(t.id,r.length-1),...n===e.hasSubagentItems?{}:{hasSubagentItems:n}}}function Hh(e,t,n){if(Rh)return e.items[t]=n,e;let r=e.items.slice();return r[t]=n,{...e,items:r}}function Uh(e,t){if(t.size===0)return e;let n=e.items.filter(e=>!t.has(e.id)),r=new Map;n.forEach((e,t)=>{r.set(e.id,t)});let i={};for(let[n,r]of Object.entries(e.streams)){let e={};for(let[n,i]of Object.entries(r.blocks))t.has(i)||(e[Number(n)]=i);i[n]={...r,blocks:e,unclaimed:r.unclaimed.filter(e=>!t.has(e))}}return{...e,items:n,index:r,streams:i}}function Wh(e,t,n){let r=e.index.get(t);if(r===void 0)return e;let i=e.items[r];if(!i||i.kind!==`tool`)return e;let a=n(i);return a===i?e:Hh(e,r,a)}function Gh(e,t){return e.seen.has(t)?e:Rh?(e.seen.add(t),e):{...e,seen:new Set(e.seen).add(t)}}function Kh(e){return{...e,nextId:e.nextId+1}}function qh(e,t,n){let r=Jh(n);return r?`${t}:${r}`:`${t}:${e.nextId}`}function Jh(e){return typeof e.uuid==`string`&&e.uuid?e.uuid:null}function Yh(e){return typeof e.parent_tool_use_id==`string`&&e.parent_tool_use_id?e.parent_tool_use_id:null}function Xh(e){return typeof e.timestamp==`string`?e.timestamp:null}function Zh(e){return typeof e==`string`?e:``}function Qh(e){return typeof e==`number`&&Number.isFinite(e)?e:0}function $h(e){return typeof e==`string`?e?[{type:`text`,text:e}]:[]:Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.type==`string`):[]}function eg(e){return e.map(e=>e.type===`text`?e.text??``:``).filter(Boolean).join(`
|
|
101
101
|
`)}function tg(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);return typeof e==`object`&&e&&!Array.isArray(e)?e:null}catch{return null}}function ng(e){return e?typeof e.content==`string`?e.content:e.content.map(e=>e.type===`text`?e.text??``:e.type===`image`?`[image]`:`[${e.type}]`).join(`
|
|
102
102
|
`):``}function rg(e){if(e==null||!Number.isFinite(e))return``;if(e<1e3)return`${Math.floor(e)}ms`;if(e<1e4)return`${(Math.floor(e/100)/10).toFixed(1)}s`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/3600),r=Math.floor(t%3600/60);return n>0?`${n}h ${r}m`:`${r}m ${t%60}s`}function ig(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ag(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(!Number.isFinite(n))return``;let r=Math.max(0,t-n),i=Math.floor(r/1e3);if(i<45)return`just now`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);if(o<24)return`${o}h ago`;let s=Math.floor(o/24);return s<30?`${s}d ago`:new Date(n).toLocaleDateString()}function og(e,t=Date.now()){if(e==null||!Number.isFinite(e)||e<=0)return``;let n=Math.floor(Math.max(0,t-e)/1e3);if(n<45)return`just now`;let r=(e,t)=>`${e} ${t}${e===1?``:`s`} ago`,i=Math.floor(n/60);if(i<60)return r(Math.max(1,i),`minute`);let a=Math.floor(i/60);if(a<24)return r(a,`hour`);let o=Math.floor(a/24);return o<30?r(o,`day`):new Date(e).toLocaleDateString()}function sg(e){if(!e)return;let t=new Date(e);if(!Number.isNaN(t.getTime()))return t.toLocaleString()}function cg(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``}function lg(e){let t=e.replace(/[\\/]+$/,``),n=t.split(/[\\/]/);return n[n.length-1]||t}function ug(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function dg(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function U(...e){return e.filter(Boolean).join(` `)}function fg(e,t=6){let n=e.trim().split(/\s+/).filter(Boolean);return n.length<=t?n.join(` `):`${n.slice(0,t).join(` `)}…`}function pg(e){return e.title?.trim()||e.firstPrompt?.trim().replace(/\s+/g,` `)||`Session ${e.id.slice(0,8)}`}function mg(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function hg(e,t=Date.now()){return{id:e,title:null,providerId:null,variantId:null,projectId:null,model:null,permissionMode:null,projectDir:null,createdAt:t}}function gg(e,t){if(!t)return e;let n={...e};return!e.model&&!e.providerId&&t.model&&(n.model=t.model,n.providerId=t.providerId??null,n.variantId=null),!e.effort&&t.effort&&(n.effort=t.effort),!e.projectDir&&t.cwd&&(n.projectDir=t.cwd),n}var _g=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function vg(e){return _g.test(e)}function yg(){let e=new Uint8Array(16),t=globalThis.crypto;if(t&&typeof t.getRandomValues==`function`)return t.getRandomValues(e),e;for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256);return e}function bg(){let e=globalThis.crypto;if(e&&typeof e.randomUUID==`function`){let t=e.randomUUID();if(vg(t))return t}let t=yg();t[6]=(t[6]??0)&15|64,t[8]=(t[8]??0)&63|128;let n=Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function xg(e){return e.title?.trim()||`New chat`}function Sg(e){let t=e.trim().replace(/\s+/g,` `).slice(0,500);return t.length>0?t:null}function Cg(e,t){return typeof t==`string`&&e[t]!==void 0}var wg=`oonacode.uiPrefs`;function Tg(e){if(!e)return null;try{let t=e.getItem(wg);return t?Qc(JSON.parse(t)):null}catch{return null}}function Eg(e,t){if(e)try{e.setItem(wg,JSON.stringify(t))}catch{}}function Dg(e,t){let n=t.notifications?{...e.notifications,...t.notifications}:e.notifications;return Qc({...e,...t,notifications:n})}function Og(e){let t=e;return!t||typeof t!=`object`?!1:t.status===400||t.status===422||t.code===`bad_request`}function kg(e){let{row:t,panel:n,viewport:r}=e,i=e.gap??6,a=e.margin??8,o=Math.max(0,Math.min(e.width??352,r.width-2*a)),s=Math.max(0,Math.min(e.maxHeight??448,r.height-2*a)),c=Math.min(e.height>0?e.height:200,s),l=Math.max(a,Math.min(t.top,r.height-a-c)),u=n.right+i;if(u+o<=r.width-a)return{left:u,top:l,width:o,maxHeight:s,side:`right`};let d=n.left-i-o;if(d>=a)return{left:d,top:l,width:o,maxHeight:s,side:`left`};let f=Math.max(a,Math.min(t.left,r.width-a-o)),p=r.height-a-(t.bottom+i),m=t.top-i-a;if(p>=c||p>=m)return{left:f,top:t.bottom+i,width:o,maxHeight:Math.max(0,Math.min(s,p)),side:`below`};let h=Math.max(0,Math.min(s,m));return{left:f,top:t.top-i-Math.min(c,h),width:o,maxHeight:h,side:`above`}}var Ag={ids:[],activeId:null};function jg(e=[],t=null){let n=[];for(let t of e)t&&!n.includes(t)&&n.push(t);let r=n.slice(-20);return{ids:r,activeId:t&&r.includes(t)?t:r[r.length-1]??null}}function Mg(e,t){return!e.ids.includes(t)||e.activeId===t?e:{ids:e.ids,activeId:t}}function Ng(e,t){let n=e.ids.indexOf(t);if(n===-1)return e;let r=e.ids.filter(e=>e!==t);return e.activeId===t?{ids:r,activeId:r[n]??r[n-1]??null}:{ids:r,activeId:e.activeId}}function Pg(e,t,n){if(t===n||t<0||t>=e.ids.length)return e;let r=Math.max(0,Math.min(e.ids.length-1,n));if(r===t)return e;let i=[...e.ids],[a]=i.splice(t,1);return a===void 0?e:(i.splice(r,0,a),{ids:i,activeId:e.activeId})}function Fg(e,t){let n=t instanceof Set?t:new Set(t),r=e.ids.filter(e=>n.has(e));return r.length===e.ids.length?e:{ids:r,activeId:e.activeId&&r.includes(e.activeId)?e.activeId:r[r.length-1]??null}}function Ig(e,t){if(e.ids.length===0)return e;let n=e.activeId?e.ids.indexOf(e.activeId):-1,r=n===-1?0:n,i=e.ids.length,a=((r+t)%i+i)%i,o=e.ids[a];return o?Mg(e,o):e}function Lg(e,t={},n={}){let r=[],i=[],a={},o={};for(let s of e.ids){let e=n[s];if(e){i.push(s),e.title&&(a[s]=e.title);continue}r.push(s);let c=t[s];c&&(o[s]=c)}return{openTabs:r,draftTabs:i,draftTitles:a,activeTab:e.activeId,remoteTabs:o}}function Rg(e){let t=e?.remoteTabs;if(!t)return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`string`&&r.length>0&&(n[e]=r);return n}function zg(e){let t=e?.draftTabs??[],n=e?.draftTitles??{},r=[];for(let e of t){if(typeof e!=`string`||e.length===0)continue;let t=n[e];r.push({id:e,title:typeof t==`string`&&t.length>0?t:null})}return r}function Bg(e){return jg([...e.openTabs??[],...e.draftTabs??[]],e.activeTab??null)}function Vg(e,t){if(e.length!==t.length)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!0;return!1}function Hg(e,t){for(let n of new Set([...Object.keys(e),...Object.keys(t)]))if(e[n]!==t[n])return!0;return!1}function Ug(e,t,n,r={}){let i=Lg(e,n??{},r);return!!(Vg(t.openTabs??[],i.openTabs)||Vg(t.draftTabs??[],i.draftTabs)||Hg(t.draftTitles??{},i.draftTitles)||(t.activeTab??null)!==e.activeId||n&&Hg(t.remoteTabs??{},i.remoteTabs))}var Wg=.25,Gg=`g1`;function Kg(e=Ag){return{root:{type:`group`,id:Gg},groups:{[Gg]:e},focused:Gg}}function qg(e){let t=[],n=e=>{if(e.type===`group`)t.push(e.id);else for(let t of e.children)n(t)};return n(e.root),t}function Jg(e){let t=[];for(let n of qg(e))t.push(...e.groups[n]?.ids??[]);return t}function Yg(e,t){for(let n of qg(e))if(e.groups[n]?.ids.includes(t))return n;return null}function Xg(e){return e.groups[e.focused]??Ag}function Zg(e){return{ids:Jg(e),activeId:Xg(e).activeId}}function Qg(e,t){if(e.activeId!==t.activeId||e.ids.length!==t.ids.length)return!1;for(let n=0;n<e.ids.length;n++)if(e.ids[n]!==t.ids[n])return!1;return!0}function $g(e){let t=[];for(let n of qg(e)){let r=e.groups[n]?.activeId;r&&t.push(r)}return t}function e_(e,t){let n=qg(e);return n.length<2?null:n[(n.indexOf(t)+1)%n.length]??null}function t_(e,t){let n=e.root;for(let e of t){if(n.type!==`split`)return null;let t=n.children[e];if(!t)return null;n=t}return n}function n_(e,t=e.length){let n=Array.from({length:t},(t,n)=>{let r=e[n];return typeof r==`number`&&Number.isFinite(r)&&r>0?r:0}),r=n.reduce((e,t)=>e+t,0);if(t===0)return[];if(r<=0)return n.map(()=>1/t);let i=r/n.filter(e=>e>0).length,a=n.map(e=>e>0?e:i),o=a.reduce((e,t)=>e+t,0);return a.map(e=>e/o)}function r_(e){if(e.type===`group`)return e;let t=[],n=[],r=n_(e.sizes,e.children.length);return e.children.forEach((i,a)=>{let o=r_(i);if(!o)return;let s=r[a]??0;o.type===`split`&&o.direction===e.direction?o.children.forEach((e,r)=>{t.push(e),n.push(s*(o.sizes[r]??0))}):(t.push(o),n.push(s))}),t.length===0?null:t.length===1?t[0]:{type:`split`,direction:e.direction,children:t,sizes:n_(n)}}function i_(e,t){if(e.type===`group`)return e.id===t?null:e;let n=[],r=[];return e.children.forEach((i,a)=>{let o=i_(i,t);o&&(n.push(o),r.push(e.sizes[a]??0))}),n.length===0?null:r_({type:`split`,direction:e.direction,children:n,sizes:r})}function a_(e){let t=0;for(let n of Object.keys(e.groups)){let e=/^g(\d+)$/.exec(n);e&&(t=Math.max(t,Number(e[1])))}return`g${t+1}`}function o_(e,t){let n=qg(e);if(n.length<=1||!n.includes(t))return e;let r=n.indexOf(t),i=n.filter(e=>e!==t),a=i_(e.root,t)??{type:`group`,id:i[0]},{[t]:o,...s}=e.groups;return{root:a,groups:s,focused:e.focused===t?n[r-1]??n[r+1]??i[0]:e.focused}}function s_(e,t,n){return e.groups[t]===n?e:{...e,groups:{...e.groups,[t]:n}}}function c_(e,t){let n=e.groups[t];return n&&n.ids.length===0?o_(e,t):e}function l_(e,t,n,r){let i=r===`left`||r===`right`?`row`:`column`,a=r===`left`||r===`top`;if(e.type===`group`)return e.id===t?{type:`split`,direction:i,children:a?[n,e]:[e,n],sizes:[.5,.5]}:e;let o=e.children.findIndex(e=>e.type===`group`&&e.id===t);if(o>=0&&e.direction===i){let t=e.sizes[o]??1/e.children.length,r=[...e.children],i=[...e.sizes],s=a?o:o+1;return i[o]=t/2,r.splice(s,0,n),i.splice(s,0,t/2),{...e,children:r,sizes:i}}return{...e,children:e.children.map(e=>l_(e,t,n,r))}}function u_(e,t,n){let r=e;for(let e=0;e<40&&Jg(r).length>20;e++){let e=new Set(qg(r).map(e=>r.groups[e]?.activeId??null).filter(Boolean)),i=r=>r.find(r=>r!==t&&r!==n&&!e.has(r)),a=i(r.groups[r.focused]?.ids??[]);if(!a){for(let e of qg(r))if(a=i(r.groups[e]?.ids??[]),a)break}if(!a)break;r=h_(r,a)}return r}function d_(e,t){return e.focused===t||!e.groups[t]?e:{...e,focused:t}}function f_(e,t){let n=qg(e)[t];return n?d_(e,n):e}function p_(e,t){let n=Yg(e,t);if(!n)return e;let r=e.groups[n];return r.activeId===t&&e.focused===n?e:{...s_(e,n,Mg(r,t)),focused:n}}function m_(e,t,n=e.focused){if(!t)return e;if(Yg(e,t))return p_(e,t);let r=e.groups[n]?n:e.focused,i=e.groups[r]??Ag;return u_({...s_(e,r,{ids:[...i.ids,t],activeId:t}),focused:r},t,i.activeId)}function h_(e,t){let n=Yg(e,t);return n?c_(s_(e,n,Ng(e.groups[n],t)),n):e}function g_(e,t,n,r){let i=e.groups[t];return i?s_(e,t,Pg(i,n,r)):e}function __(e,t){let n=e.groups[e.focused];return n?s_(e,e.focused,Ig(n,t)):e}function v_(e,t,n,r){let i=e.groups[n];if(!i)return e;let a=Yg(e,t);if(a===n){let a=i.ids.indexOf(t);return p_(d_(r===void 0?e:g_(e,n,a,r>a?r-1:r),n),t)}let o=[...i.ids],s=r===void 0?o.length:Math.max(0,Math.min(o.length,r));o.splice(s,0,t);let c={...e,focused:n};return c=s_(c,n,{ids:o,activeId:t}),a&&(c=c_(s_(c,a,Ng(c.groups[a],t)),a)),a?c:u_(c,t,i.activeId)}function y_(e,t,n,r){if(!e.groups[n])return e;let i=Yg(e,t);if(i===n&&e.groups[n].ids.length===1||qg(e).length>=8)return e;let a=e;i&&(a=c_(s_(a,i,Ng(a.groups[i],t)),i));let o=a_(a),s={root:r_(l_(a.root,n,{type:`group`,id:o},r))??a.root,groups:{...a.groups,[o]:{ids:[t],activeId:t}},focused:o};return i?s:u_(s,t,null)}function b_(e,t,n){return e.groups[n.groupId]?n.zone===`center`?v_(e,t,n.groupId,n.index):y_(e,t,n.groupId,n.zone):e}function x_(e,t,n){return n.zone===`center`&&n.index===void 0?Yg(e,t)!==n.groupId:b_(e,t,n)!==e}function S_(e,t,n){let r=t_(e,t);if(!r||r.type!==`split`)return e;let i=n_(n,r.children.length);return i.every((e,t)=>Math.abs(e-(r.sizes[t]??0))<1e-6)?e:{...e,root:w_(e.root,t,{...r,sizes:i})}}function C_(e,t){let n=t_(e,t);return!n||n.type!==`split`?e:S_(e,t,n.children.map(()=>1))}function w_(e,t,n){if(t.length===0)return n;if(e.type!==`split`)return e;let[r,...i]=t;return{...e,children:e.children.map((e,t)=>t===r?w_(e,i,n):e)}}function T_(e,t,n=null){let r=new Set(t),i=new Set,a=e;for(let t of qg(e)){let e=a.groups[t],n=e.ids.filter(e=>!r.has(e)||i.has(e)?!1:(i.add(e),!0));if(n.length===e.ids.length)continue;let o=e.activeId&&n.includes(e.activeId)?e.activeId:n.at(-1)??null;a=s_(a,t,{ids:n,activeId:o})}for(let e of qg(a))a=c_(a,e);let o=t.filter(e=>!i.has(e));if(o.length>0){let e=a.groups[a.focused]??Ag,t=[...e.ids,...o.filter((e,t)=>o.indexOf(e)===t)];a=s_(a,a.focused,{ids:t,activeId:e.activeId??t.at(-1)??null})}return n&&r.has(n)&&(a=p_(a,n)),a}function E_(e){if(e.type===`group`)return{width:380,height:240};let t=e.children.map(E_);return e.direction===`row`?{width:t.reduce((e,t)=>e+t.width,0),height:Math.max(0,...t.map(e=>e.height))}:{width:Math.max(0,...t.map(e=>e.width)),height:t.reduce((e,t)=>e+t.height,0)}}function D_(e,t,n){if(e.root.type===`group`)return!1;let r=E_(e.root);return t<r.width||n<r.height}function O_(e,t,n,r=Wg){if(e.width<=0||e.height<=0)return`center`;let i=(t-e.left)/e.width,a=(n-e.top)/e.height,o=[[`left`,i],[`right`,1-i],[`top`,a],[`bottom`,1-a]],s=o[0];for(let e of o)e[1]<s[1]&&(s=e);return s[1]<r?s[0]:`center`}function k_(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(t<r.left+r.width/2)return n}return e.length}function A_(e){switch(e){case`left`:return{left:0,top:0,width:.5,height:1};case`right`:return{left:.5,top:0,width:.5,height:1};case`top`:return{left:0,top:0,width:1,height:.5};case`bottom`:return{left:0,top:.5,width:1,height:.5};default:return{left:0,top:0,width:1,height:1}}}function j_(e){if(e.root.type===`group`)return null;let t=n=>{if(n.type===`group`){let t=e.groups[n.id]??Ag;return{group:{tabs:[...t.ids],active:t.activeId}}}return{split:n.direction,sizes:n.sizes.map(e=>Math.round(e*1e4)/1e4),children:n.children.map(t)}};return{root:t(e.root),focused:Math.max(0,qg(e).indexOf(e.focused))}}function M_(e,t){if(!e||!t)return!e&&!t;if(e.focused!==t.focused)return!1;let n=(e,t)=>{if(`group`in e||`group`in t){if(!(`group`in e)||!(`group`in t))return!1;let n=e.group,r=t.group;return n.active===r.active&&n.tabs.length===r.tabs.length&&n.tabs.every((e,t)=>e===r.tabs[t])}return e.split===t.split&&e.children.length===t.children.length&&e.children.every((e,r)=>n(e,t.children[r]))&&e.sizes.every((e,n)=>Math.abs(e-(t.sizes[n]??NaN))<.001)};return n(e.root,t.root)}function N_(e,t,n=null){let r=Kg();if(e&&typeof e==`object`&&e.root){let t={},n=0,i=(e,r)=>{if(r>8||!e||typeof e!=`object`)return null;if(`group`in e&&e.group&&Array.isArray(e.group.tabs)){if(n>=8)return null;n+=1;let r=`g${n}`,i=e.group.tabs.filter(e=>typeof e==`string`),a=typeof e.group.active==`string`&&i.includes(e.group.active)?e.group.active:i.at(-1)??null;return t[r]={ids:i,activeId:a},{type:`group`,id:r}}if(`split`in e&&(e.split===`row`||e.split===`column`)){let t=Array.isArray(e.children)?e.children:[],n=[],a=[];return t.forEach((t,o)=>{let s=i(t,r+1);s&&(n.push(s),a.push(Array.isArray(e.sizes)?e.sizes[o]??0:0))}),n.length===0?null:r_({type:`split`,direction:e.split,children:n,sizes:a})}return null},a=i(e.root,0);if(a&&Object.keys(t).length>0){let n=[],i=e=>{e.type===`group`?n.push(e.id):e.children.forEach(i)};i(a),r={root:a,groups:t,focused:n[typeof e.focused==`number`&&Number.isInteger(e.focused)?e.focused:0]??n[0]}}}return T_(r,t,n)}function P_(e){return!e||e.text.length===0&&e.attachments.length===0&&(e.replies?.length??0)===0}function F_(e,t){if(!e||e.text!==t.text||e.attachments.length!==t.attachments.length)return!1;let n=e.replies??[],r=t.replies??[];return n.length!==r.length||!n.every((e,t)=>e===r[t])?!1:e.attachments.every((e,n)=>e===t.attachments[n])}function I_(e,t,n){if(P_(n)){if(e[t]===void 0)return e;let{[t]:n,...r}=e;return r}return F_(e[t],n)?e:{...e,[t]:n}}function L_(e,t){let n=Object.keys(e);if(n.length===0)return e;let r=new Set(t);if(n.every(e=>r.has(e)))return e;let i={};for(let t of n)r.has(t)&&(i[t]=e[t]);return i}var R_=new Map;function z_(e,t){return R_.set(e,t),()=>{R_.get(e)===t&&R_.delete(e)}}function B_(e){return R_.get(e)?.()??null}var V_=1e5,H_=50;function U_(e,t,n=null){let r=e.drafts[t],i=e.remoteTabs[t],a={id:t,kind:i?`remote`:r?`draft`:`session`};i&&(a.hostId=i.hostId,a.hostName=i.hostName),r&&(a.draft={title:r.title,providerId:r.providerId,model:r.model,variantId:r.variantId,permissionMode:r.permissionMode,...r.posture?{posture:r.posture}:{},projectDir:r.projectDir,projectId:r.projectId});let o=(n??e.unsent[t])?.text??``;o.length>0&&(a.unsentText=o.slice(0,V_));let s=e.files[t];if(s&&s.open.length>0){let e=s.open.slice(0,H_);a.files={open:e,active:s.active&&e.includes(s.active)?s.active:null}}return a}function W_(e){let{unsentText:t,files:n,...r}=e;return r}var G_=[`default`,`acceptEdits`,`plan`,`auto`,`dontAsk`,`bypassPermissions`];function K_(e,t=Date.now()){let n=e.draft??{},r=e=>typeof e==`string`&&e.length>0?e:null,i=r(n.permissionMode);return{...hg(e.id,t),title:r(n.title),providerId:r(n.providerId),model:r(n.model),variantId:r(n.variantId),permissionMode:i&&G_.includes(i)?i:null,...M(n.posture)?{posture:n.posture}:{},projectDir:r(n.projectDir),projectId:r(n.projectId)}}var q_=`application/x-oonacode-tab`,J_=null;function Y_(e,t){if(J_={...t},e){e.effectAllowed=`move`;try{e.setData(q_,t.tabId)}catch{}}}function X_(){return J_}function Z_(){let e=J_;return J_=null,e}function Q_(e){if(J_)return!0;let t=e?.types;if(!t)return!1;for(let e=0;e<t.length;e++)if(t[e]===`application/x-oonacode-tab`)return!0;return!1}function $_(e,t){return e.clientX<0||e.clientY<0||e.clientX>t.innerWidth||e.clientY>t.innerHeight}function ev(e,t,n){let r=e.getAttribute(`data-editor-group`);if(!r)return null;let i=e.querySelector(`[data-tab-strip]`),a=i?.getBoundingClientRect();if(i&&a&&a.height>0&&n>=a.top&&n<=a.bottom)return{groupId:r,zone:`center`,index:k_(Array.from(i.querySelectorAll(`[data-tab-group="${nv(r)}"]`)).filter(e=>e.hasAttribute(`data-tab-id`)).map(e=>e.getBoundingClientRect()),t)};let o=e.querySelector(`[data-group-body]`)??e;return e.getAttribute(`data-compact`)===`true`?{groupId:r,zone:`center`}:{groupId:r,zone:O_(o.getBoundingClientRect(),t,n)}}function tv(e,t,n){let r=(typeof e.elementFromPoint==`function`?e.elementFromPoint(t,n):null)?.closest(`[data-editor-group]`)??null;return r?ev(r,t,n):null}function nv(e){return typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/["\\]/g,`\\$&`)}function rv(e,t){return e?`From \`${e}\`:`:t===`assistant`?`From your earlier reply:`:t===`user`?`From my earlier message:`:t&&typeof t==`object`&&t.tool?`From the output of ${t.tool}:`:null}var iv=/^From (?:`[^`]+`|your earlier reply|my earlier message|the output of .+):$/,av=`Replying to an earlier part of this conversation — the quoted lines are from the chat history above, not new input:`;function ov(e,t=null,n=null){let r=e.replace(/\r\n?/g,`
|
|
@@ -151,13 +151,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
151
151
|
`)}):null]})}),nL=(0,v.memo)(function({item:e}){return(0,W.jsxs)(`div`,{className:`my-3 flex items-center gap-2 text-[11px] text-fg-faint`,children:[(0,W.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,W.jsxs)(`span`,{children:[`Context compacted (`,e.trigger,`) · `,ig(e.preTokens),e.postTokens===null?``:` → ${ig(e.postTokens)}`,` tokens`]}),(0,W.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}),rL=(0,v.memo)(function({item:e,modelNameOf:t}){let[n,r]=(0,v.useState)(!1),i=e.refusal,a=e=>e?t(e):null,o=e.subtype===Mm,s=a(i?.originalModel)??`The model`,c;if(o){let e=a(i?.fallbackModel)??`another model`;c=i?.scope===`local`?`${s}’s safeguards flagged a subagent’s request — ${e} answered it instead`:`${s}’s safeguards flagged this message — ${e} answers instead, for the rest of this run`}else{let t=a(e.refusalBefore?.originalModel);c=t?`${s} refused too, after ${t}’s safeguards had — there is no other model to fall back to`:`${s}’s safeguards refused this message — there is no model to fall back to`}let l=o?e.text||i?.explanation||``:i?.explanation||e.text||``;return(0,W.jsxs)(`div`,{className:U(`my-2 rounded-md border text-xs`,o?`border-warn/40 bg-warn-soft text-warn`:`border-danger/40 bg-danger-soft text-danger`),"data-testid":o?`safeguard-fallback`:`safeguard-no-fallback`,role:o?`note`:`alert`,title:sg(e.timestamp),children:[(0,W.jsxs)(`button`,{type:`button`,"aria-expanded":l?n:void 0,disabled:!l,onClick:()=>r(e=>!e),className:`flex w-full items-start gap-1.5 px-2.5 py-1.5 text-left disabled:cursor-default`,children:[(0,W.jsx)(q.Shield,{className:`mt-px w-3.5 h-3.5 flex-shrink-0`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 font-medium`,children:c}),i?.category?(0,W.jsx)(`span`,{className:`flex-shrink-0 rounded border border-current/30 px-1 text-[10px] uppercase tracking-wide opacity-80`,"data-testid":`safeguard-category`,title:`The safeguard's category`,children:i.category}):null,l?(0,W.jsx)(q.Chevron,{open:n,className:`mt-px w-3.5 h-3.5 flex-shrink-0 opacity-70`}):null]}),n&&l?(0,W.jsx)(`div`,{className:`border-t border-current/20 px-3 py-2 text-fg-muted`,children:(0,W.jsx)(iL,{text:l})}):null]})}),iL=(0,v.memo)(function({text:e}){return(0,W.jsx)(aN,{text:e})}),aL=(0,v.memo)(function({item:e,modelNameOf:t}){if(e.subtype===`chat-notice`&&e.chatMarker)return(0,W.jsx)(dP,{marker:e.chatMarker,timestamp:e.timestamp});if(e.subtype===`new-chat`&&e.newChat)return(0,W.jsx)(pP,{chat:e.newChat,timestamp:e.timestamp});if(e.subtype===`safeguard-fallback`||e.subtype===`safeguard-no-fallback`)return(0,W.jsx)(rL,{item:e,modelNameOf:t});let n=e.subtype===`local-command`||e.subtype===`local-command-error`,r=e.subtype===`command`;return e.subtype===`rewind`?(0,W.jsxs)(`div`,{className:`my-3 flex items-center gap-2 text-[11px] text-fg-faint`,"data-testid":`rewind-boundary`,children:[(0,W.jsx)(`span`,{className:`h-px flex-1 bg-border`}),(0,W.jsxs)(`span`,{className:`whitespace-nowrap rounded border border-border bg-surface-2 px-2 py-0.5`,children:[`⟲ `,e.text]}),(0,W.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}):(0,W.jsx)(`div`,{className:U(`my-2 rounded-md border border-border bg-surface-2 px-3 py-1.5 text-xs`,e.subtype===`local-command-error`?`text-danger`:n?`text-fg`:`text-fg-muted`),"data-testid":n||r?`command-echo`:void 0,children:r?(0,W.jsx)(`span`,{className:`font-mono`,children:e.text}):n&&e.text.includes(`
|
|
152
152
|
`)?(0,W.jsx)(oL,{text:e.text}):(0,W.jsx)(`span`,{className:U(`pre-wrap`,n&&`font-semibold`),children:n?iu(e.text):e.text})})}),oL=(0,v.memo)(function({text:e}){let t=(0,v.useMemo)(()=>iu(e),[e]);return sL(t)?(0,W.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,"data-testid":`command-output-markdown`,children:(0,W.jsx)(aN,{text:t})}):(0,W.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre font-mono text-[11px] leading-snug`,"data-testid":`command-output-text`,children:t})});function sL(e){return/^#{1,6} /m.test(e)||/^\|[\s:|-]*-{3,}[\s:|-]*\|?\s*$/m.test(e)}var cL=(0,v.memo)(function({item:e}){let t=lL(e.message);return(0,W.jsxs)(`div`,{className:`my-2 flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,title:t===e.message?void 0:e.message,children:[(0,W.jsx)(q.Alert,{className:`mt-0.5 w-3.5 h-3.5`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`font-mono`,children:e.code}),`: `,t]})]})});function lL(e){let t=uL(e),n=t.indexOf(`{"type":"error"`);if(n>=0)try{let e=JSON.parse(t.slice(n)).error?.message;typeof e==`string`&&e.trim()&&(t=`${t.slice(0,n).trim()} ${e.trim()}`.trim())}catch{}return t}function uL(e){return e.replace(/<\/?tool_use_error>/g,``).trim()}function dL({label:e,lastFrameAt:t=null}){let n=gL(t),r=n!==null&&n>=3e4,i=n!==null&&n>=3e5;return(0,W.jsxs)(`div`,{className:`my-2 flex flex-wrap items-center gap-2 text-xs text-fg-muted`,"data-testid":`working`,role:`status`,"aria-live":`polite`,children:[(0,W.jsx)(q.Spinner,{className:`w-3.5 h-3.5`}),(0,W.jsx)(`span`,{className:`blink`,children:e}),(0,W.jsxs)(`span`,{className:`thinking-dots`,"aria-hidden":!0,children:[(0,W.jsx)(`span`,{children:`.`}),(0,W.jsx)(`span`,{children:`.`}),(0,W.jsx)(`span`,{children:`.`})]}),r&&t!==null?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{"data-testid":`working-quiet`,"aria-hidden":`true`,className:i?`inline-flex items-center gap-1 text-fg`:void 0,title:`Last activity at ${vL.format(t)}`,children:[i?(0,W.jsx)(q.Alert,{className:`h-3.5 w-3.5 shrink-0 text-warn`}):null,`· nothing from the agent for ${rg(n)}`,i?` — it may be stuck: press Stop, then send a message to continue`:``]}),(0,W.jsx)(`span`,{className:`sr-only`,"data-testid":`working-quiet-sr`,children:i?`Nothing from the agent for over five minutes. It may be stuck: press Stop, then send a message to continue.`:`Nothing from the agent for over thirty seconds.`})]}):null]})}function fL(e,t){return e.item.id===t||e.children.some(e=>fL(e,t))}function pL(e){if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(()=>e());return()=>cancelAnimationFrame(t)}let t=setTimeout(e,16);return()=>clearTimeout(t)}function mL(e){let t=e?.pendingPermissions??[];return t.length===0?null:t.some(e=>e.toolName===`AskUserQuestion`)?`answer`:`approval`}function hL(e){return!e||e.status!==`running`||e.pendingPermissions.length>0?null:e.lastFrameAt}function gL(e){let[t,n]=(0,v.useState)(()=>Date.now());return(0,v.useEffect)(()=>{if(e===null)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),e===null?null:Math.max(0,t-e)}var _L=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`}),vL=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),yL=new Intl.DateTimeFormat(void 0,{dateStyle:`full`,timeStyle:`long`}),bL=new Intl.DateTimeFormat(void 0,{weekday:`long`,day:`numeric`,month:`long`}),xL=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function SL(e){let t=Date.parse(e);if(!Number.isFinite(t))return null;let n=new Date(t);return`${n.getFullYear()}-${n.getMonth()+1}-${n.getDate()}`}function CL(e,t=new Date){let n=SL(e);if(n===null)return``;if(n===SL(t.toISOString()))return`Today`;let r=new Date(t);if(r.setDate(r.getDate()-1),n===SL(r.toISOString()))return`Yesterday`;let i=Date.parse(e);return(new Date(i).getFullYear()===t.getFullYear()?bL:xL).format(i)}function wL(){let[e,t]=(0,v.useState)(0),n=SL(new Date().toISOString())??``;return(0,v.useEffect)(()=>{let e=new Date,n=new Date(e.getFullYear(),e.getMonth(),e.getDate()+1,0,0,1),r=setTimeout(()=>t(e=>e+1),n.getTime()-e.getTime());return()=>clearTimeout(r)},[n,e]),n}var TL=(0,v.memo)(function({iso:e}){let t=e?Date.parse(e):NaN,n=Number.isFinite(t);return(0,W.jsx)(`span`,{"data-testid":`item-time`,className:`mb-2 min-w-11 shrink-0 select-none whitespace-nowrap text-right text-[10px] tabular-nums text-fg-muted`,title:n?yL.format(t):void 0,children:n?_L.format(t):``})}),EL=(0,v.memo)(function({iso:e}){return(0,W.jsx)(`div`,{className:`my-3 flex justify-center`,"data-testid":`day-separator`,children:(0,W.jsx)(`span`,{className:`rounded-full border border-border bg-surface px-2.5 py-0.5 text-[11px] text-fg-muted`,children:CL(e)})})});function DL({hasProject:e}){let{actions:t}=G();return(0,W.jsxs)(`div`,{className:`py-10 text-center`,"data-testid":`draft-intro`,children:[(0,W.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`Send a message to start this chat.`}),e?null:(0,W.jsxs)(`div`,{className:`mx-auto mt-2 max-w-md text-xs text-fg-faint`,children:[`It runs in a folder OonaCode makes for it. The agent can still read and write anywhere on this PC — it just asks first.`,` `,(0,W.jsx)(`button`,{type:`button`,className:`underline hover:text-fg`,onClick:()=>t.openDialog(`project`),children:`Use one of your project folders`}),` `,`to load its `,(0,W.jsx)(`code`,{children:`CLAUDE.md`}),` and settings instead.`]})]})}function OL(e,t,n){return e===`waiting_permission`&&!n?`Waiting for your approval`:t??`thinking`}var kL={open:!1,query:``,currentId:null,focusSeq:0},AL=[];function jL(){let{state:e,actions:t,api:n}=G(),r=ky(),i=Ay(),a=Dy().sessionId,o=a?e.remote.tabs[a]!==void 0:!1,s=r?.init?.cwd??i?.cwd??null,c=e.info?.homeDir??null,l=e.info?.platform??null,u=(0,v.useMemo)(()=>n.statLocalPaths?new PM({stat:(e,t)=>n.statLocalPaths(e,t)}):null,[n]),d=r?.status===`running`||r?.status===`waiting_permission`,f=(0,v.useRef)(d);return(0,v.useEffect)(()=>{f.current&&!d&&a&&!o&&u?.invalidate(a),f.current=d},[d,a,o,u]),(0,v.useMemo)(()=>{let e=typeof window<`u`?window.oonacode??null:null,r=n.grantLocalFile?.bind(n)??null;return{sessionId:a,cwd:s,homeDir:o?null:c,platform:o?null:l,remote:o,grant:r,openInViewer:o?null:e=>t.openFile(e,a??void 0),bridge:e&&(e.openPath||e.showItemInFolder)?e:null,notify:(e,n)=>t.toast(e,n),stat:o?null:u}},[a,s,o,c,l,n,t,u])}function ML(){let e=jL(),t=NL();return(0,W.jsx)(IM.Provider,{value:e,children:(0,W.jsx)(oP.Provider,{value:t,children:(0,W.jsx)(PL,{})})})}function NL(){let{state:e,actions:t}=G(),n=Dy().sessionId,r=n?e.chatConversations[n]:void 0,i=e.connection.hostId??e.info?.hostId??null;return(0,v.useMemo)(()=>{let e=new Map((r??[]).map(e=>[e.id,e.title?.trim()||null])),a=Ld(r);return{openChat:e=>t.selectSession(e),openConversation:e=>t.openConversations(e),conversationTitle:t=>e.get(t)??null,canOpenChat:(e,t)=>e!==n&&(i===null||t===i),answerState:e=>a.get(e)??null}},[t,r,n,i])}function PL(){let{state:e,actions:t,dispatch:n}=G(),r=ky(),i=Ay(),a=jy(),o=(0,v.useRef)(null),[s,c]=(0,v.useState)(!0),l=(0,v.useRef)(null),{sessionId:u,focused:d}=Dy(),f=u&&!a?e.transcriptLoading[u]===!0:!1,p=e.prefs.showReasoningSummaries,m=r?.items,{flow:h,queued:g}=(0,v.useMemo)(()=>II(m),[m]),_=(0,v.useRef)([]),y=(0,v.useMemo)(()=>{let e=h?Fh(h,_.current):[];return _.current=e,e},[h]),b=u?e.windows[u]:void 0,x=(0,v.useMemo)(()=>b??hv(e.prefs.transcriptWindowSize),[b,e.prefs.transcriptWindowSize]),S=(0,v.useMemo)(()=>xv(y,x),[y,x]),[C,w]=(0,v.useState)(kL),T=(0,v.useMemo)(()=>C.open&&h?xI(h,C.query,{showReasoning:p}):AL,[h,C.open,C.query,p]),E=C.currentId===null?-1:T.findIndex(e=>e.id===C.currentId),D=E>=0?T[E]??null:null,O=(0,v.useCallback)(()=>w(e=>({...e,open:!0,focusSeq:e.focusSeq+1})),[]),k=(0,v.useCallback)(()=>w(kL),[]),A=(0,v.useCallback)(e=>w(t=>({...t,query:e,currentId:null})),[]),j=(0,v.useRef)(null),M=(0,v.useCallback)(e=>{j.current=null,w(t=>{let n=Ae(t.currentId===null?-1:T.findIndex(e=>e.id===t.currentId),e,T.length);return{...t,currentId:T[n]?.id??null}})},[T]);(0,v.useEffect)(()=>{if(!C.open||C.currentId!==null&&T.some(e=>e.id===C.currentId))return;let e=T.length>0?T[T.length-1]?.id??null:null;e!==C.currentId&&w(t=>({...t,currentId:e}))},[T,C.open,C.currentId]),(0,v.useEffect)(()=>{if(!u||!d||typeof window>`u`)return;let e=e=>{!(e.ctrlKey||e.metaKey)||e.altKey||e.key!==`f`&&e.key!==`F`||(e.preventDefault(),O())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u,d,O]);let ee=(0,v.useMemo)(()=>vP(),[]),N=D?[...D.path,D.id].join(`
|
|
153
153
|
`):``;(0,v.useLayoutEffect)(()=>{ee.set(new Set(N===``?[]:N.split(`
|
|
154
|
-
`)))},[N,ee]),(0,v.useEffect)(()=>{if(!D||!u){j.current=null;return}if(j.current===D.id)return;let e=y.findIndex(e=>e.item.id===D.rootId);if(e<0)return;if(e<S.start){t.revealTranscript(u,y.length-e,y.length);return}let n=o.current;if(n)return pL(()=>{let e=n.querySelector(cI(D.id))??n.querySelector(cI(D.rootId));if(!(e instanceof HTMLElement))return;j.current=D.id,c(!1);let t=hI(e,C.query);t?gI(t,n):typeof e.scrollIntoView==`function`&&e.scrollIntoView({block:`center`})})},[D,y,S.start,u,t,C.query]);let P=e.jumpTo,F=(0,v.useRef)(P?.seq??0);(0,v.useEffect)(()=>{if(!P||!u||P.sessionId!==u||P.seq<=F.current)return;let e=y.findIndex(e=>fL(e,P.itemId));if(e<0){F.current=P.seq;return}if(e<S.start){t.revealTranscript(u,y.length-e,y.length);return}let n=o.current;if(n)return F.current=P.seq,pL(()=>{let t=n.querySelector(cI(P.itemId))??n.querySelector(cI(y[e].item.id));t instanceof HTMLElement&&(c(!1),typeof t.scrollIntoView==`function`&&t.scrollIntoView({block:`center`,behavior:`smooth`}),t.classList.add(`chat-jump-flash`),setTimeout(()=>t.classList.remove(`chat-jump-flash`),1600))})},[P,y,S.start,u,t]);let ne=(0,v.useCallback)(e=>{let n=(e.target instanceof Element?e.target:null)?.closest(`[data-testid="user-reply-quote"]`),i=r?.items;if(!n||!u||!i)return;let a=n.closest(`[data-item-id]`)?.getAttribute(`data-item-id`)??null,o=a?i.findIndex(e=>e.id===a):-1,s=mv((o>=0?i.slice(0,o):i).map(e=>({id:e.id,text:wI(e)})),n.getAttribute(`data-quote`)??``);s&&t.jumpToItem(u,s)},[r?.items,u,t]);(0,v.useEffect)(()=>{let e=o.current;if(!C.open||!e){mI();return}let t=()=>pI(e,T,D?.id??null,C.query);t();let n=pL(t);return()=>{n(),mI()}},[C.open,C.query,T,D,S.items]);let re=D?.id??null,[L,ie]=(0,v.useState)(null),R=sx(),ae=u!==null&&!R,oe=(0,v.useCallback)(()=>ie(null),[]),se=(0,v.useCallback)(e=>{if(e.shiftKey)return;let t=o.current;if(!t)return;let n=e.target instanceof Element?e.target:null;n?.closest(`input, textarea, select, [contenteditable="true"]`)||(e.preventDefault(),ie({at:{x:e.clientX,y:e.clientY},target:CI(n,t)}))},[]),ce=(0,v.useMemo)(()=>{let e=L?.target.itemId;if(!e||!r)return null;let t=r.index.get(e);return t===void 0?null:r.items[t]??null},[L,r]),le=(0,v.useMemo)(()=>{if(!L)return[];let{target:e}=L,n=e=>void XM(e).then(e=>t.toast(e?`success`:`error`,e?`Copied`:`Could not copy to the clipboard`)),r={reply:()=>{if(!u)return;let n=e.selection.trim()===``?lv(ce?wI(ce):``):e.selection;if(n.trim()===``)return;let r=ce?.kind===`tool`?uv(ce.input):null,i=ce?.kind===`assistant`||ce?.kind===`thinking`?`assistant`:ce?.kind===`user`?`user`:ce?.kind===`tool`?{tool:ce.name}:null;t.quoteIntoComposer(u,ov(n,r,i),{preview:dv(n),itemId:ce?.id??null})},copy:()=>n(e.selection),"copy-code":()=>n(e.code??``),"copy-link":()=>n(e.link??``),"open-link":()=>{let t=DI(e.link);if(!t)return;let n=typeof window<`u`?window.oonacode:void 0;n?.openExternal?n.openExternal(t):window.open(t,`_blank`,`noopener,noreferrer`)},"copy-item":()=>n(ce?wI(ce):``),find:()=>w(t=>({...t,open:!0,query:e.selection.trim(),currentId:null,focusSeq:t.focusSeq+1})),"select-block":()=>{let t=e.itemId?o.current?.querySelector(cI(e.itemId)):null,n=t?.firstElementChild??t,r=window.getSelection();if(!n||!r)return;let i=document.createRange();i.selectNodeContents(n),r.removeAllRanges(),r.addRange(i)}},i={reply:(0,W.jsx)(q.Reply,{className:`h-3.5 w-3.5`}),copy:(0,W.jsx)(q.Copy,{className:`h-3.5 w-3.5`}),"copy-code":(0,W.jsx)(q.Copy,{className:`h-3.5 w-3.5`}),"copy-item":(0,W.jsx)(q.Copy,{className:`h-3.5 w-3.5`}),"copy-link":(0,W.jsx)(q.Globe,{className:`h-3.5 w-3.5`}),"open-link":(0,W.jsx)(q.Globe,{className:`h-3.5 w-3.5`}),find:(0,W.jsx)(q.Search,{className:`h-3.5 w-3.5`})};return OI(e,ce,{canReply:ae}).map(e=>({key:e.key,label:e.label,hint:e.hint,disabled:e.disabled,separated:e.separated,icon:i[e.key]??(0,W.jsx)(`span`,{}),testId:`chat-menu-${e.key}`,onSelect:r[e.key]}))},[L,ce,t,u,ae]),ue=(0,v.useCallback)(()=>{if(!u||!S.hasMore)return;let e=o.current;e&&(l.current=e.scrollHeight-e.scrollTop),t.growTranscript(u,S.total)},[u,S.hasMore,S.total,t]),[de,fe]=(0,v.useState)(null),pe=(0,v.useRef)(null),me=(0,v.useCallback)(()=>{let e=o.current;if(!e){fe(null);return}let t=e.querySelectorAll(`[${kI}]`),n=e.getBoundingClientRect().top,r=pe.current?.offsetHeight??0,i=AI(t.length,e=>t[e].getBoundingClientRect().top-n,r),a=i<0?null:t[i].getAttribute(kI);fe(e=>e===a?e:a)},[]),he=(0,v.useCallback)(()=>{let e=o.current;if(!e)return;let n={scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight},r=Sv(n);c(r),me(),r&&u?t.trimTranscript(u):Cv(n)&&S.hasMore&&ue()},[u,S.hasMore,ue,t,me]),ge=(0,v.useCallback)(()=>{let e=o.current;if(!e||!de)return;let t=e.querySelector(cI(de));if(!(t instanceof HTMLElement))return;let n=t.getBoundingClientRect().top-e.getBoundingClientRect().top;c(!1),e.scrollTo({top:e.scrollTop+n-(pe.current?.offsetHeight??0)})},[de]),_e=(0,v.useCallback)(()=>{let e=o.current;e&&e.scrollTo({top:e.scrollHeight}),c(!0),u&&t.trimTranscript(u)},[u,t]);(0,v.useLayoutEffect)(()=>{let e=o.current;if(e){if(l.current!==null){e.scrollTop=Math.max(0,e.scrollHeight-l.current),l.current=null;return}s&&(e.scrollTop=e.scrollHeight)}},[S.items,s]);let ve=(0,v.useRef)(s);ve.current=s;let ye=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=o.current;if(!e||typeof ResizeObserver>`u`)return;let t=ye.current,n=e.clientWidth,r=e.clientHeight,i=t?.offsetHeight??0,a=new ResizeObserver(()=>{let a=e.clientWidth===n&&e.clientHeight===r,o=(t?.offsetHeight??0)===i;a&&o||(n=e.clientWidth,r=e.clientHeight,i=t?.offsetHeight??0,ve.current&&(e.scrollTop=e.scrollHeight))});return a.observe(e),t&&a.observe(t),()=>a.disconnect()},[u]),(0,v.useLayoutEffect)(()=>{me()},[S.items,me]);let be=r?.lastLocalPromptId??null;(0,v.useEffect)(()=>{be!==null&&_e()},[be,_e]),(0,v.useEffect)(()=>{c(!0),l.current=null,fe(null),w(kL)},[u]);let xe=e.chatSearchRequest,Se=(0,v.useRef)(xe?.seen?xe.seq:0);(0,v.useEffect)(()=>{let e=xe;!e||!u||e.sessionId!==u||e.seq<=Se.current||(Se.current=e.seq,j.current=null,w(t=>({open:!0,query:e.query,currentId:null,focusSeq:t.focusSeq+1})),n({type:`chat_search_request_seen`,seq:e.seq}))},[xe,u,n]);let Ce=r?.hasSubagentItems===!0||i?.hasSubagents===!0||Object.keys(r?.agentActivity??{}).length>0,we=(0,v.useMemo)(()=>{let e=new Map;if(!Ce)return e;for(let t of LN(h??[]))e.set(t.agentId,t.name);return e},[h,Ce]),Te=(0,v.useRef)(we);Te.current=we;let Ee=(0,v.useRef)(r);Ee.current=r;let De=(0,v.useCallback)(e=>{let t=Ee.current,n=t?.index.get(e);return n!==void 0&&t?.items[n]?.kind===`tool`},[]),Oe=(0,v.useCallback)(e=>Te.current.get(e)??null,[]),ke=(0,v.useRef)(e.providers);ke.current=e.providers;let je=(0,v.useCallback)(e=>If(e,ke.current),[]),Me=wL(),Ne=(0,v.useCallback)((e,n=!1)=>{let r=[],i=null;for(let t of YI(PI(FI(e,De)))){let e=`run`in t?t.run[0]:`orphans`in t?t.orphans[0]:t.item,o=`run`in t?t.run[t.run.length-1].timestamp:`orphans`in t?t.orphans[t.orphans.length-1].timestamp:t.item.timestamp;if(n&&o){let t=SL(o);t!==null&&t!==i&&(r.push((0,W.jsx)(EL,{iso:o,today:Me},`day:${e.id}`)),i=t)}let s=a(t);s!==null&&r.push(s)}return r;function a(e){if(`orphans`in e){let t=e.orphans[0];return(0,W.jsxs)(`div`,{[sI]:t.id,className:`flex items-end gap-2`,children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,W.jsx)(ZI,{items:e.orphans})}),(0,W.jsx)(TL,{iso:e.orphans[e.orphans.length-1].timestamp})]},`orphans:${t.id}`)}if(`run`in e){let t=e.run[0];return(0,W.jsxs)(`div`,{[sI]:t.id,className:`flex items-end gap-2`,children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,W.jsx)(HP,{items:e.run,agentNameOf:Oe})}),(0,W.jsx)(TL,{iso:e.run[e.run.length-1].timestamp})]},`run:${t.id}`)}let r=e.item,i=(()=>{switch(r.kind){case`user`:return(0,W.jsx)(VI,{item:r},r.id);case`assistant`:return(0,W.jsx)(qI,{item:r},r.id);case`thinking`:return p?(0,W.jsx)(PP,{item:r},r.id):null;case`tool`:return r.name===`AskUserQuestion`?(0,W.jsx)(NI,{item:r},r.id):(0,W.jsx)(NP,{node:e,renderChildren:Ne},r.id);case`result`:return(0,W.jsx)(tL,{item:r},r.id);case`compact`:return(0,W.jsx)(nL,{item:r},r.id);case`permission`:return r.status===`pending`?null:(0,W.jsx)(UP,{item:r,agentName:r.request.agentId?Oe(r.request.agentId):null,onDecide:e=>t.respondPermission(r.request.requestId,e,u??void 0)},r.id);case`system`:return(0,W.jsx)(aL,{item:r,modelNameOf:je},r.id);case`error`:return(0,W.jsx)(cL,{item:r},r.id)}})();if(i===null)return null;let a=r.kind===`user`&&BI(r);return(0,W.jsxs)(`div`,{[sI]:r.id,...n&&a?{[kI]:r.id}:{},className:U(`flex items-end gap-2`,r.id===re&&`chat-search-current`),children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:i}),a?null:(0,W.jsx)(TL,{iso:r.timestamp})]},r.id)}},[t,p,re,Oe,De,Me,je,u]),z=(0,v.useMemo)(()=>(Qb(u),Ne(S.items,!0)),[Ne,S.items,u]),Pe=(0,v.useMemo)(()=>{if(de===null||!h)return null;let e=h.find(e=>e.id===de);if(!e||e.kind!==`user`)return null;let t=sv(e.text);return jI(t&&t.reply!==``?t.reply:e.text)},[h,de]);if(!u)return(0,W.jsx)(Yy,{icon:(0,W.jsx)(q.Edit,{className:`w-8 h-8`}),title:`No session selected`,hint:`Open a chat tab or pick a session from the sidebar. Sessions run on this PC and are stored in the host's SQLite database.`,action:(0,W.jsxs)(J,{variant:`primary`,onClick:()=>t.newTab(),children:[(0,W.jsx)(q.Plus,{className:`w-4 h-4`}),` New chat`]})});let Fe=r?.init,Ie=r?.status===`running`||r?.status===`waiting_permission`,Le=mL(r),Re=Le===`answer`?`Waiting for your answer`:Le===`approval`?`Waiting for your approval`:OL(r?.status,r?.statusText,e.prefs.autoAcceptPermissions&&!te(I(i)));return(0,W.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[C.open?(0,W.jsx)(oI,{query:C.query,index:E,count:T.length,focusSeq:C.focusSeq,onQuery:A,onStep:M,onClose:k}):null,(0,W.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[Pe===null?null:(0,W.jsx)(`div`,{ref:pe,className:`pointer-events-none absolute inset-x-0 top-0 z-10 px-3 pr-12 pt-2 sm:px-6 sm:pr-14`,children:(0,W.jsxs)(`button`,{type:`button`,onClick:ge,title:`Go to this message`,"data-testid":`pinned-user-message`,"data-pinned-id":de,className:`pointer-events-auto flex w-full items-center gap-2 rounded-lg border border-border bg-surface px-3 py-1.5 text-left text-xs text-fg-muted shadow-md hover:bg-surface-2 hover:text-fg`,children:[(0,W.jsx)(q.User,{className:`h-3 w-3 shrink-0`}),(0,W.jsx)(`span`,{className:`truncate`,children:Pe})]})}),(0,W.jsx)(`div`,{ref:o,onScroll:he,onContextMenu:se,onClick:ne,className:`flex-1 overflow-y-auto px-3 py-3 sm:px-6`,"data-testid":`transcript`,children:(0,W.jsx)(yP.Provider,{value:ee,children:(0,W.jsxs)(`div`,{ref:ye,className:`w-full`,children:[a&&a.projectDir?(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 text-[11px] text-fg-faint`,children:[(0,W.jsx)(q.Folder,{className:`w-3 h-3`}),(0,W.jsx)(`span`,{className:`font-mono`,children:a.projectDir}),(0,W.jsx)(Z,{tone:`accent`,children:`project attached`})]}):null,i||Fe?(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 text-[11px] text-fg-faint`,children:[(0,W.jsx)(q.Folder,{className:`w-3 h-3`}),(0,W.jsx)(`span`,{className:`font-mono`,children:Fe?.cwd??i?.cwd}),Fe?.model??i?.model?(0,W.jsx)(Z,{children:zs(Fe?.model??i?.model??``)}):null,i?.providerId?(0,W.jsx)(Z,{tone:`accent`,children:i.providerId}):null,(0,W.jsx)(Z,{children:Fe?.permissionMode??i?.permissionMode??`default`}),Fe?(0,W.jsxs)(`span`,{children:[Fe.tools.length,` tools · engine `,Fe.claudeCodeVersion]}):null]}):null,S.hasMore?(0,W.jsx)(`div`,{className:`mb-2 flex items-center justify-center`,"data-testid":`window-more`,children:(0,W.jsxs)(J,{size:`sm`,onClick:ue,children:[(0,W.jsx)(q.ArrowDown,{className:`w-3 h-3 rotate-180`}),` Load `,100,` `,`older lines (`,S.hiddenAbove,` hidden)`]})}):null,f&&(!r||r.items.length===0)?(0,W.jsxs)(`div`,{className:`flex items-center gap-2 py-8 text-sm text-fg-muted`,children:[(0,W.jsx)(q.Spinner,{}),` Loading transcript…`]}):null,!f&&(r?.items.length??0)===0?a?(0,W.jsx)(DL,{hasProject:a.projectDir!==null}):r?(0,W.jsx)(`div`,{className:`py-10 text-center text-sm text-fg-muted`,children:`Send a message to start this session.`}):null:null,z,Ie?(0,W.jsx)(dL,{label:Re,lastFrameAt:hL(r)}):null,(0,W.jsx)(`div`,{className:`h-2`})]})})}),(0,W.jsx)(nx,{open:L!==null,at:L?.at??{x:0,y:0},items:le,onClose:oe,label:`Chat`,testId:`chat-context-menu`})]}),(0,W.jsx)(LI,{items:g,onCancel:e=>{e.requestId&&t.cancelQueued(e.requestId,u??void 0)},onSendNow:e=>e.requestId?t.sendQueuedNow(e.requestId,u??void 0):Promise.resolve(null)}),C.open?null:(0,W.jsx)(Y,{label:`Find in this chat (Ctrl+F)`,onClick:O,className:`absolute right-5 top-2 border border-border bg-surface shadow-md`,"data-testid":`chat-search-open`,children:(0,W.jsx)(q.Search,{className:`w-3.5 h-3.5`})}),s?null:(0,W.jsxs)(`button`,{type:`button`,onClick:_e,className:`absolute bottom-3 left-1/2 -translate-x-1/2 rounded-full border border-border bg-surface px-3 py-1 text-xs shadow-md hover:bg-surface-2`,"data-testid":`chat-jump-latest`,children:[(0,W.jsx)(q.ArrowDown,{className:`mr-1 inline w-3 h-3`}),` Jump to latest`]})]})}function FL(e){return(e/1048576).toFixed(e>=104857600?0:1)+` MB`}function IL(e){switch(e.phase){case`download`:return e.totalBytes?`Downloading the coding engine (v${e.version}) — ${FL(e.receivedBytes)} of ${FL(e.totalBytes)}…`:`Downloading the coding engine (v${e.version}) — ${FL(e.receivedBytes)}…`;case`verify`:return`Verifying the coding engine…`;case`extract`:return`Unpacking the coding engine…`;case`failed`:return`The coding engine could not be downloaded: ${e.error??`unknown error`}. The next message tries again.`;default:return null}}function LL(){let{state:e}=G(),t=e.engineDownload;if(!t)return null;let n=IL(t);if(!n)return null;let r=t.phase===`failed`,i=t.phase===`download`&&t.totalBytes?Math.min(100,Math.round(t.receivedBytes/t.totalBytes*100)):null;return(0,W.jsxs)(`div`,{className:`mx-4 mb-2 rounded-md border px-3 py-2 text-xs `+(r?`border-danger/40 bg-danger/10 text-danger`:`border-accent/40 bg-accent/10 text-fg`),role:`status`,"data-testid":`engine-download`,children:[(0,W.jsx)(`div`,{children:n}),i===null?null:(0,W.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded bg-fg/10`,children:(0,W.jsx)(`div`,{className:`h-full bg-accent`,style:{width:i+`%`}})})]})}var RL=524288,zL={shown:null,bytes:0,pixels:null,error:null,loading:!1},BL=[{value:`source`,label:`Source`},{value:`preview`,label:`Preview`}],VL=`preview`;function HL(){let{state:e,actions:t,api:n}=G(),r=ky(),i=Oy(),a=i?e.files[i]:void 0,o=a?.active??null,s=r?.status===`running`||r?.status===`waiting_permission`,[c,l]=(0,v.useState)({sessionId:i,files:{}}),u=c.sessionId===i?c.files:{},[d,f]=(0,v.useState)(VL),p=e=>{VL=e,f(e)},m=(0,v.useRef)(i);m.current=i;let h=(e,t,n)=>l(r=>{let i=r.sessionId===e?r.files:{};return{sessionId:e,files:{...i,[t]:n(i[t]??zL)}}}),g=async e=>{if(!i)return;let t=i;h(t,e,e=>({...e,loading:!0,error:null}));try{let r=await UL(n,t,e);if(m.current!==t)return;h(t,e,e=>{let t=e.shown!==null&&KL(e.shown,r.shown);return{shown:t?e.shown:r.shown,bytes:r.bytes,pixels:t?e.pixels:null,error:null,loading:!1}})}catch(n){if(m.current!==t)return;let r=n instanceof Error?n.message:String(n);h(t,e,e=>({...e,error:r,loading:!1}))}},_=(e,t,n)=>{if(!i||t<=0||n<=0)return;let r=i;l(i=>{let a=i.sessionId===r?i.files[e]:void 0;return!a||a.pixels?.w===t&&a.pixels.h===n?i:{...i,files:{...i.files,[e]:{...a,pixels:{w:t,h:n}}}}})},y=JSON.stringify(a?.open??[]);(0,v.useEffect)(()=>{let e=new Set(JSON.parse(y));l(t=>{let n=Object.keys(t.files).filter(t=>e.has(t));return n.length===Object.keys(t.files).length?t:{...t,files:Object.fromEntries(n.map(e=>[e,t.files[e]]))}})},[y]);let b=(0,v.useRef)(s);if((0,v.useEffect)(()=>{let e=b.current&&!s;b.current=s,o&&(e||!u[o])&&g(o)},[o,s,i]),!i||!a||!o)return null;let x=u[o],S=x?.shown??null,C=S?.kind===`text`&&S.markdown;return(0,W.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-bg`,"aria-label":`File viewer`,"data-testid":`file-viewer`,children:[(0,W.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 border-b border-border px-3 font-mono text-[11px] text-fg-faint`,children:[(0,W.jsx)(q.File,{className:`w-3.5 h-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:o,children:o}),x?.pixels?(0,W.jsxs)(`span`,{className:`shrink-0`,"data-testid":`file-viewer-pixels`,children:[x.pixels.w,` × `,x.pixels.h]}):null,S?(0,W.jsx)(`span`,{className:`shrink-0`,children:Rj(x.bytes)}):null,C?(0,W.jsx)(`span`,{className:`shrink-0 font-sans`,children:(0,W.jsx)(Jy,{label:`Markdown view`,value:d,options:BL,onChange:p})}):null,(0,W.jsx)(`span`,{className:`shrink-0 rounded bg-surface-2 px-1 text-[10px] uppercase tracking-wide`,children:`read-only`}),(0,W.jsx)(Y,{label:`Re-read this file`,className:`p-1`,onClick:()=>void g(o),"data-testid":`file-viewer-refresh`,children:(0,W.jsx)(q.Refresh,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(Y,{label:`Back to the chat`,className:`p-1`,onClick:()=>t.showChat(),"data-testid":`file-viewer-back`,children:(0,W.jsx)(q.X,{className:`w-3.5 h-3.5`})})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-3 py-2`,"data-testid":`file-viewer-body`,children:(0,W.jsx)(qL,{path:o,loaded:x,markdownMode:d,onPixels:(e,t)=>_(o,e,t)},`${i}\n${o}`)})]})}async function UL(e,t,n){let r=Ej(n),i=e.readSessionFileBytes?async()=>new Uint8Array(await e.readSessionFileBytes(t,n)):null;if(i&&r.mime!==null){let e=await i();return{shown:WL(r.kind,r.mime,e),bytes:e.byteLength}}if(i&&r.kind===`unknown`)return GL(await i(),!1);if(!e.readSessionFile)throw Error(`This host cannot read files — update it.`);let a=await e.readSessionFile(t,n),o=r.kind===`markdown`;return Fj(a)?i?GL(await i(),o):{shown:{kind:`binary`},bytes:a.length}:{shown:{kind:`text`,text:a,markdown:o},bytes:a.length}}function WL(e,t,n){return e===`pdf`?{kind:`pdf`}:{kind:e,blob:new Blob([n],{type:t}),digest:Lj(n)}}function GL(e,t){let n=Mj(e);if(n)return{shown:WL(n.kind,n.mime,e),bytes:e.length};let r=Ij(e);return{shown:r===null?{kind:`binary`}:{kind:`text`,text:r,markdown:t},bytes:e.length}}function KL(e,t){return`digest`in e&&`digest`in t&&e.kind===t.kind&&e.digest===t.digest}function qL({path:e,loaded:t,markdownMode:n,onPixels:r}){if(!t||t.loading&&t.shown===null)return(0,W.jsx)(JL,{children:`Reading…`});if(t.error&&t.shown===null)return(0,W.jsx)(JL,{tone:`danger`,testId:`file-viewer-error`,children:t.error});let i=t.shown;if(!i)return null;let a=pj(e),o=Rj(t.bytes);switch(i.kind){case`image`:return(0,W.jsx)(QL,{blob:i.blob,name:a,onPixels:r},i.digest);case`audio`:case`video`:return(0,W.jsx)($L,{kind:i.kind,blob:i.blob,name:a,size:o},i.digest);case`pdf`:return(0,W.jsxs)(JL,{testId:`file-viewer-pdf`,children:[a,` is a PDF document (`,o,`). The viewer cannot show PDF files — copy its path from the file list to open it in a PDF reader.`]});case`binary`:return(0,W.jsxs)(JL,{testId:`file-viewer-binary`,children:[a,` is not a text file (`,o,`), and not a picture or a clip the viewer can show.`]});case`text`:return(0,W.jsx)(YL,{path:e,text:i.text,markdown:i.markdown,mode:n})}}function JL({children:e,tone:t,testId:n}){return(0,W.jsx)(`div`,{className:t===`danger`?`py-4 text-xs text-danger`:`py-4 text-xs text-fg-faint`,"data-testid":n,children:e})}function YL({path:e,text:t,markdown:n,mode:r}){let i=t.length>RL,a=i?t.slice(0,RL):t;return(0,W.jsxs)(W.Fragment,{children:[n&&r===`preview`?(0,W.jsx)(`div`,{className:`max-w-3xl py-2 text-sm`,"data-testid":`file-viewer-markdown`,children:(0,W.jsx)(aN,{text:a})}):(0,W.jsx)(QM,{code:a,language:wj(e)}),i?(0,W.jsxs)(`div`,{className:`pb-2 text-[11px] text-fg-faint`,children:[`Showing the first `,Rj(RL),` of `,Rj(t.length),`.`]}):null]})}function XL(e){let[t,n]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let t=URL.createObjectURL(e);return n(t),()=>URL.revokeObjectURL(t)},[e]),t}var ZL={backgroundImage:`repeating-conic-gradient(rgb(128 128 128 / 0.22) 0% 25%, transparent 0% 50%)`,backgroundSize:`16px 16px`};function QL({blob:e,name:t,onPixels:n}){let r=XL(e),[i,a]=(0,v.useState)(!1);return i?(0,W.jsxs)(JL,{testId:`file-viewer-image-error`,children:[t,` could not be drawn — it may be damaged, or not the kind of picture its name says.`]}):r?(0,W.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center`,children:(0,W.jsx)(`img`,{src:r,alt:t,draggable:!1,"data-testid":`file-viewer-image`,className:`block max-h-full max-w-full object-contain`,style:ZL,onLoad:e=>n(e.currentTarget.naturalWidth,e.currentTarget.naturalHeight),onError:()=>a(!0)})}):null}function $L({kind:e,blob:t,name:n,size:r}){let i=XL(t),[a,o]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=e=>{e.effectiveDirective===`media-src`&&e.blockedURI.startsWith(`blob`)&&o(`policy`)};return document.addEventListener(`securitypolicyviolation`,e),()=>document.removeEventListener(`securitypolicyviolation`,e)},[]),a)return(0,W.jsx)(JL,{testId:`file-viewer-media-error`,children:a===`policy`?`${n} (${r}) cannot be played in this window: its security policy does not allow audio or video yet.`:`${n} (${r}) cannot be played here: its format or codec is not one Chromium plays.`});if(!i)return null;let s=()=>o(e=>e??`format`);return e===`audio`?(0,W.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center`,children:(0,W.jsx)(`audio`,{src:i,controls:!0,preload:`metadata`,onError:s,"data-testid":`file-viewer-audio`,className:`w-full max-w-xl`})}):(0,W.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center`,children:(0,W.jsx)(`video`,{src:i,controls:!0,preload:`metadata`,onError:s,"data-testid":`file-viewer-video`,className:`block max-h-full max-w-full bg-black`})})}function eR(e,t){return t.scrollWidth<=t.clientWidth||Math.abs(e.deltaX)>Math.abs(e.deltaY)||e.deltaY===0?0:e.deltaMode===1?e.deltaY*16:e.deltaMode===2?e.deltaY*t.clientWidth:e.deltaY}function tR(e){let t=e.split(/[\\/]+/).filter(Boolean);return t[t.length-1]??e}function nR({groupId:e,compact:t=!1,split:n=!1,dropIndex:r=null}={}){let{state:i,actions:a}=G(),o=jy(),s=Ay(),c=i.layout,l=e&&c.groups[e]?e:c.focused,u=c.groups[l],d=c.focused===l,f=Oy(),p=o?.projectDir??(s?.projectDir?s.cwd:null)??null,m=p?tR(p):`no folder`,h=u?.activeId??null,g=h?i.files[h]:void 0,_=g?.active??null,y=i.pageGroup&&c.groups[i.pageGroup]?i.pageGroup:c.focused,b=i.page!==null&&y===l?i.page:null,x=b===null?null:b.kind===`projects`?`Projects`:b.kind===`scheduled`?`Scheduled`:i.vaultProjects.find(e=>e.id===b.projectId)?.name??`Project`,[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(null),E=(0,v.useCallback)(()=>T(null),[]),[D,O]=(0,v.useState)(null),k=D?i.remote.tabs[D.id]??null:null,A=(0,v.useRef)(null);(0,v.useEffect)(()=>{A.current?.scrollIntoView({block:`nearest`,inline:`nearest`})},[_]);let j=typeof window<`u`?window.oonacode:void 0,M=typeof j?.openTabsInNewWindow==`function`,ee=i.windowRole===`popout`&&typeof j?.moveTabsToMainWindow==`function`,N=w?.kind===`chat`?Yg(c,w.id)??l:l,P=c.groups[N]?.ids??[],F=e_(c,N),I=w?w.kind===`chat`?[{key:`rename`,label:`Rename…`,icon:(0,W.jsx)(q.Edit,{className:`w-3.5 h-3.5`}),onSelect:()=>{a.selectSession(w.id),C(w.id)},testId:`tab-menu-rename`},{key:`split-right`,label:`Split right`,icon:(0,W.jsx)(q.Columns,{className:`w-3.5 h-3.5`}),separated:!0,onSelect:()=>a.splitTab(`right`,w.id),testId:`tab-menu-split-right`},{key:`split-down`,label:`Split down`,onSelect:()=>a.splitTab(`bottom`,w.id),testId:`tab-menu-split-down`},{key:`move-other-group`,label:`Move to other group`,disabled:F===null,onSelect:()=>a.moveTabToOtherGroup(w.id),testId:`tab-menu-move-other-group`},...M?[{key:`move-new-window`,label:`Move to new window`,icon:(0,W.jsx)(q.WindowOut,{className:`w-3.5 h-3.5`}),onSelect:()=>void a.moveTabToNewWindow(w.id),testId:`tab-menu-move-new-window`}]:[],...ee?[{key:`move-main-window`,label:`Move to main window`,onSelect:()=>void a.moveTabToMainWindow(w.id),testId:`tab-menu-move-main-window`}]:[],{key:`close`,label:`Close`,icon:(0,W.jsx)(q.X,{className:`w-3.5 h-3.5`}),separated:!0,onSelect:()=>a.closeTab(w.id),testId:`tab-menu-close`},{key:`close-others`,label:`Close other tabs`,disabled:P.length<2,onSelect:()=>{for(let e of P)e!==w.id&&a.closeTab(e)},testId:`tab-menu-close-others`},{key:`close-all`,label:`Close all tabs`,onSelect:()=>{for(let e of P)a.closeTab(e)},testId:`tab-menu-close-all`},{key:`delete`,label:`Delete`,icon:(0,W.jsx)(q.Trash,{className:`w-3.5 h-3.5`}),danger:!0,separated:!0,onSelect:()=>{i.drafts[w.id]?a.closeTab(w.id):O({id:w.id,title:w.title})},testId:`tab-menu-delete`}]:[{key:`close`,label:`Close`,icon:(0,W.jsx)(q.X,{className:`w-3.5 h-3.5`}),onSelect:()=>a.closeFile(w.path,h??void 0),testId:`tab-menu-close`},{key:`close-others`,label:`Close other files`,disabled:(g?.open.length??0)<2,onSelect:()=>{for(let e of g?.open??[])e!==w.path&&a.closeFile(e,h??void 0)},testId:`tab-menu-close-others`},{key:`close-all`,label:`Close all files`,onSelect:()=>{for(let e of g?.open??[])a.closeFile(e,h??void 0)},testId:`tab-menu-close-all`}]:[],te=(0,v.useMemo)(()=>t?Jg(c):u?.ids??[],[t,c,u]),ne=(0,v.useMemo)(()=>te.map(e=>{let n=i.drafts[e],r=i.transcripts[e]?.session??i.sessions.find(t=>t.id===e)??null,a=i.transcripts[e]?.status??r?.status??`idle`;return{id:e,draft:n!==void 0,title:n?xg(n):r?pg(r):`Session ${e.slice(0,8)}`,customTitle:n?n.title??``:r?.title??``,cwd:n?n.projectDir??``:r?.cwd??``,running:a===`running`||a===`waiting_permission`,waiting:a===`waiting_permission`,error:a===`error`,group:t?Yg(c,e)??l:l}}),[te,i.drafts,i.transcripts,i.sessions,t,c,l]),re=(0,v.useCallback)((e,t)=>{C(null),a.renameTab(e,t)},[a]),L=f?i.remote.tabs[f]??null:null,ie=(0,v.useRef)(null),R=t?c.groups[c.focused]?.activeId??null:u?.activeId??null;(0,v.useEffect)(()=>{ie.current?.scrollIntoView({block:`nearest`,inline:`nearest`})},[R]);let ae=(e,t)=>{if(!Z_())return;let n=typeof window<`u`?window:null;a.tabDraggedOut(t,{screenX:Number.isFinite(e.screenX)?e.screenX:null,screenY:Number.isFinite(e.screenY)?e.screenY:null,outside:n?$_(e,n):!1})},oe=(0,v.useRef)(null),se=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let e=oe.current;if(!e)return;let t=e=>{let t=se.current;if(!t)return;let n=eR(e,t);n!==0&&(e.preventDefault(),t.scrollLeft+=n)},n=e=>{e.button===1&&e.preventDefault()};return e.addEventListener(`wheel`,t,{passive:!1}),e.addEventListener(`mousedown`,n),()=>{e.removeEventListener(`wheel`,t),e.removeEventListener(`mousedown`,n)}},[]),(0,W.jsxs)(`div`,{ref:oe,className:U(`flex h-9 shrink-0 items-stretch gap-1 border-b border-border bg-surface px-1`,n&&(d?`shadow-[inset_0_2px_0_var(--accent)]`:`opacity-95`)),role:`tablist`,"aria-label":`Open chats`,"data-testid":`tab-bar`,"data-group":l,children:[(0,W.jsxs)(`div`,{ref:se,className:`flex min-w-0 flex-1 items-stretch gap-1 overflow-x-auto`,"data-testid":`tabs-scroller`,"data-tab-strip":!0,children:[b===null?null:(0,W.jsxs)(`div`,{role:`tab`,"aria-selected":!0,tabIndex:0,onAuxClick:e=>{e.button===1&&(e.preventDefault(),a.closePage())},className:`group relative flex min-w-[7rem] max-w-[15rem] shrink-0 items-center gap-1.5 rounded-t-md border-b-2 border-accent bg-surface-2 px-2 text-xs text-fg`,"data-testid":`page-tab`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 py-1`,children:[b.kind===`scheduled`?(0,W.jsx)(q.Clock,{className:`w-3 h-3 shrink-0 text-fg-faint`}):(0,W.jsx)(q.Project,{className:`w-3 h-3 shrink-0 text-project`}),(0,W.jsx)(`span`,{className:`truncate`,children:ug(x??``,28)})]}),(0,W.jsx)(Y,{label:`Close ${x??`page`}`,className:`p-0.5`,onClick:()=>a.closePage(),"data-testid":`page-tab-close`,children:(0,W.jsx)(q.X,{className:`w-3 h-3`})})]}),ne.map((e,i)=>{let o=e.id===R&&_===null&&b===null,s=S===e.id,c=t?te.filter((e,t)=>t<i&&ne[t]?.group===l).length:i,u=r!==null&&e.group===l&&r===c;return(0,W.jsxs)(`div`,{ref:e.id===R?ie:void 0,role:`tab`,"aria-selected":o,tabIndex:o?0:-1,draggable:!s,"data-tab-id":e.id,"data-tab-group":e.group,onDragStart:t=>Y_(t.dataTransfer,{tabId:e.id,groupId:e.group}),onDragEnd:t=>ae(t,e.id),onContextMenu:t=>{t.preventDefault(),T({kind:`chat`,id:e.id,title:e.title,at:{x:t.clientX,y:t.clientY},el:t.currentTarget})},onAuxClick:t=>{t.button===1&&(t.preventDefault(),a.closeTab(e.id))},className:U(`group relative flex min-w-[7rem] max-w-[15rem] shrink-0 items-center gap-1.5 rounded-t-md border-b-2 px-2 text-xs`,o?n&&!d?`border-fg-faint bg-surface-2 text-fg`:`border-accent bg-surface-2 text-fg`:`border-transparent text-fg-muted hover:bg-surface-2`),"data-testid":`tab-${e.id}`,children:[u?(0,W.jsx)(rR,{}):null,s?(0,W.jsx)(iR,{initial:e.customTitle,placeholder:e.title,onCommit:t=>re(e.id,t),onCancel:()=>C(null)}):(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{a.selectSession(e.id),a.showChat(e.id)},onDoubleClick:()=>C(e.id),title:e.cwd?`${e.title}\n${e.cwd}`:`${e.title}\nDouble-click to rename`,className:`flex min-w-0 flex-1 items-center gap-1.5 py-1 text-left`,children:[e.running?(0,W.jsx)(q.Spinner,{className:U(`w-3 h-3 shrink-0`,e.waiting?`text-warn`:`text-accent`),title:`Agent running`}):e.error?(0,W.jsx)(q.Alert,{className:`w-3 h-3 shrink-0 text-danger`}):(0,W.jsx)(`span`,{className:`w-3 shrink-0`,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`truncate`,children:ug(e.title,28)})]}),(0,W.jsx)(Y,{label:`Close ${e.title}`,className:`p-0.5 opacity-0 group-hover:opacity-100 focus:opacity-100`,onClick:()=>a.closeTab(e.id),children:(0,W.jsx)(q.X,{className:`w-3 h-3`})})]},e.id)}),r!==null&&r>=(u?.ids.length??0)?(0,W.jsx)(`div`,{className:`relative w-2 shrink-0`,"aria-hidden":!0,children:(0,W.jsx)(rR,{})}):null,g?.open.map(e=>{let t=_===e&&b===null,n=pj(e);return(0,W.jsxs)(`div`,{ref:t?A:void 0,role:`tab`,"aria-selected":t,tabIndex:t?0:-1,title:e,onContextMenu:t=>{t.preventDefault(),T({kind:`file`,path:e,at:{x:t.clientX,y:t.clientY},el:t.currentTarget})},onAuxClick:t=>{t.button===1&&(t.preventDefault(),a.closeFile(e,h??void 0))},className:U(`group relative flex min-w-[6rem] max-w-[14rem] shrink-0 items-center gap-1.5 rounded-t-md border-b-2 px-2 text-xs`,t?`border-accent bg-surface-2 text-fg`:`border-transparent text-fg-muted hover:bg-surface-2`),"data-testid":`file-tab-${e}`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>a.activateFile(e,h??void 0),className:`flex min-w-0 flex-1 items-center gap-1.5 py-1 text-left`,children:[(0,W.jsx)(q.File,{className:`w-3 h-3 shrink-0 text-fg-faint`}),(0,W.jsx)(`span`,{className:`truncate`,children:ug(n,28)})]}),(0,W.jsx)(Y,{label:`Close ${n}`,className:`p-0.5 opacity-0 group-hover:opacity-100 focus:opacity-100`,onClick:()=>a.closeFile(e,h??void 0),"data-testid":`file-tab-close-${e}`,children:(0,W.jsx)(q.X,{className:`w-3 h-3`})})]},`file:${e}`)})]}),(0,W.jsx)(nx,{open:w!==null,at:w?.at??{x:0,y:0},anchorEl:w?.el??null,label:`Tab actions`,onClose:E,items:I.map(e=>({...e,onSelect:()=>{E(),e.onSelect()}}))}),(0,W.jsx)(Xy,{open:D!==null,title:D?`Delete "${ug(D.title,60)}"?`:`Delete this chat?`,message:k?`It is deleted on ${k.hostName} — the only place it is kept — so it is gone from every device. Files, folders and code on that PC are not touched — only the chat is deleted.`:`It is deleted from this PC — the only place it is kept — so it is gone from every device. Your files, folder and code are not touched — only the chat is deleted.`,onConfirm:()=>{D&&(k?a.deleteRemoteSession(k.hostId,k.sessionId):a.deleteSession(D.id))},onClose:()=>O(null)}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 pl-1`,children:[(0,W.jsx)(Y,{label:`New chat`,onClick:()=>{a.focusGroup(l),a.newTab()},"data-testid":`new-tab`,children:(0,W.jsx)(q.Plus,{className:`w-4 h-4`})}),(0,W.jsxs)(`button`,{hidden:b!==null,type:`button`,title:L?`Choose a project folder in OonaCode on ${L.hostName}`:p?`${p} — click to change the folder`:`No project folder: this chat runs in its own workspace. Click to use one of your folders.`,"aria-label":L?`Choose a project folder in OonaCode on ${L.hostName}`:`Use a project folder…`,disabled:L!==null,onClick:()=>a.openDialog(`project`),className:`flex max-w-[220px] items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-fg-muted hover:border-accent/60 hover:text-fg disabled:opacity-50`,"data-testid":`open-project-dialog`,children:[(0,W.jsx)(q.Folder,{className:`w-3.5 h-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`hidden truncate sm:inline`,"data-testid":`folder-chip`,children:m})]})]})]})}function rR(){return(0,W.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute -left-[3px] top-1 bottom-1 w-[3px] rounded bg-accent`,"data-testid":`tab-drop-mark`})}function iR({initial:e,placeholder:t,onCommit:n,onCancel:r}){let[i,a]=(0,v.useState)(e),o=(0,v.useRef)(null),s=(0,v.useRef)(!1);return(0,v.useEffect)(()=>{o.current?.focus(),o.current?.select()},[]),(0,W.jsx)(`input`,{ref:o,"aria-label":`Rename tab`,"data-testid":`tab-title-input`,className:`min-w-0 flex-1 rounded border border-accent bg-bg px-1 py-0.5 text-xs outline-none`,value:i,maxLength:500,placeholder:t,spellCheck:!1,onChange:e=>a(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),n(i)):e.key===`Escape`&&(e.preventDefault(),s.current=!0,r())},onBlur:()=>{s.current||n(i)}})}function aR({page:e}){return e.kind===`projects`?(0,W.jsx)(XF,{}):e.kind===`project`?(0,W.jsx)(QF,{projectId:e.projectId},e.projectId):(0,W.jsx)(iI,{})}function oR(e){let[t,n]=(0,v.useState)(null);return(0,v.useLayoutEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=()=>{let e=t.getBoundingClientRect(),r=Math.round(e.width),i=Math.round(e.height);(r!==0||i!==0)&&n(e=>e&&e.width===r&&e.height===i?e:{width:r,height:i})};r();let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}function sR(){let{state:e}=G(),t=(0,v.useRef)(null),n=oR(t),r=e.layout,i=r.root.type===`split`,a=i&&n!==null&&D_(r,n.width,n.height);return(0,W.jsx)(`div`,{ref:t,className:`relative flex min-h-0 min-w-0 flex-1`,"data-testid":`editor-area`,"data-groups":qg(r).length,"data-compact":a?`true`:`false`,children:i&&!a?(0,W.jsx)(cR,{node:r.root,path:[]}):(0,W.jsx)(mR,{groupId:r.focused,compact:a})})}function cR({node:e,path:t}){return e.type===`group`?(0,W.jsx)(mR,{groupId:e.id,compact:!1,split:!0}):(0,W.jsx)(dR,{node:e,path:t})}function lR(e){return e.type===`group`?e.id:`split:${lR(e.children[0])}`}var uR=4;function dR({node:e,path:t}){let{actions:n}=G(),r=e.direction===`row`,i=(0,v.useRef)(null),a=(0,v.useRef)([]),o=(0,v.useCallback)(o=>s=>{let c=i.current;if(!c||s.button!==0)return;s.preventDefault();let l=s.currentTarget,u=(r?c.clientWidth:c.clientHeight)-uR*(e.children.length-1);if(u<=0)return;let d=r?s.clientX:s.clientY,f=[...e.sizes],p=(f[o]??0)+(f[o+1]??0),m=e=>(r?E_(e).width:E_(e).height)/u,h=m(e.children[o]),g=m(e.children[o+1]),_=f,v=e=>{let t=((r?e.clientX:e.clientY)-d)/u,n=p<=h+g?p/2:Math.min(p-g,Math.max(h,(f[o]??0)+t));_=[...f],_[o]=n,_[o+1]=p-n;let i=a.current[o],s=a.current[o+1];i&&(i.style.flexGrow=String(_[o])),s&&(s.style.flexGrow=String(_[o+1]))},y=()=>{l.removeEventListener(`pointermove`,v),l.removeEventListener(`pointerup`,y),l.removeEventListener(`pointercancel`,y),n.resizeSplit(t,_)};try{l.setPointerCapture(s.pointerId)}catch{}l.addEventListener(`pointermove`,v),l.addEventListener(`pointerup`,y),l.addEventListener(`pointercancel`,y)},[n,e,t,r]);return(0,W.jsx)(`div`,{ref:i,className:U(`flex min-h-0 min-w-0 flex-1`,r?`flex-row`:`flex-col`),"data-split":e.direction,children:e.children.map((i,s)=>(0,W.jsxs)(v.Fragment,{children:[s>0?(0,W.jsx)(`div`,{role:`separator`,"aria-orientation":r?`vertical`:`horizontal`,"aria-label":`Resize the groups (double-click: make them equal)`,title:`Drag to resize · double-click to make them equal`,onPointerDown:o(s-1),onDoubleClick:()=>n.equalizeSplit(t),className:U(`shrink-0 bg-border transition-colors hover:bg-accent/60`,r?`w-1 cursor-col-resize`:`h-1 cursor-row-resize`),"data-testid":`split-divider-${t.join(`.`)||`root`}-${s-1}`}):null,(0,W.jsx)(`div`,{ref:e=>{a.current[s]=e},className:`flex min-h-0 min-w-0`,style:{flexGrow:e.sizes[s]??1,flexShrink:1,flexBasis:0},"data-split-cell":s,children:(0,W.jsx)(cR,{node:i,path:[...t,s]})})]},lR(i)))})}function fR(e,t){return e===t?!0:!e||!t?!1:e.groupId===t.groupId&&e.zone===t.zone&&e.index===t.index}function pR({target:e}){let t=A_(e.zone);return(0,W.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute z-40 rounded-md border-2 border-accent/70 bg-accent/15 transition-all duration-100`,style:{left:`${t.left*100}%`,top:`${t.top*100}%`,width:`${t.width*100}%`,height:`${t.height*100}%`},"data-testid":`drop-overlay`,"data-zone":e.zone})}function mR({groupId:e,compact:t,split:n=!1}){let{state:r,actions:i}=G(),a=(0,v.useRef)(null),o=r.layout,s=o.groups[e],c=o.focused===e,l=s?.activeId??null,u=r.pageGroup&&o.groups[r.pageGroup]?r.pageGroup:o.focused,d=r.page!==null&&u===e?r.page:null,[f,p]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(f===null||typeof document>`u`)return;let e=()=>p(null);return document.addEventListener(`dragend`,e,!0),document.addEventListener(`drop`,e,!0),()=>{document.removeEventListener(`dragend`,e,!0),document.removeEventListener(`drop`,e,!0)}},[f]);let m=e=>{if(!Q_(e.dataTransfer))return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`move`;let t=a.current,n=t?ev(t,e.clientX,e.clientY):null,r=X_(),i=n&&(!r||x_(o,r.tabId,n))?n:null;p(e=>fR(e,i)?e:i)},h=e=>{let t=e.relatedTarget;t instanceof Node&&a.current?.contains(t)||p(null)},g=e=>{if(!Q_(e.dataTransfer))return;e.preventDefault(),e.stopPropagation(),p(null);let t=X_();if(!t)return;let n=a.current,r=n?ev(n,e.clientX,e.clientY):null;Z_(),r&&i.dropTab(t.tabId,r)},_=()=>i.focusGroup(e);return(0,W.jsx)(`section`,{ref:a,className:U(`relative flex min-h-0 min-w-0 flex-1 flex-col`,n&&`outline-offset-[-1px]`),"aria-label":n?`Editor group ${qg(o).indexOf(e)+1}`:void 0,"data-editor-group":e,"data-focused":c?`true`:`false`,"data-compact":t?`true`:`false`,"data-testid":`editor-group-${e}`,onPointerDownCapture:_,onFocusCapture:_,onDragEnterCapture:e=>{Q_(e.dataTransfer)&&e.preventDefault()},onDragOverCapture:m,onDragLeave:h,onDropCapture:g,children:(0,W.jsx)(v.Profiler,{id:e,onRender:$b,children:(0,W.jsxs)(Ey,{sessionId:d?null:l,groupId:e,focused:c,children:[(0,W.jsx)(nR,{groupId:e,compact:t,split:n,dropIndex:f?.zone===`center`&&f.index!==void 0?f.index:null}),(0,W.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,"data-group-body":!0,children:[d?(0,W.jsx)(aR,{page:d}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ox,{}),l&&r.files[l]?.active?(0,W.jsx)(HL,{}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ML,{}),c?(0,W.jsx)(LL,{}):null,(0,W.jsx)(EF,{},l??`none`)]})]}),f&&f.index===void 0?(0,W.jsx)(pR,{target:f}):null]})]})})})}function hR({open:e,onClose:t}){let{state:n,actions:r}=G();(0,v.useEffect)(()=>{e&&r.runDoctor()},[e,r]);let i=n.doctor,a=i?.filter(e=>!e.ok).length??0;return(0,W.jsxs)(Ky,{open:e,title:`Doctor`,onClose:t,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(J,{onClick:()=>void r.runDoctor(),children:[(0,W.jsx)(q.Refresh,{className:`w-3.5 h-3.5`}),` Run again`]}),(0,W.jsx)(J,{variant:`primary`,onClick:t,children:`Close`})]}),children:[n.info?(0,W.jsxs)(`div`,{className:`mb-3 grid grid-cols-1 gap-x-4 gap-y-0.5 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[`Host: `,n.info.hostName,` (`,n.info.platform,`/`,n.info.arch,`)`]}),(0,W.jsxs)(`div`,{children:[`App: `,Gv(n.info.appVersion,n.info.cliChannel),n.info.cliChannel&&n.info.cliChannel!==`stable`?` — ${n.info.cliChannel} channel (updates stay within it)`:``]}),(0,W.jsxs)(`div`,{className:`truncate`,title:n.info.engine.binaryPath,children:[`Engine: `,n.info.engine.version??`unknown`,` — `,n.info.engine.binaryPath]}),(0,W.jsxs)(`div`,{className:`truncate`,title:n.info.engine.configDir,children:[`Isolated config dir: `,n.info.engine.configDir]}),(0,W.jsxs)(`div`,{children:[`Listening: `,n.info.addresses.join(`, `),`:`,n.info.port]})]}):null,i===null?(0,W.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,W.jsx)(q.Spinner,{}),` Running checks…`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mb-2 text-sm`,children:a===0?(0,W.jsxs)(`span`,{className:`text-ok`,children:[`All `,i.length,` checks passed.`]}):(0,W.jsxs)(`span`,{className:`text-danger`,children:[a,` of `,i.length,` checks need attention.`]})}),(0,W.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:i.map(e=>(0,W.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 text-sm`,children:[e.ok?(0,W.jsx)(q.Check,{className:`mt-0.5 text-ok`}):(0,W.jsx)(q.Alert,{className:`mt-0.5 text-danger`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,W.jsx)(`div`,{className:`pre-wrap text-xs text-fg-muted`,children:e.detail}),!e.ok&&e.fix?(0,W.jsx)(`div`,{className:`mt-1 pre-wrap rounded bg-surface-2 px-2 py-1 font-mono text-xs`,children:e.fix}):null]})]},e.id))})]})]})}function gR({open:e,onClose:t}){let{state:n,actions:r}=G(),i=Ay(),a=jy(),o=n.currentSessionId,[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(null);(0,v.useEffect)(()=>{e&&(c(a?.projectDir??i?.projectDir??``),m(null),u(!1),f(!1))},[e,a?.projectDir,i?.projectDir]);let h=(0,v.useCallback)(async e=>{let t=e.trim();if(t){u(!0),m(null);try{m(await r.inspectProject(t))}finally{u(!1)}}},[r]),g=(0,v.useCallback)(async()=>{let e=typeof window<`u`?window.oonacode:void 0;if(!e?.pickDirectory)return;let t=await e.pickDirectory({title:`Choose a project folder`});t&&(c(t),await h(t))},[h]),_=(0,v.useCallback)(async()=>{if(!(!p||!o)){f(!0);try{await r.attachProject(p.dir,o)&&t()}finally{f(!1)}}},[p,o,r,t]),y=o===null?null:n.remote.tabs[o]??null,b=o!==null&&y===null&&p!==null&&p.exists&&p.isDirectory&&p.anchorable;return(0,W.jsx)(Ky,{open:e,title:`Use a project folder`,onClose:t,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{onClick:t,children:b?`Not now`:`Close`}),b?(0,W.jsx)(J,{variant:`primary`,busy:d,onClick:()=>void _(),"data-testid":`project-switch`,children:`Switch to this project`}):null]}),children:y?(0,W.jsxs)(vR,{tone:`warn`,testId:`project-remote`,children:[`This chat runs on `,(0,W.jsx)(`strong`,{children:y.hostName}),`, and a project folder is a folder on that PC. Open OonaCode there and choose it from that window — this one can only see this machine's disk, and the folder has to be where the agent actually works.`]}):(0,W.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),h(s)},children:[(0,W.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-2 px-3 py-2 text-xs text-fg-muted space-y-1.5`,children:[(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{className:`text-fg`,children:`What a project folder is.`}),` It tells this chat which folder on this PC it is working in. The agent then loads that folder's`,(0,W.jsx)(`span`,{className:`font-mono`,children:` CLAUDE.md`}),` and`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:`.claude/`}),` settings, and — the part you noticed — it stops asking permission for edits and commands inside that folder, because you have said "this is the project, go ahead here".`]}),(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{className:`text-fg`,children:`Where it is used.`}),` Every message in this chat runs with that folder as the working directory: relative paths resolve there, the file tools default there, and its project rules apply. Each chat has its own folder; other chats are unaffected. The chat still keeps running in the app-private workspace until you attach one.`]}),(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{className:`text-fg`,children:`Good folders:`}),` the root of a code project you own — a repository or app directory, usually the one with a`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:`CLAUDE.md`}),` or a`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:`.claude/`}),` folder, a`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:`.git`}),` repo, or a`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:`package.json`}),`.`]}),(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{className:`text-fg`,children:`Do not set:`}),` your whole home directory, a drive root (`,(0,W.jsx)(`span`,{className:`font-mono`,children:`C:`}),`),`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:`Desktop`}),`,`,(0,W.jsx)(`span`,{className:`font-mono`,children:` Downloads`}),`, a system or Program Files folder, or a cloud-synced root — attaching there gives the agent silent, unprompted edit access across far more than a project, which is exactly what the permission prompts exist to prevent. OonaCode already refuses the home directory and drive roots for this reason.`]}),(0,W.jsxs)(`p`,{children:[`A folder buys `,(0,W.jsx)(`strong`,{className:`text-fg`,children:`silence and context, never access`}),`: the agent can already read and write anywhere with your approval — outside a project it just asks first.`]})]}),(0,W.jsx)(Wy,{label:`Folder on this PC`,hint:`An absolute path. Only this machine can see it, so OonaCode asks the host what is there.`,children:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{className:X,value:s,onChange:e=>{c(e.target.value),m(null)},placeholder:`D:\\projects\\my-app`,"aria-label":`Project folder`,autoFocus:!0,spellCheck:!1}),window.oonacode?.pickDirectory?(0,W.jsxs)(J,{onClick:()=>void g(),children:[(0,W.jsx)(q.Folder,{className:`w-4 h-4`}),` Browse`]}):null,(0,W.jsx)(J,{busy:l,disabled:s.trim().length===0,onClick:()=>void h(s),"data-testid":`project-check`,children:`Check`})]})}),p?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(_R,{result:p,restarts:i!==null}),o===null?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Open a chat first — a folder is attached to one chat, not to the app.`}):null]}):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`A chat does not need a folder. It already has every file tool, everywhere — outside a project it simply asks before touching a file. Naming a project adds that project's configuration and context; it never adds access that was missing.`})]})})}function _R({result:e,restarts:t}){return!e.exists||!e.isDirectory?(0,W.jsxs)(vR,{tone:`danger`,testId:`project-verdict`,children:[(0,W.jsx)(`strong`,{className:`font-mono`,children:e.dir}),` is not a folder on this PC.`]}):e.anchorable?e.looksLikeProject?(0,W.jsxs)(vR,{tone:`accent`,testId:`project-verdict`,children:[(0,W.jsxs)(`div`,{className:`font-medium`,children:[`Switching this chat to `,e.dir,` loads:`]}),(0,W.jsxs)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-4`,children:[(0,W.jsxs)(`li`,{children:[`its `,(0,W.jsx)(`code`,{children:e.hasClaudeMd?`CLAUDE.md`:`CLAUDE.md (none at the root)`}),` and the ones above it`]}),(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`code`,{children:`.claude/settings.json`}),` and `,(0,W.jsx)(`code`,{children:`settings.local.json`}),e.hasClaudeDir?``:` (none yet)`]}),(0,W.jsx)(`li`,{children:`that project's skills, sub-agents, slash commands and hooks`}),(0,W.jsx)(`li`,{children:`silence: file operations inside it stop raising a permission card`})]}),(0,W.jsx)(`div`,{className:`mt-1.5`,children:t?`The agent restarts once to pick them up and resumes this conversation exactly where it is — nothing is lost.`:`Your first message starts the chat there.`})]}):(0,W.jsxs)(vR,{tone:`accent`,testId:`project-verdict`,children:[(0,W.jsxs)(`div`,{className:`font-medium`,children:[`Switching this chat to `,e.dir,`:`]}),(0,W.jsxs)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-4`,children:[(0,W.jsxs)(`li`,{children:[`it has no `,(0,W.jsx)(`code`,{children:`CLAUDE.md`}),` and no `,(0,W.jsx)(`code`,{children:`.claude/`}),` folder yet, so nothing is loaded from it — add them later and the next restart picks them up`]}),(0,W.jsx)(`li`,{children:`silence: file operations inside it stop raising a permission card`})]}),(0,W.jsx)(`div`,{className:`mt-1.5`,children:t?`The agent restarts once and resumes this conversation exactly where it is — nothing is lost.`:`Your first message starts the chat there.`})]}):(0,W.jsxs)(vR,{tone:`danger`,testId:`project-verdict`,children:[`OonaCode will not use `,(0,W.jsx)(`strong`,{className:`font-mono`,children:e.dir}),` as a project:`,` `,e.reason??`it is not a usable project directory`,`.`]})}function vR({tone:e,testId:t,children:n}){return(0,W.jsx)(`div`,{className:`rounded-md border px-3 py-2 text-xs ${e===`danger`?`border-danger/40 bg-danger-soft text-danger`:e===`warn`?`border-warn/50 bg-warn-soft text-warn`:`border-accent/40 bg-accent-soft text-fg`}`,"data-testid":t,children:n})}var yR=(e,t)=>`${e}::${t}`;function bR(e){let t=e.indexOf(`::`);return t<=0||t===e.length-2?null:{providerId:e.slice(0,t),model:e.slice(t+2)}}function xR(e){let t=e?.chatDefaults??{};return{name:e?.name??``,goal:e?.goal??``,instructions:e?.instructions??``,repositories:(e?.repositories??[]).join(`
|
|
155
|
-
`),model:t.providerId&&t.model?
|
|
154
|
+
`)))},[N,ee]),(0,v.useEffect)(()=>{if(!D||!u){j.current=null;return}if(j.current===D.id)return;let e=y.findIndex(e=>e.item.id===D.rootId);if(e<0)return;if(e<S.start){t.revealTranscript(u,y.length-e,y.length);return}let n=o.current;if(n)return pL(()=>{let e=n.querySelector(cI(D.id))??n.querySelector(cI(D.rootId));if(!(e instanceof HTMLElement))return;j.current=D.id,c(!1);let t=hI(e,C.query);t?gI(t,n):typeof e.scrollIntoView==`function`&&e.scrollIntoView({block:`center`})})},[D,y,S.start,u,t,C.query]);let P=e.jumpTo,F=(0,v.useRef)(P?.seq??0);(0,v.useEffect)(()=>{if(!P||!u||P.sessionId!==u||P.seq<=F.current)return;let e=y.findIndex(e=>fL(e,P.itemId));if(e<0){F.current=P.seq;return}if(e<S.start){t.revealTranscript(u,y.length-e,y.length);return}let n=o.current;if(n)return F.current=P.seq,pL(()=>{let t=n.querySelector(cI(P.itemId))??n.querySelector(cI(y[e].item.id));t instanceof HTMLElement&&(c(!1),typeof t.scrollIntoView==`function`&&t.scrollIntoView({block:`center`,behavior:`smooth`}),t.classList.add(`chat-jump-flash`),setTimeout(()=>t.classList.remove(`chat-jump-flash`),1600))})},[P,y,S.start,u,t]);let ne=(0,v.useCallback)(e=>{let n=(e.target instanceof Element?e.target:null)?.closest(`[data-testid="user-reply-quote"]`),i=r?.items;if(!n||!u||!i)return;let a=n.closest(`[data-item-id]`)?.getAttribute(`data-item-id`)??null,o=a?i.findIndex(e=>e.id===a):-1,s=mv((o>=0?i.slice(0,o):i).map(e=>({id:e.id,text:wI(e)})),n.getAttribute(`data-quote`)??``);s&&t.jumpToItem(u,s)},[r?.items,u,t]);(0,v.useEffect)(()=>{let e=o.current;if(!C.open||!e){mI();return}let t=()=>pI(e,T,D?.id??null,C.query);t();let n=pL(t);return()=>{n(),mI()}},[C.open,C.query,T,D,S.items]);let re=D?.id??null,[L,ie]=(0,v.useState)(null),R=sx(),ae=u!==null&&!R,oe=(0,v.useCallback)(()=>ie(null),[]),se=(0,v.useCallback)(e=>{if(e.shiftKey)return;let t=o.current;if(!t)return;let n=e.target instanceof Element?e.target:null;n?.closest(`input, textarea, select, [contenteditable="true"]`)||(e.preventDefault(),ie({at:{x:e.clientX,y:e.clientY},target:CI(n,t)}))},[]),ce=(0,v.useMemo)(()=>{let e=L?.target.itemId;if(!e||!r)return null;let t=r.index.get(e);return t===void 0?null:r.items[t]??null},[L,r]),le=(0,v.useMemo)(()=>{if(!L)return[];let{target:e}=L,n=e=>void XM(e).then(e=>t.toast(e?`success`:`error`,e?`Copied`:`Could not copy to the clipboard`)),r={reply:()=>{if(!u)return;let n=e.selection.trim()===``?lv(ce?wI(ce):``):e.selection;if(n.trim()===``)return;let r=ce?.kind===`tool`?uv(ce.input):null,i=ce?.kind===`assistant`||ce?.kind===`thinking`?`assistant`:ce?.kind===`user`?`user`:ce?.kind===`tool`?{tool:ce.name}:null;t.quoteIntoComposer(u,ov(n,r,i),{preview:dv(n),itemId:ce?.id??null})},copy:()=>n(e.selection),"copy-code":()=>n(e.code??``),"copy-link":()=>n(e.link??``),"open-link":()=>{let t=DI(e.link);if(!t)return;let n=typeof window<`u`?window.oonacode:void 0;n?.openExternal?n.openExternal(t):window.open(t,`_blank`,`noopener,noreferrer`)},"copy-item":()=>n(ce?wI(ce):``),find:()=>w(t=>({...t,open:!0,query:e.selection.trim(),currentId:null,focusSeq:t.focusSeq+1})),"select-block":()=>{let t=e.itemId?o.current?.querySelector(cI(e.itemId)):null,n=t?.firstElementChild??t,r=window.getSelection();if(!n||!r)return;let i=document.createRange();i.selectNodeContents(n),r.removeAllRanges(),r.addRange(i)}},i={reply:(0,W.jsx)(q.Reply,{className:`h-3.5 w-3.5`}),copy:(0,W.jsx)(q.Copy,{className:`h-3.5 w-3.5`}),"copy-code":(0,W.jsx)(q.Copy,{className:`h-3.5 w-3.5`}),"copy-item":(0,W.jsx)(q.Copy,{className:`h-3.5 w-3.5`}),"copy-link":(0,W.jsx)(q.Globe,{className:`h-3.5 w-3.5`}),"open-link":(0,W.jsx)(q.Globe,{className:`h-3.5 w-3.5`}),find:(0,W.jsx)(q.Search,{className:`h-3.5 w-3.5`})};return OI(e,ce,{canReply:ae}).map(e=>({key:e.key,label:e.label,hint:e.hint,disabled:e.disabled,separated:e.separated,icon:i[e.key]??(0,W.jsx)(`span`,{}),testId:`chat-menu-${e.key}`,onSelect:r[e.key]}))},[L,ce,t,u,ae]),ue=(0,v.useCallback)(()=>{if(!u||!S.hasMore)return;let e=o.current;e&&(l.current=e.scrollHeight-e.scrollTop),t.growTranscript(u,S.total)},[u,S.hasMore,S.total,t]),[de,fe]=(0,v.useState)(null),pe=(0,v.useRef)(null),me=(0,v.useCallback)(()=>{let e=o.current;if(!e){fe(null);return}let t=e.querySelectorAll(`[${kI}]`),n=e.getBoundingClientRect().top,r=pe.current?.offsetHeight??0,i=AI(t.length,e=>t[e].getBoundingClientRect().top-n,r),a=i<0?null:t[i].getAttribute(kI);fe(e=>e===a?e:a)},[]),he=(0,v.useCallback)(()=>{let e=o.current;if(!e)return;let n={scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight},r=Sv(n);c(r),me(),r&&u?t.trimTranscript(u):Cv(n)&&S.hasMore&&ue()},[u,S.hasMore,ue,t,me]),ge=(0,v.useCallback)(()=>{let e=o.current;if(!e||!de)return;let t=e.querySelector(cI(de));if(!(t instanceof HTMLElement))return;let n=t.getBoundingClientRect().top-e.getBoundingClientRect().top;c(!1),e.scrollTo({top:e.scrollTop+n-(pe.current?.offsetHeight??0)})},[de]),_e=(0,v.useCallback)(()=>{let e=o.current;e&&e.scrollTo({top:e.scrollHeight}),c(!0),u&&t.trimTranscript(u)},[u,t]);(0,v.useLayoutEffect)(()=>{let e=o.current;if(e){if(l.current!==null){e.scrollTop=Math.max(0,e.scrollHeight-l.current),l.current=null;return}s&&(e.scrollTop=e.scrollHeight)}},[S.items,s]);let ve=(0,v.useRef)(s);ve.current=s;let ye=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=o.current;if(!e||typeof ResizeObserver>`u`)return;let t=ye.current,n=e.clientWidth,r=e.clientHeight,i=t?.offsetHeight??0,a=new ResizeObserver(()=>{let a=e.clientWidth===n&&e.clientHeight===r,o=(t?.offsetHeight??0)===i;a&&o||(n=e.clientWidth,r=e.clientHeight,i=t?.offsetHeight??0,ve.current&&(e.scrollTop=e.scrollHeight))});return a.observe(e),t&&a.observe(t),()=>a.disconnect()},[u]),(0,v.useLayoutEffect)(()=>{me()},[S.items,me]);let be=r?.lastLocalPromptId??null;(0,v.useEffect)(()=>{be!==null&&_e()},[be,_e]),(0,v.useEffect)(()=>{c(!0),l.current=null,fe(null),w(kL)},[u]);let xe=e.chatSearchRequest,Se=(0,v.useRef)(xe?.seen?xe.seq:0);(0,v.useEffect)(()=>{let e=xe;!e||!u||e.sessionId!==u||e.seq<=Se.current||(Se.current=e.seq,j.current=null,w(t=>({open:!0,query:e.query,currentId:null,focusSeq:t.focusSeq+1})),n({type:`chat_search_request_seen`,seq:e.seq}))},[xe,u,n]);let Ce=r?.hasSubagentItems===!0||i?.hasSubagents===!0||Object.keys(r?.agentActivity??{}).length>0,we=(0,v.useMemo)(()=>{let e=new Map;if(!Ce)return e;for(let t of LN(h??[]))e.set(t.agentId,t.name);return e},[h,Ce]),Te=(0,v.useRef)(we);Te.current=we;let Ee=(0,v.useRef)(r);Ee.current=r;let De=(0,v.useCallback)(e=>{let t=Ee.current,n=t?.index.get(e);return n!==void 0&&t?.items[n]?.kind===`tool`},[]),Oe=(0,v.useCallback)(e=>Te.current.get(e)??null,[]),ke=(0,v.useRef)(e.providers);ke.current=e.providers;let je=(0,v.useCallback)(e=>If(e,ke.current),[]),Me=wL(),Ne=(0,v.useCallback)((e,n=!1)=>{let r=[],i=null;for(let t of YI(PI(FI(e,De)))){let e=`run`in t?t.run[0]:`orphans`in t?t.orphans[0]:t.item,o=`run`in t?t.run[t.run.length-1].timestamp:`orphans`in t?t.orphans[t.orphans.length-1].timestamp:t.item.timestamp;if(n&&o){let t=SL(o);t!==null&&t!==i&&(r.push((0,W.jsx)(EL,{iso:o,today:Me},`day:${e.id}`)),i=t)}let s=a(t);s!==null&&r.push(s)}return r;function a(e){if(`orphans`in e){let t=e.orphans[0];return(0,W.jsxs)(`div`,{[sI]:t.id,className:`flex items-end gap-2`,children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,W.jsx)(ZI,{items:e.orphans})}),(0,W.jsx)(TL,{iso:e.orphans[e.orphans.length-1].timestamp})]},`orphans:${t.id}`)}if(`run`in e){let t=e.run[0];return(0,W.jsxs)(`div`,{[sI]:t.id,className:`flex items-end gap-2`,children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,W.jsx)(HP,{items:e.run,agentNameOf:Oe})}),(0,W.jsx)(TL,{iso:e.run[e.run.length-1].timestamp})]},`run:${t.id}`)}let r=e.item,i=(()=>{switch(r.kind){case`user`:return(0,W.jsx)(VI,{item:r},r.id);case`assistant`:return(0,W.jsx)(qI,{item:r},r.id);case`thinking`:return p?(0,W.jsx)(PP,{item:r},r.id):null;case`tool`:return r.name===`AskUserQuestion`?(0,W.jsx)(NI,{item:r},r.id):(0,W.jsx)(NP,{node:e,renderChildren:Ne},r.id);case`result`:return(0,W.jsx)(tL,{item:r},r.id);case`compact`:return(0,W.jsx)(nL,{item:r},r.id);case`permission`:return r.status===`pending`?null:(0,W.jsx)(UP,{item:r,agentName:r.request.agentId?Oe(r.request.agentId):null,onDecide:e=>t.respondPermission(r.request.requestId,e,u??void 0)},r.id);case`system`:return(0,W.jsx)(aL,{item:r,modelNameOf:je},r.id);case`error`:return(0,W.jsx)(cL,{item:r},r.id)}})();if(i===null)return null;let a=r.kind===`user`&&BI(r);return(0,W.jsxs)(`div`,{[sI]:r.id,...n&&a?{[kI]:r.id}:{},className:U(`flex items-end gap-2`,r.id===re&&`chat-search-current`),children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:i}),a?null:(0,W.jsx)(TL,{iso:r.timestamp})]},r.id)}},[t,p,re,Oe,De,Me,je,u]),z=(0,v.useMemo)(()=>(Qb(u),Ne(S.items,!0)),[Ne,S.items,u]),Pe=(0,v.useMemo)(()=>{if(de===null||!h)return null;let e=h.find(e=>e.id===de);if(!e||e.kind!==`user`)return null;let t=sv(e.text);return jI(t&&t.reply!==``?t.reply:e.text)},[h,de]);if(!u)return(0,W.jsx)(Yy,{icon:(0,W.jsx)(q.Edit,{className:`w-8 h-8`}),title:`No session selected`,hint:`Open a chat tab or pick a session from the sidebar. Sessions run on this PC and are stored in the host's SQLite database.`,action:(0,W.jsxs)(J,{variant:`primary`,onClick:()=>t.newTab(),children:[(0,W.jsx)(q.Plus,{className:`w-4 h-4`}),` New chat`]})});let Fe=r?.init,Ie=r?.status===`running`||r?.status===`waiting_permission`,Le=mL(r),Re=Le===`answer`?`Waiting for your answer`:Le===`approval`?`Waiting for your approval`:OL(r?.status,r?.statusText,e.prefs.autoAcceptPermissions&&!te(I(i)));return(0,W.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[C.open?(0,W.jsx)(oI,{query:C.query,index:E,count:T.length,focusSeq:C.focusSeq,onQuery:A,onStep:M,onClose:k}):null,(0,W.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[Pe===null?null:(0,W.jsx)(`div`,{ref:pe,className:`pointer-events-none absolute inset-x-0 top-0 z-10 px-3 pr-12 pt-2 sm:px-6 sm:pr-14`,children:(0,W.jsxs)(`button`,{type:`button`,onClick:ge,title:`Go to this message`,"data-testid":`pinned-user-message`,"data-pinned-id":de,className:`pointer-events-auto flex w-full items-center gap-2 rounded-lg border border-border bg-surface px-3 py-1.5 text-left text-xs text-fg-muted shadow-md hover:bg-surface-2 hover:text-fg`,children:[(0,W.jsx)(q.User,{className:`h-3 w-3 shrink-0`}),(0,W.jsx)(`span`,{className:`truncate`,children:Pe})]})}),(0,W.jsx)(`div`,{ref:o,onScroll:he,onContextMenu:se,onClick:ne,className:`flex-1 overflow-y-auto px-3 py-3 sm:px-6`,"data-testid":`transcript`,children:(0,W.jsx)(yP.Provider,{value:ee,children:(0,W.jsxs)(`div`,{ref:ye,className:`w-full`,children:[a&&a.projectDir?(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 text-[11px] text-fg-faint`,children:[(0,W.jsx)(q.Folder,{className:`w-3 h-3`}),(0,W.jsx)(`span`,{className:`font-mono`,children:a.projectDir}),(0,W.jsx)(Z,{tone:`accent`,children:`project attached`})]}):null,i||Fe?(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 text-[11px] text-fg-faint`,children:[(0,W.jsx)(q.Folder,{className:`w-3 h-3`}),(0,W.jsx)(`span`,{className:`font-mono`,"data-testid":`chat-cwd`,children:i?.cwd??Fe?.cwd}),Fe?.model??i?.model?(0,W.jsx)(Z,{children:zs(Fe?.model??i?.model??``)}):null,i?.providerId?(0,W.jsx)(Z,{tone:`accent`,children:i.providerId}):null,(0,W.jsx)(Z,{children:Fe?.permissionMode??i?.permissionMode??`default`}),Fe?(0,W.jsxs)(`span`,{children:[Fe.tools.length,` tools · engine `,Fe.claudeCodeVersion]}):null]}):null,S.hasMore?(0,W.jsx)(`div`,{className:`mb-2 flex items-center justify-center`,"data-testid":`window-more`,children:(0,W.jsxs)(J,{size:`sm`,onClick:ue,children:[(0,W.jsx)(q.ArrowDown,{className:`w-3 h-3 rotate-180`}),` Load `,100,` `,`older lines (`,S.hiddenAbove,` hidden)`]})}):null,f&&(!r||r.items.length===0)?(0,W.jsxs)(`div`,{className:`flex items-center gap-2 py-8 text-sm text-fg-muted`,children:[(0,W.jsx)(q.Spinner,{}),` Loading transcript…`]}):null,!f&&(r?.items.length??0)===0?a?(0,W.jsx)(DL,{hasProject:a.projectDir!==null}):r?(0,W.jsx)(`div`,{className:`py-10 text-center text-sm text-fg-muted`,children:`Send a message to start this session.`}):null:null,z,Ie?(0,W.jsx)(dL,{label:Re,lastFrameAt:hL(r)}):null,(0,W.jsx)(`div`,{className:`h-2`})]})})}),(0,W.jsx)(nx,{open:L!==null,at:L?.at??{x:0,y:0},items:le,onClose:oe,label:`Chat`,testId:`chat-context-menu`})]}),(0,W.jsx)(LI,{items:g,onCancel:e=>{e.requestId&&t.cancelQueued(e.requestId,u??void 0)},onSendNow:e=>e.requestId?t.sendQueuedNow(e.requestId,u??void 0):Promise.resolve(null)}),C.open?null:(0,W.jsx)(Y,{label:`Find in this chat (Ctrl+F)`,onClick:O,className:`absolute right-5 top-2 border border-border bg-surface shadow-md`,"data-testid":`chat-search-open`,children:(0,W.jsx)(q.Search,{className:`w-3.5 h-3.5`})}),s?null:(0,W.jsxs)(`button`,{type:`button`,onClick:_e,className:`absolute bottom-3 left-1/2 -translate-x-1/2 rounded-full border border-border bg-surface px-3 py-1 text-xs shadow-md hover:bg-surface-2`,"data-testid":`chat-jump-latest`,children:[(0,W.jsx)(q.ArrowDown,{className:`mr-1 inline w-3 h-3`}),` Jump to latest`]})]})}function FL(e){return(e/1048576).toFixed(e>=104857600?0:1)+` MB`}function IL(e){switch(e.phase){case`download`:return e.totalBytes?`Downloading the coding engine (v${e.version}) — ${FL(e.receivedBytes)} of ${FL(e.totalBytes)}…`:`Downloading the coding engine (v${e.version}) — ${FL(e.receivedBytes)}…`;case`verify`:return`Verifying the coding engine…`;case`extract`:return`Unpacking the coding engine…`;case`failed`:return`The coding engine could not be downloaded: ${e.error??`unknown error`}. The next message tries again.`;default:return null}}function LL(){let{state:e}=G(),t=e.engineDownload;if(!t)return null;let n=IL(t);if(!n)return null;let r=t.phase===`failed`,i=t.phase===`download`&&t.totalBytes?Math.min(100,Math.round(t.receivedBytes/t.totalBytes*100)):null;return(0,W.jsxs)(`div`,{className:`mx-4 mb-2 rounded-md border px-3 py-2 text-xs `+(r?`border-danger/40 bg-danger/10 text-danger`:`border-accent/40 bg-accent/10 text-fg`),role:`status`,"data-testid":`engine-download`,children:[(0,W.jsx)(`div`,{children:n}),i===null?null:(0,W.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded bg-fg/10`,children:(0,W.jsx)(`div`,{className:`h-full bg-accent`,style:{width:i+`%`}})})]})}var RL=524288,zL={shown:null,bytes:0,pixels:null,error:null,loading:!1},BL=[{value:`source`,label:`Source`},{value:`preview`,label:`Preview`}],VL=`preview`;function HL(){let{state:e,actions:t,api:n}=G(),r=ky(),i=Oy(),a=i?e.files[i]:void 0,o=a?.active??null,s=r?.status===`running`||r?.status===`waiting_permission`,[c,l]=(0,v.useState)({sessionId:i,files:{}}),u=c.sessionId===i?c.files:{},[d,f]=(0,v.useState)(VL),p=e=>{VL=e,f(e)},m=(0,v.useRef)(i);m.current=i;let h=(e,t,n)=>l(r=>{let i=r.sessionId===e?r.files:{};return{sessionId:e,files:{...i,[t]:n(i[t]??zL)}}}),g=async e=>{if(!i)return;let t=i;h(t,e,e=>({...e,loading:!0,error:null}));try{let r=await UL(n,t,e);if(m.current!==t)return;h(t,e,e=>{let t=e.shown!==null&&KL(e.shown,r.shown);return{shown:t?e.shown:r.shown,bytes:r.bytes,pixels:t?e.pixels:null,error:null,loading:!1}})}catch(n){if(m.current!==t)return;let r=n instanceof Error?n.message:String(n);h(t,e,e=>({...e,error:r,loading:!1}))}},_=(e,t,n)=>{if(!i||t<=0||n<=0)return;let r=i;l(i=>{let a=i.sessionId===r?i.files[e]:void 0;return!a||a.pixels?.w===t&&a.pixels.h===n?i:{...i,files:{...i.files,[e]:{...a,pixels:{w:t,h:n}}}}})},y=JSON.stringify(a?.open??[]);(0,v.useEffect)(()=>{let e=new Set(JSON.parse(y));l(t=>{let n=Object.keys(t.files).filter(t=>e.has(t));return n.length===Object.keys(t.files).length?t:{...t,files:Object.fromEntries(n.map(e=>[e,t.files[e]]))}})},[y]);let b=(0,v.useRef)(s);if((0,v.useEffect)(()=>{let e=b.current&&!s;b.current=s,o&&(e||!u[o])&&g(o)},[o,s,i]),!i||!a||!o)return null;let x=u[o],S=x?.shown??null,C=S?.kind===`text`&&S.markdown;return(0,W.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-bg`,"aria-label":`File viewer`,"data-testid":`file-viewer`,children:[(0,W.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 border-b border-border px-3 font-mono text-[11px] text-fg-faint`,children:[(0,W.jsx)(q.File,{className:`w-3.5 h-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:o,children:o}),x?.pixels?(0,W.jsxs)(`span`,{className:`shrink-0`,"data-testid":`file-viewer-pixels`,children:[x.pixels.w,` × `,x.pixels.h]}):null,S?(0,W.jsx)(`span`,{className:`shrink-0`,children:Rj(x.bytes)}):null,C?(0,W.jsx)(`span`,{className:`shrink-0 font-sans`,children:(0,W.jsx)(Jy,{label:`Markdown view`,value:d,options:BL,onChange:p})}):null,(0,W.jsx)(`span`,{className:`shrink-0 rounded bg-surface-2 px-1 text-[10px] uppercase tracking-wide`,children:`read-only`}),(0,W.jsx)(Y,{label:`Re-read this file`,className:`p-1`,onClick:()=>void g(o),"data-testid":`file-viewer-refresh`,children:(0,W.jsx)(q.Refresh,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(Y,{label:`Back to the chat`,className:`p-1`,onClick:()=>t.showChat(),"data-testid":`file-viewer-back`,children:(0,W.jsx)(q.X,{className:`w-3.5 h-3.5`})})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-3 py-2`,"data-testid":`file-viewer-body`,children:(0,W.jsx)(qL,{path:o,loaded:x,markdownMode:d,onPixels:(e,t)=>_(o,e,t)},`${i}\n${o}`)})]})}async function UL(e,t,n){let r=Ej(n),i=e.readSessionFileBytes?async()=>new Uint8Array(await e.readSessionFileBytes(t,n)):null;if(i&&r.mime!==null){let e=await i();return{shown:WL(r.kind,r.mime,e),bytes:e.byteLength}}if(i&&r.kind===`unknown`)return GL(await i(),!1);if(!e.readSessionFile)throw Error(`This host cannot read files — update it.`);let a=await e.readSessionFile(t,n),o=r.kind===`markdown`;return Fj(a)?i?GL(await i(),o):{shown:{kind:`binary`},bytes:a.length}:{shown:{kind:`text`,text:a,markdown:o},bytes:a.length}}function WL(e,t,n){return e===`pdf`?{kind:`pdf`}:{kind:e,blob:new Blob([n],{type:t}),digest:Lj(n)}}function GL(e,t){let n=Mj(e);if(n)return{shown:WL(n.kind,n.mime,e),bytes:e.length};let r=Ij(e);return{shown:r===null?{kind:`binary`}:{kind:`text`,text:r,markdown:t},bytes:e.length}}function KL(e,t){return`digest`in e&&`digest`in t&&e.kind===t.kind&&e.digest===t.digest}function qL({path:e,loaded:t,markdownMode:n,onPixels:r}){if(!t||t.loading&&t.shown===null)return(0,W.jsx)(JL,{children:`Reading…`});if(t.error&&t.shown===null)return(0,W.jsx)(JL,{tone:`danger`,testId:`file-viewer-error`,children:t.error});let i=t.shown;if(!i)return null;let a=pj(e),o=Rj(t.bytes);switch(i.kind){case`image`:return(0,W.jsx)(QL,{blob:i.blob,name:a,onPixels:r},i.digest);case`audio`:case`video`:return(0,W.jsx)($L,{kind:i.kind,blob:i.blob,name:a,size:o},i.digest);case`pdf`:return(0,W.jsxs)(JL,{testId:`file-viewer-pdf`,children:[a,` is a PDF document (`,o,`). The viewer cannot show PDF files — copy its path from the file list to open it in a PDF reader.`]});case`binary`:return(0,W.jsxs)(JL,{testId:`file-viewer-binary`,children:[a,` is not a text file (`,o,`), and not a picture or a clip the viewer can show.`]});case`text`:return(0,W.jsx)(YL,{path:e,text:i.text,markdown:i.markdown,mode:n})}}function JL({children:e,tone:t,testId:n}){return(0,W.jsx)(`div`,{className:t===`danger`?`py-4 text-xs text-danger`:`py-4 text-xs text-fg-faint`,"data-testid":n,children:e})}function YL({path:e,text:t,markdown:n,mode:r}){let i=t.length>RL,a=i?t.slice(0,RL):t;return(0,W.jsxs)(W.Fragment,{children:[n&&r===`preview`?(0,W.jsx)(`div`,{className:`max-w-3xl py-2 text-sm`,"data-testid":`file-viewer-markdown`,children:(0,W.jsx)(aN,{text:a})}):(0,W.jsx)(QM,{code:a,language:wj(e)}),i?(0,W.jsxs)(`div`,{className:`pb-2 text-[11px] text-fg-faint`,children:[`Showing the first `,Rj(RL),` of `,Rj(t.length),`.`]}):null]})}function XL(e){let[t,n]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let t=URL.createObjectURL(e);return n(t),()=>URL.revokeObjectURL(t)},[e]),t}var ZL={backgroundImage:`repeating-conic-gradient(rgb(128 128 128 / 0.22) 0% 25%, transparent 0% 50%)`,backgroundSize:`16px 16px`};function QL({blob:e,name:t,onPixels:n}){let r=XL(e),[i,a]=(0,v.useState)(!1);return i?(0,W.jsxs)(JL,{testId:`file-viewer-image-error`,children:[t,` could not be drawn — it may be damaged, or not the kind of picture its name says.`]}):r?(0,W.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center`,children:(0,W.jsx)(`img`,{src:r,alt:t,draggable:!1,"data-testid":`file-viewer-image`,className:`block max-h-full max-w-full object-contain`,style:ZL,onLoad:e=>n(e.currentTarget.naturalWidth,e.currentTarget.naturalHeight),onError:()=>a(!0)})}):null}function $L({kind:e,blob:t,name:n,size:r}){let i=XL(t),[a,o]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=e=>{e.effectiveDirective===`media-src`&&e.blockedURI.startsWith(`blob`)&&o(`policy`)};return document.addEventListener(`securitypolicyviolation`,e),()=>document.removeEventListener(`securitypolicyviolation`,e)},[]),a)return(0,W.jsx)(JL,{testId:`file-viewer-media-error`,children:a===`policy`?`${n} (${r}) cannot be played in this window: its security policy does not allow audio or video yet.`:`${n} (${r}) cannot be played here: its format or codec is not one Chromium plays.`});if(!i)return null;let s=()=>o(e=>e??`format`);return e===`audio`?(0,W.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center`,children:(0,W.jsx)(`audio`,{src:i,controls:!0,preload:`metadata`,onError:s,"data-testid":`file-viewer-audio`,className:`w-full max-w-xl`})}):(0,W.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center`,children:(0,W.jsx)(`video`,{src:i,controls:!0,preload:`metadata`,onError:s,"data-testid":`file-viewer-video`,className:`block max-h-full max-w-full bg-black`})})}function eR(e,t){return t.scrollWidth<=t.clientWidth||Math.abs(e.deltaX)>Math.abs(e.deltaY)||e.deltaY===0?0:e.deltaMode===1?e.deltaY*16:e.deltaMode===2?e.deltaY*t.clientWidth:e.deltaY}function tR(e){let t=e.split(/[\\/]+/).filter(Boolean);return t[t.length-1]??e}function nR({groupId:e,compact:t=!1,split:n=!1,dropIndex:r=null}={}){let{state:i,actions:a}=G(),o=jy(),s=Ay(),c=i.layout,l=e&&c.groups[e]?e:c.focused,u=c.groups[l],d=c.focused===l,f=Oy(),p=o?.projectDir??(s?.projectDir?s.cwd:null)??null,m=p?tR(p):`no folder`,h=u?.activeId??null,g=h?i.files[h]:void 0,_=g?.active??null,y=i.pageGroup&&c.groups[i.pageGroup]?i.pageGroup:c.focused,b=i.page!==null&&y===l?i.page:null,x=b===null?null:b.kind===`projects`?`Projects`:b.kind===`scheduled`?`Scheduled`:i.vaultProjects.find(e=>e.id===b.projectId)?.name??`Project`,[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(null),E=(0,v.useCallback)(()=>T(null),[]),[D,O]=(0,v.useState)(null),k=D?i.remote.tabs[D.id]??null:null,A=(0,v.useRef)(null);(0,v.useEffect)(()=>{A.current?.scrollIntoView({block:`nearest`,inline:`nearest`})},[_]);let j=typeof window<`u`?window.oonacode:void 0,M=typeof j?.openTabsInNewWindow==`function`,ee=i.windowRole===`popout`&&typeof j?.moveTabsToMainWindow==`function`,N=w?.kind===`chat`?Yg(c,w.id)??l:l,P=c.groups[N]?.ids??[],F=e_(c,N),I=w?w.kind===`chat`?[{key:`rename`,label:`Rename…`,icon:(0,W.jsx)(q.Edit,{className:`w-3.5 h-3.5`}),onSelect:()=>{a.selectSession(w.id),C(w.id)},testId:`tab-menu-rename`},{key:`split-right`,label:`Split right`,icon:(0,W.jsx)(q.Columns,{className:`w-3.5 h-3.5`}),separated:!0,onSelect:()=>a.splitTab(`right`,w.id),testId:`tab-menu-split-right`},{key:`split-down`,label:`Split down`,onSelect:()=>a.splitTab(`bottom`,w.id),testId:`tab-menu-split-down`},{key:`move-other-group`,label:`Move to other group`,disabled:F===null,onSelect:()=>a.moveTabToOtherGroup(w.id),testId:`tab-menu-move-other-group`},...M?[{key:`move-new-window`,label:`Move to new window`,icon:(0,W.jsx)(q.WindowOut,{className:`w-3.5 h-3.5`}),onSelect:()=>void a.moveTabToNewWindow(w.id),testId:`tab-menu-move-new-window`}]:[],...ee?[{key:`move-main-window`,label:`Move to main window`,onSelect:()=>void a.moveTabToMainWindow(w.id),testId:`tab-menu-move-main-window`}]:[],{key:`close`,label:`Close`,icon:(0,W.jsx)(q.X,{className:`w-3.5 h-3.5`}),separated:!0,onSelect:()=>a.closeTab(w.id),testId:`tab-menu-close`},{key:`close-others`,label:`Close other tabs`,disabled:P.length<2,onSelect:()=>{for(let e of P)e!==w.id&&a.closeTab(e)},testId:`tab-menu-close-others`},{key:`close-all`,label:`Close all tabs`,onSelect:()=>{for(let e of P)a.closeTab(e)},testId:`tab-menu-close-all`},{key:`delete`,label:`Delete`,icon:(0,W.jsx)(q.Trash,{className:`w-3.5 h-3.5`}),danger:!0,separated:!0,onSelect:()=>{i.drafts[w.id]?a.closeTab(w.id):O({id:w.id,title:w.title})},testId:`tab-menu-delete`}]:[{key:`close`,label:`Close`,icon:(0,W.jsx)(q.X,{className:`w-3.5 h-3.5`}),onSelect:()=>a.closeFile(w.path,h??void 0),testId:`tab-menu-close`},{key:`close-others`,label:`Close other files`,disabled:(g?.open.length??0)<2,onSelect:()=>{for(let e of g?.open??[])e!==w.path&&a.closeFile(e,h??void 0)},testId:`tab-menu-close-others`},{key:`close-all`,label:`Close all files`,onSelect:()=>{for(let e of g?.open??[])a.closeFile(e,h??void 0)},testId:`tab-menu-close-all`}]:[],te=(0,v.useMemo)(()=>t?Jg(c):u?.ids??[],[t,c,u]),ne=(0,v.useMemo)(()=>te.map(e=>{let n=i.drafts[e],r=i.transcripts[e]?.session??i.sessions.find(t=>t.id===e)??null,a=i.transcripts[e]?.status??r?.status??`idle`;return{id:e,draft:n!==void 0,title:n?xg(n):r?pg(r):`Session ${e.slice(0,8)}`,customTitle:n?n.title??``:r?.title??``,cwd:n?n.projectDir??``:r?.cwd??``,running:a===`running`||a===`waiting_permission`,waiting:a===`waiting_permission`,error:a===`error`,group:t?Yg(c,e)??l:l}}),[te,i.drafts,i.transcripts,i.sessions,t,c,l]),re=(0,v.useCallback)((e,t)=>{C(null),a.renameTab(e,t)},[a]),L=f?i.remote.tabs[f]??null:null,ie=(0,v.useRef)(null),R=t?c.groups[c.focused]?.activeId??null:u?.activeId??null;(0,v.useEffect)(()=>{ie.current?.scrollIntoView({block:`nearest`,inline:`nearest`})},[R]);let ae=(e,t)=>{if(!Z_())return;let n=typeof window<`u`?window:null;a.tabDraggedOut(t,{screenX:Number.isFinite(e.screenX)?e.screenX:null,screenY:Number.isFinite(e.screenY)?e.screenY:null,outside:n?$_(e,n):!1})},oe=(0,v.useRef)(null),se=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let e=oe.current;if(!e)return;let t=e=>{let t=se.current;if(!t)return;let n=eR(e,t);n!==0&&(e.preventDefault(),t.scrollLeft+=n)},n=e=>{e.button===1&&e.preventDefault()};return e.addEventListener(`wheel`,t,{passive:!1}),e.addEventListener(`mousedown`,n),()=>{e.removeEventListener(`wheel`,t),e.removeEventListener(`mousedown`,n)}},[]),(0,W.jsxs)(`div`,{ref:oe,className:U(`flex h-9 shrink-0 items-stretch gap-1 border-b border-border bg-surface px-1`,n&&(d?`shadow-[inset_0_2px_0_var(--accent)]`:`opacity-95`)),role:`tablist`,"aria-label":`Open chats`,"data-testid":`tab-bar`,"data-group":l,children:[(0,W.jsxs)(`div`,{ref:se,className:`flex min-w-0 flex-1 items-stretch gap-1 overflow-x-auto`,"data-testid":`tabs-scroller`,"data-tab-strip":!0,children:[b===null?null:(0,W.jsxs)(`div`,{role:`tab`,"aria-selected":!0,tabIndex:0,onAuxClick:e=>{e.button===1&&(e.preventDefault(),a.closePage())},className:`group relative flex min-w-[7rem] max-w-[15rem] shrink-0 items-center gap-1.5 rounded-t-md border-b-2 border-accent bg-surface-2 px-2 text-xs text-fg`,"data-testid":`page-tab`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 py-1`,children:[b.kind===`scheduled`?(0,W.jsx)(q.Clock,{className:`w-3 h-3 shrink-0 text-fg-faint`}):(0,W.jsx)(q.Project,{className:`w-3 h-3 shrink-0 text-project`}),(0,W.jsx)(`span`,{className:`truncate`,children:ug(x??``,28)})]}),(0,W.jsx)(Y,{label:`Close ${x??`page`}`,className:`p-0.5`,onClick:()=>a.closePage(),"data-testid":`page-tab-close`,children:(0,W.jsx)(q.X,{className:`w-3 h-3`})})]}),ne.map((e,i)=>{let o=e.id===R&&_===null&&b===null,s=S===e.id,c=t?te.filter((e,t)=>t<i&&ne[t]?.group===l).length:i,u=r!==null&&e.group===l&&r===c;return(0,W.jsxs)(`div`,{ref:e.id===R?ie:void 0,role:`tab`,"aria-selected":o,tabIndex:o?0:-1,draggable:!s,"data-tab-id":e.id,"data-tab-group":e.group,onDragStart:t=>Y_(t.dataTransfer,{tabId:e.id,groupId:e.group}),onDragEnd:t=>ae(t,e.id),onContextMenu:t=>{t.preventDefault(),T({kind:`chat`,id:e.id,title:e.title,at:{x:t.clientX,y:t.clientY},el:t.currentTarget})},onAuxClick:t=>{t.button===1&&(t.preventDefault(),a.closeTab(e.id))},className:U(`group relative flex min-w-[7rem] max-w-[15rem] shrink-0 items-center gap-1.5 rounded-t-md border-b-2 px-2 text-xs`,o?n&&!d?`border-fg-faint bg-surface-2 text-fg`:`border-accent bg-surface-2 text-fg`:`border-transparent text-fg-muted hover:bg-surface-2`),"data-testid":`tab-${e.id}`,children:[u?(0,W.jsx)(rR,{}):null,s?(0,W.jsx)(iR,{initial:e.customTitle,placeholder:e.title,onCommit:t=>re(e.id,t),onCancel:()=>C(null)}):(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{a.selectSession(e.id),a.showChat(e.id)},onDoubleClick:()=>C(e.id),title:e.cwd?`${e.title}\n${e.cwd}`:`${e.title}\nDouble-click to rename`,className:`flex min-w-0 flex-1 items-center gap-1.5 py-1 text-left`,children:[e.running?(0,W.jsx)(q.Spinner,{className:U(`w-3 h-3 shrink-0`,e.waiting?`text-warn`:`text-accent`),title:`Agent running`}):e.error?(0,W.jsx)(q.Alert,{className:`w-3 h-3 shrink-0 text-danger`}):(0,W.jsx)(`span`,{className:`w-3 shrink-0`,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`truncate`,children:ug(e.title,28)})]}),(0,W.jsx)(Y,{label:`Close ${e.title}`,className:`p-0.5 opacity-0 group-hover:opacity-100 focus:opacity-100`,onClick:()=>a.closeTab(e.id),children:(0,W.jsx)(q.X,{className:`w-3 h-3`})})]},e.id)}),r!==null&&r>=(u?.ids.length??0)?(0,W.jsx)(`div`,{className:`relative w-2 shrink-0`,"aria-hidden":!0,children:(0,W.jsx)(rR,{})}):null,g?.open.map(e=>{let t=_===e&&b===null,n=pj(e);return(0,W.jsxs)(`div`,{ref:t?A:void 0,role:`tab`,"aria-selected":t,tabIndex:t?0:-1,title:e,onContextMenu:t=>{t.preventDefault(),T({kind:`file`,path:e,at:{x:t.clientX,y:t.clientY},el:t.currentTarget})},onAuxClick:t=>{t.button===1&&(t.preventDefault(),a.closeFile(e,h??void 0))},className:U(`group relative flex min-w-[6rem] max-w-[14rem] shrink-0 items-center gap-1.5 rounded-t-md border-b-2 px-2 text-xs`,t?`border-accent bg-surface-2 text-fg`:`border-transparent text-fg-muted hover:bg-surface-2`),"data-testid":`file-tab-${e}`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>a.activateFile(e,h??void 0),className:`flex min-w-0 flex-1 items-center gap-1.5 py-1 text-left`,children:[(0,W.jsx)(q.File,{className:`w-3 h-3 shrink-0 text-fg-faint`}),(0,W.jsx)(`span`,{className:`truncate`,children:ug(n,28)})]}),(0,W.jsx)(Y,{label:`Close ${n}`,className:`p-0.5 opacity-0 group-hover:opacity-100 focus:opacity-100`,onClick:()=>a.closeFile(e,h??void 0),"data-testid":`file-tab-close-${e}`,children:(0,W.jsx)(q.X,{className:`w-3 h-3`})})]},`file:${e}`)})]}),(0,W.jsx)(nx,{open:w!==null,at:w?.at??{x:0,y:0},anchorEl:w?.el??null,label:`Tab actions`,onClose:E,items:I.map(e=>({...e,onSelect:()=>{E(),e.onSelect()}}))}),(0,W.jsx)(Xy,{open:D!==null,title:D?`Delete "${ug(D.title,60)}"?`:`Delete this chat?`,message:k?`It is deleted on ${k.hostName} — the only place it is kept — so it is gone from every device. Files, folders and code on that PC are not touched — only the chat is deleted.`:`It is deleted from this PC — the only place it is kept — so it is gone from every device. Your files, folder and code are not touched — only the chat is deleted.`,onConfirm:()=>{D&&(k?a.deleteRemoteSession(k.hostId,k.sessionId):a.deleteSession(D.id))},onClose:()=>O(null)}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 pl-1`,children:[(0,W.jsx)(Y,{label:`New chat`,onClick:()=>{a.focusGroup(l),a.newTab()},"data-testid":`new-tab`,children:(0,W.jsx)(q.Plus,{className:`w-4 h-4`})}),(0,W.jsxs)(`button`,{hidden:b!==null,type:`button`,title:L?`Choose a project folder in OonaCode on ${L.hostName}`:p?`${p} — click to change the folder`:`No project folder: this chat runs in its own workspace. Click to use one of your folders.`,"aria-label":L?`Choose a project folder in OonaCode on ${L.hostName}`:`Use a project folder…`,disabled:L!==null,onClick:()=>a.openDialog(`project`),className:`flex max-w-[220px] items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-fg-muted hover:border-accent/60 hover:text-fg disabled:opacity-50`,"data-testid":`open-project-dialog`,children:[(0,W.jsx)(q.Folder,{className:`w-3.5 h-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`hidden truncate sm:inline`,"data-testid":`folder-chip`,children:m})]})]})]})}function rR(){return(0,W.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute -left-[3px] top-1 bottom-1 w-[3px] rounded bg-accent`,"data-testid":`tab-drop-mark`})}function iR({initial:e,placeholder:t,onCommit:n,onCancel:r}){let[i,a]=(0,v.useState)(e),o=(0,v.useRef)(null),s=(0,v.useRef)(!1);return(0,v.useEffect)(()=>{o.current?.focus(),o.current?.select()},[]),(0,W.jsx)(`input`,{ref:o,"aria-label":`Rename tab`,"data-testid":`tab-title-input`,className:`min-w-0 flex-1 rounded border border-accent bg-bg px-1 py-0.5 text-xs outline-none`,value:i,maxLength:500,placeholder:t,spellCheck:!1,onChange:e=>a(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),n(i)):e.key===`Escape`&&(e.preventDefault(),s.current=!0,r())},onBlur:()=>{s.current||n(i)}})}function aR({page:e}){return e.kind===`projects`?(0,W.jsx)(XF,{}):e.kind===`project`?(0,W.jsx)(QF,{projectId:e.projectId},e.projectId):(0,W.jsx)(iI,{})}function oR(e){let[t,n]=(0,v.useState)(null);return(0,v.useLayoutEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=()=>{let e=t.getBoundingClientRect(),r=Math.round(e.width),i=Math.round(e.height);(r!==0||i!==0)&&n(e=>e&&e.width===r&&e.height===i?e:{width:r,height:i})};r();let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}function sR(){let{state:e}=G(),t=(0,v.useRef)(null),n=oR(t),r=e.layout,i=r.root.type===`split`,a=i&&n!==null&&D_(r,n.width,n.height);return(0,W.jsx)(`div`,{ref:t,className:`relative flex min-h-0 min-w-0 flex-1`,"data-testid":`editor-area`,"data-groups":qg(r).length,"data-compact":a?`true`:`false`,children:i&&!a?(0,W.jsx)(cR,{node:r.root,path:[]}):(0,W.jsx)(mR,{groupId:r.focused,compact:a})})}function cR({node:e,path:t}){return e.type===`group`?(0,W.jsx)(mR,{groupId:e.id,compact:!1,split:!0}):(0,W.jsx)(dR,{node:e,path:t})}function lR(e){return e.type===`group`?e.id:`split:${lR(e.children[0])}`}var uR=4;function dR({node:e,path:t}){let{actions:n}=G(),r=e.direction===`row`,i=(0,v.useRef)(null),a=(0,v.useRef)([]),o=(0,v.useCallback)(o=>s=>{let c=i.current;if(!c||s.button!==0)return;s.preventDefault();let l=s.currentTarget,u=(r?c.clientWidth:c.clientHeight)-uR*(e.children.length-1);if(u<=0)return;let d=r?s.clientX:s.clientY,f=[...e.sizes],p=(f[o]??0)+(f[o+1]??0),m=e=>(r?E_(e).width:E_(e).height)/u,h=m(e.children[o]),g=m(e.children[o+1]),_=f,v=e=>{let t=((r?e.clientX:e.clientY)-d)/u,n=p<=h+g?p/2:Math.min(p-g,Math.max(h,(f[o]??0)+t));_=[...f],_[o]=n,_[o+1]=p-n;let i=a.current[o],s=a.current[o+1];i&&(i.style.flexGrow=String(_[o])),s&&(s.style.flexGrow=String(_[o+1]))},y=()=>{l.removeEventListener(`pointermove`,v),l.removeEventListener(`pointerup`,y),l.removeEventListener(`pointercancel`,y),n.resizeSplit(t,_)};try{l.setPointerCapture(s.pointerId)}catch{}l.addEventListener(`pointermove`,v),l.addEventListener(`pointerup`,y),l.addEventListener(`pointercancel`,y)},[n,e,t,r]);return(0,W.jsx)(`div`,{ref:i,className:U(`flex min-h-0 min-w-0 flex-1`,r?`flex-row`:`flex-col`),"data-split":e.direction,children:e.children.map((i,s)=>(0,W.jsxs)(v.Fragment,{children:[s>0?(0,W.jsx)(`div`,{role:`separator`,"aria-orientation":r?`vertical`:`horizontal`,"aria-label":`Resize the groups (double-click: make them equal)`,title:`Drag to resize · double-click to make them equal`,onPointerDown:o(s-1),onDoubleClick:()=>n.equalizeSplit(t),className:U(`shrink-0 bg-border transition-colors hover:bg-accent/60`,r?`w-1 cursor-col-resize`:`h-1 cursor-row-resize`),"data-testid":`split-divider-${t.join(`.`)||`root`}-${s-1}`}):null,(0,W.jsx)(`div`,{ref:e=>{a.current[s]=e},className:`flex min-h-0 min-w-0`,style:{flexGrow:e.sizes[s]??1,flexShrink:1,flexBasis:0},"data-split-cell":s,children:(0,W.jsx)(cR,{node:i,path:[...t,s]})})]},lR(i)))})}function fR(e,t){return e===t?!0:!e||!t?!1:e.groupId===t.groupId&&e.zone===t.zone&&e.index===t.index}function pR({target:e}){let t=A_(e.zone);return(0,W.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute z-40 rounded-md border-2 border-accent/70 bg-accent/15 transition-all duration-100`,style:{left:`${t.left*100}%`,top:`${t.top*100}%`,width:`${t.width*100}%`,height:`${t.height*100}%`},"data-testid":`drop-overlay`,"data-zone":e.zone})}function mR({groupId:e,compact:t,split:n=!1}){let{state:r,actions:i}=G(),a=(0,v.useRef)(null),o=r.layout,s=o.groups[e],c=o.focused===e,l=s?.activeId??null,u=r.pageGroup&&o.groups[r.pageGroup]?r.pageGroup:o.focused,d=r.page!==null&&u===e?r.page:null,[f,p]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(f===null||typeof document>`u`)return;let e=()=>p(null);return document.addEventListener(`dragend`,e,!0),document.addEventListener(`drop`,e,!0),()=>{document.removeEventListener(`dragend`,e,!0),document.removeEventListener(`drop`,e,!0)}},[f]);let m=e=>{if(!Q_(e.dataTransfer))return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`move`;let t=a.current,n=t?ev(t,e.clientX,e.clientY):null,r=X_(),i=n&&(!r||x_(o,r.tabId,n))?n:null;p(e=>fR(e,i)?e:i)},h=e=>{let t=e.relatedTarget;t instanceof Node&&a.current?.contains(t)||p(null)},g=e=>{if(!Q_(e.dataTransfer))return;e.preventDefault(),e.stopPropagation(),p(null);let t=X_();if(!t)return;let n=a.current,r=n?ev(n,e.clientX,e.clientY):null;Z_(),r&&i.dropTab(t.tabId,r)},_=()=>i.focusGroup(e);return(0,W.jsx)(`section`,{ref:a,className:U(`relative flex min-h-0 min-w-0 flex-1 flex-col`,n&&`outline-offset-[-1px]`),"aria-label":n?`Editor group ${qg(o).indexOf(e)+1}`:void 0,"data-editor-group":e,"data-focused":c?`true`:`false`,"data-compact":t?`true`:`false`,"data-testid":`editor-group-${e}`,onPointerDownCapture:_,onFocusCapture:_,onDragEnterCapture:e=>{Q_(e.dataTransfer)&&e.preventDefault()},onDragOverCapture:m,onDragLeave:h,onDropCapture:g,children:(0,W.jsx)(v.Profiler,{id:e,onRender:$b,children:(0,W.jsxs)(Ey,{sessionId:d?null:l,groupId:e,focused:c,children:[(0,W.jsx)(nR,{groupId:e,compact:t,split:n,dropIndex:f?.zone===`center`&&f.index!==void 0?f.index:null}),(0,W.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,"data-group-body":!0,children:[d?(0,W.jsx)(aR,{page:d}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ox,{}),l&&r.files[l]?.active?(0,W.jsx)(HL,{}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ML,{}),c?(0,W.jsx)(LL,{}):null,(0,W.jsx)(EF,{},l??`none`)]})]}),f&&f.index===void 0?(0,W.jsx)(pR,{target:f}):null]})]})})})}function hR({open:e,onClose:t}){let{state:n,actions:r}=G();(0,v.useEffect)(()=>{e&&r.runDoctor()},[e,r]);let i=n.doctor,a=i?.filter(e=>!e.ok).length??0;return(0,W.jsxs)(Ky,{open:e,title:`Doctor`,onClose:t,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(J,{onClick:()=>void r.runDoctor(),children:[(0,W.jsx)(q.Refresh,{className:`w-3.5 h-3.5`}),` Run again`]}),(0,W.jsx)(J,{variant:`primary`,onClick:t,children:`Close`})]}),children:[n.info?(0,W.jsxs)(`div`,{className:`mb-3 grid grid-cols-1 gap-x-4 gap-y-0.5 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[`Host: `,n.info.hostName,` (`,n.info.platform,`/`,n.info.arch,`)`]}),(0,W.jsxs)(`div`,{children:[`App: `,Gv(n.info.appVersion,n.info.cliChannel),n.info.cliChannel&&n.info.cliChannel!==`stable`?` — ${n.info.cliChannel} channel (updates stay within it)`:``]}),(0,W.jsxs)(`div`,{className:`truncate`,title:n.info.engine.binaryPath,children:[`Engine: `,n.info.engine.version??`unknown`,` — `,n.info.engine.binaryPath]}),(0,W.jsxs)(`div`,{className:`truncate`,title:n.info.engine.configDir,children:[`Isolated config dir: `,n.info.engine.configDir]}),(0,W.jsxs)(`div`,{children:[`Listening: `,n.info.addresses.join(`, `),`:`,n.info.port]})]}):null,i===null?(0,W.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,W.jsx)(q.Spinner,{}),` Running checks…`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mb-2 text-sm`,children:a===0?(0,W.jsxs)(`span`,{className:`text-ok`,children:[`All `,i.length,` checks passed.`]}):(0,W.jsxs)(`span`,{className:`text-danger`,children:[a,` of `,i.length,` checks need attention.`]})}),(0,W.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:i.map(e=>(0,W.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 text-sm`,children:[e.ok?(0,W.jsx)(q.Check,{className:`mt-0.5 text-ok`}):(0,W.jsx)(q.Alert,{className:`mt-0.5 text-danger`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,W.jsx)(`div`,{className:`pre-wrap text-xs text-fg-muted`,children:e.detail}),!e.ok&&e.fix?(0,W.jsx)(`div`,{className:`mt-1 pre-wrap rounded bg-surface-2 px-2 py-1 font-mono text-xs`,children:e.fix}):null]})]},e.id))})]})]})}function gR({open:e,onClose:t}){let{state:n,actions:r}=G(),i=Ay(),a=jy(),o=n.currentSessionId,[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(null),h=a?a.projectDir??null:i?.cwd??null,g=!a&&i!==null&&!i.projectDir;(0,v.useEffect)(()=>{e&&(c(h??``),m(null),u(!1),f(!1))},[e,h]);let _=(0,v.useCallback)(async e=>{let t=e.trim();if(t){u(!0),m(null);try{m(await r.inspectProject(t))}finally{u(!1)}}},[r]),y=(0,v.useCallback)(async()=>{let e=typeof window<`u`?window.oonacode:void 0;if(!e?.pickDirectory)return;let t=await e.pickDirectory({title:`Choose a project folder`});t&&(c(t),await _(t))},[_]),b=(0,v.useCallback)(async()=>{if(!(!p||!o)){f(!0);try{await r.attachProject(p.dir,o)&&t()}finally{f(!1)}}},[p,o,r,t]),x=o===null?null:n.remote.tabs[o]??null,S=p!==null&&h!==null&&_R(p.dir,h),C=o!==null&&x===null&&p!==null&&!S&&p.exists&&p.isDirectory&&p.anchorable;return(0,W.jsx)(Ky,{open:e,title:`Use a project folder`,onClose:t,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{onClick:t,children:C?`Not now`:`Close`}),C?(0,W.jsx)(J,{variant:`primary`,busy:d,onClick:()=>void b(),"data-testid":`project-switch`,children:`Switch to this project`}):null]}),children:x?(0,W.jsxs)(yR,{tone:`warn`,testId:`project-remote`,children:[`This chat runs on `,(0,W.jsx)(`strong`,{children:x.hostName}),`, and a project folder is a folder on that PC. Open OonaCode there and choose it from that window — this one can only see this machine's disk, and the folder has to be where the agent actually works.`]}):(0,W.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),_(s)},children:[(0,W.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-2 px-3 py-2 text-xs text-fg-muted space-y-1.5`,children:[(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{className:`text-fg`,children:`What a project folder is.`}),` It tells this chat which folder on this PC it is working in. The agent then loads that folder's`,(0,W.jsx)(`span`,{className:`font-mono`,children:` CLAUDE.md`}),` and`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:`.claude/`}),` settings, and — the part you noticed — it stops asking permission for edits and commands inside that folder, because you have said "this is the project, go ahead here".`]}),(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{className:`text-fg`,children:`Where it is used.`}),` Every message in this chat runs with that folder as the working directory: relative paths resolve there, the file tools default there, and its project rules apply. Each chat has its own folder; other chats are unaffected. The chat still keeps running in the app-private workspace until you attach one.`]}),(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{className:`text-fg`,children:`Good folders:`}),` the root of a code project you own — a repository or app directory, usually the one with a`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:`CLAUDE.md`}),` or a`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:`.claude/`}),` folder, a`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:`.git`}),` repo, or a`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:`package.json`}),`.`]}),(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{className:`text-fg`,children:`Do not set:`}),` your whole home directory, a drive root (`,(0,W.jsx)(`span`,{className:`font-mono`,children:`C:`}),`),`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:`Desktop`}),`,`,(0,W.jsx)(`span`,{className:`font-mono`,children:` Downloads`}),`, a system or Program Files folder, or a cloud-synced root — attaching there gives the agent silent, unprompted edit access across far more than a project, which is exactly what the permission prompts exist to prevent. OonaCode already refuses the home directory and drive roots for this reason.`]}),(0,W.jsxs)(`p`,{children:[`A folder buys `,(0,W.jsx)(`strong`,{className:`text-fg`,children:`silence and context, never access`}),`: the agent can already read and write anywhere with your approval — outside a project it just asks first.`]})]}),h===null?null:(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`project-current`,children:[`This chat runs in `,(0,W.jsx)(`span`,{className:`break-all font-mono text-fg`,children:h}),g?` — its own workspace, which OonaCode made for it`:``,`.`]}),(0,W.jsx)(Wy,{label:`Folder on this PC`,hint:`An absolute path. Only this machine can see it, so OonaCode asks the host what is there.`,children:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{className:X,value:s,onChange:e=>{c(e.target.value),m(null)},placeholder:`D:\\projects\\my-app`,"aria-label":`Project folder`,autoFocus:!0,spellCheck:!1}),window.oonacode?.pickDirectory?(0,W.jsxs)(J,{onClick:()=>void y(),children:[(0,W.jsx)(q.Folder,{className:`w-4 h-4`}),` Browse`]}):null,(0,W.jsx)(J,{busy:l,disabled:s.trim().length===0,onClick:()=>void _(s),"data-testid":`project-check`,children:`Check`})]})}),p?S?(0,W.jsxs)(yR,{tone:`accent`,testId:`project-verdict`,children:[`This chat already runs in `,(0,W.jsx)(`strong`,{className:`font-mono`,children:p.dir}),g?` — type or browse to the folder you want it to move to.`:`.`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(vR,{result:p,restarts:i!==null}),o===null?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Open a chat first — a folder is attached to one chat, not to the app.`}):null]}):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`A chat does not need a folder. It already has every file tool, everywhere — outside a project it simply asks before touching a file. Naming a project adds that project's configuration and context; it never adds access that was missing.`})]})})}function _R(e,t){let n=e=>{let t=e.trim().replace(/\\/g,`/`).replace(/\/+$/,``);return/^[a-z]:/i.test(t)?t.toLowerCase():t};return n(e)===n(t)}function vR({result:e,restarts:t}){return!e.exists||!e.isDirectory?(0,W.jsxs)(yR,{tone:`danger`,testId:`project-verdict`,children:[(0,W.jsx)(`strong`,{className:`font-mono`,children:e.dir}),` is not a folder on this PC.`]}):e.anchorable?e.looksLikeProject?(0,W.jsxs)(yR,{tone:`accent`,testId:`project-verdict`,children:[(0,W.jsxs)(`div`,{className:`font-medium`,children:[`Switching this chat to `,e.dir,` loads:`]}),(0,W.jsxs)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-4`,children:[(0,W.jsxs)(`li`,{children:[`its `,(0,W.jsx)(`code`,{children:e.hasClaudeMd?`CLAUDE.md`:`CLAUDE.md (none at the root)`}),` and the ones above it`]}),(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`code`,{children:`.claude/settings.json`}),` and `,(0,W.jsx)(`code`,{children:`settings.local.json`}),e.hasClaudeDir?``:` (none yet)`]}),(0,W.jsx)(`li`,{children:`that project's skills, sub-agents, slash commands and hooks`}),(0,W.jsx)(`li`,{children:`silence: file operations inside it stop raising a permission card`})]}),(0,W.jsx)(`div`,{className:`mt-1.5`,children:t?`The agent restarts once to pick them up and resumes this conversation exactly where it is — nothing is lost.`:`Your first message starts the chat there.`})]}):(0,W.jsxs)(yR,{tone:`accent`,testId:`project-verdict`,children:[(0,W.jsxs)(`div`,{className:`font-medium`,children:[`Switching this chat to `,e.dir,`:`]}),(0,W.jsxs)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-4`,children:[(0,W.jsxs)(`li`,{children:[`it has no `,(0,W.jsx)(`code`,{children:`CLAUDE.md`}),` and no `,(0,W.jsx)(`code`,{children:`.claude/`}),` folder yet, so nothing is loaded from it — add them later and the next restart picks them up`]}),(0,W.jsx)(`li`,{children:`silence: file operations inside it stop raising a permission card`})]}),(0,W.jsx)(`div`,{className:`mt-1.5`,children:t?`The agent restarts once and resumes this conversation exactly where it is — nothing is lost.`:`Your first message starts the chat there.`})]}):(0,W.jsxs)(yR,{tone:`danger`,testId:`project-verdict`,children:[`OonaCode will not use `,(0,W.jsx)(`strong`,{className:`font-mono`,children:e.dir}),` as a project:`,` `,e.reason??`it is not a usable project directory`,`.`]})}function yR({tone:e,testId:t,children:n}){return(0,W.jsx)(`div`,{className:`rounded-md border px-3 py-2 text-xs ${e===`danger`?`border-danger/40 bg-danger-soft text-danger`:e===`warn`?`border-warn/50 bg-warn-soft text-warn`:`border-accent/40 bg-accent-soft text-fg`}`,"data-testid":t,children:n})}var bR=(e,t)=>`${e}::${t}`;function xR(e){let t=e.indexOf(`::`);return t<=0||t===e.length-2?null:{providerId:e.slice(0,t),model:e.slice(t+2)}}function SR(e){let t=e?.chatDefaults??{};return{name:e?.name??``,goal:e?.goal??``,instructions:e?.instructions??``,repositories:(e?.repositories??[]).join(`
|
|
155
|
+
`),model:t.providerId&&t.model?bR(t.providerId,t.model):``,effort:t.effort??``,cwd:t.cwd??``,memoryEnabled:e?.memoryEnabled===!0,memory:e?.memory??``,tasksEnabled:e?.tasksEnabled!==!1,minInterval:String(e?.minRoutineIntervalMinutes??15)}}var CR=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0);function wR(e){let t=xR(e.model);return!t&&!e.effort&&!e.cwd.trim()?null:{providerId:t?.providerId??null,model:t?.model??null,effort:e.effort||null,cwd:e.cwd.trim()||null}}function TR(e){if(!e.name.trim())return`A project needs a name.`;let t=Number(e.minInterval);return!Number.isInteger(t)||t<ec.minIntervalFloor||t>ec.minIntervalCeiling?`The minimum interval is a whole number of minutes, ${ec.minIntervalFloor}–${ec.minIntervalCeiling}.`:CR(e.repositories).length>ec.repositories?`At most ${ec.repositories} repositories.`:null}var ER=(e,t)=>(e?.providerId??null)===(t?.providerId??null)&&(e?.model??null)===(t?.model??null)&&(e?.effort??null)===(t?.effort??null)&&(e?.cwd??null)===(t?.cwd??null);function DR(e,t){let n=SR(t),r={};e.name.trim()!==t.name&&(r.name=e.name.trim()),e.goal!==n.goal&&(r.goal=e.goal),e.instructions!==t.instructions&&(r.instructions=e.instructions);let i=CR(e.repositories);i.join(`
|
|
156
156
|
`)!==(t.repositories??[]).join(`
|
|
157
|
-
`)&&(r.repositories=i);let a=CR(e);TR(t.chatDefaults,a)||(r.chatDefaults=a),e.memoryEnabled!==n.memoryEnabled&&(r.memoryEnabled=e.memoryEnabled),e.memory!==n.memory&&(r.memory=e.memory),e.tasksEnabled!==n.tasksEnabled&&(r.tasksEnabled=e.tasksEnabled);let o=Number(e.minInterval);return String(o)!==n.minInterval&&Number.isInteger(o)&&(r.minRoutineIntervalMinutes=o),r}function DR(e){let t=CR(e),n=SR(e.repositories),r=Number(e.minInterval);return{name:e.name.trim(),instructions:e.instructions,...e.goal.trim()?{goal:e.goal}:{},...n.length>0?{repositories:n}:{},...t?{chatDefaults:t}:{},...e.memoryEnabled?{memoryEnabled:!0}:{},...e.memory?{memory:e.memory}:{},...e.tasksEnabled?{}:{tasksEnabled:!1},...Number.isInteger(r)&&r!==15?{minRoutineIntervalMinutes:r}:{}}}function OR(e,t){if(t===null){let t=xR(null);return Object.keys(t).some(n=>e[n]!==t[n])}return Object.keys(ER(e,t)).length>0}function kR(e){let t=typeof window<`u`?window.oonacode:void 0;t?.openExternal?t.openExternal(e):window.open(e,`_blank`,`noopener,noreferrer`)}function AR({open:e,onClose:t}){let{state:n,actions:r}=G(),i=n.claudeLogin,a=n.ui.claudeLoginMode,[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),g=(0,v.useRef)(null),[_,y]=(0,v.useState)(0),[b,x]=(0,v.useState)(null),S=i?.phase===`starting`||i?.phase===`awaiting_browser`||i?.phase===`awaiting_code`,C=i!=null&&(S||b!==null&&i.id===b),w=C?i:null,T=C&&S,E=w?.phase??`idle`,D=T?w?.url??w?.fallbackUrl??null:null,O=E===`connected`,k=O||E===`failed`||E===`cancelled`,A=!a&&!S&&!m,j=k&&!A;(0,v.useEffect)(()=>{if(!e)return;s(``),h(null),p(!1),x(null),g.current=null,r.refreshClaudeLogin();let t=setInterval(()=>void r.refreshClaudeLogin(),2e3);return()=>clearInterval(t)},[e,r]),(0,v.useEffect)(()=>{if(!e||!a)return;let t=!1;return(async()=>{let e=await r.startClaudeLogin();t||!e||(e.login?x(e.login.id):h(e))})(),()=>{t=!0}},[e,a,_,r]),(0,v.useEffect)(()=>{!e||!D||!a||g.current===D||!T||(g.current=D,a===`open`?kR(D):navigator.clipboard?navigator.clipboard.writeText(D).then(()=>{d(!0),r.toast(`info`,`Sign-in link copied — paste it into the browser where you are signed in to Claude`),setTimeout(()=>d(!1),2500)}).catch(()=>r.toast(`error`,`Could not copy — use the Copy button below`)):r.toast(`error`,`Could not copy — select the link and copy it by hand`))},[e,D,a,T,r]),(0,v.useEffect)(()=>{w?.phase===`connected`&&r.refreshClaudeSubscription()},[w?.phase,r]);let M=m?.command?`${m.command.file} ${m.command.args.join(` `)}`:null,ee=async()=>{if(D)try{await navigator.clipboard.writeText(D),d(!0),setTimeout(()=>d(!1),1500)}catch{r.toast(`error`,`Could not copy — select the link and copy it by hand`)}},N=async()=>{if(o.trim()){l(!0);try{await r.submitClaudeLoginCode(o)&&s(``)}finally{l(!1)}}},P=A?(0,W.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2`,children:[(0,W.jsx)(J,{onClick:t,"data-testid":`claude-login-close`,children:`Close`}),(0,W.jsxs)(J,{onClick:()=>r.openClaudeLogin(`copy`),"data-testid":`claude-login-copy-mode`,children:[(0,W.jsx)(q.Copy,{className:`w-4 h-4`}),` Copy link`]}),(0,W.jsxs)(J,{variant:`primary`,onClick:()=>r.openClaudeLogin(`open`),"data-testid":`claude-login-open-mode`,children:[(0,W.jsx)(q.LogIn,{className:`w-4 h-4`}),` Sign in with my subscription`]})]}):j||m?(0,W.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[O?null:(0,W.jsx)(J,{onClick:()=>{g.current=null,h(null),x(null),a||r.openClaudeLogin(`open`),y(e=>e+1)},"data-testid":`claude-login-retry`,children:`Try again`}),(0,W.jsx)(J,{variant:`primary`,onClick:t,"data-testid":`claude-login-close`,children:`Close`})]}):(0,W.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[(0,W.jsx)(J,{onClick:t,children:`Keep in background`}),(0,W.jsx)(J,{variant:`danger`,onClick:()=>void r.cancelClaudeLogin(),"data-testid":`claude-login-cancel`,children:`Cancel sign-in`})]});return(0,W.jsx)(Ky,{open:e,title:`Connect your Claude subscription`,onClose:t,footer:P,children:(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Your Claude Pro/Max login runs the genuine Claude Code engine directly against api.anthropic.com — never through the gateway. The token it stores lasts a year and syncs to every PC you sign in to.`}),A?(0,W.jsxs)(`div`,{className:`space-y-2 text-sm`,"data-testid":`claude-login-choose`,children:[(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`span`,{className:`font-medium`,children:`Sign in with my subscription`}),` opens the Claude sign-in page in this PC's browser.`]}),(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`span`,{className:`font-medium`,children:`Copy link`}),` copies the same page's link for the browser where you are already signed in to Claude — any browser on this PC works.`]}),(0,W.jsx)(`p`,{className:`text-fg-faint`,children:`Either way this window connects by itself when you finish signing in.`})]}):null,A?null:(0,W.jsx)(`div`,{className:`rounded-md border border-border bg-surface-2 p-3 text-xs`,"data-testid":`claude-login-wait`,children:D?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mb-1 text-fg-faint`,children:a===`copy`?`Sign-in link (copied):`:`Sign-in link (opened in your browser):`}),(0,W.jsx)(`div`,{className:`break-all font-mono select-all`,"data-testid":`claude-login-url`,children:D}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,W.jsxs)(J,{size:`sm`,onClick:()=>void ee(),"data-testid":`claude-login-copy`,children:[(0,W.jsx)(q.Copy,{className:`w-3 h-3`}),` `,u?`Copied`:`Copy link`]}),(0,W.jsx)(J,{size:`sm`,onClick:()=>kR(D),children:`Open in browser`})]})]}):O?null:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-fg-muted`,children:[(0,W.jsx)(q.Spinner,{className:`w-4 h-4 animate-spin`}),` Preparing your sign-in link…`]})}),(0,W.jsx)(`div`,{className:U(`text-sm`,O?`text-ok`:E===`failed`?`text-danger`:`text-fg-muted`),"data-testid":`claude-login-status`,children:A?null:O?`Connected — your Claude subscription is stored in the vault and runs from this PC.`:T&&D?w?.message??`Waiting for you to finish in the browser…`:w?.message??m?.instructions??`Starting the Claude sign-in…`}),T&&D?(0,W.jsx)(`div`,{className:`text-xs`,children:f?(0,W.jsx)(Wy,{label:`The page showed a code instead? Paste it here`,children:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{className:X,value:o,onChange:e=>s(e.target.value),placeholder:`paste the code here`,autoComplete:`off`,spellCheck:!1,"data-testid":`claude-login-code`,onKeyDown:e=>{e.key===`Enter`&&N()}}),(0,W.jsx)(J,{variant:`primary`,busy:c,disabled:!o.trim(),onClick:()=>void N(),"data-testid":`claude-login-submit`,children:`Continue`})]})}):(0,W.jsx)(`button`,{type:`button`,className:`text-fg-faint underline hover:text-fg`,onClick:()=>p(!0),"data-testid":`claude-login-show-code`,children:`The page showed a code instead? Paste it here`})}):null,M?(0,W.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-2 p-3 text-xs`,children:[(0,W.jsx)(`div`,{className:`mb-1 text-fg-faint`,children:`This host cannot open a terminal for the engine. Run this in a terminal on this PC, then add the printed token as a subscription credential:`}),(0,W.jsx)(QM,{code:M,language:n.info?.platform===`win32`?`powershell`:`bash`})]}):null]})})}function jR({compact:e=!1}){let{actions:t}=G(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),u=(0,v.useRef)(null),d=(0,v.useCallback)(async()=>{let e=await t.githubLink(`get`);e&&r(e)},[t]);(0,v.useEffect)(()=>{d()},[d]);let f=n?.login.phase===`awaiting_approval`;(0,v.useEffect)(()=>{if(!f)return;let e=setInterval(()=>void d(),2e3);return()=>clearInterval(e)},[f,d]);let p=f?n?.login.verificationUriComplete??n?.login.verificationUri??null:null;if((0,v.useEffect)(()=>{let e=n?.login.id;!f||!p||!e||u.current===e||(u.current=e,kR(p))},[f,p,n?.login.id]),!n)return null;let m=async e=>{a(!0);try{let n=await t.githubLink(e);n&&r(n)}finally{a(!1),s(!1)}},h=e=>{navigator.clipboard?.writeText(e).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)}).catch(()=>t.toast(`error`,`Could not copy — select it and copy by hand`))},g=n.account,_=n.login.phase===`failed`||n.login.phase===`expired`;return(0,W.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border bg-surface-2/40 p-3 text-sm`,"data-testid":`github-link`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(q.GitBranch,{className:`h-4 w-4 shrink-0`}),g?(0,W.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,"data-testid":`github-linked`,children:[`GitHub linked as `,(0,W.jsxs)(`b`,{children:[`@`,g.login]}),g.name?(0,W.jsxs)(`span`,{className:`text-fg-muted`,children:[` · `,g.name]}):null]}):(0,W.jsx)(`span`,{className:`min-w-0 flex-1`,children:`GitHub not linked`}),g?(0,W.jsx)(J,{size:`sm`,variant:o?`danger`:`ghost`,disabled:i,onClick:()=>o?void m(`unlink`):s(!0),"data-testid":`github-unlink`,children:o?`Unlink — sure?`:`Unlink`}):n.available&&!f?(0,W.jsx)(J,{size:`sm`,variant:`primary`,disabled:i,onClick:()=>void m(`start`),"data-testid":`github-link-start`,children:`Link GitHub`}):null]}),f?(0,W.jsxs)(`div`,{className:`space-y-2`,"data-testid":`github-link-pending`,children:[(0,W.jsxs)(`p`,{className:`text-fg-muted`,children:[`GitHub’s page opened in your browser. If it did not, open`,` `,(0,W.jsx)(`a`,{className:`underline`,href:p??`#`,onClick:e=>{e.preventDefault(),p&&kR(p)},children:p}),` `,`on any device and enter:`]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`code`,{className:`rounded border border-border px-2 py-1 font-mono text-base`,"data-testid":`github-user-code`,children:n.login.userCode}),(0,W.jsxs)(J,{size:`sm`,onClick:()=>n.login.userCode&&h(n.login.userCode),children:[(0,W.jsx)(q.Copy,{className:`h-3.5 w-3.5`}),` `,c?`Copied`:`Copy`]}),(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>void m(`cancel`),children:`Cancel`})]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-faint`,children:`Waiting for GitHub…`})]}):null,_?(0,W.jsxs)(`p`,{className:`text-xs text-danger`,"data-testid":`github-link-ended`,children:[n.login.message??`The link did not complete.`,` Press Link GitHub to try again.`]}):null,!e||!g?(0,W.jsx)(`p`,{className:`text-xs text-fg-faint`,children:g?`The agent’s git and gh use this account on every PC of yours, for github.com only. The token stays in your encrypted vault and never reaches the OonaCode server.`:n.available?`Public repositories need nothing. For private ones, link GitHub: the agent’s git and gh then sign in as you on every PC of yours. Without it, the agent uses whatever git sign-in this PC already has.`:n.unavailableReason??`Link GitHub is not available.`}):null]})}var MR=`__new__`;function NR({title:e,children:t}){return(0,W.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3 first:border-t-0 first:pt-0`,children:[(0,W.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:e}),t]})}function PR({open:e,startNew:t=!1,selectId:n=null,onClose:r}){let{state:i,actions:a}=G(),o=i.vaultProjects,s=i.info&&i.info.platform!==`win32`?`${i.info.homeDir??`/home/you`}/src/my-app`:`C:\\src\\my-app`,[c,l]=(0,v.useState)(MR),[u,d]=(0,v.useState)(xR(null)),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),g=(e,t)=>d(n=>({...n,[e]:t}));(0,v.useEffect)(()=>{if(!e)return;a.refreshVaultProjects();let r=n&&o.some(e=>e.id===n)?n:null;l(t?MR:r??o[0]?.id??MR),h(!1)},[e]);let _=c===MR?null:o.find(e=>e.id===c)??null;(0,v.useEffect)(()=>{d(xR(_)),h(!1)},[_?.id,_?.updatedAt]);let y=(0,v.useMemo)(()=>i.providers.filter(e=>e.configured).flatMap(e=>e.definition.models.map(t=>({key:yR(e.definition.id,t.id),label:`${e.definition.displayName} — ${t.displayName||t.id}`,option:t}))),[i.providers]),b=y.find(e=>e.key===u.model)??null,x=u.model&&!b?bR(u.model):null,S=b?Se(b.option):[],C=OR(u,_),w=C?wR(u):null;async function T(){if(!wR(u)){p(!0);try{if(_===null){let e=await a.createVaultProject(DR(u));e&&l(e.id)}else await a.updateVaultProject(_.id,ER(u,_))}finally{p(!1)}}}async function E(){if(_){if(!m){h(!0);return}p(!0);try{await a.deleteVaultProject(_.id)&&l(MR)}finally{p(!1)}}}async function O(){let e=await window.oonacode?.pickDirectory?.({title:`The folder new chats in this project run in`,...u.cwd?{defaultPath:u.cwd}:{}});e&&g(`cwd`,e)}let k=e=>i.sessions.filter(t=>t.projectId===e).length,A=e=>e.sessionCount??k(e.id),j=_?A(_):0;return(0,W.jsx)(Ky,{open:e,title:`Projects`,onClose:r,wide:!0,footer:(0,W.jsxs)(W.Fragment,{children:[_?j>0?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-muted`,"data-testid":`project-delete-reason`,children:D(j)}),(0,W.jsx)(J,{variant:`ghost`,disabled:!0,"data-testid":`project-delete`,children:`Delete project`})]}):(0,W.jsx)(J,{variant:m?`danger`:`ghost`,onClick:E,disabled:f,"data-testid":`project-delete`,children:m?`Delete ${_.name}?`:`Delete project`}):null,(0,W.jsx)(`span`,{className:`flex-1`}),w?(0,W.jsx)(`span`,{className:`text-xs text-danger`,"data-testid":`project-problem`,children:w}):null,(0,W.jsx)(J,{variant:`ghost`,onClick:r,children:`Close`}),(0,W.jsx)(J,{variant:`primary`,onClick:T,disabled:f||!C||w!==null,"data-testid":`project-save`,children:_===null?`Create project`:`Save`})]}),children:(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[180px_1fr]`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`projects-list`,children:[(0,W.jsxs)(`button`,{type:`button`,className:U(`flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,c===MR?`bg-accent-soft text-fg`:`hover:bg-surface-2 text-fg-muted`),onClick:()=>l(MR),"data-testid":`project-new`,children:[(0,W.jsx)(q.Plus,{className:`w-3.5 h-3.5`}),` New project`]}),o.map(e=>(0,W.jsxs)(`button`,{type:`button`,className:U(`flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,c===e.id?`bg-accent-soft text-fg`:`hover:bg-surface-2 text-fg`),onClick:()=>l(e.id),"data-testid":`project-item-${e.id}`,children:[(0,W.jsx)(q.Project,{className:`w-3.5 h-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,W.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:A(e)})]},e.id))]}),(0,W.jsxs)(`div`,{className:`max-h-[65vh] space-y-4 overflow-y-auto pr-1`,children:[(0,W.jsxs)(NR,{title:`Project`,children:[(0,W.jsx)(Wy,{label:`Name`,children:(0,W.jsx)(`input`,{className:X,value:u.name,onChange:e=>g(`name`,e.target.value),placeholder:`My app`,maxLength:ec.name,"data-testid":`project-name`})}),(0,W.jsx)(Wy,{label:`Goal (optional)`,hint:`What the project is for, in a line or two.`,children:(0,W.jsx)(`input`,{className:X,value:u.goal,onChange:e=>g(`goal`,e.target.value),placeholder:`A desktop app that…`,maxLength:ec.goal,"data-testid":`project-goal`})}),(0,W.jsx)(Wy,{label:`Instructions for the agent (optional)`,children:(0,W.jsx)(`textarea`,{className:U(X,`h-40 font-mono text-xs`),value:u.instructions,onChange:e=>g(`instructions`,e.target.value),placeholder:`Standing rules for every chat in this project — e.g.
|
|
157
|
+
`)&&(r.repositories=i);let a=wR(e);ER(t.chatDefaults,a)||(r.chatDefaults=a),e.memoryEnabled!==n.memoryEnabled&&(r.memoryEnabled=e.memoryEnabled),e.memory!==n.memory&&(r.memory=e.memory),e.tasksEnabled!==n.tasksEnabled&&(r.tasksEnabled=e.tasksEnabled);let o=Number(e.minInterval);return String(o)!==n.minInterval&&Number.isInteger(o)&&(r.minRoutineIntervalMinutes=o),r}function OR(e){let t=wR(e),n=CR(e.repositories),r=Number(e.minInterval);return{name:e.name.trim(),instructions:e.instructions,...e.goal.trim()?{goal:e.goal}:{},...n.length>0?{repositories:n}:{},...t?{chatDefaults:t}:{},...e.memoryEnabled?{memoryEnabled:!0}:{},...e.memory?{memory:e.memory}:{},...e.tasksEnabled?{}:{tasksEnabled:!1},...Number.isInteger(r)&&r!==15?{minRoutineIntervalMinutes:r}:{}}}function kR(e,t){if(t===null){let t=SR(null);return Object.keys(t).some(n=>e[n]!==t[n])}return Object.keys(DR(e,t)).length>0}function AR(e){let t=typeof window<`u`?window.oonacode:void 0;t?.openExternal?t.openExternal(e):window.open(e,`_blank`,`noopener,noreferrer`)}function jR({open:e,onClose:t}){let{state:n,actions:r}=G(),i=n.claudeLogin,a=n.ui.claudeLoginMode,[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),g=(0,v.useRef)(null),[_,y]=(0,v.useState)(0),[b,x]=(0,v.useState)(null),S=i?.phase===`starting`||i?.phase===`awaiting_browser`||i?.phase===`awaiting_code`,C=i!=null&&(S||b!==null&&i.id===b),w=C?i:null,T=C&&S,E=w?.phase??`idle`,D=T?w?.url??w?.fallbackUrl??null:null,O=E===`connected`,k=O||E===`failed`||E===`cancelled`,A=!a&&!S&&!m,j=k&&!A;(0,v.useEffect)(()=>{if(!e)return;s(``),h(null),p(!1),x(null),g.current=null,r.refreshClaudeLogin();let t=setInterval(()=>void r.refreshClaudeLogin(),2e3);return()=>clearInterval(t)},[e,r]),(0,v.useEffect)(()=>{if(!e||!a)return;let t=!1;return(async()=>{let e=await r.startClaudeLogin();t||!e||(e.login?x(e.login.id):h(e))})(),()=>{t=!0}},[e,a,_,r]),(0,v.useEffect)(()=>{!e||!D||!a||g.current===D||!T||(g.current=D,a===`open`?AR(D):navigator.clipboard?navigator.clipboard.writeText(D).then(()=>{d(!0),r.toast(`info`,`Sign-in link copied — paste it into the browser where you are signed in to Claude`),setTimeout(()=>d(!1),2500)}).catch(()=>r.toast(`error`,`Could not copy — use the Copy button below`)):r.toast(`error`,`Could not copy — select the link and copy it by hand`))},[e,D,a,T,r]),(0,v.useEffect)(()=>{w?.phase===`connected`&&r.refreshClaudeSubscription()},[w?.phase,r]);let M=m?.command?`${m.command.file} ${m.command.args.join(` `)}`:null,ee=async()=>{if(D)try{await navigator.clipboard.writeText(D),d(!0),setTimeout(()=>d(!1),1500)}catch{r.toast(`error`,`Could not copy — select the link and copy it by hand`)}},N=async()=>{if(o.trim()){l(!0);try{await r.submitClaudeLoginCode(o)&&s(``)}finally{l(!1)}}},P=A?(0,W.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2`,children:[(0,W.jsx)(J,{onClick:t,"data-testid":`claude-login-close`,children:`Close`}),(0,W.jsxs)(J,{onClick:()=>r.openClaudeLogin(`copy`),"data-testid":`claude-login-copy-mode`,children:[(0,W.jsx)(q.Copy,{className:`w-4 h-4`}),` Copy link`]}),(0,W.jsxs)(J,{variant:`primary`,onClick:()=>r.openClaudeLogin(`open`),"data-testid":`claude-login-open-mode`,children:[(0,W.jsx)(q.LogIn,{className:`w-4 h-4`}),` Sign in with my subscription`]})]}):j||m?(0,W.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[O?null:(0,W.jsx)(J,{onClick:()=>{g.current=null,h(null),x(null),a||r.openClaudeLogin(`open`),y(e=>e+1)},"data-testid":`claude-login-retry`,children:`Try again`}),(0,W.jsx)(J,{variant:`primary`,onClick:t,"data-testid":`claude-login-close`,children:`Close`})]}):(0,W.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[(0,W.jsx)(J,{onClick:t,children:`Keep in background`}),(0,W.jsx)(J,{variant:`danger`,onClick:()=>void r.cancelClaudeLogin(),"data-testid":`claude-login-cancel`,children:`Cancel sign-in`})]});return(0,W.jsx)(Ky,{open:e,title:`Connect your Claude subscription`,onClose:t,footer:P,children:(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Your Claude Pro/Max login runs the genuine Claude Code engine directly against api.anthropic.com — never through the gateway. The token it stores lasts a year and syncs to every PC you sign in to.`}),A?(0,W.jsxs)(`div`,{className:`space-y-2 text-sm`,"data-testid":`claude-login-choose`,children:[(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`span`,{className:`font-medium`,children:`Sign in with my subscription`}),` opens the Claude sign-in page in this PC's browser.`]}),(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`span`,{className:`font-medium`,children:`Copy link`}),` copies the same page's link for the browser where you are already signed in to Claude — any browser on this PC works.`]}),(0,W.jsx)(`p`,{className:`text-fg-faint`,children:`Either way this window connects by itself when you finish signing in.`})]}):null,A?null:(0,W.jsx)(`div`,{className:`rounded-md border border-border bg-surface-2 p-3 text-xs`,"data-testid":`claude-login-wait`,children:D?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mb-1 text-fg-faint`,children:a===`copy`?`Sign-in link (copied):`:`Sign-in link (opened in your browser):`}),(0,W.jsx)(`div`,{className:`break-all font-mono select-all`,"data-testid":`claude-login-url`,children:D}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,W.jsxs)(J,{size:`sm`,onClick:()=>void ee(),"data-testid":`claude-login-copy`,children:[(0,W.jsx)(q.Copy,{className:`w-3 h-3`}),` `,u?`Copied`:`Copy link`]}),(0,W.jsx)(J,{size:`sm`,onClick:()=>AR(D),children:`Open in browser`})]})]}):O?null:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-fg-muted`,children:[(0,W.jsx)(q.Spinner,{className:`w-4 h-4 animate-spin`}),` Preparing your sign-in link…`]})}),(0,W.jsx)(`div`,{className:U(`text-sm`,O?`text-ok`:E===`failed`?`text-danger`:`text-fg-muted`),"data-testid":`claude-login-status`,children:A?null:O?`Connected — your Claude subscription is stored in the vault and runs from this PC.`:T&&D?w?.message??`Waiting for you to finish in the browser…`:w?.message??m?.instructions??`Starting the Claude sign-in…`}),T&&D?(0,W.jsx)(`div`,{className:`text-xs`,children:f?(0,W.jsx)(Wy,{label:`The page showed a code instead? Paste it here`,children:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{className:X,value:o,onChange:e=>s(e.target.value),placeholder:`paste the code here`,autoComplete:`off`,spellCheck:!1,"data-testid":`claude-login-code`,onKeyDown:e=>{e.key===`Enter`&&N()}}),(0,W.jsx)(J,{variant:`primary`,busy:c,disabled:!o.trim(),onClick:()=>void N(),"data-testid":`claude-login-submit`,children:`Continue`})]})}):(0,W.jsx)(`button`,{type:`button`,className:`text-fg-faint underline hover:text-fg`,onClick:()=>p(!0),"data-testid":`claude-login-show-code`,children:`The page showed a code instead? Paste it here`})}):null,M?(0,W.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-2 p-3 text-xs`,children:[(0,W.jsx)(`div`,{className:`mb-1 text-fg-faint`,children:`This host cannot open a terminal for the engine. Run this in a terminal on this PC, then add the printed token as a subscription credential:`}),(0,W.jsx)(QM,{code:M,language:n.info?.platform===`win32`?`powershell`:`bash`})]}):null]})})}function MR({compact:e=!1}){let{actions:t}=G(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),u=(0,v.useRef)(null),d=(0,v.useCallback)(async()=>{let e=await t.githubLink(`get`);e&&r(e)},[t]);(0,v.useEffect)(()=>{d()},[d]);let f=n?.login.phase===`awaiting_approval`;(0,v.useEffect)(()=>{if(!f)return;let e=setInterval(()=>void d(),2e3);return()=>clearInterval(e)},[f,d]);let p=f?n?.login.verificationUriComplete??n?.login.verificationUri??null:null;if((0,v.useEffect)(()=>{let e=n?.login.id;!f||!p||!e||u.current===e||(u.current=e,AR(p))},[f,p,n?.login.id]),!n)return null;let m=async e=>{a(!0);try{let n=await t.githubLink(e);n&&r(n)}finally{a(!1),s(!1)}},h=e=>{navigator.clipboard?.writeText(e).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)}).catch(()=>t.toast(`error`,`Could not copy — select it and copy by hand`))},g=n.account,_=n.login.phase===`failed`||n.login.phase===`expired`;return(0,W.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border bg-surface-2/40 p-3 text-sm`,"data-testid":`github-link`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(q.GitBranch,{className:`h-4 w-4 shrink-0`}),g?(0,W.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,"data-testid":`github-linked`,children:[`GitHub linked as `,(0,W.jsxs)(`b`,{children:[`@`,g.login]}),g.name?(0,W.jsxs)(`span`,{className:`text-fg-muted`,children:[` · `,g.name]}):null]}):(0,W.jsx)(`span`,{className:`min-w-0 flex-1`,children:`GitHub not linked`}),g?(0,W.jsx)(J,{size:`sm`,variant:o?`danger`:`ghost`,disabled:i,onClick:()=>o?void m(`unlink`):s(!0),"data-testid":`github-unlink`,children:o?`Unlink — sure?`:`Unlink`}):n.available&&!f?(0,W.jsx)(J,{size:`sm`,variant:`primary`,disabled:i,onClick:()=>void m(`start`),"data-testid":`github-link-start`,children:`Link GitHub`}):null]}),f?(0,W.jsxs)(`div`,{className:`space-y-2`,"data-testid":`github-link-pending`,children:[(0,W.jsxs)(`p`,{className:`text-fg-muted`,children:[`GitHub’s page opened in your browser. If it did not, open`,` `,(0,W.jsx)(`a`,{className:`underline`,href:p??`#`,onClick:e=>{e.preventDefault(),p&&AR(p)},children:p}),` `,`on any device and enter:`]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`code`,{className:`rounded border border-border px-2 py-1 font-mono text-base`,"data-testid":`github-user-code`,children:n.login.userCode}),(0,W.jsxs)(J,{size:`sm`,onClick:()=>n.login.userCode&&h(n.login.userCode),children:[(0,W.jsx)(q.Copy,{className:`h-3.5 w-3.5`}),` `,c?`Copied`:`Copy`]}),(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>void m(`cancel`),children:`Cancel`})]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-faint`,children:`Waiting for GitHub…`})]}):null,_?(0,W.jsxs)(`p`,{className:`text-xs text-danger`,"data-testid":`github-link-ended`,children:[n.login.message??`The link did not complete.`,` Press Link GitHub to try again.`]}):null,!e||!g?(0,W.jsx)(`p`,{className:`text-xs text-fg-faint`,children:g?`The agent’s git and gh use this account on every PC of yours, for github.com only. The token stays in your encrypted vault and never reaches the OonaCode server.`:n.available?`Public repositories need nothing. For private ones, link GitHub: the agent’s git and gh then sign in as you on every PC of yours. Without it, the agent uses whatever git sign-in this PC already has.`:n.unavailableReason??`Link GitHub is not available.`}):null]})}var NR=`__new__`;function PR({title:e,children:t}){return(0,W.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3 first:border-t-0 first:pt-0`,children:[(0,W.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:e}),t]})}function FR({open:e,startNew:t=!1,selectId:n=null,onClose:r}){let{state:i,actions:a}=G(),o=i.vaultProjects,s=i.info&&i.info.platform!==`win32`?`${i.info.homeDir??`/home/you`}/src/my-app`:`C:\\src\\my-app`,[c,l]=(0,v.useState)(NR),[u,d]=(0,v.useState)(SR(null)),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),g=(e,t)=>d(n=>({...n,[e]:t}));(0,v.useEffect)(()=>{if(!e)return;a.refreshVaultProjects();let r=n&&o.some(e=>e.id===n)?n:null;l(t?NR:r??o[0]?.id??NR),h(!1)},[e]);let _=c===NR?null:o.find(e=>e.id===c)??null;(0,v.useEffect)(()=>{d(SR(_)),h(!1)},[_?.id,_?.updatedAt]);let y=(0,v.useMemo)(()=>i.providers.filter(e=>e.configured).flatMap(e=>e.definition.models.map(t=>({key:bR(e.definition.id,t.id),label:`${e.definition.displayName} — ${t.displayName||t.id}`,option:t}))),[i.providers]),b=y.find(e=>e.key===u.model)??null,x=u.model&&!b?xR(u.model):null,S=b?Se(b.option):[],C=kR(u,_),w=C?TR(u):null;async function T(){if(!TR(u)){p(!0);try{if(_===null){let e=await a.createVaultProject(OR(u));e&&l(e.id)}else await a.updateVaultProject(_.id,DR(u,_))}finally{p(!1)}}}async function E(){if(_){if(!m){h(!0);return}p(!0);try{await a.deleteVaultProject(_.id)&&l(NR)}finally{p(!1)}}}async function O(){let e=await window.oonacode?.pickDirectory?.({title:`The folder new chats in this project run in`,...u.cwd?{defaultPath:u.cwd}:{}});e&&g(`cwd`,e)}let k=e=>i.sessions.filter(t=>t.projectId===e).length,A=e=>e.sessionCount??k(e.id),j=_?A(_):0;return(0,W.jsx)(Ky,{open:e,title:`Projects`,onClose:r,wide:!0,footer:(0,W.jsxs)(W.Fragment,{children:[_?j>0?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-muted`,"data-testid":`project-delete-reason`,children:D(j)}),(0,W.jsx)(J,{variant:`ghost`,disabled:!0,"data-testid":`project-delete`,children:`Delete project`})]}):(0,W.jsx)(J,{variant:m?`danger`:`ghost`,onClick:E,disabled:f,"data-testid":`project-delete`,children:m?`Delete ${_.name}?`:`Delete project`}):null,(0,W.jsx)(`span`,{className:`flex-1`}),w?(0,W.jsx)(`span`,{className:`text-xs text-danger`,"data-testid":`project-problem`,children:w}):null,(0,W.jsx)(J,{variant:`ghost`,onClick:r,children:`Close`}),(0,W.jsx)(J,{variant:`primary`,onClick:T,disabled:f||!C||w!==null,"data-testid":`project-save`,children:_===null?`Create project`:`Save`})]}),children:(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[180px_1fr]`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`projects-list`,children:[(0,W.jsxs)(`button`,{type:`button`,className:U(`flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,c===NR?`bg-accent-soft text-fg`:`hover:bg-surface-2 text-fg-muted`),onClick:()=>l(NR),"data-testid":`project-new`,children:[(0,W.jsx)(q.Plus,{className:`w-3.5 h-3.5`}),` New project`]}),o.map(e=>(0,W.jsxs)(`button`,{type:`button`,className:U(`flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,c===e.id?`bg-accent-soft text-fg`:`hover:bg-surface-2 text-fg`),onClick:()=>l(e.id),"data-testid":`project-item-${e.id}`,children:[(0,W.jsx)(q.Project,{className:`w-3.5 h-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,W.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:A(e)})]},e.id))]}),(0,W.jsxs)(`div`,{className:`max-h-[65vh] space-y-4 overflow-y-auto pr-1`,children:[(0,W.jsxs)(PR,{title:`Project`,children:[(0,W.jsx)(Wy,{label:`Name`,children:(0,W.jsx)(`input`,{className:X,value:u.name,onChange:e=>g(`name`,e.target.value),placeholder:`My app`,maxLength:ec.name,"data-testid":`project-name`})}),(0,W.jsx)(Wy,{label:`Goal (optional)`,hint:`What the project is for, in a line or two.`,children:(0,W.jsx)(`input`,{className:X,value:u.goal,onChange:e=>g(`goal`,e.target.value),placeholder:`A desktop app that…`,maxLength:ec.goal,"data-testid":`project-goal`})}),(0,W.jsx)(Wy,{label:`Instructions for the agent (optional)`,children:(0,W.jsx)(`textarea`,{className:U(X,`h-40 font-mono text-xs`),value:u.instructions,onChange:e=>g(`instructions`,e.target.value),placeholder:`Standing rules for every chat in this project — e.g.
|
|
158
158
|
- push to the feature branch, never to main
|
|
159
159
|
- run the tests before saying a change is done
|
|
160
|
-
- use the browser on port 9170 for anything on the web`,maxLength:ec.instructions,"data-testid":`project-instructions`})})]}),(0,W.jsxs)(NR,{title:`Repositories`,children:[(0,W.jsx)(Wy,{label:`One per line (optional)`,hint:`Every chat in the project is told about them.`,children:(0,W.jsx)(`textarea`,{className:U(X,`h-16 font-mono text-xs`),value:u.repositories,onChange:e=>g(`repositories`,e.target.value),placeholder:`https://github.com/you/app`,"data-testid":`project-repositories`})}),(0,W.jsx)(jR,{compact:!0})]}),(0,W.jsxs)(NR,{title:`New chats`,children:[(0,W.jsx)(Wy,{label:`Model`,hint:`What a new chat in this project starts on.`,children:(0,W.jsxs)(`select`,{className:X,value:u.model,onChange:e=>{g(`model`,e.target.value),g(`effort`,``)},"data-testid":`project-model`,children:[(0,W.jsx)(`option`,{value:``,children:`Whatever a new chat would start on`}),x?(0,W.jsxs)(`option`,{value:u.model,children:[x.model,` (not on this PC)`]}):null,y.map(e=>(0,W.jsx)(`option`,{value:e.key,children:e.label},e.key))]})}),S.length>0?(0,W.jsx)(Wy,{label:`Effort`,children:(0,W.jsxs)(`select`,{className:X,value:u.effort,onChange:e=>g(`effort`,e.target.value),"data-testid":`project-effort`,children:[(0,W.jsx)(`option`,{value:``,children:`Default`}),S.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))]})}):null,(0,W.jsx)(Wy,{label:`Folder`,hint:`Where a new chat runs; left empty, each chat gets its own.`,children:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{className:U(X,`flex-1 font-mono text-xs`),value:u.cwd,onChange:e=>g(`cwd`,e.target.value),placeholder:s,"data-testid":`project-cwd`}),window.oonacode?.pickDirectory?(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>void O(),children:`Choose…`}):null]})})]}),(0,W.jsxs)(NR,{title:`Memory`,children:[(0,W.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:u.memoryEnabled,onChange:e=>g(`memoryEnabled`,e.target.checked),"data-testid":`project-memory-enabled`}),(0,W.jsx)(`span`,{children:`Keep a project memory — notes every chat of the project reads at its start, and the agent keeps up to date.`})]}),u.memoryEnabled?(0,W.jsx)(`textarea`,{className:U(X,`h-28 font-mono text-xs`),value:u.memory,onChange:e=>g(`memory`,e.target.value),placeholder:`Nothing noted yet.`,maxLength:ec.memory,"data-testid":`project-memory`}):null]}),(0,W.jsxs)(NR,{title:`Scheduled tasks`,children:[(0,W.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:u.tasksEnabled,onChange:e=>g(`tasksEnabled`,e.target.checked),"data-testid":`project-tasks-enabled`}),(0,W.jsx)(`span`,{children:`The agent may schedule work in this project's chats — once, or on a repeat — with OonaCode's scheduler on this PC.`})]}),u.tasksEnabled?(0,W.jsx)(Wy,{label:`Shortest repeat, in minutes`,children:(0,W.jsx)(`input`,{className:U(X,`w-28`),inputMode:`numeric`,value:u.minInterval,onChange:e=>g(`minInterval`,e.target.value),"data-testid":`project-min-interval`})}):null,_?(0,W.jsx)(WN,{projectId:_.id,showChat:!0}):null]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Saved settings reach the project's chats at their next message. Projects live in your vault: only your own devices can read them.`})]})]})})}var FR=`(min-width: 768px)`;function IR(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(FR).matches}function LR(){let[e,t]=(0,v.useState)(IR);return(0,v.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(FR),n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function RR(e){try{return!!e?.matches(`:hover`)}catch{return!1}}function zR(e){if(typeof document>`u`)return!1;if(document.querySelector(`[role="menu"], [role="dialog"]`))return!0;let t=document.activeElement;return!!(e&&t&&e.contains(t)&&t.tagName===`INPUT`)}function BR({hidden:e,children:t}){let{state:n,actions:r}=G(),i=n.ui.sidebarPinnedOverride??n.prefs.sidebarPinned,a=n.ui.sidebarOpen,[o,s]=(0,v.useState)(null),c=o??n.prefs.sidebarWidth,[l,u]=(0,v.useState)(!1),d=LR(),f=(0,v.useRef)(null),p=(0,v.useRef)(null),m=(0,v.useCallback)(()=>{p.current!==null&&(clearTimeout(p.current),p.current=null)},[]),h=(0,v.useCallback)(()=>{m(),p.current=setTimeout(function e(){if(zR(f.current)){p.current=setTimeout(e,350);return}p.current=null,!RR(f.current)&&u(!1)},350)},[m]);(0,v.useEffect)(()=>m,[m]),(0,v.useEffect)(()=>{u(!1),m()},[i,m]),(0,v.useEffect)(()=>{if(e)return;let t=e=>{if(!(!(e.ctrlKey||e.metaKey)||e.shiftKey||e.altKey)&&(e.key===`k`||e.key===`K`)){if(IR()){if(i)return;u(!0),h()}else a||r.setSidebar(!0)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,i,a,h,r]);let g=e=>{e.preventDefault();let t=e.clientX,i=c,a=i,o=e=>{a=zc(i+(e.clientX-t)),s(a)},l=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,l),document.body.style.cursor=``,document.body.style.userSelect=``,s(null),a!==n.prefs.sidebarWidth&&r.savePrefs({sidebarWidth:a})};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,l)},_=i||l;return(0,W.jsxs)(W.Fragment,{children:[!i&&!l&&!e?(0,W.jsx)(`div`,{className:`absolute inset-y-0 left-0 z-40 hidden w-2 md:block`,onMouseEnter:()=>{u(!0),h()},"aria-hidden":!0,"data-testid":`sidebar-hover-edge`}):null,(0,W.jsxs)(`aside`,{ref:f,"data-chrome":`sidebar`,hidden:e,inert:!e&&(d?!_:!a),"data-testid":`sidebar-frame`,"data-state":i?`docked`:l?`peek`:`hidden`,style:{"--sidebar-w":`${c}px`},onMouseEnter:i?void 0:m,onMouseLeave:i?void 0:h,className:U(`absolute inset-y-0 left-0 z-30 w-72 max-w-[85vw] border-r border-border bg-surface transition-transform md:w-[var(--sidebar-w)] md:max-w-[70vw]`,a?`translate-x-0`:`-translate-x-full`,i?`md:relative md:z-auto md:translate-x-0`:U(`md:z-40 md:shadow-2xl`,_?`md:translate-x-0`:`md:-translate-x-full`)),children:[t,(0,W.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the session list`,title:`Drag to resize · double-click for the default width`,className:`absolute inset-y-0 -right-1 z-10 hidden w-2 cursor-col-resize hover:bg-accent/30 md:block`,onPointerDown:g,onDoubleClick:()=>void r.savePrefs({sidebarWidth:288}),"data-testid":`sidebar-resize`})]})]})}function VR({open:e,onClose:t}){return(0,W.jsx)(Ky,{open:e,title:`Export my chats`,onClose:t,children:(0,W.jsx)(HR,{onDone:t})})}function HR({onDone:e}){let{api:t,state:n}=G(),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(0),p=n.sessionsTotal||n.sessions.length;(0,v.useEffect)(()=>{if(!a){f(0);return}let e=Date.now(),t=setInterval(()=>f(Math.floor((Date.now()-e)/1e3)),1e3);return()=>clearInterval(t)},[a]);let m=async()=>{if(!t.exportSessionsArchive){c(`this PC is running an older OonaCode that cannot export chats`);return}o(!0),c(null);try{let n=await t.exportSessionsArchive(r),a=URL.createObjectURL(n),o=document.createElement(`a`);o.href=a,o.download=`oonacode-chats-${new Date().toISOString().slice(0,10)}.zip`,o.click(),URL.revokeObjectURL(a),i(``),u(!1),e()}catch(e){c(e instanceof Error?e.message:`the export failed`)}finally{o(!1)}};return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Ky,{open:a,title:`Exporting your chats`,onClose:()=>void 0,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(q.Spinner,{className:`mt-0.5 w-5 h-5 shrink-0 text-accent`}),(0,W.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,W.jsxs)(`div`,{className:`font-medium`,children:[`Packing`,` `,p>0?`${p} chat${p===1?``:`s`}`:`your chats`,`…`]}),(0,W.jsxs)(`div`,{className:`mt-1 tabular text-fg-muted`,children:[Math.floor(d/60),`:`,String(d%60).padStart(2,`0`),` elapsed`]}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-faint`,children:`Your PC writes the whole archive before the download starts, so nothing appears in your downloads until it is finished. A long history can take a minute or two — this is normal, and you do not need to press anything again.`})]})]})}),(0,W.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`One zip with a plain `,(0,W.jsx)(`code`,{children:`.txt`}),` of every conversation on this PC, plus an index. It is for reading and copying from — there is no way to load it back in.`]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-warn`,children:`The zip is not encrypted: anyone who opens it can read every conversation in it.`}),l?(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`password`,autoFocus:!0,className:X+` max-w-[16rem]`,placeholder:`Account password`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r&&m()},"data-testid":`export-chats-password`}),(0,W.jsx)(J,{onClick:()=>void m(),disabled:a||!r,children:a?`Exporting…`:`Export`}),(0,W.jsx)(J,{variant:`ghost`,onClick:()=>{u(!1),i(``),c(null)},children:`Cancel`})]}):(0,W.jsx)(J,{className:`mt-2`,onClick:()=>u(!0),"data-testid":`export-chats`,children:`Export chats…`}),s?(0,W.jsx)(`div`,{className:`mt-2 text-xs text-danger`,children:s}):null]})}var UR=70,WR=96,GR=170,KR=56;function qR(e,t=22){let n=e.trim().replace(/\s+/g,` `);return n.length<=t?n:`${n.slice(0,Math.max(1,t-1)).trimEnd()}…`}var JR={working:3,idle:2,asleep:1,missing:0},YR=Math.PI*2,XR=e=>(e%YR+YR)%YR,ZR=e=>Math.round(e*100)/100;function QR(e){let t=0,n=0;for(let r of e)t+=Math.cos(r),n+=Math.sin(r);return Math.hypot(t,n)<1e-9?null:Math.atan2(n,t)}function $R(e,t=!1){return e.filter(e=>t||e.status!==`closed`).filter(e=>e.members.length>0).sort((e,t)=>e.createdAt===t.createdAt?e.id<t.id?-1:+(e.id>t.id):e.createdAt<t.createdAt?-1:1)}function ez(e,t={}){let n=t.now??Date.now(),r=$R(e,t.showClosed??!1),i=t.showClosed?0:e.filter(e=>e.status===`closed`).length,a=r.length,o=a<=1?0:Math.max(72,a*WR/YR),s=e=>-Math.PI/2+YR*e/Math.max(1,a),c=new Map;r.forEach((e,t)=>{for(let n of e.members){let r=n.leftAt===null,i=c.get(n.sessionId);i?(r&&!i.titleFromCurrent&&n.title&&(i.title=n.title,i.titleFromCurrent=!0),JR[n.state]>JR[i.state]&&(i.state=n.state)):(i={sessionId:n.sessionId,hostId:n.hostId,title:n.title,titleFromCurrent:r,state:n.state,hubs:[],conversationIds:[],anyCurrent:!1},c.set(n.sessionId,i)),i.conversationIds.includes(e.id)||(i.hubs.push(t),i.conversationIds.push(e.id)),r&&(i.anyCurrent=!0)}});let l=c.size,u=Math.max(o+120,l*UR/YR,110),d=[...c.values()].map(e=>({acc:e,pref:XR((a<=1?0:QR(e.hubs.map(s))??s(e.hubs[0]))+Math.PI/2)})).sort((e,t)=>Math.abs(e.pref-t.pref)>1e-9?e.pref-t.pref:e.acc.sessionId<t.acc.sessionId?-1:+(e.acc.sessionId>t.acc.sessionId)),f=YR/Math.max(1,l),p=(a<=1?null:QR(d.map((e,t)=>e.pref-t*f)))??0,m=ZR(2*(u+GR)),h=ZR(2*(u+KR)),g=m/2,_=h/2,v=r.map((e,t)=>{let r=s(t),i=e.members.filter(e=>e.leftAt===null).length,a=Date.parse(e.lastActivityAt),c=Ed(e);return{id:e.id,x:ZR(g+o*Math.cos(r)),y:ZR(_+o*Math.sin(r)),name:c,label:qR(c),status:e.status,waiting:e.waiting,members:i,messageCount:e.messageCount,recent:e.status!==`closed`&&Number.isFinite(a)&&n-a>=-5e3&&n-a<=6e4}}),y=d.map(({acc:e},t)=>{let n=-Math.PI/2+p+t*f,r=g+u*Math.cos(n),i=_+u*Math.sin(n),a=Math.cos(n),o=Math.sin(n),s=a>.3?`start`:a<-.3?`end`:`middle`,c=s===`middle`?r:r+a*15,l=s===`middle`?o<0?i-15:i+15+8:i+o*15+4;return{sessionId:e.sessionId,hostId:e.hostId,x:ZR(r),y:ZR(i),title:e.title,label:qR(e.title||`a chat`),state:e.state,conversationIds:e.conversationIds,left:!e.anyCurrent,labelX:ZR(c),labelY:ZR(l),anchor:s}}),b=new Map(v.map(e=>[e.id,e])),x=new Map(y.map(e=>[e.sessionId,e])),S=[];for(let e of r){let t=b.get(e.id),n=new Set,r=new Map;for(let t of e.members)r.set(t.sessionId,(r.get(t.sessionId)??!0)&&t.leftAt!==null);for(let i of e.members){if(n.has(i.sessionId))continue;n.add(i.sessionId);let a=x.get(i.sessionId);S.push({conversationId:e.id,sessionId:i.sessionId,left:r.get(i.sessionId)??!1,x1:t.x,y1:t.y,x2:a.x,y2:a.y})}}return{hubs:v,chats:y,edges:S,width:m,height:h,hiddenClosed:i}}function tz(e){if(!e)return null;for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.kind===`notice`||!n.fromSession))return{conversationId:n.conversationId,from:n.fromSession,to:n.toSession,kind:n.kind}}return null}function nz(e,t,n,r,i,a){let o=Math.hypot(n-e,r-t);if(o<=i+a||o===0)return{x1:e,y1:t,x2:n,y2:r};let s=(n-e)/o,c=(r-t)/o;return{x1:ZR(e+s*i),y1:ZR(t+c*i),x2:ZR(n-s*a),y2:ZR(r-c*a)}}var rz={working:`working`,idle:`idle`,asleep:`asleep`,missing:`not on this PC any more`},iz={working:`fill-accent stroke-accent animate-pulse`,idle:`fill-accent-soft stroke-accent`,asleep:`fill-surface-3 stroke-fg-faint`,missing:`fill-surface-2 stroke-fg-faint`},az={active:`stroke-ok`,paused:`stroke-warn`,closed:`stroke-fg-faint`};function oz(e){return t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())}}function sz({list:e,showClosed:t,selectedId:n,messages:r,onSelectConversation:i,onOpenChat:a,canOpenChat:o,now:s}){let c=(0,v.useMemo)(()=>ez(e,{showClosed:t,now:s}),[e,t,s]),l=(0,v.useMemo)(()=>tz(r),[r]);if(c.hubs.length===0)return(0,W.jsxs)(`div`,{className:`space-y-1 py-6 text-center text-sm text-fg-muted`,"data-testid":`conversation-map-empty`,children:[(0,W.jsx)(`p`,{children:`No chats are talking to each other right now.`}),(0,W.jsx)(`p`,{className:`text-xs`,children:`Turn on "Talk to other chats" in a chat's Tools menu.`}),c.hiddenClosed>0?(0,W.jsxs)(`p`,{className:`text-xs text-fg-faint`,children:[c.hiddenClosed,` closed conversation`,c.hiddenClosed===1?``:`s`,` hidden.`]}):null]});let u=new Map(c.hubs.map(e=>[e.id,e])),d=new Map(c.chats.map(e=>[e.sessionId,e])),f=[];if(l&&u.has(l.conversationId)){let e=u.get(l.conversationId),t=d.get(l.from),n=d.get(l.to);t&&f.push({key:`from`,...nz(t.x,t.y,e.x,e.y,11,20)}),n&&f.push({key:`to`,...nz(e.x,e.y,n.x,n.y,18,13)})}return(0,W.jsxs)(`div`,{className:`max-h-[65vh] overflow-auto rounded-md border border-border bg-surface`,"data-testid":`conversation-map`,children:[(0,W.jsxs)(`svg`,{viewBox:`0 0 ${c.width} ${c.height}`,preserveAspectRatio:`xMidYMid meet`,className:`block h-auto w-full min-w-[480px] select-none`,style:{maxHeight:`63vh`},role:`img`,"aria-label":`Which chats are talking to each other`,children:[(0,W.jsx)(`defs`,{children:(0,W.jsx)(`marker`,{id:`conversation-map-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,W.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,className:`fill-accent`})})}),(0,W.jsx)(`g`,{"data-testid":`conversation-map-edges`,children:c.edges.map(e=>{let t=u.get(e.conversationId),r=e.conversationId===n;return(0,W.jsx)(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,className:U(r?`stroke-accent`:t.status===`active`?`stroke-fg-muted`:`stroke-border`),strokeWidth:r?2:t.status===`active`?1.5:1,strokeDasharray:e.left?`4 4`:void 0,opacity:t.status===`closed`?.5:1,"data-testid":`map-edge-${e.conversationId}-${e.sessionId}`,"data-left":e.left?`true`:void 0},`${e.conversationId}:${e.sessionId}`)})}),f.length>0?(0,W.jsx)(`g`,{"data-testid":`conversation-map-latest`,children:f.map(e=>(0,W.jsx)(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,className:`stroke-accent`,strokeWidth:3,markerEnd:`url(#conversation-map-arrow)`},e.key))}):null,c.hubs.map(e=>{let t=e.id===n,r=[e.name,`${Ad[e.status]} · ${e.members} chat${e.members===1?``:`s`} · ${e.messageCount} message${e.messageCount===1?``:`s`}`,e.waiting>0?`${e.waiting} waiting to be delivered`:null,`Click to see this conversation.`].filter(Boolean).join(`
|
|
161
|
-
`);return(0,W.jsxs)(`g`,{role:`button`,tabIndex:0,"aria-label":`Conversation ${e.name}, ${Ad[e.status]}`,"aria-pressed":t,className:`cursor-pointer outline-none`,onClick:()=>i(e.id),onKeyDown:
|
|
162
|
-
`),i=e.state===`missing`||e.left;return(0,W.jsxs)(`g`,{role:t?`button`:void 0,tabIndex:t?0:void 0,"aria-label":t?`Open chat ${e.title}`:void 0,className:U(t?`cursor-pointer`:`cursor-default`,`outline-none`),opacity:i?.5:1,onClick:t?()=>a(e.sessionId):void 0,onKeyDown:t?oz(()=>a(e.sessionId)):void 0,"data-testid":`map-chat-${e.sessionId}`,"data-state":e.state,children:[(0,W.jsx)(`title`,{children:r}),(0,W.jsx)(`circle`,{cx:e.x,cy:e.y,r:9,className:iz[e.state],strokeWidth:2,strokeDasharray:e.state===`missing`?`3 2`:void 0}),(0,W.jsx)(`text`,{x:e.labelX,y:e.labelY,textAnchor:e.anchor,className:`fill-fg text-[11px]`,children:e.label})]},e.sessionId)})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-border px-3 py-1.5 text-[11px] text-fg-muted`,"data-testid":`conversation-map-legend`,children:[(0,W.jsx)(cz,{dot:`bg-accent animate-pulse`,children:`working`}),(0,W.jsx)(cz,{dot:`bg-accent-soft border border-accent`,children:`idle`}),(0,W.jsx)(cz,{dot:`bg-surface-3 border border-fg-faint`,children:`asleep`}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(`span`,{className:`inline-block h-3 w-3 rounded-full border-2 border-ok`}),`active`]}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(`span`,{className:`inline-block h-3 w-3 rounded-full border-2 border-dashed border-warn`}),`paused`]}),(0,W.jsx)(`span`,{children:`dashed spoke: left`}),f.length>0?(0,W.jsx)(`span`,{className:`text-accent`,children:`arrows: the newest message`}):null,c.hiddenClosed>0?(0,W.jsxs)(`span`,{className:`text-fg-faint`,children:[c.hiddenClosed,` closed hidden`]}):null]})]})}function cz({dot:e,children:t}){return(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(`span`,{className:U(`inline-block h-2.5 w-2.5 rounded-full`,e)}),t]})}function lz({open:e,selectId:t=null,onClose:n}){let{state:r,actions:i}=G(),a=r.conversationsChange,[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(`list`),[C,w]=(0,v.useState)(!1),T=(0,v.useRef)(null);T.current=f;let E=(0,v.useRef)(-1),D=(0,v.useCallback)(async()=>{let e=await i.listConversations();if(e===`unsupported`){l(!0);return}if(e===null){d(!0);return}l(!1),d(!1),s(e)},[i]),O=(0,v.useCallback)(async e=>{let t=await i.conversationHistory(e);t&&T.current===e&&h(t)},[i]);(0,v.useEffect)(()=>{e&&(E.current=a.seq,_(!1),p(t??null),D())},[e]),(0,v.useEffect)(()=>{!e||f!==null||!o||o.length===0||p(o[0].id)},[e,o,f]),(0,v.useEffect)(()=>{if(!e||!f){h(null);return}h(e=>e?.conversation.id===f?e:null),O(f)},[e,f,O]),(0,v.useEffect)(()=>{if(!e||a.seq===E.current)return;E.current=a.seq,D();let t=T.current;t&&(a.conversationIds===null||a.conversationIds.includes(t))&&O(t)},[e,a,D,O]);let k=e=>{s(t=>t?.map(t=>t.id===e.id?e:t)??t),h(t=>t&&t.conversation.id===e.id?{...t,conversation:e}:t)},A=async(e,t,n)=>{let r=await i.conversationAction(e,t,n);return r&&k(r),r!==null},j=async()=>{b(!0);try{await i.stopAllConversations()}finally{b(!1),_(!1)}D(),T.current&&O(T.current)},M=async e=>{await i.cancelChatMessage(e.id),T.current&&O(T.current)},ee=(0,v.useCallback)((e,t,n=[])=>{if(!e)return t??`OonaCode`;let i=n.find(t=>t.sessionId===e);if(i?.title)return i.title;if(t)return t;let a=r.sessions.find(t=>t.id===e);return a?pg(a):`a chat`},[r.sessions]),N=m&&m.conversation.id===f?m.conversation:o?.find(e=>e.id===f)??null;return(0,W.jsxs)(Ky,{open:e,title:`Conversations`,onClose:n,wide:!0,footer:(0,W.jsx)(J,{variant:`ghost`,onClick:n,children:`Close`}),children:[(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,W.jsxs)(`p`,{className:`min-w-0 flex-1 text-xs text-fg-muted`,children:[`Messages and tasks your chats send each other, on this PC.`,` `,(0,W.jsx)(Hy,{label:`Conversations`,details:Kd.window})]}),c?null:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsxs)(J,{variant:`danger`,size:`sm`,onClick:()=>_(!0),disabled:g||y,title:Kd.stopAll,"data-testid":`conversations-stop-all`,children:[(0,W.jsx)(q.Stop,{className:`h-3 w-3`}),` Stop all conversations`]}),(0,W.jsx)(Hy,{label:`Stop all conversations`,details:Kd.stopAll})]})]}),g?(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alertdialog`,"aria-label":`Stop all conversations?`,"data-testid":`conversations-stop-confirm`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Pause every conversation and stop the turns they are running now? Nothing is deleted; you can resume each one.`}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>_(!1),children:`Cancel`}),(0,W.jsx)(J,{size:`sm`,variant:`danger`,busy:y,onClick:()=>void j(),"data-testid":`conversations-stop-confirm-yes`,children:`Stop all`})]}):null,!c&&o!==null?(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`inline-flex overflow-hidden rounded-md border border-border text-xs`,role:`group`,"aria-label":`View`,children:[`list`,`map`].map(e=>(0,W.jsx)(`button`,{type:`button`,"aria-pressed":x===e,onClick:()=>S(e),className:U(`px-3 py-1`,x===e?`bg-accent text-accent-fg`:`text-fg-muted hover:bg-surface-2`),title:e===`list`?Kd.listView:Kd.mapView,"data-testid":`conversations-view-${e}`,children:e===`list`?`List`:`Map`},e))}),x===`map`?(0,W.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-muted`,title:Kd.showClosed,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked),"data-testid":`conversation-map-show-closed`}),`Show closed`]}):null,(0,W.jsx)(Hy,{label:`Map`,details:Kd.mapView})]}):null,c?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`conversations-unsupported`,children:`OonaCode on this PC is too old for conversations between chats. Update it, then open this window again.`}):o===null?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`conversations-loading`,children:u?`Could not read the conversations from this PC right now. They show here as soon as it answers.`:`Loading…`}):x===`map`?(0,W.jsx)(sz,{list:o,showClosed:C,selectedId:f,messages:m&&m.conversation.id===f?m.messages:null,onSelectConversation:e=>{p(e),S(`list`)},onOpenChat:e=>{n(),i.selectSession(e)},canOpenChat:e=>r.sessions.some(t=>t.id===e)}):o.length===0?(0,W.jsxs)(`div`,{className:`space-y-1 text-sm text-fg-muted`,"data-testid":`conversations-empty`,children:[(0,W.jsx)(`p`,{children:`No conversations yet.`}),(0,W.jsx)(`p`,{className:`text-xs`,children:`To start one, turn on "Talk to other chats" in the Tools menu of two chats, then ask one of them to send the other a message or a task.`})]}):(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[260px_1fr]`,children:[(0,W.jsx)(`ul`,{className:`flex max-h-[65vh] flex-col gap-1 overflow-y-auto pr-1`,"data-testid":`conversations-list`,children:o.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(fz,{c:e,selected:e.id===f,onSelect:()=>p(e.id)})},e.id))}),(0,W.jsx)(`div`,{className:`max-h-[65vh] min-w-0 overflow-y-auto pr-1`,children:N?(0,W.jsx)(gz,{c:N,messages:m&&m.conversation.id===N.id?m.messages:null,titleOf:ee,onAction:(e,t)=>A(N.id,e,t),onWithdraw:e=>void M(e),onOpenChat:e=>{n(),i.selectSession(e)},isLocalChat:e=>r.sessions.some(t=>t.id===e)},N.id):(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Choose a conversation.`})})]})]})}function uz({c:e}){return(0,W.jsx)(`span`,{title:Kd.status,"data-testid":`conversation-status`,children:(0,W.jsx)(Z,{tone:jd(e.status),children:Ad[e.status]})})}function dz({label:e,used:t,budget:n,format:r=e=>e.toLocaleString()}){let i=Vd(t,n),a=i>=1?`bg-danger`:i>=.8?`bg-warn`:`bg-accent`;return(0,W.jsxs)(`div`,{className:`mt-1`,"data-testid":`usage-${e.toLowerCase()}`,children:[(0,W.jsxs)(`div`,{className:`flex justify-between gap-2 text-[11px] text-fg-muted`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsxs)(`span`,{"data-testid":`usage-numbers`,children:[r(t),` of `,r(n)]})]}),(0,W.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`${e} used`,"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":t,children:(0,W.jsx)(`div`,{className:U(`h-full rounded-full`,a),style:{width:`${Math.round(i*100)}%`}})})]})}function fz({c:e,selected:t,onSelect:n}){let r=e.members.filter(e=>e.leftAt===null);return(0,W.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,className:U(`w-full rounded-md border px-2.5 py-2 text-left text-xs`,t?`border-accent bg-accent-soft`:`border-border hover:bg-surface-2`),"data-testid":`conversation-row-${e.id}`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:Ed(e)}),(0,W.jsx)(uz,{c:e})]}),(0,W.jsxs)(`div`,{className:`mt-0.5 truncate text-fg-muted`,"data-testid":`conversation-members`,children:[r.length,` chat`,r.length===1?``:`s`,e.title?`: ${r.map(e=>e.title).join(`, `)}`:``]}),e.status!==`active`&&e.pausedReason?(0,W.jsx)(`div`,{className:`mt-0.5 text-warn`,"data-testid":`conversation-paused-reason`,children:e.pausedReason}):null,(0,W.jsx)(dz,{label:`Messages`,used:e.used.messages,budget:e.budget.messages}),(0,W.jsx)(dz,{label:`Tokens`,used:e.used.tokens,budget:e.budget.tokens,format:ig}),(0,W.jsxs)(`div`,{className:`mt-1 flex justify-between gap-2 text-[11px] text-fg-faint`,children:[(0,W.jsx)(`span`,{"data-testid":`conversation-cost`,children:Wd(e.used.credits)}),(0,W.jsx)(`span`,{title:sg(e.lastActivityAt),children:ag(e.lastActivityAt)})]})]})}function pz({title:e,help:t,children:n}){return(0,W.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3 first:border-t-0 first:pt-0`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:[e,t?(0,W.jsx)(Hy,{label:e,details:t}):null]}),n]})}var mz={working:`working`,idle:`idle`,asleep:`asleep`,missing:`gone`},hz={working:`This chat is working on a turn right now.`,idle:`This chat is open and waiting.`,asleep:`This chat is not running; a message wakes it from its saved history.`,missing:`This chat is not on this PC any more (deleted).`};function gz({c:e,messages:t,titleOf:n,onAction:r,onWithdraw:i,onOpenChat:a,isLocalChat:o}){let[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(String(e.budget.messages)),[h,g]=(0,v.useState)(String(e.budget.tokens));(0,v.useEffect)(()=>{m(String(e.budget.messages)),g(String(e.budget.tokens))},[e.budget.messages,e.budget.tokens]);let _=async(e,t,n)=>{c(e);try{return await r(t,n)}finally{c(null)}},y=p.trim()!==String(e.budget.messages)||h.trim()!==String(e.budget.tokens),b=y?Ud(p,h):null,x=()=>{if(!y||Ud(p,h))return;let t={},n=Number(p.trim()),r=Number(h.trim());n!==e.budget.messages&&(t.messages=n),r!==e.budget.tokens&&(t.tokens=r),_(`budget`,`budget`,t)},S=e.status===`closed`,C=(0,v.useMemo)(()=>[...e.members].sort((e,t)=>(e.leftAt===null?0:1)-(t.leftAt===null?0:1)),[e.members]);return(0,W.jsxs)(`div`,{className:`space-y-4`,"data-testid":`conversation-detail`,"data-id":e.id,children:[(0,W.jsxs)(pz,{title:`Conversation`,help:Kd.status,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`min-w-0 text-base font-semibold text-fg`,children:Ed(e)}),(0,W.jsx)(uz,{c:e})]}),e.pausedReason&&!S?(0,W.jsxs)(`p`,{className:`text-xs text-warn`,"data-testid":`conversation-detail-reason`,children:[`Paused: `,e.pausedReason]}):e.pausedReason&&S?(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Closed: `,e.pausedReason]}):null,(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Started `,sg(e.createdAt),` · last activity`,` `,(0,W.jsx)(`span`,{title:sg(e.lastActivityAt),children:ag(e.lastActivityAt)}),e.waiting>0?` · ${e.waiting} waiting to be delivered`:``]}),S?null:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.status===`active`?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(J,{size:`sm`,onClick:()=>void _(`pause`,`pause`),busy:s===`pause`,title:Kd.pause,"data-testid":`conversation-pause`,children:`Pause`}),(0,W.jsx)(Hy,{label:`Pause`,details:Kd.pause})]}):(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(J,{size:`sm`,variant:`primary`,onClick:()=>void _(`resume`,`resume`),busy:s===`resume`,title:Kd.resume,"data-testid":`conversation-resume`,children:`Resume`}),(0,W.jsx)(Hy,{label:`Resume`,details:Kd.resume})]}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(J,{size:`sm`,variant:l?`danger`:`ghost`,busy:s===`close`,title:Kd.close,onClick:()=>{if(!l){u(!0);return}u(!1),_(`close`,`close`)},"data-testid":`conversation-close`,children:l?`Close it for good?`:`Close`}),(0,W.jsx)(Hy,{label:`Close`,details:Kd.close})]})]})]}),(0,W.jsxs)(pz,{title:`Budget`,help:Kd.budget,children:[(0,W.jsx)(dz,{label:`Messages`,used:e.used.messages,budget:e.budget.messages}),(0,W.jsx)(dz,{label:`Tokens`,used:e.used.tokens,budget:e.budget.tokens,format:ig}),(0,W.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,W.jsxs)(`span`,{"data-testid":`conversation-detail-cost`,children:[`Cost so far `,Wd(e.used.credits),` · `,ig(e.used.tokens),` `,`new tokens`]}),(0,W.jsx)(Hy,{label:`Cost`,details:Kd.cost})]}),S?null:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,W.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[`Messages`,(0,W.jsx)(`input`,{className:U(X,`w-24`),inputMode:`numeric`,value:p,onChange:e=>m(e.target.value),"data-testid":`conversation-budget-messages`})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[`Tokens`,(0,W.jsx)(`input`,{className:U(X,`w-32`),inputMode:`numeric`,value:h,onChange:e=>g(e.target.value),"data-testid":`conversation-budget-tokens`})]}),(0,W.jsx)(J,{size:`sm`,variant:`primary`,onClick:x,disabled:!y||b!==null,busy:s===`budget`,title:Kd.budget,"data-testid":`conversation-budget-save`,children:`Save budget`}),b?(0,W.jsx)(`span`,{className:`text-xs text-danger`,"data-testid":`conversation-budget-problem`,children:b}):null]})]}),(0,W.jsx)(pz,{title:`Chats`,help:Kd.removeMember,children:(0,W.jsx)(`ul`,{className:`space-y-1`,"data-testid":`conversation-members-list`,children:C.map(e=>{let t=`${e.hostId}:${e.sessionId}`,n=e.leftAt!==null;return(0,W.jsxs)(`li`,{className:U(`flex flex-wrap items-center gap-2 rounded-md border border-border px-2.5 py-1.5 text-xs`,n&&`opacity-60`),"data-testid":`conversation-member-${e.sessionId}`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-fg`,children:e.title}),(0,W.jsx)(`span`,{title:hz[e.state],children:(0,W.jsx)(Z,{tone:e.state===`working`?`accent`:`neutral`,children:mz[e.state]})}),e.talkOn===!1?(0,W.jsx)(`span`,{className:`text-fg-faint`,title:`Its "Talk to other chats" switch is off: it cannot message other chats. It still answers a chat that messages it, and only that chat, when asked; what it sent before, and answers to what it asked, wait until it is on again.`,children:`answers only`}):null,n?(0,W.jsx)(`span`,{className:`text-fg-faint`,title:sg(e.leftAt),children:`left`}):null,e.state!==`missing`&&o(e.sessionId)?(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>a(e.sessionId),title:Kd.openChat,"data-testid":`conversation-member-open`,children:`Open chat`}):null,!n&&!S?(0,W.jsx)(J,{size:`sm`,variant:d===t?`danger`:`ghost`,busy:s===`remove:${t}`,title:Kd.removeMember,onClick:()=>{if(d!==t){f(t);return}f(null),_(`remove:${t}`,`remove-member`,{sessionId:e.sessionId,hostId:e.hostId})},"data-testid":`conversation-member-remove`,children:d===t?`Remove?`:`Remove`}):null]},t)})})}),(0,W.jsx)(pz,{title:`History`,help:Kd.history,children:t===null?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading…`}):t.length===0?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Nothing has been sent yet.`}):(0,W.jsx)(`ol`,{className:`space-y-2`,"data-testid":`conversation-history`,children:t.map(t=>(0,W.jsx)(_z,{m:t,from:t.kind===`notice`?`OonaCode`:n(t.fromSession,t.fromTitle,e.members),to:n(t.toSession,t.toTitle,e.members),onWithdraw:()=>i(t)},t.id))})})]})}function _z({m:e,from:t,to:n,onWithdraw:r}){let i=Fd(e),a=Hd(i),o=Rd(e),s=zd(e),[c,l]=(0,v.useState)(!1),u=e.kind===`reply`?q.Reply:e.kind===`notice`?q.Alert:e.kind===`continue`?q.Refresh:q.Mail;return(0,W.jsxs)(`li`,{className:U(`rounded-md border px-2.5 py-2 text-xs`,e.kind===`notice`?`border-warn/40 bg-warn-soft/40`:`border-border`),"data-testid":`conversation-message-${e.id}`,"data-kind":e.kind,"data-status":e.status,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,W.jsx)(u,{className:U(`h-3.5 w-3.5`,e.kind===`notice`?`text-warn`:`text-accent`)}),(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:Md[e.kind]}),(0,W.jsxs)(`span`,{className:`min-w-0 truncate text-fg-muted`,"data-testid":`conversation-message-route`,children:[t,` → `,n]}),(0,W.jsx)(`span`,{className:`text-fg-faint`,title:sg(e.createdAt),children:cg(e.createdAt)}),(0,W.jsx)(`span`,{className:`flex-1`}),e.kind===`notice`?null:(0,W.jsx)(`span`,{title:Nd[e.status],children:(0,W.jsx)(Z,{tone:Pd(e.status),children:(0,W.jsx)(`span`,{"data-testid":`conversation-message-status`,children:e.status})})})]}),o||s||e.continued||e.stalled?(0,W.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-2 text-fg-muted`,children:[o?(0,W.jsx)(`span`,{title:o.help,"data-testid":`conversation-message-reply`,children:o.text}):null,s?(0,W.jsx)(`span`,{"data-testid":`conversation-message-batch`,children:s}):null,e.continued?(0,W.jsx)(`span`,{children:`continued after an OonaCode restart`}):null,e.stalled?(0,W.jsxs)(`span`,{className:`text-warn`,children:[`waiting for your permission to use `,e.stalled]}):null]}):null,e.error?(0,W.jsx)(`div`,{className:U(`mt-0.5`,e.status===`failed`?`text-danger`:`text-fg-muted`),"data-testid":`conversation-message-error`,children:e.error}):null,e.tokens>0||(e.credits??0)>0?(0,W.jsxs)(`div`,{className:`mt-0.5 text-fg-faint`,"data-testid":`conversation-message-usage`,children:[`The turn it caused: `,Gd(e,ig(e.tokens))]}):null,(0,W.jsx)(`div`,{className:U(`mt-1.5 text-fg`,a&&!c&&`max-h-24 overflow-hidden [mask-image:linear-gradient(to_bottom,black_60%,transparent)]`),"data-testid":`conversation-message-body`,"data-collapsed":a&&!c?`true`:void 0,children:(0,W.jsx)(aN,{text:i})}),(0,W.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[a?(0,W.jsx)(`button`,{type:`button`,className:`text-accent hover:underline`,onClick:()=>l(e=>!e),"aria-expanded":c,"data-testid":`conversation-message-expand`,children:c?`Show less`:`Show all`}):null,(0,W.jsx)(`span`,{className:`flex-1`}),Bd(e)?(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:r,title:Kd.withdraw,"data-testid":`conversation-message-withdraw`,children:`Withdraw`}):null]})]})}var vz={language:`en`,localVoice:{},speed:1,words:Nu.words},yz=`oonacode.voiceSummary.v1`;function bz(e){let t=e&&typeof e==`object`?e:{},n=vz,r={};if(t.localVoice&&typeof t.localVoice==`object`)for(let[e,n]of Object.entries(t.localVoice))typeof n==`string`&&n.length<300&&ju(e)&&(r[e]=n);return{language:typeof t.language==`string`&&ju(t.language)?ju(t.language).code:n.language,localVoice:r,speed:Iu(t.speed),words:Fu(t.words)}}function xz(e=Cz()){try{let t=e?.getItem(yz);return bz(t?JSON.parse(t):null)}catch{return{...vz}}}function Sz(e,t=Cz()){try{t?.setItem(yz,JSON.stringify(e))}catch{}}function Cz(){try{return typeof window<`u`?window.localStorage:null}catch{return null}}function wz(e){return e.kind===`system`?null:e.key.slice(e.key.indexOf(`:`)+1)}var Tz={zh:[`cmn`]};function Ez(e){return e.toLowerCase().replace(/_/g,`-`)}function Dz(e,t){let n=Ez(e);return[t.code,...Tz[t.code]??[]].some(e=>n===e||n.startsWith(`${e}-`))}function Oz(e,t){let n=Ez(e);return n===Ez(t.bcp47)?0:n===t.code||(Tz[t.code]??[]).includes(n)?1:2}function kz(e){let t=new Set(e.map(e=>e.name));return e.filter(e=>{let n=e.name.indexOf(`+`);if(n<=0)return!0;let r=e.name.lastIndexOf(` `),i=r>n?e.name.slice(r+1):``,a=i?`${e.name.slice(0,n)} ${i}`:e.name.slice(0,n);return!t.has(a)})}function Az(e,t,n){let r=t.filter(t=>t.language===e.code||(t.locale?Dz(t.locale,e):!1)),i=r.filter(e=>e.engine!==`espeak`).map(e=>({key:`sherpa:${e.id}`,label:e.label,kind:`sherpa`})),a=r.filter(e=>e.engine===`espeak`).slice(0,1).map(e=>({key:`espeak:${e.id}`,label:e.label||`eSpeak (robotic)`,kind:`espeak`})),o=kz(n.filter(t=>Dz(t.lang,e)&&t.localService!==!1)).map((t,n)=>({v:t,i:n,fit:Oz(t.lang,e)})).sort((e,t)=>e.fit-t.fit||e.i-t.i).map(({v:e})=>({key:`system:${e.voiceURI}`,label:`${e.name} (system)`,kind:`system`}));return[...i,...o,...a]}function jz(e,t){return e.find(e=>e.key===t)??e[0]??null}function Mz(e,t){if(e===`win32`||e===`linux`||e===`darwin`)return e;let n=t??``;return/Windows|Win32|Win64/i.test(n)?`win32`:/Android|CrOS/i.test(n)?null:/Linux|X11/i.test(n)?`linux`:/Mac OS X|Macintosh/i.test(n)?`darwin`:null}function Nz(e,t,n=null,r=!1){let i=t?``:` The OonaCode desktop app comes with its own Armenian voices, and eSpeak for every other language.`,a=`No local voice for ${e.name} on this PC.`;return t&&n===`win32`&&r?`${a} The app’s own eSpeak voice, which speaks every language here, could not start — usually because Microsoft’s Visual C++ Redistributable (x64) is not installed: https://aka.ms/vs/17/release/vc_redist.x64.exe. Install it, then open this window again.`:n===`linux`?`${a} Install speech-dispatcher and espeak-ng from your distribution (Debian, Ubuntu, Mint: sudo apt install speech-dispatcher espeak-ng · Fedora: sudo dnf install speech-dispatcher espeak-ng · Arch: sudo pacman -S speech-dispatcher espeak-ng), then restart OonaCode.${i}`:n===`darwin`?`${a} Add a ${e.name} voice in System Settings → Accessibility → Spoken Content → System voice → Manage Voices, then open this window again.${i}`:n===`win32`?`${a} Add a ${e.name} voice in Settings → Time & language → Speech → Add voices, if Windows offers one for ${e.name}, then open this window again.${i}`:`${a} Add a ${e.name} voice in the system's speech settings (Windows: Settings → Time & language → Speech), then open this window again.${i}`}function Pz(e){return e===`linux`?`whole`:`sentences`}var Fz=75;function Iz(e,t){return Math.round(3e3+e.length*120/Iu(t))}async function Lz(e,t,n,r){let{signal:i,onItem:a}=r,o=e.getVoices().find(e=>e.voiceURI===r.voiceURI)??null;e.cancel();let s=r.mode===`whole`?[n.join(` `)]:[...n];for(let c=0;c<s.length;c+=1){if(i.aborted)return;let l=s[c],u=await new Promise((s,u)=>{let d=[],f=!1,p=()=>!f&&(f=!0,d.forEach(e=>clearTimeout(e)),i.removeEventListener(`abort`,m),!0),m=()=>{p()&&(e.cancel(),s(`stopped`))},h=t(l);o&&(h.voice=o),h.lang=o?.lang??r.bcp47,h.rate=r.rate,h.onstart=()=>{if(f)return;if(r.mode===`sentences`){a(c);return}a(0);let e=0;for(let t=1;t<n.length;t+=1)e+=(n[t-1].length+1)*Fz/Iu(r.rate),d.push(setTimeout(()=>!f&&a(t),e))},h.onend=()=>{p()&&s(`ended`)},h.onerror=e=>{p()&&(i.aborted||e.error===`interrupted`||e.error===`canceled`?s(`stopped`):u(Error(`The system voice failed: ${e.error??`unknown error`}`)))},i.addEventListener(`abort`,m),d.push(setTimeout(()=>{p()&&s(`lost`)},Iz(l,r.rate))),e.speak(h)});if(u===`stopped`)return;u===`lost`&&e.cancel()}}function Rz(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function zz(e,t){let n=new DataView(new ArrayBuffer(44)),r=(e,t)=>{for(let r=0;r<t.length;r+=1)n.setUint8(e+r,t.charCodeAt(r))};return r(0,`RIFF`),n.setUint32(4,36+e,!0),r(8,`WAVE`),r(12,`fmt `),n.setUint32(16,16,!0),n.setUint16(20,1,!0),n.setUint16(22,1,!0),n.setUint32(24,t,!0),n.setUint32(28,t*2,!0),n.setUint16(32,2,!0),n.setUint16(34,16,!0),r(36,`data`),n.setUint32(40,e,!0),n}function Bz(e,t){let n=new Uint8Array(44+e.length);return n.set(new Uint8Array(zz(e.length,t).buffer),0),n.set(e,44),n.buffer}function Vz(e,t){let n=new DataView(new ArrayBuffer(e.length*2));for(let t=0;t<e.length;t+=1){let r=Math.max(-1,Math.min(1,e[t]));n.setInt16(t*2,Math.round(r*32767),!0)}return Bz(new Uint8Array(n.buffer),t)}function Hz(){let e=null,t=()=>{if(!e)return;let t=e;e=null,URL.revokeObjectURL(t.url),t.done()};return{play(n,r){return t(),new Promise(i=>{let a=URL.createObjectURL(new Blob([n],{type:`audio/wav`})),o=new Audio(a);o.preservesPitch=!0,o.playbackRate=r,e={audio:o,url:a,done:i},o.onended=t,o.onerror=t,o.play().catch(t)})},stop(){e&&e.audio.pause(),t()}}}var Uz=Hz;async function Wz(e,t,n,r){if(e.length===0)return;let i=t(e[0],0);for(let a=0;a<e.length;a+=1){if(r.signal.aborted)return;let o=await i;if(r.signal.aborted)return;i=a+1<e.length?t(e[a+1],a+1):null,i?.catch(()=>void 0),r.onItem?.(a),await n.play(o,r.playbackRate??1)}}var Gz={range:`all`,from:``,to:``},Kz=`oonacode.aboutBriefing.v1`,qz=/^\d{4}-\d{2}-\d{2}$/;function Jz(e){let t=e&&typeof e==`object`?e:{};return{range:Su(t.range)?t.range:Gz.range,from:typeof t.from==`string`&&qz.test(t.from)?t.from:``,to:typeof t.to==`string`&&qz.test(t.to)?t.to:``}}function Yz(){try{let e=window.localStorage.getItem(Kz);return Jz(e?JSON.parse(e):null)}catch{return{...Gz}}}function Xz(e){try{window.localStorage.setItem(Kz,JSON.stringify(e))}catch{}}function Zz(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t.has(r)&&(n+=1);return n===0?`none`:n===e.length?`all`:`some`}function Qz(e,t){let n=new Set(t);if(Zz(e,t)===`all`)for(let t of e)n.delete(t);else for(let t of e)n.add(t);return n}function $z(e,t){let n=new Set(t),r=!1;for(let t of e)n.has(t)||(r=!0);return r?new Set([...e].filter(e=>n.has(e))):e}function eB(e,t){let n=[];if(e>0&&n.push(`${e} of the picked chats ${e===1?`has`:`have`} no about yet`),t>0){let r=e>0?`${t}`:`${t} of the picked chats`;n.push(`${r} ${t===1?`has an about`:`have abouts`} older than the chat’s last change`)}let r=[e>0?`a chat with no about is announced by its name and “no summary yet”`:null,t>0?`an older about is read as it is`:null].filter(Boolean).join(`, and `);return`${n.join(`; `)}. Writing them is one housekeeper call per chat, paid by the chat’s own route — credits for an OonaCode pool chat. Until then ${r}.`}var tB={status:`idle`,index:-1,total:0,sessionId:null,title:null,part:0,error:null,playlist:[]};function nB(e){return e.status===`preparing`||e.status===`speaking`||e.status===`paused`}var rB={afterNameMs:bu.afterNameMs,betweenChatsMs:bu.betweenChatsMs};function iB(e,t){return new Promise(n=>{if(t.aborted||e<=0){n();return}let r=()=>{clearTimeout(i),t.removeEventListener(`abort`,r),n()},i=setTimeout(r,e);t.addEventListener(`abort`,r,{once:!0})})}function aB(e,t){return t.aborted?Promise.reject(Error(`stopped`)):new Promise((n,r)=>{let i=()=>r(Error(`stopped`));t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})})}var oB=class{#e;#t=[];#n=tB;#r=null;#i=new Map;#a=new AbortController;constructor(e){this.#e=e}get state(){return this.#n}start(e,t=0){if(this.#t=[...e],this.#i.clear(),this.#t.length===0){this.#o(),this.#s({...tB});return}this.#l(Math.max(0,Math.min(t,this.#t.length-1)),0)}pause(){(this.#n.status===`preparing`||this.#n.status===`speaking`)&&(this.#o(),this.#s({status:`paused`}))}resume(){let e=this.#n;e.index<0||this.#t.length===0||(e.status===`paused`?this.#l(e.index,e.part):e.status===`error`&&this.#l(e.index,0))}stop(){this.#o(),this.#n.status!==`idle`&&this.#n.status!==`stopped`&&this.#s({status:`stopped`,index:-1,part:0,error:null})}reset(){this.#o(),this.#t=[],this.#i.clear(),this.#n!==tB&&(this.#n=tB,this.#e.onState(tB))}next(){if(this.#t.length===0||this.#n.index<0)return;let e=this.#n.index+1;if(e>=this.#t.length){this.#o(),this.#s({status:`done`,part:0});return}this.#l(e,0)}previous(){this.#t.length===0||this.#n.index<0||this.#l(Math.max(0,this.#n.index-1),0)}jumpTo(e){let t=this.#t.findIndex(t=>t.sessionId===e);t>=0&&this.#l(t,0)}resetWords(){this.#i.clear()}dispose(){this.reset(),this.#a.abort()}#o(){let e=this.#r;if(this.#r=null,e){e.abort();try{this.#e.silence()}catch{}}}#s(e){let t={...this.#n,...e},n=t.index>=0?this.#t[t.index]:void 0;t.total=this.#t.length,t.sessionId=n?.sessionId??null,t.title=n?.title??null,t.playlist=t.playlist.length===this.#t.length&&t.playlist.every((e,t)=>e===this.#t[t].sessionId)?t.playlist:this.#t.map(e=>e.sessionId),this.#n=t,this.#e.onState(t)}#c(e){let t=this.#t[e],n=this.#i.get(t.sessionId);if(n)return n;let r=this.#e.words(t,this.#a.signal);return this.#i.set(t.sessionId,r),r.catch(()=>{this.#i.get(t.sessionId)===r&&this.#i.delete(t.sessionId)}),r}#l(e,t){this.#o();let n=new AbortController;this.#r=n,this.#u(e,t,n.signal)}async#u(e,t,n){let r=this.#e.sleep??iB,i=this.#e.afterNameMs??rB.afterNameMs,a=this.#e.betweenChatsMs??rB.betweenChatsMs,o=e;try{for(;o<this.#t.length;o+=1){let s=o===e?t:0;this.#s({status:`preparing`,index:o,part:s,error:null});let c=await aB(this.#c(o),n);if(n.aborted)return;o+1<this.#t.length&&this.#c(o+1).catch(()=>void 0);let l=+!!c.name;if(c.name&&s===0&&(this.#s({status:`speaking`,part:0}),await this.#e.speak([c.name],{signal:n,onItem:()=>void 0}),n.aborted||(c.body.length>0&&await r(i,n),n.aborted)))return;let u=Math.max(0,s-l),d=c.body.slice(u);if(d.length>0&&(this.#s({status:`speaking`,part:l+u}),await this.#e.speak(d,{signal:n,onItem:e=>{n.aborted||this.#s({status:`speaking`,part:l+u+e})}}),n.aborted)||o+1<this.#t.length&&(await r(a,n),n.aborted))return}this.#r?.signal===n&&(this.#r=null),this.#s({status:`done`,index:this.#t.length-1,part:0})}catch(e){if(n.aborted)return;this.#r?.signal===n&&(this.#r=null);try{this.#e.silence()}catch{}let t=this.#t[o]?.title??`a chat`,r=e instanceof Error?e.message:String(e);this.#s({status:`error`,index:Math.min(o,this.#t.length-1),part:0,error:`${t}: ${r}`})}}};async function sB(e,t){let{voice:n,language:r,speed:i,tts:a,signal:o,onItem:s}=t,c=n?wz(n):null;if(c&&a){await Wz(e,async e=>{let n=await a.speak({voiceId:c,text:t.prepare(e,r.code),speed:i});return Vz(n.samples,n.sampleRate)},t.player,{signal:o,onItem:s});return}if(n?.kind===`system`){if(!t.synth)throw Error(`This window has no system speech.`);await Lz(t.synth,t.makeUtterance,e,{voiceURI:n.key.slice(7),bcp47:r.bcp47,rate:i,mode:Pz(t.platform),signal:o,onItem:s});return}throw Error(Nz(r,!!a,t.platform,t.espeakMissing))}function cB(e){let[t,n]=(0,v.useState)([]);return(0,v.useEffect)(()=>{if(!e||typeof window>`u`||!window.speechSynthesis)return;let t=window.speechSynthesis,r=()=>n(t.getVoices());return r(),t.addEventListener?.(`voiceschanged`,r),()=>t.removeEventListener?.(`voiceschanged`,r)},[e]),t}function lB(e){let t=e instanceof Error?e.message:String(e);return/no route for|not_found|404/i.test(t)&&/voice/i.test(t)?`This PC’s OonaCode host does not know "Listen" yet — update OonaCode.`:t}function uB({open:e,onClose:t}){let{state:n,api:r}=G(),i=n.voiceSummarySessionId,a=(0,v.useMemo)(()=>n.sessions.find(e=>e.id===i)??null,[n.sessions,i]),o=typeof window<`u`?window.oonacode?.tts:void 0,s=Mz(typeof window<`u`?window.oonacode?.platform:null,typeof navigator<`u`?navigator.userAgent:null),[c,l]=(0,v.useState)(()=>xz()),[u,d]=(0,v.useState)(null),f=cB(e),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)({kind:`idle`}),[S,C]=(0,v.useState)(null),w=(0,v.useRef)(null),T=ju(c.language)??ju(`en`),E=(0,v.useCallback)(e=>{l(t=>{let n={...t,...e};return Sz(n),n})},[]),D=p?.summaries??[],O=D.find(e=>e.id===_)??D[0]??null,k=(0,v.useCallback)(async()=>{if(!i||!r.listVoiceSummaries)return null;try{let e=await r.listVoiceSummaries(i);return m(e),g(null),e}catch(e){return g(lB(e)),null}},[r,i]);(0,v.useEffect)(()=>{e&&(m(null),y(null),C(null),x({kind:`idle`}),k(),o?(d(null),o.listVoices().then(d,()=>d([]))):d([]))},[e,k,o]);let A=a?`${a.entryCount}:${a.mtime}`:null,j=(0,v.useRef)(null),M=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!e){j.current=null;return}if(j.current===null){j.current=A;return}A!==j.current&&(j.current=A,!M.current&&(M.current=setTimeout(()=>{M.current=null,k()},800)))},[e,A,k]),(0,v.useEffect)(()=>()=>{M.current&&clearTimeout(M.current),M.current=null},[]);let ee=(0,v.useCallback)(()=>{let e=w.current;w.current=null,e&&(e.abort.abort(),e.stop())},[]);(0,v.useEffect)(()=>{e||ee()},[e,ee]),(0,v.useEffect)(()=>()=>ee(),[ee]);let N=(0,v.useMemo)(()=>Az(T,u??[],f),[T,u,f]),P=jz(N,c.localVoice[T.code]),F=!!(o&&u&&!u.some(e=>e.engine===`espeak`)),I=b.kind===`summarising`||b.kind===`translating`||b.kind===`speaking`,te=!!(r.listVoiceSummaries&&r.createVoiceSummary),ne=async()=>{if(!i||!r.createVoiceSummary)return null;x({kind:`summarising`});let e=await r.createVoiceSummary(i,{words:c.words});return C(e.created?null:Sd.unchanged(Rz(e.summary.createdAt))),y(e.summary.id),await k(),e.summary},re=async()=>{if(!i)return;ee();let e=new AbortController,t=Uz(),n=()=>{try{window.speechSynthesis?.cancel()}catch{}};w.current={abort:e,stop:()=>{t.stop(),n()}};let a=e.signal;try{let e=_d(p,_)?await ne():O;if(a.aborted)return;if(!e)throw Error(`There is no summary to play.`);let n=yd(e,T.code);if(n===null){if(!r.translateVoiceSummary)throw Error(`This host cannot translate yet.`);x({kind:`translating`});let t=await r.translateVoiceSummary(i,e.id,{language:T.code});if(m(n=>dB(n,e.id,t.translation)),a.aborted)return;n=t.translation.text,k()}let l=Qu(n);if(l.length===0)throw Error(`There was nothing to read.`);let u=e=>x({kind:`speaking`,index:e+1,total:l.length}),d=P?wz(P):null;if(d&&o)await Wz(l,async e=>{let t=await o.speak({voiceId:d,text:gd(e,T.code),speed:c.speed});return Vz(t.samples,t.sampleRate)},t,{signal:a,onItem:u});else if(P?.kind===`system`){let e=typeof window<`u`?window.speechSynthesis:void 0;if(!e)throw Error(`This window has no system speech.`);await Lz(e,e=>new SpeechSynthesisUtterance(e),l,{voiceURI:P.key.slice(7),bcp47:T.bcp47,rate:c.speed,mode:Pz(s),signal:a,onItem:u})}else throw Error(Nz(T,!!o,s,F));if(a.aborted)return;x({kind:`done`})}catch(e){if(a.aborted)return;x({kind:`error`,message:lB(e)})}finally{w.current?.abort===e&&(w.current=null)}},L=()=>{ee(),x({kind:`stopped`})},ie=async e=>{if(!(!i||!r.deleteVoiceSummary))try{await r.deleteVoiceSummary(i,e),_===e&&y(null),await k()}catch(e){x({kind:`error`,message:lB(e)})}};if(!e)return null;let R=a?Vl(a):`this chat`,ae=O?yd(O,T.code):null,oe=O?new Set(vd(O)):new Set;return(0,W.jsx)(Ky,{open:e,title:`Listen to this chat`,onClose:t,wide:!0,footer:(0,W.jsxs)(W.Fragment,{children:[I?(0,W.jsxs)(J,{onClick:L,"data-testid":`voice-stop`,children:[(0,W.jsx)(q.Stop,{className:`h-4 w-4`}),` Stop`]}):null,(0,W.jsxs)(J,{variant:`primary`,onClick:()=>void re(),disabled:I||!te||!i,"data-testid":`voice-play`,children:[(0,W.jsx)(q.Play,{className:`h-4 w-4`}),` Play`]}),(0,W.jsx)(J,{onClick:t,children:`Close`})]}),children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm`,children:[(0,W.jsxs)(`p`,{className:`text-fg-muted`,children:[`A spoken summary of `,(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:R}),` — its goal, what was done, where it stands and what is pending — written by the chat’s own model, in English. Other languages are translated once by `,Mu.label,` on your OonaCode credits and kept with the summary.`]}),te?null:(0,W.jsx)(`p`,{className:`text-danger`,children:`This version of the host cannot make voice summaries.`}),(0,W.jsxs)(`section`,{"data-testid":`voice-summaries`,children:[(0,W.jsx)(`h3`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Summaries`}),h?(0,W.jsx)(`p`,{className:`text-xs text-danger`,children:h}):null,p&&D.length===0?(0,W.jsx)(`p`,{className:`text-fg-muted`,"data-testid":`voice-no-summaries`,children:Sd.noSummaries}):null,D.length>0&&_d(p,_)?(0,W.jsx)(`p`,{className:`mb-1 text-xs text-fg-muted`,"data-testid":`voice-changed`,children:Sd.changedSinceNewest}):null,(0,W.jsx)(`ul`,{className:`flex max-h-56 flex-col gap-1 overflow-y-auto`,children:D.map(e=>{let t=O?.id===e.id;return(0,W.jsxs)(`li`,{"data-testid":`voice-summary-row`,className:U(`flex items-start gap-2 rounded-md border px-2 py-1.5`,t?`border-accent bg-accent/10`:`border-border`),children:[(0,W.jsx)(`input`,{type:`radio`,name:`voice-summary`,className:`mt-1`,"aria-label":`Summary of ${Rz(e.createdAt)}`,checked:t,disabled:I,onChange:()=>y(e.id)}),(0,W.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 flex-col items-start text-left`,disabled:I,onClick:()=>y(e.id),children:[(0,W.jsxs)(`span`,{className:`font-medium`,children:[Rz(e.createdAt),e.current?(0,W.jsx)(`span`,{className:`ml-2 rounded-full bg-accent/15 px-1.5 text-xs text-accent`,children:`current`}):null]}),(0,W.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[e.words,` words · about `,bd(e.seconds),` ·`,` `,vd(e).map(e=>e.toUpperCase()).join(` `),` `,`· `,e.cost.model??`the chat’s model`,` · `,xd(e.cost)]})]}),(0,W.jsx)(J,{size:`sm`,onClick:()=>void ie(e.id),disabled:I,"aria-label":`Delete the summary of ${Rz(e.createdAt)}`,"data-testid":`voice-summary-delete`,children:(0,W.jsx)(q.Trash,{className:`h-3.5 w-3.5`})})]},e.id)})}),S?(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,"data-testid":`voice-notice`,children:S}):null]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,W.jsx)(Wy,{label:`Language`,children:(0,W.jsx)(`select`,{"aria-label":`Language`,className:Gy,value:T.code,disabled:I,onChange:e=>E({language:e.target.value}),children:Au.map(e=>{let t=e.name===e.native?e.name:`${e.name} — ${e.native}`;return(0,W.jsx)(`option`,{value:e.code,children:oe.has(e.code)?`${t} ✓`:t},e.code)})})}),o&&u===null?(0,W.jsx)(`p`,{className:`px-1 py-2 text-fg-muted`,"data-testid":`voice-loading`,children:`Looking for this PC’s voices…`}):N.length>0?(0,W.jsx)(Wy,{label:`Voice`,children:(0,W.jsx)(`select`,{"aria-label":`Voice`,className:Gy,value:P?.key??``,disabled:I,onChange:e=>E({localVoice:{...c.localVoice,[T.code]:e.target.value}}),children:N.map(e=>(0,W.jsx)(`option`,{value:e.key,children:e.label},e.key))})}):(0,W.jsx)(`p`,{className:`rounded-md border border-border bg-surface-2 px-3 py-2 text-fg-muted`,"data-testid":`no-local-voice`,children:Nz(T,!!o,s,F)}),(0,W.jsx)(Wy,{label:`Speed ×${c.speed.toFixed(2)}`,children:(0,W.jsx)(`input`,{"aria-label":`Speed`,type:`range`,min:Pu.speed.min,max:Pu.speed.max,step:.05,value:c.speed,disabled:I,onChange:e=>E({speed:Number(e.target.value)})})}),(0,W.jsx)(Wy,{label:`Length of a new summary`,children:(0,W.jsxs)(`select`,{"aria-label":`Length of a new summary`,className:Gy,value:String(c.words),disabled:I,onChange:e=>E({words:Number(e.target.value)}),children:[(0,W.jsx)(`option`,{value:`120`,children:`Short — about 120 words`}),(0,W.jsx)(`option`,{value:`200`,children:`Normal — about 200 words`}),(0,W.jsx)(`option`,{value:`300`,children:`Long — about 300 words`}),[120,200,300].includes(c.words)?null:(0,W.jsxs)(`option`,{value:String(c.words),children:[c.words,` words`]})]})})]}),(0,W.jsx)(fB,{stage:b}),O?(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:Sd.heading(T,ae!==null)}),(0,W.jsx)(`p`,{className:`whitespace-pre-wrap rounded-md border border-border bg-surface-2 px-3 py-2`,"data-testid":`voice-summary-text`,dir:ae!==null&&T.rtl?`rtl`:`ltr`,lang:ae===null?`en-US`:T.bcp47,children:ae??O.text})]}):null]})})}function dB(e,t,n){return e&&{...e,summaries:e.summaries.map(e=>e.id===t?{...e,translations:[...e.translations.filter(e=>e.language!==n.language),n]}:e)}}function fB({stage:e}){let t=[{key:`summarising`,label:Sd.generating},{key:`translating`,label:Sd.translating},{key:`speaking`,label:`Speaking`}];if(e.kind===`idle`)return null;if(e.kind===`error`)return(0,W.jsx)(`p`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-danger`,role:`alert`,"data-testid":`voice-stage`,children:e.message});if(e.kind===`stopped`||e.kind===`done`)return(0,W.jsx)(`p`,{className:`text-fg-muted`,"data-testid":`voice-stage`,children:e.kind===`stopped`?`Stopped.`:`Done.`});let n=t.findIndex(t=>t.key===e.kind);return(0,W.jsx)(`ol`,{className:`flex flex-wrap items-center gap-2 text-xs`,"data-testid":`voice-stage`,"aria-live":`polite`,children:t.map((t,r)=>(0,W.jsx)(`li`,{className:U(`rounded-full px-2 py-0.5`,r===n?`bg-accent/15 font-medium text-accent`:r<n?`text-fg-muted line-through`:`text-fg-faint`),children:t.key===`speaking`&&e.kind===`speaking`?`Speaking ${e.index} of ${e.total}`:t.label},t.key))})}function pB(e){return Yu(e).replace(/\n+/g,` `).trim()||e.trim()}function mB(e){let t=e instanceof Error?e.message:String(e);return/no route for|404/i.test(t)&&/about/i.test(t)?`This PC’s OonaCode host cannot read the abouts in other languages yet — update OonaCode. English plays.`:t}function hB(e){return{sessionId:e.sessionId,title:e.title.trim()||`Untitled chat`,about:e.about}}function gB(e){return e.filter(e=>!e.pending&&e.source!==`user`&&(!e.about||e.stale))}function _B({open:e,picked:t}){let{api:n}=G(),r=(0,v.useRef)(n);r.current=n;let i=typeof window<`u`?window.oonacode?.tts:void 0,a=Mz(typeof window<`u`?window.oonacode?.platform:null,typeof navigator<`u`?navigator.userAgent:null),[o,s]=(0,v.useState)(()=>xz()),[c,l]=(0,v.useState)(null),u=cB(e),d=ju(o.language)??ju(`en`),f=(0,v.useMemo)(()=>Az(d,c??[],u),[d,c,u]),p=jz(f,o.localVoice[d.code]),m=!!(i&&c&&!c.some(e=>e.engine===`espeak`)),[h,g]=(0,v.useState)(tB),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(0),[S,C]=(0,v.useState)(!1),w=(0,v.useRef)({lang:d,voice:p,speed:o.speed,espeakMissing:m,platform:a,tts:i});w.current={lang:d,voice:p,speed:o.speed,espeakMissing:m,platform:a,tts:i};let T=(0,v.useCallback)(e=>{s(t=>{let n={...t,...e};return Sz(n),n})},[]),E=(0,v.useMemo)(()=>{let e=Uz();return new oB({words:async e=>{let{lang:t}=w.current;if(!e.about)return{name:pB(e.title),body:[Du(t.code)]};if(t.code===`en`)return{name:pB(e.title),body:Qu(Yu(e.about))};let n=r.current.translateChatAbout;if(!n)throw Error(`This PC’s OonaCode host cannot read the abouts in other languages yet — update OonaCode. English plays.`);try{let r=await n(e.sessionId,{language:t.code});return r.created&&x(e=>e+1),{name:r.translation.name?pB(r.translation.name):null,body:Qu(r.translation.text)}}catch(e){throw Error(`could not translate it: ${mB(e)}`)}},speak:(t,{signal:n,onItem:r})=>{let i=w.current;return sB(t,{voice:i.voice,language:i.lang,speed:i.speed,tts:i.tts,player:e,synth:typeof window<`u`?window.speechSynthesis:void 0,makeUtterance:e=>new SpeechSynthesisUtterance(e),platform:i.platform,espeakMissing:i.espeakMissing,prepare:gd,signal:n,onItem:r})},silence:()=>{e.stop();try{typeof window<`u`&&window.speechSynthesis?.cancel()}catch{}},onState:g})},[]);(0,v.useEffect)(()=>{if(!e){E.reset();return}s(xz()),i?(l(null),i.listVoices().then(l,()=>l([]))):l([])},[e,i,E]),(0,v.useEffect)(()=>()=>E.dispose(),[E]),(0,v.useEffect)(()=>{E.resetWords()},[d.code,E]);let D=t.map(e=>`${e.sessionId}\u0000${e.title}\u0000${e.about??``}`).join(``);(0,v.useEffect)(()=>{C(!1)},[D,d.code]),(0,v.useEffect)(()=>{let r=n.planChatAboutTranslations;if(!e||d.code===`en`||t.length===0||!r){y(null);return}let i=!0;return r({language:d.code,sessionIds:t.map(e=>e.sessionId)}).then(e=>i&&y(e),()=>i&&y(null)),()=>{i=!1}},[e,d.code,D,b,n]);let O=h.status===`preparing`||h.status===`speaking`,k=d.code!==`en`&&_!==null&&_.language===d.code&&_.needed>bu.confirmAbove,A=(0,v.useCallback)(()=>{C(!1),E.start(t.map(hB),0)},[E,t]),j=(0,v.useCallback)(()=>{if(t.length!==0){if(k&&!S){C(!0);return}A()}},[t.length,k,S,A]);return{prefs:o,update:T,lang:d,options:f,voice:p,espeakMissing:m,voicesLoading:!!i&&c===null,desktop:!!i,platform:a,state:h,busy:O,active:nB(h),plan:_&&_.language===d.code?_:null,confirming:S,play:j,start:A,cancelConfirm:()=>C(!1),pause:()=>E.pause(),resume:()=>E.resume(),stop:()=>E.stop(),next:()=>E.next(),previous:()=>E.previous(),jumpTo:e=>E.jumpTo(e),pickedCount:t.length}}function vB({b:e,picked:t,enabled:n,generateAll:r,onGenerated:i}){let{api:a}=G(),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),u=gB(t),d=u.filter(e=>!e.about).length,f=u.length-d,p=r?.running===!0,m=async()=>{if(a.generateChatAbouts){s(!0),l(null);try{i((await a.generateChatAbouts({sessionIds:u.map(e=>e.sessionId)})).generateAll)}catch(e){l(mB(e))}finally{s(!1)}}},h=e.busy;return(0,W.jsxs)(`section`,{className:`space-y-2 rounded-md border border-border px-3 py-2`,"data-testid":`briefing-panel`,"aria-label":`Listen to the picked chats`,children:[(0,W.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Listen to the picked chats`}),(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Tick chats below, then Play: each chat’s name, then its about, one after another. Another language is translated once by `,Mu.label,` on your OonaCode credits and kept, so playing it again costs nothing.`]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,W.jsx)(Wy,{label:`Language`,children:(0,W.jsx)(`select`,{"aria-label":`Language`,className:Gy,value:e.lang.code,disabled:h,onChange:t=>e.update({language:t.target.value}),"data-testid":`briefing-language`,children:Au.map(e=>(0,W.jsx)(`option`,{value:e.code,children:e.name===e.native?e.name:`${e.name} — ${e.native}`},e.code))})}),e.voicesLoading?(0,W.jsx)(`p`,{className:`px-1 py-2 text-xs text-fg-muted`,"data-testid":`briefing-voices-loading`,children:`Looking for this PC’s voices…`}):e.options.length>0?(0,W.jsx)(Wy,{label:`Voice`,children:(0,W.jsx)(`select`,{"aria-label":`Voice`,className:Gy,value:e.voice?.key??``,disabled:h,onChange:t=>e.update({localVoice:{...e.prefs.localVoice,[e.lang.code]:t.target.value}}),"data-testid":`briefing-voice`,children:e.options.map(e=>(0,W.jsx)(`option`,{value:e.key,children:e.label},e.key))})}):(0,W.jsx)(`p`,{className:`rounded-md border border-border bg-surface-2 px-2 py-1.5 text-xs text-fg-muted sm:col-span-2`,"data-testid":`briefing-no-voice`,children:Nz(e.lang,e.desktop,e.platform,e.espeakMissing)}),(0,W.jsx)(Wy,{label:`Speed ×${e.prefs.speed.toFixed(2)}`,children:(0,W.jsx)(`input`,{"aria-label":`Speed`,type:`range`,min:Pu.speed.min,max:Pu.speed.max,step:.05,value:e.prefs.speed,disabled:h,onChange:t=>e.update({speed:Number(t.target.value)})})})]}),e.plan&&t.length>0?(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`briefing-cost`,children:[ku(e.plan,e.lang.name),e.plan.needed>0?` — paid once, then kept.`:``]}):null,e.confirming&&e.plan?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-warn/50 bg-warn-soft px-2 py-1.5 text-xs text-fg`,role:`alert`,"data-testid":`briefing-confirm`,children:[(0,W.jsxs)(`p`,{className:`basis-full`,children:[`Before playing: `,ku(e.plan,e.lang.name),` — paid once from your OonaCode credits, then kept.`]}),(0,W.jsx)(J,{size:`sm`,variant:`primary`,onClick:e.start,"data-testid":`briefing-confirm-play`,children:`Translate and play`}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:e.cancelConfirm,children:`Cancel`})]}):null,u.length>0&&a.generateChatAbouts?(0,W.jsxs)(`div`,{className:`space-y-1.5 text-xs`,"data-testid":`briefing-need-about`,children:[(0,W.jsx)(`p`,{className:`text-fg-muted`,children:eB(d,f)}),(0,W.jsxs)(J,{size:`sm`,onClick:()=>void m(),busy:o,disabled:!n||p||e.busy,title:n?void 0:`Chat abouts are off — turn them on above.`,"data-testid":`briefing-write-first`,children:[(0,W.jsx)(q.Refresh,{className:`h-3 w-3`}),` Write abouts for these first`]})]}):null,c?(0,W.jsx)(`p`,{className:`text-xs text-danger`,"data-testid":`briefing-write-error`,children:c}):null]})}function yB({b:e}){let t=e.state,n=t.index>=0?` (${t.index+1} of ${t.total})`:``,r=null;return t.status===`preparing`?r=`Now: ${t.title??``}${n} — ${e.lang.code===`en`?`getting ready…`:`translating…`}`:t.status===`speaking`?r=`Now: ${t.title??``}${n}`:t.status===`paused`?r=`Paused: ${t.title??``}${n}`:t.status===`done`?r=`Finished — ${t.total} chat${t.total===1?``:`s`} read.`:t.status===`stopped`?r=`Stopped.`:t.status===`error`&&(r=t.error),(0,W.jsxs)(W.Fragment,{children:[r?(0,W.jsx)(`p`,{className:U(`mr-auto min-w-0 basis-full truncate text-xs sm:basis-auto sm:flex-1`,t.status===`error`?`text-danger`:`text-fg-muted`),title:r,"aria-live":`polite`,"data-testid":`briefing-now`,children:r}):null,e.active||t.status===`error`?(0,W.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[(0,W.jsx)(J,{size:`sm`,onClick:e.previous,disabled:t.status===`error`,"aria-label":`Previous chat`,title:`Previous chat`,"data-testid":`briefing-previous`,children:(0,W.jsx)(q.SkipBack,{className:`h-3.5 w-3.5`})}),t.status===`paused`||t.status===`error`?(0,W.jsxs)(J,{size:`sm`,variant:`primary`,onClick:e.resume,"data-testid":`briefing-resume`,children:[(0,W.jsx)(q.Play,{className:`h-3.5 w-3.5`}),` `,t.status===`error`?`Try again`:`Resume`]}):(0,W.jsxs)(J,{size:`sm`,onClick:e.pause,"data-testid":`briefing-pause`,children:[(0,W.jsx)(q.Pause,{className:`h-3.5 w-3.5`}),` Pause`]}),(0,W.jsxs)(J,{size:`sm`,onClick:e.stop,"data-testid":`briefing-stop`,children:[(0,W.jsx)(q.Stop,{className:`h-3.5 w-3.5`}),` Stop`]}),(0,W.jsx)(J,{size:`sm`,onClick:e.next,disabled:t.status===`error`,"aria-label":`Next chat`,title:`Next chat`,"data-testid":`briefing-next`,children:(0,W.jsx)(q.SkipForward,{className:`h-3.5 w-3.5`})})]}):(0,W.jsxs)(J,{variant:`primary`,onClick:e.play,disabled:e.pickedCount===0||e.voice===null||e.voicesLoading,title:e.pickedCount===0?`Tick the chats to hear first`:void 0,"data-testid":`briefing-play`,children:[(0,W.jsx)(q.Play,{className:`h-4 w-4`}),` Play `,e.pickedCount,` picked`]})]})}function bB({open:e,onClose:t}){let{state:n,actions:r}=G(),i=n.chatAboutsChange,[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(!1),S=(0,v.useRef)(-1),[C,w]=(0,v.useState)(()=>Yz()),[T,E]=(0,v.useState)(()=>new Set),[D,O]=(0,v.useState)(()=>Date.now()),k=(0,v.useCallback)(async()=>{let e=await r.listChatAbouts();if(e===`unsupported`){c(!0);return}if(e===null){u(!0);return}c(!1),u(!1),o(e),f(e.generateAll)},[r]);(0,v.useEffect)(()=>{e&&(S.current=i.seq,O(Date.now()),k())},[e]);let A=e=>{w(t=>{let n={...t,...e};return Xz(n),n}),O(Date.now())};(0,v.useEffect)(()=>{!e||i.seq===S.current||(S.current=i.seq,i.generateAll!==void 0&&f(i.generateAll),k())},[e,i,k]);let j=n.settings?.chatAboutEnabled??a?.settings.enabled??Kl.enabled,M=async e=>{x(!0);try{await r.saveSettings({chatAboutEnabled:e})}finally{x(!1)}k()},ee=async()=>{g(!0);try{let e=await r.generateAllChatAbouts();e&&f(e.generateAll)}finally{g(!1)}},N=async()=>{y(!0);try{let e=await r.stopGenerateAllChatAbouts();e&&f(e.generateAll)}finally{y(!1)}},P=(0,v.useMemo)(()=>wu(C.range,D,{from:C.from,to:C.to}),[C,D]),F=(0,v.useMemo)(()=>{let e=(a?.chats??[]).filter(e=>Tu(e.updatedAt,P)),t=e=>{let t=Date.parse(e.updatedAt);return Number.isFinite(t)?t:0};return[...e].sort((e,n)=>t(n)-t(e))},[a,P]),I=(0,v.useMemo)(()=>{let e=p.trim().toLowerCase();return e?F.filter(t=>t.title.toLowerCase().includes(e)||(t.about??``).toLowerCase().includes(e)):F},[F,p]),te=(0,v.useMemo)(()=>I.map(e=>e.sessionId),[I]),ne=te.join(`,`);(0,v.useEffect)(()=>{E(e=>$z(e,te))},[ne]);let re=(0,v.useMemo)(()=>I.filter(e=>T.has(e.sessionId)),[I,T]),L=Zz(te,T),ie=(0,v.useRef)(null);(0,v.useEffect)(()=>{ie.current&&(ie.current.indeterminate=L===`some`)});let R=_B({open:e,picked:re}),ae=R.active||R.state.status===`error`,oe=(0,v.useMemo)(()=>new Set(R.state.playlist),[R.state.playlist]),se=ae?R.state.sessionId:null,ce=e=>E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),le=xu.find(e=>e.id===C.range)?.label??``,ue=(0,v.useCallback)(e=>n.sessions.find(t=>t.id===e)?.entryCount??null,[n.sessions]),de=a?mu(a.totals):null,fe=d?.running===!0;return(0,W.jsxs)(Ky,{open:e,title:`What your chats are about`,onClose:t,wide:!0,footer:(0,W.jsxs)(W.Fragment,{children:[a!==null&&!s?(0,W.jsx)(yB,{b:R}):null,(0,W.jsx)(J,{variant:`ghost`,onClick:t,children:`Close`})]}),children:[(0,W.jsxs)(`p`,{className:`mb-3 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,W.jsx)(`span`,{className:`min-w-0`,children:`A short note per chat on this PC saying what it works on, so your other chats can tell which one to ask.`}),(0,W.jsx)(Hy,{label:`What your chats are about`,details:(0,W.jsx)(Uy,{items:[...yu.what,...yu.when,...yu.who,...yu.yours,...yu.where]})})]}),s?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-unsupported`,children:`OonaCode on this PC is too old for chat abouts. Update it, then open this window again.`}):a===null?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-loading`,children:l?`Could not read the abouts from this PC right now. They show here as soon as it answers.`:`Loading…`}):(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsx)(`div`,{className:`rounded-md border border-border px-3`,children:(0,W.jsx)(qy,{label:`Write an about for every chat`,hint:j?`On: each chat’s housekeeper model writes its about in the background.`:`Off: nothing is written and nothing is spent. Regenerate and “Generate for all chats now” are unavailable.`,details:[yu.switch,...yu.who],checked:j,disabled:b,onChange:e=>void M(e),testId:`chat-abouts-switch`})}),de?(0,W.jsxs)(`div`,{className:`text-xs text-fg-muted`,"data-testid":`chat-abouts-totals`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:`All about calls so far: `}),(0,W.jsx)(`span`,{"data-testid":`chat-abouts-totals-line`,children:de.line}),de.unpriced?(0,W.jsx)(`span`,{className:`block text-fg-faint`,"data-testid":`chat-abouts-totals-unpriced`,children:de.unpriced}):null]}):null,(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsxs)(J,{size:`sm`,variant:`primary`,onClick:()=>void ee(),busy:h,disabled:!j||fe,title:j?yu.generateAll:yu.regenerateOff,"data-testid":`chat-abouts-generate-all`,children:[(0,W.jsx)(q.Refresh,{className:`h-3 w-3`}),` Generate for all chats now`]}),(0,W.jsx)(Hy,{label:`Generate for all chats now`,details:yu.generateAll})]}),fe?(0,W.jsxs)(J,{size:`sm`,variant:`danger`,onClick:()=>void N(),busy:_,title:yu.stop,"data-testid":`chat-abouts-stop`,children:[(0,W.jsx)(q.Stop,{className:`h-3 w-3`}),` Stop`]}):null]}),d?(0,W.jsx)(xB,{g:d}):null,(0,W.jsx)(vB,{b:R,picked:re,enabled:j,generateAll:d,onGenerated:f}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,W.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`Last active`,(0,W.jsx)(`select`,{"aria-label":`Last active`,className:U(Gy,`text-xs`),value:C.range,onChange:e=>A({range:e.target.value}),"data-testid":`chat-abouts-range`,children:xu.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),C.range===`custom`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`From`,(0,W.jsx)(`input`,{type:`date`,"aria-label":`From`,className:U(X,`text-xs`),value:C.from,onChange:e=>A({from:e.target.value}),"data-testid":`chat-abouts-from`})]}),(0,W.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`To`,(0,W.jsx)(`input`,{type:`date`,"aria-label":`To`,className:U(X,`text-xs`),value:C.to,onChange:e=>A({to:e.target.value}),"data-testid":`chat-abouts-to`})]})]}):null,(0,W.jsx)(`input`,{className:U(X,`min-w-[10rem] flex-1 basis-40 text-xs`),type:`search`,value:p,onChange:e=>m(e.target.value),placeholder:`Find a chat by its title or its about`,"aria-label":`Find a chat by its title or its about`,"data-testid":`chat-abouts-filter`})]}),I.length>0?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,W.jsxs)(`label`,{className:`inline-flex items-center gap-2 font-medium text-fg`,children:[(0,W.jsx)(`input`,{ref:ie,type:`checkbox`,checked:L===`all`,"aria-checked":L===`some`?`mixed`:L===`all`,onChange:()=>E(e=>Qz(te,e)),"data-testid":`chat-abouts-select-all`}),`Select all`]}),(0,W.jsxs)(`span`,{className:`text-fg-muted`,"data-testid":`chat-abouts-count`,children:[I.length,` chat`,I.length===1?``:`s`,re.length>0?` · ${re.length} picked`:``]})]}):null,a.chats.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-empty`,children:`No chats on this PC yet.`}):I.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-no-match`,children:p.trim()?`No chat matches “${p.trim()}”${C.range===`all`?``:` in ${le.toLowerCase()}`}.`:`No chat was active in ${C.range===`custom`?`that range`:le.toLowerCase()}.`}):(0,W.jsx)(`ul`,{className:`space-y-2`,"data-testid":`chat-abouts-list`,children:I.map(e=>(0,W.jsx)(SB,{row:e,enabled:j,entryCount:ue(e.sessionId),checked:T.has(e.sessionId),onToggle:()=>ce(e.sessionId),playing:se===e.sessionId,onJump:ae&&oe.has(e.sessionId)?()=>R.jumpTo(e.sessionId):null,onOpen:()=>{r.selectSession(e.sessionId)}},e.sessionId))})]})]})}function xB({g:e}){let t=e.total>0?Math.round(Math.min(e.done,e.total)/e.total*100):100;return(0,W.jsxs)(`div`,{className:`space-y-1 text-xs`,"data-testid":`chat-abouts-progress`,children:[(0,W.jsx)(`div`,{className:`text-fg-muted`,"data-testid":`chat-abouts-progress-line`,children:gu(e)}),(0,W.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`Generate for all chats now`,"aria-valuemin":0,"aria-valuemax":e.total,"aria-valuenow":e.done,children:(0,W.jsx)(`div`,{className:U(`h-full rounded-full`,e.running?`bg-accent`:`bg-fg-faint`),style:{width:`${t}%`}})}),!e.running&&e.stoppedReason?(0,W.jsxs)(`div`,{className:`text-warn`,"data-testid":`chat-abouts-stopped-reason`,children:[`Stopped: `,e.stoppedReason]}):null]})}function SB({row:e,enabled:t,entryCount:n,checked:r,onToggle:i,playing:a,onJump:o,onOpen:s}){let c=e.title.trim()||`Untitled chat`,l=lu(e),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>{a&&u.current?.scrollIntoView?.({block:`nearest`})},[a]),(0,W.jsxs)(`li`,{ref:u,className:U(`rounded-md border px-3 py-2 text-xs`,a?`border-accent bg-accent/10`:`border-border`,o?`cursor-pointer hover:border-accent`:``),onClick:o??void 0,title:o&&!a?`Play from this chat`:void 0,"aria-current":a?`true`:void 0,"data-testid":`chat-about-row-${e.sessionId}`,"data-playing":a?`true`:void 0,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`shrink-0`,checked:r,onChange:i,onClick:e=>e.stopPropagation(),"aria-label":`Pick ${c}`,"data-testid":`chat-about-pick`}),a?(0,W.jsx)(q.Speaker,{className:`h-3.5 w-3.5 text-accent`,title:`Playing`}):null,(0,W.jsx)(`button`,{type:`button`,className:`min-w-0 max-w-full truncate text-left text-sm font-medium text-fg hover:text-accent hover:underline`,onClick:e=>{e.stopPropagation(),s()},title:`Open this chat`,"data-testid":`chat-about-open`,children:c}),e.source===`user`?(0,W.jsx)(`span`,{title:yu.yours[0],children:(0,W.jsx)(Z,{tone:`accent`,children:`yours`})}):null,e.stale&&e.about?(0,W.jsx)(`span`,{title:yu.stale,"data-testid":`chat-about-stale`,children:(0,W.jsx)(Z,{tone:`warn`,children:`stale`})}):null,e.pending?(0,W.jsx)(`span`,{"data-testid":`chat-about-pending`,children:(0,W.jsx)(Z,{tone:`accent`,children:`writing…`})}):null]}),e.about?(0,W.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-fg`,"data-testid":`chat-about-text`,children:e.about}):null,e.about&&e.stale?(0,W.jsx)(`p`,{className:`mt-0.5 text-warn`,"data-testid":`chat-about-stale-note`,children:`The chat has moved on since this about was written.`}):null,e.about?null:(0,W.jsxs)(`p`,{className:`mt-1 text-fg-muted`,"data-testid":`chat-about-missing`,children:[`No about yet. `,hu(e,{enabled:t,entryCount:n})]}),e.about&&e.lastError?(0,W.jsxs)(`p`,{className:`mt-0.5 text-danger`,"data-testid":`chat-about-error`,children:[`The last attempt failed: `,e.lastError]}):null,(0,W.jsxs)(`div`,{className:`mt-1 flex flex-wrap justify-between gap-x-3 gap-y-0.5 text-[11px] text-fg-faint`,children:[(0,W.jsxs)(`span`,{title:sg(e.updatedAt),"data-testid":`chat-about-active`,children:[`Active `,ag(e.updatedAt)]}),e.about&&e.aboutAt?(0,W.jsxs)(`span`,{title:sg(e.aboutAt),"data-testid":`chat-about-written`,children:[`Written `,ag(e.aboutAt),l?` by ${l}`:``]}):(0,W.jsx)(`span`,{}),(0,W.jsx)(`span`,{title:e.route?`Paid by ${uu[e.route]}`:void 0,"data-testid":`chat-about-spend`,children:pu(e.spend,e.route)})]})]})}function CB({open:e,onClose:t}){let{state:n,actions:r}=G(),i=n.assignProjectSessionId,a=i?n.sessions.find(e=>e.id===i)??null:null,o=i?n.drafts[i]??null:null,s=a?.projectId??o?.projectId??null,[c,l]=(0,v.useState)(s),[u,d]=(0,v.useState)(!1);(0,v.useEffect)(()=>{e&&l(s)},[e,s]);let f=a?.status===`running`||a?.status===`waiting_permission`,p=fg(a?pg(a):o?.title??`New chat`);async function m(){if(i){d(!0);try{await r.setSessionProject(i,c)&&t()}finally{d(!1)}}}return(0,W.jsxs)(Ky,{open:e,title:`Move “${p}” to a project`,onClose:t,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{variant:`ghost`,onClick:()=>{t(),r.openDialog(`projects`)},children:`Manage projects…`}),(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(J,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,W.jsx)(J,{variant:`primary`,onClick:m,disabled:u||c===s,"data-testid":`assign-project-apply`,children:`Apply`})]}),children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5`,role:`radiogroup`,"aria-label":`Project`,children:[(0,W.jsx)(wB,{selected:c===null,onSelect:()=>l(null),label:`No project`,testId:`assign-project-none`}),n.vaultProjects.map(e=>(0,W.jsx)(wB,{selected:c===e.id,onSelect:()=>l(e.id),label:e.name,hint:e.instructions.trim()?`has instructions`:void 0,testId:`assign-project-${e.id}`},e.id)),n.vaultProjects.length===0?(0,W.jsxs)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:[`No projects yet — create one under `,(0,W.jsx)(`em`,{children:`Manage projects…`}),`.`]}):null]}),f?(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,"data-testid":`assign-project-busy`,children:`This chat is mid-turn — it moves now and the turn is left alone. The project's instructions reach the agent at your next message.`}):(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:`The project's instructions reach the agent on the chat's next start — nothing in the conversation is lost.`})]})}function wB({selected:e,onSelect:t,label:n,hint:r,testId:i}){return(0,W.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e,onClick:t,className:U(`flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,e?`bg-accent-soft text-fg`:`hover:bg-surface-2 text-fg`),"data-testid":i,children:[(0,W.jsx)(`span`,{className:U(`inline-block h-3 w-3 rounded-full border`,e?`border-accent bg-accent`:`border-border`)}),(0,W.jsx)(q.Project,{className:`w-3.5 h-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),r?(0,W.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:r}):null]})}var TB=`Install Google’s agy`,EB=`Setting up Google’s agy for you — OonaCode downloads Google’s own release and checks its checksum (about 200 MB, nothing is bundled in OonaCode).`,DB=`OonaCode downloads Google’s own agy release (about 200 MB) and checks its checksum before it uses it. Nothing from Google is bundled inside OonaCode.`,OB=`Sign in with Google`,kB=`This PC’s OonaCode is too old to run chats on Google’s agy — update it from the title bar.`,AB=`Kept on this PC only, in memory: it is gone when OonaCode stops, and it is never synced or sent anywhere.`,jB=new Set([`loadCodeAssist`,`fetchAdminControls`,`retrieveUserQuotaSummary`,`fetchUserInfo`,`fetchAvailableModels`,`listExperiments`,`writeTrajectoryAcls`,`recordTrajectoryAnalytics`]);function MB(e){return e.kind===`tunnel`||e.method!==null&&jB.has(e.method)}function NB(e){let t=[],n=[];for(let r of e)(MB(r)?n:t).push(r);return{main:t,background:n}}function PB(e){if(e.kind===`tunnel`)return{title:e.host??`tunnel`,detail:null};let t=[e.model,e.requestType===`checkpoint`?`checkpoint`:null].filter(e=>!!e).join(` · `);return{title:e.method??`Code Assist call`,detail:t||null}}function FB(e){let{title:t,detail:n}=PB(e);return n?`${t} · ${n}`:t}function IB(e){let t=e.denied||e.error!==null||e.status!==null&&e.status>=400?`danger`:`neutral`;return e.denied?{text:`denied`,tone:t}:e.status===null?e.error===null?{text:`pending`,tone:t}:{text:`error`,tone:t}:{text:String(e.status),tone:t}}var LB=e=>e.toLocaleString(`en-US`);function RB(e){if(!e)return null;let t=e.cached>0?` (${LB(e.cached)} cached)`:``;return`in ${LB(e.input)}${t} · out ${LB(e.output)}`}function zB(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``}function BB(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function VB(e){switch(e){case`ready`:return{label:`Ready`,tone:`ok`};case`not_installed`:return{label:`agy is not installed`,tone:`warn`};case`not_signed_in`:return{label:`Not signed in to agy`,tone:`warn`};default:return{label:`agy did not answer`,tone:`danger`}}}function HB(e){return e.newerThanTested?`This agy is newer than the version OonaCode was tested with (${e.testedVersion}). It usually keeps working; if chats on it start failing, look for an OonaCode update.`:null}function UB(e){let t=e.remainingPercent,n=t!==null&&Number.isFinite(t),r=sg(e.resetsAt);return{remaining:n?`${Math.round(Math.min(100,Math.max(0,t)))}% left`:`unknown`,tone:rc(t),resets:r?`resets ${r}`:null}}var WB=1e3,GB=2e3;function KB(e){if(!e)return null;if(e.install.state===`working`)return WB;switch(e.login.phase){case`starting`:case`verifying`:return WB;case`awaiting_code`:return GB;default:return null}}function qB(e){if(!e)return!1;if(e.install.state===`working`)return!0;let t=e.login.phase;return t===`starting`||t===`awaiting_code`||t===`verifying`}function JB(e){switch(e){case`manifest`:return`Looking up Google’s latest release…`;case`download`:return`Downloading agy…`;case`verify`:return`Checking the download…`;case`place`:return`Finishing up…`;default:return`Starting the install…`}}function YB(e){let{received:t,total:n}=e;return n===null||!Number.isFinite(n)||n<=0?null:Math.min(100,Math.max(0,Math.floor(t/n*100)))}function XB(e){let{received:t,total:n}=e;return n!==null&&n>0?`${Rj(t)} of ${Rj(n)}`:t>0?Rj(t):null}function ZB(e){if(!e)return null;try{return new URL(e).protocol===`https:`?e:null}catch{return null}}function QB(e,t){return t?e.split(t).join(`…`):e}function $B(e,t){return e?`Status…`:t?t.state===`not_installed`?t.install.supported?`Install…`:`Status…`:t.state===`not_signed_in`?`Sign in…`:`Status…`:`Set up…`}var eV=15,tV=2e4,nV=5e3,rV=null;function iV(e){let[t,n]=(0,v.useState)(()=>Date.now());return(0,v.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),t}function aV({install:e,busy:t,offer:n,onInstall:r,onCancel:i}){if(e.state===`working`){let n=YB(e),r=XB(e);return(0,W.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`agy-install`,"data-install-state":`working`,children:[(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-install-statement`,children:EB}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg`,role:`status`,"data-testid":`agy-install-phase`,"data-phase":e.phase??void 0,children:[(0,W.jsx)(q.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsxs)(`span`,{className:`min-w-0`,children:[JB(e.phase),e.version?` (agy ${e.version})`:``]})]}),(0,W.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`Installing agy`,"aria-valuemin":0,"aria-valuemax":100,...n===null?{}:{"aria-valuenow":n},"data-indeterminate":n===null?`true`:void 0,"data-testid":`agy-install-bar`,children:(0,W.jsx)(`div`,{className:U(`h-full rounded-full bg-accent`,n===null?`w-1/3 animate-pulse`:void 0),style:n===null?void 0:{width:`${n}%`}})}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[11px] text-fg-faint`,"data-testid":`agy-install-bytes`,children:r??``}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,disabled:t,onClick:i,"data-testid":`agy-install-cancel`,children:`Cancel`})]})]})}return e.supported?e.state===`idle`&&!n?(0,W.jsx)(`div`,{className:`space-y-2`,"data-testid":`agy-install`,"data-install-state":`starting`,children:(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-install-statement`,children:EB})}):(0,W.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-install`,"data-install-state":e.state,children:[e.state===`failed`?(0,W.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,"data-testid":`agy-install-failed`,children:e.error??`The install did not finish.`}):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-install-explanation`,children:DB}),(0,W.jsxs)(J,{variant:`primary`,busy:t,disabled:t,onClick:r,"data-testid":e.state===`failed`?`agy-install-retry`:`agy-install-button`,children:[(0,W.jsx)(q.Download,{className:`h-4 w-4`}),` `,e.state===`failed`?`Try again`:TB]})]}):null}function oV({login:e,busy:t,onStart:n,onRestart:r,onCancel:i,onSubmit:a}){let[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),u=(0,v.useRef)(null);(0,v.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]),(0,v.useEffect)(()=>{e.phase!==`awaiting_code`&&s(``)},[e.phase]);let d=(0,v.useRef)(null),f=e.phase===`awaiting_code`,p=f?ZB(e.url):null,m=f&&e.expiresAt?Date.parse(e.expiresAt):NaN,h=Number.isFinite(m),g=iV(f&&h),_=h?Math.max(0,Math.ceil((m-g)/1e3)):null,y=_===0;(0,v.useEffect)(()=>{y&&s(``)},[y]);let b=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(e.phase===`starting`&&(b.current=!0),!f||!p||!e.startedAt||rV===e.startedAt)return;let t=h?Date.now()-(m-6e4):1/0;if(!(!b.current&&t>nV)){rV=e.startedAt;try{kR(p)}catch{}}},[e.phase,p,e.startedAt]),(0,v.useEffect)(()=>{f&&LP(d.current)},[f]);let[x,S]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(e.phase!==`verifying`){S(!1);return}let t=setTimeout(()=>S(!0),tV);return()=>clearTimeout(t)},[e.phase]);let C=o.trim(),w=im(C),T=()=>{!w||t||(s(``),a(C))},E=()=>{p&&XM(p).then(e=>{e&&(l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),1500))})},D=(0,W.jsx)(J,{size:`sm`,variant:`ghost`,disabled:t,onClick:i,"data-testid":`agy-login-cancel`,children:`Cancel`});return(0,W.jsxs)(`div`,{ref:d,className:`space-y-2`,"data-testid":`agy-sign-in`,"data-login-phase":e.phase,children:[(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-sign-in-explanation`,children:rm}),e.phase===`starting`?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`agy-login-starting`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-fg`,role:`status`,children:[(0,W.jsx)(q.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),e.message??`Starting Google’s sign-in…`]}),(0,W.jsx)(`span`,{className:`flex-1`}),D]}):e.phase===`awaiting_code`?(0,W.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-awaiting`,children:[y?(0,W.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-expired`,children:[(0,W.jsx)(`div`,{className:`rounded-md border border-warn/40 bg-warn-soft px-3 py-2 text-xs text-warn`,role:`alert`,children:`Time ran out — Google’s agy only waits a minute. Press Sign in again.`}),(0,W.jsxs)(J,{variant:`primary`,busy:t,disabled:t,onClick:r,"data-testid":`agy-login-expired-restart`,children:[(0,W.jsx)(q.LogIn,{className:`h-4 w-4`}),` Sign in again`]})]}):(0,W.jsxs)(W.Fragment,{children:[e.message?(0,W.jsx)(`p`,{className:`text-xs text-fg`,children:e.message}):null,p?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsxs)(`a`,{className:`inline-flex items-center gap-1 text-xs font-medium text-accent underline`,href:p,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),kR(p)},"data-testid":`agy-login-link`,children:[(0,W.jsx)(q.ExternalLink,{className:`h-3.5 w-3.5`}),` Open Google’s sign-in page`]}),(0,W.jsxs)(J,{size:`sm`,onClick:E,"data-testid":`agy-login-copy-link`,children:[(0,W.jsx)(q.Copy,{className:`h-3.5 w-3.5`}),` `,c?`Copied`:`Copy link`]})]}):null,(0,W.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-fg`,children:[(0,W.jsxs)(`span`,{className:`flex items-baseline justify-between gap-2`,children:[`Code from Google`,_===null?null:(0,W.jsxs)(`span`,{role:`timer`,className:U(`font-normal tabular-nums`,_<eV?`font-medium text-warn`:`text-fg-faint`),"data-tone":_<eV?`warn`:`neutral`,"data-testid":`agy-login-countdown`,children:[_,` s left to finish`]})]}),(0,W.jsx)(`input`,{className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 font-mono text-xs text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`,type:`text`,value:o,placeholder:`Paste the code Google shows you`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,"data-1p-ignore":`true`,"data-lpignore":`true`,"data-form-type":`other`,"data-autofocus":!0,onChange:e=>s(e.target.value),onPaste:e=>{let n=e.clipboardData?.getData(`text`).trim()??``;im(n)&&(e.preventDefault(),!t&&(s(``),a(n)))},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},"data-testid":`agy-login-code`})]}),C&&!w?(0,W.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`agy-login-code-hint`,children:`Paste the code exactly as Google shows it — one line, no spaces.`}):null,(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(J,{variant:`primary`,size:`sm`,disabled:!w||t,onClick:T,"data-testid":`agy-login-continue`,children:`Continue`}),D]})]}),y?(0,W.jsx)(`div`,{className:`flex items-center gap-2`,children:D}):null]}):e.phase===`verifying`?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`agy-login-verifying`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-fg`,role:`status`,children:[(0,W.jsx)(q.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),e.message??`Checking the code with Google…`]}),(0,W.jsx)(`span`,{className:`flex-1`}),D,x?(0,W.jsx)(`p`,{className:`w-full text-[11px] text-fg-faint`,"data-testid":`agy-login-verifying-slow`,children:`Still waiting for Google…`}):null]}):e.phase===`failed`?(0,W.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-failed`,children:[(0,W.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:e.message??`The sign-in did not finish.`}),(0,W.jsxs)(J,{variant:`primary`,busy:t,disabled:t,onClick:n,"data-testid":`agy-sign-in-restart`,children:[(0,W.jsx)(q.LogIn,{className:`h-4 w-4`}),` Start again`]})]}):(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[e.phase===`done`&&e.message?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.message}):null,(0,W.jsxs)(J,{variant:`primary`,busy:t,disabled:t,onClick:n,"data-testid":`agy-sign-in-button`,children:[(0,W.jsx)(q.LogIn,{className:`h-4 w-4`}),` `,OB]})]})]})}var sV={ok:`bg-ok`,warn:`bg-warn`,danger:`bg-danger`,neutral:`bg-surface-3`},cV={ok:`text-ok`,warn:`text-warn`,danger:`text-danger`,neutral:`text-fg-muted`};function lV({label:e,testid:t,children:n}){return(0,W.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 py-0.5 text-xs`,children:[(0,W.jsx)(`dt`,{className:`shrink-0 text-fg-faint`,children:e}),(0,W.jsx)(`dd`,{className:`min-w-0 text-right font-medium text-fg`,"data-testid":t,children:n})]})}function uV({definition:e}){let{api:t,socket:n}=G(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(0),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),h=(0,v.useRef)(!0),g=(0,v.useRef)(0),_=(0,v.useRef)(0);(0,v.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let y=(0,v.useCallback)(async(e,n=!1)=>{let r=++g.current;if(!t.getAgyStatus){o(!0);return}_.current+=1,n||u(e=>e+1);try{let n=await t.getAgyStatus(e?{refresh:!0}:void 0);if(!h.current||r!==g.current)return;i(n),c(null),o(!1)}catch(e){if(!h.current||r!==g.current)return;ym(e)?o(!0):c(mg(e))}finally{--_.current,!n&&h.current&&u(e=>e-1)}},[t]),b=(0,v.useCallback)(async(e,t,n=``)=>{g.current+=1,f(e),m(null);try{let e=await t();return h.current?(g.current+=1,i(e),c(null),o(!1),e):null}catch(e){return h.current&&(ym(e)?o(!0):(m(QB(mg(e),n)),y(!1,!0))),null}finally{h.current&&f(null)}},[y]);(0,v.useEffect)(()=>{y(!1)},[y]);let[x,S]=(0,v.useState)(!1),C=(0,v.useCallback)(async()=>{if(!t.agyInstall){o(!0);return}S(!0),await b(`install`,()=>t.agyInstall())},[t,b]),w=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!(w.current||!r||!t.agyInstall)){if(r.install.state!==`idle`){w.current=!0;return}r.state!==`not_installed`||!r.install.supported||(w.current=!0,C())}},[r,t,C]);let T=KB(r);(0,v.useEffect)(()=>{if(T===null)return;let e=setInterval(()=>{_.current===0&&y(!1,!0)},T);return()=>clearInterval(e)},[T,y]),(0,v.useEffect)(()=>n.on(`account_changed`,e=>{e.reason===`provider`&&y(!1,!0)}),[n,y]);let E=As(e);if(a)return(0,W.jsx)(`div`,{className:`rounded-md border border-warn/40 bg-warn-soft px-3 py-2 text-xs text-warn`,"data-testid":`agy-unsupported`,children:kB});let D=r===null&&s===null,O=l>0,k=qB(r),A=r?.install.state===`working`,j=(0,W.jsx)(J,{variant:`primary`,size:`sm`,busy:O||D,disabled:O||D||k,onClick:()=>void y(!0),"data-testid":`agy-check-again`,children:O||D?`Checking…`:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q.Refresh,{className:`h-3.5 w-3.5`}),` Check again`]})}),M=r?A?{label:`Installing agy…`,tone:`accent`}:VB(r.state):null;return(0,W.jsxs)(`div`,{className:`space-y-3`,"data-testid":`agy-card`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,W.jsx)(Z,{tone:`ok`,children:E.badge}),(0,W.jsx)(Z,{children:e.kind})]}),(0,W.jsx)(`div`,{className:`rounded-md border border-ok/40 bg-ok-soft px-3 py-2 text-xs text-ok`,"data-testid":`agy-route`,children:E.detail}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[M?(0,W.jsx)(`span`,{"data-testid":`agy-state`,"data-state":r?.state,children:(0,W.jsx)(Z,{tone:M.tone,children:M.label})}):D?(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,"data-testid":`agy-checking`,children:[(0,W.jsx)(q.Spinner,{className:`h-3.5 w-3.5`}),` Asking agy…`]}):null,(0,W.jsx)(`span`,{className:`flex-1`}),j]}),O&&r?(0,W.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`agy-busy-note`,children:`Asking agy again — this takes a few seconds.`}):null,s?(0,W.jsxs)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,"data-testid":`agy-failed`,children:[`The host could not check agy: `,s]}):null,r?(0,W.jsxs)(W.Fragment,{children:[r.state!==`ready`&&r.message&&!k?(0,W.jsx)(`p`,{className:`text-xs text-fg`,"data-testid":`agy-message`,children:r.message}):null,r.state===`not_installed`?(0,W.jsx)(aV,{install:r.install,busy:d===`install`||d===`cancel_install`,offer:!t.agyInstall||x&&d!==`install`,onInstall:()=>{w.current=!0,C()},onCancel:()=>{w.current=!0,S(!0),t.cancelAgyInstall&&b(`cancel_install`,()=>t.cancelAgyInstall())}}):null,r.state===`not_signed_in`?(0,W.jsx)(oV,{login:r.login,busy:d===`login`||d===`cancel_login`||d===`code`,onStart:()=>{t.agyLogin?b(`login`,()=>t.agyLogin()):o(!0)},onRestart:()=>{(async()=>{t.cancelAgyLogin&&await b(`cancel_login`,()=>t.cancelAgyLogin()),t.agyLogin?await b(`login`,()=>t.agyLogin()):o(!0)})()},onCancel:()=>{t.cancelAgyLogin&&b(`cancel_login`,()=>t.cancelAgyLogin())},onSubmit:e=>{t.submitAgyLoginCode?b(`code`,()=>t.submitAgyLoginCode(e),e):o(!0)}}):null,p?(0,W.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,"data-testid":`agy-action-error`,children:p}):null,(0,W.jsxs)(`dl`,{className:`rounded-md border border-border px-3 py-1.5`,"data-testid":`agy-facts`,children:[(0,W.jsx)(lV,{label:`Installed`,testid:`agy-installed`,children:r.installed?`Yes`:`No`}),r.path?(0,W.jsx)(lV,{label:`Path`,testid:`agy-path`,children:(0,W.jsx)(`span`,{className:`break-all font-mono text-[11px]`,children:r.path})}):null,r.version?(0,W.jsx)(lV,{label:`Version`,testid:`agy-version`,children:r.version}):null,(0,W.jsx)(lV,{label:`Signed in`,testid:`agy-signed-in`,children:r.signedIn===null?r.installed?`Unknown`:`—`:r.signedIn?`Yes`:`No`}),(0,W.jsx)(lV,{label:`Checked`,testid:`agy-checked`,children:(0,W.jsx)(`span`,{title:sg(r.checkedAt),children:ag(r.checkedAt)})})]}),HB(r)?(0,W.jsxs)(`p`,{className:`flex items-start gap-1.5 rounded-md bg-surface-2 px-3 py-2 text-xs text-fg-muted`,"data-testid":`agy-newer-note`,children:[(0,W.jsx)(q.Info,{className:`mt-px h-3.5 w-3.5 shrink-0`}),HB(r)]}):null,r.models.length>0?(0,W.jsxs)(`div`,{"data-testid":`agy-models`,children:[(0,W.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-muted`,children:`Models agy offers`}),(0,W.jsx)(`ul`,{className:`space-y-0.5`,children:r.models.map(e=>(0,W.jsxs)(`li`,{className:`flex items-baseline justify-between gap-3 text-xs`,"data-testid":`agy-model-${e.id}`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.displayName}),(0,W.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-fg-faint`,children:e.id})]},e.id))})]}):null,r.usage.length>0?(0,W.jsxs)(`div`,{"data-testid":`agy-usage`,children:[(0,W.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-muted`,children:`Your plan’s usage`}),(0,W.jsx)(`ul`,{className:`space-y-2`,children:r.usage.map((e,t)=>{let n=UB(e),r=e.remainingPercent;return(0,W.jsxs)(`li`,{"data-testid":`agy-usage-row-${t}`,children:[(0,W.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 truncate text-fg`,children:[e.group,` · `,e.window]}),(0,W.jsx)(`span`,{className:U(`shrink-0 font-medium`,cV[n.tone]),"data-tone":n.tone,"data-testid":`agy-usage-remaining-${t}`,children:n.remaining})]}),(0,W.jsx)(`div`,{className:`mt-0.5 h-1.5 w-full overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`${e.group} ${e.window}: ${n.remaining}`,"aria-valuemin":0,"aria-valuemax":100,...r!==null&&Number.isFinite(r)?{"aria-valuenow":Math.round(r)}:{},children:(0,W.jsx)(`div`,{className:U(`h-full rounded-full`,sV[n.tone]),style:{width:`${r!==null&&Number.isFinite(r)?Math.min(100,Math.max(0,r)):0}%`}})}),n.resets?(0,W.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:n.resets}):null]},`${e.group}-${e.window}-${t}`)})})]}):null]}):null]})}function dV(e,t){let n=e.definition.displayName;return!t||t.id===`payg`||t.id===`api-key`?[`Sign in to the ${n} console.`,`Create an API key (or copy an existing one).`,`Paste it below — OonaCode encrypts it into your vault before it leaves this PC.`]:[`Open the ${n} console and pick the ${t.label} plan.`,t.notes??`Complete the provider’s subscription/token flow in the browser.`,`Copy the token it issues${t.keyFormat?` (looks like ${t.keyFormat})`:``} and paste it below.`]}function fV(e,t){let n=e.find(e=>e.definition.id===t);if(!n)return[];let r=n.definition.clientGroup??n.definition.id,i=e.find(e=>e.definition.id===r);return i?[i,...e.filter(e=>e.definition.clientGroup===r)]:[n]}function pV(e){let t=[];for(let n of e){let e=n.definition,r=Ts(e),i=e.credentialClass===`subscription`;if(r.length>1)for(let i of r)t.push({key:`${e.id}:${i.id}`,label:i.id===`token-plan`?`Subscription`:i.id===`payg`?`API`:i.label,provider:n,variantId:i.id,variant:i,isSubscription:!1,hasLoginFlow:!1,loginKind:null,keyFormat:i.keyFormat??e.keyFormat});else t.push({key:e.id,label:e.recordLabel??(i?`Subscription`:`API`),provider:n,variantId:r[0]?.id??null,variant:r[0]??null,isSubscription:i,hasLoginFlow:i&&e.route===`direct`,loginKind:i&&e.route===`direct`?e.subscriptionLogin?`oauth`:`claude`:null,keyFormat:r[0]?.keyFormat??e.keyFormat})}return t}function mV(e){let t=(e.provider.credentials??[]).filter(e=>e.class!==`none`);return(e.variantId?t.filter(t=>(t.variantId??`payg`)===e.variantId):t).slice(0,1)}function hV({open:e,providerId:t,onClose:n}){let{state:r,actions:i}=G(),a=(0,v.useMemo)(()=>t?fV(r.providers,t):[],[r.providers,t]),o=(0,v.useMemo)(()=>pV(a),[a]),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),b=o.find(e=>e.key===s)??o[0]??null;if((0,v.useEffect)(()=>{if(!e)return;let n=o.find(e=>e.provider.definition.id===t);c((n??o[0])?.key??``),u(``),m(``),y(null)},[e,t,o]),(0,v.useEffect)(()=>{if(!e||!b)return;let t=b.provider.definition;f(t.userBaseUrl?b.variant?.baseUrl??t.baseUrl:``)},[e,b,b?.key]),!b)return null;let x=b.provider.definition,S=a[0]?.definition?.displayName??x.displayName;if(x.engine===`agy`)return(0,W.jsx)(Ky,{open:e,title:S,onClose:n,footer:(0,W.jsx)(J,{onClick:n,children:`Close`}),children:(0,W.jsx)(uV,{definition:x})});let C=mV(b),w=a.some(e=>(e.credentials??[]).some(e=>e.class!==`none`)),T=x.credentialClass!==`none`,E=As(x,{credentialClass:b.isSubscription?`subscription`:x.credentialClass,...x.userBaseUrl&&d.trim()?{baseUrl:d.trim()}:{}}),D=!h&&(!T||l.trim().length>0),O=async()=>{g(!0),y(null);try{if(!T){await i.setActiveProvider(x.id),n();return}let e=await i.probeCredential(x.id,{secret:l.trim(),variantId:b.variantId,...x.userBaseUrl&&d.trim()?{baseUrl:d.trim()}:{}});if(!e.ok){y(e.error??`${S} rejected this key — check it and try again.`);return}let t={};b.variantId&&(t.variant=b.variantId),x.userBaseUrl&&d.trim()&&(t.baseUrl=d.trim()),await i.addCredential({class:b.isSubscription?`subscription`:`api_key`,providerId:x.id,secret:l.trim(),...p.trim()?{label:p.trim()}:{},...Object.keys(t).length>0?{meta:t}:{}})&&(u(``),n())}finally{g(!1)}};return(0,W.jsx)(Ky,{open:e,title:`${w?`Manage`:`Connect`} ${S}`,onClose:n,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{onClick:n,children:`Cancel`}),b.loginKind===`oauth`?(0,W.jsxs)(J,{onClick:()=>i.openOauthLogin(b.provider.definition.id),"data-testid":`connect-oauth-signin`,children:[(0,W.jsx)(q.LogIn,{className:`w-4 h-4`}),` `,b.provider.definition.subscriptionLogin?.signInLabel??`Sign in instead`]}):b.loginKind===`claude`?(0,W.jsxs)(J,{onClick:()=>i.openClaudeLogin(null),"data-testid":`connect-claude-signin`,children:[(0,W.jsx)(q.LogIn,{className:`w-4 h-4`}),` Sign in instead`]}):null,(0,W.jsx)(J,{variant:`primary`,busy:h,disabled:!D,onClick:()=>void O(),children:h?`Checking…`:T?`Save key`:`Use this provider`})]}),children:(0,W.jsxs)(`div`,{className:`space-y-3`,children:[o.length>1?(0,W.jsx)(`div`,{className:`flex gap-1 border-b border-border`,role:`tablist`,children:o.map(e=>{let t=mV(e)[0];return(0,W.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.key===b.key,"data-testid":`record-tab-${e.key}`,onClick:()=>c(e.key),className:e.key===b.key?`rounded-t-md border border-b-0 border-border bg-surface-2 px-3 py-1.5 text-sm font-medium`:`px-3 py-1.5 text-sm text-fg-muted hover:text-fg`,children:[e.label,t?(0,W.jsx)(`span`,{className:`ml-1.5 font-mono text-[11px] text-ok`,children:t.masked}):null]},e.key)})}):null,C.length>0?(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:`Connected`}),C.map(e=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border px-2.5 py-1.5`,"data-testid":`stored-credential-${e.id}`,children:[(0,W.jsx)(Z,{tone:e.class===`subscription`?`accent`:`ok`,children:b.label}),(0,W.jsx)(`span`,{className:`font-mono text-xs`,children:e.masked}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-fg-faint`,children:e.label}),(0,W.jsx)(J,{size:`sm`,onClick:()=>void i.testCredential(e.id),children:`Test`}),(0,W.jsx)(J,{size:`sm`,variant:`danger`,onClick:()=>void i.deleteCredential(e.id),children:`Remove`})]},e.id))]}):null,(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,W.jsx)(Z,{tone:E.viaGateway?`accent`:`ok`,children:E.badge}),(0,W.jsx)(Z,{children:x.kind}),b.keyFormat?(0,W.jsxs)(`span`,{className:`text-fg-faint`,children:[`key format `,b.keyFormat]}):null]}),(0,W.jsxs)(`div`,{className:E.viaGateway?`rounded-md border border-border bg-surface-2 px-3 py-2 text-xs text-fg-muted`:`rounded-md border border-ok/40 bg-ok-soft px-3 py-2 text-xs text-ok`,"data-testid":`connect-route`,children:[E.detail,T&&!E.viaGateway?` The key is stored in your zero-knowledge vault.`:null]}),T?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`ol`,{className:`ml-4 list-decimal space-y-1 text-xs text-fg-muted`,children:b.loginKind===`oauth`?[`Press “${b.provider.definition.subscriptionLogin?.signInLabel??`Sign in`}”: a short code opens in your browser, you approve it, and the subscription is stored by itself — nothing to paste.`,`The token refreshes on its own; sign in again only if the provider says it expired.`,`Or paste an access token below, if you have one from elsewhere.`].map((e,t)=>(0,W.jsx)(`li`,{children:e},t)):b.hasLoginFlow?[`Press “Sign in instead” to get a token through the genuine engine — the fastest way.`,"Or run `claude setup-token` yourself and complete the sign-in in your browser.",`Paste the token it prints below (it looks like sk-ant-oat01-…).`].map((e,t)=>(0,W.jsx)(`li`,{children:e},t)):dV(b.provider,b.variant).map((e,t)=>(0,W.jsx)(`li`,{children:e},t))}),(0,W.jsx)(Wy,{label:b.isSubscription?`Subscription token`:`API key`,hint:`Tried against the provider before it is saved, then encrypted on this PC with your vault key.`,children:(0,W.jsx)(`input`,{className:X,type:`password`,autoComplete:`off`,spellCheck:!1,value:l,placeholder:b.keyFormat??`sk-…`,onChange:e=>{u(e.target.value),y(null)}})}),_?(0,W.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,"data-testid":`connect-probe-error`,children:_}):null,x.userBaseUrl?(0,W.jsx)(Wy,{label:`Base URL`,hint:`Point this at your own server if it is not the default. Each record has its own endpoint.`,children:(0,W.jsx)(`input`,{className:X,value:d,spellCheck:!1,onChange:e=>f(e.target.value),placeholder:b.variant?.baseUrl??x.baseUrl})}):null,(0,W.jsx)(Wy,{label:`Label (optional)`,children:(0,W.jsx)(`input`,{className:X,value:p,onChange:e=>m(e.target.value),placeholder:`${S} ${b.label.toLowerCase()} key`})})]}):(0,W.jsxs)(`div`,{className:`rounded-md bg-surface-2 px-3 py-2 text-xs text-fg-muted`,children:[x.displayName,` needs no credential.`]})]})})}function gV({open:e,onClose:t}){let{state:n,actions:r}=G(),i=n.ui.oauthLoginProviderId,a=i?n.providers.find(e=>e.definition.id===i)??null:null,o=n.oauthLogin&&n.oauthLogin.providerId===i?n.oauthLogin:null,[s,c]=(0,v.useState)(0),[l,u]=(0,v.useState)(!1),d=(0,v.useRef)(null),f=a?.definition.displayName??i??`the provider`,p=a?.definition.subscriptionLogin?.signInLabel??`Sign in to ${f}`,m=o?.phase===`awaiting_approval`,h=m?o?.verificationUriComplete??o?.verificationUri??null:null;(0,v.useEffect)(()=>{if(!e||!i)return;d.current=null,r.startOauthLogin(i);let t=setInterval(()=>void r.refreshOauthLogin(i),2e3);return()=>clearInterval(t)},[e,i,s,r]),(0,v.useEffect)(()=>{!e||!h||!o?.id||d.current===o.id||(d.current=o.id,kR(h))},[e,h,o?.id]),(0,v.useEffect)(()=>{e&&o?.phase===`connected`&&r.refreshCredentials()},[e,o?.phase,r]);let g=e=>{if(!navigator.clipboard){r.toast(`error`,`Could not copy — select it and copy by hand`);return}navigator.clipboard.writeText(e).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)}).catch(()=>r.toast(`error`,`Could not copy`))},_=o?.phase===`connected`||o?.phase===`failed`||o?.phase===`expired`||o?.phase===`cancelled`;return(0,W.jsx)(Ky,{open:e,title:p,onClose:t,footer:(0,W.jsxs)(W.Fragment,{children:[m?(0,W.jsx)(J,{onClick:()=>i&&void r.cancelOauthLogin(i),"data-testid":`oauth-login-cancel`,children:`Cancel sign-in`}):null,_&&o?.phase!==`connected`?(0,W.jsx)(J,{onClick:()=>c(e=>e+1),"data-testid":`oauth-login-retry`,children:`Try again`}):null,(0,W.jsx)(J,{variant:`primary`,onClick:t,children:o?.phase===`connected`?`Done`:`Close`})]}),children:(0,W.jsx)(`div`,{className:`space-y-3 text-sm`,"data-testid":`oauth-login-dialog`,children:m&&o?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{children:[`A sign-in page for `,f,` opened in your browser. If it did not, open the link below on any device and enter this code:`]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`code`,{className:`text-lg font-mono px-2 py-1 rounded border border-border`,"data-testid":`oauth-user-code`,children:o.userCode}),(0,W.jsxs)(J,{onClick:()=>o.userCode&&g(o.userCode),children:[(0,W.jsx)(q.Copy,{className:`w-4 h-4`}),` `,l?`Copied`:`Copy code`]})]}),h?(0,W.jsxs)(`div`,{className:`flex items-center gap-2 break-all`,children:[(0,W.jsx)(`a`,{className:`underline`,href:h,onClick:e=>{e.preventDefault(),kR(h)},children:h}),(0,W.jsxs)(J,{onClick:()=>g(h),children:[(0,W.jsx)(q.Copy,{className:`w-4 h-4`}),` Copy link`]})]}):null,(0,W.jsxs)(`p`,{className:`text-fg-muted`,children:[`Waiting for your approval… the code expires`,o.expiresAt?` at ${new Date(o.expiresAt).toLocaleTimeString()}`:` soon`,`. The subscription is stored in your vault the moment `,f,` confirms it.`]})]}):o?.phase===`connected`?(0,W.jsxs)(`p`,{"data-testid":`oauth-login-connected`,children:[`Signed in. Your `,f,` subscription is stored in your vault and synced to your other machines; chats on it run from this PC straight to the provider.`]}):_?(0,W.jsx)(`p`,{className:`text-danger`,"data-testid":`oauth-login-ended`,children:o?.message??`The sign-in did not complete.`}):(0,W.jsx)(`p`,{children:`Starting the sign-in…`})})})}function _V({open:e,onClose:t}){let{state:n,actions:r}=G(),i=(0,v.useMemo)(()=>sf(n.providers),[n.providers]),[a,o]=(0,v.useState)({}),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1);(0,v.useEffect)(()=>{e&&(o({...n.settings?.modelVisibility??{}}),c(``))},[e]);let d=(e,t)=>a[e]??t,f=(e,t,n)=>d(e,n).includes(t),p=(e,t,n)=>{o(r=>{let i=r[e]??n,a=i.includes(t)?i.filter(e=>e!==t):n.filter(e=>e===t||i.includes(e));return{...r,[e]:a}})},m=(e,t,n)=>{o(r=>({...r,[e]:t?[...n]:[]}))},h=async()=>{u(!0);try{let e={};for(let t of i){let n=t.definition.models.map(e=>e.id),r=a[t.definition.id];r&&r.length!==n.length&&(e[t.definition.id]=r)}await r.saveSettings({modelVisibility:e}),t()}finally{u(!1)}},g=s.trim().toLowerCase();return(0,W.jsx)(Ky,{open:e,title:`Manage models`,onClose:t,wide:!0,footer:(0,W.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,W.jsxs)(J,{onClick:()=>{t(),r.openSettings(`providers`)},"data-testid":`manage-models-add-provider`,children:[(0,W.jsx)(q.Plus,{className:`w-3.5 h-3.5`}),` Add provider`]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(J,{onClick:t,children:`Cancel`}),(0,W.jsx)(J,{variant:`primary`,busy:l,onClick:()=>void h(),"data-testid":`manage-models-save`,children:`Save`})]})]}),children:(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Choose which models the chat's picker offers. A provider with every model checked shows all of them — including ones it adds later.`}),(0,W.jsx)(`input`,{className:X,value:s,onChange:e=>c(e.target.value),placeholder:`Filter models…`,"data-testid":`manage-models-filter`}),i.length===0?(0,W.jsxs)(`div`,{className:`text-sm text-fg-faint`,children:[`No provider is connected yet — use `,(0,W.jsx)(`strong`,{children:`Add provider`}),` below to connect one.`]}):null,i.map(e=>{let t=e.definition.models.map(e=>e.id),n=e.definition.models.filter(e=>!g||e.id.toLowerCase().includes(g)||(e.displayName??``).toLowerCase().includes(g)),r=d(e.definition.id,t).length;return(0,W.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`manage-models-${e.definition.id}`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`font-medium`,children:e.definition.displayName}),(0,W.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[r===t.length?`all`:r,` of `,t.length,` shown`]}),(0,W.jsxs)(`span`,{className:`ml-auto flex gap-1`,children:[(0,W.jsx)(J,{size:`sm`,onClick:()=>m(e.definition.id,!0,t),children:`All`}),(0,W.jsx)(J,{size:`sm`,onClick:()=>m(e.definition.id,!1,t),children:`None`})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-2`,children:[n.map(n=>(0,W.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:f(e.definition.id,n.id,t),onChange:()=>p(e.definition.id,n.id,t),"data-testid":`manage-model-${n.id}`}),(0,W.jsxs)(`span`,{className:`truncate`,title:n.id,children:[n.displayName??n.id,n.displayName&&n.displayName!==n.id?(0,W.jsxs)(`span`,{className:`text-fg-faint`,children:[` · `,n.id]}):null]})]},n.id)),n.length===0?(0,W.jsxs)(`div`,{className:`text-xs text-fg-faint`,children:[(0,W.jsx)(q.Info,{className:`mr-1 inline w-3 h-3`}),` No model matches the filter.`]}):null]})]},e.definition.id)})]})})}var vV={mode:`names`,mine:!0,model:!0,tools:!1,subagents:!1,projectId:null,when:`any`,caseSensitive:!1,wholeWord:!1};function yV(e,t,n){let r=De(t,{caseSensitive:n.caseSensitive,wholeWord:n.wholeWord});if(!r)return[{text:e,hit:!1}];let i=[],a=0;for(let t of e.matchAll(r)){let n=t.index??0;t[0].length!==0&&(n>a&&i.push({text:e.slice(a,n),hit:!1}),i.push({text:t[0],hit:!0}),a=n+t[0].length)}return a<e.length&&i.push({text:e.slice(a),hit:!1}),i}function bV(e){return Object.keys(vV).some(t=>e[t]!==vV[t])}function xV(e,t=Date.now()){if(e===`any`)return null;if(e===`today`){let e=new Date(t);return e.setHours(0,0,0,0),e}return new Date(t-(e===`week`?7:30)*24*60*60*1e3)}function SV(e,t,n,r=Date.now()){if(n.projectId!==null&&e.projectId!==n.projectId)return!1;let i=xV(n.when,r);if(i&&e.mtime<i.getTime())return!1;if((n.caseSensitive||n.wholeWord)&&t.trim()!==``){let r=[e.title,e.firstPrompt,e.lastPrompt,e.projectDir],i={caseSensitive:n.caseSensitive,wholeWord:n.wholeWord};if(!r.some(e=>typeof e==`string`&&Oe(e,t,i)))return!1}return!0}function CV(e,t,n=Date.now()){let r=e.trim();if(r.length<2||!t.mine&&!t.model&&!t.tools)return null;let i=xV(t.when,n);return{q:r,limit:200,from:t.mine&&t.model?`both`:t.mine?`user`:t.model?`assistant`:`none`,tools:t.tools,subagents:t.subagents,...i?{since:i.toISOString()}:{},...t.projectId?{projectId:t.projectId}:{},caseSensitive:t.caseSensitive,wholeWord:t.wholeWord}}function wV({label:e,hint:t,checked:n,onChange:r,testId:i}){return(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 py-0.5 text-xs`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:n,onChange:e=>r(e.target.checked),"data-testid":i}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`text-fg`,children:e}),t?(0,W.jsx)(`span`,{className:`block text-[11px] text-fg-faint`,children:t}):null]})]})}var TV=`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-fg focus:outline-none`,EV={names:`Names & prompts`,conversations:`Whole chats`,namesHint:`A chat’s name, its first and last message, and its folder.`,conversationsHint:`Every message of every chat on this PC. Pick whose words to look in.`};function DV({options:e,onChange:t,projects:n,onClose:r,words:i=EV}){let a=(n,r)=>t({...e,[n]:r}),o=e.mode===`conversations`,s=o&&!e.mine&&!e.model&&!e.tools;return(0,W.jsxs)(`div`,{className:`absolute left-2 right-2 top-full z-30 mt-1 space-y-3 rounded-lg border border-border bg-surface p-3 shadow-xl`,onMouseDown:e=>{!(e.target instanceof HTMLSelectElement)&&!(e.target instanceof HTMLInputElement)&&e.preventDefault()},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),r())},"data-testid":`search-options`,children:[(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:`Search in`}),(0,W.jsx)(Jy,{label:`Search in`,value:e.mode,options:[{value:`names`,label:i.names},{value:`conversations`,label:i.conversations}],onChange:e=>a(`mode`,e)}),(0,W.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`search-mode-hint`,children:o?i.conversationsHint:i.namesHint})]}),o?(0,W.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,W.jsx)(wV,{label:`My messages`,checked:e.mine,onChange:e=>a(`mine`,e),testId:`search-opt-mine`}),(0,W.jsx)(wV,{label:`Model replies`,checked:e.model,onChange:e=>a(`model`,e),testId:`search-opt-model`}),(0,W.jsx)(wV,{label:`Tool calls & output`,hint:`Commands, file paths and what the tools answered.`,checked:e.tools,onChange:e=>a(`tools`,e),testId:`search-opt-tools`}),(0,W.jsx)(wV,{label:`Subagents’ conversations`,checked:e.subagents,onChange:e=>a(`subagents`,e),testId:`search-opt-subagents`}),s?(0,W.jsx)(`p`,{className:`text-[11px] text-warn`,children:`Tick at least one to search.`}):null]}):null,(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[n?(0,W.jsxs)(`label`,{className:`space-y-1 text-[11px] text-fg-faint`,children:[(0,W.jsx)(`span`,{children:`Project`}),(0,W.jsxs)(`select`,{className:TV,value:e.projectId??``,onChange:e=>a(`projectId`,e.target.value||null),"data-testid":`search-opt-project`,children:[(0,W.jsx)(`option`,{value:``,children:`All projects`}),n.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}):null,(0,W.jsxs)(`label`,{className:`space-y-1 text-[11px] text-fg-faint`,children:[(0,W.jsx)(`span`,{children:`When`}),(0,W.jsxs)(`select`,{className:TV,value:e.when,onChange:e=>a(`when`,e.target.value),"data-testid":`search-opt-when`,children:[(0,W.jsx)(`option`,{value:`any`,children:`Any time`}),(0,W.jsx)(`option`,{value:`today`,children:`Today`}),(0,W.jsx)(`option`,{value:`week`,children:`Last 7 days`}),(0,W.jsx)(`option`,{value:`month`,children:`Last 30 days`})]})]})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-x-4`,children:[(0,W.jsx)(wV,{label:`Match case`,checked:e.caseSensitive,onChange:e=>a(`caseSensitive`,e),testId:`search-opt-case`}),(0,W.jsx)(wV,{label:`Whole words`,checked:e.wholeWord,onChange:e=>a(`wholeWord`,e),testId:`search-opt-word`})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border pt-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:U(`text-xs`,bV(e)?`text-accent hover:underline`:`text-fg-faint`),disabled:!bV(e),onClick:()=>t(vV),"data-testid":`search-opt-reset`,children:`Reset`}),(0,W.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-2 px-2 py-1 text-xs text-fg hover:bg-surface-3`,onClick:r,"data-testid":`search-opt-done`,children:`Done`})]})]})}function OV(e){return e.kind===`tool`?e.tool??`Tool`:e.role===`assistant`?`Model`:`You`}function kV({query:e,options:t}){let{state:n,actions:r}=G(),i=(0,v.useMemo)(()=>CV(e,t),[e,t]),[a,o]=(0,v.useState)(null),s=i?JSON.stringify(i):``;(0,v.useEffect)(()=>{if(!i)return;let e=!0,t=setTimeout(()=>{r.searchTranscripts(i).then(t=>{e&&o({key:s,res:t})})},350);return()=>{e=!1,clearTimeout(t)}},[s,r]);let c=a&&a.key===s?a:null,l=(0,v.useMemo)(()=>{let e=new Map;for(let t of c?.res?.hits??[]){let r=n.sessions.find(e=>e.id===t.sessionId)?.title||t.title||`Untitled chat`,i=e.get(t.sessionId)??{title:r,hits:[]};i.hits.push(t),e.set(t.sessionId,i)}return[...e.entries()]},[c,n.sessions]);if(!i)return(0,W.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-fg-faint`,"data-testid":`transcript-search-idle`,children:e.trim().length<2?`Type at least two characters to search every chat.`:`Tick what to look in — your messages, the model’s replies or the tools’ side.`});if(!c)return(0,W.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-fg-faint`,"data-testid":`transcript-search-busy`,children:`Searching every chat…`});if(c.res===null)return(0,W.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-danger`,"data-testid":`transcript-search-failed`,children:`This PC could not search its chats. Try again, or update OonaCode.`});let u=c.res.hits.length;return(0,W.jsxs)(`div`,{className:`pb-2`,"data-testid":`transcript-search-results`,children:[(0,W.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-fg-faint`,children:u===0?`No message on this PC says that.`:`${u}${c.res.truncated?`+`:``} ${u===1?`message`:`messages`} in ${l.length} ${l.length===1?`chat`:`chats`}`}),l.map(([n,i])=>(0,W.jsxs)(`div`,{className:`mb-1.5`,"data-testid":`transcript-search-chat-${n}`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-[13px] font-semibold text-fg hover:bg-surface-2`,onClick:()=>r.openChatWithSearch(n,e.trim()),children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i.title}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-3 px-1.5 text-[10px] font-semibold text-fg-muted`,children:i.hits.length})]}),i.hits.map(i=>(0,W.jsxs)(`button`,{type:`button`,className:`block w-full rounded px-2 py-1 pl-4 text-left text-xs hover:bg-surface-2`,onClick:()=>r.openChatWithSearch(n,e.trim()),"data-testid":`transcript-search-hit`,children:[(0,W.jsxs)(`span`,{className:`mb-0.5 flex items-center gap-1.5 text-[10px] text-fg-faint`,children:[i.kind===`tool`?(0,W.jsx)(q.Tool,{className:`h-3 w-3`}):i.role===`assistant`?(0,W.jsx)(q.Bot,{className:`h-3 w-3`}):(0,W.jsx)(q.User,{className:`h-3 w-3`}),(0,W.jsx)(`span`,{className:`font-medium text-fg-muted`,children:OV(i)}),i.subpath?(0,W.jsx)(`span`,{children:`· subagent`}):null,i.timestamp?(0,W.jsx)(`span`,{className:`ml-auto`,children:ag(i.timestamp)}):null]}),(0,W.jsx)(`span`,{className:`line-clamp-3 text-fg-muted`,children:yV(i.snippet,e,t).map((e,t)=>e.hit?(0,W.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,W.jsx)(`span`,{children:e.text},t))})]},`${i.seq}`))]},n))]})}function AV(e){return`${e.agentId??`claude-code`}:${e.id}`}function jV(e){let t=Date.parse(e.lastEntryAt??e.updatedAt);return Number.isFinite(t)?t:0}function MV(e,t,n=Date.now()){let r=xV(t.when,n)?.getTime()??null,i=De(e,{caseSensitive:t.caseSensitive,wholeWord:t.wholeWord});return e=>r!==null&&jV(e)<r?!1:i===null||[e.title,e.firstPrompt,e.lastPrompt,e.cwd,e.projectName,e.id].some(e=>typeof e==`string`&&(i.lastIndex=0,i.test(e)))}function NV(e,t,n=Date.now()){let r=e.trim();if(r.length<2||!t.mine&&!t.model&&!t.tools)return null;let i=xV(t.when,n);return{q:r,from:t.mine&&t.model?`both`:t.mine?`user`:t.model?`assistant`:`none`,tools:t.tools,subagents:t.subagents,...i?{since:i.toISOString()}:{},caseSensitive:t.caseSensitive,wholeWord:t.wholeWord}}function PV(e,t){let n=new Map;for(let t of e){let e=AV(t);n.set(e,e);for(let r of t.supersedes??[]){let i=AV({agentId:t.agentId,id:r});n.has(i)||n.set(i,e)}}let r=new Map;for(let e of t){let t=n.get(AV(e));if(!t)continue;let i=r.get(t);if(!i){r.set(t,{...e,snippets:e.snippets.slice(0,3)});continue}r.set(t,{...i,hits:i.hits+e.hits,...i.hitsCapped||e.hitsCapped?{hitsCapped:!0}:{},snippets:[...i.snippets,...e.snippets].slice(0,3)})}return r}var FV={new:`New`,imported:`Imported`,behind:`Imported · original moved on`,deleted:`You deleted it in OonaCode`,unavailable:`Cannot be imported yet`};function IV(e){return e.alreadyImported?e.upToDate===!1?`behind`:`imported`:e.deletedHere===!0?`deleted`:LV(e)?`unavailable`:`new`}function LV(e){return typeof e.unavailable==`string`&&e.unavailable.length>0}function RV(e){if(LV(e))return!1;let t=IV(e);return t===`new`||t===`behind`}function zV(e){return IV(e)===`new`}function BV(e,t){return new Set(t?e.filter(zV).map(e=>e.id):[])}function VV(e){if(!e.some(e=>e.projectName))return e;let t=[],n=new Map;for(let r of e){let e=r.projectName??``,i=n.get(e);i||(i=[],n.set(e,i),t.push(e)),i.push(r)}return t.flatMap(e=>n.get(e)??[])}function HV(){return{new:0,imported:0,behind:0,deleted:0,unavailable:0}}function UV(e){let t=new Map;for(let n of e){let e=n.agentId??`claude-code`,r=t.get(e);r||(r={key:e,name:n.agentName??`Claude Code`,rows:[],counts:HV()},t.set(e,r)),r.rows.push(n),r.counts[IV(n)]+=1}for(let e of t.values())e.rows=VV([...e.rows].sort((e,t)=>jV(t)-jV(e)));return[...t.values()]}function WV(e,t){let n=0,r=0,i=0;for(let a of e){let e=t.has(a.id);e&&(n+=1),RV(a)&&(r+=1,e&&(i+=1))}return n===0?`none`:r>0&&i===r?`all`:`some`}function GV(e,t){let n=new Set(t),r=e.filter(RV);if(WV(e,t)===`all`||r.length===0)for(let t of e)n.delete(t.id);else for(let e of r)n.add(e.id);return n}function KV(e,t){let n=0;if(t)for(let r of e)t.has(r)||(n+=1);return{total:e.size,notShown:n}}var qV={names:`Names & folders`,conversations:`Whole conversations`,namesHint:`A chat’s name, its first and last message, and the folder it ran in.`,conversationsHint:`Every message of every chat listed here, read from the other apps’ own files. Pick whose words to look in.`},JV=`Ticks the chats with something to bring in — new ones, and imported ones whose original moved on. An imported chat that is up to date, or one you deleted in OonaCode, is ticked on its own row.`;function YV(e){return e.partial===`time`?`Stopped after ${Math.round(e.elapsedMs/1e3)} s — these are the chats found until then. A longer phrase narrows it.`:e.partial===`chats`?`Stopped at ${e.chats.length} chats — a longer phrase narrows it.`:null}function XV(e){return e?e.replace(/[\\/]+$/,``).split(/[\\/]/).length<=2?e:`…${e.slice(-40)}`:`no folder recorded`}function ZV(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function QV(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}var $V=(e,t,n)=>`${e} ${e===1?t:n}`;function eH({open:e,onClose:t,autoOffer:n=!1}){let{state:r,actions:i}=G(),a=r.importProgress,[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(new Set),[g,_]=(0,v.useState)(new Set),[y,b]=(0,v.useState)(null),x=(0,v.useMemo)(()=>f??[],[f]),S=(0,v.useMemo)(()=>UV(x),[x]),C=(0,v.useMemo)(()=>{let e={new:0,imported:0,behind:0,deleted:0,unavailable:0};for(let t of S)for(let n of Object.keys(e))e[n]+=t.counts[n];return e},[S]),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(vV),[O,k]=(0,v.useState)(!1),A=(0,v.useRef)(null),j=w.trim()!==``,M=E.mode===`conversations`,[ee,N]=(0,v.useState)(new Set);(0,v.useEffect)(()=>N(new Set),[w,E]);let P=(0,v.useMemo)(()=>M?NV(w,E):null,[M,w,E]),F=P?JSON.stringify(P):``,[I,te]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!e||!P)return;let t=new AbortController,n=!0,r=setTimeout(()=>{i.searchImportChats(P,t.signal).then(e=>{n&&te({key:F,res:e})})},350);return()=>{n=!1,clearTimeout(r),t.abort()}},[e,F,i]);let ne=I&&I.key===F?I:null,re=(0,v.useMemo)(()=>ne?.res?PV(x,ne.res.chats):null,[ne,x]),L=(0,v.useMemo)(()=>j?M?re?x.filter(e=>re.has(AV(e))):[]:x.filter(MV(w,E)):null,[j,M,x,w,E,re]),ie=(0,v.useMemo)(()=>L?new Set(L):null,[L]),R=(0,v.useMemo)(()=>L?new Set(L.map(e=>e.id)):null,[L]),ae=L??x,oe=(0,v.useMemo)(()=>j?{query:w,options:E,litNames:!M}:null,[j,w,E,M]),se=(0,v.useMemo)(()=>x.filter(e=>e.alreadyImported&&m.has(e.id)),[x,m]),ce=(0,v.useMemo)(()=>KV(m,R),[m,R]),le=S.length===1?S[0].name:`coding-agent`;(0,v.useEffect)(()=>{if(!e)return;d(null),b(null),_(new Set),h(new Set),T(``),te(null),k(!1),s(!0);let t=n;i.scanClaudeSessions().then(e=>{p(e.sessions),h(BV(e.sessions,t))}).catch(e=>d(e instanceof Error?e.message:String(e))).finally(()=>s(!1))},[e]);let ue=(0,v.useCallback)(e=>h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),de=r.prefs.claudeImportOffered,fe=(0,v.useCallback)(()=>{de||i.savePrefs({claudeImportOffered:!0}),t()},[de,i,t]),pe=async()=>{l(!0),d(null);try{let e=await i.importClaudeSessions([...m],se.length>0);b({imported:e.imported.length,replaced:e.replaced?.length??0,entries:e.imported.reduce((e,t)=>e+t.entries,0)+(e.replaced??[]).reduce((e,t)=>e+t.entries,0),failed:e.failed.length,filed:e.filed?.length??0,projectsMade:(e.projects??[]).filter(e=>e.created).map(e=>e.name),warnings:e.warnings??[]}),r.prefs.claudeImportOffered||i.savePrefs({claudeImportOffered:!0}),await i.refreshSessions()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},me=C.imported+C.behind;return(0,W.jsx)(Ky,{open:e,title:`Import your ${le} chats`,onClose:fe,wide:!0,footer:(0,W.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 text-[11px] text-fg-faint`,children:[!y&&ce.notShown>0?(0,W.jsxs)(`span`,{className:`block text-fg-muted`,"data-testid":`import-claude-ticked-hidden`,children:[ce.total,` ticked · `,ce.notShown,` not shown by the search`]}):null,se.length>0?(0,W.jsxs)(`span`,{className:`block text-warn`,children:[se.length,` already-imported `,se.length===1?`chat`:`chats`,` `,`will be REPLACED — the OonaCode copy is rebuilt from the original, and anything added here is lost.`]}):(0,W.jsx)(`span`,{className:`block`,children:`Your other apps stay exactly as they are — this copies, it never moves or deletes.`})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,W.jsx)(J,{onClick:fe,"data-testid":`import-claude-close`,children:y?`Done`:`Not now`}),y?null:(0,W.jsxs)(J,{variant:`primary`,busy:c,disabled:ce.total===0,onClick:()=>void pe(),"data-testid":`import-claude-run`,children:[`Import `,$V(ce.total,`chat`,`chats`)]})]})]}),children:(0,W.jsxs)(`div`,{className:`space-y-3`,"data-testid":`import-claude-body`,children:[o?(0,W.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`Looking for chats on this PC…`}):null,a&&!y?(0,W.jsxs)(`div`,{className:`space-y-2`,"data-testid":`import-claude-progress`,children:[(0,W.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,W.jsxs)(`span`,{children:[`Importing `,(0,W.jsx)(`strong`,{children:a.done}),` of `,(0,W.jsx)(`strong`,{children:a.total}),`…`]}),(0,W.jsxs)(`span`,{className:`text-[11px] text-fg-faint`,children:[Math.round(a.done/Math.max(a.total,1)*100),`%`]})]}),(0,W.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded bg-surface-2`,children:(0,W.jsx)(`div`,{className:`h-full bg-accent transition-[width] duration-200`,style:{width:`${Math.round(a.done/Math.max(a.total,1)*100)}%`}})}),a.current?(0,W.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,title:a.current,children:[`reading: `,a.current]}):null,(0,W.jsxs)(`div`,{className:`flex gap-3 text-[11px] text-fg-faint`,children:[(0,W.jsxs)(`span`,{children:[a.imported,` imported`]}),a.skipped>0?(0,W.jsxs)(`span`,{children:[a.skipped,` already in`]}):null,a.failed>0?(0,W.jsxs)(`span`,{className:`text-warn`,children:[a.failed,` could not be read`]}):null]}),(0,W.jsx)(`p`,{className:`text-[11px] text-fg-faint`,children:`A big chat takes a moment — the largest here are over 100 MB. Your Claude Code is only being read.`})]}):null,u?(0,W.jsx)(`div`,{className:`rounded border border-danger/40 bg-danger/10 p-2 text-sm text-danger`,children:u}):null,y?(0,W.jsxs)(`div`,{className:`text-sm`,"data-testid":`import-claude-done`,children:[(0,W.jsxs)(`p`,{children:[`Imported `,(0,W.jsx)(`strong`,{children:y.imported}),` `,y.imported===1?`chat`:`chats`,y.replaced>0?(0,W.jsxs)(W.Fragment,{children:[` and rebuilt `,(0,W.jsx)(`strong`,{children:y.replaced}),` that `,y.replaced===1?`was`:`were`,` already here`]}):null,` `,`(`,y.entries.toLocaleString(),` entries). They are in your sessions list now, and you can carry on typing in them.`]}),y.projectsMade.length>0?(0,W.jsxs)(`p`,{className:`mt-1`,"data-testid":`import-claude-projects-made`,children:[y.projectsMade.length===1?`Created the project `:`Created the projects `,y.projectsMade.map((e,t)=>(0,W.jsxs)(`span`,{children:[t>0?`, `:``,(0,W.jsx)(`strong`,{children:e})]},e)),` `,`and filed `,y.projectsMade.length===1?`its`:`their`,` chats under`,` `,y.projectsMade.length===1?`it`:`them`,`.`]}):null,y.filed>0?(0,W.jsxs)(`p`,{className:`mt-1 text-fg-muted`,"data-testid":`import-claude-filed`,children:[y.filed,` `,y.filed===1?`chat that was`:`chats that were`,` already here`,` `,y.filed===1?`is`:`are`,` now filed under`,` `,y.filed===1?`its`:`their`,` project.`]}):null,y.failed>0?(0,W.jsxs)(`p`,{className:`mt-1 text-warn`,children:[y.failed,` could not be read and were left alone.`]}):null,y.warnings.map(e=>(0,W.jsx)(`p`,{className:`mt-1 text-warn`,children:e},e))]}):null,!o&&!y&&!a&&f!==null&&f.length>0?(0,W.jsxs)(`div`,{className:`space-y-0.5 text-sm`,"data-testid":`import-claude-tally`,children:[(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{children:f.length}),` `,f.length===1?`chat`:`chats`,` on this PC`,S.length>0?` — `:``,S.map((e,t)=>(0,W.jsxs)(`span`,{children:[t>0?`, `:``,(0,W.jsx)(`strong`,{children:e.rows.length}),` `,e.name]},e.key))]}),(0,W.jsxs)(`p`,{className:`text-fg-muted`,children:[(0,W.jsx)(`strong`,{className:`text-fg`,children:C.new}),` new`,me>0?` · ${me} already imported`:``,C.behind>0?` (${C.behind} behind their original)`:``,C.deleted>0?` · ${C.deleted} you deleted in OonaCode`:``]})]}):null,!o&&!y&&!a&&f!==null&&C.new===0&&!j?(0,W.jsx)(`div`,{className:`text-sm text-fg-muted`,"data-testid":`import-claude-empty`,children:f.length===0?`No chats from a coding agent were found on this PC.`:`Nothing new to import. Every chat is listed below — tick one to import it again.`}):null,!y&&!a&&x.length>0?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Every chat the coding agents on this PC have, newest first. Importing copies them into OonaCode so you can read them here — and continue them, in the folder each one ran in.`,n&&C.new>0?` The new ones are ticked.`:` Tick the ones you want.`]}),(0,W.jsxs)(`div`,{className:`relative`,"data-testid":`import-search`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsxs)(`div`,{className:`relative flex-1`,children:[(0,W.jsx)(q.Search,{className:`pointer-events-none absolute left-2 top-2 w-3.5 h-3.5 text-fg-faint`}),(0,W.jsx)(`input`,{ref:A,"aria-label":`Search the chats to import`,className:U(X,`pl-7`),placeholder:M?`Search inside every conversation`:`Search by name, message or folder`,value:w,onChange:e=>T(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(w!==``||O)&&(e.preventDefault(),e.stopPropagation(),O?k(!1):T(``))},"data-testid":`import-search-input`})]}),(0,W.jsxs)(Y,{label:O?`Hide search options`:`Search options`,className:U(`relative`,O&&`text-accent`),"aria-pressed":O,onMouseDown:e=>e.preventDefault(),onClick:()=>k(e=>!e),"data-testid":`import-search-options-toggle`,children:[(0,W.jsx)(q.Sliders,{}),bV(E)?(0,W.jsx)(`span`,{className:`absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-accent`,"data-testid":`import-search-options-dot`}):null]}),j?(0,W.jsx)(Y,{label:`Clear search`,onMouseDown:e=>e.preventDefault(),onClick:()=>{T(``),A.current?.focus()},"data-testid":`import-search-clear`,children:(0,W.jsx)(q.X,{})}):null]}),O?(0,W.jsx)(DV,{options:E,onChange:D,words:qV,onClose:()=>{k(!1),A.current?.focus()}}):null]}),j?(0,W.jsx)(cH,{query:w,conversations:M,request:P!==null,answer:ne,matches:L?.length??0,messages:[...re?.values()??[]].reduce((e,t)=>e+t.hits,0),capped:[...re?.values()??[]].some(e=>e.hitsCapped)}):null,(0,W.jsx)(`div`,{className:`max-h-96 space-y-3 overflow-y-auto`,"data-testid":`import-claude-list`,children:S.map(e=>{let t=ie?e.rows.filter(e=>ie.has(e)):e.rows;if(t.length===0)return null;let n=ie?!ee.has(e.key):!g.has(e.key),r=ie?N:_;return(0,W.jsxs)(`div`,{className:`rounded border border-border`,"data-testid":`import-group-${e.key}`,children:[(0,W.jsx)(rH,{section:e,rows:t,searching:ie!==null,open:n,chosen:m,onFold:()=>r(t=>tH(t,e.key)),onTicks:h}),n?t.map(e=>(0,W.jsx)(aH,{row:e,checked:m.has(e.id),onToggle:ue,phrase:oe,hit:re?.get(AV(e))},AV(e))):null]},e.key)})}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-fg-faint`,children:[(0,W.jsx)(`button`,{type:`button`,className:`underline`,title:JV,onClick:()=>h(e=>{let t=new Set(e);for(let e of ae)RV(e)&&t.add(e.id);return t}),"data-testid":`import-claude-select-all`,children:L===null?`Select all`:`Select all matches`}),(0,W.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>h(e=>{if(L===null)return new Set;let t=new Set(e);for(let e of ae)t.delete(e.id);return t}),"data-testid":`import-claude-select-none`,children:L===null?`Select none`:`Unselect matches`})]})]}):null]})})}function tH(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function nH({state:e,disabled:t,onToggle:n,label:r,title:i,testId:a}){let o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{o.current&&(o.current.indeterminate=e===`some`)}),(0,W.jsx)(`input`,{ref:o,type:`checkbox`,className:`shrink-0`,checked:e===`all`,disabled:t,onChange:n,"aria-label":r,title:i,"data-state":e,"data-testid":a})}function rH({section:e,rows:t,searching:n,open:r,chosen:i,onFold:a,onTicks:o}){let s=WV(t,i),c=t.filter(RV).length,l=e.rows.filter(e=>i.has(e.id)).length,u=e.counts,d=u.imported+u.behind===e.rows.length,f=n?`the ${e.name} matches`:`${e.name}`,p=s===`all`?`Untick every chat in ${f}`:c===0&&s===`none`?`Nothing new here — tick a chat on its own row to import it again.`:c===0?`Untick every chat in ${f}`:JV;return(0,W.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-surface-2 px-2 py-1.5`,children:[(0,W.jsx)(nH,{state:s,disabled:c===0&&s===`none`,onToggle:()=>o(e=>GV(t,e)),label:s===`all`?`Untick every chat in ${f}`:`Tick the chats in ${f}`,title:p,testId:`import-group-check-${e.key}`}),(0,W.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left text-xs font-medium`,onClick:a,"aria-expanded":r,title:r?`Fold ${e.name}`:`Open ${e.name}`,"data-testid":`import-group-header-${e.key}`,children:[(0,W.jsx)(q.Chevron,{open:r,className:`w-3 h-3 shrink-0`}),e.name,(0,W.jsxs)(`span`,{className:`truncate font-normal text-fg-faint`,children:[$V(e.rows.length,`chat`,`chats`),n?` · ${$V(t.length,`match`,`matches`)}`:``,u.new>0?` · ${u.new} new`:d?` · all imported`:``,u.behind>0?` · ${u.behind} behind`:``,u.deleted>0?` · ${u.deleted} you deleted`:``,l>0?` · ${l} ticked`:``]})]})]})}function iH({row:e,status:t}){let n=FV[t],r={"data-testid":`import-status-${e.id}`,"data-status":t};switch(t){case`new`:return(0,W.jsx)(`span`,{className:`font-medium text-accent`,...r,children:n});case`imported`:case`behind`:return(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-fg-muted`,title:t===`behind`?`The original has newer messages than the OonaCode copy — importing again brings them in (and replaces the copy).`:`Already in OonaCode. Ticking it rebuilds the OonaCode copy from the original, which replaces it.`,...r,children:[(0,W.jsx)(q.Check,{className:`w-3 h-3 text-ok`}),n,t===`behind`?(0,W.jsxs)(`span`,{className:`ml-0.5 inline-flex shrink-0 items-center gap-0.5 rounded bg-warn-soft px-1 text-[10px] font-medium leading-4 text-warn`,"data-testid":`import-behind-${e.id}`,"aria-label":`behind its original`,children:[(0,W.jsx)(q.ArrowDown,{className:`w-2.5 h-2.5`}),`behind`]}):null]});case`deleted`:return(0,W.jsx)(`span`,{className:`text-fg-faint`,title:`You imported this chat and deleted it in OonaCode; its original is still on this PC. Tick it to bring it back.`,...r,children:n});case`unavailable`:return(0,W.jsx)(`span`,{className:`text-warn`,...r,children:n})}}var aH=(0,v.memo)(function({row:e,checked:t,onToggle:n,phrase:r,hit:i}){let a=LV(e),o=e=>r?.litNames?yV(e,r.query,r.options).map((e,t)=>e.hit?(0,W.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,W.jsx)(`span`,{children:e.text},t)):e;return(0,W.jsxs)(`label`,{className:`flex items-start gap-2 border-b border-border p-2 last:border-b-0 ${a?`cursor-default opacity-60`:`cursor-pointer hover:bg-surface-2`}`,"data-testid":`import-row-${e.id}`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:t,disabled:a,onChange:()=>n(e.id),"aria-label":e.title??e.firstPrompt??e.id}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block truncate text-sm`,children:e.title||e.firstPrompt?o(e.title||e.firstPrompt||``):(0,W.jsx)(`span`,{className:`text-fg-faint`,children:`(no prompt)`})}),(0,W.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-fg-faint`,children:[e.projectName?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,W.jsx)(q.Project,{className:`w-3 h-3`}),o(e.projectName)]}):(0,W.jsxs)(W.Fragment,{children:[e.cwd?(0,W.jsx)(`span`,{title:e.cwd,children:o(XV(e.cwd))}):XV(e.cwd),e.cwd&&!e.cwdExists?` · folder is gone`:``]}),` `,`· `,e.entryCount,` entries`,e.bytes>0?` · ${ZV(e.bytes)}`:``,e.model?` · ${e.model}`:``]}),e.unavailable||e.note?(0,W.jsx)(`span`,{className:`mt-0.5 block text-[11px] ${e.unavailable?`text-warn`:`text-fg-faint`}`,"data-testid":`import-row-note-${e.id}`,children:e.unavailable??e.note}):null,i&&r?(0,W.jsx)(sH,{hit:i,query:r.query,options:r.options,testId:`import-row-hits-${e.id}`}):null]}),e.supersedes&&e.supersedes.length>0?(0,W.jsx)(`span`,{className:`mt-0.5 shrink-0 rounded bg-surface-2 px-1 text-[11px] text-fg-faint`,title:`Rewound — replaces ${e.supersedes.length} earlier ${e.supersedes.length===1?`branch`:`branches`} of this chat`,children:`rewound`}):null,(0,W.jsxs)(`span`,{className:`mt-0.5 flex shrink-0 flex-col items-end gap-0.5 text-right text-[11px]`,children:[(0,W.jsx)(`span`,{className:`whitespace-nowrap text-fg-faint`,children:QV(e.lastEntryAt??e.updatedAt)}),(0,W.jsx)(`span`,{className:`whitespace-nowrap`,children:(0,W.jsx)(iH,{row:e,status:IV(e)})})]})]})});function oH(e){let t=e.kind===`tool`?e.tool??`Tool`:e.role===`assistant`?`Model`:`You`;return e.subagent?`${t} (subagent)`:t}function sH({hit:e,query:t,options:n,testId:r}){return(0,W.jsxs)(`span`,{className:`mt-1 block space-y-0.5`,"data-testid":r,children:[(0,W.jsxs)(`span`,{className:`block text-[11px] font-medium text-fg-muted`,children:[e.hits,e.hitsCapped?`+`:``,` `,e.hits===1&&!e.hitsCapped?`message says`:`messages say`,` it`]}),e.snippets.map((e,r)=>(0,W.jsxs)(`span`,{className:`block line-clamp-2 text-[11px] text-fg-muted`,"data-testid":`import-row-snippet`,children:[(0,W.jsxs)(`span`,{className:`font-medium text-fg-faint`,children:[oH(e),`:`]}),` `,yV(e.snippet,t,n).map((e,t)=>e.hit?(0,W.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,W.jsx)(`span`,{children:e.text},t))]},r))]})}function cH({query:e,conversations:t,request:n,answer:r,matches:i,messages:a,capped:o}){let s=(e,t,n=`text-fg-muted`)=>(0,W.jsx)(`p`,{className:`text-[11px] ${n}`,"data-testid":t,children:e});if(!t)return i===0?s(`No chat’s name, message or folder says “${e.trim()}”. Whole conversations, in the search options, looks inside them.`,`import-search-none`):s(`${i} ${i===1?`chat matches`:`chats match`}`,`import-search-count`);if(!n)return s(e.trim().length<2?`Type at least two characters to search inside the conversations.`:`Tick what to look in — your messages, the model’s replies or the tools’ side.`,`import-search-idle`);if(!r)return s(`Searching every conversation on this PC…`,`import-search-busy`);if(r.res===null)return s(`This PC could not search its conversations. Try again, or update OonaCode.`,`import-search-failed`,`text-danger`);let c=r.res,l=YV(c),u=c.sources.filter(e=>e.note).map(e=>`${e.agentName}: ${e.note}`);return(0,W.jsxs)(`div`,{className:`space-y-0.5`,children:[i===0?s(c.partial===`aborted`?`The search was stopped.`:`No conversation on this PC says that.`,`import-search-none`):s(`${i} ${i===1?`chat says`:`chats say`} it · ${a}${o?`+`:``} ${a===1&&!o?`message`:`messages`}`,`import-search-count`),l?s(l,`import-search-partial`,`text-warn`):null,u.map(e=>(0,W.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`import-search-source-note`,children:e},e))]})}var lH={model:null,previousModel:null,costUsd:0,inputTokens:0,outputTokens:0,turns:0,durationMs:0,contextTokens:null,contextWindow:null,contextUsed:null,costSource:`engine`,credits:null,resetAtIndex:null,didReset:!1,countedResults:0};function uH(e,t){let n=t?zs(t):null,r=null,i=null;for(let t=0;t<e.length;t++){let a=e[t];if(!a||a.kind!==`assistant`||!L(a.model))continue;let o=zs(a.model);n!==null&&o!==n&&(r=t,i=n),n=o}return{index:r,from:i,to:n}}function dH(e){let{items:t,session:n=null,initModel:r=null,boundary:i=null,models:a}=e,o=e.contextTokens!=null&&e.contextTokens>0?e.contextTokens:null;if(t.length===0&&!n)return lH;let s=uH(t,r),c=i&&i.index>=0?Math.min(i.index,t.length):null,l=null,u=null;s.index!==null&&(c===null||s.index>=c)?(l=s.index,u=s.from):c!==null&&(l=c,u=i?.from??s.from);let d=l??0,f=0,p=0,m=0,h=0,g=0,_=0;for(let e=d;e<t.length;e++){let n=t[e];!n||n.kind!==`result`||(_+=1,f+=n.costUsd,p+=n.inputTokens,m+=n.outputTokens,h+=n.numTurns,g+=n.durationMs)}_===0&&l===null&&n&&(f=n.totalCostUsd,p=n.inputTokens,m=n.outputTokens);let v=`engine`,y=null;n&&n.providerId===`oonacode`&&(f=n.totalCostUsd,y=n.poolCredits??null,v=`gateway`);let b=r?zs(r):null,x=i&&c!==null&&l===c?i.to:s.to??n?.model??b??null,S=[x,n?.model??null,b].filter(e=>typeof e==`string`&&e.length>0),C=(a?S.map(e=>a.find(t=>t.id===e)).find(e=>e?.contextWindow!=null):void 0)?.contextWindow??null;return{model:x,previousModel:u,costUsd:f,inputTokens:p,outputTokens:m,turns:h,durationMs:g,contextTokens:o,contextWindow:C,contextUsed:C&&C>0&&o!==null?Math.min(1,o/C):null,resetAtIndex:l,didReset:l!==null,countedResults:_,costSource:v,credits:y}}var fH=[...yu.what,...yu.when,...yu.who,...yu.yours,...yu.where];function pH({sessionId:e,entryCount:t}){let{state:n,actions:r}=G(),i=n.chatAboutsChange,a=Xl(n.settings??{}),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(null),C=(0,v.useRef)(i.seq),w=(0,v.useRef)(!0);(0,v.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let T=(0,v.useCallback)(async()=>{let t=await r.getChatAbout(e);if(w.current){if(t===`unsupported`){l(!0);return}t!==null&&(l(!1),s(t))}},[r,e]);if((0,v.useEffect)(()=>{T()},[T]),(0,v.useEffect)(()=>{i.seq!==C.current&&(C.current=i.seq,cu(i,e)&&T())},[i,e,T]),c||o===null)return null;let E=()=>{p(o.about??``),d(!0),S(null),b(null)},D=async()=>{if(_u(f))return;let t=f.trim()===``;h(!0);try{let n=await r.updateChatAbout(e,t?null:f);if(!w.current||!n)return;s(n),d(!1),S(t?a.enabled?`Cleared. The housekeeper writes a new about at the chat’s next change.`:`Cleared. None is written while chat abouts are off.`:null)}finally{w.current&&h(!1)}},O=async()=>{_(!0),b(null),S(null);try{let t=await r.regenerateChatAbout(e);if(!w.current)return;t.about&&s(t.about),t.ok||b(t.error??`The about could not be written.`)}finally{w.current&&_(!1)}},k=vu(f,a.maxWords),A=_u(f),j=lu(o);return(0,W.jsxs)(`div`,{className:`mb-2`,"data-testid":`session-about`,children:[(0,W.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:(0,W.jsx)(q.Info,{className:`w-3.5 h-3.5`})}),`About`,(0,W.jsx)(Hy,{label:`About`,details:(0,W.jsx)(Uy,{items:fH})}),o.stale&&o.about?(0,W.jsx)(`span`,{title:yu.stale,"data-testid":`session-about-stale`,children:(0,W.jsx)(Z,{tone:`warn`,children:`stale`})}):null]}),u?(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsx)(`textarea`,{className:U(X,`min-h-[7rem] resize-y text-xs`),value:f,onChange:e=>p(e.target.value),"aria-label":`This chat’s about`,placeholder:`What this chat works on, for your other chats to read`,autoFocus:!0,"data-testid":`session-about-input`}),(0,W.jsxs)(`div`,{className:U(`text-[11px]`,k.overChars?`text-danger`:k.overWords?`text-warn`:`text-fg-faint`),"data-testid":`session-about-count`,children:[k.words,` / `,a.maxWords,` words · `,k.chars.toLocaleString(`en-US`),` /`,` `,Jl.userChars.toLocaleString(`en-US`),` characters`]}),A?(0,W.jsx)(`div`,{className:`text-[11px] text-danger`,"data-testid":`session-about-problem`,children:A}):k.overWords?(0,W.jsxs)(`div`,{className:`text-[11px] text-warn`,children:[`Longer than the `,a.maxWords,` words the housekeeper writes; your other chats read all of it.`]}):null,(0,W.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:`Saved empty, it is cleared, and the housekeeper writes one again at the chat’s next change.`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(J,{size:`sm`,variant:`primary`,onClick:()=>void D(),busy:m,disabled:A!==null,"data-testid":`session-about-save`,children:`Save`}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>d(!1),disabled:m,"data-testid":`session-about-cancel`,children:`Cancel`})]})]}):(0,W.jsxs)(W.Fragment,{children:[o.about?(0,W.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-xs text-fg`,"data-testid":`session-about-text`,children:o.about}):(0,W.jsxs)(`p`,{className:`text-[11px] text-fg-muted`,"data-testid":`session-about-missing`,children:[`No about yet. `,hu(o,{enabled:a.enabled,entryCount:t})]}),o.about&&o.aboutAt?(0,W.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,title:sg(o.aboutAt),"data-testid":`session-about-written`,children:[`Written `,ag(o.aboutAt),j?` by ${j}`:``]}):null,o.about&&o.pending?(0,W.jsx)(`div`,{className:`text-[11px] text-accent`,children:`Being written again now…`}):null,o.about&&o.lastError?(0,W.jsxs)(`div`,{className:`text-[11px] text-danger`,"data-testid":`session-about-last-error`,children:[`The last attempt failed: `,o.lastError]}):null,(0,W.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,title:o.route?`Paid by ${uu[o.route]}`:void 0,"data-testid":`session-about-spend`,children:[`Cost so far: `,pu(o.spend,o.route)]}),x?(0,W.jsx)(`div`,{className:`mt-0.5 text-[11px] text-fg-muted`,"data-testid":`session-about-note`,children:x}):null,y?(0,W.jsx)(`div`,{className:`mt-0.5 text-[11px] text-danger`,role:`alert`,"data-testid":`session-about-regen-error`,children:y}):null,(0,W.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[(0,W.jsxs)(J,{size:`sm`,variant:`ghost`,onClick:E,disabled:g,title:yu.edit,"data-testid":`session-about-edit`,children:[(0,W.jsx)(q.Edit,{className:`h-3 w-3`}),` Edit`]}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>void O(),disabled:!a.enabled||g,title:a.enabled?yu.regenerate:yu.regenerateOff,"data-testid":`session-about-regenerate`,children:g?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q.Spinner,{className:`h-3 w-3`}),` Writing…`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q.Refresh,{className:`h-3 w-3`}),` Regenerate`]})})]}),a.enabled?null:(0,W.jsx)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,"data-testid":`session-about-off`,children:`Regenerate is unavailable: chat abouts are off.`})]})]})}function mH({view:e}){let t=(0,v.useMemo)(()=>BB(e.request??``),[e.request]);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:e.truncated?`Cut at the size the host keeps.`:`As agy sent it.`}),(0,W.jsx)(ZM,{text:t})]}),(0,W.jsx)(`pre`,{className:`mt-0.5 max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-md border border-border bg-code-bg p-2 font-mono text-[11px] leading-snug text-fg`,"data-testid":`agy-request-json`,children:t})]})}function hH({sessionId:e,running:t}){let{api:n}=G(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)({}),h=(0,v.useRef)(!0);(0,v.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let g=(0,v.useCallback)(async()=>{if(!n.listAgyRequests){o(!0);return}c(!0);try{let t=await n.listAgyRequests(e);if(!h.current)return;o(!1),i(t.requests)}catch(e){if(!h.current)return;ym(e)&&o(!0)}finally{h.current&&c(!1)}},[n,e]);(0,v.useEffect)(()=>{g()},[g]);let _=(0,v.useRef)(t);(0,v.useEffect)(()=>{_.current&&!t&&g(),_.current=t},[t,g]);let{main:y,background:b}=(0,v.useMemo)(()=>NB(r??[]),[r]),x=async t=>{if(p[t.id]){m(e=>{let{[t.id]:n,...r}=e;return r});return}m(e=>({...e,[t.id]:{phase:`loading`}}));let r=e=>{h.current&&m(n=>n[t.id]?{...n,[t.id]:e}:n)};if(!n.getAgyRequestBody)return r({phase:`gone`});try{let i=await n.getAgyRequestBody(e,t.id);r(i.request===null?{phase:`gone`}:{phase:`ready`,view:i})}catch(e){r(ym(e)?{phase:`gone`}:{phase:`failed`,message:mg(e)})}};if(a||r===null)return null;let S=e=>{let{title:t,detail:n}=PB(e),r=IB(e),i=RB(e.usage),a=p[e.id],o=[n,e.ms===null?`running…`:rg(e.ms),i].filter(e=>!!e),s=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{className:`flex items-baseline gap-1.5`,children:[(0,W.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-fg-faint`,title:sg(e.at),children:zB(e.at)}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-fg`,children:t}),(0,W.jsx)(`span`,{className:U(`shrink-0 text-[11px] font-medium`,r.tone===`danger`?`text-danger`:`text-fg-muted`),"data-tone":r.tone,"data-testid":`agy-request-status-${e.id}`,children:r.text})]}),(0,W.jsx)(`span`,{className:`block break-words text-[11px] text-fg-faint`,children:o.join(` · `)}),e.error?(0,W.jsx)(`span`,{className:`block break-words text-[11px] text-danger`,children:e.error}):null]});return(0,W.jsxs)(`li`,{className:`rounded-md border border-border px-2 py-1`,"data-testid":`agy-request-${e.id}`,"data-kind":e.kind,children:[e.hasBody?(0,W.jsx)(`button`,{type:`button`,className:`block w-full text-left`,"aria-expanded":a!==void 0,title:`${FB(e)} — show the request`,onClick:()=>void x(e),"data-testid":`agy-request-open-${e.id}`,children:s}):(0,W.jsx)(`div`,{title:FB(e),children:s}),a?(0,W.jsx)(`div`,{className:`mt-1`,"data-testid":`agy-request-body-${e.id}`,children:a.phase===`loading`?(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-fg-muted`,children:[(0,W.jsx)(q.Spinner,{className:`h-3 w-3`}),` Loading the request…`]}):a.phase===`gone`?(0,W.jsx)(`div`,{className:`text-[11px] text-fg-muted`,"data-testid":`agy-request-body-gone`,children:`This request’s body is no longer kept on this PC.`}):a.phase===`failed`?(0,W.jsxs)(`div`,{className:`text-[11px] text-danger`,role:`alert`,children:[`Could not read it: `,a.message]}):(0,W.jsx)(mH,{view:a.view})}):null]},e.id)};return(0,W.jsxs)(`div`,{className:`mb-2`,"data-testid":`agy-requests`,children:[(0,W.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left text-[11px] font-semibold uppercase tracking-wide text-fg-faint hover:text-fg-muted`,"aria-expanded":l,onClick:()=>u(e=>!e),"data-testid":`agy-requests-toggle`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:(0,W.jsx)(q.Chevron,{className:`h-3 w-3`,open:l})}),`Google agy requests`,(0,W.jsx)(`span`,{className:`font-mono normal-case tracking-normal`,"data-testid":`agy-requests-count`,children:r.length})]}),(0,W.jsx)(Y,{label:`Refresh agy requests`,className:`p-1`,disabled:s,onClick:()=>void g(),"data-testid":`agy-requests-refresh`,children:s?(0,W.jsx)(q.Spinner,{className:`h-3 w-3`}):(0,W.jsx)(q.Refresh,{className:`h-3 w-3`})})]}),(0,W.jsx)(`p`,{className:`mb-1 text-[11px] leading-snug text-fg-faint`,"data-testid":`agy-requests-privacy`,children:AB}),l?(0,W.jsxs)(W.Fragment,{children:[y.length===0?(0,W.jsx)(`p`,{className:`text-[11px] text-fg-muted`,"data-testid":`agy-requests-empty`,children:`No model calls yet — they appear here as agy talks to Google.`}):(0,W.jsx)(`ul`,{className:`max-h-72 space-y-1 overflow-y-auto`,"data-testid":`agy-requests-main`,children:y.map(S)}),b.length>0?(0,W.jsxs)(`div`,{className:`mt-1.5`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-[11px] text-accent hover:underline`,"aria-expanded":d,onClick:()=>f(e=>!e),"data-testid":`agy-background-toggle`,children:[(0,W.jsx)(q.Chevron,{className:`h-3 w-3`,open:d}),`background calls (`,b.length,`)`]}),d?(0,W.jsx)(`ul`,{className:`mt-1 max-h-72 space-y-1 overflow-y-auto opacity-70`,"data-testid":`agy-requests-background`,children:b.map(S)}):null]}):null]}):null]})}function gH({label:e,icon:t,children:n}){return(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1`,children:[(0,W.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-faint`,children:[t?(0,W.jsx)(`span`,{className:`shrink-0 text-fg-faint`,"aria-hidden":`true`,children:t}):null,e]}),(0,W.jsx)(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-fg`,children:n})]})}function _H({label:e,icon:t}){return(0,W.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:t}),e]})}var vH={provider:(0,W.jsx)(q.Plug,{className:`w-3.5 h-3.5`}),route:(0,W.jsx)(q.Globe,{className:`w-3.5 h-3.5`}),model:(0,W.jsx)(q.Bot,{className:`w-3.5 h-3.5`}),permission:(0,W.jsx)(q.Shield,{className:`w-3.5 h-3.5`}),context:(0,W.jsx)(q.Brain,{className:`w-3.5 h-3.5`}),window:(0,W.jsx)(q.Panel,{className:`w-3.5 h-3.5`}),compactions:(0,W.jsx)(q.CollapseAll,{className:`w-3.5 h-3.5`}),usage:(0,W.jsx)(q.Coins,{className:`w-3.5 h-3.5`}),tokensIn:(0,W.jsx)(q.Download,{className:`w-3.5 h-3.5`}),tokensOut:(0,W.jsx)(q.Upload,{className:`w-3.5 h-3.5`}),duration:(0,W.jsx)(q.Clock,{className:`w-3.5 h-3.5`}),turns:(0,W.jsx)(q.Send,{className:`w-3.5 h-3.5`}),session:(0,W.jsx)(q.Info,{className:`w-3.5 h-3.5`}),status:(0,W.jsx)(q.Monitor,{className:`w-3.5 h-3.5`}),updated:(0,W.jsx)(q.Refresh,{className:`w-3.5 h-3.5`}),entries:(0,W.jsx)(q.Menu,{className:`w-3.5 h-3.5`}),project:(0,W.jsx)(q.Project,{className:`w-3.5 h-3.5`}),folder:(0,W.jsx)(q.Folder,{className:`w-3.5 h-3.5`})};function yH({used:e}){let t=Math.round(e*100);return(0,W.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Context used`,children:(0,W.jsx)(`div`,{className:U(`h-full rounded-full`,t>=90?`bg-danger`:t>=70?`bg-warn`:`bg-accent`),style:{width:`${t}%`}})})}function bH(){let{state:e,actions:t}=G(),n=Ay(),r=n?e.remote.tabs[n.id]!==void 0:!1,i=n?e.drafts[n.id]!==void 0:!1,a=ky(),o=e.currentSessionId,s=n?.projectId?e.vaultProjects.find(e=>e.id===n.projectId):void 0,c=s?.instructions.trim()??``,l=n?.providerId??e.activeProviderId,u=e.providers.find(e=>e.definition.id===l),d=u?.definition.models,f=(0,v.useMemo)(()=>{let e=u?.definition;return e?As(e,{credentialClass:(u.credentials.find(e=>e.variantId===n?.variantId)??u.credentials[0])?.class??null}):null},[u,n?.variantId]),p=(0,v.useMemo)(()=>dH({items:a?.items??[],session:n,initModel:a?.init?.model??null,boundary:o?e.modelBoundaries[o]??null:null,models:d,contextTokens:a?.contextTokens??null}),[a?.items,a?.init?.model,a?.contextTokens,n,o,e.modelBoundaries,d]),m=(0,v.useMemo)(()=>(a?.items??[]).filter(e=>e.kind===`user`&&e.compactSummary).length,[a?.items]),h=n?$p(n.providerId)&&!r&&!i:!1,g=a?.status===`running`||a?.status===`waiting_permission`;return(0,W.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-border bg-surface`,"aria-label":`Session info`,"data-testid":`session-panel`,children:[(0,W.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,W.jsx)(q.Info,{className:`w-3.5 h-3.5 text-fg-faint`}),(0,W.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:`Session info`}),(0,W.jsx)(Y,{label:`Hide session info`,className:`p-1`,onClick:()=>void t.savePrefs({sessionPanelOpen:!1}),children:(0,W.jsx)(q.X,{className:`w-3.5 h-3.5`})})]}),n?(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-2`,children:[p.didReset?(0,W.jsxs)(`div`,{className:`mb-2 rounded-md bg-accent-soft px-2 py-1.5 text-[11px] text-accent`,"data-testid":`stats-reset`,children:[`Statistics restarted at the model change`,p.previousModel?` (was ${p.previousModel})`:``,`.`]}):null,!r&&!i?(0,W.jsx)(pH,{sessionId:n.id,entryCount:n.entryCount??null},n.id):null,(0,W.jsxs)(`div`,{className:`mb-2`,children:[(0,W.jsx)(_H,{label:`Model`,icon:vH.model}),(0,W.jsx)(gH,{label:`Provider`,icon:vH.provider,children:u?.definition.displayName??l??`—`}),(0,W.jsx)(gH,{label:`Route`,icon:vH.route,children:f?(0,W.jsx)(Z,{tone:f.viaGateway?`accent`:`ok`,children:f.badge}):`—`}),f?(0,W.jsx)(`div`,{className:`pb-1 text-[11px] leading-snug text-fg-faint`,children:f.detail}):null,(0,W.jsx)(gH,{label:`Model`,icon:vH.model,children:p.model??n.model??`—`}),(0,W.jsxs)(gH,{label:`Permission mode`,icon:vH.permission,children:[(0,W.jsx)(Z,{children:N(I(n))}),` `,(0,W.jsx)(Z,{children:n.permissionMode})]})]}),(0,W.jsxs)(`div`,{className:`mb-2`,children:[(0,W.jsx)(_H,{label:`Context`,icon:vH.context}),p.contextUsed!==null&&p.contextTokens!==null?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(yH,{used:p.contextUsed}),(0,W.jsxs)(`div`,{className:`mt-1 text-[11px] text-fg-muted`,"data-testid":`context-used`,children:[ig(p.contextTokens),` / `,ig(p.contextWindow??0),` `,`tokens (`,Math.round(p.contextUsed*100),`%)`]})]}):(0,W.jsx)(`div`,{className:`text-[11px] text-fg-muted`,"data-testid":`context-used`,children:p.contextTokens===null?`Measured at the next reply`:`${ig(p.contextTokens)} tokens (window unknown)`}),(0,W.jsx)(gH,{label:`Context window`,icon:vH.window,children:(0,W.jsx)(`span`,{"data-testid":`context-window`,children:p.contextWindow?`${ig(p.contextWindow)} tokens`:`unknown`})}),(0,W.jsx)(gH,{label:`Compactions`,icon:vH.compactions,children:(0,W.jsx)(`span`,{"data-testid":`compaction-count`,children:m})})]}),(0,W.jsxs)(`div`,{className:`mb-2`,children:[(0,W.jsx)(_H,{label:`Usage`,icon:vH.usage}),(0,W.jsx)(gH,{label:`Tokens in`,icon:vH.tokensIn,children:ig(p.inputTokens)}),(0,W.jsx)(gH,{label:`Tokens out`,icon:vH.tokensOut,children:ig(p.outputTokens)}),p.credits===null?null:(0,W.jsx)(gH,{label:`Credits used`,icon:vH.usage,children:p.credits.toLocaleString(`en-US`,{maximumFractionDigits:2})}),(0,W.jsx)(gH,{label:`Duration`,icon:vH.duration,children:p.countedResults>0&&rg(p.durationMs)||`—`}),(0,W.jsx)(gH,{label:`Turns`,icon:vH.turns,children:p.countedResults>0?p.turns:`—`})]}),(0,W.jsxs)(`div`,{className:`mb-2`,children:[(0,W.jsx)(_H,{label:`Session`,icon:vH.session}),(0,W.jsx)(gH,{label:`Status`,icon:vH.status,children:(0,W.jsx)(Z,{tone:a?.status===`error`?`danger`:a?.status===`running`?`accent`:a?.status===`waiting_permission`?`warn`:`neutral`,children:a?.status??n.status})}),(0,W.jsx)(gH,{label:`Updated`,icon:vH.updated,children:ag(n.updatedAt)}),(0,W.jsx)(gH,{label:`Entries`,icon:vH.entries,children:n.entryCount}),(0,W.jsx)(gH,{label:`Project`,icon:vH.project,children:(0,W.jsx)(`span`,{"data-testid":`session-project`,children:s?s.name:`—`})}),c?(0,W.jsx)(`div`,{className:`whitespace-pre-wrap break-words pb-1 text-[11px] leading-snug text-fg-faint`,"data-testid":`session-project-instructions`,children:c.length>300?`${c.slice(0,300)}\u2026`:c}):null,r?null:(0,W.jsx)(`button`,{type:`button`,className:`text-[11px] text-accent hover:underline`,onClick:()=>t.openAssignProject(n.id),"data-testid":`session-change-project`,children:s?`Move to another project…`:`Move to a project…`}),(0,W.jsx)(gH,{label:`Folder`,icon:vH.folder,children:n.projectDir?`project`:`own workspace`}),(0,W.jsx)(`div`,{className:`mt-1 break-all font-mono text-[10px] text-fg-faint`,"data-testid":`session-folder`,children:n.cwd}),r?null:(0,W.jsx)(`button`,{type:`button`,className:`mt-1 text-[11px] text-accent hover:underline`,onClick:()=>t.openDialog(`project`),"data-testid":`session-change-folder`,children:`Change folder…`})]}),h?(0,W.jsx)(hH,{sessionId:n.id,running:g},n.id):null,r?null:(0,W.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`session-scheduled-tasks`,children:[(0,W.jsx)(_H,{label:`Scheduled tasks`,icon:vH.session}),(0,W.jsx)(WN,{sessionId:n.id})]}),a?.init?(0,W.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[`engine `,a.init.claudeCodeVersion,` · `,a.init.tools.length,` tools`]}):null]}):(0,W.jsx)(`div`,{className:`p-4 text-xs text-fg-faint`,children:`Open a chat to see its statistics.`})]})}function xH(e){let t=e=>e.type===`dir`?0:1;return[...e].sort((e,n)=>t(e)-t(n)||e.name.localeCompare(n.name))}function SH(e){let t=[];return e.target.type===`file`&&t.push({key:`open`,label:`Open`,icon:(0,W.jsx)(q.File,{className:`w-3.5 h-3.5`}),onSelect:e.onOpen,testId:`files-menu-open`}),t.push({key:`copy-path`,label:`Copy path`,icon:(0,W.jsx)(q.Copy,{className:`w-3.5 h-3.5`}),disabled:!e.canCopyPath,onSelect:e.onCopyPath,testId:`files-menu-copy-path`},{key:`copy-relative-path`,label:`Copy relative path`,icon:(0,W.jsx)(q.Copy,{className:`w-3.5 h-3.5`}),onSelect:e.onCopyRelativePath,testId:`files-menu-copy-relative-path`}),!e.remote&&e.canDelete&&t.push({key:`delete`,label:`Delete…`,icon:(0,W.jsx)(q.Trash,{className:`w-3.5 h-3.5`}),danger:!0,separated:!0,onSelect:e.onDelete,testId:`files-menu-delete`}),t}function CH(e,t){return t instanceof hm&&t.status===404&&/^no route for /.test(t.message)?`This host is too old to delete files — update it from the title bar.`:`Could not delete ${pj(e.path)}: ${t instanceof Error?t.message:String(t)}`}function wH(){let{state:e,dispatch:t,actions:n,api:r}=G(),i=Ay(),a=ky(),o=i?.id??null,s=o?e.remote.tabs[o]!==void 0:!1,c=a?.status===`running`||a?.status===`waiting_permission`,l=o?e.files[o]?.active??null:null,u=e.info?.platform??null,d=i?.cwd??``,[f,p]=(0,v.useState)({}),[m,h]=(0,v.useState)(()=>new Set),[g,_]=(0,v.useState)(!1),y=(0,v.useRef)(f);y.current=f;let b=(0,v.useRef)(m);b.current=m;let x=(0,v.useRef)(o);x.current=o;let S=(0,v.useRef)(e.files);S.current=e.files;let[C,w]=(0,v.useState)(null),T=(0,v.useCallback)(()=>w(null),[]),E=(0,v.useCallback)((e,t,n)=>w({target:e,at:t,el:n}),[]),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(!1),j=(0,v.useCallback)(()=>O(null),[]),M=(0,v.useCallback)(async e=>{if(!o||!r.listSessionFiles)return;let t=o;p(t=>({...t,[e]:{...t[e]??{entries:null},loading:!0,error:null}}));try{let n=await r.listSessionFiles(t,e);if(x.current!==t)return;_(!1),p(t=>({...t,[e]:{entries:xH(n.entries),loading:!1,error:null}}))}catch(n){if(x.current!==t)return;ym(n)&&_(!0);let r=n instanceof Error?n.message:String(n);p(t=>({...t,[e]:{entries:t[e]?.entries??null,loading:!1,error:r}}))}},[r,o]);(0,v.useEffect)(()=>{p({}),h(new Set),_(!1),w(null),O(null),o&&!s&&M(``)},[o,s,M]);let ee=(0,v.useRef)(c);(0,v.useEffect)(()=>{if(ee.current&&!c&&o&&!s)for(let e of Object.keys(y.current))(e===``||b.current.has(e))&&M(e);ee.current=c},[c,o,s,M]);let N=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),y.current[e]?.entries||M(e)),n})},P=()=>{if(o){M(``);for(let e of m)M(e)}},F=(e,t)=>{XM(e).then(e=>n.toast(e?`success`:`error`,e?t:`Could not copy to the clipboard`))},I=async()=>{let e=D,i=o;if(!(!e||!i||!r.deleteSessionFile)){A(!0);try{await r.deleteSessionFile(i,e.path);for(let n of S.current[i]?.open??[])gj(n,e.path)&&t({type:`file_close`,sessionId:i,path:n});x.current===i&&(h(t=>new Set([...t].filter(t=>!gj(t,e.path)))),p(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!gj(t,e.path)))),M(hj(e.path))),n.toast(`success`,`Deleted ${pj(e.path)}`)}catch(t){n.toast(`error`,CH(e,t)),x.current===i&&M(hj(e.path))}finally{A(!1),O(null)}}},te=C?SH({target:C.target,remote:s,canDelete:typeof r.deleteSessionFile==`function`,canCopyPath:d!==``,onOpen:()=>n.openFile(C.target.path),onCopyPath:()=>F(yj(d,C.target.path,u),`Path copied`),onCopyRelativePath:()=>F(vj(C.target.path,_j(d,u)),`Relative path copied`),onDelete:()=>O(C.target)}):[],ne=()=>void n.savePrefs({explorerOpen:!1}),re=i?.cwd?pj(i.cwd)||i.cwd:`Files`,L=f[``],ie=C?.target.path??null,R=(0,v.useMemo)(()=>o?s?(0,W.jsx)(EH,{children:`This chat runs on another PC; its files can be browsed there.`}):g?(0,W.jsx)(EH,{children:`This host is too old to list files — update it from the title bar.`}):L?.error&&!L.entries?(0,W.jsx)(EH,{tone:`danger`,children:L.error}):L?.entries?L.entries.length===0?(0,W.jsx)(EH,{children:`The folder is empty.`}):(0,W.jsx)(`ul`,{role:`tree`,"aria-label":`Workspace files`,className:`py-1`,children:(0,W.jsx)(kH,{rel:``,depth:0,tree:f,expanded:m,activeFile:l,menuPath:ie,onToggle:N,onOpen:e=>n.openFile(e),onMenu:E})}):(0,W.jsx)(EH,{children:`Listing…`}):(0,W.jsx)(EH,{children:`Open a chat to browse the folder it works in.`}),[o,s,g,L,f,m,l,ie,n]);return(0,W.jsxs)(`aside`,{className:`flex w-64 shrink-0 flex-col border-r border-border bg-surface`,"aria-label":`Files`,"data-testid":`file-explorer`,children:[(0,W.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,W.jsx)(q.Folder,{className:`w-3.5 h-3.5 text-fg-faint`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-semibold uppercase tracking-wide text-fg-muted`,title:i?.cwd??void 0,children:re}),(0,W.jsx)(Y,{label:`Refresh files`,className:`p-1`,onClick:P,disabled:!o||s,"data-testid":`file-explorer-refresh`,children:(0,W.jsx)(q.Refresh,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(Y,{label:`Hide files`,className:`p-1`,onClick:ne,children:(0,W.jsx)(q.X,{className:`w-3.5 h-3.5`})})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:R}),(0,W.jsx)(nx,{open:C!==null,at:C?.at??{x:0,y:0},anchorEl:C?.el??null,label:`File actions`,testId:`files-context-menu`,onClose:T,items:te}),(0,W.jsx)(TH,{target:D,absolute:D?d?yj(d,D.path,u):D.path:``,platform:u,busy:k,onConfirm:()=>void I(),onClose:j})]})}function TH({target:e,absolute:t,platform:n,busy:r,onConfirm:i,onClose:a}){let o=e?.type===`dir`;return(0,W.jsx)(Ky,{open:e!==null,title:o?`Delete this folder?`:`Delete this file?`,onClose:a,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{onClick:a,disabled:r,"data-testid":`files-delete-cancel`,children:`Cancel`}),(0,W.jsx)(J,{variant:`danger`,busy:r,onClick:i,"data-testid":`files-delete-confirm`,children:`Delete permanently`})]}),children:(0,W.jsxs)(`div`,{className:`space-y-2 text-sm text-fg-muted`,"data-testid":`files-delete-dialog`,children:[(0,W.jsx)(`p`,{className:`break-all rounded bg-surface-2 px-2 py-1 font-mono text-xs text-fg`,children:t}),(0,W.jsxs)(`p`,{children:[o?`This folder and everything inside it will be deleted from the disk permanently.`:`This file will be deleted from the disk permanently.`,` `,`It does not go to the `,n===`win32`?`Recycle Bin`:`Trash`,`, and it cannot be undone.`]})]})})}function EH({children:e,tone:t}){return(0,W.jsx)(`div`,{className:U(`p-4 text-xs`,t===`danger`?`text-danger`:`text-fg-faint`),children:e})}function DH(e){let t=e.getBoundingClientRect();return{x:t.left+24,y:t.bottom}}function OH(e,t){return{onContextMenu:n=>{n.preventDefault();let r=n.currentTarget;t(e,n.clientX===0&&n.clientY===0?DH(r):{x:n.clientX,y:n.clientY},r)},onKeyDown:n=>{(n.key===`ContextMenu`||n.shiftKey&&n.key===`F10`)&&(n.preventDefault(),t(e,DH(n.currentTarget),n.currentTarget))}}}function kH({rel:e,depth:t,tree:n,expanded:r,activeFile:i,menuPath:a,onToggle:o,onOpen:s,onMenu:c}){let l=n[e];return l?l.error&&!l.entries?(0,W.jsx)(`li`,{className:`px-2 py-1 text-[11px] text-danger`,style:{paddingLeft:`${.5+t*.75}rem`},children:l.error}):l.entries?(0,W.jsx)(W.Fragment,{children:l.entries.map(l=>{let u=mj(e,l.name),d=a===u;if(l.type===`dir`){let e=r.has(u);return(0,W.jsxs)(`li`,{role:`treeitem`,"aria-expanded":e,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>o(u),...OH({path:u,type:`dir`},c),"data-testid":`explorer-dir-${u}`,className:U(`flex w-full items-center gap-1 py-0.5 pr-2 text-left text-xs text-fg hover:bg-surface-2`,d&&`bg-surface-2`),style:{paddingLeft:`${.5+t*.75}rem`},children:[(0,W.jsx)(q.ChevronRight,{className:U(`w-3 h-3 shrink-0 text-fg-faint transition-transform`,e&&`rotate-90`)}),(0,W.jsx)(q.Folder,{className:`w-3.5 h-3.5 shrink-0 text-fg-faint`}),(0,W.jsx)(`span`,{className:`truncate`,children:l.name})]}),e?(0,W.jsx)(`ul`,{role:`group`,children:(0,W.jsx)(kH,{rel:u,depth:t+1,tree:n,expanded:r,activeFile:i,menuPath:a,onToggle:o,onOpen:s,onMenu:c})}):null]},u)}let f=i===u;return(0,W.jsx)(`li`,{role:`treeitem`,"aria-selected":f,children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>s(u),...OH({path:u,type:l.type},c),disabled:l.type!==`file`,"data-testid":`explorer-file-${u}`,title:`${u} · ${Rj(l.size)}`,className:U(`flex w-full items-center gap-1 py-0.5 pr-2 text-left text-xs hover:bg-surface-2 disabled:opacity-50`,f?`bg-accent-soft text-accent`:d?`bg-surface-2 text-fg`:`text-fg`),style:{paddingLeft:`${.5+t*.75+.9}rem`},children:[(0,W.jsx)(q.File,{className:`w-3.5 h-3.5 shrink-0 text-fg-faint`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:l.name}),(0,W.jsx)(`span`,{className:`shrink-0 text-[10px] text-fg-faint`,children:Rj(l.size)})]})},u)})}):(0,W.jsx)(`li`,{className:`px-2 py-1 text-[11px] text-fg-faint`,style:{paddingLeft:`${.5+t*.75}rem`},children:`Listing…`}):null}var AH={autoAccept:{hint:`Allow every tool the agent wants to use, without asking you. Off by default.`,details:[`Answered by this PC itself, so it covers EVERY chat running here — started in this app, the oona terminal, your phone, Telegram, the website or another PC.`,`The agent’s questions to you (its multiple-choice cards) still wait for your answer.`,`A chat set to Ask first in the composer still asks you before each tool — that is what Ask first means.`,`Subagents never ask: their tool requests are always allowed.`,`Takes effect at the next tool request, even in a chat that is already working.`,`What a chat may attempt at all is still its own Build / Plan / Ask first / Autonomous choice in the composer; this only answers the prompts it would have shown you.`]},reasoning:{hint:`Show the model’s thinking between its messages.`,details:[`Display only — the model thinks the same either way.`,`Hidden thinking is also left out of chat search (Ctrl+F).`,`For the windows this PC serves (this app, the local web UI). The phone has its own switch.`]},colourScheme:{hint:`System follows your desktop’s light or dark setting.`,details:[`Also colours this window’s title bar and menu.`,`Your own colours per element are under Theme.`]},notifications:{hint:`Desktop notifications from this app while its window is not in front.`,details:[`Nothing pops up while you are looking at the window.`,`Your phone’s push notifications are separate: the phone buzzes only while no window on this PC is open.`]},notifyFinished:{hint:`When a chat’s turn ends — finished, or failed.`,details:[`Named after the chat; clicking the notification opens it.`]},notifyWaiting:{hint:`When a chat waits for you: a permission, or one of the agent’s questions.`,details:[`With auto-accept on, only the agent’s questions still wait for you, so only they notify.`]},notifyError:{hint:`When a chat stops on an error.`,details:[`The error itself is also written into the chat.`]},transcriptWindow:{hint:`How many messages and tool cards of a chat stay drawn; older ones leave the top like a stack and come back when you scroll up.`,details:[`Only what is DRAWN: the whole chat is still kept, and still searched.`,`Smaller is faster on long agentic chats; larger keeps more on screen.`]},defaultCwd:{hint:`The folder a new chat runs in when it is not given one. Empty: each chat gets its own private folder.`,details:[`A folder here becomes each new chat’s project: its CLAUDE.md, .claude settings, hooks and skills load. Your home folder and drive roots never load as a project.`,`Empty is the safe default: the agent then works only inside that chat’s own folder under OonaCode’s data directory.`,`Used by chats started in this app. A project’s own folder (Projects → New chats) wins over it; the oona terminal always uses the folder you run it in.`]},remoteAccess:{hint:`Let your phone, Telegram, the website and your other PCs reach this PC.`,details:[`This PC keeps one outbound, end-to-end encrypted channel to your OonaCode server; every other device reaches it through that channel alone.`,`It is also how they read this PC’s chats: the chats are kept only here, never on our server, so they can be read while this PC is on and reachable.`,`Off: they still see this PC online, marked “remote access off”, and cannot list or open its chats, send prompts, unlock it remotely or delete its chats. This PC also cannot open chats on your other PCs.`,`Takes effect immediately.`]},imageRetention:{hint:`Pictures in this PC’s chat history older than this are replaced with a short note. 0 keeps them forever. Default: a year.`,details:[`Replaced: the pictures stored in this PC’s chats — screenshots and other pictures a tool returned, and pictures you pasted into a message — once they are older than this.`,`Each becomes a one-line note saying a picture was there, why and when it went, e.g. “[Picture removed after 365 days to save space — picture from a tool (PNG), 412 KB]”.`,`Not affected: the words of every chat, and the files on your disk. The chat continues normally — the model no longer needs pictures that old.`,`Runs by itself: a few minutes after this PC’s OonaCode starts, then once a day, in small steps that never hold up a chat. A chat that is working, or was in the last hour, is done at the next run.`,`The database file stops growing from pictures; it does not shrink. The space is reused for new chats.`,`Only this PC holds its chats, so this is every copy there is.`]},chatAbout:{hint:`A short note per chat saying what it works on, which your other chats read through “Talk to other chats”. On by default.`,details:[`Written in the background by each chat’s housekeeper — the cheap helper model of the chat’s own provider — after a turn ends, only when the chat changed since, and at most once per interval below.`,`The same switch covers Regenerate (in a chat’s session info) and “Generate for all chats now” (View → What chats are about…). Off stops all three, so nothing is spent on abouts.`,`Paid by the chat’s own route: an OonaCode pool chat spends credits, your own API key is billed by your provider, and your own subscription’s plan covers it.`,`An about is part of its chat and stays on this PC: it is never uploaded to our server, and your other devices read it from this PC, like the chat.`]},chatAboutInterval:{hint:`At most one background about per chat in this many minutes.`,details:[`Only the background job waits for it: Regenerate and “Generate for all chats now” write at once.`,`A background about is written only after a turn ends and only when the chat changed, so a chat nobody uses costs nothing, whatever this says.`,`Shorter keeps abouts fresher and makes more calls.`]},chatAboutMaxWords:{hint:`The longest about the housekeeper may write.`,details:[`A longer answer is cut at this many words.`,`Applies to every about the housekeeper writes: in the background, by Regenerate and by “Generate for all chats now”. An about you write yourself may be longer (up to 2,000 characters).`,`A longer about costs a few more output tokens, and a chat that lists your chats reads every one of them.`]},chatAboutInputChars:{hint:`How much of a chat the housekeeper reads to write its about.`,details:[`Taken from the chat’s title, project and folder, its previous about, your first message, the newest summary of the earlier conversation, your latest messages and the agent’s last answer — each with a share, so no part crowds out the others.`,`Applies to the background job, Regenerate and “Generate for all chats now”.`,`Most of what a call costs: roughly a quarter as many tokens as characters. More gives a better-informed about and costs more.`]},keepUnlocked:{hint:`Leave your vault unlocked when you close or quit the app.`,details:[`Off (default): closing the window — to the tray too — or quitting stops the chats that are running and locks this PC until you unlock it. Your phone and other devices cannot use it meanwhile.`,`On: chats keep running and your other devices keep working after the window is closed. Choose it on a PC only you use.`]},server:{hint:`Your account’s OonaCode server.`,details:[`Where your account lives: sign-in, OonaCode-pool models and credits, your encrypted vault, remote access, and app updates.`,`Your own API keys and subscriptions never go through it — this PC calls those providers directly.`,`Set by signing in. (Developers point a build at another server with OONACODE_GATEWAY_URL.)`]},diagnostics:{hint:`While you are signed in, this PC sends OonaCode its warnings and errors, and a short report of any turn that fails.`,details:[`A report names the error, the model and the provider — never the content of your chats.`,`It is how bugs you never reported get fixed. There is no usage tracking.`]},allowDebugging:{hint:`Let a debugger attach to this app’s windows, to see and control them while fixing a bug. Off by default. Takes effect when OonaCode restarts.`,details:[`For finding bugs together: DevTools (chrome://inspect), Playwright or another Chrome DevTools Protocol client attaches to every window of this app — reads what it shows, clicks, types and runs code in it.`,`The risk: while it is on, ANY program on this PC can do the same — read your chats on screen and act as you in OonaCode, with no prompt. Turn it on only while you need it.`,`Only on this PC: the port is opened on 127.0.0.1, never on the network, and web pages in your browser cannot connect to it.`,`Desktop app only, this PC only: the local web UI in a browser, the phone, Telegram and your other PCs are not affected.`,`Read when the app starts, so a change applies at the next start (Restart now). The host service and your chats keep running through the restart.`,`While it is on, every window shows a red “Debugging on” badge and says so in its title.`]},debugPort:{hint:`The port on 127.0.0.1 a debugger connects to.`,details:[`Connect with http://127.0.0.1:<port> — e.g. chrome://inspect → Configure… → localhost:<port>, or Playwright’s connectOverCDP.`,`A port another program already uses is refused when you save.`,`With “Also debug the main process”, the next port is taken too.`]},debugMainProcess:{hint:`Also open Node’s inspector for the app’s main process, on the next port.`,details:[`For bugs in the desktop shell itself (windows, menus, updates, the tray), not in a window’s page.`,`Gives full control of the main process — it can run any program as you. Off unless you choose it.`,`Applies only while “Allow debugging” is on, at the next start.`]}};function jH(e){if(!Cc(e))return`Off in this run: no debugging port is open.`;let t=[];return e.port!==null&&t.push(e.listening?`On in this run: windows on 127.0.0.1:${e.port}${e.fromCommandLine?` (from the command line)`:``}.`:`Port ${e.port} could not be opened — another program may be using it.`),e.inspectPort!==null&&t.push(e.inspectProblem?`Main-process inspector: ${e.inspectProblem}`:`Main process on 127.0.0.1:${e.inspectPort}.`),t.join(` `)}function MH(e){return wc(e.saved,e.running)}function NH(e){return`Debugging is on: ${Tc(e)}. While it is on, any program on this PC can read and control OonaCode. Click to change it in Settings → Developer.`}function PH({providerId:e,configured:t}){let{api:n,state:r,actions:i}=G(),[a,o]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(t||!n.getAgyStatus)return;let e=!0;return n.getAgyStatus().then(t=>{e&&o({state:t.state,install:t.install})},()=>{e&&o(null)}),()=>{e=!1}},[n,t,r.providers]),(0,W.jsx)(J,{size:`sm`,variant:t?`secondary`:`primary`,onClick:()=>i.openProviderConnect(e),"data-testid":`agy-provider-button`,children:$B(t,a)})}function FH(){let{actions:e}=G(),[t,n]=(0,v.useState)(void 0),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(null),s=(0,v.useCallback)(async()=>{n(await e.listSkills())},[e]);return(0,v.useEffect)(()=>{s()},[s]),t===`unsupported`?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`This PC’s OonaCode is older than skills — update it to manage them here.`}):r?(0,W.jsx)(IH,{onDone:()=>{i(!1),cF(),mN(),s()}}):(0,W.jsxs)(`div`,{className:`space-y-3`,"data-testid":`skills-section`,children:[(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Skills every chat on this PC gets — type `,(0,W.jsx)(`span`,{className:`font-mono`,children:`/`}),` in the message box to use one for that message. They work with every model. A change applies from a chat’s next start (a new chat, or one idle for ten minutes).`]}),(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`skills-per-chat-note`,children:[`The model is not shown them on its own: each chat chooses which skills the model may use by itself, in the `,(0,W.jsx)(`span`,{className:`font-medium`,children:`Skills`}),` menu under its message box — only those cost tokens on every message of that chat.`]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(J,{size:`sm`,onClick:()=>i(!0),"data-testid":`skills-import-open`,children:[(0,W.jsx)(q.Download,{className:`h-3.5 w-3.5`}),` Import from Claude Code…`]}),t?(0,W.jsx)(`span`,{className:`truncate text-[11px] text-fg-faint`,title:t.dir,children:t.dir}):null]}),t===void 0?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading…`}):t===null?(0,W.jsx)(`p`,{className:`text-xs text-danger`,children:`The host could not list the skills right now.`}):t.skills.length===0?(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`skills-empty`,children:[`No skills of your own yet. Import them from Claude Code, or put a folder with a`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:`SKILL.md`}),` in the folder above.`]}):(0,W.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.skills.map(t=>(0,W.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2 text-sm`,"data-testid":`skill-row`,"data-name":t.name,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,W.jsxs)(`span`,{className:`font-mono font-medium`,children:[`/`,t.name]}),t.argumentHint?(0,W.jsx)(`span`,{className:`font-mono text-xs text-fg-faint`,children:t.argumentHint}):null,t.broken?(0,W.jsx)(Z,{tone:`warn`,children:`no SKILL.md`}):null]}),t.description?(0,W.jsx)(`div`,{className:`line-clamp-2 text-xs text-fg-muted`,title:t.description,children:t.description}):null,(0,W.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[Rj(t.bytes),` · `,t.files,` file`,t.files===1?``:`s`,t.importedFrom?(0,W.jsxs)(W.Fragment,{children:[` `,`· imported `,t.importedAt?ag(t.importedAt):``,` from`,` `,(0,W.jsx)(`span`,{title:t.importedFrom,children:t.importedFrom})]}):null]})]}),(0,W.jsxs)(J,{size:`sm`,variant:`ghost`,busy:a===t.name,"aria-label":`Remove ${t.name}`,onClick:async()=>{o(t.name);let n=await e.removeSkill(t.name);o(null),n&&(cF(),mN(),await s())},"data-testid":`skill-remove`,children:[(0,W.jsx)(q.Trash,{className:`h-3.5 w-3.5`}),` Remove`]})]},t.name))})]})}function IH({onDone:e}){let{actions:t}=G(),[n,r]=(0,v.useState)(void 0),[i,a]=(0,v.useState)(()=>new Set),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null);(0,v.useEffect)(()=>{let e=!0;return t.scanClaudeSkills().then(t=>{e&&r(t)}),()=>{e=!1}},[t]);let f=(0,v.useMemo)(()=>{let e=new Map;for(let t of n?.skills??[]){let n=t.origin===`plugin`?`Plugin: ${t.plugin??`?`}`:`Your skills`;e.set(n,[...e.get(n)??[],t])}return[...e.entries()]},[n]),p=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,W.jsxs)(`div`,{className:`space-y-3`,"data-testid":`skills-import`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:e,children:`← Back`}),(0,W.jsx)(`span`,{className:`text-sm font-medium`,children:`Import skills from Claude Code`})]}),(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Tick the skills to copy into OonaCode. Your Claude Code install is only read — nothing in it is changed.`,n?.roots.length?(0,W.jsxs)(W.Fragment,{children:[` `,`Read from `,(0,W.jsx)(`span`,{className:`font-mono`,children:n.roots.join(`, `)}),`.`]}):null]}),n===void 0?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Looking…`}):n===null?(0,W.jsx)(`p`,{className:`text-xs text-danger`,children:`The host could not read Claude Code’s skills.`}):n.skills.length===0?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`skills-import-empty`,children:`No skills found in Claude Code on this PC.`}):f.map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wide text-fg-faint`,children:e}),(0,W.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>{let t=!!e.unavailable||e.alreadyInOonaCode&&!o;return(0,W.jsx)(`li`,{className:`px-3 py-1.5 text-sm`,children:(0,W.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:i.has(e.key)&&!t,disabled:t,onChange:()=>p(e.key),"data-testid":`skills-import-pick`,"data-name":e.name}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{className:`font-mono font-medium`,children:[`/`,e.name]}),` `,e.alreadyInOonaCode?(0,W.jsx)(Z,{children:`already in OonaCode`}):null,` `,e.unavailable?(0,W.jsx)(Z,{tone:`warn`,children:e.unavailable}):null,e.description?(0,W.jsx)(`span`,{className:`line-clamp-2 block text-xs text-fg-muted`,children:e.description}):null,e.note?(0,W.jsx)(`span`,{className:`block text-[11px] text-warn`,children:e.note}):null,(0,W.jsxs)(`span`,{className:`block text-[11px] text-fg-faint`,children:[Rj(e.bytes),` · `,e.path]})]})]})},e.key)})})]},e)),n&&n.skills.some(e=>e.alreadyInOonaCode)?(0,W.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Replace the ones already in OonaCode`]}):null,u?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,role:`status`,"data-testid":`skills-import-outcome`,children:u}):null,(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(J,{variant:`primary`,size:`sm`,busy:c,disabled:i.size===0,"data-testid":`skills-import-go`,onClick:async()=>{l(!0);let n=await t.importClaudeSkills([...i],o);if(l(!1),!n)return;let r=n.skipped.map(e=>`${e.name||e.key}: ${e.reason}`);d(`Imported ${n.imported.length}`+(r.length>0?` · skipped ${r.join(`; `)}`:``)),n.skipped.length===0&&e()},children:[`Import `,i.size>0?i.size:``]}),(0,W.jsx)(J,{size:`sm`,onClick:e,children:`Cancel`})]})]})}var LH=[{id:`general`,label:`General`,icon:q.Settings},{id:`theme`,label:`Theme`,icon:q.Palette},{id:`advanced`,label:`Advanced`,icon:q.Sliders},{id:`skills`,label:`Skills`,icon:q.Tool},{id:`providers`,label:`Providers`,icon:q.Plug},{id:`devices`,label:`Devices`,icon:q.Monitor},{id:`host`,label:`This PC`,icon:q.Stethoscope},{id:`developer`,label:`Developer`,icon:q.Bug}];function RH(){let e=typeof window<`u`?window.oonacode:void 0;return e?.getDebugging&&e.setDebugging?e:null}function zH(){let{state:e,actions:t}=G(),n=e.prefs,r=e.settings?.theme??`system`;return(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(qy,{label:`Auto-accept permissions`,hint:AH.autoAccept.hint,details:AH.autoAccept.details,checked:n.autoAcceptPermissions,onChange:e=>void t.savePrefs({autoAcceptPermissions:e}),testId:`settings-auto-accept`}),(0,W.jsx)(qy,{label:`Show reasoning in the timeline`,hint:AH.reasoning.hint,details:AH.reasoning.details,checked:n.showReasoningSummaries,onChange:e=>void t.savePrefs({showReasoningSummaries:e})}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border py-3`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Colour scheme`,(0,W.jsx)(Hy,{label:`Colour scheme`,details:(0,W.jsx)(Uy,{items:AH.colourScheme.details})})]}),(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-faint`,children:AH.colourScheme.hint})]}),(0,W.jsx)(Jy,{label:`Colour scheme`,value:r,options:[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}],onChange:e=>void t.saveSettings({theme:e})})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-2`,children:[(0,W.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,W.jsx)(q.Bell,{className:`w-3 h-3`}),` Notifications`,(0,W.jsx)(Hy,{label:`Notifications`,details:(0,W.jsx)(Uy,{items:AH.notifications.details})})]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-faint`,children:AH.notifications.hint}),(0,W.jsx)(qy,{label:`Agent finished or needs attention`,hint:AH.notifyFinished.hint,details:AH.notifyFinished.details,checked:n.notifications.agentFinished,onChange:e=>void t.savePrefs({notifications:{...n.notifications,agentFinished:e}})}),(0,W.jsx)(qy,{label:`Permission or question waiting for you`,hint:AH.notifyWaiting.hint,details:AH.notifyWaiting.details,checked:n.notifications.permissionRequired,onChange:e=>void t.savePrefs({notifications:{...n.notifications,permissionRequired:e}})}),(0,W.jsx)(qy,{label:`Error occurred`,hint:AH.notifyError.hint,details:AH.notifyError.details,checked:n.notifications.errorOccurred,onChange:e=>void t.savePrefs({notifications:{...n.notifications,errorOccurred:e}})})]}),e.prefsBackend===`local`?(0,W.jsx)(`div`,{className:`mt-2 rounded-md bg-warn-soft px-3 py-2 text-xs text-warn`,children:`This host does not store UI preferences yet, so they are kept on this device only.`}):null]})}function BH(e){let t=e.replace(/-/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function VH(e){let t={};if(typeof document>`u`||typeof getComputedStyle!=`function`)return t;let n=document.documentElement,r=n.getAttribute(`data-theme`),i=[];for(let e of Fc){let t=n.style.getPropertyValue(`--${e}`);t&&i.push([e,t]),n.style.removeProperty(`--${e}`)}n.setAttribute(`data-theme`,e);let a=getComputedStyle(n);for(let e of Fc){let n=a.getPropertyValue(`--${e}`).trim();t[e]=/^#[0-9a-fA-F]{6}$/.test(n)?n.toLowerCase():`#808080`}r===null?n.removeAttribute(`data-theme`):n.setAttribute(`data-theme`,r);for(let[e,t]of i)n.style.setProperty(`--${e}`,t);return t}function HH(){let{state:e,actions:t}=G(),n=e.prefs,[r,i]=(0,v.useState)(`dark`),a=(0,v.useMemo)(()=>VH(r),[r]),[o,s]=(0,v.useState)({}),c=(0,v.useRef)(o);c.current=o;let l=(0,v.useRef)(n.themeColors);l.current=n.themeColors;let u=(0,v.useRef)(null),d=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)};(0,v.useEffect)(()=>d,[]);let f=e=>{d();let n=c.current;Object.keys(n).length!==0&&(s({}),t.savePrefs({themeColors:{...l.current,[e]:{...l.current[e],...n}}}))},p=(e,t)=>{s(n=>({...n,[e]:t})),c.current={...c.current,[e]:t},d(),u.current=window.setTimeout(()=>f(r),300)},m={...l.current[r],...o},h=Object.keys(m).length,g=e=>{d(),s({});let n={...m};delete n[e],t.savePrefs({themeColors:{...l.current,[r]:n}})};return(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:`Theme colours`}),(0,W.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-faint`,children:`Choose any colour for any element. A colour you do not choose keeps the theme's own value. Your colours follow your account to every PC.`})]}),(0,W.jsx)(Jy,{label:`Edit colour scheme`,value:r,options:[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],onChange:e=>{f(r),i(e)}})]}),(0,W.jsx)(`div`,{className:`grid grid-cols-1 gap-x-4 sm:grid-cols-2`,children:Fc.map(e=>{let t=m[e]!==void 0,n=m[e]??a[e]??`#808080`;return(0,W.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border py-1.5`,"data-testid":`theme-color-row-${r}-${e}`,children:[(0,W.jsx)(`input`,{type:`color`,className:`h-6 w-9 shrink-0 cursor-pointer rounded border border-border bg-transparent p-0.5`,value:n,onChange:t=>p(e,t.target.value),"aria-label":`${BH(e)} colour (${r} scheme)`,"data-testid":`theme-color-${r}-${e}`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:BH(e)}),(0,W.jsx)(`span`,{className:`w-16 shrink-0 text-right font-mono text-[10px] text-fg-faint`,children:t?m[e]:`default`}),t?(0,W.jsx)(Y,{label:`Reset ${BH(e)} to the theme colour`,className:`p-0.5`,"data-testid":`theme-color-clear-${r}-${e}`,onClick:()=>g(e),children:(0,W.jsx)(q.Refresh,{className:`w-3 h-3`})}):null]},e)})}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border pt-2`,children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,"data-testid":`theme-colors-count`,children:h===0?`No custom colours in the ${r} scheme.`:`${h} custom colour${h===1?``:`s`} in the ${r} scheme.`}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>{d(),s({}),t.savePrefs({themeColors:{...l.current,[r]:{}}})},disabled:h===0,"data-testid":`theme-reset-${r}`,children:`Reset all`})]})]})}function UH(){let{state:e,actions:t}=G(),n=e.prefs,[r,i]=(0,v.useState)(String(n.transcriptWindowSize));return(0,v.useEffect)(()=>i(String(n.transcriptWindowSize)),[n.transcriptWindowSize]),(0,W.jsx)(`div`,{className:`space-y-1`,children:(0,W.jsx)(Wy,{label:`Transcript window size`,hint:`${AH.transcriptWindow.hint} Scrolling to the top brings back 100 more. 100–${Nc}, default 500.`,details:AH.transcriptWindow.details,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{className:U(X,`w-32`),type:`number`,min:100,max:Nc,step:100,value:r,onChange:e=>i(e.target.value),onBlur:()=>{let e=Number.parseInt(r,10);Number.isFinite(e)&&t.savePrefs({transcriptWindowSize:e})},"aria-label":`Transcript window size`}),(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,children:`messages and tool cards`})]})})})}function WH(){let{state:e,actions:t}=G(),n=(0,v.useMemo)(()=>Os(e.providers),[e.providers]);return(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[n.length===0?(0,W.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`No providers in the registry.`}):null,n.map(n=>{let r=n.definition,i=e.activeProviderId===r.id,a=Ds(e.providers,r.id),o=a.some(e=>e.configured),s=[...new Set(a.flatMap(e=>(e.credentials??[]).map(e=>e.class)))].filter(e=>e!==`none`);return(0,W.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border px-3 py-2`,"data-testid":`provider-${r.id}`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium`,children:r.displayName}),i?(0,W.jsx)(Z,{tone:`accent`,children:`active`}):null,r.route===`direct`?(0,W.jsx)(Z,{tone:`ok`,children:`direct`}):null,s.length>0?s.map(e=>(0,W.jsxs)(Z,{tone:`ok`,children:[e===`subscription`?`subscription`:`API key`,` connected`]},e)):o?(0,W.jsx)(Z,{tone:`ok`,children:`connected`}):(0,W.jsx)(Z,{tone:`warn`,children:`not connected`})]}),(0,W.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[r.models.length,` model`,r.models.length===1?``:`s`,r.credentialVariants?.length?` · ${r.credentialVariants.map(e=>e.label).join(` / `)}`:``]})]}),r.engine===`agy`?(0,W.jsx)(PH,{providerId:r.id,configured:o}):(0,W.jsxs)(J,{size:`sm`,variant:o?`secondary`:`primary`,onClick:()=>t.openProviderConnect(r.id),children:[(0,W.jsx)(q.Plus,{className:`w-3 h-3`}),` `,o?`Manage…`:`Connect`]})]},r.id)}),(0,W.jsx)(`div`,{className:`pt-3`,children:(0,W.jsx)(jR,{})})]})}function GH(){let{state:e,actions:t}=G(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(``);return(0,v.useEffect)(()=>{t.refreshHosts()},[t]),e.account?.loggedIn?e.remote.supported?(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[e.remote.loading?(0,W.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-fg-muted`,children:[(0,W.jsx)(q.Spinner,{}),` Loading devices…`]}):null,e.remote.hosts.map(e=>(0,W.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border px-3 py-2`,children:[(0,W.jsx)(q.Monitor,{className:`w-4 h-4 shrink-0 text-fg-faint`}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:n===e.hostId?(0,W.jsx)(`input`,{className:X,value:i,autoFocus:!0,"aria-label":`Label for ${e.hostName}`,onChange:e=>a(e.target.value),onKeyDown:n=>{n.key===`Enter`&&i.trim()?(t.renameHost(e.hostId,i.trim()),r(null)):n.key===`Escape`&&r(null)}}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[e.label||e.hostName,e.isSelf?(0,W.jsx)(Z,{tone:`accent`,children:`this PC`}):null,(0,W.jsx)(Z,{tone:e.online?`ok`:`neutral`,children:e.online?`online`:`offline`}),e.remoteAccessOff?(0,W.jsx)(Z,{tone:`warn`,children:`remote access off`}):null]}),(0,W.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[e.platform,e.appVersion?` · v${e.appVersion}`:``,e.lastSeenAt?` · seen ${ag(e.lastSeenAt)}`:``]})]})}),n===e.hostId?(0,W.jsx)(J,{size:`sm`,variant:`primary`,onClick:()=>{i.trim()&&t.renameHost(e.hostId,i.trim()),r(null)},children:`Save`}):(0,W.jsxs)(J,{size:`sm`,onClick:()=>{r(e.hostId),a(e.label||e.hostName)},children:[(0,W.jsx)(q.Edit,{className:`w-3 h-3`}),` Rename`]})]},e.hostId)),!e.remote.loading&&e.remote.hosts.length===0?(0,W.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`No devices reported yet.`}):null]}):(0,W.jsxs)(`div`,{className:`rounded-md border border-border px-3 py-3 text-sm text-fg-muted`,children:[`This PC's OonaCode is too old to list your account's devices — update it. This PC is`,` `,(0,W.jsx)(`strong`,{children:e.connection.hostName??`unknown`}),`.`]}):(0,W.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`Sign in to see the devices on your account.`})}function KH(e,t,n=Date.now()){if(e===0)return`Off — pictures are kept forever.`;if(!t)return`Not run yet — it runs a few minutes after OonaCode starts, then daily.`;let r=ag(t.finishedAt,n);return t.pictures===0?`Last run: nothing to replace, ${r}.`:`Last run: ${t.pictures.toLocaleString(`en-US`)} ${t.pictures===1?`picture`:`pictures`}, ${Rj(t.bytesFreed)}, ${r}.`}function qH({days:e,lastRun:t,onSave:n}){let[r,i]=(0,v.useState)(String(e));(0,v.useEffect)(()=>i(String(e)),[e]);let a=()=>{let t=Number.parseInt(r,10);if(!Number.isFinite(t)){i(String(e));return}let a=t<=0?0:Math.min($c,Math.max(1,t));i(String(a)),a!==e&&n(a)};return(0,W.jsxs)(Wy,{label:`Replace pictures older than`,hint:AH.imageRetention.hint,details:AH.imageRetention.details,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{className:U(X,`w-24`),type:`number`,min:0,max:$c,step:1,value:r,onChange:e=>i(e.target.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`&&a()},"aria-label":`Replace pictures older than (days)`,"data-testid":`settings-image-retention`}),(0,W.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`days`,e===365?` (a year)`:``]})]}),(0,W.jsx)(`span`,{className:`text-xs text-fg-muted`,"data-testid":`settings-image-retention-status`,children:KH(e,t)})]})}function JH(e,t,n){let r=e.trim(),i=Number(r);return!/^\d+$/.test(r)||i<t||i>n?`A whole number from ${t.toLocaleString(`en-US`)} to ${n.toLocaleString(`en-US`)}.`:null}function YH({label:e,unit:t,hint:n,details:r,value:i,min:a,max:o,defaultValue:s,onSave:c,testId:l}){let[u,d]=(0,v.useState)(String(i)),[f,p]=(0,v.useState)(null);(0,v.useEffect)(()=>{d(String(i)),p(null)},[i]);let m=()=>{let e=JH(u,a,o);if(p(e),e)return;let t=Number(u.trim());t!==i&&c(t)},h=e=>e.toLocaleString(`en-US`);return(0,W.jsxs)(Wy,{label:e,hint:`${n} ${h(a)}–${h(o)}, default ${h(s)}.`,details:r,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{className:U(X,`w-28`,f&&`border-danger`),type:`number`,min:a,max:o,step:1,value:u,onChange:e=>d(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m()},"aria-label":e,"aria-invalid":f!==null,"data-testid":l}),(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,children:t})]}),f?(0,W.jsx)(`span`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`${l}-problem`,children:f}):null]})}function XH({settings:e}){let{actions:t}=G(),n=ql,r=Kl;return(0,W.jsxs)(`div`,{className:`border-t border-border pt-3`,"data-testid":`settings-chat-abouts`,children:[(0,W.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Chat abouts`}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>t.openChatAbouts(),"data-testid":`settings-open-chat-abouts`,children:`What your chats are about…`})]}),e.chatAboutEnabled===void 0?null:(0,W.jsx)(qy,{label:`Write an about for every chat`,hint:AH.chatAbout.hint,details:AH.chatAbout.details,checked:e.chatAboutEnabled,onChange:e=>void t.saveSettings({chatAboutEnabled:e}),testId:`settings-chat-about-enabled`}),(0,W.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[e.chatAboutIntervalMinutes===void 0?null:(0,W.jsx)(YH,{label:`Minutes between background abouts`,unit:`minutes`,hint:AH.chatAboutInterval.hint,details:AH.chatAboutInterval.details,value:e.chatAboutIntervalMinutes,min:n.intervalMinutes.min,max:n.intervalMinutes.max,defaultValue:r.intervalMinutes,onSave:e=>void t.saveSettings({chatAboutIntervalMinutes:e}),testId:`settings-chat-about-interval`}),e.chatAboutMaxWords===void 0?null:(0,W.jsx)(YH,{label:`Longest about`,unit:`words`,hint:AH.chatAboutMaxWords.hint,details:AH.chatAboutMaxWords.details,value:e.chatAboutMaxWords,min:n.maxWords.min,max:n.maxWords.max,defaultValue:r.maxWords,onSave:e=>void t.saveSettings({chatAboutMaxWords:e}),testId:`settings-chat-about-max-words`}),e.chatAboutInputChars===void 0?null:(0,W.jsx)(YH,{label:`How much of a chat is read`,unit:`characters`,hint:AH.chatAboutInputChars.hint,details:AH.chatAboutInputChars.details,value:e.chatAboutInputChars,min:n.inputChars.min,max:n.inputChars.max,defaultValue:r.inputChars,onSave:e=>void t.saveSettings({chatAboutInputChars:e}),testId:`settings-chat-about-input-chars`})]})]})}function ZH(){let{state:e,actions:t}=G(),n=e.settings,[r,i]=(0,v.useState)(n?.defaultCwd??``);if((0,v.useEffect)(()=>i(n?.defaultCwd??``),[n?.defaultCwd]),(0,v.useEffect)(()=>{t.refreshSettings()},[t]),!n)return(0,W.jsx)(`div`,{className:`py-6 text-sm text-fg-muted`,children:`Loading settings…`});let a=e.account?.gatewayUrl??n.gatewayUrl??x,o=e=>{let r=e.trim()?e.trim():null;r!==(n.defaultCwd??null)&&t.saveSettings({defaultCwd:r})},s=async()=>{let e=await window.oonacode?.pickDirectory?.({title:`The folder new chats run in`,...r?{defaultPath:r}:{}});e&&(i(e),o(e))};return(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsx)(Wy,{label:`Default working directory`,hint:AH.defaultCwd.hint,details:AH.defaultCwd.details,children:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{className:U(X,`flex-1 font-mono text-xs`),value:r,onChange:e=>i(e.target.value),onBlur:()=>o(r),placeholder:`Empty — each chat gets its own folder`,spellCheck:!1,"data-testid":`settings-default-cwd`}),window.oonacode?.pickDirectory?(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>void s(),children:`Choose…`}):null,r?(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>{i(``),o(``)},children:`Clear`}):null]})}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-1`,children:[(0,W.jsx)(qy,{label:`Remote access`,hint:AH.remoteAccess.hint,details:AH.remoteAccess.details,checked:n.relayEnabled??!0,onChange:e=>void t.saveSettings({relayEnabled:e}),testId:`settings-relay`}),(0,W.jsx)(qy,{label:`Keep the vault unlocked when the app closes`,hint:AH.keepUnlocked.hint,details:AH.keepUnlocked.details,checked:n.keepUnlockedOnExit??!1,onChange:e=>void t.saveSettings({keepUnlockedOnExit:e}),testId:`settings-keep-unlocked-exit`})]}),n.imageRetentionDays===void 0?null:(0,W.jsx)(`div`,{className:`border-t border-border pt-3`,children:(0,W.jsx)(qH,{days:n.imageRetentionDays,lastRun:n.imageRetentionLastRun??null,onSave:e=>void t.saveSettings({imageRetentionDays:e})})}),n.chatAboutEnabled!==void 0||n.chatAboutIntervalMinutes!==void 0||n.chatAboutMaxWords!==void 0||n.chatAboutInputChars!==void 0?(0,W.jsx)(XH,{settings:n}):null,(0,W.jsxs)(`div`,{className:`space-y-2 border-t border-border pt-3 text-xs`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Server`,(0,W.jsx)(Hy,{label:`Server`,details:(0,W.jsx)(Uy,{items:AH.server.details})})]}),(0,W.jsx)(`span`,{className:`block text-fg-faint`,children:AH.server.hint})]}),(0,W.jsx)(`span`,{className:`break-all font-mono text-fg-muted`,"data-testid":`settings-server`,children:a})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Diagnostics`,(0,W.jsx)(Hy,{label:`Diagnostics`,details:(0,W.jsx)(Uy,{items:AH.diagnostics.details})})]}),(0,W.jsx)(`span`,{className:`block text-fg-faint`,children:AH.diagnostics.hint})]})]})]})}function QH(e){return e instanceof Error?e.message:String(e)}function $H(){let e=RH(),[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(null),l=(0,v.useRef)(Promise.resolve());if((0,v.useEffect)(()=>{if(!e?.getDebugging)return;let t=!0;return e.getDebugging().then(e=>{t&&(n(e),o(String(e.saved.port)))},e=>{t&&i(QH(e))}),()=>{t=!1}},[e]),!e)return(0,W.jsx)(`div`,{className:`py-6 text-sm text-fg-muted`,children:`Debugging is a setting of the OonaCode desktop app.`});if(!t)return r?(0,W.jsx)(`div`,{className:`py-6 text-sm text-danger`,role:`alert`,children:r}):(0,W.jsx)(`div`,{className:`py-6 text-sm text-fg-muted`,children:`Loading…`});let u=t=>{l.current=l.current.then(async()=>{try{let r=await e.setDebugging(t);n(r.state),i(r.ok?null:r.problem??`Not saved.`),r.ok&&o(String(r.state.saved.port))}catch(e){i(QH(e))}})},d=()=>{let e=a.trim(),n=/^\d+$/.test(e)?Number(e):NaN,r=Sc(n);if(r){i(r);return}if(n===t.saved.port){i(null);return}u({port:n})},f=async()=>{try{let t=await e.relaunchApp();t.started?c(t.message||`OonaCode is restarting…`):i(t.message||`OonaCode could not restart.`)}catch(e){i(QH(e))}},p=MH(t),m=r!==null&&/^(The port|Ports?) /.test(r);return(0,W.jsxs)(`div`,{className:`space-y-3`,"data-testid":`settings-developer`,children:[(0,W.jsx)(qy,{label:`Allow debugging`,hint:AH.allowDebugging.hint,details:AH.allowDebugging.details,checked:t.saved.enabled,onChange:e=>u({enabled:e}),testId:`settings-allow-debugging`}),(0,W.jsx)(Wy,{label:`Debugging port`,hint:`${AH.debugPort.hint} ${_c}–${vc}, default ${gc}.`,details:AH.debugPort.details,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{className:U(X,`max-w-28`,m&&`border-danger`),type:`number`,min:_c,max:vc,step:1,value:a,onChange:e=>o(e.target.value),onBlur:d,onKeyDown:e=>{e.key===`Enter`&&d()},"aria-label":`Debugging port`,"aria-invalid":m,"data-testid":`settings-debug-port`}),(0,W.jsx)(`span`,{className:`whitespace-nowrap text-xs text-fg-faint`,children:`on 127.0.0.1`})]})}),(0,W.jsx)(qy,{label:`Also debug the main process`,hint:AH.debugMainProcess.hint,details:AH.debugMainProcess.details,checked:t.saved.inspectMain,disabled:!t.saved.enabled,onChange:e=>u({inspectMain:e}),testId:`settings-debug-main`}),r?(0,W.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`settings-debugging-problem`,children:r}):null,(0,W.jsxs)(`div`,{className:`rounded-md border border-border px-3 py-2 text-xs`,"data-testid":`settings-debugging-status`,children:[(0,W.jsx)(`div`,{className:`text-fg-muted`,children:jH(t.running)}),p?(0,W.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-warn`,"data-testid":`settings-debugging-restart-note`,children:`Takes effect when OonaCode restarts. The host service and your chats keep running.`}),(0,W.jsx)(J,{size:`sm`,variant:`primary`,onClick:()=>void f(),disabled:s!==null||!e.relaunchApp,"data-testid":`settings-debugging-restart`,children:`Restart now`})]}):null,s?(0,W.jsx)(`div`,{className:`mt-1 text-fg-faint`,children:s}):null]})]})}function eU({open:e,onClose:t}){let{state:n,actions:r}=G(),[i,a]=(0,v.useState)(`general`),o=n.ui.settingsSection;(0,v.useEffect)(()=>{e&&o&&a(o)},[e,o]),(0,v.useEffect)(()=>{e&&!n.settings&&r.refreshSettings()},[e,n.settings,r]);let s=RH()!==null,c=s?LH:LH.filter(e=>e.id!==`developer`);return(0,W.jsx)(Ky,{open:e,title:`Settings`,onClose:t,wide:!0,footer:(0,W.jsx)(J,{onClick:t,children:`Done`}),children:(0,W.jsxs)(`div`,{className:`flex min-h-[22rem] gap-4`,children:[(0,W.jsxs)(`nav`,{className:`w-36 shrink-0 space-y-0.5`,"aria-label":`Settings sections`,children:[c.map(e=>{let t=e.icon;return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),"aria-current":i===e.id?`true`:void 0,className:U(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,i===e.id?`bg-accent-soft font-medium text-accent`:`text-fg-muted hover:bg-surface-2`),children:[(0,W.jsx)(t,{className:`w-3.5 h-3.5`}),e.label]},e.id)}),(0,W.jsxs)(`div`,{className:`pt-3 text-[11px] text-fg-faint`,children:[`OonaCode Desktop v`,Gv(typeof window<`u`&&window.oonacode?.appVersion||n.connection.appVersion||`0.0.0`,Wv({bridge:typeof window<`u`?window.oonacode:void 0,info:n.info}))]})]}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i===`general`?(0,W.jsx)(zH,{}):null,i===`theme`?(0,W.jsx)(HH,{}):null,i===`advanced`?(0,W.jsx)(UH,{}):null,i===`skills`?(0,W.jsx)(FH,{}):null,i===`providers`?(0,W.jsx)(WH,{}):null,i===`devices`?(0,W.jsx)(GH,{}):null,i===`host`?(0,W.jsx)(ZH,{}):null,i===`developer`&&s?(0,W.jsx)($H,{}):null]})]})})}function tU({toast:e}){let{actions:t}=G();(0,v.useEffect)(()=>{let n=setTimeout(()=>t.dismissToast(e.id),e.kind===`error`?9e3:5e3);return()=>clearTimeout(n)},[e.id,e.kind,t]);let n=e.kind===`error`?`border-danger/50 bg-danger-soft text-danger`:e.kind===`success`?`border-ok/50 bg-ok-soft text-ok`:`border-border bg-surface text-fg`;return(0,W.jsxs)(`div`,{role:e.kind===`error`?`alert`:`status`,className:U(`pointer-events-auto flex max-w-sm items-start gap-2 rounded-md border px-3 py-2 text-sm shadow-md`,n),children:[e.kind===`error`?(0,W.jsx)(q.Alert,{className:`mt-0.5 w-4 h-4`}):e.kind===`success`?(0,W.jsx)(q.Check,{className:`mt-0.5 w-4 h-4`}):null,(0,W.jsx)(`div`,{className:`pre-wrap min-w-0 flex-1`,children:e.text}),(0,W.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,className:`opacity-60 hover:opacity-100`,onClick:()=>t.dismissToast(e.id),children:(0,W.jsx)(q.X,{className:`w-3.5 h-3.5`})})]})}function nU(){let{state:e}=G();return e.toasts.length===0?null:(0,W.jsx)(`div`,{className:`pointer-events-none fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.toasts.map(e=>(0,W.jsx)(tU,{toast:e},e.id))})}var rU=2e3;function iU(e){if(!aU(e))return;let t=typeof window<`u`?window.oonacode:void 0;if(t?.openExternal){t.openExternal(e).catch(()=>void 0);return}typeof window<`u`&&window.open(e,`_blank`,`noopener,noreferrer`)}function aU(e){if(typeof e!=`string`||e===``)return!1;try{let{protocol:t}=new URL(e);return t===`http:`||t===`https:`}catch{return!1}}function oU(e){if(e.message)return e.message;switch(e.status){case`denied`:return`That request was denied in the browser. Start again if it was you.`;case`expired`:return`The code expired before it was approved. Start again for a fresh one.`;default:return`The sign-in could not be started. Check that this PC can reach the gateway.`}}function sU({children:e,testId:t}){let{state:n}=G(),r=n.connection.hostName??n.info?.hostName??null;return(0,W.jsxs)(`div`,{className:`flex h-full flex-col bg-bg text-fg`,"data-testid":t,children:[(0,W.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-surface px-3`,children:[(0,W.jsx)(`span`,{className:`font-semibold tracking-tight`,children:`OonaCode`}),r?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-fg-faint`,children:`/`}),(0,W.jsx)(`span`,{className:`truncate text-sm text-fg-muted`,"data-testid":`frame-host-name`,children:r})]}):null]}),(0,W.jsx)(`main`,{className:`flex min-h-0 flex-1 items-start justify-center overflow-y-auto p-6`,children:(0,W.jsx)(`div`,{className:`w-full max-w-md py-6`,children:e})}),(0,W.jsx)(nU,{})]})}function cU(){return(0,W.jsx)(sU,{testId:`account-loading`,children:(0,W.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,W.jsx)(q.Spinner,{className:`w-4 h-4`}),(0,W.jsx)(`span`,{children:`Checking your account…`})]})})}function lU({link:e}){let{actions:t}=G(),[n,r]=(0,v.useState)(!1),i=e.verificationUrl??``,a=e.verificationUrlComplete??i,o=aU(a),s=t.refreshAccountLink;return(0,v.useEffect)(()=>{let e=setInterval(()=>void s(),rU);return()=>clearInterval(e)},[s]),(0,W.jsxs)(`div`,{className:`space-y-3`,"data-testid":`link-waiting`,children:[(0,W.jsxs)(`ol`,{className:`space-y-2 text-sm`,children:[(0,W.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:`1. Open`}),o?(0,W.jsx)(`a`,{className:`break-all font-medium text-accent underline`,href:a,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`link-url`,onClick:e=>{window.oonacode?.openExternal&&(e.preventDefault(),iU(a))},children:i}):(0,W.jsx)(`span`,{className:`break-all font-medium`,"data-testid":`link-url`,children:i})]}),(0,W.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:`2. Enter`}),(0,W.jsx)(`span`,{className:`select-all rounded-md border border-border bg-surface-2 px-2.5 py-1 font-mono text-base tracking-widest`,"data-testid":`link-user-code`,children:e.userCode})]})]}),(0,W.jsxs)(`p`,{className:`flex items-center gap-2 text-xs text-fg-muted`,role:`status`,children:[(0,W.jsx)(q.Spinner,{className:`w-3.5 h-3.5`}),(0,W.jsx)(`span`,{children:`Waiting for approval in your browser…`})]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-faint`,children:`Approve this code only if you are looking at it on your own screen right now. It is good for a few minutes and can be used once.`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o?(0,W.jsxs)(J,{size:`sm`,onClick:()=>iU(a),"data-testid":`link-reopen`,children:[(0,W.jsx)(q.LogIn,{className:`w-3.5 h-3.5`}),` Open the browser again`]}):null,(0,W.jsx)(J,{size:`sm`,variant:`ghost`,busy:n,"data-testid":`link-cancel`,onClick:()=>{r(!0),t.cancelAccountLink().finally(()=>r(!1))},children:`Cancel`})]})]})}function uU(e){if(typeof e!=`string`||e===``)return null;try{let t=new URL(e).hostname;if(!t)return null;let n=/^api(?:-([a-z0-9-]+))?.(.+)$/i.exec(t),r=n?.[2];return n&&r?n[1]?n[1]+`.`+r:r:t}catch{return null}}function dU(){let{state:e,actions:t}=G(),n=e.accountLink,r=uU(n?.verificationUrl??e.settings?.gatewayUrl??e.account?.gatewayUrl??null),[i,a]=(0,v.useState)(!1),o=(0,v.useCallback)(async()=>{a(!0);try{let e=await t.startAccountLink();e?.status===`waiting`&&iU(e.verificationUrlComplete??e.verificationUrl??``)}finally{a(!1)}},[t]);if(n?.status===`waiting`)return(0,W.jsx)(lU,{link:n});let s=n&&(n.status===`denied`||n.status===`expired`);return(0,W.jsxs)(`div`,{className:`space-y-2`,children:[s?(0,W.jsx)(`p`,{role:`status`,"data-testid":`link-refused`,className:`rounded-md border border-warn/50 bg-warn-soft px-3 py-2 text-xs text-fg`,children:oU(n)}):null,(0,W.jsxs)(J,{variant:`primary`,busy:i,onClick:()=>void o(),"data-testid":`link-start`,className:`w-full justify-center`,children:[(0,W.jsx)(q.LogIn,{className:`w-3.5 h-3.5`}),s?`Try again in your browser`:`Sign in with your browser`]}),(0,W.jsxs)(`p`,{className:`text-xs text-fg-faint`,"data-testid":`link-site-note`,children:[`Opens `,r??`your account page`,` and shows a short code to confirm. Your password is never typed on this machine, and this PC never sees anyone else's.`]})]})}function fU(){let{state:e}=G(),[t,n]=(0,v.useState)(!1),r=t||e.emailVerification!==null;return(0,W.jsx)(sU,{testId:`sign-in-view`,children:(0,W.jsxs)(`div`,{className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Sign in to use OonaCode`}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`OonaCode runs the agent on this PC, with your own providers — but it needs an OonaCode account. There is no guest mode.`})]}),(0,W.jsx)(dU,{}),(0,W.jsx)(`div`,{className:U(`space-y-3 border-t border-border pt-4`,r?``:`text-center`),children:r?(0,W.jsx)(qb,{}):(0,W.jsx)(J,{size:`sm`,variant:`ghost`,"data-testid":`use-password`,onClick:()=>n(!0),children:`Use an email and password instead`})})]})})}function pU(){let{state:e,actions:t}=G(),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let e=()=>u.current?.focus();e();let t=setTimeout(e,60);return()=>clearTimeout(t)},[]),(0,W.jsxs)(`div`,{className:`flex min-h-screen items-center justify-center bg-surface-1 p-6`,"data-testid":`locked-view`,onMouseDown:()=>u.current?.focus(),children:[(0,W.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),!n||o)return;s(!0),l(null);let a=null;t.unlock(n,{keepUnlocked:i,onError:e=>{a=e}}).then(e=>{s(!1),e?r(``):l(a??`Wrong password — the vault stays locked.`)})},className:`w-full max-w-sm space-y-4 text-center`,children:[(0,W.jsx)(q.Lock,{className:`mx-auto h-10 w-10 text-fg-faint`}),(0,W.jsx)(`h1`,{className:`text-lg font-semibold`,children:`This device is locked`}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`The vault, your keys and every session on this PC stay unreadable until you unlock — with your account password here, or remotely from another of your devices.`}),(0,W.jsx)(`input`,{ref:u,type:`password`,className:X,value:n,onChange:e=>r(e.target.value),onMouseDown:e=>e.stopPropagation(),placeholder:`Account password`,autoFocus:!0,"data-testid":`locked-password`}),(0,W.jsxs)(`label`,{className:`flex items-start justify-center gap-2 text-sm text-fg-muted`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:i,onChange:e=>a(e.target.checked),"data-testid":`locked-keep-unlocked`}),(0,W.jsx)(`span`,{children:`Keep me unlocked on this PC`})]}),c?(0,W.jsx)(`div`,{className:`text-sm text-danger`,"data-testid":`locked-error`,children:c}):null,(0,W.jsx)(J,{type:`submit`,variant:`primary`,busy:o,disabled:!n,children:`Unlock`}),(0,W.jsxs)(`div`,{className:`text-xs text-fg-faint`,children:[`Signed in as `,e.account?.email??`this account`,` ·`,` `,(0,W.jsx)(`button`,{type:`button`,className:`underline hover:text-fg`,onClick:()=>void t.logout(),children:`Sign out`})]})]}),(0,W.jsx)(nU,{})]})}function mU(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function hU(e,t,n){let r=mU(n),i=e.filter(e=>!t.has(e.id)).sort((e,t)=>t.mtime-e.mtime),a=[],o=[];for(let e of i)(e.mtime>=r?a:o).push(e);return{today:a,older:o}}function gU(e,t){let n=t.trim().toLowerCase();return n===``||e.toLowerCase().includes(n)}var _U=`flex w-full items-center gap-1 rounded px-2 py-1 text-left text-[11px] font-semibold uppercase tracking-wide text-fg-faint hover:bg-surface-2`,vU=`flex items-center gap-1 px-2 pb-0.5 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,yU=`flex w-full items-center gap-1.5 rounded border-l-2 border-project/70 bg-surface-2/40 px-2 py-1.5 text-left text-[13px] font-semibold tracking-normal text-fg hover:bg-surface-2`,bU=`flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-2`;function xU(){let{state:e,actions:t}=G(),n=e.ui.sidebarPinnedOverride??e.prefs.sidebarPinned,[r,i]=(0,v.useState)(vV),[a,o]=(0,v.useState)({}),[s,c]=(0,v.useState)(!1),l=RF(),[u,d]=(0,v.useState)(null),f=(0,v.useCallback)(()=>d(null),[]),p=OU(),m=qF(),h=mU(m),g=e.prefs.sidebarView,_=e.prefs.pinned,y=e=>o(t=>({...t,[e]:t[e]!==!0})),b=e=>a[e]===!0,x=e.prefs.collapsedProjects,S=e=>x.includes(e),C=e=>{let n=S(e)?x.filter(t=>t!==e):[...x,e];t.savePrefs({collapsedProjects:n})},w=(0,v.useCallback)(e=>{t.selectSession(e),window.innerWidth<768&&t.setSidebar(!1)},[t]),T=(0,v.useCallback)(e=>{t.openPage({kind:`project`,projectId:e}),window.innerWidth<768&&t.setSidebar(!1)},[t]),E=e.search.trim()!==``,D=(0,v.useMemo)(()=>{let t=e.sessions.filter(t=>!e.remote.tabs[t.id]);if(!E)return t;let n=Date.now();return t.filter(t=>SV(t,e.search,r,n))},[e.sessions,e.remote.tabs,e.search,E,r]),O=(0,v.useMemo)(()=>{let t=new Map(D.map(e=>[e.id,e])),n=[];for(let r of _)if(r.kind===`chat`){let i=t.get(r.id)??(E?void 0:e.pinnedRows[r.id]);i&&!e.remote.tabs[i.id]&&n.push({kind:`chat`,session:i})}else{let t=e.vaultProjects.find(e=>e.id===r.id);if(!t||!gU(t.name,E?e.search:``))continue;let i=e.sessions.filter(e=>e.projectId===t.id);n.push({kind:`project`,project:t,sessions:i})}return n},[_,D,E,e.search,e.pinnedRows,e.remote.tabs,e.vaultProjects,e.sessions]),k=(0,v.useMemo)(()=>new Set(_.filter(e=>e.kind===`chat`).map(e=>e.id)),[_]),A=(0,v.useMemo)(()=>g===`recent`?hU(D,k,h):null,[g,D,k,h]),j=(0,v.useMemo)(()=>new Map(e.vaultProjects.map(e=>[e.id,e.name])),[e.vaultProjects]),M=(0,v.useMemo)(()=>{if(g!==`projects`)return[];let t=new Map;for(let n of e.vaultProjects)t.set(n.id,{name:n.name,sessions:[]});let n=[];for(let e of D){let r=e.projectId?t.get(e.projectId):void 0;r?r.sessions.push(e):n.push(e)}let r=[...t.entries()].map(([e,t])=>({key:e,name:t.name,projectId:e,sessions:t.sessions.slice().sort((e,t)=>t.mtime-e.mtime)}));return r.sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`})),(n.length>0||r.length===0)&&r.push({key:`none`,name:`No project`,projectId:null,sessions:n.slice().sort((e,t)=>t.mtime-e.mtime)}),E?r.filter(e=>e.sessions.length>0):r},[g,e.vaultProjects,D,E]),ee=e=>{t.savePrefs({collapsedProjects:e?M.map(e=>e.key):[]})},N=(0,v.useMemo)(()=>e.remote.hosts.filter(e=>!e.isSelf),[e.remote.hosts]),P=()=>{let e=b(`remote`);y(`remote`),e&&t.refreshHosts()},F=e=>{t.setSearch(e),t.refreshSessions(e)},[I,te]=(0,v.useState)(!1),[ne,re]=(0,v.useState)(0),L=(0,v.useRef)(null),[ie,R]=(0,v.useState)(!1),[ae,oe]=(0,v.useState)(``),se=r.mode===`conversations`,ce=se?ae:e.search,le=I||ce!==``||ie;(0,v.useEffect)(()=>{I&&L.current?.focus()},[I,ne]),(0,v.useEffect)(()=>{let e=e=>{!(e.ctrlKey||e.metaKey)||e.shiftKey||e.altKey||(e.key===`k`||e.key===`K`)&&window.oonacode?.host!==`vscode`&&(e.preventDefault(),te(!0),re(e=>e+1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let ue=()=>{e.search!==``&&F(``),oe(``),R(!1),te(!1)},de=t=>{t.mode!==r.mode&&(t.mode===`conversations`?(oe(e.search),e.search!==``&&F(``)):(ae!==``&&F(ae),oe(``))),i(t)},fe=D.length,pe=e=>{e!==g&&t.savePrefs({sidebarView:e})},me=e.page,he={onOpen:w,onMenu:l.openMenu,clock:m},ge=!e.sessionsLoading&&fe===0&&!e.sessionsError?(0,W.jsx)(`div`,{className:`px-3 py-3 text-center text-xs text-fg-faint`,"data-testid":`sessions-empty`,children:E?`No sessions match.`:`No sessions yet — press + to start one.`}):null;return(0,W.jsxs)(`nav`,{className:`flex h-full w-full flex-col bg-surface`,"aria-label":`Sessions`,children:[(0,W.jsxs)(`div`,{className:`relative flex flex-wrap items-center justify-end gap-x-2 gap-y-1 border-b border-border p-2`,children:[(0,W.jsx)(Y,{label:`Search chats (Ctrl+K)`,onClick:()=>{te(!0),re(e=>e+1)},"data-testid":`open-search`,children:(0,W.jsx)(q.Search,{})}),(0,W.jsx)(`span`,{className:`flex-1`}),le?(0,W.jsxs)(`div`,{className:`absolute inset-0 z-10 flex items-center gap-1 bg-surface px-2`,"data-testid":`sidebar-search`,children:[(0,W.jsxs)(`div`,{className:`relative flex-1`,children:[(0,W.jsx)(q.Search,{className:`pointer-events-none absolute left-2 top-2 w-3.5 h-3.5 text-fg-faint`}),(0,W.jsx)(`input`,{ref:L,"aria-label":`Search sessions`,className:U(X,`pl-7`),placeholder:se?`Search every chat`:`Search chats`,value:ce,onChange:e=>se?oe(e.target.value):F(e.target.value),onBlur:()=>{ce===``&&!ie&&te(!1)},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ue())}})]}),(0,W.jsxs)(Y,{label:ie?`Hide search options`:`Search options`,className:U(`relative`,ie&&`text-accent`),"aria-pressed":ie,onMouseDown:e=>e.preventDefault(),onClick:()=>R(e=>!e),"data-testid":`search-options-toggle`,children:[(0,W.jsx)(q.Sliders,{}),bV(r)?(0,W.jsx)(`span`,{className:`absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-accent`,"data-testid":`search-options-dot`}):null]}),(0,W.jsx)(Y,{label:`Close search`,onMouseDown:e=>e.preventDefault(),onClick:ue,"data-testid":`close-search`,children:(0,W.jsx)(q.X,{})})]}):null,le&&ie?(0,W.jsx)(DV,{options:r,onChange:de,projects:e.vaultProjects,onClose:()=>{R(!1),L.current?.focus()}}):null,(0,W.jsx)(Y,{label:`Refresh sessions`,onClick:()=>{t.refreshSessions(),t.refreshHosts()},children:(0,W.jsx)(q.Refresh,{className:e.sessionsLoading?`spin`:``})}),e.account?.loggedIn?(0,W.jsx)(Y,{label:`Import chats from your other coding agents`,onClick:()=>t.openDialog(`import-claude`),"data-testid":`open-import-claude`,children:(0,W.jsx)(q.Download,{})}):null,e.account?.loggedIn?(0,W.jsx)(Y,{label:`Export my chats`,onClick:()=>t.openDialog(`export-chats`),"data-testid":`open-export-chats`,children:(0,W.jsx)(q.Upload,{})}):null,g===`projects`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Y,{label:`Collapse all projects`,onClick:()=>ee(!0),"data-testid":`projects-collapse-all`,children:(0,W.jsx)(q.CollapseAll,{})}),(0,W.jsx)(Y,{label:`Expand all projects`,onClick:()=>ee(!1),"data-testid":`projects-expand-all`,children:(0,W.jsx)(q.ExpandAll,{})})]}):null,(0,W.jsx)(Y,{label:`Conversations — what your chats send each other`,onClick:()=>t.openConversations(),"data-testid":`open-conversations`,children:(0,W.jsx)(q.Chats,{})}),(0,W.jsx)(Y,{label:`What your chats are about — each chat’s about and what it cost`,onClick:()=>t.openChatAbouts(),"data-testid":`open-chat-abouts`,children:(0,W.jsx)(q.Info,{})}),(0,W.jsx)(Y,{label:n?`Hide the session list — it slides in when the pointer reaches the left edge`:`Pin the session list beside the chat`,className:U(`hidden md:inline-flex`,n?`text-accent`:`text-fg-muted`),"aria-pressed":n,onClick:()=>t.toggleSidebarPinned(),"data-testid":`sidebar-pin`,children:(0,W.jsx)(q.Pin,{})})]}),(0,W.jsx)(SU,{clock:m}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1 pb-2`,children:se&&ae.trim()!==``?(0,W.jsx)(kV,{query:ae,options:r}):(0,W.jsxs)(W.Fragment,{children:[O.length>0?(0,W.jsxs)(`div`,{className:`mb-1`,"data-testid":`section-pinned`,children:[(0,W.jsx)(`div`,{className:vU,children:(0,W.jsx)(`span`,{children:`Pinned`})}),O.map(t=>t.kind===`chat`?(0,W.jsx)(IF,{session:t.session,active:t.session.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.session.id]??null,menuOpen:l.menuFor===t.session.id,kindIcon:!0,testIdPrefix:`pinned-session`,...he},`chat:${t.session.id}`):(0,W.jsx)(TU,{project:t.project,sessions:t.sessions,active:me?.kind===`project`&&me.projectId===t.project.id,onOpen:T,onMenu:(e,n)=>d({target:{projectId:t.project.id,foldKey:null},at:e,el:n})},`project:${t.project.id}`))]}):null,(0,W.jsxs)(`div`,{className:`mb-1`,"data-testid":`sessions-local`,children:[e.sessionsError?(0,W.jsx)(`div`,{className:`px-2 py-2 text-xs text-danger`,children:e.sessionsError}):null,A?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{"data-testid":`section-today`,children:[(0,W.jsxs)(`div`,{className:vU,children:[(0,W.jsx)(`span`,{children:`Today`}),(0,W.jsx)(`span`,{className:`font-normal normal-case`,children:A.today.length||``}),(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(wU,{view:g,onChange:pe})]}),ge??(A.today.length===0?(0,W.jsx)(`div`,{className:`px-3 py-1 text-xs text-fg-faint`,"data-testid":`today-empty`,children:E?`Nothing from today matches.`:`Nothing yet today.`}):A.today.map(t=>(0,W.jsx)(IF,{session:t,active:t.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.id]??null,menuOpen:l.menuFor===t.id,projectName:t.projectId?j.get(t.projectId)??null:null,...he},t.id)))]}),A.older.length>0?(0,W.jsxs)(`div`,{"data-testid":`section-older`,children:[(0,W.jsxs)(`div`,{className:vU,children:[(0,W.jsx)(`span`,{children:`Older`}),(0,W.jsx)(`span`,{className:`font-normal normal-case`,children:A.older.length})]}),A.older.map(t=>(0,W.jsx)(IF,{session:t,active:t.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.id]??null,menuOpen:l.menuFor===t.id,projectName:t.projectId?j.get(t.projectId)??null:null,...he},t.id))]}):null]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:vU,"data-testid":`section-by-project`,children:[(0,W.jsx)(`span`,{children:`By project`}),(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(wU,{view:g,onChange:pe})]}),ge,M.map(n=>{let r=`local:${n.key}`;return(0,W.jsxs)(`div`,{className:`mb-1 pl-2`,"data-testid":`project-group-${n.key}`,children:[(0,W.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,W.jsx)(kU,{group:n,collapsed:S(n.key),onToggle:()=>C(n.key),onMenu:(e,t)=>d({target:{projectId:n.projectId,foldKey:n.key},at:e,el:t}),menuOpen:u?.target.foldKey===n.key}),n.projectId?(0,W.jsxs)(`div`,{className:`absolute right-1 hidden items-center rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:[(0,W.jsx)(Y,{label:`Settings of ${n.name}`,className:`p-1`,"data-testid":`project-settings-${n.key}`,onClick:e=>{e.stopPropagation(),t.openProjectSettings(n.projectId)},children:(0,W.jsx)(q.Settings,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(Y,{label:`New chat in ${n.name}`,className:`p-1`,"data-testid":`project-new-chat-${n.key}`,onClick:e=>{e.stopPropagation(),t.newTab({projectId:n.projectId})},children:(0,W.jsx)(q.Plus,{className:`w-3.5 h-3.5`})})]}):null]}),S(n.key)?null:n.sessions.map(t=>(0,W.jsx)(IF,{session:t,active:t.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.id]??null,menuOpen:l.menuFor===t.id,...he},t.id))]},r)})]})]}),(0,W.jsxs)(`div`,{className:`mb-1`,"data-testid":`sessions-remote`,children:[(0,W.jsxs)(`button`,{type:`button`,className:_U,onClick:P,"aria-expanded":!b(`remote`),children:[(0,W.jsx)(q.Chevron,{open:!b(`remote`),className:`w-3 h-3`}),(0,W.jsx)(q.Globe,{className:`w-3 h-3`}),(0,W.jsx)(`span`,{className:`truncate`,children:`Remote`}),(0,W.jsx)(`span`,{className:`ml-auto font-normal`,children:N.length})]}),b(`remote`)?null:(0,W.jsxs)(W.Fragment,{children:[!e.remote.supported||e.remote.reason===`logged_out`?(0,W.jsx)(`div`,{className:`px-3 py-3 text-xs text-fg-faint`,children:`Sign in to see the sessions of your other devices.`}):N.length===0?(0,W.jsx)(`div`,{className:`px-3 py-3 text-xs text-fg-faint`,children:e.remote.loading?`Looking for your other devices…`:`No other devices yet.`}):null,N.map(e=>(0,W.jsx)(EU,{host:e,collapsed:b(`host:${e.hostId}`)||a[`host:${e.hostId}`]===void 0,onToggle:()=>{let n=`host:${e.hostId}`,r=a[n]===void 0||a[n]===!0;o(e=>({...e,[n]:!r})),r&&t.refreshHostSessions(e.hostId)}},e.hostId))]})]})]})}),(0,W.jsx)(`div`,{className:`shrink-0 border-t border-border px-3 py-2 text-[11px] text-fg-faint`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`button`,{type:`button`,"data-testid":`app-version`,title:`What's new in this version`,className:`truncate hover:text-fg hover:underline`,onClick:()=>t.openDialog(`whats-new`),children:[`OonaCode Desktop v`,p]}),(0,W.jsx)(Y,{label:`Lock this device — vault and sessions`,className:`p-1`,"data-testid":`lock-device`,onClick:()=>c(!0),children:(0,W.jsx)(q.Lock,{className:`h-3.5 w-3.5`})})]})}),(0,W.jsx)(nx,{open:u!==null,at:u?.at??{x:0,y:0},anchorEl:u?.el??null,label:`Project actions`,testId:`project-context-menu`,onClose:f,items:u?zF({projectId:u.target.projectId,pinned:u.target.projectId!==null&&Xc(_,`project`,u.target.projectId),fold:u.target.foldKey===null?null:{collapsed:S(u.target.foldKey),onToggle:()=>C(u.target.foldKey)},actions:t}):[]}),l.element,(0,W.jsx)(Xy,{open:s,title:`Lock this device?`,confirmLabel:`Lock`,message:`Every chat closes and nothing on this PC can be read or run until you unlock — here with your password, or remotely from another device.`,onConfirm:()=>void t.lockDevice(),onClose:()=>c(!1)})]})}function SU({clock:e}){let{state:t,actions:n}=G(),[r,i]=(0,v.useState)(null),a=(0,v.useCallback)(()=>i(null),[]),o=t.page,s=()=>{window.innerWidth<768&&n.setSidebar(!1)};return(0,W.jsxs)(`div`,{className:`shrink-0 border-b border-border px-1 py-1`,"data-testid":`sidebar-nav`,children:[(0,W.jsxs)(`div`,{className:`flex items-center rounded-md hover:bg-surface-2`,children:[(0,W.jsxs)(`button`,{type:`button`,className:U(bU,`flex-1 hover:bg-transparent`),title:`New chat (Ctrl+T)`,onClick:()=>{n.newTab(),s()},"data-testid":`sidebar-new`,children:[(0,W.jsx)(q.Edit,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,W.jsx)(`span`,{children:`New`})]}),(0,W.jsx)(Y,{label:`Start a new chat or a new project`,className:`mr-1 p-1`,"aria-haspopup":`menu`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();i({at:{x:t.left,y:t.bottom+2},el:e.currentTarget})},"data-testid":`sidebar-new-menu`,children:(0,W.jsx)(q.Chevron,{open:!0,className:`w-3.5 h-3.5`})})]}),(0,W.jsxs)(`button`,{type:`button`,className:U(bU,`w-full`,o?.kind===`projects`||o?.kind===`project`?`bg-surface-2 font-medium`:``),"aria-current":o?.kind===`projects`?`page`:void 0,onClick:()=>{n.openPage({kind:`projects`}),s()},"data-testid":`open-projects`,children:[(0,W.jsx)(q.Project,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,W.jsx)(`span`,{children:`Projects`})]}),(0,W.jsx)(CU,{clock:e,active:o?.kind===`scheduled`,onOpen:()=>{n.openPage({kind:`scheduled`}),s()}}),(0,W.jsx)(nx,{open:r!==null,at:r?.at??{x:0,y:0},anchorEl:r?.el??null,label:`New`,testId:`sidebar-new-context-menu`,onClose:a,items:[{key:`chat`,label:`New chat`,hint:`Ctrl+T`,icon:(0,W.jsx)(q.Chats,{className:`w-3.5 h-3.5`}),onSelect:()=>{n.newTab(),s()},testId:`sidebar-new-chat`},{key:`project`,label:`New project…`,icon:(0,W.jsx)(q.Project,{className:`w-3.5 h-3.5`}),onSelect:()=>n.openNewProject(),testId:`sidebar-new-project`}]})]})}function CU({clock:e,active:t,onOpen:n}){let{tasks:r}=KF(),i=(0,v.useMemo)(()=>r?nI(r,e):null,[r,e]);return(0,W.jsxs)(`button`,{type:`button`,className:U(bU,`w-full`,t?`bg-surface-2 font-medium`:``),"aria-current":t?`page`:void 0,onClick:n,title:i?.text??`Every scheduled task on this PC`,"data-testid":`open-scheduled`,children:[(0,W.jsx)(q.Clock,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,W.jsx)(`span`,{className:`flex-1`,children:`Scheduled`}),i?(0,W.jsx)(`span`,{className:U(`mr-1 inline-block h-2 w-2 shrink-0 rounded-full`,i.tone===`stuck`?`bg-warn`:`bg-accent`),"aria-label":i.text,"data-testid":`scheduled-dot`,"data-tone":i.tone}):null]})}function wU({view:e,onChange:t}){let[n,r]=(0,v.useState)(null),i=(0,v.useCallback)(()=>r(null),[]),a=e=>e?(0,W.jsx)(q.Check,{className:`w-3.5 h-3.5 text-accent`}):(0,W.jsx)(`span`,{className:`w-3.5`});return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Y,{label:`How the list is laid out`,className:`p-0.5 normal-case`,"aria-haspopup":`menu`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();r({at:{x:t.left,y:t.bottom+2},el:e.currentTarget})},"data-testid":`sidebar-view-options`,children:(0,W.jsx)(q.Sliders,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(nx,{open:n!==null,at:n?.at??{x:0,y:0},anchorEl:n?.el??null,label:`How the list is laid out`,testId:`sidebar-view-menu`,onClose:i,items:[{key:`recent`,label:`Recent — Today, then Older`,icon:a(e===`recent`),onSelect:()=>t(`recent`),testId:`sidebar-view-recent`},{key:`projects`,label:`By project`,icon:a(e===`projects`),onSelect:()=>t(`projects`),testId:`sidebar-view-projects`}]})]})}function TU({project:e,sessions:t,active:n,onOpen:r,onMenu:i}){let a=(0,v.useRef)(null),o=e.sessionCount??t.length;return(0,W.jsxs)(`div`,{ref:a,className:U(`group relative flex items-center rounded-md`,n?`bg-accent-soft`:`hover:bg-surface-2`),onContextMenu:e=>{e.preventDefault(),i({x:e.clientX,y:e.clientY},a.current)},children:[(0,W.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 py-1.5 pl-2 pr-8 text-left`,"aria-current":n?`page`:void 0,title:`Open ${e.name}`,onClick:()=>r(e.id),"data-testid":`pinned-project-${e.id}`,children:[(0,W.jsx)(q.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.name}),(0,W.jsx)(jF,{sessions:t,testId:`pinned-project-busy-${e.id}`}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-3 px-1.5 py-px text-[10px] font-semibold text-fg-muted`,children:o})]}),(0,W.jsx)(Y,{label:`Project actions`,className:`pointer-events-none absolute right-1 bg-surface/90 p-1 opacity-0 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100`,"data-testid":`pinned-project-menu-${e.id}`,onClick:e=>{e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();i({x:t.left,y:t.bottom+2},a.current)},children:(0,W.jsx)(q.More,{className:`w-3.5 h-3.5`})})]})}function EU({host:e,collapsed:t,onToggle:n}){let{state:r,actions:i}=G(),a=e.label||e.hostName,o=r.remote.sessions[e.hostId],s=r.remote.unreachable[e.hostId],c=s?mf(s.reason,a,s.detail):null,[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),p=e.remoteAccessOff===!0;return(0,W.jsxs)(`div`,{className:`mb-1 pl-2`,"data-testid":`remote-host-${e.hostId}`,children:[(0,W.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,W.jsxs)(`button`,{type:`button`,className:_U,onClick:n,"aria-expanded":!t,title:e.online?`${a} — online`:`${a} — offline: its chats can be read while it is online`,children:[(0,W.jsx)(q.Chevron,{open:!t,className:`w-3 h-3`}),(0,W.jsx)(`span`,{className:U(`inline-block h-2 w-2 shrink-0 rounded-full`,e.online?`bg-ok`:`bg-fg-faint`),"aria-label":e.online?`online`:`offline`}),(0,W.jsx)(`span`,{className:`truncate normal-case`,children:a}),p?(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-warn-soft px-1.5 text-[10px] font-normal normal-case text-warn`,"data-testid":`remote-off-${e.hostId}`,children:`remote access off`}):null,(0,W.jsx)(`span`,{className:`ml-auto font-normal`,children:!p&&o?o.length:``})]}),(0,W.jsxs)(`div`,{className:`absolute right-1 hidden items-center rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:[(0,W.jsx)(Y,{label:p?pf(a):e.online?`New chat on ${a}`:`${a} is offline — a new chat has to start on a PC that is awake`,className:`p-1`,disabled:!e.online||p,"data-testid":`remote-new-chat-${e.hostId}`,onClick:()=>void i.newRemoteTab(e.hostId),children:(0,W.jsx)(q.Plus,{className:`w-3 h-3`})}),(0,W.jsx)(Y,{label:`Unlock this device`,className:`p-1`,disabled:p,"data-testid":`remote-unlock-${e.hostId}`,onClick:()=>u(`unlock`),children:(0,W.jsx)(q.Lock,{className:`w-3 h-3`})}),(0,W.jsx)(Y,{label:`Rename device`,className:`p-1`,onClick:()=>u(`rename`),children:(0,W.jsx)(q.Edit,{className:`w-3 h-3`})})]}),(0,W.jsx)(Zy,{open:l===`unlock`,title:`Unlock "${a}" remotely`,label:`Your account password — it never leaves this PC: the keys are sealed to that device and the server cannot read them.`,password:!0,submitLabel:`Unlock`,onSubmit:t=>void i.remoteUnlockHost(e.hostId,t),onClose:()=>u(null)}),(0,W.jsx)(Zy,{open:l===`rename`,title:`Rename device`,label:`Device name`,initialValue:a,onSubmit:t=>{t!==a&&i.renameHost(e.hostId,t)},onClose:()=>u(null)})]}),!t&&p?(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-warn`,"data-testid":`remote-off-note-${e.hostId}`,children:pf(a)}):t?null:o===void 0?(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-faint`,children:`Loading…`}):o.length===0&&c?(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-warn`,"data-testid":`remote-unreachable-${e.hostId}`,children:c}):o.length===0?(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-faint`,children:`No sessions on this device.`}):o.map(t=>(0,W.jsx)(DU,{host:e,session:t,active:t.id===r.currentSessionId&&r.page===null,onConfirmDelete:()=>f(t)},t.id)),(0,W.jsx)(Xy,{open:d!==null,title:`Delete this chat?`,message:`It is deleted on ${e.hostName} — the only place it is kept — so it is gone from every device. Files, folders and code on that PC are not touched — only the chat is deleted.`,onConfirm:()=>{d&&i.deleteRemoteSession(e.hostId,d.id)},onClose:()=>f(null)})]})}function DU({host:e,session:t,active:n,onConfirmDelete:r}){let{actions:i}=G(),a=pg(t);return(0,W.jsxs)(`div`,{className:U(`group flex items-center rounded-md`,n?`bg-accent-soft`:`hover:bg-surface-2`),children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{i.openRemoteSession(e.hostId,t.id),window.innerWidth<768&&i.setSidebar(!1)},className:`flex min-w-0 flex-1 items-center gap-2 px-2 py-1.5 text-left`,"aria-current":n?`true`:void 0,"data-testid":`remote-session-${t.id}`,title:e.online?void 0:`Read-only until that PC is online`,children:[(0,W.jsx)(kF,{status:t.status}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:U(`truncate text-sm`,n?`font-medium`:``),children:a}),(0,W.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[ag(t.updatedAt),t.model?` · ${t.model}`:``,e.online?``:` · read-only`]})]})]}),(0,W.jsx)(`div`,{className:`mr-1 hidden items-center gap-0.5 rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:(0,W.jsx)(Y,{label:e.online?`Delete this chat`:`That PC is asleep — a chat can only be deleted while the PC that holds it is online`,className:`p-1 hover:text-danger disabled:opacity-40`,disabled:!e.online,"data-testid":`remote-session-delete-${t.id}`,onClick:()=>{r()},children:(0,W.jsx)(q.Trash,{className:`w-3.5 h-3.5`})})})]})}function OU(){let{state:e}=G(),t=typeof window<`u`?window.oonacode:void 0;return Gv(t?.appVersion??e.bundleAppVersion??e.connection.appVersion??e.info?.appVersion??`0.0.0`,Wv({bridge:t,info:e.info}))}function kU({group:e,collapsed:t,onToggle:n,onMenu:r,menuOpen:i=!1}){let a=(0,v.useRef)(null),o=(0,v.useRef)(null),[s,c]=(0,v.useState)(null),l=(0,v.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null),c(null)},[]),u=(0,v.useRef)(i);return u.current=i,(0,v.useEffect)(()=>{i&&l()},[i,l]),(0,v.useEffect)(()=>{if(s===null)return;let e=e=>{ex(e.target,a.current)&&l()};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[s,l]),(0,v.useEffect)(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`button`,{ref:a,type:`button`,className:yU,onClick:()=>{l(),n()},onMouseEnter:()=>{o.current!==null&&clearTimeout(o.current),!u.current&&(o.current=setTimeout(()=>{o.current=null,a.current&&!u.current&&c(a.current.getBoundingClientRect())},450))},onMouseLeave:l,onContextMenu:e=>{e.preventDefault(),l(),r({x:e.clientX,y:e.clientY},a.current)},"aria-expanded":!t,"data-testid":`project-header-${e.key}`,children:[(0,W.jsx)(q.Chevron,{open:!t,className:`w-3 h-3 shrink-0`}),(0,W.jsx)(q.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.name}),(0,W.jsx)(jF,{sessions:e.sessions,testId:`project-busy-${e.key}`}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-surface-3 px-1.5 py-px text-[10px] font-semibold normal-case tracking-normal text-fg-muted`,"data-testid":`project-count-${e.key}`,children:e.sessions.length})]}),s===null?null:(0,W.jsx)(AU,{group:e,anchor:s})]})}function AU({group:e,anchor:t}){let{state:n}=G(),r=e.projectId?n.vaultProjects.find(t=>t.id===e.projectId):void 0,i=e.sessions.filter(e=>e.status===`running`||e.status===`waiting_permission`).length,a=e.sessions.reduce((e,t)=>e===null||t.updatedAt>e?t.updatedAt:e,null),o=[...new Set(e.sessions.map(e=>e.projectDir??e.cwd).filter(e=>typeof e==`string`&&e.length>0))],s=r?.instructions?.trim()??``,c=Math.max(8,Math.min(t.right+8,window.innerWidth-304-8)),l=Math.max(8,Math.min(t.top,window.innerHeight-320));return(0,Ly.createPortal)((0,W.jsxs)(`div`,{role:`tooltip`,"data-testid":`project-details-${e.key}`,className:`fixed z-50 max-h-[20rem] w-[19rem] overflow-y-auto rounded-lg border border-border bg-surface p-3 text-xs shadow-lg`,style:{left:c,top:l},children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5`,children:[(0,W.jsx)(q.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,W.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.name})]}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(NF,{label:`Chats`,value:String(e.sessions.length)}),(0,W.jsx)(NF,{label:`Working now`,value:i>0?String(i):null}),(0,W.jsx)(NF,{label:`Last activity`,value:a?ag(a):null}),(0,W.jsx)(NF,{label:o.length>1?`Folders`:`Folder`,value:o.length>1?`${o.length} folders`:o[0]??null})]}),e.projectId?(0,W.jsxs)(`div`,{className:`mt-2 border-t border-border pt-2`,children:[(0,W.jsx)(`div`,{className:`mb-1 text-fg-faint`,children:`Standing instructions`}),s?(0,W.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-fg`,"data-testid":`project-instructions-${e.key}`,children:s.length>400?`${s.slice(0,400)}…`:s}):(0,W.jsx)(`div`,{className:`text-fg-faint`,children:`None — chats here start with nothing extra.`})]}):(0,W.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 text-fg-faint`,children:`Chats filed under no project.`})]}),document.body)}function jU(){return ey(typeof window<`u`?window.oonacode:void 0)}function MU(e){if(e.upToDate)return`Everything on this PC is up to date — the app, the host service and the oona CLI.`;let t=[];return e.terminal&&t.push(`OonaCode updates the oona CLI and the host service in place — the service restarts and your chats come back with it.`),e.desktop&&t.push(e.terminal?`Then it downloads the app, installs it and relaunches, restoring your open tabs.`:`OonaCode downloads the update, installs it and relaunches. Your open chat tabs are restored afterwards.`),t.length===0?t.push("This window cannot install updates by itself — run the installer again, or `oona update` in a terminal. Your open chat tabs are stored in the host and come back automatically."):e.manual.length>0&&t.push(e.manual.includes(`desktop`)?`The app itself needs the installer from the website.`:"The rest needs `oona update` in a terminal."),t.join(` `)}var NU=2*Math.PI*10;function PU(){return typeof window<`u`&&window.oonacode!==void 0}function FU(){let{state:e,actions:t}=G(),n=e.update,r=e.updateInstall,i=e.prefs.dismissedUpdateVersion,a=n.version!==``&&(e.updateDismissed===n.version||i===n.version);if(!PU())return null;let o=Yv({install:r,manifestAvailable:n.available&&!a}),s=e.terminalUpdate.running,c=e.updateChecking||r.phase===`checking`||s,l=n.components.length,u=Math.round(r.percent),d=s?`Updating the CLI and host service`:o===`ready`?`Restart to finish updating`:o===`downloading`?`Downloading update (${u}%)`:o===`available`?`Update available (${l})`:`Check for updates`,f=s?`Updating the oona CLI and the host service…`:o===`ready`?`An update is ready — restart to finish`:o===`downloading`?`Downloading OonaCode ${r.version||`update`} — ${u}%`:o===`available`?`${l} component${l===1?``:`s`} can be updated`:`Check for updates`;return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{if(o===`idle`){t.checkUpdates(!0);return}if(o===`ready`){t.installUpdate();return}t.openDialog(`update`)},title:f,"aria-label":d,"aria-busy":c||void 0,"data-testid":`update-badge`,"data-state":o,className:U(`relative inline-flex h-7 w-7 items-center justify-center rounded-full border transition-transform hover:scale-105`,o===`idle`?`border-border bg-surface-2 text-fg-muted hover:text-fg`:`border-accent bg-accent-soft text-accent`),children:[o===`downloading`?(0,W.jsxs)(`svg`,{viewBox:`0 0 24 24`,"data-testid":`update-badge-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":u,className:`absolute inset-0 h-full w-full -rotate-90`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,fill:`none`,strokeWidth:`2`,className:`stroke-border`}),(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:NU,strokeDashoffset:NU*(1-Math.max(0,Math.min(100,u))/100),className:`stroke-accent`})]}):null,c&&o!==`downloading`&&o!==`ready`?(0,W.jsx)(`span`,{"data-testid":`update-badge-checking`,className:`inline-flex`,children:(0,W.jsx)(q.Spinner,{className:`w-3.5 h-3.5`})}):o===`ready`?(0,W.jsx)(`span`,{"data-testid":`update-badge-ready`,className:`inline-flex`,children:(0,W.jsx)(q.Refresh,{className:`w-3.5 h-3.5`})}):o===`downloading`?(0,W.jsx)(`span`,{"data-testid":`update-badge-downloading`,className:`text-[9px] font-semibold`,children:u}):(0,W.jsx)(`span`,{"data-testid":o===`available`?`update-badge-available`:`update-badge-idle`,className:`inline-flex`,children:(0,W.jsx)(q.Download,{className:`w-3.5 h-3.5`})}),o===`available`?(0,W.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-accent`,"aria-hidden":!0}):null]})}function IU(){let{state:e,actions:t}=G(),n=e.updateInstall,r=Math.round(Math.max(0,Math.min(100,n.percent))),i=Qv(n.bytesPerSecond);if(n.phase===`error`)return(0,W.jsxs)(`div`,{className:`rounded-md border border-danger-soft bg-danger-soft px-3 py-2 text-xs text-danger`,"data-testid":`update-error`,role:`alert`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(q.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`font-medium`,children:`The update could not be downloaded.`}),(0,W.jsx)(`div`,{className:`mt-0.5 pre-wrap break-words`,children:n.error})]})]}),(0,W.jsx)(`div`,{className:`mt-2`,children:(0,W.jsxs)(J,{size:`sm`,onClick:()=>void t.installUpdate(),"data-testid":`update-retry`,children:[(0,W.jsx)(q.Refresh,{className:`w-3.5 h-3.5`}),` Try again`]})})]});let a=n.phase===`installing`;return(0,W.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`update-progress`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:a?`Installing and restarting…`:n.phase===`ready`?`Downloaded — restart to install`:`Downloading OonaCode ${n.version||``}`.trim()}),a?null:(0,W.jsxs)(`span`,{className:`text-fg-muted`,children:[r,`%`]})]}),n.notice?(0,W.jsx)(`div`,{className:`pre-wrap text-xs text-warn`,"data-testid":`update-notice`,role:`status`,children:n.notice}):null,(0,W.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-2`,children:(0,W.jsx)(`div`,{className:U(`h-full rounded-full bg-accent`,a&&`animate-pulse`),style:{width:`${a?100:r}%`},"data-testid":`update-progress-bar`})}),a?(0,W.jsx)(`div`,{className:`text-xs text-fg-faint`,children:`The host service stops for a few seconds while the installer runs, then OonaCode starts again with your chat tabs.`}):(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-fg-faint`,children:[(0,W.jsxs)(`span`,{children:[Zv(n.transferred),n.total>0?` of ${Zv(n.total)}`:``]}),i?(0,W.jsx)(`span`,{children:i}):null]})]})}function LU(){let{state:e,actions:t}=G(),n=e.terminalUpdate;return n.running?(0,W.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-border bg-surface-2 px-3 py-2 text-xs`,"data-testid":`terminal-update-running`,role:`status`,children:[(0,W.jsx)(q.Spinner,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`font-medium text-fg`,children:`Updating the oona CLI and host service...`}),(0,W.jsx)(`div`,{className:`mt-0.5 text-fg-faint`,children:`The host service stops for a few seconds while its installer runs. Your chats are in the database and come back with it.`})]})]}):n.failed?(0,W.jsxs)(`div`,{className:`rounded-md border border-danger-soft bg-danger-soft px-3 py-2 text-xs text-danger`,"data-testid":`terminal-update-error`,role:`alert`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(q.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`font-medium`,children:`The CLI and host service could not be updated.`}),(0,W.jsx)(`div`,{className:`mt-0.5 pre-wrap break-words`,children:n.message})]})]}),(0,W.jsx)(`div`,{className:`mt-2`,children:(0,W.jsxs)(J,{size:`sm`,onClick:()=>void t.installUpdate(),"data-testid":`terminal-update-retry`,children:[(0,W.jsx)(q.Refresh,{className:`w-3.5 h-3.5`}),` Try again`]})})]}):null}function RU({open:e,onClose:t}){let{state:n,actions:r}=G(),i=n.update,a=n.updateInstall,o=r.checkUpdates,s=a.phase===`downloading`||a.phase===`installing`||a.phase===`ready`;(0,v.useEffect)(()=>{!e||s||o(!1)},[e,s,o]);let c=jU(),l=ty(i.components.map(e=>e.component),c,{checked:i.version!==``,shellEngaged:a.phase!==`idle`&&a.phase!==`checking`}),u=i.version||a.version,d=a.phase===`ready`,f=a.phase===`downloading`||a.phase===`installing`||d||a.phase===`error`,p=n.terminalUpdate.running,m=n.updateChecking||a.phase===`checking`||p;return(0,W.jsx)(Ky,{open:e,title:`Update OonaCode`,onClose:t,footer:d?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{onClick:t,children:`Later`}),(0,W.jsxs)(J,{variant:`primary`,onClick:()=>void r.installUpdate(),"data-testid":`update-restart`,children:[(0,W.jsx)(q.Refresh,{className:`w-4 h-4`}),`Restart and install`]})]}):f?(0,W.jsx)(J,{onClick:t,children:`Close`}):l.upToDate?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(J,{onClick:()=>void r.checkUpdates(!0),busy:m,disabled:m,"data-testid":`update-check-again`,children:[(0,W.jsx)(q.Refresh,{className:`w-4 h-4`}),`Check again`]}),(0,W.jsx)(J,{variant:`primary`,onClick:t,children:`Close`})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{onClick:()=>r.dismissUpdate(),children:`Skip this version`}),(0,W.jsx)(J,{onClick:t,children:`Later`}),(0,W.jsxs)(J,{variant:`primary`,busy:m,disabled:m,onClick:()=>void r.installUpdate(),children:[(0,W.jsx)(q.Download,{className:`w-4 h-4`}),l.label]})]}),children:(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[u?(0,W.jsxs)(`span`,{className:`font-medium`,children:[`Release `,u]}):null,i.channel?(0,W.jsx)(Z,{children:i.channel}):null,n.updateChecking?(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,"data-testid":`update-rechecking`,children:`checking for a newer one…`}):null,i.publishedAt?(0,W.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`published `,new Date(i.publishedAt).toLocaleDateString()]}):null]}),f?(0,W.jsx)(IU,{}):null,(0,W.jsx)(LU,{}),i.components.length>0?(0,W.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:i.components.map(e=>(0,W.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2`,children:[(0,W.jsx)(q.Download,{className:`mt-0.5 w-3.5 h-3.5 shrink-0 text-accent`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,W.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[e.current,` → `,(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:e.latest})]}),(0,W.jsx)(`div`,{className:`text-xs text-fg-faint`,"data-testid":`update-how-${e.component}`,children:ny(e.component,c)}),e.notes?(0,W.jsx)(`div`,{className:`mt-0.5 pre-wrap text-xs text-fg-faint`,children:e.notes}):null]})]},e.component))}):null,i.notes?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Release notes`}),(0,W.jsx)(`div`,{className:`max-h-48 overflow-y-auto rounded-md bg-surface-2 px-3 py-2 pre-wrap text-xs text-fg-muted`,children:i.notes})]}):null,f?null:(0,W.jsx)(`p`,{className:`text-xs text-fg-faint`,"data-testid":`update-plan-note`,children:MU(l)})]})})}function zU(e){switch(e){case`open`:return{cls:`bg-ok`,label:`Connected`};case`connecting`:case`reconnecting`:return{cls:`bg-warn animate-pulse`,label:e===`connecting`?`Connecting…`:`Reconnecting…`};case`unauthorized`:return{cls:`bg-danger`,label:`Unauthorized`};case`closed`:return{cls:`bg-danger`,label:`Disconnected`};default:return{cls:`bg-fg-faint`,label:`Idle`}}}function BU(){let{state:e,actions:t}=G(),n=zU(e.connection.status),r=e.account?.loggedIn===!0,i=typeof window<`u`&&window.oonacode?.host===`vscode`;return(0,W.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-surface px-2 sm:px-3`,children:[i?null:(0,W.jsx)(Y,{label:`Toggle sidebar`,onClick:()=>{typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(min-width: 768px)`).matches?t.toggleSidebarPinned():t.setSidebar(!e.ui.sidebarOpen)},"data-testid":`toggle-sidebar`,children:(0,W.jsx)(q.PanelLeft,{})}),(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i?null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`font-semibold tracking-tight`,children:`OonaCode`}),(0,W.jsx)(`span`,{className:`hidden text-fg-faint sm:inline`,children:`/`})]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.openDialog(`session-picker`),title:`Open a session on this PC or another device`,className:`hidden min-w-0 truncate text-sm text-fg-muted hover:text-fg sm:inline`,"data-testid":`host-name`,children:e.connection.hostName??`host`}),(0,W.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-muted`,title:e.connection.detail??n.label,"data-testid":`connection-status`,children:[(0,W.jsx)(`span`,{className:U(`inline-block h-2 w-2 rounded-full`,n.cls),"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:n.label})]})]}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,W.jsx)(VU,{}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.openDialog(`bug-report`),title:`Bug Report...`,"aria-label":`Bug Report...`,"data-testid":`bug-report-button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-full border border-border bg-surface-2 text-fg-muted transition-transform hover:scale-105 hover:text-fg`,children:(0,W.jsx)(q.Bug,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(FU,{}),e.hostUpdatedTo?(0,W.jsxs)(J,{size:`sm`,variant:`primary`,onClick:()=>window.location.reload(),title:`This window still runs the previous version; the host is now v${e.hostUpdatedTo}`,"data-testid":`reload-for-update`,children:[`Reload for v`,e.hostUpdatedTo]}):null,r?null:(0,W.jsxs)(J,{size:`sm`,variant:`primary`,onClick:()=>t.openDialog(`account`),"data-testid":`sign-in`,children:[(0,W.jsx)(q.LogIn,{className:`w-3.5 h-3.5`}),` Sign in`]}),(0,W.jsx)(Y,{label:e.prefs.explorerOpen?`Hide files`:`Show files`,onClick:()=>void t.savePrefs({explorerOpen:!e.prefs.explorerOpen}),className:e.prefs.explorerOpen?`bg-surface-2 text-fg`:void 0,"data-testid":`toggle-explorer`,children:(0,W.jsx)(q.Folder,{})}),(0,W.jsx)(Y,{label:e.prefs.sessionPanelOpen?`Hide session info`:`Show session info`,onClick:()=>void t.savePrefs({sessionPanelOpen:!e.prefs.sessionPanelOpen}),className:e.prefs.sessionPanelOpen?`bg-surface-2 text-fg`:void 0,"data-testid":`toggle-session-panel`,children:(0,W.jsx)(q.Panel,{})}),(0,W.jsx)(Y,{label:`Doctor`,onClick:()=>t.openDialog(`doctor`),children:(0,W.jsx)(q.Stethoscope,{})}),r?(0,W.jsx)(HU,{}):null,(0,W.jsx)(Y,{label:`Account`,onClick:()=>t.openDialog(`account`),children:(0,W.jsxs)(`span`,{className:`relative`,children:[(0,W.jsx)(q.User,{}),r?(0,W.jsx)(`span`,{className:U(`absolute -right-0.5 -top-0.5 h-1.5 w-1.5 rounded-full`,e.account?.vaultUnlocked?`bg-ok`:`bg-warn`)}):null]})}),(0,W.jsx)(Y,{label:`Settings`,onClick:()=>t.openDialog(`settings`),children:(0,W.jsx)(q.Settings,{})})]})]})}function VU(){let{actions:e}=G(),[t,n]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=typeof window<`u`?window.oonacode:void 0;if(!e?.getDebugging)return;let t=!0;return e.getDebugging().then(e=>{t&&n(e.running)},()=>{}),()=>{t=!1}},[]),!t||!Cc(t))return null;let r=NH(t);return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>e.openSettings(`developer`),title:r,"aria-label":r,"data-testid":`debugging-badge`,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-red-600 px-2.5 text-[11px] font-semibold text-white hover:bg-red-700`,children:[(0,W.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-white`,"aria-hidden":!0}),`Debugging on`]})}function HU(){let{state:e}=G(),[t,n]=(0,v.useState)(!1),r=(0,v.useRef)(null),i=e.plan;(0,v.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[t]);let a=i?i.credits.balance:null,o=i?Dv(i):null,s=Av(i),c=jv;return(0,W.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,W.jsx)(Y,{label:s?`Credits and plan — ${s.text}`:`Credits and plan`,onClick:()=>n(e=>!e),"data-testid":`balance-badge`,className:t?`bg-surface-2 text-fg`:void 0,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(q.Coins,{}),a===null?null:(0,W.jsx)(`span`,{className:U(`hidden text-xs tabular-nums sm:inline`,s?s.level===`empty`?`text-danger`:`text-warn`:void 0),"data-testid":`balance-credits`,"data-level":s?.level??`ok`,children:c(a)})]})}),t?(0,W.jsx)(`div`,{className:`absolute right-0 top-full z-50 mt-1 w-64 rounded-md border border-border bg-surface p-3 text-sm shadow-lg`,"data-testid":`balance-popover`,children:i===null||o===null?(0,W.jsx)(`div`,{className:`text-fg-muted`,children:`Balance is unavailable — the gateway can't be reached.`}):(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:`Plan`}),(0,W.jsxs)(`span`,{className:`font-medium`,children:[i.planName,i.status===`none`?` (lapsed)`:``]})]}),(0,W.jsx)(`div`,{className:`h-px bg-border`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:`Credits`}),(0,W.jsx)(`span`,{className:`font-semibold tabular-nums`,children:c(o.balance)})]}),s?(0,W.jsx)(`div`,{className:U(`rounded-sm px-2 py-1 text-[11px]`,s.level===`empty`?`bg-danger-soft text-danger`:`bg-warn-soft text-warn`),"data-testid":`balance-warning`,children:s.text}):null,o.hasSplit?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:`Plan credits`}),(0,W.jsx)(`span`,{className:`tabular-nums`,children:c(o.plan??0)})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:`Top-up credits`}),(0,W.jsx)(`span`,{className:`tabular-nums`,children:c(o.topup??0)})]})]}):null,(0,W.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[i.credits.monthlyGrant>0?`Plan credits top up to ${c(i.credits.monthlyGrant)} each 30-day period and expire with it; top-ups never do.`:`This plan pays no monthly credits — the signup gift and anything you buy never expire.`,` `,`Free models never draw on this balance.`]})]})}):null]})}function UU(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error??Error(`could not read the file`)),r.onload=()=>{let e=typeof r.result==`string`?r.result:``,n=e.indexOf(`,`);t(n>=0?e.slice(n+1):``)},r.readAsDataURL(e)})}function WU(e,t){let n=[],r=e.length,i=e.reduce((e,t)=>e+t.size,0);for(let e of t){if(r>=5)return{accepted:n,refused:`At most 5 files per report.`};if(e.size>5242880)return{accepted:n,refused:`${e.name} is ${Zv(e.size)}; a file may be at most ${Zv(Xs)}.`};if(i+e.size>12582912)return{accepted:n,refused:`All files together may be at most ${Zv(Zs)}.`};n.push(e),r+=1,i+=e.size}return{accepted:n,refused:null}}function GU(e){return e instanceof hm?e.code===`account_required`||e.status===401?`Sign in to OonaCode first — a report is filed under your account so we can answer it.`:ym(e)?`This host build cannot send bug reports yet — update OonaCode on this PC.`:e.status===429?`Too many reports in a minute — wait a moment and send again.`:e.status===413?`The attachments are too large for one report.`:e.message||`The report could not be sent.`:e instanceof Error&&e.message?e.message:`The report could not be sent.`}var KU=0;function qU({open:e,onClose:t}){let{state:n,actions:r,api:i}=G(),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(!1),h=(0,v.useRef)(null);(0,v.useEffect)(()=>{e&&(o(``),c([]),u(!1),f(null))},[e]);let g=n.account?.loggedIn===!0,_=typeof i.sendBugReport==`function`,y=typeof window<`u`?window.oonacode:void 0,b=y?y.host===`vscode`?`vscode`:`desktop`:`browser`,x=n.currentSessionId?n.sessions.find(e=>e.id===n.currentSessionId)??null:null,S=(0,v.useCallback)(async e=>{let t=Array.from(e);if(t.length===0)return;let{accepted:n,refused:r}=WU(s,t);f(r);let i=t.filter(e=>n.includes(e));if(i.length!==0){m(!0);try{let e=[];for(let t of i){let n=await UU(t);if(!n)continue;let r=t.type||`application/octet-stream`;KU+=1,e.push({key:`f${KU}`,name:t.name,contentType:r,dataBase64:n,size:t.size,preview:r.startsWith(`image/`)?`data:${r};base64,${n}`:null})}c(t=>[...t,...e])}catch(e){f(e instanceof Error?e.message:`could not read the file`)}finally{m(!1)}}},[s]),C=e=>{let t=e.target.files;t&&S(t),e.target.value=``},w=e=>c(t=>t.filter(t=>t.key!==e)),T=async()=>{let e=a.trim();if(!e||l)return;if(!_){f(`This host build cannot send bug reports yet — update OonaCode on this PC.`);return}u(!0),f(null);let o={message:e.slice(0,Ys),...s.length>0?{attachments:s.map(({name:e,contentType:t,dataBase64:n})=>({name:e,contentType:t,dataBase64:n}))}:{},...n.currentSessionId?{sessionId:n.currentSessionId}:{},detail:{embedded:b,connection:n.connection.status,...y?.appVersion?{appVersion:y.appVersion}:{},...n.bundleAppVersion?{uiVersion:n.bundleAppVersion}:{},...n.info?.appVersion?{hostVersion:n.info.appVersion}:{},...n.info?.engine?.version?{engineVersion:n.info.engine.version}:{},...x?.status?{sessionStatus:x.status}:{}}};try{let e=await i.sendBugReport(o);r.toast(`success`,`Bug report #${e.id} sent — thank you.`),t()}catch(e){f(GU(e))}finally{u(!1)}},E=Ys-a.length;return(0,W.jsx)(Ky,{open:e,title:`Bug Report`,onClose:t,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{onClick:t,disabled:l,children:`Cancel`}),(0,W.jsxs)(J,{variant:`primary`,busy:l,disabled:!a.trim()||p,onClick:()=>void T(),"data-testid":`bug-report-send`,children:[(0,W.jsx)(q.Bug,{className:`w-4 h-4`}),`Send report`]})]}),children:(0,W.jsxs)(`div`,{className:`space-y-3 text-sm`,"data-testid":`bug-report-dialog`,children:[(0,W.jsxs)(`p`,{className:`text-fg-muted`,children:[`Tell us what went wrong and what you expected. Screenshots help. The report is filed under your account with this PC's versions`,x?` and the open chat’s model`:``,`; the chat itself is never sent.`]}),g?null:(0,W.jsx)(`div`,{className:`rounded-md border border-warn/40 bg-warn-soft px-3 py-2 text-xs text-warn`,children:`Sign in to OonaCode to send a report — it is filed under your account so we can answer it.`}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:`What happened?`}),(0,W.jsx)(`textarea`,{name:`message`,className:U(X,`min-h-32 resize-y`),value:a,maxLength:Ys,placeholder:`The answer stopped after a few seconds with “API error”. I was using…`,onChange:e=>o(e.target.value),"data-testid":`bug-report-message`}),(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,children:E<500?`${E} characters left`:``})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{ref:h,type:`file`,multiple:!0,className:`hidden`,onChange:C,"data-testid":`bug-report-files`}),(0,W.jsxs)(J,{size:`sm`,onClick:()=>h.current?.click(),disabled:l||p||s.length>=5,children:[(0,W.jsx)(q.Paperclip,{className:`w-3.5 h-3.5`}),`Attach files or pictures`]}),(0,W.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`up to `,5,` files,`,` `,Zv(Xs),` each`]})]}),s.length>0?(0,W.jsx)(`ul`,{className:`flex flex-wrap gap-2`,"data-testid":`bug-report-attachments`,children:s.map(e=>(0,W.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md border border-border bg-surface-2 px-2 py-1 text-xs`,children:[e.preview?(0,W.jsx)(`img`,{src:e.preview,alt:``,className:`h-8 w-8 rounded object-cover`,"aria-hidden":!0}):(0,W.jsx)(q.Paperclip,{className:`w-3.5 h-3.5 text-fg-muted`}),(0,W.jsx)(`span`,{className:`max-w-40 truncate`,title:e.name,children:e.name}),(0,W.jsx)(`span`,{className:`text-fg-faint`,children:Zv(e.size)}),(0,W.jsx)(Y,{label:`Remove ${e.name}`,onClick:()=>w(e.key),children:(0,W.jsx)(q.X,{className:`w-3.5 h-3.5`})})]},e.key))}):null]}),d?(0,W.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`bug-report-error`,children:d}):null]})})}function JU(e){let t=Date.parse(`${e}T12:00:00`);return Number.isFinite(t)?new Date(t).toLocaleDateString(void 0,{dateStyle:`long`}):e}function YU({open:e,notes:t,onClose:n}){return(0,W.jsx)(Ky,{open:e,title:`What's new in OonaCode`,onClose:n,footer:(0,W.jsx)(J,{variant:`primary`,onClick:n,children:`Got it`}),children:(0,W.jsx)(`div`,{className:`space-y-5 text-sm`,"data-testid":`whats-new`,children:t.map(e=>(0,W.jsxs)(`section`,{"data-version":e.version,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-baseline gap-2`,children:[(0,W.jsxs)(`h3`,{className:`text-base font-semibold`,children:[`Version `,e.version]}),(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,children:JU(e.date)})]}),e.added.length>0?(0,W.jsx)(`ul`,{className:`space-y-1.5`,children:e.added.map((e,t)=>(0,W.jsxs)(`li`,{className:`flex gap-2`,children:[(0,W.jsx)(q.Plus,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent`}),(0,W.jsx)(`span`,{children:e})]},t))}):null,e.fixed.length>0?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mb-1 mt-3 text-xs font-medium uppercase tracking-wide text-fg-faint`,children:`Fixed`}),(0,W.jsx)(`ul`,{className:`space-y-1.5`,children:e.fixed.map((e,t)=>(0,W.jsxs)(`li`,{className:`flex gap-2`,children:[(0,W.jsx)(q.Check,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-ok`}),(0,W.jsx)(`span`,{children:e})]},t))})]}):null]},`${e.version}:${e.platforms?.join(`,`)??`all`}`))})})}function XU(){let{state:e,actions:t}=G(),n=sm(e.account);return!n||e.ui.dialog===`account`?null:(0,W.jsxs)(`div`,{role:`status`,"data-testid":`vault-rekey-banner`,className:`flex items-center gap-2 bg-warn-soft px-3 py-1.5 text-xs text-warn`,children:[(0,W.jsx)(q.Alert,{className:`w-3.5 h-3.5`}),(0,W.jsx)(`span`,{className:`flex-1`,children:mm(n)}),(0,W.jsx)(J,{size:`sm`,variant:`primary`,onClick:()=>t.openDialog(`account`),children:`Open Account`})]})}function ZU({onReconnect:e}){let{state:t}=G(),n=t.connection.status;if(n===`open`||n===`idle`||n===`connecting`)return null;let r=n===`unauthorized`&&!window.oonacode;return(0,W.jsxs)(`div`,{role:`status`,className:U(`flex items-center gap-2 px-3 py-1.5 text-xs`,r?`bg-danger-soft text-danger`:`bg-warn-soft text-warn`),children:[r?(0,W.jsx)(q.Alert,{className:`w-3.5 h-3.5`}):(0,W.jsx)(q.Spinner,{className:`w-3.5 h-3.5`}),(0,W.jsx)(`span`,{className:`flex-1`,children:r?`The host rejected this connection${t.connection.detail?` (${t.connection.detail})`:``}. Re-open the UI from the desktop app or paste a fresh token.`:`Reconnecting to the host${t.connection.detail?` — ${t.connection.detail}`:``}…`}),r&&e?(0,W.jsx)(J,{size:`sm`,variant:`danger`,onClick:e,children:`Enter token`}):null]})}function QU(){let{state:e,actions:t}=G(),n=(0,v.useRef)(1);n.current=Object.keys(e.layout.groups).length,(0,v.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{if(e.ctrlKey||e.metaKey){if(e.key===`Tab`){e.preventDefault(),t.cycleTab(e.shiftKey?-1:1);return}if(!(e.shiftKey||e.altKey)){if(e.key===`\\`||e.code===`Backslash`){e.preventDefault(),t.splitTab(`right`);return}if(/^[1-9]$/.test(e.key)){let r=Number(e.key)-1;if(r>=n.current)return;e.preventDefault(),t.focusGroupAt(r),$U(r)}}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t])}function $U(e){let t=()=>{(document.querySelectorAll(`[data-editor-group]`)[e]?.querySelector(`[data-testid="composer"] textarea`))?.focus()};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}function eW(){let{state:e,actions:t}=G(),n=(0,v.useRef)(!1),r=e.account?.loggedIn===!0,i=e.prefs.claudeImportOffered?3:e.prefs.claudeImportOffers,a=e.ui.dialog===`none`&&e.windowRole===`main`,o=e.settings!==null,s=(0,v.useRef)(e.ui.dialog);s.current=e.ui.dialog,(0,v.useEffect)(()=>{n.current||!o||i>=3||!r||!a||(n.current=!0,t.scanClaudeSessions().then(e=>{if(e.sessions.some(e=>!e.alreadyImported&&e.deletedHere!==!0&&!e.unavailable)){if(s.current!==`none`){n.current=!1;return}t.offerImport(),t.savePrefs({claudeImportOffers:i+1})}}).catch(()=>{}))},[t,a,r,i,o])}function tW(){let{state:e,actions:t}=G(),n=(0,v.useRef)(!1),[r,i]=(0,v.useState)(null),a=typeof window<`u`?window.oonacode:void 0,o=a?.appVersion??e.bundleAppVersion??null,s=e.settings!==null,c=e.prefs.lastSeenReleaseNotes,l=e.sessionListLoaded,u=e.sessionsTotal>0||e.sessions.length>0,d=e.settings?.uiPrefs,f=d!==void 0&&!(`lastSeenReleaseNotes`in d),p=e.ui.dialog===`none`&&e.windowRole===`main`,m=e.info?.platform??a?.platform??null;(0,v.useEffect)(()=>{if(n.current||!s||!o||!p||c===null&&!l||(n.current=!0,f))return;let{record:e,show:r}=il(o,c,u,void 0,m);e!==null&&t.savePrefs({lastSeenReleaseNotes:e}),r.length!==0&&(i(r),t.openDialog(`whats-new`))},[t,f,p,o,c,m,l,s,u]);let h=e.ui.dialog===`whats-new`;return(0,v.useEffect)(()=>{!h&&r&&i(null)},[r,h]),r??(o?rl(o,`0`,void 0,m):[])}function nW({onUnauthorized:e}){let{state:t,actions:n}=G(),r=(0,v.useCallback)(()=>n.openDialog(`none`),[n]),i=tW();eW();let a=typeof window<`u`&&window.oonacode?.host===`vscode`,o=t.ui.sidebarOpen&&!a;return QU(),(0,W.jsxs)(`div`,{className:`flex h-full flex-col bg-bg text-fg`,children:[(0,W.jsx)(BU,{}),(0,W.jsx)(ZU,{onReconnect:e}),(0,W.jsx)(XU,{}),(0,W.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,W.jsx)(BR,{hidden:a,children:(0,W.jsx)(xU,{})}),o?(0,W.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 md:hidden`,onClick:()=>n.setSidebar(!1),"aria-hidden":!0}):null,t.prefs.explorerOpen?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 md:hidden`,onClick:()=>void n.savePrefs({explorerOpen:!1}),"aria-hidden":!0}),(0,W.jsx)(`div`,{className:`absolute inset-y-0 left-0 z-30 flex max-w-[85vw] md:static md:z-auto md:max-w-none`,children:(0,W.jsx)(wH,{})})]}):null,(0,W.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:(0,W.jsx)(sR,{})}),t.prefs.sessionPanelOpen?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 lg:hidden`,onClick:()=>void n.savePrefs({sessionPanelOpen:!1}),"aria-hidden":!0}),(0,W.jsx)(`div`,{className:`absolute inset-y-0 right-0 z-30 flex max-w-[85vw] lg:static lg:z-auto lg:max-w-none`,children:(0,W.jsx)(bH,{})})]}):null]}),(0,W.jsx)(gR,{open:t.ui.dialog===`project`,onClose:r}),(0,W.jsx)(PR,{open:t.ui.dialog===`projects`,startNew:t.projectsStartNew,selectId:t.projectsSelectId,onClose:r}),(0,W.jsx)(CB,{open:t.ui.dialog===`assign-project`,onClose:r}),(0,W.jsx)(eU,{open:t.ui.dialog===`settings`,onClose:r}),(0,W.jsx)(Xb,{open:t.ui.dialog===`account`,onClose:r}),(0,W.jsx)(hR,{open:t.ui.dialog===`doctor`,onClose:r}),(0,W.jsx)(ax,{open:t.ui.dialog===`session-picker`,onClose:r}),(0,W.jsx)(RU,{open:t.ui.dialog===`update`,onClose:r}),(0,W.jsx)(qU,{open:t.ui.dialog===`bug-report`,onClose:r}),(0,W.jsx)(AR,{open:t.ui.dialog===`claude-login`,onClose:r}),(0,W.jsx)(gV,{open:t.ui.dialog===`oauth-login`,onClose:r}),(0,W.jsx)(_V,{open:t.ui.dialog===`manage-models`,onClose:r}),(0,W.jsx)(eH,{open:t.ui.dialog===`import-claude`,autoOffer:t.importOffered,onClose:r}),(0,W.jsx)(VR,{open:t.ui.dialog===`export-chats`,onClose:r}),(0,W.jsx)(lz,{open:t.ui.dialog===`conversations`,selectId:t.conversationsSelectId,onClose:r}),(0,W.jsx)(bB,{open:t.ui.dialog===`chat-abouts`,onClose:r}),(0,W.jsx)(uB,{open:t.ui.dialog===`voice-summary`,onClose:r}),(0,W.jsx)(YU,{open:t.ui.dialog===`whats-new`,notes:i,onClose:r}),(0,W.jsx)(hV,{open:t.ui.connectProviderId!==null,providerId:t.ui.connectProviderId,onClose:()=>n.openProviderConnect(null)}),(0,W.jsx)(nU,{})]})}function rW({onUnauthorized:e}){let{state:t}=G(),n=t.account?.loggedIn===!0&&!t.account.vaultUnlocked;return(0,v.useEffect)(()=>{window.oonacode?.setVaultLocked?.(n)},[n]),t.accountLoaded?t.account?.loggedIn?!t.account.vaultUnlocked&&sm(t.account)===null?(0,W.jsx)(pU,{}):(0,W.jsx)(nW,{onUnauthorized:e}):(0,W.jsx)(fU,{}):(0,W.jsx)(cU,{})}function iW({api:e,socket:t,relay:n,initialSessionId:r,onUnauthorized:i,reportError:a}){return(0,W.jsx)(Iy,{api:e,socket:t,relay:n??null,initialSessionId:r??null,onUnauthorized:i,...a?{reportError:a}:{},children:(0,W.jsx)(rW,{onUnauthorized:i})})}var aW=`oonacode.host.connection`,oW=`session`;function sW(e){let t=e.replace(/^#\/?\??/,``),n=new URLSearchParams(t),r=n.get(`token`),i=n.get(`host`)??n.get(`baseUrl`),a=n.get(oW);n.delete(`token`),n.delete(`host`),n.delete(`baseUrl`);let o=n.toString();return{token:r&&r.trim()?r.trim():null,baseUrl:i,sessionId:a,restHash:o?`#${o}`:``}}function cW(e){if(!e)return null;try{let t=e.getItem(aW);if(!t)return null;let n=JSON.parse(t);if(typeof n.baseUrl==`string`&&typeof n.token==`string`&&n.token)return{baseUrl:_m(n.baseUrl),token:n.token}}catch{}return null}function lW(e,t){if(e)try{t?e.setItem(aW,JSON.stringify(t)):e.removeItem(aW)}catch{}}async function uW(e){let t=sW(e.location.hash);if(t.token){let n={baseUrl:_m(t.baseUrl??e.location.origin),token:t.token};lW(e.storage,n);let r=`${e.location.pathname}${e.location.search}${t.restHash}`;try{e.replaceUrl?.(r)}catch{}return{connection:n,source:`hash`,sessionId:t.sessionId}}if(e.bridge&&typeof e.bridge.getConnection==`function`)try{let n=await e.bridge.getConnection();if(n&&typeof n.token==`string`&&n.token&&typeof n.baseUrl==`string`){let r={baseUrl:_m(n.baseUrl),token:n.token};return lW(e.storage,r),{connection:r,source:`bridge`,sessionId:t.sessionId}}}catch{}let n=cW(e.storage);return n?{connection:n,source:`storage`,sessionId:t.sessionId}:{connection:null,source:`none`,sessionId:t.sessionId}}function dW(e=window){let t=null;try{t=e.sessionStorage}catch{t=null}return uW({location:e.location,storage:t,replaceUrl:t=>e.history.replaceState(null,``,t),bridge:e.oonacode})}var fW=1;function pW(){let e=globalThis.crypto;return e&&typeof e.randomUUID==`function`?e.randomUUID():`c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function mW(e,t){return`${_m(e).replace(/^http(s?):/i,`ws$1:`)}${b}?token=${encodeURIComponent(t)}`}var hW=class{clientId;opts;ws=null;_status=`idle`;attempts=0;preOpenFailures=0;epoch=0;reconnectTimer=null;pingTimer=null;manuallyClosed=!1;handlers=new Map;anyHandlers=new Set;statusHandlers=new Set;subscriptions=new Map;promptCounter=0;constructor(e){this.opts={clientKind:`web`,minBackoffMs:500,maxBackoffMs:15e3,pingIntervalMs:25e3,authProbeAfterFailures:2,...e,baseUrl:_m(e.baseUrl)},this.clientId=e.clientId??pW()}get status(){return this._status}connect(){this.manuallyClosed=!1,!(this.ws&&(this._status===`open`||this._status===`connecting`))&&this.open()}close(){this.manuallyClosed=!0,this.epoch+=1,this.clearTimers();let e=this.ws;if(this.ws=null,e){e.onopen=e.onclose=e.onerror=e.onmessage=null;try{e.close(1e3,`client closed`)}catch{}}this.setStatus(`closed`)}send(e){let t=this.ws;if(!t||t.readyState!==fW)return!1;try{return t.send(JSON.stringify(e)),!0}catch{return!1}}on(e,t){let n=this.handlers.get(e);n||(n=new Set,this.handlers.set(e,n));let r=t;return n.add(r),()=>{n?.delete(r)}}onAny(e){return this.anyHandlers.add(e),()=>{this.anyHandlers.delete(e)}}onStatus(e){return this.statusHandlers.add(e),e(this._status),()=>{this.statusHandlers.delete(e)}}subscribe(e,t){let n=this.subscriptions.get(e),r=t??n;this.subscriptions.set(e,r),this.send(r===void 0?{type:`subscribe`,sessionId:e}:{type:`subscribe`,sessionId:e,afterSeq:r})}unsubscribe(e){this.subscriptions.delete(e),this.send({type:`unsubscribe`,sessionId:e})}noteSeq(e,t){if(t===null||!this.subscriptions.has(e))return;let n=this.subscriptions.get(e);(n===void 0||t>n)&&this.subscriptions.set(e,t)}prompt(e,t,n={}){let r=n.requestId??`req-${this.clientId.slice(0,8)}-${++this.promptCounter}`,i={type:`prompt`,sessionId:e,requestId:r,text:t};if(n.attachments&&n.attachments.length>0&&(i.attachments=n.attachments),n.options&&(i.options=n.options),!this.send(i))throw Error(`not connected`);return r}respondPermission(e,t,n){return this.send({type:`permission_response`,sessionId:e,requestId:t,decision:n})}interrupt(e){return this.send({type:`interrupt`,sessionId:e})}setModel(e,t){return this.send({type:`set_model`,sessionId:e,model:t})}setPermissionMode(e,t,n){return this.send({type:`set_permission_mode`,sessionId:e,mode:t,...n===void 0?{}:{posture:n}})}setEffort(e,t){return this.send({type:`set_effort`,sessionId:e,effort:t})}open(){this.clearTimers(),this.epoch+=1,this.setStatus(this.attempts===0?`connecting`:`reconnecting`);let e=mW(this.opts.baseUrl,this.opts.token),t=this.opts.createWebSocket??(e=>new WebSocket(e)),n;try{n=t(e)}catch(e){this.scheduleReconnect(String(e?.message??e));return}this.ws=n;let r=!1;n.onopen=()=>{if(this.ws===n){r=!0,this.attempts=0,this.preOpenFailures=0,this.setStatus(`open`),this.send({type:`hello`,protocolVersion:1,clientKind:this.opts.clientKind,clientId:this.clientId,...this.opts.clientVersion?{clientVersion:this.opts.clientVersion}:{}});for(let[e,t]of this.subscriptions)this.send(t===void 0?{type:`subscribe`,sessionId:e}:{type:`subscribe`,sessionId:e,afterSeq:t});this.opts.pingIntervalMs>0&&(this.pingTimer=setInterval(()=>this.send({type:`ping`,ts:Date.now()}),this.opts.pingIntervalMs))}},n.onmessage=e=>{if(this.ws!==n)return;let t;try{t=typeof e.data==`string`?JSON.parse(e.data):null}catch{return}Ne(t)&&this.dispatch(t)},n.onerror=()=>{},n.onclose=e=>{if(this.ws!==n)return;if(this.ws=null,this.pingTimer&&=(clearInterval(this.pingTimer),null),this.manuallyClosed){this.setStatus(`closed`);return}if(e.code===4401||e.code===4403||e.code===1008){this.setStatus(`unauthorized`,e.reason||`host rejected the token or origin`);return}let t=e.reason||`closed (${e.code})`;if(this.preOpenFailures=r?0:this.preOpenFailures+1,!r&&this.opts.authProbeAfterFailures>0&&this.preOpenFailures>=this.opts.authProbeAfterFailures){this.probeAuthThenReconnect(t);return}this.scheduleReconnect(t)}}async probeAuthThenReconnect(e){let t=this.epoch;this.setStatus(`reconnecting`,e);let n=this.opts.fetchImpl??((e,t)=>fetch(e,t)),r=!1;try{let e=await n(`${this.opts.baseUrl}${z.health}`,{method:`GET`,headers:{authorization:`Bearer ${this.opts.token}`}});if(e.status===401||e.status===403)r=!0;else if(e.status===200){let t=await e.json().catch(()=>null);r=!(t&&typeof t==`object`&&typeof t.hostId==`string`)}}catch{}if(!(this.manuallyClosed||t!==this.epoch)){if(r){this.setStatus(`unauthorized`,`host rejected the token`);return}this.scheduleReconnect(e)}}dispatch(e){e.type===`agent`&&e.seq!==null&&this.noteSeq(e.sessionId,e.seq);let t=this.handlers.get(e.type);if(t)for(let n of[...t])gW(()=>n(e));for(let t of[...this.anyHandlers])gW(()=>t(e))}scheduleReconnect(e){this.attempts+=1;let t=Math.min(this.opts.maxBackoffMs,this.opts.minBackoffMs*2**Math.min(this.attempts-1,10)),n=Math.round(t*(.7+Math.random()*.6));this.setStatus(`reconnecting`,e);let r=this.opts.setTimeoutImpl??setTimeout;this.reconnectTimer=r(()=>{this.reconnectTimer=null,this.manuallyClosed||this.open()},n)}clearTimers(){this.reconnectTimer&&=((this.opts.clearTimeoutImpl??clearTimeout)(this.reconnectTimer),null),this.pingTimer&&=(clearInterval(this.pingTimer),null)}setStatus(e,t){this._status=e;for(let n of[...this.statusHandlers])gW(()=>n(e,t))}};function gW(e){try{e()}catch(e){console.error(`[HostSocket] handler failed`,e)}}var _W=/([?&#](?:token|access_token|key|api_key|secret|password)=)[^&#\s"']*/gi,vW=/\b(Bearer|Basic)\s+[A-Za-z0-9\-._~+/=]{8,}/g;function yW(e){return e.replace(_W,`$1[redacted]`).replace(vW,`$1 [redacted]`)}function bW(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function xW(e){return typeof e==`object`&&!!e&&typeof e.message==`string`}function SW(e){if(xW(e)){let t=typeof e.name==`string`&&e.name?e.name:`Error`,n=typeof e.stack==`string`&&e.stack?e.stack:null;return{message:e.message||t,stack:n}}return typeof e==`string`?{message:bW(e,512),stack:null}:{message:`Unhandled rejection (${e===null?`null`:Array.isArray(e)?`array`:typeof e})`,stack:null}}function CW(e){return e?e.split(`
|
|
163
|
-
`).find(e=>/^\s+at\s/.test(e))?.trim()??``:``}function wW(e){let t=e.now??(()=>Date.now()),n=e.maxPerMinute??5,r=e.embedded??`browser`,i=[],a=new Map,o=(e,t)=>{for(;i.length>0&&(i[0]??0)<=t-6e4;)i.shift();for(let[e,n]of a)n<=t-6e4&&a.delete(e);return a.has(e)||i.length>=n?!1:(i.push(t),a.set(e,t),!0)},s=async(n,i={})=>{try{let a=e.api.reportError;if(typeof a!=`function`)return!1;let{message:s,stack:c}=SW(n),l=t();if(!o(`${s}\n${CW(c)}`,l))return!1;let u={client:`web-ui`,message:bW(yW(s),qs),detail:{source:`manual`,...i,embedded:r},at:new Date(l).toISOString()};return c&&(u.stack=bW(yW(c),Js)),e.appVersion&&(u.appVersion=e.appVersion),e.platform&&(u.platform=e.platform),await a.call(e.api,u),!0}catch{return!1}},c=e=>{if(typeof e?.message!=`string`)return;let t=e.error??null;if(t===null&&!e.message)return;let n={source:`window.onerror`};typeof e.filename==`string`&&e.filename&&(n.filename=e.filename),typeof e.lineno==`number`&&e.lineno>0&&(n.lineno=e.lineno),typeof e.colno==`number`&&e.colno>0&&(n.colno=e.colno),s(t??e.message,n)},l=e=>{s(e?.reason,{source:`unhandledrejection`})};return{install:t=>{if(typeof e.api.reportError!=`function`)return()=>{};let n=e=>c(e),r=e=>l(e);return t.addEventListener(`error`,n),t.addEventListener(`unhandledrejection`,r),()=>{t.removeEventListener(`error`,n),t.removeEventListener(`unhandledrejection`,r)}},report:s,handleErrorEvent:c,handleRejectionEvent:l}}var TW=1;function EW(e,t){return`${_m(e).replace(/^http(s?):/i,`ws$1:`)}${z.remoteWs}?token=${encodeURIComponent(t)}`}function DW(e){return`tab-${e}-${Math.random().toString(36).slice(2,10)}`}var OW=class{#e;#t=new Map;#n=new Set;#r=null;#i=`idle`;#a=null;#o=0;#s=!1;#c=0;#l=null;constructor(e){this.#e=e}get status(){return this.#i}get pairingCount(){return this.#t.size}onStatus(e){return this.#n.add(e),e(this.#i),()=>{this.#n.delete(e)}}connect(){if(this.#r||this.#i===`connecting`)return;this.#s=!1,this.#d(`connecting`);let e=EW(this.#e.baseUrl,this.#e.token),t=this.#e.createWebSocket??(e=>new WebSocket(e)),n;try{n=t(e)}catch{this.#d(`closed`),this.#u();return}this.#r=n,n.onopen=()=>{if(this.#r===n){this.#o=0,this.#d(`open`),this.#f({type:`remote_hello`,protocolVersion:1,clientId:this.#e.clientId??`web-ui`,...this.#e.clientVersion?{clientVersion:this.#e.clientVersion}:{}});for(let e of this.#t.values())this.#p(e)}},n.onmessage=e=>{this.#r===n&&this.#h(e.data)},n.onerror=()=>void 0,n.onclose=()=>{if(this.#r===n){this.#r=null;for(let e of this.#t.values())this.#m(e,{state:`host_offline`,online:!1,detail:`reconnecting to this PC…`});this.#i!==`unavailable`&&this.#d(`closed`),this.#u()}}}close(){this.#s=!0,this.#l=null,this.#a&&(this.#e.clearTimeoutImpl??clearTimeout)(this.#a),this.#a=null,this.#t.clear();let e=this.#r;if(this.#r=null,e){e.onopen=e.onclose=e.onerror=e.onmessage=null;try{e.close(1e3,`closed`)}catch{}}this.#d(`idle`)}#u(){let e=this.#e.reconnectDelayMs??1e3;if(this.#s||e<=0||this.#a||this.#t.size===0)return;let t=this.#e.maxReconnectDelayMs??2e4;this.#o+=1;let n=Math.min(e*2**Math.min(this.#o-1,5),t),r=this.#e.setTimeoutImpl??setTimeout;this.#a=r(()=>{this.#a=null,this.#s||this.connect()},n)}#d(e,t){if(this.#i!==e){this.#i=e;for(let n of[...this.#n])n(e,t)}}#f(e){let t=this.#r;if(!t||t.readyState!==TW)return!1;try{return t.send(JSON.stringify(e)),!0}catch{return!1}}attach(e){this.#c+=1;let t=DW(this.#c),n={pairingId:t,hostId:e.hostId,sessionId:e.sessionId,state:`unavailable`,online:!1,detail:null,onFrame:e.onFrame,onState:e.onState};return this.#t.set(t,n),this.#r&&this.#r.readyState===TW?(this.#l!==null&&this.#m(n,{detail:this.#l}),this.#p(n)):this.connect(),{pairingId:t,hostId:e.hostId,sessionId:e.sessionId,send:e=>this.send(t,e),detach:()=>this.detach(t)}}detach(e){this.#t.get(e)&&(this.#t.delete(e),this.#f({type:`remote_detach`,pairingId:e}),this.#t.size===0&&this.close())}send(e,t){let n=this.#t.get(e);return!n||!n.online?!1:this.#f({type:`remote_send`,pairingId:e,frame:t})}#p(e){this.#f({type:`remote_attach`,pairingId:e.pairingId,hostId:e.hostId,sessionId:e.sessionId})}#m(e,t){Object.assign(e,t),e.onState({pairingId:e.pairingId,hostId:e.hostId,sessionId:e.sessionId,state:e.state,online:e.online,detail:e.detail})}#h(e){let t;try{let n=JSON.parse(typeof e==`string`?e:String(e));if(!Le(n))return;t=n}catch{return}switch(t.type){case`remote_welcome`:if(!t.canRelay){let e=t.reason??`this PC cannot reach your other devices right now`;this.#l=e,this.#d(`unavailable`,e);for(let t of this.#t.values())this.#m(t,{state:`unavailable`,online:!1,detail:e});return}this.#l=null,this.#i===`unavailable`&&this.#d(`open`);for(let e of this.#t.values())e.online||this.#p(e);return;case`remote_status`:{let e=this.#t.get(t.pairingId);if(!e)return;this.#m(e,{state:t.state,online:Re(t.state),detail:t.detail??null});return}case`remote_frame`:this.#t.get(t.pairingId)?.onFrame(t.frame);return;case`remote_error`:{let e=t.pairingId?this.#t.get(t.pairingId):void 0;e&&this.#m(e,{state:`error`,online:!1,detail:t.message});return}default:return}}};function kW({defaultBaseUrl:e,error:t,onConnect:n}){let[r,i]=(0,v.useState)(e),[a,o]=(0,v.useState)(``),s=r.trim().length>0&&a.trim().length>0;return(0,W.jsx)(`div`,{className:`flex min-h-full items-center justify-center bg-bg p-4`,children:(0,W.jsxs)(`form`,{className:`w-full max-w-md space-y-4 rounded-xl border border-border bg-surface p-6 shadow-md`,onSubmit:e=>{e.preventDefault(),s&&n({baseUrl:r.trim(),token:a.trim()})},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Connect to your OonaCode host`}),(0,W.jsxs)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:[`This page needs the host's access token. It is normally passed automatically when you open the UI from the desktop app or run`,` `,(0,W.jsx)(`code`,{className:`rounded bg-surface-2 px-1 font-mono`,children:`oona web`}),`.`]})]}),t?(0,W.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:t}):null,(0,W.jsx)(Wy,{label:`Host URL`,children:(0,W.jsx)(`input`,{className:X,value:r,onChange:e=>i(e.target.value),placeholder:`http://127.0.0.1:41317`,spellCheck:!1,autoComplete:`url`})}),(0,W.jsx)(Wy,{label:`Host token`,hint:'Found in host/host.json ("token") in the OonaCode folder of the PC running the host — %LOCALAPPDATA%\\OonaCode on Windows, ~/Library/Application Support/OonaCode on macOS, ~/.oonacode on Linux — printed by `oona serve --show-token`, or embedded in the URL printed by `oona web --print`.',children:(0,W.jsx)(`input`,{className:X,type:`password`,value:a,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1,autoFocus:!0})}),(0,W.jsx)(J,{type:`submit`,variant:`primary`,className:`w-full justify-center`,disabled:!s,children:`Connect`})]})})}function AW(e){return!!e&&e.platform===`linux`&&e.host!==`vscode`&&!!e.onMenuModel}var jW=e=>!!e&&e.type!==`separator`&&e.enabled;function MW(e,t,n){let r=e.length;for(let i=1;i<=r;i+=1){let a=((t+n*i)%r+r)%r;if(jW(e[a]))return a}return-1}function NW({label:e,mnemonic:t,show:n}){let r=n&&t?e.toLowerCase().indexOf(t):-1;return r<0?e:(0,W.jsxs)(W.Fragment,{children:[e.slice(0,r),(0,W.jsx)(`span`,{className:`underline underline-offset-2`,children:e[r]}),e.slice(r+1)]})}function PW({bridge:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(-1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),d=(0,v.useRef)(null);(0,v.useEffect)(()=>e.onMenuModel?.(e=>{n(e),i(null),o(-1),c(null)}),[e]);let f=t?.items??[],p=(0,v.useCallback)(e=>e===null?[]:f[e]?.submenu??[],[f]),m=(0,v.useCallback)(()=>{i(null),o(-1),c(null)},[]),h=(0,v.useCallback)((e,t)=>{i(e);let n=p(e);o(t?MW(n,-1,1):-1),t&&c(e)},[p]),g=(0,v.useCallback)(t=>{!t||!jW(t)||t.type===`submenu`||(m(),e.invokeMenuItem?.(t.id))},[e,m]);if((0,v.useEffect)(()=>{if(f.length===0)return;let e=!1,t=()=>r!==null||s!==null,n=e=>{e.preventDefault(),e.stopPropagation()},l=l=>{if(l.key===`Alt`){e=!l.repeat,u(!0);return}e=!1;let d=!l.ctrlKey&&!l.metaKey&&!l.shiftKey;if(!t()){if(l.key===`F10`&&d&&!l.altKey){n(l),c(0);return}if(l.altKey&&d&&l.key.length===1){let e=f.findIndex(e=>e.mnemonic===l.key.toLowerCase());e>=0&&(n(l),h(e,!0))}return}let _=p(r),v=s??r??0,y=e=>{let t=(v+e+f.length)%f.length;r===null?c(t):h(t,!0)};switch(l.key){case`Escape`:n(l),r!==null&&s!==null?(i(null),o(-1)):m();return;case`ArrowLeft`:n(l),y(-1);return;case`ArrowRight`:n(l),y(1);return;case`ArrowDown`:n(l),r===null?h(v,!0):o(MW(_,a,1));return;case`ArrowUp`:n(l),r===null?(h(v,!0),o(MW(p(v),0,-1))):o(MW(_,a<0?0:a,-1));return;case`Home`:n(l),r!==null&&o(MW(_,-1,1));return;case`End`:n(l),r!==null&&o(MW(_,0,-1));return;case`Enter`:case` `:n(l),r===null?h(v,!0):g(_[a]);return;case`Tab`:m();return}if(l.key.length===1&&!l.ctrlKey&&!l.metaKey){n(l);let e=l.key.toLowerCase();if(r!==null)g(_.find(t=>t.mnemonic===e&&jW(t)));else{let t=f.findIndex(t=>t.mnemonic===e);t>=0&&h(t,!0)}return}m()},_=n=>{n.key===`Alt`&&(u(!1),e&&(e=!1,t()?m():c(0)))},v=()=>{e=!1,u(!1),m()},y=e=>{(r!==null||s!==null)&&(d.current&&e.target instanceof Node&&d.current.contains(e.target)||m())};return window.addEventListener(`keydown`,l,!0),window.addEventListener(`keyup`,_,!0),window.addEventListener(`blur`,v),document.addEventListener(`mousedown`,y,!0),()=>{window.removeEventListener(`keydown`,l,!0),window.removeEventListener(`keyup`,_,!0),window.removeEventListener(`blur`,v),document.removeEventListener(`mousedown`,y,!0)}},[f,r,s,a,p,h,g,m]),!t||f.length===0)return null;let _=l||s!==null;return(0,W.jsx)(`div`,{ref:d,role:`menubar`,"aria-label":`Application menu`,className:`flex h-7 shrink-0 items-stretch gap-px border-b border-border bg-surface px-1 text-[13px] text-fg select-none`,children:f.map((e,t)=>{let n=r===t;return(0,W.jsxs)(`div`,{className:`relative flex`,children:[(0,W.jsx)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`menu`,"aria-expanded":n,tabIndex:-1,disabled:!e.enabled,"data-menu-top":e.id,onMouseDown:e=>{e.preventDefault(),n?m():h(t,!1)},onMouseEnter:()=>{r!==null&&r!==t&&h(t,!1)},className:U(`my-0.5 rounded-sm px-2.5`,n||s===t?`bg-surface-3`:`hover:bg-surface-2`,!e.enabled&&`text-fg-faint`),children:(0,W.jsx)(NW,{label:e.label,mnemonic:e.mnemonic,show:_})}),n&&e.submenu?(0,W.jsx)(FW,{entries:e.submenu,active:a,showMnemonics:_,onHover:o,onRun:g}):null]},e.id)})})}function FW({entries:e,active:t,showMnemonics:n,onHover:r,onRun:i,nested:a=!1}){let[o,s]=(0,v.useState)(null);return(0,W.jsx)(`div`,{role:`menu`,className:U(`absolute z-[70] min-w-[15rem] rounded-md border border-border bg-surface py-1 text-fg shadow-lg`,a?`top-0 left-full -mt-1 ml-px`:`top-full left-0 mt-px`),children:e.map((e,a)=>{if(e.type===`separator`)return(0,W.jsx)(`div`,{role:`separator`,className:`my-1 border-t border-border`},e.id);let c=e.type===`checkbox`?`menuitemcheckbox`:e.type===`radio`?`menuitemradio`:`menuitem`,l=e.type===`checkbox`||e.type===`radio`;return(0,W.jsxs)(`div`,{role:c,"aria-disabled":!e.enabled||void 0,"aria-checked":l?e.checked:void 0,"aria-haspopup":e.type===`submenu`?`menu`:void 0,"data-menu-entry":e.id,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>{r(a),s(e.type===`submenu`?a:null)},onClick:()=>i(e),className:U(`relative flex cursor-default items-center gap-2 px-3 py-1`,a===t&&e.enabled&&`bg-surface-2`,!e.enabled&&`text-fg-faint`),children:[(0,W.jsx)(`span`,{className:`w-4 shrink-0 text-center`,"aria-hidden":!0,children:l&&e.checked?e.type===`radio`?`•`:`✓`:``}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:(0,W.jsx)(NW,{label:e.label,mnemonic:e.mnemonic,show:n})}),e.accelerator?(0,W.jsx)(`span`,{className:`shrink-0 pl-6 text-xs text-fg-faint`,children:e.accelerator}):null,e.type===`submenu`?(0,W.jsx)(`span`,{className:`shrink-0 pl-4 text-fg-faint`,"aria-hidden":!0,children:`›`}):null,e.type===`submenu`&&o===a&&e.submenu?(0,W.jsx)(FW,{entries:e.submenu,active:-1,showMnemonics:n,onHover:()=>{},onRun:i,nested:!0}):null]},e.id)})})}function IW(e){return!!e&&typeof e==`object`&&typeof e.hostId==`string`}function LW(e){return Math.min(5e3,500*2**Math.max(0,e))}async function RW(e){let t=e.sleep??(e=>new Promise(t=>setTimeout(t,e)));for(let n=0;;n++){if(e.cancelled?.())return null;try{let t=await e.getConnection();if(t&&typeof t.token==`string`&&t.token&&typeof t.baseUrl==`string`&&await e.accepts(t).catch(()=>!1))return t}catch{}await t(LW(n))}}function zW(){let[e,t]=(0,v.useState)(void 0),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(0),c=(0,v.useRef)(!1),l=(0,v.useRef)(!1);(0,v.useEffect)(()=>()=>{l.current=!0},[]);let u=(0,v.useCallback)(()=>{let e=window.oonacode;return!e||typeof e.getConnection!=`function`?!1:c.current?!0:(c.current=!0,RW({getConnection:()=>e.getConnection(),accepts:e=>vm(e).health().then(e=>IW(e),()=>!1),cancelled:()=>l.current}).then(e=>{c.current=!1,e&&(lW(window.sessionStorage,e),s(e=>e+1),t({baseUrl:e.baseUrl,token:e.token}))}),!0)},[]);(0,v.useEffect)(()=>{dW().then(e=>{r(e.sessionId),!(!e.connection&&u())&&t(e.connection)})},[u]),(0,v.useEffect)(()=>{e!==void 0&&document.getElementById(`oona-splash`)?.remove()},[e]);let d=(0,v.useCallback)(()=>{lW(window.sessionStorage,null),!u()&&(a(`The host rejected the token. Paste a current one from the host.`),t(null))},[u]),f=(0,v.useMemo)(()=>{if(!e)return null;let t=vm(e),n=window.oonacode?.window?.id;return{api:t,socket:new hW({baseUrl:e.baseUrl,token:e.token,clientKind:window.oonacode?`desktop`:`web`,clientVersion:window.oonacode?.appVersion,...n?{clientId:`${n.slice(0,16)}-${pW()}`}:{}}),relay:new OW({baseUrl:e.baseUrl,token:e.token,clientId:window.oonacode?`desktop`:`web-ui`,...window.oonacode?.appVersion?{clientVersion:window.oonacode.appVersion}:{}})}},[e]),p=(0,v.useMemo)(()=>f?wW({api:f.api,appVersion:window.oonacode?.appVersion??null,platform:window.oonacode?.platform??null,embedded:window.oonacode?`desktop`:`browser`}):null,[f]);return(0,v.useEffect)(()=>p?.install(window),[p]),e===void 0?null:!e||!f?(0,W.jsx)(kW,{defaultBaseUrl:window.location.origin,error:i,onConnect:e=>{lW(window.sessionStorage,e),a(null),t(e)}}):(0,W.jsx)(iW,{api:f.api,socket:f.socket,relay:f.relay,initialSessionId:n,onUnauthorized:d,...p?{reportError:p.report}:{}},o)}function BW({children:e}){let t=typeof window>`u`?void 0:window.oonacode;return AW(t)?(0,W.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,W.jsx)(PW,{bridge:t}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1`,children:e})]}):(0,W.jsx)(W.Fragment,{children:e})}var VW=document.getElementById(`root`);(0,y.createRoot)(VW).render((0,W.jsx)(v.StrictMode,{children:(0,W.jsx)(BW,{children:(0,W.jsx)(zW,{})})}));
|
|
160
|
+
- use the browser on port 9170 for anything on the web`,maxLength:ec.instructions,"data-testid":`project-instructions`})})]}),(0,W.jsxs)(PR,{title:`Repositories`,children:[(0,W.jsx)(Wy,{label:`One per line (optional)`,hint:`Every chat in the project is told about them.`,children:(0,W.jsx)(`textarea`,{className:U(X,`h-16 font-mono text-xs`),value:u.repositories,onChange:e=>g(`repositories`,e.target.value),placeholder:`https://github.com/you/app`,"data-testid":`project-repositories`})}),(0,W.jsx)(MR,{compact:!0})]}),(0,W.jsxs)(PR,{title:`New chats`,children:[(0,W.jsx)(Wy,{label:`Model`,hint:`What a new chat in this project starts on.`,children:(0,W.jsxs)(`select`,{className:X,value:u.model,onChange:e=>{g(`model`,e.target.value),g(`effort`,``)},"data-testid":`project-model`,children:[(0,W.jsx)(`option`,{value:``,children:`Whatever a new chat would start on`}),x?(0,W.jsxs)(`option`,{value:u.model,children:[x.model,` (not on this PC)`]}):null,y.map(e=>(0,W.jsx)(`option`,{value:e.key,children:e.label},e.key))]})}),S.length>0?(0,W.jsx)(Wy,{label:`Effort`,children:(0,W.jsxs)(`select`,{className:X,value:u.effort,onChange:e=>g(`effort`,e.target.value),"data-testid":`project-effort`,children:[(0,W.jsx)(`option`,{value:``,children:`Default`}),S.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))]})}):null,(0,W.jsx)(Wy,{label:`Folder`,hint:`Where a new chat runs; left empty, each chat gets its own.`,children:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{className:U(X,`flex-1 font-mono text-xs`),value:u.cwd,onChange:e=>g(`cwd`,e.target.value),placeholder:s,"data-testid":`project-cwd`}),window.oonacode?.pickDirectory?(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>void O(),children:`Choose…`}):null]})})]}),(0,W.jsxs)(PR,{title:`Memory`,children:[(0,W.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:u.memoryEnabled,onChange:e=>g(`memoryEnabled`,e.target.checked),"data-testid":`project-memory-enabled`}),(0,W.jsx)(`span`,{children:`Keep a project memory — notes every chat of the project reads at its start, and the agent keeps up to date.`})]}),u.memoryEnabled?(0,W.jsx)(`textarea`,{className:U(X,`h-28 font-mono text-xs`),value:u.memory,onChange:e=>g(`memory`,e.target.value),placeholder:`Nothing noted yet.`,maxLength:ec.memory,"data-testid":`project-memory`}):null]}),(0,W.jsxs)(PR,{title:`Scheduled tasks`,children:[(0,W.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:u.tasksEnabled,onChange:e=>g(`tasksEnabled`,e.target.checked),"data-testid":`project-tasks-enabled`}),(0,W.jsx)(`span`,{children:`The agent may schedule work in this project's chats — once, or on a repeat — with OonaCode's scheduler on this PC.`})]}),u.tasksEnabled?(0,W.jsx)(Wy,{label:`Shortest repeat, in minutes`,children:(0,W.jsx)(`input`,{className:U(X,`w-28`),inputMode:`numeric`,value:u.minInterval,onChange:e=>g(`minInterval`,e.target.value),"data-testid":`project-min-interval`})}):null,_?(0,W.jsx)(WN,{projectId:_.id,showChat:!0}):null]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Saved settings reach the project's chats at their next message. Projects live in your vault: only your own devices can read them.`})]})]})})}var IR=`(min-width: 768px)`;function LR(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(IR).matches}function RR(){let[e,t]=(0,v.useState)(LR);return(0,v.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(IR),n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function zR(e){try{return!!e?.matches(`:hover`)}catch{return!1}}function BR(e){if(typeof document>`u`)return!1;if(document.querySelector(`[role="menu"], [role="dialog"]`))return!0;let t=document.activeElement;return!!(e&&t&&e.contains(t)&&t.tagName===`INPUT`)}function VR({hidden:e,children:t}){let{state:n,actions:r}=G(),i=n.ui.sidebarPinnedOverride??n.prefs.sidebarPinned,a=n.ui.sidebarOpen,[o,s]=(0,v.useState)(null),c=o??n.prefs.sidebarWidth,[l,u]=(0,v.useState)(!1),d=RR(),f=(0,v.useRef)(null),p=(0,v.useRef)(null),m=(0,v.useCallback)(()=>{p.current!==null&&(clearTimeout(p.current),p.current=null)},[]),h=(0,v.useCallback)(()=>{m(),p.current=setTimeout(function e(){if(BR(f.current)){p.current=setTimeout(e,350);return}p.current=null,!zR(f.current)&&u(!1)},350)},[m]);(0,v.useEffect)(()=>m,[m]),(0,v.useEffect)(()=>{u(!1),m()},[i,m]),(0,v.useEffect)(()=>{if(e)return;let t=e=>{if(!(!(e.ctrlKey||e.metaKey)||e.shiftKey||e.altKey)&&(e.key===`k`||e.key===`K`)){if(LR()){if(i)return;u(!0),h()}else a||r.setSidebar(!0)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,i,a,h,r]);let g=e=>{e.preventDefault();let t=e.clientX,i=c,a=i,o=e=>{a=zc(i+(e.clientX-t)),s(a)},l=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,l),document.body.style.cursor=``,document.body.style.userSelect=``,s(null),a!==n.prefs.sidebarWidth&&r.savePrefs({sidebarWidth:a})};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,l)},_=i||l;return(0,W.jsxs)(W.Fragment,{children:[!i&&!l&&!e?(0,W.jsx)(`div`,{className:`absolute inset-y-0 left-0 z-40 hidden w-2 md:block`,onMouseEnter:()=>{u(!0),h()},"aria-hidden":!0,"data-testid":`sidebar-hover-edge`}):null,(0,W.jsxs)(`aside`,{ref:f,"data-chrome":`sidebar`,hidden:e,inert:!e&&(d?!_:!a),"data-testid":`sidebar-frame`,"data-state":i?`docked`:l?`peek`:`hidden`,style:{"--sidebar-w":`${c}px`},onMouseEnter:i?void 0:m,onMouseLeave:i?void 0:h,className:U(`absolute inset-y-0 left-0 z-30 w-72 max-w-[85vw] border-r border-border bg-surface transition-transform md:w-[var(--sidebar-w)] md:max-w-[70vw]`,a?`translate-x-0`:`-translate-x-full`,i?`md:relative md:z-auto md:translate-x-0`:U(`md:z-40 md:shadow-2xl`,_?`md:translate-x-0`:`md:-translate-x-full`)),children:[t,(0,W.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the session list`,title:`Drag to resize · double-click for the default width`,className:`absolute inset-y-0 -right-1 z-10 hidden w-2 cursor-col-resize hover:bg-accent/30 md:block`,onPointerDown:g,onDoubleClick:()=>void r.savePrefs({sidebarWidth:288}),"data-testid":`sidebar-resize`})]})]})}function HR({open:e,onClose:t}){return(0,W.jsx)(Ky,{open:e,title:`Export my chats`,onClose:t,children:(0,W.jsx)(UR,{onDone:t})})}function UR({onDone:e}){let{api:t,state:n}=G(),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(0),p=n.sessionsTotal||n.sessions.length;(0,v.useEffect)(()=>{if(!a){f(0);return}let e=Date.now(),t=setInterval(()=>f(Math.floor((Date.now()-e)/1e3)),1e3);return()=>clearInterval(t)},[a]);let m=async()=>{if(!t.exportSessionsArchive){c(`this PC is running an older OonaCode that cannot export chats`);return}o(!0),c(null);try{let n=await t.exportSessionsArchive(r),a=URL.createObjectURL(n),o=document.createElement(`a`);o.href=a,o.download=`oonacode-chats-${new Date().toISOString().slice(0,10)}.zip`,o.click(),URL.revokeObjectURL(a),i(``),u(!1),e()}catch(e){c(e instanceof Error?e.message:`the export failed`)}finally{o(!1)}};return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Ky,{open:a,title:`Exporting your chats`,onClose:()=>void 0,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(q.Spinner,{className:`mt-0.5 w-5 h-5 shrink-0 text-accent`}),(0,W.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,W.jsxs)(`div`,{className:`font-medium`,children:[`Packing`,` `,p>0?`${p} chat${p===1?``:`s`}`:`your chats`,`…`]}),(0,W.jsxs)(`div`,{className:`mt-1 tabular text-fg-muted`,children:[Math.floor(d/60),`:`,String(d%60).padStart(2,`0`),` elapsed`]}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-faint`,children:`Your PC writes the whole archive before the download starts, so nothing appears in your downloads until it is finished. A long history can take a minute or two — this is normal, and you do not need to press anything again.`})]})]})}),(0,W.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`One zip with a plain `,(0,W.jsx)(`code`,{children:`.txt`}),` of every conversation on this PC, plus an index. It is for reading and copying from — there is no way to load it back in.`]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-warn`,children:`The zip is not encrypted: anyone who opens it can read every conversation in it.`}),l?(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`password`,autoFocus:!0,className:X+` max-w-[16rem]`,placeholder:`Account password`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r&&m()},"data-testid":`export-chats-password`}),(0,W.jsx)(J,{onClick:()=>void m(),disabled:a||!r,children:a?`Exporting…`:`Export`}),(0,W.jsx)(J,{variant:`ghost`,onClick:()=>{u(!1),i(``),c(null)},children:`Cancel`})]}):(0,W.jsx)(J,{className:`mt-2`,onClick:()=>u(!0),"data-testid":`export-chats`,children:`Export chats…`}),s?(0,W.jsx)(`div`,{className:`mt-2 text-xs text-danger`,children:s}):null]})}var WR=70,GR=96,KR=170,qR=56;function JR(e,t=22){let n=e.trim().replace(/\s+/g,` `);return n.length<=t?n:`${n.slice(0,Math.max(1,t-1)).trimEnd()}…`}var YR={working:3,idle:2,asleep:1,missing:0},XR=Math.PI*2,ZR=e=>(e%XR+XR)%XR,QR=e=>Math.round(e*100)/100;function $R(e){let t=0,n=0;for(let r of e)t+=Math.cos(r),n+=Math.sin(r);return Math.hypot(t,n)<1e-9?null:Math.atan2(n,t)}function ez(e,t=!1){return e.filter(e=>t||e.status!==`closed`).filter(e=>e.members.length>0).sort((e,t)=>e.createdAt===t.createdAt?e.id<t.id?-1:+(e.id>t.id):e.createdAt<t.createdAt?-1:1)}function tz(e,t={}){let n=t.now??Date.now(),r=ez(e,t.showClosed??!1),i=t.showClosed?0:e.filter(e=>e.status===`closed`).length,a=r.length,o=a<=1?0:Math.max(72,a*GR/XR),s=e=>-Math.PI/2+XR*e/Math.max(1,a),c=new Map;r.forEach((e,t)=>{for(let n of e.members){let r=n.leftAt===null,i=c.get(n.sessionId);i?(r&&!i.titleFromCurrent&&n.title&&(i.title=n.title,i.titleFromCurrent=!0),YR[n.state]>YR[i.state]&&(i.state=n.state)):(i={sessionId:n.sessionId,hostId:n.hostId,title:n.title,titleFromCurrent:r,state:n.state,hubs:[],conversationIds:[],anyCurrent:!1},c.set(n.sessionId,i)),i.conversationIds.includes(e.id)||(i.hubs.push(t),i.conversationIds.push(e.id)),r&&(i.anyCurrent=!0)}});let l=c.size,u=Math.max(o+120,l*WR/XR,110),d=[...c.values()].map(e=>({acc:e,pref:ZR((a<=1?0:$R(e.hubs.map(s))??s(e.hubs[0]))+Math.PI/2)})).sort((e,t)=>Math.abs(e.pref-t.pref)>1e-9?e.pref-t.pref:e.acc.sessionId<t.acc.sessionId?-1:+(e.acc.sessionId>t.acc.sessionId)),f=XR/Math.max(1,l),p=(a<=1?null:$R(d.map((e,t)=>e.pref-t*f)))??0,m=QR(2*(u+KR)),h=QR(2*(u+qR)),g=m/2,_=h/2,v=r.map((e,t)=>{let r=s(t),i=e.members.filter(e=>e.leftAt===null).length,a=Date.parse(e.lastActivityAt),c=Ed(e);return{id:e.id,x:QR(g+o*Math.cos(r)),y:QR(_+o*Math.sin(r)),name:c,label:JR(c),status:e.status,waiting:e.waiting,members:i,messageCount:e.messageCount,recent:e.status!==`closed`&&Number.isFinite(a)&&n-a>=-5e3&&n-a<=6e4}}),y=d.map(({acc:e},t)=>{let n=-Math.PI/2+p+t*f,r=g+u*Math.cos(n),i=_+u*Math.sin(n),a=Math.cos(n),o=Math.sin(n),s=a>.3?`start`:a<-.3?`end`:`middle`,c=s===`middle`?r:r+a*15,l=s===`middle`?o<0?i-15:i+15+8:i+o*15+4;return{sessionId:e.sessionId,hostId:e.hostId,x:QR(r),y:QR(i),title:e.title,label:JR(e.title||`a chat`),state:e.state,conversationIds:e.conversationIds,left:!e.anyCurrent,labelX:QR(c),labelY:QR(l),anchor:s}}),b=new Map(v.map(e=>[e.id,e])),x=new Map(y.map(e=>[e.sessionId,e])),S=[];for(let e of r){let t=b.get(e.id),n=new Set,r=new Map;for(let t of e.members)r.set(t.sessionId,(r.get(t.sessionId)??!0)&&t.leftAt!==null);for(let i of e.members){if(n.has(i.sessionId))continue;n.add(i.sessionId);let a=x.get(i.sessionId);S.push({conversationId:e.id,sessionId:i.sessionId,left:r.get(i.sessionId)??!1,x1:t.x,y1:t.y,x2:a.x,y2:a.y})}}return{hubs:v,chats:y,edges:S,width:m,height:h,hiddenClosed:i}}function nz(e){if(!e)return null;for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.kind===`notice`||!n.fromSession))return{conversationId:n.conversationId,from:n.fromSession,to:n.toSession,kind:n.kind}}return null}function rz(e,t,n,r,i,a){let o=Math.hypot(n-e,r-t);if(o<=i+a||o===0)return{x1:e,y1:t,x2:n,y2:r};let s=(n-e)/o,c=(r-t)/o;return{x1:QR(e+s*i),y1:QR(t+c*i),x2:QR(n-s*a),y2:QR(r-c*a)}}var iz={working:`working`,idle:`idle`,asleep:`asleep`,missing:`not on this PC any more`},az={working:`fill-accent stroke-accent animate-pulse`,idle:`fill-accent-soft stroke-accent`,asleep:`fill-surface-3 stroke-fg-faint`,missing:`fill-surface-2 stroke-fg-faint`},oz={active:`stroke-ok`,paused:`stroke-warn`,closed:`stroke-fg-faint`};function sz(e){return t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())}}function cz({list:e,showClosed:t,selectedId:n,messages:r,onSelectConversation:i,onOpenChat:a,canOpenChat:o,now:s}){let c=(0,v.useMemo)(()=>tz(e,{showClosed:t,now:s}),[e,t,s]),l=(0,v.useMemo)(()=>nz(r),[r]);if(c.hubs.length===0)return(0,W.jsxs)(`div`,{className:`space-y-1 py-6 text-center text-sm text-fg-muted`,"data-testid":`conversation-map-empty`,children:[(0,W.jsx)(`p`,{children:`No chats are talking to each other right now.`}),(0,W.jsx)(`p`,{className:`text-xs`,children:`Turn on "Talk to other chats" in a chat's Tools menu.`}),c.hiddenClosed>0?(0,W.jsxs)(`p`,{className:`text-xs text-fg-faint`,children:[c.hiddenClosed,` closed conversation`,c.hiddenClosed===1?``:`s`,` hidden.`]}):null]});let u=new Map(c.hubs.map(e=>[e.id,e])),d=new Map(c.chats.map(e=>[e.sessionId,e])),f=[];if(l&&u.has(l.conversationId)){let e=u.get(l.conversationId),t=d.get(l.from),n=d.get(l.to);t&&f.push({key:`from`,...rz(t.x,t.y,e.x,e.y,11,20)}),n&&f.push({key:`to`,...rz(e.x,e.y,n.x,n.y,18,13)})}return(0,W.jsxs)(`div`,{className:`max-h-[65vh] overflow-auto rounded-md border border-border bg-surface`,"data-testid":`conversation-map`,children:[(0,W.jsxs)(`svg`,{viewBox:`0 0 ${c.width} ${c.height}`,preserveAspectRatio:`xMidYMid meet`,className:`block h-auto w-full min-w-[480px] select-none`,style:{maxHeight:`63vh`},role:`img`,"aria-label":`Which chats are talking to each other`,children:[(0,W.jsx)(`defs`,{children:(0,W.jsx)(`marker`,{id:`conversation-map-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,W.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,className:`fill-accent`})})}),(0,W.jsx)(`g`,{"data-testid":`conversation-map-edges`,children:c.edges.map(e=>{let t=u.get(e.conversationId),r=e.conversationId===n;return(0,W.jsx)(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,className:U(r?`stroke-accent`:t.status===`active`?`stroke-fg-muted`:`stroke-border`),strokeWidth:r?2:t.status===`active`?1.5:1,strokeDasharray:e.left?`4 4`:void 0,opacity:t.status===`closed`?.5:1,"data-testid":`map-edge-${e.conversationId}-${e.sessionId}`,"data-left":e.left?`true`:void 0},`${e.conversationId}:${e.sessionId}`)})}),f.length>0?(0,W.jsx)(`g`,{"data-testid":`conversation-map-latest`,children:f.map(e=>(0,W.jsx)(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,className:`stroke-accent`,strokeWidth:3,markerEnd:`url(#conversation-map-arrow)`},e.key))}):null,c.hubs.map(e=>{let t=e.id===n,r=[e.name,`${Ad[e.status]} · ${e.members} chat${e.members===1?``:`s`} · ${e.messageCount} message${e.messageCount===1?``:`s`}`,e.waiting>0?`${e.waiting} waiting to be delivered`:null,`Click to see this conversation.`].filter(Boolean).join(`
|
|
161
|
+
`);return(0,W.jsxs)(`g`,{role:`button`,tabIndex:0,"aria-label":`Conversation ${e.name}, ${Ad[e.status]}`,"aria-pressed":t,className:`cursor-pointer outline-none`,onClick:()=>i(e.id),onKeyDown:sz(()=>i(e.id)),"data-testid":`map-hub-${e.id}`,"data-status":e.status,"data-recent":e.recent?`true`:void 0,children:[(0,W.jsx)(`title`,{children:r}),e.recent?(0,W.jsx)(`circle`,{cx:e.x,cy:e.y,r:23,className:`fill-accent-soft stroke-accent animate-pulse`,strokeWidth:1}):null,(0,W.jsx)(`circle`,{cx:e.x,cy:e.y,r:16,className:U(t?`fill-accent-soft`:`fill-surface-2`,oz[e.status]),strokeWidth:t?3.5:2.5,strokeDasharray:e.status===`paused`?`5 3`:void 0}),(0,W.jsx)(`text`,{x:e.x,y:e.y+4,textAnchor:`middle`,className:`fill-fg text-[11px] font-semibold`,children:e.members}),(0,W.jsx)(`text`,{x:e.x,y:e.y+16+14,textAnchor:`middle`,className:U(`text-[11px]`,e.status===`closed`?`fill-fg-faint`:`fill-fg`,t&&`font-semibold`),children:e.label}),e.status!==`active`||e.waiting>0?(0,W.jsx)(`text`,{x:e.x,y:e.y+16+27,textAnchor:`middle`,className:U(`text-[10px]`,e.status===`paused`?`fill-warn`:`fill-fg-faint`),children:[e.status===`active`?null:Ad[e.status],e.waiting>0?`${e.waiting} waiting`:null].filter(Boolean).join(` · `)}):null]},e.id)}),c.chats.map(e=>{let t=e.state!==`missing`&&o(e.sessionId),n=e.conversationIds.map(e=>u.get(e)?.name??e),r=[e.title,iz[e.state],`In ${n.length} conversation${n.length===1?``:`s`}: ${n.join(`, `)}`,e.left?`It has left.`:null,t?`Click to open this chat.`:null].filter(Boolean).join(`
|
|
162
|
+
`),i=e.state===`missing`||e.left;return(0,W.jsxs)(`g`,{role:t?`button`:void 0,tabIndex:t?0:void 0,"aria-label":t?`Open chat ${e.title}`:void 0,className:U(t?`cursor-pointer`:`cursor-default`,`outline-none`),opacity:i?.5:1,onClick:t?()=>a(e.sessionId):void 0,onKeyDown:t?sz(()=>a(e.sessionId)):void 0,"data-testid":`map-chat-${e.sessionId}`,"data-state":e.state,children:[(0,W.jsx)(`title`,{children:r}),(0,W.jsx)(`circle`,{cx:e.x,cy:e.y,r:9,className:az[e.state],strokeWidth:2,strokeDasharray:e.state===`missing`?`3 2`:void 0}),(0,W.jsx)(`text`,{x:e.labelX,y:e.labelY,textAnchor:e.anchor,className:`fill-fg text-[11px]`,children:e.label})]},e.sessionId)})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-border px-3 py-1.5 text-[11px] text-fg-muted`,"data-testid":`conversation-map-legend`,children:[(0,W.jsx)(lz,{dot:`bg-accent animate-pulse`,children:`working`}),(0,W.jsx)(lz,{dot:`bg-accent-soft border border-accent`,children:`idle`}),(0,W.jsx)(lz,{dot:`bg-surface-3 border border-fg-faint`,children:`asleep`}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(`span`,{className:`inline-block h-3 w-3 rounded-full border-2 border-ok`}),`active`]}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(`span`,{className:`inline-block h-3 w-3 rounded-full border-2 border-dashed border-warn`}),`paused`]}),(0,W.jsx)(`span`,{children:`dashed spoke: left`}),f.length>0?(0,W.jsx)(`span`,{className:`text-accent`,children:`arrows: the newest message`}):null,c.hiddenClosed>0?(0,W.jsxs)(`span`,{className:`text-fg-faint`,children:[c.hiddenClosed,` closed hidden`]}):null]})]})}function lz({dot:e,children:t}){return(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(`span`,{className:U(`inline-block h-2.5 w-2.5 rounded-full`,e)}),t]})}function uz({open:e,selectId:t=null,onClose:n}){let{state:r,actions:i}=G(),a=r.conversationsChange,[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(`list`),[C,w]=(0,v.useState)(!1),T=(0,v.useRef)(null);T.current=f;let E=(0,v.useRef)(-1),D=(0,v.useCallback)(async()=>{let e=await i.listConversations();if(e===`unsupported`){l(!0);return}if(e===null){d(!0);return}l(!1),d(!1),s(e)},[i]),O=(0,v.useCallback)(async e=>{let t=await i.conversationHistory(e);t&&T.current===e&&h(t)},[i]);(0,v.useEffect)(()=>{e&&(E.current=a.seq,_(!1),p(t??null),D())},[e]),(0,v.useEffect)(()=>{!e||f!==null||!o||o.length===0||p(o[0].id)},[e,o,f]),(0,v.useEffect)(()=>{if(!e||!f){h(null);return}h(e=>e?.conversation.id===f?e:null),O(f)},[e,f,O]),(0,v.useEffect)(()=>{if(!e||a.seq===E.current)return;E.current=a.seq,D();let t=T.current;t&&(a.conversationIds===null||a.conversationIds.includes(t))&&O(t)},[e,a,D,O]);let k=e=>{s(t=>t?.map(t=>t.id===e.id?e:t)??t),h(t=>t&&t.conversation.id===e.id?{...t,conversation:e}:t)},A=async(e,t,n)=>{let r=await i.conversationAction(e,t,n);return r&&k(r),r!==null},j=async()=>{b(!0);try{await i.stopAllConversations()}finally{b(!1),_(!1)}D(),T.current&&O(T.current)},M=async e=>{await i.cancelChatMessage(e.id),T.current&&O(T.current)},ee=(0,v.useCallback)((e,t,n=[])=>{if(!e)return t??`OonaCode`;let i=n.find(t=>t.sessionId===e);if(i?.title)return i.title;if(t)return t;let a=r.sessions.find(t=>t.id===e);return a?pg(a):`a chat`},[r.sessions]),N=m&&m.conversation.id===f?m.conversation:o?.find(e=>e.id===f)??null;return(0,W.jsxs)(Ky,{open:e,title:`Conversations`,onClose:n,wide:!0,footer:(0,W.jsx)(J,{variant:`ghost`,onClick:n,children:`Close`}),children:[(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,W.jsxs)(`p`,{className:`min-w-0 flex-1 text-xs text-fg-muted`,children:[`Messages and tasks your chats send each other, on this PC.`,` `,(0,W.jsx)(Hy,{label:`Conversations`,details:Kd.window})]}),c?null:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsxs)(J,{variant:`danger`,size:`sm`,onClick:()=>_(!0),disabled:g||y,title:Kd.stopAll,"data-testid":`conversations-stop-all`,children:[(0,W.jsx)(q.Stop,{className:`h-3 w-3`}),` Stop all conversations`]}),(0,W.jsx)(Hy,{label:`Stop all conversations`,details:Kd.stopAll})]})]}),g?(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alertdialog`,"aria-label":`Stop all conversations?`,"data-testid":`conversations-stop-confirm`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Pause every conversation and stop the turns they are running now? Nothing is deleted; you can resume each one.`}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>_(!1),children:`Cancel`}),(0,W.jsx)(J,{size:`sm`,variant:`danger`,busy:y,onClick:()=>void j(),"data-testid":`conversations-stop-confirm-yes`,children:`Stop all`})]}):null,!c&&o!==null?(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`inline-flex overflow-hidden rounded-md border border-border text-xs`,role:`group`,"aria-label":`View`,children:[`list`,`map`].map(e=>(0,W.jsx)(`button`,{type:`button`,"aria-pressed":x===e,onClick:()=>S(e),className:U(`px-3 py-1`,x===e?`bg-accent text-accent-fg`:`text-fg-muted hover:bg-surface-2`),title:e===`list`?Kd.listView:Kd.mapView,"data-testid":`conversations-view-${e}`,children:e===`list`?`List`:`Map`},e))}),x===`map`?(0,W.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-muted`,title:Kd.showClosed,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked),"data-testid":`conversation-map-show-closed`}),`Show closed`]}):null,(0,W.jsx)(Hy,{label:`Map`,details:Kd.mapView})]}):null,c?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`conversations-unsupported`,children:`OonaCode on this PC is too old for conversations between chats. Update it, then open this window again.`}):o===null?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`conversations-loading`,children:u?`Could not read the conversations from this PC right now. They show here as soon as it answers.`:`Loading…`}):x===`map`?(0,W.jsx)(cz,{list:o,showClosed:C,selectedId:f,messages:m&&m.conversation.id===f?m.messages:null,onSelectConversation:e=>{p(e),S(`list`)},onOpenChat:e=>{n(),i.selectSession(e)},canOpenChat:e=>r.sessions.some(t=>t.id===e)}):o.length===0?(0,W.jsxs)(`div`,{className:`space-y-1 text-sm text-fg-muted`,"data-testid":`conversations-empty`,children:[(0,W.jsx)(`p`,{children:`No conversations yet.`}),(0,W.jsx)(`p`,{className:`text-xs`,children:`To start one, turn on "Talk to other chats" in the Tools menu of two chats, then ask one of them to send the other a message or a task.`})]}):(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[260px_1fr]`,children:[(0,W.jsx)(`ul`,{className:`flex max-h-[65vh] flex-col gap-1 overflow-y-auto pr-1`,"data-testid":`conversations-list`,children:o.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(pz,{c:e,selected:e.id===f,onSelect:()=>p(e.id)})},e.id))}),(0,W.jsx)(`div`,{className:`max-h-[65vh] min-w-0 overflow-y-auto pr-1`,children:N?(0,W.jsx)(_z,{c:N,messages:m&&m.conversation.id===N.id?m.messages:null,titleOf:ee,onAction:(e,t)=>A(N.id,e,t),onWithdraw:e=>void M(e),onOpenChat:e=>{n(),i.selectSession(e)},isLocalChat:e=>r.sessions.some(t=>t.id===e)},N.id):(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Choose a conversation.`})})]})]})}function dz({c:e}){return(0,W.jsx)(`span`,{title:Kd.status,"data-testid":`conversation-status`,children:(0,W.jsx)(Z,{tone:jd(e.status),children:Ad[e.status]})})}function fz({label:e,used:t,budget:n,format:r=e=>e.toLocaleString()}){let i=Vd(t,n),a=i>=1?`bg-danger`:i>=.8?`bg-warn`:`bg-accent`;return(0,W.jsxs)(`div`,{className:`mt-1`,"data-testid":`usage-${e.toLowerCase()}`,children:[(0,W.jsxs)(`div`,{className:`flex justify-between gap-2 text-[11px] text-fg-muted`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsxs)(`span`,{"data-testid":`usage-numbers`,children:[r(t),` of `,r(n)]})]}),(0,W.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`${e} used`,"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":t,children:(0,W.jsx)(`div`,{className:U(`h-full rounded-full`,a),style:{width:`${Math.round(i*100)}%`}})})]})}function pz({c:e,selected:t,onSelect:n}){let r=e.members.filter(e=>e.leftAt===null);return(0,W.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,className:U(`w-full rounded-md border px-2.5 py-2 text-left text-xs`,t?`border-accent bg-accent-soft`:`border-border hover:bg-surface-2`),"data-testid":`conversation-row-${e.id}`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:Ed(e)}),(0,W.jsx)(dz,{c:e})]}),(0,W.jsxs)(`div`,{className:`mt-0.5 truncate text-fg-muted`,"data-testid":`conversation-members`,children:[r.length,` chat`,r.length===1?``:`s`,e.title?`: ${r.map(e=>e.title).join(`, `)}`:``]}),e.status!==`active`&&e.pausedReason?(0,W.jsx)(`div`,{className:`mt-0.5 text-warn`,"data-testid":`conversation-paused-reason`,children:e.pausedReason}):null,(0,W.jsx)(fz,{label:`Messages`,used:e.used.messages,budget:e.budget.messages}),(0,W.jsx)(fz,{label:`Tokens`,used:e.used.tokens,budget:e.budget.tokens,format:ig}),(0,W.jsxs)(`div`,{className:`mt-1 flex justify-between gap-2 text-[11px] text-fg-faint`,children:[(0,W.jsx)(`span`,{"data-testid":`conversation-cost`,children:Wd(e.used.credits)}),(0,W.jsx)(`span`,{title:sg(e.lastActivityAt),children:ag(e.lastActivityAt)})]})]})}function mz({title:e,help:t,children:n}){return(0,W.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3 first:border-t-0 first:pt-0`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:[e,t?(0,W.jsx)(Hy,{label:e,details:t}):null]}),n]})}var hz={working:`working`,idle:`idle`,asleep:`asleep`,missing:`gone`},gz={working:`This chat is working on a turn right now.`,idle:`This chat is open and waiting.`,asleep:`This chat is not running; a message wakes it from its saved history.`,missing:`This chat is not on this PC any more (deleted).`};function _z({c:e,messages:t,titleOf:n,onAction:r,onWithdraw:i,onOpenChat:a,isLocalChat:o}){let[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(String(e.budget.messages)),[h,g]=(0,v.useState)(String(e.budget.tokens));(0,v.useEffect)(()=>{m(String(e.budget.messages)),g(String(e.budget.tokens))},[e.budget.messages,e.budget.tokens]);let _=async(e,t,n)=>{c(e);try{return await r(t,n)}finally{c(null)}},y=p.trim()!==String(e.budget.messages)||h.trim()!==String(e.budget.tokens),b=y?Ud(p,h):null,x=()=>{if(!y||Ud(p,h))return;let t={},n=Number(p.trim()),r=Number(h.trim());n!==e.budget.messages&&(t.messages=n),r!==e.budget.tokens&&(t.tokens=r),_(`budget`,`budget`,t)},S=e.status===`closed`,C=(0,v.useMemo)(()=>[...e.members].sort((e,t)=>(e.leftAt===null?0:1)-(t.leftAt===null?0:1)),[e.members]);return(0,W.jsxs)(`div`,{className:`space-y-4`,"data-testid":`conversation-detail`,"data-id":e.id,children:[(0,W.jsxs)(mz,{title:`Conversation`,help:Kd.status,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`min-w-0 text-base font-semibold text-fg`,children:Ed(e)}),(0,W.jsx)(dz,{c:e})]}),e.pausedReason&&!S?(0,W.jsxs)(`p`,{className:`text-xs text-warn`,"data-testid":`conversation-detail-reason`,children:[`Paused: `,e.pausedReason]}):e.pausedReason&&S?(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Closed: `,e.pausedReason]}):null,(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Started `,sg(e.createdAt),` · last activity`,` `,(0,W.jsx)(`span`,{title:sg(e.lastActivityAt),children:ag(e.lastActivityAt)}),e.waiting>0?` · ${e.waiting} waiting to be delivered`:``]}),S?null:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.status===`active`?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(J,{size:`sm`,onClick:()=>void _(`pause`,`pause`),busy:s===`pause`,title:Kd.pause,"data-testid":`conversation-pause`,children:`Pause`}),(0,W.jsx)(Hy,{label:`Pause`,details:Kd.pause})]}):(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(J,{size:`sm`,variant:`primary`,onClick:()=>void _(`resume`,`resume`),busy:s===`resume`,title:Kd.resume,"data-testid":`conversation-resume`,children:`Resume`}),(0,W.jsx)(Hy,{label:`Resume`,details:Kd.resume})]}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(J,{size:`sm`,variant:l?`danger`:`ghost`,busy:s===`close`,title:Kd.close,onClick:()=>{if(!l){u(!0);return}u(!1),_(`close`,`close`)},"data-testid":`conversation-close`,children:l?`Close it for good?`:`Close`}),(0,W.jsx)(Hy,{label:`Close`,details:Kd.close})]})]})]}),(0,W.jsxs)(mz,{title:`Budget`,help:Kd.budget,children:[(0,W.jsx)(fz,{label:`Messages`,used:e.used.messages,budget:e.budget.messages}),(0,W.jsx)(fz,{label:`Tokens`,used:e.used.tokens,budget:e.budget.tokens,format:ig}),(0,W.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,W.jsxs)(`span`,{"data-testid":`conversation-detail-cost`,children:[`Cost so far `,Wd(e.used.credits),` · `,ig(e.used.tokens),` `,`new tokens`]}),(0,W.jsx)(Hy,{label:`Cost`,details:Kd.cost})]}),S?null:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,W.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[`Messages`,(0,W.jsx)(`input`,{className:U(X,`w-24`),inputMode:`numeric`,value:p,onChange:e=>m(e.target.value),"data-testid":`conversation-budget-messages`})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[`Tokens`,(0,W.jsx)(`input`,{className:U(X,`w-32`),inputMode:`numeric`,value:h,onChange:e=>g(e.target.value),"data-testid":`conversation-budget-tokens`})]}),(0,W.jsx)(J,{size:`sm`,variant:`primary`,onClick:x,disabled:!y||b!==null,busy:s===`budget`,title:Kd.budget,"data-testid":`conversation-budget-save`,children:`Save budget`}),b?(0,W.jsx)(`span`,{className:`text-xs text-danger`,"data-testid":`conversation-budget-problem`,children:b}):null]})]}),(0,W.jsx)(mz,{title:`Chats`,help:Kd.removeMember,children:(0,W.jsx)(`ul`,{className:`space-y-1`,"data-testid":`conversation-members-list`,children:C.map(e=>{let t=`${e.hostId}:${e.sessionId}`,n=e.leftAt!==null;return(0,W.jsxs)(`li`,{className:U(`flex flex-wrap items-center gap-2 rounded-md border border-border px-2.5 py-1.5 text-xs`,n&&`opacity-60`),"data-testid":`conversation-member-${e.sessionId}`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-fg`,children:e.title}),(0,W.jsx)(`span`,{title:gz[e.state],children:(0,W.jsx)(Z,{tone:e.state===`working`?`accent`:`neutral`,children:hz[e.state]})}),e.talkOn===!1?(0,W.jsx)(`span`,{className:`text-fg-faint`,title:`Its "Talk to other chats" switch is off: it cannot message other chats. It still answers a chat that messages it, and only that chat, when asked; what it sent before, and answers to what it asked, wait until it is on again.`,children:`answers only`}):null,n?(0,W.jsx)(`span`,{className:`text-fg-faint`,title:sg(e.leftAt),children:`left`}):null,e.state!==`missing`&&o(e.sessionId)?(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>a(e.sessionId),title:Kd.openChat,"data-testid":`conversation-member-open`,children:`Open chat`}):null,!n&&!S?(0,W.jsx)(J,{size:`sm`,variant:d===t?`danger`:`ghost`,busy:s===`remove:${t}`,title:Kd.removeMember,onClick:()=>{if(d!==t){f(t);return}f(null),_(`remove:${t}`,`remove-member`,{sessionId:e.sessionId,hostId:e.hostId})},"data-testid":`conversation-member-remove`,children:d===t?`Remove?`:`Remove`}):null]},t)})})}),(0,W.jsx)(mz,{title:`History`,help:Kd.history,children:t===null?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading…`}):t.length===0?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Nothing has been sent yet.`}):(0,W.jsx)(`ol`,{className:`space-y-2`,"data-testid":`conversation-history`,children:t.map(t=>(0,W.jsx)(vz,{m:t,from:t.kind===`notice`?`OonaCode`:n(t.fromSession,t.fromTitle,e.members),to:n(t.toSession,t.toTitle,e.members),onWithdraw:()=>i(t)},t.id))})})]})}function vz({m:e,from:t,to:n,onWithdraw:r}){let i=Fd(e),a=Hd(i),o=Rd(e),s=zd(e),[c,l]=(0,v.useState)(!1),u=e.kind===`reply`?q.Reply:e.kind===`notice`?q.Alert:e.kind===`continue`?q.Refresh:q.Mail;return(0,W.jsxs)(`li`,{className:U(`rounded-md border px-2.5 py-2 text-xs`,e.kind===`notice`?`border-warn/40 bg-warn-soft/40`:`border-border`),"data-testid":`conversation-message-${e.id}`,"data-kind":e.kind,"data-status":e.status,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,W.jsx)(u,{className:U(`h-3.5 w-3.5`,e.kind===`notice`?`text-warn`:`text-accent`)}),(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:Md[e.kind]}),(0,W.jsxs)(`span`,{className:`min-w-0 truncate text-fg-muted`,"data-testid":`conversation-message-route`,children:[t,` → `,n]}),(0,W.jsx)(`span`,{className:`text-fg-faint`,title:sg(e.createdAt),children:cg(e.createdAt)}),(0,W.jsx)(`span`,{className:`flex-1`}),e.kind===`notice`?null:(0,W.jsx)(`span`,{title:Nd[e.status],children:(0,W.jsx)(Z,{tone:Pd(e.status),children:(0,W.jsx)(`span`,{"data-testid":`conversation-message-status`,children:e.status})})})]}),o||s||e.continued||e.stalled?(0,W.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-2 text-fg-muted`,children:[o?(0,W.jsx)(`span`,{title:o.help,"data-testid":`conversation-message-reply`,children:o.text}):null,s?(0,W.jsx)(`span`,{"data-testid":`conversation-message-batch`,children:s}):null,e.continued?(0,W.jsx)(`span`,{children:`continued after an OonaCode restart`}):null,e.stalled?(0,W.jsxs)(`span`,{className:`text-warn`,children:[`waiting for your permission to use `,e.stalled]}):null]}):null,e.error?(0,W.jsx)(`div`,{className:U(`mt-0.5`,e.status===`failed`?`text-danger`:`text-fg-muted`),"data-testid":`conversation-message-error`,children:e.error}):null,e.tokens>0||(e.credits??0)>0?(0,W.jsxs)(`div`,{className:`mt-0.5 text-fg-faint`,"data-testid":`conversation-message-usage`,children:[`The turn it caused: `,Gd(e,ig(e.tokens))]}):null,(0,W.jsx)(`div`,{className:U(`mt-1.5 text-fg`,a&&!c&&`max-h-24 overflow-hidden [mask-image:linear-gradient(to_bottom,black_60%,transparent)]`),"data-testid":`conversation-message-body`,"data-collapsed":a&&!c?`true`:void 0,children:(0,W.jsx)(aN,{text:i})}),(0,W.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[a?(0,W.jsx)(`button`,{type:`button`,className:`text-accent hover:underline`,onClick:()=>l(e=>!e),"aria-expanded":c,"data-testid":`conversation-message-expand`,children:c?`Show less`:`Show all`}):null,(0,W.jsx)(`span`,{className:`flex-1`}),Bd(e)?(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:r,title:Kd.withdraw,"data-testid":`conversation-message-withdraw`,children:`Withdraw`}):null]})]})}var yz={language:`en`,localVoice:{},speed:1,words:Nu.words},bz=`oonacode.voiceSummary.v1`;function xz(e){let t=e&&typeof e==`object`?e:{},n=yz,r={};if(t.localVoice&&typeof t.localVoice==`object`)for(let[e,n]of Object.entries(t.localVoice))typeof n==`string`&&n.length<300&&ju(e)&&(r[e]=n);return{language:typeof t.language==`string`&&ju(t.language)?ju(t.language).code:n.language,localVoice:r,speed:Iu(t.speed),words:Fu(t.words)}}function Sz(e=wz()){try{let t=e?.getItem(bz);return xz(t?JSON.parse(t):null)}catch{return{...yz}}}function Cz(e,t=wz()){try{t?.setItem(bz,JSON.stringify(e))}catch{}}function wz(){try{return typeof window<`u`?window.localStorage:null}catch{return null}}function Tz(e){return e.kind===`system`?null:e.key.slice(e.key.indexOf(`:`)+1)}var Ez={zh:[`cmn`]};function Dz(e){return e.toLowerCase().replace(/_/g,`-`)}function Oz(e,t){let n=Dz(e);return[t.code,...Ez[t.code]??[]].some(e=>n===e||n.startsWith(`${e}-`))}function kz(e,t){let n=Dz(e);return n===Dz(t.bcp47)?0:n===t.code||(Ez[t.code]??[]).includes(n)?1:2}function Az(e){let t=new Set(e.map(e=>e.name));return e.filter(e=>{let n=e.name.indexOf(`+`);if(n<=0)return!0;let r=e.name.lastIndexOf(` `),i=r>n?e.name.slice(r+1):``,a=i?`${e.name.slice(0,n)} ${i}`:e.name.slice(0,n);return!t.has(a)})}function jz(e,t,n){let r=t.filter(t=>t.language===e.code||(t.locale?Oz(t.locale,e):!1)),i=r.filter(e=>e.engine!==`espeak`).map(e=>({key:`sherpa:${e.id}`,label:e.label,kind:`sherpa`})),a=r.filter(e=>e.engine===`espeak`).slice(0,1).map(e=>({key:`espeak:${e.id}`,label:e.label||`eSpeak (robotic)`,kind:`espeak`})),o=Az(n.filter(t=>Oz(t.lang,e)&&t.localService!==!1)).map((t,n)=>({v:t,i:n,fit:kz(t.lang,e)})).sort((e,t)=>e.fit-t.fit||e.i-t.i).map(({v:e})=>({key:`system:${e.voiceURI}`,label:`${e.name} (system)`,kind:`system`}));return[...i,...o,...a]}function Mz(e,t){return e.find(e=>e.key===t)??e[0]??null}function Nz(e,t){if(e===`win32`||e===`linux`||e===`darwin`)return e;let n=t??``;return/Windows|Win32|Win64/i.test(n)?`win32`:/Android|CrOS/i.test(n)?null:/Linux|X11/i.test(n)?`linux`:/Mac OS X|Macintosh/i.test(n)?`darwin`:null}function Pz(e,t,n=null,r=!1){let i=t?``:` The OonaCode desktop app comes with its own Armenian voices, and eSpeak for every other language.`,a=`No local voice for ${e.name} on this PC.`;return t&&n===`win32`&&r?`${a} The app’s own eSpeak voice, which speaks every language here, could not start — usually because Microsoft’s Visual C++ Redistributable (x64) is not installed: https://aka.ms/vs/17/release/vc_redist.x64.exe. Install it, then open this window again.`:n===`linux`?`${a} Install speech-dispatcher and espeak-ng from your distribution (Debian, Ubuntu, Mint: sudo apt install speech-dispatcher espeak-ng · Fedora: sudo dnf install speech-dispatcher espeak-ng · Arch: sudo pacman -S speech-dispatcher espeak-ng), then restart OonaCode.${i}`:n===`darwin`?`${a} Add a ${e.name} voice in System Settings → Accessibility → Spoken Content → System voice → Manage Voices, then open this window again.${i}`:n===`win32`?`${a} Add a ${e.name} voice in Settings → Time & language → Speech → Add voices, if Windows offers one for ${e.name}, then open this window again.${i}`:`${a} Add a ${e.name} voice in the system's speech settings (Windows: Settings → Time & language → Speech), then open this window again.${i}`}function Fz(e){return e===`linux`?`whole`:`sentences`}var Iz=75;function Lz(e,t){return Math.round(3e3+e.length*120/Iu(t))}async function Rz(e,t,n,r){let{signal:i,onItem:a}=r,o=e.getVoices().find(e=>e.voiceURI===r.voiceURI)??null;e.cancel();let s=r.mode===`whole`?[n.join(` `)]:[...n];for(let c=0;c<s.length;c+=1){if(i.aborted)return;let l=s[c],u=await new Promise((s,u)=>{let d=[],f=!1,p=()=>!f&&(f=!0,d.forEach(e=>clearTimeout(e)),i.removeEventListener(`abort`,m),!0),m=()=>{p()&&(e.cancel(),s(`stopped`))},h=t(l);o&&(h.voice=o),h.lang=o?.lang??r.bcp47,h.rate=r.rate,h.onstart=()=>{if(f)return;if(r.mode===`sentences`){a(c);return}a(0);let e=0;for(let t=1;t<n.length;t+=1)e+=(n[t-1].length+1)*Iz/Iu(r.rate),d.push(setTimeout(()=>!f&&a(t),e))},h.onend=()=>{p()&&s(`ended`)},h.onerror=e=>{p()&&(i.aborted||e.error===`interrupted`||e.error===`canceled`?s(`stopped`):u(Error(`The system voice failed: ${e.error??`unknown error`}`)))},i.addEventListener(`abort`,m),d.push(setTimeout(()=>{p()&&s(`lost`)},Lz(l,r.rate))),e.speak(h)});if(u===`stopped`)return;u===`lost`&&e.cancel()}}function zz(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Bz(e,t){let n=new DataView(new ArrayBuffer(44)),r=(e,t)=>{for(let r=0;r<t.length;r+=1)n.setUint8(e+r,t.charCodeAt(r))};return r(0,`RIFF`),n.setUint32(4,36+e,!0),r(8,`WAVE`),r(12,`fmt `),n.setUint32(16,16,!0),n.setUint16(20,1,!0),n.setUint16(22,1,!0),n.setUint32(24,t,!0),n.setUint32(28,t*2,!0),n.setUint16(32,2,!0),n.setUint16(34,16,!0),r(36,`data`),n.setUint32(40,e,!0),n}function Vz(e,t){let n=new Uint8Array(44+e.length);return n.set(new Uint8Array(Bz(e.length,t).buffer),0),n.set(e,44),n.buffer}function Hz(e,t){let n=new DataView(new ArrayBuffer(e.length*2));for(let t=0;t<e.length;t+=1){let r=Math.max(-1,Math.min(1,e[t]));n.setInt16(t*2,Math.round(r*32767),!0)}return Vz(new Uint8Array(n.buffer),t)}function Uz(){let e=null,t=()=>{if(!e)return;let t=e;e=null,URL.revokeObjectURL(t.url),t.done()};return{play(n,r){return t(),new Promise(i=>{let a=URL.createObjectURL(new Blob([n],{type:`audio/wav`})),o=new Audio(a);o.preservesPitch=!0,o.playbackRate=r,e={audio:o,url:a,done:i},o.onended=t,o.onerror=t,o.play().catch(t)})},stop(){e&&e.audio.pause(),t()}}}var Wz=Uz;async function Gz(e,t,n,r){if(e.length===0)return;let i=t(e[0],0);for(let a=0;a<e.length;a+=1){if(r.signal.aborted)return;let o=await i;if(r.signal.aborted)return;i=a+1<e.length?t(e[a+1],a+1):null,i?.catch(()=>void 0),r.onItem?.(a),await n.play(o,r.playbackRate??1)}}var Kz={range:`all`,from:``,to:``},qz=`oonacode.aboutBriefing.v1`,Jz=/^\d{4}-\d{2}-\d{2}$/;function Yz(e){let t=e&&typeof e==`object`?e:{};return{range:Su(t.range)?t.range:Kz.range,from:typeof t.from==`string`&&Jz.test(t.from)?t.from:``,to:typeof t.to==`string`&&Jz.test(t.to)?t.to:``}}function Xz(){try{let e=window.localStorage.getItem(qz);return Yz(e?JSON.parse(e):null)}catch{return{...Kz}}}function Zz(e){try{window.localStorage.setItem(qz,JSON.stringify(e))}catch{}}function Qz(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t.has(r)&&(n+=1);return n===0?`none`:n===e.length?`all`:`some`}function $z(e,t){let n=new Set(t);if(Qz(e,t)===`all`)for(let t of e)n.delete(t);else for(let t of e)n.add(t);return n}function eB(e,t){let n=new Set(t),r=!1;for(let t of e)n.has(t)||(r=!0);return r?new Set([...e].filter(e=>n.has(e))):e}function tB(e,t){let n=[];if(e>0&&n.push(`${e} of the picked chats ${e===1?`has`:`have`} no about yet`),t>0){let r=e>0?`${t}`:`${t} of the picked chats`;n.push(`${r} ${t===1?`has an about`:`have abouts`} older than the chat’s last change`)}let r=[e>0?`a chat with no about is announced by its name and “no summary yet”`:null,t>0?`an older about is read as it is`:null].filter(Boolean).join(`, and `);return`${n.join(`; `)}. Writing them is one housekeeper call per chat, paid by the chat’s own route — credits for an OonaCode pool chat. Until then ${r}.`}var nB={status:`idle`,index:-1,total:0,sessionId:null,title:null,part:0,error:null,playlist:[]};function rB(e){return e.status===`preparing`||e.status===`speaking`||e.status===`paused`}var iB={afterNameMs:bu.afterNameMs,betweenChatsMs:bu.betweenChatsMs};function aB(e,t){return new Promise(n=>{if(t.aborted||e<=0){n();return}let r=()=>{clearTimeout(i),t.removeEventListener(`abort`,r),n()},i=setTimeout(r,e);t.addEventListener(`abort`,r,{once:!0})})}function oB(e,t){return t.aborted?Promise.reject(Error(`stopped`)):new Promise((n,r)=>{let i=()=>r(Error(`stopped`));t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})})}var sB=class{#e;#t=[];#n=nB;#r=null;#i=new Map;#a=new AbortController;constructor(e){this.#e=e}get state(){return this.#n}start(e,t=0){if(this.#t=[...e],this.#i.clear(),this.#t.length===0){this.#o(),this.#s({...nB});return}this.#l(Math.max(0,Math.min(t,this.#t.length-1)),0)}pause(){(this.#n.status===`preparing`||this.#n.status===`speaking`)&&(this.#o(),this.#s({status:`paused`}))}resume(){let e=this.#n;e.index<0||this.#t.length===0||(e.status===`paused`?this.#l(e.index,e.part):e.status===`error`&&this.#l(e.index,0))}stop(){this.#o(),this.#n.status!==`idle`&&this.#n.status!==`stopped`&&this.#s({status:`stopped`,index:-1,part:0,error:null})}reset(){this.#o(),this.#t=[],this.#i.clear(),this.#n!==nB&&(this.#n=nB,this.#e.onState(nB))}next(){if(this.#t.length===0||this.#n.index<0)return;let e=this.#n.index+1;if(e>=this.#t.length){this.#o(),this.#s({status:`done`,part:0});return}this.#l(e,0)}previous(){this.#t.length===0||this.#n.index<0||this.#l(Math.max(0,this.#n.index-1),0)}jumpTo(e){let t=this.#t.findIndex(t=>t.sessionId===e);t>=0&&this.#l(t,0)}resetWords(){this.#i.clear()}dispose(){this.reset(),this.#a.abort()}#o(){let e=this.#r;if(this.#r=null,e){e.abort();try{this.#e.silence()}catch{}}}#s(e){let t={...this.#n,...e},n=t.index>=0?this.#t[t.index]:void 0;t.total=this.#t.length,t.sessionId=n?.sessionId??null,t.title=n?.title??null,t.playlist=t.playlist.length===this.#t.length&&t.playlist.every((e,t)=>e===this.#t[t].sessionId)?t.playlist:this.#t.map(e=>e.sessionId),this.#n=t,this.#e.onState(t)}#c(e){let t=this.#t[e],n=this.#i.get(t.sessionId);if(n)return n;let r=this.#e.words(t,this.#a.signal);return this.#i.set(t.sessionId,r),r.catch(()=>{this.#i.get(t.sessionId)===r&&this.#i.delete(t.sessionId)}),r}#l(e,t){this.#o();let n=new AbortController;this.#r=n,this.#u(e,t,n.signal)}async#u(e,t,n){let r=this.#e.sleep??aB,i=this.#e.afterNameMs??iB.afterNameMs,a=this.#e.betweenChatsMs??iB.betweenChatsMs,o=e;try{for(;o<this.#t.length;o+=1){let s=o===e?t:0;this.#s({status:`preparing`,index:o,part:s,error:null});let c=await oB(this.#c(o),n);if(n.aborted)return;o+1<this.#t.length&&this.#c(o+1).catch(()=>void 0);let l=+!!c.name;if(c.name&&s===0&&(this.#s({status:`speaking`,part:0}),await this.#e.speak([c.name],{signal:n,onItem:()=>void 0}),n.aborted||(c.body.length>0&&await r(i,n),n.aborted)))return;let u=Math.max(0,s-l),d=c.body.slice(u);if(d.length>0&&(this.#s({status:`speaking`,part:l+u}),await this.#e.speak(d,{signal:n,onItem:e=>{n.aborted||this.#s({status:`speaking`,part:l+u+e})}}),n.aborted)||o+1<this.#t.length&&(await r(a,n),n.aborted))return}this.#r?.signal===n&&(this.#r=null),this.#s({status:`done`,index:this.#t.length-1,part:0})}catch(e){if(n.aborted)return;this.#r?.signal===n&&(this.#r=null);try{this.#e.silence()}catch{}let t=this.#t[o]?.title??`a chat`,r=e instanceof Error?e.message:String(e);this.#s({status:`error`,index:Math.min(o,this.#t.length-1),part:0,error:`${t}: ${r}`})}}};async function cB(e,t){let{voice:n,language:r,speed:i,tts:a,signal:o,onItem:s}=t,c=n?Tz(n):null;if(c&&a){await Gz(e,async e=>{let n=await a.speak({voiceId:c,text:t.prepare(e,r.code),speed:i});return Hz(n.samples,n.sampleRate)},t.player,{signal:o,onItem:s});return}if(n?.kind===`system`){if(!t.synth)throw Error(`This window has no system speech.`);await Rz(t.synth,t.makeUtterance,e,{voiceURI:n.key.slice(7),bcp47:r.bcp47,rate:i,mode:Fz(t.platform),signal:o,onItem:s});return}throw Error(Pz(r,!!a,t.platform,t.espeakMissing))}function lB(e){let[t,n]=(0,v.useState)([]);return(0,v.useEffect)(()=>{if(!e||typeof window>`u`||!window.speechSynthesis)return;let t=window.speechSynthesis,r=()=>n(t.getVoices());return r(),t.addEventListener?.(`voiceschanged`,r),()=>t.removeEventListener?.(`voiceschanged`,r)},[e]),t}function uB(e){let t=e instanceof Error?e.message:String(e);return/no route for|not_found|404/i.test(t)&&/voice/i.test(t)?`This PC’s OonaCode host does not know "Listen" yet — update OonaCode.`:t}function dB({open:e,onClose:t}){let{state:n,api:r}=G(),i=n.voiceSummarySessionId,a=(0,v.useMemo)(()=>n.sessions.find(e=>e.id===i)??null,[n.sessions,i]),o=typeof window<`u`?window.oonacode?.tts:void 0,s=Nz(typeof window<`u`?window.oonacode?.platform:null,typeof navigator<`u`?navigator.userAgent:null),[c,l]=(0,v.useState)(()=>Sz()),[u,d]=(0,v.useState)(null),f=lB(e),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)({kind:`idle`}),[S,C]=(0,v.useState)(null),w=(0,v.useRef)(null),T=ju(c.language)??ju(`en`),E=(0,v.useCallback)(e=>{l(t=>{let n={...t,...e};return Cz(n),n})},[]),D=p?.summaries??[],O=D.find(e=>e.id===_)??D[0]??null,k=(0,v.useCallback)(async()=>{if(!i||!r.listVoiceSummaries)return null;try{let e=await r.listVoiceSummaries(i);return m(e),g(null),e}catch(e){return g(uB(e)),null}},[r,i]);(0,v.useEffect)(()=>{e&&(m(null),y(null),C(null),x({kind:`idle`}),k(),o?(d(null),o.listVoices().then(d,()=>d([]))):d([]))},[e,k,o]);let A=a?`${a.entryCount}:${a.mtime}`:null,j=(0,v.useRef)(null),M=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!e){j.current=null;return}if(j.current===null){j.current=A;return}A!==j.current&&(j.current=A,!M.current&&(M.current=setTimeout(()=>{M.current=null,k()},800)))},[e,A,k]),(0,v.useEffect)(()=>()=>{M.current&&clearTimeout(M.current),M.current=null},[]);let ee=(0,v.useCallback)(()=>{let e=w.current;w.current=null,e&&(e.abort.abort(),e.stop())},[]);(0,v.useEffect)(()=>{e||ee()},[e,ee]),(0,v.useEffect)(()=>()=>ee(),[ee]);let N=(0,v.useMemo)(()=>jz(T,u??[],f),[T,u,f]),P=Mz(N,c.localVoice[T.code]),F=!!(o&&u&&!u.some(e=>e.engine===`espeak`)),I=b.kind===`summarising`||b.kind===`translating`||b.kind===`speaking`,te=!!(r.listVoiceSummaries&&r.createVoiceSummary),ne=async()=>{if(!i||!r.createVoiceSummary)return null;x({kind:`summarising`});let e=await r.createVoiceSummary(i,{words:c.words});return C(e.created?null:Sd.unchanged(zz(e.summary.createdAt))),y(e.summary.id),await k(),e.summary},re=async()=>{if(!i)return;ee();let e=new AbortController,t=Wz(),n=()=>{try{window.speechSynthesis?.cancel()}catch{}};w.current={abort:e,stop:()=>{t.stop(),n()}};let a=e.signal;try{let e=_d(p,_)?await ne():O;if(a.aborted)return;if(!e)throw Error(`There is no summary to play.`);let n=yd(e,T.code);if(n===null){if(!r.translateVoiceSummary)throw Error(`This host cannot translate yet.`);x({kind:`translating`});let t=await r.translateVoiceSummary(i,e.id,{language:T.code});if(m(n=>fB(n,e.id,t.translation)),a.aborted)return;n=t.translation.text,k()}let l=Qu(n);if(l.length===0)throw Error(`There was nothing to read.`);let u=e=>x({kind:`speaking`,index:e+1,total:l.length}),d=P?Tz(P):null;if(d&&o)await Gz(l,async e=>{let t=await o.speak({voiceId:d,text:gd(e,T.code),speed:c.speed});return Hz(t.samples,t.sampleRate)},t,{signal:a,onItem:u});else if(P?.kind===`system`){let e=typeof window<`u`?window.speechSynthesis:void 0;if(!e)throw Error(`This window has no system speech.`);await Rz(e,e=>new SpeechSynthesisUtterance(e),l,{voiceURI:P.key.slice(7),bcp47:T.bcp47,rate:c.speed,mode:Fz(s),signal:a,onItem:u})}else throw Error(Pz(T,!!o,s,F));if(a.aborted)return;x({kind:`done`})}catch(e){if(a.aborted)return;x({kind:`error`,message:uB(e)})}finally{w.current?.abort===e&&(w.current=null)}},L=()=>{ee(),x({kind:`stopped`})},ie=async e=>{if(!(!i||!r.deleteVoiceSummary))try{await r.deleteVoiceSummary(i,e),_===e&&y(null),await k()}catch(e){x({kind:`error`,message:uB(e)})}};if(!e)return null;let R=a?Vl(a):`this chat`,ae=O?yd(O,T.code):null,oe=O?new Set(vd(O)):new Set;return(0,W.jsx)(Ky,{open:e,title:`Listen to this chat`,onClose:t,wide:!0,footer:(0,W.jsxs)(W.Fragment,{children:[I?(0,W.jsxs)(J,{onClick:L,"data-testid":`voice-stop`,children:[(0,W.jsx)(q.Stop,{className:`h-4 w-4`}),` Stop`]}):null,(0,W.jsxs)(J,{variant:`primary`,onClick:()=>void re(),disabled:I||!te||!i,"data-testid":`voice-play`,children:[(0,W.jsx)(q.Play,{className:`h-4 w-4`}),` Play`]}),(0,W.jsx)(J,{onClick:t,children:`Close`})]}),children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm`,children:[(0,W.jsxs)(`p`,{className:`text-fg-muted`,children:[`A spoken summary of `,(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:R}),` — its goal, what was done, where it stands and what is pending — written by the chat’s own model, in English. Other languages are translated once by `,Mu.label,` on your OonaCode credits and kept with the summary.`]}),te?null:(0,W.jsx)(`p`,{className:`text-danger`,children:`This version of the host cannot make voice summaries.`}),(0,W.jsxs)(`section`,{"data-testid":`voice-summaries`,children:[(0,W.jsx)(`h3`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Summaries`}),h?(0,W.jsx)(`p`,{className:`text-xs text-danger`,children:h}):null,p&&D.length===0?(0,W.jsx)(`p`,{className:`text-fg-muted`,"data-testid":`voice-no-summaries`,children:Sd.noSummaries}):null,D.length>0&&_d(p,_)?(0,W.jsx)(`p`,{className:`mb-1 text-xs text-fg-muted`,"data-testid":`voice-changed`,children:Sd.changedSinceNewest}):null,(0,W.jsx)(`ul`,{className:`flex max-h-56 flex-col gap-1 overflow-y-auto`,children:D.map(e=>{let t=O?.id===e.id;return(0,W.jsxs)(`li`,{"data-testid":`voice-summary-row`,className:U(`flex items-start gap-2 rounded-md border px-2 py-1.5`,t?`border-accent bg-accent/10`:`border-border`),children:[(0,W.jsx)(`input`,{type:`radio`,name:`voice-summary`,className:`mt-1`,"aria-label":`Summary of ${zz(e.createdAt)}`,checked:t,disabled:I,onChange:()=>y(e.id)}),(0,W.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 flex-col items-start text-left`,disabled:I,onClick:()=>y(e.id),children:[(0,W.jsxs)(`span`,{className:`font-medium`,children:[zz(e.createdAt),e.current?(0,W.jsx)(`span`,{className:`ml-2 rounded-full bg-accent/15 px-1.5 text-xs text-accent`,children:`current`}):null]}),(0,W.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[e.words,` words · about `,bd(e.seconds),` ·`,` `,vd(e).map(e=>e.toUpperCase()).join(` `),` `,`· `,e.cost.model??`the chat’s model`,` · `,xd(e.cost)]})]}),(0,W.jsx)(J,{size:`sm`,onClick:()=>void ie(e.id),disabled:I,"aria-label":`Delete the summary of ${zz(e.createdAt)}`,"data-testid":`voice-summary-delete`,children:(0,W.jsx)(q.Trash,{className:`h-3.5 w-3.5`})})]},e.id)})}),S?(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,"data-testid":`voice-notice`,children:S}):null]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,W.jsx)(Wy,{label:`Language`,children:(0,W.jsx)(`select`,{"aria-label":`Language`,className:Gy,value:T.code,disabled:I,onChange:e=>E({language:e.target.value}),children:Au.map(e=>{let t=e.name===e.native?e.name:`${e.name} — ${e.native}`;return(0,W.jsx)(`option`,{value:e.code,children:oe.has(e.code)?`${t} ✓`:t},e.code)})})}),o&&u===null?(0,W.jsx)(`p`,{className:`px-1 py-2 text-fg-muted`,"data-testid":`voice-loading`,children:`Looking for this PC’s voices…`}):N.length>0?(0,W.jsx)(Wy,{label:`Voice`,children:(0,W.jsx)(`select`,{"aria-label":`Voice`,className:Gy,value:P?.key??``,disabled:I,onChange:e=>E({localVoice:{...c.localVoice,[T.code]:e.target.value}}),children:N.map(e=>(0,W.jsx)(`option`,{value:e.key,children:e.label},e.key))})}):(0,W.jsx)(`p`,{className:`rounded-md border border-border bg-surface-2 px-3 py-2 text-fg-muted`,"data-testid":`no-local-voice`,children:Pz(T,!!o,s,F)}),(0,W.jsx)(Wy,{label:`Speed ×${c.speed.toFixed(2)}`,children:(0,W.jsx)(`input`,{"aria-label":`Speed`,type:`range`,min:Pu.speed.min,max:Pu.speed.max,step:.05,value:c.speed,disabled:I,onChange:e=>E({speed:Number(e.target.value)})})}),(0,W.jsx)(Wy,{label:`Length of a new summary`,children:(0,W.jsxs)(`select`,{"aria-label":`Length of a new summary`,className:Gy,value:String(c.words),disabled:I,onChange:e=>E({words:Number(e.target.value)}),children:[(0,W.jsx)(`option`,{value:`120`,children:`Short — about 120 words`}),(0,W.jsx)(`option`,{value:`200`,children:`Normal — about 200 words`}),(0,W.jsx)(`option`,{value:`300`,children:`Long — about 300 words`}),[120,200,300].includes(c.words)?null:(0,W.jsxs)(`option`,{value:String(c.words),children:[c.words,` words`]})]})})]}),(0,W.jsx)(pB,{stage:b}),O?(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:Sd.heading(T,ae!==null)}),(0,W.jsx)(`p`,{className:`whitespace-pre-wrap rounded-md border border-border bg-surface-2 px-3 py-2`,"data-testid":`voice-summary-text`,dir:ae!==null&&T.rtl?`rtl`:`ltr`,lang:ae===null?`en-US`:T.bcp47,children:ae??O.text})]}):null]})})}function fB(e,t,n){return e&&{...e,summaries:e.summaries.map(e=>e.id===t?{...e,translations:[...e.translations.filter(e=>e.language!==n.language),n]}:e)}}function pB({stage:e}){let t=[{key:`summarising`,label:Sd.generating},{key:`translating`,label:Sd.translating},{key:`speaking`,label:`Speaking`}];if(e.kind===`idle`)return null;if(e.kind===`error`)return(0,W.jsx)(`p`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-danger`,role:`alert`,"data-testid":`voice-stage`,children:e.message});if(e.kind===`stopped`||e.kind===`done`)return(0,W.jsx)(`p`,{className:`text-fg-muted`,"data-testid":`voice-stage`,children:e.kind===`stopped`?`Stopped.`:`Done.`});let n=t.findIndex(t=>t.key===e.kind);return(0,W.jsx)(`ol`,{className:`flex flex-wrap items-center gap-2 text-xs`,"data-testid":`voice-stage`,"aria-live":`polite`,children:t.map((t,r)=>(0,W.jsx)(`li`,{className:U(`rounded-full px-2 py-0.5`,r===n?`bg-accent/15 font-medium text-accent`:r<n?`text-fg-muted line-through`:`text-fg-faint`),children:t.key===`speaking`&&e.kind===`speaking`?`Speaking ${e.index} of ${e.total}`:t.label},t.key))})}function mB(e){return Yu(e).replace(/\n+/g,` `).trim()||e.trim()}function hB(e){let t=e instanceof Error?e.message:String(e);return/no route for|404/i.test(t)&&/about/i.test(t)?`This PC’s OonaCode host cannot read the abouts in other languages yet — update OonaCode. English plays.`:t}function gB(e){return{sessionId:e.sessionId,title:e.title.trim()||`Untitled chat`,about:e.about}}function _B(e){return e.filter(e=>!e.pending&&e.source!==`user`&&(!e.about||e.stale))}function vB({open:e,picked:t}){let{api:n}=G(),r=(0,v.useRef)(n);r.current=n;let i=typeof window<`u`?window.oonacode?.tts:void 0,a=Nz(typeof window<`u`?window.oonacode?.platform:null,typeof navigator<`u`?navigator.userAgent:null),[o,s]=(0,v.useState)(()=>Sz()),[c,l]=(0,v.useState)(null),u=lB(e),d=ju(o.language)??ju(`en`),f=(0,v.useMemo)(()=>jz(d,c??[],u),[d,c,u]),p=Mz(f,o.localVoice[d.code]),m=!!(i&&c&&!c.some(e=>e.engine===`espeak`)),[h,g]=(0,v.useState)(nB),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(0),[S,C]=(0,v.useState)(!1),w=(0,v.useRef)({lang:d,voice:p,speed:o.speed,espeakMissing:m,platform:a,tts:i});w.current={lang:d,voice:p,speed:o.speed,espeakMissing:m,platform:a,tts:i};let T=(0,v.useCallback)(e=>{s(t=>{let n={...t,...e};return Cz(n),n})},[]),E=(0,v.useMemo)(()=>{let e=Wz();return new sB({words:async e=>{let{lang:t}=w.current;if(!e.about)return{name:mB(e.title),body:[Du(t.code)]};if(t.code===`en`)return{name:mB(e.title),body:Qu(Yu(e.about))};let n=r.current.translateChatAbout;if(!n)throw Error(`This PC’s OonaCode host cannot read the abouts in other languages yet — update OonaCode. English plays.`);try{let r=await n(e.sessionId,{language:t.code});return r.created&&x(e=>e+1),{name:r.translation.name?mB(r.translation.name):null,body:Qu(r.translation.text)}}catch(e){throw Error(`could not translate it: ${hB(e)}`)}},speak:(t,{signal:n,onItem:r})=>{let i=w.current;return cB(t,{voice:i.voice,language:i.lang,speed:i.speed,tts:i.tts,player:e,synth:typeof window<`u`?window.speechSynthesis:void 0,makeUtterance:e=>new SpeechSynthesisUtterance(e),platform:i.platform,espeakMissing:i.espeakMissing,prepare:gd,signal:n,onItem:r})},silence:()=>{e.stop();try{typeof window<`u`&&window.speechSynthesis?.cancel()}catch{}},onState:g})},[]);(0,v.useEffect)(()=>{if(!e){E.reset();return}s(Sz()),i?(l(null),i.listVoices().then(l,()=>l([]))):l([])},[e,i,E]),(0,v.useEffect)(()=>()=>E.dispose(),[E]),(0,v.useEffect)(()=>{E.resetWords()},[d.code,E]);let D=t.map(e=>`${e.sessionId}\u0000${e.title}\u0000${e.about??``}`).join(``);(0,v.useEffect)(()=>{C(!1)},[D,d.code]),(0,v.useEffect)(()=>{let r=n.planChatAboutTranslations;if(!e||d.code===`en`||t.length===0||!r){y(null);return}let i=!0;return r({language:d.code,sessionIds:t.map(e=>e.sessionId)}).then(e=>i&&y(e),()=>i&&y(null)),()=>{i=!1}},[e,d.code,D,b,n]);let O=h.status===`preparing`||h.status===`speaking`,k=d.code!==`en`&&_!==null&&_.language===d.code&&_.needed>bu.confirmAbove,A=(0,v.useCallback)(()=>{C(!1),E.start(t.map(gB),0)},[E,t]),j=(0,v.useCallback)(()=>{if(t.length!==0){if(k&&!S){C(!0);return}A()}},[t.length,k,S,A]);return{prefs:o,update:T,lang:d,options:f,voice:p,espeakMissing:m,voicesLoading:!!i&&c===null,desktop:!!i,platform:a,state:h,busy:O,active:rB(h),plan:_&&_.language===d.code?_:null,confirming:S,play:j,start:A,cancelConfirm:()=>C(!1),pause:()=>E.pause(),resume:()=>E.resume(),stop:()=>E.stop(),next:()=>E.next(),previous:()=>E.previous(),jumpTo:e=>E.jumpTo(e),pickedCount:t.length}}function yB({b:e,picked:t,enabled:n,generateAll:r,onGenerated:i}){let{api:a}=G(),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),u=_B(t),d=u.filter(e=>!e.about).length,f=u.length-d,p=r?.running===!0,m=async()=>{if(a.generateChatAbouts){s(!0),l(null);try{i((await a.generateChatAbouts({sessionIds:u.map(e=>e.sessionId)})).generateAll)}catch(e){l(hB(e))}finally{s(!1)}}},h=e.busy;return(0,W.jsxs)(`section`,{className:`space-y-2 rounded-md border border-border px-3 py-2`,"data-testid":`briefing-panel`,"aria-label":`Listen to the picked chats`,children:[(0,W.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Listen to the picked chats`}),(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Tick chats below, then Play: each chat’s name, then its about, one after another. Another language is translated once by `,Mu.label,` on your OonaCode credits and kept, so playing it again costs nothing.`]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,W.jsx)(Wy,{label:`Language`,children:(0,W.jsx)(`select`,{"aria-label":`Language`,className:Gy,value:e.lang.code,disabled:h,onChange:t=>e.update({language:t.target.value}),"data-testid":`briefing-language`,children:Au.map(e=>(0,W.jsx)(`option`,{value:e.code,children:e.name===e.native?e.name:`${e.name} — ${e.native}`},e.code))})}),e.voicesLoading?(0,W.jsx)(`p`,{className:`px-1 py-2 text-xs text-fg-muted`,"data-testid":`briefing-voices-loading`,children:`Looking for this PC’s voices…`}):e.options.length>0?(0,W.jsx)(Wy,{label:`Voice`,children:(0,W.jsx)(`select`,{"aria-label":`Voice`,className:Gy,value:e.voice?.key??``,disabled:h,onChange:t=>e.update({localVoice:{...e.prefs.localVoice,[e.lang.code]:t.target.value}}),"data-testid":`briefing-voice`,children:e.options.map(e=>(0,W.jsx)(`option`,{value:e.key,children:e.label},e.key))})}):(0,W.jsx)(`p`,{className:`rounded-md border border-border bg-surface-2 px-2 py-1.5 text-xs text-fg-muted sm:col-span-2`,"data-testid":`briefing-no-voice`,children:Pz(e.lang,e.desktop,e.platform,e.espeakMissing)}),(0,W.jsx)(Wy,{label:`Speed ×${e.prefs.speed.toFixed(2)}`,children:(0,W.jsx)(`input`,{"aria-label":`Speed`,type:`range`,min:Pu.speed.min,max:Pu.speed.max,step:.05,value:e.prefs.speed,disabled:h,onChange:t=>e.update({speed:Number(t.target.value)})})})]}),e.plan&&t.length>0?(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`briefing-cost`,children:[ku(e.plan,e.lang.name),e.plan.needed>0?` — paid once, then kept.`:``]}):null,e.confirming&&e.plan?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-warn/50 bg-warn-soft px-2 py-1.5 text-xs text-fg`,role:`alert`,"data-testid":`briefing-confirm`,children:[(0,W.jsxs)(`p`,{className:`basis-full`,children:[`Before playing: `,ku(e.plan,e.lang.name),` — paid once from your OonaCode credits, then kept.`]}),(0,W.jsx)(J,{size:`sm`,variant:`primary`,onClick:e.start,"data-testid":`briefing-confirm-play`,children:`Translate and play`}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:e.cancelConfirm,children:`Cancel`})]}):null,u.length>0&&a.generateChatAbouts?(0,W.jsxs)(`div`,{className:`space-y-1.5 text-xs`,"data-testid":`briefing-need-about`,children:[(0,W.jsx)(`p`,{className:`text-fg-muted`,children:tB(d,f)}),(0,W.jsxs)(J,{size:`sm`,onClick:()=>void m(),busy:o,disabled:!n||p||e.busy,title:n?void 0:`Chat abouts are off — turn them on above.`,"data-testid":`briefing-write-first`,children:[(0,W.jsx)(q.Refresh,{className:`h-3 w-3`}),` Write abouts for these first`]})]}):null,c?(0,W.jsx)(`p`,{className:`text-xs text-danger`,"data-testid":`briefing-write-error`,children:c}):null]})}function bB({b:e}){let t=e.state,n=t.index>=0?` (${t.index+1} of ${t.total})`:``,r=null;return t.status===`preparing`?r=`Now: ${t.title??``}${n} — ${e.lang.code===`en`?`getting ready…`:`translating…`}`:t.status===`speaking`?r=`Now: ${t.title??``}${n}`:t.status===`paused`?r=`Paused: ${t.title??``}${n}`:t.status===`done`?r=`Finished — ${t.total} chat${t.total===1?``:`s`} read.`:t.status===`stopped`?r=`Stopped.`:t.status===`error`&&(r=t.error),(0,W.jsxs)(W.Fragment,{children:[r?(0,W.jsx)(`p`,{className:U(`mr-auto min-w-0 basis-full truncate text-xs sm:basis-auto sm:flex-1`,t.status===`error`?`text-danger`:`text-fg-muted`),title:r,"aria-live":`polite`,"data-testid":`briefing-now`,children:r}):null,e.active||t.status===`error`?(0,W.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[(0,W.jsx)(J,{size:`sm`,onClick:e.previous,disabled:t.status===`error`,"aria-label":`Previous chat`,title:`Previous chat`,"data-testid":`briefing-previous`,children:(0,W.jsx)(q.SkipBack,{className:`h-3.5 w-3.5`})}),t.status===`paused`||t.status===`error`?(0,W.jsxs)(J,{size:`sm`,variant:`primary`,onClick:e.resume,"data-testid":`briefing-resume`,children:[(0,W.jsx)(q.Play,{className:`h-3.5 w-3.5`}),` `,t.status===`error`?`Try again`:`Resume`]}):(0,W.jsxs)(J,{size:`sm`,onClick:e.pause,"data-testid":`briefing-pause`,children:[(0,W.jsx)(q.Pause,{className:`h-3.5 w-3.5`}),` Pause`]}),(0,W.jsxs)(J,{size:`sm`,onClick:e.stop,"data-testid":`briefing-stop`,children:[(0,W.jsx)(q.Stop,{className:`h-3.5 w-3.5`}),` Stop`]}),(0,W.jsx)(J,{size:`sm`,onClick:e.next,disabled:t.status===`error`,"aria-label":`Next chat`,title:`Next chat`,"data-testid":`briefing-next`,children:(0,W.jsx)(q.SkipForward,{className:`h-3.5 w-3.5`})})]}):(0,W.jsxs)(J,{variant:`primary`,onClick:e.play,disabled:e.pickedCount===0||e.voice===null||e.voicesLoading,title:e.pickedCount===0?`Tick the chats to hear first`:void 0,"data-testid":`briefing-play`,children:[(0,W.jsx)(q.Play,{className:`h-4 w-4`}),` Play `,e.pickedCount,` picked`]})]})}function xB({open:e,onClose:t}){let{state:n,actions:r}=G(),i=n.chatAboutsChange,[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(!1),S=(0,v.useRef)(-1),[C,w]=(0,v.useState)(()=>Xz()),[T,E]=(0,v.useState)(()=>new Set),[D,O]=(0,v.useState)(()=>Date.now()),k=(0,v.useCallback)(async()=>{let e=await r.listChatAbouts();if(e===`unsupported`){c(!0);return}if(e===null){u(!0);return}c(!1),u(!1),o(e),f(e.generateAll)},[r]);(0,v.useEffect)(()=>{e&&(S.current=i.seq,O(Date.now()),k())},[e]);let A=e=>{w(t=>{let n={...t,...e};return Zz(n),n}),O(Date.now())};(0,v.useEffect)(()=>{!e||i.seq===S.current||(S.current=i.seq,i.generateAll!==void 0&&f(i.generateAll),k())},[e,i,k]);let j=n.settings?.chatAboutEnabled??a?.settings.enabled??Kl.enabled,M=async e=>{x(!0);try{await r.saveSettings({chatAboutEnabled:e})}finally{x(!1)}k()},ee=async()=>{g(!0);try{let e=await r.generateAllChatAbouts();e&&f(e.generateAll)}finally{g(!1)}},N=async()=>{y(!0);try{let e=await r.stopGenerateAllChatAbouts();e&&f(e.generateAll)}finally{y(!1)}},P=(0,v.useMemo)(()=>wu(C.range,D,{from:C.from,to:C.to}),[C,D]),F=(0,v.useMemo)(()=>{let e=(a?.chats??[]).filter(e=>Tu(e.updatedAt,P)),t=e=>{let t=Date.parse(e.updatedAt);return Number.isFinite(t)?t:0};return[...e].sort((e,n)=>t(n)-t(e))},[a,P]),I=(0,v.useMemo)(()=>{let e=p.trim().toLowerCase();return e?F.filter(t=>t.title.toLowerCase().includes(e)||(t.about??``).toLowerCase().includes(e)):F},[F,p]),te=(0,v.useMemo)(()=>I.map(e=>e.sessionId),[I]),ne=te.join(`,`);(0,v.useEffect)(()=>{E(e=>eB(e,te))},[ne]);let re=(0,v.useMemo)(()=>I.filter(e=>T.has(e.sessionId)),[I,T]),L=Qz(te,T),ie=(0,v.useRef)(null);(0,v.useEffect)(()=>{ie.current&&(ie.current.indeterminate=L===`some`)});let R=vB({open:e,picked:re}),ae=R.active||R.state.status===`error`,oe=(0,v.useMemo)(()=>new Set(R.state.playlist),[R.state.playlist]),se=ae?R.state.sessionId:null,ce=e=>E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),le=xu.find(e=>e.id===C.range)?.label??``,ue=(0,v.useCallback)(e=>n.sessions.find(t=>t.id===e)?.entryCount??null,[n.sessions]),de=a?mu(a.totals):null,fe=d?.running===!0;return(0,W.jsxs)(Ky,{open:e,title:`What your chats are about`,onClose:t,wide:!0,footer:(0,W.jsxs)(W.Fragment,{children:[a!==null&&!s?(0,W.jsx)(bB,{b:R}):null,(0,W.jsx)(J,{variant:`ghost`,onClick:t,children:`Close`})]}),children:[(0,W.jsxs)(`p`,{className:`mb-3 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,W.jsx)(`span`,{className:`min-w-0`,children:`A short note per chat on this PC saying what it works on, so your other chats can tell which one to ask.`}),(0,W.jsx)(Hy,{label:`What your chats are about`,details:(0,W.jsx)(Uy,{items:[...yu.what,...yu.when,...yu.who,...yu.yours,...yu.where]})})]}),s?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-unsupported`,children:`OonaCode on this PC is too old for chat abouts. Update it, then open this window again.`}):a===null?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-loading`,children:l?`Could not read the abouts from this PC right now. They show here as soon as it answers.`:`Loading…`}):(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsx)(`div`,{className:`rounded-md border border-border px-3`,children:(0,W.jsx)(qy,{label:`Write an about for every chat`,hint:j?`On: each chat’s housekeeper model writes its about in the background.`:`Off: nothing is written and nothing is spent. Regenerate and “Generate for all chats now” are unavailable.`,details:[yu.switch,...yu.who],checked:j,disabled:b,onChange:e=>void M(e),testId:`chat-abouts-switch`})}),de?(0,W.jsxs)(`div`,{className:`text-xs text-fg-muted`,"data-testid":`chat-abouts-totals`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:`All about calls so far: `}),(0,W.jsx)(`span`,{"data-testid":`chat-abouts-totals-line`,children:de.line}),de.unpriced?(0,W.jsx)(`span`,{className:`block text-fg-faint`,"data-testid":`chat-abouts-totals-unpriced`,children:de.unpriced}):null]}):null,(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsxs)(J,{size:`sm`,variant:`primary`,onClick:()=>void ee(),busy:h,disabled:!j||fe,title:j?yu.generateAll:yu.regenerateOff,"data-testid":`chat-abouts-generate-all`,children:[(0,W.jsx)(q.Refresh,{className:`h-3 w-3`}),` Generate for all chats now`]}),(0,W.jsx)(Hy,{label:`Generate for all chats now`,details:yu.generateAll})]}),fe?(0,W.jsxs)(J,{size:`sm`,variant:`danger`,onClick:()=>void N(),busy:_,title:yu.stop,"data-testid":`chat-abouts-stop`,children:[(0,W.jsx)(q.Stop,{className:`h-3 w-3`}),` Stop`]}):null]}),d?(0,W.jsx)(SB,{g:d}):null,(0,W.jsx)(yB,{b:R,picked:re,enabled:j,generateAll:d,onGenerated:f}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,W.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`Last active`,(0,W.jsx)(`select`,{"aria-label":`Last active`,className:U(Gy,`text-xs`),value:C.range,onChange:e=>A({range:e.target.value}),"data-testid":`chat-abouts-range`,children:xu.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),C.range===`custom`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`From`,(0,W.jsx)(`input`,{type:`date`,"aria-label":`From`,className:U(X,`text-xs`),value:C.from,onChange:e=>A({from:e.target.value}),"data-testid":`chat-abouts-from`})]}),(0,W.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`To`,(0,W.jsx)(`input`,{type:`date`,"aria-label":`To`,className:U(X,`text-xs`),value:C.to,onChange:e=>A({to:e.target.value}),"data-testid":`chat-abouts-to`})]})]}):null,(0,W.jsx)(`input`,{className:U(X,`min-w-[10rem] flex-1 basis-40 text-xs`),type:`search`,value:p,onChange:e=>m(e.target.value),placeholder:`Find a chat by its title or its about`,"aria-label":`Find a chat by its title or its about`,"data-testid":`chat-abouts-filter`})]}),I.length>0?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,W.jsxs)(`label`,{className:`inline-flex items-center gap-2 font-medium text-fg`,children:[(0,W.jsx)(`input`,{ref:ie,type:`checkbox`,checked:L===`all`,"aria-checked":L===`some`?`mixed`:L===`all`,onChange:()=>E(e=>$z(te,e)),"data-testid":`chat-abouts-select-all`}),`Select all`]}),(0,W.jsxs)(`span`,{className:`text-fg-muted`,"data-testid":`chat-abouts-count`,children:[I.length,` chat`,I.length===1?``:`s`,re.length>0?` · ${re.length} picked`:``]})]}):null,a.chats.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-empty`,children:`No chats on this PC yet.`}):I.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-no-match`,children:p.trim()?`No chat matches “${p.trim()}”${C.range===`all`?``:` in ${le.toLowerCase()}`}.`:`No chat was active in ${C.range===`custom`?`that range`:le.toLowerCase()}.`}):(0,W.jsx)(`ul`,{className:`space-y-2`,"data-testid":`chat-abouts-list`,children:I.map(e=>(0,W.jsx)(CB,{row:e,enabled:j,entryCount:ue(e.sessionId),checked:T.has(e.sessionId),onToggle:()=>ce(e.sessionId),playing:se===e.sessionId,onJump:ae&&oe.has(e.sessionId)?()=>R.jumpTo(e.sessionId):null,onOpen:()=>{r.selectSession(e.sessionId)}},e.sessionId))})]})]})}function SB({g:e}){let t=e.total>0?Math.round(Math.min(e.done,e.total)/e.total*100):100;return(0,W.jsxs)(`div`,{className:`space-y-1 text-xs`,"data-testid":`chat-abouts-progress`,children:[(0,W.jsx)(`div`,{className:`text-fg-muted`,"data-testid":`chat-abouts-progress-line`,children:gu(e)}),(0,W.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`Generate for all chats now`,"aria-valuemin":0,"aria-valuemax":e.total,"aria-valuenow":e.done,children:(0,W.jsx)(`div`,{className:U(`h-full rounded-full`,e.running?`bg-accent`:`bg-fg-faint`),style:{width:`${t}%`}})}),!e.running&&e.stoppedReason?(0,W.jsxs)(`div`,{className:`text-warn`,"data-testid":`chat-abouts-stopped-reason`,children:[`Stopped: `,e.stoppedReason]}):null]})}function CB({row:e,enabled:t,entryCount:n,checked:r,onToggle:i,playing:a,onJump:o,onOpen:s}){let c=e.title.trim()||`Untitled chat`,l=lu(e),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>{a&&u.current?.scrollIntoView?.({block:`nearest`})},[a]),(0,W.jsxs)(`li`,{ref:u,className:U(`rounded-md border px-3 py-2 text-xs`,a?`border-accent bg-accent/10`:`border-border`,o?`cursor-pointer hover:border-accent`:``),onClick:o??void 0,title:o&&!a?`Play from this chat`:void 0,"aria-current":a?`true`:void 0,"data-testid":`chat-about-row-${e.sessionId}`,"data-playing":a?`true`:void 0,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`shrink-0`,checked:r,onChange:i,onClick:e=>e.stopPropagation(),"aria-label":`Pick ${c}`,"data-testid":`chat-about-pick`}),a?(0,W.jsx)(q.Speaker,{className:`h-3.5 w-3.5 text-accent`,title:`Playing`}):null,(0,W.jsx)(`button`,{type:`button`,className:`min-w-0 max-w-full truncate text-left text-sm font-medium text-fg hover:text-accent hover:underline`,onClick:e=>{e.stopPropagation(),s()},title:`Open this chat`,"data-testid":`chat-about-open`,children:c}),e.source===`user`?(0,W.jsx)(`span`,{title:yu.yours[0],children:(0,W.jsx)(Z,{tone:`accent`,children:`yours`})}):null,e.stale&&e.about?(0,W.jsx)(`span`,{title:yu.stale,"data-testid":`chat-about-stale`,children:(0,W.jsx)(Z,{tone:`warn`,children:`stale`})}):null,e.pending?(0,W.jsx)(`span`,{"data-testid":`chat-about-pending`,children:(0,W.jsx)(Z,{tone:`accent`,children:`writing…`})}):null]}),e.about?(0,W.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-fg`,"data-testid":`chat-about-text`,children:e.about}):null,e.about&&e.stale?(0,W.jsx)(`p`,{className:`mt-0.5 text-warn`,"data-testid":`chat-about-stale-note`,children:`The chat has moved on since this about was written.`}):null,e.about?null:(0,W.jsxs)(`p`,{className:`mt-1 text-fg-muted`,"data-testid":`chat-about-missing`,children:[`No about yet. `,hu(e,{enabled:t,entryCount:n})]}),e.about&&e.lastError?(0,W.jsxs)(`p`,{className:`mt-0.5 text-danger`,"data-testid":`chat-about-error`,children:[`The last attempt failed: `,e.lastError]}):null,(0,W.jsxs)(`div`,{className:`mt-1 flex flex-wrap justify-between gap-x-3 gap-y-0.5 text-[11px] text-fg-faint`,children:[(0,W.jsxs)(`span`,{title:sg(e.updatedAt),"data-testid":`chat-about-active`,children:[`Active `,ag(e.updatedAt)]}),e.about&&e.aboutAt?(0,W.jsxs)(`span`,{title:sg(e.aboutAt),"data-testid":`chat-about-written`,children:[`Written `,ag(e.aboutAt),l?` by ${l}`:``]}):(0,W.jsx)(`span`,{}),(0,W.jsx)(`span`,{title:e.route?`Paid by ${uu[e.route]}`:void 0,"data-testid":`chat-about-spend`,children:pu(e.spend,e.route)})]})]})}function wB({open:e,onClose:t}){let{state:n,actions:r}=G(),i=n.assignProjectSessionId,a=i?n.sessions.find(e=>e.id===i)??null:null,o=i?n.drafts[i]??null:null,s=a?.projectId??o?.projectId??null,[c,l]=(0,v.useState)(s),[u,d]=(0,v.useState)(!1);(0,v.useEffect)(()=>{e&&l(s)},[e,s]);let f=a?.status===`running`||a?.status===`waiting_permission`,p=fg(a?pg(a):o?.title??`New chat`);async function m(){if(i){d(!0);try{await r.setSessionProject(i,c)&&t()}finally{d(!1)}}}return(0,W.jsxs)(Ky,{open:e,title:`Move “${p}” to a project`,onClose:t,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{variant:`ghost`,onClick:()=>{t(),r.openDialog(`projects`)},children:`Manage projects…`}),(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(J,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,W.jsx)(J,{variant:`primary`,onClick:m,disabled:u||c===s,"data-testid":`assign-project-apply`,children:`Apply`})]}),children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5`,role:`radiogroup`,"aria-label":`Project`,children:[(0,W.jsx)(TB,{selected:c===null,onSelect:()=>l(null),label:`No project`,testId:`assign-project-none`}),n.vaultProjects.map(e=>(0,W.jsx)(TB,{selected:c===e.id,onSelect:()=>l(e.id),label:e.name,hint:e.instructions.trim()?`has instructions`:void 0,testId:`assign-project-${e.id}`},e.id)),n.vaultProjects.length===0?(0,W.jsxs)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:[`No projects yet — create one under `,(0,W.jsx)(`em`,{children:`Manage projects…`}),`.`]}):null]}),f?(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,"data-testid":`assign-project-busy`,children:`This chat is mid-turn — it moves now and the turn is left alone. The project's instructions reach the agent at your next message.`}):(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:`The project's instructions reach the agent on the chat's next start — nothing in the conversation is lost.`})]})}function TB({selected:e,onSelect:t,label:n,hint:r,testId:i}){return(0,W.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e,onClick:t,className:U(`flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,e?`bg-accent-soft text-fg`:`hover:bg-surface-2 text-fg`),"data-testid":i,children:[(0,W.jsx)(`span`,{className:U(`inline-block h-3 w-3 rounded-full border`,e?`border-accent bg-accent`:`border-border`)}),(0,W.jsx)(q.Project,{className:`w-3.5 h-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),r?(0,W.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:r}):null]})}var EB=`Install Google’s agy`,DB=`Setting up Google’s agy for you — OonaCode downloads Google’s own release and checks its checksum (about 200 MB, nothing is bundled in OonaCode).`,OB=`OonaCode downloads Google’s own agy release (about 200 MB) and checks its checksum before it uses it. Nothing from Google is bundled inside OonaCode.`,kB=`Sign in with Google`,AB=`This PC’s OonaCode is too old to run chats on Google’s agy — update it from the title bar.`,jB=`Kept on this PC only, in memory: it is gone when OonaCode stops, and it is never synced or sent anywhere.`,MB=new Set([`loadCodeAssist`,`fetchAdminControls`,`retrieveUserQuotaSummary`,`fetchUserInfo`,`fetchAvailableModels`,`listExperiments`,`writeTrajectoryAcls`,`recordTrajectoryAnalytics`]);function NB(e){return e.kind===`tunnel`||e.method!==null&&MB.has(e.method)}function PB(e){let t=[],n=[];for(let r of e)(NB(r)?n:t).push(r);return{main:t,background:n}}function FB(e){if(e.kind===`tunnel`)return{title:e.host??`tunnel`,detail:null};let t=[e.model,e.requestType===`checkpoint`?`checkpoint`:null].filter(e=>!!e).join(` · `);return{title:e.method??`Code Assist call`,detail:t||null}}function IB(e){let{title:t,detail:n}=FB(e);return n?`${t} · ${n}`:t}function LB(e){let t=e.denied||e.error!==null||e.status!==null&&e.status>=400?`danger`:`neutral`;return e.denied?{text:`denied`,tone:t}:e.status===null?e.error===null?{text:`pending`,tone:t}:{text:`error`,tone:t}:{text:String(e.status),tone:t}}var RB=e=>e.toLocaleString(`en-US`);function zB(e){if(!e)return null;let t=e.cached>0?` (${RB(e.cached)} cached)`:``;return`in ${RB(e.input)}${t} · out ${RB(e.output)}`}function BB(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``}function VB(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function HB(e){switch(e){case`ready`:return{label:`Ready`,tone:`ok`};case`not_installed`:return{label:`agy is not installed`,tone:`warn`};case`not_signed_in`:return{label:`Not signed in to agy`,tone:`warn`};default:return{label:`agy did not answer`,tone:`danger`}}}function UB(e){return e.newerThanTested?`This agy is newer than the version OonaCode was tested with (${e.testedVersion}). It usually keeps working; if chats on it start failing, look for an OonaCode update.`:null}function WB(e){let t=e.remainingPercent,n=t!==null&&Number.isFinite(t),r=sg(e.resetsAt);return{remaining:n?`${Math.round(Math.min(100,Math.max(0,t)))}% left`:`unknown`,tone:rc(t),resets:r?`resets ${r}`:null}}var GB=1e3,KB=2e3;function qB(e){if(!e)return null;if(e.install.state===`working`)return GB;switch(e.login.phase){case`starting`:case`verifying`:return GB;case`awaiting_code`:return KB;default:return null}}function JB(e){if(!e)return!1;if(e.install.state===`working`)return!0;let t=e.login.phase;return t===`starting`||t===`awaiting_code`||t===`verifying`}function YB(e){switch(e){case`manifest`:return`Looking up Google’s latest release…`;case`download`:return`Downloading agy…`;case`verify`:return`Checking the download…`;case`place`:return`Finishing up…`;default:return`Starting the install…`}}function XB(e){let{received:t,total:n}=e;return n===null||!Number.isFinite(n)||n<=0?null:Math.min(100,Math.max(0,Math.floor(t/n*100)))}function ZB(e){let{received:t,total:n}=e;return n!==null&&n>0?`${Rj(t)} of ${Rj(n)}`:t>0?Rj(t):null}function QB(e){if(!e)return null;try{return new URL(e).protocol===`https:`?e:null}catch{return null}}function $B(e,t){return t?e.split(t).join(`…`):e}function eV(e,t){return e?`Status…`:t?t.state===`not_installed`?t.install.supported?`Install…`:`Status…`:t.state===`not_signed_in`?`Sign in…`:`Status…`:`Set up…`}var tV=15,nV=2e4,rV=5e3,iV=null;function aV(e){let[t,n]=(0,v.useState)(()=>Date.now());return(0,v.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),t}function oV({install:e,busy:t,offer:n,onInstall:r,onCancel:i}){if(e.state===`working`){let n=XB(e),r=ZB(e);return(0,W.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`agy-install`,"data-install-state":`working`,children:[(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-install-statement`,children:DB}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg`,role:`status`,"data-testid":`agy-install-phase`,"data-phase":e.phase??void 0,children:[(0,W.jsx)(q.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsxs)(`span`,{className:`min-w-0`,children:[YB(e.phase),e.version?` (agy ${e.version})`:``]})]}),(0,W.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`Installing agy`,"aria-valuemin":0,"aria-valuemax":100,...n===null?{}:{"aria-valuenow":n},"data-indeterminate":n===null?`true`:void 0,"data-testid":`agy-install-bar`,children:(0,W.jsx)(`div`,{className:U(`h-full rounded-full bg-accent`,n===null?`w-1/3 animate-pulse`:void 0),style:n===null?void 0:{width:`${n}%`}})}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[11px] text-fg-faint`,"data-testid":`agy-install-bytes`,children:r??``}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,disabled:t,onClick:i,"data-testid":`agy-install-cancel`,children:`Cancel`})]})]})}return e.supported?e.state===`idle`&&!n?(0,W.jsx)(`div`,{className:`space-y-2`,"data-testid":`agy-install`,"data-install-state":`starting`,children:(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-install-statement`,children:DB})}):(0,W.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-install`,"data-install-state":e.state,children:[e.state===`failed`?(0,W.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,"data-testid":`agy-install-failed`,children:e.error??`The install did not finish.`}):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-install-explanation`,children:OB}),(0,W.jsxs)(J,{variant:`primary`,busy:t,disabled:t,onClick:r,"data-testid":e.state===`failed`?`agy-install-retry`:`agy-install-button`,children:[(0,W.jsx)(q.Download,{className:`h-4 w-4`}),` `,e.state===`failed`?`Try again`:EB]})]}):null}function sV({login:e,busy:t,onStart:n,onRestart:r,onCancel:i,onSubmit:a}){let[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),u=(0,v.useRef)(null);(0,v.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]),(0,v.useEffect)(()=>{e.phase!==`awaiting_code`&&s(``)},[e.phase]);let d=(0,v.useRef)(null),f=e.phase===`awaiting_code`,p=f?QB(e.url):null,m=f&&e.expiresAt?Date.parse(e.expiresAt):NaN,h=Number.isFinite(m),g=aV(f&&h),_=h?Math.max(0,Math.ceil((m-g)/1e3)):null,y=_===0;(0,v.useEffect)(()=>{y&&s(``)},[y]);let b=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(e.phase===`starting`&&(b.current=!0),!f||!p||!e.startedAt||iV===e.startedAt)return;let t=h?Date.now()-(m-6e4):1/0;if(!(!b.current&&t>rV)){iV=e.startedAt;try{AR(p)}catch{}}},[e.phase,p,e.startedAt]),(0,v.useEffect)(()=>{f&&LP(d.current)},[f]);let[x,S]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(e.phase!==`verifying`){S(!1);return}let t=setTimeout(()=>S(!0),nV);return()=>clearTimeout(t)},[e.phase]);let C=o.trim(),w=im(C),T=()=>{!w||t||(s(``),a(C))},E=()=>{p&&XM(p).then(e=>{e&&(l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),1500))})},D=(0,W.jsx)(J,{size:`sm`,variant:`ghost`,disabled:t,onClick:i,"data-testid":`agy-login-cancel`,children:`Cancel`});return(0,W.jsxs)(`div`,{ref:d,className:`space-y-2`,"data-testid":`agy-sign-in`,"data-login-phase":e.phase,children:[(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-sign-in-explanation`,children:rm}),e.phase===`starting`?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`agy-login-starting`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-fg`,role:`status`,children:[(0,W.jsx)(q.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),e.message??`Starting Google’s sign-in…`]}),(0,W.jsx)(`span`,{className:`flex-1`}),D]}):e.phase===`awaiting_code`?(0,W.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-awaiting`,children:[y?(0,W.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-expired`,children:[(0,W.jsx)(`div`,{className:`rounded-md border border-warn/40 bg-warn-soft px-3 py-2 text-xs text-warn`,role:`alert`,children:`Time ran out — Google’s agy only waits a minute. Press Sign in again.`}),(0,W.jsxs)(J,{variant:`primary`,busy:t,disabled:t,onClick:r,"data-testid":`agy-login-expired-restart`,children:[(0,W.jsx)(q.LogIn,{className:`h-4 w-4`}),` Sign in again`]})]}):(0,W.jsxs)(W.Fragment,{children:[e.message?(0,W.jsx)(`p`,{className:`text-xs text-fg`,children:e.message}):null,p?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsxs)(`a`,{className:`inline-flex items-center gap-1 text-xs font-medium text-accent underline`,href:p,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),AR(p)},"data-testid":`agy-login-link`,children:[(0,W.jsx)(q.ExternalLink,{className:`h-3.5 w-3.5`}),` Open Google’s sign-in page`]}),(0,W.jsxs)(J,{size:`sm`,onClick:E,"data-testid":`agy-login-copy-link`,children:[(0,W.jsx)(q.Copy,{className:`h-3.5 w-3.5`}),` `,c?`Copied`:`Copy link`]})]}):null,(0,W.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-fg`,children:[(0,W.jsxs)(`span`,{className:`flex items-baseline justify-between gap-2`,children:[`Code from Google`,_===null?null:(0,W.jsxs)(`span`,{role:`timer`,className:U(`font-normal tabular-nums`,_<tV?`font-medium text-warn`:`text-fg-faint`),"data-tone":_<tV?`warn`:`neutral`,"data-testid":`agy-login-countdown`,children:[_,` s left to finish`]})]}),(0,W.jsx)(`input`,{className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 font-mono text-xs text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`,type:`text`,value:o,placeholder:`Paste the code Google shows you`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,"data-1p-ignore":`true`,"data-lpignore":`true`,"data-form-type":`other`,"data-autofocus":!0,onChange:e=>s(e.target.value),onPaste:e=>{let n=e.clipboardData?.getData(`text`).trim()??``;im(n)&&(e.preventDefault(),!t&&(s(``),a(n)))},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},"data-testid":`agy-login-code`})]}),C&&!w?(0,W.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`agy-login-code-hint`,children:`Paste the code exactly as Google shows it — one line, no spaces.`}):null,(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(J,{variant:`primary`,size:`sm`,disabled:!w||t,onClick:T,"data-testid":`agy-login-continue`,children:`Continue`}),D]})]}),y?(0,W.jsx)(`div`,{className:`flex items-center gap-2`,children:D}):null]}):e.phase===`verifying`?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`agy-login-verifying`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-fg`,role:`status`,children:[(0,W.jsx)(q.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),e.message??`Checking the code with Google…`]}),(0,W.jsx)(`span`,{className:`flex-1`}),D,x?(0,W.jsx)(`p`,{className:`w-full text-[11px] text-fg-faint`,"data-testid":`agy-login-verifying-slow`,children:`Still waiting for Google…`}):null]}):e.phase===`failed`?(0,W.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-failed`,children:[(0,W.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:e.message??`The sign-in did not finish.`}),(0,W.jsxs)(J,{variant:`primary`,busy:t,disabled:t,onClick:n,"data-testid":`agy-sign-in-restart`,children:[(0,W.jsx)(q.LogIn,{className:`h-4 w-4`}),` Start again`]})]}):(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[e.phase===`done`&&e.message?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.message}):null,(0,W.jsxs)(J,{variant:`primary`,busy:t,disabled:t,onClick:n,"data-testid":`agy-sign-in-button`,children:[(0,W.jsx)(q.LogIn,{className:`h-4 w-4`}),` `,kB]})]})]})}var cV={ok:`bg-ok`,warn:`bg-warn`,danger:`bg-danger`,neutral:`bg-surface-3`},lV={ok:`text-ok`,warn:`text-warn`,danger:`text-danger`,neutral:`text-fg-muted`};function uV({label:e,testid:t,children:n}){return(0,W.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 py-0.5 text-xs`,children:[(0,W.jsx)(`dt`,{className:`shrink-0 text-fg-faint`,children:e}),(0,W.jsx)(`dd`,{className:`min-w-0 text-right font-medium text-fg`,"data-testid":t,children:n})]})}function dV({definition:e}){let{api:t,socket:n}=G(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(0),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),h=(0,v.useRef)(!0),g=(0,v.useRef)(0),_=(0,v.useRef)(0);(0,v.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let y=(0,v.useCallback)(async(e,n=!1)=>{let r=++g.current;if(!t.getAgyStatus){o(!0);return}_.current+=1,n||u(e=>e+1);try{let n=await t.getAgyStatus(e?{refresh:!0}:void 0);if(!h.current||r!==g.current)return;i(n),c(null),o(!1)}catch(e){if(!h.current||r!==g.current)return;ym(e)?o(!0):c(mg(e))}finally{--_.current,!n&&h.current&&u(e=>e-1)}},[t]),b=(0,v.useCallback)(async(e,t,n=``)=>{g.current+=1,f(e),m(null);try{let e=await t();return h.current?(g.current+=1,i(e),c(null),o(!1),e):null}catch(e){return h.current&&(ym(e)?o(!0):(m($B(mg(e),n)),y(!1,!0))),null}finally{h.current&&f(null)}},[y]);(0,v.useEffect)(()=>{y(!1)},[y]);let[x,S]=(0,v.useState)(!1),C=(0,v.useCallback)(async()=>{if(!t.agyInstall){o(!0);return}S(!0),await b(`install`,()=>t.agyInstall())},[t,b]),w=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!(w.current||!r||!t.agyInstall)){if(r.install.state!==`idle`){w.current=!0;return}r.state!==`not_installed`||!r.install.supported||(w.current=!0,C())}},[r,t,C]);let T=qB(r);(0,v.useEffect)(()=>{if(T===null)return;let e=setInterval(()=>{_.current===0&&y(!1,!0)},T);return()=>clearInterval(e)},[T,y]),(0,v.useEffect)(()=>n.on(`account_changed`,e=>{e.reason===`provider`&&y(!1,!0)}),[n,y]);let E=As(e);if(a)return(0,W.jsx)(`div`,{className:`rounded-md border border-warn/40 bg-warn-soft px-3 py-2 text-xs text-warn`,"data-testid":`agy-unsupported`,children:AB});let D=r===null&&s===null,O=l>0,k=JB(r),A=r?.install.state===`working`,j=(0,W.jsx)(J,{variant:`primary`,size:`sm`,busy:O||D,disabled:O||D||k,onClick:()=>void y(!0),"data-testid":`agy-check-again`,children:O||D?`Checking…`:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q.Refresh,{className:`h-3.5 w-3.5`}),` Check again`]})}),M=r?A?{label:`Installing agy…`,tone:`accent`}:HB(r.state):null;return(0,W.jsxs)(`div`,{className:`space-y-3`,"data-testid":`agy-card`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,W.jsx)(Z,{tone:`ok`,children:E.badge}),(0,W.jsx)(Z,{children:e.kind})]}),(0,W.jsx)(`div`,{className:`rounded-md border border-ok/40 bg-ok-soft px-3 py-2 text-xs text-ok`,"data-testid":`agy-route`,children:E.detail}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[M?(0,W.jsx)(`span`,{"data-testid":`agy-state`,"data-state":r?.state,children:(0,W.jsx)(Z,{tone:M.tone,children:M.label})}):D?(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,"data-testid":`agy-checking`,children:[(0,W.jsx)(q.Spinner,{className:`h-3.5 w-3.5`}),` Asking agy…`]}):null,(0,W.jsx)(`span`,{className:`flex-1`}),j]}),O&&r?(0,W.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`agy-busy-note`,children:`Asking agy again — this takes a few seconds.`}):null,s?(0,W.jsxs)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,"data-testid":`agy-failed`,children:[`The host could not check agy: `,s]}):null,r?(0,W.jsxs)(W.Fragment,{children:[r.state!==`ready`&&r.message&&!k?(0,W.jsx)(`p`,{className:`text-xs text-fg`,"data-testid":`agy-message`,children:r.message}):null,r.state===`not_installed`?(0,W.jsx)(oV,{install:r.install,busy:d===`install`||d===`cancel_install`,offer:!t.agyInstall||x&&d!==`install`,onInstall:()=>{w.current=!0,C()},onCancel:()=>{w.current=!0,S(!0),t.cancelAgyInstall&&b(`cancel_install`,()=>t.cancelAgyInstall())}}):null,r.state===`not_signed_in`?(0,W.jsx)(sV,{login:r.login,busy:d===`login`||d===`cancel_login`||d===`code`,onStart:()=>{t.agyLogin?b(`login`,()=>t.agyLogin()):o(!0)},onRestart:()=>{(async()=>{t.cancelAgyLogin&&await b(`cancel_login`,()=>t.cancelAgyLogin()),t.agyLogin?await b(`login`,()=>t.agyLogin()):o(!0)})()},onCancel:()=>{t.cancelAgyLogin&&b(`cancel_login`,()=>t.cancelAgyLogin())},onSubmit:e=>{t.submitAgyLoginCode?b(`code`,()=>t.submitAgyLoginCode(e),e):o(!0)}}):null,p?(0,W.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,"data-testid":`agy-action-error`,children:p}):null,(0,W.jsxs)(`dl`,{className:`rounded-md border border-border px-3 py-1.5`,"data-testid":`agy-facts`,children:[(0,W.jsx)(uV,{label:`Installed`,testid:`agy-installed`,children:r.installed?`Yes`:`No`}),r.path?(0,W.jsx)(uV,{label:`Path`,testid:`agy-path`,children:(0,W.jsx)(`span`,{className:`break-all font-mono text-[11px]`,children:r.path})}):null,r.version?(0,W.jsx)(uV,{label:`Version`,testid:`agy-version`,children:r.version}):null,(0,W.jsx)(uV,{label:`Signed in`,testid:`agy-signed-in`,children:r.signedIn===null?r.installed?`Unknown`:`—`:r.signedIn?`Yes`:`No`}),(0,W.jsx)(uV,{label:`Checked`,testid:`agy-checked`,children:(0,W.jsx)(`span`,{title:sg(r.checkedAt),children:ag(r.checkedAt)})})]}),UB(r)?(0,W.jsxs)(`p`,{className:`flex items-start gap-1.5 rounded-md bg-surface-2 px-3 py-2 text-xs text-fg-muted`,"data-testid":`agy-newer-note`,children:[(0,W.jsx)(q.Info,{className:`mt-px h-3.5 w-3.5 shrink-0`}),UB(r)]}):null,r.models.length>0?(0,W.jsxs)(`div`,{"data-testid":`agy-models`,children:[(0,W.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-muted`,children:`Models agy offers`}),(0,W.jsx)(`ul`,{className:`space-y-0.5`,children:r.models.map(e=>(0,W.jsxs)(`li`,{className:`flex items-baseline justify-between gap-3 text-xs`,"data-testid":`agy-model-${e.id}`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.displayName}),(0,W.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-fg-faint`,children:e.id})]},e.id))})]}):null,r.usage.length>0?(0,W.jsxs)(`div`,{"data-testid":`agy-usage`,children:[(0,W.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-muted`,children:`Your plan’s usage`}),(0,W.jsx)(`ul`,{className:`space-y-2`,children:r.usage.map((e,t)=>{let n=WB(e),r=e.remainingPercent;return(0,W.jsxs)(`li`,{"data-testid":`agy-usage-row-${t}`,children:[(0,W.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 truncate text-fg`,children:[e.group,` · `,e.window]}),(0,W.jsx)(`span`,{className:U(`shrink-0 font-medium`,lV[n.tone]),"data-tone":n.tone,"data-testid":`agy-usage-remaining-${t}`,children:n.remaining})]}),(0,W.jsx)(`div`,{className:`mt-0.5 h-1.5 w-full overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`${e.group} ${e.window}: ${n.remaining}`,"aria-valuemin":0,"aria-valuemax":100,...r!==null&&Number.isFinite(r)?{"aria-valuenow":Math.round(r)}:{},children:(0,W.jsx)(`div`,{className:U(`h-full rounded-full`,cV[n.tone]),style:{width:`${r!==null&&Number.isFinite(r)?Math.min(100,Math.max(0,r)):0}%`}})}),n.resets?(0,W.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:n.resets}):null]},`${e.group}-${e.window}-${t}`)})})]}):null]}):null]})}function fV(e,t){let n=e.definition.displayName;return!t||t.id===`payg`||t.id===`api-key`?[`Sign in to the ${n} console.`,`Create an API key (or copy an existing one).`,`Paste it below — OonaCode encrypts it into your vault before it leaves this PC.`]:[`Open the ${n} console and pick the ${t.label} plan.`,t.notes??`Complete the provider’s subscription/token flow in the browser.`,`Copy the token it issues${t.keyFormat?` (looks like ${t.keyFormat})`:``} and paste it below.`]}function pV(e,t){let n=e.find(e=>e.definition.id===t);if(!n)return[];let r=n.definition.clientGroup??n.definition.id,i=e.find(e=>e.definition.id===r);return i?[i,...e.filter(e=>e.definition.clientGroup===r)]:[n]}function mV(e){let t=[];for(let n of e){let e=n.definition,r=Ts(e),i=e.credentialClass===`subscription`;if(r.length>1)for(let i of r)t.push({key:`${e.id}:${i.id}`,label:i.id===`token-plan`?`Subscription`:i.id===`payg`?`API`:i.label,provider:n,variantId:i.id,variant:i,isSubscription:!1,hasLoginFlow:!1,loginKind:null,keyFormat:i.keyFormat??e.keyFormat});else t.push({key:e.id,label:e.recordLabel??(i?`Subscription`:`API`),provider:n,variantId:r[0]?.id??null,variant:r[0]??null,isSubscription:i,hasLoginFlow:i&&e.route===`direct`,loginKind:i&&e.route===`direct`?e.subscriptionLogin?`oauth`:`claude`:null,keyFormat:r[0]?.keyFormat??e.keyFormat})}return t}function hV(e){let t=(e.provider.credentials??[]).filter(e=>e.class!==`none`);return(e.variantId?t.filter(t=>(t.variantId??`payg`)===e.variantId):t).slice(0,1)}function gV({open:e,providerId:t,onClose:n}){let{state:r,actions:i}=G(),a=(0,v.useMemo)(()=>t?pV(r.providers,t):[],[r.providers,t]),o=(0,v.useMemo)(()=>mV(a),[a]),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),b=o.find(e=>e.key===s)??o[0]??null;if((0,v.useEffect)(()=>{if(!e)return;let n=o.find(e=>e.provider.definition.id===t);c((n??o[0])?.key??``),u(``),m(``),y(null)},[e,t,o]),(0,v.useEffect)(()=>{if(!e||!b)return;let t=b.provider.definition;f(t.userBaseUrl?b.variant?.baseUrl??t.baseUrl:``)},[e,b,b?.key]),!b)return null;let x=b.provider.definition,S=a[0]?.definition?.displayName??x.displayName;if(x.engine===`agy`)return(0,W.jsx)(Ky,{open:e,title:S,onClose:n,footer:(0,W.jsx)(J,{onClick:n,children:`Close`}),children:(0,W.jsx)(dV,{definition:x})});let C=hV(b),w=a.some(e=>(e.credentials??[]).some(e=>e.class!==`none`)),T=x.credentialClass!==`none`,E=As(x,{credentialClass:b.isSubscription?`subscription`:x.credentialClass,...x.userBaseUrl&&d.trim()?{baseUrl:d.trim()}:{}}),D=!h&&(!T||l.trim().length>0),O=async()=>{g(!0),y(null);try{if(!T){await i.setActiveProvider(x.id),n();return}let e=await i.probeCredential(x.id,{secret:l.trim(),variantId:b.variantId,...x.userBaseUrl&&d.trim()?{baseUrl:d.trim()}:{}});if(!e.ok){y(e.error??`${S} rejected this key — check it and try again.`);return}let t={};b.variantId&&(t.variant=b.variantId),x.userBaseUrl&&d.trim()&&(t.baseUrl=d.trim()),await i.addCredential({class:b.isSubscription?`subscription`:`api_key`,providerId:x.id,secret:l.trim(),...p.trim()?{label:p.trim()}:{},...Object.keys(t).length>0?{meta:t}:{}})&&(u(``),n())}finally{g(!1)}};return(0,W.jsx)(Ky,{open:e,title:`${w?`Manage`:`Connect`} ${S}`,onClose:n,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{onClick:n,children:`Cancel`}),b.loginKind===`oauth`?(0,W.jsxs)(J,{onClick:()=>i.openOauthLogin(b.provider.definition.id),"data-testid":`connect-oauth-signin`,children:[(0,W.jsx)(q.LogIn,{className:`w-4 h-4`}),` `,b.provider.definition.subscriptionLogin?.signInLabel??`Sign in instead`]}):b.loginKind===`claude`?(0,W.jsxs)(J,{onClick:()=>i.openClaudeLogin(null),"data-testid":`connect-claude-signin`,children:[(0,W.jsx)(q.LogIn,{className:`w-4 h-4`}),` Sign in instead`]}):null,(0,W.jsx)(J,{variant:`primary`,busy:h,disabled:!D,onClick:()=>void O(),children:h?`Checking…`:T?`Save key`:`Use this provider`})]}),children:(0,W.jsxs)(`div`,{className:`space-y-3`,children:[o.length>1?(0,W.jsx)(`div`,{className:`flex gap-1 border-b border-border`,role:`tablist`,children:o.map(e=>{let t=hV(e)[0];return(0,W.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.key===b.key,"data-testid":`record-tab-${e.key}`,onClick:()=>c(e.key),className:e.key===b.key?`rounded-t-md border border-b-0 border-border bg-surface-2 px-3 py-1.5 text-sm font-medium`:`px-3 py-1.5 text-sm text-fg-muted hover:text-fg`,children:[e.label,t?(0,W.jsx)(`span`,{className:`ml-1.5 font-mono text-[11px] text-ok`,children:t.masked}):null]},e.key)})}):null,C.length>0?(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:`Connected`}),C.map(e=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border px-2.5 py-1.5`,"data-testid":`stored-credential-${e.id}`,children:[(0,W.jsx)(Z,{tone:e.class===`subscription`?`accent`:`ok`,children:b.label}),(0,W.jsx)(`span`,{className:`font-mono text-xs`,children:e.masked}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-fg-faint`,children:e.label}),(0,W.jsx)(J,{size:`sm`,onClick:()=>void i.testCredential(e.id),children:`Test`}),(0,W.jsx)(J,{size:`sm`,variant:`danger`,onClick:()=>void i.deleteCredential(e.id),children:`Remove`})]},e.id))]}):null,(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,W.jsx)(Z,{tone:E.viaGateway?`accent`:`ok`,children:E.badge}),(0,W.jsx)(Z,{children:x.kind}),b.keyFormat?(0,W.jsxs)(`span`,{className:`text-fg-faint`,children:[`key format `,b.keyFormat]}):null]}),(0,W.jsxs)(`div`,{className:E.viaGateway?`rounded-md border border-border bg-surface-2 px-3 py-2 text-xs text-fg-muted`:`rounded-md border border-ok/40 bg-ok-soft px-3 py-2 text-xs text-ok`,"data-testid":`connect-route`,children:[E.detail,T&&!E.viaGateway?` The key is stored in your zero-knowledge vault.`:null]}),T?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`ol`,{className:`ml-4 list-decimal space-y-1 text-xs text-fg-muted`,children:b.loginKind===`oauth`?[`Press “${b.provider.definition.subscriptionLogin?.signInLabel??`Sign in`}”: a short code opens in your browser, you approve it, and the subscription is stored by itself — nothing to paste.`,`The token refreshes on its own; sign in again only if the provider says it expired.`,`Or paste an access token below, if you have one from elsewhere.`].map((e,t)=>(0,W.jsx)(`li`,{children:e},t)):b.hasLoginFlow?[`Press “Sign in instead” to get a token through the genuine engine — the fastest way.`,"Or run `claude setup-token` yourself and complete the sign-in in your browser.",`Paste the token it prints below (it looks like sk-ant-oat01-…).`].map((e,t)=>(0,W.jsx)(`li`,{children:e},t)):fV(b.provider,b.variant).map((e,t)=>(0,W.jsx)(`li`,{children:e},t))}),(0,W.jsx)(Wy,{label:b.isSubscription?`Subscription token`:`API key`,hint:`Tried against the provider before it is saved, then encrypted on this PC with your vault key.`,children:(0,W.jsx)(`input`,{className:X,type:`password`,autoComplete:`off`,spellCheck:!1,value:l,placeholder:b.keyFormat??`sk-…`,onChange:e=>{u(e.target.value),y(null)}})}),_?(0,W.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,"data-testid":`connect-probe-error`,children:_}):null,x.userBaseUrl?(0,W.jsx)(Wy,{label:`Base URL`,hint:`Point this at your own server if it is not the default. Each record has its own endpoint.`,children:(0,W.jsx)(`input`,{className:X,value:d,spellCheck:!1,onChange:e=>f(e.target.value),placeholder:b.variant?.baseUrl??x.baseUrl})}):null,(0,W.jsx)(Wy,{label:`Label (optional)`,children:(0,W.jsx)(`input`,{className:X,value:p,onChange:e=>m(e.target.value),placeholder:`${S} ${b.label.toLowerCase()} key`})})]}):(0,W.jsxs)(`div`,{className:`rounded-md bg-surface-2 px-3 py-2 text-xs text-fg-muted`,children:[x.displayName,` needs no credential.`]})]})})}function _V({open:e,onClose:t}){let{state:n,actions:r}=G(),i=n.ui.oauthLoginProviderId,a=i?n.providers.find(e=>e.definition.id===i)??null:null,o=n.oauthLogin&&n.oauthLogin.providerId===i?n.oauthLogin:null,[s,c]=(0,v.useState)(0),[l,u]=(0,v.useState)(!1),d=(0,v.useRef)(null),f=a?.definition.displayName??i??`the provider`,p=a?.definition.subscriptionLogin?.signInLabel??`Sign in to ${f}`,m=o?.phase===`awaiting_approval`,h=m?o?.verificationUriComplete??o?.verificationUri??null:null;(0,v.useEffect)(()=>{if(!e||!i)return;d.current=null,r.startOauthLogin(i);let t=setInterval(()=>void r.refreshOauthLogin(i),2e3);return()=>clearInterval(t)},[e,i,s,r]),(0,v.useEffect)(()=>{!e||!h||!o?.id||d.current===o.id||(d.current=o.id,AR(h))},[e,h,o?.id]),(0,v.useEffect)(()=>{e&&o?.phase===`connected`&&r.refreshCredentials()},[e,o?.phase,r]);let g=e=>{if(!navigator.clipboard){r.toast(`error`,`Could not copy — select it and copy by hand`);return}navigator.clipboard.writeText(e).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)}).catch(()=>r.toast(`error`,`Could not copy`))},_=o?.phase===`connected`||o?.phase===`failed`||o?.phase===`expired`||o?.phase===`cancelled`;return(0,W.jsx)(Ky,{open:e,title:p,onClose:t,footer:(0,W.jsxs)(W.Fragment,{children:[m?(0,W.jsx)(J,{onClick:()=>i&&void r.cancelOauthLogin(i),"data-testid":`oauth-login-cancel`,children:`Cancel sign-in`}):null,_&&o?.phase!==`connected`?(0,W.jsx)(J,{onClick:()=>c(e=>e+1),"data-testid":`oauth-login-retry`,children:`Try again`}):null,(0,W.jsx)(J,{variant:`primary`,onClick:t,children:o?.phase===`connected`?`Done`:`Close`})]}),children:(0,W.jsx)(`div`,{className:`space-y-3 text-sm`,"data-testid":`oauth-login-dialog`,children:m&&o?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{children:[`A sign-in page for `,f,` opened in your browser. If it did not, open the link below on any device and enter this code:`]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`code`,{className:`text-lg font-mono px-2 py-1 rounded border border-border`,"data-testid":`oauth-user-code`,children:o.userCode}),(0,W.jsxs)(J,{onClick:()=>o.userCode&&g(o.userCode),children:[(0,W.jsx)(q.Copy,{className:`w-4 h-4`}),` `,l?`Copied`:`Copy code`]})]}),h?(0,W.jsxs)(`div`,{className:`flex items-center gap-2 break-all`,children:[(0,W.jsx)(`a`,{className:`underline`,href:h,onClick:e=>{e.preventDefault(),AR(h)},children:h}),(0,W.jsxs)(J,{onClick:()=>g(h),children:[(0,W.jsx)(q.Copy,{className:`w-4 h-4`}),` Copy link`]})]}):null,(0,W.jsxs)(`p`,{className:`text-fg-muted`,children:[`Waiting for your approval… the code expires`,o.expiresAt?` at ${new Date(o.expiresAt).toLocaleTimeString()}`:` soon`,`. The subscription is stored in your vault the moment `,f,` confirms it.`]})]}):o?.phase===`connected`?(0,W.jsxs)(`p`,{"data-testid":`oauth-login-connected`,children:[`Signed in. Your `,f,` subscription is stored in your vault and synced to your other machines; chats on it run from this PC straight to the provider.`]}):_?(0,W.jsx)(`p`,{className:`text-danger`,"data-testid":`oauth-login-ended`,children:o?.message??`The sign-in did not complete.`}):(0,W.jsx)(`p`,{children:`Starting the sign-in…`})})})}function vV({open:e,onClose:t}){let{state:n,actions:r}=G(),i=(0,v.useMemo)(()=>sf(n.providers),[n.providers]),[a,o]=(0,v.useState)({}),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1);(0,v.useEffect)(()=>{e&&(o({...n.settings?.modelVisibility??{}}),c(``))},[e]);let d=(e,t)=>a[e]??t,f=(e,t,n)=>d(e,n).includes(t),p=(e,t,n)=>{o(r=>{let i=r[e]??n,a=i.includes(t)?i.filter(e=>e!==t):n.filter(e=>e===t||i.includes(e));return{...r,[e]:a}})},m=(e,t,n)=>{o(r=>({...r,[e]:t?[...n]:[]}))},h=async()=>{u(!0);try{let e={};for(let t of i){let n=t.definition.models.map(e=>e.id),r=a[t.definition.id];r&&r.length!==n.length&&(e[t.definition.id]=r)}await r.saveSettings({modelVisibility:e}),t()}finally{u(!1)}},g=s.trim().toLowerCase();return(0,W.jsx)(Ky,{open:e,title:`Manage models`,onClose:t,wide:!0,footer:(0,W.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,W.jsxs)(J,{onClick:()=>{t(),r.openSettings(`providers`)},"data-testid":`manage-models-add-provider`,children:[(0,W.jsx)(q.Plus,{className:`w-3.5 h-3.5`}),` Add provider`]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(J,{onClick:t,children:`Cancel`}),(0,W.jsx)(J,{variant:`primary`,busy:l,onClick:()=>void h(),"data-testid":`manage-models-save`,children:`Save`})]})]}),children:(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Choose which models the chat's picker offers. A provider with every model checked shows all of them — including ones it adds later.`}),(0,W.jsx)(`input`,{className:X,value:s,onChange:e=>c(e.target.value),placeholder:`Filter models…`,"data-testid":`manage-models-filter`}),i.length===0?(0,W.jsxs)(`div`,{className:`text-sm text-fg-faint`,children:[`No provider is connected yet — use `,(0,W.jsx)(`strong`,{children:`Add provider`}),` below to connect one.`]}):null,i.map(e=>{let t=e.definition.models.map(e=>e.id),n=e.definition.models.filter(e=>!g||e.id.toLowerCase().includes(g)||(e.displayName??``).toLowerCase().includes(g)),r=d(e.definition.id,t).length;return(0,W.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`manage-models-${e.definition.id}`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`font-medium`,children:e.definition.displayName}),(0,W.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[r===t.length?`all`:r,` of `,t.length,` shown`]}),(0,W.jsxs)(`span`,{className:`ml-auto flex gap-1`,children:[(0,W.jsx)(J,{size:`sm`,onClick:()=>m(e.definition.id,!0,t),children:`All`}),(0,W.jsx)(J,{size:`sm`,onClick:()=>m(e.definition.id,!1,t),children:`None`})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-2`,children:[n.map(n=>(0,W.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:f(e.definition.id,n.id,t),onChange:()=>p(e.definition.id,n.id,t),"data-testid":`manage-model-${n.id}`}),(0,W.jsxs)(`span`,{className:`truncate`,title:n.id,children:[n.displayName??n.id,n.displayName&&n.displayName!==n.id?(0,W.jsxs)(`span`,{className:`text-fg-faint`,children:[` · `,n.id]}):null]})]},n.id)),n.length===0?(0,W.jsxs)(`div`,{className:`text-xs text-fg-faint`,children:[(0,W.jsx)(q.Info,{className:`mr-1 inline w-3 h-3`}),` No model matches the filter.`]}):null]})]},e.definition.id)})]})})}var yV={mode:`names`,mine:!0,model:!0,tools:!1,subagents:!1,projectId:null,when:`any`,caseSensitive:!1,wholeWord:!1};function bV(e,t,n){let r=De(t,{caseSensitive:n.caseSensitive,wholeWord:n.wholeWord});if(!r)return[{text:e,hit:!1}];let i=[],a=0;for(let t of e.matchAll(r)){let n=t.index??0;t[0].length!==0&&(n>a&&i.push({text:e.slice(a,n),hit:!1}),i.push({text:t[0],hit:!0}),a=n+t[0].length)}return a<e.length&&i.push({text:e.slice(a),hit:!1}),i}function xV(e){return Object.keys(yV).some(t=>e[t]!==yV[t])}function SV(e,t=Date.now()){if(e===`any`)return null;if(e===`today`){let e=new Date(t);return e.setHours(0,0,0,0),e}return new Date(t-(e===`week`?7:30)*24*60*60*1e3)}function CV(e,t,n,r=Date.now()){if(n.projectId!==null&&e.projectId!==n.projectId)return!1;let i=SV(n.when,r);if(i&&e.mtime<i.getTime())return!1;if((n.caseSensitive||n.wholeWord)&&t.trim()!==``){let r=[e.title,e.firstPrompt,e.lastPrompt,e.projectDir],i={caseSensitive:n.caseSensitive,wholeWord:n.wholeWord};if(!r.some(e=>typeof e==`string`&&Oe(e,t,i)))return!1}return!0}function wV(e,t,n=Date.now()){let r=e.trim();if(r.length<2||!t.mine&&!t.model&&!t.tools)return null;let i=SV(t.when,n);return{q:r,limit:200,from:t.mine&&t.model?`both`:t.mine?`user`:t.model?`assistant`:`none`,tools:t.tools,subagents:t.subagents,...i?{since:i.toISOString()}:{},...t.projectId?{projectId:t.projectId}:{},caseSensitive:t.caseSensitive,wholeWord:t.wholeWord}}function TV({label:e,hint:t,checked:n,onChange:r,testId:i}){return(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 py-0.5 text-xs`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:n,onChange:e=>r(e.target.checked),"data-testid":i}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`text-fg`,children:e}),t?(0,W.jsx)(`span`,{className:`block text-[11px] text-fg-faint`,children:t}):null]})]})}var EV=`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-fg focus:outline-none`,DV={names:`Names & prompts`,conversations:`Whole chats`,namesHint:`A chat’s name, its first and last message, and its folder.`,conversationsHint:`Every message of every chat on this PC. Pick whose words to look in.`};function OV({options:e,onChange:t,projects:n,onClose:r,words:i=DV}){let a=(n,r)=>t({...e,[n]:r}),o=e.mode===`conversations`,s=o&&!e.mine&&!e.model&&!e.tools;return(0,W.jsxs)(`div`,{className:`absolute left-2 right-2 top-full z-30 mt-1 space-y-3 rounded-lg border border-border bg-surface p-3 shadow-xl`,onMouseDown:e=>{!(e.target instanceof HTMLSelectElement)&&!(e.target instanceof HTMLInputElement)&&e.preventDefault()},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),r())},"data-testid":`search-options`,children:[(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:`Search in`}),(0,W.jsx)(Jy,{label:`Search in`,value:e.mode,options:[{value:`names`,label:i.names},{value:`conversations`,label:i.conversations}],onChange:e=>a(`mode`,e)}),(0,W.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`search-mode-hint`,children:o?i.conversationsHint:i.namesHint})]}),o?(0,W.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,W.jsx)(TV,{label:`My messages`,checked:e.mine,onChange:e=>a(`mine`,e),testId:`search-opt-mine`}),(0,W.jsx)(TV,{label:`Model replies`,checked:e.model,onChange:e=>a(`model`,e),testId:`search-opt-model`}),(0,W.jsx)(TV,{label:`Tool calls & output`,hint:`Commands, file paths and what the tools answered.`,checked:e.tools,onChange:e=>a(`tools`,e),testId:`search-opt-tools`}),(0,W.jsx)(TV,{label:`Subagents’ conversations`,checked:e.subagents,onChange:e=>a(`subagents`,e),testId:`search-opt-subagents`}),s?(0,W.jsx)(`p`,{className:`text-[11px] text-warn`,children:`Tick at least one to search.`}):null]}):null,(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[n?(0,W.jsxs)(`label`,{className:`space-y-1 text-[11px] text-fg-faint`,children:[(0,W.jsx)(`span`,{children:`Project`}),(0,W.jsxs)(`select`,{className:EV,value:e.projectId??``,onChange:e=>a(`projectId`,e.target.value||null),"data-testid":`search-opt-project`,children:[(0,W.jsx)(`option`,{value:``,children:`All projects`}),n.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}):null,(0,W.jsxs)(`label`,{className:`space-y-1 text-[11px] text-fg-faint`,children:[(0,W.jsx)(`span`,{children:`When`}),(0,W.jsxs)(`select`,{className:EV,value:e.when,onChange:e=>a(`when`,e.target.value),"data-testid":`search-opt-when`,children:[(0,W.jsx)(`option`,{value:`any`,children:`Any time`}),(0,W.jsx)(`option`,{value:`today`,children:`Today`}),(0,W.jsx)(`option`,{value:`week`,children:`Last 7 days`}),(0,W.jsx)(`option`,{value:`month`,children:`Last 30 days`})]})]})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-x-4`,children:[(0,W.jsx)(TV,{label:`Match case`,checked:e.caseSensitive,onChange:e=>a(`caseSensitive`,e),testId:`search-opt-case`}),(0,W.jsx)(TV,{label:`Whole words`,checked:e.wholeWord,onChange:e=>a(`wholeWord`,e),testId:`search-opt-word`})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border pt-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:U(`text-xs`,xV(e)?`text-accent hover:underline`:`text-fg-faint`),disabled:!xV(e),onClick:()=>t(yV),"data-testid":`search-opt-reset`,children:`Reset`}),(0,W.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-2 px-2 py-1 text-xs text-fg hover:bg-surface-3`,onClick:r,"data-testid":`search-opt-done`,children:`Done`})]})]})}function kV(e){return e.kind===`tool`?e.tool??`Tool`:e.role===`assistant`?`Model`:`You`}function AV({query:e,options:t}){let{state:n,actions:r}=G(),i=(0,v.useMemo)(()=>wV(e,t),[e,t]),[a,o]=(0,v.useState)(null),s=i?JSON.stringify(i):``;(0,v.useEffect)(()=>{if(!i)return;let e=!0,t=setTimeout(()=>{r.searchTranscripts(i).then(t=>{e&&o({key:s,res:t})})},350);return()=>{e=!1,clearTimeout(t)}},[s,r]);let c=a&&a.key===s?a:null,l=(0,v.useMemo)(()=>{let e=new Map;for(let t of c?.res?.hits??[]){let r=n.sessions.find(e=>e.id===t.sessionId)?.title||t.title||`Untitled chat`,i=e.get(t.sessionId)??{title:r,hits:[]};i.hits.push(t),e.set(t.sessionId,i)}return[...e.entries()]},[c,n.sessions]);if(!i)return(0,W.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-fg-faint`,"data-testid":`transcript-search-idle`,children:e.trim().length<2?`Type at least two characters to search every chat.`:`Tick what to look in — your messages, the model’s replies or the tools’ side.`});if(!c)return(0,W.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-fg-faint`,"data-testid":`transcript-search-busy`,children:`Searching every chat…`});if(c.res===null)return(0,W.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-danger`,"data-testid":`transcript-search-failed`,children:`This PC could not search its chats. Try again, or update OonaCode.`});let u=c.res.hits.length;return(0,W.jsxs)(`div`,{className:`pb-2`,"data-testid":`transcript-search-results`,children:[(0,W.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-fg-faint`,children:u===0?`No message on this PC says that.`:`${u}${c.res.truncated?`+`:``} ${u===1?`message`:`messages`} in ${l.length} ${l.length===1?`chat`:`chats`}`}),l.map(([n,i])=>(0,W.jsxs)(`div`,{className:`mb-1.5`,"data-testid":`transcript-search-chat-${n}`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-[13px] font-semibold text-fg hover:bg-surface-2`,onClick:()=>r.openChatWithSearch(n,e.trim()),children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i.title}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-3 px-1.5 text-[10px] font-semibold text-fg-muted`,children:i.hits.length})]}),i.hits.map(i=>(0,W.jsxs)(`button`,{type:`button`,className:`block w-full rounded px-2 py-1 pl-4 text-left text-xs hover:bg-surface-2`,onClick:()=>r.openChatWithSearch(n,e.trim()),"data-testid":`transcript-search-hit`,children:[(0,W.jsxs)(`span`,{className:`mb-0.5 flex items-center gap-1.5 text-[10px] text-fg-faint`,children:[i.kind===`tool`?(0,W.jsx)(q.Tool,{className:`h-3 w-3`}):i.role===`assistant`?(0,W.jsx)(q.Bot,{className:`h-3 w-3`}):(0,W.jsx)(q.User,{className:`h-3 w-3`}),(0,W.jsx)(`span`,{className:`font-medium text-fg-muted`,children:kV(i)}),i.subpath?(0,W.jsx)(`span`,{children:`· subagent`}):null,i.timestamp?(0,W.jsx)(`span`,{className:`ml-auto`,children:ag(i.timestamp)}):null]}),(0,W.jsx)(`span`,{className:`line-clamp-3 text-fg-muted`,children:bV(i.snippet,e,t).map((e,t)=>e.hit?(0,W.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,W.jsx)(`span`,{children:e.text},t))})]},`${i.seq}`))]},n))]})}function jV(e){return`${e.agentId??`claude-code`}:${e.id}`}function MV(e){let t=Date.parse(e.lastEntryAt??e.updatedAt);return Number.isFinite(t)?t:0}function NV(e,t,n=Date.now()){let r=SV(t.when,n)?.getTime()??null,i=De(e,{caseSensitive:t.caseSensitive,wholeWord:t.wholeWord});return e=>r!==null&&MV(e)<r?!1:i===null||[e.title,e.firstPrompt,e.lastPrompt,e.cwd,e.projectName,e.id].some(e=>typeof e==`string`&&(i.lastIndex=0,i.test(e)))}function PV(e,t,n=Date.now()){let r=e.trim();if(r.length<2||!t.mine&&!t.model&&!t.tools)return null;let i=SV(t.when,n);return{q:r,from:t.mine&&t.model?`both`:t.mine?`user`:t.model?`assistant`:`none`,tools:t.tools,subagents:t.subagents,...i?{since:i.toISOString()}:{},caseSensitive:t.caseSensitive,wholeWord:t.wholeWord}}function FV(e,t){let n=new Map;for(let t of e){let e=jV(t);n.set(e,e);for(let r of t.supersedes??[]){let i=jV({agentId:t.agentId,id:r});n.has(i)||n.set(i,e)}}let r=new Map;for(let e of t){let t=n.get(jV(e));if(!t)continue;let i=r.get(t);if(!i){r.set(t,{...e,snippets:e.snippets.slice(0,3)});continue}r.set(t,{...i,hits:i.hits+e.hits,...i.hitsCapped||e.hitsCapped?{hitsCapped:!0}:{},snippets:[...i.snippets,...e.snippets].slice(0,3)})}return r}var IV={new:`New`,imported:`Imported`,behind:`Imported · original moved on`,deleted:`You deleted it in OonaCode`,unavailable:`Cannot be imported yet`};function LV(e){return e.alreadyImported?e.upToDate===!1?`behind`:`imported`:e.deletedHere===!0?`deleted`:RV(e)?`unavailable`:`new`}function RV(e){return typeof e.unavailable==`string`&&e.unavailable.length>0}function zV(e){if(RV(e))return!1;let t=LV(e);return t===`new`||t===`behind`}function BV(e){return LV(e)===`new`}function VV(e,t){return new Set(t?e.filter(BV).map(e=>e.id):[])}function HV(e){if(!e.some(e=>e.projectName))return e;let t=[],n=new Map;for(let r of e){let e=r.projectName??``,i=n.get(e);i||(i=[],n.set(e,i),t.push(e)),i.push(r)}return t.flatMap(e=>n.get(e)??[])}function UV(){return{new:0,imported:0,behind:0,deleted:0,unavailable:0}}function WV(e){let t=new Map;for(let n of e){let e=n.agentId??`claude-code`,r=t.get(e);r||(r={key:e,name:n.agentName??`Claude Code`,rows:[],counts:UV()},t.set(e,r)),r.rows.push(n),r.counts[LV(n)]+=1}for(let e of t.values())e.rows=HV([...e.rows].sort((e,t)=>MV(t)-MV(e)));return[...t.values()]}function GV(e,t){let n=0,r=0,i=0;for(let a of e){let e=t.has(a.id);e&&(n+=1),zV(a)&&(r+=1,e&&(i+=1))}return n===0?`none`:r>0&&i===r?`all`:`some`}function KV(e,t){let n=new Set(t),r=e.filter(zV);if(GV(e,t)===`all`||r.length===0)for(let t of e)n.delete(t.id);else for(let e of r)n.add(e.id);return n}function qV(e,t){let n=0;if(t)for(let r of e)t.has(r)||(n+=1);return{total:e.size,notShown:n}}var JV={names:`Names & folders`,conversations:`Whole conversations`,namesHint:`A chat’s name, its first and last message, and the folder it ran in.`,conversationsHint:`Every message of every chat listed here, read from the other apps’ own files. Pick whose words to look in.`},YV=`Ticks the chats with something to bring in — new ones, and imported ones whose original moved on. An imported chat that is up to date, or one you deleted in OonaCode, is ticked on its own row.`;function XV(e){return e.partial===`time`?`Stopped after ${Math.round(e.elapsedMs/1e3)} s — these are the chats found until then. A longer phrase narrows it.`:e.partial===`chats`?`Stopped at ${e.chats.length} chats — a longer phrase narrows it.`:null}function ZV(e){return e?e.replace(/[\\/]+$/,``).split(/[\\/]/).length<=2?e:`…${e.slice(-40)}`:`no folder recorded`}function QV(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function $V(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}var eH=(e,t,n)=>`${e} ${e===1?t:n}`;function tH({open:e,onClose:t,autoOffer:n=!1}){let{state:r,actions:i}=G(),a=r.importProgress,[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(new Set),[g,_]=(0,v.useState)(new Set),[y,b]=(0,v.useState)(null),x=(0,v.useMemo)(()=>f??[],[f]),S=(0,v.useMemo)(()=>WV(x),[x]),C=(0,v.useMemo)(()=>{let e={new:0,imported:0,behind:0,deleted:0,unavailable:0};for(let t of S)for(let n of Object.keys(e))e[n]+=t.counts[n];return e},[S]),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(yV),[O,k]=(0,v.useState)(!1),A=(0,v.useRef)(null),j=w.trim()!==``,M=E.mode===`conversations`,[ee,N]=(0,v.useState)(new Set);(0,v.useEffect)(()=>N(new Set),[w,E]);let P=(0,v.useMemo)(()=>M?PV(w,E):null,[M,w,E]),F=P?JSON.stringify(P):``,[I,te]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!e||!P)return;let t=new AbortController,n=!0,r=setTimeout(()=>{i.searchImportChats(P,t.signal).then(e=>{n&&te({key:F,res:e})})},350);return()=>{n=!1,clearTimeout(r),t.abort()}},[e,F,i]);let ne=I&&I.key===F?I:null,re=(0,v.useMemo)(()=>ne?.res?FV(x,ne.res.chats):null,[ne,x]),L=(0,v.useMemo)(()=>j?M?re?x.filter(e=>re.has(jV(e))):[]:x.filter(NV(w,E)):null,[j,M,x,w,E,re]),ie=(0,v.useMemo)(()=>L?new Set(L):null,[L]),R=(0,v.useMemo)(()=>L?new Set(L.map(e=>e.id)):null,[L]),ae=L??x,oe=(0,v.useMemo)(()=>j?{query:w,options:E,litNames:!M}:null,[j,w,E,M]),se=(0,v.useMemo)(()=>x.filter(e=>e.alreadyImported&&m.has(e.id)),[x,m]),ce=(0,v.useMemo)(()=>qV(m,R),[m,R]),le=S.length===1?S[0].name:`coding-agent`;(0,v.useEffect)(()=>{if(!e)return;d(null),b(null),_(new Set),h(new Set),T(``),te(null),k(!1),s(!0);let t=n;i.scanClaudeSessions().then(e=>{p(e.sessions),h(VV(e.sessions,t))}).catch(e=>d(e instanceof Error?e.message:String(e))).finally(()=>s(!1))},[e]);let ue=(0,v.useCallback)(e=>h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),de=r.prefs.claudeImportOffered,fe=(0,v.useCallback)(()=>{de||i.savePrefs({claudeImportOffered:!0}),t()},[de,i,t]),pe=async()=>{l(!0),d(null);try{let e=await i.importClaudeSessions([...m],se.length>0);b({imported:e.imported.length,replaced:e.replaced?.length??0,entries:e.imported.reduce((e,t)=>e+t.entries,0)+(e.replaced??[]).reduce((e,t)=>e+t.entries,0),failed:e.failed.length,filed:e.filed?.length??0,projectsMade:(e.projects??[]).filter(e=>e.created).map(e=>e.name),warnings:e.warnings??[]}),r.prefs.claudeImportOffered||i.savePrefs({claudeImportOffered:!0}),await i.refreshSessions()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},me=C.imported+C.behind;return(0,W.jsx)(Ky,{open:e,title:`Import your ${le} chats`,onClose:fe,wide:!0,footer:(0,W.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 text-[11px] text-fg-faint`,children:[!y&&ce.notShown>0?(0,W.jsxs)(`span`,{className:`block text-fg-muted`,"data-testid":`import-claude-ticked-hidden`,children:[ce.total,` ticked · `,ce.notShown,` not shown by the search`]}):null,se.length>0?(0,W.jsxs)(`span`,{className:`block text-warn`,children:[se.length,` already-imported `,se.length===1?`chat`:`chats`,` `,`will be REPLACED — the OonaCode copy is rebuilt from the original, and anything added here is lost.`]}):(0,W.jsx)(`span`,{className:`block`,children:`Your other apps stay exactly as they are — this copies, it never moves or deletes.`})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,W.jsx)(J,{onClick:fe,"data-testid":`import-claude-close`,children:y?`Done`:`Not now`}),y?null:(0,W.jsxs)(J,{variant:`primary`,busy:c,disabled:ce.total===0,onClick:()=>void pe(),"data-testid":`import-claude-run`,children:[`Import `,eH(ce.total,`chat`,`chats`)]})]})]}),children:(0,W.jsxs)(`div`,{className:`space-y-3`,"data-testid":`import-claude-body`,children:[o?(0,W.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`Looking for chats on this PC…`}):null,a&&!y?(0,W.jsxs)(`div`,{className:`space-y-2`,"data-testid":`import-claude-progress`,children:[(0,W.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,W.jsxs)(`span`,{children:[`Importing `,(0,W.jsx)(`strong`,{children:a.done}),` of `,(0,W.jsx)(`strong`,{children:a.total}),`…`]}),(0,W.jsxs)(`span`,{className:`text-[11px] text-fg-faint`,children:[Math.round(a.done/Math.max(a.total,1)*100),`%`]})]}),(0,W.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded bg-surface-2`,children:(0,W.jsx)(`div`,{className:`h-full bg-accent transition-[width] duration-200`,style:{width:`${Math.round(a.done/Math.max(a.total,1)*100)}%`}})}),a.current?(0,W.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,title:a.current,children:[`reading: `,a.current]}):null,(0,W.jsxs)(`div`,{className:`flex gap-3 text-[11px] text-fg-faint`,children:[(0,W.jsxs)(`span`,{children:[a.imported,` imported`]}),a.skipped>0?(0,W.jsxs)(`span`,{children:[a.skipped,` already in`]}):null,a.failed>0?(0,W.jsxs)(`span`,{className:`text-warn`,children:[a.failed,` could not be read`]}):null]}),(0,W.jsx)(`p`,{className:`text-[11px] text-fg-faint`,children:`A big chat takes a moment — the largest here are over 100 MB. Your Claude Code is only being read.`})]}):null,u?(0,W.jsx)(`div`,{className:`rounded border border-danger/40 bg-danger/10 p-2 text-sm text-danger`,children:u}):null,y?(0,W.jsxs)(`div`,{className:`text-sm`,"data-testid":`import-claude-done`,children:[(0,W.jsxs)(`p`,{children:[`Imported `,(0,W.jsx)(`strong`,{children:y.imported}),` `,y.imported===1?`chat`:`chats`,y.replaced>0?(0,W.jsxs)(W.Fragment,{children:[` and rebuilt `,(0,W.jsx)(`strong`,{children:y.replaced}),` that `,y.replaced===1?`was`:`were`,` already here`]}):null,` `,`(`,y.entries.toLocaleString(),` entries). They are in your sessions list now, and you can carry on typing in them.`]}),y.projectsMade.length>0?(0,W.jsxs)(`p`,{className:`mt-1`,"data-testid":`import-claude-projects-made`,children:[y.projectsMade.length===1?`Created the project `:`Created the projects `,y.projectsMade.map((e,t)=>(0,W.jsxs)(`span`,{children:[t>0?`, `:``,(0,W.jsx)(`strong`,{children:e})]},e)),` `,`and filed `,y.projectsMade.length===1?`its`:`their`,` chats under`,` `,y.projectsMade.length===1?`it`:`them`,`.`]}):null,y.filed>0?(0,W.jsxs)(`p`,{className:`mt-1 text-fg-muted`,"data-testid":`import-claude-filed`,children:[y.filed,` `,y.filed===1?`chat that was`:`chats that were`,` already here`,` `,y.filed===1?`is`:`are`,` now filed under`,` `,y.filed===1?`its`:`their`,` project.`]}):null,y.failed>0?(0,W.jsxs)(`p`,{className:`mt-1 text-warn`,children:[y.failed,` could not be read and were left alone.`]}):null,y.warnings.map(e=>(0,W.jsx)(`p`,{className:`mt-1 text-warn`,children:e},e))]}):null,!o&&!y&&!a&&f!==null&&f.length>0?(0,W.jsxs)(`div`,{className:`space-y-0.5 text-sm`,"data-testid":`import-claude-tally`,children:[(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{children:f.length}),` `,f.length===1?`chat`:`chats`,` on this PC`,S.length>0?` — `:``,S.map((e,t)=>(0,W.jsxs)(`span`,{children:[t>0?`, `:``,(0,W.jsx)(`strong`,{children:e.rows.length}),` `,e.name]},e.key))]}),(0,W.jsxs)(`p`,{className:`text-fg-muted`,children:[(0,W.jsx)(`strong`,{className:`text-fg`,children:C.new}),` new`,me>0?` · ${me} already imported`:``,C.behind>0?` (${C.behind} behind their original)`:``,C.deleted>0?` · ${C.deleted} you deleted in OonaCode`:``]})]}):null,!o&&!y&&!a&&f!==null&&C.new===0&&!j?(0,W.jsx)(`div`,{className:`text-sm text-fg-muted`,"data-testid":`import-claude-empty`,children:f.length===0?`No chats from a coding agent were found on this PC.`:`Nothing new to import. Every chat is listed below — tick one to import it again.`}):null,!y&&!a&&x.length>0?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Every chat the coding agents on this PC have, newest first. Importing copies them into OonaCode so you can read them here — and continue them, in the folder each one ran in.`,n&&C.new>0?` The new ones are ticked.`:` Tick the ones you want.`]}),(0,W.jsxs)(`div`,{className:`relative`,"data-testid":`import-search`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsxs)(`div`,{className:`relative flex-1`,children:[(0,W.jsx)(q.Search,{className:`pointer-events-none absolute left-2 top-2 w-3.5 h-3.5 text-fg-faint`}),(0,W.jsx)(`input`,{ref:A,"aria-label":`Search the chats to import`,className:U(X,`pl-7`),placeholder:M?`Search inside every conversation`:`Search by name, message or folder`,value:w,onChange:e=>T(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(w!==``||O)&&(e.preventDefault(),e.stopPropagation(),O?k(!1):T(``))},"data-testid":`import-search-input`})]}),(0,W.jsxs)(Y,{label:O?`Hide search options`:`Search options`,className:U(`relative`,O&&`text-accent`),"aria-pressed":O,onMouseDown:e=>e.preventDefault(),onClick:()=>k(e=>!e),"data-testid":`import-search-options-toggle`,children:[(0,W.jsx)(q.Sliders,{}),xV(E)?(0,W.jsx)(`span`,{className:`absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-accent`,"data-testid":`import-search-options-dot`}):null]}),j?(0,W.jsx)(Y,{label:`Clear search`,onMouseDown:e=>e.preventDefault(),onClick:()=>{T(``),A.current?.focus()},"data-testid":`import-search-clear`,children:(0,W.jsx)(q.X,{})}):null]}),O?(0,W.jsx)(OV,{options:E,onChange:D,words:JV,onClose:()=>{k(!1),A.current?.focus()}}):null]}),j?(0,W.jsx)(lH,{query:w,conversations:M,request:P!==null,answer:ne,matches:L?.length??0,messages:[...re?.values()??[]].reduce((e,t)=>e+t.hits,0),capped:[...re?.values()??[]].some(e=>e.hitsCapped)}):null,(0,W.jsx)(`div`,{className:`max-h-96 space-y-3 overflow-y-auto`,"data-testid":`import-claude-list`,children:S.map(e=>{let t=ie?e.rows.filter(e=>ie.has(e)):e.rows;if(t.length===0)return null;let n=ie?!ee.has(e.key):!g.has(e.key),r=ie?N:_;return(0,W.jsxs)(`div`,{className:`rounded border border-border`,"data-testid":`import-group-${e.key}`,children:[(0,W.jsx)(iH,{section:e,rows:t,searching:ie!==null,open:n,chosen:m,onFold:()=>r(t=>nH(t,e.key)),onTicks:h}),n?t.map(e=>(0,W.jsx)(oH,{row:e,checked:m.has(e.id),onToggle:ue,phrase:oe,hit:re?.get(jV(e))},jV(e))):null]},e.key)})}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-fg-faint`,children:[(0,W.jsx)(`button`,{type:`button`,className:`underline`,title:YV,onClick:()=>h(e=>{let t=new Set(e);for(let e of ae)zV(e)&&t.add(e.id);return t}),"data-testid":`import-claude-select-all`,children:L===null?`Select all`:`Select all matches`}),(0,W.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>h(e=>{if(L===null)return new Set;let t=new Set(e);for(let e of ae)t.delete(e.id);return t}),"data-testid":`import-claude-select-none`,children:L===null?`Select none`:`Unselect matches`})]})]}):null]})})}function nH(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function rH({state:e,disabled:t,onToggle:n,label:r,title:i,testId:a}){let o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{o.current&&(o.current.indeterminate=e===`some`)}),(0,W.jsx)(`input`,{ref:o,type:`checkbox`,className:`shrink-0`,checked:e===`all`,disabled:t,onChange:n,"aria-label":r,title:i,"data-state":e,"data-testid":a})}function iH({section:e,rows:t,searching:n,open:r,chosen:i,onFold:a,onTicks:o}){let s=GV(t,i),c=t.filter(zV).length,l=e.rows.filter(e=>i.has(e.id)).length,u=e.counts,d=u.imported+u.behind===e.rows.length,f=n?`the ${e.name} matches`:`${e.name}`,p=s===`all`?`Untick every chat in ${f}`:c===0&&s===`none`?`Nothing new here — tick a chat on its own row to import it again.`:c===0?`Untick every chat in ${f}`:YV;return(0,W.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-surface-2 px-2 py-1.5`,children:[(0,W.jsx)(rH,{state:s,disabled:c===0&&s===`none`,onToggle:()=>o(e=>KV(t,e)),label:s===`all`?`Untick every chat in ${f}`:`Tick the chats in ${f}`,title:p,testId:`import-group-check-${e.key}`}),(0,W.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left text-xs font-medium`,onClick:a,"aria-expanded":r,title:r?`Fold ${e.name}`:`Open ${e.name}`,"data-testid":`import-group-header-${e.key}`,children:[(0,W.jsx)(q.Chevron,{open:r,className:`w-3 h-3 shrink-0`}),e.name,(0,W.jsxs)(`span`,{className:`truncate font-normal text-fg-faint`,children:[eH(e.rows.length,`chat`,`chats`),n?` · ${eH(t.length,`match`,`matches`)}`:``,u.new>0?` · ${u.new} new`:d?` · all imported`:``,u.behind>0?` · ${u.behind} behind`:``,u.deleted>0?` · ${u.deleted} you deleted`:``,l>0?` · ${l} ticked`:``]})]})]})}function aH({row:e,status:t}){let n=IV[t],r={"data-testid":`import-status-${e.id}`,"data-status":t};switch(t){case`new`:return(0,W.jsx)(`span`,{className:`font-medium text-accent`,...r,children:n});case`imported`:case`behind`:return(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-fg-muted`,title:t===`behind`?`The original has newer messages than the OonaCode copy — importing again brings them in (and replaces the copy).`:`Already in OonaCode. Ticking it rebuilds the OonaCode copy from the original, which replaces it.`,...r,children:[(0,W.jsx)(q.Check,{className:`w-3 h-3 text-ok`}),n,t===`behind`?(0,W.jsxs)(`span`,{className:`ml-0.5 inline-flex shrink-0 items-center gap-0.5 rounded bg-warn-soft px-1 text-[10px] font-medium leading-4 text-warn`,"data-testid":`import-behind-${e.id}`,"aria-label":`behind its original`,children:[(0,W.jsx)(q.ArrowDown,{className:`w-2.5 h-2.5`}),`behind`]}):null]});case`deleted`:return(0,W.jsx)(`span`,{className:`text-fg-faint`,title:`You imported this chat and deleted it in OonaCode; its original is still on this PC. Tick it to bring it back.`,...r,children:n});case`unavailable`:return(0,W.jsx)(`span`,{className:`text-warn`,...r,children:n})}}var oH=(0,v.memo)(function({row:e,checked:t,onToggle:n,phrase:r,hit:i}){let a=RV(e),o=e=>r?.litNames?bV(e,r.query,r.options).map((e,t)=>e.hit?(0,W.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,W.jsx)(`span`,{children:e.text},t)):e;return(0,W.jsxs)(`label`,{className:`flex items-start gap-2 border-b border-border p-2 last:border-b-0 ${a?`cursor-default opacity-60`:`cursor-pointer hover:bg-surface-2`}`,"data-testid":`import-row-${e.id}`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:t,disabled:a,onChange:()=>n(e.id),"aria-label":e.title??e.firstPrompt??e.id}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block truncate text-sm`,children:e.title||e.firstPrompt?o(e.title||e.firstPrompt||``):(0,W.jsx)(`span`,{className:`text-fg-faint`,children:`(no prompt)`})}),(0,W.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-fg-faint`,children:[e.projectName?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,W.jsx)(q.Project,{className:`w-3 h-3`}),o(e.projectName)]}):(0,W.jsxs)(W.Fragment,{children:[e.cwd?(0,W.jsx)(`span`,{title:e.cwd,children:o(ZV(e.cwd))}):ZV(e.cwd),e.cwd&&!e.cwdExists?` · folder is gone`:``]}),` `,`· `,e.entryCount,` entries`,e.bytes>0?` · ${QV(e.bytes)}`:``,e.model?` · ${e.model}`:``]}),e.unavailable||e.note?(0,W.jsx)(`span`,{className:`mt-0.5 block text-[11px] ${e.unavailable?`text-warn`:`text-fg-faint`}`,"data-testid":`import-row-note-${e.id}`,children:e.unavailable??e.note}):null,i&&r?(0,W.jsx)(cH,{hit:i,query:r.query,options:r.options,testId:`import-row-hits-${e.id}`}):null]}),e.supersedes&&e.supersedes.length>0?(0,W.jsx)(`span`,{className:`mt-0.5 shrink-0 rounded bg-surface-2 px-1 text-[11px] text-fg-faint`,title:`Rewound — replaces ${e.supersedes.length} earlier ${e.supersedes.length===1?`branch`:`branches`} of this chat`,children:`rewound`}):null,(0,W.jsxs)(`span`,{className:`mt-0.5 flex shrink-0 flex-col items-end gap-0.5 text-right text-[11px]`,children:[(0,W.jsx)(`span`,{className:`whitespace-nowrap text-fg-faint`,children:$V(e.lastEntryAt??e.updatedAt)}),(0,W.jsx)(`span`,{className:`whitespace-nowrap`,children:(0,W.jsx)(aH,{row:e,status:LV(e)})})]})]})});function sH(e){let t=e.kind===`tool`?e.tool??`Tool`:e.role===`assistant`?`Model`:`You`;return e.subagent?`${t} (subagent)`:t}function cH({hit:e,query:t,options:n,testId:r}){return(0,W.jsxs)(`span`,{className:`mt-1 block space-y-0.5`,"data-testid":r,children:[(0,W.jsxs)(`span`,{className:`block text-[11px] font-medium text-fg-muted`,children:[e.hits,e.hitsCapped?`+`:``,` `,e.hits===1&&!e.hitsCapped?`message says`:`messages say`,` it`]}),e.snippets.map((e,r)=>(0,W.jsxs)(`span`,{className:`block line-clamp-2 text-[11px] text-fg-muted`,"data-testid":`import-row-snippet`,children:[(0,W.jsxs)(`span`,{className:`font-medium text-fg-faint`,children:[sH(e),`:`]}),` `,bV(e.snippet,t,n).map((e,t)=>e.hit?(0,W.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,W.jsx)(`span`,{children:e.text},t))]},r))]})}function lH({query:e,conversations:t,request:n,answer:r,matches:i,messages:a,capped:o}){let s=(e,t,n=`text-fg-muted`)=>(0,W.jsx)(`p`,{className:`text-[11px] ${n}`,"data-testid":t,children:e});if(!t)return i===0?s(`No chat’s name, message or folder says “${e.trim()}”. Whole conversations, in the search options, looks inside them.`,`import-search-none`):s(`${i} ${i===1?`chat matches`:`chats match`}`,`import-search-count`);if(!n)return s(e.trim().length<2?`Type at least two characters to search inside the conversations.`:`Tick what to look in — your messages, the model’s replies or the tools’ side.`,`import-search-idle`);if(!r)return s(`Searching every conversation on this PC…`,`import-search-busy`);if(r.res===null)return s(`This PC could not search its conversations. Try again, or update OonaCode.`,`import-search-failed`,`text-danger`);let c=r.res,l=XV(c),u=c.sources.filter(e=>e.note).map(e=>`${e.agentName}: ${e.note}`);return(0,W.jsxs)(`div`,{className:`space-y-0.5`,children:[i===0?s(c.partial===`aborted`?`The search was stopped.`:`No conversation on this PC says that.`,`import-search-none`):s(`${i} ${i===1?`chat says`:`chats say`} it · ${a}${o?`+`:``} ${a===1&&!o?`message`:`messages`}`,`import-search-count`),l?s(l,`import-search-partial`,`text-warn`):null,u.map(e=>(0,W.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`import-search-source-note`,children:e},e))]})}var uH={model:null,previousModel:null,costUsd:0,inputTokens:0,outputTokens:0,turns:0,durationMs:0,contextTokens:null,contextWindow:null,contextUsed:null,costSource:`engine`,credits:null,resetAtIndex:null,didReset:!1,countedResults:0};function dH(e,t){let n=t?zs(t):null,r=null,i=null;for(let t=0;t<e.length;t++){let a=e[t];if(!a||a.kind!==`assistant`||!L(a.model))continue;let o=zs(a.model);n!==null&&o!==n&&(r=t,i=n),n=o}return{index:r,from:i,to:n}}function fH(e){let{items:t,session:n=null,initModel:r=null,boundary:i=null,models:a}=e,o=e.contextTokens!=null&&e.contextTokens>0?e.contextTokens:null;if(t.length===0&&!n)return uH;let s=dH(t,r),c=i&&i.index>=0?Math.min(i.index,t.length):null,l=null,u=null;s.index!==null&&(c===null||s.index>=c)?(l=s.index,u=s.from):c!==null&&(l=c,u=i?.from??s.from);let d=l??0,f=0,p=0,m=0,h=0,g=0,_=0;for(let e=d;e<t.length;e++){let n=t[e];!n||n.kind!==`result`||(_+=1,f+=n.costUsd,p+=n.inputTokens,m+=n.outputTokens,h+=n.numTurns,g+=n.durationMs)}_===0&&l===null&&n&&(f=n.totalCostUsd,p=n.inputTokens,m=n.outputTokens);let v=`engine`,y=null;n&&n.providerId===`oonacode`&&(f=n.totalCostUsd,y=n.poolCredits??null,v=`gateway`);let b=r?zs(r):null,x=i&&c!==null&&l===c?i.to:s.to??n?.model??b??null,S=[x,n?.model??null,b].filter(e=>typeof e==`string`&&e.length>0),C=(a?S.map(e=>a.find(t=>t.id===e)).find(e=>e?.contextWindow!=null):void 0)?.contextWindow??null;return{model:x,previousModel:u,costUsd:f,inputTokens:p,outputTokens:m,turns:h,durationMs:g,contextTokens:o,contextWindow:C,contextUsed:C&&C>0&&o!==null?Math.min(1,o/C):null,resetAtIndex:l,didReset:l!==null,countedResults:_,costSource:v,credits:y}}var pH=[...yu.what,...yu.when,...yu.who,...yu.yours,...yu.where];function mH({sessionId:e,entryCount:t}){let{state:n,actions:r}=G(),i=n.chatAboutsChange,a=Xl(n.settings??{}),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(null),C=(0,v.useRef)(i.seq),w=(0,v.useRef)(!0);(0,v.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let T=(0,v.useCallback)(async()=>{let t=await r.getChatAbout(e);if(w.current){if(t===`unsupported`){l(!0);return}t!==null&&(l(!1),s(t))}},[r,e]);if((0,v.useEffect)(()=>{T()},[T]),(0,v.useEffect)(()=>{i.seq!==C.current&&(C.current=i.seq,cu(i,e)&&T())},[i,e,T]),c||o===null)return null;let E=()=>{p(o.about??``),d(!0),S(null),b(null)},D=async()=>{if(_u(f))return;let t=f.trim()===``;h(!0);try{let n=await r.updateChatAbout(e,t?null:f);if(!w.current||!n)return;s(n),d(!1),S(t?a.enabled?`Cleared. The housekeeper writes a new about at the chat’s next change.`:`Cleared. None is written while chat abouts are off.`:null)}finally{w.current&&h(!1)}},O=async()=>{_(!0),b(null),S(null);try{let t=await r.regenerateChatAbout(e);if(!w.current)return;t.about&&s(t.about),t.ok||b(t.error??`The about could not be written.`)}finally{w.current&&_(!1)}},k=vu(f,a.maxWords),A=_u(f),j=lu(o);return(0,W.jsxs)(`div`,{className:`mb-2`,"data-testid":`session-about`,children:[(0,W.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:(0,W.jsx)(q.Info,{className:`w-3.5 h-3.5`})}),`About`,(0,W.jsx)(Hy,{label:`About`,details:(0,W.jsx)(Uy,{items:pH})}),o.stale&&o.about?(0,W.jsx)(`span`,{title:yu.stale,"data-testid":`session-about-stale`,children:(0,W.jsx)(Z,{tone:`warn`,children:`stale`})}):null]}),u?(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsx)(`textarea`,{className:U(X,`min-h-[7rem] resize-y text-xs`),value:f,onChange:e=>p(e.target.value),"aria-label":`This chat’s about`,placeholder:`What this chat works on, for your other chats to read`,autoFocus:!0,"data-testid":`session-about-input`}),(0,W.jsxs)(`div`,{className:U(`text-[11px]`,k.overChars?`text-danger`:k.overWords?`text-warn`:`text-fg-faint`),"data-testid":`session-about-count`,children:[k.words,` / `,a.maxWords,` words · `,k.chars.toLocaleString(`en-US`),` /`,` `,Jl.userChars.toLocaleString(`en-US`),` characters`]}),A?(0,W.jsx)(`div`,{className:`text-[11px] text-danger`,"data-testid":`session-about-problem`,children:A}):k.overWords?(0,W.jsxs)(`div`,{className:`text-[11px] text-warn`,children:[`Longer than the `,a.maxWords,` words the housekeeper writes; your other chats read all of it.`]}):null,(0,W.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:`Saved empty, it is cleared, and the housekeeper writes one again at the chat’s next change.`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(J,{size:`sm`,variant:`primary`,onClick:()=>void D(),busy:m,disabled:A!==null,"data-testid":`session-about-save`,children:`Save`}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>d(!1),disabled:m,"data-testid":`session-about-cancel`,children:`Cancel`})]})]}):(0,W.jsxs)(W.Fragment,{children:[o.about?(0,W.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-xs text-fg`,"data-testid":`session-about-text`,children:o.about}):(0,W.jsxs)(`p`,{className:`text-[11px] text-fg-muted`,"data-testid":`session-about-missing`,children:[`No about yet. `,hu(o,{enabled:a.enabled,entryCount:t})]}),o.about&&o.aboutAt?(0,W.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,title:sg(o.aboutAt),"data-testid":`session-about-written`,children:[`Written `,ag(o.aboutAt),j?` by ${j}`:``]}):null,o.about&&o.pending?(0,W.jsx)(`div`,{className:`text-[11px] text-accent`,children:`Being written again now…`}):null,o.about&&o.lastError?(0,W.jsxs)(`div`,{className:`text-[11px] text-danger`,"data-testid":`session-about-last-error`,children:[`The last attempt failed: `,o.lastError]}):null,(0,W.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,title:o.route?`Paid by ${uu[o.route]}`:void 0,"data-testid":`session-about-spend`,children:[`Cost so far: `,pu(o.spend,o.route)]}),x?(0,W.jsx)(`div`,{className:`mt-0.5 text-[11px] text-fg-muted`,"data-testid":`session-about-note`,children:x}):null,y?(0,W.jsx)(`div`,{className:`mt-0.5 text-[11px] text-danger`,role:`alert`,"data-testid":`session-about-regen-error`,children:y}):null,(0,W.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[(0,W.jsxs)(J,{size:`sm`,variant:`ghost`,onClick:E,disabled:g,title:yu.edit,"data-testid":`session-about-edit`,children:[(0,W.jsx)(q.Edit,{className:`h-3 w-3`}),` Edit`]}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>void O(),disabled:!a.enabled||g,title:a.enabled?yu.regenerate:yu.regenerateOff,"data-testid":`session-about-regenerate`,children:g?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q.Spinner,{className:`h-3 w-3`}),` Writing…`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q.Refresh,{className:`h-3 w-3`}),` Regenerate`]})})]}),a.enabled?null:(0,W.jsx)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,"data-testid":`session-about-off`,children:`Regenerate is unavailable: chat abouts are off.`})]})]})}function hH({view:e}){let t=(0,v.useMemo)(()=>VB(e.request??``),[e.request]);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:e.truncated?`Cut at the size the host keeps.`:`As agy sent it.`}),(0,W.jsx)(ZM,{text:t})]}),(0,W.jsx)(`pre`,{className:`mt-0.5 max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-md border border-border bg-code-bg p-2 font-mono text-[11px] leading-snug text-fg`,"data-testid":`agy-request-json`,children:t})]})}function gH({sessionId:e,running:t}){let{api:n}=G(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)({}),h=(0,v.useRef)(!0);(0,v.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let g=(0,v.useCallback)(async()=>{if(!n.listAgyRequests){o(!0);return}c(!0);try{let t=await n.listAgyRequests(e);if(!h.current)return;o(!1),i(t.requests)}catch(e){if(!h.current)return;ym(e)&&o(!0)}finally{h.current&&c(!1)}},[n,e]);(0,v.useEffect)(()=>{g()},[g]);let _=(0,v.useRef)(t);(0,v.useEffect)(()=>{_.current&&!t&&g(),_.current=t},[t,g]);let{main:y,background:b}=(0,v.useMemo)(()=>PB(r??[]),[r]),x=async t=>{if(p[t.id]){m(e=>{let{[t.id]:n,...r}=e;return r});return}m(e=>({...e,[t.id]:{phase:`loading`}}));let r=e=>{h.current&&m(n=>n[t.id]?{...n,[t.id]:e}:n)};if(!n.getAgyRequestBody)return r({phase:`gone`});try{let i=await n.getAgyRequestBody(e,t.id);r(i.request===null?{phase:`gone`}:{phase:`ready`,view:i})}catch(e){r(ym(e)?{phase:`gone`}:{phase:`failed`,message:mg(e)})}};if(a||r===null)return null;let S=e=>{let{title:t,detail:n}=FB(e),r=LB(e),i=zB(e.usage),a=p[e.id],o=[n,e.ms===null?`running…`:rg(e.ms),i].filter(e=>!!e),s=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{className:`flex items-baseline gap-1.5`,children:[(0,W.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-fg-faint`,title:sg(e.at),children:BB(e.at)}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-fg`,children:t}),(0,W.jsx)(`span`,{className:U(`shrink-0 text-[11px] font-medium`,r.tone===`danger`?`text-danger`:`text-fg-muted`),"data-tone":r.tone,"data-testid":`agy-request-status-${e.id}`,children:r.text})]}),(0,W.jsx)(`span`,{className:`block break-words text-[11px] text-fg-faint`,children:o.join(` · `)}),e.error?(0,W.jsx)(`span`,{className:`block break-words text-[11px] text-danger`,children:e.error}):null]});return(0,W.jsxs)(`li`,{className:`rounded-md border border-border px-2 py-1`,"data-testid":`agy-request-${e.id}`,"data-kind":e.kind,children:[e.hasBody?(0,W.jsx)(`button`,{type:`button`,className:`block w-full text-left`,"aria-expanded":a!==void 0,title:`${IB(e)} — show the request`,onClick:()=>void x(e),"data-testid":`agy-request-open-${e.id}`,children:s}):(0,W.jsx)(`div`,{title:IB(e),children:s}),a?(0,W.jsx)(`div`,{className:`mt-1`,"data-testid":`agy-request-body-${e.id}`,children:a.phase===`loading`?(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-fg-muted`,children:[(0,W.jsx)(q.Spinner,{className:`h-3 w-3`}),` Loading the request…`]}):a.phase===`gone`?(0,W.jsx)(`div`,{className:`text-[11px] text-fg-muted`,"data-testid":`agy-request-body-gone`,children:`This request’s body is no longer kept on this PC.`}):a.phase===`failed`?(0,W.jsxs)(`div`,{className:`text-[11px] text-danger`,role:`alert`,children:[`Could not read it: `,a.message]}):(0,W.jsx)(hH,{view:a.view})}):null]},e.id)};return(0,W.jsxs)(`div`,{className:`mb-2`,"data-testid":`agy-requests`,children:[(0,W.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left text-[11px] font-semibold uppercase tracking-wide text-fg-faint hover:text-fg-muted`,"aria-expanded":l,onClick:()=>u(e=>!e),"data-testid":`agy-requests-toggle`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:(0,W.jsx)(q.Chevron,{className:`h-3 w-3`,open:l})}),`Google agy requests`,(0,W.jsx)(`span`,{className:`font-mono normal-case tracking-normal`,"data-testid":`agy-requests-count`,children:r.length})]}),(0,W.jsx)(Y,{label:`Refresh agy requests`,className:`p-1`,disabled:s,onClick:()=>void g(),"data-testid":`agy-requests-refresh`,children:s?(0,W.jsx)(q.Spinner,{className:`h-3 w-3`}):(0,W.jsx)(q.Refresh,{className:`h-3 w-3`})})]}),(0,W.jsx)(`p`,{className:`mb-1 text-[11px] leading-snug text-fg-faint`,"data-testid":`agy-requests-privacy`,children:jB}),l?(0,W.jsxs)(W.Fragment,{children:[y.length===0?(0,W.jsx)(`p`,{className:`text-[11px] text-fg-muted`,"data-testid":`agy-requests-empty`,children:`No model calls yet — they appear here as agy talks to Google.`}):(0,W.jsx)(`ul`,{className:`max-h-72 space-y-1 overflow-y-auto`,"data-testid":`agy-requests-main`,children:y.map(S)}),b.length>0?(0,W.jsxs)(`div`,{className:`mt-1.5`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-[11px] text-accent hover:underline`,"aria-expanded":d,onClick:()=>f(e=>!e),"data-testid":`agy-background-toggle`,children:[(0,W.jsx)(q.Chevron,{className:`h-3 w-3`,open:d}),`background calls (`,b.length,`)`]}),d?(0,W.jsx)(`ul`,{className:`mt-1 max-h-72 space-y-1 overflow-y-auto opacity-70`,"data-testid":`agy-requests-background`,children:b.map(S)}):null]}):null]}):null]})}function _H({label:e,icon:t,children:n}){return(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1`,children:[(0,W.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-faint`,children:[t?(0,W.jsx)(`span`,{className:`shrink-0 text-fg-faint`,"aria-hidden":`true`,children:t}):null,e]}),(0,W.jsx)(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-fg`,children:n})]})}function vH({label:e,icon:t}){return(0,W.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:t}),e]})}var yH={provider:(0,W.jsx)(q.Plug,{className:`w-3.5 h-3.5`}),route:(0,W.jsx)(q.Globe,{className:`w-3.5 h-3.5`}),model:(0,W.jsx)(q.Bot,{className:`w-3.5 h-3.5`}),permission:(0,W.jsx)(q.Shield,{className:`w-3.5 h-3.5`}),context:(0,W.jsx)(q.Brain,{className:`w-3.5 h-3.5`}),window:(0,W.jsx)(q.Panel,{className:`w-3.5 h-3.5`}),compactions:(0,W.jsx)(q.CollapseAll,{className:`w-3.5 h-3.5`}),usage:(0,W.jsx)(q.Coins,{className:`w-3.5 h-3.5`}),tokensIn:(0,W.jsx)(q.Download,{className:`w-3.5 h-3.5`}),tokensOut:(0,W.jsx)(q.Upload,{className:`w-3.5 h-3.5`}),duration:(0,W.jsx)(q.Clock,{className:`w-3.5 h-3.5`}),turns:(0,W.jsx)(q.Send,{className:`w-3.5 h-3.5`}),session:(0,W.jsx)(q.Info,{className:`w-3.5 h-3.5`}),status:(0,W.jsx)(q.Monitor,{className:`w-3.5 h-3.5`}),updated:(0,W.jsx)(q.Refresh,{className:`w-3.5 h-3.5`}),entries:(0,W.jsx)(q.Menu,{className:`w-3.5 h-3.5`}),project:(0,W.jsx)(q.Project,{className:`w-3.5 h-3.5`}),folder:(0,W.jsx)(q.Folder,{className:`w-3.5 h-3.5`})};function bH({used:e}){let t=Math.round(e*100);return(0,W.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Context used`,children:(0,W.jsx)(`div`,{className:U(`h-full rounded-full`,t>=90?`bg-danger`:t>=70?`bg-warn`:`bg-accent`),style:{width:`${t}%`}})})}function xH(){let{state:e,actions:t}=G(),n=Ay(),r=n?e.remote.tabs[n.id]!==void 0:!1,i=n?e.drafts[n.id]!==void 0:!1,a=ky(),o=e.currentSessionId,s=n?.projectId?e.vaultProjects.find(e=>e.id===n.projectId):void 0,c=s?.instructions.trim()??``,l=n?.providerId??e.activeProviderId,u=e.providers.find(e=>e.definition.id===l),d=u?.definition.models,f=(0,v.useMemo)(()=>{let e=u?.definition;return e?As(e,{credentialClass:(u.credentials.find(e=>e.variantId===n?.variantId)??u.credentials[0])?.class??null}):null},[u,n?.variantId]),p=(0,v.useMemo)(()=>fH({items:a?.items??[],session:n,initModel:a?.init?.model??null,boundary:o?e.modelBoundaries[o]??null:null,models:d,contextTokens:a?.contextTokens??null}),[a?.items,a?.init?.model,a?.contextTokens,n,o,e.modelBoundaries,d]),m=(0,v.useMemo)(()=>(a?.items??[]).filter(e=>e.kind===`user`&&e.compactSummary).length,[a?.items]),h=n?$p(n.providerId)&&!r&&!i:!1,g=a?.status===`running`||a?.status===`waiting_permission`;return(0,W.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-border bg-surface`,"aria-label":`Session info`,"data-testid":`session-panel`,children:[(0,W.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,W.jsx)(q.Info,{className:`w-3.5 h-3.5 text-fg-faint`}),(0,W.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:`Session info`}),(0,W.jsx)(Y,{label:`Hide session info`,className:`p-1`,onClick:()=>void t.savePrefs({sessionPanelOpen:!1}),children:(0,W.jsx)(q.X,{className:`w-3.5 h-3.5`})})]}),n?(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-2`,children:[p.didReset?(0,W.jsxs)(`div`,{className:`mb-2 rounded-md bg-accent-soft px-2 py-1.5 text-[11px] text-accent`,"data-testid":`stats-reset`,children:[`Statistics restarted at the model change`,p.previousModel?` (was ${p.previousModel})`:``,`.`]}):null,!r&&!i?(0,W.jsx)(mH,{sessionId:n.id,entryCount:n.entryCount??null},n.id):null,(0,W.jsxs)(`div`,{className:`mb-2`,children:[(0,W.jsx)(vH,{label:`Model`,icon:yH.model}),(0,W.jsx)(_H,{label:`Provider`,icon:yH.provider,children:u?.definition.displayName??l??`—`}),(0,W.jsx)(_H,{label:`Route`,icon:yH.route,children:f?(0,W.jsx)(Z,{tone:f.viaGateway?`accent`:`ok`,children:f.badge}):`—`}),f?(0,W.jsx)(`div`,{className:`pb-1 text-[11px] leading-snug text-fg-faint`,children:f.detail}):null,(0,W.jsx)(_H,{label:`Model`,icon:yH.model,children:p.model??n.model??`—`}),(0,W.jsxs)(_H,{label:`Permission mode`,icon:yH.permission,children:[(0,W.jsx)(Z,{children:N(I(n))}),` `,(0,W.jsx)(Z,{children:n.permissionMode})]})]}),(0,W.jsxs)(`div`,{className:`mb-2`,children:[(0,W.jsx)(vH,{label:`Context`,icon:yH.context}),p.contextUsed!==null&&p.contextTokens!==null?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(bH,{used:p.contextUsed}),(0,W.jsxs)(`div`,{className:`mt-1 text-[11px] text-fg-muted`,"data-testid":`context-used`,children:[ig(p.contextTokens),` / `,ig(p.contextWindow??0),` `,`tokens (`,Math.round(p.contextUsed*100),`%)`]})]}):(0,W.jsx)(`div`,{className:`text-[11px] text-fg-muted`,"data-testid":`context-used`,children:p.contextTokens===null?`Measured at the next reply`:`${ig(p.contextTokens)} tokens (window unknown)`}),(0,W.jsx)(_H,{label:`Context window`,icon:yH.window,children:(0,W.jsx)(`span`,{"data-testid":`context-window`,children:p.contextWindow?`${ig(p.contextWindow)} tokens`:`unknown`})}),(0,W.jsx)(_H,{label:`Compactions`,icon:yH.compactions,children:(0,W.jsx)(`span`,{"data-testid":`compaction-count`,children:m})})]}),(0,W.jsxs)(`div`,{className:`mb-2`,children:[(0,W.jsx)(vH,{label:`Usage`,icon:yH.usage}),(0,W.jsx)(_H,{label:`Tokens in`,icon:yH.tokensIn,children:ig(p.inputTokens)}),(0,W.jsx)(_H,{label:`Tokens out`,icon:yH.tokensOut,children:ig(p.outputTokens)}),p.credits===null?null:(0,W.jsx)(_H,{label:`Credits used`,icon:yH.usage,children:p.credits.toLocaleString(`en-US`,{maximumFractionDigits:2})}),(0,W.jsx)(_H,{label:`Duration`,icon:yH.duration,children:p.countedResults>0&&rg(p.durationMs)||`—`}),(0,W.jsx)(_H,{label:`Turns`,icon:yH.turns,children:p.countedResults>0?p.turns:`—`})]}),(0,W.jsxs)(`div`,{className:`mb-2`,children:[(0,W.jsx)(vH,{label:`Session`,icon:yH.session}),(0,W.jsx)(_H,{label:`Status`,icon:yH.status,children:(0,W.jsx)(Z,{tone:a?.status===`error`?`danger`:a?.status===`running`?`accent`:a?.status===`waiting_permission`?`warn`:`neutral`,children:a?.status??n.status})}),(0,W.jsx)(_H,{label:`Updated`,icon:yH.updated,children:ag(n.updatedAt)}),(0,W.jsx)(_H,{label:`Entries`,icon:yH.entries,children:n.entryCount}),(0,W.jsx)(_H,{label:`Project`,icon:yH.project,children:(0,W.jsx)(`span`,{"data-testid":`session-project`,children:s?s.name:`—`})}),c?(0,W.jsx)(`div`,{className:`whitespace-pre-wrap break-words pb-1 text-[11px] leading-snug text-fg-faint`,"data-testid":`session-project-instructions`,children:c.length>300?`${c.slice(0,300)}\u2026`:c}):null,r?null:(0,W.jsx)(`button`,{type:`button`,className:`text-[11px] text-accent hover:underline`,onClick:()=>t.openAssignProject(n.id),"data-testid":`session-change-project`,children:s?`Move to another project…`:`Move to a project…`}),(0,W.jsx)(_H,{label:`Folder`,icon:yH.folder,children:n.projectDir?`project`:`own workspace`}),(0,W.jsx)(`div`,{className:`mt-1 break-all font-mono text-[10px] text-fg-faint`,"data-testid":`session-folder`,children:n.cwd}),r?null:(0,W.jsx)(`button`,{type:`button`,className:`mt-1 text-[11px] text-accent hover:underline`,onClick:()=>t.openDialog(`project`),"data-testid":`session-change-folder`,children:`Change folder…`})]}),h?(0,W.jsx)(gH,{sessionId:n.id,running:g},n.id):null,r?null:(0,W.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`session-scheduled-tasks`,children:[(0,W.jsx)(vH,{label:`Scheduled tasks`,icon:yH.session}),(0,W.jsx)(WN,{sessionId:n.id})]}),a?.init?(0,W.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[`engine `,a.init.claudeCodeVersion,` · `,a.init.tools.length,` tools`]}):null]}):(0,W.jsx)(`div`,{className:`p-4 text-xs text-fg-faint`,children:`Open a chat to see its statistics.`})]})}function SH(e){let t=e=>e.type===`dir`?0:1;return[...e].sort((e,n)=>t(e)-t(n)||e.name.localeCompare(n.name))}function CH(e){let t=[];return e.target.type===`file`&&t.push({key:`open`,label:`Open`,icon:(0,W.jsx)(q.File,{className:`w-3.5 h-3.5`}),onSelect:e.onOpen,testId:`files-menu-open`}),t.push({key:`copy-path`,label:`Copy path`,icon:(0,W.jsx)(q.Copy,{className:`w-3.5 h-3.5`}),disabled:!e.canCopyPath,onSelect:e.onCopyPath,testId:`files-menu-copy-path`},{key:`copy-relative-path`,label:`Copy relative path`,icon:(0,W.jsx)(q.Copy,{className:`w-3.5 h-3.5`}),onSelect:e.onCopyRelativePath,testId:`files-menu-copy-relative-path`}),!e.remote&&e.canDelete&&t.push({key:`delete`,label:`Delete…`,icon:(0,W.jsx)(q.Trash,{className:`w-3.5 h-3.5`}),danger:!0,separated:!0,onSelect:e.onDelete,testId:`files-menu-delete`}),t}function wH(e,t){return t instanceof hm&&t.status===404&&/^no route for /.test(t.message)?`This host is too old to delete files — update it from the title bar.`:`Could not delete ${pj(e.path)}: ${t instanceof Error?t.message:String(t)}`}function TH(){let{state:e,dispatch:t,actions:n,api:r}=G(),i=Ay(),a=ky(),o=i?.id??null,s=o?e.remote.tabs[o]!==void 0:!1,c=a?.status===`running`||a?.status===`waiting_permission`,l=o?e.files[o]?.active??null:null,u=e.info?.platform??null,d=i?.cwd??``,[f,p]=(0,v.useState)({}),[m,h]=(0,v.useState)(()=>new Set),[g,_]=(0,v.useState)(!1),y=(0,v.useRef)(f);y.current=f;let b=(0,v.useRef)(m);b.current=m;let x=(0,v.useRef)(o);x.current=o;let S=(0,v.useRef)(e.files);S.current=e.files;let[C,w]=(0,v.useState)(null),T=(0,v.useCallback)(()=>w(null),[]),E=(0,v.useCallback)((e,t,n)=>w({target:e,at:t,el:n}),[]),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(!1),j=(0,v.useCallback)(()=>O(null),[]),M=(0,v.useCallback)(async e=>{if(!o||!r.listSessionFiles)return;let t=o;p(t=>({...t,[e]:{...t[e]??{entries:null},loading:!0,error:null}}));try{let n=await r.listSessionFiles(t,e);if(x.current!==t)return;_(!1),p(t=>({...t,[e]:{entries:SH(n.entries),loading:!1,error:null}}))}catch(n){if(x.current!==t)return;ym(n)&&_(!0);let r=n instanceof Error?n.message:String(n);p(t=>({...t,[e]:{entries:t[e]?.entries??null,loading:!1,error:r}}))}},[r,o]);(0,v.useEffect)(()=>{p({}),h(new Set),_(!1),w(null),O(null),o&&!s&&M(``)},[o,s,M]);let ee=(0,v.useRef)(c);(0,v.useEffect)(()=>{if(ee.current&&!c&&o&&!s)for(let e of Object.keys(y.current))(e===``||b.current.has(e))&&M(e);ee.current=c},[c,o,s,M]);let N=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),y.current[e]?.entries||M(e)),n})},P=()=>{if(o){M(``);for(let e of m)M(e)}},F=(e,t)=>{XM(e).then(e=>n.toast(e?`success`:`error`,e?t:`Could not copy to the clipboard`))},I=async()=>{let e=D,i=o;if(!(!e||!i||!r.deleteSessionFile)){A(!0);try{await r.deleteSessionFile(i,e.path);for(let n of S.current[i]?.open??[])gj(n,e.path)&&t({type:`file_close`,sessionId:i,path:n});x.current===i&&(h(t=>new Set([...t].filter(t=>!gj(t,e.path)))),p(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!gj(t,e.path)))),M(hj(e.path))),n.toast(`success`,`Deleted ${pj(e.path)}`)}catch(t){n.toast(`error`,wH(e,t)),x.current===i&&M(hj(e.path))}finally{A(!1),O(null)}}},te=C?CH({target:C.target,remote:s,canDelete:typeof r.deleteSessionFile==`function`,canCopyPath:d!==``,onOpen:()=>n.openFile(C.target.path),onCopyPath:()=>F(yj(d,C.target.path,u),`Path copied`),onCopyRelativePath:()=>F(vj(C.target.path,_j(d,u)),`Relative path copied`),onDelete:()=>O(C.target)}):[],ne=()=>void n.savePrefs({explorerOpen:!1}),re=i?.cwd?pj(i.cwd)||i.cwd:`Files`,L=f[``],ie=C?.target.path??null,R=(0,v.useMemo)(()=>o?s?(0,W.jsx)(DH,{children:`This chat runs on another PC; its files can be browsed there.`}):g?(0,W.jsx)(DH,{children:`This host is too old to list files — update it from the title bar.`}):L?.error&&!L.entries?(0,W.jsx)(DH,{tone:`danger`,children:L.error}):L?.entries?L.entries.length===0?(0,W.jsx)(DH,{children:`The folder is empty.`}):(0,W.jsx)(`ul`,{role:`tree`,"aria-label":`Workspace files`,className:`py-1`,children:(0,W.jsx)(AH,{rel:``,depth:0,tree:f,expanded:m,activeFile:l,menuPath:ie,onToggle:N,onOpen:e=>n.openFile(e),onMenu:E})}):(0,W.jsx)(DH,{children:`Listing…`}):(0,W.jsx)(DH,{children:`Open a chat to browse the folder it works in.`}),[o,s,g,L,f,m,l,ie,n]);return(0,W.jsxs)(`aside`,{className:`flex w-64 shrink-0 flex-col border-r border-border bg-surface`,"aria-label":`Files`,"data-testid":`file-explorer`,children:[(0,W.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,W.jsx)(q.Folder,{className:`w-3.5 h-3.5 text-fg-faint`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-semibold uppercase tracking-wide text-fg-muted`,title:i?.cwd??void 0,children:re}),(0,W.jsx)(Y,{label:`Refresh files`,className:`p-1`,onClick:P,disabled:!o||s,"data-testid":`file-explorer-refresh`,children:(0,W.jsx)(q.Refresh,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(Y,{label:`Hide files`,className:`p-1`,onClick:ne,children:(0,W.jsx)(q.X,{className:`w-3.5 h-3.5`})})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:R}),(0,W.jsx)(nx,{open:C!==null,at:C?.at??{x:0,y:0},anchorEl:C?.el??null,label:`File actions`,testId:`files-context-menu`,onClose:T,items:te}),(0,W.jsx)(EH,{target:D,absolute:D?d?yj(d,D.path,u):D.path:``,platform:u,busy:k,onConfirm:()=>void I(),onClose:j})]})}function EH({target:e,absolute:t,platform:n,busy:r,onConfirm:i,onClose:a}){let o=e?.type===`dir`;return(0,W.jsx)(Ky,{open:e!==null,title:o?`Delete this folder?`:`Delete this file?`,onClose:a,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{onClick:a,disabled:r,"data-testid":`files-delete-cancel`,children:`Cancel`}),(0,W.jsx)(J,{variant:`danger`,busy:r,onClick:i,"data-testid":`files-delete-confirm`,children:`Delete permanently`})]}),children:(0,W.jsxs)(`div`,{className:`space-y-2 text-sm text-fg-muted`,"data-testid":`files-delete-dialog`,children:[(0,W.jsx)(`p`,{className:`break-all rounded bg-surface-2 px-2 py-1 font-mono text-xs text-fg`,children:t}),(0,W.jsxs)(`p`,{children:[o?`This folder and everything inside it will be deleted from the disk permanently.`:`This file will be deleted from the disk permanently.`,` `,`It does not go to the `,n===`win32`?`Recycle Bin`:`Trash`,`, and it cannot be undone.`]})]})})}function DH({children:e,tone:t}){return(0,W.jsx)(`div`,{className:U(`p-4 text-xs`,t===`danger`?`text-danger`:`text-fg-faint`),children:e})}function OH(e){let t=e.getBoundingClientRect();return{x:t.left+24,y:t.bottom}}function kH(e,t){return{onContextMenu:n=>{n.preventDefault();let r=n.currentTarget;t(e,n.clientX===0&&n.clientY===0?OH(r):{x:n.clientX,y:n.clientY},r)},onKeyDown:n=>{(n.key===`ContextMenu`||n.shiftKey&&n.key===`F10`)&&(n.preventDefault(),t(e,OH(n.currentTarget),n.currentTarget))}}}function AH({rel:e,depth:t,tree:n,expanded:r,activeFile:i,menuPath:a,onToggle:o,onOpen:s,onMenu:c}){let l=n[e];return l?l.error&&!l.entries?(0,W.jsx)(`li`,{className:`px-2 py-1 text-[11px] text-danger`,style:{paddingLeft:`${.5+t*.75}rem`},children:l.error}):l.entries?(0,W.jsx)(W.Fragment,{children:l.entries.map(l=>{let u=mj(e,l.name),d=a===u;if(l.type===`dir`){let e=r.has(u);return(0,W.jsxs)(`li`,{role:`treeitem`,"aria-expanded":e,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>o(u),...kH({path:u,type:`dir`},c),"data-testid":`explorer-dir-${u}`,className:U(`flex w-full items-center gap-1 py-0.5 pr-2 text-left text-xs text-fg hover:bg-surface-2`,d&&`bg-surface-2`),style:{paddingLeft:`${.5+t*.75}rem`},children:[(0,W.jsx)(q.ChevronRight,{className:U(`w-3 h-3 shrink-0 text-fg-faint transition-transform`,e&&`rotate-90`)}),(0,W.jsx)(q.Folder,{className:`w-3.5 h-3.5 shrink-0 text-fg-faint`}),(0,W.jsx)(`span`,{className:`truncate`,children:l.name})]}),e?(0,W.jsx)(`ul`,{role:`group`,children:(0,W.jsx)(AH,{rel:u,depth:t+1,tree:n,expanded:r,activeFile:i,menuPath:a,onToggle:o,onOpen:s,onMenu:c})}):null]},u)}let f=i===u;return(0,W.jsx)(`li`,{role:`treeitem`,"aria-selected":f,children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>s(u),...kH({path:u,type:l.type},c),disabled:l.type!==`file`,"data-testid":`explorer-file-${u}`,title:`${u} · ${Rj(l.size)}`,className:U(`flex w-full items-center gap-1 py-0.5 pr-2 text-left text-xs hover:bg-surface-2 disabled:opacity-50`,f?`bg-accent-soft text-accent`:d?`bg-surface-2 text-fg`:`text-fg`),style:{paddingLeft:`${.5+t*.75+.9}rem`},children:[(0,W.jsx)(q.File,{className:`w-3.5 h-3.5 shrink-0 text-fg-faint`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:l.name}),(0,W.jsx)(`span`,{className:`shrink-0 text-[10px] text-fg-faint`,children:Rj(l.size)})]})},u)})}):(0,W.jsx)(`li`,{className:`px-2 py-1 text-[11px] text-fg-faint`,style:{paddingLeft:`${.5+t*.75}rem`},children:`Listing…`}):null}var jH={autoAccept:{hint:`Allow every tool the agent wants to use, without asking you. Off by default.`,details:[`Answered by this PC itself, so it covers EVERY chat running here — started in this app, the oona terminal, your phone, Telegram, the website or another PC.`,`The agent’s questions to you (its multiple-choice cards) still wait for your answer.`,`A chat set to Ask first in the composer still asks you before each tool — that is what Ask first means.`,`Subagents never ask: their tool requests are always allowed.`,`Takes effect at the next tool request, even in a chat that is already working.`,`What a chat may attempt at all is still its own Build / Plan / Ask first / Autonomous choice in the composer; this only answers the prompts it would have shown you.`]},reasoning:{hint:`Show the model’s thinking between its messages.`,details:[`Display only — the model thinks the same either way.`,`Hidden thinking is also left out of chat search (Ctrl+F).`,`For the windows this PC serves (this app, the local web UI). The phone has its own switch.`]},colourScheme:{hint:`System follows your desktop’s light or dark setting.`,details:[`Also colours this window’s title bar and menu.`,`Your own colours per element are under Theme.`]},notifications:{hint:`Desktop notifications from this app while its window is not in front.`,details:[`Nothing pops up while you are looking at the window.`,`Your phone’s push notifications are separate: the phone buzzes only while no window on this PC is open.`]},notifyFinished:{hint:`When a chat’s turn ends — finished, or failed.`,details:[`Named after the chat; clicking the notification opens it.`]},notifyWaiting:{hint:`When a chat waits for you: a permission, or one of the agent’s questions.`,details:[`With auto-accept on, only the agent’s questions still wait for you, so only they notify.`]},notifyError:{hint:`When a chat stops on an error.`,details:[`The error itself is also written into the chat.`]},transcriptWindow:{hint:`How many messages and tool cards of a chat stay drawn; older ones leave the top like a stack and come back when you scroll up.`,details:[`Only what is DRAWN: the whole chat is still kept, and still searched.`,`Smaller is faster on long agentic chats; larger keeps more on screen.`]},defaultCwd:{hint:`The folder a new chat runs in when it is not given one. Empty: each chat gets its own private folder.`,details:[`A folder here becomes each new chat’s project: its CLAUDE.md, .claude settings, hooks and skills load. Your home folder and drive roots never load as a project.`,`Empty is the safe default: the agent then works only inside that chat’s own folder under OonaCode’s data directory.`,`Used by chats started in this app. A project’s own folder (Projects → New chats) wins over it; the oona terminal always uses the folder you run it in.`]},remoteAccess:{hint:`Let your phone, Telegram, the website and your other PCs reach this PC.`,details:[`This PC keeps one outbound, end-to-end encrypted channel to your OonaCode server; every other device reaches it through that channel alone.`,`It is also how they read this PC’s chats: the chats are kept only here, never on our server, so they can be read while this PC is on and reachable.`,`Off: they still see this PC online, marked “remote access off”, and cannot list or open its chats, send prompts, unlock it remotely or delete its chats. This PC also cannot open chats on your other PCs.`,`Takes effect immediately.`]},imageRetention:{hint:`Pictures in this PC’s chat history older than this are replaced with a short note. 0 keeps them forever. Default: a year.`,details:[`Replaced: the pictures stored in this PC’s chats — screenshots and other pictures a tool returned, and pictures you pasted into a message — once they are older than this.`,`Each becomes a one-line note saying a picture was there, why and when it went, e.g. “[Picture removed after 365 days to save space — picture from a tool (PNG), 412 KB]”.`,`Not affected: the words of every chat, and the files on your disk. The chat continues normally — the model no longer needs pictures that old.`,`Runs by itself: a few minutes after this PC’s OonaCode starts, then once a day, in small steps that never hold up a chat. A chat that is working, or was in the last hour, is done at the next run.`,`The database file stops growing from pictures; it does not shrink. The space is reused for new chats.`,`Only this PC holds its chats, so this is every copy there is.`]},chatAbout:{hint:`A short note per chat saying what it works on, which your other chats read through “Talk to other chats”. On by default.`,details:[`Written in the background by each chat’s housekeeper — the cheap helper model of the chat’s own provider — after a turn ends, only when the chat changed since, and at most once per interval below.`,`The same switch covers Regenerate (in a chat’s session info) and “Generate for all chats now” (View → What chats are about…). Off stops all three, so nothing is spent on abouts.`,`Paid by the chat’s own route: an OonaCode pool chat spends credits, your own API key is billed by your provider, and your own subscription’s plan covers it.`,`An about is part of its chat and stays on this PC: it is never uploaded to our server, and your other devices read it from this PC, like the chat.`]},chatAboutInterval:{hint:`At most one background about per chat in this many minutes.`,details:[`Only the background job waits for it: Regenerate and “Generate for all chats now” write at once.`,`A background about is written only after a turn ends and only when the chat changed, so a chat nobody uses costs nothing, whatever this says.`,`Shorter keeps abouts fresher and makes more calls.`]},chatAboutMaxWords:{hint:`The longest about the housekeeper may write.`,details:[`A longer answer is cut at this many words.`,`Applies to every about the housekeeper writes: in the background, by Regenerate and by “Generate for all chats now”. An about you write yourself may be longer (up to 2,000 characters).`,`A longer about costs a few more output tokens, and a chat that lists your chats reads every one of them.`]},chatAboutInputChars:{hint:`How much of a chat the housekeeper reads to write its about.`,details:[`Taken from the chat’s title, project and folder, its previous about, your first message, the newest summary of the earlier conversation, your latest messages and the agent’s last answer — each with a share, so no part crowds out the others.`,`Applies to the background job, Regenerate and “Generate for all chats now”.`,`Most of what a call costs: roughly a quarter as many tokens as characters. More gives a better-informed about and costs more.`]},keepUnlocked:{hint:`Leave your vault unlocked when you close or quit the app.`,details:[`Off (default): closing the window — to the tray too — or quitting stops the chats that are running and locks this PC until you unlock it. Your phone and other devices cannot use it meanwhile.`,`On: chats keep running and your other devices keep working after the window is closed. Choose it on a PC only you use.`]},server:{hint:`Your account’s OonaCode server.`,details:[`Where your account lives: sign-in, OonaCode-pool models and credits, your encrypted vault, remote access, and app updates.`,`Your own API keys and subscriptions never go through it — this PC calls those providers directly.`,`Set by signing in. (Developers point a build at another server with OONACODE_GATEWAY_URL.)`]},diagnostics:{hint:`While you are signed in, this PC sends OonaCode its warnings and errors, and a short report of any turn that fails.`,details:[`A report names the error, the model and the provider — never the content of your chats.`,`It is how bugs you never reported get fixed. There is no usage tracking.`]},allowDebugging:{hint:`Let a debugger attach to this app’s windows, to see and control them while fixing a bug. Off by default. Takes effect when OonaCode restarts.`,details:[`For finding bugs together: DevTools (chrome://inspect), Playwright or another Chrome DevTools Protocol client attaches to every window of this app — reads what it shows, clicks, types and runs code in it.`,`The risk: while it is on, ANY program on this PC can do the same — read your chats on screen and act as you in OonaCode, with no prompt. Turn it on only while you need it.`,`Only on this PC: the port is opened on 127.0.0.1, never on the network, and web pages in your browser cannot connect to it.`,`Desktop app only, this PC only: the local web UI in a browser, the phone, Telegram and your other PCs are not affected.`,`Read when the app starts, so a change applies at the next start (Restart now). The host service and your chats keep running through the restart.`,`While it is on, every window shows a red “Debugging on” badge and says so in its title.`]},debugPort:{hint:`The port on 127.0.0.1 a debugger connects to.`,details:[`Connect with http://127.0.0.1:<port> — e.g. chrome://inspect → Configure… → localhost:<port>, or Playwright’s connectOverCDP.`,`A port another program already uses is refused when you save.`,`With “Also debug the main process”, the next port is taken too.`]},debugMainProcess:{hint:`Also open Node’s inspector for the app’s main process, on the next port.`,details:[`For bugs in the desktop shell itself (windows, menus, updates, the tray), not in a window’s page.`,`Gives full control of the main process — it can run any program as you. Off unless you choose it.`,`Applies only while “Allow debugging” is on, at the next start.`]}};function MH(e){if(!Cc(e))return`Off in this run: no debugging port is open.`;let t=[];return e.port!==null&&t.push(e.listening?`On in this run: windows on 127.0.0.1:${e.port}${e.fromCommandLine?` (from the command line)`:``}.`:`Port ${e.port} could not be opened — another program may be using it.`),e.inspectPort!==null&&t.push(e.inspectProblem?`Main-process inspector: ${e.inspectProblem}`:`Main process on 127.0.0.1:${e.inspectPort}.`),t.join(` `)}function NH(e){return wc(e.saved,e.running)}function PH(e){return`Debugging is on: ${Tc(e)}. While it is on, any program on this PC can read and control OonaCode. Click to change it in Settings → Developer.`}function FH({providerId:e,configured:t}){let{api:n,state:r,actions:i}=G(),[a,o]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(t||!n.getAgyStatus)return;let e=!0;return n.getAgyStatus().then(t=>{e&&o({state:t.state,install:t.install})},()=>{e&&o(null)}),()=>{e=!1}},[n,t,r.providers]),(0,W.jsx)(J,{size:`sm`,variant:t?`secondary`:`primary`,onClick:()=>i.openProviderConnect(e),"data-testid":`agy-provider-button`,children:eV(t,a)})}function IH(){let{actions:e}=G(),[t,n]=(0,v.useState)(void 0),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(null),s=(0,v.useCallback)(async()=>{n(await e.listSkills())},[e]);return(0,v.useEffect)(()=>{s()},[s]),t===`unsupported`?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`This PC’s OonaCode is older than skills — update it to manage them here.`}):r?(0,W.jsx)(LH,{onDone:()=>{i(!1),cF(),mN(),s()}}):(0,W.jsxs)(`div`,{className:`space-y-3`,"data-testid":`skills-section`,children:[(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Skills every chat on this PC gets — type `,(0,W.jsx)(`span`,{className:`font-mono`,children:`/`}),` in the message box to use one for that message. They work with every model. A change applies from a chat’s next start (a new chat, or one idle for ten minutes).`]}),(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`skills-per-chat-note`,children:[`The model is not shown them on its own: each chat chooses which skills the model may use by itself, in the `,(0,W.jsx)(`span`,{className:`font-medium`,children:`Skills`}),` menu under its message box — only those cost tokens on every message of that chat.`]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(J,{size:`sm`,onClick:()=>i(!0),"data-testid":`skills-import-open`,children:[(0,W.jsx)(q.Download,{className:`h-3.5 w-3.5`}),` Import from Claude Code…`]}),t?(0,W.jsx)(`span`,{className:`truncate text-[11px] text-fg-faint`,title:t.dir,children:t.dir}):null]}),t===void 0?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading…`}):t===null?(0,W.jsx)(`p`,{className:`text-xs text-danger`,children:`The host could not list the skills right now.`}):t.skills.length===0?(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`skills-empty`,children:[`No skills of your own yet. Import them from Claude Code, or put a folder with a`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:`SKILL.md`}),` in the folder above.`]}):(0,W.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.skills.map(t=>(0,W.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2 text-sm`,"data-testid":`skill-row`,"data-name":t.name,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,W.jsxs)(`span`,{className:`font-mono font-medium`,children:[`/`,t.name]}),t.argumentHint?(0,W.jsx)(`span`,{className:`font-mono text-xs text-fg-faint`,children:t.argumentHint}):null,t.broken?(0,W.jsx)(Z,{tone:`warn`,children:`no SKILL.md`}):null]}),t.description?(0,W.jsx)(`div`,{className:`line-clamp-2 text-xs text-fg-muted`,title:t.description,children:t.description}):null,(0,W.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[Rj(t.bytes),` · `,t.files,` file`,t.files===1?``:`s`,t.importedFrom?(0,W.jsxs)(W.Fragment,{children:[` `,`· imported `,t.importedAt?ag(t.importedAt):``,` from`,` `,(0,W.jsx)(`span`,{title:t.importedFrom,children:t.importedFrom})]}):null]})]}),(0,W.jsxs)(J,{size:`sm`,variant:`ghost`,busy:a===t.name,"aria-label":`Remove ${t.name}`,onClick:async()=>{o(t.name);let n=await e.removeSkill(t.name);o(null),n&&(cF(),mN(),await s())},"data-testid":`skill-remove`,children:[(0,W.jsx)(q.Trash,{className:`h-3.5 w-3.5`}),` Remove`]})]},t.name))})]})}function LH({onDone:e}){let{actions:t}=G(),[n,r]=(0,v.useState)(void 0),[i,a]=(0,v.useState)(()=>new Set),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null);(0,v.useEffect)(()=>{let e=!0;return t.scanClaudeSkills().then(t=>{e&&r(t)}),()=>{e=!1}},[t]);let f=(0,v.useMemo)(()=>{let e=new Map;for(let t of n?.skills??[]){let n=t.origin===`plugin`?`Plugin: ${t.plugin??`?`}`:`Your skills`;e.set(n,[...e.get(n)??[],t])}return[...e.entries()]},[n]),p=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,W.jsxs)(`div`,{className:`space-y-3`,"data-testid":`skills-import`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:e,children:`← Back`}),(0,W.jsx)(`span`,{className:`text-sm font-medium`,children:`Import skills from Claude Code`})]}),(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Tick the skills to copy into OonaCode. Your Claude Code install is only read — nothing in it is changed.`,n?.roots.length?(0,W.jsxs)(W.Fragment,{children:[` `,`Read from `,(0,W.jsx)(`span`,{className:`font-mono`,children:n.roots.join(`, `)}),`.`]}):null]}),n===void 0?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Looking…`}):n===null?(0,W.jsx)(`p`,{className:`text-xs text-danger`,children:`The host could not read Claude Code’s skills.`}):n.skills.length===0?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`skills-import-empty`,children:`No skills found in Claude Code on this PC.`}):f.map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wide text-fg-faint`,children:e}),(0,W.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>{let t=!!e.unavailable||e.alreadyInOonaCode&&!o;return(0,W.jsx)(`li`,{className:`px-3 py-1.5 text-sm`,children:(0,W.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:i.has(e.key)&&!t,disabled:t,onChange:()=>p(e.key),"data-testid":`skills-import-pick`,"data-name":e.name}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{className:`font-mono font-medium`,children:[`/`,e.name]}),` `,e.alreadyInOonaCode?(0,W.jsx)(Z,{children:`already in OonaCode`}):null,` `,e.unavailable?(0,W.jsx)(Z,{tone:`warn`,children:e.unavailable}):null,e.description?(0,W.jsx)(`span`,{className:`line-clamp-2 block text-xs text-fg-muted`,children:e.description}):null,e.note?(0,W.jsx)(`span`,{className:`block text-[11px] text-warn`,children:e.note}):null,(0,W.jsxs)(`span`,{className:`block text-[11px] text-fg-faint`,children:[Rj(e.bytes),` · `,e.path]})]})]})},e.key)})})]},e)),n&&n.skills.some(e=>e.alreadyInOonaCode)?(0,W.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Replace the ones already in OonaCode`]}):null,u?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,role:`status`,"data-testid":`skills-import-outcome`,children:u}):null,(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(J,{variant:`primary`,size:`sm`,busy:c,disabled:i.size===0,"data-testid":`skills-import-go`,onClick:async()=>{l(!0);let n=await t.importClaudeSkills([...i],o);if(l(!1),!n)return;let r=n.skipped.map(e=>`${e.name||e.key}: ${e.reason}`);d(`Imported ${n.imported.length}`+(r.length>0?` · skipped ${r.join(`; `)}`:``)),n.skipped.length===0&&e()},children:[`Import `,i.size>0?i.size:``]}),(0,W.jsx)(J,{size:`sm`,onClick:e,children:`Cancel`})]})]})}var RH=[{id:`general`,label:`General`,icon:q.Settings},{id:`theme`,label:`Theme`,icon:q.Palette},{id:`advanced`,label:`Advanced`,icon:q.Sliders},{id:`skills`,label:`Skills`,icon:q.Tool},{id:`providers`,label:`Providers`,icon:q.Plug},{id:`devices`,label:`Devices`,icon:q.Monitor},{id:`host`,label:`This PC`,icon:q.Stethoscope},{id:`developer`,label:`Developer`,icon:q.Bug}];function zH(){let e=typeof window<`u`?window.oonacode:void 0;return e?.getDebugging&&e.setDebugging?e:null}function BH(){let{state:e,actions:t}=G(),n=e.prefs,r=e.settings?.theme??`system`;return(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(qy,{label:`Auto-accept permissions`,hint:jH.autoAccept.hint,details:jH.autoAccept.details,checked:n.autoAcceptPermissions,onChange:e=>void t.savePrefs({autoAcceptPermissions:e}),testId:`settings-auto-accept`}),(0,W.jsx)(qy,{label:`Show reasoning in the timeline`,hint:jH.reasoning.hint,details:jH.reasoning.details,checked:n.showReasoningSummaries,onChange:e=>void t.savePrefs({showReasoningSummaries:e})}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border py-3`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Colour scheme`,(0,W.jsx)(Hy,{label:`Colour scheme`,details:(0,W.jsx)(Uy,{items:jH.colourScheme.details})})]}),(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-faint`,children:jH.colourScheme.hint})]}),(0,W.jsx)(Jy,{label:`Colour scheme`,value:r,options:[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}],onChange:e=>void t.saveSettings({theme:e})})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-2`,children:[(0,W.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,W.jsx)(q.Bell,{className:`w-3 h-3`}),` Notifications`,(0,W.jsx)(Hy,{label:`Notifications`,details:(0,W.jsx)(Uy,{items:jH.notifications.details})})]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-faint`,children:jH.notifications.hint}),(0,W.jsx)(qy,{label:`Agent finished or needs attention`,hint:jH.notifyFinished.hint,details:jH.notifyFinished.details,checked:n.notifications.agentFinished,onChange:e=>void t.savePrefs({notifications:{...n.notifications,agentFinished:e}})}),(0,W.jsx)(qy,{label:`Permission or question waiting for you`,hint:jH.notifyWaiting.hint,details:jH.notifyWaiting.details,checked:n.notifications.permissionRequired,onChange:e=>void t.savePrefs({notifications:{...n.notifications,permissionRequired:e}})}),(0,W.jsx)(qy,{label:`Error occurred`,hint:jH.notifyError.hint,details:jH.notifyError.details,checked:n.notifications.errorOccurred,onChange:e=>void t.savePrefs({notifications:{...n.notifications,errorOccurred:e}})})]}),e.prefsBackend===`local`?(0,W.jsx)(`div`,{className:`mt-2 rounded-md bg-warn-soft px-3 py-2 text-xs text-warn`,children:`This host does not store UI preferences yet, so they are kept on this device only.`}):null]})}function VH(e){let t=e.replace(/-/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function HH(e){let t={};if(typeof document>`u`||typeof getComputedStyle!=`function`)return t;let n=document.documentElement,r=n.getAttribute(`data-theme`),i=[];for(let e of Fc){let t=n.style.getPropertyValue(`--${e}`);t&&i.push([e,t]),n.style.removeProperty(`--${e}`)}n.setAttribute(`data-theme`,e);let a=getComputedStyle(n);for(let e of Fc){let n=a.getPropertyValue(`--${e}`).trim();t[e]=/^#[0-9a-fA-F]{6}$/.test(n)?n.toLowerCase():`#808080`}r===null?n.removeAttribute(`data-theme`):n.setAttribute(`data-theme`,r);for(let[e,t]of i)n.style.setProperty(`--${e}`,t);return t}function UH(){let{state:e,actions:t}=G(),n=e.prefs,[r,i]=(0,v.useState)(`dark`),a=(0,v.useMemo)(()=>HH(r),[r]),[o,s]=(0,v.useState)({}),c=(0,v.useRef)(o);c.current=o;let l=(0,v.useRef)(n.themeColors);l.current=n.themeColors;let u=(0,v.useRef)(null),d=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)};(0,v.useEffect)(()=>d,[]);let f=e=>{d();let n=c.current;Object.keys(n).length!==0&&(s({}),t.savePrefs({themeColors:{...l.current,[e]:{...l.current[e],...n}}}))},p=(e,t)=>{s(n=>({...n,[e]:t})),c.current={...c.current,[e]:t},d(),u.current=window.setTimeout(()=>f(r),300)},m={...l.current[r],...o},h=Object.keys(m).length,g=e=>{d(),s({});let n={...m};delete n[e],t.savePrefs({themeColors:{...l.current,[r]:n}})};return(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:`Theme colours`}),(0,W.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-faint`,children:`Choose any colour for any element. A colour you do not choose keeps the theme's own value. Your colours follow your account to every PC.`})]}),(0,W.jsx)(Jy,{label:`Edit colour scheme`,value:r,options:[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],onChange:e=>{f(r),i(e)}})]}),(0,W.jsx)(`div`,{className:`grid grid-cols-1 gap-x-4 sm:grid-cols-2`,children:Fc.map(e=>{let t=m[e]!==void 0,n=m[e]??a[e]??`#808080`;return(0,W.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border py-1.5`,"data-testid":`theme-color-row-${r}-${e}`,children:[(0,W.jsx)(`input`,{type:`color`,className:`h-6 w-9 shrink-0 cursor-pointer rounded border border-border bg-transparent p-0.5`,value:n,onChange:t=>p(e,t.target.value),"aria-label":`${VH(e)} colour (${r} scheme)`,"data-testid":`theme-color-${r}-${e}`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:VH(e)}),(0,W.jsx)(`span`,{className:`w-16 shrink-0 text-right font-mono text-[10px] text-fg-faint`,children:t?m[e]:`default`}),t?(0,W.jsx)(Y,{label:`Reset ${VH(e)} to the theme colour`,className:`p-0.5`,"data-testid":`theme-color-clear-${r}-${e}`,onClick:()=>g(e),children:(0,W.jsx)(q.Refresh,{className:`w-3 h-3`})}):null]},e)})}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border pt-2`,children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,"data-testid":`theme-colors-count`,children:h===0?`No custom colours in the ${r} scheme.`:`${h} custom colour${h===1?``:`s`} in the ${r} scheme.`}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>{d(),s({}),t.savePrefs({themeColors:{...l.current,[r]:{}}})},disabled:h===0,"data-testid":`theme-reset-${r}`,children:`Reset all`})]})]})}function WH(){let{state:e,actions:t}=G(),n=e.prefs,[r,i]=(0,v.useState)(String(n.transcriptWindowSize));return(0,v.useEffect)(()=>i(String(n.transcriptWindowSize)),[n.transcriptWindowSize]),(0,W.jsx)(`div`,{className:`space-y-1`,children:(0,W.jsx)(Wy,{label:`Transcript window size`,hint:`${jH.transcriptWindow.hint} Scrolling to the top brings back 100 more. 100–${Nc}, default 500.`,details:jH.transcriptWindow.details,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{className:U(X,`w-32`),type:`number`,min:100,max:Nc,step:100,value:r,onChange:e=>i(e.target.value),onBlur:()=>{let e=Number.parseInt(r,10);Number.isFinite(e)&&t.savePrefs({transcriptWindowSize:e})},"aria-label":`Transcript window size`}),(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,children:`messages and tool cards`})]})})})}function GH(){let{state:e,actions:t}=G(),n=(0,v.useMemo)(()=>Os(e.providers),[e.providers]);return(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[n.length===0?(0,W.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`No providers in the registry.`}):null,n.map(n=>{let r=n.definition,i=e.activeProviderId===r.id,a=Ds(e.providers,r.id),o=a.some(e=>e.configured),s=[...new Set(a.flatMap(e=>(e.credentials??[]).map(e=>e.class)))].filter(e=>e!==`none`);return(0,W.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border px-3 py-2`,"data-testid":`provider-${r.id}`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium`,children:r.displayName}),i?(0,W.jsx)(Z,{tone:`accent`,children:`active`}):null,r.route===`direct`?(0,W.jsx)(Z,{tone:`ok`,children:`direct`}):null,s.length>0?s.map(e=>(0,W.jsxs)(Z,{tone:`ok`,children:[e===`subscription`?`subscription`:`API key`,` connected`]},e)):o?(0,W.jsx)(Z,{tone:`ok`,children:`connected`}):(0,W.jsx)(Z,{tone:`warn`,children:`not connected`})]}),(0,W.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[r.models.length,` model`,r.models.length===1?``:`s`,r.credentialVariants?.length?` · ${r.credentialVariants.map(e=>e.label).join(` / `)}`:``]})]}),r.engine===`agy`?(0,W.jsx)(FH,{providerId:r.id,configured:o}):(0,W.jsxs)(J,{size:`sm`,variant:o?`secondary`:`primary`,onClick:()=>t.openProviderConnect(r.id),children:[(0,W.jsx)(q.Plus,{className:`w-3 h-3`}),` `,o?`Manage…`:`Connect`]})]},r.id)}),(0,W.jsx)(`div`,{className:`pt-3`,children:(0,W.jsx)(MR,{})})]})}function KH(){let{state:e,actions:t}=G(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(``);return(0,v.useEffect)(()=>{t.refreshHosts()},[t]),e.account?.loggedIn?e.remote.supported?(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[e.remote.loading?(0,W.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-fg-muted`,children:[(0,W.jsx)(q.Spinner,{}),` Loading devices…`]}):null,e.remote.hosts.map(e=>(0,W.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border px-3 py-2`,children:[(0,W.jsx)(q.Monitor,{className:`w-4 h-4 shrink-0 text-fg-faint`}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:n===e.hostId?(0,W.jsx)(`input`,{className:X,value:i,autoFocus:!0,"aria-label":`Label for ${e.hostName}`,onChange:e=>a(e.target.value),onKeyDown:n=>{n.key===`Enter`&&i.trim()?(t.renameHost(e.hostId,i.trim()),r(null)):n.key===`Escape`&&r(null)}}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[e.label||e.hostName,e.isSelf?(0,W.jsx)(Z,{tone:`accent`,children:`this PC`}):null,(0,W.jsx)(Z,{tone:e.online?`ok`:`neutral`,children:e.online?`online`:`offline`}),e.remoteAccessOff?(0,W.jsx)(Z,{tone:`warn`,children:`remote access off`}):null]}),(0,W.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[e.platform,e.appVersion?` · v${e.appVersion}`:``,e.lastSeenAt?` · seen ${ag(e.lastSeenAt)}`:``]})]})}),n===e.hostId?(0,W.jsx)(J,{size:`sm`,variant:`primary`,onClick:()=>{i.trim()&&t.renameHost(e.hostId,i.trim()),r(null)},children:`Save`}):(0,W.jsxs)(J,{size:`sm`,onClick:()=>{r(e.hostId),a(e.label||e.hostName)},children:[(0,W.jsx)(q.Edit,{className:`w-3 h-3`}),` Rename`]})]},e.hostId)),!e.remote.loading&&e.remote.hosts.length===0?(0,W.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`No devices reported yet.`}):null]}):(0,W.jsxs)(`div`,{className:`rounded-md border border-border px-3 py-3 text-sm text-fg-muted`,children:[`This PC's OonaCode is too old to list your account's devices — update it. This PC is`,` `,(0,W.jsx)(`strong`,{children:e.connection.hostName??`unknown`}),`.`]}):(0,W.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`Sign in to see the devices on your account.`})}function qH(e,t,n=Date.now()){if(e===0)return`Off — pictures are kept forever.`;if(!t)return`Not run yet — it runs a few minutes after OonaCode starts, then daily.`;let r=ag(t.finishedAt,n);return t.pictures===0?`Last run: nothing to replace, ${r}.`:`Last run: ${t.pictures.toLocaleString(`en-US`)} ${t.pictures===1?`picture`:`pictures`}, ${Rj(t.bytesFreed)}, ${r}.`}function JH({days:e,lastRun:t,onSave:n}){let[r,i]=(0,v.useState)(String(e));(0,v.useEffect)(()=>i(String(e)),[e]);let a=()=>{let t=Number.parseInt(r,10);if(!Number.isFinite(t)){i(String(e));return}let a=t<=0?0:Math.min($c,Math.max(1,t));i(String(a)),a!==e&&n(a)};return(0,W.jsxs)(Wy,{label:`Replace pictures older than`,hint:jH.imageRetention.hint,details:jH.imageRetention.details,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{className:U(X,`w-24`),type:`number`,min:0,max:$c,step:1,value:r,onChange:e=>i(e.target.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`&&a()},"aria-label":`Replace pictures older than (days)`,"data-testid":`settings-image-retention`}),(0,W.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`days`,e===365?` (a year)`:``]})]}),(0,W.jsx)(`span`,{className:`text-xs text-fg-muted`,"data-testid":`settings-image-retention-status`,children:qH(e,t)})]})}function YH(e,t,n){let r=e.trim(),i=Number(r);return!/^\d+$/.test(r)||i<t||i>n?`A whole number from ${t.toLocaleString(`en-US`)} to ${n.toLocaleString(`en-US`)}.`:null}function XH({label:e,unit:t,hint:n,details:r,value:i,min:a,max:o,defaultValue:s,onSave:c,testId:l}){let[u,d]=(0,v.useState)(String(i)),[f,p]=(0,v.useState)(null);(0,v.useEffect)(()=>{d(String(i)),p(null)},[i]);let m=()=>{let e=YH(u,a,o);if(p(e),e)return;let t=Number(u.trim());t!==i&&c(t)},h=e=>e.toLocaleString(`en-US`);return(0,W.jsxs)(Wy,{label:e,hint:`${n} ${h(a)}–${h(o)}, default ${h(s)}.`,details:r,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{className:U(X,`w-28`,f&&`border-danger`),type:`number`,min:a,max:o,step:1,value:u,onChange:e=>d(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m()},"aria-label":e,"aria-invalid":f!==null,"data-testid":l}),(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,children:t})]}),f?(0,W.jsx)(`span`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`${l}-problem`,children:f}):null]})}function ZH({settings:e}){let{actions:t}=G(),n=ql,r=Kl;return(0,W.jsxs)(`div`,{className:`border-t border-border pt-3`,"data-testid":`settings-chat-abouts`,children:[(0,W.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Chat abouts`}),(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>t.openChatAbouts(),"data-testid":`settings-open-chat-abouts`,children:`What your chats are about…`})]}),e.chatAboutEnabled===void 0?null:(0,W.jsx)(qy,{label:`Write an about for every chat`,hint:jH.chatAbout.hint,details:jH.chatAbout.details,checked:e.chatAboutEnabled,onChange:e=>void t.saveSettings({chatAboutEnabled:e}),testId:`settings-chat-about-enabled`}),(0,W.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[e.chatAboutIntervalMinutes===void 0?null:(0,W.jsx)(XH,{label:`Minutes between background abouts`,unit:`minutes`,hint:jH.chatAboutInterval.hint,details:jH.chatAboutInterval.details,value:e.chatAboutIntervalMinutes,min:n.intervalMinutes.min,max:n.intervalMinutes.max,defaultValue:r.intervalMinutes,onSave:e=>void t.saveSettings({chatAboutIntervalMinutes:e}),testId:`settings-chat-about-interval`}),e.chatAboutMaxWords===void 0?null:(0,W.jsx)(XH,{label:`Longest about`,unit:`words`,hint:jH.chatAboutMaxWords.hint,details:jH.chatAboutMaxWords.details,value:e.chatAboutMaxWords,min:n.maxWords.min,max:n.maxWords.max,defaultValue:r.maxWords,onSave:e=>void t.saveSettings({chatAboutMaxWords:e}),testId:`settings-chat-about-max-words`}),e.chatAboutInputChars===void 0?null:(0,W.jsx)(XH,{label:`How much of a chat is read`,unit:`characters`,hint:jH.chatAboutInputChars.hint,details:jH.chatAboutInputChars.details,value:e.chatAboutInputChars,min:n.inputChars.min,max:n.inputChars.max,defaultValue:r.inputChars,onSave:e=>void t.saveSettings({chatAboutInputChars:e}),testId:`settings-chat-about-input-chars`})]})]})}function QH(){let{state:e,actions:t}=G(),n=e.settings,[r,i]=(0,v.useState)(n?.defaultCwd??``);if((0,v.useEffect)(()=>i(n?.defaultCwd??``),[n?.defaultCwd]),(0,v.useEffect)(()=>{t.refreshSettings()},[t]),!n)return(0,W.jsx)(`div`,{className:`py-6 text-sm text-fg-muted`,children:`Loading settings…`});let a=e.account?.gatewayUrl??n.gatewayUrl??x,o=e=>{let r=e.trim()?e.trim():null;r!==(n.defaultCwd??null)&&t.saveSettings({defaultCwd:r})},s=async()=>{let e=await window.oonacode?.pickDirectory?.({title:`The folder new chats run in`,...r?{defaultPath:r}:{}});e&&(i(e),o(e))};return(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsx)(Wy,{label:`Default working directory`,hint:jH.defaultCwd.hint,details:jH.defaultCwd.details,children:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{className:U(X,`flex-1 font-mono text-xs`),value:r,onChange:e=>i(e.target.value),onBlur:()=>o(r),placeholder:`Empty — each chat gets its own folder`,spellCheck:!1,"data-testid":`settings-default-cwd`}),window.oonacode?.pickDirectory?(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>void s(),children:`Choose…`}):null,r?(0,W.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>{i(``),o(``)},children:`Clear`}):null]})}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-1`,children:[(0,W.jsx)(qy,{label:`Remote access`,hint:jH.remoteAccess.hint,details:jH.remoteAccess.details,checked:n.relayEnabled??!0,onChange:e=>void t.saveSettings({relayEnabled:e}),testId:`settings-relay`}),(0,W.jsx)(qy,{label:`Keep the vault unlocked when the app closes`,hint:jH.keepUnlocked.hint,details:jH.keepUnlocked.details,checked:n.keepUnlockedOnExit??!1,onChange:e=>void t.saveSettings({keepUnlockedOnExit:e}),testId:`settings-keep-unlocked-exit`})]}),n.imageRetentionDays===void 0?null:(0,W.jsx)(`div`,{className:`border-t border-border pt-3`,children:(0,W.jsx)(JH,{days:n.imageRetentionDays,lastRun:n.imageRetentionLastRun??null,onSave:e=>void t.saveSettings({imageRetentionDays:e})})}),n.chatAboutEnabled!==void 0||n.chatAboutIntervalMinutes!==void 0||n.chatAboutMaxWords!==void 0||n.chatAboutInputChars!==void 0?(0,W.jsx)(ZH,{settings:n}):null,(0,W.jsxs)(`div`,{className:`space-y-2 border-t border-border pt-3 text-xs`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Server`,(0,W.jsx)(Hy,{label:`Server`,details:(0,W.jsx)(Uy,{items:jH.server.details})})]}),(0,W.jsx)(`span`,{className:`block text-fg-faint`,children:jH.server.hint})]}),(0,W.jsx)(`span`,{className:`break-all font-mono text-fg-muted`,"data-testid":`settings-server`,children:a})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Diagnostics`,(0,W.jsx)(Hy,{label:`Diagnostics`,details:(0,W.jsx)(Uy,{items:jH.diagnostics.details})})]}),(0,W.jsx)(`span`,{className:`block text-fg-faint`,children:jH.diagnostics.hint})]})]})]})}function $H(e){return e instanceof Error?e.message:String(e)}function eU(){let e=zH(),[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(null),l=(0,v.useRef)(Promise.resolve());if((0,v.useEffect)(()=>{if(!e?.getDebugging)return;let t=!0;return e.getDebugging().then(e=>{t&&(n(e),o(String(e.saved.port)))},e=>{t&&i($H(e))}),()=>{t=!1}},[e]),!e)return(0,W.jsx)(`div`,{className:`py-6 text-sm text-fg-muted`,children:`Debugging is a setting of the OonaCode desktop app.`});if(!t)return r?(0,W.jsx)(`div`,{className:`py-6 text-sm text-danger`,role:`alert`,children:r}):(0,W.jsx)(`div`,{className:`py-6 text-sm text-fg-muted`,children:`Loading…`});let u=t=>{l.current=l.current.then(async()=>{try{let r=await e.setDebugging(t);n(r.state),i(r.ok?null:r.problem??`Not saved.`),r.ok&&o(String(r.state.saved.port))}catch(e){i($H(e))}})},d=()=>{let e=a.trim(),n=/^\d+$/.test(e)?Number(e):NaN,r=Sc(n);if(r){i(r);return}if(n===t.saved.port){i(null);return}u({port:n})},f=async()=>{try{let t=await e.relaunchApp();t.started?c(t.message||`OonaCode is restarting…`):i(t.message||`OonaCode could not restart.`)}catch(e){i($H(e))}},p=NH(t),m=r!==null&&/^(The port|Ports?) /.test(r);return(0,W.jsxs)(`div`,{className:`space-y-3`,"data-testid":`settings-developer`,children:[(0,W.jsx)(qy,{label:`Allow debugging`,hint:jH.allowDebugging.hint,details:jH.allowDebugging.details,checked:t.saved.enabled,onChange:e=>u({enabled:e}),testId:`settings-allow-debugging`}),(0,W.jsx)(Wy,{label:`Debugging port`,hint:`${jH.debugPort.hint} ${_c}–${vc}, default ${gc}.`,details:jH.debugPort.details,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{className:U(X,`max-w-28`,m&&`border-danger`),type:`number`,min:_c,max:vc,step:1,value:a,onChange:e=>o(e.target.value),onBlur:d,onKeyDown:e=>{e.key===`Enter`&&d()},"aria-label":`Debugging port`,"aria-invalid":m,"data-testid":`settings-debug-port`}),(0,W.jsx)(`span`,{className:`whitespace-nowrap text-xs text-fg-faint`,children:`on 127.0.0.1`})]})}),(0,W.jsx)(qy,{label:`Also debug the main process`,hint:jH.debugMainProcess.hint,details:jH.debugMainProcess.details,checked:t.saved.inspectMain,disabled:!t.saved.enabled,onChange:e=>u({inspectMain:e}),testId:`settings-debug-main`}),r?(0,W.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`settings-debugging-problem`,children:r}):null,(0,W.jsxs)(`div`,{className:`rounded-md border border-border px-3 py-2 text-xs`,"data-testid":`settings-debugging-status`,children:[(0,W.jsx)(`div`,{className:`text-fg-muted`,children:MH(t.running)}),p?(0,W.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-warn`,"data-testid":`settings-debugging-restart-note`,children:`Takes effect when OonaCode restarts. The host service and your chats keep running.`}),(0,W.jsx)(J,{size:`sm`,variant:`primary`,onClick:()=>void f(),disabled:s!==null||!e.relaunchApp,"data-testid":`settings-debugging-restart`,children:`Restart now`})]}):null,s?(0,W.jsx)(`div`,{className:`mt-1 text-fg-faint`,children:s}):null]})]})}function tU({open:e,onClose:t}){let{state:n,actions:r}=G(),[i,a]=(0,v.useState)(`general`),o=n.ui.settingsSection;(0,v.useEffect)(()=>{e&&o&&a(o)},[e,o]),(0,v.useEffect)(()=>{e&&!n.settings&&r.refreshSettings()},[e,n.settings,r]);let s=zH()!==null,c=s?RH:RH.filter(e=>e.id!==`developer`);return(0,W.jsx)(Ky,{open:e,title:`Settings`,onClose:t,wide:!0,footer:(0,W.jsx)(J,{onClick:t,children:`Done`}),children:(0,W.jsxs)(`div`,{className:`flex min-h-[22rem] gap-4`,children:[(0,W.jsxs)(`nav`,{className:`w-36 shrink-0 space-y-0.5`,"aria-label":`Settings sections`,children:[c.map(e=>{let t=e.icon;return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),"aria-current":i===e.id?`true`:void 0,className:U(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,i===e.id?`bg-accent-soft font-medium text-accent`:`text-fg-muted hover:bg-surface-2`),children:[(0,W.jsx)(t,{className:`w-3.5 h-3.5`}),e.label]},e.id)}),(0,W.jsxs)(`div`,{className:`pt-3 text-[11px] text-fg-faint`,children:[`OonaCode Desktop v`,Gv(typeof window<`u`&&window.oonacode?.appVersion||n.connection.appVersion||`0.0.0`,Wv({bridge:typeof window<`u`?window.oonacode:void 0,info:n.info}))]})]}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i===`general`?(0,W.jsx)(BH,{}):null,i===`theme`?(0,W.jsx)(UH,{}):null,i===`advanced`?(0,W.jsx)(WH,{}):null,i===`skills`?(0,W.jsx)(IH,{}):null,i===`providers`?(0,W.jsx)(GH,{}):null,i===`devices`?(0,W.jsx)(KH,{}):null,i===`host`?(0,W.jsx)(QH,{}):null,i===`developer`&&s?(0,W.jsx)(eU,{}):null]})]})})}function nU({toast:e}){let{actions:t}=G();(0,v.useEffect)(()=>{let n=setTimeout(()=>t.dismissToast(e.id),e.kind===`error`?9e3:5e3);return()=>clearTimeout(n)},[e.id,e.kind,t]);let n=e.kind===`error`?`border-danger/50 bg-danger-soft text-danger`:e.kind===`success`?`border-ok/50 bg-ok-soft text-ok`:`border-border bg-surface text-fg`;return(0,W.jsxs)(`div`,{role:e.kind===`error`?`alert`:`status`,className:U(`pointer-events-auto flex max-w-sm items-start gap-2 rounded-md border px-3 py-2 text-sm shadow-md`,n),children:[e.kind===`error`?(0,W.jsx)(q.Alert,{className:`mt-0.5 w-4 h-4`}):e.kind===`success`?(0,W.jsx)(q.Check,{className:`mt-0.5 w-4 h-4`}):null,(0,W.jsx)(`div`,{className:`pre-wrap min-w-0 flex-1`,children:e.text}),(0,W.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,className:`opacity-60 hover:opacity-100`,onClick:()=>t.dismissToast(e.id),children:(0,W.jsx)(q.X,{className:`w-3.5 h-3.5`})})]})}function rU(){let{state:e}=G();return e.toasts.length===0?null:(0,W.jsx)(`div`,{className:`pointer-events-none fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.toasts.map(e=>(0,W.jsx)(nU,{toast:e},e.id))})}var iU=2e3;function aU(e){if(!oU(e))return;let t=typeof window<`u`?window.oonacode:void 0;if(t?.openExternal){t.openExternal(e).catch(()=>void 0);return}typeof window<`u`&&window.open(e,`_blank`,`noopener,noreferrer`)}function oU(e){if(typeof e!=`string`||e===``)return!1;try{let{protocol:t}=new URL(e);return t===`http:`||t===`https:`}catch{return!1}}function sU(e){if(e.message)return e.message;switch(e.status){case`denied`:return`That request was denied in the browser. Start again if it was you.`;case`expired`:return`The code expired before it was approved. Start again for a fresh one.`;default:return`The sign-in could not be started. Check that this PC can reach the gateway.`}}function cU({children:e,testId:t}){let{state:n}=G(),r=n.connection.hostName??n.info?.hostName??null;return(0,W.jsxs)(`div`,{className:`flex h-full flex-col bg-bg text-fg`,"data-testid":t,children:[(0,W.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-surface px-3`,children:[(0,W.jsx)(`span`,{className:`font-semibold tracking-tight`,children:`OonaCode`}),r?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-fg-faint`,children:`/`}),(0,W.jsx)(`span`,{className:`truncate text-sm text-fg-muted`,"data-testid":`frame-host-name`,children:r})]}):null]}),(0,W.jsx)(`main`,{className:`flex min-h-0 flex-1 items-start justify-center overflow-y-auto p-6`,children:(0,W.jsx)(`div`,{className:`w-full max-w-md py-6`,children:e})}),(0,W.jsx)(rU,{})]})}function lU(){return(0,W.jsx)(cU,{testId:`account-loading`,children:(0,W.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,W.jsx)(q.Spinner,{className:`w-4 h-4`}),(0,W.jsx)(`span`,{children:`Checking your account…`})]})})}function uU({link:e}){let{actions:t}=G(),[n,r]=(0,v.useState)(!1),i=e.verificationUrl??``,a=e.verificationUrlComplete??i,o=oU(a),s=t.refreshAccountLink;return(0,v.useEffect)(()=>{let e=setInterval(()=>void s(),iU);return()=>clearInterval(e)},[s]),(0,W.jsxs)(`div`,{className:`space-y-3`,"data-testid":`link-waiting`,children:[(0,W.jsxs)(`ol`,{className:`space-y-2 text-sm`,children:[(0,W.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:`1. Open`}),o?(0,W.jsx)(`a`,{className:`break-all font-medium text-accent underline`,href:a,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`link-url`,onClick:e=>{window.oonacode?.openExternal&&(e.preventDefault(),aU(a))},children:i}):(0,W.jsx)(`span`,{className:`break-all font-medium`,"data-testid":`link-url`,children:i})]}),(0,W.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:`2. Enter`}),(0,W.jsx)(`span`,{className:`select-all rounded-md border border-border bg-surface-2 px-2.5 py-1 font-mono text-base tracking-widest`,"data-testid":`link-user-code`,children:e.userCode})]})]}),(0,W.jsxs)(`p`,{className:`flex items-center gap-2 text-xs text-fg-muted`,role:`status`,children:[(0,W.jsx)(q.Spinner,{className:`w-3.5 h-3.5`}),(0,W.jsx)(`span`,{children:`Waiting for approval in your browser…`})]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-faint`,children:`Approve this code only if you are looking at it on your own screen right now. It is good for a few minutes and can be used once.`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o?(0,W.jsxs)(J,{size:`sm`,onClick:()=>aU(a),"data-testid":`link-reopen`,children:[(0,W.jsx)(q.LogIn,{className:`w-3.5 h-3.5`}),` Open the browser again`]}):null,(0,W.jsx)(J,{size:`sm`,variant:`ghost`,busy:n,"data-testid":`link-cancel`,onClick:()=>{r(!0),t.cancelAccountLink().finally(()=>r(!1))},children:`Cancel`})]})]})}function dU(e){if(typeof e!=`string`||e===``)return null;try{let t=new URL(e).hostname;if(!t)return null;let n=/^api(?:-([a-z0-9-]+))?.(.+)$/i.exec(t),r=n?.[2];return n&&r?n[1]?n[1]+`.`+r:r:t}catch{return null}}function fU(){let{state:e,actions:t}=G(),n=e.accountLink,r=dU(n?.verificationUrl??e.settings?.gatewayUrl??e.account?.gatewayUrl??null),[i,a]=(0,v.useState)(!1),o=(0,v.useCallback)(async()=>{a(!0);try{let e=await t.startAccountLink();e?.status===`waiting`&&aU(e.verificationUrlComplete??e.verificationUrl??``)}finally{a(!1)}},[t]);if(n?.status===`waiting`)return(0,W.jsx)(uU,{link:n});let s=n&&(n.status===`denied`||n.status===`expired`);return(0,W.jsxs)(`div`,{className:`space-y-2`,children:[s?(0,W.jsx)(`p`,{role:`status`,"data-testid":`link-refused`,className:`rounded-md border border-warn/50 bg-warn-soft px-3 py-2 text-xs text-fg`,children:sU(n)}):null,(0,W.jsxs)(J,{variant:`primary`,busy:i,onClick:()=>void o(),"data-testid":`link-start`,className:`w-full justify-center`,children:[(0,W.jsx)(q.LogIn,{className:`w-3.5 h-3.5`}),s?`Try again in your browser`:`Sign in with your browser`]}),(0,W.jsxs)(`p`,{className:`text-xs text-fg-faint`,"data-testid":`link-site-note`,children:[`Opens `,r??`your account page`,` and shows a short code to confirm. Your password is never typed on this machine, and this PC never sees anyone else's.`]})]})}function pU(){let{state:e}=G(),[t,n]=(0,v.useState)(!1),r=t||e.emailVerification!==null;return(0,W.jsx)(cU,{testId:`sign-in-view`,children:(0,W.jsxs)(`div`,{className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Sign in to use OonaCode`}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`OonaCode runs the agent on this PC, with your own providers — but it needs an OonaCode account. There is no guest mode.`})]}),(0,W.jsx)(fU,{}),(0,W.jsx)(`div`,{className:U(`space-y-3 border-t border-border pt-4`,r?``:`text-center`),children:r?(0,W.jsx)(qb,{}):(0,W.jsx)(J,{size:`sm`,variant:`ghost`,"data-testid":`use-password`,onClick:()=>n(!0),children:`Use an email and password instead`})})]})})}function mU(){let{state:e,actions:t}=G(),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let e=()=>u.current?.focus();e();let t=setTimeout(e,60);return()=>clearTimeout(t)},[]),(0,W.jsxs)(`div`,{className:`flex min-h-screen items-center justify-center bg-surface-1 p-6`,"data-testid":`locked-view`,onMouseDown:()=>u.current?.focus(),children:[(0,W.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),!n||o)return;s(!0),l(null);let a=null;t.unlock(n,{keepUnlocked:i,onError:e=>{a=e}}).then(e=>{s(!1),e?r(``):l(a??`Wrong password — the vault stays locked.`)})},className:`w-full max-w-sm space-y-4 text-center`,children:[(0,W.jsx)(q.Lock,{className:`mx-auto h-10 w-10 text-fg-faint`}),(0,W.jsx)(`h1`,{className:`text-lg font-semibold`,children:`This device is locked`}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`The vault, your keys and every session on this PC stay unreadable until you unlock — with your account password here, or remotely from another of your devices.`}),(0,W.jsx)(`input`,{ref:u,type:`password`,className:X,value:n,onChange:e=>r(e.target.value),onMouseDown:e=>e.stopPropagation(),placeholder:`Account password`,autoFocus:!0,"data-testid":`locked-password`}),(0,W.jsxs)(`label`,{className:`flex items-start justify-center gap-2 text-sm text-fg-muted`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:i,onChange:e=>a(e.target.checked),"data-testid":`locked-keep-unlocked`}),(0,W.jsx)(`span`,{children:`Keep me unlocked on this PC`})]}),c?(0,W.jsx)(`div`,{className:`text-sm text-danger`,"data-testid":`locked-error`,children:c}):null,(0,W.jsx)(J,{type:`submit`,variant:`primary`,busy:o,disabled:!n,children:`Unlock`}),(0,W.jsxs)(`div`,{className:`text-xs text-fg-faint`,children:[`Signed in as `,e.account?.email??`this account`,` ·`,` `,(0,W.jsx)(`button`,{type:`button`,className:`underline hover:text-fg`,onClick:()=>void t.logout(),children:`Sign out`})]})]}),(0,W.jsx)(rU,{})]})}function hU(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function gU(e,t,n){let r=hU(n),i=e.filter(e=>!t.has(e.id)).sort((e,t)=>t.mtime-e.mtime),a=[],o=[];for(let e of i)(e.mtime>=r?a:o).push(e);return{today:a,older:o}}function _U(e,t){let n=t.trim().toLowerCase();return n===``||e.toLowerCase().includes(n)}var vU=`flex w-full items-center gap-1 rounded px-2 py-1 text-left text-[11px] font-semibold uppercase tracking-wide text-fg-faint hover:bg-surface-2`,yU=`flex items-center gap-1 px-2 pb-0.5 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,bU=`flex w-full items-center gap-1.5 rounded border-l-2 border-project/70 bg-surface-2/40 px-2 py-1.5 text-left text-[13px] font-semibold tracking-normal text-fg hover:bg-surface-2`,xU=`flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-2`;function SU(){let{state:e,actions:t}=G(),n=e.ui.sidebarPinnedOverride??e.prefs.sidebarPinned,[r,i]=(0,v.useState)(yV),[a,o]=(0,v.useState)({}),[s,c]=(0,v.useState)(!1),l=RF(),[u,d]=(0,v.useState)(null),f=(0,v.useCallback)(()=>d(null),[]),p=kU(),m=qF(),h=hU(m),g=e.prefs.sidebarView,_=e.prefs.pinned,y=e=>o(t=>({...t,[e]:t[e]!==!0})),b=e=>a[e]===!0,x=e.prefs.collapsedProjects,S=e=>x.includes(e),C=e=>{let n=S(e)?x.filter(t=>t!==e):[...x,e];t.savePrefs({collapsedProjects:n})},w=(0,v.useCallback)(e=>{t.selectSession(e),window.innerWidth<768&&t.setSidebar(!1)},[t]),T=(0,v.useCallback)(e=>{t.openPage({kind:`project`,projectId:e}),window.innerWidth<768&&t.setSidebar(!1)},[t]),E=e.search.trim()!==``,D=(0,v.useMemo)(()=>{let t=e.sessions.filter(t=>!e.remote.tabs[t.id]);if(!E)return t;let n=Date.now();return t.filter(t=>CV(t,e.search,r,n))},[e.sessions,e.remote.tabs,e.search,E,r]),O=(0,v.useMemo)(()=>{let t=new Map(D.map(e=>[e.id,e])),n=[];for(let r of _)if(r.kind===`chat`){let i=t.get(r.id)??(E?void 0:e.pinnedRows[r.id]);i&&!e.remote.tabs[i.id]&&n.push({kind:`chat`,session:i})}else{let t=e.vaultProjects.find(e=>e.id===r.id);if(!t||!_U(t.name,E?e.search:``))continue;let i=e.sessions.filter(e=>e.projectId===t.id);n.push({kind:`project`,project:t,sessions:i})}return n},[_,D,E,e.search,e.pinnedRows,e.remote.tabs,e.vaultProjects,e.sessions]),k=(0,v.useMemo)(()=>new Set(_.filter(e=>e.kind===`chat`).map(e=>e.id)),[_]),A=(0,v.useMemo)(()=>g===`recent`?gU(D,k,h):null,[g,D,k,h]),j=(0,v.useMemo)(()=>new Map(e.vaultProjects.map(e=>[e.id,e.name])),[e.vaultProjects]),M=(0,v.useMemo)(()=>{if(g!==`projects`)return[];let t=new Map;for(let n of e.vaultProjects)t.set(n.id,{name:n.name,sessions:[]});let n=[];for(let e of D){let r=e.projectId?t.get(e.projectId):void 0;r?r.sessions.push(e):n.push(e)}let r=[...t.entries()].map(([e,t])=>({key:e,name:t.name,projectId:e,sessions:t.sessions.slice().sort((e,t)=>t.mtime-e.mtime)}));return r.sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`})),(n.length>0||r.length===0)&&r.push({key:`none`,name:`No project`,projectId:null,sessions:n.slice().sort((e,t)=>t.mtime-e.mtime)}),E?r.filter(e=>e.sessions.length>0):r},[g,e.vaultProjects,D,E]),ee=e=>{t.savePrefs({collapsedProjects:e?M.map(e=>e.key):[]})},N=(0,v.useMemo)(()=>e.remote.hosts.filter(e=>!e.isSelf),[e.remote.hosts]),P=()=>{let e=b(`remote`);y(`remote`),e&&t.refreshHosts()},F=e=>{t.setSearch(e),t.refreshSessions(e)},[I,te]=(0,v.useState)(!1),[ne,re]=(0,v.useState)(0),L=(0,v.useRef)(null),[ie,R]=(0,v.useState)(!1),[ae,oe]=(0,v.useState)(``),se=r.mode===`conversations`,ce=se?ae:e.search,le=I||ce!==``||ie;(0,v.useEffect)(()=>{I&&L.current?.focus()},[I,ne]),(0,v.useEffect)(()=>{let e=e=>{!(e.ctrlKey||e.metaKey)||e.shiftKey||e.altKey||(e.key===`k`||e.key===`K`)&&window.oonacode?.host!==`vscode`&&(e.preventDefault(),te(!0),re(e=>e+1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let ue=()=>{e.search!==``&&F(``),oe(``),R(!1),te(!1)},de=t=>{t.mode!==r.mode&&(t.mode===`conversations`?(oe(e.search),e.search!==``&&F(``)):(ae!==``&&F(ae),oe(``))),i(t)},fe=D.length,pe=e=>{e!==g&&t.savePrefs({sidebarView:e})},me=e.page,he={onOpen:w,onMenu:l.openMenu,clock:m},ge=!e.sessionsLoading&&fe===0&&!e.sessionsError?(0,W.jsx)(`div`,{className:`px-3 py-3 text-center text-xs text-fg-faint`,"data-testid":`sessions-empty`,children:E?`No sessions match.`:`No sessions yet — press + to start one.`}):null;return(0,W.jsxs)(`nav`,{className:`flex h-full w-full flex-col bg-surface`,"aria-label":`Sessions`,children:[(0,W.jsxs)(`div`,{className:`relative flex flex-wrap items-center justify-end gap-x-2 gap-y-1 border-b border-border p-2`,children:[(0,W.jsx)(Y,{label:`Search chats (Ctrl+K)`,onClick:()=>{te(!0),re(e=>e+1)},"data-testid":`open-search`,children:(0,W.jsx)(q.Search,{})}),(0,W.jsx)(`span`,{className:`flex-1`}),le?(0,W.jsxs)(`div`,{className:`absolute inset-0 z-10 flex items-center gap-1 bg-surface px-2`,"data-testid":`sidebar-search`,children:[(0,W.jsxs)(`div`,{className:`relative flex-1`,children:[(0,W.jsx)(q.Search,{className:`pointer-events-none absolute left-2 top-2 w-3.5 h-3.5 text-fg-faint`}),(0,W.jsx)(`input`,{ref:L,"aria-label":`Search sessions`,className:U(X,`pl-7`),placeholder:se?`Search every chat`:`Search chats`,value:ce,onChange:e=>se?oe(e.target.value):F(e.target.value),onBlur:()=>{ce===``&&!ie&&te(!1)},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ue())}})]}),(0,W.jsxs)(Y,{label:ie?`Hide search options`:`Search options`,className:U(`relative`,ie&&`text-accent`),"aria-pressed":ie,onMouseDown:e=>e.preventDefault(),onClick:()=>R(e=>!e),"data-testid":`search-options-toggle`,children:[(0,W.jsx)(q.Sliders,{}),xV(r)?(0,W.jsx)(`span`,{className:`absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-accent`,"data-testid":`search-options-dot`}):null]}),(0,W.jsx)(Y,{label:`Close search`,onMouseDown:e=>e.preventDefault(),onClick:ue,"data-testid":`close-search`,children:(0,W.jsx)(q.X,{})})]}):null,le&&ie?(0,W.jsx)(OV,{options:r,onChange:de,projects:e.vaultProjects,onClose:()=>{R(!1),L.current?.focus()}}):null,(0,W.jsx)(Y,{label:`Refresh sessions`,onClick:()=>{t.refreshSessions(),t.refreshHosts()},children:(0,W.jsx)(q.Refresh,{className:e.sessionsLoading?`spin`:``})}),e.account?.loggedIn?(0,W.jsx)(Y,{label:`Import chats from your other coding agents`,onClick:()=>t.openDialog(`import-claude`),"data-testid":`open-import-claude`,children:(0,W.jsx)(q.Download,{})}):null,e.account?.loggedIn?(0,W.jsx)(Y,{label:`Export my chats`,onClick:()=>t.openDialog(`export-chats`),"data-testid":`open-export-chats`,children:(0,W.jsx)(q.Upload,{})}):null,g===`projects`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Y,{label:`Collapse all projects`,onClick:()=>ee(!0),"data-testid":`projects-collapse-all`,children:(0,W.jsx)(q.CollapseAll,{})}),(0,W.jsx)(Y,{label:`Expand all projects`,onClick:()=>ee(!1),"data-testid":`projects-expand-all`,children:(0,W.jsx)(q.ExpandAll,{})})]}):null,(0,W.jsx)(Y,{label:`Conversations — what your chats send each other`,onClick:()=>t.openConversations(),"data-testid":`open-conversations`,children:(0,W.jsx)(q.Chats,{})}),(0,W.jsx)(Y,{label:`What your chats are about — each chat’s about and what it cost`,onClick:()=>t.openChatAbouts(),"data-testid":`open-chat-abouts`,children:(0,W.jsx)(q.Info,{})}),(0,W.jsx)(Y,{label:n?`Hide the session list — it slides in when the pointer reaches the left edge`:`Pin the session list beside the chat`,className:U(`hidden md:inline-flex`,n?`text-accent`:`text-fg-muted`),"aria-pressed":n,onClick:()=>t.toggleSidebarPinned(),"data-testid":`sidebar-pin`,children:(0,W.jsx)(q.Pin,{})})]}),(0,W.jsx)(CU,{clock:m}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1 pb-2`,children:se&&ae.trim()!==``?(0,W.jsx)(AV,{query:ae,options:r}):(0,W.jsxs)(W.Fragment,{children:[O.length>0?(0,W.jsxs)(`div`,{className:`mb-1`,"data-testid":`section-pinned`,children:[(0,W.jsx)(`div`,{className:yU,children:(0,W.jsx)(`span`,{children:`Pinned`})}),O.map(t=>t.kind===`chat`?(0,W.jsx)(IF,{session:t.session,active:t.session.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.session.id]??null,menuOpen:l.menuFor===t.session.id,kindIcon:!0,testIdPrefix:`pinned-session`,...he},`chat:${t.session.id}`):(0,W.jsx)(EU,{project:t.project,sessions:t.sessions,active:me?.kind===`project`&&me.projectId===t.project.id,onOpen:T,onMenu:(e,n)=>d({target:{projectId:t.project.id,foldKey:null},at:e,el:n})},`project:${t.project.id}`))]}):null,(0,W.jsxs)(`div`,{className:`mb-1`,"data-testid":`sessions-local`,children:[e.sessionsError?(0,W.jsx)(`div`,{className:`px-2 py-2 text-xs text-danger`,children:e.sessionsError}):null,A?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{"data-testid":`section-today`,children:[(0,W.jsxs)(`div`,{className:yU,children:[(0,W.jsx)(`span`,{children:`Today`}),(0,W.jsx)(`span`,{className:`font-normal normal-case`,children:A.today.length||``}),(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(TU,{view:g,onChange:pe})]}),ge??(A.today.length===0?(0,W.jsx)(`div`,{className:`px-3 py-1 text-xs text-fg-faint`,"data-testid":`today-empty`,children:E?`Nothing from today matches.`:`Nothing yet today.`}):A.today.map(t=>(0,W.jsx)(IF,{session:t,active:t.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.id]??null,menuOpen:l.menuFor===t.id,projectName:t.projectId?j.get(t.projectId)??null:null,...he},t.id)))]}),A.older.length>0?(0,W.jsxs)(`div`,{"data-testid":`section-older`,children:[(0,W.jsxs)(`div`,{className:yU,children:[(0,W.jsx)(`span`,{children:`Older`}),(0,W.jsx)(`span`,{className:`font-normal normal-case`,children:A.older.length})]}),A.older.map(t=>(0,W.jsx)(IF,{session:t,active:t.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.id]??null,menuOpen:l.menuFor===t.id,projectName:t.projectId?j.get(t.projectId)??null:null,...he},t.id))]}):null]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:yU,"data-testid":`section-by-project`,children:[(0,W.jsx)(`span`,{children:`By project`}),(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(TU,{view:g,onChange:pe})]}),ge,M.map(n=>{let r=`local:${n.key}`;return(0,W.jsxs)(`div`,{className:`mb-1 pl-2`,"data-testid":`project-group-${n.key}`,children:[(0,W.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,W.jsx)(AU,{group:n,collapsed:S(n.key),onToggle:()=>C(n.key),onMenu:(e,t)=>d({target:{projectId:n.projectId,foldKey:n.key},at:e,el:t}),menuOpen:u?.target.foldKey===n.key}),n.projectId?(0,W.jsxs)(`div`,{className:`absolute right-1 hidden items-center rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:[(0,W.jsx)(Y,{label:`Settings of ${n.name}`,className:`p-1`,"data-testid":`project-settings-${n.key}`,onClick:e=>{e.stopPropagation(),t.openProjectSettings(n.projectId)},children:(0,W.jsx)(q.Settings,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(Y,{label:`New chat in ${n.name}`,className:`p-1`,"data-testid":`project-new-chat-${n.key}`,onClick:e=>{e.stopPropagation(),t.newTab({projectId:n.projectId})},children:(0,W.jsx)(q.Plus,{className:`w-3.5 h-3.5`})})]}):null]}),S(n.key)?null:n.sessions.map(t=>(0,W.jsx)(IF,{session:t,active:t.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.id]??null,menuOpen:l.menuFor===t.id,...he},t.id))]},r)})]})]}),(0,W.jsxs)(`div`,{className:`mb-1`,"data-testid":`sessions-remote`,children:[(0,W.jsxs)(`button`,{type:`button`,className:vU,onClick:P,"aria-expanded":!b(`remote`),children:[(0,W.jsx)(q.Chevron,{open:!b(`remote`),className:`w-3 h-3`}),(0,W.jsx)(q.Globe,{className:`w-3 h-3`}),(0,W.jsx)(`span`,{className:`truncate`,children:`Remote`}),(0,W.jsx)(`span`,{className:`ml-auto font-normal`,children:N.length})]}),b(`remote`)?null:(0,W.jsxs)(W.Fragment,{children:[!e.remote.supported||e.remote.reason===`logged_out`?(0,W.jsx)(`div`,{className:`px-3 py-3 text-xs text-fg-faint`,children:`Sign in to see the sessions of your other devices.`}):N.length===0?(0,W.jsx)(`div`,{className:`px-3 py-3 text-xs text-fg-faint`,children:e.remote.loading?`Looking for your other devices…`:`No other devices yet.`}):null,N.map(e=>(0,W.jsx)(DU,{host:e,collapsed:b(`host:${e.hostId}`)||a[`host:${e.hostId}`]===void 0,onToggle:()=>{let n=`host:${e.hostId}`,r=a[n]===void 0||a[n]===!0;o(e=>({...e,[n]:!r})),r&&t.refreshHostSessions(e.hostId)}},e.hostId))]})]})]})}),(0,W.jsx)(`div`,{className:`shrink-0 border-t border-border px-3 py-2 text-[11px] text-fg-faint`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`button`,{type:`button`,"data-testid":`app-version`,title:`What's new in this version`,className:`truncate hover:text-fg hover:underline`,onClick:()=>t.openDialog(`whats-new`),children:[`OonaCode Desktop v`,p]}),(0,W.jsx)(Y,{label:`Lock this device — vault and sessions`,className:`p-1`,"data-testid":`lock-device`,onClick:()=>c(!0),children:(0,W.jsx)(q.Lock,{className:`h-3.5 w-3.5`})})]})}),(0,W.jsx)(nx,{open:u!==null,at:u?.at??{x:0,y:0},anchorEl:u?.el??null,label:`Project actions`,testId:`project-context-menu`,onClose:f,items:u?zF({projectId:u.target.projectId,pinned:u.target.projectId!==null&&Xc(_,`project`,u.target.projectId),fold:u.target.foldKey===null?null:{collapsed:S(u.target.foldKey),onToggle:()=>C(u.target.foldKey)},actions:t}):[]}),l.element,(0,W.jsx)(Xy,{open:s,title:`Lock this device?`,confirmLabel:`Lock`,message:`Every chat closes and nothing on this PC can be read or run until you unlock — here with your password, or remotely from another device.`,onConfirm:()=>void t.lockDevice(),onClose:()=>c(!1)})]})}function CU({clock:e}){let{state:t,actions:n}=G(),[r,i]=(0,v.useState)(null),a=(0,v.useCallback)(()=>i(null),[]),o=t.page,s=()=>{window.innerWidth<768&&n.setSidebar(!1)};return(0,W.jsxs)(`div`,{className:`shrink-0 border-b border-border px-1 py-1`,"data-testid":`sidebar-nav`,children:[(0,W.jsxs)(`div`,{className:`flex items-center rounded-md hover:bg-surface-2`,children:[(0,W.jsxs)(`button`,{type:`button`,className:U(xU,`flex-1 hover:bg-transparent`),title:`New chat (Ctrl+T)`,onClick:()=>{n.newTab(),s()},"data-testid":`sidebar-new`,children:[(0,W.jsx)(q.Edit,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,W.jsx)(`span`,{children:`New`})]}),(0,W.jsx)(Y,{label:`Start a new chat or a new project`,className:`mr-1 p-1`,"aria-haspopup":`menu`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();i({at:{x:t.left,y:t.bottom+2},el:e.currentTarget})},"data-testid":`sidebar-new-menu`,children:(0,W.jsx)(q.Chevron,{open:!0,className:`w-3.5 h-3.5`})})]}),(0,W.jsxs)(`button`,{type:`button`,className:U(xU,`w-full`,o?.kind===`projects`||o?.kind===`project`?`bg-surface-2 font-medium`:``),"aria-current":o?.kind===`projects`?`page`:void 0,onClick:()=>{n.openPage({kind:`projects`}),s()},"data-testid":`open-projects`,children:[(0,W.jsx)(q.Project,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,W.jsx)(`span`,{children:`Projects`})]}),(0,W.jsx)(wU,{clock:e,active:o?.kind===`scheduled`,onOpen:()=>{n.openPage({kind:`scheduled`}),s()}}),(0,W.jsx)(nx,{open:r!==null,at:r?.at??{x:0,y:0},anchorEl:r?.el??null,label:`New`,testId:`sidebar-new-context-menu`,onClose:a,items:[{key:`chat`,label:`New chat`,hint:`Ctrl+T`,icon:(0,W.jsx)(q.Chats,{className:`w-3.5 h-3.5`}),onSelect:()=>{n.newTab(),s()},testId:`sidebar-new-chat`},{key:`project`,label:`New project…`,icon:(0,W.jsx)(q.Project,{className:`w-3.5 h-3.5`}),onSelect:()=>n.openNewProject(),testId:`sidebar-new-project`}]})]})}function wU({clock:e,active:t,onOpen:n}){let{tasks:r}=KF(),i=(0,v.useMemo)(()=>r?nI(r,e):null,[r,e]);return(0,W.jsxs)(`button`,{type:`button`,className:U(xU,`w-full`,t?`bg-surface-2 font-medium`:``),"aria-current":t?`page`:void 0,onClick:n,title:i?.text??`Every scheduled task on this PC`,"data-testid":`open-scheduled`,children:[(0,W.jsx)(q.Clock,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,W.jsx)(`span`,{className:`flex-1`,children:`Scheduled`}),i?(0,W.jsx)(`span`,{className:U(`mr-1 inline-block h-2 w-2 shrink-0 rounded-full`,i.tone===`stuck`?`bg-warn`:`bg-accent`),"aria-label":i.text,"data-testid":`scheduled-dot`,"data-tone":i.tone}):null]})}function TU({view:e,onChange:t}){let[n,r]=(0,v.useState)(null),i=(0,v.useCallback)(()=>r(null),[]),a=e=>e?(0,W.jsx)(q.Check,{className:`w-3.5 h-3.5 text-accent`}):(0,W.jsx)(`span`,{className:`w-3.5`});return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Y,{label:`How the list is laid out`,className:`p-0.5 normal-case`,"aria-haspopup":`menu`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();r({at:{x:t.left,y:t.bottom+2},el:e.currentTarget})},"data-testid":`sidebar-view-options`,children:(0,W.jsx)(q.Sliders,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(nx,{open:n!==null,at:n?.at??{x:0,y:0},anchorEl:n?.el??null,label:`How the list is laid out`,testId:`sidebar-view-menu`,onClose:i,items:[{key:`recent`,label:`Recent — Today, then Older`,icon:a(e===`recent`),onSelect:()=>t(`recent`),testId:`sidebar-view-recent`},{key:`projects`,label:`By project`,icon:a(e===`projects`),onSelect:()=>t(`projects`),testId:`sidebar-view-projects`}]})]})}function EU({project:e,sessions:t,active:n,onOpen:r,onMenu:i}){let a=(0,v.useRef)(null),o=e.sessionCount??t.length;return(0,W.jsxs)(`div`,{ref:a,className:U(`group relative flex items-center rounded-md`,n?`bg-accent-soft`:`hover:bg-surface-2`),onContextMenu:e=>{e.preventDefault(),i({x:e.clientX,y:e.clientY},a.current)},children:[(0,W.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 py-1.5 pl-2 pr-8 text-left`,"aria-current":n?`page`:void 0,title:`Open ${e.name}`,onClick:()=>r(e.id),"data-testid":`pinned-project-${e.id}`,children:[(0,W.jsx)(q.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.name}),(0,W.jsx)(jF,{sessions:t,testId:`pinned-project-busy-${e.id}`}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-3 px-1.5 py-px text-[10px] font-semibold text-fg-muted`,children:o})]}),(0,W.jsx)(Y,{label:`Project actions`,className:`pointer-events-none absolute right-1 bg-surface/90 p-1 opacity-0 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100`,"data-testid":`pinned-project-menu-${e.id}`,onClick:e=>{e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();i({x:t.left,y:t.bottom+2},a.current)},children:(0,W.jsx)(q.More,{className:`w-3.5 h-3.5`})})]})}function DU({host:e,collapsed:t,onToggle:n}){let{state:r,actions:i}=G(),a=e.label||e.hostName,o=r.remote.sessions[e.hostId],s=r.remote.unreachable[e.hostId],c=s?mf(s.reason,a,s.detail):null,[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),p=e.remoteAccessOff===!0;return(0,W.jsxs)(`div`,{className:`mb-1 pl-2`,"data-testid":`remote-host-${e.hostId}`,children:[(0,W.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,W.jsxs)(`button`,{type:`button`,className:vU,onClick:n,"aria-expanded":!t,title:e.online?`${a} — online`:`${a} — offline: its chats can be read while it is online`,children:[(0,W.jsx)(q.Chevron,{open:!t,className:`w-3 h-3`}),(0,W.jsx)(`span`,{className:U(`inline-block h-2 w-2 shrink-0 rounded-full`,e.online?`bg-ok`:`bg-fg-faint`),"aria-label":e.online?`online`:`offline`}),(0,W.jsx)(`span`,{className:`truncate normal-case`,children:a}),p?(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-warn-soft px-1.5 text-[10px] font-normal normal-case text-warn`,"data-testid":`remote-off-${e.hostId}`,children:`remote access off`}):null,(0,W.jsx)(`span`,{className:`ml-auto font-normal`,children:!p&&o?o.length:``})]}),(0,W.jsxs)(`div`,{className:`absolute right-1 hidden items-center rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:[(0,W.jsx)(Y,{label:p?pf(a):e.online?`New chat on ${a}`:`${a} is offline — a new chat has to start on a PC that is awake`,className:`p-1`,disabled:!e.online||p,"data-testid":`remote-new-chat-${e.hostId}`,onClick:()=>void i.newRemoteTab(e.hostId),children:(0,W.jsx)(q.Plus,{className:`w-3 h-3`})}),(0,W.jsx)(Y,{label:`Unlock this device`,className:`p-1`,disabled:p,"data-testid":`remote-unlock-${e.hostId}`,onClick:()=>u(`unlock`),children:(0,W.jsx)(q.Lock,{className:`w-3 h-3`})}),(0,W.jsx)(Y,{label:`Rename device`,className:`p-1`,onClick:()=>u(`rename`),children:(0,W.jsx)(q.Edit,{className:`w-3 h-3`})})]}),(0,W.jsx)(Zy,{open:l===`unlock`,title:`Unlock "${a}" remotely`,label:`Your account password — it never leaves this PC: the keys are sealed to that device and the server cannot read them.`,password:!0,submitLabel:`Unlock`,onSubmit:t=>void i.remoteUnlockHost(e.hostId,t),onClose:()=>u(null)}),(0,W.jsx)(Zy,{open:l===`rename`,title:`Rename device`,label:`Device name`,initialValue:a,onSubmit:t=>{t!==a&&i.renameHost(e.hostId,t)},onClose:()=>u(null)})]}),!t&&p?(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-warn`,"data-testid":`remote-off-note-${e.hostId}`,children:pf(a)}):t?null:o===void 0?(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-faint`,children:`Loading…`}):o.length===0&&c?(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-warn`,"data-testid":`remote-unreachable-${e.hostId}`,children:c}):o.length===0?(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-faint`,children:`No sessions on this device.`}):o.map(t=>(0,W.jsx)(OU,{host:e,session:t,active:t.id===r.currentSessionId&&r.page===null,onConfirmDelete:()=>f(t)},t.id)),(0,W.jsx)(Xy,{open:d!==null,title:`Delete this chat?`,message:`It is deleted on ${e.hostName} — the only place it is kept — so it is gone from every device. Files, folders and code on that PC are not touched — only the chat is deleted.`,onConfirm:()=>{d&&i.deleteRemoteSession(e.hostId,d.id)},onClose:()=>f(null)})]})}function OU({host:e,session:t,active:n,onConfirmDelete:r}){let{actions:i}=G(),a=pg(t);return(0,W.jsxs)(`div`,{className:U(`group flex items-center rounded-md`,n?`bg-accent-soft`:`hover:bg-surface-2`),children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{i.openRemoteSession(e.hostId,t.id),window.innerWidth<768&&i.setSidebar(!1)},className:`flex min-w-0 flex-1 items-center gap-2 px-2 py-1.5 text-left`,"aria-current":n?`true`:void 0,"data-testid":`remote-session-${t.id}`,title:e.online?void 0:`Read-only until that PC is online`,children:[(0,W.jsx)(kF,{status:t.status}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:U(`truncate text-sm`,n?`font-medium`:``),children:a}),(0,W.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[ag(t.updatedAt),t.model?` · ${t.model}`:``,e.online?``:` · read-only`]})]})]}),(0,W.jsx)(`div`,{className:`mr-1 hidden items-center gap-0.5 rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:(0,W.jsx)(Y,{label:e.online?`Delete this chat`:`That PC is asleep — a chat can only be deleted while the PC that holds it is online`,className:`p-1 hover:text-danger disabled:opacity-40`,disabled:!e.online,"data-testid":`remote-session-delete-${t.id}`,onClick:()=>{r()},children:(0,W.jsx)(q.Trash,{className:`w-3.5 h-3.5`})})})]})}function kU(){let{state:e}=G(),t=typeof window<`u`?window.oonacode:void 0;return Gv(t?.appVersion??e.bundleAppVersion??e.connection.appVersion??e.info?.appVersion??`0.0.0`,Wv({bridge:t,info:e.info}))}function AU({group:e,collapsed:t,onToggle:n,onMenu:r,menuOpen:i=!1}){let a=(0,v.useRef)(null),o=(0,v.useRef)(null),[s,c]=(0,v.useState)(null),l=(0,v.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null),c(null)},[]),u=(0,v.useRef)(i);return u.current=i,(0,v.useEffect)(()=>{i&&l()},[i,l]),(0,v.useEffect)(()=>{if(s===null)return;let e=e=>{ex(e.target,a.current)&&l()};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[s,l]),(0,v.useEffect)(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`button`,{ref:a,type:`button`,className:bU,onClick:()=>{l(),n()},onMouseEnter:()=>{o.current!==null&&clearTimeout(o.current),!u.current&&(o.current=setTimeout(()=>{o.current=null,a.current&&!u.current&&c(a.current.getBoundingClientRect())},450))},onMouseLeave:l,onContextMenu:e=>{e.preventDefault(),l(),r({x:e.clientX,y:e.clientY},a.current)},"aria-expanded":!t,"data-testid":`project-header-${e.key}`,children:[(0,W.jsx)(q.Chevron,{open:!t,className:`w-3 h-3 shrink-0`}),(0,W.jsx)(q.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.name}),(0,W.jsx)(jF,{sessions:e.sessions,testId:`project-busy-${e.key}`}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-surface-3 px-1.5 py-px text-[10px] font-semibold normal-case tracking-normal text-fg-muted`,"data-testid":`project-count-${e.key}`,children:e.sessions.length})]}),s===null?null:(0,W.jsx)(jU,{group:e,anchor:s})]})}function jU({group:e,anchor:t}){let{state:n}=G(),r=e.projectId?n.vaultProjects.find(t=>t.id===e.projectId):void 0,i=e.sessions.filter(e=>e.status===`running`||e.status===`waiting_permission`).length,a=e.sessions.reduce((e,t)=>e===null||t.updatedAt>e?t.updatedAt:e,null),o=[...new Set(e.sessions.map(e=>e.projectDir??e.cwd).filter(e=>typeof e==`string`&&e.length>0))],s=r?.instructions?.trim()??``,c=Math.max(8,Math.min(t.right+8,window.innerWidth-304-8)),l=Math.max(8,Math.min(t.top,window.innerHeight-320));return(0,Ly.createPortal)((0,W.jsxs)(`div`,{role:`tooltip`,"data-testid":`project-details-${e.key}`,className:`fixed z-50 max-h-[20rem] w-[19rem] overflow-y-auto rounded-lg border border-border bg-surface p-3 text-xs shadow-lg`,style:{left:c,top:l},children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5`,children:[(0,W.jsx)(q.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,W.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.name})]}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(NF,{label:`Chats`,value:String(e.sessions.length)}),(0,W.jsx)(NF,{label:`Working now`,value:i>0?String(i):null}),(0,W.jsx)(NF,{label:`Last activity`,value:a?ag(a):null}),(0,W.jsx)(NF,{label:o.length>1?`Folders`:`Folder`,value:o.length>1?`${o.length} folders`:o[0]??null})]}),e.projectId?(0,W.jsxs)(`div`,{className:`mt-2 border-t border-border pt-2`,children:[(0,W.jsx)(`div`,{className:`mb-1 text-fg-faint`,children:`Standing instructions`}),s?(0,W.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-fg`,"data-testid":`project-instructions-${e.key}`,children:s.length>400?`${s.slice(0,400)}…`:s}):(0,W.jsx)(`div`,{className:`text-fg-faint`,children:`None — chats here start with nothing extra.`})]}):(0,W.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 text-fg-faint`,children:`Chats filed under no project.`})]}),document.body)}function MU(){return ey(typeof window<`u`?window.oonacode:void 0)}function NU(e){if(e.upToDate)return`Everything on this PC is up to date — the app, the host service and the oona CLI.`;let t=[];return e.terminal&&t.push(`OonaCode updates the oona CLI and the host service in place — the service restarts and your chats come back with it.`),e.desktop&&t.push(e.terminal?`Then it downloads the app, installs it and relaunches, restoring your open tabs.`:`OonaCode downloads the update, installs it and relaunches. Your open chat tabs are restored afterwards.`),t.length===0?t.push("This window cannot install updates by itself — run the installer again, or `oona update` in a terminal. Your open chat tabs are stored in the host and come back automatically."):e.manual.length>0&&t.push(e.manual.includes(`desktop`)?`The app itself needs the installer from the website.`:"The rest needs `oona update` in a terminal."),t.join(` `)}var PU=2*Math.PI*10;function FU(){return typeof window<`u`&&window.oonacode!==void 0}function IU(){let{state:e,actions:t}=G(),n=e.update,r=e.updateInstall,i=e.prefs.dismissedUpdateVersion,a=n.version!==``&&(e.updateDismissed===n.version||i===n.version);if(!FU())return null;let o=Yv({install:r,manifestAvailable:n.available&&!a}),s=e.terminalUpdate.running,c=e.updateChecking||r.phase===`checking`||s,l=n.components.length,u=Math.round(r.percent),d=s?`Updating the CLI and host service`:o===`ready`?`Restart to finish updating`:o===`downloading`?`Downloading update (${u}%)`:o===`available`?`Update available (${l})`:`Check for updates`,f=s?`Updating the oona CLI and the host service…`:o===`ready`?`An update is ready — restart to finish`:o===`downloading`?`Downloading OonaCode ${r.version||`update`} — ${u}%`:o===`available`?`${l} component${l===1?``:`s`} can be updated`:`Check for updates`;return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{if(o===`idle`){t.checkUpdates(!0);return}if(o===`ready`){t.installUpdate();return}t.openDialog(`update`)},title:f,"aria-label":d,"aria-busy":c||void 0,"data-testid":`update-badge`,"data-state":o,className:U(`relative inline-flex h-7 w-7 items-center justify-center rounded-full border transition-transform hover:scale-105`,o===`idle`?`border-border bg-surface-2 text-fg-muted hover:text-fg`:`border-accent bg-accent-soft text-accent`),children:[o===`downloading`?(0,W.jsxs)(`svg`,{viewBox:`0 0 24 24`,"data-testid":`update-badge-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":u,className:`absolute inset-0 h-full w-full -rotate-90`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,fill:`none`,strokeWidth:`2`,className:`stroke-border`}),(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:PU,strokeDashoffset:PU*(1-Math.max(0,Math.min(100,u))/100),className:`stroke-accent`})]}):null,c&&o!==`downloading`&&o!==`ready`?(0,W.jsx)(`span`,{"data-testid":`update-badge-checking`,className:`inline-flex`,children:(0,W.jsx)(q.Spinner,{className:`w-3.5 h-3.5`})}):o===`ready`?(0,W.jsx)(`span`,{"data-testid":`update-badge-ready`,className:`inline-flex`,children:(0,W.jsx)(q.Refresh,{className:`w-3.5 h-3.5`})}):o===`downloading`?(0,W.jsx)(`span`,{"data-testid":`update-badge-downloading`,className:`text-[9px] font-semibold`,children:u}):(0,W.jsx)(`span`,{"data-testid":o===`available`?`update-badge-available`:`update-badge-idle`,className:`inline-flex`,children:(0,W.jsx)(q.Download,{className:`w-3.5 h-3.5`})}),o===`available`?(0,W.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-accent`,"aria-hidden":!0}):null]})}function LU(){let{state:e,actions:t}=G(),n=e.updateInstall,r=Math.round(Math.max(0,Math.min(100,n.percent))),i=Qv(n.bytesPerSecond);if(n.phase===`error`)return(0,W.jsxs)(`div`,{className:`rounded-md border border-danger-soft bg-danger-soft px-3 py-2 text-xs text-danger`,"data-testid":`update-error`,role:`alert`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(q.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`font-medium`,children:`The update could not be downloaded.`}),(0,W.jsx)(`div`,{className:`mt-0.5 pre-wrap break-words`,children:n.error})]})]}),(0,W.jsx)(`div`,{className:`mt-2`,children:(0,W.jsxs)(J,{size:`sm`,onClick:()=>void t.installUpdate(),"data-testid":`update-retry`,children:[(0,W.jsx)(q.Refresh,{className:`w-3.5 h-3.5`}),` Try again`]})})]});let a=n.phase===`installing`;return(0,W.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`update-progress`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:a?`Installing and restarting…`:n.phase===`ready`?`Downloaded — restart to install`:`Downloading OonaCode ${n.version||``}`.trim()}),a?null:(0,W.jsxs)(`span`,{className:`text-fg-muted`,children:[r,`%`]})]}),n.notice?(0,W.jsx)(`div`,{className:`pre-wrap text-xs text-warn`,"data-testid":`update-notice`,role:`status`,children:n.notice}):null,(0,W.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-2`,children:(0,W.jsx)(`div`,{className:U(`h-full rounded-full bg-accent`,a&&`animate-pulse`),style:{width:`${a?100:r}%`},"data-testid":`update-progress-bar`})}),a?(0,W.jsx)(`div`,{className:`text-xs text-fg-faint`,children:`The host service stops for a few seconds while the installer runs, then OonaCode starts again with your chat tabs.`}):(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-fg-faint`,children:[(0,W.jsxs)(`span`,{children:[Zv(n.transferred),n.total>0?` of ${Zv(n.total)}`:``]}),i?(0,W.jsx)(`span`,{children:i}):null]})]})}function RU(){let{state:e,actions:t}=G(),n=e.terminalUpdate;return n.running?(0,W.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-border bg-surface-2 px-3 py-2 text-xs`,"data-testid":`terminal-update-running`,role:`status`,children:[(0,W.jsx)(q.Spinner,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`font-medium text-fg`,children:`Updating the oona CLI and host service...`}),(0,W.jsx)(`div`,{className:`mt-0.5 text-fg-faint`,children:`The host service stops for a few seconds while its installer runs. Your chats are in the database and come back with it.`})]})]}):n.failed?(0,W.jsxs)(`div`,{className:`rounded-md border border-danger-soft bg-danger-soft px-3 py-2 text-xs text-danger`,"data-testid":`terminal-update-error`,role:`alert`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(q.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`font-medium`,children:`The CLI and host service could not be updated.`}),(0,W.jsx)(`div`,{className:`mt-0.5 pre-wrap break-words`,children:n.message})]})]}),(0,W.jsx)(`div`,{className:`mt-2`,children:(0,W.jsxs)(J,{size:`sm`,onClick:()=>void t.installUpdate(),"data-testid":`terminal-update-retry`,children:[(0,W.jsx)(q.Refresh,{className:`w-3.5 h-3.5`}),` Try again`]})})]}):null}function zU({open:e,onClose:t}){let{state:n,actions:r}=G(),i=n.update,a=n.updateInstall,o=r.checkUpdates,s=a.phase===`downloading`||a.phase===`installing`||a.phase===`ready`;(0,v.useEffect)(()=>{!e||s||o(!1)},[e,s,o]);let c=MU(),l=ty(i.components.map(e=>e.component),c,{checked:i.version!==``,shellEngaged:a.phase!==`idle`&&a.phase!==`checking`}),u=i.version||a.version,d=a.phase===`ready`,f=a.phase===`downloading`||a.phase===`installing`||d||a.phase===`error`,p=n.terminalUpdate.running,m=n.updateChecking||a.phase===`checking`||p;return(0,W.jsx)(Ky,{open:e,title:`Update OonaCode`,onClose:t,footer:d?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{onClick:t,children:`Later`}),(0,W.jsxs)(J,{variant:`primary`,onClick:()=>void r.installUpdate(),"data-testid":`update-restart`,children:[(0,W.jsx)(q.Refresh,{className:`w-4 h-4`}),`Restart and install`]})]}):f?(0,W.jsx)(J,{onClick:t,children:`Close`}):l.upToDate?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(J,{onClick:()=>void r.checkUpdates(!0),busy:m,disabled:m,"data-testid":`update-check-again`,children:[(0,W.jsx)(q.Refresh,{className:`w-4 h-4`}),`Check again`]}),(0,W.jsx)(J,{variant:`primary`,onClick:t,children:`Close`})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{onClick:()=>r.dismissUpdate(),children:`Skip this version`}),(0,W.jsx)(J,{onClick:t,children:`Later`}),(0,W.jsxs)(J,{variant:`primary`,busy:m,disabled:m,onClick:()=>void r.installUpdate(),children:[(0,W.jsx)(q.Download,{className:`w-4 h-4`}),l.label]})]}),children:(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[u?(0,W.jsxs)(`span`,{className:`font-medium`,children:[`Release `,u]}):null,i.channel?(0,W.jsx)(Z,{children:i.channel}):null,n.updateChecking?(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,"data-testid":`update-rechecking`,children:`checking for a newer one…`}):null,i.publishedAt?(0,W.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`published `,new Date(i.publishedAt).toLocaleDateString()]}):null]}),f?(0,W.jsx)(LU,{}):null,(0,W.jsx)(RU,{}),i.components.length>0?(0,W.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:i.components.map(e=>(0,W.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2`,children:[(0,W.jsx)(q.Download,{className:`mt-0.5 w-3.5 h-3.5 shrink-0 text-accent`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,W.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[e.current,` → `,(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:e.latest})]}),(0,W.jsx)(`div`,{className:`text-xs text-fg-faint`,"data-testid":`update-how-${e.component}`,children:ny(e.component,c)}),e.notes?(0,W.jsx)(`div`,{className:`mt-0.5 pre-wrap text-xs text-fg-faint`,children:e.notes}):null]})]},e.component))}):null,i.notes?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Release notes`}),(0,W.jsx)(`div`,{className:`max-h-48 overflow-y-auto rounded-md bg-surface-2 px-3 py-2 pre-wrap text-xs text-fg-muted`,children:i.notes})]}):null,f?null:(0,W.jsx)(`p`,{className:`text-xs text-fg-faint`,"data-testid":`update-plan-note`,children:NU(l)})]})})}function BU(e){switch(e){case`open`:return{cls:`bg-ok`,label:`Connected`};case`connecting`:case`reconnecting`:return{cls:`bg-warn animate-pulse`,label:e===`connecting`?`Connecting…`:`Reconnecting…`};case`unauthorized`:return{cls:`bg-danger`,label:`Unauthorized`};case`closed`:return{cls:`bg-danger`,label:`Disconnected`};default:return{cls:`bg-fg-faint`,label:`Idle`}}}function VU(){let{state:e,actions:t}=G(),n=BU(e.connection.status),r=e.account?.loggedIn===!0,i=typeof window<`u`&&window.oonacode?.host===`vscode`;return(0,W.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-surface px-2 sm:px-3`,children:[i?null:(0,W.jsx)(Y,{label:`Toggle sidebar`,onClick:()=>{typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(min-width: 768px)`).matches?t.toggleSidebarPinned():t.setSidebar(!e.ui.sidebarOpen)},"data-testid":`toggle-sidebar`,children:(0,W.jsx)(q.PanelLeft,{})}),(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i?null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`font-semibold tracking-tight`,children:`OonaCode`}),(0,W.jsx)(`span`,{className:`hidden text-fg-faint sm:inline`,children:`/`})]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.openDialog(`session-picker`),title:`Open a session on this PC or another device`,className:`hidden min-w-0 truncate text-sm text-fg-muted hover:text-fg sm:inline`,"data-testid":`host-name`,children:e.connection.hostName??`host`}),(0,W.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-muted`,title:e.connection.detail??n.label,"data-testid":`connection-status`,children:[(0,W.jsx)(`span`,{className:U(`inline-block h-2 w-2 rounded-full`,n.cls),"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:n.label})]})]}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,W.jsx)(HU,{}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.openDialog(`bug-report`),title:`Bug Report...`,"aria-label":`Bug Report...`,"data-testid":`bug-report-button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-full border border-border bg-surface-2 text-fg-muted transition-transform hover:scale-105 hover:text-fg`,children:(0,W.jsx)(q.Bug,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(IU,{}),e.hostUpdatedTo?(0,W.jsxs)(J,{size:`sm`,variant:`primary`,onClick:()=>window.location.reload(),title:`This window still runs the previous version; the host is now v${e.hostUpdatedTo}`,"data-testid":`reload-for-update`,children:[`Reload for v`,e.hostUpdatedTo]}):null,r?null:(0,W.jsxs)(J,{size:`sm`,variant:`primary`,onClick:()=>t.openDialog(`account`),"data-testid":`sign-in`,children:[(0,W.jsx)(q.LogIn,{className:`w-3.5 h-3.5`}),` Sign in`]}),(0,W.jsx)(Y,{label:e.prefs.explorerOpen?`Hide files`:`Show files`,onClick:()=>void t.savePrefs({explorerOpen:!e.prefs.explorerOpen}),className:e.prefs.explorerOpen?`bg-surface-2 text-fg`:void 0,"data-testid":`toggle-explorer`,children:(0,W.jsx)(q.Folder,{})}),(0,W.jsx)(Y,{label:e.prefs.sessionPanelOpen?`Hide session info`:`Show session info`,onClick:()=>void t.savePrefs({sessionPanelOpen:!e.prefs.sessionPanelOpen}),className:e.prefs.sessionPanelOpen?`bg-surface-2 text-fg`:void 0,"data-testid":`toggle-session-panel`,children:(0,W.jsx)(q.Panel,{})}),(0,W.jsx)(Y,{label:`Doctor`,onClick:()=>t.openDialog(`doctor`),children:(0,W.jsx)(q.Stethoscope,{})}),r?(0,W.jsx)(UU,{}):null,(0,W.jsx)(Y,{label:`Account`,onClick:()=>t.openDialog(`account`),children:(0,W.jsxs)(`span`,{className:`relative`,children:[(0,W.jsx)(q.User,{}),r?(0,W.jsx)(`span`,{className:U(`absolute -right-0.5 -top-0.5 h-1.5 w-1.5 rounded-full`,e.account?.vaultUnlocked?`bg-ok`:`bg-warn`)}):null]})}),(0,W.jsx)(Y,{label:`Settings`,onClick:()=>t.openDialog(`settings`),children:(0,W.jsx)(q.Settings,{})})]})]})}function HU(){let{actions:e}=G(),[t,n]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=typeof window<`u`?window.oonacode:void 0;if(!e?.getDebugging)return;let t=!0;return e.getDebugging().then(e=>{t&&n(e.running)},()=>{}),()=>{t=!1}},[]),!t||!Cc(t))return null;let r=PH(t);return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>e.openSettings(`developer`),title:r,"aria-label":r,"data-testid":`debugging-badge`,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-red-600 px-2.5 text-[11px] font-semibold text-white hover:bg-red-700`,children:[(0,W.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-white`,"aria-hidden":!0}),`Debugging on`]})}function UU(){let{state:e}=G(),[t,n]=(0,v.useState)(!1),r=(0,v.useRef)(null),i=e.plan;(0,v.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[t]);let a=i?i.credits.balance:null,o=i?Dv(i):null,s=Av(i),c=jv;return(0,W.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,W.jsx)(Y,{label:s?`Credits and plan — ${s.text}`:`Credits and plan`,onClick:()=>n(e=>!e),"data-testid":`balance-badge`,className:t?`bg-surface-2 text-fg`:void 0,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(q.Coins,{}),a===null?null:(0,W.jsx)(`span`,{className:U(`hidden text-xs tabular-nums sm:inline`,s?s.level===`empty`?`text-danger`:`text-warn`:void 0),"data-testid":`balance-credits`,"data-level":s?.level??`ok`,children:c(a)})]})}),t?(0,W.jsx)(`div`,{className:`absolute right-0 top-full z-50 mt-1 w-64 rounded-md border border-border bg-surface p-3 text-sm shadow-lg`,"data-testid":`balance-popover`,children:i===null||o===null?(0,W.jsx)(`div`,{className:`text-fg-muted`,children:`Balance is unavailable — the gateway can't be reached.`}):(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:`Plan`}),(0,W.jsxs)(`span`,{className:`font-medium`,children:[i.planName,i.status===`none`?` (lapsed)`:``]})]}),(0,W.jsx)(`div`,{className:`h-px bg-border`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:`Credits`}),(0,W.jsx)(`span`,{className:`font-semibold tabular-nums`,children:c(o.balance)})]}),s?(0,W.jsx)(`div`,{className:U(`rounded-sm px-2 py-1 text-[11px]`,s.level===`empty`?`bg-danger-soft text-danger`:`bg-warn-soft text-warn`),"data-testid":`balance-warning`,children:s.text}):null,o.hasSplit?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:`Plan credits`}),(0,W.jsx)(`span`,{className:`tabular-nums`,children:c(o.plan??0)})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:`Top-up credits`}),(0,W.jsx)(`span`,{className:`tabular-nums`,children:c(o.topup??0)})]})]}):null,(0,W.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[i.credits.monthlyGrant>0?`Plan credits top up to ${c(i.credits.monthlyGrant)} each 30-day period and expire with it; top-ups never do.`:`This plan pays no monthly credits — the signup gift and anything you buy never expire.`,` `,`Free models never draw on this balance.`]})]})}):null]})}function WU(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error??Error(`could not read the file`)),r.onload=()=>{let e=typeof r.result==`string`?r.result:``,n=e.indexOf(`,`);t(n>=0?e.slice(n+1):``)},r.readAsDataURL(e)})}function GU(e,t){let n=[],r=e.length,i=e.reduce((e,t)=>e+t.size,0);for(let e of t){if(r>=5)return{accepted:n,refused:`At most 5 files per report.`};if(e.size>5242880)return{accepted:n,refused:`${e.name} is ${Zv(e.size)}; a file may be at most ${Zv(Xs)}.`};if(i+e.size>12582912)return{accepted:n,refused:`All files together may be at most ${Zv(Zs)}.`};n.push(e),r+=1,i+=e.size}return{accepted:n,refused:null}}function KU(e){return e instanceof hm?e.code===`account_required`||e.status===401?`Sign in to OonaCode first — a report is filed under your account so we can answer it.`:ym(e)?`This host build cannot send bug reports yet — update OonaCode on this PC.`:e.status===429?`Too many reports in a minute — wait a moment and send again.`:e.status===413?`The attachments are too large for one report.`:e.message||`The report could not be sent.`:e instanceof Error&&e.message?e.message:`The report could not be sent.`}var qU=0;function JU({open:e,onClose:t}){let{state:n,actions:r,api:i}=G(),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(!1),h=(0,v.useRef)(null);(0,v.useEffect)(()=>{e&&(o(``),c([]),u(!1),f(null))},[e]);let g=n.account?.loggedIn===!0,_=typeof i.sendBugReport==`function`,y=typeof window<`u`?window.oonacode:void 0,b=y?y.host===`vscode`?`vscode`:`desktop`:`browser`,x=n.currentSessionId?n.sessions.find(e=>e.id===n.currentSessionId)??null:null,S=(0,v.useCallback)(async e=>{let t=Array.from(e);if(t.length===0)return;let{accepted:n,refused:r}=GU(s,t);f(r);let i=t.filter(e=>n.includes(e));if(i.length!==0){m(!0);try{let e=[];for(let t of i){let n=await WU(t);if(!n)continue;let r=t.type||`application/octet-stream`;qU+=1,e.push({key:`f${qU}`,name:t.name,contentType:r,dataBase64:n,size:t.size,preview:r.startsWith(`image/`)?`data:${r};base64,${n}`:null})}c(t=>[...t,...e])}catch(e){f(e instanceof Error?e.message:`could not read the file`)}finally{m(!1)}}},[s]),C=e=>{let t=e.target.files;t&&S(t),e.target.value=``},w=e=>c(t=>t.filter(t=>t.key!==e)),T=async()=>{let e=a.trim();if(!e||l)return;if(!_){f(`This host build cannot send bug reports yet — update OonaCode on this PC.`);return}u(!0),f(null);let o={message:e.slice(0,Ys),...s.length>0?{attachments:s.map(({name:e,contentType:t,dataBase64:n})=>({name:e,contentType:t,dataBase64:n}))}:{},...n.currentSessionId?{sessionId:n.currentSessionId}:{},detail:{embedded:b,connection:n.connection.status,...y?.appVersion?{appVersion:y.appVersion}:{},...n.bundleAppVersion?{uiVersion:n.bundleAppVersion}:{},...n.info?.appVersion?{hostVersion:n.info.appVersion}:{},...n.info?.engine?.version?{engineVersion:n.info.engine.version}:{},...x?.status?{sessionStatus:x.status}:{}}};try{let e=await i.sendBugReport(o);r.toast(`success`,`Bug report #${e.id} sent — thank you.`),t()}catch(e){f(KU(e))}finally{u(!1)}},E=Ys-a.length;return(0,W.jsx)(Ky,{open:e,title:`Bug Report`,onClose:t,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{onClick:t,disabled:l,children:`Cancel`}),(0,W.jsxs)(J,{variant:`primary`,busy:l,disabled:!a.trim()||p,onClick:()=>void T(),"data-testid":`bug-report-send`,children:[(0,W.jsx)(q.Bug,{className:`w-4 h-4`}),`Send report`]})]}),children:(0,W.jsxs)(`div`,{className:`space-y-3 text-sm`,"data-testid":`bug-report-dialog`,children:[(0,W.jsxs)(`p`,{className:`text-fg-muted`,children:[`Tell us what went wrong and what you expected. Screenshots help. The report is filed under your account with this PC's versions`,x?` and the open chat’s model`:``,`; the chat itself is never sent.`]}),g?null:(0,W.jsx)(`div`,{className:`rounded-md border border-warn/40 bg-warn-soft px-3 py-2 text-xs text-warn`,children:`Sign in to OonaCode to send a report — it is filed under your account so we can answer it.`}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:`What happened?`}),(0,W.jsx)(`textarea`,{name:`message`,className:U(X,`min-h-32 resize-y`),value:a,maxLength:Ys,placeholder:`The answer stopped after a few seconds with “API error”. I was using…`,onChange:e=>o(e.target.value),"data-testid":`bug-report-message`}),(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,children:E<500?`${E} characters left`:``})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{ref:h,type:`file`,multiple:!0,className:`hidden`,onChange:C,"data-testid":`bug-report-files`}),(0,W.jsxs)(J,{size:`sm`,onClick:()=>h.current?.click(),disabled:l||p||s.length>=5,children:[(0,W.jsx)(q.Paperclip,{className:`w-3.5 h-3.5`}),`Attach files or pictures`]}),(0,W.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`up to `,5,` files,`,` `,Zv(Xs),` each`]})]}),s.length>0?(0,W.jsx)(`ul`,{className:`flex flex-wrap gap-2`,"data-testid":`bug-report-attachments`,children:s.map(e=>(0,W.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md border border-border bg-surface-2 px-2 py-1 text-xs`,children:[e.preview?(0,W.jsx)(`img`,{src:e.preview,alt:``,className:`h-8 w-8 rounded object-cover`,"aria-hidden":!0}):(0,W.jsx)(q.Paperclip,{className:`w-3.5 h-3.5 text-fg-muted`}),(0,W.jsx)(`span`,{className:`max-w-40 truncate`,title:e.name,children:e.name}),(0,W.jsx)(`span`,{className:`text-fg-faint`,children:Zv(e.size)}),(0,W.jsx)(Y,{label:`Remove ${e.name}`,onClick:()=>w(e.key),children:(0,W.jsx)(q.X,{className:`w-3.5 h-3.5`})})]},e.key))}):null]}),d?(0,W.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`bug-report-error`,children:d}):null]})})}function YU(e){let t=Date.parse(`${e}T12:00:00`);return Number.isFinite(t)?new Date(t).toLocaleDateString(void 0,{dateStyle:`long`}):e}function XU({open:e,notes:t,onClose:n}){return(0,W.jsx)(Ky,{open:e,title:`What's new in OonaCode`,onClose:n,footer:(0,W.jsx)(J,{variant:`primary`,onClick:n,children:`Got it`}),children:(0,W.jsx)(`div`,{className:`space-y-5 text-sm`,"data-testid":`whats-new`,children:t.map(e=>(0,W.jsxs)(`section`,{"data-version":e.version,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-baseline gap-2`,children:[(0,W.jsxs)(`h3`,{className:`text-base font-semibold`,children:[`Version `,e.version]}),(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,children:YU(e.date)})]}),e.added.length>0?(0,W.jsx)(`ul`,{className:`space-y-1.5`,children:e.added.map((e,t)=>(0,W.jsxs)(`li`,{className:`flex gap-2`,children:[(0,W.jsx)(q.Plus,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent`}),(0,W.jsx)(`span`,{children:e})]},t))}):null,e.fixed.length>0?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mb-1 mt-3 text-xs font-medium uppercase tracking-wide text-fg-faint`,children:`Fixed`}),(0,W.jsx)(`ul`,{className:`space-y-1.5`,children:e.fixed.map((e,t)=>(0,W.jsxs)(`li`,{className:`flex gap-2`,children:[(0,W.jsx)(q.Check,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-ok`}),(0,W.jsx)(`span`,{children:e})]},t))})]}):null]},`${e.version}:${e.platforms?.join(`,`)??`all`}`))})})}function ZU(){let{state:e,actions:t}=G(),n=sm(e.account);return!n||e.ui.dialog===`account`?null:(0,W.jsxs)(`div`,{role:`status`,"data-testid":`vault-rekey-banner`,className:`flex items-center gap-2 bg-warn-soft px-3 py-1.5 text-xs text-warn`,children:[(0,W.jsx)(q.Alert,{className:`w-3.5 h-3.5`}),(0,W.jsx)(`span`,{className:`flex-1`,children:mm(n)}),(0,W.jsx)(J,{size:`sm`,variant:`primary`,onClick:()=>t.openDialog(`account`),children:`Open Account`})]})}function QU({onReconnect:e}){let{state:t}=G(),n=t.connection.status;if(n===`open`||n===`idle`||n===`connecting`)return null;let r=n===`unauthorized`&&!window.oonacode;return(0,W.jsxs)(`div`,{role:`status`,className:U(`flex items-center gap-2 px-3 py-1.5 text-xs`,r?`bg-danger-soft text-danger`:`bg-warn-soft text-warn`),children:[r?(0,W.jsx)(q.Alert,{className:`w-3.5 h-3.5`}):(0,W.jsx)(q.Spinner,{className:`w-3.5 h-3.5`}),(0,W.jsx)(`span`,{className:`flex-1`,children:r?`The host rejected this connection${t.connection.detail?` (${t.connection.detail})`:``}. Re-open the UI from the desktop app or paste a fresh token.`:`Reconnecting to the host${t.connection.detail?` — ${t.connection.detail}`:``}…`}),r&&e?(0,W.jsx)(J,{size:`sm`,variant:`danger`,onClick:e,children:`Enter token`}):null]})}function $U(){let{state:e,actions:t}=G(),n=(0,v.useRef)(1);n.current=Object.keys(e.layout.groups).length,(0,v.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{if(e.ctrlKey||e.metaKey){if(e.key===`Tab`){e.preventDefault(),t.cycleTab(e.shiftKey?-1:1);return}if(!(e.shiftKey||e.altKey)){if(e.key===`\\`||e.code===`Backslash`){e.preventDefault(),t.splitTab(`right`);return}if(/^[1-9]$/.test(e.key)){let r=Number(e.key)-1;if(r>=n.current)return;e.preventDefault(),t.focusGroupAt(r),eW(r)}}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t])}function eW(e){let t=()=>{(document.querySelectorAll(`[data-editor-group]`)[e]?.querySelector(`[data-testid="composer"] textarea`))?.focus()};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}function tW(){let{state:e,actions:t}=G(),n=(0,v.useRef)(!1),r=e.account?.loggedIn===!0,i=e.prefs.claudeImportOffered?3:e.prefs.claudeImportOffers,a=e.ui.dialog===`none`&&e.windowRole===`main`,o=e.settings!==null,s=(0,v.useRef)(e.ui.dialog);s.current=e.ui.dialog,(0,v.useEffect)(()=>{n.current||!o||i>=3||!r||!a||(n.current=!0,t.scanClaudeSessions().then(e=>{if(e.sessions.some(e=>!e.alreadyImported&&e.deletedHere!==!0&&!e.unavailable)){if(s.current!==`none`){n.current=!1;return}t.offerImport(),t.savePrefs({claudeImportOffers:i+1})}}).catch(()=>{}))},[t,a,r,i,o])}function nW(){let{state:e,actions:t}=G(),n=(0,v.useRef)(!1),[r,i]=(0,v.useState)(null),a=typeof window<`u`?window.oonacode:void 0,o=a?.appVersion??e.bundleAppVersion??null,s=e.settings!==null,c=e.prefs.lastSeenReleaseNotes,l=e.sessionListLoaded,u=e.sessionsTotal>0||e.sessions.length>0,d=e.settings?.uiPrefs,f=d!==void 0&&!(`lastSeenReleaseNotes`in d),p=e.ui.dialog===`none`&&e.windowRole===`main`,m=e.info?.platform??a?.platform??null;(0,v.useEffect)(()=>{if(n.current||!s||!o||!p||c===null&&!l||(n.current=!0,f))return;let{record:e,show:r}=il(o,c,u,void 0,m);e!==null&&t.savePrefs({lastSeenReleaseNotes:e}),r.length!==0&&(i(r),t.openDialog(`whats-new`))},[t,f,p,o,c,m,l,s,u]);let h=e.ui.dialog===`whats-new`;return(0,v.useEffect)(()=>{!h&&r&&i(null)},[r,h]),r??(o?rl(o,`0`,void 0,m):[])}function rW({onUnauthorized:e}){let{state:t,actions:n}=G(),r=(0,v.useCallback)(()=>n.openDialog(`none`),[n]),i=nW();tW();let a=typeof window<`u`&&window.oonacode?.host===`vscode`,o=t.ui.sidebarOpen&&!a;return $U(),(0,W.jsxs)(`div`,{className:`flex h-full flex-col bg-bg text-fg`,children:[(0,W.jsx)(VU,{}),(0,W.jsx)(QU,{onReconnect:e}),(0,W.jsx)(ZU,{}),(0,W.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,W.jsx)(VR,{hidden:a,children:(0,W.jsx)(SU,{})}),o?(0,W.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 md:hidden`,onClick:()=>n.setSidebar(!1),"aria-hidden":!0}):null,t.prefs.explorerOpen?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 md:hidden`,onClick:()=>void n.savePrefs({explorerOpen:!1}),"aria-hidden":!0}),(0,W.jsx)(`div`,{className:`absolute inset-y-0 left-0 z-30 flex max-w-[85vw] md:static md:z-auto md:max-w-none`,children:(0,W.jsx)(TH,{})})]}):null,(0,W.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:(0,W.jsx)(sR,{})}),t.prefs.sessionPanelOpen?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 lg:hidden`,onClick:()=>void n.savePrefs({sessionPanelOpen:!1}),"aria-hidden":!0}),(0,W.jsx)(`div`,{className:`absolute inset-y-0 right-0 z-30 flex max-w-[85vw] lg:static lg:z-auto lg:max-w-none`,children:(0,W.jsx)(xH,{})})]}):null]}),(0,W.jsx)(gR,{open:t.ui.dialog===`project`,onClose:r}),(0,W.jsx)(FR,{open:t.ui.dialog===`projects`,startNew:t.projectsStartNew,selectId:t.projectsSelectId,onClose:r}),(0,W.jsx)(wB,{open:t.ui.dialog===`assign-project`,onClose:r}),(0,W.jsx)(tU,{open:t.ui.dialog===`settings`,onClose:r}),(0,W.jsx)(Xb,{open:t.ui.dialog===`account`,onClose:r}),(0,W.jsx)(hR,{open:t.ui.dialog===`doctor`,onClose:r}),(0,W.jsx)(ax,{open:t.ui.dialog===`session-picker`,onClose:r}),(0,W.jsx)(zU,{open:t.ui.dialog===`update`,onClose:r}),(0,W.jsx)(JU,{open:t.ui.dialog===`bug-report`,onClose:r}),(0,W.jsx)(jR,{open:t.ui.dialog===`claude-login`,onClose:r}),(0,W.jsx)(_V,{open:t.ui.dialog===`oauth-login`,onClose:r}),(0,W.jsx)(vV,{open:t.ui.dialog===`manage-models`,onClose:r}),(0,W.jsx)(tH,{open:t.ui.dialog===`import-claude`,autoOffer:t.importOffered,onClose:r}),(0,W.jsx)(HR,{open:t.ui.dialog===`export-chats`,onClose:r}),(0,W.jsx)(uz,{open:t.ui.dialog===`conversations`,selectId:t.conversationsSelectId,onClose:r}),(0,W.jsx)(xB,{open:t.ui.dialog===`chat-abouts`,onClose:r}),(0,W.jsx)(dB,{open:t.ui.dialog===`voice-summary`,onClose:r}),(0,W.jsx)(XU,{open:t.ui.dialog===`whats-new`,notes:i,onClose:r}),(0,W.jsx)(gV,{open:t.ui.connectProviderId!==null,providerId:t.ui.connectProviderId,onClose:()=>n.openProviderConnect(null)}),(0,W.jsx)(rU,{})]})}function iW({onUnauthorized:e}){let{state:t}=G(),n=t.account?.loggedIn===!0&&!t.account.vaultUnlocked;return(0,v.useEffect)(()=>{window.oonacode?.setVaultLocked?.(n)},[n]),t.accountLoaded?t.account?.loggedIn?!t.account.vaultUnlocked&&sm(t.account)===null?(0,W.jsx)(mU,{}):(0,W.jsx)(rW,{onUnauthorized:e}):(0,W.jsx)(pU,{}):(0,W.jsx)(lU,{})}function aW({api:e,socket:t,relay:n,initialSessionId:r,onUnauthorized:i,reportError:a}){return(0,W.jsx)(Iy,{api:e,socket:t,relay:n??null,initialSessionId:r??null,onUnauthorized:i,...a?{reportError:a}:{},children:(0,W.jsx)(iW,{onUnauthorized:i})})}var oW=`oonacode.host.connection`,sW=`session`;function cW(e){let t=e.replace(/^#\/?\??/,``),n=new URLSearchParams(t),r=n.get(`token`),i=n.get(`host`)??n.get(`baseUrl`),a=n.get(sW);n.delete(`token`),n.delete(`host`),n.delete(`baseUrl`);let o=n.toString();return{token:r&&r.trim()?r.trim():null,baseUrl:i,sessionId:a,restHash:o?`#${o}`:``}}function lW(e){if(!e)return null;try{let t=e.getItem(oW);if(!t)return null;let n=JSON.parse(t);if(typeof n.baseUrl==`string`&&typeof n.token==`string`&&n.token)return{baseUrl:_m(n.baseUrl),token:n.token}}catch{}return null}function uW(e,t){if(e)try{t?e.setItem(oW,JSON.stringify(t)):e.removeItem(oW)}catch{}}async function dW(e){let t=cW(e.location.hash);if(t.token){let n={baseUrl:_m(t.baseUrl??e.location.origin),token:t.token};uW(e.storage,n);let r=`${e.location.pathname}${e.location.search}${t.restHash}`;try{e.replaceUrl?.(r)}catch{}return{connection:n,source:`hash`,sessionId:t.sessionId}}if(e.bridge&&typeof e.bridge.getConnection==`function`)try{let n=await e.bridge.getConnection();if(n&&typeof n.token==`string`&&n.token&&typeof n.baseUrl==`string`){let r={baseUrl:_m(n.baseUrl),token:n.token};return uW(e.storage,r),{connection:r,source:`bridge`,sessionId:t.sessionId}}}catch{}let n=lW(e.storage);return n?{connection:n,source:`storage`,sessionId:t.sessionId}:{connection:null,source:`none`,sessionId:t.sessionId}}function fW(e=window){let t=null;try{t=e.sessionStorage}catch{t=null}return dW({location:e.location,storage:t,replaceUrl:t=>e.history.replaceState(null,``,t),bridge:e.oonacode})}var pW=1;function mW(){let e=globalThis.crypto;return e&&typeof e.randomUUID==`function`?e.randomUUID():`c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function hW(e,t){return`${_m(e).replace(/^http(s?):/i,`ws$1:`)}${b}?token=${encodeURIComponent(t)}`}var gW=class{clientId;opts;ws=null;_status=`idle`;attempts=0;preOpenFailures=0;epoch=0;reconnectTimer=null;pingTimer=null;manuallyClosed=!1;handlers=new Map;anyHandlers=new Set;statusHandlers=new Set;subscriptions=new Map;promptCounter=0;constructor(e){this.opts={clientKind:`web`,minBackoffMs:500,maxBackoffMs:15e3,pingIntervalMs:25e3,authProbeAfterFailures:2,...e,baseUrl:_m(e.baseUrl)},this.clientId=e.clientId??mW()}get status(){return this._status}connect(){this.manuallyClosed=!1,!(this.ws&&(this._status===`open`||this._status===`connecting`))&&this.open()}close(){this.manuallyClosed=!0,this.epoch+=1,this.clearTimers();let e=this.ws;if(this.ws=null,e){e.onopen=e.onclose=e.onerror=e.onmessage=null;try{e.close(1e3,`client closed`)}catch{}}this.setStatus(`closed`)}send(e){let t=this.ws;if(!t||t.readyState!==pW)return!1;try{return t.send(JSON.stringify(e)),!0}catch{return!1}}on(e,t){let n=this.handlers.get(e);n||(n=new Set,this.handlers.set(e,n));let r=t;return n.add(r),()=>{n?.delete(r)}}onAny(e){return this.anyHandlers.add(e),()=>{this.anyHandlers.delete(e)}}onStatus(e){return this.statusHandlers.add(e),e(this._status),()=>{this.statusHandlers.delete(e)}}subscribe(e,t){let n=this.subscriptions.get(e),r=t??n;this.subscriptions.set(e,r),this.send(r===void 0?{type:`subscribe`,sessionId:e}:{type:`subscribe`,sessionId:e,afterSeq:r})}unsubscribe(e){this.subscriptions.delete(e),this.send({type:`unsubscribe`,sessionId:e})}noteSeq(e,t){if(t===null||!this.subscriptions.has(e))return;let n=this.subscriptions.get(e);(n===void 0||t>n)&&this.subscriptions.set(e,t)}prompt(e,t,n={}){let r=n.requestId??`req-${this.clientId.slice(0,8)}-${++this.promptCounter}`,i={type:`prompt`,sessionId:e,requestId:r,text:t};if(n.attachments&&n.attachments.length>0&&(i.attachments=n.attachments),n.options&&(i.options=n.options),!this.send(i))throw Error(`not connected`);return r}respondPermission(e,t,n){return this.send({type:`permission_response`,sessionId:e,requestId:t,decision:n})}interrupt(e){return this.send({type:`interrupt`,sessionId:e})}setModel(e,t){return this.send({type:`set_model`,sessionId:e,model:t})}setPermissionMode(e,t,n){return this.send({type:`set_permission_mode`,sessionId:e,mode:t,...n===void 0?{}:{posture:n}})}setEffort(e,t){return this.send({type:`set_effort`,sessionId:e,effort:t})}open(){this.clearTimers(),this.epoch+=1,this.setStatus(this.attempts===0?`connecting`:`reconnecting`);let e=hW(this.opts.baseUrl,this.opts.token),t=this.opts.createWebSocket??(e=>new WebSocket(e)),n;try{n=t(e)}catch(e){this.scheduleReconnect(String(e?.message??e));return}this.ws=n;let r=!1;n.onopen=()=>{if(this.ws===n){r=!0,this.attempts=0,this.preOpenFailures=0,this.setStatus(`open`),this.send({type:`hello`,protocolVersion:1,clientKind:this.opts.clientKind,clientId:this.clientId,...this.opts.clientVersion?{clientVersion:this.opts.clientVersion}:{}});for(let[e,t]of this.subscriptions)this.send(t===void 0?{type:`subscribe`,sessionId:e}:{type:`subscribe`,sessionId:e,afterSeq:t});this.opts.pingIntervalMs>0&&(this.pingTimer=setInterval(()=>this.send({type:`ping`,ts:Date.now()}),this.opts.pingIntervalMs))}},n.onmessage=e=>{if(this.ws!==n)return;let t;try{t=typeof e.data==`string`?JSON.parse(e.data):null}catch{return}Ne(t)&&this.dispatch(t)},n.onerror=()=>{},n.onclose=e=>{if(this.ws!==n)return;if(this.ws=null,this.pingTimer&&=(clearInterval(this.pingTimer),null),this.manuallyClosed){this.setStatus(`closed`);return}if(e.code===4401||e.code===4403||e.code===1008){this.setStatus(`unauthorized`,e.reason||`host rejected the token or origin`);return}let t=e.reason||`closed (${e.code})`;if(this.preOpenFailures=r?0:this.preOpenFailures+1,!r&&this.opts.authProbeAfterFailures>0&&this.preOpenFailures>=this.opts.authProbeAfterFailures){this.probeAuthThenReconnect(t);return}this.scheduleReconnect(t)}}async probeAuthThenReconnect(e){let t=this.epoch;this.setStatus(`reconnecting`,e);let n=this.opts.fetchImpl??((e,t)=>fetch(e,t)),r=!1;try{let e=await n(`${this.opts.baseUrl}${z.health}`,{method:`GET`,headers:{authorization:`Bearer ${this.opts.token}`}});if(e.status===401||e.status===403)r=!0;else if(e.status===200){let t=await e.json().catch(()=>null);r=!(t&&typeof t==`object`&&typeof t.hostId==`string`)}}catch{}if(!(this.manuallyClosed||t!==this.epoch)){if(r){this.setStatus(`unauthorized`,`host rejected the token`);return}this.scheduleReconnect(e)}}dispatch(e){e.type===`agent`&&e.seq!==null&&this.noteSeq(e.sessionId,e.seq);let t=this.handlers.get(e.type);if(t)for(let n of[...t])_W(()=>n(e));for(let t of[...this.anyHandlers])_W(()=>t(e))}scheduleReconnect(e){this.attempts+=1;let t=Math.min(this.opts.maxBackoffMs,this.opts.minBackoffMs*2**Math.min(this.attempts-1,10)),n=Math.round(t*(.7+Math.random()*.6));this.setStatus(`reconnecting`,e);let r=this.opts.setTimeoutImpl??setTimeout;this.reconnectTimer=r(()=>{this.reconnectTimer=null,this.manuallyClosed||this.open()},n)}clearTimers(){this.reconnectTimer&&=((this.opts.clearTimeoutImpl??clearTimeout)(this.reconnectTimer),null),this.pingTimer&&=(clearInterval(this.pingTimer),null)}setStatus(e,t){this._status=e;for(let n of[...this.statusHandlers])_W(()=>n(e,t))}};function _W(e){try{e()}catch(e){console.error(`[HostSocket] handler failed`,e)}}var vW=/([?&#](?:token|access_token|key|api_key|secret|password)=)[^&#\s"']*/gi,yW=/\b(Bearer|Basic)\s+[A-Za-z0-9\-._~+/=]{8,}/g;function bW(e){return e.replace(vW,`$1[redacted]`).replace(yW,`$1 [redacted]`)}function xW(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function SW(e){return typeof e==`object`&&!!e&&typeof e.message==`string`}function CW(e){if(SW(e)){let t=typeof e.name==`string`&&e.name?e.name:`Error`,n=typeof e.stack==`string`&&e.stack?e.stack:null;return{message:e.message||t,stack:n}}return typeof e==`string`?{message:xW(e,512),stack:null}:{message:`Unhandled rejection (${e===null?`null`:Array.isArray(e)?`array`:typeof e})`,stack:null}}function wW(e){return e?e.split(`
|
|
163
|
+
`).find(e=>/^\s+at\s/.test(e))?.trim()??``:``}function TW(e){let t=e.now??(()=>Date.now()),n=e.maxPerMinute??5,r=e.embedded??`browser`,i=[],a=new Map,o=(e,t)=>{for(;i.length>0&&(i[0]??0)<=t-6e4;)i.shift();for(let[e,n]of a)n<=t-6e4&&a.delete(e);return a.has(e)||i.length>=n?!1:(i.push(t),a.set(e,t),!0)},s=async(n,i={})=>{try{let a=e.api.reportError;if(typeof a!=`function`)return!1;let{message:s,stack:c}=CW(n),l=t();if(!o(`${s}\n${wW(c)}`,l))return!1;let u={client:`web-ui`,message:xW(bW(s),qs),detail:{source:`manual`,...i,embedded:r},at:new Date(l).toISOString()};return c&&(u.stack=xW(bW(c),Js)),e.appVersion&&(u.appVersion=e.appVersion),e.platform&&(u.platform=e.platform),await a.call(e.api,u),!0}catch{return!1}},c=e=>{if(typeof e?.message!=`string`)return;let t=e.error??null;if(t===null&&!e.message)return;let n={source:`window.onerror`};typeof e.filename==`string`&&e.filename&&(n.filename=e.filename),typeof e.lineno==`number`&&e.lineno>0&&(n.lineno=e.lineno),typeof e.colno==`number`&&e.colno>0&&(n.colno=e.colno),s(t??e.message,n)},l=e=>{s(e?.reason,{source:`unhandledrejection`})};return{install:t=>{if(typeof e.api.reportError!=`function`)return()=>{};let n=e=>c(e),r=e=>l(e);return t.addEventListener(`error`,n),t.addEventListener(`unhandledrejection`,r),()=>{t.removeEventListener(`error`,n),t.removeEventListener(`unhandledrejection`,r)}},report:s,handleErrorEvent:c,handleRejectionEvent:l}}var EW=1;function DW(e,t){return`${_m(e).replace(/^http(s?):/i,`ws$1:`)}${z.remoteWs}?token=${encodeURIComponent(t)}`}function OW(e){return`tab-${e}-${Math.random().toString(36).slice(2,10)}`}var kW=class{#e;#t=new Map;#n=new Set;#r=null;#i=`idle`;#a=null;#o=0;#s=!1;#c=0;#l=null;constructor(e){this.#e=e}get status(){return this.#i}get pairingCount(){return this.#t.size}onStatus(e){return this.#n.add(e),e(this.#i),()=>{this.#n.delete(e)}}connect(){if(this.#r||this.#i===`connecting`)return;this.#s=!1,this.#d(`connecting`);let e=DW(this.#e.baseUrl,this.#e.token),t=this.#e.createWebSocket??(e=>new WebSocket(e)),n;try{n=t(e)}catch{this.#d(`closed`),this.#u();return}this.#r=n,n.onopen=()=>{if(this.#r===n){this.#o=0,this.#d(`open`),this.#f({type:`remote_hello`,protocolVersion:1,clientId:this.#e.clientId??`web-ui`,...this.#e.clientVersion?{clientVersion:this.#e.clientVersion}:{}});for(let e of this.#t.values())this.#p(e)}},n.onmessage=e=>{this.#r===n&&this.#h(e.data)},n.onerror=()=>void 0,n.onclose=()=>{if(this.#r===n){this.#r=null;for(let e of this.#t.values())this.#m(e,{state:`host_offline`,online:!1,detail:`reconnecting to this PC…`});this.#i!==`unavailable`&&this.#d(`closed`),this.#u()}}}close(){this.#s=!0,this.#l=null,this.#a&&(this.#e.clearTimeoutImpl??clearTimeout)(this.#a),this.#a=null,this.#t.clear();let e=this.#r;if(this.#r=null,e){e.onopen=e.onclose=e.onerror=e.onmessage=null;try{e.close(1e3,`closed`)}catch{}}this.#d(`idle`)}#u(){let e=this.#e.reconnectDelayMs??1e3;if(this.#s||e<=0||this.#a||this.#t.size===0)return;let t=this.#e.maxReconnectDelayMs??2e4;this.#o+=1;let n=Math.min(e*2**Math.min(this.#o-1,5),t),r=this.#e.setTimeoutImpl??setTimeout;this.#a=r(()=>{this.#a=null,this.#s||this.connect()},n)}#d(e,t){if(this.#i!==e){this.#i=e;for(let n of[...this.#n])n(e,t)}}#f(e){let t=this.#r;if(!t||t.readyState!==EW)return!1;try{return t.send(JSON.stringify(e)),!0}catch{return!1}}attach(e){this.#c+=1;let t=OW(this.#c),n={pairingId:t,hostId:e.hostId,sessionId:e.sessionId,state:`unavailable`,online:!1,detail:null,onFrame:e.onFrame,onState:e.onState};return this.#t.set(t,n),this.#r&&this.#r.readyState===EW?(this.#l!==null&&this.#m(n,{detail:this.#l}),this.#p(n)):this.connect(),{pairingId:t,hostId:e.hostId,sessionId:e.sessionId,send:e=>this.send(t,e),detach:()=>this.detach(t)}}detach(e){this.#t.get(e)&&(this.#t.delete(e),this.#f({type:`remote_detach`,pairingId:e}),this.#t.size===0&&this.close())}send(e,t){let n=this.#t.get(e);return!n||!n.online?!1:this.#f({type:`remote_send`,pairingId:e,frame:t})}#p(e){this.#f({type:`remote_attach`,pairingId:e.pairingId,hostId:e.hostId,sessionId:e.sessionId})}#m(e,t){Object.assign(e,t),e.onState({pairingId:e.pairingId,hostId:e.hostId,sessionId:e.sessionId,state:e.state,online:e.online,detail:e.detail})}#h(e){let t;try{let n=JSON.parse(typeof e==`string`?e:String(e));if(!Le(n))return;t=n}catch{return}switch(t.type){case`remote_welcome`:if(!t.canRelay){let e=t.reason??`this PC cannot reach your other devices right now`;this.#l=e,this.#d(`unavailable`,e);for(let t of this.#t.values())this.#m(t,{state:`unavailable`,online:!1,detail:e});return}this.#l=null,this.#i===`unavailable`&&this.#d(`open`);for(let e of this.#t.values())e.online||this.#p(e);return;case`remote_status`:{let e=this.#t.get(t.pairingId);if(!e)return;this.#m(e,{state:t.state,online:Re(t.state),detail:t.detail??null});return}case`remote_frame`:this.#t.get(t.pairingId)?.onFrame(t.frame);return;case`remote_error`:{let e=t.pairingId?this.#t.get(t.pairingId):void 0;e&&this.#m(e,{state:`error`,online:!1,detail:t.message});return}default:return}}};function AW({defaultBaseUrl:e,error:t,onConnect:n}){let[r,i]=(0,v.useState)(e),[a,o]=(0,v.useState)(``),s=r.trim().length>0&&a.trim().length>0;return(0,W.jsx)(`div`,{className:`flex min-h-full items-center justify-center bg-bg p-4`,children:(0,W.jsxs)(`form`,{className:`w-full max-w-md space-y-4 rounded-xl border border-border bg-surface p-6 shadow-md`,onSubmit:e=>{e.preventDefault(),s&&n({baseUrl:r.trim(),token:a.trim()})},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Connect to your OonaCode host`}),(0,W.jsxs)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:[`This page needs the host's access token. It is normally passed automatically when you open the UI from the desktop app or run`,` `,(0,W.jsx)(`code`,{className:`rounded bg-surface-2 px-1 font-mono`,children:`oona web`}),`.`]})]}),t?(0,W.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:t}):null,(0,W.jsx)(Wy,{label:`Host URL`,children:(0,W.jsx)(`input`,{className:X,value:r,onChange:e=>i(e.target.value),placeholder:`http://127.0.0.1:41317`,spellCheck:!1,autoComplete:`url`})}),(0,W.jsx)(Wy,{label:`Host token`,hint:'Found in host/host.json ("token") in the OonaCode folder of the PC running the host — %LOCALAPPDATA%\\OonaCode on Windows, ~/Library/Application Support/OonaCode on macOS, ~/.oonacode on Linux — printed by `oona serve --show-token`, or embedded in the URL printed by `oona web --print`.',children:(0,W.jsx)(`input`,{className:X,type:`password`,value:a,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1,autoFocus:!0})}),(0,W.jsx)(J,{type:`submit`,variant:`primary`,className:`w-full justify-center`,disabled:!s,children:`Connect`})]})})}function jW(e){return!!e&&e.platform===`linux`&&e.host!==`vscode`&&!!e.onMenuModel}var MW=e=>!!e&&e.type!==`separator`&&e.enabled;function NW(e,t,n){let r=e.length;for(let i=1;i<=r;i+=1){let a=((t+n*i)%r+r)%r;if(MW(e[a]))return a}return-1}function PW({label:e,mnemonic:t,show:n}){let r=n&&t?e.toLowerCase().indexOf(t):-1;return r<0?e:(0,W.jsxs)(W.Fragment,{children:[e.slice(0,r),(0,W.jsx)(`span`,{className:`underline underline-offset-2`,children:e[r]}),e.slice(r+1)]})}function FW({bridge:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(-1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),d=(0,v.useRef)(null);(0,v.useEffect)(()=>e.onMenuModel?.(e=>{n(e),i(null),o(-1),c(null)}),[e]);let f=t?.items??[],p=(0,v.useCallback)(e=>e===null?[]:f[e]?.submenu??[],[f]),m=(0,v.useCallback)(()=>{i(null),o(-1),c(null)},[]),h=(0,v.useCallback)((e,t)=>{i(e);let n=p(e);o(t?NW(n,-1,1):-1),t&&c(e)},[p]),g=(0,v.useCallback)(t=>{!t||!MW(t)||t.type===`submenu`||(m(),e.invokeMenuItem?.(t.id))},[e,m]);if((0,v.useEffect)(()=>{if(f.length===0)return;let e=!1,t=()=>r!==null||s!==null,n=e=>{e.preventDefault(),e.stopPropagation()},l=l=>{if(l.key===`Alt`){e=!l.repeat,u(!0);return}e=!1;let d=!l.ctrlKey&&!l.metaKey&&!l.shiftKey;if(!t()){if(l.key===`F10`&&d&&!l.altKey){n(l),c(0);return}if(l.altKey&&d&&l.key.length===1){let e=f.findIndex(e=>e.mnemonic===l.key.toLowerCase());e>=0&&(n(l),h(e,!0))}return}let _=p(r),v=s??r??0,y=e=>{let t=(v+e+f.length)%f.length;r===null?c(t):h(t,!0)};switch(l.key){case`Escape`:n(l),r!==null&&s!==null?(i(null),o(-1)):m();return;case`ArrowLeft`:n(l),y(-1);return;case`ArrowRight`:n(l),y(1);return;case`ArrowDown`:n(l),r===null?h(v,!0):o(NW(_,a,1));return;case`ArrowUp`:n(l),r===null?(h(v,!0),o(NW(p(v),0,-1))):o(NW(_,a<0?0:a,-1));return;case`Home`:n(l),r!==null&&o(NW(_,-1,1));return;case`End`:n(l),r!==null&&o(NW(_,0,-1));return;case`Enter`:case` `:n(l),r===null?h(v,!0):g(_[a]);return;case`Tab`:m();return}if(l.key.length===1&&!l.ctrlKey&&!l.metaKey){n(l);let e=l.key.toLowerCase();if(r!==null)g(_.find(t=>t.mnemonic===e&&MW(t)));else{let t=f.findIndex(t=>t.mnemonic===e);t>=0&&h(t,!0)}return}m()},_=n=>{n.key===`Alt`&&(u(!1),e&&(e=!1,t()?m():c(0)))},v=()=>{e=!1,u(!1),m()},y=e=>{(r!==null||s!==null)&&(d.current&&e.target instanceof Node&&d.current.contains(e.target)||m())};return window.addEventListener(`keydown`,l,!0),window.addEventListener(`keyup`,_,!0),window.addEventListener(`blur`,v),document.addEventListener(`mousedown`,y,!0),()=>{window.removeEventListener(`keydown`,l,!0),window.removeEventListener(`keyup`,_,!0),window.removeEventListener(`blur`,v),document.removeEventListener(`mousedown`,y,!0)}},[f,r,s,a,p,h,g,m]),!t||f.length===0)return null;let _=l||s!==null;return(0,W.jsx)(`div`,{ref:d,role:`menubar`,"aria-label":`Application menu`,className:`flex h-7 shrink-0 items-stretch gap-px border-b border-border bg-surface px-1 text-[13px] text-fg select-none`,children:f.map((e,t)=>{let n=r===t;return(0,W.jsxs)(`div`,{className:`relative flex`,children:[(0,W.jsx)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`menu`,"aria-expanded":n,tabIndex:-1,disabled:!e.enabled,"data-menu-top":e.id,onMouseDown:e=>{e.preventDefault(),n?m():h(t,!1)},onMouseEnter:()=>{r!==null&&r!==t&&h(t,!1)},className:U(`my-0.5 rounded-sm px-2.5`,n||s===t?`bg-surface-3`:`hover:bg-surface-2`,!e.enabled&&`text-fg-faint`),children:(0,W.jsx)(PW,{label:e.label,mnemonic:e.mnemonic,show:_})}),n&&e.submenu?(0,W.jsx)(IW,{entries:e.submenu,active:a,showMnemonics:_,onHover:o,onRun:g}):null]},e.id)})})}function IW({entries:e,active:t,showMnemonics:n,onHover:r,onRun:i,nested:a=!1}){let[o,s]=(0,v.useState)(null);return(0,W.jsx)(`div`,{role:`menu`,className:U(`absolute z-[70] min-w-[15rem] rounded-md border border-border bg-surface py-1 text-fg shadow-lg`,a?`top-0 left-full -mt-1 ml-px`:`top-full left-0 mt-px`),children:e.map((e,a)=>{if(e.type===`separator`)return(0,W.jsx)(`div`,{role:`separator`,className:`my-1 border-t border-border`},e.id);let c=e.type===`checkbox`?`menuitemcheckbox`:e.type===`radio`?`menuitemradio`:`menuitem`,l=e.type===`checkbox`||e.type===`radio`;return(0,W.jsxs)(`div`,{role:c,"aria-disabled":!e.enabled||void 0,"aria-checked":l?e.checked:void 0,"aria-haspopup":e.type===`submenu`?`menu`:void 0,"data-menu-entry":e.id,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>{r(a),s(e.type===`submenu`?a:null)},onClick:()=>i(e),className:U(`relative flex cursor-default items-center gap-2 px-3 py-1`,a===t&&e.enabled&&`bg-surface-2`,!e.enabled&&`text-fg-faint`),children:[(0,W.jsx)(`span`,{className:`w-4 shrink-0 text-center`,"aria-hidden":!0,children:l&&e.checked?e.type===`radio`?`•`:`✓`:``}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:(0,W.jsx)(PW,{label:e.label,mnemonic:e.mnemonic,show:n})}),e.accelerator?(0,W.jsx)(`span`,{className:`shrink-0 pl-6 text-xs text-fg-faint`,children:e.accelerator}):null,e.type===`submenu`?(0,W.jsx)(`span`,{className:`shrink-0 pl-4 text-fg-faint`,"aria-hidden":!0,children:`›`}):null,e.type===`submenu`&&o===a&&e.submenu?(0,W.jsx)(IW,{entries:e.submenu,active:-1,showMnemonics:n,onHover:()=>{},onRun:i,nested:!0}):null]},e.id)})})}function LW(e){return!!e&&typeof e==`object`&&typeof e.hostId==`string`}function RW(e){return Math.min(5e3,500*2**Math.max(0,e))}async function zW(e){let t=e.sleep??(e=>new Promise(t=>setTimeout(t,e)));for(let n=0;;n++){if(e.cancelled?.())return null;try{let t=await e.getConnection();if(t&&typeof t.token==`string`&&t.token&&typeof t.baseUrl==`string`&&await e.accepts(t).catch(()=>!1))return t}catch{}await t(RW(n))}}function BW(){let[e,t]=(0,v.useState)(void 0),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(0),c=(0,v.useRef)(!1),l=(0,v.useRef)(!1);(0,v.useEffect)(()=>()=>{l.current=!0},[]);let u=(0,v.useCallback)(()=>{let e=window.oonacode;return!e||typeof e.getConnection!=`function`?!1:c.current?!0:(c.current=!0,zW({getConnection:()=>e.getConnection(),accepts:e=>vm(e).health().then(e=>LW(e),()=>!1),cancelled:()=>l.current}).then(e=>{c.current=!1,e&&(uW(window.sessionStorage,e),s(e=>e+1),t({baseUrl:e.baseUrl,token:e.token}))}),!0)},[]);(0,v.useEffect)(()=>{fW().then(e=>{r(e.sessionId),!(!e.connection&&u())&&t(e.connection)})},[u]),(0,v.useEffect)(()=>{e!==void 0&&document.getElementById(`oona-splash`)?.remove()},[e]);let d=(0,v.useCallback)(()=>{uW(window.sessionStorage,null),!u()&&(a(`The host rejected the token. Paste a current one from the host.`),t(null))},[u]),f=(0,v.useMemo)(()=>{if(!e)return null;let t=vm(e),n=window.oonacode?.window?.id;return{api:t,socket:new gW({baseUrl:e.baseUrl,token:e.token,clientKind:window.oonacode?`desktop`:`web`,clientVersion:window.oonacode?.appVersion,...n?{clientId:`${n.slice(0,16)}-${mW()}`}:{}}),relay:new kW({baseUrl:e.baseUrl,token:e.token,clientId:window.oonacode?`desktop`:`web-ui`,...window.oonacode?.appVersion?{clientVersion:window.oonacode.appVersion}:{}})}},[e]),p=(0,v.useMemo)(()=>f?TW({api:f.api,appVersion:window.oonacode?.appVersion??null,platform:window.oonacode?.platform??null,embedded:window.oonacode?`desktop`:`browser`}):null,[f]);return(0,v.useEffect)(()=>p?.install(window),[p]),e===void 0?null:!e||!f?(0,W.jsx)(AW,{defaultBaseUrl:window.location.origin,error:i,onConnect:e=>{uW(window.sessionStorage,e),a(null),t(e)}}):(0,W.jsx)(aW,{api:f.api,socket:f.socket,relay:f.relay,initialSessionId:n,onUnauthorized:d,...p?{reportError:p.report}:{}},o)}function VW({children:e}){let t=typeof window>`u`?void 0:window.oonacode;return jW(t)?(0,W.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,W.jsx)(FW,{bridge:t}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1`,children:e})]}):(0,W.jsx)(W.Fragment,{children:e})}var HW=document.getElementById(`root`);(0,y.createRoot)(HW).render((0,W.jsx)(v.StrictMode,{children:(0,W.jsx)(VW,{children:(0,W.jsx)(BW,{})})}));
|