om-memory-system 3.2.0-next.12 → 3.2.0-next.14

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.
@@ -31,9 +31,11 @@ export interface DiscoveryResult {
31
31
  unrecognized: UnrecognizedFile[];
32
32
  }
33
33
  /**
34
- * Bounds on a folder walk. A Pi sessions folder is shallow (one folder per
35
- * project), so a walk that goes past these is almost certainly a home folder,
34
+ * Bounds on a folder walk. A Pi sessions folder holds a few hundred folders,
35
+ * so a walk past the folder or file limit is almost certainly a home folder,
36
36
  * `/`, or a whole backup volume, and would block the process for minutes.
37
+ * Depth is only a backstop: subagent runs nest session folders seven or more
38
+ * levels deep (`<project>/<run>/<id>/run-0/session/<id>/run-0`).
37
39
  */
38
40
  export interface DiscoveryLimits {
39
41
  maxDepth: number;
@@ -16,7 +16,7 @@ import { homedir } from "node:os";
16
16
  export const DEFAULT_PI_SESSION_ROOT = join(homedir(), ".pi", "agent", "sessions");
17
17
  export const PI_HEADER_READ_LIMIT = 64 * 1024;
18
18
  export const DEFAULT_DISCOVERY_LIMITS = {
19
- maxDepth: 6,
19
+ maxDepth: 32,
20
20
  maxFolders: 5_000,
21
21
  maxFiles: 20_000,
22
22
  };
@@ -112,7 +112,15 @@ export function createLegacyClient(ctx) {
112
112
  const connected = [
113
113
  ...new Set(models.data.map((model) => model.providerID).filter(Boolean)),
114
114
  ];
115
- return { data: { connected } };
115
+ // The Settings page lists each connected provider's models from `all`, as
116
+ // the V1 SDK's provider list returns them.
117
+ const all = connected.map((id) => ({
118
+ id,
119
+ models: Object.fromEntries(models.data
120
+ .filter((model) => model.providerID === id)
121
+ .map((model) => [model.id, { name: model.name || model.id }])),
122
+ }));
123
+ return { data: { connected, all } };
116
124
  },
117
125
  },
118
126
  tui: {
@@ -119,6 +119,6 @@ ${e}</tr>
119
119
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
120
120
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${df(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=ff(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+df(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=ff(e);if(i===null)return df(n);e=i;let a=`<img src="${e}" alt="${df(n)}"`;return t&&(a+=` title="${df(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:df(e.text)}},Cf=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},wf=class e{options;renderer;textRenderer;constructor(e){this.options=e||Ku,this.options.renderer=this.options.renderer||new Sf,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Cf}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Tf=class{options;block;constructor(e){this.options=e||Ku}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?xf.lex:xf.lexInline}provideParser(e=this.block){return e?wf.parse:wf.parseInline}},Ef=new class{defaults=Gu();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=wf;Renderer=Sf;TextRenderer=Cf;Lexer=xf;Tokenizer=bf;Hooks=Tf;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Sf(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new bf(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Tf;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=Tf.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Tf.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return xf.lex(e,t??this.defaults)}parser(e,t){return wf.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?xf.lex:xf.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?wf.parse:wf.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?xf.lex:xf.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?wf.parse:wf.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
121
121
  Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+df(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Df(e,t){return Ef.parse(e,t)}Df.options=Df.setOptions=function(e){return Ef.setOptions(e),Df.defaults=Ef.defaults,qu(Df.defaults),Df},Df.getDefaults=Gu,Df.defaults=Ku;function Of(...e){return Ef.use(...e),Df.defaults=Ef.defaults,qu(Df.defaults),Df}Df.use=Of,Df.walkTokens=function(e,t){return Ef.walkTokens(e,t)},Df.parseInline=Ef.parseInline,Df.Parser=wf,Df.parser=wf.parse,Df.Renderer=Sf,Df.TextRenderer=Cf,Df.Lexer=xf,Df.lexer=xf.lex,Df.Tokenizer=bf,Df.Hooks=Tf,Df.parse=Df,Df.options,Df.setOptions,Df.walkTokens,Df.parseInline,wf.parse,xf.lex,Df.setOptions({gfm:!0,breaks:!0});function kf(e){let t=Df.parse(e,{async:!1});return Wu.sanitize(t)}function Af(e){if(e.projectPath){let t=e.projectPath.replace(/\\/g,`/`).split(`/`).filter(e=>e);return t[t.length-1]||e.projectPath}return e.displayName||e.id}function jf(e){return{createdDate:Sl(e.createdAt),updatedDate:e.updatedAt&&e.updatedAt!==e.createdAt?Sl(e.updatedAt):null}}function Mf(e,t){return e.similarity===void 0?null:t?`${Math.round(e.similarity*100)}%`:`${e.similarity}%`}function Nf({variant:e,item:t,memory:n,prompt:r,selected:i=!1,onSelect:a,onPin:o,onUnpin:s,onEdit:c,onDeleteMemory:l,onDeletePrompt:u}){let{t:d}=kt();if(e===`pair`&&n&&r){let e=n.isPinned||!1,t=jf(n),u=Mf(n,!0);return(0,H.jsxs)(`div`,{className:`rounded-xl border border-border bg-card/60 p-3 space-y-3 ${i?`ring-1 ring-primary/50`:``} ${e?`border-primary/40`:``}`,"data-id":n.id,children:[(0,H.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-muted/40 p-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(xl,{variant:`secondary`,children:d(`badge-prompt`)}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Sl(r.createdAt)})]}),(0,H.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:r.content})]}),(0,H.jsx)(`div`,{className:`flex justify-center text-muted-foreground`,children:(0,H.jsx)(ne,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 min-w-0`,children:[(0,H.jsx)(zi,{checked:i,onCheckedChange:e=>a?.(n.id,e===!0)}),(0,H.jsx)(xl,{children:d(`badge-memory`)}),n.memoryType?(0,H.jsx)(xl,{variant:`outline`,children:n.memoryType}):null,u?(0,H.jsx)(`span`,{className:`text-xs text-primary`,children:u}):null,e?(0,H.jsx)(xl,{variant:`secondary`,children:d(`badge-pinned`)}):null,(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:n.displayName||n.id})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[e?(0,H.jsx)(U,{variant:`ghost`,size:`icon-xs`,title:`Unpin`,onClick:()=>s?.(n.id),children:(0,H.jsx)(he,{className:`size-3.5 fill-current`})}):(0,H.jsx)(U,{variant:`ghost`,size:`icon-xs`,title:`Pin`,onClick:()=>o?.(n.id),children:(0,H.jsx)(he,{className:`size-3.5`})}),(0,H.jsx)(U,{variant:`ghost`,size:`icon-xs`,onClick:()=>c?.(n.id),children:(0,H.jsx)(me,{className:`size-3.5`})}),(0,H.jsxs)(U,{variant:`destructive`,size:`xs`,onClick:()=>l?.(n.id,!0),children:[(0,H.jsx)(Te,{className:`size-3.5`}),d(`btn-delete-pair`)]})]})]}),n.tags?.length?(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.tags.map(e=>(0,H.jsx)(xl,{variant:`outline`,className:`font-normal`,children:e},e))}):null,(0,H.jsx)(`div`,{className:`markdown-content text-sm prose-invert max-w-none`,dangerouslySetInnerHTML:{__html:kf(n.content)}}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-muted-foreground`,children:[(0,H.jsxs)(`span`,{children:[d(`date-created`),` `,t.createdDate]}),t.updatedDate?(0,H.jsxs)(`span`,{children:[d(`date-updated`),` `,t.updatedDate]}):null,(0,H.jsxs)(`span`,{children:[`ID: `,n.id]})]})]})]})}if(e===`prompt`&&t){let e=!!t.linkedMemoryId;return(0,H.jsxs)(`div`,{className:`rounded-xl border border-border bg-card/60 p-3 space-y-2 ${i?`ring-1 ring-primary/50`:``}`,"data-id":t.id,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,H.jsx)(zi,{checked:i,onCheckedChange:e=>a?.(t.id,e===!0)}),(0,H.jsx)(fe,{className:`size-3.5 text-muted-foreground`}),(0,H.jsx)(xl,{variant:`secondary`,children:d(`badge-prompt`)}),e?(0,H.jsxs)(xl,{variant:`outline`,children:[(0,H.jsx)(P,{className:`size-3`}),d(`badge-linked`)]}):null,(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Sl(t.createdAt)})]}),(0,H.jsxs)(U,{variant:`destructive`,size:`xs`,onClick:()=>u?.(t.id,e),children:[(0,H.jsx)(Te,{className:`size-3.5`}),d(e?`btn-delete-pair`:`btn-delete`)]})]}),(0,H.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:t.content}),e?(0,H.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,H.jsx)(ne,{className:`size-3`}),d(`text-generated-above`),(0,H.jsx)(ie,{className:`size-3`})]}):null]})}if(e===`memory`&&t){let e=t.isPinned||!1,n=!!t.linkedPromptId,r=jf(t),u=Mf(t,!1);return(0,H.jsxs)(`div`,{className:`rounded-xl border border-border bg-card/60 p-3 space-y-2 ${i?`ring-1 ring-primary/50`:``} ${e?`border-primary/40`:``}`,"data-id":t.id,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 min-w-0`,children:[(0,H.jsx)(zi,{checked:i,onCheckedChange:e=>a?.(t.id,e===!0)}),t.memoryType?(0,H.jsx)(xl,{variant:`outline`,children:t.memoryType}):null,n?(0,H.jsxs)(xl,{variant:`outline`,children:[(0,H.jsx)(P,{className:`size-3`}),d(`badge-linked`)]}):null,u?(0,H.jsx)(`span`,{className:`text-xs text-primary`,children:u}):null,e?(0,H.jsx)(xl,{variant:`secondary`,children:d(`badge-pinned`)}):null,(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:Af(t)}),t.projectPath?(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground/70 truncate w-full`,children:t.projectPath}):null]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[e?(0,H.jsx)(U,{variant:`ghost`,size:`icon-xs`,title:`Unpin`,onClick:()=>s?.(t.id),children:(0,H.jsx)(he,{className:`size-3.5 fill-current`})}):(0,H.jsx)(U,{variant:`ghost`,size:`icon-xs`,title:`Pin`,onClick:()=>o?.(t.id),children:(0,H.jsx)(he,{className:`size-3.5`})}),(0,H.jsx)(U,{variant:`ghost`,size:`icon-xs`,onClick:()=>c?.(t.id),children:(0,H.jsx)(me,{className:`size-3.5`})}),(0,H.jsxs)(U,{variant:`destructive`,size:`xs`,onClick:()=>l?.(t.id,n),children:[(0,H.jsx)(Te,{className:`size-3.5`}),d(n?`btn-delete-pair`:`btn-delete`)]})]})]}),t.tags?.length?(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.tags.map(e=>(0,H.jsx)(xl,{variant:`outline`,className:`font-normal`,children:e},e))}):null,(0,H.jsx)(`div`,{className:`markdown-content text-sm prose-invert max-w-none`,dangerouslySetInnerHTML:{__html:kf(t.content)}}),n?(0,H.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,H.jsx)(ie,{className:`size-3`}),d(`text-from-below`),(0,H.jsx)(ne,{className:`size-3`})]}):null,(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-muted-foreground`,children:[(0,H.jsxs)(`span`,{children:[d(`date-created`),` `,r.createdDate]}),r.updatedDate?(0,H.jsxs)(`span`,{children:[d(`date-updated`),` `,r.updatedDate]}):null,(0,H.jsxs)(`span`,{children:[`ID: `,t.id]})]})]})}return null}function Pf(e){let t=new Map(e.map(e=>[e.id,e])),n=[],r=new Set;for(let i of e)if(!r.has(i.id)){if(i.type===`memory`&&i.linkedPromptId&&t.has(i.linkedPromptId)){let e=t.get(i.linkedPromptId);n.push({isPair:!0,memory:i,prompt:e}),r.add(i.id),r.add(e.id)}else if(i.type===`prompt`&&i.linkedMemoryId&&t.has(i.linkedMemoryId)){let e=t.get(i.linkedMemoryId);n.push({isPair:!0,memory:e,prompt:i}),r.add(i.id),r.add(e.id)}else n.push({isPair:!1,type:i.type,item:i}),r.add(i.id)}return n.sort((e,t)=>{let n=e.isPair?e.memory.createdAt:e.item.createdAt,r=t.isPair?t.memory.createdAt:t.item.createdAt;return new Date(r).getTime()-new Date(n).getTime()})}function Ff({memories:e,selectedIds:t,currentPage:n,totalPages:r,loading:i=!1,error:a=null,onSelect:o,onPageChange:s,onPin:c,onUnpin:l,onEdit:u,onDeleteMemory:d,onDeletePrompt:f}){let{t:p}=kt(),m=(0,_.useMemo)(()=>Pf(e),[e]),h=p(`text-page`,{current:n,total:r}),g=(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(U,{variant:`outline`,size:`icon-xs`,disabled:!(n>1),onClick:()=>s(-1),children:(0,H.jsx)(oe,{className:`size-3.5`})}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:h}),(0,H.jsx)(U,{variant:`outline`,size:`icon-xs`,disabled:!(n<r),onClick:()=>s(1),children:(0,H.jsx)(k,{className:`size-3.5`})})]});return(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`div`,{className:`space-y-3 min-h-32`,children:i&&e.length===0?(0,H.jsx)(`div`,{className:`text-sm text-muted-foreground py-8 text-center`,children:p(`loading-init`)}):a?(0,H.jsxs)(`div`,{className:`text-sm text-destructive py-8 text-center`,children:[`Error: `,a]}):m.length===0?(0,H.jsx)(`div`,{className:`text-sm text-muted-foreground py-8 text-center`,children:p(`empty-memories`)}):m.map(e=>e.isPair?(0,H.jsx)(Nf,{variant:`pair`,memory:e.memory,prompt:e.prompt,selected:t.has(e.memory.id),onSelect:o,onPin:c,onUnpin:l,onEdit:u,onDeleteMemory:d,onDeletePrompt:f},e.memory.id):e.type===`prompt`?(0,H.jsx)(Nf,{variant:`prompt`,item:e.item,selected:t.has(e.item.id),onSelect:o,onPin:c,onUnpin:l,onEdit:u,onDeleteMemory:d,onDeletePrompt:f},e.item.id):(0,H.jsx)(Nf,{variant:`memory`,item:e.item,selected:t.has(e.item.id),onSelect:o,onPin:c,onUnpin:l,onEdit:u,onDeleteMemory:d,onDeletePrompt:f},e.item.id))}),(0,H.jsx)(`div`,{className:`flex justify-end`,children:g})]})}var If=Object.defineProperty,Lf=(e,t)=>If(e,`name`,{value:t,configurable:!0}),Rf=_.createContext(void 0);function zf(e){let t=_.useContext(Rf);return e||t||`ltr`}Lf(zf,`useDirection`);var Bf=Object.defineProperty,Vf=(e,t)=>Bf(e,`name`,{value:t,configurable:!0});function Hf(e,[t,n]){return Math.min(n,Math.max(t,e))}Vf(Hf,`clamp`);var Uf=Object.defineProperty,$=(e,t)=>Uf(e,`name`,{value:t,configurable:!0});function Wf(e,t){return _.useReducer((e,n)=>t[e][n]??e,e)}$(Wf,`useStateMachine`);var Gf=`ScrollArea`,[Kf,qf]=Ir(Gf),[Jf,Yf]=Kf(Gf),Xf=_.forwardRef($(function(e,t){let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=_.useState(null),[l,u]=_.useState(null),[d,f]=_.useState(null),[p,m]=_.useState(null),[h,g]=_.useState(null),[v,y]=_.useState(0),[b,x]=_.useState(0),[S,C]=_.useState(!1),[w,T]=_.useState(!1),E=It(t,c),ee=zf(i);return(0,H.jsx)(Jf,{scope:n,type:r,dir:ee,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:w,onScrollbarYEnabledChange:T,onCornerWidthChange:y,onCornerHeightChange:x,children:(0,H.jsx)(bi.div,{dir:ee,...o,ref:E,style:{position:`relative`,"--radix-scroll-area-corner-width":v+`px`,"--radix-scroll-area-corner-height":b+`px`,...e.style}})})},`ScrollArea`)),Zf=`ScrollAreaViewport`,Qf=_.forwardRef($(function(e,t){let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=Yf(Zf,n),s=It(t,_.useRef(null),o.onViewportChange);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($f,{nonce:i}),(0,H.jsx)(bi.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,H.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})},`ScrollAreaViewport`)),$f=_.memo($(function({nonce:e}){return(0,H.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:e})},`ScrollAreaViewportStyle`),(e,t)=>e.nonce===t.nonce),ep=`ScrollAreaScrollbar`,tp=_.forwardRef($(function(e,t){let{forceMount:n,...r}=e,i=Yf(ep,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return _.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,H.jsx)(np,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,H.jsx)(rp,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,H.jsx)(ip,{...r,ref:t,forceMount:n}):i.type===`always`?(0,H.jsx)(ap,{...r,ref:t,"data-state":`visible`}):null},`ScrollAreaScrollbar`)),np=_.forwardRef($(function(e,t){let{forceMount:n,...r}=e,i=Yf(ep,e.__scopeScrollArea),[a,o]=_.useState(!1);return _.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=$(()=>{window.clearTimeout(t),o(!0)},`handlePointerEnter`),r=$(()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)},`handlePointerLeave`);return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,H.jsx)(fi,{present:n||a,children:(0,H.jsx)(ip,{"data-state":a?`visible`:`hidden`,...r,ref:t})})},`ScrollAreaScrollbarHover`)),rp=_.forwardRef($(function(e,t){let{forceMount:n,...r}=e,i=Yf(ep,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=Tp(()=>c(`SCROLL_END`),100),[s,c]=Wf(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return _.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),_.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=$(()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r},`handleScroll`);return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,H.jsx)(fi,{present:n||s!==`hidden`,children:(0,H.jsx)(ap,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:Vr(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:Vr(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})},`ScrollAreaScrollbarScroll`)),ip=_.forwardRef($(function(e,t){let n=Yf(ep,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=_.useState(!1),s=e.orientation===`horizontal`,c=Tp(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return Ep(n.viewport,c),Ep(n.content,c),(0,H.jsx)(fi,{present:r||a,children:(0,H.jsx)(ap,{"data-state":a?`visible`:`hidden`,...i,ref:t})})},`ScrollAreaScrollbarAuto`)),ap=_.forwardRef($(function(e,t){let{orientation:n=`vertical`,...r}=e,i=Yf(ep,e.__scopeScrollArea),a=_.useRef(null),o=_.useRef(0),[s,c]=_.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=vp(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:$(e=>a.current=e,`onThumbChange`),onThumbPointerUp:$(()=>o.current=0,`onThumbPointerUp`),onThumbPointerDown:$(e=>o.current=e,`onThumbPointerDown`)};function d(e,t){return bp(e,o.current,s,t)}return $(d,`getScrollPosition`),n===`horizontal`?(0,H.jsx)(op,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=xp(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,H.jsx)(sp,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=xp(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null},`ScrollAreaScrollbarVisible`)),op=_.forwardRef($(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=Yf(ep,e.__scopeScrollArea),[o,s]=_.useState(),c=_.useRef(null),l=It(t,c,a.onScrollbarXChange);return _.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,H.jsx)(up,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":yp(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),Cp(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:_p(o.paddingLeft),paddingEnd:_p(o.paddingRight)}})}})},`ScrollAreaScrollbarX`)),sp=_.forwardRef($(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=Yf(ep,e.__scopeScrollArea),[o,s]=_.useState(),c=_.useRef(null),l=It(t,c,a.onScrollbarYChange);return _.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,H.jsx)(up,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":yp(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),Cp(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:_p(o.paddingTop),paddingEnd:_p(o.paddingBottom)}})}})},`ScrollAreaScrollbarY`)),[cp,lp]=Kf(ep),up=_.forwardRef($(function(e,t){let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=Yf(ep,n),[m,h]=_.useState(null),g=It(t,h),v=_.useRef(null),y=_.useRef(``),b=p.viewport,x=r.content-r.viewport,S=qi(u),C=qi(c),w=Tp(d,10);function T(e){if(v.current){let t=e.clientX-v.current.left,n=e.clientY-v.current.top;l({x:t,y:n})}}return $(T,`handleDragScroll`),_.useEffect(()=>{let e=$(e=>{let t=e.target;m?.contains(t)&&S(e,x)},`handleWheel`);return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[b,m,x,S]),_.useEffect(C,[r,C]),Ep(m,w),Ep(p.content,w),(0,H.jsx)(cp,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:qi(a),onThumbPointerUp:qi(o),onThumbPositionChange:C,onThumbPointerDown:qi(s),children:(0,H.jsx)(bi.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:Vr(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),v.current=m.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),T(e))}),onPointerMove:Vr(e.onPointerMove,T),onPointerUp:Vr(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=y.current,p.viewport&&(p.viewport.style.scrollBehavior=``),v.current=null})})})},`ScrollAreaScrollbarImpl`)),dp=`ScrollAreaThumb`,fp=_.forwardRef($(function(e,t){let{forceMount:n,...r}=e,i=lp(dp,e.__scopeScrollArea);return(0,H.jsx)(fi,{present:n||i.hasThumb,children:(0,H.jsx)(pp,{ref:t,...r})})},`ScrollAreaThumb`)),pp=_.forwardRef($(function(e,t){let{__scopeScrollArea:n,style:r,...i}=e,a=Yf(dp,n),o=lp(dp,n),{onThumbPositionChange:s}=o,c=It(t,o.onThumbChange),l=_.useRef(void 0),u=Tp(()=>{l.current&&=(l.current(),void 0)},100);return _.useEffect(()=>{let e=a.viewport;if(e){let t=$(()=>{if(u(),!l.current){let t=wp(e,s);l.current=t,s()}},`handleScroll`);return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,H.jsx)(bi.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:Vr(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:Vr(e.onPointerUp,o.onThumbPointerUp)})},`ScrollAreaThumbImpl`)),mp=`ScrollAreaCorner`,hp=_.forwardRef($(function(e,t){let n=Yf(mp,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,H.jsx)(gp,{...e,ref:t}):null},`ScrollAreaCorner`)),gp=_.forwardRef($(function(e,t){let{__scopeScrollArea:n,...r}=e,i=Yf(mp,n),[a,o]=_.useState(0),[s,c]=_.useState(0),l=!!(a&&s),{onCornerWidthChange:u,onCornerHeightChange:d}=i;return Ep(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),Ep(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),_.useEffect(()=>()=>{u(0),d(0)},[u,d]),l?(0,H.jsx)(bi.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null},`ScrollAreaCornerImpl`));function _p(e){return e?parseInt(e,10):0}$(_p,`toInt`);function vp(e,t){let n=e/t;return isNaN(n)?0:n}$(vp,`getThumbRatio`);function yp(e){let t=vp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}$(yp,`getThumbSize`);function bp(e,t,n,r=`ltr`){let i=yp(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return Sp([c,l],d)(e)}$(bp,`getScrollPositionFromPointer`);function xp(e,t,n=`ltr`){let r=yp(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=Hf(e,n===`ltr`?[0,o]:[o*-1,0]);return Sp([0,o],[0,s])(c)}$(xp,`getThumbOffsetFromScroll`);function Sp(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}$(Sp,`linearScale`);function Cp(e,t){return e>0&&e<t}$(Cp,`isScrollingWithinScrollbarBounds`);var wp=$((e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return $((function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)}),`loop`)(),()=>window.cancelAnimationFrame(r)},`addUnlinkedScrollListener`);function Tp(e,t){let n=qi(e),r=_.useRef(0);return _.useEffect(()=>()=>window.clearTimeout(r.current),[]),_.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}$(Tp,`useDebounceCallback`);function Ep(e,t){let n=qi(t);Kr(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}$(Ep,`useResizeObserver`);var Dp=Xf,Op=Qf,kp=hp;function Ap({className:e,children:t,...n}){return(0,H.jsxs)(Dp,{"data-slot":`scroll-area`,className:Ar(`relative`,e),...n,children:[(0,H.jsx)(Op,{"data-slot":`scroll-area-viewport`,className:`focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1`,children:t}),(0,H.jsx)(jp,{}),(0,H.jsx)(kp,{})]})}function jp({className:e,orientation:t=`vertical`,...n}){return(0,H.jsx)(tp,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:Ar(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,e),...n,children:(0,H.jsx)(fp,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}function Mp({open:e=!1,profileId:t=``,onOpenChange:n}){let{t:r}=kt(),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)([]);(0,_.useEffect)(()=>{e&&t&&c(t)},[e,t]);async function c(e){a(!0),s([]);let t=await ut(`/api/user-profile/changelog?profileId=${encodeURIComponent(e)}&limit=10`);a(!1),t.success&&t.data?s(t.data):s([])}return(0,H.jsx)(ws,{open:e,onOpenChange:n,children:(0,H.jsxs)(Ds,{className:`sm:max-w-lg`,children:[(0,H.jsx)(Os,{children:(0,H.jsx)(As,{children:r(`modal-changelog-title`)})}),(0,H.jsx)(Ap,{className:`max-h-80`,children:i?(0,H.jsx)(`div`,{className:`text-sm text-muted-foreground py-6 text-center`,children:r(`loading-changelog`)}):o.length===0?(0,H.jsx)(`div`,{className:`text-sm text-muted-foreground py-6 text-center`,children:r(`empty-changelog`)}):(0,H.jsx)(`div`,{className:`space-y-3 pr-3`,children:o.map((e,t)=>(0,H.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,H.jsxs)(`span`,{className:`font-medium`,children:[`v`,e.version]}),(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:e.changeType}),(0,H.jsx)(`span`,{className:`text-muted-foreground ml-auto`,children:Sl(e.createdAt)})]}),(0,H.jsx)(`p`,{className:`text-sm`,children:e.changeSummary})]},`${e.version}-${t}`))})})]})})}function Np({className:e,type:t,...n}){return(0,H.jsx)(`input`,{type:t,"data-slot":`input`,className:Ar(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 flex h-8 w-full min-w-0 rounded-lg border bg-transparent px-2.5 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-ring/30 focus-visible:ring-3`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,e),...n})}function Pp({open:e=!1,type:t=null,index:n=0,action:r=`edit`,item:i=null,onOpenChange:a,onSaved:o}){let{t:s}=kt(),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)([``]),[m,h]=(0,_.useState)(`1`),[g,v]=(0,_.useState)(!1),y=r===`edit`,b=t===`workflows`;(0,_.useEffect)(()=>{e&&i&&(l(i.category||``),d(i.description||``),p(i.steps?.length?[...i.steps]:[``]),h(`1`))},[e,i]);let x=y?s(`btn-edit`)||`Edit Item`:m===`2`?s(`confirm-delete-title`)||`Confirm Delete`:s(`confirm-delete`)||`Delete Item?`;function S(e){a?.(e)}function C(){p(e=>[...e,``])}function w(e){p(t=>{let n=t.filter((t,n)=>n!==e);return n.length===0?[``]:n})}function T(e,t){p(n=>n.map((n,r)=>r===e?t:n))}async function E(e){if(e.preventDefault(),!t)return;if(r===`delete`){if(m===`1`){h(`2`);return}v(!0);let e=await ut(`/api/user-profile/item`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:t,index:n,action:`delete`})});v(!1),e.success?(L.success(s(`toast-delete-success`)||`Item deleted`),S(!1),o?.()):L.error(e.error||s(`toast-delete-failed`)||`Delete failed`);return}v(!0);let i={type:t,index:n,action:`edit`,category:b?void 0:c,description:u};t===`workflows`&&(i.steps=f.map(e=>e.trim()).filter(Boolean));let a=await ut(`/api/user-profile/item`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)});v(!1),a.success?(L.success(s(`toast-update-success`)||`Item updated`),S(!1),o?.()):L.error(a.error||s(`toast-update-failed`)||`Update failed`)}return(0,H.jsx)(ws,{open:e,onOpenChange:S,children:(0,H.jsxs)(Ds,{className:`sm:max-w-lg`,children:[(0,H.jsx)(Os,{children:(0,H.jsx)(As,{children:x})}),(0,H.jsxs)(`form`,{className:`space-y-4`,onSubmit:E,children:[y||m===`1`?(0,H.jsxs)(H.Fragment,{children:[b?null:(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(_l,{htmlFor:`profile-item-category`,children:s(`label-category`)}),(0,H.jsx)(Np,{id:`profile-item-category`,value:c,onChange:e=>l(e.target.value),disabled:!y})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(_l,{htmlFor:`profile-item-description`,children:s(`label-description`)}),(0,H.jsx)(vl,{id:`profile-item-description`,rows:4,value:u,onChange:e=>d(e.target.value),disabled:!y})]}),b&&y?(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(_l,{children:s(`label-steps`)}),(0,H.jsx)(`div`,{className:`space-y-2`,children:f.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground w-5 tabular-nums`,children:t+1}),(0,H.jsx)(Np,{value:e,placeholder:`Step ${t+1}...`,onChange:e=>T(t,e.target.value)}),(0,H.jsx)(U,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:()=>w(t),children:`×`})]},t))}),(0,H.jsx)(U,{type:`button`,variant:`secondary`,size:`sm`,onClick:C,children:s(`btn-add-step`)})]}):null]}):null,(0,H.jsxs)(ks,{children:[(0,H.jsx)(U,{type:`button`,variant:`secondary`,onClick:()=>S(!1),children:s(`btn-cancel`)}),(0,H.jsx)(U,{type:`submit`,variant:y?`default`:`destructive`,disabled:g,children:y?s(`btn-save`)||`Save`:s(`btn-delete`)||`Delete`})]})]})]})})}var Fp=20;function Ip(e,t){let n=e.length,r=Math.max(1,Math.ceil(n/Fp)),i=Math.min(t,r),a=(i-1)*Fp;return{items:e.slice(a,a+Fp),total:n,totalPages:r,page:i,start:a}}function Lp(e){return Math.round((e.confidence||0)*1e3)/10}function Rp(e){return e.evidence?Array.isArray(e.evidence)?e.evidence.join(`
122
- `):e.evidence:``}function zp(e){return e.evidence?Array.isArray(e.evidence)?e.evidence.length:1:0}function Bp({profile:e,loading:t=!1,onRefresh:n,onCleanup:r}){let{t:i}=kt(),[a,o]=(0,_.useState)({pref:1,pat:1,wf:1}),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(0),[h,g]=(0,_.useState)(`edit`),[v,y]=(0,_.useState)(null),b=(0,_.useMemo)(()=>{if(!e?.exists||!e.profileData)return null;let t=e.profileData;if(typeof t==`string`)try{t=JSON.parse(t)}catch{return null}return t},[e]),x=(0,_.useMemo)(()=>wc(b?.preferences),[b]),S=(0,_.useMemo)(()=>wc(b?.patterns),[b]),C=(0,_.useMemo)(()=>wc(b?.workflows),[b]),w=(0,_.useMemo)(()=>C.map((e,t)=>({item:e,index:t})).sort((e,t)=>(t.item.frequency||0)-(e.item.frequency||0)),[C]),T=Ip(x,a.pref),E=Ip(S,a.pat),ee=Ip(w,a.wf),D=C.length;function ne(e,t,n){let r=(e===`preferences`?x:e===`patterns`?S:C)[t];r&&(f(e),m(t),g(n),y(r),u(!0))}function ie(e,t){return e.indexOf(t)}function ae({page:e,pageKey:t}){return e.total<=Fp?null:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-2`,children:[(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground mr-2`,children:[e.start+1,`-`,Math.min(e.start+Fp,e.total),` / `,e.total]}),Array.from({length:e.totalPages},(e,t)=>t+1).map(n=>(0,H.jsx)(U,{size:`xs`,variant:n===e.page?`default`:`outline`,onClick:()=>o(e=>({...e,[t]:n})),children:n},n))]})}function O({item:e,type:t,fullList:n}){let r=ie(n,e),a=Lp(e);return(0,H.jsxs)(`div`,{className:`rounded-xl border border-border bg-card/50 p-3 space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,H.jsx)(xl,{variant:`outline`,children:e.category||`General`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-0.5 ml-auto`,children:[(0,H.jsx)(U,{variant:`ghost`,size:`icon-xs`,title:i(`btn-edit`)||`Edit`,onClick:()=>ne(t,r,`edit`),children:(0,H.jsx)(I,{className:`size-3`})}),(0,H.jsx)(U,{variant:`ghost`,size:`icon-xs`,title:i(`btn-delete`)||`Delete`,onClick:()=>ne(t,r,`delete`),children:(0,H.jsx)(Te,{className:`size-3`})})]}),(0,H.jsxs)(`div`,{className:`size-9 rounded-full border border-border grid place-items-center text-[10px] tabular-nums shrink-0`,title:`${a}%`,children:[a,`%`]})]}),(0,H.jsx)(`p`,{className:`text-sm`,children:e.description||``}),e.evidence||e.frequency?(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:i(`label-evidence-tooltip`,{count:e.frequency||1}),children:[(0,H.jsx)(we,{className:`size-3`}),e.frequency||1]}),zp(e)>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`·`}),(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:Rp(e),children:[(0,H.jsx)(N,{className:`size-3`}),zp(e),` evidence`]})]}):null]}):null]})}return t&&!e?(0,H.jsx)(`div`,{className:`text-sm text-muted-foreground py-8 text-center`,children:i(`loading-profile`)}):e?.exists?b?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`h3`,{className:`text-base font-medium`,children:e.displayName||e.userId}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsxs)(`span`,{className:`rounded-full bg-muted px-2.5 py-1 text-xs`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:i(`profile-version`)}),(0,H.jsx)(`span`,{className:`ml-1`,children:e.version})]}),(0,H.jsxs)(`span`,{className:`rounded-full bg-muted px-2.5 py-1 text-xs`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:i(`profile-prompts`)}),(0,H.jsx)(`span`,{className:`ml-1`,children:e.totalPromptsAnalyzed})]}),(0,H.jsxs)(`span`,{className:`rounded-full bg-muted px-2.5 py-1 text-xs`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:i(`profile-updated`)}),(0,H.jsx)(`span`,{className:`ml-1`,children:e.lastAnalyzedAt?Sl(e.lastAnalyzedAt):`—`})]}),(0,H.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-1.5`,children:[(0,H.jsxs)(U,{variant:`outline`,size:`sm`,onClick:()=>r?.(),children:[(0,H.jsx)(Se,{className:`size-3.5`}),i(`btn-ai-cleanup`)]}),(0,H.jsxs)(U,{variant:`secondary`,size:`sm`,onClick:()=>n?.(),children:[(0,H.jsx)(ve,{className:`size-3.5`}),i(`btn-refresh`)]}),(0,H.jsxs)(U,{variant:`secondary`,size:`sm`,onClick:()=>c(!0),children:[(0,H.jsx)(ye,{className:`size-3.5`}),`History`]})]})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-2`,children:[(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,H.jsx)(M,{className:`size-4`}),i(`profile-preferences`),(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:x.length})]}),x.length===0?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`empty-preferences`)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:T.items.map(e=>(0,H.jsx)(O,{item:e,type:`preferences`,fullList:x},ie(x,e)))}),(0,H.jsx)(ae,{page:T,pageKey:`pref`})]})]}),(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,H.jsx)(te,{className:`size-4`}),i(`profile-patterns`),(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:S.length})]}),S.length===0?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`empty-patterns`)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:E.items.map(e=>(0,H.jsx)(O,{item:e,type:`patterns`,fullList:S},ie(S,e)))}),(0,H.jsx)(ae,{page:E,pageKey:`pat`})]})]}),(0,H.jsxs)(`section`,{className:`space-y-3 lg:col-span-2`,children:[(0,H.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,H.jsx)(Ae,{className:`size-4`}),i(`profile-workflows`),(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:D})]}),D===0?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`empty-workflows`)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`space-y-2`,children:ee.items.map(e=>{let t=e.item,n=e.index,r=Lp(t);return(0,H.jsxs)(`div`,{className:`rounded-xl border border-border bg-card/50 p-3 space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium flex-1`,children:t.description||``}),(0,H.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,H.jsx)(U,{variant:`ghost`,size:`icon-xs`,onClick:()=>ne(`workflows`,n,`edit`),children:(0,H.jsx)(I,{className:`size-3`})}),(0,H.jsx)(U,{variant:`ghost`,size:`icon-xs`,onClick:()=>ne(`workflows`,n,`delete`),children:(0,H.jsx)(Te,{className:`size-3`})})]}),(0,H.jsxs)(`div`,{className:`size-9 rounded-full border border-border grid place-items-center text-[10px] tabular-nums shrink-0`,children:[r,`%`]})]}),t.steps?.length?(0,H.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:t.steps.map((e,n)=>(0,H.jsxs)(`div`,{className:`contents`,children:[(0,H.jsxs)(`div`,{className:`inline-flex items-center gap-1.5 rounded-lg bg-muted px-2 py-1 text-xs`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:n+1}),(0,H.jsx)(`span`,{children:e})]}),n<(t.steps?.length||0)-1?(0,H.jsx)(re,{className:`size-3 text-muted-foreground`}):null]},n))}):null,(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:i(`label-evidence-tooltip`,{count:t.frequency||1}),children:[(0,H.jsx)(we,{className:`size-3`}),t.frequency||1]}),zp(t)>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`·`}),(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:Rp(t),children:[(0,H.jsx)(N,{className:`size-3`}),zp(t),` evidence`]})]}):null]})]},e.index)})}),(0,H.jsx)(ae,{page:ee,pageKey:`wf`})]})]})]})]}),(0,H.jsx)(Mp,{open:s,onOpenChange:c,profileId:e?.id||``}),(0,H.jsx)(Pp,{open:l,onOpenChange:u,type:d,index:p,action:h,item:v,onSaved:n})]}):null:(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-10 text-muted-foreground`,children:[(0,H.jsx)(Oe,{className:`size-8`}),(0,H.jsx)(`p`,{className:`text-sm`,children:e?.message||i(`empty-preferences`)})]})}function Vp({open:e=!1,count:t=0,onOpenChange:n,onComplete:r}){let{t:i}=kt(),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(0);(0,_.useEffect)(()=>{e&&!a&&(c(i(`migration-found-tags`,{count:t})),u(0))},[e,a,t,i]);function d(e){a&&!e||n?.(e)}async function f(){o(!0),c(i(`status-migration-init`)),u(0);let e=!0,t=0,n=1e3;for(;e&&t<n;){t++;let n=await ut(`/api/migration/tags/run-batch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({batchSize:3})});if(!n.success||!n.data){c(i(`toast-migration-failed`)+`: `+(n.error||``)),o(!1);return}let r=n.data.processed;e=n.data.hasMore;let a=n.data.total;u(a>0?Math.round(r/a*100):0),c(i(`status-migration-progress`,{current:r,total:a})),e&&await new Promise(e=>setTimeout(e,100))}if(t>=n){c(i(`migration-stopped`)),o(!1);return}u(100),c(i(`toast-migration-success`)),L.success(i(`toast-migration-success`)),setTimeout(()=>{o(!1),d(!1),r?.()},2e3)}return(0,H.jsx)(ws,{open:e,onOpenChange:d,children:(0,H.jsxs)(Ds,{className:`sm:max-w-md`,showCloseButton:!a,children:[(0,H.jsx)(Os,{children:(0,H.jsx)(As,{children:i(`modal-migration-title`)})}),(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s}),(0,H.jsx)(`div`,{className:`h-2 rounded-full bg-muted overflow-hidden`,children:(0,H.jsx)(`div`,{className:`h-full bg-primary transition-all duration-200`,style:{width:`${l}%`}})}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`migration-note`)})]}),a?null:(0,H.jsx)(ks,{children:(0,H.jsxs)(U,{onClick:f,children:[(0,H.jsx)(ge,{className:`size-3.5`}),i(`btn-start-migration`)]})})]})})}async function Hp(e,t={}){let n=await fetch(e,{...t,headers:{"x-omms-token":window.__OMMS_TOKEN__??``,...t.body?{"Content-Type":`application/json`}:{},...t.headers}}),r=await n.json();if(!n.ok)throw Error(r.error??`Request failed (${n.status})`);return r}var Up={Models:[`模型`,`النماذج`],"External API fallback":[`外部 API 备用模型`,`النموذج الاحتياطي عبر واجهة API الخارجية`],none:[`无`,`لا يوجد`],ready:[`就绪`,`جاهز`],"not ready":[`未就绪`,`غير جاهز`],"Credentials (values hidden)":[`凭据(不显示内容)`,`بيانات الاعتماد (القيم مخفية)`],set:[`已设置`,`مضبوط`],"not set":[`未设置`,`غير مضبوط`],"Effective model":[`当前使用模型`,`النموذج المستخدم`],session:[`会话`,`الجلسة`],"external API":[`外部 API`,`واجهة API الخارجية`],unavailable:[`不可用`,`غير متاح`],"Project override is active. Changes to the global file may not take effect here.":[`项目设置优先。全局文件的更改可能不会在此生效。`,`إعدادات المشروع لها الأولوية. قد لا تسري تغييرات الملف العام هنا.`],"Model choice":[`模型选择`,`اختيار النموذج`],"Session model":[`会话模型`,`نموذج الجلسة`],"Manual model":[`手动选择模型`,`اختيار النموذج يدوياً`],"Manual provider/model":[`手动输入提供商/模型`,`إدخال المزوّد/النموذج يدوياً`],"Model list unavailable. Enter provider/model manually.":[`模型列表不可用。请手动输入提供商/模型。`,`قائمة النماذج غير متاحة. أدخل المزوّد/النموذج يدوياً.`],"Save model":[`保存模型`,`حفظ النموذج`],"Enter a model as provider/model.":[`按 提供商/模型 格式输入。`,`أدخل النموذج بصيغة المزوّد/النموذج.`],"Saved. New capture and profile work uses these settings.":[`已保存。下一次捕获和用户画像将使用这些设置。`,`تم الحفظ. ستستخدم عمليات الالتقاط والملف الشخصي الجديدة هذه الإعدادات.`],"Saved. OMMS now reads ~/.config/omms/omms.jsonc. The legacy config was kept.":[`已保存。OMMS 现在读取 ~/.config/omms/omms.jsonc,旧配置保留。`,`تم الحفظ. يقرأ OMMS الآن الملف ~/.config/omms/omms.jsonc مع الاحتفاظ بالإعدادات القديمة.`],"Current settings were reloaded; check the values and save again.":[`已重新加载当前设置;检查数值后再次保存。`,`أُعيد تحميل الإعدادات الحالية. راجع القيم ثم احفظ مجدداً.`],"Capture diagnostics":[`捕获诊断`,`تشخيص الالتقاط`],"Time range":[`时间范围`,`الفترة الزمنية`],"24 hours":[`24 小时`,`24 ساعة`],"7 days":[`7 天`,`7 أيام`],"30 days":[`30 天`,`30 يوماً`],"90 days":[`90 天`,`90 يوماً`],"Outcomes by model":[`各模型结果`,`النتائج حسب النموذج`],"Host / model":[`主机 / 模型`,`المضيف / النموذج`],Saved:[`已保存`,`محفوظ`],Skipped:[`已跳过`,`متجاوز`],Failed:[`失败`,`فشل`],Total:[`总数`,`المجموع`],"Failure reasons":[`失败原因`,`أسباب الفشل`],"Recent attempts":[`最近尝试`,`المحاولات الأخيرة`],Time:[`时间`,`الوقت`],Host:[`主机`,`المضيف`],Source:[`来源`,`المصدر`],Session:[`会话`,`الجلسة`],Path:[`路径`,`المسار`],Model:[`模型`,`النموذج`],Stop:[`结束原因`,`سبب التوقف`],Blocks:[`区块`,`الكتل`],Prompt:[`提示词长度`,`طول الطلب`],Reply:[`回复长度`,`طول الرد`],Duration:[`耗时`,`المدة`],Outcome:[`结果`,`النتيجة`],Reason:[`原因`,`السبب`],"Save capture traces":[`保存捕获追踪`,`حفظ تتبعات الالتقاط`],"Traces can contain conversation content after redaction. Keep tracing off unless you need it for debugging.":[`追踪文件在脱敏后仍可能包含对话内容。仅在调试时开启。`,`قد تحتوي التتبعات على محتوى المحادثة بعد التنقيح. فعّلها عند التصحيح فقط.`],"This project turns tracing off. The global switch cannot turn it on here.":[`此项目已关闭追踪。全局开关无法在此开启。`,`أوقف هذا المشروع التتبع. لا يمكن للمفتاح العام تفعيله هنا.`],"Trace retention (days)":[`追踪保留天数`,`مدة حفظ التتبعات (بالأيام)`],"Attempt retention (days)":[`尝试记录保留天数`,`مدة حفظ المحاولات (بالأيام)`],"Trace files":[`追踪文件`,`ملفات التتبع`],View:[`查看`,`عرض`],Delete:[`删除`,`حذف`],Health:[`健康检查`,`فحص الحالة`],"Config files":[`配置文件`,`ملفات الإعدادات`],"Memory store":[`记忆存储`,`مخزن الذاكرة`],Embedding:[`嵌入模型`,`نموذج التضمين`],"Web binding":[`网页服务绑定`,`ربط خادم الويب`],"OpenCode model":[`OpenCode 模型`,`نموذج OpenCode`],"Pi model":[`Pi 模型`,`نموذج Pi`],"Capture failures (24 hours)":[`捕获失败(24 小时)`,`فشل الالتقاط (24 ساعة)`],"OpenCode model test":[`OpenCode 模型测试`,`اختبار نموذج OpenCode`],"Pi model test":[`Pi 模型测试`,`اختبار نموذج Pi`],"Run checks":[`运行检查`,`تشغيل الفحوصات`],"Run checks and test models":[`运行检查并测试模型`,`تشغيل الفحوصات واختبار النماذج`],"Checking…":[`正在检查…`,`جارٍ الفحص…`],pass:[`通过`,`نجاح`],warn:[`警告`,`تحذير`],fail:[`失败`,`فشل`],"Import and backfill":[`导入和回填`,`الاستيراد والاستكمال`],"History host":[`历史记录主机`,`مضيف السجل`],Scope:[`范围`,`النطاق`],"Current project":[`当前项目`,`المشروع الحالي`],"All projects":[`所有项目`,`كل المشاريع`],"Project directory":[`项目目录`,`مجلد المشروع`],"Current directory":[`当前目录`,`المجلد الحالي`],"Profile batch size":[`用户画像批量大小`,`حجم دفعة الملف الشخصي`],"Directory maps (old=new, one per line)":[`目录映射(旧=新,每行一条)`,`تعيين المجلدات (قديم=جديد، واحد في كل سطر)`],"Force reimport":[`强制重新导入`,`فرض إعادة الاستيراد`],"Skip memories":[`跳过记忆`,`تجاوز الذكريات`],"Skip profile":[`跳过用户画像`,`تجاوز الملف الشخصي`],"Import model":[`导入模型`,`نموذج الاستيراد`],"Saved external API":[`已保存的外部 API`,`واجهة API الخارجية المحفوظة`],"Preview (dry run)":[`预览(不写入)`,`معاينة (تشغيل تجريبي)`],"Start import":[`开始导入`,`بدء الاستيراد`],"Cancel after current unit":[`完成当前单元后取消`,`الإلغاء بعد الوحدة الحالية`],"Directory maps must be old=new, one per line":[`目录映射须为 旧=新,每行一条`,`يجب أن يكون تعيين المجلدات بصيغة قديم=جديد، واحد في كل سطر`],running:[`运行中`,`جارٍ التشغيل`],cancelling:[`正在取消`,`جارٍ الإلغاء`],cancelled:[`已取消`,`أُلغي`],done:[`已完成`,`اكتمل`],failed:[`失败`,`فشل`],units:[`单元`,`وحدات`],"List sessions":[`列出会话`,`عرض الجلسات`],"Refresh list":[`刷新列表`,`تحديث القائمة`],"Advanced options":[`高级选项`,`خيارات متقدمة`],"Hide advanced options":[`隐藏高级选项`,`إخفاء الخيارات المتقدمة`],"default location":[`默认位置`,`الموقع الافتراضي`],"Prompt date from":[`提示日期起`,`تاريخ الطلب من`],"Prompt date to":[`提示日期止`,`تاريخ الطلب إلى`],"Prompt dates are inclusive, use your time zone, and filter the turns inside each session, not the list. Empty dates include every turn.":[`提示日期包含首尾两天,按你所在时区计算,只筛选每个会话中的对话轮次,不筛选列表。留空则包含所有轮次。`,`تواريخ الطلب شاملة لليومين، وتُحسب بمنطقتك الزمنية، وتُصفّي الأدوار داخل كل جلسة لا القائمة. تركها فارغة يشمل كل الأدوار.`],"Sessions with directories that no longer exist":[`目录已不存在的会话`,`جلسات لم تعد مجلداتها موجودة`],"Show them and add a directory map":[`显示它们并添加目录映射`,`اعرضها وأضف تعيين مجلد`],Selected:[`已选择`,`المحدد`],"Select all matching":[`选择所有匹配项`,`تحديد كل المطابق`],"Clear selection":[`清除选择`,`مسح التحديد`],Select:[`选择`,`تحديد`],Created:[`创建时间`,`تاريخ الإنشاء`],"Resolved by":[`解析方式`,`طريقة التحديد`],recorded:[`记录的目录`,`المجلد المسجّل`],mapped:[`目录映射`,`تعيين مجلد`],"project root":[`项目根目录`,`جذر المشروع`],missing:[`缺失`,`مفقود`],"No sessions match.":[`没有匹配的会话。`,`لا توجد جلسات مطابقة.`],Previous:[`上一页`,`السابق`],Next:[`下一页`,`التالي`],None:[`无`,`لا شيء`],"Configured, not tested.":[`已配置,未测试。`,`مُعدّ، لم يُختبر.`],"Test models in Health":[`在健康检查中测试模型`,`اختبر النماذج في قسم السلامة`],Import:[`导入`,`استيراد`],sessions:[`个会话`,`جلسات`],"List sessions first.":[`请先列出会话。`,`اعرض الجلسات أولاً.`],"Options changed. Refresh the session list first.":[`选项已更改。请先刷新会话列表。`,`تغيّرت الخيارات. حدّث قائمة الجلسات أولاً.`],"Select at least one session.":[`请至少选择一个会话。`,`حدّد جلسة واحدة على الأقل.`],"Select at most 1000 sessions one by one, or use Select all matching.":[`逐个选择最多 1000 个会话,或使用“选择所有匹配项”。`,`حدّد 1000 جلسة كحد أقصى واحدة تلو الأخرى، أو استخدم «تحديد كل المطابق».`],"Model readiness is unknown. Reload the page.":[`无法确定模型是否就绪。请重新加载页面。`,`حالة جاهزية النموذج غير معروفة. أعد تحميل الصفحة.`],"No import model is ready. Connect a model in OpenCode or complete the external API settings.":[`没有可用的导入模型。请在 OpenCode 中连接模型,或补全外部 API 设置。`,`لا يوجد نموذج استيراد جاهز. اربط نموذجاً في OpenCode أو أكمل إعدادات واجهة API الخارجية.`],"The external API is not ready":[`外部 API 未就绪`,`واجهة API الخارجية غير جاهزة`],"The external API has no memoryModel in the global config":[`全局配置中缺少外部 API 的 memoryModel`,`لا يحتوي الإعداد العام على memoryModel لواجهة API الخارجية`],"The external API has no memoryApiUrl in the global config":[`全局配置中缺少外部 API 的 memoryApiUrl`,`لا يحتوي الإعداد العام على memoryApiUrl لواجهة API الخارجية`],"The external API key is missing in the OpenCode process; check memoryApiKey and its env:// or file:// source":[`OpenCode 进程中缺少外部 API 密钥;请检查 memoryApiKey 及其 env:// 或 file:// 来源`,`مفتاح واجهة API الخارجية غير موجود في عملية OpenCode؛ تحقّق من memoryApiKey ومصدره env:// أو file://`],"The memoryProvider in the global config is not supported for imports":[`全局配置中的 memoryProvider 不支持导入`,`مزوّد memoryProvider في الإعداد العام غير مدعوم للاستيراد`],"Pi sessions folder or one .jsonl session file":[`Pi 会话文件夹或单个 .jsonl 会话文件`,`مجلد جلسات Pi أو ملف جلسة ‎.jsonl واحد`],"OpenCode database file":[`OpenCode 数据库文件`,`ملف قاعدة بيانات OpenCode`],"Absolute path, for example on a mounted volume":[`绝对路径,例如已挂载卷上的路径`,`مسار مطلق، مثلاً على وحدة تخزين مركّبة`],"Use this source":[`使用此来源`,`استخدم هذا المصدر`],Browse:[`浏览`,`استعراض`],"Use the default location":[`使用默认位置`,`استخدم الموقع الافتراضي`],"Chosen source":[`已选来源`,`المصدر المختار`],Choose:[`选择`,`اختيار`],"Only the first 500 entries are shown.":[`仅显示前 500 项。`,`تُعرض أول 500 عنصر فقط.`],Log:[`日志`,`السجل`],"Capture attempts only":[`仅显示捕获尝试`,`محاولات الالتقاط فقط`],Refresh:[`刷新`,`تحديث`],"Copy log path":[`复制日志路径`,`نسخ مسار السجل`],"Log lines":[`日志行`,`أسطر السجل`],"No log has been written yet.":[`尚未写入日志。`,`لم يُكتب سجل بعد.`],"Loading log…":[`正在加载日志…`,`جارٍ تحميل السجل…`]};function Wp(e,t){return t===`en`?e:Up[e]?.[t===`zh`?0:1]??e}function Gp(){let{language:e}=kt();return t=>Wp(t,e)}function Kp(){let e=Gp(),[t,n]=(0,_.useState)(),[r,i]=(0,_.useState)({}),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=!0;Hp(`/api/settings`).then(t=>{e&&n(t)}).catch(t=>{e&&o(t.message)});for(let t of[`opencode`,`pi`])Hp(`/api/settings/models?host=${t}`).then(n=>{e&&i(e=>({...e,[t]:n}))}).catch(()=>{e&&i(e=>({...e,[t]:{available:!1}}))});return()=>{e=!1}},[]);async function l(r,i){if(!t)return;let a=`${r}Provider`,s=`${r}Model`,l=i.indexOf(`/`);if(i!==`inherit`&&(l<1||l===i.length-1)){o(e(`Enter a model as provider/model.`));return}let u=i===`inherit`?{[s]:`inherit`}:{[a]:i.slice(0,l),[s]:i.slice(l+1)};c(!0);try{let r=await Hp(`/api/settings`,{method:`PATCH`,body:JSON.stringify({edits:u,revision:t.revision})});n(await Hp(`/api/settings`)),o(e(r.migratedLegacy?`Saved. OMMS now reads ~/.config/omms/omms.jsonc. The legacy config was kept.`:`Saved. New capture and profile work uses these settings.`))}catch(r){n(await Hp(`/api/settings`).catch(()=>t)),o(`${r.message}. ${e(`Current settings were reloaded; check the values and save again.`)}`)}finally{c(!1)}}return(0,H.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-border bg-card p-4`,"aria-label":e(`Models`),children:[(0,H.jsx)(`h2`,{className:`text-lg font-medium`,children:e(`Models`)}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[e(`External API fallback`),`: `,t?.fallback.model??e(`none`),` (`,e(t?.fallback.configured?`ready`:`not ready`),`).`]}),[`opencode`,`pi`].map(e=>(0,H.jsx)(qp,{host:e,model:t?.settings[`${e}Model`],provider:t?.settings[`${e}Provider`],effective:e===`pi`?t?.effective.pi.kind:t?.effective.opencode.mode??`unready`,list:r[e],busy:s||!t,onSave:t=>l(e,t)},e)),(0,H.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[e(`Credentials (values hidden)`),`:`,` `,t&&Object.entries(t.secrets).map(([t,n])=>(0,H.jsxs)(`span`,{className:`me-3`,children:[t,`: `,n.set?`${e(`set`)} (${n.source})`:e(`not set`)]},t))]}),a&&(0,H.jsx)(`p`,{role:`status`,className:`text-sm`,children:a})]})}function qp({host:e,model:t,provider:n,effective:r,list:i,busy:a,onSave:o}){let s=Gp(),c=t?.globalValue===`inherit`||!t?.globalValue?`inherit`:`${n?.globalValue??``}/${t.globalValue}`,[l,u]=(0,_.useState)(),[d,f]=(0,_.useState)(),[p,m]=(0,_.useState)(),h=l??(c===`inherit`?`inherit`:`manual`),g=i?.models??[],v=c===`inherit`?``:c,y=p||v||(g[0]?`${g[0].provider}/${g[0].model}`:`typed`),b=!g.some(e=>`${e.provider}/${e.model}`===y),x=d??v;return(0,H.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border p-3`,children:[(0,H.jsx)(`h3`,{className:`font-medium`,children:e===`pi`?`Pi`:`OpenCode`}),(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[s(`Effective model`),`:`,` `,t?.value===`inherit`||r===`session`?s(`session`):r===`manual`?s(`external API`):r===`unready`?s(`unavailable`):`${n?.value??``}/${t?.value??``}`]}),(t?.source===`project`||n?.source===`project`)&&(0,H.jsx)(`p`,{className:`text-xs text-amber-600`,children:s(`Project override is active. Changes to the global file may not take effect here.`)}),(0,H.jsx)(`label`,{className:`block text-sm`,htmlFor:`${e}-model`,children:s(`Model choice`)}),(0,H.jsxs)(`select`,{id:`${e}-model`,className:`w-full rounded-lg border border-border bg-background p-2 text-sm`,value:h,onChange:e=>u(e.target.value),children:[(0,H.jsx)(`option`,{value:`inherit`,children:s(`Session model`)}),(0,H.jsx)(`option`,{value:`manual`,children:s(`Manual model`)})]}),h===`manual`&&i?.available&&g.length>0&&(0,H.jsxs)(`select`,{className:`w-full rounded-lg border border-border bg-background p-2 text-sm`,"aria-label":`${e===`pi`?`Pi`:`OpenCode`} ${s(`Model`)}`,value:b?`typed`:y,onChange:e=>m(e.target.value),children:[g.map(e=>(0,H.jsxs)(`option`,{value:`${e.provider}/${e.model}`,children:[e.name,` (`,e.provider,`/`,e.model,`)`]},`${e.provider}/${e.model}`)),(0,H.jsx)(`option`,{value:`typed`,children:s(`Manual provider/model`)})]}),h===`manual`&&b&&(0,H.jsx)(`input`,{className:`w-full rounded-lg border border-border bg-background p-2 text-sm`,"aria-label":`${e} ${s(`Manual provider/model`)}`,placeholder:`provider/model`,value:x,onChange:e=>{f(e.target.value),m(`typed`)}}),h===`manual`&&i&&!i.available&&(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`Model list unavailable. Enter provider/model manually.`)}),(0,H.jsx)(`button`,{type:`button`,className:`rounded-lg border border-border px-3 py-1.5 text-sm`,disabled:a,onClick:()=>o(h===`inherit`?`inherit`:b?x.trim():y),children:s(`Save model`)})]})}function Jp(){let e=Gp(),[t,n]=(0,_.useState)(7),[r,i]=(0,_.useState)(),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(``),p=(0,_.useCallback)(async e=>{try{let[t,n,r]=await Promise.all([Hp(`/api/settings/diagnostics?days=${e}`),Hp(`/api/settings/traces`),Hp(`/api/settings`)]);i(t),o(n.traces),c(r),f(``)}catch(e){f(e.message)}},[]);(0,_.useEffect)(()=>{p(t)},[t,p]);async function m(n){if(s)try{await Hp(`/api/settings`,{method:`PATCH`,body:JSON.stringify({revision:s.revision,edits:n})}),await p(t)}catch(t){c(await Hp(`/api/settings`).catch(()=>s)),f(`${t.message}. ${e(`Current settings were reloaded; check the values and save again.`)}`)}}async function h(e){try{let t=await Hp(`/api/settings/traces/${encodeURIComponent(e)}`);u(t.content)}catch(e){f(e.message)}}async function g(n){if(window.confirm(`${e(`Delete`)} ${n}?`))try{await Hp(`/api/settings/traces/${encodeURIComponent(n)}`,{method:`DELETE`}),u(``),await p(t)}catch(e){f(e.message)}}let v=s?.settings.captureTrace;return(0,H.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-border bg-card p-4`,"aria-label":e(`Capture diagnostics`),children:[(0,H.jsx)(`h2`,{className:`text-lg font-medium`,children:e(`Capture diagnostics`)}),(0,H.jsxs)(`label`,{className:`text-sm`,children:[e(`Time range`),` `,(0,H.jsxs)(`select`,{className:`ms-2 rounded border border-border bg-background p-1`,value:t,onChange:e=>n(Number(e.target.value)),children:[(0,H.jsx)(`option`,{value:1,children:e(`24 hours`)}),(0,H.jsx)(`option`,{value:7,children:e(`7 days`)}),(0,H.jsx)(`option`,{value:30,children:e(`30 days`)}),(0,H.jsx)(`option`,{value:90,children:e(`90 days`)})]})]}),d&&(0,H.jsx)(`p`,{role:`alert`,children:d}),(0,H.jsx)(`div`,{className:`overflow-x-auto`,children:(0,H.jsxs)(`table`,{className:`w-full text-start text-sm`,children:[(0,H.jsx)(`caption`,{className:`text-start font-medium`,children:e(`Outcomes by model`)}),(0,H.jsx)(`thead`,{children:(0,H.jsx)(`tr`,{children:[`Host / model`,`Saved`,`Skipped`,`Failed`,`Total`].map(t=>(0,H.jsx)(`th`,{scope:`col`,children:e(t)},t))})}),(0,H.jsx)(`tbody`,{children:r?.byModel.map((e,t)=>(0,H.jsxs)(`tr`,{children:[(0,H.jsxs)(`td`,{children:[e.host,`: `,e.provider,`/`,e.model]}),(0,H.jsxs)(`td`,{children:[e.saved,` (`,Math.round(100*e.saved/e.total),`%)`]}),(0,H.jsxs)(`td`,{children:[e.skipped,` (`,Math.round(100*e.skipped/e.total),`%)`]}),(0,H.jsxs)(`td`,{children:[e.failed,` (`,Math.round(100*e.failed/e.total),`%)`]}),(0,H.jsx)(`td`,{children:e.total})]},`${e.host}-${e.provider}-${e.model}-${t}`))})]})}),(0,H.jsxs)(`div`,{className:`text-sm`,children:[(0,H.jsx)(`h3`,{className:`font-medium`,children:e(`Failure reasons`)}),r?.byReason.map((e,t)=>(0,H.jsxs)(`p`,{children:[e.host,`: `,e.reason,` (`,e.count,`)`]},`${e.host}-${e.reason}-${t}`))]}),(0,H.jsx)(`div`,{className:`max-h-52 overflow-auto text-sm`,children:(0,H.jsxs)(`table`,{className:`w-full min-w-max`,children:[(0,H.jsx)(`caption`,{className:`text-start font-medium`,children:e(`Recent attempts`)}),(0,H.jsx)(`thead`,{children:(0,H.jsx)(`tr`,{children:[`Time`,`Host`,`Source`,`Session`,`Path`,`Model`,`Stop`,`Blocks`,`Prompt`,`Reply`,`Duration`,`Outcome`,`Reason`].map(t=>(0,H.jsx)(`th`,{scope:`col`,className:`pe-3 text-start`,children:e(t)},t))})}),(0,H.jsx)(`tbody`,{children:r?.recent.map((e,t)=>(0,H.jsx)(`tr`,{children:[new Date(e.timestamp).toLocaleString(),e.host,e.sourceType,e.sessionId,e.path,`${e.provider??``}/${e.model??``}`,e.stopReason,e.blockTypes?.join(`, `),e.promptChars,e.replyChars,e.durationMs,e.outcome,e.reason].map((e,t)=>(0,H.jsx)(`td`,{className:`pe-3`,children:e??``},t))},`${e.timestamp}-${t}`))})]})}),(0,H.jsxs)(`div`,{className:`space-y-2 border-t border-border pt-3 text-sm`,children:[(0,H.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:v?.value===!0,disabled:!s,onChange:t=>{t.target.checked&&!window.confirm(e(`Traces can contain conversation content after redaction. Keep tracing off unless you need it for debugging.`))||m({captureTrace:t.target.checked})}}),` `,e(`Save capture traces`)]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`Traces can contain conversation content after redaction. Keep tracing off unless you need it for debugging.`)}),v?.source===`project`&&(0,H.jsx)(`p`,{className:`text-xs text-amber-600`,children:e(`This project turns tracing off. The global switch cannot turn it on here.`)}),[`captureTraceRetentionDays`,`captureAttemptRetentionDays`].map(t=>(0,H.jsxs)(`label`,{className:`block`,children:[e(t===`captureTraceRetentionDays`?`Trace retention (days)`:`Attempt retention (days)`),` `,(0,H.jsx)(`input`,{type:`number`,min:1,className:`ms-2 w-20 rounded border border-border bg-background p-1`,defaultValue:Number(s?.settings[t]?.value??30),onBlur:e=>{let n=Number(e.target.value);Number.isSafeInteger(n)&&n>0&&n!==s?.settings[t]?.value&&m({[t]:n})}},`${t}-${s?.settings[t]?.value}`)]},t)),(0,H.jsx)(`h3`,{className:`font-medium`,children:e(`Trace files`)}),a.map(t=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(`span`,{children:[t.file,` (`,t.size,` bytes)`]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>void h(t.file),children:e(`View`)}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>void g(t.file),children:e(`Delete`)})]},t.file)),l&&(0,H.jsx)(`pre`,{className:`max-h-60 overflow-auto whitespace-pre-wrap break-words rounded bg-background p-2 text-xs`,children:l})]})]})}function Yp(){let e=Gp(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(``);async function s(e){i(!0);try{let t=await Hp(`/api/settings/health`,{method:`POST`,body:JSON.stringify({testModels:e})});n(t.checks),o(``)}catch(e){o(e.message)}finally{i(!1)}}return(0,H.jsxs)(`section`,{id:`settings-health`,className:`space-y-3 rounded-xl border border-border bg-card p-4`,"aria-label":e(`Health`),children:[(0,H.jsx)(`h2`,{className:`text-lg font-medium`,children:e(`Health`)}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(`button`,{className:`rounded-lg border border-border px-3 py-1.5 text-sm`,disabled:r,onClick:()=>void s(!1),children:e(`Run checks`)}),(0,H.jsx)(`button`,{className:`rounded-lg border border-border px-3 py-1.5 text-sm`,disabled:r,onClick:()=>void s(!0),children:e(`Run checks and test models`)})]}),r&&(0,H.jsx)(`p`,{role:`status`,children:e(`Checking…`)}),a&&(0,H.jsx)(`p`,{role:`alert`,children:a}),(0,H.jsx)(`ul`,{className:`space-y-2 text-sm`,children:t.map(t=>(0,H.jsxs)(`li`,{className:`rounded-lg border border-border p-2`,children:[(0,H.jsx)(`strong`,{className:t.status===`fail`?`text-red-600`:t.status===`warn`?`text-amber-600`:`text-green-600`,children:e(t.status).toUpperCase()}),` `,`· `,e(t.check),`: `,t.reason]},t.check))})]})}function Xp(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);return t?[Number(t[1]),Number(t[2])-1,Number(t[3])]:null}function Zp(e){let t=Xp(e);return t?new Date(t[0],t[1],t[2],0,0,0,0).getTime():void 0}function Qp(e){let t=Xp(e);return t?new Date(t[0],t[1],t[2],23,59,59,999).getTime():void 0}function $p(e,t,n){let r=!n&&e!==null&&e.revision===t.revision;return{page:r?{...t,listedAt:e.listedAt}:t,sameListing:r}}function em(e){let t=Gp(),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(``),f=`rounded border border-border px-3 py-1.5 text-sm disabled:opacity-50`;async function p(t){try{let n=await Hp(`/api/settings/imports/sources/validate`,{method:`POST`,body:JSON.stringify({host:e.host,path:t})});a(n),r(n.displayPath),e.onChoose(n),d(``)}catch(e){d(e.message)}}async function m(t){try{let n=await Hp(`/api/settings/imports/sources/browse`,{method:`POST`,body:JSON.stringify({host:e.host,...t?{path:t}:{}})});s(n),d(``)}catch(e){let t=e.message;/loopback/i.test(t)&&l(!0),d(t)}}function h(){a(null),r(``),s(null),e.onChoose(null)}return(0,H.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,H.jsxs)(`label`,{className:`block`,children:[e.host===`pi`?t(`Pi sessions folder or one .jsonl session file`):t(`OpenCode database file`),(0,H.jsx)(`input`,{className:`mt-1 block w-full rounded border border-border bg-background p-2 font-mono`,value:n,placeholder:t(`Absolute path, for example on a mounted volume`),onChange:e=>r(e.target.value)})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,className:f,disabled:!n.trim(),onClick:()=>void p(n.trim()),children:t(`Use this source`)}),!c&&(0,H.jsx)(`button`,{type:`button`,className:f,onClick:()=>void m(o?.path),children:t(`Browse`)}),i&&(0,H.jsx)(`button`,{type:`button`,className:f,onClick:h,children:t(`Use the default location`)})]}),i&&(0,H.jsxs)(`p`,{role:`status`,children:[t(`Chosen source`),`: `,(0,H.jsx)(`span`,{className:`font-mono`,children:i.displayPath})]}),u&&(0,H.jsx)(`p`,{role:`alert`,children:u}),o&&(0,H.jsxs)(`div`,{className:`rounded border border-border p-2`,children:[(0,H.jsx)(`p`,{className:`font-mono text-xs break-all`,children:o.path}),(0,H.jsxs)(`ul`,{className:`max-h-60 overflow-auto`,children:[o.parent&&(0,H.jsx)(`li`,{children:(0,H.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>void m(o.parent),children:`..`})}),o.entries.map(n=>(0,H.jsxs)(`li`,{className:`flex items-center gap-2`,children:[n.kind===`folder`?(0,H.jsxs)(`button`,{type:`button`,className:`underline`,onClick:()=>void m(n.path),children:[n.name,`/`]}):(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:n.name}),(n.kind!==`folder`||e.host===`pi`)&&(0,H.jsx)(`button`,{type:`button`,className:`text-xs underline`,onClick:()=>void p(n.path),children:t(`Choose`)})]},n.path))]}),o.truncated&&(0,H.jsx)(`p`,{className:`text-xs`,children:t(`Only the first 500 entries are shown.`)})]})]})}var tm=50,nm=1e3,rm={"missing-model":`The external API has no memoryModel in the global config`,"missing-url":`The external API has no memoryApiUrl in the global config`,"missing-key":`The external API key is missing in the OpenCode process; check memoryApiKey and its env:// or file:// source`,"unsupported-provider":`The memoryProvider in the global config is not supported for imports`},im=()=>({mode:`ids`,picked:new Map});function am(e,t){return e.split(`
123
- `).map(e=>e.trim()).filter(Boolean).map(e=>{let n=e.indexOf(`=`);if(n<1||n===e.length-1)throw Error(t);return{from:e.slice(0,n),to:e.slice(n+1)}})}function om(){let e=Gp(),[t,n]=(0,_.useState)(`pi`),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(`current-project`),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(!1),[E,ee]=(0,_.useState)(null),[D,te]=(0,_.useState)(``),[ne,re]=(0,_.useState)(!1),[ie,ae]=(0,_.useState)(!1),[O,oe]=(0,_.useState)(im),[k,A]=(0,_.useState)(null),[se,j]=(0,_.useState)(``),[ce,M]=(0,_.useState)(null),[N,P]=(0,_.useState)(``);(0,_.useEffect)(()=>{Hp(`/api/settings/imports/readiness`).then(e=>{A(e);let t=e.opencode.models[0];j(t?`${t.provider}/${t.model}`:e.external.state===`ready`?`external`:``)}).catch(()=>A(null)),Hp(`/api/settings/imports/current`).then(e=>M(e.job)).catch(()=>{})},[]),(0,_.useEffect)(()=>{if(ce?.state!==`running`&&ce?.state!==`cancelling`)return;let e=setInterval(()=>{Hp(`/api/settings/imports/current`).then(e=>M(e.job)).catch(e=>P(e.message))},1e3);return()=>clearInterval(e)},[ce?.state]);let le=JSON.stringify([t,r?.sourceToken,a,s,l]),ue=!!E&&(ne||le!==D);function de(){let n=am(l,e(`Directory maps must be old=new, one per line`));return{host:t,...r?{source:r.sourceToken}:{},scope:a,...a===`current-project`&&s?{project:s}:{},pathMaps:n}}async function fe(e,t){ae(!0);try{let n=await Hp(`/api/settings/imports/sessions`,{method:`POST`,body:JSON.stringify({...de(),offset:e,limit:tm,refresh:t})}),r=$p(E,n,t);r.sameListing||oe(im()),ee(r.page),te(le),re(!1),P(``)}catch(e){P(e.message)}finally{ae(!1)}}let pe=E?E.total-(a===`all-projects`?E.unresolvedCount:0):0,F=O.mode===`all`?pe-O.excluded.size:O.picked.size,me=e=>O.mode===`all`?!O.excluded.has(e.key):O.picked.has(e.key);function I(e){if(!(!e.selectable||!e.directory)){if(O.mode===`all`){let t=new Set(O.excluded);t.has(e.key)?t.delete(e.key):t.add(e.key),oe({mode:`all`,excluded:t})}else{let t=new Map(O.picked);t.has(e.key)?t.delete(e.key):t.set(e.key,e.directory),oe({mode:`ids`,picked:t})}}}let he=!b||!S,ge=t===`pi`&&k?.piReader.available===!1,_e=he?k?se?se===`external`&&k.external.state!==`ready`?e(rm[k.external.state]??`The external API is not ready`):null:e(`No import model is ready. Connect a model in OpenCode or complete the external API settings.`):e(`Model readiness is unknown. Reload the page.`):null,ve=E?ue?e(`Options changed. Refresh the session list first.`):F===0?e(`Select at least one session.`):O.mode===`ids`&&O.picked.size>nm?e(`Select at most 1000 sessions one by one, or use Select all matching.`):null:e(`List sessions first.`),ye=ce?.state===`running`||ce?.state===`cancelling`;async function be(n){if(E)try{let r=d?Zp(d):void 0,i=p?Qp(p):void 0,o={host:t,source:E.source.sourceToken,selection:O.mode===`all`?{mode:`all`,excludedKeys:[...O.excluded],revision:E.revision,listedAt:E.listedAt}:{mode:`ids`,sessions:[...O.picked].map(([e,t])=>({key:e,directory:t})),listedAt:E.listedAt},options:{dryRun:n,force:v,skipMemories:b,skipProfile:S,scope:a,...a===`current-project`&&s?{project:s}:{},...r===void 0?{}:{since:r},...i===void 0?{}:{until:i},...h?{profileBatch:Number(h)}:{},pathMaps:am(l,e(`Directory maps must be old=new, one per line`))},...se?{modelChoice:se}:{}},c=await Hp(`/api/settings/imports`,{method:`POST`,body:JSON.stringify(o)});M(c),P(``)}catch(e){let t=e.message;/out of date|changed|no longer/i.test(t)&&re(!0),P(t)}}async function xe(){try{let e=await Hp(`/api/settings/imports/current/cancel`,{method:`POST`,body:`{}`});M(e.job)}catch(e){P(e.message)}}function Se(){o(`all-projects`),T(!0)}let Ce={recorded:e(`recorded`),mapped:e(`mapped`),worktree:e(`project root`),unresolved:e(`missing`)},we=`mt-1 block w-full rounded border border-border bg-background p-2`,Te=`rounded border border-border px-3 py-1.5 text-sm disabled:opacity-50`;return(0,H.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-border bg-card p-4`,"aria-label":e(`Import and backfill`),children:[(0,H.jsx)(`h2`,{className:`text-lg font-medium`,children:e(`Import and backfill`)}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-sm`,children:[e(`History host`),(0,H.jsxs)(`select`,{className:we,value:t,onChange:e=>{n(e.target.value),i(null),ee(null),oe(im())},children:[(0,H.jsx)(`option`,{value:`pi`,children:`Pi`}),(0,H.jsx)(`option`,{value:`opencode`,children:`OpenCode`})]})]}),(0,H.jsx)(`button`,{type:`button`,className:Te,disabled:ie,onClick:()=>void fe(0,!0),children:e(E?`Refresh list`:`List sessions`)}),(0,H.jsx)(`button`,{type:`button`,className:Te,onClick:()=>T(!w),children:e(w?`Hide advanced options`:`Advanced options`)})]}),(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e(`Source`),`: `,r?.displayPath??E?.source.displayPath??e(`default location`),` · `,e(a===`current-project`?`Current project`:`All projects`)]}),ge&&(0,H.jsx)(`p`,{role:`alert`,children:k?.piReader.reason}),w&&(0,H.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,children:[(0,H.jsx)(em,{host:t,onChoose:i}),(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,H.jsxs)(`label`,{className:`text-sm`,children:[e(`Scope`),(0,H.jsxs)(`select`,{className:we,value:a,onChange:e=>o(e.target.value),children:[(0,H.jsx)(`option`,{value:`current-project`,children:e(`Current project`)}),(0,H.jsx)(`option`,{value:`all-projects`,children:e(`All projects`)})]})]}),a===`current-project`&&(0,H.jsxs)(`label`,{className:`text-sm`,children:[e(`Project directory`),(0,H.jsx)(`input`,{className:we,value:s,onChange:e=>c(e.target.value),placeholder:e(`Current directory`)})]}),(0,H.jsxs)(`label`,{className:`text-sm`,children:[e(`Prompt date from`),(0,H.jsx)(`input`,{type:`date`,className:we,value:d,onChange:e=>f(e.target.value)})]}),(0,H.jsxs)(`label`,{className:`text-sm`,children:[e(`Prompt date to`),(0,H.jsx)(`input`,{type:`date`,className:we,value:p,onChange:e=>m(e.target.value)})]}),(0,H.jsxs)(`label`,{className:`text-sm`,children:[e(`Profile batch size`),(0,H.jsx)(`input`,{inputMode:`numeric`,className:we,value:h,onChange:e=>g(e.target.value)})]})]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`Prompt dates are inclusive, use your time zone, and filter the turns inside each session, not the list. Empty dates include every turn.`)}),(0,H.jsxs)(`label`,{className:`block text-sm`,children:[e(`Directory maps (old=new, one per line)`),(0,H.jsx)(`textarea`,{className:we,rows:2,value:l,onChange:e=>u(e.target.value)})]}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-3 text-sm`,children:[[`Force reimport`,v,y],[`Skip memories`,b,x],[`Skip profile`,S,C]].map(([t,n,r])=>(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked)}),` `,e(t)]},t))})]}),ue&&E&&(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-amber-600`,children:e(`Options changed. Refresh the session list first.`)}),E&&a===`current-project`&&E.unresolvedCount>0&&(0,H.jsxs)(`p`,{className:`text-sm`,children:[e(`Sessions with directories that no longer exist`),`: `,E.unresolvedCount,`.`,` `,(0,H.jsx)(`button`,{type:`button`,className:`underline`,onClick:Se,children:e(`Show them and add a directory map`)})]}),E&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,H.jsxs)(`span`,{role:`status`,children:[e(`Selected`),`: `,F,` / `,pe]}),(0,H.jsxs)(`button`,{type:`button`,className:Te,disabled:pe===0,onClick:()=>oe({mode:`all`,excluded:new Set}),children:[e(`Select all matching`),` (`,pe,`)`]}),(0,H.jsx)(`button`,{type:`button`,className:Te,onClick:()=>oe(im()),children:e(`Clear selection`)})]}),(0,H.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,H.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{className:`text-muted-foreground`,children:[(0,H.jsx)(`th`,{className:`p-1`,children:(0,H.jsx)(`span`,{className:`sr-only`,children:e(`Select`)})}),(0,H.jsx)(`th`,{className:`p-1`,children:e(`Created`)}),(0,H.jsx)(`th`,{className:`p-1`,children:e(`Session`)}),(0,H.jsx)(`th`,{className:`p-1`,children:e(`Project directory`)}),(0,H.jsx)(`th`,{className:`p-1`,children:e(`Resolved by`)})]})}),(0,H.jsx)(`tbody`,{children:E.rows.map(t=>(0,H.jsxs)(`tr`,{className:`border-t border-border`,children:[(0,H.jsx)(`td`,{className:`p-1`,children:(0,H.jsx)(`input`,{type:`checkbox`,"aria-label":`${e(`Select`)} ${t.sessionId??t.key}`,checked:t.selectable&&me(t),disabled:!t.selectable,onChange:()=>I(t)})}),(0,H.jsx)(`td`,{className:`p-1 whitespace-nowrap`,children:t.createdAt?new Date(t.createdAt).toLocaleString():`—`}),(0,H.jsx)(`td`,{className:`p-1 font-mono text-xs`,children:t.sessionId??t.key}),(0,H.jsx)(`td`,{className:`p-1 font-mono text-xs break-all`,children:t.directory??t.recordedDirectory??`—`}),(0,H.jsx)(`td`,{className:`p-1`,children:Ce[t.via]})]},t.key))})]}),E.total===0&&(0,H.jsx)(`p`,{className:`text-sm`,children:e(`No sessions match.`)})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,H.jsx)(`button`,{type:`button`,className:Te,disabled:ie||E.offset===0,onClick:()=>void fe(Math.max(0,E.offset-tm),!1),children:e(`Previous`)}),(0,H.jsxs)(`span`,{children:[E.total?E.offset+1:0,`–`,Math.min(E.offset+tm,E.total),` /`,` `,E.total]}),(0,H.jsx)(`button`,{type:`button`,className:Te,disabled:ie||E.offset+tm>=E.total,onClick:()=>void fe(E.offset+tm,!1),children:e(`Next`)})]})]}),(0,H.jsxs)(`label`,{className:`block text-sm`,children:[e(`Import model`),(0,H.jsxs)(`select`,{className:we,value:se,onChange:e=>j(e.target.value),children:[(0,H.jsx)(`option`,{value:``,children:e(`None`)}),k?.opencode.models.map(e=>(0,H.jsxs)(`option`,{value:`${e.provider}/${e.model}`,children:[e.name,` (`,e.provider,`/`,e.model,`)`]},`${e.provider}/${e.model}`)),(0,H.jsxs)(`option`,{value:`external`,children:[e(`Saved external API`),k?.external.model?` (${k.external.model})`:``,k&&k.external.state!==`ready`?` — ${e(`not ready`)}`:``]})]})]}),(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e(`Configured, not tested.`),` `,(0,H.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>document.getElementById(`settings-health`)?.scrollIntoView(),children:e(`Test models in Health`)})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,className:Te,disabled:ye||ge||!!ve,onClick:()=>void be(!0),children:e(`Preview (dry run)`)}),(0,H.jsx)(`button`,{type:`button`,className:Te,disabled:ye||ge||!!ve||!!_e,onClick:()=>void be(!1),children:e(`Start import`)}),ye&&(0,H.jsx)(`button`,{type:`button`,className:Te,disabled:ce?.state===`cancelling`,onClick:()=>void xe(),children:e(`Cancel after current unit`)})]}),(ve||_e)&&!ye&&(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:ve??_e}),N&&(0,H.jsx)(`p`,{role:`alert`,children:N}),ce&&(0,H.jsxs)(`div`,{role:`status`,className:`text-sm`,children:[ce.host,` · `,ce.dryRun?e(`Preview (dry run)`):e(`Import`),` · `,e(ce.state),` ·`,` `,ce.sessions,` `,e(`sessions`),` · `,ce.processed,`/`,ce.total,` `,e(`units`),ce.error&&(0,H.jsx)(`p`,{role:`alert`,children:ce.error}),ce.report&&(0,H.jsx)(`pre`,{className:`mt-2 overflow-auto whitespace-pre-wrap rounded bg-background p-3 text-xs`,children:ce.report})]})]})}function sm(){let e=Gp(),[t,n]=(0,_.useState)(!1),[r,i]=(0,_.useState)(),[a,o]=(0,_.useState)(``);async function s(e){try{i(await Hp(`/api/settings/log?lines=200${e?`&filter=capture`:``}`)),o(``)}catch(e){o(e.message)}}return(0,_.useEffect)(()=>{s(t)},[t]),(0,H.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-border bg-card p-4`,"aria-label":e(`Log`),children:[(0,H.jsx)(`h2`,{className:`text-lg font-medium`,children:e(`Log`)}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-sm`,children:[(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked)}),` `,e(`Capture attempts only`)]}),(0,H.jsx)(`button`,{type:`button`,className:`rounded-lg border border-border px-3 py-1`,onClick:()=>void s(t),children:e(`Refresh`)}),r&&(0,H.jsx)(`button`,{type:`button`,className:`rounded-lg border border-border px-3 py-1`,onClick:()=>void navigator.clipboard.writeText(r.path),children:e(`Copy log path`)})]}),(0,H.jsx)(`p`,{className:`break-all text-xs text-muted-foreground`,children:r?.path}),a&&(0,H.jsx)(`p`,{role:`alert`,children:a}),(0,H.jsx)(`pre`,{className:`max-h-80 overflow-auto rounded-lg bg-background p-3 text-xs whitespace-pre-wrap break-words`,"aria-label":e(`Log lines`),children:r?r.lines.length?r.lines.join(`
124
- `):e(`No log has been written yet.`):e(`Loading log…`)})]})}function cm(){return(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsx)(Kp,{}),(0,H.jsx)(Jp,{}),(0,H.jsx)(Yp,{}),(0,H.jsx)(om,{}),(0,H.jsx)(sm,{})]})}var lm=rn(`grid gap-0.5 rounded-2xl border px-4 py-3 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4 group/alert relative w-full`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`text-destructive bg-card *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current`}},defaultVariants:{variant:`default`}});function um({className:e,variant:t,...n}){return(0,H.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:Ar(lm({variant:t}),e),...n})}function dm({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`alert-description`,className:Ar(`text-muted-foreground text-sm [&_p]:leading-relaxed col-start-2`,e),...t})}function fm({...e}){let t=fl();return(0,H.jsx)(lt,{theme:t,className:`toaster group`,style:{"--normal-bg":`var(--color-popover)`,"--normal-text":`var(--color-popover-foreground)`,"--normal-border":`var(--color-border)`},icons:{loading:(0,H.jsx)(le,{className:`size-4 animate-spin`}),success:(0,H.jsx)(se,{className:`size-4`}),error:(0,H.jsx)(F,{className:`size-4`}),info:(0,H.jsx)(N,{className:`size-4`}),warning:(0,H.jsx)(De,{className:`size-4`})},...e})}function pm(e,t,n){return e?t:n}var mm=[``,`feature`,`bug-fix`,`refactor`,`architecture`,`rule`,`documentation`,`discussion`,`analysis`,`configuration`];function hm(){let{t:e,language:t}=kt(),n=Qc(),[r,i]=(0,_.useState)(!1),a=At(),o=jt();(0,_.useEffect)(()=>{let e=Xc();(async()=>{await a.loadTags(),await a.loadMemories(),await a.loadStats(),await a.checkMigrationStatus(),await a.checkAuthWarning()})();let t=setInterval(()=>{a.loadStats(),!a.isSearching&&n===`project`&&a.loadMemories()},3e4);return()=>{e(),clearInterval(t)}},[]);let s=o.loadUserProfile;(0,_.useEffect)(()=>{n===`profile`&&s()},[n,s]);function c(e){e!==t&&(Tt(e),a.loadMemories(),a.loadStats(),n===`profile`&&o.loadUserProfile())}function l(e){e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),Yc(Rc.home))}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(fm,{richColors:!0,position:`bottom-right`}),(0,H.jsxs)(`div`,{className:`flex min-h-svh bg-background text-foreground`,children:[(0,H.jsx)(ml,{open:r,onOpenChange:i,currentView:n,brand:e(`brand`),projectLabel:e(`tab-project`),profileLabel:e(`tab-profile`),langLabel:t.toUpperCase(),languageLabel:e(`nav-language`),themeLabel:e(`nav-theme`),settingsLabel:e(`nav-settings`),closeLabel:e(`nav-close`),onLanguageSelect:c}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,H.jsxs)(`div`,{className:`sticky top-0 z-30 flex items-center gap-2 border-b border-border bg-background/95 px-3 py-2 backdrop-blur md:hidden`,children:[(0,H.jsx)(U,{variant:`ghost`,size:`icon-sm`,onClick:()=>i(!0),"aria-label":e(`nav-menu`),children:(0,H.jsx)(de,{className:`size-4`})}),(0,H.jsx)(`a`,{href:Rc.home,className:`truncate text-sm tracking-wide text-primary`,onClick:l,children:e(`brand`)})]}),(0,H.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex-1 space-y-4 p-4 md:p-6`,children:[a.showAuthWarning?(0,H.jsxs)(um,{variant:`destructive`,children:[(0,H.jsx)(De,{}),(0,H.jsx)(dm,{children:e(`auth-warning-text`)})]}):null,(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,H.jsx)(`h1`,{className:`text-base tracking-wide text-primary`,children:e(n===`project`?`tab-project`:n===`profile`?`tab-profile`:`nav-settings`)}),n===`project`?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:e(`text-total`,{count:pm(a.isSearching,a.totalItems,a.statsTotal)})}),a.refreshing?(0,H.jsx)(ue,{className:`size-3.5 animate-spin`}):null]}):null]}),n===`project`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3 rounded-xl border border-border bg-card p-3`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(_l,{htmlFor:`tag-filter`,children:e(`label-tag`)}),(0,H.jsxs)(`select`,{id:`tag-filter`,className:`flex h-8 min-w-48 rounded-lg border border-border bg-background px-2 text-sm`,value:a.selectedTag,onChange:e=>a.onTagFilterChange(e.currentTarget.value),children:[(0,H.jsx)(`option`,{value:``,children:e(`opt-all-tags`)}),a.tags.map(e=>(0,H.jsx)(`option`,{value:e.tag,children:e.displayName||e.tag},e.tag))]})]}),(0,H.jsxs)(`div`,{className:`flex flex-1 items-end gap-1.5 min-w-56`,children:[(0,H.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,H.jsx)(_l,{htmlFor:`search-input`,className:`sr-only`,children:e(`placeholder-search`)}),(0,H.jsx)(Np,{id:`search-input`,placeholder:e(`placeholder-search`),value:a.searchInput,onChange:e=>a.setSearchInput(e.target.value),onKeyDown:e=>e.key===`Enter`&&a.performSearch()})]}),(0,H.jsx)(U,{variant:`outline`,size:`icon`,onClick:a.performSearch,children:(0,H.jsx)(be,{className:`size-4`})}),a.isSearching?(0,H.jsx)(U,{variant:`outline`,size:`icon`,onClick:a.clearSearch,children:(0,H.jsx)(je,{className:`size-4`})}):null]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,H.jsxs)(U,{variant:`outline`,size:`sm`,onClick:a.runCleanup,children:[(0,H.jsx)(Ee,{className:`size-3.5`}),e(`btn-cleanup`)]}),(0,H.jsxs)(U,{variant:`outline`,size:`sm`,onClick:a.runDeduplication,children:[(0,H.jsx)(ve,{className:`size-3.5`}),e(`btn-deduplicate`)]})]}),a.selectedIds.size>0?(0,H.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2 border-t border-border pt-3`,children:[(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`text-selected`,{count:a.selectedIds.size})}),(0,H.jsx)(U,{variant:`secondary`,size:`xs`,onClick:a.selectAllCurrentPage,children:e(`btn-select-all`)}),(0,H.jsx)(U,{variant:`destructive`,size:`xs`,onClick:a.bulkDelete,children:e(`btn-delete-selected`)}),(0,H.jsx)(U,{variant:`ghost`,size:`xs`,onClick:a.deselectAll,children:e(`btn-deselect-all`)})]}):null]}),a.migrationNeeded?(0,H.jsxs)(um,{variant:`destructive`,className:`space-y-3`,children:[(0,H.jsx)(De,{}),(0,H.jsxs)(dm,{className:`space-y-3`,children:[(0,H.jsx)(`p`,{children:a.migrationMessage||e(`migration-mismatch`)}),(0,H.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,H.jsx)(zi,{checked:a.migrationConfirmed,onCheckedChange:e=>a.setMigrationConfirmed(e===!0),className:`mt-0.5`}),(0,H.jsx)(`span`,{children:e(`migration-understand`)})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(U,{variant:`destructive`,size:`sm`,disabled:!a.migrationConfirmed,onClick:()=>a.runMigration(`fresh-start`),children:e(`btn-fresh-start`)}),(0,H.jsx)(U,{variant:`secondary`,size:`sm`,disabled:!a.migrationConfirmed,onClick:()=>a.runMigration(`re-embed`),children:e(`btn-reembed`)})]})]})]}):null,(0,H.jsx)(Ff,{memories:a.memories,selectedIds:a.selectedIds,currentPage:a.currentPage,totalPages:a.totalPages,totalItems:a.totalItems,isSearching:a.isSearching,loading:a.loadingMemories,error:a.memoriesError,onSelect:a.onSelect,onPageChange:e=>{let t=a.currentPage+e;a.setCurrentPage(t),a.loadMemories({page:t})},onPin:a.pinMemory,onUnpin:a.unpinMemory,onEdit:a.openEdit,onDeleteMemory:a.deleteMemory,onDeletePrompt:a.deletePrompt}),(0,H.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-4 space-y-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm text-muted-foreground`,children:e(`section-add`)}),(0,H.jsxs)(`form`,{className:`space-y-3`,onSubmit:a.addMemory,children:[(0,H.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(_l,{htmlFor:`add-tag`,children:e(`label-tag`)}),(0,H.jsxs)(`select`,{id:`add-tag`,required:!0,className:`flex h-8 w-full rounded-lg border border-border bg-background px-2 text-sm`,value:a.addTag,onChange:e=>a.setAddTag(e.target.value),children:[(0,H.jsx)(`option`,{value:``,children:e(`opt-select-tag`)}),a.tags.map(e=>(0,H.jsx)(`option`,{value:e.tag,children:e.displayName||e.tag},e.tag))]})]}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(_l,{htmlFor:`add-type`,children:e(`label-type`)}),(0,H.jsx)(`select`,{id:`add-type`,className:`flex h-8 w-full rounded-lg border border-border bg-background px-2 text-sm`,value:a.addType,onChange:e=>a.setAddType(e.target.value),children:mm.map(t=>(0,H.jsx)(`option`,{value:t,children:e(t?`opt-${t}`:`opt-other`)},t||`other`))})]}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(_l,{htmlFor:`add-tags`,children:e(`label-tags`)}),(0,H.jsx)(Np,{id:`add-tags`,placeholder:e(`placeholder-tags`),value:a.addTags,onChange:e=>a.setAddTags(e.target.value)})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(_l,{htmlFor:`add-content`,children:e(`label-content`)}),(0,H.jsx)(vl,{id:`add-content`,rows:4,required:!0,placeholder:e(`placeholder-content`),value:a.addContent,onChange:e=>a.setAddContent(e.target.value)})]}),(0,H.jsxs)(U,{type:`submit`,children:[(0,H.jsx)(_e,{className:`size-3.5`}),e(`btn-add-memory`)]})]})]})]}):n===`settings`?(0,H.jsx)(cm,{}):(0,H.jsx)(Bp,{profile:o.userProfile,loading:o.loadingProfile,onRefresh:o.refreshProfile,onCleanup:()=>o.setAiCleanupOpen(!0)})]})]})]}),(0,H.jsx)(yl,{open:a.editOpen,onOpenChange:a.setEditOpen,content:a.editContent,onSave:a.saveEdit}),(0,H.jsx)(Vp,{open:a.tagMigrationOpen,onOpenChange:a.setTagMigrationOpen,count:a.tagMigrationCount,onComplete:()=>{a.loadMemories(),a.loadStats()}}),(0,H.jsx)(Oc,{open:o.aiCleanupOpen,onOpenChange:o.setAiCleanupOpen,profile:o.userProfile,onApplied:o.loadUserProfile})]})}dl();var gm=document.getElementById(`app`);if(!gm)throw Error(`Root element #app not found`);(0,v.createRoot)(gm).render((0,H.jsx)(_.StrictMode,{children:(0,H.jsx)(Ot,{children:(0,H.jsx)(hm,{})})}));
122
+ `):e.evidence:``}function zp(e){return e.evidence?Array.isArray(e.evidence)?e.evidence.length:1:0}function Bp({profile:e,loading:t=!1,onRefresh:n,onCleanup:r}){let{t:i}=kt(),[a,o]=(0,_.useState)({pref:1,pat:1,wf:1}),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(0),[h,g]=(0,_.useState)(`edit`),[v,y]=(0,_.useState)(null),b=(0,_.useMemo)(()=>{if(!e?.exists||!e.profileData)return null;let t=e.profileData;if(typeof t==`string`)try{t=JSON.parse(t)}catch{return null}return t},[e]),x=(0,_.useMemo)(()=>wc(b?.preferences),[b]),S=(0,_.useMemo)(()=>wc(b?.patterns),[b]),C=(0,_.useMemo)(()=>wc(b?.workflows),[b]),w=(0,_.useMemo)(()=>C.map((e,t)=>({item:e,index:t})).sort((e,t)=>(t.item.frequency||0)-(e.item.frequency||0)),[C]),T=Ip(x,a.pref),E=Ip(S,a.pat),ee=Ip(w,a.wf),D=C.length;function ne(e,t,n){let r=(e===`preferences`?x:e===`patterns`?S:C)[t];r&&(f(e),m(t),g(n),y(r),u(!0))}function ie(e,t){return e.indexOf(t)}function ae({page:e,pageKey:t}){return e.total<=Fp?null:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-2`,children:[(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground mr-2`,children:[e.start+1,`-`,Math.min(e.start+Fp,e.total),` / `,e.total]}),Array.from({length:e.totalPages},(e,t)=>t+1).map(n=>(0,H.jsx)(U,{size:`xs`,variant:n===e.page?`default`:`outline`,onClick:()=>o(e=>({...e,[t]:n})),children:n},n))]})}function O({item:e,type:t,fullList:n}){let r=ie(n,e),a=Lp(e);return(0,H.jsxs)(`div`,{className:`rounded-xl border border-border bg-card/50 p-3 space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,H.jsx)(xl,{variant:`outline`,children:e.category||`General`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-0.5 ml-auto`,children:[(0,H.jsx)(U,{variant:`ghost`,size:`icon-xs`,title:i(`btn-edit`)||`Edit`,onClick:()=>ne(t,r,`edit`),children:(0,H.jsx)(I,{className:`size-3`})}),(0,H.jsx)(U,{variant:`ghost`,size:`icon-xs`,title:i(`btn-delete`)||`Delete`,onClick:()=>ne(t,r,`delete`),children:(0,H.jsx)(Te,{className:`size-3`})})]}),(0,H.jsxs)(`div`,{className:`size-9 rounded-full border border-border grid place-items-center text-[10px] tabular-nums shrink-0`,title:`${a}%`,children:[a,`%`]})]}),(0,H.jsx)(`p`,{className:`text-sm`,children:e.description||``}),e.evidence||e.frequency?(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:i(`label-evidence-tooltip`,{count:e.frequency||1}),children:[(0,H.jsx)(we,{className:`size-3`}),e.frequency||1]}),zp(e)>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`·`}),(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:Rp(e),children:[(0,H.jsx)(N,{className:`size-3`}),zp(e),` evidence`]})]}):null]}):null]})}return t&&!e?(0,H.jsx)(`div`,{className:`text-sm text-muted-foreground py-8 text-center`,children:i(`loading-profile`)}):e?.exists?b?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`h3`,{className:`text-base font-medium`,children:e.displayName||e.userId}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsxs)(`span`,{className:`rounded-full bg-muted px-2.5 py-1 text-xs`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:i(`profile-version`)}),(0,H.jsx)(`span`,{className:`ml-1`,children:e.version})]}),(0,H.jsxs)(`span`,{className:`rounded-full bg-muted px-2.5 py-1 text-xs`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:i(`profile-prompts`)}),(0,H.jsx)(`span`,{className:`ml-1`,children:e.totalPromptsAnalyzed})]}),(0,H.jsxs)(`span`,{className:`rounded-full bg-muted px-2.5 py-1 text-xs`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:i(`profile-updated`)}),(0,H.jsx)(`span`,{className:`ml-1`,children:e.lastAnalyzedAt?Sl(e.lastAnalyzedAt):`—`})]}),(0,H.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-1.5`,children:[(0,H.jsxs)(U,{variant:`outline`,size:`sm`,onClick:()=>r?.(),children:[(0,H.jsx)(Se,{className:`size-3.5`}),i(`btn-ai-cleanup`)]}),(0,H.jsxs)(U,{variant:`secondary`,size:`sm`,onClick:()=>n?.(),children:[(0,H.jsx)(ve,{className:`size-3.5`}),i(`btn-refresh`)]}),(0,H.jsxs)(U,{variant:`secondary`,size:`sm`,onClick:()=>c(!0),children:[(0,H.jsx)(ye,{className:`size-3.5`}),`History`]})]})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-2`,children:[(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,H.jsx)(M,{className:`size-4`}),i(`profile-preferences`),(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:x.length})]}),x.length===0?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`empty-preferences`)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:T.items.map(e=>(0,H.jsx)(O,{item:e,type:`preferences`,fullList:x},ie(x,e)))}),(0,H.jsx)(ae,{page:T,pageKey:`pref`})]})]}),(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,H.jsx)(te,{className:`size-4`}),i(`profile-patterns`),(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:S.length})]}),S.length===0?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`empty-patterns`)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:E.items.map(e=>(0,H.jsx)(O,{item:e,type:`patterns`,fullList:S},ie(S,e)))}),(0,H.jsx)(ae,{page:E,pageKey:`pat`})]})]}),(0,H.jsxs)(`section`,{className:`space-y-3 lg:col-span-2`,children:[(0,H.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,H.jsx)(Ae,{className:`size-4`}),i(`profile-workflows`),(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:D})]}),D===0?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`empty-workflows`)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`space-y-2`,children:ee.items.map(e=>{let t=e.item,n=e.index,r=Lp(t);return(0,H.jsxs)(`div`,{className:`rounded-xl border border-border bg-card/50 p-3 space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium flex-1`,children:t.description||``}),(0,H.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,H.jsx)(U,{variant:`ghost`,size:`icon-xs`,onClick:()=>ne(`workflows`,n,`edit`),children:(0,H.jsx)(I,{className:`size-3`})}),(0,H.jsx)(U,{variant:`ghost`,size:`icon-xs`,onClick:()=>ne(`workflows`,n,`delete`),children:(0,H.jsx)(Te,{className:`size-3`})})]}),(0,H.jsxs)(`div`,{className:`size-9 rounded-full border border-border grid place-items-center text-[10px] tabular-nums shrink-0`,children:[r,`%`]})]}),t.steps?.length?(0,H.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:t.steps.map((e,n)=>(0,H.jsxs)(`div`,{className:`contents`,children:[(0,H.jsxs)(`div`,{className:`inline-flex items-center gap-1.5 rounded-lg bg-muted px-2 py-1 text-xs`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:n+1}),(0,H.jsx)(`span`,{children:e})]}),n<(t.steps?.length||0)-1?(0,H.jsx)(re,{className:`size-3 text-muted-foreground`}):null]},n))}):null,(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:i(`label-evidence-tooltip`,{count:t.frequency||1}),children:[(0,H.jsx)(we,{className:`size-3`}),t.frequency||1]}),zp(t)>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`·`}),(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:Rp(t),children:[(0,H.jsx)(N,{className:`size-3`}),zp(t),` evidence`]})]}):null]})]},e.index)})}),(0,H.jsx)(ae,{page:ee,pageKey:`wf`})]})]})]})]}),(0,H.jsx)(Mp,{open:s,onOpenChange:c,profileId:e?.id||``}),(0,H.jsx)(Pp,{open:l,onOpenChange:u,type:d,index:p,action:h,item:v,onSaved:n})]}):null:(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-10 text-muted-foreground`,children:[(0,H.jsx)(Oe,{className:`size-8`}),(0,H.jsx)(`p`,{className:`text-sm`,children:e?.message||i(`empty-preferences`)})]})}function Vp({open:e=!1,count:t=0,onOpenChange:n,onComplete:r}){let{t:i}=kt(),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(0);(0,_.useEffect)(()=>{e&&!a&&(c(i(`migration-found-tags`,{count:t})),u(0))},[e,a,t,i]);function d(e){a&&!e||n?.(e)}async function f(){o(!0),c(i(`status-migration-init`)),u(0);let e=!0,t=0,n=1e3;for(;e&&t<n;){t++;let n=await ut(`/api/migration/tags/run-batch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({batchSize:3})});if(!n.success||!n.data){c(i(`toast-migration-failed`)+`: `+(n.error||``)),o(!1);return}let r=n.data.processed;e=n.data.hasMore;let a=n.data.total;u(a>0?Math.round(r/a*100):0),c(i(`status-migration-progress`,{current:r,total:a})),e&&await new Promise(e=>setTimeout(e,100))}if(t>=n){c(i(`migration-stopped`)),o(!1);return}u(100),c(i(`toast-migration-success`)),L.success(i(`toast-migration-success`)),setTimeout(()=>{o(!1),d(!1),r?.()},2e3)}return(0,H.jsx)(ws,{open:e,onOpenChange:d,children:(0,H.jsxs)(Ds,{className:`sm:max-w-md`,showCloseButton:!a,children:[(0,H.jsx)(Os,{children:(0,H.jsx)(As,{children:i(`modal-migration-title`)})}),(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s}),(0,H.jsx)(`div`,{className:`h-2 rounded-full bg-muted overflow-hidden`,children:(0,H.jsx)(`div`,{className:`h-full bg-primary transition-all duration-200`,style:{width:`${l}%`}})}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`migration-note`)})]}),a?null:(0,H.jsx)(ks,{children:(0,H.jsxs)(U,{onClick:f,children:[(0,H.jsx)(ge,{className:`size-3.5`}),i(`btn-start-migration`)]})})]})})}async function Hp(e,t={}){let n=(t.method??`GET`).toUpperCase(),r=n!==`GET`&&n!==`HEAD`,i=await fetch(e,{...t,headers:{"x-omms-token":window.__OMMS_TOKEN__??``,...r||t.body?{"Content-Type":`application/json`}:{},...t.headers}}),a=await i.json();if(!i.ok)throw Error(a.error??`Request failed (${i.status})`);return a}var Up=new Set,Wp=0;function Gp(e){Wp++;for(let t of Up)t(e)}function Kp(){let e=Wp;return{isCurrent:()=>Wp===e}}async function qp(){try{let e=await Hp(`/api/settings`);return Gp(e),e}catch{return null}}function Jp(e){return Up.add(e),()=>{Up.delete(e)}}function Yp(e,t){return`${e.replace(/\.+$/,``)}. ${t}`}var Xp={Models:[`模型`,`النماذج`],"External API fallback":[`外部 API 备用模型`,`النموذج الاحتياطي عبر واجهة API الخارجية`],none:[`无`,`لا يوجد`],ready:[`就绪`,`جاهز`],"not ready":[`未就绪`,`غير جاهز`],"Credentials (values hidden)":[`凭据(不显示内容)`,`بيانات الاعتماد (القيم مخفية)`],set:[`已设置`,`مضبوط`],"not set":[`未设置`,`غير مضبوط`],"Effective model":[`当前使用模型`,`النموذج المستخدم`],session:[`会话`,`الجلسة`],"external API":[`外部 API`,`واجهة API الخارجية`],unavailable:[`不可用`,`غير متاح`],"Project override is active. Changes to the global file may not take effect here.":[`项目设置优先。全局文件的更改可能不会在此生效。`,`إعدادات المشروع لها الأولوية. قد لا تسري تغييرات الملف العام هنا.`],"Model choice":[`模型选择`,`اختيار النموذج`],"Session model":[`会话模型`,`نموذج الجلسة`],"Manual model":[`手动选择模型`,`اختيار النموذج يدوياً`],"Manual provider/model":[`手动输入提供商/模型`,`إدخال المزوّد/النموذج يدوياً`],"Model list unavailable. Enter provider/model manually.":[`模型列表不可用。请手动输入提供商/模型。`,`قائمة النماذج غير متاحة. أدخل المزوّد/النموذج يدوياً.`],"Save model":[`保存模型`,`حفظ النموذج`],"Enter a model as provider/model.":[`按 提供商/模型 格式输入。`,`أدخل النموذج بصيغة المزوّد/النموذج.`],"Saved. New capture and profile work uses these settings.":[`已保存。下一次捕获和用户画像将使用这些设置。`,`تم الحفظ. ستستخدم عمليات الالتقاط والملف الشخصي الجديدة هذه الإعدادات.`],"Saved. OMMS now reads ~/.config/omms/omms.jsonc. The legacy config was kept.":[`已保存。OMMS 现在读取 ~/.config/omms/omms.jsonc,旧配置保留。`,`تم الحفظ. يقرأ OMMS الآن الملف ~/.config/omms/omms.jsonc مع الاحتفاظ بالإعدادات القديمة.`],"Current settings were reloaded; check the values and save again.":[`已重新加载当前设置;检查数值后再次保存。`,`أُعيد تحميل الإعدادات الحالية. راجع القيم ثم احفظ مجدداً.`],"Capture diagnostics":[`捕获诊断`,`تشخيص الالتقاط`],"Time range":[`时间范围`,`الفترة الزمنية`],"24 hours":[`24 小时`,`24 ساعة`],"7 days":[`7 天`,`7 أيام`],"30 days":[`30 天`,`30 يوماً`],"90 days":[`90 天`,`90 يوماً`],"Outcomes by model":[`各模型结果`,`النتائج حسب النموذج`],"Host / model":[`主机 / 模型`,`المضيف / النموذج`],Saved:[`已保存`,`محفوظ`],Skipped:[`已跳过`,`متجاوز`],Failed:[`失败`,`فشل`],Total:[`总数`,`المجموع`],"Failure reasons":[`失败原因`,`أسباب الفشل`],"Recent attempts":[`最近尝试`,`المحاولات الأخيرة`],Time:[`时间`,`الوقت`],Host:[`主机`,`المضيف`],Source:[`来源`,`المصدر`],Session:[`会话`,`الجلسة`],Path:[`路径`,`المسار`],Model:[`模型`,`النموذج`],Stop:[`结束原因`,`سبب التوقف`],Blocks:[`区块`,`الكتل`],Prompt:[`提示词长度`,`طول الطلب`],Reply:[`回复长度`,`طول الرد`],Duration:[`耗时`,`المدة`],Outcome:[`结果`,`النتيجة`],Reason:[`原因`,`السبب`],"Save capture traces":[`保存捕获追踪`,`حفظ تتبعات الالتقاط`],"Traces can contain conversation content after redaction. Keep tracing off unless you need it for debugging.":[`追踪文件在脱敏后仍可能包含对话内容。仅在调试时开启。`,`قد تحتوي التتبعات على محتوى المحادثة بعد التنقيح. فعّلها عند التصحيح فقط.`],"This project turns tracing off. The global switch cannot turn it on here.":[`此项目已关闭追踪。全局开关无法在此开启。`,`أوقف هذا المشروع التتبع. لا يمكن للمفتاح العام تفعيله هنا.`],"Trace retention (days)":[`追踪保留天数`,`مدة حفظ التتبعات (بالأيام)`],"Attempt retention (days)":[`尝试记录保留天数`,`مدة حفظ المحاولات (بالأيام)`],"Trace files":[`追踪文件`,`ملفات التتبع`],View:[`查看`,`عرض`],Delete:[`删除`,`حذف`],Health:[`健康检查`,`فحص الحالة`],"Config files":[`配置文件`,`ملفات الإعدادات`],"Memory store":[`记忆存储`,`مخزن الذاكرة`],Embedding:[`嵌入模型`,`نموذج التضمين`],"Web binding":[`网页服务绑定`,`ربط خادم الويب`],"OpenCode model":[`OpenCode 模型`,`نموذج OpenCode`],"Pi model":[`Pi 模型`,`نموذج Pi`],"Capture failures (24 hours)":[`捕获失败(24 小时)`,`فشل الالتقاط (24 ساعة)`],"OpenCode model test":[`OpenCode 模型测试`,`اختبار نموذج OpenCode`],"Pi model test":[`Pi 模型测试`,`اختبار نموذج Pi`],"Run checks":[`运行检查`,`تشغيل الفحوصات`],"Run checks and test models":[`运行检查并测试模型`,`تشغيل الفحوصات واختبار النماذج`],"Checking…":[`正在检查…`,`جارٍ الفحص…`],pass:[`通过`,`نجاح`],warn:[`警告`,`تحذير`],fail:[`失败`,`فشل`],"Import and backfill":[`导入和回填`,`الاستيراد والاستكمال`],"History host":[`历史记录主机`,`مضيف السجل`],Scope:[`范围`,`النطاق`],"Current project":[`当前项目`,`المشروع الحالي`],"All projects":[`所有项目`,`كل المشاريع`],"Project directory":[`项目目录`,`مجلد المشروع`],"Current directory":[`当前目录`,`المجلد الحالي`],"Profile batch size":[`用户画像批量大小`,`حجم دفعة الملف الشخصي`],"Directory maps (old=new, one per line)":[`目录映射(旧=新,每行一条)`,`تعيين المجلدات (قديم=جديد، واحد في كل سطر)`],"Force reimport":[`强制重新导入`,`فرض إعادة الاستيراد`],"Skip memories":[`跳过记忆`,`تجاوز الذكريات`],"Skip profile":[`跳过用户画像`,`تجاوز الملف الشخصي`],"Import model":[`导入模型`,`نموذج الاستيراد`],"Saved external API":[`已保存的外部 API`,`واجهة API الخارجية المحفوظة`],"Preview (dry run)":[`预览(不写入)`,`معاينة (تشغيل تجريبي)`],"Start import":[`开始导入`,`بدء الاستيراد`],"Cancel after current unit":[`完成当前单元后取消`,`الإلغاء بعد الوحدة الحالية`],"Directory maps must be old=new, one per line":[`目录映射须为 旧=新,每行一条`,`يجب أن يكون تعيين المجلدات بصيغة قديم=جديد، واحد في كل سطر`],running:[`运行中`,`جارٍ التشغيل`],cancelling:[`正在取消`,`جارٍ الإلغاء`],cancelled:[`已取消`,`أُلغي`],done:[`已完成`,`اكتمل`],failed:[`失败`,`فشل`],units:[`单元`,`وحدات`],"List sessions":[`列出会话`,`عرض الجلسات`],"Refresh list":[`刷新列表`,`تحديث القائمة`],"Advanced options":[`高级选项`,`خيارات متقدمة`],"Hide advanced options":[`隐藏高级选项`,`إخفاء الخيارات المتقدمة`],"default location":[`默认位置`,`الموقع الافتراضي`],"Prompt date from":[`提示日期起`,`تاريخ الطلب من`],"Prompt date to":[`提示日期止`,`تاريخ الطلب إلى`],"Prompt dates are inclusive, use your time zone, and filter the turns inside each session, not the list. Empty dates include every turn.":[`提示日期包含首尾两天,按你所在时区计算,只筛选每个会话中的对话轮次,不筛选列表。留空则包含所有轮次。`,`تواريخ الطلب شاملة لليومين، وتُحسب بمنطقتك الزمنية، وتُصفّي الأدوار داخل كل جلسة لا القائمة. تركها فارغة يشمل كل الأدوار.`],"Sessions with directories that no longer exist":[`目录已不存在的会话`,`جلسات لم تعد مجلداتها موجودة`],"Show them and add a directory map":[`显示它们并添加目录映射`,`اعرضها وأضف تعيين مجلد`],Selected:[`已选择`,`المحدد`],"Select all matching":[`选择所有匹配项`,`تحديد كل المطابق`],"Clear selection":[`清除选择`,`مسح التحديد`],Select:[`选择`,`تحديد`],Created:[`创建时间`,`تاريخ الإنشاء`],"Resolved by":[`解析方式`,`طريقة التحديد`],recorded:[`记录的目录`,`المجلد المسجّل`],mapped:[`目录映射`,`تعيين مجلد`],"project root":[`项目根目录`,`جذر المشروع`],missing:[`缺失`,`مفقود`],"No sessions match.":[`没有匹配的会话。`,`لا توجد جلسات مطابقة.`],Previous:[`上一页`,`السابق`],Next:[`下一页`,`التالي`],None:[`无`,`لا شيء`],"Configured, not tested.":[`已配置,未测试。`,`مُعدّ، لم يُختبر.`],"Test models in Health":[`在健康检查中测试模型`,`اختبر النماذج في قسم السلامة`],Import:[`导入`,`استيراد`],sessions:[`个会话`,`جلسات`],"List sessions first.":[`请先列出会话。`,`اعرض الجلسات أولاً.`],"Options changed. Refresh the session list first.":[`选项已更改。请先刷新会话列表。`,`تغيّرت الخيارات. حدّث قائمة الجلسات أولاً.`],"Select at least one session.":[`请至少选择一个会话。`,`حدّد جلسة واحدة على الأقل.`],"Select at most 1000 sessions one by one, or use Select all matching.":[`逐个选择最多 1000 个会话,或使用“选择所有匹配项”。`,`حدّد 1000 جلسة كحد أقصى واحدة تلو الأخرى، أو استخدم «تحديد كل المطابق».`],"Model readiness is unknown. Reload the page.":[`无法确定模型是否就绪。请重新加载页面。`,`حالة جاهزية النموذج غير معروفة. أعد تحميل الصفحة.`],"No import model is ready. Connect a model in OpenCode or complete the external API settings.":[`没有可用的导入模型。请在 OpenCode 中连接模型,或补全外部 API 设置。`,`لا يوجد نموذج استيراد جاهز. اربط نموذجاً في OpenCode أو أكمل إعدادات واجهة API الخارجية.`],"The external API is not ready":[`外部 API 未就绪`,`واجهة API الخارجية غير جاهزة`],"The external API has no memoryModel in the global config":[`全局配置中缺少外部 API 的 memoryModel`,`لا يحتوي الإعداد العام على memoryModel لواجهة API الخارجية`],"The external API has no memoryApiUrl in the global config":[`全局配置中缺少外部 API 的 memoryApiUrl`,`لا يحتوي الإعداد العام على memoryApiUrl لواجهة API الخارجية`],"The external API key is missing in the OpenCode process; check memoryApiKey and its env:// or file:// source":[`OpenCode 进程中缺少外部 API 密钥;请检查 memoryApiKey 及其 env:// 或 file:// 来源`,`مفتاح واجهة API الخارجية غير موجود في عملية OpenCode؛ تحقّق من memoryApiKey ومصدره env:// أو file://`],"The memoryProvider in the global config is not supported for imports":[`全局配置中的 memoryProvider 不支持导入`,`مزوّد memoryProvider في الإعداد العام غير مدعوم للاستيراد`],"Pi sessions folder or one .jsonl session file":[`Pi 会话文件夹或单个 .jsonl 会话文件`,`مجلد جلسات Pi أو ملف جلسة ‎.jsonl واحد`],"OpenCode database file":[`OpenCode 数据库文件`,`ملف قاعدة بيانات OpenCode`],"Absolute path, for example on a mounted volume":[`绝对路径,例如已挂载卷上的路径`,`مسار مطلق، مثلاً على وحدة تخزين مركّبة`],"Use this source":[`使用此来源`,`استخدم هذا المصدر`],Browse:[`浏览`,`استعراض`],"Use the default location":[`使用默认位置`,`استخدم الموقع الافتراضي`],"Chosen source":[`已选来源`,`المصدر المختار`],Choose:[`选择`,`اختيار`],"Only the first 500 entries are shown.":[`仅显示前 500 项。`,`تُعرض أول 500 عنصر فقط.`],"Reload the page before saving again.":[`再次保存前请重新加载页面。`,`أعد تحميل الصفحة قبل الحفظ مرة أخرى.`],"The current settings could not be reloaded. Reload the page.":[`无法重新加载当前设置。请重新加载页面。`,`تعذّر إعادة تحميل الإعدادات الحالية. أعد تحميل الصفحة.`],Log:[`日志`,`السجل`],"Capture attempts only":[`仅显示捕获尝试`,`محاولات الالتقاط فقط`],Refresh:[`刷新`,`تحديث`],"Copy log path":[`复制日志路径`,`نسخ مسار السجل`],"Log lines":[`日志行`,`أسطر السجل`],"No log has been written yet.":[`尚未写入日志。`,`لم يُكتب سجل بعد.`],"Loading log…":[`正在加载日志…`,`جارٍ تحميل السجل…`]};function Zp(e,t){return t===`en`?e:Xp[e]?.[t===`zh`?0:1]??e}function Qp(){let{language:e}=kt();return t=>Zp(t,e)}function $p(){let e=Qp(),[t,n]=(0,_.useState)(),[r,i]=(0,_.useState)({}),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=!0,t=Kp();Hp(`/api/settings`).then(r=>{e&&t.isCurrent()&&n(r)}).catch(t=>{e&&o(t.message)});for(let t of[`opencode`,`pi`])Hp(`/api/settings/models?host=${t}`).then(n=>{e&&i(e=>({...e,[t]:n}))}).catch(()=>{e&&i(e=>({...e,[t]:{available:!1}}))});let r=Jp(t=>{e&&n(t)});return()=>{e=!1,r()}},[]);async function l(n,r){if(!t)return;let i=`${n}Provider`,a=`${n}Model`,s=r.indexOf(`/`);if(r!==`inherit`&&(s<1||s===r.length-1)){o(e(`Enter a model as provider/model.`));return}let l=r===`inherit`?{[a]:`inherit`}:{[i]:r.slice(0,s),[a]:r.slice(s+1)};c(!0);let u,d;try{u=await Hp(`/api/settings`,{method:`PATCH`,body:JSON.stringify({edits:l,revision:t.revision})})}catch(e){d=e}let f=await qp()!==null;if(c(!1),u){let t=e(u.migratedLegacy?`Saved. OMMS now reads ~/.config/omms/omms.jsonc. The legacy config was kept.`:`Saved. New capture and profile work uses these settings.`);o(f?t:`${t} ${e(`Reload the page before saving again.`)}`)}else o(Yp(d?.message??``,e(f?`Current settings were reloaded; check the values and save again.`:`The current settings could not be reloaded. Reload the page.`)))}return(0,H.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-border bg-card p-4`,"aria-label":e(`Models`),children:[(0,H.jsx)(`h2`,{className:`text-lg font-medium`,children:e(`Models`)}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[e(`External API fallback`),`: `,t?.fallback.model??e(`none`),` (`,e(t?.fallback.configured?`ready`:`not ready`),`).`]}),[`opencode`,`pi`].map(e=>(0,H.jsx)(em,{host:e,model:t?.settings[`${e}Model`],provider:t?.settings[`${e}Provider`],effective:e===`pi`?t?.effective.pi.kind:t?.effective.opencode.mode??`unready`,list:r[e],busy:s||!t,onSave:t=>l(e,t)},e)),(0,H.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[e(`Credentials (values hidden)`),`:`,` `,t&&Object.entries(t.secrets).map(([t,n])=>(0,H.jsxs)(`span`,{className:`me-3`,children:[t,`: `,n.set?`${e(`set`)} (${n.source})`:e(`not set`)]},t))]}),a&&(0,H.jsx)(`p`,{role:`status`,className:`text-sm`,children:a})]})}function em({host:e,model:t,provider:n,effective:r,list:i,busy:a,onSave:o}){let s=Qp(),c=t?.globalValue===`inherit`||!t?.globalValue?`inherit`:`${n?.globalValue??``}/${t.globalValue}`,[l,u]=(0,_.useState)(),[d,f]=(0,_.useState)(),[p,m]=(0,_.useState)(),h=l??(c===`inherit`?`inherit`:`manual`),g=i?.models??[],v=c===`inherit`?``:c,y=p||v||(g[0]?`${g[0].provider}/${g[0].model}`:`typed`),b=!g.some(e=>`${e.provider}/${e.model}`===y),x=d??v;return(0,H.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border p-3`,children:[(0,H.jsx)(`h3`,{className:`font-medium`,children:e===`pi`?`Pi`:`OpenCode`}),(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[s(`Effective model`),`:`,` `,t?.value===`inherit`||r===`session`?s(`session`):r===`manual`?s(`external API`):r===`unready`?s(`unavailable`):`${n?.value??``}/${t?.value??``}`]}),(t?.source===`project`||n?.source===`project`)&&(0,H.jsx)(`p`,{className:`text-xs text-amber-600`,children:s(`Project override is active. Changes to the global file may not take effect here.`)}),(0,H.jsx)(`label`,{className:`block text-sm`,htmlFor:`${e}-model`,children:s(`Model choice`)}),(0,H.jsxs)(`select`,{id:`${e}-model`,className:`w-full rounded-lg border border-border bg-background p-2 text-sm`,value:h,onChange:e=>u(e.target.value),children:[(0,H.jsx)(`option`,{value:`inherit`,children:s(`Session model`)}),(0,H.jsx)(`option`,{value:`manual`,children:s(`Manual model`)})]}),h===`manual`&&i?.available&&g.length>0&&(0,H.jsxs)(`select`,{className:`w-full rounded-lg border border-border bg-background p-2 text-sm`,"aria-label":`${e===`pi`?`Pi`:`OpenCode`} ${s(`Model`)}`,value:b?`typed`:y,onChange:e=>m(e.target.value),children:[g.map(e=>(0,H.jsxs)(`option`,{value:`${e.provider}/${e.model}`,children:[e.name,` (`,e.provider,`/`,e.model,`)`]},`${e.provider}/${e.model}`)),(0,H.jsx)(`option`,{value:`typed`,children:s(`Manual provider/model`)})]}),h===`manual`&&b&&(0,H.jsx)(`input`,{className:`w-full rounded-lg border border-border bg-background p-2 text-sm`,"aria-label":`${e} ${s(`Manual provider/model`)}`,placeholder:`provider/model`,value:x,onChange:e=>{f(e.target.value),m(`typed`)}}),h===`manual`&&i&&!i.available&&(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`Model list unavailable. Enter provider/model manually.`)}),(0,H.jsx)(`button`,{type:`button`,className:`rounded-lg border border-border px-3 py-1.5 text-sm`,disabled:a,onClick:()=>o(h===`inherit`?`inherit`:b?x.trim():y),children:s(`Save model`)})]})}function tm(){let e=Qp(),[t,n]=(0,_.useState)(7),[r,i]=(0,_.useState)(),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(``),p=(0,_.useCallback)(async e=>{let t=Kp();try{let[n,r,a]=await Promise.all([Hp(`/api/settings/diagnostics?days=${e}`),Hp(`/api/settings/traces`),Hp(`/api/settings`)]);i(n),o(r.traces),t.isCurrent()&&c(a),f(``)}catch(e){f(e.message)}},[]);(0,_.useEffect)(()=>{p(t)},[t,p]),(0,_.useEffect)(()=>Jp(e=>c(e)),[]);async function m(n){if(!s)return;let r;try{await Hp(`/api/settings`,{method:`PATCH`,body:JSON.stringify({revision:s.revision,edits:n})})}catch(e){r=e}let i=await qp()!==null;if(!r){await p(t),i||f(e(`Reload the page before saving again.`));return}f(Yp(r.message,e(i?`Current settings were reloaded; check the values and save again.`:`The current settings could not be reloaded. Reload the page.`)))}async function h(e){try{let t=await Hp(`/api/settings/traces/${encodeURIComponent(e)}`);u(t.content)}catch(e){f(e.message)}}async function g(n){if(window.confirm(`${e(`Delete`)} ${n}?`))try{await Hp(`/api/settings/traces/${encodeURIComponent(n)}`,{method:`DELETE`}),u(``),await p(t)}catch(e){f(e.message)}}let v=s?.settings.captureTrace;return(0,H.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-border bg-card p-4`,"aria-label":e(`Capture diagnostics`),children:[(0,H.jsx)(`h2`,{className:`text-lg font-medium`,children:e(`Capture diagnostics`)}),(0,H.jsxs)(`label`,{className:`text-sm`,children:[e(`Time range`),` `,(0,H.jsxs)(`select`,{className:`ms-2 rounded border border-border bg-background p-1`,value:t,onChange:e=>n(Number(e.target.value)),children:[(0,H.jsx)(`option`,{value:1,children:e(`24 hours`)}),(0,H.jsx)(`option`,{value:7,children:e(`7 days`)}),(0,H.jsx)(`option`,{value:30,children:e(`30 days`)}),(0,H.jsx)(`option`,{value:90,children:e(`90 days`)})]})]}),d&&(0,H.jsx)(`p`,{role:`alert`,children:d}),(0,H.jsx)(`div`,{className:`overflow-x-auto`,children:(0,H.jsxs)(`table`,{className:`w-full text-start text-sm`,children:[(0,H.jsx)(`caption`,{className:`text-start font-medium`,children:e(`Outcomes by model`)}),(0,H.jsx)(`thead`,{children:(0,H.jsx)(`tr`,{children:[`Host / model`,`Saved`,`Skipped`,`Failed`,`Total`].map(t=>(0,H.jsx)(`th`,{scope:`col`,children:e(t)},t))})}),(0,H.jsx)(`tbody`,{children:r?.byModel.map((e,t)=>(0,H.jsxs)(`tr`,{children:[(0,H.jsxs)(`td`,{children:[e.host,`: `,e.provider,`/`,e.model]}),(0,H.jsxs)(`td`,{children:[e.saved,` (`,Math.round(100*e.saved/e.total),`%)`]}),(0,H.jsxs)(`td`,{children:[e.skipped,` (`,Math.round(100*e.skipped/e.total),`%)`]}),(0,H.jsxs)(`td`,{children:[e.failed,` (`,Math.round(100*e.failed/e.total),`%)`]}),(0,H.jsx)(`td`,{children:e.total})]},`${e.host}-${e.provider}-${e.model}-${t}`))})]})}),(0,H.jsxs)(`div`,{className:`text-sm`,children:[(0,H.jsx)(`h3`,{className:`font-medium`,children:e(`Failure reasons`)}),r?.byReason.map((e,t)=>(0,H.jsxs)(`p`,{children:[e.host,`: `,e.reason,` (`,e.count,`)`]},`${e.host}-${e.reason}-${t}`))]}),(0,H.jsx)(`div`,{className:`max-h-52 overflow-auto text-sm`,children:(0,H.jsxs)(`table`,{className:`w-full min-w-max`,children:[(0,H.jsx)(`caption`,{className:`text-start font-medium`,children:e(`Recent attempts`)}),(0,H.jsx)(`thead`,{children:(0,H.jsx)(`tr`,{children:[`Time`,`Host`,`Source`,`Session`,`Path`,`Model`,`Stop`,`Blocks`,`Prompt`,`Reply`,`Duration`,`Outcome`,`Reason`].map(t=>(0,H.jsx)(`th`,{scope:`col`,className:`pe-3 text-start`,children:e(t)},t))})}),(0,H.jsx)(`tbody`,{children:r?.recent.map((e,t)=>(0,H.jsx)(`tr`,{children:[new Date(e.timestamp).toLocaleString(),e.host,e.sourceType,e.sessionId,e.path,`${e.provider??``}/${e.model??``}`,e.stopReason,e.blockTypes?.join(`, `),e.promptChars,e.replyChars,e.durationMs,e.outcome,e.reason].map((e,t)=>(0,H.jsx)(`td`,{className:`pe-3`,children:e??``},t))},`${e.timestamp}-${t}`))})]})}),(0,H.jsxs)(`div`,{className:`space-y-2 border-t border-border pt-3 text-sm`,children:[(0,H.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:v?.value===!0,disabled:!s,onChange:t=>{t.target.checked&&!window.confirm(e(`Traces can contain conversation content after redaction. Keep tracing off unless you need it for debugging.`))||m({captureTrace:t.target.checked})}}),` `,e(`Save capture traces`)]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`Traces can contain conversation content after redaction. Keep tracing off unless you need it for debugging.`)}),v?.source===`project`&&(0,H.jsx)(`p`,{className:`text-xs text-amber-600`,children:e(`This project turns tracing off. The global switch cannot turn it on here.`)}),[`captureTraceRetentionDays`,`captureAttemptRetentionDays`].map(t=>(0,H.jsxs)(`label`,{className:`block`,children:[e(t===`captureTraceRetentionDays`?`Trace retention (days)`:`Attempt retention (days)`),` `,(0,H.jsx)(`input`,{type:`number`,min:1,className:`ms-2 w-20 rounded border border-border bg-background p-1`,defaultValue:Number(s?.settings[t]?.value??30),onBlur:e=>{let n=Number(e.target.value);Number.isSafeInteger(n)&&n>0&&n!==s?.settings[t]?.value&&m({[t]:n})}},`${t}-${s?.settings[t]?.value}`)]},t)),(0,H.jsx)(`h3`,{className:`font-medium`,children:e(`Trace files`)}),a.map(t=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(`span`,{children:[t.file,` (`,t.size,` bytes)`]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>void h(t.file),children:e(`View`)}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>void g(t.file),children:e(`Delete`)})]},t.file)),l&&(0,H.jsx)(`pre`,{className:`max-h-60 overflow-auto whitespace-pre-wrap break-words rounded bg-background p-2 text-xs`,children:l})]})]})}function nm(){let e=Qp(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(``);async function s(e){i(!0);try{let t=await Hp(`/api/settings/health`,{method:`POST`,body:JSON.stringify({testModels:e})});n(t.checks),o(``)}catch(e){o(e.message)}finally{i(!1)}}return(0,H.jsxs)(`section`,{id:`settings-health`,className:`space-y-3 rounded-xl border border-border bg-card p-4`,"aria-label":e(`Health`),children:[(0,H.jsx)(`h2`,{className:`text-lg font-medium`,children:e(`Health`)}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(`button`,{className:`rounded-lg border border-border px-3 py-1.5 text-sm`,disabled:r,onClick:()=>void s(!1),children:e(`Run checks`)}),(0,H.jsx)(`button`,{className:`rounded-lg border border-border px-3 py-1.5 text-sm`,disabled:r,onClick:()=>void s(!0),children:e(`Run checks and test models`)})]}),r&&(0,H.jsx)(`p`,{role:`status`,children:e(`Checking…`)}),a&&(0,H.jsx)(`p`,{role:`alert`,children:a}),(0,H.jsx)(`ul`,{className:`space-y-2 text-sm`,children:t.map(t=>(0,H.jsxs)(`li`,{className:`rounded-lg border border-border p-2`,children:[(0,H.jsx)(`strong`,{className:t.status===`fail`?`text-red-600`:t.status===`warn`?`text-amber-600`:`text-green-600`,children:e(t.status).toUpperCase()}),` `,`· `,e(t.check),`: `,t.reason]},t.check))})]})}function rm(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);return t?[Number(t[1]),Number(t[2])-1,Number(t[3])]:null}function im(e){let t=rm(e);return t?new Date(t[0],t[1],t[2],0,0,0,0).getTime():void 0}function am(e){let t=rm(e);return t?new Date(t[0],t[1],t[2],23,59,59,999).getTime():void 0}function om(e,t,n){let r=!n&&e!==null&&e.revision===t.revision;return{page:r?{...t,listedAt:e.listedAt}:t,sameListing:r}}function sm(e){let t=Qp(),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(``),f=`rounded border border-border px-3 py-1.5 text-sm disabled:opacity-50`;async function p(t){try{let n=await Hp(`/api/settings/imports/sources/validate`,{method:`POST`,body:JSON.stringify({host:e.host,path:t})});a(n),r(n.displayPath),e.onChoose(n),d(``)}catch(e){d(e.message)}}async function m(t){try{let n=await Hp(`/api/settings/imports/sources/browse`,{method:`POST`,body:JSON.stringify({host:e.host,...t?{path:t}:{}})});s(n),d(``)}catch(e){let t=e.message;/loopback/i.test(t)&&l(!0),d(t)}}function h(){a(null),r(``),s(null),e.onChoose(null)}return(0,H.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,H.jsxs)(`label`,{className:`block`,children:[e.host===`pi`?t(`Pi sessions folder or one .jsonl session file`):t(`OpenCode database file`),(0,H.jsx)(`input`,{className:`mt-1 block w-full rounded border border-border bg-background p-2 font-mono`,value:n,placeholder:t(`Absolute path, for example on a mounted volume`),onChange:e=>r(e.target.value)})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,className:f,disabled:!n.trim(),onClick:()=>void p(n.trim()),children:t(`Use this source`)}),!c&&(0,H.jsx)(`button`,{type:`button`,className:f,onClick:()=>void m(o?.path),children:t(`Browse`)}),i&&(0,H.jsx)(`button`,{type:`button`,className:f,onClick:h,children:t(`Use the default location`)})]}),i&&(0,H.jsxs)(`p`,{role:`status`,children:[t(`Chosen source`),`: `,(0,H.jsx)(`span`,{className:`font-mono`,children:i.displayPath})]}),u&&(0,H.jsx)(`p`,{role:`alert`,children:u}),o&&(0,H.jsxs)(`div`,{className:`rounded border border-border p-2`,children:[(0,H.jsx)(`p`,{className:`font-mono text-xs break-all`,children:o.path}),(0,H.jsxs)(`ul`,{className:`max-h-60 overflow-auto`,children:[o.parent&&(0,H.jsx)(`li`,{children:(0,H.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>void m(o.parent),children:`..`})}),o.entries.map(n=>(0,H.jsxs)(`li`,{className:`flex items-center gap-2`,children:[n.kind===`folder`?(0,H.jsxs)(`button`,{type:`button`,className:`underline`,onClick:()=>void m(n.path),children:[n.name,`/`]}):(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:n.name}),(n.kind!==`folder`||e.host===`pi`)&&(0,H.jsx)(`button`,{type:`button`,className:`text-xs underline`,onClick:()=>void p(n.path),children:t(`Choose`)})]},n.path))]}),o.truncated&&(0,H.jsx)(`p`,{className:`text-xs`,children:t(`Only the first 500 entries are shown.`)})]})]})}var cm=50,lm=1e3,um={"missing-model":`The external API has no memoryModel in the global config`,"missing-url":`The external API has no memoryApiUrl in the global config`,"missing-key":`The external API key is missing in the OpenCode process; check memoryApiKey and its env:// or file:// source`,"unsupported-provider":`The memoryProvider in the global config is not supported for imports`},dm=()=>({mode:`ids`,picked:new Map});function fm(e,t){return e.split(`
123
+ `).map(e=>e.trim()).filter(Boolean).map(e=>{let n=e.indexOf(`=`);if(n<1||n===e.length-1)throw Error(t);return{from:e.slice(0,n),to:e.slice(n+1)}})}function pm(){let e=Qp(),[t,n]=(0,_.useState)(`pi`),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(`current-project`),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(!1),[E,ee]=(0,_.useState)(null),[D,te]=(0,_.useState)(``),[ne,re]=(0,_.useState)(!1),[ie,ae]=(0,_.useState)(!1),[O,oe]=(0,_.useState)(dm),[k,A]=(0,_.useState)(null),[se,j]=(0,_.useState)(``),[ce,M]=(0,_.useState)(null),[N,P]=(0,_.useState)(``);(0,_.useEffect)(()=>{Hp(`/api/settings/imports/readiness`).then(e=>{A(e);let t=e.opencode.models[0];j(t?`${t.provider}/${t.model}`:e.external.state===`ready`?`external`:``)}).catch(()=>A(null)),Hp(`/api/settings/imports/current`).then(e=>M(e.job)).catch(()=>{})},[]),(0,_.useEffect)(()=>{if(ce?.state!==`running`&&ce?.state!==`cancelling`)return;let e=setInterval(()=>{Hp(`/api/settings/imports/current`).then(e=>M(e.job)).catch(e=>P(e.message))},1e3);return()=>clearInterval(e)},[ce?.state]);let le=JSON.stringify([t,r?.sourceToken,a,s,l]),ue=!!E&&(ne||le!==D);function de(){let n=fm(l,e(`Directory maps must be old=new, one per line`));return{host:t,...r?{source:r.sourceToken}:{},scope:a,...a===`current-project`&&s?{project:s}:{},pathMaps:n}}async function fe(e,t){ae(!0);try{let n=await Hp(`/api/settings/imports/sessions`,{method:`POST`,body:JSON.stringify({...de(),offset:e,limit:cm,refresh:t})}),r=om(E,n,t);r.sameListing||oe(dm()),ee(r.page),te(le),re(!1),P(``)}catch(e){P(e.message)}finally{ae(!1)}}let pe=E?E.total-(a===`all-projects`?E.unresolvedCount:0):0,F=O.mode===`all`?pe-O.excluded.size:O.picked.size,me=e=>O.mode===`all`?!O.excluded.has(e.key):O.picked.has(e.key);function I(e){if(!(!e.selectable||!e.directory)){if(O.mode===`all`){let t=new Set(O.excluded);t.has(e.key)?t.delete(e.key):t.add(e.key),oe({mode:`all`,excluded:t})}else{let t=new Map(O.picked);t.has(e.key)?t.delete(e.key):t.set(e.key,e.directory),oe({mode:`ids`,picked:t})}}}let he=!b||!S,ge=t===`pi`&&k?.piReader.available===!1,_e=he?k?se?se===`external`&&k.external.state!==`ready`?e(um[k.external.state]??`The external API is not ready`):null:e(`No import model is ready. Connect a model in OpenCode or complete the external API settings.`):e(`Model readiness is unknown. Reload the page.`):null,ve=E?ue?e(`Options changed. Refresh the session list first.`):F===0?e(`Select at least one session.`):O.mode===`ids`&&O.picked.size>lm?e(`Select at most 1000 sessions one by one, or use Select all matching.`):null:e(`List sessions first.`),ye=ce?.state===`running`||ce?.state===`cancelling`;async function be(n){if(E)try{let r=d?im(d):void 0,i=p?am(p):void 0,o={host:t,source:E.source.sourceToken,selection:O.mode===`all`?{mode:`all`,excludedKeys:[...O.excluded],revision:E.revision,listedAt:E.listedAt}:{mode:`ids`,sessions:[...O.picked].map(([e,t])=>({key:e,directory:t})),listedAt:E.listedAt},options:{dryRun:n,force:v,skipMemories:b,skipProfile:S,scope:a,...a===`current-project`&&s?{project:s}:{},...r===void 0?{}:{since:r},...i===void 0?{}:{until:i},...h?{profileBatch:Number(h)}:{},pathMaps:fm(l,e(`Directory maps must be old=new, one per line`))},...se?{modelChoice:se}:{}},c=await Hp(`/api/settings/imports`,{method:`POST`,body:JSON.stringify(o)});M(c),P(``)}catch(e){let t=e.message;/out of date|changed|no longer/i.test(t)&&re(!0),P(t)}}async function xe(){try{let e=await Hp(`/api/settings/imports/current/cancel`,{method:`POST`,body:`{}`});M(e.job)}catch(e){P(e.message)}}function Se(){o(`all-projects`),T(!0)}let Ce={recorded:e(`recorded`),mapped:e(`mapped`),worktree:e(`project root`),unresolved:e(`missing`)},we=`mt-1 block w-full rounded border border-border bg-background p-2`,Te=`rounded border border-border px-3 py-1.5 text-sm disabled:opacity-50`;return(0,H.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-border bg-card p-4`,"aria-label":e(`Import and backfill`),children:[(0,H.jsx)(`h2`,{className:`text-lg font-medium`,children:e(`Import and backfill`)}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-sm`,children:[e(`History host`),(0,H.jsxs)(`select`,{className:we,value:t,onChange:e=>{n(e.target.value),i(null),ee(null),oe(dm())},children:[(0,H.jsx)(`option`,{value:`pi`,children:`Pi`}),(0,H.jsx)(`option`,{value:`opencode`,children:`OpenCode`})]})]}),(0,H.jsx)(`button`,{type:`button`,className:Te,disabled:ie,onClick:()=>void fe(0,!0),children:e(E?`Refresh list`:`List sessions`)}),(0,H.jsx)(`button`,{type:`button`,className:Te,onClick:()=>T(!w),children:e(w?`Hide advanced options`:`Advanced options`)})]}),(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e(`Source`),`: `,r?.displayPath??E?.source.displayPath??e(`default location`),` · `,e(a===`current-project`?`Current project`:`All projects`)]}),ge&&(0,H.jsx)(`p`,{role:`alert`,children:k?.piReader.reason}),w&&(0,H.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,children:[(0,H.jsx)(sm,{host:t,onChoose:i}),(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,H.jsxs)(`label`,{className:`text-sm`,children:[e(`Scope`),(0,H.jsxs)(`select`,{className:we,value:a,onChange:e=>o(e.target.value),children:[(0,H.jsx)(`option`,{value:`current-project`,children:e(`Current project`)}),(0,H.jsx)(`option`,{value:`all-projects`,children:e(`All projects`)})]})]}),a===`current-project`&&(0,H.jsxs)(`label`,{className:`text-sm`,children:[e(`Project directory`),(0,H.jsx)(`input`,{className:we,value:s,onChange:e=>c(e.target.value),placeholder:e(`Current directory`)})]}),(0,H.jsxs)(`label`,{className:`text-sm`,children:[e(`Prompt date from`),(0,H.jsx)(`input`,{type:`date`,className:we,value:d,onChange:e=>f(e.target.value)})]}),(0,H.jsxs)(`label`,{className:`text-sm`,children:[e(`Prompt date to`),(0,H.jsx)(`input`,{type:`date`,className:we,value:p,onChange:e=>m(e.target.value)})]}),(0,H.jsxs)(`label`,{className:`text-sm`,children:[e(`Profile batch size`),(0,H.jsx)(`input`,{inputMode:`numeric`,className:we,value:h,onChange:e=>g(e.target.value)})]})]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`Prompt dates are inclusive, use your time zone, and filter the turns inside each session, not the list. Empty dates include every turn.`)}),(0,H.jsxs)(`label`,{className:`block text-sm`,children:[e(`Directory maps (old=new, one per line)`),(0,H.jsx)(`textarea`,{className:we,rows:2,value:l,onChange:e=>u(e.target.value)})]}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-3 text-sm`,children:[[`Force reimport`,v,y],[`Skip memories`,b,x],[`Skip profile`,S,C]].map(([t,n,r])=>(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked)}),` `,e(t)]},t))})]}),ue&&E&&(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-amber-600`,children:e(`Options changed. Refresh the session list first.`)}),E&&a===`current-project`&&E.unresolvedCount>0&&(0,H.jsxs)(`p`,{className:`text-sm`,children:[e(`Sessions with directories that no longer exist`),`: `,E.unresolvedCount,`.`,` `,(0,H.jsx)(`button`,{type:`button`,className:`underline`,onClick:Se,children:e(`Show them and add a directory map`)})]}),E&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,H.jsxs)(`span`,{role:`status`,children:[e(`Selected`),`: `,F,` / `,pe]}),(0,H.jsxs)(`button`,{type:`button`,className:Te,disabled:pe===0,onClick:()=>oe({mode:`all`,excluded:new Set}),children:[e(`Select all matching`),` (`,pe,`)`]}),(0,H.jsx)(`button`,{type:`button`,className:Te,onClick:()=>oe(dm()),children:e(`Clear selection`)})]}),(0,H.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,H.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{className:`text-muted-foreground`,children:[(0,H.jsx)(`th`,{className:`p-1`,children:(0,H.jsx)(`span`,{className:`sr-only`,children:e(`Select`)})}),(0,H.jsx)(`th`,{className:`p-1`,children:e(`Created`)}),(0,H.jsx)(`th`,{className:`p-1`,children:e(`Session`)}),(0,H.jsx)(`th`,{className:`p-1`,children:e(`Project directory`)}),(0,H.jsx)(`th`,{className:`p-1`,children:e(`Resolved by`)})]})}),(0,H.jsx)(`tbody`,{children:E.rows.map(t=>(0,H.jsxs)(`tr`,{className:`border-t border-border`,children:[(0,H.jsx)(`td`,{className:`p-1`,children:(0,H.jsx)(`input`,{type:`checkbox`,"aria-label":`${e(`Select`)} ${t.sessionId??t.key}`,checked:t.selectable&&me(t),disabled:!t.selectable,onChange:()=>I(t)})}),(0,H.jsx)(`td`,{className:`p-1 whitespace-nowrap`,children:t.createdAt?new Date(t.createdAt).toLocaleString():`—`}),(0,H.jsx)(`td`,{className:`p-1 font-mono text-xs`,children:t.sessionId??t.key}),(0,H.jsx)(`td`,{className:`p-1 font-mono text-xs break-all`,children:t.directory??t.recordedDirectory??`—`}),(0,H.jsx)(`td`,{className:`p-1`,children:Ce[t.via]})]},t.key))})]}),E.total===0&&(0,H.jsx)(`p`,{className:`text-sm`,children:e(`No sessions match.`)})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,H.jsx)(`button`,{type:`button`,className:Te,disabled:ie||E.offset===0,onClick:()=>void fe(Math.max(0,E.offset-cm),!1),children:e(`Previous`)}),(0,H.jsxs)(`span`,{children:[E.total?E.offset+1:0,`–`,Math.min(E.offset+cm,E.total),` /`,` `,E.total]}),(0,H.jsx)(`button`,{type:`button`,className:Te,disabled:ie||E.offset+cm>=E.total,onClick:()=>void fe(E.offset+cm,!1),children:e(`Next`)})]})]}),(0,H.jsxs)(`label`,{className:`block text-sm`,children:[e(`Import model`),(0,H.jsxs)(`select`,{className:we,value:se,onChange:e=>j(e.target.value),children:[(0,H.jsx)(`option`,{value:``,children:e(`None`)}),k?.opencode.models.map(e=>(0,H.jsxs)(`option`,{value:`${e.provider}/${e.model}`,children:[e.name,` (`,e.provider,`/`,e.model,`)`]},`${e.provider}/${e.model}`)),(0,H.jsxs)(`option`,{value:`external`,children:[e(`Saved external API`),k?.external.model?` (${k.external.model})`:``,k&&k.external.state!==`ready`?` — ${e(`not ready`)}`:``]})]})]}),(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e(`Configured, not tested.`),` `,(0,H.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>document.getElementById(`settings-health`)?.scrollIntoView(),children:e(`Test models in Health`)})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,className:Te,disabled:ye||ge||!!ve,onClick:()=>void be(!0),children:e(`Preview (dry run)`)}),(0,H.jsx)(`button`,{type:`button`,className:Te,disabled:ye||ge||!!ve||!!_e,onClick:()=>void be(!1),children:e(`Start import`)}),ye&&(0,H.jsx)(`button`,{type:`button`,className:Te,disabled:ce?.state===`cancelling`,onClick:()=>void xe(),children:e(`Cancel after current unit`)})]}),(ve||_e)&&!ye&&(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:ve??_e}),N&&(0,H.jsx)(`p`,{role:`alert`,children:N}),ce&&(0,H.jsxs)(`div`,{role:`status`,className:`text-sm`,children:[ce.host,` · `,ce.dryRun?e(`Preview (dry run)`):e(`Import`),` · `,e(ce.state),` ·`,` `,ce.sessions,` `,e(`sessions`),` · `,ce.processed,`/`,ce.total,` `,e(`units`),ce.error&&(0,H.jsx)(`p`,{role:`alert`,children:ce.error}),ce.report&&(0,H.jsx)(`pre`,{className:`mt-2 overflow-auto whitespace-pre-wrap rounded bg-background p-3 text-xs`,children:ce.report})]})]})}function mm(){let e=Qp(),[t,n]=(0,_.useState)(!1),[r,i]=(0,_.useState)(),[a,o]=(0,_.useState)(``);async function s(e){try{i(await Hp(`/api/settings/log?lines=200${e?`&filter=capture`:``}`)),o(``)}catch(e){o(e.message)}}return(0,_.useEffect)(()=>{s(t)},[t]),(0,H.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-border bg-card p-4`,"aria-label":e(`Log`),children:[(0,H.jsx)(`h2`,{className:`text-lg font-medium`,children:e(`Log`)}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-sm`,children:[(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked)}),` `,e(`Capture attempts only`)]}),(0,H.jsx)(`button`,{type:`button`,className:`rounded-lg border border-border px-3 py-1`,onClick:()=>void s(t),children:e(`Refresh`)}),r&&(0,H.jsx)(`button`,{type:`button`,className:`rounded-lg border border-border px-3 py-1`,onClick:()=>void navigator.clipboard.writeText(r.path),children:e(`Copy log path`)})]}),(0,H.jsx)(`p`,{className:`break-all text-xs text-muted-foreground`,children:r?.path}),a&&(0,H.jsx)(`p`,{role:`alert`,children:a}),(0,H.jsx)(`pre`,{className:`max-h-80 overflow-auto rounded-lg bg-background p-3 text-xs whitespace-pre-wrap break-words`,"aria-label":e(`Log lines`),children:r?r.lines.length?r.lines.join(`
124
+ `):e(`No log has been written yet.`):e(`Loading log…`)})]})}function hm(){return(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsx)($p,{}),(0,H.jsx)(tm,{}),(0,H.jsx)(nm,{}),(0,H.jsx)(pm,{}),(0,H.jsx)(mm,{})]})}var gm=rn(`grid gap-0.5 rounded-2xl border px-4 py-3 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4 group/alert relative w-full`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`text-destructive bg-card *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current`}},defaultVariants:{variant:`default`}});function _m({className:e,variant:t,...n}){return(0,H.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:Ar(gm({variant:t}),e),...n})}function vm({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`alert-description`,className:Ar(`text-muted-foreground text-sm [&_p]:leading-relaxed col-start-2`,e),...t})}function ym({...e}){let t=fl();return(0,H.jsx)(lt,{theme:t,className:`toaster group`,style:{"--normal-bg":`var(--color-popover)`,"--normal-text":`var(--color-popover-foreground)`,"--normal-border":`var(--color-border)`},icons:{loading:(0,H.jsx)(le,{className:`size-4 animate-spin`}),success:(0,H.jsx)(se,{className:`size-4`}),error:(0,H.jsx)(F,{className:`size-4`}),info:(0,H.jsx)(N,{className:`size-4`}),warning:(0,H.jsx)(De,{className:`size-4`})},...e})}function bm(e,t,n){return e?t:n}var xm=[``,`feature`,`bug-fix`,`refactor`,`architecture`,`rule`,`documentation`,`discussion`,`analysis`,`configuration`];function Sm(){let{t:e,language:t}=kt(),n=Qc(),[r,i]=(0,_.useState)(!1),a=At(),o=jt();(0,_.useEffect)(()=>{let e=Xc();(async()=>{await a.loadTags(),await a.loadMemories(),await a.loadStats(),await a.checkMigrationStatus(),await a.checkAuthWarning()})();let t=setInterval(()=>{a.loadStats(),!a.isSearching&&n===`project`&&a.loadMemories()},3e4);return()=>{e(),clearInterval(t)}},[]);let s=o.loadUserProfile;(0,_.useEffect)(()=>{n===`profile`&&s()},[n,s]);function c(e){e!==t&&(Tt(e),a.loadMemories(),a.loadStats(),n===`profile`&&o.loadUserProfile())}function l(e){e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),Yc(Rc.home))}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ym,{richColors:!0,position:`bottom-right`}),(0,H.jsxs)(`div`,{className:`flex min-h-svh bg-background text-foreground`,children:[(0,H.jsx)(ml,{open:r,onOpenChange:i,currentView:n,brand:e(`brand`),projectLabel:e(`tab-project`),profileLabel:e(`tab-profile`),langLabel:t.toUpperCase(),languageLabel:e(`nav-language`),themeLabel:e(`nav-theme`),settingsLabel:e(`nav-settings`),closeLabel:e(`nav-close`),onLanguageSelect:c}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,H.jsxs)(`div`,{className:`sticky top-0 z-30 flex items-center gap-2 border-b border-border bg-background/95 px-3 py-2 backdrop-blur md:hidden`,children:[(0,H.jsx)(U,{variant:`ghost`,size:`icon-sm`,onClick:()=>i(!0),"aria-label":e(`nav-menu`),children:(0,H.jsx)(de,{className:`size-4`})}),(0,H.jsx)(`a`,{href:Rc.home,className:`truncate text-sm tracking-wide text-primary`,onClick:l,children:e(`brand`)})]}),(0,H.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex-1 space-y-4 p-4 md:p-6`,children:[a.showAuthWarning?(0,H.jsxs)(_m,{variant:`destructive`,children:[(0,H.jsx)(De,{}),(0,H.jsx)(vm,{children:e(`auth-warning-text`)})]}):null,(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,H.jsx)(`h1`,{className:`text-base tracking-wide text-primary`,children:e(n===`project`?`tab-project`:n===`profile`?`tab-profile`:`nav-settings`)}),n===`project`?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:e(`text-total`,{count:bm(a.isSearching,a.totalItems,a.statsTotal)})}),a.refreshing?(0,H.jsx)(ue,{className:`size-3.5 animate-spin`}):null]}):null]}),n===`project`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3 rounded-xl border border-border bg-card p-3`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(_l,{htmlFor:`tag-filter`,children:e(`label-tag`)}),(0,H.jsxs)(`select`,{id:`tag-filter`,className:`flex h-8 min-w-48 rounded-lg border border-border bg-background px-2 text-sm`,value:a.selectedTag,onChange:e=>a.onTagFilterChange(e.currentTarget.value),children:[(0,H.jsx)(`option`,{value:``,children:e(`opt-all-tags`)}),a.tags.map(e=>(0,H.jsx)(`option`,{value:e.tag,children:e.displayName||e.tag},e.tag))]})]}),(0,H.jsxs)(`div`,{className:`flex flex-1 items-end gap-1.5 min-w-56`,children:[(0,H.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,H.jsx)(_l,{htmlFor:`search-input`,className:`sr-only`,children:e(`placeholder-search`)}),(0,H.jsx)(Np,{id:`search-input`,placeholder:e(`placeholder-search`),value:a.searchInput,onChange:e=>a.setSearchInput(e.target.value),onKeyDown:e=>e.key===`Enter`&&a.performSearch()})]}),(0,H.jsx)(U,{variant:`outline`,size:`icon`,onClick:a.performSearch,children:(0,H.jsx)(be,{className:`size-4`})}),a.isSearching?(0,H.jsx)(U,{variant:`outline`,size:`icon`,onClick:a.clearSearch,children:(0,H.jsx)(je,{className:`size-4`})}):null]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,H.jsxs)(U,{variant:`outline`,size:`sm`,onClick:a.runCleanup,children:[(0,H.jsx)(Ee,{className:`size-3.5`}),e(`btn-cleanup`)]}),(0,H.jsxs)(U,{variant:`outline`,size:`sm`,onClick:a.runDeduplication,children:[(0,H.jsx)(ve,{className:`size-3.5`}),e(`btn-deduplicate`)]})]}),a.selectedIds.size>0?(0,H.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2 border-t border-border pt-3`,children:[(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`text-selected`,{count:a.selectedIds.size})}),(0,H.jsx)(U,{variant:`secondary`,size:`xs`,onClick:a.selectAllCurrentPage,children:e(`btn-select-all`)}),(0,H.jsx)(U,{variant:`destructive`,size:`xs`,onClick:a.bulkDelete,children:e(`btn-delete-selected`)}),(0,H.jsx)(U,{variant:`ghost`,size:`xs`,onClick:a.deselectAll,children:e(`btn-deselect-all`)})]}):null]}),a.migrationNeeded?(0,H.jsxs)(_m,{variant:`destructive`,className:`space-y-3`,children:[(0,H.jsx)(De,{}),(0,H.jsxs)(vm,{className:`space-y-3`,children:[(0,H.jsx)(`p`,{children:a.migrationMessage||e(`migration-mismatch`)}),(0,H.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,H.jsx)(zi,{checked:a.migrationConfirmed,onCheckedChange:e=>a.setMigrationConfirmed(e===!0),className:`mt-0.5`}),(0,H.jsx)(`span`,{children:e(`migration-understand`)})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(U,{variant:`destructive`,size:`sm`,disabled:!a.migrationConfirmed,onClick:()=>a.runMigration(`fresh-start`),children:e(`btn-fresh-start`)}),(0,H.jsx)(U,{variant:`secondary`,size:`sm`,disabled:!a.migrationConfirmed,onClick:()=>a.runMigration(`re-embed`),children:e(`btn-reembed`)})]})]})]}):null,(0,H.jsx)(Ff,{memories:a.memories,selectedIds:a.selectedIds,currentPage:a.currentPage,totalPages:a.totalPages,totalItems:a.totalItems,isSearching:a.isSearching,loading:a.loadingMemories,error:a.memoriesError,onSelect:a.onSelect,onPageChange:e=>{let t=a.currentPage+e;a.setCurrentPage(t),a.loadMemories({page:t})},onPin:a.pinMemory,onUnpin:a.unpinMemory,onEdit:a.openEdit,onDeleteMemory:a.deleteMemory,onDeletePrompt:a.deletePrompt}),(0,H.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-4 space-y-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm text-muted-foreground`,children:e(`section-add`)}),(0,H.jsxs)(`form`,{className:`space-y-3`,onSubmit:a.addMemory,children:[(0,H.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(_l,{htmlFor:`add-tag`,children:e(`label-tag`)}),(0,H.jsxs)(`select`,{id:`add-tag`,required:!0,className:`flex h-8 w-full rounded-lg border border-border bg-background px-2 text-sm`,value:a.addTag,onChange:e=>a.setAddTag(e.target.value),children:[(0,H.jsx)(`option`,{value:``,children:e(`opt-select-tag`)}),a.tags.map(e=>(0,H.jsx)(`option`,{value:e.tag,children:e.displayName||e.tag},e.tag))]})]}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(_l,{htmlFor:`add-type`,children:e(`label-type`)}),(0,H.jsx)(`select`,{id:`add-type`,className:`flex h-8 w-full rounded-lg border border-border bg-background px-2 text-sm`,value:a.addType,onChange:e=>a.setAddType(e.target.value),children:xm.map(t=>(0,H.jsx)(`option`,{value:t,children:e(t?`opt-${t}`:`opt-other`)},t||`other`))})]}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(_l,{htmlFor:`add-tags`,children:e(`label-tags`)}),(0,H.jsx)(Np,{id:`add-tags`,placeholder:e(`placeholder-tags`),value:a.addTags,onChange:e=>a.setAddTags(e.target.value)})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(_l,{htmlFor:`add-content`,children:e(`label-content`)}),(0,H.jsx)(vl,{id:`add-content`,rows:4,required:!0,placeholder:e(`placeholder-content`),value:a.addContent,onChange:e=>a.setAddContent(e.target.value)})]}),(0,H.jsxs)(U,{type:`submit`,children:[(0,H.jsx)(_e,{className:`size-3.5`}),e(`btn-add-memory`)]})]})]})]}):n===`settings`?(0,H.jsx)(hm,{}):(0,H.jsx)(Bp,{profile:o.userProfile,loading:o.loadingProfile,onRefresh:o.refreshProfile,onCleanup:()=>o.setAiCleanupOpen(!0)})]})]})]}),(0,H.jsx)(yl,{open:a.editOpen,onOpenChange:a.setEditOpen,content:a.editContent,onSave:a.saveEdit}),(0,H.jsx)(Vp,{open:a.tagMigrationOpen,onOpenChange:a.setTagMigrationOpen,count:a.tagMigrationCount,onComplete:()=>{a.loadMemories(),a.loadStats()}}),(0,H.jsx)(Oc,{open:o.aiCleanupOpen,onOpenChange:o.setAiCleanupOpen,profile:o.userProfile,onApplied:o.loadUserProfile})]})}dl();var Cm=document.getElementById(`app`);if(!Cm)throw Error(`Root element #app not found`);(0,v.createRoot)(Cm).render((0,H.jsx)(_.StrictMode,{children:(0,H.jsx)(Ot,{children:(0,H.jsx)(Sm,{})})}));
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/x-icon" href="/favicon.ico" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>omms Memory Explorer</title>
8
- <script type="module" crossorigin src="/assets/index-BO6gokx9.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-BMkPht7g.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-D5ak5KsI.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "om-memory-system",
3
- "version": "3.2.0-next.12",
3
+ "version": "3.2.0-next.14",
4
4
  "description": "Opinionated modular memory system for coding agents (OpenCode + Pi)",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.js",