ai-helper-agent 2.8.22 → 2.8.23

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.
@@ -1,4 +1,4 @@
1
- import{a as e,c as t,l as n}from"./i18n-5c8prpFJ.js";import{C as r,S as i,Y as a,g as o,h as s,w as c}from"./version-DLS0FCk4.js";import{AlignmentType as l,BorderStyle as u,Document as d,ExternalHyperlink as f,HeadingLevel as p,ImageRun as m,LevelFormat as h,Packer as ee,Paragraph as g,Table as te,TableCell as ne,TableRow as _,TextRun as v,WidthType as y,convertInchesToTwip as b}from"./dist-BUuoW_84.js";var x=40,S=3e3,C=/^\s{0,3}(`{3,}|~{3,})/,w=/^\s{0,3}(#{1,6})[ \t]+(.*)$/,T=/^\s{0,3}=+\s*$/,E=/^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/,D=/^\s*\|.*\|\s*$/,re=/^\s*(?:\d+(?:\.\d+)+[.、))]?\s*|\d+[.、))]\s*|[一二三四五六七八九十]+[、.]\s*|[((][一二三四五六七八九十\d]+[))]\s*)/,ie=/[/\\:*?"<>|]/g,ae=/[\u0000-\u001f\u007f\u200b-\u200f\u2028\u2029\ufeff]/g,O=`
1
+ import{a as e,c as t,l as n}from"./i18n-5c8prpFJ.js";import{C as r,S as i,Y as a,g as o,h as s,w as c}from"./version-DigCzqtw.js";import{AlignmentType as l,BorderStyle as u,Document as d,ExternalHyperlink as f,HeadingLevel as p,ImageRun as m,LevelFormat as h,Packer as ee,Paragraph as g,Table as te,TableCell as ne,TableRow as _,TextRun as v,WidthType as y,convertInchesToTwip as b}from"./dist-BUuoW_84.js";var x=40,S=3e3,C=/^\s{0,3}(`{3,}|~{3,})/,w=/^\s{0,3}(#{1,6})[ \t]+(.*)$/,T=/^\s{0,3}=+\s*$/,E=/^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/,D=/^\s*\|.*\|\s*$/,re=/^\s*(?:\d+(?:\.\d+)+[.、))]?\s*|\d+[.、))]\s*|[一二三四五六七八九十]+[、.]\s*|[((][一二三四五六七八九十\d]+[))]\s*)/,ie=/[/\\:*?"<>|]/g,ae=/[\u0000-\u001f\u007f\u200b-\u200f\u2028\u2029\ufeff]/g,O=`
2
2
  `;function oe(e){return typeof e==`string`?e.replace(/\r\n?/g,O).replace(/\n{3,}/g,`
3
3
 
4
4
  `):``}function se(e){return(e.length>S?e.slice(0,S):e).split(O).slice(0,x).join(O)}function ce(e){return String(e).replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/`+/g,``).replace(/(\*\*|__|\*|_|~~)/g,``).replace(/https?:\/\/\S+/gi,``).replace(/<[^>]+>/g,``)}function k(e){if(typeof e!=`string`||!e.trim())return``;let t=ce(e);return t=t.replace(ae,``),t=t.replace(re,``),t=t.replace(ie,`_`),t=t.replace(/\s+/g,`-`).replace(/-{2,}/g,`-`),t=t.replace(/^[-_.\s]+/,``).replace(/[-_.\s]+$/,``),t}function A(e,t=40){let n=Array.from(e);return(n.length>t?n.slice(0,t).join(``):e).replace(/[-_.,;:、,。;:\s]+$/u,``)}function le(e){if(typeof e!=`string`||!e.trim())return``;let t=se(e).split(O),n=[],r=``;for(let e=0;e<t.length;e++){let i=t[e],a=i.match(C);if(r){a&&a[1][0]===r&&(r=``);continue}if(a){r=a[1][0];continue}let o=i.match(w);if(o){let e=o[2].replace(/[ \t]+#+[ \t]*$/,``).trim();e&&n.push({level:o[1].length,text:e});continue}let s=t[e+1];s&&T.test(s)&&i.trim()&&!E.test(i)&&!D.test(i)&&(n.push({level:1,text:i.trim()}),e++)}return n.length===0?``:A(k((n.find(e=>e.level===1)||n[0]).text))}function ue({title:e=``,kind:t,timestamp:n,ext:r}){let i=`${t}-${n}.${r}`,a=A(k(e));return a?`${a}-${i}`:i}function j(e,{kind:t,ext:n,timestamp:r=Date.now()}){return ue({title:le(e),kind:t,timestamp:r,ext:n})}e(`zh`,{chatExport:{exportFailed:`导出失败:{message}`,pdfLibNotLoaded:`PDF 库未加载,无法导出`,noContent:`没有可导出的内容`,imageLibNotLoaded:`图片库未加载,无法导出为图片`,imagePlaceholder:`[图片: {name}]`,canvasFailed:`Canvas 转 DataURL 失败:{message}`,svgLoadFailed:`SVG 图片加载失败`}}),e(`en`,{chatExport:{exportFailed:`Export failed: {message}`,pdfLibNotLoaded:`PDF library not loaded, cannot export`,noContent:`No content to export`,imageLibNotLoaded:`Image library not loaded, cannot export as image`,imagePlaceholder:`[Image: {name}]`,canvasFailed:`Canvas to DataURL failed: {message}`,svgLoadFailed:`SVG image loading failed`}});var M=new Map,N=/Mac|iPhone|iPad|iPod/i.test(typeof navigator<`u`?navigator.userAgent:``)?`Apple Color Emoji`:`Segoe UI Emoji`,P=RegExp(`(?:\\p{Regional_Indicator}{2})|(?:\\p{Emoji_Presentation}|\\p{Extended_Pictographic}\\uFE0F)(?:[\\u{1F3FB}-\\u{1F3FF}]|\\u200D(?:\\p{Emoji_Presentation}|\\p{Extended_Pictographic}\\uFE0F))*`,`gu`),F=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g,I=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;function L(e){return e==null||e===``?e:String(e).replace(F,``).replace(I,`�`)}var R=0;function z(){return R+=1,R}var B=new Set([`png`,`jpg`,`jpeg`,`gif`,`bmp`]);function V(e){return B.has(String(e||``).toLowerCase())}function H(e,t={}){if(!e)return[];let n=[];return String(e).split(/\r?\n/).forEach((e,r)=>{r>0&&n.push(new v({...t,break:1}));let i=0;for(let r of e.matchAll(P))r.index>i&&n.push(new v({...t,text:e.slice(i,r.index)})),n.push(new v({...t,text:r[0],font:{name:N}})),i=r.index+r[0].length;i<e.length&&n.push(new v({...t,text:e.slice(i)}))}),n}function U(e){if(!e)return[];let r=/(\*\*(.+?)\*\*|(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)|__(.+?)__|(?<!_)_(?!_)(.+?)(?<!_)_(?!_)|`([^`]+)`|\[([^\]]+)\]\(([^)]+)\)|!\[([^\]]*)\]\(([^)]+)\))/,i=[],a=e;for(;a.length>0;){let e=a.match(r);if(!e){i.push(...H(a));break}let o=e.index;o>0&&i.push(...H(a.slice(0,o)));let s=e[1];if(e[2]!==void 0)i.push(...H(e[2],{bold:!0}));else if(e[3]!==void 0)i.push(...H(e[3],{italics:!0}));else if(e[4]!==void 0)i.push(...H(e[4],{bold:!0}));else if(e[5]!==void 0)i.push(...H(e[5],{italics:!0}));else if(e[6]!==void 0)i.push(new v({text:e[6],font:`Consolas`,size:20}));else if(e[7]!==void 0)i.push(new f({children:[new v({text:e[7],style:`Hyperlink`})],link:e[8]}));else if(e[9]!==void 0){let r=e[10];if(r.startsWith(`data:`))try{let[n,a]=r.split(`,`),o=n.match(/data:(image\/(\w+))/);if(o&&a&&V(o[2])){let t=atob(a),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);let r=o[2],s=de(n,r),c=s.width,l=s.height;if(c>567){let e=567/c;c=Math.round(c*e),l=Math.round(l*e)}i.push(new m({data:n,transformation:{width:c,height:l},type:r,altText:{id:z(),name:e[9]||`image`}}))}else i.push(new v({text:t(`chatExport.imagePlaceholder`,{name:e[9]||`image`}),italics:!0,color:`999999`}))}catch(r){n.warn(`[ChatExport] ImageRun create failed:`,r.message),i.push(new v({text:t(`chatExport.imagePlaceholder`,{name:e[9]||`image`}),italics:!0,color:`999999`}))}else i.push(new v({text:t(`chatExport.imagePlaceholder`,{name:e[9]||r}),italics:!0,color:`999999`}))}a=a.slice(o+s.length)}return i}function de(e,t){if(t===`png`&&e.length>24){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:t.getUint32(16),height:t.getUint32(20)}}if((t===`jpeg`||t===`jpg`)&&e.length>100){let t=2;for(;t<e.length-9;)if(e[t]===255){let n=e[t+1];if(n>=192&&n<=195){let n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{height:n.getUint16(t+5),width:n.getUint16(t+7)}}t+=2+(e[t+2]<<8|e[t+3])}else t++}return{width:600,height:400}}async function W(e){if(!e||!e.trim())return[new g({children:[new v({text:``})]})];let t=[],n=L(e),r=[];n=n.replace(/```(\w*)\n([\s\S]*?)```/g,(e,t,n)=>{let i=r.length;return r.push({lang:t||``,code:n.trimEnd()}),`\n\n%%CODEBLOCK_${i}%%\n\n`});let i=[];n=n.replace(/<table[\s\S]*?<\/table>/gi,e=>{let t=i.length;return i.push(e),`\n\n%%HTMLTABLE_${t}%%\n\n`});let a=s(n,`MDTABLE`);n=a.text;let o=a.blocks.map(e=>e.full),c=n.split(/\n{2,}/).filter(e=>e.trim());for(let e of c){let n=e.trim(),a=n.match(/^%%CODEBLOCK_(\d+)%%$/);if(a){let{lang:e,code:n}=r[parseInt(a[1])],i=e?`${e} code`:`code`;t.push(new g({children:[new v({text:i,bold:!0,font:`Consolas`,size:18})]}));let o=n.split(`
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agent-store-CeC2_dkP.js","assets/chunk-CMxvf4Kt.js","assets/model-profiles-ClPgbQ-J.js","assets/i18n-5c8prpFJ.js","assets/pdf-DnVqBaAN.js","assets/__vite-browser-external-CM3Eme-n.js","assets/lib-YwkWjNcC.js","assets/jszip.min-DO6SOhXU.js","assets/dist-DuuG_8Br.js","assets/chat-export-DWrq6XW7.js","assets/dist-BUuoW_84.js","assets/version-DLS0FCk4.js","assets/voice-shortcut-Dx863RGz.js","assets/session-store-M5mPmMr3.js"])))=>i.map(i=>d[i]);
2
- import{o as e,r as t}from"./chunk-CMxvf4Kt.js";import{a as n,c as r,l as i,r as a}from"./i18n-5c8prpFJ.js";import{$ as o,At as s,Dt as c,Et as l,H as u,Ht as d,Jt as f,Lt as p,Ot as m,Pt as h,Rt as g,S as _,St as v,U as y,Ut as b,Y as x,Yt as S,b as C,ct as w,dt as T,kt as E,lt as D,ut as O,wt as k,x as A}from"./model-profiles-ClPgbQ-J.js";import{A as j,B as M,C as N,D as ee,E as te,M as ne,O as re,S as ie,T as ae,a as oe,at as se,b as ce,c as le,d as ue,f as de,h as fe,j as pe,k as me,l as he,m as ge,n as _e,o as ve,ot as ye,p as be,r as xe,s as Se,t as Ce,u as we,v as Te,w as Ee,x as De,y as Oe}from"./session-store-M5mPmMr3.js";import{a as ke,n as Ae,o as je,r as Me,t as Ne}from"./voice-shortcut-Dx863RGz.js";import{A as Pe,B as Fe,C as Ie,E as Le,F as Re,H as ze,I as Be,K as Ve,L as He,M as P,O as Ue,R as We,S as Ge,T as Ke,U as qe,V as Je,W as Ye,X as Xe,Y as F,Z as Ze,_ as Qe,d as $e,f as et,g as tt,h as nt,i as rt,j as I,k as it,l as at,m as ot,n as st,p as ct,u as lt,v as ut,w as dt,x as ft,y as pt,z as L}from"./version-DLS0FCk4.js";import{a as mt,c as ht,i as gt,n as _t,o as vt,r as yt,s as bt}from"./agent-store-CeC2_dkP.js";import{A as xt,C as St,D as Ct,E as wt,M as Tt,O as Et,S as Dt,T as Ot,_ as kt,a as At,b as jt,c as Mt,d as Nt,f as Pt,g as Ft,h as It,i as Lt,k as Rt,l as zt,m as Bt,n as Vt,o as Ht,p as Ut,r as Wt,s as Gt,t as Kt,u as qt,v as Jt,w as Yt,x as Xt,y as Zt}from"./workspace-manager-CL4JvHkJ.js";var Qt=ne.map(e=>e.id),$t=[...new Set([...S,`mcp`,`knowledge`])],en=[{labelKey:`presetMode.preciseLabel`,tipKey:`presetMode.preciseTip`,temp:.2,topP:1},{labelKey:`presetMode.generalLabel`,tipKey:`presetMode.generalTip`,temp:.45,topP:.9},{labelKey:`presetMode.divergentLabel`,tipKey:`presetMode.divergentTip`,temp:.65,topP:.9},{labelKey:`presetMode.creativeLabel`,tipKey:`presetMode.creativeTip`,temp:.9,topP:.9}];n(`zh`,{contextUsage:{compactionInjection:`[上下文摘要|压缩了{count}条历史]`}}),n(`en`,{contextUsage:{compactionInjection:`[Context Summary | {count} messages compacted]`}});var tn=2e3,nn=.7,rn=1e3;function an(e,{isolateChat:t=!0,maxMemoryMessages:n=null,compaction:r=null,historyBudget:i=1/0,currentMessage:a=null}={}){let o=a||{role:`user`,content:``};if(!t)return{messages:[o],keptHistory:[],compactionApplied:!1,trimmedCount:0,historySummaryText:null};let c=Array.isArray(e)?e:[],l=!1,u=-1;r&&r.summary&&r.upToMessageId&&(u=c.findIndex(e=>e.messageId===r.upToMessageId),l=u>=0);let f=c,p=c.map((e,t)=>t);n&&n>0&&c.length>n&&(f=c.slice(c.length-n),p=p.slice(c.length-n));let m=[];for(let e=0;e<f.length;e++)l&&p[e]<=u||m.push(f[e]);let g=[],_=E([o]);for(let e=m.length-1;e>=0;e--){let t=m[e],n=E([{...t,content:d(t.content)}]);if(_+n<=i)g.unshift(t),_+=n;else break}let v=null,y=m.length-g.length;if(y>0){let e=h(m.slice(0,y));e&&(v=s(e)>rn?e.substring(0,rn*4)+`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agent-store-CeC2_dkP.js","assets/chunk-CMxvf4Kt.js","assets/model-profiles-ClPgbQ-J.js","assets/i18n-5c8prpFJ.js","assets/pdf-DnVqBaAN.js","assets/__vite-browser-external-CM3Eme-n.js","assets/lib-YwkWjNcC.js","assets/jszip.min-DO6SOhXU.js","assets/dist-DuuG_8Br.js","assets/chat-export-ryKcmB-h.js","assets/dist-BUuoW_84.js","assets/version-DigCzqtw.js","assets/voice-shortcut-Dx863RGz.js","assets/session-store-M5mPmMr3.js"])))=>i.map(i=>d[i]);
2
+ import{o as e,r as t}from"./chunk-CMxvf4Kt.js";import{a as n,c as r,l as i,r as a}from"./i18n-5c8prpFJ.js";import{$ as o,At as s,Dt as c,Et as l,H as u,Ht as d,Jt as f,Lt as p,Ot as m,Pt as h,Rt as g,S as _,St as v,U as y,Ut as b,Y as x,Yt as S,b as C,ct as w,dt as T,kt as E,lt as D,ut as O,wt as k,x as A}from"./model-profiles-ClPgbQ-J.js";import{A as j,B as M,C as N,D as ee,E as te,M as ne,O as re,S as ie,T as ae,a as oe,at as se,b as ce,c as le,d as ue,f as de,h as fe,j as pe,k as me,l as he,m as ge,n as _e,o as ve,ot as ye,p as be,r as xe,s as Se,t as Ce,u as we,v as Te,w as Ee,x as De,y as Oe}from"./session-store-M5mPmMr3.js";import{a as ke,n as Ae,o as je,r as Me,t as Ne}from"./voice-shortcut-Dx863RGz.js";import{A as Pe,B as Fe,C as Ie,E as Le,F as Re,H as ze,I as Be,K as Ve,L as He,M as P,O as Ue,R as We,S as Ge,T as Ke,U as qe,V as Je,W as Ye,X as Xe,Y as F,Z as Ze,_ as Qe,d as $e,f as et,g as tt,h as nt,i as rt,j as I,k as it,l as at,m as ot,n as st,p as ct,u as lt,v as ut,w as dt,x as ft,y as pt,z as L}from"./version-DigCzqtw.js";import{a as mt,c as ht,i as gt,n as _t,o as vt,r as yt,s as bt}from"./agent-store-CeC2_dkP.js";import{A as xt,C as St,D as Ct,E as wt,M as Tt,O as Et,S as Dt,T as Ot,_ as kt,a as At,b as jt,c as Mt,d as Nt,f as Pt,g as Ft,h as It,i as Lt,k as Rt,l as zt,m as Bt,n as Vt,o as Ht,p as Ut,r as Wt,s as Gt,t as Kt,u as qt,v as Jt,w as Yt,x as Xt,y as Zt}from"./workspace-manager-CL4JvHkJ.js";var Qt=ne.map(e=>e.id),$t=[...new Set([...S,`mcp`,`knowledge`])],en=[{labelKey:`presetMode.preciseLabel`,tipKey:`presetMode.preciseTip`,temp:.2,topP:1},{labelKey:`presetMode.generalLabel`,tipKey:`presetMode.generalTip`,temp:.45,topP:.9},{labelKey:`presetMode.divergentLabel`,tipKey:`presetMode.divergentTip`,temp:.65,topP:.9},{labelKey:`presetMode.creativeLabel`,tipKey:`presetMode.creativeTip`,temp:.9,topP:.9}];n(`zh`,{contextUsage:{compactionInjection:`[上下文摘要|压缩了{count}条历史]`}}),n(`en`,{contextUsage:{compactionInjection:`[Context Summary | {count} messages compacted]`}});var tn=2e3,nn=.7,rn=1e3;function an(e,{isolateChat:t=!0,maxMemoryMessages:n=null,compaction:r=null,historyBudget:i=1/0,currentMessage:a=null}={}){let o=a||{role:`user`,content:``};if(!t)return{messages:[o],keptHistory:[],compactionApplied:!1,trimmedCount:0,historySummaryText:null};let c=Array.isArray(e)?e:[],l=!1,u=-1;r&&r.summary&&r.upToMessageId&&(u=c.findIndex(e=>e.messageId===r.upToMessageId),l=u>=0);let f=c,p=c.map((e,t)=>t);n&&n>0&&c.length>n&&(f=c.slice(c.length-n),p=p.slice(c.length-n));let m=[];for(let e=0;e<f.length;e++)l&&p[e]<=u||m.push(f[e]);let g=[],_=E([o]);for(let e=m.length-1;e>=0;e--){let t=m[e],n=E([{...t,content:d(t.content)}]);if(_+n<=i)g.unshift(t),_+=n;else break}let v=null,y=m.length-g.length;if(y>0){let e=h(m.slice(0,y));e&&(v=s(e)>rn?e.substring(0,rn*4)+`
3
3
  ...[历史摘要已截断]`:e)}return{messages:[...g,o],keptHistory:g,compactionApplied:l,trimmedCount:y,historySummaryText:v}}function on(e,t){return!t||!t.summary?e:`${e}\n\n${r(`contextUsage.compactionInjection`,{count:t.compressedCount||0})}\n${t.summary}`}function sn(e,t,n,r){return t?.compactionApplied&&n?.summary?e[0]={...e[0],content:on(e[0].content,n)}:n?.summary&&r?.warn(`[SidePanel] contextCompaction invalid (upToMessageId not found), ignored this send`),e}function cn({model:e,customModelMap:t=null,systemPromptText:n=``,toolCount:r=0,history:i=[],inputText:a=``,maxMemoryMessages:o=null,compaction:u=null,isolateChat:d=!0,userConfiguredWindow:f=0}={}){let m=p(e,f,t),h=m-s(n)-l-tn,g=Math.floor(Math.max(h,0)*nn),_={role:`user`,content:a},v=d?u:null,y=an(i,{isolateChat:d,maxMemoryMessages:o,compaction:v,historyBudget:g,currentMessage:_}),b=s(y.compactionApplied?on(n,v):n),x=r*200,S=E(y.keptHistory),C=a&&a.trim()?E([_]):0,w=b+x+S+C,T=c(w,m);return{usedTokens:w,contextWindow:m,ratio:m>0?w/m:0,level:T.level,breakdown:{system:b,tools:x,history:S,input:C,outputReserve:l,safetyMargin:tn,selectedCount:y.keptHistory.length,totalCount:i.length,trimmedCount:y.trimmedCount,compactionApplied:y.compactionApplied,compactionInvalid:!!(v&&v.summary&&!y.compactionApplied),historyBudget:g}}}function ln(e,{maxMemoryMessages:t=null,compaction:n=null}={}){let r=an(e,{isolateChat:!0,maxMemoryMessages:t,compaction:n,historyBudget:1/0,currentMessage:null}),i=[],a=!!(r.compactionApplied&&n?.summary);a&&i.push({role:`user`,content:`【已有摘要】\n${n.summary}`});for(let e of r.keptHistory){let t=d(e.content);i.push({role:e.role,content:typeof t==`string`?t:JSON.stringify(t??``)||``})}return{material:i,includedCount:r.keptHistory.length,hasOldSummary:a}}function un(e){if(!e||!e.trim()||e.trim()==`/`)return;let t=e.trim(),n=C.inputHistory.indexOf(t);n!==-1&&C.inputHistory.splice(n,1),C.inputHistory.push(t),C.inputHistory.length>20&&C.inputHistory.shift(),dn()}function dn(){try{chrome.storage.local.set({inputHistory:C.inputHistory}),i.debug(`[SidePanel] input history saved,count:`,C.inputHistory.length)}catch(e){i.error(`[SidePanel] saveinput history failed:`,e)}}var fn=[`workspace`,`bookmark`,`toc`,`search`,`todo`,`schedule`],pn=`.workspace-panel.expanded, .bookmark-panel.expanded, .message-toc-panel.expanded, .search-panel.expanded, .schedule-panel.open`,mn=null,hn=null;function gn(){if(mn)return mn;mn=document.createElement(`div`),mn.className=`side-rail`,mn.id=`sideRail`,mn.innerHTML=fn.map(e=>`<div class="side-rail-slot" data-slot="${e}"></div>`).join(``),document.body.appendChild(mn),vn();let e=document.getElementById(`chatContainer`);return e&&typeof ResizeObserver<`u`&&new ResizeObserver(vn).observe(e),window.addEventListener(`resize`,vn),mn}function _n(e){return(mn||gn()).querySelector(`.side-rail-slot[data-slot="${e}"]`)}function vn(){if(!mn)return;let e=document.getElementById(`chatContainer`);if(!e)return;let t=e.getBoundingClientRect(),n=window.innerHeight;mn.style.top=`${Math.max(0,Math.round(t.top))}px`,mn.style.bottom=`${Math.max(0,Math.round(n-t.bottom))}px`,yn()}function yn(){hn&&clearTimeout(hn),hn=setTimeout(()=>{hn=null,document.querySelectorAll(pn).forEach(Ue)},120)}n(`zh`,{panelFs:{enter:`全屏`,exit:`退出全屏`}}),n(`en`,{panelFs:{enter:`Fullscreen`,exit:`Exit fullscreen`}});var bn=`panel-fullscreen`,xn=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M16 3h3a2 2 0 0 1 2 2v3"/><path d="M8 21H5a2 2 0 0 1-2-2v-3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/></svg>`,Sn=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 8h3a2 2 0 0 0 2-2V3"/><path d="M21 8h-3a2 2 0 0 1-2-2V3"/><path d="M3 16h3a2 2 0 0 1 2 2v3"/><path d="M21 16h-3a2 2 0 0 0-2 2v3"/></svg>`,Cn=new WeakSet;function wn(e){return!!e&&Cn.has(e)}function Tn(e,t){e&&(t?Cn.add(e):Cn.delete(e),e.classList.add(`panel-fs-no-anim`),e.classList.toggle(bn,!!t),e.offsetWidth,requestAnimationFrame(()=>e.classList.remove(`panel-fs-no-anim`)))}function En(e){Tn(e,!1)}function Dn(e,t){if(!e)return;let n=r(t?`panelFs.exit`:`panelFs.enter`);e.innerHTML=t?Sn:xn,e.title=n,e.setAttribute(`aria-label`,n),e.setAttribute(`aria-pressed`,String(!!t))}function On(e=``){let t=document.createElement(`button`);return t.type=`button`,t.className=[`panel-fullscreen-btn`,e].filter(Boolean).join(` `),t.innerHTML=xn,t}function kn(e,t,{onToggle:n}={}){if(!e||!t)return()=>{};let r=()=>Dn(e,wn(t));return e.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation();let i=!wn(t);Tn(t,i),r(),n&&n(i)}),r(),r}n(`zh`,{messageToc:{toggleTitle:`显示目录(H{count}个标题)`,title:`目录`,headingCount:`{count} 个`,lock:`锁定目录(不自动收起)`,unlock:`解锁目录`,close:`关闭目录`}}),n(`en`,{messageToc:{toggleTitle:`Show table of contents (H{count} headings)`,title:`Contents`,headingCount:`{count}`,lock:`Pin table of contents`,unlock:`Unpin table of contents`,close:`Close table of contents`}});var An=`messageTocLocked`,jn=!1,Mn=null,Nn=null,Pn=null;function Fn(e){Nn=e,Pn={parent:e.parentElement,nextSibling:e.nextSibling},document.body.appendChild(e),e.classList.add(`expanded`),Tn(e,!0)}function In(){let e=Nn;if(!e)return;Nn=null,Tn(e,!1);let t=Pn;Pn=null,t?.parent?.isConnected?t.parent.insertBefore(e,t.nextSibling):e.remove()}var Ln=`<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 9.9-1"/></svg>`,Rn=`<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>`;function zn(e){e&&(e.innerHTML=jn?Rn:Ln,e.title=r(jn?`messageToc.unlock`:`messageToc.lock`),e.classList.toggle(`locked`,jn))}function Bn(){try{let e=chrome.storage?.local?.set?.({[An]:jn});e&&typeof e.catch==`function`&&e.catch(()=>{})}catch{}}function Vn(){document.addEventListener(`mouseover`,Hn,!0),document.addEventListener(`mouseout`,Un,!0);try{let e=chrome.storage?.local?.get?.(An);e&&typeof e.then==`function`?e.then(e=>{jn=!!(e&&e[An])}).catch(()=>{}):e&&typeof e==`object`&&(jn=!!e[An])}catch{}i.debug(`[SidePanel] messagedirectory featureinitializing`)}function Hn(e){if(!(e.target instanceof Element))return;if(e.target.closest(`.message-toc-container`)){C.isMouseOverToc=!0;return}let t=e.target.closest(`.message.assistant`),n=e.target.closest(`.workspace-preview-markdown`);if(!t&&!n)return;let r=t||n,i=r.querySelectorAll(`.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6`);if(i.length===0){!jn&&!Nn&&Xn();return}Yn(r,i)}function Un(e){if(!(e.target instanceof Element))return;if(e.target.closest(`.message-toc-container`)){C.isMouseOverToc=!1,C.tocHideTimer&&=(clearTimeout(C.tocHideTimer),null);return}let t=e.target.closest(`.message.assistant`),n=e.target.closest(`.workspace-preview-markdown`);if(!t&&!n||jn)return;let r=e.relatedTarget;r&&(r.closest(`.message-toc-container`)||r.closest(`.message.assistant`)||r.closest(`.workspace-preview-markdown`))||C.isMouseOverToc||(C.tocHideTimer&&clearTimeout(C.tocHideTimer),C.tocHideTimer=setTimeout(()=>{!C.isMouseOverToc&&!Nn&&Xn(),C.tocHideTimer=null},800))}var Wn=null,Gn=null;function Kn(e){let t=e.parentElement;for(;t&&t!==document.body&&t!==document.documentElement;){let e=getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`||e===`overlay`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function qn(e,t,n,r){if(Jn(),n.length===0)return;let i=Kn(t),a=e.querySelector(`.message-toc-content`),o=Array.from(e.querySelectorAll(`.message-toc-item`)),s=new Map(o.map(e=>[e.dataset.target,e])),c=0,l=null,u=-1,d=e=>{if(!a)return;let t=e.getBoundingClientRect(),n=a.getBoundingClientRect();(t.top<n.top||t.bottom>n.bottom)&&(a.scrollTop+=t.top-n.top-(n.height-t.height)/2)},f=()=>{let e=window.innerHeight||document.documentElement.clientHeight||0;if(!i)return{top:0,bottom:e};let t=i.getBoundingClientRect();return{top:Math.max(t.top,0),bottom:Math.min(t.top+i.clientHeight,e)}},p=()=>{if(i)return i.scrollTop+i.clientHeight>=i.scrollHeight-2;let e=document.documentElement;return window.scrollY+window.innerHeight>=e.scrollHeight-2},m=()=>i?i.scrollTop<=2:window.scrollY<=2,h=()=>{if(c=0,!e.isConnected)return;let t=f(),i=t.top,a=t.bottom,h=Math.max(a-i,1),g=n.map(e=>{let t=e.getBoundingClientRect();if(t.width||t.height)return t.top;let n=e.closest(`.markdown-body`);return n?n.getBoundingClientRect().top:t.top}),_=0;for(let e=0;e<g.length&&g[e]<=i;e++)_=e;let v=i+h*.75,y=_,b=_+1;if(b<g.length){let e=g[b];u===b?e<=a&&(y=b):e<=v&&(y=b)}m()?y=0:p()&&(y=n.length-1);let x=n[y];if(!x||x.id===l)return;u=y,l=x.id,o.forEach(e=>e.classList.toggle(`active`,e.dataset.target===l));let S=s.get(l);S&&r.classList.contains(`expanded`)&&d(S)},g=()=>{c||=requestAnimationFrame(h)};document.addEventListener(`scroll`,g,{capture:!0,passive:!0}),window.addEventListener(`resize`,g,{passive:!0});let _=typeof IntersectionObserver==`function`?new IntersectionObserver(g,{threshold:[0,.25,.5,.75,1]}):null;_&&n.forEach(e=>_.observe(e)),h(),Gn=()=>{if(h(),!l)return;let e=s.get(l);e&&d(e)},Wn=()=>{c&&cancelAnimationFrame(c),c=0,document.removeEventListener(`scroll`,g,{capture:!0}),window.removeEventListener(`resize`,g),_&&_.disconnect()}}function Jn(){Wn&&=(Wn(),null),Gn=null}function Yn(e,t){let n=Array.from(t),i=Mn;C.messageTocContainer&&Xn(),Mn=i,n.forEach((e,t)=>{e.id||=`toc-heading-${Date.now()}-${t}`});let a=document.createElement(`div`);a.className=`message-toc-container`,a.dataset.headingsCount=n.length;let o=0,s=n.map(e=>{let t=parseInt(e.tagName.charAt(1)),n=e.textContent.trim(),r=n.length>30?n.substring(0,30)+`...`:n,i=`H${t}`;return o++,`
4
4
  <li class="message-toc-item level-${t}"
5
5
  data-target="${e.id}"
@@ -1126,7 +1126,7 @@ It is this session's directory or the agent default, so it stays accessible (wor
1126
1126
  <source src="${c}" type="${Y(o)}">
1127
1127
  </audio>
1128
1128
  <div id="mediaUnsupportedHint" style="display:none;">${u}</div>
1129
- </div>`;let d=i.querySelector(`video, audio`),f=i.querySelector(`#mediaUnsupportedHint`);if(d){let e=()=>{d.style.display=`none`,f&&(f.style.display=`block`)};d.addEventListener(`error`,e),i.querySelectorAll(`source`).forEach(t=>t.addEventListener(`error`,e))}}var Q_=!1;function $_(e,t){let n=e.getBoundingClientRect();t.style.top=n.bottom+4+`px`;let r=n.right-160;t.style.left=Math.max(4,r)+`px`,t.style.right=`auto`}function ev(e,t){$_(e,t),t.classList.add(`show`)}function tv(){let e=document.getElementById(`workspacePreviewExportMenu`),t=document.getElementById(`workspacePreviewExportBtn`),n=document.getElementById(`workspacePreviewExportDropdown`);if(!e||!t||!n)return;document.body.appendChild(n),t.addEventListener(`click`,e=>{e.stopPropagation(),n.classList.contains(`show`)?n.classList.remove(`show`):ev(t,n)});let r=null,i=null;e.addEventListener(`mouseenter`,()=>{i&&=(clearTimeout(i),null),r=setTimeout(()=>{ev(t,n)},200)}),e.addEventListener(`mouseleave`,()=>{r&&=(clearTimeout(r),null),i=setTimeout(()=>{!e.matches(`:hover`)&&!n.matches(`:hover`)&&n.classList.remove(`show`)},300)}),n.addEventListener(`mouseenter`,()=>{i&&=(clearTimeout(i),null)}),n.addEventListener(`mouseleave`,()=>{i=setTimeout(()=>{!e.matches(`:hover`)&&!n.matches(`:hover`)&&n.classList.remove(`show`)},200)}),n.querySelectorAll(`.ws-export-dropdown-item`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let r=e.dataset.exportType;n.classList.remove(`show`),rv(r)})}),document.addEventListener(`click`,t=>{!e.contains(t.target)&&!n.contains(t.target)&&n.classList.remove(`show`)});let a=()=>{n.classList.contains(`show`)&&$_(t,n)};document.getElementById(`workspacePreviewContent`)?.addEventListener(`scroll`,a),window.addEventListener(`resize`,a)}function nv(){return document.getElementById(`workspacePreviewArea`).dataset.markdownText||``}async function rv(e){if(Q_)return;Q_=!0;let t=document.getElementById(`workspacePreviewExportBtn`);document.getElementById(`workspacePreviewExportMenu`);let n=document.getElementById(`workspacePreviewExportDropdown`),a=document.getElementById(`workspacePreviewArea`).dataset.previewName||`export`,o=t.innerHTML;t.innerHTML=`<svg viewBox="0 0 24 24" fill="none" style="animation: spin 0.8s linear infinite; width: 14px; height: 14px; flex-shrink: 0;"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-dasharray="31.4" stroke-dashoffset="10" opacity="0.25"/><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-dasharray="31.4" stroke-dashoffset="10"/></svg>`,t.disabled=!0,t.style.opacity=`0.6`;try{switch(e){case`docx`:await ov(a);break;case`pdf`:await cv(a);break;case`image`:await lv(a);break;case`md`:uv(a);break}}catch(e){i.error(`[WorkspacePanel] export failed:`,e),F(r(`chatExport.exportFailed`,{message:e.message}),`error`)}finally{Q_=!1,t.innerHTML=o,t.disabled=!1,t.style.opacity=`1`,n.classList.remove(`show`)}}async function iv(e){if(typeof mermaid>`u`)return;let{renderMermaidInContainer:t,convertSvgsToImages:n}=await A(async()=>{let{renderMermaidInContainer:e,convertSvgsToImages:t}=await import(`./chat-export-DWrq6XW7.js`);return{renderMermaidInContainer:e,convertSvgsToImages:t}},__vite__mapDeps([9,10,1,11,2,3,12,0]));await t(e),await n(e)}async function av(e){if(typeof mermaid>`u`||!/```mermaid/i.test(e))return e;let{renderMermaidInContainer:t,convertSvgsToImages:n}=await A(async()=>{let{renderMermaidInContainer:e,convertSvgsToImages:t}=await import(`./chat-export-DWrq6XW7.js`);return{renderMermaidInContainer:e,convertSvgsToImages:t}},__vite__mapDeps([9,10,1,11,2,3,12,0]));try{let r=tt(e),i=document.createElement(`div`);i.style.cssText=`position:fixed;left:-9999px;top:-9999px;`,i.innerHTML=r,document.body.appendChild(i),await t(i),await n(i);let a=i.querySelectorAll(`.mermaid`),o=[];for(let e of a){let t=e.querySelector(`img`);t&&t.src&&t.src.startsWith(`data:`)?o.push(t.src):o.push(null)}if(document.body.removeChild(i),o.length===0)return e;let s=0;return e.replace(/```\s*mermaid\s*[\r\n]+([\s\S]*?)```/gi,e=>{let t=o[s];return s++,t?`![mermaid](${t})`:e})}catch(t){return i.warn(`[WorkspacePanel] Mermaid pre-render failed:`,t.message),e}}async function ov(e){let{Packer:t}=await A(async()=>{let{Packer:e}=await import(`./dist-BUuoW_84.js`);return{Packer:e}},__vite__mapDeps([10,1])),{createDocxDocument:n}=await A(async()=>{let{createDocxDocument:e}=await import(`./chat-export-DWrq6XW7.js`);return{createDocxDocument:e}},__vite__mapDeps([9,10,1,11,2,3,12,0])),i=nv();if(!i){F(r(`chatExport.noContent`),`error`);return}i=await av(i);let a=n(await sv(i)),o=await t.toBlob(a),s=`word-${new Date().getTime()}.docx`;dv(o,s),F(r(`workspace.downloaded`,{name:s}),`success`)}async function sv(e){let{Document:t,Packer:n,Paragraph:r,TextRun:i,HeadingLevel:a,Table:o,TableRow:s,TableCell:c,AlignmentType:l,WidthType:u,BorderStyle:d,ImageRun:f,ExternalHyperlink:p,convertInchesToTwip:m}=await A(async()=>{let{Document:e,Packer:t,Paragraph:n,TextRun:r,HeadingLevel:i,Table:a,TableRow:o,TableCell:s,AlignmentType:c,WidthType:l,BorderStyle:u,ImageRun:d,ExternalHyperlink:f,convertInchesToTwip:p}=await import(`./dist-BUuoW_84.js`);return{Document:e,Packer:t,Paragraph:n,TextRun:r,HeadingLevel:i,Table:a,TableRow:o,TableCell:s,AlignmentType:c,WidthType:l,BorderStyle:u,ImageRun:d,ExternalHyperlink:f,convertInchesToTwip:p}},__vite__mapDeps([10,1])),{createTextRuns:h,sanitizeDocxText:g,nextDocxImageId:_,isDocxEmbeddableImageType:v}=await A(async()=>{let{createTextRuns:e,sanitizeDocxText:t,nextDocxImageId:n,isDocxEmbeddableImageType:r}=await import(`./chat-export-DWrq6XW7.js`);return{createTextRuns:e,sanitizeDocxText:t,nextDocxImageId:n,isDocxEmbeddableImageType:r}},__vite__mapDeps([9,10,1,11,2,3,12,0]));if(!e||!e.trim())return[new r({children:[new i({text:``})]})];let y=[],b=g(e),x=[];b=b.replace(/```(\w*)\n([\s\S]*?)```/g,(e,t,n)=>{let r=x.length;return x.push({lang:t||``,code:n.trimEnd()}),`\n\n%%CODEBLOCK_${r}%%\n\n`});let S=[];b=b.replace(/<table[\s\S]*?<\/table>/gi,e=>{let t=S.length;return S.push(e),`\n\n%%HTMLTABLE_${t}%%\n\n`});let C=nt(b,`MDTABLE`);b=C.text;let w=C.blocks.map(e=>e.full),T=b.split(/\n{2,}/).filter(e=>e.trim());function E(e){if(!e)return[];let t=/(\*\*(.+?)\*\*|(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)|__(.+?)__|(?<!_)_(?!_)(.+?)(?<!_)_(?!_)|`([^`]+)`|\[([^\]]+)\]\(([^)]+)\)|!\[([^\]]*)\]\(([^)]+)\))/,n=[],r=e;for(;r.length>0;){let e=r.match(t);if(!e){n.push(...h(r));break}let a=e.index;a>0&&n.push(...h(r.slice(0,a)));let o=e[1];if(e[2]!==void 0)n.push(...h(e[2],{bold:!0}));else if(e[3]!==void 0)n.push(...h(e[3],{italics:!0}));else if(e[4]!==void 0)n.push(...h(e[4],{bold:!0}));else if(e[5]!==void 0)n.push(...h(e[5],{italics:!0}));else if(e[6]!==void 0)n.push(new i({text:e[6],font:`Consolas`,size:20}));else if(e[7]!==void 0)n.push(new p({children:[new i({text:e[7],style:`Hyperlink`})],link:e[8]}));else if(e[9]!==void 0){let t=e[10];if(t.startsWith(`data:`))try{let[r,a]=t.split(`,`),o=r.match(/data:(image\/(\w+))/);if(o&&a&&v(o[2])){let t=atob(a),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);n.push(new f({data:r,transformation:{width:400,height:300},type:o[2],altText:{id:_(),name:e[9]||`image`}}))}else n.push(new i({text:`[Image: `+(e[9]||`image`)+`]`,italics:!0,color:`999999`}))}catch{n.push(new i({text:`[Image]`,italics:!0,color:`999999`}))}else n.push(new i({text:`[Image: `+(e[9]||t)+`]`,italics:!0,color:`999999`}))}r=r.slice(a+o.length)}return n}function D(e){let t=new DOMParser().parseFromString(e,`text/html`),n=[];return t.querySelectorAll(`tr`).forEach(e=>{let t=[];e.querySelectorAll(`th, td`).forEach(e=>t.push(e.textContent.trim())),t.length>0&&n.push(t)}),n}function O(e){let t=e.trim().split(`
1129
+ </div>`;let d=i.querySelector(`video, audio`),f=i.querySelector(`#mediaUnsupportedHint`);if(d){let e=()=>{d.style.display=`none`,f&&(f.style.display=`block`)};d.addEventListener(`error`,e),i.querySelectorAll(`source`).forEach(t=>t.addEventListener(`error`,e))}}var Q_=!1;function $_(e,t){let n=e.getBoundingClientRect();t.style.top=n.bottom+4+`px`;let r=n.right-160;t.style.left=Math.max(4,r)+`px`,t.style.right=`auto`}function ev(e,t){$_(e,t),t.classList.add(`show`)}function tv(){let e=document.getElementById(`workspacePreviewExportMenu`),t=document.getElementById(`workspacePreviewExportBtn`),n=document.getElementById(`workspacePreviewExportDropdown`);if(!e||!t||!n)return;document.body.appendChild(n),t.addEventListener(`click`,e=>{e.stopPropagation(),n.classList.contains(`show`)?n.classList.remove(`show`):ev(t,n)});let r=null,i=null;e.addEventListener(`mouseenter`,()=>{i&&=(clearTimeout(i),null),r=setTimeout(()=>{ev(t,n)},200)}),e.addEventListener(`mouseleave`,()=>{r&&=(clearTimeout(r),null),i=setTimeout(()=>{!e.matches(`:hover`)&&!n.matches(`:hover`)&&n.classList.remove(`show`)},300)}),n.addEventListener(`mouseenter`,()=>{i&&=(clearTimeout(i),null)}),n.addEventListener(`mouseleave`,()=>{i=setTimeout(()=>{!e.matches(`:hover`)&&!n.matches(`:hover`)&&n.classList.remove(`show`)},200)}),n.querySelectorAll(`.ws-export-dropdown-item`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let r=e.dataset.exportType;n.classList.remove(`show`),rv(r)})}),document.addEventListener(`click`,t=>{!e.contains(t.target)&&!n.contains(t.target)&&n.classList.remove(`show`)});let a=()=>{n.classList.contains(`show`)&&$_(t,n)};document.getElementById(`workspacePreviewContent`)?.addEventListener(`scroll`,a),window.addEventListener(`resize`,a)}function nv(){return document.getElementById(`workspacePreviewArea`).dataset.markdownText||``}async function rv(e){if(Q_)return;Q_=!0;let t=document.getElementById(`workspacePreviewExportBtn`);document.getElementById(`workspacePreviewExportMenu`);let n=document.getElementById(`workspacePreviewExportDropdown`),a=document.getElementById(`workspacePreviewArea`).dataset.previewName||`export`,o=t.innerHTML;t.innerHTML=`<svg viewBox="0 0 24 24" fill="none" style="animation: spin 0.8s linear infinite; width: 14px; height: 14px; flex-shrink: 0;"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-dasharray="31.4" stroke-dashoffset="10" opacity="0.25"/><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-dasharray="31.4" stroke-dashoffset="10"/></svg>`,t.disabled=!0,t.style.opacity=`0.6`;try{switch(e){case`docx`:await ov(a);break;case`pdf`:await cv(a);break;case`image`:await lv(a);break;case`md`:uv(a);break}}catch(e){i.error(`[WorkspacePanel] export failed:`,e),F(r(`chatExport.exportFailed`,{message:e.message}),`error`)}finally{Q_=!1,t.innerHTML=o,t.disabled=!1,t.style.opacity=`1`,n.classList.remove(`show`)}}async function iv(e){if(typeof mermaid>`u`)return;let{renderMermaidInContainer:t,convertSvgsToImages:n}=await A(async()=>{let{renderMermaidInContainer:e,convertSvgsToImages:t}=await import(`./chat-export-ryKcmB-h.js`);return{renderMermaidInContainer:e,convertSvgsToImages:t}},__vite__mapDeps([9,10,1,11,2,3,12,0]));await t(e),await n(e)}async function av(e){if(typeof mermaid>`u`||!/```mermaid/i.test(e))return e;let{renderMermaidInContainer:t,convertSvgsToImages:n}=await A(async()=>{let{renderMermaidInContainer:e,convertSvgsToImages:t}=await import(`./chat-export-ryKcmB-h.js`);return{renderMermaidInContainer:e,convertSvgsToImages:t}},__vite__mapDeps([9,10,1,11,2,3,12,0]));try{let r=tt(e),i=document.createElement(`div`);i.style.cssText=`position:fixed;left:-9999px;top:-9999px;`,i.innerHTML=r,document.body.appendChild(i),await t(i),await n(i);let a=i.querySelectorAll(`.mermaid`),o=[];for(let e of a){let t=e.querySelector(`img`);t&&t.src&&t.src.startsWith(`data:`)?o.push(t.src):o.push(null)}if(document.body.removeChild(i),o.length===0)return e;let s=0;return e.replace(/```\s*mermaid\s*[\r\n]+([\s\S]*?)```/gi,e=>{let t=o[s];return s++,t?`![mermaid](${t})`:e})}catch(t){return i.warn(`[WorkspacePanel] Mermaid pre-render failed:`,t.message),e}}async function ov(e){let{Packer:t}=await A(async()=>{let{Packer:e}=await import(`./dist-BUuoW_84.js`);return{Packer:e}},__vite__mapDeps([10,1])),{createDocxDocument:n}=await A(async()=>{let{createDocxDocument:e}=await import(`./chat-export-ryKcmB-h.js`);return{createDocxDocument:e}},__vite__mapDeps([9,10,1,11,2,3,12,0])),i=nv();if(!i){F(r(`chatExport.noContent`),`error`);return}i=await av(i);let a=n(await sv(i)),o=await t.toBlob(a),s=`word-${new Date().getTime()}.docx`;dv(o,s),F(r(`workspace.downloaded`,{name:s}),`success`)}async function sv(e){let{Document:t,Packer:n,Paragraph:r,TextRun:i,HeadingLevel:a,Table:o,TableRow:s,TableCell:c,AlignmentType:l,WidthType:u,BorderStyle:d,ImageRun:f,ExternalHyperlink:p,convertInchesToTwip:m}=await A(async()=>{let{Document:e,Packer:t,Paragraph:n,TextRun:r,HeadingLevel:i,Table:a,TableRow:o,TableCell:s,AlignmentType:c,WidthType:l,BorderStyle:u,ImageRun:d,ExternalHyperlink:f,convertInchesToTwip:p}=await import(`./dist-BUuoW_84.js`);return{Document:e,Packer:t,Paragraph:n,TextRun:r,HeadingLevel:i,Table:a,TableRow:o,TableCell:s,AlignmentType:c,WidthType:l,BorderStyle:u,ImageRun:d,ExternalHyperlink:f,convertInchesToTwip:p}},__vite__mapDeps([10,1])),{createTextRuns:h,sanitizeDocxText:g,nextDocxImageId:_,isDocxEmbeddableImageType:v}=await A(async()=>{let{createTextRuns:e,sanitizeDocxText:t,nextDocxImageId:n,isDocxEmbeddableImageType:r}=await import(`./chat-export-ryKcmB-h.js`);return{createTextRuns:e,sanitizeDocxText:t,nextDocxImageId:n,isDocxEmbeddableImageType:r}},__vite__mapDeps([9,10,1,11,2,3,12,0]));if(!e||!e.trim())return[new r({children:[new i({text:``})]})];let y=[],b=g(e),x=[];b=b.replace(/```(\w*)\n([\s\S]*?)```/g,(e,t,n)=>{let r=x.length;return x.push({lang:t||``,code:n.trimEnd()}),`\n\n%%CODEBLOCK_${r}%%\n\n`});let S=[];b=b.replace(/<table[\s\S]*?<\/table>/gi,e=>{let t=S.length;return S.push(e),`\n\n%%HTMLTABLE_${t}%%\n\n`});let C=nt(b,`MDTABLE`);b=C.text;let w=C.blocks.map(e=>e.full),T=b.split(/\n{2,}/).filter(e=>e.trim());function E(e){if(!e)return[];let t=/(\*\*(.+?)\*\*|(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)|__(.+?)__|(?<!_)_(?!_)(.+?)(?<!_)_(?!_)|`([^`]+)`|\[([^\]]+)\]\(([^)]+)\)|!\[([^\]]*)\]\(([^)]+)\))/,n=[],r=e;for(;r.length>0;){let e=r.match(t);if(!e){n.push(...h(r));break}let a=e.index;a>0&&n.push(...h(r.slice(0,a)));let o=e[1];if(e[2]!==void 0)n.push(...h(e[2],{bold:!0}));else if(e[3]!==void 0)n.push(...h(e[3],{italics:!0}));else if(e[4]!==void 0)n.push(...h(e[4],{bold:!0}));else if(e[5]!==void 0)n.push(...h(e[5],{italics:!0}));else if(e[6]!==void 0)n.push(new i({text:e[6],font:`Consolas`,size:20}));else if(e[7]!==void 0)n.push(new p({children:[new i({text:e[7],style:`Hyperlink`})],link:e[8]}));else if(e[9]!==void 0){let t=e[10];if(t.startsWith(`data:`))try{let[r,a]=t.split(`,`),o=r.match(/data:(image\/(\w+))/);if(o&&a&&v(o[2])){let t=atob(a),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);n.push(new f({data:r,transformation:{width:400,height:300},type:o[2],altText:{id:_(),name:e[9]||`image`}}))}else n.push(new i({text:`[Image: `+(e[9]||`image`)+`]`,italics:!0,color:`999999`}))}catch{n.push(new i({text:`[Image]`,italics:!0,color:`999999`}))}else n.push(new i({text:`[Image: `+(e[9]||t)+`]`,italics:!0,color:`999999`}))}r=r.slice(a+o.length)}return n}function D(e){let t=new DOMParser().parseFromString(e,`text/html`),n=[];return t.querySelectorAll(`tr`).forEach(e=>{let t=[];e.querySelectorAll(`th, td`).forEach(e=>t.push(e.textContent.trim())),t.length>0&&n.push(t)}),n}function O(e){let t=e.trim().split(`
1130
1130
  `),n=[];for(let e of t){if(/^[\s\|:\-]+$/.test(e.replace(/\|/g,``)))continue;let t=Ge(e).map(e=>e.trim());t.length>0&&n.push(t)}return n}function k(e){if(e.length===0)return new r({children:[]});let t=Math.max(...e.map(e=>e.length));return new o({rows:e.map((e,n)=>{let i=[];for(let a=0;a<t;a++){let o=e[a]||``;i.push(new c({children:[new r({children:E(o),spacing:{before:40,after:40}})],shading:n===0?{fill:`F2F2F2`}:void 0,width:{size:Math.round(100/t*100)/100,type:u.PERCENTAGE}}))}return new s({children:i})}),width:{size:100,type:u.PERCENTAGE},borders:{top:{style:d.SINGLE,size:1,color:`DDDDDD`},bottom:{style:d.SINGLE,size:1,color:`DDDDDD`},left:{style:d.SINGLE,size:1,color:`DDDDDD`},right:{style:d.SINGLE,size:1,color:`DDDDDD`},insideHorizontal:{style:d.SINGLE,size:1,color:`DDDDDD`},insideVertical:{style:d.SINGLE,size:1,color:`DDDDDD`}}})}for(let e of T){let t=e.trim(),n=t.match(/^%%CODEBLOCK_(\d+)%%$/);if(n){let{lang:e,code:t}=x[parseInt(n[1])],a=e?`${e} code`:`code`;y.push(new r({children:[new i({text:a,bold:!0,font:`Consolas`,size:18})]}));let o=t.split(`
1131
1131
  `);for(let e of o)y.push(new r({children:[new i({text:e||` `,font:`Consolas`,size:18})],spacing:{before:0,after:0,line:240},shading:{fill:`F5F5F5`}}));y.push(new r({children:[new i({text:``})]}));continue}let o=t.match(/^%%HTMLTABLE_(\d+)%%$/);if(o){let e=D(S[parseInt(o[1])]);e.length>0&&(y.push(k(e)),y.push(new r({children:[new i({text:``})]})));continue}let s=t.match(/^%%MDTABLE_(\d+)%%$/);if(s){let e=O(w[parseInt(s[1])]);y.push(k(e)),y.push(new r({children:[new i({text:``})]}));continue}let c=t.match(/^(#{1,6})\s+(.+)/);if(c){let e={1:a.HEADING_1,2:a.HEADING_2,3:a.HEADING_3,4:a.HEADING_4,5:a.HEADING_5,6:a.HEADING_6};y.push(new r({children:E(c[2]),heading:e[c[1].length]||a.HEADING_1,border:{bottom:{style:d.SINGLE,size:6,color:`EAECEF`}}}));let n=t.slice(c[0].length).replace(/^\n+/,``).trim();n&&y.push(new r({children:E(n),spacing:{before:60,after:60}}));continue}if(/^(---|\*\*\*|___)\s*$/.test(t)){y.push(new r({children:[],border:{bottom:{style:d.SINGLE,size:6,color:`CCCCCC`}},spacing:{before:200,after:200}}));continue}if(/^[\-\*\+]\s+/.test(t)){let t=e.split(/\n(?=[\-\*\+]\s+)/);for(let e of t)y.push(new r({children:E(e.replace(/^[\-\*\+]\s+/,``)),bullet:{level:0},spacing:{before:40,after:40}}));continue}if(/^\d+\.\s+/.test(t)){let t=e.split(/\n(?=\d+\.\s+)/);for(let e of t)y.push(new r({children:E(e.replace(/^\d+\.\s+/,``)),numbering:{reference:`default`,level:0},spacing:{before:40,after:40}}));continue}if(t.startsWith(`>`)){let t=e.split(`
1132
1132
  `).map(e=>e.replace(/^>\s?/,``)).join(`
@@ -1387,7 +1387,7 @@ It is this session's directory or the agent default, so it stays accessible (wor
1387
1387
  <span class="page-action-btn" data-action="translate" data-tab-id="${e.id}" title="${r(`pageSelector.translatePage`)}">${r(`pageSelector.translatePage`)}</span>
1388
1388
  </span>
1389
1389
  </div>
1390
- `}).join(``),t.querySelectorAll(`img.favicon-img`).forEach(e=>{e.addEventListener(`error`,()=>{e.style.display=`none`})}),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,t=>{let n=t.target.closest(`.page-action-btn`);if(n){t.stopPropagation(),Fx(parseInt(n.dataset.tabId),n.dataset.action);return}Px(parseInt(e.dataset.tabId))})})}function jx(e){e.forEach((e,t)=>{t===C.selectedPageIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function Mx(e){C.selectedPage={id:e.id,title:e.title||r(`pageSelector.noTitle`),url:e.url||``,favIconUrl:e.favIconUrl||``};let t=document.getElementById(`pageIndicator`),n=document.getElementById(`pageIndicatorName`);if(t&&n){let e=C.selectedPage.title&&C.selectedPage.title!==r(`pageSelector.noTitle`)?C.selectedPage.title:``,i=C.selectedPage.url||``;e&&i?n.textContent=`${e} · ${i}`:n.textContent=e||i,t.style.display=`flex`}}function Nx(){C.selectedPage=null,C.selectedPageIndex=-1;let e=document.getElementById(`pageIndicator`);e&&(e.style.display=`none`)}function Px(e){let t=document.getElementById(`userInput`);if(t){let e=Da(t.value,t.selectionStart,`at`);e&&(t.value=e.value,t.selectionStart=t.selectionEnd=e.caret),t.focus()}chrome.tabs.get(e,e=>{if(chrome.runtime.lastError||!e){i.error(`[PageSelector] getlabelpageinfo failed:`,chrome.runtime.lastError);return}Mx(e),Gb(),t&&(t.focus(),Ke())})}function Fx(e,t){let n={interpret:r(`pageSelector.interpretMsg`),summarize:r(`pageSelector.summarizeMsg`),translate:r(`pageSelector.translateMsg`)}[t];n&&chrome.tabs.get(e,e=>{if(chrome.runtime.lastError||!e){i.error(`[PageSelector] get tab info failed:`,chrome.runtime.lastError);return}Mx(e),Gb();let t=document.getElementById(`userInput`);t&&(t.value=n,Ke()),mT()})}function Ix(){let e=document.getElementById(`pageIndicatorClose`);e&&e.addEventListener(`click`,()=>{Nx()})}n(`zh`,{msgFullscreen:{title:`全屏阅读`,btnTitle:`全屏查看本回答 (Alt+双击 / Alt+F)`,btnLabel:`全屏`,copy:`复制`,copyTitle:`复制回答内容(Ctrl/⌘+点击复制富文本)`,export:`导出`,exportTitle:`导出下载本回答`,exportWord:`导出 Word`,exportPdf:`导出 PDF`,exportImage:`导出图片`,exportMarkdown:`导出 Markdown`,close:`退出全屏`,closeTitle:`退出全屏 (Esc)`}}),n(`en`,{msgFullscreen:{title:`Fullscreen Reading`,btnTitle:`View this answer fullscreen (Alt+Double-click / Alt+F)`,btnLabel:`Fullscreen`,copy:`Copy`,copyTitle:`Copy answer (Ctrl/Cmd+click for rich text)`,export:`Export`,exportTitle:`Export / download this answer`,exportWord:`Export Word`,exportPdf:`Export PDF`,exportImage:`Export Image`,exportMarkdown:`Export Markdown`,close:`Exit fullscreen`,closeTitle:`Exit fullscreen (Esc)`}});var Lx=`messageFullscreenOverlay`,Rx=`messageFullscreenBody`,zx=`messageFullscreenTitle`,Bx=`messageFullscreenCopyBtn`,Vx=`messageFullscreenCloseBtn`,Hx=`messageFullscreenExportBtn`,Ux=`messageFullscreenExportDropdown`,Wx=null,Gx=null,Kx=null,qx=!1,Jx=null,Yx=!1;function Xx(){return Wx!==null}function Zx(e){return!e||Xx()?null:e.innerHTML}function Qx(){let e=document.querySelectorAll(`#chatContainer .message.assistant`);return e.length?e[e.length-1]:null}function $x(){let e=document.createElement(`button`);return e.className=`fullscreen-btn`,e.title=r(`msgFullscreen.btnTitle`),e.innerHTML=[`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">`,`<path d="M6 2H2v4M10 2h4v4M6 14H2v-4M10 14h4v-4"/>`,`</svg>`,`<span>${r(`msgFullscreen.btnLabel`)}</span>`].join(``),e}function eS(){let e=document.getElementById(Lx),t=document.getElementById(Rx);return!e||!t?(i.warn(`[MsgFullscreen] overlay/body element missing`),null):{overlay:e,body:t,title:document.getElementById(zx),copyBtn:document.getElementById(Bx),closeBtn:document.getElementById(Vx)}}function tS(e){if(!e)return;let t=eS();if(t&&Wx!==e){if(!Wx){let e=document.getElementById(`chatContainer`);Jx=e?e.scrollTop:null}Wx&&(Yx=!0,nS(),Yx=!1),Gx=document.createComment(`msg-fullscreen-anchor`),e.parentNode.insertBefore(Gx,e),e.dataset.fullscreen=`1`,t.body.appendChild(e),Wx=e,t.overlay.style.display=`flex`,document.body.classList.add(`message-fullscreen-viewing`),t.title&&(t.title.textContent=r(`msgFullscreen.title`)),t.copyBtn&&(t.copyBtn.title=r(`msgFullscreen.copyTitle`)),t.closeBtn&&(t.closeBtn.title=r(`msgFullscreen.closeTitle`)),fS(),iS(t.body)}}function nS(){if(!Wx)return;let e=eS();if(oS(),pS(),Gx&&Gx.parentNode)Gx.parentNode.insertBefore(Wx,Gx);else if(e){let e=document.getElementById(`chatContainer`);e&&e.appendChild(Wx)}if(Gx&&Gx.parentNode&&Gx.parentNode.removeChild(Gx),delete Wx.dataset.fullscreen,Wx=null,Gx=null,e){e.overlay.style.display=`none`,e.body.innerHTML=``;let t=e.overlay.querySelector(`.message-fullscreen-rail`);t&&t.querySelectorAll(`.message-toc-container`).forEach(e=>e.remove())}if(document.body.classList.remove(`message-fullscreen-viewing`),!Yx&&Jx!==null){let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=Jx),Jx=null}}function rS(e){if(Wx&&Wx===e){nS();return}tS(e||Qx())}function iS(e){oS(),qx=!1,e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,aS,{passive:!0}),typeof ResizeObserver<`u`&&(Kx=new ResizeObserver(()=>{qx||(e.scrollTop=e.scrollHeight)}),Kx.observe(e.firstElementChild||e))}function aS(){let e=document.getElementById(Rx);e&&(qx=e.scrollHeight-e.scrollTop-e.clientHeight>60)}function oS(){let e=document.getElementById(Rx);e&&e.removeEventListener(`scroll`,aS),Kx&&=(Kx.disconnect(),null)}function sS(e){if(e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyF`){e.preventDefault(),Wx?nS():tS(Qx());return}e.key===`Escape`&&Wx&&(e.preventDefault(),e.stopImmediatePropagation(),nS())}function cS(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=e.target.closest?.(`#chatContainer .message.assistant`);t&&(e.preventDefault(),rS(t))}async function lS(e){if(!Wx)return;let{copyAssistantMessage:t}=await A(async()=>{let{copyAssistantMessage:e}=await Promise.resolve().then(()=>gS);return{copyAssistantMessage:e}},void 0);t(Wx,document.getElementById(Bx),e)}var uS={docx:`<path d="M4 1.5h6L13 4.5v10H4z"/><path d="M10 1.5v3h3"/><path d="M6 8h4M6 10.5h4"/>`,pdf:`<path d="M4 1.5h6L13 4.5v10H4z"/><path d="M10 1.5v3h3"/><path d="M6.5 11.5c2-1 2.5-4 1-4s-1 4 2 4"/>`,image:`<rect x="2.5" y="3" width="11" height="10" rx="1.2"/><circle cx="6" cy="6.5" r="1"/><path d="M13.5 10 10 6.5 4.5 12.5"/>`,markdown:`<path d="M2.5 12V4l3 3 3-3v8"/><path d="M12.5 4v6m0 0 2-2.2m-2 2.2L10.5 7.8"/>`};function dS(){let e=document.createElement(`div`);e.className=`message-fullscreen-export`;let t=document.createElement(`button`);t.className=`message-fullscreen-icon-btn`,t.id=Hx,t.type=`button`,t.title=r(`msgFullscreen.exportTitle`),t.innerHTML=[`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" width="16" height="16">`,`<path d="M8 2v8m0 0 3-3M8 10 5 7M2.5 13.5h11"/>`,`</svg>`,`<span>${r(`msgFullscreen.export`)}</span>`,`<svg class="dropdown-arrow" width="8" height="6" viewBox="0 0 8 6" fill="currentColor"><path d="M0 0l4 6 4-6z"/></svg>`].join(``);let n=document.createElement(`div`);n.className=`message-fullscreen-export-dropdown`,n.id=Ux;let i=e=>`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">${uS[e]}</svg>`;n.innerHTML=[`<button class="export-dropdown-item export-docx-item" type="button">${i(`docx`)}<span>${r(`msgFullscreen.exportWord`)}</span></button>`,`<button class="export-dropdown-item export-pdf-item" type="button">${i(`pdf`)}<span>${r(`msgFullscreen.exportPdf`)}</span></button>`,`<button class="export-dropdown-item export-image-item" type="button">${i(`image`)}<span>${r(`msgFullscreen.exportImage`)}</span></button>`,`<button class="export-dropdown-item export-md-item" type="button">${i(`markdown`)}<span>${r(`msgFullscreen.exportMarkdown`)}</span></button>`].join(``),t.addEventListener(`click`,e=>{e.stopPropagation(),n.classList.toggle(`show`)});let a=(e,t)=>{let r=n.querySelector(e);r.addEventListener(`click`,async e=>{e.stopPropagation(),Wx&&(n.classList.remove(`show`),(await A(()=>import(`./chat-export-DWrq6XW7.js`),__vite__mapDeps([9,10,1,11,2,3,12,0])))[t](Wx,r,n))})};return a(`.export-docx-item`,`exportAssistantMessageToDocx`),a(`.export-pdf-item`,`exportAssistantMessageToPdf`),a(`.export-image-item`,`exportAssistantMessageToImage`),a(`.export-md-item`,`exportAssistantMessageToMarkdown`),e.appendChild(t),e.appendChild(n),e}function fS(){if(document.getElementById(Hx))return;let e=document.getElementById(Vx),t=e?e.parentNode:document.querySelector(`.message-fullscreen-actions`);t&&t.insertBefore(dS(),e||null)}function pS(){let e=document.getElementById(Ux);e&&e.classList.remove(`show`)}var mS=!1;function hS(){mS||(mS=!0,document.addEventListener(`click`,e=>{let t=document.getElementById(Ux);t&&t.classList.contains(`show`)&&!e.target.closest?.(`.message-fullscreen-export`)&&t.classList.remove(`show`);let n=e.target.closest?.(`.fullscreen-btn`);if(n){e.stopPropagation(),rS(n.closest(`.message`));return}if(e.target.closest?.(`#messageFullscreenCloseBtn`)){e.stopPropagation(),nS();return}e.target.closest?.(`#messageFullscreenCopyBtn`)&&(e.stopPropagation(),lS(e))},!0),document.addEventListener(`keydown`,sS,!0),document.addEventListener(`dblclick`,cS,!0))}var gS=t({copyAssistantMessage:()=>yS,copyMessage:()=>vS,copyRichText:()=>SS,fallbackCopyRichText:()=>wS,fallbackCopyText:()=>xS,quoteAndAsk:()=>DS,setQuoteContextInjector:()=>ES,showCopySuccess:()=>bS,wrapHtmlWithStyles:()=>CS});n(`zh`,{chatCopy:{copiedMarkdown:`已复制 Markdown`,copiedRich:`已复制富文本`,copyFailedManual:`复制失败,请手动复制`}}),n(`en`,{chatCopy:{copiedMarkdown:`Markdown copied`,copiedRich:`Rich text copied`,copyFailedManual:`Copy failed, please copy manually`}});function _S(e){let t=e.querySelectorAll(`.mermaid`),n=null;for(let e of t)try{if(!n&&e._pngDataUrl){let t=e._pngDataUrl.split(`,`)[1]||``,r=atob(t),i=r.length,a=new Uint8Array(i);for(let e=0;e<i;e++)a[e]=r.charCodeAt(e);n=new Blob([a],{type:`image/png`})}let t=e.getAttribute(`data-raw-code`),r=t?decodeURIComponent(t):e.dataset.rawMermaidCode||(e.textContent||``).trim();if(r){let t=r.split(`
1390
+ `}).join(``),t.querySelectorAll(`img.favicon-img`).forEach(e=>{e.addEventListener(`error`,()=>{e.style.display=`none`})}),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,t=>{let n=t.target.closest(`.page-action-btn`);if(n){t.stopPropagation(),Fx(parseInt(n.dataset.tabId),n.dataset.action);return}Px(parseInt(e.dataset.tabId))})})}function jx(e){e.forEach((e,t)=>{t===C.selectedPageIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function Mx(e){C.selectedPage={id:e.id,title:e.title||r(`pageSelector.noTitle`),url:e.url||``,favIconUrl:e.favIconUrl||``};let t=document.getElementById(`pageIndicator`),n=document.getElementById(`pageIndicatorName`);if(t&&n){let e=C.selectedPage.title&&C.selectedPage.title!==r(`pageSelector.noTitle`)?C.selectedPage.title:``,i=C.selectedPage.url||``;e&&i?n.textContent=`${e} · ${i}`:n.textContent=e||i,t.style.display=`flex`}}function Nx(){C.selectedPage=null,C.selectedPageIndex=-1;let e=document.getElementById(`pageIndicator`);e&&(e.style.display=`none`)}function Px(e){let t=document.getElementById(`userInput`);if(t){let e=Da(t.value,t.selectionStart,`at`);e&&(t.value=e.value,t.selectionStart=t.selectionEnd=e.caret),t.focus()}chrome.tabs.get(e,e=>{if(chrome.runtime.lastError||!e){i.error(`[PageSelector] getlabelpageinfo failed:`,chrome.runtime.lastError);return}Mx(e),Gb(),t&&(t.focus(),Ke())})}function Fx(e,t){let n={interpret:r(`pageSelector.interpretMsg`),summarize:r(`pageSelector.summarizeMsg`),translate:r(`pageSelector.translateMsg`)}[t];n&&chrome.tabs.get(e,e=>{if(chrome.runtime.lastError||!e){i.error(`[PageSelector] get tab info failed:`,chrome.runtime.lastError);return}Mx(e),Gb();let t=document.getElementById(`userInput`);t&&(t.value=n,Ke()),mT()})}function Ix(){let e=document.getElementById(`pageIndicatorClose`);e&&e.addEventListener(`click`,()=>{Nx()})}n(`zh`,{msgFullscreen:{title:`全屏阅读`,btnTitle:`全屏查看本回答 (Alt+双击 / Alt+F)`,btnLabel:`全屏`,copy:`复制`,copyTitle:`复制回答内容(Ctrl/⌘+点击复制富文本)`,export:`导出`,exportTitle:`导出下载本回答`,exportWord:`导出 Word`,exportPdf:`导出 PDF`,exportImage:`导出图片`,exportMarkdown:`导出 Markdown`,close:`退出全屏`,closeTitle:`退出全屏 (Esc)`}}),n(`en`,{msgFullscreen:{title:`Fullscreen Reading`,btnTitle:`View this answer fullscreen (Alt+Double-click / Alt+F)`,btnLabel:`Fullscreen`,copy:`Copy`,copyTitle:`Copy answer (Ctrl/Cmd+click for rich text)`,export:`Export`,exportTitle:`Export / download this answer`,exportWord:`Export Word`,exportPdf:`Export PDF`,exportImage:`Export Image`,exportMarkdown:`Export Markdown`,close:`Exit fullscreen`,closeTitle:`Exit fullscreen (Esc)`}});var Lx=`messageFullscreenOverlay`,Rx=`messageFullscreenBody`,zx=`messageFullscreenTitle`,Bx=`messageFullscreenCopyBtn`,Vx=`messageFullscreenCloseBtn`,Hx=`messageFullscreenExportBtn`,Ux=`messageFullscreenExportDropdown`,Wx=null,Gx=null,Kx=null,qx=!1,Jx=null,Yx=!1;function Xx(){return Wx!==null}function Zx(e){return!e||Xx()?null:e.innerHTML}function Qx(){let e=document.querySelectorAll(`#chatContainer .message.assistant`);return e.length?e[e.length-1]:null}function $x(){let e=document.createElement(`button`);return e.className=`fullscreen-btn`,e.title=r(`msgFullscreen.btnTitle`),e.innerHTML=[`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">`,`<path d="M6 2H2v4M10 2h4v4M6 14H2v-4M10 14h4v-4"/>`,`</svg>`,`<span>${r(`msgFullscreen.btnLabel`)}</span>`].join(``),e}function eS(){let e=document.getElementById(Lx),t=document.getElementById(Rx);return!e||!t?(i.warn(`[MsgFullscreen] overlay/body element missing`),null):{overlay:e,body:t,title:document.getElementById(zx),copyBtn:document.getElementById(Bx),closeBtn:document.getElementById(Vx)}}function tS(e){if(!e)return;let t=eS();if(t&&Wx!==e){if(!Wx){let e=document.getElementById(`chatContainer`);Jx=e?e.scrollTop:null}Wx&&(Yx=!0,nS(),Yx=!1),Gx=document.createComment(`msg-fullscreen-anchor`),e.parentNode.insertBefore(Gx,e),e.dataset.fullscreen=`1`,t.body.appendChild(e),Wx=e,t.overlay.style.display=`flex`,document.body.classList.add(`message-fullscreen-viewing`),t.title&&(t.title.textContent=r(`msgFullscreen.title`)),t.copyBtn&&(t.copyBtn.title=r(`msgFullscreen.copyTitle`)),t.closeBtn&&(t.closeBtn.title=r(`msgFullscreen.closeTitle`)),fS(),iS(t.body)}}function nS(){if(!Wx)return;let e=eS();if(oS(),pS(),Gx&&Gx.parentNode)Gx.parentNode.insertBefore(Wx,Gx);else if(e){let e=document.getElementById(`chatContainer`);e&&e.appendChild(Wx)}if(Gx&&Gx.parentNode&&Gx.parentNode.removeChild(Gx),delete Wx.dataset.fullscreen,Wx=null,Gx=null,e){e.overlay.style.display=`none`,e.body.innerHTML=``;let t=e.overlay.querySelector(`.message-fullscreen-rail`);t&&t.querySelectorAll(`.message-toc-container`).forEach(e=>e.remove())}if(document.body.classList.remove(`message-fullscreen-viewing`),!Yx&&Jx!==null){let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=Jx),Jx=null}}function rS(e){if(Wx&&Wx===e){nS();return}tS(e||Qx())}function iS(e){oS(),qx=!1,e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,aS,{passive:!0}),typeof ResizeObserver<`u`&&(Kx=new ResizeObserver(()=>{qx||(e.scrollTop=e.scrollHeight)}),Kx.observe(e.firstElementChild||e))}function aS(){let e=document.getElementById(Rx);e&&(qx=e.scrollHeight-e.scrollTop-e.clientHeight>60)}function oS(){let e=document.getElementById(Rx);e&&e.removeEventListener(`scroll`,aS),Kx&&=(Kx.disconnect(),null)}function sS(e){if(e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyF`){e.preventDefault(),Wx?nS():tS(Qx());return}e.key===`Escape`&&Wx&&(e.preventDefault(),e.stopImmediatePropagation(),nS())}function cS(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=e.target.closest?.(`#chatContainer .message.assistant`);t&&(e.preventDefault(),rS(t))}async function lS(e){if(!Wx)return;let{copyAssistantMessage:t}=await A(async()=>{let{copyAssistantMessage:e}=await Promise.resolve().then(()=>gS);return{copyAssistantMessage:e}},void 0);t(Wx,document.getElementById(Bx),e)}var uS={docx:`<path d="M4 1.5h6L13 4.5v10H4z"/><path d="M10 1.5v3h3"/><path d="M6 8h4M6 10.5h4"/>`,pdf:`<path d="M4 1.5h6L13 4.5v10H4z"/><path d="M10 1.5v3h3"/><path d="M6.5 11.5c2-1 2.5-4 1-4s-1 4 2 4"/>`,image:`<rect x="2.5" y="3" width="11" height="10" rx="1.2"/><circle cx="6" cy="6.5" r="1"/><path d="M13.5 10 10 6.5 4.5 12.5"/>`,markdown:`<path d="M2.5 12V4l3 3 3-3v8"/><path d="M12.5 4v6m0 0 2-2.2m-2 2.2L10.5 7.8"/>`};function dS(){let e=document.createElement(`div`);e.className=`message-fullscreen-export`;let t=document.createElement(`button`);t.className=`message-fullscreen-icon-btn`,t.id=Hx,t.type=`button`,t.title=r(`msgFullscreen.exportTitle`),t.innerHTML=[`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" width="16" height="16">`,`<path d="M8 2v8m0 0 3-3M8 10 5 7M2.5 13.5h11"/>`,`</svg>`,`<span>${r(`msgFullscreen.export`)}</span>`,`<svg class="dropdown-arrow" width="8" height="6" viewBox="0 0 8 6" fill="currentColor"><path d="M0 0l4 6 4-6z"/></svg>`].join(``);let n=document.createElement(`div`);n.className=`message-fullscreen-export-dropdown`,n.id=Ux;let i=e=>`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">${uS[e]}</svg>`;n.innerHTML=[`<button class="export-dropdown-item export-docx-item" type="button">${i(`docx`)}<span>${r(`msgFullscreen.exportWord`)}</span></button>`,`<button class="export-dropdown-item export-pdf-item" type="button">${i(`pdf`)}<span>${r(`msgFullscreen.exportPdf`)}</span></button>`,`<button class="export-dropdown-item export-image-item" type="button">${i(`image`)}<span>${r(`msgFullscreen.exportImage`)}</span></button>`,`<button class="export-dropdown-item export-md-item" type="button">${i(`markdown`)}<span>${r(`msgFullscreen.exportMarkdown`)}</span></button>`].join(``),t.addEventListener(`click`,e=>{e.stopPropagation(),n.classList.toggle(`show`)});let a=(e,t)=>{let r=n.querySelector(e);r.addEventListener(`click`,async e=>{e.stopPropagation(),Wx&&(n.classList.remove(`show`),(await A(()=>import(`./chat-export-ryKcmB-h.js`),__vite__mapDeps([9,10,1,11,2,3,12,0])))[t](Wx,r,n))})};return a(`.export-docx-item`,`exportAssistantMessageToDocx`),a(`.export-pdf-item`,`exportAssistantMessageToPdf`),a(`.export-image-item`,`exportAssistantMessageToImage`),a(`.export-md-item`,`exportAssistantMessageToMarkdown`),e.appendChild(t),e.appendChild(n),e}function fS(){if(document.getElementById(Hx))return;let e=document.getElementById(Vx),t=e?e.parentNode:document.querySelector(`.message-fullscreen-actions`);t&&t.insertBefore(dS(),e||null)}function pS(){let e=document.getElementById(Ux);e&&e.classList.remove(`show`)}var mS=!1;function hS(){mS||(mS=!0,document.addEventListener(`click`,e=>{let t=document.getElementById(Ux);t&&t.classList.contains(`show`)&&!e.target.closest?.(`.message-fullscreen-export`)&&t.classList.remove(`show`);let n=e.target.closest?.(`.fullscreen-btn`);if(n){e.stopPropagation(),rS(n.closest(`.message`));return}if(e.target.closest?.(`#messageFullscreenCloseBtn`)){e.stopPropagation(),nS();return}e.target.closest?.(`#messageFullscreenCopyBtn`)&&(e.stopPropagation(),lS(e))},!0),document.addEventListener(`keydown`,sS,!0),document.addEventListener(`dblclick`,cS,!0))}var gS=t({copyAssistantMessage:()=>yS,copyMessage:()=>vS,copyRichText:()=>SS,fallbackCopyRichText:()=>wS,fallbackCopyText:()=>xS,quoteAndAsk:()=>DS,setQuoteContextInjector:()=>ES,showCopySuccess:()=>bS,wrapHtmlWithStyles:()=>CS});n(`zh`,{chatCopy:{copiedMarkdown:`已复制 Markdown`,copiedRich:`已复制富文本`,copyFailedManual:`复制失败,请手动复制`}}),n(`en`,{chatCopy:{copiedMarkdown:`Markdown copied`,copiedRich:`Rich text copied`,copyFailedManual:`Copy failed, please copy manually`}});function _S(e){let t=e.querySelectorAll(`.mermaid`),n=null;for(let e of t)try{if(!n&&e._pngDataUrl){let t=e._pngDataUrl.split(`,`)[1]||``,r=atob(t),i=r.length,a=new Uint8Array(i);for(let e=0;e<i;e++)a[e]=r.charCodeAt(e);n=new Blob([a],{type:`image/png`})}let t=e.getAttribute(`data-raw-code`),r=t?decodeURIComponent(t):e.dataset.rawMermaidCode||(e.textContent||``).trim();if(r){let t=r.split(`
1391
1391
  `),n=document.createElement(`pre`);n.appendChild(document.createTextNode(t[0]||``));for(let e=1;e<t.length;e++)n.appendChild(document.createElement(`br`)),n.appendChild(document.createTextNode(t[e]));e.parentNode.replaceChild(n,e)}else e.remove()}catch(t){i.warn(`[SidePanel] Mermaid chartprocessing failed,remove:`,t.message),e.remove()}return{html:e.innerHTML,firstPngBlob:n}}function vS(e,t){try{let n=e.dataset.textContent_||e.dataset.rawContent||``;navigator.clipboard.writeText(n).then(()=>{let e=t.innerHTML;t.innerHTML=`
1392
1392
  <svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor">
1393
1393
  <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0z"/>
@@ -1751,7 +1751,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
1751
1751
  <svg class="thinking-process-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1752
1752
  <polyline points="6 9 12 15 18 9"/>
1753
1753
  </svg>
1754
- `,d){let e=p.querySelector(`.token-stat`);e&&(e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Xe(d,e)}))}let g=document.createElement(`div`);g.className=`thinking-process-body`;let _=document.createElement(`div`);for(_.className=`thinking-process-content`,g.appendChild(_);l.firstChild;)_.appendChild(l.firstChild);let v=_.querySelectorAll(`.thinking-content`),y=e.trim();if(v.length>0){let e=v[v.length-1],t=e.textContent.trim();if(!s||s&&t===y){let t=e.previousElementSibling;for(;t;){if(t.classList.contains(`thinking-badge`)){t.remove();break}t=t.previousElementSibling}e.remove()}}if(_.children.length>0&&_.textContent.trim()){f.appendChild(p),f.appendChild(g);let t=document.createElement(`div`);t.className=`final-answer`,e&&e.trim()&&(t.innerHTML=Qe(e));let n=c.querySelector(`.thinking-indicator`);n&&n.remove(),c.appendChild(f),c.appendChild(t),wC(p)}else{let t=c.querySelector(`.thinking-indicator`);t&&t.remove(),e&&e.trim()&&(l.innerHTML=Qe(e))}}else e&&e.trim()&&(l.innerHTML=Qe(e))}e.classList.add(`assistant`,`message`),e.dataset.rawContent=typeof t==`string`?ft(t):JSON.stringify(t),e.dataset.textContent_=ft(Pw(t)),e.dataset.executionLog=JSON.stringify(n);let f=document.createElement(`div`);f.className=`message-footer`;let p=document.createElement(`button`);p.className=`copy-btn`,p.title=r(`chatStream.copyMarkdown`),p.innerHTML=[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>`,`</svg>`,`<span>`+r(`chatStream.copy`)+`</span>`].join(``),p.addEventListener(`click`,t=>{t.stopPropagation(),yS(e,p,t)}),f.appendChild(p);let m=document.createElement(`button`);m.className=`quote-btn`,m.title=r(`chatStream.quoteTitle`),m.innerHTML=[`<svg t="1781246498458" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9645" width="14" height="14"><path d="M156.09136 606.57001a457.596822 457.596822 0 0 1 221.680239-392.516385 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z m406.752731 0a457.596822 457.596822 0 0 1 221.680239-392.007944 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z" fill="#8a8a8a" p-id="9646"></path></svg>`,`<span>`+r(`chatStream.quote`)+`</span>`].join(``),m.addEventListener(`click`,t=>{t.stopPropagation(),DS(e)}),f.appendChild(m),f.appendChild($x());let h=document.createElement(`div`);h.className=`export-menu-container`;let g=document.createElement(`button`);g.className=`export-trigger-btn`,g.innerHTML=`<svg t="1781245244396" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5115" width="14" height="14"><path d="M496.213333 739.84c2.133333 2.133333 4.693333 3.84 7.68 5.12 0.853333 0.426667 2.133333 0.426667 2.986667 0.853333 1.706667 0.426667 2.986667 0.853333 4.693333 0.853334 5.546667 0 11.093333-2.133333 14.933334-6.4l256-256c8.533333-8.533333 8.533333-21.76 0-30.293334s-21.76-8.533333-30.293334 0L533.333333 674.133333V128c0-11.946667-9.386667-21.333333-21.333333-21.333333s-21.333333 9.386667-21.333333 21.333333v545.706667l-219.306667-219.306667c-8.533333-8.533333-21.76-8.533333-30.293333 0s-8.533333 21.76 0 30.293333l255.146666 255.146667zM768 874.666667H256c-11.946667 0-21.333333 9.386667-21.333333 21.333333s9.386667 21.333333 21.333333 21.333333h512c11.946667 0 21.333333-9.386667 21.333333-21.333333s-9.386667-21.333333-21.333333-21.333333z" fill="#8a8a8a" p-id="5116"></path></svg><span>`+r(`chatStream.export`)+`</span><svg class="dropdown-arrow" width="8" height="6" viewBox="0 0 8 6" fill="currentColor"><path d="M0 0l4 6 4-6z"/></svg>`;let _=document.createElement(`div`);_.className=`export-dropdown`,_.innerHTML=[`<button class="export-dropdown-item export-docx-item" type="button">`,`<svg t="1781245550030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6544" width="32" height="32"><path d="M747.936 901.171H276.819c-72.2 0-130.953-55.224-130.953-123.078V244.721c0-67.854 58.752-123.078 130.953-123.078h383.525c6.597 0 12.937 2.505 17.795 6.954l192.363 178.046c5.317 4.96 8.386 11.914 8.386 19.227v452.223c0 67.854-58.752 123.078-130.952 123.078zM276.819 174.004c-43.31 0-78.592 31.703-78.592 70.717v533.372c0 39.015 35.282 70.718 78.592 70.718h471.117c43.31 0 78.592-31.703 78.592-70.718V337.324l-176.461-163.32H276.819z" fill="#8a8a8a" p-id="6545"></path><path d="M830.567 331.546H669.446c-14.471 0-26.18-11.71-26.18-26.181V156.209c0-14.471 11.709-26.18 26.18-26.18s26.181 11.709 26.181 26.18v122.976h134.94c14.471 0 26.181 11.709 26.181 26.18s-11.711 26.181-26.181 26.181z" fill="#8a8a8a" p-id="6546"></path><path d="M730.214 428.749l-92.04 343.616h-53.179L511.363 498.29l-75.677 274.074h-53.179l-92.04-343.616h49.088l69.542 255.667 69.541-255.667h63.406l69.541 255.667 69.541-255.667h49.088z" fill="#8a8a8a" p-id="6547"></path></svg>`,`<span>`+r(`chatStream.exportWord`)+`</span>`,`</button>`,`<button class="export-dropdown-item export-pdf-item" type="button">`,`<svg t="1781245863206" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8152" width="32" height="32"><path d="M582.4 864H170.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V170.666667c0-6.4 4.266667-10.666667 10.666667-10.666667h309.333333V320c0 40.533333 34.133333 74.666667 74.666667 74.666667h160v38.4c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V298.666667c0-8.533333-4.266667-17.066667-8.533334-23.466667l-170.666666-170.666667c-6.4-6.4-14.933333-8.533333-23.466667-8.533333H170.666667C130.133333 96 96 130.133333 96 170.666667v682.666666c0 40.533333 34.133333 74.666667 74.666667 74.666667h411.733333c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32z m132.266667-550.4v17.066667H554.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V160h19.2l151.466667 153.6z" fill="#8a8a8a" p-id="8153"></path><path d="M332.8 533.333333c-12.8 0-19.2 2.133333-25.6 6.4-6.4 4.266667-8.533333 12.8-8.533333 23.466667v206.933333c0 6.4 2.133333 12.8 6.4 19.2 4.266667 4.266667 10.666667 8.533333 21.333333 8.533334s17.066667-4.266667 21.333333-8.533334c4.266667-4.266667 6.4-10.666667 6.4-19.2v-64h32c57.6 0 89.6-29.866667 89.6-87.466666 0-27.733333-8.533333-51.2-23.466666-64-14.933333-14.933333-36.266667-21.333333-66.133334-21.333334h-53.333333z m87.466667 85.333334c0 12.8-2.133333 23.466667-8.533334 27.733333-4.266667 4.266667-14.933333 8.533333-27.733333 8.533333h-32v-70.4H384c12.8 0 21.333333 2.133333 27.733333 8.533334 6.4 4.266667 8.533333 12.8 8.533334 25.6zM667.733333 571.733333c-8.533333-12.8-21.333333-21.333333-34.133333-29.866666-14.933333-4.266667-32-8.533333-51.2-8.533334h-61.866667c-8.533333 0-17.066667 0-23.466666 8.533334-2.133333 4.266667-4.266667 10.666667-4.266667 19.2V768c0 8.533333 2.133333 14.933333 4.266667 19.2 6.4 8.533333 14.933333 8.533333 23.466666 8.533333h64c19.2 0 34.133333-4.266667 49.066667-10.666666 12.8-6.4 25.6-17.066667 34.133333-29.866667 8.533333-12.8 14.933333-25.6 19.2-42.666667 4.266667-14.933333 6.4-32 6.4-49.066666 0-17.066667-2.133333-34.133333-6.4-49.066667-4.266667-14.933333-10.666667-29.866667-19.2-42.666667z m-42.666666 153.6c-8.533333 12.8-21.333333 19.2-38.4 19.2h-38.4v-160H576c21.333333 0 38.4 6.4 46.933333 19.2 10.666667 12.8 14.933333 34.133333 14.933334 59.733334 2.133333 27.733333-4.266667 46.933333-12.8 61.866666zM851.2 533.333333h-106.666667c-8.533333 0-17.066667 2.133333-21.333333 6.4-6.4 4.266667-8.533333 12.8-8.533333 21.333334v209.066666c0 6.4 2.133333 12.8 6.4 17.066667 4.266667 6.4 10.666667 8.533333 21.333333 8.533333 8.533333 0 17.066667-2.133333 21.333333-8.533333 2.133333-4.266667 6.4-8.533333 6.4-19.2v-85.333333h72.533334c12.8 0 23.466667-6.4 25.6-17.066667 2.133333-8.533333 2.133333-14.933333 0-17.066667-2.133333-4.266667-6.4-17.066667-25.6-17.066666H768v-49.066667h81.066667c8.533333 0 14.933333-2.133333 19.2-4.266667 4.266667-2.133333 8.533333-8.533333 8.533333-21.333333 2.133333-12.8-8.533333-23.466667-25.6-23.466667z" fill="#8a8a8a" p-id="8154"></path></svg>`,`<span>`+r(`chatStream.exportPdf`)+`</span>`,`</button>`,`<button class="export-dropdown-item export-image-item" type="button">`,`<svg t="1784207887308" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5993" width="32" height="32"><path d="M400.696 268.795c-17.249 0-31.233 13.986-31.233 31.233v30.471c0 17.249 13.986 31.233 31.233 31.233s31.233-13.986 31.233-31.233v-30.471c0-17.249-13.985-31.233-31.233-31.233z" fill="#8a8a8a" p-id="5994"></path><path d="M623.649 361.734c17.249 0 31.234-13.986 31.234-31.233v-30.471c0-17.249-13.986-31.233-31.234-31.233s-31.233 13.986-31.233 31.233v30.471c-0.001 17.248 13.985 31.233 31.233 31.233z" fill="#8a8a8a" p-id="5995"></path><path d="M438.295 388.804c-14.656 9.104-19.155 28.362-10.050 43.013 11.209 18.047 41.976 48.59 86.157 48.59 43.958 0 75.1-30.313 86.574-48.223 9.303-14.529 5.068-33.847-9.455-43.15-14.539-9.298-33.852-5.068-43.15 9.455-0.122 0.199-13.38 19.45-33.969 19.45-20.009 0-32.444-18.128-33.278-19.373-9.166-14.423-28.28-18.805-42.829-9.761z" fill="#8a8a8a" p-id="5996"></path><path d="M824.508503 116.690676 571.592236 116.690676c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c40.181141 0 72.878844 32.692586 72.878844 72.878844l0 396.966057-189.334159-165.29465c-12.20088-10.655687-30.517037-10.207479-42.173518 0.9967L468.578048 674.16231 309.521472 517.519714c-11.895935-11.70253-30.903847-12.002358-43.154869-0.645706L126.957507 646.163629l0-394.126382c0-40.186258 32.692586-72.878844 72.878844-72.878844l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352S470.000444 116.690676 452.751594 116.690676L199.836351 116.690676c-74.632791 0-135.346571 60.71378-135.346571 135.346571l0 520.56405c0 74.632791 60.71378 135.346571 135.346571 135.346571l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352s-13.985526-31.233352-31.233352-31.233352L199.836351 845.481164c-40.186258 0-72.878844-32.692586-72.878844-72.878844l0-41.23924 160.003134-148.385539 159.428036 157.007917c12.048407 11.865235 31.361265 11.981892 43.546795 0.274246l198.576661-190.68697 208.876238 182.346001 0 40.683585c0 40.186258-32.697703 72.878844-72.878844 72.878844L571.592236 845.481164c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c74.627674 0 135.346571-60.71378 135.346571-135.346571L959.855074 252.037247C959.855074 177.404456 899.136178 116.690676 824.508503 116.690676z" fill="#8a8a8a" p-id="5997"></path></svg>`,`<span>`+r(`chatStream.exportImage`)+`</span>`,`</button>`,`<button class="export-dropdown-item export-md-item" type="button">`,`<svg t="1784038824502" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1666" width="32" height="32"><path d="M601.216 85.333333a42.666667 42.666667 0 0 1 30.485333 12.821334l209.450667 213.973333a42.666667 42.666667 0 0 1 12.181333 29.866667V853.333333a85.333333 85.333333 0 0 1-85.333333 85.333334H256a85.333333 85.333333 0 0 1-85.333333-85.333334V170.666667a85.333333 85.333333 0 0 1 85.333333-85.333334h345.216z m-35.584 64H256a21.333333 21.333333 0 0 0-21.333333 21.333334v682.666666a21.333333 21.333333 0 0 0 21.333333 21.333334h512a21.333333 21.333333 0 0 0 21.333333-21.333334V395.413333h-191.68a32 32 0 0 1-32-32L565.632 149.333333z m64 38.186667v143.893333h140.821333L629.632 187.52z" fill="#8a8a8a" p-id="1667"></path><path d="M384.341333 800l-3.072-0.106667a32 32 0 0 1-29.162666-34.624l21.973333-256c2.752-32.256 46.165333-40.490667 60.544-11.477333l77.290667 156.010667 78.805333-156.224c14.08-27.925333 55.082667-20.906667 60.074667 8.789333l0.384 3.050667 20.714666 256a32 32 0 0 1-63.786666 5.162666l-11.541334-142.549333-56.341333 111.722667c-11.413333 22.613333-42.88 23.381333-55.744 2.517333l-1.493333-2.730667-54.912-110.826666-12.181334 142.016a32 32 0 0 1-31.552 29.269333z" fill="#8a8a8a" p-id="1668"></path></svg>`,`<span>`+r(`chatStream.exportMarkdown`)+`</span>`,`</button>`].join(``);let v=_.querySelector(`.export-docx-item`);v.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToDocx:n}=await A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(e,v,_)});let y=_.querySelector(`.export-md-item`);y.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToMarkdown:n}=await A(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(e,y,_)});let b=_.querySelector(`.export-pdf-item`);b.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToPdf:n}=await A(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(e,b,_)});let x=_.querySelector(`.export-image-item`);x.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToImage:n}=await A(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(e,x,_)}),g.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==_&&e.classList.remove(`show`)}),_.classList.toggle(`show`)});let S=null;h.addEventListener(`mouseenter`,()=>{S=setTimeout(()=>{document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==_&&e.classList.remove(`show`)}),_.classList.add(`show`)},300)}),h.addEventListener(`mouseleave`,()=>{S&&=(clearTimeout(S),null),setTimeout(()=>{!h.matches(`:hover`)&&!_.matches(`:hover`)&&_.classList.remove(`show`)},100)}),h.appendChild(g),h.appendChild(_),f.appendChild(h);let w=document.createElement(`div`);w.className=`footer-right-actions`;let T=Le(n);if(T){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:L(T.totalTokens),prompt:L(T.promptTokens),completion:L(T.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${L(T.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Xe(T,e)}),w.appendChild(e)}let E=hb(t),D=vb(n,t);if(E.length&&(e.dataset.declaredArtifacts=JSON.stringify(E)),Ib(D),D.length>0){let e=document.createElement(`button`);e.className=`artifacts-btn`,e.type=`button`,e.title=r(`artifacts.btnTitle`,{count:D.length}),e.innerHTML=`
1754
+ `,d){let e=p.querySelector(`.token-stat`);e&&(e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Xe(d,e)}))}let g=document.createElement(`div`);g.className=`thinking-process-body`;let _=document.createElement(`div`);for(_.className=`thinking-process-content`,g.appendChild(_);l.firstChild;)_.appendChild(l.firstChild);let v=_.querySelectorAll(`.thinking-content`),y=e.trim();if(v.length>0){let e=v[v.length-1],t=e.textContent.trim();if(!s||s&&t===y){let t=e.previousElementSibling;for(;t;){if(t.classList.contains(`thinking-badge`)){t.remove();break}t=t.previousElementSibling}e.remove()}}if(_.children.length>0&&_.textContent.trim()){f.appendChild(p),f.appendChild(g);let t=document.createElement(`div`);t.className=`final-answer`,e&&e.trim()&&(t.innerHTML=Qe(e));let n=c.querySelector(`.thinking-indicator`);n&&n.remove(),c.appendChild(f),c.appendChild(t),wC(p)}else{let t=c.querySelector(`.thinking-indicator`);t&&t.remove(),e&&e.trim()&&(l.innerHTML=Qe(e))}}else e&&e.trim()&&(l.innerHTML=Qe(e))}e.classList.add(`assistant`,`message`),e.dataset.rawContent=typeof t==`string`?ft(t):JSON.stringify(t),e.dataset.textContent_=ft(Pw(t)),e.dataset.executionLog=JSON.stringify(n);let f=document.createElement(`div`);f.className=`message-footer`;let p=document.createElement(`button`);p.className=`copy-btn`,p.title=r(`chatStream.copyMarkdown`),p.innerHTML=[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>`,`</svg>`,`<span>`+r(`chatStream.copy`)+`</span>`].join(``),p.addEventListener(`click`,t=>{t.stopPropagation(),yS(e,p,t)}),f.appendChild(p);let m=document.createElement(`button`);m.className=`quote-btn`,m.title=r(`chatStream.quoteTitle`),m.innerHTML=[`<svg t="1781246498458" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9645" width="14" height="14"><path d="M156.09136 606.57001a457.596822 457.596822 0 0 1 221.680239-392.516385 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z m406.752731 0a457.596822 457.596822 0 0 1 221.680239-392.007944 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z" fill="#8a8a8a" p-id="9646"></path></svg>`,`<span>`+r(`chatStream.quote`)+`</span>`].join(``),m.addEventListener(`click`,t=>{t.stopPropagation(),DS(e)}),f.appendChild(m),f.appendChild($x());let h=document.createElement(`div`);h.className=`export-menu-container`;let g=document.createElement(`button`);g.className=`export-trigger-btn`,g.innerHTML=`<svg t="1781245244396" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5115" width="14" height="14"><path d="M496.213333 739.84c2.133333 2.133333 4.693333 3.84 7.68 5.12 0.853333 0.426667 2.133333 0.426667 2.986667 0.853333 1.706667 0.426667 2.986667 0.853333 4.693333 0.853334 5.546667 0 11.093333-2.133333 14.933334-6.4l256-256c8.533333-8.533333 8.533333-21.76 0-30.293334s-21.76-8.533333-30.293334 0L533.333333 674.133333V128c0-11.946667-9.386667-21.333333-21.333333-21.333333s-21.333333 9.386667-21.333333 21.333333v545.706667l-219.306667-219.306667c-8.533333-8.533333-21.76-8.533333-30.293333 0s-8.533333 21.76 0 30.293333l255.146666 255.146667zM768 874.666667H256c-11.946667 0-21.333333 9.386667-21.333333 21.333333s9.386667 21.333333 21.333333 21.333333h512c11.946667 0 21.333333-9.386667 21.333333-21.333333s-9.386667-21.333333-21.333333-21.333333z" fill="#8a8a8a" p-id="5116"></path></svg><span>`+r(`chatStream.export`)+`</span><svg class="dropdown-arrow" width="8" height="6" viewBox="0 0 8 6" fill="currentColor"><path d="M0 0l4 6 4-6z"/></svg>`;let _=document.createElement(`div`);_.className=`export-dropdown`,_.innerHTML=[`<button class="export-dropdown-item export-docx-item" type="button">`,`<svg t="1781245550030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6544" width="32" height="32"><path d="M747.936 901.171H276.819c-72.2 0-130.953-55.224-130.953-123.078V244.721c0-67.854 58.752-123.078 130.953-123.078h383.525c6.597 0 12.937 2.505 17.795 6.954l192.363 178.046c5.317 4.96 8.386 11.914 8.386 19.227v452.223c0 67.854-58.752 123.078-130.952 123.078zM276.819 174.004c-43.31 0-78.592 31.703-78.592 70.717v533.372c0 39.015 35.282 70.718 78.592 70.718h471.117c43.31 0 78.592-31.703 78.592-70.718V337.324l-176.461-163.32H276.819z" fill="#8a8a8a" p-id="6545"></path><path d="M830.567 331.546H669.446c-14.471 0-26.18-11.71-26.18-26.181V156.209c0-14.471 11.709-26.18 26.18-26.18s26.181 11.709 26.181 26.18v122.976h134.94c14.471 0 26.181 11.709 26.181 26.18s-11.711 26.181-26.181 26.181z" fill="#8a8a8a" p-id="6546"></path><path d="M730.214 428.749l-92.04 343.616h-53.179L511.363 498.29l-75.677 274.074h-53.179l-92.04-343.616h49.088l69.542 255.667 69.541-255.667h63.406l69.541 255.667 69.541-255.667h49.088z" fill="#8a8a8a" p-id="6547"></path></svg>`,`<span>`+r(`chatStream.exportWord`)+`</span>`,`</button>`,`<button class="export-dropdown-item export-pdf-item" type="button">`,`<svg t="1781245863206" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8152" width="32" height="32"><path d="M582.4 864H170.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V170.666667c0-6.4 4.266667-10.666667 10.666667-10.666667h309.333333V320c0 40.533333 34.133333 74.666667 74.666667 74.666667h160v38.4c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V298.666667c0-8.533333-4.266667-17.066667-8.533334-23.466667l-170.666666-170.666667c-6.4-6.4-14.933333-8.533333-23.466667-8.533333H170.666667C130.133333 96 96 130.133333 96 170.666667v682.666666c0 40.533333 34.133333 74.666667 74.666667 74.666667h411.733333c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32z m132.266667-550.4v17.066667H554.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V160h19.2l151.466667 153.6z" fill="#8a8a8a" p-id="8153"></path><path d="M332.8 533.333333c-12.8 0-19.2 2.133333-25.6 6.4-6.4 4.266667-8.533333 12.8-8.533333 23.466667v206.933333c0 6.4 2.133333 12.8 6.4 19.2 4.266667 4.266667 10.666667 8.533333 21.333333 8.533334s17.066667-4.266667 21.333333-8.533334c4.266667-4.266667 6.4-10.666667 6.4-19.2v-64h32c57.6 0 89.6-29.866667 89.6-87.466666 0-27.733333-8.533333-51.2-23.466666-64-14.933333-14.933333-36.266667-21.333333-66.133334-21.333334h-53.333333z m87.466667 85.333334c0 12.8-2.133333 23.466667-8.533334 27.733333-4.266667 4.266667-14.933333 8.533333-27.733333 8.533333h-32v-70.4H384c12.8 0 21.333333 2.133333 27.733333 8.533334 6.4 4.266667 8.533333 12.8 8.533334 25.6zM667.733333 571.733333c-8.533333-12.8-21.333333-21.333333-34.133333-29.866666-14.933333-4.266667-32-8.533333-51.2-8.533334h-61.866667c-8.533333 0-17.066667 0-23.466666 8.533334-2.133333 4.266667-4.266667 10.666667-4.266667 19.2V768c0 8.533333 2.133333 14.933333 4.266667 19.2 6.4 8.533333 14.933333 8.533333 23.466666 8.533333h64c19.2 0 34.133333-4.266667 49.066667-10.666666 12.8-6.4 25.6-17.066667 34.133333-29.866667 8.533333-12.8 14.933333-25.6 19.2-42.666667 4.266667-14.933333 6.4-32 6.4-49.066666 0-17.066667-2.133333-34.133333-6.4-49.066667-4.266667-14.933333-10.666667-29.866667-19.2-42.666667z m-42.666666 153.6c-8.533333 12.8-21.333333 19.2-38.4 19.2h-38.4v-160H576c21.333333 0 38.4 6.4 46.933333 19.2 10.666667 12.8 14.933333 34.133333 14.933334 59.733334 2.133333 27.733333-4.266667 46.933333-12.8 61.866666zM851.2 533.333333h-106.666667c-8.533333 0-17.066667 2.133333-21.333333 6.4-6.4 4.266667-8.533333 12.8-8.533333 21.333334v209.066666c0 6.4 2.133333 12.8 6.4 17.066667 4.266667 6.4 10.666667 8.533333 21.333333 8.533333 8.533333 0 17.066667-2.133333 21.333333-8.533333 2.133333-4.266667 6.4-8.533333 6.4-19.2v-85.333333h72.533334c12.8 0 23.466667-6.4 25.6-17.066667 2.133333-8.533333 2.133333-14.933333 0-17.066667-2.133333-4.266667-6.4-17.066667-25.6-17.066666H768v-49.066667h81.066667c8.533333 0 14.933333-2.133333 19.2-4.266667 4.266667-2.133333 8.533333-8.533333 8.533333-21.333333 2.133333-12.8-8.533333-23.466667-25.6-23.466667z" fill="#8a8a8a" p-id="8154"></path></svg>`,`<span>`+r(`chatStream.exportPdf`)+`</span>`,`</button>`,`<button class="export-dropdown-item export-image-item" type="button">`,`<svg t="1784207887308" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5993" width="32" height="32"><path d="M400.696 268.795c-17.249 0-31.233 13.986-31.233 31.233v30.471c0 17.249 13.986 31.233 31.233 31.233s31.233-13.986 31.233-31.233v-30.471c0-17.249-13.985-31.233-31.233-31.233z" fill="#8a8a8a" p-id="5994"></path><path d="M623.649 361.734c17.249 0 31.234-13.986 31.234-31.233v-30.471c0-17.249-13.986-31.233-31.234-31.233s-31.233 13.986-31.233 31.233v30.471c-0.001 17.248 13.985 31.233 31.233 31.233z" fill="#8a8a8a" p-id="5995"></path><path d="M438.295 388.804c-14.656 9.104-19.155 28.362-10.050 43.013 11.209 18.047 41.976 48.59 86.157 48.59 43.958 0 75.1-30.313 86.574-48.223 9.303-14.529 5.068-33.847-9.455-43.15-14.539-9.298-33.852-5.068-43.15 9.455-0.122 0.199-13.38 19.45-33.969 19.45-20.009 0-32.444-18.128-33.278-19.373-9.166-14.423-28.28-18.805-42.829-9.761z" fill="#8a8a8a" p-id="5996"></path><path d="M824.508503 116.690676 571.592236 116.690676c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c40.181141 0 72.878844 32.692586 72.878844 72.878844l0 396.966057-189.334159-165.29465c-12.20088-10.655687-30.517037-10.207479-42.173518 0.9967L468.578048 674.16231 309.521472 517.519714c-11.895935-11.70253-30.903847-12.002358-43.154869-0.645706L126.957507 646.163629l0-394.126382c0-40.186258 32.692586-72.878844 72.878844-72.878844l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352S470.000444 116.690676 452.751594 116.690676L199.836351 116.690676c-74.632791 0-135.346571 60.71378-135.346571 135.346571l0 520.56405c0 74.632791 60.71378 135.346571 135.346571 135.346571l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352s-13.985526-31.233352-31.233352-31.233352L199.836351 845.481164c-40.186258 0-72.878844-32.692586-72.878844-72.878844l0-41.23924 160.003134-148.385539 159.428036 157.007917c12.048407 11.865235 31.361265 11.981892 43.546795 0.274246l198.576661-190.68697 208.876238 182.346001 0 40.683585c0 40.186258-32.697703 72.878844-72.878844 72.878844L571.592236 845.481164c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c74.627674 0 135.346571-60.71378 135.346571-135.346571L959.855074 252.037247C959.855074 177.404456 899.136178 116.690676 824.508503 116.690676z" fill="#8a8a8a" p-id="5997"></path></svg>`,`<span>`+r(`chatStream.exportImage`)+`</span>`,`</button>`,`<button class="export-dropdown-item export-md-item" type="button">`,`<svg t="1784038824502" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1666" width="32" height="32"><path d="M601.216 85.333333a42.666667 42.666667 0 0 1 30.485333 12.821334l209.450667 213.973333a42.666667 42.666667 0 0 1 12.181333 29.866667V853.333333a85.333333 85.333333 0 0 1-85.333333 85.333334H256a85.333333 85.333333 0 0 1-85.333333-85.333334V170.666667a85.333333 85.333333 0 0 1 85.333333-85.333334h345.216z m-35.584 64H256a21.333333 21.333333 0 0 0-21.333333 21.333334v682.666666a21.333333 21.333333 0 0 0 21.333333 21.333334h512a21.333333 21.333333 0 0 0 21.333333-21.333334V395.413333h-191.68a32 32 0 0 1-32-32L565.632 149.333333z m64 38.186667v143.893333h140.821333L629.632 187.52z" fill="#8a8a8a" p-id="1667"></path><path d="M384.341333 800l-3.072-0.106667a32 32 0 0 1-29.162666-34.624l21.973333-256c2.752-32.256 46.165333-40.490667 60.544-11.477333l77.290667 156.010667 78.805333-156.224c14.08-27.925333 55.082667-20.906667 60.074667 8.789333l0.384 3.050667 20.714666 256a32 32 0 0 1-63.786666 5.162666l-11.541334-142.549333-56.341333 111.722667c-11.413333 22.613333-42.88 23.381333-55.744 2.517333l-1.493333-2.730667-54.912-110.826666-12.181334 142.016a32 32 0 0 1-31.552 29.269333z" fill="#8a8a8a" p-id="1668"></path></svg>`,`<span>`+r(`chatStream.exportMarkdown`)+`</span>`,`</button>`].join(``);let v=_.querySelector(`.export-docx-item`);v.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToDocx:n}=await A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(e,v,_)});let y=_.querySelector(`.export-md-item`);y.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToMarkdown:n}=await A(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(e,y,_)});let b=_.querySelector(`.export-pdf-item`);b.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToPdf:n}=await A(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(e,b,_)});let x=_.querySelector(`.export-image-item`);x.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToImage:n}=await A(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(e,x,_)}),g.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==_&&e.classList.remove(`show`)}),_.classList.toggle(`show`)});let S=null;h.addEventListener(`mouseenter`,()=>{S=setTimeout(()=>{document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==_&&e.classList.remove(`show`)}),_.classList.add(`show`)},300)}),h.addEventListener(`mouseleave`,()=>{S&&=(clearTimeout(S),null),setTimeout(()=>{!h.matches(`:hover`)&&!_.matches(`:hover`)&&_.classList.remove(`show`)},100)}),h.appendChild(g),h.appendChild(_),f.appendChild(h);let w=document.createElement(`div`);w.className=`footer-right-actions`;let T=Le(n);if(T){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:L(T.totalTokens),prompt:L(T.promptTokens),completion:L(T.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${L(T.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Xe(T,e)}),w.appendChild(e)}let E=hb(t),D=vb(n,t);if(E.length&&(e.dataset.declaredArtifacts=JSON.stringify(E)),Ib(D),D.length>0){let e=document.createElement(`button`);e.className=`artifacts-btn`,e.type=`button`,e.title=r(`artifacts.btnTitle`,{count:D.length}),e.innerHTML=`
1755
1755
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">
1756
1756
  <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
1757
1757
  <polyline points="14 2 14 8 20 8"/>
@@ -1817,7 +1817,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
1817
1817
  </div>
1818
1818
  <div class="context-bubble-content">${l}</div>
1819
1819
  </div>
1820
- `;let u=o.querySelector(`.context-bubble-header`),d=o.querySelector(`.context-bubble-content`);return u.addEventListener(`click`,e=>{e.stopPropagation(),d.classList.toggle(`expanded`)}),e===`knowledge`&&o.querySelectorAll(`.kb-bubble-hit-text`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),e.classList.toggle(`expanded`)})}),a.appendChild(o),n&&(a.scrollTop=a.scrollHeight),o}function yT(e){let t=e,n;do n=t,t=t.replace(/^\[(?:已选技能|Selected skill): [^\]]+\]\n[\s\S]*?(?:请根据上述技能说明[\s\S]*?处理以下问题[::]|Please use the relevant tools[\s\S]*?handle the following problem[.:])\s*\n/,``).replace(/^\[(?:已选技能|Selected skill): [^\]]+\]\n(?:请|Please)[^\n]*(?:处理以下问题|handle the following problem)[^。\n]*。?\s*\n/,``);while(t!==n);return t}function bT(e){let t=e,n;do n=t,t=t.replace(/^\[(?:已选MCP服务|Selected MCP service):\s*[^\]]+\]\n(?:请使用「[^」]+」MCP服务来处理以下问题:|Please use the "[^"]+" MCP service to handle the following problem:)\s*\n/,``);while(t!==n);return t}var xT=e=>!!e&&e.dataset.resumable===`budget`;function ST(e,t,n=!0,a=[],o=null,s=!1,c=null,l=null,u=[],d=!1,f=void 0){let p=document.getElementById(`chatContainer`),m=document.createElement(`div`);m.className=`message ${e}`;let h=f===void 0?new Date().toISOString():f||null;h&&(m.dataset.timestamp=h);let g=l||`msg_`+Date.now().toString(36)+`_`+Math.random().toString(36).substring(2,8);m.dataset.messageId=g;let _=Array.isArray(t)?t.filter(e=>e.type===`text`).map(e=>e.text).join(``):t,v=e===`user`?pe(_):_,y=Array.isArray(t)&&t.some(e=>e.type===`image_url`);m.dataset.rawContent=Array.isArray(t)?JSON.stringify(t):ft(t),m.dataset.textContent_=ft(e===`user`?pe(c||v):c||v);let b=v;if(m.dataset.executionLog=JSON.stringify(a),s&&(m.dataset.wasRevised=`true`),e===`assistant`){m.innerHTML=Qe(t);let e=document.createElement(`div`);e.className=`message-footer`;let n=document.createElement(`button`);n.className=`copy-btn`,n.title=r(`chatStream.copyMarkdown`),n.innerHTML=[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>`,`</svg>`,`<span>${r(`common.copy`)}</span>`].join(``),n.addEventListener(`click`,e=>{e.stopPropagation(),yS(m,n,e)}),e.appendChild(n);let c=document.createElement(`button`);c.className=`quote-btn`,c.title=r(`chat.quoteTitle`),c.innerHTML=[`<svg t="1781246498458" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9645" width="14" height="14"><path d="M156.09136 606.57001a457.596822 457.596822 0 0 1 221.680239-392.516385 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z m406.752731 0a457.596822 457.596822 0 0 1 221.680239-392.007944 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z" fill="#8a8a8a" p-id="9646"></path></svg>`,`<span>${r(`chat.quote`)}</span>`].join(``),c.addEventListener(`click`,e=>{e.stopPropagation(),DS(m)}),e.appendChild(c),e.appendChild($x());let l=document.createElement(`div`);l.className=`export-menu-container`;let u=document.createElement(`button`);u.className=`export-trigger-btn`,u.innerHTML=`<svg t="1781245244396" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5115" width="14" height="14"><path d="M496.213333 739.84c2.133333 2.133333 4.693333 3.84 7.68 5.12 0.853333 0.426667 2.133333 0.426667 2.986667 0.853333 1.706667 0.426667 2.986667 0.853333 4.693333 0.853334 5.546667 0 11.093333-2.133333 14.933334-6.4l256-256c8.533333-8.533333 8.533333-21.76 0-30.293334s-21.76-8.533333-30.293334 0L533.333333 674.133333V128c0-11.946667-9.386667-21.333333-21.333333-21.333333s-21.333333 9.386667-21.333333 21.333333v545.706667l-219.306667-219.306667c-8.533333-8.533333-21.76-8.533333-30.293333 0s-8.533333 21.76 0 30.293333l255.146666 255.146667zM768 874.666667H256c-11.946667 0-21.333333 9.386667-21.333333 21.333333s9.386667 21.333333 21.333333 21.333333h512c11.946667 0 21.333333-9.386667 21.333333-21.333333s-9.386667-21.333333-21.333333-21.333333z" fill="#8a8a8a" p-id="5116"></path></svg><span>${r(`chat.export`)}</span><svg class="dropdown-arrow" width="8" height="6" viewBox="0 0 8 6" fill="currentColor"><path d="M0 0l4 6 4-6z"/></svg>`;let f=document.createElement(`div`);f.className=`export-dropdown`,f.innerHTML=[`<button class="export-dropdown-item export-docx-item" type="button">`,`<svg t="1781245550030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6544" width="32" height="32"><path d="M747.936 901.171H276.819c-72.2 0-130.953-55.224-130.953-123.078V244.721c0-67.854 58.752-123.078 130.953-123.078h383.525c6.597 0 12.937 2.505 17.795 6.954l192.363 178.046c5.317 4.96 8.386 11.914 8.386 19.227v452.223c0 67.854-58.752 123.078-130.952 123.078zM276.819 174.004c-43.31 0-78.592 31.703-78.592 70.717v533.372c0 39.015 35.282 70.718 78.592 70.718h471.117c43.31 0 78.592-31.703 78.592-70.718V337.324l-176.461-163.32H276.819z" fill="#8a8a8a" p-id="6545"></path><path d="M830.567 331.546H669.446c-14.471 0-26.18-11.71-26.18-26.181V156.209c0-14.471 11.709-26.18 26.18-26.18s26.181 11.709 26.181 26.18v122.976h134.94c14.471 0 26.181 11.709 26.181 26.18s-11.711 26.181-26.181 26.181z" fill="#8a8a8a" p-id="6546"></path><path d="M730.214 428.749l-92.04 343.616h-53.179L511.363 498.29l-75.677 274.074h-53.179l-92.04-343.616h49.088l69.542 255.667 69.541-255.667h63.406l69.541 255.667 69.541-255.667h49.088z" fill="#8a8a8a" p-id="6547"></path></svg>`,`<span>${r(`chatMsg.exportWord`)}</span>`,`</button>`,`<button class="export-dropdown-item export-pdf-item" type="button">`,`<svg t="1781245863206" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8152" width="32" height="32"><path d="M582.4 864H170.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V170.666667c0-6.4 4.266667-10.666667 10.666667-10.666667h309.333333V320c0 40.533333 34.133333 74.666667 74.666667 74.666667h160v38.4c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V298.666667c0-8.533333-4.266667-17.066667-8.533334-23.466667l-170.666666-170.666667c-6.4-6.4-14.933333-8.533333-23.466667-8.533333H170.666667C130.133333 96 96 130.133333 96 170.666667v682.666666c0 40.533333 34.133333 74.666667 74.666667 74.666667h411.733333c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32z m132.266667-550.4v17.066667H554.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V160h19.2l151.466667 153.6z" fill="#8a8a8a" p-id="8153"></path><path d="M332.8 533.333333c-12.8 0-19.2 2.133333-25.6 6.4-6.4 4.266667-8.533333 12.8-8.533333 23.466667v206.933333c0 6.4 2.133333 12.8 6.4 19.2 4.266667 4.266667 10.666667 8.533333 21.333333 8.533334s17.066667-4.266667 21.333333-8.533334c4.266667-4.266667 6.4-10.666667 6.4-19.2v-64h32c57.6 0 89.6-29.866667 89.6-87.466666 0-27.733333-8.533333-51.2-23.466666-64-14.933333-14.933333-36.266667-21.333333-66.133334-21.333334h-53.333333z m87.466667 85.333334c0 12.8-2.133333 23.466667-8.533334 27.733333-4.266667 4.266667-14.933333 8.533333-27.733333 8.533333h-32v-70.4H384c12.8 0 21.333333 2.133333 27.733333 8.533334 6.4 4.266667 8.533333 12.8 8.533334 25.6zM667.733333 571.733333c-8.533333-12.8-21.333333-21.333333-34.133333-29.866666-14.933333-4.266667-32-8.533333-51.2-8.533334h-61.866667c-8.533333 0-17.066667 0-23.466666 8.533334-2.133333 4.266667-4.266667 10.666667-4.266667 19.2V768c0 8.533333 2.133333 14.933333 4.266667 19.2 6.4 8.533333 14.933333 8.533333 23.466666 8.533333h64c19.2 0 34.133333-4.266667 49.066667-10.666666 12.8-6.4 25.6-17.066667 34.133333-29.866667 8.533333-12.8 14.933333-25.6 19.2-42.666667 4.266667-14.933333 6.4-32 6.4-49.066666 0-17.066667-2.133333-34.133333-6.4-49.066667-4.266667-14.933333-10.666667-29.866667-19.2-42.666667z m-42.666666 153.6c-8.533333 12.8-21.333333 19.2-38.4 19.2h-38.4v-160H576c21.333333 0 38.4 6.4 46.933333 19.2 10.666667 12.8 14.933333 34.133333 14.933334 59.733334 2.133333 27.733333-4.266667 46.933333-12.8 61.866666zM851.2 533.333333h-106.666667c-8.533333 0-17.066667 2.133333-21.333333 6.4-6.4 4.266667-8.533333 12.8-8.533333 21.333334v209.066666c0 6.4 2.133333 12.8 6.4 17.066667 4.266667 6.4 10.666667 8.533333 21.333333 8.533333 8.533333 0 17.066667-2.133333 21.333333-8.533333 2.133333-4.266667 6.4-8.533333 6.4-19.2v-85.333333h72.533334c12.8 0 23.466667-6.4 25.6-17.066667 2.133333-8.533333 2.133333-14.933333 0-17.066667-2.133333-4.266667-6.4-17.066667-25.6-17.066666H768v-49.066667h81.066667c8.533333 0 14.933333-2.133333 19.2-4.266667 4.266667-2.133333 8.533333-8.533333 8.533333-21.333333 2.133333-12.8-8.533333-23.466667-25.6-23.466667z" fill="#8a8a8a" p-id="8154"></path></svg>`,`<span>${r(`chatMsg.exportPdf`)}</span>`,`</button>`,`<button class="export-dropdown-item export-image-item" type="button">`,`<svg t="1784207887308" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5993" width="32" height="32"><path d="M400.696 268.795c-17.249 0-31.233 13.986-31.233 31.233v30.471c0 17.249 13.986 31.233 31.233 31.233s31.233-13.986 31.233-31.233v-30.471c0-17.249-13.985-31.233-31.233-31.233z" fill="#8a8a8a" p-id="5994"></path><path d="M623.649 361.734c17.249 0 31.234-13.986 31.234-31.233v-30.471c0-17.249-13.986-31.233-31.234-31.233s-31.233 13.986-31.233 31.233v30.471c-0.001 17.248 13.985 31.233 31.233 31.233z" fill="#8a8a8a" p-id="5995"></path><path d="M438.295 388.804c-14.656 9.104-19.155 28.362-10.050 43.013 11.209 18.047 41.976 48.59 86.157 48.59 43.958 0 75.1-30.313 86.574-48.223 9.303-14.529 5.068-33.847-9.455-43.15-14.539-9.298-33.852-5.068-43.15 9.455-0.122 0.199-13.38 19.45-33.969 19.45-20.009 0-32.444-18.128-33.278-19.373-9.166-14.423-28.28-18.805-42.829-9.761z" fill="#8a8a8a" p-id="5996"></path><path d="M824.508503 116.690676 571.592236 116.690676c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c40.181141 0 72.878844 32.692586 72.878844 72.878844l0 396.966057-189.334159-165.29465c-12.20088-10.655687-30.517037-10.207479-42.173518 0.9967L468.578048 674.16231 309.521472 517.519714c-11.895935-11.70253-30.903847-12.002358-43.154869-0.645706L126.957507 646.163629l0-394.126382c0-40.186258 32.692586-72.878844 72.878844-72.878844l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352S470.000444 116.690676 452.751594 116.690676L199.836351 116.690676c-74.632791 0-135.346571 60.71378-135.346571 135.346571l0 520.56405c0 74.632791 60.71378 135.346571 135.346571 135.346571l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352s-13.985526-31.233352-31.233352-31.233352L199.836351 845.481164c-40.186258 0-72.878844-32.692586-72.878844-72.878844l0-41.23924 160.003134-148.385539 159.428036 157.007917c12.048407 11.865235 31.361265 11.981892 43.546795 0.274246l198.576661-190.68697 208.876238 182.346001 0 40.683585c0 40.186258-32.697703 72.878844-72.878844 72.878844L571.592236 845.481164c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c74.627674 0 135.346571-60.71378 135.346571-135.346571L959.855074 252.037247C959.855074 177.404456 899.136178 116.690676 824.508503 116.690676z" fill="#8a8a8a" p-id="5997"></path></svg>`,`<span>${r(`chatMsg.exportImage`)}</span>`,`</button>`,`<button class="export-dropdown-item export-md-item" type="button">`,`<svg t="1784038824502" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1666" width="32" height="32"><path d="M601.216 85.333333a42.666667 42.666667 0 0 1 30.485333 12.821334l209.450667 213.973333a42.666667 42.666667 0 0 1 12.181333 29.866667V853.333333a85.333333 85.333333 0 0 1-85.333333 85.333334H256a85.333333 85.333333 0 0 1-85.333333-85.333334V170.666667a85.333333 85.333333 0 0 1 85.333333-85.333334h345.216z m-35.584 64H256a21.333333 21.333333 0 0 0-21.333333 21.333334v682.666666a21.333333 21.333333 0 0 0 21.333333 21.333334h512a21.333333 21.333333 0 0 0 21.333333-21.333334V395.413333h-191.68a32 32 0 0 1-32-32L565.632 149.333333z m64 38.186667v143.893333h140.821333L629.632 187.52z" fill="#8a8a8a" p-id="1667"></path><path d="M384.341333 800l-3.072-0.106667a32 32 0 0 1-29.162666-34.624l21.973333-256c2.752-32.256 46.165333-40.490667 60.544-11.477333l77.290667 156.010667 78.805333-156.224c14.08-27.925333 55.082667-20.906667 60.074667 8.789333l0.384 3.050667 20.714666 256a32 32 0 0 1-63.786666 5.162666l-11.541334-142.549333-56.341333 111.722667c-11.413333 22.613333-42.88 23.381333-55.744 2.517333l-1.493333-2.730667-54.912-110.826666-12.181334 142.016a32 32 0 0 1-31.552 29.269333z" fill="#8a8a8a" p-id="1668"></path></svg>`,`<span>${r(`chatMsg.exportMarkdown`)}</span>`,`</button>`].join(``);let p=f.querySelector(`.export-docx-item`);p.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToDocx:t}=await A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));t(m,p,f)});let h=f.querySelector(`.export-md-item`);h.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToMarkdown:t}=await A(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));t(m,h,f)});let _=f.querySelector(`.export-pdf-item`);_.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToPdf:t}=await A(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));t(m,_,f)});let v=f.querySelector(`.export-image-item`);v.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToImage:t}=await A(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));t(m,v,f)}),u.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==f&&e.classList.remove(`show`)}),f.classList.toggle(`show`)});let y=null;l.addEventListener(`mouseenter`,()=>{y=setTimeout(()=>{document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==f&&e.classList.remove(`show`)}),f.classList.add(`show`)},300)}),l.addEventListener(`mouseleave`,()=>{y&&=(clearTimeout(y),null),setTimeout(()=>{!l.matches(`:hover`)&&!f.matches(`:hover`)&&f.classList.remove(`show`)},100)}),l.appendChild(u),l.appendChild(f),e.appendChild(l);let b=document.createElement(`div`);b.className=`footer-right-actions`;let x=Le(a);if(x){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:L(x.totalTokens),prompt:L(x.promptTokens),completion:L(x.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${L(x.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Xe(x,e)}),b.appendChild(e)}let S=a&&a.length>0,w=o!=null,T=a?a.filter(e=>e.nodeType===`reflection`&&e.reflectionType===`post`&&e.status===`success`).length:0;TT(),DT(),ct();let E=a?.find(e=>e.nodeType===`reflection`&&e.reflectionType===`post`),D=hb(t),O=vb(a,t);if(D.length&&(m.dataset.declaredArtifacts=JSON.stringify(D)),Ib(O),console.log(`[addMessage] executionLog entries:`,a?.length,`| agent_file entries:`,a?.filter(e=>e.nodeType===`tool_exec`&&e.action?.name===`agent_file`).length,`| artifacts:`,O.length),O.length>0){let e=document.createElement(`button`);e.className=`artifacts-btn`,e.type=`button`,e.title=r(`artifacts.btnTitle`,{count:O.length}),e.innerHTML=`
1820
+ `;let u=o.querySelector(`.context-bubble-header`),d=o.querySelector(`.context-bubble-content`);return u.addEventListener(`click`,e=>{e.stopPropagation(),d.classList.toggle(`expanded`)}),e===`knowledge`&&o.querySelectorAll(`.kb-bubble-hit-text`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),e.classList.toggle(`expanded`)})}),a.appendChild(o),n&&(a.scrollTop=a.scrollHeight),o}function yT(e){let t=e,n;do n=t,t=t.replace(/^\[(?:已选技能|Selected skill): [^\]]+\]\n[\s\S]*?(?:请根据上述技能说明[\s\S]*?处理以下问题[::]|Please use the relevant tools[\s\S]*?handle the following problem[.:])\s*\n/,``).replace(/^\[(?:已选技能|Selected skill): [^\]]+\]\n(?:请|Please)[^\n]*(?:处理以下问题|handle the following problem)[^。\n]*。?\s*\n/,``);while(t!==n);return t}function bT(e){let t=e,n;do n=t,t=t.replace(/^\[(?:已选MCP服务|Selected MCP service):\s*[^\]]+\]\n(?:请使用「[^」]+」MCP服务来处理以下问题:|Please use the "[^"]+" MCP service to handle the following problem:)\s*\n/,``);while(t!==n);return t}var xT=e=>!!e&&e.dataset.resumable===`budget`;function ST(e,t,n=!0,a=[],o=null,s=!1,c=null,l=null,u=[],d=!1,f=void 0){let p=document.getElementById(`chatContainer`),m=document.createElement(`div`);m.className=`message ${e}`;let h=f===void 0?new Date().toISOString():f||null;h&&(m.dataset.timestamp=h);let g=l||`msg_`+Date.now().toString(36)+`_`+Math.random().toString(36).substring(2,8);m.dataset.messageId=g;let _=Array.isArray(t)?t.filter(e=>e.type===`text`).map(e=>e.text).join(``):t,v=e===`user`?pe(_):_,y=Array.isArray(t)&&t.some(e=>e.type===`image_url`);m.dataset.rawContent=Array.isArray(t)?JSON.stringify(t):ft(t),m.dataset.textContent_=ft(e===`user`?pe(c||v):c||v);let b=v;if(m.dataset.executionLog=JSON.stringify(a),s&&(m.dataset.wasRevised=`true`),e===`assistant`){m.innerHTML=Qe(t);let e=document.createElement(`div`);e.className=`message-footer`;let n=document.createElement(`button`);n.className=`copy-btn`,n.title=r(`chatStream.copyMarkdown`),n.innerHTML=[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>`,`</svg>`,`<span>${r(`common.copy`)}</span>`].join(``),n.addEventListener(`click`,e=>{e.stopPropagation(),yS(m,n,e)}),e.appendChild(n);let c=document.createElement(`button`);c.className=`quote-btn`,c.title=r(`chat.quoteTitle`),c.innerHTML=[`<svg t="1781246498458" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9645" width="14" height="14"><path d="M156.09136 606.57001a457.596822 457.596822 0 0 1 221.680239-392.516385 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z m406.752731 0a457.596822 457.596822 0 0 1 221.680239-392.007944 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z" fill="#8a8a8a" p-id="9646"></path></svg>`,`<span>${r(`chat.quote`)}</span>`].join(``),c.addEventListener(`click`,e=>{e.stopPropagation(),DS(m)}),e.appendChild(c),e.appendChild($x());let l=document.createElement(`div`);l.className=`export-menu-container`;let u=document.createElement(`button`);u.className=`export-trigger-btn`,u.innerHTML=`<svg t="1781245244396" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5115" width="14" height="14"><path d="M496.213333 739.84c2.133333 2.133333 4.693333 3.84 7.68 5.12 0.853333 0.426667 2.133333 0.426667 2.986667 0.853333 1.706667 0.426667 2.986667 0.853333 4.693333 0.853334 5.546667 0 11.093333-2.133333 14.933334-6.4l256-256c8.533333-8.533333 8.533333-21.76 0-30.293334s-21.76-8.533333-30.293334 0L533.333333 674.133333V128c0-11.946667-9.386667-21.333333-21.333333-21.333333s-21.333333 9.386667-21.333333 21.333333v545.706667l-219.306667-219.306667c-8.533333-8.533333-21.76-8.533333-30.293333 0s-8.533333 21.76 0 30.293333l255.146666 255.146667zM768 874.666667H256c-11.946667 0-21.333333 9.386667-21.333333 21.333333s9.386667 21.333333 21.333333 21.333333h512c11.946667 0 21.333333-9.386667 21.333333-21.333333s-9.386667-21.333333-21.333333-21.333333z" fill="#8a8a8a" p-id="5116"></path></svg><span>${r(`chat.export`)}</span><svg class="dropdown-arrow" width="8" height="6" viewBox="0 0 8 6" fill="currentColor"><path d="M0 0l4 6 4-6z"/></svg>`;let f=document.createElement(`div`);f.className=`export-dropdown`,f.innerHTML=[`<button class="export-dropdown-item export-docx-item" type="button">`,`<svg t="1781245550030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6544" width="32" height="32"><path d="M747.936 901.171H276.819c-72.2 0-130.953-55.224-130.953-123.078V244.721c0-67.854 58.752-123.078 130.953-123.078h383.525c6.597 0 12.937 2.505 17.795 6.954l192.363 178.046c5.317 4.96 8.386 11.914 8.386 19.227v452.223c0 67.854-58.752 123.078-130.952 123.078zM276.819 174.004c-43.31 0-78.592 31.703-78.592 70.717v533.372c0 39.015 35.282 70.718 78.592 70.718h471.117c43.31 0 78.592-31.703 78.592-70.718V337.324l-176.461-163.32H276.819z" fill="#8a8a8a" p-id="6545"></path><path d="M830.567 331.546H669.446c-14.471 0-26.18-11.71-26.18-26.181V156.209c0-14.471 11.709-26.18 26.18-26.18s26.181 11.709 26.181 26.18v122.976h134.94c14.471 0 26.181 11.709 26.181 26.18s-11.711 26.181-26.181 26.181z" fill="#8a8a8a" p-id="6546"></path><path d="M730.214 428.749l-92.04 343.616h-53.179L511.363 498.29l-75.677 274.074h-53.179l-92.04-343.616h49.088l69.542 255.667 69.541-255.667h63.406l69.541 255.667 69.541-255.667h49.088z" fill="#8a8a8a" p-id="6547"></path></svg>`,`<span>${r(`chatMsg.exportWord`)}</span>`,`</button>`,`<button class="export-dropdown-item export-pdf-item" type="button">`,`<svg t="1781245863206" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8152" width="32" height="32"><path d="M582.4 864H170.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V170.666667c0-6.4 4.266667-10.666667 10.666667-10.666667h309.333333V320c0 40.533333 34.133333 74.666667 74.666667 74.666667h160v38.4c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V298.666667c0-8.533333-4.266667-17.066667-8.533334-23.466667l-170.666666-170.666667c-6.4-6.4-14.933333-8.533333-23.466667-8.533333H170.666667C130.133333 96 96 130.133333 96 170.666667v682.666666c0 40.533333 34.133333 74.666667 74.666667 74.666667h411.733333c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32z m132.266667-550.4v17.066667H554.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V160h19.2l151.466667 153.6z" fill="#8a8a8a" p-id="8153"></path><path d="M332.8 533.333333c-12.8 0-19.2 2.133333-25.6 6.4-6.4 4.266667-8.533333 12.8-8.533333 23.466667v206.933333c0 6.4 2.133333 12.8 6.4 19.2 4.266667 4.266667 10.666667 8.533333 21.333333 8.533334s17.066667-4.266667 21.333333-8.533334c4.266667-4.266667 6.4-10.666667 6.4-19.2v-64h32c57.6 0 89.6-29.866667 89.6-87.466666 0-27.733333-8.533333-51.2-23.466666-64-14.933333-14.933333-36.266667-21.333333-66.133334-21.333334h-53.333333z m87.466667 85.333334c0 12.8-2.133333 23.466667-8.533334 27.733333-4.266667 4.266667-14.933333 8.533333-27.733333 8.533333h-32v-70.4H384c12.8 0 21.333333 2.133333 27.733333 8.533334 6.4 4.266667 8.533333 12.8 8.533334 25.6zM667.733333 571.733333c-8.533333-12.8-21.333333-21.333333-34.133333-29.866666-14.933333-4.266667-32-8.533333-51.2-8.533334h-61.866667c-8.533333 0-17.066667 0-23.466666 8.533334-2.133333 4.266667-4.266667 10.666667-4.266667 19.2V768c0 8.533333 2.133333 14.933333 4.266667 19.2 6.4 8.533333 14.933333 8.533333 23.466666 8.533333h64c19.2 0 34.133333-4.266667 49.066667-10.666666 12.8-6.4 25.6-17.066667 34.133333-29.866667 8.533333-12.8 14.933333-25.6 19.2-42.666667 4.266667-14.933333 6.4-32 6.4-49.066666 0-17.066667-2.133333-34.133333-6.4-49.066667-4.266667-14.933333-10.666667-29.866667-19.2-42.666667z m-42.666666 153.6c-8.533333 12.8-21.333333 19.2-38.4 19.2h-38.4v-160H576c21.333333 0 38.4 6.4 46.933333 19.2 10.666667 12.8 14.933333 34.133333 14.933334 59.733334 2.133333 27.733333-4.266667 46.933333-12.8 61.866666zM851.2 533.333333h-106.666667c-8.533333 0-17.066667 2.133333-21.333333 6.4-6.4 4.266667-8.533333 12.8-8.533333 21.333334v209.066666c0 6.4 2.133333 12.8 6.4 17.066667 4.266667 6.4 10.666667 8.533333 21.333333 8.533333 8.533333 0 17.066667-2.133333 21.333333-8.533333 2.133333-4.266667 6.4-8.533333 6.4-19.2v-85.333333h72.533334c12.8 0 23.466667-6.4 25.6-17.066667 2.133333-8.533333 2.133333-14.933333 0-17.066667-2.133333-4.266667-6.4-17.066667-25.6-17.066666H768v-49.066667h81.066667c8.533333 0 14.933333-2.133333 19.2-4.266667 4.266667-2.133333 8.533333-8.533333 8.533333-21.333333 2.133333-12.8-8.533333-23.466667-25.6-23.466667z" fill="#8a8a8a" p-id="8154"></path></svg>`,`<span>${r(`chatMsg.exportPdf`)}</span>`,`</button>`,`<button class="export-dropdown-item export-image-item" type="button">`,`<svg t="1784207887308" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5993" width="32" height="32"><path d="M400.696 268.795c-17.249 0-31.233 13.986-31.233 31.233v30.471c0 17.249 13.986 31.233 31.233 31.233s31.233-13.986 31.233-31.233v-30.471c0-17.249-13.985-31.233-31.233-31.233z" fill="#8a8a8a" p-id="5994"></path><path d="M623.649 361.734c17.249 0 31.234-13.986 31.234-31.233v-30.471c0-17.249-13.986-31.233-31.234-31.233s-31.233 13.986-31.233 31.233v30.471c-0.001 17.248 13.985 31.233 31.233 31.233z" fill="#8a8a8a" p-id="5995"></path><path d="M438.295 388.804c-14.656 9.104-19.155 28.362-10.050 43.013 11.209 18.047 41.976 48.59 86.157 48.59 43.958 0 75.1-30.313 86.574-48.223 9.303-14.529 5.068-33.847-9.455-43.15-14.539-9.298-33.852-5.068-43.15 9.455-0.122 0.199-13.38 19.45-33.969 19.45-20.009 0-32.444-18.128-33.278-19.373-9.166-14.423-28.28-18.805-42.829-9.761z" fill="#8a8a8a" p-id="5996"></path><path d="M824.508503 116.690676 571.592236 116.690676c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c40.181141 0 72.878844 32.692586 72.878844 72.878844l0 396.966057-189.334159-165.29465c-12.20088-10.655687-30.517037-10.207479-42.173518 0.9967L468.578048 674.16231 309.521472 517.519714c-11.895935-11.70253-30.903847-12.002358-43.154869-0.645706L126.957507 646.163629l0-394.126382c0-40.186258 32.692586-72.878844 72.878844-72.878844l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352S470.000444 116.690676 452.751594 116.690676L199.836351 116.690676c-74.632791 0-135.346571 60.71378-135.346571 135.346571l0 520.56405c0 74.632791 60.71378 135.346571 135.346571 135.346571l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352s-13.985526-31.233352-31.233352-31.233352L199.836351 845.481164c-40.186258 0-72.878844-32.692586-72.878844-72.878844l0-41.23924 160.003134-148.385539 159.428036 157.007917c12.048407 11.865235 31.361265 11.981892 43.546795 0.274246l198.576661-190.68697 208.876238 182.346001 0 40.683585c0 40.186258-32.697703 72.878844-72.878844 72.878844L571.592236 845.481164c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c74.627674 0 135.346571-60.71378 135.346571-135.346571L959.855074 252.037247C959.855074 177.404456 899.136178 116.690676 824.508503 116.690676z" fill="#8a8a8a" p-id="5997"></path></svg>`,`<span>${r(`chatMsg.exportImage`)}</span>`,`</button>`,`<button class="export-dropdown-item export-md-item" type="button">`,`<svg t="1784038824502" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1666" width="32" height="32"><path d="M601.216 85.333333a42.666667 42.666667 0 0 1 30.485333 12.821334l209.450667 213.973333a42.666667 42.666667 0 0 1 12.181333 29.866667V853.333333a85.333333 85.333333 0 0 1-85.333333 85.333334H256a85.333333 85.333333 0 0 1-85.333333-85.333334V170.666667a85.333333 85.333333 0 0 1 85.333333-85.333334h345.216z m-35.584 64H256a21.333333 21.333333 0 0 0-21.333333 21.333334v682.666666a21.333333 21.333333 0 0 0 21.333333 21.333334h512a21.333333 21.333333 0 0 0 21.333333-21.333334V395.413333h-191.68a32 32 0 0 1-32-32L565.632 149.333333z m64 38.186667v143.893333h140.821333L629.632 187.52z" fill="#8a8a8a" p-id="1667"></path><path d="M384.341333 800l-3.072-0.106667a32 32 0 0 1-29.162666-34.624l21.973333-256c2.752-32.256 46.165333-40.490667 60.544-11.477333l77.290667 156.010667 78.805333-156.224c14.08-27.925333 55.082667-20.906667 60.074667 8.789333l0.384 3.050667 20.714666 256a32 32 0 0 1-63.786666 5.162666l-11.541334-142.549333-56.341333 111.722667c-11.413333 22.613333-42.88 23.381333-55.744 2.517333l-1.493333-2.730667-54.912-110.826666-12.181334 142.016a32 32 0 0 1-31.552 29.269333z" fill="#8a8a8a" p-id="1668"></path></svg>`,`<span>${r(`chatMsg.exportMarkdown`)}</span>`,`</button>`].join(``);let p=f.querySelector(`.export-docx-item`);p.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToDocx:t}=await A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));t(m,p,f)});let h=f.querySelector(`.export-md-item`);h.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToMarkdown:t}=await A(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));t(m,h,f)});let _=f.querySelector(`.export-pdf-item`);_.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToPdf:t}=await A(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));t(m,_,f)});let v=f.querySelector(`.export-image-item`);v.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToImage:t}=await A(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));t(m,v,f)}),u.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==f&&e.classList.remove(`show`)}),f.classList.toggle(`show`)});let y=null;l.addEventListener(`mouseenter`,()=>{y=setTimeout(()=>{document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==f&&e.classList.remove(`show`)}),f.classList.add(`show`)},300)}),l.addEventListener(`mouseleave`,()=>{y&&=(clearTimeout(y),null),setTimeout(()=>{!l.matches(`:hover`)&&!f.matches(`:hover`)&&f.classList.remove(`show`)},100)}),l.appendChild(u),l.appendChild(f),e.appendChild(l);let b=document.createElement(`div`);b.className=`footer-right-actions`;let x=Le(a);if(x){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:L(x.totalTokens),prompt:L(x.promptTokens),completion:L(x.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${L(x.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Xe(x,e)}),b.appendChild(e)}let S=a&&a.length>0,w=o!=null,T=a?a.filter(e=>e.nodeType===`reflection`&&e.reflectionType===`post`&&e.status===`success`).length:0;TT(),DT(),ct();let E=a?.find(e=>e.nodeType===`reflection`&&e.reflectionType===`post`),D=hb(t),O=vb(a,t);if(D.length&&(m.dataset.declaredArtifacts=JSON.stringify(D)),Ib(O),console.log(`[addMessage] executionLog entries:`,a?.length,`| agent_file entries:`,a?.filter(e=>e.nodeType===`tool_exec`&&e.action?.name===`agent_file`).length,`| artifacts:`,O.length),O.length>0){let e=document.createElement(`button`);e.className=`artifacts-btn`,e.type=`button`,e.title=r(`artifacts.btnTitle`,{count:O.length}),e.innerHTML=`
1821
1821
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">
1822
1822
  <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
1823
1823
  <polyline points="14 2 14 8 20 8"/>
@@ -1880,11 +1880,11 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
1880
1880
  <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
1881
1881
  <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>
1882
1882
  </svg>
1883
- </button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),s.querySelectorAll(`.subtask-progress`).forEach(e=>{sT(e)}),s.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),NT(C.activeSessionId)})}),s.querySelectorAll(`.tool-call-abort-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),chrome.runtime.sendMessage({type:`ABORT_CURRENT_TOOL`,sessionId:C.activeSessionId}),e.disabled=!0,e.title=r(`chatMsg.aborting`)})});let l=s.querySelector(`.message-footer`);if(l){let e=l.querySelector(`.copy-btn`);e&&e.addEventListener(`click`,t=>{t.stopPropagation(),yS(s,e,t)});let t=l.querySelector(`.quote-btn`);t&&t.addEventListener(`click`,e=>{e.stopPropagation(),DS(s)});let n=l.querySelector(`.export-trigger-btn`),r=l.querySelector(`.export-dropdown`);n&&r&&(n.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==r&&e.classList.remove(`show`)}),r.classList.toggle(`show`)}),r.querySelector(`.export-docx-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToDocx:n}=await A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(s,t,r)}),r.querySelector(`.export-md-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToMarkdown:n}=await A(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(s,t,r)}),r.querySelector(`.export-pdf-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToPdf:n}=await A(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(s,t,r)}),r.querySelector(`.export-image-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToImage:n}=await A(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(s,t,r)}));let a=l.querySelector(`.prototype-btn-small`);if(a){let e=(()=>{try{let e=s.dataset.executionLog;return e?JSON.parse(e):[]}catch{return[]}})().find(e=>e.nodeType===`tool_exec`&&e.action?.name===`preview_ui`||e.action?.name===`preview_preview_ui`&&e.status===`success`);e&&a.addEventListener(`click`,()=>{let t=e.prototypeId;if(!t&&e.observation)try{t=(typeof e.observation==`string`?JSON.parse(e.observation):e.observation)?.prototypeId}catch{}t?Kc(t):i.error(`[SidePanel] not found prototypeId,entry keys:`,Object.keys(e),`observation:`,e.observation)})}let o=l.querySelector(`.bookmark-btn`);o&&(bh(o,C.activeSessionId,s.dataset.messageId),o.addEventListener(`click`,async e=>{e.stopPropagation();let t=C.activeSessionId,n=s.dataset.messageId;if(o.classList.contains(`bookmarked`)){await ch(t,n),bh(o,t,n);let{refreshBookmarkPanel:e}=await A(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>fh);return{refreshBookmarkPanel:e}},void 0);e()}else{await sh(t,n,s.dataset.textContent_||``,C.sessions.find(e=>e.id===t)?.title||``),bh(o,t,n);let{refreshBookmarkPanel:e}=await A(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>fh);return{refreshBookmarkPanel:e}},void 0);e()}}));let c=l.querySelector(`.delete-btn`);c&&c.addEventListener(`click`,e=>{e.stopPropagation(),FT(s)});let u=l.querySelector(`.fork-btn`);u&&u.addEventListener(`click`,async e=>{e.stopPropagation();let t=s.dataset.messageId;t&&await yc(C.activeSessionId,t)});let d=l.querySelector(`.resume-task-btn`);d&&d.addEventListener(`click`,async e=>{if(e.stopPropagation(),d.disabled)return;let t=await AS({budgetEnded:xT(s)});t!==null&&(d.disabled=!0,d.style.opacity=`0.6`,d.style.cursor=`not-allowed`,FS(C.activeSessionId,t).finally(()=>{d.disabled=!1,d.style.opacity=``,d.style.cursor=``}))}),AT(s);let f=l.querySelector(`.token-usage-tag`);f&&!f._clickBound&&(f._clickBound=!0,f.style.cursor=`pointer`,f.addEventListener(`click`,e=>{e.stopPropagation();try{let e=s.dataset.executionLog,t=Le(e?JSON.parse(e):[]);t&&Xe(t,f)}catch{}}))}let u=s.querySelector(`.message-toolbar`);if(u){let e=u.querySelector(`.edit-btn`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),zT(s)});let t=u.querySelector(`.copy-btn`);t&&t.addEventListener(`click`,e=>{e.stopPropagation(),vS(s,t)});let n=u.querySelector(`.delete-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),FT(s)})}s.querySelectorAll(`.user-message-image`).forEach(e=>{e.addEventListener(`click`,()=>{am(e.src,e)})}),a.appendChild(s),nk()}function MT(e){e.querySelectorAll(`.tool-call-body > pre, .tool-result-content > pre, .agent-stream-output > pre`).forEach(e=>{if(e.parentElement.classList.contains(`code-block-container`))return;let t=document.createElement(`div`);t.className=`code-block-container`,t.style.position=`relative`,t.innerHTML=`<button class="code-copy-btn" title="${r(`chatMsg.copyCode`)}">
1883
+ </button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),s.querySelectorAll(`.subtask-progress`).forEach(e=>{sT(e)}),s.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),NT(C.activeSessionId)})}),s.querySelectorAll(`.tool-call-abort-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),chrome.runtime.sendMessage({type:`ABORT_CURRENT_TOOL`,sessionId:C.activeSessionId}),e.disabled=!0,e.title=r(`chatMsg.aborting`)})});let l=s.querySelector(`.message-footer`);if(l){let e=l.querySelector(`.copy-btn`);e&&e.addEventListener(`click`,t=>{t.stopPropagation(),yS(s,e,t)});let t=l.querySelector(`.quote-btn`);t&&t.addEventListener(`click`,e=>{e.stopPropagation(),DS(s)});let n=l.querySelector(`.export-trigger-btn`),r=l.querySelector(`.export-dropdown`);n&&r&&(n.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==r&&e.classList.remove(`show`)}),r.classList.toggle(`show`)}),r.querySelector(`.export-docx-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToDocx:n}=await A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(s,t,r)}),r.querySelector(`.export-md-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToMarkdown:n}=await A(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(s,t,r)}),r.querySelector(`.export-pdf-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToPdf:n}=await A(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(s,t,r)}),r.querySelector(`.export-image-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToImage:n}=await A(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(s,t,r)}));let a=l.querySelector(`.prototype-btn-small`);if(a){let e=(()=>{try{let e=s.dataset.executionLog;return e?JSON.parse(e):[]}catch{return[]}})().find(e=>e.nodeType===`tool_exec`&&e.action?.name===`preview_ui`||e.action?.name===`preview_preview_ui`&&e.status===`success`);e&&a.addEventListener(`click`,()=>{let t=e.prototypeId;if(!t&&e.observation)try{t=(typeof e.observation==`string`?JSON.parse(e.observation):e.observation)?.prototypeId}catch{}t?Kc(t):i.error(`[SidePanel] not found prototypeId,entry keys:`,Object.keys(e),`observation:`,e.observation)})}let o=l.querySelector(`.bookmark-btn`);o&&(bh(o,C.activeSessionId,s.dataset.messageId),o.addEventListener(`click`,async e=>{e.stopPropagation();let t=C.activeSessionId,n=s.dataset.messageId;if(o.classList.contains(`bookmarked`)){await ch(t,n),bh(o,t,n);let{refreshBookmarkPanel:e}=await A(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>fh);return{refreshBookmarkPanel:e}},void 0);e()}else{await sh(t,n,s.dataset.textContent_||``,C.sessions.find(e=>e.id===t)?.title||``),bh(o,t,n);let{refreshBookmarkPanel:e}=await A(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>fh);return{refreshBookmarkPanel:e}},void 0);e()}}));let c=l.querySelector(`.delete-btn`);c&&c.addEventListener(`click`,e=>{e.stopPropagation(),FT(s)});let u=l.querySelector(`.fork-btn`);u&&u.addEventListener(`click`,async e=>{e.stopPropagation();let t=s.dataset.messageId;t&&await yc(C.activeSessionId,t)});let d=l.querySelector(`.resume-task-btn`);d&&d.addEventListener(`click`,async e=>{if(e.stopPropagation(),d.disabled)return;let t=await AS({budgetEnded:xT(s)});t!==null&&(d.disabled=!0,d.style.opacity=`0.6`,d.style.cursor=`not-allowed`,FS(C.activeSessionId,t).finally(()=>{d.disabled=!1,d.style.opacity=``,d.style.cursor=``}))}),AT(s);let f=l.querySelector(`.token-usage-tag`);f&&!f._clickBound&&(f._clickBound=!0,f.style.cursor=`pointer`,f.addEventListener(`click`,e=>{e.stopPropagation();try{let e=s.dataset.executionLog,t=Le(e?JSON.parse(e):[]);t&&Xe(t,f)}catch{}}))}let u=s.querySelector(`.message-toolbar`);if(u){let e=u.querySelector(`.edit-btn`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),zT(s)});let t=u.querySelector(`.copy-btn`);t&&t.addEventListener(`click`,e=>{e.stopPropagation(),vS(s,t)});let n=u.querySelector(`.delete-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),FT(s)})}s.querySelectorAll(`.user-message-image`).forEach(e=>{e.addEventListener(`click`,()=>{am(e.src,e)})}),a.appendChild(s),nk()}function MT(e){e.querySelectorAll(`.tool-call-body > pre, .tool-result-content > pre, .agent-stream-output > pre`).forEach(e=>{if(e.parentElement.classList.contains(`code-block-container`))return;let t=document.createElement(`div`);t.className=`code-block-container`,t.style.position=`relative`,t.innerHTML=`<button class="code-copy-btn" title="${r(`chatMsg.copyCode`)}">
1884
1884
  <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
1885
1885
  <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>
1886
1886
  </svg>
1887
- </button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),e.querySelectorAll(`.thinking-process-header`).forEach(e=>{wC(e)}),e.querySelectorAll(`.tool-call-header`).forEach(e=>{e.addEventListener(`click`,t=>{if(t.ctrlKey||t.metaKey)return;let n=e.closest(`.tool-call-item`);n&&n.classList.toggle(`expanded`)})}),e.querySelectorAll(`.tool-call-result`).forEach(e=>{let t=e.querySelector(`code`);if(!t)return;let n=t.dataset.fullContent;if(!n||n.length<=500)return;let r=t.textContent||``,i=!1;e.style.cursor=`pointer`,e.addEventListener(`click`,e=>{e.ctrlKey||e.metaKey||(e.stopPropagation(),i=!i,t.textContent=i?n:r)})}),e.querySelectorAll(`.subtask-progress`).forEach(e=>{sT(e)}),e.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),NT(C.activeSessionId)})}),e.querySelectorAll(`.tool-call-abort-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),chrome.runtime.sendMessage({type:`ABORT_CURRENT_TOOL`,sessionId:C.activeSessionId}),e.disabled=!0,e.title=r(`chatMsg.aborting`)})}),e.querySelectorAll(`.message-footer`).forEach(e=>{let t=e.closest(`.message`);if(!t)return;let n=e.querySelector(`.copy-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),yS(t,n,e)});let r=e.querySelector(`.quote-btn`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),DS(t)});let i=e.querySelector(`.export-trigger-btn`),a=e.querySelector(`.export-dropdown`);i&&a&&(i.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==a&&e.classList.remove(`show`)}),a.classList.toggle(`show`)}),a.querySelector(`.export-docx-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToDocx:r}=await A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));r(t,n,a)}),a.querySelector(`.export-md-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToMarkdown:r}=await A(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));r(t,n,a)}),a.querySelector(`.export-pdf-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToPdf:r}=await A(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));r(t,n,a)}),a.querySelector(`.export-image-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToImage:r}=await A(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-DWrq6XW7.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));r(t,n,a)}));let o=e.querySelector(`.prototype-btn-small`);if(o){let e=(()=>{try{let e=t.dataset.executionLog;return e?JSON.parse(e):[]}catch{return[]}})().find(e=>e.nodeType===`tool_exec`&&e.action?.name===`preview_ui`||e.action?.name===`preview_preview_ui`&&e.status===`success`);e&&o.addEventListener(`click`,()=>{let t=e.prototypeId;if(!t&&e.observation)try{t=(typeof e.observation==`string`?JSON.parse(e.observation):e.observation)?.prototypeId}catch{}t&&Kc(t)})}let s=e.querySelector(`.bookmark-btn`);s&&(bh(s,C.activeSessionId,t.dataset.messageId),s.addEventListener(`click`,async e=>{e.stopPropagation();let n=C.activeSessionId,r=t.dataset.messageId;if(s.classList.contains(`bookmarked`)){await ch(n,r),bh(s,n,r);let{refreshBookmarkPanel:e}=await A(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>fh);return{refreshBookmarkPanel:e}},void 0);e()}else{await sh(n,r,t.dataset.textContent_||``,C.sessions.find(e=>e.id===n)?.title||``),bh(s,n,r);let{refreshBookmarkPanel:e}=await A(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>fh);return{refreshBookmarkPanel:e}},void 0);e()}}));let c=e.querySelector(`.delete-btn`);c&&c.addEventListener(`click`,e=>{e.stopPropagation(),FT(t)});let l=e.querySelector(`.fork-btn`);l&&l.addEventListener(`click`,async e=>{e.stopPropagation();let n=t.dataset.messageId;n&&await yc(C.activeSessionId,n)});let u=e.querySelector(`.resume-task-btn`);u&&u.addEventListener(`click`,async e=>{if(e.stopPropagation(),u.disabled)return;let n=await AS({budgetEnded:xT(t)});n!==null&&(u.disabled=!0,u.style.opacity=`0.6`,u.style.cursor=`not-allowed`,FS(C.activeSessionId,n).finally(()=>{u.disabled=!1,u.style.opacity=``,u.style.cursor=``}))}),AT(t);let d=e.querySelector(`.token-usage-tag`);d&&!d._clickBound&&(d._clickBound=!0,d.style.cursor=`pointer`,d.addEventListener(`click`,e=>{e.stopPropagation();try{let e=t.dataset.executionLog,n=Le(e?JSON.parse(e):[]);n&&Xe(n,d)}catch{}}))}),e.querySelectorAll(`.message-toolbar`).forEach(e=>{let t=e.closest(`.message`);if(!t)return;let n=e.querySelector(`.edit-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),zT(t)});let r=e.querySelector(`.copy-btn`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),vS(t,r)});let i=e.querySelector(`.delete-btn`);i&&i.addEventListener(`click`,e=>{e.stopPropagation(),FT(t)})}),e.querySelectorAll(`.user-message-image`).forEach(e=>{e.addEventListener(`click`,()=>{am(e.src,e)})}),e.querySelectorAll(`.mermaid-controls`).forEach(e=>e.remove()),$e(),TT(),DT(),nk()}function NT(e){return new Promise(t=>{let n=document.querySelector(`.command-terminate-overlay`);n&&n.remove();let i=document.createElement(`div`);i.className=`command-terminate-overlay`,i.innerHTML=`
1887
+ </button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),e.querySelectorAll(`.thinking-process-header`).forEach(e=>{wC(e)}),e.querySelectorAll(`.tool-call-header`).forEach(e=>{e.addEventListener(`click`,t=>{if(t.ctrlKey||t.metaKey)return;let n=e.closest(`.tool-call-item`);n&&n.classList.toggle(`expanded`)})}),e.querySelectorAll(`.tool-call-result`).forEach(e=>{let t=e.querySelector(`code`);if(!t)return;let n=t.dataset.fullContent;if(!n||n.length<=500)return;let r=t.textContent||``,i=!1;e.style.cursor=`pointer`,e.addEventListener(`click`,e=>{e.ctrlKey||e.metaKey||(e.stopPropagation(),i=!i,t.textContent=i?n:r)})}),e.querySelectorAll(`.subtask-progress`).forEach(e=>{sT(e)}),e.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),NT(C.activeSessionId)})}),e.querySelectorAll(`.tool-call-abort-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),chrome.runtime.sendMessage({type:`ABORT_CURRENT_TOOL`,sessionId:C.activeSessionId}),e.disabled=!0,e.title=r(`chatMsg.aborting`)})}),e.querySelectorAll(`.message-footer`).forEach(e=>{let t=e.closest(`.message`);if(!t)return;let n=e.querySelector(`.copy-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),yS(t,n,e)});let r=e.querySelector(`.quote-btn`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),DS(t)});let i=e.querySelector(`.export-trigger-btn`),a=e.querySelector(`.export-dropdown`);i&&a&&(i.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==a&&e.classList.remove(`show`)}),a.classList.toggle(`show`)}),a.querySelector(`.export-docx-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToDocx:r}=await A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));r(t,n,a)}),a.querySelector(`.export-md-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToMarkdown:r}=await A(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));r(t,n,a)}),a.querySelector(`.export-pdf-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToPdf:r}=await A(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));r(t,n,a)}),a.querySelector(`.export-image-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToImage:r}=await A(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-ryKcmB-h.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));r(t,n,a)}));let o=e.querySelector(`.prototype-btn-small`);if(o){let e=(()=>{try{let e=t.dataset.executionLog;return e?JSON.parse(e):[]}catch{return[]}})().find(e=>e.nodeType===`tool_exec`&&e.action?.name===`preview_ui`||e.action?.name===`preview_preview_ui`&&e.status===`success`);e&&o.addEventListener(`click`,()=>{let t=e.prototypeId;if(!t&&e.observation)try{t=(typeof e.observation==`string`?JSON.parse(e.observation):e.observation)?.prototypeId}catch{}t&&Kc(t)})}let s=e.querySelector(`.bookmark-btn`);s&&(bh(s,C.activeSessionId,t.dataset.messageId),s.addEventListener(`click`,async e=>{e.stopPropagation();let n=C.activeSessionId,r=t.dataset.messageId;if(s.classList.contains(`bookmarked`)){await ch(n,r),bh(s,n,r);let{refreshBookmarkPanel:e}=await A(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>fh);return{refreshBookmarkPanel:e}},void 0);e()}else{await sh(n,r,t.dataset.textContent_||``,C.sessions.find(e=>e.id===n)?.title||``),bh(s,n,r);let{refreshBookmarkPanel:e}=await A(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>fh);return{refreshBookmarkPanel:e}},void 0);e()}}));let c=e.querySelector(`.delete-btn`);c&&c.addEventListener(`click`,e=>{e.stopPropagation(),FT(t)});let l=e.querySelector(`.fork-btn`);l&&l.addEventListener(`click`,async e=>{e.stopPropagation();let n=t.dataset.messageId;n&&await yc(C.activeSessionId,n)});let u=e.querySelector(`.resume-task-btn`);u&&u.addEventListener(`click`,async e=>{if(e.stopPropagation(),u.disabled)return;let n=await AS({budgetEnded:xT(t)});n!==null&&(u.disabled=!0,u.style.opacity=`0.6`,u.style.cursor=`not-allowed`,FS(C.activeSessionId,n).finally(()=>{u.disabled=!1,u.style.opacity=``,u.style.cursor=``}))}),AT(t);let d=e.querySelector(`.token-usage-tag`);d&&!d._clickBound&&(d._clickBound=!0,d.style.cursor=`pointer`,d.addEventListener(`click`,e=>{e.stopPropagation();try{let e=t.dataset.executionLog,n=Le(e?JSON.parse(e):[]);n&&Xe(n,d)}catch{}}))}),e.querySelectorAll(`.message-toolbar`).forEach(e=>{let t=e.closest(`.message`);if(!t)return;let n=e.querySelector(`.edit-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),zT(t)});let r=e.querySelector(`.copy-btn`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),vS(t,r)});let i=e.querySelector(`.delete-btn`);i&&i.addEventListener(`click`,e=>{e.stopPropagation(),FT(t)})}),e.querySelectorAll(`.user-message-image`).forEach(e=>{e.addEventListener(`click`,()=>{am(e.src,e)})}),e.querySelectorAll(`.mermaid-controls`).forEach(e=>e.remove()),$e(),TT(),DT(),nk()}function NT(e){return new Promise(t=>{let n=document.querySelector(`.command-terminate-overlay`);n&&n.remove();let i=document.createElement(`div`);i.className=`command-terminate-overlay`,i.innerHTML=`
1888
1888
  <div class="command-terminate-modal">
1889
1889
  <div class="command-terminate-header">
1890
1890
  <div class="command-terminate-icon">⏹</div>
@@ -1,4 +1,4 @@
1
- import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./i18n-5c8prpFJ.js";import{$t as l,Nt as u,Tt as d,_ as f,a as p,c as m,d as h,g,h as _,i as v,in as y,m as b,n as x,o as S,p as ee,r as te,rn as ne,s as re,t as ie,tn as C,u as w,v as ae,wt as T,zt as E}from"./model-profiles-ClPgbQ-J.js";import{r as oe}from"./network-scope-0d6MoKgI.js";import{i as se,r as ce}from"./voice-shortcut-Dx863RGz.js";import{$ as le,Q as D,a as O,c as ue,d as de,et as fe,g as pe,i as me,l as he,o as ge,r as _e,s as ve,t as ye,tt as be,v as xe}from"./version-DLS0FCk4.js";e(`zh`,{optionsConst:{aiSearch:`AI搜索`,explain:`解释`,translate:`翻译`,summary:`总结`,copy:`复制`,defaultSystemPrompt:`AI Helper:IT技术助手。
1
+ import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./i18n-5c8prpFJ.js";import{$t as l,Nt as u,Tt as d,_ as f,a as p,c as m,d as h,g,h as _,i as v,in as y,m as b,n as x,o as S,p as ee,r as te,rn as ne,s as re,t as ie,tn as C,u as w,v as ae,wt as T,zt as E}from"./model-profiles-ClPgbQ-J.js";import{r as oe}from"./network-scope-0d6MoKgI.js";import{i as se,r as ce}from"./voice-shortcut-Dx863RGz.js";import{$ as le,Q as D,a as O,c as ue,d as de,et as fe,g as pe,i as me,l as he,o as ge,r as _e,s as ve,t as ye,tt as be,v as xe}from"./version-DigCzqtw.js";e(`zh`,{optionsConst:{aiSearch:`AI搜索`,explain:`解释`,translate:`翻译`,summary:`总结`,copy:`复制`,defaultSystemPrompt:`AI Helper:IT技术助手。
2
2
 
3
3
  ## 能力
4
4
  编程开发与调试(Java/Python/JavaScript/Go/C++)、架构优化、性能调优、代码审查、文档编写、浏览器工具调用
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/context-indicator-Sf2n8eWg.js","assets/chunk-CMxvf4Kt.js","assets/model-profiles-ClPgbQ-J.js","assets/i18n-5c8prpFJ.js","assets/voice-shortcut-Dx863RGz.js","assets/session-store-M5mPmMr3.js","assets/version-DLS0FCk4.js","assets/agent-store-CeC2_dkP.js","assets/workspace-manager-CL4JvHkJ.js"])))=>i.map(i=>d[i]);
2
- import{a as e,c as t,i as n,l as r,n as i,r as a,s as o}from"./i18n-5c8prpFJ.js";import{A as s,At as c,Bt as l,Ht as u,J as d,Jt as f,L as p,Lt as m,M as h,Nt as g,Ot as _,P as ee,R as v,U as te,b as y,c as b,ct as ne,d as x,gt as S,ht as C,i as w,it as T,jt as re,k as ie,q as E,r as ae,rt as oe,u as se,wt as ce,x as D,y as le,zt as ue}from"./model-profiles-ClPgbQ-J.js";import{_ as de,d as fe}from"./session-store-M5mPmMr3.js";import{A as pe,C as me,D as he,E as ge,M as _e,N as ve,O as ye,S as be,T as xe,_ as Se,a as Ce,b as we,c as Te,d as Ee,f as De,g as Oe,h as ke,i as Ae,j as je,k as Me,l as Ne,m as Pe,n as O,o as Fe,p as Ie,r as Le,s as Re,t as ze,u as Be,v as Ve,w as He,x as Ue,y as We}from"./todo-model--JIghLks.js";import{$ as Ge,A as Ke,D as qe,G as Je,H as Ye,J as Xe,K as Ze,M as k,N as Qe,O as $e,P as et,Q as tt,R as nt,T as rt,V as it,W as at,Y as A,Z as ot,_ as st,b as ct,et as lt,j,k as ut,l as dt,q as ft,t as pt,tt as mt,v as ht,y as gt}from"./version-DLS0FCk4.js";import{$ as _t,$n as vt,$r as yt,$t as bt,A as xt,An as St,Ar as Ct,At as wt,B as Tt,Bn as Et,Br as Dt,Bt as Ot,C as kt,Cn as At,Cr as jt,Ct as Mt,D as Nt,Dn as Pt,Dr as Ft,Dt as It,E as Lt,En as Rt,Er as zt,Et as Bt,F as Vt,Fn as Ht,Fr as Ut,Ft as Wt,G as Gt,Gn as Kt,Gr as qt,Gt as Jt,H as Yt,Hn as Xt,Hr as Zt,Ht as Qt,I as $t,In as en,Ir as tn,It as nn,J as rn,Jn as an,Jr as on,Jt as sn,K as cn,Kn as ln,Kr as un,Kt as dn,L as fn,Ln as pn,Lr as mn,Lt as hn,M as gn,Mn as _n,Mr as vn,Mt as yn,N as bn,Nn as xn,Nr as Sn,Nt as Cn,O as wn,On as Tn,Or as En,Ot as Dn,P as On,Pn as kn,Pr as An,Pt as jn,Q as Mn,Qn as Nn,Qr as Pn,Qt as Fn,R as In,Rn as Ln,Rr as Rn,Rt as zn,S as Bn,Sr as Vn,St as Hn,T as Un,Tn as Wn,Tr as Gn,Tt as Kn,Un as qn,Ur as Jn,Ut as Yn,V as Xn,Vn as Zn,Vr as Qn,Vt as $n,W as er,Wn as tr,Wr as nr,Wt as rr,X as ir,Xn as ar,Xr as or,Xt as sr,Y as cr,Yn as lr,Yr as ur,Yt as dr,Z as fr,Zn as pr,Zr as mr,Zt as hr,_ as gr,_n as _r,_r as vr,_t as yr,a as br,an as xr,ar as Sr,at as Cr,b as wr,bn as Tr,br as Er,bt as Dr,c as Or,cn as kr,ct as Ar,d as jr,dn as Mr,dr as Nr,dt as Pr,ei as Fr,en as Ir,er as Lr,et as Rr,f as zr,fn as Br,fr as Vr,ft as Hr,g as Ur,gn as Wr,gr as Gr,gt as Kr,h as qr,hn as Jr,hr as Yr,i as Xr,in as Zr,ir as Qr,it as $r,j as ei,jn as ti,jr as ni,jt as ri,k as ii,kn as ai,kt as oi,l as si,ln as ci,lr as li,lt as ui,m as di,mr as fi,mt as pi,n as mi,nn as hi,nr as gi,nt as _i,o as vi,on as yi,or as bi,ot as xi,p as Si,pn as Ci,pr as wi,pt as Ti,q as Ei,qn as Di,qr as Oi,qt as ki,r as Ai,rn as ji,rr as Mi,rt as Ni,s as Pi,sn as Fi,sr as Ii,st as Li,t as Ri,ti as zi,tn as Bi,tr as Vi,tt as Hi,u as Ui,un as Wi,ur as Gi,ut as Ki,v as qi,vn as Ji,vr as Yi,vt as Xi,w as Zi,wn as Qi,wr as $i,wt as ea,x as ta,xn as na,xr as ra,xt as ia,y as aa,yn as oa,yr as sa,yt as ca,z as la,zn as ua,zr as da,zt as fa}from"./context-indicator-Sf2n8eWg.js";import{o as pa}from"./agent-store-CeC2_dkP.js";import{O as ma,b as ha,l as ga,p as _a,v as va}from"./workspace-manager-CL4JvHkJ.js";var ya=`panel-observer-`,ba=new Map,xa=new Set;function Sa(e){typeof e==`function`&&xa.add(e)}function Ca(e){if(!e)return null;let t=ba.get(e);if(t)return t;let n;try{n=chrome.runtime.connect({name:`${ya}${e}`})}catch(e){return r.debug(`[PanelObserver] 建立观察端口失败(忽略):`,e?.message||e),null}ba.set(e,n);try{n.onMessage.addListener(e=>{for(let t of xa)try{t(e)}catch(e){r.debug(`[PanelObserver] 消息处理异常(忽略):`,e?.message||e)}})}catch(e){r.debug(`[PanelObserver] 观察端口消息监听挂不上(忽略):`,e?.message||e)}try{n.onDisconnect.addListener(()=>{ba.get(e)===n&&ba.delete(e)})}catch(e){r.debug(`[PanelObserver] 观察端口断开监听挂不上(忽略):`,e?.message||e)}return n}function wa(e){if(!e)return;let t=ba.get(e);if(t){ba.delete(e);try{t.disconnect()}catch(e){r.debug(`[PanelObserver] 关闭观察端口异常(忽略):`,e?.message||e)}}}function Ta({sessionId:e,callId:t,renderer:n,persist:i,onFinished:a=()=>{},emptyFallback:o=``,awaitSnapshot:s=!1}){let c=``,l=!1,u=s,d=[],f=n=>!!n&&n.sessionId===e&&n.callId===t,p=e=>{let t=[];for(let n of e){let e=t[t.length-1];n.type===`STREAM_CHUNK`&&e&&e.type===`STREAM_CHUNK`?t[t.length-1]={...n,delta:(e.delta||``)+(n.delta||``)}:t.push(n)}return t},m=()=>{u=!1;let e=p(d);d=[];for(let t of e)g(t)},h=e=>{l=!0,Promise.resolve().then(()=>i(e)).catch(e=>r.warn(`[ChatReattach] 终态落库失败(忽略):`,e?.message||e)).then(()=>{try{a()}catch{}})};return{sessionId:e,callId:t,get finished(){return l},dispose(){l=!0},restore(e){if(!u)return;u=!1;let r=!!e&&e.callId===t,i=r&&typeof e.accumulated==`string`?e.accumulated:``,a=r&&!!e.html;a&&n.restore?.({html:e.html}),c=i,i&&!a&&n.chunk?.(i);let o=p(d);d=[];for(let e of o)g(e)},handleMessage(e){return l||!f(e)?!1:u?e.type===`STREAM_CHUNK`?(d.push(e),!0):e.type===`API_COMPLETE`||e.type===`API_ERROR`?(m(),g(e)):(d.push(e),!0):g(e)}};function g(r){switch(r.type){case`STREAM_START`:return c=``,n.start?.(),!0;case`STREAM_CHUNK`:return c+=r.delta||``,n.chunk?.(c),!0;case`STREAM_TOOL_CALL`:return n.toolCalls?.(r.toolCalls||[],c),!0;case`STREAM_TOOL_RESULT`:return r.result&&n.toolResult?.(r.result),!0;case`AGENT_STREAM`:return r.execId&&n.agentStream?.(r),!0;case`AGENT_STREAM_DONE`:return r.execId&&n.agentStreamDone?.(r),!0;case`API_RETRYING`:return n.retrying?.(r.attempt,r.maxRetries),!0;case`STREAM_PRESELECT`:return n.preselect?.(r.preselectLog||[]),!0;case`EXECUTION_STATUS_UPDATE`:return!0;case`API_COMPLETE`:{let i=r.content&&String(r.content).trim()?r.content:o||c,a=r.executionLog||[],s={reflectionScore:r.reflectionScore,reasoningContent:r.reasoningContent||null,wasRevised:r.wasRevised||!1,budgetEnded:r.budgetEnded===!0};return n.final?.(i,a,s),h({sessionId:e,callId:t,content:i,executionLog:a,...s}),!0}case`API_ERROR`:return n.error?.(r.error||``,r.executionLog||[]),h({sessionId:e,callId:t,error:r.error||``,executionLog:r.executionLog||[]}),!0;default:return!1}}}function Ea({queryRunning:e,hasLocalListener:t,isAttached:n,attach:i}){return{async syncFromBackground(){try{let r=await e(),a=r&&r.activeCallIds?r.activeCallIds:{};for(let[e,r]of Object.entries(a))!e||!r||t(e)||n(e,r)||i(e,r)}catch(e){r.debug(`[ChatReattach] 查询后台运行状态失败(忽略):`,e?.message||e)}}}}var Da=!1,Oa=new Map,ka=null,Aa=!1,ja=null,Ma=null,Na=null,Pa=250,Fa=new Set([`STREAM_START`,`STREAM_CHUNK`,`STREAM_TOOL_CALL`,`STREAM_TOOL_RESULT`,`AGENT_STREAM`,`AGENT_STREAM_DONE`,`API_RETRYING`,`STREAM_PRESELECT`,`EXECUTION_STATUS_UPDATE`,`API_COMPLETE`,`API_ERROR`]);function Ia(e=0){return new Promise((t,n)=>{let r=!1,i=null,a=(e,t)=>{r||(r=!0,i&&clearTimeout(i),e(t))};e>0&&(i=setTimeout(()=>a(t,{}),e));try{chrome.runtime.sendMessage({type:`QUERY_SESSION_RUNNING`},e=>{if(chrome.runtime.lastError){a(n,Error(chrome.runtime.lastError.message));return}a(t,e||{})})}catch(e){a(n,e)}})}function La(e,t){let n=new Map;return{start(){Dn(e,``),It(``),oi(Date.now()),ui(t),Kn(t)},chunk(n){Dn(e,n),wt(t,n)},restore({html:e}){Hr(t,e)},toolCalls(e,n){typeof n==`string`&&n&&ea(t,n),Ki(t,e)},toolResult(e){Pr(e,t)},agentStream(e){Mt(t,n),Ti(n,t,e)},agentStreamDone(e){let t=n.get(e.execId);t&&t.element&&e.exitCode!==0&&t.element.classList.add(`agent-stream-error`)},retrying(e,n){Dr(t,e,n)},preselect(e){let n=t.querySelector(`.message-content`);!n||!e.length||e.forEach(e=>n.insertBefore(Kr(e),n.firstChild))},final(e,n,r={}){ca(t,e,n,r.reflectionScore,r.reasoningContent,r.wasRevised)},error(e,n){ca(t,e,n||[])}}}async function Ra(e,t,n){let r=!!e.error,i={role:`assistant`,content:r?e.error:e.content||``,executionLog:e.executionLog||[],reflectionScore:e.reflectionScore,wasRevised:e.wasRevised||!1,callId:e.callId,resumed:!0,resumable:e.budgetEnded?`budget`:!1};if(!r&&n&&(i.messageId=n.dataset.messageId||void 0,i.htmlContent=n.dataset.htmlContent||n.outerHTML),y.activeSessionId===t){y.messageHistory.push(i);try{document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:t}}))}catch{}}let{appendMessageToSession:a}=await D(async()=>{let{appendMessageToSession:e}=await import(`./context-indicator-Sf2n8eWg.js`).then(e=>e.kr);return{appendMessageToSession:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));await a(t,i)}function za(){D(()=>import(`./context-indicator-Sf2n8eWg.js`).then(e=>e.U).then(e=>e.syncPendingSessionsToStorage()),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).catch(e=>r.debug(`[ChatReattach] 同步生成态失败(忽略):`,e?.message||e))}var Ba=1e3;function Va(e){return Promise.race([ri(e),new Promise(e=>setTimeout(()=>e(null),Ba))])}function Ha(e,n){let i=yr(e);if(i())return!1;let a=Ar(e);a.dataset.callId=n,i(a),Dn(e,``),oi(Date.now()),Bt(Date.now()),y.pendingCallApiSessionIds.add(e),y.generatingSessionIds.add(e),za();try{document.dispatchEvent(new CustomEvent(`generating-state-changed`))}catch{}let o=Ta({sessionId:e,callId:n,awaitSnapshot:!0,renderer:La(e,a),persist:t=>Ra(t,e,a),emptyFallback:t(`chatMsg.emptyModelReply`),onFinished:()=>{if(Oa.get(e)===o){Oa.delete(e),wa(e),y.pendingCallApiSessionIds.delete(e),za(),Xi(e);try{document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:e}}))}catch{}Nn(e)}}});return Oa.set(e,o),Ca(e),Va(e).then(t=>{o.finished||Oa.get(e)!==o||o.restore(t)}).catch(()=>o.restore(null)),y.activeSessionId===e&&ia(e),r.info(`[ChatReattach] 已接管运行中的任务: sessionId=${e}, callId=${n}`),!0}function Ua(e){let t=Oa.get(e);if(!t)return;Oa.delete(e),wa(e);try{t.dispose?.()}catch{}let n=yr(e),r=n();try{r?.remove()}catch{}n(null),Xi(e),y.pendingCallApiSessionIds.delete(e),za();try{document.dispatchEvent(new CustomEvent(`generating-state-changed`))}catch{}}function Wa(){let e=ka;e&&Promise.resolve().then(()=>e.syncFromBackground()).catch(e=>r.debug(`[ChatReattach] 对齐后台状态失败(忽略):`,e?.message||e))}function Ga(){!Da||!ka||Na||(Na=setTimeout(()=>{Na=null,Wa()},Pa))}var Ka=new Map,qa=3e3,Ja=100,Ya=new Set,Xa=new Set([`API_COMPLETE`,`API_ERROR`]);function Za(e,t){let n=`${e}|${t.callId}`;Ya.has(n)||(Ya.add(n),Ya.size>Ja&&Ya.delete(Ya.values().next().value),Ua(e),Ha(e,t.callId)&&Oa.get(e)?.handleMessage(t))}function Qa(e,t,n){let r=Ka.get(e);if(r){r.messages.push(n);return}r={callId:t,messages:[n]},Ka.set(e,r),Ia(qa).then(t=>$a(e,t&&t.activeCallIds&&t.activeCallIds[e]||null)).catch(()=>$a(e,null)).finally(()=>{Ka.delete(e)})}function $a(e,t){let n=Ka.get(e);if(!n)return;let{callId:r,messages:i}=n;if(t===r)Ua(e),Ha(e,r);else if(t===null){let t=i.find(e=>Xa.has(e.type));if(!t)return;Za(e,t);return}else return;let a=Oa.get(e);if(!(!a||a.callId!==r))for(let e of i){if(a.finished)break;a.handleMessage(e)}}function eo(){if(Aa)return;Aa=!0;let e=e=>{if(!e)return!1;let t=e.sessionId?Oa.get(e.sessionId):null;return t?e.callId&&e.callId!==t.callId?(Qa(e.sessionId,e.callId,e),!1):(Ca(e.sessionId),t.handleMessage(e),!1):(e.callId&&Fa.has(e.type)&&Ga(),!1)};chrome.runtime.onMessage.addListener(e),Sa(e),ja=e=>{let t=e?.detail?.sessionId;t&&Oa.has(t)&&ia(t),Ga()},document.addEventListener(`session-hydrated`,ja),Ma=e=>{let t=e?.detail?.sessionId;t&&Oa.has(t)&&ia(t)},document.addEventListener(`chat-history-rendered`,Ma)}function to(){return Da?{syncFromBackground:()=>ka.syncFromBackground()}:(Da=!0,eo(),ka=Ea({queryRunning:Ia,hasLocalListener:e=>y.pendingCancelApiMap.has(e),isAttached:(e,t)=>Oa.get(e)?.callId===t?(Ca(e),!0):!1,attach:(e,t)=>{Ha(e,t)}}),ka.syncFromBackground(),{syncFromBackground:()=>ka.syncFromBackground()})}function no(e){!Da||!ka||(e&&y.activeSessionId===e&&ia(e),ka.syncFromBackground())}e(`zh`,{dock:{ariaLabel:`执行中会话`,running:`正在执行`,node:`正在执行:{node}`,subtask:`子任务 {index}/{total}`,queued:`排队 {count} 条`,done:`已完成,点击查看结果`,doneAt:`已完成 {time}`,scheduled:`定时任务`,dismiss:`从停靠条移除`,dismissStale:`移除失效条目`,stale:`状态可能已失效 · 未在限定时间内收到执行更新`,more:`还有 {count} 个`,moreAria:`还有 {count} 个未显示的执行条目`,overflowTitle:`其他执行中的会话`,openSession:`点击进入该会话`,unknownSession:`未知会话`}}),e(`en`,{dock:{ariaLabel:`Running sessions`,running:`Running`,node:`Running: {node}`,subtask:`Subtask {index}/{total}`,queued:`{count} queued`,done:`Finished — click to review`,doneAt:`Finished {time}`,scheduled:`Scheduled task`,dismiss:`Remove from dock`,dismissStale:`Remove stale entry`,stale:`Status may be stale · no execution update in time`,more:`+{count} more`,moreAria:`{count} more running entries not shown`,overflowTitle:`Other active sessions`,openSession:`Click to open this session`,unknownSession:`Unknown session`}});var ro=`sessionDockDismissed`,io=5e3,ao=250,oo=1200,so=8,co=so-1,lo=9e4,uo={running:0,queued:1,done:2},fo=new Map,po=new Map,mo=new Map,ho=new Map,go=new Set,_o=new Set,vo=new Map,yo=new Map,bo=new Set,xo=new Set,So=new Set,Co=[],wo=new Set,M=null,N=null,P=null,To=[],Eo=!1,Do=null,Oo=null,ko=!1,Ao=null,jo=null;function Mo(e){return e?Array.isArray(e)?e:e instanceof Set?Array.from(e):[]:[]}function No(e){let t=new Set;for(let n of Mo(e))n&&t.add(h(String(n))||String(n));return t}function Po({phase:e=``,sessionId:t=null,backendRunningIds:n=[],startedAt:r=0,lastUpdateAt:i=0,now:a=Date.now(),staleMs:o=lo}={}){if(e!==`running`||!t||Mo(n).includes(t))return!1;let s=Math.max(Number(r)||0,Number(i)||0);return s?a-s>=o:!1}var Fo=160;function Io(e){let t=String(e??``).replace(/\s+/g,` `).trim();if(!t)return``;let n=Array.from(t);return n.length<=Fo?t:`${n.slice(0,Fo).join(``).trimEnd()}…`}function Lo(e,t){let n=e=>String(e??``).trim().replace(/[…\s.]+$/,``).replace(/\s+/g,``),r=n(e),i=n(t);return!r||!i?!1:r===i||i.startsWith(r)||r.startsWith(i)}function Ro({phase:e=``,queuedText:t=``,questionText:n=``,title:r=``}={}){let i=e===`queued`?Io(t):``,a=i||Io(n),o=Io(r),s=a||o,c=i?`queued`:a?`question`:s?`title`:``;return{primary:s,sub:a&&!Lo(o,a)?o:``,isQuestion:!!a,from:c}}function zo(e){let t=Array.isArray(e?.messageHistory)?e.messageHistory:[];for(let e=t.length-1;e>=0;--e){let n=t[e];if(!n||n.role!==`user`)continue;let r=re(n.content);if(r&&String(r).trim())return{text:String(r),messageId:n.messageId?String(n.messageId):``}}return{text:``,messageId:``}}function Bo({activeSessionId:e=null,titles:t={},questions:n={},anchors:r={},queuedTexts:i={},generatingIds:a=[],pendingIds:o=[],runningIds:s=[],completedIds:c=[],queuedCounts:l={},scheduledIds:u=[],dismissedIds:d=[],nodeInfo:f={},startedAt:p={},doneAt:m={},lastUpdateAt:h={},now:g=Date.now(),staleMs:_=lo}={}){let ee=Mo(s),v=new Set([...Mo(a),...Mo(o),...ee]),te=new Set(Mo(c)),y=new Set(Mo(d)),b=new Set(Mo(u)),ne=l||{},x=new Set([...v,...te,...Object.keys(ne)]),S=[];for(let a of x){if(!a||a===e)continue;let o=Number(ne[a])||0,s;if(v.has(a))s=`running`;else if(o>0)s=`queued`;else if(te.has(a))s=`done`;else continue;let c=Po({phase:s,sessionId:a,backendRunningIds:ee,startedAt:p?.[a],lastUpdateAt:h?.[a],now:g,staleMs:_});if(y.has(a)&&(s===`done`||c))continue;let l=f?.[a]||{},u=Ro({phase:s,queuedText:i?.[a]||``,questionText:n?.[a]||``,title:t?.[a]||``});S.push({sessionId:a,title:t?.[a]||``,primary:u.primary,sub:u.sub,isQuestion:u.isQuestion,anchorMessageId:u.from===`question`?String(r?.[a]||``):``,phase:s,stale:c,source:b.has(a)?`scheduled`:`chat`,queuedCount:o,nodeName:l.nodeName||``,subtaskIndex:l.subtaskIndex||0,subtaskTotal:l.subtaskTotal||0,startedAt:p?.[a]||0,doneAt:m?.[a]||0,lastUpdateAt:h?.[a]||0})}return S.sort((e,t)=>{let n=uo[e.phase]-uo[t.phase];if(n!==0)return n;if(e.stale!==t.stale)return e.stale?1:-1;let r=e.phase===`done`?e.doneAt:e.startedAt,i=t.phase===`done`?t.doneAt:t.startedAt;return r===i?String(e.sessionId).localeCompare(String(t.sessionId)):i-r}),S}function Vo(e){return So.has(e)||y.generatingSessionIds.has(e)||y.pendingCallApiSessionIds.has(e)}function Ho(){let e={};try{let t=Rn();for(let n of t){let t=Ut(n);t>0&&(e[n]=t)}}catch(e){r.debug(`[SessionDock] read queue counts failed:`,e?.message||e)}return e}function Uo(){let e={};for(let t of y.sessions||[])e[t.id]=t.title||``;for(let[t,n]of vo)e[t]||(e[t]=n);return e}function Wo(){let e={},t={},n=new Map;for(let e of y.sessions||[])n.set(e.id,e);for(let r of new Set([...So,...y.generatingSessionIds,...y.pendingCallApiSessionIds,...y.completedSessionIds])){let i=po.get(r)||mo.get(r)||0,a=yo.get(r);if(i&&a&&a.stamp===i){a.text&&(e[r]=a.text,t[r]=a.messageId||``);continue}let o=zo(n.get(r));o.text&&(e[r]=o.text,t[r]=o.messageId)}return{questions:e,anchors:t}}function Go(){let e={};try{for(let t of Rn()){let n=da(t);n?.text&&(e[t]=String(n.text))}}catch(e){r.debug(`[SessionDock] read queued texts failed:`,e?.message||e)}return e}function Ko(e){for(let t of e||[]){let e=t.sessionId;if(!e)continue;let n=t.startedAt||t.doneAt||0,i=yo.get(e),a=!i||i.stamp!==n,o=!t.title;!a&&!o||xo.has(e)||(xo.add(e),ne(e).then(t=>{if(t&&((o||!vo.has(e))&&vo.set(e,t.title||``),a)){let r=zo(t);yo.set(e,{text:r.text,messageId:r.messageId,stamp:n})}}).catch(e=>{r.debug(`[SessionDock] hydrate label failed:`,e?.message||e)}).finally(()=>{xo.delete(e),F()}))}}function qo(e){if(!e)return``;let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function Jo(e){if(e.phase===`running`){if(e.stale)return t(`dock.stale`);let n=e.nodeName?t(`dock.node`,{node:e.nodeName}):t(`dock.running`);return e.subtaskTotal>1?`${n} · ${t(`dock.subtask`,{index:e.subtaskIndex,total:e.subtaskTotal})}`:n}return e.phase===`queued`?t(`dock.queued`,{count:e.queuedCount}):e.doneAt?t(`dock.doneAt`,{time:qo(e.doneAt)}):t(`dock.done`)}function Yo(e){po.set(e,Date.now()),mo.delete(e),yo.delete(e)}function Xo(){let e=new Set([...y.generatingSessionIds,...y.pendingCallApiSessionIds]);for(let t of e)bo.has(t)&&(bo.delete(t),Yo(t));F()}function Zo(){let e=y.completedSessionIds;for(let e of new Set([...So,...y.generatingSessionIds,...y.pendingCallApiSessionIds]))po.has(e)||po.set(e,Date.now()),mo.delete(e);for(let e of So)_o.delete(e);for(let t of e)!mo.has(t)&&!Vo(t)&&mo.set(t,Date.now());let{questions:t,anchors:n}=Wo(),r=Bo({activeSessionId:y.activeSessionId,titles:Uo(),questions:t,anchors:n,queuedTexts:Go(),generatingIds:y.generatingSessionIds,pendingIds:y.pendingCallApiSessionIds,runningIds:So,completedIds:e,queuedCounts:Ho(),scheduledIds:go,dismissedIds:_o,nodeInfo:Object.fromEntries(fo),startedAt:Object.fromEntries(po),doneAt:Object.fromEntries(mo),lastUpdateAt:Object.fromEntries(ho),now:Date.now()});return Ko(r),r}function Qo(e){let t=new Set(Co.filter(e=>e.phase===`done`).map(e=>e.sessionId)),n=e.filter(e=>e.phase===`done`&&!t.has(e.sessionId)).map(e=>e.sessionId);n.length!==0&&(wo=new Set(n),Ao&&clearTimeout(Ao),Ao=setTimeout(()=>{Ao=null,wo=new Set,F()},oo))}function $o(){if(M||typeof document>`u`)return M;M=document.createElement(`div`),M.className=`session-dock`,M.id=`sessionDock`,M.setAttribute(`role`,`navigation`),document.body.appendChild(M),N=document.createElement(`div`),N.className=`session-dock-tip`,document.body.appendChild(N),es();let e=document.getElementById(`chatContainer`);return e&&typeof ResizeObserver<`u`&&new ResizeObserver(es).observe(e),window.addEventListener(`resize`,es),M}function es(){if(!M)return;let e=document.getElementById(`chatContainer`);if(!e)return;let t=e.getBoundingClientRect();M.style.top=`${Math.max(0,Math.round(t.top+8))}px`}function ts(e){bi(e.sessionId,{focusMessageId:e.anchorMessageId||null})}function ns(e){let n=document.createElement(`div`);n.className=`session-dock-item`,n.dataset.sessionId=e.sessionId,n.dataset.phase=e.phase,e.stale&&(n.dataset.stale=`true`),wo.has(e.sessionId)&&n.classList.add(`is-flash`);let r=e.title||t(`dock.unknownSession`),i=e.primary||r,a=Jo(e),o=e.phase===`done`?`✓`:Array.from(r)[0]||`?`,s=document.createElement(`button`);if(s.type=`button`,s.className=`session-dock-chip`,s.setAttribute(`aria-label`,`${i} · ${a}`),s.title=``,s.textContent=o,s.addEventListener(`click`,()=>{ts(e)}),n.appendChild(s),e.queuedCount>0&&e.phase!==`done`){let t=document.createElement(`span`);t.className=`session-dock-badge`,t.textContent=String(e.queuedCount>99?`99+`:e.queuedCount),n.appendChild(t)}if(e.source===`scheduled`){let e=document.createElement(`span`);e.className=`session-dock-clock`,n.appendChild(e)}if(e.phase===`done`||e.stale){let r=document.createElement(`button`);r.type=`button`,r.className=`session-dock-dismiss`;let i=e.stale?t(`dock.dismissStale`):t(`dock.dismiss`);r.setAttribute(`aria-label`,i),r.title=i,r.textContent=`×`,r.addEventListener(`click`,t=>{t.stopPropagation(),hs(e.sessionId)}),n.appendChild(r)}return n.addEventListener(`mouseenter`,()=>rs(n,e,a)),n.addEventListener(`mouseleave`,is),n.addEventListener(`focusin`,()=>rs(n,e,a)),n.addEventListener(`focusout`,is),n}function rs(e,n,r){if(!N)return;N.innerHTML=``;let i=document.createElement(`div`);i.className=`session-dock-tip-title`,i.textContent=n.primary||n.title||t(`dock.unknownSession`);let a=document.createElement(`div`);if(a.className=`session-dock-tip-status`,a.textContent=r,N.appendChild(i),n.sub){let e=document.createElement(`div`);e.className=`session-dock-tip-sub`,e.textContent=n.sub,N.appendChild(e)}N.appendChild(a);let o=e.getBoundingClientRect();N.style.top=`${Math.round(o.top)}px`,N.style.left=`${Math.round(o.right+8)}px`,N.classList.add(`show`)}function is(){N&&N.classList.remove(`show`)}function as(){return P||typeof document>`u`?P:(P=document.createElement(`div`),P.className=`session-dock-overflow`,P.setAttribute(`role`,`menu`),P.addEventListener(`mouseenter`,os),P.addEventListener(`mouseleave`,ss),P.addEventListener(`focusin`,os),P.addEventListener(`focusout`,ss),document.body.appendChild(P),P)}function os(){jo&&=(clearTimeout(jo),null)}function ss(){Eo||(os(),jo=setTimeout(()=>{jo=null,fs()},220))}function cs(){let e=M?M.querySelector(`.session-dock-more`):null;e&&(e.setAttribute(`aria-expanded`,Eo?`true`:`false`),e.classList.toggle(`is-open`,Eo))}function ls(){let e=as();if(!e)return;e.innerHTML=``;let n=document.createElement(`div`);n.className=`session-dock-overflow-header`,n.textContent=t(`dock.overflowTitle`),e.appendChild(n);let r=document.createElement(`div`);r.className=`session-dock-overflow-list`;for(let e of To){let n=e.primary||e.title||t(`dock.unknownSession`),i=Jo(e),a=document.createElement(`button`);a.type=`button`,a.className=`session-dock-overflow-row`,a.dataset.phase=e.phase,e.stale&&(a.dataset.stale=`true`),a.setAttribute(`aria-label`,`${n} · ${i}`);let o=document.createElement(`span`);o.className=`session-dock-overflow-title`,o.textContent=n;let s=document.createElement(`span`);s.className=`session-dock-overflow-status`,s.textContent=i,a.appendChild(o),a.appendChild(s),a.addEventListener(`click`,()=>{fs(),ts(e)}),r.appendChild(a)}e.appendChild(r)}function us(){if(!P||!M)return;let e=M.querySelector(`.session-dock-item--more`);if(!e)return;let t=e.getBoundingClientRect();P.style.left=`${Math.round(t.right+8)}px`;let n=P.offsetHeight||0,r=Math.max(8,window.innerHeight-n-8);P.style.top=`${Math.round(Math.min(Math.max(8,t.top),r))}px`}function ds(){To.length!==0&&as()&&(os(),ls(),us(),P.classList.add(`show`),cs())}function fs(){os(),Eo=!1,P&&P.classList.remove(`show`),cs()}function ps(){if(P&&P.classList.contains(`show`)&&Eo){fs();return}ds(),Eo=!0,cs()}function ms(e){let n=document.createElement(`div`);n.className=`session-dock-item session-dock-item--more`,n.dataset.count=String(e.length);let r=document.createElement(`button`);return r.type=`button`,r.className=`session-dock-chip session-dock-more`,r.setAttribute(`aria-label`,t(`dock.moreAria`,{count:e.length})),r.setAttribute(`aria-expanded`,Eo?`true`:`false`),r.textContent=`+${e.length>99?`99`:e.length}`,r.addEventListener(`click`,()=>ps()),n.appendChild(r),n.addEventListener(`mouseenter`,()=>ds()),n.addEventListener(`mouseleave`,ss),n.addEventListener(`focusin`,()=>ds()),n.addEventListener(`focusout`,ss),n}function hs(e){e&&(_o.add(e),gs(),F())}function gs(){try{chrome.storage.local.set({[ro]:Array.from(_o)}).catch(()=>{})}catch{}}function _s(){try{chrome.storage.local.get([ro],e=>{let t=e?.[ro];if(Array.isArray(t)){for(let e of t)_o.add(e);F()}})}catch{}}function vs(){if(!$o())return;let e=Zo();if(Qo(e),Co=e,fs(),To=[],M.innerHTML=``,e.length===0){M.classList.remove(`show`),document.body.classList.remove(`has-session-dock`),is();return}let t=e.length>so?co:so;To=e.slice(t);for(let n of e.slice(0,t))M.appendChild(ns(n));To.length>0&&M.appendChild(ms(To)),M.classList.add(`show`),document.body.classList.add(`has-session-dock`)}function F(){Do||=setTimeout(()=>{Do=null;try{vs()}catch(e){r.warn(`[SessionDock] render failed:`,e?.message||e)}},ao)}function ys(){return new Promise(e=>{try{chrome.runtime.sendMessage({type:`QUERY_SESSION_RUNNING`},t=>{if(chrome.runtime.lastError||!t){e();return}if(Array.isArray(t.activeSessionIds)){let e=No(t.activeSessionIds);for(let t of e){if(bo.has(t)){bo.delete(t),Yo(t);continue}So.has(t)||y.generatingSessionIds.has(t)||y.pendingCallApiSessionIds.has(t)||Yo(t)}So=e}e()})}catch{e()}})}function bs(e){let t=e?.sessionId;if(!t)return;let n=fo.get(t)||{};fo.set(t,{nodeName:e.nodeName||n.nodeName||``,subtaskIndex:e.subtaskIndex||n.subtaskIndex||0,subtaskTotal:e.subtaskTotal||n.subtaskTotal||0}),ho.set(t,Date.now()),F()}function xs(e){e&&(fo.delete(e),po.delete(e),mo.delete(e),ho.delete(e),_o.delete(e),vo.delete(e),yo.delete(e),bo.delete(e),F())}function Ss(){if(!(ko||typeof document>`u`||!$o())){ko=!0,_s(),document.addEventListener(`generating-state-changed`,Xo),document.addEventListener(`session-switched`,F),document.addEventListener(`generation-ended`,e=>{let t=e?.detail?.sessionId;t&&(bo.add(t),mo.has(t)||mo.set(t,Date.now())),F()}),document.addEventListener(`session-archived`,e=>xs(e?.detail?.sessionId)),document.addEventListener(`session-deleted`,e=>xs(e?.detail?.sessionId));try{qt(F)}catch(e){r.debug(`[SessionDock] subscribe queue failed:`,e?.message||e)}try{chrome.runtime.onMessage.addListener(e=>e?e.type===`EXECUTION_STATUS_UPDATE`?(bs(e),!1):e.type===`SCHEDULED_TASK_RUN_STATE`&&e.sessionId?(e.running?go.add(e.sessionId):go.delete(e.sessionId),F(),!1):(e.type===`SCHEDULED_SESSION_UPDATED`&&F(),!1):!1)}catch(e){r.debug(`[SessionDock] register runtime listener failed:`,e?.message||e)}document.addEventListener(`visibilitychange`,()=>{if(document.hidden){fs();return}ys().then(F)}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&Eo&&fs()}),Oo||=setInterval(()=>{document.hidden||ys().then(F)},io),ys().then(()=>{for(let e of So)po.has(e)||po.set(e,Date.now());vs()})}}function Cs(){let e=document.getElementById(`chatNavUp`),n=document.getElementById(`chatNavDown`),r=document.getElementById(`chatNavHotzone`),i=document.getElementById(`chatNavButtons`),a=document.getElementById(`chatNavQuestionPanel`),o=[],s=!1,c=null,l=``,u=!1,d=!1;function f(e){let t=document.getElementById(`chatContainer`);if(!t)return-1;let n=t.getBoundingClientRect();return et(e,n.top,n.bottom)}function p(e,t){let n=document.getElementById(`chatContainer`);if(!n)return`noop`;let r=qe(n);if(r.length===0)return`noop`;let i=n.getBoundingClientRect().top;if(t){if(e===`prev`)r[0].start.scrollIntoView({behavior:`smooth`,block:`start`});else{let e=r[r.length-1].elements;e[e.length-1].scrollIntoView({behavior:`smooth`,block:`end`})}return`jumped`}let a=Xe(r.length,Qe(r,i),e);return a===null?(m(e),`blocked`):(r[a].start.scrollIntoView({behavior:`smooth`,block:`start`}),`jumped`)}function m(t){let r=t===`prev`?e:n;r&&(r.classList.remove(`blocked`),r.offsetWidth,r.classList.add(`blocked`),r.addEventListener(`animationend`,()=>r.classList.remove(`blocked`),{once:!0}))}function h(e,n){let r=a.querySelectorAll(`.chat-nav-question-item`);r.forEach(t=>{Number(t.dataset.groupIndex)===e?(t.classList.add(`current`),t.setAttribute(`aria-current`,`true`)):(t.classList.remove(`current`),t.setAttribute(`aria-current`,`false`))});let i=a.querySelector(`.chat-nav-question-header .count`);i&&(i.textContent=t(`chat.navPosition`,{current:e>=0?e+1:n,total:n}));let o=Array.from(r).find(t=>Number(t.dataset.groupIndex)===e);!d&&e>=0&&o&&o.scrollIntoView({block:`nearest`})}function g(){if(!a||!a.classList.contains(`expanded`))return;o=qe(document.getElementById(`chatContainer`));let e=l?qe(document.getElementById(`chatContainer`)).length:a.querySelectorAll(`.chat-nav-question-item`).length;if(o.length===0){a.innerHTML=``,a.classList.remove(`expanded`);return}if(!l&&e!==o.length){_();return}h(f(o),o.length)}function _(){if(!a)return!1;if(o=qe(document.getElementById(`chatContainer`)),o.length===0)return a.innerHTML=``,!1;let e=f(o),t=document.activeElement===a.querySelector(`[data-role="nav-search"]`);a.innerHTML=ft(o,e,s,l),a.querySelector(`.chat-nav-pin`).addEventListener(`click`,e=>{e.stopPropagation(),x()});let n=a.querySelector(`[data-role="nav-search"]`);if(n){let e=()=>{l!==n.value&&(l=n.value,_())};n.addEventListener(`input`,t=>{t.isComposing||e()}),n.addEventListener(`compositionend`,e),t&&(n.focus(),n.setSelectionRange(n.value.length,n.value.length))}if(e>=0){let t=a.querySelector(`.chat-nav-question-item[data-group-index="${e}"]`);t&&t.scrollIntoView({block:`nearest`})}return!0}function ee(){let e=document.activeElement;return e?[r,i,a].some(t=>t&&(t===e||t.contains(e))):!1}function v(){i.classList.remove(`expanded`),a&&a.classList.remove(`expanded`)}function te(){let e=ee();v(),e&&r&&(u=!0,r.focus({preventScroll:!0}),u=!1)}function y(){if(clearTimeout(c),i.classList.add(`expanded`),a){if(a.classList.contains(`expanded`)){g();return}_()?a.classList.add(`expanded`):a.classList.remove(`expanded`)}}function b(e){clearTimeout(c),!s&&(ee()||(e?v():c=setTimeout(v,300)))}function ne(e){if(s=e,r&&(r.classList.toggle(`pinned`,e),r.setAttribute(`aria-pressed`,String(e))),a){a.classList.toggle(`pinned`,e);let n=a.querySelector(`.chat-nav-pin`);if(n){let r=t(e?`chat.navUnpinLabel`:`chat.navPinLabel`);n.textContent=r,n.title=r,n.setAttribute(`aria-pressed`,String(e)),n.classList.toggle(`on`,e)}}}function x(){ne(!s)}e&&e.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),p(`prev`,e.ctrlKey||e.metaKey),g()}),n&&n.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),p(`next`,e.ctrlKey||e.metaKey),g()}),r&&i&&(r.addEventListener(`mouseenter`,y),r.addEventListener(`mouseleave`,()=>b(!1)),r.addEventListener(`click`,()=>x()),r.addEventListener(`focus`,()=>{u||y()}),r.addEventListener(`blur`,()=>b(!1)),r.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),x())}),i.addEventListener(`mouseenter`,y),i.addEventListener(`mouseleave`,()=>b(!1)),i.addEventListener(`focusin`,y),a&&(a.addEventListener(`mouseenter`,()=>{d=!0,y()}),a.addEventListener(`mouseleave`,()=>{d=!1,b(!1)}),a.addEventListener(`focusin`,y),a.addEventListener(`keydown`,e=>{if(e.target.matches(`[data-role="nav-search"]`))return;let t=Array.from(a.querySelectorAll(`.chat-nav-question-item`));if(t.length===0)return;let n=t.indexOf(document.activeElement),r=null;e.key===`ArrowDown`?r=Math.min(n+1,t.length-1):e.key===`ArrowUp`?r=n<=0?0:n-1:e.key===`Home`?r=0:e.key===`End`&&(r=t.length-1),r!==null&&(e.preventDefault(),t[r].focus())}),a.addEventListener(`click`,e=>{let t=e.target.closest(`.chat-nav-question-item`);if(!t||!t.dataset.messageId)return;let n=o.find(e=>(e.userElement||e.start).dataset.messageId===t.dataset.messageId);if(!n)return;let r=n.userElement||n.start;r.scrollIntoView({behavior:`instant`,block:`start`}),r.classList.add(`bookmark-highlight`),setTimeout(()=>r.classList.remove(`bookmark-highlight`),2e3),s?g():te()})));{let e=document.getElementById(`chatContainer`);if(e){let t=!1;e.addEventListener(`scroll`,()=>{!a||!a.classList.contains(`expanded`)||t||(t=!0,requestAnimationFrame(()=>{t=!1,g()}))},{passive:!0})}}function S(){let e=a&&a.classList.contains(`expanded`);if(!s&&!e)return!1;if(a&&a.querySelector(`[data-role="nav-search"]`)&&l){l=``,_();let e=a.querySelector(`[data-role="nav-search"]`);return e&&e.focus(),!0}return ne(!1),te(),!0}return{jumpToMessage:p,updateActiveQuestion:g,handleEscape:S,isPinned:()=>s}}function ws(e){if(!e)return!1;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;return!!(t&&t.closest&&t.closest(`#chatContainer, .message-fullscreen-body`))}e(`zh`,{searchPanel:{toggleTitle:`消息搜索`,title:`消息搜索`,closeTitle:`关闭`,inputPlaceholder:`搜索消息(支持 & | 组合搜索)...`,clearTitle:`清除`,globalSearchTitle:`在所有会话中搜索`,globalSearch:`全局搜索`,currentSessionTitle:`仅在当前会话中搜索`,currentSession:`当前会话`,startSearchHint:`输入关键词开始搜索`,searching:`搜索中...`,searchingWithCount:`搜索中... {count} 条`,searchError:`搜索出错`,noActiveSession:`没有活跃会话`,noSessionData:`没有会话数据`,noMatch:`未找到匹配消息`,unknownSession:`未知会话`,countResult:`{count} 条`,noResult:`无结果`,searchingSuffix:` (搜索中...)`,currentSessionResults:`当前会话{label} · {count} 条`,otherSessionsResults:`其他会话 · {count} 条`,roleUser:`你`,roleAssistant:`助手`,sessionNotExist:`会话已不存在`,messageDeleted:`消息已被删除`}}),e(`en`,{searchPanel:{toggleTitle:`Search messages`,title:`Message search`,closeTitle:`Close`,inputPlaceholder:`Search messages (supports & | combined search)...`,clearTitle:`Clear`,globalSearchTitle:`Search in all sessions`,globalSearch:`Global search`,currentSessionTitle:`Search in current session only`,currentSession:`Current session`,startSearchHint:`Enter keywords to start searching`,searching:`Searching...`,searchingWithCount:`Searching... {count} found`,searchError:`Search error`,noActiveSession:`No active session`,noSessionData:`No session data`,noMatch:`No matching messages found`,unknownSession:`Unknown session`,countResult:`{count} found`,noResult:`No results`,searchingSuffix:` (searching...)`,currentSessionResults:`Current session{label} · {count} found`,otherSessionsResults:`Other sessions · {count} found`,roleUser:`You`,roleAssistant:`Assistant`,sessionNotExist:`Session no longer exists`,messageDeleted:`Message has been deleted`}});var Ts=!1,Es=!1,I=[],Ds=``;function Os(){y.searchInputHistory=[],y.searchInputHistoryIndex=-1;try{chrome.storage.local.get([`searchInputHistory`],e=>{e.searchInputHistory&&(y.searchInputHistory=e.searchInputHistory)})}catch{}let e=document.createElement(`div`);e.className=`search-panel-container`,e.id=`searchPanelContainer`,e.innerHTML=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/context-indicator-DjOAo_Ln.js","assets/chunk-CMxvf4Kt.js","assets/model-profiles-ClPgbQ-J.js","assets/i18n-5c8prpFJ.js","assets/voice-shortcut-Dx863RGz.js","assets/session-store-M5mPmMr3.js","assets/version-DigCzqtw.js","assets/agent-store-CeC2_dkP.js","assets/workspace-manager-CL4JvHkJ.js"])))=>i.map(i=>d[i]);
2
+ import{a as e,c as t,i as n,l as r,n as i,r as a,s as o}from"./i18n-5c8prpFJ.js";import{A as s,At as c,Bt as l,Ht as u,J as d,Jt as f,L as p,Lt as m,M as h,Nt as g,Ot as _,P as ee,R as v,U as te,b as y,c as b,ct as ne,d as x,gt as S,ht as C,i as w,it as T,jt as re,k as ie,q as E,r as ae,rt as oe,u as se,wt as ce,x as D,y as le,zt as ue}from"./model-profiles-ClPgbQ-J.js";import{_ as de,d as fe}from"./session-store-M5mPmMr3.js";import{A as pe,C as me,D as he,E as ge,M as _e,N as ve,O as ye,S as be,T as xe,_ as Se,a as Ce,b as we,c as Te,d as Ee,f as De,g as Oe,h as ke,i as Ae,j as je,k as Me,l as Ne,m as Pe,n as O,o as Fe,p as Ie,r as Le,s as Re,t as ze,u as Be,v as Ve,w as He,x as Ue,y as We}from"./todo-model--JIghLks.js";import{$ as Ge,A as Ke,D as qe,G as Je,H as Ye,J as Xe,K as Ze,M as k,N as Qe,O as $e,P as et,Q as tt,R as nt,T as rt,V as it,W as at,Y as A,Z as ot,_ as st,b as ct,et as lt,j,k as ut,l as dt,q as ft,t as pt,tt as mt,v as ht,y as gt}from"./version-DigCzqtw.js";import{$ as _t,$n as vt,$r as yt,$t as bt,A as xt,An as St,Ar as Ct,At as wt,B as Tt,Bn as Et,Br as Dt,Bt as Ot,C as kt,Cn as At,Cr as jt,Ct as Mt,D as Nt,Dn as Pt,Dr as Ft,Dt as It,E as Lt,En as Rt,Er as zt,Et as Bt,F as Vt,Fn as Ht,Fr as Ut,Ft as Wt,G as Gt,Gn as Kt,Gr as qt,Gt as Jt,H as Yt,Hn as Xt,Hr as Zt,Ht as Qt,I as $t,In as en,Ir as tn,It as nn,J as rn,Jn as an,Jr as on,Jt as sn,K as cn,Kn as ln,Kr as un,Kt as dn,L as fn,Ln as pn,Lr as mn,Lt as hn,M as gn,Mn as _n,Mr as vn,Mt as yn,N as bn,Nn as xn,Nr as Sn,Nt as Cn,O as wn,On as Tn,Or as En,Ot as Dn,P as On,Pn as kn,Pr as An,Pt as jn,Q as Mn,Qn as Nn,Qr as Pn,Qt as Fn,R as In,Rn as Ln,Rr as Rn,Rt as zn,S as Bn,Sr as Vn,St as Hn,T as Un,Tn as Wn,Tr as Gn,Tt as Kn,Un as qn,Ur as Jn,Ut as Yn,V as Xn,Vn as Zn,Vr as Qn,Vt as $n,W as er,Wn as tr,Wr as nr,Wt as rr,X as ir,Xn as ar,Xr as or,Xt as sr,Y as cr,Yn as lr,Yr as ur,Yt as dr,Z as fr,Zn as pr,Zr as mr,Zt as hr,_ as gr,_n as _r,_r as vr,_t as yr,a as br,an as xr,ar as Sr,at as Cr,b as wr,bn as Tr,br as Er,bt as Dr,c as Or,cn as kr,ct as Ar,d as jr,dn as Mr,dr as Nr,dt as Pr,ei as Fr,en as Ir,er as Lr,et as Rr,f as zr,fn as Br,fr as Vr,ft as Hr,g as Ur,gn as Wr,gr as Gr,gt as Kr,h as qr,hn as Jr,hr as Yr,i as Xr,in as Zr,ir as Qr,it as $r,j as ei,jn as ti,jr as ni,jt as ri,k as ii,kn as ai,kt as oi,l as si,ln as ci,lr as li,lt as ui,m as di,mr as fi,mt as pi,n as mi,nn as hi,nr as gi,nt as _i,o as vi,on as yi,or as bi,ot as xi,p as Si,pn as Ci,pr as wi,pt as Ti,q as Ei,qn as Di,qr as Oi,qt as ki,r as Ai,rn as ji,rr as Mi,rt as Ni,s as Pi,sn as Fi,sr as Ii,st as Li,t as Ri,ti as zi,tn as Bi,tr as Vi,tt as Hi,u as Ui,un as Wi,ur as Gi,ut as Ki,v as qi,vn as Ji,vr as Yi,vt as Xi,w as Zi,wn as Qi,wr as $i,wt as ea,x as ta,xn as na,xr as ra,xt as ia,y as aa,yn as oa,yr as sa,yt as ca,z as la,zn as ua,zr as da,zt as fa}from"./context-indicator-DjOAo_Ln.js";import{o as pa}from"./agent-store-CeC2_dkP.js";import{O as ma,b as ha,l as ga,p as _a,v as va}from"./workspace-manager-CL4JvHkJ.js";var ya=`panel-observer-`,ba=new Map,xa=new Set;function Sa(e){typeof e==`function`&&xa.add(e)}function Ca(e){if(!e)return null;let t=ba.get(e);if(t)return t;let n;try{n=chrome.runtime.connect({name:`${ya}${e}`})}catch(e){return r.debug(`[PanelObserver] 建立观察端口失败(忽略):`,e?.message||e),null}ba.set(e,n);try{n.onMessage.addListener(e=>{for(let t of xa)try{t(e)}catch(e){r.debug(`[PanelObserver] 消息处理异常(忽略):`,e?.message||e)}})}catch(e){r.debug(`[PanelObserver] 观察端口消息监听挂不上(忽略):`,e?.message||e)}try{n.onDisconnect.addListener(()=>{ba.get(e)===n&&ba.delete(e)})}catch(e){r.debug(`[PanelObserver] 观察端口断开监听挂不上(忽略):`,e?.message||e)}return n}function wa(e){if(!e)return;let t=ba.get(e);if(t){ba.delete(e);try{t.disconnect()}catch(e){r.debug(`[PanelObserver] 关闭观察端口异常(忽略):`,e?.message||e)}}}function Ta({sessionId:e,callId:t,renderer:n,persist:i,onFinished:a=()=>{},emptyFallback:o=``,awaitSnapshot:s=!1}){let c=``,l=!1,u=s,d=[],f=n=>!!n&&n.sessionId===e&&n.callId===t,p=e=>{let t=[];for(let n of e){let e=t[t.length-1];n.type===`STREAM_CHUNK`&&e&&e.type===`STREAM_CHUNK`?t[t.length-1]={...n,delta:(e.delta||``)+(n.delta||``)}:t.push(n)}return t},m=()=>{u=!1;let e=p(d);d=[];for(let t of e)g(t)},h=e=>{l=!0,Promise.resolve().then(()=>i(e)).catch(e=>r.warn(`[ChatReattach] 终态落库失败(忽略):`,e?.message||e)).then(()=>{try{a()}catch{}})};return{sessionId:e,callId:t,get finished(){return l},dispose(){l=!0},restore(e){if(!u)return;u=!1;let r=!!e&&e.callId===t,i=r&&typeof e.accumulated==`string`?e.accumulated:``,a=r&&!!e.html;a&&n.restore?.({html:e.html}),c=i,i&&!a&&n.chunk?.(i);let o=p(d);d=[];for(let e of o)g(e)},handleMessage(e){return l||!f(e)?!1:u?e.type===`STREAM_CHUNK`?(d.push(e),!0):e.type===`API_COMPLETE`||e.type===`API_ERROR`?(m(),g(e)):(d.push(e),!0):g(e)}};function g(r){switch(r.type){case`STREAM_START`:return c=``,n.start?.(),!0;case`STREAM_CHUNK`:return c+=r.delta||``,n.chunk?.(c),!0;case`STREAM_TOOL_CALL`:return n.toolCalls?.(r.toolCalls||[],c),!0;case`STREAM_TOOL_RESULT`:return r.result&&n.toolResult?.(r.result),!0;case`AGENT_STREAM`:return r.execId&&n.agentStream?.(r),!0;case`AGENT_STREAM_DONE`:return r.execId&&n.agentStreamDone?.(r),!0;case`API_RETRYING`:return n.retrying?.(r.attempt,r.maxRetries),!0;case`STREAM_PRESELECT`:return n.preselect?.(r.preselectLog||[]),!0;case`EXECUTION_STATUS_UPDATE`:return!0;case`API_COMPLETE`:{let i=r.content&&String(r.content).trim()?r.content:o||c,a=r.executionLog||[],s={reflectionScore:r.reflectionScore,reasoningContent:r.reasoningContent||null,wasRevised:r.wasRevised||!1,budgetEnded:r.budgetEnded===!0};return n.final?.(i,a,s),h({sessionId:e,callId:t,content:i,executionLog:a,...s}),!0}case`API_ERROR`:return n.error?.(r.error||``,r.executionLog||[]),h({sessionId:e,callId:t,error:r.error||``,executionLog:r.executionLog||[]}),!0;default:return!1}}}function Ea({queryRunning:e,hasLocalListener:t,isAttached:n,attach:i}){return{async syncFromBackground(){try{let r=await e(),a=r&&r.activeCallIds?r.activeCallIds:{};for(let[e,r]of Object.entries(a))!e||!r||t(e)||n(e,r)||i(e,r)}catch(e){r.debug(`[ChatReattach] 查询后台运行状态失败(忽略):`,e?.message||e)}}}}var Da=!1,Oa=new Map,ka=null,Aa=!1,ja=null,Ma=null,Na=null,Pa=250,Fa=new Set([`STREAM_START`,`STREAM_CHUNK`,`STREAM_TOOL_CALL`,`STREAM_TOOL_RESULT`,`AGENT_STREAM`,`AGENT_STREAM_DONE`,`API_RETRYING`,`STREAM_PRESELECT`,`EXECUTION_STATUS_UPDATE`,`API_COMPLETE`,`API_ERROR`]);function Ia(e=0){return new Promise((t,n)=>{let r=!1,i=null,a=(e,t)=>{r||(r=!0,i&&clearTimeout(i),e(t))};e>0&&(i=setTimeout(()=>a(t,{}),e));try{chrome.runtime.sendMessage({type:`QUERY_SESSION_RUNNING`},e=>{if(chrome.runtime.lastError){a(n,Error(chrome.runtime.lastError.message));return}a(t,e||{})})}catch(e){a(n,e)}})}function La(e,t){let n=new Map;return{start(){Dn(e,``),It(``),oi(Date.now()),ui(t),Kn(t)},chunk(n){Dn(e,n),wt(t,n)},restore({html:e}){Hr(t,e)},toolCalls(e,n){typeof n==`string`&&n&&ea(t,n),Ki(t,e)},toolResult(e){Pr(e,t)},agentStream(e){Mt(t,n),Ti(n,t,e)},agentStreamDone(e){let t=n.get(e.execId);t&&t.element&&e.exitCode!==0&&t.element.classList.add(`agent-stream-error`)},retrying(e,n){Dr(t,e,n)},preselect(e){let n=t.querySelector(`.message-content`);!n||!e.length||e.forEach(e=>n.insertBefore(Kr(e),n.firstChild))},final(e,n,r={}){ca(t,e,n,r.reflectionScore,r.reasoningContent,r.wasRevised)},error(e,n){ca(t,e,n||[])}}}async function Ra(e,t,n){let r=!!e.error,i={role:`assistant`,content:r?e.error:e.content||``,executionLog:e.executionLog||[],reflectionScore:e.reflectionScore,wasRevised:e.wasRevised||!1,callId:e.callId,resumed:!0,resumable:e.budgetEnded?`budget`:!1};if(!r&&n&&(i.messageId=n.dataset.messageId||void 0,i.htmlContent=n.dataset.htmlContent||n.outerHTML),y.activeSessionId===t){y.messageHistory.push(i);try{document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:t}}))}catch{}}let{appendMessageToSession:a}=await D(async()=>{let{appendMessageToSession:e}=await import(`./context-indicator-DjOAo_Ln.js`).then(e=>e.kr);return{appendMessageToSession:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));await a(t,i)}function za(){D(()=>import(`./context-indicator-DjOAo_Ln.js`).then(e=>e.U).then(e=>e.syncPendingSessionsToStorage()),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).catch(e=>r.debug(`[ChatReattach] 同步生成态失败(忽略):`,e?.message||e))}var Ba=1e3;function Va(e){return Promise.race([ri(e),new Promise(e=>setTimeout(()=>e(null),Ba))])}function Ha(e,n){let i=yr(e);if(i())return!1;let a=Ar(e);a.dataset.callId=n,i(a),Dn(e,``),oi(Date.now()),Bt(Date.now()),y.pendingCallApiSessionIds.add(e),y.generatingSessionIds.add(e),za();try{document.dispatchEvent(new CustomEvent(`generating-state-changed`))}catch{}let o=Ta({sessionId:e,callId:n,awaitSnapshot:!0,renderer:La(e,a),persist:t=>Ra(t,e,a),emptyFallback:t(`chatMsg.emptyModelReply`),onFinished:()=>{if(Oa.get(e)===o){Oa.delete(e),wa(e),y.pendingCallApiSessionIds.delete(e),za(),Xi(e);try{document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:e}}))}catch{}Nn(e)}}});return Oa.set(e,o),Ca(e),Va(e).then(t=>{o.finished||Oa.get(e)!==o||o.restore(t)}).catch(()=>o.restore(null)),y.activeSessionId===e&&ia(e),r.info(`[ChatReattach] 已接管运行中的任务: sessionId=${e}, callId=${n}`),!0}function Ua(e){let t=Oa.get(e);if(!t)return;Oa.delete(e),wa(e);try{t.dispose?.()}catch{}let n=yr(e),r=n();try{r?.remove()}catch{}n(null),Xi(e),y.pendingCallApiSessionIds.delete(e),za();try{document.dispatchEvent(new CustomEvent(`generating-state-changed`))}catch{}}function Wa(){let e=ka;e&&Promise.resolve().then(()=>e.syncFromBackground()).catch(e=>r.debug(`[ChatReattach] 对齐后台状态失败(忽略):`,e?.message||e))}function Ga(){!Da||!ka||Na||(Na=setTimeout(()=>{Na=null,Wa()},Pa))}var Ka=new Map,qa=3e3,Ja=100,Ya=new Set,Xa=new Set([`API_COMPLETE`,`API_ERROR`]);function Za(e,t){let n=`${e}|${t.callId}`;Ya.has(n)||(Ya.add(n),Ya.size>Ja&&Ya.delete(Ya.values().next().value),Ua(e),Ha(e,t.callId)&&Oa.get(e)?.handleMessage(t))}function Qa(e,t,n){let r=Ka.get(e);if(r){r.messages.push(n);return}r={callId:t,messages:[n]},Ka.set(e,r),Ia(qa).then(t=>$a(e,t&&t.activeCallIds&&t.activeCallIds[e]||null)).catch(()=>$a(e,null)).finally(()=>{Ka.delete(e)})}function $a(e,t){let n=Ka.get(e);if(!n)return;let{callId:r,messages:i}=n;if(t===r)Ua(e),Ha(e,r);else if(t===null){let t=i.find(e=>Xa.has(e.type));if(!t)return;Za(e,t);return}else return;let a=Oa.get(e);if(!(!a||a.callId!==r))for(let e of i){if(a.finished)break;a.handleMessage(e)}}function eo(){if(Aa)return;Aa=!0;let e=e=>{if(!e)return!1;let t=e.sessionId?Oa.get(e.sessionId):null;return t?e.callId&&e.callId!==t.callId?(Qa(e.sessionId,e.callId,e),!1):(Ca(e.sessionId),t.handleMessage(e),!1):(e.callId&&Fa.has(e.type)&&Ga(),!1)};chrome.runtime.onMessage.addListener(e),Sa(e),ja=e=>{let t=e?.detail?.sessionId;t&&Oa.has(t)&&ia(t),Ga()},document.addEventListener(`session-hydrated`,ja),Ma=e=>{let t=e?.detail?.sessionId;t&&Oa.has(t)&&ia(t)},document.addEventListener(`chat-history-rendered`,Ma)}function to(){return Da?{syncFromBackground:()=>ka.syncFromBackground()}:(Da=!0,eo(),ka=Ea({queryRunning:Ia,hasLocalListener:e=>y.pendingCancelApiMap.has(e),isAttached:(e,t)=>Oa.get(e)?.callId===t?(Ca(e),!0):!1,attach:(e,t)=>{Ha(e,t)}}),ka.syncFromBackground(),{syncFromBackground:()=>ka.syncFromBackground()})}function no(e){!Da||!ka||(e&&y.activeSessionId===e&&ia(e),ka.syncFromBackground())}e(`zh`,{dock:{ariaLabel:`执行中会话`,running:`正在执行`,node:`正在执行:{node}`,subtask:`子任务 {index}/{total}`,queued:`排队 {count} 条`,done:`已完成,点击查看结果`,doneAt:`已完成 {time}`,scheduled:`定时任务`,dismiss:`从停靠条移除`,dismissStale:`移除失效条目`,stale:`状态可能已失效 · 未在限定时间内收到执行更新`,more:`还有 {count} 个`,moreAria:`还有 {count} 个未显示的执行条目`,overflowTitle:`其他执行中的会话`,openSession:`点击进入该会话`,unknownSession:`未知会话`}}),e(`en`,{dock:{ariaLabel:`Running sessions`,running:`Running`,node:`Running: {node}`,subtask:`Subtask {index}/{total}`,queued:`{count} queued`,done:`Finished — click to review`,doneAt:`Finished {time}`,scheduled:`Scheduled task`,dismiss:`Remove from dock`,dismissStale:`Remove stale entry`,stale:`Status may be stale · no execution update in time`,more:`+{count} more`,moreAria:`{count} more running entries not shown`,overflowTitle:`Other active sessions`,openSession:`Click to open this session`,unknownSession:`Unknown session`}});var ro=`sessionDockDismissed`,io=5e3,ao=250,oo=1200,so=8,co=so-1,lo=9e4,uo={running:0,queued:1,done:2},fo=new Map,po=new Map,mo=new Map,ho=new Map,go=new Set,_o=new Set,vo=new Map,yo=new Map,bo=new Set,xo=new Set,So=new Set,Co=[],wo=new Set,M=null,N=null,P=null,To=[],Eo=!1,Do=null,Oo=null,ko=!1,Ao=null,jo=null;function Mo(e){return e?Array.isArray(e)?e:e instanceof Set?Array.from(e):[]:[]}function No(e){let t=new Set;for(let n of Mo(e))n&&t.add(h(String(n))||String(n));return t}function Po({phase:e=``,sessionId:t=null,backendRunningIds:n=[],startedAt:r=0,lastUpdateAt:i=0,now:a=Date.now(),staleMs:o=lo}={}){if(e!==`running`||!t||Mo(n).includes(t))return!1;let s=Math.max(Number(r)||0,Number(i)||0);return s?a-s>=o:!1}var Fo=160;function Io(e){let t=String(e??``).replace(/\s+/g,` `).trim();if(!t)return``;let n=Array.from(t);return n.length<=Fo?t:`${n.slice(0,Fo).join(``).trimEnd()}…`}function Lo(e,t){let n=e=>String(e??``).trim().replace(/[…\s.]+$/,``).replace(/\s+/g,``),r=n(e),i=n(t);return!r||!i?!1:r===i||i.startsWith(r)||r.startsWith(i)}function Ro({phase:e=``,queuedText:t=``,questionText:n=``,title:r=``}={}){let i=e===`queued`?Io(t):``,a=i||Io(n),o=Io(r),s=a||o,c=i?`queued`:a?`question`:s?`title`:``;return{primary:s,sub:a&&!Lo(o,a)?o:``,isQuestion:!!a,from:c}}function zo(e){let t=Array.isArray(e?.messageHistory)?e.messageHistory:[];for(let e=t.length-1;e>=0;--e){let n=t[e];if(!n||n.role!==`user`)continue;let r=re(n.content);if(r&&String(r).trim())return{text:String(r),messageId:n.messageId?String(n.messageId):``}}return{text:``,messageId:``}}function Bo({activeSessionId:e=null,titles:t={},questions:n={},anchors:r={},queuedTexts:i={},generatingIds:a=[],pendingIds:o=[],runningIds:s=[],completedIds:c=[],queuedCounts:l={},scheduledIds:u=[],dismissedIds:d=[],nodeInfo:f={},startedAt:p={},doneAt:m={},lastUpdateAt:h={},now:g=Date.now(),staleMs:_=lo}={}){let ee=Mo(s),v=new Set([...Mo(a),...Mo(o),...ee]),te=new Set(Mo(c)),y=new Set(Mo(d)),b=new Set(Mo(u)),ne=l||{},x=new Set([...v,...te,...Object.keys(ne)]),S=[];for(let a of x){if(!a||a===e)continue;let o=Number(ne[a])||0,s;if(v.has(a))s=`running`;else if(o>0)s=`queued`;else if(te.has(a))s=`done`;else continue;let c=Po({phase:s,sessionId:a,backendRunningIds:ee,startedAt:p?.[a],lastUpdateAt:h?.[a],now:g,staleMs:_});if(y.has(a)&&(s===`done`||c))continue;let l=f?.[a]||{},u=Ro({phase:s,queuedText:i?.[a]||``,questionText:n?.[a]||``,title:t?.[a]||``});S.push({sessionId:a,title:t?.[a]||``,primary:u.primary,sub:u.sub,isQuestion:u.isQuestion,anchorMessageId:u.from===`question`?String(r?.[a]||``):``,phase:s,stale:c,source:b.has(a)?`scheduled`:`chat`,queuedCount:o,nodeName:l.nodeName||``,subtaskIndex:l.subtaskIndex||0,subtaskTotal:l.subtaskTotal||0,startedAt:p?.[a]||0,doneAt:m?.[a]||0,lastUpdateAt:h?.[a]||0})}return S.sort((e,t)=>{let n=uo[e.phase]-uo[t.phase];if(n!==0)return n;if(e.stale!==t.stale)return e.stale?1:-1;let r=e.phase===`done`?e.doneAt:e.startedAt,i=t.phase===`done`?t.doneAt:t.startedAt;return r===i?String(e.sessionId).localeCompare(String(t.sessionId)):i-r}),S}function Vo(e){return So.has(e)||y.generatingSessionIds.has(e)||y.pendingCallApiSessionIds.has(e)}function Ho(){let e={};try{let t=Rn();for(let n of t){let t=Ut(n);t>0&&(e[n]=t)}}catch(e){r.debug(`[SessionDock] read queue counts failed:`,e?.message||e)}return e}function Uo(){let e={};for(let t of y.sessions||[])e[t.id]=t.title||``;for(let[t,n]of vo)e[t]||(e[t]=n);return e}function Wo(){let e={},t={},n=new Map;for(let e of y.sessions||[])n.set(e.id,e);for(let r of new Set([...So,...y.generatingSessionIds,...y.pendingCallApiSessionIds,...y.completedSessionIds])){let i=po.get(r)||mo.get(r)||0,a=yo.get(r);if(i&&a&&a.stamp===i){a.text&&(e[r]=a.text,t[r]=a.messageId||``);continue}let o=zo(n.get(r));o.text&&(e[r]=o.text,t[r]=o.messageId)}return{questions:e,anchors:t}}function Go(){let e={};try{for(let t of Rn()){let n=da(t);n?.text&&(e[t]=String(n.text))}}catch(e){r.debug(`[SessionDock] read queued texts failed:`,e?.message||e)}return e}function Ko(e){for(let t of e||[]){let e=t.sessionId;if(!e)continue;let n=t.startedAt||t.doneAt||0,i=yo.get(e),a=!i||i.stamp!==n,o=!t.title;!a&&!o||xo.has(e)||(xo.add(e),ne(e).then(t=>{if(t&&((o||!vo.has(e))&&vo.set(e,t.title||``),a)){let r=zo(t);yo.set(e,{text:r.text,messageId:r.messageId,stamp:n})}}).catch(e=>{r.debug(`[SessionDock] hydrate label failed:`,e?.message||e)}).finally(()=>{xo.delete(e),F()}))}}function qo(e){if(!e)return``;let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function Jo(e){if(e.phase===`running`){if(e.stale)return t(`dock.stale`);let n=e.nodeName?t(`dock.node`,{node:e.nodeName}):t(`dock.running`);return e.subtaskTotal>1?`${n} · ${t(`dock.subtask`,{index:e.subtaskIndex,total:e.subtaskTotal})}`:n}return e.phase===`queued`?t(`dock.queued`,{count:e.queuedCount}):e.doneAt?t(`dock.doneAt`,{time:qo(e.doneAt)}):t(`dock.done`)}function Yo(e){po.set(e,Date.now()),mo.delete(e),yo.delete(e)}function Xo(){let e=new Set([...y.generatingSessionIds,...y.pendingCallApiSessionIds]);for(let t of e)bo.has(t)&&(bo.delete(t),Yo(t));F()}function Zo(){let e=y.completedSessionIds;for(let e of new Set([...So,...y.generatingSessionIds,...y.pendingCallApiSessionIds]))po.has(e)||po.set(e,Date.now()),mo.delete(e);for(let e of So)_o.delete(e);for(let t of e)!mo.has(t)&&!Vo(t)&&mo.set(t,Date.now());let{questions:t,anchors:n}=Wo(),r=Bo({activeSessionId:y.activeSessionId,titles:Uo(),questions:t,anchors:n,queuedTexts:Go(),generatingIds:y.generatingSessionIds,pendingIds:y.pendingCallApiSessionIds,runningIds:So,completedIds:e,queuedCounts:Ho(),scheduledIds:go,dismissedIds:_o,nodeInfo:Object.fromEntries(fo),startedAt:Object.fromEntries(po),doneAt:Object.fromEntries(mo),lastUpdateAt:Object.fromEntries(ho),now:Date.now()});return Ko(r),r}function Qo(e){let t=new Set(Co.filter(e=>e.phase===`done`).map(e=>e.sessionId)),n=e.filter(e=>e.phase===`done`&&!t.has(e.sessionId)).map(e=>e.sessionId);n.length!==0&&(wo=new Set(n),Ao&&clearTimeout(Ao),Ao=setTimeout(()=>{Ao=null,wo=new Set,F()},oo))}function $o(){if(M||typeof document>`u`)return M;M=document.createElement(`div`),M.className=`session-dock`,M.id=`sessionDock`,M.setAttribute(`role`,`navigation`),document.body.appendChild(M),N=document.createElement(`div`),N.className=`session-dock-tip`,document.body.appendChild(N),es();let e=document.getElementById(`chatContainer`);return e&&typeof ResizeObserver<`u`&&new ResizeObserver(es).observe(e),window.addEventListener(`resize`,es),M}function es(){if(!M)return;let e=document.getElementById(`chatContainer`);if(!e)return;let t=e.getBoundingClientRect();M.style.top=`${Math.max(0,Math.round(t.top+8))}px`}function ts(e){bi(e.sessionId,{focusMessageId:e.anchorMessageId||null})}function ns(e){let n=document.createElement(`div`);n.className=`session-dock-item`,n.dataset.sessionId=e.sessionId,n.dataset.phase=e.phase,e.stale&&(n.dataset.stale=`true`),wo.has(e.sessionId)&&n.classList.add(`is-flash`);let r=e.title||t(`dock.unknownSession`),i=e.primary||r,a=Jo(e),o=e.phase===`done`?`✓`:Array.from(r)[0]||`?`,s=document.createElement(`button`);if(s.type=`button`,s.className=`session-dock-chip`,s.setAttribute(`aria-label`,`${i} · ${a}`),s.title=``,s.textContent=o,s.addEventListener(`click`,()=>{ts(e)}),n.appendChild(s),e.queuedCount>0&&e.phase!==`done`){let t=document.createElement(`span`);t.className=`session-dock-badge`,t.textContent=String(e.queuedCount>99?`99+`:e.queuedCount),n.appendChild(t)}if(e.source===`scheduled`){let e=document.createElement(`span`);e.className=`session-dock-clock`,n.appendChild(e)}if(e.phase===`done`||e.stale){let r=document.createElement(`button`);r.type=`button`,r.className=`session-dock-dismiss`;let i=e.stale?t(`dock.dismissStale`):t(`dock.dismiss`);r.setAttribute(`aria-label`,i),r.title=i,r.textContent=`×`,r.addEventListener(`click`,t=>{t.stopPropagation(),hs(e.sessionId)}),n.appendChild(r)}return n.addEventListener(`mouseenter`,()=>rs(n,e,a)),n.addEventListener(`mouseleave`,is),n.addEventListener(`focusin`,()=>rs(n,e,a)),n.addEventListener(`focusout`,is),n}function rs(e,n,r){if(!N)return;N.innerHTML=``;let i=document.createElement(`div`);i.className=`session-dock-tip-title`,i.textContent=n.primary||n.title||t(`dock.unknownSession`);let a=document.createElement(`div`);if(a.className=`session-dock-tip-status`,a.textContent=r,N.appendChild(i),n.sub){let e=document.createElement(`div`);e.className=`session-dock-tip-sub`,e.textContent=n.sub,N.appendChild(e)}N.appendChild(a);let o=e.getBoundingClientRect();N.style.top=`${Math.round(o.top)}px`,N.style.left=`${Math.round(o.right+8)}px`,N.classList.add(`show`)}function is(){N&&N.classList.remove(`show`)}function as(){return P||typeof document>`u`?P:(P=document.createElement(`div`),P.className=`session-dock-overflow`,P.setAttribute(`role`,`menu`),P.addEventListener(`mouseenter`,os),P.addEventListener(`mouseleave`,ss),P.addEventListener(`focusin`,os),P.addEventListener(`focusout`,ss),document.body.appendChild(P),P)}function os(){jo&&=(clearTimeout(jo),null)}function ss(){Eo||(os(),jo=setTimeout(()=>{jo=null,fs()},220))}function cs(){let e=M?M.querySelector(`.session-dock-more`):null;e&&(e.setAttribute(`aria-expanded`,Eo?`true`:`false`),e.classList.toggle(`is-open`,Eo))}function ls(){let e=as();if(!e)return;e.innerHTML=``;let n=document.createElement(`div`);n.className=`session-dock-overflow-header`,n.textContent=t(`dock.overflowTitle`),e.appendChild(n);let r=document.createElement(`div`);r.className=`session-dock-overflow-list`;for(let e of To){let n=e.primary||e.title||t(`dock.unknownSession`),i=Jo(e),a=document.createElement(`button`);a.type=`button`,a.className=`session-dock-overflow-row`,a.dataset.phase=e.phase,e.stale&&(a.dataset.stale=`true`),a.setAttribute(`aria-label`,`${n} · ${i}`);let o=document.createElement(`span`);o.className=`session-dock-overflow-title`,o.textContent=n;let s=document.createElement(`span`);s.className=`session-dock-overflow-status`,s.textContent=i,a.appendChild(o),a.appendChild(s),a.addEventListener(`click`,()=>{fs(),ts(e)}),r.appendChild(a)}e.appendChild(r)}function us(){if(!P||!M)return;let e=M.querySelector(`.session-dock-item--more`);if(!e)return;let t=e.getBoundingClientRect();P.style.left=`${Math.round(t.right+8)}px`;let n=P.offsetHeight||0,r=Math.max(8,window.innerHeight-n-8);P.style.top=`${Math.round(Math.min(Math.max(8,t.top),r))}px`}function ds(){To.length!==0&&as()&&(os(),ls(),us(),P.classList.add(`show`),cs())}function fs(){os(),Eo=!1,P&&P.classList.remove(`show`),cs()}function ps(){if(P&&P.classList.contains(`show`)&&Eo){fs();return}ds(),Eo=!0,cs()}function ms(e){let n=document.createElement(`div`);n.className=`session-dock-item session-dock-item--more`,n.dataset.count=String(e.length);let r=document.createElement(`button`);return r.type=`button`,r.className=`session-dock-chip session-dock-more`,r.setAttribute(`aria-label`,t(`dock.moreAria`,{count:e.length})),r.setAttribute(`aria-expanded`,Eo?`true`:`false`),r.textContent=`+${e.length>99?`99`:e.length}`,r.addEventListener(`click`,()=>ps()),n.appendChild(r),n.addEventListener(`mouseenter`,()=>ds()),n.addEventListener(`mouseleave`,ss),n.addEventListener(`focusin`,()=>ds()),n.addEventListener(`focusout`,ss),n}function hs(e){e&&(_o.add(e),gs(),F())}function gs(){try{chrome.storage.local.set({[ro]:Array.from(_o)}).catch(()=>{})}catch{}}function _s(){try{chrome.storage.local.get([ro],e=>{let t=e?.[ro];if(Array.isArray(t)){for(let e of t)_o.add(e);F()}})}catch{}}function vs(){if(!$o())return;let e=Zo();if(Qo(e),Co=e,fs(),To=[],M.innerHTML=``,e.length===0){M.classList.remove(`show`),document.body.classList.remove(`has-session-dock`),is();return}let t=e.length>so?co:so;To=e.slice(t);for(let n of e.slice(0,t))M.appendChild(ns(n));To.length>0&&M.appendChild(ms(To)),M.classList.add(`show`),document.body.classList.add(`has-session-dock`)}function F(){Do||=setTimeout(()=>{Do=null;try{vs()}catch(e){r.warn(`[SessionDock] render failed:`,e?.message||e)}},ao)}function ys(){return new Promise(e=>{try{chrome.runtime.sendMessage({type:`QUERY_SESSION_RUNNING`},t=>{if(chrome.runtime.lastError||!t){e();return}if(Array.isArray(t.activeSessionIds)){let e=No(t.activeSessionIds);for(let t of e){if(bo.has(t)){bo.delete(t),Yo(t);continue}So.has(t)||y.generatingSessionIds.has(t)||y.pendingCallApiSessionIds.has(t)||Yo(t)}So=e}e()})}catch{e()}})}function bs(e){let t=e?.sessionId;if(!t)return;let n=fo.get(t)||{};fo.set(t,{nodeName:e.nodeName||n.nodeName||``,subtaskIndex:e.subtaskIndex||n.subtaskIndex||0,subtaskTotal:e.subtaskTotal||n.subtaskTotal||0}),ho.set(t,Date.now()),F()}function xs(e){e&&(fo.delete(e),po.delete(e),mo.delete(e),ho.delete(e),_o.delete(e),vo.delete(e),yo.delete(e),bo.delete(e),F())}function Ss(){if(!(ko||typeof document>`u`||!$o())){ko=!0,_s(),document.addEventListener(`generating-state-changed`,Xo),document.addEventListener(`session-switched`,F),document.addEventListener(`generation-ended`,e=>{let t=e?.detail?.sessionId;t&&(bo.add(t),mo.has(t)||mo.set(t,Date.now())),F()}),document.addEventListener(`session-archived`,e=>xs(e?.detail?.sessionId)),document.addEventListener(`session-deleted`,e=>xs(e?.detail?.sessionId));try{qt(F)}catch(e){r.debug(`[SessionDock] subscribe queue failed:`,e?.message||e)}try{chrome.runtime.onMessage.addListener(e=>e?e.type===`EXECUTION_STATUS_UPDATE`?(bs(e),!1):e.type===`SCHEDULED_TASK_RUN_STATE`&&e.sessionId?(e.running?go.add(e.sessionId):go.delete(e.sessionId),F(),!1):(e.type===`SCHEDULED_SESSION_UPDATED`&&F(),!1):!1)}catch(e){r.debug(`[SessionDock] register runtime listener failed:`,e?.message||e)}document.addEventListener(`visibilitychange`,()=>{if(document.hidden){fs();return}ys().then(F)}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&Eo&&fs()}),Oo||=setInterval(()=>{document.hidden||ys().then(F)},io),ys().then(()=>{for(let e of So)po.has(e)||po.set(e,Date.now());vs()})}}function Cs(){let e=document.getElementById(`chatNavUp`),n=document.getElementById(`chatNavDown`),r=document.getElementById(`chatNavHotzone`),i=document.getElementById(`chatNavButtons`),a=document.getElementById(`chatNavQuestionPanel`),o=[],s=!1,c=null,l=``,u=!1,d=!1;function f(e){let t=document.getElementById(`chatContainer`);if(!t)return-1;let n=t.getBoundingClientRect();return et(e,n.top,n.bottom)}function p(e,t){let n=document.getElementById(`chatContainer`);if(!n)return`noop`;let r=qe(n);if(r.length===0)return`noop`;let i=n.getBoundingClientRect().top;if(t){if(e===`prev`)r[0].start.scrollIntoView({behavior:`smooth`,block:`start`});else{let e=r[r.length-1].elements;e[e.length-1].scrollIntoView({behavior:`smooth`,block:`end`})}return`jumped`}let a=Xe(r.length,Qe(r,i),e);return a===null?(m(e),`blocked`):(r[a].start.scrollIntoView({behavior:`smooth`,block:`start`}),`jumped`)}function m(t){let r=t===`prev`?e:n;r&&(r.classList.remove(`blocked`),r.offsetWidth,r.classList.add(`blocked`),r.addEventListener(`animationend`,()=>r.classList.remove(`blocked`),{once:!0}))}function h(e,n){let r=a.querySelectorAll(`.chat-nav-question-item`);r.forEach(t=>{Number(t.dataset.groupIndex)===e?(t.classList.add(`current`),t.setAttribute(`aria-current`,`true`)):(t.classList.remove(`current`),t.setAttribute(`aria-current`,`false`))});let i=a.querySelector(`.chat-nav-question-header .count`);i&&(i.textContent=t(`chat.navPosition`,{current:e>=0?e+1:n,total:n}));let o=Array.from(r).find(t=>Number(t.dataset.groupIndex)===e);!d&&e>=0&&o&&o.scrollIntoView({block:`nearest`})}function g(){if(!a||!a.classList.contains(`expanded`))return;o=qe(document.getElementById(`chatContainer`));let e=l?qe(document.getElementById(`chatContainer`)).length:a.querySelectorAll(`.chat-nav-question-item`).length;if(o.length===0){a.innerHTML=``,a.classList.remove(`expanded`);return}if(!l&&e!==o.length){_();return}h(f(o),o.length)}function _(){if(!a)return!1;if(o=qe(document.getElementById(`chatContainer`)),o.length===0)return a.innerHTML=``,!1;let e=f(o),t=document.activeElement===a.querySelector(`[data-role="nav-search"]`);a.innerHTML=ft(o,e,s,l),a.querySelector(`.chat-nav-pin`).addEventListener(`click`,e=>{e.stopPropagation(),x()});let n=a.querySelector(`[data-role="nav-search"]`);if(n){let e=()=>{l!==n.value&&(l=n.value,_())};n.addEventListener(`input`,t=>{t.isComposing||e()}),n.addEventListener(`compositionend`,e),t&&(n.focus(),n.setSelectionRange(n.value.length,n.value.length))}if(e>=0){let t=a.querySelector(`.chat-nav-question-item[data-group-index="${e}"]`);t&&t.scrollIntoView({block:`nearest`})}return!0}function ee(){let e=document.activeElement;return e?[r,i,a].some(t=>t&&(t===e||t.contains(e))):!1}function v(){i.classList.remove(`expanded`),a&&a.classList.remove(`expanded`)}function te(){let e=ee();v(),e&&r&&(u=!0,r.focus({preventScroll:!0}),u=!1)}function y(){if(clearTimeout(c),i.classList.add(`expanded`),a){if(a.classList.contains(`expanded`)){g();return}_()?a.classList.add(`expanded`):a.classList.remove(`expanded`)}}function b(e){clearTimeout(c),!s&&(ee()||(e?v():c=setTimeout(v,300)))}function ne(e){if(s=e,r&&(r.classList.toggle(`pinned`,e),r.setAttribute(`aria-pressed`,String(e))),a){a.classList.toggle(`pinned`,e);let n=a.querySelector(`.chat-nav-pin`);if(n){let r=t(e?`chat.navUnpinLabel`:`chat.navPinLabel`);n.textContent=r,n.title=r,n.setAttribute(`aria-pressed`,String(e)),n.classList.toggle(`on`,e)}}}function x(){ne(!s)}e&&e.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),p(`prev`,e.ctrlKey||e.metaKey),g()}),n&&n.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),p(`next`,e.ctrlKey||e.metaKey),g()}),r&&i&&(r.addEventListener(`mouseenter`,y),r.addEventListener(`mouseleave`,()=>b(!1)),r.addEventListener(`click`,()=>x()),r.addEventListener(`focus`,()=>{u||y()}),r.addEventListener(`blur`,()=>b(!1)),r.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),x())}),i.addEventListener(`mouseenter`,y),i.addEventListener(`mouseleave`,()=>b(!1)),i.addEventListener(`focusin`,y),a&&(a.addEventListener(`mouseenter`,()=>{d=!0,y()}),a.addEventListener(`mouseleave`,()=>{d=!1,b(!1)}),a.addEventListener(`focusin`,y),a.addEventListener(`keydown`,e=>{if(e.target.matches(`[data-role="nav-search"]`))return;let t=Array.from(a.querySelectorAll(`.chat-nav-question-item`));if(t.length===0)return;let n=t.indexOf(document.activeElement),r=null;e.key===`ArrowDown`?r=Math.min(n+1,t.length-1):e.key===`ArrowUp`?r=n<=0?0:n-1:e.key===`Home`?r=0:e.key===`End`&&(r=t.length-1),r!==null&&(e.preventDefault(),t[r].focus())}),a.addEventListener(`click`,e=>{let t=e.target.closest(`.chat-nav-question-item`);if(!t||!t.dataset.messageId)return;let n=o.find(e=>(e.userElement||e.start).dataset.messageId===t.dataset.messageId);if(!n)return;let r=n.userElement||n.start;r.scrollIntoView({behavior:`instant`,block:`start`}),r.classList.add(`bookmark-highlight`),setTimeout(()=>r.classList.remove(`bookmark-highlight`),2e3),s?g():te()})));{let e=document.getElementById(`chatContainer`);if(e){let t=!1;e.addEventListener(`scroll`,()=>{!a||!a.classList.contains(`expanded`)||t||(t=!0,requestAnimationFrame(()=>{t=!1,g()}))},{passive:!0})}}function S(){let e=a&&a.classList.contains(`expanded`);if(!s&&!e)return!1;if(a&&a.querySelector(`[data-role="nav-search"]`)&&l){l=``,_();let e=a.querySelector(`[data-role="nav-search"]`);return e&&e.focus(),!0}return ne(!1),te(),!0}return{jumpToMessage:p,updateActiveQuestion:g,handleEscape:S,isPinned:()=>s}}function ws(e){if(!e)return!1;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;return!!(t&&t.closest&&t.closest(`#chatContainer, .message-fullscreen-body`))}e(`zh`,{searchPanel:{toggleTitle:`消息搜索`,title:`消息搜索`,closeTitle:`关闭`,inputPlaceholder:`搜索消息(支持 & | 组合搜索)...`,clearTitle:`清除`,globalSearchTitle:`在所有会话中搜索`,globalSearch:`全局搜索`,currentSessionTitle:`仅在当前会话中搜索`,currentSession:`当前会话`,startSearchHint:`输入关键词开始搜索`,searching:`搜索中...`,searchingWithCount:`搜索中... {count} 条`,searchError:`搜索出错`,noActiveSession:`没有活跃会话`,noSessionData:`没有会话数据`,noMatch:`未找到匹配消息`,unknownSession:`未知会话`,countResult:`{count} 条`,noResult:`无结果`,searchingSuffix:` (搜索中...)`,currentSessionResults:`当前会话{label} · {count} 条`,otherSessionsResults:`其他会话 · {count} 条`,roleUser:`你`,roleAssistant:`助手`,sessionNotExist:`会话已不存在`,messageDeleted:`消息已被删除`}}),e(`en`,{searchPanel:{toggleTitle:`Search messages`,title:`Message search`,closeTitle:`Close`,inputPlaceholder:`Search messages (supports & | combined search)...`,clearTitle:`Clear`,globalSearchTitle:`Search in all sessions`,globalSearch:`Global search`,currentSessionTitle:`Search in current session only`,currentSession:`Current session`,startSearchHint:`Enter keywords to start searching`,searching:`Searching...`,searchingWithCount:`Searching... {count} found`,searchError:`Search error`,noActiveSession:`No active session`,noSessionData:`No session data`,noMatch:`No matching messages found`,unknownSession:`Unknown session`,countResult:`{count} found`,noResult:`No results`,searchingSuffix:` (searching...)`,currentSessionResults:`Current session{label} · {count} found`,otherSessionsResults:`Other sessions · {count} found`,roleUser:`You`,roleAssistant:`Assistant`,sessionNotExist:`Session no longer exists`,messageDeleted:`Message has been deleted`}});var Ts=!1,Es=!1,I=[],Ds=``;function Os(){y.searchInputHistory=[],y.searchInputHistoryIndex=-1;try{chrome.storage.local.get([`searchInputHistory`],e=>{e.searchInputHistory&&(y.searchInputHistory=e.searchInputHistory)})}catch{}let e=document.createElement(`div`);e.className=`search-panel-container`,e.id=`searchPanelContainer`,e.innerHTML=`
3
3
  <button class="search-panel-toggle" id="searchPanelToggle" title="${t(`searchPanel.toggleTitle`)}">
4
4
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
5
5
  <circle cx="11" cy="11" r="8"/>
@@ -48,7 +48,7 @@ import{a as e,c as t,i as n,l as r,n as i,r as a,s as o}from"./i18n-5c8prpFJ.js"
48
48
  </div>
49
49
  <div class="search-result-preview">${c}</div>
50
50
  </div>
51
- `}).join(``)}function Bs(e,t){if(!t)return e;let n=t.split(/[&|]/).map(e=>e.trim()).filter(Boolean);if(n.length===0)return e;let r=n.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)),i=RegExp(`(${r.join(`|`)})`,`gi`);return e.replace(i,`<mark class="search-highlight-match">$1</mark>`)}async function Vs(e,n){if(!(!e||!n)){if(y.activeSessionId!==e)try{let n=y.activeSessionId;if(await Ct(e)===!1||y.activeSessionId!==e){A(t(`searchPanel.sessionNotExist`),`warning`);return}document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:n,skipScrollRestore:!0}}));try{let{renderSessionTabs:e}=await D(async()=>{let{renderSessionTabs:e}=await import(`./context-indicator-Sf2n8eWg.js`).then(e=>e.cr);return{renderSessionTabs:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));e()}catch(e){r.warn(`[SearchPanel] refreshsessionTab failed:`,e)}}catch(e){r.error(`[SearchPanel] switchsession failed:`,e);return}setTimeout(async()=>{let i=document.getElementById(`chatContainer`);if(!i){r.warn(`[SearchPanel] chatContainer not found`);return}let a=i.querySelector(`.message[data-message-id="${n}"]`);if(a||=i.querySelector(`[data-message-id="${n}"]`),!a){let t=Array.from(i.querySelectorAll(`[data-message-id]`),e=>e.dataset.messageId);r.warn(`[SearchPanel] positionmessage failed`,{targetSessionId:e,activeSessionId:y.activeSessionId,targetMessageId:n,typeOfMessageId:typeof n,messageIdLength:n.length,domMessageIds:t,chatContainerHtmlLen:i.innerHTML.length})}if(a)a.scrollIntoView({behavior:`instant`,block:`nearest`}),a.classList.add(`bookmark-highlight`),setTimeout(()=>{a.classList.remove(`bookmark-highlight`)},2e3);else{A(t(`searchPanel.messageDeleted`),`warning`);try{if(await te(e,n)){I=I.filter(t=>!(t.sessionId===e&&t.messageId===n));let i=document.getElementById(`searchPanelContent`),a=document.getElementById(`searchPanelCount`);i&&I.length>0?(Rs(I,Ds,i),a.textContent=t(`searchPanel.countResult`,{count:I.length})):i&&I.length===0&&(i.innerHTML=`<div class="search-panel-empty">${t(`searchPanel.noMatch`)}</div>`,a&&(a.textContent=t(`searchPanel.noResult`))),r.debug(`[SearchPanel] cleaned IndexedDB dirtydata:`,e,n)}}catch(e){r.warn(`[SearchPanel] cleanupdirtydata failed:`,e)}}},500)}}e(`zh`,{schedPanel:{toggleTitle:`定时任务`,toggleRunning:`执行中`,title:`定时任务`,newTask:`新建任务`,close:`关闭`,empty:`暂无定时任务`,nameLabel:`任务名称`,descLabel:`任务描述(可选)`,promptLabel:`任务指令`,scheduleLabel:`定时规则`,scheduleTypeOnce:`一次性`,scheduleTypeInterval:`间隔`,scheduleTypeCron:`Cron 表达式`,intervalValuePlaceholder:`例如:30m / 2h / 1d`,cronValuePlaceholder:`例如:0 9 * * *`,relativeValuePlaceholder:`例如:30`,onceModeLabel:`执行方式`,onceModeRelative:`多少分钟后`,onceModeAbsolute:`指定时间点`,valueLabelInterval:`间隔时间`,valueLabelCron:`Cron 表达式`,minutesSuffix:` 分钟后`,contextUrlLabel:`上下文网页地址(可选)`,useCurrentPage:`使用当前页面`,sessionLabel:`宿主会话`,sessionAuto:`自动(会话被删时自动新建)`,save:`保存`,cancel:`取消`,edit:`编辑`,editTitle:`编辑任务`,delete:`删除`,runNow:`立即执行`,enable:`启用`,disable:`停用`,statusSuccess:`成功`,statusFailed:`失败`,statusRunning:`运行中`,statusDisabled:`已停用`,nextRun:`下次执行`,deleted:`任务已删除`,saved:`任务已保存`,runNowToast:`已触发执行`,deleteConfirmTitle:`删除定时任务`,deleteConfirmMsg:`确定删除任务「{name}」吗?`,createFailed:`创建任务失败`,nameRequired:`请填写任务名称`,promptRequired:`请填写任务指令`,scheduleRequired:`请填写定时规则`,loading:`加载中...`,contextModeLabel:`网页上下文方式`,contextModeFetch:`抓取网页正文`,contextModeUrlOnly:`仅使用 URL(不抓正文)`,maxRunsLabel:`最多执行次数(可选)`,endAtLabel:`截止时间(可选)`,runHistoryLabel:`运行历史`,runHistoryEmpty:`暂无运行记录`,runCountLabel:`运行历史 ({count})`,filterAll:`全部`,filterEnabled:`启用中`,filterDisabled:`已停用`,sortLabel:`排序`,sortCreated:`创建时间`,sortLastRun:`最近执行`,sortUpdated:`更新时间`,emptyFiltered:`没有符合筛选条件的任务`}}),e(`en`,{schedPanel:{toggleTitle:`Scheduled tasks`,toggleRunning:`Running`,title:`Scheduled tasks`,newTask:`New task`,close:`Close`,empty:`No scheduled tasks`,nameLabel:`Name`,descLabel:`Description (optional)`,promptLabel:`Prompt`,scheduleLabel:`Schedule`,scheduleTypeOnce:`Once`,scheduleTypeInterval:`Interval`,scheduleTypeCron:`Cron expression`,intervalValuePlaceholder:`e.g. 30m / 2h / 1d`,cronValuePlaceholder:`e.g. 0 9 * * *`,relativeValuePlaceholder:`e.g. 30`,onceModeLabel:`Run mode`,onceModeRelative:`After some minutes`,onceModeAbsolute:`At specific time`,valueLabelInterval:`Interval`,valueLabelCron:`Cron expression`,minutesSuffix:` minutes later`,contextUrlLabel:`Context page URL (optional)`,useCurrentPage:`Use current page`,sessionLabel:`Host session`,sessionAuto:`Auto (recreate if deleted)`,save:`Save`,cancel:`Cancel`,edit:`Edit`,editTitle:`Edit task`,delete:`Delete`,runNow:`Run now`,enable:`Enable`,disable:`Disable`,statusSuccess:`Success`,statusFailed:`Failed`,statusRunning:`Running`,statusDisabled:`Disabled`,nextRun:`Next run`,deleted:`Task deleted`,saved:`Task saved`,runNowToast:`Execution triggered`,deleteConfirmTitle:`Delete scheduled task`,deleteConfirmMsg:`Delete task "{name}"?`,createFailed:`Failed to create task`,nameRequired:`Name is required`,promptRequired:`Prompt is required`,scheduleRequired:`Schedule is required`,loading:`Loading...`,contextModeLabel:`Page context mode`,contextModeFetch:`Fetch page content`,contextModeUrlOnly:`URL only`,maxRunsLabel:`Max runs (optional)`,endAtLabel:`End time (optional)`,runHistoryLabel:`Run history`,runHistoryEmpty:`No runs yet`,runCountLabel:`Run history ({count})`,filterAll:`All`,filterEnabled:`Enabled`,filterDisabled:`Disabled`,sortLabel:`Sort`,sortCreated:`Created`,sortLastRun:`Last run`,sortUpdated:`Updated`,emptyFiltered:`No tasks match the filter`}});function Hs(e){return chrome.runtime.sendMessage(e)}function Us(e){return e?new Date(e).toLocaleString(void 0,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}):`—`}function Ws(e){return e==null?``:e<1e3?e+`ms`:e<6e4?(e/1e3).toFixed(1).replace(/\.0$/,``)+`s`:(e/6e4).toFixed(1).replace(/\.0$/,``)+`min`}function Gs(e){return e===`success`?t(`schedPanel.statusSuccess`):e===`failed`?t(`schedPanel.statusFailed`):e===`running`?t(`schedPanel.statusRunning`):``}function Ks(e){if(!e)return``;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function qs(e){let n=e.schedule||{};return n.type===`once`?n.onceMode===`relative`?t(`schedPanel.scheduleTypeOnce`)+` · `+(n.value||``)+t(`schedPanel.minutesSuffix`):t(`schedPanel.scheduleTypeOnce`)+` · `+Us(new Date(n.value).getTime()):n.type===`interval`?t(`schedPanel.scheduleTypeInterval`)+` · `+(n.value||``):n.type===`cron`?t(`schedPanel.scheduleTypeCron`)+` · `+(n.value||``):``}function Js(e){return e.enabled?e.lastStatus===`running`?`<span class="sched-badge running">${t(`schedPanel.statusRunning`)}</span>`:e.lastStatus===`failed`?`<span class="sched-badge failed">${t(`schedPanel.statusFailed`)}</span>`:e.lastStatus===`success`?`<span class="sched-badge success">${t(`schedPanel.statusSuccess`)}</span>`:``:`<span class="sched-badge muted">${t(`schedPanel.statusDisabled`)}</span>`}function Ys(){let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=e.scrollHeight)}async function Xs(e){if(e){if(y.activeSessionId!==e){let t=y.activeSessionId;try{if(await Ct(e)===!1||y.activeSessionId!==e)return}catch{return}document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:t,skipScrollRestore:!0}}));try{let{renderSessionTabs:e}=await D(async()=>{let{renderSessionTabs:e}=await import(`./context-indicator-Sf2n8eWg.js`).then(e=>e.cr);return{renderSessionTabs:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));e()}catch{}}setTimeout(Ys,500)}}function Zs(){let e=document.createElement(`div`);e.className=`schedule-panel-container`,e.id=`schedulePanelContainer`,e.innerHTML=`
51
+ `}).join(``)}function Bs(e,t){if(!t)return e;let n=t.split(/[&|]/).map(e=>e.trim()).filter(Boolean);if(n.length===0)return e;let r=n.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)),i=RegExp(`(${r.join(`|`)})`,`gi`);return e.replace(i,`<mark class="search-highlight-match">$1</mark>`)}async function Vs(e,n){if(!(!e||!n)){if(y.activeSessionId!==e)try{let n=y.activeSessionId;if(await Ct(e)===!1||y.activeSessionId!==e){A(t(`searchPanel.sessionNotExist`),`warning`);return}document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:n,skipScrollRestore:!0}}));try{let{renderSessionTabs:e}=await D(async()=>{let{renderSessionTabs:e}=await import(`./context-indicator-DjOAo_Ln.js`).then(e=>e.cr);return{renderSessionTabs:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));e()}catch(e){r.warn(`[SearchPanel] refreshsessionTab failed:`,e)}}catch(e){r.error(`[SearchPanel] switchsession failed:`,e);return}setTimeout(async()=>{let i=document.getElementById(`chatContainer`);if(!i){r.warn(`[SearchPanel] chatContainer not found`);return}let a=i.querySelector(`.message[data-message-id="${n}"]`);if(a||=i.querySelector(`[data-message-id="${n}"]`),!a){let t=Array.from(i.querySelectorAll(`[data-message-id]`),e=>e.dataset.messageId);r.warn(`[SearchPanel] positionmessage failed`,{targetSessionId:e,activeSessionId:y.activeSessionId,targetMessageId:n,typeOfMessageId:typeof n,messageIdLength:n.length,domMessageIds:t,chatContainerHtmlLen:i.innerHTML.length})}if(a)a.scrollIntoView({behavior:`instant`,block:`nearest`}),a.classList.add(`bookmark-highlight`),setTimeout(()=>{a.classList.remove(`bookmark-highlight`)},2e3);else{A(t(`searchPanel.messageDeleted`),`warning`);try{if(await te(e,n)){I=I.filter(t=>!(t.sessionId===e&&t.messageId===n));let i=document.getElementById(`searchPanelContent`),a=document.getElementById(`searchPanelCount`);i&&I.length>0?(Rs(I,Ds,i),a.textContent=t(`searchPanel.countResult`,{count:I.length})):i&&I.length===0&&(i.innerHTML=`<div class="search-panel-empty">${t(`searchPanel.noMatch`)}</div>`,a&&(a.textContent=t(`searchPanel.noResult`))),r.debug(`[SearchPanel] cleaned IndexedDB dirtydata:`,e,n)}}catch(e){r.warn(`[SearchPanel] cleanupdirtydata failed:`,e)}}},500)}}e(`zh`,{schedPanel:{toggleTitle:`定时任务`,toggleRunning:`执行中`,title:`定时任务`,newTask:`新建任务`,close:`关闭`,empty:`暂无定时任务`,nameLabel:`任务名称`,descLabel:`任务描述(可选)`,promptLabel:`任务指令`,scheduleLabel:`定时规则`,scheduleTypeOnce:`一次性`,scheduleTypeInterval:`间隔`,scheduleTypeCron:`Cron 表达式`,intervalValuePlaceholder:`例如:30m / 2h / 1d`,cronValuePlaceholder:`例如:0 9 * * *`,relativeValuePlaceholder:`例如:30`,onceModeLabel:`执行方式`,onceModeRelative:`多少分钟后`,onceModeAbsolute:`指定时间点`,valueLabelInterval:`间隔时间`,valueLabelCron:`Cron 表达式`,minutesSuffix:` 分钟后`,contextUrlLabel:`上下文网页地址(可选)`,useCurrentPage:`使用当前页面`,sessionLabel:`宿主会话`,sessionAuto:`自动(会话被删时自动新建)`,save:`保存`,cancel:`取消`,edit:`编辑`,editTitle:`编辑任务`,delete:`删除`,runNow:`立即执行`,enable:`启用`,disable:`停用`,statusSuccess:`成功`,statusFailed:`失败`,statusRunning:`运行中`,statusDisabled:`已停用`,nextRun:`下次执行`,deleted:`任务已删除`,saved:`任务已保存`,runNowToast:`已触发执行`,deleteConfirmTitle:`删除定时任务`,deleteConfirmMsg:`确定删除任务「{name}」吗?`,createFailed:`创建任务失败`,nameRequired:`请填写任务名称`,promptRequired:`请填写任务指令`,scheduleRequired:`请填写定时规则`,loading:`加载中...`,contextModeLabel:`网页上下文方式`,contextModeFetch:`抓取网页正文`,contextModeUrlOnly:`仅使用 URL(不抓正文)`,maxRunsLabel:`最多执行次数(可选)`,endAtLabel:`截止时间(可选)`,runHistoryLabel:`运行历史`,runHistoryEmpty:`暂无运行记录`,runCountLabel:`运行历史 ({count})`,filterAll:`全部`,filterEnabled:`启用中`,filterDisabled:`已停用`,sortLabel:`排序`,sortCreated:`创建时间`,sortLastRun:`最近执行`,sortUpdated:`更新时间`,emptyFiltered:`没有符合筛选条件的任务`}}),e(`en`,{schedPanel:{toggleTitle:`Scheduled tasks`,toggleRunning:`Running`,title:`Scheduled tasks`,newTask:`New task`,close:`Close`,empty:`No scheduled tasks`,nameLabel:`Name`,descLabel:`Description (optional)`,promptLabel:`Prompt`,scheduleLabel:`Schedule`,scheduleTypeOnce:`Once`,scheduleTypeInterval:`Interval`,scheduleTypeCron:`Cron expression`,intervalValuePlaceholder:`e.g. 30m / 2h / 1d`,cronValuePlaceholder:`e.g. 0 9 * * *`,relativeValuePlaceholder:`e.g. 30`,onceModeLabel:`Run mode`,onceModeRelative:`After some minutes`,onceModeAbsolute:`At specific time`,valueLabelInterval:`Interval`,valueLabelCron:`Cron expression`,minutesSuffix:` minutes later`,contextUrlLabel:`Context page URL (optional)`,useCurrentPage:`Use current page`,sessionLabel:`Host session`,sessionAuto:`Auto (recreate if deleted)`,save:`Save`,cancel:`Cancel`,edit:`Edit`,editTitle:`Edit task`,delete:`Delete`,runNow:`Run now`,enable:`Enable`,disable:`Disable`,statusSuccess:`Success`,statusFailed:`Failed`,statusRunning:`Running`,statusDisabled:`Disabled`,nextRun:`Next run`,deleted:`Task deleted`,saved:`Task saved`,runNowToast:`Execution triggered`,deleteConfirmTitle:`Delete scheduled task`,deleteConfirmMsg:`Delete task "{name}"?`,createFailed:`Failed to create task`,nameRequired:`Name is required`,promptRequired:`Prompt is required`,scheduleRequired:`Schedule is required`,loading:`Loading...`,contextModeLabel:`Page context mode`,contextModeFetch:`Fetch page content`,contextModeUrlOnly:`URL only`,maxRunsLabel:`Max runs (optional)`,endAtLabel:`End time (optional)`,runHistoryLabel:`Run history`,runHistoryEmpty:`No runs yet`,runCountLabel:`Run history ({count})`,filterAll:`All`,filterEnabled:`Enabled`,filterDisabled:`Disabled`,sortLabel:`Sort`,sortCreated:`Created`,sortLastRun:`Last run`,sortUpdated:`Updated`,emptyFiltered:`No tasks match the filter`}});function Hs(e){return chrome.runtime.sendMessage(e)}function Us(e){return e?new Date(e).toLocaleString(void 0,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}):`—`}function Ws(e){return e==null?``:e<1e3?e+`ms`:e<6e4?(e/1e3).toFixed(1).replace(/\.0$/,``)+`s`:(e/6e4).toFixed(1).replace(/\.0$/,``)+`min`}function Gs(e){return e===`success`?t(`schedPanel.statusSuccess`):e===`failed`?t(`schedPanel.statusFailed`):e===`running`?t(`schedPanel.statusRunning`):``}function Ks(e){if(!e)return``;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function qs(e){let n=e.schedule||{};return n.type===`once`?n.onceMode===`relative`?t(`schedPanel.scheduleTypeOnce`)+` · `+(n.value||``)+t(`schedPanel.minutesSuffix`):t(`schedPanel.scheduleTypeOnce`)+` · `+Us(new Date(n.value).getTime()):n.type===`interval`?t(`schedPanel.scheduleTypeInterval`)+` · `+(n.value||``):n.type===`cron`?t(`schedPanel.scheduleTypeCron`)+` · `+(n.value||``):``}function Js(e){return e.enabled?e.lastStatus===`running`?`<span class="sched-badge running">${t(`schedPanel.statusRunning`)}</span>`:e.lastStatus===`failed`?`<span class="sched-badge failed">${t(`schedPanel.statusFailed`)}</span>`:e.lastStatus===`success`?`<span class="sched-badge success">${t(`schedPanel.statusSuccess`)}</span>`:``:`<span class="sched-badge muted">${t(`schedPanel.statusDisabled`)}</span>`}function Ys(){let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=e.scrollHeight)}async function Xs(e){if(e){if(y.activeSessionId!==e){let t=y.activeSessionId;try{if(await Ct(e)===!1||y.activeSessionId!==e)return}catch{return}document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:t,skipScrollRestore:!0}}));try{let{renderSessionTabs:e}=await D(async()=>{let{renderSessionTabs:e}=await import(`./context-indicator-DjOAo_Ln.js`).then(e=>e.cr);return{renderSessionTabs:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));e()}catch{}}setTimeout(Ys,500)}}function Zs(){let e=document.createElement(`div`);e.className=`schedule-panel-container`,e.id=`schedulePanelContainer`,e.innerHTML=`
52
52
  <style>
53
53
  .schedule-panel-container { position: relative; display: flex; justify-content: flex-end; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; width: 100%; background: transparent; }
54
54
  .schedule-panel-toggle { background: rgba(var(--brand-rgb), 0.14); color: var(--brand-600); border: none; border-radius: 6px 0 0 6px; padding: 8px 4px; cursor: pointer; font-size: 14px; box-shadow: -1px 1px 4px rgba(var(--overlay-rgb), 0.12); transition: all 0.3s ease; display: flex; align-items: center; justify-content: center; }
@@ -396,7 +396,7 @@ import{a as e,c as t,i as n,l as r,n as i,r as a,s as o}from"./i18n-5c8prpFJ.js"
396
396
  class="todo-menu-item${e.danger?` danger`:``}">
397
397
  ${e.icon||``}<span>${k(e.label)}</span>${pd(e.shortcut)}
398
398
  </button>`}function hd(e,t,n){let r=dd();r.innerHTML=t.map((e,t)=>t===0&&e.divider?{...e,divider:!1}:e).map(e=>md(e,n)).join(``);let i=e.getBoundingClientRect(),a=r.offsetWidth||168,o=r.offsetHeight||132,s=Math.min(i.right-a,window.innerWidth-a-8);s=Math.max(8,s);let c=i.bottom+4;c+o>window.innerHeight-8&&(c=Math.max(8,i.top-o-4)),r.style.left=`${s}px`,r.style.top=`${c}px`}function gd(e){if(e.status===O.DONE){let n=He(e),r=[{action:`restore`,label:t(`todo.restoreTo`,{status:Tu(n)}),icon:B.undo,shortcut:`Alt+D`,divider:!0}];return n!==O.PENDING&&r.push({action:`set-pending`,label:t(`todo.backToPending`),icon:B.circle}),r}return e.status===O.DOING?[{action:`set-done`,label:t(`todo.markDone`),icon:B.check,shortcut:`Alt+D`,divider:!0},{action:`set-pending`,label:t(`todo.backToPending`),icon:B.circle}]:[{action:`set-doing`,label:t(`todo.startDoing`),icon:B.play,divider:!0},{action:`set-done`,label:t(`todo.markDone`),icon:B.check,shortcut:`Alt+D`}]}function _d(e,n){let r=Fu(n);r&&hd(e,[...gd(r),{swatches:!0,label:t(`todo.priority`),current:r.priority||``,shortcut:`Alt+P`,divider:!0},{action:`edit-title`,label:t(`todo.editTitleAction`),icon:B.edit,divider:!0},{action:`edit-note`,label:r.note?t(`todo.editNote`):t(`todo.addNote`),icon:B.note,shortcut:`Alt+B`},{action:`set-due`,label:t(`todo.setDue`),icon:B.calendar},{action:`edit-link`,label:r.link?t(`todo.editLink`):t(`todo.addLink`),icon:B.link,shortcut:`Alt+L`},{action:`delete`,label:t(`todo.delete`),icon:B.trash,danger:!0,divider:!0}],n)}function vd(e){let t=yd();t.length!==0&&hd(e,t,``)}function yd(){return[{action:`stats`,label:t(`todo.statsEntry`),icon:B.chart,divider:!0},{action:`export-options`,label:t(`todo.exportEntry`),icon:B.download,divider:!0},{action:`import-options`,label:t(`todo.importEntry`),icon:B.upload}]}async function bd(){let{active:e,done:t}=_c(),n=await ol({counts:{all:e.length+t.length,active:e.length,done:t.length}});n&&xd(n.scope,n.format)}function xd(e,n){let{active:i,done:a}=_c(),o=[...i,...a];if(xe(o,e).length===0){A(t(`todo.exportEmptyToast`),`info`);return}try{A(t(`todo.exportedToast`,{name:zc(o,{scope:e,format:n})}),`success`)}catch(e){r.error(`[Todo] export failed:`,e),A(t(`todo.exportFailedToast`),`error`)}}async function Sd(){let e=await Bc();if(!e)return;let n=await Vc(e);if(!n.ok){A(t(n.reason===`json`?`todo.importJsonError`:`todo.importFormatError`),`error`);return}let{active:r,done:i}=_c(),a=await sl({count:n.todos.length,existing:r.length+i.length});if(!a)return;zl=`active`,q();let o=await Ac(n.todos,a);if(!o.ok){A(t(o.reason===`empty`?`todo.importEmptyToast`:`todo.importFailedToast`),`error`);return}if(o.added===0){A(t(`todo.importNothingNewToast`,{skipped:o.skipped}),`info`);return}A(t(`todo.importedToast`,{added:o.added,skipped:o.skipped}),`success`)}async function Cd(e,n){let r=Fu(n);switch(e){case`set-doing`:J(Sc(n,O.DOING));return;case`set-pending`:J(Sc(n,O.PENDING));return;case`set-done`:Lu(n);return;case`restore`:Ru(n);return;case`edit-title`:Zu(n);return;case`edit-note`:Xu(n);return;case`set-due`:Vl=n,Zl=!0,q();return;case`edit-link`:$u(n);return;case`stats`:Sl();return;case`export-options`:bd();return;case`import-options`:Sd();return;case`delete`:await ud(t(`todo.deleteConfirmMsg`,{title:r?.title||``}),t(`todo.deleteConfirmTitle`))&&J(Dc(n),t(`todo.deletedToast`));return;default:}}function wd(e,t={}){let{active:n,done:r}=_c(),i=[...n,...r].find(t=>t.id===e);return i?Le(i,t):``}function Td(e){let n=wd(e);if(!n){A(t(`todo.emptyDigestToast`),`info`);return}let r=document.getElementById(`userInput`);if(!r){A(t(`todo.noInputToast`),`error`);return}let i=r.value.replace(/\s+$/,``);r.value=i?`${i}\n\n${n}`:n,r.dispatchEvent(new Event(`input`,{bubbles:!0})),r.focus(),r.selectionStart=r.selectionEnd=r.value.length,rt(),ou(),A(t(`todo.filledToast`),`success`)}function Ed(e){let n=wd(e,{plain:!0});if(!n){A(t(`todo.emptyDigestToast`),`info`);return}Dd(n,t(`todo.copiedToast`))}function Dd(e,n){try{navigator.clipboard.writeText(e).then(()=>{A(n,`success`)}).catch(e=>{r.warn(`[Todo] copy failed:`,e),A(t(`todo.copyFailed`),`error`)})}catch(e){r.warn(`[Todo] clipboard unavailable:`,e),A(t(`todo.copyFailed`),`error`)}}function Od(e){let t=e.target.closest?.(`.todo-item[draggable="true"]`);if(!t)return;let n=t.closest(`.todo-list[data-group="active"]`);if(!n)return;let r=Array.from(n.querySelectorAll(`.todo-item`));Ul={id:t.dataset.id,from:r.indexOf(t),list:n},t.classList.add(`dragging`);let{active:i,done:a}=_c(),o=[...i,...a].find(e=>e.id===t.dataset.id);try{e.dataTransfer.effectAllowed=`copyMove`,e.dataTransfer.setData(`text/plain`,Le(o)||t.dataset.id)}catch{}}function kd(e){if(!Ul)return;e.preventDefault();let t=Ul.list;if(!t||!t.isConnected)return;let n=Array.from(t.querySelectorAll(`.todo-item`)).filter(e=>!e.classList.contains(`dragging`)),r=n.length;for(let t=0;t<n.length;t++){let i=n[t].getBoundingClientRect();if(e.clientY<i.top+i.height/2){r=t;break}}let i=Ad();r>=n.length?t.appendChild(i):n[r].before(i)}function Ad(){let e=U.querySelector(`.todo-insert`);return e||(e=document.createElement(`div`),e.className=`todo-insert`,e)}function jd(e){if(!Ul)return;e.preventDefault();let t=Ul.list,n=U.querySelector(`.todo-insert`),r=Ul.from;if(n&&t){let e=Array.from(t.querySelectorAll(`.todo-item`)).filter(e=>!e.classList.contains(`dragging`)),i=e.findIndex(e=>n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING);r=i===-1?e.length:i}let i=Ul.from;Md(),i!==r&&J(Oc(i,r))}function Md(){Ul=null,U?.querySelectorAll(`.todo-item.dragging`).forEach(e=>e.classList.remove(`dragging`)),U?.querySelector(`.todo-insert`)?.remove()}var Nd=`—`,Pd=[{labelKey:`versionInfo.website`,url:`https://xiweicheng.github.io/ai-helper/`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/></svg>`},{labelKey:`versionInfo.discussions`,url:`https://github.com/xiweicheng/ai-helper/discussions`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z"/></svg>`},{labelKey:`versionInfo.reportIssue`,url:`https://github.com/xiweicheng/ai-helper/issues/new`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"/></svg>`},{labelKey:`versionInfo.githubRepo`,url:`https://github.com/xiweicheng/ai-helper`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 .5C5.73.5.5 5.73.5 12c0 5.08 3.29 9.39 7.86 10.91.58.11.79-.25.79-.56 0-.28-.01-1.02-.02-2-3.2.7-3.88-1.54-3.88-1.54-.52-1.33-1.28-1.69-1.28-1.69-1.04-.71.08-.7.08-.7 1.15.08 1.76 1.19 1.76 1.19 1.03 1.76 2.7 1.25 3.36.96.1-.75.4-1.25.72-1.54-2.55-.29-5.24-1.28-5.24-5.68 0-1.26.45-2.28 1.19-3.09-.12-.29-.52-1.46.11-3.05 0 0 .97-.31 3.18 1.18a11.1 11.1 0 012.9-.39c.98 0 1.97.13 2.9.39 2.2-1.49 3.17-1.18 3.17-1.18.63 1.59.23 2.76.11 3.05.74.81 1.19 1.83 1.19 3.09 0 4.41-2.69 5.38-5.25 5.67.41.35.78 1.05.78 2.12 0 1.53-.01 2.76-.01 3.14 0 .31.21.68.8.56A11.51 11.51 0 0023.5 12C23.5 5.73 18.27.5 12 .5z"/></svg>`},{labelKey:`versionInfo.giteeRepo`,url:`https://gitee.com/xiweicheng/ai-helper`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M11.984 0A12 12 0 000 12a12 12 0 0012 12 12 12 0 0012-12A12 12 0 0012 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 01-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 00-.592-.593h-4.15a.592.592 0 01-.592-.592v-1.482a.593.593 0 01.593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 01-4 4H8.444a3.556 3.556 0 01-3.555-3.556V8.89a3.556 3.556 0 013.555-3.556h9.63z"/></svg>`}];function Fd(e){let t=e=>typeof e==`string`?e.trim():``,n=e&&typeof e==`object`?e:{};return{version:t(n.version),tag:t(n.tag),commitId:t(n.commitId),publishedAt:t(n.publishedAt)}}function Id(e){if(!e)return Nd;let t=Date.parse(e);return Number.isNaN(t)?Nd:new Date(t).toLocaleString()}function Ld(e){let n=Fd(pt),r=[{label:t(`versionInfo.version`),value:n.version?`v${n.version}`:Nd},{label:t(`versionInfo.tag`),value:n.tag||Nd},{label:t(`versionInfo.commit`),value:n.commitId?n.commitId.slice(0,8):Nd,title:n.commitId,mono:!0},{label:t(`versionInfo.publishedAt`),value:Id(n.publishedAt)}];e.textContent=``;for(let t of r){let n=document.createElement(`div`);n.className=`version-info-row`;let r=document.createElement(`div`);r.className=`version-info-label`,r.textContent=t.label;let i=document.createElement(`div`);i.className=t.mono?`version-info-value mono`:`version-info-value`,i.textContent=t.value,t.title&&(i.title=t.title),n.appendChild(r),n.appendChild(i),e.appendChild(n)}}function Rd(e){e.textContent=``;for(let n of Pd){let r=document.createElement(`div`);r.className=`version-info-link`,r.title=n.url;let i=document.createElement(`span`);i.className=`version-info-link-icon`,i.innerHTML=n.icon;let a=document.createElement(`span`);a.className=`version-info-link-label`,a.textContent=t(n.labelKey);let o=document.createElement(`span`);o.className=`version-info-link-arrow`,o.textContent=`↗`,r.appendChild(i),r.appendChild(a),r.appendChild(o),r.addEventListener(`click`,()=>{chrome.tabs.create({url:n.url})}),e.appendChild(r)}}function zd(){let e=Fd(pt);return[`AI Helper v${e.version||Nd}`,`${t(`versionInfo.tag`)}: ${e.tag||Nd}`,`${t(`versionInfo.commit`)}: ${e.commitId||Nd}`,`${t(`versionInfo.publishedAt`)}: ${Id(e.publishedAt)}`].join(`
399
- `)}function Bd(){let e=document.getElementById(`versionInfoBtn`),n=document.getElementById(`versionInfoModal`),r=document.getElementById(`versionInfoCloseBtn`),i=document.getElementById(`versionInfoCopyBtn`),a=document.getElementById(`versionInfoList`),o=document.getElementById(`versionInfoLinks`);if(!e||!n||!a)return;let s=()=>{n.style.display=`none`};e.addEventListener(`click`,e=>{e.stopPropagation();let t=document.getElementById(`headerMoreDropdown`);t&&t.classList.remove(`show`),Ld(a),o&&Rd(o),n.style.display=`flex`}),r&&r.addEventListener(`click`,s),n.addEventListener(`click`,e=>{e.target===n&&s()}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&n.style.display===`flex`&&s()}),i&&i.addEventListener(`click`,async()=>{try{await navigator.clipboard.writeText(zd()),A(t(`common.copySuccess`),`success`)}catch{A(t(`common.copyFailed`),`error`)}})}var Vd=null;function Hd(){if(!Vd)return;Vd.classList.remove(`open`);let e=Vd.parentElement?Vd.parentElement.querySelector(`.section-select-row`):null;e&&e.classList.remove(`open`),Vd=null}function Ud(){return`<input type="search" class="section-select-search" placeholder="${t(`sectionSelect.searchPlaceholder`)}" data-i18n-placeholder="sectionSelect.searchPlaceholder" spellcheck="false">`}function Wd(e,n){if(!e)return;let r=String(n||``).trim().toLowerCase(),i=Array.from(e.children).filter(e=>e.hasAttribute(`data-value`)),a=0;for(let e of i){let t=!r||e.textContent.toLowerCase().includes(r);e.style.display=t?``:`none`,t&&(a+=1)}let o=e.querySelector(`.section-select-empty`);r&&a===0?(o||(o=document.createElement(`div`),o.className=`section-select-empty`,e.appendChild(o)),o.textContent=t(`sectionSelect.noMatch`)):o&&o.remove()}function Gd(e,t){Hd(),e.classList.add(`open`),t.classList.add(`open`),Vd=e;let n=e.querySelector(`.section-select-search`);n&&(n.value=``,Wd(e,``),n.focus())}document.addEventListener(`click`,e=>{let t=e.target.closest(`.section-select-row`);if(t){let e=t.parentElement.querySelector(`.section-select-list`);if(!e)return;e===Vd?Hd():Gd(e,t);return}Vd&&!Vd.parentElement.contains(e.target)&&Hd()}),document.addEventListener(`input`,e=>{let t=e.target;if(!t||!t.classList||!t.classList.contains(`section-select-search`))return;let n=t.closest(`.section-select-list`);n&&Wd(n,t.value)});var Kd=!1;async function qd(){document.getElementById(`providerList`)&&(Kd||(Kd=!0,Xd(),Zd()),await Jd())}async function Jd(){let e=document.getElementById(`providerList`),t=document.getElementById(`providerSelectValue`),n=document.getElementById(`providerSelectHost`);if(!e)return;let r=await x(),i=r.profiles.find(e=>e.id===r.activeProfileId)||r.profiles[0];t&&(t.textContent=i?i.name:``),n&&(n.textContent=i?se(i.apiBase):``),e.innerHTML=Ud();let a=[...r.profiles].sort((e,t)=>w(e.name,t.name));for(let t of a){let n=!!i&&t.id===i.id,r=document.createElement(`div`);r.className=`provider-option`+(n?` selected`:``),r.dataset.value=t.id;let a=document.createElement(`span`);a.className=`provider-option-check`,a.textContent=n?`✓`:``,r.appendChild(a);let o=document.createElement(`span`);o.className=`provider-option-left`,o.textContent=t.name,r.appendChild(o);let s=se(t.apiBase);if(s){let e=document.createElement(`span`);e.className=`provider-option-right`,e.textContent=s,r.appendChild(e)}r.addEventListener(`click`,e=>{e.stopPropagation(),Hd(),Yd(t.id)}),e.appendChild(r)}}async function Yd(e){if(e===(await x()).activeProfileId)return;let t=await ae(e);t&&(await Jd(),r.debug(`[SidePanel] provider switched:`,t.name))}function Xd(){let e=document.getElementById(`providerManageBtn`);e&&e.addEventListener(`click`,async e=>{e.stopPropagation();let t=chrome.runtime.getURL(`options.html#basic`),n=await chrome.tabs.query({url:chrome.runtime.getURL(`options.html`)});n.length>0?await chrome.tabs.update(n[0].id,{active:!0,url:t}):await chrome.tabs.create({url:t})})}function Zd(){chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&(e.modelProfiles||e.activeProfileId)&&Jd()})}var Qd=0;function $d(e,t){let n=e&&e.nodeType===1?e:e?e.parentElement:null;for(let e=n;e&&e!==t;e=e.parentElement)if(getComputedStyle(e).position===`absolute`)return!0;return!1}function ef(e){let t=[];return e.querySelectorAll(`*`).forEach(e=>{getComputedStyle(e).position===`absolute`&&e.getClientRects().length>0&&t.push(e)}),t}function tf(e){e.forEach(e=>{(e.getAnimations?.()||[]).forEach(e=>{e.playState!==`idle`&&e.finish?.()})})}function nf(){Qd||=requestAnimationFrame(()=>{Qd=0,of()})}function rf(){let e=document.getElementById(`selectionToggleGroup`),t=document.getElementById(`inputAddMenuSwitches`);e&&t&&e.parentElement!==t&&t.appendChild(e)}function af(){let e=document.getElementById(`selectionToggleGroup`),t=document.querySelector(`.input-bottom-left`);e&&t&&e.parentElement!==t&&t.appendChild(e)}function of(){let e=document.querySelector(`.input-bottom-row`),t=e?.closest(`.input-container`)||null;if(!(!e||!t)){t.classList.add(`measuring`);try{sf(e,t)}finally{t.classList.remove(`measuring`)}}}function sf(e,t){t.classList.remove(`temp-collapsed`,`agent-collapsed`,`switches-icon`,`selection-in-menu`),af();let n=ef(e),r=n.map(e=>e.style.display);n.forEach(e=>{e.style.display=`none`});let i=()=>{n.forEach((e,t)=>{e.style.display=r[t]}),tf(n)};if(e.scrollWidth<=e.clientWidth){i();return}if(t.classList.add(`temp-collapsed`),e.scrollWidth<=e.clientWidth){i();return}if(t.classList.add(`agent-collapsed`),e.scrollWidth<=e.clientWidth){i();return}if(t.classList.add(`switches-icon`),e.scrollWidth<=e.clientWidth){i();return}t.classList.add(`selection-in-menu`),rf(),i()}function cf(){of(),window.addEventListener(`resize`,nf);let e=document.querySelector(`.input-bottom-row`),t=e?.closest(`.input-container`)||null;if(t&&typeof ResizeObserver<`u`){let e=t.clientWidth;new ResizeObserver(t=>{let n=t[0]?.contentRect?.width??0;Math.abs(n-e)<1||(e=n,nf())}).observe(t)}e&&typeof MutationObserver<`u`&&new MutationObserver(t=>{let n=document.getElementById(`selectionToggleGroup`),r=e=>!!n&&[...e.addedNodes,...e.removedNodes].includes(n);t.some(t=>!$d(t.target,e)&&!r(t))&&nf()}).observe(e,{subtree:!0,childList:!0,characterData:!0})}var lf=`footer-compact`,uf=`footer-compact-ultra`,df=`footer-wrap`,ff=`footer-measuring`,pf=0;function mf(){pf||=requestAnimationFrame(()=>{pf=0,gf()})}function hf(e){if(e.target.nodeType===1&&e.target.closest(`.message-footer`))return!0;for(let t of e.addedNodes)if(t.nodeType===1&&(t.classList?.contains(`message-footer`)||t.querySelector?.(`.message-footer`)||t.closest?.(`.message-footer`)))return!0;return!1}function gf(){let e=document.getElementById(`chatContainer`);if(!e)return;let t=e.querySelectorAll(`.message.assistant .message-footer`);if(t.length){t.forEach(e=>{e.classList.add(ff),e.classList.remove(lf,uf,df)});try{let e=[...t].filter(e=>e.clientWidth>0&&e.scrollWidth>e.clientWidth);e.forEach(e=>e.classList.add(lf)),e=e.filter(e=>e.scrollWidth>e.clientWidth),e.forEach(e=>e.classList.add(uf)),e=e.filter(e=>e.scrollWidth>e.clientWidth),e.forEach(e=>e.classList.add(df))}finally{t.forEach(e=>e.classList.remove(ff))}}}function _f(){let e=document.getElementById(`chatContainer`);if(e){if(gf(),window.addEventListener(`resize`,mf),typeof ResizeObserver<`u`){let t=e.clientWidth;new ResizeObserver(e=>{let n=e[0]?.contentRect?.width??0;Math.abs(n-t)<1||(t=n,mf())}).observe(e)}typeof MutationObserver<`u`&&new MutationObserver(e=>{e.some(hf)&&mf()}).observe(e,{subtree:!0,childList:!0}),document.fonts?.ready?.then(mf).catch(()=>{})}}e(`zh`,{fileSelector:{workspaceTitle:`工作目录`,switchHint:`方向键切换 · Enter添加到文件问答 · Esc取消`,searching:`搜索中...`,noMatch:`没有匹配的文件或目录`,noWorkspace:`暂无工作目录,请先连接 Agent`,loadFailed:`加载失败: {error}`,truncated:`仅显示前 {count} 条,请继续输入以缩小范围`}}),e(`en`,{fileSelector:{workspaceTitle:`Workspace`,switchHint:`↑↓ navigate · Enter attach · Esc cancel`,searching:`Searching...`,noMatch:`No matching file or directory`,noWorkspace:`No workspace directory. Connect an Agent first.`,loadFailed:`Load failed: {error}`,truncated:`Showing top {count} results. Keep typing to narrow down.`}});var vf=50,yf=200,bf=200,xf=0,Sf=null,Cf=[];function wf(e){return(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`)}function Tf(e){let t=document.getElementById(`fileAtTitlePath`);if(!t)return;let n=e?wf(e):``;t.textContent=n,t.title=n}async function Ef(e=``){let t=document.getElementById(`fileAtSelector`),n=document.getElementById(`fileAtDropdown`);if(!t||!n)return;n.dataset.focusGuard||(n.dataset.focusGuard=`1`,n.addEventListener(`mousedown`,e=>{e.target.closest(`.prompt-item`)&&e.preventDefault()}));let r=document.getElementById(`fileAtWorkspaceOpenBtn`);r&&!r.dataset.bound&&(r.dataset.bound=`1`,r.addEventListener(`click`,async e=>{e.stopPropagation(),Df(),await Mr()})),ot(),t.style.display=`block`,n.classList.add(`show`),await Of(e)}function Df(){let e=document.getElementById(`fileAtSelector`),t=document.getElementById(`fileAtDropdown`);e&&(e.style.display=`none`),t&&t.classList.remove(`show`),y.selectedFileAtIndex=-1,Sf&&=(clearTimeout(Sf),null),xf++}function Of(e=``){let n=document.getElementById(`fileAtList`);if(!n)return;let i=++xf,a=e.trim();Sf&&clearTimeout(Sf);let o=async()=>{try{let e=await va();if(i!==xf)return;if(Tf(e),!e){n.innerHTML=`<div class="prompt-empty">${t(`fileSelector.noWorkspace`)}</div>`,y.selectedFileAtIndex=-1;return}let r;if(r=a?await ma(e,a,yf):((await ha(e)).entries||[]).map(t=>({name:t.name,type:t.type||`file`,size:t.size,mtime:t.mtime,fullPath:wf(`${e}/${t.name}`)})),i!==xf)return;Af(r,a,n,e)}catch(e){if(i!==xf)return;r.warn(`[FileAtSelector] search failed:`,e.message),n.innerHTML=`<div class="prompt-empty">${t(`fileSelector.loadFailed`,{error:e.message})}</div>`,y.selectedFileAtIndex=-1}};a?(n.innerHTML=`<div class="prompt-empty">${t(`fileSelector.searching`)}</div>`,Sf=setTimeout(o,bf)):Sf=setTimeout(o,0)}function kf(e,t){let n=t.toLowerCase();return[...e].sort((e,t)=>{let r=(e.name||``).toLowerCase(),i=(t.name||``).toLowerCase();if(n){let e=+!!r.startsWith(n),t=+!!i.startsWith(n);if(e!==t)return t-e}let a=e.mtime||0,o=t.mtime||0;if(a!==o)return o-a;let s=e.type===`directory`?0:1,c=t.type===`directory`?0:1;return s===c?r.localeCompare(i):s-c})}function Af(e,n,r,i){let a=kf(e,n),o=a.slice(0,vf),s=a.length>vf,c=wf(i);if(o.length===0){r.innerHTML=`<div class="prompt-empty">${t(`fileSelector.noMatch`)}</div>`,y.selectedFileAtIndex=-1;return}if(y.selectedFileAtIndex=0,Cf=o,r.innerHTML=o.map((e,t)=>{let n=_a(e.name,e.type),r=wf(e.fullPath),i=r.startsWith(c)?r.substring(c.length).replace(/^\//,``):r;return`
399
+ `)}function Bd(){let e=document.getElementById(`versionInfoBtn`),n=document.getElementById(`versionInfoModal`),r=document.getElementById(`versionInfoCloseBtn`),i=document.getElementById(`versionInfoCopyBtn`),a=document.getElementById(`versionInfoList`),o=document.getElementById(`versionInfoLinks`);if(!e||!n||!a)return;let s=()=>{n.style.display=`none`};e.addEventListener(`click`,e=>{e.stopPropagation();let t=document.getElementById(`headerMoreDropdown`);t&&t.classList.remove(`show`),Ld(a),o&&Rd(o),n.style.display=`flex`}),r&&r.addEventListener(`click`,s),n.addEventListener(`click`,e=>{e.target===n&&s()}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&n.style.display===`flex`&&s()}),i&&i.addEventListener(`click`,async()=>{try{await navigator.clipboard.writeText(zd()),A(t(`common.copySuccess`),`success`)}catch{A(t(`common.copyFailed`),`error`)}})}var Vd=null;function Hd(){if(!Vd)return;Vd.classList.remove(`open`);let e=Vd.parentElement?Vd.parentElement.querySelector(`.section-select-row`):null;e&&e.classList.remove(`open`),Vd=null}function Ud(){return`<input type="search" class="section-select-search" placeholder="${t(`sectionSelect.searchPlaceholder`)}" data-i18n-placeholder="sectionSelect.searchPlaceholder" spellcheck="false">`}function Wd(e,n){if(!e)return;let r=String(n||``).trim().toLowerCase(),i=Array.from(e.children).filter(e=>e.hasAttribute(`data-value`)),a=0;for(let e of i){let t=!r||e.textContent.toLowerCase().includes(r);e.style.display=t?``:`none`,t&&(a+=1)}let o=e.querySelector(`.section-select-empty`);r&&a===0?(o||(o=document.createElement(`div`),o.className=`section-select-empty`,e.appendChild(o)),o.textContent=t(`sectionSelect.noMatch`)):o&&o.remove()}function Gd(e,t){Hd(),e.classList.add(`open`),t.classList.add(`open`),Vd=e;let n=e.querySelector(`.section-select-search`);n&&(n.value=``,Wd(e,``),n.focus())}document.addEventListener(`click`,e=>{let t=e.target.closest(`.section-select-row`);if(t){let e=t.parentElement.querySelector(`.section-select-list`);if(!e)return;e===Vd?Hd():Gd(e,t);return}Vd&&!Vd.parentElement.contains(e.target)&&Hd()}),document.addEventListener(`input`,e=>{let t=e.target;if(!t||!t.classList||!t.classList.contains(`section-select-search`))return;let n=t.closest(`.section-select-list`);n&&Wd(n,t.value)});var Kd=!1;async function qd(){document.getElementById(`providerList`)&&(Kd||(Kd=!0,Xd(),Zd()),await Jd())}async function Jd(){let e=document.getElementById(`providerList`),t=document.getElementById(`providerSelectValue`),n=document.getElementById(`providerSelectHost`);if(!e)return;let r=await x(),i=r.profiles.find(e=>e.id===r.activeProfileId)||r.profiles[0];t&&(t.textContent=i?i.name:``),n&&(n.textContent=i?se(i.apiBase):``),e.innerHTML=Ud();let a=[...r.profiles].sort((e,t)=>w(e.name,t.name));for(let t of a){let n=!!i&&t.id===i.id,r=document.createElement(`div`);r.className=`provider-option`+(n?` selected`:``),r.dataset.value=t.id;let a=document.createElement(`span`);a.className=`provider-option-check`,a.textContent=n?`✓`:``,r.appendChild(a);let o=document.createElement(`span`);o.className=`provider-option-left`,o.textContent=t.name,r.appendChild(o);let s=se(t.apiBase);if(s){let e=document.createElement(`span`);e.className=`provider-option-right`,e.textContent=s,r.appendChild(e)}r.addEventListener(`click`,e=>{e.stopPropagation(),Hd(),Yd(t.id)}),e.appendChild(r)}}async function Yd(e){if(e===(await x()).activeProfileId)return;let t=await ae(e);t&&(await Jd(),r.debug(`[SidePanel] provider switched:`,t.name))}function Xd(){let e=document.getElementById(`providerManageBtn`);e&&e.addEventListener(`click`,async e=>{e.stopPropagation();let t=chrome.runtime.getURL(`options.html#basic`),n=await chrome.tabs.query({url:chrome.runtime.getURL(`options.html`)});n.length>0?await chrome.tabs.update(n[0].id,{active:!0,url:t}):await chrome.tabs.create({url:t})})}function Zd(){chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&(e.modelProfiles||e.activeProfileId)&&Jd()})}var Qd=0;function $d(e,t){let n=e&&e.nodeType===1?e:e?e.parentElement:null;for(let e=n;e&&e!==t;e=e.parentElement)if(getComputedStyle(e).position===`absolute`)return!0;return!1}function ef(e){let t=[];return e.querySelectorAll(`*`).forEach(e=>{getComputedStyle(e).position===`absolute`&&e.getClientRects().length>0&&t.push(e)}),t}function tf(e){e.forEach(e=>{(e.getAnimations?.()||[]).forEach(e=>{e.playState!==`idle`&&e.finish?.()})})}function nf(){Qd||=requestAnimationFrame(()=>{Qd=0,of()})}function rf(){let e=document.getElementById(`selectionToggleGroup`),t=document.getElementById(`inputAddMenuSwitches`);e&&t&&e.parentElement!==t&&t.appendChild(e)}function af(){let e=document.getElementById(`selectionToggleGroup`),t=document.querySelector(`.input-bottom-left`);e&&t&&e.parentElement!==t&&t.appendChild(e)}function of(){let e=document.querySelector(`.input-bottom-row`),t=e?.closest(`.input-container`)||null;if(!(!e||!t)){t.classList.add(`measuring`);try{sf(e,t)}finally{t.classList.remove(`measuring`)}}}function sf(e,t){t.classList.remove(`temp-collapsed`,`agent-collapsed`,`switches-icon`,`selection-in-menu`),af();let n=ef(e),r=n.map(e=>e.style.display);n.forEach(e=>{e.style.display=`none`});let i=()=>{n.forEach((e,t)=>{e.style.display=r[t]}),tf(n)};if(e.scrollWidth<=e.clientWidth){i();return}if(t.classList.add(`temp-collapsed`),e.scrollWidth<=e.clientWidth){i();return}if(t.classList.add(`agent-collapsed`),e.scrollWidth<=e.clientWidth){i();return}if(t.classList.add(`switches-icon`),e.scrollWidth<=e.clientWidth){i();return}t.classList.add(`selection-in-menu`),rf(),i()}function cf(){of(),window.addEventListener(`resize`,nf);let e=document.querySelector(`.input-bottom-row`),t=e?.closest(`.input-container`)||null;if(t&&typeof ResizeObserver<`u`){let e=t.clientWidth;new ResizeObserver(t=>{let n=t[0]?.contentRect?.width??0;Math.abs(n-e)<1||(e=n,nf())}).observe(t)}e&&typeof MutationObserver<`u`&&new MutationObserver(t=>{let n=document.getElementById(`selectionToggleGroup`),r=e=>!!n&&[...e.addedNodes,...e.removedNodes].includes(n);t.some(t=>!$d(t.target,e)&&!r(t))&&nf()}).observe(e,{subtree:!0,childList:!0,characterData:!0})}var lf=`footer-compact`,uf=`footer-compact-ultra`,df=`footer-wrap`,ff=`footer-measuring`,pf=0;function mf(){pf||=requestAnimationFrame(()=>{pf=0,gf()})}function hf(e){if(e.target.nodeType===1&&e.target.closest(`.message-footer`))return!0;for(let t of e.addedNodes)if(t.nodeType===1&&(t.classList?.contains(`message-footer`)||t.querySelector?.(`.message-footer`)||t.closest?.(`.message-footer`)))return!0;return!1}function gf(){let e=document.getElementById(`chatContainer`);if(!e)return;let t=e.querySelectorAll(`.message.assistant .message-footer`);if(t.length){t.forEach(e=>{e.classList.add(ff),e.classList.remove(lf,uf,df)});try{let e=[...t].filter(e=>e.clientWidth>0&&e.scrollWidth>e.clientWidth);e.forEach(e=>e.classList.add(lf)),e=e.filter(e=>e.scrollWidth>e.clientWidth),e.forEach(e=>e.classList.add(uf)),e=e.filter(e=>e.scrollWidth>e.clientWidth),e.forEach(e=>e.classList.add(df))}finally{t.forEach(e=>e.classList.remove(ff))}}}function _f(){let e=document.getElementById(`chatContainer`);if(e){if(gf(),window.addEventListener(`resize`,mf),typeof ResizeObserver<`u`){let t=e.clientWidth;new ResizeObserver(()=>{let n=e.clientWidth;Math.abs(n-t)<1||(t=n,mf())}).observe(e)}typeof MutationObserver<`u`&&new MutationObserver(e=>{e.some(hf)&&mf()}).observe(e,{subtree:!0,childList:!0}),document.fonts?.ready?.then(mf).catch(()=>{})}}e(`zh`,{fileSelector:{workspaceTitle:`工作目录`,switchHint:`方向键切换 · Enter添加到文件问答 · Esc取消`,searching:`搜索中...`,noMatch:`没有匹配的文件或目录`,noWorkspace:`暂无工作目录,请先连接 Agent`,loadFailed:`加载失败: {error}`,truncated:`仅显示前 {count} 条,请继续输入以缩小范围`}}),e(`en`,{fileSelector:{workspaceTitle:`Workspace`,switchHint:`↑↓ navigate · Enter attach · Esc cancel`,searching:`Searching...`,noMatch:`No matching file or directory`,noWorkspace:`No workspace directory. Connect an Agent first.`,loadFailed:`Load failed: {error}`,truncated:`Showing top {count} results. Keep typing to narrow down.`}});var vf=50,yf=200,bf=200,xf=0,Sf=null,Cf=[];function wf(e){return(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`)}function Tf(e){let t=document.getElementById(`fileAtTitlePath`);if(!t)return;let n=e?wf(e):``;t.textContent=n,t.title=n}async function Ef(e=``){let t=document.getElementById(`fileAtSelector`),n=document.getElementById(`fileAtDropdown`);if(!t||!n)return;n.dataset.focusGuard||(n.dataset.focusGuard=`1`,n.addEventListener(`mousedown`,e=>{e.target.closest(`.prompt-item`)&&e.preventDefault()}));let r=document.getElementById(`fileAtWorkspaceOpenBtn`);r&&!r.dataset.bound&&(r.dataset.bound=`1`,r.addEventListener(`click`,async e=>{e.stopPropagation(),Df(),await Mr()})),ot(),t.style.display=`block`,n.classList.add(`show`),await Of(e)}function Df(){let e=document.getElementById(`fileAtSelector`),t=document.getElementById(`fileAtDropdown`);e&&(e.style.display=`none`),t&&t.classList.remove(`show`),y.selectedFileAtIndex=-1,Sf&&=(clearTimeout(Sf),null),xf++}function Of(e=``){let n=document.getElementById(`fileAtList`);if(!n)return;let i=++xf,a=e.trim();Sf&&clearTimeout(Sf);let o=async()=>{try{let e=await va();if(i!==xf)return;if(Tf(e),!e){n.innerHTML=`<div class="prompt-empty">${t(`fileSelector.noWorkspace`)}</div>`,y.selectedFileAtIndex=-1;return}let r;if(r=a?await ma(e,a,yf):((await ha(e)).entries||[]).map(t=>({name:t.name,type:t.type||`file`,size:t.size,mtime:t.mtime,fullPath:wf(`${e}/${t.name}`)})),i!==xf)return;Af(r,a,n,e)}catch(e){if(i!==xf)return;r.warn(`[FileAtSelector] search failed:`,e.message),n.innerHTML=`<div class="prompt-empty">${t(`fileSelector.loadFailed`,{error:e.message})}</div>`,y.selectedFileAtIndex=-1}};a?(n.innerHTML=`<div class="prompt-empty">${t(`fileSelector.searching`)}</div>`,Sf=setTimeout(o,bf)):Sf=setTimeout(o,0)}function kf(e,t){let n=t.toLowerCase();return[...e].sort((e,t)=>{let r=(e.name||``).toLowerCase(),i=(t.name||``).toLowerCase();if(n){let e=+!!r.startsWith(n),t=+!!i.startsWith(n);if(e!==t)return t-e}let a=e.mtime||0,o=t.mtime||0;if(a!==o)return o-a;let s=e.type===`directory`?0:1,c=t.type===`directory`?0:1;return s===c?r.localeCompare(i):s-c})}function Af(e,n,r,i){let a=kf(e,n),o=a.slice(0,vf),s=a.length>vf,c=wf(i);if(o.length===0){r.innerHTML=`<div class="prompt-empty">${t(`fileSelector.noMatch`)}</div>`,y.selectedFileAtIndex=-1;return}if(y.selectedFileAtIndex=0,Cf=o,r.innerHTML=o.map((e,t)=>{let n=_a(e.name,e.type),r=wf(e.fullPath),i=r.startsWith(c)?r.substring(c.length).replace(/^\//,``):r;return`
400
400
  <div class="prompt-item ${t===0?`selected`:``}" data-index="${t}" data-path="${k(r)}" title="${k(r)}">
401
401
  <span class="prompt-item-index">${t+1}</span>
402
402
  <span class="prompt-item-icon">${n}</span>
@@ -472,7 +472,7 @@ import{a as e,c as t,i as n,l as r,n as i,r as a,s as o}from"./i18n-5c8prpFJ.js"
472
472
  <button class="sap-btn sap-transfer"></button>
473
473
  <button class="sap-btn sap-regen"></button>
474
474
  </div>
475
- `,document.body.appendChild(Q),Q.querySelector(`.sap-close`).addEventListener(`click`,Vm),Q.querySelector(`.sap-lock`).addEventListener(`click`,Fm),Q.querySelector(`.sap-copy`).addEventListener(`click`,Gm),Q.querySelector(`.sap-transfer`).addEventListener(`click`,Km),Q.querySelector(`.sap-regen`).addEventListener(`click`,()=>{Cm&&wm&&Jm()}),Wm(Q.querySelector(`.sap-header`)),Q)}function Nm(){if(!Q)return;Q.querySelector(`.sap-close`).title=t(`sidePanel.popupClose`);let e=Q.querySelector(`.sap-copy`);e.textContent=t(`sidePanel.popupCopy`),e.title=t(`sidePanel.popupCopy`);let n=Q.querySelector(`.sap-transfer`);n.textContent=t(`sidePanel.popupTransfer`),n.title=t(`sidePanel.popupTransfer`);let r=Q.querySelector(`.sap-regen`);r.textContent=t(`sidePanel.popupRegenerate`),r.title=t(`sidePanel.popupRegenerate`),Pm()}function Pm(){if(!Q)return;let e=Q.querySelector(`.sap-lock`);e&&(e.classList.toggle(`locked`,Om),e.title=t(Om?`sidePanel.popupUnlock`:`sidePanel.popupLock`),e.innerHTML=Om?`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>`:`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 9.9-1"/></svg>`)}function Fm(){Om=!Om,Pm()}function Im(e,t){let n=Mm(),r=window.innerWidth,i=window.innerHeight,a=t+12,o=e-320/2;o<8&&(o=8),o+320>r-8&&(o=r-320-8),a+280>i-8&&(a=t-280-12),a<8&&(a=8),n.style.position=`fixed`,n.style.top=a+`px`,n.style.left=o+`px`}function Lm(e){let n=Mm();Nm(),n.querySelector(`.sap-title`).textContent=e||t(`sidePanel.popupTitle`),n.querySelector(`.sap-body`).innerHTML=`<div class="sap-loading">${k(t(`sidePanel.popupLoading`))}</div>`,n.classList.add(`show`),Q.style.display=`block`}function Rm(){return!!Q&&Q.classList.contains(`show`)}function zm(e,t=!0){let n=Q?.querySelector(`.sap-body`);n&&(n.innerHTML=`<div class="sap-content markdown-body">${e}</div>`,t&&(n.scrollTop=n.scrollHeight))}function Bm(e){let t=Q?.querySelector(`.sap-body`);t&&(t.innerHTML=`<div class="sap-error">${k(e)}</div>`)}function Vm(){Dm&&xm&&chrome.runtime.sendMessage({type:`CANCEL_REACT`,sessionId:xm}).catch(()=>{}),Q&&(Q.classList.remove(`show`),Q.style.display=`none`),xm=null,Sm=``,Dm=!1,Om=!1}function Hm(e){if(!Rm()||Om||Q.contains(e.target))return;let t=document.getElementById(`selectionFloatingMenu`);t&&t.contains(e.target)||Vm()}function Um(e){e.key===`Escape`&&(!Rm()||Om||Vm())}function Wm(e){let t=!1,n,r,i,a;e.addEventListener(`mousedown`,e=>{if(e.target.closest(`.sap-close, .sap-lock`))return;t=!0,n=e.clientX,r=e.clientY;let o=Q.getBoundingClientRect();i=o.top,a=o.left,e.preventDefault()}),document.addEventListener(`mousemove`,e=>{if(!t)return;let o=e.clientX-n,s=e.clientY-r;Q.style.position=`fixed`,Q.style.top=i+s+`px`,Q.style.left=a+o+`px`}),document.addEventListener(`mouseup`,()=>{t=!1})}function Gm(){Sm&&navigator.clipboard.writeText(Sm).then(()=>{A(t(`sidePanel.popupCopied`))}).catch(()=>{let e=document.createElement(`textarea`);e.value=Sm,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e),A(t(`sidePanel.popupCopied`))})}function Km(){if(!Sm||!Cm)return;nn()&&Cn();let e=Sm,n=Cm.content,r=`${Tm?`[${t(`sidePanel.popupContextLabel`)}]\n${Tm}\n\n`:``}[${t(`sidePanel.selectedContentLabel`)}]\n${wm}\n\n[${t(`sidePanel.userQuestionLabel`)}]\n${Cm.content}`;D(async()=>{let{addMessage:e}=await import(`./context-indicator-Sf2n8eWg.js`).then(e=>e.U);return{addMessage:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({addMessage:i})=>{i(`user`,n,!0,[],null,!1,r),y.messageHistory.push({role:`user`,content:r,timestamp:new Date().toISOString()}),i(`assistant`,e,!0),y.messageHistory.push({role:`assistant`,content:e}),D(async()=>{let{saveCurrentSession:e}=await import(`./context-indicator-Sf2n8eWg.js`).then(e=>e.kr);return{saveCurrentSession:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({saveCurrentSession:e})=>{e()}),Promise.all([D(()=>import(`./context-indicator-Sf2n8eWg.js`).then(e=>e.ht),__vite__mapDeps([0,1,2,3,4,5,6,7,8])),new Promise(e=>requestAnimationFrame(e))]).then(([{autoScrollToBottom:e}])=>{e(document.getElementById(`chatContainer`),{force:!0,smooth:!0}),A(t(`sidePanel.popupTransferred`))})}),Vm()}function qm(e,t,n){let{context:r,truncated:i}=Am(n,t);Cm=e,wm=t,Tm=r,Em=i,Jm()}function Jm(){Sm=``,Dm=!0,Lm(Cm?.content);let e=jm(wm,Tm,Cm.content,Em);xm=`popup_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,chrome.runtime.sendMessage({type:`SIDEPANEL_POPUP_ASK`,sessionId:xm,messages:e}).catch(e=>{r.error(`[SelectionPopup] sendMessage failed:`,e),Bm(t(`sidePanel.popupRequestFailed`)),Dm=!1})}var Ym=!1;function Xm(){Ym||(Ym=!0,chrome.runtime.onMessage.addListener(e=>{if(!(!e||!e.type)&&e.type.startsWith(`SIDEPANEL_POPUP_`)&&e.sessionId===xm){if(e.type===`SIDEPANEL_POPUP_STREAM_CHUNK`)e.delta&&(Sm+=e.delta,zm(st(Sm)));else if(e.type===`SIDEPANEL_POPUP_STREAM_DONE`)Dm=!1,e.finalContent&&(Sm=e.finalContent),zm(st(Sm));else if(e.type===`SIDEPANEL_POPUP_STREAM_ERROR`){if(!Dm)return;Dm=!1,Bm(e.error||t(`sidePanel.popupRequestFailed`))}}}))}function Zm(){Xm(),document.addEventListener(`mousedown`,Hm),document.addEventListener(`keydown`,Um)}function Qm(e,t,n,r,i){!t||!e||(Xm(),Im(n,r),Om=!1,qm(e,t,i||y.currentSelectionRange))}e(`zh`,{tokenStats:{clearConfirmMessage:`确定要清空所有 Token 使用统计吗?此操作不可撤销。`,loadFailed:`加载失败`,currentSessionNoData:`当前会话暂无数据`,totalTokenUsage:`总 Token 消耗`,apiCallCount:`API 调用次数`,contextUsageRate:`上下文使用率`,max:`最大`,avg:`平均`,min:`最小`,totalTokens:`总 Token`,totalSessions:`总会话数`,totalApiCalls:`总 API 调用`,callTypeNonStream:`普通`,callTypeStream:`流式`,callTypeReflection:`反思`,callTypeToolReflection:`工具反思`,callTypeSubtaskReflection:`子任务反思`,tabTrend:`趋势`,tabDistribution:`分布`,tabGlobal:`全局`,topCardSessionTokens:`本次 Token`,topCardSessionCalls:`本次调用`,topCardContextPeak:`上下文峰值`,sparklineTitle:`最近 20 次调用趋势`,distPromptVsCompletion:`Prompt / Completion 占比`,distPrompt:`Prompt`,distCompletion:`Completion`,distByModel:`按模型分布`,distByCallType:`按调用类型分布`,distNoData:`暂无分布数据`,globalSparklineTitle:`最近 30 天趋势`,globalNoDailyData:`所选范围内暂无数据`,globalTotalTokens:`总 Token`,globalTotalSessions:`总会话数`,globalTotalApiCalls:`总 API 调用`}}),e(`en`,{tokenStats:{clearConfirmMessage:`Are you sure you want to clear all Token usage statistics? This action cannot be undone.`,loadFailed:`Load failed`,currentSessionNoData:`No data for current session`,totalTokenUsage:`Total Token Usage`,apiCallCount:`API Call Count`,contextUsageRate:`Context Usage Rate`,max:`Max`,avg:`Avg`,min:`Min`,totalTokens:`Total Tokens`,totalSessions:`Total Sessions`,totalApiCalls:`Total API Calls`,callTypeNonStream:`Normal`,callTypeStream:`Stream`,callTypeReflection:`Reflection`,callTypeToolReflection:`Tool Reflection`,callTypeSubtaskReflection:`Subtask Reflection`,tabTrend:`Trend`,tabDistribution:`Distribution`,tabGlobal:`Global`,topCardSessionTokens:`Session Tokens`,topCardSessionCalls:`Session Calls`,topCardContextPeak:`Context Peak`,sparklineTitle:`Last 20 Calls Trend`,distPromptVsCompletion:`Prompt / Completion Ratio`,distPrompt:`Prompt`,distCompletion:`Completion`,distByModel:`By Model`,distByCallType:`By Call Type`,distNoData:`No distribution data`,globalSparklineTitle:`Last 30 Days Trend`,globalNoDailyData:`No data in selected range`,globalTotalTokens:`Total Tokens`,globalTotalSessions:`Total Sessions`,globalTotalApiCalls:`Total API Calls`}});function $m(e,n){let i=document.getElementById(`tokenStatsOverlay`),a=document.getElementById(`tokenStatsClose`),o=document.getElementById(`tokenStatsRefreshBtn`),s=document.getElementById(`tokenStatsClearBtn`),c=document.getElementById(`tokenStatsTabNav`),l=document.getElementById(`tokenStatsTopCards`);if(!i)return;let u=`trend`,d=`month`;function f(){i.style.display=`flex`,h()}function p(){i.style.display=`none`}if(window.openTokenStats=f,a&&a.addEventListener(`click`,p),i&&i.addEventListener(`click`,e=>{e.target===i&&p()}),o&&o.addEventListener(`click`,h),s&&s.addEventListener(`click`,async()=>{await n(t(`tokenStats.clearConfirmMessage`),t(`toolStats.clearTitle`))&&(await he(),h())}),c){c.addEventListener(`click`,e=>{let t=e.target.closest(`.token-tab-btn`);if(!t)return;let n=t.dataset.tab;if(n===u)return;c.querySelectorAll(`.token-tab-btn`).forEach(e=>{e.classList.remove(`active`),e.style.borderBottomColor=`transparent`,e.style.color=`var(--text-secondary)`}),t.classList.add(`active`),t.style.borderBottomColor=`var(--brand-500)`,t.style.color=`var(--brand-500)`,document.querySelectorAll(`.token-tab-content`).forEach(e=>{e.style.display=`none`});let r=document.getElementById(`tokenTab${n.charAt(0).toUpperCase()+n.slice(1)}`);r&&(r.style.display=n===`global`?`flex`:``),u=n});let e=c.querySelector(`.token-tab-btn.active`);e&&(e.style.borderBottomColor=`var(--brand-500)`,e.style.color=`var(--brand-500)`)}let m=document.querySelectorAll(`.token-time-range-btn`);m.forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.range;t!==d&&(d=t,m.forEach(e=>{e.classList.remove(`active`),e.style.border=`1px solid var(--border-default)`,e.style.background=`var(--bg-surface)`,e.style.color=`var(--text-secondary)`}),e.classList.add(`active`),e.style.border=`1px solid var(--brand-500)`,e.style.background=`var(--brand-500)`,e.style.color=`var(--text-on-brand)`,x())})});async function h(){let n=e(),i=document.getElementById(`tokenStatsLoading`),a=document.getElementById(`tokenStatsEmpty`),o=document.getElementById(`tokenStatsContent`);i&&(i.style.display=``),a&&(a.style.display=`none`),o&&(o.style.display=`none`),c&&(c.style.display=`none`),l&&(l.style.display=`none`);try{let[e,t]=await Promise.all([je(n),Me()]);if(i&&(i.style.display=`none`),!(t&&t.totalApiCalls>0)){a&&(a.style.display=``);return}o&&(o.style.display=``),c&&(c.style.display=`flex`),l&&(l.style.display=``),g(e),_(e),C(e.records||[]),y(t),x()}catch(e){r.error(`[TokenStats] load stats failed:`,e),i&&(i.style.display=`none`),a&&(a.textContent=t(`tokenStats.loadFailed`),a.style.display=``)}}function g(e){if(!l)return;if(!e||e.apiCallCount===0){l.innerHTML=``;return}let n=e.maxContextUsageRate||0,r=T(n);l.innerHTML=`
475
+ `,document.body.appendChild(Q),Q.querySelector(`.sap-close`).addEventListener(`click`,Vm),Q.querySelector(`.sap-lock`).addEventListener(`click`,Fm),Q.querySelector(`.sap-copy`).addEventListener(`click`,Gm),Q.querySelector(`.sap-transfer`).addEventListener(`click`,Km),Q.querySelector(`.sap-regen`).addEventListener(`click`,()=>{Cm&&wm&&Jm()}),Wm(Q.querySelector(`.sap-header`)),Q)}function Nm(){if(!Q)return;Q.querySelector(`.sap-close`).title=t(`sidePanel.popupClose`);let e=Q.querySelector(`.sap-copy`);e.textContent=t(`sidePanel.popupCopy`),e.title=t(`sidePanel.popupCopy`);let n=Q.querySelector(`.sap-transfer`);n.textContent=t(`sidePanel.popupTransfer`),n.title=t(`sidePanel.popupTransfer`);let r=Q.querySelector(`.sap-regen`);r.textContent=t(`sidePanel.popupRegenerate`),r.title=t(`sidePanel.popupRegenerate`),Pm()}function Pm(){if(!Q)return;let e=Q.querySelector(`.sap-lock`);e&&(e.classList.toggle(`locked`,Om),e.title=t(Om?`sidePanel.popupUnlock`:`sidePanel.popupLock`),e.innerHTML=Om?`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>`:`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 9.9-1"/></svg>`)}function Fm(){Om=!Om,Pm()}function Im(e,t){let n=Mm(),r=window.innerWidth,i=window.innerHeight,a=t+12,o=e-320/2;o<8&&(o=8),o+320>r-8&&(o=r-320-8),a+280>i-8&&(a=t-280-12),a<8&&(a=8),n.style.position=`fixed`,n.style.top=a+`px`,n.style.left=o+`px`}function Lm(e){let n=Mm();Nm(),n.querySelector(`.sap-title`).textContent=e||t(`sidePanel.popupTitle`),n.querySelector(`.sap-body`).innerHTML=`<div class="sap-loading">${k(t(`sidePanel.popupLoading`))}</div>`,n.classList.add(`show`),Q.style.display=`block`}function Rm(){return!!Q&&Q.classList.contains(`show`)}function zm(e,t=!0){let n=Q?.querySelector(`.sap-body`);n&&(n.innerHTML=`<div class="sap-content markdown-body">${e}</div>`,t&&(n.scrollTop=n.scrollHeight))}function Bm(e){let t=Q?.querySelector(`.sap-body`);t&&(t.innerHTML=`<div class="sap-error">${k(e)}</div>`)}function Vm(){Dm&&xm&&chrome.runtime.sendMessage({type:`CANCEL_REACT`,sessionId:xm}).catch(()=>{}),Q&&(Q.classList.remove(`show`),Q.style.display=`none`),xm=null,Sm=``,Dm=!1,Om=!1}function Hm(e){if(!Rm()||Om||Q.contains(e.target))return;let t=document.getElementById(`selectionFloatingMenu`);t&&t.contains(e.target)||Vm()}function Um(e){e.key===`Escape`&&(!Rm()||Om||Vm())}function Wm(e){let t=!1,n,r,i,a;e.addEventListener(`mousedown`,e=>{if(e.target.closest(`.sap-close, .sap-lock`))return;t=!0,n=e.clientX,r=e.clientY;let o=Q.getBoundingClientRect();i=o.top,a=o.left,e.preventDefault()}),document.addEventListener(`mousemove`,e=>{if(!t)return;let o=e.clientX-n,s=e.clientY-r;Q.style.position=`fixed`,Q.style.top=i+s+`px`,Q.style.left=a+o+`px`}),document.addEventListener(`mouseup`,()=>{t=!1})}function Gm(){Sm&&navigator.clipboard.writeText(Sm).then(()=>{A(t(`sidePanel.popupCopied`))}).catch(()=>{let e=document.createElement(`textarea`);e.value=Sm,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e),A(t(`sidePanel.popupCopied`))})}function Km(){if(!Sm||!Cm)return;nn()&&Cn();let e=Sm,n=Cm.content,r=`${Tm?`[${t(`sidePanel.popupContextLabel`)}]\n${Tm}\n\n`:``}[${t(`sidePanel.selectedContentLabel`)}]\n${wm}\n\n[${t(`sidePanel.userQuestionLabel`)}]\n${Cm.content}`;D(async()=>{let{addMessage:e}=await import(`./context-indicator-DjOAo_Ln.js`).then(e=>e.U);return{addMessage:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({addMessage:i})=>{i(`user`,n,!0,[],null,!1,r),y.messageHistory.push({role:`user`,content:r,timestamp:new Date().toISOString()}),i(`assistant`,e,!0),y.messageHistory.push({role:`assistant`,content:e}),D(async()=>{let{saveCurrentSession:e}=await import(`./context-indicator-DjOAo_Ln.js`).then(e=>e.kr);return{saveCurrentSession:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({saveCurrentSession:e})=>{e()}),Promise.all([D(()=>import(`./context-indicator-DjOAo_Ln.js`).then(e=>e.ht),__vite__mapDeps([0,1,2,3,4,5,6,7,8])),new Promise(e=>requestAnimationFrame(e))]).then(([{autoScrollToBottom:e}])=>{e(document.getElementById(`chatContainer`),{force:!0,smooth:!0}),A(t(`sidePanel.popupTransferred`))})}),Vm()}function qm(e,t,n){let{context:r,truncated:i}=Am(n,t);Cm=e,wm=t,Tm=r,Em=i,Jm()}function Jm(){Sm=``,Dm=!0,Lm(Cm?.content);let e=jm(wm,Tm,Cm.content,Em);xm=`popup_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,chrome.runtime.sendMessage({type:`SIDEPANEL_POPUP_ASK`,sessionId:xm,messages:e}).catch(e=>{r.error(`[SelectionPopup] sendMessage failed:`,e),Bm(t(`sidePanel.popupRequestFailed`)),Dm=!1})}var Ym=!1;function Xm(){Ym||(Ym=!0,chrome.runtime.onMessage.addListener(e=>{if(!(!e||!e.type)&&e.type.startsWith(`SIDEPANEL_POPUP_`)&&e.sessionId===xm){if(e.type===`SIDEPANEL_POPUP_STREAM_CHUNK`)e.delta&&(Sm+=e.delta,zm(st(Sm)));else if(e.type===`SIDEPANEL_POPUP_STREAM_DONE`)Dm=!1,e.finalContent&&(Sm=e.finalContent),zm(st(Sm));else if(e.type===`SIDEPANEL_POPUP_STREAM_ERROR`){if(!Dm)return;Dm=!1,Bm(e.error||t(`sidePanel.popupRequestFailed`))}}}))}function Zm(){Xm(),document.addEventListener(`mousedown`,Hm),document.addEventListener(`keydown`,Um)}function Qm(e,t,n,r,i){!t||!e||(Xm(),Im(n,r),Om=!1,qm(e,t,i||y.currentSelectionRange))}e(`zh`,{tokenStats:{clearConfirmMessage:`确定要清空所有 Token 使用统计吗?此操作不可撤销。`,loadFailed:`加载失败`,currentSessionNoData:`当前会话暂无数据`,totalTokenUsage:`总 Token 消耗`,apiCallCount:`API 调用次数`,contextUsageRate:`上下文使用率`,max:`最大`,avg:`平均`,min:`最小`,totalTokens:`总 Token`,totalSessions:`总会话数`,totalApiCalls:`总 API 调用`,callTypeNonStream:`普通`,callTypeStream:`流式`,callTypeReflection:`反思`,callTypeToolReflection:`工具反思`,callTypeSubtaskReflection:`子任务反思`,tabTrend:`趋势`,tabDistribution:`分布`,tabGlobal:`全局`,topCardSessionTokens:`本次 Token`,topCardSessionCalls:`本次调用`,topCardContextPeak:`上下文峰值`,sparklineTitle:`最近 20 次调用趋势`,distPromptVsCompletion:`Prompt / Completion 占比`,distPrompt:`Prompt`,distCompletion:`Completion`,distByModel:`按模型分布`,distByCallType:`按调用类型分布`,distNoData:`暂无分布数据`,globalSparklineTitle:`最近 30 天趋势`,globalNoDailyData:`所选范围内暂无数据`,globalTotalTokens:`总 Token`,globalTotalSessions:`总会话数`,globalTotalApiCalls:`总 API 调用`}}),e(`en`,{tokenStats:{clearConfirmMessage:`Are you sure you want to clear all Token usage statistics? This action cannot be undone.`,loadFailed:`Load failed`,currentSessionNoData:`No data for current session`,totalTokenUsage:`Total Token Usage`,apiCallCount:`API Call Count`,contextUsageRate:`Context Usage Rate`,max:`Max`,avg:`Avg`,min:`Min`,totalTokens:`Total Tokens`,totalSessions:`Total Sessions`,totalApiCalls:`Total API Calls`,callTypeNonStream:`Normal`,callTypeStream:`Stream`,callTypeReflection:`Reflection`,callTypeToolReflection:`Tool Reflection`,callTypeSubtaskReflection:`Subtask Reflection`,tabTrend:`Trend`,tabDistribution:`Distribution`,tabGlobal:`Global`,topCardSessionTokens:`Session Tokens`,topCardSessionCalls:`Session Calls`,topCardContextPeak:`Context Peak`,sparklineTitle:`Last 20 Calls Trend`,distPromptVsCompletion:`Prompt / Completion Ratio`,distPrompt:`Prompt`,distCompletion:`Completion`,distByModel:`By Model`,distByCallType:`By Call Type`,distNoData:`No distribution data`,globalSparklineTitle:`Last 30 Days Trend`,globalNoDailyData:`No data in selected range`,globalTotalTokens:`Total Tokens`,globalTotalSessions:`Total Sessions`,globalTotalApiCalls:`Total API Calls`}});function $m(e,n){let i=document.getElementById(`tokenStatsOverlay`),a=document.getElementById(`tokenStatsClose`),o=document.getElementById(`tokenStatsRefreshBtn`),s=document.getElementById(`tokenStatsClearBtn`),c=document.getElementById(`tokenStatsTabNav`),l=document.getElementById(`tokenStatsTopCards`);if(!i)return;let u=`trend`,d=`month`;function f(){i.style.display=`flex`,h()}function p(){i.style.display=`none`}if(window.openTokenStats=f,a&&a.addEventListener(`click`,p),i&&i.addEventListener(`click`,e=>{e.target===i&&p()}),o&&o.addEventListener(`click`,h),s&&s.addEventListener(`click`,async()=>{await n(t(`tokenStats.clearConfirmMessage`),t(`toolStats.clearTitle`))&&(await he(),h())}),c){c.addEventListener(`click`,e=>{let t=e.target.closest(`.token-tab-btn`);if(!t)return;let n=t.dataset.tab;if(n===u)return;c.querySelectorAll(`.token-tab-btn`).forEach(e=>{e.classList.remove(`active`),e.style.borderBottomColor=`transparent`,e.style.color=`var(--text-secondary)`}),t.classList.add(`active`),t.style.borderBottomColor=`var(--brand-500)`,t.style.color=`var(--brand-500)`,document.querySelectorAll(`.token-tab-content`).forEach(e=>{e.style.display=`none`});let r=document.getElementById(`tokenTab${n.charAt(0).toUpperCase()+n.slice(1)}`);r&&(r.style.display=n===`global`?`flex`:``),u=n});let e=c.querySelector(`.token-tab-btn.active`);e&&(e.style.borderBottomColor=`var(--brand-500)`,e.style.color=`var(--brand-500)`)}let m=document.querySelectorAll(`.token-time-range-btn`);m.forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.range;t!==d&&(d=t,m.forEach(e=>{e.classList.remove(`active`),e.style.border=`1px solid var(--border-default)`,e.style.background=`var(--bg-surface)`,e.style.color=`var(--text-secondary)`}),e.classList.add(`active`),e.style.border=`1px solid var(--brand-500)`,e.style.background=`var(--brand-500)`,e.style.color=`var(--text-on-brand)`,x())})});async function h(){let n=e(),i=document.getElementById(`tokenStatsLoading`),a=document.getElementById(`tokenStatsEmpty`),o=document.getElementById(`tokenStatsContent`);i&&(i.style.display=``),a&&(a.style.display=`none`),o&&(o.style.display=`none`),c&&(c.style.display=`none`),l&&(l.style.display=`none`);try{let[e,t]=await Promise.all([je(n),Me()]);if(i&&(i.style.display=`none`),!(t&&t.totalApiCalls>0)){a&&(a.style.display=``);return}o&&(o.style.display=``),c&&(c.style.display=`flex`),l&&(l.style.display=``),g(e),_(e),C(e.records||[]),y(t),x()}catch(e){r.error(`[TokenStats] load stats failed:`,e),i&&(i.style.display=`none`),a&&(a.textContent=t(`tokenStats.loadFailed`),a.style.display=``)}}function g(e){if(!l)return;if(!e||e.apiCallCount===0){l.innerHTML=``;return}let n=e.maxContextUsageRate||0,r=T(n);l.innerHTML=`
476
476
  <div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;">
477
477
  <div style="background: var(--brand-soft-bg); border-radius: 8px; padding: 10px; text-align: center;">
478
478
  <div style="font-size: 10px; color: var(--text-tertiary); margin-bottom: 4px;">${t(`tokenStats.topCardSessionTokens`)}</div>
@@ -601,7 +601,7 @@ Agent address: {url}
601
601
  Are you sure you want to update the agent? It will install the latest patch version within the {version} minor range compatible with this extension, then restart the service. The service will be unavailable during update.`,updateAgentTitle:`Update Agent`,agentUpdating:`Updating agent (may take a few minutes)...`,agentUpdateRestarting:`Agent is updating and restarting...`,agentVersionAhead:`Agent version is newer than this extension. Please update the extension from the store first`,agentAlreadyLatest:`Already at the latest compatible version`,agentUpdateAvailable:`Update available: v{current} → v{latest}`,updateFailed:`Update failed: {error}`,updateRequestFailed:`Update request failed: {error}`,stopAgentConfirm:`Agent name: {name}
602
602
  Agent address: {url}
603
603
 
604
- Are you sure you want to stop the agent service? You will not be able to connect and will need to manually restart it.`,stopAgentTitle:`Stop Agent`,agentStopped:`Agent service stopped, agent is offline`,stopFailed:`Stop failed: {error}`,stopRequestFailed:`Stop request failed: {error}`,agentStatusRefreshed:`Agent status refreshed`,deleteAgentTitle:`Delete Agent`,deleteAgentConfirm:`Are you sure you want to delete agent "{name}"? This action cannot be undone.`,welcomeTitle:`Start a Conversation`,welcomeSubtitle:`Enter your question and the AI assistant will help you`,sendBtnStop:`Stop generating`,sendBtnSend:`Send`,defaultPromptImage:`Please look at the attached image and describe what you see`,defaultPromptFile:`Please read the attached file and summarize the key points`,defaultPromptAttachments:`Please review the attached image and file and summarize the key points`,defaultPromptKnowledge:`Please answer based on the knowledge base content I referenced`,defaultKnowledgeQuery:`key points summary`,defaultPromptPage:`Please summarize the main content of this page`,defaultPromptSelection:`Please continue based on the content I provided`,defaultPromptContext:`Please continue based on the context I provided`,imageNotEnabled:`Image recognition not enabled, image attached as file`,screenshotFailed:`Screenshot failed, please retry`,auditCategoryAuth:`Auth`,auditCategoryFs:`File`,auditCategoryExec:`Command`,auditCategorySecurity:`Security`,auditCategorySystem:`System`,auditDetailSeparator:`; `,auditQueryFailed:`Query failed: {error}`,auditLoadFailed:`Load failed: {error}`,auditNoMatch:`No matching audit logs`,auditEmpty:`No audit logs`,clearStatsConfirm:`Are you sure you want to clear all tool usage stats? This action cannot be undone.`,clearStatsTitle:`Clear Stats`,toolStatsSummary:`Used {used} tools, unused {unused} tools`,toolStatsLoadFailed:`Load failed`,toolNameDescSeparator:`: `}}),window.showCustomConfirm=function(e,n=t(`sidePanel.confirmAction`)){return new Promise(t=>{let r=document.getElementById(`customConfirmOverlay`),i=document.getElementById(`customConfirmTitle`),a=document.getElementById(`customConfirmMessage`),o=document.getElementById(`customConfirmCancelBtn`),s=document.getElementById(`customConfirmOkBtn`);if(!r||!i||!a||!o||!s){t(confirm(e));return}let c=()=>{r.style.display=`none`,s.removeEventListener(`click`,l),o.removeEventListener(`click`,u),r.removeEventListener(`click`,d),document.removeEventListener(`keydown`,f)},l=()=>{c(),t(!0)},u=()=>{c(),t(!1)},d=e=>{e.target===r&&(c(),t(!1))},f=e=>{e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),l()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),u())};i.textContent=n,a.innerHTML=e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`).replace(/\n/g,`<br>`),r.style.display=`flex`,s.addEventListener(`click`,l),o.addEventListener(`click`,u),r.addEventListener(`click`,d),document.addEventListener(`keydown`,f),requestAnimationFrame(()=>s.focus())})},chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&e.chatAutoCompaction&&(y.chatConfig.autoCompaction=e.chatAutoCompaction.newValue===!0,nh(),r.debug(`[SidePanel] auto-compaction config updated:`,y.chatConfig.autoCompaction)),t===`local`&&e.chatPersistSummaryToMemory&&(y.chatConfig.persistSummaryToMemory=e.chatPersistSummaryToMemory.newValue!==!1,rh(),r.debug(`[SidePanel] persist-summary config updated:`,y.chatConfig.persistSummaryToMemory)),t===`local`&&e.chatMaxMemoryMessages&&(y.chatConfig.maxMemoryMessages=e.chatMaxMemoryMessages.newValue,th(),r.debug(`[SidePanel] memory limitconfiguration updated:`,y.chatConfig.maxMemoryMessages)),t===`local`&&e.queueAutoCarry&&(y.chatConfig.queueAutoCarry=e.queueAutoCarry.newValue!==!1,r.debug(`[SidePanel] queue auto-carry updated:`,y.chatConfig.queueAutoCarry)),t===`local`&&e.queueAutoCarryEveryNIterations&&(y.chatConfig.queueAutoCarryEveryNIterations=e.queueAutoCarryEveryNIterations.newValue,r.debug(`[SidePanel] queue auto-carry interval updated:`,y.chatConfig.queueAutoCarryEveryNIterations))});function th(){let e=document.getElementById(`memoryLimitLabel`);e&&(y.chatConfig.maxMemoryMessages!==null&&y.chatConfig.maxMemoryMessages!==void 0&&y.chatConfig.maxMemoryMessages>0?e.textContent=y.chatConfig.maxMemoryMessages:e.textContent=t(`sidePanel.memoryLimitAll`),e.title=t(`sidePanel.memoryLimitTitle`))}function nh(){let e=document.getElementById(`autoCompactBtn`);e&&(e.checked=y.chatConfig.autoCompaction===!0)}function rh(){let e=document.getElementById(`persistSummaryBtn`);e&&(e.checked=y.chatConfig.persistSummaryToMemory!==!1)}function ih(e){e.preventDefault(),e.stopPropagation();let t=document.getElementById(`memoryLimitDropdown`);if(t.classList.toggle(`show`),t.classList.contains(`show`)){let e=y.chatConfig.maxMemoryMessages;t.querySelectorAll(`.memory-limit-option`).forEach(t=>{t.classList.remove(`selected`);let n=parseInt(t.dataset.value);(e===null&&n===0||e!==null&&e>0&&n===e)&&t.classList.add(`selected`)});let n=t.querySelector(`#memoryLimitInput`);e!==null&&e>0?n.value=e:n.value=``}}function ah(){let e=document.getElementById(`memoryLimitDropdown`),n=document.getElementById(`memoryLimitLabel`),r=e?.querySelector(`#memoryLimitInput`);if(!e||!n)return;th(),n.addEventListener(`click`,ih);let i=document.getElementById(`autoCompactBtn`);i&&(i.checked=y.chatConfig.autoCompaction===!0,i.addEventListener(`change`,()=>{let e=i.checked;chrome.storage.local.set({chatAutoCompaction:e},()=>{y.chatConfig.autoCompaction=e,A(t(`sidePanel.configUpdated`),`success`)})}));let a=document.getElementById(`persistSummaryBtn`);a&&(a.checked=y.chatConfig.persistSummaryToMemory!==!1,a.addEventListener(`change`,()=>{let e=a.checked;chrome.storage.local.set({chatPersistSummaryToMemory:e},()=>{y.chatConfig.persistSummaryToMemory=e,A(t(`sidePanel.configUpdated`),`success`)})}));let o=e.querySelectorAll(`.memory-limit-option`);o.forEach(e=>{e.addEventListener(`click`,n=>{n.stopPropagation();let i=parseInt(e.dataset.value),a=i===0?null:i;o.forEach(e=>e.classList.remove(`selected`)),e.classList.add(`selected`),r&&(r.value=i===0?``:i),chrome.storage.local.set({chatMaxMemoryMessages:a},()=>{y.chatConfig.maxMemoryMessages=a,th(),A(t(`sidePanel.configUpdated`),`success`)})})}),r&&(r.addEventListener(`click`,e=>e.stopPropagation()),r.addEventListener(`mousedown`,e=>e.stopPropagation()),r.addEventListener(`change`,e=>{e.stopPropagation();let n=e.target.value.trim(),r=n&&parseInt(n)>0?parseInt(n):null;o.forEach(e=>e.classList.remove(`selected`)),chrome.storage.local.set({chatMaxMemoryMessages:r},()=>{y.chatConfig.maxMemoryMessages=r,th(),A(t(`sidePanel.configUpdated`),`success`)})})),document.getElementById(`memoryLimitConfigEntry`)?.addEventListener(`click`,()=>{chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`memory`})}),document.addEventListener(`click`,t=>{!e.contains(t.target)&&t.target!==n&&e.classList.remove(`show`)})}async function oh(e){if(y.activeAgentId&&y.activeAgentId!=="default")try{let{updateAgent:t}=await D(async()=>{let{updateAgent:e}=await import(`./agent-store-CeC2_dkP.js`).then(e=>e.t);return{updateAgent:e}},__vite__mapDeps([7,1,2,3]));await t(y.activeAgentId,{model:e})}catch{}else chrome.storage.local.set({modelName:e}),le(e)}async function sh(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=eh(e.pairedAgents),n=e.activeAgentId,r=t.find(e=>e.id===n&&!e.disabled);if(!r){y.agentPlatform={connected:!1},$(y.agentPlatform);return}if(r.token)try{let e=await fetch(`${r.url}/api/status/detail`,{cache:`no-cache`,headers:{Authorization:`Bearer ${r.token}`}});if(e.ok){let t=await e.json();if(t.success){y.agentPlatform={platformName:t.platformName||`Unknown`,platform:t.platform||`unknown`,arch:t.arch||`unknown`,shell:t.shell||`/bin/sh`,homeDir:t.homeDir||``,workdir:t.workdir||``,connected:!0},t.version&&y.agentVersions.set(n,t.version),t.workdir&&y.agentWorkdirs.set(n,t.workdir),t.homeDir&&y.agentHomeDirs.set(n,t.homeDir);let e=Lh(t.platformName||t.platform,t.arch);e&&y.agentSystemInfos.set(n,e)}else y.agentPlatform={connected:!1}}else y.agentPlatform={connected:!1}}catch{y.agentPlatform={connected:!1}}else y.agentPlatform={connected:!1};$(y.agentPlatform),oa()}catch{}}async function ch(e,t,n){if(y.activeAgentId&&y.activeAgentId!=="default")try{let{updateAgent:n}=await D(async()=>{let{updateAgent:e}=await import(`./agent-store-CeC2_dkP.js`).then(e=>e.t);return{updateAgent:e}},__vite__mapDeps([7,1,2,3]));await n(y.activeAgentId,{temperature:e,topP:t})}catch{}else chrome.storage.local.set({temperature:e,topP:t,selectedTempIndex:n})}function lh(){let e=document.getElementById(`currentModelTag`);if(!e)return;let t=y.currentModel||``;e.textContent=t,e.title=t,e.style.display=t?``:`none`}var uh=new Set,dh=0;function fh(){let e=document.getElementById(`workdirTag`);e&&(e.dataset.locked=na(y.activeSessionId)?`true`:`false`)}async function ph(){let e=++dh,n=document.getElementById(`workdirTag`),i=document.getElementById(`workdirTagName`);if(!n||!i)return;let a=y.activeSessionId||null,o=Array.isArray(y.enabledTools)&&y.enabledTools.includes(`agent_exec`);if(y.agentPlatform?.connected!==!0||!o){n.style.display=`none`;return}let c=null;try{c=await p(a)}catch(e){r.debug(`[WorkdirTag] resolve failed:`,e&&e.message)}if(e!==dh)return;let l=c&&c.workdir||``;if(!l){n.style.display=`none`;return}n.style.display=``,i.textContent=s(l,{homeDir:y.agentPlatform?.homeDir||``}),fh();try{let{getWorkspaceRoot:e}=await D(async()=>{let{getWorkspaceRoot:e}=await import(`./workspace-manager-CL4JvHkJ.js`).then(e=>e.j);return{getWorkspaceRoot:e}},__vite__mapDeps([8,1,2,3])),t=await e(a),i=!!(t&&t!==l);i&&c.scope==="default"?(n.dataset.invalid=`false`,ym(a).then(e=>{e&&ph()}).catch(e=>r.debug(`[WorkdirTag] reconcile failed:`,e&&e.message))):n.dataset.invalid=i?`true`:`false`}catch{n.dataset.invalid=`false`}if(e===dh&&(n.title=`${l}${c.scope===`session`?t(`workdirTag.sessionScope`):t(`workdirTag.defaultScope`)}${n.dataset.invalid===`true`?t(`workdirTag.pathMissing`):``}`,c.boundWorkdir&&c.scope==="default")){let e=`${a||``}::${c.agentId||``}`;uh.has(e)||(uh.add(e),A(t(`workdirTag.agentSwitched`),`warning`))}}function mh(){let e=document.getElementById(`workdirTag`);e&&(e.setAttribute(`aria-label`,t(`workdirTag.tagHint`)),e.addEventListener(`click`,async e=>{if(e.stopPropagation(),na(y.activeSessionId)){fh(),A(t(`workdirTag.lockedHint`),`warning`);return}fh();let{showSwitchWorkdirDialog:n}=await D(async()=>{let{showSwitchWorkdirDialog:e}=await import(`./context-indicator-Sf2n8eWg.js`).then(e=>e.mn);return{showSwitchWorkdirDialog:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));await n({sessionId:y.activeSessionId||null})})),ph(),document.addEventListener(`session-switched`,()=>{ph()}),document.addEventListener(`session-workdir-changed`,()=>{ph()}),document.addEventListener(`agent-model-changed`,()=>{ph()}),document.addEventListener(`agent-tools-changed`,()=>{ph()}),document.addEventListener(`generating-state-changed`,()=>{fh()}),document.addEventListener(`generation-ended`,()=>{fh()}),qt(()=>{fh()})}function hh(){let e=document.getElementById(`currentModelTag`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),document.getElementById(`tempDisplay`)?.click()}),lh()}function gh(e){let t=0;document.querySelectorAll(`.model-option`).forEach(n=>{n.dataset.value===e?(n.classList.add(`selected`),n.querySelector(`.model-option-check`).textContent=`✓`,t=parseInt(n.dataset.contextWindow,10)||0):(n.classList.remove(`selected`),n.querySelector(`.model-option-check`).textContent=``)});let n=document.getElementById(`modelSelectValue`);n&&e&&(n.textContent=e);let r=document.getElementById(`modelSelectCtxBadge`);r&&(t>0?(r.textContent=g(t),r.style.display=``):r.style.display=`none`),lh()}function _h(e,n){let r=document.getElementById(`tempDropdown`);if(!r){typeof n==`function`&&n();return}let i=r.querySelector(`.model-section`),a=[];if((Array.isArray(e)?e:[]).forEach(e=>{typeof e==`string`?a.push({name:e,contextWindow:0}):e&&typeof e==`object`&&e.name&&a.push({name:e.name,contextWindow:e.contextWindow||0})}),i){i.innerHTML=`
604
+ Are you sure you want to stop the agent service? You will not be able to connect and will need to manually restart it.`,stopAgentTitle:`Stop Agent`,agentStopped:`Agent service stopped, agent is offline`,stopFailed:`Stop failed: {error}`,stopRequestFailed:`Stop request failed: {error}`,agentStatusRefreshed:`Agent status refreshed`,deleteAgentTitle:`Delete Agent`,deleteAgentConfirm:`Are you sure you want to delete agent "{name}"? This action cannot be undone.`,welcomeTitle:`Start a Conversation`,welcomeSubtitle:`Enter your question and the AI assistant will help you`,sendBtnStop:`Stop generating`,sendBtnSend:`Send`,defaultPromptImage:`Please look at the attached image and describe what you see`,defaultPromptFile:`Please read the attached file and summarize the key points`,defaultPromptAttachments:`Please review the attached image and file and summarize the key points`,defaultPromptKnowledge:`Please answer based on the knowledge base content I referenced`,defaultKnowledgeQuery:`key points summary`,defaultPromptPage:`Please summarize the main content of this page`,defaultPromptSelection:`Please continue based on the content I provided`,defaultPromptContext:`Please continue based on the context I provided`,imageNotEnabled:`Image recognition not enabled, image attached as file`,screenshotFailed:`Screenshot failed, please retry`,auditCategoryAuth:`Auth`,auditCategoryFs:`File`,auditCategoryExec:`Command`,auditCategorySecurity:`Security`,auditCategorySystem:`System`,auditDetailSeparator:`; `,auditQueryFailed:`Query failed: {error}`,auditLoadFailed:`Load failed: {error}`,auditNoMatch:`No matching audit logs`,auditEmpty:`No audit logs`,clearStatsConfirm:`Are you sure you want to clear all tool usage stats? This action cannot be undone.`,clearStatsTitle:`Clear Stats`,toolStatsSummary:`Used {used} tools, unused {unused} tools`,toolStatsLoadFailed:`Load failed`,toolNameDescSeparator:`: `}}),window.showCustomConfirm=function(e,n=t(`sidePanel.confirmAction`)){return new Promise(t=>{let r=document.getElementById(`customConfirmOverlay`),i=document.getElementById(`customConfirmTitle`),a=document.getElementById(`customConfirmMessage`),o=document.getElementById(`customConfirmCancelBtn`),s=document.getElementById(`customConfirmOkBtn`);if(!r||!i||!a||!o||!s){t(confirm(e));return}let c=()=>{r.style.display=`none`,s.removeEventListener(`click`,l),o.removeEventListener(`click`,u),r.removeEventListener(`click`,d),document.removeEventListener(`keydown`,f)},l=()=>{c(),t(!0)},u=()=>{c(),t(!1)},d=e=>{e.target===r&&(c(),t(!1))},f=e=>{e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),l()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),u())};i.textContent=n,a.innerHTML=e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`).replace(/\n/g,`<br>`),r.style.display=`flex`,s.addEventListener(`click`,l),o.addEventListener(`click`,u),r.addEventListener(`click`,d),document.addEventListener(`keydown`,f),requestAnimationFrame(()=>s.focus())})},chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&e.chatAutoCompaction&&(y.chatConfig.autoCompaction=e.chatAutoCompaction.newValue===!0,nh(),r.debug(`[SidePanel] auto-compaction config updated:`,y.chatConfig.autoCompaction)),t===`local`&&e.chatPersistSummaryToMemory&&(y.chatConfig.persistSummaryToMemory=e.chatPersistSummaryToMemory.newValue!==!1,rh(),r.debug(`[SidePanel] persist-summary config updated:`,y.chatConfig.persistSummaryToMemory)),t===`local`&&e.chatMaxMemoryMessages&&(y.chatConfig.maxMemoryMessages=e.chatMaxMemoryMessages.newValue,th(),r.debug(`[SidePanel] memory limitconfiguration updated:`,y.chatConfig.maxMemoryMessages)),t===`local`&&e.queueAutoCarry&&(y.chatConfig.queueAutoCarry=e.queueAutoCarry.newValue!==!1,r.debug(`[SidePanel] queue auto-carry updated:`,y.chatConfig.queueAutoCarry)),t===`local`&&e.queueAutoCarryEveryNIterations&&(y.chatConfig.queueAutoCarryEveryNIterations=e.queueAutoCarryEveryNIterations.newValue,r.debug(`[SidePanel] queue auto-carry interval updated:`,y.chatConfig.queueAutoCarryEveryNIterations))});function th(){let e=document.getElementById(`memoryLimitLabel`);e&&(y.chatConfig.maxMemoryMessages!==null&&y.chatConfig.maxMemoryMessages!==void 0&&y.chatConfig.maxMemoryMessages>0?e.textContent=y.chatConfig.maxMemoryMessages:e.textContent=t(`sidePanel.memoryLimitAll`),e.title=t(`sidePanel.memoryLimitTitle`))}function nh(){let e=document.getElementById(`autoCompactBtn`);e&&(e.checked=y.chatConfig.autoCompaction===!0)}function rh(){let e=document.getElementById(`persistSummaryBtn`);e&&(e.checked=y.chatConfig.persistSummaryToMemory!==!1)}function ih(e){e.preventDefault(),e.stopPropagation();let t=document.getElementById(`memoryLimitDropdown`);if(t.classList.toggle(`show`),t.classList.contains(`show`)){let e=y.chatConfig.maxMemoryMessages;t.querySelectorAll(`.memory-limit-option`).forEach(t=>{t.classList.remove(`selected`);let n=parseInt(t.dataset.value);(e===null&&n===0||e!==null&&e>0&&n===e)&&t.classList.add(`selected`)});let n=t.querySelector(`#memoryLimitInput`);e!==null&&e>0?n.value=e:n.value=``}}function ah(){let e=document.getElementById(`memoryLimitDropdown`),n=document.getElementById(`memoryLimitLabel`),r=e?.querySelector(`#memoryLimitInput`);if(!e||!n)return;th(),n.addEventListener(`click`,ih);let i=document.getElementById(`autoCompactBtn`);i&&(i.checked=y.chatConfig.autoCompaction===!0,i.addEventListener(`change`,()=>{let e=i.checked;chrome.storage.local.set({chatAutoCompaction:e},()=>{y.chatConfig.autoCompaction=e,A(t(`sidePanel.configUpdated`),`success`)})}));let a=document.getElementById(`persistSummaryBtn`);a&&(a.checked=y.chatConfig.persistSummaryToMemory!==!1,a.addEventListener(`change`,()=>{let e=a.checked;chrome.storage.local.set({chatPersistSummaryToMemory:e},()=>{y.chatConfig.persistSummaryToMemory=e,A(t(`sidePanel.configUpdated`),`success`)})}));let o=e.querySelectorAll(`.memory-limit-option`);o.forEach(e=>{e.addEventListener(`click`,n=>{n.stopPropagation();let i=parseInt(e.dataset.value),a=i===0?null:i;o.forEach(e=>e.classList.remove(`selected`)),e.classList.add(`selected`),r&&(r.value=i===0?``:i),chrome.storage.local.set({chatMaxMemoryMessages:a},()=>{y.chatConfig.maxMemoryMessages=a,th(),A(t(`sidePanel.configUpdated`),`success`)})})}),r&&(r.addEventListener(`click`,e=>e.stopPropagation()),r.addEventListener(`mousedown`,e=>e.stopPropagation()),r.addEventListener(`change`,e=>{e.stopPropagation();let n=e.target.value.trim(),r=n&&parseInt(n)>0?parseInt(n):null;o.forEach(e=>e.classList.remove(`selected`)),chrome.storage.local.set({chatMaxMemoryMessages:r},()=>{y.chatConfig.maxMemoryMessages=r,th(),A(t(`sidePanel.configUpdated`),`success`)})})),document.getElementById(`memoryLimitConfigEntry`)?.addEventListener(`click`,()=>{chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`memory`})}),document.addEventListener(`click`,t=>{!e.contains(t.target)&&t.target!==n&&e.classList.remove(`show`)})}async function oh(e){if(y.activeAgentId&&y.activeAgentId!=="default")try{let{updateAgent:t}=await D(async()=>{let{updateAgent:e}=await import(`./agent-store-CeC2_dkP.js`).then(e=>e.t);return{updateAgent:e}},__vite__mapDeps([7,1,2,3]));await t(y.activeAgentId,{model:e})}catch{}else chrome.storage.local.set({modelName:e}),le(e)}async function sh(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=eh(e.pairedAgents),n=e.activeAgentId,r=t.find(e=>e.id===n&&!e.disabled);if(!r){y.agentPlatform={connected:!1},$(y.agentPlatform);return}if(r.token)try{let e=await fetch(`${r.url}/api/status/detail`,{cache:`no-cache`,headers:{Authorization:`Bearer ${r.token}`}});if(e.ok){let t=await e.json();if(t.success){y.agentPlatform={platformName:t.platformName||`Unknown`,platform:t.platform||`unknown`,arch:t.arch||`unknown`,shell:t.shell||`/bin/sh`,homeDir:t.homeDir||``,workdir:t.workdir||``,connected:!0},t.version&&y.agentVersions.set(n,t.version),t.workdir&&y.agentWorkdirs.set(n,t.workdir),t.homeDir&&y.agentHomeDirs.set(n,t.homeDir);let e=Lh(t.platformName||t.platform,t.arch);e&&y.agentSystemInfos.set(n,e)}else y.agentPlatform={connected:!1}}else y.agentPlatform={connected:!1}}catch{y.agentPlatform={connected:!1}}else y.agentPlatform={connected:!1};$(y.agentPlatform),oa()}catch{}}async function ch(e,t,n){if(y.activeAgentId&&y.activeAgentId!=="default")try{let{updateAgent:n}=await D(async()=>{let{updateAgent:e}=await import(`./agent-store-CeC2_dkP.js`).then(e=>e.t);return{updateAgent:e}},__vite__mapDeps([7,1,2,3]));await n(y.activeAgentId,{temperature:e,topP:t})}catch{}else chrome.storage.local.set({temperature:e,topP:t,selectedTempIndex:n})}function lh(){let e=document.getElementById(`currentModelTag`);if(!e)return;let t=y.currentModel||``;e.textContent=t,e.title=t,e.style.display=t?``:`none`}var uh=new Set,dh=0;function fh(){let e=document.getElementById(`workdirTag`);e&&(e.dataset.locked=na(y.activeSessionId)?`true`:`false`)}async function ph(){let e=++dh,n=document.getElementById(`workdirTag`),i=document.getElementById(`workdirTagName`);if(!n||!i)return;let a=y.activeSessionId||null,o=Array.isArray(y.enabledTools)&&y.enabledTools.includes(`agent_exec`);if(y.agentPlatform?.connected!==!0||!o){n.style.display=`none`;return}let c=null;try{c=await p(a)}catch(e){r.debug(`[WorkdirTag] resolve failed:`,e&&e.message)}if(e!==dh)return;let l=c&&c.workdir||``;if(!l){n.style.display=`none`;return}n.style.display=``,i.textContent=s(l,{homeDir:y.agentPlatform?.homeDir||``}),fh();try{let{getWorkspaceRoot:e}=await D(async()=>{let{getWorkspaceRoot:e}=await import(`./workspace-manager-CL4JvHkJ.js`).then(e=>e.j);return{getWorkspaceRoot:e}},__vite__mapDeps([8,1,2,3])),t=await e(a),i=!!(t&&t!==l);i&&c.scope==="default"?(n.dataset.invalid=`false`,ym(a).then(e=>{e&&ph()}).catch(e=>r.debug(`[WorkdirTag] reconcile failed:`,e&&e.message))):n.dataset.invalid=i?`true`:`false`}catch{n.dataset.invalid=`false`}if(e===dh&&(n.title=`${l}${c.scope===`session`?t(`workdirTag.sessionScope`):t(`workdirTag.defaultScope`)}${n.dataset.invalid===`true`?t(`workdirTag.pathMissing`):``}`,c.boundWorkdir&&c.scope==="default")){let e=`${a||``}::${c.agentId||``}`;uh.has(e)||(uh.add(e),A(t(`workdirTag.agentSwitched`),`warning`))}}function mh(){let e=document.getElementById(`workdirTag`);e&&(e.setAttribute(`aria-label`,t(`workdirTag.tagHint`)),e.addEventListener(`click`,async e=>{if(e.stopPropagation(),na(y.activeSessionId)){fh(),A(t(`workdirTag.lockedHint`),`warning`);return}fh();let{showSwitchWorkdirDialog:n}=await D(async()=>{let{showSwitchWorkdirDialog:e}=await import(`./context-indicator-DjOAo_Ln.js`).then(e=>e.mn);return{showSwitchWorkdirDialog:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));await n({sessionId:y.activeSessionId||null})})),ph(),document.addEventListener(`session-switched`,()=>{ph()}),document.addEventListener(`session-workdir-changed`,()=>{ph()}),document.addEventListener(`agent-model-changed`,()=>{ph()}),document.addEventListener(`agent-tools-changed`,()=>{ph()}),document.addEventListener(`generating-state-changed`,()=>{fh()}),document.addEventListener(`generation-ended`,()=>{fh()}),qt(()=>{fh()})}function hh(){let e=document.getElementById(`currentModelTag`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),document.getElementById(`tempDisplay`)?.click()}),lh()}function gh(e){let t=0;document.querySelectorAll(`.model-option`).forEach(n=>{n.dataset.value===e?(n.classList.add(`selected`),n.querySelector(`.model-option-check`).textContent=`✓`,t=parseInt(n.dataset.contextWindow,10)||0):(n.classList.remove(`selected`),n.querySelector(`.model-option-check`).textContent=``)});let n=document.getElementById(`modelSelectValue`);n&&e&&(n.textContent=e);let r=document.getElementById(`modelSelectCtxBadge`);r&&(t>0?(r.textContent=g(t),r.style.display=``):r.style.display=`none`),lh()}function _h(e,n){let r=document.getElementById(`tempDropdown`);if(!r){typeof n==`function`&&n();return}let i=r.querySelector(`.model-section`),a=[];if((Array.isArray(e)?e:[]).forEach(e=>{typeof e==`string`?a.push({name:e,contextWindow:0}):e&&typeof e==`object`&&e.name&&a.push({name:e.name,contextWindow:e.contextWindow||0})}),i){i.innerHTML=`
605
605
  <div class="model-section-title" data-i18n="model.selectModel">${t(`model.selectModel`)}</div>
606
606
  <div class="section-select" id="modelSelect">
607
607
  <div class="section-select-row" id="modelSelectRow">
@@ -666,7 +666,7 @@ Are you sure you want to stop the agent service? You will not be able to connect
666
666
  </div>
667
667
  <h2>${t(`sidePanel.welcomeTitle`)}</h2>
668
668
  <p>${t(`sidePanel.welcomeSubtitle`)}</p>
669
- `,a.appendChild(e)}if(r.debug(`[SidePanel] session-switched: pendingTask?`,l,`pendingSessionIds:`,[...y.pendingCallApiSessionIds],`activeSessionId:`,n,`hasCancelApi:`,!!y.pendingCancelApi),l&&(r.debug(`[SidePanel] switch back tobackground task session,rebuildstreamingoutput element`),Hn(n)),no(n),!e.detail?.skipScrollRestore){let e=`scrollPosition_`+(n||`default`);chrome.storage.local.get([e],t=>{t[e]!==void 0&&setTimeout(async()=>{let n=document.getElementById(`chatContainer`);n&&(n.scrollTop=t[e]);let{updateScrollButtonState:r}=await D(async()=>{let{updateScrollButtonState:e}=await import(`./context-indicator-Sf2n8eWg.js`).then(e=>e.ht);return{updateScrollButtonState:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));r()},150)})}}),document.addEventListener(`session-cache-invalidate`,e=>{let{sessionId:t}=e.detail||{};t&&Xh(t)}),document.querySelectorAll(`.model-option`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=e.dataset.value;y.currentModel=n,gh(n),oh(n),Xr()})}),document.addEventListener(`agent-model-changed`,()=>{gh(y.currentModel);let e=document.getElementById(`tempSlider`),t=document.getElementById(`tempNumberInput`),n=document.getElementById(`tempIconValue`);e&&(e.value=y.temperature),t&&(t.value=y.temperature.toFixed(2)),n&&(n.textContent=y.temperature.toFixed(2)),te()}),document.addEventListener(`click`,e=>{let t=document.getElementById(`promptDropdown`),n=document.getElementById(`promptSelector`),r=document.getElementById(`agentAtSelector`),i=document.getElementById(`selectionFloatingMenu`);n.contains(e.target)||(t.classList.remove(`show`),ii()),r&&!r.contains(e.target)&&hr();let a=document.getElementById(`fileAtSelector`);if(a&&!a.contains(e.target)&&Df(),i&&!i.contains(e.target)){let t=window.getSelection(),n=ws(e.target),r=t&&!t.isCollapsed&&ws(t.anchorNode);(!n||!r)&&window.hideFloatingMenu()}});let E=document.getElementById(`stopCompanionBtn`);function ae(){let e=!!(a&&a.value&&a.value.trim())||en();return y.isGenerating&&e}function oe(){a&&a.value&&a.value.trim();let e=y.isGenerating,n=ae();s.classList.toggle(`queue-mode`,n),s.classList.toggle(`stop-mode`,e&&!n),n?(s.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h11"/><path d="M3 12h11"/><path d="M3 18h7"/><path d="M17.5 10v8"/><path d="M14.5 15.5L17.5 18.5l3-3"/></svg>`,s.title=t(`queue.enqueueBtn`)):e?(s.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>`,s.title=t(`sidePanel.sendBtnStop`)):(s.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z"/></svg>`,s.title=t(`sidePanel.sendBtnSend`)),s.disabled=!1,s.style.opacity=``,s.style.cursor=``,E&&(E.style.display=n?``:`none`,E.disabled=!1,E.style.opacity=``,E.style.cursor=``)}s.addEventListener(`click`,()=>{if(!y.isGenerating){Ni();return}ae()?pn():pi(s)}),E?.addEventListener(`click`,()=>pi(E));function se(e){if(!y.isGenerating)return!1;let n=y.activeSessionId;return n?ua(n)?(qn(n),pi(E&&E.style.display!==`none`?E:e||s)?(A(t(`queue.stopAndSendStarted`),`success`,2500),!0):(Di(n),!0)):(A(t(`queue.stopAndSendEmpty`),`warning`,3e3),!1):!1}function le(e,{isPrimarySend:t=!1}={}){if(!e)return;let n=()=>t&&ae();e.addEventListener(`contextmenu`,t=>{n()||!y.isGenerating||!ua(y.activeSessionId)||(t.preventDefault(),se(e))});let r=null,i=()=>{r&&=(clearTimeout(r),null)};e.addEventListener(`pointerdown`,t=>{t.pointerType===`mouse`&&t.button!==0||n()||!y.isGenerating||!ua(y.activeSessionId)||(i(),r=setTimeout(()=>{r=null,se(e)},600))});for(let t of[`pointerup`,`pointerleave`,`pointercancel`])e.addEventListener(t,i)}le(s,{isPrimarySend:!0}),le(E),document.addEventListener(`queue-stop-and-send`,()=>{se(E&&E.style.display!==`none`?E:s)}),document.addEventListener(`generating-state-changed`,oe),a.addEventListener(`input`,oe),document.addEventListener(`input-attachments-changed`,oe),document.addEventListener(`voice-draft-written`,oe);let ue=document.getElementById(`shortcutsBtn`),de=document.getElementById(`shortcutsModal`),fe=document.getElementById(`shortcutsCloseBtn`);function pe(){de&&(de.style.display=`flex`)}function me(){de&&(de.style.display=`none`)}ue&&ue.addEventListener(`click`,e=>{e.stopPropagation(),pe();let t=document.getElementById(`headerMoreDropdown`);t&&t.classList.remove(`show`)}),fe&&fe.addEventListener(`click`,me),de&&de.addEventListener(`click`,e=>{e.target===de&&me()});let he=Cs();Wt(),lr({adjustInputHeight:_}).catch(e=>{r.warn(`[SidePanel] initVoiceInput failed:`,e?.message||e)}),document.addEventListener(`keydown`,e=>{if((e.ctrlKey||e.metaKey)&&e.key===`t`){e.preventDefault();let t=document.getElementById(`toolsPopup`);t&&t.style.display!==`none`?fi():vr()}if(e.key===`Escape`&&an()){e.preventDefault();return}if(!(e.key===`Escape`&&he.handleEscape())){if(e.key===`Escape`&&de&&de.style.display!==`none`){me();return}if(e.altKey&&e.code===`Slash`){e.preventDefault(),pe();return}if(e.altKey&&!e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),Jr();return}if(e.altKey&&e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),Wr();return}if(ar(e)){e.preventDefault(),pr();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyN`){e.preventDefault(),Ii();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyW`){e.preventDefault(),Sr();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyE`){e.preventDefault();let t=document.querySelectorAll(`#chatContainer .message.user`),n=t[t.length-1];if(n){Ei(n);let e=document.getElementById(`userInput`);e&&e.focus()}return}if(e.altKey&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault();let t=e.key===`ArrowUp`?`prev`:`next`;he.jumpToMessage(t,e.ctrlKey||e.metaKey),he.updateActiveQuestion();return}}}),a.addEventListener(`keydown`,e=>{let t=document.getElementById(`promptSelector`),n=document.getElementById(`promptDropdown`),r=document.getElementById(`agentAtSelector`),i=document.getElementById(`agentAtDropdown`);if(r.style.display!==`none`&&i.classList.contains(`show`)){let t=document.getElementById(`agentAtTabs`),n=t&&t.classList.contains(`merged-mode`);if(!n&&e.key===`Tab`){e.preventDefault();let t=Array.from(document.querySelectorAll(`#agentAtTabs .prompt-tab`)).map(e=>e.dataset.tab),n=e=>{let t=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="${e}"]`);return!!t&&t.style.display!==`none`},r=t.indexOf(Qt);for(let e=0;e<t.length;e++)if(r=(r+1)%t.length,n(t[r])){Fi(t[r]);break}return}let r,i;n?(r=document.getElementById(`agentAtList`),i=y.selectedAgentAtIndex):Qt===`pages`?(r=document.getElementById(`agentPageList`),i=y.selectedPageIndex):Qt===`proxies`?(r=document.getElementById(`agentProxyList`),i=y.selectedProxyAtIndex):Qt===`knowledge`?(r=document.getElementById(`agentKnowledgeList`),i=y.selectedKnowledgeAtIndex):(r=document.getElementById(`agentAtList`),i=y.selectedAgentAtIndex);let a=r?r.querySelectorAll(`.prompt-item`):[],o=a.length;if(o!==0){if(e.key===`ArrowDown`){e.preventDefault();let t=i<0?0:(i+1)%o;n?(y.selectedAgentAtIndex=t,kr(a)):Qt===`proxies`?(y.selectedProxyAtIndex=t,kr(a)):Qt===`knowledge`?(y.selectedKnowledgeAtIndex=t,kr(a)):Qt===`pages`?(y.selectedPageIndex=t,$n(a)):(y.selectedAgentAtIndex=t,kr(a));return}else if(e.key===`ArrowUp`){e.preventDefault();let t=i<0||i===0?o-1:i-1;n?(y.selectedAgentAtIndex=t,kr(a)):Qt===`proxies`?(y.selectedProxyAtIndex=t,kr(a)):Qt===`knowledge`?(y.selectedKnowledgeAtIndex=t,kr(a)):Qt===`pages`?(y.selectedPageIndex=t,$n(a)):(y.selectedAgentAtIndex=t,kr(a));return}else if(e.key===`Enter`&&i>=0){e.preventDefault();let t=a[i];if(t.dataset.type===`knowledge`){rr({id:t.dataset.kbId,name:t.dataset.kbName,enabled:t.dataset.kbDisabled!==`1`},{multi:e.ctrlKey||e.metaKey});return}t.click(),(e.ctrlKey||e.metaKey)&&hr();return}else if(e.key===`Escape`){hr();return}}}let o=document.getElementById(`fileAtSelector`),s=document.getElementById(`fileAtDropdown`);if(o&&s&&o.style.display!==`none`&&s.classList.contains(`show`)){let t=document.getElementById(`fileAtList`),n=t?t.querySelectorAll(`.prompt-item`):[],r=n.length;if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),r>0&&(y.selectedFileAtIndex=e.key===`ArrowDown`?y.selectedFileAtIndex<0?0:(y.selectedFileAtIndex+1)%r:y.selectedFileAtIndex<0||y.selectedFileAtIndex===0?r-1:y.selectedFileAtIndex-1,Mf(n));return}if(e.key===`Enter`&&r>0&&y.selectedFileAtIndex>=0){e.preventDefault(),n[y.selectedFileAtIndex].click();return}if(e.key===`Escape`){e.preventDefault(),Df();return}}if(t.style.display!==`none`&&n.classList.contains(`show`)){if(y.showMergedList){let t=n.querySelectorAll(`#promptList .prompt-item`),r=t.length;if(e.key===`ArrowDown`){e.preventDefault(),y.selectedPromptIndex<0?y.selectedPromptIndex=0:y.selectedPromptIndex=(y.selectedPromptIndex+1)%r,$t(t);return}if(e.key===`ArrowUp`){e.preventDefault(),y.selectedPromptIndex<0||y.selectedPromptIndex===0?y.selectedPromptIndex=r-1:--y.selectedPromptIndex,$t(t);return}if(e.key===`Enter`&&y.selectedPromptIndex>=0){e.preventDefault();let n=t[y.selectedPromptIndex],r=e.ctrlKey||e.metaKey;n.dataset.type===`skill`?Ui(n.dataset.skillName,{multi:r}):n.dataset.type===`mcp`?si(n.dataset.serverId,n.dataset.serverName,{multi:r}):r?ei(n.dataset.code):gn(n.dataset.code);return}if(e.key===`Escape`){ii();return}return}if(y.activeDropdownTab===`skills`){let t=n.querySelectorAll(`#skillList .skill-list-item`),r=t.length;if(e.key===`ArrowDown`){e.preventDefault(),y.selectedSkillIndex<0?y.selectedSkillIndex=0:y.selectedSkillIndex=(y.selectedSkillIndex+1)%r,Lt(t);return}if(e.key===`ArrowUp`){e.preventDefault(),y.selectedSkillIndex<0||y.selectedSkillIndex===0?y.selectedSkillIndex=r-1:--y.selectedSkillIndex,Lt(t);return}if(e.key===`Enter`&&y.selectedSkillIndex>=0){e.preventDefault();let n=t[y.selectedSkillIndex];Ui(n.dataset.skillName,{multi:e.ctrlKey||e.metaKey});return}if(e.key===`Escape`){ii();return}if(e.key===`Tab`){e.preventDefault();let t=document.getElementById(`mcpTab`);t&&t.style.display!==`none`?Zi(`mcp`):Zi(`prompts`);return}return}if(y.activeDropdownTab===`mcp`){let t=n.querySelectorAll(`#mcpList .mcp-list-item`),r=t.length;if(e.key===`ArrowDown`){e.preventDefault(),y.selectedMcpServiceIndex<0?y.selectedMcpServiceIndex=0:y.selectedMcpServiceIndex=(y.selectedMcpServiceIndex+1)%r,Un(t);return}if(e.key===`ArrowUp`){e.preventDefault(),y.selectedMcpServiceIndex<0||y.selectedMcpServiceIndex===0?y.selectedMcpServiceIndex=r-1:--y.selectedMcpServiceIndex,Un(t);return}if(e.key===`Enter`&&y.selectedMcpServiceIndex>=0){e.preventDefault();let n=t[y.selectedMcpServiceIndex];si(n.dataset.serverId,n.dataset.serverName,{multi:e.ctrlKey||e.metaKey});return}if(e.key===`Escape`){ii();return}if(e.key===`Tab`){e.preventDefault(),Zi(`prompts`);return}return}let t=n.querySelectorAll(`#promptList .prompt-item`),r=t.length;if(e.key===`Tab`){let t=document.getElementById(`skillsTab`),n=document.getElementById(`mcpTab`);if(t&&t.style.display!==`none`){e.preventDefault(),Zi(`skills`);return}if(n&&n.style.display!==`none`){e.preventDefault(),Zi(`mcp`);return}}if(r!==0&&e.key===`ArrowDown`){e.preventDefault(),y.selectedPromptIndex<0?y.selectedPromptIndex=0:y.selectedPromptIndex=(y.selectedPromptIndex+1)%r,$t(t);return}if(e.key===`ArrowUp`){e.preventDefault(),y.selectedPromptIndex<0||y.selectedPromptIndex===0?y.selectedPromptIndex=r-1:--y.selectedPromptIndex,$t(t);return}if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&y.selectedPromptIndex>=0){e.preventDefault();let n=t[y.selectedPromptIndex].dataset.code;ei(n);return}if(e.key===`Enter`&&y.selectedPromptIndex>=0){e.preventDefault();let n=t[y.selectedPromptIndex].dataset.code;gn(n);return}if(e.key===`Escape`){ii();return}}if(e.key===`Escape`){y.inputHistoryIndex>=0&&(y.inputHistoryIndex=-1),a.value&&(a.value=``,a.style.height=`auto`,a.dispatchEvent(new Event(`input`))),e.preventDefault();return}let c=t.style.display!==`none`&&n.classList.contains(`show`),l=r.style.display!==`none`&&i.classList.contains(`show`),u=o.style.display!==`none`&&s.classList.contains(`show`);if(e.key===`ArrowUp`&&y.inputHistoryIndex===-1&&!a.value.trim()&&!en()&&om()){e.preventDefault();return}if(!c&&!l&&!u){let t=Lp({key:e.key,value:a.value,caret:a.selectionStart,history:y.inputHistory,index:y.inputHistoryIndex});if(t.handled){e.preventDefault(),y.inputHistoryIndex=t.index,a.value=t.value,a.dispatchEvent(new Event(`input`)),a.setSelectionRange(t.value.length,t.value.length);return}}if(e.key===`Enter`&&!e.shiftKey){if(y.isComposing)return;if(e.preventDefault(),Df(),y.isGenerating){if(e.altKey){Zn(a.value);return}pn();return}Ni()}}),a.addEventListener(`compositionstart`,()=>{y.isComposing=!0}),a.addEventListener(`compositionend`,()=>{y.isComposing=!1}),a.addEventListener(`paste`,e=>{let t=e.clipboardData?.items;if(t)for(let n of t){if(n.type.startsWith(`image/`)&&y.enableImageInput){e.preventDefault();let t=n.getAsFile();t&&Tn(t);break}if(n.kind===`file`&&y.enableFileInput){e.preventDefault();let t=n.getAsFile();t&&Wn([t]);break}}});let ge=document.getElementById(`fileAttachBtn`),_e=document.getElementById(`fileInput`);ge&&_e&&(ge.addEventListener(`click`,()=>{_e.click()}),_e.addEventListener(`change`,async()=>{if(_e.files.length>0){let e=Array.from(_e.files),n=e.filter(e=>e.type.startsWith(`image/`)),r=e.filter(e=>!e.type.startsWith(`image/`));if(n.length>0)if(y.enableImageInput)for(let e of n)await Tn(e);else A(t(`sidePanel.imageNotEnabled`)),Wn(n);r.length>0&&Wn(r),_e.value=``}}));let ve=document.querySelector(`.input-wrapper`),ye=0;ve&&(ve.addEventListener(`dragenter`,e=>{e.preventDefault(),e.stopPropagation(),ye++,ve.classList.add(`drag-over`)}),ve.addEventListener(`dragleave`,e=>{e.preventDefault(),e.stopPropagation(),ye--,ye<=0&&(ye=0,ve.classList.remove(`drag-over`))}),ve.addEventListener(`dragover`,e=>{e.preventDefault(),e.stopPropagation()}),ve.addEventListener(`drop`,async e=>{e.preventDefault(),e.stopPropagation(),ye=0,ve.classList.remove(`drag-over`);let n=e.dataTransfer.getData(`application/x-workspace-file`);if(n){e.preventDefault();try{let{path:e}=JSON.parse(n);if(e){ci([e]);return}}catch(e){r.warn(`[SidePanel] parse workspace dragdata failed:`,e)}}let i=Array.from(e.dataTransfer.files);if(i.length>0){e.preventDefault();let n=i.filter(e=>e.type.startsWith(`image/`)),r=i.filter(e=>!e.type.startsWith(`image/`));if(n.length>0)if(y.enableImageInput)for(let e of n)await Tn(e);else A(t(`sidePanel.imageNotEnabled`)),Wn(n);r.length>0&&Wn(r);return}let o=e.dataTransfer.getData(`text/plain`);if(o&&(e.preventDefault(),a)){a.focus();let e=a.selectionStart??a.value.length,t=a.selectionEnd??a.value.length;a.value=a.value.slice(0,e)+o+a.value.slice(t),a.selectionStart=a.selectionEnd=e+o.length,a.dispatchEvent(new Event(`input`))}}));let be=document.getElementById(`screenshotBtn`);be&&be.addEventListener(`click`,async()=>{if(y.enableImageInput)try{await Jr()}catch(e){r.error(`[SidePanel] screenshot failed:`,e),A(t(`sidePanel.screenshotFailed`))}}),ai(),a.addEventListener(`wheel`,e=>{y.isScrolling=!0;let t=a.style.height||a.offsetHeight+`px`;a.style.height=t,a.scrollHeight<=a.clientHeight+10&&(e.preventDefault(),e.stopPropagation()),setTimeout(()=>{y.isScrolling=!1},100)},{passive:!1}),a.addEventListener(`input`,e=>{let t=a.value,n=document.getElementById(`promptSelector`),r=document.getElementById(`promptDropdown`);document.getElementById(`agentAtSelector`),document.getElementById(`agentAtDropdown`);let i=Nr({value:t,caret:a.selectionStart});i&&i.key===`dollar`?(ii(),hr(),Ef(i.filterText)):i&&i.key===`at`?(ii(),Df(),yi(i.filterText)):i&&i.key===`slash`?(hr(),Df(),n.style.display!==`none`&&r.classList.contains(`show`)?Vt(i.filterText):On(i.filterText)):(ii(),hr(),Df()),_()});let xe=Rp((e,t)=>{chrome.storage.local.set({[e]:t})},200);u.addEventListener(`scroll`,()=>{xe(`scrollPosition_`+(y.activeSessionId||`default`),u.scrollTop)}),window.addEventListener(`pagehide`,()=>{chrome.storage.local.set({[`scrollPosition_`+(y.activeSessionId||`default`)]:u.scrollTop})});let Se=document.getElementById(`headerMoreBtn`),Ce=document.getElementById(`headerMoreDropdown`);Se&&Ce&&(Se.addEventListener(`click`,e=>{e.stopPropagation(),Ce.classList.toggle(`show`)}),document.addEventListener(`click`,e=>{!Ce.contains(e.target)&&e.target!==Se&&ke()}));let we=document.getElementById(`themeToggleBtn`),Te=document.getElementById(`themeToggleLabel`),Ee=document.getElementById(`themeSubmenu`),De=e=>t(e===`dark`?`settings.themeDark`:e===`system`?`settings.themeSystem`:`settings.themeLight`),Oe=()=>{let e=tt();Te&&(Te.textContent=t(`header.themeToggle`,{theme:De(e)})),Ee&&Ee.querySelectorAll(`.theme-submenu-item`).forEach(t=>{t.classList.toggle(`active`,t.dataset.themeValue===e)}),we&&we.setAttribute(`aria-expanded`,String(!!(Ee&&Ee.classList.contains(`show`))))};function ke(){Ee&&Ee.classList.remove(`show`),Ce&&Ce.classList.remove(`show`),we&&we.setAttribute(`aria-expanded`,`false`)}we&&Ee&&(we.addEventListener(`click`,e=>{e.stopPropagation(),Ee.classList.toggle(`show`),Oe()}),Ee.querySelectorAll(`.theme-submenu-item`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),lt(e.dataset.themeValue),ke()})})),Oe(),mt(Oe),o(Oe),c.addEventListener(`click`,e=>{e.stopPropagation(),ke(),xi()}),l&&l.addEventListener(`click`,e=>{e.stopPropagation(),ke(),_n()});let Ae=document.getElementById(`importChatBtn`);Ae&&Ae.addEventListener(`click`,e=>{e.stopPropagation(),ke(),xn()});let je=document.getElementById(`importSessionsFile`);je&&je.addEventListener(`change`,e=>{let t=e.target.files[0];t&&St(t)});let Me=document.getElementById(`settingsBtn`);Me&&Me.addEventListener(`click`,()=>{chrome.runtime.openOptionsPage()});let Ne=document.getElementById(`headerAgentIndicator`);Ne&&Ne.addEventListener(`click`,async()=>{let e=chrome.runtime.getURL(`options.html#agent`),t=await chrome.tabs.query({url:chrome.runtime.getURL(`options.html`)});t.length>0?await chrome.tabs.update(t[0].id,{active:!0,url:e}):await chrome.tabs.create({url:e})});let Pe=document.getElementById(`prototypeLibraryBtn`);Pe&&Pe.addEventListener(`click`,e=>{e.stopPropagation(),ke(),Qr()});let O=document.getElementById(`tokenStatsHeaderBtn`);O&&O.addEventListener(`click`,e=>{e.stopPropagation(),ke(),window.openTokenStats&&window.openTokenStats()});let Fe=document.getElementById(`auditLogBtn`),Ie=document.getElementById(`auditLogOverlay`),Le=document.getElementById(`auditLogClose`),Re=document.getElementById(`auditLogRefreshBtn`),ze=document.getElementById(`auditLogCategoryFilter`),Be=document.getElementById(`auditLogLimit`),Ve=document.getElementById(`auditLogSearch`),He=document.getElementById(`auditLogSearchClear`),Ue=document.getElementById(`auditLogLoading`),We=document.getElementById(`auditLogEmpty`),Ke=document.getElementById(`auditLogList`),qe=[],Je={auth:t(`sidePanel.auditCategoryAuth`),fs:t(`sidePanel.auditCategoryFs`),exec:t(`sidePanel.auditCategoryExec`),security:t(`sidePanel.auditCategorySecurity`),system:t(`sidePanel.auditCategorySystem`)},Xe={info:`INFO`,warn:`WARN`,error:`ERROR`},Ze={info:`audit-level-info`,warn:`audit-level-warn`,error:`audit-level-error`};function Qe(e){if(!e)return`-`;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function $e(e){let n=new Set([`timestamp`,`level`,`category`,`action`]),r=[];for(let[t,i]of Object.entries(e)){if(n.has(t))continue;let e=typeof i==`string`?i:JSON.stringify(i),a=e.length>60?e.slice(0,60)+`...`:e;r.push(`${t}: ${a}`)}return r.join(t(`sidePanel.auditDetailSeparator`))}async function et(){if(!Ue||!We||!Ke)return;Ue.style.display=`block`,We.style.display=`none`,Ke.style.display=`none`;let e=ze?.value||null,n=parseInt(Be?.value||`200`,10);try{let r=await new Promise((t,r)=>{chrome.runtime.sendMessage({type:`QUERY_AUDIT_LOGS`,category:e,limit:n},e=>{chrome.runtime.lastError?r(Error(chrome.runtime.lastError.message)):t(e)})});if(Ue.style.display=`none`,!r||!r.success){We.style.display=`block`,We.textContent=t(`sidePanel.auditQueryFailed`,{error:r?.error||t(`sidePanel.unknownError`)});return}qe=r.entries||[],rt()}catch(e){Ue.style.display=`none`,We.style.display=`block`,We.textContent=t(`sidePanel.auditLoadFailed`,{error:e.message})}}function rt(){if(!Ke)return;let e=(Ve?.value||``).trim().toLowerCase(),n=qe;if(e&&(n=n.filter(t=>[t.action||``,t.category||``,...Object.entries(t).filter(([e])=>![`timestamp`,`level`,`category`,`action`].includes(e)).map(([,e])=>typeof e==`string`?e:JSON.stringify(e))].join(` `).toLowerCase().includes(e))),He&&(He.style.display=e?`block`:`none`),Ue.style.display=`none`,n.length===0){We.style.display=`block`,We.textContent=t(e?`sidePanel.auditNoMatch`:`sidePanel.auditEmpty`),Ke.style.display=`none`;return}We.style.display=`none`,Ke.style.display=`block`,Ke.innerHTML=n.map(e=>{let t=k(Je[e.category]||e.category||`-`),n=k(Xe[e.level]||e.level?.toUpperCase()||`INFO`),r=Ze[e.level]||`audit-level-info`,i=Qe(e.timestamp),a=k($e(e));return`<div class="audit-entry">
669
+ `,a.appendChild(e)}if(r.debug(`[SidePanel] session-switched: pendingTask?`,l,`pendingSessionIds:`,[...y.pendingCallApiSessionIds],`activeSessionId:`,n,`hasCancelApi:`,!!y.pendingCancelApi),l&&(r.debug(`[SidePanel] switch back tobackground task session,rebuildstreamingoutput element`),Hn(n)),no(n),!e.detail?.skipScrollRestore){let e=`scrollPosition_`+(n||`default`);chrome.storage.local.get([e],t=>{t[e]!==void 0&&setTimeout(async()=>{let n=document.getElementById(`chatContainer`);n&&(n.scrollTop=t[e]);let{updateScrollButtonState:r}=await D(async()=>{let{updateScrollButtonState:e}=await import(`./context-indicator-DjOAo_Ln.js`).then(e=>e.ht);return{updateScrollButtonState:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));r()},150)})}}),document.addEventListener(`session-cache-invalidate`,e=>{let{sessionId:t}=e.detail||{};t&&Xh(t)}),document.querySelectorAll(`.model-option`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=e.dataset.value;y.currentModel=n,gh(n),oh(n),Xr()})}),document.addEventListener(`agent-model-changed`,()=>{gh(y.currentModel);let e=document.getElementById(`tempSlider`),t=document.getElementById(`tempNumberInput`),n=document.getElementById(`tempIconValue`);e&&(e.value=y.temperature),t&&(t.value=y.temperature.toFixed(2)),n&&(n.textContent=y.temperature.toFixed(2)),te()}),document.addEventListener(`click`,e=>{let t=document.getElementById(`promptDropdown`),n=document.getElementById(`promptSelector`),r=document.getElementById(`agentAtSelector`),i=document.getElementById(`selectionFloatingMenu`);n.contains(e.target)||(t.classList.remove(`show`),ii()),r&&!r.contains(e.target)&&hr();let a=document.getElementById(`fileAtSelector`);if(a&&!a.contains(e.target)&&Df(),i&&!i.contains(e.target)){let t=window.getSelection(),n=ws(e.target),r=t&&!t.isCollapsed&&ws(t.anchorNode);(!n||!r)&&window.hideFloatingMenu()}});let E=document.getElementById(`stopCompanionBtn`);function ae(){let e=!!(a&&a.value&&a.value.trim())||en();return y.isGenerating&&e}function oe(){a&&a.value&&a.value.trim();let e=y.isGenerating,n=ae();s.classList.toggle(`queue-mode`,n),s.classList.toggle(`stop-mode`,e&&!n),n?(s.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h11"/><path d="M3 12h11"/><path d="M3 18h7"/><path d="M17.5 10v8"/><path d="M14.5 15.5L17.5 18.5l3-3"/></svg>`,s.title=t(`queue.enqueueBtn`)):e?(s.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>`,s.title=t(`sidePanel.sendBtnStop`)):(s.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z"/></svg>`,s.title=t(`sidePanel.sendBtnSend`)),s.disabled=!1,s.style.opacity=``,s.style.cursor=``,E&&(E.style.display=n?``:`none`,E.disabled=!1,E.style.opacity=``,E.style.cursor=``)}s.addEventListener(`click`,()=>{if(!y.isGenerating){Ni();return}ae()?pn():pi(s)}),E?.addEventListener(`click`,()=>pi(E));function se(e){if(!y.isGenerating)return!1;let n=y.activeSessionId;return n?ua(n)?(qn(n),pi(E&&E.style.display!==`none`?E:e||s)?(A(t(`queue.stopAndSendStarted`),`success`,2500),!0):(Di(n),!0)):(A(t(`queue.stopAndSendEmpty`),`warning`,3e3),!1):!1}function le(e,{isPrimarySend:t=!1}={}){if(!e)return;let n=()=>t&&ae();e.addEventListener(`contextmenu`,t=>{n()||!y.isGenerating||!ua(y.activeSessionId)||(t.preventDefault(),se(e))});let r=null,i=()=>{r&&=(clearTimeout(r),null)};e.addEventListener(`pointerdown`,t=>{t.pointerType===`mouse`&&t.button!==0||n()||!y.isGenerating||!ua(y.activeSessionId)||(i(),r=setTimeout(()=>{r=null,se(e)},600))});for(let t of[`pointerup`,`pointerleave`,`pointercancel`])e.addEventListener(t,i)}le(s,{isPrimarySend:!0}),le(E),document.addEventListener(`queue-stop-and-send`,()=>{se(E&&E.style.display!==`none`?E:s)}),document.addEventListener(`generating-state-changed`,oe),a.addEventListener(`input`,oe),document.addEventListener(`input-attachments-changed`,oe),document.addEventListener(`voice-draft-written`,oe);let ue=document.getElementById(`shortcutsBtn`),de=document.getElementById(`shortcutsModal`),fe=document.getElementById(`shortcutsCloseBtn`);function pe(){de&&(de.style.display=`flex`)}function me(){de&&(de.style.display=`none`)}ue&&ue.addEventListener(`click`,e=>{e.stopPropagation(),pe();let t=document.getElementById(`headerMoreDropdown`);t&&t.classList.remove(`show`)}),fe&&fe.addEventListener(`click`,me),de&&de.addEventListener(`click`,e=>{e.target===de&&me()});let he=Cs();Wt(),lr({adjustInputHeight:_}).catch(e=>{r.warn(`[SidePanel] initVoiceInput failed:`,e?.message||e)}),document.addEventListener(`keydown`,e=>{if((e.ctrlKey||e.metaKey)&&e.key===`t`){e.preventDefault();let t=document.getElementById(`toolsPopup`);t&&t.style.display!==`none`?fi():vr()}if(e.key===`Escape`&&an()){e.preventDefault();return}if(!(e.key===`Escape`&&he.handleEscape())){if(e.key===`Escape`&&de&&de.style.display!==`none`){me();return}if(e.altKey&&e.code===`Slash`){e.preventDefault(),pe();return}if(e.altKey&&!e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),Jr();return}if(e.altKey&&e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),Wr();return}if(ar(e)){e.preventDefault(),pr();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyN`){e.preventDefault(),Ii();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyW`){e.preventDefault(),Sr();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyE`){e.preventDefault();let t=document.querySelectorAll(`#chatContainer .message.user`),n=t[t.length-1];if(n){Ei(n);let e=document.getElementById(`userInput`);e&&e.focus()}return}if(e.altKey&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault();let t=e.key===`ArrowUp`?`prev`:`next`;he.jumpToMessage(t,e.ctrlKey||e.metaKey),he.updateActiveQuestion();return}}}),a.addEventListener(`keydown`,e=>{let t=document.getElementById(`promptSelector`),n=document.getElementById(`promptDropdown`),r=document.getElementById(`agentAtSelector`),i=document.getElementById(`agentAtDropdown`);if(r.style.display!==`none`&&i.classList.contains(`show`)){let t=document.getElementById(`agentAtTabs`),n=t&&t.classList.contains(`merged-mode`);if(!n&&e.key===`Tab`){e.preventDefault();let t=Array.from(document.querySelectorAll(`#agentAtTabs .prompt-tab`)).map(e=>e.dataset.tab),n=e=>{let t=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="${e}"]`);return!!t&&t.style.display!==`none`},r=t.indexOf(Qt);for(let e=0;e<t.length;e++)if(r=(r+1)%t.length,n(t[r])){Fi(t[r]);break}return}let r,i;n?(r=document.getElementById(`agentAtList`),i=y.selectedAgentAtIndex):Qt===`pages`?(r=document.getElementById(`agentPageList`),i=y.selectedPageIndex):Qt===`proxies`?(r=document.getElementById(`agentProxyList`),i=y.selectedProxyAtIndex):Qt===`knowledge`?(r=document.getElementById(`agentKnowledgeList`),i=y.selectedKnowledgeAtIndex):(r=document.getElementById(`agentAtList`),i=y.selectedAgentAtIndex);let a=r?r.querySelectorAll(`.prompt-item`):[],o=a.length;if(o!==0){if(e.key===`ArrowDown`){e.preventDefault();let t=i<0?0:(i+1)%o;n?(y.selectedAgentAtIndex=t,kr(a)):Qt===`proxies`?(y.selectedProxyAtIndex=t,kr(a)):Qt===`knowledge`?(y.selectedKnowledgeAtIndex=t,kr(a)):Qt===`pages`?(y.selectedPageIndex=t,$n(a)):(y.selectedAgentAtIndex=t,kr(a));return}else if(e.key===`ArrowUp`){e.preventDefault();let t=i<0||i===0?o-1:i-1;n?(y.selectedAgentAtIndex=t,kr(a)):Qt===`proxies`?(y.selectedProxyAtIndex=t,kr(a)):Qt===`knowledge`?(y.selectedKnowledgeAtIndex=t,kr(a)):Qt===`pages`?(y.selectedPageIndex=t,$n(a)):(y.selectedAgentAtIndex=t,kr(a));return}else if(e.key===`Enter`&&i>=0){e.preventDefault();let t=a[i];if(t.dataset.type===`knowledge`){rr({id:t.dataset.kbId,name:t.dataset.kbName,enabled:t.dataset.kbDisabled!==`1`},{multi:e.ctrlKey||e.metaKey});return}t.click(),(e.ctrlKey||e.metaKey)&&hr();return}else if(e.key===`Escape`){hr();return}}}let o=document.getElementById(`fileAtSelector`),s=document.getElementById(`fileAtDropdown`);if(o&&s&&o.style.display!==`none`&&s.classList.contains(`show`)){let t=document.getElementById(`fileAtList`),n=t?t.querySelectorAll(`.prompt-item`):[],r=n.length;if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),r>0&&(y.selectedFileAtIndex=e.key===`ArrowDown`?y.selectedFileAtIndex<0?0:(y.selectedFileAtIndex+1)%r:y.selectedFileAtIndex<0||y.selectedFileAtIndex===0?r-1:y.selectedFileAtIndex-1,Mf(n));return}if(e.key===`Enter`&&r>0&&y.selectedFileAtIndex>=0){e.preventDefault(),n[y.selectedFileAtIndex].click();return}if(e.key===`Escape`){e.preventDefault(),Df();return}}if(t.style.display!==`none`&&n.classList.contains(`show`)){if(y.showMergedList){let t=n.querySelectorAll(`#promptList .prompt-item`),r=t.length;if(e.key===`ArrowDown`){e.preventDefault(),y.selectedPromptIndex<0?y.selectedPromptIndex=0:y.selectedPromptIndex=(y.selectedPromptIndex+1)%r,$t(t);return}if(e.key===`ArrowUp`){e.preventDefault(),y.selectedPromptIndex<0||y.selectedPromptIndex===0?y.selectedPromptIndex=r-1:--y.selectedPromptIndex,$t(t);return}if(e.key===`Enter`&&y.selectedPromptIndex>=0){e.preventDefault();let n=t[y.selectedPromptIndex],r=e.ctrlKey||e.metaKey;n.dataset.type===`skill`?Ui(n.dataset.skillName,{multi:r}):n.dataset.type===`mcp`?si(n.dataset.serverId,n.dataset.serverName,{multi:r}):r?ei(n.dataset.code):gn(n.dataset.code);return}if(e.key===`Escape`){ii();return}return}if(y.activeDropdownTab===`skills`){let t=n.querySelectorAll(`#skillList .skill-list-item`),r=t.length;if(e.key===`ArrowDown`){e.preventDefault(),y.selectedSkillIndex<0?y.selectedSkillIndex=0:y.selectedSkillIndex=(y.selectedSkillIndex+1)%r,Lt(t);return}if(e.key===`ArrowUp`){e.preventDefault(),y.selectedSkillIndex<0||y.selectedSkillIndex===0?y.selectedSkillIndex=r-1:--y.selectedSkillIndex,Lt(t);return}if(e.key===`Enter`&&y.selectedSkillIndex>=0){e.preventDefault();let n=t[y.selectedSkillIndex];Ui(n.dataset.skillName,{multi:e.ctrlKey||e.metaKey});return}if(e.key===`Escape`){ii();return}if(e.key===`Tab`){e.preventDefault();let t=document.getElementById(`mcpTab`);t&&t.style.display!==`none`?Zi(`mcp`):Zi(`prompts`);return}return}if(y.activeDropdownTab===`mcp`){let t=n.querySelectorAll(`#mcpList .mcp-list-item`),r=t.length;if(e.key===`ArrowDown`){e.preventDefault(),y.selectedMcpServiceIndex<0?y.selectedMcpServiceIndex=0:y.selectedMcpServiceIndex=(y.selectedMcpServiceIndex+1)%r,Un(t);return}if(e.key===`ArrowUp`){e.preventDefault(),y.selectedMcpServiceIndex<0||y.selectedMcpServiceIndex===0?y.selectedMcpServiceIndex=r-1:--y.selectedMcpServiceIndex,Un(t);return}if(e.key===`Enter`&&y.selectedMcpServiceIndex>=0){e.preventDefault();let n=t[y.selectedMcpServiceIndex];si(n.dataset.serverId,n.dataset.serverName,{multi:e.ctrlKey||e.metaKey});return}if(e.key===`Escape`){ii();return}if(e.key===`Tab`){e.preventDefault(),Zi(`prompts`);return}return}let t=n.querySelectorAll(`#promptList .prompt-item`),r=t.length;if(e.key===`Tab`){let t=document.getElementById(`skillsTab`),n=document.getElementById(`mcpTab`);if(t&&t.style.display!==`none`){e.preventDefault(),Zi(`skills`);return}if(n&&n.style.display!==`none`){e.preventDefault(),Zi(`mcp`);return}}if(r!==0&&e.key===`ArrowDown`){e.preventDefault(),y.selectedPromptIndex<0?y.selectedPromptIndex=0:y.selectedPromptIndex=(y.selectedPromptIndex+1)%r,$t(t);return}if(e.key===`ArrowUp`){e.preventDefault(),y.selectedPromptIndex<0||y.selectedPromptIndex===0?y.selectedPromptIndex=r-1:--y.selectedPromptIndex,$t(t);return}if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&y.selectedPromptIndex>=0){e.preventDefault();let n=t[y.selectedPromptIndex].dataset.code;ei(n);return}if(e.key===`Enter`&&y.selectedPromptIndex>=0){e.preventDefault();let n=t[y.selectedPromptIndex].dataset.code;gn(n);return}if(e.key===`Escape`){ii();return}}if(e.key===`Escape`){y.inputHistoryIndex>=0&&(y.inputHistoryIndex=-1),a.value&&(a.value=``,a.style.height=`auto`,a.dispatchEvent(new Event(`input`))),e.preventDefault();return}let c=t.style.display!==`none`&&n.classList.contains(`show`),l=r.style.display!==`none`&&i.classList.contains(`show`),u=o.style.display!==`none`&&s.classList.contains(`show`);if(e.key===`ArrowUp`&&y.inputHistoryIndex===-1&&!a.value.trim()&&!en()&&om()){e.preventDefault();return}if(!c&&!l&&!u){let t=Lp({key:e.key,value:a.value,caret:a.selectionStart,history:y.inputHistory,index:y.inputHistoryIndex});if(t.handled){e.preventDefault(),y.inputHistoryIndex=t.index,a.value=t.value,a.dispatchEvent(new Event(`input`)),a.setSelectionRange(t.value.length,t.value.length);return}}if(e.key===`Enter`&&!e.shiftKey){if(y.isComposing)return;if(e.preventDefault(),Df(),y.isGenerating){if(e.altKey){Zn(a.value);return}pn();return}Ni()}}),a.addEventListener(`compositionstart`,()=>{y.isComposing=!0}),a.addEventListener(`compositionend`,()=>{y.isComposing=!1}),a.addEventListener(`paste`,e=>{let t=e.clipboardData?.items;if(t)for(let n of t){if(n.type.startsWith(`image/`)&&y.enableImageInput){e.preventDefault();let t=n.getAsFile();t&&Tn(t);break}if(n.kind===`file`&&y.enableFileInput){e.preventDefault();let t=n.getAsFile();t&&Wn([t]);break}}});let ge=document.getElementById(`fileAttachBtn`),_e=document.getElementById(`fileInput`);ge&&_e&&(ge.addEventListener(`click`,()=>{_e.click()}),_e.addEventListener(`change`,async()=>{if(_e.files.length>0){let e=Array.from(_e.files),n=e.filter(e=>e.type.startsWith(`image/`)),r=e.filter(e=>!e.type.startsWith(`image/`));if(n.length>0)if(y.enableImageInput)for(let e of n)await Tn(e);else A(t(`sidePanel.imageNotEnabled`)),Wn(n);r.length>0&&Wn(r),_e.value=``}}));let ve=document.querySelector(`.input-wrapper`),ye=0;ve&&(ve.addEventListener(`dragenter`,e=>{e.preventDefault(),e.stopPropagation(),ye++,ve.classList.add(`drag-over`)}),ve.addEventListener(`dragleave`,e=>{e.preventDefault(),e.stopPropagation(),ye--,ye<=0&&(ye=0,ve.classList.remove(`drag-over`))}),ve.addEventListener(`dragover`,e=>{e.preventDefault(),e.stopPropagation()}),ve.addEventListener(`drop`,async e=>{e.preventDefault(),e.stopPropagation(),ye=0,ve.classList.remove(`drag-over`);let n=e.dataTransfer.getData(`application/x-workspace-file`);if(n){e.preventDefault();try{let{path:e}=JSON.parse(n);if(e){ci([e]);return}}catch(e){r.warn(`[SidePanel] parse workspace dragdata failed:`,e)}}let i=Array.from(e.dataTransfer.files);if(i.length>0){e.preventDefault();let n=i.filter(e=>e.type.startsWith(`image/`)),r=i.filter(e=>!e.type.startsWith(`image/`));if(n.length>0)if(y.enableImageInput)for(let e of n)await Tn(e);else A(t(`sidePanel.imageNotEnabled`)),Wn(n);r.length>0&&Wn(r);return}let o=e.dataTransfer.getData(`text/plain`);if(o&&(e.preventDefault(),a)){a.focus();let e=a.selectionStart??a.value.length,t=a.selectionEnd??a.value.length;a.value=a.value.slice(0,e)+o+a.value.slice(t),a.selectionStart=a.selectionEnd=e+o.length,a.dispatchEvent(new Event(`input`))}}));let be=document.getElementById(`screenshotBtn`);be&&be.addEventListener(`click`,async()=>{if(y.enableImageInput)try{await Jr()}catch(e){r.error(`[SidePanel] screenshot failed:`,e),A(t(`sidePanel.screenshotFailed`))}}),ai(),a.addEventListener(`wheel`,e=>{y.isScrolling=!0;let t=a.style.height||a.offsetHeight+`px`;a.style.height=t,a.scrollHeight<=a.clientHeight+10&&(e.preventDefault(),e.stopPropagation()),setTimeout(()=>{y.isScrolling=!1},100)},{passive:!1}),a.addEventListener(`input`,e=>{let t=a.value,n=document.getElementById(`promptSelector`),r=document.getElementById(`promptDropdown`);document.getElementById(`agentAtSelector`),document.getElementById(`agentAtDropdown`);let i=Nr({value:t,caret:a.selectionStart});i&&i.key===`dollar`?(ii(),hr(),Ef(i.filterText)):i&&i.key===`at`?(ii(),Df(),yi(i.filterText)):i&&i.key===`slash`?(hr(),Df(),n.style.display!==`none`&&r.classList.contains(`show`)?Vt(i.filterText):On(i.filterText)):(ii(),hr(),Df()),_()});let xe=Rp((e,t)=>{chrome.storage.local.set({[e]:t})},200);u.addEventListener(`scroll`,()=>{xe(`scrollPosition_`+(y.activeSessionId||`default`),u.scrollTop)}),window.addEventListener(`pagehide`,()=>{chrome.storage.local.set({[`scrollPosition_`+(y.activeSessionId||`default`)]:u.scrollTop})});let Se=document.getElementById(`headerMoreBtn`),Ce=document.getElementById(`headerMoreDropdown`);Se&&Ce&&(Se.addEventListener(`click`,e=>{e.stopPropagation(),Ce.classList.toggle(`show`)}),document.addEventListener(`click`,e=>{!Ce.contains(e.target)&&e.target!==Se&&ke()}));let we=document.getElementById(`themeToggleBtn`),Te=document.getElementById(`themeToggleLabel`),Ee=document.getElementById(`themeSubmenu`),De=e=>t(e===`dark`?`settings.themeDark`:e===`system`?`settings.themeSystem`:`settings.themeLight`),Oe=()=>{let e=tt();Te&&(Te.textContent=t(`header.themeToggle`,{theme:De(e)})),Ee&&Ee.querySelectorAll(`.theme-submenu-item`).forEach(t=>{t.classList.toggle(`active`,t.dataset.themeValue===e)}),we&&we.setAttribute(`aria-expanded`,String(!!(Ee&&Ee.classList.contains(`show`))))};function ke(){Ee&&Ee.classList.remove(`show`),Ce&&Ce.classList.remove(`show`),we&&we.setAttribute(`aria-expanded`,`false`)}we&&Ee&&(we.addEventListener(`click`,e=>{e.stopPropagation(),Ee.classList.toggle(`show`),Oe()}),Ee.querySelectorAll(`.theme-submenu-item`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),lt(e.dataset.themeValue),ke()})})),Oe(),mt(Oe),o(Oe),c.addEventListener(`click`,e=>{e.stopPropagation(),ke(),xi()}),l&&l.addEventListener(`click`,e=>{e.stopPropagation(),ke(),_n()});let Ae=document.getElementById(`importChatBtn`);Ae&&Ae.addEventListener(`click`,e=>{e.stopPropagation(),ke(),xn()});let je=document.getElementById(`importSessionsFile`);je&&je.addEventListener(`change`,e=>{let t=e.target.files[0];t&&St(t)});let Me=document.getElementById(`settingsBtn`);Me&&Me.addEventListener(`click`,()=>{chrome.runtime.openOptionsPage()});let Ne=document.getElementById(`headerAgentIndicator`);Ne&&Ne.addEventListener(`click`,async()=>{let e=chrome.runtime.getURL(`options.html#agent`),t=await chrome.tabs.query({url:chrome.runtime.getURL(`options.html`)});t.length>0?await chrome.tabs.update(t[0].id,{active:!0,url:e}):await chrome.tabs.create({url:e})});let Pe=document.getElementById(`prototypeLibraryBtn`);Pe&&Pe.addEventListener(`click`,e=>{e.stopPropagation(),ke(),Qr()});let O=document.getElementById(`tokenStatsHeaderBtn`);O&&O.addEventListener(`click`,e=>{e.stopPropagation(),ke(),window.openTokenStats&&window.openTokenStats()});let Fe=document.getElementById(`auditLogBtn`),Ie=document.getElementById(`auditLogOverlay`),Le=document.getElementById(`auditLogClose`),Re=document.getElementById(`auditLogRefreshBtn`),ze=document.getElementById(`auditLogCategoryFilter`),Be=document.getElementById(`auditLogLimit`),Ve=document.getElementById(`auditLogSearch`),He=document.getElementById(`auditLogSearchClear`),Ue=document.getElementById(`auditLogLoading`),We=document.getElementById(`auditLogEmpty`),Ke=document.getElementById(`auditLogList`),qe=[],Je={auth:t(`sidePanel.auditCategoryAuth`),fs:t(`sidePanel.auditCategoryFs`),exec:t(`sidePanel.auditCategoryExec`),security:t(`sidePanel.auditCategorySecurity`),system:t(`sidePanel.auditCategorySystem`)},Xe={info:`INFO`,warn:`WARN`,error:`ERROR`},Ze={info:`audit-level-info`,warn:`audit-level-warn`,error:`audit-level-error`};function Qe(e){if(!e)return`-`;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function $e(e){let n=new Set([`timestamp`,`level`,`category`,`action`]),r=[];for(let[t,i]of Object.entries(e)){if(n.has(t))continue;let e=typeof i==`string`?i:JSON.stringify(i),a=e.length>60?e.slice(0,60)+`...`:e;r.push(`${t}: ${a}`)}return r.join(t(`sidePanel.auditDetailSeparator`))}async function et(){if(!Ue||!We||!Ke)return;Ue.style.display=`block`,We.style.display=`none`,Ke.style.display=`none`;let e=ze?.value||null,n=parseInt(Be?.value||`200`,10);try{let r=await new Promise((t,r)=>{chrome.runtime.sendMessage({type:`QUERY_AUDIT_LOGS`,category:e,limit:n},e=>{chrome.runtime.lastError?r(Error(chrome.runtime.lastError.message)):t(e)})});if(Ue.style.display=`none`,!r||!r.success){We.style.display=`block`,We.textContent=t(`sidePanel.auditQueryFailed`,{error:r?.error||t(`sidePanel.unknownError`)});return}qe=r.entries||[],rt()}catch(e){Ue.style.display=`none`,We.style.display=`block`,We.textContent=t(`sidePanel.auditLoadFailed`,{error:e.message})}}function rt(){if(!Ke)return;let e=(Ve?.value||``).trim().toLowerCase(),n=qe;if(e&&(n=n.filter(t=>[t.action||``,t.category||``,...Object.entries(t).filter(([e])=>![`timestamp`,`level`,`category`,`action`].includes(e)).map(([,e])=>typeof e==`string`?e:JSON.stringify(e))].join(` `).toLowerCase().includes(e))),He&&(He.style.display=e?`block`:`none`),Ue.style.display=`none`,n.length===0){We.style.display=`block`,We.textContent=t(e?`sidePanel.auditNoMatch`:`sidePanel.auditEmpty`),Ke.style.display=`none`;return}We.style.display=`none`,Ke.style.display=`block`,Ke.innerHTML=n.map(e=>{let t=k(Je[e.category]||e.category||`-`),n=k(Xe[e.level]||e.level?.toUpperCase()||`INFO`),r=Ze[e.level]||`audit-level-info`,i=Qe(e.timestamp),a=k($e(e));return`<div class="audit-entry">
670
670
  <div class="audit-entry-header">
671
671
  <span class="audit-time">${i}</span>
672
672
  <span class="audit-level ${r}">${n}</span>
@@ -685,4 +685,4 @@ Are you sure you want to stop the agent service? You will not be able to connect
685
685
  <span style="font-size: 12px; color: ${o}; font-weight: 500;">${r.toFixed(0)}%</span>
686
686
  </td>
687
687
  <td style="padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border-subtle); color: var(--text-tertiary); font-size: 12px;">${s}</td>
688
- </tr>`}).join(``),Zt()}function Zt(){let{column:e,asc:t}=Jt,n=[`name`,`callCount`,`successCount`,`successRate`,`duration`],r={name:`sortByName`,callCount:`sortByCallCount`,successCount:`sortBySuccessCount`,successRate:`sortBySuccessRate`,duration:`sortByDuration`};n.forEach(n=>{let i=document.getElementById(r[n]);if(!i)return;let a=i.querySelector(`.sort-indicator`);a&&(n===e?(a.textContent=t?`▲`:`▼`,a.style.color=`var(--brand-500)`):(a.textContent=``,a.style.color=``))})}document.querySelectorAll(`#toolStatsTable th[data-sort]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.sort;Jt.column===t?Jt.asc=!Jt.asc:(Jt.column=t,Jt.asc=!1),Yt()})}),Nt.addEventListener(`click`,()=>{cr()}),Pt.addEventListener(`click`,()=>{cr(),er()});let tn=document.getElementById(`confirmModal`);tn.addEventListener(`click`,e=>{e.target===tn&&cr()});let nn=document.getElementById(`selectionClose`);nn&&nn.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),r.debug(`[SidePanel] user clickcloseselected content by button`),Gt(),window.hideFloatingMenu(),y.lastSelectedText=``,y.currentSelectionRange=null}),a.addEventListener(`input`,()=>{})}),Je().then(()=>{th(),$r(y.chatConfig.showMessageTimestamp!==!1),nh(),rh()}),document.addEventListener(`DOMContentLoaded`,()=>{ah()}),document.addEventListener(`DOMContentLoaded`,un),document.addEventListener(`DOMContentLoaded`,mi),document.addEventListener(`DOMContentLoaded`,hh),document.addEventListener(`DOMContentLoaded`,mh),document.addEventListener(`DOMContentLoaded`,cf),document.addEventListener(`DOMContentLoaded`,_f),document.addEventListener(`DOMContentLoaded`,dp),document.addEventListener(`DOMContentLoaded`,Ip),document.addEventListener(`DOMContentLoaded`,kn),document.addEventListener(`DOMContentLoaded`,async()=>{mr(),to(),await Qi(),At(),await gc(),nu(),Os(),Zm(),Zs(),Gh(),Wi(),Bd();let{updateBookmarkButtons:e,updateBookmarkBadge:t}=await D(async()=>{let{updateBookmarkButtons:e,updateBookmarkBadge:t}=await import(`./context-indicator-Sf2n8eWg.js`).then(e=>e.Sn);return{updateBookmarkButtons:e,updateBookmarkBadge:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));e(),t()}),document.addEventListener(`DOMContentLoaded`,()=>{Ss()}),document.addEventListener(`DOMContentLoaded`,async()=>{Ht(e=>Ni(e)),await Et(),await pm()});function Zh(){Gt(),Or(),Pi(),Yn(),hn(),Rt();let e=document.getElementById(`imagePreviewBar`);e&&(e.innerHTML=``,e.style.display=`none`)}function Qh(e){let t=e||{};t.quotedContextText&&Cr(t.quotedContextText),t.selectedPage&&Ot(t.selectedPage),!t.quotedContextText&&y.selectedContextText&&Mn(),aa(),qi(),hi(),Ji(),Pt()}document.addEventListener(`queue-context-cleared`,Zh),document.addEventListener(`queue-context-restored`,e=>{Qh(e&&e.detail?e.detail.snapshot:null)}),document.addEventListener(`DOMContentLoaded`,xt),document.addEventListener(`DOMContentLoaded`,di),document.addEventListener(`DOMContentLoaded`,qr),document.addEventListener(`DOMContentLoaded`,Si),document.addEventListener(`DOMContentLoaded`,fa),document.addEventListener(`DOMContentLoaded`,Gi),document.addEventListener(`DOMContentLoaded`,li),document.addEventListener(`DOMContentLoaded`,Mi),document.addEventListener(`DOMContentLoaded`,ti),document.addEventListener(`DOMContentLoaded`,()=>br()),document.addEventListener(`DOMContentLoaded`,async()=>{let{refreshAgentNames:e,initScrollToBottomBtn:t}=await D(async()=>{let{refreshAgentNames:e,initScrollToBottomBtn:t}=await import(`./context-indicator-Sf2n8eWg.js`).then(e=>e.ht);return{refreshAgentNames:e,initScrollToBottomBtn:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));e(),t()});async function $h(){try{let e=(await chrome.storage.local.get(`_detachOriginTabId`))?._detachOriginTabId;if(typeof e==`number`)try{let t=await chrome.tabs.get(e);if(t?.id!=null)return t.id}catch{}}catch{}try{let e=(await chrome.windows.getAll({populate:!0})||[]).filter(e=>e.type===`normal`);return((e.find(e=>e.focused)||e[0])?.tabs||[]).find(e=>e.active)?.id??null}catch{return null}}document.addEventListener(`DOMContentLoaded`,()=>{let e=new URLSearchParams(window.location.search).has(`popup`),n=document.getElementById(`detachBtn`),i=document.getElementById(`attachBtn`),a=e?i:n;e?i&&(i.style.display=`flex`):n&&(n.style.display=`flex`);let o=()=>{if(!a)return;let n=y.pendingCallApiSessionIds&&y.pendingCallApiSessionIds.size>0;a.disabled=n,a.style.opacity=n?`0.35`:``,a.style.cursor=n?`not-allowed`:`pointer`,a.title=t(n?`detach.taskRunning`:e?`header.attachTitle`:`header.detachTitle`)};o(),document.addEventListener(`generating-state-changed`,o),n&&n.addEventListener(`click`,async()=>{if(y.pendingCallApiSessionIds&&y.pendingCallApiSessionIds.size>0){A(t(`detach.taskRunning`),`warning`);return}try{if((await chrome.runtime.sendMessage({type:`DETACH_SIDEPANEL`,width:window.innerWidth}))?.success)try{window.close()}catch{}}catch(e){r.warn(`[SidePanel] detach failed:`,e?.message)}}),i&&i.addEventListener(`click`,async()=>{if(y.pendingCallApiSessionIds&&y.pendingCallApiSessionIds.size>0){A(t(`detach.taskRunning`),`warning`);return}try{let e=(await chrome.windows.getCurrent()).id,n=await $h();if(n==null){A(t(`detach.attachFailed`),`error`);return}let i=await chrome.runtime.sendMessage({type:`ATTACH_SIDEPANEL`,windowId:e,tabId:n});if(i?.success)try{window.close()}catch{}else r.warn(`[SidePanel] attach rejected:`,i?.error),A(t(`detach.attachFailed`),`error`)}catch(e){r.warn(`[SidePanel] attach failed:`,e?.message),A(t(`detach.attachFailed`),`error`)}})});
688
+ </tr>`}).join(``),Zt()}function Zt(){let{column:e,asc:t}=Jt,n=[`name`,`callCount`,`successCount`,`successRate`,`duration`],r={name:`sortByName`,callCount:`sortByCallCount`,successCount:`sortBySuccessCount`,successRate:`sortBySuccessRate`,duration:`sortByDuration`};n.forEach(n=>{let i=document.getElementById(r[n]);if(!i)return;let a=i.querySelector(`.sort-indicator`);a&&(n===e?(a.textContent=t?`▲`:`▼`,a.style.color=`var(--brand-500)`):(a.textContent=``,a.style.color=``))})}document.querySelectorAll(`#toolStatsTable th[data-sort]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.sort;Jt.column===t?Jt.asc=!Jt.asc:(Jt.column=t,Jt.asc=!1),Yt()})}),Nt.addEventListener(`click`,()=>{cr()}),Pt.addEventListener(`click`,()=>{cr(),er()});let tn=document.getElementById(`confirmModal`);tn.addEventListener(`click`,e=>{e.target===tn&&cr()});let nn=document.getElementById(`selectionClose`);nn&&nn.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),r.debug(`[SidePanel] user clickcloseselected content by button`),Gt(),window.hideFloatingMenu(),y.lastSelectedText=``,y.currentSelectionRange=null}),a.addEventListener(`input`,()=>{})}),Je().then(()=>{th(),$r(y.chatConfig.showMessageTimestamp!==!1),nh(),rh()}),document.addEventListener(`DOMContentLoaded`,()=>{ah()}),document.addEventListener(`DOMContentLoaded`,un),document.addEventListener(`DOMContentLoaded`,mi),document.addEventListener(`DOMContentLoaded`,hh),document.addEventListener(`DOMContentLoaded`,mh),document.addEventListener(`DOMContentLoaded`,cf),document.addEventListener(`DOMContentLoaded`,_f),document.addEventListener(`DOMContentLoaded`,dp),document.addEventListener(`DOMContentLoaded`,Ip),document.addEventListener(`DOMContentLoaded`,kn),document.addEventListener(`DOMContentLoaded`,async()=>{mr(),to(),await Qi(),At(),await gc(),nu(),Os(),Zm(),Zs(),Gh(),Wi(),Bd();let{updateBookmarkButtons:e,updateBookmarkBadge:t}=await D(async()=>{let{updateBookmarkButtons:e,updateBookmarkBadge:t}=await import(`./context-indicator-DjOAo_Ln.js`).then(e=>e.Sn);return{updateBookmarkButtons:e,updateBookmarkBadge:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));e(),t()}),document.addEventListener(`DOMContentLoaded`,()=>{Ss()}),document.addEventListener(`DOMContentLoaded`,async()=>{Ht(e=>Ni(e)),await Et(),await pm()});function Zh(){Gt(),Or(),Pi(),Yn(),hn(),Rt();let e=document.getElementById(`imagePreviewBar`);e&&(e.innerHTML=``,e.style.display=`none`)}function Qh(e){let t=e||{};t.quotedContextText&&Cr(t.quotedContextText),t.selectedPage&&Ot(t.selectedPage),!t.quotedContextText&&y.selectedContextText&&Mn(),aa(),qi(),hi(),Ji(),Pt()}document.addEventListener(`queue-context-cleared`,Zh),document.addEventListener(`queue-context-restored`,e=>{Qh(e&&e.detail?e.detail.snapshot:null)}),document.addEventListener(`DOMContentLoaded`,xt),document.addEventListener(`DOMContentLoaded`,di),document.addEventListener(`DOMContentLoaded`,qr),document.addEventListener(`DOMContentLoaded`,Si),document.addEventListener(`DOMContentLoaded`,fa),document.addEventListener(`DOMContentLoaded`,Gi),document.addEventListener(`DOMContentLoaded`,li),document.addEventListener(`DOMContentLoaded`,Mi),document.addEventListener(`DOMContentLoaded`,ti),document.addEventListener(`DOMContentLoaded`,()=>br()),document.addEventListener(`DOMContentLoaded`,async()=>{let{refreshAgentNames:e,initScrollToBottomBtn:t}=await D(async()=>{let{refreshAgentNames:e,initScrollToBottomBtn:t}=await import(`./context-indicator-DjOAo_Ln.js`).then(e=>e.ht);return{refreshAgentNames:e,initScrollToBottomBtn:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));e(),t()});async function $h(){try{let e=(await chrome.storage.local.get(`_detachOriginTabId`))?._detachOriginTabId;if(typeof e==`number`)try{let t=await chrome.tabs.get(e);if(t?.id!=null)return t.id}catch{}}catch{}try{let e=(await chrome.windows.getAll({populate:!0})||[]).filter(e=>e.type===`normal`);return((e.find(e=>e.focused)||e[0])?.tabs||[]).find(e=>e.active)?.id??null}catch{return null}}document.addEventListener(`DOMContentLoaded`,()=>{let e=new URLSearchParams(window.location.search).has(`popup`),n=document.getElementById(`detachBtn`),i=document.getElementById(`attachBtn`),a=e?i:n;e?i&&(i.style.display=`flex`):n&&(n.style.display=`flex`);let o=()=>{if(!a)return;let n=y.pendingCallApiSessionIds&&y.pendingCallApiSessionIds.size>0;a.disabled=n,a.style.opacity=n?`0.35`:``,a.style.cursor=n?`not-allowed`:`pointer`,a.title=t(n?`detach.taskRunning`:e?`header.attachTitle`:`header.detachTitle`)};o(),document.addEventListener(`generating-state-changed`,o),n&&n.addEventListener(`click`,async()=>{if(y.pendingCallApiSessionIds&&y.pendingCallApiSessionIds.size>0){A(t(`detach.taskRunning`),`warning`);return}try{if((await chrome.runtime.sendMessage({type:`DETACH_SIDEPANEL`,width:window.innerWidth}))?.success)try{window.close()}catch{}}catch(e){r.warn(`[SidePanel] detach failed:`,e?.message)}}),i&&i.addEventListener(`click`,async()=>{if(y.pendingCallApiSessionIds&&y.pendingCallApiSessionIds.size>0){A(t(`detach.taskRunning`),`warning`);return}try{let e=(await chrome.windows.getCurrent()).id,n=await $h();if(n==null){A(t(`detach.attachFailed`),`error`);return}let i=await chrome.runtime.sendMessage({type:`ATTACH_SIDEPANEL`,windowId:e,tabId:n});if(i?.success)try{window.close()}catch{}else r.warn(`[SidePanel] attach rejected:`,i?.error),A(t(`detach.attachFailed`),`error`)}catch(e){r.warn(`[SidePanel] attach failed:`,e?.message),A(t(`detach.attachFailed`),`error`)}})});
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/workspace-manager-CL4JvHkJ.js","assets/chunk-CMxvf4Kt.js","assets/model-profiles-ClPgbQ-J.js","assets/i18n-5c8prpFJ.js","assets/context-indicator-Sf2n8eWg.js","assets/voice-shortcut-Dx863RGz.js","assets/session-store-M5mPmMr3.js","assets/agent-store-CeC2_dkP.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/workspace-manager-CL4JvHkJ.js","assets/chunk-CMxvf4Kt.js","assets/model-profiles-ClPgbQ-J.js","assets/i18n-5c8prpFJ.js","assets/context-indicator-DjOAo_Ln.js","assets/voice-shortcut-Dx863RGz.js","assets/session-store-M5mPmMr3.js","assets/agent-store-CeC2_dkP.js"])))=>i.map(i=>d[i]);
2
2
  import{a as e,c as t,l as n,r}from"./i18n-5c8prpFJ.js";import{N as i,b as a,rn as o,wt as s,x as c}from"./model-profiles-ClPgbQ-J.js";import{o as l}from"./voice-shortcut-Dx863RGz.js";import{o as u}from"./agent-store-CeC2_dkP.js";var d=`appTheme`,f=[`light`,`dark`,`system`],p=`light`,m=`light`,h=null,g=null,_=[],v=!1;function y(e){let t=e!==m;m=e,typeof document<`u`&&document.documentElement.setAttribute(`data-theme`,e);try{localStorage.setItem(`appThemeResolved`,e)}catch{}t&&_.slice().forEach(t=>{try{t(e)}catch(e){console.warn(`[theme] subscriber error`,e)}})}function b(e){return e===`system`?typeof matchMedia<`u`&&matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e===`dark`?`dark`:`light`}(function(){try{let e=typeof localStorage<`u`&&localStorage.getItem(`appThemeResolved`);(e===`dark`||e===`light`)&&(m=e,typeof document<`u`&&document.documentElement.setAttribute(`data-theme`,e))}catch{}})();function x(){return p}function S(){return m}function C(e){_.push(e)}async function w(){typeof matchMedia<`u`&&(h=matchMedia(`(prefers-color-scheme: dark)`),g&&h.removeEventListener(`change`,g),g=()=>{p===`system`&&y(b(`system`))},h.addEventListener(`change`,g)),!v&&typeof chrome<`u`&&chrome.storage&&chrome.storage.onChanged&&(chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&e.appTheme&&f.includes(e.appTheme.newValue)&&(p=e.appTheme.newValue,y(b(p)))}),v=!0);let e=await new Promise(e=>{try{chrome.storage.local.get([d],t=>{if(chrome.runtime&&chrome.runtime.lastError){e(null);return}e(t||{})})}catch{e(null)}});e!==null&&(p=f.includes(e[d])?e[d]:`light`,y(b(p)))}async function T(e){f.includes(e)&&(p=e,y(b(e)),await new Promise(t=>chrome.storage.local.set({appTheme:e},t)))}e(`zh`,{util:{cmdHintPowerShell:"(请使用 PowerShell 语法,如 `Get-ChildItem`、`Set-Content`、`Remove-Item` 等)",cmdHintCmd:"(请使用 CMD 语法,如 `dir`、`echo`、`del` 等)",cmdHintGitBash:"(请使用 Unix 命令,如 `ls`、`cat`、`rm` 等,路径使用正斜杠 `/`)",cmdHintPowerShellShort:`(请使用 PowerShell 语法)`,cmdHintUnix:"(请使用 Unix 命令,如 `ls`、`cat`、`rm` 等)",cmdExecEnvTitle:`## 命令执行环境`,cmdExecOsShell:`**操作系统/Shell**`,cmdExecWorkdir:`工作目录`,cmdExecWorkdirUnset:`未设置`,assistantTerm:`- **助手**:用户创建的 AI 智能体,每个助手有独立的系统提示词和工具权限,可独立工作或被其他助手调度执行子任务`,noDesc:`无描述`,subDispatchTitle:`## 子助手调度`,subDispatchDesc:`使用 dispatch_task(subAgentId, task) 分派子任务给其他助手执行,支持并行调用。`,subDispatchAvailable:`可用子助手:`,agentTerm:`- **代理**:远端执行服务,提供文件操作、命令执行等能力。可通过 manage_agent 工具查询或切换代理`,agentHostLabel:`- 代理主机地址:`,agentHostHint:`(访问代理端服务时请优先使用此地址)`,terminologyTitle:`## 术语定义`,taskPlanningTitle:`## 任务拆解`,taskPlanningDesc:`复杂任务(多步骤、有依赖)拆解为子任务,通常 2-6 个、最多不超过 8 个;简单任务(1-2 步即可完成)直接执行,不要为凑数而拆分。使用 plan_task(taskDescription, subtasks) 提交方案。重要:调用 plan_task 时必须单独调用,同一轮响应中不要同时返回其他工具调用;其他想执行的动作请编入子任务描述,由子任务执行。`,artifactDeclTitle:`## 文件产物声明`,artifactDeclDesc:`当本次任务通过脚本或命令在工作目录内创建/修改了文件(尤其是运行时才确定路径的文件,如带日期的报表),请在最终回答末尾各用一行声明每个产物,格式严格为:[[artifact:相对工作目录或绝对路径|可选中文说明]]。示例:[[artifact:报表_2026-10-20.xlsx|书签统计报表]]。只列本次真实产生的文件,不要虚构、不要列未生成的文件;说明可省略。这些标记不会展示给用户。`,memoryTitle:`## 记忆`,memoryRules:`- 统一工具 agent_memory,通过 action 区分:store(增删改)/recall(检索)/manage(审查清理)
3
3
  - store: subAction=add需type+content,update需memoryId+type,**delete仅需memoryId无需type**。**删除前先recall查id**
4
4
  - recall: query用关键词(如"考试"),不用完整句子。可选memoryType和limit
@@ -173,4 +173,4 @@ Ctrl/Cmd+click to copy rich-text table`,downloadExcel:`Download Excel`,exportTab
173
173
  `);return{full:a+`
174
174
  `+o+`
175
175
  `+s,header:a+`
176
- `+o,body:s}}function ut(e){let t=e.closest(`.code-block-container`);if(t){let n=t.querySelector(`pre code`);n&&P(n.textContent,e)}}function dt(e,n){if(n.ctrlKey||n.metaKey){let n=e.closest(`.table-container-wrapper`)?.querySelector(`table`);if(n)try{let r=_t(n).outerHTML;e.focus();let i=new Blob([r],{type:`text/html`}),a=new ClipboardItem({"text/html":i});navigator.clipboard.write([a]).then(()=>{E(t(`markdown.copiedRichTable`))}).catch(()=>{let n=document.createElement(`div`);n.style.cssText=`position:fixed;left:-999999px;top:-999999px;`,n.innerHTML=r,document.body.appendChild(n);let i=document.createRange();i.selectNodeContents(n);let a=window.getSelection();a.removeAllRanges(),a.addRange(i);try{e.focus(),document.execCommand(`copy`),E(t(`markdown.copiedRichTable`))}catch{E(t(`markdown.copyRichTableFailed`),`error`)}finally{a.removeAllRanges(),document.body.removeChild(n)}})}catch{E(t(`markdown.copyFailedShort`),`error`)}return}let r=e.dataset.tableFull?decodeURIComponent(e.dataset.tableFull):null;if(r){P(r,e),E(t(`markdown.copiedMdTable`));return}let i=e.dataset.tableIndex,a=window.__tableBlocks?.[parseInt(i)];if(a){P(a.full,e),E(t(`markdown.copiedMdTable`));return}let o=lt(e);o&&(P(o.full,e),E(t(`markdown.copiedMdTable`)))}function ft(e){let t=e.dataset.tableHeader?decodeURIComponent(e.dataset.tableHeader):null,n=e.dataset.tableBody?decodeURIComponent(e.dataset.tableBody):null;if(t&&n){G({header:t,body:n});return}let r=e.dataset.tableIndex,i=window.__tableBlocks?.[parseInt(r)];if(i){G(i);return}let a=lt(e);a&&G(a)}async function pt(e){let r=e.closest(`.table-container-wrapper`);if(r)try{let e=await B();if(!e){E(t(`markdown.imageExportLibMissing`),`error`);return}let n=await e(r,{scale:2,useCORS:!0,logging:!1,backgroundColor:`#ffffff`}),i=document.createElement(`a`);i.download=`table-${Date.now()}.jpg`,i.href=n.toDataURL(`image/jpeg`,.95),document.body.appendChild(i),i.click(),document.body.removeChild(i),E(t(`markdown.tableImageExported`))}catch(e){n.error(`[SidePanel] export tableimage failed:`,e),E(t(`markdown.exportImageFailed`),`error`)}}var mt=!1;function ht(){mt||typeof document>`u`||!document.addEventListener||(mt=!0,document.addEventListener(`click`,e=>{let t=e.target;if(!t||typeof t.closest!=`function`)return;let n=t.closest(`.code-copy-btn`);if(n){e.stopPropagation(),ut(n);return}let r=t.closest(`.copy-md-btn`);if(r){e.stopPropagation(),dt(r,e);return}let i=t.closest(`.download-excel-btn`);if(i){e.stopPropagation(),ft(i);return}let a=t.closest(`.export-table-img-btn`);if(a){e.stopPropagation(),pt(a);return}},!0))}function gt(){ht()}function _t(e){let t=e.cloneNode(!0);return t.querySelectorAll(`.table-header-cell-wrapper`).forEach(e=>{let t=e.textContent.trim();e.innerHTML=``,e.textContent=t,e.classList.remove(`table-header-cell-wrapper`)}),t.querySelectorAll(`.table-toolbar`).forEach(e=>e.remove()),t}var vt=RegExp(`(?:~?/[\\w\\-.\\u4e00-\\u9fa5/]+|\\b[A-Za-z]:\\\\[\\w\\-.\\\\\\u4e00-\\u9fa5]+|\\b[\\w\\-.\\u4e00-\\u9fa5]+/[\\w\\-./\\u4e00-\\u9fa5]*\\.[A-Za-z0-9]{1,6}|\\b[\\w\\-.\\u4e00-\\u9fa5]+\\.[A-Za-z0-9]{1,6})`,`g`);function yt(e){if(!e)return[];let t=e.replace(/\bhttps?:\/\/\S+/gi,` `),n=[],r;for(vt.lastIndex=0;(r=vt.exec(t))!==null;){let e=r[0].replace(/[,。、)()\s]+$/,``);e&&(/\/$/.test(e)&&!RegExp(`\\.[A-Za-z0-9]{1,6}$`).test(e)||/[.\\/~]/.test(e)&&(n.includes(e)||n.push(e)))}return n}function X(e){return(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`)}async function bt(e,n=[]){if(!e)return;let r=e.querySelector(`.markdown-body`)||e,i=new Set((n||[]).map(X)),a=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode(e){if(!e.nodeValue||!e.nodeValue.trim())return NodeFilter.FILTER_REJECT;let t=e.parentNode;return!t||!t.closest||t.closest(`a, pre, code, script, style, .chat-file-link`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),o=[];for(;a.nextNode();)o.push(a.currentNode);let s=new Set;for(let e of o)for(let t of yt(e.nodeValue))s.add(t);if(s.size===0)return;let l=[...s].filter(e=>!i.has(X(e))),u=new Set;if(l.length>0)try{let e=null;try{let t=await(await c(()=>import(`./workspace-manager-CL4JvHkJ.js`).then(e=>e.j),__vite__mapDeps([0,1,2,3]))).getAgentStatusDetail();t&&t.workdir&&(e=t.workdir)}catch{}let t=await c(()=>import(`./context-indicator-Sf2n8eWg.js`).then(e=>e.mn),__vite__mapDeps([4,1,2,3,5,6,7,0])),n=e?X(e):null,r=await Promise.all(l.map(e=>t.resolveWorkspaceAbsolutePath(e).catch(()=>null))),i=[];for(let e=0;e<l.length;e++){let t=r[e];if(!n||!t)continue;let a=X(t);a!==n&&!a.startsWith(n.endsWith(`/`)?n:n+`/`)||i.push({token:l[e],path:t})}if(i.length){let e=await chrome.runtime.sendMessage({type:`CHECK_FILES_EXIST`,paths:i.map(e=>e.path)});if(e&&e.success&&e.results)for(let t of i)e.results[t.path]===!0&&u.add(X(t.token))}}catch{}let d=e=>i.has(X(e))||u.has(X(e)),f=t(`chat.fileLinkTitle`);for(let e of o){let t=e.nodeValue,n=yt(t).filter(d);if(n.length===0)continue;let r=n.slice().sort((e,t)=>t.length-e.length),i=document.createDocumentFragment(),a=t;for(;a.length;){let e=-1,t=null;for(let n of r){let r=a.indexOf(n);r!==-1&&(e===-1||r<e)&&(e=r,t=n)}if(e===-1){i.appendChild(document.createTextNode(a));break}e>0&&i.appendChild(document.createTextNode(a.slice(0,e)));let n=document.createElement(`span`);n.className=`chat-file-link`,n.setAttribute(`data-path`,t),n.setAttribute(`title`,f),n.textContent=t,i.appendChild(n),a=a.slice(e+t.length)}e.parentNode&&e.parentNode.replaceChild(i,e)}}var xt=!1;function St(){xt||(xt=!0,document.addEventListener(`click`,async e=>{let n=e.target.closest&&e.target.closest(`.chat-file-link`);if(!n)return;let r=n.getAttribute(`data-path`);if(r)try{await(await c(()=>import(`./context-indicator-Sf2n8eWg.js`).then(e=>e.mn),__vite__mapDeps([4,1,2,3,5,6,7,0]))).locateFileInWorkspace(r)}catch{E(t(`chat.fileLinkFailed`),`error`)}},!0))}var Z=`voiceInputDevice`,Ct=new Set([`default`,`communications`]);function Q(e){return typeof e==`string`?e.trim():``}function wt(e){let t=Q(e),n={channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0};return t?{...n,deviceId:{exact:t}}:n}function $(e){try{return(e.navigator??globalThis.navigator)?.mediaDevices||null}catch{return null}}async function Tt(e={}){let t=$(e);if(!t||typeof t.enumerateDevices!=`function`)return[];let n;try{n=await t.enumerateDevices()}catch{return[]}let r=new Set,i=[];for(let e of Array.isArray(n)?n:[]){if(e?.kind!==`audioinput`)continue;let t=Q(e.deviceId);!t||Ct.has(t)||r.has(t)||(r.add(t),i.push({deviceId:t,label:typeof e.label==`string`?e.label.trim():``}))}return i}function Et(e,t){let n=Q(t);return n?(Array.isArray(e)?e:[]).some(e=>e?.deviceId===n):!0}var Dt=2500,Ot=Symbol(`device-enum-timeout`);async function kt(e={},t=Dt){let n=$(e);if(!n||typeof n.enumerateDevices!=`function`)return{devices:[],timedOut:!1,unsupported:!0};let r=Math.max(0,Number(t)||2500),i=null,a=new Promise(e=>{i=setTimeout(()=>e(Ot),r)});try{let t=await Promise.race([Tt(e),a]);return t===Ot?{devices:[],timedOut:!0,unsupported:!1}:{devices:t,timedOut:!1,unsupported:!1}}finally{i!==null&&clearTimeout(i)}}var At=1500;async function jt(e={},t=At){let n=$(e);if(!n||typeof n.getUserMedia!=`function`)return!1;let r=Math.max(0,Number(t)||1500),i=e=>{try{e?.getTracks?.().forEach(e=>e.stop())}catch{}},a=!1,o=null,s=null,c=Promise.resolve().then(()=>n.getUserMedia({audio:!0})).then(e=>(a?i(e):o=e,!!e)).catch(()=>!1),l=new Promise(e=>{s=setTimeout(()=>e(!1),r)}),u;try{u=await Promise.race([c,l])}finally{s!==null&&clearTimeout(s),a=!0,i(o),o=null}return u===!0}function Mt(){try{return globalThis.chrome?.storage?.local||null}catch{return null}}async function Nt(){let e=Mt();if(!e?.get)return``;try{return Q((await e.get(Z))?.[Z])}catch{return``}}async function Pt(e){let t=Q(e),n=Mt();if(!n?.set)return t;try{await n.set({[Z]:t})}catch{}return t}function Ft(e,t={}){let n=$(t);if(!n||typeof n.addEventListener!=`function`)return()=>{};let r=()=>{try{e()}catch{}};try{n.addEventListener(`devicechange`,r)}catch{return()=>{}}return()=>{try{n.removeEventListener(`devicechange`,r)}catch{}}}async function It(e,t={}){let n=$(t);if(!n||typeof n.getUserMedia!=`function`){let e=Error(`unsupported`);throw e.name=`NotSupportedError`,e}let r=Q(e);try{return{stream:await n.getUserMedia({audio:wt(r)}),fellBack:!1,deviceId:r}}catch(e){let t=e?.name||``;if(!r||!(t===`OverconstrainedError`||t===`NotFoundError`||t===`NotReadableError`))throw e;return{stream:await n.getUserMedia({audio:wt(``)}),fellBack:!0,deviceId:``,error:t}}}var Lt={version:`2.8.22`,tag:`v2.8.22`,commitId:`bbb20019705f4e9f26042228081c5111f80837ef`,publishedAt:`2026-11-27T04:05:29.831Z`};export{w as $,me as A,N as B,B as C,be as D,ie as E,Se as F,pe as G,he as H,te as I,Te as J,ve as K,ne as L,k as M,Ce as N,_e as O,we as P,x as Q,ee as R,U as S,D as T,ge as U,fe as V,le as W,ae as X,E as Y,O as Z,$e as _,kt as a,Qe as b,Ft as c,gt as d,T as et,bt as f,He as g,qe as h,Nt as i,A as j,P as k,ct as l,_t as m,It as n,Pt as o,St as p,je as q,Et as r,jt as s,Lt as t,C as tt,q as u,Ze as v,Fe as w,Ve as x,at as y,re as z};
176
+ `+o,body:s}}function ut(e){let t=e.closest(`.code-block-container`);if(t){let n=t.querySelector(`pre code`);n&&P(n.textContent,e)}}function dt(e,n){if(n.ctrlKey||n.metaKey){let n=e.closest(`.table-container-wrapper`)?.querySelector(`table`);if(n)try{let r=_t(n).outerHTML;e.focus();let i=new Blob([r],{type:`text/html`}),a=new ClipboardItem({"text/html":i});navigator.clipboard.write([a]).then(()=>{E(t(`markdown.copiedRichTable`))}).catch(()=>{let n=document.createElement(`div`);n.style.cssText=`position:fixed;left:-999999px;top:-999999px;`,n.innerHTML=r,document.body.appendChild(n);let i=document.createRange();i.selectNodeContents(n);let a=window.getSelection();a.removeAllRanges(),a.addRange(i);try{e.focus(),document.execCommand(`copy`),E(t(`markdown.copiedRichTable`))}catch{E(t(`markdown.copyRichTableFailed`),`error`)}finally{a.removeAllRanges(),document.body.removeChild(n)}})}catch{E(t(`markdown.copyFailedShort`),`error`)}return}let r=e.dataset.tableFull?decodeURIComponent(e.dataset.tableFull):null;if(r){P(r,e),E(t(`markdown.copiedMdTable`));return}let i=e.dataset.tableIndex,a=window.__tableBlocks?.[parseInt(i)];if(a){P(a.full,e),E(t(`markdown.copiedMdTable`));return}let o=lt(e);o&&(P(o.full,e),E(t(`markdown.copiedMdTable`)))}function ft(e){let t=e.dataset.tableHeader?decodeURIComponent(e.dataset.tableHeader):null,n=e.dataset.tableBody?decodeURIComponent(e.dataset.tableBody):null;if(t&&n){G({header:t,body:n});return}let r=e.dataset.tableIndex,i=window.__tableBlocks?.[parseInt(r)];if(i){G(i);return}let a=lt(e);a&&G(a)}async function pt(e){let r=e.closest(`.table-container-wrapper`);if(r)try{let e=await B();if(!e){E(t(`markdown.imageExportLibMissing`),`error`);return}let n=await e(r,{scale:2,useCORS:!0,logging:!1,backgroundColor:`#ffffff`}),i=document.createElement(`a`);i.download=`table-${Date.now()}.jpg`,i.href=n.toDataURL(`image/jpeg`,.95),document.body.appendChild(i),i.click(),document.body.removeChild(i),E(t(`markdown.tableImageExported`))}catch(e){n.error(`[SidePanel] export tableimage failed:`,e),E(t(`markdown.exportImageFailed`),`error`)}}var mt=!1;function ht(){mt||typeof document>`u`||!document.addEventListener||(mt=!0,document.addEventListener(`click`,e=>{let t=e.target;if(!t||typeof t.closest!=`function`)return;let n=t.closest(`.code-copy-btn`);if(n){e.stopPropagation(),ut(n);return}let r=t.closest(`.copy-md-btn`);if(r){e.stopPropagation(),dt(r,e);return}let i=t.closest(`.download-excel-btn`);if(i){e.stopPropagation(),ft(i);return}let a=t.closest(`.export-table-img-btn`);if(a){e.stopPropagation(),pt(a);return}},!0))}function gt(){ht()}function _t(e){let t=e.cloneNode(!0);return t.querySelectorAll(`.table-header-cell-wrapper`).forEach(e=>{let t=e.textContent.trim();e.innerHTML=``,e.textContent=t,e.classList.remove(`table-header-cell-wrapper`)}),t.querySelectorAll(`.table-toolbar`).forEach(e=>e.remove()),t}var vt=RegExp(`(?:~?/[\\w\\-.\\u4e00-\\u9fa5/]+|\\b[A-Za-z]:\\\\[\\w\\-.\\\\\\u4e00-\\u9fa5]+|\\b[\\w\\-.\\u4e00-\\u9fa5]+/[\\w\\-./\\u4e00-\\u9fa5]*\\.[A-Za-z0-9]{1,6}|\\b[\\w\\-.\\u4e00-\\u9fa5]+\\.[A-Za-z0-9]{1,6})`,`g`);function yt(e){if(!e)return[];let t=e.replace(/\bhttps?:\/\/\S+/gi,` `),n=[],r;for(vt.lastIndex=0;(r=vt.exec(t))!==null;){let e=r[0].replace(/[,。、)()\s]+$/,``);e&&(/\/$/.test(e)&&!RegExp(`\\.[A-Za-z0-9]{1,6}$`).test(e)||/[.\\/~]/.test(e)&&(n.includes(e)||n.push(e)))}return n}function X(e){return(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`)}async function bt(e,n=[]){if(!e)return;let r=e.querySelector(`.markdown-body`)||e,i=new Set((n||[]).map(X)),a=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode(e){if(!e.nodeValue||!e.nodeValue.trim())return NodeFilter.FILTER_REJECT;let t=e.parentNode;return!t||!t.closest||t.closest(`a, pre, code, script, style, .chat-file-link`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),o=[];for(;a.nextNode();)o.push(a.currentNode);let s=new Set;for(let e of o)for(let t of yt(e.nodeValue))s.add(t);if(s.size===0)return;let l=[...s].filter(e=>!i.has(X(e))),u=new Set;if(l.length>0)try{let e=null;try{let t=await(await c(()=>import(`./workspace-manager-CL4JvHkJ.js`).then(e=>e.j),__vite__mapDeps([0,1,2,3]))).getAgentStatusDetail();t&&t.workdir&&(e=t.workdir)}catch{}let t=await c(()=>import(`./context-indicator-DjOAo_Ln.js`).then(e=>e.mn),__vite__mapDeps([4,1,2,3,5,6,7,0])),n=e?X(e):null,r=await Promise.all(l.map(e=>t.resolveWorkspaceAbsolutePath(e).catch(()=>null))),i=[];for(let e=0;e<l.length;e++){let t=r[e];if(!n||!t)continue;let a=X(t);a!==n&&!a.startsWith(n.endsWith(`/`)?n:n+`/`)||i.push({token:l[e],path:t})}if(i.length){let e=await chrome.runtime.sendMessage({type:`CHECK_FILES_EXIST`,paths:i.map(e=>e.path)});if(e&&e.success&&e.results)for(let t of i)e.results[t.path]===!0&&u.add(X(t.token))}}catch{}let d=e=>i.has(X(e))||u.has(X(e)),f=t(`chat.fileLinkTitle`);for(let e of o){let t=e.nodeValue,n=yt(t).filter(d);if(n.length===0)continue;let r=n.slice().sort((e,t)=>t.length-e.length),i=document.createDocumentFragment(),a=t;for(;a.length;){let e=-1,t=null;for(let n of r){let r=a.indexOf(n);r!==-1&&(e===-1||r<e)&&(e=r,t=n)}if(e===-1){i.appendChild(document.createTextNode(a));break}e>0&&i.appendChild(document.createTextNode(a.slice(0,e)));let n=document.createElement(`span`);n.className=`chat-file-link`,n.setAttribute(`data-path`,t),n.setAttribute(`title`,f),n.textContent=t,i.appendChild(n),a=a.slice(e+t.length)}e.parentNode&&e.parentNode.replaceChild(i,e)}}var xt=!1;function St(){xt||(xt=!0,document.addEventListener(`click`,async e=>{let n=e.target.closest&&e.target.closest(`.chat-file-link`);if(!n)return;let r=n.getAttribute(`data-path`);if(r)try{await(await c(()=>import(`./context-indicator-DjOAo_Ln.js`).then(e=>e.mn),__vite__mapDeps([4,1,2,3,5,6,7,0]))).locateFileInWorkspace(r)}catch{E(t(`chat.fileLinkFailed`),`error`)}},!0))}var Z=`voiceInputDevice`,Ct=new Set([`default`,`communications`]);function Q(e){return typeof e==`string`?e.trim():``}function wt(e){let t=Q(e),n={channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0};return t?{...n,deviceId:{exact:t}}:n}function $(e){try{return(e.navigator??globalThis.navigator)?.mediaDevices||null}catch{return null}}async function Tt(e={}){let t=$(e);if(!t||typeof t.enumerateDevices!=`function`)return[];let n;try{n=await t.enumerateDevices()}catch{return[]}let r=new Set,i=[];for(let e of Array.isArray(n)?n:[]){if(e?.kind!==`audioinput`)continue;let t=Q(e.deviceId);!t||Ct.has(t)||r.has(t)||(r.add(t),i.push({deviceId:t,label:typeof e.label==`string`?e.label.trim():``}))}return i}function Et(e,t){let n=Q(t);return n?(Array.isArray(e)?e:[]).some(e=>e?.deviceId===n):!0}var Dt=2500,Ot=Symbol(`device-enum-timeout`);async function kt(e={},t=Dt){let n=$(e);if(!n||typeof n.enumerateDevices!=`function`)return{devices:[],timedOut:!1,unsupported:!0};let r=Math.max(0,Number(t)||2500),i=null,a=new Promise(e=>{i=setTimeout(()=>e(Ot),r)});try{let t=await Promise.race([Tt(e),a]);return t===Ot?{devices:[],timedOut:!0,unsupported:!1}:{devices:t,timedOut:!1,unsupported:!1}}finally{i!==null&&clearTimeout(i)}}var At=1500;async function jt(e={},t=At){let n=$(e);if(!n||typeof n.getUserMedia!=`function`)return!1;let r=Math.max(0,Number(t)||1500),i=e=>{try{e?.getTracks?.().forEach(e=>e.stop())}catch{}},a=!1,o=null,s=null,c=Promise.resolve().then(()=>n.getUserMedia({audio:!0})).then(e=>(a?i(e):o=e,!!e)).catch(()=>!1),l=new Promise(e=>{s=setTimeout(()=>e(!1),r)}),u;try{u=await Promise.race([c,l])}finally{s!==null&&clearTimeout(s),a=!0,i(o),o=null}return u===!0}function Mt(){try{return globalThis.chrome?.storage?.local||null}catch{return null}}async function Nt(){let e=Mt();if(!e?.get)return``;try{return Q((await e.get(Z))?.[Z])}catch{return``}}async function Pt(e){let t=Q(e),n=Mt();if(!n?.set)return t;try{await n.set({[Z]:t})}catch{}return t}function Ft(e,t={}){let n=$(t);if(!n||typeof n.addEventListener!=`function`)return()=>{};let r=()=>{try{e()}catch{}};try{n.addEventListener(`devicechange`,r)}catch{return()=>{}}return()=>{try{n.removeEventListener(`devicechange`,r)}catch{}}}async function It(e,t={}){let n=$(t);if(!n||typeof n.getUserMedia!=`function`){let e=Error(`unsupported`);throw e.name=`NotSupportedError`,e}let r=Q(e);try{return{stream:await n.getUserMedia({audio:wt(r)}),fellBack:!1,deviceId:r}}catch(e){let t=e?.name||``;if(!r||!(t===`OverconstrainedError`||t===`NotFoundError`||t===`NotReadableError`))throw e;return{stream:await n.getUserMedia({audio:wt(``)}),fellBack:!0,deviceId:``,error:t}}}var Lt={version:`2.8.23`,tag:`v2.8.23`,commitId:`c4a1a9b9c9ba1e0daf34849a522a75e91dd7a2f1`,publishedAt:`2026-11-27T07:15:39.630Z`};export{w as $,me as A,N as B,B as C,be as D,ie as E,Se as F,pe as G,he as H,te as I,Te as J,ve as K,ne as L,k as M,Ce as N,_e as O,we as P,x as Q,ee as R,U as S,D as T,ge as U,fe as V,le as W,ae as X,E as Y,O as Z,$e as _,kt as a,Qe as b,Ft as c,gt as d,T as et,bt as f,He as g,qe as h,Nt as i,A as j,P as k,ct as l,_t as m,It as n,Pt as o,St as p,je as q,Et as r,jt as s,Lt as t,C as tt,q as u,Ze as v,Fe as w,Ve as x,at as y,re as z};
@@ -2,7 +2,7 @@
2
2
  "manifest_version": 3,
3
3
  "default_locale": "zh_CN",
4
4
  "name": "__MSG_extName__",
5
- "version": "2.8.22",
5
+ "version": "2.8.23",
6
6
  "description": "__MSG_extDescription__",
7
7
  "permissions": [
8
8
  "activeTab",
package/dist/options.html CHANGED
@@ -10,7 +10,7 @@
10
10
  <script type="module" crossorigin src="/assets/model-profiles-ClPgbQ-J.js"></script>
11
11
  <script type="module" crossorigin src="/assets/voice-shortcut-Dx863RGz.js"></script>
12
12
  <script type="module" crossorigin src="/assets/agent-store-CeC2_dkP.js"></script>
13
- <script type="module" crossorigin src="/assets/version-DLS0FCk4.js"></script>
13
+ <script type="module" crossorigin src="/assets/version-DigCzqtw.js"></script>
14
14
  <script type="module" crossorigin src="/assets/network-scope-0d6MoKgI.js"></script>
15
15
  <script type="module" crossorigin src="/assets/options.js"></script>
16
16
  <link rel="stylesheet" crossorigin href="/assets/theme-ChzggwXz.css">
@@ -11,9 +11,9 @@
11
11
  <script type="module" crossorigin src="/assets/session-store-M5mPmMr3.js"></script>
12
12
  <script type="module" crossorigin src="/assets/voice-shortcut-Dx863RGz.js"></script>
13
13
  <script type="module" crossorigin src="/assets/agent-store-CeC2_dkP.js"></script>
14
- <script type="module" crossorigin src="/assets/version-DLS0FCk4.js"></script>
14
+ <script type="module" crossorigin src="/assets/version-DigCzqtw.js"></script>
15
15
  <script type="module" crossorigin src="/assets/workspace-manager-CL4JvHkJ.js"></script>
16
- <script type="module" crossorigin src="/assets/context-indicator-Sf2n8eWg.js"></script>
16
+ <script type="module" crossorigin src="/assets/context-indicator-DjOAo_Ln.js"></script>
17
17
  <script type="module" crossorigin src="/assets/todo-model--JIghLks.js"></script>
18
18
  <script type="module" crossorigin src="/assets/side_panel.js"></script>
19
19
  <link rel="stylesheet" crossorigin href="/assets/theme-ChzggwXz.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-helper-agent",
3
- "version": "2.8.22",
3
+ "version": "2.8.23",
4
4
  "description": "AI Helper Agent - Local file access and system command execution proxy for Chrome extension / AI Helper 代理服务,为 Chrome 扩展提供本地文件读写和系统命令执行",
5
5
  "type": "module",
6
6
  "main": "./src/server.js",