@oonacode/darwin-x64 0.3.363 → 0.3.366
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.
|
@@ -83,7 +83,7 @@ Error generating stack: `+e.message+`
|
|
|
83
83
|
|
|
84
84
|
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 Ma(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:Fa(t,`input`,e.processors),output:Fa(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Na(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 Na(r.element,n);if(r.type===`set`)return Na(r.valueType,n);if(r.type===`lazy`)return Na(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 Na(r.innerType,n);if(r.type===`intersection`)return Na(r.left,n)||Na(r.right,n);if(r.type===`record`||r.type===`map`)return Na(r.keyType,n)||Na(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Na(r.in,n)||Na(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Na(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Na(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Na(e,n))return!0;return!!(r.rest&&Na(r.rest,n))}return!1}var Pa=(e,t={})=>n=>{let r=ka({...n,processors:t});return Aa(e,r),ja(r,e),Ma(r,e)},Fa=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ka({...i??{},target:a,io:t,processors:n});return Aa(e,o),ja(o,e),Ma(o,e)},Ia={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},La=(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=Ia[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}))])}},Ra=(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)},za=(e,t,n,r)=>{n.type=`boolean`},Ba=(e,t,n,r)=>{n.not={}},Va=(e,t,n,r)=>{let i=e._zod.def,a=dt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Ha=(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}},Ua=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Wa=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Ga=(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=Aa(a.element,t,{...r,path:[...r.path,`items`]})},Ka=(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]=Aa(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=Aa(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},qa=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Aa(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ja=(e,t,n,r)=>{let i=e._zod.def,a=Aa(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Aa(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]]},Ya=(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=Aa(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=Aa(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Aa(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)}},Xa=(e,t,n,r)=>{let i=e._zod.def,a=Aa(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`}]},Za=(e,t,n,r)=>{let i=e._zod.def;Aa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Qa=(e,t,n,r)=>{let i=e._zod.def;Aa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},$a=(e,t,n,r)=>{let i=e._zod.def;Aa(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)))},eo=(e,t,n,r)=>{let i=e._zod.def;Aa(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},to=(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;Aa(o,t,r);let s=t.seen.get(e);s.ref=o},no=(e,t,n,r)=>{let i=e._zod.def;Aa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ro=(e,t,n,r)=>{let i=e._zod.def;Aa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},io=L(`ZodISODateTime`,(e,t)=>{wr.init(e,t),jo.init(e,t)});function ao(e){return Xi(io,e)}var oo=L(`ZodISODate`,(e,t)=>{Tr.init(e,t),jo.init(e,t)});function so(e){return Zi(oo,e)}var co=L(`ZodISOTime`,(e,t)=>{Er.init(e,t),jo.init(e,t)});function lo(e){return Qi(co,e)}var uo=L(`ZodISODuration`,(e,t)=>{Dr.init(e,t),jo.init(e,t)});function fo(e){return $i(uo,e)}var po=L(`ZodError`,(e,t)=>{Yt.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Qt(e,t)},flatten:{value:t=>Zt(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ft,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ft,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),mo=$t(po),ho=en(po),go=tn(po),_o=rn(po),vo=on(po),yo=sn(po),bo=cn(po),xo=ln(po),So=un(po),Co=dn(po),wo=fn(po),To=pn(po),Eo=new WeakMap;function Do(e,t,n){let r=Object.getPrototypeOf(e),i=Eo.get(r);if(i||(i=new Set,Eo.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 Oo=L(`ZodType`,(e,t)=>(ur.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Fa(e,`input`),output:Fa(e,`output`)}}),e.toJSONSchema=Pa(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>mo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>go(e,t,n),e.parseAsync=async(t,n)=>ho(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>_o(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>vo(e,t,n),e.decode=(t,n)=>yo(e,t,n),e.encodeAsync=async(t,n)=>bo(e,t,n),e.decodeAsync=async(t,n)=>xo(e,t,n),e.safeEncode=(t,n)=>So(e,t,n),e.safeDecode=(t,n)=>Co(e,t,n),e.safeEncodeAsync=async(t,n)=>wo(e,t,n),e.safeDecodeAsync=async(t,n)=>To(e,t,n),Do(e,`ZodType`,{check(...e){let t=this.def;return this.clone(bt(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 At(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ws(e,t))},superRefine(e,t){return this.check(Gs(e,t))},overwrite(e){return this.check(ya(e))},optional(){return Es(this)},exactOptional(){return Os(this)},nullable(){return As(this)},nullish(){return Es(As(this))},nonoptional(e){return Is(this,e)},array(){return cs(this)},or(e){return fs([this,e])},and(e){return gs(this,e)},transform(e){return Bs(this,ws(e))},default(e){return Ms(this,e)},prefault(e){return Ps(this,e)},catch(e){return Rs(this,e)},pipe(e){return Bs(this,e)},readonly(){return Hs(this)},describe(e){let t=this.clone();return Ei.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ei.get(this);let t=this.clone();return Ei.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 Ei.get(e)?.description},configurable:!0}),e)),ko=L(`_ZodString`,(e,t)=>{dr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>La(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Do(e,`_ZodString`,{regex(...e){return this.check(pa(...e))},includes(...e){return this.check(ga(...e))},startsWith(...e){return this.check(_a(...e))},endsWith(...e){return this.check(va(...e))},min(...e){return this.check(da(...e))},max(...e){return this.check(ua(...e))},length(...e){return this.check(fa(...e))},nonempty(...e){return this.check(da(1,...e))},lowercase(e){return this.check(ma(e))},uppercase(e){return this.check(ha(e))},trim(){return this.check(xa())},normalize(...e){return this.check(ba(...e))},toLowerCase(){return this.check(Sa())},toUpperCase(){return this.check(Ca())},slugify(){return this.check(wa())}})}),Ao=L(`ZodString`,(e,t)=>{dr.init(e,t),ko.init(e,t),e.email=t=>e.check(Oi(Mo,t)),e.url=t=>e.check(Pi(Fo,t)),e.jwt=t=>e.check(Yi(Xo,t)),e.emoji=t=>e.check(Fi(Io,t)),e.guid=t=>e.check(ki(No,t)),e.uuid=t=>e.check(Ai(Po,t)),e.uuidv4=t=>e.check(ji(Po,t)),e.uuidv6=t=>e.check(Mi(Po,t)),e.uuidv7=t=>e.check(Ni(Po,t)),e.nanoid=t=>e.check(Ii(Lo,t)),e.guid=t=>e.check(ki(No,t)),e.cuid=t=>e.check(Li(Ro,t)),e.cuid2=t=>e.check(Ri(zo,t)),e.ulid=t=>e.check(zi(Bo,t)),e.base64=t=>e.check(Ki(qo,t)),e.base64url=t=>e.check(qi(Jo,t)),e.xid=t=>e.check(Bi(Vo,t)),e.ksuid=t=>e.check(Vi(Ho,t)),e.ipv4=t=>e.check(Hi(Uo,t)),e.ipv6=t=>e.check(Ui(Wo,t)),e.cidrv4=t=>e.check(Wi(Go,t)),e.cidrv6=t=>e.check(Gi(Ko,t)),e.e164=t=>e.check(Ji(Yo,t)),e.datetime=t=>e.check(ao(t)),e.date=t=>e.check(so(t)),e.time=t=>e.check(lo(t)),e.duration=t=>e.check(fo(t))});function R(e){return Di(Ao,e)}var jo=L(`ZodStringFormat`,(e,t)=>{fr.init(e,t),ko.init(e,t)}),Mo=L(`ZodEmail`,(e,t)=>{hr.init(e,t),jo.init(e,t)}),No=L(`ZodGUID`,(e,t)=>{pr.init(e,t),jo.init(e,t)}),Po=L(`ZodUUID`,(e,t)=>{mr.init(e,t),jo.init(e,t)}),Fo=L(`ZodURL`,(e,t)=>{gr.init(e,t),jo.init(e,t)}),Io=L(`ZodEmoji`,(e,t)=>{_r.init(e,t),jo.init(e,t)}),Lo=L(`ZodNanoID`,(e,t)=>{vr.init(e,t),jo.init(e,t)}),Ro=L(`ZodCUID`,(e,t)=>{yr.init(e,t),jo.init(e,t)}),zo=L(`ZodCUID2`,(e,t)=>{br.init(e,t),jo.init(e,t)}),Bo=L(`ZodULID`,(e,t)=>{xr.init(e,t),jo.init(e,t)}),Vo=L(`ZodXID`,(e,t)=>{Sr.init(e,t),jo.init(e,t)}),Ho=L(`ZodKSUID`,(e,t)=>{Cr.init(e,t),jo.init(e,t)}),Uo=L(`ZodIPv4`,(e,t)=>{Or.init(e,t),jo.init(e,t)}),Wo=L(`ZodIPv6`,(e,t)=>{kr.init(e,t),jo.init(e,t)}),Go=L(`ZodCIDRv4`,(e,t)=>{Ar.init(e,t),jo.init(e,t)}),Ko=L(`ZodCIDRv6`,(e,t)=>{jr.init(e,t),jo.init(e,t)}),qo=L(`ZodBase64`,(e,t)=>{Nr.init(e,t),jo.init(e,t)}),Jo=L(`ZodBase64URL`,(e,t)=>{Fr.init(e,t),jo.init(e,t)}),Yo=L(`ZodE164`,(e,t)=>{Ir.init(e,t),jo.init(e,t)}),Xo=L(`ZodJWT`,(e,t)=>{Rr.init(e,t),jo.init(e,t)}),Zo=L(`ZodNumber`,(e,t)=>{zr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ra(e,t,n,r),Do(e,`ZodNumber`,{gt(e,t){return this.check(sa(e,t))},gte(e,t){return this.check(ca(e,t))},min(e,t){return this.check(ca(e,t))},lt(e,t){return this.check(aa(e,t))},lte(e,t){return this.check(oa(e,t))},max(e,t){return this.check(oa(e,t))},int(e){return this.check(es(e))},safe(e){return this.check(es(e))},positive(e){return this.check(sa(0,e))},nonnegative(e){return this.check(ca(0,e))},negative(e){return this.check(aa(0,e))},nonpositive(e){return this.check(oa(0,e))},multipleOf(e,t){return this.check(la(e,t))},step(e,t){return this.check(la(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 Qo(e){return ea(Zo,e)}var $o=L(`ZodNumberFormat`,(e,t)=>{Br.init(e,t),Zo.init(e,t)});function es(e){return ta($o,e)}var ts=L(`ZodBoolean`,(e,t)=>{Vr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>za(e,t,n,r)});function ns(e){return na(ts,e)}var rs=L(`ZodUnknown`,(e,t)=>{Hr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function is(){return ra(rs)}var as=L(`ZodNever`,(e,t)=>{Ur.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ba(e,t,n,r)});function os(e){return ia(as,e)}var ss=L(`ZodArray`,(e,t)=>{Gr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ga(e,t,n,r),e.element=t.element,Do(e,`ZodArray`,{min(e,t){return this.check(da(e,t))},nonempty(e){return this.check(da(1,e))},max(e,t){return this.check(ua(e,t))},length(e,t){return this.check(fa(e,t))},unwrap(){return this.element}})});function cs(e,t){return Ta(ss,e,t)}var ls=L(`ZodObject`,(e,t)=>{Xr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ka(e,t,n,r),vt(e,`shape`,()=>t.shape),Do(e,`ZodObject`,{keyof(){return bs(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:is()})},loose(){return this.clone({...this._zod.def,catchall:is()})},strict(){return this.clone({...this._zod.def,catchall:os()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return It(this,e)},safeExtend(e){return Lt(this,e)},merge(e){return Rt(this,e)},pick(e){return Pt(this,e)},omit(e){return Ft(this,e)},partial(...e){return zt(Ts,this,e[0])},required(...e){return Bt(Fs,this,e[0])}})});function us(e,t){return new ls({type:`object`,shape:e??{},...jt(t)})}var ds=L(`ZodUnion`,(e,t)=>{Qr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qa(e,t,n,r),e.options=t.options});function fs(e,t){return new ds({type:`union`,options:e,...jt(t)})}var ps=L(`ZodDiscriminatedUnion`,(e,t)=>{ds.init(e,t),$r.init(e,t)});function ms(e,t,n){return new ps({type:`union`,options:t,discriminator:e,...jt(n)})}var hs=L(`ZodIntersection`,(e,t)=>{ei.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ja(e,t,n,r)});function gs(e,t){return new hs({type:`intersection`,left:e,right:t})}var _s=L(`ZodRecord`,(e,t)=>{ri.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ya(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function vs(e,t,n){return!t||!t._zod?new _s({type:`record`,keyType:R(),valueType:e,...jt(t)}):new _s({type:`record`,keyType:e,valueType:t,...jt(n)})}var ys=L(`ZodEnum`,(e,t)=>{ii.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Va(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 ys({...t,checks:[],...jt(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 ys({...t,checks:[],...jt(r),entries:i})}});function bs(e,t){return new ys({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...jt(t)})}var xs=L(`ZodLiteral`,(e,t)=>{ai.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ha(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 Ss(e,t){return new xs({type:`literal`,values:Array.isArray(e)?e:[e],...jt(t)})}var Cs=L(`ZodTransform`,(e,t)=>{oi.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wa(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ct(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(qt(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(qt(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 ws(e){return new Cs({type:`transform`,transform:e})}var Ts=L(`ZodOptional`,(e,t)=>{ci.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ro(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Es(e){return new Ts({type:`optional`,innerType:e})}var Ds=L(`ZodExactOptional`,(e,t)=>{li.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ro(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Os(e){return new Ds({type:`optional`,innerType:e})}var ks=L(`ZodNullable`,(e,t)=>{ui.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function As(e){return new ks({type:`nullable`,innerType:e})}var js=L(`ZodDefault`,(e,t)=>{di.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ms(e,t){return new js({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Dt(t)}})}var Ns=L(`ZodPrefault`,(e,t)=>{pi.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$a(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ps(e,t){return new Ns({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Dt(t)}})}var Fs=L(`ZodNonOptional`,(e,t)=>{mi.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Za(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Is(e,t){return new Fs({type:`nonoptional`,innerType:e,...jt(t)})}var Ls=L(`ZodCatch`,(e,t)=>{gi.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Rs(e,t){return new Ls({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var zs=L(`ZodPipe`,(e,t)=>{_i.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>to(e,t,n,r),e.in=t.in,e.out=t.out});function Bs(e,t){return new zs({type:`pipe`,in:e,out:t})}var Vs=L(`ZodReadonly`,(e,t)=>{yi.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>no(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hs(e){return new Vs({type:`readonly`,innerType:e})}var Us=L(`ZodCustom`,(e,t)=>{xi.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ua(e,t,n,r)});function Ws(e,t={}){return Ea(Us,e,t)}function Gs(e,t){return Da(e,t)}var Ks={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 qs(e){return(e.credentialVariants??[]).filter(e=>!e.operatorOnly)}function Js(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 Ys(e,t){return e.filter(e=>e.definition.id===t||e.definition.clientGroup===t&&e.definition.id!==t)}function Xs(e){return Js(e).filter(e=>e.definition.enabled&&e.definition.credentialClass!==`none`&&e.definition.poolOnly!==!0&&T(e.definition.id)&&!D(e.definition.id))}function Zs(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 Qs(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}:Zs(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 $s=ms(`type`,[us({type:Ss(`oauth-device`),deviceAuthorizationUrl:R().url(),tokenUrl:R().url(),clientId:R().min(1),scopes:cs(R().min(1)).min(1),signInLabel:R().min(1).optional(),referrer:R().min(1).optional(),tokensNeverExpire:ns().optional(),identify:bs([`github-copilot`]).optional()}),us({type:Ss(`openai-device`),deviceAuthorizationUrl:R().url(),pollUrl:R().url(),tokenUrl:R().url(),verificationUri:R().url(),redirectUri:R().url(),clientId:R().min(1),signInLabel:R().min(1).optional()})]),ec=us({id:R().min(1),displayName:R().min(1),upstreamId:R().min(1).optional(),servedBy:cs(R().min(1)).optional(),subscriptionServedBy:cs(R().min(1)).optional(),engine:Ss(`agy-server`).optional(),engineByProvider:vs(R().min(1),bs([`agy-server`,`claude`])).optional(),contextWindow:Qo().int().positive().optional(),maxOutputTokens:Qo().int().positive().optional(),supportsTools:ns().optional(),supportsThinking:ns().optional(),effortLevels:cs(bs(Fe)).optional(),defaultEffort:bs(Fe).optional(),helperModel:R().min(1).optional(),supportsVision:ns().optional(),inputPricePerM:Qo().nonnegative().optional(),outputPricePerM:Qo().nonnegative().optional(),creditsPerM:us({input:Qo().nonnegative(),output:Qo().nonnegative(),maxInput:Qo().nonnegative().optional(),maxOutput:Qo().nonnegative().optional()}).optional(),notes:R().optional(),free:ns().optional(),aaIntelligence:Qo().optional(),aaCoding:Qo().optional(),aaOutputTps:Qo().optional(),aaTtft:Qo().optional(),aa:us({fetchedAt:R(),creator:R().optional(),releaseDate:R().optional(),benchmarks:vs(R(),Qo()).optional()}).loose().optional()}).loose(),tc=us({id:R().regex(/^[a-z0-9][a-z0-9-]{1,40}$/,`provider id must be lowercase kebab-case`),displayName:R().min(1),kind:bs([`anthropic-passthrough`,`openai-compatible`,`gemini`]),route:bs([`gateway`,`direct`]),credentialClass:bs([`api_key`,`subscription`,`none`]),baseUrl:R().url(),messagesPath:R().startsWith(`/`).optional(),modelsPath:R().startsWith(`/`).optional(),auth:us({header:bs([`x-api-key`,`authorization-bearer`,`api-key`,`x-goog-api-key`,`none`]),extraHeaders:vs(R(),R()).optional()}),models:cs(ec),defaultModel:R().min(1),modelAliases:vs(R(),R()).optional(),helperModel:R().min(1).optional(),capabilities:us({streaming:ns(),tools:ns(),thinking:ns(),vision:ns(),countTokens:ns(),promptCaching:ns(),promptCacheTtlSec:Qo().int().positive().optional()}),translate:us({maxTokensParam:bs([`max_tokens`,`max_completion_tokens`]).optional(),reasoningEffortFromBudget:ns().optional(),reasoningContentField:R().nullable().optional(),supportsParallelToolCalls:ns().optional(),systemRole:bs([`system`,`developer`]).optional(),streamIncludeUsage:ns().optional(),wire:bs([`chat`,`responses`]).optional()}).optional(),passthrough:us({stripCacheControl:ns().optional(),cacheChain:ns().optional(),toolSchemaRequiredArray:ns().optional(),toolDescriptionRequired:ns().optional(),keepOutputConfig:ns().optional(),allowedBetas:cs(R()).optional(),anthropicVersion:R().optional()}).optional(),userBaseUrl:ns().optional(),engineEnv:vs(R(),R()).optional(),directCapable:ns().optional(),subscriptionLogin:$s.optional(),museCliLogin:us({type:Ss(`muse-cli`),signInLabel:R().min(1).optional()}).optional(),poolOnly:ns().optional(),contributorMode:us({suffix:R().min(1),summary:R().min(1)}).optional(),phase:fs([Ss(1),Ss(2)]),enabled:ns(),docsUrl:R().url().optional(),notes:R().optional(),references:cs(us({label:R().min(1),url:R().url(),kind:bs([`docs`,`pricing`,`models`,`console`,`status`,`keys`,`signup`,`other`]).optional()})).optional(),keyFormat:R().optional(),credentialVariants:cs(us({id:R().min(1),label:R().min(1),header:bs([`x-api-key`,`authorization-bearer`,`api-key`,`x-goog-api-key`,`none`]).optional(),extraHeaders:vs(R(),R()).optional(),operatorOnly:ns().optional(),requiresClaudeCodeIdentity:ns().optional(),subscriptionLogin:$s.optional(),agyLogin:us({type:Ss(`agy-server`),signInLabel:R().optional()}).optional(),codexLogin:us({type:Ss(`codex-server`),signInLabel:R().optional()}).optional(),museLogin:us({type:Ss(`muse-server`),signInLabel:R().optional()}).optional(),claudeCodeShape:us({betas:R().min(1),userAgent:R().min(1),billingHeader:R().min(1),headers:vs(R(),R()).optional()}).optional(),baseUrl:R().url().optional(),keyFormat:R().optional(),notes:R().optional()})).optional(),adminGroup:R().optional(),clientGroup:R().optional(),recordLabel:R().optional(),engine:Ss(`agy`).optional(),effortLevels:cs(bs(Fe)).optional(),defaultEffort:bs(Fe).optional()});us({version:Qo().int().positive(),updatedAt:R(),providers:cs(tc)});function nc(e,t){return rc(e,fc(e,t))}function rc(e,t){return e.models.find(e=>e.id===t)?.upstreamId??t}function ic(e){return/^claude-/i.test(e)}function ac(e){return/^claude-.+-\d{8}$/i.test(e)?e.replace(/-\d{8}$/,``):null}function oc(e){return e.replace(/\[1m\]$/i,``)}var sc=new Set([`opus`,`sonnet`,`haiku`,`fable`]);function cc(e){return sc.has(e.toLowerCase())}function lc(e,t){let n=oc(t);if(cc(n)||e.models.some(e=>e.id===n))return null;let r=e.modelAliases;if(!r)return null;let i=ac(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 uc(e,t){return{images:e.models.find(e=>e.id===t)?.supportsVision??e.capabilities.vision,documents:ic(t)}}function dc(e,t,n){let r=uc(e,t),i=e.engine===`agy`,a=new Set;for(let e of n){let t=e?.type;t===`image`&&(i||!r.images)&&a.add(`image`),t===`document`&&(i||!r.documents)&&a.add(`document`)}return a}function fc(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=lc(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 pc={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}`,accountDelete:`/api/me/account/delete`,tokenPurge:e=>`/api/me/tokens/${e}/purge`,tokenSealed:e=>`/api/me/tokens/${e}/sealed`,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`,poolReleaseSession:`/api/me/pool/release-session`,poolAutoRoute:`/api/me/pool/auto-route`,poolNextSuggestion:`/api/me/pool/next-suggestion`,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`},mc=2048,hc=16384,gc=8e3,_c=5242880,vc=12582912;new Set(`BCDFGHJKLMNPQRSTVWXZ`.split(``));var yc=`discard-my-vault-and-history`,bc=`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.`,xc={notes:100,title:80,text:1e5,totalText:1e6},Sc={name:120,instructions:2e4,goal:2e3,repositories:50,repositoryUrl:500,memory:2e4,minIntervalFloor:1,minIntervalCeiling:10080},Cc=`⏰ Scheduled task "`;function wc(e){if(!e.startsWith(Cc))return null;let t=e.indexOf(`"
|
|
85
85
|
|
|
86
|
-
`,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 Tc(e){return e===null||!Number.isFinite(e)?`neutral`:e>30?`ok`:e>10?`warn`:`danger`}var Ec=3e4,Dc=1440,Oc=6e4,kc=[`mon`,`tue`,`wed`,`thu`,`fri`,`sat`,`sun`],Ac=/^([01]\d|2[0-3]):[0-5]\d$/;us({tz:R().min(1),windows:cs(us({from:R().regex(Ac,`HH:MM`),to:R().regex(Ac,`HH:MM`),days:cs(bs(kc)).optional(),kind:bs([`peak`,`offpeak`])})),offpeakDiscount:Qo().nonnegative().max(1).optional()});var jc=[`priceInputCacheMissPeak`,`priceInputCacheMissOffpeak`,`priceInputCacheHitPeak`,`priceInputCacheHitOffpeak`,`priceCacheWritePeak`,`priceCacheWriteOffpeak`,`priceOutputPeak`,`priceOutputOffpeak`],Mc=us({inputCacheMiss:Qo().nonnegative(),inputCacheHit:Qo().nonnegative().optional(),cacheWrite:Qo().nonnegative().optional(),output:Qo().nonnegative()});us({by:Ss(`prompt_tokens`),tiers:cs(us({upToPromptTokens:Qo().int().positive().optional(),price:Mc.optional(),cost:Mc.optional()})).min(1),note:R().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})}),[...jc];var Nc={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`};Nc.realtime,Nc.translations,Nc.live,Nc.speechStream,Nc.transcriptionStream;var Pc=`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`,Fc=`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`,Ic=`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`,Lc=`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`,Rc={oonacode:{hex:`#000000`,owner:`OonaCode`,d:Pc,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:Ic},xai:{hex:`#000000`,owner:`xAI`,d:Fc},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:Fc},"openai-subscription":{hex:`#000000`,owner:`OpenAI`,d:Ic},"openai-codex":{hex:`#000000`,owner:`OpenAI`,d:Ic},"google-agy":{hex:`#8E75B2`,owner:`Google`,d:Lc},antigravity:{hex:`#8E75B2`,owner:`Google`,d:Lc},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 zc(e){return Rc[e]??null}function Bc(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 Vc=9230,Hc=1024,Uc=65534,Wc=`127.0.0.1`;Object.freeze({enabled:!1,port:Vc,inspectMain:!1}),Object.freeze({port:null,listening:!1,fromCommandLine:!1,inspectPort:null,inspectProblem:null});function Gc(e){return e+1}function Kc(e){return typeof e==`number`&&Number.isInteger(e)}function qc(e){return!Kc(e)||e<1024||e>65534?`The port must be a whole number from ${Hc.toLocaleString(`en-US`)} to ${Uc.toLocaleString(`en-US`)} (the main-process inspector takes the next one).`:null}function Jc(e){return e.port!==null||e.inspectPort!==null}function Yc(e,t){let n=e.enabled?e.port:null,r=e.enabled&&e.inspectMain?Gc(e.port):null;return!t.fromCommandLine&&t.port!==n||t.inspectPort!==r||Xc(t)}function Xc(e){return!Jc(e)&&typeof e.chromiumUntilRestart==`number`}function Zc(e){let t=[];return e.port!==null&&t.push(`${Wc}:${e.port}`),e.inspectPort!==null&&t.push(`${Wc}:${e.inspectPort}`),t.length===2?`${t[0]} (windows) and ${t[1]} (main process)`:e.inspectPort===null?t[0]??``:`${t[0]} (main process)`}var Qc=[`stable`,`dev`];function $c(e){return typeof e==`string`&&Qc.includes(e)}function el(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return $c(t)?t:null}var tl=[`win32`,`linux`,`darwin`],nl=[`x64`,`arm64`];function rl(e,t){let n=el(e)??`stable`,r=[];return n!==`stable`&&r.push(`channel=${encodeURIComponent(n)}`),t&&tl.includes(t.platform)&&(r.push(`platform=${t.platform}`),t.arch&&nl.includes(t.arch)&&r.push(`arch=${t.arch}`)),r.length>0?`${pc.releasesLatest}?${r.join(`&`)}`:pc.releasesLatest}function il(e,t){let n=el(t)??`stable`;return n===`stable`?e:`${e} (${n})`}var al={safeguards:`safeguards`,safety_filters:`safety filters`},ol=[{vendor:`Alibaba (Model Studio / DashScope — Qwen, and the DeepSeek/GLM it hosts)`,seenAs:`400 {"error":{"code":"data_inspection_failed","message":"Input data may contain inappropriate content."}}`,pattern:/data[_ ]?inspection[_ ]?failed|may contain inappropriate content/i},{vendor:`Zhipu (GLM)`,seenAs:`400 {"error":{"code":"1301","message":"系统检测到输入或生成内容可能包含不安全或敏感内容…"}} (contentFilter)`,pattern:/"code"\s*:\s*"?1301"?|不安全或敏感内容|unsafe or sensitive content|contentFilter/i},{vendor:`DeepSeek`,seenAs:`400 {"error":{"message":"Content Exists Risk","type":"invalid_request_error"}}`,pattern:/content exists risk/i},{vendor:`Moonshot (Kimi)`,seenAs:`400 {"error":{"type":"content_filter","message":"The request was rejected because it was considered high risk"}}`,pattern:/"type"\s*:\s*"content_filter"|considered high risk/i},{vendor:`xAI (Grok)`,seenAs:`400 "Content violates usage guidelines. Failed check: SAFETY_CHECK_TYPE_…"`,pattern:/content violates usage guidelines|SAFETY_CHECK_TYPE_/i},{vendor:`OpenAI (and Azure-style filters)`,seenAs:`400 {"error":{"code":"content_filter" | "content_policy_violation" | "moderation_blocked"}}`,pattern:/"code"\s*:\s*"(?:content_filter|content_policy_violation|moderation_blocked)"/i},{vendor:`Google (Gemini)`,seenAs:`This request was blocked by Gemini's filters. They can occasionally trigger by mistake on safe coding, security, or biology-related queries.`,pattern:/blocked by Gemini(?:'s)? filters|Gemini(?:'s)? filters/i}],sl=/blocked by (?:the )?(?:content[ -]safety|Gemini(?:'s)?) filters?|content safety filters?|blocked by Gemini(?:'s)? filters?/i,cl=/blocked by Gemini(?:'s)? filters|Gemini(?:'s)? filters\.? They can occasionally trigger/i;function ll(e){return typeof e==`string`&&cl.test(e)}function ul(e){return typeof e!=`string`||e===``||!/^\s*(?:Failed to authenticate\.\s*)?API Error\b/i.test(e)?null:ol.find(t=>t.pattern.test(e))??null}function dl(e){return typeof e==`string`&&(ll(e)||sl.test(e)&&/blocked/i.test(e))}function fl(e){return typeof e==`string`&&e.includes(`Something went wrong on our side with this model`)}var pl=`:free`;function ml(e){return e.endsWith(pl)}function hl(e){return ml(e)?e.slice(0,-5):e}var gl=`model_refusal_fallback`,_l=`model_refusal_no_fallback`;function vl(e){return typeof e==`string`&&e.trim()!==``?e.trim():null}function yl(e,t,n){return vl(e[t])??vl(e[n])}function bl(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:yl(t,`original_model`,`originalModel`),fallbackModel:r===`fallback`?yl(t,`fallback_model`,`fallbackModel`):null,category:yl(t,`api_refusal_category`,`apiRefusalCategory`)??vl(t.category),explanation:yl(t,`api_refusal_explanation`,`apiRefusalExplanation`)??vl(t.explanation),text:typeof t.content==`string`?t.content.trim():vl(t.text)??``,retractedUuids:Array.isArray(i)?i.filter(e=>typeof e==`string`):[]}}function xl(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 Sl(e,t){return!e||t.alive===!1||!e.live&&t.since!==null&&e.at!==null&&e.at<t.since?null:e}function Cl(e){let t=oc(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 wl(e,t=[]){let n=oc(e.trim()),r=null;for(let e of t)for(let t of e.definition.models){if(t.id===n||oc(t.id)===n)return t.displayName;r===null&&(t.upstreamId===n||hl(t.id)===n)&&(r=t.displayName)}return r??Cl(n)}function Tl(e){return`${e} (safeguard)`}var El=`none`,Dl={mode:`auto`,model:null,perModel:{}};function Ol(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0&&t.length<=200&&/^[A-Za-z0-9._:@/[\]-]+$/.test(t)?t:null}function kl(e){return oc(e.trim()).toLowerCase()}function Al(e){let t=typeof e==`object`&&e&&!Array.isArray(e)?e:{},n=Ol(t.model),r=t.mode,i=r===`off`?`off`:r===`model`&&n!==null?`model`:`auto`,a={},o=t.perModel;if(typeof o==`object`&&o&&!Array.isArray(o))for(let[e,t]of Object.entries(o)){let n=Ol(e),r=t===`none`?El:Ol(t);if(n!==null&&r!==null&&kl(n)!==kl(r)&&(a[kl(n)]=r,Object.keys(a).length>=64))break}return{mode:i,model:i===`model`?n:null,perModel:a}}function jl(e){return e===w}var Ml=`oona settings safeguard-fallback auto`;function Nl(e,t=[]){if(!e)return`the model`;let n=kl(e);return t.find(e=>kl(e.id)===n||e.upstreamId&&kl(e.upstreamId)===n)?.displayName??Cl(e)}function Pl(e,t=e=>Nl(e)){let n=`blocked by ${al[e.reason]}`;if(e.outcome===`retried`)return`${n} → retried on ${e.retriedOn?t(e.retriedOn):`another model`}`;switch(e.blocked){case`off`:return`${n} · fallback off (${Ml})`;case`no_model`:return`${n} · no fallback model`;case`unavailable`:return`${n} · fallback not available here`;case`refused_again`:return`${n} · fallback refused too`;case`not_retryable`:return`${n} · not retried`;default:return n}}var Fl=5e4,Il=6,Ll=[`sessions`,`search`,`files`],Rl=[`media`,`sessionInfo`];function zl(e){return typeof e==`string`&&Ll.includes(e)?e:null}function Bl(e){if(!Array.isArray(e))return null;let t=[];for(let n of e)typeof n==`string`&&Rl.includes(n)&&!t.includes(n)&&t.push(n);return t}var Vl=[`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`],Hl=/^[A-Za-z0-9 ,'"_-]+$/,Ul=/^(?:[A-Za-z0-9 _-]+|'[A-Za-z0-9 _-]+'|"[A-Za-z0-9 _-]+")$/;function Wl(e){let t=typeof e==`number`&&Number.isFinite(e)?Math.round(e):NaN;return Number.isFinite(t)?Math.min(28,Math.max(10,t)):null}function Gl(e){if(typeof e!=`string`)return null;let t=e.trim().slice(0,160).trim();return t.length===0||!Hl.test(t)?null:t.split(`,`).every(e=>Ul.test(e.trim()))?t:null}function Kl(e){let t=pu(e);return{family:Gl(t.family),size:Wl(t.size)}}function ql(e){let t=pu(e);return{chat:Kl(t.chat),sidebar:Kl(t.sidebar)}}var Jl={agentFinished:!1,permissionRequired:!0,errorOccurred:!0},Yl={autoAcceptPermissions:!1,autosaveFiles:!1,safeguardFallback:Dl,showReasoningSummaries:!0,notifications:Jl,showAgentPicker:!0,transcriptWindowSize:500,keptTranscripts:3,openTabs:[],draftTabs:[],draftTitles:{},activeTab:null,editorLayout:null,remoteTabs:{},sessionPanelOpen:!1,explorerOpen:!1,leftPanelSection:`sessions`,leftPanelOpen:!0,rightPanelSections:[],rightPanelCollapsed:[],sidebarWidth:288,sessionPanelWidth:288,mediaPanelWidth:320,rightPanelWidth:320,sidebarPinned:!0,dismissedUpdateVersion:null,lastSeenReleaseNotes:null,claudeImportOffered:!1,claudeImportOffers:0,collapsedProjects:[],themeColors:{light:{},dark:{}},fonts:{chat:{family:null,size:null},sidebar:{family:null,size:null}},pinned:[],sidebarView:`recent`};function Xl(e){return Math.min(Math.max(typeof e==`number`&&Number.isFinite(e)?Math.floor(e):0,0),3)}function Zl(e){return Math.min(640,Math.max(200,typeof e==`number`&&Number.isFinite(e)?Math.round(e):288))}function Ql(e,t){return Math.min(720,Math.max(240,typeof e==`number`&&Number.isFinite(e)?Math.round(e):t))}function $l(e){return Math.min(20,Math.max(0,typeof e==`number`&&Number.isFinite(e)?Math.round(e):3))}function eu(e){return Math.min(Fl,Math.max(100,typeof e==`number`&&Number.isFinite(e)?Math.round(e):500))}function tu(e,t){return typeof e==`boolean`?e:t}function nu(e){return typeof e==`string`&&e.length>0&&e.length<=64?e:null}function ru(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 iu(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 au(e){if(typeof e!=`string`)return null;let t=e.trim();return/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():null}function ou(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(!Vl.includes(n))continue;let e=au(r);e!==null&&(t[n]=e)}return t}function su(e){let t=typeof e==`object`&&e?e:{};return{light:ou(t.light),dark:ou(t.dark)}}function cu(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 lu(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>Il||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 uu(e,t,n){return e.some(e=>e.kind===t&&e.id===n)}function du(e,t,n,r){return r===uu(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 fu(e){let t=typeof e==`object`&&e?e:{},n=typeof t.notifications==`object`&&t.notifications!==null?t.notifications:{},r=ru(t.openTabs),i=ru(t.draftTabs).filter(e=>!r.includes(e)),a={};for(let[e,n]of Object.entries(iu(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,l=tu(t.sessionPanelOpen,Yl.sessionPanelOpen),u=tu(t.explorerOpen,Yl.explorerOpen),d=Bl(t.rightPanelSections)??(l?[`sessionInfo`]:[]),f=(Bl(t.rightPanelCollapsed)??[]).filter(e=>d.includes(e));return{autoAcceptPermissions:tu(t.autoAcceptPermissions,Yl.autoAcceptPermissions),autosaveFiles:tu(t.autosaveFiles,Yl.autosaveFiles),safeguardFallback:Al(t.safeguardFallback),showReasoningSummaries:tu(t.showReasoningSummaries,Yl.showReasoningSummaries),notifications:{agentFinished:tu(n.agentFinished,Jl.agentFinished),permissionRequired:tu(n.permissionRequired,Jl.permissionRequired),errorOccurred:tu(n.errorOccurred,Jl.errorOccurred)},showAgentPicker:tu(t.showAgentPicker,Yl.showAgentPicker),transcriptWindowSize:eu(t.transcriptWindowSize),keptTranscripts:$l(t.keptTranscripts),openTabs:r,draftTabs:i,draftTitles:a,activeTab:c,editorLayout:lu(t.editorLayout,o),remoteTabs:iu(t.remoteTabs),sessionPanelOpen:l,explorerOpen:u,leftPanelSection:zl(t.leftPanelSection)??(u?`files`:`sessions`),leftPanelOpen:tu(t.leftPanelOpen,Yl.leftPanelOpen),rightPanelSections:d,rightPanelCollapsed:f,sidebarWidth:Zl(t.sidebarWidth),sessionPanelWidth:Ql(t.sessionPanelWidth,288),mediaPanelWidth:Ql(t.mediaPanelWidth,320),rightPanelWidth:Ql(t.rightPanelWidth??t.mediaPanelWidth??t.sessionPanelWidth,320),sidebarPinned:tu(t.sidebarPinned,Yl.sidebarPinned),dismissedUpdateVersion:nu(t.dismissedUpdateVersion),lastSeenReleaseNotes:nu(t.lastSeenReleaseNotes),claudeImportOffered:tu(t.claudeImportOffered,Yl.claudeImportOffered),claudeImportOffers:Xl(t.claudeImportOffers),collapsedProjects:ru(t.collapsedProjects),themeColors:su(t.themeColors),fonts:ql(t.fonts),pinned:cu(t.pinned),sidebarView:t.sidebarView===`projects`?`projects`:`recent`}}new Set(Object.keys(Yl));function pu(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}var mu=3650,hu=[{version:`0.3.363`,date:`2026-11-18`,platforms:[`darwin`],added:[`3D models in chats: a new “3D model” tool next to Images, Video and Speech makes a textured 3D model (GLB, and FBX, OBJ, STL or USDZ if you ask) from a picture in the chat’s folder, from 2–4 views of one object, or from a description. Quality low, medium or high, priced per model; it is made on OonaCode’s own GPU server. Not offered in the EU, the UK or South Korea, because of the 3D model’s licence.`],fixed:[`A chat that was itself started by another chat can now start new chats too (each still needs your yes), and one chat can keep up to 10 chats it started open.`]},{version:`0.3.362`,date:`2026-11-18`,platforms:[`linux`],added:[`3D models in chats: a new “3D model” tool next to Images, Video and Speech makes a textured 3D model (GLB, and FBX, OBJ, STL or USDZ if you ask) from a picture in the chat’s folder, from 2–4 views of one object, or from a description. Quality low, medium or high, priced per model; it is made on OonaCode’s own GPU server. Not offered in the EU, the UK or South Korea, because of the 3D model’s licence.`],fixed:[`A chat that was itself started by another chat can now start new chats too (each still needs your yes), and one chat can keep up to 10 chats it started open.`]},{version:`0.3.361`,date:`2026-11-18`,platforms:[`win32`],added:[`3D models in chats: a new “3D model” tool next to Images, Video and Speech makes a textured 3D model (GLB, and FBX, OBJ, STL or USDZ if you ask) from a picture in the chat’s folder, from 2–4 views of one object, or from a description. Quality low, medium or high, priced per model; it is made on OonaCode’s own GPU server. Not offered in the EU, the UK or South Korea, because of the 3D model’s licence.`],fixed:[`A chat that was itself started by another chat can now start new chats too (each still needs your yes), and one chat can keep up to 10 chats it started open.`]},{version:`0.3.360`,date:`2026-11-18`,platforms:[`darwin`],added:[`A chat running on another of your PCs: its Image, Video and Speech model and “Ask me first” can now be changed from here too, in the Tools menu (that PC needs this version).`,`The PCs of OonaCode’s own operator account can be updated from the admin panel; an update waits until no chat on the PC is working.`],fixed:["Signed in with an OonaCode API key, the model list (`oona models`, the picker) shows only the models that key can use, and refreshes itself every 10 minutes."]},{version:`0.3.359`,date:`2026-11-18`,platforms:[`linux`],added:[`A chat running on another of your PCs: its Image, Video and Speech model and “Ask me first” can now be changed from here too, in the Tools menu (that PC needs this version).`,`The PCs of OonaCode’s own operator account can be updated from the admin panel; an update waits until no chat on the PC is working.`],fixed:["Signed in with an OonaCode API key, the model list (`oona models`, the picker) shows only the models that key can use, and refreshes itself every 10 minutes."]},{version:`0.3.358`,date:`2026-11-18`,platforms:[`win32`],added:[`A chat running on another of your PCs: its Image, Video and Speech model and “Ask me first” can now be changed from here too, in the Tools menu (that PC needs this version).`,`The PCs of OonaCode’s own operator account can be updated from the admin panel; an update waits until no chat on the PC is working.`],fixed:["Signed in with an OonaCode API key, the model list (`oona models`, the picker) shows only the models that key can use, and refreshes itself every 10 minutes."]},{version:`0.3.357`,date:`2026-11-17`,platforms:[`darwin`],added:[`Claude Opus 5.5 and Claude Sonnet 5.5 on OonaCode’s pool are now ordinary models in the picker, served through Google: one entry each, whoever serves it. A chat saved on the old “via Google” names keeps working.`,`Image, video and voice: the chat now knows every media model and what each can do. When a task needs another one — editing a picture, say — it asks you with one click (Switch / Keep) before anything is made or charged, in every mode.`,`A media model that cannot do what was asked now says which ones can.`],fixed:[`A chat with folders linked from another PC (“Bring this PC into the chat”) is told which PC and folders from the first message, so it starts there instead of asking where your project is.`,`A PDF sent to Claude through Google is passed as a file it can read, not dropped.`]},{version:`0.3.356`,date:`2026-11-17`,platforms:[`linux`],added:[`Claude Opus 5.5 and Claude Sonnet 5.5 on OonaCode’s pool are now ordinary models in the picker, served through Google: one entry each, whoever serves it. A chat saved on the old “via Google” names keeps working.`,`Image, video and voice: the chat now knows every media model and what each can do. When a task needs another one — editing a picture, say — it asks you with one click (Switch / Keep) before anything is made or charged, in every mode.`,`A media model that cannot do what was asked now says which ones can.`],fixed:[`A chat with folders linked from another PC (“Bring this PC into the chat”) is told which PC and folders from the first message, so it starts there instead of asking where your project is.`,`A PDF sent to Claude through Google is passed as a file it can read, not dropped.`]},{version:`0.3.355`,date:`2026-11-17`,platforms:[`win32`],added:[`Claude Opus 5.5 and Claude Sonnet 5.5 on OonaCode’s pool are now ordinary models in the picker, served through Google: one entry each, whoever serves it. A chat saved on the old “via Google” names keeps working.`,`Image, video and voice: the chat now knows every media model and what each can do. When a task needs another one — editing a picture, say — it asks you with one click (Switch / Keep) before anything is made or charged, in every mode.`,`A media model that cannot do what was asked now says which ones can.`],fixed:[`A chat with folders linked from another PC (“Bring this PC into the chat”) is told which PC and folders from the first message, so it starts there instead of asking where your project is.`,`A PDF sent to Claude through Google is passed as a file it can read, not dropped.`]},{version:`0.3.354`,date:`2026-11-17`,platforms:[`darwin`],added:[`Google models on OonaCode’s pool can now start subagents: helpers that work in parallel with the same tools on your PC, each under its own Agent card and in the subagent badge.`,`On your own Google plan (agy), the subagents agy starts now show their work in the chat: the Agent card stays open until the subagent finishes and then shows its answer.`,`The Android app can now choose a chat’s folder by tapping through this PC’s folders — it sees folder names only, over your private link.`,`Pins are shared with the Android app: a chat you pin on the phone is pinned here too, and the other way round.`,`Forking a chat from the phone names the copy as you asked, and can end it at a chosen message.`,`For chats on OonaCode’s pool, the PC now sends the chat’s title (its first 50 characters) so the operator’s admin page can show which chat uses which account. It is kept in memory only, never stored — see /privacy.`],fixed:['Chats on your own key: `thinking: {type: "between_tools"}` and structured output (`output_config.format`) now reach OpenAI-protocol providers as they do Anthropic’s.']},{version:`0.3.353`,date:`2026-11-17`,platforms:[`linux`],added:[`Google models on OonaCode’s pool can now start subagents: helpers that work in parallel with the same tools on your PC, each under its own Agent card and in the subagent badge.`,`On your own Google plan (agy), the subagents agy starts now show their work in the chat: the Agent card stays open until the subagent finishes and then shows its answer.`,`The Android app can now choose a chat’s folder by tapping through this PC’s folders — it sees folder names only, over your private link.`,`Pins are shared with the Android app: a chat you pin on the phone is pinned here too, and the other way round.`,`Forking a chat from the phone names the copy as you asked, and can end it at a chosen message.`,`For chats on OonaCode’s pool, the PC now sends the chat’s title (its first 50 characters) so the operator’s admin page can show which chat uses which account. It is kept in memory only, never stored — see /privacy.`],fixed:['Chats on your own key: `thinking: {type: "between_tools"}` and structured output (`output_config.format`) now reach OpenAI-protocol providers as they do Anthropic’s.']},{version:`0.3.352`,date:`2026-11-17`,platforms:[`win32`],added:[`Google models on OonaCode’s pool can now start subagents: helpers that work in parallel with the same tools on your PC, each under its own Agent card and in the subagent badge.`,`On your own Google plan (agy), the subagents agy starts now show their work in the chat: the Agent card stays open until the subagent finishes and then shows its answer.`,`For chats on OonaCode’s pool, the PC now sends the chat’s title (its first 50 characters) so the operator’s admin page can show which chat uses which account. It is kept in memory only, never stored — see /privacy.`],fixed:['Chats on your own key: `thinking: {type: "between_tools"}` and structured output (`output_config.format`) now reach OpenAI-protocol providers as they do Anthropic’s.']},{version:`0.3.351`,date:`2026-11-17`,platforms:[`android`],added:[],fixed:[`A chat with pictures, tables and charts no longer jumps up and down: pictures and file cards keep their size while they load, wide tables and code blocks no longer grow after they appear, and a chat you open again shows its pictures at once.`,`The chat no longer jumps when a reply finishes.`,`Voice typing says why it could not start and switches to Google’s speech recognition when the phone’s own recognizer refuses; you can pick the speech service in Settings → Voice typing.`,`Android’s Back button on Settings returns to the previous screen instead of leaving the app.`,`Send, Stop and the mic keep their places in the message box, so a quick second tap can no longer stop a turn or open voice typing by accident.`,`With the keyboard open, the first tap on a message’s menu or a custom model’s Use now works.`,`A custom model id that matches a listed model is shown as that model.`,`A message sent with Send now appears after the end of the turn it interrupted.`,`Chat notifications now name the chat.`,`The home-screen widget shows a proper preview in the widget picker and is found by searching OonaCode.`]},{version:`0.3.351`,date:`2026-11-17`,platforms:[`win32`],added:[`The Android app can now choose a chat’s folder by tapping through this PC’s folders — it sees folder names only, over your private link.`,`Pins are shared with the Android app: a chat you pin on the phone is pinned here too, and the other way round.`,`Forking a chat from the phone names the copy as you asked, and can end it at a chosen message.`],fixed:[]},{version:`0.3.350`,date:`2026-11-17`,platforms:[`android`],added:[`Long-press a chat to pin it to the top, fork it, move it to a project, change its folder or delete it. Pins are the same as on your PC.`,`A message’s menu can fork the chat from that message, or remove that exchange (or it and everything after).`,`Share text, links, photos and files into OonaCode from any app: pick the PC and the chat, or start a new chat, and it opens ready to send.`,`Voice typing: tap the mic in the message box and speak — Android’s own speech recognition writes your words as you talk; nothing goes to OonaCode and it costs no credits.`,`The + button takes a photo, picks pictures from your gallery or pastes a copied picture; large photos are made smaller automatically and their location is removed.`,`Reply to your agent, or Allow / Deny a permission, straight from the notification. If OonaCode is locked, the chat opens with your reply ready to send.`,`While a turn you started from the phone is running, a quiet “Working on…” notification with a Stop button shows.`,`After a reply, your PC’s suggested next message appears above the box — tap to use it, tap again or hold to send.`,`A badge beside the model shows how many subagents a chat is running; tap it to see each one and read its transcript.`,`Custom model… at the end of every provider in the model picker.`,`A home-screen widget with your recent chats, their PC and status, and a button to write in that chat. While OonaCode is locked it shows only “Open OonaCode”.`,`What’s new: after an update the app shows what changed, and Settings → About → What’s new lists it any time.`,`OonaCode offers its own updates from Google Play: the new version downloads in the background, and one tap on Restart installs it.`],fixed:[`Tapping a notification now opens that chat on its PC, even when the app was closed.`,`Each waiting message has its own Send now when several are queued, and a message sent now moves into the chat right away.`]},{version:`0.3.350`,date:`2026-11-17`,platforms:[`darwin`],added:[`Settings → Devices now lets you remove an offline PC from your account (it adds itself back when it comes online again) and revoke any other signed-in device, each after a confirmation.`,`Settings → Developer → Allow debugging now applies at once: a debugger can attach to the app’s windows right after you switch it on, and the port closes when you switch it off. No restart.`,"OonaCode for macOS now installs with npm (`npm i -g oonacode`, Apple Silicon and Intel) or Homebrew (`brew tap oonak-ai/tap https://oonacode.oonak.ai/releases/download/brew/homebrew-tap.git && brew install oonak-ai/tap/oonacode`).",`Persian, Georgian and every other language now play in “Listen to this chat” with the app’s own eSpeak voice, as on Windows.`,`Window control now works on single windows once Accessibility is allowed (it says exactly where to allow it), and can move and resize them.`],fixed:[`Signing in to your own Google plan (agy) now shows Google’s sign-in page right away instead of waiting forever.`,`Clicking a notification now opens the chat it is about, even if OonaCode was closed or the notification came from earlier.`,`“Check for Updates…”, “Stop host service” and About in the menu bar and app menu now work when the window is closed, and closing a full-screen window no longer leaves a black screen.`,`On Intel Macs, closing Oonak Browser’s last window now really quits it, so its Dock icon goes away; closing it no longer pauses about two seconds.`,`The red “Debugging on” badge and the window titles now follow Settings → Developer → Allow debugging at once, in every window — switched off, the badge goes. If OonaCode started with debugging on, Chromium’s own port can only close at a restart: the badge turns amber, “restart to close”, and Settings offers Restart now.`,`A message you type while a Google model on OonaCode’s server is working now reaches it at its next step — “please stop” no longer waits for the whole turn — and it leaves the queued strip as soon as the model has read it. Messages with pictures used to stay in the strip after they were read.`]},{version:`0.3.349`,date:`2026-11-17`,platforms:[`linux`],added:[`Settings → Devices now lets you remove an offline PC from your account (it adds itself back when it comes online again) and revoke any other signed-in device, each after a confirmation.`,`While OonaCode updates (AppImage, .deb or .rpm), a small “Updating OonaCode” window now shows until the new version opens.`,`Oonak Browser is now on by default in new chats, tested on KDE Plasma (Wayland and X11).`,`Window control now works on every window on KDE Plasma, Wayland included, with nothing to install, and can move and resize windows.`,`The .deb and .rpm now bring eSpeak NG and speech-dispatcher, so “Listen to this chat” speaks every language; on the AppImage the Listen window shows the exact install command for your distribution.`],fixed:[`On KDE Plasma (Wayland), a chat tab dragged out of the window now opens where you drop it, and “Move chat to new window” opens next to the window it came from.`,`On desktops with no tray icon (plain GNOME), closing the window now minimises OonaCode instead of hiding it where it cannot be found; a one-time note names the GNOME extension that adds the tray.`,`Signing in to your own Google plan (agy): OonaCode no longer mistakes agy’s browser for a stuck command, and leaves an agy installed by your package manager alone.`,`Closing the chat’s Oonak Browser no longer pauses about two seconds.`,"`npm i -g oonacode` works on Linux again: since 0.3.332 the npm package named only the Windows build."]},{version:`0.3.348`,date:`2026-11-17`,platforms:[`win32`],added:[`Settings → Devices now lets you remove an offline PC from your account (it adds itself back when it comes online again) and revoke any other signed-in device, each after a confirmation.`,`Window control can now move and resize windows, so the agent can arrange them side by side.`],fixed:[`Signing in to your own Google plan (agy): when the one-minute window runs out, the card now says so instead of a vague “did not finish”.`,"`npm i -g oonacode` keeps working on every platform after a release that built only some of them."]},{version:`0.3.347`,date:`2026-11-17`,platforms:[`win32`],added:[],fixed:[`The red “Debugging on” badge and the window titles now follow Settings → Developer → Allow debugging at once, in every window — switched off, the badge goes. If OonaCode started with debugging on, Chromium’s own port can only close at a restart: the badge turns amber, “restart to close”, and Settings offers Restart now.`]},{version:`0.3.346`,date:`2026-11-17`,platforms:[`linux`],added:[`Settings → Developer → Allow debugging now applies at once: a debugger can attach to the app’s windows right after you switch it on, and the port closes when you switch it off. No restart.`],fixed:[`A message you type while a Google model on OonaCode’s server is working now reaches it at its next step — “please stop” no longer waits for the whole turn — and it leaves the queued strip as soon as the model has read it. Messages with pictures used to stay in the strip after they were read.`]},{version:`0.3.345`,date:`2026-11-17`,platforms:[`win32`],added:[`Settings → Developer → Allow debugging now applies at once: a debugger can attach to the app’s windows right after you switch it on, and the port closes when you switch it off. No restart.`],fixed:[`A message you type while a Google model on OonaCode’s server is working now reaches it at its next step — “please stop” no longer waits for the whole turn — and it leaves the queued strip as soon as the model has read it. Messages with pictures used to stay in the strip after they were read.`]},{version:`0.3.344`,date:`2026-11-17`,platforms:[`win32`],added:[],fixed:[`When the Google account serving a chat runs out of quota for its model mid-turn, the chat says so and continues by itself on another of OonaCode’s accounts, instead of just stopping.`]},{version:`0.3.343`,date:`2026-11-17`,platforms:[`darwin`],added:[`Hovering a model in the model picker now shows its effort levels — the ones the chat’s effort menu offers for it — with its default marked.`],fixed:[`A long chat on a Google model (Gemini 3.8 Flash, Gemini 4 Hydrogen, Argon, Carbon) no longer stops with “The socket connection was closed unexpectedly” when OonaCode’s server restarts or the connection drops mid-turn: the chat says so, waits for the server and continues the same task by itself, where it left off. Stop still ends it at once.`,`A model’s details in the picker no longer end with a paragraph of internal setup notes; everything about the model itself (ratings, effort, context, prices, capabilities) stays.`]},{version:`0.3.342`,date:`2026-11-17`,platforms:[`linux`],added:[`Hovering a model in the model picker now shows its effort levels — the ones the chat’s effort menu offers for it — with its default marked.`],fixed:[`A long chat on a Google model (Gemini 3.8 Flash, Gemini 4 Hydrogen, Argon, Carbon) no longer stops with “The socket connection was closed unexpectedly” when OonaCode’s server restarts or the connection drops mid-turn: the chat says so, waits for the server and continues the same task by itself, where it left off. Stop still ends it at once.`,`A model’s details in the picker no longer end with a paragraph of internal setup notes; everything about the model itself (ratings, effort, context, prices, capabilities) stays.`]},{version:`0.3.341`,date:`2026-11-17`,platforms:[`win32`],added:[],fixed:[`A long chat on a Google model (Gemini 3.8 Flash, Gemini 4 Hydrogen, Argon, Carbon) no longer stops with “The socket connection was closed unexpectedly” when OonaCode’s server restarts or the connection drops mid-turn: the chat says so, waits for the server and continues the same task by itself, where it left off. Stop still ends it at once.`]},{version:`0.3.340`,date:`2026-11-17`,platforms:[`win32`],added:[`Hovering a model in the model picker now shows its effort levels — the ones the chat’s effort menu offers for it — with its default marked.`],fixed:[`A model’s details in the picker no longer end with a paragraph of internal setup notes; everything about the model itself (ratings, effort, context, prices, capabilities) stays.`]},{version:`0.3.339`,date:`2026-11-16`,platforms:[`darwin`],added:[`OonaCode uses much less memory with many chats open: only the chat on screen — and up to three you looked at recently — keeps its whole history loaded; the other open tabs still show their status and finished marks, and load their history again when you open them. With a dozen long chats open this saves several hundred MB.`,`Settings → This PC → Memory: how long a quiet chat keeps its agent running, how many idle agents may stay, and when an unused Oonak Browser closes (after 30 minutes nobody used it, by default). Settings → Advanced: how many hidden chats stay in memory.`],fixed:[`GitHub Copilot chats no longer show empty lines. When Copilot’s model thinks privately it sends an encrypted thought with no words, and each one drew as a blank line; they are no longer drawn (they stay in the chat’s history, so Copilot still gets them back on the next turn).`,`Opening a chat while it is working shows its history above the running turn, not below it.`,`The account panel and oona no longer say the sign-up gift never expires — credits you buy never expire; the gift ends after its welcome period.`]},{version:`0.3.338`,date:`2026-11-16`,platforms:[`linux`],added:[`OonaCode uses much less memory with many chats open: only the chat on screen — and up to three you looked at recently — keeps its whole history loaded; the other open tabs still show their status and finished marks, and load their history again when you open them. With a dozen long chats open this saves several hundred MB.`,`Settings → This PC → Memory: how long a quiet chat keeps its agent running, how many idle agents may stay, and when an unused Oonak Browser closes (after 30 minutes nobody used it, by default). Settings → Advanced: how many hidden chats stay in memory.`],fixed:[`GitHub Copilot chats no longer show empty lines. When Copilot’s model thinks privately it sends an encrypted thought with no words, and each one drew as a blank line; they are no longer drawn (they stay in the chat’s history, so Copilot still gets them back on the next turn).`,`Opening a chat while it is working shows its history above the running turn, not below it.`,`The account panel and oona no longer say the sign-up gift never expires — credits you buy never expire; the gift ends after its welcome period.`]},{version:`0.3.337`,date:`2026-11-16`,platforms:[`win32`],added:[],fixed:[`GitHub Copilot chats no longer show empty lines. When Copilot’s model thinks privately it sends an encrypted thought with no words, and each one drew as a blank line; they are no longer drawn (they stay in the chat’s history, so Copilot still gets them back on the next turn).`]},{version:`0.3.336`,date:`2026-11-16`,platforms:[`win32`],added:[`OonaCode uses much less memory with many chats open: only the chat on screen — and up to three you looked at recently — keeps its whole history loaded; the other open tabs still show their status and finished marks, and load their history again when you open them. With a dozen long chats open this saves several hundred MB.`,`Settings → This PC → Memory: how long a quiet chat keeps its agent running, how many idle agents may stay, and when an unused Oonak Browser closes (after 30 minutes nobody used it, by default). Settings → Advanced: how many hidden chats stay in memory.`],fixed:[`Opening a chat while it is working shows its history above the running turn, not below it.`,`The account panel no longer says the sign-up gift never expires — credits you buy never expire; the gift ends after its welcome period.`]},{version:`0.3.335`,date:`2026-11-15`,platforms:[`darwin`],added:[`Auto-suggest: after each answer the message box shows a greyed guess at what you might say next; press Tab to take it, then edit or send it. Nothing is sent by itself. In OonaCode pool chats the guess comes from OonaCode’s small fast models and costs a few credits; on your own Claude-protocol key or plan the engine makes it on that plan. Turn it off in Settings → This PC → "Auto-suggest my next message".`,`The usage card of a linked provider names the account its figures belong to — "Account: you@example.com", the whole account on hover — even when only one is linked.`,`OonaCode repairs its own chat database when the disk returns read errors: it re-reads the damaged files onto fresh disk blocks, keeps the originals in a "host.damaged-…" folder, and says what happened and what (if anything) was lost. Before, the local service kept restarting and the app looked signed out. "oona db repair" runs the same repair by hand.`],fixed:[]},{version:`0.3.334`,date:`2026-11-15`,platforms:[`linux`],added:[`Auto-suggest: after each answer the message box shows a greyed guess at what you might say next; press Tab to take it, then edit or send it. Nothing is sent by itself. In OonaCode pool chats the guess comes from OonaCode’s small fast models and costs a few credits; on your own Claude-protocol key or plan the engine makes it on that plan. Turn it off in Settings → This PC → "Auto-suggest my next message".`,`The usage card of a linked provider names the account its figures belong to — "Account: you@example.com", the whole account on hover — even when only one is linked.`,`OonaCode repairs its own chat database when the disk returns read errors: it re-reads the damaged files onto fresh disk blocks, keeps the originals in a "host.damaged-…" folder, and says what happened and what (if anything) was lost. Before, the local service kept restarting and the app looked signed out. "oona db repair" runs the same repair by hand.`],fixed:[`"OonaCode Terminal" in the applications menu no longer opens a window that closes at once when the terminal app stops on an error — the error stays on screen until you press Enter.`]},{version:`0.3.333`,date:`2026-11-15`,platforms:[`win32`],added:[`Auto-suggest: after each answer the message box shows a greyed guess at what you might say next; press Tab to take it, then edit or send it. Nothing is sent by itself. In OonaCode pool chats the guess comes from OonaCode’s small fast models and costs a few credits; on your own Claude-protocol key or plan the engine makes it on that plan. Turn it off in Settings → This PC → "Auto-suggest my next message".`,`The usage card of a linked provider names the account its figures belong to — "Account: you@example.com", the whole account on hover — even when only one is linked.`,`OonaCode repairs its own chat database when the disk returns read errors: it re-reads the damaged files onto fresh disk blocks, keeps the originals in a "host.damaged-…" folder, and says what happened and what (if anything) was lost. Before, the local service kept restarting and the app looked signed out. "oona db repair" runs the same repair by hand.`],fixed:[`A command a Google (agy) chat runs over ssh is no longer ended in the middle of a long, quiet remote job (a big download, a build) once it has printed output; one whose ssh has printed nothing at all is now ended after 10 minutes with a note, instead of the chat waiting half an hour.`,`Linux: "OonaCode Terminal" in the applications menu no longer opens a window that closes at once when the terminal app stops on an error — the error stays on screen until you press Enter.`]},{version:`0.3.332`,date:`2026-11-15`,added:[`The OonaCode pool’s Google models are back — Gemini 3.8 Flash, Gemini 4 Argon and Gemini 4 Hydrogen — running on Google’s own agy on OonaCode’s server: your message goes to agy, and every file, command and Oonak Browser step it takes runs on your PC, under the chat’s Build, Ask first or Autonomous setting. A command that runs for minutes keeps going, and the chat says when it is done.`],fixed:[]},{version:`0.3.331`,date:`2026-11-14`,added:[`The message box shows math as math: LaTeX you type between \\( \\), \\[ \\], $ … $ or $$ … $$, and formulas you paste from a web page or another chat, turn into rendered formulas — the message still goes out as plain Markdown with LaTeX. Copying part of a chat that holds formulas copies them as LaTeX.`],fixed:[`Google Gemini now runs only through Google’s own agy on your PC, signed in to your own Google account (Settings → Providers → Google): the OonaCode pool no longer lists Gemini models, and background tasks no longer fall back to one.`]},{version:`0.3.330`,date:`2026-11-14`,added:[`Several accounts of one subscription: link a second SuperGrok, ChatGPT (Codex), GitHub Copilot, Meta or Google account beside the first with "Add another account" (Google: "Add another Google account" on its card). The model picker then lists the provider once per account, named with the account’s email — hover it for the whole account — and a chat stays on the account it started on. New chats use the account you linked last.`,`Each linked account has "Sign in again", which renews only that account, and Remove.`],fixed:[`A new sign-in no longer replaces a different account you had linked: only a sign-in of the same account replaces it.`,`A chat moved to another account of Google Gemini (your plan) starts a fresh conversation on that account, handed the chat so far — each Google account keeps its own sign-in and its own conversations on this PC.`,`Your own SuperGrok, ChatGPT, GitHub Copilot and Meta sign-ins present the current versions of their own apps (Grok CLI 1.0.77, Codex 0.169.0, Copilot CLI 1.0.109, Muse Code 1.4.20), and "Sign in with Meta" installs Muse Code 1.4.20 (about 505 MB).`,`o4-mini is no longer offered for an OpenAI key: OpenAI shut it down on 2026-10-23, so every message to it failed.`]},{version:`0.3.329`,date:`2026-11-14`,added:[`A chat on Google Gemini (your plan) now has every OonaCode tool the other models have, each while its switch in the Tools menu is on: Oonak Browser and the other tool packs, chats talking to each other, scheduling, "move this task to a new chat", chats on your other PCs, action buttons — beside the pictures, video, speech and folder tools it already had. Before, the Tools menu showed switches for these in a Gemini chat that did nothing.`],fixed:[`A project that switched scheduling off now also keeps its Gemini chats from scheduling.`,`OonaCode now keeps Google’s agy up to date as far as 1.5.8, which it has been checked against: the usage numbers, the model list, the chat protocol and OonaCode’s own tools.`]},{version:`0.3.328`,date:`2026-11-14`,platforms:[`darwin`],added:[],fixed:[`This macOS release brings everything in 0.3.326 and 0.3.327, listed below: Google Gemini (your plan) on Google’s own agy again, long chats with many pictures no longer stuck on "Request body is too large", and no Test button in the connect dialog.`]},{version:`0.3.327`,date:`2026-11-14`,added:[],fixed:[`Google Gemini (your plan) runs on Google’s own agy again, as it did before 0.3.324: OonaCode installs agy for you and every Google chat goes through it — OonaCode no longer sends Google requests of its own. If you signed in with Google on 0.3.324–0.3.326, sign in once more in agy (OonaCode shows you how) on each PC.`,`The connect dialog no longer has a Test button: it sent some subscriptions a request their own app never sends.`,`When a key you paste is refused, the message names the provider that refused it instead of always saying "Anthropic", and never shows a web page’s code.`]},{version:`0.3.326`,date:`2026-11-14`,added:[],fixed:[`A long chat with many pictures — screenshots, images a tool brought back — no longer stops for good with "Request body is too large". When a request grows past what the provider accepts, OonaCode now replaces the oldest pictures with a short note and keeps the newest, so the chat and /compact go on. A chat that is already stuck continues after the update.`]},{version:`0.3.325`,date:`2026-11-13`,added:[],fixed:[`A Google chat now names its model plainly (Gemini 3.8 Flash) instead of Google’s internal template (gemini-3.8-flash-{effort:high}); chats started on 0.3.324 put themselves right on their next message.`,`A Google chat in Plan mode now shows Plan in its picker, like every other chat, instead of reading Build while it plans.`,`Right after an update, Google chats use the new Google sign-in at once — no waiting for OonaCode to refresh its provider list first.`,`The app no longer carries the old agy engine at all (about 20,000 lines lighter).`]},{version:`0.3.324`,date:`2026-11-13`,added:[`Your own Google Antigravity plan now runs on OonaCode itself — no agy to install or update. Sign in once with your Google account (open the link, paste the code Google shows) and Gemini 3.8 Flash, Gemini 4 Argon, Carbon and Hydrogen and Claude Opus and Sonnet 5.5 via Google work like every other model: every tool and skill, Plan and Ask first, pictures, and your plan’s usage in the model picker.`],fixed:[`Google chats are no longer limited to Build and Autonomous and no longer lose the chat tools: they run on the same agent as every other chat. Your earlier Google chats keep their history and continue after the new sign-in.`]},{version:`0.3.323`,date:`2026-11-13`,added:[],fixed:[`On your own Google Gemini (agy) plan, a recovered safety-filter or malformed-tool-call retry (“Retries remaining: 3”) no longer fails a turn that already answered cleanly, and no longer repeats on every later message in that chat (even after switching models).`,`The Images (generate_image) tool, image model selector, and Ask-first toggle are now offered in local Google Gemini (agy) chats too, instead of disappearing from the chat Tools list when a Google model is selected.`]},{version:`0.3.322`,date:`2026-11-13`,added:[`Scheduled recurring tasks can now repeat as often as every minute: the default interval floor for unassigned chats is lowered from 15 minutes down to 1 minute, allowing fast periodic automations without requiring a custom project setting.`],fixed:[]},{version:`0.3.321`,date:`2026-11-13`,added:[`Claude Fable 5.2 (claude-fable-5-2) is here, in the OonaCode pool and on your linked Claude subscription: Anthropic’s newest frontier technical reasoning and coding model, with a 1M-token context window and up to 128K output tokens, priced 20% lower than Fable 5.1.`],fixed:[]},{version:`0.3.320`,date:`2026-11-13`,added:[`Gemini 4 Hydrogen is here, on your own Google Gemini (agy) plan and in the OonaCode pool: a 1M-token context window, up to 262K output tokens and four reasoning levels — Low, Medium, High and the new XHigh — chosen with the effort picker.`],fixed:[`Gemini 4 Carbon is no longer offered in the model list of a Google account that cannot use it.`]},{version:`0.3.319`,date:`2026-11-12`,platforms:[`linux`],added:[`Math in a chat now looks like math. When a model writes a formula with dollar signs or \\( … \\) — Euler’s identity, an integral, a fraction — it is drawn as a proper equation, in its own block when it stands alone and inline inside a sentence. Prices (“$5 and $10”), shell variables and code are never read as formulas.`,`Superscripts and subscripts that models write as <sup> and <sub> (x², H₂O) are drawn as such, and <br> is a line break. No other HTML is drawn.`],fixed:[`Answers from Muse, Gemini and other models no longer show raw “$$ … $$”, “$e$” or “<sup>” text in the chat.`]},{version:`0.3.318`,date:`2026-11-12`,platforms:[`darwin`],added:[`Math in a chat now looks like math. When a model writes a formula with dollar signs or \\( … \\) — Euler’s identity, an integral, a fraction — it is drawn as a proper equation, in its own block when it stands alone and inline inside a sentence. Prices (“$5 and $10”), shell variables and code are never read as formulas.`,`Superscripts and subscripts that models write as <sup> and <sub> (x², H₂O) are drawn as such, and <br> is a line break. No other HTML is drawn.`],fixed:[`Answers from Muse, Gemini and other models no longer show raw “$$ … $$”, “$e$” or “<sup>” text in the chat.`]},{version:`0.3.317`,date:`2026-11-12`,platforms:[`win32`],added:[`Math in a chat now looks like math. When a model writes a formula with dollar signs or \\( … \\) — Euler’s identity, an integral, a fraction — it is drawn as a proper equation, in its own block when it stands alone and inline inside a sentence. On the Android app it shows as readable text, such as “e^(iπ) + 1 = 0”. Prices (“$5 and $10”), shell variables and code are never read as formulas.`,`Superscripts and subscripts that models write as <sup> and <sub> (x², H₂O) are drawn as such, and <br> is a line break. No other HTML is drawn.`],fixed:[`Answers from Muse, Gemini and other models no longer show raw “$$ … $$”, “$e$” or “<sup>” text in the chat.`]},{version:`0.3.316`,date:`2026-11-11`,platforms:[`win32`],added:[`“Clean up chat folders” now says what each folder is. A folder with no chat in OonaCode’s database is marked as left over and safe to delete, with its dates, size, files and full path. Chats you still have that moved to another folder are listed by name with the folder they work in now and the old one they left behind; you can delete those too, after a clear warning (they are never ticked for you).`],fixed:[`Updating from the app runs one update at a time, however often “Update now” is pressed and in however many windows: a second press waits for the update that is already running instead of starting another. Every window shows the same running update, and none offers an Update button until it ends.`]},{version:`0.3.316`,date:`2026-11-11`,platforms:[`linux`],added:[`In a chat on Google Gemini (agy), the assistant can now move the chat to a folder you name: it asks you to confirm, and the move happens when its turn ends. Before, it had no way to do this and tried shell commands that changed nothing, then said the workspace was set.`,`“Clean up chat folders” now says what each folder is. A folder with no chat in OonaCode’s database is marked as left over and safe to delete, with its dates, size, files and full path. Chats you still have that moved to another folder are listed by name with the folder they work in now and the old one they left behind; you can delete those too, after a clear warning (they are never ticked for you).`],fixed:[`Updating from the app runs one update at a time, however often “Update now” is pressed and in however many windows: a second press waits for the update that is already running instead of starting another. Every window shows the same running update, and none offers an Update button until it ends.`,`Only one OonaCode update installer runs at a time, also when you run oona update in Terminal while the app is updating: the second one says an update is already running and changes nothing.`]},{version:`0.3.315`,date:`2026-11-11`,platforms:[`darwin`],added:[`In a chat on Google Gemini (agy), the assistant can now move the chat to a folder you name: it asks you to confirm, and the move happens when its turn ends. Before, it had no way to do this and tried shell commands that changed nothing, then said the workspace was set.`,`“Clean up chat folders” now says what each folder is. A folder with no chat in OonaCode’s database is marked as left over and safe to delete, with its dates, size, files and full path. Chats you still have that moved to another folder are listed by name with the folder they work in now and the old one they left behind; you can delete those too, after a clear warning (they are never ticked for you).`],fixed:[`Pressing “Update now” again no longer starts a second update. The window keeps saying that OonaCode is updating, with no Update button, until the app closes and reopens by itself on the new version; if the update fails, it says why and the button comes back. Before, every press started another installer and another dialog (five at once on one Mac) while the first was still downloading.`,`Only one OonaCode update runs at a time, also when you run oona update in Terminal while the app is updating: the second one says an update is already running and changes nothing.`]},{version:`0.3.314`,date:`2026-11-11`,platforms:[`win32`],added:[`In a chat on Google Gemini (agy), the assistant can now move the chat to a folder you name: it asks you to confirm, and the move happens when its turn ends. Before, it had no way to do this and tried shell commands that changed nothing, then said the workspace was set.`],fixed:[]},{version:`0.3.313`,date:`2026-11-11`,platforms:[`linux`],added:[],fixed:[`On your own Meta Muse key or sign-in, every request now carries Muse Code’s contributor-mode marker on every model, the way Muse Code itself sends it: “on” for a -contributor model and “off” for any other, Ember included. Before, a standard model went out without it.`]},{version:`0.3.312`,date:`2026-11-11`,platforms:[`darwin`],added:[],fixed:[`On your own Meta Muse key or sign-in, every request now carries Muse Code’s contributor-mode marker on every model, the way Muse Code itself sends it: “on” for a -contributor model and “off” for any other, Ember included. Before, a standard model went out without it.`]},{version:`0.3.311`,date:`2026-11-11`,platforms:[`win32`],added:[],fixed:[`On your own Meta Muse key or sign-in, every request now carries Muse Code’s contributor-mode marker on every model, the way Muse Code itself sends it: “on” for a -contributor model and “off” for any other, Ember included. Before, a standard model went out without it.`]},{version:`0.3.310`,date:`2026-11-11`,platforms:[`linux`],added:[`Gemini 4 Carbon is available in the OonaCode pool and on your own Google Gemini (agy) plan, with Low, Medium and High effort and a 1M-token context window.`,`Muse Ember 1.0 is available on your own Meta Muse plan, with a 1M-token context window, up to 512K output tokens and reasoning-effort controls. Ember has no Contributor variant and is not part of the OonaCode pool.`],fixed:[`Messages you send while the assistant is working now clear from the Queued strip one by one as the assistant reads them, also when it reads several together. Two identical messages no longer clear as one, and a message no longer clears because a longer text happens to contain its words.`,`A very long chat that no longer fits the model does not write “earlier messages left out” every time it wakes up, and its assistant now stays ready for about an hour instead of ten minutes, so your next message starts faster.`,`On your own Google Gemini (agy) plan, a real “stream idle timeout” is shown at once instead of being retried for many minutes; the stale copy of that error after a clean answer stays hidden, and agy is updated to 1.5.5.`,`The effort picker shows the default effort the assistant really starts with, on every provider.`]},{version:`0.3.309`,date:`2026-11-11`,platforms:[`darwin`],added:[`OonaCode for Mac lists what 0.3.305 and 0.3.306 brought without notes: Gemini 4 Carbon in the OonaCode pool and on your own Google Gemini (agy) plan, with Low, Medium and High effort and a 1M-token context window, and agy 1.5.5.`],fixed:[`Messages you send while the assistant is working now clear from the Queued strip one by one as the assistant reads them, also when it reads several together. Two identical messages no longer clear as one, and a message no longer clears because a longer text happens to contain its words.`,`A very long chat that no longer fits the model does not write “earlier messages left out” every time it wakes up, and its assistant now stays ready for about an hour instead of ten minutes, so your next message starts faster.`,`On your own Google Gemini (agy) plan, a real “stream idle timeout” is shown at once instead of being retried for many minutes; the stale copy of that error after a clean answer stays hidden.`,`The effort picker shows the default effort the assistant really starts with, on every provider.`,`OonaCode starts normally on a Mac whose keychain list another tool has damaged: it now looks for your keys in your login keychain directly, and if it ever cannot open your chats because of that list, the message says how to repair it.`]},{version:`0.3.308`,date:`2026-11-11`,platforms:[`win32`],added:[],fixed:[`Messages you send while the assistant is working now clear from the Queued strip one by one as the assistant reads them, also when it reads several together. Two identical messages no longer clear as one, and a message no longer clears because a longer text happens to contain its words.`,`A very long chat that no longer fits the model does not write “earlier messages left out” every time it wakes up, and its assistant now stays ready for about an hour instead of ten minutes, so your next message starts faster.`,`On your own Google Gemini (agy) plan, a real “stream idle timeout” is shown at once instead of being retried for many minutes; the stale copy of that error after a clean answer stays hidden.`,`The effort picker shows the default effort the assistant really starts with, on every provider.`]},{version:`0.3.307`,date:`2026-11-11`,platforms:[`win32`,`darwin`],added:[`Muse Ember 1.0 is available on your own Meta Muse plan, with a 1M-token context window, up to 512K output tokens and reasoning-effort controls. Ember has no Contributor variant and is not part of the OonaCode pool.`],fixed:[]},{version:`0.3.306`,date:`2026-11-11`,platforms:[`win32`],added:[],fixed:[`Messages sent while the assistant is working now clear from the Queued strip as soon as the assistant reads them (including when multiple queued messages are absorbed together in one step or after a reconnect), and reopening a chat keeps every mid-turn message in place.`,`Chats on your own Google Gemini (agy) plan no longer show a stale “stream idle timeout: context deadline exceeded” error at the end of clean turns, and agy is updated to 1.5.5.`,`Long reasoning turns on slow models (Gemini 4 Carbon above all) keep their connection alive with periodic stream heartbeats so reverse proxies do not drop the stream while the model thinks.`]},{version:`0.3.305`,date:`2026-11-10`,platforms:[`win32`],added:[`Gemini 4 Carbon is now available in the OonaCode pool and on your own Google Gemini (agy) plan, with Low, Medium, and High reasoning-effort options (1M context window, 256K output tokens).`],fixed:[`The reasoning-effort picker now shows the exact supported effort levels and default effort for every model across pool and direct providers.`]},{version:`0.3.304`,date:`2026-11-09`,platforms:[`win32`],added:[`Clean up chat folders (File menu, and a button in the sidebar): lists the folders left behind by chats you deleted, shows how much space they take and removes the ones you tick. Folders with nothing of yours in them are ticked for you; a folder that holds files is left for you to choose. Folders of chats you still have, and folders changed in the last day, are never offered.`],fixed:[`A chat that started in its own folder and was then moved to another one no longer loses track of its first files: a file the assistant names without a path is also looked for in the chat’s first folder, so it stops reading “moved or deleted”.`,`Deleting a chat now removes its folder even when the only thing in it was the assistant’s “always allow” memory; those folders used to pile up for ever.`]},{version:`0.3.304`,date:`2026-11-09`,platforms:[`linux`,`darwin`],added:[`GitHub Copilot: link your own Copilot plan (Free, Pro and above) under Providers → GitHub Copilot Subscription with Sign in with GitHub. Pick Copilot Auto in the model picker and GitHub chooses the model your plan allows. Point at the provider to see your AI credits and when they reset. The sign-in lets OonaCode read only your GitHub profile, nothing about your repositories, and your sign-in stays on your PC.`,`Clean up chat folders (File menu, and a button in the sidebar): lists the folders left behind by chats you deleted, shows how much space they take and removes the ones you tick. Folders with nothing of yours in them are ticked for you; a folder that holds files is left for you to choose. Folders of chats you still have, and folders changed in the last day, are never offered.`],fixed:[`A chat that started in its own folder and was then moved to another one no longer loses track of its first files: a file the assistant names without a path is also looked for in the chat’s first folder, so it stops reading “moved or deleted”.`,`Deleting a chat now removes its folder even when the only thing in it was the assistant’s “always allow” memory; those folders used to pile up for ever.`]},{version:`0.3.303`,date:`2026-11-07`,platforms:[`win32`],added:[`GitHub Copilot: link your own Copilot plan (Free, Pro and above) under Providers → GitHub Copilot Subscription with Sign in with GitHub. Pick Copilot Auto in the model picker and GitHub chooses the model your plan allows. Point at the provider to see your AI credits and when they reset. The sign-in lets OonaCode read only your GitHub profile, nothing about your repositories, and your sign-in stays on your PC.`],fixed:[]},{version:`0.3.302`,date:`2026-11-06`,added:[`Action buttons have their own switch in the chat’s Tools menu. Turn it off and the assistant stops offering buttons; the buttons a chat already has stay and still run.`,`Connect an AI tool: every connected tool has a Details button (instead of a card that opened when you pointed at it), Reveal key shows a connection’s key again after your password so you can share it without making a new one, and connections that have ended can be deleted, one by one or all at once.`],fixed:[`The assistant can no longer start Oonak Browser by hand even in Bypass permissions mode; it uses the chat’s one browser.`,`Signing in to a connector could fail on some PCs because the browser refused the local address the sign-in came back to; OonaCode now always picks one the browser accepts.`]},{version:`0.3.301`,date:`2026-11-05`,platforms:[`darwin`],added:[`OonaCode for Mac is up to date again: this build carries everything the Windows and Linux versions have had since 0.3.294 — action buttons at the top right of a chat, Ctrl + scroll (or Command + scroll) to change the text size of the chat or the sidebar, the Connect an AI tool activity list, and the changes listed under the versions above.`],fixed:[]},{version:`0.3.300`,date:`2026-11-05`,added:[`Action buttons: when you ask for the same job twice, the assistant offers to turn it into a button at the top right of the chat. A button can run a ready command on your PC at once, or send a job to the assistant, which does it in a subagent and prints the report in the chat. Point at a button to read what it does, right-click it to Run or Delete it, and ask the assistant to change it.`,`Ctrl + scroll over the chat or over the sidebar makes that text bigger or smaller (Command + scroll on a Mac) — the same size you set in Settings → Theme → Fonts.`,`Connect an AI tool: every connected tool now shows the chats it can read, its own key, and an Activity list of who used it and when. The list updates while the window is open, and Share shows how to connect the tool and makes a new key for it when you need the command again.`,`Deleting or forking a chat now shows a message window until it has finished.`],fixed:[`Session Info no longer lists made-up “browser sessions” picked up from text in the chat, and the assistant no longer starts Oonak Browser by hand and piles up windows — it uses the chat’s one browser.`]},{version:`0.3.299`,date:`2026-11-04`,added:[`Gemini (agy) chats can now make video and speak: OonaCode’s video and text-to-speech tools reach Google’s agy as a built-in tool server, and the chat’s Tools menu lists Video and Speech like any other chat. (Pictures there still use agy’s own picture tool.)`],fixed:[`Meta Muse in the OonaCode pool now sends exactly the headers and request fields the real Muse program sends, so Meta sees the same client your own Muse would be.`]},{version:`0.3.298`,date:`2026-11-04`,added:[`Pictures from the plan you already pay for: GPT Image 2, 2.5 Flare and 2.5 Sunburst now draw from a ChatGPT plan, and Muse Image 1.0 from a Muse plan. Picking GPT Image on a ChatGPT plan used to end in an error, because only an OpenAI API key could make it.`,`Tools → speech models: every speech model your chat can reach is on the list, not only the one set for the chat’s model.`,`GPT-6.1 Terra is in the ChatGPT plan’s models, and Muse Spark 1.3 contributor can think at Max.`,`Google’s agy is updated to 1.5.0 and Muse to 1.4.14.`],fixed:[`A Gemini (agy) chat that makes a picture with agy’s own tool no longer shows that step as an error (“The turn ended before this finished”).`,`Gemini 3.8 Flash in a pooled chat thinks at the level you pick, the same way Google’s agy asks for it.`]},{version:`0.3.297`,date:`2026-11-02`,added:[`Fork asks for the copy’s name first, filled in with “<chat name> fork”.`],fixed:[`Deleting or forking a long chat: the chat shows “Deleting…” or “Forking…” and takes no other click until it is done — no more second delete because the first was still working. The open chat is covered while it happens.`,`A long wait in a Gemini (agy) chat — an ssh waiting for a render on your server — is no longer ended after 15 minutes. OonaCode now ends only a command that has neither worked nor sent or received anything for 30 minutes, and the agent keeps remote connections alive.`,`While a command or tool runs, the line under the chat says what is running and for how long, instead of “nothing from the agent — it may be stuck”.`,`A large video downloads however long it takes, as long as data keeps coming; it used to be cut off after 10 minutes and thrown away.`,`Slow pictures (high quality, sets of 12) get almost 5 minutes instead of 2.`]},{version:`0.3.296`,date:`2026-11-02`,added:[`Tools → picture, video and speech models: point at a model in the list (or walk the list with the arrow keys) and a card beside it says everything it can do — what it makes and from what (a first or last frame, reference pictures, editing or extending a clip, a song to follow), how long and how big, sound, prompt options, the rules for combining inputs, and the price. Speech models show their voices, speed, languages and how-to-speak instructions.`],fixed:[]},{version:`0.3.295`,date:`2026-11-02`,added:[`VS Code: the OonaCode panel is now the whole app — the session list, search and files on the left, the same title bar — so you can see and switch your chats without leaving the editor.`,`VS Code: the extension keeps itself up to date. It checks for a new version at start and every few hours, verifies the download, and installs it; “OonaCode: Check for Updates” asks right away.`],fixed:[`VS Code: the panel no longer drops to “Health probe timed out” and reloads while OonaCode is busy opening a long chat — the reload loop that ended in a crash.`,`“Send now” on a step that was taking long no longer marks the turn as “error during execution”; it ends as stopped, as Stop does.`,`A turn that failed before the model said anything no longer shows millions of tokens in its footer.`,`A video the provider refused part-way (moderated) is now closed at once, instead of holding one of your two video slots and its credits for a day — which made other chats wait out a “rate limit”. When the slots are full, the chat now says so instead of blaming the provider.`,`A model OonaCode cannot serve right now reads “model unavailable”, not “sign-in needed” — your sign-in was fine.`,`Ordinary commands such as echo or curl are no longer refused as “tool misuse”, and their turns are no longer removed from the chat.`,`A browser you restore from Session info stays open while you use it, and only this chat’s own profiles can be restored.`,`Tool cards no longer open by themselves for every file name in their output, and a generated picture is not shown three times.`,`Deleting saved prompts quickly no longer brings one back; Enter on a row’s Send or X button does that button.`,`Doctor’s database check no longer freezes OonaCode for a minute on a large chat history.`]},{version:`0.3.294`,date:`2026-11-02`,platforms:[`darwin`],added:[`Save to send later is now a compact table: every prompt fits on one line with a short preview, Send puts it in the message box, and double-click opens the full prompt in a separate editor. Sending a picked prompt removes it even after editing; clearing the message box keeps it saved.`],fixed:[`Tool results that name a local picture, video or sound now show the same preview and Play controls as ordinary chat text, and the result card opens automatically. This includes Generate image results that only name the saved file.`]},{version:`0.3.293`,date:`2026-11-02`,platforms:[`win32`],added:[`Save to send later is now a compact table: every prompt fits on one line with a short preview, Send puts it in the message box, and double-click opens the full prompt in a separate editor. Sending a picked prompt removes it even after editing; clearing the message box keeps it saved.`],fixed:[`Tool results that name a local picture, video or sound now show the same preview and Play controls as ordinary chat text, and the result card opens automatically. This includes Generate image results that only name the saved file.`]},{version:`0.3.292`,date:`2026-11-01`,platforms:[`darwin`],added:[],fixed:[`Save to send later: deleting a saved prompt with ✕ (or when sending a picked saved prompt) no longer fails with "The saved prompt could not be deleted."`,`When a model tries to run an MCP tool or dummy echo command inside Bash instead of calling the tool itself (such as Oonak Browser or web search after a long run of shell commands), OonaCode now stops the call at once, returns a short hint with the active tools and their input format, cleans earlier no-op echo loops from the request, and switches the retry onto the right tool.`]},{version:`0.3.291`,date:`2026-11-01`,platforms:[`win32`],added:[],fixed:[`Save to send later: deleting a saved prompt with ✕ (or when sending a picked saved prompt) no longer fails with "The saved prompt could not be deleted."`]},{version:`0.3.290`,date:`2026-11-01`,platforms:[`win32`],added:[],fixed:[`When a model tries to run an MCP tool or dummy echo command inside Bash instead of calling the tool itself (such as Oonak Browser or web search after a long run of shell commands), OonaCode now stops the call at once, returns a short hint with the active tools and their input format, cleans earlier no-op echo loops from the request, and switches the retry onto the right tool.`]},{version:`0.3.289`,date:`2026-11-01`,platforms:[`darwin`],added:[`Session Info lists every Oonak Browser profile (user-data-dir) the model used in that chat, with a Restore browser button that opens Oonak Browser on that profile and reopens its saved tabs.`],fixed:[]},{version:`0.3.288`,date:`2026-11-01`,platforms:[`win32`],added:[`Session Info lists every Oonak Browser profile (user-data-dir) the model used in that chat, with a Restore browser button that opens Oonak Browser on that profile and reopens its saved tabs.`],fixed:[]},{version:`0.3.287`,date:`2026-10-31`,platforms:[`darwin`],added:[`On a Mac, the terminal can choose the picture, video and speech model for a chat: oona --image-model, --video-model and --audio-model, also when you continue a chat with -c or -r. Leave a flag out and that kind stays on the default.`,`Save to send later: each saved message has an ✕, so you can delete it from the list without sending it.`],fixed:[]},{version:`0.3.286`,date:`2026-10-31`,platforms:[`win32`],added:[`The terminal can choose the picture, video and speech model for a chat: oona --image-model, --video-model and --audio-model, also when you continue a chat with -c or -r. Leave a flag out and that kind stays on the default.`],fixed:[]},{version:`0.3.285`,date:`2026-10-31`,platforms:[`win32`],added:[`Save to send later: each saved message has an ✕, so you can delete it from the list without sending it.`],fixed:[]},{version:`0.3.284`,date:`2026-10-30`,added:[`Your chats on this PC are now encrypted, so no other program and no copy of the file can read them. It happens by itself, once, on the first start of this version — about a minute for every 3 GB of history, with the progress on the start screen. If the app closes meanwhile, nothing is lost: it starts over next time.`,`The key is held by Windows (or your Mac’s keychain or Linux keyring) for your user account, with a copy in your vault. If your PC ever loses it, oona db recover-key brings it back.`,`Once your chats are encrypted, the old history files in Documents\\OonaCode-backups are moved into the encrypted database and the plain files are deleted.`,`Encryption protects the file at rest. Programs running as you while OonaCode is open can still reach what you can, as with any app.`],fixed:[]},{version:`0.3.283`,date:`2026-10-30`,added:[`File → Connect an AI tool…: let Claude Code or another AI tool read your chats on this PC — all of them, chosen ones or one project, for an hour, a day or until you revoke it. Read-only, and the tool never gets your password or vault key. Every read is listed, and one click ends it.`,`Videos: Wan 3.0 animates a photo to a song (a reference picture plus reference audio), takes a document or a web page as a brief, reference clips with pictures, and prompts up to 20,000 characters. Wan 2.7, Wan 2.6, HappyHorse and Grok Imagine gained the options their makers offer that were missing here.`,`Pictures: each model now offers everything its maker does — for example a transparent background, JPEG or WebP and masked edits on GPT Image, image sets on Wan 2.7, and a thinking mode on Qwen-Image 3.0. One call can make several pictures, and chats can use every picture and video model the service runs.`,`This version can open an encrypted chat database. The next update encrypts the chats on this PC by itself, once, with the progress on the start screen.`,`oona db recover-key brings this PC’s chat-database key back from your vault, if Windows or your keyring ever loses it.`],fixed:[`A negative prompt on Wan video models is now actually applied (it was sent where the provider never reads it).`,`Pictures from Qwen, Wan and Grok Imagine models are saved in the chat again; they used to fail to save.`,`A sound clip longer than 15 seconds for Wan 3.0 now says how long it is, instead of a wrong “goes without a picture” error.`,`Very long chats keep their older history inside OonaCode’s database, not as plain text files in Documents\\OonaCode-backups. The files earlier versions wrote there are moved back in once the database is encrypted.`]},{version:`0.3.282`,date:`2026-10-30`,added:[`Allow Telegram to reach this PC (Settings → This PC): the OonaCode bot can list, open and answer this PC’s chats only while it is on. It starts off — turn it on for each PC you want to use from Telegram.`,`The desktop app, the VS Code panel and a browser window each remember their own open chats, saved the moment they change. One of them can no longer close the chats another had open.`,`The groundwork for encrypting the chats stored on your PC: OonaCode now uses a database engine that can encrypt them. Nothing is encrypted yet — that comes in a later update, by itself.`],fixed:[`Chats an earlier update closed come back on the first start of this one, wherever the window still had its own copy of them (the desktop app usually does).`,`The Windows install command no longer waits for ever on a download that has stopped moving; it tries again.`]},{version:`0.3.281`,date:`2026-10-30`,added:[],fixed:[`Stop now really stops the answer: the model’s provider is told to stop too, so nobody pays for output that is no longer read — on your own key and on the OonaCode pool.`,`The message box no longer loses the keyboard to a video or sound player in the chat while you type.`,`A firewall, proxy or Cloudflare page answering in place of OonaCode no longer signs your PC out.`,`Two open tabs of the website no longer sign each other out.`,`Deleting a chat that still had messages waiting to send no longer brings the chat back.`,`Credits are no longer kept on hold when a request fails on our side before it reaches the model.`,`A long chat on a model whose context size is unknown now says when its oldest part was left out on resume, instead of dropping it silently.`,`A crafted link can no longer point your local OonaCode window at another server.`,`Opening a file from a chat refuses more kinds of programs (help files, add-ins and others).`]},{version:`0.3.280`,date:`2026-10-29`,added:[],fixed:[`Google agy chats now retry temporary INVALID_ARGUMENT failures and no longer report an old failure again after a later reply succeeds.`,`Hosted agents keep the model explicitly requested instead of silently substituting the pool default when that model is absent from the public list.`]},{version:`0.3.279`,date:`2026-10-29`,platforms:[`darwin`],added:[`HappyHorse 1.1 is in the video model list: text-to-video, image-to-video and reference-to-video (up to 9 pictures), 3–15 seconds at up to 1080P. Pick it for a chat under Tools → Video model.`,`Asking the video tool what it accepts now lists every video model the chat can use — each with its own inputs (Grok Imagine 1.5’s preset voices included) — and marks the one this chat uses, so you can see what switching models would give you.`,`Save to send later: the clock button to the right of Send keeps the message you typed in this chat instead of sending it. The badge on the button counts what is saved; with an empty message box, the button opens the list (oldest first) — pick one to put it back in the box, edit it if you like, and sending it takes it off the list.`,`The video tool now offers everything the video model you picked actually takes — not just a description and a first picture. Wan 3.0 can be handed a clip to edit and reference clips and sounds, Grok Imagine 1.5 takes preset voices for the speakers and pictures pinned inside the clip, and models that accept a last frame, a “what must not appear” note, a seed or a watermark offer those too.`],fixed:[`Files a reply names — a plan, a report, any plain file, not just pictures, clips and sounds — now appear in the chat’s Media panel under Files.`,`Ctrl+F opens the chat’s find bar on Armenian, Farsi and other non-Latin keyboard layouts too.`,`A clip or a sound in the chat no longer starts playing by itself when you send a new message.`]},{version:`0.3.278`,date:`2026-10-29`,added:[`HappyHorse 1.1 is in the video model list: text-to-video, image-to-video and reference-to-video (up to 9 pictures), 3–15 seconds at up to 1080P. Pick it for a chat under Tools → Video model.`,`Asking the video tool what it accepts now lists every video model the chat can use — each with its own inputs (Grok Imagine 1.5’s preset voices included) — and marks the one this chat uses, so you can see what switching models would give you.`],fixed:[`The “save to send later” clock now sits to the right of the Send/Queue button.`]},{version:`0.3.277`,date:`2026-10-29`,added:[`Save to send later: the clock button beside Send keeps the message you typed in this chat instead of sending it. The badge on the button counts what is saved; with an empty message box, the button opens the list (oldest first) — pick one to put it back in the box, edit it if you like, and sending it takes it off the list.`,`The video tool now offers everything the video model you picked actually takes — not just a description and a first picture. Wan 3.0 can be handed a clip to edit and reference clips and sounds, Grok Imagine 1.5 takes preset voices for the speakers and pictures pinned inside the clip, and models that accept a last frame, a “what must not appear” note, a seed or a watermark offer those too. Ask the chat what its video model accepts, or just describe what you want: it checks against the model and says what does not fit.`],fixed:[`Files a reply names — a plan, a report, any plain file, not just pictures, clips and sounds — now appear in the chat’s Media panel under Files. Before, a file like a Markdown plan printed in the chat was missing there.`,`Ctrl+F opens the chat’s find bar on Armenian, Farsi and other non-Latin keyboard layouts too. Before it only worked when the layout typed a Latin “f”, so on those layouts nothing happened.`,`A clip or a sound in the chat no longer starts playing by itself when you send a new message.`]},{version:`0.3.276`,date:`2026-10-27`,added:[`Kimi now accepts a Kimi Code subscription key (the sk-kimi… key from the Kimi Code console) as well as a Moonshot API key. With a Kimi Code key, resting the pointer on the model box shows how much of your 5-hour and monthly allowance is used and when each resets.`],fixed:[`A chat on Google’s agy can now use the GitHub account you linked: git and gh are signed in there too. Before, agy chats had no GitHub access at all, because agy keeps to its own private home.`,`When GitHub answers “not found” for a repository of an organization that has not approved OonaCode (the organization’s owner approves “OonaCode Git” in its OAuth app settings), the chat now says that instead of concluding the repository does not exist.`]},{version:`0.3.275`,date:`2026-10-27`,added:[`Kimi (Moonshot) is back as a provider you connect with your own Moonshot API key: Kimi K3, K3.1 Pro, K2.7 Code and K2.6. Your PC talks to Moonshot directly — nothing goes through OonaCode’s servers. (The Kimi Code subscription is a different service and is not included.)`],fixed:[`The app keeps up with the provider and model list from OonaCode’s server again. After the server added a provider for Google’s voices, builds before this one could not read the new list and quietly kept the old one, so new models and providers did not appear until the next update.`,`A chat that was set to Gemini is told that the provider was removed and asked to pick another, instead of failing with “unknown provider”. Gemini itself was never available to use.`]},{version:`0.3.274`,date:`2026-10-27`,added:[],fixed:[`A big chat you reopen (Ctrl+R, or after a restart) now ends on its newest messages. Before, the transcripts of old agents were listed after the whole chat, so their cards piled up at the bottom and the last few minutes of the conversation sat above them, out of the window.`,`The note that earlier messages were left out of the request is shown as its folded line after a reload too, not as raw <local-command-stdout> text.`]},{version:`0.3.273`,date:`2026-10-26`,added:[`Rest the pointer on the model box (or focus it with the keyboard) to see how much of that model’s plan or key you have used: the bars and when each limit resets, with the model you are on first. For your own Claude plan it shows what Claude itself reported on its last answer; when that is older than 10 minutes, OonaCode asks again with one tiny message (a few tokens of your own plan or key), or you press “Check now”. Settings → This PC can switch the check off or change the 10 minutes.`],fixed:[`A picture or file sent in a chat on Google’s agy — any of its models, Claude through Google included — is no longer refused with “takes text only”: OonaCode saves it in the chat’s folder and gives the model its path, as it does for every other model.`,`A Google agy chat no longer repeats “Google answered “service unavailable” — continuing in …” (and redoes its last step each time) when Google had in fact answered every request of the turn. A real Google outage is still waited out as before.`]},{version:`0.3.272`,date:`2026-10-26`,added:[`A find-in-page field in the top bar, next to the MCP servers icon: it searches everything visible in OonaCode and highlights the matches (Enter and Shift+Enter step through them). Ctrl+F opens it when no chat find takes the key; Ctrl+Shift+F always does.`,`On the website’s API keys page, a key you create from now on can be shown again with “Reveal key” — it is sealed in your browser with your vault key, so the server still cannot read it. Keys made before this still show only their last four characters.`,`Removing a message now also removes the summary the engine wrote after it, if the chat was summarised later (the summary was made from that message); the confirmation says so. The model then reads the earlier messages themselves again.`],fixed:[`Messages you type while a Google agy turn is running now all go together when the turn ends, instead of one turn per message with “2 queued” left over. The waiting strip says when they will be read, how long they have waited, what the agent is doing and how long earlier turns took.`,`The media panel starts over when OonaCode comes back after an update: it asks for a fresh access grant and reads the list again, and a failed read has a Try again button.`,`The Session info panel shows a chat’s context size as soon as you open it, not only after its next reply.`,`A sub-agent’s “Conversation compacted” line stays inside that agent’s card instead of appearing loose at the end of the chat.`,`When a chat’s own model cannot write its About or the summary of older messages, OonaCode now says so instead of quietly answering with another model.`]},{version:`0.3.271`,date:`2026-10-25`,added:[`Messages can be removed from a chat, and from what the model remembers. Right-click one of your messages, or any reply, tool call or thought of its exchange: “Remove this exchange…” takes out your message and everything the agent did for it; “Remove this and everything after…” also takes out every later message. Open windows update at once, and the chat starts fresh from what is left on its next message. Text already sent to a provider stays in that provider’s own logs.`,`When the provider is throttling OonaCode for a short while, the pool now holds your request and sends it the moment the provider is ready, instead of failing it straight away. It holds up to 90 seconds at a time, and a longer pause is waited out over the engine’s next retry.`,`Your PC’s agy and Muse helper move to the versions tested on the server (agy 1.4.7, Muse 1.4.13).`],fixed:[`Chats on a ChatGPT plan (Codex) no longer fail their About, titles and the summary of older messages with a 400 error.`,`Chats on Claude through Google, and chats on your own NVIDIA key, keep a summary of the messages that no longer fit the model’s window: their background calls now use a model the key can actually reach.`,`A chat on another of your PCs shows “PC linked · N folders” again after a restart, instead of asking you to link the same folders once more.`,`The agy note “still reports Individual quota reached…” is gone from the chat; the turn is still treated as the success it was.`,`The file explorer is back in VS Code, the chat font now also covers the message box, and a tool call at the edge of an older page of a remote chat keeps its name and input.`,`“Not delivered — the chat couldn’t start” now appears only when OonaCode itself could not start the turn, never for an error the model returned, so Send again cannot double a message.`]},{version:`0.3.270`,date:`2026-10-25`,added:[`One left panel: an icon strip on the far left switches between Sessions, Search and Files, and the file explorer now has the sidebar’s width and resize handle. Sessions and Files each have a filter box at the top.`,`Search has its own section with two scopes: Chats (every option the old search had) and Files & contents, which searches the open chat’s folder and shows the matching lines.`,`Settings → Theme → Fonts: choose the typeface and size for the chat and for the sidebar separately. Left alone, everything looks as before.`,`Hover a provider you use with your own key or subscription in the model picker to see its usage: quota bars with the time each resets.`,`On a Mac, updating now shows a window saying what is happening — it closes by itself when the new OonaCode opens, so you know whether to wait. Windows has had one since 0.3.92.`],fixed:[`Dark mode: Settings → Theme now has the Colour scheme switch (Light, Dark, System), and the colour editor opens on the colours you are actually looking at. Its old Light | Dark buttons only chose which colours to edit, so choosing Dark there seemed to do nothing. On System, the file editor also follows Windows’ dark setting now.`,`A chat on another of your PCs opens with its newest 500 messages and loads earlier ones as you scroll up, instead of pulling thousands at once over a slow link.`,`A message sent into a chat that then failed to start is marked “Not delivered — the chat couldn’t start”, with Send again. It used to look sent although the model never received it.`,`Subagents always run on the chat’s own model.`,`On a Mac, an update that could not close OonaCode used to report “done” and leave the old app in place — the terminal half updated and the app did not, sometimes for days. It now closes the app even when its window is frozen, and says plainly if it still could not, instead of claiming success.`,`After an update on a Mac, OonaCode opens again by itself. It used to reopen only if the update had closed it.`,`A browser the agent opened no longer leaves processes behind when it is closed or when OonaCode restarts. Helpers of a browser whose window was already gone could keep running for days — one of them found using most of a processor core — and they also stopped old browser versions from being cleaned up.`]},{version:`0.3.269`,date:`2026-10-25`,added:[],fixed:[`OonaCode can be quit again. Since 0.3.244, Quit (and ⌘Q on a Mac) did nothing at all unless a chat happened to be working: the question that warns about working chats answered itself when nothing was running, forgot it had answered, and asked again for ever — so the app stayed open and kept a processor core busy trying to close. If an app of yours has been sitting at high CPU, this was why.`]},{version:`0.3.268`,date:`2026-10-25`,added:[],fixed:[`Long chats no longer fail to start with “SessionStore.load() timed out after 60000ms”. Since 0.3.264 a chat’s start waited for the summary of its older messages, and the first one of a long chat could take longer than the engine allows; a chat now starts after at most 15 seconds, and the summary finishes in the background for the next start.`,`Stop now always stops a turn, even when the model is stuck retrying.`,`There is one Session info button on a wide window (on the right edge) instead of two.`]},{version:`0.3.267`,date:`2026-10-25`,added:[`Claude through Google now takes chats up to 500,000 tokens (it was 200,000), so a long chat on it keeps far more of its own history before anything is left out.`],fixed:[]},{version:`0.3.266`,date:`2026-10-25`,added:[],fixed:[`A chat’s “about” in Session info is now always written in English, whatever language the chat or its files are in — it used to follow pasted text, so an English chat could get a Persian about. The briefing and Listen still translate it into your language when you ask.`,`An about that ran over its length is now cut at the end of a whole sentence instead of in the middle of a thought, and the model is told to keep it short so the “where it stands now” part is not lost.`]},{version:`0.3.265`,date:`2026-10-25`,added:[],fixed:[`A model’s context limit now comes from the server instead of a copy kept in the app, so changing it in the admin reaches every PC. If a model ever refuses a chat as too long and names its limit, OonaCode remembers that limit and plans the next start by it, instead of hitting the same wall again.`]},{version:`0.3.264`,date:`2026-10-25`,added:[`A long chat keeps its older part in view. When a chat has grown past what the model can read, OonaCode gives the model as much of the recent conversation as fits and, in front of it, a short summary of the older part — what you asked for, what was decided and done, and what is left — instead of simply dropping it. The summary is written once, kept on this PC, and only extended as the chat grows; it appears in Usage as “Long-chat summaries”.`],fixed:[`A chat that was one very long piece of work followed by a short message no longer answers that it cannot see any earlier context: the model now gets the newest steps of that work under your original request.`,`The “invalid request” and “Autocompact is thrashing” errors that long runs of work could end in on models with a smaller window are gone: a chat is no longer handed to the model larger than the model accepts.`,`The note that earlier messages were left out now says when the cut fell inside your latest request, and when a summary was given in their place.`]},{version:`0.3.263`,date:`2026-10-25`,added:[`The right-hand side is now one dock: an icon strip on the edge, and Media and Session info stacked in it as sections. Each icon puts its section in or takes it out, both can be open at once, and a header folds its section to a line without losing what it had loaded.`,`The dock has one width and one drag handle for both sections, and it remembers which sections are in and which are folded.`],fixed:[]},{version:`0.3.262`,date:`2026-10-24`,added:[`xAI text-to-speech can now use a pronunciation map, so you can keep the written words while supplying IPA or a spoken replacement for names and multilingual dubbing.`],fixed:[`Voice and media requests recover onto another eligible operator key when one key reaches its limit, rather than failing the request immediately.`,`Google text-to-speech limits are now tracked per model, so a limit on one voice model does not make another available voice model unavailable.`,`OonaCode now presents the current versions of the Muse and Grok coding clients to their providers.`]},{version:`0.3.261`,date:`2026-10-24`,platforms:[`darwin`],added:[`“Bring this PC into the chat” remembers the folders you picked for that chat. Switching between two remote chats, reopening one, or reloading the window comes back linked to exactly those folders — you choose them once. Unlink still clears them for good.`,`A model change says what it came from: “Set model to X for this session only (previous model was Y)”, with the model you just picked in blue and the one it left in grey.`,`You can set a model typed by id on a chat that runs on another one of your PCs, instead of having to go to that PC to change it.`,`A file named in a chat opens in OonaCode, even when it is outside the chat folder. Text and code can be edited; a sound, picture or video plays as before.`,`An edited file no longer has a Save button. A changed tab shows *, Ctrl+S saves it, and Settings → General → Autosave files saves each change as you type.`,`Right-clicking a file the chat names offers “Copy relative path” and “Copy absolute path”.`,`A change to the model list or to settings now reaches this PC on its next check-in with the server, without restarting.`,`The chat’s browser no longer shows a “Restore pages?” bubble or brings back the tabs it had last time. OonaCode closes it on every exit, which used to look like a crash.`],fixed:[`One “Send now” for the whole queue: it sends every queued message at once and empties the list, instead of one button per message.`,`A message the agent had already read gets its receipt instead of staying pinned in the queue, where pressing Send now answered “The agent has already read that message”.`,`Stopping a reply, or pressing Send now while one is running, no longer shows an error. The chat says “User requested stop”.`,`Closing a file you have changed asks whether to save it, with Save, Don’t save and Cancel.`,`A file you edit keeps the line endings it had on disk when you save it, and a file the model writes while you have it open no longer replaces what you are typing in it.`,`After an admin changes a provider’s offered models, this PC’s list keeps every model’s prices and limits — no stale or emptied list in between.`,`A PC that checks in with the server on a slow schedule no longer reads as offline between check-ins; a change reaches it within a minute.`,`A Google Gemini chat no longer shows an error after a complete answer when the connection closes. The answer stays, and a real failure still shows as an error.`,`A folder you linked that may no longer be linked (a drive root, your home folder, a network share, OonaCode’s own data) is dropped when the link comes back, and never a folder you did not pick is added.`]},{version:`0.3.260`,date:`2026-10-24`,platforms:[`win32`],added:[`“Bring this PC into the chat” remembers the folders you picked for that chat. Switching between two remote chats, reopening one, or reloading the window comes back linked to exactly those folders — you choose them once. Unlink still clears them for good.`],fixed:[`One “Send now” for the whole queue on the phone too: it sends every queued message at once and empties the list, instead of one button per message.`,`A folder you linked that may no longer be linked (a drive root, your home folder, a network share, OonaCode’s own data) is dropped when the link comes back, and never a folder you did not pick is added.`]},{version:`0.3.260`,date:`2026-10-24`,platforms:[`linux`],added:[`“Bring this PC into the chat” remembers the folders you picked for that chat. Switching between two remote chats, reopening one, or reloading the window comes back linked to exactly those folders — you choose them once. Unlink still clears them for good.`,`This is Linux’s first update since 0.3.250, so it also brings everything in between: a model change says what it came from (“Set model to X for this session only (previous model was Y)”, the model you picked in blue and the one it left in grey); a model typed by id can be set on a chat that runs on another of your PCs; right-clicking a file the chat names offers “Copy relative path” and “Copy absolute path”; a file named in a chat opens in OonaCode even outside the chat folder and its text can be edited; an edited file is saved with Ctrl+S (and Settings → General → Autosave files saves as you type); the sticky notes button shows how many note tabs you have; and a Google Gemini chat in Build asks before running a command, like every other chat.`],fixed:[`One “Send now” for the whole queue on the phone too: it sends every queued message at once and empties the list, instead of one button per message.`,`A folder you linked that may no longer be linked (a drive root, your home folder, a network share, OonaCode’s own data) is dropped when the link comes back, and never a folder you did not pick is added.`,`Also from in between: stopping a reply, or pressing Send now while one is running, says “User requested stop” instead of an error; closing a file you have changed asks whether to save it; a file you edit keeps the line endings it had on disk and a file the model writes while you have it open no longer replaces what you are typing in it; after an admin changes a provider’s offered models, this PC’s list keeps every model’s prices and limits; a PC that checks in with the server on a slow schedule no longer reads as offline between check-ins; a Google Gemini chat no longer shows an error after a complete answer when the connection closes; and a message the agent had already read gets its receipt instead of staying pinned in the queue.`]},{version:`0.3.259`,date:`2026-10-24`,platforms:[`win32`],added:[`A model change says what it came from: “Set model to X for this session only (previous model was Y)”, with the model you just picked in blue and the one it left in grey.`,`You can set a model typed by id on a chat that runs on another one of your PCs, instead of having to go to that PC to change it.`],fixed:[`One “Send now” sends the whole queue at once and empties it, instead of one button per message.`,`A message the agent had already read gets its receipt instead of staying pinned in the queue, where pressing Send now answered “The agent has already read that message”.`]},{version:`0.3.258`,date:`2026-10-23`,platforms:[`win32`],added:[`Right-clicking a file the chat names offers “Copy relative path” and “Copy absolute path”.`],fixed:[`A file you edit keeps the line endings it had on disk when you save it, and a file the model writes while you have it open no longer replaces what you are typing in it.`,`A Google Gemini chat in Build asks before running a command again, and Allow runs that command.`,`After an admin changes a provider’s offered models, this PC’s list keeps every model’s prices and limits — no stale or emptied list in between.`,`A PC that checks in with the server on a slow schedule no longer reads as offline between check-ins; a change reaches it within a minute.`]},{version:`0.3.257`,date:`2026-10-23`,platforms:[`win32`],added:[],fixed:[`Stopping a reply, or pressing Send now while one is running, no longer shows an error. The chat says “User requested stop”.`,`Closing a file you have changed asks whether to save it, with Save, Don’t save and Cancel.`]},{version:`0.3.256`,date:`2026-10-22`,platforms:[`win32`],added:[`A change to the model list or to settings now reaches this PC on its next check-in with the server, without restarting.`],fixed:[]},{version:`0.3.255`,date:`2026-10-22`,platforms:[`win32`],added:[],fixed:[`A Google Gemini chat no longer shows an error after a complete answer when agy’s local connection closes. The answer stays, and a real failure still shows as an error.`]},{version:`0.3.254`,date:`2026-10-22`,platforms:[`win32`],added:[`A file named in a chat opens in OonaCode, even when it is outside the chat folder. Text and code can be edited; a sound, picture or video plays as before.`,`An edited file no longer has a Save button. A changed tab shows *, Ctrl+S saves it, and Settings → General → Autosave files saves each change as you type.`],fixed:[]},{version:`0.3.252`,date:`2026-10-21`,platforms:[`win32`,`darwin`],added:[`The sticky notes button shows how many note tabs you have, as a blue number.`],fixed:[]},{version:`0.3.251`,date:`2026-10-21`,platforms:[`win32`],added:[`A Google Gemini chat in Build now asks before running a command, using the same permission card as every other chat. Autonomous and auto-accept still run commands without asking.`],fixed:[]},{version:`0.3.250`,date:`2026-10-21`,added:[`The file list now has Show in Explorer, which opens the file or folder selected in your computer’s file manager, and Rename for both files and folders.`,`A text file opened from the file list can now be edited. Change it, then press Save or Ctrl+S. Pictures, videos, sounds and PDF files stay view-only.`],fixed:[]},{version:`0.3.249`,date:`2026-10-20`,added:[`When the model reads a picture, a video or a sound file, that step in the chat now opens by itself: you see the picture, or get a player for the video or sound, without clicking. Click the step to close it. Steps that read ordinary text files stay closed as before.`],fixed:[]},{version:`0.3.248`,date:`2026-10-20`,added:[],fixed:[`A chat on Google Gemini (through your Google plan) no longer ends a finished turn with an error. Google’s agy tool can keep repeating an old “quota reached” message at the end of a long chat even though your limit was fine and the answer arrived; OonaCode now shows the answer as done and adds a short note. A limit you really hit still shows as an error.`,`When you do reach your Google limit in a Gemini chat, OonaCode now shows Google’s own message, including when it resets, instead of a message about the OonaCode pool that did not apply to you.`]},{version:`0.3.247`,date:`2026-10-20`,added:[`On the Android app, a short tap on a message now opens a menu: Reply (quotes it above the box), Copy, Forward (opens it as a draft in another chat you pick), Share and Save text to… A long press still selects text.`,`On the Android app, a picture, video, sound or file that a reply names now opens from your PC: pictures show right in the chat, videos and sounds play in the chat, and other files open in the app you choose or are saved where you say. A file larger than 25 MB asks first.`,`This PC now hands those files to your phone over the same private link as your chats — only files that the chat itself named or that sit in its folder, one piece at a time.`],fixed:[]},{version:`0.3.246`,date:`2026-10-19`,added:[`Every chat can now make videos and spoken audio, not only pictures: ask for a short clip or a voice-over and the model makes it, saves it in the chat’s folder and plays it right in the chat. Video and Speech sit beside Images in the Tools menu, switched on by default.`,`In the Tools menu each of the three has a model choice for this chat (its default follows the model you are chatting with: a Grok chat uses Grok’s, an Alibaba chat Alibaba’s) and an “Ask me first” switch. With it on — the default for video — the model asks you for the length, resolution and shape and tells you the price in credits before anything is spent.`,`Pictures, videos and speech are paid with your OonaCode credits like any other message, whatever model or key the chat runs on, and the credits charged are shown in the answer.`,`On Apple Silicon Macs (M1 and later) Oonak Browser is now the native build: it quits with its last window, shows its own Dock icon and never asks for notification permission.`],fixed:[]},{version:`0.3.245`,date:`2026-10-19`,added:[`A picture, video or sound that a model reply named but that is not on your PC any more is now left out of the Media explorer, with a line under the list saying how many were left out and a Show button to see them.`,`A picture the model made now shows up in the chat as a small square beside its name — you no longer need the Media panel to notice it — and a click enlarges it.`,`A file the model names (a PDF, a Word or Excel document, a zip and so on) now shows its type’s icon in the chat and in the Media explorer; a file of any other type gets a plain file icon.`],fixed:[`The Media explorer no longer lists a website path such as /logo.svg or /favicon.png from a model reply as if it were a file on your PC, and a card that cannot be opened now shows the file name and date instead of only “Moved or deleted”.`]},{version:`0.3.244`,date:`2026-10-19`,added:[`When the agent enters plan mode (and when you approve its plan) the Build / Plan / Ask picker now follows it, so the picker always shows the mode the chat is really in.`],fixed:[`Four engine tools nobody uses here — ListAgents, EnterWorktree, ExitWorktree and ReportFindings — are switched off in every chat, which makes each request a little smaller.`]},{version:`0.3.243`,date:`2026-10-18`,added:[`OonaCode now asks before it quits or updates while any chat is still working — including chats whose tabs you closed — and names them, so nothing is interrupted by accident.`],fixed:[]},{version:`0.3.242`,date:`2026-10-18`,added:[`Every model can now take any attachment: a picture or PDF that the chosen model cannot read (Google’s agy, text-only Qwen or GLM models, and so on) is saved in the chat’s temporary folder and the model is given its file path instead of the message being refused.`,`The media panel can filter by All, Mine or Replies, so the pictures, videos, sounds and links that the model’s replies name are listed too, and every item has a right-click menu (View or Play, Show in chat, Show in folder, Copy path or link).`,`The “Media in this chat” and “Session info” panels can be resized by dragging their left edge; double-click the edge for the default width.`,`Web search is now in every chat, always: there is no Tools-menu switch for it any more, and chats that had it switched off search again.`],fixed:[]},{version:`0.3.241`,date:`2026-10-17`,added:[`Remote sessions in the sidebar now have a full right-click context menu and actions button (Pin to top, Move to Project, Project settings, Change folder, Details, Listen to this chat, Files, Rename, Fork and Delete) plus a details card on hover.`,`The Files explorer and file viewer now work for remote chats over the blind relay, so you can browse folders, view code, Markdown and images, copy paths and delete files on the remote PC.`,`Oonak Browser is now available for macOS chats as well as Windows and Linux.`],fixed:[`Newly created or renamed remote chats now appear immediately in the Remote section of the left sidebar, and the sidebar automatically recovers after a brief server or connection blip.`,`Opening a long remote chat with many screenshots no longer disconnects the relay for backpressure or stops loading recent messages.`]},{version:`0.3.240`,date:`2026-10-17`,added:[`Every Thought block now shows how long the model spent thinking (for example “Thought · 42 words · 12s”), both live and when a chat is reopened.`,`Remote chat tabs now show a badge naming the PC they run on, and you can rename a remote chat directly from its tab or from the Remote list in the sidebar.`,`Files attached from the Android app are uploaded into the chat’s folder on the PC that runs the chat.`],fixed:[`Subagent reports and continuation notes now fold into a single Engine note line instead of staying pinned at the bottom of the chat or replacing the pinned user question.`,`Local video and file paths in replies (including Windows paths with forward slashes, paths with spaces, and Markdown links) now reliably show their Play, View and Open in folder buttons.`,`Chats on a ChatGPT (Codex) subscription no longer fail when the model calls tools.`,`Google agy chats wait and retry automatically (5 s, 20 s, 1 min, 2 min) when Google answers with a temporary 503 Unavailable.`]},{version:`0.3.239`,date:`2026-10-16`,platforms:[`win32`],added:[`Media in every chat: the gallery button at the top right of a chat lists the photos, videos, audio, files and links you sent in it. Photos open in the viewer (← → step through them), videos and audio play in place, files open or show in their folder, and “Show in chat” jumps to the message.`],fixed:[`Google agy chats no longer flash a command window when they start. OonaCode now keeps agy up to date itself, quietly, while no agy chat is running.`,`An agy command that waits for someone to type (a password prompt, an ssh question) no longer holds the chat for hours: after 15 minutes with no output and no work, OonaCode ends that command, says so in the chat, and agy carries on.`,`The coding engine is updated (Claude Code 2.1.301): long answers are no longer cut off after three minutes of silence, a long chat no longer compacts again and again, and a tool no longer runs twice.`,`If the app’s window crashes (for example when the computer runs out of memory), it reloads by itself.`,`A chat on your own Meta Muse or ChatGPT plan that started on another provider no longer fails with “call_id must be at most 64 characters”.`,`Your other PCs keep one order in the Remote list instead of reshuffling.`,"`oona -p` with an OonaCode API key says what went wrong instead of asking you to sign in."]},{version:`0.3.239`,date:`2026-10-16`,platforms:[`darwin`],added:[`Media in every chat: the gallery button at the top right of a chat lists the photos, videos, audio, files and links you sent in it. Photos open in the viewer (← → step through them), videos and audio play in place, files open or show in their folder, and “Show in chat” jumps to the message.`],fixed:[`The coding engine is updated (Claude Code 2.1.301): long answers are no longer cut off after three minutes of silence, a long chat no longer compacts again and again, and a tool no longer runs twice.`,`If the app’s window crashes (for example when the computer runs out of memory), it reloads by itself.`,`A chat on your own Meta Muse or ChatGPT plan that started on another provider no longer fails with “call_id must be at most 64 characters”.`,`Your other PCs keep one order in the Remote list instead of reshuffling.`,`A download cut part-way during an update is resumed instead of starting over.`,"`oona -p` with an OonaCode API key says what went wrong instead of asking you to sign in."]},{version:`0.3.239`,date:`2026-10-16`,platforms:[`linux`],added:[`Media in every chat: the gallery button at the top right of a chat lists the photos, videos, audio, files and links you sent in it. Photos open in the viewer (← → step through them), videos and audio play in place, files open or show in their folder, and “Show in chat” jumps to the message.`],fixed:[`“Restart now” in Settings opens the app again instead of closing it for good.`,`The OonaCode service starts again after a quick reboot.`,`A power cut no longer empties the files that keep you signed in and unlocked.`,`A download cut part-way (weak Wi-Fi) during an install or update is resumed instead of giving up.`,`Notifications come from “OonaCode”.`,`The coding engine is updated (Claude Code 2.1.301): long answers are no longer cut off after three minutes of silence, a long chat no longer compacts again and again, and a tool no longer runs twice.`,`If the app’s window crashes (for example when the computer runs out of memory), it reloads by itself.`,`A chat on your own Meta Muse or ChatGPT plan that started on another provider no longer fails with “call_id must be at most 64 characters”.`,`Your other PCs keep one order in the Remote list instead of reshuffling.`,"`oona -p` with an OonaCode API key says what went wrong instead of asking you to sign in."]},{version:`0.3.238`,date:`2026-10-16`,added:[`Auto in the OonaCode pool: pick “Auto” and each new message runs on the pool model that suits it — how hard the task is, how big the chat is, whether a model already has the chat in its cache, speed and cost — at an effort it picks too. The model button shows which model Auto chose, like “Auto (Qwen3.8 Max)”. (It appears once OonaCode switches it on.)`,`Window control in the Tools menu: when you ask, the agent can list, hide, show, minimise, restore or focus the windows on your computer (Windows; apps on macOS; X11 and KDE on Linux).`,`The conversations popup in a chat shows when each conversation started and when it was last active.`],fixed:[`A Google agy chat that hits a temporary “service unavailable” from Google now waits a few seconds and carries on in the same conversation instead of ending the turn.`,`The agent keeps Oonak Browser’s window visible: no hidden or headless browser unless you ask for one.`]},{version:`0.3.237`,date:`2026-10-15`,platforms:[`win32`,`darwin`],added:[`When a long chat no longer fits the model, the chat shows one line saying how many earlier messages the request left out; click it for the explanation.`],fixed:[`The model picker no longer has an “All models” list, which showed the same model twice when a provider offers it both by key and by subscription. Pick a provider to see its models.`,`Google’s agy: Gemini 3.7 Flash, 3.6 Flash and 3.1 Pro are gone from the picker, because Google no longer offers them, and the picker shows only the models your own Google plan lists. A chat that was on one of them asks you to pick another model.`,`A picture or PDF attached to a chat on Google’s agy is refused with words that say agy takes text only on every one of its models, and that another provider’s model can read it.`,`A thought with no words in it (Meta Muse hides its thinking) no longer leaves an empty “Thought” card in the chat.`,`Conversations between chats read “idle” when nothing is going on.`]},{version:`0.3.237`,date:`2026-10-15`,platforms:[`linux`],added:[`The model picker is redone: your providers on the left, each with how many models it has, and the chosen provider’s models on the right, best first by independent intelligence rating. Each side has its own search. After you pick a model from another provider, its button says “next message” until your next message runs on it.`,`Every model shows its own effort levels, and the effort picker starts on the model’s default. A model with no effort levels shows no picker.`,`Meta Muse: Muse Spark 1.3 and 1.2, Wonder 1.0 and Wonder Full 1.0 — paste your Muse key in Connect or press “Sign in with Meta”.`,`ChatGPT plans: GPT-6.1 Sol, GPT-6 Sol, GPT-6 Astra and GPT-5.6 Sol when your plan lists them; chats keep their thinking across tool calls and use the effort you pick.`,`NVIDIA is back for your own NVIDIA key, with twelve hosted models that call tools. Your own SuperGrok subscription offers Grok 4.7 Fast.`,`Bring this PC into the chat: on a chat that runs on another PC, pick folders on this PC and what the chat may do there; it asks you before every change. And a Tools switch lets a chat list, read and message the chats on your other PCs.`,`Sticky notes beside the bug button, saved in your vault so they follow you to your other computers.`,`Suggest, beside Listen in every chat, proposes what to send next, and the project manager does it for several chats at once. Nothing is sent until you press Send.`,`Listen to this chat is a player with a seek bar, a speed you can change while it plays, and the spoken word highlighted.`,`A tab whose chat finished a turn you have not looked at yet wears a dot. A long chat folds old agents into one “N earlier agents” row, and every block shows its time.`,`When a long chat no longer fits the model, one line says how many earlier messages the request left out.`],fixed:[`A message sent while a chat is working, right after you picked another model, waits for the running turn and is answered by the model you picked.`,`A PC you sign in later appears in the left panel by itself.`,`A thought with no words in it no longer leaves an empty “Thought” card.`,`The Claude Code engine is updated to 2.1.296.`]},{version:`0.3.236`,date:`2026-10-14`,platforms:[`win32`,`darwin`],added:[`Every model now shows its own effort levels, and the effort picker starts on the model’s default — so you can see what level a chat really runs at. A model that has no effort levels no longer shows a picker at all.`,`A collapsed thought block now shows how the thought begins, like a command does: “Thought 42 words: First I read the file…”.`,`Meta Muse requests now match Meta’s own Muse CLI, so its thinking, tool calls, pictures and PDFs show up properly in the chat.`],fixed:[`Grok 4.5 no longer offers an “extra high” effort that xAI treats as high, and GPT-4.1 no longer shows an effort picker it cannot use.`]},{version:`0.3.235`,date:`2026-10-13`,platforms:[`win32`,`darwin`],added:[`Meta Muse: use Meta’s Muse Spark 1.3, Spark 1.2, Wonder 1.0 and Wonder Full 1.0 in your chats. Open Connect, pick Meta Muse, and either paste your Muse key or press “Sign in with Meta” — OonaCode downloads Meta’s Muse once (about 360 MB, after you agree), you confirm the code on Meta’s page, and the key is kept in your vault.`,`ChatGPT plans: GPT-6.1 Sol (500k context), GPT-6 Sol, GPT-6 Astra and GPT-5.6 Sol are available when your plan lists them, next to the models you already had.`,`Google’s agy: Gemini 4 Argon appears in the model picker when your Google plan includes it (Ultra), at Low, Medium and High.`],fixed:[]},{version:`0.3.234`,date:`2026-10-13`,platforms:[`win32`,`darwin`],added:[`Bring this PC into the chat: on a chat that runs on another PC, press the button in the chat’s toolbar, pick folders on this PC and tick Read, Create, Edit or Delete for each. The chat can then work with those files. It asks you before it creates, changes, moves or deletes anything, and the link ends when you close the tab. Both PCs need this version.`,`Chats on my other PCs: a new switch in the Tools menu lets a chat list your other PCs and their chats, read them, message them and start new chats there on the model you choose. You confirm every new chat.`,`The Tools menu now works on a chat that runs on another PC, so you can switch its tools from here.`],fixed:[`A PC you sign in after OonaCode has started now appears in the left panel by itself, without opening Settings → Devices first.`]},{version:`0.3.233`,date:`2026-10-12`,platforms:[`win32`,`darwin`],added:[`The model picker now tells you when a pick is not in use yet: after you pick a model from another provider, its button says “next message” and explains that the chat keeps running on its current model until your next message.`,`A long chat folds the agents that ran long ago into one “N earlier agents” row that says when they ran, instead of one card for each of them under your newest message.`],fixed:[`A message you send while a chat is working, right after you picked another model or provider, now waits for the running turn and is answered by the model you picked. It used to go to the model that was already running, so the chat kept answering as the old one while the picker showed the new one.`,`Every block in a chat now shows the time it happened — also the notes the app writes itself and the cards for earlier agents.`]},{version:`0.3.232`,date:`2026-10-12`,platforms:[`win32`],added:[`The model picker is redone: your providers on the left, each with how many models it has, and the chosen provider’s models on the right, best first by independent intelligence rating (unrated ones last). Each side has its own search, and the one over the providers finds a model across every provider, showing only the providers that carry it.`,`NVIDIA is back for your own NVIDIA key: twelve hosted models that call tools, among them Nemotron 3 Ultra and Super, Kimi K3, GLM-5.3, DeepSeek V4.1 Flash and Gemma 4.`],fixed:[`Models hosted as vendor/model (Kimi K3 on NVIDIA and the like) now show their intelligence rating.`]},{version:`0.3.232`,date:`2026-10-12`,platforms:[`darwin`],added:[`Sticky notes: the note button beside the bug button at the top opens your notes as tabs. Make as many as you like, name them with a double-click, and write — every change is saved by itself in your vault, so the notes follow you to your other computers. Text only.`,`Chats on your own ChatGPT plan keep their thinking across tool calls, use the effort level you pick (up to max where the model has it), and list the models your account really offers.`,`The model picker is redone: your providers on the left, each with how many models it has, and the chosen provider’s models on the right, best first by independent intelligence rating (unrated ones last). Each side has its own search, and the one over the providers finds a model across every provider, showing only the providers that carry it.`,`NVIDIA is back for your own NVIDIA key: twelve hosted models that call tools, among them Nemotron 3 Ultra and Super, Kimi K3, GLM-5.3, DeepSeek V4.1 Flash and Gemma 4.`],fixed:[`Suggest no longer starts reading the chat the moment you open it: pick how many hours to read, then press Suggest.`,`The Claude Code engine is updated to 2.1.296.`,`Models hosted as vendor/model (Kimi K3 on NVIDIA and the like) now show their intelligence rating.`]},{version:`0.3.231`,date:`2026-10-12`,platforms:[`android`],added:[`On the phone: any text in a chat can be selected and copied, and About became Session info.`],fixed:[]},{version:`0.3.230`,date:`2026-10-11`,platforms:[`win32`],added:[`Sticky notes: the note button beside the bug button at the top opens your notes as tabs. Make as many as you like, name them with a double-click, and write — every change is saved by itself in your vault, so the notes follow you to your other PCs. Text only.`,`Chats on your own ChatGPT plan keep their thinking across tool calls, use the effort level you pick (up to max where the model has it), and list the models your account really offers.`],fixed:[`Suggest no longer starts reading the chat the moment you open it: pick how many hours to read, then press Suggest.`,`A Gemini chat on your own Google plan no longer repeats, turn after turn, a command it refused earlier.`,`The Claude Code engine is updated to 2.1.296.`]},{version:`0.3.229`,date:`2026-10-11`,platforms:[`darwin`],added:[`Suggest, beside Listen in every chat: it reads the last few hours of the chat and suggests what to send it next. You edit it, put it in the message box or send it — nothing runs by itself.`,`The project manager, beside the "about" button over the chat list: tick chats, press Review, and each gets a suggestion you can edit and send with its own button.`,`A tab whose chat finished a turn you have not looked at yet wears a dot (red when the turn failed), and so does its row in the list.`,`Listen to this chat is a player: a seek bar, play and pause, ten seconds back and forward, the previous or next sentence, a speed you can change while it plays, the spoken word highlighted (click any word to play from it), and every summary listed newest first on top.`,`MCP servers: add them in Settings → MCP Servers from a directory of popular ones (PostgreSQL, Supabase, GitHub, Sentry, Slack, Notion, Linear and more) or your own, and switch each on or off per chat.`,`Connectors: Supabase, Railway and Vercel in the Tools menu — sign in once, switch one on in a chat, and the agent can look at your projects, databases, logs and deployments; read-only until you allow changes, and it asks before each one.`,`Pictures: ask any chat for an image and it makes one, saved in the chat’s folder and shown in the chat (a few credits each; Images in the Tools menu turns it off).`,`Web search for every model, from your Mac, with no key and no credits.`,`Claude Haiku 5.5 with a 1M-token window, and Grok 4.7 Fast on your own SuperGrok subscription.`,`Pasting a very long text, or a video, sound or large picture, saves it in the chat’s folder and attaches it as a file.`,`Hover a “Read …png” line in the chat and the picture shows at once.`],fixed:[`A compacted chat reopens with its whole history, not only what came after its last compaction.`,`Deleting a chat frees its OonaCode pool seat at once.`,`Large chats resume faster.`,`The chat summary (“About”) no longer fails on models that think at length.`,`A refusal by Gemini’s safety filter is retried once on another model, like the others.`,`Error notes in the chat read as plain sentences instead of codes or raw data.`,`The message navigator always shows at least four lines and no longer vanishes on the way to it.`]},{version:`0.3.228`,date:`2026-10-11`,platforms:[`win32`],added:[`Suggest, beside Listen in every chat: it reads the last few hours of the chat and suggests what to send it next. You edit it, put it in the message box or send it — nothing runs by itself.`,`The project manager, beside the "about" button over the chat list: tick chats, press Review, and each gets a suggestion you can edit and send with its own button.`,`A tab whose chat finished a turn you have not looked at yet wears a dot (red when the turn failed), and so does its row in the list.`],fixed:[]},{version:`0.3.227`,date:`2026-10-11`,platforms:[`win32`],added:[`Listen to this chat is a player: a seek bar, play and pause, ten seconds back and forward, the previous or next sentence, and a speed you can change while it plays.`,`The word being spoken is highlighted in the summary, and clicking any word plays from there.`,`Every summary the chat has is listed on top, newest first; pick one to hear it, with the languages it was already translated into.`],fixed:[]},{version:`0.3.226`,date:`2026-10-11`,platforms:[`win32`],added:[`Google Gemini (agy) chats show what agy looked at: a picture it viewed appears in the chat, and a sound or video it named plays inside the tool card.`,`Your own SuperGrok subscription offers Grok 4.7 Fast.`,`The Android app groups this PC’s chats by the project each one is filed under.`],fixed:[`Google Gemini (agy) tool steps read in words — View file, Run command, Edit — with their file or command, instead of raw arguments.`,`Your own SuperGrok sign-in presents the current Grok CLI (1.0.50), so xAI does not refuse it as outdated.`]},{version:`0.3.225`,date:`2026-10-10`,platforms:[`win32`,`linux`],added:[`Per-credential usage keys: operator credentials can now store their own console session keys (such as Xiaomi MiMo account credentials) directly in the Admin Panel to monitor individual token plan quotas and balances.`,`Google agy thinking blocks: local Google Antigravity (Gemini) sessions now extract and display model thinking blocks and rich tool arguments in chat from agy transcripts.`],fixed:[`Session info regeneration: fixed an issue where regenerating the session summary for Google Antigravity (Gemini) sessions would fail with a missing subscription token error.`,`Xiaomi MiMo cleanup: removed redundant and withdrawn mimo-v2.5 and mimo-v2.5-pro models from the registry and models catalog; replaced by mimo-v2.6-pro and mimo-v2.6-flash.`]},{version:`0.3.224`,date:`2026-10-09`,platforms:[`win32`,`linux`],added:[`Auto-save clipboard files and large pasted text: pasting text exceeding 10,000 characters or 300 lines automatically saves into your workspace .oonacode/tmp folder and attaches as a file without bloating the composer. Clipboard videos, audio, and large images are similarly saved and attached as local paths.`],fixed:[`Error display in chat: masked internal error codes, raw JSON, and provider balance exhaustion notices from the user chat bubble, displaying clean status indicators instead.`,`Google Antigravity pool plan access: included Gemini 3.8 Flash and 3.7 Flash across all active subscription plans (Standard, Pro, Team Standard, Team Premium, Free).`,`Session info panel: fixed an issue where switching between chats could leave stale child views mounted in the session info panel.`]},{version:`0.3.223`,date:`2026-10-09`,platforms:[`win32`,`linux`],added:[`MCP Servers settings & Antigravity catalog: configure stdio, sse, and http Model Context Protocol servers in File -> Settings -> MCP Servers. Choose from a rich directory of popular providers (PostgreSQL, Supabase, Redis, SQLite, MongoDB Atlas, GitHub, GitLab, Sentry, Cloudflare, Slack, Notion, Linear, PostHog, Brave Search) or add custom servers.`,`TopBar MCP badge: see your configured MCP servers count at a glance next to the Bug Report button, and click to open MCP settings directly.`,`Per-chat MCP server toggles: selectively enable or disable configured MCP servers per conversation in the composer toolbar to eliminate prompt token overhead.`],fixed:[]},{version:`0.3.222`,date:`2026-10-09`,platforms:[`win32`,`linux`],added:[],fixed:[`Chat summary "About": increased housekeeper output token headroom to prevent thinking and verbose models (e.g. Qwen, Gemini) from exceeding the token ceiling and failing with "Claude's response exceeded the 700 output token maximum".`]},{version:`0.3.221`,date:`2026-10-09`,platforms:[`win32`,`linux`],added:[`Web search for every model: all models can now search the web via keyless local DuckDuckGo search from your PC, with no extra credentials or credits needed.`,`Claude Haiku 5.5: available with 1M context, 128K output, and tiered pricing (replaces Haiku 4.5).`],fixed:[`Deleting a chat immediately frees its pool seat on the server, instead of keeping it held until the session cache window expires.`,`Session info panel headers: distinct icons for About (sparkle) and Scheduled tasks (bell) so sections no longer repeat the same info glyph.`,`Large sessions resume faster and safer with reverse-bounded transcript loading and auto-trimming to disk.`,`Gemini content safety filter blocks are now caught by safeguard fallback and retried on the fallback model.`]},{version:`0.3.220`,date:`2026-10-07`,platforms:[`win32`,`linux`],added:[],fixed:[`A chat on a Google Claude model no longer stops with “Autocompact is thrashing”. Its window was set to 100,000 tokens, so the chat compacted again right after every compaction and the engine gave up; it is now 200,000, and if the engine ever gives up this way the next message starts from a shorter history instead of repeating the same state.`]},{version:`0.3.219`,date:`2026-10-07`,platforms:[`win32`,`linux`],added:[`Pictures: ask any chat for an image — “generate a realistic tiger fighting a crocodile” — and it now makes one, with any model, the way Google’s Antigravity does. The picture is saved in the chat’s folder and shown right in the chat; click it for the full viewer. It costs a few OonaCode credits per picture, you can edit a picture file from the folder too, and it can be switched off in the Tools menu (Images).`,`The Google Claude models (typed by exact id in the model picker’s Custom model row) show their real 100,000-token window in the session panel, and the chat now compacts before the limit instead of being refused and re-sent.`],fixed:[`Google-hosted Claude and Gemini chats re-used almost none of Google’s prompt cache, so big chats ate the 5-hour window in minutes. They now reuse about 98 % of the prompt, which makes them far cheaper and faster.`,`The hidden /setcustommodel command and the admin custom-model tool are gone — the model picker’s Custom model row does the same job.`]},{version:`0.3.218`,date:`2026-10-07`,platforms:[`win32`,`linux`],added:[`Connectors: Supabase, Railway and Vercel in the Tools menu. Sign in once with the service’s own page, switch the connector on in a chat, and the agent can look at your projects, databases, logs and deployments. It is read-only until you turn on “Allow changes”, and then it asks you before every change; purchases, billing and secret or key readers are never offered. Each shows whether the service’s command-line tool is installed and can add the vendor’s own skills. In the terminal: oona connectors. Guide: /docs/connectors.`,`Hover a “Read …png” line in the chat and the picture shows at once; click the picture for the full viewer with zoom, like a picture you sent.`],fixed:[`A chat that was compacted no longer reopens showing only what came after its last compaction: the whole history is there again.`,`The message navigator always shows at least four lines, and its list no longer vanishes while the pointer crosses the gap to it.`]},{version:`0.3.217`,date:`2026-10-07`,platforms:[`darwin`],added:[`Pictures you attach open large: click one in the box or in a sent message for a viewer with zoom (buttons, wheel, drag, Fit and 100 %). Click a PDF or text file and it opens in its own program.`,`When a model refuses a message on safety grounds, OonaCode retries it once on another model and says so in the chat. Choose how in Settings → Safeguards: switch automatically, always switch to a model you pick, or never — with a fallback for each model. The same in the terminal: oona settings safeguard-fallback and --fallback-model. Works for Claude, Gemini and Google’s agy.`,`The terminal signs in two ways: your OonaCode account (through your browser) or an OonaCode API key. A fresh oona asks which; oona login --api-key-stdin stores a key for scripts, oona whoami says which one is in use, and oona logout removes it. The terminal manual is on the website: /docs/cli.`,`The conversations badge reads like the agents badge — “3 conversations · 1 active” — and the Conversations window lists every limit: messages, tokens, credits, depth, rates and the idle close.`,`A chat can start a new chat for you on another provider, model, effort or project — it asks you first, and a chat that was itself started by a chat cannot start more.`,`The message navigator’s list shows each message’s date and opens on your latest one; messages further back than 5,000 lines are greyed.`],fixed:[`A chat that was compacted no longer reopens showing only what came after its last compaction: the whole history is there again.`,`The message navigator always shows at least four lines, and its list no longer vanishes while the pointer crosses the gap to it. A click on it now takes you to older messages even while the chat is still replying (the page used to jump straight back).`,`oona: a wrong command or flag now exits with code 2, oona sessions list no longer breaks on multi-line titles, piping oona into head no longer prints an error, and the plain-prompt mode can send a message again.`,`One-shot terminal runs reuse the engine already on the Mac instead of downloading it every time, and a model you typed with /model that is not in the picker keeps its name after OonaCode restarts.`]},{version:`0.3.216`,date:`2026-10-07`,platforms:[`win32`,`linux`],added:[`The terminal signs in two ways: your OonaCode account (through your browser) or an OonaCode API key. A fresh oona asks which; oona login --api-key-stdin stores a key for scripts and servers, oona whoami says which one is in use, and oona logout removes it. The key is sealed by the host and never written to the terminal’s config.`,`The terminal manual is on the website: /docs/cli, written from commands run on Debian and Ubuntu servers.`],fixed:[`oona: a wrong command or flag now exits with code 2, oona sessions list no longer breaks on multi-line titles, piping oona into head no longer prints an error, and the plain-prompt mode can send a message again.`,`One-shot terminal runs reuse the engine already on the PC instead of downloading it every time.`,`A model you typed with /model that is not in the picker keeps its name after OonaCode restarts.`]},{version:`0.3.215`,date:`2026-10-07`,platforms:[`win32`,`linux`],added:[`Pictures you attach open large: click one in the box or in a sent message for a viewer with zoom (buttons, wheel, drag, Fit and 100 %). Click a PDF or text file and it opens in its own program.`,`When a model refuses a message on safety grounds, OonaCode retries it once on another model and says so in the chat. Choose how in Settings → Safeguards: switch automatically, always switch to a model you pick, or never — with a fallback for each model. The same in the terminal: oona settings safeguard-fallback and --fallback-model. Works for Claude, Gemini and Google’s agy.`,`The conversations badge reads like the agents badge — “3 conversations · 1 active” — and the Conversations window lists every limit: messages, tokens, credits, depth, rates and the idle close.`,`A chat can start a new chat for you on another provider, model, effort or project — it asks you first, and a chat that was itself started by a chat cannot start more.`,`The message navigator’s list shows each message’s date and opens on your latest one; messages further back than 5,000 lines are greyed.`],fixed:[`A click on the message navigator now takes you to older messages even while the chat is still replying (the page used to jump straight back).`,`The message navigator no longer touches the message times, and its lines are darker and longer.`]},{version:`0.3.214`,date:`2026-10-06`,platforms:[`darwin`],added:[`OonaCode runs natively on Apple Silicon Macs. The installer picks the Apple Silicon build by itself, and an Apple Silicon Mac that had the Intel one moves to it on its next install or update — the Intel build cannot run there on macOS 14 or older.`,`A message navigator on every chat: the small stack of lines at the middle-right of the chat is your own messages — rest on it, focus it or tap it and the list of everything you sent opens; click one and the chat scrolls straight to it.`],fixed:[`On an Apple Silicon Mac with macOS 14 or older, every chat crashed (“CPU lacks AVX support”) and Update did nothing. If yours did, run once in Terminal: curl -fsSL https://oonacode.oonak.ai/install.sh | bash`,`When an update cannot start, the app now says why and what to run instead of saying “Updating OonaCode…” while nothing happens.`,`File → Export chats… no longer freezes the window under a Save panel: the zip goes straight into Downloads and Finder shows it.`]},{version:`0.3.213`,date:`2026-10-06`,added:[`A message navigator on every chat: the small stack of lines at the middle-right of the chat is your own messages — rest on it, focus it or tap it and the list of everything you sent opens; click one and the chat scrolls straight to it. Escape closes the list.`],fixed:[],platforms:[`win32`,`linux`]},{version:`0.3.212`,date:`2026-10-06`,added:[`Headless one-shot runs without signing in: --api-key (or OONACODE_API_KEY) bills the run through the gateway on that OonaCode key — held in memory for the run only, never stored. For containers and CI.`],fixed:[`A keyed run no longer stops at the device-link screen, and no longer dies with "the OonaCode pool needs your OonaCode account": the key now also covers provider routing and the registry read on a machine that was never signed in.`],platforms:[`win32`,`linux`]},{version:`0.3.211`,date:`2026-10-06`,added:[`A message navigator on every chat: the small stack of lines at the middle-right of the chat is your own messages — rest on it and the list of everything you sent opens; click one and the chat scrolls straight to it.`,`One-shot runs without signing in: --api-key (or OONACODE_API_KEY) bills the run through the gateway on that OonaCode key — held in memory for the run only, never stored. For headless machines and containers.`],fixed:[],platforms:[`linux`]},{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 gu(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:_u(r.pre,i.pre)}function _u(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 vu(e,t,n=hu,r=null){if(!e||e===`0.0.0`)return[];let i=n.filter(t=>gu(t.version,e)<=0&&(!r||!t.platforms||t.platforms.includes(r)));return[...t===null?i.filter(t=>gu(t.version,e)===0):i.filter(e=>gu(e.version,t)>0)].sort((e,t)=>gu(t.version,e.version))}function yu(e,t,n,r=hu,i=null){if(!e||e===`0.0.0`)return{record:null,show:[]};let a=null;for(let e of r)(a===null||gu(e.version,a)>0)&&(a=e.version);let o=a!==null&&gu(e,a)>0?a:e;return{record:t===null||gu(o,t)>0?o:null,show:t===null&&!n?[]:vu(e,t,r,i)}}function bu(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 xu=`the user skipped the question`,Su=`(the user skipped this question)`;function Cu(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 wu(e,t,n={},r=new Set){let i={};return e.forEach((e,a)=>{if(r.has(a)){i[e.question]=Su;return}let o=(n[a]??``).trim();i[e.question]=o||(t[a]??[]).join(`, `)}),i}function Tu(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 Eu(e){if(!e||typeof e!=`object`)return null;let t=e.answers;return t&&typeof t==`object`&&!Array.isArray(t)?t:null}var Du=[`oauth`,`token`];function Ou(e){switch(e){case`signed-out`:return`Not signed in`;case`connecting`:return`Waiting for your sign-in…`;case`connected`:return`Connected`;case`expired`:return`Sign-in expired`;case`error`:return`Cannot reach the service`}}var ku=R().refine(e=>/^https:\/\/[^\s]+$/i.test(e),`must be an https address`),Au=us({vendor:R().min(1).max(60),mcpUrl:ku,readOnlyQuery:vs(R(),R()).nullable(),auth:us({methods:cs(bs(Du)).min(1),scopes:cs(R()),offlineAccess:ns(),token:us({label:R(),createUrl:ku,note:R().nullable()}).nullable()}),tools:us({deny:cs(R()),allowWrites:cs(R()),featured:cs(R()),maxResultChars:Qo().int().min(1e3).max(2e5)}),cli:us({command:R().regex(/^[A-Za-z0-9._-]{1,40}$/),versionArg:R().regex(/^--?[A-Za-z0-9-]{1,20}$/),install:vs(R(),R()),login:us({command:R(),tokenEnv:R().nullable()}),purpose:R()}).nullable(),skills:cs(us({name:R().regex(/^[a-z0-9][a-z0-9_-]{0,47}$/),source:us({repo:R().regex(/^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/),ref:R().regex(/^[0-9a-f]{40}$/,`pin a full commit, never a branch`),path:R().refine(e=>!/(^|[\\/])\.\.([\\/]|$)|^[\\/]/.test(e),`relative path`)}),license:R(),exclude:cs(R())})),docsUrl:ku}).loose();function ju(e){if(e.toolName!==`ConnectorChange`)return null;let t=e.input;if(!t||typeof t!=`object`||typeof t.connector!=`string`||typeof t.vendor!=`string`||typeof t.tool!=`string`)return null;let n=t.arguments!==null&&typeof t.arguments==`object`&&!Array.isArray(t.arguments)?t.arguments:{};return{connector:t.connector,vendor:t.vendor,tool:t.tool,description:typeof t.description==`string`?t.description:``,arguments:n}}function Mu(e){let t=Object.keys(e.arguments).slice(0,8);return`${e.vendor}: ${e.tool}${t.length>0?` (${t.join(`, `)})`:``}`}var Nu=[`win32`,`linux`,`darwin`],Pu=[`demo`,`live`],Fu=[`allow`,`ask`],Iu=[`string`,`number`,`integer`,`boolean`,`array`,`object`];function Lu(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 Ru(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 zu(e,t){let n=t?.[e.slug];return typeof n==`boolean`?n:e.defaultOn}function Bu(e,t){return e.filter(e=>zu(e,t))}var Vu={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},Hu=/^[A-Za-z0-9_-]+$/;function Uu(e){return typeof e==`string`&&e.length>0&&e.length<=Vu.entryTool&&Hu.test(e)}function Wu(e){return Math.ceil(e.length/4)}function Gu(e){return Wu(`${e.entryTool} ${e.description}`)+55}function Ku(e){return e.tokensPerRequest??Gu(e)+(e.promptLine?Wu(e.promptLine):0)}var qu=us({type:bs(Iu),required:ns().optional(),enum:cs(fs([R(),Qo()])).optional(),description:R().optional()}),Ju=us({slug:R().min(1),description:R(),params:vs(R(),qu),permission:bs(Fu),sort:Qo()}),Yu=us({version:R(),url:R(),sha256:R(),sizeBytes:Qo(),exe:R(),format:Ss(`zip`)}),Xu=us({slug:R().min(1),name:R(),entryTool:R().refine(Uu,`not a valid tool name`),description:R(),promptLine:R().nullable(),details:R().nullable().optional(),status:bs(Pu),defaultOn:ns(),sort:Qo(),install:Yu.nullable(),actions:cs(Ju),connector:Au.nullable().optional().catch(null)}).loose();us({platform:bs(Nu),version:R(),packs:cs(Xu),refreshMinutes:Qo()});var Zu=bs([`stdio`,`sse`,`http`]),Qu=us({id:R().trim().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/i,`ID must be 1-64 alphanumeric, dash, dot, or underscore characters`),name:R().trim().min(1).max(100),description:R().max(500).optional(),transport:Zu,command:R().min(1).max(500).optional(),args:cs(R()).max(100).optional(),env:vs(R(),R()).optional(),url:R().url().max(2e3).optional(),headers:vs(R(),R()).optional(),defaultOn:ns(),enabled:ns().optional(),catalogId:R().max(100).optional()});Qu.refine(e=>e.transport===`stdio`?typeof e.command==`string`&&e.command.length>0:typeof e.url==`string`&&e.url.length>0,{message:`stdio transport requires a command; sse/http transports require a url`}),Qu.partial(),vs(R().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/i),ns()).refine(e=>Object.keys(e).length<=128,`At most 128 MCP server switches`);function $u(e,t){if(e.enabled===!1)return!1;let n=t?t[e.id]:void 0;return typeof n==`boolean`?n:e.defaultOn}function ed(e,t,n){return{...e??{},[t]:n}}var td=[{id:`databases`,label:`Databases`},{id:`cloud`,label:`Cloud & DevOps`},{id:`productivity`,label:`Productivity`},{id:`analytics`,label:`Analytics`},{id:`ai`,label:`AI & Reasoning`},{id:`developer`,label:`Developer Tools`}],nd=[{id:`postgres`,name:`PostgreSQL`,description:`Inspect schemas, query tables, run read operations and analyze database structures.`,category:`databases`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-postgres`,"${connectionString}"],parameters:[{key:`connectionString`,label:`Database Connection URL`,placeholder:`postgresql://user:password@localhost:5432/dbname`,type:`password`,required:!0,target:`arg`,templateIndex:2}],docsUrl:`https://github.com/modelcontextprotocol/servers/tree/main/src/postgres`},{id:`sqlite`,name:`SQLite`,description:`Direct SQL query and schema inspection for local SQLite database files.`,category:`databases`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-sqlite`,`--db-path`,"${dbPath}"],parameters:[{key:`dbPath`,label:`SQLite File Path`,placeholder:`C:/data/app.db or /var/data/app.db`,type:`string`,required:!0,target:`arg`,templateIndex:3}],docsUrl:`https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite`},{id:`supabase`,name:`Supabase`,description:`Manage Supabase Postgres database, migrations, edge functions, and project config.`,category:`databases`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-supabase`],parameters:[{key:`SUPABASE_ACCESS_TOKEN`,label:`Personal Access Token`,type:`password`,required:!0,target:`env`},{key:`SUPABASE_PROJECT_REF`,label:`Project Reference ID`,placeholder:`abcdefghijklmnopqrst`,type:`string`,required:!0,target:`env`}],docsUrl:`https://supabase.com/docs/guides/ai/mcp`},{id:`redis`,name:`Redis`,description:`Inspect keys, data structures, and execute Redis operational commands.`,category:`databases`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-redis`,"${redisUrl}"],parameters:[{key:`redisUrl`,label:`Redis Connection URL`,placeholder:`redis://localhost:6379`,type:`string`,required:!0,target:`arg`,templateIndex:2}]},{id:`mongodb`,name:`MongoDB Atlas`,description:`Query collections, inspect schemas, and interact with MongoDB Atlas databases.`,category:`databases`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-mongodb`,"${connectionString}"],parameters:[{key:`connectionString`,label:`MongoDB Connection URI`,placeholder:`mongodb+srv://user:pass@cluster.mongodb.net/dbname`,type:`password`,required:!0,target:`arg`,templateIndex:2}]},{id:`github`,name:`GitHub`,description:`Search repositories, manage issues, pull requests, files, and branches.`,category:`cloud`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-github`],parameters:[{key:`GITHUB_PERSONAL_ACCESS_TOKEN`,label:`GitHub Personal Access Token (repo scope)`,placeholder:`ghp_...`,type:`password`,required:!0,target:`env`}],docsUrl:`https://github.com/modelcontextprotocol/servers/tree/main/src/github`},{id:`gitlab`,name:`GitLab`,description:`Access GitLab merge requests, project branches, issues, and pipelines.`,category:`cloud`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-gitlab`],parameters:[{key:`GITLAB_PERSONAL_ACCESS_TOKEN`,label:`GitLab Personal Access Token`,type:`password`,required:!0,target:`env`},{key:`GITLAB_API_URL`,label:`GitLab API URL (optional for self-hosted)`,placeholder:`https://gitlab.com/api/v4`,type:`string`,required:!1,target:`env`}]},{id:`cloudflare`,name:`Cloudflare`,description:`Inspect and manage Cloudflare Workers, KV namespaces, D1 databases, and DNS records.`,category:`cloud`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@cloudflare/mcp-server-cloudflare`],parameters:[{key:`CLOUDFLARE_API_TOKEN`,label:`API Token`,type:`password`,required:!0,target:`env`},{key:`CLOUDFLARE_ACCOUNT_ID`,label:`Account ID`,type:`string`,required:!0,target:`env`}]},{id:`sentry`,name:`Sentry`,description:`Retrieve real-time application errors, stack traces, and issue analytics.`,category:`cloud`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-sentry`],parameters:[{key:`SENTRY_AUTH_TOKEN`,label:`Auth Token`,type:`password`,required:!0,target:`env`}]},{id:`google-drive`,name:`Google Drive`,description:`Search, read, and export documents, spreadsheets, and files from Google Drive.`,category:`productivity`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-gdrive`],docsUrl:`https://github.com/modelcontextprotocol/servers/tree/main/src/gdrive`},{id:`slack`,name:`Slack`,description:`Read conversation history, search channel messages, and post updates to Slack channels.`,category:`productivity`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-slack`],parameters:[{key:`SLACK_BOT_TOKEN`,label:`Bot User OAuth Token (xoxb-...)`,type:`password`,required:!0,target:`env`},{key:`SLACK_TEAM_ID`,label:`Slack Workspace Team ID`,type:`string`,required:!0,target:`env`}]},{id:`notion`,name:`Notion`,description:`Read and update Notion workspaces, databases, pages, and blocks.`,category:`productivity`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-notion`],parameters:[{key:`NOTION_API_KEY`,label:`Internal Integration Secret (secret_...)`,type:`password`,required:!0,target:`env`}]},{id:`linear`,name:`Linear`,description:`Track issues, cycles, projects, and comments in Linear.`,category:`productivity`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-linear`],parameters:[{key:`LINEAR_API_KEY`,label:`Personal API Key`,type:`password`,required:!0,target:`env`}]},{id:`posthog`,name:`PostHog`,description:`Query product analytics funnels, trends, user session paths, and feature flags.`,category:`analytics`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@posthog/mcp-server-posthog`],parameters:[{key:`POSTHOG_API_KEY`,label:`Personal API Key`,type:`password`,required:!0,target:`env`},{key:`POSTHOG_PROJECT_ID`,label:`Project ID`,type:`string`,required:!0,target:`env`}]},{id:`brave-search`,name:`Brave Search`,description:`Search the live web and discover local points of interest via Brave Search API.`,category:`ai`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-brave-search`],parameters:[{key:`BRAVE_API_KEY`,label:`Brave Search API Key`,type:`password`,required:!0,target:`env`}]},{id:`memory-graph`,name:`Memory (Knowledge Graph)`,description:`Persistent knowledge-graph entity and relation memory across agent turns.`,category:`ai`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-memory`]},{id:`puppeteer`,name:`Puppeteer Headless Browser`,description:`Automate browser navigation, take page screenshots, and scrape dynamic web content.`,category:`ai`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-puppeteer`]},{id:`remote-sse`,name:`Remote SSE MCP Server`,description:`Connect to any hosted remote MCP server over Server-Sent Events (SSE).`,category:`developer`,transport:`sse`,defaultUrl:`https://`,parameters:[{key:`url`,label:`SSE Endpoint URL`,placeholder:`https://mcp.example.com/sse`,type:`string`,required:!0,target:`url`},{key:`Authorization`,label:`Authorization Header (optional, e.g. Bearer token)`,placeholder:`Bearer ...`,type:`password`,required:!1,target:`header`}]},{id:`remote-http`,name:`Remote Streamable HTTP Server`,description:`Connect to any remote MCP server using standard Streamable HTTP transport.`,category:`developer`,transport:`http`,defaultUrl:`https://`,parameters:[{key:`url`,label:`HTTP Endpoint URL`,placeholder:`https://mcp.example.com/mcp`,type:`string`,required:!0,target:`url`},{key:`Authorization`,label:`Authorization Header (optional, e.g. Bearer token)`,placeholder:`Bearer ...`,type:`password`,required:!1,target:`header`}]}],rd=[`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(`
|
|
86
|
+
`,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 Tc(e){return e===null||!Number.isFinite(e)?`neutral`:e>30?`ok`:e>10?`warn`:`danger`}var Ec=3e4,Dc=1440,Oc=6e4,kc=[`mon`,`tue`,`wed`,`thu`,`fri`,`sat`,`sun`],Ac=/^([01]\d|2[0-3]):[0-5]\d$/;us({tz:R().min(1),windows:cs(us({from:R().regex(Ac,`HH:MM`),to:R().regex(Ac,`HH:MM`),days:cs(bs(kc)).optional(),kind:bs([`peak`,`offpeak`])})),offpeakDiscount:Qo().nonnegative().max(1).optional()});var jc=[`priceInputCacheMissPeak`,`priceInputCacheMissOffpeak`,`priceInputCacheHitPeak`,`priceInputCacheHitOffpeak`,`priceCacheWritePeak`,`priceCacheWriteOffpeak`,`priceOutputPeak`,`priceOutputOffpeak`],Mc=us({inputCacheMiss:Qo().nonnegative(),inputCacheHit:Qo().nonnegative().optional(),cacheWrite:Qo().nonnegative().optional(),output:Qo().nonnegative()});us({by:Ss(`prompt_tokens`),tiers:cs(us({upToPromptTokens:Qo().int().positive().optional(),price:Mc.optional(),cost:Mc.optional()})).min(1),note:R().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})}),[...jc];var Nc={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`};Nc.realtime,Nc.translations,Nc.live,Nc.speechStream,Nc.transcriptionStream;var Pc=`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`,Fc=`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`,Ic=`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`,Lc=`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`,Rc={oonacode:{hex:`#000000`,owner:`OonaCode`,d:Pc,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:Ic},xai:{hex:`#000000`,owner:`xAI`,d:Fc},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:Fc},"openai-subscription":{hex:`#000000`,owner:`OpenAI`,d:Ic},"openai-codex":{hex:`#000000`,owner:`OpenAI`,d:Ic},"google-agy":{hex:`#8E75B2`,owner:`Google`,d:Lc},antigravity:{hex:`#8E75B2`,owner:`Google`,d:Lc},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 zc(e){return Rc[e]??null}function Bc(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 Vc=9230,Hc=1024,Uc=65534,Wc=`127.0.0.1`;Object.freeze({enabled:!1,port:Vc,inspectMain:!1}),Object.freeze({port:null,listening:!1,fromCommandLine:!1,inspectPort:null,inspectProblem:null});function Gc(e){return e+1}function Kc(e){return typeof e==`number`&&Number.isInteger(e)}function qc(e){return!Kc(e)||e<1024||e>65534?`The port must be a whole number from ${Hc.toLocaleString(`en-US`)} to ${Uc.toLocaleString(`en-US`)} (the main-process inspector takes the next one).`:null}function Jc(e){return e.port!==null||e.inspectPort!==null}function Yc(e,t){let n=e.enabled?e.port:null,r=e.enabled&&e.inspectMain?Gc(e.port):null;return!t.fromCommandLine&&t.port!==n||t.inspectPort!==r||Xc(t)}function Xc(e){return!Jc(e)&&typeof e.chromiumUntilRestart==`number`}function Zc(e){let t=[];return e.port!==null&&t.push(`${Wc}:${e.port}`),e.inspectPort!==null&&t.push(`${Wc}:${e.inspectPort}`),t.length===2?`${t[0]} (windows) and ${t[1]} (main process)`:e.inspectPort===null?t[0]??``:`${t[0]} (main process)`}var Qc=[`stable`,`dev`];function $c(e){return typeof e==`string`&&Qc.includes(e)}function el(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return $c(t)?t:null}var tl=[`win32`,`linux`,`darwin`],nl=[`x64`,`arm64`];function rl(e,t){let n=el(e)??`stable`,r=[];return n!==`stable`&&r.push(`channel=${encodeURIComponent(n)}`),t&&tl.includes(t.platform)&&(r.push(`platform=${t.platform}`),t.arch&&nl.includes(t.arch)&&r.push(`arch=${t.arch}`)),r.length>0?`${pc.releasesLatest}?${r.join(`&`)}`:pc.releasesLatest}function il(e,t){let n=el(t)??`stable`;return n===`stable`?e:`${e} (${n})`}var al={safeguards:`safeguards`,safety_filters:`safety filters`},ol=[{vendor:`Alibaba (Model Studio / DashScope — Qwen, and the DeepSeek/GLM it hosts)`,seenAs:`400 {"error":{"code":"data_inspection_failed","message":"Input data may contain inappropriate content."}}`,pattern:/data[_ ]?inspection[_ ]?failed|may contain inappropriate content/i},{vendor:`Zhipu (GLM)`,seenAs:`400 {"error":{"code":"1301","message":"系统检测到输入或生成内容可能包含不安全或敏感内容…"}} (contentFilter)`,pattern:/"code"\s*:\s*"?1301"?|不安全或敏感内容|unsafe or sensitive content|contentFilter/i},{vendor:`DeepSeek`,seenAs:`400 {"error":{"message":"Content Exists Risk","type":"invalid_request_error"}}`,pattern:/content exists risk/i},{vendor:`Moonshot (Kimi)`,seenAs:`400 {"error":{"type":"content_filter","message":"The request was rejected because it was considered high risk"}}`,pattern:/"type"\s*:\s*"content_filter"|considered high risk/i},{vendor:`xAI (Grok)`,seenAs:`400 "Content violates usage guidelines. Failed check: SAFETY_CHECK_TYPE_…"`,pattern:/content violates usage guidelines|SAFETY_CHECK_TYPE_/i},{vendor:`OpenAI (and Azure-style filters)`,seenAs:`400 {"error":{"code":"content_filter" | "content_policy_violation" | "moderation_blocked"}}`,pattern:/"code"\s*:\s*"(?:content_filter|content_policy_violation|moderation_blocked)"/i},{vendor:`Google (Gemini)`,seenAs:`This request was blocked by Gemini's filters. They can occasionally trigger by mistake on safe coding, security, or biology-related queries.`,pattern:/blocked by Gemini(?:'s)? filters|Gemini(?:'s)? filters/i}],sl=/blocked by (?:the )?(?:content[ -]safety|Gemini(?:'s)?) filters?|content safety filters?|blocked by Gemini(?:'s)? filters?/i,cl=/blocked by Gemini(?:'s)? filters|Gemini(?:'s)? filters\.? They can occasionally trigger/i;function ll(e){return typeof e==`string`&&cl.test(e)}function ul(e){return typeof e!=`string`||e===``||!/^\s*(?:Failed to authenticate\.\s*)?API Error\b/i.test(e)?null:ol.find(t=>t.pattern.test(e))??null}function dl(e){return typeof e==`string`&&(ll(e)||sl.test(e)&&/blocked/i.test(e))}function fl(e){return typeof e==`string`&&e.includes(`Something went wrong on our side with this model`)}var pl=`:free`;function ml(e){return e.endsWith(pl)}function hl(e){return ml(e)?e.slice(0,-5):e}var gl=`model_refusal_fallback`,_l=`model_refusal_no_fallback`;function vl(e){return typeof e==`string`&&e.trim()!==``?e.trim():null}function yl(e,t,n){return vl(e[t])??vl(e[n])}function bl(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:yl(t,`original_model`,`originalModel`),fallbackModel:r===`fallback`?yl(t,`fallback_model`,`fallbackModel`):null,category:yl(t,`api_refusal_category`,`apiRefusalCategory`)??vl(t.category),explanation:yl(t,`api_refusal_explanation`,`apiRefusalExplanation`)??vl(t.explanation),text:typeof t.content==`string`?t.content.trim():vl(t.text)??``,retractedUuids:Array.isArray(i)?i.filter(e=>typeof e==`string`):[]}}function xl(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 Sl(e,t){return!e||t.alive===!1||!e.live&&t.since!==null&&e.at!==null&&e.at<t.since?null:e}function Cl(e){let t=oc(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 wl(e,t=[]){let n=oc(e.trim()),r=null;for(let e of t)for(let t of e.definition.models){if(t.id===n||oc(t.id)===n)return t.displayName;r===null&&(t.upstreamId===n||hl(t.id)===n)&&(r=t.displayName)}return r??Cl(n)}function Tl(e){return`${e} (safeguard)`}var El=`none`,Dl={mode:`auto`,model:null,perModel:{}};function Ol(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0&&t.length<=200&&/^[A-Za-z0-9._:@/[\]-]+$/.test(t)?t:null}function kl(e){return oc(e.trim()).toLowerCase()}function Al(e){let t=typeof e==`object`&&e&&!Array.isArray(e)?e:{},n=Ol(t.model),r=t.mode,i=r===`off`?`off`:r===`model`&&n!==null?`model`:`auto`,a={},o=t.perModel;if(typeof o==`object`&&o&&!Array.isArray(o))for(let[e,t]of Object.entries(o)){let n=Ol(e),r=t===`none`?El:Ol(t);if(n!==null&&r!==null&&kl(n)!==kl(r)&&(a[kl(n)]=r,Object.keys(a).length>=64))break}return{mode:i,model:i===`model`?n:null,perModel:a}}function jl(e){return e===w}var Ml=`oona settings safeguard-fallback auto`;function Nl(e,t=[]){if(!e)return`the model`;let n=kl(e);return t.find(e=>kl(e.id)===n||e.upstreamId&&kl(e.upstreamId)===n)?.displayName??Cl(e)}function Pl(e,t=e=>Nl(e)){let n=`blocked by ${al[e.reason]}`;if(e.outcome===`retried`)return`${n} → retried on ${e.retriedOn?t(e.retriedOn):`another model`}`;switch(e.blocked){case`off`:return`${n} · fallback off (${Ml})`;case`no_model`:return`${n} · no fallback model`;case`unavailable`:return`${n} · fallback not available here`;case`refused_again`:return`${n} · fallback refused too`;case`not_retryable`:return`${n} · not retried`;default:return n}}var Fl=5e4,Il=6,Ll=[`sessions`,`search`,`files`],Rl=[`media`,`sessionInfo`];function zl(e){return typeof e==`string`&&Ll.includes(e)?e:null}function Bl(e){if(!Array.isArray(e))return null;let t=[];for(let n of e)typeof n==`string`&&Rl.includes(n)&&!t.includes(n)&&t.push(n);return t}var Vl=[`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`],Hl=/^[A-Za-z0-9 ,'"_-]+$/,Ul=/^(?:[A-Za-z0-9 _-]+|'[A-Za-z0-9 _-]+'|"[A-Za-z0-9 _-]+")$/;function Wl(e){let t=typeof e==`number`&&Number.isFinite(e)?Math.round(e):NaN;return Number.isFinite(t)?Math.min(28,Math.max(10,t)):null}function Gl(e){if(typeof e!=`string`)return null;let t=e.trim().slice(0,160).trim();return t.length===0||!Hl.test(t)?null:t.split(`,`).every(e=>Ul.test(e.trim()))?t:null}function Kl(e){let t=pu(e);return{family:Gl(t.family),size:Wl(t.size)}}function ql(e){let t=pu(e);return{chat:Kl(t.chat),sidebar:Kl(t.sidebar)}}var Jl={agentFinished:!1,permissionRequired:!0,errorOccurred:!0},Yl={autoAcceptPermissions:!1,autosaveFiles:!1,safeguardFallback:Dl,showReasoningSummaries:!0,notifications:Jl,showAgentPicker:!0,transcriptWindowSize:500,keptTranscripts:3,openTabs:[],draftTabs:[],draftTitles:{},activeTab:null,editorLayout:null,remoteTabs:{},sessionPanelOpen:!1,explorerOpen:!1,leftPanelSection:`sessions`,leftPanelOpen:!0,rightPanelSections:[],rightPanelCollapsed:[],sidebarWidth:288,sessionPanelWidth:288,mediaPanelWidth:320,rightPanelWidth:320,sidebarPinned:!0,dismissedUpdateVersion:null,lastSeenReleaseNotes:null,claudeImportOffered:!1,claudeImportOffers:0,collapsedProjects:[],themeColors:{light:{},dark:{}},fonts:{chat:{family:null,size:null},sidebar:{family:null,size:null}},pinned:[],sidebarView:`recent`};function Xl(e){return Math.min(Math.max(typeof e==`number`&&Number.isFinite(e)?Math.floor(e):0,0),3)}function Zl(e){return Math.min(640,Math.max(200,typeof e==`number`&&Number.isFinite(e)?Math.round(e):288))}function Ql(e,t){return Math.min(720,Math.max(240,typeof e==`number`&&Number.isFinite(e)?Math.round(e):t))}function $l(e){return Math.min(20,Math.max(0,typeof e==`number`&&Number.isFinite(e)?Math.round(e):3))}function eu(e){return Math.min(Fl,Math.max(100,typeof e==`number`&&Number.isFinite(e)?Math.round(e):500))}function tu(e,t){return typeof e==`boolean`?e:t}function nu(e){return typeof e==`string`&&e.length>0&&e.length<=64?e:null}function ru(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 iu(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 au(e){if(typeof e!=`string`)return null;let t=e.trim();return/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():null}function ou(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(!Vl.includes(n))continue;let e=au(r);e!==null&&(t[n]=e)}return t}function su(e){let t=typeof e==`object`&&e?e:{};return{light:ou(t.light),dark:ou(t.dark)}}function cu(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 lu(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>Il||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 uu(e,t,n){return e.some(e=>e.kind===t&&e.id===n)}function du(e,t,n,r){return r===uu(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 fu(e){let t=typeof e==`object`&&e?e:{},n=typeof t.notifications==`object`&&t.notifications!==null?t.notifications:{},r=ru(t.openTabs),i=ru(t.draftTabs).filter(e=>!r.includes(e)),a={};for(let[e,n]of Object.entries(iu(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,l=tu(t.sessionPanelOpen,Yl.sessionPanelOpen),u=tu(t.explorerOpen,Yl.explorerOpen),d=Bl(t.rightPanelSections)??(l?[`sessionInfo`]:[]),f=(Bl(t.rightPanelCollapsed)??[]).filter(e=>d.includes(e));return{autoAcceptPermissions:tu(t.autoAcceptPermissions,Yl.autoAcceptPermissions),autosaveFiles:tu(t.autosaveFiles,Yl.autosaveFiles),safeguardFallback:Al(t.safeguardFallback),showReasoningSummaries:tu(t.showReasoningSummaries,Yl.showReasoningSummaries),notifications:{agentFinished:tu(n.agentFinished,Jl.agentFinished),permissionRequired:tu(n.permissionRequired,Jl.permissionRequired),errorOccurred:tu(n.errorOccurred,Jl.errorOccurred)},showAgentPicker:tu(t.showAgentPicker,Yl.showAgentPicker),transcriptWindowSize:eu(t.transcriptWindowSize),keptTranscripts:$l(t.keptTranscripts),openTabs:r,draftTabs:i,draftTitles:a,activeTab:c,editorLayout:lu(t.editorLayout,o),remoteTabs:iu(t.remoteTabs),sessionPanelOpen:l,explorerOpen:u,leftPanelSection:zl(t.leftPanelSection)??(u?`files`:`sessions`),leftPanelOpen:tu(t.leftPanelOpen,Yl.leftPanelOpen),rightPanelSections:d,rightPanelCollapsed:f,sidebarWidth:Zl(t.sidebarWidth),sessionPanelWidth:Ql(t.sessionPanelWidth,288),mediaPanelWidth:Ql(t.mediaPanelWidth,320),rightPanelWidth:Ql(t.rightPanelWidth??t.mediaPanelWidth??t.sessionPanelWidth,320),sidebarPinned:tu(t.sidebarPinned,Yl.sidebarPinned),dismissedUpdateVersion:nu(t.dismissedUpdateVersion),lastSeenReleaseNotes:nu(t.lastSeenReleaseNotes),claudeImportOffered:tu(t.claudeImportOffered,Yl.claudeImportOffered),claudeImportOffers:Xl(t.claudeImportOffers),collapsedProjects:ru(t.collapsedProjects),themeColors:su(t.themeColors),fonts:ql(t.fonts),pinned:cu(t.pinned),sidebarView:t.sidebarView===`projects`?`projects`:`recent`}}new Set(Object.keys(Yl));function pu(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}var mu=3650,hu=[{version:`0.3.366`,date:`2026-11-18`,platforms:[`darwin`],added:[`Settings → This PC → “Debug mode: technical notes in chats”. Off by default: notes about how a chat is run — a Google account that ran out of quota and the chat moving to another, a broken connection the turn continues after, a chat handed over as text, Google’s “service unavailable” and the retry — now go to this PC’s log instead of the chat. Errors that stop a turn, and notes that change what you see, still show.`],fixed:[`Chats on Gemini 4 Carbon, Hydrogen or Argon on OonaCode’s server no longer stop with “used up its quota” and then “does not offer gemini-4-… on any of its Google accounts” while the account still had quota (fixed on the server on 2026-11-18).`]},{version:`0.3.365`,date:`2026-11-18`,platforms:[`linux`],added:[`Settings → This PC → “Debug mode: technical notes in chats”. Off by default: notes about how a chat is run — a Google account that ran out of quota and the chat moving to another, a broken connection the turn continues after, a chat handed over as text, Google’s “service unavailable” and the retry — now go to this PC’s log instead of the chat. Errors that stop a turn, and notes that change what you see, still show.`],fixed:[`Chats on Gemini 4 Carbon, Hydrogen or Argon on OonaCode’s server no longer stop with “used up its quota” and then “does not offer gemini-4-… on any of its Google accounts” while the account still had quota (fixed on the server on 2026-11-18).`]},{version:`0.3.364`,date:`2026-11-18`,platforms:[`win32`],added:[`Settings → This PC → “Debug mode: technical notes in chats”. Off by default: notes about how a chat is run — a Google account that ran out of quota and the chat moving to another, a broken connection the turn continues after, a chat handed over as text, Google’s “service unavailable” and the retry — now go to this PC’s log instead of the chat. Errors that stop a turn, and notes that change what you see, still show.`],fixed:[`Chats on Gemini 4 Carbon, Hydrogen or Argon on OonaCode’s server no longer stop with “used up its quota” and then “does not offer gemini-4-… on any of its Google accounts” while the account still had quota (fixed on the server on 2026-11-18).`]},{version:`0.3.363`,date:`2026-11-18`,platforms:[`darwin`],added:[`3D models in chats: a new “3D model” tool next to Images, Video and Speech makes a textured 3D model (GLB, and FBX, OBJ, STL or USDZ if you ask) from a picture in the chat’s folder, from 2–4 views of one object, or from a description. Quality low, medium or high, priced per model; it is made on OonaCode’s own GPU server. Not offered in the EU, the UK or South Korea, because of the 3D model’s licence.`],fixed:[`A chat that was itself started by another chat can now start new chats too (each still needs your yes), and one chat can keep up to 10 chats it started open.`]},{version:`0.3.362`,date:`2026-11-18`,platforms:[`linux`],added:[`3D models in chats: a new “3D model” tool next to Images, Video and Speech makes a textured 3D model (GLB, and FBX, OBJ, STL or USDZ if you ask) from a picture in the chat’s folder, from 2–4 views of one object, or from a description. Quality low, medium or high, priced per model; it is made on OonaCode’s own GPU server. Not offered in the EU, the UK or South Korea, because of the 3D model’s licence.`],fixed:[`A chat that was itself started by another chat can now start new chats too (each still needs your yes), and one chat can keep up to 10 chats it started open.`]},{version:`0.3.361`,date:`2026-11-18`,platforms:[`win32`],added:[`3D models in chats: a new “3D model” tool next to Images, Video and Speech makes a textured 3D model (GLB, and FBX, OBJ, STL or USDZ if you ask) from a picture in the chat’s folder, from 2–4 views of one object, or from a description. Quality low, medium or high, priced per model; it is made on OonaCode’s own GPU server. Not offered in the EU, the UK or South Korea, because of the 3D model’s licence.`],fixed:[`A chat that was itself started by another chat can now start new chats too (each still needs your yes), and one chat can keep up to 10 chats it started open.`]},{version:`0.3.360`,date:`2026-11-18`,platforms:[`darwin`],added:[`A chat running on another of your PCs: its Image, Video and Speech model and “Ask me first” can now be changed from here too, in the Tools menu (that PC needs this version).`,`The PCs of OonaCode’s own operator account can be updated from the admin panel; an update waits until no chat on the PC is working.`],fixed:["Signed in with an OonaCode API key, the model list (`oona models`, the picker) shows only the models that key can use, and refreshes itself every 10 minutes."]},{version:`0.3.359`,date:`2026-11-18`,platforms:[`linux`],added:[`A chat running on another of your PCs: its Image, Video and Speech model and “Ask me first” can now be changed from here too, in the Tools menu (that PC needs this version).`,`The PCs of OonaCode’s own operator account can be updated from the admin panel; an update waits until no chat on the PC is working.`],fixed:["Signed in with an OonaCode API key, the model list (`oona models`, the picker) shows only the models that key can use, and refreshes itself every 10 minutes."]},{version:`0.3.358`,date:`2026-11-18`,platforms:[`win32`],added:[`A chat running on another of your PCs: its Image, Video and Speech model and “Ask me first” can now be changed from here too, in the Tools menu (that PC needs this version).`,`The PCs of OonaCode’s own operator account can be updated from the admin panel; an update waits until no chat on the PC is working.`],fixed:["Signed in with an OonaCode API key, the model list (`oona models`, the picker) shows only the models that key can use, and refreshes itself every 10 minutes."]},{version:`0.3.357`,date:`2026-11-17`,platforms:[`darwin`],added:[`Claude Opus 5.5 and Claude Sonnet 5.5 on OonaCode’s pool are now ordinary models in the picker, served through Google: one entry each, whoever serves it. A chat saved on the old “via Google” names keeps working.`,`Image, video and voice: the chat now knows every media model and what each can do. When a task needs another one — editing a picture, say — it asks you with one click (Switch / Keep) before anything is made or charged, in every mode.`,`A media model that cannot do what was asked now says which ones can.`],fixed:[`A chat with folders linked from another PC (“Bring this PC into the chat”) is told which PC and folders from the first message, so it starts there instead of asking where your project is.`,`A PDF sent to Claude through Google is passed as a file it can read, not dropped.`]},{version:`0.3.356`,date:`2026-11-17`,platforms:[`linux`],added:[`Claude Opus 5.5 and Claude Sonnet 5.5 on OonaCode’s pool are now ordinary models in the picker, served through Google: one entry each, whoever serves it. A chat saved on the old “via Google” names keeps working.`,`Image, video and voice: the chat now knows every media model and what each can do. When a task needs another one — editing a picture, say — it asks you with one click (Switch / Keep) before anything is made or charged, in every mode.`,`A media model that cannot do what was asked now says which ones can.`],fixed:[`A chat with folders linked from another PC (“Bring this PC into the chat”) is told which PC and folders from the first message, so it starts there instead of asking where your project is.`,`A PDF sent to Claude through Google is passed as a file it can read, not dropped.`]},{version:`0.3.355`,date:`2026-11-17`,platforms:[`win32`],added:[`Claude Opus 5.5 and Claude Sonnet 5.5 on OonaCode’s pool are now ordinary models in the picker, served through Google: one entry each, whoever serves it. A chat saved on the old “via Google” names keeps working.`,`Image, video and voice: the chat now knows every media model and what each can do. When a task needs another one — editing a picture, say — it asks you with one click (Switch / Keep) before anything is made or charged, in every mode.`,`A media model that cannot do what was asked now says which ones can.`],fixed:[`A chat with folders linked from another PC (“Bring this PC into the chat”) is told which PC and folders from the first message, so it starts there instead of asking where your project is.`,`A PDF sent to Claude through Google is passed as a file it can read, not dropped.`]},{version:`0.3.354`,date:`2026-11-17`,platforms:[`darwin`],added:[`Google models on OonaCode’s pool can now start subagents: helpers that work in parallel with the same tools on your PC, each under its own Agent card and in the subagent badge.`,`On your own Google plan (agy), the subagents agy starts now show their work in the chat: the Agent card stays open until the subagent finishes and then shows its answer.`,`The Android app can now choose a chat’s folder by tapping through this PC’s folders — it sees folder names only, over your private link.`,`Pins are shared with the Android app: a chat you pin on the phone is pinned here too, and the other way round.`,`Forking a chat from the phone names the copy as you asked, and can end it at a chosen message.`,`For chats on OonaCode’s pool, the PC now sends the chat’s title (its first 50 characters) so the operator’s admin page can show which chat uses which account. It is kept in memory only, never stored — see /privacy.`],fixed:['Chats on your own key: `thinking: {type: "between_tools"}` and structured output (`output_config.format`) now reach OpenAI-protocol providers as they do Anthropic’s.']},{version:`0.3.353`,date:`2026-11-17`,platforms:[`linux`],added:[`Google models on OonaCode’s pool can now start subagents: helpers that work in parallel with the same tools on your PC, each under its own Agent card and in the subagent badge.`,`On your own Google plan (agy), the subagents agy starts now show their work in the chat: the Agent card stays open until the subagent finishes and then shows its answer.`,`The Android app can now choose a chat’s folder by tapping through this PC’s folders — it sees folder names only, over your private link.`,`Pins are shared with the Android app: a chat you pin on the phone is pinned here too, and the other way round.`,`Forking a chat from the phone names the copy as you asked, and can end it at a chosen message.`,`For chats on OonaCode’s pool, the PC now sends the chat’s title (its first 50 characters) so the operator’s admin page can show which chat uses which account. It is kept in memory only, never stored — see /privacy.`],fixed:['Chats on your own key: `thinking: {type: "between_tools"}` and structured output (`output_config.format`) now reach OpenAI-protocol providers as they do Anthropic’s.']},{version:`0.3.352`,date:`2026-11-17`,platforms:[`win32`],added:[`Google models on OonaCode’s pool can now start subagents: helpers that work in parallel with the same tools on your PC, each under its own Agent card and in the subagent badge.`,`On your own Google plan (agy), the subagents agy starts now show their work in the chat: the Agent card stays open until the subagent finishes and then shows its answer.`,`For chats on OonaCode’s pool, the PC now sends the chat’s title (its first 50 characters) so the operator’s admin page can show which chat uses which account. It is kept in memory only, never stored — see /privacy.`],fixed:['Chats on your own key: `thinking: {type: "between_tools"}` and structured output (`output_config.format`) now reach OpenAI-protocol providers as they do Anthropic’s.']},{version:`0.3.351`,date:`2026-11-17`,platforms:[`android`],added:[],fixed:[`A chat with pictures, tables and charts no longer jumps up and down: pictures and file cards keep their size while they load, wide tables and code blocks no longer grow after they appear, and a chat you open again shows its pictures at once.`,`The chat no longer jumps when a reply finishes.`,`Voice typing says why it could not start and switches to Google’s speech recognition when the phone’s own recognizer refuses; you can pick the speech service in Settings → Voice typing.`,`Android’s Back button on Settings returns to the previous screen instead of leaving the app.`,`Send, Stop and the mic keep their places in the message box, so a quick second tap can no longer stop a turn or open voice typing by accident.`,`With the keyboard open, the first tap on a message’s menu or a custom model’s Use now works.`,`A custom model id that matches a listed model is shown as that model.`,`A message sent with Send now appears after the end of the turn it interrupted.`,`Chat notifications now name the chat.`,`The home-screen widget shows a proper preview in the widget picker and is found by searching OonaCode.`]},{version:`0.3.351`,date:`2026-11-17`,platforms:[`win32`],added:[`The Android app can now choose a chat’s folder by tapping through this PC’s folders — it sees folder names only, over your private link.`,`Pins are shared with the Android app: a chat you pin on the phone is pinned here too, and the other way round.`,`Forking a chat from the phone names the copy as you asked, and can end it at a chosen message.`],fixed:[]},{version:`0.3.350`,date:`2026-11-17`,platforms:[`android`],added:[`Long-press a chat to pin it to the top, fork it, move it to a project, change its folder or delete it. Pins are the same as on your PC.`,`A message’s menu can fork the chat from that message, or remove that exchange (or it and everything after).`,`Share text, links, photos and files into OonaCode from any app: pick the PC and the chat, or start a new chat, and it opens ready to send.`,`Voice typing: tap the mic in the message box and speak — Android’s own speech recognition writes your words as you talk; nothing goes to OonaCode and it costs no credits.`,`The + button takes a photo, picks pictures from your gallery or pastes a copied picture; large photos are made smaller automatically and their location is removed.`,`Reply to your agent, or Allow / Deny a permission, straight from the notification. If OonaCode is locked, the chat opens with your reply ready to send.`,`While a turn you started from the phone is running, a quiet “Working on…” notification with a Stop button shows.`,`After a reply, your PC’s suggested next message appears above the box — tap to use it, tap again or hold to send.`,`A badge beside the model shows how many subagents a chat is running; tap it to see each one and read its transcript.`,`Custom model… at the end of every provider in the model picker.`,`A home-screen widget with your recent chats, their PC and status, and a button to write in that chat. While OonaCode is locked it shows only “Open OonaCode”.`,`What’s new: after an update the app shows what changed, and Settings → About → What’s new lists it any time.`,`OonaCode offers its own updates from Google Play: the new version downloads in the background, and one tap on Restart installs it.`],fixed:[`Tapping a notification now opens that chat on its PC, even when the app was closed.`,`Each waiting message has its own Send now when several are queued, and a message sent now moves into the chat right away.`]},{version:`0.3.350`,date:`2026-11-17`,platforms:[`darwin`],added:[`Settings → Devices now lets you remove an offline PC from your account (it adds itself back when it comes online again) and revoke any other signed-in device, each after a confirmation.`,`Settings → Developer → Allow debugging now applies at once: a debugger can attach to the app’s windows right after you switch it on, and the port closes when you switch it off. No restart.`,"OonaCode for macOS now installs with npm (`npm i -g oonacode`, Apple Silicon and Intel) or Homebrew (`brew tap oonak-ai/tap https://oonacode.oonak.ai/releases/download/brew/homebrew-tap.git && brew install oonak-ai/tap/oonacode`).",`Persian, Georgian and every other language now play in “Listen to this chat” with the app’s own eSpeak voice, as on Windows.`,`Window control now works on single windows once Accessibility is allowed (it says exactly where to allow it), and can move and resize them.`],fixed:[`Signing in to your own Google plan (agy) now shows Google’s sign-in page right away instead of waiting forever.`,`Clicking a notification now opens the chat it is about, even if OonaCode was closed or the notification came from earlier.`,`“Check for Updates…”, “Stop host service” and About in the menu bar and app menu now work when the window is closed, and closing a full-screen window no longer leaves a black screen.`,`On Intel Macs, closing Oonak Browser’s last window now really quits it, so its Dock icon goes away; closing it no longer pauses about two seconds.`,`The red “Debugging on” badge and the window titles now follow Settings → Developer → Allow debugging at once, in every window — switched off, the badge goes. If OonaCode started with debugging on, Chromium’s own port can only close at a restart: the badge turns amber, “restart to close”, and Settings offers Restart now.`,`A message you type while a Google model on OonaCode’s server is working now reaches it at its next step — “please stop” no longer waits for the whole turn — and it leaves the queued strip as soon as the model has read it. Messages with pictures used to stay in the strip after they were read.`]},{version:`0.3.349`,date:`2026-11-17`,platforms:[`linux`],added:[`Settings → Devices now lets you remove an offline PC from your account (it adds itself back when it comes online again) and revoke any other signed-in device, each after a confirmation.`,`While OonaCode updates (AppImage, .deb or .rpm), a small “Updating OonaCode” window now shows until the new version opens.`,`Oonak Browser is now on by default in new chats, tested on KDE Plasma (Wayland and X11).`,`Window control now works on every window on KDE Plasma, Wayland included, with nothing to install, and can move and resize windows.`,`The .deb and .rpm now bring eSpeak NG and speech-dispatcher, so “Listen to this chat” speaks every language; on the AppImage the Listen window shows the exact install command for your distribution.`],fixed:[`On KDE Plasma (Wayland), a chat tab dragged out of the window now opens where you drop it, and “Move chat to new window” opens next to the window it came from.`,`On desktops with no tray icon (plain GNOME), closing the window now minimises OonaCode instead of hiding it where it cannot be found; a one-time note names the GNOME extension that adds the tray.`,`Signing in to your own Google plan (agy): OonaCode no longer mistakes agy’s browser for a stuck command, and leaves an agy installed by your package manager alone.`,`Closing the chat’s Oonak Browser no longer pauses about two seconds.`,"`npm i -g oonacode` works on Linux again: since 0.3.332 the npm package named only the Windows build."]},{version:`0.3.348`,date:`2026-11-17`,platforms:[`win32`],added:[`Settings → Devices now lets you remove an offline PC from your account (it adds itself back when it comes online again) and revoke any other signed-in device, each after a confirmation.`,`Window control can now move and resize windows, so the agent can arrange them side by side.`],fixed:[`Signing in to your own Google plan (agy): when the one-minute window runs out, the card now says so instead of a vague “did not finish”.`,"`npm i -g oonacode` keeps working on every platform after a release that built only some of them."]},{version:`0.3.347`,date:`2026-11-17`,platforms:[`win32`],added:[],fixed:[`The red “Debugging on” badge and the window titles now follow Settings → Developer → Allow debugging at once, in every window — switched off, the badge goes. If OonaCode started with debugging on, Chromium’s own port can only close at a restart: the badge turns amber, “restart to close”, and Settings offers Restart now.`]},{version:`0.3.346`,date:`2026-11-17`,platforms:[`linux`],added:[`Settings → Developer → Allow debugging now applies at once: a debugger can attach to the app’s windows right after you switch it on, and the port closes when you switch it off. No restart.`],fixed:[`A message you type while a Google model on OonaCode’s server is working now reaches it at its next step — “please stop” no longer waits for the whole turn — and it leaves the queued strip as soon as the model has read it. Messages with pictures used to stay in the strip after they were read.`]},{version:`0.3.345`,date:`2026-11-17`,platforms:[`win32`],added:[`Settings → Developer → Allow debugging now applies at once: a debugger can attach to the app’s windows right after you switch it on, and the port closes when you switch it off. No restart.`],fixed:[`A message you type while a Google model on OonaCode’s server is working now reaches it at its next step — “please stop” no longer waits for the whole turn — and it leaves the queued strip as soon as the model has read it. Messages with pictures used to stay in the strip after they were read.`]},{version:`0.3.344`,date:`2026-11-17`,platforms:[`win32`],added:[],fixed:[`When the Google account serving a chat runs out of quota for its model mid-turn, the chat says so and continues by itself on another of OonaCode’s accounts, instead of just stopping.`]},{version:`0.3.343`,date:`2026-11-17`,platforms:[`darwin`],added:[`Hovering a model in the model picker now shows its effort levels — the ones the chat’s effort menu offers for it — with its default marked.`],fixed:[`A long chat on a Google model (Gemini 3.8 Flash, Gemini 4 Hydrogen, Argon, Carbon) no longer stops with “The socket connection was closed unexpectedly” when OonaCode’s server restarts or the connection drops mid-turn: the chat says so, waits for the server and continues the same task by itself, where it left off. Stop still ends it at once.`,`A model’s details in the picker no longer end with a paragraph of internal setup notes; everything about the model itself (ratings, effort, context, prices, capabilities) stays.`]},{version:`0.3.342`,date:`2026-11-17`,platforms:[`linux`],added:[`Hovering a model in the model picker now shows its effort levels — the ones the chat’s effort menu offers for it — with its default marked.`],fixed:[`A long chat on a Google model (Gemini 3.8 Flash, Gemini 4 Hydrogen, Argon, Carbon) no longer stops with “The socket connection was closed unexpectedly” when OonaCode’s server restarts or the connection drops mid-turn: the chat says so, waits for the server and continues the same task by itself, where it left off. Stop still ends it at once.`,`A model’s details in the picker no longer end with a paragraph of internal setup notes; everything about the model itself (ratings, effort, context, prices, capabilities) stays.`]},{version:`0.3.341`,date:`2026-11-17`,platforms:[`win32`],added:[],fixed:[`A long chat on a Google model (Gemini 3.8 Flash, Gemini 4 Hydrogen, Argon, Carbon) no longer stops with “The socket connection was closed unexpectedly” when OonaCode’s server restarts or the connection drops mid-turn: the chat says so, waits for the server and continues the same task by itself, where it left off. Stop still ends it at once.`]},{version:`0.3.340`,date:`2026-11-17`,platforms:[`win32`],added:[`Hovering a model in the model picker now shows its effort levels — the ones the chat’s effort menu offers for it — with its default marked.`],fixed:[`A model’s details in the picker no longer end with a paragraph of internal setup notes; everything about the model itself (ratings, effort, context, prices, capabilities) stays.`]},{version:`0.3.339`,date:`2026-11-16`,platforms:[`darwin`],added:[`OonaCode uses much less memory with many chats open: only the chat on screen — and up to three you looked at recently — keeps its whole history loaded; the other open tabs still show their status and finished marks, and load their history again when you open them. With a dozen long chats open this saves several hundred MB.`,`Settings → This PC → Memory: how long a quiet chat keeps its agent running, how many idle agents may stay, and when an unused Oonak Browser closes (after 30 minutes nobody used it, by default). Settings → Advanced: how many hidden chats stay in memory.`],fixed:[`GitHub Copilot chats no longer show empty lines. When Copilot’s model thinks privately it sends an encrypted thought with no words, and each one drew as a blank line; they are no longer drawn (they stay in the chat’s history, so Copilot still gets them back on the next turn).`,`Opening a chat while it is working shows its history above the running turn, not below it.`,`The account panel and oona no longer say the sign-up gift never expires — credits you buy never expire; the gift ends after its welcome period.`]},{version:`0.3.338`,date:`2026-11-16`,platforms:[`linux`],added:[`OonaCode uses much less memory with many chats open: only the chat on screen — and up to three you looked at recently — keeps its whole history loaded; the other open tabs still show their status and finished marks, and load their history again when you open them. With a dozen long chats open this saves several hundred MB.`,`Settings → This PC → Memory: how long a quiet chat keeps its agent running, how many idle agents may stay, and when an unused Oonak Browser closes (after 30 minutes nobody used it, by default). Settings → Advanced: how many hidden chats stay in memory.`],fixed:[`GitHub Copilot chats no longer show empty lines. When Copilot’s model thinks privately it sends an encrypted thought with no words, and each one drew as a blank line; they are no longer drawn (they stay in the chat’s history, so Copilot still gets them back on the next turn).`,`Opening a chat while it is working shows its history above the running turn, not below it.`,`The account panel and oona no longer say the sign-up gift never expires — credits you buy never expire; the gift ends after its welcome period.`]},{version:`0.3.337`,date:`2026-11-16`,platforms:[`win32`],added:[],fixed:[`GitHub Copilot chats no longer show empty lines. When Copilot’s model thinks privately it sends an encrypted thought with no words, and each one drew as a blank line; they are no longer drawn (they stay in the chat’s history, so Copilot still gets them back on the next turn).`]},{version:`0.3.336`,date:`2026-11-16`,platforms:[`win32`],added:[`OonaCode uses much less memory with many chats open: only the chat on screen — and up to three you looked at recently — keeps its whole history loaded; the other open tabs still show their status and finished marks, and load their history again when you open them. With a dozen long chats open this saves several hundred MB.`,`Settings → This PC → Memory: how long a quiet chat keeps its agent running, how many idle agents may stay, and when an unused Oonak Browser closes (after 30 minutes nobody used it, by default). Settings → Advanced: how many hidden chats stay in memory.`],fixed:[`Opening a chat while it is working shows its history above the running turn, not below it.`,`The account panel no longer says the sign-up gift never expires — credits you buy never expire; the gift ends after its welcome period.`]},{version:`0.3.335`,date:`2026-11-15`,platforms:[`darwin`],added:[`Auto-suggest: after each answer the message box shows a greyed guess at what you might say next; press Tab to take it, then edit or send it. Nothing is sent by itself. In OonaCode pool chats the guess comes from OonaCode’s small fast models and costs a few credits; on your own Claude-protocol key or plan the engine makes it on that plan. Turn it off in Settings → This PC → "Auto-suggest my next message".`,`The usage card of a linked provider names the account its figures belong to — "Account: you@example.com", the whole account on hover — even when only one is linked.`,`OonaCode repairs its own chat database when the disk returns read errors: it re-reads the damaged files onto fresh disk blocks, keeps the originals in a "host.damaged-…" folder, and says what happened and what (if anything) was lost. Before, the local service kept restarting and the app looked signed out. "oona db repair" runs the same repair by hand.`],fixed:[]},{version:`0.3.334`,date:`2026-11-15`,platforms:[`linux`],added:[`Auto-suggest: after each answer the message box shows a greyed guess at what you might say next; press Tab to take it, then edit or send it. Nothing is sent by itself. In OonaCode pool chats the guess comes from OonaCode’s small fast models and costs a few credits; on your own Claude-protocol key or plan the engine makes it on that plan. Turn it off in Settings → This PC → "Auto-suggest my next message".`,`The usage card of a linked provider names the account its figures belong to — "Account: you@example.com", the whole account on hover — even when only one is linked.`,`OonaCode repairs its own chat database when the disk returns read errors: it re-reads the damaged files onto fresh disk blocks, keeps the originals in a "host.damaged-…" folder, and says what happened and what (if anything) was lost. Before, the local service kept restarting and the app looked signed out. "oona db repair" runs the same repair by hand.`],fixed:[`"OonaCode Terminal" in the applications menu no longer opens a window that closes at once when the terminal app stops on an error — the error stays on screen until you press Enter.`]},{version:`0.3.333`,date:`2026-11-15`,platforms:[`win32`],added:[`Auto-suggest: after each answer the message box shows a greyed guess at what you might say next; press Tab to take it, then edit or send it. Nothing is sent by itself. In OonaCode pool chats the guess comes from OonaCode’s small fast models and costs a few credits; on your own Claude-protocol key or plan the engine makes it on that plan. Turn it off in Settings → This PC → "Auto-suggest my next message".`,`The usage card of a linked provider names the account its figures belong to — "Account: you@example.com", the whole account on hover — even when only one is linked.`,`OonaCode repairs its own chat database when the disk returns read errors: it re-reads the damaged files onto fresh disk blocks, keeps the originals in a "host.damaged-…" folder, and says what happened and what (if anything) was lost. Before, the local service kept restarting and the app looked signed out. "oona db repair" runs the same repair by hand.`],fixed:[`A command a Google (agy) chat runs over ssh is no longer ended in the middle of a long, quiet remote job (a big download, a build) once it has printed output; one whose ssh has printed nothing at all is now ended after 10 minutes with a note, instead of the chat waiting half an hour.`,`Linux: "OonaCode Terminal" in the applications menu no longer opens a window that closes at once when the terminal app stops on an error — the error stays on screen until you press Enter.`]},{version:`0.3.332`,date:`2026-11-15`,added:[`The OonaCode pool’s Google models are back — Gemini 3.8 Flash, Gemini 4 Argon and Gemini 4 Hydrogen — running on Google’s own agy on OonaCode’s server: your message goes to agy, and every file, command and Oonak Browser step it takes runs on your PC, under the chat’s Build, Ask first or Autonomous setting. A command that runs for minutes keeps going, and the chat says when it is done.`],fixed:[]},{version:`0.3.331`,date:`2026-11-14`,added:[`The message box shows math as math: LaTeX you type between \\( \\), \\[ \\], $ … $ or $$ … $$, and formulas you paste from a web page or another chat, turn into rendered formulas — the message still goes out as plain Markdown with LaTeX. Copying part of a chat that holds formulas copies them as LaTeX.`],fixed:[`Google Gemini now runs only through Google’s own agy on your PC, signed in to your own Google account (Settings → Providers → Google): the OonaCode pool no longer lists Gemini models, and background tasks no longer fall back to one.`]},{version:`0.3.330`,date:`2026-11-14`,added:[`Several accounts of one subscription: link a second SuperGrok, ChatGPT (Codex), GitHub Copilot, Meta or Google account beside the first with "Add another account" (Google: "Add another Google account" on its card). The model picker then lists the provider once per account, named with the account’s email — hover it for the whole account — and a chat stays on the account it started on. New chats use the account you linked last.`,`Each linked account has "Sign in again", which renews only that account, and Remove.`],fixed:[`A new sign-in no longer replaces a different account you had linked: only a sign-in of the same account replaces it.`,`A chat moved to another account of Google Gemini (your plan) starts a fresh conversation on that account, handed the chat so far — each Google account keeps its own sign-in and its own conversations on this PC.`,`Your own SuperGrok, ChatGPT, GitHub Copilot and Meta sign-ins present the current versions of their own apps (Grok CLI 1.0.77, Codex 0.169.0, Copilot CLI 1.0.109, Muse Code 1.4.20), and "Sign in with Meta" installs Muse Code 1.4.20 (about 505 MB).`,`o4-mini is no longer offered for an OpenAI key: OpenAI shut it down on 2026-10-23, so every message to it failed.`]},{version:`0.3.329`,date:`2026-11-14`,added:[`A chat on Google Gemini (your plan) now has every OonaCode tool the other models have, each while its switch in the Tools menu is on: Oonak Browser and the other tool packs, chats talking to each other, scheduling, "move this task to a new chat", chats on your other PCs, action buttons — beside the pictures, video, speech and folder tools it already had. Before, the Tools menu showed switches for these in a Gemini chat that did nothing.`],fixed:[`A project that switched scheduling off now also keeps its Gemini chats from scheduling.`,`OonaCode now keeps Google’s agy up to date as far as 1.5.8, which it has been checked against: the usage numbers, the model list, the chat protocol and OonaCode’s own tools.`]},{version:`0.3.328`,date:`2026-11-14`,platforms:[`darwin`],added:[],fixed:[`This macOS release brings everything in 0.3.326 and 0.3.327, listed below: Google Gemini (your plan) on Google’s own agy again, long chats with many pictures no longer stuck on "Request body is too large", and no Test button in the connect dialog.`]},{version:`0.3.327`,date:`2026-11-14`,added:[],fixed:[`Google Gemini (your plan) runs on Google’s own agy again, as it did before 0.3.324: OonaCode installs agy for you and every Google chat goes through it — OonaCode no longer sends Google requests of its own. If you signed in with Google on 0.3.324–0.3.326, sign in once more in agy (OonaCode shows you how) on each PC.`,`The connect dialog no longer has a Test button: it sent some subscriptions a request their own app never sends.`,`When a key you paste is refused, the message names the provider that refused it instead of always saying "Anthropic", and never shows a web page’s code.`]},{version:`0.3.326`,date:`2026-11-14`,added:[],fixed:[`A long chat with many pictures — screenshots, images a tool brought back — no longer stops for good with "Request body is too large". When a request grows past what the provider accepts, OonaCode now replaces the oldest pictures with a short note and keeps the newest, so the chat and /compact go on. A chat that is already stuck continues after the update.`]},{version:`0.3.325`,date:`2026-11-13`,added:[],fixed:[`A Google chat now names its model plainly (Gemini 3.8 Flash) instead of Google’s internal template (gemini-3.8-flash-{effort:high}); chats started on 0.3.324 put themselves right on their next message.`,`A Google chat in Plan mode now shows Plan in its picker, like every other chat, instead of reading Build while it plans.`,`Right after an update, Google chats use the new Google sign-in at once — no waiting for OonaCode to refresh its provider list first.`,`The app no longer carries the old agy engine at all (about 20,000 lines lighter).`]},{version:`0.3.324`,date:`2026-11-13`,added:[`Your own Google Antigravity plan now runs on OonaCode itself — no agy to install or update. Sign in once with your Google account (open the link, paste the code Google shows) and Gemini 3.8 Flash, Gemini 4 Argon, Carbon and Hydrogen and Claude Opus and Sonnet 5.5 via Google work like every other model: every tool and skill, Plan and Ask first, pictures, and your plan’s usage in the model picker.`],fixed:[`Google chats are no longer limited to Build and Autonomous and no longer lose the chat tools: they run on the same agent as every other chat. Your earlier Google chats keep their history and continue after the new sign-in.`]},{version:`0.3.323`,date:`2026-11-13`,added:[],fixed:[`On your own Google Gemini (agy) plan, a recovered safety-filter or malformed-tool-call retry (“Retries remaining: 3”) no longer fails a turn that already answered cleanly, and no longer repeats on every later message in that chat (even after switching models).`,`The Images (generate_image) tool, image model selector, and Ask-first toggle are now offered in local Google Gemini (agy) chats too, instead of disappearing from the chat Tools list when a Google model is selected.`]},{version:`0.3.322`,date:`2026-11-13`,added:[`Scheduled recurring tasks can now repeat as often as every minute: the default interval floor for unassigned chats is lowered from 15 minutes down to 1 minute, allowing fast periodic automations without requiring a custom project setting.`],fixed:[]},{version:`0.3.321`,date:`2026-11-13`,added:[`Claude Fable 5.2 (claude-fable-5-2) is here, in the OonaCode pool and on your linked Claude subscription: Anthropic’s newest frontier technical reasoning and coding model, with a 1M-token context window and up to 128K output tokens, priced 20% lower than Fable 5.1.`],fixed:[]},{version:`0.3.320`,date:`2026-11-13`,added:[`Gemini 4 Hydrogen is here, on your own Google Gemini (agy) plan and in the OonaCode pool: a 1M-token context window, up to 262K output tokens and four reasoning levels — Low, Medium, High and the new XHigh — chosen with the effort picker.`],fixed:[`Gemini 4 Carbon is no longer offered in the model list of a Google account that cannot use it.`]},{version:`0.3.319`,date:`2026-11-12`,platforms:[`linux`],added:[`Math in a chat now looks like math. When a model writes a formula with dollar signs or \\( … \\) — Euler’s identity, an integral, a fraction — it is drawn as a proper equation, in its own block when it stands alone and inline inside a sentence. Prices (“$5 and $10”), shell variables and code are never read as formulas.`,`Superscripts and subscripts that models write as <sup> and <sub> (x², H₂O) are drawn as such, and <br> is a line break. No other HTML is drawn.`],fixed:[`Answers from Muse, Gemini and other models no longer show raw “$$ … $$”, “$e$” or “<sup>” text in the chat.`]},{version:`0.3.318`,date:`2026-11-12`,platforms:[`darwin`],added:[`Math in a chat now looks like math. When a model writes a formula with dollar signs or \\( … \\) — Euler’s identity, an integral, a fraction — it is drawn as a proper equation, in its own block when it stands alone and inline inside a sentence. Prices (“$5 and $10”), shell variables and code are never read as formulas.`,`Superscripts and subscripts that models write as <sup> and <sub> (x², H₂O) are drawn as such, and <br> is a line break. No other HTML is drawn.`],fixed:[`Answers from Muse, Gemini and other models no longer show raw “$$ … $$”, “$e$” or “<sup>” text in the chat.`]},{version:`0.3.317`,date:`2026-11-12`,platforms:[`win32`],added:[`Math in a chat now looks like math. When a model writes a formula with dollar signs or \\( … \\) — Euler’s identity, an integral, a fraction — it is drawn as a proper equation, in its own block when it stands alone and inline inside a sentence. On the Android app it shows as readable text, such as “e^(iπ) + 1 = 0”. Prices (“$5 and $10”), shell variables and code are never read as formulas.`,`Superscripts and subscripts that models write as <sup> and <sub> (x², H₂O) are drawn as such, and <br> is a line break. No other HTML is drawn.`],fixed:[`Answers from Muse, Gemini and other models no longer show raw “$$ … $$”, “$e$” or “<sup>” text in the chat.`]},{version:`0.3.316`,date:`2026-11-11`,platforms:[`win32`],added:[`“Clean up chat folders” now says what each folder is. A folder with no chat in OonaCode’s database is marked as left over and safe to delete, with its dates, size, files and full path. Chats you still have that moved to another folder are listed by name with the folder they work in now and the old one they left behind; you can delete those too, after a clear warning (they are never ticked for you).`],fixed:[`Updating from the app runs one update at a time, however often “Update now” is pressed and in however many windows: a second press waits for the update that is already running instead of starting another. Every window shows the same running update, and none offers an Update button until it ends.`]},{version:`0.3.316`,date:`2026-11-11`,platforms:[`linux`],added:[`In a chat on Google Gemini (agy), the assistant can now move the chat to a folder you name: it asks you to confirm, and the move happens when its turn ends. Before, it had no way to do this and tried shell commands that changed nothing, then said the workspace was set.`,`“Clean up chat folders” now says what each folder is. A folder with no chat in OonaCode’s database is marked as left over and safe to delete, with its dates, size, files and full path. Chats you still have that moved to another folder are listed by name with the folder they work in now and the old one they left behind; you can delete those too, after a clear warning (they are never ticked for you).`],fixed:[`Updating from the app runs one update at a time, however often “Update now” is pressed and in however many windows: a second press waits for the update that is already running instead of starting another. Every window shows the same running update, and none offers an Update button until it ends.`,`Only one OonaCode update installer runs at a time, also when you run oona update in Terminal while the app is updating: the second one says an update is already running and changes nothing.`]},{version:`0.3.315`,date:`2026-11-11`,platforms:[`darwin`],added:[`In a chat on Google Gemini (agy), the assistant can now move the chat to a folder you name: it asks you to confirm, and the move happens when its turn ends. Before, it had no way to do this and tried shell commands that changed nothing, then said the workspace was set.`,`“Clean up chat folders” now says what each folder is. A folder with no chat in OonaCode’s database is marked as left over and safe to delete, with its dates, size, files and full path. Chats you still have that moved to another folder are listed by name with the folder they work in now and the old one they left behind; you can delete those too, after a clear warning (they are never ticked for you).`],fixed:[`Pressing “Update now” again no longer starts a second update. The window keeps saying that OonaCode is updating, with no Update button, until the app closes and reopens by itself on the new version; if the update fails, it says why and the button comes back. Before, every press started another installer and another dialog (five at once on one Mac) while the first was still downloading.`,`Only one OonaCode update runs at a time, also when you run oona update in Terminal while the app is updating: the second one says an update is already running and changes nothing.`]},{version:`0.3.314`,date:`2026-11-11`,platforms:[`win32`],added:[`In a chat on Google Gemini (agy), the assistant can now move the chat to a folder you name: it asks you to confirm, and the move happens when its turn ends. Before, it had no way to do this and tried shell commands that changed nothing, then said the workspace was set.`],fixed:[]},{version:`0.3.313`,date:`2026-11-11`,platforms:[`linux`],added:[],fixed:[`On your own Meta Muse key or sign-in, every request now carries Muse Code’s contributor-mode marker on every model, the way Muse Code itself sends it: “on” for a -contributor model and “off” for any other, Ember included. Before, a standard model went out without it.`]},{version:`0.3.312`,date:`2026-11-11`,platforms:[`darwin`],added:[],fixed:[`On your own Meta Muse key or sign-in, every request now carries Muse Code’s contributor-mode marker on every model, the way Muse Code itself sends it: “on” for a -contributor model and “off” for any other, Ember included. Before, a standard model went out without it.`]},{version:`0.3.311`,date:`2026-11-11`,platforms:[`win32`],added:[],fixed:[`On your own Meta Muse key or sign-in, every request now carries Muse Code’s contributor-mode marker on every model, the way Muse Code itself sends it: “on” for a -contributor model and “off” for any other, Ember included. Before, a standard model went out without it.`]},{version:`0.3.310`,date:`2026-11-11`,platforms:[`linux`],added:[`Gemini 4 Carbon is available in the OonaCode pool and on your own Google Gemini (agy) plan, with Low, Medium and High effort and a 1M-token context window.`,`Muse Ember 1.0 is available on your own Meta Muse plan, with a 1M-token context window, up to 512K output tokens and reasoning-effort controls. Ember has no Contributor variant and is not part of the OonaCode pool.`],fixed:[`Messages you send while the assistant is working now clear from the Queued strip one by one as the assistant reads them, also when it reads several together. Two identical messages no longer clear as one, and a message no longer clears because a longer text happens to contain its words.`,`A very long chat that no longer fits the model does not write “earlier messages left out” every time it wakes up, and its assistant now stays ready for about an hour instead of ten minutes, so your next message starts faster.`,`On your own Google Gemini (agy) plan, a real “stream idle timeout” is shown at once instead of being retried for many minutes; the stale copy of that error after a clean answer stays hidden, and agy is updated to 1.5.5.`,`The effort picker shows the default effort the assistant really starts with, on every provider.`]},{version:`0.3.309`,date:`2026-11-11`,platforms:[`darwin`],added:[`OonaCode for Mac lists what 0.3.305 and 0.3.306 brought without notes: Gemini 4 Carbon in the OonaCode pool and on your own Google Gemini (agy) plan, with Low, Medium and High effort and a 1M-token context window, and agy 1.5.5.`],fixed:[`Messages you send while the assistant is working now clear from the Queued strip one by one as the assistant reads them, also when it reads several together. Two identical messages no longer clear as one, and a message no longer clears because a longer text happens to contain its words.`,`A very long chat that no longer fits the model does not write “earlier messages left out” every time it wakes up, and its assistant now stays ready for about an hour instead of ten minutes, so your next message starts faster.`,`On your own Google Gemini (agy) plan, a real “stream idle timeout” is shown at once instead of being retried for many minutes; the stale copy of that error after a clean answer stays hidden.`,`The effort picker shows the default effort the assistant really starts with, on every provider.`,`OonaCode starts normally on a Mac whose keychain list another tool has damaged: it now looks for your keys in your login keychain directly, and if it ever cannot open your chats because of that list, the message says how to repair it.`]},{version:`0.3.308`,date:`2026-11-11`,platforms:[`win32`],added:[],fixed:[`Messages you send while the assistant is working now clear from the Queued strip one by one as the assistant reads them, also when it reads several together. Two identical messages no longer clear as one, and a message no longer clears because a longer text happens to contain its words.`,`A very long chat that no longer fits the model does not write “earlier messages left out” every time it wakes up, and its assistant now stays ready for about an hour instead of ten minutes, so your next message starts faster.`,`On your own Google Gemini (agy) plan, a real “stream idle timeout” is shown at once instead of being retried for many minutes; the stale copy of that error after a clean answer stays hidden.`,`The effort picker shows the default effort the assistant really starts with, on every provider.`]},{version:`0.3.307`,date:`2026-11-11`,platforms:[`win32`,`darwin`],added:[`Muse Ember 1.0 is available on your own Meta Muse plan, with a 1M-token context window, up to 512K output tokens and reasoning-effort controls. Ember has no Contributor variant and is not part of the OonaCode pool.`],fixed:[]},{version:`0.3.306`,date:`2026-11-11`,platforms:[`win32`],added:[],fixed:[`Messages sent while the assistant is working now clear from the Queued strip as soon as the assistant reads them (including when multiple queued messages are absorbed together in one step or after a reconnect), and reopening a chat keeps every mid-turn message in place.`,`Chats on your own Google Gemini (agy) plan no longer show a stale “stream idle timeout: context deadline exceeded” error at the end of clean turns, and agy is updated to 1.5.5.`,`Long reasoning turns on slow models (Gemini 4 Carbon above all) keep their connection alive with periodic stream heartbeats so reverse proxies do not drop the stream while the model thinks.`]},{version:`0.3.305`,date:`2026-11-10`,platforms:[`win32`],added:[`Gemini 4 Carbon is now available in the OonaCode pool and on your own Google Gemini (agy) plan, with Low, Medium, and High reasoning-effort options (1M context window, 256K output tokens).`],fixed:[`The reasoning-effort picker now shows the exact supported effort levels and default effort for every model across pool and direct providers.`]},{version:`0.3.304`,date:`2026-11-09`,platforms:[`win32`],added:[`Clean up chat folders (File menu, and a button in the sidebar): lists the folders left behind by chats you deleted, shows how much space they take and removes the ones you tick. Folders with nothing of yours in them are ticked for you; a folder that holds files is left for you to choose. Folders of chats you still have, and folders changed in the last day, are never offered.`],fixed:[`A chat that started in its own folder and was then moved to another one no longer loses track of its first files: a file the assistant names without a path is also looked for in the chat’s first folder, so it stops reading “moved or deleted”.`,`Deleting a chat now removes its folder even when the only thing in it was the assistant’s “always allow” memory; those folders used to pile up for ever.`]},{version:`0.3.304`,date:`2026-11-09`,platforms:[`linux`,`darwin`],added:[`GitHub Copilot: link your own Copilot plan (Free, Pro and above) under Providers → GitHub Copilot Subscription with Sign in with GitHub. Pick Copilot Auto in the model picker and GitHub chooses the model your plan allows. Point at the provider to see your AI credits and when they reset. The sign-in lets OonaCode read only your GitHub profile, nothing about your repositories, and your sign-in stays on your PC.`,`Clean up chat folders (File menu, and a button in the sidebar): lists the folders left behind by chats you deleted, shows how much space they take and removes the ones you tick. Folders with nothing of yours in them are ticked for you; a folder that holds files is left for you to choose. Folders of chats you still have, and folders changed in the last day, are never offered.`],fixed:[`A chat that started in its own folder and was then moved to another one no longer loses track of its first files: a file the assistant names without a path is also looked for in the chat’s first folder, so it stops reading “moved or deleted”.`,`Deleting a chat now removes its folder even when the only thing in it was the assistant’s “always allow” memory; those folders used to pile up for ever.`]},{version:`0.3.303`,date:`2026-11-07`,platforms:[`win32`],added:[`GitHub Copilot: link your own Copilot plan (Free, Pro and above) under Providers → GitHub Copilot Subscription with Sign in with GitHub. Pick Copilot Auto in the model picker and GitHub chooses the model your plan allows. Point at the provider to see your AI credits and when they reset. The sign-in lets OonaCode read only your GitHub profile, nothing about your repositories, and your sign-in stays on your PC.`],fixed:[]},{version:`0.3.302`,date:`2026-11-06`,added:[`Action buttons have their own switch in the chat’s Tools menu. Turn it off and the assistant stops offering buttons; the buttons a chat already has stay and still run.`,`Connect an AI tool: every connected tool has a Details button (instead of a card that opened when you pointed at it), Reveal key shows a connection’s key again after your password so you can share it without making a new one, and connections that have ended can be deleted, one by one or all at once.`],fixed:[`The assistant can no longer start Oonak Browser by hand even in Bypass permissions mode; it uses the chat’s one browser.`,`Signing in to a connector could fail on some PCs because the browser refused the local address the sign-in came back to; OonaCode now always picks one the browser accepts.`]},{version:`0.3.301`,date:`2026-11-05`,platforms:[`darwin`],added:[`OonaCode for Mac is up to date again: this build carries everything the Windows and Linux versions have had since 0.3.294 — action buttons at the top right of a chat, Ctrl + scroll (or Command + scroll) to change the text size of the chat or the sidebar, the Connect an AI tool activity list, and the changes listed under the versions above.`],fixed:[]},{version:`0.3.300`,date:`2026-11-05`,added:[`Action buttons: when you ask for the same job twice, the assistant offers to turn it into a button at the top right of the chat. A button can run a ready command on your PC at once, or send a job to the assistant, which does it in a subagent and prints the report in the chat. Point at a button to read what it does, right-click it to Run or Delete it, and ask the assistant to change it.`,`Ctrl + scroll over the chat or over the sidebar makes that text bigger or smaller (Command + scroll on a Mac) — the same size you set in Settings → Theme → Fonts.`,`Connect an AI tool: every connected tool now shows the chats it can read, its own key, and an Activity list of who used it and when. The list updates while the window is open, and Share shows how to connect the tool and makes a new key for it when you need the command again.`,`Deleting or forking a chat now shows a message window until it has finished.`],fixed:[`Session Info no longer lists made-up “browser sessions” picked up from text in the chat, and the assistant no longer starts Oonak Browser by hand and piles up windows — it uses the chat’s one browser.`]},{version:`0.3.299`,date:`2026-11-04`,added:[`Gemini (agy) chats can now make video and speak: OonaCode’s video and text-to-speech tools reach Google’s agy as a built-in tool server, and the chat’s Tools menu lists Video and Speech like any other chat. (Pictures there still use agy’s own picture tool.)`],fixed:[`Meta Muse in the OonaCode pool now sends exactly the headers and request fields the real Muse program sends, so Meta sees the same client your own Muse would be.`]},{version:`0.3.298`,date:`2026-11-04`,added:[`Pictures from the plan you already pay for: GPT Image 2, 2.5 Flare and 2.5 Sunburst now draw from a ChatGPT plan, and Muse Image 1.0 from a Muse plan. Picking GPT Image on a ChatGPT plan used to end in an error, because only an OpenAI API key could make it.`,`Tools → speech models: every speech model your chat can reach is on the list, not only the one set for the chat’s model.`,`GPT-6.1 Terra is in the ChatGPT plan’s models, and Muse Spark 1.3 contributor can think at Max.`,`Google’s agy is updated to 1.5.0 and Muse to 1.4.14.`],fixed:[`A Gemini (agy) chat that makes a picture with agy’s own tool no longer shows that step as an error (“The turn ended before this finished”).`,`Gemini 3.8 Flash in a pooled chat thinks at the level you pick, the same way Google’s agy asks for it.`]},{version:`0.3.297`,date:`2026-11-02`,added:[`Fork asks for the copy’s name first, filled in with “<chat name> fork”.`],fixed:[`Deleting or forking a long chat: the chat shows “Deleting…” or “Forking…” and takes no other click until it is done — no more second delete because the first was still working. The open chat is covered while it happens.`,`A long wait in a Gemini (agy) chat — an ssh waiting for a render on your server — is no longer ended after 15 minutes. OonaCode now ends only a command that has neither worked nor sent or received anything for 30 minutes, and the agent keeps remote connections alive.`,`While a command or tool runs, the line under the chat says what is running and for how long, instead of “nothing from the agent — it may be stuck”.`,`A large video downloads however long it takes, as long as data keeps coming; it used to be cut off after 10 minutes and thrown away.`,`Slow pictures (high quality, sets of 12) get almost 5 minutes instead of 2.`]},{version:`0.3.296`,date:`2026-11-02`,added:[`Tools → picture, video and speech models: point at a model in the list (or walk the list with the arrow keys) and a card beside it says everything it can do — what it makes and from what (a first or last frame, reference pictures, editing or extending a clip, a song to follow), how long and how big, sound, prompt options, the rules for combining inputs, and the price. Speech models show their voices, speed, languages and how-to-speak instructions.`],fixed:[]},{version:`0.3.295`,date:`2026-11-02`,added:[`VS Code: the OonaCode panel is now the whole app — the session list, search and files on the left, the same title bar — so you can see and switch your chats without leaving the editor.`,`VS Code: the extension keeps itself up to date. It checks for a new version at start and every few hours, verifies the download, and installs it; “OonaCode: Check for Updates” asks right away.`],fixed:[`VS Code: the panel no longer drops to “Health probe timed out” and reloads while OonaCode is busy opening a long chat — the reload loop that ended in a crash.`,`“Send now” on a step that was taking long no longer marks the turn as “error during execution”; it ends as stopped, as Stop does.`,`A turn that failed before the model said anything no longer shows millions of tokens in its footer.`,`A video the provider refused part-way (moderated) is now closed at once, instead of holding one of your two video slots and its credits for a day — which made other chats wait out a “rate limit”. When the slots are full, the chat now says so instead of blaming the provider.`,`A model OonaCode cannot serve right now reads “model unavailable”, not “sign-in needed” — your sign-in was fine.`,`Ordinary commands such as echo or curl are no longer refused as “tool misuse”, and their turns are no longer removed from the chat.`,`A browser you restore from Session info stays open while you use it, and only this chat’s own profiles can be restored.`,`Tool cards no longer open by themselves for every file name in their output, and a generated picture is not shown three times.`,`Deleting saved prompts quickly no longer brings one back; Enter on a row’s Send or X button does that button.`,`Doctor’s database check no longer freezes OonaCode for a minute on a large chat history.`]},{version:`0.3.294`,date:`2026-11-02`,platforms:[`darwin`],added:[`Save to send later is now a compact table: every prompt fits on one line with a short preview, Send puts it in the message box, and double-click opens the full prompt in a separate editor. Sending a picked prompt removes it even after editing; clearing the message box keeps it saved.`],fixed:[`Tool results that name a local picture, video or sound now show the same preview and Play controls as ordinary chat text, and the result card opens automatically. This includes Generate image results that only name the saved file.`]},{version:`0.3.293`,date:`2026-11-02`,platforms:[`win32`],added:[`Save to send later is now a compact table: every prompt fits on one line with a short preview, Send puts it in the message box, and double-click opens the full prompt in a separate editor. Sending a picked prompt removes it even after editing; clearing the message box keeps it saved.`],fixed:[`Tool results that name a local picture, video or sound now show the same preview and Play controls as ordinary chat text, and the result card opens automatically. This includes Generate image results that only name the saved file.`]},{version:`0.3.292`,date:`2026-11-01`,platforms:[`darwin`],added:[],fixed:[`Save to send later: deleting a saved prompt with ✕ (or when sending a picked saved prompt) no longer fails with "The saved prompt could not be deleted."`,`When a model tries to run an MCP tool or dummy echo command inside Bash instead of calling the tool itself (such as Oonak Browser or web search after a long run of shell commands), OonaCode now stops the call at once, returns a short hint with the active tools and their input format, cleans earlier no-op echo loops from the request, and switches the retry onto the right tool.`]},{version:`0.3.291`,date:`2026-11-01`,platforms:[`win32`],added:[],fixed:[`Save to send later: deleting a saved prompt with ✕ (or when sending a picked saved prompt) no longer fails with "The saved prompt could not be deleted."`]},{version:`0.3.290`,date:`2026-11-01`,platforms:[`win32`],added:[],fixed:[`When a model tries to run an MCP tool or dummy echo command inside Bash instead of calling the tool itself (such as Oonak Browser or web search after a long run of shell commands), OonaCode now stops the call at once, returns a short hint with the active tools and their input format, cleans earlier no-op echo loops from the request, and switches the retry onto the right tool.`]},{version:`0.3.289`,date:`2026-11-01`,platforms:[`darwin`],added:[`Session Info lists every Oonak Browser profile (user-data-dir) the model used in that chat, with a Restore browser button that opens Oonak Browser on that profile and reopens its saved tabs.`],fixed:[]},{version:`0.3.288`,date:`2026-11-01`,platforms:[`win32`],added:[`Session Info lists every Oonak Browser profile (user-data-dir) the model used in that chat, with a Restore browser button that opens Oonak Browser on that profile and reopens its saved tabs.`],fixed:[]},{version:`0.3.287`,date:`2026-10-31`,platforms:[`darwin`],added:[`On a Mac, the terminal can choose the picture, video and speech model for a chat: oona --image-model, --video-model and --audio-model, also when you continue a chat with -c or -r. Leave a flag out and that kind stays on the default.`,`Save to send later: each saved message has an ✕, so you can delete it from the list without sending it.`],fixed:[]},{version:`0.3.286`,date:`2026-10-31`,platforms:[`win32`],added:[`The terminal can choose the picture, video and speech model for a chat: oona --image-model, --video-model and --audio-model, also when you continue a chat with -c or -r. Leave a flag out and that kind stays on the default.`],fixed:[]},{version:`0.3.285`,date:`2026-10-31`,platforms:[`win32`],added:[`Save to send later: each saved message has an ✕, so you can delete it from the list without sending it.`],fixed:[]},{version:`0.3.284`,date:`2026-10-30`,added:[`Your chats on this PC are now encrypted, so no other program and no copy of the file can read them. It happens by itself, once, on the first start of this version — about a minute for every 3 GB of history, with the progress on the start screen. If the app closes meanwhile, nothing is lost: it starts over next time.`,`The key is held by Windows (or your Mac’s keychain or Linux keyring) for your user account, with a copy in your vault. If your PC ever loses it, oona db recover-key brings it back.`,`Once your chats are encrypted, the old history files in Documents\\OonaCode-backups are moved into the encrypted database and the plain files are deleted.`,`Encryption protects the file at rest. Programs running as you while OonaCode is open can still reach what you can, as with any app.`],fixed:[]},{version:`0.3.283`,date:`2026-10-30`,added:[`File → Connect an AI tool…: let Claude Code or another AI tool read your chats on this PC — all of them, chosen ones or one project, for an hour, a day or until you revoke it. Read-only, and the tool never gets your password or vault key. Every read is listed, and one click ends it.`,`Videos: Wan 3.0 animates a photo to a song (a reference picture plus reference audio), takes a document or a web page as a brief, reference clips with pictures, and prompts up to 20,000 characters. Wan 2.7, Wan 2.6, HappyHorse and Grok Imagine gained the options their makers offer that were missing here.`,`Pictures: each model now offers everything its maker does — for example a transparent background, JPEG or WebP and masked edits on GPT Image, image sets on Wan 2.7, and a thinking mode on Qwen-Image 3.0. One call can make several pictures, and chats can use every picture and video model the service runs.`,`This version can open an encrypted chat database. The next update encrypts the chats on this PC by itself, once, with the progress on the start screen.`,`oona db recover-key brings this PC’s chat-database key back from your vault, if Windows or your keyring ever loses it.`],fixed:[`A negative prompt on Wan video models is now actually applied (it was sent where the provider never reads it).`,`Pictures from Qwen, Wan and Grok Imagine models are saved in the chat again; they used to fail to save.`,`A sound clip longer than 15 seconds for Wan 3.0 now says how long it is, instead of a wrong “goes without a picture” error.`,`Very long chats keep their older history inside OonaCode’s database, not as plain text files in Documents\\OonaCode-backups. The files earlier versions wrote there are moved back in once the database is encrypted.`]},{version:`0.3.282`,date:`2026-10-30`,added:[`Allow Telegram to reach this PC (Settings → This PC): the OonaCode bot can list, open and answer this PC’s chats only while it is on. It starts off — turn it on for each PC you want to use from Telegram.`,`The desktop app, the VS Code panel and a browser window each remember their own open chats, saved the moment they change. One of them can no longer close the chats another had open.`,`The groundwork for encrypting the chats stored on your PC: OonaCode now uses a database engine that can encrypt them. Nothing is encrypted yet — that comes in a later update, by itself.`],fixed:[`Chats an earlier update closed come back on the first start of this one, wherever the window still had its own copy of them (the desktop app usually does).`,`The Windows install command no longer waits for ever on a download that has stopped moving; it tries again.`]},{version:`0.3.281`,date:`2026-10-30`,added:[],fixed:[`Stop now really stops the answer: the model’s provider is told to stop too, so nobody pays for output that is no longer read — on your own key and on the OonaCode pool.`,`The message box no longer loses the keyboard to a video or sound player in the chat while you type.`,`A firewall, proxy or Cloudflare page answering in place of OonaCode no longer signs your PC out.`,`Two open tabs of the website no longer sign each other out.`,`Deleting a chat that still had messages waiting to send no longer brings the chat back.`,`Credits are no longer kept on hold when a request fails on our side before it reaches the model.`,`A long chat on a model whose context size is unknown now says when its oldest part was left out on resume, instead of dropping it silently.`,`A crafted link can no longer point your local OonaCode window at another server.`,`Opening a file from a chat refuses more kinds of programs (help files, add-ins and others).`]},{version:`0.3.280`,date:`2026-10-29`,added:[],fixed:[`Google agy chats now retry temporary INVALID_ARGUMENT failures and no longer report an old failure again after a later reply succeeds.`,`Hosted agents keep the model explicitly requested instead of silently substituting the pool default when that model is absent from the public list.`]},{version:`0.3.279`,date:`2026-10-29`,platforms:[`darwin`],added:[`HappyHorse 1.1 is in the video model list: text-to-video, image-to-video and reference-to-video (up to 9 pictures), 3–15 seconds at up to 1080P. Pick it for a chat under Tools → Video model.`,`Asking the video tool what it accepts now lists every video model the chat can use — each with its own inputs (Grok Imagine 1.5’s preset voices included) — and marks the one this chat uses, so you can see what switching models would give you.`,`Save to send later: the clock button to the right of Send keeps the message you typed in this chat instead of sending it. The badge on the button counts what is saved; with an empty message box, the button opens the list (oldest first) — pick one to put it back in the box, edit it if you like, and sending it takes it off the list.`,`The video tool now offers everything the video model you picked actually takes — not just a description and a first picture. Wan 3.0 can be handed a clip to edit and reference clips and sounds, Grok Imagine 1.5 takes preset voices for the speakers and pictures pinned inside the clip, and models that accept a last frame, a “what must not appear” note, a seed or a watermark offer those too.`],fixed:[`Files a reply names — a plan, a report, any plain file, not just pictures, clips and sounds — now appear in the chat’s Media panel under Files.`,`Ctrl+F opens the chat’s find bar on Armenian, Farsi and other non-Latin keyboard layouts too.`,`A clip or a sound in the chat no longer starts playing by itself when you send a new message.`]},{version:`0.3.278`,date:`2026-10-29`,added:[`HappyHorse 1.1 is in the video model list: text-to-video, image-to-video and reference-to-video (up to 9 pictures), 3–15 seconds at up to 1080P. Pick it for a chat under Tools → Video model.`,`Asking the video tool what it accepts now lists every video model the chat can use — each with its own inputs (Grok Imagine 1.5’s preset voices included) — and marks the one this chat uses, so you can see what switching models would give you.`],fixed:[`The “save to send later” clock now sits to the right of the Send/Queue button.`]},{version:`0.3.277`,date:`2026-10-29`,added:[`Save to send later: the clock button beside Send keeps the message you typed in this chat instead of sending it. The badge on the button counts what is saved; with an empty message box, the button opens the list (oldest first) — pick one to put it back in the box, edit it if you like, and sending it takes it off the list.`,`The video tool now offers everything the video model you picked actually takes — not just a description and a first picture. Wan 3.0 can be handed a clip to edit and reference clips and sounds, Grok Imagine 1.5 takes preset voices for the speakers and pictures pinned inside the clip, and models that accept a last frame, a “what must not appear” note, a seed or a watermark offer those too. Ask the chat what its video model accepts, or just describe what you want: it checks against the model and says what does not fit.`],fixed:[`Files a reply names — a plan, a report, any plain file, not just pictures, clips and sounds — now appear in the chat’s Media panel under Files. Before, a file like a Markdown plan printed in the chat was missing there.`,`Ctrl+F opens the chat’s find bar on Armenian, Farsi and other non-Latin keyboard layouts too. Before it only worked when the layout typed a Latin “f”, so on those layouts nothing happened.`,`A clip or a sound in the chat no longer starts playing by itself when you send a new message.`]},{version:`0.3.276`,date:`2026-10-27`,added:[`Kimi now accepts a Kimi Code subscription key (the sk-kimi… key from the Kimi Code console) as well as a Moonshot API key. With a Kimi Code key, resting the pointer on the model box shows how much of your 5-hour and monthly allowance is used and when each resets.`],fixed:[`A chat on Google’s agy can now use the GitHub account you linked: git and gh are signed in there too. Before, agy chats had no GitHub access at all, because agy keeps to its own private home.`,`When GitHub answers “not found” for a repository of an organization that has not approved OonaCode (the organization’s owner approves “OonaCode Git” in its OAuth app settings), the chat now says that instead of concluding the repository does not exist.`]},{version:`0.3.275`,date:`2026-10-27`,added:[`Kimi (Moonshot) is back as a provider you connect with your own Moonshot API key: Kimi K3, K3.1 Pro, K2.7 Code and K2.6. Your PC talks to Moonshot directly — nothing goes through OonaCode’s servers. (The Kimi Code subscription is a different service and is not included.)`],fixed:[`The app keeps up with the provider and model list from OonaCode’s server again. After the server added a provider for Google’s voices, builds before this one could not read the new list and quietly kept the old one, so new models and providers did not appear until the next update.`,`A chat that was set to Gemini is told that the provider was removed and asked to pick another, instead of failing with “unknown provider”. Gemini itself was never available to use.`]},{version:`0.3.274`,date:`2026-10-27`,added:[],fixed:[`A big chat you reopen (Ctrl+R, or after a restart) now ends on its newest messages. Before, the transcripts of old agents were listed after the whole chat, so their cards piled up at the bottom and the last few minutes of the conversation sat above them, out of the window.`,`The note that earlier messages were left out of the request is shown as its folded line after a reload too, not as raw <local-command-stdout> text.`]},{version:`0.3.273`,date:`2026-10-26`,added:[`Rest the pointer on the model box (or focus it with the keyboard) to see how much of that model’s plan or key you have used: the bars and when each limit resets, with the model you are on first. For your own Claude plan it shows what Claude itself reported on its last answer; when that is older than 10 minutes, OonaCode asks again with one tiny message (a few tokens of your own plan or key), or you press “Check now”. Settings → This PC can switch the check off or change the 10 minutes.`],fixed:[`A picture or file sent in a chat on Google’s agy — any of its models, Claude through Google included — is no longer refused with “takes text only”: OonaCode saves it in the chat’s folder and gives the model its path, as it does for every other model.`,`A Google agy chat no longer repeats “Google answered “service unavailable” — continuing in …” (and redoes its last step each time) when Google had in fact answered every request of the turn. A real Google outage is still waited out as before.`]},{version:`0.3.272`,date:`2026-10-26`,added:[`A find-in-page field in the top bar, next to the MCP servers icon: it searches everything visible in OonaCode and highlights the matches (Enter and Shift+Enter step through them). Ctrl+F opens it when no chat find takes the key; Ctrl+Shift+F always does.`,`On the website’s API keys page, a key you create from now on can be shown again with “Reveal key” — it is sealed in your browser with your vault key, so the server still cannot read it. Keys made before this still show only their last four characters.`,`Removing a message now also removes the summary the engine wrote after it, if the chat was summarised later (the summary was made from that message); the confirmation says so. The model then reads the earlier messages themselves again.`],fixed:[`Messages you type while a Google agy turn is running now all go together when the turn ends, instead of one turn per message with “2 queued” left over. The waiting strip says when they will be read, how long they have waited, what the agent is doing and how long earlier turns took.`,`The media panel starts over when OonaCode comes back after an update: it asks for a fresh access grant and reads the list again, and a failed read has a Try again button.`,`The Session info panel shows a chat’s context size as soon as you open it, not only after its next reply.`,`A sub-agent’s “Conversation compacted” line stays inside that agent’s card instead of appearing loose at the end of the chat.`,`When a chat’s own model cannot write its About or the summary of older messages, OonaCode now says so instead of quietly answering with another model.`]},{version:`0.3.271`,date:`2026-10-25`,added:[`Messages can be removed from a chat, and from what the model remembers. Right-click one of your messages, or any reply, tool call or thought of its exchange: “Remove this exchange…” takes out your message and everything the agent did for it; “Remove this and everything after…” also takes out every later message. Open windows update at once, and the chat starts fresh from what is left on its next message. Text already sent to a provider stays in that provider’s own logs.`,`When the provider is throttling OonaCode for a short while, the pool now holds your request and sends it the moment the provider is ready, instead of failing it straight away. It holds up to 90 seconds at a time, and a longer pause is waited out over the engine’s next retry.`,`Your PC’s agy and Muse helper move to the versions tested on the server (agy 1.4.7, Muse 1.4.13).`],fixed:[`Chats on a ChatGPT plan (Codex) no longer fail their About, titles and the summary of older messages with a 400 error.`,`Chats on Claude through Google, and chats on your own NVIDIA key, keep a summary of the messages that no longer fit the model’s window: their background calls now use a model the key can actually reach.`,`A chat on another of your PCs shows “PC linked · N folders” again after a restart, instead of asking you to link the same folders once more.`,`The agy note “still reports Individual quota reached…” is gone from the chat; the turn is still treated as the success it was.`,`The file explorer is back in VS Code, the chat font now also covers the message box, and a tool call at the edge of an older page of a remote chat keeps its name and input.`,`“Not delivered — the chat couldn’t start” now appears only when OonaCode itself could not start the turn, never for an error the model returned, so Send again cannot double a message.`]},{version:`0.3.270`,date:`2026-10-25`,added:[`One left panel: an icon strip on the far left switches between Sessions, Search and Files, and the file explorer now has the sidebar’s width and resize handle. Sessions and Files each have a filter box at the top.`,`Search has its own section with two scopes: Chats (every option the old search had) and Files & contents, which searches the open chat’s folder and shows the matching lines.`,`Settings → Theme → Fonts: choose the typeface and size for the chat and for the sidebar separately. Left alone, everything looks as before.`,`Hover a provider you use with your own key or subscription in the model picker to see its usage: quota bars with the time each resets.`,`On a Mac, updating now shows a window saying what is happening — it closes by itself when the new OonaCode opens, so you know whether to wait. Windows has had one since 0.3.92.`],fixed:[`Dark mode: Settings → Theme now has the Colour scheme switch (Light, Dark, System), and the colour editor opens on the colours you are actually looking at. Its old Light | Dark buttons only chose which colours to edit, so choosing Dark there seemed to do nothing. On System, the file editor also follows Windows’ dark setting now.`,`A chat on another of your PCs opens with its newest 500 messages and loads earlier ones as you scroll up, instead of pulling thousands at once over a slow link.`,`A message sent into a chat that then failed to start is marked “Not delivered — the chat couldn’t start”, with Send again. It used to look sent although the model never received it.`,`Subagents always run on the chat’s own model.`,`On a Mac, an update that could not close OonaCode used to report “done” and leave the old app in place — the terminal half updated and the app did not, sometimes for days. It now closes the app even when its window is frozen, and says plainly if it still could not, instead of claiming success.`,`After an update on a Mac, OonaCode opens again by itself. It used to reopen only if the update had closed it.`,`A browser the agent opened no longer leaves processes behind when it is closed or when OonaCode restarts. Helpers of a browser whose window was already gone could keep running for days — one of them found using most of a processor core — and they also stopped old browser versions from being cleaned up.`]},{version:`0.3.269`,date:`2026-10-25`,added:[],fixed:[`OonaCode can be quit again. Since 0.3.244, Quit (and ⌘Q on a Mac) did nothing at all unless a chat happened to be working: the question that warns about working chats answered itself when nothing was running, forgot it had answered, and asked again for ever — so the app stayed open and kept a processor core busy trying to close. If an app of yours has been sitting at high CPU, this was why.`]},{version:`0.3.268`,date:`2026-10-25`,added:[],fixed:[`Long chats no longer fail to start with “SessionStore.load() timed out after 60000ms”. Since 0.3.264 a chat’s start waited for the summary of its older messages, and the first one of a long chat could take longer than the engine allows; a chat now starts after at most 15 seconds, and the summary finishes in the background for the next start.`,`Stop now always stops a turn, even when the model is stuck retrying.`,`There is one Session info button on a wide window (on the right edge) instead of two.`]},{version:`0.3.267`,date:`2026-10-25`,added:[`Claude through Google now takes chats up to 500,000 tokens (it was 200,000), so a long chat on it keeps far more of its own history before anything is left out.`],fixed:[]},{version:`0.3.266`,date:`2026-10-25`,added:[],fixed:[`A chat’s “about” in Session info is now always written in English, whatever language the chat or its files are in — it used to follow pasted text, so an English chat could get a Persian about. The briefing and Listen still translate it into your language when you ask.`,`An about that ran over its length is now cut at the end of a whole sentence instead of in the middle of a thought, and the model is told to keep it short so the “where it stands now” part is not lost.`]},{version:`0.3.265`,date:`2026-10-25`,added:[],fixed:[`A model’s context limit now comes from the server instead of a copy kept in the app, so changing it in the admin reaches every PC. If a model ever refuses a chat as too long and names its limit, OonaCode remembers that limit and plans the next start by it, instead of hitting the same wall again.`]},{version:`0.3.264`,date:`2026-10-25`,added:[`A long chat keeps its older part in view. When a chat has grown past what the model can read, OonaCode gives the model as much of the recent conversation as fits and, in front of it, a short summary of the older part — what you asked for, what was decided and done, and what is left — instead of simply dropping it. The summary is written once, kept on this PC, and only extended as the chat grows; it appears in Usage as “Long-chat summaries”.`],fixed:[`A chat that was one very long piece of work followed by a short message no longer answers that it cannot see any earlier context: the model now gets the newest steps of that work under your original request.`,`The “invalid request” and “Autocompact is thrashing” errors that long runs of work could end in on models with a smaller window are gone: a chat is no longer handed to the model larger than the model accepts.`,`The note that earlier messages were left out now says when the cut fell inside your latest request, and when a summary was given in their place.`]},{version:`0.3.263`,date:`2026-10-25`,added:[`The right-hand side is now one dock: an icon strip on the edge, and Media and Session info stacked in it as sections. Each icon puts its section in or takes it out, both can be open at once, and a header folds its section to a line without losing what it had loaded.`,`The dock has one width and one drag handle for both sections, and it remembers which sections are in and which are folded.`],fixed:[]},{version:`0.3.262`,date:`2026-10-24`,added:[`xAI text-to-speech can now use a pronunciation map, so you can keep the written words while supplying IPA or a spoken replacement for names and multilingual dubbing.`],fixed:[`Voice and media requests recover onto another eligible operator key when one key reaches its limit, rather than failing the request immediately.`,`Google text-to-speech limits are now tracked per model, so a limit on one voice model does not make another available voice model unavailable.`,`OonaCode now presents the current versions of the Muse and Grok coding clients to their providers.`]},{version:`0.3.261`,date:`2026-10-24`,platforms:[`darwin`],added:[`“Bring this PC into the chat” remembers the folders you picked for that chat. Switching between two remote chats, reopening one, or reloading the window comes back linked to exactly those folders — you choose them once. Unlink still clears them for good.`,`A model change says what it came from: “Set model to X for this session only (previous model was Y)”, with the model you just picked in blue and the one it left in grey.`,`You can set a model typed by id on a chat that runs on another one of your PCs, instead of having to go to that PC to change it.`,`A file named in a chat opens in OonaCode, even when it is outside the chat folder. Text and code can be edited; a sound, picture or video plays as before.`,`An edited file no longer has a Save button. A changed tab shows *, Ctrl+S saves it, and Settings → General → Autosave files saves each change as you type.`,`Right-clicking a file the chat names offers “Copy relative path” and “Copy absolute path”.`,`A change to the model list or to settings now reaches this PC on its next check-in with the server, without restarting.`,`The chat’s browser no longer shows a “Restore pages?” bubble or brings back the tabs it had last time. OonaCode closes it on every exit, which used to look like a crash.`],fixed:[`One “Send now” for the whole queue: it sends every queued message at once and empties the list, instead of one button per message.`,`A message the agent had already read gets its receipt instead of staying pinned in the queue, where pressing Send now answered “The agent has already read that message”.`,`Stopping a reply, or pressing Send now while one is running, no longer shows an error. The chat says “User requested stop”.`,`Closing a file you have changed asks whether to save it, with Save, Don’t save and Cancel.`,`A file you edit keeps the line endings it had on disk when you save it, and a file the model writes while you have it open no longer replaces what you are typing in it.`,`After an admin changes a provider’s offered models, this PC’s list keeps every model’s prices and limits — no stale or emptied list in between.`,`A PC that checks in with the server on a slow schedule no longer reads as offline between check-ins; a change reaches it within a minute.`,`A Google Gemini chat no longer shows an error after a complete answer when the connection closes. The answer stays, and a real failure still shows as an error.`,`A folder you linked that may no longer be linked (a drive root, your home folder, a network share, OonaCode’s own data) is dropped when the link comes back, and never a folder you did not pick is added.`]},{version:`0.3.260`,date:`2026-10-24`,platforms:[`win32`],added:[`“Bring this PC into the chat” remembers the folders you picked for that chat. Switching between two remote chats, reopening one, or reloading the window comes back linked to exactly those folders — you choose them once. Unlink still clears them for good.`],fixed:[`One “Send now” for the whole queue on the phone too: it sends every queued message at once and empties the list, instead of one button per message.`,`A folder you linked that may no longer be linked (a drive root, your home folder, a network share, OonaCode’s own data) is dropped when the link comes back, and never a folder you did not pick is added.`]},{version:`0.3.260`,date:`2026-10-24`,platforms:[`linux`],added:[`“Bring this PC into the chat” remembers the folders you picked for that chat. Switching between two remote chats, reopening one, or reloading the window comes back linked to exactly those folders — you choose them once. Unlink still clears them for good.`,`This is Linux’s first update since 0.3.250, so it also brings everything in between: a model change says what it came from (“Set model to X for this session only (previous model was Y)”, the model you picked in blue and the one it left in grey); a model typed by id can be set on a chat that runs on another of your PCs; right-clicking a file the chat names offers “Copy relative path” and “Copy absolute path”; a file named in a chat opens in OonaCode even outside the chat folder and its text can be edited; an edited file is saved with Ctrl+S (and Settings → General → Autosave files saves as you type); the sticky notes button shows how many note tabs you have; and a Google Gemini chat in Build asks before running a command, like every other chat.`],fixed:[`One “Send now” for the whole queue on the phone too: it sends every queued message at once and empties the list, instead of one button per message.`,`A folder you linked that may no longer be linked (a drive root, your home folder, a network share, OonaCode’s own data) is dropped when the link comes back, and never a folder you did not pick is added.`,`Also from in between: stopping a reply, or pressing Send now while one is running, says “User requested stop” instead of an error; closing a file you have changed asks whether to save it; a file you edit keeps the line endings it had on disk and a file the model writes while you have it open no longer replaces what you are typing in it; after an admin changes a provider’s offered models, this PC’s list keeps every model’s prices and limits; a PC that checks in with the server on a slow schedule no longer reads as offline between check-ins; a Google Gemini chat no longer shows an error after a complete answer when the connection closes; and a message the agent had already read gets its receipt instead of staying pinned in the queue.`]},{version:`0.3.259`,date:`2026-10-24`,platforms:[`win32`],added:[`A model change says what it came from: “Set model to X for this session only (previous model was Y)”, with the model you just picked in blue and the one it left in grey.`,`You can set a model typed by id on a chat that runs on another one of your PCs, instead of having to go to that PC to change it.`],fixed:[`One “Send now” sends the whole queue at once and empties it, instead of one button per message.`,`A message the agent had already read gets its receipt instead of staying pinned in the queue, where pressing Send now answered “The agent has already read that message”.`]},{version:`0.3.258`,date:`2026-10-23`,platforms:[`win32`],added:[`Right-clicking a file the chat names offers “Copy relative path” and “Copy absolute path”.`],fixed:[`A file you edit keeps the line endings it had on disk when you save it, and a file the model writes while you have it open no longer replaces what you are typing in it.`,`A Google Gemini chat in Build asks before running a command again, and Allow runs that command.`,`After an admin changes a provider’s offered models, this PC’s list keeps every model’s prices and limits — no stale or emptied list in between.`,`A PC that checks in with the server on a slow schedule no longer reads as offline between check-ins; a change reaches it within a minute.`]},{version:`0.3.257`,date:`2026-10-23`,platforms:[`win32`],added:[],fixed:[`Stopping a reply, or pressing Send now while one is running, no longer shows an error. The chat says “User requested stop”.`,`Closing a file you have changed asks whether to save it, with Save, Don’t save and Cancel.`]},{version:`0.3.256`,date:`2026-10-22`,platforms:[`win32`],added:[`A change to the model list or to settings now reaches this PC on its next check-in with the server, without restarting.`],fixed:[]},{version:`0.3.255`,date:`2026-10-22`,platforms:[`win32`],added:[],fixed:[`A Google Gemini chat no longer shows an error after a complete answer when agy’s local connection closes. The answer stays, and a real failure still shows as an error.`]},{version:`0.3.254`,date:`2026-10-22`,platforms:[`win32`],added:[`A file named in a chat opens in OonaCode, even when it is outside the chat folder. Text and code can be edited; a sound, picture or video plays as before.`,`An edited file no longer has a Save button. A changed tab shows *, Ctrl+S saves it, and Settings → General → Autosave files saves each change as you type.`],fixed:[]},{version:`0.3.252`,date:`2026-10-21`,platforms:[`win32`,`darwin`],added:[`The sticky notes button shows how many note tabs you have, as a blue number.`],fixed:[]},{version:`0.3.251`,date:`2026-10-21`,platforms:[`win32`],added:[`A Google Gemini chat in Build now asks before running a command, using the same permission card as every other chat. Autonomous and auto-accept still run commands without asking.`],fixed:[]},{version:`0.3.250`,date:`2026-10-21`,added:[`The file list now has Show in Explorer, which opens the file or folder selected in your computer’s file manager, and Rename for both files and folders.`,`A text file opened from the file list can now be edited. Change it, then press Save or Ctrl+S. Pictures, videos, sounds and PDF files stay view-only.`],fixed:[]},{version:`0.3.249`,date:`2026-10-20`,added:[`When the model reads a picture, a video or a sound file, that step in the chat now opens by itself: you see the picture, or get a player for the video or sound, without clicking. Click the step to close it. Steps that read ordinary text files stay closed as before.`],fixed:[]},{version:`0.3.248`,date:`2026-10-20`,added:[],fixed:[`A chat on Google Gemini (through your Google plan) no longer ends a finished turn with an error. Google’s agy tool can keep repeating an old “quota reached” message at the end of a long chat even though your limit was fine and the answer arrived; OonaCode now shows the answer as done and adds a short note. A limit you really hit still shows as an error.`,`When you do reach your Google limit in a Gemini chat, OonaCode now shows Google’s own message, including when it resets, instead of a message about the OonaCode pool that did not apply to you.`]},{version:`0.3.247`,date:`2026-10-20`,added:[`On the Android app, a short tap on a message now opens a menu: Reply (quotes it above the box), Copy, Forward (opens it as a draft in another chat you pick), Share and Save text to… A long press still selects text.`,`On the Android app, a picture, video, sound or file that a reply names now opens from your PC: pictures show right in the chat, videos and sounds play in the chat, and other files open in the app you choose or are saved where you say. A file larger than 25 MB asks first.`,`This PC now hands those files to your phone over the same private link as your chats — only files that the chat itself named or that sit in its folder, one piece at a time.`],fixed:[]},{version:`0.3.246`,date:`2026-10-19`,added:[`Every chat can now make videos and spoken audio, not only pictures: ask for a short clip or a voice-over and the model makes it, saves it in the chat’s folder and plays it right in the chat. Video and Speech sit beside Images in the Tools menu, switched on by default.`,`In the Tools menu each of the three has a model choice for this chat (its default follows the model you are chatting with: a Grok chat uses Grok’s, an Alibaba chat Alibaba’s) and an “Ask me first” switch. With it on — the default for video — the model asks you for the length, resolution and shape and tells you the price in credits before anything is spent.`,`Pictures, videos and speech are paid with your OonaCode credits like any other message, whatever model or key the chat runs on, and the credits charged are shown in the answer.`,`On Apple Silicon Macs (M1 and later) Oonak Browser is now the native build: it quits with its last window, shows its own Dock icon and never asks for notification permission.`],fixed:[]},{version:`0.3.245`,date:`2026-10-19`,added:[`A picture, video or sound that a model reply named but that is not on your PC any more is now left out of the Media explorer, with a line under the list saying how many were left out and a Show button to see them.`,`A picture the model made now shows up in the chat as a small square beside its name — you no longer need the Media panel to notice it — and a click enlarges it.`,`A file the model names (a PDF, a Word or Excel document, a zip and so on) now shows its type’s icon in the chat and in the Media explorer; a file of any other type gets a plain file icon.`],fixed:[`The Media explorer no longer lists a website path such as /logo.svg or /favicon.png from a model reply as if it were a file on your PC, and a card that cannot be opened now shows the file name and date instead of only “Moved or deleted”.`]},{version:`0.3.244`,date:`2026-10-19`,added:[`When the agent enters plan mode (and when you approve its plan) the Build / Plan / Ask picker now follows it, so the picker always shows the mode the chat is really in.`],fixed:[`Four engine tools nobody uses here — ListAgents, EnterWorktree, ExitWorktree and ReportFindings — are switched off in every chat, which makes each request a little smaller.`]},{version:`0.3.243`,date:`2026-10-18`,added:[`OonaCode now asks before it quits or updates while any chat is still working — including chats whose tabs you closed — and names them, so nothing is interrupted by accident.`],fixed:[]},{version:`0.3.242`,date:`2026-10-18`,added:[`Every model can now take any attachment: a picture or PDF that the chosen model cannot read (Google’s agy, text-only Qwen or GLM models, and so on) is saved in the chat’s temporary folder and the model is given its file path instead of the message being refused.`,`The media panel can filter by All, Mine or Replies, so the pictures, videos, sounds and links that the model’s replies name are listed too, and every item has a right-click menu (View or Play, Show in chat, Show in folder, Copy path or link).`,`The “Media in this chat” and “Session info” panels can be resized by dragging their left edge; double-click the edge for the default width.`,`Web search is now in every chat, always: there is no Tools-menu switch for it any more, and chats that had it switched off search again.`],fixed:[]},{version:`0.3.241`,date:`2026-10-17`,added:[`Remote sessions in the sidebar now have a full right-click context menu and actions button (Pin to top, Move to Project, Project settings, Change folder, Details, Listen to this chat, Files, Rename, Fork and Delete) plus a details card on hover.`,`The Files explorer and file viewer now work for remote chats over the blind relay, so you can browse folders, view code, Markdown and images, copy paths and delete files on the remote PC.`,`Oonak Browser is now available for macOS chats as well as Windows and Linux.`],fixed:[`Newly created or renamed remote chats now appear immediately in the Remote section of the left sidebar, and the sidebar automatically recovers after a brief server or connection blip.`,`Opening a long remote chat with many screenshots no longer disconnects the relay for backpressure or stops loading recent messages.`]},{version:`0.3.240`,date:`2026-10-17`,added:[`Every Thought block now shows how long the model spent thinking (for example “Thought · 42 words · 12s”), both live and when a chat is reopened.`,`Remote chat tabs now show a badge naming the PC they run on, and you can rename a remote chat directly from its tab or from the Remote list in the sidebar.`,`Files attached from the Android app are uploaded into the chat’s folder on the PC that runs the chat.`],fixed:[`Subagent reports and continuation notes now fold into a single Engine note line instead of staying pinned at the bottom of the chat or replacing the pinned user question.`,`Local video and file paths in replies (including Windows paths with forward slashes, paths with spaces, and Markdown links) now reliably show their Play, View and Open in folder buttons.`,`Chats on a ChatGPT (Codex) subscription no longer fail when the model calls tools.`,`Google agy chats wait and retry automatically (5 s, 20 s, 1 min, 2 min) when Google answers with a temporary 503 Unavailable.`]},{version:`0.3.239`,date:`2026-10-16`,platforms:[`win32`],added:[`Media in every chat: the gallery button at the top right of a chat lists the photos, videos, audio, files and links you sent in it. Photos open in the viewer (← → step through them), videos and audio play in place, files open or show in their folder, and “Show in chat” jumps to the message.`],fixed:[`Google agy chats no longer flash a command window when they start. OonaCode now keeps agy up to date itself, quietly, while no agy chat is running.`,`An agy command that waits for someone to type (a password prompt, an ssh question) no longer holds the chat for hours: after 15 minutes with no output and no work, OonaCode ends that command, says so in the chat, and agy carries on.`,`The coding engine is updated (Claude Code 2.1.301): long answers are no longer cut off after three minutes of silence, a long chat no longer compacts again and again, and a tool no longer runs twice.`,`If the app’s window crashes (for example when the computer runs out of memory), it reloads by itself.`,`A chat on your own Meta Muse or ChatGPT plan that started on another provider no longer fails with “call_id must be at most 64 characters”.`,`Your other PCs keep one order in the Remote list instead of reshuffling.`,"`oona -p` with an OonaCode API key says what went wrong instead of asking you to sign in."]},{version:`0.3.239`,date:`2026-10-16`,platforms:[`darwin`],added:[`Media in every chat: the gallery button at the top right of a chat lists the photos, videos, audio, files and links you sent in it. Photos open in the viewer (← → step through them), videos and audio play in place, files open or show in their folder, and “Show in chat” jumps to the message.`],fixed:[`The coding engine is updated (Claude Code 2.1.301): long answers are no longer cut off after three minutes of silence, a long chat no longer compacts again and again, and a tool no longer runs twice.`,`If the app’s window crashes (for example when the computer runs out of memory), it reloads by itself.`,`A chat on your own Meta Muse or ChatGPT plan that started on another provider no longer fails with “call_id must be at most 64 characters”.`,`Your other PCs keep one order in the Remote list instead of reshuffling.`,`A download cut part-way during an update is resumed instead of starting over.`,"`oona -p` with an OonaCode API key says what went wrong instead of asking you to sign in."]},{version:`0.3.239`,date:`2026-10-16`,platforms:[`linux`],added:[`Media in every chat: the gallery button at the top right of a chat lists the photos, videos, audio, files and links you sent in it. Photos open in the viewer (← → step through them), videos and audio play in place, files open or show in their folder, and “Show in chat” jumps to the message.`],fixed:[`“Restart now” in Settings opens the app again instead of closing it for good.`,`The OonaCode service starts again after a quick reboot.`,`A power cut no longer empties the files that keep you signed in and unlocked.`,`A download cut part-way (weak Wi-Fi) during an install or update is resumed instead of giving up.`,`Notifications come from “OonaCode”.`,`The coding engine is updated (Claude Code 2.1.301): long answers are no longer cut off after three minutes of silence, a long chat no longer compacts again and again, and a tool no longer runs twice.`,`If the app’s window crashes (for example when the computer runs out of memory), it reloads by itself.`,`A chat on your own Meta Muse or ChatGPT plan that started on another provider no longer fails with “call_id must be at most 64 characters”.`,`Your other PCs keep one order in the Remote list instead of reshuffling.`,"`oona -p` with an OonaCode API key says what went wrong instead of asking you to sign in."]},{version:`0.3.238`,date:`2026-10-16`,added:[`Auto in the OonaCode pool: pick “Auto” and each new message runs on the pool model that suits it — how hard the task is, how big the chat is, whether a model already has the chat in its cache, speed and cost — at an effort it picks too. The model button shows which model Auto chose, like “Auto (Qwen3.8 Max)”. (It appears once OonaCode switches it on.)`,`Window control in the Tools menu: when you ask, the agent can list, hide, show, minimise, restore or focus the windows on your computer (Windows; apps on macOS; X11 and KDE on Linux).`,`The conversations popup in a chat shows when each conversation started and when it was last active.`],fixed:[`A Google agy chat that hits a temporary “service unavailable” from Google now waits a few seconds and carries on in the same conversation instead of ending the turn.`,`The agent keeps Oonak Browser’s window visible: no hidden or headless browser unless you ask for one.`]},{version:`0.3.237`,date:`2026-10-15`,platforms:[`win32`,`darwin`],added:[`When a long chat no longer fits the model, the chat shows one line saying how many earlier messages the request left out; click it for the explanation.`],fixed:[`The model picker no longer has an “All models” list, which showed the same model twice when a provider offers it both by key and by subscription. Pick a provider to see its models.`,`Google’s agy: Gemini 3.7 Flash, 3.6 Flash and 3.1 Pro are gone from the picker, because Google no longer offers them, and the picker shows only the models your own Google plan lists. A chat that was on one of them asks you to pick another model.`,`A picture or PDF attached to a chat on Google’s agy is refused with words that say agy takes text only on every one of its models, and that another provider’s model can read it.`,`A thought with no words in it (Meta Muse hides its thinking) no longer leaves an empty “Thought” card in the chat.`,`Conversations between chats read “idle” when nothing is going on.`]},{version:`0.3.237`,date:`2026-10-15`,platforms:[`linux`],added:[`The model picker is redone: your providers on the left, each with how many models it has, and the chosen provider’s models on the right, best first by independent intelligence rating. Each side has its own search. After you pick a model from another provider, its button says “next message” until your next message runs on it.`,`Every model shows its own effort levels, and the effort picker starts on the model’s default. A model with no effort levels shows no picker.`,`Meta Muse: Muse Spark 1.3 and 1.2, Wonder 1.0 and Wonder Full 1.0 — paste your Muse key in Connect or press “Sign in with Meta”.`,`ChatGPT plans: GPT-6.1 Sol, GPT-6 Sol, GPT-6 Astra and GPT-5.6 Sol when your plan lists them; chats keep their thinking across tool calls and use the effort you pick.`,`NVIDIA is back for your own NVIDIA key, with twelve hosted models that call tools. Your own SuperGrok subscription offers Grok 4.7 Fast.`,`Bring this PC into the chat: on a chat that runs on another PC, pick folders on this PC and what the chat may do there; it asks you before every change. And a Tools switch lets a chat list, read and message the chats on your other PCs.`,`Sticky notes beside the bug button, saved in your vault so they follow you to your other computers.`,`Suggest, beside Listen in every chat, proposes what to send next, and the project manager does it for several chats at once. Nothing is sent until you press Send.`,`Listen to this chat is a player with a seek bar, a speed you can change while it plays, and the spoken word highlighted.`,`A tab whose chat finished a turn you have not looked at yet wears a dot. A long chat folds old agents into one “N earlier agents” row, and every block shows its time.`,`When a long chat no longer fits the model, one line says how many earlier messages the request left out.`],fixed:[`A message sent while a chat is working, right after you picked another model, waits for the running turn and is answered by the model you picked.`,`A PC you sign in later appears in the left panel by itself.`,`A thought with no words in it no longer leaves an empty “Thought” card.`,`The Claude Code engine is updated to 2.1.296.`]},{version:`0.3.236`,date:`2026-10-14`,platforms:[`win32`,`darwin`],added:[`Every model now shows its own effort levels, and the effort picker starts on the model’s default — so you can see what level a chat really runs at. A model that has no effort levels no longer shows a picker at all.`,`A collapsed thought block now shows how the thought begins, like a command does: “Thought 42 words: First I read the file…”.`,`Meta Muse requests now match Meta’s own Muse CLI, so its thinking, tool calls, pictures and PDFs show up properly in the chat.`],fixed:[`Grok 4.5 no longer offers an “extra high” effort that xAI treats as high, and GPT-4.1 no longer shows an effort picker it cannot use.`]},{version:`0.3.235`,date:`2026-10-13`,platforms:[`win32`,`darwin`],added:[`Meta Muse: use Meta’s Muse Spark 1.3, Spark 1.2, Wonder 1.0 and Wonder Full 1.0 in your chats. Open Connect, pick Meta Muse, and either paste your Muse key or press “Sign in with Meta” — OonaCode downloads Meta’s Muse once (about 360 MB, after you agree), you confirm the code on Meta’s page, and the key is kept in your vault.`,`ChatGPT plans: GPT-6.1 Sol (500k context), GPT-6 Sol, GPT-6 Astra and GPT-5.6 Sol are available when your plan lists them, next to the models you already had.`,`Google’s agy: Gemini 4 Argon appears in the model picker when your Google plan includes it (Ultra), at Low, Medium and High.`],fixed:[]},{version:`0.3.234`,date:`2026-10-13`,platforms:[`win32`,`darwin`],added:[`Bring this PC into the chat: on a chat that runs on another PC, press the button in the chat’s toolbar, pick folders on this PC and tick Read, Create, Edit or Delete for each. The chat can then work with those files. It asks you before it creates, changes, moves or deletes anything, and the link ends when you close the tab. Both PCs need this version.`,`Chats on my other PCs: a new switch in the Tools menu lets a chat list your other PCs and their chats, read them, message them and start new chats there on the model you choose. You confirm every new chat.`,`The Tools menu now works on a chat that runs on another PC, so you can switch its tools from here.`],fixed:[`A PC you sign in after OonaCode has started now appears in the left panel by itself, without opening Settings → Devices first.`]},{version:`0.3.233`,date:`2026-10-12`,platforms:[`win32`,`darwin`],added:[`The model picker now tells you when a pick is not in use yet: after you pick a model from another provider, its button says “next message” and explains that the chat keeps running on its current model until your next message.`,`A long chat folds the agents that ran long ago into one “N earlier agents” row that says when they ran, instead of one card for each of them under your newest message.`],fixed:[`A message you send while a chat is working, right after you picked another model or provider, now waits for the running turn and is answered by the model you picked. It used to go to the model that was already running, so the chat kept answering as the old one while the picker showed the new one.`,`Every block in a chat now shows the time it happened — also the notes the app writes itself and the cards for earlier agents.`]},{version:`0.3.232`,date:`2026-10-12`,platforms:[`win32`],added:[`The model picker is redone: your providers on the left, each with how many models it has, and the chosen provider’s models on the right, best first by independent intelligence rating (unrated ones last). Each side has its own search, and the one over the providers finds a model across every provider, showing only the providers that carry it.`,`NVIDIA is back for your own NVIDIA key: twelve hosted models that call tools, among them Nemotron 3 Ultra and Super, Kimi K3, GLM-5.3, DeepSeek V4.1 Flash and Gemma 4.`],fixed:[`Models hosted as vendor/model (Kimi K3 on NVIDIA and the like) now show their intelligence rating.`]},{version:`0.3.232`,date:`2026-10-12`,platforms:[`darwin`],added:[`Sticky notes: the note button beside the bug button at the top opens your notes as tabs. Make as many as you like, name them with a double-click, and write — every change is saved by itself in your vault, so the notes follow you to your other computers. Text only.`,`Chats on your own ChatGPT plan keep their thinking across tool calls, use the effort level you pick (up to max where the model has it), and list the models your account really offers.`,`The model picker is redone: your providers on the left, each with how many models it has, and the chosen provider’s models on the right, best first by independent intelligence rating (unrated ones last). Each side has its own search, and the one over the providers finds a model across every provider, showing only the providers that carry it.`,`NVIDIA is back for your own NVIDIA key: twelve hosted models that call tools, among them Nemotron 3 Ultra and Super, Kimi K3, GLM-5.3, DeepSeek V4.1 Flash and Gemma 4.`],fixed:[`Suggest no longer starts reading the chat the moment you open it: pick how many hours to read, then press Suggest.`,`The Claude Code engine is updated to 2.1.296.`,`Models hosted as vendor/model (Kimi K3 on NVIDIA and the like) now show their intelligence rating.`]},{version:`0.3.231`,date:`2026-10-12`,platforms:[`android`],added:[`On the phone: any text in a chat can be selected and copied, and About became Session info.`],fixed:[]},{version:`0.3.230`,date:`2026-10-11`,platforms:[`win32`],added:[`Sticky notes: the note button beside the bug button at the top opens your notes as tabs. Make as many as you like, name them with a double-click, and write — every change is saved by itself in your vault, so the notes follow you to your other PCs. Text only.`,`Chats on your own ChatGPT plan keep their thinking across tool calls, use the effort level you pick (up to max where the model has it), and list the models your account really offers.`],fixed:[`Suggest no longer starts reading the chat the moment you open it: pick how many hours to read, then press Suggest.`,`A Gemini chat on your own Google plan no longer repeats, turn after turn, a command it refused earlier.`,`The Claude Code engine is updated to 2.1.296.`]},{version:`0.3.229`,date:`2026-10-11`,platforms:[`darwin`],added:[`Suggest, beside Listen in every chat: it reads the last few hours of the chat and suggests what to send it next. You edit it, put it in the message box or send it — nothing runs by itself.`,`The project manager, beside the "about" button over the chat list: tick chats, press Review, and each gets a suggestion you can edit and send with its own button.`,`A tab whose chat finished a turn you have not looked at yet wears a dot (red when the turn failed), and so does its row in the list.`,`Listen to this chat is a player: a seek bar, play and pause, ten seconds back and forward, the previous or next sentence, a speed you can change while it plays, the spoken word highlighted (click any word to play from it), and every summary listed newest first on top.`,`MCP servers: add them in Settings → MCP Servers from a directory of popular ones (PostgreSQL, Supabase, GitHub, Sentry, Slack, Notion, Linear and more) or your own, and switch each on or off per chat.`,`Connectors: Supabase, Railway and Vercel in the Tools menu — sign in once, switch one on in a chat, and the agent can look at your projects, databases, logs and deployments; read-only until you allow changes, and it asks before each one.`,`Pictures: ask any chat for an image and it makes one, saved in the chat’s folder and shown in the chat (a few credits each; Images in the Tools menu turns it off).`,`Web search for every model, from your Mac, with no key and no credits.`,`Claude Haiku 5.5 with a 1M-token window, and Grok 4.7 Fast on your own SuperGrok subscription.`,`Pasting a very long text, or a video, sound or large picture, saves it in the chat’s folder and attaches it as a file.`,`Hover a “Read …png” line in the chat and the picture shows at once.`],fixed:[`A compacted chat reopens with its whole history, not only what came after its last compaction.`,`Deleting a chat frees its OonaCode pool seat at once.`,`Large chats resume faster.`,`The chat summary (“About”) no longer fails on models that think at length.`,`A refusal by Gemini’s safety filter is retried once on another model, like the others.`,`Error notes in the chat read as plain sentences instead of codes or raw data.`,`The message navigator always shows at least four lines and no longer vanishes on the way to it.`]},{version:`0.3.228`,date:`2026-10-11`,platforms:[`win32`],added:[`Suggest, beside Listen in every chat: it reads the last few hours of the chat and suggests what to send it next. You edit it, put it in the message box or send it — nothing runs by itself.`,`The project manager, beside the "about" button over the chat list: tick chats, press Review, and each gets a suggestion you can edit and send with its own button.`,`A tab whose chat finished a turn you have not looked at yet wears a dot (red when the turn failed), and so does its row in the list.`],fixed:[]},{version:`0.3.227`,date:`2026-10-11`,platforms:[`win32`],added:[`Listen to this chat is a player: a seek bar, play and pause, ten seconds back and forward, the previous or next sentence, and a speed you can change while it plays.`,`The word being spoken is highlighted in the summary, and clicking any word plays from there.`,`Every summary the chat has is listed on top, newest first; pick one to hear it, with the languages it was already translated into.`],fixed:[]},{version:`0.3.226`,date:`2026-10-11`,platforms:[`win32`],added:[`Google Gemini (agy) chats show what agy looked at: a picture it viewed appears in the chat, and a sound or video it named plays inside the tool card.`,`Your own SuperGrok subscription offers Grok 4.7 Fast.`,`The Android app groups this PC’s chats by the project each one is filed under.`],fixed:[`Google Gemini (agy) tool steps read in words — View file, Run command, Edit — with their file or command, instead of raw arguments.`,`Your own SuperGrok sign-in presents the current Grok CLI (1.0.50), so xAI does not refuse it as outdated.`]},{version:`0.3.225`,date:`2026-10-10`,platforms:[`win32`,`linux`],added:[`Per-credential usage keys: operator credentials can now store their own console session keys (such as Xiaomi MiMo account credentials) directly in the Admin Panel to monitor individual token plan quotas and balances.`,`Google agy thinking blocks: local Google Antigravity (Gemini) sessions now extract and display model thinking blocks and rich tool arguments in chat from agy transcripts.`],fixed:[`Session info regeneration: fixed an issue where regenerating the session summary for Google Antigravity (Gemini) sessions would fail with a missing subscription token error.`,`Xiaomi MiMo cleanup: removed redundant and withdrawn mimo-v2.5 and mimo-v2.5-pro models from the registry and models catalog; replaced by mimo-v2.6-pro and mimo-v2.6-flash.`]},{version:`0.3.224`,date:`2026-10-09`,platforms:[`win32`,`linux`],added:[`Auto-save clipboard files and large pasted text: pasting text exceeding 10,000 characters or 300 lines automatically saves into your workspace .oonacode/tmp folder and attaches as a file without bloating the composer. Clipboard videos, audio, and large images are similarly saved and attached as local paths.`],fixed:[`Error display in chat: masked internal error codes, raw JSON, and provider balance exhaustion notices from the user chat bubble, displaying clean status indicators instead.`,`Google Antigravity pool plan access: included Gemini 3.8 Flash and 3.7 Flash across all active subscription plans (Standard, Pro, Team Standard, Team Premium, Free).`,`Session info panel: fixed an issue where switching between chats could leave stale child views mounted in the session info panel.`]},{version:`0.3.223`,date:`2026-10-09`,platforms:[`win32`,`linux`],added:[`MCP Servers settings & Antigravity catalog: configure stdio, sse, and http Model Context Protocol servers in File -> Settings -> MCP Servers. Choose from a rich directory of popular providers (PostgreSQL, Supabase, Redis, SQLite, MongoDB Atlas, GitHub, GitLab, Sentry, Cloudflare, Slack, Notion, Linear, PostHog, Brave Search) or add custom servers.`,`TopBar MCP badge: see your configured MCP servers count at a glance next to the Bug Report button, and click to open MCP settings directly.`,`Per-chat MCP server toggles: selectively enable or disable configured MCP servers per conversation in the composer toolbar to eliminate prompt token overhead.`],fixed:[]},{version:`0.3.222`,date:`2026-10-09`,platforms:[`win32`,`linux`],added:[],fixed:[`Chat summary "About": increased housekeeper output token headroom to prevent thinking and verbose models (e.g. Qwen, Gemini) from exceeding the token ceiling and failing with "Claude's response exceeded the 700 output token maximum".`]},{version:`0.3.221`,date:`2026-10-09`,platforms:[`win32`,`linux`],added:[`Web search for every model: all models can now search the web via keyless local DuckDuckGo search from your PC, with no extra credentials or credits needed.`,`Claude Haiku 5.5: available with 1M context, 128K output, and tiered pricing (replaces Haiku 4.5).`],fixed:[`Deleting a chat immediately frees its pool seat on the server, instead of keeping it held until the session cache window expires.`,`Session info panel headers: distinct icons for About (sparkle) and Scheduled tasks (bell) so sections no longer repeat the same info glyph.`,`Large sessions resume faster and safer with reverse-bounded transcript loading and auto-trimming to disk.`,`Gemini content safety filter blocks are now caught by safeguard fallback and retried on the fallback model.`]},{version:`0.3.220`,date:`2026-10-07`,platforms:[`win32`,`linux`],added:[],fixed:[`A chat on a Google Claude model no longer stops with “Autocompact is thrashing”. Its window was set to 100,000 tokens, so the chat compacted again right after every compaction and the engine gave up; it is now 200,000, and if the engine ever gives up this way the next message starts from a shorter history instead of repeating the same state.`]},{version:`0.3.219`,date:`2026-10-07`,platforms:[`win32`,`linux`],added:[`Pictures: ask any chat for an image — “generate a realistic tiger fighting a crocodile” — and it now makes one, with any model, the way Google’s Antigravity does. The picture is saved in the chat’s folder and shown right in the chat; click it for the full viewer. It costs a few OonaCode credits per picture, you can edit a picture file from the folder too, and it can be switched off in the Tools menu (Images).`,`The Google Claude models (typed by exact id in the model picker’s Custom model row) show their real 100,000-token window in the session panel, and the chat now compacts before the limit instead of being refused and re-sent.`],fixed:[`Google-hosted Claude and Gemini chats re-used almost none of Google’s prompt cache, so big chats ate the 5-hour window in minutes. They now reuse about 98 % of the prompt, which makes them far cheaper and faster.`,`The hidden /setcustommodel command and the admin custom-model tool are gone — the model picker’s Custom model row does the same job.`]},{version:`0.3.218`,date:`2026-10-07`,platforms:[`win32`,`linux`],added:[`Connectors: Supabase, Railway and Vercel in the Tools menu. Sign in once with the service’s own page, switch the connector on in a chat, and the agent can look at your projects, databases, logs and deployments. It is read-only until you turn on “Allow changes”, and then it asks you before every change; purchases, billing and secret or key readers are never offered. Each shows whether the service’s command-line tool is installed and can add the vendor’s own skills. In the terminal: oona connectors. Guide: /docs/connectors.`,`Hover a “Read …png” line in the chat and the picture shows at once; click the picture for the full viewer with zoom, like a picture you sent.`],fixed:[`A chat that was compacted no longer reopens showing only what came after its last compaction: the whole history is there again.`,`The message navigator always shows at least four lines, and its list no longer vanishes while the pointer crosses the gap to it.`]},{version:`0.3.217`,date:`2026-10-07`,platforms:[`darwin`],added:[`Pictures you attach open large: click one in the box or in a sent message for a viewer with zoom (buttons, wheel, drag, Fit and 100 %). Click a PDF or text file and it opens in its own program.`,`When a model refuses a message on safety grounds, OonaCode retries it once on another model and says so in the chat. Choose how in Settings → Safeguards: switch automatically, always switch to a model you pick, or never — with a fallback for each model. The same in the terminal: oona settings safeguard-fallback and --fallback-model. Works for Claude, Gemini and Google’s agy.`,`The terminal signs in two ways: your OonaCode account (through your browser) or an OonaCode API key. A fresh oona asks which; oona login --api-key-stdin stores a key for scripts, oona whoami says which one is in use, and oona logout removes it. The terminal manual is on the website: /docs/cli.`,`The conversations badge reads like the agents badge — “3 conversations · 1 active” — and the Conversations window lists every limit: messages, tokens, credits, depth, rates and the idle close.`,`A chat can start a new chat for you on another provider, model, effort or project — it asks you first, and a chat that was itself started by a chat cannot start more.`,`The message navigator’s list shows each message’s date and opens on your latest one; messages further back than 5,000 lines are greyed.`],fixed:[`A chat that was compacted no longer reopens showing only what came after its last compaction: the whole history is there again.`,`The message navigator always shows at least four lines, and its list no longer vanishes while the pointer crosses the gap to it. A click on it now takes you to older messages even while the chat is still replying (the page used to jump straight back).`,`oona: a wrong command or flag now exits with code 2, oona sessions list no longer breaks on multi-line titles, piping oona into head no longer prints an error, and the plain-prompt mode can send a message again.`,`One-shot terminal runs reuse the engine already on the Mac instead of downloading it every time, and a model you typed with /model that is not in the picker keeps its name after OonaCode restarts.`]},{version:`0.3.216`,date:`2026-10-07`,platforms:[`win32`,`linux`],added:[`The terminal signs in two ways: your OonaCode account (through your browser) or an OonaCode API key. A fresh oona asks which; oona login --api-key-stdin stores a key for scripts and servers, oona whoami says which one is in use, and oona logout removes it. The key is sealed by the host and never written to the terminal’s config.`,`The terminal manual is on the website: /docs/cli, written from commands run on Debian and Ubuntu servers.`],fixed:[`oona: a wrong command or flag now exits with code 2, oona sessions list no longer breaks on multi-line titles, piping oona into head no longer prints an error, and the plain-prompt mode can send a message again.`,`One-shot terminal runs reuse the engine already on the PC instead of downloading it every time.`,`A model you typed with /model that is not in the picker keeps its name after OonaCode restarts.`]},{version:`0.3.215`,date:`2026-10-07`,platforms:[`win32`,`linux`],added:[`Pictures you attach open large: click one in the box or in a sent message for a viewer with zoom (buttons, wheel, drag, Fit and 100 %). Click a PDF or text file and it opens in its own program.`,`When a model refuses a message on safety grounds, OonaCode retries it once on another model and says so in the chat. Choose how in Settings → Safeguards: switch automatically, always switch to a model you pick, or never — with a fallback for each model. The same in the terminal: oona settings safeguard-fallback and --fallback-model. Works for Claude, Gemini and Google’s agy.`,`The conversations badge reads like the agents badge — “3 conversations · 1 active” — and the Conversations window lists every limit: messages, tokens, credits, depth, rates and the idle close.`,`A chat can start a new chat for you on another provider, model, effort or project — it asks you first, and a chat that was itself started by a chat cannot start more.`,`The message navigator’s list shows each message’s date and opens on your latest one; messages further back than 5,000 lines are greyed.`],fixed:[`A click on the message navigator now takes you to older messages even while the chat is still replying (the page used to jump straight back).`,`The message navigator no longer touches the message times, and its lines are darker and longer.`]},{version:`0.3.214`,date:`2026-10-06`,platforms:[`darwin`],added:[`OonaCode runs natively on Apple Silicon Macs. The installer picks the Apple Silicon build by itself, and an Apple Silicon Mac that had the Intel one moves to it on its next install or update — the Intel build cannot run there on macOS 14 or older.`,`A message navigator on every chat: the small stack of lines at the middle-right of the chat is your own messages — rest on it, focus it or tap it and the list of everything you sent opens; click one and the chat scrolls straight to it.`],fixed:[`On an Apple Silicon Mac with macOS 14 or older, every chat crashed (“CPU lacks AVX support”) and Update did nothing. If yours did, run once in Terminal: curl -fsSL https://oonacode.oonak.ai/install.sh | bash`,`When an update cannot start, the app now says why and what to run instead of saying “Updating OonaCode…” while nothing happens.`,`File → Export chats… no longer freezes the window under a Save panel: the zip goes straight into Downloads and Finder shows it.`]},{version:`0.3.213`,date:`2026-10-06`,added:[`A message navigator on every chat: the small stack of lines at the middle-right of the chat is your own messages — rest on it, focus it or tap it and the list of everything you sent opens; click one and the chat scrolls straight to it. Escape closes the list.`],fixed:[],platforms:[`win32`,`linux`]},{version:`0.3.212`,date:`2026-10-06`,added:[`Headless one-shot runs without signing in: --api-key (or OONACODE_API_KEY) bills the run through the gateway on that OonaCode key — held in memory for the run only, never stored. For containers and CI.`],fixed:[`A keyed run no longer stops at the device-link screen, and no longer dies with "the OonaCode pool needs your OonaCode account": the key now also covers provider routing and the registry read on a machine that was never signed in.`],platforms:[`win32`,`linux`]},{version:`0.3.211`,date:`2026-10-06`,added:[`A message navigator on every chat: the small stack of lines at the middle-right of the chat is your own messages — rest on it and the list of everything you sent opens; click one and the chat scrolls straight to it.`,`One-shot runs without signing in: --api-key (or OONACODE_API_KEY) bills the run through the gateway on that OonaCode key — held in memory for the run only, never stored. For headless machines and containers.`],fixed:[],platforms:[`linux`]},{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 gu(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:_u(r.pre,i.pre)}function _u(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 vu(e,t,n=hu,r=null){if(!e||e===`0.0.0`)return[];let i=n.filter(t=>gu(t.version,e)<=0&&(!r||!t.platforms||t.platforms.includes(r)));return[...t===null?i.filter(t=>gu(t.version,e)===0):i.filter(e=>gu(e.version,t)>0)].sort((e,t)=>gu(t.version,e.version))}function yu(e,t,n,r=hu,i=null){if(!e||e===`0.0.0`)return{record:null,show:[]};let a=null;for(let e of r)(a===null||gu(e.version,a)>0)&&(a=e.version);let o=a!==null&&gu(e,a)>0?a:e;return{record:t===null||gu(o,t)>0?o:null,show:t===null&&!n?[]:vu(e,t,r,i)}}function bu(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 xu=`the user skipped the question`,Su=`(the user skipped this question)`;function Cu(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 wu(e,t,n={},r=new Set){let i={};return e.forEach((e,a)=>{if(r.has(a)){i[e.question]=Su;return}let o=(n[a]??``).trim();i[e.question]=o||(t[a]??[]).join(`, `)}),i}function Tu(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 Eu(e){if(!e||typeof e!=`object`)return null;let t=e.answers;return t&&typeof t==`object`&&!Array.isArray(t)?t:null}var Du=[`oauth`,`token`];function Ou(e){switch(e){case`signed-out`:return`Not signed in`;case`connecting`:return`Waiting for your sign-in…`;case`connected`:return`Connected`;case`expired`:return`Sign-in expired`;case`error`:return`Cannot reach the service`}}var ku=R().refine(e=>/^https:\/\/[^\s]+$/i.test(e),`must be an https address`),Au=us({vendor:R().min(1).max(60),mcpUrl:ku,readOnlyQuery:vs(R(),R()).nullable(),auth:us({methods:cs(bs(Du)).min(1),scopes:cs(R()),offlineAccess:ns(),token:us({label:R(),createUrl:ku,note:R().nullable()}).nullable()}),tools:us({deny:cs(R()),allowWrites:cs(R()),featured:cs(R()),maxResultChars:Qo().int().min(1e3).max(2e5)}),cli:us({command:R().regex(/^[A-Za-z0-9._-]{1,40}$/),versionArg:R().regex(/^--?[A-Za-z0-9-]{1,20}$/),install:vs(R(),R()),login:us({command:R(),tokenEnv:R().nullable()}),purpose:R()}).nullable(),skills:cs(us({name:R().regex(/^[a-z0-9][a-z0-9_-]{0,47}$/),source:us({repo:R().regex(/^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/),ref:R().regex(/^[0-9a-f]{40}$/,`pin a full commit, never a branch`),path:R().refine(e=>!/(^|[\\/])\.\.([\\/]|$)|^[\\/]/.test(e),`relative path`)}),license:R(),exclude:cs(R())})),docsUrl:ku}).loose();function ju(e){if(e.toolName!==`ConnectorChange`)return null;let t=e.input;if(!t||typeof t!=`object`||typeof t.connector!=`string`||typeof t.vendor!=`string`||typeof t.tool!=`string`)return null;let n=t.arguments!==null&&typeof t.arguments==`object`&&!Array.isArray(t.arguments)?t.arguments:{};return{connector:t.connector,vendor:t.vendor,tool:t.tool,description:typeof t.description==`string`?t.description:``,arguments:n}}function Mu(e){let t=Object.keys(e.arguments).slice(0,8);return`${e.vendor}: ${e.tool}${t.length>0?` (${t.join(`, `)})`:``}`}var Nu=[`win32`,`linux`,`darwin`],Pu=[`demo`,`live`],Fu=[`allow`,`ask`],Iu=[`string`,`number`,`integer`,`boolean`,`array`,`object`];function Lu(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 Ru(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 zu(e,t){let n=t?.[e.slug];return typeof n==`boolean`?n:e.defaultOn}function Bu(e,t){return e.filter(e=>zu(e,t))}var Vu={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},Hu=/^[A-Za-z0-9_-]+$/;function Uu(e){return typeof e==`string`&&e.length>0&&e.length<=Vu.entryTool&&Hu.test(e)}function Wu(e){return Math.ceil(e.length/4)}function Gu(e){return Wu(`${e.entryTool} ${e.description}`)+55}function Ku(e){return e.tokensPerRequest??Gu(e)+(e.promptLine?Wu(e.promptLine):0)}var qu=us({type:bs(Iu),required:ns().optional(),enum:cs(fs([R(),Qo()])).optional(),description:R().optional()}),Ju=us({slug:R().min(1),description:R(),params:vs(R(),qu),permission:bs(Fu),sort:Qo()}),Yu=us({version:R(),url:R(),sha256:R(),sizeBytes:Qo(),exe:R(),format:Ss(`zip`)}),Xu=us({slug:R().min(1),name:R(),entryTool:R().refine(Uu,`not a valid tool name`),description:R(),promptLine:R().nullable(),details:R().nullable().optional(),status:bs(Pu),defaultOn:ns(),sort:Qo(),install:Yu.nullable(),actions:cs(Ju),connector:Au.nullable().optional().catch(null)}).loose();us({platform:bs(Nu),version:R(),packs:cs(Xu),refreshMinutes:Qo()});var Zu=bs([`stdio`,`sse`,`http`]),Qu=us({id:R().trim().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/i,`ID must be 1-64 alphanumeric, dash, dot, or underscore characters`),name:R().trim().min(1).max(100),description:R().max(500).optional(),transport:Zu,command:R().min(1).max(500).optional(),args:cs(R()).max(100).optional(),env:vs(R(),R()).optional(),url:R().url().max(2e3).optional(),headers:vs(R(),R()).optional(),defaultOn:ns(),enabled:ns().optional(),catalogId:R().max(100).optional()});Qu.refine(e=>e.transport===`stdio`?typeof e.command==`string`&&e.command.length>0:typeof e.url==`string`&&e.url.length>0,{message:`stdio transport requires a command; sse/http transports require a url`}),Qu.partial(),vs(R().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/i),ns()).refine(e=>Object.keys(e).length<=128,`At most 128 MCP server switches`);function $u(e,t){if(e.enabled===!1)return!1;let n=t?t[e.id]:void 0;return typeof n==`boolean`?n:e.defaultOn}function ed(e,t,n){return{...e??{},[t]:n}}var td=[{id:`databases`,label:`Databases`},{id:`cloud`,label:`Cloud & DevOps`},{id:`productivity`,label:`Productivity`},{id:`analytics`,label:`Analytics`},{id:`ai`,label:`AI & Reasoning`},{id:`developer`,label:`Developer Tools`}],nd=[{id:`postgres`,name:`PostgreSQL`,description:`Inspect schemas, query tables, run read operations and analyze database structures.`,category:`databases`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-postgres`,"${connectionString}"],parameters:[{key:`connectionString`,label:`Database Connection URL`,placeholder:`postgresql://user:password@localhost:5432/dbname`,type:`password`,required:!0,target:`arg`,templateIndex:2}],docsUrl:`https://github.com/modelcontextprotocol/servers/tree/main/src/postgres`},{id:`sqlite`,name:`SQLite`,description:`Direct SQL query and schema inspection for local SQLite database files.`,category:`databases`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-sqlite`,`--db-path`,"${dbPath}"],parameters:[{key:`dbPath`,label:`SQLite File Path`,placeholder:`C:/data/app.db or /var/data/app.db`,type:`string`,required:!0,target:`arg`,templateIndex:3}],docsUrl:`https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite`},{id:`supabase`,name:`Supabase`,description:`Manage Supabase Postgres database, migrations, edge functions, and project config.`,category:`databases`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-supabase`],parameters:[{key:`SUPABASE_ACCESS_TOKEN`,label:`Personal Access Token`,type:`password`,required:!0,target:`env`},{key:`SUPABASE_PROJECT_REF`,label:`Project Reference ID`,placeholder:`abcdefghijklmnopqrst`,type:`string`,required:!0,target:`env`}],docsUrl:`https://supabase.com/docs/guides/ai/mcp`},{id:`redis`,name:`Redis`,description:`Inspect keys, data structures, and execute Redis operational commands.`,category:`databases`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-redis`,"${redisUrl}"],parameters:[{key:`redisUrl`,label:`Redis Connection URL`,placeholder:`redis://localhost:6379`,type:`string`,required:!0,target:`arg`,templateIndex:2}]},{id:`mongodb`,name:`MongoDB Atlas`,description:`Query collections, inspect schemas, and interact with MongoDB Atlas databases.`,category:`databases`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-mongodb`,"${connectionString}"],parameters:[{key:`connectionString`,label:`MongoDB Connection URI`,placeholder:`mongodb+srv://user:pass@cluster.mongodb.net/dbname`,type:`password`,required:!0,target:`arg`,templateIndex:2}]},{id:`github`,name:`GitHub`,description:`Search repositories, manage issues, pull requests, files, and branches.`,category:`cloud`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-github`],parameters:[{key:`GITHUB_PERSONAL_ACCESS_TOKEN`,label:`GitHub Personal Access Token (repo scope)`,placeholder:`ghp_...`,type:`password`,required:!0,target:`env`}],docsUrl:`https://github.com/modelcontextprotocol/servers/tree/main/src/github`},{id:`gitlab`,name:`GitLab`,description:`Access GitLab merge requests, project branches, issues, and pipelines.`,category:`cloud`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-gitlab`],parameters:[{key:`GITLAB_PERSONAL_ACCESS_TOKEN`,label:`GitLab Personal Access Token`,type:`password`,required:!0,target:`env`},{key:`GITLAB_API_URL`,label:`GitLab API URL (optional for self-hosted)`,placeholder:`https://gitlab.com/api/v4`,type:`string`,required:!1,target:`env`}]},{id:`cloudflare`,name:`Cloudflare`,description:`Inspect and manage Cloudflare Workers, KV namespaces, D1 databases, and DNS records.`,category:`cloud`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@cloudflare/mcp-server-cloudflare`],parameters:[{key:`CLOUDFLARE_API_TOKEN`,label:`API Token`,type:`password`,required:!0,target:`env`},{key:`CLOUDFLARE_ACCOUNT_ID`,label:`Account ID`,type:`string`,required:!0,target:`env`}]},{id:`sentry`,name:`Sentry`,description:`Retrieve real-time application errors, stack traces, and issue analytics.`,category:`cloud`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-sentry`],parameters:[{key:`SENTRY_AUTH_TOKEN`,label:`Auth Token`,type:`password`,required:!0,target:`env`}]},{id:`google-drive`,name:`Google Drive`,description:`Search, read, and export documents, spreadsheets, and files from Google Drive.`,category:`productivity`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-gdrive`],docsUrl:`https://github.com/modelcontextprotocol/servers/tree/main/src/gdrive`},{id:`slack`,name:`Slack`,description:`Read conversation history, search channel messages, and post updates to Slack channels.`,category:`productivity`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-slack`],parameters:[{key:`SLACK_BOT_TOKEN`,label:`Bot User OAuth Token (xoxb-...)`,type:`password`,required:!0,target:`env`},{key:`SLACK_TEAM_ID`,label:`Slack Workspace Team ID`,type:`string`,required:!0,target:`env`}]},{id:`notion`,name:`Notion`,description:`Read and update Notion workspaces, databases, pages, and blocks.`,category:`productivity`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-notion`],parameters:[{key:`NOTION_API_KEY`,label:`Internal Integration Secret (secret_...)`,type:`password`,required:!0,target:`env`}]},{id:`linear`,name:`Linear`,description:`Track issues, cycles, projects, and comments in Linear.`,category:`productivity`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-linear`],parameters:[{key:`LINEAR_API_KEY`,label:`Personal API Key`,type:`password`,required:!0,target:`env`}]},{id:`posthog`,name:`PostHog`,description:`Query product analytics funnels, trends, user session paths, and feature flags.`,category:`analytics`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@posthog/mcp-server-posthog`],parameters:[{key:`POSTHOG_API_KEY`,label:`Personal API Key`,type:`password`,required:!0,target:`env`},{key:`POSTHOG_PROJECT_ID`,label:`Project ID`,type:`string`,required:!0,target:`env`}]},{id:`brave-search`,name:`Brave Search`,description:`Search the live web and discover local points of interest via Brave Search API.`,category:`ai`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-brave-search`],parameters:[{key:`BRAVE_API_KEY`,label:`Brave Search API Key`,type:`password`,required:!0,target:`env`}]},{id:`memory-graph`,name:`Memory (Knowledge Graph)`,description:`Persistent knowledge-graph entity and relation memory across agent turns.`,category:`ai`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-memory`]},{id:`puppeteer`,name:`Puppeteer Headless Browser`,description:`Automate browser navigation, take page screenshots, and scrape dynamic web content.`,category:`ai`,transport:`stdio`,defaultCommand:`npx`,defaultArgs:[`-y`,`@modelcontextprotocol/server-puppeteer`]},{id:`remote-sse`,name:`Remote SSE MCP Server`,description:`Connect to any hosted remote MCP server over Server-Sent Events (SSE).`,category:`developer`,transport:`sse`,defaultUrl:`https://`,parameters:[{key:`url`,label:`SSE Endpoint URL`,placeholder:`https://mcp.example.com/sse`,type:`string`,required:!0,target:`url`},{key:`Authorization`,label:`Authorization Header (optional, e.g. Bearer token)`,placeholder:`Bearer ...`,type:`password`,required:!1,target:`header`}]},{id:`remote-http`,name:`Remote Streamable HTTP Server`,description:`Connect to any remote MCP server using standard Streamable HTTP transport.`,category:`developer`,transport:`http`,defaultUrl:`https://`,parameters:[{key:`url`,label:`HTTP Endpoint URL`,placeholder:`https://mcp.example.com/mcp`,type:`string`,required:!0,target:`url`},{key:`Authorization`,label:`Authorization Header (optional, e.g. Bearer token)`,placeholder:`Bearer ...`,type:`password`,required:!1,target:`header`}]}],rd=[`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(`
|
|
87
87
|
`);var id={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},ad={message:`✉️ Message from chat "`,reply:`↩️ Reply from chat "`,continue:`↻ Continue the message from chat "`},od=`⚠ `,sd=`<local-command-stdout>`,cd=`</local-command-stdout>`,ld=/^[A-Za-z0-9._:-]{1,128}$/;function ud(e){let t=(e??``).replace(/["“”]/g,`'`).replace(/\s+/g,` `).trim();if(!t)return`Untitled chat`;let n=id.titleChars;return t.length>n?`${t.slice(0,n-1).trimEnd()}…`:t}function dd(e){return ud(e.title?.trim()||e.firstPrompt?.trim()||`Chat ${e.id.slice(0,8)}`)}function fd(e,t){let n=rd.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 pd=/^\[conv:(\S+) chat:(\S+) host:(\S+) msg:(\S+?)(?: reply-to:(\S+?))?( reply expected)?\]$/;function md(e){if(typeof e!=`string`)return null;let t=e;t.startsWith(sd)&&t.endsWith(cd)&&(t=t.slice(22,t.length-23)),t=t.replace(/\r\n/g,`
|
|
88
88
|
`);let n=t.indexOf(`
|
|
89
89
|
`);if(n<0)return null;let r=t.slice(0,n),i=t.slice(n+1),a=i.indexOf(`
|
|
@@ -548,12 +548,12 @@ else:
|
|
|
548
548
|
`)&&(r.repositories=i);let a=T5(e);Rke(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 zke(e){let t=T5(e),n=w5(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!==1?{minRoutineIntervalMinutes:r}:{}}}function Bke(e,t){if(t===null){let t=C5(null);return Object.keys(t).some(n=>e[n]!==t[n])}return Object.keys(D5(e,t)).length>0}function O5(e){let t=typeof window<`u`?window.oonacode:void 0;t?.openExternal?t.openExternal(e):window.open(e,`_blank`,`noopener,noreferrer`)}function Vke({open:e,onClose:t}){let{state:n,actions:r}=V(),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`?O5(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 ee=m?.command?`${m.command.file} ${m.command.args.join(` `)}`:null,M=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`)}},te=async()=>{if(o.trim()){l(!0);try{await r.submitClaudeLoginCode(o)&&s(``)}finally{l(!1)}}},ne=A?(0,B.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2`,children:[(0,B.jsx)(U,{onClick:t,"data-testid":`claude-login-close`,children:`Close`}),(0,B.jsxs)(U,{onClick:()=>r.openClaudeLogin(`copy`),"data-testid":`claude-login-copy-mode`,children:[(0,B.jsx)(H.Copy,{className:`w-4 h-4`}),` Copy link`]}),(0,B.jsxs)(U,{variant:`primary`,onClick:()=>r.openClaudeLogin(`open`),"data-testid":`claude-login-open-mode`,children:[(0,B.jsx)(H.LogIn,{className:`w-4 h-4`}),` Sign in with my subscription`]})]}):j||m?(0,B.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[O?null:(0,B.jsx)(U,{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,B.jsx)(U,{variant:`primary`,onClick:t,"data-testid":`claude-login-close`,children:`Close`})]}):(0,B.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[(0,B.jsx)(U,{onClick:t,children:`Keep in background`}),(0,B.jsx)(U,{variant:`danger`,onClick:()=>void r.cancelClaudeLogin(),"data-testid":`claude-login-cancel`,children:`Cancel sign-in`})]});return(0,B.jsx)(gC,{open:e,title:`Connect your Claude subscription`,onClose:t,footer:ne,children:(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.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,B.jsxs)(`div`,{className:`space-y-2 text-sm`,"data-testid":`claude-login-choose`,children:[(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`span`,{className:`font-medium`,children:`Sign in with my subscription`}),` opens the Claude sign-in page in this PC's browser.`]}),(0,B.jsxs)(`p`,{children:[(0,B.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,B.jsx)(`p`,{className:`text-fg-faint`,children:`Either way this window connects by itself when you finish signing in.`})]}):null,A?null:(0,B.jsx)(`div`,{className:`rounded-md border border-border bg-surface-2 p-3 text-xs`,"data-testid":`claude-login-wait`,children:D?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`mb-1 text-fg-faint`,children:a===`copy`?`Sign-in link (copied):`:`Sign-in link (opened in your browser):`}),(0,B.jsx)(`div`,{className:`break-all font-mono select-all`,"data-testid":`claude-login-url`,children:D}),(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,B.jsxs)(U,{size:`sm`,onClick:()=>void M(),"data-testid":`claude-login-copy`,children:[(0,B.jsx)(H.Copy,{className:`w-3 h-3`}),` `,u?`Copied`:`Copy link`]}),(0,B.jsx)(U,{size:`sm`,onClick:()=>O5(D),children:`Open in browser`})]})]}):O?null:(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-fg-muted`,children:[(0,B.jsx)(H.Spinner,{className:`w-4 h-4 animate-spin`}),` Preparing your sign-in link…`]})}),(0,B.jsx)(`div`,{className:z(`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,B.jsx)(`div`,{className:`text-xs`,children:f?(0,B.jsx)(fC,{label:`The page showed a code instead? Paste it here`,children:(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`input`,{className:pC,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`&&te()}}),(0,B.jsx)(U,{variant:`primary`,busy:c,disabled:!o.trim(),onClick:()=>void te(),"data-testid":`claude-login-submit`,children:`Continue`})]})}):(0,B.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,ee?(0,B.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-2 p-3 text-xs`,children:[(0,B.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,B.jsx)(QI,{code:ee,language:n.info?.platform===`win32`?`powershell`:`bash`})]}):null]})})}function k5({compact:e=!1}){let{actions:t}=V(),[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,O5(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,B.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,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(H.GitBranch,{className:`h-4 w-4 shrink-0`}),g?(0,B.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,"data-testid":`github-linked`,children:[`GitHub linked as `,(0,B.jsxs)(`b`,{children:[`@`,g.login]}),g.name?(0,B.jsxs)(`span`,{className:`text-fg-muted`,children:[` · `,g.name]}):null]}):(0,B.jsx)(`span`,{className:`min-w-0 flex-1`,children:`GitHub not linked`}),g?(0,B.jsx)(U,{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,B.jsx)(U,{size:`sm`,variant:`primary`,disabled:i,onClick:()=>void m(`start`),"data-testid":`github-link-start`,children:`Link GitHub`}):null]}),f?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`github-link-pending`,children:[(0,B.jsxs)(`p`,{className:`text-fg-muted`,children:[`GitHub’s page opened in your browser. If it did not, open`,` `,(0,B.jsx)(`a`,{className:`underline`,href:p??`#`,onClick:e=>{e.preventDefault(),p&&O5(p)},children:p}),` `,`on any device and enter:`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.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,B.jsxs)(U,{size:`sm`,onClick:()=>n.login.userCode&&h(n.login.userCode),children:[(0,B.jsx)(H.Copy,{className:`h-3.5 w-3.5`}),` `,c?`Copied`:`Copy`]}),(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>void m(`cancel`),children:`Cancel`})]}),(0,B.jsx)(`p`,{className:`text-xs text-fg-faint`,children:`Waiting for GitHub…`})]}):null,_?(0,B.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,B.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 A5=`__new__`;function j5({title:e,children:t}){return(0,B.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3 first:border-t-0 first:pt-0`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:e}),t]})}function Hke({open:e,startNew:t=!1,selectId:n=null,onClose:r}){let{state:i,actions:a}=V(),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)(A5),[u,d]=(0,v.useState)(C5(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?A5:r??o[0]?.id??A5),h(!1)},[e]);let _=c===A5?null:o.find(e=>e.id===c)??null;(0,v.useEffect)(()=>{d(C5(_)),h(!1)},[_?.id,_?.updatedAt]);let y=(0,v.useMemo)(()=>i.providers.filter(e=>e.configured).flatMap(e=>e.definition.models.map(t=>({key:x5(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?S5(u.model):null,S=b?Ve(b.option):[],C=Bke(u,_),w=C?E5(u):null;async function T(){if(!E5(u)){p(!0);try{if(_===null){let e=await a.createVaultProject(zke(u));e&&l(e.id)}else await a.updateVaultProject(_.id,D5(u,_))}finally{p(!1)}}}async function E(){if(_){if(!m){h(!0);return}p(!0);try{await a.deleteVaultProject(_.id)&&l(A5)}finally{p(!1)}}}async function D(){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,B.jsx)(gC,{open:e,title:`Projects`,onClose:r,wide:!0,footer:(0,B.jsxs)(B.Fragment,{children:[_?j>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-xs text-fg-muted`,"data-testid":`project-delete-reason`,children:O(j)}),(0,B.jsx)(U,{variant:`ghost`,disabled:!0,"data-testid":`project-delete`,children:`Delete project`})]}):(0,B.jsx)(U,{variant:m?`danger`:`ghost`,onClick:E,disabled:f,"data-testid":`project-delete`,children:m?`Delete ${_.name}?`:`Delete project`}):null,(0,B.jsx)(`span`,{className:`flex-1`}),w?(0,B.jsx)(`span`,{className:`text-xs text-danger`,"data-testid":`project-problem`,children:w}):null,(0,B.jsx)(U,{variant:`ghost`,onClick:r,children:`Close`}),(0,B.jsx)(U,{variant:`primary`,onClick:T,disabled:f||!C||w!==null,"data-testid":`project-save`,children:_===null?`Create project`:`Save`})]}),children:(0,B.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[180px_1fr]`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`projects-list`,children:[(0,B.jsxs)(`button`,{type:`button`,className:z(`flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,c===A5?`bg-accent-soft text-fg`:`hover:bg-surface-2 text-fg-muted`),onClick:()=>l(A5),"data-testid":`project-new`,children:[(0,B.jsx)(H.Plus,{className:`w-3.5 h-3.5`}),` New project`]}),o.map(e=>(0,B.jsxs)(`button`,{type:`button`,className:z(`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,B.jsx)(H.Project,{className:`w-3.5 h-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,B.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:A(e)})]},e.id))]}),(0,B.jsxs)(`div`,{className:`max-h-[65vh] space-y-4 overflow-y-auto pr-1`,children:[(0,B.jsxs)(j5,{title:`Project`,children:[(0,B.jsx)(fC,{label:`Name`,children:(0,B.jsx)(`input`,{className:pC,value:u.name,onChange:e=>g(`name`,e.target.value),placeholder:`My app`,maxLength:Sc.name,"data-testid":`project-name`})}),(0,B.jsx)(fC,{label:`Goal (optional)`,hint:`What the project is for, in a line or two.`,children:(0,B.jsx)(`input`,{className:pC,value:u.goal,onChange:e=>g(`goal`,e.target.value),placeholder:`A desktop app that…`,maxLength:Sc.goal,"data-testid":`project-goal`})}),(0,B.jsx)(fC,{label:`Instructions for the agent (optional)`,children:(0,B.jsx)(`textarea`,{className:z(pC,`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.
|
|
549
549
|
- push to the feature branch, never to main
|
|
550
550
|
- run the tests before saying a change is done
|
|
551
|
-
- use the browser on port 9170 for anything on the web`,maxLength:Sc.instructions,"data-testid":`project-instructions`})})]}),(0,B.jsxs)(j5,{title:`Repositories`,children:[(0,B.jsx)(fC,{label:`One per line (optional)`,hint:`Every chat in the project is told about them.`,children:(0,B.jsx)(`textarea`,{className:z(pC,`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,B.jsx)(k5,{compact:!0})]}),(0,B.jsxs)(j5,{title:`New chats`,children:[(0,B.jsx)(fC,{label:`Model`,hint:`What a new chat in this project starts on.`,children:(0,B.jsxs)(`select`,{className:pC,value:u.model,onChange:e=>{g(`model`,e.target.value),g(`effort`,``)},"data-testid":`project-model`,children:[(0,B.jsx)(`option`,{value:``,children:`Whatever a new chat would start on`}),x?(0,B.jsxs)(`option`,{value:u.model,children:[x.model,` (not on this PC)`]}):null,y.map(e=>(0,B.jsx)(`option`,{value:e.key,children:e.label},e.key))]})}),S.length>0?(0,B.jsx)(fC,{label:`Effort`,children:(0,B.jsxs)(`select`,{className:pC,value:u.effort,onChange:e=>g(`effort`,e.target.value),"data-testid":`project-effort`,children:[(0,B.jsx)(`option`,{value:``,children:b&&Be(b.option)?`Default (${Be(b.option)})`:`Default`}),S.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})}):null,(0,B.jsx)(fC,{label:`Folder`,hint:`Where a new chat runs; left empty, each chat gets its own.`,children:(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`input`,{className:z(pC,`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,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>void D(),children:`Choose…`}):null]})})]}),(0,B.jsxs)(j5,{title:`Memory`,children:[(0,B.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:u.memoryEnabled,onChange:e=>g(`memoryEnabled`,e.target.checked),"data-testid":`project-memory-enabled`}),(0,B.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,B.jsx)(`textarea`,{className:z(pC,`h-28 font-mono text-xs`),value:u.memory,onChange:e=>g(`memory`,e.target.value),placeholder:`Nothing noted yet.`,maxLength:Sc.memory,"data-testid":`project-memory`}):null]}),(0,B.jsxs)(j5,{title:`Scheduled tasks`,children:[(0,B.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:u.tasksEnabled,onChange:e=>g(`tasksEnabled`,e.target.checked),"data-testid":`project-tasks-enabled`}),(0,B.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,B.jsx)(fC,{label:`Shortest repeat, in minutes`,children:(0,B.jsx)(`input`,{className:z(pC,`w-28`),inputMode:`numeric`,value:u.minInterval,onChange:e=>g(`minInterval`,e.target.value),"data-testid":`project-min-interval`})}):null,_?(0,B.jsx)(CL,{projectId:_.id,showChat:!0}):null]}),(0,B.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.`})]})]})})}function Uke({open:e,onClose:t}){return(0,B.jsx)(gC,{open:e,title:`Export my chats`,onClose:t,children:(0,B.jsx)(Wke,{onDone:t})})}function Wke({onDone:e}){let{api:t,state:n}=V(),[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,B.jsxs)(`div`,{children:[(0,B.jsx)(gC,{open:a,title:`Exporting your chats`,onClose:()=>void 0,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(H.Spinner,{className:`mt-0.5 w-5 h-5 shrink-0 text-accent`}),(0,B.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,B.jsxs)(`div`,{className:`font-medium`,children:[`Packing`,` `,p>0?`${p} chat${p===1?``:`s`}`:`your chats`,`…`]}),(0,B.jsxs)(`div`,{className:`mt-1 tabular text-fg-muted`,children:[Math.floor(d/60),`:`,String(d%60).padStart(2,`0`),` elapsed`]}),(0,B.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,B.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`One zip with a plain `,(0,B.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,B.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,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`input`,{type:`password`,autoFocus:!0,className:pC+` 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,B.jsx)(U,{onClick:()=>void m(),disabled:a||!r,children:a?`Exporting…`:`Export`}),(0,B.jsx)(U,{variant:`ghost`,onClick:()=>{u(!1),i(``),c(null)},children:`Cancel`})]}):(0,B.jsx)(U,{className:`mt-2`,onClick:()=>u(!0),"data-testid":`export-chats`,children:`Export chats…`}),s?(0,B.jsx)(`div`,{className:`mt-2 text-xs text-danger`,children:s}):null]})}function Gke({open:e,onClose:t}){return(0,B.jsx)(gC,{open:e,title:`Clean up chat folders`,onClose:t,wide:!0,children:(0,B.jsx)(Yke,{open:e,onDone:t})})}function M5(e,t){let n=HF(e)||`0 B`;return t?n:`at least ${n}`}var Kke={chat_exists:`a chat uses it`,recent:`changed in the last day`,invalid:`not a chat folder`,not_found:`already gone`,error:`could not be removed`};function qke(e){let t=Math.floor((Date.now()-e)/864e5);if(t<30)return Rv(e);if(t<60)return`${t} days ago`;if(t<365){let e=Math.floor(t/30);return`${e} ${e===1?`month`:`months`} ago`}let n=Math.floor(t/365);return`${n} ${n===1?`year`:`years`} ago`}function N5(e){if(!e)return``;let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=new Date(t).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`}),r=qke(t);return r?`${n} (${r})`:n}function P5(e){return e.onlyScaffolding?e.files===0&&e.sample.length===0?`Empty folder`:`Empty, apart from OonaCode’s permission memory`:e.sample.length>0?e.sample.join(`, `):`Files in its .claude folder`}function Jke(e){let t=e.slice(0,3).map(e=>`“${e}”`),n=e.length-t.length;return n>0?`${t.join(`, `)} and ${n} more`:t.join(`, `)}function Yke({open:e,onDone:t}){let{api:n}=V(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(new Set),[d,f]=(0,v.useState)(new Set),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),b=(0,v.useCallback)(async()=>{if(!n.workspaceCleanupScan){c(`This PC is running an older OonaCode that cannot clean chat folders. Update OonaCode first.`);return}o(!0),c(null);try{let e=await n.workspaceCleanupScan();i(e),u(new Set(e.orphans.filter(e=>e.deletable&&e.onlyScaffolding).map(e=>e.id))),f(new Set)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[n]);(0,v.useEffect)(()=>{e&&(y(null),m(!1),b())},[e,b]);let x=(0,v.useMemo)(()=>new Map((r?.orphans??[]).map(e=>[e.id,e])),[r]),S=r?.leftBehind.entries??[],C=(0,v.useMemo)(()=>new Map((r?.leftBehind.entries??[]).map(e=>[e.id,e])),[r]),w=(r?.orphans??[]).filter(e=>e.deletable&&e.onlyScaffolding),T=(r?.orphans??[]).filter(e=>e.deletable&&!e.onlyScaffolding),E=(r?.orphans??[]).filter(e=>!e.deletable),D=[...l].map(e=>x.get(e)).filter(e=>!!e),O=[...d].map(e=>C.get(e)).filter(e=>!!e&&e.deletable),k=D.length+O.length,A=D.reduce((e,t)=>e+t.sizeBytes,0)+O.reduce((e,t)=>e+t.sizeBytes,0),j=D.every(e=>e.sizeExact)&&O.every(e=>e.sizeExact),ee=e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),M=e=>f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),te=async()=>{if(!n.workspaceCleanupDelete||k===0)return;g(!0),c(null);let e={};for(let t of D)e[t.id]=`Folder ${t.id.slice(0,8)}`;for(let t of O)e[t.id]=`Folder ${t.id.slice(0,8)} of the chat “${t.chatTitle}”`;try{let t=await n.workspaceCleanupDelete({ids:[...D.map(e=>e.id),...O.map(e=>e.id)],...O.length>0?{includeMoved:!0}:{}});y({...t,labels:e}),m(!1),await b()}catch(e){c(e instanceof Error?e.message:String(e))}finally{g(!1)}},ne=e=>{let t=window.oonacode?.showItemInFolder;typeof t==`function`&&t(e)},N=typeof window.oonacode?.showItemInFolder==`function`,P=e=>N?(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>ne(e.path),"aria-label":`Show ${e.id.slice(0,8)} in its folder`,title:`Show in folder`,children:(0,B.jsx)(H.Folder,{className:`h-3.5 w-3.5`})}):null,re=e=>[e.createdAt?`Created ${N5(e.createdAt)}`:``,`Last changed ${N5(e.changedAt)}`].filter(Boolean).join(` · `),ie=e=>(0,B.jsx)(`div`,{className:`select-text break-all font-mono text-[11px] text-fg-muted`,"data-testid":`cleanup-path`,children:e.path}),ae=e=>(0,B.jsxs)(`li`,{className:`flex items-start gap-3 py-2.5`,"data-testid":`cleanup-row`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:l.has(e.id),onChange:()=>ee(e.id),"aria-label":`Select folder ${e.id.slice(0,8)} for deletion: no chat uses it, ${M5(e.sizeBytes,e.sizeExact)}, last changed ${N5(e.changedAt)}`,"data-testid":`cleanup-pick-${e.id}`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:M5(e.sizeBytes,e.sizeExact)}),e.files>0?(0,B.jsxs)(`span`,{className:`text-fg-muted`,children:[e.files,` files`]}):null,(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-ok-soft px-2 py-0.5 text-xs font-medium text-ok`,"data-testid":`cleanup-orphan-badge`,children:[(0,B.jsx)(H.Check,{className:`h-3 w-3`}),`No chat uses this folder - safe to delete`]})]}),(0,B.jsx)(`div`,{className:`text-xs text-fg-muted`,"data-testid":`cleanup-dates`,children:re(e)}),(0,B.jsxs)(`div`,{className:`text-xs`,"data-testid":`cleanup-contents`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`Inside: `}),P5(e)]}),ie(e)]}),P(e)]},e.id),oe=e=>(0,B.jsxs)(`li`,{className:`flex items-start gap-3 py-2.5`,"data-testid":`cleanup-moved-row`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:d.has(e.id),disabled:!e.deletable,onChange:()=>M(e.id),"aria-label":`Select the old folder of the chat “${e.chatTitle}” for deletion, ${M5(e.sizeBytes,e.sizeExact)}. The chat still exists.`,"data-testid":`cleanup-moved-pick-${e.id}`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium`,"data-testid":`cleanup-moved-title`,children:e.chatTitle}),(0,B.jsxs)(`div`,{className:`text-xs text-fg-muted`,"data-testid":`cleanup-moved-cwd`,children:[`Now works in `,(0,B.jsx)(`span`,{className:`select-text break-all font-mono`,children:e.chatCwd})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 text-sm`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:M5(e.sizeBytes,e.sizeExact)}),e.files>0?(0,B.jsxs)(`span`,{className:`text-fg-muted`,children:[e.files,` files`]}):null]}),(0,B.jsxs)(`div`,{className:`text-xs`,"data-testid":`cleanup-contents`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`Inside: `}),P5(e)]}),(0,B.jsxs)(`div`,{className:`text-xs text-fg-muted`,"data-testid":`cleanup-dates`,children:[re(e),e.chatUpdatedAt?` · Chat last used ${N5(e.chatUpdatedAt)}`:``]}),(0,B.jsx)(`p`,{className:`text-xs text-warn`,"data-testid":`cleanup-moved-note`,children:`Left over from before the chat moved; the chat’s old messages may mention files in it.`}),e.deletable?null:(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`cleanup-moved-kept`,children:e.recent?`Changed in the last day, so it is kept for now.`:`Another chat is working in this folder, so it is kept.`}),ie(e)]}),P(e)]},e.id),se=[...w,...T].map(e=>e.id),F=r?.leftBehind.count??0;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm`,"data-testid":`workspace-cleanup`,children:[(0,B.jsx)(`p`,{className:`text-fg-muted`,children:`A chat with no project runs in a folder of its own. Deleting the chat keeps that folder when something was written in it, so folders of chats you deleted long ago are still on your disk.`}),s?(0,B.jsx)(`p`,{role:`alert`,className:`rounded-md bg-danger-soft px-3 py-2 text-danger`,children:s}):null,a&&!r?(0,B.jsx)(`p`,{className:`text-fg-muted`,children:`Looking at your chat folders…`}):null,_?(0,B.jsxs)(`div`,{className:`rounded-md bg-surface-2 px-3 py-2`,role:`status`,"data-testid":`cleanup-result`,children:[(0,B.jsxs)(`p`,{children:[`Deleted `,_.removed.length,` `,_.removed.length===1?`folder`:`folders`,`, freeing `,HF(_.freedBytes)||`0 B`,`.`,_.skipped.length>0?` Kept ${_.skipped.length}, with the reason for ${_.skipped.length===1?`it`:`each`}:`:``]}),_.skipped.length>0?(0,B.jsx)(`ul`,{className:`mt-1 list-disc pl-5 text-xs`,"data-testid":`cleanup-result-kept`,children:_.skipped.map(e=>(0,B.jsxs)(`li`,{"data-testid":`cleanup-result-kept-row`,children:[_.labels[e.id]??`Folder ${e.id.slice(0,8)}`,`:`,` `,Kke[e.reason]??e.reason,e.message?` - ${e.message}`:``]},e.id))}):null]}):null,r&&r.orphans.length===0?(0,B.jsxs)(`p`,{"data-testid":`cleanup-nothing`,children:[`Nothing to clean up. Every folder under`,` `,(0,B.jsx)(`span`,{className:`font-mono text-xs`,children:r.root}),` belongs to a chat you still have.`]}):null,r&&r.orphans.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`p`,{"data-testid":`cleanup-summary`,children:[(0,B.jsx)(`strong`,{children:r.totals.orphanCount}),` `,r.totals.orphanCount===1?`folder belongs`:`folders belong`,` to chats you deleted (`,M5(r.totals.orphanBytes,r.totals.sizeExact),`).`]}),(0,B.jsx)(`p`,{className:`rounded-md bg-ok-soft px-3 py-2 text-ok`,"data-testid":`cleanup-orphan-statement`,children:r.totals.orphanCount===1?`This folder has no chat in OonaCode’s database on this PC (checked across every account on this PC). It is a leftover of a deleted chat and is safe to delete.`:`These folders have no chat in OonaCode’s database on this PC (checked across every account on this PC). They are leftovers of deleted chats and are safe to delete.`}),w.length>0?(0,B.jsxs)(`section`,{children:[(0,B.jsxs)(`h3`,{className:`mb-1 font-medium`,children:[`Nothing of yours inside (`,w.length,`)`]}),(0,B.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border px-3`,children:w.map(ae)})]}):null,T.length>0?(0,B.jsxs)(`section`,{children:[(0,B.jsxs)(`h3`,{className:`mb-1 font-medium`,children:[`Files inside (`,T.length,`)`]}),(0,B.jsx)(`p`,{className:`mb-1 text-xs text-fg-muted`,children:`Files the assistant made or you pasted in those chats. Not ticked: look first, a delete removes them for good.`}),(0,B.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border px-3`,children:T.map(ae)})]}):null,E.length>0?(0,B.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`cleanup-recent`,children:[E.length,` `,E.length===1?`folder was`:`folders were`,` changed in the last day and `,E.length===1?`is`:`are`,` kept for now (a chat you are still starting may use `,E.length===1?`it`:`them`,`).`]}):null]}):null,r&&F>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`cleanup-left-behind`,children:[F,` `,F===1?`chat you still have moved`:`chats you still have moved`,` to another folder and left `,M5(r.leftBehind.bytes,r.leftBehind.sizeExact),` in`,` `,F===1?`its`:`their`,` old `,F===1?`folder`:`folders`,`.`,S.length>0?``:` Those stay.`]}),S.length>0?(0,B.jsxs)(`section`,{"data-testid":`cleanup-moved`,children:[(0,B.jsxs)(`h3`,{className:`mb-1 font-medium`,children:[`Chats you still have, now working elsewhere (`,S.length,`)`]}),(0,B.jsx)(`p`,{className:`mb-1 text-xs text-fg-muted`,children:`These chats still exist, so their folders are not leftovers of deleted chats. Not ticked. Delete one only if you are sure you do not need what that chat made there.`}),(0,B.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border px-3`,children:S.map(oe)})]}):null]}):null,p?(0,B.jsxs)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-3`,role:`alertdialog`,"aria-label":`Confirm delete`,children:[(0,B.jsxs)(`p`,{className:`text-danger`,"data-testid":`cleanup-confirm-text`,children:[`Delete `,k,` `,k===1?`folder`:`folders`,` (`,M5(A,j),`) and everything inside? This cannot be undone.`]}),O.length>0?(0,B.jsxs)(`p`,{className:`mt-2 font-medium text-danger`,"data-testid":`cleanup-confirm-moved-warning`,children:[O.length,` of these`,` `,O.length===1?`belongs to a chat`:`belong to chats`,` you still have:`,` `,Jke(O.map(e=>e.chatTitle)),`. The`,` `,O.length===1?`chat stays`:`chats stay`,`, but the files made before`,` `,O.length===1?`it`:`they`,` moved will be gone, and old messages that mention them will point at nothing.`]}):null,(0,B.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,B.jsx)(U,{variant:`danger`,busy:h,onClick:()=>void te(),"data-testid":`cleanup-confirm`,children:`Delete forever`}),(0,B.jsx)(U,{variant:`ghost`,onClick:()=>m(!1),disabled:h,children:`Cancel`})]})]}):(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(U,{variant:`danger`,disabled:k===0||h,onClick:()=>m(!0),"data-testid":`cleanup-delete`,children:[(0,B.jsx)(H.Trash,{className:`h-3.5 w-3.5`}),k===0?`Delete…`:`Delete ${k} ${k===1?`folder`:`folders`} (${M5(A,j)})…`]}),se.length>0?(0,B.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>u(new Set(se)),title:`Tick every folder of a deleted chat (never the folders of chats you still have)`,"data-testid":`cleanup-all`,children:`Select all`}):null,se.length>0||S.length>0?(0,B.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>{u(new Set),f(new Set)},"data-testid":`cleanup-none`,children:`Select none`}):null,(0,B.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>void b(),disabled:a,"data-testid":`cleanup-rescan`,children:[(0,B.jsx)(H.Refresh,{className:`h-3.5 w-3.5`}),` Rescan`]}),(0,B.jsx)(U,{variant:`ghost`,size:`sm`,onClick:t,className:`ml-auto`,children:`Close`})]})]})}var F5=3,I5=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function Xke(e){let t=e.scope;return t.kind===`all`?`Every chat on this PC${e.chatCount===void 0?``:` (${I5(e.chatCount,`chat`)} now)`}, and chats made later`:t.kind===`chats`?I5(t.chatIds.length,`chosen chat`):`Project “${e.projectName??`one project`}”${e.chatCount===void 0?``:` (${I5(e.chatCount,`chat`)} now)`}, and chats filed under it later`}function L5(e,t,n){let r=e.chats?.find(e=>e.id===n);if(r)return r.present?r.title:null;let i=t.find(e=>e.id===n);return i?Gv(i):null}var Zke=e=>e?`“${e}”`:`a chat no longer here`;function Qke(e,t,n){let r=(e.chatIds??[]).map(e=>Zke(L5(t,n,e)));return e.outcome===`refused`?`was refused (${e.call.replace(`_`,` `)})`:e.call===`list_chats`?`listed ${I5(e.chats,`chat`)}`:e.call===`read_chat`?r.length>0?`read ${r.join(`, `)}`:`read 1 chat`:r.length>0?`searched, found in ${r.join(`, `)}`:`searched ${I5(e.chats,`chat`)}`}function $ke({grant:e,sessions:t}){if(e.scope.kind===`all`)return(0,B.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,"data-testid":`ai-tool-chats-${e.id}`,children:[`Every chat on this PC`,e.chatCount===void 0?``:` (${e.chatCount} now)`]});let n=e.chats??(e.scope.kind===`chats`?e.scope.chatIds.map(n=>{let r=L5(e,t,n);return{id:n,title:r??`A chat`,present:r!==null}}):[]);if(n.length===0)return(0,B.jsx)(`div`,{className:`mt-1 text-xs text-fg-faint`,"data-testid":`ai-tool-chats-${e.id}`,children:e.scope.kind===`project`?`No chat is filed under this project.`:`No chats.`});let r=n.length-F5+(e.chatsMore??0);return(0,B.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1 text-xs`,"data-testid":`ai-tool-chats-${e.id}`,children:[n.slice(0,F5).map(e=>(0,B.jsx)(`span`,{className:`max-w-[14rem] truncate rounded bg-surface-2 px-1.5 py-0.5 ${e.present?`text-fg`:`text-fg-faint line-through`}`,title:e.present?e.title:`${e.title} (${e.id})`,children:e.title},e.id)),r>0?(0,B.jsxs)(`span`,{className:`text-fg-faint`,children:[`+`,r,` more`]}):null]})}function eAe({grant:e}){let t=e.chats??[],n=e.reads[e.reads.length-1],r=e.status===`revoked`?`Revoked ${e.revokedAt?zv(e.revokedAt):``}`.trim():e.status===`expired`?`Expired ${e.expiresAt?zv(e.expiresAt):``}`.trim():e.expiresAt?`Active until ${zv(e.expiresAt)}`:`Active until you revoke it`;return(0,B.jsxs)(`div`,{className:`mt-2 rounded-md border border-border bg-surface-2 p-2 text-xs`,"data-testid":`ai-tool-details-${e.id}`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(iz,{label:`Status`,value:r}),(0,B.jsx)(iz,{label:`Opens`,value:Xke(e)}),(0,B.jsx)(iz,{label:`Its own key`,value:e.tokenHint?`${e.tokenHint}…`:`made before key hints`}),(0,B.jsx)(iz,{label:`Connected`,value:zv(e.createdAt)}),(0,B.jsx)(iz,{label:`Key replaced`,value:e.keyChangedAt?zv(e.keyChangedAt):null}),(0,B.jsx)(iz,{label:`Lasts`,value:e.lifetime===`hour`?`One hour`:e.lifetime===`day`?`One day`:`Until you revoke it`}),(0,B.jsx)(iz,{label:`Last used`,value:n?zv(n.at):`never`}),(0,B.jsx)(iz,{label:`Calls logged`,value:String(e.reads.length)})]}),(0,B.jsxs)(`div`,{className:`mt-2 border-t border-border pt-2`,children:[(0,B.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:e.scope.kind===`all`?`Chats it can read`:`Chats it can read (${e.chatCount??t.length})`}),e.scope.kind===`all`?(0,B.jsx)(`p`,{className:`text-fg-muted`,children:`Every chat on this PC, the ones you make later too. Choose chats or a project next time to share less.`}):t.length===0?(0,B.jsx)(`p`,{className:`text-fg-faint`,children:`None.`}):(0,B.jsxs)(`ul`,{className:`max-h-48 space-y-0.5 overflow-y-auto`,"data-testid":`ai-tool-details-chats-${e.id}`,children:[t.map(e=>(0,B.jsx)(`li`,{className:`truncate ${e.present?`text-fg`:`text-fg-faint line-through`}`,title:e.present?e.title:`${e.title} (${e.id})`,children:e.title},e.id)),(e.chatsMore??0)>0?(0,B.jsxs)(`li`,{className:`text-fg-faint`,children:[`+`,e.chatsMore,` more`]}):null]})]}),(0,B.jsxs)(`p`,{className:`mt-2 border-t border-border pt-2 text-fg-faint`,children:[`This connection has a key of its own. It opens only the chats above: another connected tool's key cannot read them, and this one cannot read theirs. Revoke ends this key and no other`,e.status===`active`?``:`; Delete takes the ended connection off the list`,`.`]})]})}function tAe({grant:e,sessions:t}){let n=[...e.reads].reverse(),r=[...new Set(n.map(e=>e.client).filter(e=>!!e))];return(0,B.jsxs)(`div`,{className:`mt-2 rounded-md border border-border bg-surface-2 p-2 text-xs`,"data-testid":`ai-tool-activity-${e.id}`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center justify-between gap-2`,children:[(0,B.jsxs)(`span`,{className:`font-medium text-fg`,children:[`Activity — `,I5(n.length,`call`),` logged`,n.length>=Bg.readsKept?` (the last ${Bg.readsKept} are kept)`:``]}),(0,B.jsxs)(`span`,{className:`text-fg-faint`,children:[`Connected `,zv(e.createdAt),e.keyChangedAt?` · key replaced ${zv(e.keyChangedAt)}`:``]})]}),r.length>1?(0,B.jsxs)(`p`,{className:`mb-1 text-warn`,"data-testid":`ai-tool-callers-${e.id}`,children:[r.length,` different programs used this key: `,r.join(` · `),`. If you shared it with only one, revoke it or make a new key.`]}):null,n.length===0?(0,B.jsx)(`p`,{className:`text-fg-faint`,children:`Nothing has used this connection yet.`}):(0,B.jsx)(`div`,{className:`max-h-60 overflow-y-auto`,children:(0,B.jsxs)(`table`,{className:`w-full text-left`,children:[(0,B.jsx)(`thead`,{className:`sticky top-0 bg-surface-2 text-fg-faint`,children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{className:`py-0.5 pr-2 font-normal`,children:`When`}),(0,B.jsx)(`th`,{className:`py-0.5 pr-2 font-normal`,children:`Who`}),(0,B.jsx)(`th`,{className:`py-0.5 font-normal`,children:`What`})]})}),(0,B.jsx)(`tbody`,{"data-testid":`ai-tool-activity-rows-${e.id}`,children:n.map((n,r)=>(0,B.jsxs)(`tr`,{className:`align-top`,children:[(0,B.jsx)(`td`,{className:`whitespace-nowrap py-0.5 pr-2 text-fg-muted`,children:zv(n.at)}),(0,B.jsx)(`td`,{className:`max-w-[10rem] truncate py-0.5 pr-2 text-fg-muted`,title:n.client??`not named by the caller`,children:n.client??`—`}),(0,B.jsx)(`td`,{className:n.outcome===`refused`?`py-0.5 text-warn`:`py-0.5 text-fg`,children:Qke(n,e,t)})]},`${n.at}-${r}`))})]})})]})}function nAe({open:e,onClose:t}){return(0,B.jsx)(gC,{open:e,title:`Connect an AI tool`,onClose:t,wide:!0,children:e?(0,B.jsx)(oAe,{}):null})}var rAe=2e3,iAe=6e3,R5={hour:`One hour`,day:`One day`,"until-revoked":`Until I revoke it`};function aAe(e){let t=e.chats,n=`${t} chat${t===1?``:`s`}`,r=e.outcome===`refused`?`refused (${e.call})`:e.call===`list_chats`?`listed ${n}`:e.call===`read_chat`?`read ${n}`:`searched ${n}`;return`${Bv(e.at)} · ${r}`}function oAe(){let{api:e,state:t}=V(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)([]),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)({}),[y,b]=(0,v.useState)(new Set),x=(0,v.useRef)(new Map),S=(e,t)=>_(n=>{let{[e]:r,...i}=n;return r===t?i:{...i,[e]:t}}),[C,w]=(0,v.useState)(null),[T,E]=(0,v.useState)(!1),D=!!(e.listAiToolGrants&&e.createAiToolGrant&&e.revokeAiToolGrant),O=(0,v.useCallback)(async()=>{if(e.listAiToolGrants)try{let t=await e.listAiToolGrants();r(e=>e&&JSON.stringify(e)===JSON.stringify(t.grants)?e:t.grants),h(t.mcpUrl),a(null);let n=x.current,i=[];for(let e of t.grants){let t=e.reads[e.reads.length-1]?.at??``;n.has(e.id)&&n.get(e.id)!==t&&t!==``&&i.push(e.id),n.set(e.id,t)}i.length>0&&(b(e=>new Set([...e,...i])),setTimeout(()=>b(e=>{let t=new Set(e);for(let e of i)t.delete(e);return t}),iAe))}catch(e){a(Kv(e))}},[e]);(0,v.useEffect)(()=>{O(),e.listVaultProjects().then(e=>s(e.projects)).catch(()=>s([]))},[e,O]),(0,v.useEffect)(()=>{if(!e.listAiToolGrants)return;let t=setInterval(()=>{typeof document<`u`&&document.visibilityState===`hidden`||O()},rAe);return()=>clearInterval(t)},[e,O]);let k=(0,v.useCallback)(e=>o.find(t=>t.id===e)?.name??`one project`,[o]),A=e=>{if(e.kind===`all`)return`All chats on this PC`;if(e.kind===`chats`){let t=e.chatIds.length;return`${t} chosen chat${t===1?``:`s`}`}return`Project: ${k(e.projectId)}`},j=async t=>{if(e.revokeAiToolGrant){p(t);try{await e.revokeAiToolGrant(t),await O()}catch(e){a(Kv(e))}finally{p(null)}}},ee=(n??[]).filter(e=>e.status!==`active`),M=async t=>{if(e.forgetAiToolGrant){E(!0);try{for(let n of t)await e.forgetAiToolGrant(n.id);_(e=>{let n={...e};for(let e of t)delete n[e.id];return n})}catch(e){a(Kv(e))}finally{E(!1),await O()}}};return D?(0,B.jsxs)(`div`,{className:`space-y-3 text-sm`,"data-testid":`connect-ai-tool-body`,children:[(0,B.jsxs)(`p`,{className:`text-fg-muted`,children:[`Let an AI tool on this PC — Claude Code in VS Code, or any MCP client — `,(0,B.jsx)(`b`,{children:`read`}),` your chats on `,t.connection.hostName?(0,B.jsx)(`b`,{children:t.connection.hostName}):`this PC`,`. It gets read-only access through OonaCode, only while OonaCode runs and is unlocked; it never gets your password, your vault or OonaCode's own key.`]}),(0,B.jsxs)(`ul`,{className:`list-disc space-y-1 rounded-md border border-warn/40 bg-warn/5 py-2 pl-6 pr-3 text-xs text-warn`,"data-testid":`connect-ai-tool-warning`,children:[(0,B.jsx)(`li`,{children:`Whatever the tool reads is sent to that tool's model provider.`}),(0,B.jsx)(`li`,{children:`Chats can hold secrets you pasted or a tool printed. Key-shaped strings are masked, but not everything secret looks like a key.`}),(0,B.jsx)(`li`,{children:`A chat's text can carry instructions aimed at the tool. OonaCode marks everything it hands over as untrusted data, and offers read tools only — nothing that writes, sends or deletes.`})]}),u?(0,B.jsx)(lAe,{made:u,onDone:()=>d(null)}):c?(0,B.jsx)(uAe,{projects:o,onCancel:()=>l(!1),onCreated:e=>{l(!1),d(e),O()}}):(0,B.jsxs)(U,{onClick:()=>l(!0),"data-testid":`connect-ai-tool-new`,children:[(0,B.jsx)(H.Plug,{className:`w-3.5 h-3.5`}),`Connect a tool…`]}),i?(0,B.jsx)(`div`,{className:`text-xs text-danger`,children:i}):null,(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-1 text-xs font-medium uppercase tracking-wide text-fg-faint`,children:[(0,B.jsx)(`span`,{children:`Connected tools`}),(0,B.jsx)(`span`,{className:`ml-2 normal-case tracking-normal text-ok`,"data-testid":`connect-ai-tool-live`,children:`● live`}),ee.length>0&&e.forgetAiToolGrant?(0,B.jsxs)(U,{size:`sm`,variant:`ghost`,className:`float-right normal-case tracking-normal`,busy:T,onClick:()=>w(`ended`),"data-testid":`ai-tool-delete-ended`,children:[`Delete `,ee.length,` ended`]}):null]}),(0,B.jsx)(`p`,{className:`mb-1 text-xs text-fg-faint`,"data-testid":`connect-ai-tool-own-keys`,children:`Each connection has a key of its own and opens only the chats on its line — press Details on one for everything about it. Make one connection per AI tool.`}),n===null?(0,B.jsx)(`div`,{className:`text-xs text-fg-faint`,children:`Loading…`}):n.length===0?(0,B.jsx)(`div`,{className:`text-xs text-fg-faint`,"data-testid":`connect-ai-tool-none`,children:`No AI tool is connected.`}):(0,B.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:n.map(n=>(0,B.jsxs)(`li`,{className:z(`p-2 transition-colors`,y.has(n.id)&&`bg-accent-soft`),"data-fresh":y.has(n.id)?`true`:void 0,"data-testid":`ai-tool-grant-${n.id}`,children:[(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:n.toolName}),n.tokenHint?(0,B.jsxs)(`span`,{className:`rounded bg-surface-2 px-1 font-mono text-[10px] text-fg-faint`,title:`This connection's own key begins like this. Another tool's key opens only that tool's chats.`,"data-testid":`ai-tool-key-${n.id}`,children:[n.tokenHint,`…`]}):null]}),(0,B.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[A(n.scope),` · `,(0,B.jsx)(cAe,{grant:n})]}),(0,B.jsx)($ke,{grant:n,sessions:t.sessions})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-1`,children:[(0,B.jsx)(U,{size:`sm`,onClick:()=>S(n.id,`details`),"aria-expanded":g[n.id]===`details`,"data-testid":`ai-tool-details-btn-${n.id}`,children:`Details`}),(0,B.jsxs)(U,{size:`sm`,onClick:()=>S(n.id,`activity`),"aria-expanded":g[n.id]===`activity`,"data-testid":`ai-tool-activity-btn-${n.id}`,children:[`Activity`,n.reads.length>0?` (${n.reads.length})`:``]}),n.status===`active`?(0,B.jsx)(U,{size:`sm`,onClick:()=>S(n.id,`share`),"aria-expanded":g[n.id]===`share`,"data-testid":`ai-tool-share-btn-${n.id}`,children:`Share`}):null,n.status===`active`?(0,B.jsx)(U,{size:`sm`,variant:`danger`,busy:f===n.id,onClick:()=>void j(n.id),"data-testid":`ai-tool-revoke-${n.id}`,children:`Revoke`}):null,n.status!==`active`&&e.forgetAiToolGrant?(0,B.jsx)(U,{size:`sm`,variant:`danger`,onClick:()=>w(n),"data-testid":`ai-tool-delete-${n.id}`,children:`Delete`}):null]})]}),g[n.id]===`details`?(0,B.jsx)(eAe,{grant:n}):null,g[n.id]===`activity`?(0,B.jsx)(tAe,{grant:n,sessions:t.sessions}):null,g[n.id]===`share`&&n.status===`active`?(0,B.jsx)(sAe,{grant:n,mcpUrl:m,onChanged:()=>void O()}):null,n.reads.length>0?(0,B.jsx)(`ul`,{className:`mt-1 space-y-0.5 text-xs text-fg-faint`,"data-testid":`ai-tool-reads`,children:[...n.reads].reverse().slice(0,5).map((e,t)=>(0,B.jsxs)(`li`,{title:zv(e.at),children:[n.toolName,` `,aAe(e).replace(` · `,` — `)]},`${e.at}-${t}`))}):n.status===`active`?(0,B.jsx)(`div`,{className:`mt-1 text-xs text-fg-faint`,children:`Nothing read yet.`}):null]},n.id))})]}),(0,B.jsx)(bC,{open:C!==null,title:C===`ended`?`Delete the ended connections?`:`Delete this connection?`,message:C===`ended`?`${ee.length} ended connection${ee.length===1?``:`s`} (revoked or expired) leave the list, with the log of what each read. They cannot read anything now, so nothing else changes.`:C?`“${C.toolName}” is ${C.status===`revoked`?`revoked`:`expired`} and cannot read anything. It leaves the list, with the log of what it read.`:``,confirmLabel:`Delete`,onConfirm:()=>{M(C===`ended`?ee:C?[C]:[])},onClose:()=>w(null)})]}):(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`connect-ai-tool-unsupported`,children:`This PC is running an older OonaCode that cannot connect an AI tool. Update it first.`})}function sAe({grant:e,mcpUrl:t,onChanged:n}){let{api:r}=V(),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(!1),g=t??`http://127.0.0.1:<port>/api/v1/ai-tools/mcp`,_=qee(g,`${e.tokenHint??`oca_`}…<the rest of this connection's key>`),y=e.revealable!==!1&&!!r.revealAiToolGrant,b=async()=>{let t=i;if(t){l(!0),d(null);try{let i=t===`reveal`?await r.revealAiToolGrant(e.id,{password:o}):await r.rotateAiToolGrant(e.id,{password:o});p({answer:i,fresh:t===`new`}),a(null),s(``),h(!1),t===`new`&&n()}catch(e){d(Kv(e))}finally{l(!1)}}};return(0,B.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-md border border-border bg-surface-2 p-2 text-xs`,"data-testid":`ai-tool-share-${e.id}`,children:[(0,B.jsxs)(`div`,{className:`font-medium text-fg`,children:[`Give `,e.toolName,` access`]}),(0,B.jsxs)(`div`,{className:`text-fg-muted`,children:[`The tool connects to `,(0,B.jsx)(`code`,{className:`font-mono text-fg`,children:g}),` and sends its own key as `,(0,B.jsx)(`code`,{className:`font-mono text-fg`,children:`Authorization: Bearer …`}),`. This key opens only the chats on this line.`]}),f?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:f.fresh?`text-warn`:`text-fg-muted`,children:f.fresh?`New key. The key it replaces has stopped working; give this command to ${e.toolName}.`:`This connection's key. Treat it like a password: anyone who has it can read the chats on this line.`}),(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(`pre`,{className:`min-w-0 flex-1 overflow-x-auto whitespace-pre-wrap break-all rounded bg-surface p-2 font-mono`,"data-testid":`ai-tool-share-command-${e.id}`,children:f.answer.command}),(0,B.jsxs)(U,{size:`sm`,onClick:()=>void XI(f.answer.command).then(e=>{e&&h(!0)}),"data-testid":`ai-tool-share-copy-${e.id}`,children:[(0,B.jsx)(H.Copy,{className:`w-3.5 h-3.5`}),m?`Copied`:`Copy`]})]}),(0,B.jsxs)(`details`,{className:`text-fg-muted`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer`,children:`For another MCP client`}),(0,B.jsxs)(`div`,{className:`mt-1 space-y-1 font-mono`,children:[(0,B.jsxs)(`div`,{children:[`URL: `,f.answer.mcpUrl]}),(0,B.jsxs)(`div`,{className:`break-all`,children:[`Header: `,f.answer.header]})]})]}),(0,B.jsx)(U,{size:`sm`,onClick:()=>p(null),"data-testid":`ai-tool-share-hide-${e.id}`,children:`Hide key`})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap break-all rounded bg-surface p-2 font-mono`,"data-testid":`ai-tool-share-template-${e.id}`,children:_}),y?(0,B.jsx)(`p`,{className:`text-fg-faint`,children:`Reveal the key with your OonaCode password to copy the whole command.`}):(0,B.jsx)(`p`,{className:`text-fg-faint`,"data-testid":`ai-tool-share-not-kept-${e.id}`,children:`This key was made before OonaCode kept keys, so it cannot be shown again. Make a new key to share this connection: whatever uses the current key stops working until you give it the new command.`}),i?(0,B.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),o&&b()},children:[(0,B.jsx)(`input`,{type:`password`,className:z(pC,`max-w-[16rem]`),placeholder:`Your OonaCode password`,autoComplete:`current-password`,autoFocus:!0,value:o,onChange:e=>s(e.target.value),"data-testid":`ai-tool-share-password-${e.id}`}),(0,B.jsx)(U,{size:`sm`,variant:`primary`,type:`submit`,busy:c,disabled:!o,"data-testid":`ai-tool-share-${i===`reveal`?`reveal`:`make`}-${e.id}`,children:i===`reveal`?`Show key`:`Make new key`}),(0,B.jsx)(U,{size:`sm`,onClick:()=>{a(null),d(null)},children:`Cancel`})]}):(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[y?(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:()=>a(`reveal`),"data-testid":`ai-tool-share-reveal-key-${e.id}`,children:`Reveal key…`}):null,(0,B.jsx)(U,{size:`sm`,variant:y?`ghost`:void 0,onClick:()=>a(`new`),disabled:!r.rotateAiToolGrant,"data-testid":`ai-tool-share-new-key-${e.id}`,title:`Replace this connection's key: the old one stops working at once (for a key that leaked).`,children:y?`Replace the key…`:`New key and command…`})]}),u?(0,B.jsx)(`div`,{className:`text-danger`,children:u}):null]})]})}function cAe({grant:e}){return e.status===`revoked`?(0,B.jsx)(`span`,{className:`text-fg-faint`,children:`revoked`}):e.status===`expired`?(0,B.jsx)(`span`,{className:`text-fg-faint`,children:`expired`}):(0,B.jsxs)(`span`,{className:`text-ok`,children:[`active`,e.expiresAt?` until ${zv(e.expiresAt)}`:` until revoked`]})}function lAe({made:e,onDone:t}){let[n,r]=(0,v.useState)(!1);return(0,B.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border bg-surface-2 p-2`,"data-testid":`connect-ai-tool-made`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:`Paste this into a terminal for Claude Code`}),(0,B.jsx)(`p`,{className:`text-xs text-warn`,children:`Treat it like a password — the tool keeps it in its own settings file, and Revoke below is what ends it. You can see it again later: Share on its line, then Reveal key with your password.`}),(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(`pre`,{className:`min-w-0 flex-1 overflow-x-auto whitespace-pre-wrap break-all rounded bg-surface p-2 font-mono text-xs`,"data-testid":`connect-ai-tool-command`,children:e.command}),(0,B.jsxs)(U,{size:`sm`,onClick:()=>{XI(e.command).then(e=>{e&&r(!0)})},"data-testid":`connect-ai-tool-copy`,children:[(0,B.jsx)(H.Copy,{className:`w-3.5 h-3.5`}),n?`Copied`:`Copy`]})]}),(0,B.jsxs)(`details`,{className:`text-xs text-fg-muted`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer`,children:`Another MCP client`}),(0,B.jsxs)(`div`,{className:`mt-1 space-y-1`,children:[(0,B.jsxs)(`div`,{children:[`Streamable HTTP URL: `,(0,B.jsx)(`code`,{className:`break-all`,children:e.mcpUrl})]}),(0,B.jsxs)(`div`,{children:[`Header: `,(0,B.jsx)(`code`,{className:`break-all`,children:e.header})]})]})]}),(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:t,"data-testid":`connect-ai-tool-done`,children:`Done`})]})}function uAe({projects:e,onCancel:t,onCreated:n}){let{api:r,state:i}=V(),[a,o]=(0,v.useState)(`Claude Code`),[s,c]=(0,v.useState)(`all`),[l,u]=(0,v.useState)([]),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(`hour`),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),w=(0,v.useMemo)(()=>{let e=d.trim().toLowerCase();return i.sessions.filter(t=>!e||Gv(t).toLowerCase().includes(e)).slice(0,200)},[i.sessions,d]),T=s===`all`?{kind:`all`}:s===`chats`?l.length>0?{kind:`chats`,chatIds:l}:null:p?{kind:`project`,projectId:p}:null,E=!!(T&&a.trim()&&_&&!b),D=async()=>{if(!(!E||!T||!r.createAiToolGrant)){x(!0),C(null);try{let e=await r.createAiToolGrant({toolName:a.trim(),scope:T,lifetime:h,password:_});y(``),n(e)}catch(e){C(Kv(e))}finally{x(!1)}}},O=e=>u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,B.jsxs)(`div`,{className:`space-y-3 rounded-md border border-border p-2`,"data-testid":`connect-ai-tool-form`,children:[(0,B.jsxs)(`label`,{className:`block`,children:[(0,B.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Tool name`}),(0,B.jsx)(`input`,{className:pC,value:a,maxLength:60,onChange:e=>o(e.target.value),"data-testid":`connect-ai-tool-name`})]}),(0,B.jsxs)(`fieldset`,{children:[(0,B.jsx)(`legend`,{className:`text-xs text-fg-muted`,children:`What it may read`}),(0,B.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-3`,children:[[`all`,`All chats`],[`chats`,`Chosen chats`],[`project`,`One project`]].map(([e,t])=>(0,B.jsxs)(`label`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`connect-ai-tool-scope`,checked:s===e,onChange:()=>c(e),"data-testid":`connect-ai-tool-scope-${e}`}),t]},e))}),s===`chats`?(0,B.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,B.jsx)(`input`,{className:pC,placeholder:`Filter chats`,value:d,onChange:e=>f(e.target.value)}),(0,B.jsx)(`div`,{className:`max-h-48 overflow-y-auto rounded-md border border-border`,children:w.length===0?(0,B.jsx)(`div`,{className:`p-2 text-xs text-fg-faint`,children:`No chats.`}):w.map(e=>(0,B.jsxs)(`label`,{className:`flex items-center gap-2 px-2 py-1 text-xs hover:bg-surface-2`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:l.includes(e.id),onChange:()=>O(e.id),"data-testid":`connect-ai-tool-chat-${e.id}`}),(0,B.jsx)(`span`,{className:`truncate`,children:Gv(e)})]},e.id))}),(0,B.jsxs)(`div`,{className:`text-xs text-fg-faint`,children:[l.length,` chosen`]})]}):null,s===`project`?(0,B.jsxs)(`select`,{className:z(mC,`mt-2`),value:p,onChange:e=>m(e.target.value),"data-testid":`connect-ai-tool-project`,children:[(0,B.jsx)(`option`,{value:``,children:`Pick a project…`}),e.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]}):null]}),(0,B.jsxs)(`label`,{className:`block`,children:[(0,B.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`For how long`}),(0,B.jsx)(`select`,{className:mC,value:h,onChange:e=>g(e.target.value),"data-testid":`connect-ai-tool-lifetime`,children:Object.keys(R5).map(e=>(0,B.jsx)(`option`,{value:e,children:R5[e]},e))})]}),(0,B.jsxs)(`label`,{className:`block`,children:[(0,B.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Account password — to say it is you`}),(0,B.jsx)(`input`,{type:`password`,className:pC+` max-w-[16rem]`,placeholder:`Account password`,value:_,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&D()},"data-testid":`connect-ai-tool-password`})]}),S?(0,B.jsx)(`div`,{className:`text-xs text-danger`,"data-testid":`connect-ai-tool-error`,children:S}):null,(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(U,{variant:`primary`,onClick:()=>void D(),disabled:!E,busy:b,"data-testid":`connect-ai-tool-create`,children:`Connect`}),(0,B.jsx)(U,{variant:`ghost`,onClick:t,children:`Cancel`})]})]})}var z5=new Map,B5=0;function dAe(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,`0`)}function V5(e){return[e.summaryId,e.language,e.voiceKey,dAe(e.text)].join(`|`)}function fAe(e,t){let n=V5(e),r=z5.get(n);return r&&(z5.delete(n),r.clips.length!==t&&(U5(r),r=void 0)),r??={key:n,clips:Array(t).fill(void 0),bytes:0},z5.set(n,r),H5(n),r}function pAe(e,t,n,r){let i=e.clips[t];i&&(W5(i.url),e.bytes-=i.bytes);let a={url:mAe(n),bytes:n.byteLength,...r};return e.clips[t]=a,e.bytes+=a.bytes,z5.delete(e.key),z5.set(e.key,e),H5(e.key),a}function H5(e){let t=0;for(let e of z5.values())t+=e.bytes;for(let[n,r]of z5){if(z5.size<=8&&t<=50331648)return;n!==e&&(z5.delete(n),t-=r.bytes,U5(r))}}function U5(e){for(let t of e.clips)t&&W5(t.url)}function mAe(e){return typeof URL<`u`&&typeof URL.createObjectURL==`function`?URL.createObjectURL(new Blob([e],{type:`audio/wav`})):(B5+=1,`clip:${B5}`)}function W5(e){if(e.startsWith(`blob:`))try{URL.revokeObjectURL(e)}catch{}}var G5=()=>new Audio,K5=1e-6,hAe=class{#e;#t;#n;#r;#i;#a=new Set;#o;#s=[``,``];#c=0;#l;#u=`idle`;#d;#f=0;#p=0;#m=null;#h=null;#g=0;#_=!1;#v=!1;#y=!1;#b=!1;constructor(e){this.#e=e.tts,this.#t=e.voiceId,this.#n=e.language,this.#r=e.entry,this.#d=lm(e.rate??1),this.#i=e.errorText??(e=>e instanceof Error&&e.message?e.message:String(e));let t=e.timeline;e.entry.clips.forEach((e,n)=>{e&&(t=Zp(t,n,e.seconds,e))}),this.#l=t,this.#o=[G5(),G5()];for(let e of this.#o)e.playbackRate=this.#d,e.preservesPitch=!0}get timeline(){return this.#l}snapshot(){let e=this.#l,t=this.#C(),n=-1;return e.words.length>0&&(n=this.#m??(this.#u===`ended`?e.words.length-1:Math.max(0,$p(e,t+K5)))),{status:this.#u,currentSec:t,durationSec:e.totalSec,durationExact:e.complete||this.#r.clips.every(Boolean),wordIndex:n,sentenceIndex:n>=0?e.words[n].sentence:Qp(e,t),rate:this.#d,error:this.#h}}subscribe(e){return this.#a.add(e),()=>this.#a.delete(e)}#x(){for(let e of[...this.#a])e()}#S(e){this.#u=e,this.#x()}#C(){let e=this.#l;if(this.#u===`ended`)return e.totalSec;if(this.#m!==null)return em(e,this.#m);let t=e.sentences[this.#f];if(!t)return 0;let n=this.#u===`playing`?this.#o[this.#c].currentTime||0:this.#p;return t.startSec+Math.max(0,Math.min(n,t.durationSec))}#w(){let e=this.#l.sentences.length;for(let t=0;t<e;t+=1){let n=(this.#f+t)%e;if(!this.#r.clips[n])return n}return-1}#T(){if(!this.#_||this.#v||this.#y||this.#b)return;let e=this.#w();if(e<0)return;let t=this.#l.sentences[e];this.#v=!0,(async()=>{try{let n=await this.#e.speak({voiceId:this.#t,text:Bp(t.spoken,this.#n),speed:1}),r=n.sampleRate>0?n.samples.length/n.sampleRate:0,i=im(n.samples,n.sampleRate);if(pAe(this.#r,e,Ly(n.samples,n.sampleRate),{seconds:r,...i}),this.#v=!1,this.#b)return;this.#l=Zp(this.#l,e,r,i),this.#u===`buffering`&&e===this.#f?this.#D(this.#f):this.#u===`playing`&&e===this.#f+1&&this.#O(),this.#x(),this.#T()}catch(e){if(this.#v=!1,this.#b)return;this.#E(this.#i(e))}})()}#E(e){this.#y=!0,this.#g+=1,this.#u===`playing`&&(this.#p=this.#o[this.#c].currentTime||0);for(let e of this.#o)e.pause();this.#h=e,this.#S(`error`)}#D(e){let t=++this.#g;this.#f=e;let n=this.#r.clips[e];if(!n){for(let e of this.#o)e.pause();this.#u!==`buffering`&&this.#S(`buffering`),this.#T();return}if(this.#m!==null){let t=this.#l.sentences[e];this.#p=em(this.#l,this.#m)-t.startSec,this.#m=null}let r=Math.max(0,Math.min(this.#p,Math.max(0,n.seconds-.01))),i=this.#c,a=this.#o[i];this.#o[+(i===0)].pause(),this.#s[i]!==n.url&&(a.src=n.url,this.#s[i]=n.url),a.currentTime=r,a.playbackRate=this.#d,a.preservesPitch=!0,a.onended=()=>{t===this.#g&&this.#k(e)},a.onerror=()=>{t===this.#g&&this.#E(`This window could not play the voice’s audio.`)},this.#p=r;let o=e=>{t!==this.#g||e instanceof Error&&e.name===`AbortError`||this.#E(`This window could not play the voice’s audio${e instanceof Error&&e.message?` (${e.message})`:``}.`)};try{a.play()?.catch?.(o)}catch(e){queueMicrotask(()=>o(e))}this.#O(),this.#u===`playing`?this.#x():this.#S(`playing`)}#O(){let e=this.#r.clips[this.#f+1],t=+(this.#c===0);!e||this.#s[t]===e.url||(this.#o[t].src=e.url,this.#s[t]=e.url)}#k(e){let t=this.#l.sentences.length;if(e+1>=t){this.#g+=1,this.#f=t-1,this.#p=this.#l.sentences[t-1]?.durationSec??0,this.#S(`ended`);return}this.#c=+(this.#c===0),this.#p=0,this.#D(e+1)}play(){if(!(this.#b||this.#u===`playing`||this.#u===`buffering`)){if(this.#l.sentences.length===0){this.#S(`ended`);return}this.#u===`ended`&&(this.#f=0,this.#p=0,this.#m=null),this.#u===`error`&&(this.#y=!1,this.#h=null),this.#_=!0,this.#D(this.#f),this.#T()}}pause(){if(this.#u===`playing`||this.#u===`buffering`){this.#u===`playing`&&(this.#p=this.#o[this.#c].currentTime||0),this.#g+=1;for(let e of this.#o)e.pause();this.#S(`paused`)}}toggle(){this.#u===`playing`||this.#u===`buffering`?this.pause():this.play()}#A(e,t,n){let r=this.#u===`playing`||this.#u===`buffering`;if(this.#g+=1,this.#u===`playing`&&this.#o[this.#c].pause(),this.#f=e,this.#p=t,this.#m=n,r){this.#D(e),this.#T();return}if(this.#m!==null&&this.#r.clips[e]){let t=this.#l.sentences[e];this.#p=em(this.#l,this.#m)-t.startSec,this.#m=null}this.#S(this.#u===`idle`?`idle`:this.#u===`error`?`error`:`paused`)}seek(e){let t=this.#l;if(t.sentences.length===0)return;let n=Math.max(0,Math.min(t.totalSec,e)),r=Qp(t,n),i=t.sentences[r];if(this.#r.clips[r]){this.#A(r,n-i.startSec,null);return}let a=$p(t,n+K5),o=a>=i.wordFrom&&a<i.wordTo?a:i.wordTo>i.wordFrom?i.wordFrom:null;this.#A(r,n-i.startSec,o)}seekWord(e){let t=this.#l;if(t.words.length===0)return;let n=t.words[Math.max(0,Math.min(e,t.words.length-1))],r=t.sentences[n.sentence];this.#r.clips[n.sentence]?this.#A(n.sentence,n.startSec-r.startSec,null):this.#A(n.sentence,0,n.index)}skip(e){this.seek(nm(this.#l,this.#C(),e))}nextSentence(){let e=this.#l.sentences[this.#f+1];e&&this.#A(e.index,0,null)}prevSentence(){let e=this.#l,t=Qp(e,rm(e,this.#C())+K5);this.#A(Math.max(0,t),0,null)}setRate(e){let t=lm(e);if(t!==this.#d){this.#d=t;for(let e of this.#o)e.playbackRate=t,e.preservesPitch=!0;this.#x()}}destroy(){if(!this.#b){this.#b=!0,this.#g+=1;for(let e of this.#o)e.onended=null,e.onerror=null,e.pause();this.#u=`idle`,this.#a.clear()}}};function gAe(e){let t=e.now??(()=>Date.now()),n=-1/0,r=0,i=null,a=new Set,o=(e,t)=>{let n=setTimeout(()=>{a.delete(n),e()},t);a.add(n)},s=(a,s)=>{let c=r,l=e.synth.getVoices().find(t=>t.voiceURI===e.voiceURI)??null,u=e.makeUtterance(a);l&&(u.voice=l),u.lang=l?.lang??e.bcp47,u.rate=s.rate;let d=!1,f=()=>!d&&c===r,p=()=>{d=!0,i===u&&(i=null)};u.onstart=()=>{f()&&s.onStart()},u.onboundary=e=>{f()&&(e.name===void 0||e.name===`word`)&&typeof e.charIndex==`number`&&s.onBoundary(e.charIndex)},u.onend=()=>{f()&&(p(),s.onEnd())},u.onerror=e=>{f()&&(p(),e.error!==`interrupted`&&e.error!==`canceled`&&s.onError(Error(`The system voice failed: ${e.error??`unknown error`}`)))},o(()=>{f()&&(p(),e.synth.cancel(),n=t(),s.onEnd())},Fy(a,s.rate)),i=u,e.synth.speak(u)};return{queueAhead:!1,speak(e,i){let a=n+50-t();if(a>0){let t=r;o(()=>{t===r&&s(e,i)},a);return}s(e,i)},stop(){r+=1,i=null;for(let e of a)clearTimeout(e);a.clear();try{e.synth.cancel()}catch{}return n=t(),new Promise(e=>setTimeout(e,50))}}}var q5=e=>typeof requestAnimationFrame==`function`?requestAnimationFrame(e):setTimeout(()=>e(Date.now()),16),_Ae=e=>{typeof cancelAnimationFrame==`function`?cancelAnimationFrame(e):clearTimeout(e)};function vAe(e){let[,t]=(0,v.useReducer)(e=>e+1,0);return(0,v.useEffect)(()=>{if(!e)return;let n=0,r=!1,i=-2,a=0,o=s=>{let c=e.snapshot();if(c.status!==`playing`&&c.status!==`buffering`){r=!1,t();return}(c.wordIndex!==i||s-a>=250)&&(i=c.wordIndex,a=s,t()),n=q5(o)},s=()=>{t();let i=e.snapshot();!r&&(i.status===`playing`||i.status===`buffering`)&&(r=!0,n=q5(o))},c=e.subscribe(s);return s(),()=>{c(),r&&_Ae(n)}},[e]),e?e.snapshot():null}function yAe({summaries:e,loaded:t,selectedId:n,changed:r,notice:i,error:a,locked:o,onSelect:s,onDelete:c}){let l=sm(e);return(0,B.jsxs)(`section`,{"data-testid":`voice-summaries`,children:[(0,B.jsx)(`h3`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Summaries`}),a?(0,B.jsx)(`p`,{className:`text-xs text-danger`,children:a}):null,t&&l.length===0?(0,B.jsx)(`p`,{className:`text-fg-muted`,"data-testid":`voice-no-summaries`,children:wm.noSummaries}):null,l.length>0&&r?(0,B.jsx)(`p`,{className:`mb-1 text-xs text-fg-muted`,"data-testid":`voice-changed`,children:wm.changedSinceNewest}):null,(0,B.jsx)(`ul`,{className:`flex max-h-44 flex-col gap-1 overflow-y-auto`,children:l.map(e=>{let t=n===e.id,r=Iy(e.createdAt);return(0,B.jsxs)(`li`,{"data-testid":`voice-summary-row`,className:z(`flex items-start gap-2 rounded-md border px-2 py-1.5`,t?`border-accent bg-accent/10`:`border-border`),children:[(0,B.jsx)(`input`,{type:`radio`,name:`voice-summary`,className:`mt-1`,"aria-label":`Summary of ${r}`,checked:t,disabled:o,onChange:()=>s(e.id)}),(0,B.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 flex-col items-start text-left`,disabled:o,onClick:()=>s(e.id),children:[(0,B.jsxs)(`span`,{className:`font-medium`,children:[r,e.current?(0,B.jsx)(`span`,{className:`ml-2 rounded-full bg-accent/15 px-1.5 text-xs text-accent`,children:wm.current}):null]}),(0,B.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[e.words,` words · about `,ree(e.seconds),` ·`,` `,xm(e).map(e=>e.toUpperCase()).join(` `),` `,`· `,e.cost.model??`the chat’s model`,` · `,Cm(e.cost)]})]}),(0,B.jsx)(U,{size:`sm`,onClick:()=>c(e.id),disabled:o,"aria-label":`Delete the summary of ${r}`,"data-testid":`voice-summary-delete`,children:(0,B.jsx)(H.Trash,{className:`h-3.5 w-3.5`})})]},e.id)})}),i?(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,"data-testid":`voice-notice`,children:i}):null]})}function bAe(e){switch(e?.status){case`buffering`:return`Getting the voice ready…`;case`paused`:return`Paused.`;case`ended`:return`Done.`;case`playing`:return`Playing.`;default:return``}}function J5({label:e,onClick:t,disabled:n,children:r,testId:i,primary:a}){return(0,B.jsx)(`button`,{type:`button`,"aria-label":e,title:e,onClick:t,disabled:n,"data-testid":i,className:z(`inline-flex items-center justify-center rounded-full disabled:opacity-40`,a?`h-9 w-9 bg-accent text-accent-fg hover:opacity-90`:`h-8 min-w-8 px-1.5 text-fg-muted hover:bg-surface-2 hover:text-fg`),children:r})}function xAe({player:e,snapshot:t,speed:n,onSpeed:r}){let i=t,a=!e||!i,o=i?.status===`playing`||i?.status===`buffering`,s=i?.currentSec??0,c=i?.durationSec??0,l=i&&!i.durationExact?`~`:``,u=`${am(s)} / ${l}${am(c)}`;return(0,B.jsxs)(`section`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface-2 px-3 py-2`,"data-testid":`voice-player`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`input`,{type:`range`,"aria-label":`Position`,"aria-valuetext":`${am(s)} of ${l}${am(c)}`,className:`min-w-0 flex-1`,min:0,max:Math.max(.1,c),step:.1,value:Math.min(s,Math.max(.1,c)),disabled:a,onChange:t=>e?.seek(Number(t.target.value)),"data-testid":`voice-position`}),(0,B.jsx)(`span`,{className:`shrink-0 tabular-nums text-xs text-fg-muted`,"data-testid":`voice-clock`,children:u})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,B.jsx)(J5,{label:`Previous sentence`,onClick:()=>e?.prevSentence(),disabled:a,testId:`voice-prev`,children:(0,B.jsx)(H.SkipBack,{className:`h-4 w-4`})}),(0,B.jsx)(J5,{label:`Back 10 seconds`,onClick:()=>e?.skip(-10),disabled:a,testId:`voice-back`,children:(0,B.jsxs)(`span`,{className:`text-xs font-medium`,children:[`−`,10,`s`]})}),(0,B.jsx)(J5,{label:o?`Pause`:`Play`,onClick:()=>e?.toggle(),disabled:a,testId:`voice-toggle`,primary:!0,children:o?(0,B.jsx)(H.Pause,{className:`h-4 w-4`}):(0,B.jsx)(H.Play,{className:`h-4 w-4`})}),(0,B.jsx)(J5,{label:`Forward 10 seconds`,onClick:()=>e?.skip(10),disabled:a,testId:`voice-forward`,children:(0,B.jsxs)(`span`,{className:`text-xs font-medium`,children:[`+`,10,`s`]})}),(0,B.jsx)(J5,{label:`Next sentence`,onClick:()=>e?.nextSentence(),disabled:a,testId:`voice-next`,children:(0,B.jsx)(H.SkipForward,{className:`h-4 w-4`})}),(0,B.jsxs)(`span`,{className:`ml-1 flex items-center gap-1 text-xs text-fg-muted`,"aria-live":`polite`,"data-testid":`voice-player-status`,children:[i?.status===`buffering`?(0,B.jsx)(H.Spinner,{className:`h-3.5 w-3.5`}):null,bAe(i)]}),(0,B.jsxs)(`label`,{className:`ml-auto flex items-center gap-2 text-xs text-fg-muted`,children:[(0,B.jsxs)(`span`,{className:`tabular-nums`,children:[`Speed ×`,n.toFixed(2)]}),(0,B.jsx)(`input`,{type:`range`,"aria-label":`Speed`,min:cm,max:2,step:.05,value:n,onChange:e=>r(Number(e.target.value))})]})]})]})}var SAe=(0,v.memo)(function({index:e,text:t,current:n,onPick:r}){return(0,B.jsx)(`span`,{"data-word":e,"data-current":n?`true`:void 0,onClick:()=>r(e),className:z(`cursor-pointer rounded-sm hover:bg-accent/10`,n&&`bg-accent/20 text-fg`),children:t})});function CAe({text:e,timeline:t,wordIndex:n,onPickWord:r,dir:i,lang:a}){let o=(0,v.useRef)(null),s=(0,v.useRef)(0),c=(0,v.useRef)(0),l=(0,v.useRef)(r);l.current=r;let u=(0,v.useMemo)(()=>e=>l.current(e),[]),d=t&&t.text===e?t.words.length:-1,f=(0,v.useMemo)(()=>{if(!t||d<0)return null;let n=[],r=0;for(let i of t.words)n.push({gap:e.slice(r,i.start),word:{index:i.index,text:e.slice(i.start,i.end)}}),r=i.end;return n.push({gap:e.slice(r),word:null}),n},[d,e]);(0,v.useEffect)(()=>{if(n<0||!o.current||Date.now()-s.current<4e3)return;let e=o.current.querySelector(`[data-word="${n}"]`);e&&(c.current=Date.now(),e.scrollIntoView({block:`nearest`}))},[n]);let p=()=>{s.current=Date.now()},m=e;return f&&(m=f.map((e,t)=>(0,B.jsx)(wAe,{gap:e.gap,word:e.word,current:e.word?.index===n,onPick:u},t))),(0,B.jsx)(`p`,{ref:o,className:`max-h-64 overflow-y-auto whitespace-pre-wrap rounded-md border border-border bg-surface-2 px-3 py-2 leading-relaxed`,"data-testid":`voice-summary-text`,dir:i,lang:a,onWheel:p,onTouchMove:p,onScroll:()=>{Date.now()-c.current>200&&p()},children:m})}var wAe=(0,v.memo)(function({gap:e,word:t,current:n,onPick:r}){return(0,B.jsxs)(B.Fragment,{children:[e,t?(0,B.jsx)(SAe,{index:t.index,text:t.text,current:n,onPick:r}):null]})});function Y5(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 X5(e,t,n){let[r,i]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(!e||n!==`linux`||!t?.installCommand)return;let r=!0;return t.installCommand().then(e=>r&&i(typeof e==`string`&&e.trim()?e:null),()=>r&&i(null)),()=>{r=!1}},[e,t,n]),r}function Z5(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 TAe(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`SELECT`||t===`TEXTAREA`||e.isContentEditable||e.getAttribute(`contenteditable`)===`true`}function EAe({open:e,onClose:t}){let{state:n,api:r}=V(),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=jy(typeof window<`u`?window.oonacode?.platform:null,typeof navigator<`u`?navigator.userAgent:null),[c,l]=(0,v.useState)(()=>Sy()),[u,d]=(0,v.useState)(null),f=Y5(e),p=X5(e,o,s),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)({kind:`idle`}),[C,w]=(0,v.useState)(null),T=(0,v.useRef)(null),[E,D]=(0,v.useState)(null),O=(0,v.useRef)(null),k=(0,v.useRef)(null),A=(0,v.useRef)(null),j=(0,v.useRef)(c.speed);j.current=c.speed;let ee=vAe(E),M=$f(c.language)??$f(`en`),te=(0,v.useCallback)(e=>{l(t=>{let n={...t,...e};return Cy(n),n})},[]),ne=(0,v.useMemo)(()=>m?.summaries??[],[m]),N=ne.find(e=>e.id===y)??ne[0]??null,P=(0,v.useCallback)(async()=>{if(!i||!r.listVoiceSummaries)return null;try{let e=await r.listVoiceSummaries(i),t={...e,summaries:sm(e.summaries)};return h(t),_(null),t}catch(e){return _(Z5(e)),null}},[r,i]);(0,v.useEffect)(()=>{e&&(h(null),b(null),w(null),S({kind:`idle`}),P(),o?(d(null),o.listVoices().then(d,()=>d([]))):d([]))},[e,P,o]);let re=a?`${a.entryCount}:${a.mtime}`:null,ie=(0,v.useRef)(null),ae=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!e){ie.current=null;return}if(ie.current===null){ie.current=re;return}re!==ie.current&&(ie.current=re,!ae.current&&(ae.current=setTimeout(()=>{ae.current=null,P()},800)))},[e,re,P]),(0,v.useEffect)(()=>()=>{ae.current&&clearTimeout(ae.current),ae.current=null},[]);let oe=(0,v.useCallback)(()=>{T.current?.abort(),T.current=null,A.current=null,O.current?.destroy(),O.current=null,k.current=null,D(null)},[]);(0,v.useEffect)(()=>{e||oe()},[e,oe]),(0,v.useEffect)(()=>()=>oe(),[oe]);let se=(0,v.useMemo)(()=>ky(M,u??[],f),[M,u,f]),F=Ay(se,c.localVoice[M.code]),ce=!!(o&&u&&!u.some(e=>e.engine===`espeak`)),le=x.kind===`summarising`||x.kind===`translating`,ue=!!(r.listVoiceSummaries&&r.createVoiceSummary),de=typeof window<`u`&&!!window.speechSynthesis,fe=N?Sm(N,M.code):null,pe=F?.key??null,me=F?.kind??null,he=N?.id??null,ge=(0,v.useMemo)(()=>{if(!he||fe===null||!pe||!me)return null;let e=Ty({key:pe,kind:me,label:``}),t,n;if(e&&o)t=`clip`,n=e;else if(me===`system`&&de)t=`system`,n=pe.slice(7);else return null;let r={summaryId:he,language:M.code,voiceKey:pe,text:fe};return{key:V5(r),...r,bcp47:M.bcp47,kind:t,voiceId:n}},[he,fe,pe,me,o,de,M]);(0,v.useEffect)(()=>{if(!e||(ge?.key??null)===(k.current?.key??null))return;let t=O.current,n=k.current,r=t?.snapshot()??null;if(t?.destroy(),O.current=null,k.current=ge,!ge){D(null);return}let i=Yp(ge.text,{language:ge.language}),a;a=ge.kind===`clip`&&o?new hAe({tts:o,voiceId:ge.voiceId,language:ge.language,timeline:i,entry:fAe(ge,i.sentences.length),rate:j.current,errorText:Z5}):new um(gAe({synth:window.speechSynthesis,makeUtterance:e=>new SpeechSynthesisUtterance(e),voiceURI:ge.voiceId,bcp47:ge.bcp47}),i,{mode:Py(s),rate:j.current});let c=!1;if(t&&n&&r){let e=r.status===`playing`||r.status===`buffering`;n.summaryId===ge.summaryId&&n.language===ge.language&&n.text===ge.text?(r.wordIndex>=0&&r.status!==`ended`&&a.seekWord(r.wordIndex),c=e):n.summaryId===ge.summaryId&&(c=e)}A.current===ge.key&&(A.current=null,c=!0),O.current=a,D(a),c&&a.play()},[e,ge,o,s]);let _e=async()=>{if(!i||!r.createVoiceSummary)return null;S({kind:`summarising`});let e=await r.createVoiceSummary(i,{words:c.words});return w(e.created?null:wm.unchanged(Iy(e.summary.createdAt))),b(e.summary.id),await P(),e.summary},ve=async()=>{if(!i)return;T.current?.abort();let e=new AbortController;T.current=e;let t=e.signal;A.current=null;try{let e=bm(m,y)?await _e():N;if(t.aborted)return;if(!e)throw Error(`There is no summary to play.`);let n=Sm(e,M.code);if(n===null){if(!r.translateVoiceSummary)throw Error(`This host cannot translate yet.`);S({kind:`translating`});let a=await r.translateVoiceSummary(i,e.id,{language:M.code});if(h(t=>DAe(t,e.id,a.translation)),t.aborted)return;n=a.translation.text,P()}if(!n.trim())throw Error(`There was nothing to read.`);if(!F||F.kind===`system`&&!de)throw Error(F?`This window has no system speech.`:Ny(M,!!o,s,ce,p));S({kind:`idle`});let a=V5({summaryId:e.id,language:M.code,voiceKey:F.key,text:n});k.current?.key===a&&O.current?O.current.play():A.current=a}catch(e){if(t.aborted)return;S({kind:`error`,message:Z5(e)})}finally{T.current===e&&(T.current=null)}},ye=()=>{T.current?.abort(),T.current=null,A.current=null,le&&S({kind:`idle`}),O.current?.pause()},be=e=>{e!==N?.id&&(O.current?.pause(),w(null),b(e))},xe=async e=>{if(!(!i||!r.deleteVoiceSummary))try{await r.deleteVoiceSummary(i,e),y===e&&b(null),await P()}catch(e){S({kind:`error`,message:Z5(e)})}},Se=e=>{let t=ip(e);te({speed:t}),O.current?.setRate(t)};if((0,v.useEffect)(()=>{if(!e)return;let t=e=>{let t=O.current;if(!t||e.altKey||e.ctrlKey||e.metaKey||TAe(e.target))return;let n=e.target instanceof Element?e.target:null;if(!(n&&n!==document.body&&!n.closest(`[aria-label="Listen to this chat"]`))){if(e.key===` `||e.key===`Spacebar`){if(n?.closest(`button`))return;e.preventDefault(),t.toggle()}else if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let n=e.key===`ArrowRight`;e.shiftKey?n?t.nextSentence():t.prevSentence():t.skip(n?10:-10)}}};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]),!e)return null;let Ce=a?dd(a):`this chat`,we=N?xm(N):[],Te=new Set(we),Ee=fe??N?.text??null,De=ee?.status===`error`?ee.error:null,Oe=ee?.status===`playing`||ee?.status===`buffering`,ke=E&&k.current?.text===Ee?E.timeline:null;return(0,B.jsx)(gC,{open:e,title:`Listen to this chat`,onClose:t,wide:!0,footer:(0,B.jsxs)(B.Fragment,{children:[le||Oe?(0,B.jsxs)(U,{onClick:ye,"data-testid":`voice-stop`,children:[(0,B.jsx)(H.Stop,{className:`h-4 w-4`}),` Stop`]}):null,(0,B.jsxs)(U,{variant:`primary`,onClick:()=>void ve(),disabled:le||!ue||!i,"data-testid":`voice-play`,children:[(0,B.jsx)(H.Play,{className:`h-4 w-4`}),` Play`]}),(0,B.jsx)(U,{onClick:t,children:`Close`})]}),children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm`,children:[ue?null:(0,B.jsx)(`p`,{className:`text-danger`,children:`This version of the host cannot make voice summaries.`}),(0,B.jsx)(yAe,{summaries:ne,loaded:m!==null,selectedId:N?.id??null,changed:bm(m,y),notice:C,error:g,locked:le,onSelect:be,onDelete:e=>void xe(e)}),(0,B.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`A spoken summary of `,(0,B.jsx)(`span`,{className:`font-medium text-fg`,children:Ce}),` — 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 `,ep.label,` on your OonaCode credits and kept with the summary.`]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,B.jsx)(fC,{label:`Language`,children:(0,B.jsx)(`select`,{"aria-label":`Language`,className:mC,value:M.code,disabled:le,onChange:e=>te({language:e.target.value}),children:Qf.map(e=>{let t=e.name===e.native?e.name:`${e.name} — ${e.native}`;return(0,B.jsx)(`option`,{value:e.code,children:Te.has(e.code)?`${t} ✓`:t},e.code)})})}),o&&u===null?(0,B.jsx)(`p`,{className:`px-1 py-2 text-fg-muted`,"data-testid":`voice-loading`,children:`Looking for this PC’s voices…`}):se.length>0?(0,B.jsx)(fC,{label:`Voice`,children:(0,B.jsx)(`select`,{"aria-label":`Voice`,className:mC,value:F?.key??``,disabled:le,onChange:e=>te({localVoice:{...c.localVoice,[M.code]:e.target.value}}),children:se.map(e=>(0,B.jsx)(`option`,{value:e.key,children:e.label},e.key))})}):(0,B.jsx)(`p`,{className:`rounded-md border border-border bg-surface-2 px-3 py-2 text-fg-muted`,"data-testid":`no-local-voice`,children:Ny(M,!!o,s,ce,p)}),(0,B.jsx)(fC,{label:`Length of a new summary`,children:(0,B.jsxs)(`select`,{"aria-label":`Length of a new summary`,className:mC,value:String(c.words),disabled:le,onChange:e=>te({words:Number(e.target.value)}),children:[(0,B.jsx)(`option`,{value:`120`,children:`Short — about 120 words`}),(0,B.jsx)(`option`,{value:`200`,children:`Normal — about 200 words`}),(0,B.jsx)(`option`,{value:`300`,children:`Long — about 300 words`}),[120,200,300].includes(c.words)?null:(0,B.jsxs)(`option`,{value:String(c.words),children:[c.words,` words`]})]})})]}),(0,B.jsx)(OAe,{stage:x,playerError:De}),(0,B.jsx)(xAe,{player:E,snapshot:ee,speed:c.speed,onSpeed:Se}),N&&Ee!==null?(0,B.jsxs)(`section`,{children:[(0,B.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:wm.heading(M,fe!==null)}),we.length>1?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":`Languages it has`,children:we.map(e=>{let t=$f(e);if(!t)return null;let n=e===M.code;return(0,B.jsx)(`button`,{type:`button`,"aria-pressed":n,title:t.name===t.native?t.name:`${t.name} — ${t.native}`,disabled:le,onClick:()=>te({language:e}),"data-testid":`voice-lang-chip`,className:z(`rounded-full border px-2 py-0.5 text-xs`,n?`border-accent bg-accent/15 text-accent`:`border-border text-fg-muted hover:bg-surface-2`),children:e.toUpperCase()},e)})}):null]}),(0,B.jsx)(CAe,{text:Ee,timeline:ke,wordIndex:ee?.wordIndex??-1,onPickWord:e=>O.current?.seekWord(e),dir:fe!==null&&M.rtl?`rtl`:`ltr`,lang:fe===null?`en-US`:M.bcp47})]}):null]})})}function DAe(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 OAe({stage:e,playerError:t}){let n=e.kind===`error`?e.message:t;if(n)return(0,B.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:n});if(e.kind!==`summarising`&&e.kind!==`translating`)return null;let r=[{key:`summarising`,label:wm.generating},{key:`translating`,label:wm.translating}],i=r.findIndex(t=>t.key===e.kind);return(0,B.jsx)(`ol`,{className:`flex flex-wrap items-center gap-2 text-xs`,"data-testid":`voice-stage`,"aria-live":`polite`,children:r.map((e,t)=>(0,B.jsx)(`li`,{className:z(`rounded-full px-2 py-0.5`,t===i?`bg-accent/15 font-medium text-accent`:t<i?`text-fg-muted line-through`:`text-fg-faint`),children:e.label},e.key))})}function Q5(e){return _p(e).replace(/\n+/g,` `).trim()||e.trim()}function $5(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 kAe(e){return{sessionId:e.sessionId,title:e.title.trim()||`Untitled chat`,about:e.about}}function AAe(e){return e.filter(e=>!e.pending&&e.source!==`user`&&(!e.about||e.stale))}function jAe({open:e,picked:t}){let{api:n}=V(),r=(0,v.useRef)(n);r.current=n;let i=typeof window<`u`?window.oonacode?.tts:void 0,a=jy(typeof window<`u`?window.oonacode?.platform:null,typeof navigator<`u`?navigator.userAgent:null),[o,s]=(0,v.useState)(()=>Sy()),[c,l]=(0,v.useState)(null),u=Y5(e),d=X5(e,i,a),f=$f(o.language)??$f(`en`),p=(0,v.useMemo)(()=>ky(f,c??[],u),[f,c,u]),m=Ay(p,o.localVoice[f.code]),h=!!(i&&c&&!c.some(e=>e.engine===`espeak`)),[g,_]=(0,v.useState)(Gy),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(0),[C,w]=(0,v.useState)(!1),T=(0,v.useRef)({lang:f,voice:m,speed:o.speed,espeakMissing:h,installCommand:d,platform:a,tts:i});T.current={lang:f,voice:m,speed:o.speed,espeakMissing:h,installCommand:d,platform:a,tts:i};let E=(0,v.useCallback)(e=>{s(t=>{let n={...t,...e};return Cy(n),n})},[]),D=(0,v.useMemo)(()=>{let e=Jte();return new nne({words:async e=>{let{lang:t}=T.current;if(!e.about)return{name:Q5(e.title),body:[Yf(t.code)]};if(t.code===`en`)return{name:Q5(e.title),body:Sp(_p(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&&S(e=>e+1),{name:r.translation.name?Q5(r.translation.name):null,body:Sp(r.translation.text)}}catch(e){throw Error(`could not translate it: ${$5(e)}`)}},speak:(t,{signal:n,onItem:r})=>{let i=T.current;return rne(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,installCommand:i.installCommand,prepare:Bp,signal:n,onItem:r})},silence:()=>{e.stop();try{typeof window<`u`&&window.speechSynthesis?.cancel()}catch{}},onState:_})},[]);(0,v.useEffect)(()=>{if(!e){D.reset();return}s(Sy()),i?(l(null),i.listVoices().then(l,()=>l([]))):l([])},[e,i,D]),(0,v.useEffect)(()=>()=>D.dispose(),[D]),(0,v.useEffect)(()=>{D.resetWords()},[f.code,D]);let O=t.map(e=>`${e.sessionId}\u0000${e.title}\u0000${e.about??``}`).join(``);(0,v.useEffect)(()=>{w(!1)},[O,f.code]),(0,v.useEffect)(()=>{let r=n.planChatAboutTranslations;if(!e||f.code===`en`||t.length===0||!r){b(null);return}let i=!0;return r({language:f.code,sessionIds:t.map(e=>e.sessionId)}).then(e=>i&&b(e),()=>i&&b(null)),()=>{i=!1}},[e,f.code,O,x,n]);let k=g.status===`preparing`||g.status===`speaking`,A=f.code!==`en`&&y!==null&&y.language===f.code&&y.needed>Hf.confirmAbove,j=(0,v.useCallback)(()=>{w(!1),D.start(t.map(kAe),0)},[D,t]),ee=(0,v.useCallback)(()=>{if(t.length!==0){if(A&&!C){w(!0);return}j()}},[t.length,A,C,j]);return{prefs:o,update:E,lang:f,options:p,voice:m,espeakMissing:h,installCommand:d,voicesLoading:!!i&&c===null,desktop:!!i,platform:a,state:g,busy:k,active:$te(g),plan:y&&y.language===f.code?y:null,confirming:C,play:ee,start:j,cancelConfirm:()=>w(!1),pause:()=>D.pause(),resume:()=>D.resume(),stop:()=>D.stop(),next:()=>D.next(),previous:()=>D.previous(),jumpTo:e=>D.jumpTo(e),pickedCount:t.length}}function MAe({b:e,picked:t,enabled:n,generateAll:r,onGenerated:i}){let{api:a}=V(),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),u=AAe(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($5(e))}finally{s(!1)}}},h=e.busy;return(0,B.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,B.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Listen to the picked chats`}),(0,B.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 `,ep.label,` on your OonaCode credits and kept, so playing it again costs nothing.`]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,B.jsx)(fC,{label:`Language`,children:(0,B.jsx)(`select`,{"aria-label":`Language`,className:mC,value:e.lang.code,disabled:h,onChange:t=>e.update({language:t.target.value}),"data-testid":`briefing-language`,children:Qf.map(e=>(0,B.jsx)(`option`,{value:e.code,children:e.name===e.native?e.name:`${e.name} — ${e.native}`},e.code))})}),e.voicesLoading?(0,B.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,B.jsx)(fC,{label:`Voice`,children:(0,B.jsx)(`select`,{"aria-label":`Voice`,className:mC,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,B.jsx)(`option`,{value:e.key,children:e.label},e.key))})}):(0,B.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:Ny(e.lang,e.desktop,e.platform,e.espeakMissing,e.installCommand)}),(0,B.jsx)(fC,{label:`Speed ×${e.prefs.speed.toFixed(2)}`,children:(0,B.jsx)(`input`,{"aria-label":`Speed`,type:`range`,min:np.speed.min,max:np.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,B.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`briefing-cost`,children:[Zf(e.plan,e.lang.name),e.plan.needed>0?` — paid once, then kept.`:``]}):null,e.confirming&&e.plan?(0,B.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,B.jsxs)(`p`,{className:`basis-full`,children:[`Before playing: `,Zf(e.plan,e.lang.name),` — paid once from your OonaCode credits, then kept.`]}),(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:e.start,"data-testid":`briefing-confirm-play`,children:`Translate and play`}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:e.cancelConfirm,children:`Cancel`})]}):null,u.length>0&&a.generateChatAbouts?(0,B.jsxs)(`div`,{className:`space-y-1.5 text-xs`,"data-testid":`briefing-need-about`,children:[(0,B.jsx)(`p`,{className:`text-fg-muted`,children:Qte(d,f)}),(0,B.jsxs)(U,{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,B.jsx)(H.Refresh,{className:`h-3 w-3`}),` Write abouts for these first`]})]}):null,c?(0,B.jsx)(`p`,{className:`text-xs text-danger`,"data-testid":`briefing-write-error`,children:c}):null]})}function NAe({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,B.jsxs)(B.Fragment,{children:[r?(0,B.jsx)(`p`,{className:z(`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,B.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[(0,B.jsx)(U,{size:`sm`,onClick:e.previous,disabled:t.status===`error`,"aria-label":`Previous chat`,title:`Previous chat`,"data-testid":`briefing-previous`,children:(0,B.jsx)(H.SkipBack,{className:`h-3.5 w-3.5`})}),t.status===`paused`||t.status===`error`?(0,B.jsxs)(U,{size:`sm`,variant:`primary`,onClick:e.resume,"data-testid":`briefing-resume`,children:[(0,B.jsx)(H.Play,{className:`h-3.5 w-3.5`}),` `,t.status===`error`?`Try again`:`Resume`]}):(0,B.jsxs)(U,{size:`sm`,onClick:e.pause,"data-testid":`briefing-pause`,children:[(0,B.jsx)(H.Pause,{className:`h-3.5 w-3.5`}),` Pause`]}),(0,B.jsxs)(U,{size:`sm`,onClick:e.stop,"data-testid":`briefing-stop`,children:[(0,B.jsx)(H.Stop,{className:`h-3.5 w-3.5`}),` Stop`]}),(0,B.jsx)(U,{size:`sm`,onClick:e.next,disabled:t.status===`error`,"aria-label":`Next chat`,title:`Next chat`,"data-testid":`briefing-next`,children:(0,B.jsx)(H.SkipForward,{className:`h-3.5 w-3.5`})})]}):(0,B.jsxs)(U,{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,B.jsx)(H.Play,{className:`h-4 w-4`}),` Play `,e.pickedCount,` picked`]})]})}function PAe({open:e,onClose:t}){let{state:n,actions:r}=V(),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)(()=>Xte()),[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 Zte(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??mf.enabled,ee=async e=>{x(!0);try{await r.saveSettings({chatAboutEnabled:e})}finally{x(!1)}k()},M=async()=>{g(!0);try{let e=await r.generateAllChatAbouts();e&&f(e.generateAll)}finally{g(!1)}},te=async()=>{y(!0);try{let e=await r.stopGenerateAllChatAbouts();e&&f(e.generateAll)}finally{y(!1)}},ne=(0,v.useMemo)(()=>Kf(C.range,D,{from:C.from,to:C.to}),[C,D]),N=(0,v.useMemo)(()=>{let e=(a?.chats??[]).filter(e=>qf(e.updatedAt,ne)),t=e=>{let t=Date.parse(e.updatedAt);return Number.isFinite(t)?t:0};return[...e].sort((e,n)=>t(n)-t(e))},[a,ne]),P=(0,v.useMemo)(()=>{let e=p.trim().toLowerCase();return e?N.filter(t=>t.title.toLowerCase().includes(e)||(t.about??``).toLowerCase().includes(e)):N},[N,p]),re=(0,v.useMemo)(()=>P.map(e=>e.sessionId),[P]),ie=re.join(`,`);(0,v.useEffect)(()=>{E(e=>Wy(e,re))},[ie]);let ae=(0,v.useMemo)(()=>P.filter(e=>T.has(e.sessionId)),[P,T]),oe=Hy(re,T),se=(0,v.useRef)(null);(0,v.useEffect)(()=>{se.current&&(se.current.indeterminate=oe===`some`)});let F=jAe({open:e,picked:ae}),ce=F.active||F.state.status===`error`,le=(0,v.useMemo)(()=>new Set(F.state.playlist),[F.state.playlist]),ue=ce?F.state.sessionId:null,de=e=>E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),fe=Uf.find(e=>e.id===C.range)?.label??``,pe=(0,v.useCallback)(e=>n.sessions.find(t=>t.id===e)?.entryCount??null,[n.sessions]),me=a?If(a.totals):null,he=d?.running===!0;return(0,B.jsxs)(gC,{open:e,title:`What your chats are about`,onClose:t,wide:!0,footer:(0,B.jsxs)(B.Fragment,{children:[a!==null&&!s?(0,B.jsx)(NAe,{b:F}):null,(0,B.jsx)(U,{variant:`ghost`,onClick:t,children:`Close`})]}),children:[(0,B.jsxs)(`p`,{className:`mb-3 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,B.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,B.jsx)(uC,{label:`What your chats are about`,details:(0,B.jsx)(dC,{items:[...Vf.what,...Vf.when,...Vf.who,...Vf.yours,...Vf.where]})})]}),s?(0,B.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,B.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,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(`div`,{className:`rounded-md border border-border px-3`,children:(0,B.jsx)(_C,{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:[Vf.switch,...Vf.who],checked:j,disabled:b,onChange:e=>void ee(e),testId:`chat-abouts-switch`})}),me?(0,B.jsxs)(`div`,{className:`text-xs text-fg-muted`,"data-testid":`chat-abouts-totals`,children:[(0,B.jsx)(`span`,{className:`font-medium text-fg`,children:`All about calls so far: `}),(0,B.jsx)(`span`,{"data-testid":`chat-abouts-totals-line`,children:me.line}),me.unpriced?(0,B.jsx)(`span`,{className:`block text-fg-faint`,"data-testid":`chat-abouts-totals-unpriced`,children:me.unpriced}):null]}):null,(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,B.jsxs)(U,{size:`sm`,variant:`primary`,onClick:()=>void M(),busy:h,disabled:!j||he,title:j?Vf.generateAll:Vf.regenerateOff,"data-testid":`chat-abouts-generate-all`,children:[(0,B.jsx)(H.Refresh,{className:`h-3 w-3`}),` Generate for all chats now`]}),(0,B.jsx)(uC,{label:`Generate for all chats now`,details:Vf.generateAll})]}),he?(0,B.jsxs)(U,{size:`sm`,variant:`danger`,onClick:()=>void te(),busy:_,title:Vf.stop,"data-testid":`chat-abouts-stop`,children:[(0,B.jsx)(H.Stop,{className:`h-3 w-3`}),` Stop`]}):null]}),d?(0,B.jsx)(FAe,{g:d}):null,(0,B.jsx)(MAe,{b:F,picked:ae,enabled:j,generateAll:d,onGenerated:f}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`Last active`,(0,B.jsx)(`select`,{"aria-label":`Last active`,className:z(mC,`text-xs`),value:C.range,onChange:e=>A({range:e.target.value}),"data-testid":`chat-abouts-range`,children:Uf.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),C.range===`custom`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`From`,(0,B.jsx)(`input`,{type:`date`,"aria-label":`From`,className:z(pC,`text-xs`),value:C.from,onChange:e=>A({from:e.target.value}),"data-testid":`chat-abouts-from`})]}),(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`To`,(0,B.jsx)(`input`,{type:`date`,"aria-label":`To`,className:z(pC,`text-xs`),value:C.to,onChange:e=>A({to:e.target.value}),"data-testid":`chat-abouts-to`})]})]}):null,(0,B.jsx)(`input`,{className:z(pC,`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`})]}),P.length>0?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,B.jsxs)(`label`,{className:`inline-flex items-center gap-2 font-medium text-fg`,children:[(0,B.jsx)(`input`,{ref:se,type:`checkbox`,checked:oe===`all`,"aria-checked":oe===`some`?`mixed`:oe===`all`,onChange:()=>E(e=>Uy(re,e)),"data-testid":`chat-abouts-select-all`}),`Select all`]}),(0,B.jsxs)(`span`,{className:`text-fg-muted`,"data-testid":`chat-abouts-count`,children:[P.length,` chat`,P.length===1?``:`s`,ae.length>0?` · ${ae.length} picked`:``]})]}):null,a.chats.length===0?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-empty`,children:`No chats on this PC yet.`}):P.length===0?(0,B.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 ${fe.toLowerCase()}`}.`:`No chat was active in ${C.range===`custom`?`that range`:fe.toLowerCase()}.`}):(0,B.jsx)(`ul`,{className:`space-y-2`,"data-testid":`chat-abouts-list`,children:P.map(e=>(0,B.jsx)(IAe,{row:e,enabled:j,entryCount:pe(e.sessionId),checked:T.has(e.sessionId),onToggle:()=>de(e.sessionId),playing:ue===e.sessionId,onJump:ce&&le.has(e.sessionId)?()=>F.jumpTo(e.sessionId):null,onOpen:()=>{r.selectSession(e.sessionId)}},e.sessionId))})]})]})}function FAe({g:e}){let t=e.total>0?Math.round(Math.min(e.done,e.total)/e.total*100):100;return(0,B.jsxs)(`div`,{className:`space-y-1 text-xs`,"data-testid":`chat-abouts-progress`,children:[(0,B.jsx)(`div`,{className:`text-fg-muted`,"data-testid":`chat-abouts-progress-line`,children:Rf(e)}),(0,B.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,B.jsx)(`div`,{className:z(`h-full rounded-full`,e.running?`bg-accent`:`bg-fg-faint`),style:{width:`${t}%`}})}),!e.running&&e.stoppedReason?(0,B.jsxs)(`div`,{className:`text-warn`,"data-testid":`chat-abouts-stopped-reason`,children:[`Stopped: `,e.stoppedReason]}):null]})}function IAe({row:e,enabled:t,entryCount:n,checked:r,onToggle:i,playing:a,onJump:o,onOpen:s}){let c=e.title.trim()||`Untitled chat`,l=jf(e),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>{a&&u.current?.scrollIntoView?.({block:`nearest`})},[a]),(0,B.jsxs)(`li`,{ref:u,className:z(`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,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.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,B.jsx)(H.Speaker,{className:`h-3.5 w-3.5 text-accent`,title:`Playing`}):null,(0,B.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,B.jsx)(`span`,{title:Vf.yours[0],children:(0,B.jsx)(hC,{tone:`accent`,children:`yours`})}):null,e.stale&&e.about?(0,B.jsx)(`span`,{title:Vf.stale,"data-testid":`chat-about-stale`,children:(0,B.jsx)(hC,{tone:`warn`,children:`stale`})}):null,e.pending?(0,B.jsx)(`span`,{"data-testid":`chat-about-pending`,children:(0,B.jsx)(hC,{tone:`accent`,children:`writing…`})}):null]}),e.about?(0,B.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,B.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,B.jsxs)(`p`,{className:`mt-1 text-fg-muted`,"data-testid":`chat-about-missing`,children:[`No about yet. `,Lf(e,{enabled:t,entryCount:n})]}),e.about&&e.lastError?(0,B.jsxs)(`p`,{className:`mt-0.5 text-danger`,"data-testid":`chat-about-error`,children:[`The last attempt failed: `,e.lastError]}):null,(0,B.jsxs)(`div`,{className:`mt-1 flex flex-wrap justify-between gap-x-3 gap-y-0.5 text-[11px] text-fg-faint`,children:[(0,B.jsxs)(`span`,{title:zv(e.updatedAt),"data-testid":`chat-about-active`,children:[`Active `,Lv(e.updatedAt)]}),e.about&&e.aboutAt?(0,B.jsxs)(`span`,{title:zv(e.aboutAt),"data-testid":`chat-about-written`,children:[`Written `,Lv(e.aboutAt),l?` by ${l}`:``]}):(0,B.jsx)(`span`,{}),(0,B.jsx)(`span`,{title:e.route?`Paid by ${Mf[e.route]}`:void 0,"data-testid":`chat-about-spend`,children:Ff(e.spend,e.route)})]})]})}function LAe({open:e,onClose:t}){let{state:n,actions:r}=V(),i=n.nextPromptsChange,[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)(()=>Db()),[h,g]=(0,v.useState)(()=>Tb()),[_,y]=(0,v.useState)(()=>new Set),[b,x]=(0,v.useState)(()=>Date.now()),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)({}),[O,k]=(0,v.useState)(()=>new Set),[A,j]=(0,v.useState)({}),[ee,M]=(0,v.useState)(()=>new Set),[te,ne]=(0,v.useState)({}),N=(0,v.useRef)(-1),P=(0,v.useCallback)(async()=>{let e=await r.listNextPrompts();if(e===`unsupported`){c(!0);return}if(e===null){u(!0);return}c(!1),u(!1),o(e),f(e.review)},[r]);(0,v.useEffect)(()=>{e&&(N.current=i.seq,x(Date.now()),P())},[e]),(0,v.useEffect)(()=>{!e||i.seq===N.current||(N.current=i.seq,i.review!==void 0&&f(i.review),P())},[e,i,P]);let re=e=>{m(t=>{let n={...t,...e};return Ob(n),n}),x(Date.now())},ie=(0,v.useMemo)(()=>{let e=new Map;for(let t of a?.suggestions??[])e.set(t.sessionId,t);return e},[a]),ae=(0,v.useMemo)(()=>Kf(p.range,b,{from:p.from,to:p.to}),[p,b]),oe=(0,v.useMemo)(()=>{let e=e=>{let t=Date.parse(e.updatedAt);return Number.isFinite(t)?t:0};return n.sessions.filter(e=>!n.remote.tabs[e.id]&&qf(e.updatedAt,ae)).sort((t,n)=>e(n)-e(t))},[n.sessions,n.remote.tabs,ae]),se=(0,v.useMemo)(()=>oe.map(e=>e.id),[oe]),F=se.join(`,`);(0,v.useEffect)(()=>{y(e=>Wy(e,se))},[F]);let ce=(0,v.useMemo)(()=>se.filter(e=>_.has(e)),[se,_]),le=Hy(se,_),ue=(0,v.useRef)(null);(0,v.useEffect)(()=>{ue.current&&(ue.current.indeterminate=le===`some`)});let de=e=>y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),fe=d?.running===!0,pe=a?.model??dm.model,me=Uf.find(e=>e.id===p.range)?.label??``,he=async()=>{if(ce.length!==0){C(!0);try{let e=await r.reviewNextPrompts(ce,h);e&&f(e)}finally{C(!1)}}},ge=async()=>{T(!0);try{let e=await r.stopNextPromptReview();e&&f(e)}finally{T(!1)}},_e=async e=>{k(t=>new Set(t).add(e)),j(({[e]:t,...n})=>n);try{let t=await r.suggestNextPrompt(e,{windowHours:h,force:!0});if(`error`in t){j(n=>({...n,[e]:t.error}));return}o(n=>n&&{...n,suggestions:[t.suggestion,...n.suggestions.filter(t=>t.sessionId!==e)]})}finally{k(t=>{let n=new Set(t);return n.delete(e),n})}},ve=async(e,t,n)=>{let i=t.trim();if(i){M(t=>new Set(t).add(e));try{if(!await r.sendToChat(e,i))return;n&&r.markNextPromptSent(e,n.id,i),ne(t=>({...t,[e]:new Date().toISOString()})),D(({[e]:t,...n})=>n)}finally{M(t=>{let n=new Set(t);return n.delete(e),n})}}};return(0,B.jsxs)(gC,{open:e,title:mm.managerTitle,onClose:t,wide:!0,footer:(0,B.jsx)(U,{variant:`ghost`,onClick:t,children:`Close`}),children:[(0,B.jsx)(`p`,{className:`mb-3 text-xs text-fg-muted`,"data-testid":`manager-hint`,children:mm.managerHint}),s?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`manager-unsupported`,children:`OonaCode on this PC is too old for the project manager. Update it, then open this window again.`}):a===null?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`manager-loading`,children:l?`Could not read the suggestions from this PC right now. They show here as soon as it answers.`:`Loading…`}):(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`Last active`,(0,B.jsx)(`select`,{"aria-label":`Last active`,className:z(mC,`text-xs`),value:p.range,onChange:e=>re({range:e.target.value}),"data-testid":`manager-range`,children:Uf.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),p.range===`custom`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`From`,(0,B.jsx)(`input`,{type:`date`,"aria-label":`From`,className:z(pC,`text-xs`),value:p.from,onChange:e=>re({from:e.target.value}),"data-testid":`manager-from`})]}),(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`To`,(0,B.jsx)(`input`,{type:`date`,"aria-label":`To`,className:z(pC,`text-xs`),value:p.to,onChange:e=>re({to:e.target.value}),"data-testid":`manager-to`})]})]}):null,(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`Read the last`,(0,B.jsx)(`select`,{"aria-label":`Hours of each chat to read`,className:z(mC,`text-xs`),value:h,onChange:e=>{let t=Number(e.target.value);g(t),Eb(t)},"data-testid":`manager-window`,children:fm.map(e=>(0,B.jsxs)(`option`,{value:e,children:[e,` hour`,e===1?``:`s`]},e))})]}),(0,B.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1.5`,children:[(0,B.jsxs)(U,{size:`sm`,variant:`primary`,onClick:()=>void he(),busy:S,disabled:ce.length===0||fe,"data-testid":`manager-review`,children:[(0,B.jsx)(H.Lightbulb,{className:`h-3 w-3`}),` Review selected (`,ce.length,`)`]}),fe?(0,B.jsxs)(U,{size:`sm`,variant:`danger`,onClick:()=>void ge(),busy:w,"data-testid":`manager-stop`,children:[(0,B.jsx)(H.Stop,{className:`h-3 w-3`}),` Stop`]}):null]})]}),d?(0,B.jsxs)(`div`,{className:`space-y-1 text-xs`,"data-testid":`manager-progress`,children:[(0,B.jsx)(`div`,{className:`text-fg-muted`,"data-testid":`manager-progress-line`,children:kb(d)}),(0,B.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`Review`,"aria-valuemin":0,"aria-valuemax":d.total,"aria-valuenow":d.done,children:(0,B.jsx)(`div`,{className:z(`h-full rounded-full`,d.running?`bg-accent`:`bg-fg-faint`),style:{width:`${d.total>0?Math.round(Math.min(d.done,d.total)/d.total*100):100}%`}})})]}):null,oe.length>0?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,B.jsxs)(`label`,{className:`inline-flex items-center gap-2 font-medium text-fg`,children:[(0,B.jsx)(`input`,{ref:ue,type:`checkbox`,checked:le===`all`,"aria-checked":le===`some`?`mixed`:le===`all`,onChange:()=>y(e=>Uy(se,e)),"data-testid":`manager-select-all`}),`Select all`]}),(0,B.jsxs)(`span`,{className:`text-fg-muted`,"data-testid":`manager-count`,children:[oe.length,` chat`,oe.length===1?``:`s`,ce.length>0?` · ${ce.length} picked`:``]})]}):null,oe.length===0?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`manager-empty`,children:n.sessions.length===0?`No chats on this PC yet.`:`No chat was active in ${p.range===`custom`?`that range`:me.toLowerCase()}.`}):(0,B.jsx)(`ul`,{className:`space-y-2`,"data-testid":`manager-list`,children:oe.map(e=>{let i=e.id,a=ie.get(i)??null,o=n.transcripts[i]?.status??e.status,s=te[i]&&(!a?.sentAt||te[i]>a.sentAt)?te[i]:a?.sentAt??null;return(0,B.jsx)(RAe,{session:e,status:o,suggestion:a,text:E[i]??a?.prompt??``,edited:E[i]!==void 0,checked:_.has(i),reviewing:O.has(i)||fe&&d.current.includes(i),error:A[i]??null,sending:ee.has(i),sentAt:s,onToggle:()=>de(i),onEdit:e=>D(t=>({...t,[i]:e})),onSend:e=>void ve(i,e,a),onSuggest:()=>void _e(i),onOpen:()=>{r.selectSession(i),t()}},i)})}),(0,B.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`manager-cost-note`,children:mm.costNote(pe)})]})]})}function RAe({session:e,status:t,suggestion:n,text:r,edited:i,checked:a,reviewing:o,error:s,sending:c,sentAt:l,onToggle:u,onEdit:d,onSend:f,onSuggest:p,onOpen:m}){let h=Gv(e),g=Nb(e,t),_=t===`running`||t===`waiting_permission`,v=n?.status===`failed`;return(0,B.jsxs)(`li`,{className:`rounded-md border border-border px-3 py-2 text-xs`,"data-testid":`manager-row-${e.id}`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`shrink-0`,checked:a,onChange:u,"aria-label":`Pick ${h}`,"data-testid":`manager-pick`}),(0,B.jsx)(nz,{status:t}),g?(0,B.jsx)(tz,{mark:g,testId:`manager-finished`}):null,(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:h}),(0,B.jsxs)(`span`,{className:`shrink-0 text-[11px] text-fg-faint`,title:zv(e.updatedAt),"data-testid":`manager-active`,children:[`Active `,Lv(e.updatedAt)]})]}),o?(0,B.jsxs)(`p`,{className:`mt-1 flex items-center gap-1.5 text-fg-muted`,"data-testid":`manager-reading`,children:[(0,B.jsx)(H.Spinner,{className:`h-3 w-3`}),mm.reviewing(n?.windowHours??dm.windowHours)]}):null,s?(0,B.jsx)(`p`,{className:`mt-1 text-danger`,"data-testid":`manager-error`,children:s}):null,n?v?(0,B.jsx)(`p`,{className:`mt-1 text-danger`,"data-testid":`manager-failed`,children:n.error??`The suggestion could not be written.`}):(0,B.jsxs)(`div`,{className:`mt-1 space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start gap-1.5`,children:[(0,B.jsx)(`p`,{className:`min-w-0 flex-1 text-fg`,"data-testid":`manager-state`,children:n.state||`Where the chat stands is not said.`}),n.stale?(0,B.jsx)(`span`,{title:`The chat has moved on since this was written — Suggest for a fresh one.`,"data-testid":`manager-stale`,children:(0,B.jsx)(hC,{tone:`warn`,children:`stale`})}):null,i?(0,B.jsx)(`span`,{title:`Your edit is kept until you send it`,"data-testid":`manager-edited`,children:(0,B.jsx)(hC,{tone:`accent`,children:`edited`})}):null]}),n.why?(0,B.jsx)(`p`,{className:`text-fg-muted`,"data-testid":`manager-why`,children:n.why}):null,n.prompt===``&&!i?(0,B.jsx)(`p`,{className:`text-warn`,"data-testid":`manager-decide`,children:mm.decideYourself}):null]}):!o&&!s?(0,B.jsx)(`p`,{className:`mt-1 text-fg-faint`,"data-testid":`manager-none`,children:`No suggestion yet — tick it and Review, or press Suggest.`}):null,n&&!v?(0,B.jsx)(`textarea`,{"aria-label":`Message for ${h}`,className:`mt-1.5 min-h-[4rem] w-full resize-y rounded-md border border-border bg-bg px-2 py-1.5 text-xs text-fg focus:border-accent focus:outline-none`,value:r,placeholder:`Write the message yourself, or press Suggest`,onChange:e=>d(e.target.value),"data-testid":`manager-text`}):null,(0,B.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,children:[(0,B.jsxs)(U,{size:`sm`,variant:`primary`,disabled:!r.trim()||c,busy:c,onClick:()=>f(r),title:_?`The chat is working: this waits for the running turn`:void 0,"data-testid":`manager-send`,children:[(0,B.jsx)(H.Send,{className:`h-3 w-3`}),` `,_?`Send — queues behind the running turn`:`Send`]}),(0,B.jsxs)(U,{size:`sm`,variant:`secondary`,disabled:o,onClick:p,"data-testid":`manager-suggest`,children:[(0,B.jsx)(H.Lightbulb,{className:`h-3 w-3`}),` Suggest`]}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:m,"data-testid":`manager-open`,children:`Open chat`}),l?(0,B.jsxs)(`span`,{className:`text-ok`,"data-testid":`manager-sent`,children:[`Sent `,jb(l)]}):null,n?(0,B.jsxs)(`span`,{className:`ml-auto text-[11px] text-fg-faint`,"data-testid":`manager-cost`,children:[Cm(n.cost),` · `,Lv(n.createdAt)]}):null]})]})}function zAe({open:e,onClose:t}){let{state:n,actions:r}=V(),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=Wv(a?Gv(a):o?.title??`New chat`);async function m(){if(i){d(!0);try{await r.setSessionProject(i,c)&&t()}finally{d(!1)}}}return(0,B.jsxs)(gC,{open:e,title:`Move “${p}” to a project`,onClose:t,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{variant:`ghost`,onClick:()=>{t(),r.openDialog(`projects`)},children:`Manage projects…`}),(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsx)(U,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,B.jsx)(U,{variant:`primary`,onClick:m,disabled:u||c===s,"data-testid":`assign-project-apply`,children:`Apply`})]}),children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-0.5`,role:`radiogroup`,"aria-label":`Project`,children:[(0,B.jsx)(e7,{selected:c===null,onSelect:()=>l(null),label:`No project`,testId:`assign-project-none`}),n.vaultProjects.map(e=>(0,B.jsx)(e7,{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,B.jsxs)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:[`No projects yet — create one under `,(0,B.jsx)(`em`,{children:`Manage projects…`}),`.`]}):null]}),f?(0,B.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,B.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 e7({selected:e,onSelect:t,label:n,hint:r,testId:i}){return(0,B.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e,onClick:t,className:z(`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,B.jsx)(`span`,{className:z(`inline-block h-3 w-3 rounded-full border`,e?`border-accent bg-accent`:`border-border`)}),(0,B.jsx)(H.Project,{className:`w-3.5 h-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),r?(0,B.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:r}):null]})}var BAe=`Install Google’s agy`,t7=`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).`,VAe=`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.`,HAe=`Sign in with Google`,UAe=`This PC’s OonaCode is too old to run chats on Google’s agy — update it from the title bar.`,WAe=`Kept on this PC only, in memory: it is gone when OonaCode stops, and it is never synced or sent anywhere.`,GAe=new Set([`loadCodeAssist`,`fetchAdminControls`,`retrieveUserQuotaSummary`,`fetchUserInfo`,`fetchAvailableModels`,`listExperiments`,`writeTrajectoryAcls`,`recordTrajectoryAnalytics`]);function KAe(e){return e.kind===`tunnel`||e.method!==null&&GAe.has(e.method)}function qAe(e){let t=[],n=[];for(let r of e)(KAe(r)?n:t).push(r);return{main:t,background:n}}function n7(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 r7(e){let{title:t,detail:n}=n7(e);return n?`${t} · ${n}`:t}function JAe(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 i7=e=>e.toLocaleString(`en-US`);function YAe(e){if(!e)return null;let t=e.cached>0?` (${i7(e.cached)} cached)`:``;return`in ${i7(e.input)}${t} · out ${i7(e.output)}`}function XAe(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``}function ZAe(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function QAe(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 a7(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 o7(e){let t=e.update;return t?t.state===`waiting`||t.state===`failed`||t.heldBack?t.message:t.state===`updating`?t.message??`OonaCode is updating agy…`:null:null}function s7(e){let t=e.group.trim(),n=e.window.trim();return t&&n.toLowerCase().startsWith(`${t.toLowerCase()} `)&&(n=n.slice(t.length).trim()),t?n?`${t} · ${n}`:t:n}function $Ae(e){let t=e.remainingPercent,n=t!==null&&Number.isFinite(t),r=zv(e.resetsAt);return{remaining:n?`${Math.round(Math.min(100,Math.max(0,t)))}% left`:`unknown`,tone:Tc(t),resets:r?`resets ${r}`:null}}var c7=1e3,eje=2e3;function tje(e){if(!e)return null;if(e.install.state===`working`)return c7;switch(e.login.phase){case`starting`:case`verifying`:return c7;case`awaiting_code`:return eje;default:return null}}function nje(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 rje(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 ije(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 aje(e){let{received:t,total:n}=e;return n!==null&&n>0?`${HF(t)} of ${HF(n)}`:t>0?HF(t):null}function oje(e){if(!e)return null;try{return new URL(e).protocol===`https:`?e:null}catch{return null}}function sje(e,t){return t?e.split(t).join(`…`):e}function cje(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 l7=15,lje=2e4,uje=5e3,u7=null;function dje(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 fje({install:e,busy:t,offer:n,onInstall:r,onCancel:i}){if(e.state===`working`){let n=ije(e),r=aje(e);return(0,B.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`agy-install`,"data-install-state":`working`,children:[(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-install-statement`,children:t7}),(0,B.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,B.jsx)(H.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[rje(e.phase),e.version?` (agy ${e.version})`:``]})]}),(0,B.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,B.jsx)(`div`,{className:z(`h-full rounded-full bg-accent`,n===null?`w-1/3 animate-pulse`:void 0),style:n===null?void 0:{width:`${n}%`}})}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-[11px] text-fg-faint`,"data-testid":`agy-install-bytes`,children:r??``}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,disabled:t,onClick:i,"data-testid":`agy-install-cancel`,children:`Cancel`})]})]})}return e.supported?e.state===`idle`&&!n?(0,B.jsx)(`div`,{className:`space-y-2`,"data-testid":`agy-install`,"data-install-state":`starting`,children:(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-install-statement`,children:t7})}):(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-install`,"data-install-state":e.state,children:[e.state===`failed`?(0,B.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,B.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-install-explanation`,children:VAe}),(0,B.jsxs)(U,{variant:`primary`,busy:t,disabled:t,onClick:r,"data-testid":e.state===`failed`?`agy-install-retry`:`agy-install-button`,children:[(0,B.jsx)(H.Download,{className:`h-4 w-4`}),` `,e.state===`failed`?`Try again`:BAe]})]}):null}function pje({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?oje(e.url):null,m=f&&e.expiresAt?Date.parse(e.expiresAt):NaN,h=Number.isFinite(m),g=dje(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||u7===e.startedAt)return;let t=h?Date.now()-(m-6e4):1/0;if(!(!b.current&&t>uje)){u7=e.startedAt;try{O5(p)}catch{}}},[e.phase,p,e.startedAt]),(0,v.useEffect)(()=>{f&&SI(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),lje);return()=>clearTimeout(t)},[e.phase]);let C=o.trim(),w=Lg(C),T=()=>{!w||t||(s(``),a(C))},E=()=>{p&&XI(p).then(e=>{e&&(l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),1500))})},D=(0,B.jsx)(U,{size:`sm`,variant:`ghost`,disabled:t,onClick:i,"data-testid":`agy-login-cancel`,children:`Cancel`});return(0,B.jsxs)(`div`,{ref:d,className:`space-y-2`,"data-testid":`agy-sign-in`,"data-login-phase":e.phase,children:[(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-sign-in-explanation`,children:Gee}),e.phase===`starting`?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`agy-login-starting`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-fg`,role:`status`,children:[(0,B.jsx)(H.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),e.message??`Starting Google’s sign-in…`]}),(0,B.jsx)(`span`,{className:`flex-1`}),D]}):e.phase===`awaiting_code`?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-awaiting`,children:[y?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-expired`,children:[(0,B.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,B.jsxs)(U,{variant:`primary`,busy:t,disabled:t,onClick:r,"data-testid":`agy-login-expired-restart`,children:[(0,B.jsx)(H.LogIn,{className:`h-4 w-4`}),` Sign in again`]})]}):(0,B.jsxs)(B.Fragment,{children:[e.message?(0,B.jsx)(`p`,{className:`text-xs text-fg`,children:e.message}):null,p?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.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(),O5(p)},"data-testid":`agy-login-link`,children:[(0,B.jsx)(H.ExternalLink,{className:`h-3.5 w-3.5`}),` Open Google’s sign-in page`]}),(0,B.jsxs)(U,{size:`sm`,onClick:E,"data-testid":`agy-login-copy-link`,children:[(0,B.jsx)(H.Copy,{className:`h-3.5 w-3.5`}),` `,c?`Copied`:`Copy link`]})]}):null,(0,B.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-fg`,children:[(0,B.jsxs)(`span`,{className:`flex items-baseline justify-between gap-2`,children:[`Code from Google`,_===null?null:(0,B.jsxs)(`span`,{role:`timer`,className:z(`font-normal tabular-nums`,_<l7?`font-medium text-warn`:`text-fg-faint`),"data-tone":_<l7?`warn`:`neutral`,"data-testid":`agy-login-countdown`,children:[_,` s left to finish`]})]}),(0,B.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()??``;Lg(n)&&(e.preventDefault(),!t&&(s(``),a(n)))},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},"data-testid":`agy-login-code`})]}),C&&!w?(0,B.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,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(U,{variant:`primary`,size:`sm`,disabled:!w||t,onClick:T,"data-testid":`agy-login-continue`,children:`Continue`}),D]})]}),y?(0,B.jsx)(`div`,{className:`flex items-center gap-2`,children:D}):null]}):e.phase===`verifying`?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`agy-login-verifying`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-fg`,role:`status`,children:[(0,B.jsx)(H.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),e.message??`Checking the code with Google…`]}),(0,B.jsx)(`span`,{className:`flex-1`}),D,x?(0,B.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,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-failed`,children:[(0,B.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,B.jsxs)(U,{variant:`primary`,busy:t,disabled:t,onClick:n,"data-testid":`agy-sign-in-restart`,children:[(0,B.jsx)(H.LogIn,{className:`h-4 w-4`}),` Start again`]})]}):(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[e.phase===`done`&&e.message?(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.message}):null,(0,B.jsxs)(U,{variant:`primary`,busy:t,disabled:t,onClick:n,"data-testid":`agy-sign-in-button`,children:[(0,B.jsx)(H.LogIn,{className:`h-4 w-4`}),` `,HAe]})]})]})}var mje={ok:`bg-ok`,warn:`bg-warn`,danger:`bg-danger`,neutral:`bg-surface-3`},hje={ok:`text-ok`,warn:`text-warn`,danger:`text-danger`,neutral:`text-fg-muted`};function d7({label:e,testid:t,children:n}){return(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 py-0.5 text-xs`,children:[(0,B.jsx)(`dt`,{className:`shrink-0 text-fg-faint`,children:e}),(0,B.jsx)(`dd`,{className:`min-w-0 text-right font-medium text-fg`,"data-testid":t,children:n})]})}var gje=new Set([`starting`,`awaiting_code`,`verifying`,`failed`]);function f7(e){if(e.adding)return{addAccount:!0};if(e.accountId)return{accountId:e.accountId}}function p7(e){return e.email??(e.main?`Your first Google account`:`A Google account`)}function m7({usage:e,prefix:t}){return(0,B.jsx)(`ul`,{className:`space-y-2`,children:e.map((e,n)=>{let r=$Ae(e),i=e.remainingPercent;return(0,B.jsxs)(`li`,{"data-testid":`${t}-row-${n}`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:s7(e)}),(0,B.jsx)(`span`,{className:z(`shrink-0 font-medium`,hje[r.tone]),"data-tone":r.tone,"data-testid":`${t}-remaining-${n}`,children:r.remaining})]}),(0,B.jsx)(`div`,{className:`mt-0.5 h-1.5 w-full overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`${s7(e)}: ${r.remaining}`,"aria-valuemin":0,"aria-valuemax":100,...i!==null&&Number.isFinite(i)?{"aria-valuenow":Math.round(i)}:{},children:(0,B.jsx)(`div`,{className:z(`h-full rounded-full`,mje[r.tone]),style:{width:`${i!==null&&Number.isFinite(i)?Math.min(100,Math.max(0,i)):0}%`}})}),r.resets?(0,B.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:r.resets}):null]},`${e.group}-${e.window}-${n}`)})})}function h7({definition:e}){let{api:t,socket:n}=V(),[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,g]=(0,v.useState)(null),_=(0,v.useRef)(!0),y=(0,v.useRef)(0),b=(0,v.useRef)(0);(0,v.useEffect)(()=>(_.current=!0,()=>{_.current=!1}),[]);let x=(0,v.useCallback)(async(e,n=!1)=>{let r=++y.current;if(!t.getAgyStatus){o(!0);return}b.current+=1,n||u(e=>e+1);try{let n=await t.getAgyStatus(e?{refresh:!0}:void 0);if(!_.current||r!==y.current)return;i(n),c(null),o(!1)}catch(e){if(!_.current||r!==y.current)return;Zg(e)?o(!0):c(Kv(e))}finally{--b.current,!n&&_.current&&u(e=>e-1)}},[t]),S=(0,v.useCallback)(async(e,t,n=``)=>{y.current+=1,f(e),m(null);try{let e=await t();return _.current?(y.current+=1,i(e),c(null),o(!1),e):null}catch(e){return _.current&&(Zg(e)?o(!0):(m(sje(Kv(e),n)),x(!1,!0))),null}finally{_.current&&f(null)}},[x]);(0,v.useEffect)(()=>{x(!1)},[x]);let[C,w]=(0,v.useState)(!1),T=(0,v.useCallback)(async()=>{if(!t.agyInstall){o(!0);return}w(!0),await S(`install`,()=>t.agyInstall())},[t,S]),E=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!(E.current||!r||!t.agyInstall)){if(r.install.state!==`idle`){E.current=!0;return}r.state!==`not_installed`||!r.install.supported||(E.current=!0,T())}},[r,t,T]);let D=tje(r);(0,v.useEffect)(()=>{if(D===null)return;let e=setInterval(()=>{b.current===0&&x(!1,!0)},D);return()=>clearInterval(e)},[D,x]),(0,v.useEffect)(()=>n.on(`account_changed`,e=>{e.reason===`provider`&&x(!1,!0)}),[n,x]);let O=Qs(e);if(a)return(0,B.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:UAe});let k=r===null&&s===null,A=l>0,j=nje(r),ee=r?.install.state===`working`,M=(0,B.jsx)(U,{variant:`primary`,size:`sm`,busy:A||k,disabled:A||k||j,onClick:()=>void x(!0),"data-testid":`agy-check-again`,children:A||k?`Checking…`:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(H.Refresh,{className:`h-3.5 w-3.5`}),` Check again`]})}),te=r?ee?{label:`Installing agy…`,tone:`accent`}:QAe(r.state):null,ne=r?.accounts??[],N=!!r?.login.accountId&&gje.has(r?.login.phase??`idle`),P=N?ne.find(e=>e.id===r?.login.accountId)??null:null,re=ne.length>1?ne.filter(e=>e.usage.length>0).map(e=>({id:e.id,title:p7(e),usage:e.usage})):r&&r.usage.length>0?[{id:null,title:null,usage:r.usage}]:[];return(0,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`agy-card`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,B.jsx)(hC,{tone:`ok`,children:O.badge}),(0,B.jsx)(hC,{children:e.kind})]}),(0,B.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:O.detail}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[te?(0,B.jsx)(`span`,{"data-testid":`agy-state`,"data-state":r?.state,children:(0,B.jsx)(hC,{tone:te.tone,children:te.label})}):k?(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,"data-testid":`agy-checking`,children:[(0,B.jsx)(H.Spinner,{className:`h-3.5 w-3.5`}),` Asking agy…`]}):null,(0,B.jsx)(`span`,{className:`flex-1`}),M]}),A&&r?(0,B.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,B.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,B.jsxs)(B.Fragment,{children:[r.state!==`ready`&&r.message&&!j?(0,B.jsx)(`p`,{className:`text-xs text-fg`,"data-testid":`agy-message`,children:r.message}):null,r.state===`not_installed`?(0,B.jsx)(fje,{install:r.install,busy:d===`install`||d===`cancel_install`,offer:!t.agyInstall||C&&d!==`install`,onInstall:()=>{E.current=!0,T()},onCancel:()=>{E.current=!0,w(!0),t.cancelAgyInstall&&S(`cancel_install`,()=>t.cancelAgyInstall())}}):null,r.state===`not_signed_in`||N?(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[N?(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg`,"data-testid":`agy-account-flow`,children:r.login.adding?`Adding another Google account`:`Signing ${P?p7(P):`this Google account`} in again`}):null,(0,B.jsx)(pje,{login:r.login,busy:d===`login`||d===`cancel_login`||d===`code`,onStart:()=>{let e=r.login.phase===`failed`?f7(r.login):void 0;t.agyLogin?S(`login`,()=>t.agyLogin(e)):o(!0)},onRestart:()=>{let e=f7(r.login);(async()=>{t.cancelAgyLogin&&await S(`cancel_login`,()=>t.cancelAgyLogin()),t.agyLogin?await S(`login`,()=>t.agyLogin(e)):o(!0)})()},onCancel:()=>{t.cancelAgyLogin&&S(`cancel_login`,()=>t.cancelAgyLogin())},onSubmit:e=>{t.submitAgyLoginCode?S(`code`,()=>t.submitAgyLoginCode(e),e):o(!0)}})]}):null,ne.length>0&&r.state!==`not_installed`?(0,B.jsxs)(`div`,{"data-testid":`agy-accounts`,children:[(0,B.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-muted`,children:ne.length>1?`Google accounts (${ne.length})`:`Google account`}),(0,B.jsx)(`ul`,{className:`space-y-1`,children:ne.map(e=>(0,B.jsxs)(`li`,{className:`space-y-1 rounded-md border border-border px-2.5 py-1.5`,"data-testid":`agy-account-${e.id}`,title:`${p7(e)}${e.linkedAt?` · linked ${zv(e.linkedAt)}`:``}${e.isDefault&&ne.length>1?` · new chats use it`:``}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-fg`,"data-testid":`agy-account-email`,children:p7(e)}),e.isDefault&&ne.length>1?(0,B.jsx)(hC,{tone:`accent`,children:`default`}):null,(0,B.jsx)(`span`,{"data-testid":`agy-account-state`,children:(0,B.jsx)(hC,{tone:e.checking?`neutral`:e.signedIn?`ok`:e.signedIn===!1?`warn`:`neutral`,children:e.checking?`Checking…`:e.signedIn?`Signed in`:e.signedIn===!1?`Signed out`:`Unknown`})}),t.agyLogin?(0,B.jsx)(U,{size:`sm`,disabled:j||d!==null,onClick:()=>void S(`login`,()=>t.agyLogin({accountId:e.id})),"data-testid":`agy-account-signin-${e.id}`,children:`Sign in again`}):null,!e.main&&t.removeAgyAccount&&h!==e.id?(0,B.jsx)(U,{size:`sm`,variant:`ghost`,disabled:d!==null,onClick:()=>g(e.id),"data-testid":`agy-account-remove-${e.id}`,children:`Remove`}):null]}),h===e.id?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg`,"data-testid":`agy-account-remove-confirm-${e.id}`,children:[(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`Remove `,p7(e),` from this PC? Its sign-in here goes; chats that ran on it ask for another account.`]}),(0,B.jsx)(U,{size:`sm`,variant:`danger`,busy:d===`remove`,disabled:d!==null,onClick:()=>{g(null),S(`remove`,()=>t.removeAgyAccount(e.id))},"data-testid":`agy-account-remove-yes-${e.id}`,children:`Remove`}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>g(null),"data-testid":`agy-account-remove-no-${e.id}`,children:`Keep`})]}):null]},e.id))}),r.state===`ready`&&t.agyLogin&&!N?(0,B.jsx)(`div`,{className:`mt-1.5`,children:(0,B.jsxs)(U,{size:`sm`,disabled:j||d!==null,onClick:()=>void S(`login`,()=>t.agyLogin({addAccount:!0})),"data-testid":`agy-add-account`,children:[(0,B.jsx)(H.LogIn,{className:`h-3.5 w-3.5`}),` Add another Google account`]})}):null]}):null,p?(0,B.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,B.jsxs)(`dl`,{className:`rounded-md border border-border px-3 py-1.5`,"data-testid":`agy-facts`,children:[(0,B.jsx)(d7,{label:`Installed`,testid:`agy-installed`,children:r.installed?`Yes`:`No`}),r.path?(0,B.jsx)(d7,{label:`Path`,testid:`agy-path`,children:(0,B.jsx)(`span`,{className:`break-all font-mono text-[11px]`,children:r.path})}):null,r.version?(0,B.jsx)(d7,{label:`Version`,testid:`agy-version`,children:r.version}):null,(0,B.jsx)(d7,{label:`Signed in`,testid:`agy-signed-in`,children:r.signedIn===null?r.installed?`Unknown`:`—`:r.signedIn?`Yes`:`No`}),(0,B.jsx)(d7,{label:`Checked`,testid:`agy-checked`,children:(0,B.jsx)(`span`,{title:zv(r.checkedAt),children:Lv(r.checkedAt)})})]}),a7(r)?(0,B.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,B.jsx)(H.Info,{className:`mt-px h-3.5 w-3.5 shrink-0`}),a7(r)]}):null,o7(r)?(0,B.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-update-note`,children:[(0,B.jsx)(H.Info,{className:`mt-px h-3.5 w-3.5 shrink-0`}),o7(r)]}):null,r.models.length>0?(0,B.jsxs)(`div`,{"data-testid":`agy-models`,children:[(0,B.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-muted`,children:`Models agy offers`}),(0,B.jsx)(`ul`,{className:`space-y-0.5`,children:r.models.map(e=>(0,B.jsxs)(`li`,{className:`flex items-baseline justify-between gap-3 text-xs`,"data-testid":`agy-model-${e.id}`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.displayName}),(0,B.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-fg-faint`,children:e.id})]},e.id))})]}):null,re.map(e=>e.id===null?(0,B.jsxs)(`div`,{"data-testid":`agy-usage`,children:[(0,B.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-muted`,children:`Your plan’s usage`}),(0,B.jsx)(m7,{usage:e.usage,prefix:`agy-usage`})]},`default`):(0,B.jsxs)(`div`,{"data-testid":`agy-usage-${e.id}`,children:[(0,B.jsxs)(`div`,{className:`mb-1 truncate text-xs font-medium text-fg-muted`,children:[e.title,` — plan usage`]}),(0,B.jsx)(m7,{usage:e.usage,prefix:`agy-usage-${e.id}`})]},e.id))]}):null]})}var _je=1e3;function g7(e){return`${(e/1048576).toFixed(+(e<10485760))} MB`}var vje={download:`Downloading Muse from Meta…`,verify:`Checking the download against Meta’s checksum…`,place:`Setting Muse up…`};function yje({open:e,label:t,onClose:n,intent:r}){let{api:i,actions:a}=V(),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(`checking`),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(!1),m=(0,v.useRef)(null),h=(0,v.useRef)(!1),g=(0,v.useCallback)(async()=>{if(!i.museSetup)return null;try{let e=await i.museSetup();return s(e),e}catch{return null}},[i]),_=(0,v.useCallback)(async()=>{if(!i.museLoginStart){l(`unavailable`);return}d(null),h.current=!1,m.current=null,l(`running`);try{s(await i.museLoginStart(r))}catch(e){d(e instanceof Error?e.message:String(e)),l(`stopped`)}},[i,r]);(0,v.useEffect)(()=>{if(!e)return;let t=!0;return l(`checking`),d(null),s(null),(async()=>{if(!i.museSetup||!i.museLoginStart){t&&l(`unavailable`);return}let e=await g();if(t){if(!e){l(`unavailable`);return}e.login.phase===`awaiting_approval`||e.install.state===`working`?l(`running`):e.installed?_():l(`confirm`)}})(),()=>{t=!1}},[e,i,g,_]),(0,v.useEffect)(()=>{if(!e||c!==`running`)return;let t=setInterval(()=>void g(),_je);return()=>clearInterval(t)},[e,c,g]);let y=o?.login??null,b=o?.install??null,x=y?.phase===`awaiting_approval`,S=x&&(y?.verificationUriComplete??y?.verificationUri)?y?.verificationUriComplete??y?.verificationUri??null:null;(0,v.useEffect)(()=>{!e||!S||!y?.id||m.current===y.id||zg(S)&&(m.current=y.id,O5(S))},[e,S,y?.id]),(0,v.useEffect)(()=>{e&&y?.phase===`connected`&&!h.current&&(h.current=!0,a.refreshCredentials())},[e,y?.phase,a]);let C=async()=>{try{i.museLoginCancel&&s(await i.museLoginCancel())}catch{}l(`stopped`)},w=e=>{if(!navigator.clipboard){a.toast(`error`,`Could not copy — select it and copy by hand`);return}navigator.clipboard.writeText(e).then(()=>{p(!0),setTimeout(()=>p(!1),2e3)}).catch(()=>a.toast(`error`,`Could not copy`))},T=y?.phase===`connected`,E=y?.phase===`failed`||y?.phase===`expired`||y?.phase===`cancelled`,D=b?.state===`failed`,O=b?.state===`working`,k=b?.total&&b.total>0?Math.min(100,Math.floor(b.received/b.total*100)):null,A;return A=c===`unavailable`?(0,B.jsx)(`p`,{"data-testid":`muse-unavailable`,children:`This version of OonaCode on this PC cannot sign in with Meta. Paste your Muse key in the Connect window instead.`}):c===`checking`||!o?(0,B.jsx)(`p`,{children:`Looking at this PC…`}):c===`confirm`?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`muse-confirm`,children:[(0,B.jsxs)(`p`,{children:[`To sign you in, OonaCode will download Meta’s own `,(0,B.jsx)(`b`,{children:`Muse`}),` program once (about`,` `,505,` MB) into its own folder, checked against Meta’s published checksum. It runs only to sign you in.`]}),(0,B.jsx)(`p`,{className:`text-fg-muted`,children:`You then approve a short code on Meta’s page. Your key is stored in your vault; chats run from this PC straight to Meta, not through Muse. Nothing is downloaded until you press the button.`})]}):T?(0,B.jsx)(`p`,{"data-testid":`muse-connected`,children:`Signed in. Your Meta Muse key is stored in your vault and synced to your other machines; chats on it run from this PC straight to Meta.`}):O?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`muse-install`,children:[(0,B.jsx)(`p`,{children:vje[b?.phase??`download`]??`Installing Muse…`}),(0,B.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded bg-surface-2`,children:(0,B.jsx)(`div`,{className:`h-2 bg-accent`,style:{width:`${k??5}%`},"data-testid":`muse-install-bar`})}),(0,B.jsx)(`p`,{className:`text-fg-muted text-xs`,children:b&&b.received>0?`${g7(b.received)}${b.total?` of ${g7(b.total)}`:``}`:`Starting the download…`})]}):D?(0,B.jsx)(`p`,{className:`text-danger`,"data-testid":`muse-install-failed`,children:b?.error??`Muse could not be installed.`}):x&&y?(0,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`muse-awaiting`,children:[(0,B.jsx)(`p`,{children:`A sign-in page from Meta opened in your browser. If it did not, open the link below on any device and make sure this code matches:`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`code`,{className:`text-lg font-mono px-2 py-1 rounded border border-border`,"data-testid":`muse-user-code`,children:y.userCode}),(0,B.jsxs)(U,{onClick:()=>y.userCode&&w(y.userCode),children:[(0,B.jsx)(H.Copy,{className:`w-4 h-4`}),` `,f?`Copied`:`Copy code`]})]}),S&&zg(S)?(0,B.jsxs)(`div`,{className:`flex items-center gap-2 break-all`,children:[(0,B.jsx)(`a`,{className:`underline`,href:S,onClick:e=>{e.preventDefault(),O5(S)},children:S}),(0,B.jsxs)(U,{onClick:()=>w(S),children:[(0,B.jsx)(H.Copy,{className:`w-4 h-4`}),` Copy link`]})]}):null,(0,B.jsxs)(`p`,{className:`text-fg-muted`,children:[`Waiting for your approval…`,y.expiresAt?` The code expires at ${new Date(y.expiresAt).toLocaleTimeString()}.`:``,` `,`The key is stored in your vault the moment Meta confirms it.`]})]}):E||c===`stopped`?(0,B.jsx)(`p`,{className:E&&y?.phase!==`cancelled`?`text-danger`:``,"data-testid":`muse-ended`,children:u??y?.message??`The sign-in did not complete.`}):(0,B.jsx)(`p`,{children:y?.message??`Getting Meta’s sign-in page ready…`}),(0,B.jsx)(gC,{open:e,title:t,onClose:()=>n(T),footer:(0,B.jsxs)(B.Fragment,{children:[c===`running`&&!T&&!E&&!D?(0,B.jsx)(U,{onClick:()=>void C(),"data-testid":`muse-cancel`,children:`Cancel`}):null,c===`confirm`?(0,B.jsx)(U,{variant:`primary`,onClick:()=>void _(),"data-testid":`muse-start`,children:`Download and sign in`}):null,(c===`stopped`||E||D)&&!T&&c!==`unavailable`?(0,B.jsx)(U,{onClick:()=>void _(),"data-testid":`muse-retry`,children:`Try again`}):null,(0,B.jsx)(U,{variant:`primary`,onClick:()=>n(T),children:T?`Done`:`Close`})]}),children:(0,B.jsx)(`div`,{className:`space-y-3 text-sm`,"data-testid":`muse-login-dialog`,children:A})})}function bje(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 xje(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 Sje(e){let t=[];for(let n of e){let e=n.definition,r=qs(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.museCliLogin?`muse`:e.subscriptionLogin?`oauth`:`claude`:null,keyFormat:r[0]?.keyFormat??e.keyFormat})}return t}function _7(e){let t=(e.provider.credentials??[]).filter(e=>e.class!==`none`),n=e.variantId?t.filter(t=>(t.variantId??`payg`)===e.variantId):t;if(!e.isSubscription)return n.slice(0,1);let r=new Set;return n.filter(e=>{let t=e.accountKey??``;return!r.has(t)&&(r.add(t),!0)})}function Cje(e){return e.isSubscription&&(e.loginKind===`oauth`||e.loginKind===`muse`||e.loginKind===null)}function wje({open:e,providerId:t,onClose:n}){let{state:r,actions:i}=V(),a=(0,v.useMemo)(()=>t?xje(r.providers,t):[],[r.providers,t]),o=(0,v.useMemo)(()=>Sje(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,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(void 0),[w,T]=(0,v.useState)(!1),E=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),x(!1),C(void 0),T(!1)},[e,t,o]),(0,v.useEffect)(()=>{if(!e||!E)return;let t=E.provider.definition;f(t.userBaseUrl?E.variant?.baseUrl??t.baseUrl:``)},[e,E,E?.key]),!E)return null;let D=E.provider.definition,O=a[0]?.definition?.displayName??D.displayName;if(D.engine===`agy`)return(0,B.jsx)(gC,{open:e,title:O,onClose:n,footer:(0,B.jsx)(U,{onClick:n,children:`Close`}),children:(0,B.jsx)(h7,{definition:D})});if(b)return(0,B.jsx)(yje,{open:e,label:D.museCliLogin?.signInLabel??`Sign in with Meta`,...S?{intent:S}:{},onClose:e=>{x(!1),e&&n()}});let k=_7(E),A=a.some(e=>(e.credentials??[]).some(e=>e.class!==`none`)),j=D.credentialClass!==`none`,ee=Qs(D,{credentialClass:E.isSubscription?`subscription`:D.credentialClass,...D.userBaseUrl&&d.trim()?{baseUrl:d.trim()}:{}}),M=!h&&(!j||l.trim().length>0),te=async()=>{g(!0),y(null);try{if(!j){await i.setActiveProvider(D.id),n();return}let e=await i.probeCredential(D.id,{secret:l.trim(),variantId:E.variantId,...D.userBaseUrl&&d.trim()?{baseUrl:d.trim()}:{}});if(!e.ok){y(e.error??`${O} rejected this key — check it and try again.`);return}let t={};E.variantId&&(t.variant=E.variantId),D.userBaseUrl&&d.trim()&&(t.baseUrl=d.trim()),await i.addCredential({class:E.isSubscription?`subscription`:`api_key`,providerId:D.id,secret:l.trim(),...p.trim()?{label:p.trim()}:{},...Object.keys(t).length>0?{meta:t}:{},...E.isSubscription&&w&&k.length>0?{addAccount:!0}:{}})&&(u(``),n())}finally{g(!1)}};return(0,B.jsx)(gC,{open:e,title:`${A?`Manage`:`Connect`} ${O}`,onClose:n,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{onClick:n,children:`Cancel`}),E.loginKind===`oauth`?(0,B.jsxs)(U,{onClick:()=>i.openOauthLogin(E.provider.definition.id,k.length>0?{addAccount:!0}:null),"data-testid":`connect-oauth-signin`,children:[(0,B.jsx)(H.LogIn,{className:`w-4 h-4`}),` `,k.length>0?`Add another account`:E.provider.definition.subscriptionLogin?.signInLabel??`Sign in instead`]}):E.loginKind===`muse`?(0,B.jsxs)(U,{onClick:()=>{C(k.length>0?{addAccount:!0}:void 0),x(!0)},"data-testid":`connect-muse-signin`,children:[(0,B.jsx)(H.LogIn,{className:`w-4 h-4`}),` `,k.length>0?`Add another account`:E.provider.definition.museCliLogin?.signInLabel??`Sign in with Meta`]}):E.loginKind===`claude`?(0,B.jsxs)(U,{onClick:()=>i.openClaudeLogin(null),"data-testid":`connect-claude-signin`,children:[(0,B.jsx)(H.LogIn,{className:`w-4 h-4`}),` Sign in instead`]}):null,(0,B.jsx)(U,{variant:`primary`,busy:h,disabled:!M,onClick:()=>void te(),children:h?`Checking…`:j?`Save key`:`Use this provider`})]}),children:(0,B.jsxs)(`div`,{className:`space-y-3`,children:[o.length>1?(0,B.jsx)(`div`,{className:`flex gap-1 border-b border-border`,role:`tablist`,children:o.map(e=>{let t=_7(e)[0];return(0,B.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.key===E.key,"data-testid":`record-tab-${e.key}`,onClick:()=>c(e.key),className:e.key===E.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,B.jsx)(`span`,{className:`ml-1.5 font-mono text-[11px] text-ok`,children:t.masked}):null]},e.key)})}):null,k.length>0?(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:k.length>1?`Linked accounts (${k.length})`:`Connected`}),k.map(e=>(0,B.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}`,title:e.accountLabel?`${e.accountLabel} — ${e.label}`:e.label,children:[(0,B.jsx)(hC,{tone:e.class===`subscription`?`accent`:`ok`,children:E.label}),e.accountLabel?(0,B.jsx)(`span`,{className:`truncate text-xs font-medium`,"data-testid":`stored-account`,children:e.accountLabel}):(0,B.jsx)(`span`,{className:`font-mono text-xs`,children:e.masked}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-fg-faint`,children:e.label}),E.loginKind===`oauth`?(0,B.jsx)(U,{size:`sm`,onClick:()=>i.openOauthLogin(E.provider.definition.id,{replaceCredentialId:e.id}),"data-testid":`renew-credential-${e.id}`,children:`Sign in again`}):E.loginKind===`muse`?(0,B.jsx)(U,{size:`sm`,onClick:()=>{C({replaceCredentialId:e.id}),x(!0)},"data-testid":`renew-credential-${e.id}`,children:`Sign in again`}):null,(0,B.jsx)(U,{size:`sm`,variant:`danger`,onClick:()=>void i.deleteCredential(e.id),children:`Remove`})]},e.id))]}):null,(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,B.jsx)(hC,{tone:ee.viaGateway?`accent`:`ok`,children:ee.badge}),(0,B.jsx)(hC,{children:D.kind}),E.keyFormat?(0,B.jsxs)(`span`,{className:`text-fg-faint`,children:[`key format `,E.keyFormat]}):null]}),(0,B.jsxs)(`div`,{className:ee.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:[ee.detail,j&&!ee.viaGateway?` The key is stored in your zero-knowledge vault.`:null]}),j?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`ol`,{className:`ml-4 list-decimal space-y-1 text-xs text-fg-muted`,children:E.loginKind===`muse`?[`Press “${E.provider.definition.museCliLogin?.signInLabel??`Sign in with Meta`}”: OonaCode fetches Meta’s own Muse once into its own folder, you approve a short code on Meta’s page, and the key is stored by itself.`,`Or paste a Muse subscription key, or a Meta Model API key, below.`,`Chats go from this PC straight to Meta; the key stays in your vault.`].map((e,t)=>(0,B.jsx)(`li`,{children:e},t)):E.loginKind===`oauth`?[`Press “${E.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,B.jsx)(`li`,{children:e},t)):E.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,B.jsx)(`li`,{children:e},t)):bje(E.provider,E.variant).map((e,t)=>(0,B.jsx)(`li`,{children:e},t))}),(0,B.jsx)(fC,{label:E.loginKind===`muse`?`Muse key`:E.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,B.jsx)(`input`,{className:pC,type:`password`,autoComplete:`off`,spellCheck:!1,value:l,placeholder:E.keyFormat??`sk-…`,onChange:e=>{u(e.target.value),y(null)}})}),_?(0,B.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,D.userBaseUrl?(0,B.jsx)(fC,{label:`Base URL`,hint:`Point this at your own server if it is not the default. Each record has its own endpoint.`,children:(0,B.jsx)(`input`,{className:pC,value:d,spellCheck:!1,onChange:e=>f(e.target.value),placeholder:E.variant?.baseUrl??D.baseUrl})}):null,E.isSubscription&&k.length>0&&Cje(E)?(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked),"data-testid":`connect-as-another`}),`Add this token as another account (keep the linked ones)`]}):null,(0,B.jsx)(fC,{label:`Label (optional)`,children:(0,B.jsx)(`input`,{className:pC,value:p,onChange:e=>m(e.target.value),placeholder:`${O} ${E.label.toLowerCase()} key`})})]}):(0,B.jsxs)(`div`,{className:`rounded-md bg-surface-2 px-3 py-2 text-xs text-fg-muted`,children:[D.displayName,` needs no credential.`]})]})})}function Tje({open:e,onClose:t}){let{state:n,actions:r}=V(),i=n.ui.oauthLoginProviderId,a=n.ui.oauthLoginIntent,o=i?n.providers.find(e=>e.definition.id===i)??null:null,s=n.oauthLogin&&n.oauthLogin.providerId===i?n.oauthLogin:null,[c,l]=(0,v.useState)(0),[u,d]=(0,v.useState)(!1),f=(0,v.useRef)(null),p=o?.definition.displayName??i??`the provider`,m=o?.definition.subscriptionLogin?.signInLabel??`Sign in to ${p}`,h=s?.phase===`awaiting_approval`,g=h?s?.verificationUriComplete??s?.verificationUri??null:null;(0,v.useEffect)(()=>{if(!e||!i)return;f.current=null,r.startOauthLogin(i,a);let t=setInterval(()=>void r.refreshOauthLogin(i),2e3);return()=>clearInterval(t)},[e,i,c,r,a]),(0,v.useEffect)(()=>{!e||!g||!s?.id||f.current===s.id||(f.current=s.id,O5(g))},[e,g,s?.id]),(0,v.useEffect)(()=>{e&&s?.phase===`connected`&&r.refreshCredentials()},[e,s?.phase,r]);let _=e=>{if(!navigator.clipboard){r.toast(`error`,`Could not copy — select it and copy by hand`);return}navigator.clipboard.writeText(e).then(()=>{d(!0),setTimeout(()=>d(!1),2e3)}).catch(()=>r.toast(`error`,`Could not copy`))},y=s?.phase===`connected`||s?.phase===`failed`||s?.phase===`expired`||s?.phase===`cancelled`;return(0,B.jsx)(gC,{open:e,title:m,onClose:t,footer:(0,B.jsxs)(B.Fragment,{children:[h?(0,B.jsx)(U,{onClick:()=>i&&void r.cancelOauthLogin(i),"data-testid":`oauth-login-cancel`,children:`Cancel sign-in`}):null,y&&s?.phase!==`connected`?(0,B.jsx)(U,{onClick:()=>l(e=>e+1),"data-testid":`oauth-login-retry`,children:`Try again`}):null,(0,B.jsx)(U,{variant:`primary`,onClick:t,children:s?.phase===`connected`?`Done`:`Close`})]}),children:(0,B.jsx)(`div`,{className:`space-y-3 text-sm`,"data-testid":`oauth-login-dialog`,children:h&&s?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`p`,{children:[`A sign-in page for `,p,` opened in your browser. If it did not, open the link below on any device and enter this code:`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`code`,{className:`text-lg font-mono px-2 py-1 rounded border border-border`,"data-testid":`oauth-user-code`,children:s.userCode}),(0,B.jsxs)(U,{onClick:()=>s.userCode&&_(s.userCode),children:[(0,B.jsx)(H.Copy,{className:`w-4 h-4`}),` `,u?`Copied`:`Copy code`]})]}),g?(0,B.jsxs)(`div`,{className:`flex items-center gap-2 break-all`,children:[(0,B.jsx)(`a`,{className:`underline`,href:g,onClick:e=>{e.preventDefault(),O5(g)},children:g}),(0,B.jsxs)(U,{onClick:()=>_(g),children:[(0,B.jsx)(H.Copy,{className:`w-4 h-4`}),` Copy link`]})]}):null,(0,B.jsxs)(`p`,{className:`text-fg-muted`,children:[`Waiting for your approval… the code expires`,s.expiresAt?` at ${new Date(s.expiresAt).toLocaleTimeString()}`:` soon`,`. The subscription is stored in your vault the moment `,p,` confirms it.`]})]}):s?.phase===`connected`?(0,B.jsxs)(`p`,{"data-testid":`oauth-login-connected`,children:[`Signed in. Your `,p,` subscription is stored in your vault and synced to your other machines; chats on it run from this PC straight to the provider.`]}):y?(0,B.jsx)(`p`,{className:`text-danger`,"data-testid":`oauth-login-ended`,children:s?.message??`The sign-in did not complete.`}):(0,B.jsx)(`p`,{children:`Starting the sign-in…`})})})}function Eje({open:e,onClose:t}){let{state:n,actions:r}=V(),i=(0,v.useMemo)(()=>Jm(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,B.jsx)(gC,{open:e,title:`Manage models`,onClose:t,wide:!0,footer:(0,B.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,B.jsxs)(U,{onClick:()=>{t(),r.openSettings(`providers`)},"data-testid":`manage-models-add-provider`,children:[(0,B.jsx)(H.Plus,{className:`w-3.5 h-3.5`}),` Add provider`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(U,{onClick:t,children:`Cancel`}),(0,B.jsx)(U,{variant:`primary`,busy:l,onClick:()=>void h(),"data-testid":`manage-models-save`,children:`Save`})]})]}),children:(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.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,B.jsx)(`input`,{className:pC,value:s,onChange:e=>c(e.target.value),placeholder:`Filter models…`,"data-testid":`manage-models-filter`}),i.length===0?(0,B.jsxs)(`div`,{className:`text-sm text-fg-faint`,children:[`No provider is connected yet — use `,(0,B.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,B.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`manage-models-${e.definition.id}`,children:[(0,B.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:e.definition.displayName}),(0,B.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[r===t.length?`all`:r,` of `,t.length,` shown`]}),(0,B.jsxs)(`span`,{className:`ml-auto flex gap-1`,children:[(0,B.jsx)(U,{size:`sm`,onClick:()=>m(e.definition.id,!0,t),children:`All`}),(0,B.jsx)(U,{size:`sm`,onClick:()=>m(e.definition.id,!1,t),children:`None`})]})]}),(0,B.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-2`,children:[n.map(n=>(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,B.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,B.jsxs)(`span`,{className:`truncate`,title:n.id,children:[n.displayName??n.id,n.displayName&&n.displayName!==n.id?(0,B.jsxs)(`span`,{className:`text-fg-faint`,children:[` · `,n.id]}):null]})]},n.id)),n.length===0?(0,B.jsxs)(`div`,{className:`text-xs text-fg-faint`,children:[(0,B.jsx)(H.Info,{className:`mr-1 inline w-3 h-3`}),` No model matches the filter.`]}):null]})]},e.definition.id)})]})})}var v7={mode:`names`,mine:!0,model:!0,tools:!1,subagents:!1,projectId:null,when:`any`,caseSensitive:!1,wholeWord:!1};function y7(e,t,n){let r=Ke(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 b7(e){return Object.keys(v7).some(t=>e[t]!==v7[t])}function x7(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 Dje(e,t,n,r=Date.now()){if(n.projectId!==null&&e.projectId!==n.projectId)return!1;let i=x7(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`&&qe(e,t,i)))return!1}return!0}function Oje(e,t,n=Date.now()){let r=e.trim();if(r.length<2||!t.mine&&!t.model&&!t.tools)return null;let i=x7(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 S7({label:e,hint:t,checked:n,onChange:r,testId:i}){return(0,B.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 py-0.5 text-xs`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:n,onChange:e=>r(e.target.checked),"data-testid":i}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`text-fg`,children:e}),t?(0,B.jsx)(`span`,{className:`block text-[11px] text-fg-faint`,children:t}):null]})]})}var C7=`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-fg focus:outline-none`,kje={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 w7({options:e,onChange:t,projects:n,onClose:r,words:i=kje}){let a=(n,r)=>t({...e,[n]:r}),o=e.mode===`conversations`,s=o&&!e.mine&&!e.model&&!e.tools;return(0,B.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,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:`Search in`}),(0,B.jsx)(vC,{label:`Search in`,value:e.mode,options:[{value:`names`,label:i.names},{value:`conversations`,label:i.conversations}],onChange:e=>a(`mode`,e)}),(0,B.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`search-mode-hint`,children:o?i.conversationsHint:i.namesHint})]}),o?(0,B.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,B.jsx)(S7,{label:`My messages`,checked:e.mine,onChange:e=>a(`mine`,e),testId:`search-opt-mine`}),(0,B.jsx)(S7,{label:`Model replies`,checked:e.model,onChange:e=>a(`model`,e),testId:`search-opt-model`}),(0,B.jsx)(S7,{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,B.jsx)(S7,{label:`Subagents’ conversations`,checked:e.subagents,onChange:e=>a(`subagents`,e),testId:`search-opt-subagents`}),s?(0,B.jsx)(`p`,{className:`text-[11px] text-warn`,children:`Tick at least one to search.`}):null]}):null,(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[n?(0,B.jsxs)(`label`,{className:`space-y-1 text-[11px] text-fg-faint`,children:[(0,B.jsx)(`span`,{children:`Project`}),(0,B.jsxs)(`select`,{className:C7,value:e.projectId??``,onChange:e=>a(`projectId`,e.target.value||null),"data-testid":`search-opt-project`,children:[(0,B.jsx)(`option`,{value:``,children:`All projects`}),n.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}):null,(0,B.jsxs)(`label`,{className:`space-y-1 text-[11px] text-fg-faint`,children:[(0,B.jsx)(`span`,{children:`When`}),(0,B.jsxs)(`select`,{className:C7,value:e.when,onChange:e=>a(`when`,e.target.value),"data-testid":`search-opt-when`,children:[(0,B.jsx)(`option`,{value:`any`,children:`Any time`}),(0,B.jsx)(`option`,{value:`today`,children:`Today`}),(0,B.jsx)(`option`,{value:`week`,children:`Last 7 days`}),(0,B.jsx)(`option`,{value:`month`,children:`Last 30 days`})]})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-x-4`,children:[(0,B.jsx)(S7,{label:`Match case`,checked:e.caseSensitive,onChange:e=>a(`caseSensitive`,e),testId:`search-opt-case`}),(0,B.jsx)(S7,{label:`Whole words`,checked:e.wholeWord,onChange:e=>a(`wholeWord`,e),testId:`search-opt-word`})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border pt-2`,children:[(0,B.jsx)(`button`,{type:`button`,className:z(`text-xs`,b7(e)?`text-accent hover:underline`:`text-fg-faint`),disabled:!b7(e),onClick:()=>t(v7),"data-testid":`search-opt-reset`,children:`Reset`}),(0,B.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 Aje(e){return e.kind===`tool`?e.tool??`Tool`:e.role===`assistant`?`Model`:`You`}function jje({query:e,options:t}){let{state:n,actions:r}=V(),i=(0,v.useMemo)(()=>Oje(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,B.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,B.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,B.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,B.jsxs)(`div`,{className:`pb-2`,"data-testid":`transcript-search-results`,children:[(0,B.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,B.jsxs)(`div`,{className:`mb-1.5`,"data-testid":`transcript-search-chat-${n}`,children:[(0,B.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,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i.title}),(0,B.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,B.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,B.jsxs)(`span`,{className:`mb-0.5 flex items-center gap-1.5 text-[10px] text-fg-faint`,children:[i.kind===`tool`?(0,B.jsx)(H.Tool,{className:`h-3 w-3`}):i.role===`assistant`?(0,B.jsx)(H.Bot,{className:`h-3 w-3`}):(0,B.jsx)(H.User,{className:`h-3 w-3`}),(0,B.jsx)(`span`,{className:`font-medium text-fg-muted`,children:Aje(i)}),i.subpath?(0,B.jsx)(`span`,{children:`· subagent`}):null,i.timestamp?(0,B.jsx)(`span`,{className:`ml-auto`,children:Lv(i.timestamp)}):null]}),(0,B.jsx)(`span`,{className:`line-clamp-3 text-fg-muted`,children:y7(i.snippet,e,t).map((e,t)=>e.hit?(0,B.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,B.jsx)(`span`,{children:e.text},t))})]},`${i.seq}`))]},n))]})}function T7(e){return`${e.agentId??`claude-code`}:${e.id}`}function E7(e){let t=Date.parse(e.lastEntryAt??e.updatedAt);return Number.isFinite(t)?t:0}function Mje(e,t,n=Date.now()){let r=x7(t.when,n)?.getTime()??null,i=Ke(e,{caseSensitive:t.caseSensitive,wholeWord:t.wholeWord});return e=>r!==null&&E7(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 Nje(e,t,n=Date.now()){let r=e.trim();if(r.length<2||!t.mine&&!t.model&&!t.tools)return null;let i=x7(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 Pje(e,t){let n=new Map;for(let t of e){let e=T7(t);n.set(e,e);for(let r of t.supersedes??[]){let i=T7({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(T7(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 Fje={new:`New`,imported:`Imported`,behind:`Imported · original moved on`,deleted:`You deleted it in OonaCode`,unavailable:`Cannot be imported yet`};function D7(e){return e.alreadyImported?e.upToDate===!1?`behind`:`imported`:e.deletedHere===!0?`deleted`:O7(e)?`unavailable`:`new`}function O7(e){return typeof e.unavailable==`string`&&e.unavailable.length>0}function k7(e){if(O7(e))return!1;let t=D7(e);return t===`new`||t===`behind`}function Ije(e){return D7(e)===`new`}function Lje(e,t){return new Set(t?e.filter(Ije).map(e=>e.id):[])}function Rje(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 zje(){return{new:0,imported:0,behind:0,deleted:0,unavailable:0}}function Bje(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:zje()},t.set(e,r)),r.rows.push(n),r.counts[D7(n)]+=1}for(let e of t.values())e.rows=Rje([...e.rows].sort((e,t)=>E7(t)-E7(e)));return[...t.values()]}function A7(e,t){let n=0,r=0,i=0;for(let a of e){let e=t.has(a.id);e&&(n+=1),k7(a)&&(r+=1,e&&(i+=1))}return n===0?`none`:r>0&&i===r?`all`:`some`}function Vje(e,t){let n=new Set(t),r=e.filter(k7);if(A7(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 Hje(e,t){let n=0;if(t)for(let r of e)t.has(r)||(n+=1);return{total:e.size,notShown:n}}var Uje={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.`},j7=`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 Wje(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 M7(e){return e?e.replace(/[\\/]+$/,``).split(/[\\/]/).length<=2?e:`…${e.slice(-40)}`:`no folder recorded`}function Gje(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function Kje(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}var N7=(e,t,n)=>`${e} ${e===1?t:n}`;function qje({open:e,onClose:t,autoOffer:n=!1}){let{state:r,actions:i}=V(),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)(()=>Bje(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)(v7),[O,k]=(0,v.useState)(!1),A=(0,v.useRef)(null),j=w.trim()!==``,ee=E.mode===`conversations`,[M,te]=(0,v.useState)(new Set);(0,v.useEffect)(()=>te(new Set),[w,E]);let ne=(0,v.useMemo)(()=>ee?Nje(w,E):null,[ee,w,E]),N=ne?JSON.stringify(ne):``,[P,re]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!e||!ne)return;let t=new AbortController,n=!0,r=setTimeout(()=>{i.searchImportChats(ne,t.signal).then(e=>{n&&re({key:N,res:e})})},350);return()=>{n=!1,clearTimeout(r),t.abort()}},[e,N,i]);let ie=P&&P.key===N?P:null,ae=(0,v.useMemo)(()=>ie?.res?Pje(x,ie.res.chats):null,[ie,x]),oe=(0,v.useMemo)(()=>j?ee?ae?x.filter(e=>ae.has(T7(e))):[]:x.filter(Mje(w,E)):null,[j,ee,x,w,E,ae]),se=(0,v.useMemo)(()=>oe?new Set(oe):null,[oe]),F=(0,v.useMemo)(()=>oe?new Set(oe.map(e=>e.id)):null,[oe]),ce=oe??x,le=(0,v.useMemo)(()=>j?{query:w,options:E,litNames:!ee}:null,[j,w,E,ee]),ue=(0,v.useMemo)(()=>x.filter(e=>e.alreadyImported&&m.has(e.id)),[x,m]),de=(0,v.useMemo)(()=>Hje(m,F),[m,F]),fe=S.length===1?S[0].name:`coding-agent`;(0,v.useEffect)(()=>{if(!e)return;d(null),b(null),_(new Set),h(new Set),T(``),re(null),k(!1),s(!0);let t=n;i.scanClaudeSessions().then(e=>{p(e.sessions),h(Lje(e.sessions,t))}).catch(e=>d(e instanceof Error?e.message:String(e))).finally(()=>s(!1))},[e]);let pe=(0,v.useCallback)(e=>h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),me=r.prefs.claudeImportOffered,he=(0,v.useCallback)(()=>{me||i.savePrefs({claudeImportOffered:!0}),t()},[me,i,t]),ge=async()=>{l(!0),d(null);try{let e=await i.importClaudeSessions([...m],ue.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)}},_e=C.imported+C.behind;return(0,B.jsx)(gC,{open:e,title:`Import your ${fe} chats`,onClose:he,wide:!0,footer:(0,B.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,B.jsxs)(`span`,{className:`min-w-0 text-[11px] text-fg-faint`,children:[!y&&de.notShown>0?(0,B.jsxs)(`span`,{className:`block text-fg-muted`,"data-testid":`import-claude-ticked-hidden`,children:[de.total,` ticked · `,de.notShown,` not shown by the search`]}):null,ue.length>0?(0,B.jsxs)(`span`,{className:`block text-warn`,children:[ue.length,` already-imported `,ue.length===1?`chat`:`chats`,` `,`will be REPLACED — the OonaCode copy is rebuilt from the original, and anything added here is lost.`]}):(0,B.jsx)(`span`,{className:`block`,children:`Your other apps stay exactly as they are — this copies, it never moves or deletes.`})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,B.jsx)(U,{onClick:he,"data-testid":`import-claude-close`,children:y?`Done`:`Not now`}),y?null:(0,B.jsxs)(U,{variant:`primary`,busy:c,disabled:de.total===0,onClick:()=>void ge(),"data-testid":`import-claude-run`,children:[`Import `,N7(de.total,`chat`,`chats`)]})]})]}),children:(0,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`import-claude-body`,children:[o?(0,B.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`Looking for chats on this PC…`}):null,a&&!y?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`import-claude-progress`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,B.jsxs)(`span`,{children:[`Importing `,(0,B.jsx)(`strong`,{children:a.done}),` of `,(0,B.jsx)(`strong`,{children:a.total}),`…`]}),(0,B.jsxs)(`span`,{className:`text-[11px] text-fg-faint`,children:[Math.round(a.done/Math.max(a.total,1)*100),`%`]})]}),(0,B.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded bg-surface-2`,children:(0,B.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,B.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,title:a.current,children:[`reading: `,a.current]}):null,(0,B.jsxs)(`div`,{className:`flex gap-3 text-[11px] text-fg-faint`,children:[(0,B.jsxs)(`span`,{children:[a.imported,` imported`]}),a.skipped>0?(0,B.jsxs)(`span`,{children:[a.skipped,` already in`]}):null,a.failed>0?(0,B.jsxs)(`span`,{className:`text-warn`,children:[a.failed,` could not be read`]}):null]}),(0,B.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,B.jsx)(`div`,{className:`rounded border border-danger/40 bg-danger/10 p-2 text-sm text-danger`,children:u}):null,y?(0,B.jsxs)(`div`,{className:`text-sm`,"data-testid":`import-claude-done`,children:[(0,B.jsxs)(`p`,{children:[`Imported `,(0,B.jsx)(`strong`,{children:y.imported}),` `,y.imported===1?`chat`:`chats`,y.replaced>0?(0,B.jsxs)(B.Fragment,{children:[` and rebuilt `,(0,B.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,B.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,B.jsxs)(`span`,{children:[t>0?`, `:``,(0,B.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,B.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,B.jsxs)(`p`,{className:`mt-1 text-warn`,children:[y.failed,` could not be read and were left alone.`]}):null,y.warnings.map(e=>(0,B.jsx)(`p`,{className:`mt-1 text-warn`,children:e},e))]}):null,!o&&!y&&!a&&f!==null&&f.length>0?(0,B.jsxs)(`div`,{className:`space-y-0.5 text-sm`,"data-testid":`import-claude-tally`,children:[(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`strong`,{children:f.length}),` `,f.length===1?`chat`:`chats`,` on this PC`,S.length>0?` — `:``,S.map((e,t)=>(0,B.jsxs)(`span`,{children:[t>0?`, `:``,(0,B.jsx)(`strong`,{children:e.rows.length}),` `,e.name]},e.key))]}),(0,B.jsxs)(`p`,{className:`text-fg-muted`,children:[(0,B.jsx)(`strong`,{className:`text-fg`,children:C.new}),` new`,_e>0?` · ${_e} 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,B.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,B.jsxs)(B.Fragment,{children:[(0,B.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,B.jsxs)(`div`,{className:`relative`,"data-testid":`import-search`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsxs)(`div`,{className:`relative flex-1`,children:[(0,B.jsx)(H.Search,{className:`pointer-events-none absolute left-2 top-2 w-3.5 h-3.5 text-fg-faint`}),(0,B.jsx)(`input`,{ref:A,"aria-label":`Search the chats to import`,className:z(pC,`pl-7`),placeholder:ee?`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,B.jsxs)(lC,{label:O?`Hide search options`:`Search options`,className:z(`relative`,O&&`text-accent`),"aria-pressed":O,onMouseDown:e=>e.preventDefault(),onClick:()=>k(e=>!e),"data-testid":`import-search-options-toggle`,children:[(0,B.jsx)(H.Sliders,{}),b7(E)?(0,B.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,B.jsx)(lC,{label:`Clear search`,onMouseDown:e=>e.preventDefault(),onClick:()=>{T(``),A.current?.focus()},"data-testid":`import-search-clear`,children:(0,B.jsx)(H.X,{})}):null]}),O?(0,B.jsx)(w7,{options:E,onChange:D,words:Uje,onClose:()=>{k(!1),A.current?.focus()}}):null]}),j?(0,B.jsx)(tMe,{query:w,conversations:ee,request:ne!==null,answer:ie,matches:oe?.length??0,messages:[...ae?.values()??[]].reduce((e,t)=>e+t.hits,0),capped:[...ae?.values()??[]].some(e=>e.hitsCapped)}):null,(0,B.jsx)(`div`,{className:`max-h-96 space-y-3 overflow-y-auto`,"data-testid":`import-claude-list`,children:S.map(e=>{let t=se?e.rows.filter(e=>se.has(e)):e.rows;if(t.length===0)return null;let n=se?!M.has(e.key):!g.has(e.key),r=se?te:_;return(0,B.jsxs)(`div`,{className:`rounded border border-border`,"data-testid":`import-group-${e.key}`,children:[(0,B.jsx)(Xje,{section:e,rows:t,searching:se!==null,open:n,chosen:m,onFold:()=>r(t=>Jje(t,e.key)),onTicks:h}),n?t.map(e=>(0,B.jsx)(Qje,{row:e,checked:m.has(e.id),onToggle:pe,phrase:le,hit:ae?.get(T7(e))},T7(e))):null]},e.key)})}),(0,B.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-fg-faint`,children:[(0,B.jsx)(`button`,{type:`button`,className:`underline`,title:j7,onClick:()=>h(e=>{let t=new Set(e);for(let e of ce)k7(e)&&t.add(e.id);return t}),"data-testid":`import-claude-select-all`,children:oe===null?`Select all`:`Select all matches`}),(0,B.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>h(e=>{if(oe===null)return new Set;let t=new Set(e);for(let e of ce)t.delete(e.id);return t}),"data-testid":`import-claude-select-none`,children:oe===null?`Select none`:`Unselect matches`})]})]}):null]})})}function Jje(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Yje({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,B.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 Xje({section:e,rows:t,searching:n,open:r,chosen:i,onFold:a,onTicks:o}){let s=A7(t,i),c=t.filter(k7).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}`:j7;return(0,B.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,B.jsx)(Yje,{state:s,disabled:c===0&&s===`none`,onToggle:()=>o(e=>Vje(t,e)),label:s===`all`?`Untick every chat in ${f}`:`Tick the chats in ${f}`,title:p,testId:`import-group-check-${e.key}`}),(0,B.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,B.jsx)(H.Chevron,{open:r,className:`w-3 h-3 shrink-0`}),e.name,(0,B.jsxs)(`span`,{className:`truncate font-normal text-fg-faint`,children:[N7(e.rows.length,`chat`,`chats`),n?` · ${N7(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 Zje({row:e,status:t}){let n=Fje[t],r={"data-testid":`import-status-${e.id}`,"data-status":t};switch(t){case`new`:return(0,B.jsx)(`span`,{className:`font-medium text-accent`,...r,children:n});case`imported`:case`behind`:return(0,B.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,B.jsx)(H.Check,{className:`w-3 h-3 text-ok`}),n,t===`behind`?(0,B.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,B.jsx)(H.ArrowDown,{className:`w-2.5 h-2.5`}),`behind`]}):null]});case`deleted`:return(0,B.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,B.jsx)(`span`,{className:`text-warn`,...r,children:n})}}var Qje=(0,v.memo)(function({row:e,checked:t,onToggle:n,phrase:r,hit:i}){let a=O7(e),o=e=>r?.litNames?y7(e,r.query,r.options).map((e,t)=>e.hit?(0,B.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,B.jsx)(`span`,{children:e.text},t)):e;return(0,B.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,B.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:t,disabled:a,onChange:()=>n(e.id),"aria-label":e.title??e.firstPrompt??e.id}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block truncate text-sm`,children:e.title||e.firstPrompt?o(e.title||e.firstPrompt||``):(0,B.jsx)(`span`,{className:`text-fg-faint`,children:`(no prompt)`})}),(0,B.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-fg-faint`,children:[e.projectName?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,B.jsx)(H.Project,{className:`w-3 h-3`}),o(e.projectName)]}):(0,B.jsxs)(B.Fragment,{children:[e.cwd?(0,B.jsx)(`span`,{title:e.cwd,children:o(M7(e.cwd))}):M7(e.cwd),e.cwd&&!e.cwdExists?` · folder is gone`:``]}),` `,`· `,e.entryCount,` entries`,e.bytes>0?` · ${Gje(e.bytes)}`:``,e.model?` · ${e.model}`:``]}),e.unavailable||e.note?(0,B.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,B.jsx)(eMe,{hit:i,query:r.query,options:r.options,testId:`import-row-hits-${e.id}`}):null]}),e.supersedes&&e.supersedes.length>0?(0,B.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,B.jsxs)(`span`,{className:`mt-0.5 flex shrink-0 flex-col items-end gap-0.5 text-right text-[11px]`,children:[(0,B.jsx)(`span`,{className:`whitespace-nowrap text-fg-faint`,children:Kje(e.lastEntryAt??e.updatedAt)}),(0,B.jsx)(`span`,{className:`whitespace-nowrap`,children:(0,B.jsx)(Zje,{row:e,status:D7(e)})})]})]})});function $je(e){let t=e.kind===`tool`?e.tool??`Tool`:e.role===`assistant`?`Model`:`You`;return e.subagent?`${t} (subagent)`:t}function eMe({hit:e,query:t,options:n,testId:r}){return(0,B.jsxs)(`span`,{className:`mt-1 block space-y-0.5`,"data-testid":r,children:[(0,B.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,B.jsxs)(`span`,{className:`block line-clamp-2 text-[11px] text-fg-muted`,"data-testid":`import-row-snippet`,children:[(0,B.jsxs)(`span`,{className:`font-medium text-fg-faint`,children:[$je(e),`:`]}),` `,y7(e.snippet,t,n).map((e,t)=>e.hit?(0,B.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,B.jsx)(`span`,{children:e.text},t))]},r))]})}function tMe({query:e,conversations:t,request:n,answer:r,matches:i,messages:a,capped:o}){let s=(e,t,n=`text-fg-muted`)=>(0,B.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=Wje(c),u=c.sources.filter(e=>e.note).map(e=>`${e.agentName}: ${e.note}`);return(0,B.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,B.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`import-search-source-note`,children:e},e))]})}function nMe({id:e,title:t,icon:n,count:r,collapsed:i,onToggle:a,onRemove:o,removeLabel:s,grow:c,drag:l,children:u}){return(0,B.jsxs)(`section`,{"aria-label":t,"data-testid":`section-${e}`,style:{flexGrow:c,flexShrink:1,flexBasis:i?`auto`:0},className:z(`relative flex min-h-0 flex-col border-b border-border last:border-b-0`,l?.hint===`before`&&`shadow-[inset_0_2px_0_0_var(--color-accent)]`,l?.hint===`after`&&`shadow-[inset_0_-2px_0_0_var(--color-accent)]`),onDragOver:l?.onDragOver,onDrop:l?.onDrop,children:[(0,B.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 px-3`,draggable:l?!0:void 0,onDragStart:l?.onDragStart,onDragEnd:l?.onDragEnd,children:[(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":!i,"aria-controls":`section-body-${e}`,"data-testid":`section-header-${e}`,onClick:a,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,title:i?`Open ${t}`:`Fold ${t}`,children:[(0,B.jsx)(H.Chevron,{open:!i,className:`w-3 h-3 text-fg-faint`}),n?(0,B.jsx)(n,{className:`w-3.5 h-3.5 text-fg-faint`}):null,(0,B.jsxs)(`span`,{className:`truncate text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:[t,typeof r==`number`?` · ${r}`:``]})]}),o?(0,B.jsx)(lC,{label:s??`Hide ${t}`,className:`p-1`,onClick:o,children:(0,B.jsx)(H.X,{className:`w-3.5 h-3.5`})}):null]}),(0,B.jsx)(`div`,{id:`section-body-${e}`,"data-testid":`section-body-${e}`,hidden:i,className:z(`min-h-0 flex-1 flex-col`,i?`hidden`:`flex`),children:u})]})}function P7({items:e,onPick:t,testId:n,label:r,multi:i=!1,className:a,footer:o}){let s=(0,v.useRef)(null);return(0,B.jsxs)(`div`,{ref:s,role:`tablist`,"aria-orientation":`vertical`,"aria-label":r,"data-testid":n,onKeyDown:e=>{if(![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;let t=Array.from(s.current?.querySelectorAll(`button[role="tab"]`)??[]);if(t.length===0)return;let n=t.indexOf(document.activeElement),r=e.key===`Home`?0:e.key===`End`?t.length-1:n<0?0:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length;e.preventDefault(),t[r]?.focus()},className:z(`flex w-12 shrink-0 flex-col items-center gap-1 border-border bg-surface py-2`,a),children:[e.map(n=>(0,B.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n.active,"aria-label":n.label,title:n.label,"data-testid":`activity-${n.id}`,tabIndex:n.active||!i&&e.every(e=>!e.active)?0:-1,onClick:()=>t(n.id),className:z(`relative flex h-10 w-10 items-center justify-center rounded-md`,n.active?`bg-surface-2 text-fg shadow-[inset_2px_0_0_0_var(--color-accent)]`:`text-fg-muted hover:bg-surface-2 hover:text-fg`),children:[(0,B.jsx)(n.icon,{className:`w-5 h-5`}),typeof n.count==`number`&&n.count>0?(0,B.jsx)(`span`,{className:`absolute bottom-1 right-1 min-w-3.5 rounded-full bg-accent px-1 text-[9px] leading-[14px] text-white`,children:n.count>99?`99+`:n.count}):null]},n.id)),o?(0,B.jsx)(`div`,{className:`mt-auto flex flex-col items-center gap-1`,children:o}):null]})}var F7=[{kind:`photo`,label:`Photos`,empty:`No pictures in this chat yet.`},{kind:`video`,label:`Videos`,empty:`No videos in this chat yet.`},{kind:`audio`,label:`Audio`,empty:`No sound files in this chat yet.`},{kind:`file`,label:`Files`,empty:`No files in this chat yet.`},{kind:`link`,label:`Links`,empty:`No links in this chat yet.`}];function rMe(e){let t=[];for(let n of e){let e=n.at?new Date(n.at):null,r=e!==null&&!Number.isNaN(e.getTime()),i=r?`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}`:`unknown`,a=t[t.length-1];(!a||a.key!==i)&&(a={key:i,label:r?e.toLocaleDateString(void 0,{month:`long`,year:`numeric`}):`Undated`,items:[]},t.push(a)),a.items.push(n)}return t}function I7(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(void 0,{day:`numeric`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}function iMe(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`})}function L7(e){let t=[];e.size!==null&&e.size>=0&&t.push(HF(e.size));let n=I7(e.at);return n&&t.push(n),t.join(` · `)}function R7(e){return e.source===`removed`?!1:e.source!==`path`||e.exists!==!1}function z7(e){return e.source===`removed`?e.removedAfterDays?`Removed after ${e.removedAfterDays} day${e.removedAfterDays===1?``:`s`}`:`Removed to save space`:e.source===`path`&&e.exists===!1?`Moved or deleted`:null}function aMe(e,t){let n=new Set(e.map(e=>e.id));return[...e,...t.filter(e=>!n.has(e.id))]}function oMe(e){try{let t=new URL(e),n=`${t.pathname===`/`?``:t.pathname}${t.search}${t.hash}`;return{host:t.host,rest:n}}catch{return{host:e,rest:``}}}function sMe(e,t){if(!t||!e)return null;let n=`u:${t}`;for(let r of e)if(r.id===n||r.uuid===t)return r.id;return null}function cMe(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return btoa(n)}var lMe=[{value:`all`,label:`All`,title:`Everything in this chat`},{value:`user`,label:`Mine`,title:`What you sent`},{value:`assistant`,label:`Replies`,title:`What the model’s replies contain`}];function B7(e){let t=e.getBoundingClientRect();return{x:t.left+24,y:t.bottom}}function V7(e,t){return{onContextMenu:n=>{n.preventDefault();let r=n.currentTarget;t(e,n.clientX===0&&n.clientY===0?B7(r):{x:n.clientX,y:n.clientY},r)},onKeyDown:n=>{(n.key===`ContextMenu`||n.shiftKey&&n.key===`F10`)&&(n.preventDefault(),t(e,B7(n.currentTarget),n.currentTarget))}}}var uMe=60,dMe=800,H7={items:[],nextBefore:null,missingHidden:0,loaded:!1,loading:!1,error:null};function U7(){return{photo:H7,video:H7,audio:H7,file:H7,link:H7}}function fMe({sessionId:e,onTotal:t}){let{state:n,actions:r,api:i}=V(),a=n.remote.tabs[e]!==void 0,o=n.drafts[e]!==void 0,s=n.transcripts[e]??null,c=(0,v.useCallback)(()=>r.setMediaPanel(!1),[r]),[l,u]=(0,v.useState)(`photo`),[d,f]=(0,v.useState)(`all`),p=(0,v.useRef)(d);p.current=d;let[m,h]=(0,v.useState)(!1),g=(0,v.useRef)(m);g.current=m;let[_,y]=(0,v.useState)(U7),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(null),E=(0,v.useRef)(_);E.current=_;let D=(0,v.useRef)(!0);(0,v.useEffect)(()=>(D.current=!0,()=>{D.current=!1}),[]);let O=!a&&!o&&typeof i.listChatMedia==`function`,k=(0,v.useCallback)(async()=>{if(i.grantChatMedia)try{let t=await i.grantChatMedia(e);D.current&&T(()=>t.urlOf)}catch{}},[i,e]);(0,v.useEffect)(()=>{O&&k()},[O,k]);let A=(0,v.useCallback)(async(t,n)=>{if(!i.listChatMedia)return;let r=E.current[t];if(r.loading||n===`more`&&!r.nextBefore)return;y(e=>({...e,[t]:{...e[t],loading:!0,error:null}}));let a=p.current,o=g.current,s;try{s=await i.listChatMedia(e,{kind:t,...a===`all`?{}:{from:a},missing:o?`show`:`hide`,limit:uMe,...n===`more`&&r.nextBefore?{before:r.nextBefore}:{}})}catch(e){if(!D.current||p.current!==a||g.current!==o)return;Zg(e)&&e.code!==`session_not_found`&&C(!0),y(n=>({...n,[t]:{...n[t],loading:!1,loaded:!0,error:e instanceof Error?e.message:`The media list could not be read.`}}));return}!D.current||p.current!==a||g.current!==o||(x(s.counts),y(e=>({...e,[t]:{items:n===`more`?aMe(e[t].items,s.items):s.items,nextBefore:s.nextBefore,missingHidden:s.missingHidden??0,loaded:!0,loading:!1,error:null}})))},[i,e]);(0,v.useEffect)(()=>{O&&(E.current[l].loaded||A(l,`first`))},[O,l,A,d,m]);let j=(0,v.useMemo)(()=>s?s.items.filter(e=>e.kind===`user`||d!==`user`&&e.kind===`assistant`&&!e.streaming).length:0,[s,d]),ee=(0,v.useRef)(j);(0,v.useEffect)(()=>{if(!O||j===ee.current)return;let e=setTimeout(()=>{ee.current=j,y(e=>{let t=U7();return t[l]={...e[l],loaded:!0},t}),A(l,`first`)},dMe);return()=>clearTimeout(e)},[O,j,l,A]);let M=n.connection.status===`open`,te=(0,v.useRef)(!1),ne=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!M){te.current&&(ne.current=!0);return}te.current=!0,ne.current&&(ne.current=!1,O&&(C(!1),x(null),E.current=U7(),y(U7()),k(),A(l,`first`)))},[M,O,k,A,l]);let N=(0,v.useCallback)(()=>{C(!1),x(null),E.current=U7(),y(U7()),k(),A(l,`first`)},[k,A,l]),P=r.toast,re=(0,v.useCallback)(e=>{p.current!==e&&(p.current=e,E.current=U7(),y(U7()),x(null),f(e))},[]),ie=(0,v.useCallback)(e=>{g.current!==e&&(g.current=e,E.current=U7(),y(U7()),x(null),h(e))},[]),[ae,oe]=(0,v.useState)(null),se=(0,v.useCallback)((e,t,n)=>oe({item:e,at:t,el:n}),[]),F=(0,v.useCallback)(()=>oe(null),[]),ce=(0,v.useCallback)(t=>{let n=sMe(s?.items,t.entryUuid);if(!n){P(`info`,`That message is not loaded in this window yet — scroll up in the chat.`);return}r.jumpToItem(e,n),typeof window<`u`&&typeof window.matchMedia==`function`&&!window.matchMedia(`(min-width: 1024px)`).matches&&c()},[r,c,P,e,s?.items]),le=(0,v.useCallback)(async t=>{if(!i.readChatMedia)return null;try{return cMe(await i.readChatMedia(e,t.id))}catch(e){return P(`error`,`${t.name} could not be read: ${e instanceof Error?e.message:`unknown error`}`),null}},[i,P,e]),ue=(0,v.useCallback)(async e=>{if(e.source===`path`&&e.path){await JL(e.path,P);return}let t=await le(e);t!==null&&await XL({name:e.name,mediaType:e.mediaType.split(`;`)[0]??e.mediaType,base64:t},P)},[P,le]),de=typeof window<`u`?window.oonacode:void 0,fe=de?.showItemInFolder?e=>{e.path&&de.showItemInFolder?.(e.path).then(e=>{!e.ok&&e.message&&P(`error`,e.message)},()=>P(`error`,`The folder could not be opened.`))}:null,[pe,me]=(0,v.useState)(null),he=(0,v.useMemo)(()=>_.photo.items.filter(R7),[_.photo.items]),ge=(0,v.useCallback)(async(e,t=he)=>{let n=t[e];if(!n)return;let r=await le(n);r===null||!D.current||me({index:e,picture:{id:n.id,name:n.name,mediaType:n.mediaType,base64:r}})},[le,he]),_e=(0,v.useCallback)(()=>me(null),[]),ve=pe?{index:pe.index,total:he.length,onPrev:pe.index>0?()=>void ge(pe.index-1):null,onNext:pe.index<he.length-1?()=>void ge(pe.index+1):null}:void 0,[ye,be]=(0,v.useState)(null),xe=(0,v.useCallback)((e,t)=>{navigator.clipboard.writeText(e).then(()=>P(`success`,`${t} copied.`),()=>P(`error`,`${t} could not be copied.`))},[P]),Se=(0,v.useMemo)(()=>{let e=ae?.item;if(!e)return[];let t=[],n=z7(e)!==null;if(e.kind===`link`&&e.url){let n=e.url;t.push({key:`open`,label:`Open in browser`,icon:(0,B.jsx)(H.ExternalLink,{className:`w-3.5 h-3.5`}),onSelect:()=>O5(n)})}else if(e.kind===`photo`){let r=he.findIndex(t=>t.id===e.id);t.push({key:`open`,label:`View`,icon:(0,B.jsx)(H.Image,{className:`w-3.5 h-3.5`}),disabled:n||r<0,onSelect:()=>void ge(r)})}else e.kind===`video`?t.push({key:`open`,label:`Play`,icon:(0,B.jsx)(H.Play,{className:`w-3.5 h-3.5`}),disabled:n,onSelect:()=>be(e)}):t.push({key:`open`,label:e.kind===`audio`?`Open externally`:`Open`,icon:(0,B.jsx)(H.ExternalLink,{className:`w-3.5 h-3.5`}),disabled:n,onSelect:()=>void ue(e)});if(t.push({key:`show-in-chat`,label:`Show in chat`,icon:(0,B.jsx)(H.Chats,{className:`w-3.5 h-3.5`}),hint:e.from===`assistant`?`reply`:`your message`,onSelect:()=>ce(e),testId:`media-menu-show-in-chat`}),fe&&e.source===`path`&&e.exists!==!1&&t.push({key:`folder`,label:`Show in folder`,icon:(0,B.jsx)(H.Folder,{className:`w-3.5 h-3.5`}),onSelect:()=>fe(e)}),e.kind===`link`&&e.url){let n=e.url;t.push({key:`copy`,label:`Copy link`,icon:(0,B.jsx)(H.Copy,{className:`w-3.5 h-3.5`}),separated:!0,onSelect:()=>xe(n,`The link`)})}else if(e.path){let n=e.path;t.push({key:`copy`,label:`Copy path`,icon:(0,B.jsx)(H.Copy,{className:`w-3.5 h-3.5`}),separated:!0,onSelect:()=>xe(n,`The path`)})}return t},[ae,he,ge,ue,ce,fe,xe]),Ce=b?Object.values(b).reduce((e,t)=>e+t,0):null;(0,v.useEffect)(()=>{t?.(Ce)},[t,Ce]);let we=_[l],Te=b??Fh();return(0,B.jsxs)(B.Fragment,{children:[a?(0,B.jsx)(W7,{children:`This chat runs on another PC. Its pictures and files are on that PC — open the media explorer there.`}):o?(0,B.jsx)(W7,{children:`Nothing has been sent in this chat yet.`}):!O||S?(0,B.jsxs)(W7,{children:[`This PC's OonaCode does not list a chat's media yet — update it.`,` `,O?(0,B.jsx)(`button`,{type:`button`,className:`underline`,onClick:N,"data-testid":`media-retry-unsupported`,children:`Try again`}):null]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{role:`group`,"aria-label":`Whose media`,className:`flex shrink-0 gap-0.5 border-b border-border px-1.5 py-1`,"data-testid":`media-from`,children:lMe.map(e=>(0,B.jsx)(`button`,{type:`button`,"aria-pressed":d===e.value,title:e.title,onClick:()=>re(e.value),"data-testid":`media-from-${e.value}`,className:z(`flex-1 rounded-md px-2 py-1 text-xs`,d===e.value?`bg-accent-soft font-semibold text-accent`:`text-fg-muted hover:bg-surface-2 hover:text-fg`),children:e.label},e.value))}),(0,B.jsx)(`div`,{role:`tablist`,"aria-label":`Kinds of media`,className:`flex shrink-0 gap-0.5 overflow-x-auto border-b border-border px-1.5 py-1`,onKeyDown:e=>{if(e.key!==`ArrowRight`&&e.key!==`ArrowLeft`)return;let t=F7[(F7.findIndex(e=>e.kind===l)+(e.key===`ArrowRight`?1:-1)+F7.length)%F7.length];u(t.kind),e.preventDefault(),requestAnimationFrame(()=>document.getElementById(`media-tab-${t.kind}`)?.focus())},children:F7.map(e=>(0,B.jsxs)(`button`,{id:`media-tab-${e.kind}`,type:`button`,role:`tab`,"aria-selected":l===e.kind,"aria-controls":`media-tabpanel`,tabIndex:l===e.kind?0:-1,onClick:()=>u(e.kind),"data-testid":`media-tab-${e.kind}`,className:z(`flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs`,l===e.kind?`bg-surface-2 font-semibold text-fg`:`text-fg-muted hover:bg-surface-2 hover:text-fg`),children:[e.label,(0,B.jsx)(`span`,{className:`rounded-full bg-surface-3 px-1.5 text-[10px] tabular-nums text-fg-muted`,"data-testid":`media-count-${e.kind}`,children:Te[e.kind]})]},e.kind))}),(0,B.jsxs)(`div`,{id:`media-tabpanel`,role:`tabpanel`,"aria-labelledby":`media-tab-${l}`,className:`min-h-0 flex-1 overflow-y-auto px-2 py-2`,"data-testid":`media-tabpanel`,children:[we.error&&we.items.length===0?(0,B.jsxs)(`div`,{className:`p-2 text-xs text-danger`,role:`alert`,children:[we.error,` `,(0,B.jsx)(`button`,{type:`button`,className:`underline`,onClick:N,"data-testid":`media-retry`,children:`Try again`})]}):we.loaded&&we.items.length===0?(0,B.jsx)(`div`,{className:`p-4 text-center text-xs text-fg-faint`,"data-testid":`media-empty`,children:F7.find(e=>e.kind===l)?.empty}):l===`photo`||l===`video`?(0,B.jsx)(mMe,{items:we.items,urlOf:w,onOpen:e=>{if(e.kind===`photo`){let t=he.findIndex(t=>t.id===e.id);t>=0&&ge(t)}else be(e)},onShowInChat:ce,onBroken:k,onMenu:se}):(0,B.jsx)(`ul`,{className:`flex flex-col gap-1`,"data-testid":`media-list`,children:we.items.map(e=>(0,B.jsx)(_Me,{item:e,urlOf:w,onOpen:()=>e.kind===`link`&&e.url?O5(e.url):void ue(e),onShowInFolder:fe&&e.source===`path`&&e.exists!==!1?()=>fe(e):null,onShowInChat:()=>ce(e),onMenu:se,onBroken:k,showOwner:d===`all`},e.id))}),!m&&we.loaded&&we.missingHidden>0?(0,B.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-fg-muted`,"data-testid":`media-missing-hidden`,children:[(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[we.missingHidden,` file`,we.missingHidden===1?``:`s`,` the replies named `,we.missingHidden===1?`is`:`are`,` not on this PC any more — left out.`]}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>ie(!0),"data-testid":`media-show-missing`,children:`Show`})]}):null,m&&we.items.some(e=>e.exists===!1)?(0,B.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-fg-muted`,"data-testid":`media-missing-shown`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Showing files that are not on this PC any more.`}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>ie(!1),"data-testid":`media-hide-missing`,children:`Hide them`})]}):null,we.loading?(0,B.jsxs)(`div`,{className:`flex justify-center p-3 text-fg-faint`,"aria-live":`polite`,children:[(0,B.jsx)(H.Spinner,{className:`w-4 h-4 animate-spin`}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Loading…`})]}):we.nextBefore?(0,B.jsx)(pMe,{onLoad:()=>void A(l,`more`)}):null]})]}),(0,B.jsx)(ow,{open:ae!==null,at:ae?.at??{x:0,y:0},anchorEl:ae?.el??null,label:`Media actions`,testId:`media-context-menu`,onClose:F,items:Se}),(0,B.jsx)(rR,{picture:pe?.picture??null,onClose:_e,notify:P,...ve?{nav:ve}:{}}),(0,B.jsx)(vMe,{item:ye,src:ye&&w?w(ye.id):null,onClose:()=>be(null),onOpen:ye?()=>void ue(ye):null})]})}function W7({children:e}){return(0,B.jsx)(`div`,{className:`p-4 text-xs text-fg-faint`,"data-testid":`media-note`,children:e})}function pMe({onLoad:e}){let t=(0,v.useRef)(null),n=(0,v.useRef)(e);return n.current=e,(0,v.useEffect)(()=>{let e=t.current;if(!e||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&n.current()});return r.observe(e),()=>r.disconnect()},[]),(0,B.jsx)(`div`,{ref:t,className:`flex justify-center p-2`,children:(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:e,"data-testid":`media-load-more`,children:`Load more`})})}function mMe({items:e,urlOf:t,onOpen:n,onShowInChat:r,onBroken:i,onMenu:a}){let o=(0,v.useMemo)(()=>rMe(e),[e]);return(0,B.jsx)(`div`,{className:`flex flex-col gap-3`,"data-testid":`media-grid`,children:o.map(e=>(0,B.jsxs)(`section`,{"aria-label":e.label,children:[(0,B.jsx)(`h3`,{className:`mb-1 px-0.5 text-[11px] font-semibold text-fg-faint`,children:e.label}),(0,B.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:e.items.map(e=>(0,B.jsx)(hMe,{item:e,src:t&&R7(e)?t(e.id):null,onOpen:()=>n(e),onShowInChat:()=>r(e),onBroken:i,onMenu:a},e.id))})]},e.key))})}function hMe({item:e,src:t,onOpen:n,onShowInChat:r,onBroken:i,onMenu:a}){let o=z7(e),[s,c]=(0,v.useState)(!1),l=(0,v.useRef)(!1),u=`${e.name}${e.at?` — ${I7(e.at)}`:``}`,d=iMe(e.at);return(0,B.jsxs)(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface-2`,"data-testid":`media-tile`,"data-media-id":e.id,"data-from":e.from,...V7(e,a),children:[o?(0,B.jsxs)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-0.5 overflow-hidden p-1 text-center text-[10px] leading-tight text-fg-faint`,title:`${u} — ${o.toLowerCase()}${e.path?` (${e.path})`:``}`,"data-testid":`media-tile-unavailable`,children:[e.kind===`video`?(0,B.jsx)(H.Film,{className:`w-4 h-4 shrink-0`}):(0,B.jsx)(H.Image,{className:`w-4 h-4 shrink-0`}),(0,B.jsx)(`span`,{className:`text-warn`,"data-testid":`media-tile-reason`,children:o}),(0,B.jsx)(`span`,{className:`line-clamp-2 break-all font-medium text-fg-muted`,"data-testid":`media-tile-name`,children:e.name}),d?(0,B.jsx)(`span`,{"data-testid":`media-tile-date`,children:d}):null]}):(0,B.jsxs)(`button`,{type:`button`,onClick:n,title:u,"aria-label":`${e.kind===`video`?`Play`:`View`} ${u}`,className:`block h-full w-full focus:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"data-testid":`media-tile-open`,children:[t&&!s?e.kind===`video`?(0,B.jsx)(`video`,{src:`${t}#t=0.1`,preload:`metadata`,muted:!0,className:`pointer-events-none h-full w-full object-cover`,onError:()=>c(!0)}):(0,B.jsx)(`img`,{src:t,alt:e.name,loading:`lazy`,draggable:!1,className:`h-full w-full object-cover`,onError:()=>{if(!l.current){l.current=!0,i();return}c(!0)}}):(0,B.jsx)(`span`,{className:`flex h-full w-full items-center justify-center text-fg-faint`,children:e.kind===`video`?(0,B.jsx)(H.Film,{className:`w-5 h-5`}):(0,B.jsx)(H.Image,{className:`w-5 h-5`})}),e.kind===`video`?(0,B.jsx)(`span`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,B.jsx)(`span`,{className:`rounded-full bg-black/55 p-2 text-white`,children:(0,B.jsx)(H.Play,{className:`w-4 h-4`})})}):null]}),(0,B.jsx)(`button`,{type:`button`,onClick:r,title:`Show in chat`,"aria-label":`Show ${e.name} in chat`,className:`absolute bottom-1 right-1 rounded bg-black/55 p-1 text-white opacity-0 transition-opacity focus:opacity-100 group-hover:opacity-100`,"data-testid":`media-show-in-chat`,children:(0,B.jsx)(H.Chats,{className:`w-3 h-3`})})]})}function gMe(e){return e.kind===`link`?(0,B.jsx)(H.Link,{className:`w-4 h-4`}):e.kind===`audio`?(0,B.jsx)(H.Music,{className:`w-4 h-4`}):e.kind===`video`?(0,B.jsx)(H.Film,{className:`w-4 h-4`}):e.kind===`photo`?(0,B.jsx)(H.Image,{className:`w-4 h-4`}):(0,B.jsx)(H.File,{className:`w-4 h-4`})}function _Me({item:e,urlOf:t,onOpen:n,onShowInFolder:r,onShowInChat:i,onMenu:a,onBroken:o,showOwner:s}){let[c,l]=(0,v.useState)(!1),u=z7(e),d=e.kind===`link`,f=d&&e.url?oMe(e.url):null,p=d?I7(e.at):L7(e),m=e.kind===`audio`&&!u&&t!==null;return(0,B.jsxs)(`li`,{className:`rounded-md border border-transparent px-1.5 py-1.5 hover:border-border hover:bg-surface-2`,"data-testid":`media-row`,"data-media-id":e.id,"data-from":e.from,...V7(e,a),children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[m?(0,B.jsx)(lC,{label:c?`Hide the player for ${e.name}`:`Play ${e.name}`,className:`shrink-0 rounded-full bg-accent-soft p-1.5 text-accent`,onClick:()=>l(e=>!e),"aria-pressed":c,"data-testid":`media-play`,children:c?(0,B.jsx)(H.Pause,{className:`w-3.5 h-3.5`}):(0,B.jsx)(H.Play,{className:`w-3.5 h-3.5`})}):e.kind===`file`?(0,B.jsx)(VI,{name:e.name,className:`shrink-0`}):(0,B.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-3 p-1.5 text-fg-muted`,"aria-hidden":!0,children:gMe(e)}),(0,B.jsxs)(`button`,{type:`button`,onClick:u?void 0:n,disabled:u!==null,title:u?`${e.name} — ${u.toLowerCase()}${e.path?` (${e.path})`:``}`:d?`Open ${e.url??``} in the browser`:e.path?`Open ${e.path}`:`Open ${e.name}`,className:`min-w-0 flex-1 text-left disabled:cursor-default`,"data-testid":`media-row-open`,children:[f?(0,B.jsxs)(`span`,{className:`block truncate text-xs`,children:[(0,B.jsx)(`span`,{className:`font-medium text-accent`,children:f.host}),(0,B.jsx)(`span`,{className:`text-fg-muted`,children:f.rest})]}):(0,B.jsx)(`span`,{className:`block truncate text-xs font-medium text-fg`,children:e.name}),(0,B.jsxs)(`span`,{className:`block truncate text-[11px] text-fg-faint`,children:[u?(0,B.jsx)(`span`,{className:`text-warn`,"data-testid":`media-unavailable`,children:u}):null,u&&p?` · `:``,s?(0,B.jsx)(`span`,{"data-testid":`media-owner`,children:e.from===`assistant`?`Reply`:`You`}):null,s&&p?` · `:``,p]})]}),r?(0,B.jsx)(lC,{label:`Show in folder`,className:`shrink-0 p-1`,onClick:r,children:(0,B.jsx)(H.Folder,{className:`w-3.5 h-3.5`})}):null,(0,B.jsx)(lC,{label:`Show in chat`,className:`shrink-0 p-1`,onClick:i,"data-testid":`media-show-in-chat`,children:(0,B.jsx)(H.Chats,{className:`w-3.5 h-3.5`})})]}),c&&m&&t?(0,B.jsx)(`audio`,{controls:!0,autoPlay:!0,preload:`none`,src:t(e.id),onError:o,className:`mt-1.5 h-8 w-full`,"data-testid":`media-audio`}):null]})}function vMe({item:e,src:t,onClose:n,onOpen:r}){return(0,B.jsx)(gC,{open:e!==null,title:e?.name||`Video`,onClose:n,full:!0,children:e?(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2`,"data-testid":`video-viewer`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-faint`,children:L7(e)}),r?(0,B.jsx)(U,{size:`sm`,onClick:r,children:`Open externally`}):null]}),t?(0,B.jsx)(`video`,{src:t,controls:!0,autoPlay:!0,className:`min-h-0 w-full flex-1 rounded-md bg-black`,"data-testid":`video-viewer-player`}):(0,B.jsx)(`p`,{className:`text-xs text-fg-faint`,children:`This video cannot be played here.`})]}):null})}var yMe={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 bMe(e,t){let n=t?oc(t):null,r=null,i=null;for(let t=0;t<e.length;t++){let a=e[t];if(!a||a.kind!==`assistant`||!se(a.model))continue;let o=oc(a.model);n!==null&&o!==n&&(r=t,i=n),n=o}return{index:r,from:i,to:n}}function xMe(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 yMe;let s=bMe(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?oc(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??S.map(e=>Bee(e)).find(e=>e!==null)??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 SMe=[...Vf.what,...Vf.when,...Vf.who,...Vf.yours,...Vf.where];function CMe({sessionId:e,entryCount:t}){let{state:n,actions:r}=V(),i=n.chatAboutsChange,a=vf(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,Af(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(zf(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=Bf(f,a.maxWords),A=zf(f),j=jf(o);return(0,B.jsxs)(`div`,{className:`mb-2`,"data-testid":`session-about`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,children:(0,B.jsx)(H.Skill,{className:`w-3.5 h-3.5`})}),`About`,(0,B.jsx)(uC,{label:`About`,details:(0,B.jsx)(dC,{items:SMe})}),o.stale&&o.about?(0,B.jsx)(`span`,{title:Vf.stale,"data-testid":`session-about-stale`,children:(0,B.jsx)(hC,{tone:`warn`,children:`stale`})}):null]}),u?(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(`textarea`,{className:z(pC,`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,B.jsxs)(`div`,{className:z(`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`),` /`,` `,gf.userChars.toLocaleString(`en-US`),` characters`]}),A?(0,B.jsx)(`div`,{className:`text-[11px] text-danger`,"data-testid":`session-about-problem`,children:A}):k.overWords?(0,B.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,B.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,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:()=>void D(),busy:m,disabled:A!==null,"data-testid":`session-about-save`,children:`Save`}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>d(!1),disabled:m,"data-testid":`session-about-cancel`,children:`Cancel`})]})]}):(0,B.jsxs)(B.Fragment,{children:[o.about?(0,B.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-xs text-fg`,"data-testid":`session-about-text`,children:o.about}):(0,B.jsxs)(`p`,{className:`text-[11px] text-fg-muted`,"data-testid":`session-about-missing`,children:[`No about yet. `,Lf(o,{enabled:a.enabled,entryCount:t})]}),o.about&&o.aboutAt?(0,B.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,title:zv(o.aboutAt),"data-testid":`session-about-written`,children:[`Written `,Lv(o.aboutAt),j?` by ${j}`:``]}):null,o.about&&o.pending?(0,B.jsx)(`div`,{className:`text-[11px] text-accent`,children:`Being written again now…`}):null,o.about&&o.lastError?(0,B.jsxs)(`div`,{className:`text-[11px] text-danger`,"data-testid":`session-about-last-error`,children:[`The last attempt failed: `,o.lastError]}):null,(0,B.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,title:o.route?`Paid by ${Mf[o.route]}`:void 0,"data-testid":`session-about-spend`,children:[`Cost so far: `,Ff(o.spend,o.route)]}),x?(0,B.jsx)(`div`,{className:`mt-0.5 text-[11px] text-fg-muted`,"data-testid":`session-about-note`,children:x}):null,y?(0,B.jsx)(`div`,{className:`mt-0.5 text-[11px] text-danger`,role:`alert`,"data-testid":`session-about-regen-error`,children:y}):null,(0,B.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[(0,B.jsxs)(U,{size:`sm`,variant:`ghost`,onClick:E,disabled:g,title:Vf.edit,"data-testid":`session-about-edit`,children:[(0,B.jsx)(H.Edit,{className:`h-3 w-3`}),` Edit`]}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>void O(),disabled:!a.enabled||g,title:a.enabled?Vf.regenerate:Vf.regenerateOff,"data-testid":`session-about-regenerate`,children:g?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(H.Spinner,{className:`h-3 w-3`}),` Writing…`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(H.Refresh,{className:`h-3 w-3`}),` Regenerate`]})})]}),a.enabled?null:(0,B.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 wMe({view:e}){let t=(0,v.useMemo)(()=>ZAe(e.request??``),[e.request]);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:e.truncated?`Cut at the size the host keeps.`:`As agy sent it.`}),(0,B.jsx)(ZI,{text:t})]}),(0,B.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 TMe({sessionId:e,running:t}){let{api:n}=V(),[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;Zg(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)(()=>qAe(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(Zg(e)?{phase:`gone`}:{phase:`failed`,message:Kv(e)})}};if(a||r===null)return null;let S=e=>{let{title:t,detail:n}=n7(e),r=JAe(e),i=YAe(e.usage),a=p[e.id],o=[n,e.ms===null?`running…`:Fv(e.ms),i].filter(e=>!!e),s=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`span`,{className:`flex items-baseline gap-1.5`,children:[(0,B.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-fg-faint`,title:zv(e.at),children:XAe(e.at)}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-fg`,children:t}),(0,B.jsx)(`span`,{className:z(`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,B.jsx)(`span`,{className:`block break-words text-[11px] text-fg-faint`,children:o.join(` · `)}),e.error?(0,B.jsx)(`span`,{className:`block break-words text-[11px] text-danger`,children:e.error}):null]});return(0,B.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,B.jsx)(`button`,{type:`button`,className:`block w-full text-left`,"aria-expanded":a!==void 0,title:`${r7(e)} — show the request`,onClick:()=>void x(e),"data-testid":`agy-request-open-${e.id}`,children:s}):(0,B.jsx)(`div`,{title:r7(e),children:s}),a?(0,B.jsx)(`div`,{className:`mt-1`,"data-testid":`agy-request-body-${e.id}`,children:a.phase===`loading`?(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-fg-muted`,children:[(0,B.jsx)(H.Spinner,{className:`h-3 w-3`}),` Loading the request…`]}):a.phase===`gone`?(0,B.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,B.jsxs)(`div`,{className:`text-[11px] text-danger`,role:`alert`,children:[`Could not read it: `,a.message]}):(0,B.jsx)(wMe,{view:a.view})}):null]},e.id)};return(0,B.jsxs)(`div`,{className:`mb-2`,"data-testid":`agy-requests`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,B.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,B.jsx)(`span`,{"aria-hidden":`true`,children:(0,B.jsx)(H.Chevron,{className:`h-3 w-3`,open:l})}),`Google agy requests`,(0,B.jsx)(`span`,{className:`font-mono normal-case tracking-normal`,"data-testid":`agy-requests-count`,children:r.length})]}),(0,B.jsx)(lC,{label:`Refresh agy requests`,className:`p-1`,disabled:s,onClick:()=>void g(),"data-testid":`agy-requests-refresh`,children:s?(0,B.jsx)(H.Spinner,{className:`h-3 w-3`}):(0,B.jsx)(H.Refresh,{className:`h-3 w-3`})})]}),(0,B.jsx)(`p`,{className:`mb-1 text-[11px] leading-snug text-fg-faint`,"data-testid":`agy-requests-privacy`,children:WAe}),l?(0,B.jsxs)(B.Fragment,{children:[y.length===0?(0,B.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,B.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,B.jsxs)(`div`,{className:`mt-1.5`,children:[(0,B.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,B.jsx)(H.Chevron,{className:`h-3 w-3`,open:d}),`background calls (`,b.length,`)`]}),d?(0,B.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 G7({label:e,icon:t,children:n}){return(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1`,children:[(0,B.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-faint`,children:[t?(0,B.jsx)(`span`,{className:`shrink-0 text-fg-faint`,"aria-hidden":`true`,children:t}):null,e]}),(0,B.jsx)(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-fg`,children:n})]})}function K7({label:e,icon:t}){return(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,children:t}),e]})}var q7={provider:(0,B.jsx)(H.Plug,{className:`w-3.5 h-3.5`}),route:(0,B.jsx)(H.Globe,{className:`w-3.5 h-3.5`}),model:(0,B.jsx)(H.Bot,{className:`w-3.5 h-3.5`}),permission:(0,B.jsx)(H.Shield,{className:`w-3.5 h-3.5`}),context:(0,B.jsx)(H.Brain,{className:`w-3.5 h-3.5`}),window:(0,B.jsx)(H.Panel,{className:`w-3.5 h-3.5`}),compactions:(0,B.jsx)(H.CollapseAll,{className:`w-3.5 h-3.5`}),usage:(0,B.jsx)(H.Coins,{className:`w-3.5 h-3.5`}),tokensIn:(0,B.jsx)(H.Download,{className:`w-3.5 h-3.5`}),tokensOut:(0,B.jsx)(H.Upload,{className:`w-3.5 h-3.5`}),duration:(0,B.jsx)(H.Clock,{className:`w-3.5 h-3.5`}),turns:(0,B.jsx)(H.Send,{className:`w-3.5 h-3.5`}),session:(0,B.jsx)(H.Info,{className:`w-3.5 h-3.5`}),tasks:(0,B.jsx)(H.Bell,{className:`w-3.5 h-3.5`}),status:(0,B.jsx)(H.Monitor,{className:`w-3.5 h-3.5`}),updated:(0,B.jsx)(H.Refresh,{className:`w-3.5 h-3.5`}),entries:(0,B.jsx)(H.Menu,{className:`w-3.5 h-3.5`}),project:(0,B.jsx)(H.Project,{className:`w-3.5 h-3.5`}),folder:(0,B.jsx)(H.Folder,{className:`w-3.5 h-3.5`})};function EMe({used:e}){let t=Math.round(e*100);return(0,B.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,B.jsx)(`div`,{className:z(`h-full rounded-full`,t>=90?`bg-danger`:t>=70?`bg-warn`:`bg-accent`),style:{width:`${t}%`}})})}function DMe(){let{state:e,actions:t,api:n}=V(),r=XS(),[i,a]=(0,v.useState)(null),o=r?e.remote.tabs[r.id]!==void 0:!1,s=r?e.drafts[r.id]!==void 0:!1,c=YS(),l=e.currentSessionId,u=r?.projectId?e.vaultProjects.find(e=>e.id===r.projectId):void 0,d=u?.instructions.trim()??``,f=r?.providerId??e.activeProviderId,p=e.providers.find(e=>e.definition.id===f),m=p?.definition.models,h=(0,v.useMemo)(()=>{let e=p?.definition;return e?Qs(e,{credentialClass:(p.credentials.find(e=>e.variantId===r?.variantId)??p.credentials[0])?.class??null}):null},[p,r?.variantId]),g=(0,v.useMemo)(()=>xMe({items:c?.items??[],session:r,initModel:c?.init?.model??null,boundary:l?e.modelBoundaries[l]??null:null,models:m,contextTokens:c?.contextTokens??null}),[c?.items,c?.init?.model,c?.contextTokens,r,l,e.modelBoundaries,m]),_=(0,v.useMemo)(()=>(c?.items??[]).filter(e=>e.kind===`user`&&e.compactSummary).length,[c?.items]),y=r?Ng(r.providerId)&&!o&&!s:!1,b=c?.status===`running`||c?.status===`waiting_permission`,x=(0,v.useMemo)(()=>{if(!r)return[];let e=new Set,t=[],n=n=>{let r=n.trim();!r||e.has(r)||(e.add(r),t.push(r))};for(let e of r.browserProfiles??[])n(e);for(let e of c?.items??[])if(e.kind===`tool`&&e.name===`mcp__oonacode__browser`){let t=e.input?.action;t!==`help`&&t!==`close`&&t!==`reset`&&n(r.id.replace(/[^a-zA-Z0-9-]/g,`_`).slice(0,64)||`_`)}return t},[r,c?.items]),S=(0,v.useCallback)(async e=>{if(!r||!n.openSessionBrowser){t.toast(`error`,`This PC’s OonaCode cannot open browser profiles yet — update it.`);return}a(e);try{let i=await n.openSessionBrowser(r.id,e);t.toast(`success`,i.alreadyOpen?`Brought Oonak Browser (${i.profile}) to the front`:`Opened Oonak Browser with user-data-dir ${i.profile}`)}catch(e){t.toast(`error`,e instanceof Error&&e.message?e.message:`Could not open Oonak Browser for this profile.`)}finally{a(null)}},[r,n,t]);return(0,B.jsx)(B.Fragment,{children:r?(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-2`,children:[g.didReset?(0,B.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`,g.previousModel?` (was ${g.previousModel})`:``,`.`]}):null,!o&&!s?(0,B.jsx)(CMe,{sessionId:r.id,entryCount:r.entryCount??null},r.id):null,(0,B.jsxs)(`div`,{className:`mb-2`,children:[(0,B.jsx)(K7,{label:`Model`,icon:q7.model}),(0,B.jsx)(G7,{label:`Provider`,icon:q7.provider,children:p?.definition.displayName??f??`—`}),(0,B.jsx)(G7,{label:`Route`,icon:q7.route,children:h?(0,B.jsx)(hC,{tone:h.viaGateway?`accent`:`ok`,children:h.badge}):`—`}),h?(0,B.jsx)(`div`,{className:`pb-1 text-[11px] leading-snug text-fg-faint`,children:h.detail}):null,(0,B.jsx)(G7,{label:`Model`,icon:q7.model,children:g.model??r.model??`—`}),(0,B.jsxs)(G7,{label:`Permission mode`,icon:q7.permission,children:[(0,B.jsx)(hC,{children:ne(re(r))}),` `,(0,B.jsx)(hC,{children:r.permissionMode})]})]}),(0,B.jsxs)(`div`,{className:`mb-2`,children:[(0,B.jsx)(K7,{label:`Context`,icon:q7.context}),g.contextUsed!==null&&g.contextTokens!==null?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(EMe,{used:g.contextUsed}),(0,B.jsxs)(`div`,{className:`mt-1 text-[11px] text-fg-muted`,"data-testid":`context-used`,children:[Iv(g.contextTokens),` / `,Iv(g.contextWindow??0),` `,`tokens (`,Math.round(g.contextUsed*100),`%)`]})]}):(0,B.jsx)(`div`,{className:`text-[11px] text-fg-muted`,"data-testid":`context-used`,children:g.contextTokens===null?`Measured at the next reply`:`${Iv(g.contextTokens)} tokens (window unknown)`}),(0,B.jsx)(G7,{label:`Context window`,icon:q7.window,children:(0,B.jsx)(`span`,{"data-testid":`context-window`,children:g.contextWindow?`${Iv(g.contextWindow)} tokens`:`unknown`})}),(0,B.jsx)(G7,{label:`Compactions`,icon:q7.compactions,children:(0,B.jsx)(`span`,{"data-testid":`compaction-count`,children:_})})]}),(0,B.jsxs)(`div`,{className:`mb-2`,children:[(0,B.jsx)(K7,{label:`Usage`,icon:q7.usage}),(0,B.jsx)(G7,{label:`Tokens in`,icon:q7.tokensIn,children:Iv(g.inputTokens)}),(0,B.jsx)(G7,{label:`Tokens out`,icon:q7.tokensOut,children:Iv(g.outputTokens)}),g.credits===null?null:(0,B.jsx)(G7,{label:`Credits used`,icon:q7.usage,children:g.credits.toLocaleString(`en-US`,{maximumFractionDigits:2})}),(0,B.jsx)(G7,{label:`Duration`,icon:q7.duration,children:g.countedResults>0&&Fv(g.durationMs)||`—`}),(0,B.jsx)(G7,{label:`Turns`,icon:q7.turns,children:g.countedResults>0?g.turns:`—`})]}),(0,B.jsxs)(`div`,{className:`mb-2`,children:[(0,B.jsx)(K7,{label:`Session`,icon:q7.session}),(0,B.jsx)(G7,{label:`Status`,icon:q7.status,children:(0,B.jsx)(hC,{tone:c?.status===`error`?`danger`:c?.status===`running`?`accent`:c?.status===`waiting_permission`?`warn`:`neutral`,children:c?.status??r.status})}),(0,B.jsx)(G7,{label:`Updated`,icon:q7.updated,children:Lv(r.updatedAt)}),(0,B.jsx)(G7,{label:`Entries`,icon:q7.entries,children:r.entryCount}),(0,B.jsx)(G7,{label:`Project`,icon:q7.project,children:(0,B.jsx)(`span`,{"data-testid":`session-project`,children:u?u.name:`—`})}),d?(0,B.jsx)(`div`,{className:`whitespace-pre-wrap break-words pb-1 text-[11px] leading-snug text-fg-faint`,"data-testid":`session-project-instructions`,children:d.length>300?`${d.slice(0,300)}\u2026`:d}):null,o?null:(0,B.jsx)(`button`,{type:`button`,className:`text-[11px] text-accent hover:underline`,onClick:()=>t.openAssignProject(r.id),"data-testid":`session-change-project`,children:u?`Move to another project…`:`Move to a project…`}),(0,B.jsx)(G7,{label:`Folder`,icon:q7.folder,children:r.projectDir?`project`:`own workspace`}),(0,B.jsx)(`div`,{className:`mt-1 break-all font-mono text-[10px] text-fg-faint`,"data-testid":`session-folder`,children:r.cwd}),o?null:(0,B.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…`})]}),x.length>0?(0,B.jsxs)(`div`,{className:`mb-2 space-y-1.5`,"data-testid":`session-browser-profiles`,children:[(0,B.jsx)(K7,{label:`Oonak Browser`,icon:q7.route}),(0,B.jsxs)(`div`,{className:`text-[11px] leading-snug text-fg-faint`,children:[`Browser user-data-dir `,x.length===1?`profile`:`profiles`,` used in this session:`]}),(0,B.jsx)(`div`,{className:`flex flex-col gap-1`,children:x.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border bg-surface-2 px-2 py-1.5`,"data-testid":`session-browser-profile`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1 break-all font-mono text-[11px] text-fg`,title:`user-data-dir: ${e}`,children:e}),!o&&!s?(0,B.jsx)(`button`,{type:`button`,disabled:i!==null,onClick:()=>void S(e),className:`shrink-0 rounded bg-accent px-2 py-0.5 text-[11px] font-medium text-accent-fg hover:opacity-90 disabled:opacity-50`,"data-testid":`session-browser-open`,children:i===e?`Opening…`:`Restore browser`}):null]},e))})]}):null,y?(0,B.jsx)(TMe,{sessionId:r.id,running:b},r.id):null,o?null:(0,B.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`session-scheduled-tasks`,children:[(0,B.jsx)(K7,{label:`Scheduled tasks`,icon:q7.tasks}),(0,B.jsx)(CL,{sessionId:r.id})]}),c?.init?(0,B.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[`engine `,c.init.claudeCodeVersion,` · `,c.init.tools.length,` tools`]}):null]}):(0,B.jsx)(`div`,{className:`p-4 text-xs text-fg-faint`,children:`Open a chat to see its statistics.`})})}var J7=[{id:`media`,title:`Media`,hideLabel:`Hide media`,icon:H.Gallery,available:({sessionId:e})=>e!==null,render:({sessionId:e,reportCount:t})=>e?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`media-panel`,"aria-label":`Media in this chat`,children:(0,B.jsx)(fMe,{sessionId:e,onTotal:t},e)}):null},{id:`sessionInfo`,title:`Session info`,hideLabel:`Hide session info`,icon:H.Info,render:({sessionId:e})=>(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`session-panel`,"aria-label":`Session info`,children:(0,B.jsx)(DMe,{},e??`none`)})}];function Y7(e){return J7.find(t=>t.id===e)}var X7={rightPanelWidth:320};function OMe(e,t){let{state:n,actions:r}=V(),i=n.prefs[e],[a,o]=(0,v.useState)(null),s=a??i,c=(0,B.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the ${t}`,title:`Drag to resize · double-click for the default width`,className:`absolute inset-y-0 -left-1 z-10 hidden w-2 cursor-col-resize hover:bg-accent/30 lg:block`,onPointerDown:t=>{t.preventDefault();let n=t.clientX,a=s,c=a,l=t=>{c=Ql(a+(n-t.clientX),X7[e]),o(c)},u=()=>{window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),document.body.style.cursor=``,document.body.style.userSelect=``,o(null),c!==i&&r.savePrefs({[e]:c})};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u)},onDoubleClick:()=>void r.savePrefs({[e]:X7[e]}),"data-testid":`right-panel-resize`});return{style:{width:`min(${s}px, 85vw)`},handle:c}}function kMe(){let{state:e,actions:t}=V(),{rightPanelSections:n,rightPanelCollapsed:r}=e.prefs,i=e.currentSessionId,a=OMe(`rightPanelWidth`,`right panel`),[o,s]=(0,v.useState)({}),c=(0,v.useMemo)(()=>{let e={};for(let t of J7)e[t.id]=e=>s(n=>n[t.id]===e?n:{...n,[t.id]:e});return e},[]),l=(0,v.useCallback)(e=>Y7(e)?.available?.({sessionId:i})??!0,[i]),u=dx(n,l),d=fx(u,r),f=(e,n)=>void t.savePrefs(px(e,n)),p=J7.map(e=>{let t=n.includes(e.id);return{id:e.id,label:t?e.hideLabel:`Show ${e.title.toLowerCase()}`,icon:e.icon,active:t,count:o[e.id]??null}});return(0,B.jsxs)(B.Fragment,{children:[u.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 lg:hidden`,onClick:()=>f([],[]),"aria-hidden":!0}),(0,B.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,B.jsxs)(`aside`,{className:`relative flex shrink-0 flex-col border-l border-border bg-surface`,style:a.style,"aria-label":`Side panels`,"data-testid":`right-dock`,"data-font-scope":`sidebar`,children:[a.handle,u.map(e=>{let t=Y7(e);return t?(0,B.jsx)(nMe,{id:e,title:t.title,icon:t.icon,count:o[e]??null,collapsed:r.includes(e),onToggle:()=>f(n,ux(r,e)),onRemove:()=>f(lx(n,e),r),removeLabel:t.hideLabel,grow:d[e]??1,children:t.render({sessionId:i,reportCount:c[e]})},e):null})]})})]}):null,(0,B.jsx)(`div`,{className:`hidden border-l border-border lg:flex`,children:(0,B.jsx)(P7,{items:p,multi:!0,testId:`activity-bar-right`,label:`Side panels`,onPick:e=>{l(e)&&f(lx(n,e),r)}})})]})}function AMe(e){let t=e=>e.type===`dir`?0:1;return[...e].sort((e,n)=>t(e)-t(n)||e.name.localeCompare(n.name))}function jMe(e){let t=[];return e.target.type===`file`&&t.push({key:`open`,label:`Open`,icon:(0,B.jsx)(H.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,B.jsx)(H.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,B.jsx)(H.Copy,{className:`w-3.5 h-3.5`}),onSelect:e.onCopyRelativePath,testId:`files-menu-copy-relative-path`}),!e.remote&&e.canReveal&&t.push({key:`show-in-explorer`,label:`Show in Explorer`,icon:(0,B.jsx)(H.Folder,{className:`w-3.5 h-3.5`}),onSelect:e.onReveal,testId:`files-menu-show-in-explorer`}),!e.remote&&e.canRename&&t.push({key:`rename`,label:`Rename…`,icon:(0,B.jsx)(H.Edit,{className:`w-3.5 h-3.5`}),onSelect:e.onRename,testId:`files-menu-rename`}),!e.remote&&e.canDelete&&t.push({key:`delete`,label:`Delete…`,icon:(0,B.jsx)(H.Trash,{className:`w-3.5 h-3.5`}),danger:!0,separated:!0,onSelect:e.onDelete,testId:`files-menu-delete`}),t}function MMe(e,t){return t instanceof qg&&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 ${DF(e.path)}: ${t instanceof Error?t.message:String(t)}`}function NMe(){let{state:e,dispatch:t,actions:n,api:r}=V(),i=XS(),a=YS(),o=i?.id??null,s=(o?e.remote.tabs[o]:void 0)?.hostId??(o?e.remote.sessionOwners[o]:void 0)??null,c=s!==null,l=c&&typeof r.listHostSessionFiles==`function`,u=a?.status===`running`||a?.status===`waiting_permission`,d=o?e.files[o]?.active??null:null,f=c?e.remote.hosts.find(e=>e.hostId===s)?.platform??null:e.info?.platform??null,p=i?.cwd??``,m=e=>{n.openFile(e),_x(n.setSidebar)},[h,g]=(0,v.useState)({}),[_,y]=(0,v.useState)(()=>new Set),[b,x]=(0,v.useState)(!1),S=(0,v.useRef)(h);S.current=h;let C=(0,v.useRef)(_);C.current=_;let w=(0,v.useRef)(o);w.current=o;let T=(0,v.useRef)(e.files);T.current=e.files;let[E,D]=(0,v.useState)(null),O=(0,v.useCallback)(()=>D(null),[]),k=(0,v.useCallback)((e,t,n)=>D({target:e,at:t,el:n}),[]),[A,j]=(0,v.useState)(null),[ee,M]=(0,v.useState)(!1),te=(0,v.useCallback)(()=>j(null),[]),[ne,N]=(0,v.useState)(null),[P,re]=(0,v.useState)(!1),ie=(0,v.useCallback)(()=>N(null),[]),[ae,oe]=(0,v.useState)(``),se=yx(ae)!==``,F=(0,v.useMemo)(()=>se?xx(h,ae):null,[se,h,ae]),ce=(0,v.useCallback)(async e=>{if(!o||(c?!r.listHostSessionFiles||!s:!r.listSessionFiles))return;let t=o;g(t=>({...t,[e]:{...t[e]??{entries:null},loading:!0,error:null}}));try{let n=c&&s&&r.listHostSessionFiles?await r.listHostSessionFiles(s,t,e):await r.listSessionFiles(t,e);if(w.current!==t)return;x(!1),g(t=>({...t,[e]:{entries:AMe(n.entries),loading:!1,error:null}}))}catch(n){if(w.current!==t)return;Zg(n)&&x(!0);let r=n instanceof Error?n.message:String(n);g(t=>({...t,[e]:{entries:t[e]?.entries??null,loading:!1,error:r}}))}},[r,o,c,s]);(0,v.useEffect)(()=>{g({}),y(new Set),x(!1),D(null),j(null),o&&(!c||l)&&ce(``)},[o,c,l,ce]);let le=(0,v.useRef)(u);(0,v.useEffect)(()=>{if(le.current&&!u&&o&&(!c||l))for(let e of Object.keys(S.current))(e===``||C.current.has(e))&&ce(e);le.current=u},[u,o,c,l,ce]);let ue=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),S.current[e]?.entries||ce(e)),n})},de=()=>{if(o){ce(``);for(let e of _)ce(e)}},fe=(e,t)=>{XI(e).then(e=>n.toast(e?`success`:`error`,e?t:`Could not copy to the clipboard`))},pe=e=>{let t=window.oonacode;if(!p||!t?.showItemInFolder){n.toast(`error`,`Show in Explorer is available in the desktop app on this PC.`);return}t.showItemInFolder(MF(p,e.path,f)).then(e=>{e.ok||n.toast(`error`,e.message||`Could not show it in Explorer.`)})},me=(e,t,n)=>n===e?t:n.startsWith(`${e}/`)?`${t}${n.slice(e.length)}`:null,he=async e=>{let i=ne,a=o;if(!(!i||!a||!r.renameSessionFile||c)){re(!0);try{let o=await r.renameSessionFile(a,i.path,e);ske(a,i.path,o.path);for(let e of T.current[a]?.open??[]){let n=me(i.path,o.path,e);n&&(t({type:`file_close`,sessionId:a,path:e}),(i.type===`file`||e!==i.path)&&t({type:`file_open`,sessionId:a,path:n}))}w.current===a&&(y(e=>{let t=new Set;for(let n of e)t.add(me(i.path,o.path,n)??n);return t}),g(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[me(i.path,o.path,e)??e,t]))),ce(OF(o.path))),n.toast(`success`,`Renamed to ${DF(o.path)}`),N(null)}catch(e){n.toast(`error`,`Could not rename ${DF(i.path)}: ${e instanceof Error?e.message:String(e)}`)}finally{re(!1)}}},ge=async()=>{let e=A,i=o;if(!(!e||!i)&&!(c?!r.deleteHostSessionFile||!s:!r.deleteSessionFile)){M(!0);try{c&&s&&r.deleteHostSessionFile?await r.deleteHostSessionFile(s,i,e.path):await r.deleteSessionFile(i,e.path);for(let n of T.current[i]?.open??[])kF(n,e.path)&&t({type:`file_close`,sessionId:i,path:n});w.current===i&&(y(t=>new Set([...t].filter(t=>!kF(t,e.path)))),g(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!kF(t,e.path)))),ce(OF(e.path))),n.toast(`success`,`Deleted ${DF(e.path)}`)}catch(t){n.toast(`error`,MMe(e,t)),w.current===i&&ce(OF(e.path))}finally{M(!1),j(null)}}},_e=E?jMe({target:E.target,remote:c,canDelete:typeof r.deleteSessionFile==`function`,canCopyPath:p!==``,canReveal:!c&&p!==``&&typeof window.oonacode?.showItemInFolder==`function`,canRename:!c&&typeof r.renameSessionFile==`function`,onOpen:()=>m(E.target.path),onCopyPath:()=>fe(MF(p,E.target.path,f),`Path copied`),onCopyRelativePath:()=>fe(jF(E.target.path,AF(p,f)),`Relative path copied`),onReveal:()=>pe(E.target),onRename:()=>N(E.target),onDelete:()=>j(E.target)}):[],ve=i?.cwd?DF(i.cwd)||i.cwd:`Files`,ye=h[``],be=E?.target.path??null,xe=(0,v.useMemo)(()=>o?c&&!l?(0,B.jsx)(Z7,{children:`This chat runs on another PC; its files can be browsed there.`}):b?(0,B.jsx)(Z7,{children:`This host is too old to list files — update it from the title bar.`}):ye?.error&&!ye.entries?(0,B.jsx)(Z7,{tone:`danger`,children:ye.error}):ye?.entries?ye.entries.length===0?(0,B.jsx)(Z7,{children:`The folder is empty.`}):F&&F.visible.size===0?(0,B.jsx)(Z7,{children:`Nothing listed matches. The filter looks at the folders already opened — Search (Ctrl+K) looks through the whole folder, file contents too.`}):(0,B.jsx)(`ul`,{role:`tree`,"aria-label":`Workspace files`,className:`py-1`,children:(0,B.jsx)(e9,{rel:``,depth:0,tree:h,expanded:_,activeFile:d,menuPath:be,narrowed:F,onToggle:ue,onOpen:m,onMenu:k})}):(0,B.jsx)(Z7,{children:`Listing…`}):(0,B.jsx)(Z7,{children:`Open a chat to browse the folder it works in.`}),[o,c,b,ye,h,_,d,be,F,n]);return(0,B.jsxs)(`section`,{className:`flex h-full min-h-0 w-full flex-col bg-surface`,"aria-label":`Files`,"data-testid":`file-explorer`,"data-font-scope":`sidebar`,children:[(0,B.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,B.jsx)(H.Folder,{className:`w-3.5 h-3.5 text-fg-faint`}),(0,B.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:ve}),(0,B.jsx)(lC,{label:`Refresh files`,className:`p-1`,onClick:de,disabled:!o||c&&!l,"data-testid":`file-explorer-refresh`,children:(0,B.jsx)(H.Refresh,{className:`w-3.5 h-3.5`})})]}),(0,B.jsxs)(`div`,{className:`relative shrink-0 border-b border-border p-2`,children:[(0,B.jsx)(H.Filter,{className:`pointer-events-none absolute left-4 top-4 w-3.5 h-3.5 text-fg-faint`}),(0,B.jsx)(`input`,{"aria-label":`Filter files by name`,className:z(pC,`pl-7`,ae!==``&&`pr-7`),placeholder:`Filter files`,value:ae,onChange:e=>oe(e.target.value),onKeyDown:e=>{e.key===`Escape`&&ae!==``&&(e.preventDefault(),e.stopPropagation(),oe(``))},"data-testid":`files-filter`}),ae===``?null:(0,B.jsx)(lC,{label:`Clear the filter`,className:`absolute right-2.5 top-2.5 p-1`,onClick:()=>oe(``),"data-testid":`files-filter-clear`,children:(0,B.jsx)(H.X,{className:`w-3.5 h-3.5`})})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:xe}),(0,B.jsx)(ow,{open:E!==null,at:E?.at??{x:0,y:0},anchorEl:E?.el??null,label:`File actions`,testId:`files-context-menu`,onClose:O,items:_e}),(0,B.jsx)(PMe,{target:ne,busy:P,onConfirm:e=>void he(e),onClose:ie}),(0,B.jsx)(FMe,{target:A,absolute:A?p?MF(p,A.path,f):A.path:``,platform:f,busy:ee,onConfirm:()=>void ge(),onClose:te})]})}function PMe({target:e,busy:t,onConfirm:n,onClose:r}){let[i,a]=(0,v.useState)(``);(0,v.useEffect)(()=>{a(e?DF(e.path):``)},[e]);let o=e?.type===`dir`;return(0,B.jsx)(gC,{open:e!==null,title:o?`Rename this folder`:`Rename this file`,onClose:r,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{onClick:r,disabled:t,"data-testid":`files-rename-cancel`,children:`Cancel`}),(0,B.jsx)(U,{variant:`primary`,busy:t,disabled:!i.trim()||i.trim()===(e?DF(e.path):``),onClick:()=>n(i.trim()),"data-testid":`files-rename-confirm`,children:`Rename`})]}),children:(0,B.jsxs)(`label`,{className:`block text-sm`,children:[(0,B.jsx)(`span`,{className:`mb-1 block text-fg-muted`,children:`New name`}),(0,B.jsx)(`input`,{value:i,autoFocus:!0,disabled:t,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i.trim()&&n(i.trim())},className:`w-full rounded-md border border-border bg-surface px-2 py-1.5`,"data-testid":`files-rename-input`})]})})}function FMe({target:e,absolute:t,platform:n,busy:r,onConfirm:i,onClose:a}){let o=e?.type===`dir`;return(0,B.jsx)(gC,{open:e!==null,title:o?`Delete this folder?`:`Delete this file?`,onClose:a,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{onClick:a,disabled:r,"data-testid":`files-delete-cancel`,children:`Cancel`}),(0,B.jsx)(U,{variant:`danger`,busy:r,onClick:i,"data-testid":`files-delete-confirm`,children:`Delete permanently`})]}),children:(0,B.jsxs)(`div`,{className:`space-y-2 text-sm text-fg-muted`,"data-testid":`files-delete-dialog`,children:[(0,B.jsx)(`p`,{className:`break-all rounded bg-surface-2 px-2 py-1 font-mono text-xs text-fg`,children:t}),(0,B.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 Z7({children:e,tone:t}){return(0,B.jsx)(`div`,{className:z(`p-4 text-xs`,t===`danger`?`text-danger`:`text-fg-faint`),children:e})}function Q7(e){let t=e.getBoundingClientRect();return{x:t.left+24,y:t.bottom}}function $7(e,t){return{onContextMenu:n=>{n.preventDefault();let r=n.currentTarget;t(e,n.clientX===0&&n.clientY===0?Q7(r):{x:n.clientX,y:n.clientY},r)},onKeyDown:n=>{(n.key===`ContextMenu`||n.shiftKey&&n.key===`F10`)&&(n.preventDefault(),t(e,Q7(n.currentTarget),n.currentTarget))}}}function e9({rel:e,depth:t,tree:n,expanded:r,activeFile:i,menuPath:a,narrowed:o,onToggle:s,onOpen:c,onMenu:l}){let u=n[e];return u?u.error&&!u.entries?(0,B.jsx)(`li`,{className:`px-2 py-1 text-[11px] text-danger`,style:{paddingLeft:`${.5+t*.75}rem`},children:u.error}):u.entries?(0,B.jsx)(B.Fragment,{children:u.entries.map(u=>{let d=Eue(e,u.name);if(o&&!o.visible.has(d))return null;let f=a===d;if(u.type===`dir`){let e=r.has(d)||!!o?.open.has(d);return(0,B.jsxs)(`li`,{role:`treeitem`,"aria-expanded":e,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s(d),...$7({path:d,type:`dir`},l),"data-testid":`explorer-dir-${d}`,className:z(`flex w-full items-center gap-1 py-0.5 pr-2 text-left text-xs text-fg hover:bg-surface-2`,f&&`bg-surface-2`),style:{paddingLeft:`${.5+t*.75}rem`},children:[(0,B.jsx)(H.ChevronRight,{className:z(`w-3 h-3 shrink-0 text-fg-faint transition-transform`,e&&`rotate-90`)}),(0,B.jsx)(H.Folder,{className:`w-3.5 h-3.5 shrink-0 text-fg-faint`}),(0,B.jsx)(`span`,{className:`truncate`,children:u.name})]}),e?(0,B.jsx)(`ul`,{role:`group`,children:(0,B.jsx)(e9,{rel:d,depth:t+1,tree:n,expanded:r,activeFile:i,menuPath:a,narrowed:o,onToggle:s,onOpen:c,onMenu:l})}):null]},d)}let p=i===d;return(0,B.jsx)(`li`,{role:`treeitem`,"aria-selected":p,children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>c(d),...$7({path:d,type:u.type},l),disabled:u.type!==`file`,"data-testid":`explorer-file-${d}`,title:`${d} · ${HF(u.size)}`,className:z(`flex w-full items-center gap-1 py-0.5 pr-2 text-left text-xs hover:bg-surface-2 disabled:opacity-50`,p?`bg-accent-soft text-accent`:f?`bg-surface-2 text-fg`:`text-fg`),style:{paddingLeft:`${.5+t*.75+.9}rem`},children:[(0,B.jsx)(H.File,{className:`w-3.5 h-3.5 shrink-0 text-fg-faint`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:u.name}),(0,B.jsx)(`span`,{className:`shrink-0 text-[10px] text-fg-faint`,children:HF(u.size)})]})},d)})}):(0,B.jsx)(`li`,{className:`px-2 py-1 text-[11px] text-fg-faint`,style:{paddingLeft:`${.5+t*.75}rem`},children:`Listing…`}):null}function t9({text:e,query:t,options:n}){return(0,B.jsx)(B.Fragment,{children:y7(e,t,n).map((e,t)=>e.hit?(0,B.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,B.jsx)(`span`,{children:e.text},t))})}function IMe({active:e,focusAsk:t=0}){let{state:n}=V(),[r,i]=(0,v.useState)(`chats`),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(v7),[l,u]=(0,v.useState)(!1),d=(0,v.useRef)(null),f=(0,v.useRef)(0),p=(0,v.useRef)(!1);(0,v.useEffect)(()=>{t!==f.current&&(f.current=t,p.current=!0),e&&p.current&&(p.current=!1,d.current?.focus())},[e,t]);let m=r===`chats`,h=m&&s.mode===`conversations`,g=()=>{o(``),u(!1),d.current?.focus()},_=e=>c(t=>({...t,[e]:!t[e]}));return(0,B.jsxs)(`section`,{className:`flex h-full min-h-0 w-full flex-col bg-surface`,"aria-label":`Search`,"data-testid":`search-section`,children:[(0,B.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,B.jsx)(H.Search,{className:`w-3.5 h-3.5 text-fg-faint`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:`Search`})]}),(0,B.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b border-border p-2`,children:[(0,B.jsx)(`div`,{className:`flex rounded-md border border-border bg-surface-2 p-0.5`,role:`radiogroup`,"aria-label":`Search in`,children:[[`chats`,`Chats`],[`files`,`Files & contents`]].map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":r===e,onClick:()=>{i(e),u(!1),d.current?.focus()},className:z(`flex-1 rounded px-2 py-1 text-xs font-medium transition-colors`,r===e?`bg-surface text-fg shadow-sm`:`text-fg-muted hover:text-fg`),"data-testid":`search-scope-${e}`,children:t},e))}),(0,B.jsxs)(`div`,{className:`relative flex items-center gap-1`,"data-testid":`sidebar-search`,children:[(0,B.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,B.jsx)(H.Search,{className:`pointer-events-none absolute left-2 top-2 w-3.5 h-3.5 text-fg-faint`}),(0,B.jsx)(`input`,{ref:d,"aria-label":m?`Search sessions`:`Search files`,className:z(pC,`pl-7`),placeholder:m?h?`Search every chat`:`Search chats`:`File names and contents`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(a!==``||l)&&(e.preventDefault(),e.stopPropagation(),l?u(!1):o(``))},"data-testid":`search-input`})]}),m?(0,B.jsxs)(lC,{label:l?`Hide search options`:`Search options`,className:z(`relative`,l&&`text-accent`),"aria-pressed":l,onMouseDown:e=>e.preventDefault(),onClick:()=>u(e=>!e),"data-testid":`search-options-toggle`,children:[(0,B.jsx)(H.Sliders,{}),b7(s)?(0,B.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,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(lC,{label:`Match case`,className:z(`px-1 text-[11px] font-semibold`,s.caseSensitive&&`text-accent`),"aria-pressed":s.caseSensitive,onClick:()=>_(`caseSensitive`),"data-testid":`file-search-case`,children:`Aa`}),(0,B.jsx)(lC,{label:`Whole words`,className:z(`px-1 text-[11px] font-semibold underline`,s.wholeWord&&`text-accent`),"aria-pressed":s.wholeWord,onClick:()=>_(`wholeWord`),"data-testid":`file-search-word`,children:`ab`})]}),a!==``||l?(0,B.jsx)(lC,{label:`Clear search`,onMouseDown:e=>e.preventDefault(),onClick:g,"data-testid":`close-search`,children:(0,B.jsx)(H.X,{})}):null,m&&l?(0,B.jsx)(w7,{options:s,onChange:c,projects:n.vaultProjects,onClose:()=>{u(!1),d.current?.focus()}}):null]})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1 pb-2`,children:m?h?a.trim()===``?(0,B.jsx)(n9,{testId:`search-idle`,children:`Type to search every message of every chat on this PC.`}):(0,B.jsx)(jje,{query:a,options:s}):(0,B.jsx)(LMe,{query:a,options:s}):(0,B.jsx)(RMe,{query:a,options:s})})]})}function n9({children:e,testId:t,tone:n}){return(0,B.jsx)(`div`,{className:z(`px-3 py-4 text-center text-xs`,n===`danger`?`text-danger`:`text-fg-faint`),"data-testid":t,children:e})}function LMe({query:e,options:t}){let{state:n,actions:r}=V(),i=lz(),a=mz(),o=e.trim(),[s,c]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!o)return;let e=!0,t=setTimeout(()=>{r.searchSessionNames(o).then(t=>{e&&c({term:o,sessions:t})})},200);return()=>{e=!1,clearTimeout(t)}},[o,r]);let l=s&&s.term===o?s:null,u=(0,v.useMemo)(()=>{if(!l?.sessions)return[];let e=Date.now();return l.sessions.filter(n=>Dje(n,o,t,e))},[l,o,t]),d=(0,v.useMemo)(()=>new Map(n.vaultProjects.map(e=>[e.id,e.name])),[n.vaultProjects]);return o?l?l.sessions===null?(0,B.jsx)(n9,{testId:`search-failed`,tone:`danger`,children:`This PC could not search its chats. Try again.`}):(0,B.jsxs)(`div`,{"data-testid":`search-results`,children:[(0,B.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-fg-faint`,children:u.length===0?`No chat matches.`:`${u.length} ${u.length===1?`chat`:`chats`}`}),u.map(e=>(0,B.jsx)(sz,{session:e,active:e.id===n.currentSessionId&&n.page===null,link:n.sessionLinks[e.id]??null,menuOpen:i.menuFor===e.id,busy:i.sessionOps[e.id]??null,projectName:e.projectId?d.get(e.projectId)??null:null,testIdPrefix:`search-session`,onOpen:e=>{r.selectSession(e),_x(r.setSidebar)},onMenu:i.openMenu,clock:a},e.id)),i.element]}):(0,B.jsx)(n9,{testId:`search-busy`,children:`Searching…`}):(0,B.jsx)(n9,{testId:`search-idle`,children:`Type to find a chat by its name, its first or last message, or its folder. The sliders search inside every message.`})}function RMe({query:e,options:t}){let{state:n,actions:r,api:i}=V(),a=XS(),o=a?.id??null,s=o!==null&&!!(n.remote.tabs[o]??n.remote.sessionOwners[o]),c=e.trim(),l=t.caseSensitive,u=t.wholeWord,d=`${o??``}\n${c}\n${+!!l}${+!!u}`,f=o!==null&&!s&&typeof i.searchSessionFiles==`function`,p=f&&c.length>=2,[m,h]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!p||!o||!i.searchSessionFiles)return;let e=!0,t=i.searchSessionFiles,n=setTimeout(()=>{t(o,{q:c,caseSensitive:l,wholeWord:u}).then(t=>{e&&h({key:d,res:t,error:null})},t=>{if(!e)return;let n=Zg(t)?`This host is too old to search files — update it from the title bar.`:`Could not search the files: ${t instanceof Error?t.message:String(t)}`;h({key:d,res:null,error:n})})},300);return()=>{e=!1,clearTimeout(n)}},[d,p,i]);let g=a?.cwd?DF(a.cwd)||a.cwd:null;if(!o)return(0,B.jsx)(n9,{testId:`file-search-idle`,children:`Open a chat to search the folder it works in.`});if(s)return(0,B.jsx)(n9,{testId:`file-search-idle`,children:`This chat runs on another PC; its files can be searched there.`});if(!f)return(0,B.jsx)(n9,{testId:`file-search-idle`,children:`This window cannot search files.`});if(c.length<2)return(0,B.jsxs)(n9,{testId:`file-search-idle`,children:[`Searches the file names and the text in the folder of the open chat`,g?(0,B.jsxs)(B.Fragment,{children:[` — `,(0,B.jsx)(`span`,{className:`font-medium text-fg-muted`,title:a?.cwd,children:g})]}):null,`. Type at least two characters.`]});let _=m&&m.key===d?m:null;if(!_)return(0,B.jsx)(n9,{testId:`file-search-busy`,children:`Searching the files…`});if(!_.res)return(0,B.jsx)(n9,{testId:`file-search-failed`,tone:`danger`,children:_.error});let{results:y,truncated:b}=_.res,x=y.reduce((e,t)=>e+t.hits.length,0),S=e=>{r.openFile(e),_x(r.setSidebar)};return(0,B.jsxs)(`div`,{"data-testid":`file-search-results`,children:[(0,B.jsxs)(`div`,{className:`px-3 py-1.5 text-[11px] text-fg-faint`,"data-testid":`file-search-summary`,children:[y.length===0?`Nothing in ${g??`this folder`} matches.`:`${y.length}${b?`+`:``} ${y.length===1?`file`:`files`}${x>0?`, ${x} ${x===1?`line`:`lines`}`:``} in ${g??`this folder`}`,b?` — the search stopped early; narrow the phrase to see the rest.`:``]}),y.map(e=>{let n=DF(e.path)||e.path,r=e.path.length>n.length?e.path.slice(0,e.path.length-n.length-1):``;return(0,B.jsxs)(`div`,{className:`mb-1`,"data-testid":`file-search-result-${e.path}`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-xs hover:bg-surface-2`,title:e.path,onClick:()=>S(e.path),"data-testid":`file-search-file`,children:[(0,B.jsx)(H.File,{className:`w-3.5 h-3.5 shrink-0 text-fg-faint`}),(0,B.jsx)(`span`,{className:`shrink-0 font-medium text-fg`,children:e.nameMatch?(0,B.jsx)(t9,{text:n,query:c,options:t}):n}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-fg-faint`,children:r}),e.hits.length>0?(0,B.jsxs)(`span`,{className:`shrink-0 rounded-full bg-surface-3 px-1.5 text-[10px] font-semibold text-fg-muted`,children:[e.hits.length,e.moreHits?`+`:``]}):null]}),e.hits.map(n=>(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full gap-2 rounded px-2 py-0.5 pl-7 text-left font-mono text-[11px] hover:bg-surface-2`,onClick:()=>S(e.path),"data-testid":`file-search-hit`,children:[(0,B.jsx)(`span`,{className:`shrink-0 text-fg-faint`,children:n.line}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg-muted`,children:(0,B.jsx)(t9,{text:n.text,query:c,options:t})})]},n.line))]},e.path)})]})}function r9(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function zMe(e,t,n){let r=r9(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 i9(e,t){let n=t.trim().toLowerCase();return n===``||e.toLowerCase().includes(n)}var BMe=3e4,a9=`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`,o9=`flex items-center gap-1 px-2 pb-0.5 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,VMe=`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`,s9=`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 HMe({onOpenSearch:e}={}){let{state:t,actions:n}=V(),r=t.ui.sidebarPinnedOverride??t.prefs.sidebarPinned,[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)(!1),c=lz(),[l,u]=(0,v.useState)(null),d=(0,v.useCallback)(()=>u(null),[]),f=JMe(),p=mz(),m=r9(p),h=t.prefs.sidebarView,g=t.prefs.pinned,_=e=>a(t=>({...t,[e]:t[e]!==!0})),y=e=>i[e]===!0,b=t.prefs.collapsedProjects,x=e=>b.includes(e),S=e=>{let t=x(e)?b.filter(t=>t!==e):[...b,e];n.savePrefs({collapsedProjects:t})},C=(0,v.useCallback)(e=>{let r=t.remote.tabs[e]?.hostId??t.remote.sessionOwners[e]??null;r?n.openRemoteSession(r,e):n.selectSession(e),window.innerWidth<768&&n.setSidebar(!1)},[n,t.remote.tabs,t.remote.sessionOwners]),w=(0,v.useCallback)(e=>{n.openPage({kind:`project`,projectId:e}),window.innerWidth<768&&n.setSidebar(!1)},[n]),[T,E]=(0,v.useState)(``),D=yx(T)!==``,O=(0,v.useMemo)(()=>new Map(t.vaultProjects.map(e=>[e.id,e.name])),[t.vaultProjects]),k=(0,v.useCallback)(e=>bx(e,T,e.projectId?O.get(e.projectId):null),[T,O]),A=(0,v.useMemo)(()=>{let e=t.sessions.filter(e=>!t.remote.tabs[e.id]);return D?e.filter(k):e},[t.sessions,t.remote.tabs,D,k]),j=(0,v.useMemo)(()=>{let e=new Map(A.map(e=>[e.id,e]));for(let n of Object.values(t.remote.sessions))for(let t of n??[])e.has(t.id)||e.set(t.id,t);let n=[];for(let r of g)if(r.kind===`chat`){let i=e.get(r.id)??t.pinnedRows[r.id];i&&(!D||k(i))&&n.push({kind:`chat`,session:i})}else{let e=t.vaultProjects.find(e=>e.id===r.id);if(!e||!i9(e.name,T))continue;let i=t.sessions.filter(t=>t.projectId===e.id);n.push({kind:`project`,project:e,sessions:i})}return n},[g,A,D,T,k,t.pinnedRows,t.remote.sessions,t.vaultProjects,t.sessions]),ee=(0,v.useMemo)(()=>new Set(g.filter(e=>e.kind===`chat`).map(e=>e.id)),[g]),M=(0,v.useMemo)(()=>h===`recent`?zMe(A,ee,m):null,[h,A,ee,m]),te=(0,v.useMemo)(()=>{if(h!==`projects`)return[];let e=new Map;for(let n of t.vaultProjects)e.set(n.id,{name:n.name,sessions:[]});let n=[];for(let t of A){let r=t.projectId?e.get(t.projectId):void 0;r?r.sessions.push(t):n.push(t)}let r=[...e.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)}),D?r.filter(e=>e.sessions.length>0||e.projectId!==null&&i9(e.name,T)):r},[h,t.vaultProjects,A,D,T]),ne=e=>{n.savePrefs({collapsedProjects:e?te.map(e=>e.key):[]})},N=(0,v.useMemo)(()=>t.remote.hosts.filter(e=>!e.isSelf),[t.remote.hosts]),P=()=>{let e=y(`remote`);_(`remote`),e&&n.refreshHosts()},re=!y(`remote`),ie=(0,v.useRef)(!1);ie.current=t.remote.loading;let ae=(0,v.useRef)(i);ae.current=i;let oe=(0,v.useRef)(N);oe.current=N,(0,v.useEffect)(()=>{if(!re)return;let e=()=>{if(!(document.visibilityState===`hidden`||ie.current)){n.refreshHosts();for(let e of oe.current)e.online&&ae.current[`host:${e.hostId}`]===!1&&n.refreshHostSessions(e.hostId)}},t=setInterval(e,BMe);return window.addEventListener(`focus`,e),()=>{clearInterval(t),window.removeEventListener(`focus`,e)}},[re,n]);let se=A.length,F=e=>{e!==h&&n.savePrefs({sidebarView:e})},ce=t.page,le={onOpen:C,onMenu:c.openMenu,clock:p},ue=!t.sessionsLoading&&se===0&&!t.sessionsError?(0,B.jsx)(`div`,{className:`px-3 py-3 text-center text-xs text-fg-faint`,"data-testid":`sessions-empty`,children:D?`No chats match the filter.`:`No sessions yet — press + to start one.`}):null;return(0,B.jsxs)(`nav`,{className:`flex h-full w-full flex-col bg-surface`,"aria-label":`Sessions`,children:[(0,B.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,B.jsxs)(`div`,{className:`relative min-w-[8rem] flex-1`,children:[(0,B.jsx)(H.Filter,{className:`pointer-events-none absolute left-2 top-2 w-3.5 h-3.5 text-fg-faint`}),(0,B.jsx)(`input`,{"aria-label":`Filter chats by name`,className:z(pC,`pl-7`,T!==``&&`pr-7`),placeholder:`Filter chats`,value:T,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Escape`&&T!==``&&(e.preventDefault(),e.stopPropagation(),E(``))},"data-testid":`sessions-filter`}),T===``?null:(0,B.jsx)(lC,{label:`Clear the filter`,className:`absolute right-0.5 top-0.5 p-1`,onClick:()=>E(``),"data-testid":`sessions-filter-clear`,children:(0,B.jsx)(H.X,{className:`w-3.5 h-3.5`})})]}),(0,B.jsx)(lC,{label:`Search chats and files (Ctrl+K)`,onClick:()=>{n.showLeftSection(`search`),e?.()},"data-testid":`open-search`,children:(0,B.jsx)(H.Search,{})}),(0,B.jsx)(lC,{label:`Refresh sessions`,onClick:()=>{n.refreshSessions(),n.refreshHosts()},children:(0,B.jsx)(H.Refresh,{className:t.sessionsLoading?`spin`:``})}),t.account?.loggedIn?(0,B.jsx)(lC,{label:`Import chats from your other coding agents`,onClick:()=>n.openDialog(`import-claude`),"data-testid":`open-import-claude`,children:(0,B.jsx)(H.Download,{})}):null,t.account?.loggedIn?(0,B.jsx)(lC,{label:`Export my chats`,onClick:()=>n.openDialog(`export-chats`),"data-testid":`open-export-chats`,children:(0,B.jsx)(H.Upload,{})}):null,t.currentSessionId&&t.remote.tabs[t.currentSessionId]?null:(0,B.jsx)(lC,{label:`Clean up chat folders — free the space of deleted chats`,onClick:()=>n.openDialog(`workspace-cleanup`),"data-testid":`open-workspace-cleanup`,children:(0,B.jsx)(H.Trash,{})}),t.account?.loggedIn&&!(t.currentSessionId&&t.remote.tabs[t.currentSessionId])?(0,B.jsx)(lC,{label:`Connect an AI tool — let it read your chats on this PC`,onClick:()=>n.openDialog(`connect-ai-tool`),"data-testid":`open-connect-ai-tool`,children:(0,B.jsx)(H.Plug,{})}):null,h===`projects`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(lC,{label:`Collapse all projects`,onClick:()=>ne(!0),"data-testid":`projects-collapse-all`,children:(0,B.jsx)(H.CollapseAll,{})}),(0,B.jsx)(lC,{label:`Expand all projects`,onClick:()=>ne(!1),"data-testid":`projects-expand-all`,children:(0,B.jsx)(H.ExpandAll,{})})]}):null,(0,B.jsx)(lC,{label:`Conversations — what your chats send each other`,onClick:()=>n.openConversations(),"data-testid":`open-conversations`,children:(0,B.jsx)(H.Chats,{})}),(0,B.jsx)(lC,{label:`What your chats are about — each chat’s about and what it cost`,onClick:()=>n.openChatAbouts(),"data-testid":`open-chat-abouts`,children:(0,B.jsx)(H.Info,{})}),(0,B.jsx)(lC,{label:`Project manager — review chats and suggest what to send each next`,onClick:()=>n.openProjectManager(),"data-testid":`open-project-manager`,children:(0,B.jsx)(H.Clipboard,{})}),(0,B.jsx)(lC,{label:r?`Hide the session list — it slides in when the pointer reaches the left edge`:`Pin the session list beside the chat`,className:z(`hidden md:inline-flex`,r?`text-accent`:`text-fg-muted`),"aria-pressed":r,onClick:()=>n.toggleSidebarPinned(),"data-testid":`sidebar-pin`,children:(0,B.jsx)(H.Pin,{})})]}),(0,B.jsx)(UMe,{clock:p}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1 pb-2`,children:(0,B.jsxs)(B.Fragment,{children:[j.length>0?(0,B.jsxs)(`div`,{className:`mb-1`,"data-testid":`section-pinned`,children:[(0,B.jsx)(`div`,{className:o9,children:(0,B.jsx)(`span`,{children:`Pinned`})}),j.map(e=>e.kind===`chat`?(0,B.jsx)(sz,{session:e.session,active:e.session.id===t.currentSessionId&&ce===null,link:t.sessionLinks[e.session.id]??null,menuOpen:c.menuFor===e.session.id,busy:c.sessionOps[e.session.id]??null,kindIcon:!0,testIdPrefix:`pinned-session`,...le},`chat:${e.session.id}`):(0,B.jsx)(GMe,{project:e.project,sessions:e.sessions,active:ce?.kind===`project`&&ce.projectId===e.project.id,onOpen:w,onMenu:(t,n)=>u({target:{projectId:e.project.id,foldKey:null},at:t,el:n})},`project:${e.project.id}`))]}):null,(0,B.jsxs)(`div`,{className:`mb-1`,"data-testid":`sessions-local`,children:[t.sessionsError?(0,B.jsx)(`div`,{className:`px-2 py-2 text-xs text-danger`,children:t.sessionsError}):null,M?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{"data-testid":`section-today`,children:[(0,B.jsxs)(`div`,{className:o9,children:[(0,B.jsx)(`span`,{children:`Today`}),(0,B.jsx)(`span`,{className:`font-normal normal-case`,children:M.today.length||``}),(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsx)(c9,{view:h,onChange:F})]}),ue??(M.today.length===0?(0,B.jsx)(`div`,{className:`px-3 py-1 text-xs text-fg-faint`,"data-testid":`today-empty`,children:D?`Nothing from today matches.`:`Nothing yet today.`}):M.today.map(e=>(0,B.jsx)(sz,{session:e,active:e.id===t.currentSessionId&&ce===null,link:t.sessionLinks[e.id]??null,menuOpen:c.menuFor===e.id,busy:c.sessionOps[e.id]??null,projectName:e.projectId?O.get(e.projectId)??null:null,...le},e.id)))]}),M.older.length>0?(0,B.jsxs)(`div`,{"data-testid":`section-older`,children:[(0,B.jsxs)(`div`,{className:o9,children:[(0,B.jsx)(`span`,{children:`Older`}),(0,B.jsx)(`span`,{className:`font-normal normal-case`,children:M.older.length})]}),M.older.map(e=>(0,B.jsx)(sz,{session:e,active:e.id===t.currentSessionId&&ce===null,link:t.sessionLinks[e.id]??null,menuOpen:c.menuFor===e.id,busy:c.sessionOps[e.id]??null,projectName:e.projectId?O.get(e.projectId)??null:null,...le},e.id))]}):null]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:o9,"data-testid":`section-by-project`,children:[(0,B.jsx)(`span`,{children:`By project`}),(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsx)(c9,{view:h,onChange:F})]}),ue,te.map(e=>{let r=`local:${e.key}`;return(0,B.jsxs)(`div`,{className:`mb-1 pl-2`,"data-testid":`project-group-${e.key}`,children:[(0,B.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,B.jsx)(YMe,{group:e,collapsed:x(e.key),onToggle:()=>S(e.key),onMenu:(t,n)=>u({target:{projectId:e.projectId,foldKey:e.key},at:t,el:n}),menuOpen:l?.target.foldKey===e.key}),e.projectId?(0,B.jsxs)(`div`,{className:`absolute right-1 hidden items-center rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:[(0,B.jsx)(lC,{label:`Settings of ${e.name}`,className:`p-1`,"data-testid":`project-settings-${e.key}`,onClick:t=>{t.stopPropagation(),n.openProjectSettings(e.projectId)},children:(0,B.jsx)(H.Settings,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(lC,{label:`New chat in ${e.name}`,className:`p-1`,"data-testid":`project-new-chat-${e.key}`,onClick:t=>{t.stopPropagation(),n.newTab({projectId:e.projectId})},children:(0,B.jsx)(H.Plus,{className:`w-3.5 h-3.5`})})]}):null]}),x(e.key)?null:e.sessions.map(e=>(0,B.jsx)(sz,{session:e,active:e.id===t.currentSessionId&&ce===null,link:t.sessionLinks[e.id]??null,menuOpen:c.menuFor===e.id,busy:c.sessionOps[e.id]??null,...le},e.id))]},r)})]})]}),(0,B.jsxs)(`div`,{className:`mb-1`,"data-testid":`sessions-remote`,children:[(0,B.jsxs)(`button`,{type:`button`,className:a9,onClick:P,"aria-expanded":!y(`remote`),children:[(0,B.jsx)(H.Chevron,{open:!y(`remote`),className:`w-3 h-3`}),(0,B.jsx)(H.Globe,{className:`w-3 h-3`}),(0,B.jsx)(`span`,{className:`truncate`,children:`Remote`}),(0,B.jsx)(`span`,{className:`ml-auto font-normal`,children:N.length})]}),y(`remote`)?null:(0,B.jsxs)(B.Fragment,{children:[!t.remote.supported||t.remote.reason===`logged_out`?(0,B.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,B.jsx)(`div`,{className:`px-3 py-3 text-xs text-fg-faint`,children:t.remote.loading?`Looking for your other devices…`:`No other devices yet.`}):null,N.map(e=>(0,B.jsx)(KMe,{host:e,filter:D?k:null,collapsed:y(`host:${e.hostId}`)||i[`host:${e.hostId}`]===void 0,onToggle:()=>{let t=`host:${e.hostId}`,r=i[t]===void 0||i[t]===!0;a(e=>({...e,[t]:!r})),r&&n.refreshHostSessions(e.hostId)}},e.hostId))]})]})]})}),(0,B.jsx)(`div`,{className:`shrink-0 border-t border-border px-3 py-2 text-[11px] text-fg-faint`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsxs)(`button`,{type:`button`,"data-testid":`app-version`,title:`What's new in this version`,className:`truncate hover:text-fg hover:underline`,onClick:()=>n.openDialog(`whats-new`),children:[`OonaCode Desktop v`,f]}),(0,B.jsx)(lC,{label:`Lock this device — vault and sessions`,className:`p-1`,"data-testid":`lock-device`,onClick:()=>s(!0),children:(0,B.jsx)(H.Lock,{className:`h-3.5 w-3.5`})})]})}),(0,B.jsx)(ow,{open:l!==null,at:l?.at??{x:0,y:0},anchorEl:l?.el??null,label:`Project actions`,testId:`project-context-menu`,onClose:d,items:l?uz({projectId:l.target.projectId,pinned:l.target.projectId!==null&&uu(g,`project`,l.target.projectId),fold:l.target.foldKey===null?null:{collapsed:x(l.target.foldKey),onToggle:()=>S(l.target.foldKey)},actions:n}):[]}),c.element,(0,B.jsx)(bC,{open:o,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 n.lockDevice(),onClose:()=>s(!1)})]})}function UMe({clock:e}){let{state:t,actions:n}=V(),[r,i]=(0,v.useState)(null),a=(0,v.useCallback)(()=>i(null),[]),o=t.page,s=()=>{window.innerWidth<768&&n.setSidebar(!1)};return(0,B.jsxs)(`div`,{className:`shrink-0 border-b border-border px-1 py-1`,"data-testid":`sidebar-nav`,children:[(0,B.jsxs)(`div`,{className:`flex items-center rounded-md hover:bg-surface-2`,children:[(0,B.jsxs)(`button`,{type:`button`,className:z(s9,`flex-1 hover:bg-transparent`),title:`New chat (Ctrl+T)`,onClick:()=>{n.newTab(),s()},"data-testid":`sidebar-new`,children:[(0,B.jsx)(H.Edit,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,B.jsx)(`span`,{children:`New`})]}),(0,B.jsx)(lC,{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,B.jsx)(H.Chevron,{open:!0,className:`w-3.5 h-3.5`})})]}),(0,B.jsxs)(`button`,{type:`button`,className:z(s9,`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,B.jsx)(H.Project,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,B.jsx)(`span`,{children:`Projects`})]}),(0,B.jsx)(WMe,{clock:e,active:o?.kind===`scheduled`,onOpen:()=>{n.openPage({kind:`scheduled`}),s()}}),(0,B.jsx)(ow,{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,B.jsx)(H.Chats,{className:`w-3.5 h-3.5`}),onSelect:()=>{n.newTab(),s()},testId:`sidebar-new-chat`},{key:`project`,label:`New project…`,icon:(0,B.jsx)(H.Project,{className:`w-3.5 h-3.5`}),onSelect:()=>n.openNewProject(),testId:`sidebar-new-project`}]})]})}function WMe({clock:e,active:t,onOpen:n}){let{tasks:r}=pz(),i=(0,v.useMemo)(()=>r?kme(r,e):null,[r,e]);return(0,B.jsxs)(`button`,{type:`button`,className:z(s9,`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,B.jsx)(H.Clock,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,B.jsx)(`span`,{className:`flex-1`,children:`Scheduled`}),i?(0,B.jsx)(`span`,{className:z(`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 c9({view:e,onChange:t}){let[n,r]=(0,v.useState)(null),i=(0,v.useCallback)(()=>r(null),[]),a=e=>e?(0,B.jsx)(H.Check,{className:`w-3.5 h-3.5 text-accent`}):(0,B.jsx)(`span`,{className:`w-3.5`});return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(lC,{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,B.jsx)(H.Sliders,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(ow,{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 GMe({project:e,sessions:t,active:n,onOpen:r,onMenu:i}){let a=(0,v.useRef)(null),o=e.sessionCount??t.length;return(0,B.jsxs)(`div`,{ref:a,className:z(`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,B.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,B.jsx)(H.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.name}),(0,B.jsx)(rz,{sessions:t,testId:`pinned-project-busy-${e.id}`}),(0,B.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,B.jsx)(lC,{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,B.jsx)(H.More,{className:`w-3.5 h-3.5`})})]})}function KMe({host:e,collapsed:t,onToggle:n,filter:r=null}){let{state:i,actions:a}=V(),o=e.label||e.hostName,s=i.remote.sessions[e.hostId],c=(0,v.useMemo)(()=>{let t=s??[],n=new Set(t.map(e=>e.id)),r=[];for(let[t,a]of Object.entries(i.remote.tabs)){if(a.hostId!==e.hostId||n.has(t))continue;let o=i.transcripts[t]?.session??i.sessions.find(e=>e.id===t)??null;if(o){r.push(o),n.add(t);continue}let s=i.drafts[t];if(s){let e=new Date(s.createdAt).toISOString();r.push({id:s.id,projectKey:`draft`,cwd:s.projectDir??``,projectDir:s.projectDir??null,projectId:s.projectId??null,title:s.title??`New chat`,firstPrompt:null,lastPrompt:null,providerId:s.providerId??null,variantId:s.variantId??null,model:s.model??null,permissionMode:s.permissionMode??`default`,posture:s.posture??`build`,...s.effort?{effort:s.effort}:{},status:`idle`,createdAt:e,updatedAt:e,mtime:s.createdAt,entryCount:0,totalCostUsd:0,inputTokens:0,outputTokens:0,poolCredits:0,hasSubagents:!1,forkedFrom:null,engineSince:null,finishedUnseen:null}),n.add(t)}}if(s!==void 0||r.length!==0)return r.length>0?[...r,...t]:s},[s,i.remote.tabs,i.transcripts,i.sessions,i.drafts,e.hostId]),l=r&&c?c.filter(r):c,u=i.remote.unreachable[e.hostId],d=u?ah(u.reason,o,u.detail):null,[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(null),x=(0,v.useCallback)(()=>b(null),[]),S=e.remoteAccessOff===!0;return(0,v.useEffect)(()=>{if(t||S||!e.online||!u)return;let n=setTimeout(()=>{a.refreshHostSessions(e.hostId)},3e3);return()=>clearTimeout(n)},[t,S,e.online,u,e.hostId,a]),(0,B.jsxs)(`div`,{className:`mb-1 pl-2`,"data-testid":`remote-host-${e.hostId}`,children:[(0,B.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,B.jsxs)(`button`,{type:`button`,className:a9,onClick:n,"aria-expanded":!t,title:e.online?`${o} — online`:`${o} — offline: its chats can be read while it is online`,children:[(0,B.jsx)(H.Chevron,{open:!t,className:`w-3 h-3`}),(0,B.jsx)(`span`,{className:z(`inline-block h-2 w-2 shrink-0 rounded-full`,e.online?`bg-ok`:`bg-fg-faint`),"aria-label":e.online?`online`:`offline`}),(0,B.jsx)(`span`,{className:`truncate normal-case`,children:o}),S?(0,B.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,B.jsx)(`span`,{className:`ml-auto font-normal`,children:!S&&l?l.length:``})]}),(0,B.jsxs)(`div`,{className:`absolute right-1 hidden items-center rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:[(0,B.jsx)(lC,{label:S?ih(o):e.online?`New chat on ${o}`:`${o} is offline — a new chat has to start on a PC that is awake`,className:`p-1`,disabled:!e.online||S,"data-testid":`remote-new-chat-${e.hostId}`,onClick:()=>void a.newRemoteTab(e.hostId),children:(0,B.jsx)(H.Plus,{className:`w-3 h-3`})}),(0,B.jsx)(lC,{label:`Unlock this device`,className:`p-1`,disabled:S,"data-testid":`remote-unlock-${e.hostId}`,onClick:()=>p(`unlock`),children:(0,B.jsx)(H.Lock,{className:`w-3 h-3`})}),(0,B.jsx)(lC,{label:`Rename device`,className:`p-1`,onClick:()=>p(`rename`),children:(0,B.jsx)(H.Edit,{className:`w-3 h-3`})})]}),(0,B.jsx)(SC,{open:f===`unlock`,title:`Unlock "${o}" 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 a.remoteUnlockHost(e.hostId,t),onClose:()=>p(null)}),(0,B.jsx)(SC,{open:f===`rename`,title:`Rename device`,label:`Device name`,initialValue:o,onSubmit:t=>{t!==o&&a.renameHost(e.hostId,t)},onClose:()=>p(null)})]}),!t&&S?(0,B.jsx)(`div`,{className:`px-3 py-2 text-xs text-warn`,"data-testid":`remote-off-note-${e.hostId}`,children:ih(o)}):t?null:l===void 0?(0,B.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-faint`,children:`Loading…`}):l.length===0&&d?(0,B.jsx)(`div`,{className:`px-3 py-2 text-xs text-warn`,"data-testid":`remote-unreachable-${e.hostId}`,children:d}):l.length===0?(0,B.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-faint`,children:r&&c&&c.length>0?`No chats here match the filter.`:`No sessions on this device.`}):l.map(t=>(0,B.jsx)(qMe,{host:e,session:t,active:t.id===i.currentSessionId&&i.page===null,menuOpen:y?.session.id===t.id,onMenu:(e,t,n)=>b({session:e,at:t,el:n}),onRename:()=>h(t),onConfirmDelete:()=>_(t)},t.id)),(0,B.jsx)(ow,{open:y!==null,at:y?.at??{x:0,y:0},anchorEl:y?.el??null,label:`Chat actions`,testId:`remote-session-context-menu`,onClose:x,items:y?cz({session:y.session,link:null,pinned:uu(i.prefs.pinned,`chat`,y.session.id),actions:{...a,selectSession:t=>{t?a.openRemoteSession(e.hostId,t):a.selectSession(null)}},onSync:()=>void 0,onRename:()=>h(y.session),onDelete:()=>_(y.session)}):[]}),(0,B.jsx)(SC,{open:m!==null,title:`Rename chat`,label:`Chat title (leave empty to reset)`,initialValue:m?m.title??Gv(m):``,onSubmit:t=>{m&&(i.drafts[m.id]?a.renameTab(m.id,t):a.renameRemoteSession(e.hostId,m.id,t))},onClose:()=>h(null)}),(0,B.jsx)(bC,{open:g!==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:()=>{g&&(i.drafts[g.id]?a.closeTab(g.id):a.deleteRemoteSession(e.hostId,g.id))},onClose:()=>_(null)})]})}function qMe({host:e,session:t,active:n,menuOpen:r=!1,onMenu:i,onRename:a,onConfirmDelete:o}){let{actions:s}=V(),c=Gv(t),l=(0,v.useRef)(null),u=(0,v.useRef)(null),[d,f]=(0,v.useState)(null),p=(0,v.useCallback)(()=>{u.current!==null&&(clearTimeout(u.current),u.current=null),f(null)},[]),m=(0,v.useRef)(r);return m.current=r,(0,v.useEffect)(()=>{r&&p()},[r,p]),(0,v.useEffect)(()=>{if(d===null)return;let e=e=>{aw(e.target,l.current)&&p()};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[d,p]),(0,v.useEffect)(()=>()=>{u.current!==null&&clearTimeout(u.current)},[]),(0,B.jsxs)(`div`,{ref:l,className:z(`group relative flex items-center rounded-md`,n?`bg-accent-soft`:`hover:bg-surface-2`),onMouseEnter:()=>{u.current!==null&&clearTimeout(u.current),!m.current&&(u.current=setTimeout(()=>{u.current=null,l.current&&!m.current&&f(l.current.getBoundingClientRect())},450))},onMouseLeave:p,onClick:p,onContextMenu:e=>{e.preventDefault(),p(),i(t,{x:e.clientX,y:e.clientY},l.current)},children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{s.openRemoteSession(e.hostId,t.id),window.innerWidth<768&&s.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,B.jsx)(nz,{status:t.status}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:z(`truncate text-sm`,n?`font-medium`:``),children:c}),(0,B.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[Lv(t.updatedAt),t.model?` · ${t.model}`:``,e.online?``:` · read-only`]})]})]}),(0,B.jsxs)(`div`,{className:`mr-1 hidden items-center gap-0.5 rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:[(0,B.jsx)(lC,{label:e.online?`Rename this chat`:`That PC is asleep — a chat can only be renamed while the PC that holds it is online`,className:`p-1 disabled:opacity-40`,disabled:!e.online,"data-testid":`remote-session-rename-${t.id}`,onClick:()=>{a()},children:(0,B.jsx)(H.Edit,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(lC,{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:()=>{o()},children:(0,B.jsx)(H.Trash,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(lC,{label:`Chat actions`,className:`p-1`,"data-testid":`remote-session-menu-${t.id}`,onClick:e=>{e.stopPropagation(),p();let n=e.currentTarget.getBoundingClientRect();i(t,{x:n.left,y:n.bottom+2},l.current)},children:(0,B.jsx)(H.More,{className:`w-3.5 h-3.5`})})]}),d===null?null:(0,B.jsx)(az,{session:t,anchor:d})]})}function JMe(){let{state:e}=V(),t=typeof window<`u`?window.oonacode:void 0;return cS(t?.appVersion??e.bundleAppVersion??e.connection.appVersion??e.info?.appVersion??`0.0.0`,sS({bridge:t,info:e.info}))}function YMe({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=>{aw(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,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{ref:a,type:`button`,className:VMe,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,B.jsx)(H.Chevron,{open:!t,className:`w-3 h-3 shrink-0`}),(0,B.jsx)(H.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name}),(0,B.jsx)(rz,{sessions:e.sessions,testId:`project-busy-${e.key}`}),(0,B.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,B.jsx)(XMe,{group:e,anchor:s})]})}function XMe({group:e,anchor:t}){let{state:n}=V(),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,rC.createPortal)((0,B.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,B.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5`,children:[(0,B.jsx)(H.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,B.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.name})]}),(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(iz,{label:`Chats`,value:String(e.sessions.length)}),(0,B.jsx)(iz,{label:`Working now`,value:i>0?String(i):null}),(0,B.jsx)(iz,{label:`Last activity`,value:a?Lv(a):null}),(0,B.jsx)(iz,{label:o.length>1?`Folders`:`Folder`,value:o.length>1?`${o.length} folders`:o[0]??null})]}),e.projectId?(0,B.jsxs)(`div`,{className:`mt-2 border-t border-border pt-2`,children:[(0,B.jsx)(`div`,{className:`mb-1 text-fg-faint`,children:`Standing instructions`}),s?(0,B.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,B.jsx)(`div`,{className:`text-fg-faint`,children:`None — chats here start with nothing extra.`})]}):(0,B.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 text-fg-faint`,children:`Chats filed under no project.`})]}),document.body)}var l9=`(min-width: 768px)`;function u9(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(l9).matches}function ZMe(){let[e,t]=(0,v.useState)(u9);return(0,v.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(l9),n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function QMe(e){try{return!!e?.matches(`:hover`)}catch{return!1}}function $Me(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 eNe({hidden:e,collapsed:t=!1,peekAsk:n=0,children:r}){let{state:i,actions:a}=V(),o=i.ui.sidebarPinnedOverride??i.prefs.sidebarPinned,s=i.ui.sidebarOpen,[c,l]=(0,v.useState)(null),u=c??i.prefs.sidebarWidth,[d,f]=(0,v.useState)(!1),p=ZMe(),m=(0,v.useRef)(null),h=(0,v.useRef)(null),g=(0,v.useCallback)(()=>{h.current!==null&&(clearTimeout(h.current),h.current=null)},[]),_=(0,v.useCallback)(()=>{g(),h.current=setTimeout(function e(){if($Me(m.current)){h.current=setTimeout(e,350);return}h.current=null,!QMe(m.current)&&f(!1)},350)},[g]);(0,v.useEffect)(()=>g,[g]),(0,v.useEffect)(()=>{f(!1),g()},[o,g]);let y=(0,v.useRef)(n);(0,v.useEffect)(()=>{n!==y.current&&(y.current=n,!(e||o||!u9())&&(f(!0),_()))},[n,e,o,_]),(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(u9()){if(o)return;f(!0),_()}else s||a.setSidebar(!0)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,o,s,_,a]);let b=e=>{e.preventDefault();let t=e.clientX,n=u,r=n,o=e=>{r=Zl(n+(e.clientX-t)),l(r)},s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),document.body.style.cursor=``,document.body.style.userSelect=``,l(null),r!==i.prefs.sidebarWidth&&a.savePrefs({sidebarWidth:r})};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},x=o||d;return(0,B.jsxs)(B.Fragment,{children:[!o&&!d&&!e&&!t?(0,B.jsx)(`div`,{className:`absolute inset-y-0 left-0 z-40 hidden w-2 md:block`,onMouseEnter:()=>{f(!0),_()},"aria-hidden":!0,"data-testid":`sidebar-hover-edge`}):null,(0,B.jsxs)(`aside`,{ref:m,"data-chrome":`sidebar`,"data-font-scope":`sidebar`,hidden:e,inert:!e&&(p?!x||t:!s),"data-testid":`sidebar-frame`,"data-state":t?`collapsed`:o?`docked`:d?`peek`:`hidden`,style:{"--sidebar-w":`${u}px`},onMouseEnter:o?void 0:g,onMouseLeave:o?void 0:_,className:z(`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]`,s?`translate-x-0`:`-translate-x-full`,o?`md:relative md:z-auto md:translate-x-0`:z(`md:z-40 md:shadow-2xl`,x?`md:translate-x-0`:`md:-translate-x-full`),t&&`md:hidden`),children:[r,(0,B.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:b,onDoubleClick:()=>void a.savePrefs({sidebarWidth:288}),"data-testid":`sidebar-resize`})]})]})}var d9=[{id:`sessions`,title:`Sessions`,label:`Sessions`,icon:H.Chats},{id:`search`,title:`Search`,label:`Search chats and files (Ctrl+K)`,icon:H.Search},{id:`files`,title:`Files`,label:`Files of this chat`,icon:H.Folder}];function tNe({hidden:e=!1}){let{state:t,actions:n}=V(),r=t.prefs.leftPanelSection,i=t.prefs.leftPanelOpen,a=t.ui.sidebarPinnedOverride??t.prefs.sidebarPinned,[o,s]=(0,v.useState)(0),[c,l]=(0,v.useState)(0),[u,d]=(0,v.useState)(()=>new Set([r]));(0,v.useEffect)(()=>{d(e=>e.has(r)?e:new Set([...e,r]))},[r]),(0,v.useEffect)(()=>{if(e)return;let t=e=>{!(e.ctrlKey||e.metaKey)||e.shiftKey||e.altKey||(e.key===`k`||e.key===`K`)&&window.oonacode?.host!==`vscode`&&(e.preventDefault(),n.showLeftSection(`search`),l(e=>e+1))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,n]);let f=e=>{let t=vx({section:r,open:i},e,a);(t.section!==r||t.open!==i)&&n.savePrefs(hx(t.section,t.open)),a||s(e=>e+1),t.open&&e===`search`&&l(e=>e+1)},p=d9.map(e=>({id:e.id,label:e.label,icon:e.icon,active:i&&e.id===r})),m=e=>e===`sessions`?(0,B.jsx)(HMe,{onOpenSearch:()=>l(e=>e+1)}):e===`search`?(0,B.jsx)(IMe,{active:r===`search`,focusAsk:c}):(0,B.jsx)(NMe,{});return(0,B.jsxs)(B.Fragment,{children:[e?null:(0,B.jsx)(`div`,{className:`hidden border-r border-border md:flex`,children:(0,B.jsx)(P7,{items:p,testId:`activity-bar-left`,label:`Side bar`,onPick:f})}),(0,B.jsx)(`div`,{className:`contents md:relative md:flex md:shrink-0`,children:(0,B.jsx)(eNe,{hidden:e,collapsed:!i,peekAsk:o,children:(0,B.jsxs)(`div`,{className:`flex h-full w-full flex-col`,"data-testid":`left-dock`,"data-section":r,children:[(0,B.jsx)(nNe,{section:r,onPick:e=>{n.showLeftSection(e),e===`search`&&l(e=>e+1)}}),Ll.filter(e=>u.has(e)||e===r).map(e=>(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,hidden:e!==r,"data-testid":`left-section-${e}`,children:m(e)},e))]})})})]})}function nNe({section:e,onPick:t}){return(0,B.jsx)(`div`,{className:`flex shrink-0 gap-1 border-b border-border p-1 md:hidden`,role:`tablist`,"aria-label":`Side bar`,children:d9.map(n=>(0,B.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n.id===e,onClick:()=>t(n.id),className:z(`flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-xs`,n.id===e?`bg-surface-2 font-medium text-fg`:`text-fg-muted hover:bg-surface-2 hover:text-fg`),"data-testid":`left-tab-${n.id}`,children:[(0,B.jsx)(n.icon,{className:`w-3.5 h-3.5`}),n.title]},n.id))})}var f9={autosaveFiles:{hint:`Save a file as soon as you change it. Off by default.`,details:[`Applies to text files opened in this window’s file viewer.`,`While off, a changed file shows * on its tab and Ctrl+S saves it.`,`A file opened from another PC stays read-only.`]},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: the operating system’s app mode (Windows: Settings → Personalisation → Colours → “Choose your default app mode”).`,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 chat on screen is still kept whole, and still searched.`,`Smaller is faster on long agentic chats; larger keeps more on screen.`]},keptTranscripts:{hint:`How many open tabs you are not looking at keep their whole chat in this window’s memory. The others are read again from this PC when you show them.`,details:[`Chats on screen, chats that are working (a turn, a permission card) and chats on another PC are always kept.`,`A closed tab’s chat is let go of at once.`,`Each long chat costs tens to hundreds of MB here; 0 keeps only what is on screen, more makes switching back instant for more tabs.`,`Applies to this window only: the desktop app, a browser tab and the VS Code panel each keep their own.`]},engineIdleMinutes:{hint:`How long a chat’s engine stays open after its last turn. Its next message starts it again and resumes the chat.`,details:[`An open engine answers the next message at once and keeps the provider’s prompt cache warm; it holds the chat’s whole context in memory (hundreds of MB for a long chat).`,`An agy chat waits three times as long, and a chat too long for its model’s window six times: starting those again is slow and re-reads the most.`,`Background work the chat left running (a Monitor, a background command or agent) keeps its engine open up to 12 hours.`]},maxIdleEngines:{hint:`At most this many engines stay open with no turn; when one more goes quiet, the one quiet longest closes.`,details:[`Bounds the memory of chats you visited in the last hour, not the ones you are working in: an engine with a turn is never closed.`,`Never closes an engine with background work, or an agy engine (they keep their own longer window).`]},browserIdleMinutes:{hint:`How long a chat’s Oonak Browser stays open when nobody uses it. Its profile — logins, cookies — is kept, and the next browser action opens it again.`,details:[`Used means the agent’s browser actions, or you moving between pages in it (a sign-in, a link).`,`Never closed while a turn of its chat runs. A browser you opened from Session Info stays until you close it.`]},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.`]},telegram:{hint:`Let the OonaCode Telegram bot list, read, continue and delete this PC’s chats. Off by default.`,details:[`The bot reaches this PC through OonaCode’s server, and what you send and receive in Telegram passes through that server unencrypted — Telegram can read it too. Everything else stays end-to-end encrypted.`,`Off: this PC refuses every Telegram request, even from your own Telegram account, and a chat open in Telegram is closed at once. The bot says how to turn it back on.`,`Only this PC can turn it on — not the website, the phone or the bot.`,`Needs Remote access on as well, and Telegram connected to your account in the bot (/connect).`]},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.`]},promptSuggestions:{hint:`After each turn, a greyed guess at your next message appears in the empty message box; Tab puts it in, and nothing is ever sent by itself. On by default. It is an extra small request to the model, on your plan or credits.`,details:[`OonaCode pool chats: guessed by OonaCode’s small, fast models (the Auto model’s classifier), from the chat’s last message and answer. Each guess costs a few credits, charged like any pool request and shown in your usage as Auto-suggest.`,`Chats on your own Claude-protocol key or plan (your Claude, DeepSeek, Kimi, GLM…): guessed by the Claude Code engine on your own plan, reusing the turn’s prompt cache — a small request, but not a free one. Those chats never send anything to OonaCode for it.`,`Codex/ChatGPT, SuperGrok, Muse, GitHub Copilot and Google’s agy chats get none: those CLIs never make such a request (and on Copilot it would use a premium request).`,`Tab only fills the box, and Enter sends it like anything you type. Typing hides the guess; the chat’s next turn replaces it. Not after a turn that failed or that you stopped.`,`Decided by this PC for every chat that runs here, whichever window or device sent the turn. Off: the guesses go from every window at once and no new one is asked for; a chat whose agent is already running on your own plan stops making them when its agent next starts.`,`A guess is kept only in this PC’s memory, never in the chat’s history.`]},providerUsagePing:{hint:`When you look at a provider’s usage card and its last figure is old, check it with one tiny request. On by default.`,details:[`Applies to providers you use with your OWN key or subscription — your Claude plan, an own DeepSeek, OpenAI, xAI, MiMo or Alibaba key, a ChatGPT plan, Meta’s Muse key. Google’s agy and SuperGrok have a usage report of their own, and the OonaCode pool shows credits instead: they are never checked.`,`Only when you look: opening the model picker’s card, or resting the pointer on the picker’s box while one of those models is active. Never in the background, and never while the last figure is younger than the time below.`,`The check is one “reply PONG” request of a few tokens, sent from this PC straight to the provider with your own plan or key — so it spends a few tokens of THEM, and nothing about it goes through our servers. Your Claude plan is asked through the genuine Claude engine, as a chat message is.`,`Only the rate-limit figures in the answer are kept (on this PC, with the time they were seen); the answer itself is thrown away. Off: the card shows the last figures it saw, or nothing, and never asks.`]},providerUsageStale:{hint:`How old the last usage figure may be before a look at the card checks again.`,details:[`0 never checks on a look (the card shows what it last saw). A card opened sooner than this after the last figure does not ask the provider anything.`,`A check that failed is not repeated for ten minutes, and “Check now” on the card makes at most one a minute.`]},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.`]},safeguardFallback:{hint:`When a model refuses a message on content or safety grounds, run that one message once more on another model. On by default.`,details:[`Decided by this PC itself, for EVERY chat running here — started in this app, the oona terminal, your phone, Telegram, the website or another PC.`,`Only that message is sent to the other model; the chat stays on the model you picked. The refusal and the retry are both written into the chat, and the turn line says what happened.`,`Switch automatically: the best other model your chat’s route can serve — a Claude chat tries other Claude models first. Always switch to: the model you choose, every time. Never: the refusal is shown and nothing is retried.`,`OonaCode pool: the model that answers is charged at its own price. Your own key or subscription never switches to another provider — only to another model of the same one.`,`A fallback you set for one model (below) beats this choice, and a chat’s own --fallback-model (terminal, agent API) beats both.`,`Limit: Claude Code’s own engine still moves Opus 5, Opus 5.5 and Fable chats to Opus 4.8 by itself when their safeguards refuse — it cannot be switched off.`,`One retry only: if the second model refuses too, the chat says so and stops.`]},safeguardPerModel:{hint:`Pick the fallback for one model. It beats the choice above for that model only; “Never fall back” stops a model from being retried.`,details:[`Applies when the refused model is the one you name here, in any chat on this PC, however it was started.`,`A model you use through your own key or subscription can only fall back to a model of the same provider; an OonaCode pool model can fall back to any pool model.`,`Up to 64 models. A chat’s own --fallback-model still beats this table.`,`Charged by the model that answers: pool credits at its price, or your own key or plan.`]},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. Applies at once.`,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.`,`Applies at once: switched on, the port opens right away for every window; switched off, it closes. Nothing restarts.`,`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 once, like it.`]}};function rNe(e){if(Xc(e))return`Off: the debugging port and the inspector are closed. Chromium's own port (127.0.0.1:${e.chromiumUntilRestart}), opened when OonaCode started with debugging on, closes only when the app restarts.`;if(!Jc(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 iNe(e){return Yc(e.saved,e.running)}function aNe(e){return Xc(e.running)?`Restart OonaCode to close Chromium's port too.`:`This change could not be applied while OonaCode runs; it applies at the next start.`}function oNe(e){return`Debugging is off, but Chromium's own port (127.0.0.1:${e.chromiumUntilRestart??`?`}), opened when OonaCode started with debugging on, stays open until the app restarts. Click for Settings → Developer → Restart now.`}function sNe(e){return`Debugging is on: ${Zc(e)}. While it is on, any program on this PC can read and control OonaCode. Click to change it in Settings → Developer.`}function cNe({providerId:e,configured:t}){let{api:n,state:r,actions:i}=V(),[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,B.jsx)(U,{size:`sm`,variant:t?`secondary`:`primary`,onClick:()=>i.openProviderConnect(e),"data-testid":`agy-provider-button`,children:cje(t,a)})}function p9(e,t){return t.get(e.providerId)??e.providerId}function lNe(e,t,n){let r=Km(t);if(!r)return[];let i=e.find(e=>e.models.some(e=>e.value===t)),a=kl(r.modelId);return(jl(r.providerId)?e.filter(e=>jl(e.providerId)):e.filter(e=>!jl(e.providerId)&&p9(e,n)===(i?p9(i,n):r.providerId))).map(e=>({...e,models:e.models.filter(e=>kl(e.modelId)!==a)})).filter(e=>e.models.length>0)}function m9({groups:e}){return(0,B.jsx)(B.Fragment,{children:e.map(e=>(0,B.jsx)(`optgroup`,{label:e.label,children:e.models.map(e=>(0,B.jsx)(`option`,{value:e.value,children:e.label},e.value))},`${e.providerId}:${e.variantId??``}`))})}var uNe=[{mode:`auto`,label:`Switch to another model automatically`,hint:`The best other model this chat can use. A Claude chat tries other Claude models first.`},{mode:`model`,label:`Always switch to:`,hint:`The model you choose, every time a model refuses.`},{mode:`off`,label:`Never — show the refusal`,hint:`Nothing is retried; the chat shows the refusal and where to change this.`}];function dNe(){let{state:e,actions:t}=V(),n=Al(e.prefs.safeguardFallback),r=(0,v.useMemo)(()=>Qm(e.providers),[e.providers]),i=(0,v.useMemo)(()=>new Map(e.providers.map(e=>[e.definition.id,e.definition.clientGroup??e.definition.id])),[e.providers]),a=(0,v.useMemo)(()=>r.flatMap(e=>e.models.map(e=>({id:e.modelId,displayName:e.label}))),[r]),o=e=>Nl(e,a),[s,c]=(0,v.useState)(!1),l=s?`model`:n.mode,u=e=>void t.savePrefs({safeguardFallback:Al(e)}),d=e=>{if(e===`model`){c(!0);return}c(!1),u({...n,mode:e,model:null})},f=(e=>e?r.flatMap(e=>e.models).find(t=>kl(t.modelId)===kl(e)):void 0)(n.model),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(``),_=(0,v.useMemo)(()=>p?lNe(r,p,i):[],[r,p,i]),y=Object.entries(n.perModel),b=y.length>=64,x=p!==``&&h!==``&&(h===`none`||_.some(e=>e.models.some(e=>e.value===h))),S=()=>{let e=Km(p);if(!e||!x)return;let t=h===`none`?El:Km(h)?.modelId??``;if(!t)return;let r=kl(e.modelId);b&&n.perModel[r]===void 0||(u({...n,perModel:{...n.perModel,[r]:t}}),m(``),g(``))},C=e=>{let t={...n.perModel};delete t[e],u({...n,perModel:t})};return(0,B.jsxs)(`div`,{className:`space-y-4`,"data-testid":`settings-safeguards`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,B.jsx)(H.Shield,{className:`w-3.5 h-3.5`}),` When a model refuses a message`,(0,B.jsx)(uC,{label:`When a model refuses a message`,details:(0,B.jsx)(dC,{items:f9.safeguardFallback.details})})]}),(0,B.jsx)(`p`,{className:`text-xs text-fg-faint`,children:f9.safeguardFallback.hint}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-faint`,children:`On the OonaCode pool, the model that answers is charged at its own price. Your own key or subscription never switches to another provider.`}),(0,B.jsx)(`div`,{role:`radiogroup`,"aria-label":`When a model refuses a message`,className:`mt-2 space-y-1`,children:uNe.map(e=>(0,B.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md px-1 py-1.5 hover:bg-surface-2`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`safeguard-mode`,className:`mt-1`,checked:l===e.mode,onChange:()=>d(e.mode),"data-testid":`safeguard-mode-${e.mode}`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.label}),(0,B.jsx)(`span`,{className:`block text-xs text-fg-faint`,children:e.hint}),e.mode===`model`?(0,B.jsxs)(`select`,{className:z(pC,`mt-1.5 max-w-sm`),"aria-label":`Always switch to`,value:f?.value??``,disabled:l!==`model`,onChange:e=>{let t=Km(e.target.value);t&&(c(!1),u({...n,mode:`model`,model:t.modelId}))},"data-testid":`safeguard-model-select`,children:[(0,B.jsx)(`option`,{value:``,children:n.model&&!f?`${o(n.model)} (not listed)`:`Choose a model…`}),(0,B.jsx)(m9,{groups:r})]}):null]})]},e.mode))}),(0,B.jsx)(`p`,{className:`mt-2 rounded-md bg-surface-2 px-2.5 py-1.5 text-xs text-fg-muted`,children:`Claude Code’s own engine still moves Opus 5, Opus 5.5 and Fable chats to Opus 4.8 by itself when their safeguards refuse — that cannot be switched off.`})]}),(0,B.jsxs)(`div`,{className:`border-t border-border pt-3`,"data-testid":`safeguard-per-model`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Fallback per model`,(0,B.jsx)(uC,{label:`Fallback per model`,details:(0,B.jsx)(dC,{items:f9.safeguardPerModel.details})})]}),(0,B.jsx)(`p`,{className:`text-xs text-fg-faint`,children:f9.safeguardPerModel.hint}),y.length>0?(0,B.jsxs)(`table`,{className:`mt-2 w-full text-xs`,"data-testid":`safeguard-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{className:`text-left text-fg-faint`,children:[(0,B.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Refused model`}),(0,B.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Fallback`}),(0,B.jsx)(`th`,{className:`w-8`})]})}),(0,B.jsx)(`tbody`,{children:y.map(([e,t])=>(0,B.jsxs)(`tr`,{className:`border-t border-border`,"data-testid":`safeguard-row-${e}`,children:[(0,B.jsx)(`td`,{className:`py-1.5 pr-2 text-fg`,children:o(e)}),(0,B.jsx)(`td`,{className:`py-1.5 pr-2 text-fg-muted`,children:t===`none`?`Never`:o(t)}),(0,B.jsx)(`td`,{className:`py-1.5 text-right`,children:(0,B.jsx)(lC,{label:`Remove the fallback for ${o(e)}`,className:`p-0.5`,onClick:()=>C(e),"data-testid":`safeguard-remove-${e}`,children:(0,B.jsx)(H.Trash,{className:`w-3 h-3`})})})]},e))})]}):(0,B.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,"data-testid":`safeguard-table-empty`,children:`No per-model fallbacks — every model follows the choice above.`}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-2`,children:[(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs text-fg-muted`,children:[`When this model refuses`,(0,B.jsxs)(`select`,{className:z(pC,`max-w-56`),value:p,onChange:e=>{m(e.target.value),g(``)},"data-testid":`safeguard-add-refused`,children:[(0,B.jsx)(`option`,{value:``,children:`Choose a model…`}),(0,B.jsx)(m9,{groups:r})]})]}),(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs text-fg-muted`,children:[`Use`,(0,B.jsxs)(`select`,{className:z(pC,`max-w-56`),value:h,disabled:p===``,onChange:e=>g(e.target.value),"data-testid":`safeguard-add-fallback`,children:[(0,B.jsx)(`option`,{value:``,children:`Choose a fallback…`}),(0,B.jsx)(`option`,{value:El,children:`Never fall back`}),(0,B.jsx)(m9,{groups:_})]})]}),(0,B.jsxs)(U,{size:`sm`,variant:`primary`,disabled:!x||b&&n.perModel[kl(Km(p)?.modelId??``)]===void 0,onClick:S,"data-testid":`safeguard-add`,children:[(0,B.jsx)(H.Plus,{className:`w-3 h-3`}),` Add`]})]}),b?(0,B.jsxs)(`p`,{className:`mt-1 text-xs text-warn`,children:[`The table is full (`,64,` models). Remove one to add another.`]}):null,r.length===0?(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-faint`,children:`No models are listed on this PC yet — connect a provider first.`}):null]})]})}function fNe(){let{actions:e}=V(),[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,B.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,B.jsx)(pNe,{onDone:()=>{i(!1),KR(),cL(),s()}}):(0,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`skills-section`,children:[(0,B.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Skills every chat on this PC gets — type `,(0,B.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,B.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,B.jsx)(`span`,{className:`font-medium`,children:`Skills`}),` menu under its message box — only those cost tokens on every message of that chat.`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsxs)(U,{size:`sm`,onClick:()=>i(!0),"data-testid":`skills-import-open`,children:[(0,B.jsx)(H.Download,{className:`h-3.5 w-3.5`}),` Import from Claude Code…`]}),t?(0,B.jsx)(`span`,{className:`truncate text-[11px] text-fg-faint`,title:t.dir,children:t.dir}):null]}),t===void 0?(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading…`}):t===null?(0,B.jsx)(`p`,{className:`text-xs text-danger`,children:`The host could not list the skills right now.`}):t.skills.length===0?(0,B.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,B.jsx)(`span`,{className:`font-mono`,children:`SKILL.md`}),` in the folder above.`]}):(0,B.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.skills.map(t=>(0,B.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2 text-sm`,"data-testid":`skill-row`,"data-name":t.name,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,B.jsxs)(`span`,{className:`font-mono font-medium`,children:[`/`,t.name]}),t.argumentHint?(0,B.jsx)(`span`,{className:`font-mono text-xs text-fg-faint`,children:t.argumentHint}):null,t.broken?(0,B.jsx)(hC,{tone:`warn`,children:`no SKILL.md`}):null]}),t.description?(0,B.jsx)(`div`,{className:`line-clamp-2 text-xs text-fg-muted`,title:t.description,children:t.description}):null,(0,B.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[HF(t.bytes),` · `,t.files,` file`,t.files===1?``:`s`,t.importedFrom?(0,B.jsxs)(B.Fragment,{children:[` `,`· imported `,t.importedAt?Lv(t.importedAt):``,` from`,` `,(0,B.jsx)(`span`,{title:t.importedFrom,children:t.importedFrom})]}):null]})]}),(0,B.jsxs)(U,{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&&(KR(),cL(),await s())},"data-testid":`skill-remove`,children:[(0,B.jsx)(H.Trash,{className:`h-3.5 w-3.5`}),` Remove`]})]},t.name))})]})}function pNe({onDone:e}){let{actions:t}=V(),[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,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`skills-import`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:e,children:`← Back`}),(0,B.jsx)(`span`,{className:`text-sm font-medium`,children:`Import skills from Claude Code`})]}),(0,B.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,B.jsxs)(B.Fragment,{children:[` `,`Read from `,(0,B.jsx)(`span`,{className:`font-mono`,children:n.roots.join(`, `)}),`.`]}):null]}),n===void 0?(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Looking…`}):n===null?(0,B.jsx)(`p`,{className:`text-xs text-danger`,children:`The host could not read Claude Code’s skills.`}):n.skills.length===0?(0,B.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,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wide text-fg-faint`,children:e}),(0,B.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,B.jsx)(`li`,{className:`px-3 py-1.5 text-sm`,children:(0,B.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,B.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,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`span`,{className:`font-mono font-medium`,children:[`/`,e.name]}),` `,e.alreadyInOonaCode?(0,B.jsx)(hC,{children:`already in OonaCode`}):null,` `,e.unavailable?(0,B.jsx)(hC,{tone:`warn`,children:e.unavailable}):null,e.description?(0,B.jsx)(`span`,{className:`line-clamp-2 block text-xs text-fg-muted`,children:e.description}):null,e.note?(0,B.jsx)(`span`,{className:`block text-[11px] text-warn`,children:e.note}):null,(0,B.jsxs)(`span`,{className:`block text-[11px] text-fg-faint`,children:[HF(e.bytes),` · `,e.path]})]})]})},e.key)})})]},e)),n&&n.skills.some(e=>e.alreadyInOonaCode)?(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Replace the ones already in OonaCode`]}):null,u?(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,role:`status`,"data-testid":`skills-import-outcome`,children:u}):null,(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsxs)(U,{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,B.jsx)(U,{size:`sm`,onClick:e,children:`Cancel`})]})]})}function mNe({open:e,onClose:t,editingServer:n}){let{actions:r}=V(),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(`all`),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(`stdio`),[x,S]=(0,v.useState)(`npx`),[C,w]=(0,v.useState)(``),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(``),[j,ee]=(0,v.useState)(!1),[M,te]=(0,v.useState)({}),[ne,N]=(0,v.useState)(!1),[P,re]=(0,v.useState)(null),[ie,ae]=(0,v.useState)(!1),[oe,se]=(0,v.useState)(null),[F,ce]=(0,v.useState)(null);n&&n.id!==F&&(ce(n.id),d(!0),l(null),p(n.id),h(n.name),_(n.description??``),b(n.transport),S(n.command??`npx`),w((n.args??[]).join(` `)),E(Object.entries(n.env??{}).map(([e,t])=>`${e}=${t}`).join(`
|
|
551
|
+
- use the browser on port 9170 for anything on the web`,maxLength:Sc.instructions,"data-testid":`project-instructions`})})]}),(0,B.jsxs)(j5,{title:`Repositories`,children:[(0,B.jsx)(fC,{label:`One per line (optional)`,hint:`Every chat in the project is told about them.`,children:(0,B.jsx)(`textarea`,{className:z(pC,`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,B.jsx)(k5,{compact:!0})]}),(0,B.jsxs)(j5,{title:`New chats`,children:[(0,B.jsx)(fC,{label:`Model`,hint:`What a new chat in this project starts on.`,children:(0,B.jsxs)(`select`,{className:pC,value:u.model,onChange:e=>{g(`model`,e.target.value),g(`effort`,``)},"data-testid":`project-model`,children:[(0,B.jsx)(`option`,{value:``,children:`Whatever a new chat would start on`}),x?(0,B.jsxs)(`option`,{value:u.model,children:[x.model,` (not on this PC)`]}):null,y.map(e=>(0,B.jsx)(`option`,{value:e.key,children:e.label},e.key))]})}),S.length>0?(0,B.jsx)(fC,{label:`Effort`,children:(0,B.jsxs)(`select`,{className:pC,value:u.effort,onChange:e=>g(`effort`,e.target.value),"data-testid":`project-effort`,children:[(0,B.jsx)(`option`,{value:``,children:b&&Be(b.option)?`Default (${Be(b.option)})`:`Default`}),S.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})}):null,(0,B.jsx)(fC,{label:`Folder`,hint:`Where a new chat runs; left empty, each chat gets its own.`,children:(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`input`,{className:z(pC,`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,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>void D(),children:`Choose…`}):null]})})]}),(0,B.jsxs)(j5,{title:`Memory`,children:[(0,B.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:u.memoryEnabled,onChange:e=>g(`memoryEnabled`,e.target.checked),"data-testid":`project-memory-enabled`}),(0,B.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,B.jsx)(`textarea`,{className:z(pC,`h-28 font-mono text-xs`),value:u.memory,onChange:e=>g(`memory`,e.target.value),placeholder:`Nothing noted yet.`,maxLength:Sc.memory,"data-testid":`project-memory`}):null]}),(0,B.jsxs)(j5,{title:`Scheduled tasks`,children:[(0,B.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:u.tasksEnabled,onChange:e=>g(`tasksEnabled`,e.target.checked),"data-testid":`project-tasks-enabled`}),(0,B.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,B.jsx)(fC,{label:`Shortest repeat, in minutes`,children:(0,B.jsx)(`input`,{className:z(pC,`w-28`),inputMode:`numeric`,value:u.minInterval,onChange:e=>g(`minInterval`,e.target.value),"data-testid":`project-min-interval`})}):null,_?(0,B.jsx)(CL,{projectId:_.id,showChat:!0}):null]}),(0,B.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.`})]})]})})}function Uke({open:e,onClose:t}){return(0,B.jsx)(gC,{open:e,title:`Export my chats`,onClose:t,children:(0,B.jsx)(Wke,{onDone:t})})}function Wke({onDone:e}){let{api:t,state:n}=V(),[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,B.jsxs)(`div`,{children:[(0,B.jsx)(gC,{open:a,title:`Exporting your chats`,onClose:()=>void 0,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(H.Spinner,{className:`mt-0.5 w-5 h-5 shrink-0 text-accent`}),(0,B.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,B.jsxs)(`div`,{className:`font-medium`,children:[`Packing`,` `,p>0?`${p} chat${p===1?``:`s`}`:`your chats`,`…`]}),(0,B.jsxs)(`div`,{className:`mt-1 tabular text-fg-muted`,children:[Math.floor(d/60),`:`,String(d%60).padStart(2,`0`),` elapsed`]}),(0,B.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,B.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`One zip with a plain `,(0,B.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,B.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,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`input`,{type:`password`,autoFocus:!0,className:pC+` 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,B.jsx)(U,{onClick:()=>void m(),disabled:a||!r,children:a?`Exporting…`:`Export`}),(0,B.jsx)(U,{variant:`ghost`,onClick:()=>{u(!1),i(``),c(null)},children:`Cancel`})]}):(0,B.jsx)(U,{className:`mt-2`,onClick:()=>u(!0),"data-testid":`export-chats`,children:`Export chats…`}),s?(0,B.jsx)(`div`,{className:`mt-2 text-xs text-danger`,children:s}):null]})}function Gke({open:e,onClose:t}){return(0,B.jsx)(gC,{open:e,title:`Clean up chat folders`,onClose:t,wide:!0,children:(0,B.jsx)(Yke,{open:e,onDone:t})})}function M5(e,t){let n=HF(e)||`0 B`;return t?n:`at least ${n}`}var Kke={chat_exists:`a chat uses it`,recent:`changed in the last day`,invalid:`not a chat folder`,not_found:`already gone`,error:`could not be removed`};function qke(e){let t=Math.floor((Date.now()-e)/864e5);if(t<30)return Rv(e);if(t<60)return`${t} days ago`;if(t<365){let e=Math.floor(t/30);return`${e} ${e===1?`month`:`months`} ago`}let n=Math.floor(t/365);return`${n} ${n===1?`year`:`years`} ago`}function N5(e){if(!e)return``;let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=new Date(t).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`}),r=qke(t);return r?`${n} (${r})`:n}function P5(e){return e.onlyScaffolding?e.files===0&&e.sample.length===0?`Empty folder`:`Empty, apart from OonaCode’s permission memory`:e.sample.length>0?e.sample.join(`, `):`Files in its .claude folder`}function Jke(e){let t=e.slice(0,3).map(e=>`“${e}”`),n=e.length-t.length;return n>0?`${t.join(`, `)} and ${n} more`:t.join(`, `)}function Yke({open:e,onDone:t}){let{api:n}=V(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(new Set),[d,f]=(0,v.useState)(new Set),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),b=(0,v.useCallback)(async()=>{if(!n.workspaceCleanupScan){c(`This PC is running an older OonaCode that cannot clean chat folders. Update OonaCode first.`);return}o(!0),c(null);try{let e=await n.workspaceCleanupScan();i(e),u(new Set(e.orphans.filter(e=>e.deletable&&e.onlyScaffolding).map(e=>e.id))),f(new Set)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[n]);(0,v.useEffect)(()=>{e&&(y(null),m(!1),b())},[e,b]);let x=(0,v.useMemo)(()=>new Map((r?.orphans??[]).map(e=>[e.id,e])),[r]),S=r?.leftBehind.entries??[],C=(0,v.useMemo)(()=>new Map((r?.leftBehind.entries??[]).map(e=>[e.id,e])),[r]),w=(r?.orphans??[]).filter(e=>e.deletable&&e.onlyScaffolding),T=(r?.orphans??[]).filter(e=>e.deletable&&!e.onlyScaffolding),E=(r?.orphans??[]).filter(e=>!e.deletable),D=[...l].map(e=>x.get(e)).filter(e=>!!e),O=[...d].map(e=>C.get(e)).filter(e=>!!e&&e.deletable),k=D.length+O.length,A=D.reduce((e,t)=>e+t.sizeBytes,0)+O.reduce((e,t)=>e+t.sizeBytes,0),j=D.every(e=>e.sizeExact)&&O.every(e=>e.sizeExact),ee=e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),M=e=>f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),te=async()=>{if(!n.workspaceCleanupDelete||k===0)return;g(!0),c(null);let e={};for(let t of D)e[t.id]=`Folder ${t.id.slice(0,8)}`;for(let t of O)e[t.id]=`Folder ${t.id.slice(0,8)} of the chat “${t.chatTitle}”`;try{let t=await n.workspaceCleanupDelete({ids:[...D.map(e=>e.id),...O.map(e=>e.id)],...O.length>0?{includeMoved:!0}:{}});y({...t,labels:e}),m(!1),await b()}catch(e){c(e instanceof Error?e.message:String(e))}finally{g(!1)}},ne=e=>{let t=window.oonacode?.showItemInFolder;typeof t==`function`&&t(e)},N=typeof window.oonacode?.showItemInFolder==`function`,P=e=>N?(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>ne(e.path),"aria-label":`Show ${e.id.slice(0,8)} in its folder`,title:`Show in folder`,children:(0,B.jsx)(H.Folder,{className:`h-3.5 w-3.5`})}):null,re=e=>[e.createdAt?`Created ${N5(e.createdAt)}`:``,`Last changed ${N5(e.changedAt)}`].filter(Boolean).join(` · `),ie=e=>(0,B.jsx)(`div`,{className:`select-text break-all font-mono text-[11px] text-fg-muted`,"data-testid":`cleanup-path`,children:e.path}),ae=e=>(0,B.jsxs)(`li`,{className:`flex items-start gap-3 py-2.5`,"data-testid":`cleanup-row`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:l.has(e.id),onChange:()=>ee(e.id),"aria-label":`Select folder ${e.id.slice(0,8)} for deletion: no chat uses it, ${M5(e.sizeBytes,e.sizeExact)}, last changed ${N5(e.changedAt)}`,"data-testid":`cleanup-pick-${e.id}`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:M5(e.sizeBytes,e.sizeExact)}),e.files>0?(0,B.jsxs)(`span`,{className:`text-fg-muted`,children:[e.files,` files`]}):null,(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-ok-soft px-2 py-0.5 text-xs font-medium text-ok`,"data-testid":`cleanup-orphan-badge`,children:[(0,B.jsx)(H.Check,{className:`h-3 w-3`}),`No chat uses this folder - safe to delete`]})]}),(0,B.jsx)(`div`,{className:`text-xs text-fg-muted`,"data-testid":`cleanup-dates`,children:re(e)}),(0,B.jsxs)(`div`,{className:`text-xs`,"data-testid":`cleanup-contents`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`Inside: `}),P5(e)]}),ie(e)]}),P(e)]},e.id),oe=e=>(0,B.jsxs)(`li`,{className:`flex items-start gap-3 py-2.5`,"data-testid":`cleanup-moved-row`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:d.has(e.id),disabled:!e.deletable,onChange:()=>M(e.id),"aria-label":`Select the old folder of the chat “${e.chatTitle}” for deletion, ${M5(e.sizeBytes,e.sizeExact)}. The chat still exists.`,"data-testid":`cleanup-moved-pick-${e.id}`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium`,"data-testid":`cleanup-moved-title`,children:e.chatTitle}),(0,B.jsxs)(`div`,{className:`text-xs text-fg-muted`,"data-testid":`cleanup-moved-cwd`,children:[`Now works in `,(0,B.jsx)(`span`,{className:`select-text break-all font-mono`,children:e.chatCwd})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 text-sm`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:M5(e.sizeBytes,e.sizeExact)}),e.files>0?(0,B.jsxs)(`span`,{className:`text-fg-muted`,children:[e.files,` files`]}):null]}),(0,B.jsxs)(`div`,{className:`text-xs`,"data-testid":`cleanup-contents`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`Inside: `}),P5(e)]}),(0,B.jsxs)(`div`,{className:`text-xs text-fg-muted`,"data-testid":`cleanup-dates`,children:[re(e),e.chatUpdatedAt?` · Chat last used ${N5(e.chatUpdatedAt)}`:``]}),(0,B.jsx)(`p`,{className:`text-xs text-warn`,"data-testid":`cleanup-moved-note`,children:`Left over from before the chat moved; the chat’s old messages may mention files in it.`}),e.deletable?null:(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`cleanup-moved-kept`,children:e.recent?`Changed in the last day, so it is kept for now.`:`Another chat is working in this folder, so it is kept.`}),ie(e)]}),P(e)]},e.id),se=[...w,...T].map(e=>e.id),F=r?.leftBehind.count??0;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm`,"data-testid":`workspace-cleanup`,children:[(0,B.jsx)(`p`,{className:`text-fg-muted`,children:`A chat with no project runs in a folder of its own. Deleting the chat keeps that folder when something was written in it, so folders of chats you deleted long ago are still on your disk.`}),s?(0,B.jsx)(`p`,{role:`alert`,className:`rounded-md bg-danger-soft px-3 py-2 text-danger`,children:s}):null,a&&!r?(0,B.jsx)(`p`,{className:`text-fg-muted`,children:`Looking at your chat folders…`}):null,_?(0,B.jsxs)(`div`,{className:`rounded-md bg-surface-2 px-3 py-2`,role:`status`,"data-testid":`cleanup-result`,children:[(0,B.jsxs)(`p`,{children:[`Deleted `,_.removed.length,` `,_.removed.length===1?`folder`:`folders`,`, freeing `,HF(_.freedBytes)||`0 B`,`.`,_.skipped.length>0?` Kept ${_.skipped.length}, with the reason for ${_.skipped.length===1?`it`:`each`}:`:``]}),_.skipped.length>0?(0,B.jsx)(`ul`,{className:`mt-1 list-disc pl-5 text-xs`,"data-testid":`cleanup-result-kept`,children:_.skipped.map(e=>(0,B.jsxs)(`li`,{"data-testid":`cleanup-result-kept-row`,children:[_.labels[e.id]??`Folder ${e.id.slice(0,8)}`,`:`,` `,Kke[e.reason]??e.reason,e.message?` - ${e.message}`:``]},e.id))}):null]}):null,r&&r.orphans.length===0?(0,B.jsxs)(`p`,{"data-testid":`cleanup-nothing`,children:[`Nothing to clean up. Every folder under`,` `,(0,B.jsx)(`span`,{className:`font-mono text-xs`,children:r.root}),` belongs to a chat you still have.`]}):null,r&&r.orphans.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`p`,{"data-testid":`cleanup-summary`,children:[(0,B.jsx)(`strong`,{children:r.totals.orphanCount}),` `,r.totals.orphanCount===1?`folder belongs`:`folders belong`,` to chats you deleted (`,M5(r.totals.orphanBytes,r.totals.sizeExact),`).`]}),(0,B.jsx)(`p`,{className:`rounded-md bg-ok-soft px-3 py-2 text-ok`,"data-testid":`cleanup-orphan-statement`,children:r.totals.orphanCount===1?`This folder has no chat in OonaCode’s database on this PC (checked across every account on this PC). It is a leftover of a deleted chat and is safe to delete.`:`These folders have no chat in OonaCode’s database on this PC (checked across every account on this PC). They are leftovers of deleted chats and are safe to delete.`}),w.length>0?(0,B.jsxs)(`section`,{children:[(0,B.jsxs)(`h3`,{className:`mb-1 font-medium`,children:[`Nothing of yours inside (`,w.length,`)`]}),(0,B.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border px-3`,children:w.map(ae)})]}):null,T.length>0?(0,B.jsxs)(`section`,{children:[(0,B.jsxs)(`h3`,{className:`mb-1 font-medium`,children:[`Files inside (`,T.length,`)`]}),(0,B.jsx)(`p`,{className:`mb-1 text-xs text-fg-muted`,children:`Files the assistant made or you pasted in those chats. Not ticked: look first, a delete removes them for good.`}),(0,B.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border px-3`,children:T.map(ae)})]}):null,E.length>0?(0,B.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`cleanup-recent`,children:[E.length,` `,E.length===1?`folder was`:`folders were`,` changed in the last day and `,E.length===1?`is`:`are`,` kept for now (a chat you are still starting may use `,E.length===1?`it`:`them`,`).`]}):null]}):null,r&&F>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`cleanup-left-behind`,children:[F,` `,F===1?`chat you still have moved`:`chats you still have moved`,` to another folder and left `,M5(r.leftBehind.bytes,r.leftBehind.sizeExact),` in`,` `,F===1?`its`:`their`,` old `,F===1?`folder`:`folders`,`.`,S.length>0?``:` Those stay.`]}),S.length>0?(0,B.jsxs)(`section`,{"data-testid":`cleanup-moved`,children:[(0,B.jsxs)(`h3`,{className:`mb-1 font-medium`,children:[`Chats you still have, now working elsewhere (`,S.length,`)`]}),(0,B.jsx)(`p`,{className:`mb-1 text-xs text-fg-muted`,children:`These chats still exist, so their folders are not leftovers of deleted chats. Not ticked. Delete one only if you are sure you do not need what that chat made there.`}),(0,B.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border px-3`,children:S.map(oe)})]}):null]}):null,p?(0,B.jsxs)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-3`,role:`alertdialog`,"aria-label":`Confirm delete`,children:[(0,B.jsxs)(`p`,{className:`text-danger`,"data-testid":`cleanup-confirm-text`,children:[`Delete `,k,` `,k===1?`folder`:`folders`,` (`,M5(A,j),`) and everything inside? This cannot be undone.`]}),O.length>0?(0,B.jsxs)(`p`,{className:`mt-2 font-medium text-danger`,"data-testid":`cleanup-confirm-moved-warning`,children:[O.length,` of these`,` `,O.length===1?`belongs to a chat`:`belong to chats`,` you still have:`,` `,Jke(O.map(e=>e.chatTitle)),`. The`,` `,O.length===1?`chat stays`:`chats stay`,`, but the files made before`,` `,O.length===1?`it`:`they`,` moved will be gone, and old messages that mention them will point at nothing.`]}):null,(0,B.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,B.jsx)(U,{variant:`danger`,busy:h,onClick:()=>void te(),"data-testid":`cleanup-confirm`,children:`Delete forever`}),(0,B.jsx)(U,{variant:`ghost`,onClick:()=>m(!1),disabled:h,children:`Cancel`})]})]}):(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(U,{variant:`danger`,disabled:k===0||h,onClick:()=>m(!0),"data-testid":`cleanup-delete`,children:[(0,B.jsx)(H.Trash,{className:`h-3.5 w-3.5`}),k===0?`Delete…`:`Delete ${k} ${k===1?`folder`:`folders`} (${M5(A,j)})…`]}),se.length>0?(0,B.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>u(new Set(se)),title:`Tick every folder of a deleted chat (never the folders of chats you still have)`,"data-testid":`cleanup-all`,children:`Select all`}):null,se.length>0||S.length>0?(0,B.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>{u(new Set),f(new Set)},"data-testid":`cleanup-none`,children:`Select none`}):null,(0,B.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>void b(),disabled:a,"data-testid":`cleanup-rescan`,children:[(0,B.jsx)(H.Refresh,{className:`h-3.5 w-3.5`}),` Rescan`]}),(0,B.jsx)(U,{variant:`ghost`,size:`sm`,onClick:t,className:`ml-auto`,children:`Close`})]})]})}var F5=3,I5=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function Xke(e){let t=e.scope;return t.kind===`all`?`Every chat on this PC${e.chatCount===void 0?``:` (${I5(e.chatCount,`chat`)} now)`}, and chats made later`:t.kind===`chats`?I5(t.chatIds.length,`chosen chat`):`Project “${e.projectName??`one project`}”${e.chatCount===void 0?``:` (${I5(e.chatCount,`chat`)} now)`}, and chats filed under it later`}function L5(e,t,n){let r=e.chats?.find(e=>e.id===n);if(r)return r.present?r.title:null;let i=t.find(e=>e.id===n);return i?Gv(i):null}var Zke=e=>e?`“${e}”`:`a chat no longer here`;function Qke(e,t,n){let r=(e.chatIds??[]).map(e=>Zke(L5(t,n,e)));return e.outcome===`refused`?`was refused (${e.call.replace(`_`,` `)})`:e.call===`list_chats`?`listed ${I5(e.chats,`chat`)}`:e.call===`read_chat`?r.length>0?`read ${r.join(`, `)}`:`read 1 chat`:r.length>0?`searched, found in ${r.join(`, `)}`:`searched ${I5(e.chats,`chat`)}`}function $ke({grant:e,sessions:t}){if(e.scope.kind===`all`)return(0,B.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,"data-testid":`ai-tool-chats-${e.id}`,children:[`Every chat on this PC`,e.chatCount===void 0?``:` (${e.chatCount} now)`]});let n=e.chats??(e.scope.kind===`chats`?e.scope.chatIds.map(n=>{let r=L5(e,t,n);return{id:n,title:r??`A chat`,present:r!==null}}):[]);if(n.length===0)return(0,B.jsx)(`div`,{className:`mt-1 text-xs text-fg-faint`,"data-testid":`ai-tool-chats-${e.id}`,children:e.scope.kind===`project`?`No chat is filed under this project.`:`No chats.`});let r=n.length-F5+(e.chatsMore??0);return(0,B.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1 text-xs`,"data-testid":`ai-tool-chats-${e.id}`,children:[n.slice(0,F5).map(e=>(0,B.jsx)(`span`,{className:`max-w-[14rem] truncate rounded bg-surface-2 px-1.5 py-0.5 ${e.present?`text-fg`:`text-fg-faint line-through`}`,title:e.present?e.title:`${e.title} (${e.id})`,children:e.title},e.id)),r>0?(0,B.jsxs)(`span`,{className:`text-fg-faint`,children:[`+`,r,` more`]}):null]})}function eAe({grant:e}){let t=e.chats??[],n=e.reads[e.reads.length-1],r=e.status===`revoked`?`Revoked ${e.revokedAt?zv(e.revokedAt):``}`.trim():e.status===`expired`?`Expired ${e.expiresAt?zv(e.expiresAt):``}`.trim():e.expiresAt?`Active until ${zv(e.expiresAt)}`:`Active until you revoke it`;return(0,B.jsxs)(`div`,{className:`mt-2 rounded-md border border-border bg-surface-2 p-2 text-xs`,"data-testid":`ai-tool-details-${e.id}`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(iz,{label:`Status`,value:r}),(0,B.jsx)(iz,{label:`Opens`,value:Xke(e)}),(0,B.jsx)(iz,{label:`Its own key`,value:e.tokenHint?`${e.tokenHint}…`:`made before key hints`}),(0,B.jsx)(iz,{label:`Connected`,value:zv(e.createdAt)}),(0,B.jsx)(iz,{label:`Key replaced`,value:e.keyChangedAt?zv(e.keyChangedAt):null}),(0,B.jsx)(iz,{label:`Lasts`,value:e.lifetime===`hour`?`One hour`:e.lifetime===`day`?`One day`:`Until you revoke it`}),(0,B.jsx)(iz,{label:`Last used`,value:n?zv(n.at):`never`}),(0,B.jsx)(iz,{label:`Calls logged`,value:String(e.reads.length)})]}),(0,B.jsxs)(`div`,{className:`mt-2 border-t border-border pt-2`,children:[(0,B.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:e.scope.kind===`all`?`Chats it can read`:`Chats it can read (${e.chatCount??t.length})`}),e.scope.kind===`all`?(0,B.jsx)(`p`,{className:`text-fg-muted`,children:`Every chat on this PC, the ones you make later too. Choose chats or a project next time to share less.`}):t.length===0?(0,B.jsx)(`p`,{className:`text-fg-faint`,children:`None.`}):(0,B.jsxs)(`ul`,{className:`max-h-48 space-y-0.5 overflow-y-auto`,"data-testid":`ai-tool-details-chats-${e.id}`,children:[t.map(e=>(0,B.jsx)(`li`,{className:`truncate ${e.present?`text-fg`:`text-fg-faint line-through`}`,title:e.present?e.title:`${e.title} (${e.id})`,children:e.title},e.id)),(e.chatsMore??0)>0?(0,B.jsxs)(`li`,{className:`text-fg-faint`,children:[`+`,e.chatsMore,` more`]}):null]})]}),(0,B.jsxs)(`p`,{className:`mt-2 border-t border-border pt-2 text-fg-faint`,children:[`This connection has a key of its own. It opens only the chats above: another connected tool's key cannot read them, and this one cannot read theirs. Revoke ends this key and no other`,e.status===`active`?``:`; Delete takes the ended connection off the list`,`.`]})]})}function tAe({grant:e,sessions:t}){let n=[...e.reads].reverse(),r=[...new Set(n.map(e=>e.client).filter(e=>!!e))];return(0,B.jsxs)(`div`,{className:`mt-2 rounded-md border border-border bg-surface-2 p-2 text-xs`,"data-testid":`ai-tool-activity-${e.id}`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center justify-between gap-2`,children:[(0,B.jsxs)(`span`,{className:`font-medium text-fg`,children:[`Activity — `,I5(n.length,`call`),` logged`,n.length>=Bg.readsKept?` (the last ${Bg.readsKept} are kept)`:``]}),(0,B.jsxs)(`span`,{className:`text-fg-faint`,children:[`Connected `,zv(e.createdAt),e.keyChangedAt?` · key replaced ${zv(e.keyChangedAt)}`:``]})]}),r.length>1?(0,B.jsxs)(`p`,{className:`mb-1 text-warn`,"data-testid":`ai-tool-callers-${e.id}`,children:[r.length,` different programs used this key: `,r.join(` · `),`. If you shared it with only one, revoke it or make a new key.`]}):null,n.length===0?(0,B.jsx)(`p`,{className:`text-fg-faint`,children:`Nothing has used this connection yet.`}):(0,B.jsx)(`div`,{className:`max-h-60 overflow-y-auto`,children:(0,B.jsxs)(`table`,{className:`w-full text-left`,children:[(0,B.jsx)(`thead`,{className:`sticky top-0 bg-surface-2 text-fg-faint`,children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{className:`py-0.5 pr-2 font-normal`,children:`When`}),(0,B.jsx)(`th`,{className:`py-0.5 pr-2 font-normal`,children:`Who`}),(0,B.jsx)(`th`,{className:`py-0.5 font-normal`,children:`What`})]})}),(0,B.jsx)(`tbody`,{"data-testid":`ai-tool-activity-rows-${e.id}`,children:n.map((n,r)=>(0,B.jsxs)(`tr`,{className:`align-top`,children:[(0,B.jsx)(`td`,{className:`whitespace-nowrap py-0.5 pr-2 text-fg-muted`,children:zv(n.at)}),(0,B.jsx)(`td`,{className:`max-w-[10rem] truncate py-0.5 pr-2 text-fg-muted`,title:n.client??`not named by the caller`,children:n.client??`—`}),(0,B.jsx)(`td`,{className:n.outcome===`refused`?`py-0.5 text-warn`:`py-0.5 text-fg`,children:Qke(n,e,t)})]},`${n.at}-${r}`))})]})})]})}function nAe({open:e,onClose:t}){return(0,B.jsx)(gC,{open:e,title:`Connect an AI tool`,onClose:t,wide:!0,children:e?(0,B.jsx)(oAe,{}):null})}var rAe=2e3,iAe=6e3,R5={hour:`One hour`,day:`One day`,"until-revoked":`Until I revoke it`};function aAe(e){let t=e.chats,n=`${t} chat${t===1?``:`s`}`,r=e.outcome===`refused`?`refused (${e.call})`:e.call===`list_chats`?`listed ${n}`:e.call===`read_chat`?`read ${n}`:`searched ${n}`;return`${Bv(e.at)} · ${r}`}function oAe(){let{api:e,state:t}=V(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)([]),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)({}),[y,b]=(0,v.useState)(new Set),x=(0,v.useRef)(new Map),S=(e,t)=>_(n=>{let{[e]:r,...i}=n;return r===t?i:{...i,[e]:t}}),[C,w]=(0,v.useState)(null),[T,E]=(0,v.useState)(!1),D=!!(e.listAiToolGrants&&e.createAiToolGrant&&e.revokeAiToolGrant),O=(0,v.useCallback)(async()=>{if(e.listAiToolGrants)try{let t=await e.listAiToolGrants();r(e=>e&&JSON.stringify(e)===JSON.stringify(t.grants)?e:t.grants),h(t.mcpUrl),a(null);let n=x.current,i=[];for(let e of t.grants){let t=e.reads[e.reads.length-1]?.at??``;n.has(e.id)&&n.get(e.id)!==t&&t!==``&&i.push(e.id),n.set(e.id,t)}i.length>0&&(b(e=>new Set([...e,...i])),setTimeout(()=>b(e=>{let t=new Set(e);for(let e of i)t.delete(e);return t}),iAe))}catch(e){a(Kv(e))}},[e]);(0,v.useEffect)(()=>{O(),e.listVaultProjects().then(e=>s(e.projects)).catch(()=>s([]))},[e,O]),(0,v.useEffect)(()=>{if(!e.listAiToolGrants)return;let t=setInterval(()=>{typeof document<`u`&&document.visibilityState===`hidden`||O()},rAe);return()=>clearInterval(t)},[e,O]);let k=(0,v.useCallback)(e=>o.find(t=>t.id===e)?.name??`one project`,[o]),A=e=>{if(e.kind===`all`)return`All chats on this PC`;if(e.kind===`chats`){let t=e.chatIds.length;return`${t} chosen chat${t===1?``:`s`}`}return`Project: ${k(e.projectId)}`},j=async t=>{if(e.revokeAiToolGrant){p(t);try{await e.revokeAiToolGrant(t),await O()}catch(e){a(Kv(e))}finally{p(null)}}},ee=(n??[]).filter(e=>e.status!==`active`),M=async t=>{if(e.forgetAiToolGrant){E(!0);try{for(let n of t)await e.forgetAiToolGrant(n.id);_(e=>{let n={...e};for(let e of t)delete n[e.id];return n})}catch(e){a(Kv(e))}finally{E(!1),await O()}}};return D?(0,B.jsxs)(`div`,{className:`space-y-3 text-sm`,"data-testid":`connect-ai-tool-body`,children:[(0,B.jsxs)(`p`,{className:`text-fg-muted`,children:[`Let an AI tool on this PC — Claude Code in VS Code, or any MCP client — `,(0,B.jsx)(`b`,{children:`read`}),` your chats on `,t.connection.hostName?(0,B.jsx)(`b`,{children:t.connection.hostName}):`this PC`,`. It gets read-only access through OonaCode, only while OonaCode runs and is unlocked; it never gets your password, your vault or OonaCode's own key.`]}),(0,B.jsxs)(`ul`,{className:`list-disc space-y-1 rounded-md border border-warn/40 bg-warn/5 py-2 pl-6 pr-3 text-xs text-warn`,"data-testid":`connect-ai-tool-warning`,children:[(0,B.jsx)(`li`,{children:`Whatever the tool reads is sent to that tool's model provider.`}),(0,B.jsx)(`li`,{children:`Chats can hold secrets you pasted or a tool printed. Key-shaped strings are masked, but not everything secret looks like a key.`}),(0,B.jsx)(`li`,{children:`A chat's text can carry instructions aimed at the tool. OonaCode marks everything it hands over as untrusted data, and offers read tools only — nothing that writes, sends or deletes.`})]}),u?(0,B.jsx)(lAe,{made:u,onDone:()=>d(null)}):c?(0,B.jsx)(uAe,{projects:o,onCancel:()=>l(!1),onCreated:e=>{l(!1),d(e),O()}}):(0,B.jsxs)(U,{onClick:()=>l(!0),"data-testid":`connect-ai-tool-new`,children:[(0,B.jsx)(H.Plug,{className:`w-3.5 h-3.5`}),`Connect a tool…`]}),i?(0,B.jsx)(`div`,{className:`text-xs text-danger`,children:i}):null,(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-1 text-xs font-medium uppercase tracking-wide text-fg-faint`,children:[(0,B.jsx)(`span`,{children:`Connected tools`}),(0,B.jsx)(`span`,{className:`ml-2 normal-case tracking-normal text-ok`,"data-testid":`connect-ai-tool-live`,children:`● live`}),ee.length>0&&e.forgetAiToolGrant?(0,B.jsxs)(U,{size:`sm`,variant:`ghost`,className:`float-right normal-case tracking-normal`,busy:T,onClick:()=>w(`ended`),"data-testid":`ai-tool-delete-ended`,children:[`Delete `,ee.length,` ended`]}):null]}),(0,B.jsx)(`p`,{className:`mb-1 text-xs text-fg-faint`,"data-testid":`connect-ai-tool-own-keys`,children:`Each connection has a key of its own and opens only the chats on its line — press Details on one for everything about it. Make one connection per AI tool.`}),n===null?(0,B.jsx)(`div`,{className:`text-xs text-fg-faint`,children:`Loading…`}):n.length===0?(0,B.jsx)(`div`,{className:`text-xs text-fg-faint`,"data-testid":`connect-ai-tool-none`,children:`No AI tool is connected.`}):(0,B.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:n.map(n=>(0,B.jsxs)(`li`,{className:z(`p-2 transition-colors`,y.has(n.id)&&`bg-accent-soft`),"data-fresh":y.has(n.id)?`true`:void 0,"data-testid":`ai-tool-grant-${n.id}`,children:[(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:n.toolName}),n.tokenHint?(0,B.jsxs)(`span`,{className:`rounded bg-surface-2 px-1 font-mono text-[10px] text-fg-faint`,title:`This connection's own key begins like this. Another tool's key opens only that tool's chats.`,"data-testid":`ai-tool-key-${n.id}`,children:[n.tokenHint,`…`]}):null]}),(0,B.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[A(n.scope),` · `,(0,B.jsx)(cAe,{grant:n})]}),(0,B.jsx)($ke,{grant:n,sessions:t.sessions})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-1`,children:[(0,B.jsx)(U,{size:`sm`,onClick:()=>S(n.id,`details`),"aria-expanded":g[n.id]===`details`,"data-testid":`ai-tool-details-btn-${n.id}`,children:`Details`}),(0,B.jsxs)(U,{size:`sm`,onClick:()=>S(n.id,`activity`),"aria-expanded":g[n.id]===`activity`,"data-testid":`ai-tool-activity-btn-${n.id}`,children:[`Activity`,n.reads.length>0?` (${n.reads.length})`:``]}),n.status===`active`?(0,B.jsx)(U,{size:`sm`,onClick:()=>S(n.id,`share`),"aria-expanded":g[n.id]===`share`,"data-testid":`ai-tool-share-btn-${n.id}`,children:`Share`}):null,n.status===`active`?(0,B.jsx)(U,{size:`sm`,variant:`danger`,busy:f===n.id,onClick:()=>void j(n.id),"data-testid":`ai-tool-revoke-${n.id}`,children:`Revoke`}):null,n.status!==`active`&&e.forgetAiToolGrant?(0,B.jsx)(U,{size:`sm`,variant:`danger`,onClick:()=>w(n),"data-testid":`ai-tool-delete-${n.id}`,children:`Delete`}):null]})]}),g[n.id]===`details`?(0,B.jsx)(eAe,{grant:n}):null,g[n.id]===`activity`?(0,B.jsx)(tAe,{grant:n,sessions:t.sessions}):null,g[n.id]===`share`&&n.status===`active`?(0,B.jsx)(sAe,{grant:n,mcpUrl:m,onChanged:()=>void O()}):null,n.reads.length>0?(0,B.jsx)(`ul`,{className:`mt-1 space-y-0.5 text-xs text-fg-faint`,"data-testid":`ai-tool-reads`,children:[...n.reads].reverse().slice(0,5).map((e,t)=>(0,B.jsxs)(`li`,{title:zv(e.at),children:[n.toolName,` `,aAe(e).replace(` · `,` — `)]},`${e.at}-${t}`))}):n.status===`active`?(0,B.jsx)(`div`,{className:`mt-1 text-xs text-fg-faint`,children:`Nothing read yet.`}):null]},n.id))})]}),(0,B.jsx)(bC,{open:C!==null,title:C===`ended`?`Delete the ended connections?`:`Delete this connection?`,message:C===`ended`?`${ee.length} ended connection${ee.length===1?``:`s`} (revoked or expired) leave the list, with the log of what each read. They cannot read anything now, so nothing else changes.`:C?`“${C.toolName}” is ${C.status===`revoked`?`revoked`:`expired`} and cannot read anything. It leaves the list, with the log of what it read.`:``,confirmLabel:`Delete`,onConfirm:()=>{M(C===`ended`?ee:C?[C]:[])},onClose:()=>w(null)})]}):(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`connect-ai-tool-unsupported`,children:`This PC is running an older OonaCode that cannot connect an AI tool. Update it first.`})}function sAe({grant:e,mcpUrl:t,onChanged:n}){let{api:r}=V(),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(!1),g=t??`http://127.0.0.1:<port>/api/v1/ai-tools/mcp`,_=qee(g,`${e.tokenHint??`oca_`}…<the rest of this connection's key>`),y=e.revealable!==!1&&!!r.revealAiToolGrant,b=async()=>{let t=i;if(t){l(!0),d(null);try{let i=t===`reveal`?await r.revealAiToolGrant(e.id,{password:o}):await r.rotateAiToolGrant(e.id,{password:o});p({answer:i,fresh:t===`new`}),a(null),s(``),h(!1),t===`new`&&n()}catch(e){d(Kv(e))}finally{l(!1)}}};return(0,B.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-md border border-border bg-surface-2 p-2 text-xs`,"data-testid":`ai-tool-share-${e.id}`,children:[(0,B.jsxs)(`div`,{className:`font-medium text-fg`,children:[`Give `,e.toolName,` access`]}),(0,B.jsxs)(`div`,{className:`text-fg-muted`,children:[`The tool connects to `,(0,B.jsx)(`code`,{className:`font-mono text-fg`,children:g}),` and sends its own key as `,(0,B.jsx)(`code`,{className:`font-mono text-fg`,children:`Authorization: Bearer …`}),`. This key opens only the chats on this line.`]}),f?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:f.fresh?`text-warn`:`text-fg-muted`,children:f.fresh?`New key. The key it replaces has stopped working; give this command to ${e.toolName}.`:`This connection's key. Treat it like a password: anyone who has it can read the chats on this line.`}),(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(`pre`,{className:`min-w-0 flex-1 overflow-x-auto whitespace-pre-wrap break-all rounded bg-surface p-2 font-mono`,"data-testid":`ai-tool-share-command-${e.id}`,children:f.answer.command}),(0,B.jsxs)(U,{size:`sm`,onClick:()=>void XI(f.answer.command).then(e=>{e&&h(!0)}),"data-testid":`ai-tool-share-copy-${e.id}`,children:[(0,B.jsx)(H.Copy,{className:`w-3.5 h-3.5`}),m?`Copied`:`Copy`]})]}),(0,B.jsxs)(`details`,{className:`text-fg-muted`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer`,children:`For another MCP client`}),(0,B.jsxs)(`div`,{className:`mt-1 space-y-1 font-mono`,children:[(0,B.jsxs)(`div`,{children:[`URL: `,f.answer.mcpUrl]}),(0,B.jsxs)(`div`,{className:`break-all`,children:[`Header: `,f.answer.header]})]})]}),(0,B.jsx)(U,{size:`sm`,onClick:()=>p(null),"data-testid":`ai-tool-share-hide-${e.id}`,children:`Hide key`})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap break-all rounded bg-surface p-2 font-mono`,"data-testid":`ai-tool-share-template-${e.id}`,children:_}),y?(0,B.jsx)(`p`,{className:`text-fg-faint`,children:`Reveal the key with your OonaCode password to copy the whole command.`}):(0,B.jsx)(`p`,{className:`text-fg-faint`,"data-testid":`ai-tool-share-not-kept-${e.id}`,children:`This key was made before OonaCode kept keys, so it cannot be shown again. Make a new key to share this connection: whatever uses the current key stops working until you give it the new command.`}),i?(0,B.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),o&&b()},children:[(0,B.jsx)(`input`,{type:`password`,className:z(pC,`max-w-[16rem]`),placeholder:`Your OonaCode password`,autoComplete:`current-password`,autoFocus:!0,value:o,onChange:e=>s(e.target.value),"data-testid":`ai-tool-share-password-${e.id}`}),(0,B.jsx)(U,{size:`sm`,variant:`primary`,type:`submit`,busy:c,disabled:!o,"data-testid":`ai-tool-share-${i===`reveal`?`reveal`:`make`}-${e.id}`,children:i===`reveal`?`Show key`:`Make new key`}),(0,B.jsx)(U,{size:`sm`,onClick:()=>{a(null),d(null)},children:`Cancel`})]}):(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[y?(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:()=>a(`reveal`),"data-testid":`ai-tool-share-reveal-key-${e.id}`,children:`Reveal key…`}):null,(0,B.jsx)(U,{size:`sm`,variant:y?`ghost`:void 0,onClick:()=>a(`new`),disabled:!r.rotateAiToolGrant,"data-testid":`ai-tool-share-new-key-${e.id}`,title:`Replace this connection's key: the old one stops working at once (for a key that leaked).`,children:y?`Replace the key…`:`New key and command…`})]}),u?(0,B.jsx)(`div`,{className:`text-danger`,children:u}):null]})]})}function cAe({grant:e}){return e.status===`revoked`?(0,B.jsx)(`span`,{className:`text-fg-faint`,children:`revoked`}):e.status===`expired`?(0,B.jsx)(`span`,{className:`text-fg-faint`,children:`expired`}):(0,B.jsxs)(`span`,{className:`text-ok`,children:[`active`,e.expiresAt?` until ${zv(e.expiresAt)}`:` until revoked`]})}function lAe({made:e,onDone:t}){let[n,r]=(0,v.useState)(!1);return(0,B.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border bg-surface-2 p-2`,"data-testid":`connect-ai-tool-made`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:`Paste this into a terminal for Claude Code`}),(0,B.jsx)(`p`,{className:`text-xs text-warn`,children:`Treat it like a password — the tool keeps it in its own settings file, and Revoke below is what ends it. You can see it again later: Share on its line, then Reveal key with your password.`}),(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(`pre`,{className:`min-w-0 flex-1 overflow-x-auto whitespace-pre-wrap break-all rounded bg-surface p-2 font-mono text-xs`,"data-testid":`connect-ai-tool-command`,children:e.command}),(0,B.jsxs)(U,{size:`sm`,onClick:()=>{XI(e.command).then(e=>{e&&r(!0)})},"data-testid":`connect-ai-tool-copy`,children:[(0,B.jsx)(H.Copy,{className:`w-3.5 h-3.5`}),n?`Copied`:`Copy`]})]}),(0,B.jsxs)(`details`,{className:`text-xs text-fg-muted`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer`,children:`Another MCP client`}),(0,B.jsxs)(`div`,{className:`mt-1 space-y-1`,children:[(0,B.jsxs)(`div`,{children:[`Streamable HTTP URL: `,(0,B.jsx)(`code`,{className:`break-all`,children:e.mcpUrl})]}),(0,B.jsxs)(`div`,{children:[`Header: `,(0,B.jsx)(`code`,{className:`break-all`,children:e.header})]})]})]}),(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:t,"data-testid":`connect-ai-tool-done`,children:`Done`})]})}function uAe({projects:e,onCancel:t,onCreated:n}){let{api:r,state:i}=V(),[a,o]=(0,v.useState)(`Claude Code`),[s,c]=(0,v.useState)(`all`),[l,u]=(0,v.useState)([]),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(`hour`),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),w=(0,v.useMemo)(()=>{let e=d.trim().toLowerCase();return i.sessions.filter(t=>!e||Gv(t).toLowerCase().includes(e)).slice(0,200)},[i.sessions,d]),T=s===`all`?{kind:`all`}:s===`chats`?l.length>0?{kind:`chats`,chatIds:l}:null:p?{kind:`project`,projectId:p}:null,E=!!(T&&a.trim()&&_&&!b),D=async()=>{if(!(!E||!T||!r.createAiToolGrant)){x(!0),C(null);try{let e=await r.createAiToolGrant({toolName:a.trim(),scope:T,lifetime:h,password:_});y(``),n(e)}catch(e){C(Kv(e))}finally{x(!1)}}},O=e=>u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,B.jsxs)(`div`,{className:`space-y-3 rounded-md border border-border p-2`,"data-testid":`connect-ai-tool-form`,children:[(0,B.jsxs)(`label`,{className:`block`,children:[(0,B.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Tool name`}),(0,B.jsx)(`input`,{className:pC,value:a,maxLength:60,onChange:e=>o(e.target.value),"data-testid":`connect-ai-tool-name`})]}),(0,B.jsxs)(`fieldset`,{children:[(0,B.jsx)(`legend`,{className:`text-xs text-fg-muted`,children:`What it may read`}),(0,B.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-3`,children:[[`all`,`All chats`],[`chats`,`Chosen chats`],[`project`,`One project`]].map(([e,t])=>(0,B.jsxs)(`label`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`connect-ai-tool-scope`,checked:s===e,onChange:()=>c(e),"data-testid":`connect-ai-tool-scope-${e}`}),t]},e))}),s===`chats`?(0,B.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,B.jsx)(`input`,{className:pC,placeholder:`Filter chats`,value:d,onChange:e=>f(e.target.value)}),(0,B.jsx)(`div`,{className:`max-h-48 overflow-y-auto rounded-md border border-border`,children:w.length===0?(0,B.jsx)(`div`,{className:`p-2 text-xs text-fg-faint`,children:`No chats.`}):w.map(e=>(0,B.jsxs)(`label`,{className:`flex items-center gap-2 px-2 py-1 text-xs hover:bg-surface-2`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:l.includes(e.id),onChange:()=>O(e.id),"data-testid":`connect-ai-tool-chat-${e.id}`}),(0,B.jsx)(`span`,{className:`truncate`,children:Gv(e)})]},e.id))}),(0,B.jsxs)(`div`,{className:`text-xs text-fg-faint`,children:[l.length,` chosen`]})]}):null,s===`project`?(0,B.jsxs)(`select`,{className:z(mC,`mt-2`),value:p,onChange:e=>m(e.target.value),"data-testid":`connect-ai-tool-project`,children:[(0,B.jsx)(`option`,{value:``,children:`Pick a project…`}),e.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]}):null]}),(0,B.jsxs)(`label`,{className:`block`,children:[(0,B.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`For how long`}),(0,B.jsx)(`select`,{className:mC,value:h,onChange:e=>g(e.target.value),"data-testid":`connect-ai-tool-lifetime`,children:Object.keys(R5).map(e=>(0,B.jsx)(`option`,{value:e,children:R5[e]},e))})]}),(0,B.jsxs)(`label`,{className:`block`,children:[(0,B.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Account password — to say it is you`}),(0,B.jsx)(`input`,{type:`password`,className:pC+` max-w-[16rem]`,placeholder:`Account password`,value:_,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&D()},"data-testid":`connect-ai-tool-password`})]}),S?(0,B.jsx)(`div`,{className:`text-xs text-danger`,"data-testid":`connect-ai-tool-error`,children:S}):null,(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(U,{variant:`primary`,onClick:()=>void D(),disabled:!E,busy:b,"data-testid":`connect-ai-tool-create`,children:`Connect`}),(0,B.jsx)(U,{variant:`ghost`,onClick:t,children:`Cancel`})]})]})}var z5=new Map,B5=0;function dAe(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,`0`)}function V5(e){return[e.summaryId,e.language,e.voiceKey,dAe(e.text)].join(`|`)}function fAe(e,t){let n=V5(e),r=z5.get(n);return r&&(z5.delete(n),r.clips.length!==t&&(U5(r),r=void 0)),r??={key:n,clips:Array(t).fill(void 0),bytes:0},z5.set(n,r),H5(n),r}function pAe(e,t,n,r){let i=e.clips[t];i&&(W5(i.url),e.bytes-=i.bytes);let a={url:mAe(n),bytes:n.byteLength,...r};return e.clips[t]=a,e.bytes+=a.bytes,z5.delete(e.key),z5.set(e.key,e),H5(e.key),a}function H5(e){let t=0;for(let e of z5.values())t+=e.bytes;for(let[n,r]of z5){if(z5.size<=8&&t<=50331648)return;n!==e&&(z5.delete(n),t-=r.bytes,U5(r))}}function U5(e){for(let t of e.clips)t&&W5(t.url)}function mAe(e){return typeof URL<`u`&&typeof URL.createObjectURL==`function`?URL.createObjectURL(new Blob([e],{type:`audio/wav`})):(B5+=1,`clip:${B5}`)}function W5(e){if(e.startsWith(`blob:`))try{URL.revokeObjectURL(e)}catch{}}var G5=()=>new Audio,K5=1e-6,hAe=class{#e;#t;#n;#r;#i;#a=new Set;#o;#s=[``,``];#c=0;#l;#u=`idle`;#d;#f=0;#p=0;#m=null;#h=null;#g=0;#_=!1;#v=!1;#y=!1;#b=!1;constructor(e){this.#e=e.tts,this.#t=e.voiceId,this.#n=e.language,this.#r=e.entry,this.#d=lm(e.rate??1),this.#i=e.errorText??(e=>e instanceof Error&&e.message?e.message:String(e));let t=e.timeline;e.entry.clips.forEach((e,n)=>{e&&(t=Zp(t,n,e.seconds,e))}),this.#l=t,this.#o=[G5(),G5()];for(let e of this.#o)e.playbackRate=this.#d,e.preservesPitch=!0}get timeline(){return this.#l}snapshot(){let e=this.#l,t=this.#C(),n=-1;return e.words.length>0&&(n=this.#m??(this.#u===`ended`?e.words.length-1:Math.max(0,$p(e,t+K5)))),{status:this.#u,currentSec:t,durationSec:e.totalSec,durationExact:e.complete||this.#r.clips.every(Boolean),wordIndex:n,sentenceIndex:n>=0?e.words[n].sentence:Qp(e,t),rate:this.#d,error:this.#h}}subscribe(e){return this.#a.add(e),()=>this.#a.delete(e)}#x(){for(let e of[...this.#a])e()}#S(e){this.#u=e,this.#x()}#C(){let e=this.#l;if(this.#u===`ended`)return e.totalSec;if(this.#m!==null)return em(e,this.#m);let t=e.sentences[this.#f];if(!t)return 0;let n=this.#u===`playing`?this.#o[this.#c].currentTime||0:this.#p;return t.startSec+Math.max(0,Math.min(n,t.durationSec))}#w(){let e=this.#l.sentences.length;for(let t=0;t<e;t+=1){let n=(this.#f+t)%e;if(!this.#r.clips[n])return n}return-1}#T(){if(!this.#_||this.#v||this.#y||this.#b)return;let e=this.#w();if(e<0)return;let t=this.#l.sentences[e];this.#v=!0,(async()=>{try{let n=await this.#e.speak({voiceId:this.#t,text:Bp(t.spoken,this.#n),speed:1}),r=n.sampleRate>0?n.samples.length/n.sampleRate:0,i=im(n.samples,n.sampleRate);if(pAe(this.#r,e,Ly(n.samples,n.sampleRate),{seconds:r,...i}),this.#v=!1,this.#b)return;this.#l=Zp(this.#l,e,r,i),this.#u===`buffering`&&e===this.#f?this.#D(this.#f):this.#u===`playing`&&e===this.#f+1&&this.#O(),this.#x(),this.#T()}catch(e){if(this.#v=!1,this.#b)return;this.#E(this.#i(e))}})()}#E(e){this.#y=!0,this.#g+=1,this.#u===`playing`&&(this.#p=this.#o[this.#c].currentTime||0);for(let e of this.#o)e.pause();this.#h=e,this.#S(`error`)}#D(e){let t=++this.#g;this.#f=e;let n=this.#r.clips[e];if(!n){for(let e of this.#o)e.pause();this.#u!==`buffering`&&this.#S(`buffering`),this.#T();return}if(this.#m!==null){let t=this.#l.sentences[e];this.#p=em(this.#l,this.#m)-t.startSec,this.#m=null}let r=Math.max(0,Math.min(this.#p,Math.max(0,n.seconds-.01))),i=this.#c,a=this.#o[i];this.#o[+(i===0)].pause(),this.#s[i]!==n.url&&(a.src=n.url,this.#s[i]=n.url),a.currentTime=r,a.playbackRate=this.#d,a.preservesPitch=!0,a.onended=()=>{t===this.#g&&this.#k(e)},a.onerror=()=>{t===this.#g&&this.#E(`This window could not play the voice’s audio.`)},this.#p=r;let o=e=>{t!==this.#g||e instanceof Error&&e.name===`AbortError`||this.#E(`This window could not play the voice’s audio${e instanceof Error&&e.message?` (${e.message})`:``}.`)};try{a.play()?.catch?.(o)}catch(e){queueMicrotask(()=>o(e))}this.#O(),this.#u===`playing`?this.#x():this.#S(`playing`)}#O(){let e=this.#r.clips[this.#f+1],t=+(this.#c===0);!e||this.#s[t]===e.url||(this.#o[t].src=e.url,this.#s[t]=e.url)}#k(e){let t=this.#l.sentences.length;if(e+1>=t){this.#g+=1,this.#f=t-1,this.#p=this.#l.sentences[t-1]?.durationSec??0,this.#S(`ended`);return}this.#c=+(this.#c===0),this.#p=0,this.#D(e+1)}play(){if(!(this.#b||this.#u===`playing`||this.#u===`buffering`)){if(this.#l.sentences.length===0){this.#S(`ended`);return}this.#u===`ended`&&(this.#f=0,this.#p=0,this.#m=null),this.#u===`error`&&(this.#y=!1,this.#h=null),this.#_=!0,this.#D(this.#f),this.#T()}}pause(){if(this.#u===`playing`||this.#u===`buffering`){this.#u===`playing`&&(this.#p=this.#o[this.#c].currentTime||0),this.#g+=1;for(let e of this.#o)e.pause();this.#S(`paused`)}}toggle(){this.#u===`playing`||this.#u===`buffering`?this.pause():this.play()}#A(e,t,n){let r=this.#u===`playing`||this.#u===`buffering`;if(this.#g+=1,this.#u===`playing`&&this.#o[this.#c].pause(),this.#f=e,this.#p=t,this.#m=n,r){this.#D(e),this.#T();return}if(this.#m!==null&&this.#r.clips[e]){let t=this.#l.sentences[e];this.#p=em(this.#l,this.#m)-t.startSec,this.#m=null}this.#S(this.#u===`idle`?`idle`:this.#u===`error`?`error`:`paused`)}seek(e){let t=this.#l;if(t.sentences.length===0)return;let n=Math.max(0,Math.min(t.totalSec,e)),r=Qp(t,n),i=t.sentences[r];if(this.#r.clips[r]){this.#A(r,n-i.startSec,null);return}let a=$p(t,n+K5),o=a>=i.wordFrom&&a<i.wordTo?a:i.wordTo>i.wordFrom?i.wordFrom:null;this.#A(r,n-i.startSec,o)}seekWord(e){let t=this.#l;if(t.words.length===0)return;let n=t.words[Math.max(0,Math.min(e,t.words.length-1))],r=t.sentences[n.sentence];this.#r.clips[n.sentence]?this.#A(n.sentence,n.startSec-r.startSec,null):this.#A(n.sentence,0,n.index)}skip(e){this.seek(nm(this.#l,this.#C(),e))}nextSentence(){let e=this.#l.sentences[this.#f+1];e&&this.#A(e.index,0,null)}prevSentence(){let e=this.#l,t=Qp(e,rm(e,this.#C())+K5);this.#A(Math.max(0,t),0,null)}setRate(e){let t=lm(e);if(t!==this.#d){this.#d=t;for(let e of this.#o)e.playbackRate=t,e.preservesPitch=!0;this.#x()}}destroy(){if(!this.#b){this.#b=!0,this.#g+=1;for(let e of this.#o)e.onended=null,e.onerror=null,e.pause();this.#u=`idle`,this.#a.clear()}}};function gAe(e){let t=e.now??(()=>Date.now()),n=-1/0,r=0,i=null,a=new Set,o=(e,t)=>{let n=setTimeout(()=>{a.delete(n),e()},t);a.add(n)},s=(a,s)=>{let c=r,l=e.synth.getVoices().find(t=>t.voiceURI===e.voiceURI)??null,u=e.makeUtterance(a);l&&(u.voice=l),u.lang=l?.lang??e.bcp47,u.rate=s.rate;let d=!1,f=()=>!d&&c===r,p=()=>{d=!0,i===u&&(i=null)};u.onstart=()=>{f()&&s.onStart()},u.onboundary=e=>{f()&&(e.name===void 0||e.name===`word`)&&typeof e.charIndex==`number`&&s.onBoundary(e.charIndex)},u.onend=()=>{f()&&(p(),s.onEnd())},u.onerror=e=>{f()&&(p(),e.error!==`interrupted`&&e.error!==`canceled`&&s.onError(Error(`The system voice failed: ${e.error??`unknown error`}`)))},o(()=>{f()&&(p(),e.synth.cancel(),n=t(),s.onEnd())},Fy(a,s.rate)),i=u,e.synth.speak(u)};return{queueAhead:!1,speak(e,i){let a=n+50-t();if(a>0){let t=r;o(()=>{t===r&&s(e,i)},a);return}s(e,i)},stop(){r+=1,i=null;for(let e of a)clearTimeout(e);a.clear();try{e.synth.cancel()}catch{}return n=t(),new Promise(e=>setTimeout(e,50))}}}var q5=e=>typeof requestAnimationFrame==`function`?requestAnimationFrame(e):setTimeout(()=>e(Date.now()),16),_Ae=e=>{typeof cancelAnimationFrame==`function`?cancelAnimationFrame(e):clearTimeout(e)};function vAe(e){let[,t]=(0,v.useReducer)(e=>e+1,0);return(0,v.useEffect)(()=>{if(!e)return;let n=0,r=!1,i=-2,a=0,o=s=>{let c=e.snapshot();if(c.status!==`playing`&&c.status!==`buffering`){r=!1,t();return}(c.wordIndex!==i||s-a>=250)&&(i=c.wordIndex,a=s,t()),n=q5(o)},s=()=>{t();let i=e.snapshot();!r&&(i.status===`playing`||i.status===`buffering`)&&(r=!0,n=q5(o))},c=e.subscribe(s);return s(),()=>{c(),r&&_Ae(n)}},[e]),e?e.snapshot():null}function yAe({summaries:e,loaded:t,selectedId:n,changed:r,notice:i,error:a,locked:o,onSelect:s,onDelete:c}){let l=sm(e);return(0,B.jsxs)(`section`,{"data-testid":`voice-summaries`,children:[(0,B.jsx)(`h3`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Summaries`}),a?(0,B.jsx)(`p`,{className:`text-xs text-danger`,children:a}):null,t&&l.length===0?(0,B.jsx)(`p`,{className:`text-fg-muted`,"data-testid":`voice-no-summaries`,children:wm.noSummaries}):null,l.length>0&&r?(0,B.jsx)(`p`,{className:`mb-1 text-xs text-fg-muted`,"data-testid":`voice-changed`,children:wm.changedSinceNewest}):null,(0,B.jsx)(`ul`,{className:`flex max-h-44 flex-col gap-1 overflow-y-auto`,children:l.map(e=>{let t=n===e.id,r=Iy(e.createdAt);return(0,B.jsxs)(`li`,{"data-testid":`voice-summary-row`,className:z(`flex items-start gap-2 rounded-md border px-2 py-1.5`,t?`border-accent bg-accent/10`:`border-border`),children:[(0,B.jsx)(`input`,{type:`radio`,name:`voice-summary`,className:`mt-1`,"aria-label":`Summary of ${r}`,checked:t,disabled:o,onChange:()=>s(e.id)}),(0,B.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 flex-col items-start text-left`,disabled:o,onClick:()=>s(e.id),children:[(0,B.jsxs)(`span`,{className:`font-medium`,children:[r,e.current?(0,B.jsx)(`span`,{className:`ml-2 rounded-full bg-accent/15 px-1.5 text-xs text-accent`,children:wm.current}):null]}),(0,B.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[e.words,` words · about `,ree(e.seconds),` ·`,` `,xm(e).map(e=>e.toUpperCase()).join(` `),` `,`· `,e.cost.model??`the chat’s model`,` · `,Cm(e.cost)]})]}),(0,B.jsx)(U,{size:`sm`,onClick:()=>c(e.id),disabled:o,"aria-label":`Delete the summary of ${r}`,"data-testid":`voice-summary-delete`,children:(0,B.jsx)(H.Trash,{className:`h-3.5 w-3.5`})})]},e.id)})}),i?(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,"data-testid":`voice-notice`,children:i}):null]})}function bAe(e){switch(e?.status){case`buffering`:return`Getting the voice ready…`;case`paused`:return`Paused.`;case`ended`:return`Done.`;case`playing`:return`Playing.`;default:return``}}function J5({label:e,onClick:t,disabled:n,children:r,testId:i,primary:a}){return(0,B.jsx)(`button`,{type:`button`,"aria-label":e,title:e,onClick:t,disabled:n,"data-testid":i,className:z(`inline-flex items-center justify-center rounded-full disabled:opacity-40`,a?`h-9 w-9 bg-accent text-accent-fg hover:opacity-90`:`h-8 min-w-8 px-1.5 text-fg-muted hover:bg-surface-2 hover:text-fg`),children:r})}function xAe({player:e,snapshot:t,speed:n,onSpeed:r}){let i=t,a=!e||!i,o=i?.status===`playing`||i?.status===`buffering`,s=i?.currentSec??0,c=i?.durationSec??0,l=i&&!i.durationExact?`~`:``,u=`${am(s)} / ${l}${am(c)}`;return(0,B.jsxs)(`section`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface-2 px-3 py-2`,"data-testid":`voice-player`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`input`,{type:`range`,"aria-label":`Position`,"aria-valuetext":`${am(s)} of ${l}${am(c)}`,className:`min-w-0 flex-1`,min:0,max:Math.max(.1,c),step:.1,value:Math.min(s,Math.max(.1,c)),disabled:a,onChange:t=>e?.seek(Number(t.target.value)),"data-testid":`voice-position`}),(0,B.jsx)(`span`,{className:`shrink-0 tabular-nums text-xs text-fg-muted`,"data-testid":`voice-clock`,children:u})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,B.jsx)(J5,{label:`Previous sentence`,onClick:()=>e?.prevSentence(),disabled:a,testId:`voice-prev`,children:(0,B.jsx)(H.SkipBack,{className:`h-4 w-4`})}),(0,B.jsx)(J5,{label:`Back 10 seconds`,onClick:()=>e?.skip(-10),disabled:a,testId:`voice-back`,children:(0,B.jsxs)(`span`,{className:`text-xs font-medium`,children:[`−`,10,`s`]})}),(0,B.jsx)(J5,{label:o?`Pause`:`Play`,onClick:()=>e?.toggle(),disabled:a,testId:`voice-toggle`,primary:!0,children:o?(0,B.jsx)(H.Pause,{className:`h-4 w-4`}):(0,B.jsx)(H.Play,{className:`h-4 w-4`})}),(0,B.jsx)(J5,{label:`Forward 10 seconds`,onClick:()=>e?.skip(10),disabled:a,testId:`voice-forward`,children:(0,B.jsxs)(`span`,{className:`text-xs font-medium`,children:[`+`,10,`s`]})}),(0,B.jsx)(J5,{label:`Next sentence`,onClick:()=>e?.nextSentence(),disabled:a,testId:`voice-next`,children:(0,B.jsx)(H.SkipForward,{className:`h-4 w-4`})}),(0,B.jsxs)(`span`,{className:`ml-1 flex items-center gap-1 text-xs text-fg-muted`,"aria-live":`polite`,"data-testid":`voice-player-status`,children:[i?.status===`buffering`?(0,B.jsx)(H.Spinner,{className:`h-3.5 w-3.5`}):null,bAe(i)]}),(0,B.jsxs)(`label`,{className:`ml-auto flex items-center gap-2 text-xs text-fg-muted`,children:[(0,B.jsxs)(`span`,{className:`tabular-nums`,children:[`Speed ×`,n.toFixed(2)]}),(0,B.jsx)(`input`,{type:`range`,"aria-label":`Speed`,min:cm,max:2,step:.05,value:n,onChange:e=>r(Number(e.target.value))})]})]})]})}var SAe=(0,v.memo)(function({index:e,text:t,current:n,onPick:r}){return(0,B.jsx)(`span`,{"data-word":e,"data-current":n?`true`:void 0,onClick:()=>r(e),className:z(`cursor-pointer rounded-sm hover:bg-accent/10`,n&&`bg-accent/20 text-fg`),children:t})});function CAe({text:e,timeline:t,wordIndex:n,onPickWord:r,dir:i,lang:a}){let o=(0,v.useRef)(null),s=(0,v.useRef)(0),c=(0,v.useRef)(0),l=(0,v.useRef)(r);l.current=r;let u=(0,v.useMemo)(()=>e=>l.current(e),[]),d=t&&t.text===e?t.words.length:-1,f=(0,v.useMemo)(()=>{if(!t||d<0)return null;let n=[],r=0;for(let i of t.words)n.push({gap:e.slice(r,i.start),word:{index:i.index,text:e.slice(i.start,i.end)}}),r=i.end;return n.push({gap:e.slice(r),word:null}),n},[d,e]);(0,v.useEffect)(()=>{if(n<0||!o.current||Date.now()-s.current<4e3)return;let e=o.current.querySelector(`[data-word="${n}"]`);e&&(c.current=Date.now(),e.scrollIntoView({block:`nearest`}))},[n]);let p=()=>{s.current=Date.now()},m=e;return f&&(m=f.map((e,t)=>(0,B.jsx)(wAe,{gap:e.gap,word:e.word,current:e.word?.index===n,onPick:u},t))),(0,B.jsx)(`p`,{ref:o,className:`max-h-64 overflow-y-auto whitespace-pre-wrap rounded-md border border-border bg-surface-2 px-3 py-2 leading-relaxed`,"data-testid":`voice-summary-text`,dir:i,lang:a,onWheel:p,onTouchMove:p,onScroll:()=>{Date.now()-c.current>200&&p()},children:m})}var wAe=(0,v.memo)(function({gap:e,word:t,current:n,onPick:r}){return(0,B.jsxs)(B.Fragment,{children:[e,t?(0,B.jsx)(SAe,{index:t.index,text:t.text,current:n,onPick:r}):null]})});function Y5(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 X5(e,t,n){let[r,i]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(!e||n!==`linux`||!t?.installCommand)return;let r=!0;return t.installCommand().then(e=>r&&i(typeof e==`string`&&e.trim()?e:null),()=>r&&i(null)),()=>{r=!1}},[e,t,n]),r}function Z5(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 TAe(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`SELECT`||t===`TEXTAREA`||e.isContentEditable||e.getAttribute(`contenteditable`)===`true`}function EAe({open:e,onClose:t}){let{state:n,api:r}=V(),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=jy(typeof window<`u`?window.oonacode?.platform:null,typeof navigator<`u`?navigator.userAgent:null),[c,l]=(0,v.useState)(()=>Sy()),[u,d]=(0,v.useState)(null),f=Y5(e),p=X5(e,o,s),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)({kind:`idle`}),[C,w]=(0,v.useState)(null),T=(0,v.useRef)(null),[E,D]=(0,v.useState)(null),O=(0,v.useRef)(null),k=(0,v.useRef)(null),A=(0,v.useRef)(null),j=(0,v.useRef)(c.speed);j.current=c.speed;let ee=vAe(E),M=$f(c.language)??$f(`en`),te=(0,v.useCallback)(e=>{l(t=>{let n={...t,...e};return Cy(n),n})},[]),ne=(0,v.useMemo)(()=>m?.summaries??[],[m]),N=ne.find(e=>e.id===y)??ne[0]??null,P=(0,v.useCallback)(async()=>{if(!i||!r.listVoiceSummaries)return null;try{let e=await r.listVoiceSummaries(i),t={...e,summaries:sm(e.summaries)};return h(t),_(null),t}catch(e){return _(Z5(e)),null}},[r,i]);(0,v.useEffect)(()=>{e&&(h(null),b(null),w(null),S({kind:`idle`}),P(),o?(d(null),o.listVoices().then(d,()=>d([]))):d([]))},[e,P,o]);let re=a?`${a.entryCount}:${a.mtime}`:null,ie=(0,v.useRef)(null),ae=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!e){ie.current=null;return}if(ie.current===null){ie.current=re;return}re!==ie.current&&(ie.current=re,!ae.current&&(ae.current=setTimeout(()=>{ae.current=null,P()},800)))},[e,re,P]),(0,v.useEffect)(()=>()=>{ae.current&&clearTimeout(ae.current),ae.current=null},[]);let oe=(0,v.useCallback)(()=>{T.current?.abort(),T.current=null,A.current=null,O.current?.destroy(),O.current=null,k.current=null,D(null)},[]);(0,v.useEffect)(()=>{e||oe()},[e,oe]),(0,v.useEffect)(()=>()=>oe(),[oe]);let se=(0,v.useMemo)(()=>ky(M,u??[],f),[M,u,f]),F=Ay(se,c.localVoice[M.code]),ce=!!(o&&u&&!u.some(e=>e.engine===`espeak`)),le=x.kind===`summarising`||x.kind===`translating`,ue=!!(r.listVoiceSummaries&&r.createVoiceSummary),de=typeof window<`u`&&!!window.speechSynthesis,fe=N?Sm(N,M.code):null,pe=F?.key??null,me=F?.kind??null,he=N?.id??null,ge=(0,v.useMemo)(()=>{if(!he||fe===null||!pe||!me)return null;let e=Ty({key:pe,kind:me,label:``}),t,n;if(e&&o)t=`clip`,n=e;else if(me===`system`&&de)t=`system`,n=pe.slice(7);else return null;let r={summaryId:he,language:M.code,voiceKey:pe,text:fe};return{key:V5(r),...r,bcp47:M.bcp47,kind:t,voiceId:n}},[he,fe,pe,me,o,de,M]);(0,v.useEffect)(()=>{if(!e||(ge?.key??null)===(k.current?.key??null))return;let t=O.current,n=k.current,r=t?.snapshot()??null;if(t?.destroy(),O.current=null,k.current=ge,!ge){D(null);return}let i=Yp(ge.text,{language:ge.language}),a;a=ge.kind===`clip`&&o?new hAe({tts:o,voiceId:ge.voiceId,language:ge.language,timeline:i,entry:fAe(ge,i.sentences.length),rate:j.current,errorText:Z5}):new um(gAe({synth:window.speechSynthesis,makeUtterance:e=>new SpeechSynthesisUtterance(e),voiceURI:ge.voiceId,bcp47:ge.bcp47}),i,{mode:Py(s),rate:j.current});let c=!1;if(t&&n&&r){let e=r.status===`playing`||r.status===`buffering`;n.summaryId===ge.summaryId&&n.language===ge.language&&n.text===ge.text?(r.wordIndex>=0&&r.status!==`ended`&&a.seekWord(r.wordIndex),c=e):n.summaryId===ge.summaryId&&(c=e)}A.current===ge.key&&(A.current=null,c=!0),O.current=a,D(a),c&&a.play()},[e,ge,o,s]);let _e=async()=>{if(!i||!r.createVoiceSummary)return null;S({kind:`summarising`});let e=await r.createVoiceSummary(i,{words:c.words});return w(e.created?null:wm.unchanged(Iy(e.summary.createdAt))),b(e.summary.id),await P(),e.summary},ve=async()=>{if(!i)return;T.current?.abort();let e=new AbortController;T.current=e;let t=e.signal;A.current=null;try{let e=bm(m,y)?await _e():N;if(t.aborted)return;if(!e)throw Error(`There is no summary to play.`);let n=Sm(e,M.code);if(n===null){if(!r.translateVoiceSummary)throw Error(`This host cannot translate yet.`);S({kind:`translating`});let a=await r.translateVoiceSummary(i,e.id,{language:M.code});if(h(t=>DAe(t,e.id,a.translation)),t.aborted)return;n=a.translation.text,P()}if(!n.trim())throw Error(`There was nothing to read.`);if(!F||F.kind===`system`&&!de)throw Error(F?`This window has no system speech.`:Ny(M,!!o,s,ce,p));S({kind:`idle`});let a=V5({summaryId:e.id,language:M.code,voiceKey:F.key,text:n});k.current?.key===a&&O.current?O.current.play():A.current=a}catch(e){if(t.aborted)return;S({kind:`error`,message:Z5(e)})}finally{T.current===e&&(T.current=null)}},ye=()=>{T.current?.abort(),T.current=null,A.current=null,le&&S({kind:`idle`}),O.current?.pause()},be=e=>{e!==N?.id&&(O.current?.pause(),w(null),b(e))},xe=async e=>{if(!(!i||!r.deleteVoiceSummary))try{await r.deleteVoiceSummary(i,e),y===e&&b(null),await P()}catch(e){S({kind:`error`,message:Z5(e)})}},Se=e=>{let t=ip(e);te({speed:t}),O.current?.setRate(t)};if((0,v.useEffect)(()=>{if(!e)return;let t=e=>{let t=O.current;if(!t||e.altKey||e.ctrlKey||e.metaKey||TAe(e.target))return;let n=e.target instanceof Element?e.target:null;if(!(n&&n!==document.body&&!n.closest(`[aria-label="Listen to this chat"]`))){if(e.key===` `||e.key===`Spacebar`){if(n?.closest(`button`))return;e.preventDefault(),t.toggle()}else if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let n=e.key===`ArrowRight`;e.shiftKey?n?t.nextSentence():t.prevSentence():t.skip(n?10:-10)}}};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]),!e)return null;let Ce=a?dd(a):`this chat`,we=N?xm(N):[],Te=new Set(we),Ee=fe??N?.text??null,De=ee?.status===`error`?ee.error:null,Oe=ee?.status===`playing`||ee?.status===`buffering`,ke=E&&k.current?.text===Ee?E.timeline:null;return(0,B.jsx)(gC,{open:e,title:`Listen to this chat`,onClose:t,wide:!0,footer:(0,B.jsxs)(B.Fragment,{children:[le||Oe?(0,B.jsxs)(U,{onClick:ye,"data-testid":`voice-stop`,children:[(0,B.jsx)(H.Stop,{className:`h-4 w-4`}),` Stop`]}):null,(0,B.jsxs)(U,{variant:`primary`,onClick:()=>void ve(),disabled:le||!ue||!i,"data-testid":`voice-play`,children:[(0,B.jsx)(H.Play,{className:`h-4 w-4`}),` Play`]}),(0,B.jsx)(U,{onClick:t,children:`Close`})]}),children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm`,children:[ue?null:(0,B.jsx)(`p`,{className:`text-danger`,children:`This version of the host cannot make voice summaries.`}),(0,B.jsx)(yAe,{summaries:ne,loaded:m!==null,selectedId:N?.id??null,changed:bm(m,y),notice:C,error:g,locked:le,onSelect:be,onDelete:e=>void xe(e)}),(0,B.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`A spoken summary of `,(0,B.jsx)(`span`,{className:`font-medium text-fg`,children:Ce}),` — 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 `,ep.label,` on your OonaCode credits and kept with the summary.`]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,B.jsx)(fC,{label:`Language`,children:(0,B.jsx)(`select`,{"aria-label":`Language`,className:mC,value:M.code,disabled:le,onChange:e=>te({language:e.target.value}),children:Qf.map(e=>{let t=e.name===e.native?e.name:`${e.name} — ${e.native}`;return(0,B.jsx)(`option`,{value:e.code,children:Te.has(e.code)?`${t} ✓`:t},e.code)})})}),o&&u===null?(0,B.jsx)(`p`,{className:`px-1 py-2 text-fg-muted`,"data-testid":`voice-loading`,children:`Looking for this PC’s voices…`}):se.length>0?(0,B.jsx)(fC,{label:`Voice`,children:(0,B.jsx)(`select`,{"aria-label":`Voice`,className:mC,value:F?.key??``,disabled:le,onChange:e=>te({localVoice:{...c.localVoice,[M.code]:e.target.value}}),children:se.map(e=>(0,B.jsx)(`option`,{value:e.key,children:e.label},e.key))})}):(0,B.jsx)(`p`,{className:`rounded-md border border-border bg-surface-2 px-3 py-2 text-fg-muted`,"data-testid":`no-local-voice`,children:Ny(M,!!o,s,ce,p)}),(0,B.jsx)(fC,{label:`Length of a new summary`,children:(0,B.jsxs)(`select`,{"aria-label":`Length of a new summary`,className:mC,value:String(c.words),disabled:le,onChange:e=>te({words:Number(e.target.value)}),children:[(0,B.jsx)(`option`,{value:`120`,children:`Short — about 120 words`}),(0,B.jsx)(`option`,{value:`200`,children:`Normal — about 200 words`}),(0,B.jsx)(`option`,{value:`300`,children:`Long — about 300 words`}),[120,200,300].includes(c.words)?null:(0,B.jsxs)(`option`,{value:String(c.words),children:[c.words,` words`]})]})})]}),(0,B.jsx)(OAe,{stage:x,playerError:De}),(0,B.jsx)(xAe,{player:E,snapshot:ee,speed:c.speed,onSpeed:Se}),N&&Ee!==null?(0,B.jsxs)(`section`,{children:[(0,B.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:wm.heading(M,fe!==null)}),we.length>1?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":`Languages it has`,children:we.map(e=>{let t=$f(e);if(!t)return null;let n=e===M.code;return(0,B.jsx)(`button`,{type:`button`,"aria-pressed":n,title:t.name===t.native?t.name:`${t.name} — ${t.native}`,disabled:le,onClick:()=>te({language:e}),"data-testid":`voice-lang-chip`,className:z(`rounded-full border px-2 py-0.5 text-xs`,n?`border-accent bg-accent/15 text-accent`:`border-border text-fg-muted hover:bg-surface-2`),children:e.toUpperCase()},e)})}):null]}),(0,B.jsx)(CAe,{text:Ee,timeline:ke,wordIndex:ee?.wordIndex??-1,onPickWord:e=>O.current?.seekWord(e),dir:fe!==null&&M.rtl?`rtl`:`ltr`,lang:fe===null?`en-US`:M.bcp47})]}):null]})})}function DAe(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 OAe({stage:e,playerError:t}){let n=e.kind===`error`?e.message:t;if(n)return(0,B.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:n});if(e.kind!==`summarising`&&e.kind!==`translating`)return null;let r=[{key:`summarising`,label:wm.generating},{key:`translating`,label:wm.translating}],i=r.findIndex(t=>t.key===e.kind);return(0,B.jsx)(`ol`,{className:`flex flex-wrap items-center gap-2 text-xs`,"data-testid":`voice-stage`,"aria-live":`polite`,children:r.map((e,t)=>(0,B.jsx)(`li`,{className:z(`rounded-full px-2 py-0.5`,t===i?`bg-accent/15 font-medium text-accent`:t<i?`text-fg-muted line-through`:`text-fg-faint`),children:e.label},e.key))})}function Q5(e){return _p(e).replace(/\n+/g,` `).trim()||e.trim()}function $5(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 kAe(e){return{sessionId:e.sessionId,title:e.title.trim()||`Untitled chat`,about:e.about}}function AAe(e){return e.filter(e=>!e.pending&&e.source!==`user`&&(!e.about||e.stale))}function jAe({open:e,picked:t}){let{api:n}=V(),r=(0,v.useRef)(n);r.current=n;let i=typeof window<`u`?window.oonacode?.tts:void 0,a=jy(typeof window<`u`?window.oonacode?.platform:null,typeof navigator<`u`?navigator.userAgent:null),[o,s]=(0,v.useState)(()=>Sy()),[c,l]=(0,v.useState)(null),u=Y5(e),d=X5(e,i,a),f=$f(o.language)??$f(`en`),p=(0,v.useMemo)(()=>ky(f,c??[],u),[f,c,u]),m=Ay(p,o.localVoice[f.code]),h=!!(i&&c&&!c.some(e=>e.engine===`espeak`)),[g,_]=(0,v.useState)(Gy),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(0),[C,w]=(0,v.useState)(!1),T=(0,v.useRef)({lang:f,voice:m,speed:o.speed,espeakMissing:h,installCommand:d,platform:a,tts:i});T.current={lang:f,voice:m,speed:o.speed,espeakMissing:h,installCommand:d,platform:a,tts:i};let E=(0,v.useCallback)(e=>{s(t=>{let n={...t,...e};return Cy(n),n})},[]),D=(0,v.useMemo)(()=>{let e=Jte();return new nne({words:async e=>{let{lang:t}=T.current;if(!e.about)return{name:Q5(e.title),body:[Yf(t.code)]};if(t.code===`en`)return{name:Q5(e.title),body:Sp(_p(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&&S(e=>e+1),{name:r.translation.name?Q5(r.translation.name):null,body:Sp(r.translation.text)}}catch(e){throw Error(`could not translate it: ${$5(e)}`)}},speak:(t,{signal:n,onItem:r})=>{let i=T.current;return rne(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,installCommand:i.installCommand,prepare:Bp,signal:n,onItem:r})},silence:()=>{e.stop();try{typeof window<`u`&&window.speechSynthesis?.cancel()}catch{}},onState:_})},[]);(0,v.useEffect)(()=>{if(!e){D.reset();return}s(Sy()),i?(l(null),i.listVoices().then(l,()=>l([]))):l([])},[e,i,D]),(0,v.useEffect)(()=>()=>D.dispose(),[D]),(0,v.useEffect)(()=>{D.resetWords()},[f.code,D]);let O=t.map(e=>`${e.sessionId}\u0000${e.title}\u0000${e.about??``}`).join(``);(0,v.useEffect)(()=>{w(!1)},[O,f.code]),(0,v.useEffect)(()=>{let r=n.planChatAboutTranslations;if(!e||f.code===`en`||t.length===0||!r){b(null);return}let i=!0;return r({language:f.code,sessionIds:t.map(e=>e.sessionId)}).then(e=>i&&b(e),()=>i&&b(null)),()=>{i=!1}},[e,f.code,O,x,n]);let k=g.status===`preparing`||g.status===`speaking`,A=f.code!==`en`&&y!==null&&y.language===f.code&&y.needed>Hf.confirmAbove,j=(0,v.useCallback)(()=>{w(!1),D.start(t.map(kAe),0)},[D,t]),ee=(0,v.useCallback)(()=>{if(t.length!==0){if(A&&!C){w(!0);return}j()}},[t.length,A,C,j]);return{prefs:o,update:E,lang:f,options:p,voice:m,espeakMissing:h,installCommand:d,voicesLoading:!!i&&c===null,desktop:!!i,platform:a,state:g,busy:k,active:$te(g),plan:y&&y.language===f.code?y:null,confirming:C,play:ee,start:j,cancelConfirm:()=>w(!1),pause:()=>D.pause(),resume:()=>D.resume(),stop:()=>D.stop(),next:()=>D.next(),previous:()=>D.previous(),jumpTo:e=>D.jumpTo(e),pickedCount:t.length}}function MAe({b:e,picked:t,enabled:n,generateAll:r,onGenerated:i}){let{api:a}=V(),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),u=AAe(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($5(e))}finally{s(!1)}}},h=e.busy;return(0,B.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,B.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Listen to the picked chats`}),(0,B.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 `,ep.label,` on your OonaCode credits and kept, so playing it again costs nothing.`]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,B.jsx)(fC,{label:`Language`,children:(0,B.jsx)(`select`,{"aria-label":`Language`,className:mC,value:e.lang.code,disabled:h,onChange:t=>e.update({language:t.target.value}),"data-testid":`briefing-language`,children:Qf.map(e=>(0,B.jsx)(`option`,{value:e.code,children:e.name===e.native?e.name:`${e.name} — ${e.native}`},e.code))})}),e.voicesLoading?(0,B.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,B.jsx)(fC,{label:`Voice`,children:(0,B.jsx)(`select`,{"aria-label":`Voice`,className:mC,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,B.jsx)(`option`,{value:e.key,children:e.label},e.key))})}):(0,B.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:Ny(e.lang,e.desktop,e.platform,e.espeakMissing,e.installCommand)}),(0,B.jsx)(fC,{label:`Speed ×${e.prefs.speed.toFixed(2)}`,children:(0,B.jsx)(`input`,{"aria-label":`Speed`,type:`range`,min:np.speed.min,max:np.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,B.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`briefing-cost`,children:[Zf(e.plan,e.lang.name),e.plan.needed>0?` — paid once, then kept.`:``]}):null,e.confirming&&e.plan?(0,B.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,B.jsxs)(`p`,{className:`basis-full`,children:[`Before playing: `,Zf(e.plan,e.lang.name),` — paid once from your OonaCode credits, then kept.`]}),(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:e.start,"data-testid":`briefing-confirm-play`,children:`Translate and play`}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:e.cancelConfirm,children:`Cancel`})]}):null,u.length>0&&a.generateChatAbouts?(0,B.jsxs)(`div`,{className:`space-y-1.5 text-xs`,"data-testid":`briefing-need-about`,children:[(0,B.jsx)(`p`,{className:`text-fg-muted`,children:Qte(d,f)}),(0,B.jsxs)(U,{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,B.jsx)(H.Refresh,{className:`h-3 w-3`}),` Write abouts for these first`]})]}):null,c?(0,B.jsx)(`p`,{className:`text-xs text-danger`,"data-testid":`briefing-write-error`,children:c}):null]})}function NAe({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,B.jsxs)(B.Fragment,{children:[r?(0,B.jsx)(`p`,{className:z(`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,B.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[(0,B.jsx)(U,{size:`sm`,onClick:e.previous,disabled:t.status===`error`,"aria-label":`Previous chat`,title:`Previous chat`,"data-testid":`briefing-previous`,children:(0,B.jsx)(H.SkipBack,{className:`h-3.5 w-3.5`})}),t.status===`paused`||t.status===`error`?(0,B.jsxs)(U,{size:`sm`,variant:`primary`,onClick:e.resume,"data-testid":`briefing-resume`,children:[(0,B.jsx)(H.Play,{className:`h-3.5 w-3.5`}),` `,t.status===`error`?`Try again`:`Resume`]}):(0,B.jsxs)(U,{size:`sm`,onClick:e.pause,"data-testid":`briefing-pause`,children:[(0,B.jsx)(H.Pause,{className:`h-3.5 w-3.5`}),` Pause`]}),(0,B.jsxs)(U,{size:`sm`,onClick:e.stop,"data-testid":`briefing-stop`,children:[(0,B.jsx)(H.Stop,{className:`h-3.5 w-3.5`}),` Stop`]}),(0,B.jsx)(U,{size:`sm`,onClick:e.next,disabled:t.status===`error`,"aria-label":`Next chat`,title:`Next chat`,"data-testid":`briefing-next`,children:(0,B.jsx)(H.SkipForward,{className:`h-3.5 w-3.5`})})]}):(0,B.jsxs)(U,{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,B.jsx)(H.Play,{className:`h-4 w-4`}),` Play `,e.pickedCount,` picked`]})]})}function PAe({open:e,onClose:t}){let{state:n,actions:r}=V(),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)(()=>Xte()),[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 Zte(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??mf.enabled,ee=async e=>{x(!0);try{await r.saveSettings({chatAboutEnabled:e})}finally{x(!1)}k()},M=async()=>{g(!0);try{let e=await r.generateAllChatAbouts();e&&f(e.generateAll)}finally{g(!1)}},te=async()=>{y(!0);try{let e=await r.stopGenerateAllChatAbouts();e&&f(e.generateAll)}finally{y(!1)}},ne=(0,v.useMemo)(()=>Kf(C.range,D,{from:C.from,to:C.to}),[C,D]),N=(0,v.useMemo)(()=>{let e=(a?.chats??[]).filter(e=>qf(e.updatedAt,ne)),t=e=>{let t=Date.parse(e.updatedAt);return Number.isFinite(t)?t:0};return[...e].sort((e,n)=>t(n)-t(e))},[a,ne]),P=(0,v.useMemo)(()=>{let e=p.trim().toLowerCase();return e?N.filter(t=>t.title.toLowerCase().includes(e)||(t.about??``).toLowerCase().includes(e)):N},[N,p]),re=(0,v.useMemo)(()=>P.map(e=>e.sessionId),[P]),ie=re.join(`,`);(0,v.useEffect)(()=>{E(e=>Wy(e,re))},[ie]);let ae=(0,v.useMemo)(()=>P.filter(e=>T.has(e.sessionId)),[P,T]),oe=Hy(re,T),se=(0,v.useRef)(null);(0,v.useEffect)(()=>{se.current&&(se.current.indeterminate=oe===`some`)});let F=jAe({open:e,picked:ae}),ce=F.active||F.state.status===`error`,le=(0,v.useMemo)(()=>new Set(F.state.playlist),[F.state.playlist]),ue=ce?F.state.sessionId:null,de=e=>E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),fe=Uf.find(e=>e.id===C.range)?.label??``,pe=(0,v.useCallback)(e=>n.sessions.find(t=>t.id===e)?.entryCount??null,[n.sessions]),me=a?If(a.totals):null,he=d?.running===!0;return(0,B.jsxs)(gC,{open:e,title:`What your chats are about`,onClose:t,wide:!0,footer:(0,B.jsxs)(B.Fragment,{children:[a!==null&&!s?(0,B.jsx)(NAe,{b:F}):null,(0,B.jsx)(U,{variant:`ghost`,onClick:t,children:`Close`})]}),children:[(0,B.jsxs)(`p`,{className:`mb-3 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,B.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,B.jsx)(uC,{label:`What your chats are about`,details:(0,B.jsx)(dC,{items:[...Vf.what,...Vf.when,...Vf.who,...Vf.yours,...Vf.where]})})]}),s?(0,B.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,B.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,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(`div`,{className:`rounded-md border border-border px-3`,children:(0,B.jsx)(_C,{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:[Vf.switch,...Vf.who],checked:j,disabled:b,onChange:e=>void ee(e),testId:`chat-abouts-switch`})}),me?(0,B.jsxs)(`div`,{className:`text-xs text-fg-muted`,"data-testid":`chat-abouts-totals`,children:[(0,B.jsx)(`span`,{className:`font-medium text-fg`,children:`All about calls so far: `}),(0,B.jsx)(`span`,{"data-testid":`chat-abouts-totals-line`,children:me.line}),me.unpriced?(0,B.jsx)(`span`,{className:`block text-fg-faint`,"data-testid":`chat-abouts-totals-unpriced`,children:me.unpriced}):null]}):null,(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,B.jsxs)(U,{size:`sm`,variant:`primary`,onClick:()=>void M(),busy:h,disabled:!j||he,title:j?Vf.generateAll:Vf.regenerateOff,"data-testid":`chat-abouts-generate-all`,children:[(0,B.jsx)(H.Refresh,{className:`h-3 w-3`}),` Generate for all chats now`]}),(0,B.jsx)(uC,{label:`Generate for all chats now`,details:Vf.generateAll})]}),he?(0,B.jsxs)(U,{size:`sm`,variant:`danger`,onClick:()=>void te(),busy:_,title:Vf.stop,"data-testid":`chat-abouts-stop`,children:[(0,B.jsx)(H.Stop,{className:`h-3 w-3`}),` Stop`]}):null]}),d?(0,B.jsx)(FAe,{g:d}):null,(0,B.jsx)(MAe,{b:F,picked:ae,enabled:j,generateAll:d,onGenerated:f}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`Last active`,(0,B.jsx)(`select`,{"aria-label":`Last active`,className:z(mC,`text-xs`),value:C.range,onChange:e=>A({range:e.target.value}),"data-testid":`chat-abouts-range`,children:Uf.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),C.range===`custom`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`From`,(0,B.jsx)(`input`,{type:`date`,"aria-label":`From`,className:z(pC,`text-xs`),value:C.from,onChange:e=>A({from:e.target.value}),"data-testid":`chat-abouts-from`})]}),(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`To`,(0,B.jsx)(`input`,{type:`date`,"aria-label":`To`,className:z(pC,`text-xs`),value:C.to,onChange:e=>A({to:e.target.value}),"data-testid":`chat-abouts-to`})]})]}):null,(0,B.jsx)(`input`,{className:z(pC,`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`})]}),P.length>0?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,B.jsxs)(`label`,{className:`inline-flex items-center gap-2 font-medium text-fg`,children:[(0,B.jsx)(`input`,{ref:se,type:`checkbox`,checked:oe===`all`,"aria-checked":oe===`some`?`mixed`:oe===`all`,onChange:()=>E(e=>Uy(re,e)),"data-testid":`chat-abouts-select-all`}),`Select all`]}),(0,B.jsxs)(`span`,{className:`text-fg-muted`,"data-testid":`chat-abouts-count`,children:[P.length,` chat`,P.length===1?``:`s`,ae.length>0?` · ${ae.length} picked`:``]})]}):null,a.chats.length===0?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-empty`,children:`No chats on this PC yet.`}):P.length===0?(0,B.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 ${fe.toLowerCase()}`}.`:`No chat was active in ${C.range===`custom`?`that range`:fe.toLowerCase()}.`}):(0,B.jsx)(`ul`,{className:`space-y-2`,"data-testid":`chat-abouts-list`,children:P.map(e=>(0,B.jsx)(IAe,{row:e,enabled:j,entryCount:pe(e.sessionId),checked:T.has(e.sessionId),onToggle:()=>de(e.sessionId),playing:ue===e.sessionId,onJump:ce&&le.has(e.sessionId)?()=>F.jumpTo(e.sessionId):null,onOpen:()=>{r.selectSession(e.sessionId)}},e.sessionId))})]})]})}function FAe({g:e}){let t=e.total>0?Math.round(Math.min(e.done,e.total)/e.total*100):100;return(0,B.jsxs)(`div`,{className:`space-y-1 text-xs`,"data-testid":`chat-abouts-progress`,children:[(0,B.jsx)(`div`,{className:`text-fg-muted`,"data-testid":`chat-abouts-progress-line`,children:Rf(e)}),(0,B.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,B.jsx)(`div`,{className:z(`h-full rounded-full`,e.running?`bg-accent`:`bg-fg-faint`),style:{width:`${t}%`}})}),!e.running&&e.stoppedReason?(0,B.jsxs)(`div`,{className:`text-warn`,"data-testid":`chat-abouts-stopped-reason`,children:[`Stopped: `,e.stoppedReason]}):null]})}function IAe({row:e,enabled:t,entryCount:n,checked:r,onToggle:i,playing:a,onJump:o,onOpen:s}){let c=e.title.trim()||`Untitled chat`,l=jf(e),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>{a&&u.current?.scrollIntoView?.({block:`nearest`})},[a]),(0,B.jsxs)(`li`,{ref:u,className:z(`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,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.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,B.jsx)(H.Speaker,{className:`h-3.5 w-3.5 text-accent`,title:`Playing`}):null,(0,B.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,B.jsx)(`span`,{title:Vf.yours[0],children:(0,B.jsx)(hC,{tone:`accent`,children:`yours`})}):null,e.stale&&e.about?(0,B.jsx)(`span`,{title:Vf.stale,"data-testid":`chat-about-stale`,children:(0,B.jsx)(hC,{tone:`warn`,children:`stale`})}):null,e.pending?(0,B.jsx)(`span`,{"data-testid":`chat-about-pending`,children:(0,B.jsx)(hC,{tone:`accent`,children:`writing…`})}):null]}),e.about?(0,B.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,B.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,B.jsxs)(`p`,{className:`mt-1 text-fg-muted`,"data-testid":`chat-about-missing`,children:[`No about yet. `,Lf(e,{enabled:t,entryCount:n})]}),e.about&&e.lastError?(0,B.jsxs)(`p`,{className:`mt-0.5 text-danger`,"data-testid":`chat-about-error`,children:[`The last attempt failed: `,e.lastError]}):null,(0,B.jsxs)(`div`,{className:`mt-1 flex flex-wrap justify-between gap-x-3 gap-y-0.5 text-[11px] text-fg-faint`,children:[(0,B.jsxs)(`span`,{title:zv(e.updatedAt),"data-testid":`chat-about-active`,children:[`Active `,Lv(e.updatedAt)]}),e.about&&e.aboutAt?(0,B.jsxs)(`span`,{title:zv(e.aboutAt),"data-testid":`chat-about-written`,children:[`Written `,Lv(e.aboutAt),l?` by ${l}`:``]}):(0,B.jsx)(`span`,{}),(0,B.jsx)(`span`,{title:e.route?`Paid by ${Mf[e.route]}`:void 0,"data-testid":`chat-about-spend`,children:Ff(e.spend,e.route)})]})]})}function LAe({open:e,onClose:t}){let{state:n,actions:r}=V(),i=n.nextPromptsChange,[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)(()=>Db()),[h,g]=(0,v.useState)(()=>Tb()),[_,y]=(0,v.useState)(()=>new Set),[b,x]=(0,v.useState)(()=>Date.now()),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)({}),[O,k]=(0,v.useState)(()=>new Set),[A,j]=(0,v.useState)({}),[ee,M]=(0,v.useState)(()=>new Set),[te,ne]=(0,v.useState)({}),N=(0,v.useRef)(-1),P=(0,v.useCallback)(async()=>{let e=await r.listNextPrompts();if(e===`unsupported`){c(!0);return}if(e===null){u(!0);return}c(!1),u(!1),o(e),f(e.review)},[r]);(0,v.useEffect)(()=>{e&&(N.current=i.seq,x(Date.now()),P())},[e]),(0,v.useEffect)(()=>{!e||i.seq===N.current||(N.current=i.seq,i.review!==void 0&&f(i.review),P())},[e,i,P]);let re=e=>{m(t=>{let n={...t,...e};return Ob(n),n}),x(Date.now())},ie=(0,v.useMemo)(()=>{let e=new Map;for(let t of a?.suggestions??[])e.set(t.sessionId,t);return e},[a]),ae=(0,v.useMemo)(()=>Kf(p.range,b,{from:p.from,to:p.to}),[p,b]),oe=(0,v.useMemo)(()=>{let e=e=>{let t=Date.parse(e.updatedAt);return Number.isFinite(t)?t:0};return n.sessions.filter(e=>!n.remote.tabs[e.id]&&qf(e.updatedAt,ae)).sort((t,n)=>e(n)-e(t))},[n.sessions,n.remote.tabs,ae]),se=(0,v.useMemo)(()=>oe.map(e=>e.id),[oe]),F=se.join(`,`);(0,v.useEffect)(()=>{y(e=>Wy(e,se))},[F]);let ce=(0,v.useMemo)(()=>se.filter(e=>_.has(e)),[se,_]),le=Hy(se,_),ue=(0,v.useRef)(null);(0,v.useEffect)(()=>{ue.current&&(ue.current.indeterminate=le===`some`)});let de=e=>y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),fe=d?.running===!0,pe=a?.model??dm.model,me=Uf.find(e=>e.id===p.range)?.label??``,he=async()=>{if(ce.length!==0){C(!0);try{let e=await r.reviewNextPrompts(ce,h);e&&f(e)}finally{C(!1)}}},ge=async()=>{T(!0);try{let e=await r.stopNextPromptReview();e&&f(e)}finally{T(!1)}},_e=async e=>{k(t=>new Set(t).add(e)),j(({[e]:t,...n})=>n);try{let t=await r.suggestNextPrompt(e,{windowHours:h,force:!0});if(`error`in t){j(n=>({...n,[e]:t.error}));return}o(n=>n&&{...n,suggestions:[t.suggestion,...n.suggestions.filter(t=>t.sessionId!==e)]})}finally{k(t=>{let n=new Set(t);return n.delete(e),n})}},ve=async(e,t,n)=>{let i=t.trim();if(i){M(t=>new Set(t).add(e));try{if(!await r.sendToChat(e,i))return;n&&r.markNextPromptSent(e,n.id,i),ne(t=>({...t,[e]:new Date().toISOString()})),D(({[e]:t,...n})=>n)}finally{M(t=>{let n=new Set(t);return n.delete(e),n})}}};return(0,B.jsxs)(gC,{open:e,title:mm.managerTitle,onClose:t,wide:!0,footer:(0,B.jsx)(U,{variant:`ghost`,onClick:t,children:`Close`}),children:[(0,B.jsx)(`p`,{className:`mb-3 text-xs text-fg-muted`,"data-testid":`manager-hint`,children:mm.managerHint}),s?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`manager-unsupported`,children:`OonaCode on this PC is too old for the project manager. Update it, then open this window again.`}):a===null?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`manager-loading`,children:l?`Could not read the suggestions from this PC right now. They show here as soon as it answers.`:`Loading…`}):(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`Last active`,(0,B.jsx)(`select`,{"aria-label":`Last active`,className:z(mC,`text-xs`),value:p.range,onChange:e=>re({range:e.target.value}),"data-testid":`manager-range`,children:Uf.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),p.range===`custom`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`From`,(0,B.jsx)(`input`,{type:`date`,"aria-label":`From`,className:z(pC,`text-xs`),value:p.from,onChange:e=>re({from:e.target.value}),"data-testid":`manager-from`})]}),(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`To`,(0,B.jsx)(`input`,{type:`date`,"aria-label":`To`,className:z(pC,`text-xs`),value:p.to,onChange:e=>re({to:e.target.value}),"data-testid":`manager-to`})]})]}):null,(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`Read the last`,(0,B.jsx)(`select`,{"aria-label":`Hours of each chat to read`,className:z(mC,`text-xs`),value:h,onChange:e=>{let t=Number(e.target.value);g(t),Eb(t)},"data-testid":`manager-window`,children:fm.map(e=>(0,B.jsxs)(`option`,{value:e,children:[e,` hour`,e===1?``:`s`]},e))})]}),(0,B.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1.5`,children:[(0,B.jsxs)(U,{size:`sm`,variant:`primary`,onClick:()=>void he(),busy:S,disabled:ce.length===0||fe,"data-testid":`manager-review`,children:[(0,B.jsx)(H.Lightbulb,{className:`h-3 w-3`}),` Review selected (`,ce.length,`)`]}),fe?(0,B.jsxs)(U,{size:`sm`,variant:`danger`,onClick:()=>void ge(),busy:w,"data-testid":`manager-stop`,children:[(0,B.jsx)(H.Stop,{className:`h-3 w-3`}),` Stop`]}):null]})]}),d?(0,B.jsxs)(`div`,{className:`space-y-1 text-xs`,"data-testid":`manager-progress`,children:[(0,B.jsx)(`div`,{className:`text-fg-muted`,"data-testid":`manager-progress-line`,children:kb(d)}),(0,B.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`Review`,"aria-valuemin":0,"aria-valuemax":d.total,"aria-valuenow":d.done,children:(0,B.jsx)(`div`,{className:z(`h-full rounded-full`,d.running?`bg-accent`:`bg-fg-faint`),style:{width:`${d.total>0?Math.round(Math.min(d.done,d.total)/d.total*100):100}%`}})})]}):null,oe.length>0?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,B.jsxs)(`label`,{className:`inline-flex items-center gap-2 font-medium text-fg`,children:[(0,B.jsx)(`input`,{ref:ue,type:`checkbox`,checked:le===`all`,"aria-checked":le===`some`?`mixed`:le===`all`,onChange:()=>y(e=>Uy(se,e)),"data-testid":`manager-select-all`}),`Select all`]}),(0,B.jsxs)(`span`,{className:`text-fg-muted`,"data-testid":`manager-count`,children:[oe.length,` chat`,oe.length===1?``:`s`,ce.length>0?` · ${ce.length} picked`:``]})]}):null,oe.length===0?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`manager-empty`,children:n.sessions.length===0?`No chats on this PC yet.`:`No chat was active in ${p.range===`custom`?`that range`:me.toLowerCase()}.`}):(0,B.jsx)(`ul`,{className:`space-y-2`,"data-testid":`manager-list`,children:oe.map(e=>{let i=e.id,a=ie.get(i)??null,o=n.transcripts[i]?.status??e.status,s=te[i]&&(!a?.sentAt||te[i]>a.sentAt)?te[i]:a?.sentAt??null;return(0,B.jsx)(RAe,{session:e,status:o,suggestion:a,text:E[i]??a?.prompt??``,edited:E[i]!==void 0,checked:_.has(i),reviewing:O.has(i)||fe&&d.current.includes(i),error:A[i]??null,sending:ee.has(i),sentAt:s,onToggle:()=>de(i),onEdit:e=>D(t=>({...t,[i]:e})),onSend:e=>void ve(i,e,a),onSuggest:()=>void _e(i),onOpen:()=>{r.selectSession(i),t()}},i)})}),(0,B.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`manager-cost-note`,children:mm.costNote(pe)})]})]})}function RAe({session:e,status:t,suggestion:n,text:r,edited:i,checked:a,reviewing:o,error:s,sending:c,sentAt:l,onToggle:u,onEdit:d,onSend:f,onSuggest:p,onOpen:m}){let h=Gv(e),g=Nb(e,t),_=t===`running`||t===`waiting_permission`,v=n?.status===`failed`;return(0,B.jsxs)(`li`,{className:`rounded-md border border-border px-3 py-2 text-xs`,"data-testid":`manager-row-${e.id}`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`shrink-0`,checked:a,onChange:u,"aria-label":`Pick ${h}`,"data-testid":`manager-pick`}),(0,B.jsx)(nz,{status:t}),g?(0,B.jsx)(tz,{mark:g,testId:`manager-finished`}):null,(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:h}),(0,B.jsxs)(`span`,{className:`shrink-0 text-[11px] text-fg-faint`,title:zv(e.updatedAt),"data-testid":`manager-active`,children:[`Active `,Lv(e.updatedAt)]})]}),o?(0,B.jsxs)(`p`,{className:`mt-1 flex items-center gap-1.5 text-fg-muted`,"data-testid":`manager-reading`,children:[(0,B.jsx)(H.Spinner,{className:`h-3 w-3`}),mm.reviewing(n?.windowHours??dm.windowHours)]}):null,s?(0,B.jsx)(`p`,{className:`mt-1 text-danger`,"data-testid":`manager-error`,children:s}):null,n?v?(0,B.jsx)(`p`,{className:`mt-1 text-danger`,"data-testid":`manager-failed`,children:n.error??`The suggestion could not be written.`}):(0,B.jsxs)(`div`,{className:`mt-1 space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start gap-1.5`,children:[(0,B.jsx)(`p`,{className:`min-w-0 flex-1 text-fg`,"data-testid":`manager-state`,children:n.state||`Where the chat stands is not said.`}),n.stale?(0,B.jsx)(`span`,{title:`The chat has moved on since this was written — Suggest for a fresh one.`,"data-testid":`manager-stale`,children:(0,B.jsx)(hC,{tone:`warn`,children:`stale`})}):null,i?(0,B.jsx)(`span`,{title:`Your edit is kept until you send it`,"data-testid":`manager-edited`,children:(0,B.jsx)(hC,{tone:`accent`,children:`edited`})}):null]}),n.why?(0,B.jsx)(`p`,{className:`text-fg-muted`,"data-testid":`manager-why`,children:n.why}):null,n.prompt===``&&!i?(0,B.jsx)(`p`,{className:`text-warn`,"data-testid":`manager-decide`,children:mm.decideYourself}):null]}):!o&&!s?(0,B.jsx)(`p`,{className:`mt-1 text-fg-faint`,"data-testid":`manager-none`,children:`No suggestion yet — tick it and Review, or press Suggest.`}):null,n&&!v?(0,B.jsx)(`textarea`,{"aria-label":`Message for ${h}`,className:`mt-1.5 min-h-[4rem] w-full resize-y rounded-md border border-border bg-bg px-2 py-1.5 text-xs text-fg focus:border-accent focus:outline-none`,value:r,placeholder:`Write the message yourself, or press Suggest`,onChange:e=>d(e.target.value),"data-testid":`manager-text`}):null,(0,B.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,children:[(0,B.jsxs)(U,{size:`sm`,variant:`primary`,disabled:!r.trim()||c,busy:c,onClick:()=>f(r),title:_?`The chat is working: this waits for the running turn`:void 0,"data-testid":`manager-send`,children:[(0,B.jsx)(H.Send,{className:`h-3 w-3`}),` `,_?`Send — queues behind the running turn`:`Send`]}),(0,B.jsxs)(U,{size:`sm`,variant:`secondary`,disabled:o,onClick:p,"data-testid":`manager-suggest`,children:[(0,B.jsx)(H.Lightbulb,{className:`h-3 w-3`}),` Suggest`]}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:m,"data-testid":`manager-open`,children:`Open chat`}),l?(0,B.jsxs)(`span`,{className:`text-ok`,"data-testid":`manager-sent`,children:[`Sent `,jb(l)]}):null,n?(0,B.jsxs)(`span`,{className:`ml-auto text-[11px] text-fg-faint`,"data-testid":`manager-cost`,children:[Cm(n.cost),` · `,Lv(n.createdAt)]}):null]})]})}function zAe({open:e,onClose:t}){let{state:n,actions:r}=V(),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=Wv(a?Gv(a):o?.title??`New chat`);async function m(){if(i){d(!0);try{await r.setSessionProject(i,c)&&t()}finally{d(!1)}}}return(0,B.jsxs)(gC,{open:e,title:`Move “${p}” to a project`,onClose:t,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{variant:`ghost`,onClick:()=>{t(),r.openDialog(`projects`)},children:`Manage projects…`}),(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsx)(U,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,B.jsx)(U,{variant:`primary`,onClick:m,disabled:u||c===s,"data-testid":`assign-project-apply`,children:`Apply`})]}),children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-0.5`,role:`radiogroup`,"aria-label":`Project`,children:[(0,B.jsx)(e7,{selected:c===null,onSelect:()=>l(null),label:`No project`,testId:`assign-project-none`}),n.vaultProjects.map(e=>(0,B.jsx)(e7,{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,B.jsxs)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:[`No projects yet — create one under `,(0,B.jsx)(`em`,{children:`Manage projects…`}),`.`]}):null]}),f?(0,B.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,B.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 e7({selected:e,onSelect:t,label:n,hint:r,testId:i}){return(0,B.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e,onClick:t,className:z(`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,B.jsx)(`span`,{className:z(`inline-block h-3 w-3 rounded-full border`,e?`border-accent bg-accent`:`border-border`)}),(0,B.jsx)(H.Project,{className:`w-3.5 h-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),r?(0,B.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:r}):null]})}var BAe=`Install Google’s agy`,t7=`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).`,VAe=`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.`,HAe=`Sign in with Google`,UAe=`This PC’s OonaCode is too old to run chats on Google’s agy — update it from the title bar.`,WAe=`Kept on this PC only, in memory: it is gone when OonaCode stops, and it is never synced or sent anywhere.`,GAe=new Set([`loadCodeAssist`,`fetchAdminControls`,`retrieveUserQuotaSummary`,`fetchUserInfo`,`fetchAvailableModels`,`listExperiments`,`writeTrajectoryAcls`,`recordTrajectoryAnalytics`]);function KAe(e){return e.kind===`tunnel`||e.method!==null&&GAe.has(e.method)}function qAe(e){let t=[],n=[];for(let r of e)(KAe(r)?n:t).push(r);return{main:t,background:n}}function n7(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 r7(e){let{title:t,detail:n}=n7(e);return n?`${t} · ${n}`:t}function JAe(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 i7=e=>e.toLocaleString(`en-US`);function YAe(e){if(!e)return null;let t=e.cached>0?` (${i7(e.cached)} cached)`:``;return`in ${i7(e.input)}${t} · out ${i7(e.output)}`}function XAe(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``}function ZAe(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function QAe(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 a7(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 o7(e){let t=e.update;return t?t.state===`waiting`||t.state===`failed`||t.heldBack?t.message:t.state===`updating`?t.message??`OonaCode is updating agy…`:null:null}function s7(e){let t=e.group.trim(),n=e.window.trim();return t&&n.toLowerCase().startsWith(`${t.toLowerCase()} `)&&(n=n.slice(t.length).trim()),t?n?`${t} · ${n}`:t:n}function $Ae(e){let t=e.remainingPercent,n=t!==null&&Number.isFinite(t),r=zv(e.resetsAt);return{remaining:n?`${Math.round(Math.min(100,Math.max(0,t)))}% left`:`unknown`,tone:Tc(t),resets:r?`resets ${r}`:null}}var c7=1e3,eje=2e3;function tje(e){if(!e)return null;if(e.install.state===`working`)return c7;switch(e.login.phase){case`starting`:case`verifying`:return c7;case`awaiting_code`:return eje;default:return null}}function nje(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 rje(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 ije(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 aje(e){let{received:t,total:n}=e;return n!==null&&n>0?`${HF(t)} of ${HF(n)}`:t>0?HF(t):null}function oje(e){if(!e)return null;try{return new URL(e).protocol===`https:`?e:null}catch{return null}}function sje(e,t){return t?e.split(t).join(`…`):e}function cje(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 l7=15,lje=2e4,uje=5e3,u7=null;function dje(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 fje({install:e,busy:t,offer:n,onInstall:r,onCancel:i}){if(e.state===`working`){let n=ije(e),r=aje(e);return(0,B.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`agy-install`,"data-install-state":`working`,children:[(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-install-statement`,children:t7}),(0,B.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,B.jsx)(H.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[rje(e.phase),e.version?` (agy ${e.version})`:``]})]}),(0,B.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,B.jsx)(`div`,{className:z(`h-full rounded-full bg-accent`,n===null?`w-1/3 animate-pulse`:void 0),style:n===null?void 0:{width:`${n}%`}})}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-[11px] text-fg-faint`,"data-testid":`agy-install-bytes`,children:r??``}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,disabled:t,onClick:i,"data-testid":`agy-install-cancel`,children:`Cancel`})]})]})}return e.supported?e.state===`idle`&&!n?(0,B.jsx)(`div`,{className:`space-y-2`,"data-testid":`agy-install`,"data-install-state":`starting`,children:(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-install-statement`,children:t7})}):(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-install`,"data-install-state":e.state,children:[e.state===`failed`?(0,B.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,B.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-install-explanation`,children:VAe}),(0,B.jsxs)(U,{variant:`primary`,busy:t,disabled:t,onClick:r,"data-testid":e.state===`failed`?`agy-install-retry`:`agy-install-button`,children:[(0,B.jsx)(H.Download,{className:`h-4 w-4`}),` `,e.state===`failed`?`Try again`:BAe]})]}):null}function pje({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?oje(e.url):null,m=f&&e.expiresAt?Date.parse(e.expiresAt):NaN,h=Number.isFinite(m),g=dje(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||u7===e.startedAt)return;let t=h?Date.now()-(m-6e4):1/0;if(!(!b.current&&t>uje)){u7=e.startedAt;try{O5(p)}catch{}}},[e.phase,p,e.startedAt]),(0,v.useEffect)(()=>{f&&SI(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),lje);return()=>clearTimeout(t)},[e.phase]);let C=o.trim(),w=Lg(C),T=()=>{!w||t||(s(``),a(C))},E=()=>{p&&XI(p).then(e=>{e&&(l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),1500))})},D=(0,B.jsx)(U,{size:`sm`,variant:`ghost`,disabled:t,onClick:i,"data-testid":`agy-login-cancel`,children:`Cancel`});return(0,B.jsxs)(`div`,{ref:d,className:`space-y-2`,"data-testid":`agy-sign-in`,"data-login-phase":e.phase,children:[(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-sign-in-explanation`,children:Gee}),e.phase===`starting`?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`agy-login-starting`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-fg`,role:`status`,children:[(0,B.jsx)(H.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),e.message??`Starting Google’s sign-in…`]}),(0,B.jsx)(`span`,{className:`flex-1`}),D]}):e.phase===`awaiting_code`?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-awaiting`,children:[y?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-expired`,children:[(0,B.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,B.jsxs)(U,{variant:`primary`,busy:t,disabled:t,onClick:r,"data-testid":`agy-login-expired-restart`,children:[(0,B.jsx)(H.LogIn,{className:`h-4 w-4`}),` Sign in again`]})]}):(0,B.jsxs)(B.Fragment,{children:[e.message?(0,B.jsx)(`p`,{className:`text-xs text-fg`,children:e.message}):null,p?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.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(),O5(p)},"data-testid":`agy-login-link`,children:[(0,B.jsx)(H.ExternalLink,{className:`h-3.5 w-3.5`}),` Open Google’s sign-in page`]}),(0,B.jsxs)(U,{size:`sm`,onClick:E,"data-testid":`agy-login-copy-link`,children:[(0,B.jsx)(H.Copy,{className:`h-3.5 w-3.5`}),` `,c?`Copied`:`Copy link`]})]}):null,(0,B.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-fg`,children:[(0,B.jsxs)(`span`,{className:`flex items-baseline justify-between gap-2`,children:[`Code from Google`,_===null?null:(0,B.jsxs)(`span`,{role:`timer`,className:z(`font-normal tabular-nums`,_<l7?`font-medium text-warn`:`text-fg-faint`),"data-tone":_<l7?`warn`:`neutral`,"data-testid":`agy-login-countdown`,children:[_,` s left to finish`]})]}),(0,B.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()??``;Lg(n)&&(e.preventDefault(),!t&&(s(``),a(n)))},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},"data-testid":`agy-login-code`})]}),C&&!w?(0,B.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,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(U,{variant:`primary`,size:`sm`,disabled:!w||t,onClick:T,"data-testid":`agy-login-continue`,children:`Continue`}),D]})]}),y?(0,B.jsx)(`div`,{className:`flex items-center gap-2`,children:D}):null]}):e.phase===`verifying`?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`agy-login-verifying`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-fg`,role:`status`,children:[(0,B.jsx)(H.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),e.message??`Checking the code with Google…`]}),(0,B.jsx)(`span`,{className:`flex-1`}),D,x?(0,B.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,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-failed`,children:[(0,B.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,B.jsxs)(U,{variant:`primary`,busy:t,disabled:t,onClick:n,"data-testid":`agy-sign-in-restart`,children:[(0,B.jsx)(H.LogIn,{className:`h-4 w-4`}),` Start again`]})]}):(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[e.phase===`done`&&e.message?(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.message}):null,(0,B.jsxs)(U,{variant:`primary`,busy:t,disabled:t,onClick:n,"data-testid":`agy-sign-in-button`,children:[(0,B.jsx)(H.LogIn,{className:`h-4 w-4`}),` `,HAe]})]})]})}var mje={ok:`bg-ok`,warn:`bg-warn`,danger:`bg-danger`,neutral:`bg-surface-3`},hje={ok:`text-ok`,warn:`text-warn`,danger:`text-danger`,neutral:`text-fg-muted`};function d7({label:e,testid:t,children:n}){return(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 py-0.5 text-xs`,children:[(0,B.jsx)(`dt`,{className:`shrink-0 text-fg-faint`,children:e}),(0,B.jsx)(`dd`,{className:`min-w-0 text-right font-medium text-fg`,"data-testid":t,children:n})]})}var gje=new Set([`starting`,`awaiting_code`,`verifying`,`failed`]);function f7(e){if(e.adding)return{addAccount:!0};if(e.accountId)return{accountId:e.accountId}}function p7(e){return e.email??(e.main?`Your first Google account`:`A Google account`)}function m7({usage:e,prefix:t}){return(0,B.jsx)(`ul`,{className:`space-y-2`,children:e.map((e,n)=>{let r=$Ae(e),i=e.remainingPercent;return(0,B.jsxs)(`li`,{"data-testid":`${t}-row-${n}`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:s7(e)}),(0,B.jsx)(`span`,{className:z(`shrink-0 font-medium`,hje[r.tone]),"data-tone":r.tone,"data-testid":`${t}-remaining-${n}`,children:r.remaining})]}),(0,B.jsx)(`div`,{className:`mt-0.5 h-1.5 w-full overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`${s7(e)}: ${r.remaining}`,"aria-valuemin":0,"aria-valuemax":100,...i!==null&&Number.isFinite(i)?{"aria-valuenow":Math.round(i)}:{},children:(0,B.jsx)(`div`,{className:z(`h-full rounded-full`,mje[r.tone]),style:{width:`${i!==null&&Number.isFinite(i)?Math.min(100,Math.max(0,i)):0}%`}})}),r.resets?(0,B.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:r.resets}):null]},`${e.group}-${e.window}-${n}`)})})}function h7({definition:e}){let{api:t,socket:n}=V(),[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,g]=(0,v.useState)(null),_=(0,v.useRef)(!0),y=(0,v.useRef)(0),b=(0,v.useRef)(0);(0,v.useEffect)(()=>(_.current=!0,()=>{_.current=!1}),[]);let x=(0,v.useCallback)(async(e,n=!1)=>{let r=++y.current;if(!t.getAgyStatus){o(!0);return}b.current+=1,n||u(e=>e+1);try{let n=await t.getAgyStatus(e?{refresh:!0}:void 0);if(!_.current||r!==y.current)return;i(n),c(null),o(!1)}catch(e){if(!_.current||r!==y.current)return;Zg(e)?o(!0):c(Kv(e))}finally{--b.current,!n&&_.current&&u(e=>e-1)}},[t]),S=(0,v.useCallback)(async(e,t,n=``)=>{y.current+=1,f(e),m(null);try{let e=await t();return _.current?(y.current+=1,i(e),c(null),o(!1),e):null}catch(e){return _.current&&(Zg(e)?o(!0):(m(sje(Kv(e),n)),x(!1,!0))),null}finally{_.current&&f(null)}},[x]);(0,v.useEffect)(()=>{x(!1)},[x]);let[C,w]=(0,v.useState)(!1),T=(0,v.useCallback)(async()=>{if(!t.agyInstall){o(!0);return}w(!0),await S(`install`,()=>t.agyInstall())},[t,S]),E=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!(E.current||!r||!t.agyInstall)){if(r.install.state!==`idle`){E.current=!0;return}r.state!==`not_installed`||!r.install.supported||(E.current=!0,T())}},[r,t,T]);let D=tje(r);(0,v.useEffect)(()=>{if(D===null)return;let e=setInterval(()=>{b.current===0&&x(!1,!0)},D);return()=>clearInterval(e)},[D,x]),(0,v.useEffect)(()=>n.on(`account_changed`,e=>{e.reason===`provider`&&x(!1,!0)}),[n,x]);let O=Qs(e);if(a)return(0,B.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:UAe});let k=r===null&&s===null,A=l>0,j=nje(r),ee=r?.install.state===`working`,M=(0,B.jsx)(U,{variant:`primary`,size:`sm`,busy:A||k,disabled:A||k||j,onClick:()=>void x(!0),"data-testid":`agy-check-again`,children:A||k?`Checking…`:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(H.Refresh,{className:`h-3.5 w-3.5`}),` Check again`]})}),te=r?ee?{label:`Installing agy…`,tone:`accent`}:QAe(r.state):null,ne=r?.accounts??[],N=!!r?.login.accountId&&gje.has(r?.login.phase??`idle`),P=N?ne.find(e=>e.id===r?.login.accountId)??null:null,re=ne.length>1?ne.filter(e=>e.usage.length>0).map(e=>({id:e.id,title:p7(e),usage:e.usage})):r&&r.usage.length>0?[{id:null,title:null,usage:r.usage}]:[];return(0,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`agy-card`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,B.jsx)(hC,{tone:`ok`,children:O.badge}),(0,B.jsx)(hC,{children:e.kind})]}),(0,B.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:O.detail}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[te?(0,B.jsx)(`span`,{"data-testid":`agy-state`,"data-state":r?.state,children:(0,B.jsx)(hC,{tone:te.tone,children:te.label})}):k?(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,"data-testid":`agy-checking`,children:[(0,B.jsx)(H.Spinner,{className:`h-3.5 w-3.5`}),` Asking agy…`]}):null,(0,B.jsx)(`span`,{className:`flex-1`}),M]}),A&&r?(0,B.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,B.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,B.jsxs)(B.Fragment,{children:[r.state!==`ready`&&r.message&&!j?(0,B.jsx)(`p`,{className:`text-xs text-fg`,"data-testid":`agy-message`,children:r.message}):null,r.state===`not_installed`?(0,B.jsx)(fje,{install:r.install,busy:d===`install`||d===`cancel_install`,offer:!t.agyInstall||C&&d!==`install`,onInstall:()=>{E.current=!0,T()},onCancel:()=>{E.current=!0,w(!0),t.cancelAgyInstall&&S(`cancel_install`,()=>t.cancelAgyInstall())}}):null,r.state===`not_signed_in`||N?(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[N?(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg`,"data-testid":`agy-account-flow`,children:r.login.adding?`Adding another Google account`:`Signing ${P?p7(P):`this Google account`} in again`}):null,(0,B.jsx)(pje,{login:r.login,busy:d===`login`||d===`cancel_login`||d===`code`,onStart:()=>{let e=r.login.phase===`failed`?f7(r.login):void 0;t.agyLogin?S(`login`,()=>t.agyLogin(e)):o(!0)},onRestart:()=>{let e=f7(r.login);(async()=>{t.cancelAgyLogin&&await S(`cancel_login`,()=>t.cancelAgyLogin()),t.agyLogin?await S(`login`,()=>t.agyLogin(e)):o(!0)})()},onCancel:()=>{t.cancelAgyLogin&&S(`cancel_login`,()=>t.cancelAgyLogin())},onSubmit:e=>{t.submitAgyLoginCode?S(`code`,()=>t.submitAgyLoginCode(e),e):o(!0)}})]}):null,ne.length>0&&r.state!==`not_installed`?(0,B.jsxs)(`div`,{"data-testid":`agy-accounts`,children:[(0,B.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-muted`,children:ne.length>1?`Google accounts (${ne.length})`:`Google account`}),(0,B.jsx)(`ul`,{className:`space-y-1`,children:ne.map(e=>(0,B.jsxs)(`li`,{className:`space-y-1 rounded-md border border-border px-2.5 py-1.5`,"data-testid":`agy-account-${e.id}`,title:`${p7(e)}${e.linkedAt?` · linked ${zv(e.linkedAt)}`:``}${e.isDefault&&ne.length>1?` · new chats use it`:``}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-fg`,"data-testid":`agy-account-email`,children:p7(e)}),e.isDefault&&ne.length>1?(0,B.jsx)(hC,{tone:`accent`,children:`default`}):null,(0,B.jsx)(`span`,{"data-testid":`agy-account-state`,children:(0,B.jsx)(hC,{tone:e.checking?`neutral`:e.signedIn?`ok`:e.signedIn===!1?`warn`:`neutral`,children:e.checking?`Checking…`:e.signedIn?`Signed in`:e.signedIn===!1?`Signed out`:`Unknown`})}),t.agyLogin?(0,B.jsx)(U,{size:`sm`,disabled:j||d!==null,onClick:()=>void S(`login`,()=>t.agyLogin({accountId:e.id})),"data-testid":`agy-account-signin-${e.id}`,children:`Sign in again`}):null,!e.main&&t.removeAgyAccount&&h!==e.id?(0,B.jsx)(U,{size:`sm`,variant:`ghost`,disabled:d!==null,onClick:()=>g(e.id),"data-testid":`agy-account-remove-${e.id}`,children:`Remove`}):null]}),h===e.id?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg`,"data-testid":`agy-account-remove-confirm-${e.id}`,children:[(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`Remove `,p7(e),` from this PC? Its sign-in here goes; chats that ran on it ask for another account.`]}),(0,B.jsx)(U,{size:`sm`,variant:`danger`,busy:d===`remove`,disabled:d!==null,onClick:()=>{g(null),S(`remove`,()=>t.removeAgyAccount(e.id))},"data-testid":`agy-account-remove-yes-${e.id}`,children:`Remove`}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>g(null),"data-testid":`agy-account-remove-no-${e.id}`,children:`Keep`})]}):null]},e.id))}),r.state===`ready`&&t.agyLogin&&!N?(0,B.jsx)(`div`,{className:`mt-1.5`,children:(0,B.jsxs)(U,{size:`sm`,disabled:j||d!==null,onClick:()=>void S(`login`,()=>t.agyLogin({addAccount:!0})),"data-testid":`agy-add-account`,children:[(0,B.jsx)(H.LogIn,{className:`h-3.5 w-3.5`}),` Add another Google account`]})}):null]}):null,p?(0,B.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,B.jsxs)(`dl`,{className:`rounded-md border border-border px-3 py-1.5`,"data-testid":`agy-facts`,children:[(0,B.jsx)(d7,{label:`Installed`,testid:`agy-installed`,children:r.installed?`Yes`:`No`}),r.path?(0,B.jsx)(d7,{label:`Path`,testid:`agy-path`,children:(0,B.jsx)(`span`,{className:`break-all font-mono text-[11px]`,children:r.path})}):null,r.version?(0,B.jsx)(d7,{label:`Version`,testid:`agy-version`,children:r.version}):null,(0,B.jsx)(d7,{label:`Signed in`,testid:`agy-signed-in`,children:r.signedIn===null?r.installed?`Unknown`:`—`:r.signedIn?`Yes`:`No`}),(0,B.jsx)(d7,{label:`Checked`,testid:`agy-checked`,children:(0,B.jsx)(`span`,{title:zv(r.checkedAt),children:Lv(r.checkedAt)})})]}),a7(r)?(0,B.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,B.jsx)(H.Info,{className:`mt-px h-3.5 w-3.5 shrink-0`}),a7(r)]}):null,o7(r)?(0,B.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-update-note`,children:[(0,B.jsx)(H.Info,{className:`mt-px h-3.5 w-3.5 shrink-0`}),o7(r)]}):null,r.models.length>0?(0,B.jsxs)(`div`,{"data-testid":`agy-models`,children:[(0,B.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-muted`,children:`Models agy offers`}),(0,B.jsx)(`ul`,{className:`space-y-0.5`,children:r.models.map(e=>(0,B.jsxs)(`li`,{className:`flex items-baseline justify-between gap-3 text-xs`,"data-testid":`agy-model-${e.id}`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.displayName}),(0,B.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-fg-faint`,children:e.id})]},e.id))})]}):null,re.map(e=>e.id===null?(0,B.jsxs)(`div`,{"data-testid":`agy-usage`,children:[(0,B.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-muted`,children:`Your plan’s usage`}),(0,B.jsx)(m7,{usage:e.usage,prefix:`agy-usage`})]},`default`):(0,B.jsxs)(`div`,{"data-testid":`agy-usage-${e.id}`,children:[(0,B.jsxs)(`div`,{className:`mb-1 truncate text-xs font-medium text-fg-muted`,children:[e.title,` — plan usage`]}),(0,B.jsx)(m7,{usage:e.usage,prefix:`agy-usage-${e.id}`})]},e.id))]}):null]})}var _je=1e3;function g7(e){return`${(e/1048576).toFixed(+(e<10485760))} MB`}var vje={download:`Downloading Muse from Meta…`,verify:`Checking the download against Meta’s checksum…`,place:`Setting Muse up…`};function yje({open:e,label:t,onClose:n,intent:r}){let{api:i,actions:a}=V(),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(`checking`),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(!1),m=(0,v.useRef)(null),h=(0,v.useRef)(!1),g=(0,v.useCallback)(async()=>{if(!i.museSetup)return null;try{let e=await i.museSetup();return s(e),e}catch{return null}},[i]),_=(0,v.useCallback)(async()=>{if(!i.museLoginStart){l(`unavailable`);return}d(null),h.current=!1,m.current=null,l(`running`);try{s(await i.museLoginStart(r))}catch(e){d(e instanceof Error?e.message:String(e)),l(`stopped`)}},[i,r]);(0,v.useEffect)(()=>{if(!e)return;let t=!0;return l(`checking`),d(null),s(null),(async()=>{if(!i.museSetup||!i.museLoginStart){t&&l(`unavailable`);return}let e=await g();if(t){if(!e){l(`unavailable`);return}e.login.phase===`awaiting_approval`||e.install.state===`working`?l(`running`):e.installed?_():l(`confirm`)}})(),()=>{t=!1}},[e,i,g,_]),(0,v.useEffect)(()=>{if(!e||c!==`running`)return;let t=setInterval(()=>void g(),_je);return()=>clearInterval(t)},[e,c,g]);let y=o?.login??null,b=o?.install??null,x=y?.phase===`awaiting_approval`,S=x&&(y?.verificationUriComplete??y?.verificationUri)?y?.verificationUriComplete??y?.verificationUri??null:null;(0,v.useEffect)(()=>{!e||!S||!y?.id||m.current===y.id||zg(S)&&(m.current=y.id,O5(S))},[e,S,y?.id]),(0,v.useEffect)(()=>{e&&y?.phase===`connected`&&!h.current&&(h.current=!0,a.refreshCredentials())},[e,y?.phase,a]);let C=async()=>{try{i.museLoginCancel&&s(await i.museLoginCancel())}catch{}l(`stopped`)},w=e=>{if(!navigator.clipboard){a.toast(`error`,`Could not copy — select it and copy by hand`);return}navigator.clipboard.writeText(e).then(()=>{p(!0),setTimeout(()=>p(!1),2e3)}).catch(()=>a.toast(`error`,`Could not copy`))},T=y?.phase===`connected`,E=y?.phase===`failed`||y?.phase===`expired`||y?.phase===`cancelled`,D=b?.state===`failed`,O=b?.state===`working`,k=b?.total&&b.total>0?Math.min(100,Math.floor(b.received/b.total*100)):null,A;return A=c===`unavailable`?(0,B.jsx)(`p`,{"data-testid":`muse-unavailable`,children:`This version of OonaCode on this PC cannot sign in with Meta. Paste your Muse key in the Connect window instead.`}):c===`checking`||!o?(0,B.jsx)(`p`,{children:`Looking at this PC…`}):c===`confirm`?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`muse-confirm`,children:[(0,B.jsxs)(`p`,{children:[`To sign you in, OonaCode will download Meta’s own `,(0,B.jsx)(`b`,{children:`Muse`}),` program once (about`,` `,505,` MB) into its own folder, checked against Meta’s published checksum. It runs only to sign you in.`]}),(0,B.jsx)(`p`,{className:`text-fg-muted`,children:`You then approve a short code on Meta’s page. Your key is stored in your vault; chats run from this PC straight to Meta, not through Muse. Nothing is downloaded until you press the button.`})]}):T?(0,B.jsx)(`p`,{"data-testid":`muse-connected`,children:`Signed in. Your Meta Muse key is stored in your vault and synced to your other machines; chats on it run from this PC straight to Meta.`}):O?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`muse-install`,children:[(0,B.jsx)(`p`,{children:vje[b?.phase??`download`]??`Installing Muse…`}),(0,B.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded bg-surface-2`,children:(0,B.jsx)(`div`,{className:`h-2 bg-accent`,style:{width:`${k??5}%`},"data-testid":`muse-install-bar`})}),(0,B.jsx)(`p`,{className:`text-fg-muted text-xs`,children:b&&b.received>0?`${g7(b.received)}${b.total?` of ${g7(b.total)}`:``}`:`Starting the download…`})]}):D?(0,B.jsx)(`p`,{className:`text-danger`,"data-testid":`muse-install-failed`,children:b?.error??`Muse could not be installed.`}):x&&y?(0,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`muse-awaiting`,children:[(0,B.jsx)(`p`,{children:`A sign-in page from Meta opened in your browser. If it did not, open the link below on any device and make sure this code matches:`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`code`,{className:`text-lg font-mono px-2 py-1 rounded border border-border`,"data-testid":`muse-user-code`,children:y.userCode}),(0,B.jsxs)(U,{onClick:()=>y.userCode&&w(y.userCode),children:[(0,B.jsx)(H.Copy,{className:`w-4 h-4`}),` `,f?`Copied`:`Copy code`]})]}),S&&zg(S)?(0,B.jsxs)(`div`,{className:`flex items-center gap-2 break-all`,children:[(0,B.jsx)(`a`,{className:`underline`,href:S,onClick:e=>{e.preventDefault(),O5(S)},children:S}),(0,B.jsxs)(U,{onClick:()=>w(S),children:[(0,B.jsx)(H.Copy,{className:`w-4 h-4`}),` Copy link`]})]}):null,(0,B.jsxs)(`p`,{className:`text-fg-muted`,children:[`Waiting for your approval…`,y.expiresAt?` The code expires at ${new Date(y.expiresAt).toLocaleTimeString()}.`:``,` `,`The key is stored in your vault the moment Meta confirms it.`]})]}):E||c===`stopped`?(0,B.jsx)(`p`,{className:E&&y?.phase!==`cancelled`?`text-danger`:``,"data-testid":`muse-ended`,children:u??y?.message??`The sign-in did not complete.`}):(0,B.jsx)(`p`,{children:y?.message??`Getting Meta’s sign-in page ready…`}),(0,B.jsx)(gC,{open:e,title:t,onClose:()=>n(T),footer:(0,B.jsxs)(B.Fragment,{children:[c===`running`&&!T&&!E&&!D?(0,B.jsx)(U,{onClick:()=>void C(),"data-testid":`muse-cancel`,children:`Cancel`}):null,c===`confirm`?(0,B.jsx)(U,{variant:`primary`,onClick:()=>void _(),"data-testid":`muse-start`,children:`Download and sign in`}):null,(c===`stopped`||E||D)&&!T&&c!==`unavailable`?(0,B.jsx)(U,{onClick:()=>void _(),"data-testid":`muse-retry`,children:`Try again`}):null,(0,B.jsx)(U,{variant:`primary`,onClick:()=>n(T),children:T?`Done`:`Close`})]}),children:(0,B.jsx)(`div`,{className:`space-y-3 text-sm`,"data-testid":`muse-login-dialog`,children:A})})}function bje(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 xje(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 Sje(e){let t=[];for(let n of e){let e=n.definition,r=qs(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.museCliLogin?`muse`:e.subscriptionLogin?`oauth`:`claude`:null,keyFormat:r[0]?.keyFormat??e.keyFormat})}return t}function _7(e){let t=(e.provider.credentials??[]).filter(e=>e.class!==`none`),n=e.variantId?t.filter(t=>(t.variantId??`payg`)===e.variantId):t;if(!e.isSubscription)return n.slice(0,1);let r=new Set;return n.filter(e=>{let t=e.accountKey??``;return!r.has(t)&&(r.add(t),!0)})}function Cje(e){return e.isSubscription&&(e.loginKind===`oauth`||e.loginKind===`muse`||e.loginKind===null)}function wje({open:e,providerId:t,onClose:n}){let{state:r,actions:i}=V(),a=(0,v.useMemo)(()=>t?xje(r.providers,t):[],[r.providers,t]),o=(0,v.useMemo)(()=>Sje(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,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(void 0),[w,T]=(0,v.useState)(!1),E=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),x(!1),C(void 0),T(!1)},[e,t,o]),(0,v.useEffect)(()=>{if(!e||!E)return;let t=E.provider.definition;f(t.userBaseUrl?E.variant?.baseUrl??t.baseUrl:``)},[e,E,E?.key]),!E)return null;let D=E.provider.definition,O=a[0]?.definition?.displayName??D.displayName;if(D.engine===`agy`)return(0,B.jsx)(gC,{open:e,title:O,onClose:n,footer:(0,B.jsx)(U,{onClick:n,children:`Close`}),children:(0,B.jsx)(h7,{definition:D})});if(b)return(0,B.jsx)(yje,{open:e,label:D.museCliLogin?.signInLabel??`Sign in with Meta`,...S?{intent:S}:{},onClose:e=>{x(!1),e&&n()}});let k=_7(E),A=a.some(e=>(e.credentials??[]).some(e=>e.class!==`none`)),j=D.credentialClass!==`none`,ee=Qs(D,{credentialClass:E.isSubscription?`subscription`:D.credentialClass,...D.userBaseUrl&&d.trim()?{baseUrl:d.trim()}:{}}),M=!h&&(!j||l.trim().length>0),te=async()=>{g(!0),y(null);try{if(!j){await i.setActiveProvider(D.id),n();return}let e=await i.probeCredential(D.id,{secret:l.trim(),variantId:E.variantId,...D.userBaseUrl&&d.trim()?{baseUrl:d.trim()}:{}});if(!e.ok){y(e.error??`${O} rejected this key — check it and try again.`);return}let t={};E.variantId&&(t.variant=E.variantId),D.userBaseUrl&&d.trim()&&(t.baseUrl=d.trim()),await i.addCredential({class:E.isSubscription?`subscription`:`api_key`,providerId:D.id,secret:l.trim(),...p.trim()?{label:p.trim()}:{},...Object.keys(t).length>0?{meta:t}:{},...E.isSubscription&&w&&k.length>0?{addAccount:!0}:{}})&&(u(``),n())}finally{g(!1)}};return(0,B.jsx)(gC,{open:e,title:`${A?`Manage`:`Connect`} ${O}`,onClose:n,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{onClick:n,children:`Cancel`}),E.loginKind===`oauth`?(0,B.jsxs)(U,{onClick:()=>i.openOauthLogin(E.provider.definition.id,k.length>0?{addAccount:!0}:null),"data-testid":`connect-oauth-signin`,children:[(0,B.jsx)(H.LogIn,{className:`w-4 h-4`}),` `,k.length>0?`Add another account`:E.provider.definition.subscriptionLogin?.signInLabel??`Sign in instead`]}):E.loginKind===`muse`?(0,B.jsxs)(U,{onClick:()=>{C(k.length>0?{addAccount:!0}:void 0),x(!0)},"data-testid":`connect-muse-signin`,children:[(0,B.jsx)(H.LogIn,{className:`w-4 h-4`}),` `,k.length>0?`Add another account`:E.provider.definition.museCliLogin?.signInLabel??`Sign in with Meta`]}):E.loginKind===`claude`?(0,B.jsxs)(U,{onClick:()=>i.openClaudeLogin(null),"data-testid":`connect-claude-signin`,children:[(0,B.jsx)(H.LogIn,{className:`w-4 h-4`}),` Sign in instead`]}):null,(0,B.jsx)(U,{variant:`primary`,busy:h,disabled:!M,onClick:()=>void te(),children:h?`Checking…`:j?`Save key`:`Use this provider`})]}),children:(0,B.jsxs)(`div`,{className:`space-y-3`,children:[o.length>1?(0,B.jsx)(`div`,{className:`flex gap-1 border-b border-border`,role:`tablist`,children:o.map(e=>{let t=_7(e)[0];return(0,B.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.key===E.key,"data-testid":`record-tab-${e.key}`,onClick:()=>c(e.key),className:e.key===E.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,B.jsx)(`span`,{className:`ml-1.5 font-mono text-[11px] text-ok`,children:t.masked}):null]},e.key)})}):null,k.length>0?(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:k.length>1?`Linked accounts (${k.length})`:`Connected`}),k.map(e=>(0,B.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}`,title:e.accountLabel?`${e.accountLabel} — ${e.label}`:e.label,children:[(0,B.jsx)(hC,{tone:e.class===`subscription`?`accent`:`ok`,children:E.label}),e.accountLabel?(0,B.jsx)(`span`,{className:`truncate text-xs font-medium`,"data-testid":`stored-account`,children:e.accountLabel}):(0,B.jsx)(`span`,{className:`font-mono text-xs`,children:e.masked}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-fg-faint`,children:e.label}),E.loginKind===`oauth`?(0,B.jsx)(U,{size:`sm`,onClick:()=>i.openOauthLogin(E.provider.definition.id,{replaceCredentialId:e.id}),"data-testid":`renew-credential-${e.id}`,children:`Sign in again`}):E.loginKind===`muse`?(0,B.jsx)(U,{size:`sm`,onClick:()=>{C({replaceCredentialId:e.id}),x(!0)},"data-testid":`renew-credential-${e.id}`,children:`Sign in again`}):null,(0,B.jsx)(U,{size:`sm`,variant:`danger`,onClick:()=>void i.deleteCredential(e.id),children:`Remove`})]},e.id))]}):null,(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,B.jsx)(hC,{tone:ee.viaGateway?`accent`:`ok`,children:ee.badge}),(0,B.jsx)(hC,{children:D.kind}),E.keyFormat?(0,B.jsxs)(`span`,{className:`text-fg-faint`,children:[`key format `,E.keyFormat]}):null]}),(0,B.jsxs)(`div`,{className:ee.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:[ee.detail,j&&!ee.viaGateway?` The key is stored in your zero-knowledge vault.`:null]}),j?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`ol`,{className:`ml-4 list-decimal space-y-1 text-xs text-fg-muted`,children:E.loginKind===`muse`?[`Press “${E.provider.definition.museCliLogin?.signInLabel??`Sign in with Meta`}”: OonaCode fetches Meta’s own Muse once into its own folder, you approve a short code on Meta’s page, and the key is stored by itself.`,`Or paste a Muse subscription key, or a Meta Model API key, below.`,`Chats go from this PC straight to Meta; the key stays in your vault.`].map((e,t)=>(0,B.jsx)(`li`,{children:e},t)):E.loginKind===`oauth`?[`Press “${E.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,B.jsx)(`li`,{children:e},t)):E.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,B.jsx)(`li`,{children:e},t)):bje(E.provider,E.variant).map((e,t)=>(0,B.jsx)(`li`,{children:e},t))}),(0,B.jsx)(fC,{label:E.loginKind===`muse`?`Muse key`:E.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,B.jsx)(`input`,{className:pC,type:`password`,autoComplete:`off`,spellCheck:!1,value:l,placeholder:E.keyFormat??`sk-…`,onChange:e=>{u(e.target.value),y(null)}})}),_?(0,B.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,D.userBaseUrl?(0,B.jsx)(fC,{label:`Base URL`,hint:`Point this at your own server if it is not the default. Each record has its own endpoint.`,children:(0,B.jsx)(`input`,{className:pC,value:d,spellCheck:!1,onChange:e=>f(e.target.value),placeholder:E.variant?.baseUrl??D.baseUrl})}):null,E.isSubscription&&k.length>0&&Cje(E)?(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked),"data-testid":`connect-as-another`}),`Add this token as another account (keep the linked ones)`]}):null,(0,B.jsx)(fC,{label:`Label (optional)`,children:(0,B.jsx)(`input`,{className:pC,value:p,onChange:e=>m(e.target.value),placeholder:`${O} ${E.label.toLowerCase()} key`})})]}):(0,B.jsxs)(`div`,{className:`rounded-md bg-surface-2 px-3 py-2 text-xs text-fg-muted`,children:[D.displayName,` needs no credential.`]})]})})}function Tje({open:e,onClose:t}){let{state:n,actions:r}=V(),i=n.ui.oauthLoginProviderId,a=n.ui.oauthLoginIntent,o=i?n.providers.find(e=>e.definition.id===i)??null:null,s=n.oauthLogin&&n.oauthLogin.providerId===i?n.oauthLogin:null,[c,l]=(0,v.useState)(0),[u,d]=(0,v.useState)(!1),f=(0,v.useRef)(null),p=o?.definition.displayName??i??`the provider`,m=o?.definition.subscriptionLogin?.signInLabel??`Sign in to ${p}`,h=s?.phase===`awaiting_approval`,g=h?s?.verificationUriComplete??s?.verificationUri??null:null;(0,v.useEffect)(()=>{if(!e||!i)return;f.current=null,r.startOauthLogin(i,a);let t=setInterval(()=>void r.refreshOauthLogin(i),2e3);return()=>clearInterval(t)},[e,i,c,r,a]),(0,v.useEffect)(()=>{!e||!g||!s?.id||f.current===s.id||(f.current=s.id,O5(g))},[e,g,s?.id]),(0,v.useEffect)(()=>{e&&s?.phase===`connected`&&r.refreshCredentials()},[e,s?.phase,r]);let _=e=>{if(!navigator.clipboard){r.toast(`error`,`Could not copy — select it and copy by hand`);return}navigator.clipboard.writeText(e).then(()=>{d(!0),setTimeout(()=>d(!1),2e3)}).catch(()=>r.toast(`error`,`Could not copy`))},y=s?.phase===`connected`||s?.phase===`failed`||s?.phase===`expired`||s?.phase===`cancelled`;return(0,B.jsx)(gC,{open:e,title:m,onClose:t,footer:(0,B.jsxs)(B.Fragment,{children:[h?(0,B.jsx)(U,{onClick:()=>i&&void r.cancelOauthLogin(i),"data-testid":`oauth-login-cancel`,children:`Cancel sign-in`}):null,y&&s?.phase!==`connected`?(0,B.jsx)(U,{onClick:()=>l(e=>e+1),"data-testid":`oauth-login-retry`,children:`Try again`}):null,(0,B.jsx)(U,{variant:`primary`,onClick:t,children:s?.phase===`connected`?`Done`:`Close`})]}),children:(0,B.jsx)(`div`,{className:`space-y-3 text-sm`,"data-testid":`oauth-login-dialog`,children:h&&s?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`p`,{children:[`A sign-in page for `,p,` opened in your browser. If it did not, open the link below on any device and enter this code:`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`code`,{className:`text-lg font-mono px-2 py-1 rounded border border-border`,"data-testid":`oauth-user-code`,children:s.userCode}),(0,B.jsxs)(U,{onClick:()=>s.userCode&&_(s.userCode),children:[(0,B.jsx)(H.Copy,{className:`w-4 h-4`}),` `,u?`Copied`:`Copy code`]})]}),g?(0,B.jsxs)(`div`,{className:`flex items-center gap-2 break-all`,children:[(0,B.jsx)(`a`,{className:`underline`,href:g,onClick:e=>{e.preventDefault(),O5(g)},children:g}),(0,B.jsxs)(U,{onClick:()=>_(g),children:[(0,B.jsx)(H.Copy,{className:`w-4 h-4`}),` Copy link`]})]}):null,(0,B.jsxs)(`p`,{className:`text-fg-muted`,children:[`Waiting for your approval… the code expires`,s.expiresAt?` at ${new Date(s.expiresAt).toLocaleTimeString()}`:` soon`,`. The subscription is stored in your vault the moment `,p,` confirms it.`]})]}):s?.phase===`connected`?(0,B.jsxs)(`p`,{"data-testid":`oauth-login-connected`,children:[`Signed in. Your `,p,` subscription is stored in your vault and synced to your other machines; chats on it run from this PC straight to the provider.`]}):y?(0,B.jsx)(`p`,{className:`text-danger`,"data-testid":`oauth-login-ended`,children:s?.message??`The sign-in did not complete.`}):(0,B.jsx)(`p`,{children:`Starting the sign-in…`})})})}function Eje({open:e,onClose:t}){let{state:n,actions:r}=V(),i=(0,v.useMemo)(()=>Jm(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,B.jsx)(gC,{open:e,title:`Manage models`,onClose:t,wide:!0,footer:(0,B.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,B.jsxs)(U,{onClick:()=>{t(),r.openSettings(`providers`)},"data-testid":`manage-models-add-provider`,children:[(0,B.jsx)(H.Plus,{className:`w-3.5 h-3.5`}),` Add provider`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(U,{onClick:t,children:`Cancel`}),(0,B.jsx)(U,{variant:`primary`,busy:l,onClick:()=>void h(),"data-testid":`manage-models-save`,children:`Save`})]})]}),children:(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.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,B.jsx)(`input`,{className:pC,value:s,onChange:e=>c(e.target.value),placeholder:`Filter models…`,"data-testid":`manage-models-filter`}),i.length===0?(0,B.jsxs)(`div`,{className:`text-sm text-fg-faint`,children:[`No provider is connected yet — use `,(0,B.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,B.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`manage-models-${e.definition.id}`,children:[(0,B.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:e.definition.displayName}),(0,B.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[r===t.length?`all`:r,` of `,t.length,` shown`]}),(0,B.jsxs)(`span`,{className:`ml-auto flex gap-1`,children:[(0,B.jsx)(U,{size:`sm`,onClick:()=>m(e.definition.id,!0,t),children:`All`}),(0,B.jsx)(U,{size:`sm`,onClick:()=>m(e.definition.id,!1,t),children:`None`})]})]}),(0,B.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-2`,children:[n.map(n=>(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,B.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,B.jsxs)(`span`,{className:`truncate`,title:n.id,children:[n.displayName??n.id,n.displayName&&n.displayName!==n.id?(0,B.jsxs)(`span`,{className:`text-fg-faint`,children:[` · `,n.id]}):null]})]},n.id)),n.length===0?(0,B.jsxs)(`div`,{className:`text-xs text-fg-faint`,children:[(0,B.jsx)(H.Info,{className:`mr-1 inline w-3 h-3`}),` No model matches the filter.`]}):null]})]},e.definition.id)})]})})}var v7={mode:`names`,mine:!0,model:!0,tools:!1,subagents:!1,projectId:null,when:`any`,caseSensitive:!1,wholeWord:!1};function y7(e,t,n){let r=Ke(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 b7(e){return Object.keys(v7).some(t=>e[t]!==v7[t])}function x7(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 Dje(e,t,n,r=Date.now()){if(n.projectId!==null&&e.projectId!==n.projectId)return!1;let i=x7(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`&&qe(e,t,i)))return!1}return!0}function Oje(e,t,n=Date.now()){let r=e.trim();if(r.length<2||!t.mine&&!t.model&&!t.tools)return null;let i=x7(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 S7({label:e,hint:t,checked:n,onChange:r,testId:i}){return(0,B.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 py-0.5 text-xs`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:n,onChange:e=>r(e.target.checked),"data-testid":i}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`text-fg`,children:e}),t?(0,B.jsx)(`span`,{className:`block text-[11px] text-fg-faint`,children:t}):null]})]})}var C7=`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-fg focus:outline-none`,kje={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 w7({options:e,onChange:t,projects:n,onClose:r,words:i=kje}){let a=(n,r)=>t({...e,[n]:r}),o=e.mode===`conversations`,s=o&&!e.mine&&!e.model&&!e.tools;return(0,B.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,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:`Search in`}),(0,B.jsx)(vC,{label:`Search in`,value:e.mode,options:[{value:`names`,label:i.names},{value:`conversations`,label:i.conversations}],onChange:e=>a(`mode`,e)}),(0,B.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`search-mode-hint`,children:o?i.conversationsHint:i.namesHint})]}),o?(0,B.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,B.jsx)(S7,{label:`My messages`,checked:e.mine,onChange:e=>a(`mine`,e),testId:`search-opt-mine`}),(0,B.jsx)(S7,{label:`Model replies`,checked:e.model,onChange:e=>a(`model`,e),testId:`search-opt-model`}),(0,B.jsx)(S7,{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,B.jsx)(S7,{label:`Subagents’ conversations`,checked:e.subagents,onChange:e=>a(`subagents`,e),testId:`search-opt-subagents`}),s?(0,B.jsx)(`p`,{className:`text-[11px] text-warn`,children:`Tick at least one to search.`}):null]}):null,(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[n?(0,B.jsxs)(`label`,{className:`space-y-1 text-[11px] text-fg-faint`,children:[(0,B.jsx)(`span`,{children:`Project`}),(0,B.jsxs)(`select`,{className:C7,value:e.projectId??``,onChange:e=>a(`projectId`,e.target.value||null),"data-testid":`search-opt-project`,children:[(0,B.jsx)(`option`,{value:``,children:`All projects`}),n.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}):null,(0,B.jsxs)(`label`,{className:`space-y-1 text-[11px] text-fg-faint`,children:[(0,B.jsx)(`span`,{children:`When`}),(0,B.jsxs)(`select`,{className:C7,value:e.when,onChange:e=>a(`when`,e.target.value),"data-testid":`search-opt-when`,children:[(0,B.jsx)(`option`,{value:`any`,children:`Any time`}),(0,B.jsx)(`option`,{value:`today`,children:`Today`}),(0,B.jsx)(`option`,{value:`week`,children:`Last 7 days`}),(0,B.jsx)(`option`,{value:`month`,children:`Last 30 days`})]})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-x-4`,children:[(0,B.jsx)(S7,{label:`Match case`,checked:e.caseSensitive,onChange:e=>a(`caseSensitive`,e),testId:`search-opt-case`}),(0,B.jsx)(S7,{label:`Whole words`,checked:e.wholeWord,onChange:e=>a(`wholeWord`,e),testId:`search-opt-word`})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border pt-2`,children:[(0,B.jsx)(`button`,{type:`button`,className:z(`text-xs`,b7(e)?`text-accent hover:underline`:`text-fg-faint`),disabled:!b7(e),onClick:()=>t(v7),"data-testid":`search-opt-reset`,children:`Reset`}),(0,B.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 Aje(e){return e.kind===`tool`?e.tool??`Tool`:e.role===`assistant`?`Model`:`You`}function jje({query:e,options:t}){let{state:n,actions:r}=V(),i=(0,v.useMemo)(()=>Oje(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,B.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,B.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,B.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,B.jsxs)(`div`,{className:`pb-2`,"data-testid":`transcript-search-results`,children:[(0,B.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,B.jsxs)(`div`,{className:`mb-1.5`,"data-testid":`transcript-search-chat-${n}`,children:[(0,B.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,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i.title}),(0,B.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,B.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,B.jsxs)(`span`,{className:`mb-0.5 flex items-center gap-1.5 text-[10px] text-fg-faint`,children:[i.kind===`tool`?(0,B.jsx)(H.Tool,{className:`h-3 w-3`}):i.role===`assistant`?(0,B.jsx)(H.Bot,{className:`h-3 w-3`}):(0,B.jsx)(H.User,{className:`h-3 w-3`}),(0,B.jsx)(`span`,{className:`font-medium text-fg-muted`,children:Aje(i)}),i.subpath?(0,B.jsx)(`span`,{children:`· subagent`}):null,i.timestamp?(0,B.jsx)(`span`,{className:`ml-auto`,children:Lv(i.timestamp)}):null]}),(0,B.jsx)(`span`,{className:`line-clamp-3 text-fg-muted`,children:y7(i.snippet,e,t).map((e,t)=>e.hit?(0,B.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,B.jsx)(`span`,{children:e.text},t))})]},`${i.seq}`))]},n))]})}function T7(e){return`${e.agentId??`claude-code`}:${e.id}`}function E7(e){let t=Date.parse(e.lastEntryAt??e.updatedAt);return Number.isFinite(t)?t:0}function Mje(e,t,n=Date.now()){let r=x7(t.when,n)?.getTime()??null,i=Ke(e,{caseSensitive:t.caseSensitive,wholeWord:t.wholeWord});return e=>r!==null&&E7(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 Nje(e,t,n=Date.now()){let r=e.trim();if(r.length<2||!t.mine&&!t.model&&!t.tools)return null;let i=x7(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 Pje(e,t){let n=new Map;for(let t of e){let e=T7(t);n.set(e,e);for(let r of t.supersedes??[]){let i=T7({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(T7(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 Fje={new:`New`,imported:`Imported`,behind:`Imported · original moved on`,deleted:`You deleted it in OonaCode`,unavailable:`Cannot be imported yet`};function D7(e){return e.alreadyImported?e.upToDate===!1?`behind`:`imported`:e.deletedHere===!0?`deleted`:O7(e)?`unavailable`:`new`}function O7(e){return typeof e.unavailable==`string`&&e.unavailable.length>0}function k7(e){if(O7(e))return!1;let t=D7(e);return t===`new`||t===`behind`}function Ije(e){return D7(e)===`new`}function Lje(e,t){return new Set(t?e.filter(Ije).map(e=>e.id):[])}function Rje(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 zje(){return{new:0,imported:0,behind:0,deleted:0,unavailable:0}}function Bje(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:zje()},t.set(e,r)),r.rows.push(n),r.counts[D7(n)]+=1}for(let e of t.values())e.rows=Rje([...e.rows].sort((e,t)=>E7(t)-E7(e)));return[...t.values()]}function A7(e,t){let n=0,r=0,i=0;for(let a of e){let e=t.has(a.id);e&&(n+=1),k7(a)&&(r+=1,e&&(i+=1))}return n===0?`none`:r>0&&i===r?`all`:`some`}function Vje(e,t){let n=new Set(t),r=e.filter(k7);if(A7(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 Hje(e,t){let n=0;if(t)for(let r of e)t.has(r)||(n+=1);return{total:e.size,notShown:n}}var Uje={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.`},j7=`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 Wje(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 M7(e){return e?e.replace(/[\\/]+$/,``).split(/[\\/]/).length<=2?e:`…${e.slice(-40)}`:`no folder recorded`}function Gje(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function Kje(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}var N7=(e,t,n)=>`${e} ${e===1?t:n}`;function qje({open:e,onClose:t,autoOffer:n=!1}){let{state:r,actions:i}=V(),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)(()=>Bje(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)(v7),[O,k]=(0,v.useState)(!1),A=(0,v.useRef)(null),j=w.trim()!==``,ee=E.mode===`conversations`,[M,te]=(0,v.useState)(new Set);(0,v.useEffect)(()=>te(new Set),[w,E]);let ne=(0,v.useMemo)(()=>ee?Nje(w,E):null,[ee,w,E]),N=ne?JSON.stringify(ne):``,[P,re]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!e||!ne)return;let t=new AbortController,n=!0,r=setTimeout(()=>{i.searchImportChats(ne,t.signal).then(e=>{n&&re({key:N,res:e})})},350);return()=>{n=!1,clearTimeout(r),t.abort()}},[e,N,i]);let ie=P&&P.key===N?P:null,ae=(0,v.useMemo)(()=>ie?.res?Pje(x,ie.res.chats):null,[ie,x]),oe=(0,v.useMemo)(()=>j?ee?ae?x.filter(e=>ae.has(T7(e))):[]:x.filter(Mje(w,E)):null,[j,ee,x,w,E,ae]),se=(0,v.useMemo)(()=>oe?new Set(oe):null,[oe]),F=(0,v.useMemo)(()=>oe?new Set(oe.map(e=>e.id)):null,[oe]),ce=oe??x,le=(0,v.useMemo)(()=>j?{query:w,options:E,litNames:!ee}:null,[j,w,E,ee]),ue=(0,v.useMemo)(()=>x.filter(e=>e.alreadyImported&&m.has(e.id)),[x,m]),de=(0,v.useMemo)(()=>Hje(m,F),[m,F]),fe=S.length===1?S[0].name:`coding-agent`;(0,v.useEffect)(()=>{if(!e)return;d(null),b(null),_(new Set),h(new Set),T(``),re(null),k(!1),s(!0);let t=n;i.scanClaudeSessions().then(e=>{p(e.sessions),h(Lje(e.sessions,t))}).catch(e=>d(e instanceof Error?e.message:String(e))).finally(()=>s(!1))},[e]);let pe=(0,v.useCallback)(e=>h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),me=r.prefs.claudeImportOffered,he=(0,v.useCallback)(()=>{me||i.savePrefs({claudeImportOffered:!0}),t()},[me,i,t]),ge=async()=>{l(!0),d(null);try{let e=await i.importClaudeSessions([...m],ue.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)}},_e=C.imported+C.behind;return(0,B.jsx)(gC,{open:e,title:`Import your ${fe} chats`,onClose:he,wide:!0,footer:(0,B.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,B.jsxs)(`span`,{className:`min-w-0 text-[11px] text-fg-faint`,children:[!y&&de.notShown>0?(0,B.jsxs)(`span`,{className:`block text-fg-muted`,"data-testid":`import-claude-ticked-hidden`,children:[de.total,` ticked · `,de.notShown,` not shown by the search`]}):null,ue.length>0?(0,B.jsxs)(`span`,{className:`block text-warn`,children:[ue.length,` already-imported `,ue.length===1?`chat`:`chats`,` `,`will be REPLACED — the OonaCode copy is rebuilt from the original, and anything added here is lost.`]}):(0,B.jsx)(`span`,{className:`block`,children:`Your other apps stay exactly as they are — this copies, it never moves or deletes.`})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,B.jsx)(U,{onClick:he,"data-testid":`import-claude-close`,children:y?`Done`:`Not now`}),y?null:(0,B.jsxs)(U,{variant:`primary`,busy:c,disabled:de.total===0,onClick:()=>void ge(),"data-testid":`import-claude-run`,children:[`Import `,N7(de.total,`chat`,`chats`)]})]})]}),children:(0,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`import-claude-body`,children:[o?(0,B.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`Looking for chats on this PC…`}):null,a&&!y?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`import-claude-progress`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,B.jsxs)(`span`,{children:[`Importing `,(0,B.jsx)(`strong`,{children:a.done}),` of `,(0,B.jsx)(`strong`,{children:a.total}),`…`]}),(0,B.jsxs)(`span`,{className:`text-[11px] text-fg-faint`,children:[Math.round(a.done/Math.max(a.total,1)*100),`%`]})]}),(0,B.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded bg-surface-2`,children:(0,B.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,B.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,title:a.current,children:[`reading: `,a.current]}):null,(0,B.jsxs)(`div`,{className:`flex gap-3 text-[11px] text-fg-faint`,children:[(0,B.jsxs)(`span`,{children:[a.imported,` imported`]}),a.skipped>0?(0,B.jsxs)(`span`,{children:[a.skipped,` already in`]}):null,a.failed>0?(0,B.jsxs)(`span`,{className:`text-warn`,children:[a.failed,` could not be read`]}):null]}),(0,B.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,B.jsx)(`div`,{className:`rounded border border-danger/40 bg-danger/10 p-2 text-sm text-danger`,children:u}):null,y?(0,B.jsxs)(`div`,{className:`text-sm`,"data-testid":`import-claude-done`,children:[(0,B.jsxs)(`p`,{children:[`Imported `,(0,B.jsx)(`strong`,{children:y.imported}),` `,y.imported===1?`chat`:`chats`,y.replaced>0?(0,B.jsxs)(B.Fragment,{children:[` and rebuilt `,(0,B.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,B.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,B.jsxs)(`span`,{children:[t>0?`, `:``,(0,B.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,B.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,B.jsxs)(`p`,{className:`mt-1 text-warn`,children:[y.failed,` could not be read and were left alone.`]}):null,y.warnings.map(e=>(0,B.jsx)(`p`,{className:`mt-1 text-warn`,children:e},e))]}):null,!o&&!y&&!a&&f!==null&&f.length>0?(0,B.jsxs)(`div`,{className:`space-y-0.5 text-sm`,"data-testid":`import-claude-tally`,children:[(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`strong`,{children:f.length}),` `,f.length===1?`chat`:`chats`,` on this PC`,S.length>0?` — `:``,S.map((e,t)=>(0,B.jsxs)(`span`,{children:[t>0?`, `:``,(0,B.jsx)(`strong`,{children:e.rows.length}),` `,e.name]},e.key))]}),(0,B.jsxs)(`p`,{className:`text-fg-muted`,children:[(0,B.jsx)(`strong`,{className:`text-fg`,children:C.new}),` new`,_e>0?` · ${_e} 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,B.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,B.jsxs)(B.Fragment,{children:[(0,B.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,B.jsxs)(`div`,{className:`relative`,"data-testid":`import-search`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsxs)(`div`,{className:`relative flex-1`,children:[(0,B.jsx)(H.Search,{className:`pointer-events-none absolute left-2 top-2 w-3.5 h-3.5 text-fg-faint`}),(0,B.jsx)(`input`,{ref:A,"aria-label":`Search the chats to import`,className:z(pC,`pl-7`),placeholder:ee?`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,B.jsxs)(lC,{label:O?`Hide search options`:`Search options`,className:z(`relative`,O&&`text-accent`),"aria-pressed":O,onMouseDown:e=>e.preventDefault(),onClick:()=>k(e=>!e),"data-testid":`import-search-options-toggle`,children:[(0,B.jsx)(H.Sliders,{}),b7(E)?(0,B.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,B.jsx)(lC,{label:`Clear search`,onMouseDown:e=>e.preventDefault(),onClick:()=>{T(``),A.current?.focus()},"data-testid":`import-search-clear`,children:(0,B.jsx)(H.X,{})}):null]}),O?(0,B.jsx)(w7,{options:E,onChange:D,words:Uje,onClose:()=>{k(!1),A.current?.focus()}}):null]}),j?(0,B.jsx)(tMe,{query:w,conversations:ee,request:ne!==null,answer:ie,matches:oe?.length??0,messages:[...ae?.values()??[]].reduce((e,t)=>e+t.hits,0),capped:[...ae?.values()??[]].some(e=>e.hitsCapped)}):null,(0,B.jsx)(`div`,{className:`max-h-96 space-y-3 overflow-y-auto`,"data-testid":`import-claude-list`,children:S.map(e=>{let t=se?e.rows.filter(e=>se.has(e)):e.rows;if(t.length===0)return null;let n=se?!M.has(e.key):!g.has(e.key),r=se?te:_;return(0,B.jsxs)(`div`,{className:`rounded border border-border`,"data-testid":`import-group-${e.key}`,children:[(0,B.jsx)(Xje,{section:e,rows:t,searching:se!==null,open:n,chosen:m,onFold:()=>r(t=>Jje(t,e.key)),onTicks:h}),n?t.map(e=>(0,B.jsx)(Qje,{row:e,checked:m.has(e.id),onToggle:pe,phrase:le,hit:ae?.get(T7(e))},T7(e))):null]},e.key)})}),(0,B.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-fg-faint`,children:[(0,B.jsx)(`button`,{type:`button`,className:`underline`,title:j7,onClick:()=>h(e=>{let t=new Set(e);for(let e of ce)k7(e)&&t.add(e.id);return t}),"data-testid":`import-claude-select-all`,children:oe===null?`Select all`:`Select all matches`}),(0,B.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>h(e=>{if(oe===null)return new Set;let t=new Set(e);for(let e of ce)t.delete(e.id);return t}),"data-testid":`import-claude-select-none`,children:oe===null?`Select none`:`Unselect matches`})]})]}):null]})})}function Jje(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Yje({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,B.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 Xje({section:e,rows:t,searching:n,open:r,chosen:i,onFold:a,onTicks:o}){let s=A7(t,i),c=t.filter(k7).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}`:j7;return(0,B.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,B.jsx)(Yje,{state:s,disabled:c===0&&s===`none`,onToggle:()=>o(e=>Vje(t,e)),label:s===`all`?`Untick every chat in ${f}`:`Tick the chats in ${f}`,title:p,testId:`import-group-check-${e.key}`}),(0,B.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,B.jsx)(H.Chevron,{open:r,className:`w-3 h-3 shrink-0`}),e.name,(0,B.jsxs)(`span`,{className:`truncate font-normal text-fg-faint`,children:[N7(e.rows.length,`chat`,`chats`),n?` · ${N7(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 Zje({row:e,status:t}){let n=Fje[t],r={"data-testid":`import-status-${e.id}`,"data-status":t};switch(t){case`new`:return(0,B.jsx)(`span`,{className:`font-medium text-accent`,...r,children:n});case`imported`:case`behind`:return(0,B.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,B.jsx)(H.Check,{className:`w-3 h-3 text-ok`}),n,t===`behind`?(0,B.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,B.jsx)(H.ArrowDown,{className:`w-2.5 h-2.5`}),`behind`]}):null]});case`deleted`:return(0,B.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,B.jsx)(`span`,{className:`text-warn`,...r,children:n})}}var Qje=(0,v.memo)(function({row:e,checked:t,onToggle:n,phrase:r,hit:i}){let a=O7(e),o=e=>r?.litNames?y7(e,r.query,r.options).map((e,t)=>e.hit?(0,B.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,B.jsx)(`span`,{children:e.text},t)):e;return(0,B.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,B.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:t,disabled:a,onChange:()=>n(e.id),"aria-label":e.title??e.firstPrompt??e.id}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block truncate text-sm`,children:e.title||e.firstPrompt?o(e.title||e.firstPrompt||``):(0,B.jsx)(`span`,{className:`text-fg-faint`,children:`(no prompt)`})}),(0,B.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-fg-faint`,children:[e.projectName?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,B.jsx)(H.Project,{className:`w-3 h-3`}),o(e.projectName)]}):(0,B.jsxs)(B.Fragment,{children:[e.cwd?(0,B.jsx)(`span`,{title:e.cwd,children:o(M7(e.cwd))}):M7(e.cwd),e.cwd&&!e.cwdExists?` · folder is gone`:``]}),` `,`· `,e.entryCount,` entries`,e.bytes>0?` · ${Gje(e.bytes)}`:``,e.model?` · ${e.model}`:``]}),e.unavailable||e.note?(0,B.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,B.jsx)(eMe,{hit:i,query:r.query,options:r.options,testId:`import-row-hits-${e.id}`}):null]}),e.supersedes&&e.supersedes.length>0?(0,B.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,B.jsxs)(`span`,{className:`mt-0.5 flex shrink-0 flex-col items-end gap-0.5 text-right text-[11px]`,children:[(0,B.jsx)(`span`,{className:`whitespace-nowrap text-fg-faint`,children:Kje(e.lastEntryAt??e.updatedAt)}),(0,B.jsx)(`span`,{className:`whitespace-nowrap`,children:(0,B.jsx)(Zje,{row:e,status:D7(e)})})]})]})});function $je(e){let t=e.kind===`tool`?e.tool??`Tool`:e.role===`assistant`?`Model`:`You`;return e.subagent?`${t} (subagent)`:t}function eMe({hit:e,query:t,options:n,testId:r}){return(0,B.jsxs)(`span`,{className:`mt-1 block space-y-0.5`,"data-testid":r,children:[(0,B.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,B.jsxs)(`span`,{className:`block line-clamp-2 text-[11px] text-fg-muted`,"data-testid":`import-row-snippet`,children:[(0,B.jsxs)(`span`,{className:`font-medium text-fg-faint`,children:[$je(e),`:`]}),` `,y7(e.snippet,t,n).map((e,t)=>e.hit?(0,B.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,B.jsx)(`span`,{children:e.text},t))]},r))]})}function tMe({query:e,conversations:t,request:n,answer:r,matches:i,messages:a,capped:o}){let s=(e,t,n=`text-fg-muted`)=>(0,B.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=Wje(c),u=c.sources.filter(e=>e.note).map(e=>`${e.agentName}: ${e.note}`);return(0,B.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,B.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`import-search-source-note`,children:e},e))]})}function nMe({id:e,title:t,icon:n,count:r,collapsed:i,onToggle:a,onRemove:o,removeLabel:s,grow:c,drag:l,children:u}){return(0,B.jsxs)(`section`,{"aria-label":t,"data-testid":`section-${e}`,style:{flexGrow:c,flexShrink:1,flexBasis:i?`auto`:0},className:z(`relative flex min-h-0 flex-col border-b border-border last:border-b-0`,l?.hint===`before`&&`shadow-[inset_0_2px_0_0_var(--color-accent)]`,l?.hint===`after`&&`shadow-[inset_0_-2px_0_0_var(--color-accent)]`),onDragOver:l?.onDragOver,onDrop:l?.onDrop,children:[(0,B.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 px-3`,draggable:l?!0:void 0,onDragStart:l?.onDragStart,onDragEnd:l?.onDragEnd,children:[(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":!i,"aria-controls":`section-body-${e}`,"data-testid":`section-header-${e}`,onClick:a,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,title:i?`Open ${t}`:`Fold ${t}`,children:[(0,B.jsx)(H.Chevron,{open:!i,className:`w-3 h-3 text-fg-faint`}),n?(0,B.jsx)(n,{className:`w-3.5 h-3.5 text-fg-faint`}):null,(0,B.jsxs)(`span`,{className:`truncate text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:[t,typeof r==`number`?` · ${r}`:``]})]}),o?(0,B.jsx)(lC,{label:s??`Hide ${t}`,className:`p-1`,onClick:o,children:(0,B.jsx)(H.X,{className:`w-3.5 h-3.5`})}):null]}),(0,B.jsx)(`div`,{id:`section-body-${e}`,"data-testid":`section-body-${e}`,hidden:i,className:z(`min-h-0 flex-1 flex-col`,i?`hidden`:`flex`),children:u})]})}function P7({items:e,onPick:t,testId:n,label:r,multi:i=!1,className:a,footer:o}){let s=(0,v.useRef)(null);return(0,B.jsxs)(`div`,{ref:s,role:`tablist`,"aria-orientation":`vertical`,"aria-label":r,"data-testid":n,onKeyDown:e=>{if(![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;let t=Array.from(s.current?.querySelectorAll(`button[role="tab"]`)??[]);if(t.length===0)return;let n=t.indexOf(document.activeElement),r=e.key===`Home`?0:e.key===`End`?t.length-1:n<0?0:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length;e.preventDefault(),t[r]?.focus()},className:z(`flex w-12 shrink-0 flex-col items-center gap-1 border-border bg-surface py-2`,a),children:[e.map(n=>(0,B.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n.active,"aria-label":n.label,title:n.label,"data-testid":`activity-${n.id}`,tabIndex:n.active||!i&&e.every(e=>!e.active)?0:-1,onClick:()=>t(n.id),className:z(`relative flex h-10 w-10 items-center justify-center rounded-md`,n.active?`bg-surface-2 text-fg shadow-[inset_2px_0_0_0_var(--color-accent)]`:`text-fg-muted hover:bg-surface-2 hover:text-fg`),children:[(0,B.jsx)(n.icon,{className:`w-5 h-5`}),typeof n.count==`number`&&n.count>0?(0,B.jsx)(`span`,{className:`absolute bottom-1 right-1 min-w-3.5 rounded-full bg-accent px-1 text-[9px] leading-[14px] text-white`,children:n.count>99?`99+`:n.count}):null]},n.id)),o?(0,B.jsx)(`div`,{className:`mt-auto flex flex-col items-center gap-1`,children:o}):null]})}var F7=[{kind:`photo`,label:`Photos`,empty:`No pictures in this chat yet.`},{kind:`video`,label:`Videos`,empty:`No videos in this chat yet.`},{kind:`audio`,label:`Audio`,empty:`No sound files in this chat yet.`},{kind:`file`,label:`Files`,empty:`No files in this chat yet.`},{kind:`link`,label:`Links`,empty:`No links in this chat yet.`}];function rMe(e){let t=[];for(let n of e){let e=n.at?new Date(n.at):null,r=e!==null&&!Number.isNaN(e.getTime()),i=r?`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}`:`unknown`,a=t[t.length-1];(!a||a.key!==i)&&(a={key:i,label:r?e.toLocaleDateString(void 0,{month:`long`,year:`numeric`}):`Undated`,items:[]},t.push(a)),a.items.push(n)}return t}function I7(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(void 0,{day:`numeric`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}function iMe(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`})}function L7(e){let t=[];e.size!==null&&e.size>=0&&t.push(HF(e.size));let n=I7(e.at);return n&&t.push(n),t.join(` · `)}function R7(e){return e.source===`removed`?!1:e.source!==`path`||e.exists!==!1}function z7(e){return e.source===`removed`?e.removedAfterDays?`Removed after ${e.removedAfterDays} day${e.removedAfterDays===1?``:`s`}`:`Removed to save space`:e.source===`path`&&e.exists===!1?`Moved or deleted`:null}function aMe(e,t){let n=new Set(e.map(e=>e.id));return[...e,...t.filter(e=>!n.has(e.id))]}function oMe(e){try{let t=new URL(e),n=`${t.pathname===`/`?``:t.pathname}${t.search}${t.hash}`;return{host:t.host,rest:n}}catch{return{host:e,rest:``}}}function sMe(e,t){if(!t||!e)return null;let n=`u:${t}`;for(let r of e)if(r.id===n||r.uuid===t)return r.id;return null}function cMe(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return btoa(n)}var lMe=[{value:`all`,label:`All`,title:`Everything in this chat`},{value:`user`,label:`Mine`,title:`What you sent`},{value:`assistant`,label:`Replies`,title:`What the model’s replies contain`}];function B7(e){let t=e.getBoundingClientRect();return{x:t.left+24,y:t.bottom}}function V7(e,t){return{onContextMenu:n=>{n.preventDefault();let r=n.currentTarget;t(e,n.clientX===0&&n.clientY===0?B7(r):{x:n.clientX,y:n.clientY},r)},onKeyDown:n=>{(n.key===`ContextMenu`||n.shiftKey&&n.key===`F10`)&&(n.preventDefault(),t(e,B7(n.currentTarget),n.currentTarget))}}}var uMe=60,dMe=800,H7={items:[],nextBefore:null,missingHidden:0,loaded:!1,loading:!1,error:null};function U7(){return{photo:H7,video:H7,audio:H7,file:H7,link:H7}}function fMe({sessionId:e,onTotal:t}){let{state:n,actions:r,api:i}=V(),a=n.remote.tabs[e]!==void 0,o=n.drafts[e]!==void 0,s=n.transcripts[e]??null,c=(0,v.useCallback)(()=>r.setMediaPanel(!1),[r]),[l,u]=(0,v.useState)(`photo`),[d,f]=(0,v.useState)(`all`),p=(0,v.useRef)(d);p.current=d;let[m,h]=(0,v.useState)(!1),g=(0,v.useRef)(m);g.current=m;let[_,y]=(0,v.useState)(U7),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(null),E=(0,v.useRef)(_);E.current=_;let D=(0,v.useRef)(!0);(0,v.useEffect)(()=>(D.current=!0,()=>{D.current=!1}),[]);let O=!a&&!o&&typeof i.listChatMedia==`function`,k=(0,v.useCallback)(async()=>{if(i.grantChatMedia)try{let t=await i.grantChatMedia(e);D.current&&T(()=>t.urlOf)}catch{}},[i,e]);(0,v.useEffect)(()=>{O&&k()},[O,k]);let A=(0,v.useCallback)(async(t,n)=>{if(!i.listChatMedia)return;let r=E.current[t];if(r.loading||n===`more`&&!r.nextBefore)return;y(e=>({...e,[t]:{...e[t],loading:!0,error:null}}));let a=p.current,o=g.current,s;try{s=await i.listChatMedia(e,{kind:t,...a===`all`?{}:{from:a},missing:o?`show`:`hide`,limit:uMe,...n===`more`&&r.nextBefore?{before:r.nextBefore}:{}})}catch(e){if(!D.current||p.current!==a||g.current!==o)return;Zg(e)&&e.code!==`session_not_found`&&C(!0),y(n=>({...n,[t]:{...n[t],loading:!1,loaded:!0,error:e instanceof Error?e.message:`The media list could not be read.`}}));return}!D.current||p.current!==a||g.current!==o||(x(s.counts),y(e=>({...e,[t]:{items:n===`more`?aMe(e[t].items,s.items):s.items,nextBefore:s.nextBefore,missingHidden:s.missingHidden??0,loaded:!0,loading:!1,error:null}})))},[i,e]);(0,v.useEffect)(()=>{O&&(E.current[l].loaded||A(l,`first`))},[O,l,A,d,m]);let j=(0,v.useMemo)(()=>s?s.items.filter(e=>e.kind===`user`||d!==`user`&&e.kind===`assistant`&&!e.streaming).length:0,[s,d]),ee=(0,v.useRef)(j);(0,v.useEffect)(()=>{if(!O||j===ee.current)return;let e=setTimeout(()=>{ee.current=j,y(e=>{let t=U7();return t[l]={...e[l],loaded:!0},t}),A(l,`first`)},dMe);return()=>clearTimeout(e)},[O,j,l,A]);let M=n.connection.status===`open`,te=(0,v.useRef)(!1),ne=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!M){te.current&&(ne.current=!0);return}te.current=!0,ne.current&&(ne.current=!1,O&&(C(!1),x(null),E.current=U7(),y(U7()),k(),A(l,`first`)))},[M,O,k,A,l]);let N=(0,v.useCallback)(()=>{C(!1),x(null),E.current=U7(),y(U7()),k(),A(l,`first`)},[k,A,l]),P=r.toast,re=(0,v.useCallback)(e=>{p.current!==e&&(p.current=e,E.current=U7(),y(U7()),x(null),f(e))},[]),ie=(0,v.useCallback)(e=>{g.current!==e&&(g.current=e,E.current=U7(),y(U7()),x(null),h(e))},[]),[ae,oe]=(0,v.useState)(null),se=(0,v.useCallback)((e,t,n)=>oe({item:e,at:t,el:n}),[]),F=(0,v.useCallback)(()=>oe(null),[]),ce=(0,v.useCallback)(t=>{let n=sMe(s?.items,t.entryUuid);if(!n){P(`info`,`That message is not loaded in this window yet — scroll up in the chat.`);return}r.jumpToItem(e,n),typeof window<`u`&&typeof window.matchMedia==`function`&&!window.matchMedia(`(min-width: 1024px)`).matches&&c()},[r,c,P,e,s?.items]),le=(0,v.useCallback)(async t=>{if(!i.readChatMedia)return null;try{return cMe(await i.readChatMedia(e,t.id))}catch(e){return P(`error`,`${t.name} could not be read: ${e instanceof Error?e.message:`unknown error`}`),null}},[i,P,e]),ue=(0,v.useCallback)(async e=>{if(e.source===`path`&&e.path){await JL(e.path,P);return}let t=await le(e);t!==null&&await XL({name:e.name,mediaType:e.mediaType.split(`;`)[0]??e.mediaType,base64:t},P)},[P,le]),de=typeof window<`u`?window.oonacode:void 0,fe=de?.showItemInFolder?e=>{e.path&&de.showItemInFolder?.(e.path).then(e=>{!e.ok&&e.message&&P(`error`,e.message)},()=>P(`error`,`The folder could not be opened.`))}:null,[pe,me]=(0,v.useState)(null),he=(0,v.useMemo)(()=>_.photo.items.filter(R7),[_.photo.items]),ge=(0,v.useCallback)(async(e,t=he)=>{let n=t[e];if(!n)return;let r=await le(n);r===null||!D.current||me({index:e,picture:{id:n.id,name:n.name,mediaType:n.mediaType,base64:r}})},[le,he]),_e=(0,v.useCallback)(()=>me(null),[]),ve=pe?{index:pe.index,total:he.length,onPrev:pe.index>0?()=>void ge(pe.index-1):null,onNext:pe.index<he.length-1?()=>void ge(pe.index+1):null}:void 0,[ye,be]=(0,v.useState)(null),xe=(0,v.useCallback)((e,t)=>{navigator.clipboard.writeText(e).then(()=>P(`success`,`${t} copied.`),()=>P(`error`,`${t} could not be copied.`))},[P]),Se=(0,v.useMemo)(()=>{let e=ae?.item;if(!e)return[];let t=[],n=z7(e)!==null;if(e.kind===`link`&&e.url){let n=e.url;t.push({key:`open`,label:`Open in browser`,icon:(0,B.jsx)(H.ExternalLink,{className:`w-3.5 h-3.5`}),onSelect:()=>O5(n)})}else if(e.kind===`photo`){let r=he.findIndex(t=>t.id===e.id);t.push({key:`open`,label:`View`,icon:(0,B.jsx)(H.Image,{className:`w-3.5 h-3.5`}),disabled:n||r<0,onSelect:()=>void ge(r)})}else e.kind===`video`?t.push({key:`open`,label:`Play`,icon:(0,B.jsx)(H.Play,{className:`w-3.5 h-3.5`}),disabled:n,onSelect:()=>be(e)}):t.push({key:`open`,label:e.kind===`audio`?`Open externally`:`Open`,icon:(0,B.jsx)(H.ExternalLink,{className:`w-3.5 h-3.5`}),disabled:n,onSelect:()=>void ue(e)});if(t.push({key:`show-in-chat`,label:`Show in chat`,icon:(0,B.jsx)(H.Chats,{className:`w-3.5 h-3.5`}),hint:e.from===`assistant`?`reply`:`your message`,onSelect:()=>ce(e),testId:`media-menu-show-in-chat`}),fe&&e.source===`path`&&e.exists!==!1&&t.push({key:`folder`,label:`Show in folder`,icon:(0,B.jsx)(H.Folder,{className:`w-3.5 h-3.5`}),onSelect:()=>fe(e)}),e.kind===`link`&&e.url){let n=e.url;t.push({key:`copy`,label:`Copy link`,icon:(0,B.jsx)(H.Copy,{className:`w-3.5 h-3.5`}),separated:!0,onSelect:()=>xe(n,`The link`)})}else if(e.path){let n=e.path;t.push({key:`copy`,label:`Copy path`,icon:(0,B.jsx)(H.Copy,{className:`w-3.5 h-3.5`}),separated:!0,onSelect:()=>xe(n,`The path`)})}return t},[ae,he,ge,ue,ce,fe,xe]),Ce=b?Object.values(b).reduce((e,t)=>e+t,0):null;(0,v.useEffect)(()=>{t?.(Ce)},[t,Ce]);let we=_[l],Te=b??Fh();return(0,B.jsxs)(B.Fragment,{children:[a?(0,B.jsx)(W7,{children:`This chat runs on another PC. Its pictures and files are on that PC — open the media explorer there.`}):o?(0,B.jsx)(W7,{children:`Nothing has been sent in this chat yet.`}):!O||S?(0,B.jsxs)(W7,{children:[`This PC's OonaCode does not list a chat's media yet — update it.`,` `,O?(0,B.jsx)(`button`,{type:`button`,className:`underline`,onClick:N,"data-testid":`media-retry-unsupported`,children:`Try again`}):null]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{role:`group`,"aria-label":`Whose media`,className:`flex shrink-0 gap-0.5 border-b border-border px-1.5 py-1`,"data-testid":`media-from`,children:lMe.map(e=>(0,B.jsx)(`button`,{type:`button`,"aria-pressed":d===e.value,title:e.title,onClick:()=>re(e.value),"data-testid":`media-from-${e.value}`,className:z(`flex-1 rounded-md px-2 py-1 text-xs`,d===e.value?`bg-accent-soft font-semibold text-accent`:`text-fg-muted hover:bg-surface-2 hover:text-fg`),children:e.label},e.value))}),(0,B.jsx)(`div`,{role:`tablist`,"aria-label":`Kinds of media`,className:`flex shrink-0 gap-0.5 overflow-x-auto border-b border-border px-1.5 py-1`,onKeyDown:e=>{if(e.key!==`ArrowRight`&&e.key!==`ArrowLeft`)return;let t=F7[(F7.findIndex(e=>e.kind===l)+(e.key===`ArrowRight`?1:-1)+F7.length)%F7.length];u(t.kind),e.preventDefault(),requestAnimationFrame(()=>document.getElementById(`media-tab-${t.kind}`)?.focus())},children:F7.map(e=>(0,B.jsxs)(`button`,{id:`media-tab-${e.kind}`,type:`button`,role:`tab`,"aria-selected":l===e.kind,"aria-controls":`media-tabpanel`,tabIndex:l===e.kind?0:-1,onClick:()=>u(e.kind),"data-testid":`media-tab-${e.kind}`,className:z(`flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs`,l===e.kind?`bg-surface-2 font-semibold text-fg`:`text-fg-muted hover:bg-surface-2 hover:text-fg`),children:[e.label,(0,B.jsx)(`span`,{className:`rounded-full bg-surface-3 px-1.5 text-[10px] tabular-nums text-fg-muted`,"data-testid":`media-count-${e.kind}`,children:Te[e.kind]})]},e.kind))}),(0,B.jsxs)(`div`,{id:`media-tabpanel`,role:`tabpanel`,"aria-labelledby":`media-tab-${l}`,className:`min-h-0 flex-1 overflow-y-auto px-2 py-2`,"data-testid":`media-tabpanel`,children:[we.error&&we.items.length===0?(0,B.jsxs)(`div`,{className:`p-2 text-xs text-danger`,role:`alert`,children:[we.error,` `,(0,B.jsx)(`button`,{type:`button`,className:`underline`,onClick:N,"data-testid":`media-retry`,children:`Try again`})]}):we.loaded&&we.items.length===0?(0,B.jsx)(`div`,{className:`p-4 text-center text-xs text-fg-faint`,"data-testid":`media-empty`,children:F7.find(e=>e.kind===l)?.empty}):l===`photo`||l===`video`?(0,B.jsx)(mMe,{items:we.items,urlOf:w,onOpen:e=>{if(e.kind===`photo`){let t=he.findIndex(t=>t.id===e.id);t>=0&&ge(t)}else be(e)},onShowInChat:ce,onBroken:k,onMenu:se}):(0,B.jsx)(`ul`,{className:`flex flex-col gap-1`,"data-testid":`media-list`,children:we.items.map(e=>(0,B.jsx)(_Me,{item:e,urlOf:w,onOpen:()=>e.kind===`link`&&e.url?O5(e.url):void ue(e),onShowInFolder:fe&&e.source===`path`&&e.exists!==!1?()=>fe(e):null,onShowInChat:()=>ce(e),onMenu:se,onBroken:k,showOwner:d===`all`},e.id))}),!m&&we.loaded&&we.missingHidden>0?(0,B.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-fg-muted`,"data-testid":`media-missing-hidden`,children:[(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[we.missingHidden,` file`,we.missingHidden===1?``:`s`,` the replies named `,we.missingHidden===1?`is`:`are`,` not on this PC any more — left out.`]}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>ie(!0),"data-testid":`media-show-missing`,children:`Show`})]}):null,m&&we.items.some(e=>e.exists===!1)?(0,B.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-fg-muted`,"data-testid":`media-missing-shown`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Showing files that are not on this PC any more.`}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>ie(!1),"data-testid":`media-hide-missing`,children:`Hide them`})]}):null,we.loading?(0,B.jsxs)(`div`,{className:`flex justify-center p-3 text-fg-faint`,"aria-live":`polite`,children:[(0,B.jsx)(H.Spinner,{className:`w-4 h-4 animate-spin`}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Loading…`})]}):we.nextBefore?(0,B.jsx)(pMe,{onLoad:()=>void A(l,`more`)}):null]})]}),(0,B.jsx)(ow,{open:ae!==null,at:ae?.at??{x:0,y:0},anchorEl:ae?.el??null,label:`Media actions`,testId:`media-context-menu`,onClose:F,items:Se}),(0,B.jsx)(rR,{picture:pe?.picture??null,onClose:_e,notify:P,...ve?{nav:ve}:{}}),(0,B.jsx)(vMe,{item:ye,src:ye&&w?w(ye.id):null,onClose:()=>be(null),onOpen:ye?()=>void ue(ye):null})]})}function W7({children:e}){return(0,B.jsx)(`div`,{className:`p-4 text-xs text-fg-faint`,"data-testid":`media-note`,children:e})}function pMe({onLoad:e}){let t=(0,v.useRef)(null),n=(0,v.useRef)(e);return n.current=e,(0,v.useEffect)(()=>{let e=t.current;if(!e||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&n.current()});return r.observe(e),()=>r.disconnect()},[]),(0,B.jsx)(`div`,{ref:t,className:`flex justify-center p-2`,children:(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:e,"data-testid":`media-load-more`,children:`Load more`})})}function mMe({items:e,urlOf:t,onOpen:n,onShowInChat:r,onBroken:i,onMenu:a}){let o=(0,v.useMemo)(()=>rMe(e),[e]);return(0,B.jsx)(`div`,{className:`flex flex-col gap-3`,"data-testid":`media-grid`,children:o.map(e=>(0,B.jsxs)(`section`,{"aria-label":e.label,children:[(0,B.jsx)(`h3`,{className:`mb-1 px-0.5 text-[11px] font-semibold text-fg-faint`,children:e.label}),(0,B.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:e.items.map(e=>(0,B.jsx)(hMe,{item:e,src:t&&R7(e)?t(e.id):null,onOpen:()=>n(e),onShowInChat:()=>r(e),onBroken:i,onMenu:a},e.id))})]},e.key))})}function hMe({item:e,src:t,onOpen:n,onShowInChat:r,onBroken:i,onMenu:a}){let o=z7(e),[s,c]=(0,v.useState)(!1),l=(0,v.useRef)(!1),u=`${e.name}${e.at?` — ${I7(e.at)}`:``}`,d=iMe(e.at);return(0,B.jsxs)(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface-2`,"data-testid":`media-tile`,"data-media-id":e.id,"data-from":e.from,...V7(e,a),children:[o?(0,B.jsxs)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-0.5 overflow-hidden p-1 text-center text-[10px] leading-tight text-fg-faint`,title:`${u} — ${o.toLowerCase()}${e.path?` (${e.path})`:``}`,"data-testid":`media-tile-unavailable`,children:[e.kind===`video`?(0,B.jsx)(H.Film,{className:`w-4 h-4 shrink-0`}):(0,B.jsx)(H.Image,{className:`w-4 h-4 shrink-0`}),(0,B.jsx)(`span`,{className:`text-warn`,"data-testid":`media-tile-reason`,children:o}),(0,B.jsx)(`span`,{className:`line-clamp-2 break-all font-medium text-fg-muted`,"data-testid":`media-tile-name`,children:e.name}),d?(0,B.jsx)(`span`,{"data-testid":`media-tile-date`,children:d}):null]}):(0,B.jsxs)(`button`,{type:`button`,onClick:n,title:u,"aria-label":`${e.kind===`video`?`Play`:`View`} ${u}`,className:`block h-full w-full focus:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"data-testid":`media-tile-open`,children:[t&&!s?e.kind===`video`?(0,B.jsx)(`video`,{src:`${t}#t=0.1`,preload:`metadata`,muted:!0,className:`pointer-events-none h-full w-full object-cover`,onError:()=>c(!0)}):(0,B.jsx)(`img`,{src:t,alt:e.name,loading:`lazy`,draggable:!1,className:`h-full w-full object-cover`,onError:()=>{if(!l.current){l.current=!0,i();return}c(!0)}}):(0,B.jsx)(`span`,{className:`flex h-full w-full items-center justify-center text-fg-faint`,children:e.kind===`video`?(0,B.jsx)(H.Film,{className:`w-5 h-5`}):(0,B.jsx)(H.Image,{className:`w-5 h-5`})}),e.kind===`video`?(0,B.jsx)(`span`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,B.jsx)(`span`,{className:`rounded-full bg-black/55 p-2 text-white`,children:(0,B.jsx)(H.Play,{className:`w-4 h-4`})})}):null]}),(0,B.jsx)(`button`,{type:`button`,onClick:r,title:`Show in chat`,"aria-label":`Show ${e.name} in chat`,className:`absolute bottom-1 right-1 rounded bg-black/55 p-1 text-white opacity-0 transition-opacity focus:opacity-100 group-hover:opacity-100`,"data-testid":`media-show-in-chat`,children:(0,B.jsx)(H.Chats,{className:`w-3 h-3`})})]})}function gMe(e){return e.kind===`link`?(0,B.jsx)(H.Link,{className:`w-4 h-4`}):e.kind===`audio`?(0,B.jsx)(H.Music,{className:`w-4 h-4`}):e.kind===`video`?(0,B.jsx)(H.Film,{className:`w-4 h-4`}):e.kind===`photo`?(0,B.jsx)(H.Image,{className:`w-4 h-4`}):(0,B.jsx)(H.File,{className:`w-4 h-4`})}function _Me({item:e,urlOf:t,onOpen:n,onShowInFolder:r,onShowInChat:i,onMenu:a,onBroken:o,showOwner:s}){let[c,l]=(0,v.useState)(!1),u=z7(e),d=e.kind===`link`,f=d&&e.url?oMe(e.url):null,p=d?I7(e.at):L7(e),m=e.kind===`audio`&&!u&&t!==null;return(0,B.jsxs)(`li`,{className:`rounded-md border border-transparent px-1.5 py-1.5 hover:border-border hover:bg-surface-2`,"data-testid":`media-row`,"data-media-id":e.id,"data-from":e.from,...V7(e,a),children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[m?(0,B.jsx)(lC,{label:c?`Hide the player for ${e.name}`:`Play ${e.name}`,className:`shrink-0 rounded-full bg-accent-soft p-1.5 text-accent`,onClick:()=>l(e=>!e),"aria-pressed":c,"data-testid":`media-play`,children:c?(0,B.jsx)(H.Pause,{className:`w-3.5 h-3.5`}):(0,B.jsx)(H.Play,{className:`w-3.5 h-3.5`})}):e.kind===`file`?(0,B.jsx)(VI,{name:e.name,className:`shrink-0`}):(0,B.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-3 p-1.5 text-fg-muted`,"aria-hidden":!0,children:gMe(e)}),(0,B.jsxs)(`button`,{type:`button`,onClick:u?void 0:n,disabled:u!==null,title:u?`${e.name} — ${u.toLowerCase()}${e.path?` (${e.path})`:``}`:d?`Open ${e.url??``} in the browser`:e.path?`Open ${e.path}`:`Open ${e.name}`,className:`min-w-0 flex-1 text-left disabled:cursor-default`,"data-testid":`media-row-open`,children:[f?(0,B.jsxs)(`span`,{className:`block truncate text-xs`,children:[(0,B.jsx)(`span`,{className:`font-medium text-accent`,children:f.host}),(0,B.jsx)(`span`,{className:`text-fg-muted`,children:f.rest})]}):(0,B.jsx)(`span`,{className:`block truncate text-xs font-medium text-fg`,children:e.name}),(0,B.jsxs)(`span`,{className:`block truncate text-[11px] text-fg-faint`,children:[u?(0,B.jsx)(`span`,{className:`text-warn`,"data-testid":`media-unavailable`,children:u}):null,u&&p?` · `:``,s?(0,B.jsx)(`span`,{"data-testid":`media-owner`,children:e.from===`assistant`?`Reply`:`You`}):null,s&&p?` · `:``,p]})]}),r?(0,B.jsx)(lC,{label:`Show in folder`,className:`shrink-0 p-1`,onClick:r,children:(0,B.jsx)(H.Folder,{className:`w-3.5 h-3.5`})}):null,(0,B.jsx)(lC,{label:`Show in chat`,className:`shrink-0 p-1`,onClick:i,"data-testid":`media-show-in-chat`,children:(0,B.jsx)(H.Chats,{className:`w-3.5 h-3.5`})})]}),c&&m&&t?(0,B.jsx)(`audio`,{controls:!0,autoPlay:!0,preload:`none`,src:t(e.id),onError:o,className:`mt-1.5 h-8 w-full`,"data-testid":`media-audio`}):null]})}function vMe({item:e,src:t,onClose:n,onOpen:r}){return(0,B.jsx)(gC,{open:e!==null,title:e?.name||`Video`,onClose:n,full:!0,children:e?(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2`,"data-testid":`video-viewer`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-faint`,children:L7(e)}),r?(0,B.jsx)(U,{size:`sm`,onClick:r,children:`Open externally`}):null]}),t?(0,B.jsx)(`video`,{src:t,controls:!0,autoPlay:!0,className:`min-h-0 w-full flex-1 rounded-md bg-black`,"data-testid":`video-viewer-player`}):(0,B.jsx)(`p`,{className:`text-xs text-fg-faint`,children:`This video cannot be played here.`})]}):null})}var yMe={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 bMe(e,t){let n=t?oc(t):null,r=null,i=null;for(let t=0;t<e.length;t++){let a=e[t];if(!a||a.kind!==`assistant`||!se(a.model))continue;let o=oc(a.model);n!==null&&o!==n&&(r=t,i=n),n=o}return{index:r,from:i,to:n}}function xMe(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 yMe;let s=bMe(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?oc(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??S.map(e=>Bee(e)).find(e=>e!==null)??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 SMe=[...Vf.what,...Vf.when,...Vf.who,...Vf.yours,...Vf.where];function CMe({sessionId:e,entryCount:t}){let{state:n,actions:r}=V(),i=n.chatAboutsChange,a=vf(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,Af(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(zf(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=Bf(f,a.maxWords),A=zf(f),j=jf(o);return(0,B.jsxs)(`div`,{className:`mb-2`,"data-testid":`session-about`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,children:(0,B.jsx)(H.Skill,{className:`w-3.5 h-3.5`})}),`About`,(0,B.jsx)(uC,{label:`About`,details:(0,B.jsx)(dC,{items:SMe})}),o.stale&&o.about?(0,B.jsx)(`span`,{title:Vf.stale,"data-testid":`session-about-stale`,children:(0,B.jsx)(hC,{tone:`warn`,children:`stale`})}):null]}),u?(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(`textarea`,{className:z(pC,`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,B.jsxs)(`div`,{className:z(`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`),` /`,` `,gf.userChars.toLocaleString(`en-US`),` characters`]}),A?(0,B.jsx)(`div`,{className:`text-[11px] text-danger`,"data-testid":`session-about-problem`,children:A}):k.overWords?(0,B.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,B.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,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:()=>void D(),busy:m,disabled:A!==null,"data-testid":`session-about-save`,children:`Save`}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>d(!1),disabled:m,"data-testid":`session-about-cancel`,children:`Cancel`})]})]}):(0,B.jsxs)(B.Fragment,{children:[o.about?(0,B.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-xs text-fg`,"data-testid":`session-about-text`,children:o.about}):(0,B.jsxs)(`p`,{className:`text-[11px] text-fg-muted`,"data-testid":`session-about-missing`,children:[`No about yet. `,Lf(o,{enabled:a.enabled,entryCount:t})]}),o.about&&o.aboutAt?(0,B.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,title:zv(o.aboutAt),"data-testid":`session-about-written`,children:[`Written `,Lv(o.aboutAt),j?` by ${j}`:``]}):null,o.about&&o.pending?(0,B.jsx)(`div`,{className:`text-[11px] text-accent`,children:`Being written again now…`}):null,o.about&&o.lastError?(0,B.jsxs)(`div`,{className:`text-[11px] text-danger`,"data-testid":`session-about-last-error`,children:[`The last attempt failed: `,o.lastError]}):null,(0,B.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,title:o.route?`Paid by ${Mf[o.route]}`:void 0,"data-testid":`session-about-spend`,children:[`Cost so far: `,Ff(o.spend,o.route)]}),x?(0,B.jsx)(`div`,{className:`mt-0.5 text-[11px] text-fg-muted`,"data-testid":`session-about-note`,children:x}):null,y?(0,B.jsx)(`div`,{className:`mt-0.5 text-[11px] text-danger`,role:`alert`,"data-testid":`session-about-regen-error`,children:y}):null,(0,B.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[(0,B.jsxs)(U,{size:`sm`,variant:`ghost`,onClick:E,disabled:g,title:Vf.edit,"data-testid":`session-about-edit`,children:[(0,B.jsx)(H.Edit,{className:`h-3 w-3`}),` Edit`]}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>void O(),disabled:!a.enabled||g,title:a.enabled?Vf.regenerate:Vf.regenerateOff,"data-testid":`session-about-regenerate`,children:g?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(H.Spinner,{className:`h-3 w-3`}),` Writing…`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(H.Refresh,{className:`h-3 w-3`}),` Regenerate`]})})]}),a.enabled?null:(0,B.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 wMe({view:e}){let t=(0,v.useMemo)(()=>ZAe(e.request??``),[e.request]);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:e.truncated?`Cut at the size the host keeps.`:`As agy sent it.`}),(0,B.jsx)(ZI,{text:t})]}),(0,B.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 TMe({sessionId:e,running:t}){let{api:n}=V(),[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;Zg(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)(()=>qAe(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(Zg(e)?{phase:`gone`}:{phase:`failed`,message:Kv(e)})}};if(a||r===null)return null;let S=e=>{let{title:t,detail:n}=n7(e),r=JAe(e),i=YAe(e.usage),a=p[e.id],o=[n,e.ms===null?`running…`:Fv(e.ms),i].filter(e=>!!e),s=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`span`,{className:`flex items-baseline gap-1.5`,children:[(0,B.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-fg-faint`,title:zv(e.at),children:XAe(e.at)}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-fg`,children:t}),(0,B.jsx)(`span`,{className:z(`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,B.jsx)(`span`,{className:`block break-words text-[11px] text-fg-faint`,children:o.join(` · `)}),e.error?(0,B.jsx)(`span`,{className:`block break-words text-[11px] text-danger`,children:e.error}):null]});return(0,B.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,B.jsx)(`button`,{type:`button`,className:`block w-full text-left`,"aria-expanded":a!==void 0,title:`${r7(e)} — show the request`,onClick:()=>void x(e),"data-testid":`agy-request-open-${e.id}`,children:s}):(0,B.jsx)(`div`,{title:r7(e),children:s}),a?(0,B.jsx)(`div`,{className:`mt-1`,"data-testid":`agy-request-body-${e.id}`,children:a.phase===`loading`?(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-fg-muted`,children:[(0,B.jsx)(H.Spinner,{className:`h-3 w-3`}),` Loading the request…`]}):a.phase===`gone`?(0,B.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,B.jsxs)(`div`,{className:`text-[11px] text-danger`,role:`alert`,children:[`Could not read it: `,a.message]}):(0,B.jsx)(wMe,{view:a.view})}):null]},e.id)};return(0,B.jsxs)(`div`,{className:`mb-2`,"data-testid":`agy-requests`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,B.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,B.jsx)(`span`,{"aria-hidden":`true`,children:(0,B.jsx)(H.Chevron,{className:`h-3 w-3`,open:l})}),`Google agy requests`,(0,B.jsx)(`span`,{className:`font-mono normal-case tracking-normal`,"data-testid":`agy-requests-count`,children:r.length})]}),(0,B.jsx)(lC,{label:`Refresh agy requests`,className:`p-1`,disabled:s,onClick:()=>void g(),"data-testid":`agy-requests-refresh`,children:s?(0,B.jsx)(H.Spinner,{className:`h-3 w-3`}):(0,B.jsx)(H.Refresh,{className:`h-3 w-3`})})]}),(0,B.jsx)(`p`,{className:`mb-1 text-[11px] leading-snug text-fg-faint`,"data-testid":`agy-requests-privacy`,children:WAe}),l?(0,B.jsxs)(B.Fragment,{children:[y.length===0?(0,B.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,B.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,B.jsxs)(`div`,{className:`mt-1.5`,children:[(0,B.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,B.jsx)(H.Chevron,{className:`h-3 w-3`,open:d}),`background calls (`,b.length,`)`]}),d?(0,B.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 G7({label:e,icon:t,children:n}){return(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1`,children:[(0,B.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-faint`,children:[t?(0,B.jsx)(`span`,{className:`shrink-0 text-fg-faint`,"aria-hidden":`true`,children:t}):null,e]}),(0,B.jsx)(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-fg`,children:n})]})}function K7({label:e,icon:t}){return(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,children:t}),e]})}var q7={provider:(0,B.jsx)(H.Plug,{className:`w-3.5 h-3.5`}),route:(0,B.jsx)(H.Globe,{className:`w-3.5 h-3.5`}),model:(0,B.jsx)(H.Bot,{className:`w-3.5 h-3.5`}),permission:(0,B.jsx)(H.Shield,{className:`w-3.5 h-3.5`}),context:(0,B.jsx)(H.Brain,{className:`w-3.5 h-3.5`}),window:(0,B.jsx)(H.Panel,{className:`w-3.5 h-3.5`}),compactions:(0,B.jsx)(H.CollapseAll,{className:`w-3.5 h-3.5`}),usage:(0,B.jsx)(H.Coins,{className:`w-3.5 h-3.5`}),tokensIn:(0,B.jsx)(H.Download,{className:`w-3.5 h-3.5`}),tokensOut:(0,B.jsx)(H.Upload,{className:`w-3.5 h-3.5`}),duration:(0,B.jsx)(H.Clock,{className:`w-3.5 h-3.5`}),turns:(0,B.jsx)(H.Send,{className:`w-3.5 h-3.5`}),session:(0,B.jsx)(H.Info,{className:`w-3.5 h-3.5`}),tasks:(0,B.jsx)(H.Bell,{className:`w-3.5 h-3.5`}),status:(0,B.jsx)(H.Monitor,{className:`w-3.5 h-3.5`}),updated:(0,B.jsx)(H.Refresh,{className:`w-3.5 h-3.5`}),entries:(0,B.jsx)(H.Menu,{className:`w-3.5 h-3.5`}),project:(0,B.jsx)(H.Project,{className:`w-3.5 h-3.5`}),folder:(0,B.jsx)(H.Folder,{className:`w-3.5 h-3.5`})};function EMe({used:e}){let t=Math.round(e*100);return(0,B.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,B.jsx)(`div`,{className:z(`h-full rounded-full`,t>=90?`bg-danger`:t>=70?`bg-warn`:`bg-accent`),style:{width:`${t}%`}})})}function DMe(){let{state:e,actions:t,api:n}=V(),r=XS(),[i,a]=(0,v.useState)(null),o=r?e.remote.tabs[r.id]!==void 0:!1,s=r?e.drafts[r.id]!==void 0:!1,c=YS(),l=e.currentSessionId,u=r?.projectId?e.vaultProjects.find(e=>e.id===r.projectId):void 0,d=u?.instructions.trim()??``,f=r?.providerId??e.activeProviderId,p=e.providers.find(e=>e.definition.id===f),m=p?.definition.models,h=(0,v.useMemo)(()=>{let e=p?.definition;return e?Qs(e,{credentialClass:(p.credentials.find(e=>e.variantId===r?.variantId)??p.credentials[0])?.class??null}):null},[p,r?.variantId]),g=(0,v.useMemo)(()=>xMe({items:c?.items??[],session:r,initModel:c?.init?.model??null,boundary:l?e.modelBoundaries[l]??null:null,models:m,contextTokens:c?.contextTokens??null}),[c?.items,c?.init?.model,c?.contextTokens,r,l,e.modelBoundaries,m]),_=(0,v.useMemo)(()=>(c?.items??[]).filter(e=>e.kind===`user`&&e.compactSummary).length,[c?.items]),y=r?Ng(r.providerId)&&!o&&!s:!1,b=c?.status===`running`||c?.status===`waiting_permission`,x=(0,v.useMemo)(()=>{if(!r)return[];let e=new Set,t=[],n=n=>{let r=n.trim();!r||e.has(r)||(e.add(r),t.push(r))};for(let e of r.browserProfiles??[])n(e);for(let e of c?.items??[])if(e.kind===`tool`&&e.name===`mcp__oonacode__browser`){let t=e.input?.action;t!==`help`&&t!==`close`&&t!==`reset`&&n(r.id.replace(/[^a-zA-Z0-9-]/g,`_`).slice(0,64)||`_`)}return t},[r,c?.items]),S=(0,v.useCallback)(async e=>{if(!r||!n.openSessionBrowser){t.toast(`error`,`This PC’s OonaCode cannot open browser profiles yet — update it.`);return}a(e);try{let i=await n.openSessionBrowser(r.id,e);t.toast(`success`,i.alreadyOpen?`Brought Oonak Browser (${i.profile}) to the front`:`Opened Oonak Browser with user-data-dir ${i.profile}`)}catch(e){t.toast(`error`,e instanceof Error&&e.message?e.message:`Could not open Oonak Browser for this profile.`)}finally{a(null)}},[r,n,t]);return(0,B.jsx)(B.Fragment,{children:r?(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-2`,children:[g.didReset?(0,B.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`,g.previousModel?` (was ${g.previousModel})`:``,`.`]}):null,!o&&!s?(0,B.jsx)(CMe,{sessionId:r.id,entryCount:r.entryCount??null},r.id):null,(0,B.jsxs)(`div`,{className:`mb-2`,children:[(0,B.jsx)(K7,{label:`Model`,icon:q7.model}),(0,B.jsx)(G7,{label:`Provider`,icon:q7.provider,children:p?.definition.displayName??f??`—`}),(0,B.jsx)(G7,{label:`Route`,icon:q7.route,children:h?(0,B.jsx)(hC,{tone:h.viaGateway?`accent`:`ok`,children:h.badge}):`—`}),h?(0,B.jsx)(`div`,{className:`pb-1 text-[11px] leading-snug text-fg-faint`,children:h.detail}):null,(0,B.jsx)(G7,{label:`Model`,icon:q7.model,children:g.model??r.model??`—`}),(0,B.jsxs)(G7,{label:`Permission mode`,icon:q7.permission,children:[(0,B.jsx)(hC,{children:ne(re(r))}),` `,(0,B.jsx)(hC,{children:r.permissionMode})]})]}),(0,B.jsxs)(`div`,{className:`mb-2`,children:[(0,B.jsx)(K7,{label:`Context`,icon:q7.context}),g.contextUsed!==null&&g.contextTokens!==null?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(EMe,{used:g.contextUsed}),(0,B.jsxs)(`div`,{className:`mt-1 text-[11px] text-fg-muted`,"data-testid":`context-used`,children:[Iv(g.contextTokens),` / `,Iv(g.contextWindow??0),` `,`tokens (`,Math.round(g.contextUsed*100),`%)`]})]}):(0,B.jsx)(`div`,{className:`text-[11px] text-fg-muted`,"data-testid":`context-used`,children:g.contextTokens===null?`Measured at the next reply`:`${Iv(g.contextTokens)} tokens (window unknown)`}),(0,B.jsx)(G7,{label:`Context window`,icon:q7.window,children:(0,B.jsx)(`span`,{"data-testid":`context-window`,children:g.contextWindow?`${Iv(g.contextWindow)} tokens`:`unknown`})}),(0,B.jsx)(G7,{label:`Compactions`,icon:q7.compactions,children:(0,B.jsx)(`span`,{"data-testid":`compaction-count`,children:_})})]}),(0,B.jsxs)(`div`,{className:`mb-2`,children:[(0,B.jsx)(K7,{label:`Usage`,icon:q7.usage}),(0,B.jsx)(G7,{label:`Tokens in`,icon:q7.tokensIn,children:Iv(g.inputTokens)}),(0,B.jsx)(G7,{label:`Tokens out`,icon:q7.tokensOut,children:Iv(g.outputTokens)}),g.credits===null?null:(0,B.jsx)(G7,{label:`Credits used`,icon:q7.usage,children:g.credits.toLocaleString(`en-US`,{maximumFractionDigits:2})}),(0,B.jsx)(G7,{label:`Duration`,icon:q7.duration,children:g.countedResults>0&&Fv(g.durationMs)||`—`}),(0,B.jsx)(G7,{label:`Turns`,icon:q7.turns,children:g.countedResults>0?g.turns:`—`})]}),(0,B.jsxs)(`div`,{className:`mb-2`,children:[(0,B.jsx)(K7,{label:`Session`,icon:q7.session}),(0,B.jsx)(G7,{label:`Status`,icon:q7.status,children:(0,B.jsx)(hC,{tone:c?.status===`error`?`danger`:c?.status===`running`?`accent`:c?.status===`waiting_permission`?`warn`:`neutral`,children:c?.status??r.status})}),(0,B.jsx)(G7,{label:`Updated`,icon:q7.updated,children:Lv(r.updatedAt)}),(0,B.jsx)(G7,{label:`Entries`,icon:q7.entries,children:r.entryCount}),(0,B.jsx)(G7,{label:`Project`,icon:q7.project,children:(0,B.jsx)(`span`,{"data-testid":`session-project`,children:u?u.name:`—`})}),d?(0,B.jsx)(`div`,{className:`whitespace-pre-wrap break-words pb-1 text-[11px] leading-snug text-fg-faint`,"data-testid":`session-project-instructions`,children:d.length>300?`${d.slice(0,300)}\u2026`:d}):null,o?null:(0,B.jsx)(`button`,{type:`button`,className:`text-[11px] text-accent hover:underline`,onClick:()=>t.openAssignProject(r.id),"data-testid":`session-change-project`,children:u?`Move to another project…`:`Move to a project…`}),(0,B.jsx)(G7,{label:`Folder`,icon:q7.folder,children:r.projectDir?`project`:`own workspace`}),(0,B.jsx)(`div`,{className:`mt-1 break-all font-mono text-[10px] text-fg-faint`,"data-testid":`session-folder`,children:r.cwd}),o?null:(0,B.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…`})]}),x.length>0?(0,B.jsxs)(`div`,{className:`mb-2 space-y-1.5`,"data-testid":`session-browser-profiles`,children:[(0,B.jsx)(K7,{label:`Oonak Browser`,icon:q7.route}),(0,B.jsxs)(`div`,{className:`text-[11px] leading-snug text-fg-faint`,children:[`Browser user-data-dir `,x.length===1?`profile`:`profiles`,` used in this session:`]}),(0,B.jsx)(`div`,{className:`flex flex-col gap-1`,children:x.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border bg-surface-2 px-2 py-1.5`,"data-testid":`session-browser-profile`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1 break-all font-mono text-[11px] text-fg`,title:`user-data-dir: ${e}`,children:e}),!o&&!s?(0,B.jsx)(`button`,{type:`button`,disabled:i!==null,onClick:()=>void S(e),className:`shrink-0 rounded bg-accent px-2 py-0.5 text-[11px] font-medium text-accent-fg hover:opacity-90 disabled:opacity-50`,"data-testid":`session-browser-open`,children:i===e?`Opening…`:`Restore browser`}):null]},e))})]}):null,y?(0,B.jsx)(TMe,{sessionId:r.id,running:b},r.id):null,o?null:(0,B.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`session-scheduled-tasks`,children:[(0,B.jsx)(K7,{label:`Scheduled tasks`,icon:q7.tasks}),(0,B.jsx)(CL,{sessionId:r.id})]}),c?.init?(0,B.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[`engine `,c.init.claudeCodeVersion,` · `,c.init.tools.length,` tools`]}):null]}):(0,B.jsx)(`div`,{className:`p-4 text-xs text-fg-faint`,children:`Open a chat to see its statistics.`})})}var J7=[{id:`media`,title:`Media`,hideLabel:`Hide media`,icon:H.Gallery,available:({sessionId:e})=>e!==null,render:({sessionId:e,reportCount:t})=>e?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`media-panel`,"aria-label":`Media in this chat`,children:(0,B.jsx)(fMe,{sessionId:e,onTotal:t},e)}):null},{id:`sessionInfo`,title:`Session info`,hideLabel:`Hide session info`,icon:H.Info,render:({sessionId:e})=>(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`session-panel`,"aria-label":`Session info`,children:(0,B.jsx)(DMe,{},e??`none`)})}];function Y7(e){return J7.find(t=>t.id===e)}var X7={rightPanelWidth:320};function OMe(e,t){let{state:n,actions:r}=V(),i=n.prefs[e],[a,o]=(0,v.useState)(null),s=a??i,c=(0,B.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the ${t}`,title:`Drag to resize · double-click for the default width`,className:`absolute inset-y-0 -left-1 z-10 hidden w-2 cursor-col-resize hover:bg-accent/30 lg:block`,onPointerDown:t=>{t.preventDefault();let n=t.clientX,a=s,c=a,l=t=>{c=Ql(a+(n-t.clientX),X7[e]),o(c)},u=()=>{window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),document.body.style.cursor=``,document.body.style.userSelect=``,o(null),c!==i&&r.savePrefs({[e]:c})};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u)},onDoubleClick:()=>void r.savePrefs({[e]:X7[e]}),"data-testid":`right-panel-resize`});return{style:{width:`min(${s}px, 85vw)`},handle:c}}function kMe(){let{state:e,actions:t}=V(),{rightPanelSections:n,rightPanelCollapsed:r}=e.prefs,i=e.currentSessionId,a=OMe(`rightPanelWidth`,`right panel`),[o,s]=(0,v.useState)({}),c=(0,v.useMemo)(()=>{let e={};for(let t of J7)e[t.id]=e=>s(n=>n[t.id]===e?n:{...n,[t.id]:e});return e},[]),l=(0,v.useCallback)(e=>Y7(e)?.available?.({sessionId:i})??!0,[i]),u=dx(n,l),d=fx(u,r),f=(e,n)=>void t.savePrefs(px(e,n)),p=J7.map(e=>{let t=n.includes(e.id);return{id:e.id,label:t?e.hideLabel:`Show ${e.title.toLowerCase()}`,icon:e.icon,active:t,count:o[e.id]??null}});return(0,B.jsxs)(B.Fragment,{children:[u.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 lg:hidden`,onClick:()=>f([],[]),"aria-hidden":!0}),(0,B.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,B.jsxs)(`aside`,{className:`relative flex shrink-0 flex-col border-l border-border bg-surface`,style:a.style,"aria-label":`Side panels`,"data-testid":`right-dock`,"data-font-scope":`sidebar`,children:[a.handle,u.map(e=>{let t=Y7(e);return t?(0,B.jsx)(nMe,{id:e,title:t.title,icon:t.icon,count:o[e]??null,collapsed:r.includes(e),onToggle:()=>f(n,ux(r,e)),onRemove:()=>f(lx(n,e),r),removeLabel:t.hideLabel,grow:d[e]??1,children:t.render({sessionId:i,reportCount:c[e]})},e):null})]})})]}):null,(0,B.jsx)(`div`,{className:`hidden border-l border-border lg:flex`,children:(0,B.jsx)(P7,{items:p,multi:!0,testId:`activity-bar-right`,label:`Side panels`,onPick:e=>{l(e)&&f(lx(n,e),r)}})})]})}function AMe(e){let t=e=>e.type===`dir`?0:1;return[...e].sort((e,n)=>t(e)-t(n)||e.name.localeCompare(n.name))}function jMe(e){let t=[];return e.target.type===`file`&&t.push({key:`open`,label:`Open`,icon:(0,B.jsx)(H.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,B.jsx)(H.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,B.jsx)(H.Copy,{className:`w-3.5 h-3.5`}),onSelect:e.onCopyRelativePath,testId:`files-menu-copy-relative-path`}),!e.remote&&e.canReveal&&t.push({key:`show-in-explorer`,label:`Show in Explorer`,icon:(0,B.jsx)(H.Folder,{className:`w-3.5 h-3.5`}),onSelect:e.onReveal,testId:`files-menu-show-in-explorer`}),!e.remote&&e.canRename&&t.push({key:`rename`,label:`Rename…`,icon:(0,B.jsx)(H.Edit,{className:`w-3.5 h-3.5`}),onSelect:e.onRename,testId:`files-menu-rename`}),!e.remote&&e.canDelete&&t.push({key:`delete`,label:`Delete…`,icon:(0,B.jsx)(H.Trash,{className:`w-3.5 h-3.5`}),danger:!0,separated:!0,onSelect:e.onDelete,testId:`files-menu-delete`}),t}function MMe(e,t){return t instanceof qg&&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 ${DF(e.path)}: ${t instanceof Error?t.message:String(t)}`}function NMe(){let{state:e,dispatch:t,actions:n,api:r}=V(),i=XS(),a=YS(),o=i?.id??null,s=(o?e.remote.tabs[o]:void 0)?.hostId??(o?e.remote.sessionOwners[o]:void 0)??null,c=s!==null,l=c&&typeof r.listHostSessionFiles==`function`,u=a?.status===`running`||a?.status===`waiting_permission`,d=o?e.files[o]?.active??null:null,f=c?e.remote.hosts.find(e=>e.hostId===s)?.platform??null:e.info?.platform??null,p=i?.cwd??``,m=e=>{n.openFile(e),_x(n.setSidebar)},[h,g]=(0,v.useState)({}),[_,y]=(0,v.useState)(()=>new Set),[b,x]=(0,v.useState)(!1),S=(0,v.useRef)(h);S.current=h;let C=(0,v.useRef)(_);C.current=_;let w=(0,v.useRef)(o);w.current=o;let T=(0,v.useRef)(e.files);T.current=e.files;let[E,D]=(0,v.useState)(null),O=(0,v.useCallback)(()=>D(null),[]),k=(0,v.useCallback)((e,t,n)=>D({target:e,at:t,el:n}),[]),[A,j]=(0,v.useState)(null),[ee,M]=(0,v.useState)(!1),te=(0,v.useCallback)(()=>j(null),[]),[ne,N]=(0,v.useState)(null),[P,re]=(0,v.useState)(!1),ie=(0,v.useCallback)(()=>N(null),[]),[ae,oe]=(0,v.useState)(``),se=yx(ae)!==``,F=(0,v.useMemo)(()=>se?xx(h,ae):null,[se,h,ae]),ce=(0,v.useCallback)(async e=>{if(!o||(c?!r.listHostSessionFiles||!s:!r.listSessionFiles))return;let t=o;g(t=>({...t,[e]:{...t[e]??{entries:null},loading:!0,error:null}}));try{let n=c&&s&&r.listHostSessionFiles?await r.listHostSessionFiles(s,t,e):await r.listSessionFiles(t,e);if(w.current!==t)return;x(!1),g(t=>({...t,[e]:{entries:AMe(n.entries),loading:!1,error:null}}))}catch(n){if(w.current!==t)return;Zg(n)&&x(!0);let r=n instanceof Error?n.message:String(n);g(t=>({...t,[e]:{entries:t[e]?.entries??null,loading:!1,error:r}}))}},[r,o,c,s]);(0,v.useEffect)(()=>{g({}),y(new Set),x(!1),D(null),j(null),o&&(!c||l)&&ce(``)},[o,c,l,ce]);let le=(0,v.useRef)(u);(0,v.useEffect)(()=>{if(le.current&&!u&&o&&(!c||l))for(let e of Object.keys(S.current))(e===``||C.current.has(e))&&ce(e);le.current=u},[u,o,c,l,ce]);let ue=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),S.current[e]?.entries||ce(e)),n})},de=()=>{if(o){ce(``);for(let e of _)ce(e)}},fe=(e,t)=>{XI(e).then(e=>n.toast(e?`success`:`error`,e?t:`Could not copy to the clipboard`))},pe=e=>{let t=window.oonacode;if(!p||!t?.showItemInFolder){n.toast(`error`,`Show in Explorer is available in the desktop app on this PC.`);return}t.showItemInFolder(MF(p,e.path,f)).then(e=>{e.ok||n.toast(`error`,e.message||`Could not show it in Explorer.`)})},me=(e,t,n)=>n===e?t:n.startsWith(`${e}/`)?`${t}${n.slice(e.length)}`:null,he=async e=>{let i=ne,a=o;if(!(!i||!a||!r.renameSessionFile||c)){re(!0);try{let o=await r.renameSessionFile(a,i.path,e);ske(a,i.path,o.path);for(let e of T.current[a]?.open??[]){let n=me(i.path,o.path,e);n&&(t({type:`file_close`,sessionId:a,path:e}),(i.type===`file`||e!==i.path)&&t({type:`file_open`,sessionId:a,path:n}))}w.current===a&&(y(e=>{let t=new Set;for(let n of e)t.add(me(i.path,o.path,n)??n);return t}),g(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[me(i.path,o.path,e)??e,t]))),ce(OF(o.path))),n.toast(`success`,`Renamed to ${DF(o.path)}`),N(null)}catch(e){n.toast(`error`,`Could not rename ${DF(i.path)}: ${e instanceof Error?e.message:String(e)}`)}finally{re(!1)}}},ge=async()=>{let e=A,i=o;if(!(!e||!i)&&!(c?!r.deleteHostSessionFile||!s:!r.deleteSessionFile)){M(!0);try{c&&s&&r.deleteHostSessionFile?await r.deleteHostSessionFile(s,i,e.path):await r.deleteSessionFile(i,e.path);for(let n of T.current[i]?.open??[])kF(n,e.path)&&t({type:`file_close`,sessionId:i,path:n});w.current===i&&(y(t=>new Set([...t].filter(t=>!kF(t,e.path)))),g(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!kF(t,e.path)))),ce(OF(e.path))),n.toast(`success`,`Deleted ${DF(e.path)}`)}catch(t){n.toast(`error`,MMe(e,t)),w.current===i&&ce(OF(e.path))}finally{M(!1),j(null)}}},_e=E?jMe({target:E.target,remote:c,canDelete:typeof r.deleteSessionFile==`function`,canCopyPath:p!==``,canReveal:!c&&p!==``&&typeof window.oonacode?.showItemInFolder==`function`,canRename:!c&&typeof r.renameSessionFile==`function`,onOpen:()=>m(E.target.path),onCopyPath:()=>fe(MF(p,E.target.path,f),`Path copied`),onCopyRelativePath:()=>fe(jF(E.target.path,AF(p,f)),`Relative path copied`),onReveal:()=>pe(E.target),onRename:()=>N(E.target),onDelete:()=>j(E.target)}):[],ve=i?.cwd?DF(i.cwd)||i.cwd:`Files`,ye=h[``],be=E?.target.path??null,xe=(0,v.useMemo)(()=>o?c&&!l?(0,B.jsx)(Z7,{children:`This chat runs on another PC; its files can be browsed there.`}):b?(0,B.jsx)(Z7,{children:`This host is too old to list files — update it from the title bar.`}):ye?.error&&!ye.entries?(0,B.jsx)(Z7,{tone:`danger`,children:ye.error}):ye?.entries?ye.entries.length===0?(0,B.jsx)(Z7,{children:`The folder is empty.`}):F&&F.visible.size===0?(0,B.jsx)(Z7,{children:`Nothing listed matches. The filter looks at the folders already opened — Search (Ctrl+K) looks through the whole folder, file contents too.`}):(0,B.jsx)(`ul`,{role:`tree`,"aria-label":`Workspace files`,className:`py-1`,children:(0,B.jsx)(e9,{rel:``,depth:0,tree:h,expanded:_,activeFile:d,menuPath:be,narrowed:F,onToggle:ue,onOpen:m,onMenu:k})}):(0,B.jsx)(Z7,{children:`Listing…`}):(0,B.jsx)(Z7,{children:`Open a chat to browse the folder it works in.`}),[o,c,b,ye,h,_,d,be,F,n]);return(0,B.jsxs)(`section`,{className:`flex h-full min-h-0 w-full flex-col bg-surface`,"aria-label":`Files`,"data-testid":`file-explorer`,"data-font-scope":`sidebar`,children:[(0,B.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,B.jsx)(H.Folder,{className:`w-3.5 h-3.5 text-fg-faint`}),(0,B.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:ve}),(0,B.jsx)(lC,{label:`Refresh files`,className:`p-1`,onClick:de,disabled:!o||c&&!l,"data-testid":`file-explorer-refresh`,children:(0,B.jsx)(H.Refresh,{className:`w-3.5 h-3.5`})})]}),(0,B.jsxs)(`div`,{className:`relative shrink-0 border-b border-border p-2`,children:[(0,B.jsx)(H.Filter,{className:`pointer-events-none absolute left-4 top-4 w-3.5 h-3.5 text-fg-faint`}),(0,B.jsx)(`input`,{"aria-label":`Filter files by name`,className:z(pC,`pl-7`,ae!==``&&`pr-7`),placeholder:`Filter files`,value:ae,onChange:e=>oe(e.target.value),onKeyDown:e=>{e.key===`Escape`&&ae!==``&&(e.preventDefault(),e.stopPropagation(),oe(``))},"data-testid":`files-filter`}),ae===``?null:(0,B.jsx)(lC,{label:`Clear the filter`,className:`absolute right-2.5 top-2.5 p-1`,onClick:()=>oe(``),"data-testid":`files-filter-clear`,children:(0,B.jsx)(H.X,{className:`w-3.5 h-3.5`})})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:xe}),(0,B.jsx)(ow,{open:E!==null,at:E?.at??{x:0,y:0},anchorEl:E?.el??null,label:`File actions`,testId:`files-context-menu`,onClose:O,items:_e}),(0,B.jsx)(PMe,{target:ne,busy:P,onConfirm:e=>void he(e),onClose:ie}),(0,B.jsx)(FMe,{target:A,absolute:A?p?MF(p,A.path,f):A.path:``,platform:f,busy:ee,onConfirm:()=>void ge(),onClose:te})]})}function PMe({target:e,busy:t,onConfirm:n,onClose:r}){let[i,a]=(0,v.useState)(``);(0,v.useEffect)(()=>{a(e?DF(e.path):``)},[e]);let o=e?.type===`dir`;return(0,B.jsx)(gC,{open:e!==null,title:o?`Rename this folder`:`Rename this file`,onClose:r,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{onClick:r,disabled:t,"data-testid":`files-rename-cancel`,children:`Cancel`}),(0,B.jsx)(U,{variant:`primary`,busy:t,disabled:!i.trim()||i.trim()===(e?DF(e.path):``),onClick:()=>n(i.trim()),"data-testid":`files-rename-confirm`,children:`Rename`})]}),children:(0,B.jsxs)(`label`,{className:`block text-sm`,children:[(0,B.jsx)(`span`,{className:`mb-1 block text-fg-muted`,children:`New name`}),(0,B.jsx)(`input`,{value:i,autoFocus:!0,disabled:t,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i.trim()&&n(i.trim())},className:`w-full rounded-md border border-border bg-surface px-2 py-1.5`,"data-testid":`files-rename-input`})]})})}function FMe({target:e,absolute:t,platform:n,busy:r,onConfirm:i,onClose:a}){let o=e?.type===`dir`;return(0,B.jsx)(gC,{open:e!==null,title:o?`Delete this folder?`:`Delete this file?`,onClose:a,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{onClick:a,disabled:r,"data-testid":`files-delete-cancel`,children:`Cancel`}),(0,B.jsx)(U,{variant:`danger`,busy:r,onClick:i,"data-testid":`files-delete-confirm`,children:`Delete permanently`})]}),children:(0,B.jsxs)(`div`,{className:`space-y-2 text-sm text-fg-muted`,"data-testid":`files-delete-dialog`,children:[(0,B.jsx)(`p`,{className:`break-all rounded bg-surface-2 px-2 py-1 font-mono text-xs text-fg`,children:t}),(0,B.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 Z7({children:e,tone:t}){return(0,B.jsx)(`div`,{className:z(`p-4 text-xs`,t===`danger`?`text-danger`:`text-fg-faint`),children:e})}function Q7(e){let t=e.getBoundingClientRect();return{x:t.left+24,y:t.bottom}}function $7(e,t){return{onContextMenu:n=>{n.preventDefault();let r=n.currentTarget;t(e,n.clientX===0&&n.clientY===0?Q7(r):{x:n.clientX,y:n.clientY},r)},onKeyDown:n=>{(n.key===`ContextMenu`||n.shiftKey&&n.key===`F10`)&&(n.preventDefault(),t(e,Q7(n.currentTarget),n.currentTarget))}}}function e9({rel:e,depth:t,tree:n,expanded:r,activeFile:i,menuPath:a,narrowed:o,onToggle:s,onOpen:c,onMenu:l}){let u=n[e];return u?u.error&&!u.entries?(0,B.jsx)(`li`,{className:`px-2 py-1 text-[11px] text-danger`,style:{paddingLeft:`${.5+t*.75}rem`},children:u.error}):u.entries?(0,B.jsx)(B.Fragment,{children:u.entries.map(u=>{let d=Eue(e,u.name);if(o&&!o.visible.has(d))return null;let f=a===d;if(u.type===`dir`){let e=r.has(d)||!!o?.open.has(d);return(0,B.jsxs)(`li`,{role:`treeitem`,"aria-expanded":e,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s(d),...$7({path:d,type:`dir`},l),"data-testid":`explorer-dir-${d}`,className:z(`flex w-full items-center gap-1 py-0.5 pr-2 text-left text-xs text-fg hover:bg-surface-2`,f&&`bg-surface-2`),style:{paddingLeft:`${.5+t*.75}rem`},children:[(0,B.jsx)(H.ChevronRight,{className:z(`w-3 h-3 shrink-0 text-fg-faint transition-transform`,e&&`rotate-90`)}),(0,B.jsx)(H.Folder,{className:`w-3.5 h-3.5 shrink-0 text-fg-faint`}),(0,B.jsx)(`span`,{className:`truncate`,children:u.name})]}),e?(0,B.jsx)(`ul`,{role:`group`,children:(0,B.jsx)(e9,{rel:d,depth:t+1,tree:n,expanded:r,activeFile:i,menuPath:a,narrowed:o,onToggle:s,onOpen:c,onMenu:l})}):null]},d)}let p=i===d;return(0,B.jsx)(`li`,{role:`treeitem`,"aria-selected":p,children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>c(d),...$7({path:d,type:u.type},l),disabled:u.type!==`file`,"data-testid":`explorer-file-${d}`,title:`${d} · ${HF(u.size)}`,className:z(`flex w-full items-center gap-1 py-0.5 pr-2 text-left text-xs hover:bg-surface-2 disabled:opacity-50`,p?`bg-accent-soft text-accent`:f?`bg-surface-2 text-fg`:`text-fg`),style:{paddingLeft:`${.5+t*.75+.9}rem`},children:[(0,B.jsx)(H.File,{className:`w-3.5 h-3.5 shrink-0 text-fg-faint`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:u.name}),(0,B.jsx)(`span`,{className:`shrink-0 text-[10px] text-fg-faint`,children:HF(u.size)})]})},d)})}):(0,B.jsx)(`li`,{className:`px-2 py-1 text-[11px] text-fg-faint`,style:{paddingLeft:`${.5+t*.75}rem`},children:`Listing…`}):null}function t9({text:e,query:t,options:n}){return(0,B.jsx)(B.Fragment,{children:y7(e,t,n).map((e,t)=>e.hit?(0,B.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,B.jsx)(`span`,{children:e.text},t))})}function IMe({active:e,focusAsk:t=0}){let{state:n}=V(),[r,i]=(0,v.useState)(`chats`),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(v7),[l,u]=(0,v.useState)(!1),d=(0,v.useRef)(null),f=(0,v.useRef)(0),p=(0,v.useRef)(!1);(0,v.useEffect)(()=>{t!==f.current&&(f.current=t,p.current=!0),e&&p.current&&(p.current=!1,d.current?.focus())},[e,t]);let m=r===`chats`,h=m&&s.mode===`conversations`,g=()=>{o(``),u(!1),d.current?.focus()},_=e=>c(t=>({...t,[e]:!t[e]}));return(0,B.jsxs)(`section`,{className:`flex h-full min-h-0 w-full flex-col bg-surface`,"aria-label":`Search`,"data-testid":`search-section`,children:[(0,B.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,B.jsx)(H.Search,{className:`w-3.5 h-3.5 text-fg-faint`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:`Search`})]}),(0,B.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b border-border p-2`,children:[(0,B.jsx)(`div`,{className:`flex rounded-md border border-border bg-surface-2 p-0.5`,role:`radiogroup`,"aria-label":`Search in`,children:[[`chats`,`Chats`],[`files`,`Files & contents`]].map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":r===e,onClick:()=>{i(e),u(!1),d.current?.focus()},className:z(`flex-1 rounded px-2 py-1 text-xs font-medium transition-colors`,r===e?`bg-surface text-fg shadow-sm`:`text-fg-muted hover:text-fg`),"data-testid":`search-scope-${e}`,children:t},e))}),(0,B.jsxs)(`div`,{className:`relative flex items-center gap-1`,"data-testid":`sidebar-search`,children:[(0,B.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,B.jsx)(H.Search,{className:`pointer-events-none absolute left-2 top-2 w-3.5 h-3.5 text-fg-faint`}),(0,B.jsx)(`input`,{ref:d,"aria-label":m?`Search sessions`:`Search files`,className:z(pC,`pl-7`),placeholder:m?h?`Search every chat`:`Search chats`:`File names and contents`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(a!==``||l)&&(e.preventDefault(),e.stopPropagation(),l?u(!1):o(``))},"data-testid":`search-input`})]}),m?(0,B.jsxs)(lC,{label:l?`Hide search options`:`Search options`,className:z(`relative`,l&&`text-accent`),"aria-pressed":l,onMouseDown:e=>e.preventDefault(),onClick:()=>u(e=>!e),"data-testid":`search-options-toggle`,children:[(0,B.jsx)(H.Sliders,{}),b7(s)?(0,B.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,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(lC,{label:`Match case`,className:z(`px-1 text-[11px] font-semibold`,s.caseSensitive&&`text-accent`),"aria-pressed":s.caseSensitive,onClick:()=>_(`caseSensitive`),"data-testid":`file-search-case`,children:`Aa`}),(0,B.jsx)(lC,{label:`Whole words`,className:z(`px-1 text-[11px] font-semibold underline`,s.wholeWord&&`text-accent`),"aria-pressed":s.wholeWord,onClick:()=>_(`wholeWord`),"data-testid":`file-search-word`,children:`ab`})]}),a!==``||l?(0,B.jsx)(lC,{label:`Clear search`,onMouseDown:e=>e.preventDefault(),onClick:g,"data-testid":`close-search`,children:(0,B.jsx)(H.X,{})}):null,m&&l?(0,B.jsx)(w7,{options:s,onChange:c,projects:n.vaultProjects,onClose:()=>{u(!1),d.current?.focus()}}):null]})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1 pb-2`,children:m?h?a.trim()===``?(0,B.jsx)(n9,{testId:`search-idle`,children:`Type to search every message of every chat on this PC.`}):(0,B.jsx)(jje,{query:a,options:s}):(0,B.jsx)(LMe,{query:a,options:s}):(0,B.jsx)(RMe,{query:a,options:s})})]})}function n9({children:e,testId:t,tone:n}){return(0,B.jsx)(`div`,{className:z(`px-3 py-4 text-center text-xs`,n===`danger`?`text-danger`:`text-fg-faint`),"data-testid":t,children:e})}function LMe({query:e,options:t}){let{state:n,actions:r}=V(),i=lz(),a=mz(),o=e.trim(),[s,c]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!o)return;let e=!0,t=setTimeout(()=>{r.searchSessionNames(o).then(t=>{e&&c({term:o,sessions:t})})},200);return()=>{e=!1,clearTimeout(t)}},[o,r]);let l=s&&s.term===o?s:null,u=(0,v.useMemo)(()=>{if(!l?.sessions)return[];let e=Date.now();return l.sessions.filter(n=>Dje(n,o,t,e))},[l,o,t]),d=(0,v.useMemo)(()=>new Map(n.vaultProjects.map(e=>[e.id,e.name])),[n.vaultProjects]);return o?l?l.sessions===null?(0,B.jsx)(n9,{testId:`search-failed`,tone:`danger`,children:`This PC could not search its chats. Try again.`}):(0,B.jsxs)(`div`,{"data-testid":`search-results`,children:[(0,B.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-fg-faint`,children:u.length===0?`No chat matches.`:`${u.length} ${u.length===1?`chat`:`chats`}`}),u.map(e=>(0,B.jsx)(sz,{session:e,active:e.id===n.currentSessionId&&n.page===null,link:n.sessionLinks[e.id]??null,menuOpen:i.menuFor===e.id,busy:i.sessionOps[e.id]??null,projectName:e.projectId?d.get(e.projectId)??null:null,testIdPrefix:`search-session`,onOpen:e=>{r.selectSession(e),_x(r.setSidebar)},onMenu:i.openMenu,clock:a},e.id)),i.element]}):(0,B.jsx)(n9,{testId:`search-busy`,children:`Searching…`}):(0,B.jsx)(n9,{testId:`search-idle`,children:`Type to find a chat by its name, its first or last message, or its folder. The sliders search inside every message.`})}function RMe({query:e,options:t}){let{state:n,actions:r,api:i}=V(),a=XS(),o=a?.id??null,s=o!==null&&!!(n.remote.tabs[o]??n.remote.sessionOwners[o]),c=e.trim(),l=t.caseSensitive,u=t.wholeWord,d=`${o??``}\n${c}\n${+!!l}${+!!u}`,f=o!==null&&!s&&typeof i.searchSessionFiles==`function`,p=f&&c.length>=2,[m,h]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!p||!o||!i.searchSessionFiles)return;let e=!0,t=i.searchSessionFiles,n=setTimeout(()=>{t(o,{q:c,caseSensitive:l,wholeWord:u}).then(t=>{e&&h({key:d,res:t,error:null})},t=>{if(!e)return;let n=Zg(t)?`This host is too old to search files — update it from the title bar.`:`Could not search the files: ${t instanceof Error?t.message:String(t)}`;h({key:d,res:null,error:n})})},300);return()=>{e=!1,clearTimeout(n)}},[d,p,i]);let g=a?.cwd?DF(a.cwd)||a.cwd:null;if(!o)return(0,B.jsx)(n9,{testId:`file-search-idle`,children:`Open a chat to search the folder it works in.`});if(s)return(0,B.jsx)(n9,{testId:`file-search-idle`,children:`This chat runs on another PC; its files can be searched there.`});if(!f)return(0,B.jsx)(n9,{testId:`file-search-idle`,children:`This window cannot search files.`});if(c.length<2)return(0,B.jsxs)(n9,{testId:`file-search-idle`,children:[`Searches the file names and the text in the folder of the open chat`,g?(0,B.jsxs)(B.Fragment,{children:[` — `,(0,B.jsx)(`span`,{className:`font-medium text-fg-muted`,title:a?.cwd,children:g})]}):null,`. Type at least two characters.`]});let _=m&&m.key===d?m:null;if(!_)return(0,B.jsx)(n9,{testId:`file-search-busy`,children:`Searching the files…`});if(!_.res)return(0,B.jsx)(n9,{testId:`file-search-failed`,tone:`danger`,children:_.error});let{results:y,truncated:b}=_.res,x=y.reduce((e,t)=>e+t.hits.length,0),S=e=>{r.openFile(e),_x(r.setSidebar)};return(0,B.jsxs)(`div`,{"data-testid":`file-search-results`,children:[(0,B.jsxs)(`div`,{className:`px-3 py-1.5 text-[11px] text-fg-faint`,"data-testid":`file-search-summary`,children:[y.length===0?`Nothing in ${g??`this folder`} matches.`:`${y.length}${b?`+`:``} ${y.length===1?`file`:`files`}${x>0?`, ${x} ${x===1?`line`:`lines`}`:``} in ${g??`this folder`}`,b?` — the search stopped early; narrow the phrase to see the rest.`:``]}),y.map(e=>{let n=DF(e.path)||e.path,r=e.path.length>n.length?e.path.slice(0,e.path.length-n.length-1):``;return(0,B.jsxs)(`div`,{className:`mb-1`,"data-testid":`file-search-result-${e.path}`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-xs hover:bg-surface-2`,title:e.path,onClick:()=>S(e.path),"data-testid":`file-search-file`,children:[(0,B.jsx)(H.File,{className:`w-3.5 h-3.5 shrink-0 text-fg-faint`}),(0,B.jsx)(`span`,{className:`shrink-0 font-medium text-fg`,children:e.nameMatch?(0,B.jsx)(t9,{text:n,query:c,options:t}):n}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-fg-faint`,children:r}),e.hits.length>0?(0,B.jsxs)(`span`,{className:`shrink-0 rounded-full bg-surface-3 px-1.5 text-[10px] font-semibold text-fg-muted`,children:[e.hits.length,e.moreHits?`+`:``]}):null]}),e.hits.map(n=>(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full gap-2 rounded px-2 py-0.5 pl-7 text-left font-mono text-[11px] hover:bg-surface-2`,onClick:()=>S(e.path),"data-testid":`file-search-hit`,children:[(0,B.jsx)(`span`,{className:`shrink-0 text-fg-faint`,children:n.line}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg-muted`,children:(0,B.jsx)(t9,{text:n.text,query:c,options:t})})]},n.line))]},e.path)})]})}function r9(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function zMe(e,t,n){let r=r9(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 i9(e,t){let n=t.trim().toLowerCase();return n===``||e.toLowerCase().includes(n)}var BMe=3e4,a9=`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`,o9=`flex items-center gap-1 px-2 pb-0.5 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,VMe=`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`,s9=`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 HMe({onOpenSearch:e}={}){let{state:t,actions:n}=V(),r=t.ui.sidebarPinnedOverride??t.prefs.sidebarPinned,[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)(!1),c=lz(),[l,u]=(0,v.useState)(null),d=(0,v.useCallback)(()=>u(null),[]),f=JMe(),p=mz(),m=r9(p),h=t.prefs.sidebarView,g=t.prefs.pinned,_=e=>a(t=>({...t,[e]:t[e]!==!0})),y=e=>i[e]===!0,b=t.prefs.collapsedProjects,x=e=>b.includes(e),S=e=>{let t=x(e)?b.filter(t=>t!==e):[...b,e];n.savePrefs({collapsedProjects:t})},C=(0,v.useCallback)(e=>{let r=t.remote.tabs[e]?.hostId??t.remote.sessionOwners[e]??null;r?n.openRemoteSession(r,e):n.selectSession(e),window.innerWidth<768&&n.setSidebar(!1)},[n,t.remote.tabs,t.remote.sessionOwners]),w=(0,v.useCallback)(e=>{n.openPage({kind:`project`,projectId:e}),window.innerWidth<768&&n.setSidebar(!1)},[n]),[T,E]=(0,v.useState)(``),D=yx(T)!==``,O=(0,v.useMemo)(()=>new Map(t.vaultProjects.map(e=>[e.id,e.name])),[t.vaultProjects]),k=(0,v.useCallback)(e=>bx(e,T,e.projectId?O.get(e.projectId):null),[T,O]),A=(0,v.useMemo)(()=>{let e=t.sessions.filter(e=>!t.remote.tabs[e.id]);return D?e.filter(k):e},[t.sessions,t.remote.tabs,D,k]),j=(0,v.useMemo)(()=>{let e=new Map(A.map(e=>[e.id,e]));for(let n of Object.values(t.remote.sessions))for(let t of n??[])e.has(t.id)||e.set(t.id,t);let n=[];for(let r of g)if(r.kind===`chat`){let i=e.get(r.id)??t.pinnedRows[r.id];i&&(!D||k(i))&&n.push({kind:`chat`,session:i})}else{let e=t.vaultProjects.find(e=>e.id===r.id);if(!e||!i9(e.name,T))continue;let i=t.sessions.filter(t=>t.projectId===e.id);n.push({kind:`project`,project:e,sessions:i})}return n},[g,A,D,T,k,t.pinnedRows,t.remote.sessions,t.vaultProjects,t.sessions]),ee=(0,v.useMemo)(()=>new Set(g.filter(e=>e.kind===`chat`).map(e=>e.id)),[g]),M=(0,v.useMemo)(()=>h===`recent`?zMe(A,ee,m):null,[h,A,ee,m]),te=(0,v.useMemo)(()=>{if(h!==`projects`)return[];let e=new Map;for(let n of t.vaultProjects)e.set(n.id,{name:n.name,sessions:[]});let n=[];for(let t of A){let r=t.projectId?e.get(t.projectId):void 0;r?r.sessions.push(t):n.push(t)}let r=[...e.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)}),D?r.filter(e=>e.sessions.length>0||e.projectId!==null&&i9(e.name,T)):r},[h,t.vaultProjects,A,D,T]),ne=e=>{n.savePrefs({collapsedProjects:e?te.map(e=>e.key):[]})},N=(0,v.useMemo)(()=>t.remote.hosts.filter(e=>!e.isSelf),[t.remote.hosts]),P=()=>{let e=y(`remote`);_(`remote`),e&&n.refreshHosts()},re=!y(`remote`),ie=(0,v.useRef)(!1);ie.current=t.remote.loading;let ae=(0,v.useRef)(i);ae.current=i;let oe=(0,v.useRef)(N);oe.current=N,(0,v.useEffect)(()=>{if(!re)return;let e=()=>{if(!(document.visibilityState===`hidden`||ie.current)){n.refreshHosts();for(let e of oe.current)e.online&&ae.current[`host:${e.hostId}`]===!1&&n.refreshHostSessions(e.hostId)}},t=setInterval(e,BMe);return window.addEventListener(`focus`,e),()=>{clearInterval(t),window.removeEventListener(`focus`,e)}},[re,n]);let se=A.length,F=e=>{e!==h&&n.savePrefs({sidebarView:e})},ce=t.page,le={onOpen:C,onMenu:c.openMenu,clock:p},ue=!t.sessionsLoading&&se===0&&!t.sessionsError?(0,B.jsx)(`div`,{className:`px-3 py-3 text-center text-xs text-fg-faint`,"data-testid":`sessions-empty`,children:D?`No chats match the filter.`:`No sessions yet — press + to start one.`}):null;return(0,B.jsxs)(`nav`,{className:`flex h-full w-full flex-col bg-surface`,"aria-label":`Sessions`,children:[(0,B.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,B.jsxs)(`div`,{className:`relative min-w-[8rem] flex-1`,children:[(0,B.jsx)(H.Filter,{className:`pointer-events-none absolute left-2 top-2 w-3.5 h-3.5 text-fg-faint`}),(0,B.jsx)(`input`,{"aria-label":`Filter chats by name`,className:z(pC,`pl-7`,T!==``&&`pr-7`),placeholder:`Filter chats`,value:T,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Escape`&&T!==``&&(e.preventDefault(),e.stopPropagation(),E(``))},"data-testid":`sessions-filter`}),T===``?null:(0,B.jsx)(lC,{label:`Clear the filter`,className:`absolute right-0.5 top-0.5 p-1`,onClick:()=>E(``),"data-testid":`sessions-filter-clear`,children:(0,B.jsx)(H.X,{className:`w-3.5 h-3.5`})})]}),(0,B.jsx)(lC,{label:`Search chats and files (Ctrl+K)`,onClick:()=>{n.showLeftSection(`search`),e?.()},"data-testid":`open-search`,children:(0,B.jsx)(H.Search,{})}),(0,B.jsx)(lC,{label:`Refresh sessions`,onClick:()=>{n.refreshSessions(),n.refreshHosts()},children:(0,B.jsx)(H.Refresh,{className:t.sessionsLoading?`spin`:``})}),t.account?.loggedIn?(0,B.jsx)(lC,{label:`Import chats from your other coding agents`,onClick:()=>n.openDialog(`import-claude`),"data-testid":`open-import-claude`,children:(0,B.jsx)(H.Download,{})}):null,t.account?.loggedIn?(0,B.jsx)(lC,{label:`Export my chats`,onClick:()=>n.openDialog(`export-chats`),"data-testid":`open-export-chats`,children:(0,B.jsx)(H.Upload,{})}):null,t.currentSessionId&&t.remote.tabs[t.currentSessionId]?null:(0,B.jsx)(lC,{label:`Clean up chat folders — free the space of deleted chats`,onClick:()=>n.openDialog(`workspace-cleanup`),"data-testid":`open-workspace-cleanup`,children:(0,B.jsx)(H.Trash,{})}),t.account?.loggedIn&&!(t.currentSessionId&&t.remote.tabs[t.currentSessionId])?(0,B.jsx)(lC,{label:`Connect an AI tool — let it read your chats on this PC`,onClick:()=>n.openDialog(`connect-ai-tool`),"data-testid":`open-connect-ai-tool`,children:(0,B.jsx)(H.Plug,{})}):null,h===`projects`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(lC,{label:`Collapse all projects`,onClick:()=>ne(!0),"data-testid":`projects-collapse-all`,children:(0,B.jsx)(H.CollapseAll,{})}),(0,B.jsx)(lC,{label:`Expand all projects`,onClick:()=>ne(!1),"data-testid":`projects-expand-all`,children:(0,B.jsx)(H.ExpandAll,{})})]}):null,(0,B.jsx)(lC,{label:`Conversations — what your chats send each other`,onClick:()=>n.openConversations(),"data-testid":`open-conversations`,children:(0,B.jsx)(H.Chats,{})}),(0,B.jsx)(lC,{label:`What your chats are about — each chat’s about and what it cost`,onClick:()=>n.openChatAbouts(),"data-testid":`open-chat-abouts`,children:(0,B.jsx)(H.Info,{})}),(0,B.jsx)(lC,{label:`Project manager — review chats and suggest what to send each next`,onClick:()=>n.openProjectManager(),"data-testid":`open-project-manager`,children:(0,B.jsx)(H.Clipboard,{})}),(0,B.jsx)(lC,{label:r?`Hide the session list — it slides in when the pointer reaches the left edge`:`Pin the session list beside the chat`,className:z(`hidden md:inline-flex`,r?`text-accent`:`text-fg-muted`),"aria-pressed":r,onClick:()=>n.toggleSidebarPinned(),"data-testid":`sidebar-pin`,children:(0,B.jsx)(H.Pin,{})})]}),(0,B.jsx)(UMe,{clock:p}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1 pb-2`,children:(0,B.jsxs)(B.Fragment,{children:[j.length>0?(0,B.jsxs)(`div`,{className:`mb-1`,"data-testid":`section-pinned`,children:[(0,B.jsx)(`div`,{className:o9,children:(0,B.jsx)(`span`,{children:`Pinned`})}),j.map(e=>e.kind===`chat`?(0,B.jsx)(sz,{session:e.session,active:e.session.id===t.currentSessionId&&ce===null,link:t.sessionLinks[e.session.id]??null,menuOpen:c.menuFor===e.session.id,busy:c.sessionOps[e.session.id]??null,kindIcon:!0,testIdPrefix:`pinned-session`,...le},`chat:${e.session.id}`):(0,B.jsx)(GMe,{project:e.project,sessions:e.sessions,active:ce?.kind===`project`&&ce.projectId===e.project.id,onOpen:w,onMenu:(t,n)=>u({target:{projectId:e.project.id,foldKey:null},at:t,el:n})},`project:${e.project.id}`))]}):null,(0,B.jsxs)(`div`,{className:`mb-1`,"data-testid":`sessions-local`,children:[t.sessionsError?(0,B.jsx)(`div`,{className:`px-2 py-2 text-xs text-danger`,children:t.sessionsError}):null,M?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{"data-testid":`section-today`,children:[(0,B.jsxs)(`div`,{className:o9,children:[(0,B.jsx)(`span`,{children:`Today`}),(0,B.jsx)(`span`,{className:`font-normal normal-case`,children:M.today.length||``}),(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsx)(c9,{view:h,onChange:F})]}),ue??(M.today.length===0?(0,B.jsx)(`div`,{className:`px-3 py-1 text-xs text-fg-faint`,"data-testid":`today-empty`,children:D?`Nothing from today matches.`:`Nothing yet today.`}):M.today.map(e=>(0,B.jsx)(sz,{session:e,active:e.id===t.currentSessionId&&ce===null,link:t.sessionLinks[e.id]??null,menuOpen:c.menuFor===e.id,busy:c.sessionOps[e.id]??null,projectName:e.projectId?O.get(e.projectId)??null:null,...le},e.id)))]}),M.older.length>0?(0,B.jsxs)(`div`,{"data-testid":`section-older`,children:[(0,B.jsxs)(`div`,{className:o9,children:[(0,B.jsx)(`span`,{children:`Older`}),(0,B.jsx)(`span`,{className:`font-normal normal-case`,children:M.older.length})]}),M.older.map(e=>(0,B.jsx)(sz,{session:e,active:e.id===t.currentSessionId&&ce===null,link:t.sessionLinks[e.id]??null,menuOpen:c.menuFor===e.id,busy:c.sessionOps[e.id]??null,projectName:e.projectId?O.get(e.projectId)??null:null,...le},e.id))]}):null]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:o9,"data-testid":`section-by-project`,children:[(0,B.jsx)(`span`,{children:`By project`}),(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsx)(c9,{view:h,onChange:F})]}),ue,te.map(e=>{let r=`local:${e.key}`;return(0,B.jsxs)(`div`,{className:`mb-1 pl-2`,"data-testid":`project-group-${e.key}`,children:[(0,B.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,B.jsx)(YMe,{group:e,collapsed:x(e.key),onToggle:()=>S(e.key),onMenu:(t,n)=>u({target:{projectId:e.projectId,foldKey:e.key},at:t,el:n}),menuOpen:l?.target.foldKey===e.key}),e.projectId?(0,B.jsxs)(`div`,{className:`absolute right-1 hidden items-center rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:[(0,B.jsx)(lC,{label:`Settings of ${e.name}`,className:`p-1`,"data-testid":`project-settings-${e.key}`,onClick:t=>{t.stopPropagation(),n.openProjectSettings(e.projectId)},children:(0,B.jsx)(H.Settings,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(lC,{label:`New chat in ${e.name}`,className:`p-1`,"data-testid":`project-new-chat-${e.key}`,onClick:t=>{t.stopPropagation(),n.newTab({projectId:e.projectId})},children:(0,B.jsx)(H.Plus,{className:`w-3.5 h-3.5`})})]}):null]}),x(e.key)?null:e.sessions.map(e=>(0,B.jsx)(sz,{session:e,active:e.id===t.currentSessionId&&ce===null,link:t.sessionLinks[e.id]??null,menuOpen:c.menuFor===e.id,busy:c.sessionOps[e.id]??null,...le},e.id))]},r)})]})]}),(0,B.jsxs)(`div`,{className:`mb-1`,"data-testid":`sessions-remote`,children:[(0,B.jsxs)(`button`,{type:`button`,className:a9,onClick:P,"aria-expanded":!y(`remote`),children:[(0,B.jsx)(H.Chevron,{open:!y(`remote`),className:`w-3 h-3`}),(0,B.jsx)(H.Globe,{className:`w-3 h-3`}),(0,B.jsx)(`span`,{className:`truncate`,children:`Remote`}),(0,B.jsx)(`span`,{className:`ml-auto font-normal`,children:N.length})]}),y(`remote`)?null:(0,B.jsxs)(B.Fragment,{children:[!t.remote.supported||t.remote.reason===`logged_out`?(0,B.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,B.jsx)(`div`,{className:`px-3 py-3 text-xs text-fg-faint`,children:t.remote.loading?`Looking for your other devices…`:`No other devices yet.`}):null,N.map(e=>(0,B.jsx)(KMe,{host:e,filter:D?k:null,collapsed:y(`host:${e.hostId}`)||i[`host:${e.hostId}`]===void 0,onToggle:()=>{let t=`host:${e.hostId}`,r=i[t]===void 0||i[t]===!0;a(e=>({...e,[t]:!r})),r&&n.refreshHostSessions(e.hostId)}},e.hostId))]})]})]})}),(0,B.jsx)(`div`,{className:`shrink-0 border-t border-border px-3 py-2 text-[11px] text-fg-faint`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsxs)(`button`,{type:`button`,"data-testid":`app-version`,title:`What's new in this version`,className:`truncate hover:text-fg hover:underline`,onClick:()=>n.openDialog(`whats-new`),children:[`OonaCode Desktop v`,f]}),(0,B.jsx)(lC,{label:`Lock this device — vault and sessions`,className:`p-1`,"data-testid":`lock-device`,onClick:()=>s(!0),children:(0,B.jsx)(H.Lock,{className:`h-3.5 w-3.5`})})]})}),(0,B.jsx)(ow,{open:l!==null,at:l?.at??{x:0,y:0},anchorEl:l?.el??null,label:`Project actions`,testId:`project-context-menu`,onClose:d,items:l?uz({projectId:l.target.projectId,pinned:l.target.projectId!==null&&uu(g,`project`,l.target.projectId),fold:l.target.foldKey===null?null:{collapsed:x(l.target.foldKey),onToggle:()=>S(l.target.foldKey)},actions:n}):[]}),c.element,(0,B.jsx)(bC,{open:o,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 n.lockDevice(),onClose:()=>s(!1)})]})}function UMe({clock:e}){let{state:t,actions:n}=V(),[r,i]=(0,v.useState)(null),a=(0,v.useCallback)(()=>i(null),[]),o=t.page,s=()=>{window.innerWidth<768&&n.setSidebar(!1)};return(0,B.jsxs)(`div`,{className:`shrink-0 border-b border-border px-1 py-1`,"data-testid":`sidebar-nav`,children:[(0,B.jsxs)(`div`,{className:`flex items-center rounded-md hover:bg-surface-2`,children:[(0,B.jsxs)(`button`,{type:`button`,className:z(s9,`flex-1 hover:bg-transparent`),title:`New chat (Ctrl+T)`,onClick:()=>{n.newTab(),s()},"data-testid":`sidebar-new`,children:[(0,B.jsx)(H.Edit,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,B.jsx)(`span`,{children:`New`})]}),(0,B.jsx)(lC,{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,B.jsx)(H.Chevron,{open:!0,className:`w-3.5 h-3.5`})})]}),(0,B.jsxs)(`button`,{type:`button`,className:z(s9,`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,B.jsx)(H.Project,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,B.jsx)(`span`,{children:`Projects`})]}),(0,B.jsx)(WMe,{clock:e,active:o?.kind===`scheduled`,onOpen:()=>{n.openPage({kind:`scheduled`}),s()}}),(0,B.jsx)(ow,{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,B.jsx)(H.Chats,{className:`w-3.5 h-3.5`}),onSelect:()=>{n.newTab(),s()},testId:`sidebar-new-chat`},{key:`project`,label:`New project…`,icon:(0,B.jsx)(H.Project,{className:`w-3.5 h-3.5`}),onSelect:()=>n.openNewProject(),testId:`sidebar-new-project`}]})]})}function WMe({clock:e,active:t,onOpen:n}){let{tasks:r}=pz(),i=(0,v.useMemo)(()=>r?kme(r,e):null,[r,e]);return(0,B.jsxs)(`button`,{type:`button`,className:z(s9,`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,B.jsx)(H.Clock,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,B.jsx)(`span`,{className:`flex-1`,children:`Scheduled`}),i?(0,B.jsx)(`span`,{className:z(`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 c9({view:e,onChange:t}){let[n,r]=(0,v.useState)(null),i=(0,v.useCallback)(()=>r(null),[]),a=e=>e?(0,B.jsx)(H.Check,{className:`w-3.5 h-3.5 text-accent`}):(0,B.jsx)(`span`,{className:`w-3.5`});return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(lC,{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,B.jsx)(H.Sliders,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(ow,{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 GMe({project:e,sessions:t,active:n,onOpen:r,onMenu:i}){let a=(0,v.useRef)(null),o=e.sessionCount??t.length;return(0,B.jsxs)(`div`,{ref:a,className:z(`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,B.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,B.jsx)(H.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.name}),(0,B.jsx)(rz,{sessions:t,testId:`pinned-project-busy-${e.id}`}),(0,B.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,B.jsx)(lC,{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,B.jsx)(H.More,{className:`w-3.5 h-3.5`})})]})}function KMe({host:e,collapsed:t,onToggle:n,filter:r=null}){let{state:i,actions:a}=V(),o=e.label||e.hostName,s=i.remote.sessions[e.hostId],c=(0,v.useMemo)(()=>{let t=s??[],n=new Set(t.map(e=>e.id)),r=[];for(let[t,a]of Object.entries(i.remote.tabs)){if(a.hostId!==e.hostId||n.has(t))continue;let o=i.transcripts[t]?.session??i.sessions.find(e=>e.id===t)??null;if(o){r.push(o),n.add(t);continue}let s=i.drafts[t];if(s){let e=new Date(s.createdAt).toISOString();r.push({id:s.id,projectKey:`draft`,cwd:s.projectDir??``,projectDir:s.projectDir??null,projectId:s.projectId??null,title:s.title??`New chat`,firstPrompt:null,lastPrompt:null,providerId:s.providerId??null,variantId:s.variantId??null,model:s.model??null,permissionMode:s.permissionMode??`default`,posture:s.posture??`build`,...s.effort?{effort:s.effort}:{},status:`idle`,createdAt:e,updatedAt:e,mtime:s.createdAt,entryCount:0,totalCostUsd:0,inputTokens:0,outputTokens:0,poolCredits:0,hasSubagents:!1,forkedFrom:null,engineSince:null,finishedUnseen:null}),n.add(t)}}if(s!==void 0||r.length!==0)return r.length>0?[...r,...t]:s},[s,i.remote.tabs,i.transcripts,i.sessions,i.drafts,e.hostId]),l=r&&c?c.filter(r):c,u=i.remote.unreachable[e.hostId],d=u?ah(u.reason,o,u.detail):null,[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(null),x=(0,v.useCallback)(()=>b(null),[]),S=e.remoteAccessOff===!0;return(0,v.useEffect)(()=>{if(t||S||!e.online||!u)return;let n=setTimeout(()=>{a.refreshHostSessions(e.hostId)},3e3);return()=>clearTimeout(n)},[t,S,e.online,u,e.hostId,a]),(0,B.jsxs)(`div`,{className:`mb-1 pl-2`,"data-testid":`remote-host-${e.hostId}`,children:[(0,B.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,B.jsxs)(`button`,{type:`button`,className:a9,onClick:n,"aria-expanded":!t,title:e.online?`${o} — online`:`${o} — offline: its chats can be read while it is online`,children:[(0,B.jsx)(H.Chevron,{open:!t,className:`w-3 h-3`}),(0,B.jsx)(`span`,{className:z(`inline-block h-2 w-2 shrink-0 rounded-full`,e.online?`bg-ok`:`bg-fg-faint`),"aria-label":e.online?`online`:`offline`}),(0,B.jsx)(`span`,{className:`truncate normal-case`,children:o}),S?(0,B.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,B.jsx)(`span`,{className:`ml-auto font-normal`,children:!S&&l?l.length:``})]}),(0,B.jsxs)(`div`,{className:`absolute right-1 hidden items-center rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:[(0,B.jsx)(lC,{label:S?ih(o):e.online?`New chat on ${o}`:`${o} is offline — a new chat has to start on a PC that is awake`,className:`p-1`,disabled:!e.online||S,"data-testid":`remote-new-chat-${e.hostId}`,onClick:()=>void a.newRemoteTab(e.hostId),children:(0,B.jsx)(H.Plus,{className:`w-3 h-3`})}),(0,B.jsx)(lC,{label:`Unlock this device`,className:`p-1`,disabled:S,"data-testid":`remote-unlock-${e.hostId}`,onClick:()=>p(`unlock`),children:(0,B.jsx)(H.Lock,{className:`w-3 h-3`})}),(0,B.jsx)(lC,{label:`Rename device`,className:`p-1`,onClick:()=>p(`rename`),children:(0,B.jsx)(H.Edit,{className:`w-3 h-3`})})]}),(0,B.jsx)(SC,{open:f===`unlock`,title:`Unlock "${o}" 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 a.remoteUnlockHost(e.hostId,t),onClose:()=>p(null)}),(0,B.jsx)(SC,{open:f===`rename`,title:`Rename device`,label:`Device name`,initialValue:o,onSubmit:t=>{t!==o&&a.renameHost(e.hostId,t)},onClose:()=>p(null)})]}),!t&&S?(0,B.jsx)(`div`,{className:`px-3 py-2 text-xs text-warn`,"data-testid":`remote-off-note-${e.hostId}`,children:ih(o)}):t?null:l===void 0?(0,B.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-faint`,children:`Loading…`}):l.length===0&&d?(0,B.jsx)(`div`,{className:`px-3 py-2 text-xs text-warn`,"data-testid":`remote-unreachable-${e.hostId}`,children:d}):l.length===0?(0,B.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-faint`,children:r&&c&&c.length>0?`No chats here match the filter.`:`No sessions on this device.`}):l.map(t=>(0,B.jsx)(qMe,{host:e,session:t,active:t.id===i.currentSessionId&&i.page===null,menuOpen:y?.session.id===t.id,onMenu:(e,t,n)=>b({session:e,at:t,el:n}),onRename:()=>h(t),onConfirmDelete:()=>_(t)},t.id)),(0,B.jsx)(ow,{open:y!==null,at:y?.at??{x:0,y:0},anchorEl:y?.el??null,label:`Chat actions`,testId:`remote-session-context-menu`,onClose:x,items:y?cz({session:y.session,link:null,pinned:uu(i.prefs.pinned,`chat`,y.session.id),actions:{...a,selectSession:t=>{t?a.openRemoteSession(e.hostId,t):a.selectSession(null)}},onSync:()=>void 0,onRename:()=>h(y.session),onDelete:()=>_(y.session)}):[]}),(0,B.jsx)(SC,{open:m!==null,title:`Rename chat`,label:`Chat title (leave empty to reset)`,initialValue:m?m.title??Gv(m):``,onSubmit:t=>{m&&(i.drafts[m.id]?a.renameTab(m.id,t):a.renameRemoteSession(e.hostId,m.id,t))},onClose:()=>h(null)}),(0,B.jsx)(bC,{open:g!==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:()=>{g&&(i.drafts[g.id]?a.closeTab(g.id):a.deleteRemoteSession(e.hostId,g.id))},onClose:()=>_(null)})]})}function qMe({host:e,session:t,active:n,menuOpen:r=!1,onMenu:i,onRename:a,onConfirmDelete:o}){let{actions:s}=V(),c=Gv(t),l=(0,v.useRef)(null),u=(0,v.useRef)(null),[d,f]=(0,v.useState)(null),p=(0,v.useCallback)(()=>{u.current!==null&&(clearTimeout(u.current),u.current=null),f(null)},[]),m=(0,v.useRef)(r);return m.current=r,(0,v.useEffect)(()=>{r&&p()},[r,p]),(0,v.useEffect)(()=>{if(d===null)return;let e=e=>{aw(e.target,l.current)&&p()};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[d,p]),(0,v.useEffect)(()=>()=>{u.current!==null&&clearTimeout(u.current)},[]),(0,B.jsxs)(`div`,{ref:l,className:z(`group relative flex items-center rounded-md`,n?`bg-accent-soft`:`hover:bg-surface-2`),onMouseEnter:()=>{u.current!==null&&clearTimeout(u.current),!m.current&&(u.current=setTimeout(()=>{u.current=null,l.current&&!m.current&&f(l.current.getBoundingClientRect())},450))},onMouseLeave:p,onClick:p,onContextMenu:e=>{e.preventDefault(),p(),i(t,{x:e.clientX,y:e.clientY},l.current)},children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{s.openRemoteSession(e.hostId,t.id),window.innerWidth<768&&s.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,B.jsx)(nz,{status:t.status}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:z(`truncate text-sm`,n?`font-medium`:``),children:c}),(0,B.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[Lv(t.updatedAt),t.model?` · ${t.model}`:``,e.online?``:` · read-only`]})]})]}),(0,B.jsxs)(`div`,{className:`mr-1 hidden items-center gap-0.5 rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:[(0,B.jsx)(lC,{label:e.online?`Rename this chat`:`That PC is asleep — a chat can only be renamed while the PC that holds it is online`,className:`p-1 disabled:opacity-40`,disabled:!e.online,"data-testid":`remote-session-rename-${t.id}`,onClick:()=>{a()},children:(0,B.jsx)(H.Edit,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(lC,{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:()=>{o()},children:(0,B.jsx)(H.Trash,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(lC,{label:`Chat actions`,className:`p-1`,"data-testid":`remote-session-menu-${t.id}`,onClick:e=>{e.stopPropagation(),p();let n=e.currentTarget.getBoundingClientRect();i(t,{x:n.left,y:n.bottom+2},l.current)},children:(0,B.jsx)(H.More,{className:`w-3.5 h-3.5`})})]}),d===null?null:(0,B.jsx)(az,{session:t,anchor:d})]})}function JMe(){let{state:e}=V(),t=typeof window<`u`?window.oonacode:void 0;return cS(t?.appVersion??e.bundleAppVersion??e.connection.appVersion??e.info?.appVersion??`0.0.0`,sS({bridge:t,info:e.info}))}function YMe({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=>{aw(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,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{ref:a,type:`button`,className:VMe,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,B.jsx)(H.Chevron,{open:!t,className:`w-3 h-3 shrink-0`}),(0,B.jsx)(H.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name}),(0,B.jsx)(rz,{sessions:e.sessions,testId:`project-busy-${e.key}`}),(0,B.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,B.jsx)(XMe,{group:e,anchor:s})]})}function XMe({group:e,anchor:t}){let{state:n}=V(),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,rC.createPortal)((0,B.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,B.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5`,children:[(0,B.jsx)(H.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,B.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.name})]}),(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(iz,{label:`Chats`,value:String(e.sessions.length)}),(0,B.jsx)(iz,{label:`Working now`,value:i>0?String(i):null}),(0,B.jsx)(iz,{label:`Last activity`,value:a?Lv(a):null}),(0,B.jsx)(iz,{label:o.length>1?`Folders`:`Folder`,value:o.length>1?`${o.length} folders`:o[0]??null})]}),e.projectId?(0,B.jsxs)(`div`,{className:`mt-2 border-t border-border pt-2`,children:[(0,B.jsx)(`div`,{className:`mb-1 text-fg-faint`,children:`Standing instructions`}),s?(0,B.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,B.jsx)(`div`,{className:`text-fg-faint`,children:`None — chats here start with nothing extra.`})]}):(0,B.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 text-fg-faint`,children:`Chats filed under no project.`})]}),document.body)}var l9=`(min-width: 768px)`;function u9(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(l9).matches}function ZMe(){let[e,t]=(0,v.useState)(u9);return(0,v.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(l9),n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function QMe(e){try{return!!e?.matches(`:hover`)}catch{return!1}}function $Me(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 eNe({hidden:e,collapsed:t=!1,peekAsk:n=0,children:r}){let{state:i,actions:a}=V(),o=i.ui.sidebarPinnedOverride??i.prefs.sidebarPinned,s=i.ui.sidebarOpen,[c,l]=(0,v.useState)(null),u=c??i.prefs.sidebarWidth,[d,f]=(0,v.useState)(!1),p=ZMe(),m=(0,v.useRef)(null),h=(0,v.useRef)(null),g=(0,v.useCallback)(()=>{h.current!==null&&(clearTimeout(h.current),h.current=null)},[]),_=(0,v.useCallback)(()=>{g(),h.current=setTimeout(function e(){if($Me(m.current)){h.current=setTimeout(e,350);return}h.current=null,!QMe(m.current)&&f(!1)},350)},[g]);(0,v.useEffect)(()=>g,[g]),(0,v.useEffect)(()=>{f(!1),g()},[o,g]);let y=(0,v.useRef)(n);(0,v.useEffect)(()=>{n!==y.current&&(y.current=n,!(e||o||!u9())&&(f(!0),_()))},[n,e,o,_]),(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(u9()){if(o)return;f(!0),_()}else s||a.setSidebar(!0)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,o,s,_,a]);let b=e=>{e.preventDefault();let t=e.clientX,n=u,r=n,o=e=>{r=Zl(n+(e.clientX-t)),l(r)},s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),document.body.style.cursor=``,document.body.style.userSelect=``,l(null),r!==i.prefs.sidebarWidth&&a.savePrefs({sidebarWidth:r})};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},x=o||d;return(0,B.jsxs)(B.Fragment,{children:[!o&&!d&&!e&&!t?(0,B.jsx)(`div`,{className:`absolute inset-y-0 left-0 z-40 hidden w-2 md:block`,onMouseEnter:()=>{f(!0),_()},"aria-hidden":!0,"data-testid":`sidebar-hover-edge`}):null,(0,B.jsxs)(`aside`,{ref:m,"data-chrome":`sidebar`,"data-font-scope":`sidebar`,hidden:e,inert:!e&&(p?!x||t:!s),"data-testid":`sidebar-frame`,"data-state":t?`collapsed`:o?`docked`:d?`peek`:`hidden`,style:{"--sidebar-w":`${u}px`},onMouseEnter:o?void 0:g,onMouseLeave:o?void 0:_,className:z(`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]`,s?`translate-x-0`:`-translate-x-full`,o?`md:relative md:z-auto md:translate-x-0`:z(`md:z-40 md:shadow-2xl`,x?`md:translate-x-0`:`md:-translate-x-full`),t&&`md:hidden`),children:[r,(0,B.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:b,onDoubleClick:()=>void a.savePrefs({sidebarWidth:288}),"data-testid":`sidebar-resize`})]})]})}var d9=[{id:`sessions`,title:`Sessions`,label:`Sessions`,icon:H.Chats},{id:`search`,title:`Search`,label:`Search chats and files (Ctrl+K)`,icon:H.Search},{id:`files`,title:`Files`,label:`Files of this chat`,icon:H.Folder}];function tNe({hidden:e=!1}){let{state:t,actions:n}=V(),r=t.prefs.leftPanelSection,i=t.prefs.leftPanelOpen,a=t.ui.sidebarPinnedOverride??t.prefs.sidebarPinned,[o,s]=(0,v.useState)(0),[c,l]=(0,v.useState)(0),[u,d]=(0,v.useState)(()=>new Set([r]));(0,v.useEffect)(()=>{d(e=>e.has(r)?e:new Set([...e,r]))},[r]),(0,v.useEffect)(()=>{if(e)return;let t=e=>{!(e.ctrlKey||e.metaKey)||e.shiftKey||e.altKey||(e.key===`k`||e.key===`K`)&&window.oonacode?.host!==`vscode`&&(e.preventDefault(),n.showLeftSection(`search`),l(e=>e+1))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,n]);let f=e=>{let t=vx({section:r,open:i},e,a);(t.section!==r||t.open!==i)&&n.savePrefs(hx(t.section,t.open)),a||s(e=>e+1),t.open&&e===`search`&&l(e=>e+1)},p=d9.map(e=>({id:e.id,label:e.label,icon:e.icon,active:i&&e.id===r})),m=e=>e===`sessions`?(0,B.jsx)(HMe,{onOpenSearch:()=>l(e=>e+1)}):e===`search`?(0,B.jsx)(IMe,{active:r===`search`,focusAsk:c}):(0,B.jsx)(NMe,{});return(0,B.jsxs)(B.Fragment,{children:[e?null:(0,B.jsx)(`div`,{className:`hidden border-r border-border md:flex`,children:(0,B.jsx)(P7,{items:p,testId:`activity-bar-left`,label:`Side bar`,onPick:f})}),(0,B.jsx)(`div`,{className:`contents md:relative md:flex md:shrink-0`,children:(0,B.jsx)(eNe,{hidden:e,collapsed:!i,peekAsk:o,children:(0,B.jsxs)(`div`,{className:`flex h-full w-full flex-col`,"data-testid":`left-dock`,"data-section":r,children:[(0,B.jsx)(nNe,{section:r,onPick:e=>{n.showLeftSection(e),e===`search`&&l(e=>e+1)}}),Ll.filter(e=>u.has(e)||e===r).map(e=>(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,hidden:e!==r,"data-testid":`left-section-${e}`,children:m(e)},e))]})})})]})}function nNe({section:e,onPick:t}){return(0,B.jsx)(`div`,{className:`flex shrink-0 gap-1 border-b border-border p-1 md:hidden`,role:`tablist`,"aria-label":`Side bar`,children:d9.map(n=>(0,B.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n.id===e,onClick:()=>t(n.id),className:z(`flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-xs`,n.id===e?`bg-surface-2 font-medium text-fg`:`text-fg-muted hover:bg-surface-2 hover:text-fg`),"data-testid":`left-tab-${n.id}`,children:[(0,B.jsx)(n.icon,{className:`w-3.5 h-3.5`}),n.title]},n.id))})}var f9={autosaveFiles:{hint:`Save a file as soon as you change it. Off by default.`,details:[`Applies to text files opened in this window’s file viewer.`,`While off, a changed file shows * on its tab and Ctrl+S saves it.`,`A file opened from another PC stays read-only.`]},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: the operating system’s app mode (Windows: Settings → Personalisation → Colours → “Choose your default app mode”).`,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 chat on screen is still kept whole, and still searched.`,`Smaller is faster on long agentic chats; larger keeps more on screen.`]},keptTranscripts:{hint:`How many open tabs you are not looking at keep their whole chat in this window’s memory. The others are read again from this PC when you show them.`,details:[`Chats on screen, chats that are working (a turn, a permission card) and chats on another PC are always kept.`,`A closed tab’s chat is let go of at once.`,`Each long chat costs tens to hundreds of MB here; 0 keeps only what is on screen, more makes switching back instant for more tabs.`,`Applies to this window only: the desktop app, a browser tab and the VS Code panel each keep their own.`]},engineIdleMinutes:{hint:`How long a chat’s engine stays open after its last turn. Its next message starts it again and resumes the chat.`,details:[`An open engine answers the next message at once and keeps the provider’s prompt cache warm; it holds the chat’s whole context in memory (hundreds of MB for a long chat).`,`An agy chat waits three times as long, and a chat too long for its model’s window six times: starting those again is slow and re-reads the most.`,`Background work the chat left running (a Monitor, a background command or agent) keeps its engine open up to 12 hours.`]},maxIdleEngines:{hint:`At most this many engines stay open with no turn; when one more goes quiet, the one quiet longest closes.`,details:[`Bounds the memory of chats you visited in the last hour, not the ones you are working in: an engine with a turn is never closed.`,`Never closes an engine with background work, or an agy engine (they keep their own longer window).`]},browserIdleMinutes:{hint:`How long a chat’s Oonak Browser stays open when nobody uses it. Its profile — logins, cookies — is kept, and the next browser action opens it again.`,details:[`Used means the agent’s browser actions, or you moving between pages in it (a sign-in, a link).`,`Never closed while a turn of its chat runs. A browser you opened from Session Info stays until you close it.`]},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.`]},telegram:{hint:`Let the OonaCode Telegram bot list, read, continue and delete this PC’s chats. Off by default.`,details:[`The bot reaches this PC through OonaCode’s server, and what you send and receive in Telegram passes through that server unencrypted — Telegram can read it too. Everything else stays end-to-end encrypted.`,`Off: this PC refuses every Telegram request, even from your own Telegram account, and a chat open in Telegram is closed at once. The bot says how to turn it back on.`,`Only this PC can turn it on — not the website, the phone or the bot.`,`Needs Remote access on as well, and Telegram connected to your account in the bot (/connect).`]},debugNotes:{hint:`Show the technical notes about how a chat is run — an account that ran out of quota and the move to another, a connection that broke and the turn going on by itself. Off by default.`,details:[`Off: those notes go to this PC’s log only; the chat shows just the work. Errors that stop a turn, and notes that change what you see (a stuck command was ended, the model no longer remembers the chat), always show.`,`Applies to every chat on this PC from the next note on; notes already in a chat stay.`]},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.`]},promptSuggestions:{hint:`After each turn, a greyed guess at your next message appears in the empty message box; Tab puts it in, and nothing is ever sent by itself. On by default. It is an extra small request to the model, on your plan or credits.`,details:[`OonaCode pool chats: guessed by OonaCode’s small, fast models (the Auto model’s classifier), from the chat’s last message and answer. Each guess costs a few credits, charged like any pool request and shown in your usage as Auto-suggest.`,`Chats on your own Claude-protocol key or plan (your Claude, DeepSeek, Kimi, GLM…): guessed by the Claude Code engine on your own plan, reusing the turn’s prompt cache — a small request, but not a free one. Those chats never send anything to OonaCode for it.`,`Codex/ChatGPT, SuperGrok, Muse, GitHub Copilot and Google’s agy chats get none: those CLIs never make such a request (and on Copilot it would use a premium request).`,`Tab only fills the box, and Enter sends it like anything you type. Typing hides the guess; the chat’s next turn replaces it. Not after a turn that failed or that you stopped.`,`Decided by this PC for every chat that runs here, whichever window or device sent the turn. Off: the guesses go from every window at once and no new one is asked for; a chat whose agent is already running on your own plan stops making them when its agent next starts.`,`A guess is kept only in this PC’s memory, never in the chat’s history.`]},providerUsagePing:{hint:`When you look at a provider’s usage card and its last figure is old, check it with one tiny request. On by default.`,details:[`Applies to providers you use with your OWN key or subscription — your Claude plan, an own DeepSeek, OpenAI, xAI, MiMo or Alibaba key, a ChatGPT plan, Meta’s Muse key. Google’s agy and SuperGrok have a usage report of their own, and the OonaCode pool shows credits instead: they are never checked.`,`Only when you look: opening the model picker’s card, or resting the pointer on the picker’s box while one of those models is active. Never in the background, and never while the last figure is younger than the time below.`,`The check is one “reply PONG” request of a few tokens, sent from this PC straight to the provider with your own plan or key — so it spends a few tokens of THEM, and nothing about it goes through our servers. Your Claude plan is asked through the genuine Claude engine, as a chat message is.`,`Only the rate-limit figures in the answer are kept (on this PC, with the time they were seen); the answer itself is thrown away. Off: the card shows the last figures it saw, or nothing, and never asks.`]},providerUsageStale:{hint:`How old the last usage figure may be before a look at the card checks again.`,details:[`0 never checks on a look (the card shows what it last saw). A card opened sooner than this after the last figure does not ask the provider anything.`,`A check that failed is not repeated for ten minutes, and “Check now” on the card makes at most one a minute.`]},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.`]},safeguardFallback:{hint:`When a model refuses a message on content or safety grounds, run that one message once more on another model. On by default.`,details:[`Decided by this PC itself, for EVERY chat running here — started in this app, the oona terminal, your phone, Telegram, the website or another PC.`,`Only that message is sent to the other model; the chat stays on the model you picked. The refusal and the retry are both written into the chat, and the turn line says what happened.`,`Switch automatically: the best other model your chat’s route can serve — a Claude chat tries other Claude models first. Always switch to: the model you choose, every time. Never: the refusal is shown and nothing is retried.`,`OonaCode pool: the model that answers is charged at its own price. Your own key or subscription never switches to another provider — only to another model of the same one.`,`A fallback you set for one model (below) beats this choice, and a chat’s own --fallback-model (terminal, agent API) beats both.`,`Limit: Claude Code’s own engine still moves Opus 5, Opus 5.5 and Fable chats to Opus 4.8 by itself when their safeguards refuse — it cannot be switched off.`,`One retry only: if the second model refuses too, the chat says so and stops.`]},safeguardPerModel:{hint:`Pick the fallback for one model. It beats the choice above for that model only; “Never fall back” stops a model from being retried.`,details:[`Applies when the refused model is the one you name here, in any chat on this PC, however it was started.`,`A model you use through your own key or subscription can only fall back to a model of the same provider; an OonaCode pool model can fall back to any pool model.`,`Up to 64 models. A chat’s own --fallback-model still beats this table.`,`Charged by the model that answers: pool credits at its price, or your own key or plan.`]},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. Applies at once.`,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.`,`Applies at once: switched on, the port opens right away for every window; switched off, it closes. Nothing restarts.`,`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 once, like it.`]}};function rNe(e){if(Xc(e))return`Off: the debugging port and the inspector are closed. Chromium's own port (127.0.0.1:${e.chromiumUntilRestart}), opened when OonaCode started with debugging on, closes only when the app restarts.`;if(!Jc(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 iNe(e){return Yc(e.saved,e.running)}function aNe(e){return Xc(e.running)?`Restart OonaCode to close Chromium's port too.`:`This change could not be applied while OonaCode runs; it applies at the next start.`}function oNe(e){return`Debugging is off, but Chromium's own port (127.0.0.1:${e.chromiumUntilRestart??`?`}), opened when OonaCode started with debugging on, stays open until the app restarts. Click for Settings → Developer → Restart now.`}function sNe(e){return`Debugging is on: ${Zc(e)}. While it is on, any program on this PC can read and control OonaCode. Click to change it in Settings → Developer.`}function cNe({providerId:e,configured:t}){let{api:n,state:r,actions:i}=V(),[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,B.jsx)(U,{size:`sm`,variant:t?`secondary`:`primary`,onClick:()=>i.openProviderConnect(e),"data-testid":`agy-provider-button`,children:cje(t,a)})}function p9(e,t){return t.get(e.providerId)??e.providerId}function lNe(e,t,n){let r=Km(t);if(!r)return[];let i=e.find(e=>e.models.some(e=>e.value===t)),a=kl(r.modelId);return(jl(r.providerId)?e.filter(e=>jl(e.providerId)):e.filter(e=>!jl(e.providerId)&&p9(e,n)===(i?p9(i,n):r.providerId))).map(e=>({...e,models:e.models.filter(e=>kl(e.modelId)!==a)})).filter(e=>e.models.length>0)}function m9({groups:e}){return(0,B.jsx)(B.Fragment,{children:e.map(e=>(0,B.jsx)(`optgroup`,{label:e.label,children:e.models.map(e=>(0,B.jsx)(`option`,{value:e.value,children:e.label},e.value))},`${e.providerId}:${e.variantId??``}`))})}var uNe=[{mode:`auto`,label:`Switch to another model automatically`,hint:`The best other model this chat can use. A Claude chat tries other Claude models first.`},{mode:`model`,label:`Always switch to:`,hint:`The model you choose, every time a model refuses.`},{mode:`off`,label:`Never — show the refusal`,hint:`Nothing is retried; the chat shows the refusal and where to change this.`}];function dNe(){let{state:e,actions:t}=V(),n=Al(e.prefs.safeguardFallback),r=(0,v.useMemo)(()=>Qm(e.providers),[e.providers]),i=(0,v.useMemo)(()=>new Map(e.providers.map(e=>[e.definition.id,e.definition.clientGroup??e.definition.id])),[e.providers]),a=(0,v.useMemo)(()=>r.flatMap(e=>e.models.map(e=>({id:e.modelId,displayName:e.label}))),[r]),o=e=>Nl(e,a),[s,c]=(0,v.useState)(!1),l=s?`model`:n.mode,u=e=>void t.savePrefs({safeguardFallback:Al(e)}),d=e=>{if(e===`model`){c(!0);return}c(!1),u({...n,mode:e,model:null})},f=(e=>e?r.flatMap(e=>e.models).find(t=>kl(t.modelId)===kl(e)):void 0)(n.model),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(``),_=(0,v.useMemo)(()=>p?lNe(r,p,i):[],[r,p,i]),y=Object.entries(n.perModel),b=y.length>=64,x=p!==``&&h!==``&&(h===`none`||_.some(e=>e.models.some(e=>e.value===h))),S=()=>{let e=Km(p);if(!e||!x)return;let t=h===`none`?El:Km(h)?.modelId??``;if(!t)return;let r=kl(e.modelId);b&&n.perModel[r]===void 0||(u({...n,perModel:{...n.perModel,[r]:t}}),m(``),g(``))},C=e=>{let t={...n.perModel};delete t[e],u({...n,perModel:t})};return(0,B.jsxs)(`div`,{className:`space-y-4`,"data-testid":`settings-safeguards`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,B.jsx)(H.Shield,{className:`w-3.5 h-3.5`}),` When a model refuses a message`,(0,B.jsx)(uC,{label:`When a model refuses a message`,details:(0,B.jsx)(dC,{items:f9.safeguardFallback.details})})]}),(0,B.jsx)(`p`,{className:`text-xs text-fg-faint`,children:f9.safeguardFallback.hint}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-faint`,children:`On the OonaCode pool, the model that answers is charged at its own price. Your own key or subscription never switches to another provider.`}),(0,B.jsx)(`div`,{role:`radiogroup`,"aria-label":`When a model refuses a message`,className:`mt-2 space-y-1`,children:uNe.map(e=>(0,B.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md px-1 py-1.5 hover:bg-surface-2`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`safeguard-mode`,className:`mt-1`,checked:l===e.mode,onChange:()=>d(e.mode),"data-testid":`safeguard-mode-${e.mode}`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.label}),(0,B.jsx)(`span`,{className:`block text-xs text-fg-faint`,children:e.hint}),e.mode===`model`?(0,B.jsxs)(`select`,{className:z(pC,`mt-1.5 max-w-sm`),"aria-label":`Always switch to`,value:f?.value??``,disabled:l!==`model`,onChange:e=>{let t=Km(e.target.value);t&&(c(!1),u({...n,mode:`model`,model:t.modelId}))},"data-testid":`safeguard-model-select`,children:[(0,B.jsx)(`option`,{value:``,children:n.model&&!f?`${o(n.model)} (not listed)`:`Choose a model…`}),(0,B.jsx)(m9,{groups:r})]}):null]})]},e.mode))}),(0,B.jsx)(`p`,{className:`mt-2 rounded-md bg-surface-2 px-2.5 py-1.5 text-xs text-fg-muted`,children:`Claude Code’s own engine still moves Opus 5, Opus 5.5 and Fable chats to Opus 4.8 by itself when their safeguards refuse — that cannot be switched off.`})]}),(0,B.jsxs)(`div`,{className:`border-t border-border pt-3`,"data-testid":`safeguard-per-model`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Fallback per model`,(0,B.jsx)(uC,{label:`Fallback per model`,details:(0,B.jsx)(dC,{items:f9.safeguardPerModel.details})})]}),(0,B.jsx)(`p`,{className:`text-xs text-fg-faint`,children:f9.safeguardPerModel.hint}),y.length>0?(0,B.jsxs)(`table`,{className:`mt-2 w-full text-xs`,"data-testid":`safeguard-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{className:`text-left text-fg-faint`,children:[(0,B.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Refused model`}),(0,B.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Fallback`}),(0,B.jsx)(`th`,{className:`w-8`})]})}),(0,B.jsx)(`tbody`,{children:y.map(([e,t])=>(0,B.jsxs)(`tr`,{className:`border-t border-border`,"data-testid":`safeguard-row-${e}`,children:[(0,B.jsx)(`td`,{className:`py-1.5 pr-2 text-fg`,children:o(e)}),(0,B.jsx)(`td`,{className:`py-1.5 pr-2 text-fg-muted`,children:t===`none`?`Never`:o(t)}),(0,B.jsx)(`td`,{className:`py-1.5 text-right`,children:(0,B.jsx)(lC,{label:`Remove the fallback for ${o(e)}`,className:`p-0.5`,onClick:()=>C(e),"data-testid":`safeguard-remove-${e}`,children:(0,B.jsx)(H.Trash,{className:`w-3 h-3`})})})]},e))})]}):(0,B.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,"data-testid":`safeguard-table-empty`,children:`No per-model fallbacks — every model follows the choice above.`}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-2`,children:[(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs text-fg-muted`,children:[`When this model refuses`,(0,B.jsxs)(`select`,{className:z(pC,`max-w-56`),value:p,onChange:e=>{m(e.target.value),g(``)},"data-testid":`safeguard-add-refused`,children:[(0,B.jsx)(`option`,{value:``,children:`Choose a model…`}),(0,B.jsx)(m9,{groups:r})]})]}),(0,B.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs text-fg-muted`,children:[`Use`,(0,B.jsxs)(`select`,{className:z(pC,`max-w-56`),value:h,disabled:p===``,onChange:e=>g(e.target.value),"data-testid":`safeguard-add-fallback`,children:[(0,B.jsx)(`option`,{value:``,children:`Choose a fallback…`}),(0,B.jsx)(`option`,{value:El,children:`Never fall back`}),(0,B.jsx)(m9,{groups:_})]})]}),(0,B.jsxs)(U,{size:`sm`,variant:`primary`,disabled:!x||b&&n.perModel[kl(Km(p)?.modelId??``)]===void 0,onClick:S,"data-testid":`safeguard-add`,children:[(0,B.jsx)(H.Plus,{className:`w-3 h-3`}),` Add`]})]}),b?(0,B.jsxs)(`p`,{className:`mt-1 text-xs text-warn`,children:[`The table is full (`,64,` models). Remove one to add another.`]}):null,r.length===0?(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-faint`,children:`No models are listed on this PC yet — connect a provider first.`}):null]})]})}function fNe(){let{actions:e}=V(),[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,B.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,B.jsx)(pNe,{onDone:()=>{i(!1),KR(),cL(),s()}}):(0,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`skills-section`,children:[(0,B.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Skills every chat on this PC gets — type `,(0,B.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,B.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,B.jsx)(`span`,{className:`font-medium`,children:`Skills`}),` menu under its message box — only those cost tokens on every message of that chat.`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsxs)(U,{size:`sm`,onClick:()=>i(!0),"data-testid":`skills-import-open`,children:[(0,B.jsx)(H.Download,{className:`h-3.5 w-3.5`}),` Import from Claude Code…`]}),t?(0,B.jsx)(`span`,{className:`truncate text-[11px] text-fg-faint`,title:t.dir,children:t.dir}):null]}),t===void 0?(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading…`}):t===null?(0,B.jsx)(`p`,{className:`text-xs text-danger`,children:`The host could not list the skills right now.`}):t.skills.length===0?(0,B.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,B.jsx)(`span`,{className:`font-mono`,children:`SKILL.md`}),` in the folder above.`]}):(0,B.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.skills.map(t=>(0,B.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2 text-sm`,"data-testid":`skill-row`,"data-name":t.name,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,B.jsxs)(`span`,{className:`font-mono font-medium`,children:[`/`,t.name]}),t.argumentHint?(0,B.jsx)(`span`,{className:`font-mono text-xs text-fg-faint`,children:t.argumentHint}):null,t.broken?(0,B.jsx)(hC,{tone:`warn`,children:`no SKILL.md`}):null]}),t.description?(0,B.jsx)(`div`,{className:`line-clamp-2 text-xs text-fg-muted`,title:t.description,children:t.description}):null,(0,B.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[HF(t.bytes),` · `,t.files,` file`,t.files===1?``:`s`,t.importedFrom?(0,B.jsxs)(B.Fragment,{children:[` `,`· imported `,t.importedAt?Lv(t.importedAt):``,` from`,` `,(0,B.jsx)(`span`,{title:t.importedFrom,children:t.importedFrom})]}):null]})]}),(0,B.jsxs)(U,{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&&(KR(),cL(),await s())},"data-testid":`skill-remove`,children:[(0,B.jsx)(H.Trash,{className:`h-3.5 w-3.5`}),` Remove`]})]},t.name))})]})}function pNe({onDone:e}){let{actions:t}=V(),[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,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`skills-import`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:e,children:`← Back`}),(0,B.jsx)(`span`,{className:`text-sm font-medium`,children:`Import skills from Claude Code`})]}),(0,B.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,B.jsxs)(B.Fragment,{children:[` `,`Read from `,(0,B.jsx)(`span`,{className:`font-mono`,children:n.roots.join(`, `)}),`.`]}):null]}),n===void 0?(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Looking…`}):n===null?(0,B.jsx)(`p`,{className:`text-xs text-danger`,children:`The host could not read Claude Code’s skills.`}):n.skills.length===0?(0,B.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,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wide text-fg-faint`,children:e}),(0,B.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,B.jsx)(`li`,{className:`px-3 py-1.5 text-sm`,children:(0,B.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,B.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,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`span`,{className:`font-mono font-medium`,children:[`/`,e.name]}),` `,e.alreadyInOonaCode?(0,B.jsx)(hC,{children:`already in OonaCode`}):null,` `,e.unavailable?(0,B.jsx)(hC,{tone:`warn`,children:e.unavailable}):null,e.description?(0,B.jsx)(`span`,{className:`line-clamp-2 block text-xs text-fg-muted`,children:e.description}):null,e.note?(0,B.jsx)(`span`,{className:`block text-[11px] text-warn`,children:e.note}):null,(0,B.jsxs)(`span`,{className:`block text-[11px] text-fg-faint`,children:[HF(e.bytes),` · `,e.path]})]})]})},e.key)})})]},e)),n&&n.skills.some(e=>e.alreadyInOonaCode)?(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Replace the ones already in OonaCode`]}):null,u?(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,role:`status`,"data-testid":`skills-import-outcome`,children:u}):null,(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsxs)(U,{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,B.jsx)(U,{size:`sm`,onClick:e,children:`Cancel`})]})]})}function mNe({open:e,onClose:t,editingServer:n}){let{actions:r}=V(),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(`all`),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(`stdio`),[x,S]=(0,v.useState)(`npx`),[C,w]=(0,v.useState)(``),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(``),[j,ee]=(0,v.useState)(!1),[M,te]=(0,v.useState)({}),[ne,N]=(0,v.useState)(!1),[P,re]=(0,v.useState)(null),[ie,ae]=(0,v.useState)(!1),[oe,se]=(0,v.useState)(null),[F,ce]=(0,v.useState)(null);n&&n.id!==F&&(ce(n.id),d(!0),l(null),p(n.id),h(n.name),_(n.description??``),b(n.transport),S(n.command??`npx`),w((n.args??[]).join(` `)),E(Object.entries(n.env??{}).map(([e,t])=>`${e}=${t}`).join(`
|
|
552
552
|
`)),O(n.url??``),A(Object.entries(n.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
553
553
|
`)),ee(n.defaultOn),re(null));let le=()=>{l(null),d(!1),ce(null),p(``),h(``),_(``),b(`stdio`),S(`npx`),w(``),E(``),O(``),A(``),ee(!1),te({}),re(null),se(null)},ue=()=>{le(),t()},de=e=>{l(e),d(!1),p(e.id),h(e.name),_(e.description),b(e.transport),S(e.defaultCommand??`npx`),w((e.defaultArgs??[]).join(` `)),E(Object.entries(e.defaultEnv??{}).map(([e,t])=>`${e}=${t}`).join(`
|
|
554
554
|
`)),O(e.defaultUrl??``),A(Object.entries(e.defaultHeaders??{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
555
555
|
`)),ee(!1),te({}),re(null),se(null)},fe=()=>{d(!0),l(null),p(`mcp-custom-${Date.now().toString(36).slice(-4)}`),h(``),_(``),b(`stdio`),S(`npx`),w(``),E(``),O(``),A(``),ee(!1),re(null),se(null)},pe=()=>{if(c){let e=[...c.defaultArgs??[]],t={...c.defaultEnv??{}},n=c.defaultUrl??``,r={...c.defaultHeaders??{}};for(let i of c.parameters??[]){let a=M[i.key]??``;i.target===`arg`?e=e.map(e=>e.replace(`\${${i.key}}`,a)):i.target===`env`?a&&(t[i.key]=a):i.target===`url`?n=a||n:i.target===`header`&&a&&(r[i.key]=a)}return{id:f.trim()||c.id,name:m.trim()||c.name,description:g.trim()||c.description,transport:c.transport,command:c.defaultCommand,args:e,env:Object.keys(t).length>0?t:void 0,url:n||void 0,headers:Object.keys(r).length>0?r:void 0,defaultOn:j,enabled:!0,catalogId:c.id}}let e={};for(let t of T.split(`
|
|
556
556
|
`)){let n=t.trim();if(!n||n.startsWith(`#`))continue;let r=n.indexOf(`=`);r>0&&(e[n.slice(0,r).trim()]=n.slice(r+1).trim())}let t={};for(let e of k.split(`
|
|
557
557
|
`)){let n=e.trim();if(!n||n.startsWith(`#`))continue;let r=n.indexOf(`:`);r>0&&(t[n.slice(0,r).trim()]=n.slice(r+1).trim())}let n=C.split(/\s+/).map(e=>e.trim()).filter(e=>e.length>0);return{id:f.trim()||`mcp-${Date.now().toString(36)}`,name:m.trim()||`Custom MCP Server`,description:g.trim()||void 0,transport:y,command:y===`stdio`&&x.trim()||void 0,args:y===`stdio`&&n.length>0?n:void 0,env:y===`stdio`&&Object.keys(e).length>0?e:void 0,url:y===`stdio`?void 0:D.trim()||void 0,headers:y!==`stdio`&&Object.keys(t).length>0?t:void 0,defaultOn:j,enabled:!0}},me=async()=>{N(!0),re(null),se(null);try{let e=pe(),t=await r.testMcpConfig(e);re(t)}catch(e){re({ok:!1,durationMs:0,error:e instanceof Error?e.message:String(e)})}finally{N(!1)}},he=async()=>{ae(!0),se(null);try{let e=pe();n?await r.updateMcpServer(n.id,e):await r.createMcpServer(e),ue()}catch(e){se(e instanceof Error?e.message:String(e))}finally{ae(!1)}},ge=(0,v.useMemo)(()=>{let e=nd;if(o!==`all`&&o!==`custom`&&(e=e.filter(e=>e.category===o)),i.trim()){let t=i.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.category.toLowerCase().includes(t))}return e},[i,o]),_e=(0,v.useId)();return(0,B.jsx)(gC,{open:e,title:n?`Edit ${n.name}`:c?`Configure ${c.name}`:u?`Add Custom MCP Server`:`Add MCP Server`,onClose:ue,wide:!0,footer:c||u?(0,B.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,B.jsx)(`div`,{children:P?(0,B.jsx)(`span`,{className:z(`text-xs font-medium`,P.ok?`text-ok`:`text-danger`),children:P.ok?`✓ Connected (${P.toolsCount??0} tools, ${P.durationMs}ms)`:`✗ ${P.error||`Connection failed`}`}):null}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(U,{variant:`secondary`,size:`sm`,onClick:me,disabled:ne||ie,children:ne?`Testing...`:`Test Connection`}),(0,B.jsx)(U,{variant:`primary`,size:`sm`,onClick:he,disabled:ne||ie||!m.trim()&&!c,children:ie?`Saving...`:n?`Update Server`:`Add Server`})]})]}):(0,B.jsx)(U,{onClick:ue,children:`Close`}),children:c||u?(0,B.jsxs)(`div`,{className:`space-y-4 text-xs`,children:[!n&&(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border pb-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>{l(null),d(!1)},className:`flex items-center gap-1 text-accent hover:underline font-medium`,children:`← Back to Catalog`}),c?.docsUrl&&(0,B.jsxs)(`a`,{href:c.docsUrl,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-1 text-fg-muted hover:text-fg`,children:[(0,B.jsx)(`span`,{children:`Docs`}),(0,B.jsx)(H.ExternalLink,{className:`w-3 h-3`})]})]}),oe&&(0,B.jsx)(`div`,{className:`rounded border border-danger/30 bg-danger/10 p-2 text-danger`,children:oe}),c&&(0,B.jsxs)(`div`,{className:`rounded-lg border border-border bg-surface-2 p-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-semibold text-sm text-fg`,children:c.name}),(0,B.jsx)(hC,{tone:`neutral`,children:c.transport}),(0,B.jsx)(hC,{tone:`accent`,children:c.category})]}),(0,B.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:c.description})]}),c?.parameters&&c.parameters.length>0&&(0,B.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,children:[(0,B.jsx)(`div`,{className:`font-semibold text-fg`,children:`Authentication & Configuration`}),c.parameters.map(e=>(0,B.jsx)(fC,{label:e.label,hint:e.required?`Required`:`Optional`,children:(0,B.jsx)(`input`,{type:e.type===`password`?`password`:`text`,value:M[e.key]??``,placeholder:e.placeholder,onChange:t=>te({...M,[e.key]:t.target.value}),className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`})},e.key))]}),u&&(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,B.jsx)(fC,{label:`Server ID`,hint:`Unique slug, e.g. postgres-local`,children:(0,B.jsx)(`input`,{type:`text`,value:f,disabled:!!n,onChange:e=>p(e.target.value),className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`})}),(0,B.jsx)(fC,{label:`Display Name`,hint:`Shown in menus and badges`,children:(0,B.jsx)(`input`,{type:`text`,value:m,placeholder:`My Postgres DB`,onChange:e=>h(e.target.value),className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`})})]}),(0,B.jsx)(fC,{label:`Description`,hint:`Optional summary`,children:(0,B.jsx)(`input`,{type:`text`,value:g,placeholder:`Primary analytics database`,onChange:e=>_(e.target.value),className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`})}),(0,B.jsx)(fC,{label:`Transport Type`,children:(0,B.jsxs)(`select`,{value:y,onChange:e=>b(e.target.value),className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`,children:[(0,B.jsx)(`option`,{value:`stdio`,children:`stdio (Local Subprocess / Command)`}),(0,B.jsx)(`option`,{value:`sse`,children:`sse (Remote Server-Sent Events URL)`}),(0,B.jsx)(`option`,{value:`http`,children:`http (Remote Streamable HTTP URL)`})]})}),y===`stdio`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(fC,{label:`Command`,hint:`Program on PATH, e.g. npx, uvx, python`,children:(0,B.jsx)(`input`,{type:`text`,value:x,placeholder:`npx`,onChange:e=>S(e.target.value),className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`})}),(0,B.jsx)(fC,{label:`Arguments`,hint:`Space-separated argument list`,children:(0,B.jsx)(`input`,{type:`text`,value:C,placeholder:`-y @modelcontextprotocol/server-postgres postgresql://...`,onChange:e=>w(e.target.value),className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`})}),(0,B.jsx)(fC,{label:`Environment Variables`,hint:`One KEY=VALUE per line`,children:(0,B.jsx)(`textarea`,{rows:3,value:T,placeholder:`API_TOKEN=xyz123
|
|
558
|
-
DEBUG=1`,onChange:e=>E(e.target.value),className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`})})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(fC,{label:`Endpoint URL`,hint:`https://mcp.domain.com/sse`,children:(0,B.jsx)(`input`,{type:`url`,value:D,placeholder:`https://mcp.example.com/sse`,onChange:e=>O(e.target.value),className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`})}),(0,B.jsx)(fC,{label:`Headers`,hint:`One Header: Value per line`,children:(0,B.jsx)(`textarea`,{rows:2,value:k,placeholder:`Authorization: Bearer token123`,onChange:e=>A(e.target.value),className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`})})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:[(0,B.jsx)(`input`,{id:`mcp-default-on`,type:`checkbox`,checked:j,onChange:e=>ee(e.target.checked),className:`h-4 w-4 rounded border-border text-accent focus:ring-accent`}),(0,B.jsx)(`label`,{htmlFor:`mcp-default-on`,className:`text-fg font-medium cursor-pointer`,children:`Enable in new chats by default`}),(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`(Leave unchecked for specific databases or billing services)`})]})]}):(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(H.Search,{className:`pointer-events-none absolute left-3 top-2.5 h-4 w-4 text-fg-muted`}),(0,B.jsx)(`input`,{id:_e,type:`text`,value:i,placeholder:`Search MCP providers (Postgres, GitHub, Supabase, Notion, Sentry...)`,onChange:e=>a(e.target.value),className:z(pC,`pl-9`)})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1 border-b border-border pb-2 text-xs`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s(`all`),className:z(`rounded px-2.5 py-1 font-medium transition-colors`,o===`all`?`bg-accent-soft text-accent`:`text-fg-muted hover:bg-surface-2 hover:text-fg`),children:[`All Providers (`,nd.length,`)`]}),td.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),className:z(`rounded px-2.5 py-1 font-medium transition-colors`,o===e.id?`bg-accent-soft text-accent`:`text-fg-muted hover:bg-surface-2 hover:text-fg`),children:e.label},e.id)),(0,B.jsxs)(`button`,{type:`button`,onClick:fe,className:`ml-auto flex items-center gap-1 rounded border border-dashed border-border px-2.5 py-1 font-medium text-accent hover:bg-surface-2`,children:[(0,B.jsx)(H.Plus,{className:`w-3 h-3`}),(0,B.jsx)(`span`,{children:`Custom Server`})]})]})]}),(0,B.jsx)(`div`,{className:`grid max-h-[28rem] grid-cols-1 gap-2.5 overflow-y-auto sm:grid-cols-2`,children:ge.map(e=>(0,B.jsxs)(`div`,{className:`flex flex-col justify-between rounded-lg border border-border bg-surface p-3 transition-colors hover:border-accent/40`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-1`,children:[(0,B.jsx)(`span`,{className:`font-semibold text-sm text-fg`,children:e.name}),(0,B.jsx)(hC,{tone:`neutral`,children:e.transport})]}),(0,B.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),(0,B.jsxs)(`div`,{className:`mt-3 flex items-center justify-between pt-2 border-t border-border/50`,children:[(0,B.jsx)(`span`,{className:`text-[11px] text-fg-muted capitalize`,children:e.category}),(0,B.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>de(e),children:`Add`})]})]},e.id))})]})})}function hNe(){let{state:e,actions:t}=V(),n=e.mcpServers??[],r=e.mcpTesting??{},i=e.mcpTestResults??{},[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),d=async e=>{await t.updateMcpServer(e.id,{defaultOn:!e.defaultOn})};return(0,B.jsxs)(`div`,{className:`space-y-6 text-xs text-fg`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-border pb-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`MCP Servers`}),(0,B.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:`Configure Model Context Protocol servers to provide databases, cloud APIs, and developer tools to your chats. Each chat can toggle which servers are active.`})]}),(0,B.jsxs)(U,{variant:`primary`,size:`sm`,onClick:()=>o(!0),children:[(0,B.jsx)(H.Plus,{className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{children:`Add MCP Server`})]})]}),n.length===0?(0,B.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border bg-surface-2 p-8 text-center`,children:[(0,B.jsx)(`div`,{className:`mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-accent-soft text-accent`,children:(0,B.jsx)(H.Plug,{className:`h-6 w-6`})}),(0,B.jsx)(`h4`,{className:`mt-3 text-sm font-semibold text-fg`,children:`No MCP Servers Configured`}),(0,B.jsx)(`p`,{className:`mx-auto mt-1 max-w-sm text-xs text-fg-muted`,children:`Connect databases (PostgreSQL, Supabase), developer services (GitHub, Sentry), or productivity tools (Linear, Notion) to your agent.`}),(0,B.jsx)(`div`,{className:`mt-4`,children:(0,B.jsx)(U,{variant:`primary`,size:`sm`,onClick:()=>o(!0),children:`Browse MCP Catalog`})})]}):(0,B.jsx)(`div`,{className:`space-y-3`,children:n.map(e=>{let n=!!r[e.id],a=i[e.id];return(0,B.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-border bg-surface p-3.5 shadow-sm transition-colors hover:border-accent/40`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-semibold text-sm text-fg truncate`,children:e.name}),(0,B.jsx)(hC,{tone:`neutral`,children:e.transport}),e.catalogId&&(0,B.jsx)(hC,{tone:`accent`,children:e.catalogId})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,B.jsx)(`span`,{className:`text-[11px] text-fg-muted animate-pulse`,children:`Testing...`}):a?(0,B.jsx)(`span`,{className:z(`rounded px-2 py-0.5 text-[11px] font-medium`,a.ok?`bg-ok/10 text-ok border border-ok/20`:`bg-danger/10 text-danger border border-danger/20`),title:a.error,children:a.ok?`✓ ${a.toolsCount??0} tools (${a.durationMs}ms)`:`✗ Failed`}):null,(0,B.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>t.testMcpServer(e.id),disabled:n,title:`Test connection to this server`,children:`Test`}),(0,B.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>c(e),title:`Edit server configuration`,children:`Edit`}),(0,B.jsx)(lC,{label:`Delete server`,onClick:()=>u(e),className:`text-fg-muted hover:text-danger`,children:(0,B.jsx)(H.Trash,{className:`w-3.5 h-3.5`})})]})]}),e.description&&(0,B.jsx)(`p`,{className:`text-fg-muted text-xs`,children:e.description}),(0,B.jsx)(`div`,{className:`rounded bg-surface-2 px-2.5 py-1.5 font-mono text-[11px] text-fg-muted overflow-x-auto`,children:e.transport===`stdio`?(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`text-accent`,children:e.command}),` `,(e.args??[]).join(` `)]}):(0,B.jsx)(`span`,{className:`text-accent`,children:e.url})}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between pt-2 border-t border-border/50 text-[11px]`,children:[(0,B.jsx)(_C,{label:`Default ON for new chats`,checked:e.defaultOn,onChange:()=>d(e)}),(0,B.jsxs)(`span`,{className:`text-fg-muted`,children:[`Updated `,new Date(e.updatedAt).toLocaleDateString()]})]})]},e.id)})}),(0,B.jsx)(bC,{open:l!==null,title:`Remove MCP Server`,message:l?`Are you sure you want to remove MCP server "${l.name}"?`:``,confirmLabel:`Remove`,onConfirm:async()=>{l&&(await t.deleteMcpServer(l.id),u(null))},onClose:()=>u(null)}),(a||s!==null)&&(0,B.jsx)(mNe,{open:a||s!==null,editingServer:s,onClose:()=>{o(!1),c(null)}})]})}function h9(e){switch(e){case`win32`:return`Windows`;case`darwin`:return`macOS`;case`linux`:return`Linux`;case`android`:return`Android`;case`ios`:return`iPhone`;case`web`:return`Browser`;case`telegram`:return`Telegram`;default:return e||`Unknown`}}function g9(e){return e instanceof qg&&(e.status===501||e.status===404&&e.message.startsWith(`no route for`))}function _9(e){return e.label||e.hostName}function v9(e,t,n){return n.has(e)?`${e} (#${t.slice(0,8)})`:e}function gNe(){let{state:e,actions:t,api:n}=V(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null);(0,v.useEffect)(()=>{t.refreshHosts()},[t]);let p=e.remote.hosts,m=(0,v.useMemo)(()=>{let e=new Map;for(let t of p)e.set(_9(t),(e.get(_9(t))??0)+1);return new Set([...e].filter(([,e])=>e>1).map(([e])=>e))},[p]);if(!e.account?.loggedIn)return(0,B.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`Sign in to see the devices on your account.`});if(!e.remote.supported)return(0,B.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,B.jsx)(`strong`,{children:e.connection.hostName??`unknown`}),`.`]});let h=!!n.removeHost&&!e.remote.stale,g=async e=>{if(!n.removeHost)return;let r=v9(_9(e),e.hostId,m);u(e.hostId),f(null);try{await n.removeHost(e.hostId),t.toast(`success`,`${r} is off your account's list`),await t.refreshHosts()}catch(e){f(g9(e)?`This PC's OonaCode cannot remove PCs yet — update it.`:`${r} was not removed: ${Kv(e)}`),t.refreshHosts()}finally{u(null)}};return(0,B.jsxs)(`div`,{className:`space-y-6`,children:[(0,B.jsxs)(`section`,{className:`space-y-1.5`,"aria-label":`PCs on your account`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:`PCs`}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`The computers on your account. An offline PC can be removed from this list — it is not signed out, its chats stay on it, and if it comes online again it puts itself back. An online PC can't be removed: it would be back within a minute.`}),d?(0,B.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`devices-host-error`,children:d}):null,e.remote.loading?(0,B.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-fg-muted`,children:[(0,B.jsx)(H.Spinner,{}),` Loading devices…`]}):null,p.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border px-3 py-2`,"data-testid":`device-pc-${e.hostId}`,children:[(0,B.jsx)(H.Monitor,{className:`w-4 h-4 shrink-0 text-fg-faint`}),(0,B.jsx)(`div`,{className:`min-w-0 flex-1`,children:r===e.hostId?(0,B.jsx)(`input`,{className:pC,value:a,autoFocus:!0,"aria-label":`Label for ${e.hostName}`,onChange:e=>o(e.target.value),onKeyDown:n=>{n.key===`Enter`&&a.trim()?(t.renameHost(e.hostId,a.trim()),i(null)):n.key===`Escape`&&i(null)}}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[_9(e),e.isSelf?(0,B.jsx)(hC,{tone:`accent`,children:`this PC`}):null,(0,B.jsx)(hC,{tone:e.online?`ok`:`neutral`,children:e.online?`online`:`offline`}),e.remoteAccessOff?(0,B.jsx)(hC,{tone:`warn`,children:`remote access off`}):null]}),(0,B.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[h9(e.platform),e.appVersion?` · v${e.appVersion}`:``,e.lastSeenAt?` · seen ${Lv(e.lastSeenAt)}`:``,m.has(_9(e))?` · #${e.hostId.slice(0,8)}`:``]})]})}),r===e.hostId?(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:()=>{a.trim()&&t.renameHost(e.hostId,a.trim()),i(null)},children:`Save`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(U,{size:`sm`,onClick:()=>{i(e.hostId),o(_9(e))},children:[(0,B.jsx)(H.Edit,{className:`w-3 h-3`}),` Rename`]}),h&&!e.isSelf&&!e.online?(0,B.jsxs)(U,{size:`sm`,busy:l===e.hostId,title:`Take this offline PC off your account's list`,"aria-label":`Remove ${_9(e)}`,onClick:()=>c(e),children:[(0,B.jsx)(H.Trash,{className:`w-3 h-3`}),` Remove…`]}):null]})]},e.hostId)),!e.remote.loading&&p.length===0?(0,B.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`No devices reported yet.`}):null,(0,B.jsx)(`p`,{className:`text-[11px] text-fg-faint`,children:`To take this PC off your account, uninstall OonaCode here or log out in the Account window.`})]}),(0,B.jsx)(_Ne,{}),(0,B.jsx)(bC,{open:s!==null,title:s?`Remove ${v9(_9(s),s.hostId,m)}?`:``,message:s?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`remove-pc-message`,children:[(0,B.jsxs)(`p`,{children:[_9(s),` is taken off your account's list of PCs. Its chats, files and code stay on that PC — none of them are on our server.`]}),(0,B.jsx)(`p`,{children:`It stays signed in: if it comes online again, it puts itself back on the list by itself. To sign it out for good, revoke it under Signed-in devices.`})]}):``,confirmLabel:`Remove`,onConfirm:()=>{s&&g(s)},onClose:()=>c(null)})]})}function _Ne(){let{actions:e,api:t}=V(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!t.listAccountDevices),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(!1),y=(0,v.useCallback)(async()=>{if(t.listAccountDevices)try{let e=await t.listAccountDevices();r(e.devices),a(e.thisDeviceId),s(null)}catch(e){g9(e)?l(!0):s(Kv(e))}},[t]);(0,v.useEffect)(()=>{y()},[y]);let{active:b,revoked:x}=(0,v.useMemo)(()=>{let e=n??[],t=(e,t)=>(t.lastSeenAt??``).localeCompare(e.lastSeenAt??``);return{active:e.filter(e=>!e.revoked).sort((e,n)=>Number(n.id===i)-Number(e.id===i)||t(e,n)),revoked:e.filter(e=>e.revoked).sort(t)}},[n,i]),S=async n=>{if(t.revokeAccountDevice){p(n.id),h(null);try{await t.revokeAccountDevice(n.id),e.toast(`success`,`${n.name} is signed out of your account`),await y(),e.refreshHosts()}catch(e){h(`${n.name} was not revoked: ${Kv(e)}`)}finally{p(null)}}};if(c)return(0,B.jsxs)(`section`,{className:`space-y-1.5`,"aria-label":`Signed-in devices`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:`Signed-in devices`}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`This PC's OonaCode cannot list your sign-ins yet — update it, or revoke a device on the website or in the phone app.`})]});let C=e=>{let n=e.id===i;return(0,B.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border px-3 py-2${e.revoked?` opacity-70`:``}`,"data-testid":`device-signin-${e.id}`,children:[(0,B.jsx)(H.Shield,{className:`w-4 h-4 shrink-0 text-fg-faint`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,B.jsx)(`span`,{className:`truncate`,children:e.name}),n?(0,B.jsx)(hC,{tone:`accent`,children:`this PC`}):null,e.revoked?(0,B.jsx)(hC,{tone:`danger`,children:`revoked`}):null,e.trustedUnlock&&!e.revoked?(0,B.jsx)(hC,{tone:`neutral`,children:`stays unlocked`}):null]}),(0,B.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[h9(e.platform),e.lastSeenAt?` · seen ${Lv(e.lastSeenAt)}`:``,e.lastCountry?` · ${e.lastCountry}`:``]})]}),!n&&!e.revoked&&t.revokeAccountDevice?(0,B.jsxs)(U,{size:`sm`,busy:f===e.id,"aria-label":`Revoke ${e.name}`,title:`Sign this device out of your account for good`,onClick:()=>d(e),children:[(0,B.jsx)(H.X,{className:`w-3 h-3`}),` Revoke…`]}):null]},e.id)};return(0,B.jsxs)(`section`,{className:`space-y-1.5`,"aria-label":`Signed-in devices`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:`Signed-in devices`}),(0,B.jsx)(`button`,{type:`button`,className:`ml-auto text-[11px] text-fg-muted underline underline-offset-2 hover:text-fg`,onClick:()=>void y(),children:`Refresh`})]}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Every app, browser and phone signed in to your account. Revoke signs one out for good — do it for a device you lost or no longer use. It has to sign in again with your password.`}),o?(0,B.jsxs)(`div`,{className:`text-xs text-danger`,role:`alert`,children:[`Could not list your devices: `,o]}):null,m?(0,B.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`devices-revoke-error`,children:m}):null,n===null&&!o?(0,B.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-fg-muted`,children:[(0,B.jsx)(H.Spinner,{}),` Loading sign-ins…`]}):null,b.map(C),x.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,className:`text-[11px] text-fg-muted underline underline-offset-2 hover:text-fg`,onClick:()=>_(e=>!e),children:[g?`Hide`:`Show`,` `,x.length,` revoked`]}),g?x.map(C):null]}):null,(0,B.jsx)(`p`,{className:`text-[11px] text-fg-faint`,children:`This PC can't revoke itself — log out in the Account window instead.`}),(0,B.jsx)(bC,{open:u!==null,title:u?`Revoke ${u.name}?`:``,message:u?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`revoke-device-message`,children:[(0,B.jsxs)(`p`,{children:[u.name,` is signed out of your account at once: its sessions end, it can no longer sync your keys, and a “keep me unlocked” on it stops working.`]}),(0,B.jsx)(`p`,{children:`To use it again, it has to sign in with your password. Its chats stay on that device.`})]}):``,confirmLabel:`Revoke`,onConfirm:()=>{u&&S(u)},onClose:()=>d(null)})]})}var y9=[{id:`general`,label:`General`,icon:H.Settings},{id:`safeguards`,label:`Safeguards`,icon:H.Shield},{id:`theme`,label:`Theme`,icon:H.Palette},{id:`advanced`,label:`Advanced`,icon:H.Sliders},{id:`skills`,label:`Skills`,icon:H.Tool},{id:`mcp`,label:`MCP Servers`,icon:H.Plug},{id:`providers`,label:`Providers`,icon:H.Globe},{id:`devices`,label:`Devices`,icon:H.Monitor},{id:`host`,label:`This PC`,icon:H.Stethoscope},{id:`developer`,label:`Developer`,icon:H.Bug}];function b9(){let e=typeof window<`u`?window.oonacode:void 0;return e?.getDebugging&&e.setDebugging?e:null}function x9({className:e}){let{state:t,actions:n}=V(),r=t.settings?.theme??`system`;return(0,B.jsxs)(`div`,{className:z(`flex items-center justify-between gap-3 py-3`,e),"data-testid":`settings-colour-scheme`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Colour scheme`,(0,B.jsx)(uC,{label:`Colour scheme`,details:(0,B.jsx)(dC,{items:f9.colourScheme.details})})]}),(0,B.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-faint`,children:f9.colourScheme.hint})]}),(0,B.jsx)(vC,{label:`Colour scheme`,value:r,options:[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}],onChange:e=>void n.saveSettings({theme:e})})]})}function vNe(){let{state:e,actions:t}=V(),n=e.prefs;return(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(_C,{label:`Autosave files`,hint:f9.autosaveFiles.hint,details:f9.autosaveFiles.details,checked:n.autosaveFiles,onChange:e=>void t.savePrefs({autosaveFiles:e}),testId:`settings-autosave-files`}),(0,B.jsx)(_C,{label:`Auto-accept permissions`,hint:f9.autoAccept.hint,details:f9.autoAccept.details,checked:n.autoAcceptPermissions,onChange:e=>void t.savePrefs({autoAcceptPermissions:e}),testId:`settings-auto-accept`}),(0,B.jsx)(_C,{label:`Show reasoning in the timeline`,hint:f9.reasoning.hint,details:f9.reasoning.details,checked:n.showReasoningSummaries,onChange:e=>void t.savePrefs({showReasoningSummaries:e})}),(0,B.jsx)(x9,{className:`border-t border-border`}),(0,B.jsxs)(`div`,{className:`border-t border-border pt-2`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,B.jsx)(H.Bell,{className:`w-3 h-3`}),` Notifications`,(0,B.jsx)(uC,{label:`Notifications`,details:(0,B.jsx)(dC,{items:f9.notifications.details})})]}),(0,B.jsx)(`p`,{className:`text-xs text-fg-faint`,children:f9.notifications.hint}),(0,B.jsx)(_C,{label:`Agent finished or needs attention`,hint:f9.notifyFinished.hint,details:f9.notifyFinished.details,checked:n.notifications.agentFinished,onChange:e=>void t.savePrefs({notifications:{...n.notifications,agentFinished:e}})}),(0,B.jsx)(_C,{label:`Permission or question waiting for you`,hint:f9.notifyWaiting.hint,details:f9.notifyWaiting.details,checked:n.notifications.permissionRequired,onChange:e=>void t.savePrefs({notifications:{...n.notifications,permissionRequired:e}})}),(0,B.jsx)(_C,{label:`Error occurred`,hint:f9.notifyError.hint,details:f9.notifyError.details,checked:n.notifications.errorOccurred,onChange:e=>void t.savePrefs({notifications:{...n.notifications,errorOccurred:e}})})]}),e.prefsBackend===`local`?(0,B.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 S9(e){let t=e.replace(/-/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function yNe(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 Vl){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 Vl){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}var C9=[{surface:`chat`,label:`Chat`,hint:`The conversation and the message box.`},{surface:`sidebar`,label:`Sidebar`,hint:`The chat list and the side panels.`}];function bNe(){let{state:e,actions:t}=V(),n=(0,v.useRef)(e.prefs.fonts);n.current=e.prefs.fonts;let r=(e,r)=>void t.savePrefs({fonts:{...n.current,[e]:{...n.current[e],...r}}}),i=C9.some(({surface:t})=>e.prefs.fonts[t].family!==null||e.prefs.fonts[t].size!==null);return(0,B.jsxs)(`div`,{className:`space-y-1 border-t border-border pt-3`,"data-testid":`settings-fonts`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:`Fonts`}),(0,B.jsxs)(`div`,{className:`mt-0.5 text-xs text-fg-faint`,children:[`The typeface and text size of chats and of the sidebar, each on its own. Default keeps the app's own font (`,14,`px). Code always stays monospace.`]})]}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,disabled:!i,onClick:()=>void t.savePrefs({fonts:{chat:{family:null,size:null},sidebar:{family:null,size:null}}}),"data-testid":`fonts-reset`,children:`Reset fonts`})]}),C9.map(({surface:t,label:n,hint:i})=>(0,B.jsx)(xNe,{surface:t,label:n,hint:i,value:e.prefs.fonts[t],onSave:e=>r(t,e)},t))]})}function xNe({surface:e,label:t,hint:n,value:r,onSave:i}){let a=oy.findIndex(e=>e.family===r.family),o=r.family===null?`default`:a>=0?String(a):`custom`,[s,c]=(0,v.useState)(!1),l=s?`custom`:o,[u,d]=(0,v.useState)(o===`custom`?r.family??``:``),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(r.size===null?``:String(r.size));(0,v.useEffect)(()=>h(r.size===null?``:String(r.size)),[r.size]),(0,v.useEffect)(()=>{o===`custom`&&d(r.family??``)},[o,r.family]);let g=()=>{if(u.trim()===``){p(null),c(!1),r.family!==null&&i({family:null});return}let e=Gl(u);if(e===null){p(`Font names separated by commas — letters, digits, spaces and quotes only.`);return}p(null),c(!1),e!==r.family&&i({family:e})},_=(e,t)=>{if(e.trim()===``){t&&r.size!==null&&i({size:null});return}let n=Number(e);if(!Number.isFinite(n)){t&&h(r.size===null?``:String(r.size));return}if(!(n>=10&&n<=28&&Number.isInteger(n))&&!t)return;let a=Wl(n);t&&h(a===null?``:String(a)),a!==r.size&&i({size:a})};return(0,B.jsxs)(`div`,{className:`border-t border-border py-2`,"data-testid":`font-row-${e}`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`div`,{className:`w-20 shrink-0`,children:(0,B.jsx)(`div`,{className:`text-sm text-fg`,children:t})}),(0,B.jsxs)(`select`,{className:z(pC,`w-auto min-w-0 flex-1 py-1`),value:l,onChange:e=>{let t=e.target.value;if(p(null),t===`custom`){c(!0);return}c(!1);let n=t==="default"?null:oy[Number(t)]?.family??null;n!==r.family&&i({family:n})},"aria-label":`${t} font`,"data-testid":`font-family-${e}`,children:[(0,B.jsx)(`option`,{value:`default`,children:`Default`}),oy.map((e,t)=>(0,B.jsx)(`option`,{value:String(t),children:e.label},e.label)),(0,B.jsx)(`option`,{value:`custom`,children:`Custom…`})]}),(0,B.jsx)(`input`,{className:z(pC,`w-24 py-1`),type:`number`,min:10,max:28,step:1,placeholder:`14 px`,value:m,onChange:e=>{h(e.target.value),e.nativeEvent.inputType||_(e.target.value,!1)},onBlur:()=>_(m,!0),onKeyDown:e=>{e.key===`Enter`&&_(m,!0)},"aria-label":`${t} text size in pixels (10–28)`,"data-testid":`font-size-${e}`}),r.family!==null||r.size!==null?(0,B.jsx)(lC,{label:`Reset the ${t.toLowerCase()} font to the default`,className:`p-0.5`,onClick:()=>{c(!1),p(null),d(``),i({family:null,size:null})},"data-testid":`font-reset-${e}`,children:(0,B.jsx)(H.Refresh,{className:`w-3 h-3`})}):null]}),(0,B.jsx)(`div`,{className:`mt-0.5 pl-[5.5rem] text-xs text-fg-faint`,children:n}),l===`custom`?(0,B.jsxs)(`div`,{className:`mt-1.5 pl-[5.5rem]`,children:[(0,B.jsx)(`input`,{className:z(pC,`py-1`),value:u,placeholder:`e.g. 'Fira Sans', Arial, sans-serif`,maxLength:160,onChange:e=>d(e.target.value),onBlur:g,onKeyDown:e=>{e.key===`Enter`&&g()},"aria-label":`${t} custom font`,"aria-invalid":f!==null,"data-testid":`font-custom-${e}`}),f?(0,B.jsx)(`div`,{className:`mt-1 text-xs text-danger`,role:`alert`,children:f}):null]}):null]})}function SNe(){return(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(x9,{className:`pt-0`}),(0,B.jsx)(bNe,{}),(0,B.jsx)(CNe,{})]})}function CNe(){let{state:e,actions:t}=V(),n=e.prefs,r=Ote(),[i,a]=(0,v.useState)(r),o=(0,v.useMemo)(()=>yNe(i),[i]),[s,c]=(0,v.useState)({}),l=(0,v.useRef)(s);l.current=s;let u=(0,v.useRef)(n.themeColors);u.current=n.themeColors;let d=(0,v.useRef)(null),f=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)};(0,v.useEffect)(()=>f,[]);let p=e=>{f();let n=l.current;Object.keys(n).length!==0&&(c({}),t.savePrefs({themeColors:{...u.current,[e]:{...u.current[e],...n}}}))},m=(e,t)=>{c(n=>({...n,[e]:t})),l.current={...l.current,[e]:t},f(),d.current=window.setTimeout(()=>p(i),300)},h=(0,v.useRef)(r);(0,v.useEffect)(()=>{h.current!==r&&(h.current=r,p(i),a(r))},[r]);let g={...u.current[i],...s},_=Object.keys(g).length,y=e=>{f(),c({});let n={...g};delete n[e],t.savePrefs({themeColors:{...u.current,[i]:n}})};return(0,B.jsxs)(`div`,{className:`space-y-3 border-t border-border pt-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:`Theme colours`}),(0,B.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. To switch between light and dark, use Colour scheme above.`})]}),(0,B.jsx)(vC,{label:`Edit colour scheme`,value:i,options:[{value:`light`,label:`Light colours`},{value:`dark`,label:`Dark colours`}],onChange:e=>{p(i),a(e)}})]}),(0,B.jsx)(`div`,{className:`grid grid-cols-1 gap-x-4 sm:grid-cols-2`,children:Vl.map(e=>{let t=g[e]!==void 0,n=g[e]??o[e]??`#808080`;return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border py-1.5`,"data-testid":`theme-color-row-${i}-${e}`,children:[(0,B.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=>m(e,t.target.value),"aria-label":`${S9(e)} colour (${i} scheme)`,"data-testid":`theme-color-${i}-${e}`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:S9(e)}),(0,B.jsx)(`span`,{className:`w-16 shrink-0 text-right font-mono text-[10px] text-fg-faint`,children:t?g[e]:`default`}),t?(0,B.jsx)(lC,{label:`Reset ${S9(e)} to the theme colour`,className:`p-0.5`,"data-testid":`theme-color-clear-${i}-${e}`,onClick:()=>y(e),children:(0,B.jsx)(H.Refresh,{className:`w-3 h-3`})}):null]},e)})}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border pt-2`,children:[(0,B.jsx)(`span`,{className:`text-xs text-fg-faint`,"data-testid":`theme-colors-count`,children:_===0?`No custom colours in the ${i} scheme.`:`${_} custom colour${_===1?``:`s`} in the ${i} scheme.`}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>{f(),c({}),t.savePrefs({themeColors:{...u.current,[i]:{}}})},disabled:_===0,"data-testid":`theme-reset-${i}`,children:`Reset all`})]})]})}function wNe(){let{state:e,actions:t}=V(),n=e.prefs,[r,i]=(0,v.useState)(String(n.transcriptWindowSize));return(0,v.useEffect)(()=>i(String(n.transcriptWindowSize)),[n.transcriptWindowSize]),(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(fC,{label:`Transcript window size`,hint:`${f9.transcriptWindow.hint} Scrolling to the top brings back 100 more. 100–${Fl}, default 500.`,details:f9.transcriptWindow.details,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`input`,{className:z(pC,`w-32`),type:`number`,min:100,max:Fl,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,B.jsx)(`span`,{className:`text-xs text-fg-faint`,children:`messages and tool cards`})]})}),(0,B.jsx)(w9,{label:`Hidden chats kept in memory`,unit:`tabs`,hint:f9.keptTranscripts.hint,details:f9.keptTranscripts.details,value:n.keptTranscripts,min:0,max:20,defaultValue:3,onSave:e=>void t.savePrefs({keptTranscripts:e}),testId:`settings-kept-transcripts`})]})}function TNe({settings:e}){let{actions:t}=V(),n=Zee,r=Xee;return(0,B.jsxs)(`div`,{className:`space-y-3 border-t border-border pt-3`,"data-testid":`settings-memory`,children:[(0,B.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Memory`}),e.engineIdleMinutes===void 0?null:(0,B.jsx)(w9,{label:`Keep a quiet chat’s engine for`,unit:`minutes`,hint:f9.engineIdleMinutes.hint,details:f9.engineIdleMinutes.details,value:e.engineIdleMinutes,min:n.engineIdleMinutes.min,max:n.engineIdleMinutes.max,defaultValue:r.engineIdleMinutes,onSave:e=>void t.saveSettings({engineIdleMinutes:e}),testId:`settings-engine-idle-minutes`}),e.maxIdleEngines===void 0?null:(0,B.jsx)(w9,{label:`Engines kept with no turn`,unit:`engines`,hint:f9.maxIdleEngines.hint,details:f9.maxIdleEngines.details,value:e.maxIdleEngines,min:n.maxIdleEngines.min,max:n.maxIdleEngines.max,defaultValue:r.maxIdleEngines,onSave:e=>void t.saveSettings({maxIdleEngines:e}),testId:`settings-max-idle-engines`}),e.browserIdleMinutes===void 0?null:(0,B.jsx)(w9,{label:`Close an unused Oonak Browser after`,unit:`minutes`,hint:f9.browserIdleMinutes.hint,details:f9.browserIdleMinutes.details,value:e.browserIdleMinutes,min:n.browserIdleMinutes.min,max:n.browserIdleMinutes.max,defaultValue:r.browserIdleMinutes,onSave:e=>void t.saveSettings({browserIdleMinutes:e}),testId:`settings-browser-idle-minutes`})]})}function ENe(){let{state:e,actions:t}=V(),n=(0,v.useMemo)(()=>Xs(e.providers),[e.providers]);return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[n.length===0?(0,B.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=Ys(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,B.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border px-3 py-2`,"data-testid":`provider-${r.id}`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,B.jsx)(`span`,{className:`text-sm font-medium`,children:r.displayName}),i?(0,B.jsx)(hC,{tone:`accent`,children:`active`}):null,r.route===`direct`?(0,B.jsx)(hC,{tone:`ok`,children:`direct`}):null,s.length>0?s.map(e=>(0,B.jsxs)(hC,{tone:`ok`,children:[e===`subscription`?`subscription`:`API key`,` connected`]},e)):o?(0,B.jsx)(hC,{tone:`ok`,children:`connected`}):(0,B.jsx)(hC,{tone:`warn`,children:`not connected`})]}),(0,B.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,B.jsx)(cNe,{providerId:r.id,configured:o}):(0,B.jsxs)(U,{size:`sm`,variant:o?`secondary`:`primary`,onClick:()=>t.openProviderConnect(r.id),children:[(0,B.jsx)(H.Plus,{className:`w-3 h-3`}),` `,o?`Manage…`:`Connect`]})]},r.id)}),(0,B.jsx)(`div`,{className:`pt-3`,children:(0,B.jsx)(k5,{})})]})}function DNe(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=Lv(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`}, ${HF(t.bytesFreed)}, ${r}.`}function ONe({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(mu,Math.max(1,t));i(String(a)),a!==e&&n(a)};return(0,B.jsxs)(fC,{label:`Replace pictures older than`,hint:f9.imageRetention.hint,details:f9.imageRetention.details,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`input`,{className:z(pC,`w-24`),type:`number`,min:0,max:mu,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,B.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`days`,e===365?` (a year)`:``]})]}),(0,B.jsx)(`span`,{className:`text-xs text-fg-muted`,"data-testid":`settings-image-retention-status`,children:DNe(e,t)})]})}function kNe(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 w9({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=kNe(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,B.jsxs)(fC,{label:e,hint:`${n} ${h(a)}–${h(o)}, default ${h(s)}.`,details:r,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`input`,{className:z(pC,`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,B.jsx)(`span`,{className:`text-xs text-fg-faint`,children:t})]}),f?(0,B.jsx)(`span`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`${l}-problem`,children:f}):null]})}function ANe({settings:e}){let{actions:t}=V(),n=e.providerUsagePing!==!1;return(0,B.jsxs)(`div`,{className:`border-t border-border pt-1`,"data-testid":`settings-provider-usage`,children:[(0,B.jsx)(_C,{label:`Check my plan’s usage when I look at it`,hint:f9.providerUsagePing.hint,details:f9.providerUsagePing.details,checked:n,onChange:e=>void t.saveSettings({providerUsagePing:e}),testId:`settings-provider-usage-ping`}),n&&e.providerUsageStaleMinutes!==void 0?(0,B.jsx)(`div`,{className:`pt-2`,children:(0,B.jsx)(w9,{label:`Check again when the figure is older than`,unit:`minutes`,hint:f9.providerUsageStale.hint,details:f9.providerUsageStale.details,value:e.providerUsageStaleMinutes,min:0,max:Dc,defaultValue:10,onSave:e=>void t.saveSettings({providerUsageStaleMinutes:e}),testId:`settings-provider-usage-stale`})}):null]})}function jNe({settings:e}){let{actions:t}=V(),n=hf,r=mf;return(0,B.jsxs)(`div`,{className:`border-t border-border pt-3`,"data-testid":`settings-chat-abouts`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Chat abouts`}),(0,B.jsx)(U,{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,B.jsx)(_C,{label:`Write an about for every chat`,hint:f9.chatAbout.hint,details:f9.chatAbout.details,checked:e.chatAboutEnabled,onChange:e=>void t.saveSettings({chatAboutEnabled:e}),testId:`settings-chat-about-enabled`}),(0,B.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[e.chatAboutIntervalMinutes===void 0?null:(0,B.jsx)(w9,{label:`Minutes between background abouts`,unit:`minutes`,hint:f9.chatAboutInterval.hint,details:f9.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,B.jsx)(w9,{label:`Longest about`,unit:`words`,hint:f9.chatAboutMaxWords.hint,details:f9.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,B.jsx)(w9,{label:`How much of a chat is read`,unit:`characters`,hint:f9.chatAboutInputChars.hint,details:f9.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 MNe(){let{state:e,actions:t}=V(),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,B.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,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(fC,{label:`Default working directory`,hint:f9.defaultCwd.hint,details:f9.defaultCwd.details,children:(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`input`,{className:z(pC,`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,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>void s(),children:`Choose…`}):null,r?(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>{i(``),o(``)},children:`Clear`}):null]})}),(0,B.jsxs)(`div`,{className:`border-t border-border pt-1`,children:[(0,B.jsx)(_C,{label:`Remote access`,hint:f9.remoteAccess.hint,details:f9.remoteAccess.details,checked:n.relayEnabled??!0,onChange:e=>void t.saveSettings({relayEnabled:e}),testId:`settings-relay`}),n.telegramAllowed===void 0?null:(0,B.jsx)(_C,{label:`Allow Telegram to reach this PC`,hint:f9.telegram.hint,details:f9.telegram.details,checked:n.telegramAllowed,onChange:e=>void t.saveSettings({telegramAllowed:e}),testId:`settings-telegram`}),(0,B.jsx)(_C,{label:`Keep the vault unlocked when the app closes`,hint:f9.keepUnlocked.hint,details:f9.keepUnlocked.details,checked:n.keepUnlockedOnExit??!1,onChange:e=>void t.saveSettings({keepUnlockedOnExit:e}),testId:`settings-keep-unlocked-exit`})]}),n.imageRetentionDays===void 0?null:(0,B.jsx)(`div`,{className:`border-t border-border pt-3`,children:(0,B.jsx)(ONe,{days:n.imageRetentionDays,lastRun:n.imageRetentionLastRun??null,onSave:e=>void t.saveSettings({imageRetentionDays:e})})}),n.promptSuggestions===void 0?null:(0,B.jsx)(`div`,{className:`border-t border-border pt-1`,"data-testid":`settings-prompt-suggestions`,children:(0,B.jsx)(_C,{label:`Auto-suggest my next message`,hint:f9.promptSuggestions.hint,details:f9.promptSuggestions.details,checked:n.promptSuggestions,onChange:e=>void t.saveSettings({promptSuggestions:e}),testId:`settings-prompt-suggestions-toggle`})}),n.providerUsagePing===void 0?null:(0,B.jsx)(ANe,{settings:n}),n.chatAboutEnabled!==void 0||n.chatAboutIntervalMinutes!==void 0||n.chatAboutMaxWords!==void 0||n.chatAboutInputChars!==void 0?(0,B.jsx)(jNe,{settings:n}):null,n.engineIdleMinutes!==void 0||n.maxIdleEngines!==void 0||n.browserIdleMinutes!==void 0?(0,B.jsx)(TNe,{settings:n}):null,(0,B.jsxs)(`div`,{className:`space-y-2 border-t border-border pt-3 text-xs`,children:[(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Server`,(0,B.jsx)(uC,{label:`Server`,details:(0,B.jsx)(dC,{items:f9.server.details})})]}),(0,B.jsx)(`span`,{className:`block text-fg-faint`,children:f9.server.hint})]}),(0,B.jsx)(`span`,{className:`break-all font-mono text-fg-muted`,"data-testid":`settings-server`,children:a})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Diagnostics`,(0,B.jsx)(uC,{label:`Diagnostics`,details:(0,B.jsx)(dC,{items:f9.diagnostics.details})})]}),(0,B.jsx)(`span`,{className:`block text-fg-faint`,children:f9.diagnostics.hint})]})]})]})}function T9(e){return e instanceof Error?e.message:String(e)}function NNe(){let e=b9(),[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,r=!1,a=e.onDebuggingChanged?.(e=>{r=!0,t&&n(e)});return e.getDebugging().then(e=>{!t||r||(n(e),o(String(e.saved.port)))},e=>{t&&i(T9(e))}),()=>{t=!1,a?.()}},[e]),!e)return(0,B.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,B.jsx)(`div`,{className:`py-6 text-sm text-danger`,role:`alert`,children:r}):(0,B.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(T9(e))}})},d=()=>{let e=a.trim(),n=/^\d+$/.test(e)?Number(e):NaN,r=qc(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(T9(e))}},p=iNe(t),m=r!==null&&/^(The port|Ports?) /.test(r);return(0,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`settings-developer`,children:[(0,B.jsx)(_C,{label:`Allow debugging`,hint:f9.allowDebugging.hint,details:f9.allowDebugging.details,checked:t.saved.enabled,onChange:e=>u({enabled:e}),testId:`settings-allow-debugging`}),(0,B.jsx)(fC,{label:`Debugging port`,hint:`${f9.debugPort.hint} ${Hc}–${Uc}, default ${Vc}.`,details:f9.debugPort.details,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`input`,{className:z(pC,`max-w-28`,m&&`border-danger`),type:`number`,min:Hc,max:Uc,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,B.jsx)(`span`,{className:`whitespace-nowrap text-xs text-fg-faint`,children:`on 127.0.0.1`})]})}),(0,B.jsx)(_C,{label:`Also debug the main process`,hint:f9.debugMainProcess.hint,details:f9.debugMainProcess.details,checked:t.saved.inspectMain,disabled:!t.saved.enabled,onChange:e=>u({inspectMain:e}),testId:`settings-debug-main`}),r?(0,B.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`settings-debugging-problem`,children:r}):null,(0,B.jsxs)(`div`,{className:`rounded-md border border-border px-3 py-2 text-xs`,"data-testid":`settings-debugging-status`,children:[(0,B.jsx)(`div`,{className:`text-fg-muted`,children:rNe(t.running)}),p?(0,B.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-warn`,"data-testid":`settings-debugging-restart-note`,children:aNe(t)}),(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:()=>void f(),disabled:s!==null||!e.relaunchApp,"data-testid":`settings-debugging-restart`,children:`Restart now`})]}):null,s?(0,B.jsx)(`div`,{className:`mt-1 text-fg-faint`,children:s}):null]})]})}function PNe({open:e,onClose:t}){let{state:n,actions:r}=V(),[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=b9()!==null,c=s?y9:y9.filter(e=>e.id!==`developer`);return(0,B.jsx)(gC,{open:e,title:`Settings`,onClose:t,wide:!0,footer:(0,B.jsx)(U,{onClick:t,children:`Done`}),children:(0,B.jsxs)(`div`,{className:`flex min-h-[22rem] gap-4`,children:[(0,B.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,B.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),"aria-current":i===e.id?`true`:void 0,className:z(`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,B.jsx)(t,{className:`w-3.5 h-3.5`}),e.label]},e.id)}),(0,B.jsxs)(`div`,{className:`pt-3 text-[11px] text-fg-faint`,children:[`OonaCode Desktop v`,cS(typeof window<`u`&&window.oonacode?.appVersion||n.connection.appVersion||`0.0.0`,sS({bridge:typeof window<`u`?window.oonacode:void 0,info:n.info}))]})]}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i===`general`?(0,B.jsx)(vNe,{}):null,i===`safeguards`?(0,B.jsx)(dNe,{}):null,i===`theme`?(0,B.jsx)(SNe,{}):null,i===`advanced`?(0,B.jsx)(wNe,{}):null,i===`skills`?(0,B.jsx)(fNe,{}):null,i===`mcp`?(0,B.jsx)(hNe,{}):null,i===`providers`?(0,B.jsx)(ENe,{}):null,i===`devices`?(0,B.jsx)(gNe,{}):null,i===`host`?(0,B.jsx)(MNe,{}):null,i===`developer`&&s?(0,B.jsx)(NNe,{}):null]})]})})}function FNe({toast:e}){let{actions:t}=V();(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,B.jsxs)(`div`,{role:e.kind===`error`?`alert`:`status`,className:z(`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,B.jsx)(H.Alert,{className:`mt-0.5 w-4 h-4`}):e.kind===`success`?(0,B.jsx)(H.Check,{className:`mt-0.5 w-4 h-4`}):null,(0,B.jsx)(`div`,{className:`pre-wrap min-w-0 flex-1`,children:e.text}),e.action?(0,B.jsx)(`button`,{type:`button`,className:`shrink-0 font-medium underline underline-offset-2 hover:opacity-80`,"data-testid":`toast-action`,onClick:()=>{e.action?.run(),t.dismissToast(e.id)},children:e.action.label}):null,(0,B.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,className:`opacity-60 hover:opacity-100`,onClick:()=>t.dismissToast(e.id),children:(0,B.jsx)(H.X,{className:`w-3.5 h-3.5`})})]})}function E9(){let{state:e}=V();return e.toasts.length===0?null:(0,B.jsx)(`div`,{className:`pointer-events-none fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.toasts.map(e=>(0,B.jsx)(FNe,{toast:e},e.id))})}var INe=2e3;function D9(e){if(!O9(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 O9(e){if(typeof e!=`string`||e===``)return!1;try{let{protocol:t}=new URL(e);return t===`http:`||t===`https:`}catch{return!1}}function LNe(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 k9({children:e,testId:t}){let{state:n}=V(),r=n.connection.hostName??n.info?.hostName??null;return(0,B.jsxs)(`div`,{className:`flex h-full flex-col bg-bg text-fg`,"data-testid":t,children:[(0,B.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-surface px-3`,children:[(0,B.jsx)(`span`,{className:`font-semibold tracking-tight`,children:`OonaCode`}),r?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-fg-faint`,children:`/`}),(0,B.jsx)(`span`,{className:`truncate text-sm text-fg-muted`,"data-testid":`frame-host-name`,children:r})]}):null]}),(0,B.jsx)(`main`,{className:`flex min-h-0 flex-1 items-start justify-center overflow-y-auto p-6`,children:(0,B.jsx)(`div`,{className:`w-full max-w-md py-6`,children:e})}),(0,B.jsx)(E9,{})]})}function RNe(){return(0,B.jsx)(k9,{testId:`account-loading`,children:(0,B.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,B.jsx)(H.Spinner,{className:`w-4 h-4`}),(0,B.jsx)(`span`,{children:`Checking your account…`})]})})}function zNe({link:e}){let{actions:t}=V(),[n,r]=(0,v.useState)(!1),i=e.verificationUrl??``,a=e.verificationUrlComplete??i,o=O9(a),s=t.refreshAccountLink;return(0,v.useEffect)(()=>{let e=setInterval(()=>void s(),INe);return()=>clearInterval(e)},[s]),(0,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`link-waiting`,children:[(0,B.jsxs)(`ol`,{className:`space-y-2 text-sm`,children:[(0,B.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`1. Open`}),o?(0,B.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(),D9(a))},children:i}):(0,B.jsx)(`span`,{className:`break-all font-medium`,"data-testid":`link-url`,children:i})]}),(0,B.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`2. Enter`}),(0,B.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,B.jsxs)(`p`,{className:`flex items-center gap-2 text-xs text-fg-muted`,role:`status`,children:[(0,B.jsx)(H.Spinner,{className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{children:`Waiting for approval in your browser…`})]}),(0,B.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,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o?(0,B.jsxs)(U,{size:`sm`,onClick:()=>D9(a),"data-testid":`link-reopen`,children:[(0,B.jsx)(H.LogIn,{className:`w-3.5 h-3.5`}),` Open the browser again`]}):null,(0,B.jsx)(U,{size:`sm`,variant:`ghost`,busy:n,"data-testid":`link-cancel`,onClick:()=>{r(!0),t.cancelAccountLink().finally(()=>r(!1))},children:`Cancel`})]})]})}function BNe(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 VNe(){let{state:e,actions:t}=V(),n=e.accountLink,r=BNe(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`&&D9(e.verificationUrlComplete??e.verificationUrl??``)}finally{a(!1)}},[t]);if(n?.status===`waiting`)return(0,B.jsx)(zNe,{link:n});let s=n&&(n.status===`denied`||n.status===`expired`);return(0,B.jsxs)(`div`,{className:`space-y-2`,children:[s?(0,B.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:LNe(n)}):null,(0,B.jsxs)(U,{variant:`primary`,busy:i,onClick:()=>void o(),"data-testid":`link-start`,className:`w-full justify-center`,children:[(0,B.jsx)(H.LogIn,{className:`w-3.5 h-3.5`}),s?`Try again in your browser`:`Sign in with your browser`]}),(0,B.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 HNe(){let{state:e}=V(),[t,n]=(0,v.useState)(!1),r=t||e.emailVerification!==null;return(0,B.jsx)(k9,{testId:`sign-in-view`,children:(0,B.jsxs)(`div`,{className:`space-y-5`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Sign in to use OonaCode`}),(0,B.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,B.jsx)(VNe,{}),(0,B.jsx)(`div`,{className:z(`space-y-3 border-t border-border pt-4`,r?``:`text-center`),children:r?(0,B.jsx)(rw,{}):(0,B.jsx)(U,{size:`sm`,variant:`ghost`,"data-testid":`use-password`,onClick:()=>n(!0),children:`Use an email and password instead`})})]})})}function UNe(){let{state:e,actions:t}=V(),[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,B.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,B.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,B.jsx)(H.Lock,{className:`mx-auto h-10 w-10 text-fg-faint`}),(0,B.jsx)(`h1`,{className:`text-lg font-semibold`,children:`This device is locked`}),(0,B.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,B.jsx)(`input`,{ref:u,type:`password`,className:pC,value:n,onChange:e=>r(e.target.value),onMouseDown:e=>e.stopPropagation(),placeholder:`Account password`,autoFocus:!0,"data-testid":`locked-password`}),(0,B.jsxs)(`label`,{className:`flex items-start justify-center gap-2 text-sm text-fg-muted`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:i,onChange:e=>a(e.target.checked),"data-testid":`locked-keep-unlocked`}),(0,B.jsx)(`span`,{children:`Keep me unlocked on this PC`})]}),c?(0,B.jsx)(`div`,{className:`text-sm text-danger`,"data-testid":`locked-error`,children:c}):null,(0,B.jsx)(U,{type:`submit`,variant:`primary`,busy:o,disabled:!n,children:`Unlock`}),(0,B.jsxs)(`div`,{className:`text-xs text-fg-faint`,children:[`Signed in as `,e.account?.email??`this account`,` ·`,` `,(0,B.jsx)(`button`,{type:`button`,className:`underline hover:text-fg`,onClick:()=>void t.logout(),children:`Sign out`})]})]}),(0,B.jsx)(E9,{})]})}function WNe(){return _S(typeof window<`u`?window.oonacode:void 0)}function GNe(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 A9=2*Math.PI*10;function KNe(){return typeof window<`u`&&window.oonacode!==void 0}function qNe(){let{state:e,actions:t}=V(),n=e.update,r=e.updateInstall,i=e.prefs.dismissedUpdateVersion,a=n.version!==``&&(e.updateDismissed===n.version||i===n.version);if(!KNe())return null;let o=fS({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 OonaCode`:o===`ready`?`Restart to finish updating`:o===`downloading`?`Downloading update (${u}%)`:o===`available`?`Update available (${l})`:`Check for updates`,f=s?e.terminalUpdate.message||`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,B.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:z(`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,B.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,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,fill:`none`,strokeWidth:`2`,className:`stroke-border`}),(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:A9,strokeDashoffset:A9*(1-Math.max(0,Math.min(100,u))/100),className:`stroke-accent`})]}):null,c&&o!==`downloading`&&o!==`ready`?(0,B.jsx)(`span`,{"data-testid":`update-badge-checking`,className:`inline-flex`,children:(0,B.jsx)(H.Spinner,{className:`w-3.5 h-3.5`})}):o===`ready`?(0,B.jsx)(`span`,{"data-testid":`update-badge-ready`,className:`inline-flex`,children:(0,B.jsx)(H.Refresh,{className:`w-3.5 h-3.5`})}):o===`downloading`?(0,B.jsx)(`span`,{"data-testid":`update-badge-downloading`,className:`text-[9px] font-semibold`,children:u}):(0,B.jsx)(`span`,{"data-testid":o===`available`?`update-badge-available`:`update-badge-idle`,className:`inline-flex`,children:(0,B.jsx)(H.Download,{className:`w-3.5 h-3.5`})}),o===`available`?(0,B.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-accent`,"aria-hidden":!0}):null]})}function JNe(){let{state:e,actions:t}=V(),n=e.updateInstall,r=Math.round(Math.max(0,Math.min(100,n.percent))),i=hS(n.bytesPerSecond);if(n.phase===`error`)return(0,B.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,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(H.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:`The update could not be downloaded.`}),(0,B.jsx)(`div`,{className:`mt-0.5 pre-wrap break-words`,children:n.error})]})]}),(0,B.jsx)(`div`,{className:`mt-2`,children:(0,B.jsxs)(U,{size:`sm`,onClick:()=>void t.installUpdate(),"data-testid":`update-retry`,children:[(0,B.jsx)(H.Refresh,{className:`w-3.5 h-3.5`}),` Try again`]})})]});let a=n.phase===`installing`;return(0,B.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`update-progress`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,B.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,B.jsxs)(`span`,{className:`text-fg-muted`,children:[r,`%`]})]}),n.notice?(0,B.jsx)(`div`,{className:`pre-wrap text-xs text-warn`,"data-testid":`update-notice`,role:`status`,children:n.notice}):null,(0,B.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-2`,children:(0,B.jsx)(`div`,{className:z(`h-full rounded-full bg-accent`,a&&`animate-pulse`),style:{width:`${a?100:r}%`},"data-testid":`update-progress-bar`})}),a?(0,B.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,B.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-fg-faint`,children:[(0,B.jsxs)(`span`,{children:[mS(n.transferred),n.total>0?` of ${mS(n.total)}`:``]}),i?(0,B.jsx)(`span`,{children:i}):null]})]})}function YNe(){let{state:e,actions:t}=V(),n=e.terminalUpdate;return n.running?(0,B.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,B.jsx)(H.Spinner,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`font-medium text-fg`,children:n.message?`Updating OonaCode...`:`Updating the oona CLI and host service...`}),(0,B.jsx)(`div`,{className:`mt-0.5 text-fg-faint`,"data-testid":`terminal-update-message`,children:n.message||`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,B.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,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(H.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:`The CLI and host service could not be updated.`}),(0,B.jsx)(`div`,{className:`mt-0.5 pre-wrap break-words`,children:n.message})]})]}),(0,B.jsx)(`div`,{className:`mt-2`,children:(0,B.jsxs)(U,{size:`sm`,onClick:()=>void t.installUpdate(),"data-testid":`terminal-update-retry`,children:[(0,B.jsx)(H.Refresh,{className:`w-3.5 h-3.5`}),` Try again`]})})]}):null}function XNe({open:e,onClose:t}){let{state:n,actions:r}=V(),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=WNe(),l=vS(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,B.jsx)(gC,{open:e,title:`Update OonaCode`,onClose:t,footer:p?(0,B.jsx)(U,{onClick:t,"data-testid":`update-running-close`,children:`Close`}):d?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{onClick:t,children:`Later`}),(0,B.jsxs)(U,{variant:`primary`,onClick:()=>void r.installUpdate(),"data-testid":`update-restart`,children:[(0,B.jsx)(H.Refresh,{className:`w-4 h-4`}),`Restart and install`]})]}):f?(0,B.jsx)(U,{onClick:t,children:`Close`}):l.upToDate?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(U,{onClick:()=>void r.checkUpdates(!0),busy:m,disabled:m,"data-testid":`update-check-again`,children:[(0,B.jsx)(H.Refresh,{className:`w-4 h-4`}),`Check again`]}),(0,B.jsx)(U,{variant:`primary`,onClick:t,children:`Close`})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{onClick:()=>r.dismissUpdate(),children:`Skip this version`}),(0,B.jsx)(U,{onClick:t,children:`Later`}),(0,B.jsxs)(U,{variant:`primary`,busy:m,disabled:m,onClick:()=>void r.installUpdate(),children:[(0,B.jsx)(H.Download,{className:`w-4 h-4`}),l.label]})]}),children:(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[u?(0,B.jsxs)(`span`,{className:`font-medium`,children:[`Release `,u]}):null,i.channel?(0,B.jsx)(hC,{children:i.channel}):null,n.updateChecking?(0,B.jsx)(`span`,{className:`text-xs text-fg-faint`,"data-testid":`update-rechecking`,children:`checking for a newer one…`}):null,i.publishedAt?(0,B.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`published `,new Date(i.publishedAt).toLocaleDateString()]}):null]}),f?(0,B.jsx)(JNe,{}):null,(0,B.jsx)(YNe,{}),i.components.length>0?(0,B.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:i.components.map(e=>(0,B.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2`,children:[(0,B.jsx)(H.Download,{className:`mt-0.5 w-3.5 h-3.5 shrink-0 text-accent`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,B.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[e.current,` → `,(0,B.jsx)(`span`,{className:`font-medium text-fg`,children:e.latest})]}),(0,B.jsx)(`div`,{className:`text-xs text-fg-faint`,"data-testid":`update-how-${e.component}`,children:yS(e.component,c)}),e.notes?(0,B.jsx)(`div`,{className:`mt-0.5 pre-wrap text-xs text-fg-faint`,children:e.notes}):null]})]},e.component))}):null,i.notes?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Release notes`}),(0,B.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,B.jsx)(`p`,{className:`text-xs text-fg-faint`,"data-testid":`update-plan-note`,children:GNe(l)})]})})}var j9=`oona-global-search`,M9=`oona-global-search-current`,ZNe=2e3,QNe=400;function N9(){let e=globalThis.CSS,t=globalThis.Highlight;return!e?.highlights||typeof t!=`function`?null:{registry:e.highlights,Highlight:t}}function P9(e,t){let n=N9();if(n===null)return;if(e.length===0){F9();return}let r=t>=0&&t<e.length?e[t]:null,i=[];for(let n=0;n<e.length;n++)n!==t&&i.push(e[n]);n.registry.set(j9,new n.Highlight(...i)),r?n.registry.set(M9,new n.Highlight(r)):n.registry.delete(M9)}function F9(){let e=N9();e!==null&&(e.registry.delete(j9),e.registry.delete(M9))}function I9(e,t,n=ZNe){let r=Ue(t);if(r===``||n<=0)return[];let i=e instanceof Document?e:e.ownerDocument??(typeof document<`u`?document:null);if(!i)return[];let a=Ge(r),o=[],s=e instanceof Document?e.body??e:e,c=new Map,l=e=>{if(e===null)return!0;let t=c.get(e);if(t!==void 0)return t;let n=!e.hasAttribute(`hidden`)&&!e.hasAttribute(`data-global-search-ignore`);if(n&&typeof window<`u`&&typeof window.getComputedStyle==`function`)try{let t=window.getComputedStyle(e);(t.display===`none`||t.visibility===`hidden`)&&(n=!1)}catch{}return n&&=l(e.parentElement),c.set(e,n),n},u=i.createTreeWalker(s,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;if(!t)return NodeFilter.FILTER_REJECT;let n=t.tagName;return n===`SCRIPT`||n===`STYLE`||n===`NOSCRIPT`||n===`TEMPLATE`||!l(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});for(let e=u.nextNode();e!==null;e=u.nextNode()){let t=e.data;if(!(!t||t.trim()===``)){a.lastIndex=0;for(let r of t.matchAll(a)){if(r[0].length===0)continue;let t=i.createRange();if(t.setStart(e,r.index??0),t.setEnd(e,(r.index??0)+r[0].length),o.push(t),o.length>=n)return o}}}return o}function L9(e){let t=e.startContainer instanceof Element?e.startContainer:e.startContainer.parentElement;if(!t)return;let n=t;for(;n&&n!==document.body;)n instanceof HTMLDetailsElement&&!n.open&&(n.open=!0),n=n.parentElement;typeof t.scrollIntoView==`function`&&t.scrollIntoView({behavior:`smooth`,block:`center`,inline:`nearest`});let r=t.parentElement;for(;r&&r!==document.body;){if(r instanceof HTMLElement&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth)){let e=window.getComputedStyle(r);if(e.overflowY===`auto`||e.overflowY===`scroll`){let e=r.getBoundingClientRect(),n=t.getBoundingClientRect();(n.top<e.top||n.bottom>e.bottom)&&(r.scrollTop+=n.top-e.top-(e.height-n.height)/2)}}r=r.parentElement}}function R9(e){if(typeof document>`u`||(document.querySelectorAll(`.oona-global-search-current`).forEach(e=>{e.classList.remove(`oona-global-search-current`)}),!e))return;let t=e.startContainer instanceof Element?e.startContainer:e.startContainer.parentElement;t&&t.classList.add(`oona-global-search-current`)}function $Ne(e){return!(e.target.nodeType===1?e.target:e.target.parentElement)?.closest(`[data-global-search-ignore]`)}function ePe(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)([]),[i,a]=(0,v.useState)(-1),o=(0,v.useRef)(null),s=(0,v.useCallback)(()=>{t(``),r([]),a(-1),F9(),R9(null)},[]),c=(0,v.useCallback)(e=>{let t=Ue(e);if(t===``){r([]),a(-1),F9(),R9(null);return}if(typeof document>`u`)return;let n=I9(document,t);r(n);let i=n.length>0?0:-1;a(i),P9(n,i),i>=0&&n[i]?(R9(n[i]),L9(n[i])):R9(null)},[]),l=e=>{t(e),c(e)},u=(0,v.useCallback)(t=>{if(n.length===0)return;let o=n;if(o.some(e=>!e.startContainer.isConnected)&&typeof document<`u`&&(o=I9(document,e),r(o)),o.length===0){a(-1),F9(),R9(null);return}let s=Ye(i,t,o.length);a(s),P9(o,s);let c=o[s];c&&(R9(c),L9(c))},[i,n,e]),d=e=>{e.key===`Enter`?(e.preventDefault(),u(e.shiftKey?-1:1)):e.key===`ArrowDown`?(e.preventDefault(),u(1)):e.key===`ArrowUp`?(e.preventDefault(),u(-1)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),s(),o.current?.blur())};(0,v.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{if(!(!(e.ctrlKey||e.metaKey)||e.altKey)&&(e.code===`KeyF`||e.key===`f`||e.key===`F`)){if(e.shiftKey){e.preventDefault(),o.current?.focus(),o.current?.select();return}setTimeout(()=>{e.defaultPrevented||(o.current?.focus(),o.current?.select())},0)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,v.useEffect)(()=>{if(!e.trim()||typeof document>`u`)return;let t=null,n=new MutationObserver(n=>{!n.some($Ne)||document.hidden||(t||=setTimeout(()=>{if(t=null,e.trim()){let t=I9(document,e);r(t);let n=t.length===0?-1:i>=0&&i<t.length?i:0;a(n),P9(t,n),n>=0&&t[n]?R9(t[n]):R9(null)}},QNe))});return n.observe(document.body,{childList:!0,subtree:!0,characterData:!0}),()=>{n.disconnect(),t&&clearTimeout(t)}},[e,i]);let f=e.trim()!==``,p=n.length,m=typeof navigator<`u`&&/Mac|iPhone|iPad|iPod/.test(navigator.platform)?`Find in page (⌘F)`:`Find in page (Ctrl+F)`;return(0,B.jsxs)(`div`,{"data-testid":`global-search`,"data-global-search-ignore":`true`,role:`search`,className:z(`relative inline-flex h-7 items-center rounded-full border border-border bg-surface px-2 text-xs transition-all`,`focus-within:border-accent focus-within:ring-1 focus-within:ring-accent/20`,f?`w-56 sm:w-64 md:w-72`:`w-32 sm:w-40 md:w-48`),title:m,children:[(0,B.jsx)(H.Search,{className:`w-3.5 h-3.5 shrink-0 text-fg-muted mr-1.5`}),(0,B.jsx)(`input`,{ref:o,type:`text`,value:e,onChange:e=>l(e.target.value),onKeyDown:d,placeholder:`Find in page...`,"aria-label":`Find in page`,spellCheck:!1,className:`h-full min-w-0 flex-1 bg-transparent py-0 text-xs text-fg placeholder:text-fg-muted focus:outline-none`,"data-testid":`global-search-input`}),f&&(0,B.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0 ml-1`,children:[(0,B.jsx)(`span`,{className:z(`tabular-nums text-[11px] px-1 select-none`,p===0?`text-warn font-medium`:`text-fg-muted`),"data-testid":`global-search-count`,children:Xe(i,p)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>u(-1),disabled:p===0,title:`Previous match (Shift+Enter or ↑)`,"aria-label":`Previous match`,"data-testid":`global-search-prev`,className:`flex h-5 w-5 items-center justify-center rounded text-fg-muted hover:text-fg hover:bg-surface-2 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-fg-muted`,children:(0,B.jsx)(H.ArrowDown,{className:`w-3 h-3 rotate-180`})}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>u(1),disabled:p===0,title:`Next match (Enter or ↓)`,"aria-label":`Next match`,"data-testid":`global-search-next`,className:`flex h-5 w-5 items-center justify-center rounded text-fg-muted hover:text-fg hover:bg-surface-2 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-fg-muted`,children:(0,B.jsx)(H.ArrowDown,{className:`w-3 h-3`})}),(0,B.jsx)(`button`,{type:`button`,onClick:s,title:`Clear search (Esc)`,"aria-label":`Clear search`,"data-testid":`global-search-clear`,className:`flex h-5 w-5 items-center justify-center rounded text-fg-muted hover:text-fg hover:bg-surface-2`,children:(0,B.jsx)(H.X,{className:`w-3 h-3`})})]})]})}function tPe(){let{state:e,actions:t,api:n}=V(),[r,i]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(e.connection.status!==`open`)return;let t=!1,r=n.listStickyNotes;if(r)return r().then(e=>{t||i(e.notes.length)}).catch(()=>void 0),()=>{t=!0}},[n,e.connection.status,e.ui.dialog]),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>t.openDialog(`sticky-notes`),title:r===null?`Sticky notes`:`Sticky notes, ${r} tab${r===1?``:`s`}`,"aria-label":`Sticky notes`,"data-testid":`sticky-notes-button`,className:`relative 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,B.jsx)(H.StickyNote,{className:`w-3.5 h-3.5`}),r!==null&&r>0&&(0,B.jsx)(`span`,{"data-testid":`sticky-notes-count`,className:`absolute -right-1 -top-1 min-w-4 rounded-full bg-accent px-1 text-[10px] font-semibold leading-4 text-white`,children:r})]})}function nPe(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 rPe(){let{state:e,actions:t}=V(),n=nPe(e.connection.status),r=e.account?.loggedIn===!0,i=e.prefs.rightPanelSections.includes(`media`),a=gx(),o=e.prefs.leftPanelSection===`files`&&(a?e.ui.sidebarOpen:e.prefs.leftPanelOpen),s=o,c=e.prefs.rightPanelSections.includes(`sessionInfo`);return(0,B.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-surface px-2 sm:px-3`,children:[(0,B.jsx)(lC,{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,B.jsx)(H.PanelLeft,{})}),(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-semibold tracking-tight`,children:`OonaCode`}),(0,B.jsx)(`span`,{className:`hidden text-fg-faint sm:inline`,children:`/`}),(0,B.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,B.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,B.jsx)(`span`,{className:z(`inline-block h-2 w-2 rounded-full`,n.cls),"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:n.label})]})]}),(0,B.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,B.jsx)(aPe,{}),(0,B.jsx)(iPe,{}),(0,B.jsx)(ePe,{}),(0,B.jsx)(tPe,{}),(0,B.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,B.jsx)(H.Bug,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(qNe,{}),e.hostUpdatedTo?(0,B.jsxs)(U,{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,B.jsxs)(U,{size:`sm`,variant:`primary`,onClick:()=>t.openDialog(`account`),"data-testid":`sign-in`,children:[(0,B.jsx)(H.LogIn,{className:`w-3.5 h-3.5`}),` Sign in`]}),(0,B.jsx)(lC,{label:s?`Hide files`:`Show files`,onClick:()=>{o?a?t.setSidebar(!1):t.showLeftSection(`sessions`):t.showLeftSection(`files`)},className:z(`md:hidden`,s?`bg-surface-2 text-fg`:void 0),"aria-pressed":s,"data-testid":`toggle-explorer`,children:(0,B.jsx)(H.Folder,{})}),(0,B.jsx)(lC,{label:i?`Hide media in this chat`:`Media in this chat`,onClick:()=>t.setRightSection(`media`,!i),className:i?`bg-surface-2 text-fg`:void 0,"aria-pressed":i,disabled:!e.currentSessionId,"data-testid":`toggle-media-panel`,children:(0,B.jsx)(H.Gallery,{})}),(0,B.jsx)(lC,{label:c?`Hide session info`:`Show session info`,onClick:()=>t.setRightSection(`sessionInfo`,!c),className:z(`lg:hidden`,c?`bg-surface-2 text-fg`:void 0),"data-testid":`toggle-session-panel`,children:(0,B.jsx)(H.Panel,{})}),(0,B.jsx)(lC,{label:`Doctor`,onClick:()=>t.openDialog(`doctor`),children:(0,B.jsx)(H.Stethoscope,{})}),r?(0,B.jsx)(oPe,{}):null,(0,B.jsx)(lC,{label:`Account`,onClick:()=>t.openDialog(`account`),children:(0,B.jsxs)(`span`,{className:`relative`,children:[(0,B.jsx)(H.User,{}),r?(0,B.jsx)(`span`,{className:z(`absolute -right-0.5 -top-0.5 h-1.5 w-1.5 rounded-full`,e.account?.vaultUnlocked?`bg-ok`:`bg-warn`)}):null]})}),(0,B.jsx)(lC,{label:`Settings`,onClick:()=>t.openDialog(`settings`),children:(0,B.jsx)(H.Settings,{})})]})]})}function iPe(){let{state:e,actions:t}=V(),n=(e.mcpServers??[]).filter(e=>e.enabled!==!1).length;return(0,B.jsxs)(`button`,{type:`button`,onClick:()=>t.openSettings(`mcp`),title:n===0?`No MCP servers configured. Click to open MCP Settings.`:`${n} MCP server${n===1?``:`s`} configured. Click to open MCP Settings.`,"aria-label":`MCP Servers`,"data-testid":`mcp-topbar-badge`,className:z(`inline-flex h-7 items-center gap-1 rounded-full border border-border px-2 text-xs transition-transform hover:scale-105`,n>0?`bg-surface-2 text-fg hover:border-accent hover:text-accent`:`bg-surface text-fg-muted hover:text-fg`),children:[(0,B.jsx)(H.Plug,{className:z(`w-3.5 h-3.5`,n>0?`text-accent`:`text-fg-muted`)}),(0,B.jsx)(`span`,{className:`font-medium text-[11px]`,children:n})]})}function aPe(){let{actions:e}=V(),[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,r=!1,i=e.onDebuggingChanged?.(e=>{r=!0,t&&n(e.running)});return e.getDebugging().then(e=>{t&&!r&&n(e.running)},()=>{}),()=>{t=!1,i?.()}},[]),t&&Xc(t)){let n=oNe(t);return(0,B.jsxs)(`button`,{type:`button`,onClick:()=>e.openSettings(`developer`),title:n,"aria-label":n,"data-testid":`debugging-restart-badge`,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full border border-warn px-2.5 text-[11px] font-semibold text-warn hover:bg-warn-soft`,children:[(0,B.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warn`,"aria-hidden":!0}),`Debugging: restart to close`]})}if(!t||!Jc(t))return null;let r=sNe(t);return(0,B.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,B.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-white`,"aria-hidden":!0}),`Debugging on`]})}function oPe(){let{state:e}=V(),[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?Px(i):null,s=Lx(i),c=Rx;return(0,B.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,B.jsx)(lC,{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,B.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(H.Coins,{}),a===null?null:(0,B.jsx)(`span`,{className:z(`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,B.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,B.jsx)(`div`,{className:`text-fg-muted`,children:`Balance is unavailable — the gateway can't be reached.`}):(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`Plan`}),(0,B.jsxs)(`span`,{className:`font-medium`,children:[i.planName,i.status===`none`?` (lapsed)`:``]})]}),(0,B.jsx)(`div`,{className:`h-px bg-border`}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`Credits`}),(0,B.jsx)(`span`,{className:`font-semibold tabular-nums`,children:c(o.balance)})]}),s?(0,B.jsx)(`div`,{className:z(`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,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`Plan credits`}),(0,B.jsx)(`span`,{className:`tabular-nums`,children:c(o.plan??0)})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`Top-up credits`}),(0,B.jsx)(`span`,{className:`tabular-nums`,children:c(o.topup??0)})]})]}):null,(0,B.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 — credits you buy never expire; the sign-up gift ends after its welcome period.`,` `,`Free models never draw on this balance.`]})]})}):null]})}function sPe(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 cPe(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 ${mS(e.size)}; a file may be at most ${mS(_c)}.`};if(i+e.size>12582912)return{accepted:n,refused:`All files together may be at most ${mS(vc)}.`};n.push(e),r+=1,i+=e.size}return{accepted:n,refused:null}}function lPe(e){return e instanceof qg?e.code===`account_required`||e.status===401?`Sign in to OonaCode first — a report is filed under your account so we can answer it.`:Zg(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 z9=0;function uPe({open:e,onClose:t}){let{state:n,actions:r,api:i}=V(),[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}=cPe(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 sPe(t);if(!n)continue;let r=t.type||`application/octet-stream`;z9+=1,e.push({key:`f${z9}`,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,gc),...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(lPe(e))}finally{u(!1)}},E=gc-a.length;return(0,B.jsx)(gC,{open:e,title:`Bug Report`,onClose:t,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{onClick:t,disabled:l,children:`Cancel`}),(0,B.jsxs)(U,{variant:`primary`,busy:l,disabled:!a.trim()||p,onClick:()=>void T(),"data-testid":`bug-report-send`,children:[(0,B.jsx)(H.Bug,{className:`w-4 h-4`}),`Send report`]})]}),children:(0,B.jsxs)(`div`,{className:`space-y-3 text-sm`,"data-testid":`bug-report-dialog`,children:[(0,B.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,B.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,B.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,B.jsx)(`span`,{className:`font-medium text-fg`,children:`What happened?`}),(0,B.jsx)(`textarea`,{name:`message`,className:z(pC,`min-h-32 resize-y`),value:a,maxLength:gc,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,B.jsx)(`span`,{className:`text-xs text-fg-faint`,children:E<500?`${E} characters left`:``})]}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`input`,{ref:h,type:`file`,multiple:!0,className:`hidden`,onChange:C,"data-testid":`bug-report-files`}),(0,B.jsxs)(U,{size:`sm`,onClick:()=>h.current?.click(),disabled:l||p||s.length>=5,children:[(0,B.jsx)(H.Paperclip,{className:`w-3.5 h-3.5`}),`Attach files or pictures`]}),(0,B.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`up to `,5,` files,`,` `,mS(_c),` each`]})]}),s.length>0?(0,B.jsx)(`ul`,{className:`flex flex-wrap gap-2`,"data-testid":`bug-report-attachments`,children:s.map(e=>(0,B.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,B.jsx)(`img`,{src:e.preview,alt:``,className:`h-8 w-8 rounded object-cover`,"aria-hidden":!0}):(0,B.jsx)(H.Paperclip,{className:`w-3.5 h-3.5 text-fg-muted`}),(0,B.jsx)(`span`,{className:`max-w-40 truncate`,title:e.name,children:e.name}),(0,B.jsx)(`span`,{className:`text-fg-faint`,children:mS(e.size)}),(0,B.jsx)(lC,{label:`Remove ${e.name}`,onClick:()=>w(e.key),children:(0,B.jsx)(H.X,{className:`w-3.5 h-3.5`})})]},e.key))}):null]}),d?(0,B.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`bug-report-error`,children:d}):null]})})}var B9=`oonacode.stickyNotes.active`;function V9(e){try{e?window.localStorage.setItem(B9,e):window.localStorage.removeItem(B9)}catch{}}function dPe(){try{return window.localStorage.getItem(B9)}catch{return null}}function fPe({open:e,onClose:t}){let{api:n,actions:r}=V(),i=typeof n.listStickyNotes==`function`,[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)({kind:`idle`}),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(!1),S=(0,v.useRef)(new Map),C=(0,v.useRef)(null),w=(0,v.useRef)(Promise.resolve()),T=(0,v.useCallback)(()=>{C.current&&=(clearTimeout(C.current),null);let e=[...S.current.entries()];return S.current.clear(),e.length===0||!n.updateStickyNote?w.current:(f({kind:`saving`}),w.current=w.current.then(async()=>{for(let[t,i]of e)try{await n.updateStickyNote(t,i),f({kind:`saved`,at:new Date().toISOString()})}catch(e){if(e instanceof qg&&e.status===404){o(e=>e?.filter(e=>e.id!==t)??e),r.toast(`info`,`A note was deleted on another device, so its tab was closed.`),f({kind:`idle`});continue}let n=S.current.get(t)??{};S.current.set(t,{...i,...n}),f({kind:`error`,message:Kv(e)})}}),w.current)},[n,r]),E=(0,v.useCallback)((e,t)=>{S.current.set(e,{...S.current.get(e)??{},...t}),f(e=>e.kind===`error`?e:{kind:`idle`}),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>void T(),800)},[T]),D=(0,v.useRef)(T);D.current=T,(0,v.useEffect)(()=>{if(!e)return;let t=!0;if(u(null),f({kind:`idle`}),m(null),y(null),i)return n.listStickyNotes().then(e=>{if(!t)return;o(e.notes);let n=dPe();c(e.notes.some(e=>e.id===n)?n:e.notes[0]?.id??null)}).catch(e=>{t&&u(Kv(e))}),()=>{t=!1,D.current()}},[e,i]);let O=(0,v.useCallback)(()=>{D.current(),t()},[t]),k=e=>{e!==s&&(T(),c(e),V9(e),y(null))},A=async()=>{if(!(!n.createStickyNote||b)){x(!0);try{await T();let e=await n.createStickyNote({});o(t=>[...t??[],e]),c(e.id),V9(e.id)}catch(e){f({kind:`error`,message:Kv(e)})}finally{x(!1)}}},j=async e=>{if(n.deleteStickyNote){S.current.delete(e),y(null);try{await n.deleteStickyNote(e);let t=(a??[]).filter(t=>t.id!==e);if(o(t),s===e){let e=t[0]?.id??null;c(e),V9(e)}}catch(e){f({kind:`error`,message:Kv(e)})}}},ee=(e,t)=>{o(n=>n?.map(n=>n.id===e?{...n,text:t}:n)??n),E(e,{text:t})},M=()=>{let e=p;if(!e)return;m(null);let t=h.trim().slice(0,xc.title)||`Note`;t!==a?.find(t=>t.id===e)?.title&&(o(n=>n?.map(n=>n.id===e?{...n,title:t}:n)??n),E(e,{title:t}))},te=e=>{e.key===`Enter`?(e.preventDefault(),M()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),m(null))},ne=e=>{e.dataTransfer.files.length>0&&(e.preventDefault(),r.toast(`info`,`Sticky notes keep text only — pictures and files are not saved.`))},N=a?.find(e=>e.id===s)??null,P=(a??[]).reduce((e,t)=>e+t.text.length,0),re=(a?.length??0)>=xc.notes;return(0,B.jsx)(gC,{open:e,title:`Sticky notes`,onClose:O,wide:!0,children:(0,B.jsx)(`div`,{className:`flex min-h-[24rem] flex-col gap-2 text-sm`,"data-testid":`sticky-notes-dialog`,children:i?l?(0,B.jsx)(`p`,{className:`text-danger`,"data-testid":`sticky-notes-error`,children:l}):a===null?(0,B.jsxs)(`p`,{className:`flex items-center gap-1.5 text-fg-muted`,children:[(0,B.jsx)(H.Spinner,{className:`w-3.5 h-3.5`}),` Opening your notes…`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{role:`tablist`,"aria-label":`Notes`,className:`flex items-center gap-1 overflow-x-auto border-b border-border pb-1`,children:[a.map(e=>p===e.id?(0,B.jsx)(`input`,{autoFocus:!0,"aria-label":`Note name`,className:z(pC,`h-7 w-40 py-0 text-xs`),value:h,maxLength:xc.title,onChange:e=>g(e.target.value),onBlur:M,onKeyDown:te,"data-testid":`sticky-note-rename`},e.id):(0,B.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===s,title:`Double-click to rename`,onClick:()=>k(e.id),onDoubleClick:()=>{k(e.id),m(e.id),g(e.title)},className:z(`max-w-[12rem] shrink-0 truncate rounded-md px-2.5 py-1 text-xs`,e.id===s?`bg-accent-soft font-medium text-fg`:`text-fg-muted hover:bg-surface-2 hover:text-fg`),"data-testid":`sticky-note-tab`,children:e.title||`Note`},e.id)),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void A(),disabled:b||re,title:re?`${xc.notes} notes is the most there can be`:`New note`,"aria-label":`New note`,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-2 hover:text-fg disabled:opacity-40`,"data-testid":`sticky-note-new`,children:(0,B.jsx)(H.Plus,{className:`w-3.5 h-3.5`})})]}),N?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`textarea`,{"aria-label":`Note: ${N.title}`,className:z(pC,`min-h-[18rem] flex-1 resize-y font-mono text-sm`),value:N.text,maxLength:xc.text,placeholder:`Write anything. It is saved by itself.`,onChange:e=>ee(N.id,e.target.value),onBlur:()=>void T(),onDrop:ne,spellCheck:!0,"data-testid":`sticky-note-text`}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-fg-faint`,children:[(0,B.jsx)(`span`,{"data-testid":`sticky-note-status`,children:d.kind===`saving`?`Saving…`:d.kind===`saved`?`Saved ${jb(d.at)}`:d.kind===`error`?null:`Saved in your vault as you type`}),d.kind===`error`?(0,B.jsxs)(`span`,{className:`text-danger`,"data-testid":`sticky-note-save-error`,children:[`Not saved: `,d.message]}):null,(0,B.jsxs)(`span`,{className:`ml-auto`,children:[N.text.length.toLocaleString(),` /`,` `,xc.text.toLocaleString(),` characters`]}),_===N.id?(0,B.jsxs)(`span`,{className:`flex items-center gap-1`,"data-testid":`sticky-note-confirm`,children:[`Delete “`,N.title,`”?`,(0,B.jsx)(U,{size:`sm`,variant:`danger`,onClick:()=>void j(N.id),"data-testid":`sticky-note-delete-yes`,children:`Delete`}),(0,B.jsx)(U,{size:`sm`,onClick:()=>y(null),children:`Keep`})]}):(0,B.jsxs)(U,{size:`sm`,variant:`ghost`,onClick:()=>N.text.trim()?y(N.id):void j(N.id),"data-testid":`sticky-note-delete`,children:[(0,B.jsx)(H.Trash,{className:`w-3 h-3`}),` Delete note`]})]}),P>xc.totalText*.9?(0,B.jsxs)(`p`,{className:`text-[11px] text-warn`,children:[`Your notes hold `,P.toLocaleString(),` of`,` `,xc.totalText.toLocaleString(),` characters.`]}):null]}):(0,B.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 text-fg-muted`,"data-testid":`sticky-notes-empty`,children:[(0,B.jsx)(H.StickyNote,{className:`w-6 h-6 text-fg-faint`}),(0,B.jsx)(`p`,{children:`No notes yet. They are kept in your vault and follow you to your other PCs.`}),(0,B.jsxs)(U,{variant:`primary`,onClick:()=>void A(),busy:b,children:[(0,B.jsx)(H.Plus,{className:`w-3.5 h-3.5`}),` New note`]})]})]}):(0,B.jsx)(`p`,{className:`text-fg-muted`,"data-testid":`sticky-notes-unsupported`,children:`OonaCode on this PC is too old for sticky notes. Update it, then try again.`})})})}function pPe(e){let t=Date.parse(`${e}T12:00:00`);return Number.isFinite(t)?new Date(t).toLocaleDateString(void 0,{dateStyle:`long`}):e}function mPe({open:e,notes:t,onClose:n}){return(0,B.jsx)(gC,{open:e,title:`What's new in OonaCode`,onClose:n,footer:(0,B.jsx)(U,{variant:`primary`,onClick:n,children:`Got it`}),children:(0,B.jsx)(`div`,{className:`space-y-5 text-sm`,"data-testid":`whats-new`,children:t.map(e=>(0,B.jsxs)(`section`,{"data-version":e.version,children:[(0,B.jsxs)(`div`,{className:`mb-2 flex items-baseline gap-2`,children:[(0,B.jsxs)(`h3`,{className:`text-base font-semibold`,children:[`Version `,e.version]}),(0,B.jsx)(`span`,{className:`text-xs text-fg-faint`,children:pPe(e.date)})]}),e.added.length>0?(0,B.jsx)(`ul`,{className:`space-y-1.5`,children:e.added.map((e,t)=>(0,B.jsxs)(`li`,{className:`flex gap-2`,children:[(0,B.jsx)(H.Plus,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent`}),(0,B.jsx)(`span`,{children:e})]},t))}):null,e.fixed.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`mb-1 mt-3 text-xs font-medium uppercase tracking-wide text-fg-faint`,children:`Fixed`}),(0,B.jsx)(`ul`,{className:`space-y-1.5`,children:e.fixed.map((e,t)=>(0,B.jsxs)(`li`,{className:`flex gap-2`,children:[(0,B.jsx)(H.Check,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-ok`}),(0,B.jsx)(`span`,{children:e})]},t))})]}):null]},`${e.version}:${e.platforms?.join(`,`)??`all`}`))})})}function hPe(){let{state:e,actions:t}=V(),n=e.info?.databaseRepair??null,r=e.info?.databaseDamage??null;return n?(0,B.jsxs)(`div`,{role:`status`,"data-testid":`database-repair-banner`,className:`flex items-start gap-2 bg-warn-soft px-3 py-1.5 text-xs text-warn`,children:[(0,B.jsx)(H.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`flex-1 select-text`,children:n.message}),(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:()=>void t.dismissDatabaseRepair(),children:`Got it`})]}):r?(0,B.jsxs)(`div`,{role:`status`,"data-testid":`database-damage-banner`,className:`flex items-start gap-2 bg-danger-soft px-3 py-1.5 text-xs text-danger`,children:[(0,B.jsx)(H.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,B.jsxs)(`span`,{className:`flex-1`,children:[`The disk returned read errors on this PC’s chat database (`,r.code,`). OonaCode keeps working; restart it when you can, and it checks and repairs the database, keeping the damaged files. Read errors usually mean failing hardware: check the disk and run a memory test.`]})]}):null}function gPe(){let{state:e,actions:t}=V(),n=Gg(e.account);return!n||e.ui.dialog===`account`?null:(0,B.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,B.jsx)(H.Alert,{className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{className:`flex-1`,children:rte(n)}),(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:()=>t.openDialog(`account`),children:`Open Account`})]})}function _Pe({onReconnect:e}){let{state:t}=V(),n=t.connection.status;if(n===`open`||n===`idle`||n===`connecting`)return null;let r=n===`unauthorized`&&!window.oonacode;return(0,B.jsxs)(`div`,{role:`status`,className:z(`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,B.jsx)(H.Alert,{className:`w-3.5 h-3.5`}):(0,B.jsx)(H.Spinner,{className:`w-3.5 h-3.5`}),(0,B.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,B.jsx)(U,{size:`sm`,variant:`danger`,onClick:e,children:`Enter token`}):null]})}function vPe(){let{state:e,actions:t}=V(),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),yPe(r)}}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t])}function yPe(e){let t=()=>{let t=document.querySelectorAll(`[data-editor-group]`)[e]?.querySelector(`[data-testid="composer"] [data-testid="composer-input"]`);t&&HR(t)};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}function bPe(){let{state:e,actions:t}=V(),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 xPe(){let{state:e,actions:t}=V(),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}=yu(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?vu(o,`0`,void 0,m):[])}function SPe({onUnauthorized:e}){let{state:t,actions:n}=V(),r=(0,v.useCallback)(()=>n.openDialog(`none`),[n]),i=xPe();bPe();let a=t.ui.sidebarOpen;return vPe(),(0,B.jsxs)(`div`,{className:`flex h-full flex-col bg-bg text-fg`,children:[(0,B.jsx)(rPe,{}),(0,B.jsx)(_Pe,{onReconnect:e}),(0,B.jsx)(gPe,{}),(0,B.jsx)(hPe,{}),(0,B.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,B.jsx)(tNe,{}),a?(0,B.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 md:hidden`,onClick:()=>n.setSidebar(!1),"aria-hidden":!0}):null,(0,B.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:(0,B.jsx)(xke,{})}),(0,B.jsx)(kMe,{})]}),(0,B.jsx)(Dke,{open:t.ui.dialog===`project`,onClose:r}),(0,B.jsx)(Hke,{open:t.ui.dialog===`projects`,startNew:t.projectsStartNew,selectId:t.projectsSelectId,onClose:r}),(0,B.jsx)(zAe,{open:t.ui.dialog===`assign-project`,onClose:r}),(0,B.jsx)(PNe,{open:t.ui.dialog===`settings`,onClose:r}),(0,B.jsx)(Jne,{open:t.ui.dialog===`account`,onClose:r}),(0,B.jsx)(Eke,{open:t.ui.dialog===`doctor`,onClose:r}),(0,B.jsx)(ere,{open:t.ui.dialog===`session-picker`,onClose:r}),(0,B.jsx)(XNe,{open:t.ui.dialog===`update`,onClose:r}),(0,B.jsx)(uPe,{open:t.ui.dialog===`bug-report`,onClose:r}),(0,B.jsx)(fPe,{open:t.ui.dialog===`sticky-notes`,onClose:r}),(0,B.jsx)(Vke,{open:t.ui.dialog===`claude-login`,onClose:r}),(0,B.jsx)(Tje,{open:t.ui.dialog===`oauth-login`,onClose:r}),(0,B.jsx)(Eje,{open:t.ui.dialog===`manage-models`,onClose:r}),(0,B.jsx)(qje,{open:t.ui.dialog===`import-claude`,autoOffer:t.importOffered,onClose:r}),(0,B.jsx)(Uke,{open:t.ui.dialog===`export-chats`,onClose:r}),(0,B.jsx)(Gke,{open:t.ui.dialog===`workspace-cleanup`,onClose:r}),(0,B.jsx)(nAe,{open:t.ui.dialog===`connect-ai-tool`,onClose:r}),(0,B.jsx)(ofe,{open:t.ui.dialog===`conversations`,selectId:t.conversationsSelectId,onClose:r}),(0,B.jsx)(PAe,{open:t.ui.dialog===`chat-abouts`,onClose:r}),(0,B.jsx)(LAe,{open:t.ui.dialog===`project-manager`,onClose:r}),(0,B.jsx)(EAe,{open:t.ui.dialog===`voice-summary`,onClose:r}),(0,B.jsx)(mPe,{open:t.ui.dialog===`whats-new`,notes:i,onClose:r}),(0,B.jsx)(wje,{open:t.ui.connectProviderId!==null,providerId:t.ui.connectProviderId,onClose:()=>n.openProviderConnect(null)}),(0,B.jsx)(_me,{}),(0,B.jsx)(Lke,{}),(0,B.jsx)(E9,{})]})}function CPe({onUnauthorized:e}){let{state:t}=V(),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&&Gg(t.account)===null?(0,B.jsx)(UNe,{}):(0,B.jsx)(SPe,{onUnauthorized:e}):(0,B.jsx)(HNe,{}):(0,B.jsx)(RNe,{})}function wPe({api:e,socket:t,relay:n,initialSessionId:r,onUnauthorized:i,reportError:a}){return(0,B.jsx)(nC,{api:e,socket:t,relay:n??null,initialSessionId:r??null,onUnauthorized:i,...a?{reportError:a}:{},children:(0,B.jsx)(CPe,{onUnauthorized:i})})}var H9=`oonacode.host.connection`,TPe=`session`;function EPe(e){let t=e.replace(/^#\/?\??/,``),n=new URLSearchParams(t),r=n.get(`token`),i=n.get(`host`)??n.get(`baseUrl`),a=n.get(TPe);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 U9(e,t){let n;try{n=new URL(e)}catch{return!1}return n.protocol!==`http:`&&n.protocol!==`https:`?!1:n.origin===t||n.hostname===`127.0.0.1`||n.hostname===`localhost`||n.hostname===`[::1]`}function DPe(e,t){if(!e)return null;try{let n=e.getItem(H9);if(!n)return null;let r=JSON.parse(n);if(typeof r.baseUrl==`string`&&typeof r.token==`string`&&r.token)return t!==void 0&&!U9(r.baseUrl,t)?null:{baseUrl:Yg(r.baseUrl),token:r.token}}catch{}return null}function W9(e,t){if(e)try{t?e.setItem(H9,JSON.stringify(t)):e.removeItem(H9)}catch{}}async function OPe(e){let t=EPe(e.location.hash);if(t.token){let n={baseUrl:Yg((t.baseUrl!==null&&U9(t.baseUrl,e.location.origin)?t.baseUrl:null)??e.location.origin),token:t.token};W9(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:Yg(n.baseUrl),token:n.token};return W9(e.storage,r),{connection:r,source:`bridge`,sessionId:t.sessionId}}}catch{}let n=DPe(e.storage,e.location.origin);return n?{connection:n,source:`storage`,sessionId:t.sessionId}:{connection:null,source:`none`,sessionId:t.sessionId}}function kPe(e=window){let t=null;try{t=e.sessionStorage}catch{t=null}return OPe({location:e.location,storage:t,replaceUrl:t=>e.history.replaceState(null,``,t),bridge:e.oonacode})}var APe=1;function G9(){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 jPe(e,t){return`${Yg(e).replace(/^http(s?):/i,`ws$1:`)}${b}?token=${encodeURIComponent(t)}`}var MPe=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:Yg(e.baseUrl)},this.clientId=e.clientId??G9()}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!==APe)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=jPe(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}$e(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}${I.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])K9(()=>n(e));for(let t of[...this.anyHandlers])K9(()=>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])K9(()=>n(e,t))}};function K9(e){try{e()}catch(e){console.error(`[HostSocket] handler failed`,e)}}var NPe=/([?&#](?:token|access_token|key|api_key|secret|password)=)[^&#\s"']*/gi,PPe=/\b(Bearer|Basic)\s+[A-Za-z0-9\-._~+/=]{8,}/g;function q9(e){return e.replace(NPe,`$1[redacted]`).replace(PPe,`$1 [redacted]`)}function J9(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function FPe(e){return typeof e==`object`&&!!e&&typeof e.message==`string`}function IPe(e){if(FPe(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:J9(e,512),stack:null}:{message:`Unhandled rejection (${e===null?`null`:Array.isArray(e)?`array`:typeof e})`,stack:null}}function LPe(e){return e?e.split(`
|
|
558
|
+
DEBUG=1`,onChange:e=>E(e.target.value),className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`})})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(fC,{label:`Endpoint URL`,hint:`https://mcp.domain.com/sse`,children:(0,B.jsx)(`input`,{type:`url`,value:D,placeholder:`https://mcp.example.com/sse`,onChange:e=>O(e.target.value),className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`})}),(0,B.jsx)(fC,{label:`Headers`,hint:`One Header: Value per line`,children:(0,B.jsx)(`textarea`,{rows:2,value:k,placeholder:`Authorization: Bearer token123`,onChange:e=>A(e.target.value),className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`})})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:[(0,B.jsx)(`input`,{id:`mcp-default-on`,type:`checkbox`,checked:j,onChange:e=>ee(e.target.checked),className:`h-4 w-4 rounded border-border text-accent focus:ring-accent`}),(0,B.jsx)(`label`,{htmlFor:`mcp-default-on`,className:`text-fg font-medium cursor-pointer`,children:`Enable in new chats by default`}),(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`(Leave unchecked for specific databases or billing services)`})]})]}):(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(H.Search,{className:`pointer-events-none absolute left-3 top-2.5 h-4 w-4 text-fg-muted`}),(0,B.jsx)(`input`,{id:_e,type:`text`,value:i,placeholder:`Search MCP providers (Postgres, GitHub, Supabase, Notion, Sentry...)`,onChange:e=>a(e.target.value),className:z(pC,`pl-9`)})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1 border-b border-border pb-2 text-xs`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s(`all`),className:z(`rounded px-2.5 py-1 font-medium transition-colors`,o===`all`?`bg-accent-soft text-accent`:`text-fg-muted hover:bg-surface-2 hover:text-fg`),children:[`All Providers (`,nd.length,`)`]}),td.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),className:z(`rounded px-2.5 py-1 font-medium transition-colors`,o===e.id?`bg-accent-soft text-accent`:`text-fg-muted hover:bg-surface-2 hover:text-fg`),children:e.label},e.id)),(0,B.jsxs)(`button`,{type:`button`,onClick:fe,className:`ml-auto flex items-center gap-1 rounded border border-dashed border-border px-2.5 py-1 font-medium text-accent hover:bg-surface-2`,children:[(0,B.jsx)(H.Plus,{className:`w-3 h-3`}),(0,B.jsx)(`span`,{children:`Custom Server`})]})]})]}),(0,B.jsx)(`div`,{className:`grid max-h-[28rem] grid-cols-1 gap-2.5 overflow-y-auto sm:grid-cols-2`,children:ge.map(e=>(0,B.jsxs)(`div`,{className:`flex flex-col justify-between rounded-lg border border-border bg-surface p-3 transition-colors hover:border-accent/40`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-1`,children:[(0,B.jsx)(`span`,{className:`font-semibold text-sm text-fg`,children:e.name}),(0,B.jsx)(hC,{tone:`neutral`,children:e.transport})]}),(0,B.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),(0,B.jsxs)(`div`,{className:`mt-3 flex items-center justify-between pt-2 border-t border-border/50`,children:[(0,B.jsx)(`span`,{className:`text-[11px] text-fg-muted capitalize`,children:e.category}),(0,B.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>de(e),children:`Add`})]})]},e.id))})]})})}function hNe(){let{state:e,actions:t}=V(),n=e.mcpServers??[],r=e.mcpTesting??{},i=e.mcpTestResults??{},[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),d=async e=>{await t.updateMcpServer(e.id,{defaultOn:!e.defaultOn})};return(0,B.jsxs)(`div`,{className:`space-y-6 text-xs text-fg`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-border pb-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`MCP Servers`}),(0,B.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:`Configure Model Context Protocol servers to provide databases, cloud APIs, and developer tools to your chats. Each chat can toggle which servers are active.`})]}),(0,B.jsxs)(U,{variant:`primary`,size:`sm`,onClick:()=>o(!0),children:[(0,B.jsx)(H.Plus,{className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{children:`Add MCP Server`})]})]}),n.length===0?(0,B.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border bg-surface-2 p-8 text-center`,children:[(0,B.jsx)(`div`,{className:`mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-accent-soft text-accent`,children:(0,B.jsx)(H.Plug,{className:`h-6 w-6`})}),(0,B.jsx)(`h4`,{className:`mt-3 text-sm font-semibold text-fg`,children:`No MCP Servers Configured`}),(0,B.jsx)(`p`,{className:`mx-auto mt-1 max-w-sm text-xs text-fg-muted`,children:`Connect databases (PostgreSQL, Supabase), developer services (GitHub, Sentry), or productivity tools (Linear, Notion) to your agent.`}),(0,B.jsx)(`div`,{className:`mt-4`,children:(0,B.jsx)(U,{variant:`primary`,size:`sm`,onClick:()=>o(!0),children:`Browse MCP Catalog`})})]}):(0,B.jsx)(`div`,{className:`space-y-3`,children:n.map(e=>{let n=!!r[e.id],a=i[e.id];return(0,B.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-border bg-surface p-3.5 shadow-sm transition-colors hover:border-accent/40`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-semibold text-sm text-fg truncate`,children:e.name}),(0,B.jsx)(hC,{tone:`neutral`,children:e.transport}),e.catalogId&&(0,B.jsx)(hC,{tone:`accent`,children:e.catalogId})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,B.jsx)(`span`,{className:`text-[11px] text-fg-muted animate-pulse`,children:`Testing...`}):a?(0,B.jsx)(`span`,{className:z(`rounded px-2 py-0.5 text-[11px] font-medium`,a.ok?`bg-ok/10 text-ok border border-ok/20`:`bg-danger/10 text-danger border border-danger/20`),title:a.error,children:a.ok?`✓ ${a.toolsCount??0} tools (${a.durationMs}ms)`:`✗ Failed`}):null,(0,B.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>t.testMcpServer(e.id),disabled:n,title:`Test connection to this server`,children:`Test`}),(0,B.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>c(e),title:`Edit server configuration`,children:`Edit`}),(0,B.jsx)(lC,{label:`Delete server`,onClick:()=>u(e),className:`text-fg-muted hover:text-danger`,children:(0,B.jsx)(H.Trash,{className:`w-3.5 h-3.5`})})]})]}),e.description&&(0,B.jsx)(`p`,{className:`text-fg-muted text-xs`,children:e.description}),(0,B.jsx)(`div`,{className:`rounded bg-surface-2 px-2.5 py-1.5 font-mono text-[11px] text-fg-muted overflow-x-auto`,children:e.transport===`stdio`?(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`text-accent`,children:e.command}),` `,(e.args??[]).join(` `)]}):(0,B.jsx)(`span`,{className:`text-accent`,children:e.url})}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between pt-2 border-t border-border/50 text-[11px]`,children:[(0,B.jsx)(_C,{label:`Default ON for new chats`,checked:e.defaultOn,onChange:()=>d(e)}),(0,B.jsxs)(`span`,{className:`text-fg-muted`,children:[`Updated `,new Date(e.updatedAt).toLocaleDateString()]})]})]},e.id)})}),(0,B.jsx)(bC,{open:l!==null,title:`Remove MCP Server`,message:l?`Are you sure you want to remove MCP server "${l.name}"?`:``,confirmLabel:`Remove`,onConfirm:async()=>{l&&(await t.deleteMcpServer(l.id),u(null))},onClose:()=>u(null)}),(a||s!==null)&&(0,B.jsx)(mNe,{open:a||s!==null,editingServer:s,onClose:()=>{o(!1),c(null)}})]})}function h9(e){switch(e){case`win32`:return`Windows`;case`darwin`:return`macOS`;case`linux`:return`Linux`;case`android`:return`Android`;case`ios`:return`iPhone`;case`web`:return`Browser`;case`telegram`:return`Telegram`;default:return e||`Unknown`}}function g9(e){return e instanceof qg&&(e.status===501||e.status===404&&e.message.startsWith(`no route for`))}function _9(e){return e.label||e.hostName}function v9(e,t,n){return n.has(e)?`${e} (#${t.slice(0,8)})`:e}function gNe(){let{state:e,actions:t,api:n}=V(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null);(0,v.useEffect)(()=>{t.refreshHosts()},[t]);let p=e.remote.hosts,m=(0,v.useMemo)(()=>{let e=new Map;for(let t of p)e.set(_9(t),(e.get(_9(t))??0)+1);return new Set([...e].filter(([,e])=>e>1).map(([e])=>e))},[p]);if(!e.account?.loggedIn)return(0,B.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`Sign in to see the devices on your account.`});if(!e.remote.supported)return(0,B.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,B.jsx)(`strong`,{children:e.connection.hostName??`unknown`}),`.`]});let h=!!n.removeHost&&!e.remote.stale,g=async e=>{if(!n.removeHost)return;let r=v9(_9(e),e.hostId,m);u(e.hostId),f(null);try{await n.removeHost(e.hostId),t.toast(`success`,`${r} is off your account's list`),await t.refreshHosts()}catch(e){f(g9(e)?`This PC's OonaCode cannot remove PCs yet — update it.`:`${r} was not removed: ${Kv(e)}`),t.refreshHosts()}finally{u(null)}};return(0,B.jsxs)(`div`,{className:`space-y-6`,children:[(0,B.jsxs)(`section`,{className:`space-y-1.5`,"aria-label":`PCs on your account`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:`PCs`}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`The computers on your account. An offline PC can be removed from this list — it is not signed out, its chats stay on it, and if it comes online again it puts itself back. An online PC can't be removed: it would be back within a minute.`}),d?(0,B.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`devices-host-error`,children:d}):null,e.remote.loading?(0,B.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-fg-muted`,children:[(0,B.jsx)(H.Spinner,{}),` Loading devices…`]}):null,p.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border px-3 py-2`,"data-testid":`device-pc-${e.hostId}`,children:[(0,B.jsx)(H.Monitor,{className:`w-4 h-4 shrink-0 text-fg-faint`}),(0,B.jsx)(`div`,{className:`min-w-0 flex-1`,children:r===e.hostId?(0,B.jsx)(`input`,{className:pC,value:a,autoFocus:!0,"aria-label":`Label for ${e.hostName}`,onChange:e=>o(e.target.value),onKeyDown:n=>{n.key===`Enter`&&a.trim()?(t.renameHost(e.hostId,a.trim()),i(null)):n.key===`Escape`&&i(null)}}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[_9(e),e.isSelf?(0,B.jsx)(hC,{tone:`accent`,children:`this PC`}):null,(0,B.jsx)(hC,{tone:e.online?`ok`:`neutral`,children:e.online?`online`:`offline`}),e.remoteAccessOff?(0,B.jsx)(hC,{tone:`warn`,children:`remote access off`}):null]}),(0,B.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[h9(e.platform),e.appVersion?` · v${e.appVersion}`:``,e.lastSeenAt?` · seen ${Lv(e.lastSeenAt)}`:``,m.has(_9(e))?` · #${e.hostId.slice(0,8)}`:``]})]})}),r===e.hostId?(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:()=>{a.trim()&&t.renameHost(e.hostId,a.trim()),i(null)},children:`Save`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(U,{size:`sm`,onClick:()=>{i(e.hostId),o(_9(e))},children:[(0,B.jsx)(H.Edit,{className:`w-3 h-3`}),` Rename`]}),h&&!e.isSelf&&!e.online?(0,B.jsxs)(U,{size:`sm`,busy:l===e.hostId,title:`Take this offline PC off your account's list`,"aria-label":`Remove ${_9(e)}`,onClick:()=>c(e),children:[(0,B.jsx)(H.Trash,{className:`w-3 h-3`}),` Remove…`]}):null]})]},e.hostId)),!e.remote.loading&&p.length===0?(0,B.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`No devices reported yet.`}):null,(0,B.jsx)(`p`,{className:`text-[11px] text-fg-faint`,children:`To take this PC off your account, uninstall OonaCode here or log out in the Account window.`})]}),(0,B.jsx)(_Ne,{}),(0,B.jsx)(bC,{open:s!==null,title:s?`Remove ${v9(_9(s),s.hostId,m)}?`:``,message:s?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`remove-pc-message`,children:[(0,B.jsxs)(`p`,{children:[_9(s),` is taken off your account's list of PCs. Its chats, files and code stay on that PC — none of them are on our server.`]}),(0,B.jsx)(`p`,{children:`It stays signed in: if it comes online again, it puts itself back on the list by itself. To sign it out for good, revoke it under Signed-in devices.`})]}):``,confirmLabel:`Remove`,onConfirm:()=>{s&&g(s)},onClose:()=>c(null)})]})}function _Ne(){let{actions:e,api:t}=V(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!t.listAccountDevices),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(!1),y=(0,v.useCallback)(async()=>{if(t.listAccountDevices)try{let e=await t.listAccountDevices();r(e.devices),a(e.thisDeviceId),s(null)}catch(e){g9(e)?l(!0):s(Kv(e))}},[t]);(0,v.useEffect)(()=>{y()},[y]);let{active:b,revoked:x}=(0,v.useMemo)(()=>{let e=n??[],t=(e,t)=>(t.lastSeenAt??``).localeCompare(e.lastSeenAt??``);return{active:e.filter(e=>!e.revoked).sort((e,n)=>Number(n.id===i)-Number(e.id===i)||t(e,n)),revoked:e.filter(e=>e.revoked).sort(t)}},[n,i]),S=async n=>{if(t.revokeAccountDevice){p(n.id),h(null);try{await t.revokeAccountDevice(n.id),e.toast(`success`,`${n.name} is signed out of your account`),await y(),e.refreshHosts()}catch(e){h(`${n.name} was not revoked: ${Kv(e)}`)}finally{p(null)}}};if(c)return(0,B.jsxs)(`section`,{className:`space-y-1.5`,"aria-label":`Signed-in devices`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:`Signed-in devices`}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`This PC's OonaCode cannot list your sign-ins yet — update it, or revoke a device on the website or in the phone app.`})]});let C=e=>{let n=e.id===i;return(0,B.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border px-3 py-2${e.revoked?` opacity-70`:``}`,"data-testid":`device-signin-${e.id}`,children:[(0,B.jsx)(H.Shield,{className:`w-4 h-4 shrink-0 text-fg-faint`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,B.jsx)(`span`,{className:`truncate`,children:e.name}),n?(0,B.jsx)(hC,{tone:`accent`,children:`this PC`}):null,e.revoked?(0,B.jsx)(hC,{tone:`danger`,children:`revoked`}):null,e.trustedUnlock&&!e.revoked?(0,B.jsx)(hC,{tone:`neutral`,children:`stays unlocked`}):null]}),(0,B.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[h9(e.platform),e.lastSeenAt?` · seen ${Lv(e.lastSeenAt)}`:``,e.lastCountry?` · ${e.lastCountry}`:``]})]}),!n&&!e.revoked&&t.revokeAccountDevice?(0,B.jsxs)(U,{size:`sm`,busy:f===e.id,"aria-label":`Revoke ${e.name}`,title:`Sign this device out of your account for good`,onClick:()=>d(e),children:[(0,B.jsx)(H.X,{className:`w-3 h-3`}),` Revoke…`]}):null]},e.id)};return(0,B.jsxs)(`section`,{className:`space-y-1.5`,"aria-label":`Signed-in devices`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:`Signed-in devices`}),(0,B.jsx)(`button`,{type:`button`,className:`ml-auto text-[11px] text-fg-muted underline underline-offset-2 hover:text-fg`,onClick:()=>void y(),children:`Refresh`})]}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Every app, browser and phone signed in to your account. Revoke signs one out for good — do it for a device you lost or no longer use. It has to sign in again with your password.`}),o?(0,B.jsxs)(`div`,{className:`text-xs text-danger`,role:`alert`,children:[`Could not list your devices: `,o]}):null,m?(0,B.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`devices-revoke-error`,children:m}):null,n===null&&!o?(0,B.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-fg-muted`,children:[(0,B.jsx)(H.Spinner,{}),` Loading sign-ins…`]}):null,b.map(C),x.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,className:`text-[11px] text-fg-muted underline underline-offset-2 hover:text-fg`,onClick:()=>_(e=>!e),children:[g?`Hide`:`Show`,` `,x.length,` revoked`]}),g?x.map(C):null]}):null,(0,B.jsx)(`p`,{className:`text-[11px] text-fg-faint`,children:`This PC can't revoke itself — log out in the Account window instead.`}),(0,B.jsx)(bC,{open:u!==null,title:u?`Revoke ${u.name}?`:``,message:u?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`revoke-device-message`,children:[(0,B.jsxs)(`p`,{children:[u.name,` is signed out of your account at once: its sessions end, it can no longer sync your keys, and a “keep me unlocked” on it stops working.`]}),(0,B.jsx)(`p`,{children:`To use it again, it has to sign in with your password. Its chats stay on that device.`})]}):``,confirmLabel:`Revoke`,onConfirm:()=>{u&&S(u)},onClose:()=>d(null)})]})}var y9=[{id:`general`,label:`General`,icon:H.Settings},{id:`safeguards`,label:`Safeguards`,icon:H.Shield},{id:`theme`,label:`Theme`,icon:H.Palette},{id:`advanced`,label:`Advanced`,icon:H.Sliders},{id:`skills`,label:`Skills`,icon:H.Tool},{id:`mcp`,label:`MCP Servers`,icon:H.Plug},{id:`providers`,label:`Providers`,icon:H.Globe},{id:`devices`,label:`Devices`,icon:H.Monitor},{id:`host`,label:`This PC`,icon:H.Stethoscope},{id:`developer`,label:`Developer`,icon:H.Bug}];function b9(){let e=typeof window<`u`?window.oonacode:void 0;return e?.getDebugging&&e.setDebugging?e:null}function x9({className:e}){let{state:t,actions:n}=V(),r=t.settings?.theme??`system`;return(0,B.jsxs)(`div`,{className:z(`flex items-center justify-between gap-3 py-3`,e),"data-testid":`settings-colour-scheme`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Colour scheme`,(0,B.jsx)(uC,{label:`Colour scheme`,details:(0,B.jsx)(dC,{items:f9.colourScheme.details})})]}),(0,B.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-faint`,children:f9.colourScheme.hint})]}),(0,B.jsx)(vC,{label:`Colour scheme`,value:r,options:[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}],onChange:e=>void n.saveSettings({theme:e})})]})}function vNe(){let{state:e,actions:t}=V(),n=e.prefs;return(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(_C,{label:`Autosave files`,hint:f9.autosaveFiles.hint,details:f9.autosaveFiles.details,checked:n.autosaveFiles,onChange:e=>void t.savePrefs({autosaveFiles:e}),testId:`settings-autosave-files`}),(0,B.jsx)(_C,{label:`Auto-accept permissions`,hint:f9.autoAccept.hint,details:f9.autoAccept.details,checked:n.autoAcceptPermissions,onChange:e=>void t.savePrefs({autoAcceptPermissions:e}),testId:`settings-auto-accept`}),(0,B.jsx)(_C,{label:`Show reasoning in the timeline`,hint:f9.reasoning.hint,details:f9.reasoning.details,checked:n.showReasoningSummaries,onChange:e=>void t.savePrefs({showReasoningSummaries:e})}),(0,B.jsx)(x9,{className:`border-t border-border`}),(0,B.jsxs)(`div`,{className:`border-t border-border pt-2`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,B.jsx)(H.Bell,{className:`w-3 h-3`}),` Notifications`,(0,B.jsx)(uC,{label:`Notifications`,details:(0,B.jsx)(dC,{items:f9.notifications.details})})]}),(0,B.jsx)(`p`,{className:`text-xs text-fg-faint`,children:f9.notifications.hint}),(0,B.jsx)(_C,{label:`Agent finished or needs attention`,hint:f9.notifyFinished.hint,details:f9.notifyFinished.details,checked:n.notifications.agentFinished,onChange:e=>void t.savePrefs({notifications:{...n.notifications,agentFinished:e}})}),(0,B.jsx)(_C,{label:`Permission or question waiting for you`,hint:f9.notifyWaiting.hint,details:f9.notifyWaiting.details,checked:n.notifications.permissionRequired,onChange:e=>void t.savePrefs({notifications:{...n.notifications,permissionRequired:e}})}),(0,B.jsx)(_C,{label:`Error occurred`,hint:f9.notifyError.hint,details:f9.notifyError.details,checked:n.notifications.errorOccurred,onChange:e=>void t.savePrefs({notifications:{...n.notifications,errorOccurred:e}})})]}),e.prefsBackend===`local`?(0,B.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 S9(e){let t=e.replace(/-/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function yNe(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 Vl){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 Vl){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}var C9=[{surface:`chat`,label:`Chat`,hint:`The conversation and the message box.`},{surface:`sidebar`,label:`Sidebar`,hint:`The chat list and the side panels.`}];function bNe(){let{state:e,actions:t}=V(),n=(0,v.useRef)(e.prefs.fonts);n.current=e.prefs.fonts;let r=(e,r)=>void t.savePrefs({fonts:{...n.current,[e]:{...n.current[e],...r}}}),i=C9.some(({surface:t})=>e.prefs.fonts[t].family!==null||e.prefs.fonts[t].size!==null);return(0,B.jsxs)(`div`,{className:`space-y-1 border-t border-border pt-3`,"data-testid":`settings-fonts`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:`Fonts`}),(0,B.jsxs)(`div`,{className:`mt-0.5 text-xs text-fg-faint`,children:[`The typeface and text size of chats and of the sidebar, each on its own. Default keeps the app's own font (`,14,`px). Code always stays monospace.`]})]}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,disabled:!i,onClick:()=>void t.savePrefs({fonts:{chat:{family:null,size:null},sidebar:{family:null,size:null}}}),"data-testid":`fonts-reset`,children:`Reset fonts`})]}),C9.map(({surface:t,label:n,hint:i})=>(0,B.jsx)(xNe,{surface:t,label:n,hint:i,value:e.prefs.fonts[t],onSave:e=>r(t,e)},t))]})}function xNe({surface:e,label:t,hint:n,value:r,onSave:i}){let a=oy.findIndex(e=>e.family===r.family),o=r.family===null?`default`:a>=0?String(a):`custom`,[s,c]=(0,v.useState)(!1),l=s?`custom`:o,[u,d]=(0,v.useState)(o===`custom`?r.family??``:``),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(r.size===null?``:String(r.size));(0,v.useEffect)(()=>h(r.size===null?``:String(r.size)),[r.size]),(0,v.useEffect)(()=>{o===`custom`&&d(r.family??``)},[o,r.family]);let g=()=>{if(u.trim()===``){p(null),c(!1),r.family!==null&&i({family:null});return}let e=Gl(u);if(e===null){p(`Font names separated by commas — letters, digits, spaces and quotes only.`);return}p(null),c(!1),e!==r.family&&i({family:e})},_=(e,t)=>{if(e.trim()===``){t&&r.size!==null&&i({size:null});return}let n=Number(e);if(!Number.isFinite(n)){t&&h(r.size===null?``:String(r.size));return}if(!(n>=10&&n<=28&&Number.isInteger(n))&&!t)return;let a=Wl(n);t&&h(a===null?``:String(a)),a!==r.size&&i({size:a})};return(0,B.jsxs)(`div`,{className:`border-t border-border py-2`,"data-testid":`font-row-${e}`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`div`,{className:`w-20 shrink-0`,children:(0,B.jsx)(`div`,{className:`text-sm text-fg`,children:t})}),(0,B.jsxs)(`select`,{className:z(pC,`w-auto min-w-0 flex-1 py-1`),value:l,onChange:e=>{let t=e.target.value;if(p(null),t===`custom`){c(!0);return}c(!1);let n=t==="default"?null:oy[Number(t)]?.family??null;n!==r.family&&i({family:n})},"aria-label":`${t} font`,"data-testid":`font-family-${e}`,children:[(0,B.jsx)(`option`,{value:`default`,children:`Default`}),oy.map((e,t)=>(0,B.jsx)(`option`,{value:String(t),children:e.label},e.label)),(0,B.jsx)(`option`,{value:`custom`,children:`Custom…`})]}),(0,B.jsx)(`input`,{className:z(pC,`w-24 py-1`),type:`number`,min:10,max:28,step:1,placeholder:`14 px`,value:m,onChange:e=>{h(e.target.value),e.nativeEvent.inputType||_(e.target.value,!1)},onBlur:()=>_(m,!0),onKeyDown:e=>{e.key===`Enter`&&_(m,!0)},"aria-label":`${t} text size in pixels (10–28)`,"data-testid":`font-size-${e}`}),r.family!==null||r.size!==null?(0,B.jsx)(lC,{label:`Reset the ${t.toLowerCase()} font to the default`,className:`p-0.5`,onClick:()=>{c(!1),p(null),d(``),i({family:null,size:null})},"data-testid":`font-reset-${e}`,children:(0,B.jsx)(H.Refresh,{className:`w-3 h-3`})}):null]}),(0,B.jsx)(`div`,{className:`mt-0.5 pl-[5.5rem] text-xs text-fg-faint`,children:n}),l===`custom`?(0,B.jsxs)(`div`,{className:`mt-1.5 pl-[5.5rem]`,children:[(0,B.jsx)(`input`,{className:z(pC,`py-1`),value:u,placeholder:`e.g. 'Fira Sans', Arial, sans-serif`,maxLength:160,onChange:e=>d(e.target.value),onBlur:g,onKeyDown:e=>{e.key===`Enter`&&g()},"aria-label":`${t} custom font`,"aria-invalid":f!==null,"data-testid":`font-custom-${e}`}),f?(0,B.jsx)(`div`,{className:`mt-1 text-xs text-danger`,role:`alert`,children:f}):null]}):null]})}function SNe(){return(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(x9,{className:`pt-0`}),(0,B.jsx)(bNe,{}),(0,B.jsx)(CNe,{})]})}function CNe(){let{state:e,actions:t}=V(),n=e.prefs,r=Ote(),[i,a]=(0,v.useState)(r),o=(0,v.useMemo)(()=>yNe(i),[i]),[s,c]=(0,v.useState)({}),l=(0,v.useRef)(s);l.current=s;let u=(0,v.useRef)(n.themeColors);u.current=n.themeColors;let d=(0,v.useRef)(null),f=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)};(0,v.useEffect)(()=>f,[]);let p=e=>{f();let n=l.current;Object.keys(n).length!==0&&(c({}),t.savePrefs({themeColors:{...u.current,[e]:{...u.current[e],...n}}}))},m=(e,t)=>{c(n=>({...n,[e]:t})),l.current={...l.current,[e]:t},f(),d.current=window.setTimeout(()=>p(i),300)},h=(0,v.useRef)(r);(0,v.useEffect)(()=>{h.current!==r&&(h.current=r,p(i),a(r))},[r]);let g={...u.current[i],...s},_=Object.keys(g).length,y=e=>{f(),c({});let n={...g};delete n[e],t.savePrefs({themeColors:{...u.current,[i]:n}})};return(0,B.jsxs)(`div`,{className:`space-y-3 border-t border-border pt-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:`Theme colours`}),(0,B.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. To switch between light and dark, use Colour scheme above.`})]}),(0,B.jsx)(vC,{label:`Edit colour scheme`,value:i,options:[{value:`light`,label:`Light colours`},{value:`dark`,label:`Dark colours`}],onChange:e=>{p(i),a(e)}})]}),(0,B.jsx)(`div`,{className:`grid grid-cols-1 gap-x-4 sm:grid-cols-2`,children:Vl.map(e=>{let t=g[e]!==void 0,n=g[e]??o[e]??`#808080`;return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border py-1.5`,"data-testid":`theme-color-row-${i}-${e}`,children:[(0,B.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=>m(e,t.target.value),"aria-label":`${S9(e)} colour (${i} scheme)`,"data-testid":`theme-color-${i}-${e}`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:S9(e)}),(0,B.jsx)(`span`,{className:`w-16 shrink-0 text-right font-mono text-[10px] text-fg-faint`,children:t?g[e]:`default`}),t?(0,B.jsx)(lC,{label:`Reset ${S9(e)} to the theme colour`,className:`p-0.5`,"data-testid":`theme-color-clear-${i}-${e}`,onClick:()=>y(e),children:(0,B.jsx)(H.Refresh,{className:`w-3 h-3`})}):null]},e)})}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border pt-2`,children:[(0,B.jsx)(`span`,{className:`text-xs text-fg-faint`,"data-testid":`theme-colors-count`,children:_===0?`No custom colours in the ${i} scheme.`:`${_} custom colour${_===1?``:`s`} in the ${i} scheme.`}),(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>{f(),c({}),t.savePrefs({themeColors:{...u.current,[i]:{}}})},disabled:_===0,"data-testid":`theme-reset-${i}`,children:`Reset all`})]})]})}function wNe(){let{state:e,actions:t}=V(),n=e.prefs,[r,i]=(0,v.useState)(String(n.transcriptWindowSize));return(0,v.useEffect)(()=>i(String(n.transcriptWindowSize)),[n.transcriptWindowSize]),(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(fC,{label:`Transcript window size`,hint:`${f9.transcriptWindow.hint} Scrolling to the top brings back 100 more. 100–${Fl}, default 500.`,details:f9.transcriptWindow.details,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`input`,{className:z(pC,`w-32`),type:`number`,min:100,max:Fl,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,B.jsx)(`span`,{className:`text-xs text-fg-faint`,children:`messages and tool cards`})]})}),(0,B.jsx)(w9,{label:`Hidden chats kept in memory`,unit:`tabs`,hint:f9.keptTranscripts.hint,details:f9.keptTranscripts.details,value:n.keptTranscripts,min:0,max:20,defaultValue:3,onSave:e=>void t.savePrefs({keptTranscripts:e}),testId:`settings-kept-transcripts`})]})}function TNe({settings:e}){let{actions:t}=V(),n=Zee,r=Xee;return(0,B.jsxs)(`div`,{className:`space-y-3 border-t border-border pt-3`,"data-testid":`settings-memory`,children:[(0,B.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Memory`}),e.engineIdleMinutes===void 0?null:(0,B.jsx)(w9,{label:`Keep a quiet chat’s engine for`,unit:`minutes`,hint:f9.engineIdleMinutes.hint,details:f9.engineIdleMinutes.details,value:e.engineIdleMinutes,min:n.engineIdleMinutes.min,max:n.engineIdleMinutes.max,defaultValue:r.engineIdleMinutes,onSave:e=>void t.saveSettings({engineIdleMinutes:e}),testId:`settings-engine-idle-minutes`}),e.maxIdleEngines===void 0?null:(0,B.jsx)(w9,{label:`Engines kept with no turn`,unit:`engines`,hint:f9.maxIdleEngines.hint,details:f9.maxIdleEngines.details,value:e.maxIdleEngines,min:n.maxIdleEngines.min,max:n.maxIdleEngines.max,defaultValue:r.maxIdleEngines,onSave:e=>void t.saveSettings({maxIdleEngines:e}),testId:`settings-max-idle-engines`}),e.browserIdleMinutes===void 0?null:(0,B.jsx)(w9,{label:`Close an unused Oonak Browser after`,unit:`minutes`,hint:f9.browserIdleMinutes.hint,details:f9.browserIdleMinutes.details,value:e.browserIdleMinutes,min:n.browserIdleMinutes.min,max:n.browserIdleMinutes.max,defaultValue:r.browserIdleMinutes,onSave:e=>void t.saveSettings({browserIdleMinutes:e}),testId:`settings-browser-idle-minutes`})]})}function ENe(){let{state:e,actions:t}=V(),n=(0,v.useMemo)(()=>Xs(e.providers),[e.providers]);return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[n.length===0?(0,B.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=Ys(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,B.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border px-3 py-2`,"data-testid":`provider-${r.id}`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,B.jsx)(`span`,{className:`text-sm font-medium`,children:r.displayName}),i?(0,B.jsx)(hC,{tone:`accent`,children:`active`}):null,r.route===`direct`?(0,B.jsx)(hC,{tone:`ok`,children:`direct`}):null,s.length>0?s.map(e=>(0,B.jsxs)(hC,{tone:`ok`,children:[e===`subscription`?`subscription`:`API key`,` connected`]},e)):o?(0,B.jsx)(hC,{tone:`ok`,children:`connected`}):(0,B.jsx)(hC,{tone:`warn`,children:`not connected`})]}),(0,B.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,B.jsx)(cNe,{providerId:r.id,configured:o}):(0,B.jsxs)(U,{size:`sm`,variant:o?`secondary`:`primary`,onClick:()=>t.openProviderConnect(r.id),children:[(0,B.jsx)(H.Plus,{className:`w-3 h-3`}),` `,o?`Manage…`:`Connect`]})]},r.id)}),(0,B.jsx)(`div`,{className:`pt-3`,children:(0,B.jsx)(k5,{})})]})}function DNe(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=Lv(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`}, ${HF(t.bytesFreed)}, ${r}.`}function ONe({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(mu,Math.max(1,t));i(String(a)),a!==e&&n(a)};return(0,B.jsxs)(fC,{label:`Replace pictures older than`,hint:f9.imageRetention.hint,details:f9.imageRetention.details,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`input`,{className:z(pC,`w-24`),type:`number`,min:0,max:mu,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,B.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`days`,e===365?` (a year)`:``]})]}),(0,B.jsx)(`span`,{className:`text-xs text-fg-muted`,"data-testid":`settings-image-retention-status`,children:DNe(e,t)})]})}function kNe(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 w9({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=kNe(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,B.jsxs)(fC,{label:e,hint:`${n} ${h(a)}–${h(o)}, default ${h(s)}.`,details:r,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`input`,{className:z(pC,`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,B.jsx)(`span`,{className:`text-xs text-fg-faint`,children:t})]}),f?(0,B.jsx)(`span`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`${l}-problem`,children:f}):null]})}function ANe({settings:e}){let{actions:t}=V(),n=e.providerUsagePing!==!1;return(0,B.jsxs)(`div`,{className:`border-t border-border pt-1`,"data-testid":`settings-provider-usage`,children:[(0,B.jsx)(_C,{label:`Check my plan’s usage when I look at it`,hint:f9.providerUsagePing.hint,details:f9.providerUsagePing.details,checked:n,onChange:e=>void t.saveSettings({providerUsagePing:e}),testId:`settings-provider-usage-ping`}),n&&e.providerUsageStaleMinutes!==void 0?(0,B.jsx)(`div`,{className:`pt-2`,children:(0,B.jsx)(w9,{label:`Check again when the figure is older than`,unit:`minutes`,hint:f9.providerUsageStale.hint,details:f9.providerUsageStale.details,value:e.providerUsageStaleMinutes,min:0,max:Dc,defaultValue:10,onSave:e=>void t.saveSettings({providerUsageStaleMinutes:e}),testId:`settings-provider-usage-stale`})}):null]})}function jNe({settings:e}){let{actions:t}=V(),n=hf,r=mf;return(0,B.jsxs)(`div`,{className:`border-t border-border pt-3`,"data-testid":`settings-chat-abouts`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Chat abouts`}),(0,B.jsx)(U,{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,B.jsx)(_C,{label:`Write an about for every chat`,hint:f9.chatAbout.hint,details:f9.chatAbout.details,checked:e.chatAboutEnabled,onChange:e=>void t.saveSettings({chatAboutEnabled:e}),testId:`settings-chat-about-enabled`}),(0,B.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[e.chatAboutIntervalMinutes===void 0?null:(0,B.jsx)(w9,{label:`Minutes between background abouts`,unit:`minutes`,hint:f9.chatAboutInterval.hint,details:f9.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,B.jsx)(w9,{label:`Longest about`,unit:`words`,hint:f9.chatAboutMaxWords.hint,details:f9.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,B.jsx)(w9,{label:`How much of a chat is read`,unit:`characters`,hint:f9.chatAboutInputChars.hint,details:f9.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 MNe(){let{state:e,actions:t}=V(),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,B.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,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(fC,{label:`Default working directory`,hint:f9.defaultCwd.hint,details:f9.defaultCwd.details,children:(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`input`,{className:z(pC,`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,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>void s(),children:`Choose…`}):null,r?(0,B.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>{i(``),o(``)},children:`Clear`}):null]})}),(0,B.jsxs)(`div`,{className:`border-t border-border pt-1`,children:[(0,B.jsx)(_C,{label:`Remote access`,hint:f9.remoteAccess.hint,details:f9.remoteAccess.details,checked:n.relayEnabled??!0,onChange:e=>void t.saveSettings({relayEnabled:e}),testId:`settings-relay`}),n.telegramAllowed===void 0?null:(0,B.jsx)(_C,{label:`Allow Telegram to reach this PC`,hint:f9.telegram.hint,details:f9.telegram.details,checked:n.telegramAllowed,onChange:e=>void t.saveSettings({telegramAllowed:e}),testId:`settings-telegram`}),n.debugNotes===void 0?null:(0,B.jsx)(_C,{label:`Debug mode: technical notes in chats`,hint:f9.debugNotes.hint,details:f9.debugNotes.details,checked:n.debugNotes,onChange:e=>void t.saveSettings({debugNotes:e}),testId:`settings-debug-notes`}),(0,B.jsx)(_C,{label:`Keep the vault unlocked when the app closes`,hint:f9.keepUnlocked.hint,details:f9.keepUnlocked.details,checked:n.keepUnlockedOnExit??!1,onChange:e=>void t.saveSettings({keepUnlockedOnExit:e}),testId:`settings-keep-unlocked-exit`})]}),n.imageRetentionDays===void 0?null:(0,B.jsx)(`div`,{className:`border-t border-border pt-3`,children:(0,B.jsx)(ONe,{days:n.imageRetentionDays,lastRun:n.imageRetentionLastRun??null,onSave:e=>void t.saveSettings({imageRetentionDays:e})})}),n.promptSuggestions===void 0?null:(0,B.jsx)(`div`,{className:`border-t border-border pt-1`,"data-testid":`settings-prompt-suggestions`,children:(0,B.jsx)(_C,{label:`Auto-suggest my next message`,hint:f9.promptSuggestions.hint,details:f9.promptSuggestions.details,checked:n.promptSuggestions,onChange:e=>void t.saveSettings({promptSuggestions:e}),testId:`settings-prompt-suggestions-toggle`})}),n.providerUsagePing===void 0?null:(0,B.jsx)(ANe,{settings:n}),n.chatAboutEnabled!==void 0||n.chatAboutIntervalMinutes!==void 0||n.chatAboutMaxWords!==void 0||n.chatAboutInputChars!==void 0?(0,B.jsx)(jNe,{settings:n}):null,n.engineIdleMinutes!==void 0||n.maxIdleEngines!==void 0||n.browserIdleMinutes!==void 0?(0,B.jsx)(TNe,{settings:n}):null,(0,B.jsxs)(`div`,{className:`space-y-2 border-t border-border pt-3 text-xs`,children:[(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Server`,(0,B.jsx)(uC,{label:`Server`,details:(0,B.jsx)(dC,{items:f9.server.details})})]}),(0,B.jsx)(`span`,{className:`block text-fg-faint`,children:f9.server.hint})]}),(0,B.jsx)(`span`,{className:`break-all font-mono text-fg-muted`,"data-testid":`settings-server`,children:a})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Diagnostics`,(0,B.jsx)(uC,{label:`Diagnostics`,details:(0,B.jsx)(dC,{items:f9.diagnostics.details})})]}),(0,B.jsx)(`span`,{className:`block text-fg-faint`,children:f9.diagnostics.hint})]})]})]})}function T9(e){return e instanceof Error?e.message:String(e)}function NNe(){let e=b9(),[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,r=!1,a=e.onDebuggingChanged?.(e=>{r=!0,t&&n(e)});return e.getDebugging().then(e=>{!t||r||(n(e),o(String(e.saved.port)))},e=>{t&&i(T9(e))}),()=>{t=!1,a?.()}},[e]),!e)return(0,B.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,B.jsx)(`div`,{className:`py-6 text-sm text-danger`,role:`alert`,children:r}):(0,B.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(T9(e))}})},d=()=>{let e=a.trim(),n=/^\d+$/.test(e)?Number(e):NaN,r=qc(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(T9(e))}},p=iNe(t),m=r!==null&&/^(The port|Ports?) /.test(r);return(0,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`settings-developer`,children:[(0,B.jsx)(_C,{label:`Allow debugging`,hint:f9.allowDebugging.hint,details:f9.allowDebugging.details,checked:t.saved.enabled,onChange:e=>u({enabled:e}),testId:`settings-allow-debugging`}),(0,B.jsx)(fC,{label:`Debugging port`,hint:`${f9.debugPort.hint} ${Hc}–${Uc}, default ${Vc}.`,details:f9.debugPort.details,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`input`,{className:z(pC,`max-w-28`,m&&`border-danger`),type:`number`,min:Hc,max:Uc,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,B.jsx)(`span`,{className:`whitespace-nowrap text-xs text-fg-faint`,children:`on 127.0.0.1`})]})}),(0,B.jsx)(_C,{label:`Also debug the main process`,hint:f9.debugMainProcess.hint,details:f9.debugMainProcess.details,checked:t.saved.inspectMain,disabled:!t.saved.enabled,onChange:e=>u({inspectMain:e}),testId:`settings-debug-main`}),r?(0,B.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`settings-debugging-problem`,children:r}):null,(0,B.jsxs)(`div`,{className:`rounded-md border border-border px-3 py-2 text-xs`,"data-testid":`settings-debugging-status`,children:[(0,B.jsx)(`div`,{className:`text-fg-muted`,children:rNe(t.running)}),p?(0,B.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-warn`,"data-testid":`settings-debugging-restart-note`,children:aNe(t)}),(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:()=>void f(),disabled:s!==null||!e.relaunchApp,"data-testid":`settings-debugging-restart`,children:`Restart now`})]}):null,s?(0,B.jsx)(`div`,{className:`mt-1 text-fg-faint`,children:s}):null]})]})}function PNe({open:e,onClose:t}){let{state:n,actions:r}=V(),[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=b9()!==null,c=s?y9:y9.filter(e=>e.id!==`developer`);return(0,B.jsx)(gC,{open:e,title:`Settings`,onClose:t,wide:!0,footer:(0,B.jsx)(U,{onClick:t,children:`Done`}),children:(0,B.jsxs)(`div`,{className:`flex min-h-[22rem] gap-4`,children:[(0,B.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,B.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),"aria-current":i===e.id?`true`:void 0,className:z(`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,B.jsx)(t,{className:`w-3.5 h-3.5`}),e.label]},e.id)}),(0,B.jsxs)(`div`,{className:`pt-3 text-[11px] text-fg-faint`,children:[`OonaCode Desktop v`,cS(typeof window<`u`&&window.oonacode?.appVersion||n.connection.appVersion||`0.0.0`,sS({bridge:typeof window<`u`?window.oonacode:void 0,info:n.info}))]})]}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i===`general`?(0,B.jsx)(vNe,{}):null,i===`safeguards`?(0,B.jsx)(dNe,{}):null,i===`theme`?(0,B.jsx)(SNe,{}):null,i===`advanced`?(0,B.jsx)(wNe,{}):null,i===`skills`?(0,B.jsx)(fNe,{}):null,i===`mcp`?(0,B.jsx)(hNe,{}):null,i===`providers`?(0,B.jsx)(ENe,{}):null,i===`devices`?(0,B.jsx)(gNe,{}):null,i===`host`?(0,B.jsx)(MNe,{}):null,i===`developer`&&s?(0,B.jsx)(NNe,{}):null]})]})})}function FNe({toast:e}){let{actions:t}=V();(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,B.jsxs)(`div`,{role:e.kind===`error`?`alert`:`status`,className:z(`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,B.jsx)(H.Alert,{className:`mt-0.5 w-4 h-4`}):e.kind===`success`?(0,B.jsx)(H.Check,{className:`mt-0.5 w-4 h-4`}):null,(0,B.jsx)(`div`,{className:`pre-wrap min-w-0 flex-1`,children:e.text}),e.action?(0,B.jsx)(`button`,{type:`button`,className:`shrink-0 font-medium underline underline-offset-2 hover:opacity-80`,"data-testid":`toast-action`,onClick:()=>{e.action?.run(),t.dismissToast(e.id)},children:e.action.label}):null,(0,B.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,className:`opacity-60 hover:opacity-100`,onClick:()=>t.dismissToast(e.id),children:(0,B.jsx)(H.X,{className:`w-3.5 h-3.5`})})]})}function E9(){let{state:e}=V();return e.toasts.length===0?null:(0,B.jsx)(`div`,{className:`pointer-events-none fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.toasts.map(e=>(0,B.jsx)(FNe,{toast:e},e.id))})}var INe=2e3;function D9(e){if(!O9(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 O9(e){if(typeof e!=`string`||e===``)return!1;try{let{protocol:t}=new URL(e);return t===`http:`||t===`https:`}catch{return!1}}function LNe(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 k9({children:e,testId:t}){let{state:n}=V(),r=n.connection.hostName??n.info?.hostName??null;return(0,B.jsxs)(`div`,{className:`flex h-full flex-col bg-bg text-fg`,"data-testid":t,children:[(0,B.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-surface px-3`,children:[(0,B.jsx)(`span`,{className:`font-semibold tracking-tight`,children:`OonaCode`}),r?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-fg-faint`,children:`/`}),(0,B.jsx)(`span`,{className:`truncate text-sm text-fg-muted`,"data-testid":`frame-host-name`,children:r})]}):null]}),(0,B.jsx)(`main`,{className:`flex min-h-0 flex-1 items-start justify-center overflow-y-auto p-6`,children:(0,B.jsx)(`div`,{className:`w-full max-w-md py-6`,children:e})}),(0,B.jsx)(E9,{})]})}function RNe(){return(0,B.jsx)(k9,{testId:`account-loading`,children:(0,B.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,B.jsx)(H.Spinner,{className:`w-4 h-4`}),(0,B.jsx)(`span`,{children:`Checking your account…`})]})})}function zNe({link:e}){let{actions:t}=V(),[n,r]=(0,v.useState)(!1),i=e.verificationUrl??``,a=e.verificationUrlComplete??i,o=O9(a),s=t.refreshAccountLink;return(0,v.useEffect)(()=>{let e=setInterval(()=>void s(),INe);return()=>clearInterval(e)},[s]),(0,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`link-waiting`,children:[(0,B.jsxs)(`ol`,{className:`space-y-2 text-sm`,children:[(0,B.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`1. Open`}),o?(0,B.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(),D9(a))},children:i}):(0,B.jsx)(`span`,{className:`break-all font-medium`,"data-testid":`link-url`,children:i})]}),(0,B.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`2. Enter`}),(0,B.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,B.jsxs)(`p`,{className:`flex items-center gap-2 text-xs text-fg-muted`,role:`status`,children:[(0,B.jsx)(H.Spinner,{className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{children:`Waiting for approval in your browser…`})]}),(0,B.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,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o?(0,B.jsxs)(U,{size:`sm`,onClick:()=>D9(a),"data-testid":`link-reopen`,children:[(0,B.jsx)(H.LogIn,{className:`w-3.5 h-3.5`}),` Open the browser again`]}):null,(0,B.jsx)(U,{size:`sm`,variant:`ghost`,busy:n,"data-testid":`link-cancel`,onClick:()=>{r(!0),t.cancelAccountLink().finally(()=>r(!1))},children:`Cancel`})]})]})}function BNe(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 VNe(){let{state:e,actions:t}=V(),n=e.accountLink,r=BNe(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`&&D9(e.verificationUrlComplete??e.verificationUrl??``)}finally{a(!1)}},[t]);if(n?.status===`waiting`)return(0,B.jsx)(zNe,{link:n});let s=n&&(n.status===`denied`||n.status===`expired`);return(0,B.jsxs)(`div`,{className:`space-y-2`,children:[s?(0,B.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:LNe(n)}):null,(0,B.jsxs)(U,{variant:`primary`,busy:i,onClick:()=>void o(),"data-testid":`link-start`,className:`w-full justify-center`,children:[(0,B.jsx)(H.LogIn,{className:`w-3.5 h-3.5`}),s?`Try again in your browser`:`Sign in with your browser`]}),(0,B.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 HNe(){let{state:e}=V(),[t,n]=(0,v.useState)(!1),r=t||e.emailVerification!==null;return(0,B.jsx)(k9,{testId:`sign-in-view`,children:(0,B.jsxs)(`div`,{className:`space-y-5`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Sign in to use OonaCode`}),(0,B.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,B.jsx)(VNe,{}),(0,B.jsx)(`div`,{className:z(`space-y-3 border-t border-border pt-4`,r?``:`text-center`),children:r?(0,B.jsx)(rw,{}):(0,B.jsx)(U,{size:`sm`,variant:`ghost`,"data-testid":`use-password`,onClick:()=>n(!0),children:`Use an email and password instead`})})]})})}function UNe(){let{state:e,actions:t}=V(),[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,B.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,B.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,B.jsx)(H.Lock,{className:`mx-auto h-10 w-10 text-fg-faint`}),(0,B.jsx)(`h1`,{className:`text-lg font-semibold`,children:`This device is locked`}),(0,B.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,B.jsx)(`input`,{ref:u,type:`password`,className:pC,value:n,onChange:e=>r(e.target.value),onMouseDown:e=>e.stopPropagation(),placeholder:`Account password`,autoFocus:!0,"data-testid":`locked-password`}),(0,B.jsxs)(`label`,{className:`flex items-start justify-center gap-2 text-sm text-fg-muted`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:i,onChange:e=>a(e.target.checked),"data-testid":`locked-keep-unlocked`}),(0,B.jsx)(`span`,{children:`Keep me unlocked on this PC`})]}),c?(0,B.jsx)(`div`,{className:`text-sm text-danger`,"data-testid":`locked-error`,children:c}):null,(0,B.jsx)(U,{type:`submit`,variant:`primary`,busy:o,disabled:!n,children:`Unlock`}),(0,B.jsxs)(`div`,{className:`text-xs text-fg-faint`,children:[`Signed in as `,e.account?.email??`this account`,` ·`,` `,(0,B.jsx)(`button`,{type:`button`,className:`underline hover:text-fg`,onClick:()=>void t.logout(),children:`Sign out`})]})]}),(0,B.jsx)(E9,{})]})}function WNe(){return _S(typeof window<`u`?window.oonacode:void 0)}function GNe(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 A9=2*Math.PI*10;function KNe(){return typeof window<`u`&&window.oonacode!==void 0}function qNe(){let{state:e,actions:t}=V(),n=e.update,r=e.updateInstall,i=e.prefs.dismissedUpdateVersion,a=n.version!==``&&(e.updateDismissed===n.version||i===n.version);if(!KNe())return null;let o=fS({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 OonaCode`:o===`ready`?`Restart to finish updating`:o===`downloading`?`Downloading update (${u}%)`:o===`available`?`Update available (${l})`:`Check for updates`,f=s?e.terminalUpdate.message||`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,B.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:z(`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,B.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,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,fill:`none`,strokeWidth:`2`,className:`stroke-border`}),(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:A9,strokeDashoffset:A9*(1-Math.max(0,Math.min(100,u))/100),className:`stroke-accent`})]}):null,c&&o!==`downloading`&&o!==`ready`?(0,B.jsx)(`span`,{"data-testid":`update-badge-checking`,className:`inline-flex`,children:(0,B.jsx)(H.Spinner,{className:`w-3.5 h-3.5`})}):o===`ready`?(0,B.jsx)(`span`,{"data-testid":`update-badge-ready`,className:`inline-flex`,children:(0,B.jsx)(H.Refresh,{className:`w-3.5 h-3.5`})}):o===`downloading`?(0,B.jsx)(`span`,{"data-testid":`update-badge-downloading`,className:`text-[9px] font-semibold`,children:u}):(0,B.jsx)(`span`,{"data-testid":o===`available`?`update-badge-available`:`update-badge-idle`,className:`inline-flex`,children:(0,B.jsx)(H.Download,{className:`w-3.5 h-3.5`})}),o===`available`?(0,B.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-accent`,"aria-hidden":!0}):null]})}function JNe(){let{state:e,actions:t}=V(),n=e.updateInstall,r=Math.round(Math.max(0,Math.min(100,n.percent))),i=hS(n.bytesPerSecond);if(n.phase===`error`)return(0,B.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,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(H.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:`The update could not be downloaded.`}),(0,B.jsx)(`div`,{className:`mt-0.5 pre-wrap break-words`,children:n.error})]})]}),(0,B.jsx)(`div`,{className:`mt-2`,children:(0,B.jsxs)(U,{size:`sm`,onClick:()=>void t.installUpdate(),"data-testid":`update-retry`,children:[(0,B.jsx)(H.Refresh,{className:`w-3.5 h-3.5`}),` Try again`]})})]});let a=n.phase===`installing`;return(0,B.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`update-progress`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,B.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,B.jsxs)(`span`,{className:`text-fg-muted`,children:[r,`%`]})]}),n.notice?(0,B.jsx)(`div`,{className:`pre-wrap text-xs text-warn`,"data-testid":`update-notice`,role:`status`,children:n.notice}):null,(0,B.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-2`,children:(0,B.jsx)(`div`,{className:z(`h-full rounded-full bg-accent`,a&&`animate-pulse`),style:{width:`${a?100:r}%`},"data-testid":`update-progress-bar`})}),a?(0,B.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,B.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-fg-faint`,children:[(0,B.jsxs)(`span`,{children:[mS(n.transferred),n.total>0?` of ${mS(n.total)}`:``]}),i?(0,B.jsx)(`span`,{children:i}):null]})]})}function YNe(){let{state:e,actions:t}=V(),n=e.terminalUpdate;return n.running?(0,B.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,B.jsx)(H.Spinner,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`font-medium text-fg`,children:n.message?`Updating OonaCode...`:`Updating the oona CLI and host service...`}),(0,B.jsx)(`div`,{className:`mt-0.5 text-fg-faint`,"data-testid":`terminal-update-message`,children:n.message||`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,B.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,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(H.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:`The CLI and host service could not be updated.`}),(0,B.jsx)(`div`,{className:`mt-0.5 pre-wrap break-words`,children:n.message})]})]}),(0,B.jsx)(`div`,{className:`mt-2`,children:(0,B.jsxs)(U,{size:`sm`,onClick:()=>void t.installUpdate(),"data-testid":`terminal-update-retry`,children:[(0,B.jsx)(H.Refresh,{className:`w-3.5 h-3.5`}),` Try again`]})})]}):null}function XNe({open:e,onClose:t}){let{state:n,actions:r}=V(),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=WNe(),l=vS(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,B.jsx)(gC,{open:e,title:`Update OonaCode`,onClose:t,footer:p?(0,B.jsx)(U,{onClick:t,"data-testid":`update-running-close`,children:`Close`}):d?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{onClick:t,children:`Later`}),(0,B.jsxs)(U,{variant:`primary`,onClick:()=>void r.installUpdate(),"data-testid":`update-restart`,children:[(0,B.jsx)(H.Refresh,{className:`w-4 h-4`}),`Restart and install`]})]}):f?(0,B.jsx)(U,{onClick:t,children:`Close`}):l.upToDate?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(U,{onClick:()=>void r.checkUpdates(!0),busy:m,disabled:m,"data-testid":`update-check-again`,children:[(0,B.jsx)(H.Refresh,{className:`w-4 h-4`}),`Check again`]}),(0,B.jsx)(U,{variant:`primary`,onClick:t,children:`Close`})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{onClick:()=>r.dismissUpdate(),children:`Skip this version`}),(0,B.jsx)(U,{onClick:t,children:`Later`}),(0,B.jsxs)(U,{variant:`primary`,busy:m,disabled:m,onClick:()=>void r.installUpdate(),children:[(0,B.jsx)(H.Download,{className:`w-4 h-4`}),l.label]})]}),children:(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[u?(0,B.jsxs)(`span`,{className:`font-medium`,children:[`Release `,u]}):null,i.channel?(0,B.jsx)(hC,{children:i.channel}):null,n.updateChecking?(0,B.jsx)(`span`,{className:`text-xs text-fg-faint`,"data-testid":`update-rechecking`,children:`checking for a newer one…`}):null,i.publishedAt?(0,B.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`published `,new Date(i.publishedAt).toLocaleDateString()]}):null]}),f?(0,B.jsx)(JNe,{}):null,(0,B.jsx)(YNe,{}),i.components.length>0?(0,B.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:i.components.map(e=>(0,B.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2`,children:[(0,B.jsx)(H.Download,{className:`mt-0.5 w-3.5 h-3.5 shrink-0 text-accent`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,B.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[e.current,` → `,(0,B.jsx)(`span`,{className:`font-medium text-fg`,children:e.latest})]}),(0,B.jsx)(`div`,{className:`text-xs text-fg-faint`,"data-testid":`update-how-${e.component}`,children:yS(e.component,c)}),e.notes?(0,B.jsx)(`div`,{className:`mt-0.5 pre-wrap text-xs text-fg-faint`,children:e.notes}):null]})]},e.component))}):null,i.notes?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Release notes`}),(0,B.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,B.jsx)(`p`,{className:`text-xs text-fg-faint`,"data-testid":`update-plan-note`,children:GNe(l)})]})})}var j9=`oona-global-search`,M9=`oona-global-search-current`,ZNe=2e3,QNe=400;function N9(){let e=globalThis.CSS,t=globalThis.Highlight;return!e?.highlights||typeof t!=`function`?null:{registry:e.highlights,Highlight:t}}function P9(e,t){let n=N9();if(n===null)return;if(e.length===0){F9();return}let r=t>=0&&t<e.length?e[t]:null,i=[];for(let n=0;n<e.length;n++)n!==t&&i.push(e[n]);n.registry.set(j9,new n.Highlight(...i)),r?n.registry.set(M9,new n.Highlight(r)):n.registry.delete(M9)}function F9(){let e=N9();e!==null&&(e.registry.delete(j9),e.registry.delete(M9))}function I9(e,t,n=ZNe){let r=Ue(t);if(r===``||n<=0)return[];let i=e instanceof Document?e:e.ownerDocument??(typeof document<`u`?document:null);if(!i)return[];let a=Ge(r),o=[],s=e instanceof Document?e.body??e:e,c=new Map,l=e=>{if(e===null)return!0;let t=c.get(e);if(t!==void 0)return t;let n=!e.hasAttribute(`hidden`)&&!e.hasAttribute(`data-global-search-ignore`);if(n&&typeof window<`u`&&typeof window.getComputedStyle==`function`)try{let t=window.getComputedStyle(e);(t.display===`none`||t.visibility===`hidden`)&&(n=!1)}catch{}return n&&=l(e.parentElement),c.set(e,n),n},u=i.createTreeWalker(s,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;if(!t)return NodeFilter.FILTER_REJECT;let n=t.tagName;return n===`SCRIPT`||n===`STYLE`||n===`NOSCRIPT`||n===`TEMPLATE`||!l(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});for(let e=u.nextNode();e!==null;e=u.nextNode()){let t=e.data;if(!(!t||t.trim()===``)){a.lastIndex=0;for(let r of t.matchAll(a)){if(r[0].length===0)continue;let t=i.createRange();if(t.setStart(e,r.index??0),t.setEnd(e,(r.index??0)+r[0].length),o.push(t),o.length>=n)return o}}}return o}function L9(e){let t=e.startContainer instanceof Element?e.startContainer:e.startContainer.parentElement;if(!t)return;let n=t;for(;n&&n!==document.body;)n instanceof HTMLDetailsElement&&!n.open&&(n.open=!0),n=n.parentElement;typeof t.scrollIntoView==`function`&&t.scrollIntoView({behavior:`smooth`,block:`center`,inline:`nearest`});let r=t.parentElement;for(;r&&r!==document.body;){if(r instanceof HTMLElement&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth)){let e=window.getComputedStyle(r);if(e.overflowY===`auto`||e.overflowY===`scroll`){let e=r.getBoundingClientRect(),n=t.getBoundingClientRect();(n.top<e.top||n.bottom>e.bottom)&&(r.scrollTop+=n.top-e.top-(e.height-n.height)/2)}}r=r.parentElement}}function R9(e){if(typeof document>`u`||(document.querySelectorAll(`.oona-global-search-current`).forEach(e=>{e.classList.remove(`oona-global-search-current`)}),!e))return;let t=e.startContainer instanceof Element?e.startContainer:e.startContainer.parentElement;t&&t.classList.add(`oona-global-search-current`)}function $Ne(e){return!(e.target.nodeType===1?e.target:e.target.parentElement)?.closest(`[data-global-search-ignore]`)}function ePe(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)([]),[i,a]=(0,v.useState)(-1),o=(0,v.useRef)(null),s=(0,v.useCallback)(()=>{t(``),r([]),a(-1),F9(),R9(null)},[]),c=(0,v.useCallback)(e=>{let t=Ue(e);if(t===``){r([]),a(-1),F9(),R9(null);return}if(typeof document>`u`)return;let n=I9(document,t);r(n);let i=n.length>0?0:-1;a(i),P9(n,i),i>=0&&n[i]?(R9(n[i]),L9(n[i])):R9(null)},[]),l=e=>{t(e),c(e)},u=(0,v.useCallback)(t=>{if(n.length===0)return;let o=n;if(o.some(e=>!e.startContainer.isConnected)&&typeof document<`u`&&(o=I9(document,e),r(o)),o.length===0){a(-1),F9(),R9(null);return}let s=Ye(i,t,o.length);a(s),P9(o,s);let c=o[s];c&&(R9(c),L9(c))},[i,n,e]),d=e=>{e.key===`Enter`?(e.preventDefault(),u(e.shiftKey?-1:1)):e.key===`ArrowDown`?(e.preventDefault(),u(1)):e.key===`ArrowUp`?(e.preventDefault(),u(-1)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),s(),o.current?.blur())};(0,v.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{if(!(!(e.ctrlKey||e.metaKey)||e.altKey)&&(e.code===`KeyF`||e.key===`f`||e.key===`F`)){if(e.shiftKey){e.preventDefault(),o.current?.focus(),o.current?.select();return}setTimeout(()=>{e.defaultPrevented||(o.current?.focus(),o.current?.select())},0)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,v.useEffect)(()=>{if(!e.trim()||typeof document>`u`)return;let t=null,n=new MutationObserver(n=>{!n.some($Ne)||document.hidden||(t||=setTimeout(()=>{if(t=null,e.trim()){let t=I9(document,e);r(t);let n=t.length===0?-1:i>=0&&i<t.length?i:0;a(n),P9(t,n),n>=0&&t[n]?R9(t[n]):R9(null)}},QNe))});return n.observe(document.body,{childList:!0,subtree:!0,characterData:!0}),()=>{n.disconnect(),t&&clearTimeout(t)}},[e,i]);let f=e.trim()!==``,p=n.length,m=typeof navigator<`u`&&/Mac|iPhone|iPad|iPod/.test(navigator.platform)?`Find in page (⌘F)`:`Find in page (Ctrl+F)`;return(0,B.jsxs)(`div`,{"data-testid":`global-search`,"data-global-search-ignore":`true`,role:`search`,className:z(`relative inline-flex h-7 items-center rounded-full border border-border bg-surface px-2 text-xs transition-all`,`focus-within:border-accent focus-within:ring-1 focus-within:ring-accent/20`,f?`w-56 sm:w-64 md:w-72`:`w-32 sm:w-40 md:w-48`),title:m,children:[(0,B.jsx)(H.Search,{className:`w-3.5 h-3.5 shrink-0 text-fg-muted mr-1.5`}),(0,B.jsx)(`input`,{ref:o,type:`text`,value:e,onChange:e=>l(e.target.value),onKeyDown:d,placeholder:`Find in page...`,"aria-label":`Find in page`,spellCheck:!1,className:`h-full min-w-0 flex-1 bg-transparent py-0 text-xs text-fg placeholder:text-fg-muted focus:outline-none`,"data-testid":`global-search-input`}),f&&(0,B.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0 ml-1`,children:[(0,B.jsx)(`span`,{className:z(`tabular-nums text-[11px] px-1 select-none`,p===0?`text-warn font-medium`:`text-fg-muted`),"data-testid":`global-search-count`,children:Xe(i,p)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>u(-1),disabled:p===0,title:`Previous match (Shift+Enter or ↑)`,"aria-label":`Previous match`,"data-testid":`global-search-prev`,className:`flex h-5 w-5 items-center justify-center rounded text-fg-muted hover:text-fg hover:bg-surface-2 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-fg-muted`,children:(0,B.jsx)(H.ArrowDown,{className:`w-3 h-3 rotate-180`})}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>u(1),disabled:p===0,title:`Next match (Enter or ↓)`,"aria-label":`Next match`,"data-testid":`global-search-next`,className:`flex h-5 w-5 items-center justify-center rounded text-fg-muted hover:text-fg hover:bg-surface-2 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-fg-muted`,children:(0,B.jsx)(H.ArrowDown,{className:`w-3 h-3`})}),(0,B.jsx)(`button`,{type:`button`,onClick:s,title:`Clear search (Esc)`,"aria-label":`Clear search`,"data-testid":`global-search-clear`,className:`flex h-5 w-5 items-center justify-center rounded text-fg-muted hover:text-fg hover:bg-surface-2`,children:(0,B.jsx)(H.X,{className:`w-3 h-3`})})]})]})}function tPe(){let{state:e,actions:t,api:n}=V(),[r,i]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(e.connection.status!==`open`)return;let t=!1,r=n.listStickyNotes;if(r)return r().then(e=>{t||i(e.notes.length)}).catch(()=>void 0),()=>{t=!0}},[n,e.connection.status,e.ui.dialog]),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>t.openDialog(`sticky-notes`),title:r===null?`Sticky notes`:`Sticky notes, ${r} tab${r===1?``:`s`}`,"aria-label":`Sticky notes`,"data-testid":`sticky-notes-button`,className:`relative 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,B.jsx)(H.StickyNote,{className:`w-3.5 h-3.5`}),r!==null&&r>0&&(0,B.jsx)(`span`,{"data-testid":`sticky-notes-count`,className:`absolute -right-1 -top-1 min-w-4 rounded-full bg-accent px-1 text-[10px] font-semibold leading-4 text-white`,children:r})]})}function nPe(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 rPe(){let{state:e,actions:t}=V(),n=nPe(e.connection.status),r=e.account?.loggedIn===!0,i=e.prefs.rightPanelSections.includes(`media`),a=gx(),o=e.prefs.leftPanelSection===`files`&&(a?e.ui.sidebarOpen:e.prefs.leftPanelOpen),s=o,c=e.prefs.rightPanelSections.includes(`sessionInfo`);return(0,B.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-surface px-2 sm:px-3`,children:[(0,B.jsx)(lC,{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,B.jsx)(H.PanelLeft,{})}),(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-semibold tracking-tight`,children:`OonaCode`}),(0,B.jsx)(`span`,{className:`hidden text-fg-faint sm:inline`,children:`/`}),(0,B.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,B.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,B.jsx)(`span`,{className:z(`inline-block h-2 w-2 rounded-full`,n.cls),"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:n.label})]})]}),(0,B.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,B.jsx)(aPe,{}),(0,B.jsx)(iPe,{}),(0,B.jsx)(ePe,{}),(0,B.jsx)(tPe,{}),(0,B.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,B.jsx)(H.Bug,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(qNe,{}),e.hostUpdatedTo?(0,B.jsxs)(U,{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,B.jsxs)(U,{size:`sm`,variant:`primary`,onClick:()=>t.openDialog(`account`),"data-testid":`sign-in`,children:[(0,B.jsx)(H.LogIn,{className:`w-3.5 h-3.5`}),` Sign in`]}),(0,B.jsx)(lC,{label:s?`Hide files`:`Show files`,onClick:()=>{o?a?t.setSidebar(!1):t.showLeftSection(`sessions`):t.showLeftSection(`files`)},className:z(`md:hidden`,s?`bg-surface-2 text-fg`:void 0),"aria-pressed":s,"data-testid":`toggle-explorer`,children:(0,B.jsx)(H.Folder,{})}),(0,B.jsx)(lC,{label:i?`Hide media in this chat`:`Media in this chat`,onClick:()=>t.setRightSection(`media`,!i),className:i?`bg-surface-2 text-fg`:void 0,"aria-pressed":i,disabled:!e.currentSessionId,"data-testid":`toggle-media-panel`,children:(0,B.jsx)(H.Gallery,{})}),(0,B.jsx)(lC,{label:c?`Hide session info`:`Show session info`,onClick:()=>t.setRightSection(`sessionInfo`,!c),className:z(`lg:hidden`,c?`bg-surface-2 text-fg`:void 0),"data-testid":`toggle-session-panel`,children:(0,B.jsx)(H.Panel,{})}),(0,B.jsx)(lC,{label:`Doctor`,onClick:()=>t.openDialog(`doctor`),children:(0,B.jsx)(H.Stethoscope,{})}),r?(0,B.jsx)(oPe,{}):null,(0,B.jsx)(lC,{label:`Account`,onClick:()=>t.openDialog(`account`),children:(0,B.jsxs)(`span`,{className:`relative`,children:[(0,B.jsx)(H.User,{}),r?(0,B.jsx)(`span`,{className:z(`absolute -right-0.5 -top-0.5 h-1.5 w-1.5 rounded-full`,e.account?.vaultUnlocked?`bg-ok`:`bg-warn`)}):null]})}),(0,B.jsx)(lC,{label:`Settings`,onClick:()=>t.openDialog(`settings`),children:(0,B.jsx)(H.Settings,{})})]})]})}function iPe(){let{state:e,actions:t}=V(),n=(e.mcpServers??[]).filter(e=>e.enabled!==!1).length;return(0,B.jsxs)(`button`,{type:`button`,onClick:()=>t.openSettings(`mcp`),title:n===0?`No MCP servers configured. Click to open MCP Settings.`:`${n} MCP server${n===1?``:`s`} configured. Click to open MCP Settings.`,"aria-label":`MCP Servers`,"data-testid":`mcp-topbar-badge`,className:z(`inline-flex h-7 items-center gap-1 rounded-full border border-border px-2 text-xs transition-transform hover:scale-105`,n>0?`bg-surface-2 text-fg hover:border-accent hover:text-accent`:`bg-surface text-fg-muted hover:text-fg`),children:[(0,B.jsx)(H.Plug,{className:z(`w-3.5 h-3.5`,n>0?`text-accent`:`text-fg-muted`)}),(0,B.jsx)(`span`,{className:`font-medium text-[11px]`,children:n})]})}function aPe(){let{actions:e}=V(),[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,r=!1,i=e.onDebuggingChanged?.(e=>{r=!0,t&&n(e.running)});return e.getDebugging().then(e=>{t&&!r&&n(e.running)},()=>{}),()=>{t=!1,i?.()}},[]),t&&Xc(t)){let n=oNe(t);return(0,B.jsxs)(`button`,{type:`button`,onClick:()=>e.openSettings(`developer`),title:n,"aria-label":n,"data-testid":`debugging-restart-badge`,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full border border-warn px-2.5 text-[11px] font-semibold text-warn hover:bg-warn-soft`,children:[(0,B.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warn`,"aria-hidden":!0}),`Debugging: restart to close`]})}if(!t||!Jc(t))return null;let r=sNe(t);return(0,B.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,B.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-white`,"aria-hidden":!0}),`Debugging on`]})}function oPe(){let{state:e}=V(),[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?Px(i):null,s=Lx(i),c=Rx;return(0,B.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,B.jsx)(lC,{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,B.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(H.Coins,{}),a===null?null:(0,B.jsx)(`span`,{className:z(`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,B.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,B.jsx)(`div`,{className:`text-fg-muted`,children:`Balance is unavailable — the gateway can't be reached.`}):(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`Plan`}),(0,B.jsxs)(`span`,{className:`font-medium`,children:[i.planName,i.status===`none`?` (lapsed)`:``]})]}),(0,B.jsx)(`div`,{className:`h-px bg-border`}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`Credits`}),(0,B.jsx)(`span`,{className:`font-semibold tabular-nums`,children:c(o.balance)})]}),s?(0,B.jsx)(`div`,{className:z(`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,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`Plan credits`}),(0,B.jsx)(`span`,{className:`tabular-nums`,children:c(o.plan??0)})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-fg-muted`,children:`Top-up credits`}),(0,B.jsx)(`span`,{className:`tabular-nums`,children:c(o.topup??0)})]})]}):null,(0,B.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 — credits you buy never expire; the sign-up gift ends after its welcome period.`,` `,`Free models never draw on this balance.`]})]})}):null]})}function sPe(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 cPe(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 ${mS(e.size)}; a file may be at most ${mS(_c)}.`};if(i+e.size>12582912)return{accepted:n,refused:`All files together may be at most ${mS(vc)}.`};n.push(e),r+=1,i+=e.size}return{accepted:n,refused:null}}function lPe(e){return e instanceof qg?e.code===`account_required`||e.status===401?`Sign in to OonaCode first — a report is filed under your account so we can answer it.`:Zg(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 z9=0;function uPe({open:e,onClose:t}){let{state:n,actions:r,api:i}=V(),[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}=cPe(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 sPe(t);if(!n)continue;let r=t.type||`application/octet-stream`;z9+=1,e.push({key:`f${z9}`,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,gc),...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(lPe(e))}finally{u(!1)}},E=gc-a.length;return(0,B.jsx)(gC,{open:e,title:`Bug Report`,onClose:t,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{onClick:t,disabled:l,children:`Cancel`}),(0,B.jsxs)(U,{variant:`primary`,busy:l,disabled:!a.trim()||p,onClick:()=>void T(),"data-testid":`bug-report-send`,children:[(0,B.jsx)(H.Bug,{className:`w-4 h-4`}),`Send report`]})]}),children:(0,B.jsxs)(`div`,{className:`space-y-3 text-sm`,"data-testid":`bug-report-dialog`,children:[(0,B.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,B.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,B.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,B.jsx)(`span`,{className:`font-medium text-fg`,children:`What happened?`}),(0,B.jsx)(`textarea`,{name:`message`,className:z(pC,`min-h-32 resize-y`),value:a,maxLength:gc,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,B.jsx)(`span`,{className:`text-xs text-fg-faint`,children:E<500?`${E} characters left`:``})]}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`input`,{ref:h,type:`file`,multiple:!0,className:`hidden`,onChange:C,"data-testid":`bug-report-files`}),(0,B.jsxs)(U,{size:`sm`,onClick:()=>h.current?.click(),disabled:l||p||s.length>=5,children:[(0,B.jsx)(H.Paperclip,{className:`w-3.5 h-3.5`}),`Attach files or pictures`]}),(0,B.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`up to `,5,` files,`,` `,mS(_c),` each`]})]}),s.length>0?(0,B.jsx)(`ul`,{className:`flex flex-wrap gap-2`,"data-testid":`bug-report-attachments`,children:s.map(e=>(0,B.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,B.jsx)(`img`,{src:e.preview,alt:``,className:`h-8 w-8 rounded object-cover`,"aria-hidden":!0}):(0,B.jsx)(H.Paperclip,{className:`w-3.5 h-3.5 text-fg-muted`}),(0,B.jsx)(`span`,{className:`max-w-40 truncate`,title:e.name,children:e.name}),(0,B.jsx)(`span`,{className:`text-fg-faint`,children:mS(e.size)}),(0,B.jsx)(lC,{label:`Remove ${e.name}`,onClick:()=>w(e.key),children:(0,B.jsx)(H.X,{className:`w-3.5 h-3.5`})})]},e.key))}):null]}),d?(0,B.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`bug-report-error`,children:d}):null]})})}var B9=`oonacode.stickyNotes.active`;function V9(e){try{e?window.localStorage.setItem(B9,e):window.localStorage.removeItem(B9)}catch{}}function dPe(){try{return window.localStorage.getItem(B9)}catch{return null}}function fPe({open:e,onClose:t}){let{api:n,actions:r}=V(),i=typeof n.listStickyNotes==`function`,[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)({kind:`idle`}),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(!1),S=(0,v.useRef)(new Map),C=(0,v.useRef)(null),w=(0,v.useRef)(Promise.resolve()),T=(0,v.useCallback)(()=>{C.current&&=(clearTimeout(C.current),null);let e=[...S.current.entries()];return S.current.clear(),e.length===0||!n.updateStickyNote?w.current:(f({kind:`saving`}),w.current=w.current.then(async()=>{for(let[t,i]of e)try{await n.updateStickyNote(t,i),f({kind:`saved`,at:new Date().toISOString()})}catch(e){if(e instanceof qg&&e.status===404){o(e=>e?.filter(e=>e.id!==t)??e),r.toast(`info`,`A note was deleted on another device, so its tab was closed.`),f({kind:`idle`});continue}let n=S.current.get(t)??{};S.current.set(t,{...i,...n}),f({kind:`error`,message:Kv(e)})}}),w.current)},[n,r]),E=(0,v.useCallback)((e,t)=>{S.current.set(e,{...S.current.get(e)??{},...t}),f(e=>e.kind===`error`?e:{kind:`idle`}),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>void T(),800)},[T]),D=(0,v.useRef)(T);D.current=T,(0,v.useEffect)(()=>{if(!e)return;let t=!0;if(u(null),f({kind:`idle`}),m(null),y(null),i)return n.listStickyNotes().then(e=>{if(!t)return;o(e.notes);let n=dPe();c(e.notes.some(e=>e.id===n)?n:e.notes[0]?.id??null)}).catch(e=>{t&&u(Kv(e))}),()=>{t=!1,D.current()}},[e,i]);let O=(0,v.useCallback)(()=>{D.current(),t()},[t]),k=e=>{e!==s&&(T(),c(e),V9(e),y(null))},A=async()=>{if(!(!n.createStickyNote||b)){x(!0);try{await T();let e=await n.createStickyNote({});o(t=>[...t??[],e]),c(e.id),V9(e.id)}catch(e){f({kind:`error`,message:Kv(e)})}finally{x(!1)}}},j=async e=>{if(n.deleteStickyNote){S.current.delete(e),y(null);try{await n.deleteStickyNote(e);let t=(a??[]).filter(t=>t.id!==e);if(o(t),s===e){let e=t[0]?.id??null;c(e),V9(e)}}catch(e){f({kind:`error`,message:Kv(e)})}}},ee=(e,t)=>{o(n=>n?.map(n=>n.id===e?{...n,text:t}:n)??n),E(e,{text:t})},M=()=>{let e=p;if(!e)return;m(null);let t=h.trim().slice(0,xc.title)||`Note`;t!==a?.find(t=>t.id===e)?.title&&(o(n=>n?.map(n=>n.id===e?{...n,title:t}:n)??n),E(e,{title:t}))},te=e=>{e.key===`Enter`?(e.preventDefault(),M()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),m(null))},ne=e=>{e.dataTransfer.files.length>0&&(e.preventDefault(),r.toast(`info`,`Sticky notes keep text only — pictures and files are not saved.`))},N=a?.find(e=>e.id===s)??null,P=(a??[]).reduce((e,t)=>e+t.text.length,0),re=(a?.length??0)>=xc.notes;return(0,B.jsx)(gC,{open:e,title:`Sticky notes`,onClose:O,wide:!0,children:(0,B.jsx)(`div`,{className:`flex min-h-[24rem] flex-col gap-2 text-sm`,"data-testid":`sticky-notes-dialog`,children:i?l?(0,B.jsx)(`p`,{className:`text-danger`,"data-testid":`sticky-notes-error`,children:l}):a===null?(0,B.jsxs)(`p`,{className:`flex items-center gap-1.5 text-fg-muted`,children:[(0,B.jsx)(H.Spinner,{className:`w-3.5 h-3.5`}),` Opening your notes…`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{role:`tablist`,"aria-label":`Notes`,className:`flex items-center gap-1 overflow-x-auto border-b border-border pb-1`,children:[a.map(e=>p===e.id?(0,B.jsx)(`input`,{autoFocus:!0,"aria-label":`Note name`,className:z(pC,`h-7 w-40 py-0 text-xs`),value:h,maxLength:xc.title,onChange:e=>g(e.target.value),onBlur:M,onKeyDown:te,"data-testid":`sticky-note-rename`},e.id):(0,B.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===s,title:`Double-click to rename`,onClick:()=>k(e.id),onDoubleClick:()=>{k(e.id),m(e.id),g(e.title)},className:z(`max-w-[12rem] shrink-0 truncate rounded-md px-2.5 py-1 text-xs`,e.id===s?`bg-accent-soft font-medium text-fg`:`text-fg-muted hover:bg-surface-2 hover:text-fg`),"data-testid":`sticky-note-tab`,children:e.title||`Note`},e.id)),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void A(),disabled:b||re,title:re?`${xc.notes} notes is the most there can be`:`New note`,"aria-label":`New note`,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-2 hover:text-fg disabled:opacity-40`,"data-testid":`sticky-note-new`,children:(0,B.jsx)(H.Plus,{className:`w-3.5 h-3.5`})})]}),N?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`textarea`,{"aria-label":`Note: ${N.title}`,className:z(pC,`min-h-[18rem] flex-1 resize-y font-mono text-sm`),value:N.text,maxLength:xc.text,placeholder:`Write anything. It is saved by itself.`,onChange:e=>ee(N.id,e.target.value),onBlur:()=>void T(),onDrop:ne,spellCheck:!0,"data-testid":`sticky-note-text`}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-fg-faint`,children:[(0,B.jsx)(`span`,{"data-testid":`sticky-note-status`,children:d.kind===`saving`?`Saving…`:d.kind===`saved`?`Saved ${jb(d.at)}`:d.kind===`error`?null:`Saved in your vault as you type`}),d.kind===`error`?(0,B.jsxs)(`span`,{className:`text-danger`,"data-testid":`sticky-note-save-error`,children:[`Not saved: `,d.message]}):null,(0,B.jsxs)(`span`,{className:`ml-auto`,children:[N.text.length.toLocaleString(),` /`,` `,xc.text.toLocaleString(),` characters`]}),_===N.id?(0,B.jsxs)(`span`,{className:`flex items-center gap-1`,"data-testid":`sticky-note-confirm`,children:[`Delete “`,N.title,`”?`,(0,B.jsx)(U,{size:`sm`,variant:`danger`,onClick:()=>void j(N.id),"data-testid":`sticky-note-delete-yes`,children:`Delete`}),(0,B.jsx)(U,{size:`sm`,onClick:()=>y(null),children:`Keep`})]}):(0,B.jsxs)(U,{size:`sm`,variant:`ghost`,onClick:()=>N.text.trim()?y(N.id):void j(N.id),"data-testid":`sticky-note-delete`,children:[(0,B.jsx)(H.Trash,{className:`w-3 h-3`}),` Delete note`]})]}),P>xc.totalText*.9?(0,B.jsxs)(`p`,{className:`text-[11px] text-warn`,children:[`Your notes hold `,P.toLocaleString(),` of`,` `,xc.totalText.toLocaleString(),` characters.`]}):null]}):(0,B.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 text-fg-muted`,"data-testid":`sticky-notes-empty`,children:[(0,B.jsx)(H.StickyNote,{className:`w-6 h-6 text-fg-faint`}),(0,B.jsx)(`p`,{children:`No notes yet. They are kept in your vault and follow you to your other PCs.`}),(0,B.jsxs)(U,{variant:`primary`,onClick:()=>void A(),busy:b,children:[(0,B.jsx)(H.Plus,{className:`w-3.5 h-3.5`}),` New note`]})]})]}):(0,B.jsx)(`p`,{className:`text-fg-muted`,"data-testid":`sticky-notes-unsupported`,children:`OonaCode on this PC is too old for sticky notes. Update it, then try again.`})})})}function pPe(e){let t=Date.parse(`${e}T12:00:00`);return Number.isFinite(t)?new Date(t).toLocaleDateString(void 0,{dateStyle:`long`}):e}function mPe({open:e,notes:t,onClose:n}){return(0,B.jsx)(gC,{open:e,title:`What's new in OonaCode`,onClose:n,footer:(0,B.jsx)(U,{variant:`primary`,onClick:n,children:`Got it`}),children:(0,B.jsx)(`div`,{className:`space-y-5 text-sm`,"data-testid":`whats-new`,children:t.map(e=>(0,B.jsxs)(`section`,{"data-version":e.version,children:[(0,B.jsxs)(`div`,{className:`mb-2 flex items-baseline gap-2`,children:[(0,B.jsxs)(`h3`,{className:`text-base font-semibold`,children:[`Version `,e.version]}),(0,B.jsx)(`span`,{className:`text-xs text-fg-faint`,children:pPe(e.date)})]}),e.added.length>0?(0,B.jsx)(`ul`,{className:`space-y-1.5`,children:e.added.map((e,t)=>(0,B.jsxs)(`li`,{className:`flex gap-2`,children:[(0,B.jsx)(H.Plus,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent`}),(0,B.jsx)(`span`,{children:e})]},t))}):null,e.fixed.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`mb-1 mt-3 text-xs font-medium uppercase tracking-wide text-fg-faint`,children:`Fixed`}),(0,B.jsx)(`ul`,{className:`space-y-1.5`,children:e.fixed.map((e,t)=>(0,B.jsxs)(`li`,{className:`flex gap-2`,children:[(0,B.jsx)(H.Check,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-ok`}),(0,B.jsx)(`span`,{children:e})]},t))})]}):null]},`${e.version}:${e.platforms?.join(`,`)??`all`}`))})})}function hPe(){let{state:e,actions:t}=V(),n=e.info?.databaseRepair??null,r=e.info?.databaseDamage??null;return n?(0,B.jsxs)(`div`,{role:`status`,"data-testid":`database-repair-banner`,className:`flex items-start gap-2 bg-warn-soft px-3 py-1.5 text-xs text-warn`,children:[(0,B.jsx)(H.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`flex-1 select-text`,children:n.message}),(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:()=>void t.dismissDatabaseRepair(),children:`Got it`})]}):r?(0,B.jsxs)(`div`,{role:`status`,"data-testid":`database-damage-banner`,className:`flex items-start gap-2 bg-danger-soft px-3 py-1.5 text-xs text-danger`,children:[(0,B.jsx)(H.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,B.jsxs)(`span`,{className:`flex-1`,children:[`The disk returned read errors on this PC’s chat database (`,r.code,`). OonaCode keeps working; restart it when you can, and it checks and repairs the database, keeping the damaged files. Read errors usually mean failing hardware: check the disk and run a memory test.`]})]}):null}function gPe(){let{state:e,actions:t}=V(),n=Gg(e.account);return!n||e.ui.dialog===`account`?null:(0,B.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,B.jsx)(H.Alert,{className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{className:`flex-1`,children:rte(n)}),(0,B.jsx)(U,{size:`sm`,variant:`primary`,onClick:()=>t.openDialog(`account`),children:`Open Account`})]})}function _Pe({onReconnect:e}){let{state:t}=V(),n=t.connection.status;if(n===`open`||n===`idle`||n===`connecting`)return null;let r=n===`unauthorized`&&!window.oonacode;return(0,B.jsxs)(`div`,{role:`status`,className:z(`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,B.jsx)(H.Alert,{className:`w-3.5 h-3.5`}):(0,B.jsx)(H.Spinner,{className:`w-3.5 h-3.5`}),(0,B.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,B.jsx)(U,{size:`sm`,variant:`danger`,onClick:e,children:`Enter token`}):null]})}function vPe(){let{state:e,actions:t}=V(),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),yPe(r)}}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t])}function yPe(e){let t=()=>{let t=document.querySelectorAll(`[data-editor-group]`)[e]?.querySelector(`[data-testid="composer"] [data-testid="composer-input"]`);t&&HR(t)};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}function bPe(){let{state:e,actions:t}=V(),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 xPe(){let{state:e,actions:t}=V(),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}=yu(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?vu(o,`0`,void 0,m):[])}function SPe({onUnauthorized:e}){let{state:t,actions:n}=V(),r=(0,v.useCallback)(()=>n.openDialog(`none`),[n]),i=xPe();bPe();let a=t.ui.sidebarOpen;return vPe(),(0,B.jsxs)(`div`,{className:`flex h-full flex-col bg-bg text-fg`,children:[(0,B.jsx)(rPe,{}),(0,B.jsx)(_Pe,{onReconnect:e}),(0,B.jsx)(gPe,{}),(0,B.jsx)(hPe,{}),(0,B.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,B.jsx)(tNe,{}),a?(0,B.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 md:hidden`,onClick:()=>n.setSidebar(!1),"aria-hidden":!0}):null,(0,B.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:(0,B.jsx)(xke,{})}),(0,B.jsx)(kMe,{})]}),(0,B.jsx)(Dke,{open:t.ui.dialog===`project`,onClose:r}),(0,B.jsx)(Hke,{open:t.ui.dialog===`projects`,startNew:t.projectsStartNew,selectId:t.projectsSelectId,onClose:r}),(0,B.jsx)(zAe,{open:t.ui.dialog===`assign-project`,onClose:r}),(0,B.jsx)(PNe,{open:t.ui.dialog===`settings`,onClose:r}),(0,B.jsx)(Jne,{open:t.ui.dialog===`account`,onClose:r}),(0,B.jsx)(Eke,{open:t.ui.dialog===`doctor`,onClose:r}),(0,B.jsx)(ere,{open:t.ui.dialog===`session-picker`,onClose:r}),(0,B.jsx)(XNe,{open:t.ui.dialog===`update`,onClose:r}),(0,B.jsx)(uPe,{open:t.ui.dialog===`bug-report`,onClose:r}),(0,B.jsx)(fPe,{open:t.ui.dialog===`sticky-notes`,onClose:r}),(0,B.jsx)(Vke,{open:t.ui.dialog===`claude-login`,onClose:r}),(0,B.jsx)(Tje,{open:t.ui.dialog===`oauth-login`,onClose:r}),(0,B.jsx)(Eje,{open:t.ui.dialog===`manage-models`,onClose:r}),(0,B.jsx)(qje,{open:t.ui.dialog===`import-claude`,autoOffer:t.importOffered,onClose:r}),(0,B.jsx)(Uke,{open:t.ui.dialog===`export-chats`,onClose:r}),(0,B.jsx)(Gke,{open:t.ui.dialog===`workspace-cleanup`,onClose:r}),(0,B.jsx)(nAe,{open:t.ui.dialog===`connect-ai-tool`,onClose:r}),(0,B.jsx)(ofe,{open:t.ui.dialog===`conversations`,selectId:t.conversationsSelectId,onClose:r}),(0,B.jsx)(PAe,{open:t.ui.dialog===`chat-abouts`,onClose:r}),(0,B.jsx)(LAe,{open:t.ui.dialog===`project-manager`,onClose:r}),(0,B.jsx)(EAe,{open:t.ui.dialog===`voice-summary`,onClose:r}),(0,B.jsx)(mPe,{open:t.ui.dialog===`whats-new`,notes:i,onClose:r}),(0,B.jsx)(wje,{open:t.ui.connectProviderId!==null,providerId:t.ui.connectProviderId,onClose:()=>n.openProviderConnect(null)}),(0,B.jsx)(_me,{}),(0,B.jsx)(Lke,{}),(0,B.jsx)(E9,{})]})}function CPe({onUnauthorized:e}){let{state:t}=V(),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&&Gg(t.account)===null?(0,B.jsx)(UNe,{}):(0,B.jsx)(SPe,{onUnauthorized:e}):(0,B.jsx)(HNe,{}):(0,B.jsx)(RNe,{})}function wPe({api:e,socket:t,relay:n,initialSessionId:r,onUnauthorized:i,reportError:a}){return(0,B.jsx)(nC,{api:e,socket:t,relay:n??null,initialSessionId:r??null,onUnauthorized:i,...a?{reportError:a}:{},children:(0,B.jsx)(CPe,{onUnauthorized:i})})}var H9=`oonacode.host.connection`,TPe=`session`;function EPe(e){let t=e.replace(/^#\/?\??/,``),n=new URLSearchParams(t),r=n.get(`token`),i=n.get(`host`)??n.get(`baseUrl`),a=n.get(TPe);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 U9(e,t){let n;try{n=new URL(e)}catch{return!1}return n.protocol!==`http:`&&n.protocol!==`https:`?!1:n.origin===t||n.hostname===`127.0.0.1`||n.hostname===`localhost`||n.hostname===`[::1]`}function DPe(e,t){if(!e)return null;try{let n=e.getItem(H9);if(!n)return null;let r=JSON.parse(n);if(typeof r.baseUrl==`string`&&typeof r.token==`string`&&r.token)return t!==void 0&&!U9(r.baseUrl,t)?null:{baseUrl:Yg(r.baseUrl),token:r.token}}catch{}return null}function W9(e,t){if(e)try{t?e.setItem(H9,JSON.stringify(t)):e.removeItem(H9)}catch{}}async function OPe(e){let t=EPe(e.location.hash);if(t.token){let n={baseUrl:Yg((t.baseUrl!==null&&U9(t.baseUrl,e.location.origin)?t.baseUrl:null)??e.location.origin),token:t.token};W9(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:Yg(n.baseUrl),token:n.token};return W9(e.storage,r),{connection:r,source:`bridge`,sessionId:t.sessionId}}}catch{}let n=DPe(e.storage,e.location.origin);return n?{connection:n,source:`storage`,sessionId:t.sessionId}:{connection:null,source:`none`,sessionId:t.sessionId}}function kPe(e=window){let t=null;try{t=e.sessionStorage}catch{t=null}return OPe({location:e.location,storage:t,replaceUrl:t=>e.history.replaceState(null,``,t),bridge:e.oonacode})}var APe=1;function G9(){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 jPe(e,t){return`${Yg(e).replace(/^http(s?):/i,`ws$1:`)}${b}?token=${encodeURIComponent(t)}`}var MPe=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:Yg(e.baseUrl)},this.clientId=e.clientId??G9()}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!==APe)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=jPe(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}$e(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}${I.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])K9(()=>n(e));for(let t of[...this.anyHandlers])K9(()=>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])K9(()=>n(e,t))}};function K9(e){try{e()}catch(e){console.error(`[HostSocket] handler failed`,e)}}var NPe=/([?&#](?:token|access_token|key|api_key|secret|password)=)[^&#\s"']*/gi,PPe=/\b(Bearer|Basic)\s+[A-Za-z0-9\-._~+/=]{8,}/g;function q9(e){return e.replace(NPe,`$1[redacted]`).replace(PPe,`$1 [redacted]`)}function J9(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function FPe(e){return typeof e==`object`&&!!e&&typeof e.message==`string`}function IPe(e){if(FPe(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:J9(e,512),stack:null}:{message:`Unhandled rejection (${e===null?`null`:Array.isArray(e)?`array`:typeof e})`,stack:null}}function LPe(e){return e?e.split(`
|
|
559
559
|
`).find(e=>/^\s+at\s/.test(e))?.trim()??``:``}function RPe(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}=IPe(n),l=t();if(!o(`${s}\n${LPe(c)}`,l))return!1;let u={client:`web-ui`,message:J9(q9(s),mc),detail:{source:`manual`,...i,embedded:r},at:new Date(l).toISOString()};return c&&(u.stack=J9(q9(c),hc)),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 Y9=1,zPe=1e3,BPe=3,VPe=6e4,HPe=new Set([`backpressure`,`detached by host`]);function UPe(e,t){return`${Yg(e).replace(/^http(s?):/i,`ws$1:`)}${I.remoteWs}?token=${encodeURIComponent(t)}`}function WPe(e){return`tab-${e}-${Math.random().toString(36).slice(2,10)}`}var GPe=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=UPe(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.#h(e)}},n.onmessage=e=>{this.#r===n&&this.#_(e.data)},n.onerror=()=>void 0,n.onclose=()=>{if(this.#r===n){this.#r=null;for(let e of this.#t.values())this.#g(e,{state:`host_offline`,online:!1,detail:`reconnecting to this PC…`}),e.onReach?.({kind:`ended`});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;for(let e of this.#t.values())this.#p(e);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!==Y9)return!1;try{return t.send(JSON.stringify(e)),!0}catch{return!1}}attach(e){this.#c+=1;let t=WPe(this.#c),n={pairingId:t,hostId:e.hostId,sessionId:e.sessionId,state:`unavailable`,online:!1,detail:null,onFrame:e.onFrame,onState:e.onState,...e.onReach?{onReach:e.onReach}:{},reattachTimer:null,reattaches:[]};return this.#t.set(t,n),this.#r&&this.#r.readyState===Y9?(this.#l!==null&&this.#g(n,{detail:this.#l}),this.#h(n)):this.connect(),{pairingId:t,hostId:e.hostId,sessionId:e.sessionId,send:e=>this.send(t,e),setReach:e=>this.#f({type:`remote_reach_set`,pairingId:t,folders:e}),answerReach:(e,n)=>this.#f({type:`remote_reach_answer`,pairingId:t,requestId:e,allow:n}),detach:()=>this.detach(t)}}detach(e){let t=this.#t.get(e);t&&(this.#p(t),this.#t.delete(e),this.#f({type:`remote_detach`,pairingId:e}),this.#t.size===0&&this.close())}#p(e){e.reattachTimer&&=((this.#e.clearTimeoutImpl??clearTimeout)(e.reattachTimer),null)}#m(e){if(this.#s||e.reattachTimer)return;let t=Date.now();e.reattaches=e.reattaches.filter(e=>t-e<VPe),!(e.reattaches.length>=BPe)&&(e.reattaches.push(t),e.reattachTimer=(this.#e.setTimeoutImpl??setTimeout)(()=>{e.reattachTimer=null,this.#t.get(e.pairingId)===e&&this.#h(e)},zPe))}send(e,t){let n=this.#t.get(e);return!n||!n.online?!1:this.#f({type:`remote_send`,pairingId:e,frame:t})}#h(e){this.#f({type:`remote_attach`,pairingId:e.pairingId,hostId:e.hostId,sessionId:e.sessionId})}#g(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})}#_(e){let t;try{let n=JSON.parse(typeof e==`string`?e:String(e));if(!it(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.#g(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.#h(e);return;case`remote_status`:{let e=this.#t.get(t.pairingId);if(!e)return;let n=at(t.state);n&&this.#p(e),this.#g(e,{state:t.state,online:n,detail:t.detail??null}),t.state===`host_offline`&&t.detail&&HPe.has(t.detail)&&this.#m(e);return}case`remote_frame`:this.#t.get(t.pairingId)?.onFrame(t.frame);return;case`remote_reach_state`:this.#t.get(t.pairingId)?.onReach?.({kind:`state`,linked:t.linked,folders:t.folders,...t.refusals?{refusals:t.refusals}:{}});return;case`remote_reach_ask`:this.#t.get(t.pairingId)?.onReach?.({kind:`ask`,requestId:t.requestId,summary:t.summary});return;case`remote_reach_ask_end`:this.#t.get(t.pairingId)?.onReach?.({kind:`ask_end`,requestId:t.requestId});return;case`remote_error`:{let e=t.pairingId?this.#t.get(t.pairingId):void 0;e&&this.#g(e,{state:`error`,online:!1,detail:t.message});return}default:return}}};function KPe({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,B.jsx)(`div`,{className:`flex min-h-full items-center justify-center bg-bg p-4`,children:(0,B.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,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Connect to your OonaCode host`}),(0,B.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,B.jsx)(`code`,{className:`rounded bg-surface-2 px-1 font-mono`,children:`oona web`}),`.`]})]}),t?(0,B.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,B.jsx)(fC,{label:`Host URL`,children:(0,B.jsx)(`input`,{className:pC,value:r,onChange:e=>i(e.target.value),placeholder:`http://127.0.0.1:41317`,spellCheck:!1,autoComplete:`url`})}),(0,B.jsx)(fC,{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,B.jsx)(`input`,{className:pC,type:`password`,value:a,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1,autoFocus:!0})}),(0,B.jsx)(U,{type:`submit`,variant:`primary`,className:`w-full justify-center`,disabled:!s,children:`Connect`})]})})}function qPe(e){return!!e&&e.platform===`linux`&&e.host!==`vscode`&&!!e.onMenuModel}var X9=e=>!!e&&e.type!==`separator`&&e.enabled;function Z9(e,t,n){let r=e.length;for(let i=1;i<=r;i+=1){let a=((t+n*i)%r+r)%r;if(X9(e[a]))return a}return-1}function Q9({label:e,mnemonic:t,show:n}){let r=n&&t?e.toLowerCase().indexOf(t):-1;return r<0?e:(0,B.jsxs)(B.Fragment,{children:[e.slice(0,r),(0,B.jsx)(`span`,{className:`underline underline-offset-2`,children:e[r]}),e.slice(r+1)]})}function JPe({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?Z9(n,-1,1):-1),t&&c(e)},[p]),g=(0,v.useCallback)(t=>{!t||!X9(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(Z9(_,a,1));return;case`ArrowUp`:n(l),r===null?(h(v,!0),o(Z9(p(v),0,-1))):o(Z9(_,a<0?0:a,-1));return;case`Home`:n(l),r!==null&&o(Z9(_,-1,1));return;case`End`:n(l),r!==null&&o(Z9(_,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&&X9(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,B.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,B.jsxs)(`div`,{className:`relative flex`,children:[(0,B.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:z(`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,B.jsx)(Q9,{label:e.label,mnemonic:e.mnemonic,show:_})}),n&&e.submenu?(0,B.jsx)($9,{entries:e.submenu,active:a,showMnemonics:_,onHover:o,onRun:g}):null]},e.id)})})}function $9({entries:e,active:t,showMnemonics:n,onHover:r,onRun:i,nested:a=!1}){let[o,s]=(0,v.useState)(null);return(0,B.jsx)(`div`,{role:`menu`,className:z(`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,B.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,B.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:z(`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,B.jsx)(`span`,{className:`w-4 shrink-0 text-center`,"aria-hidden":!0,children:l&&e.checked?e.type===`radio`?`•`:`✓`:``}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:(0,B.jsx)(Q9,{label:e.label,mnemonic:e.mnemonic,show:n})}),e.accelerator?(0,B.jsx)(`span`,{className:`shrink-0 pl-6 text-xs text-fg-faint`,children:e.accelerator}):null,e.type===`submenu`?(0,B.jsx)(`span`,{className:`shrink-0 pl-4 text-fg-faint`,"aria-hidden":!0,children:`›`}):null,e.type===`submenu`&&o===a&&e.submenu?(0,B.jsx)($9,{entries:e.submenu,active:-1,showMnemonics:n,onHover:()=>{},onRun:i,nested:!0}):null]},e.id)})})}function YPe(e){return!!e&&typeof e==`object`&&typeof e.hostId==`string`}function XPe(e){return Math.min(5e3,500*2**Math.max(0,e))}async function ZPe(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(XPe(n))}}var QPe=`Securing your chats on this PC…`,$Pe=`OonaCode encrypts your chat history once, so no other program can read it. A long history takes a few minutes. If the app closes meanwhile, nothing is lost: it starts over next time.`;function eFe(e,t){let n=e.getElementById(`oona-splash`);if(!n)return;let r=n.querySelector(`[data-splash-label]`),i=n.querySelector(`[data-splash-hint]`),a=Math.round(Math.max(0,Math.min(1,t))*100);r&&(r.textContent=`${QPe} ${a}%`),i&&(i.textContent=$Pe,i.style.animation=`none`,i.style.opacity=`0.75`)}function tFe(){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,ZPe({getConnection:()=>e.getConnection(),accepts:e=>Xg(e).health().then(e=>YPe(e),()=>!1),cancelled:()=>l.current}).then(e=>{c.current=!1,e&&(W9(window.sessionStorage,e),s(e=>e+1),t({baseUrl:e.baseUrl,token:e.token}))}),!0)},[]);(0,v.useEffect)(()=>{kPe().then(e=>{r(e.sessionId),!(!e.connection&&u())&&t(e.connection)})},[u]),(0,v.useEffect)(()=>{e!==void 0&&document.getElementById(`oona-splash`)?.remove()},[e]),(0,v.useEffect)(()=>{if(e!==void 0)return;let t=window.oonacode?.getDatabaseConversion?.bind(window.oonacode);if(!t)return;let n=!1,r=()=>{t().then(e=>{!n&&e!==null&&eFe(document,e)},()=>void 0)};r();let i=setInterval(r,1e3);return()=>{n=!0,clearInterval(i)}},[e]);let d=(0,v.useCallback)(()=>{W9(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=Xg(e),n=window.oonacode?.window?.id;return{api:t,socket:new MPe({baseUrl:e.baseUrl,token:e.token,clientKind:window.oonacode?`desktop`:`web`,clientVersion:window.oonacode?.appVersion,...n?{clientId:`${n.slice(0,16)}-${G9()}`}:{}}),relay:new GPe({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?RPe({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,B.jsx)(KPe,{defaultBaseUrl:window.location.origin,error:i,onConnect:e=>{W9(window.sessionStorage,e),a(null),t(e)}}):(0,B.jsx)(wPe,{api:f.api,socket:f.socket,relay:f.relay,initialSessionId:n,onUnauthorized:d,...p?{reportError:p.report}:{}},o)}function nFe({children:e}){let t=typeof window>`u`?void 0:window.oonacode;return qPe(t)?(0,B.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,B.jsx)(JPe,{bridge:t}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:e})]}):(0,B.jsx)(B.Fragment,{children:e})}var rFe=document.getElementById(`root`);(0,y.createRoot)(rFe).render((0,B.jsx)(v.StrictMode,{children:(0,B.jsx)(nFe,{children:(0,B.jsx)(tFe,{})})}));
|